Commit 3a916784 zshaohui

1.虚拟仓操作 修改

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