Commit 39524d6c LN

料盒操作逻辑修改

1 个父辈 0a886ac1
...@@ -33,7 +33,7 @@ import java.util.*; ...@@ -33,7 +33,7 @@ import java.util.*;
@Slf4j @Slf4j
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@Api(tags = "物料管理:料盒操作") @Api(tags = "物料管理料盒操作")
@RequestMapping("api/materialBox") @RequestMapping("api/materialBox")
public class MaterialBoxController { public class MaterialBoxController {
...@@ -179,9 +179,206 @@ public class MaterialBoxController { ...@@ -179,9 +179,206 @@ public class MaterialBoxController {
@PostMapping(value = "/operatePos") @PostMapping(value = "/operatePos")
@PreAuthorize("@el.check('materialBox')") @PreAuthorize("@el.check('materialBox')")
public ResultBean operatePos(@RequestBody Map<String, String> paramMap) { 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{ try{
//1.查找元器件pn是否存在,存在时需要弹框输入数量
//2.pn不存在,解析条码 成功,作为RI处理
//解析不成功,当做PN自动生成
String code = paramMap.get("barcode");//料盒条码 String code = paramMap.get("barcode");//料盒条码
String operageStr = paramMap.get("operatePN");//操作信息 String operageStr = paramMap.get("operatePN");//操作信息
String qtyStr = paramMap.get("qty");//数量
int opQty = Integer.valueOf(qtyStr);
DataLog currentTask=null; DataLog currentTask=null;
Barcode barcode=barcodeManager.findByBarcode(code); Barcode barcode=barcodeManager.findByBarcode(code);
if(barcode==null){ if(barcode==null){
...@@ -190,32 +387,20 @@ public class MaterialBoxController { ...@@ -190,32 +387,20 @@ public class MaterialBoxController {
//用+或-分割,如果最后几位是数量,按手动输入处理 //用+或-分割,如果最后几位是数量,按手动输入处理
String[] codeArray = operageStr.split(" -"); String[] codeArray = operageStr.split(" -");
String pnStr = ""; String pnStr = operageStr;
int opQty = 0;
int opType = OP.NON_OP; int opType = OP.NON_OP;
if(codeArray.length == 2){ if(opQty<0){
try{
opQty = Integer.valueOf(codeArray[1].trim());
pnStr = codeArray[0].trim();
opType = OP .CHECKOUT; 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来处理
//先查找是否有相同的PN,没有创建一个 //先查找是否有相同的PN,没有创建一个
Component component = autoGetComponent(pnStr,opQty); Component component = autoGetComponent(pnStr,opQty);
...@@ -261,49 +446,49 @@ public class MaterialBoxController { ...@@ -261,49 +446,49 @@ public class MaterialBoxController {
} }
} }
}else { // }else {
//
String newCodeStr = "=1x1=" + operageStr; // String newCodeStr = "=1x1=" + operageStr;
CodeBean codeBean = codeResolve.resolveSingleCode(newCodeStr ); // CodeBean codeBean = codeResolve.resolveSingleCode(newCodeStr );
if (codeBean.isValid()) { // if (codeBean.isValid()) {
Barcode subBarcode = codeBean.getBarcode(); // Barcode subBarcode = codeBean.getBarcode();
StoragePos pos = storagePosManager.getByBarcode(subBarcode.getBarcode()); // StoragePos pos = storagePosManager.getByBarcode(subBarcode.getBarcode());
if (pos != null) { // if (pos != null) {
throw new ValidateException("smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{pos.getPosName()}); // throw new ValidateException("smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{pos.getPosName()});
} // }
//
if (subBarcode.getHostBarcodeId() == null) { // if (subBarcode.getHostBarcodeId() == null) {
//不存在,入库 // //不存在,入库
opQty = OP.PUT_IN; // opQty = OP.PUT_IN;
int newCount = subBarcode.getAmount() ; // int newCount = subBarcode.getAmount() ;
if(newCount<=0){ // if(newCount<=0){
newCount=1; // newCount=1;
} // }
subBarcode.setHostBarcodeId(barcode.getId()); // subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setAmount(newCount); // subBarcode.setAmount(newCount);
barcodeManager.saveBarcode(subBarcode); // barcodeManager.saveBarcode(subBarcode);
finishTask(barcode, opQty, currentTask, subBarcode, subBarcode.getAmount()); // finishTask(barcode, opQty, currentTask, subBarcode, subBarcode.getAmount());
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount()); // log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount());
} // }
else if (subBarcode.getHostBarcodeId().equals(barcode.getId())) { // else if (subBarcode.getHostBarcodeId().equals(barcode.getId())) {
int qty = subBarcode.getAmount(); // int qty = subBarcode.getAmount();
//出库 // //出库
subBarcode.setAmount(0); // subBarcode.setAmount(0);
opQty = OP.CHECKOUT; // opQty = OP.CHECKOUT;
finishTask(barcode, opQty, currentTask, subBarcode, qty); // finishTask(barcode, opQty, currentTask, subBarcode, qty);
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]从料盒[" + barcode.getBarcode() + "]出库,数量:" + qty); // log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]从料盒[" + barcode.getBarcode() + "]出库,数量:" + qty);
//
} else { // } else {
//在别的料盒中 // //在别的料盒中
Barcode hostBarcode = barcodeManager.get(subBarcode.getHostBarcodeId()); // Barcode hostBarcode = barcodeManager.get(subBarcode.getHostBarcodeId());
if (hostBarcode != null) { // if (hostBarcode != null) {
throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()}); // throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()});
} // }
} // }
} else { // } else {
return ResultBean.newErrorResult(1, codeBean.getErrorCode(), codeBean.getError(), codeBean.getParams()); // return ResultBean.newErrorResult(1, codeBean.getErrorCode(), codeBean.getError(), codeBean.getParams());
} // }
} // }
}catch (Exception e){ }catch (Exception e){
// return "出入库操作出错:" + e.getMessage(); // return "出入库操作出错:" + e.getMessage();
......
...@@ -46,7 +46,7 @@ import java.util.*; ...@@ -46,7 +46,7 @@ import java.util.*;
@Slf4j @Slf4j
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@Api(tags = "物料管理:策略出库") @Api(tags = "物料管理策略出库")
@RequestMapping("api/material") @RequestMapping("api/material")
public class MaterialController { public class MaterialController {
@Autowired @Autowired
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!