Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit b869b98a
由
张少辉
编写于
2026-03-16 13:43:21 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1.电子仓货架CTU对接
1 个父辈
ab35d3a4
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
280 行增加
和
14 行删除
src/main/java/com/neotel/smfcore/core/device/rest/DualPosNameDeviceController.java
src/main/java/com/neotel/smfcore/custom/aiqingzhiyin1643/electronicWarehouse/AgvElecDeviceController.java
src/main/java/com/neotel/smfcore/core/device/rest/DualPosNameDeviceController.java
查看文件 @
b869b98
...
...
@@ -246,26 +246,14 @@ public class DualPosNameDeviceController {
StoragePos
pos
=
null
;
int
loopCount
=
0
;
List
<
String
>
needRemoveLockPosId
=
new
ArrayList
<>();
String
endStr
=
"B"
;
while
(
pos
==
null
)
{
loopCount
++;
if
(
loopCount
>=
30
)
{
log
.
info
(
barcode
.
getBarcode
()
+
"已循环查找30次 直接跳出循环"
);
break
;
}
if
(
loopCount
>=
15
)
{
endStr
=
"F"
;
}
pos
=
taskService
.
dualPosNameFindEmptyPosForPutIn
(
findNewStorageList
,
barcode
,
rfid
,
lastPosId
,
barcode
.
getBarcode
(),
endStr
);
if
(
pos
==
null
)
{
if
(
"B"
.
equals
(
endStr
))
{
endStr
=
"F"
;
}
else
{
endStr
=
"B"
;
}
pos
=
taskService
.
dualPosNameFindEmptyPosForPutIn
(
findNewStorageList
,
barcode
,
rfid
,
lastPosId
,
barcode
.
getBarcode
(),
endStr
);
}
pos
=
taskService
.
dualPosNameFindEmptyPosForPutIn
(
findNewStorageList
,
barcode
,
rfid
,
lastPosId
,
barcode
.
getBarcode
(),
""
);
if
(
pos
==
null
)
{
break
;
}
...
...
src/main/java/com/neotel/smfcore/custom/aiqingzhiyin1643/electronicWarehouse/AgvElecDeviceController.java
0 → 100644
查看文件 @
b869b98
package
com
.
neotel
.
smfcore
.
custom
.
aiqingzhiyin1643
.
electronicWarehouse
;
import
com.google.common.collect.Lists
;
import
com.neotel.smfcore.common.bean.ReelLockPosInfo
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.ReelLockPosUtil
;
import
com.neotel.smfcore.common.utils.StringUtils
;
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_STATUS
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.inList.util.InListCache
;
import
com.neotel.smfcore.core.storage.enums.CORRESPONDING_WAREHOUSE
;
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.manager.IDataLogManager
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.custom.aiqingzhiyin1643.bean.CtuCheckOutTask
;
import
com.neotel.smfcore.custom.aiqingzhiyin1643.bean.CtuPutInTask
;
import
com.neotel.smfcore.custom.aiqingzhiyin1643.momo.MomoApi
;
import
com.neotel.smfcore.custom.aiqingzhiyin1643.structuralWarehouse.util.BoxUtil
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Slf4j
@RestController
@RequestMapping
(
"/agvElecDevice"
)
public
class
AgvElecDeviceController
{
@Autowired
private
TaskService
taskService
;
@Autowired
private
CodeResolve
codeResolve
;
@Autowired
private
DataCache
dataCache
;
@Autowired
private
IDataLogManager
dataLogManager
;
@Autowired
private
MomoApi
momoApi
;
@Autowired
private
IBarcodeManager
barcodeManager
;
@Autowired
private
InListCache
inListCache
;
@ApiOperation
(
"获取库位号(1.如果有入库任务,直接返回库位号 2.如果没有入库任务,则生成一个入库任务,返回库位号)"
)
@RequestMapping
(
"/service/store/agvBox/generatePutInTask"
)
@AnonymousAccess
public
ResultBean
generatePutInTask
(
HttpServletRequest
request
)
{
String
boxStr
=
request
.
getParameter
(
"barcode"
);
String
currentLoc
=
request
.
getParameter
(
"currentLoc"
);
String
cid
=
request
.
getParameter
(
"cid"
);
log
.
info
(
"收到获取库位号的接口,料箱为:"
+
boxStr
+
",当前位置为:"
+
currentLoc
+
",cid为:"
+
cid
);
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
"boxStr"
,
""
);
resultMap
.
put
(
"posName"
,
""
);
try
{
Barcode
barcode
=
codeResolve
.
resolveOneValideBarcode
(
"=2x2="
+
boxStr
);
if
(
StringUtils
.
isNotEmpty
(
barcode
.
getPosName
()))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.materialBox.inPos"
,
"物料已在库位{0}中"
,
new
String
[]{
barcode
.
getBarcode
()});
}
//判断出库任务有没有结束
List
<
DataLog
>
dataLogList
=
taskService
.
getAllTasks
();
for
(
DataLog
dataLog
:
dataLogList
)
{
if
(
dataLog
.
isCheckOutTask
()
&&
!
dataLog
.
isFinished
()
&&
!
dataLog
.
isCancel
())
{
if
(
barcode
.
getBarcode
().
equals
(
dataLog
.
getBarcode
()))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"物料["
+
dataLog
.
getBarcode
()
+
"]已有出库任务,需继续执行出库动作"
);
}
}
}
//判断有没有任务
DataLog
dataLog
=
null
;
List
<
DataLog
>
allTasks
=
taskService
.
getAllTasks
();
for
(
DataLog
task
:
allTasks
)
{
if
(
task
.
isPutInTask
()
&&
!
task
.
isCancel
()
&&
!
task
.
isFinished
())
{
if
(
barcode
.
getBarcode
().
equals
(
task
.
getBarcode
()))
{
dataLog
=
task
;
break
;
}
}
}
if
(
dataLog
!=
null
)
{
resultMap
.
put
(
"boxStr"
,
barcode
.
getBarcode
());
resultMap
.
put
(
"posName"
,
dataLog
.
getPosName
());
}
else
{
//如果任务不存在,则创建新任务
List
<
Storage
>
storageList
=
new
ArrayList
<>();
List
<
String
>
cidList
=
Lists
.
newArrayList
();
Storage
storage
=
dataCache
.
getStorage
(
cid
);
storageList
.
add
(
storage
);
cidList
.
add
(
storage
.
getCid
());
ReelLockPosUtil
.
removeReelLockPosInfo
(
barcode
.
getBarcode
());
StoragePos
pos
=
taskService
.
findEmptyPosForPutIn
(
storageList
,
barcode
,
""
,
""
);
if
(
pos
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.noValidStorage"
,
"[{0}]料仓列表中未找到可用的料仓"
,
new
String
[]{
barcode
.
getBarcode
()});
}
else
{
ReelLockPosInfo
oldLockInfo
=
ReelLockPosUtil
.
getLockPosInfoByCode
(
barcode
.
getBarcode
());
if
(
oldLockInfo
!=
null
)
{
if
(!
oldLockInfo
.
getBarcode
().
equals
(
barcode
.
getBarcode
()))
{
ReelLockPosUtil
.
removeReelLockPosInfo
(
oldLockInfo
.
getBarcode
());
log
.
info
(
"清理锁定库位:库位号["
+
oldLockInfo
.
getLockPosName
()
+
"]上物料["
+
oldLockInfo
.
getBarcode
()
+
"]锁定的库位"
);
}
}
ReelLockPosInfo
reelLocInfo
=
new
ReelLockPosInfo
();
reelLocInfo
.
setBarcode
(
barcode
.
getBarcode
());
reelLocInfo
.
setCid
(
storage
.
getCid
());
reelLocInfo
.
setLockPosName
(
pos
.
getPosName
());
reelLocInfo
.
setLockPosId
(
pos
.
getId
());
reelLocInfo
=
ReelLockPosUtil
.
addReelLockPosInfo
(
reelLocInfo
,
cidList
);
if
(
reelLocInfo
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"["
+
barcode
.
getBarcode
()
+
"]库位["
+
reelLocInfo
.
getLockPosName
()
+
"]已被锁定,暂停入库"
,
new
String
[]{});
}
DataLog
inTask
=
BoxUtil
.
generateInTask
(
pos
,
barcode
,
currentLoc
);
taskService
.
addTaskToExecute
(
inTask
);
resultMap
.
put
(
"boxStr"
,
barcode
.
getBarcode
());
resultMap
.
put
(
"posName"
,
inTask
.
getPosName
());
}
}
}
catch
(
ValidateException
e
)
{
log
.
info
(
boxStr
+
"解析失败:"
+
e
.
getMessage
());
return
ResultBean
.
newErrorResult
(-
1
,
e
.
getMsgKey
(),
e
.
getMessage
(),
e
.
getMsgParam
());
}
return
ResultBean
.
newOkResult
(
resultMap
);
}
@ApiOperation
(
"定时获取入库任务"
)
@RequestMapping
(
"/service/store/agvBox/getPutInTask"
)
@AnonymousAccess
public
ResultBean
getPutInTask
(
String
cid
)
{
List
<
CtuPutInTask
>
putInTaskList
=
new
ArrayList
<>();
List
<
DataLog
>
allTasks
=
taskService
.
getAllTasks
();
Storage
storage
=
dataCache
.
getStorage
(
cid
);
if
(
storage
!=
null
)
{
for
(
DataLog
dataLog
:
allTasks
)
{
if
(
dataLog
.
isPutInTask
()
&&
!
dataLog
.
isFinished
()
&&
!
dataLog
.
isCancel
()
&&
storage
.
getId
().
equals
(
dataLog
.
getStorageId
()))
{
CtuPutInTask
putInTask
=
new
CtuPutInTask
();
putInTask
.
setStatus
(
dataLog
.
getStatus
());
putInTask
.
setPosName
(
dataLog
.
getPosName
());
putInTask
.
setBarcode
(
dataLog
.
getBarcode
());
putInTask
.
setPutInLoc
(
dataLog
.
getCurrentLoc
());
putInTaskList
.
add
(
putInTask
);
}
}
}
return
ResultBean
.
newOkResult
(
putInTaskList
);
}
@ApiOperation
(
"修改任务接口"
)
@RequestMapping
(
value
=
"/service/store/agvBox/updateLocInfo"
)
@AnonymousAccess
public
synchronized
ResultBean
updateLocInfo
(
HttpServletRequest
request
)
{
String
rfid
=
request
.
getParameter
(
"barcode"
);
String
statusStr
=
request
.
getParameter
(
"status"
);
String
cid
=
request
.
getParameter
(
"cid"
);
String
loc
=
request
.
getParameter
(
"loc"
);
//工位
log
.
info
(
"收到料盘["
+
rfid
+
"]更新位置指令["
+
statusStr
+
"]"
+
"cid为:"
+
cid
);
if
(
statusStr
==
null
)
{
return
ResultBean
.
newErrorResult
(
301
,
"smfcore.updateLoc.status.empty"
,
"状态不能为空"
);
}
if
(
rfid
==
null
)
{
return
ResultBean
.
newErrorResult
(
302
,
"smfcore.updateLoc.barcode.empty"
,
"条码不能为空"
);
}
Storage
storage
=
dataCache
.
getStorage
(
cid
);
if
(
storage
==
null
){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"未找到对应的料仓信息"
);
}
if
(
storage
.
getCorrespondingWarehouse
()
!=
CORRESPONDING_WAREHOUSE
.
ELECTRONIC_WAREHOUSE_BOX
){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"请在设备管理里,配置成品仓信息"
);
}
DataLog
opTask
=
null
;
List
<
DataLog
>
allTasks
=
taskService
.
getAllTasks
();
for
(
DataLog
task
:
allTasks
)
{
if
(
rfid
.
startsWith
(
task
.
getBarcode
())
&&
storage
.
getId
().
equals
(
task
.
getStorageId
()))
{
if
(!
task
.
isCancel
()
&&
!
task
.
isFinished
())
{
opTask
=
task
;
break
;
}
}
}
if
(
opTask
==
null
)
{
return
ResultBean
.
newErrorResult
(
303
,
"smfcore.task.notExist"
,
"任务不存在"
);
}
if
(
opTask
.
isFinished
())
{
return
ResultBean
.
newErrorResult
(
304
,
"smfcore.task.hasEnd"
,
"任务已完成"
);
}
statusStr
=
statusStr
.
toUpperCase
();
log
.
info
(
"更新料箱["
+
rfid
+
"]的任务状态["
+
opTask
.
getStatus
()
+
"]为["
+
statusStr
+
"]"
+
"目的地信息为:"
+
loc
);
OP_STATUS
updateStatus
=
OP_STATUS
.
valueOf
(
statusStr
);
//如果是相同状态,则不执行
if
(
statusStr
.
equals
(
opTask
.
getStatus
()))
{
return
ResultBean
.
newOkResult
(
""
);
}
if
(
updateStatus
!=
null
)
{
opTask
.
setStatus
(
statusStr
);
if
(
opTask
.
isCheckOutTask
())
{
if
(
OP_STATUS
.
EXECUTING
.
name
().
equals
(
statusStr
))
{
//在执行队列中
taskService
.
updateQueueTask
(
opTask
);
}
else
{
taskService
.
moveTaskToFinished
(
opTask
);
if
(!
opTask
.
isOutFromPos
())
{
//从库位中取出,需要移到完成队列中,并且清理库存
BoxUtil
.
outFromPos
(
opTask
);
opTask
.
setOutFromPos
(
true
);
}
taskService
.
updateFinishedTask
(
opTask
);
if
(!
opTask
.
isNotifyMomo
())
{
opTask
.
setNotifyMomo
(
true
);
taskService
.
updateFinishedTask
(
opTask
);
}
if
(
OP_STATUS
.
FINISHED
.
name
().
equals
(
statusStr
))
{
//已完成,从完成缓存中清除
taskService
.
removeFinishedTask
(
opTask
);
}
}
}
else
{
opTask
.
setStatus
(
statusStr
);
//入库任务
if
(
OP_STATUS
.
FINISHED
.
name
().
equals
(
statusStr
))
{
taskService
.
moveTaskToFinished
(
opTask
);
BoxUtil
.
intoPos
(
opTask
);
ReelLockPosUtil
.
removeReelLockPosInfo
(
opTask
.
getBarcode
());
}
else
{
taskService
.
updateQueueTask
(
opTask
);
}
}
}
else
{
log
.
info
(
rfid
+
"更新状态时未找到状态:"
+
statusStr
+
""
);
}
return
ResultBean
.
newOkResult
(
""
);
}
@ApiOperation
(
"定时获取出库库位列表"
)
@RequestMapping
(
value
=
"/service/store/agvBox/getOutTask"
)
@AnonymousAccess
public
ResultBean
getOutTask
(
HttpServletRequest
request
)
{
List
<
CtuCheckOutTask
>
ctuCheckOutTaskList
=
new
ArrayList
<>();
String
cid
=
request
.
getParameter
(
"cid"
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
if
(
storage
!=
null
)
{
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
(
storage
.
getCid
());
queueTasks
=
queueTasks
.
stream
().
sorted
(
Comparator
.
comparing
(
DataLog:
:
getPosName
)).
collect
(
Collectors
.
toList
());
for
(
DataLog
queueTask
:
queueTasks
)
{
if
(
queueTask
.
isWait
()
&&
queueTask
.
isCheckOutTask
())
{
CtuCheckOutTask
ctuCheckOutTask
=
new
CtuCheckOutTask
();
ctuCheckOutTask
.
setBarcode
(
queueTask
.
getBarcode
());
ctuCheckOutTask
.
setPosName
(
queueTask
.
getPosName
());
ctuCheckOutTask
.
setStatus
(
queueTask
.
getStatus
());
String
currentLoc
=
queueTask
.
getCurrentLoc
();
ctuCheckOutTask
.
setCheckOutLoc
(
currentLoc
);
ctuCheckOutTaskList
.
add
(
ctuCheckOutTask
);
}
}
}
return
ResultBean
.
newOkResult
(
ctuCheckOutTaskList
);
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论