Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit cfb57918
由
hc
编写于
2024-07-08 13:11:36 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
fix:gr手动入库过账数量计算逻辑优化
1 个父辈
95e1af92
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
46 行增加
和
12 行删除
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/controller/manual/ManualGrPutInController.java
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/util/GrUtil.java
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/controller/manual/ManualGrPutInController.java
查看文件 @
cfb5791
...
@@ -100,17 +100,22 @@ public class ManualGrPutInController {
...
@@ -100,17 +100,22 @@ public class ManualGrPutInController {
@ApiOperation
(
"缓存已过帐缓存信息"
)
@ApiOperation
(
"缓存已过帐缓存信息"
)
@RequestMapping
(
"/bindGrUdQty"
)
@RequestMapping
(
"/bindGrUdQty"
)
@AnonymousAccess
@AnonymousAccess
public
ResultBean
bindGrUdQty
(
@RequestBody
GrUdNum
grUdNum
)
throws
Exception
{
public
ResultBean
bindGrUdQty
(
@RequestBody
GrUdNum
grUdNum
)
{
GrUtil
.
updateGrUdQty
(
grUdNum
.
getCode
(),
grUdNum
.
getGrCode
(),
grUdNum
.
getGrItem
(),
grUdNum
.
getUdQty
(),
grUdNum
.
getLotQty
());
GrUtil
.
updateGrUdQty
(
grUdNum
.
getCode
(),
grUdNum
.
getGrCode
(),
grUdNum
.
getGrItem
(),
grUdNum
.
getUdQty
(),
grUdNum
.
getLotQty
());
return
ResultBean
.
newOkResult
(
GrUtil
.
getGrUdQty
(
grUdNum
.
getGrCode
(),
grUdNum
.
getGrItem
()));
return
ResultBean
.
newOkResult
(
GrUtil
.
getGrUdQty
(
grUdNum
.
getGrCode
(),
grUdNum
.
getGrItem
()));
}
}
@ApiOperation
(
"
缓存已过帐缓存
信息"
)
@ApiOperation
(
"
获取过账
信息"
)
@RequestMapping
(
"/grUdNum"
)
@RequestMapping
(
"/grUdNum"
)
@AnonymousAccess
@AnonymousAccess
public
ResultBean
getGrUdNum
(
String
grCode
,
String
grItem
)
throws
Exception
{
public
ResultBean
getGrUdNum
(
String
grCode
,
String
grItem
)
{
return
ResultBean
.
newOkResult
(
if
(
StringUtils
.
isEmpty
(
grCode
))
{
GrUtil
.
getGrUdQty
(
grCode
,
grItem
));
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
(
"获取料箱信息"
)
@ApiOperation
(
"获取料箱信息"
)
...
@@ -248,6 +253,9 @@ public class ManualGrPutInController {
...
@@ -248,6 +253,9 @@ public class ManualGrPutInController {
barcode
.
setBarSource
(
grCode
);
barcode
.
setBarSource
(
grCode
);
barcode
.
setSeq
(
BoxHandleUtil
.
getSeq
(
boxBarcode
,
binCode
)+
1
);
barcode
.
setSeq
(
BoxHandleUtil
.
getSeq
(
boxBarcode
,
binCode
)+
1
);
barcode
.
setPutInTime
(
System
.
currentTimeMillis
());
barcode
.
setPutInTime
(
System
.
currentTimeMillis
());
// 刷新缓存中gr已过帐数量, 如果超出数量则报错
int
amount
=
barcode
.
getAmount
();
GrUtil
.
addQty
(
grCode
,
grItem
,
amount
);
barcode
=
barcodeManager
.
save
(
barcode
);
barcode
=
barcodeManager
.
save
(
barcode
);
generatePutInTask
(
barcode
,
boxBarcode
,
OP_STATUS
.
FINISHED
.
name
());
generatePutInTask
(
barcode
,
boxBarcode
,
OP_STATUS
.
FINISHED
.
name
());
boxBarcode
.
updateSubCodes
(
barcode
);
boxBarcode
.
updateSubCodes
(
barcode
);
...
@@ -258,8 +266,6 @@ public class ManualGrPutInController {
...
@@ -258,8 +266,6 @@ public class ManualGrPutInController {
inPos
.
setBarcode
(
boxBarcode
);
inPos
.
setBarcode
(
boxBarcode
);
storagePosManager
.
save
(
inPos
);
storagePosManager
.
save
(
inPos
);
}
}
int
amount
=
barcode
.
getAmount
();
GrUtil
.
addQty
(
grCode
,
grItem
,
amount
);
return
ResultBean
.
newOkResult
(
BoxHandleUtil
.
getBoxInfo
(
boxStr
));
return
ResultBean
.
newOkResult
(
BoxHandleUtil
.
getBoxInfo
(
boxStr
));
}
else
{
}
else
{
log
.
info
(
barcode
.
getBarcode
()
+
"不可以放到料格:"
+
binCode
+
",原因为:"
+
canPutIn
);
log
.
info
(
barcode
.
getBarcode
()
+
"不可以放到料格:"
+
binCode
+
",原因为:"
+
canPutIn
);
...
...
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/rawstor/util/GrUtil.java
查看文件 @
cfb5791
...
@@ -2,6 +2,7 @@ package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util;
...
@@ -2,6 +2,7 @@ package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.device.util.DataCache
;
...
@@ -46,7 +47,13 @@ public class GrUtil {
...
@@ -46,7 +47,13 @@ public class GrUtil {
dataCache
.
updateCache
(
CACHE_GR_UDQTY
,
cacheMap
);
dataCache
.
updateCache
(
CACHE_GR_UDQTY
,
cacheMap
);
}
}
public
static
GrUdNum
getGrUdQty
(
String
grCode
,
String
grItem
)
throws
Exception
{
/**
* 获取对应gr信息,如果此时本地缓存当前gr过账完成,则刷新缓存
* @param grCode
* @param grItem
* @return
*/
public
static
GrUdNum
getGrUdQty
(
String
grCode
,
String
grItem
)
{
Map
<
String
,
GrUdNum
>
cacheMap
=
dataCache
.
getCache
(
CACHE_GR_UDQTY
);
Map
<
String
,
GrUdNum
>
cacheMap
=
dataCache
.
getCache
(
CACHE_GR_UDQTY
);
if
(
cacheMap
==
null
)
{
if
(
cacheMap
==
null
)
{
cacheMap
=
Maps
.
newConcurrentMap
();
cacheMap
=
Maps
.
newConcurrentMap
();
...
@@ -60,7 +67,7 @@ public class GrUtil {
...
@@ -60,7 +67,7 @@ public class GrUtil {
return
grUdNum
;
return
grUdNum
;
}
}
private
static
GrUdNum
refreshGrNumFromAPI
(
String
grCode
,
String
grItem
)
throws
Exception
{
private
static
GrUdNum
refreshGrNumFromAPI
(
String
grCode
,
String
grItem
)
{
Map
<
String
,
GrUdNum
>
cacheMap
=
dataCache
.
getCache
(
CACHE_GR_UDQTY
);
Map
<
String
,
GrUdNum
>
cacheMap
=
dataCache
.
getCache
(
CACHE_GR_UDQTY
);
if
(
cacheMap
==
null
)
{
if
(
cacheMap
==
null
)
{
cacheMap
=
Maps
.
newConcurrentMap
();
cacheMap
=
Maps
.
newConcurrentMap
();
...
@@ -70,7 +77,7 @@ public class GrUtil {
...
@@ -70,7 +77,7 @@ public class GrUtil {
//解析条码为barcode
//解析条码为barcode
Barcode
barcode
=
codeResolve
.
resolveCode
(
grUdNum
.
getCode
());
Barcode
barcode
=
codeResolve
.
resolveCode
(
grUdNum
.
getCode
());
if
(
barcode
==
null
)
{
if
(
barcode
==
null
)
{
throw
new
Exception
(
"条码无效"
);
throw
new
ValidateException
(
"smfcore.error.barcode.invalid"
,
"条码无效"
);
}
}
QueryGrStatusRequest
request
=
new
QueryGrStatusRequest
(
CommonUtil
.
plantCode
,
barcode
.
getProvider
(),
barcode
.
getPartNumber
(),
""
,
""
);
QueryGrStatusRequest
request
=
new
QueryGrStatusRequest
(
CommonUtil
.
plantCode
,
barcode
.
getProvider
(),
barcode
.
getPartNumber
(),
""
,
""
);
...
@@ -86,7 +93,7 @@ public class GrUtil {
...
@@ -86,7 +93,7 @@ public class GrUtil {
}
}
}
}
if
(
ObjectUtil
.
isNull
(
queryGrStatusDto
))
{
if
(
ObjectUtil
.
isNull
(
queryGrStatusDto
))
{
throw
new
Exception
(
String
.
format
(
"更新 [%s] GR过账信息缓存失败"
,
key
)
);
throw
new
ValidateException
(
"smfcore.error"
,
"更新GR过账信息缓存失败"
);
}
}
grUdNum
.
setLotQty
(
Double
.
valueOf
(
queryGrStatusDto
.
getLotQty
()).
intValue
());
grUdNum
.
setLotQty
(
Double
.
valueOf
(
queryGrStatusDto
.
getLotQty
()).
intValue
());
grUdNum
.
setUdQty
(
Double
.
valueOf
(
queryGrStatusDto
.
getUdQty
()).
intValue
());
grUdNum
.
setUdQty
(
Double
.
valueOf
(
queryGrStatusDto
.
getUdQty
()).
intValue
());
...
@@ -96,14 +103,35 @@ public class GrUtil {
...
@@ -96,14 +103,35 @@ public class GrUtil {
return
grUdNum
;
return
grUdNum
;
}
}
public
static
synchronized
void
addQty
(
String
grCode
,
String
grItem
,
int
count
)
{
public
static
void
addQty
(
String
grCode
,
String
grItem
,
int
count
)
{
Map
<
String
,
GrUdNum
>
cacheMap
=
dataCache
.
getCache
(
CACHE_GR_UDQTY
);
Map
<
String
,
GrUdNum
>
cacheMap
=
dataCache
.
getCache
(
CACHE_GR_UDQTY
);
if
(
cacheMap
==
null
)
{
if
(
cacheMap
==
null
)
{
cacheMap
=
Maps
.
newConcurrentMap
();
cacheMap
=
Maps
.
newConcurrentMap
();
}
}
String
key
=
grCode
+
"_"
+
grItem
;
String
key
=
grCode
+
"_"
+
grItem
;
GrUdNum
grUdNum
=
cacheMap
.
get
(
key
);
GrUdNum
grUdNum
=
cacheMap
.
get
(
key
);
synchronized
(
grUdNum
)
{
if
(
canPutIn
(
grCode
,
grItem
,
count
))
{
throw
new
ValidateException
(
"smfcore.error"
,
"正在过账的物料数量大于当前GR所需过账数量"
);
}
}
grUdNum
.
setUdQty
(
grUdNum
.
getUdQty
()+
count
);
grUdNum
.
setUdQty
(
grUdNum
.
getUdQty
()+
count
);
}
}
public
static
boolean
canPutIn
(
String
grCode
,
String
grItem
,
int
addCount
)
{
Map
<
String
,
GrUdNum
>
cacheMap
=
dataCache
.
getCache
(
CACHE_GR_UDQTY
);
if
(
cacheMap
==
null
)
{
cacheMap
=
Maps
.
newConcurrentMap
();
}
String
key
=
grCode
+
"_"
+
grItem
;
GrUdNum
grUdNum
=
cacheMap
.
get
(
key
);
synchronized
(
grUdNum
)
{
boolean
canPutIn
=
grUdNum
.
getUdQty
()
+
addCount
<=
grUdNum
.
getLotQty
();
if
(!
canPutIn
)
{
refreshGrNumFromAPI
(
grCode
,
grItem
);
}
return
grUdNum
.
getUdQty
()
+
addCount
<=
grUdNum
.
getLotQty
();
}
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论