|
@@ -18,6 +18,8 @@ import org.jeecg.modules.billet.rollClubThree.entity.RollClubThreeDetails;
|
|
|
import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeDetailsService;
|
|
|
import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwoDetails;
|
|
|
import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoDetailsService;
|
|
|
+import org.jeecg.modules.billet.rollDeputyCross.entity.RollDeputyCrossDetails;
|
|
|
+import org.jeecg.modules.billet.rollDeputyCross.service.IRollDeputyCrossDetailsService;
|
|
|
import org.jeecg.modules.billet.rollHeight.service.IRollHeightDetailsService;
|
|
|
import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShippDetails;
|
|
|
import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippDetailsService;
|
|
@@ -88,6 +90,9 @@ public class CarUnitServiceImpl extends ServiceImpl<CarUnitMapper, CarUnit> impl
|
|
|
@Autowired
|
|
|
private IRollOutShippDetailsService rollOutShippDetailsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IRollDeputyCrossDetailsService rollDeputyCrossDetailsService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IRollHeightDetailsService rollHeightDetailsService;
|
|
|
|
|
@@ -146,6 +151,14 @@ public class CarUnitServiceImpl extends ServiceImpl<CarUnitMapper, CarUnit> impl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 棒三 rollDeputyDetails
|
|
|
+ if (invoicing.getRollDeputyDetails() != null) {
|
|
|
+ for (StorageCenterHeatNoInvoicingVO.RollChargeDetail detail : invoicing.getRollDeputyDetails().getRollChargeDetails()) {
|
|
|
+ StorageCenterExportRow row = convert(detail, ccmNo, "付跨");
|
|
|
+ rows.add(row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 上若 rollOutShippDetails(如有)
|
|
|
if (invoicing.getRollOutShippDetails() != null) {
|
|
|
for (StorageCenterHeatNoInvoicingVO.RollChargeDetail detail : invoicing.getRollOutShippDetails().getRollChargeDetails()) {
|
|
@@ -1583,12 +1596,12 @@ public class CarUnitServiceImpl extends ServiceImpl<CarUnitMapper, CarUnit> impl
|
|
|
|
|
|
List<StorageBill> billList = storageBillMapper.selectList(billQueryWrapper);
|
|
|
|
|
|
- // 假设你已有以下数据结构
|
|
|
+ //构造数据
|
|
|
Map<String, StorageCenterHeatNoInvoicingVO.RollOneHeatNo> rollOneMap = buildRollOneHeatNoMap(oneList); // 根据棒一明细构建
|
|
|
Map<String, StorageCenterHeatNoInvoicingVO.RollTwoHeatNo> rollTwoMap = buildRollTwoHeatNoGroupByHeatNo(billList); // 根据棒二明细构建
|
|
|
Map<String, StorageCenterHeatNoInvoicingVO.RollThreeHeatNo> rollThreeMap = buildRollThreeHeatNoGroupByHeatNo(billList);
|
|
|
Map<String, StorageCenterHeatNoInvoicingVO.RollOutHeatNo> rollOutMap = buildRollOutHeatNoGroupByHeatNo(billList);
|
|
|
-
|
|
|
+ Map<String, StorageCenterHeatNoInvoicingVO.RollDeputyHeatNo> rollDeputyMap = buildRollDeputyHeatNoGroupByHeatNo(billList);
|
|
|
|
|
|
// 1. 按炉号聚合棒一和棒二数据到 StorageCenterHeatNoInvoicingVO
|
|
|
Map<String, StorageCenterHeatNoInvoicingVO> heatNoVOMap = new HashMap<>();
|
|
@@ -1617,6 +1630,13 @@ public class CarUnitServiceImpl extends ServiceImpl<CarUnitMapper, CarUnit> impl
|
|
|
|
|
|
}
|
|
|
|
|
|
+ for (String heatNo : rollDeputyMap.keySet()) {
|
|
|
+ StorageCenterHeatNoInvoicingVO vo = heatNoVOMap.computeIfAbsent(heatNo, k -> new StorageCenterHeatNoInvoicingVO());
|
|
|
+ StorageCenterHeatNoInvoicingVO.RollDeputyHeatNo rollDeputy = rollDeputyMap.get(heatNo);
|
|
|
+ vo.setRollDeputyDetails(rollDeputy);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// 2. 遍历所有炉号,构建最终返回列表
|
|
|
List<StorageCenterInvoicingVO> resultList = new ArrayList<>();
|
|
|
Set<String> allHeatNos = new HashSet<>();
|
|
@@ -1624,6 +1644,7 @@ public class CarUnitServiceImpl extends ServiceImpl<CarUnitMapper, CarUnit> impl
|
|
|
allHeatNos.addAll(rollTwoMap.keySet());
|
|
|
allHeatNos.addAll(rollThreeMap.keySet());
|
|
|
allHeatNos.addAll(rollOutMap.keySet());
|
|
|
+ allHeatNos.addAll(rollDeputyMap.keySet());
|
|
|
|
|
|
Map<String, StorageCenterInvoicingVO.HeatNoDetail> heatNoDetailMap = new HashMap<>();
|
|
|
|
|
@@ -1650,6 +1671,7 @@ public class CarUnitServiceImpl extends ServiceImpl<CarUnitMapper, CarUnit> impl
|
|
|
StorageCenterHeatNoInvoicingVO.RollTwoHeatNo rollTwo = null;
|
|
|
StorageCenterHeatNoInvoicingVO.RollThreeHeatNo rollThree = null;
|
|
|
StorageCenterHeatNoInvoicingVO.RollOutHeatNo rollOut = null;
|
|
|
+ StorageCenterHeatNoInvoicingVO.RollDeputyHeatNo rollDeputy = null;
|
|
|
|
|
|
StorageCenterHeatNoInvoicingVO vo = heatNoVOMap.get(heatNo);
|
|
|
if (vo != null) {
|
|
@@ -1657,6 +1679,7 @@ public class CarUnitServiceImpl extends ServiceImpl<CarUnitMapper, CarUnit> impl
|
|
|
rollTwo = vo.getRollClubTwoDetails();
|
|
|
rollThree = vo.getRollClubThreeDetails();
|
|
|
rollOut = vo.getRollOutShippDetails();
|
|
|
+ rollDeputy = vo.getRollDeputyDetails();
|
|
|
}
|
|
|
|
|
|
// 初始化累计值
|
|
@@ -1687,6 +1710,12 @@ public class CarUnitServiceImpl extends ServiceImpl<CarUnitMapper, CarUnit> impl
|
|
|
if (rollOut != null && rollOut.getTotalWeight() != null) {
|
|
|
totalWeight = totalWeight.add(rollOut.getTotalWeight());
|
|
|
}
|
|
|
+ if (rollDeputy != null && rollDeputy.getTotalAmount() != null) {
|
|
|
+ totalAmount += rollDeputy.getTotalAmount();
|
|
|
+ }
|
|
|
+ if (rollDeputy != null && rollDeputy.getTotalWeight() != null) {
|
|
|
+ totalWeight = totalWeight.add(rollDeputy.getTotalWeight());
|
|
|
+ }
|
|
|
|
|
|
StorageCenterInvoicingVO.HeatNoDetail detail = new StorageCenterInvoicingVO.HeatNoDetail();
|
|
|
detail.setHeatNo(heatNo);
|
|
@@ -1703,6 +1732,8 @@ public class CarUnitServiceImpl extends ServiceImpl<CarUnitMapper, CarUnit> impl
|
|
|
finalCreateTime = rollTwo.getRollChargeDetails().get(0).getCreateTime();
|
|
|
} else if (rollThree != null && rollThree.getRollChargeDetails() != null && rollThree.getRollChargeDetails().get(0).getCreateTime() != null) {
|
|
|
finalCreateTime = rollThree.getRollChargeDetails().get(0).getCreateTime();
|
|
|
+ } else if (rollDeputy != null && rollDeputy.getRollChargeDetails() != null && rollDeputy.getRollChargeDetails().get(0).getCreateTime() != null) {
|
|
|
+ finalCreateTime = rollDeputy.getRollChargeDetails().get(0).getCreateTime();
|
|
|
} else if (rollOut != null && rollOut.getRollChargeDetails() != null && rollOut.getRollChargeDetails().get(0).getCreateTime() != null) {
|
|
|
finalCreateTime = rollOut.getRollChargeDetails().get(0).getCreateTime();
|
|
|
} else {
|
|
@@ -1780,11 +1811,14 @@ public class CarUnitServiceImpl extends ServiceImpl<CarUnitMapper, CarUnit> impl
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
// 批量查询 billetBasicInfo,并按 billetNo 映射(保留创建时间最新的一条)
|
|
|
- List<BilletBasicInfo> billetBasicInfos = billetBasicInfoService.list(
|
|
|
- new LambdaQueryWrapper<BilletBasicInfo>()
|
|
|
- .in(BilletBasicInfo::getBilletNo, billetNoSet)
|
|
|
- .orderByDesc(BilletBasicInfo::getCreateTime)
|
|
|
- );
|
|
|
+ List<BilletBasicInfo> billetBasicInfos = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(billetNoSet)) {
|
|
|
+ billetBasicInfos = billetBasicInfoService.list(
|
|
|
+ new LambdaQueryWrapper<BilletBasicInfo>()
|
|
|
+ .in(BilletBasicInfo::getBilletNo, billetNoSet)
|
|
|
+ .orderByDesc(BilletBasicInfo::getCreateTime)
|
|
|
+ );
|
|
|
+ }
|
|
|
Map<String, BilletBasicInfo> billetInfoMap = billetBasicInfos.stream()
|
|
|
.filter(b -> b.getBilletNo() != null)
|
|
|
.collect(Collectors.toMap(
|
|
@@ -2316,6 +2350,151 @@ public class CarUnitServiceImpl extends ServiceImpl<CarUnitMapper, CarUnit> impl
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private Map<String, StorageCenterHeatNoInvoicingVO.RollDeputyHeatNo> buildRollDeputyHeatNoGroupByHeatNo(List<StorageBill> billList) {
|
|
|
+ Map<String, StorageCenterHeatNoInvoicingVO.RollDeputyHeatNo> resultMap = new HashMap<>();
|
|
|
+
|
|
|
+ // 提取所有有效 billId
|
|
|
+ Set<String> billIdSet = billList.stream()
|
|
|
+ .map(StorageBill::getId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(billIdSet)) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建 billId -> StorageBill 映射
|
|
|
+ Map<String, StorageBill> billMap = billList.stream()
|
|
|
+ .filter(b -> b.getId() != null)
|
|
|
+ .collect(Collectors.toMap(StorageBill::getId, Function.identity()));
|
|
|
+
|
|
|
+ // 查询所有明细
|
|
|
+ List<RollDeputyCrossDetails> detailList = rollDeputyCrossDetailsService.list(
|
|
|
+ new LambdaQueryWrapper<RollDeputyCrossDetails>()
|
|
|
+ .in(RollDeputyCrossDetails::getStorageBillId, billIdSet)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 按 heatNo -> storageBillId -> List 分组
|
|
|
+ Map<String, Map<String, List<RollDeputyCrossDetails>>> grouped = detailList.stream()
|
|
|
+ .filter(d -> d.getHeatNo() != null && d.getStorageBillId() != null)
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ RollDeputyCrossDetails::getHeatNo,
|
|
|
+ Collectors.groupingBy(RollDeputyCrossDetails::getStorageBillId)
|
|
|
+ ));
|
|
|
+
|
|
|
+ for (Map.Entry<String, Map<String, List<RollDeputyCrossDetails>>> heatNoEntry : grouped.entrySet()) {
|
|
|
+ String heatNo = heatNoEntry.getKey();
|
|
|
+ Map<String, List<RollDeputyCrossDetails>> billGroupMap = heatNoEntry.getValue();
|
|
|
+
|
|
|
+ StorageCenterHeatNoInvoicingVO.RollDeputyHeatNo rollDeputyHeatNo = resultMap.computeIfAbsent(heatNo, k -> {
|
|
|
+ StorageCenterHeatNoInvoicingVO.RollDeputyHeatNo r = new StorageCenterHeatNoInvoicingVO.RollDeputyHeatNo();
|
|
|
+ r.setSizeDetails(new ArrayList<>());
|
|
|
+ r.setRollChargeDetails(new ArrayList<>());
|
|
|
+ return r;
|
|
|
+ });
|
|
|
+
|
|
|
+ for (Map.Entry<String, List<RollDeputyCrossDetails>> billEntry : billGroupMap.entrySet()) {
|
|
|
+ String billId = billEntry.getKey();
|
|
|
+ List<RollDeputyCrossDetails> heatNoList = billEntry.getValue();
|
|
|
+
|
|
|
+ StorageBill bill = billMap.get(billId);
|
|
|
+ if (bill == null) continue;
|
|
|
+
|
|
|
+ // 计算重量(仅根据明细的 blankOutput)
|
|
|
+ BigDecimal heatWeight = heatNoList.stream()
|
|
|
+ .map(RollDeputyCrossDetails::getBlankOutput)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(BigDecimal::valueOf)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ // 获取 billetNo 列表(不去重)
|
|
|
+ List<String> billetNoList = heatNoList.stream()
|
|
|
+ .map(RollDeputyCrossDetails::getBilletNo)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .flatMap(s -> Arrays.stream(s.split(",")))
|
|
|
+ .map(String::trim)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (billetNoList.isEmpty()) continue;
|
|
|
+
|
|
|
+ // 累加总支数与重量
|
|
|
+ rollDeputyHeatNo.setTotalAmount(
|
|
|
+ Optional.ofNullable(rollDeputyHeatNo.getTotalAmount()).orElse(0) + billetNoList.size()
|
|
|
+ );
|
|
|
+ rollDeputyHeatNo.setTotalWeight(
|
|
|
+ Optional.ofNullable(rollDeputyHeatNo.getTotalWeight()).orElse(BigDecimal.ZERO).add(heatWeight)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 统计 billetNo 出现次数
|
|
|
+ Map<String, Long> billetNoCountMap = billetNoList.stream()
|
|
|
+ .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
|
|
+
|
|
|
+ // 查询基础信息(去重查询)
|
|
|
+ List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(
|
|
|
+ new LambdaQueryWrapper<BilletBasicInfo>()
|
|
|
+ .eq(BilletBasicInfo::getHeatNo, heatNo)
|
|
|
+ .in(BilletBasicInfo::getBilletNo, billetNoCountMap.keySet())
|
|
|
+ );
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(billetBasicInfoList)) continue;
|
|
|
+
|
|
|
+ // 扩展 billetBasicInfo 按照 billetNo 出现次数
|
|
|
+ List<BilletBasicInfo> expandedList = new ArrayList<>();
|
|
|
+ for (BilletBasicInfo info : billetBasicInfoList) {
|
|
|
+ long count = billetNoCountMap.getOrDefault(info.getBilletNo(), 1L);
|
|
|
+ for (int i = 0; i < count; i++) {
|
|
|
+ expandedList.add(info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 按长度分组
|
|
|
+ Map<Integer, List<BilletBasicInfo>> groupedBySize = expandedList.stream()
|
|
|
+ .filter(b -> b.getLength() != null)
|
|
|
+ .collect(Collectors.groupingBy(BilletBasicInfo::getLength));
|
|
|
+
|
|
|
+ for (Map.Entry<Integer, List<BilletBasicInfo>> sizeEntry : groupedBySize.entrySet()) {
|
|
|
+ Integer size = sizeEntry.getKey();
|
|
|
+ List<BilletBasicInfo> sizeList = sizeEntry.getValue();
|
|
|
+
|
|
|
+ BigDecimal totalWeight = sizeList.stream()
|
|
|
+ .map(BilletBasicInfo::getBilletWeight)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(BigDecimal::valueOf)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ if (size != null && size.equals(9100)) {
|
|
|
+ size = 8790;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加尺寸明细
|
|
|
+ StorageCenterHeatNoInvoicingVO.SizeDetail sizeDetail = new StorageCenterHeatNoInvoicingVO.SizeDetail();
|
|
|
+ sizeDetail.setSize(size);
|
|
|
+ sizeDetail.setSizeWeight(totalWeight);
|
|
|
+ sizeDetail.setSizeAmount(sizeList.size());
|
|
|
+ rollDeputyHeatNo.getSizeDetails().add(sizeDetail);
|
|
|
+
|
|
|
+ // 添加计费信息
|
|
|
+ StorageCenterHeatNoInvoicingVO.RollChargeDetail chargeDetail = new StorageCenterHeatNoInvoicingVO.RollChargeDetail();
|
|
|
+ chargeDetail.setSize(size);
|
|
|
+ chargeDetail.setSpec(Optional.ofNullable(sizeList.get(0).getSpec()).orElse("Unknown"));
|
|
|
+ chargeDetail.setWeight(totalWeight);
|
|
|
+ chargeDetail.setAmount(sizeList.size());
|
|
|
+ chargeDetail.setLicensePlate(Optional.ofNullable(bill.getLicensePlate()).orElse("未知"));
|
|
|
+ chargeDetail.setBtype(Optional.ofNullable(bill.getBtype()).orElse("未知"));
|
|
|
+ chargeDetail.setHeatNo(heatNo);
|
|
|
+ chargeDetail.setCarNum(Optional.ofNullable(bill.getCarNum()).orElse(1));
|
|
|
+ chargeDetail.setBrandNum(Optional.ofNullable(bill.getBrandNum()).orElse(""));
|
|
|
+ chargeDetail.setCreateTime(Optional.ofNullable(bill.getOutTime()).orElse(new Date()));
|
|
|
+ rollDeputyHeatNo.getRollChargeDetails().add(chargeDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static String getTransportUnitNameByCarNumber(String carNumber) {
|
|
|
if (StringUtils.isBlank(carNumber)) return "";
|
|
|
|