Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 42184f56
由
zshaohui
编写于
2024-07-02 14:16:17 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
原材料Gr手动入库
1 个父辈
0c23fb7a
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
488 行增加
和
101 行删除
src/main/java/com/neotel/smfcore/core/order/LiteOrderCache.java
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/controller/manual/ManualGrPutInController.java
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/util/BoxHandleUtil.java
src/main/java/com/neotel/smfcore/core/order/LiteOrderCache.java
查看文件 @
42184f5
...
@@ -1382,93 +1382,72 @@ public class LiteOrderCache {
...
@@ -1382,93 +1382,72 @@ public class LiteOrderCache {
for
(
LiteOrderItem
orderItem
:
cacheOrder
.
getOrderItems
())
{
for
(
LiteOrderItem
orderItem
:
cacheOrder
.
getOrderItems
())
{
int
remainNum
=
orderItem
.
getNeedNum
()
-
orderItem
.
getTotalOutNum
();
String
partNumber
=
orderItem
.
getPn
();
//1.查找所有符合条件的pn
if
(
remainNum
<=
0
)
{
continue
;
}
Collection
<
String
>
excludePosIds
=
excludeOutPosIds
();
//找到hold的
List
<
String
>
holdPosIdList
=
getHoldPosIdList
(
cacheOrder
);
if
(
holdPosIdList
!=
null
&&
!
holdPosIdList
.
isEmpty
())
{
excludePosIds
.
addAll
(
holdPosIdList
);
}
if
(
dataLogList
!=
null
&&
!
dataLogList
.
isEmpty
())
{
for
(
DataLog
dataLog
:
dataLogList
)
{
excludePosIds
.
add
(
dataLog
.
getPosId
());
}
}
int
taskNum
=
0
;
int
remainNum
=
orderItem
.
getNeedNum
()
-
orderItem
.
getTotalOutNum
();
String
pn
=
orderItem
.
getPn
();
String
warehouseCode
=
orderItem
.
getWarehouseCode
();
Criteria
c
=
Criteria
.
where
(
"barcode.partNumber"
).
is
(
pn
)
while
(
taskNum
<
remainNum
)
{
.
and
(
"id"
).
nin
(
excludePosIds
)
.
and
(
"enabled"
).
is
(
true
)
.
and
(
"storageId"
).
in
(
storageIdList
)
.
and
(
"barcode.warehouseCode"
).
is
(
warehouseCode
);
List
<
StoragePos
>
posList
=
storagePosManager
.
findByQuery
(
new
Query
(
c
)
);
log
.
info
(
orderNo
+
"已分配数量为:"
+
taskNum
+
",剩余数量为:"
+
remainNum
);
if
(
storageIdList
!=
null
&&
!
storageIdList
.
isEmpty
())
{
Collection
<
String
>
excludePosIds
=
excludeOutPosIds
();
posList
.
addAll
(
0
,
storagePosList
);
if
(
dataLogList
!=
null
&&
!
dataLogList
.
isEmpty
()){
}
for
(
DataLog
dataLog
:
dataLogList
)
{
excludePosIds
.
add
(
dataLog
.
getPosId
());
}
}
if
(
posList
==
null
||
posList
.
isEmpty
())
{
//1.先从执行的料箱中出库
finishedOrderTasks
(
cacheOrder
);
StoragePos
pos
=
null
;
throw
new
ValidateException
(
""
,
orderItem
.
getPn
()
+
"库存不足,odn:"
+
cacheOrder
.
getOrderNo
()
+
"无法进行出库"
);
if
(
storagePosList
!=
null
&&
!
storagePosList
.
isEmpty
())
{
}
for
(
StoragePos
storagePos
:
storagePosList
)
{
if
(
excludePosIds
.
contains
(
storagePos
.
getId
()))
{
continue
;
}
if
(
partNumber
.
equals
(
storagePos
.
getBarcode
().
getPartNumber
()))
{
pos
=
storagePos
;
break
;
}
}
}
//开始寻找组合数量为needOutNum的库存
if
(
pos
==
null
)
{
List
<
Integer
>
amountList
=
new
ArrayList
<>();
pos
=
storagePosManager
.
findPartNumberInStorages
(
storageIdList
,
partNumber
,
excludePosIds
,
checkoutType
,
orderItem
.
getBrand
(),
orderItem
.
getWarehouseCode
());
for
(
StoragePos
storagePos
:
posList
)
{
}
Barcode
barcode
=
storagePos
.
getBarcode
();
if
(
pos
==
null
)
{
amountList
.
add
(
barcode
.
getQty
());
break
;
}
else
{
Barcode
barcode
=
pos
.
getBarcode
();
log
.
info
(
barcode
.
getBarcode
()
+
"需要生成出库任务,工单号为:"
+
orderNo
+
",数量为:"
+
barcode
.
getQty
());
taskNum
=
taskNum
+
barcode
.
getQty
();
taskReelCount
=
taskReelCount
+
1
;
DataLog
task
=
newTask
(
pos
);
task
.
setSourceId
(
cacheOrder
.
getId
());
task
.
setSourceName
(
cacheOrder
.
getOrderNo
());
task
.
setSubSourceId
(
orderItem
.
getId
());
task
.
setSubSourceInfo
(
orderItem
.
getFeederInfo
());
task
.
setType
(
OP
.
CHECKOUT
);
task
.
setStatus
(
OP_STATUS
.
WAIT
.
name
());
task
.
setLoc
(
TaskLocUtil
.
OUT
);
if
(
StringUtils
.
isNotEmpty
(
barcode
.
getCartonId
())){
task
.
setCartonId
(
barcode
.
getCartonId
());
}
task
.
setOdn
(
true
);
dataLogList
.
add
(
task
);
}
}
}
//寻找到组合
//如果数量不满足,则提示出来
List
<
List
<
Integer
>>
combinations
=
CombinationUtil
.
findCombinationsWithoutDuplicates
(
amountList
,
remainNum
);
if
(
taskNum
<
remainNum
){
Collections
.
sort
(
combinations
,
Comparator
.
comparingInt
(
List:
:
size
));
if
(
combinations
.
isEmpty
())
{
finishedOrderTasks
(
cacheOrder
);
finishedOrderTasks
(
cacheOrder
);
throw
new
ValidateException
(
""
,
orderItem
.
getPn
()
+
"需要出库的数量为:"
+
remainNum
+
",未找到符合条件的组合
"
);
throw
new
ValidateException
(
""
,
orderItem
.
getPn
()
+
"库存不足,odn:"
+
cacheOrder
.
getOrderNo
()+
"无法进行出库
"
);
}
}
}
//开始出库
for
(
DataLog
dataLog
:
dataLogList
)
{
List
<
Integer
>
needOutNumList
=
combinations
.
get
(
0
);
taskService
.
addTaskToExecute
(
dataLog
);
while
(
needOutNumList
.
size
()
>
0
)
{
Integer
qty
=
needOutNumList
.
get
(
0
);
for
(
StoragePos
pos
:
posList
)
{
if
(
excludePosIds
.
contains
(
pos
.
getId
()))
{
continue
;
}
Barcode
barcode
=
pos
.
getBarcode
();
if
(
barcode
.
getQty
()
==
qty
)
{
log
.
info
(
barcode
.
getBarcode
()
+
"需要生成出库任务,工单号为:"
+
orderNo
+
",数量为:"
+
barcode
.
getQty
());
taskReelCount
=
taskReelCount
+
1
;
DataLog
task
=
newTask
(
pos
);
task
.
setSourceId
(
cacheOrder
.
getId
());
task
.
setSourceName
(
cacheOrder
.
getOrderNo
());
task
.
setSubSourceId
(
orderItem
.
getId
());
task
.
setSubSourceInfo
(
orderItem
.
getFeederInfo
());
task
.
setType
(
OP
.
CHECKOUT
);
task
.
setStatus
(
OP_STATUS
.
WAIT
.
name
());
task
.
setLoc
(
TaskLocUtil
.
OUT
);
if
(
StringUtils
.
isNotEmpty
(
barcode
.
getCartonId
()))
{
task
.
setCartonId
(
barcode
.
getCartonId
());
}
task
.
setOdn
(
true
);
dataLogList
.
add
(
task
);
excludePosIds
.
add
(
pos
.
getId
());
break
;
}
}
needOutNumList
.
remove
(
0
);
}
}
}
if
(
taskReelCount
<=
0
)
{
if
(
taskReelCount
<=
0
)
{
...
@@ -1477,9 +1456,6 @@ public class LiteOrderCache {
...
@@ -1477,9 +1456,6 @@ public class LiteOrderCache {
throw
new
ValidateException
(
"smfcore.order.out.noTask"
,
"工单无可执行的任务"
);
throw
new
ValidateException
(
"smfcore.order.out.noTask"
,
"工单无可执行的任务"
);
}
}
for
(
DataLog
dataLog
:
dataLogList
)
{
taskService
.
addTaskToExecute
(
dataLog
);
}
cacheOrder
.
setTaskReelCount
(
taskReelCount
);
cacheOrder
.
setTaskReelCount
(
taskReelCount
);
...
...
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/controller/manual/ManualGrPutInController.java
0 → 100644
查看文件 @
42184f5
package
com
.
neotel
.
smfcore
.
custom
.
luxsan
.
factory_c
.
rawstor
.
controller
.
manual
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.DateUtil
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.api.SmfApi
;
import
com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.device.enums.OP
;
import
com.neotel.smfcore.core.device.enums.OP_STATUS
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.storage.service.manager.IStoragePosManager
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.custom.luxsan.api.LuxsanApi
;
import
com.neotel.smfcore.custom.luxsan.api.bean.request.NewLabelToCellRequest
;
import
com.neotel.smfcore.custom.luxsan.api.bean.request.QueryGrStatusRequest
;
import
com.neotel.smfcore.custom.luxsan.api.bean.result.NewLabelToCellResult
;
import
com.neotel.smfcore.custom.luxsan.api.bean.result.QueryGrStatusResult
;
import
com.neotel.smfcore.custom.luxsan.factory_c.common.util.CommonUtil
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.QueryGrStatusDto
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.enums.TaskCurrentLoc
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BinCacheUtil
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BoxHandleUtil
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
@ApiOperation
(
"手动GR入库"
)
@Slf4j
@RequestMapping
(
"/manualGr"
)
@RestController
public
class
ManualGrPutInController
{
@Autowired
private
CodeResolve
codeResolve
;
@Autowired
private
SmfApi
smfApi
;
@Autowired
private
IStoragePosManager
storagePosManager
;
@Autowired
private
IBarcodeManager
barcodeManager
;
@Autowired
private
TaskService
taskService
;
@Autowired
private
DataCache
dataCache
;
@ApiOperation
(
"获取GR已过账的列表"
)
@RequestMapping
(
"/grStatus"
)
@AnonymousAccess
public
ResultBean
grStatus
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
//物料
String
codeStr
=
paramMap
.
get
(
"codeStr"
);
if
(
StringUtils
.
isEmpty
(
codeStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"条码信息"
});
}
//解析条码为barcode
Barcode
barcode
=
codeResolve
.
resolveCode
(
codeStr
);
if
(
barcode
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.error.barcode.noValidCode"
,
"条码无效"
);
}
QueryGrStatusRequest
request
=
new
QueryGrStatusRequest
(
CommonUtil
.
plantCode
,
barcode
.
getProvider
(),
barcode
.
getPartNumber
(),
""
,
""
);
List
<
QueryGrStatusResult
>
queryGrStatusList
=
LuxsanApi
.
queryGrStatus
(
request
);
return
ResultBean
.
newOkResult
(
QueryGrStatusDto
.
convertQueryGrStatusResultDto
(
queryGrStatusList
));
}
@ApiOperation
(
"获取料箱信息"
)
@RequestMapping
(
"/getBoxInfo"
)
@AnonymousAccess
public
ResultBean
getBoxInfo
(
String
boxStr
){
if
(
StringUtils
.
isEmpty
(
boxStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"料箱信息"
});
}
return
ResultBean
.
newOkResult
(
BoxHandleUtil
.
getBoxInfo
(
boxStr
));
}
@ApiOperation
(
"GR料盘入到料格"
)
@RequestMapping
(
"/reelToBox"
)
@AnonymousAccess
public
synchronized
ResultBean
reelToBox
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
binCode
=
paramMap
.
get
(
"binCode"
);
//料格信息
String
udCode
=
paramMap
.
get
(
"udCode"
);
//过账编码
String
codeStr
=
paramMap
.
get
(
"codeStr"
);
//条码信息
String
warhouseCode
=
paramMap
.
get
(
"warhouseCode"
);
//库别
String
grCode
=
paramMap
.
get
(
"grCode"
);
//GrCode
String
boxStr
=
paramMap
.
get
(
"boxStr"
);
//料箱信息
log
.
info
(
"人工GR入库,料格信息为:"
+
binCode
+
",过账编码为:"
+
udCode
+
"条码信息为:"
+
codeStr
);
if
(
StringUtils
.
isEmpty
(
binCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"料格信息"
});
}
if
(
StringUtils
.
isEmpty
(
udCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"过账编码"
});
}
if
(
StringUtils
.
isEmpty
(
codeStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"条码信息"
});
}
if
(
StringUtils
.
isEmpty
(
warhouseCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"库别"
});
}
if
(
StringUtils
.
isEmpty
(
grCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"Gr信息"
});
}
if
(
StringUtils
.
isEmpty
(
boxStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"料箱信息"
});
}
//判断条码是否正常
Barcode
barcode
=
null
;
try
{
barcode
=
codeResolve
.
resolveOneValideBarcode
(
codeStr
);
}
catch
(
ValidateException
ve
)
{
return
ResultBean
.
newErrorResult
(-
1
,
ve
.
getMsgKey
(),
ve
.
getDefaultMsg
());
}
//判断是否存在料箱中
if
(
StringUtils
.
isNotEmpty
(
barcode
.
getPosName
()))
{
log
.
info
(
barcode
.
getBarcode
()
+
"已经存在料格"
+
barcode
.
getPosName
());
return
ResultBean
.
newErrorResult
(-
1
,
""
,
barcode
.
getBarcode
()
+
"已经存在料格"
+
barcode
.
getPosName
());
}
//找到box信息
Barcode
boxBarcode
=
null
;
StoragePos
inPos
=
null
;
try
{
boxBarcode
=
codeResolve
.
resolveOneValideBarcode
(
boxStr
);
inPos
=
storagePosManager
.
getByBarcode
(
boxBarcode
.
getBarcode
());
if
(
inPos
!=
null
){
boxBarcode
=
inPos
.
getBarcode
();
}
}
catch
(
ValidateException
ve
){
return
ResultBean
.
newErrorResult
(-
1
,
ve
.
getMsgKey
(),
"料箱条码不正确:"
+
boxStr
);
}
//判断料格条码和料箱是否匹配
if
(!
binCode
.
startsWith
(
boxBarcode
.
getBarcode
())){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"当前扫描的隔口"
+
binCode
+
"与料箱信息:"
+
boxStr
+
"不匹配"
);
}
//判断是否为禁用料
barcode
=
smfApi
.
canPutInAfterResolve
(
barcode
);
//判断隔口能否放入
if
(
boxBarcode
!=
null
){
if
(
BinCacheUtil
.
canPutInBinCode
(
binCode
,
warhouseCode
))
{
NewLabelToCellResult
cell
=
LuxsanApi
.
newLabelToCell
(
new
NewLabelToCellRequest
(
CommonUtil
.
plantCode
,
Arrays
.
asList
(
udCode
),
barcode
.
getAmount
(),
binCode
,
Arrays
.
asList
(
barcode
.
getFullCode
())));
//将GR日期设置为生产日期
Date
grDate
=
DateUtil
.
getNoTimeDate
(
cell
.
getGR_DATE
());
barcode
.
setProduceDate
(
grDate
);
barcode
.
setLabelId
(
cell
.
getLABEL_ID
());
barcode
.
setPosName
(
binCode
);
barcode
.
setWarehouseCode
(
warhouseCode
);
barcode
.
setBarSource
(
grCode
);
barcode
.
setSeq
(
BoxHandleUtil
.
getSeq
(
boxBarcode
,
binCode
)+
1
);
barcode
.
setPutInTime
(
System
.
currentTimeMillis
());
barcode
=
barcodeManager
.
save
(
barcode
);
generatePutInTask
(
barcode
,
boxBarcode
,
OP_STATUS
.
FINISHED
.
name
());
boxBarcode
.
updateSubCodes
(
barcode
);
boxBarcode
.
setAmount
(
boxBarcode
.
getAmount
()+
barcode
.
getAmount
());
barcodeManager
.
save
(
boxBarcode
);
if
(
inPos
!=
null
){
//流程异常时,为保证数据一致性, pos中的box barcode也需要更新
inPos
.
setBarcode
(
boxBarcode
);
storagePosManager
.
save
(
inPos
);
}
return
ResultBean
.
newOkResult
(
BoxHandleUtil
.
getBoxInfo
(
boxStr
));
}
}
return
ResultBean
.
newErrorResult
(-
1
,
""
,
barcode
.
getBarcode
()
+
"不可以放到料格:"
+
binCode
);
}
@ApiOperation
(
"完成装箱并入库"
)
@RequestMapping
(
"/boxToPos"
)
@AnonymousAccess
public
synchronized
ResultBean
boxToPos
(
String
boxStr
)
{
if
(
StringUtils
.
isEmpty
(
boxStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"料箱信息"
});
}
//1.判断有没有正在执行的任务
List
<
DataLog
>
taskList
=
taskService
.
getAllTasks
();
for
(
DataLog
dataLog
:
taskList
)
{
if
(
boxStr
.
startsWith
(
dataLog
.
getBarcode
()))
{
if
(!
dataLog
.
isFinished
()
&&
!
dataLog
.
isCancel
())
{
if
(
dataLog
.
isPutInTask
())
{
return
ResultBean
.
newOkResult
(
dataLog
);
}
else
{
log
.
info
(
boxStr
+
"有正在执行的出库任务,服务器更改状态为完成"
);
dataLog
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
taskService
.
updateFinishedTask
(
dataLog
);
}
}
}
}
//2.获取空库位
Barcode
boxBarcode
=
codeResolve
.
resolveOneValideBarcode
(
boxStr
);
StoragePos
pos
=
BoxHandleUtil
.
locOnePos
(
boxBarcode
);
if
(
pos
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
boxStr
+
"未找到可用库位"
);
}
//4.生成入库任务
Storage
storage
=
dataCache
.
getStorageById
(
pos
.
getStorageId
());
DataLog
dataLog
=
taskService
.
addPutInTaskToExecute
(
storage
,
boxBarcode
,
pos
,
TaskCurrentLoc
.
Manual_DischargeHole
);
return
ResultBean
.
newOkResult
(
"库位为:"
+
dataLog
.
getPosName
());
}
private
void
generatePutInTask
(
Barcode
barcode
,
Barcode
boxBarcode
,
String
status
)
{
DataLog
dataLog
=
new
DataLog
();
dataLog
.
setPosId
(
boxBarcode
.
getId
());
dataLog
.
setPosName
(
barcode
.
getPosName
());
dataLog
.
setBarcode
(
barcode
.
getBarcode
());
dataLog
.
setW
(
barcode
.
getPlateSize
());
dataLog
.
setH
(
barcode
.
getHeight
());
dataLog
.
setPartNumber
(
barcode
.
getPartNumber
());
dataLog
.
setNum
(
barcode
.
getAmount
());
dataLog
.
setType
(
OP
.
PUT_IN
);
dataLog
.
setStatus
(
status
);
dataLog
.
setBatchInfo
(
barcode
.
getBatch
());
dataLog
.
setSourceName
(
barcode
.
getBarSource
());
dataLog
.
setWarehouseCode
(
barcode
.
getWarehouseCode
());
taskService
.
updateFinishedTask
(
dataLog
);
}
}
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/util/BoxHandleUtil.java
查看文件 @
42184f5
...
@@ -25,6 +25,7 @@ import org.springframework.data.mongodb.core.query.Query;
...
@@ -25,6 +25,7 @@ import org.springframework.data.mongodb.core.query.Query;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -62,6 +63,20 @@ public class BoxHandleUtil {
...
@@ -62,6 +63,20 @@ public class BoxHandleUtil {
}
}
/**
* key 为料箱号
* value 为数量
*/
private
static
Map
<
String
,
Integer
>
boxAllCountMap
=
new
ConcurrentHashMap
<>();
/**
* key为箱号
* value为A、B面
*/
private
static
Map
<
String
,
String
>
boxSideMap
=
new
ConcurrentHashMap
<>();
public
static
void
intoPos
(
DataLog
opTask
)
{
public
static
void
intoPos
(
DataLog
opTask
)
{
//已完成,加入库存,并且从完成队列中清除
//已完成,加入库存,并且从完成队列中清除
StoragePos
storagePos
=
storagePosManager
.
get
(
opTask
.
getPosId
());
StoragePos
storagePos
=
storagePosManager
.
get
(
opTask
.
getPosId
());
...
@@ -84,10 +99,10 @@ public class BoxHandleUtil {
...
@@ -84,10 +99,10 @@ public class BoxHandleUtil {
taskService
.
updateFinishedTask
(
opTask
);
taskService
.
updateFinishedTask
(
opTask
);
List
<
Barcode
>
subCodeList
=
barcode
.
getSubCodeList
();
List
<
Barcode
>
subCodeList
=
barcode
.
getSubCodeList
();
if
(
subCodeList
!=
null
&&
!
subCodeList
.
isEmpty
()){
if
(
subCodeList
!=
null
&&
!
subCodeList
.
isEmpty
())
{
for
(
Barcode
subCode
:
subCodeList
)
{
for
(
Barcode
subCode
:
subCodeList
)
{
if
(
subCode
.
isOut
()){
if
(
subCode
.
isOut
())
{
log
.
info
(
barcode
.
getBarcode
()
+
"有要出库的任务,需要重新出库"
);
log
.
info
(
barcode
.
getBarcode
()
+
"有要出库的任务,需要重新出库"
);
Storage
storage
=
dataCache
.
getStorageById
(
storagePos
.
getStorageId
());
Storage
storage
=
dataCache
.
getStorageById
(
storagePos
.
getStorageId
());
DataLog
dataLog
=
new
DataLog
(
storage
,
barcode
,
storagePos
);
DataLog
dataLog
=
new
DataLog
(
storage
,
barcode
,
storagePos
);
dataLog
.
setType
(
OP
.
CHECKOUT
);
dataLog
.
setType
(
OP
.
CHECKOUT
);
...
@@ -138,7 +153,7 @@ public class BoxHandleUtil {
...
@@ -138,7 +153,7 @@ public class BoxHandleUtil {
}
}
public
static
StoragePos
callEmptyBox
(
String
size
,
String
outLet
,
String
wareHouseCode
,
List
<
String
>
needBinCodeList
)
{
public
static
StoragePos
callEmptyBox
(
String
size
,
String
outLet
,
String
wareHouseCode
,
List
<
String
>
needBinCodeList
)
{
String
box
=
""
;
String
box
=
""
;
if
(
"7"
.
equals
(
size
))
{
if
(
"7"
.
equals
(
size
))
{
box
=
"C07"
;
box
=
"C07"
;
...
@@ -150,8 +165,8 @@ public class BoxHandleUtil {
...
@@ -150,8 +165,8 @@ public class BoxHandleUtil {
//判断有没有可用的料箱
//判断有没有可用的料箱
List
<
String
>
boxList
=
BinCacheUtil
.
getBoxList
(
wareHouseCode
);
List
<
String
>
boxList
=
BinCacheUtil
.
getBoxList
(
wareHouseCode
);
if
(
boxList
==
null
||
boxList
.
isEmpty
()){
if
(
boxList
==
null
||
boxList
.
isEmpty
())
{
log
.
info
(
wareHouseCode
+
"未找到可用料箱"
);
log
.
info
(
wareHouseCode
+
"未找到可用料箱"
);
return
null
;
return
null
;
}
}
...
@@ -166,7 +181,7 @@ public class BoxHandleUtil {
...
@@ -166,7 +181,7 @@ public class BoxHandleUtil {
c
.
and
(
"barcode.status"
).
is
(
BARCODE_STATUS
.
IN_STORE
);
c
.
and
(
"barcode.status"
).
is
(
BARCODE_STATUS
.
IN_STORE
);
c
.
and
(
"barcode.barcode"
).
in
(
boxList
);
c
.
and
(
"barcode.barcode"
).
in
(
boxList
);
if
(
needBinCodeList
!=
null
&&
!
needBinCodeList
.
isEmpty
()){
if
(
needBinCodeList
!=
null
&&
!
needBinCodeList
.
isEmpty
())
{
List
<
Criteria
>
criteriaList
=
new
ArrayList
<>();
List
<
Criteria
>
criteriaList
=
new
ArrayList
<>();
...
@@ -214,7 +229,7 @@ public class BoxHandleUtil {
...
@@ -214,7 +229,7 @@ public class BoxHandleUtil {
}
}
}
else
if
(
"13"
.
equals
(
size
)
||
"15"
.
equals
(
size
))
{
}
else
if
(
"13"
.
equals
(
size
)
||
"15"
.
equals
(
size
))
{
String
binCode
=
barcode
.
getBarcode
()
+
"-01"
;
String
binCode
=
barcode
.
getBarcode
()
+
"-01"
;
if
(
countMap
.
get
(
binCode
)
==
null
||
countMap
.
get
(
binCode
)
==
0
){
if
(
countMap
.
get
(
binCode
)
==
null
||
countMap
.
get
(
binCode
)
==
0
)
{
storagePos
=
pos
;
storagePos
=
pos
;
break
;
break
;
}
}
...
@@ -226,19 +241,19 @@ public class BoxHandleUtil {
...
@@ -226,19 +241,19 @@ public class BoxHandleUtil {
if
(
storagePos
!=
null
)
{
if
(
storagePos
!=
null
)
{
Storage
storage
=
dataCache
.
getStorageById
(
storagePos
.
getStorageId
());
Storage
storage
=
dataCache
.
getStorageById
(
storagePos
.
getStorageId
());
String
toLoc
=
"In_FeedingInlet"
;
String
toLoc
=
"In_FeedingInlet"
;
if
(
StringUtils
.
isNotEmpty
(
outLet
)){
if
(
StringUtils
.
isNotEmpty
(
outLet
))
{
if
(
"1"
.
equals
(
outLet
)){
if
(
"1"
.
equals
(
outLet
))
{
toLoc
=
"In1_FeedingInlet"
;
toLoc
=
"In1_FeedingInlet"
;
}
else
if
(
"2"
.
equals
(
outLet
)){
}
else
if
(
"2"
.
equals
(
outLet
))
{
toLoc
=
"In2_FeedingInlet"
;
toLoc
=
"In2_FeedingInlet"
;
}
}
}
}
int
priority
=
0
;
int
priority
=
0
;
if
(
needBinCodeList
!=
null
&&
!
needBinCodeList
.
isEmpty
()){
if
(
needBinCodeList
!=
null
&&
!
needBinCodeList
.
isEmpty
())
{
priority
=
999
;
priority
=
999
;
}
}
generateTask
(
storage
,
storagePos
.
getBarcode
(),
storagePos
,
OP
.
CHECKOUT
,
OP_STATUS
.
WAIT
.
name
(),
toLoc
,
ExtendType
.
STORAGE_CHECKOUT
,
priority
);
generateTask
(
storage
,
storagePos
.
getBarcode
(),
storagePos
,
OP
.
CHECKOUT
,
OP_STATUS
.
WAIT
.
name
(),
toLoc
,
ExtendType
.
STORAGE_CHECKOUT
,
priority
);
return
storagePos
;
return
storagePos
;
}
}
...
@@ -246,7 +261,7 @@ public class BoxHandleUtil {
...
@@ -246,7 +261,7 @@ public class BoxHandleUtil {
}
}
private
static
DataLog
generateTask
(
Storage
storage
,
Barcode
barcode
,
StoragePos
pos
,
int
type
,
String
status
,
String
loc
,
int
extendType
,
int
priority
)
{
private
static
DataLog
generateTask
(
Storage
storage
,
Barcode
barcode
,
StoragePos
pos
,
int
type
,
String
status
,
String
loc
,
int
extendType
,
int
priority
)
{
//开始入库任务
//开始入库任务
DataLog
task
=
new
DataLog
(
storage
,
barcode
,
pos
);
DataLog
task
=
new
DataLog
(
storage
,
barcode
,
pos
);
task
.
setType
(
type
);
task
.
setType
(
type
);
...
@@ -268,7 +283,7 @@ public class BoxHandleUtil {
...
@@ -268,7 +283,7 @@ public class BoxHandleUtil {
}
}
public
static
String
getBoxStr
(
String
code
,
boolean
suffix
)
{
public
static
String
getBoxStr
(
String
code
,
boolean
suffix
)
{
if
(
code
.
endsWith
(
"A"
)
||
code
.
endsWith
(
"B"
))
{
if
(
code
.
endsWith
(
"A"
)
||
code
.
endsWith
(
"B"
))
{
code
=
code
.
substring
(
0
,
code
.
length
()
-
1
);
code
=
code
.
substring
(
0
,
code
.
length
()
-
1
);
if
(
suffix
)
{
if
(
suffix
)
{
...
@@ -287,17 +302,18 @@ public class BoxHandleUtil {
...
@@ -287,17 +302,18 @@ public class BoxHandleUtil {
/**
/**
* 获取序列号
* 获取序列号
*
* @param boxBarcode
* @param boxBarcode
* @param binCode
* @param binCode
* @return
* @return
*/
*/
public
static
int
getSeq
(
Barcode
boxBarcode
,
String
binCode
)
{
public
static
int
getSeq
(
Barcode
boxBarcode
,
String
binCode
)
{
int
seq
=
0
;
int
seq
=
0
;
List
<
Barcode
>
subCodeList
=
boxBarcode
.
getSubCodeList
();
List
<
Barcode
>
subCodeList
=
boxBarcode
.
getSubCodeList
();
if
(
subCodeList
!=
null
&&
!
subCodeList
.
isEmpty
()){
if
(
subCodeList
!=
null
&&
!
subCodeList
.
isEmpty
())
{
for
(
Barcode
barcode
:
subCodeList
)
{
for
(
Barcode
barcode
:
subCodeList
)
{
if
(
binCode
.
equals
(
barcode
.
getPosName
())){
if
(
binCode
.
equals
(
barcode
.
getPosName
()))
{
if
(
seq
<
barcode
.
getSeq
()){
if
(
seq
<
barcode
.
getSeq
())
{
seq
=
barcode
.
getSeq
();
seq
=
barcode
.
getSeq
();
}
}
}
}
...
@@ -306,10 +322,10 @@ public class BoxHandleUtil {
...
@@ -306,10 +322,10 @@ public class BoxHandleUtil {
return
seq
;
return
seq
;
}
}
public
static
StoragePos
locOnePos
(
Barcode
boxBarcode
){
public
static
StoragePos
locOnePos
(
Barcode
boxBarcode
)
{
//判断信息是否在已经在库位中(出入库只改变料箱位置状态,不从StoragePos表中清除)
//判断信息是否在已经在库位中(出入库只改变料箱位置状态,不从StoragePos表中清除)
StoragePos
pos
=
storagePosManager
.
getByBarcode
(
boxBarcode
.
getBarcode
());
StoragePos
pos
=
storagePosManager
.
getByBarcode
(
boxBarcode
.
getBarcode
());
if
(
pos
!=
null
){
if
(
pos
!=
null
)
{
return
pos
;
return
pos
;
}
}
...
@@ -324,8 +340,8 @@ public class BoxHandleUtil {
...
@@ -324,8 +340,8 @@ public class BoxHandleUtil {
if
(
pos
==
null
)
{
if
(
pos
==
null
)
{
log
.
info
(
boxBarcode
.
getBarcode
()
+
"未找到可用库位"
);
log
.
info
(
boxBarcode
.
getBarcode
()
+
"未找到可用库位"
);
return
null
;
return
null
;
}
else
{
}
else
{
log
.
info
(
"料箱["
+
boxBarcode
.
getBarcode
()+
"]信息加入库位["
+
pos
.
getPosName
()+
"]中"
);
log
.
info
(
"料箱["
+
boxBarcode
.
getBarcode
()
+
"]信息加入库位["
+
pos
.
getPosName
()
+
"]中"
);
pos
.
setBarcode
(
boxBarcode
);
pos
.
setBarcode
(
boxBarcode
);
pos
.
setUsed
(
true
);
pos
.
setUsed
(
true
);
storagePosManager
.
save
(
pos
);
storagePosManager
.
save
(
pos
);
...
@@ -346,4 +362,142 @@ public class BoxHandleUtil {
...
@@ -346,4 +362,142 @@ public class BoxHandleUtil {
return
pos
;
return
pos
;
}
}
public
static
Map
<
String
,
Object
>
getBoxInfo
(
String
code
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
String
platsize
=
""
;
int
boxAllCount
=
0
;
int
boxRemainingCount
=
0
;
String
boxStr
=
""
;
String
msg
=
""
;
List
<
List
<
Integer
>>
boxPartitionCounts
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotBlank
(
code
))
{
if
(
code
.
startsWith
(
"C07"
)
||
code
.
startsWith
(
"C13"
)
||
code
.
startsWith
(
"C15"
))
{
String
endStr
=
code
.
substring
(
code
.
length
()
-
1
);
//得到是A、B面
boxStr
=
getBoxStr
(
code
,
false
);
if
(
boxSideMap
.
get
(
boxStr
)
!=
null
)
{
endStr
=
boxSideMap
.
get
(
boxStr
);
}
else
{
boxSideMap
.
put
(
boxStr
,
endStr
);
}
//1、获取料箱的
Barcode
barcode
=
barcodeManager
.
findByBarcode
(
boxStr
);
if
(
barcode
!=
null
)
{
List
<
Barcode
>
subCodeList
=
barcode
.
getSubCodeList
();
if
(
subCodeList
!=
null
&&
!
subCodeList
.
isEmpty
())
{
if
(
boxAllCountMap
.
get
(
boxStr
)
==
null
)
{
boxAllCountMap
.
put
(
boxStr
,
subCodeList
.
size
());
}
//进行库位分组
Map
<
String
,
Long
>
allCountMap
=
subCodeList
.
stream
().
collect
(
Collectors
.
groupingBy
(
Barcode:
:
getPosName
,
Collectors
.
counting
()));
//得到需要出库的数量
Map
<
String
,
Long
>
needOutCountMap
=
new
HashMap
<>();
List
<
Barcode
>
outSubCodeList
=
subCodeList
.
stream
().
filter
(
s
->
s
.
isOut
()).
collect
(
Collectors
.
toList
());
if
(
outSubCodeList
!=
null
&&
!
outSubCodeList
.
isEmpty
())
{
needOutCountMap
=
outSubCodeList
.
stream
().
collect
(
Collectors
.
groupingBy
(
Barcode:
:
getPosName
,
Collectors
.
counting
()));
}
List
<
Integer
>
partition1
=
new
ArrayList
<>();
partition1
.
add
(
getCountByPartition
(
needOutCountMap
,
boxStr
+
"-01"
));
partition1
.
add
(
getCountByPartition
(
allCountMap
,
boxStr
+
"-01"
));
partition1
.
add
(
1
);
List
<
Integer
>
partition2
=
new
ArrayList
<>();
partition2
.
add
(
getCountByPartition
(
needOutCountMap
,
boxStr
+
"-02"
));
partition2
.
add
(
getCountByPartition
(
allCountMap
,
boxStr
+
"-02"
));
partition2
.
add
(
2
);
List
<
Integer
>
partition3
=
new
ArrayList
<>();
partition3
.
add
(
getCountByPartition
(
needOutCountMap
,
boxStr
+
"-03"
));
partition3
.
add
(
getCountByPartition
(
allCountMap
,
boxStr
+
"-03"
));
partition3
.
add
(
3
);
List
<
Integer
>
partition4
=
new
ArrayList
<>();
partition4
.
add
(
getCountByPartition
(
needOutCountMap
,
boxStr
+
"-04"
));
partition4
.
add
(
getCountByPartition
(
allCountMap
,
boxStr
+
"-04"
));
partition4
.
add
(
4
);
List
<
Integer
>
partition5
=
new
ArrayList
<>();
partition5
.
add
(
getCountByPartition
(
needOutCountMap
,
boxStr
+
"-05"
));
partition5
.
add
(
getCountByPartition
(
allCountMap
,
boxStr
+
"-05"
));
partition5
.
add
(
5
);
List
<
Integer
>
partition6
=
new
ArrayList
<>();
partition6
.
add
(
getCountByPartition
(
needOutCountMap
,
boxStr
+
"-06"
));
partition6
.
add
(
getCountByPartition
(
allCountMap
,
boxStr
+
"-06"
));
partition6
.
add
(
6
);
//根据箱子面展示不同的隔扣
if
(
boxStr
.
startsWith
(
"C07"
))
{
platsize
=
"7"
;
if
(
"A"
.
equals
(
endStr
))
{
boxPartitionCounts
.
add
(
partition2
);
boxPartitionCounts
.
add
(
partition4
);
boxPartitionCounts
.
add
(
partition6
);
boxPartitionCounts
.
add
(
partition1
);
boxPartitionCounts
.
add
(
partition3
);
boxPartitionCounts
.
add
(
partition5
);
}
else
{
boxPartitionCounts
.
add
(
partition5
);
boxPartitionCounts
.
add
(
partition3
);
boxPartitionCounts
.
add
(
partition1
);
boxPartitionCounts
.
add
(
partition6
);
boxPartitionCounts
.
add
(
partition4
);
boxPartitionCounts
.
add
(
partition2
);
}
}
else
if
(
boxStr
.
startsWith
(
"C13"
))
{
platsize
=
"13"
;
if
(
"A"
.
equals
(
endStr
))
{
boxPartitionCounts
.
add
(
partition1
);
boxPartitionCounts
.
add
(
partition2
);
boxPartitionCounts
.
add
(
partition3
);
}
else
{
boxPartitionCounts
.
add
(
partition3
);
boxPartitionCounts
.
add
(
partition2
);
boxPartitionCounts
.
add
(
partition1
);
}
}
else
if
(
boxStr
.
startsWith
(
"C15"
))
{
platsize
=
"15"
;
if
(
"A"
.
equals
(
endStr
))
{
boxPartitionCounts
.
add
(
partition1
);
boxPartitionCounts
.
add
(
partition2
);
boxPartitionCounts
.
add
(
partition3
);
}
else
{
boxPartitionCounts
.
add
(
partition3
);
boxPartitionCounts
.
add
(
partition2
);
boxPartitionCounts
.
add
(
partition1
);
}
}
boxAllCount
=
boxAllCountMap
.
get
(
boxStr
)
==
null
?
0
:
boxAllCountMap
.
get
(
boxStr
);
boxRemainingCount
=
subCodeList
.
size
();
}
}
}
}
resultMap
.
put
(
"platsize"
,
platsize
);
resultMap
.
put
(
"boxPartitionCounts"
,
boxPartitionCounts
);
resultMap
.
put
(
"boxAllCount"
,
boxAllCount
);
resultMap
.
put
(
"boxRemainingCount"
,
boxRemainingCount
);
resultMap
.
put
(
"currentRfid"
,
boxStr
);
resultMap
.
put
(
"box"
,
boxStr
);
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
();
for
(
DataLog
queueTask
:
queueTasks
)
{
if
(
queueTask
.
getBarcode
().
equals
(
boxStr
))
{
if
(
queueTask
.
isCheckOutTask
())
{
msg
=
boxStr
+
"需执行出库操作"
;
//提示信息
}
else
{
msg
=
boxStr
+
"需执行入库操作"
;
//提示信息
}
}
}
resultMap
.
put
(
"msg"
,
msg
);
return
resultMap
;
}
private
static
int
getCountByPartition
(
Map
<
String
,
Long
>
paramMap
,
String
partition
)
{
return
paramMap
.
get
(
partition
)
==
null
?
0
:
paramMap
.
get
(
partition
).
intValue
();
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论