Commit 742613d2 张少辉

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

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