Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit ec3c1b3a
由
LN
编写于
2021-12-31 13:22:15 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加料仓客户端取消任务接口。NL料架界面显示库位号。
1 个父辈
93cd73cd
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
125 行增加
和
70 行删除
src/main/java/com/neotel/smfcore/core/device/handler/impl/NLShelfHandler.java
src/main/java/com/neotel/smfcore/core/device/rest/DeviceController.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/NLShelfHandler.java
查看文件 @
ec3c1b3
...
...
@@ -32,7 +32,7 @@ import javax.servlet.http.HttpServletRequest;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
@Api
(
tags
=
"
智能料架/亮灯料架/普通料架
"
)
@Api
(
tags
=
"
SHELF: NL(智能料架/亮灯料架/普通料架)
"
)
@RestController
@Slf4j
public
class
NLShelfHandler
extends
BaseDeviceHandler
{
...
...
@@ -44,8 +44,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
@Autowired
private
TokenProvider
tokenProvider
;
@Autowired
private
TaskService
taskService
;
@Autowired
private
ILiteOrderManager
liteOrderManager
;
...
...
@@ -173,7 +172,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
@PostMapping
(
"/api/nlShelf/codeIn"
)
@PreAuthorize
(
"@el.check('NLShelf:putIn')"
)
public
ResultBean
codeIn
(
@RequestBody
Map
<
String
,
String
>
mapValues
,
HttpServletRequest
request
)
{
String
code
=
mapValues
.
get
(
"code"
);
String
code
=
mapValues
.
get
(
"code"
)
.
trim
()
;
String
groupId
=
mapValues
.
get
(
"group"
);
String
storageId
=
mapValues
.
get
(
"storageId"
);
String
sourceId
=
mapValues
.
get
(
"sourceId"
);
...
...
@@ -193,9 +192,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
if
(
currentStorage
==
null
||
!
currentStorage
.
isNLShelf
())
{
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.shelf.notFound"
,
"未找到料架"
);
}
if
(
currentStorage
!=
null
)
{
groupId
=
currentStorage
.
getGroupId
();
}
groupId
=
currentStorage
.
getGroupId
();
}
if
(
groupId
!=
null
&&
groupId
.
equals
(
"-1"
))
{
groupId
=
""
;
...
...
@@ -240,7 +237,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
operateBean
.
setNextPosId
(
null
);
shelfPutInBeanMap
.
put
(
token
,
operateBean
);
log
.
info
(
ptoken
+
":库位["
+
pos
.
getPosName
()
+
"]操作成功,请扫描要放入的物料"
);
return
ResultBean
.
newOkResult
(
"smfcore.shelf.msg.tipScanReel"
,
"库位["
+
pos
.
getPosName
()
+
"]操作成功,请扫描要放入的物料"
,
new
String
[]{
pos
.
getPosName
()},
""
);
return
ResultBean
.
newOkResult
(
"smfcore.shelf.msg.tipScanReel"
,
"库位["
+
pos
.
getPosName
()
+
"]操作成功,请扫描要放入的物料"
,
new
String
[]{
pos
.
getPosName
()},
pos
.
getPosName
()
);
}
}
else
{
//扫的是物料条码
...
...
@@ -313,6 +310,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
Collection
<
String
>
operatingPosIds
=
taskService
.
excludePosIds
();
StoragePos
nextPos
=
storagePosManager
.
autoFindNextEmptyPos
(
currentStorage
,
operatingPosIds
,
currentPos
);
String
nextPosId
=
nextPos
==
null
?
"null"
:
nextPos
.
getId
()
+
"["
+
nextPos
.
getPosName
()
+
"]"
;
String
data
=
nextPos
==
null
?
""
:
nextPos
.
getPosName
();
//
operateBean
.
setNextPosId
(
null
);
if
(
nextPos
!=
null
)
{
...
...
@@ -321,7 +319,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
shelfPutInBeanMap
.
put
(
token
,
operateBean
);
log
.
info
(
ptoken
+
":条码["
+
code
+
"]入库操作成功,请放入库位 ["
+
currentPos
.
getPosName
()
+
"],下一个库位号:"
+
nextPosId
);
return
ResultBean
.
newOkResult
(
"smfcore.shelf.msg.inOk"
,
"操作成功,请放入库位["
+
currentPos
.
getPosName
()
+
"]"
,
new
String
[]{
currentPos
.
getPosName
()},
""
);
return
ResultBean
.
newOkResult
(
"smfcore.shelf.msg.inOk"
,
"操作成功,请放入库位["
+
currentPos
.
getPosName
()
+
"]"
,
new
String
[]{
currentPos
.
getPosName
()},
data
);
}
}
...
...
@@ -340,6 +338,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
Collection
<
String
>
operatingPosIds
=
taskService
.
excludePosIds
();
StoragePos
nextPos
=
storagePosManager
.
autoFindNextEmptyPos
(
currentStorage
,
operatingPosIds
,
opPos
);
String
nextPosId
=
nextPos
==
null
?
"null"
:
nextPos
.
getId
()
+
"["
+
nextPos
.
getPosName
()
+
"]"
;
String
data
=
nextPos
==
null
?
""
:
nextPos
.
getPosName
();
//
operateBean
.
setNextPosId
(
null
);
if
(
nextPos
!=
null
)
{
...
...
@@ -347,7 +346,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
}
shelfPutInBeanMap
.
put
(
token
,
operateBean
);
log
.
info
(
ptoken
+
":条码["
+
code
+
"]入库操作成功,请放入库位 ["
+
opPos
.
getPosName
()+
"],下一个库位号:"
+
nextPosId
);
return
ResultBean
.
newOkResult
(
"smfcore.shelf.msg.inOk"
,
"操作成功,请放入库位["
+
opPos
.
getPosName
()+
"]"
,
new
String
[]{
opPos
.
getPosName
()},
""
);
return
ResultBean
.
newOkResult
(
"smfcore.shelf.msg.inOk"
,
"操作成功,请放入库位["
+
opPos
.
getPosName
()+
"]"
,
new
String
[]{
opPos
.
getPosName
()},
data
);
}
}
catch
(
ValidateException
e
)
{
...
...
src/main/java/com/neotel/smfcore/core/device/rest/DeviceController.java
查看文件 @
ec3c1b3
...
...
@@ -5,6 +5,7 @@ import com.google.common.base.Strings;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
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.Constants
;
import
com.neotel.smfcore.common.utils.ReelLockPosUtil
;
...
...
@@ -16,7 +17,6 @@ import com.neotel.smfcore.core.system.service.po.AlarmInfo;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
com.neotel.smfcore.security.annotation.AnonymousPostMapping
;
import
com.neotel.smfcore.core.storage.enums.DeviceType
;
import
com.neotel.smfcore.core.device.handler.IDeviceHandler
;
import
com.neotel.smfcore.core.device.bean.StatusBean
;
...
...
@@ -24,16 +24,12 @@ import com.neotel.smfcore.core.device.util.DataCache;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
@Slf4j
...
...
@@ -51,14 +47,14 @@ public class DeviceController {
private
IAlarmInfoDao
alarmInfoDao
;
@Autowired
private
CodeResolve
codeResolve
;
private
CodeResolve
codeResolve
;
private
Map
<
String
,
IDeviceHandler
>
handlerMap
=
new
HashMap
<>();
public
DeviceController
(
List
<
IDeviceHandler
>
deviceHandlerList
){
public
DeviceController
(
List
<
IDeviceHandler
>
deviceHandlerList
)
{
for
(
IDeviceHandler
deviceHandler
:
deviceHandlerList
)
{
log
.
info
(
"加载到"
+
deviceHandler
.
getDeviceType
()
+
"处理类 :"
+
deviceHandler
.
getClass
());
handlerMap
.
put
(
deviceHandler
.
getDeviceType
().
name
(),
deviceHandler
);
log
.
info
(
"加载到"
+
deviceHandler
.
getDeviceType
()
+
"处理类 :"
+
deviceHandler
.
getClass
());
handlerMap
.
put
(
deviceHandler
.
getDeviceType
().
name
(),
deviceHandler
);
}
}
...
...
@@ -77,11 +73,11 @@ public class DeviceController {
synchronized
(
storage
)
{
String
deviceType
=
storage
.
getType
();
IDeviceHandler
deviceHandler
=
handlerMap
.
get
(
deviceType
);
if
(
deviceHandler
==
null
)
{
if
(
deviceHandler
==
null
)
{
//未找到处理类,使用默认处理类
deviceHandler
=
handlerMap
.
get
(
DeviceType
.
AUTO
.
name
());
deviceHandler
=
handlerMap
.
get
(
DeviceType
.
AUTO
.
name
());
}
StatusBean
resultBean
=
deviceHandler
.
handleClientRequest
(
statusBean
,
request
);
StatusBean
resultBean
=
deviceHandler
.
handleClientRequest
(
statusBean
,
request
);
return
resultBean
;
}
}
catch
(
Exception
e
)
{
...
...
@@ -102,51 +98,51 @@ public class DeviceController {
@PostMapping
(
value
=
"/service/store/emptyPosForPutin"
)
@ResponseBody
@AnonymousAccess
public
Map
<
String
,
Object
>
emptyPosForPutin
(
HttpServletRequest
request
)
{
public
Map
<
String
,
Object
>
emptyPosForPutin
(
HttpServletRequest
request
)
{
String
code
=
request
.
getParameter
(
"code"
);
String
cids
=
request
.
getParameter
(
"cids"
);
String
rfid
=
request
.
getParameter
(
"rfid"
);
String
rfidLoc
=
request
.
getParameter
(
"rfidLoc"
);
String
lastPosId
=
request
.
getParameter
(
"lastPosId"
);
String
lastPosId
=
request
.
getParameter
(
"lastPosId"
);
lineMsg
=
""
;
log
.
info
(
"流水线["
+
cids
+
"]获取["
+
rfid
+
"]["
+
code
+
"]的入库库位"
);
Map
<
String
,
Object
>
resultMap
=
Maps
.
newHashMap
();
log
.
info
(
"流水线["
+
cids
+
"]获取["
+
rfid
+
"]["
+
code
+
"]的入库库位"
);
Map
<
String
,
Object
>
resultMap
=
Maps
.
newHashMap
();
if
(
dataCahche
.
getCache
(
Constants
.
CACHE_StopOut
))
{
if
(
dataCahche
.
getCache
(
Constants
.
CACHE_StopOut
))
{
lineMsg
=
"系统更新中,暂停出入库"
;
resultMap
.
put
(
"result"
,
"100"
);
resultMap
.
put
(
"msg"
,
lineMsg
);
resultMap
.
put
(
"result"
,
"100"
);
resultMap
.
put
(
"msg"
,
lineMsg
);
return
resultMap
;
}
String
okMsg
=
""
;
String
errorMsg
=
""
;
if
(
Strings
.
isNullOrEmpty
(
cids
))
{
resultMap
.
put
(
"result"
,
"101"
);
resultMap
.
put
(
"msg"
,
"未指定料仓 cids "
);
}
else
{
if
(
Strings
.
isNullOrEmpty
(
cids
))
{
resultMap
.
put
(
"result"
,
"101"
);
resultMap
.
put
(
"msg"
,
"未指定料仓 cids "
);
}
else
{
List
<
Storage
>
storageList
=
Lists
.
newArrayList
();
List
<
String
>
cidList
=
Lists
.
newArrayList
();
for
(
String
cid:
cids
.
split
(
","
))
{
List
<
String
>
cidList
=
Lists
.
newArrayList
();
for
(
String
cid
:
cids
.
split
(
","
))
{
String
notIntoCids
=
dataCahche
.
getSettings
().
getNotIntoCids
();
if
(
notIntoCids
!=
null
)
{
if
(
notIntoCids
.
contains
(
cid
))
{
log
.
info
(
"料仓["
+
cid
+
"]已被屏蔽入库"
);
if
(
notIntoCids
!=
null
)
{
if
(
notIntoCids
.
contains
(
cid
))
{
log
.
info
(
"料仓["
+
cid
+
"]已被屏蔽入库"
);
continue
;
}
}
Storage
storage
=
dataCahche
.
getStorage
(
cid
);
if
(
storage
!=
null
)
{
if
(
storage
!=
null
)
{
storageList
.
add
(
storage
);
cidList
.
add
(
cid
);
}
}
if
(
storageList
.
isEmpty
())
{
resultMap
.
put
(
"result"
,
"99"
);
if
(
storageList
.
isEmpty
())
{
resultMap
.
put
(
"result"
,
"99"
);
errorMsg
=
"无可用的料仓"
;
resultMap
.
put
(
"msg"
,
errorMsg
);
}
else
{
resultMap
.
put
(
"msg"
,
errorMsg
);
}
else
{
try
{
Barcode
barcode
=
codeResolve
.
resolveOneValideBarcode
(
code
);
...
...
@@ -191,9 +187,9 @@ public class DeviceController {
}
}
StoragePos
pos
=
taskService
.
findEmptyPosForPutIn
(
storageList
,
barcode
,
rfid
,
lastPosId
);
StoragePos
pos
=
taskService
.
findEmptyPosForPutIn
(
storageList
,
barcode
,
rfid
,
lastPosId
);
if
(
pos
!=
null
)
{
if
(
pos
!=
null
)
{
// Storage storage = dataCache.getStorageById(pos.getStorageId());
// if(!storage.isPackage()){
...
...
@@ -213,15 +209,15 @@ public class DeviceController {
Storage
theStorage
=
dataCahche
.
getStorageById
(
pos
.
getStorageId
());
resultMap
.
put
(
"result"
,
"0"
);
resultMap
.
put
(
"msg"
,
""
);
resultMap
.
put
(
"result"
,
"0"
);
resultMap
.
put
(
"msg"
,
""
);
okMsg
=
"["
+
rfid
+
"]["
+
barcode
.
getBarcode
()+
"]锁定库位["
+
pos
.
getPosName
()+
"]优先级["
+
pos
.
getPriority
()+
"] 上个库位号["
+
lastPosId
+
"]"
;
okMsg
=
"["
+
rfid
+
"]["
+
barcode
.
getBarcode
()
+
"]锁定库位["
+
pos
.
getPosName
()
+
"]优先级["
+
pos
.
getPriority
()
+
"] 上个库位号["
+
lastPosId
+
"]"
;
ReelLockPosInfo
oldLockInfo
=
ReelLockPosUtil
.
getLockPosInfoByCode
(
barcode
.
getBarcode
());
if
(
oldLockInfo
!=
null
)
{
if
(
oldLockInfo
!=
null
)
{
if
(!
oldLockInfo
.
getBarcode
().
equals
(
barcode
.
getBarcode
()))
{
String
result
=
"-1"
;
okMsg
=
rfid
+
"["
+
rfidLoc
+
"]["
+
barcode
.
getBarcode
()
+
"]锁定库位["
+
pos
.
getPosName
()
+
"],清理旧有锁定信息"
;
...
...
@@ -243,41 +239,41 @@ public class DeviceController {
reelLocInfo
.
setLockPosName
(
pos
.
getPosName
());
reelLocInfo
.
setLockPosId
(
pos
.
getId
());
reelLocInfo
=
ReelLockPosUtil
.
addReelLockPosInfo
(
reelLocInfo
,
cidList
);
if
(
reelLocInfo
==
null
)
{
reelLocInfo
=
ReelLockPosUtil
.
addReelLockPosInfo
(
reelLocInfo
,
cidList
);
if
(
reelLocInfo
==
null
)
{
errorMsg
=
"库位已被锁定,暂停入库"
;
lineMsg
=
errorMsg
;
resultMap
.
put
(
"result"
,
"99"
);
resultMap
.
put
(
"msg"
,
errorMsg
);
resultMap
.
put
(
"result"
,
"99"
);
resultMap
.
put
(
"msg"
,
errorMsg
);
return
resultMap
;
}
else
{
resultMap
.
put
(
"pos"
,
pos
.
getPosName
());
resultMap
.
put
(
"barcode"
,
barcode
.
getBarcode
());
resultMap
.
put
(
"cid"
,
theStorage
.
getCid
());
}
else
{
resultMap
.
put
(
"pos"
,
pos
.
getPosName
());
resultMap
.
put
(
"barcode"
,
barcode
.
getBarcode
());
resultMap
.
put
(
"cid"
,
theStorage
.
getCid
());
}
}
else
{
resultMap
.
put
(
"result"
,
"104"
);
errorMsg
=
"["
+
barcode
.
getBarcode
()+
"]未找到可用的["
+
barcode
.
getPlateSize
()
+
"x"
+
barcode
.
getHeight
()+
"]仓位"
;
resultMap
.
put
(
"msg"
,
errorMsg
);
}
else
{
resultMap
.
put
(
"result"
,
"104"
);
errorMsg
=
"["
+
barcode
.
getBarcode
()
+
"]未找到可用的["
+
barcode
.
getPlateSize
()
+
"x"
+
barcode
.
getHeight
()
+
"]仓位"
;
resultMap
.
put
(
"msg"
,
errorMsg
);
}
}
catch
(
ValidateException
ve
)
{
errorMsg
=
ve
.
getMessage
();
log
.
info
(
"查找空库位失败:"
+
errorMsg
);
resultMap
.
put
(
"result"
,
"105"
);
resultMap
.
put
(
"msg"
,
errorMsg
);
resultMap
.
put
(
"result"
,
"105"
);
resultMap
.
put
(
"msg"
,
errorMsg
);
}
catch
(
Exception
e
)
{
errorMsg
=
e
.
getMessage
();
log
.
info
(
"查找空库位失败,"
,
e
);
resultMap
.
put
(
"result"
,
"105"
);
resultMap
.
put
(
"msg"
,
errorMsg
);
log
.
info
(
"查找空库位失败,"
,
e
);
resultMap
.
put
(
"result"
,
"105"
);
resultMap
.
put
(
"msg"
,
errorMsg
);
}
}
}
//没入成功
if
(!
errorMsg
.
isEmpty
())
{
if
(!
errorMsg
.
isEmpty
())
{
//有错误,记录日志
AlarmInfo
alarmInfo
=
new
AlarmInfo
();
alarmInfo
.
setBoxId
(
"0"
);
...
...
@@ -287,14 +283,74 @@ public class DeviceController {
Date
date
=
new
Date
();
alarmInfo
.
setStartTime
(
date
);
alarmInfo
.
setEndTime
(
date
);
String
msg
=
"["
+
code
+
"]"
+
errorMsg
;
String
msg
=
"["
+
code
+
"]"
+
errorMsg
;
alarmInfo
.
setAlarmMsg
(
msg
);
alarmInfoDao
.
save
(
alarmInfo
);
lineMsg
=
errorMsg
;
}
else
{
}
else
{
lineMsg
=
okMsg
;
}
return
resultMap
;
}
@ApiOperation
(
"取消入库任务"
)
@RequestMapping
(
value
=
"/service/store/cancelPutInTask"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
cancelPutInTask
(
HttpServletRequest
request
)
{
String
codeStr
=
request
.
getParameter
(
"barcode"
);
try
{
Collection
<
DataLog
>
tasks
=
taskService
.
getAllTasks
();
for
(
DataLog
task
:
tasks
)
{
if
(
codeStr
.
contains
(
task
.
getBarcode
()))
{
if
(
task
.
isPutInTask
())
{
boolean
cancelResult
=
taskService
.
cancelTask
(
task
.
getId
());
log
.
info
(
"客户端取消["
+
codeStr
+
"]的入库任务结果:"
+
cancelResult
);
return
ResultBean
.
newOkResult
(
cancelResult
);
}
}
}
}
catch
(
Exception
e
)
{
return
ResultBean
.
newErrorResult
(
2002
,
"smfcore.cancelPutInTask.fail"
,
"客户端取消入库任务[{0}]失败:{1}"
,
new
String
[]{
codeStr
,
e
.
getMessage
()});
}
return
ResultBean
.
newErrorResult
(
2003
,
"smfcore.cancelPutInTask.fail"
,
"客户端取消入库任务[{0}]失败:{1}"
,
new
String
[]{
codeStr
,
""
});
}
@ApiOperation
(
"取消出库任务"
)
@RequestMapping
(
value
=
"/service/store/cancelOutTask"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
cancelOutTask
(
HttpServletRequest
request
)
{
String
codeStr
=
request
.
getParameter
(
"barcode"
);
try
{
Collection
<
DataLog
>
tasks
=
taskService
.
getAllTasks
();
for
(
DataLog
task
:
tasks
)
{
if
(
codeStr
.
contains
(
task
.
getBarcode
())){
if
(
task
.
isCheckOutTask
()){
if
(
task
.
isWait
()
||
task
.
isExecuting
()){
//未执行完成的,理论上不会从客户端取消
boolean
cancelResult
=
taskService
.
cancelTask
(
task
.
getId
());
log
.
info
(
"客户端取消["
+
codeStr
+
"]的未执行完成的出库任务结果:"
+
cancelResult
);
return
ResultBean
.
newOkResult
(
cancelResult
);
}
else
{
return
ResultBean
.
newErrorResult
(
2005
,
"smfcore.cancelOutTask.taskHasEnd"
,
"客户端取消入库任务[{0}]失败:任务已结束或已取消"
,
new
String
[]{
codeStr
});
}
// else{
// //禁用库位
// boolean prohibitePos = true;
// boolean hideResult = taskService.hideTask(task.getId(),prohibitePos);
// log.info("客户端取消["+codeStr+"]已完成的出库任务结果:" + hideResult);
// return ResultBean.newOkResult(hideResult);
// }
}
}
}
}
catch
(
Exception
e
){
return
ResultBean
.
newErrorResult
(
2004
,
"smfcore.cancelOutTask.fail"
,
"客户端取消入库任务[{0}]失败:{1}"
,
new
String
[]{
codeStr
,
e
.
getMessage
()});
}
return
ResultBean
.
newErrorResult
(
2005
,
"smfcore.cancelOutTask.fail"
,
"客户端取消入库任务[{0}]失败:{1}"
,
new
String
[]{
codeStr
,
""
});
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论