Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
FTT_Board
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
FTT_Board
Commits
512d54cd
Commit
512d54cd
authored
May 14, 2020
by
朱天博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.车间看板
parent
74b85d07
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1199 additions
and
3 deletions
+1199
-3
FactoryBoardController.cs
...d/FTT.Board.Api/Controllers/API/FactoryBoardController.cs
+93
-0
FTT.Board.csproj
FTT.Board/FTT.Board.Api/FTT.Board.csproj
+7
-0
FTT.Board.csproj.user
FTT.Board/FTT.Board.Api/FTT.Board.csproj.user
+1
-3
Db.cs
FTT.Board/FTT.Board.Api/Models/Database/Db.cs
+110
-0
DbModule.cs
FTT.Board/FTT.Board.Api/Models/Database/DbModule.cs
+265
-0
Dbo.cs
FTT.Board/FTT.Board.Api/Models/Database/Dbo.cs
+144
-0
ModuleAttribute.cs
FTT.Board/FTT.Board.Api/Models/Database/ModuleAttribute.cs
+72
-0
FactoryBoard.cs
FTT.Board/FTT.Board.Api/Models/FactoryBoard.cs
+345
-0
Table2Model.cs
FTT.Board/FTT.Board.Api/Models/Table2Model.cs
+161
-0
Web.config
FTT.Board/FTT.Board.Api/Web.config
+1
-0
No files found.
FTT.Board/FTT.Board.Api/Controllers/API/FactoryBoardController.cs
0 → 100644
View file @
512d54cd
using
FTT.Board.Common
;
using
FTT.Board.Models
;
using
FttCloud.Public.Database
;
using
Newtonsoft.Json
;
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Linq
;
using
System.Net
;
using
System.Net.Http
;
using
System.Web.Http
;
namespace
FTT.Board.Controllers.API
{
public
class
FactoryBoardController
:
ApiController
{
public
ModuleModel
ModuleName
=>
ModuleModel
.
MES
;
public
FactoryBoardZCResponse
GetZC
(
int
FactoryWorkShopTeamID
)
{
FactoryBoardZCResponse
model
=
new
FactoryBoardZCResponse
();
DataSet
dataSet
=
Dbo
.
Create
(
ModuleName
).
GetDataSet
(
"[SP_MES_FactoryWageBoardZC]"
,
new
{
WorkTeamID
=
FactoryWorkShopTeamID
},
true
);
model
.
UserWageRanking
=
Table2Model
.
ToModelList
<
UserWageRanking
>(
dataSet
.
Tables
[
0
]);
model
.
ConstantlyWage
=
Table2Model
.
ToModelList
<
ConstantlyWage
>(
dataSet
.
Tables
[
1
]);
model
.
ZCFactoryWageInfo
=
Table2Model
.
ToModel
<
ZCFactoryWageInfo
>(
dataSet
.
Tables
[
2
]);
model
.
MonthStar
=
Table2Model
.
ToModel
<
MonthStar
>(
dataSet
.
Tables
[
3
]);
model
.
MonthStarIEPercent
=
Table2Model
.
ToModelList
<
MonthStarIEPercent
>(
dataSet
.
Tables
[
4
]);
model
.
DayYield
=
(
int
)
dataSet
.
Tables
[
5
].
Rows
[
0
][
0
];
return
model
;
}
public
FactoryBoardCXResponse
GetCX
(
int
FactoryWorkShopTeamID
)
{
FactoryBoardCXResponse
model
=
new
FactoryBoardCXResponse
();
DataSet
dataSet
=
Dbo
.
Create
(
ModuleName
).
GetDataSet
(
"[SP_MES_FactoryWageBoardZC]"
,
new
{
WorkTeamID
=
FactoryWorkShopTeamID
},
true
);
model
.
UserWageRanking
=
Table2Model
.
ToModelList
<
UserWageRanking
>(
dataSet
.
Tables
[
0
]);
model
.
ConstantlyInspection
=
Table2Model
.
ToModelList
<
ConstantlyInspection
>(
dataSet
.
Tables
[
1
]);
model
.
CXFactoryWageInfo
=
Table2Model
.
ToModel
<
CXFactoryWageInfo
>(
dataSet
.
Tables
[
2
]);
model
.
MonthStar
=
Table2Model
.
ToModel
<
MonthStar
>(
dataSet
.
Tables
[
3
]);
model
.
MonthStarIEPercent
=
Table2Model
.
ToModelList
<
MonthStarIEPercent
>(
dataSet
.
Tables
[
4
]);
model
.
DayYield
=
(
int
)
dataSet
.
Tables
[
5
].
Rows
[
0
][
0
];
return
model
;
}
public
FactoryBoardZCResponse
PostZC
(
FactoryBoardRepuest
value
)
{
FactoryBoardZCResponse
model
=
new
FactoryBoardZCResponse
();
DataSet
dataSet
=
Dbo
.
Create
(
ModuleName
).
GetDataSet
(
"[SP_MES_FactoryWageBoardZC]"
,
new
{
WorkTeamID
=
value
.
FactoryWorkShopTeamID
,
PageIndex
=
value
.
PageIndex
,
PageSize
=
value
.
PageSize
},
true
);
model
.
UserWageRanking
=
Table2Model
.
ToModelList
<
UserWageRanking
>(
dataSet
.
Tables
[
0
]);
model
.
ConstantlyWage
=
Table2Model
.
ToModelList
<
ConstantlyWage
>(
dataSet
.
Tables
[
1
]);
model
.
ZCFactoryWageInfo
=
Table2Model
.
ToModel
<
ZCFactoryWageInfo
>(
dataSet
.
Tables
[
2
]);
model
.
MonthStar
=
Table2Model
.
ToModel
<
MonthStar
>(
dataSet
.
Tables
[
3
]);
model
.
MonthStarIEPercent
=
Table2Model
.
ToModelList
<
MonthStarIEPercent
>(
dataSet
.
Tables
[
4
]);
model
.
DayYield
=
(
int
)
dataSet
.
Tables
[
5
].
Rows
[
0
][
0
];
return
model
;
}
public
FactoryBoardCXResponse
PostCX
(
FactoryBoardRepuest
value
)
{
FactoryBoardCXResponse
model
=
new
FactoryBoardCXResponse
();
DataSet
dataSet
=
Dbo
.
Create
(
ModuleName
).
GetDataSet
(
"[SP_MES_FactoryWageBoardZC]"
,
new
{
WorkTeamID
=
value
.
FactoryWorkShopTeamID
,
PageIndex
=
value
.
PageIndex
,
PageSize
=
value
.
PageSize
},
true
);
model
.
UserWageRanking
=
Table2Model
.
ToModelList
<
UserWageRanking
>(
dataSet
.
Tables
[
0
]);
model
.
ConstantlyInspection
=
Table2Model
.
ToModelList
<
ConstantlyInspection
>(
dataSet
.
Tables
[
1
]);
model
.
CXFactoryWageInfo
=
Table2Model
.
ToModel
<
CXFactoryWageInfo
>(
dataSet
.
Tables
[
2
]);
model
.
MonthStar
=
Table2Model
.
ToModel
<
MonthStar
>(
dataSet
.
Tables
[
3
]);
model
.
MonthStarIEPercent
=
Table2Model
.
ToModelList
<
MonthStarIEPercent
>(
dataSet
.
Tables
[
4
]);
model
.
DayYield
=
(
int
)
dataSet
.
Tables
[
5
].
Rows
[
0
][
0
];
return
model
;
}
}
}
\ No newline at end of file
FTT.Board/FTT.Board.Api/FTT.Board.csproj
View file @
512d54cd
...
...
@@ -164,6 +164,7 @@
<Compile
Include=
"Areas\HelpPage\SampleGeneration\TextSample.cs"
/>
<Compile
Include=
"Areas\HelpPage\XmlDocumentationProvider.cs"
/>
<Compile
Include=
"Controllers\API\CFG\CFG_BoardController.cs"
/>
<Compile
Include=
"Controllers\API\FactoryBoardController.cs"
/>
<Compile
Include=
"Controllers\ChartController.cs"
/>
<Compile
Include=
"Controllers\API\CFG\CFG_BoardDetailController.cs"
/>
<Compile
Include=
"Controllers\HomeController.cs"
/>
...
...
@@ -171,7 +172,13 @@
<Compile
Include=
"Global.asax.cs"
>
<DependentUpon>
Global.asax
</DependentUpon>
</Compile>
<Compile
Include=
"Models\Database\Db.cs"
/>
<Compile
Include=
"Models\Database\DbModule.cs"
/>
<Compile
Include=
"Models\Database\Dbo.cs"
/>
<Compile
Include=
"Models\Database\ModuleAttribute.cs"
/>
<Compile
Include=
"Models\FactoryBoard.cs"
/>
<Compile
Include=
"Models\MsSqlDbContextWraper.cs"
/>
<Compile
Include=
"Models\Table2Model.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
</ItemGroup>
<ItemGroup>
...
...
FTT.Board/FTT.Board.Api/FTT.Board.csproj.user
View file @
512d54cd
...
...
@@ -45,9 +45,7 @@
<AutoAssignPort>
True
</AutoAssignPort>
<DevelopmentServerPort>
52959
</DevelopmentServerPort>
<DevelopmentServerVPath>
/
</DevelopmentServerVPath>
<IISUrl>
http://localhost/FTT.Board
</IISUrl>
<OverrideIISAppRootUrl>
True
</OverrideIISAppRootUrl>
<IISAppRootUrl>
http://localhost/FTT.Board
</IISAppRootUrl>
<IISUrl>
http://localhost:8080/FTT.Board
</IISUrl>
<NTLMAuthentication>
False
</NTLMAuthentication>
<UseCustomServer>
False
</UseCustomServer>
<CustomServerUrl>
...
...
FTT.Board/FTT.Board.Api/Models/Database/Db.cs
0 → 100644
View file @
512d54cd
using
System
;
using
System.Collections.Generic
;
using
System.Configuration
;
using
System.Data
;
using
System.Data.SqlClient
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading
;
namespace
FttCloud.Public.Database
{
public
static
class
Db
{
/// <summary>
/// 数据库连接字符串默认Key
/// </summary>
public
static
readonly
string
CONNECTION_STRING_DEFAULT_KEY
=
"db"
;
private
static
readonly
string
CONNECTION_STRING
=
ConfigurationManager
.
AppSettings
[
CONNECTION_STRING_DEFAULT_KEY
];
public
static
DataSet
GetDataSet
(
string
sql
,
object
paras
=
null
,
bool
isSp
=
false
)
{
using
(
var
conn
=
NewConn
())
{
//throw new Exception(conn.ConnectionString);
var
ds
=
new
DataSet
();
using
(
var
cmd
=
new
SqlCommand
(
sql
,
conn
))
{
if
(
isSp
)
cmd
.
CommandType
=
CommandType
.
StoredProcedure
;
if
(
paras
!=
null
)
{
var
properties
=
paras
.
GetType
().
GetProperties
();
foreach
(
var
property
in
properties
)
{
cmd
.
Parameters
.
AddWithValue
(
"@"
+
property
.
Name
,
property
.
GetValue
(
paras
,
null
));
}
}
using
(
var
da
=
new
SqlDataAdapter
(
cmd
))
{
da
.
Fill
(
ds
);
}
}
return
ds
;
}
}
public
static
DataTable
GetDataTable
(
string
sql
,
object
paras
=
null
,
bool
isSp
=
false
)
{
using
(
var
conn
=
NewConn
())
{
var
dt
=
new
DataTable
();
using
(
var
cmd
=
new
SqlCommand
(
sql
,
conn
))
{
if
(
isSp
)
cmd
.
CommandType
=
CommandType
.
StoredProcedure
;
if
(
paras
!=
null
)
{
var
properties
=
paras
.
GetType
().
GetProperties
();
foreach
(
var
property
in
properties
)
{
cmd
.
Parameters
.
AddWithValue
(
"@"
+
property
.
Name
,
property
.
GetValue
(
paras
,
null
));
}
}
using
(
var
da
=
new
SqlDataAdapter
(
cmd
))
{
da
.
Fill
(
dt
);
}
}
return
dt
;
}
}
public
static
SqlConnection
NewConn
()
{
var
conn
=
new
SqlConnection
(
CONNECTION_STRING
);
conn
.
Open
();
return
conn
;
}
}
}
FTT.Board/FTT.Board.Api/Models/Database/DbModule.cs
0 → 100644
View file @
512d54cd
using
System.Collections.Concurrent
;
using
System.Configuration
;
namespace
FttCloud.Public.Database
{
/// <summary>
/// 系统实体。
/// 添加系统的时候,请指定使用的数据库连接字符串key。
/// </summary>
public
enum
SystemModel
{
/// <summary>
/// MES
/// </summary>
[
SystemDbConnKeyAttribute
(
"db_mes"
)]
MES
=
0
,
/// <summary>
/// U6
/// </summary>
[
SystemDbConnKeyAttribute
(
"db_u6"
)]
U6
=
1
,
/// <summary>
/// A3分销
/// </summary>
[
SystemDbConnKeyAttribute
(
"db_a3"
)]
A3
=
2
,
/// <summary>
/// 公共库
/// </summary>
[
SystemDbConnKeyAttribute
(
"db_common"
)]
Public
=
3
,
/// <summary>
/// PDM
/// </summary>
[
SystemDbConnKeyAttribute
(
"db_pdm"
)]
PDM
=
4
,
}
/// <summary>
/// 模块实体。
/// 添加模块的时候,请指定所属系统。
/// </summary>
public
enum
ModuleModel
{
/// <summary>
/// 默认
/// </summary>
[
ModuleAttribute
(
SystemModel
.
MES
)]
Default
=
0
,
/// <summary>
/// MES 系统模块.
/// 没有定义模块的情况下,属于MES系统的功能可以划分到该模块下。
/// </summary>
[
ModuleAttribute
(
SystemModel
.
MES
)]
MES
=
1
,
/// <summary>
/// U6系统模块.
/// 没有定义模块的情况下,属于U6系统的功能可以划分到该模块下。
/// </summary>
[
ModuleAttribute
(
SystemModel
.
U6
)]
U6
=
2
,
/// <summary>
/// WMS
/// </summary>
[
ModuleAttribute
(
SystemModel
.
U6
)]
WMS
=
3
,
/// <summary>
/// 订货会,OrderMeeting
/// 属于U6,独立成模块
/// </summary>
[
ModuleAttribute
(
SystemModel
.
U6
)]
OMT
=
4
,
/// <summary>
/// A3分销默认模块
/// </summary>
[
ModuleAttribute
(
SystemModel
.
A3
)]
A3
=
5
,
/// <summary>
/// 项目管理
/// </summary>
[
ModuleAttribute
(
SystemModel
.
MES
)]
PM
=
6
,
/// <summary>
/// 官网,Official Site
/// </summary>
[
ModuleAttribute
(
SystemModel
.
Public
)]
OS
=
7
,
/// <summary>
/// PDM 系统
/// </summary>
[
ModuleAttribute
(
SystemModel
.
PDM
)]
PDM
=
8
,
}
/// <summary>
/// 系统数据库配置
/// </summary>
public
class
SysDbServerModel
{
static
ConcurrentDictionary
<
ModuleModel
,
ModuleSystemDbServerModel
>
moduleDbConn
;
static
SysDbServerModel
()
{
moduleDbConn
=
new
ConcurrentDictionary
<
ModuleModel
,
ModuleSystemDbServerModel
>();
SetModuleDbConn
();
}
/// <summary>
/// 设置模块数据库连接
/// </summary>
static
void
SetModuleDbConn
()
{
System
.
Reflection
.
FieldInfo
[]
fieldInos
=
typeof
(
ModuleModel
).
GetFields
();
foreach
(
System
.
Reflection
.
FieldInfo
info
in
fieldInos
)
{
object
[]
objs
=
info
.
GetCustomAttributes
(
typeof
(
ModuleAttribute
),
false
);
if
(
objs
==
null
||
objs
.
Length
==
0
)
continue
;
var
systemCode
=
((
ModuleAttribute
)
objs
[
0
]).
SystemModel
;
var
fieldInfo
=
typeof
(
SystemModel
).
GetField
(
systemCode
.
ToString
());
if
(
fieldInfo
==
null
||
!
fieldInfo
.
IsStatic
||
!
fieldInfo
.
IsPublic
||
fieldInfo
.
IsSpecialName
)
continue
;
object
[]
objs2
=
fieldInfo
.
GetCustomAttributes
(
typeof
(
SystemDbConnKeyAttribute
),
false
);
if
(
objs2
==
null
||
objs2
.
Length
==
0
)
continue
;
var
connKey
=
((
SystemDbConnKeyAttribute
)
objs2
[
0
]).
DbConnKey
;
var
connValue
=
ConfigurationManager
.
AppSettings
[
connKey
];
if
(
string
.
IsNullOrEmpty
(
connValue
))
connValue
=
ConfigurationManager
.
AppSettings
[
Db
.
CONNECTION_STRING_DEFAULT_KEY
];
var
module
=
(
ModuleModel
)
info
.
GetRawConstantValue
();
moduleDbConn
.
TryAdd
(
module
,
new
ModuleSystemDbServerModel
(
module
,
systemCode
,
connKey
,
connValue
));
}
}
/// <summary>
/// 获取数据库连接字符串
/// </summary>
/// <param name="module"></param>
/// <returns></returns>
public
static
string
GetConn
(
ModuleModel
module
)
{
return
moduleDbConn
[
module
].
DbConnValue
;
}
/// <summary>
/// 获取系统编码
/// </summary>
/// <param name="module"></param>
/// <returns></returns>
public
static
string
GetSysCode
(
ModuleModel
module
)
{
if
(
moduleDbConn
.
ContainsKey
(
module
))
{
ModuleSystemDbServerModel
serverModel
=
moduleDbConn
[
module
];
if
(
serverModel
!=
null
)
return
serverModel
.
SystemCode
.
ToString
();
}
return
null
;
}
}
/// <summary>
/// 系统数据实体
/// </summary>
public
class
ModuleSystemDbServerModel
{
/// <summary>
/// 模块
/// </summary>
public
ModuleModel
ModuleModel
{
get
;
private
set
;
}
/// <summary>
/// 系统
/// </summary>
public
SystemModel
SystemCode
{
get
;
private
set
;
}
/// <summary>
/// 数据库连接字符串Key
/// </summary>
public
string
DbConnKey
{
get
;
private
set
;
}
/// <summary>
/// 数据库连接字符串
/// </summary>
public
string
DbConnValue
{
get
;
private
set
;
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name="moduleModel">模块</param>
/// <param name="systemCode">所属系统</param>
/// <param name="dbConnKey">数据库连接字符串关键字</param>
/// <param name="dbConnValue">数据库连接字符串值</param>
public
ModuleSystemDbServerModel
(
ModuleModel
moduleModel
,
SystemModel
systemCode
,
string
dbConnKey
,
string
dbConnValue
)
{
this
.
ModuleModel
=
moduleModel
;
this
.
SystemCode
=
systemCode
;
this
.
DbConnKey
=
dbConnKey
;
this
.
DbConnValue
=
dbConnValue
;
}
}
}
FTT.Board/FTT.Board.Api/Models/Database/Dbo.cs
0 → 100644
View file @
512d54cd
using
Newtonsoft.Json
;
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Data.SqlClient
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
FttCloud.Public.Database
{
/// <summary>
/// 数据库操作类,
/// </summary>
public
class
Dbo
{
private
string
connectionString
;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="module">模块</param>
private
Dbo
(
ModuleModel
module
)
{
connectionString
=
SysDbServerModel
.
GetConn
(
module
);
}
/// <summary>
/// 创建Dbo 实例
/// </summary>
/// <param name="module"></param>
/// <returns></returns>
public
static
Dbo
Create
(
ModuleModel
module
)
{
return
new
Dbo
(
module
);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public
SqlConnection
NewConn
()
{
var
conn
=
new
SqlConnection
(
connectionString
);
conn
.
Open
();
return
conn
;
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <param name="paras"></param>
/// <param name="isSp"></param>
/// <returns></returns>
public
DataSet
GetDataSet
(
string
sql
,
object
paras
=
null
,
bool
isSp
=
false
)
{
using
(
var
conn
=
NewConn
())
{
var
ds
=
new
DataSet
();
using
(
var
cmd
=
new
SqlCommand
(
sql
,
conn
))
{
if
(
isSp
)
cmd
.
CommandType
=
CommandType
.
StoredProcedure
;
if
(
paras
!=
null
)
{
var
properties
=
paras
.
GetType
().
GetProperties
();
foreach
(
var
property
in
properties
)
{
cmd
.
Parameters
.
AddWithValue
(
"@"
+
property
.
Name
,
property
.
GetValue
(
paras
,
null
));
}
}
using
(
var
da
=
new
SqlDataAdapter
(
cmd
))
{
da
.
Fill
(
ds
);
}
}
return
ds
;
}
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <param name="paras"></param>
/// <param name="isSp"></param>
/// <returns></returns>
public
DataTable
GetDataTable
(
string
sql
,
object
paras
=
null
,
bool
isSp
=
false
)
{
using
(
var
conn
=
NewConn
())
{
var
dt
=
new
DataTable
();
using
(
var
cmd
=
new
SqlCommand
(
sql
,
conn
))
{
if
(
isSp
)
cmd
.
CommandType
=
CommandType
.
StoredProcedure
;
if
(
paras
!=
null
)
{
var
properties
=
paras
.
GetType
().
GetProperties
();
foreach
(
var
property
in
properties
)
{
cmd
.
Parameters
.
AddWithValue
(
"@"
+
property
.
Name
,
property
.
GetValue
(
paras
,
null
));
}
}
using
(
var
da
=
new
SqlDataAdapter
(
cmd
))
{
da
.
Fill
(
dt
);
}
}
return
dt
;
}
}
private
void
WriteLog
(
string
command
,
object
paras
)
{
var
msg
=
command
+
"\r\n"
+
(
paras
==
null
?
""
:
JsonConvert
.
SerializeObject
(
paras
));
Debug
.
WriteLine
(
msg
);
}
}
}
FTT.Board/FTT.Board.Api/Models/Database/ModuleAttribute.cs
0 → 100644
View file @
512d54cd
using
System
;
namespace
FttCloud.Public.Database
{
/// <summary>
/// 针对功能模块的属性配置信息。
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Field
|
AttributeTargets
.
Property
|
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
public
class
ModuleAttribute
:
System
.
Attribute
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="systemModel"></param>
public
ModuleAttribute
(
SystemModel
systemModel
)
{
this
.
SystemModel
=
systemModel
;
}
/// <summary>
/// 系统编码
/// </summary>
public
SystemModel
SystemModel
{
get
;
set
;
}
}
/// <summary>
/// 针对功能模块的属性配置信息。
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Field
|
AttributeTargets
.
Property
|
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
public
class
SystemDbConnKeyAttribute
:
System
.
Attribute
{
/// <summary>
/// 默认值
/// </summary>
private
string
dbConnKey
=
Db
.
CONNECTION_STRING_DEFAULT_KEY
;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="strConnKey"></param>
public
SystemDbConnKeyAttribute
(
string
strConnKey
)
{
this
.
dbConnKey
=
strConnKey
;
}
/// <summary>
/// 数据库连接关键字
/// </summary>
public
string
DbConnKey
{
get
{
return
dbConnKey
;
}
set
{
dbConnKey
=
value
;
}
}
}
}
FTT.Board/FTT.Board.Api/Models/FactoryBoard.cs
0 → 100644
View file @
512d54cd
using
Newtonsoft.Json
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Web
;
namespace
FTT.Board.Models
{
/// <summary>
/// 车间看板入参
/// </summary>
public
class
FactoryBoardRepuest
{
/// <summary>
/// 车间小组ID
/// </summary>
public
int
FactoryWorkShopTeamID
{
get
;
set
;
}
/// <summary>
/// 页码
/// </summary>
public
int
PageIndex
{
get
;
set
;
}
/// <summary>
/// 条数
/// </summary>
public
int
PageSize
{
get
;
set
;
}
}
/// <summary>
/// 针车车间看板出参
/// </summary>
public
class
FactoryBoardZCResponse
{
/// <summary>
/// 员工工资排名
/// </summary>
public
List
<
UserWageRanking
>
UserWageRanking
{
get
;
set
;
}
/// <summary>
/// 实时工资
/// </summary>
public
List
<
ConstantlyWage
>
ConstantlyWage
{
get
;
set
;
}
/// <summary>
/// 车间工资统计
/// </summary>
public
ZCFactoryWageInfo
ZCFactoryWageInfo
{
get
;
set
;
}
/// <summary>
/// 本月之星
/// </summary>
public
MonthStar
MonthStar
{
get
;
set
;
}
/// <summary>
/// 本月之星当月工序占比
/// </summary>
public
List
<
MonthStarIEPercent
>
MonthStarIEPercent
{
get
;
set
;
}
/// <summary>
/// 当日产量
/// </summary>
public
int
DayYield
{
get
;
set
;
}
public
override
string
ToString
()
{
JsonSerializerSettings
jsSettings
=
new
JsonSerializerSettings
();
jsSettings
.
ReferenceLoopHandling
=
ReferenceLoopHandling
.
Ignore
;
return
JsonConvert
.
SerializeObject
(
this
,
jsSettings
).
ToString
();
}
}
/// <summary>
/// 成型车间看板出参
/// </summary>
public
class
FactoryBoardCXResponse
{
/// <summary>
/// 员工工资排名
/// </summary>
public
List
<
UserWageRanking
>
UserWageRanking
{
get
;
set
;
}
/// <summary>
/// 实时品检明细
/// </summary>
public
List
<
ConstantlyInspection
>
ConstantlyInspection
{
get
;
set
;
}
/// <summary>
/// 成型车间工资统计
/// </summary>
public
CXFactoryWageInfo
CXFactoryWageInfo
{
get
;
set
;
}
/// <summary>
/// 本月之星
/// </summary>
public
MonthStar
MonthStar
{
get
;
set
;
}
/// <summary>
/// 本月之星当月工序占比
/// </summary>
public
List
<
MonthStarIEPercent
>
MonthStarIEPercent
{
get
;
set
;
}
/// <summary>
/// 当日产量
/// </summary>
public
int
DayYield
{
get
;
set
;
}
public
override
string
ToString
()
{
JsonSerializerSettings
jsSettings
=
new
JsonSerializerSettings
();
jsSettings
.
ReferenceLoopHandling
=
ReferenceLoopHandling
.
Ignore
;
return
JsonConvert
.
SerializeObject
(
this
,
jsSettings
).
ToString
();
}
}
/// <summary>
/// 员工工资排名
/// </summary>
public
class
UserWageRanking
{
/// <summary>
/// 员工姓名
/// </summary>
public
string
UserName
{
get
;
set
;
}
/// <summary>
/// 工资
/// </summary>
public
double
SubMoney
{
get
;
set
;
}
}
/// <summary>
/// 实时工资
/// </summary>
public
class
ConstantlyWage
{
/// <summary>
/// 时间
/// </summary>
public
string
CreateDate
{
get
;
set
;
}
/// <summary>
/// 姓名
/// </summary>
public
string
UserName
{
get
;
set
;
}
/// <summary>
/// 工序或部件名
/// </summary>
public
string
IEName
{
get
;
set
;
}
/// <summary>
/// 单价
/// </summary>
public
double
Price
{
get
;
set
;
}
/// <summary>
/// 工资
/// </summary>
public
double
SubMoney
{
get
;
set
;
}
}
/// <summary>
/// 实时品检详情
/// </summary>
public
class
ConstantlyInspection
{
/// <summary>
/// 时间
/// </summary>
public
string
CreateDate
{
get
;
set
;
}
/// <summary>
/// 货号
/// </summary>
public
string
StyleCode
{
get
;
set
;
}
/// <summary>
/// 品检项目
/// </summary>
public
string
QIItemName
{
get
;
set
;
}
/// <summary>
/// 数量
/// </summary>
public
int
Qty
{
get
;
set
;
}
/// <summary>
/// 品检类型
/// </summary>
public
string
ProcessingType
{
get
;
set
;
}
}
/// <summary>
/// 针车车间工资统计
/// </summary>
public
class
ZCFactoryWageInfo
{
/// <summary>
/// 在职员工数量
/// </summary>
public
int
OnJobCount
{
get
;
set
;
}
/// <summary>
/// 最高工资
/// </summary>
public
double
MaxWage
{
get
;
set
;
}
/// <summary>
/// 最低工资
/// </summary>
public
double
MinWage
{
get
;
set
;
}
/// <summary>
/// 平均工资
/// </summary>
public
double
AverageWage
{
get
;
set
;
}
/// <summary>
/// 排名
/// </summary>
public
int
ranking
{
get
;
set
;
}
/// <summary>
/// 本月计划
/// </summary>
public
int
MonthPlan
{
get
;
set
;
}
/// <summary>
/// 本月产量
/// </summary>
public
int
MonthYield
{
get
;
set
;
}
/// <summary>
/// 待产数量
/// </summary>
public
int
MonthWaiting
{
get
;
set
;
}
/// <summary>
/// 在产数量
/// </summary>
public
int
MonthInProduction
{
get
;
set
;
}
/// <summary>
/// 当月完成率
/// </summary>
public
string
MonthPercent
{
get
;
set
;
}
}
/// <summary>
/// 成型车间工资统计
/// </summary>
public
class
CXFactoryWageInfo
{
/// <summary>
/// 在职员工数量
/// </summary>
public
int
OnJobCount
{
get
;
set
;
}
/// <summary>
/// 最高工资
/// </summary>
public
double
MaxWage
{
get
;
set
;
}
/// <summary>
/// 最低工资
/// </summary>
public
double
MinWage
{
get
;
set
;
}
/// <summary>
/// 平均工资
/// </summary>
public
double
AverageWage
{
get
;
set
;
}
/// <summary>
/// 排名
/// </summary>
public
int
ranking
{
get
;
set
;
}
/// <summary>
/// 昨日遗留
/// </summary>
public
int
YesterDayMargin
{
get
;
set
;
}
/// <summary>
/// 当日计划
/// </summary>
public
int
DayPlan
{
get
;
set
;
}
/// <summary>
/// 当日完成率
/// </summary>
public
string
DayPercent
{
get
;
set
;
}
/// <summary>
/// 不合格数量
/// </summary>
public
int
UnInspectionQty
{
get
;
set
;
}
/// <summary>
/// 合格率
/// </summary>
public
string
InspectionPercent
{
get
;
set
;
}
}
/// <summary>
/// 本月之星
/// </summary>
public
class
MonthStar
{
/// <summary>
/// 员工编号
/// </summary>
public
string
UserCode
{
get
;
set
;
}
/// <summary>
/// 员工姓名
/// </summary>
public
string
UserName
{
get
;
set
;
}
}
/// <summary>
/// 本月之星当月工序占比
/// </summary>
public
class
MonthStarIEPercent
{
/// <summary>
/// 工序或部件名
/// </summary>
public
string
IEName
{
get
;
set
;
}
/// <summary>
/// 占比
/// </summary>
public
string
IENamePercent
{
get
;
set
;
}
}
}
\ No newline at end of file
FTT.Board/FTT.Board.Api/Models/Table2Model.cs
0 → 100644
View file @
512d54cd
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Linq
;
namespace
FTT.Board.Common
{
/// <summary>
/// DataTable转成实体
/// </summary>
public
static
class
Table2Model
{
#
region
公共方法
(
扩展
DataTable
)
/// <summary>
/// DataTable转换成T
/// </summary>
/// <typeparam name="T">实体类型</typeparam>
/// <param name="table">需转换的数据table</param>
/// <returns></returns>
public
static
T
ToModel
<
T
>(
this
DataTable
table
)
where
T
:
new
()
{
if
(
table
==
null
||
table
.
Columns
.
Count
==
0
||
table
.
Rows
.
Count
==
0
)
return
default
(
T
);
var
propertyInfos
=
from
propertyInfo
in
typeof
(
T
).
GetProperties
()
where
table
.
Columns
.
Contains
(
propertyInfo
.
Name
)
select
propertyInfo
;
return
DataRowToModel
<
T
>(
propertyInfos
,
table
.
Rows
[
0
]);
//T entity = new T();
//DataRow dr = table.Rows[0];
//foreach (var pi in propertyInfos)
//{
// if (!pi.CanWrite) continue;
// object value = dr[pi.Name];
// if (value != DBNull.Value)
// pi.SetValue(entity, ChangeType(dr[pi.Name], pi.PropertyType), null);
//}
//return entity;
}
/// <summary>
/// DataTable转换成List<T>
/// </summary>
/// <typeparam name="T">实体类型</typeparam>
/// <param name="table">需转换的数据table</param>
/// <returns></returns>
public
static
List
<
T
>
ToModelList
<
T
>(
this
DataTable
table
)
where
T
:
new
()
{
List
<
T
>
entities
=
new
List
<
T
>();
if
(
table
==
null
||
table
.
Columns
.
Count
==
0
||
table
.
Rows
.
Count
==
0
)
return
entities
;
var
propertyInfos
=
from
propertyInfo
in
typeof
(
T
).
GetProperties
()
where
table
.
Columns
.
Contains
(
propertyInfo
.
Name
)
select
propertyInfo
;
foreach
(
DataRow
dr
in
table
.
Rows
)
{
entities
.
Add
(
DataRowToModel
<
T
>(
propertyInfos
,
dr
));
}
return
entities
;
//foreach (DataRow dr in table.Rows)
//{
// T entity = new T();
// foreach (var pi in propertyInfos)
// {
// if (!pi.CanWrite) continue;
// object value = dr[pi.Name];
// if (value != DBNull.Value)
// pi.SetValue(entity, ChangeType(dr[pi.Name], pi.PropertyType), null);
// }
// entities.Add(entity);
//}
//return entities;
}
#
endregion
公共方法
(
扩展
DataTable
)
#
region
私有方法
(
Convert
.
ChangeType
处理
Nullable
<>
和非
Nullable
<>)
private
static
T
DataRowToModel
<
T
>(
IEnumerable
<
System
.
Reflection
.
PropertyInfo
>
propertyInfos
,
DataRow
dataRow
)
where
T
:
new
()
{
T
entity
=
new
T
();
foreach
(
var
pi
in
propertyInfos
)
{
if
(!
pi
.
CanWrite
)
continue
;
object
value
=
dataRow
[
pi
.
Name
];
if
(
value
!=
DBNull
.
Value
||
pi
.
PropertyType
==
typeof
(
string
))
// 为null的字符串需要转化为""
pi
.
SetValue
(
entity
,
ChangeType
(
dataRow
[
pi
.
Name
],
pi
.
PropertyType
),
null
);
}
return
entity
;
}
/// <summary>
/// 类型转换(包含Nullable<>和非Nullable<>转换)
/// </summary>
/// <param name="value"></param>
/// <param name="conversionType"></param>
/// <returns></returns>
private
static
object
ChangeType
(
object
value
,
Type
conversionType
)
{
// Note: This if block was taken from Convert.ChangeType as is, and is needed here since we're
// checking properties on conversionType below.
if
(
conversionType
==
null
)
{
throw
new
ArgumentNullException
(
"conversionType"
);
}
// end if
// If it's not a nullable type, just pass through the parameters to Convert.ChangeType
if
(
conversionType
.
IsGenericType
&&
conversionType
.
GetGenericTypeDefinition
().
Equals
(
typeof
(
Nullable
<>)))
{
if
(
value
==
null
)
{
return
null
;
}
// It's a nullable type, and not null, so that means it can be converted to its underlying type,
// so overwrite the passed-in conversion type with this underlying type
System
.
ComponentModel
.
NullableConverter
nullableConverter
=
new
System
.
ComponentModel
.
NullableConverter
(
conversionType
);
conversionType
=
nullableConverter
.
UnderlyingType
;
}
// Now that we've guaranteed conversionType is something Convert.ChangeType can handle (i.e. not a
// nullable type), pass the call on to Convert.ChangeType
return
Convert
.
ChangeType
(
value
,
conversionType
);
}
#
endregion
私有方法
(
Convert
.
ChangeType
处理
Nullable
<>
和非
Nullable
<>)
}
}
FTT.Board/FTT.Board.Api/Web.config
View file @
512d54cd
...
...
@@ -12,6 +12,7 @@
<!--<
add
key
=
"db"
value
=
"Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=FTT_Board;Data Source=192.168.1.204"
/>-->
<
add
key
=
"db"
value
=
"Password=a*1;Persist Security Info=True;User ID=sa;Initial Catalog=FTT_MES;Data Source=122.226.244.210,1800"
/>
<
add
key
=
"db_mes"
value
=
"Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=FTT_MES;Data Source=192.168.1.201"
/>
</
appSettings
>
<
connectionStrings
>
<
add
name
=
"BoardModelContainer"
connectionString
=
"metadata=res://*/BoardModel.csdl|res://*/BoardModel.ssdl|res://*/BoardModel.msl;provider=System.Data.SqlClient;provider connection string="data source=192.168.1.204;initial catalog=FTT_Board;persist security info=True;user id=sa;password=sa;MultipleActiveResultSets=True;App=EntityFramework""
providerName
=
"System.Data.EntityClient"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment