diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java index a679d058a..d7b099901 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java @@ -4651,11 +4651,39 @@ public class EmisBaseService { // 合并相同起始网点和下一网点的批次 Map mergedBatches = new HashMap<>(); + int status2Index = 0; for (EmisTmsSiteBatch batch : waybillBatches) { if (StringUtils.isAnyBlank(batch.getStartSiteCode(), batch.getNextSiteCode(), batch.getSupplierCode())) { continue; } + + // 检查明细列表中是否有waybillBatchStatus=2的记录,如果有则不合并 + boolean hasWaybillBatchStatus2 = false; + if (batch.getBatchDtlList() != null && !batch.getBatchDtlList().isEmpty()) { + for (EmisTmsSiteBatchDtl dtl : batch.getBatchDtlList()) { + if ("2".equals(dtl.getWaybillBatchStatus())) { + hasWaybillBatchStatus2 = true; + break; + } + } + } + + // 如果有waybillBatchStatus=2的记录,不合并supplierCode,但添加到mergedBatches + if (hasWaybillBatchStatus2) { + String specialKey = batch.getStartSiteCode() + "_" + batch.getNextSiteCode() + "_S2_" + + (status2Index++); + EmisTmsSiteBatch newBatch = new EmisTmsSiteBatch(); + BeanUtils.copyProperties(batch, newBatch); + Set supplierSet = new TreeSet<>(); + if (StringUtils.isNotBlank(batch.getSupplierCode())) { + supplierSet.addAll(Arrays.asList(batch.getSupplierCode().split(","))); + } + newBatch.setSupplierCode(String.join(",", supplierSet)); + mergedBatches.put(specialKey, newBatch); + continue; + } + String key = batch.getStartSiteCode() + "_" + batch.getNextSiteCode(); if (mergedBatches.containsKey(key)) { EmisTmsSiteBatch existingBatch = mergedBatches.get(key); diff --git a/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchMapper.xml b/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchMapper.xml index ef08d19fd..6c0d77703 100644 --- a/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchMapper.xml @@ -64,6 +64,7 @@ + @@ -527,7 +528,8 @@ - select distinct b.id, b.batch_no, b.batch_name, b.batch_date, b.supplier_code, b.trans_line_type, - b.product_type, b.batch_type, b.trans_type, b.start_site_code, b.send_country, - b.next_site_code, b.air_billl_no, b.etd, b.eta, b.car_no, b.ship_no, - b.clearance_res_status, b.declare_res_status, b.dest_country, b.dest_country_name, - b.trans_weight, b.pack_num, b.total_waybill_qty, b.total_settlement_weight, - b.op_man, b.remark, b.tenant_id, b.del_flag, b.create_by, b.create_time, + select distinct b.id, b.batch_no, b.batch_name, b.batch_date, b.supplier_code, b.trans_line_type, + b.product_type, b.batch_type, b.trans_type, b.start_site_code, b.send_country, + b.next_site_code, b.air_billl_no, b.etd, b.eta, b.car_no, b.ship_no, + b.clearance_res_status, b.declare_res_status, b.dest_country, b.dest_country_name, + b.trans_weight, b.pack_num, b.total_waybill_qty, b.total_settlement_weight, + b.op_man, b.remark, b.tenant_id, b.del_flag, b.create_by, b.create_time, b.update_by, b.update_time, b.create_site, b.update_site, b.bl_entering, - CASE + CASE WHEN COALESCE(MAX(d.batch_volume), 0) = 0 THEN COALESCE(w.total_volume, 0) ELSE COALESCE(MAX(d.batch_volume), 0) END as total_volume, - CASE + CASE WHEN COALESCE(MAX(d.batch_parcel_qty), 0) = 0 THEN COALESCE(w.parcel_qty, 0) ELSE COALESCE(MAX(d.batch_parcel_qty), 0) END as total_parcel_qty, - CASE + CASE WHEN COALESCE(MAX(d.batch_weight), 0) = 0 THEN COALESCE(w.bill_weight, 0) ELSE COALESCE(MAX(d.batch_weight), 0) END as total_weight @@ -568,13 +570,13 @@ and b.del_flag = '0' and d.del_flag = '0' AND d.id != #{id} - group by b.id, b.batch_no, b.batch_name, b.batch_date, b.supplier_code, b.trans_line_type, - b.product_type, b.batch_type, b.trans_type, b.start_site_code, b.send_country, - b.next_site_code, b.air_billl_no, b.etd, b.eta, b.car_no, b.ship_no, - b.clearance_res_status, b.declare_res_status, b.dest_country, b.dest_country_name, - b.trans_weight, b.pack_num, b.total_waybill_qty, b.total_settlement_weight, - b.op_man, b.remark, b.tenant_id, b.del_flag, b.create_by, b.create_time, + group by b.id, b.batch_no, b.batch_name, b.batch_date, b.supplier_code, b.trans_line_type, + b.product_type, b.batch_type, b.trans_type, b.start_site_code, b.send_country, + b.next_site_code, b.air_billl_no, b.etd, b.eta, b.car_no, b.ship_no, + b.clearance_res_status, b.declare_res_status, b.dest_country, b.dest_country_name, + b.trans_weight, b.pack_num, b.total_waybill_qty, b.total_settlement_weight, + b.op_man, b.remark, b.tenant_id, b.del_flag, b.create_by, b.create_time, b.update_by, b.update_time, b.create_site, b.update_site, b.bl_entering, w.total_volume, w.parcel_qty, w.total_weight - \ No newline at end of file + diff --git a/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml b/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml index 2f0883b98..cd53168f0 100644 --- a/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml @@ -2073,7 +2073,7 @@ and cust_no like concat('%', #{custNo}, '%') and cust_name like concat('%', #{custName}, '%') and trans_line_type=#{transLineType} - and product_type=#{productType} + and FIND_IN_SET(product_type,#{productType}) and time_type like concat('%', #{timeType}, '%') and meter_type like concat('%', #{meterType}, '%') and FIND_IN_SET(a.carry_type,#{carryType}) @@ -3891,4 +3891,4 @@ limit 1 - \ No newline at end of file +