Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit b999122b
由
zshaohui
编写于
2023-10-09 09:49:35 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
NLL电子屏处理类提交
1 个父辈
a4e9d04a
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
331 行增加
和
0 行删除
src/main/java/com/neotel/smfcore/core/device/handler/impl/NLLShelfHandler.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/NLLShelfHandler.java
0 → 100644
查看文件 @
b999122
package
com
.
neotel
.
smfcore
.
core
.
device
.
handler
.
impl
;
import
com.alibaba.fastjson.JSON
;
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.common.utils.StringUtils
;
import
com.neotel.smfcore.core.barcode.rest.bean.dto.BarcodeDto
;
import
com.neotel.smfcore.core.barcode.rest.bean.mapstruct.BarcodeMapper
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
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.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.DevicesStatusUtil
;
import
com.neotel.smfcore.core.system.util.TaskService
;
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.web.bind.annotation.RequestBody
;
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
;
@Api
(
tags
=
"SHELF: NLL(标签料架)"
)
@RestController
@Slf4j
public
class
NLLShelfHandler
extends
BaseDeviceHandler
{
@Autowired
private
IStoragePosManager
storagePosManager
;
@Autowired
private
BarcodeMapper
barcodeMapper
;
@Autowired
private
DataCache
dataCache
;
@Autowired
private
TaskService
taskService
;
@Override
public
StatusBean
handleClientRequest
(
StatusBean
statusBean
,
HttpServletRequest
request
)
{
return
super
.
handleClientRequest
(
statusBean
,
request
);
}
@ApiOperation
(
"获取库位信息"
)
@RequestMapping
(
"/api/nllShelf/storagePos"
)
@AnonymousAccess
public
BarcodeDto
storagePos
(
HttpServletRequest
request
)
{
String
code
=
request
.
getParameter
(
"code"
);
BarcodeDto
dto
=
new
BarcodeDto
();
//判断库位信息是否存在
StoragePos
storagePos
=
storagePosManager
.
findByStorageName
(
code
);
if
(
storagePos
==
null
)
{
throw
new
ValidateException
(
"smfcore.valueNotExist"
,
"{0}[{1}]不存在"
,
new
String
[]{
"库位"
,
code
});
}
Barcode
barcode
=
storagePos
.
getBarcode
();
if
(
barcode
==
null
){
barcode
=
new
Barcode
();
barcode
.
setBarcode
(
code
);
barcode
.
setPartNumber
(
code
);
}
dto
=
barcodeMapper
.
toDto
(
barcode
);
opPosLight
(
"open"
,
storagePos
,
""
);
return
dto
;
}
@ApiOperation
(
"入库/出库操作"
)
@RequestMapping
(
"/api/nllShelf/codeIn"
)
@AnonymousAccess
public
ResultBean
codeIn
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
//库位名称
String
posName
=
paramMap
.
get
(
"posName"
);
if
(
StringUtils
.
isBlank
(
posName
))
{
throw
new
ValidateException
(
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"posName"
});
}
//条码
String
code
=
paramMap
.
get
(
"code"
);
if
(
StringUtils
.
isBlank
(
code
))
{
throw
new
ValidateException
(
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"code"
});
}
Barcode
barcode
=
codeResolve
.
resolveOneValideBarcode
(
code
);
if
(
barcode
==
null
)
{
throw
new
ValidateException
(
"smfcore.error.barcode.noValidCode"
,
"条码无效"
);
}
if
(
StringUtils
.
isNotBlank
(
barcode
.
getPosName
()))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.materialBox.inPos"
,
"物料已在库位{0}中"
,
new
String
[]{
barcode
.
getPosName
()});
}
//判断库位是否存在
StoragePos
pos
=
storagePosManager
.
getByPosName
(
posName
);
if
(
pos
==
null
)
{
throw
new
ValidateException
(
"smfcore.valueNotExist"
,
"{0}[{1}]不存在"
,
new
String
[]{
"库位"
,
posName
});
}
Storage
storage
=
dataCache
.
getStorageById
(
pos
.
getStorageId
());
//判断是否存在库位中
Barcode
posBarcode
=
pos
.
getBarcode
();
if
(
posBarcode
==
null
)
{
posBarcode
=
new
Barcode
();
posBarcode
.
setPartNumber
(
posName
);
posBarcode
.
setBarcode
(
posName
);
}
boolean
isExist
=
false
;
List
<
Barcode
>
subCodeList
=
posBarcode
.
getSubCodeList
();
if
(
subCodeList
!=
null
&&
!
subCodeList
.
isEmpty
())
{
for
(
Barcode
subBarcode
:
subCodeList
)
{
if
(
subBarcode
.
getBarcode
().
equals
(
barcode
.
getBarcode
()))
{
isExist
=
true
;
break
;
}
}
}
if
(
isExist
)
{
DataLog
dataLog
=
new
DataLog
(
storage
,
barcode
,
pos
);
dataLog
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
dataLog
.
setType
(
OP
.
CHECKOUT
);
dataLog
.
setCreator
(
SecurityUtils
.
getLoginUsername
());
taskService
.
updateFinishedTask
(
dataLog
);
barcode
.
setPosName
(
null
);
barcodeManager
.
save
(
barcode
);
barcode
.
setAmount
(
0
);
posBarcode
.
UpdateSubCode
(
barcode
);
}
else
{
DataLog
dataLog
=
new
DataLog
(
storage
,
barcode
,
pos
);
dataLog
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
dataLog
.
setType
(
OP
.
CHECKOUT
);
dataLog
.
setCreator
(
SecurityUtils
.
getLoginUsername
());
taskService
.
updateFinishedTask
(
dataLog
);
barcode
.
setPutInTime
(
new
Date
().
getTime
());
barcode
.
setPosName
(
pos
.
getPosName
());
barcodeManager
.
save
(
barcode
);
posBarcode
.
UpdateSubCode
(
barcode
);
}
barcodeManager
.
save
(
posBarcode
);
pos
.
setBarcode
(
posBarcode
);
storagePosManager
.
save
(
pos
);
updateStoragePosInfo
(
posName
);
return
ResultBean
.
newOkResult
(
""
);
}
@ApiOperation
(
"取出"
)
@RequestMapping
(
"/api/nllShelf/exeOut"
)
@AnonymousAccess
public
ResultBean
exeOut
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
posName
=
paramMap
.
get
(
"posName"
);
String
code
=
paramMap
.
get
(
"code"
);
Barcode
barcode
=
codeResolve
.
resolveOneValideBarcode
(
code
);
if
(
barcode
==
null
)
{
throw
new
ValidateException
(
"smfcore.error.barcode.noValidCode"
,
"条码无效"
);
}
//判断库位是否存在
StoragePos
pos
=
storagePosManager
.
getByPosName
(
posName
);
if
(
pos
==
null
)
{
throw
new
ValidateException
(
"smfcore.valueNotExist"
,
"{0}[{1}]不存在"
,
new
String
[]{
"库位"
,
posName
});
}
Barcode
posBarcode
=
pos
.
getBarcode
();
if
(
posBarcode
!=
null
)
{
List
<
Barcode
>
subCodeList
=
posBarcode
.
getSubCodeList
();
for
(
Barcode
subCode
:
subCodeList
)
{
if
(
subCode
.
getBarcode
().
equals
(
barcode
.
getBarcode
()))
{
Storage
storage
=
dataCache
.
getStorageById
(
pos
.
getStorageId
());
DataLog
dataLog
=
new
DataLog
(
storage
,
barcode
,
pos
);
dataLog
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
dataLog
.
setType
(
OP
.
CHECKOUT
);
dataLog
.
setCreator
(
SecurityUtils
.
getLoginUsername
());
taskService
.
updateFinishedTask
(
dataLog
);
barcode
.
setPosName
(
null
);
barcodeManager
.
save
(
barcode
);
barcode
.
setAmount
(
0
);
posBarcode
.
UpdateSubCode
(
barcode
);
barcodeManager
.
save
(
posBarcode
);
pos
.
setBarcode
(
posBarcode
);
storagePosManager
.
save
(
pos
);
updateStoragePosInfo
(
posName
);
return
ResultBean
.
newOkResult
(
""
);
}
}
}
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.allBoxView.noReel"
,
"库位{0}中无物料"
,
new
String
[]{
posName
});
}
@ApiOperation
(
"取出全部"
)
@RequestMapping
(
"/api/nllShelf/exeOutAll"
)
@AnonymousAccess
public
ResultBean
exeOutAll
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
posName
=
paramMap
.
get
(
"posName"
);
//判断库位是否存在
StoragePos
pos
=
storagePosManager
.
getByPosName
(
posName
);
if
(
pos
==
null
)
{
throw
new
ValidateException
(
"smfcore.valueNotExist"
,
"{0}[{1}]不存在"
,
new
String
[]{
"库位"
,
posName
});
}
Barcode
posBarcode
=
pos
.
getBarcode
();
if
(
posBarcode
!=
null
)
{
List
<
Barcode
>
subCodeList
=
posBarcode
.
getSubCodeList
();
if
(
subCodeList
!=
null
&&
!
subCodeList
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
subCodeList
.
size
();
i
++)
{
Barcode
subCode
=
subCodeList
.
get
(
i
);
Storage
storage
=
dataCache
.
getStorageById
(
pos
.
getStorageId
());
DataLog
dataLog
=
new
DataLog
(
storage
,
subCode
,
pos
);
dataLog
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
dataLog
.
setType
(
OP
.
CHECKOUT
);
dataLog
.
setCreator
(
SecurityUtils
.
getLoginUsername
());
taskService
.
updateFinishedTask
(
dataLog
);
subCode
.
setPosName
(
null
);
barcodeManager
.
save
(
subCode
);
subCode
.
setAmount
(
0
);
posBarcode
.
UpdateSubCode
(
subCode
);
}
barcodeManager
.
save
(
posBarcode
);
pos
.
setBarcode
(
posBarcode
);
storagePosManager
.
save
(
pos
);
updateStoragePosInfo
(
posName
);
return
ResultBean
.
newOkResult
(
""
);
}
}
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.allBoxView.noReel"
,
"库位{0}中无物料"
,
new
String
[]{
posName
});
}
@ApiOperation
(
"完成时关闭库位灯"
)
@RequestMapping
(
"/api/nllShelf/finish"
)
@AnonymousAccess
public
ResultBean
finish
(
String
posName
)
{
//判断库位是否存在
StoragePos
pos
=
storagePosManager
.
getByPosName
(
posName
);
if
(
pos
==
null
)
{
throw
new
ValidateException
(
"smfcore.valueNotExist"
,
"{0}[{1}]不存在"
,
new
String
[]{
"库位"
,
posName
});
}
opPosLight
(
"close"
,
pos
,
""
);
return
ResultBean
.
newOkResult
(
""
);
}
/**
* 获取库位信息
*
* @param posName
* @return
*/
private
void
updateStoragePosInfo
(
String
posName
)
{
StoragePos
storagePos
=
storagePosManager
.
getByPosName
(
posName
);
if
(
storagePos
!=
null
)
{
Map
<
String
,
Long
>
collect
=
new
HashMap
<>();
Map
<
String
,
Map
<
String
,
Long
>>
resultMap
=
new
HashMap
<>();
Barcode
barcode
=
storagePos
.
getBarcode
();
if
(
barcode
!=
null
)
{
List
<
Barcode
>
subCodeList
=
barcode
.
getSubCodeList
();
if
(
subCodeList
!=
null
&&
!
subCodeList
.
isEmpty
())
{
collect
=
subCodeList
.
stream
().
collect
(
Collectors
.
groupingBy
(
Barcode:
:
getPartNumber
,
Collectors
.
counting
()));
resultMap
.
put
(
posName
,
collect
);
}
}
Storage
storage
=
dataCache
.
getStorageById
(
storagePos
.
getStorageId
());
DevicesStatusUtil
.
addOp
(
storage
.
getCid
(),
"storagePosInfo"
,
JSON
.
toJSONString
(
resultMap
));
}
}
/**
* 操作库位灯(开灯,或关灯)
*
* @param opKey
* @param pos
* @param colorStr
*/
private
void
opPosLight
(
String
opKey
,
StoragePos
pos
,
String
colorStr
)
{
String
opStr
=
pos
.
getPosName
();
if
(!
Strings
.
isNullOrEmpty
(
colorStr
))
{
opStr
=
opStr
+
"="
+
colorStr
;
}
Storage
storage
=
dataCache
.
getStorageById
(
pos
.
getStorageId
());
DevicesStatusUtil
.
appendOp
(
storage
.
getCid
(),
opKey
,
opStr
);
log
.
info
(
"操作库位["
+
pos
.
getPosName
()
+
"]"
+
opKey
+
" : "
+
opStr
);
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论