Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit a824869c
由
LN
编写于
2022-01-28 14:25:40 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
料架类型CODESHELF改为NLP
1 个父辈
b3407e28
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
960 行增加
和
444 行删除
src/main/java/com/neotel/smfcore/core/device/handler/impl/NLPShelfHandler.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/SensorShelfHandler.java
src/main/java/com/neotel/smfcore/core/kanban/rest/BoxKanbanController.java
src/main/java/com/neotel/smfcore/core/storage/rest/StorageController.java
src/main/java/com/neotel/smfcore/core/storage/service/po/Storage.java
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/NLPShelfHandler.java
0 → 100644
查看文件 @
a824869
package
com
.
neotel
.
smfcore
.
core
.
device
.
handler
.
impl
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.google.common.base.Strings
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.device.api.CodeValidateParam
;
import
com.neotel.smfcore.core.device.api.IOpAuthApi
;
import
com.neotel.smfcore.core.device.bean.StatusBean
;
import
com.neotel.smfcore.core.device.enums.OP
;
import
com.neotel.smfcore.core.device.enums.OP_STATUS
;
import
com.neotel.smfcore.core.inList.util.InListCache
;
import
com.neotel.smfcore.core.order.enums.ORDER_COLOR
;
import
com.neotel.smfcore.core.storage.enums.DeviceType
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
import
com.neotel.smfcore.core.system.bean.OrderSetting
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
import
com.neotel.smfcore.core.system.websocket.MsgType
;
import
com.neotel.smfcore.core.system.websocket.SocketMsg
;
import
com.neotel.smfcore.core.system.websocket.WebSocketServer
;
import
com.neotel.smfcore.security.TokenProvider
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpSession
;
import
java.util.*
;
@Api
(
tags
=
"SHELF: NLP感应料架"
)
@RestController
@Slf4j
public
class
NLPShelfHandler
extends
BaseDeviceHandler
{
@Autowired
private
TokenProvider
tokenProvider
;
public
NLPShelfHandler
(
List
<
IOpAuthApi
>
apiList
)
{
super
(
apiList
);
}
/**
* 扫码
*/
@ApiOperation
(
"扫码入库"
)
@PostMapping
(
"/api/sensorShelf/codeIn"
)
@PreAuthorize
(
"@el.check('sensorShelf:putIn')"
)
public
ResultBean
codeIn
(
@RequestBody
Map
<
String
,
String
>
mapValues
,
HttpServletRequest
request
)
{
String
code
=
mapValues
.
get
(
"code"
);
String
groupId
=
mapValues
.
get
(
"group"
);
String
storageId
=
mapValues
.
get
(
"storageId"
);
String
sourceId
=
mapValues
.
get
(
"sourceId"
);
String
token
=
tokenProvider
.
getToken
(
request
);
if
(
ObjectUtils
.
isEmpty
(
code
)){
throw
new
ValidateException
(
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"code"
});
}
if
(
groupId
==
null
&&
storageId
==
null
){
throw
new
ValidateException
(
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"group"
});
}
if
(
groupId
==
null
&&
storageId
!=
null
){
Storage
storage
=
dataCache
.
getStorageById
(
storageId
);
if
(
storage
!=
null
){
groupId
=
storage
.
getGroupId
();
}
}
if
(
groupId
!=
null
&&
groupId
.
equals
(
"-1"
)){
groupId
=
""
;
}
// WebSocketServer.sendMsg("", new SocketMsg("这是一个webSocket消息:"+code, MsgType.INFO));
String
loginUser
=
SecurityUtils
.
getLoginUsername
();
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
();
ResultBean
resultBean
=
null
;
for
(
DataLog
queueTask
:
queueTasks
)
{
if
(
queueTask
.
isPutInTask
()
&&
queueTask
.
isWait
())
{
if
(!
Strings
.
isNullOrEmpty
(
groupId
)
&&
queueTask
.
getGroupId
().
equals
(
groupId
))
{
log
.
info
(
"codeIn ["
+
code
+
"]["
+
groupId
+
"]入库失败:条码["
+
queueTask
.
getBarcode
()
+
"]的任务还未结束 "
);
throw
new
ValidateException
(
"smfcore.unfinished"
,
"the task of [{0}] is unfinished"
,
new
String
[]{
queueTask
.
getBarcode
()});
}
if
(!
Strings
.
isNullOrEmpty
(
storageId
)
&&
queueTask
.
getStorageId
().
equals
(
storageId
))
{
log
.
info
(
"codeIn ["
+
code
+
"]["
+
storageId
+
"]入库失败:条码["
+
queueTask
.
getBarcode
()
+
"]的任务还未结束 "
);
throw
new
ValidateException
(
"smfcore.unfinished"
,
"the task of [{0}] is unfinished"
,
new
String
[]{
queueTask
.
getBarcode
()});
}
}
}
Barcode
barcodeSave
=
resolveBarcodeFromApiForShelf
(
new
CodeValidateParam
(
loginUser
,
groupId
,
storageId
,
code
,
token
));
if
(
barcodeSave
==
null
){
barcodeSave
=
codeResolve
.
resolveOneValideBarcode
(
"=1x1="
+
code
);
}
Date
expireDate
=
barcodeSave
.
getExpireDate
();
if
(
expireDate
!=
null
)
{
if
(
System
.
currentTimeMillis
()
>
expireDate
.
getTime
())
{
throw
new
ValidateException
(
"smfcore.error.barcode.expired"
,
"物料已过期,无法入库."
);
}
}
//从API验证
Barcode
verResult
=
verifyPutInFromApi
(
barcodeSave
);
if
(
verResult
==
null
){
return
testPutIn
(
loginUser
,
groupId
,
storageId
,
barcodeSave
,
token
);
}
// resultBean = hellaServiceHandler.checkMaterial(loginUser, groupId, code);
return
ResultBean
.
newOkResult
(
""
);
}
private
ResultBean
testPutIn
(
String
loginUser
,
String
groupId
,
String
storageId
,
Barcode
barcode
,
String
token
)
{
// CodeBean codeBean = codeResolve.resolveSingleCode(codeStr);
if
(
barcode
==
null
||
barcode
.
getBarcode
()
==
null
)
{
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.error.barcode.invalid"
,
"条码无效"
);
}
String
pn
=
barcode
.
getPartNumber
();
String
reelId
=
barcode
.
getBarcode
();
String
num
=
barcode
.
getAmount
()
+
""
;
Integer
qty
=
barcode
.
getAmount
();
String
msl
=
barcode
.
getMsl
();
try
{
//需要模拟一个库位
DataLog
dataLog
=
new
DataLog
();
dataLog
.
setBarcode
(
reelId
);
dataLog
.
setPartNumber
(
pn
);
dataLog
.
setType
(
OP
.
PUT_IN
);
barcode
.
setPutInTime
(
System
.
currentTimeMillis
());
barcodeManager
.
saveBarcode
(
barcode
);
dataLog
.
setNum
(
barcode
.
getAmount
());
dataLog
.
setStatus
(
OP_STATUS
.
WAIT
.
name
());
dataLog
.
setGroupId
(
groupId
);
dataLog
.
setStorageId
(
storageId
);
dataLog
.
setMemo
(
barcode
.
getMemo
());
dataLog
.
setOperator
(
loginUser
);
if
(
ObjectUtil
.
isNotEmpty
(
storageId
))
{
Storage
storage
=
dataCache
.
getStorageById
(
storageId
);
if
(
storage
!=
null
)
{
dataLog
.
setCid
(
storage
.
getCid
());
dataLog
.
setStorageName
(
storage
.
getName
());
}
}
try
{
taskService
.
addTaskToExecute
(
dataLog
);
}
catch
(
Exception
e
)
{
WebSocketServer
.
sendMsg
(
token
,
new
SocketMsg
(
e
.
getMessage
(),
MsgType
.
INFO
));
}
}
catch
(
ValidateException
e
)
{
log
.
error
(
e
.
toString
());
return
ResultBean
.
newErrorResult
(
1
,
e
.
getMsgKey
(),
e
.
getDefaultMsg
());
}
return
ResultBean
.
newOkResult
(
""
);
}
/**
* 从API接口解析条码,通常料架使用(其他设备会有尺寸信息且会有多个条码所以不适用此方法)
*/
protected
Barcode
resolveBarcodeFromApiForShelf
(
CodeValidateParam
param
)
throws
ValidateException
{
for
(
IOpAuthApi
opAuthApi
:
opAuthApiList
)
{
Barcode
responseBarcode
=
opAuthApi
.
resolveBarcode
(
param
);
if
(
responseBarcode
!=
null
){
return
responseBarcode
;
}
}
return
null
;
}
@Override
public
StatusBean
handleClientRequest
(
StatusBean
statusBean
,
HttpServletRequest
request
)
{
handleMsg
(
statusBean
);
statusBean
=
saveAlarmAndHumidity
(
statusBean
);
OrderSetting
orderSetting
=
dataCache
.
getOrderSetting
();
boolean
openZhiYin
=
orderSetting
.
getShelfLightType
().
equals
(
1
);
Map
<
String
,
List
<
DataLog
>>
outMap
=
new
HashMap
<>();
//亮灯
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
(
statusBean
.
getCid
());
for
(
DataLog
queueTask
:
queueTasks
)
{
if
(
queueTask
.
isWait
()){
queueTask
.
setStatus
(
OP_STATUS
.
EXECUTING
.
name
());
taskService
.
updateQueueTask
(
queueTask
);
String
rgb
=
queueTask
.
getLightColor
();
ORDER_COLOR
color
=
ORDER_COLOR
.
fromRgb
(
rgb
);
if
(
color
==
null
){
if
(
queueTask
.
isPutInTask
()){
color
=
ORDER_COLOR
.
DARKGREEN
;
}
else
{
if
(
openZhiYin
&&
ObjectUtil
.
isNotEmpty
(
queueTask
.
getSourceId
()))
{
List
<
DataLog
>
dataLogList
=
outMap
.
get
(
queueTask
.
getSourceId
());
if
(
dataLogList
==
null
)
{
dataLogList
=
new
ArrayList
<>();
}
dataLogList
.
add
(
queueTask
);
outMap
.
put
(
queueTask
.
getSourceId
(),
dataLogList
);
}
else
{
color
=
ORDER_COLOR
.
BLUE
;
}
}
}
statusBean
.
addData
(
"open"
,
queueTask
.
getPosName
()+
"="
+
color
.
name
());
log
.
info
(
"库位["
+
queueTask
.
getPosName
()+
"]+亮灯:"
+
color
.
name
());
}
// else if(queueTask.isCancel()){
// if(queueTask.isCheckOutTask()){
//
// statusBean.addData("open",queueTask.getPosName()+"="+"orange" );
// log.info("库位["+queueTask.getPosName()+"]+取消:open=orange" );
// //从任务列表中删除
// taskService.removeFinishedTask(queueTask);
// }
// }
}
List
<
DataLog
>
dataLogs
=
getLightGuideTask
(
outMap
);
for
(
DataLog
task
:
dataLogs
)
{
statusBean
.
addData
(
"open"
,
task
.
getPosName
()
+
"="
+
ORDER_COLOR
.
fromRgb
(
task
.
getLightColor
()).
name
());
}
return
statusBean
;
}
/**
* 客户端sensor变化
*/
@RequestMapping
(
"/service/store/sensorShelf/sensorChange"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
sensorChange
(
HttpServletRequest
request
,
HttpSession
httpSession
){
String
cid
=
request
.
getParameter
(
"cid"
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
if
(
storage
==
null
){
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.shelfNotExist"
,
"{0}对应的料架不存在"
,
new
String
[]{
cid
}
);
}
String
groupId
=
storage
.
getGroupId
();
// String groupName = "";
// Group group = groupManager.get(groupId);
// if(group != null){
// groupName = group.getGroupName();
// }
if
(
groupId
.
equals
(
""
)){
groupId
=
"-1"
;
}
String
[]
hasReelPosList
=
request
.
getParameterValues
(
"hasReelPosList"
);
String
[]
noReelPosList
=
request
.
getParameterValues
(
"noReelPosList"
);
String
[]
hasReelPosErrorList
=
request
.
getParameterValues
(
"hasReelPosErrorList"
);
//实际信号有料,数据库无信息
String
[]
noReelPosErrorList
=
request
.
getParameterValues
(
"noReelPosErrorList"
);
//实际信号无料,数据库有信息
if
(
hasReelPosErrorList
==
null
){
hasReelPosErrorList
=
new
String
[]{};
}
if
(
noReelPosErrorList
==
null
)
{
noReelPosErrorList
=
new
String
[]{};
}
List
<
String
>
ngToOk
=
new
ArrayList
<>();
// //数据库无信息,实际有料
// if(hasReelPosErrorList.length>0){
// Query query=new Query(Criteria.where("posName").in(hasReelPosErrorList));
// List<StoragePos> posList= storagePosManager.findByQuery(query);
// for (StoragePos pos:posList
// ) {
// if(pos.isUsed()){
// ngToOk.add(pos.getPosName());
// log.info("sensorChange 客户端上传 hasReelPosErrorList 库位["+pos.getPosName()+"]数据库有信息,放入ngToOk");
// }
// }
// }
//数据库有信息,实际无料
if
(
noReelPosErrorList
.
length
>
0
){
Query
query
=
new
Query
(
Criteria
.
where
(
"posName"
).
in
(
noReelPosErrorList
));
List
<
StoragePos
>
posList
=
storagePosManager
.
findByQuery
(
query
);
for
(
StoragePos
pos:
posList
)
{
if
(!
pos
.
isUsed
()){
ngToOk
.
add
(
pos
.
getPosName
());
log
.
info
(
"sensorChange 客户端上传 noReelPosErrorList 库位["
+
pos
.
getPosName
()+
"]数据库无信息,放入ngToOk"
);
}
}
}
List
<
List
<
String
>>
data
=
new
ArrayList
<>();
data
.
add
(
Arrays
.
asList
(
hasReelPosErrorList
)
);
data
.
add
(
Arrays
.
asList
(
noReelPosErrorList
));
DevicesStatusUtil
.
updateDeviceData
(
cid
,
data
);
List
<
String
>
inOkList
=
new
ArrayList
<>();
List
<
String
>
inNgList
=
new
ArrayList
<>();
List
<
String
>
outOkList
=
new
ArrayList
<>();
List
<
String
>
outNgList
=
new
ArrayList
<>();
if
(
hasReelPosList
!=
null
){
//入库的库位列表
if
(
hasReelPosList
.
length
>
1
){
String
msg
=
"不可同时放入多盘物料:"
+
String
.
join
(
","
,
hasReelPosList
);
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
for
(
String
posStr
:
hasReelPosList
)
{
inNgList
.
add
(
posStr
);
}
}
else
{
StoragePos
pos
=
storagePosManager
.
getByPosName
(
hasReelPosList
[
0
]);
if
(
pos
==
null
){
String
msg
=
"未找到库位:"
+
String
.
join
(
","
,
hasReelPosList
)
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
}
else
if
(!
pos
.
getStorageId
().
equals
(
storage
.
getId
())){
String
msg
=
"["
+
storage
.
getName
()+
"]未找到库位:"
+
String
.
join
(
","
,
hasReelPosList
)
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
}
//如果库位有料,直接结束
else
if
(
pos
.
getBarcode
()!=
null
)
{
log
.
info
(
"料架["
+
cid
+
"]入库库位["
+
pos
.
getPosName
()
+
"]已有料: ["
+
pos
.
getBarcode
().
getBarcode
()
+
"]"
);
}
else
{
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
();
for
(
DataLog
queueTask
:
queueTasks
)
{
boolean
isPutInTask
=
false
;
if
(
ObjectUtil
.
isNotEmpty
(
queueTask
.
getStorageId
())
){
if
(
queueTask
.
isPutInTask
()&&
queueTask
.
getStorageId
().
equals
(
storage
.
getId
())){
isPutInTask
=
true
;
}
}
else
if
(
queueTask
.
isPutInTask
()
&&
queueTask
.
getGroupId
().
equals
(
groupId
))
{
isPutInTask
=
true
;
}
if
(
isPutInTask
)
{
queueTask
.
setCid
(
cid
);
queueTask
.
setPosId
(
pos
.
getId
());
queueTask
.
setPosName
(
pos
.
getPosName
());
queueTask
.
setStorageId
(
storage
.
getId
());
queueTask
.
setStorageName
(
storage
.
getName
());
try
{
//入库完成,发送入库完成请求
super
.
finishedPutIn
(
cid
,
pos
.
getPosName
());
inOkList
.
add
(
hasReelPosList
[
0
]);
String
msg
=
queueTask
.
getBarcode
()
+
"入库到"
+
pos
.
getPosName
()
+
"成功"
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
INFO
));
break
;
}
catch
(
Exception
e
)
{
log
.
error
(
"入库出错"
,
e
);
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.inputError"
,
"入库出错:{0}"
,
new
String
[]{
e
.
getMessage
()});
}
}
}
if
(
inOkList
.
size
()
==
0
){
inNgList
.
add
(
hasReelPosList
[
0
]);
log
.
error
(
"未找到["
+
pos
.
getPosName
()+
"]的入库任务"
);
}
}
}
}
if
(
noReelPosList
!=
null
){
//出库
for
(
String
posName
:
noReelPosList
)
{
StoragePos
pos
=
storagePosManager
.
getByPosName
(
posName
);
if
(
pos
==
null
){
String
msg
=
"未找到库位:"
+
String
.
join
(
","
,
hasReelPosList
)
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
}
else
if
(!
pos
.
getStorageId
().
equals
(
storage
.
getId
())){
String
msg
=
"["
+
storage
.
getName
()+
"]未找到库位:"
+
String
.
join
(
","
,
hasReelPosList
)
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
}
else
if
(
pos
.
getBarcode
()==
null
){
log
.
info
(
"料架["
+
cid
+
"]出库库位["
+
pos
.
getPosName
()
+
"]已为空 "
);
}
else
{
String
outResult
=
""
;
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
();
for
(
DataLog
queueTask
:
queueTasks
)
{
if
(
queueTask
.
isCheckOutTask
()
&&
queueTask
.
getPosName
().
equals
(
posName
)){
//出库完成
try
{
outResult
=
posName
;
super
.
finishedOutPos
(
cid
,
posName
);
String
msg
=
queueTask
.
getBarcode
()+
"从"
+
posName
+
"出库成功"
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
INFO
));
break
;
}
catch
(
Exception
e
)
{
log
.
error
(
"出库出错"
,
e
);
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.checkoutError"
,
"出库出错:{0}"
,
new
String
[]{
e
.
getMessage
()});
}
}
}
if
(
outResult
.
isEmpty
()){
outNgList
.
add
(
posName
);
String
msg
=
"未找到["
+
posName
+
"]的出库任务"
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
}
else
{
outOkList
.
add
(
outResult
);
}
}
}
}
Map
<
String
,
List
<
String
>>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"inOkList"
,
inOkList
);
dataMap
.
put
(
"inNgList"
,
inNgList
);
dataMap
.
put
(
"outOkList"
,
outOkList
);
dataMap
.
put
(
"outNgList"
,
outNgList
);
dataMap
.
put
(
"ngToOk"
,
ngToOk
);
return
ResultBean
.
newOkResult
(
dataMap
);
}
/**
* 获取料架的库位占用及出库任务
*/
@RequestMapping
(
"/service/store/sensorShelf/shelfStatus"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
shelfStatus
(
HttpServletRequest
request
){
String
cid
=
request
.
getParameter
(
"cid"
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
List
<
StoragePos
>
allPos
=
storagePosManager
.
findNotEmptyByStorageId
(
storage
.
getId
());
List
<
String
>
posList
=
new
ArrayList
<>();
for
(
StoragePos
pos
:
allPos
)
{
posList
.
add
(
pos
.
getPosName
());
}
List
<
String
>
outTaskPosList
=
new
ArrayList
<>();
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
(
cid
);
for
(
DataLog
task
:
queueTasks
)
{
if
(
task
.
isCheckOutTask
()){
String
rgb
=
task
.
getLightColor
();
ORDER_COLOR
color
=
ORDER_COLOR
.
fromRgb
(
rgb
);
if
(
color
==
null
){
color
=
ORDER_COLOR
.
BLUE
;
}
String
outTaskPos
=
task
.
getPosName
()+
"="
+
color
.
name
();
outTaskPosList
.
add
(
outTaskPos
);
}
}
Map
<
String
,
List
<
String
>>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"hasReelPosList"
,
posList
);
dataMap
.
put
(
"outTaskList"
,
outTaskPosList
);
return
ResultBean
.
newOkResult
(
dataMap
);
}
/**
* 获取料架的库位占用情况
*/
@RequestMapping
(
"/service/store/sensorShelf/hasReelPosList"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
checkAll
(
HttpServletRequest
request
){
String
cid
=
request
.
getParameter
(
"cid"
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
List
<
StoragePos
>
allPos
=
storagePosManager
.
findNotEmptyByStorageId
(
storage
.
getId
());
List
<
String
>
posList
=
new
ArrayList
<>();
for
(
StoragePos
pos
:
allPos
)
{
posList
.
add
(
pos
.
getPosName
());
}
return
ResultBean
.
newOkResult
(
posList
);
}
@Override
public
DeviceType
getDeviceType
()
{
return
DeviceType
.
NLP
;
}
}
src/main/java/com/neotel/smfcore/core/device/handler/impl/SensorShelfHandler.java
查看文件 @
a824869
...
...
@@ -64,437 +64,437 @@ public class SensorShelfHandler extends BaseDeviceHandler {
super
(
apiList
);
}
/**
* 扫码
*/
@ApiOperation
(
"扫码入库"
)
@PostMapping
(
"/api/sensorShelf/codeIn"
)
@PreAuthorize
(
"@el.check('sensorShelf:putIn')"
)
public
ResultBean
codeIn
(
@RequestBody
Map
<
String
,
String
>
mapValues
,
HttpServletRequest
request
)
{
String
code
=
mapValues
.
get
(
"code"
);
String
groupId
=
mapValues
.
get
(
"group"
);
String
storageId
=
mapValues
.
get
(
"storageId"
);
String
sourceId
=
mapValues
.
get
(
"sourceId"
);
String
token
=
tokenProvider
.
getToken
(
request
);
if
(
ObjectUtils
.
isEmpty
(
code
)){
throw
new
ValidateException
(
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"code"
});
}
if
(
groupId
==
null
&&
storageId
==
null
){
throw
new
ValidateException
(
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"group"
});
}
if
(
groupId
==
null
&&
storageId
!=
null
){
Storage
storage
=
dataCache
.
getStorageById
(
storageId
);
if
(
storage
!=
null
){
groupId
=
storage
.
getGroupId
();
}
}
if
(
groupId
!=
null
&&
groupId
.
equals
(
"-1"
)){
groupId
=
""
;
}
// WebSocketServer.sendMsg("", new SocketMsg("这是一个webSocket消息:"+code, MsgType.INFO));
String
loginUser
=
SecurityUtils
.
getLoginUsername
();
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
();
ResultBean
resultBean
=
null
;
for
(
DataLog
queueTask
:
queueTasks
)
{
if
(
queueTask
.
isPutInTask
()
&&
queueTask
.
isWait
())
{
if
(!
Strings
.
isNullOrEmpty
(
groupId
)
&&
queueTask
.
getGroupId
().
equals
(
groupId
))
{
log
.
info
(
"codeIn ["
+
code
+
"]["
+
groupId
+
"]入库失败:条码["
+
queueTask
.
getBarcode
()
+
"]的任务还未结束 "
);
throw
new
ValidateException
(
"smfcore.unfinished"
,
"the task of [{0}] is unfinished"
,
new
String
[]{
queueTask
.
getBarcode
()});
}
if
(!
Strings
.
isNullOrEmpty
(
storageId
)
&&
queueTask
.
getStorageId
().
equals
(
storageId
))
{
log
.
info
(
"codeIn ["
+
code
+
"]["
+
storageId
+
"]入库失败:条码["
+
queueTask
.
getBarcode
()
+
"]的任务还未结束 "
);
throw
new
ValidateException
(
"smfcore.unfinished"
,
"the task of [{0}] is unfinished"
,
new
String
[]{
queueTask
.
getBarcode
()});
}
}
}
Barcode
barcodeSave
=
resolveBarcodeFromApiForShelf
(
new
CodeValidateParam
(
loginUser
,
groupId
,
storageId
,
code
,
token
));
if
(
barcodeSave
==
null
){
barcodeSave
=
codeResolve
.
resolveOneValideBarcode
(
"=1x1="
+
code
);
}
Date
expireDate
=
barcodeSave
.
getExpireDate
();
if
(
expireDate
!=
null
)
{
if
(
System
.
currentTimeMillis
()
>
expireDate
.
getTime
())
{
throw
new
ValidateException
(
"smfcore.error.barcode.expired"
,
"物料已过期,无法入库."
);
}
}
//从API验证
Barcode
verResult
=
verifyPutInFromApi
(
barcodeSave
);
if
(
verResult
==
null
){
return
testPutIn
(
loginUser
,
groupId
,
storageId
,
barcodeSave
,
token
);
}
// resultBean = hellaServiceHandler.checkMaterial(loginUser, groupId, code);
return
ResultBean
.
newOkResult
(
""
);
}
private
ResultBean
testPutIn
(
String
loginUser
,
String
groupId
,
String
storageId
,
Barcode
barcode
,
String
token
)
{
// CodeBean codeBean = codeResolve.resolveSingleCode(codeStr);
if
(
barcode
==
null
||
barcode
.
getBarcode
()
==
null
)
{
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.error.barcode.invalid"
,
"条码无效"
);
}
String
pn
=
barcode
.
getPartNumber
();
String
reelId
=
barcode
.
getBarcode
();
String
num
=
barcode
.
getAmount
()
+
""
;
Integer
qty
=
barcode
.
getAmount
();
String
msl
=
barcode
.
getMsl
();
try
{
//需要模拟一个库位
DataLog
dataLog
=
new
DataLog
();
dataLog
.
setBarcode
(
reelId
);
dataLog
.
setPartNumber
(
pn
);
dataLog
.
setType
(
OP
.
PUT_IN
);
barcode
.
setPutInTime
(
System
.
currentTimeMillis
());
barcodeManager
.
saveBarcode
(
barcode
);
dataLog
.
setNum
(
barcode
.
getAmount
());
dataLog
.
setStatus
(
OP_STATUS
.
WAIT
.
name
());
dataLog
.
setGroupId
(
groupId
);
dataLog
.
setStorageId
(
storageId
);
dataLog
.
setMemo
(
barcode
.
getMemo
());
dataLog
.
setOperator
(
loginUser
);
if
(
ObjectUtil
.
isNotEmpty
(
storageId
))
{
Storage
storage
=
dataCache
.
getStorageById
(
storageId
);
if
(
storage
!=
null
)
{
dataLog
.
setCid
(
storage
.
getCid
());
dataLog
.
setStorageName
(
storage
.
getName
());
}
}
try
{
taskService
.
addTaskToExecute
(
dataLog
);
}
catch
(
Exception
e
)
{
WebSocketServer
.
sendMsg
(
token
,
new
SocketMsg
(
e
.
getMessage
(),
MsgType
.
INFO
));
}
}
catch
(
ValidateException
e
)
{
log
.
error
(
e
.
toString
());
return
ResultBean
.
newErrorResult
(
1
,
e
.
getMsgKey
(),
e
.
getDefaultMsg
());
}
return
ResultBean
.
newOkResult
(
""
);
}
/**
* 从API接口解析条码,通常料架使用(其他设备会有尺寸信息且会有多个条码所以不适用此方法)
*/
protected
Barcode
resolveBarcodeFromApiForShelf
(
CodeValidateParam
param
)
throws
ValidateException
{
for
(
IOpAuthApi
opAuthApi
:
opAuthApiList
)
{
Barcode
responseBarcode
=
opAuthApi
.
resolveBarcode
(
param
);
if
(
responseBarcode
!=
null
){
return
responseBarcode
;
}
}
return
null
;
}
@Override
public
StatusBean
handleClientRequest
(
StatusBean
statusBean
,
HttpServletRequest
request
)
{
handleMsg
(
statusBean
);
statusBean
=
saveAlarmAndHumidity
(
statusBean
);
OrderSetting
orderSetting
=
dataCache
.
getOrderSetting
();
boolean
openZhiYin
=
orderSetting
.
getShelfLightType
().
equals
(
1
);
Map
<
String
,
List
<
DataLog
>>
outMap
=
new
HashMap
<>();
//亮灯
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
(
statusBean
.
getCid
());
for
(
DataLog
queueTask
:
queueTasks
)
{
if
(
queueTask
.
isWait
()){
queueTask
.
setStatus
(
OP_STATUS
.
EXECUTING
.
name
());
taskService
.
updateQueueTask
(
queueTask
);
String
rgb
=
queueTask
.
getLightColor
();
ORDER_COLOR
color
=
ORDER_COLOR
.
fromRgb
(
rgb
);
if
(
color
==
null
){
if
(
queueTask
.
isPutInTask
()){
color
=
ORDER_COLOR
.
DARKGREEN
;
}
else
{
if
(
openZhiYin
&&
ObjectUtil
.
isNotEmpty
(
queueTask
.
getSourceId
()))
{
List
<
DataLog
>
dataLogList
=
outMap
.
get
(
queueTask
.
getSourceId
());
if
(
dataLogList
==
null
)
{
dataLogList
=
new
ArrayList
<>();
}
dataLogList
.
add
(
queueTask
);
outMap
.
put
(
queueTask
.
getSourceId
(),
dataLogList
);
}
else
{
color
=
ORDER_COLOR
.
BLUE
;
}
}
}
statusBean
.
addData
(
"open"
,
queueTask
.
getPosName
()+
"="
+
color
.
name
());
log
.
info
(
"库位["
+
queueTask
.
getPosName
()+
"]+亮灯:"
+
color
.
name
());
}
// else if(queueTask.isCancel()){
// if(queueTask.isCheckOutTask()){
//
// statusBean.addData("open",queueTask.getPosName()+"="+"orange" );
// log.info("库位["+queueTask.getPosName()+"]+取消:open=orange" );
// //从任务列表中删除
// taskService.removeFinishedTask(queueTask);
// /**
// * 扫码
// */
// @ApiOperation("扫码入库")
// @PostMapping("/api/sensorShelf/codeIn")
// @PreAuthorize("@el.check('sensorShelf:putIn')")
// public ResultBean codeIn( @RequestBody Map<String, String> mapValues,HttpServletRequest request) {
// String code = mapValues.get("code");
// String groupId = mapValues.get("group");
// String storageId=mapValues.get("storageId");
// String sourceId=mapValues.get("sourceId");
// String token = tokenProvider.getToken(request);
// if(ObjectUtils.isEmpty(code)){
// throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"});
// }
// if(groupId==null&&storageId==null){
// throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"group"});
// }
// if(groupId==null&&storageId!=null){
// Storage storage=dataCache.getStorageById(storageId);
// if(storage!=null){
// groupId=storage.getGroupId();
// }
// }
// if(groupId!=null&&groupId.equals("-1")){
// groupId="";
// }
//// WebSocketServer.sendMsg("", new SocketMsg("这是一个webSocket消息:"+code, MsgType.INFO));
// String loginUser = SecurityUtils.getLoginUsername();
// Collection<DataLog> queueTasks = taskService.getQueueTasks();
// ResultBean resultBean = null;
// for (DataLog queueTask : queueTasks) {
// if (queueTask.isPutInTask() && queueTask.isWait()) {
// if (!Strings.isNullOrEmpty(groupId) && queueTask.getGroupId().equals(groupId)) {
// log.info("codeIn [" + code + "][" + groupId + "]入库失败:条码[" + queueTask.getBarcode() + "]的任务还未结束 ");
// throw new ValidateException("smfcore.unfinished", "the task of [{0}] is unfinished", new String[]{queueTask.getBarcode()});
// }
// if (!Strings.isNullOrEmpty(storageId) && queueTask.getStorageId().equals(storageId)) {
// log.info("codeIn [" + code + "][" + storageId + "]入库失败:条码[" + queueTask.getBarcode() + "]的任务还未结束 ");
// throw new ValidateException("smfcore.unfinished", "the task of [{0}] is unfinished", new String[]{queueTask.getBarcode()});
// }
// }
}
List
<
DataLog
>
dataLogs
=
getLightGuideTask
(
outMap
);
for
(
DataLog
task
:
dataLogs
)
{
statusBean
.
addData
(
"open"
,
task
.
getPosName
()
+
"="
+
ORDER_COLOR
.
fromRgb
(
task
.
getLightColor
()).
name
());
}
return
statusBean
;
}
/**
* 客户端sensor变化
*/
@RequestMapping
(
"/service/store/sensorShelf/sensorChange"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
sensorChange
(
HttpServletRequest
request
,
HttpSession
httpSession
){
String
cid
=
request
.
getParameter
(
"cid"
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
if
(
storage
==
null
){
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.shelfNotExist"
,
"{0}对应的料架不存在"
,
new
String
[]{
cid
}
);
}
String
groupId
=
storage
.
getGroupId
();
// String groupName = "";
// Group group = groupManager.get(groupId);
// if(group != null){
// groupName = group.getGroupName();
// }
if
(
groupId
.
equals
(
""
)){
groupId
=
"-1"
;
}
String
[]
hasReelPosList
=
request
.
getParameterValues
(
"hasReelPosList"
);
String
[]
noReelPosList
=
request
.
getParameterValues
(
"noReelPosList"
);
String
[]
hasReelPosErrorList
=
request
.
getParameterValues
(
"hasReelPosErrorList"
);
//实际信号有料,数据库无信息
String
[]
noReelPosErrorList
=
request
.
getParameterValues
(
"noReelPosErrorList"
);
//实际信号无料,数据库有信息
if
(
hasReelPosErrorList
==
null
){
hasReelPosErrorList
=
new
String
[]{};
}
if
(
noReelPosErrorList
==
null
)
{
noReelPosErrorList
=
new
String
[]{};
}
List
<
String
>
ngToOk
=
new
ArrayList
<>();
// //数据库无信息,实际有料
// if(hasReelPosErrorList.length>0){
// Query query=new Query(Criteria.where("posName").in(hasReelPosErrorList));
//
// Barcode barcodeSave = resolveBarcodeFromApiForShelf(new CodeValidateParam( loginUser,groupId,storageId,code,token));
// if(barcodeSave == null){
// barcodeSave = codeResolve.resolveOneValideBarcode("=1x1="+code);
// }
//
// Date expireDate = barcodeSave.getExpireDate();
// if (expireDate != null) {
// if (System.currentTimeMillis() > expireDate.getTime()) {
// throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
// }
// }
//
// //从API验证
// Barcode verResult = verifyPutInFromApi(barcodeSave);
//
// if(verResult==null){
// return testPutIn(loginUser,groupId,storageId, barcodeSave,token);
// }
//// resultBean = hellaServiceHandler.checkMaterial(loginUser, groupId, code);
// return ResultBean.newOkResult("");
// }
//
// private ResultBean testPutIn(String loginUser, String groupId,String storageId,Barcode barcode,String token) {
//
//// CodeBean codeBean = codeResolve.resolveSingleCode(codeStr);
// if (barcode == null || barcode.getBarcode() == null) {
// return ResultBean.newErrorResult(1, "smfcore.error.barcode.invalid", "条码无效");
// }
//
// String pn = barcode.getPartNumber();
// String reelId = barcode.getBarcode();
// String num = barcode.getAmount() + "";
// Integer qty = barcode.getAmount();
// String msl = barcode.getMsl();
// try {
//
// //需要模拟一个库位
//
// DataLog dataLog = new DataLog();
// dataLog.setBarcode(reelId);
// dataLog.setPartNumber(pn);
// dataLog.setType(OP.PUT_IN);
//
// barcode.setPutInTime(System.currentTimeMillis());
// barcodeManager.saveBarcode(barcode);
//
// dataLog.setNum(barcode.getAmount());
// dataLog.setStatus(OP_STATUS.WAIT.name());
// dataLog.setGroupId(groupId);
// dataLog.setStorageId(storageId);
// dataLog.setMemo(barcode.getMemo());
// dataLog.setOperator(loginUser);
// if (ObjectUtil.isNotEmpty(storageId)) {
// Storage storage = dataCache.getStorageById(storageId);
// if (storage != null) {
// dataLog.setCid(storage.getCid());
// dataLog.setStorageName(storage.getName());
// }
// }
// try {
// taskService.addTaskToExecute(dataLog);
// } catch (Exception e) {
// WebSocketServer.sendMsg(token, new SocketMsg(e.getMessage(), MsgType.INFO));
// }
//
//
// } catch (ValidateException e) {
// log.error(e.toString());
// return ResultBean.newErrorResult(1, e.getMsgKey(), e.getDefaultMsg());
// }
// return ResultBean.newOkResult("");
// }
//
// /**
// * 从API接口解析条码,通常料架使用(其他设备会有尺寸信息且会有多个条码所以不适用此方法)
// */
// protected Barcode resolveBarcodeFromApiForShelf(CodeValidateParam param) throws ValidateException{
// for (IOpAuthApi opAuthApi : opAuthApiList) {
// Barcode responseBarcode = opAuthApi.resolveBarcode(param);
// if(responseBarcode != null){
// return responseBarcode;
// }
// }
// return null;
// }
//
//
// @Override
// public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) {
// handleMsg(statusBean);
// statusBean = saveAlarmAndHumidity(statusBean);
//
// OrderSetting orderSetting = dataCache.getOrderSetting();
// boolean openZhiYin = orderSetting.getShelfLightType().equals(1);
// Map<String, List<DataLog>> outMap = new HashMap<>();
//
// //亮灯
// Collection<DataLog> queueTasks = taskService.getQueueTasks(statusBean.getCid());
// for (DataLog queueTask : queueTasks) {
// if(queueTask.isWait()){
// queueTask.setStatus(OP_STATUS.EXECUTING.name());
// taskService.updateQueueTask(queueTask);
// String rgb = queueTask.getLightColor();
// ORDER_COLOR color = ORDER_COLOR.fromRgb(rgb);
// if(color == null){
// if(queueTask.isPutInTask()){
// color = ORDER_COLOR.DARKGREEN;
// }else{
// if (openZhiYin && ObjectUtil.isNotEmpty(queueTask.getSourceId())) {
// List<DataLog> dataLogList = outMap.get(queueTask.getSourceId());
// if (dataLogList == null) {
// dataLogList = new ArrayList<>();
// }
// dataLogList.add(queueTask);
// outMap.put(queueTask.getSourceId(), dataLogList);
// } else {
// color = ORDER_COLOR.BLUE;
// }
// }
// }
// statusBean.addData("open",queueTask.getPosName()+"="+color.name());
// log.info("库位["+queueTask.getPosName()+"]+亮灯:" + color.name());
// }
//// else if(queueTask.isCancel()){
//// if(queueTask.isCheckOutTask()){
////
//// statusBean.addData("open",queueTask.getPosName()+"="+"orange" );
//// log.info("库位["+queueTask.getPosName()+"]+取消:open=orange" );
//// //从任务列表中删除
//// taskService.removeFinishedTask(queueTask);
//// }
//// }
// }
//
// List<DataLog> dataLogs = getLightGuideTask(outMap);
// for (DataLog task :
// dataLogs) {
// statusBean.addData("open", task.getPosName() + "=" + ORDER_COLOR.fromRgb(task.getLightColor()).name());
// }
//
// return statusBean;
// }
//
// /**
// * 客户端sensor变化
// */
// @RequestMapping("/service/store/sensorShelf/sensorChange")
// @ResponseBody
// @AnonymousAccess
// public ResultBean sensorChange(HttpServletRequest request, HttpSession httpSession){
// String cid = request.getParameter("cid");
// Storage storage = dataCache.getStorage(cid);
// if(storage == null){
// return ResultBean.newErrorResult(-1,"smfcore.shelfNotExist", "{0}对应的料架不存在",new String[]{cid} );
// }
// String groupId = storage.getGroupId();
//// String groupName = "";
//// Group group = groupManager.get(groupId);
//// if(group != null){
//// groupName = group.getGroupName();
//// }
// if(groupId.equals("")){
// groupId="-1";
// }
// String[] hasReelPosList = request.getParameterValues("hasReelPosList");
// String[] noReelPosList = request.getParameterValues("noReelPosList");
//
//
// String[] hasReelPosErrorList = request.getParameterValues("hasReelPosErrorList");//实际信号有料,数据库无信息
// String[] noReelPosErrorList = request.getParameterValues("noReelPosErrorList");//实际信号无料,数据库有信息
// if(hasReelPosErrorList==null){
// hasReelPosErrorList=new String[]{};
// }
// if(noReelPosErrorList==null) {
// noReelPosErrorList = new String[]{};
// }
// List<String> ngToOk=new ArrayList<>();
//
//// //数据库无信息,实际有料
//// if(hasReelPosErrorList.length>0){
//// Query query=new Query(Criteria.where("posName").in(hasReelPosErrorList));
//// List<StoragePos> posList= storagePosManager.findByQuery(query);
//// for (StoragePos pos:posList
//// ) {
//// if(pos.isUsed()){
//// ngToOk.add(pos.getPosName());
//// log.info("sensorChange 客户端上传 hasReelPosErrorList 库位["+pos.getPosName()+"]数据库有信息,放入ngToOk");
//// }
//// }
//// }
// //数据库有信息,实际无料
// if(noReelPosErrorList.length>0){
// Query query=new Query(Criteria.where("posName").in(noReelPosErrorList ));
// List<StoragePos> posList= storagePosManager.findByQuery(query);
// for (StoragePos pos:posList
// ) {
// if(pos.isUsed()){
// if(
!
pos.isUsed()){
// ngToOk.add(pos.getPosName());
// log.info("sensorChange 客户端上传
hasReelPosErrorList 库位["+pos.getPosName()+"]数据库有
信息,放入ngToOk");
// log.info("sensorChange 客户端上传
noReelPosErrorList 库位["+pos.getPosName()+"]数据库无
信息,放入ngToOk");
// }
// }
// }
//数据库有信息,实际无料
if
(
noReelPosErrorList
.
length
>
0
){
Query
query
=
new
Query
(
Criteria
.
where
(
"posName"
).
in
(
noReelPosErrorList
));
List
<
StoragePos
>
posList
=
storagePosManager
.
findByQuery
(
query
);
for
(
StoragePos
pos:
posList
)
{
if
(!
pos
.
isUsed
()){
ngToOk
.
add
(
pos
.
getPosName
());
log
.
info
(
"sensorChange 客户端上传 noReelPosErrorList 库位["
+
pos
.
getPosName
()+
"]数据库无信息,放入ngToOk"
);
}
}
}
List
<
List
<
String
>>
data
=
new
ArrayList
<>();
data
.
add
(
Arrays
.
asList
(
hasReelPosErrorList
)
);
data
.
add
(
Arrays
.
asList
(
noReelPosErrorList
));
DevicesStatusUtil
.
updateDeviceData
(
cid
,
data
);
List
<
String
>
inOkList
=
new
ArrayList
<>();
List
<
String
>
inNgList
=
new
ArrayList
<>();
List
<
String
>
outOkList
=
new
ArrayList
<>();
List
<
String
>
outNgList
=
new
ArrayList
<>();
if
(
hasReelPosList
!=
null
){
//入库的库位列表
if
(
hasReelPosList
.
length
>
1
){
String
msg
=
"不可同时放入多盘物料:"
+
String
.
join
(
","
,
hasReelPosList
);
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
for
(
String
posStr
:
hasReelPosList
)
{
inNgList
.
add
(
posStr
);
}
}
else
{
StoragePos
pos
=
storagePosManager
.
getByPosName
(
hasReelPosList
[
0
]);
if
(
pos
==
null
){
String
msg
=
"未找到库位:"
+
String
.
join
(
","
,
hasReelPosList
)
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
}
else
if
(!
pos
.
getStorageId
().
equals
(
storage
.
getId
())){
String
msg
=
"["
+
storage
.
getName
()+
"]未找到库位:"
+
String
.
join
(
","
,
hasReelPosList
)
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
}
//如果库位有料,直接结束
else
if
(
pos
.
getBarcode
()!=
null
)
{
log
.
info
(
"料架["
+
cid
+
"]入库库位["
+
pos
.
getPosName
()
+
"]已有料: ["
+
pos
.
getBarcode
().
getBarcode
()
+
"]"
);
}
else
{
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
();
for
(
DataLog
queueTask
:
queueTasks
)
{
boolean
isPutInTask
=
false
;
if
(
ObjectUtil
.
isNotEmpty
(
queueTask
.
getStorageId
())
){
if
(
queueTask
.
isPutInTask
()&&
queueTask
.
getStorageId
().
equals
(
storage
.
getId
())){
isPutInTask
=
true
;
}
}
else
if
(
queueTask
.
isPutInTask
()
&&
queueTask
.
getGroupId
().
equals
(
groupId
))
{
isPutInTask
=
true
;
}
if
(
isPutInTask
)
{
queueTask
.
setCid
(
cid
);
queueTask
.
setPosId
(
pos
.
getId
());
queueTask
.
setPosName
(
pos
.
getPosName
());
queueTask
.
setStorageId
(
storage
.
getId
());
queueTask
.
setStorageName
(
storage
.
getName
());
try
{
//入库完成,发送入库完成请求
super
.
finishedPutIn
(
cid
,
pos
.
getPosName
());
inOkList
.
add
(
hasReelPosList
[
0
]);
String
msg
=
queueTask
.
getBarcode
()
+
"入库到"
+
pos
.
getPosName
()
+
"成功"
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
INFO
));
break
;
}
catch
(
Exception
e
)
{
log
.
error
(
"入库出错"
,
e
);
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.inputError"
,
"入库出错:{0}"
,
new
String
[]{
e
.
getMessage
()});
}
}
}
if
(
inOkList
.
size
()
==
0
){
inNgList
.
add
(
hasReelPosList
[
0
]);
log
.
error
(
"未找到["
+
pos
.
getPosName
()+
"]的入库任务"
);
}
}
}
}
if
(
noReelPosList
!=
null
){
//出库
for
(
String
posName
:
noReelPosList
)
{
StoragePos
pos
=
storagePosManager
.
getByPosName
(
posName
);
if
(
pos
==
null
){
String
msg
=
"未找到库位:"
+
String
.
join
(
","
,
hasReelPosList
)
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
}
else
if
(!
pos
.
getStorageId
().
equals
(
storage
.
getId
())){
String
msg
=
"["
+
storage
.
getName
()+
"]未找到库位:"
+
String
.
join
(
","
,
hasReelPosList
)
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
}
else
if
(
pos
.
getBarcode
()==
null
){
log
.
info
(
"料架["
+
cid
+
"]出库库位["
+
pos
.
getPosName
()
+
"]已为空 "
);
}
else
{
String
outResult
=
""
;
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
();
for
(
DataLog
queueTask
:
queueTasks
)
{
if
(
queueTask
.
isCheckOutTask
()
&&
queueTask
.
getPosName
().
equals
(
posName
)){
//出库完成
try
{
outResult
=
posName
;
super
.
finishedOutPos
(
cid
,
posName
);
String
msg
=
queueTask
.
getBarcode
()+
"从"
+
posName
+
"出库成功"
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
INFO
));
break
;
}
catch
(
Exception
e
)
{
log
.
error
(
"出库出错"
,
e
);
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.checkoutError"
,
"出库出错:{0}"
,
new
String
[]{
e
.
getMessage
()});
}
}
}
if
(
outResult
.
isEmpty
()){
outNgList
.
add
(
posName
);
String
msg
=
"未找到["
+
posName
+
"]的出库任务"
;
log
.
error
(
msg
);
WebSocketServer
.
sendMsg
(
""
,
new
SocketMsg
(
msg
,
MsgType
.
ERROR
));
}
else
{
outOkList
.
add
(
outResult
);
}
}
}
}
Map
<
String
,
List
<
String
>>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"inOkList"
,
inOkList
);
dataMap
.
put
(
"inNgList"
,
inNgList
);
dataMap
.
put
(
"outOkList"
,
outOkList
);
dataMap
.
put
(
"outNgList"
,
outNgList
);
dataMap
.
put
(
"ngToOk"
,
ngToOk
);
return
ResultBean
.
newOkResult
(
dataMap
);
}
/**
* 获取料架的库位占用及出库任务
*/
@RequestMapping
(
"/service/store/sensorShelf/shelfStatus"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
shelfStatus
(
HttpServletRequest
request
){
String
cid
=
request
.
getParameter
(
"cid"
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
List
<
StoragePos
>
allPos
=
storagePosManager
.
findNotEmptyByStorageId
(
storage
.
getId
());
List
<
String
>
posList
=
new
ArrayList
<>();
for
(
StoragePos
pos
:
allPos
)
{
posList
.
add
(
pos
.
getPosName
());
}
List
<
String
>
outTaskPosList
=
new
ArrayList
<>();
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
(
cid
);
for
(
DataLog
task
:
queueTasks
)
{
if
(
task
.
isCheckOutTask
()){
String
rgb
=
task
.
getLightColor
();
ORDER_COLOR
color
=
ORDER_COLOR
.
fromRgb
(
rgb
);
if
(
color
==
null
){
color
=
ORDER_COLOR
.
BLUE
;
}
String
outTaskPos
=
task
.
getPosName
()+
"="
+
color
.
name
();
outTaskPosList
.
add
(
outTaskPos
);
}
}
Map
<
String
,
List
<
String
>>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"hasReelPosList"
,
posList
);
dataMap
.
put
(
"outTaskList"
,
outTaskPosList
);
return
ResultBean
.
newOkResult
(
dataMap
);
}
/**
* 获取料架的库位占用情况
*/
@RequestMapping
(
"/service/store/sensorShelf/hasReelPosList"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
checkAll
(
HttpServletRequest
request
){
String
cid
=
request
.
getParameter
(
"cid"
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
List
<
StoragePos
>
allPos
=
storagePosManager
.
findNotEmptyByStorageId
(
storage
.
getId
());
List
<
String
>
posList
=
new
ArrayList
<>();
for
(
StoragePos
pos
:
allPos
)
{
posList
.
add
(
pos
.
getPosName
());
}
return
ResultBean
.
newOkResult
(
posList
);
}
//
// List<List<String>> data=new ArrayList<>();
// data.add(Arrays.asList(hasReelPosErrorList) );
// data.add(Arrays.asList(noReelPosErrorList));
// DevicesStatusUtil.updateDeviceData(cid,data);
//
// List<String> inOkList = new ArrayList<>();
// List<String> inNgList = new ArrayList<>();
// List<String> outOkList = new ArrayList<>();
// List<String> outNgList = new ArrayList<>();
//
// if(hasReelPosList != null){
// //入库的库位列表
// if(hasReelPosList.length > 1){
// String msg = "不可同时放入多盘物料:"+ String.join(",",hasReelPosList);
// log.error(msg);
// WebSocketServer.sendMsg("",new SocketMsg(msg, MsgType.ERROR));
// for (String posStr : hasReelPosList) {
// inNgList.add(posStr);
// }
// }else{
// StoragePos pos = storagePosManager.getByPosName(hasReelPosList[0]);
// if(pos == null){
// String msg = "未找到库位:"+String.join(",",hasReelPosList) ;
// log.error(msg);
// WebSocketServer.sendMsg("",new SocketMsg(msg, MsgType.ERROR));
// }
// else if(!pos.getStorageId().equals(storage.getId())){
// String msg = "["+storage.getName()+"]未找到库位:"+String.join(",",hasReelPosList) ;
// log.error(msg);
// WebSocketServer.sendMsg("",new SocketMsg(msg, MsgType.ERROR));
// }
// //如果库位有料,直接结束
// else if(pos.getBarcode()!=null) {
// log.info("料架[" + cid + "]入库库位[" + pos.getPosName() + "]已有料: [" + pos.getBarcode().getBarcode() + "]");
// }
// else{
// Collection<DataLog> queueTasks = taskService.getQueueTasks();
// for (DataLog queueTask : queueTasks) {
// boolean isPutInTask=false;
// if(ObjectUtil.isNotEmpty(queueTask.getStorageId()) ){
// if(queueTask.isPutInTask()&&queueTask.getStorageId().equals(storage.getId())){
// isPutInTask=true;
// }
// }
// else if(queueTask.isPutInTask() && queueTask.getGroupId().equals(groupId)) {
// isPutInTask = true;
// }
// if(isPutInTask) {
// queueTask.setCid(cid);
// queueTask.setPosId(pos.getId());
// queueTask.setPosName(pos.getPosName());
// queueTask.setStorageId(storage.getId());
// queueTask.setStorageName(storage.getName());
// try {
// //入库完成,发送入库完成请求
// super.finishedPutIn(cid, pos.getPosName());
// inOkList.add(hasReelPosList[0]);
// String msg = queueTask.getBarcode() + "入库到" + pos.getPosName() + "成功";
// log.error(msg);
// WebSocketServer.sendMsg("",new SocketMsg(msg, MsgType.INFO));
// break;
// } catch (Exception e) {
// log.error("入库出错", e);
// return ResultBean.newErrorResult(-1, "smfcore.inputError", "入库出错:{0}", new String[]{e.getMessage()});
// }
// }
// }
// if(inOkList.size() == 0){
// inNgList.add(hasReelPosList[0]);
// log.error("未找到["+pos.getPosName()+"]的入库任务");
// }
// }
//
//
// }
// }
// if(noReelPosList != null){
// //出库
// for (String posName : noReelPosList) {
// StoragePos pos = storagePosManager.getByPosName(posName);
// if(pos == null){
// String msg = "未找到库位:"+String.join(",",hasReelPosList) ;
// log.error(msg);
// WebSocketServer.sendMsg("",new SocketMsg(msg, MsgType.ERROR));
// }
// else if(!pos.getStorageId().equals(storage.getId())){
// String msg = "["+storage.getName()+"]未找到库位:"+String.join(",",hasReelPosList) ;
// log.error(msg);
// WebSocketServer.sendMsg("",new SocketMsg(msg, MsgType.ERROR));
// }else if(pos.getBarcode()==null){
// log.info("料架[" + cid + "]出库库位[" + pos.getPosName() + "]已为空 ");
// }else{
// String outResult = "";
// Collection<DataLog> queueTasks = taskService.getQueueTasks();
// for (DataLog queueTask : queueTasks) {
// if(queueTask.isCheckOutTask() && queueTask.getPosName().equals(posName)){
// //出库完成
// try {
// outResult = posName;
// super.finishedOutPos(cid,posName);
// String msg = queueTask.getBarcode()+ "从"+ posName+"出库成功";
// log.error(msg);
// WebSocketServer.sendMsg("",new SocketMsg(msg, MsgType.INFO));
// break;
// } catch (Exception e) {
// log.error("出库出错",e);
// return ResultBean.newErrorResult(-1,"smfcore.checkoutError","出库出错:{0}" ,new String[]{ e.getMessage()});
// }
// }
// }
// if(outResult.isEmpty()){
// outNgList.add(posName);
// String msg = "未找到["+posName+"]的出库任务";
// log.error(msg);
// WebSocketServer.sendMsg("",new SocketMsg(msg, MsgType.ERROR));
// }else{
// outOkList.add(outResult);
// }
// }
//
// }
// }
//
// Map<String,List<String>> dataMap = new HashMap<>();
// dataMap.put("inOkList",inOkList);
// dataMap.put("inNgList",inNgList);
// dataMap.put("outOkList",outOkList);
// dataMap.put("outNgList",outNgList);
// dataMap.put("ngToOk",ngToOk);
// return ResultBean.newOkResult(dataMap);
// }
//
//
// /**
// * 获取料架的库位占用及出库任务
// */
// @RequestMapping("/service/store/sensorShelf/shelfStatus")
// @ResponseBody
// @AnonymousAccess
// public ResultBean shelfStatus(HttpServletRequest request){
// String cid = request.getParameter("cid");
// Storage storage = dataCache.getStorage(cid);
// List<StoragePos> allPos = storagePosManager.findNotEmptyByStorageId(storage.getId());
// List<String> posList = new ArrayList<>();
// for (StoragePos pos : allPos) {
// posList.add(pos.getPosName());
// }
//
// List<String> outTaskPosList = new ArrayList<>();
// Collection<DataLog> queueTasks = taskService.getQueueTasks(cid);
// for (DataLog task : queueTasks) {
// if(task.isCheckOutTask()){
// String rgb = task.getLightColor();
// ORDER_COLOR color = ORDER_COLOR.fromRgb(rgb);
// if(color == null){
// color = ORDER_COLOR.BLUE;
// }
// String outTaskPos = task.getPosName()+"="+color.name();
// outTaskPosList.add(outTaskPos);
// }
// }
//
// Map<String,List<String>> dataMap = new HashMap<>();
// dataMap.put("hasReelPosList",posList);
// dataMap.put("outTaskList",outTaskPosList);
// return ResultBean.newOkResult(dataMap);
// }
//
// /**
// * 获取料架的库位占用情况
// */
// @RequestMapping("/service/store/sensorShelf/hasReelPosList")
// @ResponseBody
// @AnonymousAccess
// public ResultBean checkAll(HttpServletRequest request){
// String cid = request.getParameter("cid");
// Storage storage = dataCache.getStorage(cid);
// List<StoragePos> allPos = storagePosManager.findNotEmptyByStorageId(storage.getId());
// List<String> posList = new ArrayList<>();
// for (StoragePos pos : allPos) {
// posList.add(pos.getPosName());
// }
// return ResultBean.newOkResult(posList);
// }
@Override
public
DeviceType
getDeviceType
()
{
...
...
src/main/java/com/neotel/smfcore/core/kanban/rest/BoxKanbanController.java
查看文件 @
a824869
...
...
@@ -107,7 +107,7 @@ public class BoxKanbanController {
continue
;
}
boxStatusDtos
.
add
(
getBoxDto
(
storage
,
allTasks
));
if
(
storage
.
getType
().
equals
(
DeviceType
.
ACCSHELF
.
name
())||
storage
.
getType
().
equals
(
DeviceType
.
CODESHELF
.
name
()
)){
if
(
storage
.
isNLPShelf
(
)){
groupType
=
1
;
}
}
...
...
src/main/java/com/neotel/smfcore/core/storage/rest/StorageController.java
查看文件 @
a824869
...
...
@@ -10,6 +10,7 @@ import com.neotel.smfcore.common.utils.PointUtil;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.storage.enums.DeviceType
;
import
com.neotel.smfcore.core.storage.rest.dto.StorageDto
;
import
com.neotel.smfcore.core.storage.rest.dto.StorageSearchDto
;
import
com.neotel.smfcore.core.storage.rest.mapstruct.StorageMapper
;
...
...
@@ -128,6 +129,18 @@ public class StorageController {
return
storageSearchDtos
;
}
@ApiOperation
(
"返回所有料仓类型"
)
@GetMapping
(
value
=
"/typeList"
)
public
List
<
String
>
typeList
()
{
List
<
DeviceType
>
availableTypeList
=
DeviceType
.
availableTypeList
();
List
<
String
>
allList
=
new
ArrayList
<>();
for
(
DeviceType
type
:
availableTypeList
)
{
allList
.
add
(
type
.
getName
());
}
return
allList
;
}
@ApiOperation
(
"新增料仓"
)
@PostMapping
@PreAuthorize
(
"@el.check('storage:add')"
)
...
...
src/main/java/com/neotel/smfcore/core/storage/service/po/Storage.java
查看文件 @
a824869
...
...
@@ -67,13 +67,13 @@ public class Storage extends BasePo implements Serializable {
private
String
inListName
=
""
;
/**
* 是否是上下层的在线料仓
* @return
*/
public
boolean
isOnlineStorage
(){
return
DeviceType
.
ONLINE
.
name
().
equals
(
type
);
}
//
/**
//
* 是否是上下层的在线料仓
//
* @return
//
*/
//
public boolean isOnlineStorage(){
//
return DeviceType.ONLINE.name().equals(type);
//
}
/**
* 是否是指上下料的料仓
...
...
@@ -107,24 +107,24 @@ public class Storage extends BasePo implements Serializable {
}
/**
* 是否是
智能
料架
* 是否是料架
*/
public
boolean
isShelf
()
{
return
DeviceType
.
SHELF
.
name
().
equals
(
type
);
}
/**
* 是否是ACC智能料架
*/
public
boolean
isAccShelf
()
{
return
DeviceType
.
ACCSHELF
.
name
().
equals
(
type
);
}
/**
* 是否是扫码料架
*/
public
boolean
isCodeShelf
()
{
return
DeviceType
.
CODESHELF
.
name
().
equals
(
type
);
}
//
/**
//
* 是否是ACC智能料架
//
*/
//
public boolean isAccShelf() {
//
return DeviceType.ACCSHELF.name().equals(type);
//
}
//
//
/**
//
* 是否是扫码料架
//
*/
//
public boolean isCodeShelf() {
//
return DeviceType.CODESHELF.name().equals(type);
//
}
/**
* 是否是普通料架
*/
...
...
@@ -132,6 +132,12 @@ public class Storage extends BasePo implements Serializable {
return
DeviceType
.
NL
.
name
().
equals
(
type
);
}
/**
* 是否是感应料架
*/
public
boolean
isNLPShelf
()
{
return
DeviceType
.
NLP
.
name
().
equals
(
type
);
}
/**
* 是否是垂直货柜
*/
public
boolean
isVerticalBox
(){
...
...
@@ -173,6 +179,16 @@ public class Storage extends BasePo implements Serializable {
return
DeviceType
.
SMD_XLC
.
name
().
equals
(
type
);
}
public
boolean
isType
(
DeviceType
[]
types
){
for
(
DeviceType
str
:
types
)
{
if
(
str
.
name
().
equals
(
type
)){
return
true
;
}
}
return
false
;
}
public
boolean
canPutInPos
(
int
w
,
int
h
,
int
PosW
,
int
posH
){
if
(
compatibleType
==
COMPATIBLE_TYPE
.
EXACT_MATCH
){
//完全匹配
...
...
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
查看文件 @
a824869
...
...
@@ -10,6 +10,7 @@ import com.neotel.smfcore.common.utils.QueryHelp;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.language.service.bean.LanguageInfo
;
import
com.neotel.smfcore.core.language.service.po.LanguageMsg
;
import
com.neotel.smfcore.core.storage.enums.DeviceType
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.system.bean.OrderSetting
;
import
com.neotel.smfcore.core.system.rest.bean.dto.SettingsDto
;
...
...
@@ -113,7 +114,7 @@ public class SettingsController {
List
<
Storage
>
storages
=
new
ArrayList
<>(
dataCache
.
getAllStorage
().
values
());
for
(
Storage
storage
:
storages
)
{
if
(
storage
.
is
Shelf
()
||
storage
.
isNLShelf
()
||
storage
.
isAccShelf
()
||
storage
.
isCodeShelf
(
))
{
if
(
storage
.
is
Type
(
new
DeviceType
[]{
DeviceType
.
NLP
,
DeviceType
.
NL
}
))
{
orderSetting
.
setShowLightType
(
true
);
break
;
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论