Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 39524d6c
由
LN
编写于
2022-01-10 08:51:10 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
料盒操作逻辑修改
1 个父辈
0a886ac1
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
251 行增加
和
66 行删除
src/main/java/com/neotel/smfcore/core/storage/rest/MaterialBoxController.java
src/main/java/com/neotel/smfcore/core/storage/rest/MaterialController.java
src/main/java/com/neotel/smfcore/core/storage/rest/MaterialBoxController.java
查看文件 @
39524d6
...
...
@@ -33,7 +33,7 @@ import java.util.*;
@Slf4j
@RestController
@RequiredArgsConstructor
@Api
(
tags
=
"物料管理
:
料盒操作"
)
@Api
(
tags
=
"物料管理
:
料盒操作"
)
@RequestMapping
(
"api/materialBox"
)
public
class
MaterialBoxController
{
...
...
@@ -179,9 +179,206 @@ public class MaterialBoxController {
@PostMapping
(
value
=
"/operatePos"
)
@PreAuthorize
(
"@el.check('materialBox')"
)
public
ResultBean
operatePos
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
try
{
String
code
=
paramMap
.
get
(
"barcode"
);
//料盒条码
String
operageStr
=
paramMap
.
get
(
"operatePN"
);
//操作信息
DataLog
currentTask
=
null
;
Barcode
barcode
=
barcodeManager
.
findByBarcode
(
code
);
if
(
barcode
==
null
)
{
throw
new
ValidateException
(
"smfcore.materialBox.invalid"
,
"未找到料盒信息{0}"
,
new
String
[]{
code
});
}
//1.查找元器件pn是否存在,存在时需要弹框输入数量
//2.pn不存在,解析条码 成功,作为RI处理
//解析不成功,当做PN自动生成
int
opQty
=
0
;
int
opType
=
OP
.
NON_OP
;
Component
component
=
componentManager
.
findOneByPN
(
operageStr
);
if
(
component
!=
null
)
{
return
ResultBean
.
newOkResult
(
operageStr
);
}
String
newCodeStr
=
"=1x1="
+
operageStr
;
CodeBean
codeBean
=
codeResolve
.
resolveSingleCode
(
newCodeStr
);
if
(
codeBean
.
isValid
())
{
Barcode
subBarcode
=
codeBean
.
getBarcode
();
StoragePos
pos
=
storagePosManager
.
getByBarcode
(
subBarcode
.
getBarcode
());
if
(
pos
!=
null
)
{
throw
new
ValidateException
(
"smfcore.materialBox.inPos"
,
"物料已在库位{0}中"
,
new
String
[]{
pos
.
getPosName
()});
}
if
(
subBarcode
.
getHostBarcodeId
()
==
null
)
{
//不存在,入库
opQty
=
OP
.
PUT_IN
;
int
newCount
=
subBarcode
.
getAmount
();
if
(
newCount
<=
0
)
{
newCount
=
1
;
}
subBarcode
.
setHostBarcodeId
(
barcode
.
getId
());
subBarcode
.
setAmount
(
newCount
);
barcodeManager
.
saveBarcode
(
subBarcode
);
finishTask
(
barcode
,
opQty
,
currentTask
,
subBarcode
,
subBarcode
.
getAmount
());
log
.
info
(
"条码"
+
subBarcode
.
getBarcode
()
+
"["
+
subBarcode
.
getPartNumber
()
+
"]入库到料盒["
+
barcode
.
getBarcode
()
+
"]数量:"
+
barcode
.
getAmount
());
}
else
if
(
subBarcode
.
getHostBarcodeId
().
equals
(
barcode
.
getId
()))
{
int
qty
=
subBarcode
.
getAmount
();
//出库
subBarcode
.
setAmount
(
0
);
opQty
=
OP
.
CHECKOUT
;
finishTask
(
barcode
,
opQty
,
currentTask
,
subBarcode
,
qty
);
log
.
info
(
"条码"
+
subBarcode
.
getBarcode
()
+
"["
+
subBarcode
.
getPartNumber
()
+
"]从料盒["
+
barcode
.
getBarcode
()
+
"]出库,数量:"
+
qty
);
}
else
{
//在别的料盒中
Barcode
hostBarcode
=
barcodeManager
.
get
(
subBarcode
.
getHostBarcodeId
());
if
(
hostBarcode
!=
null
)
{
throw
new
ValidateException
(
"smfcore.materialBox.inOtherBox"
,
"物料已在料盒{0}中"
,
new
String
[]{
hostBarcode
.
getBarcode
()});
}
}
return
ResultBean
.
newOkResult
(
""
);
}
else
{
// return ResultBean.newErrorResult(1, codeBean.getErrorCode(), codeBean.getError(), codeBean.getParams());
return
ResultBean
.
newOkResult
(
operageStr
);
}
// //用+或-分割,如果最后几位是数量,按手动输入处理
// String[] codeArray = operageStr.split(" -");
// String pnStr = "";
// int opQty = 0;
// int opType = OP.NON_OP;
// if(codeArray.length == 2){
// try{
// opQty = Integer.valueOf(codeArray[1].trim());
// pnStr = codeArray[0].trim();
// opType = OP .CHECKOUT;
// }catch (Exception e){
//
// }
// }
// if(opType == OP.NON_OP){
// codeArray = operageStr.split(" \\+");
// if(codeArray.length == 2){
// try{
// opQty = Integer.valueOf(codeArray[1].trim());
// pnStr = codeArray[0].trim();
// opType = OP.PUT_IN;
// }catch (Exception e){
//
// }
// }
// }
//
// if(opType != OP.NON_OP){
// //手动输入,按PN来处理
// //先查找是否有相同的PN,没有创建一个
// Component component = autoGetComponent(pnStr,opQty);
// //查看该库位中是否有相同的物料,有的话,数量累加
// Barcode subBarcode=barcode.getSubCode(pnStr);
//
// if(opType == OP.PUT_IN) {
// //入库
// if (subBarcode != null) {
// int oldAmount = subBarcode.getAmount();
//
// subBarcode.setHostBarcodeId(barcode.getId());
// subBarcode.setAmount(oldAmount + opQty);
// subBarcode = barcodeManager.save(subBarcode);
//
// finishTask(barcode, opType, currentTask, subBarcode, opQty);
// log.info(subBarcode.getPartNumber() + "入库到料盒[" + barcode.getBarcode() + "],物料数量:" + oldAmount + " + " + opQty + " = " + subBarcode.getAmount());
//
// } else {
// subBarcode=autoGetBarcode(barcode,component,pnStr,opQty);
// finishTask(barcode, opType, currentTask, subBarcode, opQty);
// log.info(barcode.getPartNumber() + "入库到料盒[" + barcode.getBarcode() + "],物料数量:" + barcode.getAmount());
// }
// }else {
// //出库
// if(subBarcode != null){
//
// int oldAmount = subBarcode.getAmount();
// if(oldAmount < opQty){
// throw new ValidateException("smfcore.materialBox.quantityshort","物料数量不足");
// }
// int newAmount = oldAmount - opQty;
//
// subBarcode.setHostBarcodeId(barcode.getId());
// subBarcode.setAmount(newAmount);
// subBarcode = barcodeManager.save(subBarcode);
//
// finishTask(barcode, opType, currentTask,subBarcode, opQty);
// log.info(subBarcode.getPartNumber() + "从料盒["+barcode.getPosName()+"]出库,物料数量:" + oldAmount + " - " + opQty + " = " + newAmount);
// }else{
// //无库存
// throw new ValidateException("smfcore.materialBox.noReel","料盒中未找到对应物料");
// }
// }
//
// }else {
//
// String newCodeStr = "=1x1=" + operageStr;
// CodeBean codeBean = codeResolve.resolveSingleCode(newCodeStr );
// if (codeBean.isValid()) {
// Barcode subBarcode = codeBean.getBarcode();
// StoragePos pos = storagePosManager.getByBarcode(subBarcode.getBarcode());
// if (pos != null) {
// throw new ValidateException("smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{pos.getPosName()});
// }
//
// if (subBarcode.getHostBarcodeId() == null) {
// //不存在,入库
// opQty = OP.PUT_IN;
// int newCount = subBarcode.getAmount() ;
// if(newCount<=0){
// newCount=1;
// }
// subBarcode.setHostBarcodeId(barcode.getId());
// subBarcode.setAmount(newCount);
// barcodeManager.saveBarcode(subBarcode);
// finishTask(barcode, opQty, currentTask, subBarcode, subBarcode.getAmount());
// log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount());
// }
// else if (subBarcode.getHostBarcodeId().equals(barcode.getId())) {
// int qty = subBarcode.getAmount();
// //出库
// subBarcode.setAmount(0);
// opQty = OP.CHECKOUT;
// finishTask(barcode, opQty, currentTask, subBarcode, qty);
// log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]从料盒[" + barcode.getBarcode() + "]出库,数量:" + qty);
//
// } else {
// //在别的料盒中
// Barcode hostBarcode = barcodeManager.get(subBarcode.getHostBarcodeId());
// if (hostBarcode != null) {
// throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()});
// }
// }
// } else {
// return ResultBean.newErrorResult(1, codeBean.getErrorCode(), codeBean.getError(), codeBean.getParams());
// }
// }
}
catch
(
Exception
e
)
{
// return "出入库操作出错:" + e.getMessage();
log
.
error
(
e
.
toString
());
throw
new
ValidateException
(
"smfcore.error"
,
"出错{0}"
,
new
String
[]{
e
.
toString
()});
}
// return ResultBean.newOkResult("");
}
@ApiOperation
(
"确认操作料盒的物料"
)
@PostMapping
(
value
=
"/sureOperate"
)
@PreAuthorize
(
"@el.check('materialBox')"
)
public
ResultBean
sureOperate
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
try
{
//1.查找元器件pn是否存在,存在时需要弹框输入数量
//2.pn不存在,解析条码 成功,作为RI处理
//解析不成功,当做PN自动生成
String
code
=
paramMap
.
get
(
"barcode"
);
//料盒条码
String
operageStr
=
paramMap
.
get
(
"operatePN"
);
//操作信息
String
qtyStr
=
paramMap
.
get
(
"qty"
);
//数量
int
opQty
=
Integer
.
valueOf
(
qtyStr
);
DataLog
currentTask
=
null
;
Barcode
barcode
=
barcodeManager
.
findByBarcode
(
code
);
if
(
barcode
==
null
){
...
...
@@ -190,32 +387,20 @@ public class MaterialBoxController {
//用+或-分割,如果最后几位是数量,按手动输入处理
String
[]
codeArray
=
operageStr
.
split
(
" -"
);
String
pnStr
=
""
;
int
opQty
=
0
;
String
pnStr
=
operageStr
;
int
opType
=
OP
.
NON_OP
;
if
(
codeArray
.
length
==
2
){
try
{
opQty
=
Integer
.
valueOf
(
codeArray
[
1
].
trim
());
pnStr
=
codeArray
[
0
].
trim
();
if
(
opQty
<
0
){
opType
=
OP
.
CHECKOUT
;
}
catch
(
Exception
e
){
}
}
else
if
(
opQty
>
0
){
opType
=
OP
.
PUT_IN
;
}
else
{
//请输入正确的数量
throw
new
ValidateException
(
"smfcore.materialBox.qtyError"
,
"请输入正确的数量"
);
}
if
(
opType
==
OP
.
NON_OP
){
codeArray
=
operageStr
.
split
(
" \\+"
);
if
(
codeArray
.
length
==
2
){
try
{
opQty
=
Integer
.
valueOf
(
codeArray
[
1
].
trim
());
pnStr
=
codeArray
[
0
].
trim
();
opType
=
OP
.
PUT_IN
;
}
catch
(
Exception
e
){
}
}
}
if
(
opType
!=
OP
.
NON_OP
){
//
if(opType != OP.NON_OP){
//手动输入,按PN来处理
//先查找是否有相同的PN,没有创建一个
Component
component
=
autoGetComponent
(
pnStr
,
opQty
);
...
...
@@ -261,49 +446,49 @@ public class MaterialBoxController {
}
}
}
else
{
String
newCodeStr
=
"=1x1="
+
operageStr
;
CodeBean
codeBean
=
codeResolve
.
resolveSingleCode
(
newCodeStr
);
if
(
codeBean
.
isValid
())
{
Barcode
subBarcode
=
codeBean
.
getBarcode
();
StoragePos
pos
=
storagePosManager
.
getByBarcode
(
subBarcode
.
getBarcode
());
if
(
pos
!=
null
)
{
throw
new
ValidateException
(
"smfcore.materialBox.inPos"
,
"物料已在库位{0}中"
,
new
String
[]{
pos
.
getPosName
()});
}
if
(
subBarcode
.
getHostBarcodeId
()
==
null
)
{
//不存在,入库
opQty
=
OP
.
PUT_IN
;
int
newCount
=
subBarcode
.
getAmount
()
;
if
(
newCount
<=
0
){
newCount
=
1
;
}
subBarcode
.
setHostBarcodeId
(
barcode
.
getId
());
subBarcode
.
setAmount
(
newCount
);
barcodeManager
.
saveBarcode
(
subBarcode
);
finishTask
(
barcode
,
opQty
,
currentTask
,
subBarcode
,
subBarcode
.
getAmount
());
log
.
info
(
"条码"
+
subBarcode
.
getBarcode
()
+
"["
+
subBarcode
.
getPartNumber
()
+
"]入库到料盒["
+
barcode
.
getBarcode
()
+
"]数量:"
+
barcode
.
getAmount
());
}
else
if
(
subBarcode
.
getHostBarcodeId
().
equals
(
barcode
.
getId
()))
{
int
qty
=
subBarcode
.
getAmount
();
//出库
subBarcode
.
setAmount
(
0
);
opQty
=
OP
.
CHECKOUT
;
finishTask
(
barcode
,
opQty
,
currentTask
,
subBarcode
,
qty
);
log
.
info
(
"条码"
+
subBarcode
.
getBarcode
()
+
"["
+
subBarcode
.
getPartNumber
()
+
"]从料盒["
+
barcode
.
getBarcode
()
+
"]出库,数量:"
+
qty
);
}
else
{
//在别的料盒中
Barcode
hostBarcode
=
barcodeManager
.
get
(
subBarcode
.
getHostBarcodeId
());
if
(
hostBarcode
!=
null
)
{
throw
new
ValidateException
(
"smfcore.materialBox.inOtherBox"
,
"物料已在料盒{0}中"
,
new
String
[]{
hostBarcode
.
getBarcode
()});
}
}
}
else
{
return
ResultBean
.
newErrorResult
(
1
,
codeBean
.
getErrorCode
(),
codeBean
.
getError
(),
codeBean
.
getParams
());
}
}
//
}else {
//
//
String newCodeStr = "=1x1=" + operageStr;
//
CodeBean codeBean = codeResolve.resolveSingleCode(newCodeStr );
//
if (codeBean.isValid()) {
//
Barcode subBarcode = codeBean.getBarcode();
//
StoragePos pos = storagePosManager.getByBarcode(subBarcode.getBarcode());
//
if (pos != null) {
//
throw new ValidateException("smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{pos.getPosName()});
//
}
//
//
if (subBarcode.getHostBarcodeId() == null) {
//
//不存在,入库
//
opQty = OP.PUT_IN;
//
int newCount = subBarcode.getAmount() ;
//
if(newCount<=0){
//
newCount=1;
//
}
//
subBarcode.setHostBarcodeId(barcode.getId());
//
subBarcode.setAmount(newCount);
//
barcodeManager.saveBarcode(subBarcode);
//
finishTask(barcode, opQty, currentTask, subBarcode, subBarcode.getAmount());
//
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount());
//
}
//
else if (subBarcode.getHostBarcodeId().equals(barcode.getId())) {
//
int qty = subBarcode.getAmount();
//
//出库
//
subBarcode.setAmount(0);
//
opQty = OP.CHECKOUT;
//
finishTask(barcode, opQty, currentTask, subBarcode, qty);
//
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]从料盒[" + barcode.getBarcode() + "]出库,数量:" + qty);
//
//
} else {
//
//在别的料盒中
//
Barcode hostBarcode = barcodeManager.get(subBarcode.getHostBarcodeId());
//
if (hostBarcode != null) {
//
throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()});
//
}
//
}
//
} else {
//
return ResultBean.newErrorResult(1, codeBean.getErrorCode(), codeBean.getError(), codeBean.getParams());
//
}
//
}
}
catch
(
Exception
e
){
// return "出入库操作出错:" + e.getMessage();
...
...
src/main/java/com/neotel/smfcore/core/storage/rest/MaterialController.java
查看文件 @
39524d6
...
...
@@ -46,7 +46,7 @@ import java.util.*;
@Slf4j
@RestController
@RequiredArgsConstructor
@Api
(
tags
=
"物料管理
:
策略出库"
)
@Api
(
tags
=
"物料管理
:
策略出库"
)
@RequestMapping
(
"api/material"
)
public
class
MaterialController
{
@Autowired
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论