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,140 +86,127 @@ public class VirtualOperateController { ...@@ -85,140 +86,127 @@ 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);
}
subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setAmount(newCount);
barcodeManager.saveBarcode(subBarcode);
barcode = finishTask(barcode, OP.PUT_IN, subBarcode, subBarcode.getAmount());
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount());
return ResultBean.newOkResult("");
} }
@ApiOperation("物料从料盒中取出")
@PostMapping(value = "/reelFromBox") @ApiOperation("物料放入料盒中")
@PostMapping(value = "/reelToBox")
//@AnonymousAccess //@AnonymousAccess
public ResultBean reelFromBox(@RequestBody Map<String, String> paramMap) { public ResultBean reelToBox(@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 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); 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.PUT_IN;
} else {
throw new ValidateException("smfcore.materialBox.qtyError", "请输入正确的数量");
} }
CodeBean codeBean = codeResolve.resolveSingleCode(operageStr); if ("pn".equals(putInType)) {
if (!codeBean.isValid()) { 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}); throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{operageStr});
} }
//判断是否在此料箱中 String hostBarcodeId = subCode.getHostBarcodeId();
Barcode subBarcode = codeBean.getBarcode(); if (StringUtils.isNotEmpty(hostBarcodeId)) {
String hostBarcodeId = subBarcode.getHostBarcodeId(); if (!hostBarcodeId.equals(barcode.getId())) {
if (StringUtils.isEmpty(hostBarcodeId)) { throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{barcode.getBarcode()});
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 {
//在别的料盒中
Barcode hostBarcode = barcodeManager.get(subBarcode.getHostBarcodeId());
if (hostBarcode != null) {
throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.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(""); return ResultBean.newOkResult(barcodeMapper.toDto(barcode));
} }
@ApiOperation("按pn进行入库或者出库调用") @ApiOperation("物料从料盒中取出")
@PostMapping(value = "/sureOperate") @PostMapping(value = "/reelFromBox")
public ResultBean sureOperate(@RequestBody Map<String, String> paramMap) { //@AnonymousAccess
Barcode barcode = null; public ResultBean reelFromBox(@RequestBody Map<String, String> paramMap) {
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");//数量 String checkOutType = paramMap.get("checkOutType");
int opQty = Integer.valueOf(qtyStr); String amountStr = paramMap.get("amount");
Barcode barcode = barcodeManager.findByBarcode(code);
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);
//用+或-分割,如果最后几位是数量,按手动输入处理
String pnStr = operageStr;
int opType = OP.NON_OP; int opType = OP.NON_OP;
if (opQty < 0) { if (opQty < 0) {
opType = OP.CHECKOUT; opType = OP.CHECKOUT;
} else if (opQty > 0) {
opType = OP.PUT_IN;
} else { } else {
//请输入正确的数量 //请输入正确的数量
throw new ValidateException("smfcore.materialBox.qtyError", "请输入正确的数量"); throw new ValidateException("smfcore.materialBox.qtyError", "请输入正确的数量");
} }
Component component = autoGetComponent(pnStr, opQty); //判断是pn还是ri出
if ("pn".equals(checkOutType)) {
//查看该库位中是否有相同的物料,有的话,数量累加 //查看该库位中是否有相同的物料,有的话,数量累加
Barcode subBarcode = barcode.getSubCode(pnStr); Barcode subBarcode = barcode.getSubCode(operageStr);
if (subBarcode == null) {
if (opType == OP.PUT_IN) { throw new ValidateException("smfcore.materialBox.noReel", "料盒中未找到对应物料");
//入库
if (subBarcode != null) {
int oldAmount = subBarcode.getAmount();
subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setAmount(oldAmount + opQty);
subBarcode = barcodeManager.save(subBarcode);
finishTask(barcode, opType, subBarcode, opQty);
log.info(subBarcode.getPartNumber() + "入库到料盒[" + barcode.getBarcode() + "],物料数量:" + oldAmount + " + " + opQty + " = " + subBarcode.getAmount());
} else {
subBarcode = autoGetBarcode(barcode, component, pnStr, opQty);
barcode = finishTask(barcode, opType, subBarcode, opQty);
log.info(barcode.getPartNumber() + "入库到料盒[" + barcode.getBarcode() + "],物料数量:" + barcode.getAmount());
} }
} else {
//出库
if (subBarcode != null) {
int oldAmount = subBarcode.getAmount(); int oldAmount = subBarcode.getAmount();
if (oldAmount < opQty) { if (oldAmount < opQty) {
throw new ValidateException("smfcore.materialBox.quantityshort", "物料数量不足"); throw new ValidateException("smfcore.materialBox.quantityshort", "物料数量不足");
...@@ -227,22 +215,36 @@ public class VirtualOperateController { ...@@ -227,22 +215,36 @@ public class VirtualOperateController {
subBarcode.setHostBarcodeId(barcode.getId()); subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setAmount(newAmount); subBarcode.setAmount(newAmount);
subBarcode = barcodeManager.save(subBarcode); subBarcode = barcodeManager.save(subBarcode);
barcode = finishTask(barcode, opType, subBarcode, opQty); barcode = finishTask(barcode, opType, subBarcode, opQty);
log.info(subBarcode.getPartNumber() + "从料盒[" + barcode.getPosName() + "]出库,物料数量:" + oldAmount + " - " + opQty + " = " + newAmount); log.info(subBarcode.getPartNumber() + "从料盒[" + barcode.getPosName() + "]出库,物料数量:" + oldAmount + " - " + opQty + " = " + newAmount);
} else { } else if ("ri".equals(checkOutType)) {
//无库存 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", "料盒中未找到对应物料"); throw new ValidateException("smfcore.materialBox.noReel", "料盒中未找到对应物料");
} }
if (!hostBarcodeId.equals(barcode.getId())) {
Barcode hostBarcode = barcodeManager.get(hostBarcodeId);
if (hostBarcode != null) {
throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()});
} }
} catch (Exception e) {
log.error(e.toString());
throw new ValidateException("smfcore.error", "出错{0}", new String[]{e.toString()});
} }
return ResultBean.newOkResult(barcodeMapper.toDto(barcode)); int qty = subBarcode.getAmount() - opQty;
if (qty < 0) {
qty = 0;
}
//出库
subBarcode.setAmount(qty);
finishTask(barcode, OP.CHECKOUT, subBarcode, qty);
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]从料盒[" + barcode.getBarcode() + "]出库,数量:" + qty);
}
return ResultBean.newOkResult("");
} }
@ApiOperation("料箱/物料放到库位中") @ApiOperation("料箱/物料放到库位中")
@PostMapping(value = "/boxToPosName") @PostMapping(value = "/boxToPosName")
...@@ -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!