新增成品卷的库存拆批和合批功能(增加SPECIFICATION参数)

This commit is contained in:
彭枝刚 2025-02-12 14:25:22 +08:00
parent 1717f300d3
commit 83b28a330d

View File

@ -26,10 +26,7 @@ import com.foreverwin.mom.wms.constant.Constant;
import com.foreverwin.mom.wms.dto.*;
import com.foreverwin.mom.wms.entity.*;
import com.foreverwin.mom.wms.mapper.ZWmsInventoryMapper;
import com.foreverwin.mom.wms.service.PickingService;
import com.foreverwin.mom.wms.service.WmsItemService;
import com.foreverwin.mom.wms.service.ZWmsInventoryLogService;
import com.foreverwin.mom.wms.service.ZWmsInventoryService;
import com.foreverwin.mom.wms.service.*;
import com.foreverwin.mom.wms.util.StringUtil;
import com.foreverwin.nlv.print.feign.RemotePrintService;
import lombok.RequiredArgsConstructor;
@ -43,6 +40,7 @@ import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLIntegrityConstraintViolationException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@ -72,6 +70,8 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
private final RemotePrintService remotePrintService;
private final WmsCustomFieldsService customFieldsService;
@Autowired
private TransactionTemplate transactionTemplate;
@ -1310,7 +1310,6 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
String storageBinBo = parentStorageBinBo;
for (int i = 0; i < newInventoryIdList.size(); i++) {
String inventoryId = newInventoryIdList.get(i);
JSONObject paramMap = new JSONObject();
Inventory inventory = new Inventory();
BeanUtils.copyProperties(parentInventory, inventory);
inventory.setHandle(Inventory.genHandle(site, inventoryId));
@ -1330,27 +1329,7 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
null, null, storageBinBo, null, null, null, inventory));
// 添加打印参数
paramMap.put("batchNumber", parentInventory.getBatchNo());
paramMap.put("LOT_DESC", itemObj.getItem());
paramMap.put("SPECIFICATION", ""); // TODO 待确定取值来源
paramMap.put("LOT_QTY", inventory.getQtyOnHand());
paramMap.put("INSPECTION_LEVEL", inventory.getQualityInspectionStatus());
paramMap.put("LOT_NO", inventory.getInventoryId());
paramMap.put("ITEM_DESC", itemObj.getDescription());
paramMap.put("ITEM", itemObj.getItem());
paramMap.put("DES", itemObj.getDescription());
paramMap.put("DATE", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
paramMap.put("BATCH", parentInventory.getBatchNo());
paramMap.put("QTY", inventory.getQtyOnHand());
paramMap.put("INV_ID", inventoryId);
paramMap.put("CODE", inventoryId);
paramMap.put("VENDOR_BATCH", inventory.getVendorBatchNo());
String proDate = inventory.getProductionDate() == null ? "" : inventory.getProductionDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
paramMap.put("PRO_DATE", proDate);
printData.add(paramMap);
printData = assemblePrintData(printData, parentInventory, inventory, itemObj);
}
saveBatch(newInventoryList);
inventoryLogService.saveBatch(newInventoryLogList);
@ -1369,6 +1348,8 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
inventoryLogService.saveLog(user, parentInventory.getInventoryId(), null, parentInventory.getStatus(), Constant.CHANGE_TYPE_CP_SPLIT,
parentStorageBinBo, parentInventory.getQtyOnHand(), parentIsEmpty ? null : parentStorageBinBo);
// 追加父批次的打印
printData = assemblePrintData(printData, parentInventory, parentInventory, itemObj);
// 执行打印,单独开个线程去跑
cpPrintInventoryData(printerName, printTemplate, printData);
//返回新库存ID
@ -1377,6 +1358,41 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
}
}
private List<JSONObject> assemblePrintData(List<JSONObject> printData, Inventory parentInventory, Inventory inventory, Item itemObj) {
JSONObject paramMap = new JSONObject();
// 添加打印参数
paramMap.put("batchNumber", parentInventory.getBatchNo());
paramMap.put("LOT_DESC", itemObj.getItem());
// 取自物料自定义字段 WIDTH/1000M*库存表长度M
String width = customFieldsService.getCustomFieldsValue(itemObj.getHandle(), "WIDTH");
String widthSrc = "";
if (StringUtil.notEmpty(width)) {
BigDecimal widthNum = new BigDecimal(width);
BigDecimal widthResult = widthNum.divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_UP);
widthSrc = widthResult.toString();
}
paramMap.put("SPECIFICATION", widthSrc + itemObj.getUnitOfMeasure() + "*" + inventory.getQtyOnHand() + itemObj.getUnitOfMeasure());
paramMap.put("LOT_QTY", inventory.getQtyOnHand());
paramMap.put("INSPECTION_LEVEL", inventory.getQualityInspectionStatus());
paramMap.put("LOT_NO", inventory.getInventoryId());
paramMap.put("ITEM_DESC", itemObj.getDescription());
paramMap.put("ITEM", itemObj.getItem());
paramMap.put("DES", itemObj.getDescription());
paramMap.put("DATE", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
paramMap.put("BATCH", parentInventory.getBatchNo());
paramMap.put("QTY", inventory.getQtyOnHand());
paramMap.put("INV_ID", inventory.getInventoryId());
paramMap.put("CODE", inventory.getInventoryId());
paramMap.put("VENDOR_BATCH", inventory.getVendorBatchNo());
String proDate = inventory.getProductionDate() == null ? "" : inventory.getProductionDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
paramMap.put("PRO_DATE", proDate);
printData.add(paramMap);
return printData;
}
@Override
@Transactional(rollbackFor = Exception.class)
public String cpMergeInventory(List<String> inventoryIdList, String printer, String printTemplate) {
@ -1445,28 +1461,9 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
// 添加打印参数
List<JSONObject> printData = new ArrayList<>();
JSONObject paramMap = new JSONObject();
paramMap.put("batchNumber", inventory.getBatchNo());
paramMap.put("LOT_DESC", itemObj.getItem());
paramMap.put("SPECIFICATION", ""); // TODO 待确定取值来源
paramMap.put("LOT_QTY", inventory.getQtyOnHand());
paramMap.put("INSPECTION_LEVEL", inventory.getQualityInspectionStatus());
paramMap.put("LOT_NO", inventory.getInventoryId());
paramMap.put("ITEM_DESC", itemObj.getDescription());
paramMap.put("ITEM", itemObj.getItem());
paramMap.put("DES", itemObj.getDescription());
paramMap.put("DATE", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
paramMap.put("BATCH", inventory.getBatchNo());
paramMap.put("QTY", inventory.getQtyOnHand());
paramMap.put("INV_ID", inventoryId);
paramMap.put("CODE", inventoryId);
paramMap.put("VENDOR_BATCH", inventory.getVendorBatchNo());
String proDate = inventory.getProductionDate() == null ? "" : inventory.getProductionDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
paramMap.put("PRO_DATE", proDate);
printData.add(paramMap);
// 添加打印参数
printData = assemblePrintData(printData, inventory, inventory, itemObj);
// 执行打印,单独开个线程去跑
cpPrintInventoryData(printer, printTemplate, printData);