|
|
|
@ -84,22 +84,18 @@ public class LabelSplitMergeServiceImpl extends ServiceImpl<LabelSplitMergeMappe |
|
|
|
String operator = (String) params.get("operator"); |
|
|
|
|
|
|
|
Float originalQuantity = Float.parseFloat(params.get("originalQuantity").toString()); |
|
|
|
// 获取拆分张数,默认为1(兼容旧版本) |
|
|
|
Integer splitCount = params.get("splitCount") != null ? Integer.parseInt(params.get("splitCount").toString()) : 1; |
|
|
|
Float splitQuantity = Float.parseFloat(params.get("splitQuantity").toString()); |
|
|
|
Float remainingQuantity = originalQuantity - splitQuantity; |
|
|
|
// 总拆分数量 = 拆分张数 * 每张数量 |
|
|
|
Float totalSplitQuantity = splitCount * splitQuantity; |
|
|
|
Float remainingQuantity = originalQuantity - totalSplitQuantity; |
|
|
|
|
|
|
|
if (splitQuantity <= 0 || splitQuantity >= originalQuantity) { |
|
|
|
throw new RuntimeException("拆分数量必须大于0且小于原数量"); |
|
|
|
if (splitCount <= 0) { |
|
|
|
throw new RuntimeException("拆分张数必须大于0"); |
|
|
|
} |
|
|
|
|
|
|
|
// 1. 生成新的标签条码 |
|
|
|
TransNoControl transNoControl = transNoControlService.getTransNo(site, "LabelNo", buNo); |
|
|
|
if (transNoControl == null) { |
|
|
|
throw new RuntimeException("生成标签条码失败"); |
|
|
|
} |
|
|
|
String newLabelCode = transNoControl.getNewTransNo(); |
|
|
|
|
|
|
|
if (newLabelCode == null || newLabelCode.trim().isEmpty()) { |
|
|
|
throw new RuntimeException("生成新标签条码失败"); |
|
|
|
if (splitQuantity <= 0 || totalSplitQuantity >= originalQuantity) { |
|
|
|
throw new RuntimeException("拆分总数量必须大于0且小于原数量"); |
|
|
|
} |
|
|
|
|
|
|
|
// 2. 更新原标签的库存数量 |
|
|
|
@ -115,45 +111,61 @@ public class LabelSplitMergeServiceImpl extends ServiceImpl<LabelSplitMergeMappe |
|
|
|
throw new RuntimeException("更新原标签库存失败"); |
|
|
|
} |
|
|
|
|
|
|
|
// 3. 创建新标签的库存记录 |
|
|
|
Map<String, Object> insertParams = new HashMap<>(); |
|
|
|
insertParams.put("site", site); |
|
|
|
insertParams.put("buNo", buNo); |
|
|
|
insertParams.put("rollNo", newLabelCode); |
|
|
|
insertParams.put("parentRollNo", newLabelCode); |
|
|
|
insertParams.put("partNo", partNo); |
|
|
|
insertParams.put("labelTypeTb", params.get("labelTypeTb")); |
|
|
|
insertParams.put("labelType", params.get("labelType")); |
|
|
|
insertParams.put("warehouseId", warehouseId); |
|
|
|
insertParams.put("locationId", locationId); |
|
|
|
insertParams.put("batchNo", batchNo); |
|
|
|
insertParams.put("wdr", params.get("wdr")); |
|
|
|
insertParams.put("statusTb", params.get("statusTb")); |
|
|
|
insertParams.put("status", params.get("status")); |
|
|
|
insertParams.put("firstInDate", params.get("firstInDate")); |
|
|
|
insertParams.put("latestInDate", new Date()); |
|
|
|
insertParams.put("activeDate", new Date()); |
|
|
|
insertParams.put("inQty", splitQuantity); |
|
|
|
insertParams.put("outQty", 0.0f); |
|
|
|
insertParams.put("qtyOnHand", splitQuantity); |
|
|
|
insertParams.put("qtyReserved", 0.0f); |
|
|
|
insertParams.put("freezeFlag", params.get("freezeFlag")); |
|
|
|
insertParams.put("manufactureDate", params.get("manufactureDate")); |
|
|
|
insertParams.put("expiredDate", params.get("expiredDate")); |
|
|
|
insertParams.put("orderref0", "标签拆分入库"); |
|
|
|
insertParams.put("orderref1", params.get("orderref1")); |
|
|
|
insertParams.put("orderref2", params.get("orderref2")); |
|
|
|
insertParams.put("orderref3", params.get("orderref3")); |
|
|
|
|
|
|
|
int insertCount = labelSplitMergeMapper.insertInventoryStock(insertParams); |
|
|
|
if (insertCount == 0) { |
|
|
|
throw new RuntimeException("创建新标签库存失败"); |
|
|
|
} |
|
|
|
// 3. 循环创建多张新标签的库存记录 |
|
|
|
List<String> newLabelCodes = new ArrayList<>(); |
|
|
|
for (int i = 0; i < splitCount; i++) { |
|
|
|
// 生成新的标签条码 |
|
|
|
TransNoControl transNoControl = transNoControlService.getTransNo(site, "LabelNo", buNo); |
|
|
|
if (transNoControl == null) { |
|
|
|
throw new RuntimeException("生成标签条码失败"); |
|
|
|
} |
|
|
|
String newLabelCode = transNoControl.getNewTransNo(); |
|
|
|
|
|
|
|
// 5. 生成标签变动事务记录 |
|
|
|
generateSplitTransaction(site, buNo, warehouseId, originalLabelCode, newLabelCode, partNo, batchNo, splitQuantity, remainingQuantity, locationId); |
|
|
|
if (newLabelCode == null || newLabelCode.trim().isEmpty()) { |
|
|
|
throw new RuntimeException("生成新标签条码失败"); |
|
|
|
} |
|
|
|
newLabelCodes.add(newLabelCode); |
|
|
|
|
|
|
|
// 创建新标签的库存记录 |
|
|
|
Map<String, Object> insertParams = new HashMap<>(); |
|
|
|
insertParams.put("site", site); |
|
|
|
insertParams.put("buNo", buNo); |
|
|
|
insertParams.put("rollNo", newLabelCode); |
|
|
|
insertParams.put("parentRollNo", newLabelCode); |
|
|
|
insertParams.put("partNo", partNo); |
|
|
|
insertParams.put("labelTypeTb", params.get("labelTypeTb")); |
|
|
|
insertParams.put("labelType", params.get("labelType")); |
|
|
|
insertParams.put("warehouseId", warehouseId); |
|
|
|
insertParams.put("locationId", locationId); |
|
|
|
insertParams.put("batchNo", batchNo); |
|
|
|
insertParams.put("wdr", params.get("wdr")); |
|
|
|
insertParams.put("statusTb", params.get("statusTb")); |
|
|
|
insertParams.put("status", params.get("status")); |
|
|
|
insertParams.put("firstInDate", params.get("firstInDate")); |
|
|
|
insertParams.put("latestInDate", new Date()); |
|
|
|
insertParams.put("activeDate", new Date()); |
|
|
|
insertParams.put("inQty", splitQuantity); |
|
|
|
insertParams.put("outQty", 0.0f); |
|
|
|
insertParams.put("qtyOnHand", splitQuantity); |
|
|
|
insertParams.put("qtyReserved", 0.0f); |
|
|
|
insertParams.put("freezeFlag", params.get("freezeFlag")); |
|
|
|
insertParams.put("manufactureDate", params.get("manufactureDate")); |
|
|
|
insertParams.put("expiredDate", params.get("expiredDate")); |
|
|
|
insertParams.put("orderref0", "标签拆分入库"); |
|
|
|
insertParams.put("orderref1", params.get("orderref1")); |
|
|
|
insertParams.put("orderref2", params.get("orderref2")); |
|
|
|
insertParams.put("orderref3", params.get("orderref3")); |
|
|
|
|
|
|
|
int insertCount = labelSplitMergeMapper.insertInventoryStock(insertParams); |
|
|
|
if (insertCount == 0) { |
|
|
|
throw new RuntimeException("创建新标签库存失败"); |
|
|
|
} |
|
|
|
|
|
|
|
// 6. 获取打印参数列表(拆分需要打印两张标签:原标签和新标签) |
|
|
|
// 生成标签变动事务记录 |
|
|
|
generateSplitTransaction(site, buNo, warehouseId, originalLabelCode, newLabelCode, partNo, batchNo, splitQuantity, remainingQuantity, locationId); |
|
|
|
} |
|
|
|
|
|
|
|
// 6. 获取打印参数列表(拆分需要打印多张标签:原标签 + 所有新标签) |
|
|
|
List<Map<String, Object>> printList = new ArrayList<>(); |
|
|
|
try { |
|
|
|
// 原标签打印参数 |
|
|
|
@ -164,25 +176,30 @@ public class LabelSplitMergeServiceImpl extends ServiceImpl<LabelSplitMergeMappe |
|
|
|
printList.add(printData1); |
|
|
|
} |
|
|
|
|
|
|
|
// 新标签打印参数 |
|
|
|
Map<String, Object> printData2 = wmsPrintDao.callUspPartLabelTemplate( |
|
|
|
site, buNo, "*", "", "", "", partNo, "", newLabelCode |
|
|
|
); |
|
|
|
if (printData2 != null) { |
|
|
|
printList.add(printData2); |
|
|
|
// 所有新标签打印参数 |
|
|
|
for (String newLabelCode : newLabelCodes) { |
|
|
|
Map<String, Object> printData = wmsPrintDao.callUspPartLabelTemplate( |
|
|
|
site, buNo, "*", "", "", "", partNo, "", newLabelCode |
|
|
|
); |
|
|
|
if (printData != null) { |
|
|
|
printList.add(printData); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.warn("获取打印参数失败,不影响拆分操作", e); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
result.put("newLabelCode", newLabelCode); |
|
|
|
result.put("newLabelCode", newLabelCodes.isEmpty() ? "" : newLabelCodes.get(0)); // 兼容旧版本 |
|
|
|
result.put("newLabelCodes", newLabelCodes); // 新版本返回所有新标签 |
|
|
|
result.put("originalQuantity", originalQuantity); |
|
|
|
result.put("splitCount", splitCount); |
|
|
|
result.put("splitQuantity", splitQuantity); |
|
|
|
result.put("totalSplitQuantity", totalSplitQuantity); |
|
|
|
result.put("remainingQuantity", remainingQuantity); |
|
|
|
result.put("printList", printList); |
|
|
|
|
|
|
|
logger.info("标签拆分成功,原标签: {}, 新标签: {}, 拆分数量: {}", originalLabelCode, newLabelCode, splitQuantity); |
|
|
|
logger.info("标签拆分成功,原标签: {}, 新标签: {}, 拆分张数: {}, 每张数量: {}", originalLabelCode, newLabelCodes, splitCount, splitQuantity); |
|
|
|
return result; |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|