Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jyzb_local_platform
概览
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
赵剑炜
jyzb_local_platform
Commits
e4765c6a
Commit
e4765c6a
authored
Dec 13, 2023
by
Seniorious
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
cda74cdc
隐藏空白字符变更
内嵌
并排
正在显示
24 个修改的文件
包含
1191 行增加
和
54 行删除
+1191
-54
BaseInfoController.cs
WebApiNET6-master/APIs/Controllers/BaseInfoController.cs
+365
-15
PictureReq.cs
WebApiNET6-master/APIs/Req/PictureReq.cs
+7
-2
Startup.cs
WebApiNET6-master/APIs/Startup.cs
+4
-0
EpcConvert.cs
WebApiNET6-master/Common/EpcConvert.cs
+404
-0
RecordsReq.cs
WebApiNET6-master/Models/ReqModel/RecordsReq.cs
+8
-1
EquipmentSize.cs
WebApiNET6-master/Models/Table/EquipmentSize.cs
+7
-7
Inventory.cs
WebApiNET6-master/Models/Table/Inventory.cs
+39
-18
LogDetail.cs
WebApiNET6-master/Models/Table/LogDetail.cs
+10
-10
LogSummary.cs
WebApiNET6-master/Models/Table/LogSummary.cs
+2
-1
OrderDetail.cs
WebApiNET6-master/Models/Table/OrderDetail.cs
+6
-0
Supplier.cs
WebApiNET6-master/Models/Table/Supplier.cs
+36
-0
Warehouse.cs
WebApiNET6-master/Models/Table/Warehouse.cs
+41
-0
ILogSummaryRepository.cs
WebApiNET6-master/Repositories/IRepository/IBussiness/ILogSummaryRepository.cs
+2
-0
ISupplierRepository.cs
WebApiNET6-master/Repositories/IRepository/IBussiness/ISupplierRepository.cs
+13
-0
IWarehouseRepository.cs
WebApiNET6-master/Repositories/IRepository/IBussiness/IWarehouseRepository.cs
+13
-0
LogSummaryRepository.cs
WebApiNET6-master/Repositories/Repository/Bussiness/LogSummaryRepository.cs
+86
-0
SupplierRepository.cs
WebApiNET6-master/Repositories/Repository/Bussiness/SupplierRepository.cs
+19
-0
WarehouseRepository.cs
WebApiNET6-master/Repositories/Repository/Bussiness/WarehouseRepository.cs
+19
-0
ILogService.cs
WebApiNET6-master/Services/Interface/ILogService.cs
+2
-0
ISupplierService.cs
WebApiNET6-master/Services/Interface/ISupplierService.cs
+13
-0
IWarehouseService.cs
WebApiNET6-master/Services/Interface/IWarehouseService.cs
+13
-0
LogService.cs
WebApiNET6-master/Services/LogService.cs
+38
-0
SupplierService.cs
WebApiNET6-master/Services/SupplierService.cs
+22
-0
WarehouseService.cs
WebApiNET6-master/Services/WarehouseService.cs
+22
-0
没有找到文件。
WebApiNET6-master/APIs/Controllers/BaseInfoController.cs
View file @
e4765c6a
...
...
@@ -3,6 +3,7 @@ using APIs.Dto;
using
APIs.Req
;
using
Autofac.Core
;
using
AutoMapper
;
using
Common
;
using
Common.Utility.Model
;
using
Common.Utility.RabbitMQ
;
using
Microsoft.AspNetCore.Mvc
;
...
...
@@ -18,8 +19,10 @@ using Services.Interface;
using
SqlSugar
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.Drawing.Imaging
;
using
System.Linq
;
using
System.Linq.Expressions
;
using
System.Security.Cryptography.Xml
;
using
static
Microsoft
.
AspNetCore
.
Razor
.
Language
.
TagHelperMetadata
;
...
...
@@ -42,11 +45,17 @@ namespace APIs.Controllers
private
readonly
ILogService
_logService
;
private
readonly
IDevHistoryService
_devHistoryService
;
private
readonly
IDevService
_devService
;
private
readonly
IWarehouseService
_warehouseService
;
private
readonly
IOrderService
_orderService
;
private
readonly
ISupplierService
_supplierService
;
private
readonly
IThisInfoService
_thisInfoService
;
private
readonly
IPrintService
_printService
;
public
BaseInfoController
(
IMapper
mapper
,
IPoliceService
policeService
,
IEquipmentTypeService
equipmentTypeService
,
IEquipmentSizeService
equipmentSizeService
,
ICarService
carService
,
IInventoryService
inventoryService
,
IInvService
invService
,
IUsersService
usersService
,
ILogService
logService
,
IDevHistoryService
devHistoryService
,
IDevService
devService
)
IDevService
devService
,
IWarehouseService
warehouseService
,
IOrderService
orderService
,
ISupplierService
supplierService
,
IThisInfoService
thisInfoService
,
IPrintService
printService
)
{
_carService
=
carService
;
_equipmentSizeService
=
equipmentSizeService
;
...
...
@@ -58,38 +67,379 @@ namespace APIs.Controllers
_logService
=
logService
;
_devHistoryService
=
devHistoryService
;
_devService
=
devService
;
_warehouseService
=
warehouseService
;
_orderService
=
orderService
;
_supplierService
=
supplierService
;
_thisInfoService
=
thisInfoService
;
_printService
=
printService
;
Mapper
=
mapper
;
}
/// <summary>
/// 通道上传出入库信息
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
async
Task
<
ApiResult
>
UploadRFID
([
FromBody
]
ChannelLogReq
req
)
{
try
{
#
region
合法判断
if
(
req
.
Epc
==
null
||
req
.
Epc
.
Count
()
==
0
)
{
return
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
"EPC为空"
,
};
}
if
(
req
.
state
!=
0
||
req
.
Epc
.
Count
()
!=
1
)
{
return
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
"出入库状态错误"
,
};
}
if
(
req
.
warehouseId
==
null
)
{
return
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
"仓库为空"
,
};
}
#
endregion
var
myOrder
=
await
_orderService
.
QueryOne
(
s
=>
s
.
orderState
==
2
);
//单据
var
warehouse
=
await
_warehouseService
.
QueryOne
(
s
=>
s
.
id
.
Equals
(
req
.
warehouseId
));
var
warehouseInvtory
=
await
_inventoryService
.
Query
(
s
=>
!
s
.
bussinessState
.
Equals
(
"destruction"
)
&&
!
s
.
state
.
Equals
(
"2"
)
&&
s
.
locationId
.
Equals
(
req
.
warehouseId
));
//仓库装备
myOrder
=
(
myOrder
!=
null
&&
!
myOrder
.
orderType
.
Equals
(
req
.
state
==
0
?
"in"
:
"out"
))
?
null
:
myOrder
;
//如果出入状态与单据不匹配则作为无单据处理
List
<
string
>
newEquOrderType
=
new
List
<
string
>()
{
"purchase"
,
"allocate"
,
"gift"
};
//入库单据为这些种类则会有新装备
List
<
string
>
epcList
=
new
List
<
string
>();
//经过过滤后的EPC
//初步过滤
if
(
myOrder
==
null
||
!(
newEquOrderType
.
Contains
(
myOrder
.
bussinessType
)
&&
myOrder
.
orderType
.
Equals
(
"in"
)))
//日常和无新装备单据的出入库过滤非本仓库物资
{
if
(
warehouseInvtory
==
null
||
warehouseInvtory
.
Count
()
==
0
)
{
return
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
"仓库无装备"
};
}
var
removeEpcs
=
req
.
Epc
.
Except
(
warehouseInvtory
.
Select
(
s
=>
s
.
epc
).
ToList
()).
ToList
();
epcList
=
req
.
Epc
.
Where
(
s
=>
!
removeEpcs
.
Contains
(
s
)).
ToList
();
}
else
//有新装备单据过滤本仓库物资
{
if
(
warehouseInvtory
==
null
||
warehouseInvtory
.
Count
()
==
0
)
{
epcList
=
req
.
Epc
;
}
else
{
var
keepEpcs
=
req
.
Epc
.
Except
(
warehouseInvtory
.
Select
(
s
=>
s
.
epc
).
ToList
()).
ToList
();
epcList
=
req
.
Epc
.
Where
(
s
=>
keepEpcs
.
Contains
(
s
)).
ToList
();
}
}
var
deatilDic
=
myOrder
?.
DetailList
.
Where
(
s
=>
s
.
warehouseId
.
Equals
(
req
.
warehouseId
))
.
Select
(
s
=>
s
.
equipmentSize
)
.
ToList
();
//通道所在仓库子单
//创建出入库记录
List
<
Inventory
>
newEquList
=
new
List
<
Inventory
>();
List
<
LogDetail
>
logDetailList
=
new
List
<
LogDetail
>();
var
orgInfo
=
await
_thisInfoService
.
QueryOne
(
s
=>
true
);
foreach
(
var
epc
in
epcList
)
{
var
epc_info
=
EpcConvert
.
EpcAnlysing
(
EpcConvert
.
ToHexByte
(
epc
));
string
typecode
=
epc_info
.
Wzdm
.
ToString
(
"X"
);
string
sizecode
=
epc_info
.
Hxdm
.
ToString
(
"X"
);
string
suppliercode
=
epc_info
.
OrganizationCode
.
ToString
();
var
mytype
=
await
_equipmentTypeService
.
QueryOne
(
s
=>
s
.
id
.
Equals
(
typecode
));
var
mysize
=
await
_equipmentSizeService
.
QueryOne
(
s
=>
s
.
typeId
.
Equals
(
typecode
)
&&
s
.
code
.
Equals
(
sizecode
));
var
mysupplier
=
await
_supplierService
.
QueryOne
(
s
=>
s
.
code
.
Equals
(
suppliercode
));
;
if
(
mytype
!=
null
&&
mysize
!=
null
)
{
if
(
myOrder
!=
null
&&
deatilDic
!=
null
)
//单据出入库则过滤非单据装备
{
if
(!
deatilDic
.
Contains
(
mysize
.
id
))
{
continue
;
}
else
if
(
newEquOrderType
.
Contains
(
myOrder
.
bussinessType
)
&&
myOrder
.
orderType
.
Equals
(
"in"
))
//有新装备单据生成库存记录
{
var
periodInfo
=
(
await
_printService
.
QueryOne
(
s
=>
s
.
id
.
Equals
(
myOrder
.
id
)))?.
DetailList
.
FirstOrDefault
(
s
=>
s
.
sizeId
.
Equals
(
mysize
.
id
));
newEquList
.
Add
(
new
Inventory
{
id
=
Guid
.
NewGuid
().
ToString
(),
state
=
"2"
,
epc
=
epc
,
typeId
=
mytype
.
id
??
""
,
sizeId
=
mysize
.
id
??
""
,
typeName
=
mytype
.
name
??
""
,
sizeName
=
mysize
.
name
??
""
,
bussinessState
=
"normal"
,
equState
=
"normal"
,
locationId
=
req
.
warehouseId
,
locationName
=
warehouse
?.
name
,
maintenancePeriod
=
Convert
.
ToString
(
periodInfo
?.
maintenancePeriod
),
warrantyPeriod
=
Convert
.
ToString
(
periodInfo
?.
warrantyPeriod
),
supplierId
=
mysupplier
?.
id
??
""
,
orgId
=
Convert
.
ToInt64
(
orgInfo
.
orgId
),
lostFlag
=
"0"
,
equipmentType
=
"0"
,
locationType
=
"0"
,
supplierName
=
mysupplier
?.
name
??
""
,
productionDate
=
periodInfo
?.
productionDate
,
createTime
=
DateTime
.
Now
,
updateTime
=
DateTime
.
Now
,
price
=
myOrder
.
DetailList
?.
FirstOrDefault
(
s
=>
s
.
equipmentSize
.
Equals
(
mysize
.
id
))?.
price
??
0
,
});
}
}
//出入库子单
var
inv
=
await
_inventoryService
.
QueryOne
(
s
=>
s
.
epc
.
Equals
(
epc
));
logDetailList
.
Add
(
new
LogDetail
()
{
inventoryId
=
inv
?.
id
,
epc
=
epc
,
equipmentName
=
mytype
?.
name
??
""
,
equipmentSize
=
mysize
.
name
??
""
,
equipmentTypeId
=
mytype
?.
id
??
""
,
equipmentSizeId
=
mysize
.
id
??
""
,
errorState
=
0
,
state
=
req
.
state
==
1
?
0
:
1
,
equipmentType
=
0
,
supplierId
=
mysupplier
?.
id
??
""
,
supplierName
=
mysupplier
?.
name
??
""
,
price
=
inv
?.
price
??
0
,
createTime
=
DateTime
.
Now
,
updateTime
=
DateTime
.
Now
,
});
}
else
{
continue
;
}
}
//生成主单
LogSummary
summary
=
new
LogSummary
();
if
(
logDetailList
.
Count
()
>
0
)
{
var
names
=
logDetailList
.
GroupBy
(
s
=>
s
.
equipmentName
).
Select
(
s
=>
s
.
Key
).
ToList
();
string
equipments
=
""
;
for
(
int
i
=
0
;
i
<
names
.
Count
;
i
++)
{
equipments
=
(
i
==
names
.
Count
-
1
)
?
equipments
+
$"
{
names
[
i
]}
"
:
equipments
+
$"
{
names
[
i
]}
,"
;
}
summary
=
new
LogSummary
()
{
locationId
=
req
.
warehouseId
,
locationName
=
warehouse
.
name
,
userName
=
""
,
useTime
=
DateTime
.
Now
,
createTime
=
DateTime
.
Now
,
updateTime
=
DateTime
.
Now
,
bussinessType
=
myOrder
?.
bussinessType
??
"normal"
,
deviceType
=
2
,
number
=
logDetailList
.
Count
(),
outInState
=
req
.
state
==
0
?
"out"
:
"in"
,
equipments
=
equipments
,
orderId
=
myOrder
?.
id
,
orderCode
=
myOrder
?.
orderCode
,
isUpload
=
0
,
price
=
logDetailList
.
Sum
(
s
=>
s
.
price
),
DetailList
=
logDetailList
,
};
}
var
rs
=
await
_logService
.
AddChannelLog
(
myOrder
,
summary
,
newEquList
);
return
rs
?
new
ApiResult
{
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
}:
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
ResultCode
.
OPERATE_FAILED
.
Msg
};
}
catch
(
Exception
ex
)
{
var
error
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
ex
.
Message
,
};
return
error
;
}
}
/// <summary>
///
3.0平台获取图片
///
获取装备类别
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[
HttpGet
]
public
IActionResult
DownloadLogPicture
(
string
id
)
public
async
Task
<
ApiResult
>
GetEquipmentType
(
)
{
try
{
// 读取文件内容
byte
[]
fileBytes
=
System
.
IO
.
File
.
ReadAllBytes
(
$"LogPictures\\
{
id
}
.jpg"
);
var
types
=
(
await
_equipmentTypeService
.
Query
())?.
Select
(
s
=>
new
{
id
=
s
.
id
,
name
=
s
.
name
,
code
=
s
.
id
,
}).
ToList
();
// 获取文件的MIME类型
string
contentType
=
"application/octet-stream"
;
// 默认使用二进制流的MIME类型,如果需要根据具体文件类型动态获取,请进行适当的处理。
// 返回文件结果
return
File
(
fileBytes
,
contentType
,
$"
{
id
}
.jpg"
);
var
src
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
,
data
=
types
};
return
src
;
}
catch
(
Exception
ex
)
{
var
error
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
ex
.
Message
,
};
return
error
;
}
}
/// <summary>
/// 获取本组织机构所有仓库
/// </summary>
/// <param name=""></param>
/// <returns></returns>
[
HttpGet
]
public
async
Task
<
ApiResult
>
GetWarehouse
()
{
try
{
var
warehouses
=
(
await
_warehouseService
.
Query
())?.
Select
(
s
=>
new
{
id
=
s
.
id
,
name
=
s
.
name
,
}).
ToList
();
var
src
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
,
data
=
warehouses
};
return
src
;
}
catch
(
Exception
ex
)
{
return
new
Content
Result
var
error
=
new
Api
Result
{
Content
=
"ERROR:"
+
ex
,
ContentType
=
"text/plain"
,
StatusCode
=
400
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
ex
.
Message
,
};
return
error
;
}
}
/// <summary>
/// 通道出入库照片上传
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
async
Task
<
ApiResult
>
UploadLogPicture
([
FromForm
]
LogPictureReq
req
)
{
try
{
if
(
req
.
picture
==
null
)
{
return
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
"无图片"
,
};
}
if
(
string
.
IsNullOrEmpty
(
req
.
fileName
))
{
return
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
"无图片名称"
,
};
}
if
(
string
.
IsNullOrEmpty
(
req
.
directoy
))
{
return
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
"无文件夹名称"
,
};
}
using
(
MemoryStream
ms
=
new
MemoryStream
())
{
//拷贝文件到内存流
req
.
picture
.
CopyTo
(
ms
);
var
tmp
=
ms
.
GetBuffer
();
var
fileType
=
tmp
[
0
].
ToString
()
+
tmp
[
1
].
ToString
();
var
path
=
Path
.
Combine
(
"LogPictures"
,
req
.
directoy
);
Directory
.
CreateDirectory
(
path
);
var
filePath
=
Path
.
Combine
(
path
,
req
.
fileName
);
System
.
Drawing
.
Image
.
FromStream
(
ms
).
Save
(
filePath
);
var
src
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
,
};
return
src
;
}
}
catch
(
Exception
ex
)
{
var
error
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
ex
.
Message
,
};
return
error
;
}
}
/// <summary>
...
...
@@ -104,7 +454,7 @@ namespace APIs.Controllers
//读取图片
string
imageBytes
=
""
;
string
url
=
$"LogPictures
\\
{
req
.
logI
d
}
.jpg"
;
string
url
=
$"LogPictures
/
{
req
.
pi
d
}
.jpg"
;
using
(
FileStream
fileStream
=
new
FileStream
(
url
,
FileMode
.
Open
))
{
using
(
BinaryReader
reader
=
new
BinaryReader
(
fileStream
))
...
...
WebApiNET6-master/APIs/Req/PictureReq.cs
View file @
e4765c6a
...
...
@@ -5,7 +5,6 @@
public
string
id
{
get
;
set
;
}
}
public
class
PictureReq
{
public
string
policeId
{
get
;
set
;
}
...
...
@@ -23,7 +22,13 @@
public
class
GetLogPictureReq
{
public
string
logI
d
{
get
;
set
;}
public
string
pi
d
{
get
;
set
;}
}
public
class
LogPictureReq
{
public
IFormFile
picture
{
get
;
set
;
}
public
string
fileName
{
get
;
set
;
}
//文件名
public
string
directoy
{
get
;
set
;
}
//文件夹
}
}
WebApiNET6-master/APIs/Startup.cs
View file @
e4765c6a
...
...
@@ -71,6 +71,8 @@ namespace APIs
services
.
AddScoped
<
IThisInfoService
,
ThisInfoService
>();
services
.
AddScoped
<
IDevService
,
DevService
>();
services
.
AddScoped
<
IDevHistoryService
,
DevHistoryService
>();
services
.
AddScoped
<
IWarehouseService
,
WarehouseService
>();
services
.
AddScoped
<
ISupplierService
,
SupplierService
>();
#
endregion
#
region
Repository
...
...
@@ -91,6 +93,8 @@ namespace APIs
services
.
AddScoped
<
IThisInfoRepository
,
ThisInfoRepository
>();
services
.
AddScoped
<
IDevRepository
,
DevRepository
>();
services
.
AddScoped
<
IDevHistoryRepository
,
DevHistoryRepository
>();
services
.
AddScoped
<
IWarehouseRepository
,
WarehouseRepository
>();
services
.
AddScoped
<
ISupplierRepository
,
SupplierRepository
>();
#
endregion
#
region
注册
RabbitMQ
消费者
...
...
WebApiNET6-master/Common/EpcConvert.cs
0 → 100644
View file @
e4765c6a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Common
{
public
class
Analyzingepc
{
public
byte
Header
;
// 标头(8bits): JY物资专用标头 0x11(00010001b)
public
byte
IssuerId
;
// 发行机构标识符(6bits):GA组织机构: 0x01(000001b) 国家组织机构:0x02(000010b)
public
string
OrganizationCode
;
// 组织机构代码(54bits):JY物资生产厂商使用GA或国家组织机构代码, 英文字母及数字的每一个字符转换为六位二进制
public
byte
WzdmLen
;
// 物资代码长度(4bits): 指定物资代码的长度(N*8bits), 此处为0x7
public
UInt64
Wzdm
;
// 物资代码(56bits): 使用警用物资编目数据的物资代码,按十进制转换成十六进制存储
public
UInt64
Hxdm
;
public
byte
SerialLen
;
// 序列号长度(4bits): 指定序列号长度(N*8bits), 此处为0xD
public
byte
Ver
;
// 版本号(8bits): 0x01
public
byte
TagType
;
// 标签类型(8bits): 0x00 件标 0x01 箱标
public
byte
PackingType
;
// 包装类型(4bits): 0x1 单品, 0x2 外包装, 0x3 内包装, 0xF 零头配箱
public
UInt32
ProductionDate
;
// 生产日期(24bits): 0x161201
public
byte
ExpiryDate
;
// 有效期值(6bits): 0-63
public
byte
ExpiryDateUnit
;
// 有效期时间单位(2bits): 1:01b-日, 2:10b-月, 3:11b-年
public
byte
SubPackageNum
;
// 下级包装内数量(8bits):最大255
public
UInt16
WzCount
;
// 包装数量(12bits): MAX:4095, 每箱内产品总数
public
UInt32
BoxNo
;
// 包装箱序列号(20bits): MAX:65535
public
UInt16
NoInBox
;
// 箱内序列号(12bits): 每箱内产品序号, MAX4095
/*---------以下为2.0版本新增参数,以下参数用于替换生产日期之后的字段,确保真唯一-----------*/
public
ulong
TimeSpan
{
get
;
set
;
}
//当前日期时间戳,精确到毫秒
public
byte
MachineNum
{
get
;
set
;
}
//服务器识别码(4bits),用于区分测试服务器与正式服务器生成的数据,实际1b就够了,其他3b做保留
}
public
static
class
EpcConvert
{
private
readonly
static
string
strKeyWords
=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
// 无源标签6位字段对应表
/// <summary>
/// 此方法用于将普通字符串转换成16进制的字符串。
/// </summary>
/// <param name="_str">要转换的字符串。</param>
/// <returns></returns>
public
static
string
StringToHex16String
(
string
_str
)
{
//将字符串转换成字节数组。
byte
[]
buffer
=
System
.
Text
.
Encoding
.
UTF8
.
GetBytes
(
_str
);
//定义一个string类型的变量,用于存储转换后的值。
string
result
=
string
.
Empty
;
for
(
int
i
=
0
;
i
<
buffer
.
Length
;
i
++)
{
//将每一个字节数组转换成16进制的字符串,以空格相隔开。
result
+=
Convert
.
ToString
(
buffer
[
i
],
16
)
+
" "
;
}
return
result
;
}
/// <summary>
/// 此方法用于将16进制的字节数组转换成16进制的字符串。
/// </summary>
/// <param name="_hex16Byte">要转换的16进制的字节数组。</param>
/// <returns></returns>
public
static
string
Hex16ByteToHex16String
(
byte
[]
_hex16Byte
)
{
string
result
=
string
.
Empty
;
//如果字节数组不为空。
if
(
_hex16Byte
!=
null
)
{
for
(
int
i
=
0
;
i
<
_hex16Byte
.
Length
;
i
++)
{
//将每一个字节数组转换成16进制string类型的字符串,用空格分隔开。
result
+=
_hex16Byte
[
i
].
ToString
(
"X2"
)
+
" "
;
}
}
return
result
;
}
public
static
byte
[]
ToHexByte
(
string
hexString
)
{
hexString
=
hexString
.
Replace
(
" "
,
""
);
if
((
hexString
.
Length
%
2
)
!=
0
)
{
hexString
=
hexString
+
" "
;
}
byte
[]
buffer
=
new
byte
[
hexString
.
Length
/
2
];
for
(
int
i
=
0
;
i
<
buffer
.
Length
;
i
++)
{
buffer
[
i
]
=
Convert
.
ToByte
(
hexString
.
Substring
(
i
*
2
,
2
),
0x10
);
}
return
buffer
;
}
/// <summary>
/// 生成2.0EPC
/// </summary>
/// <param name="epc"></param>
/// <returns></returns>
public
static
byte
[]
Epc2Gen
(
Analyzingepc
epc
)
{
byte
[]
buf
=
new
byte
[
40
];
int
pos
=
0
;
SetData
(
ref
buf
,
pos
,
8
,
epc
.
Header
);
pos
+=
8
;
SetData
(
ref
buf
,
pos
,
6
,
epc
.
IssuerId
);
pos
+=
6
;
SetData
(
ref
buf
,
pos
,
54
,
OrganizationCodeTo6Bin
(
epc
.
OrganizationCode
.
ToUpper
()));
pos
+=
54
;
SetData
(
ref
buf
,
pos
,
4
,
epc
.
WzdmLen
);
pos
+=
4
;
var
wzlen
=
((
epc
.
WzdmLen
-
1
)
%
8
)
*
8
;
SetData
(
ref
buf
,
pos
,
wzlen
,
epc
.
Wzdm
);
// 物资代码暂时定义最长为64bits
pos
+=
wzlen
;
SetData
(
ref
buf
,
pos
,
8
,
epc
.
Hxdm
);
// 物资代码暂时定义最长为64bits
pos
+=
8
;
SetData
(
ref
buf
,
pos
,
4
,
epc
.
SerialLen
);
pos
+=
4
;
/*----------------2.0版本字段-------------*/
SetData
(
ref
buf
,
pos
,
8
,
epc
.
Ver
);
pos
+=
8
;
SetData
(
ref
buf
,
pos
,
24
,
epc
.
ProductionDate
);
pos
+=
24
;
SetData
(
ref
buf
,
pos
,
6
,
epc
.
ExpiryDate
);
pos
+=
6
;
SetData
(
ref
buf
,
pos
,
2
,
epc
.
ExpiryDateUnit
);
pos
+=
2
;
SetData
(
ref
buf
,
pos
,
48
,
epc
.
TimeSpan
);
pos
+=
48
;
SetData
(
ref
buf
,
pos
,
12
,
epc
.
NoInBox
);
pos
+=
12
;
SetData
(
ref
buf
,
pos
,
4
,
epc
.
MachineNum
);
// 双字节对齐, 剩余保留区
if
(
pos
%
16
!=
0
)
{
pos
+=
16
-
pos
%
16
;
}
// 数据体长度
var
len
=
pos
/
8
;
var
crc
=
Crc16
(
buf
,
len
);
SetData
(
ref
buf
,
pos
,
16
,
crc
);
byte
[]
rtn
=
new
byte
[
len
+
2
];
Array
.
Copy
(
buf
,
rtn
,
len
+
2
);
return
rtn
;
}
/// <summary>
/// 生成EPC
/// </summary>
/// <param name="epc"></param>
/// <returns></returns>
public
static
byte
[]
EpcGen
(
Analyzingepc
epc
)
{
byte
[]
buf
=
new
byte
[
40
];
int
pos
=
0
;
SetData
(
ref
buf
,
pos
,
8
,
epc
.
Header
);
pos
+=
8
;
SetData
(
ref
buf
,
pos
,
6
,
epc
.
IssuerId
);
pos
+=
6
;
SetData
(
ref
buf
,
pos
,
54
,
OrganizationCodeTo6Bin
(
epc
.
OrganizationCode
.
ToUpper
()));
pos
+=
54
;
SetData
(
ref
buf
,
pos
,
4
,
epc
.
WzdmLen
);
pos
+=
4
;
var
wzlen
=
((
epc
.
WzdmLen
-
1
)
%
8
)
*
8
;
SetData
(
ref
buf
,
pos
,
wzlen
,
epc
.
Wzdm
);
// 物资代码暂时定义最长为64bits
pos
+=
wzlen
;
SetData
(
ref
buf
,
pos
,
8
,
epc
.
Hxdm
);
// 物资代码暂时定义最长为64bits
pos
+=
8
;
SetData
(
ref
buf
,
pos
,
4
,
epc
.
SerialLen
);
pos
+=
4
;
SetData
(
ref
buf
,
pos
,
8
,
epc
.
Ver
);
pos
+=
8
;
SetData
(
ref
buf
,
pos
,
8
,
epc
.
TagType
);
pos
+=
8
;
SetData
(
ref
buf
,
pos
,
4
,
epc
.
PackingType
);
pos
+=
4
;
SetData
(
ref
buf
,
pos
,
24
,
epc
.
ProductionDate
);
pos
+=
24
;
SetData
(
ref
buf
,
pos
,
6
,
epc
.
ExpiryDate
);
pos
+=
6
;
SetData
(
ref
buf
,
pos
,
2
,
epc
.
ExpiryDateUnit
);
pos
+=
2
;
SetData
(
ref
buf
,
pos
,
8
,
epc
.
SubPackageNum
);
pos
+=
8
;
SetData
(
ref
buf
,
pos
,
12
,
epc
.
WzCount
);
pos
+=
12
;
SetData
(
ref
buf
,
pos
,
20
,
epc
.
BoxNo
);
pos
+=
20
;
SetData
(
ref
buf
,
pos
,
12
,
epc
.
NoInBox
);
pos
+=
12
;
// 双字节对齐, 剩余保留区
if
(
pos
%
16
!=
0
)
{
pos
+=
16
-
pos
%
16
;
}
// 数据体长度
var
len
=
pos
/
8
;
var
crc
=
Crc16
(
buf
,
len
);
SetData
(
ref
buf
,
pos
,
16
,
crc
);
byte
[]
rtn
=
new
byte
[
len
+
2
];
Array
.
Copy
(
buf
,
rtn
,
len
+
2
);
return
rtn
;
}
/// <summary>
/// 解析EPC
/// </summary>
/// <param name="epc"></param>
/// <returns></returns>
public
static
Analyzingepc
EpcAnlysing
(
byte
[]
epc
)
{
// CRC 校验
var
crc_chk
=
Crc16
(
epc
,
epc
.
Length
-
2
);
var
crc_src
=
epc
[
epc
.
Length
-
2
]
<<
8
|
epc
[
epc
.
Length
-
1
];
if
(
crc_src
!=
crc_chk
)
{
throw
new
Exception
(
"CRC校验失败"
);
}
// 数据解析
Analyzingepc
rtn
=
new
Analyzingepc
();
int
pos
=
0
;
rtn
.
Header
=
(
byte
)
GetData
(
epc
,
pos
,
8
);
pos
+=
8
;
rtn
.
IssuerId
=
(
byte
)
GetData
(
epc
,
pos
,
6
);
pos
+=
6
;
var
oc
=
GetData
(
epc
,
pos
,
54
);
rtn
.
OrganizationCode
=
OrganizationCodeToStr
(
oc
);
pos
+=
54
;
rtn
.
WzdmLen
=
(
byte
)(
GetData
(
epc
,
pos
,
4
));
pos
+=
4
;
var
wzlen
=
((
rtn
.
WzdmLen
-
1
)
%
8
)
*
8
;
rtn
.
Wzdm
=
GetData
(
epc
,
pos
,
wzlen
);
pos
+=
wzlen
;
rtn
.
Hxdm
=
GetData
(
epc
,
pos
,
8
);
pos
+=
8
;
rtn
.
SerialLen
=
(
byte
)
GetData
(
epc
,
pos
,
4
);
pos
+=
4
;
rtn
.
Ver
=
(
byte
)
GetData
(
epc
,
pos
,
8
);
pos
+=
8
;
//2.0版本解析
if
(
rtn
.
Ver
==
0x02
)
{
rtn
.
ProductionDate
=
(
byte
)
GetData
(
epc
,
pos
,
24
);
pos
+=
24
;
rtn
.
ExpiryDate
=
(
byte
)
GetData
(
epc
,
pos
,
6
);
pos
+=
6
;
rtn
.
ExpiryDateUnit
=
(
byte
)
GetData
(
epc
,
pos
,
2
);
pos
+=
2
;
rtn
.
TimeSpan
=
(
byte
)
GetData
(
epc
,
pos
,
48
);
pos
+=
48
;
rtn
.
NoInBox
=
(
byte
)
GetData
(
epc
,
pos
,
12
);
pos
+=
12
;
rtn
.
MachineNum
=
(
byte
)
GetData
(
epc
,
pos
,
4
);
pos
+=
4
;
}
else
{
rtn
.
TagType
=
(
byte
)
GetData
(
epc
,
pos
,
8
);
pos
+=
8
;
rtn
.
PackingType
=
(
byte
)
GetData
(
epc
,
pos
,
4
);
pos
+=
4
;
rtn
.
ProductionDate
=
(
UInt32
)
GetData
(
epc
,
pos
,
24
);
pos
+=
24
;
rtn
.
ExpiryDate
=
(
byte
)
GetData
(
epc
,
pos
,
6
);
pos
+=
6
;
rtn
.
ExpiryDateUnit
=
(
byte
)
GetData
(
epc
,
pos
,
2
);
pos
+=
2
;
rtn
.
SubPackageNum
=
(
byte
)
GetData
(
epc
,
pos
,
8
);
pos
+=
8
;
rtn
.
WzCount
=
(
UInt16
)
GetData
(
epc
,
pos
,
12
);
pos
+=
12
;
rtn
.
BoxNo
=
(
UInt32
)
GetData
(
epc
,
pos
,
20
);
pos
+=
20
;
rtn
.
NoInBox
=
(
UInt16
)
GetData
(
epc
,
pos
,
12
);
pos
+=
12
;
}
return
rtn
;
}
/// <summary>
/// 向目标数组指定位置插入数据
/// </summary>
/// <param name="data">待操作数组</param>
/// <param name="pos">起始位置</param>
/// <param name="len">写入长度bits</param>
/// <param name="value">写入的值</param>
private
static
void
SetData
(
ref
byte
[]
data
,
int
pos
,
int
len
,
UInt64
value
)
{
int
p
=
pos
;
while
(--
len
>=
0
)
{
var
bitPos
=
7
-
p
%
8
;
data
[
p
++
/
8
]
|=
(
byte
)(((
value
>>
len
)
&
1
)
<<
bitPos
);
}
}
/// <summary>
/// 从目标数组获取成员变量
/// </summary>
/// <param name="data"></param>
/// <param name="pos"></param>
/// <param name="len"></param>
/// <returns></returns>
private
static
UInt64
GetData
(
byte
[]
data
,
int
pos
,
int
len
)
{
UInt64
rtn
=
0
;
int
p
=
pos
;
while
(
len
--
>
0
)
{
var
bitPos
=
7
-
p
%
8
;
rtn
<<=
1
;
rtn
|=
(
byte
)((
data
[
p
++
/
8
]
>>
bitPos
)
&
1
);
}
return
rtn
;
}
/// <summary>
/// 转换成字符串
/// </summary>
/// <param name="icode"></param>
/// <returns></returns>
private
static
string
OrganizationCodeToStr
(
UInt64
icode
)
{
string
code
=
""
;
for
(
int
i
=
0
;
i
<
9
;
i
++)
{
var
v
=
(
byte
)((
icode
>>
(
i
*
6
))
&
0x3f
);
code
=
strKeyWords
[
v
]
+
code
;
}
return
code
;
}
/// <summary>
/// 生成十六进制组织代码, 6Bin
/// </summary>
/// <param name="code"></param>
/// <returns>0 失败, 其它:正常的组织代码编号</returns>
private
static
UInt64
OrganizationCodeTo6Bin
(
string
code
)
{
UInt64
iCode
=
0
;
if
(
code
.
Length
==
9
)
{
for
(
int
i
=
0
;
i
<
code
.
Length
;
i
++)
{
var
index
=
strKeyWords
.
IndexOf
(
code
[
i
]);
if
(
index
==
-
1
)
{
throw
new
Exception
(
"输入字符非法!"
);
}
iCode
<<=
6
;
iCode
|=
(
byte
)
index
;
}
}
else
{
throw
new
Exception
(
"输入长度非法!"
);
}
return
iCode
;
}
/// <summary>
/// CRC运算
/// </summary>
/// <param name="data"></param>
/// <param name="len">必须是偶数</param>
/// <returns></returns>
public
static
UInt16
Crc16
(
byte
[]
data
,
int
lenth
)
{
ushort
crc
=
0x8791
;
for
(
int
i
=
0
;
i
<
lenth
;
++
i
)
{
ushort
temp
=
0
;
ushort
a
=
(
ushort
)(((
crc
>>
8
)
^
(
0xff
&
data
[
i
]))
<<
8
);
for
(
int
j
=
0
;
j
<
8
;
++
j
)
{
if
(((
temp
^
a
)
&
0x8000
)
!=
0
)
{
temp
=
(
ushort
)((
temp
<<
1
)
^
0x1021
);
}
else
{
temp
<<=
1
;
}
a
<<=
1
;
}
crc
=
(
ushort
)((
crc
<<
8
)
^
temp
);
}
return
crc
;
}
}
}
WebApiNET6-master/Models/ReqModel/RecordsReq.cs
View file @
e4765c6a
...
...
@@ -55,6 +55,13 @@ namespace Common.Utility.Model
public
String
equipments
{
get
;
set
;
}
[
AllowNull
]
public
List
<
EquipmentList
>?
equipmentList
{
get
;
set
;
}
//
}
public
class
ChannelLogReq
{
public
List
<
string
>
Epc
{
get
;
set
;
}
public
int
?
state
{
get
;
set
;
}
public
string
warehouseId
{
get
;
set
;
}
public
string
picture
{
get
;
set
;
}
}
}
WebApiNET6-master/Models/Table/EquipmentSize.cs
View file @
e4765c6a
...
...
@@ -15,20 +15,20 @@ namespace Models.Table
{
[
SugarColumn
(
IsIdentity
=
true
,
IsPrimaryKey
=
true
)]
public
S
tring
id
{
get
;
set
;
}
public
s
tring
id
{
get
;
set
;
}
public
S
tring
code
{
get
;
set
;
}
public
s
tring
code
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"type_id"
)]
public
String
?
typeId
{
get
;
set
;
}
public
string
typeId
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"name"
)]
public
String
?
name
{
get
;
set
;
}
public
string
name
{
get
;
set
;
}
public
String
?
note
{
get
;
set
;
}
public
string
note
{
get
;
set
;
}
public
String
?
price
{
get
;
set
;
}
public
string
price
{
get
;
set
;
}
public
String
?
state
{
get
;
set
;
}
public
string
state
{
get
;
set
;
}
}
...
...
WebApiNET6-master/Models/Table/Inventory.cs
View file @
e4765c6a
using
SqlSugar
;
using
Models.SqlModel
;
using
SqlSugar
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Security.Principal
;
using
System.Text
;
using
System.Threading.Tasks
;
using
static
Dm
.
net
.
buffer
.
ByteArrayBuffer
;
namespace
Models.Table
{
...
...
@@ -12,54 +14,73 @@ namespace Models.Table
public
class
Inventory
:
BaseTable
{
[
SugarColumn
(
IsIdentity
=
true
,
IsPrimaryKey
=
true
)]
public
S
tring
id
{
get
;
set
;
}
public
s
tring
id
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"type_id"
)]
public
S
tring
typeId
{
get
;
set
;
}
public
s
tring
typeId
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"size_id"
)]
public
S
tring
sizeId
{
get
;
set
;
}
public
s
tring
sizeId
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"supplier_id"
)]
public
S
tring
supplierId
{
get
;
set
;
}
public
s
tring
supplierId
{
get
;
set
;
}
public
S
tring
epc
{
get
;
set
;
}
public
s
tring
epc
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"org_id"
)]
public
String
orgId
{
get
;
set
;
}
public
long
?
orgId
{
get
;
set
;
}
public
S
tring
state
{
get
;
set
;
}
public
s
tring
state
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"bussiness_state"
)]
public
String
bussinessState
{
get
;
set
;
}
public
string
bussinessState
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"equ_state"
)]
public
string
equState
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"production_date"
)]
public
DateTime
?
productionDate
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"warranty_period"
)]
public
S
tring
warrantyPeriod
{
get
;
set
;
}
public
s
tring
warrantyPeriod
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"maintenance_period"
)]
public
S
tring
maintenancePeriod
{
get
;
set
;
}
public
s
tring
maintenancePeriod
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"fix_count"
)]
public
S
tring
fixCount
{
get
;
set
;
}
public
s
tring
fixCount
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"location_id"
)]
public
String
locationId
{
get
;
set
;
}
public
string
locationId
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"location_name"
)]
public
string
locationName
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"location_type"
)]
public
S
tring
locationType
{
get
;
set
;
}
public
s
tring
locationType
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"lost_flag"
)]
public
String
lostFlag
{
get
;
set
;
}
public
string
lostFlag
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"note"
)]
public
string
note
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"equipment_type"
)]
public
string
equipmentType
{
get
;
set
;
}
public
String
price
{
get
;
set
;
}
public
decimal
?
price
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"type_name"
)]
public
S
tring
typeName
{
get
;
set
;
}
public
s
tring
typeName
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"size_name"
)]
public
String
sizeName
{
get
;
set
;
}
public
string
sizeName
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"supplier_name"
)]
public
string
supplierName
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"package_id"
)]
public
string
packageId
{
get
;
set
;
}
}
}
WebApiNET6-master/Models/Table/LogDetail.cs
View file @
e4765c6a
...
...
@@ -15,24 +15,24 @@ namespace Models.Table
public
int
id
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"inventory_id"
)]
public
int
inventoryId
{
get
;
set
;
}
public
string
inventoryId
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"summary_id"
)]
public
int
summaryId
{
get
;
set
;
}
public
S
tring
epc
{
get
;
set
;
}
public
s
tring
epc
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"equipment_name"
)]
public
String
?
equipmentName
{
get
;
set
;
}
public
string
equipmentName
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"equipment_size"
)]
public
String
?
equipmentSize
{
get
;
set
;
}
public
string
equipmentSize
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"equipment_type_id"
)]
public
String
?
equipmentTypeId
{
get
;
set
;
}
public
string
equipmentTypeId
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"equipment_size_id"
)]
public
String
?
equipmentSizeId
{
get
;
set
;
}
public
string
equipmentSizeId
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"error_state"
)]
public
int
?
errorState
{
get
;
set
;
}
...
...
@@ -43,16 +43,16 @@ namespace Models.Table
public
int
?
carid
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"order_id"
)]
public
String
?
orderId
{
get
;
set
;
}
public
string
orderId
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"order_code"
)]
public
String
?
orderCode
{
get
;
set
;
}
public
string
orderCode
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"supplier_id"
)]
public
String
?
supplierId
{
get
;
set
;
}
public
string
supplierId
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"supplier_name"
)]
public
String
?
supplierName
{
get
;
set
;
}
public
string
supplierName
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"equipment_type"
)]
public
int
?
equipmentType
{
get
;
set
;
}
...
...
WebApiNET6-master/Models/Table/LogSummary.cs
View file @
e4765c6a
...
...
@@ -41,7 +41,7 @@ namespace Models.Table
public
String
?
device
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"device_type"
)]
public
int
?
device
_t
ype
{
get
;
set
;
}
public
int
?
device
T
ype
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"location_id"
)]
public
String
?
locationId
{
get
;
set
;
}
...
...
@@ -63,5 +63,6 @@ namespace Models.Table
[
Navigate
(
NavigateType
.
OneToMany
,
nameof
(
LogDetail
.
summaryId
))]
public
List
<
LogDetail
>
DetailList
{
get
;
set
;
}
=
new
List
<
LogDetail
>();
}
}
WebApiNET6-master/Models/Table/OrderDetail.cs
View file @
e4765c6a
...
...
@@ -41,5 +41,11 @@ namespace Models.Table
public
int
?
actualNum
{
get
;
set
;
}
public
decimal
?
price
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"warehouse_id"
)]
public
string
warehouseId
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"warehouse_name"
)]
public
string
warehouseName
{
get
;
set
;
}
}
}
WebApiNET6-master/Models/Table/Supplier.cs
0 → 100644
View file @
e4765c6a
using
SqlSugar
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Security.Policy
;
using
System.Text
;
using
System.Threading.Tasks
;
using
static
Dm
.
net
.
buffer
.
ByteArrayBuffer
;
namespace
Models.Table
{
[
SugarTable
(
"base_supplier"
)]
public
class
Supplier
:
BaseTable
{
[
SugarColumn
(
IsPrimaryKey
=
true
)]
public
string
id
{
get
;
set
;
}
public
string
name
{
get
;
set
;
}
public
string
code
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"short_name"
)]
public
string
shortName
{
get
;
set
;
}
public
string
contacts
{
get
;
set
;
}
public
string
phone
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"create_user"
)]
public
string
createUser
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"update_user"
)]
public
string
updateUser
{
get
;
set
;
}
public
string
state
{
get
;
set
;
}
}
}
WebApiNET6-master/Models/Table/Warehouse.cs
0 → 100644
View file @
e4765c6a
using
SqlSugar
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Models.Table
{
[
SugarTable
(
"base_warehouse"
)]
public
class
Warehouse
:
BaseTable
{
[
SugarColumn
(
IsPrimaryKey
=
true
)]
public
string
id
{
get
;
set
;
}
public
string
name
{
get
;
set
;
}
public
string
location
{
get
;
set
;
}
public
string
phone
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"is_locked"
)]
public
int
?
isLocked
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"org_id"
)]
public
string
orgId
{
get
;
set
;
}
public
int
?
sum
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"out_sum"
)]
public
int
?
outSum
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"in_sum"
)]
public
int
?
inSum
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"price_total"
)]
public
decimal
?
priceTotal
{
get
;
set
;
}
public
int
?
state
{
get
;
set
;
}
}
}
WebApiNET6-master/Repositories/IRepository/IBussiness/ILogSummaryRepository.cs
View file @
e4765c6a
...
...
@@ -15,5 +15,7 @@ namespace Repositories.IRepository.IBussiness
Task
<
bool
>
AddHandLogs
(
LogSummary
model
,
List
<
Inventory
>
invs
);
Task
<
bool
>
AddChannelLog
(
OrderMain
?
myOrder
,
LogSummary
summary
,
List
<
Inventory
>
newInvs
,
Tuple
<
string
,
string
>
inv_states
);
}
}
WebApiNET6-master/Repositories/IRepository/IBussiness/ISupplierRepository.cs
0 → 100644
View file @
e4765c6a
using
Models.Table
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Repositories.IRepository.IBussiness
{
public
interface
ISupplierRepository
:
IBaseRepository
<
Supplier
>
{
}
}
WebApiNET6-master/Repositories/IRepository/IBussiness/IWarehouseRepository.cs
0 → 100644
View file @
e4765c6a
using
Models.Table
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Repositories.IRepository.IBussiness
{
public
interface
IWarehouseRepository
:
IBaseRepository
<
Warehouse
>
{
}
}
WebApiNET6-master/Repositories/Repository/Bussiness/LogSummaryRepository.cs
View file @
e4765c6a
...
...
@@ -21,6 +21,92 @@ namespace Repositories.Repository.Bussiness
_suger
=
sugarUnitOfWork
;
}
public
async
Task
<
bool
>
AddChannelLog
(
OrderMain
?
myOrder
,
LogSummary
summary
,
List
<
Inventory
>
newInvs
,
Tuple
<
string
,
string
>
inv_states
)
{
using
(
var
context
=
_suger
.
GetDbClient
())
{
try
{
context
.
BeginTran
();
if
(
newInvs
!=
null
&&
newInvs
.
Count
()
>
0
)
{
var
inv_rs
=
context
.
Insertable
(
newInvs
).
ExecuteCommand
();
summary
.
DetailList
.
ForEach
(
s
=>
{
s
.
inventoryId
=
context
.
Queryable
<
Inventory
>().
First
(
n
=>
n
.
epc
.
Equals
(
s
.
epc
))?.
id
;
});
}
var
logrs
=
context
.
InsertNav
(
summary
).
Include
(
z1
=>
z1
.
DetailList
).
ExecuteCommand
();
//更新库存状态
var
invIds
=
summary
.
DetailList
.
Select
(
a
=>
a
.
inventoryId
).
ToList
();
context
.
Updateable
<
Inventory
>().
Where
(
s
=>
invIds
.
Contains
(
s
.
id
))
.
SetColumns
(
i
=>
new
Inventory
()
{
state
=
newInvs
!=
null
&&
newInvs
.
Count
()
>
0
?
"2"
:
summary
.
outInState
.
Equals
(
"out"
)
?
"1"
:
"0"
,
bussinessState
=
inv_states
.
Item1
,
equState
=
inv_states
.
Item2
,
updateTime
=
DateTime
.
Now
}).
ExecuteCommand
();
//更新单据
if
(
myOrder
!=
null
)
{
//子表
List
<
LogDetail
>
details
=
new
List
<
LogDetail
>();
context
.
Queryable
<
LogSummary
>()
.
Where
(
s
=>
s
.
orderId
.
Equals
(
myOrder
.
id
))
.
Select
(
s
=>
s
.
DetailList
)
.
ForEach
(
s
=>
{
details
.
AddRange
(
s
);
});
var
detailSumDic
=
details
.
GroupBy
(
s
=>
new
{
s
.
equipmentSizeId
,
s
.
epc
})
.
Select
(
s
=>
new
{
size
=
s
.
Key
.
equipmentSizeId
,
epc
=
s
.
Key
.
epc
})
.
GroupBy
(
s
=>
s
.
size
)
.
Select
(
s
=>
new
{
size
=
s
.
Key
,
count
=
s
.
Count
()
})
.
ToDictionary
(
s
=>
s
.
size
,
s
=>
s
.
count
);
foreach
(
var
item
in
myOrder
.
DetailList
)
{
if
(
detailSumDic
.
ContainsKey
(
item
.
equipmentSize
))
{
item
.
actualNum
=
detailSumDic
[
item
.
equipmentSize
];
}
}
//主表
decimal
sumPrice
=
Convert
.
ToDecimal
(
myOrder
.
DetailList
.
Select
(
s
=>
s
.
actualNum
*
s
.
price
).
Sum
());
myOrder
.
actualQuantity
=
summary
.
number
;
myOrder
.
price
=
sumPrice
;
myOrder
.
isUpload
=
1
;
myOrder
.
orderState
=
0
;
myOrder
.
updateTime
=
DateTime
.
Now
;
var
orderrs
=
context
.
UpdateNav
(
myOrder
).
Include
(
z1
=>
z1
.
DetailList
).
ExecuteCommand
();
//调拨出库删除装备
if
(
inv_states
.
Item1
.
Equals
(
"transfer"
))
{
context
.
Deleteable
<
Inventory
>().
Where
(
s
=>
invIds
.
Contains
(
s
.
id
)).
ExecuteCommand
();
}
}
context
.
CommitTran
();
}
catch
(
Exception
e
)
{
return
false
;
}
}
return
true
;
}
public
async
Task
<
bool
>
AddHandLogs
(
LogSummary
model
,
List
<
Inventory
>
inv
)
{
using
(
var
context
=
_suger
.
GetDbClient
())
...
...
WebApiNET6-master/Repositories/Repository/Bussiness/SupplierRepository.cs
0 → 100644
View file @
e4765c6a
using
Models.Table
;
using
Repositories.IRepository.IBussiness
;
using
Repositories.IRepository.IUnitOfWork
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Repositories.Repository.Bussiness
{
public
class
SupplierRepository
:
BaseRepository
<
Supplier
>,
ISupplierRepository
{
public
SupplierRepository
(
ILocalSugarUnitOfWork
sugarUnitOfWork
)
:
base
(
sugarUnitOfWork
)
{
}
}
}
WebApiNET6-master/Repositories/Repository/Bussiness/WarehouseRepository.cs
0 → 100644
View file @
e4765c6a
using
Models.Table
;
using
Repositories.IRepository.IBussiness
;
using
Repositories.IRepository.IUnitOfWork
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Repositories.Repository.Bussiness
{
public
class
WarehouseRepository
:
BaseRepository
<
Warehouse
>,
IWarehouseRepository
{
public
WarehouseRepository
(
ILocalSugarUnitOfWork
sugarUnitOfWork
)
:
base
(
sugarUnitOfWork
)
{
}
}
}
WebApiNET6-master/Services/Interface/ILogService.cs
View file @
e4765c6a
...
...
@@ -18,5 +18,7 @@ namespace Services.Interface
/// <returns></returns>
Task
<
bool
>
AddLogs
(
RecordsReq
model
);
Task
<
bool
>
AddHandLogs
(
HandRecordsReq
model
);
Task
<
bool
>
AddChannelLog
(
OrderMain
?
myOrder
,
LogSummary
summary
,
List
<
Inventory
>
newInvs
);
}
}
WebApiNET6-master/Services/Interface/ISupplierService.cs
0 → 100644
View file @
e4765c6a
using
Models.Table
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Services.Interface
{
public
interface
ISupplierService
:
IBaseServices
<
Supplier
>
{
}
}
WebApiNET6-master/Services/Interface/IWarehouseService.cs
0 → 100644
View file @
e4765c6a
using
Models.Table
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Services.Interface
{
public
interface
IWarehouseService
:
IBaseServices
<
Warehouse
>
{
}
}
WebApiNET6-master/Services/LogService.cs
View file @
e4765c6a
...
...
@@ -28,6 +28,44 @@ namespace Services
mapper
=
_mapper
;
}
public
Task
<
bool
>
AddChannelLog
(
OrderMain
?
myOrder
,
LogSummary
summary
,
List
<
Inventory
>
newInvs
)
{
var
rs1
=
"normal"
;
//bussiness_state
var
rs2
=
"normal"
;
//equ_state
if
(
myOrder
!=
null
)
{
if
(
myOrder
.
orderType
.
Equals
(
"out"
))
//获取装备应设为的状态
{
switch
(
myOrder
.
bussinessType
)
{
case
"allocate"
:
rs1
=
"transfer"
;
break
;
case
"use"
:
rs1
=
"take"
;
break
;
case
"remove"
:
rs1
=
"remove"
;
break
;
case
"destruction"
:
rs1
=
"destruction"
;
rs2
=
"destory"
;
break
;
case
"repair"
:
rs1
=
"repair"
;
rs2
=
"fix"
;
break
;
default
:
break
;
}
}
}
var
inv_states
=
new
Tuple
<
string
,
string
>(
rs1
,
rs2
);
return
_logSummaryRepository
.
AddChannelLog
(
myOrder
,
summary
,
newInvs
,
inv_states
);
}
public
Task
<
bool
>
AddHandLogs
(
HandRecordsReq
model
)
{
LogSummary
log
=
mapper
.
Map
<
LogSummary
>(
model
);
...
...
WebApiNET6-master/Services/SupplierService.cs
0 → 100644
View file @
e4765c6a
using
Models.Table
;
using
Repositories.IRepository.IBussiness
;
using
Services.Interface
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Services
{
public
class
SupplierService
:
BaseService
<
Supplier
>,
ISupplierService
{
private
readonly
ISupplierRepository
_supplierRepository
;
public
SupplierService
(
ISupplierRepository
supplierRepository
)
{
base
.
BaseDal
=
supplierRepository
;
_supplierRepository
=
supplierRepository
;
}
}
}
WebApiNET6-master/Services/WarehouseService.cs
0 → 100644
View file @
e4765c6a
using
Models.Table
;
using
Repositories.IRepository.IBussiness
;
using
Services.Interface
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Services
{
public
class
WarehouseService
:
BaseService
<
Warehouse
>,
IWarehouseService
{
private
readonly
IWarehouseRepository
_WarehouseRepository
;
public
WarehouseService
(
IWarehouseRepository
WarehouseRepository
)
{
base
.
BaseDal
=
WarehouseRepository
;
_WarehouseRepository
=
WarehouseRepository
;
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论