Browse Source

生成箱记录时,item_no 直接写区间号:起始~结束

例如首行 箱数=1,就会写成 1~1
master
han\hanst 6 days ago
parent
commit
3104d55aef
  1. 82
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java

82
src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java

@ -291,7 +291,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
String customerName = ""; String customerName = "";
String readyDateStr = ""; String readyDateStr = "";
String shippingMethod = ""; String shippingMethod = "";
String destination = "";
// 获取发货通知单信息 (从第一行数据获取即可) // 获取发货通知单信息 (从第一行数据获取即可)
Row firstDataRow = sheet.getRow(1); Row firstDataRow = sheet.getRow(1);
if (firstDataRow != null) { if (firstDataRow != null) {
@ -299,6 +299,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
if (headerMap.containsKey("客户")) customerName = getMergedCellValue(sheet, 1, headerMap.get("客户")); if (headerMap.containsKey("客户")) customerName = getMergedCellValue(sheet, 1, headerMap.get("客户"));
if (headerMap.containsKey("可提货时间")) readyDateStr = getMergedCellValue(sheet, 1, headerMap.get("可提货时间")); if (headerMap.containsKey("可提货时间")) readyDateStr = getMergedCellValue(sheet, 1, headerMap.get("可提货时间"));
if (headerMap.containsKey("发运方式")) shippingMethod = getMergedCellValue(sheet, 1, headerMap.get("发运方式")); if (headerMap.containsKey("发运方式")) shippingMethod = getMergedCellValue(sheet, 1, headerMap.get("发运方式"));
if (headerMap.containsKey("目的地")) destination = getMergedCellValue(sheet, 1, headerMap.get("目的地"));
} }
if (cmcInvoice == null || cmcInvoice.isEmpty()) { if (cmcInvoice == null || cmcInvoice.isEmpty()) {
@ -315,7 +316,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
header.setBuNo(data.getBuNo()); header.setBuNo(data.getBuNo());
header.setDelNo(delNo); header.setDelNo(delNo);
header.setCmcInvoice(cmcInvoice); header.setCmcInvoice(cmcInvoice);
header.setDestination(destination);
// 如果有按发票号分别设置的客户信息则使用该信息否则使用全局信息 // 如果有按发票号分别设置的客户信息则使用该信息否则使用全局信息
String customerNameKey = "customerName_" + cmcInvoice; String customerNameKey = "customerName_" + cmcInvoice;
String localShipAddressKey = "localShipAddress_" + cmcInvoice; String localShipAddressKey = "localShipAddress_" + cmcInvoice;
@ -394,7 +395,8 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
int palletSeqNo = 1; int palletSeqNo = 1;
int currentPalletSeqNo = 1; int currentPalletSeqNo = 1;
int boxItemNo = 1;
int boxSeqNo = 1;
String currentBoxItemNo = "";
int palletDetailItemNo = 1; int palletDetailItemNo = 1;
Map<String, EcssCoDelBoxListData> boxListMap = new LinkedHashMap<>(); Map<String, EcssCoDelBoxListData> boxListMap = new LinkedHashMap<>();
@ -549,18 +551,30 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
if (netWeightStr != null && !netWeightStr.isEmpty()) { if (netWeightStr != null && !netWeightStr.isEmpty()) {
if (isFirstRowOfMergedRegion(sheet, r, headerMap.get("净重")) || !isMerged(sheet, r, headerMap.get("净重"))) { if (isFirstRowOfMergedRegion(sheet, r, headerMap.get("净重")) || !isMerged(sheet, r, headerMap.get("净重"))) {
int currentBoxCount = 1;
if (headerMap.containsKey("箱数")) {
BigDecimal boxQtyForNo = parseBigDecimal(getMergedCellValue(sheet, r, headerMap.get("箱数")));
if (boxQtyForNo != null && boxQtyForNo.compareTo(BigDecimal.ZERO) > 0) {
currentBoxCount = boxQtyForNo.setScale(0, RoundingMode.HALF_UP).intValue();
}
}
String boxNo = boxSeqNo + "~" + (boxSeqNo + currentBoxCount - 1);
EcssCoDelBoxListData boxList = new EcssCoDelBoxListData(); EcssCoDelBoxListData boxList = new EcssCoDelBoxListData();
boxList.setSite(site); boxList.setSite(site);
boxList.setBuNo(data.getBuNo()); boxList.setBuNo(data.getBuNo());
boxList.setDelNo(delNo); boxList.setDelNo(delNo);
boxList.setSeqNo(currentPalletSeqNo); boxList.setSeqNo(currentPalletSeqNo);
boxList.setItemNo(String.valueOf(boxItemNo++));
boxList.setItemNo(boxNo);
boxList.setNetWeight(parseBigDecimal(netWeightStr)); boxList.setNetWeight(parseBigDecimal(netWeightStr));
boxList.setGrossWeight(grossWeight); boxList.setGrossWeight(grossWeight);
boxList.setCreateBy(data.getUsername()); boxList.setCreateBy(data.getUsername());
boxList.setCreateDate(new Date()); boxList.setCreateDate(new Date());
boxList.setBoxQty(BigDecimal.ZERO); boxList.setBoxQty(BigDecimal.ZERO);
boxListMap.put(boxList.getItemNo(), boxList); boxListMap.put(boxList.getItemNo(), boxList);
currentBoxItemNo = boxNo;
boxSeqNo += currentBoxCount;
} }
} }
@ -570,7 +584,6 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
palletDetail.setBuNo(data.getBuNo()); palletDetail.setBuNo(data.getBuNo());
palletDetail.setDelNo(delNo); palletDetail.setDelNo(delNo);
// ecss_CoDelBoxList item_no ecss_CoDelPalletDetail seq_no // ecss_CoDelBoxList item_no ecss_CoDelPalletDetail seq_no
String currentBoxItemNo = String.valueOf(boxItemNo - 1);
palletDetail.setSeqNo(currentBoxItemNo); palletDetail.setSeqNo(currentBoxItemNo);
palletDetail.setItemNo(palletDetailItemNo++); palletDetail.setItemNo(palletDetailItemNo++);
if (headerMap.containsKey("ERP编码")) { if (headerMap.containsKey("ERP编码")) {
@ -1309,7 +1322,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
Collectors.toMap(EcssCoDelNotifyDetailData::getPartNo,e->e)); Collectors.toMap(EcssCoDelNotifyDetailData::getPartNo,e->e));
// 装箱明细 - 按发货通知单明细item_no分组用于获取每行的重量 // 装箱明细 - 按发货通知单明细item_no分组用于获取每行的重量
List<Map> palletDetailList = coDelMapper.exportCoDelPalletDetailGroupByItemNo(notifyHeader); List<Map> palletDetailList = coDelMapper.exportCoDelPalletDetailGroupByItemNo(notifyHeader);
Map<Object, Map> palletMap = palletDetailList.stream().collect(Collectors.toMap( o -> o.get("item_no"), o -> o));
//Map<Object, Map> palletMap = palletDetailList.stream().collect(Collectors.toMap( o -> o.get("item_no"), o -> o));
// 装箱数据 // 装箱数据
List<EcssCoDelPalletHeaderData> palletHeaderDataList = coDelMapper.searchEcssCoDelPalletHeaderData(notifyHeader);// 总托数 List<EcssCoDelPalletHeaderData> palletHeaderDataList = coDelMapper.searchEcssCoDelPalletHeaderData(notifyHeader);// 总托数
Integer totalPlt = palletHeaderDataList.stream() Integer totalPlt = palletHeaderDataList.stream()
@ -1335,8 +1348,8 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
eorder.put("row_num", i + 1); eorder.put("row_num", i + 1);
EcssCoDelNotifyDetailData nodifyData = notifyDetailMap.get(partNo); EcssCoDelNotifyDetailData nodifyData = notifyDetailMap.get(partNo);
// 根据item_no获取该明细行对应的装箱重量 // 根据item_no获取该明细行对应的装箱重量
Map pm = itemNo != null ? palletMap.get(itemNo) : null;
int totalQty = pm!=null && pm.get("total_qty")!=null?Integer.parseInt(pm.get("total_qty").toString()):0;
//Map pm = itemNo != null ? palletMap.get(itemNo) : null;
//int totalQty = pm!=null && pm.get("total_qty")!=null?Integer.parseInt(pm.get("total_qty").toString()):0;
String lossratio = ""; String lossratio = "";
if (nodifyData!=null && nodifyData.getLossratio()!=null && !StringUtils.isBlank(nodifyData.getLossratio())) { if (nodifyData!=null && nodifyData.getLossratio()!=null && !StringUtils.isBlank(nodifyData.getLossratio())) {
// 关务物料属性 // 关务物料属性
@ -1374,10 +1387,10 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
allPrice = allPrice.add( ((BigDecimal)eorder.get("ttl_amount"))); allPrice = allPrice.add( ((BigDecimal)eorder.get("ttl_amount")));
if (data.getShowWeight()!=null && data.getShowWeight()) { if (data.getShowWeight()!=null && data.getShowWeight()) {
// 根据发货通知单明细查找装箱明细获取重量和净重保留2位小数 // 根据发货通知单明细查找装箱明细获取重量和净重保留2位小数
eorder.put("grossWeight", pm != null && pm.get("gross_weight") != null ?
/* eorder.put("grossWeight", pm != null && pm.get("gross_weight") != null ?
new BigDecimal(pm.get("gross_weight").toString()).setScale(2, RoundingMode.HALF_UP) : ""); new BigDecimal(pm.get("gross_weight").toString()).setScale(2, RoundingMode.HALF_UP) : "");
eorder.put("netWeight", pm != null && pm.get("net_weight") != null ? eorder.put("netWeight", pm != null && pm.get("net_weight") != null ?
new BigDecimal(pm.get("net_weight").toString()).setScale(2, RoundingMode.HALF_UP) : "");
new BigDecimal(pm.get("net_weight").toString()).setScale(2, RoundingMode.HALF_UP) : "");*/
} }
} }
// RFID需要的 // RFID需要的
@ -1481,9 +1494,14 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
boxData.setSite(data.getSite()); boxData.setSite(data.getSite());
boxData.setBuNo(notifyHeader.getBuNo()); boxData.setBuNo(notifyHeader.getBuNo());
boxData.setDelNo(notifyHeader.getDelNo()); boxData.setDelNo(notifyHeader.getDelNo());
List<Map> allBoxDetailList = coDelMapper.selectPalletDetailList(boxData);
Map<String, List<Map>> boxDetailMap = allBoxDetailList == null ? new HashMap<>() :
allBoxDetailList.stream()
.filter(detail -> detail.get("seq_no") != null)
.collect(Collectors.groupingBy(detail -> detail.get("seq_no").toString()));
for (int m = 0; m < list.size(); m++) { for (int m = 0; m < list.size(); m++) {
boxData.setSeqNo(Integer.valueOf(list.get(m).get("item_no")!=null?list.get(m).get("item_no").toString():""));
List<Map> checkList = coDelMapper.selectPalletDetailList(boxData);
String boxNo = list.get(m).get("item_no") != null ? list.get(m).get("item_no").toString() : "";
List<Map> checkList = boxDetailMap.getOrDefault(boxNo, Collections.emptyList());
// 记录当前箱子对应的exportList起始索引 // 记录当前箱子对应的exportList起始索引
int boxStartIndex = exportList.size(); int boxStartIndex = exportList.size();
// 获取box的rolls // 获取box的rolls
@ -1838,25 +1856,21 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
queryParam.setSite(notifyHeader.getSite()); queryParam.setSite(notifyHeader.getSite());
queryParam.setBuNo(notifyHeader.getBuNo()); queryParam.setBuNo(notifyHeader.getBuNo());
queryParam.setDelNo(notifyHeader.getDelNo()); queryParam.setDelNo(notifyHeader.getDelNo());
List<Map> allDetailList = coDelMapper.selectPalletDetailList(queryParam);
if (allDetailList == null || allDetailList.isEmpty()) {
log.warn("装箱明细中未找到物料信息,发货单号: {}", notifyHeader.getDelNo());
return BigDecimal.ZERO;
}
Map<String, List<Map>> detailListByBoxNo = allDetailList.stream()
.filter(detail -> detail.get("seq_no") != null)
.collect(Collectors.groupingBy(detail -> detail.get("seq_no").toString()));
// 获取所有明细中的物料编号 // 获取所有明细中的物料编号
Set<String> allPns = new HashSet<>(); Set<String> allPns = new HashSet<>();
for (Map box : boxList) {
Object seqNoObj = box.get("item_no");
if (seqNoObj == null) {
continue;
}
queryParam.setSeqNo(Integer.valueOf(seqNoObj.toString()));
List<Map> detailList = coDelMapper.selectPalletDetailList(queryParam);
if (detailList != null && !detailList.isEmpty()) {
for (Map detail : detailList) {
String pn = (String) detail.get("pn");
if (pn != null) {
allPns.add(pn);
}
}
for (Map detail : allDetailList) {
String pn = (String) detail.get("pn");
if (pn != null) {
allPns.add(pn);
} }
} }
@ -1904,13 +1918,13 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
if (seqNoObj == null) { if (seqNoObj == null) {
continue; continue;
} }
String boxNo = seqNoObj.toString();
// 查询该箱子的明细获取主要物料取第一个物料 // 查询该箱子的明细获取主要物料取第一个物料
queryParam.setSeqNo(Integer.valueOf(seqNoObj.toString()));
List<Map> detailList = coDelMapper.selectPalletDetailList(queryParam);
List<Map> detailList = detailListByBoxNo.get(boxNo);
if (detailList == null || detailList.isEmpty()) { if (detailList == null || detailList.isEmpty()) {
log.warn("箱号 {} 没有装箱明细", seqNoObj);
log.warn("箱号 {} 没有装箱明细", boxNo);
continue; continue;
} }
@ -1924,14 +1938,14 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
// 获取包装信息 // 获取包装信息
String packageNo = partNoToPackageNoMap.get(mainPn); String packageNo = partNoToPackageNoMap.get(mainPn);
if (packageNo == null) { if (packageNo == null) {
log.warn("箱号 {} 的物料 {} 未维护packageNo", seqNoObj, mainPn);
log.warn("箱号 {} 的物料 {} 未维护packageNo", boxNo, mainPn);
continue; continue;
} }
EcssPackageData packageData = packageNoToDataMap.get(packageNo); EcssPackageData packageData = packageNoToDataMap.get(packageNo);
if (packageData == null || packageData.getLength() == null if (packageData == null || packageData.getLength() == null
|| packageData.getWidth() == null || packageData.getHeight() == null) { || packageData.getWidth() == null || packageData.getHeight() == null) {
log.warn("箱号 {} 的包装 {} 信息不完整", seqNoObj, packageNo);
log.warn("箱号 {} 的包装 {} 信息不完整", boxNo, packageNo);
continue; continue;
} }
@ -1955,7 +1969,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
processedBoxCount++; processedBoxCount++;
log.debug("箱号 {} 物料 {} 包装 {} 单箱体积 {} m³ 箱数 {} 小计 {} m³", log.debug("箱号 {} 物料 {} 包装 {} 单箱体积 {} m³ 箱数 {} 小计 {} m³",
seqNoObj, mainPn, packageNo,
boxNo, mainPn, packageNo,
singleBoxVolume.setScale(4, RoundingMode.HALF_UP), singleBoxVolume.setScale(4, RoundingMode.HALF_UP),
boxQty, boxQty,
boxTotalVolume.setScale(4, RoundingMode.HALF_UP)); boxTotalVolume.setScale(4, RoundingMode.HALF_UP));

Loading…
Cancel
Save