Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 14630e37
由
zshaohui
编写于
2024-07-15 10:46:40 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
单据转库 提交
1 个父辈
be9c4309
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
249 行增加
和
483 行删除
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/controller/manual/ManualTicketPutIn.java
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/controller/manual/ManualTicketTransferController.java
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/controller/manual/ManualTicketPutIn.java
deleted
100644 → 0
查看文件 @
be9c430
package
com
.
neotel
.
smfcore
.
custom
.
luxsan
.
factory_c
.
rawstor
.
controller
.
manual
;
import
com.google.common.collect.Maps
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.DateUtil
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.api.SmfApi
;
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.manager.IComponentManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.service.po.Component
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
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.order.LiteOrderCache
;
import
com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.core.order.service.po.LiteOrderItem
;
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.api.LuxsanApi
;
import
com.neotel.smfcore.custom.luxsan.api.bean.request.*
;
import
com.neotel.smfcore.custom.luxsan.api.bean.result.BrandQtyResult
;
import
com.neotel.smfcore.custom.luxsan.api.bean.result.FetchMoveTicketResult
;
import
com.neotel.smfcore.custom.luxsan.api.bean.result.NewLabelToCellResult
;
import
com.neotel.smfcore.custom.luxsan.api.bean.result.QueryGrStatusResult
;
import
com.neotel.smfcore.custom.luxsan.factory_c.common.util.CommonUtil
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.GrUdNum
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.FetchMoveTicketDto
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.QueryGrStatusDto
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.enums.TaskCurrentLoc
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BinCacheUtil
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BoxHandleUtil
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.GrUtil
;
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
java.util.*
;
@ApiOperation
(
"手动的单据入库"
)
@Slf4j
@RequestMapping
(
"/manualTicket"
)
@RestController
public
class
ManualTicketPutIn
{
@Autowired
private
CodeResolve
codeResolve
;
@Autowired
private
SmfApi
smfApi
;
@Autowired
private
IStoragePosManager
storagePosManager
;
@Autowired
private
IBarcodeManager
barcodeManager
;
@Autowired
private
TaskService
taskService
;
@Autowired
private
DataCache
dataCache
;
@Autowired
private
IComponentManager
componentManager
;
@Autowired
private
ILiteOrderItemManager
liteOrderItemManager
;
@Autowired
private
LiteOrderCache
liteOrderCache
;
public
static
final
String
CACHE_MANUAL_TICKET
=
"CACHE_MANUAL_TICKET"
;
@ApiOperation
(
"获取ticket列表"
)
@RequestMapping
(
"/ticketStatus"
)
//@AnonymousAccess
public
ResultBean
grStatus
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
//物料
String
ticketStr
=
paramMap
.
get
(
"ticketStr"
);
if
(
StringUtils
.
isEmpty
(
ticketStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"单据号"
});
}
ticketStr
=
ticketStr
.
toUpperCase
(
Locale
.
ROOT
);
List
<
FetchMoveTicketResult
>
ticketList
=
new
ArrayList
<>();
LiteOrder
order
=
liteOrderCache
.
getOrderSortItems
(
ticketStr
);
if
(
order
==
null
){
ticketList
=
LuxsanApi
.
fetchMoveTicket
(
new
FetchMoveTicketRequest
(
CommonUtil
.
plantCode
,
ticketStr
));
}
else
{
for
(
LiteOrderItem
orderItem
:
order
.
getOrderItems
())
{
FetchMoveTicketResult
result
=
new
FetchMoveTicketResult
();
result
.
setTICKET_ITEM
(
orderItem
.
getTicketItem
());
result
.
setMATERIAL_CODE
(
orderItem
.
getMaterialCode
());
result
.
setSRC_PLANT
(
orderItem
.
getSrcPlant
());
result
.
setDST_PLANT
(
orderItem
.
getDstPlant
());
result
.
setSRC_WAREHOUSE
(
orderItem
.
getSrcWarehouse
());
result
.
setDST_WAREHOUSE
(
orderItem
.
getDstWarehouse
());
result
.
setSRC_BATCH
(
orderItem
.
getSrcBatch
());
result
.
setDST_BATCH
(
orderItem
.
getDstBatch
());
result
.
setQTY
(
orderItem
.
getQty
());
result
.
setMOVE_TYPE
(
orderItem
.
getMoveType
());
ticketList
.
add
(
result
);
}
}
return
ResultBean
.
newOkResult
(
FetchMoveTicketDto
.
convertFetchMoveTicketDto
(
ticketList
));
}
@ApiOperation
(
"缓存绑定信息"
)
@RequestMapping
(
"/bindTicket"
)
//@AnonymousAccess
public
ResultBean
bindGrUdQty
(
@RequestBody
FetchMoveTicketDto
ticketDto
)
{
List
cache
=
dataCache
.
getCache
(
CACHE_MANUAL_TICKET
);
if
(
cache
==
null
)
{
cache
=
new
ArrayList
();
}
cache
.
add
(
ticketDto
);
return
ResultBean
.
newOkResult
(
ticketDto
);
}
@ApiOperation
(
"获取过账信息"
)
@RequestMapping
(
"/grUdNum"
)
//@AnonymousAccess
public
ResultBean
getGrUdNum
(
String
grCode
,
String
grItem
)
{
if
(
StringUtils
.
isEmpty
(
grCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"grCode"
});
}
if
(
StringUtils
.
isEmpty
(
grItem
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"grItem"
});
}
return
ResultBean
.
newOkResult
(
GrUtil
.
getGrUdQty
(
grCode
,
grItem
));
}
@ApiOperation
(
"获取料箱信息"
)
@RequestMapping
(
"/getBoxInfo"
)
//@AnonymousAccess
public
ResultBean
getBoxInfo
(
String
boxStr
){
if
(
StringUtils
.
isEmpty
(
boxStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"料箱信息"
});
}
boxStr
=
boxStr
.
toUpperCase
(
Locale
.
ROOT
);
//如果不是C07,C13,C15开头的 报错
if
(!
boxStr
.
startsWith
(
"C07"
)
&&
!
boxStr
.
startsWith
(
"C13"
)
&&
!
boxStr
.
startsWith
(
"C15"
))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
boxStr
+
"不是有效的料箱条码"
);
}
//如果不是以A/B结尾的,则提示
if
(!
boxStr
.
endsWith
(
"A"
)
&&
!
boxStr
.
endsWith
(
"B"
)){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
boxStr
+
"请输入完整的料箱条码"
);
}
Barcode
barcode
=
codeResolve
.
resolveCode
(
boxStr
);
if
(
barcode
!=
null
){
StoragePos
pos
=
storagePosManager
.
getByBarcode
(
barcode
.
getBarcode
());
if
(
pos
!=
null
){
barcode
=
pos
.
getBarcode
();
barcode
.
setStatus
(
BARCODE_STATUS
.
OUT_NORMAL
);
//设置成 不在库
barcodeManager
.
save
(
barcode
);
pos
.
setBarcode
(
barcode
);
storagePosManager
.
save
(
pos
);
}
}
return
ResultBean
.
newOkResult
(
BoxHandleUtil
.
getBoxInfo
(
boxStr
));
}
@ApiOperation
(
"料盘入到料格"
)
@RequestMapping
(
"/reelToBox"
)
//@AnonymousAccess
public
synchronized
ResultBean
reelToBox
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
binCode
=
paramMap
.
get
(
"binCode"
);
//料格信息
String
codeStr
=
paramMap
.
get
(
"codeStr"
);
//条码信息
String
udCode
=
paramMap
.
get
(
"udCode"
);
//条码信息
String
warhouseCode
=
paramMap
.
get
(
"warhouseCode"
);
//库别
String
boxStr
=
paramMap
.
get
(
"boxStr"
);
//料箱信息
log
.
info
(
"人工单据入库,料格信息为:"
+
binCode
+
"条码信息为:"
+
codeStr
);
if
(
StringUtils
.
isEmpty
(
binCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"料格信息"
});
}
if
(
StringUtils
.
isEmpty
(
codeStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"条码信息"
});
}
if
(
StringUtils
.
isEmpty
(
warhouseCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"库别"
});
}
if
(
StringUtils
.
isEmpty
(
boxStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"料箱信息"
});
}
codeStr
=
codeStr
.
toUpperCase
(
Locale
.
ROOT
);
binCode
=
binCode
.
toUpperCase
(
Locale
.
ROOT
);
boxStr
=
boxStr
.
toUpperCase
(
Locale
.
ROOT
);
Barcode
noDbBarcode
=
codeResolve
.
resolveCode
(
codeStr
);
if
(
noDbBarcode
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.error.barcode.noValidCode"
,
"条码无效"
);
}
int
w
=
7
;
int
h
=
8
;
Component
component
=
componentManager
.
findByPartNumberAndProvider
(
noDbBarcode
.
getPartNumber
(),
noDbBarcode
.
getProvider
());
if
(
component
==
null
)
{
BrandQtyResult
result
=
LuxsanApi
.
brandQtyUrl
(
new
BrandQtyRequest
(
noDbBarcode
.
getPartNumber
(),
noDbBarcode
.
getProvider
()));
if
(
result
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"未找到对应的尺寸信息"
);
}
w
=
result
.
getReel_size
();
if
(
w
==
7
)
{
h
=
8
;
}
else
if
(
w
==
13
)
{
h
=
24
;
}
else
if
(
w
==
15
)
{
h
=
32
;
}
}
else
{
w
=
component
.
getPlateSize
();
h
=
component
.
getHeight
();
}
//判断条码是否正常
Barcode
barcode
=
null
;
try
{
barcode
=
codeResolve
.
resolveOneValideBarcode
(
"="
+
w
+
"x"
+
h
+
"="
+
codeStr
);
}
catch
(
ValidateException
ve
)
{
return
ResultBean
.
newErrorResult
(-
1
,
ve
.
getMsgKey
(),
ve
.
getDefaultMsg
());
}
//判断是否存在料箱中
if
(
StringUtils
.
isNotEmpty
(
barcode
.
getPosName
()))
{
log
.
info
(
barcode
.
getBarcode
()
+
"已经存在料格"
+
barcode
.
getPosName
());
return
ResultBean
.
newErrorResult
(-
1
,
""
,
barcode
.
getBarcode
()
+
"已经存在料格"
+
barcode
.
getPosName
());
}
//找到box信息
Barcode
boxBarcode
=
null
;
StoragePos
inPos
=
null
;
try
{
boxBarcode
=
codeResolve
.
resolveOneValideBarcode
(
boxStr
);
inPos
=
storagePosManager
.
getByBarcode
(
boxBarcode
.
getBarcode
());
if
(
inPos
!=
null
){
boxBarcode
=
inPos
.
getBarcode
();
}
}
catch
(
ValidateException
ve
){
return
ResultBean
.
newErrorResult
(-
1
,
ve
.
getMsgKey
(),
"料箱条码不正确:"
+
boxStr
);
}
//判断料格条码和料箱是否匹配
if
(!
binCode
.
startsWith
(
boxBarcode
.
getBarcode
())){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"当前扫描的隔口"
+
binCode
+
"与料箱信息:"
+
boxStr
+
"不匹配"
);
}
//判断是否为禁用料
barcode
=
smfApi
.
canPutInAfterResolve
(
barcode
);
barcode
.
setWarehouseCode
(
warhouseCode
);
//判断隔口能否放入
if
(
boxBarcode
!=
null
){
String
canPutIn
=
BinCacheUtil
.
canMaterialPutInBin
(
barcode
,
boxBarcode
,
binCode
);
if
(
StringUtils
.
isEmpty
(
canPutIn
))
{
NewLabelToCellResult
cell
=
LuxsanApi
.
newLabelToCell
(
new
NewLabelToCellRequest
(
CommonUtil
.
plantCode
,
Arrays
.
asList
(
udCode
),
barcode
.
getAmount
(),
binCode
,
Arrays
.
asList
(
barcode
.
getFullCode
())));
// NewLabelToCellResult cell = LuxsanApi.ticketMove(new TicketMoveRequest(CommonUtil.plantCode, ));
//将GR日期设置为生产日期
Date
grDate
=
DateUtil
.
getNoTimeDate
(
cell
.
getGR_DATE
());
barcode
.
setProduceDate
(
grDate
);
barcode
.
setLabelId
(
cell
.
getLABEL_ID
());
barcode
.
setPosName
(
binCode
);
// barcode.setBarSource(grCode);
barcode
.
setWarehouseCode
(
warhouseCode
);
barcode
.
setSeq
(
BoxHandleUtil
.
getSeq
(
boxBarcode
,
binCode
)+
1
);
barcode
.
setPutInTime
(
System
.
currentTimeMillis
());
barcode
=
barcodeManager
.
save
(
barcode
);
generatePutInTask
(
barcode
,
boxBarcode
,
OP_STATUS
.
FINISHED
.
name
());
boxBarcode
.
updateSubCodes
(
barcode
);
boxBarcode
.
setAmount
(
boxBarcode
.
getAmount
()+
barcode
.
getAmount
());
barcodeManager
.
save
(
boxBarcode
);
if
(
inPos
!=
null
){
//流程异常时,为保证数据一致性, pos中的box barcode也需要更新
inPos
.
setBarcode
(
boxBarcode
);
storagePosManager
.
save
(
inPos
);
}
return
ResultBean
.
newOkResult
(
BoxHandleUtil
.
getBoxInfo
(
boxStr
));
}
else
{
log
.
info
(
barcode
.
getBarcode
()
+
"不可以放到料格:"
+
binCode
+
",原因为:"
+
canPutIn
);
return
ResultBean
.
newErrorResult
(-
1
,
""
,
barcode
.
getBarcode
()
+
"不可以放到料格:"
+
binCode
+
",原因为:"
+
canPutIn
);
}
}
return
ResultBean
.
newErrorResult
(-
1
,
""
,
barcode
.
getBarcode
()
+
"不可以放到料格:"
+
binCode
);
}
@ApiOperation
(
"完成装箱并入库"
)
@RequestMapping
(
"/boxToPos"
)
//@AnonymousAccess
public
synchronized
ResultBean
boxToPosNew
(
String
boxStr
,
String
posName
,
String
type
)
{
if
(
StringUtils
.
isEmpty
(
boxStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"料箱信息"
});
}
Barcode
boxBarcode
=
codeResolve
.
resolveOneValideBarcode
(
boxStr
);
if
(
boxBarcode
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.error.barcode.invalid"
,
"条码无效"
);
}
//1.清理要出库的数据
List
<
Barcode
>
newSubCodeList
=
new
ArrayList
<>();
List
<
Barcode
>
subCodeList
=
boxBarcode
.
getSubCodeList
();
if
(
subCodeList
!=
null
&&
!
subCodeList
.
isEmpty
()){
for
(
Barcode
barcode
:
subCodeList
)
{
if
(
barcode
.
isOut
()){
log
.
info
(
boxStr
+
"有需要出库的料盘:"
+
barcode
.
getBarcode
()+
"需要改成不出库"
);
String
orderItemId
=
barcode
.
getOrderItemId
();
barcode
.
setOdn
(
""
);
barcode
.
setOrderId
(
""
);
barcode
.
setOrderItemId
(
""
);
barcode
.
setOut
(
false
);
barcode
=
barcodeManager
.
save
(
barcode
);
generateTask
(
barcode
,
OP_STATUS
.
CANCEL
.
name
(),
barcode
.
getAmount
(),
OP
.
CHECKOUT
,
orderItemId
);
}
newSubCodeList
.
add
(
barcode
);
}
}
boxBarcode
.
setSubCodeList
(
newSubCodeList
);
boxBarcode
=
barcodeManager
.
save
(
boxBarcode
);
//1.判断是否有正在入库的任务
for
(
DataLog
dataLog
:
taskService
.
getAllTasks
())
{
if
(!
dataLog
.
isCancel
()
&&
!
dataLog
.
isFinished
()
&&
dataLog
.
getBarcode
().
equals
(
boxBarcode
.
getBarcode
()))
{
if
(
dataLog
.
isPutInTask
())
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
boxStr
+
"有正在执行的入库任务,请确认"
);
}
else
{
log
.
info
(
boxStr
+
"有正在执行的出库任务,服务器更改状态为完成"
);
if
(!
dataLog
.
isOutFromPos
()){
taskService
.
moveTaskToFinished
(
dataLog
);
BoxHandleUtil
.
outFromPos
(
dataLog
);
dataLog
.
setOutFromPos
(
true
);
}
dataLog
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
taskService
.
updateFinishedTask
(
dataLog
);
}
}
}
//如果是type为0时,入智能仓
if
(
"0"
.
equals
(
type
)){
StoragePos
pos
=
BoxHandleUtil
.
locOnePos
(
boxBarcode
);
if
(
pos
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
boxStr
+
"未找到可用库位"
);
}
pos
.
setBarcode
(
boxBarcode
);
storagePosManager
.
save
(
pos
);
log
.
info
(
boxStr
+
"入库到智能仓,分配的储位为:"
+
pos
.
getPosName
());
Storage
storage
=
dataCache
.
getStorageById
(
pos
.
getStorageId
());
DataLog
dataLog
=
taskService
.
addPutInTaskToExecute
(
storage
,
boxBarcode
,
pos
,
TaskCurrentLoc
.
Manual_DischargeHole
);
return
ResultBean
.
newOkResult
(
""
);
}
else
if
(
"1"
.
equals
(
type
)){
if
(
StringUtils
.
isEmpty
(
posName
)){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"库位不能为空"
);
}
//判断库位有没有正在执行的任务
for
(
DataLog
task
:
taskService
.
getAllTasks
())
{
if
(
posName
.
equals
(
task
.
getPosName
())){
if
(!
task
.
isCancel
()
&&
!
task
.
isFinished
()){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
posName
+
"当前库位有正在执行的任务,请确认"
);
}
}
}
StoragePos
pos
=
storagePosManager
.
getByPosName
(
posName
);
if
(
pos
==
null
){
return
ResultBean
.
newErrorResult
(-
1
,
""
,
boxStr
+
"对应的库位"
+
posName
+
"不存在"
);
}
Barcode
barcode
=
pos
.
getBarcode
();
if
(
barcode
!=
null
){
if
(!
barcode
.
getBarcode
().
equals
(
boxBarcode
.
getBarcode
()))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
posName
+
"已经存在料箱:"
+
barcode
.
getBarcode
());
}
}
//判断当前箱子是否在其他库位中
StoragePos
oldPos
=
storagePosManager
.
getByBarcode
(
boxBarcode
.
getBarcode
());
if
(
oldPos
!=
null
){
log
.
info
(
boxStr
+
"清空原来的储位:"
+
oldPos
.
getPosName
());
oldPos
.
setBarcode
(
null
);
oldPos
.
setUsed
(
false
);
storagePosManager
.
save
(
oldPos
);
}
pos
.
setBarcode
(
null
);
taskService
.
addTaskToFinished
(
pos
,
boxBarcode
,
"手动入库"
);
return
ResultBean
.
newOkResult
(
""
);
}
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"请选择手动入库"
);
}
private
void
generatePutInTask
(
Barcode
barcode
,
Barcode
boxBarcode
,
String
status
)
{
DataLog
dataLog
=
new
DataLog
();
dataLog
.
setPosId
(
boxBarcode
.
getId
());
dataLog
.
setPosName
(
barcode
.
getPosName
());
dataLog
.
setBarcode
(
barcode
.
getBarcode
());
dataLog
.
setW
(
barcode
.
getPlateSize
());
dataLog
.
setH
(
barcode
.
getHeight
());
dataLog
.
setPartNumber
(
barcode
.
getPartNumber
());
dataLog
.
setNum
(
barcode
.
getAmount
());
dataLog
.
setType
(
OP
.
PUT_IN
);
dataLog
.
setStatus
(
status
);
dataLog
.
setBatchInfo
(
barcode
.
getBatch
());
dataLog
.
setSourceName
(
barcode
.
getBarSource
());
dataLog
.
setWarehouseCode
(
barcode
.
getWarehouseCode
());
taskService
.
updateFinishedTask
(
dataLog
);
}
private
DataLog
generateTask
(
Barcode
barcode
,
String
opStatus
,
int
opQty
,
int
opType
,
String
orderItemId
)
{
//生成任务
DataLog
task
=
new
DataLog
();
task
.
setStatus
(
opStatus
);
task
.
setPartNumber
(
barcode
.
getPartNumber
());
task
.
setBarcode
(
barcode
.
getBarcode
());
task
.
setNum
(
opQty
);
task
.
setType
(
opType
);
task
.
setPosName
(
barcode
.
getPosName
());
task
.
setOperator
(
SecurityUtils
.
getCurrentUsername
());
task
.
setDateCode
(
barcode
.
getDateCode
());
task
.
setBatchInfo
(
barcode
.
getBatch
());
task
.
setProvider
(
barcode
.
getProvider
());
task
.
setProviderNumber
(
barcode
.
getProviderNumber
());
task
.
setKeeperCode
(
barcode
.
getKeeperCode
());
task
.
setSubSourceId
(
orderItemId
);
task
.
setWarehouseCode
(
barcode
.
getWarehouseCode
());
if
(
StringUtils
.
isNotBlank
(
orderItemId
))
{
LiteOrderItem
orderItem
=
liteOrderItemManager
.
get
(
orderItemId
);
if
(
orderItem
!=
null
)
{
task
.
setSourceName
(
orderItem
.
getOrderNo
());
task
.
setLine
(
orderItem
.
getLine
());
task
.
setMo
(
orderItem
.
getMo
());
task
.
setSide
(
orderItem
.
getSide
());
task
.
setPlantCode
(
orderItem
.
getPlantCode
());
task
.
setOrderNo
(
orderItem
.
getOrderNo
());
task
.
setManualUpload
(
orderItem
.
isManualUpload
());
}
}
taskService
.
updateFinishedTask
(
task
);
return
task
;
}
}
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/controller/manual/ManualTicketTransferController.java
0 → 100644
查看文件 @
14630e3
package
com
.
neotel
.
smfcore
.
custom
.
luxsan
.
factory_c
.
rawstor
.
controller
.
manual
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.DateUtil
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.api.SmfApi
;
import
com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager
;
import
com.neotel.smfcore.core.barcode.service.manager.IComponentManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.service.po.Component
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.device.enums.OP
;
import
com.neotel.smfcore.core.device.enums.OP_STATUS
;
import
com.neotel.smfcore.core.storage.service.manager.IStoragePosManager
;
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.api.LuxsanApi
;
import
com.neotel.smfcore.custom.luxsan.api.bean.request.BrandQtyRequest
;
import
com.neotel.smfcore.custom.luxsan.api.bean.request.NewLabelToCellRequest
;
import
com.neotel.smfcore.custom.luxsan.api.bean.request.TicketPickLabelList
;
import
com.neotel.smfcore.custom.luxsan.api.bean.request.TicketPickRequest
;
import
com.neotel.smfcore.custom.luxsan.api.bean.result.BrandQtyResult
;
import
com.neotel.smfcore.custom.luxsan.api.bean.result.NewLabelToCellResult
;
import
com.neotel.smfcore.custom.luxsan.factory_c.common.util.CommonUtil
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.TicketTransfer
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BinCacheUtil
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BoxHandleUtil
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.GrUtil
;
import
com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.MaterialUtil
;
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
java.util.*
;
@ApiOperation
(
"手动单据转库"
)
@Slf4j
@RequestMapping
(
"/manualTicketTransfer"
)
@RestController
public
class
ManualTicketTransferController
{
@Autowired
private
CodeResolve
codeResolve
;
@Autowired
private
IComponentManager
componentManager
;
@Autowired
private
IStoragePosManager
storagePosManager
;
@Autowired
private
SmfApi
smfApi
;
@Autowired
private
IBarcodeManager
barcodeManager
;
@Autowired
private
TaskService
taskService
;
@ApiOperation
(
"料盘入到隔口"
)
@RequestMapping
(
"/reelToBox"
)
//@AnonymousAccess
public
synchronized
ResultBean
reelToBox
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
String
ticketCode
=
paramMap
.
get
(
"ticketCode"
);
//单据号
String
ticketItem
=
paramMap
.
get
(
"ticketItem"
);
//单据行
String
binCode
=
paramMap
.
get
(
"binCode"
);
//料格信息
String
codeStr
=
paramMap
.
get
(
"codeStr"
);
//条码信息
String
boxStr
=
paramMap
.
get
(
"boxStr"
);
//料箱信息
String
dstWarehouse
=
paramMap
.
get
(
"dstWarehouse"
);
//目的库别
String
materialCode
=
paramMap
.
get
(
"materialCode"
);
//料号
log
.
info
(
"人工单据转库,料格信息为:"
+
binCode
+
",单据行:"
+
ticketCode
+
"单据号:"
+
ticketItem
+
"条码信息为:"
+
codeStr
+
"目的库别为:"
+
dstWarehouse
+
"料号为:"
+
materialCode
);
if
(
StringUtils
.
isEmpty
(
ticketCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"单据号"
});
}
if
(
StringUtils
.
isEmpty
(
ticketItem
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"单据行"
});
}
if
(
StringUtils
.
isEmpty
(
binCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"料格信息"
});
}
if
(
StringUtils
.
isEmpty
(
codeStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"条码信息"
});
}
if
(
StringUtils
.
isEmpty
(
boxStr
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"料箱信息"
});
}
if
(
StringUtils
.
isEmpty
(
dstWarehouse
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"目的库别"
});
}
if
(
StringUtils
.
isEmpty
(
materialCode
))
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"料号"
});
}
codeStr
=
codeStr
.
toUpperCase
(
Locale
.
ROOT
);
binCode
=
binCode
.
toUpperCase
(
Locale
.
ROOT
);
boxStr
=
boxStr
.
toUpperCase
(
Locale
.
ROOT
);
Barcode
noDbBarcode
=
codeResolve
.
resolveCode
(
codeStr
);
if
(
noDbBarcode
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.error.barcode.noValidCode"
,
"条码无效"
);
}
if
(!
materialCode
.
equals
(
noDbBarcode
.
getPartNumber
()))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
materialCode
+
"与料盘上的料号:"
+
noDbBarcode
.
getPartNumber
()
+
"不一致"
);
}
int
w
=
7
;
int
h
=
8
;
Component
component
=
componentManager
.
findByPartNumberAndProvider
(
noDbBarcode
.
getPartNumber
(),
noDbBarcode
.
getProvider
());
if
(
component
==
null
)
{
BrandQtyResult
result
=
LuxsanApi
.
brandQtyUrl
(
new
BrandQtyRequest
(
noDbBarcode
.
getPartNumber
(),
noDbBarcode
.
getProvider
()));
if
(
result
==
null
)
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"未维护对应的尺寸信息"
);
}
w
=
result
.
getReel_size
();
if
(
w
==
7
)
{
h
=
8
;
}
else
if
(
w
==
13
)
{
h
=
24
;
}
else
if
(
w
==
15
)
{
h
=
32
;
}
}
else
{
w
=
component
.
getPlateSize
();
h
=
component
.
getHeight
();
}
//判断条码是否正常
Barcode
barcode
=
null
;
try
{
barcode
=
codeResolve
.
resolveOneValideBarcode
(
"="
+
w
+
"x"
+
h
+
"="
+
codeStr
);
}
catch
(
ValidateException
ve
)
{
return
ResultBean
.
newErrorResult
(-
1
,
ve
.
getMsgKey
(),
ve
.
getDefaultMsg
());
}
//判断是否存在料箱中
if
(
StringUtils
.
isNotEmpty
(
barcode
.
getPosName
()))
{
log
.
info
(
barcode
.
getBarcode
()
+
"已经存在料格"
+
barcode
.
getPosName
());
return
ResultBean
.
newErrorResult
(-
1
,
""
,
barcode
.
getBarcode
()
+
"已经存在料格"
+
barcode
.
getPosName
());
}
//找到box信息
Barcode
boxBarcode
=
null
;
StoragePos
inPos
=
null
;
try
{
boxBarcode
=
codeResolve
.
resolveOneValideBarcode
(
boxStr
);
inPos
=
storagePosManager
.
getByBarcode
(
boxBarcode
.
getBarcode
());
if
(
inPos
!=
null
)
{
boxBarcode
=
inPos
.
getBarcode
();
}
}
catch
(
ValidateException
ve
)
{
return
ResultBean
.
newErrorResult
(-
1
,
ve
.
getMsgKey
(),
"料箱条码不正确:"
+
boxStr
);
}
//判断料格条码和料箱是否匹配
if
(!
binCode
.
startsWith
(
boxBarcode
.
getBarcode
()))
{
return
ResultBean
.
newErrorResult
(-
1
,
""
,
"当前扫描的隔口"
+
binCode
+
"与料箱信息:"
+
boxStr
+
"不匹配"
);
}
//判断是否为禁用料
barcode
=
smfApi
.
canPutInAfterResolve
(
barcode
);
barcode
.
setWarehouseCode
(
dstWarehouse
);
//判断隔口能否放入
if
(
boxBarcode
!=
null
)
{
String
canPutIn
=
BinCacheUtil
.
canMaterialPutInBin
(
barcode
,
boxBarcode
,
binCode
);
if
(
StringUtils
.
isEmpty
(
canPutIn
))
{
TicketPickRequest
request
=
new
TicketPickRequest
();
request
.
setPLANT_CODE
(
CommonUtil
.
plantCode
);
request
.
setTICKET_CODE
(
ticketCode
);
request
.
setTICKET_ITEM
(
ticketItem
);
request
.
setQTY
(
barcode
.
getAmount
());
request
.
setBIN_CODE
(
binCode
);
List
<
TicketPickLabelList
>
labelList
=
new
ArrayList
<>();
TicketPickLabelList
tickPick
=
new
TicketPickLabelList
();
tickPick
.
setREEL_LIST
(
Arrays
.
asList
(
barcode
.
getBarcode
()));
tickPick
.
setLABEL_ID
(
barcode
.
getLabelId
());
labelList
.
add
(
tickPick
);
request
.
setLABEL_LIST
(
labelList
);
LuxsanApi
.
ticketPick
(
request
);
barcode
.
setPosName
(
binCode
);
barcode
.
setWarehouseCode
(
dstWarehouse
);
barcode
.
setSeq
(
BoxHandleUtil
.
getSeq
(
boxBarcode
,
binCode
)
+
1
);
barcode
.
setPutInTime
(
System
.
currentTimeMillis
());
// 刷新缓存中gr已过帐数量, 如果超出数量则报错
int
amount
=
barcode
.
getAmount
();
barcode
=
barcodeManager
.
save
(
barcode
);
generatePutInTask
(
barcode
,
boxBarcode
,
OP_STATUS
.
FINISHED
.
name
());
boxBarcode
.
updateSubCodes
(
barcode
);
boxBarcode
.
setAmount
(
boxBarcode
.
getAmount
()
+
barcode
.
getAmount
());
barcodeManager
.
save
(
boxBarcode
);
if
(
inPos
!=
null
)
{
//流程异常时,为保证数据一致性, pos中的box barcode也需要更新
inPos
.
setBarcode
(
boxBarcode
);
storagePosManager
.
save
(
inPos
);
}
return
ResultBean
.
newOkResult
(
BoxHandleUtil
.
getBoxInfo
(
boxStr
));
}
else
{
log
.
info
(
barcode
.
getBarcode
()
+
"不可以放到料格:"
+
binCode
+
",原因为:"
+
canPutIn
);
return
ResultBean
.
newErrorResult
(-
1
,
""
,
barcode
.
getBarcode
()
+
"不可以放到料格:"
+
binCode
+
",原因为:"
+
canPutIn
);
}
}
return
ResultBean
.
newErrorResult
(-
1
,
""
,
barcode
.
getBarcode
()
+
"不可以放到料格:"
+
binCode
);
}
private
void
generatePutInTask
(
Barcode
barcode
,
Barcode
boxBarcode
,
String
status
)
{
DataLog
dataLog
=
new
DataLog
();
dataLog
.
setPosId
(
boxBarcode
.
getId
());
dataLog
.
setPosName
(
barcode
.
getPosName
());
dataLog
.
setBarcode
(
barcode
.
getBarcode
());
dataLog
.
setW
(
barcode
.
getPlateSize
());
dataLog
.
setH
(
barcode
.
getHeight
());
dataLog
.
setPartNumber
(
barcode
.
getPartNumber
());
dataLog
.
setNum
(
barcode
.
getAmount
());
dataLog
.
setType
(
OP
.
PUT_IN
);
dataLog
.
setStatus
(
status
);
dataLog
.
setBatchInfo
(
barcode
.
getBatch
());
dataLog
.
setSourceName
(
barcode
.
getBarSource
());
dataLog
.
setWarehouseCode
(
barcode
.
getWarehouseCode
());
taskService
.
updateFinishedTask
(
dataLog
);
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论