Commit 742613d2 张少辉

1.电子仓CTU出库功能优化

1 个父辈 07b3795c
...@@ -161,6 +161,8 @@ public class Barcode extends BasePo implements Serializable { ...@@ -161,6 +161,8 @@ public class Barcode extends BasePo implements Serializable {
private String lastStockOutNum; //上一次出库的数量 private String lastStockOutNum; //上一次出库的数量
private int needStockNum; private int needStockNum;
private String orderItemId;
/** /**
* 关联条码,夹具时关联相关的物料,用于入库完成时插入相关物料 * 关联条码,夹具时关联相关的物料,用于入库完成时插入相关物料
......
...@@ -1141,6 +1141,7 @@ public class LiteOrderCache { ...@@ -1141,6 +1141,7 @@ public class LiteOrderCache {
subCode.setStockoutNoLine(orderItem.getRowNumber()); subCode.setStockoutNoLine(orderItem.getRowNumber());
subCode.setLastStockOutNum(subCode.getAmount() + ""); subCode.setLastStockOutNum(subCode.getAmount() + "");
subCode.setNeedStockNum(needOutNum); subCode.setNeedStockNum(needOutNum);
subCode.setOrderItemId(orderItem.getId());
return subCode; return subCode;
} }
} }
...@@ -21,6 +21,8 @@ import com.neotel.smfcore.core.storage.service.po.Storage; ...@@ -21,6 +21,8 @@ import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.MomoApi;
import com.neotel.smfcore.custom.aiqingzhiyin1643.momo.bean.response.StockoutResponse;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -31,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -31,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -58,7 +61,7 @@ public class ScanOutBoxController { ...@@ -58,7 +61,7 @@ public class ScanOutBoxController {
private IStoragePosManager storagePosManager; private IStoragePosManager storagePosManager;
@Autowired @Autowired
private DataCache dataCache; private MomoApi momoApi;
@ApiOperation("查询料箱信息") @ApiOperation("查询料箱信息")
@RequestMapping("/boxInfo") @RequestMapping("/boxInfo")
...@@ -111,7 +114,9 @@ public class ScanOutBoxController { ...@@ -111,7 +114,9 @@ public class ScanOutBoxController {
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 needStockNumStr = paramMap.get("needStockNum");
int needStockNum = Integer.valueOf(needStockNumStr);
log.info("料盒条码:{},操作信息:{},需要数量:{}", code, operageStr, needStockNum);
//判断料箱是不是有效的参数 //判断料箱是不是有效的参数
Barcode barcode = barcodeManager.findByBarcode(code); Barcode barcode = barcodeManager.findByBarcode(code);
if (barcode == null) { if (barcode == null) {
...@@ -122,16 +127,12 @@ public class ScanOutBoxController { ...@@ -122,16 +127,12 @@ public class ScanOutBoxController {
if (pos != null) { if (pos != null) {
throw new ValidateException("smfcore.materialBox.inPos", "料箱[{0}]已在库位[{1}]中", new String[]{barcode.getBarcode(), pos.getPosName()}); throw new ValidateException("smfcore.materialBox.inPos", "料箱[{0}]已在库位[{1}]中", new String[]{barcode.getBarcode(), pos.getPosName()});
} }
//判断输入的条码是否正确 //判断输入的条码是否正确
CodeBean codeBean = codeResolve.resolveSingleCode("=1x1=" + operageStr); CodeBean codeBean = codeResolve.resolveSingleCode("=1x1=" + operageStr);
if (!codeBean.isValid()) { if (!codeBean.isValid()) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{operageStr}); throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{operageStr});
} }
Barcode subBarcode = codeBean.getBarcode(); Barcode subBarcode = codeBean.getBarcode();
int opQty = subBarcode.getAmount();
//判断是否在此料箱中 //判断是否在此料箱中
String hostBarcodeId = subBarcode.getHostBarcodeId(); String hostBarcodeId = subBarcode.getHostBarcodeId();
if (StringUtils.isEmpty(hostBarcodeId)) { if (StringUtils.isEmpty(hostBarcodeId)) {
...@@ -143,40 +144,57 @@ public class ScanOutBoxController { ...@@ -143,40 +144,57 @@ public class ScanOutBoxController {
throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()}); throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()});
} }
} }
int amount = subBarcode.getAmount(); if (needStockNum < subBarcode.getNeedStockNum()) {
int qty = amount - opQty; throw new ValidateException("smfcore.virtual.quantityError", "取出数量应为[{0}]", new String[]{subBarcode.getAmount() + ""});
if (qty < 0) {
qty = 0;
} }
Integer awaitingNum = subBarcode.getAppendData("awaiting");
if (awaitingNum != null) { String stockoutNo = subBarcode.getStockoutNo();
if (opQty < awaitingNum) { if (StringUtils.isEmpty(stockoutNo)){
throw new ValidateException("smfcore.virtual.quantityError", "取出数量应为[{0}]", new String[]{awaitingNum + ""}); throw new ValidateException("smfcore.materialBox.noStockoutNo", "不是要出库的物料,请确认");
} }
//通知momo出库
int subAmount = subBarcode.getAmount();
subBarcode.setAmount(0);
StockoutResponse stockoutResponse = momoApi.stockOut(subBarcode, needStockNum);
if (!stockoutResponse.getIsSuccess()) {
return ResultBean.newErrorResult(-1, "smfcore.momo.stockOutError", stockoutResponse.getErrorMessage(), new String[]{});
} }
//出库 //设置subBarcode的信息
subBarcode.setAmount(qty); subBarcode.setAmount(subAmount - needStockNum);
subBarcode.setNeedStockNum((subBarcode.getNeedStockNum() - needStockNum) < 0 ? 0 : (subBarcode.getNeedStockNum() - needStockNum));
subBarcode = barcodeManager.save(subBarcode); subBarcode = barcodeManager.save(subBarcode);
barcode = finishTask(barcode, OP.CHECKOUT, subBarcode, opQty, OP_STATUS.FINISHED.name(), amount);
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]从料盒[" + barcode.getBarcode() + "]出库,数量:" + qty); barcode = finishTask(barcode, OP.CHECKOUT, subBarcode, needStockNum, OP_STATUS.FINISHED.name());
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]从料盒[" + barcode.getBarcode() + "]出库,数量:" + needStockNumStr);
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
private Barcode finishTask(Barcode pidBarcode, int opType, Barcode subBarcode, int opQty, String status, int amount) throws ValidateException { private Barcode finishTask(Barcode pidBarcode, int opType, Barcode subBarcode, int opQty, String status) throws ValidateException {
String orderItemId = subBarcode.getAppendData("orderItemId"); String orderItemId = subBarcode.getOrderItemId();
String orderNo = subBarcode.getAppendData("orderNo"); String stockoutNo = subBarcode.getStockoutNo();
String orderId = subBarcode.getAppendData("orderId"); subBarcode.setReceiptOrder("");
subBarcode.updateAppendData("orderItemId", null); subBarcode.setRowNumber("");
subBarcode.updateAppendData("orderNo", null); subBarcode.setStockoutNo("");
subBarcode.updateAppendData("orderId", null); subBarcode.setOrderItemId("");
subBarcode.updateAppendData("awaiting", null);
barcodeManager.save(subBarcode);
//更新barcode缓存 //更新barcode缓存
pidBarcode.UpdateSubCode(subBarcode); pidBarcode.UpdateSubCode(subBarcode);
subBarcode.setHostBarcodeId(""); if (subBarcode.getAmount() == 0) {
subBarcode.setPosName(""); subBarcode.setHostBarcodeId("");
subBarcode.setAmount(amount); subBarcode.setPosName("");
}
//更新pidBarcode的数量信息
int amount = 0;
List<Barcode> subCodeList = pidBarcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()) {
for (Barcode subCode : subCodeList) {
amount += subCode.getAmount();
}
}
pidBarcode.setAmount(amount);
barcodeManager.save(subBarcode); barcodeManager.save(subBarcode);
barcodeManager.saveBarcode(pidBarcode); barcodeManager.saveBarcode(pidBarcode);
DataLog task = new DataLog(); DataLog task = new DataLog();
...@@ -189,15 +207,8 @@ public class ScanOutBoxController { ...@@ -189,15 +207,8 @@ public class ScanOutBoxController {
task.setStorageName(pidBarcode.getBarcode()); task.setStorageName(pidBarcode.getBarcode());
task.setPosName(pidBarcode.getBarcode()); task.setPosName(pidBarcode.getBarcode());
task.setOperator(SecurityUtils.getLoginUsername()); task.setOperator(SecurityUtils.getLoginUsername());
if (StringUtils.isNotEmpty(orderItemId)) { task.setSourceName(stockoutNo);
task.setSubSourceId(orderItemId); task.setSubSourceId(orderItemId);
}
if (StringUtils.isNotEmpty(orderNo)) {
task.setSourceName(orderNo);
}
if (StringUtils.isNotEmpty(orderId)) {
task.setSourceId(orderId);
}
taskService.updateFinishedTask(task); taskService.updateFinishedTask(task);
return pidBarcode; return pidBarcode;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!