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
403fd85f
Commit
403fd85f
authored
Apr 14, 2023
by
zxw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
快速出库
报表调整与主平台一致
parent
182d6cbf
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
629 行增加
和
25 行删除
+629
-25
ViewEquipment.cs
JmpModel/Model/ViewEquipment.cs
+3
-0
JmpSqlServerModel.csproj
JmpSqlServerModel/JmpSqlServerModel.csproj
+2
-2
QuickOrderController.cs
JunmpPoliceStation/Controllers/QuickOrderController.cs
+563
-0
TjController.cs
JunmpPoliceStation/Controllers/TjController.cs
+60
-22
JunmpPoliceStation.csproj
JunmpPoliceStation/JunmpPoliceStation.csproj
+1
-1
没有找到文件。
JmpModel/Model/ViewEquipment.cs
View file @
403fd85f
...
...
@@ -83,5 +83,7 @@ namespace JmpModel.Model
/// </summary>
[
Column
(
"is_continue_use"
)]
public
bool
?
IsContinueUse
{
get
;
set
;
}
[
Column
(
"d_name"
)]
public
string
DName
{
get
;
set
;
}
}
}
\ No newline at end of file
JmpSqlServerModel/JmpSqlServerModel.csproj
View file @
403fd85f
...
...
@@ -6,8 +6,8 @@
<ItemGroup>
<PackageReference Include="ErikEJ.EntityFrameworkCore.DgmlBuilder" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="
3.1.10
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="
3.1.10
">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="
5.0.17
" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="
5.0.17
">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
...
...
JunmpPoliceStation/Controllers/QuickOrderController.cs
0 → 100644
View file @
403fd85f
using
JmpCommon
;
using
JmpCommon.Tools
;
using
JmpModel.Model
;
using
JmpModel.Model.Enumerates
;
using
JmpModel.Model.Repository
;
using
JunmpPoliceStation.App_Start
;
using
JunmpPoliceStation.Extensions
;
using
JunmpPoliceStation.Models.Repository
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.ChangeTracking.Internal
;
using
Microsoft.Extensions.Logging
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
using
StackExchange.Redis
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq.Expressions
;
using
System.Net.Http
;
using
System.Runtime.CompilerServices
;
using
System.Threading.Tasks
;
namespace
JunmpPoliceStation.Controllers
{
[
ApiController
]
[
Route
(
"api/[controller]"
)]
public
class
QuickOrderController
:
ControllerBase
{
private
ILogger
<
QuickOrderController
>
_logger
;
UnitOfWork
_unitOfWork
;
public
QuickOrderController
(
ILogger
<
QuickOrderController
>
logger
,
UnitOfWork
unitOfWork
)
{
_logger
=
logger
;
_unitOfWork
=
unitOfWork
;
}
/// <summary>
/// 直接创建单据(借用,领用,报废)
/// </summary>
/// <remarks>
/// ## 例子
///
/// {
/// "id":"", //新增可不填
/// "action":0, //0借用,1领用,2报废
/// "applyId":"",
/// "warehouseId":"",
/// "orgId":"",
/// "orgCode":"",
/// "applyName":"",
/// "note":"请求理由",//可为空
/// "detailList":[
/// {
/// "id":"",//新增可不填
/// "equipmentId":"",
/// "equipmentSizeId":"",
/// "quantity":"",
/// "supplierId":"",
/// "epc":""
/// }]
/// }
///
/// </remarks>
/// <param name="jdata"></param>
/// <returns></returns>
[
HttpPost
(
"QuickAddOrder"
)]
public
async
Task
<
HttpResponseMessage
>
QuickAddOrder
([
FromBody
]
JObject
jdata
)
{
return
await
Task
.
Run
(()
=>
{
try
{
if
(
jdata
!=
null
)
{
var
entity
=
JsonManager
.
GetJsonEntity
(
jdata
);
if
(
entity
==
null
)
{
return
JsonManager
.
SimpleCustResponse
(
$"model is null"
);
}
else
if
(
string
.
IsNullOrEmpty
(
entity
.
action
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
$"action is require"
);
}
else
if
(
string
.
IsNullOrEmpty
(
entity
.
applyId
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
$"applyId is require"
);
}
else
if
(
string
.
IsNullOrEmpty
(
entity
.
applyName
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
$"applyName is require"
);
}
else
if
(
string
.
IsNullOrEmpty
(
entity
.
orgCode
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
$"orgCode is require"
);
}
else
if
(
string
.
IsNullOrEmpty
(
entity
.
warehouseId
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
$"warehouseId is require"
);
}
else
if
(
string
.
IsNullOrEmpty
(
entity
.
orgId
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
$"orgId is require"
);
}
else
if
(
entity
.
detailList
==
null
||
entity
.
detailList
.
Count
==
0
)
{
return
JsonManager
.
SimpleCustResponse
(
$"detailList is require"
);
}
else
{
int
action
=
int
.
Parse
(
entity
.
action
);
switch
(
action
)
{
case
0
:
{
return
CreateBorrowOrder
(
"JY"
,
entity
);
}
case
1
:
{
return
CreateBorrowOrder
(
"LY"
,
entity
);
}
case
2
:
{
return
CreateFixOrder
(
"BF"
,
entity
);
}
default
:
return
JsonManager
.
SimpleCustResponse
(
$"action is require"
);
}
}
}
else
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
}
catch
(
Exception
ex
)
{
_logger
.
LogError
(
ex
.
ToString
());
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
OPERATE_FAILED
);
}
});
}
#
region
借领用
/// <summary>
/// 创建借领用单据
/// </summary>
/// <param name="head_str"></param>
/// <param name="entity"></param>
/// <returns></returns>
private
HttpResponseMessage
CreateBorrowOrder
(
string
head_str
,
dynamic
entity
)
{
string
orderID
=
Guid
.
NewGuid
().
ToString
();
string
processCurrentId
=
Guid
.
NewGuid
().
ToString
();
string
flowState
=
"true"
;
string
orderCode
=
$"
{
entity
.
orgCode
}{
head_str
}{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)}
"
;
string
note
=
"快速出库 "
+
entity
.
note
;
_unitOfWork
.
AddProcess
(
processCurrentId
,
orderID
,
""
,
""
,
""
,
""
,
""
,
(
string
)
entity
.
flowType
,
(
string
)
entity
.
flowName
,
(
string
)
entity
.
flowId
,
flowState
,
(
string
)
entity
.
orgId
,
note
,
(
string
)
entity
.
applyId
,
(
string
)
entity
.
applyName
,
orderCode
);
bool
bExpectedTime
=
DateTime
.
TryParse
(
entity
?.
expectedTime
??
""
,
out
DateTime
expectedTime
);
if
(
head_str
==
"JY"
&&
(!
bExpectedTime
||
expectedTime
==
default
))
{
return
JsonManager
.
SimpleCustResponse
(
$"expectedTime is require"
);
}
//新增数据
CommonJpBorrowReturnApply
order
=
new
CommonJpBorrowReturnApply
()
{
ChangeFlag
=
1
,
ActionType
=
head_str
==
"JY"
?
0
:
1
,
ApplyUser
=
entity
.
applyId
,
ApplyUserName
=
entity
.
applyName
,
ApplyTime
=
DateTime
.
Now
,
CreateTime
=
DateTime
.
Now
,
ApprovalResult
=
(
int
)
ApproveType
.
已审批
,
WarehouseId
=
entity
.
warehouseId
,
Id
=
orderID
,
OrgId
=
entity
.
orgId
,
OrderCode
=
orderCode
,
Note
=
note
,
ProcessCurrentId
=
processCurrentId
,
ExpectedReturnTime
=
expectedTime
,
PoliceNote
=
entity
.
policeNote
,
};
List
<
CommonJpBorrowReturnDetailEstimate
>
detailsList
=
new
List
<
CommonJpBorrowReturnDetailEstimate
>();
var
epcList
=
new
List
<
string
>();
foreach
(
var
item
in
entity
.
detailList
)
{
//if (string.IsNullOrEmpty(item.equipmentSizeId ?? ""))
//{
// return JsonManager.SimpleCustResponse("equipmentSizeId is require");
//}
if
(
string
.
IsNullOrEmpty
(
item
.
equipmentId
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
"equipmentId is require"
);
}
if
(
string
.
IsNullOrEmpty
(
item
.
epc
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
"epc is require"
);
}
epcList
.
Add
(
item
.
epc
);
//var bUnitPrice = decimal.TryParse(item.unitPrice, out decimal unitPrice);
//var bPrice = decimal.TryParse(item.price, out decimal price);
detailsList
.
Add
(
new
CommonJpBorrowReturnDetailEstimate
()
{
Id
=
Guid
.
NewGuid
().
ToString
(),
EquipmentId
=
item
.
equipmentId
,
//SizeId = string.IsNullOrEmpty(item.equipmentSizeId) ? null : item.equipmentSizeId,
EstimateId
=
order
.
Id
,
EquipmentCount
=
1
,
//SupplierId = item.supplierId,
//UnitPrice = bUnitPrice ? unitPrice : (decimal?)null,
//Price = bPrice ? price : (decimal?)null,
});
}
//重复聚合
order
.
CommonJpBorrowReturnDetailEstimates
=
detailsList
.
GroupBy
(
x
=>
new
{
x
.
EquipmentId
})
.
Select
(
x
=>
new
CommonJpBorrowReturnDetailEstimate
{
Id
=
x
.
First
().
Id
,
EquipmentId
=
x
.
First
().
EquipmentId
,
//SizeId = x.First().SizeId,
EstimateId
=
x
.
First
().
EstimateId
,
EquipmentCount
=
x
.
Count
(),
})
.
ToList
();
List
<
CommonJpBorrowReturn
>
borrowReturnList
=
new
List
<
CommonJpBorrowReturn
>();
CommonJpBorrowReturn
borrowReturn
=
new
CommonJpBorrowReturn
{
Id
=
Guid
.
NewGuid
().
ToString
(),
ActionType
=
order
.
ActionType
,
WarehouseId
=
order
.
WarehouseId
,
OrderCode
=
order
.
OrderCode
,
CurrentState
=
(
int
)
BorrowEnum
.
CurrentState
.
已出去
,
ApplyId
=
order
.
Id
,
OrgId
=
order
.
OrgId
,
CreateTime
=
DateTime
.
Now
,
CreateUser
=
entity
.
auditUser
,
IsWork
=
false
,
};
foreach
(
var
item
in
order
.
CommonJpBorrowReturnDetailEstimates
)
{
//int.TryParse(item.quantity, out int qty);
borrowReturn
.
CommonJpBorrowReturnDetailRealities
.
Add
(
new
CommonJpBorrowReturnDetailReality
()
{
Id
=
Guid
.
NewGuid
().
ToString
(),
SizeId
=
string
.
IsNullOrEmpty
(
item
.
SizeId
)
?
null
:
item
.
SizeId
,
EquipmentDetailId
=
item
.
EquipmentId
,
RealityId
=
borrowReturn
.
Id
,
State
=
(
int
)
BorrowEnum
.
CurrentState
.
已出去
,
EstimateId
=
order
.
Id
,
EquipmentCount
=
item
.
EquipmentCount
,
SupplierId
=
item
.
SupplierId
,
RealCount
=
item
.
EquipmentCount
});
//transferCom.CommonJpTransferDetailRealities = transferDetailsList;
borrowReturnList
.
Add
(
borrowReturn
);
}
order
.
CommonJpBorrowReturns
=
borrowReturnList
;
_unitOfWork
.
BorrowReturnApplyRepository
.
Insert
(
order
,
false
);
//更新物资状态
var
invList
=
_unitOfWork
.
EquipmentInventoryRepository
.
GetList
(
x
=>
epcList
.
Contains
(
x
.
Epc
),
includes
:
new
[]
{
"EquipmentCodeNavigation"
})
.
ToList
();
foreach
(
var
inventory
in
invList
)
{
if
(
inventory
.
CurrentState
!=
0
)
{
return
JsonManager
.
SimpleCustResponse
(
$"物资不是在库状态:装备名:
{
inventory
.
EquipmentCodeNavigation
.
Name
}
,EPC:
{
inventory
.
Epc
}
"
);
}
if
(
order
.
WarehouseId
!=
inventory
.
WarehouseCode
)
{
return
JsonManager
.
SimpleCustResponse
(
$"物资不是本仓库的物资:装备名:
{
inventory
.
EquipmentCodeNavigation
.
Name
}
,EPC:
{
inventory
.
Epc
}
"
);
}
inventory
.
CurrentState
=
head_str
==
"JY"
?
2
:
8
;
inventory
.
EquipmentLocation
=
3
;
//外出
var
realityItem
=
borrowReturn
.
CommonJpBorrowReturnDetailRealities
.
FirstOrDefault
(
x
=>
x
.
EquipmentDetailId
==
inventory
.
EquipmentCode
);
_unitOfWork
.
EquipmentStateRepository
.
Insert
(
new
CommonJpEquipmentState
()
{
Id
=
Guid
.
NewGuid
().
ToString
(),
PicUrl
=
""
,
BorrowId
=
realityItem
?.
Id
,
OutTime
=
DateTime
.
Now
,
OrgId
=
order
.
OrgId
,
OrderCode
=
realityItem
?.
Reality
?.
OrderCode
,
WarehouseId
=
order
.
WarehouseId
,
State
=
1
,
//PoliceId = policeId,
EqiupmentId
=
inventory
.
Id
,
CreateTime
=
DateTime
.
Now
,
ActionState
=
head_str
==
"JY"
?
2
:
3
,
OutInState
=
0
,
HistorySafeLevel
=
inventory
.
SafeLevel
},
false
);
_unitOfWork
.
EquipmentInventoryRepository
.
Update
(
inventory
,
false
);
}
if
(
_unitOfWork
.
SaveChanges
()
>
0
)
{
//报废成功,重新计算阈值
var
sizeList
=
invList
.
Select
(
x
=>
x
.
EquipmentSizecode
)
.
ToList
();
_unitOfWork
.
CalcThreshold
(
sizeList
,
order
.
OrgId
,
order
.
WarehouseId
);
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
OPERATE_SUCCESS
);
}
else
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
}
#
endregion
#
region
报废
/// <summary>
/// 创建报废单据
/// </summary>
/// <param name="head_str"></param>
/// <param name="entity"></param>
/// <returns></returns>
private
HttpResponseMessage
CreateFixOrder
(
string
head_str
,
dynamic
entity
)
{
string
orderID
=
Guid
.
NewGuid
().
ToString
();
string
processCurrentId
=
Guid
.
NewGuid
().
ToString
();
string
flowState
=
"true"
;
string
orderCode
=
$"
{
entity
.
orgCode
}{
head_str
}{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)}
"
;
string
note
=
"快速出库 "
+
entity
.
note
;
var
ExistOrder
=
_unitOfWork
.
FixReceiveApplyRepository
.
Get
(
p
=>
p
.
OrderCode
==
orderCode
);
var
fixEpcs
=
_unitOfWork
.
FixReceiveApplyDetailRepository
.
GetList
(
p
=>
p
.
Id
!=
null
).
Select
(
x
=>
x
.
Epc
.
ToString
()
).
ToList
();
if
(
ExistOrder
!=
null
)
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
ORDER_IS_EXIST
);
}
_unitOfWork
.
AddProcess
(
processCurrentId
,
orderID
,
""
,
""
,
""
,
""
,
""
,
(
string
)
entity
.
flowType
,
(
string
)
entity
.
flowName
,
(
string
)
entity
.
flowId
,
flowState
,
(
string
)
entity
.
orgId
,
note
,
(
string
)
entity
.
applyId
,
(
string
)
entity
.
applyName
,
orderCode
);
//新增数据
CommonJpFixReceiveApply
order
=
new
CommonJpFixReceiveApply
()
{
Action
=
1
,
//报废
ApplyId
=
entity
.
applyId
,
ApplyTime
=
DateTime
.
Now
,
CreateTime
=
DateTime
.
Now
,
ApprovalTime
=
null
,
ApprovalResult
=
(
int
)
ApproveType
.
已审批
,
ApprovalId
=
entity
.
approvalId
,
ApprovalName
=
note
,
WarehouseId
=
entity
.
warehouseId
,
Id
=
orderID
,
OrgId
=
entity
.
orgId
,
ApplyName
=
entity
.
applyName
,
ProcessCurrentId
=
processCurrentId
,
OrderCode
=
orderCode
,
CurrentState
=
1
};
List
<
CommonJpFixReceiveApplyDetail
>
detailsList
=
new
List
<
CommonJpFixReceiveApplyDetail
>();
foreach
(
var
item
in
entity
.
detailList
)
{
string
getEpc
=
item
.
epc
;
int
.
TryParse
(
item
.
quantity
,
out
int
qty
);
if
(
string
.
IsNullOrEmpty
(
item
.
equipmentId
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
"equipmentId is require"
);
}
else
if
(
string
.
IsNullOrEmpty
(
item
.
epc
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
"epc is require"
);
}
else
if
(
string
.
IsNullOrEmpty
(
item
.
supplierId
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
"supplierId is require"
);
}
else
if
(
string
.
IsNullOrEmpty
(
item
.
equipmentSizeId
??
""
))
{
return
JsonManager
.
SimpleCustResponse
(
"equipmentSizeId is require"
);
}
else
if
(
qty
<=
0
)
{
return
JsonManager
.
SimpleCustResponse
(
"quantity field error"
);
}
else
if
(
fixEpcs
.
Contains
(
getEpc
))
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
BASE_EXIST
);
}
else
{
detailsList
.
Add
(
new
CommonJpFixReceiveApplyDetail
()
{
Id
=
Guid
.
NewGuid
().
ToString
(),
EquipmentId
=
item
.
equipmentId
,
SizeId
=
item
.
equipmentSizeId
,
OrderId
=
order
.
Id
,
Quantity
=
qty
,
SupplierId
=
item
.
supplierId
,
Epc
=
item
.
epc
??
""
,
State
=
1
});
}
}
order
.
CommonJpFixReceiveApplyDetails
=
detailsList
;
_unitOfWork
.
FixReceiveApplyRepository
.
Insert
(
order
,
false
);
//生成流水表
GenerateRecord
(
order
);
//反写库存状态
UpdateInvState
(
order
.
CommonJpFixReceiveApplyDetails
?.
Select
(
x
=>
x
.
Epc
).
ToList
(),
order
.
Action
,
order
.
OrderCode
,
false
);
if
(
_unitOfWork
.
SaveChanges
()
>
0
)
{
//报废成功,重新计算阈值
var
sizeList
=
order
.
CommonJpFixReceiveApplyDetails
.
Select
(
x
=>
x
.
SizeId
)
.
ToList
();
_unitOfWork
.
CalcThreshold
(
sizeList
,
order
.
OrgId
,
order
.
WarehouseId
);
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
OPERATE_SUCCESS
);
}
else
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
}
/// <summary>
/// 生成报废/维修流水记录
/// </summary>
private
void
GenerateRecord
(
CommonJpFixReceiveApply
order
)
{
//string head_str = order.Action == 0 ? "WX" : "BF";
//string orgCode = order.OrderCode.Substring(0, 6);
CommonJpFixUseless
useless
=
new
CommonJpFixUseless
()
{
Id
=
Guid
.
NewGuid
().
ToString
(),
Action
=
order
.
Action
,
ApplyId
=
order
.
ApplyId
,
CreateTime
=
DateTime
.
Now
,
CreateUser
=
"李四"
,
FixTime
=
DateTime
.
Now
,
EstimateId
=
order
.
Id
,
OrderCode
=
order
.
OrderCode
,
//$"{orgCode}{head_str}{DateTime.Now.ToString("yyyyMMddHHmmss")}",
OrgId
=
order
.
OrgId
,
WarehouseId
=
order
.
WarehouseId
,
CommonJpFixUselessDetails
=
new
List
<
CommonJpFixUselessDetail
>(),
CurrentState
=
1
};
foreach
(
var
item
in
order
.
CommonJpFixReceiveApplyDetails
)
{
var
tmpEntity
=
new
CommonJpFixUselessDetail
()
{
Id
=
Guid
.
NewGuid
().
ToString
(),
OrderId
=
useless
.
Id
,
Quantity
=
item
.
Quantity
,
State
=
1
,
Epc
=
item
.
Epc
,
EquipmentId
=
item
.
EquipmentId
,
SizeId
=
item
.
SizeId
,
SupplierId
=
item
.
SupplierId
,
RealCount
=
1
};
useless
.
CommonJpFixUselessDetails
.
Add
(
tmpEntity
);
var
tmpState
=
GenerateState
(
order
.
OrderCode
,
tmpEntity
.
Epc
,
useless
.
Action
,
tmpEntity
.
Id
,
useless
.
WarehouseId
,
useless
.
OrgId
,
order
.
ApplyId
);
if
(
tmpState
!=
null
)
{
tmpEntity
.
CommonJpEquipmentStates
.
Add
(
tmpState
);
}
}
_unitOfWork
.
FixUselessRepository
.
Insert
(
useless
,
false
);
}
private
CommonJpEquipmentState
GenerateState
(
string
orderCode
,
string
epc
,
int
action
,
string
detailId
,
string
warehouseId
,
string
orgId
,
string
applyId
)
{
var
invInfo
=
_unitOfWork
.
DbContext
.
CommonJpEquipmentInventories
.
FirstOrDefault
(
t
=>
t
.
Epc
.
Contains
(
epc
));
if
(
invInfo
!=
null
)
{
CommonJpEquipmentState
equState
=
new
CommonJpEquipmentState
()
{
OrderCode
=
orderCode
,
Id
=
Guid
.
NewGuid
().
ToString
(),
State
=
2
,
ActionState
=
action
==
0
?
6
:
7
,
EqiupmentId
=
invInfo
.
Id
,
OutInState
=
0
,
FixId
=
detailId
,
WarehouseId
=
warehouseId
,
CreateTime
=
DateTime
.
Now
,
OrgId
=
orgId
,
OutTime
=
DateTime
.
Now
,
PoliceId
=
_unitOfWork
.
DbContext
.
CommonJpUsers
.
FirstOrDefault
(
x
=>
x
.
Id
==
applyId
)?.
PoliceId
};
return
equState
;
}
else
{
return
default
;
}
}
private
void
UpdateInvState
(
List
<
string
>
epcList
,
int
action
,
string
orderCode
,
bool
isLost
)
{
if
(
epcList
==
null
||
epcList
.
Count
==
0
)
{
_logger
.
LogError
(
$"[维修报废]未找到维修报废明细,
{
orderCode
}
"
);
}
var
wz_info
=
_unitOfWork
.
DbContext
.
CommonJpEquipmentInventories
.
Where
(
t
=>
epcList
.
Contains
(
t
.
Epc
)).
ToList
();
if
(
wz_info
!=
null
&&
wz_info
.
Count
()
>
0
)
{
wz_info
.
ForEach
(
x
=>
{
x
.
LostFlag
=
isLost
;
x
.
CurrentState
=
action
==
0
?
4
:
6
;
if
(
x
.
CurrentState
==
6
)
{
//报废装备置于报废区
x
.
ShelfId
=
"00000000-0000-0000-0000-000000000001"
;
x
.
ShelfRange
=
null
;
x
.
ShelfRow
=
null
;
x
.
ShelfColumn
=
null
;
}
//单警柜解绑
x
.
CabinetId
=
null
;
x
.
PoliceCode
=
null
;
_unitOfWork
.
EquipmentInventoryRepository
.
Update
(
x
,
false
);
});
}
}
#
endregion
}
}
JunmpPoliceStation/Controllers/TjController.cs
View file @
403fd85f
...
...
@@ -679,30 +679,47 @@ namespace JunmpPoliceStation.Controllers
else
{
var
codeLen
=
findcode
.
Length
+
2
;
var
data
=
equipmentList
.
GroupBy
(
t
=>
t
.
FindCode
.
PadLeft
(
codeLen
,
'0'
).
Substring
(
0
,
codeLen
)).
Select
(
c
=>
new
var
data
1
=
equipmentList
.
GroupBy
(
t
=>
new
{
OrgName
=
c
.
OrderBy
(
f
=>
f
.
OrgCode
).
FirstOrDefault
().
AreaName
,
FindCode
=
t
.
FindCode
.
PadRight
(
codeLen
,
'0'
).
Substring
(
0
,
codeLen
),
FindCodeFlag
=
t
.
OrgCode
.
Substring
(
0
,
6
)
==
findcode
.
PadRight
(
6
,
'0'
)
?
t
.
OrgCode
:
""
});
var
data
=
data1
.
Select
(
c
=>
new
{
sortFlag
=
c
.
FirstOrDefault
().
FindCode
.
PadRight
(
12
,
'0'
)
==
c
.
FirstOrDefault
().
OrgCode
||
c
.
Key
.
FindCodeFlag
==
""
?
0
:
1
,
OrgName
=
string
.
IsNullOrEmpty
(
c
.
OrderBy
(
f
=>
f
.
OrgCode
).
FirstOrDefault
().
DName
)
?
c
.
OrderBy
(
f
=>
f
.
OrgCode
).
FirstOrDefault
().
OrgName
:
c
.
OrderBy
(
f
=>
f
.
OrgCode
).
FirstOrDefault
().
DName
,
c
.
OrderBy
(
f
=>
f
.
OrgCode
).
FirstOrDefault
().
FindCode
,
c
.
OrderBy
(
f
=>
f
.
OrgCode
).
FirstOrDefault
().
OrgCode
,
zsCount
=
c
.
Count
(
f
=>
f
.
CurrentState
!=
null
),
zkCount
=
c
.
Where
(
f
=>
(
f
.
CurrentState
.
Equals
(
0
)
||
f
.
CurrentState
.
Equals
(
3
))
&&
f
.
CreateTime
?.
Year
==
DateTime
.
Now
.
Year
).
Count
(),
ckCount
=
c
.
Where
(
f
=>
!(
f
.
CurrentState
==
null
||
f
.
CurrentState
.
Equals
(
0
)
||
f
.
CurrentState
.
Equals
(
3
)
||
f
.
CurrentState
.
Equals
(
6
))
&&
f
.
CreateTime
?.
Year
==
DateTime
.
Now
.
Year
).
Count
(),
bfCount
=
c
.
Where
(
f
=>
f
.
CurrentState
.
Equals
(
6
)
&&
f
.
CreateTime
?.
Year
==
DateTime
.
Now
.
Year
).
Count
(),
zsCount
=
c
.
Count
(
f
=>
f
.
CurrentState
!=
6
&&
f
.
CurrentState
!=
null
),
zkCount
=
c
.
Where
(
f
=>
f
.
CurrentState
.
Equals
(
0
)
||
f
.
CurrentState
.
Equals
(
3
)).
Count
(),
ckCount
=
c
.
Where
(
f
=>
!(
f
.
CurrentState
==
null
||
f
.
CurrentState
.
Equals
(
0
)
||
f
.
CurrentState
.
Equals
(
3
)
||
f
.
CurrentState
.
Equals
(
6
))).
Count
(),
bfCount
=
c
.
Where
(
f
=>
f
.
CurrentState
.
Equals
(
6
)).
Count
(),
djgCount
=
c
.
Count
(
x
=>
x
.
CurrentState
==
3
),
djgckCount
=
c
.
Count
(
x
=>
x
.
CurrentState
==
7
),
priceCount
=
c
.
Where
(
f
=>
!
f
.
CurrentState
.
Equals
(
6
)
&&
f
.
Price
!=
null
).
Sum
(
k
=>
k
.
Price
),
children
=
c
.
OrderBy
(
z
=>
z
.
TypeOneId
).
GroupBy
(
a
=>
a
.
EquipmentCode
).
Select
(
c
=>
new
children
=
c
.
OrderBy
(
z
=>
z
.
TypeOneId
).
ThenBy
(
z
=>
z
.
TypeTwoId
).
ThenBy
(
z
=>
z
.
TypeThreeId
).
GroupBy
(
a
=>
a
.
EquipmentCode
).
Select
(
c
=>
new
{
id
=
c
.
FirstOrDefault
().
EquipmentCode
,
name
=
c
.
FirstOrDefault
().
EquipmentName
,
zsCount
=
c
.
Count
(
f
=>
f
.
CurrentState
!=
null
),
zkCount
=
c
.
Where
(
f
=>
(
f
.
CurrentState
.
Equals
(
0
)
||
f
.
CurrentState
.
Equals
(
3
))
&&
f
.
CreateTime
?.
Year
==
DateTime
.
Now
.
Year
).
Count
(),
ckCount
=
c
.
Where
(
f
=>
!(
f
.
CurrentState
==
null
||
f
.
CurrentState
.
Equals
(
0
)
||
f
.
CurrentState
.
Equals
(
3
)
||
f
.
CurrentState
.
Equals
(
6
))
&&
f
.
CreateTime
?.
Year
==
DateTime
.
Now
.
Year
).
Count
(),
bfCount
=
c
.
Where
(
f
=>
f
.
CurrentState
.
Equals
(
6
)
&&
f
.
CreateTime
?.
Year
==
DateTime
.
Now
.
Year
).
Count
(),
zsCount
=
c
.
Count
(
f
=>
f
.
CurrentState
!=
6
&&
f
.
CurrentState
!=
null
),
zkCount
=
c
.
Where
(
f
=>
f
.
CurrentState
.
Equals
(
0
)
||
f
.
CurrentState
.
Equals
(
3
)).
Count
(),
ckCount
=
c
.
Where
(
f
=>
!(
f
.
CurrentState
==
null
||
f
.
CurrentState
.
Equals
(
0
)
||
f
.
CurrentState
.
Equals
(
3
)
||
f
.
CurrentState
.
Equals
(
6
))).
Count
(),
bfCount
=
c
.
Where
(
f
=>
f
.
CurrentState
.
Equals
(
6
)).
Count
(),
djgCount
=
c
.
Count
(
x
=>
x
.
CurrentState
==
3
),
djgckCount
=
c
.
Count
(
x
=>
x
.
CurrentState
==
7
),
priceCount
=
c
.
Where
(
f
=>
!
f
.
CurrentState
.
Equals
(
6
)
&&
f
.
Price
!=
null
).
Sum
(
k
=>
k
.
Price
)
}).
Where
(
f
=>
f
.
id
!=
null
&&
f
.
zsCount
!=
0
).
ToList
()
}).
Where
(
f
=>
f
.
id
!=
null
&&
(
f
.
zsCount
!=
0
||
f
.
bfCount
!=
0
)
).
ToList
()
}).
ToList
();
data
=
data
.
Where
(
c
=>
c
.
zsCount
!=
0
)
.
OrderBy
(
c
=>
c
.
FindCode
.
Length
)
data
=
data
.
Where
(
c
=>
c
.
zsCount
!=
0
||
c
.
bfCount
!=
0
)
.
OrderBy
(
c
=>
c
.
sortFlag
)
.
ThenBy
(
c
=>
c
.
FindCode
.
Length
)
.
ThenBy
(
c
=>
c
.
FindCode
)
.
ThenBy
(
c
=>
c
.
OrgCode
)
.
ToList
();
...
...
@@ -714,6 +731,10 @@ namespace JunmpPoliceStation.Controllers
zkCount
=
data
.
Sum
(
c
=>
c
.
zkCount
),
ckCount
=
data
.
Sum
(
c
=>
c
.
ckCount
),
bfCount
=
data
.
Sum
(
c
=>
c
.
bfCount
),
djgCount
=
data
.
Sum
(
c
=>
c
.
djgCount
),
djgckCount
=
data
.
Sum
(
c
=>
c
.
djgckCount
),
priceCount
=
data
.
Sum
(
c
=>
c
.
priceCount
),
content
=
data
.
Skip
(
page
*
size
).
Take
(
size
)
};
...
...
@@ -995,14 +1016,25 @@ namespace JunmpPoliceStation.Controllers
else
{
var
codeLen
=
findcode
.
Length
+
2
;
var
temp
=
equipmentList
.
GroupBy
(
t
=>
t
.
FindCode
.
PadLeft
(
codeLen
,
'0'
).
Substring
(
0
,
codeLen
))
.
ToList
();
var
data
=
temp
.
Select
(
c
=>
new
//
var temp = equipmentList.GroupBy(t => t.FindCode.PadLeft(codeLen, '0').Substring(0, codeLen))
//
.ToList();
var
data
1
=
equipmentList
.
GroupBy
(
t
=>
new
{
FindCode
=
t
.
FindCode
.
PadRight
(
codeLen
,
'0'
).
Substring
(
0
,
codeLen
),
FindCodeFlag
=
t
.
OrgCode
.
Substring
(
0
,
6
)
==
findcode
.
PadRight
(
6
,
'0'
)
?
t
.
OrgCode
:
""
});
var
data
=
data1
.
Select
(
c
=>
new
{
sortFlag
=
c
.
FirstOrDefault
().
FindCode
.
PadRight
(
12
,
'0'
)
==
c
.
FirstOrDefault
().
OrgCode
||
c
.
Key
.
FindCodeFlag
==
""
?
0
:
1
,
FindCode
=
c
.
FirstOrDefault
().
FindCode
,
OrgName
=
codeLen
<
6
?
ListEq
.
FirstOrDefault
(
x
=>
x
.
Code
==
c
.
FirstOrDefault
().
FindCode
.
Substring
(
0
,
codeLen
).
PadRight
(
12
,
'0'
)).
AreaName
:
c
.
FirstOrDefault
().
AreaName
,
//OrgName = codeLen < 6 ?
// ListEq.FirstOrDefault(x => x.Code == c.FirstOrDefault().FindCode.Substring(0, codeLen).PadRight(12, '0')).AreaName
// : c.FirstOrDefault().AreaName,
OrgName
=
string
.
IsNullOrEmpty
(
c
.
OrderBy
(
f
=>
f
.
OrgCode
).
FirstOrDefault
().
DName
)
?
c
.
OrderBy
(
f
=>
f
.
OrgCode
).
FirstOrDefault
().
OrgName
:
c
.
OrderBy
(
f
=>
f
.
OrgCode
).
FirstOrDefault
().
DName
,
c
.
FirstOrDefault
().
OrgCode
,
yearStartCount
=
c
.
Count
(
f
=>
!
f
.
CurrentState
.
Equals
(
6
)
&&
f
.
CreateTime
?.
Year
<
year
),
yearStartPrice
=
c
.
Where
(
f
=>
!
f
.
CurrentState
.
Equals
(
6
)
&&
f
.
Price
!=
null
&&
f
.
CreateTime
?.
Year
<
year
).
Sum
(
k
=>
k
.
Price
),
...
...
@@ -1010,7 +1042,7 @@ namespace JunmpPoliceStation.Controllers
yearEndPrice
=
c
.
Where
(
f
=>
!
f
.
CurrentState
.
Equals
(
6
)
&&
f
.
Price
!=
null
&&
f
.
CreateTime
?.
Year
<=
year
).
Sum
(
k
=>
k
.
Price
),
yearAddCount
=
c
.
Where
(
f
=>
!
f
.
CurrentState
.
Equals
(
6
)
&&
f
.
CreateTime
?.
Year
==
year
).
Count
(),
yearDelCount
=
c
.
Where
(
f
=>
f
.
CurrentState
.
Equals
(
6
)
&&
f
.
CreateTime
?.
Year
==
year
).
Count
(),
children
=
c
.
OrderBy
(
z
=>
z
.
TypeOneId
).
GroupBy
(
a
=>
a
.
EquipmentCode
).
Select
(
c
=>
new
children
=
c
.
OrderBy
(
z
=>
z
.
TypeOneId
).
ThenBy
(
z
=>
z
.
TypeTwoId
).
ThenBy
(
z
=>
z
.
TypeThreeId
).
ThenBy
(
z
=>
z
.
EquipmentCode
).
GroupBy
(
a
=>
a
.
EquipmentCode
).
Select
(
c
=>
new
{
id
=
c
.
FirstOrDefault
().
EquipmentCode
,
name
=
c
.
FirstOrDefault
().
EquipmentName
,
...
...
@@ -1023,7 +1055,13 @@ namespace JunmpPoliceStation.Controllers
}).
Where
(
f
=>
f
.
id
!=
null
).
ToList
()
}).
ToList
();
data
=
data
.
OrderBy
(
c
=>
c
.
OrgCode
).
ToList
();
//data = data.OrderBy(c => c.OrgCode).ToList();
data
=
data
.
Where
(
c
=>
c
.
yearStartCount
!=
0
||
c
.
yearEndCount
!=
0
)
.
OrderBy
(
c
=>
c
.
sortFlag
)
.
ThenBy
(
c
=>
c
.
FindCode
.
Length
)
.
ThenBy
(
c
=>
c
.
FindCode
)
.
ThenBy
(
c
=>
c
.
OrgCode
)
.
ToList
();
var
dataPage
=
new
{
...
...
JunmpPoliceStation/JunmpPoliceStation.csproj
View file @
403fd85f
...
...
@@ -65,7 +65,7 @@
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.7.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="
3.1.10
">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="
5.0.17
">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论