Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 3ab70f07
由
LN
编写于
2021-11-23 14:51:47 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
感应料架接口修改
1 个父辈
e91fb981
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
130 行增加
和
124 行删除
src/main/java/com/neotel/smfcore/core/barcode/bean/CodeBean.java
src/main/java/com/neotel/smfcore/core/device/api/IOpAuthApi.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/BaseDeviceHandler.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/SensorShelfHandler.java
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
src/main/java/com/neotel/smfcore/hella/handler/HellaApiHandler.java
src/main/java/com/neotel/smfcore/hella/rest/HellaSensorShelfController.java
src/main/java/com/neotel/smfcore/hella/tcp/HellaTcpClient.java
src/main/java/com/neotel/smfcore/core/barcode/bean/CodeBean.java
查看文件 @
3ab70f0
...
...
@@ -75,7 +75,7 @@ public class CodeBean {
}
public
boolean
isValid
(){
return
error
==
null
&&
barcode
!=
null
;
return
(
error
==
null
)
&&
(
barcode
!=
null
)
;
}
/**
...
...
src/main/java/com/neotel/smfcore/core/device/api/IOpAuthApi.java
查看文件 @
3ab70f0
...
...
@@ -15,7 +15,7 @@ public interface IOpAuthApi {
* @return
* @throws ValidateException
*/
Barcode
resolveBarcode
(
String
code
)
throws
ValidateException
;
Barcode
resolveBarcode
(
String
loginUser
,
String
groupId
,
String
storageId
,
String
code
)
throws
ValidateException
;
/**
* 是否可入库验证
...
...
@@ -26,4 +26,6 @@ public interface IOpAuthApi {
* 是否要出库验证
*/
boolean
canCheckout
(
Barcode
barcode
)
throws
ValidateException
;
boolean
isEnable
();
}
src/main/java/com/neotel/smfcore/core/device/handler/impl/BaseDeviceHandler.java
查看文件 @
3ab70f0
...
...
@@ -303,7 +303,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
return
responseBarcode
;
}
}
return
barcode
;
return
null
;
}
/**
...
...
src/main/java/com/neotel/smfcore/core/device/handler/impl/SensorShelfHandler.java
查看文件 @
3ab70f0
...
...
@@ -8,6 +8,7 @@ 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.StorageConstants
;
import
com.neotel.smfcore.core.barcode.bean.CodeBean
;
import
com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE
;
import
com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager
;
import
com.neotel.smfcore.core.barcode.service.manager.IComponentManager
;
...
...
@@ -26,8 +27,11 @@ 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.hella.tcp.command.HellaReqCommand
;
import
com.neotel.smfcore.hella.tcp.command.HellaRespCommand
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
com.neotel.smfcore.security.service.po.Group
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -44,6 +48,7 @@ import java.util.*;
* 感应料架
* Created by sunke on 2021/7/12.
*/
@Api
(
tags
=
"感应料架"
)
@RestController
@Slf4j
public
class
SensorShelfHandler
extends
BaseDeviceHandler
{
...
...
@@ -56,7 +61,7 @@ public class SensorShelfHandler extends BaseDeviceHandler {
* 扫码
*/
@ApiOperation
(
"扫码入库"
)
@PostMapping
(
"/codeIn"
)
@PostMapping
(
"/
api/sensorShelf/
codeIn"
)
@PreAuthorize
(
"@el.check('sensorShelf:putIn')"
)
public
ResultBean
codeIn
(
@RequestBody
Map
<
String
,
String
>
mapValues
)
{
String
code
=
mapValues
.
get
(
"code"
);
...
...
@@ -93,7 +98,7 @@ public class SensorShelfHandler extends BaseDeviceHandler {
}
}
Barcode
barcodeSave
=
resolveBarcodeFromApiForShelf
(
code
);
Barcode
barcodeSave
=
resolveBarcodeFromApiForShelf
(
loginUser
,
groupId
,
storageId
,
code
);
if
(
barcodeSave
==
null
){
barcodeSave
=
codeResolve
.
resolveOneValideBarcode
(
code
);
}
...
...
@@ -106,20 +111,68 @@ public class SensorShelfHandler extends BaseDeviceHandler {
}
//从API验证
barcodeSave
=
verifyPutInFromApi
(
barcodeSave
);
Barcode
verResult
=
verifyPutInFromApi
(
barcodeSave
);
if
(
verResult
==
null
){
return
testPutIn
(
loginUser
,
groupId
,
storageId
,
barcodeSave
);
}
// resultBean = hellaServiceHandler.checkMaterial(loginUser, groupId, code);
return
resultBean
;
return
ResultBean
.
newOkResult
(
""
)
;
}
private
ResultBean
testPutIn
(
String
loginUser
,
String
groupId
,
String
storageId
,
Barcode
barcode
)
{
// CodeBean codeBean = codeResolve.resolveSingleCode(codeStr);
if
(
barcode
==
null
||
barcode
.
getBarcode
()
==
null
)
{
return
ResultBean
.
newErrorResult
(
1
,
"smfcode.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
);
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
.
sendGroupMsg
(
groupId
,
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
(
String
code
)
throws
ValidateException
{
protected
Barcode
resolveBarcodeFromApiForShelf
(
String
loginUser
,
String
groupId
,
String
storageId
,
String
code
)
throws
ValidateException
{
for
(
IOpAuthApi
opAuthApi
:
opAuthApiList
)
{
Barcode
responseBarcode
=
opAuthApi
.
resolveBarcode
(
code
);
Barcode
responseBarcode
=
opAuthApi
.
resolveBarcode
(
loginUser
,
groupId
,
storageId
,
code
);
if
(
responseBarcode
!=
null
){
return
responseBarcode
;
}
...
...
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
查看文件 @
3ab70f0
...
...
@@ -98,7 +98,7 @@ public class SettingsController {
@ApiOperation
(
"获取系统设置信息"
)
@GetMapping
(
"sysSettings"
)
@GetMapping
(
"
/
sysSettings"
)
@PreAuthorize
(
"@el.check('sysSetting')"
)
public
SysSettingsDto
getSysSettings
()
{
...
...
@@ -112,7 +112,7 @@ public class SettingsController {
}
@ApiOperation
(
"修改系统设置信息"
)
@PutMapping
(
"sysSettings"
)
@PutMapping
(
"
/
sysSettings"
)
@PreAuthorize
(
"@el.check('sysSetting')"
)
public
ResultBean
updateSysSettings
(
@Validated
@RequestBody
SysSettingsDto
sysSettingsDto
)
{
dataCache
.
updateCache
(
Constants
.
CACHE_StopOut
,
sysSettingsDto
.
isStopOut
());
...
...
@@ -123,7 +123,7 @@ public class SettingsController {
}
@ApiOperation
(
"获取出库策略信息"
)
@GetMapping
(
"checkoutSettings"
)
@GetMapping
(
"
/
checkoutSettings"
)
@PreAuthorize
(
"@el.check('outSetting')"
)
public
Map
<
String
,
String
>
getCheckOutSettings
()
{
String
outSet
=
dataCache
.
getCache
(
Constants
.
CACHE_CheckOutType
);
...
...
@@ -133,7 +133,7 @@ public class SettingsController {
}
@ApiOperation
(
"修改出库策略"
)
@PutMapping
(
"checkoutSettings"
)
@PutMapping
(
"
/
checkoutSettings"
)
@PreAuthorize
(
"@el.check('outSetting')"
)
public
ResultBean
update
(
@Validated
@RequestBody
String
type
)
{
// String type=map.get("checkOutType");
...
...
src/main/java/com/neotel/smfcore/hella/handler/HellaApiHandler.java
0 → 100644
查看文件 @
3ab70f0
package
com
.
neotel
.
smfcore
.
hella
.
handler
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.device.api.IOpAuthApi
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.hella.tcp.HellaTcpClient
;
import
com.neotel.smfcore.hella.tcp.command.HellaReqCommand
;
import
com.neotel.smfcore.hella.tcp.command.HellaRespCommand
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
public
class
HellaApiHandler
implements
IOpAuthApi
{
@Autowired
private
HellaServiceHandler
hellaServiceHandler
;
@Override
public
Barcode
resolveBarcode
(
String
loginUser
,
String
groupId
,
String
storageId
,
String
code
)
throws
ValidateException
{
if
(!
isEnable
())
{
return
null
;
}
hellaServiceHandler
.
checkMaterial
(
loginUser
,
groupId
,
storageId
,
code
);
Barcode
barcode
=
new
Barcode
();
barcode
.
setFullCode
(
code
);
return
barcode
;
}
@Override
public
Barcode
canPutIn
(
Barcode
barcode
)
throws
ValidateException
{
if
(!
isEnable
())
{
return
null
;
}
return
barcode
;
}
@Override
public
boolean
canCheckout
(
Barcode
barcode
)
throws
ValidateException
{
if
(!
isEnable
()){
return
false
;
}
return
false
;
}
@Override
public
boolean
isEnable
()
{
return
HellaTcpClient
.
isEnable
();
}
}
src/main/java/com/neotel/smfcore/hella/rest/HellaSensorShelfController.java
deleted
100644 → 0
查看文件 @
e91fb98
package
com
.
neotel
.
smfcore
.
hella
.
rest
;
import
cn.hutool.core.util.ObjectUtil
;
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.manager.IBarcodeManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.storage.service.manager.IStoragePosManager
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.hella.handler.HellaServiceHandler
;
import
com.neotel.smfcore.security.service.manager.IGroupManager
;
import
com.neotel.smfcore.security.service.po.Group
;
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.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Controller
;
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
=
"海拉感应料架"
)
@RequestMapping
(
"/api/sensorShelf"
)
@RestController
@Slf4j
public
class
HellaSensorShelfController
{
@Autowired
private
DataCache
dataCache
;
@Autowired
private
HellaServiceHandler
hellaServiceHandler
;
@Autowired
private
TaskService
taskService
;
@Autowired
protected
IStoragePosManager
storagePosManager
;
@Autowired
protected
IBarcodeManager
barcodeManager
;
@Autowired
protected
IGroupManager
groupManager
;
/**
* 扫码
*/
@ApiOperation
(
"扫码入库"
)
@PostMapping
(
"/codeIn"
)
@PreAuthorize
(
"@el.check('sensorShelf:putIn')"
)
public
ResultBean
codeIn
(
@RequestBody
Map
<
String
,
String
>
mapValues
)
{
String
code
=
mapValues
.
get
(
"code"
);
String
groupId
=
mapValues
.
get
(
"group"
);
String
storageId
=
mapValues
.
get
(
"storageId"
);
if
(
ObjectUtils
.
isEmpty
(
code
)){
throw
new
ValidateException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"code"
});
}
if
(
groupId
==
null
&&
storageId
==
null
){
throw
new
ValidateException
(
"smfcode.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
=
""
;
}
String
loginUser
=
SecurityUtils
.
getLoginUsername
();
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
();
ResultBean
resultBean
=
null
;
for
(
DataLog
queueTask
:
queueTasks
)
{
if
(
queueTask
.
isPutInTask
()
&&
queueTask
.
isWait
())
{
if
(
ObjectUtil
.
isEmpty
(
storageId
)&&
groupId
!=
null
&&
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
(
storageId
!=
null
&&
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
()});
}
}
}
resultBean
=
hellaServiceHandler
.
checkMaterial
(
loginUser
,
groupId
,
storageId
,
code
);
return
resultBean
;
}
}
src/main/java/com/neotel/smfcore/hella/tcp/HellaTcpClient.java
查看文件 @
3ab70f0
...
...
@@ -73,6 +73,14 @@ public class HellaTcpClient {
}
}
public
static
boolean
isEnable
()
{
if
(
ObjectUtil
.
isEmpty
(
host
)
||
ObjectUtil
.
isEmpty
(
port
))
{
return
false
;
}
else
{
return
true
;
}
}
public
static
void
updateServerInfo
(
String
serverHost
,
int
serverPort
){
host
=
serverHost
;
port
=
serverPort
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论