Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
JPSMysql
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
zxw
JPSMysql
Commits
d999d5ab
Commit
d999d5ab
authored
Nov 10, 2022
by
zxw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
杭州自建平台 分支重整
parent
d1103367
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
688 行增加
和
18 行删除
+688
-18
ChannelCfgController.cs
JunmpPoliceStation/Controllers/ChannelCfgController.cs
+33
-1
FixReceiveApplyController.cs
JunmpPoliceStation/Controllers/FixReceiveApplyController.cs
+200
-0
InventoryController.cs
JunmpPoliceStation/Controllers/InventoryController.cs
+188
-0
OrganizationController.cs
JunmpPoliceStation/Controllers/OrganizationController.cs
+1
-1
ProcessController.cs
JunmpPoliceStation/Controllers/ProcessController.cs
+25
-3
TjController.cs
JunmpPoliceStation/Controllers/TjController.cs
+140
-10
ViewController.cs
JunmpPoliceStation/Controllers/ViewController.cs
+13
-1
CronJob.cs
JunmpPoliceStation/Extensions/CronJob.cs
+47
-0
HttpHelper.cs
JunmpPoliceStation/Extensions/HttpHelper.cs
+38
-0
Startup.cs
JunmpPoliceStation/Startup.cs
+3
-2
没有找到文件。
JunmpPoliceStation/Controllers/ChannelCfgController.cs
View file @
d999d5ab
...
...
@@ -48,9 +48,11 @@ namespace JunmpPoliceStation.Controllers
private
ILogger
<
ChannelCfgController
>
_logger
;
private
UnitOfWork
_unitOfWork
;
protected
MQTTServer
mqttServer
;
private
HttpHelper
_httpHelper
;
public
ChannelCfgController
(
ILogger
<
ChannelCfgController
>
logger
,
INacosNamingClient
serverManager2
,
INacosServerManager
serverManager
,
IHttpClientFactory
clientFactory
,
UnitOfWork
unitOfWork
,
IWebHostEnvironment
_hostingEnvironment
,
MQTTServer
mqttServer
)
public
ChannelCfgController
(
ILogger
<
ChannelCfgController
>
logger
,
INacosNamingClient
serverManager2
,
INacosServerManager
serverManager
,
IHttpClientFactory
clientFactory
,
UnitOfWork
unitOfWork
,
IWebHostEnvironment
_hostingEnvironment
,
MQTTServer
mqttServer
,
HttpHelper
httpHelper
)
{
_httpHelper
=
httpHelper
;
_clientFactory
=
clientFactory
;
_serverManager2
=
serverManager2
;
_serverManager
=
serverManager
;
...
...
@@ -1270,6 +1272,36 @@ namespace JunmpPoliceStation.Controllers
}
/// <summary>
/// 获取服务器时间(远端)
/// </summary>
/// <returns></returns>
[
HttpGet
(
"GetRemoteServerTime"
)]
public
async
Task
<
HttpResponseMessage
>
GetRemoteServerTime
()
{
return
await
Task
.
Run
(()
=>
{
var
httpResult
=
_httpHelper
.
GetHtml
(
new
HttpItem
()
{
URL
=
_httpHelper
.
_centerServerAddress
+
"/api/ChannelCfg/GetServerTime"
,
Encoding
=
Encoding
.
UTF8
,
Method
=
"GET"
,
ContentType
=
"application/json"
,
Timeout
=
5000
,
});
if
(
httpResult
.
StatusCode
!=
HttpStatusCode
.
OK
||
string
.
IsNullOrEmpty
(
httpResult
.
Html
))
{
return
JsonManager
.
SimpleCustResponse
(
"远端上报数据失败"
);
}
var
obj
=
JsonConvert
.
DeserializeObject
<
JmpBaseResponse
<
object
>>(
httpResult
.
Html
);
if
(
obj
.
code
!=
"10000"
)
{
return
JsonManager
.
SimpleCustResponse
(
obj
.
msg
);
}
return
JsonManager
.
ReturnSuccessResponse
(
obj
.
data
);
});
}
/// <summary>
/// 同步用户账号
/// </summary>
/// <returns></returns>
...
...
JunmpPoliceStation/Controllers/FixReceiveApplyController.cs
View file @
d999d5ab
差异被折叠。
点击展开。
JunmpPoliceStation/Controllers/InventoryController.cs
View file @
d999d5ab
...
...
@@ -4876,6 +4876,194 @@ namespace JunmpPoliceStation.Controllers
}
/// <summary>
/// 获取本组织机构物资信息(供应商聚合)
/// </summary>
/// <remarks>
///
/// ## 例子
///
/// {
/// "size":10,
/// "page":0,
/// "orgId":"当前组织机构代码",
/// "warehouseId":"选择的仓库代码",
/// "equipmentId":"装备名称",
/// "equipmentSizeId":"装备型号"
/// "supplierId":"供应商id"
/// "shelfId":"货架id",
/// "range":"货架排位置"
/// "row":"货架行位置",
/// "column":"货架列位置",
/// "orderby":"排序字段 warrantyCycle:质保期",
/// "sort":"排序模式 asc desc",
/// }
///
/// </remarks>
/// <param name="jdata"></param>
/// <returns></returns>
[
HttpPost
(
"GetListEquipmentByOrgGroupBySupplier"
)]
public
async
Task
<
HttpResponseMessage
>
GetListEquipmentByOrgGroupBySupplier
([
FromBody
]
JObject
jdata
)
{
return
await
Task
.
Run
(()
=>
{
try
{
if
(
jdata
!=
null
)
{
var
entity
=
JsonManager
.
GetJsonEntity
(
jdata
);
string
orgCode
=
entity
.
orgId
;
int
.
TryParse
(
entity
.
page
,
out
int
page
);
int
.
TryParse
(
entity
.
size
,
out
int
size
);
if
(
size
==
0
)
{
size
=
10
;
}
string
OrgId
=
Guid
.
Empty
.
ToString
();
if
(
String
.
IsNullOrEmpty
(
entity
.
orgId
))
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
else
{
OrgId
=
entity
.
orgId
;
}
var
param
=
new
string
[]
{
"EquipmentSizecodeNavigation"
,
"EquipmentCodeNavigation"
,
"WarehouseCodeNavigation"
,
"WarehouseCodeNavigation.Orgization"
,
"SupplierCodeNavigation"
};
Expression
<
Func
<
CommonJpEquipmentInventory
,
bool
>>
expression
=
t
=>
OrgId
.
Equals
(
t
.
WarehouseCodeNavigation
.
OrgizationId
);
expression
=
LambdaExtensions
.
AndAlso
(
expression
,
t
=>
t
.
InventoryState
!=
"loss"
);
//orgList.Add(orgInfo.Id);//查询所有组织机构仓库库存信息
if
(!
String
.
IsNullOrEmpty
(
entity
.
warehouseId
))
{
string
warehouseId
=
entity
.
warehouseId
;
expression
=
LambdaExtensions
.
AndAlso
(
expression
,
t
=>
t
.
WarehouseCode
.
Equals
(
warehouseId
));
}
//装备名称
if
(!
String
.
IsNullOrEmpty
(
entity
.
equipmentId
))
{
string
equipmentId
=
entity
.
equipmentId
;
expression
=
LambdaExtensions
.
AndAlso
(
expression
,
t
=>
t
.
EquipmentCode
.
Contains
(
equipmentId
));
}
//装备型号
if
(!
String
.
IsNullOrEmpty
(
entity
.
equipmentSizeId
))
{
string
equipmentSizeId
=
entity
.
equipmentSizeId
;
expression
=
LambdaExtensions
.
AndAlso
(
expression
,
t
=>
t
.
EquipmentSizecode
.
Contains
(
equipmentSizeId
));
}
//供应商
if
(!
String
.
IsNullOrEmpty
(
entity
.
supplierId
))
{
string
supplierId
=
entity
.
supplierId
;
expression
=
LambdaExtensions
.
AndAlso
(
expression
,
t
=>
t
.
SupplierCode
.
Contains
(
supplierId
));
}
if
(!
string
.
IsNullOrEmpty
(
entity
.
shelfId
))
{
string
shelfId
=
entity
.
shelfId
;
expression
=
expression
.
AndAlso
(
t
=>
t
.
ShelfId
==
shelfId
);
if
(
int
.
TryParse
(
entity
.
range
,
out
int
range
)
&&
range
>
0
)
{
expression
=
expression
.
AndAlso
(
t
=>
t
.
ShelfRange
==
range
);
}
if
(
int
.
TryParse
(
entity
.
row
,
out
int
row
)
&&
row
>
0
)
{
expression
=
expression
.
AndAlso
(
t
=>
t
.
ShelfRow
==
row
);
}
if
(
int
.
TryParse
(
entity
.
column
,
out
int
column
)
&&
column
>
0
)
{
expression
=
expression
.
AndAlso
(
t
=>
t
.
ShelfColumn
==
column
);
}
}
var
EquipmentList
=
_unitOfWork
.
EquipmentInventoryRepository
.
GetList
(
expression
,
null
,
false
,
param
).
ToList
();
//var EquipmentList = _unitOfWork.EquipmentInventoryRepository.GetGroupPage(expression,t => new { t.WarehouseCode,t.EquipmentCode,t.EquipmentSizecode },"", page,size, false, param);
var
datas
=
EquipmentList
.
GroupBy
(
p
=>
new
{
p
.
WarehouseCode
,
p
.
EquipmentCode
,
p
.
EquipmentSizecode
,
p
.
SupplierCode
,
p
.
WarrantyCycle
})
.
Select
(
x
=>
new
{
id
=
x
.
Key
.
WarehouseCode
+
x
.
Key
.
EquipmentSizecode
,
warehouseName
=
x
.
FirstOrDefault
().
WarehouseCodeNavigation
?.
Name
,
equipmentName
=
x
.
FirstOrDefault
().
EquipmentCodeNavigation
?.
Name
,
warehouseId
=
x
.
FirstOrDefault
().
WarehouseCodeNavigation
?.
Id
,
equipmentSizeName
=
x
.
FirstOrDefault
().
EquipmentSizecodeNavigation
?.
SizeName
,
equipmentSizeId
=
x
.
FirstOrDefault
().
EquipmentSizecodeNavigation
?.
Id
,
supplierCode
=
x
.
FirstOrDefault
().
SupplierCode
,
supplierName
=
x
.
FirstOrDefault
().
SupplierCodeNavigation
?.
Name
,
warrantyCycle
=
x
.
FirstOrDefault
().
WarrantyCycle
,
sumCount
=
x
.
Count
(),
zkCount
=
x
.
Count
(
c
=>
c
.
CurrentState
.
Equals
(
3
)
||
c
.
CurrentState
.
Equals
(
0
)),
ckCount
=
x
.
Count
(
c
=>
!(
c
.
CurrentState
.
Equals
(
3
)
||
c
.
CurrentState
.
Equals
(
0
)
||
c
.
CurrentState
.
Equals
(
6
))),
bfCount
=
x
.
Count
(
c
=>
c
.
CurrentState
.
Equals
(
6
))
})
.
OrderBy
(
c
=>
c
.
equipmentName
)
.
ThenBy
(
c
=>
c
.
equipmentSizeName
);
if
(
entity
.
orderby
==
"warrantyCycle"
)
{
if
(
entity
.
sort
==
"desc"
)
{
datas
=
datas
.
OrderByDescending
(
x
=>
x
.
warrantyCycle
)
.
ThenBy
(
x
=>
x
.
equipmentName
)
.
ThenBy
(
x
=>
x
.
equipmentSizeName
);
}
else
{
datas
=
datas
.
OrderBy
(
x
=>
x
.
warrantyCycle
)
.
ThenBy
(
x
=>
x
.
equipmentName
)
.
ThenBy
(
x
=>
x
.
equipmentSizeName
);
}
}
var
content
=
new
{
totalElements
=
datas
.
Count
(),
content
=
datas
.
Skip
(
page
*
size
).
Take
(
size
).
ToList
()
};
return
JsonManager
.
ReturnSuccessResponse
(
content
);
// return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
else
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
}
catch
(
Exception
ex
)
{
//_logger.LogError("Login/SignIn 错误:" + ex.ToString());
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
OPERATE_FAILED
);
}
});
}
/// <summary>
/// 获取织机构物资信息
/// </summary>
/// <remarks>
...
...
JunmpPoliceStation/Controllers/OrganizationController.cs
View file @
d999d5ab
...
...
@@ -1144,7 +1144,7 @@ namespace JunmpPoliceStation.Controllers
{
org
.
OrderCount
++;
}
order
.
PrintOrderCode
=
DateTime
.
Now
.
Year
+
"-类"
+
org
.
OrderCount
.
Value
.
ToString
(
"D5"
)
+
"号"
;
order
.
PrintOrderCode
=
"类"
+
DateTime
.
Now
.
Year
+
"-"
+
org
.
OrderCount
.
Value
.
ToString
(
"D5"
)
;
order
.
PrintOrderTime
=
DateTime
.
Now
;
printOrderCode
=
order
.
PrintOrderCode
;
printOrderTime
=
order
.
PrintOrderTime
.
Value
.
ToString
(
"yyyy年MM月dd日"
);
...
...
JunmpPoliceStation/Controllers/ProcessController.cs
View file @
d999d5ab
...
...
@@ -853,7 +853,7 @@ namespace JunmpPoliceStation.Controllers
});
}
/// <summary>
/// 获取全部待审核订单列表
/// 获取全部待审核订单列表
(杭州自建平台)
/// </summary>
/// <remarks>
/// ## 例子
...
...
@@ -864,6 +864,8 @@ namespace JunmpPoliceStation.Controllers
/// "orgId":"组织机构ID",
/// "size":10,
/// "page":0,
/// "type":"出库单 入库单",
/// "orderType":""
/// }
///
/// </remarks>
...
...
@@ -884,6 +886,8 @@ namespace JunmpPoliceStation.Controllers
string
userId
=
string
.
Empty
;
string
orgId
=
string
.
Empty
;
string
orderCode
=
entity
.
orderCode
??
""
;
string
type
=
entity
.
type
??
""
;
string
orderType
=
entity
.
orderType
??
""
;
if
(
entity
==
null
)
{
...
...
@@ -930,10 +934,28 @@ namespace JunmpPoliceStation.Controllers
var
orderList
=
_unitOfWork
.
ViewAllOrderRepository
.
GetList
(
expression
,
null
,
false
,
param
).
OrderByDescending
(
p
=>
p
.
UpdateTime
);
List
<
ViewAllOrder
>
resData
=
new
List
<
ViewAllOrder
>();
if
(
type
==
"出库单"
)
{
//借用、报废、调拨出库、维修
resData
=
orderList
.
Where
(
x
=>
x
.
FlowName
==
"本库借用流程"
||
x
.
FlowName
==
"报废流程"
||
x
.
FlowName
==
"调拨下发流程"
||
x
.
FlowName
==
"维修流程"
||
(
x
.
FlowName
==
"调拨申请流程"
&&
x
.
DataScope
==
"上级"
)).
ToList
();
}
if
(
type
==
"入库单"
)
{
//采购、调拨入库
resData
=
orderList
.
Where
(
x
=>
x
.
FlowName
==
"采购流程"
||
x
.
FlowName
==
"装备回库流程"
||
(
x
.
FlowName
==
"调拨申请流程"
&&
x
.
DataScope
==
"本级"
)).
ToList
();
}
if
(!
string
.
IsNullOrEmpty
(
orderType
))
{
var
arr
=
orderType
.
Split
(
","
);
resData
=
resData
.
Where
(
x
=>
arr
.
Contains
(
x
.
FlowName
)).
ToList
();
}
var
orderValue
=
new
{
totalElements
=
orderList
.
Count
()
,
content
=
orderList
.
Skip
(
page
*
size
).
Take
(
size
).
ToList
()
totalElements
=
resData
.
Count
,
content
=
resData
.
Skip
(
page
*
size
).
Take
(
size
).
ToList
()
};
var
orderContent
=
new
{
...
...
JunmpPoliceStation/Controllers/TjController.cs
View file @
d999d5ab
...
...
@@ -1001,7 +1001,7 @@ namespace JunmpPoliceStation.Controllers
{
FindCode
=
c
.
FirstOrDefault
().
FindCode
,
OrgName
=
codeLen
<
6
?
ListEq
.
FirstOrDefault
(
x
=>
x
.
Code
==
c
.
FirstOrDefault
().
FindCode
.
Substring
(
0
,
codeLen
).
PadRight
(
12
,
'0'
)).
AreaName
ListEq
.
FirstOrDefault
(
x
=>
x
.
Code
==
c
.
FirstOrDefault
().
FindCode
.
Substring
(
0
,
codeLen
).
PadRight
(
12
,
'0'
)).
AreaName
:
c
.
FirstOrDefault
().
AreaName
,
c
.
FirstOrDefault
().
OrgCode
,
yearStartCount
=
c
.
Count
(
f
=>
!
f
.
CurrentState
.
Equals
(
6
)
&&
f
.
CreateTime
?.
Year
<
year
),
...
...
@@ -1303,15 +1303,15 @@ namespace JunmpPoliceStation.Controllers
.
OrderBy
(
c
=>
c
.
TypeOneId
).
ThenBy
(
c
=>
c
.
TypeTwoId
).
ThenBy
(
c
=>
c
.
TypeThreeId
).
ToList
();
var
data
=
equipmentList
.
GroupBy
(
t
=>
new
{
t
.
TypeOneId
,
t
.
EquipmentCode
,
t
.
Price
,
t
.
EquipmentSizecode
}).
Select
(
c
=>
new
{
id
=
c
.
FirstOrDefault
().
TypeOneId
,
ParentName
=
c
.
FirstOrDefault
().
Name
,
EquipmentName
=
c
.
FirstOrDefault
().
EquipmentName
,
SizeName
=
c
.
FirstOrDefault
().
SizeName
,
zsCount
=
c
.
Count
(
f
=>
f
.
CurrentState
!=
null
),
Price
=
c
.
FirstOrDefault
().
Price
,
sumPrice
=
c
.
Count
(
f
=>
f
.
CurrentState
!=
null
)
*
c
.
Key
.
Price
,
}
{
id
=
c
.
FirstOrDefault
().
TypeOneId
,
ParentName
=
c
.
FirstOrDefault
().
Name
,
EquipmentName
=
c
.
FirstOrDefault
().
EquipmentName
,
SizeName
=
c
.
FirstOrDefault
().
SizeName
,
zsCount
=
c
.
Count
(
f
=>
f
.
CurrentState
!=
null
),
Price
=
c
.
FirstOrDefault
().
Price
,
sumPrice
=
c
.
Count
(
f
=>
f
.
CurrentState
!=
null
)
*
c
.
Key
.
Price
,
}
).
ToList
();
return
JsonManager
.
ReturnSuccessResponse
(
data
);
...
...
@@ -1496,6 +1496,136 @@ namespace JunmpPoliceStation.Controllers
});
}
/// <summary>
/// 数据统计-条件查询 将同品牌、同型号、同厂家的归为1条数据展示,增加数量显示
/// </summary>
/// <remarks>
///
/// ## 例子
///
/// {
/// "page": "0",
/// "size": "10",
/// "level":"本级、本级及下级",
/// "orgId":"组织机构ID",
/// "orderBy":"质保期升降序 asc desc 默认asc",
/// "supplierId":"供应商id",
/// }
///
/// </remarks>
/// <param name="jdata"></param>
/// <returns></returns>
[
HttpPost
(
"GetPageZBTJ"
)]
[
NoSignAttribute
]
public
async
Task
<
HttpResponseMessage
>
GetPageZBTJ
([
FromBody
]
JObject
jdata
)
{
return
await
Task
.
Run
(()
=>
{
try
{
if
(
jdata
!=
null
)
{
var
entity
=
JsonManager
.
GetJsonEntity
(
jdata
);
int
.
TryParse
(
entity
.
page
,
out
int
page
);
int
.
TryParse
(
entity
.
size
,
out
int
size
);
if
(
size
==
0
)
{
size
=
10
;
}
Expression
<
Func
<
BaseJpOrganization
,
bool
>>
expression
=
t
=>
t
.
State
==
1
;
ListEq
=
_unitOfWork
.
OrganizationRepository
.
GetList
(
expression
,
t
=>
t
.
Code
).
ToList
();
string
orgizationCode
=
Guid
.
Empty
.
ToString
();
List
<
BaseJpOrganization
>
dataList
=
null
;
if
(!
String
.
IsNullOrEmpty
(
entity
.
orgId
))
{
orgizationCode
=
entity
.
orgId
;
}
Expression
<
Func
<
CommonJpEquipmentInventory
,
bool
>>
expressionPoliceman
=
t
=>
t
.
InventoryState
!=
"loss"
;
string
supplierId
=
entity
.
supplierId
??
""
;
string
orderBy
=
entity
.
orderBy
??
"asc"
;
string
level
=
entity
.
level
??
""
;
if
(
level
==
"本级"
)
{
expressionPoliceman
=
expressionPoliceman
.
AndAlso
(
t
=>
t
.
WarehouseCodeNavigation
.
OrgizationId
.
Equals
(
orgizationCode
));
}
else
{
dataList
=
GetClassID
(
orgizationCode
);
dataList
=
dataList
.
ToList
().
Concat
(
ListEq
.
Where
(
c
=>
c
.
Id
.
Equals
(
orgizationCode
))).
ToList
();
List
<
string
>
IdList
=
dataList
.
Select
(
c
=>
c
.
Id
).
ToList
();
expressionPoliceman
=
expressionPoliceman
.
AndAlso
(
t
=>
IdList
.
Contains
(
t
.
WarehouseCodeNavigation
.
OrgizationId
));
}
if
(!
string
.
IsNullOrEmpty
(
supplierId
))
{
expressionPoliceman
=
expressionPoliceman
.
AndAlso
(
t
=>
t
.
SupplierCode
.
Equals
(
supplierId
));
}
var
arr
=
new
[]
{
"WarehouseCodeNavigation"
,
"EquipmentCodeNavigation"
,
"EquipmentSizecodeNavigation"
,
"SupplierCodeNavigation"
,
};
var
data
=
_unitOfWork
.
EquipmentInventoryRepository
.
GetList
(
expressionPoliceman
,
includes
:
arr
)
.
GroupBy
(
x
=>
new
{
x
.
EquipmentCode
,
x
.
EquipmentSizecode
,
x
.
SupplierCode
,
x
.
WarrantyCycle
})
.
Select
(
x
=>
new
{
equipmentId
=
x
.
Key
.
EquipmentCode
,
equipmentName
=
string
.
IsNullOrEmpty
(
x
.
FirstOrDefault
().
EquipmentCodeNavigation
.
AliasName
)
?
x
.
FirstOrDefault
().
EquipmentCodeNavigation
.
Name
:
x
.
FirstOrDefault
().
EquipmentCodeNavigation
.
AliasName
,
equipmentSizeId
=
x
.
Key
.
EquipmentSizecode
,
equipmentSizeName
=
x
.
FirstOrDefault
().
EquipmentSizecodeNavigation
.
SizeName
,
supplierId
=
x
.
Key
.
SupplierCode
,
supplierName
=
x
.
FirstOrDefault
().
SupplierCodeNavigation
.
Name
,
count
=
x
.
Count
(),
warrantyCycle
=
x
.
Key
.
WarrantyCycle
,
});
if
(
orderBy
==
"asc"
)
{
data
=
data
.
OrderBy
(
x
=>
x
.
warrantyCycle
);
}
else
{
data
=
data
.
OrderByDescending
(
x
=>
x
.
warrantyCycle
);
}
return
JsonManager
.
ReturnSuccessResponse
(
new
{
totalElements
=
data
.
Count
(),
content
=
data
.
Skip
(
page
*
size
).
Take
(
size
)
});
}
else
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
}
catch
(
Exception
ex
)
{
//_logger.LogError("Login/SignIn 错误:" + ex.ToString());
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
OPERATE_FAILED
);
}
});
}
//递归取数据
private
List
<
BaseJpOrganization
>
GetClassID
(
String
id
)
...
...
JunmpPoliceStation/Controllers/ViewController.cs
View file @
d999d5ab
...
...
@@ -158,7 +158,7 @@ namespace JunmpPoliceStation.Controllers
/// <summary>
/// 总数统计(在库总量、领用总量、维修数量、报废总量、单警柜个数、仓库个数)
/// 总数统计
杭州自建
(在库总量、领用总量、维修数量、报废总量、单警柜个数、仓库个数)
/// </summary>
/// <remarks>
///
...
...
@@ -251,6 +251,16 @@ namespace JunmpPoliceStation.Controllers
x
.
OrgId
.
Contains
(
orgId
)
&&
x
.
IsOverdue
.
Contains
(
"true"
)));
}
var
thisYear
=
new
DateTime
(
DateTime
.
Now
.
Year
,
1
,
1
);
//今年出库数 今年所有出入库记录为出库的数据
var
jncksCount
=
_unitOfWork
.
EquipmentStateRepository
.
Count
(
x
=>
x
.
OrgId
==
orgId
&&
x
.
OutInState
==
0
&&
x
.
OutTime
>
thisYear
);
//今年报废数 统计今年所有报废单装备数量
var
jnbfsCount
=
_unitOfWork
.
DbContext
.
CommonJpFixReceiveApplyDetails
.
Include
(
x
=>
x
.
Order
)
.
Count
(
x
=>
x
.
Order
.
OrgId
==
orgId
&&
x
.
Order
.
CurrentState
==
1
&&
x
.
State
==
1
&&
x
.
Order
.
CreateTime
>
thisYear
);
var
reData
=
new
{
zkCount
=
zkCount
,
...
...
@@ -262,6 +272,8 @@ namespace JunmpPoliceStation.Controllers
jjbfCount
=
jjbfCount
,
ycqCount
=
ycqCount
,
cqwhCount
=
cqwhCount
,
jncksCount
=
jncksCount
,
jnbfsCount
=
jnbfsCount
};
return
JsonManager
.
ReturnSuccessResponse
(
reData
);
...
...
JunmpPoliceStation/Extensions/CronJob.cs
View file @
d999d5ab
...
...
@@ -6,6 +6,7 @@ using System.Diagnostics;
using
System.Linq
;
using
System.Net
;
using
System.Net.Http
;
using
System.Security.Cryptography
;
using
System.Text
;
using
System.Threading.Tasks
;
using
JmpCommon
;
...
...
@@ -16,11 +17,13 @@ using JunmpPoliceStation.Controllers;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.Logging
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
namespace
JunmpPoliceStation.Extensions
{
public
class
CronJob
{
public
static
string
TRUSTAGW_ACCESS_TOKEN
=
""
;
JunmppolicesqlContext
_dbContext
;
HttpHelper
_httpHelper
;
private
IConfiguration
Configuration
;
...
...
@@ -144,6 +147,50 @@ namespace JunmpPoliceStation.Extensions
return
new
Tuple
<
string
,
string
>(
"19999"
,
"操作失败"
);
}
}
public
bool
UpdateACCESS_TOKEN
()
{
try
{
var
app_id
=
"b6fcf1"
;
var
appkey
=
"1803a86623306ae5"
;
var
reqData
=
JsonConvert
.
SerializeObject
(
new
{
app_id
=
app_id
,
fingerprint
=
Convert
.
ToBase64String
(
SHA1
.
Create
()
.
ComputeHash
(
Encoding
.
UTF8
.
GetBytes
(
$"app_id=
{
app_id
}
&app_key=
{
appkey
}
"
)))
});
var
res
=
_httpHelper
.
GetHtml
(
new
HttpItem
{
URL
=
"https://139.66.16.10:6443/sts/token"
,
Encoding
=
Encoding
.
UTF8
,
Method
=
"POST"
,
ContentType
=
"application/json"
,
Postdata
=
reqData
,
IsNoTIP
=
true
});
if
(
res
.
StatusCode
!=
HttpStatusCode
.
Created
)
{
_logger
.
LogError
(
"获取ACCESS_TOKEN失败 code:"
+
res
.
StatusCode
+
JsonConvert
.
SerializeObject
(
res
));
return
false
;
}
var
jobj
=
JObject
.
Parse
(
res
.
Html
);
TRUSTAGW_ACCESS_TOKEN
=
jobj
[
"access_token"
]?.
Value
<
string
>()
??
""
;
if
(
string
.
IsNullOrEmpty
(
TRUSTAGW_ACCESS_TOKEN
))
{
_logger
.
LogError
(
"获取ACCESS_TOKEN失败 jobj:"
+
res
.
Html
);
return
false
;
}
return
true
;
}
catch
(
Exception
e
)
{
_logger
.
LogError
(
e
,
"定时任务工作异常"
);
return
false
;
}
}
}
public
class
respone
<
T
>
...
...
JunmpPoliceStation/Extensions/HttpHelper.cs
View file @
d999d5ab
...
...
@@ -9,6 +9,7 @@ using System.Security.Cryptography.X509Certificates;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
Newtonsoft.Json
;
namespace
JunmpPoliceStation.Extensions
...
...
@@ -22,6 +23,7 @@ namespace JunmpPoliceStation.Extensions
private
readonly
string
_secretKey
;
private
readonly
string
_apiVersion
;
private
readonly
string
_organizationId
;
private
readonly
bool
_noSignFlag
;
public
readonly
string
_centerServerAddress
;
public
HttpHelper
(
IConfiguration
configuration
)
{
...
...
@@ -30,6 +32,7 @@ namespace JunmpPoliceStation.Extensions
_apiVersion
=
"1.0"
;
_organizationId
=
configuration
[
"ThirdConfig:OrganizationId"
]
??
""
;
_centerServerAddress
=
configuration
[
"ThirdConfig:CenterServerAddress"
]
??
""
;
bool
.
TryParse
(
configuration
.
GetSection
(
"Auth:NoSign"
).
Value
,
out
_noSignFlag
);
}
#
region
预定义方变量
...
...
@@ -59,6 +62,33 @@ namespace JunmpPoliceStation.Extensions
try
{
//准备参数
if
(!
_noSignFlag
)
//本地测试不添加验证
{
if
(!
item
.
IsNoTIP
)
{
//补充杭州自建head头
if
(
string
.
IsNullOrEmpty
(
CronJob
.
TRUSTAGW_ACCESS_TOKEN
))
{
//重新更新token
using
(
var
scope
=
Startup
.
ServiceLocator
.
Instance
.
CreateScope
())
{
var
cronJob
=
scope
.
ServiceProvider
.
GetService
<
CronJob
>();
if
(
cronJob
?.
UpdateACCESS_TOKEN
()
!=
true
)
{
return
new
HttpResult
()
{
Cookie
=
string
.
Empty
,
Header
=
null
,
Html
=
"更新TOKEN失败"
,
StatusDescription
=
"更新TOKEN失败"
};
}
}
}
item
.
Header
.
Add
(
"X-trustagw-access-token"
,
CronJob
.
TRUSTAGW_ACCESS_TOKEN
);
item
.
Host
=
"jbzb.sjjhpt.hzs.zj"
;
}
}
SetRequest
(
item
);
}
catch
(
Exception
ex
)
...
...
@@ -311,6 +341,9 @@ namespace JunmpPoliceStation.Extensions
}
else
{
//这一句一定要写在创建连接的前面。使用回调的方法进行证书验证。(忽略证书验证)
ServicePointManager
.
ServerCertificateValidationCallback
=
new
System
.
Net
.
Security
.
RemoteCertificateValidationCallback
(
CheckValidationResult
);
//初始化对像,并设置请求的URL地址
request
=
(
HttpWebRequest
)
WebRequest
.
Create
(
item
.
URL
);
SetCerList
(
item
);
...
...
@@ -522,6 +555,11 @@ namespace JunmpPoliceStation.Extensions
public
class
HttpItem
{
/// <summary>
/// 是否请求不需要TIP验证(杭州市局加密用,为获取TIP使用)
/// </summary>
public
bool
IsNoTIP
{
get
;
set
;
}
/// <summary>
/// 请求URL必须填写
/// </summary>
public
string
URL
{
get
;
set
;
}
...
...
JunmpPoliceStation/Startup.cs
View file @
d999d5ab
...
...
@@ -177,8 +177,9 @@ namespace JunmpPoliceStation
using
(
var
scope
=
app
.
ApplicationServices
.
CreateScope
())
{
var
cronJob
=
scope
.
ServiceProvider
.
GetRequiredService
<
CronJob
>();
RecurringJob
.
AddOrUpdate
(()
=>
cronJob
.
SyncEquipmentState
(),
"* 0/10 * * * *"
);
RecurringJob
.
AddOrUpdate
(()
=>
cronJob
.
SyncEquipmentData
(),
"0 0 1 1/1 * *"
);
RecurringJob
.
AddOrUpdate
(()
=>
cronJob
.
SyncEquipmentState
(),
"* 0/10 * * * *"
,
TimeZoneInfo
.
Local
);
RecurringJob
.
AddOrUpdate
(()
=>
cronJob
.
SyncEquipmentData
(),
"0 0 1 1/1 * *"
,
TimeZoneInfo
.
Local
);
RecurringJob
.
AddOrUpdate
(()
=>
cronJob
.
UpdateACCESS_TOKEN
(),
"0 0 0/6 * * *"
,
TimeZoneInfo
.
Local
);
}
//app.UseMvc(routes =>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论