Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit bd210c83
由
LN
编写于
2024-07-22 15:00:12 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
入库单查找料箱生成出库任务
1 个父辈
f351910f
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
396 行增加
和
21 行删除
src/main/java/com/neotel/smfcore/core/storage/service/manager/IStoragePosManager.java
src/main/java/com/neotel/smfcore/core/storage/service/manager/impl/StoragePosManagerImpl.java
src/main/java/com/neotel/smfcore/custom/luxsan_sp/controller/SpReturnInventoryController.java
src/main/java/com/neotel/smfcore/custom/luxsan_sp/controller/SpSpareNoController.java
src/main/java/com/neotel/smfcore/custom/luxsan_sp/util/ReturnNoCache.java
src/main/java/com/neotel/smfcore/custom/luxsan_sp/util/SpareNoCache.java
src/main/java/com/neotel/smfcore/core/storage/service/manager/IStoragePosManager.java
查看文件 @
bd210c8
...
@@ -98,4 +98,8 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
...
@@ -98,4 +98,8 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
void
batchUpdatePosEnabled
(
List
<
String
>
idList
,
boolean
enabled
);
void
batchUpdatePosEnabled
(
List
<
String
>
idList
,
boolean
enabled
);
List
<
StoragePos
>
findPosByIdList
(
List
<
String
>
idList
);
List
<
StoragePos
>
findPosByIdList
(
List
<
String
>
idList
);
StoragePos
findBoxPNInStorages
(
List
<
String
>
storageIdList
,
String
pn
,
Collection
<
String
>
excludePosIds
,
CHECKOUT_TYPE
checkOutType
)
;
StoragePos
findEmptyBoxToPutIn
(
List
<
String
>
storageIdList
,
String
pn
,
Collection
<
String
>
excludePosIds
,
CHECKOUT_TYPE
checkOutType
)
;
}
}
src/main/java/com/neotel/smfcore/core/storage/service/manager/impl/StoragePosManagerImpl.java
查看文件 @
bd210c8
...
@@ -890,4 +890,69 @@ public class StoragePosManagerImpl implements IStoragePosManager {
...
@@ -890,4 +890,69 @@ public class StoragePosManagerImpl implements IStoragePosManager {
Query
query
=
new
Query
(
Criteria
.
where
(
"id"
).
in
(
idList
));
Query
query
=
new
Query
(
Criteria
.
where
(
"id"
).
in
(
idList
));
return
storagePosDao
.
findByQuery
(
query
);
return
storagePosDao
.
findByQuery
(
query
);
}
}
@Override
public
StoragePos
findBoxPNInStorages
(
List
<
String
>
storageIdList
,
String
pn
,
Collection
<
String
>
excludePosIds
,
CHECKOUT_TYPE
checkOutType
)
{
Criteria
c
=
Criteria
.
where
(
"id"
).
nin
(
excludePosIds
);
c
=
c
.
and
(
"enabled"
).
is
(
true
);
//可用
c
.
and
(
"used"
).
is
(
true
);
c
.
and
(
"barcode"
).
exists
(
true
);
//已使用有料箱
c
.
and
(
"barcode.status"
).
is
(
BARCODE_STATUS
.
IN_STORE
);
if
(
storageIdList
!=
null
)
{
c
=
c
.
and
(
"storageId"
).
in
(
storageIdList
);
}
if
(
ObjectUtil
.
isNotEmpty
(
pn
))
{
c
.
and
(
"barcode.subCodeList.partNumber"
).
is
(
pn
);
}
// if (ObjectUtil.isNotEmpty(warehouseCode)) {
// c.and("barcode.subCodeList.warehouseCode").is(warehouseCode);
// }
// if (ObjectUtil.isNotEmpty(brand)) {
// c.and("barcode.subCodeList.provider").is(brand);
// }
// if (isOut){
// c.and("barcode.subCodeList.isOut").is(isOut);
// }
//Sort sort = getSortByCheckOutType(checkOutType);
Sort
sort
=
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"barcode.subCodeList.createDate"
,
"barcode.subCodeList.amount"
/*,"canCheckOutTime", "barcode.usedCount"*/
);
Query
q
=
new
Query
(
c
);
q
.
with
(
sort
);
StoragePos
pos
=
storagePosDao
.
findOne
(
q
);
if
(
pos
==
null
)
{
log
.
info
(
"使用"
+
checkOutType
+
" 策略出库 partNumber="
+
pn
+
",库存未找到PN "
);
}
else
{
log
.
info
(
"使用"
+
checkOutType
+
" 策略出库 partNumber="
+
pn
+
",找到PN【"
+
pos
.
getPosName
()
+
"】 "
);
}
return
pos
;
}
@Override
public
StoragePos
findEmptyBoxToPutIn
(
List
<
String
>
storageIdList
,
String
pn
,
Collection
<
String
>
excludePosIds
,
CHECKOUT_TYPE
checkOutType
)
{
Criteria
c
=
Criteria
.
where
(
"id"
).
nin
(
excludePosIds
);
c
=
c
.
and
(
"enabled"
).
is
(
true
);
//可用
c
.
and
(
"used"
).
is
(
true
);
c
.
and
(
"barcode"
).
exists
(
true
);
//已使用有料箱
c
.
and
(
"barcode.status"
).
is
(
BARCODE_STATUS
.
IN_STORE
);
if
(
storageIdList
!=
null
)
{
c
=
c
.
and
(
"storageId"
).
in
(
storageIdList
);
}
if
(
ObjectUtil
.
isNotEmpty
(
pn
))
{
c
.
and
(
"barcode.subCodeList.partNumber"
).
is
(
pn
);
}
Sort
sort
=
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"barcode.subCodeList.createDate"
,
"barcode.subCodeList.amount"
/*,"canCheckOutTime", "barcode.usedCount"*/
);
Query
q
=
new
Query
(
c
);
q
.
with
(
sort
);
String
proName
=
"subCodeList."
+
(
6
-
1
);
q
.
addCriteria
(
Criteria
.
where
(
proName
).
exists
(
false
));
StoragePos
pos
=
storagePosDao
.
findOne
(
q
);
if
(
pos
==
null
)
{
log
.
info
(
"使用"
+
checkOutType
+
" 策略出库 partNumber="
+
pn
+
",库存未找到PN "
);
}
else
{
log
.
info
(
"使用"
+
checkOutType
+
" 策略出库 partNumber="
+
pn
+
",找到PN【"
+
pos
.
getPosName
()
+
"】 "
);
}
return
pos
;
}
}
}
src/main/java/com/neotel/smfcore/custom/luxsan_sp/controller/SpReturnInventoryController.java
查看文件 @
bd210c8
...
@@ -79,10 +79,12 @@ public class SpReturnInventoryController {
...
@@ -79,10 +79,12 @@ public class SpReturnInventoryController {
if
(
returnInventoryNo
==
null
)
{
if
(
returnInventoryNo
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"未找到对应的退库单信息"
);
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"未找到对应的退库单信息"
);
}
}
String
exeResult
=
returnNoCache
.
Execute
(
returnInventoryNo
);
if
(
ObjectUtil
.
isNotEmpty
(
exeResult
)){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"执行退库单失败:"
+
exeResult
);
}
returnInventoryNo
.
setSpareStatus
(
SpareNostatus
.
EXECUTING_STATUS
);
returnNoCache
.
addToMap
(
returnInventoryNo
);
returnNoManager
.
save
(
returnInventoryNo
);
return
ResultBean
.
newOkResult
(
""
);
return
ResultBean
.
newOkResult
(
""
);
}
}
...
...
src/main/java/com/neotel/smfcore/custom/luxsan_sp/controller/SpSpareNoController.java
查看文件 @
bd210c8
...
@@ -95,9 +95,13 @@ public class SpSpareNoController {
...
@@ -95,9 +95,13 @@ public class SpSpareNoController {
if
(
spareNo
==
null
)
{
if
(
spareNo
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"未找到对应的入库单信息"
);
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"未找到对应的入库单信息"
);
}
}
spareNo
.
setSpareStatus
(
SpareNostatus
.
EXECUTING_STATUS
);
String
exeResult
=
spareNoCache
.
Execute
(
spareNo
);
spareNoCache
.
addToMap
(
spareNo
);
if
(
ObjectUtil
.
isNotEmpty
(
exeResult
)){
spareNoManager
.
save
(
spareNo
);
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"执行退库单失败:"
+
exeResult
);
}
// spareNo.setSpareStatus(SpareNostatus.EXECUTING_STATUS);
// spareNoCache.addToMap(spareNo);
// spareNoManager.save(spareNo);
return
ResultBean
.
newOkResult
(
""
);
return
ResultBean
.
newOkResult
(
""
);
}
}
...
...
src/main/java/com/neotel/smfcore/custom/luxsan_sp/util/ReturnNoCache.java
查看文件 @
bd210c8
package
com
.
neotel
.
smfcore
.
custom
.
luxsan_sp
.
util
;
package
com
.
neotel
.
smfcore
.
custom
.
luxsan_sp
.
util
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS
;
import
com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
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.TaskService
;
import
com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetReturnInventoryResult
;
import
com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetReturnInventoryResult
;
import
com.neotel.smfcore.custom.luxsan_sp.bean.ReturnInventoryNo
;
import
com.neotel.smfcore.custom.luxsan_sp.bean.ReturnInventoryNo
;
import
com.neotel.smfcore.custom.luxsan_sp.bean.SpareNo
;
import
com.neotel.smfcore.custom.luxsan_sp.bean.SpareNoDetail
;
import
com.neotel.smfcore.custom.luxsan_sp.bean.SpareNoDetail
;
import
com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus
;
import
com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus
;
import
com.neotel.smfcore.custom.luxsan_sp.service.manager.IReturnNoManager
;
import
com.neotel.smfcore.custom.luxsan_sp.service.manager.IReturnNoManager
;
import
com.neotel.smfcore.custom.luxsan_sp.service.manager.IUnclaimedManager
;
import
lombok.extern.slf4j.Slf4j
;
import
org.ehcache.impl.internal.concurrent.ConcurrentHashMap
;
import
org.ehcache.impl.internal.concurrent.ConcurrentHashMap
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Map
;
@Service
@Service
@Slf4j
public
class
ReturnNoCache
{
public
class
ReturnNoCache
{
public
ReturnNoCache
(
ApplicationContext
applicationContext
)
{
public
ReturnNoCache
(
ApplicationContext
applicationContext
)
{
...
@@ -31,18 +41,18 @@ public class ReturnNoCache {
...
@@ -31,18 +41,18 @@ public class ReturnNoCache {
@Autowired
@Autowired
private
IReturnNoManager
returnNoManager
;
private
IReturnNoManager
returnNoManager
;
Map
<
String
,
ReturnInventoryNo
>
cacheMap
=
new
ConcurrentHashMap
<>();
Map
<
String
,
ReturnInventoryNo
>
cacheMap
=
new
ConcurrentHashMap
<>();
public
void
addToMap
(
ReturnInventoryNo
returnInventoryNo
){
public
void
addToMap
(
ReturnInventoryNo
returnInventoryNo
)
{
cacheMap
.
put
(
returnInventoryNo
.
getOrderNo
(),
returnInventoryNo
);
cacheMap
.
put
(
returnInventoryNo
.
getOrderNo
(),
returnInventoryNo
);
}
}
public
ReturnInventoryNo
getByOrderNo
(
String
orderNo
)
{
public
ReturnInventoryNo
getByOrderNo
(
String
orderNo
)
{
ReturnInventoryNo
returnInventoryNo
=
cacheMap
.
get
(
orderNo
);
ReturnInventoryNo
returnInventoryNo
=
cacheMap
.
get
(
orderNo
);
if
(
returnInventoryNo
==
null
){
if
(
returnInventoryNo
==
null
)
{
returnInventoryNo
=
returnNoManager
.
getByOrderNo
(
orderNo
);
returnInventoryNo
=
returnNoManager
.
getByOrderNo
(
orderNo
);
if
(
returnInventoryNo
!=
null
){
if
(
returnInventoryNo
!=
null
)
{
cacheMap
.
put
(
returnInventoryNo
.
getOrderNo
(),
returnInventoryNo
);
cacheMap
.
put
(
returnInventoryNo
.
getOrderNo
(),
returnInventoryNo
);
}
}
}
}
...
@@ -50,7 +60,7 @@ public class ReturnNoCache {
...
@@ -50,7 +60,7 @@ public class ReturnNoCache {
}
}
public
String
getExecutingOrderNoStr
(){
public
String
getExecutingOrderNoStr
()
{
for
(
ReturnInventoryNo
returnInventoryNo
:
cacheMap
.
values
())
{
for
(
ReturnInventoryNo
returnInventoryNo
:
cacheMap
.
values
())
{
if
(
ObjectUtil
.
isNotNull
(
returnInventoryNo
)
&&
returnInventoryNo
.
isExecuting
())
{
if
(
ObjectUtil
.
isNotNull
(
returnInventoryNo
)
&&
returnInventoryNo
.
isExecuting
())
{
return
returnInventoryNo
.
getOrderNo
();
return
returnInventoryNo
.
getOrderNo
();
...
@@ -59,7 +69,7 @@ public class ReturnNoCache {
...
@@ -59,7 +69,7 @@ public class ReturnNoCache {
return
null
;
return
null
;
}
}
public
ReturnInventoryNo
getExecutingOrderNo
(){
public
ReturnInventoryNo
getExecutingOrderNo
()
{
for
(
ReturnInventoryNo
returnInventoryNo
:
cacheMap
.
values
())
{
for
(
ReturnInventoryNo
returnInventoryNo
:
cacheMap
.
values
())
{
if
(
ObjectUtil
.
isNotNull
(
returnInventoryNo
)
&&
returnInventoryNo
.
isExecuting
())
{
if
(
ObjectUtil
.
isNotNull
(
returnInventoryNo
)
&&
returnInventoryNo
.
isExecuting
())
{
return
returnInventoryNo
;
return
returnInventoryNo
;
...
@@ -89,4 +99,143 @@ public class ReturnNoCache {
...
@@ -89,4 +99,143 @@ public class ReturnNoCache {
cacheMap
.
put
(
orderNo
,
returnInventoryNo
);
cacheMap
.
put
(
orderNo
,
returnInventoryNo
);
returnNoManager
.
save
(
returnInventoryNo
);
returnNoManager
.
save
(
returnInventoryNo
);
}
}
@Autowired
private
IStoragePosManager
storagePosManager
;
@Autowired
private
IBarcodeManager
barcodeManager
;
@Autowired
private
DataCache
dataCache
;
@Autowired
private
TaskService
taskService
;
/**
*
*/
public
synchronized
String
Execute
(
ReturnInventoryNo
returnNo
)
{
try
{
if
(
returnNo
.
getSpareStatus
().
equals
(
SpareNostatus
.
EXECUTING_STATUS
))
{
return
"已在执行中"
;
}
String
orderNo
=
returnNo
.
getOrderNo
();
log
.
info
(
"开始执行ReturnInventoryNo["
+
orderNo
+
"] "
);
List
<
StoragePos
>
needOutPos
=
new
ArrayList
<>();
List
<
String
>
storageIdList
=
new
ArrayList
<>();
for
(
Storage
storage
:
dataCache
.
getAllStorage
().
values
())
{
storageIdList
.
add
(
storage
.
getId
());
}
for
(
SpareNoDetail
detail
:
returnNo
.
getDetailList
())
{
String
pn
=
detail
.
getPartno
();
Collection
<
String
>
excludePosIds
=
taskService
.
excludePosIds
();
//根据pn查找
StoragePos
pos
=
storagePosManager
.
findBoxPNInStorages
(
storageIdList
,
pn
,
excludePosIds
,
dataCache
.
getCheckOutType
());
if
(
pos
!=
null
)
{
Barcode
boxBarcode
=
pos
.
getBarcode
();
for
(
Barcode
subBarcode
:
boxBarcode
.
getSubCodeList
())
{
if
(
subBarcode
.
getPartNumber
().
equals
(
pn
))
{
subBarcode
.
setOut
(
false
);
subBarcode
.
updateExtraData
(
"needInNum"
,
detail
.
getInQty
()
+
""
);
log
.
info
(
"入库单"
+
orderNo
+
", Pn="
+
pn
+
",查找到库位号="
+
pos
.
getPosName
()
+
",料箱号="
+
boxBarcode
.
getBarcode
()
+
",格口号="
+
subBarcode
.
getBarcode
()
+
",需要入库数量="
+
detail
.
getInQty
());
}
}
boxBarcode
.
setOut
(
false
);
boxBarcode
.
setStatus
(
BARCODE_STATUS
.
IN_STORE
);
needOutPos
.
add
(
pos
);
}
else
{
Barcode
newPn
=
new
Barcode
();
newPn
.
setPn
(
pn
);
newPn
.
setAmount
(
0
);
newPn
.
setInitialAmount
(
0
);
newPn
.
setOut
(
false
);
newPn
.
updateExtraData
(
"needInNum"
,
detail
.
getInQty
()
+
""
);
//查找准备出库的料箱中是否有空格口
StoragePos
emptyPos
=
needOutPos
.
stream
()
.
filter
(
emptyP
->
(
emptyP
.
getBarcode
().
getSubCodeList
().
size
()
<
6
))
.
findFirst
()
.
orElse
(
null
);
Barcode
emptyBox
=
null
;
if
(
emptyPos
!=
null
)
{
//使用此格口
emptyBox
=
emptyPos
.
getBarcode
();
newPn
.
setBarcode
(
emptyBox
.
getBarcode
()
+
"-"
+
emptyBox
.
getSubCodeList
().
size
());
newPn
=
barcodeManager
.
saveBarcode
(
newPn
);
List
<
Barcode
>
subL
=
emptyBox
.
getSubCodeList
();
subL
.
add
(
newPn
);
emptyBox
.
setSubCodeList
(
subL
);
log
.
info
(
"入库单"
+
orderNo
+
", Pn="
+
pn
+
",使用料箱的空格口="
+
pos
.
getPosName
()
+
",料箱号="
+
emptyBox
.
getBarcode
()
+
",格口号="
+
newPn
.
getBarcode
()
+
",需要入库数量="
+
detail
.
getInQty
());
}
else
{
//寻找一个空格口
excludePosIds
=
taskService
.
excludePosIds
();
emptyPos
=
storagePosManager
.
findEmptyBoxToPutIn
(
storageIdList
,
pn
,
excludePosIds
,
dataCache
.
getCheckOutType
());
emptyBox
=
emptyPos
.
getBarcode
();
if
(
pos
!=
null
)
{
newPn
.
setBarcode
(
emptyBox
.
getBarcode
()
+
"-"
+
emptyBox
.
getSubCodeList
().
size
());
newPn
=
barcodeManager
.
saveBarcode
(
newPn
);
List
<
Barcode
>
subL
=
emptyBox
.
getSubCodeList
();
subL
.
add
(
newPn
);
emptyBox
.
setSubCodeList
(
subL
);
emptyBox
.
setOut
(
false
);
emptyBox
.
setStatus
(
BARCODE_STATUS
.
IN_STORE
);
needOutPos
.
add
(
pos
);
log
.
info
(
"入库单"
+
orderNo
+
", Pn="
+
pn
+
",查找到有空格口料箱="
+
pos
.
getPosName
()
+
",料箱号="
+
emptyBox
.
getBarcode
()
+
",格口号="
+
newPn
.
getBarcode
()
+
",需要入库数量="
+
detail
.
getInQty
());
}
else
{
log
.
info
(
"入库单"
+
orderNo
+
", Pn="
+
pn
+
",未找到可用的空料箱="
);
}
}
}
}
//开始生成出库任务
int
index
=
1
;
for
(
StoragePos
pos
:
needOutPos
)
{
Barcode
barcode
=
pos
.
getBarcode
();
log
.
info
(
"入库单"
+
orderNo
+
", 为库位="
+
pos
.
getPosName
()
+
",料箱="
+
barcode
.
getBarcode
()
+
"生成出库任务:"
+
index
);
barcodeManager
.
saveBarcode
(
barcode
);
storagePosManager
.
save
(
pos
);
Storage
storage
=
dataCache
.
getStorageById
(
pos
.
getStorageId
());
log
.
info
(
pos
.
getPosName
()
+
"出库,料箱号为:"
+
barcode
.
getBarcode
());
DataLog
task
=
new
DataLog
(
storage
,
barcode
,
pos
);
task
.
setSourceId
(
returnNo
.
getId
());
task
.
setSourceName
(
orderNo
);
task
.
setSubSourceId
(
barcode
.
getLockName
());
task
.
setSubSourceInfo
(
barcode
.
getLockName
());
task
.
setLoc
(
"s1"
);
task
.
setType
(
OP
.
CHECKOUT
);
task
.
setCreator
(
SecurityUtils
.
getCurrentUsername
());
task
.
setStatus
(
OP_STATUS
.
WAIT
.
name
());
try
{
taskService
.
addTaskToExecute
(
task
);
}
catch
(
Exception
e
)
{
e
.
getMessage
();
}
index
++;
}
returnNo
.
setSpareStatus
(
SpareNostatus
.
EXECUTING_STATUS
);
addToMap
(
returnNo
);
returnNoManager
.
save
(
returnNo
);
}
catch
(
Exception
exception
)
{
log
.
error
(
"执行ReturnInventoryNo 出错: "
+
exception
.
toString
());
}
return
""
;
}
}
}
src/main/java/com/neotel/smfcore/custom/luxsan_sp/util/SpareNoCache.java
查看文件 @
bd210c8
package
com
.
neotel
.
smfcore
.
custom
.
luxsan_sp
.
util
;
package
com
.
neotel
.
smfcore
.
custom
.
luxsan_sp
.
util
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS
;
import
com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
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.TaskService
;
import
com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoDetail
;
import
com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoDetail
;
import
com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoResult
;
import
com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoResult
;
import
com.neotel.smfcore.custom.luxsan_sp.bean.SpareNo
;
import
com.neotel.smfcore.custom.luxsan_sp.bean.SpareNo
;
import
com.neotel.smfcore.custom.luxsan_sp.bean.SpareNoDetail
;
import
com.neotel.smfcore.custom.luxsan_sp.bean.SpareNoDetail
;
import
com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus
;
import
com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus
;
import
com.neotel.smfcore.custom.luxsan_sp.service.manager.IReturnNoManager
;
import
com.neotel.smfcore.custom.luxsan_sp.service.manager.ISpareNoManager
;
import
com.neotel.smfcore.custom.luxsan_sp.service.manager.ISpareNoManager
;
import
lombok.extern.slf4j.Slf4j
;
import
org.ehcache.impl.internal.concurrent.ConcurrentHashMap
;
import
org.ehcache.impl.internal.concurrent.ConcurrentHashMap
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Map
;
@Service
@Service
@Slf4j
public
class
SpareNoCache
{
public
class
SpareNoCache
{
public
SpareNoCache
(
ApplicationContext
applicationContext
)
{
public
SpareNoCache
(
ApplicationContext
applicationContext
)
{
...
@@ -103,4 +114,144 @@ public class SpareNoCache {
...
@@ -103,4 +114,144 @@ public class SpareNoCache {
spareNoManager
.
save
(
spareNo
);
spareNoManager
.
save
(
spareNo
);
}
}
@Autowired
private
IStoragePosManager
storagePosManager
;
@Autowired
private
IBarcodeManager
barcodeManager
;
@Autowired
private
DataCache
dataCache
;
@Autowired
private
TaskService
taskService
;
/**
*
*/
public
synchronized
String
Execute
(
SpareNo
spareNo
)
{
try
{
if
(
spareNo
.
getSpareStatus
().
equals
(
SpareNostatus
.
EXECUTING_STATUS
))
{
return
"已在执行中"
;
}
String
orderNo
=
spareNo
.
getSpareNo
();
log
.
info
(
"开始执行ReturnInventoryNo["
+
orderNo
+
"] "
);
List
<
StoragePos
>
needOutPos
=
new
ArrayList
<>();
List
<
String
>
storageIdList
=
new
ArrayList
<>();
for
(
Storage
storage
:
dataCache
.
getAllStorage
().
values
())
{
storageIdList
.
add
(
storage
.
getId
());
}
for
(
SpareNoDetail
detail
:
spareNo
.
getDetailList
())
{
String
pn
=
detail
.
getPartno
();
Collection
<
String
>
excludePosIds
=
taskService
.
excludePosIds
();
//根据pn查找
StoragePos
pos
=
storagePosManager
.
findBoxPNInStorages
(
storageIdList
,
pn
,
excludePosIds
,
dataCache
.
getCheckOutType
());
if
(
pos
!=
null
)
{
Barcode
boxBarcode
=
pos
.
getBarcode
();
for
(
Barcode
subBarcode
:
boxBarcode
.
getSubCodeList
())
{
if
(
subBarcode
.
getPartNumber
().
equals
(
pn
))
{
subBarcode
.
setOut
(
false
);
subBarcode
.
updateExtraData
(
"needInNum"
,
detail
.
getInQty
()
+
""
);
log
.
info
(
"入库单"
+
orderNo
+
", Pn="
+
pn
+
",查找到库位号="
+
pos
.
getPosName
()
+
",料箱号="
+
boxBarcode
.
getBarcode
()
+
",格口号="
+
subBarcode
.
getBarcode
()
+
",需要入库数量="
+
detail
.
getInQty
());
}
}
boxBarcode
.
setOut
(
false
);
boxBarcode
.
setStatus
(
BARCODE_STATUS
.
IN_STORE
);
needOutPos
.
add
(
pos
);
}
else
{
Barcode
newPn
=
new
Barcode
();
newPn
.
setPn
(
pn
);
newPn
.
setAmount
(
0
);
newPn
.
setInitialAmount
(
0
);
newPn
.
setOut
(
false
);
newPn
.
updateExtraData
(
"needInNum"
,
detail
.
getInQty
()
+
""
);
//查找准备出库的料箱中是否有空格口
StoragePos
emptyPos
=
needOutPos
.
stream
()
.
filter
(
emptyP
->
(
emptyP
.
getBarcode
().
getSubCodeList
().
size
()
<
6
))
.
findFirst
()
.
orElse
(
null
);
Barcode
emptyBox
=
null
;
if
(
emptyPos
!=
null
)
{
//使用此格口
emptyBox
=
emptyPos
.
getBarcode
();
newPn
.
setBarcode
(
emptyBox
.
getBarcode
()
+
"-"
+
emptyBox
.
getSubCodeList
().
size
());
newPn
=
barcodeManager
.
saveBarcode
(
newPn
);
List
<
Barcode
>
subL
=
emptyBox
.
getSubCodeList
();
subL
.
add
(
newPn
);
emptyBox
.
setSubCodeList
(
subL
);
log
.
info
(
"入库单"
+
orderNo
+
", Pn="
+
pn
+
",使用料箱的空格口="
+
pos
.
getPosName
()
+
",料箱号="
+
emptyBox
.
getBarcode
()
+
",格口号="
+
newPn
.
getBarcode
()
+
",需要入库数量="
+
detail
.
getInQty
());
}
else
{
excludePosIds
=
taskService
.
excludePosIds
();
//寻找一个空格口
emptyPos
=
storagePosManager
.
findEmptyBoxToPutIn
(
storageIdList
,
pn
,
excludePosIds
,
dataCache
.
getCheckOutType
());
emptyBox
=
emptyPos
.
getBarcode
();
if
(
pos
!=
null
)
{
newPn
.
setBarcode
(
emptyBox
.
getBarcode
()
+
"-"
+
emptyBox
.
getSubCodeList
().
size
());
newPn
=
barcodeManager
.
saveBarcode
(
newPn
);
List
<
Barcode
>
subL
=
emptyBox
.
getSubCodeList
();
subL
.
add
(
newPn
);
emptyBox
.
setSubCodeList
(
subL
);
emptyBox
.
setOut
(
false
);
emptyBox
.
setStatus
(
BARCODE_STATUS
.
IN_STORE
);
needOutPos
.
add
(
pos
);
log
.
info
(
"入库单"
+
orderNo
+
", Pn="
+
pn
+
",查找到有空格口料箱="
+
pos
.
getPosName
()
+
",料箱号="
+
emptyBox
.
getBarcode
()
+
",格口号="
+
newPn
.
getBarcode
()
+
",需要入库数量="
+
detail
.
getInQty
());
}
else
{
log
.
info
(
"入库单"
+
orderNo
+
", Pn="
+
pn
+
",未找到可用的空料箱="
);
}
}
}
}
//开始生成出库任务
int
index
=
1
;
for
(
StoragePos
pos
:
needOutPos
)
{
Barcode
barcode
=
pos
.
getBarcode
();
log
.
info
(
"入库单"
+
orderNo
+
", 为库位="
+
pos
.
getPosName
()
+
",料箱="
+
barcode
.
getBarcode
()
+
"生成出库任务:"
+
index
);
barcodeManager
.
saveBarcode
(
barcode
);
storagePosManager
.
save
(
pos
);
Storage
storage
=
dataCache
.
getStorageById
(
pos
.
getStorageId
());
log
.
info
(
pos
.
getPosName
()
+
"出库,料箱号为:"
+
barcode
.
getBarcode
());
DataLog
task
=
new
DataLog
(
storage
,
barcode
,
pos
);
task
.
setSourceId
(
spareNo
.
getId
());
task
.
setSourceName
(
orderNo
);
task
.
setSubSourceId
(
barcode
.
getLockName
());
task
.
setSubSourceInfo
(
barcode
.
getLockName
());
task
.
setType
(
OP
.
CHECKOUT
);
task
.
setCreator
(
SecurityUtils
.
getCurrentUsername
());
task
.
setLoc
(
"s1"
);
task
.
setStatus
(
OP_STATUS
.
WAIT
.
name
());
try
{
taskService
.
addTaskToExecute
(
task
);
}
catch
(
Exception
e
)
{
e
.
getMessage
();
}
index
++;
}
spareNo
.
setSpareStatus
(
SpareNostatus
.
EXECUTING_STATUS
);
addToMap
(
spareNo
);
spareNoManager
.
save
(
spareNo
);
}
catch
(
Exception
exception
)
{
log
.
error
(
"执行ReturnInventoryNo 出错: "
+
exception
.
toString
());
}
return
""
;
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论