Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 656051db
由
LN
编写于
2022-01-27 09:10:40 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
料仓增加入库单绑定
1 个父辈
44af67fc
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
249 行增加
和
11 行删除
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
src/main/java/com/neotel/smfcore/core/inList/bean/ItemReelInfo.java
src/main/java/com/neotel/smfcore/core/inList/rest/InListController.java
src/main/java/com/neotel/smfcore/core/inList/service/manager/impl/InListManagerImpl.java
src/main/java/com/neotel/smfcore/core/inList/util/InListCache.java
src/main/java/com/neotel/smfcore/core/kanban/rest/BoxKanbanController.java
src/main/java/com/neotel/smfcore/core/kanban/rest/bean/dto/BoxStatusDto.java
src/main/java/com/neotel/smfcore/core/storage/rest/dto/StorageDto.java
src/main/java/com/neotel/smfcore/core/storage/service/po/Storage.java
src/main/java/com/neotel/smfcore/core/system/websocket/WebSocketServer.java
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
查看文件 @
656051d
...
...
@@ -3,6 +3,7 @@ package com.neotel.smfcore.common.init;
import
com.neotel.smfcore.common.utils.PermissionInitUtil
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.UserCodeUtil
;
import
com.neotel.smfcore.core.inList.util.InListCache
;
import
com.neotel.smfcore.core.order.util.OrderFileWatch
;
import
com.neotel.smfcore.core.system.service.manager.IDataLogManager
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
...
...
@@ -54,6 +55,9 @@ public class DataInitManager {
@Autowired
OrderFileWatch
orderFileWatch
;
@Autowired
private
InListCache
inListCache
;
/**
* 当前版本
*/
...
...
@@ -111,6 +115,8 @@ public class DataInitManager {
orderFileWatch
.
init
();
allPermissionSet
=
annotationUtil
.
initPermission
();
inListCache
.
loadMap
();
}
catch
(
Exception
exception
)
{
log
.
error
(
"初始化环境出错..."
+
exception
.
toString
());
}
...
...
src/main/java/com/neotel/smfcore/core/inList/bean/ItemReelInfo.java
查看文件 @
656051d
package
com
.
neotel
.
smfcore
.
core
.
inList
.
bean
;
import
cn.hutool.core.date.DateTime
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
@Document
@AllArgsConstructor
@NoArgsConstructor
public
class
ItemReelInfo
implements
Serializable
{
/**
...
...
@@ -22,5 +27,10 @@ public class ItemReelInfo implements Serializable {
/**
* 入库时间
*/
private
DateTime
inTime
;
private
Date
inTime
;
/**
* 库位号
*/
private
String
posName
;
}
src/main/java/com/neotel/smfcore/core/inList/rest/InListController.java
查看文件 @
656051d
...
...
@@ -9,6 +9,7 @@ import com.neotel.smfcore.common.csv.CsvReader;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.FileUtil
;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.inList.enums.INLIST_STATUS
;
import
com.neotel.smfcore.core.inList.rest.bean.dto.InListDto
;
import
com.neotel.smfcore.core.inList.rest.bean.dto.InListItemDto
;
...
...
@@ -19,6 +20,9 @@ import com.neotel.smfcore.core.inList.service.manager.IInListItemManager;
import
com.neotel.smfcore.core.inList.service.manager.IInListManager
;
import
com.neotel.smfcore.core.inList.service.po.InList
;
import
com.neotel.smfcore.core.inList.service.po.InListItem
;
import
com.neotel.smfcore.core.inList.util.InListCache
;
import
com.neotel.smfcore.core.storage.enums.DeviceType
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
com.neotel.smfcore.security.bean.FileProperties
;
import
io.swagger.annotations.Api
;
...
...
@@ -56,6 +60,11 @@ public class InListController {
private
InListMapper
inListMapper
;
@Autowired
private
InListItemMapper
inListItemMapper
;
@Autowired
private
InListCache
inListCache
;
@Autowired
private
DataCache
dataCache
;
@ApiOperation
(
"上传入库单"
)
@PostMapping
(
value
=
"/upload"
)
...
...
@@ -101,6 +110,7 @@ public class InListController {
}
log
.
info
(
"新增加入库单:"
+
inList
.
getName
()
+
",共"
+
inListItems
.
size
()
+
"条工单详情"
);
inList
=
inListManager
.
createWithItems
(
inList
);
inListCache
.
addInListToMap
(
inList
);
// liteOrderCache.addOrderToMap(liteOrder);
}
...
...
@@ -122,7 +132,6 @@ public class InListController {
@ApiOperation
(
"入库单详情"
)
@GetMapping
(
"/detial"
)
@PreAuthorize
(
"@el.check('inList')"
)
@AnonymousAccess
public
InListDto
detial
(
@RequestParam
(
required
=
false
)
String
id
,
@RequestParam
(
required
=
false
)
String
name
)
{
if
(!
ObjectUtils
.
isEmpty
(
id
))
{
...
...
@@ -133,7 +142,10 @@ public class InListController {
return
dto
;
}
}
else
if
(!
ObjectUtils
.
isEmpty
(
name
))
{
InList
inList
=
inListManager
.
findByName
(
name
);
InList
inList
=
inListCache
.
getInList
(
name
);
if
(
inList
==
null
){
inListManager
.
findByName
(
name
);
}
if
(
inList
!=
null
)
{
InListDto
dto
=
inListMapper
.
toDto
(
inList
);
dto
.
setInListItems
(
inListItemMapper
.
toDto
(
inList
.
getInListItems
()));
...
...
@@ -148,7 +160,6 @@ public class InListController {
@ApiOperation
(
"入库单入库信息列表"
)
@GetMapping
(
"/reelList"
)
@PreAuthorize
(
"@el.check('inList')"
)
@AnonymousAccess
public
InListItemDto
reelList
(
@RequestParam
String
id
)
{
if
(!
ObjectUtils
.
isEmpty
(
id
))
{
...
...
@@ -162,6 +173,46 @@ public class InListController {
}
@ApiOperation
(
"设置料架入库单"
)
@PostMapping
(
value
=
"/setInList"
)
@PreAuthorize
(
"@el.check('inList')"
)
public
ResultBean
setInList
(
@RequestBody
Map
<
String
,
String
>
params
)
{
String
inListName
=
params
.
get
(
"inListName"
);
String
storageId
=
params
.
get
(
"storageId"
);
String
groupId
=
params
.
get
(
"groupId"
);
InList
inList
=
inListCache
.
getInList
(
inListName
);
if
(
inList
==
null
)
{
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.inlist.notFound"
,
"未找到入库单[{0}]"
,
new
String
[]{
inListName
});
}
if
(
inList
.
getStatus
()
==
INLIST_STATUS
.
OK
)
{
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.inlist.listOk"
,
"入库单[{0}]已完成"
,
new
String
[]{
inListName
});
}
if
(
ObjectUtil
.
isEmpty
(
storageId
))
{
List
<
String
>
cidList
=
dataCache
.
getCidsByGroupId
(
groupId
,
false
);
int
groupType
=
0
;
for
(
String
cid
:
cidList
)
{
Storage
storage
=
dataCache
.
getStorage
(
cid
);
if
(
storage
!=
null
)
{
if
(
storage
.
isShelf
()
||
storage
.
isNLShelf
()
||
storage
.
isAccShelf
()
||
storage
.
isCodeShelf
())
{
storage
.
setInListName
(
inListName
);
log
.
info
(
"设置组["
+
groupId
+
"]料架["
+
storage
.
getName
()
+
"]的入库单为:["
+
inListName
+
"]"
);
}
}
}
}
else
{
Storage
storage
=
dataCache
.
getStorageById
(
storageId
);
if
(
storage
!=
null
)
{
if
(
storage
.
isShelf
()
||
storage
.
isNLShelf
()
||
storage
.
isAccShelf
()
||
storage
.
isCodeShelf
())
{
storage
.
setInListName
(
inListName
);
log
.
info
(
"设置料架["
+
storage
.
getName
()
+
"]的入库单为:["
+
inListName
+
"]"
);
}
}
}
return
ResultBean
.
newOkResult
(
"smfcore.inlist.setOk"
,
"设置成功"
,
""
);
}
private
Map
<
String
,
List
<
InListItem
>>
readCsvFile
(
String
fileName
,
String
fileURL
)
{
...
...
src/main/java/com/neotel/smfcore/core/inList/service/manager/impl/InListManagerImpl.java
查看文件 @
656051d
...
...
@@ -30,7 +30,7 @@ private IInListItemManager inListItemManager;
@Override
public
InList
get
(
String
id
)
{
InList
list
=
inListDao
.
findOneById
(
id
);
if
(
list
!=
null
&&
list
.
getInListItems
()==
null
){
if
(
list
!=
null
){
List
<
InListItem
>
items
=
inListItemManager
.
findListItems
(
list
.
getName
());
list
.
setInListItems
(
items
);
}
...
...
@@ -62,7 +62,13 @@ private IInListItemManager inListItemManager;
@Override
public
InList
findByName
(
String
name
)
{
Query
query
=
new
Query
(
Criteria
.
where
(
"name"
).
is
(
name
));
return
inListDao
.
findOne
(
query
);
InList
list
=
inListDao
.
findOne
(
query
);
if
(
list
!=
null
){
List
<
InListItem
>
items
=
inListItemManager
.
findListItems
(
list
.
getName
());
list
.
setInListItems
(
items
);
}
return
list
;
}
@Override
...
...
src/main/java/com/neotel/smfcore/core/inList/util/InListCache.java
0 → 100644
查看文件 @
656051d
package
com
.
neotel
.
smfcore
.
core
.
inList
.
util
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.inList.bean.ItemReelInfo
;
import
com.neotel.smfcore.core.inList.enums.INLIST_STATUS
;
import
com.neotel.smfcore.core.inList.service.manager.IInListItemManager
;
import
com.neotel.smfcore.core.inList.service.manager.IInListManager
;
import
com.neotel.smfcore.core.inList.service.po.InList
;
import
com.neotel.smfcore.core.inList.service.po.InListItem
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.xmlbeans.XmlLineNumber
;
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.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
@Service
@Slf4j
public
class
InListCache
{
@Autowired
private
IInListManager
listManager
;
@Autowired
private
IInListItemManager
listItemManager
;
/**
* 入库单列表
*/
public
static
Map
<
String
,
InList
>
inListMap
=
new
ConcurrentHashMap
<>();
public
void
loadMap
()
{
log
.
info
(
"开始加载入库单"
);
Query
query
=
new
Query
(
Criteria
.
where
(
"status"
).
ne
(
2
));
List
<
InList
>
inLists
=
listManager
.
findByQuery
(
query
);
long
now
=
System
.
currentTimeMillis
();
for
(
InList
list
:
inLists
)
{
if
(
now
-
list
.
getUpdateDate
().
getTime
()
>
7
*
24
*
60
*
60
*
1000
)
{
log
.
info
(
"入库单 =["
+
list
.
getName
()
+
"]为7天前,关闭入库单"
);
}
else
{
addInListToMap
(
list
);
}
}
}
public
void
addInListToMap
(
InList
inList
){
if
(
inList
==
null
||
inList
.
getName
()==
null
){
return
;
}
if
(
inListMap
.
containsKey
(
inList
.
getName
())){
inListMap
.
remove
(
inList
.
getName
());
}
inListMap
.
put
(
inList
.
getName
(),
inList
);
}
public
InList
getInList
(
String
name
){
InList
inList
=
inListMap
.
get
(
name
);
if
(
inList
==
null
){
inList
=
listManager
.
findByName
(
name
);
if
(
inList
!=
null
){
addInListToMap
(
inList
);
}
}
return
inList
;
}
public
void
UpdateInList
(
String
inListName
,
StoragePos
pos
,
Barcode
barcode
)
{
if
(
ObjectUtil
.
isEmpty
(
inListName
))
{
return
;
}
InList
inList
=
getInList
(
inListName
);
if
(
inList
==
null
)
{
inList
=
listManager
.
findByName
(
inListName
);
}
if
(
inList
==
null
)
{
log
.
info
(
"UpdateInList : 入库单["
+
inListName
+
"]不存在,posName["
+
pos
.
getPosName
()
+
"]PN["
+
barcode
.
getPartNumber
()
+
"]RI["
+
barcode
.
getBarcode
()
+
"]num["
+
barcode
.
getAmount
()
+
"]"
);
}
boolean
updateOk
=
false
;
for
(
InListItem
item
:
inList
.
getInListItems
()
)
{
if
(
item
.
getPN
().
equals
(
barcode
.
getPartNumber
()))
{
updateOk
=
true
;
item
.
addReelInfo
(
new
ItemReelInfo
(
barcode
.
getBarcode
(),
barcode
.
getAmount
(),
new
Date
(),
pos
.
getPosName
()));
listItemManager
.
save
(
item
);
log
.
info
(
"UpdateInList 成功: 入库单["
+
inListName
+
"]posName["
+
pos
.
getPosName
()
+
"]PN["
+
barcode
.
getPartNumber
()
+
"]RI["
+
barcode
.
getBarcode
()
+
"]num["
+
barcode
.
getAmount
()
+
"]"
);
updateOk
=
true
;
break
;
}
}
boolean
listOk
=
true
;
for
(
InListItem
item
:
inList
.
getInListItems
()
)
{
if
(
item
.
getNum
()
!=
item
.
getInNum
())
{
listOk
=
false
;
break
;
}
}
if
(
listOk
)
{
inList
.
setStatus
(
INLIST_STATUS
.
OK
);
log
.
info
(
"UpdateInList 入库单["
+
inListName
+
"]更改状态为:OK"
);
}
else
if
(
updateOk
)
{
inList
.
setStatus
(
INLIST_STATUS
.
ABNORMAL
);
log
.
info
(
"UpdateInList 入库单["
+
inListName
+
"]更改状态为:ABNORMAL"
);
}
listManager
.
save
(
inList
);
addInListToMap
(
inList
);
}
public
ResultBean
inListValidate
(
String
inListName
,
String
pn
)
{
if
(
ObjectUtil
.
isEmpty
(
inListName
))
{
return
ResultBean
.
newOkResult
(
""
);
}
InList
inList
=
getInList
(
inListName
);
if
(
inList
==
null
)
{
inList
=
listManager
.
findByName
(
inListName
);
}
if
(
inList
==
null
)
{
return
ResultBean
.
newOkResult
(
""
);
}
for
(
InListItem
item
:
inList
.
getInListItems
()
)
{
if
(
item
.
getPN
().
equals
(
pn
)
)
{
if
(
item
.
getNum
()
>
item
.
getInNum
()){
return
ResultBean
.
newOkResult
(
""
);
}
else
{
log
.
error
(
"inListValidate 验证失败: 入库单["
+
inListName
+
"] PN["
+
pn
+
"] 已达到目标数量["
+
item
.
getNum
()+
"]["
+
item
.
getInNum
()+
"]"
);
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.inlist.pnItemOk"
,
"入库单[{0}]的物料[{1}]已入库完成"
,
new
String
[]{
inListName
,
pn
}
);
}
}
}
log
.
error
(
"inListValidate 验证失败: 入库单["
+
inListName
+
"]没有物料 PN["
+
pn
+
"]入库需求 "
);
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.inlist.noPn"
,
"入库单[{0}]没有物料[{1}]入库需求"
,
new
String
[]{
inListName
,
pn
}
);
}
}
src/main/java/com/neotel/smfcore/core/kanban/rest/BoxKanbanController.java
查看文件 @
656051d
...
...
@@ -423,7 +423,7 @@ public class BoxKanbanController {
int
allCount
=
inTask
+
outTask
;
BoxStatusDto
boxDto
=
new
BoxStatusDto
(
storage
.
getId
(),
storage
.
getName
(),
storage
.
getCid
(),
false
,
0
,
"0"
,
"0"
,
""
,
allCount
,
inTask
,
outTask
,
0
,
""
,
""
,
""
,
""
,
""
,
storage
.
getType
(),
storage
.
getUsageMap
(),
new
HashMap
<>());
0
,
""
,
""
,
""
,
""
,
""
,
storage
.
getType
(),
storage
.
getUsageMap
(),
new
HashMap
<>()
,
storage
.
getInListName
()
);
//获取设备状态,设置状态和当前任务信息
StatusBean
bean
=
DevicesStatusUtil
.
getStatusBean
(
storage
.
getCid
());
...
...
src/main/java/com/neotel/smfcore/core/kanban/rest/bean/dto/BoxStatusDto.java
查看文件 @
656051d
...
...
@@ -70,4 +70,7 @@ public class BoxStatusDto {
@ApiModelProperty
(
"操作信息"
)
private
Map
<
String
,
String
>
data
=
new
HashMap
<>();
@ApiModelProperty
(
"当前绑定的入库单名称"
)
private
String
inListName
=
""
;
}
src/main/java/com/neotel/smfcore/core/storage/rest/dto/StorageDto.java
查看文件 @
656051d
...
...
@@ -55,4 +55,8 @@ public class StorageDto implements Serializable {
@ApiModelProperty
(
"组名称"
)
private
String
groupName
=
""
;
@ApiModelProperty
(
"当前绑定的入库单名称"
)
private
String
inListName
=
""
;
}
src/main/java/com/neotel/smfcore/core/storage/service/po/Storage.java
查看文件 @
656051d
...
...
@@ -61,6 +61,11 @@ public class Storage extends BasePo implements Serializable {
*/
private
String
groupId
=
""
;
/**
* 当前绑定的入库单名称
*/
private
String
inListName
=
""
;
/**
* 是否是上下层的在线料仓
...
...
src/main/java/com/neotel/smfcore/core/system/websocket/WebSocketServer.java
查看文件 @
656051d
...
...
@@ -57,7 +57,7 @@ public class WebSocketServer {
* */
@OnOpen
public
void
onOpen
(
Session
session
,
@PathParam
(
"sid"
)
String
sid
)
{
String
psid
=
sid
.
substring
(
0
,
20
)
;
String
psid
=
sid
.
length
()>
20
?
sid
.
substring
(
0
,
20
):
sid
;
log
.
info
(
"["
+
psid
+
"]的webSocket已连接:"
+
session
.
getId
());
this
.
session
=
session
;
this
.
sid
=
sid
;
...
...
@@ -87,7 +87,7 @@ public class WebSocketServer {
*/
@OnClose
public
void
onClose
()
{
String
psid
=
sid
.
substring
(
0
,
20
)
;
String
psid
=
sid
.
length
()>
20
?
sid
.
substring
(
0
,
20
):
sid
;
log
.
info
(
"清理["
+
psid
+
"]连接:"
+
session
.
getId
());
webSocketSet
.
remove
(
this
);
}
...
...
@@ -132,6 +132,9 @@ public class WebSocketServer {
*/
public
static
void
sendMsg
(
String
token
,
SocketMsg
socketMsg
)
{
String
sid
=
"Bearer "
+
token
;
if
(
ObjectUtil
.
isEmpty
(
token
)){
sid
=
token
;
}
sendInfo
(
socketMsg
,
sid
);
}
...
...
@@ -140,7 +143,7 @@ public class WebSocketServer {
* */
public
static
void
sendInfo
(
SocketMsg
socketMsg
,
@PathParam
(
"sid"
)
String
sid
){
String
message
=
JSONObject
.
toJSONString
(
socketMsg
);
String
pSid
=
sid
.
substring
(
0
,
20
)
;
String
pSid
=
sid
.
length
()>
20
?
sid
.
substring
(
0
,
20
):
sid
;
boolean
sendOk
=
false
;
for
(
WebSocketServer
item
:
webSocketSet
)
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论