Commit 3a916784 zshaohui

1.虚拟仓操作 修改

1 个父辈 f9bee9b3
...@@ -74,10 +74,11 @@ public class VirtualOperateController { ...@@ -74,10 +74,11 @@ public class VirtualOperateController {
@Autowired @Autowired
private TaskMapper taskMapper; private TaskMapper taskMapper;
@ApiOperation("物料放入料盒中")
@PostMapping(value = "/reelToBox") @ApiOperation("扫描条码返回具体的信息")
//@AnonymousAccess @RequestMapping("/scanReelPutIn")
public ResultBean reelToBox(@RequestBody Map<String, String> paramMap) { @AnonymousAccess
public ResultBean scanPutInReel(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("barcode");//料盒条码 String code = paramMap.get("barcode");//料盒条码
String operageStr = paramMap.get("operatePN");//操作信息 String operageStr = paramMap.get("operatePN");//操作信息
//判断条码是否存在 //判断条码是否存在
...@@ -85,42 +86,98 @@ public class VirtualOperateController { ...@@ -85,42 +86,98 @@ public class VirtualOperateController {
if (barcode == null) { if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code}); throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code});
} }
Map<String, Object> resultMap = new HashMap<>();
//判断是不是按料号进行入库 //判断是不是按料号进行入库
Component component = componentManager.findOneByPN(operageStr); Component component = componentManager.findOneByPN(operageStr);
if (component != null) { if (component != null) {
return ResultBean.newOkResult(operageStr); resultMap.put("type", "pn");
resultMap.put("partNumber", operageStr);
return ResultBean.newOkResult(resultMap);
} }
//解析物料信息 //解析物料信息
String newCodeStr = "=1x1=" + operageStr; String newCodeStr = "=1x1=" + operageStr;
CodeBean codeBean = codeResolve.resolveSingleCode(newCodeStr); CodeBean codeBean = codeResolve.resolveSingleCode(newCodeStr);
if (!codeBean.isValid()){ if (!codeBean.isValid()) {
return ResultBean.newOkResult(operageStr); resultMap.put("type", "pn");
resultMap.put("partNumber", operageStr);
return ResultBean.newOkResult(resultMap);
} }
//判断物料是否存在库位中 //判断是否存在其他料箱中
Barcode subBarcode = codeBean.getBarcode(); Barcode subCode = codeBean.getBarcode();
StoragePos pos = storagePosManager.getByBarcode(subBarcode.getBarcode()); String hostBarcodeId = subCode.getHostBarcodeId();
if (pos != null) { if (StringUtils.isNotEmpty(hostBarcodeId)) {
throw new ValidateException("smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{pos.getPosName()}); if (!hostBarcodeId.equals(barcode.getId())) {
} throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{barcode.getBarcode()});
String hostBarcodeId = subBarcode.getHostBarcodeId();
if (StringUtils.isNotEmpty(hostBarcodeId)){
Barcode hostBarcode = barcodeManager.get(hostBarcodeId);
if (hostBarcode != null){
throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()});
} }
} }
//设置数量 //如果是物料信息,返回ri
int newCount = subBarcode.getAmount(); resultMap.put("type", "ri");
if (newCount <= 0) { resultMap.put("amount", subCode.getAmount());
newCount = 1; return ResultBean.newOkResult(resultMap);
}
@ApiOperation("物料放入料盒中")
@PostMapping(value = "/reelToBox")
//@AnonymousAccess
public ResultBean reelToBox(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("barcode");//料盒条码
String operageStr = paramMap.get("operatePN");//操作信息
String putInType = paramMap.get("putInType"); //判断是ri还是pn入库
String reelType = paramMap.get("reelType");
String amountStr = paramMap.get("amount");
log.info("收到物料放入料箱,boxStr:" + code
+ ",operageStr:" + operageStr
+ ",putInType:" + putInType
+ ",reelType:" + reelType
+ ",amountStr=" + amountStr);
//判断料箱是否存在
Barcode barcode = barcodeManager.findByBarcode(code);
if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code});
} }
subBarcode.setHostBarcodeId(barcode.getId()); int opQty = Integer.valueOf(amountStr);
subBarcode.setAmount(newCount); int opType = OP.NON_OP;
barcodeManager.saveBarcode(subBarcode); if (opQty > 0) {
barcode = finishTask(barcode, OP.PUT_IN, subBarcode, subBarcode.getAmount()); opType = OP.PUT_IN;
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount()); } else {
return ResultBean.newOkResult(""); throw new ValidateException("smfcore.materialBox.qtyError", "请输入正确的数量");
}
if ("pn".equals(putInType)) {
Barcode subBarcode = barcode.getSubCode(operageStr);
if (subBarcode == null) {
Component component = autoGetComponent(operageStr, opQty);
subBarcode = autoGetBarcode(barcode, component, operageStr, opQty);
} else {
int oldAmount = subBarcode.getAmount();
subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setAmount(oldAmount + opQty);
}
subBarcode.setPutInTime(System.currentTimeMillis());
subBarcode = barcodeManager.save(subBarcode);
barcode = finishTask(barcode, opType, subBarcode, opQty);
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount());
} else if ("ri".equals(putInType)) {
//解析条码
Barcode subCode = codeResolve.resolveOneValideBarcode(operageStr);
if (subCode == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{operageStr});
}
String hostBarcodeId = subCode.getHostBarcodeId();
if (StringUtils.isNotEmpty(hostBarcodeId)) {
if (!hostBarcodeId.equals(barcode.getId())) {
throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{barcode.getBarcode()});
}
}
subCode.setHostBarcodeId(barcode.getId());
subCode.setAmount(opQty);
subCode.setPutInTime(System.currentTimeMillis());
barcodeManager.saveBarcode(subCode);
barcode = finishTask(barcode, opType, subCode, opQty);
log.info("条码" + subCode.getBarcode() + "[" + subCode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount());
}
return ResultBean.newOkResult(barcodeMapper.toDto(barcode));
} }
@ApiOperation("物料从料盒中取出") @ApiOperation("物料从料盒中取出")
...@@ -129,121 +186,66 @@ public class VirtualOperateController { ...@@ -129,121 +186,66 @@ public class VirtualOperateController {
public ResultBean reelFromBox(@RequestBody Map<String, String> paramMap) { public ResultBean reelFromBox(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("barcode");//料盒条码 String code = paramMap.get("barcode");//料盒条码
String operageStr = paramMap.get("operatePN");//操作信息 String operageStr = paramMap.get("operatePN");//操作信息
String checkOutType = paramMap.get("checkOutType");
String amountStr = paramMap.get("amount");
Barcode barcode = barcodeManager.findByBarcode(code); Barcode barcode = barcodeManager.findByBarcode(code);
if (barcode == null) { if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code}); throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code});
} }
//返回料盒信息 int opQty = Integer.valueOf(amountStr);
Component component = componentManager.findOneByPN(operageStr); int opType = OP.NON_OP;
if (component != null) { if (opQty < 0) {
return ResultBean.newOkResult(operageStr); opType = OP.CHECKOUT;
}
CodeBean codeBean = codeResolve.resolveSingleCode(operageStr);
if (!codeBean.isValid()) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{operageStr});
}
//判断是否在此料箱中
Barcode subBarcode = codeBean.getBarcode();
String hostBarcodeId = subBarcode.getHostBarcodeId();
if (StringUtils.isEmpty(hostBarcodeId)) {
throw new ValidateException("smfcore.materialBox.noReel", "料盒中未找到对应物料");
}
if (hostBarcodeId.equals(barcode.getId())) {
int qty = subBarcode.getAmount();
//出库
subBarcode.setAmount(0);
finishTask(barcode, OP.CHECKOUT, subBarcode, qty);
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]从料盒[" + barcode.getBarcode() + "]出库,数量:" + qty);
} else { } else {
//在别的料盒中 //请输入正确的数量
Barcode hostBarcode = barcodeManager.get(subBarcode.getHostBarcodeId()); throw new ValidateException("smfcore.materialBox.qtyError", "请输入正确的数量");
if (hostBarcode != null) {
throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()});
}
} }
return ResultBean.newOkResult(""); //判断是pn还是ri出
} if ("pn".equals(checkOutType)) {
//查看该库位中是否有相同的物料,有的话,数量累加
@ApiOperation("按pn进行入库或者出库调用") Barcode subBarcode = barcode.getSubCode(operageStr);
@PostMapping(value = "/sureOperate") if (subBarcode == null) {
public ResultBean sureOperate(@RequestBody Map<String, String> paramMap) { throw new ValidateException("smfcore.materialBox.noReel", "料盒中未找到对应物料");
Barcode barcode = null;
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);
barcode = barcodeManager.findByBarcode(code);
if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code});
} }
int oldAmount = subBarcode.getAmount();
//用+或-分割,如果最后几位是数量,按手动输入处理 if (oldAmount < opQty) {
String pnStr = operageStr; throw new ValidateException("smfcore.materialBox.quantityshort", "物料数量不足");
int opType = OP.NON_OP;
if (opQty < 0) {
opType = OP.CHECKOUT;
} else if (opQty > 0) {
opType = OP.PUT_IN;
} else {
//请输入正确的数量
throw new ValidateException("smfcore.materialBox.qtyError", "请输入正确的数量");
} }
Component component = autoGetComponent(pnStr, opQty); int newAmount = oldAmount - opQty;
//查看该库位中是否有相同的物料,有的话,数量累加 subBarcode.setHostBarcodeId(barcode.getId());
Barcode subBarcode = barcode.getSubCode(pnStr); subBarcode.setAmount(newAmount);
subBarcode = barcodeManager.save(subBarcode);
if (opType == OP.PUT_IN) { barcode = finishTask(barcode, opType, subBarcode, opQty);
//入库 log.info(subBarcode.getPartNumber() + "从料盒[" + barcode.getPosName() + "]出库,物料数量:" + oldAmount + " - " + opQty + " = " + newAmount);
if (subBarcode != null) { } else if ("ri".equals(checkOutType)) {
int oldAmount = subBarcode.getAmount(); CodeBean codeBean = codeResolve.resolveSingleCode(operageStr);
if (!codeBean.isValid()) {
subBarcode.setHostBarcodeId(barcode.getId()); throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{operageStr});
subBarcode.setAmount(oldAmount + opQty); }
subBarcode = barcodeManager.save(subBarcode); //判断是否在此料箱中
Barcode subBarcode = codeBean.getBarcode();
finishTask(barcode, opType, subBarcode, opQty); String hostBarcodeId = subBarcode.getHostBarcodeId();
log.info(subBarcode.getPartNumber() + "入库到料盒[" + barcode.getBarcode() + "],物料数量:" + oldAmount + " + " + opQty + " = " + subBarcode.getAmount()); if (StringUtils.isEmpty(hostBarcodeId)) {
throw new ValidateException("smfcore.materialBox.noReel", "料盒中未找到对应物料");
} else { }
subBarcode = autoGetBarcode(barcode, component, pnStr, opQty); if (!hostBarcodeId.equals(barcode.getId())) {
barcode = finishTask(barcode, opType, subBarcode, opQty); Barcode hostBarcode = barcodeManager.get(hostBarcodeId);
log.info(barcode.getPartNumber() + "入库到料盒[" + barcode.getBarcode() + "],物料数量:" + barcode.getAmount()); if (hostBarcode != null) {
} throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()});
} 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);
barcode = finishTask(barcode, opType, subBarcode, opQty);
log.info(subBarcode.getPartNumber() + "从料盒[" + barcode.getPosName() + "]出库,物料数量:" + oldAmount + " - " + opQty + " = " + newAmount);
} else {
//无库存
throw new ValidateException("smfcore.materialBox.noReel", "料盒中未找到对应物料");
} }
} }
} catch (Exception e) { int qty = subBarcode.getAmount() - opQty;
log.error(e.toString()); if (qty < 0) {
throw new ValidateException("smfcore.error", "出错{0}", new String[]{e.toString()}); qty = 0;
}
//出库
subBarcode.setAmount(qty);
finishTask(barcode, OP.CHECKOUT, subBarcode, qty);
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]从料盒[" + barcode.getBarcode() + "]出库,数量:" + qty);
} }
return ResultBean.newOkResult(barcodeMapper.toDto(barcode)); return ResultBean.newOkResult("");
} }
@ApiOperation("料箱/物料放到库位中") @ApiOperation("料箱/物料放到库位中")
@PostMapping(value = "/boxToPosName") @PostMapping(value = "/boxToPosName")
//@AnonymousAccess //@AnonymousAccess
...@@ -316,7 +318,7 @@ public class VirtualOperateController { ...@@ -316,7 +318,7 @@ public class VirtualOperateController {
Barcode barcode = barcodeManager.findByBarcode(code); Barcode barcode = barcodeManager.findByBarcode(code);
if (barcode == null) { if (barcode == null) {
throw new ValidateException("smfcore.materialBox.invalid", "未找到料盒信息{0}", new String[]{code}); throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code});
} }
Barcode subBarcode = barcode.getSubCode(subPN); Barcode subBarcode = barcode.getSubCode(subPN);
if (subBarcode == null) { if (subBarcode == null) {
......
...@@ -415,10 +415,10 @@ smfcore.language.displayLanName.de-DE=Deutsch ...@@ -415,10 +415,10 @@ smfcore.language.displayLanName.de-DE=Deutsch
smfcore.logMonitor=Log Monitoring smfcore.logMonitor=Log Monitoring
smfcore.materialTrace=Material Trace smfcore.materialTrace=Material Trace
smfcore.message.critical=Critical smfcore.message.critical=Critical
smfcore.pos.noVirtual=[{0}] is not a virtual warehouse location smfcore.pos.noVirtual=[{0}] is not a virtual storage location
smfcore.virtual.posNoBarcode=[{0}] is not in the storage location smfcore.virtual.posNoBarcode=[{0}] is not in the storage location
smfcore.virtual.barcodeNotExistVirtualPos=[{0}] Storage location [{1}] does not belong to the virtual warehouse location
smfcore.virtual=Virtual Warehouse
smfcore.virtualManager=Virtual Warehouse Management
smfcore.virtualLocationManager=Virtual Location Management
smfcore.virtualOperations=Virtual Warehouse Operations
\ No newline at end of file \ No newline at end of file
smfcore.virtual.barcodeNotExistVirtualPos=[{0}] Storage location [{1}] does not belong to the virtual storage location
smfcore.virtual=Virtual Storage
smfcore.virtualManager=Virtual Storage Mgmt
smfcore.virtualLocationManager=Virtual Location Mgmt
smfcore.virtualOperations=Virtual Storage Op
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!