Merge pull request 'demand: 新增组批次成功运单过滤重复运单,查询漏组批次运单过滤出口虚拟单的主单' (#107) from develop into master

Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/107
This commit is contained in:
heyu 2025-07-10 09:02:55 +08:00
commit ebcf305898
6 changed files with 97 additions and 39 deletions

View File

@ -126,4 +126,6 @@ public class EmisTmsSiteBatchMiss extends BaseEntity {
/* 是否问题件 1-是 0-否 */ /* 是否问题件 1-是 0-否 */
private String blIsQuestion; private String blIsQuestion;
private String virtualRemark;
private Integer problemType;
} }

View File

@ -2,6 +2,7 @@ package com.xdadan.erp.emis.mapper;
import java.util.List; import java.util.List;
import com.xdadan.erp.emis.domain.EmisTmsSiteBatchMiss; import com.xdadan.erp.emis.domain.EmisTmsSiteBatchMiss;
import com.xdadan.erp.emis.domain.EmisWaybill;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
/** /**
@ -87,4 +88,9 @@ public interface EmisTmsSiteBatchMissMapper {
void deleteByBillCodes(@Param("billCodes") List<String> billCodes); void deleteByBillCodes(@Param("billCodes") List<String> billCodes);
void deleteReally(String lineCode); void deleteReally(String lineCode);
/**
* 根据运单号批量查询TMS漏组批次信息
*/
List<EmisWaybill> selectByBillCodes(@Param("billCodes") List<String> billCodes);
} }

View File

@ -83,6 +83,44 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
} else { } else {
list = emisTmsSiteBatchMissMapper.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss); list = emisTmsSiteBatchMissMapper.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
} }
// 收集所有virtualRemark中的单号
Set<String> relatedBillCodes = new HashSet<>();
for (EmisTmsSiteBatchMiss miss : list) {
String virtualRemark = miss.getVirtualRemark();
if (virtualRemark != null && !virtualRemark.trim().isEmpty()) {
String[] codes = virtualRemark.split(",");
for (String code : codes) {
relatedBillCodes.add(code.trim());
}
}
}
if (CollectionUtil.isEmpty(relatedBillCodes)) {
return list;
}
// 批量查找相关单号
List<EmisWaybill> relatedList = relatedBillCodes.isEmpty() ? Collections.emptyList()
: emisTmsSiteBatchMissMapper.selectByBillCodes(new ArrayList<>(relatedBillCodes));
Map<String, EmisWaybill> relatedMap = relatedList.stream()
.collect(Collectors.toMap(EmisWaybill::getBillCode, Function.identity(), (a, b) -> a));
// 过滤逻辑
list = list.stream()
.filter(wb -> {
String virtualRemark = wb.getVirtualRemark();
if (virtualRemark == null || virtualRemark.trim().isEmpty()) {
return true;
}
String[] relatedNos = virtualRemark.split(",");
for (String no : relatedNos) {
EmisWaybill related = relatedMap.get(no.trim());
if (related != null && Integer.valueOf(173).equals(related.getProblemType())) {
return false;
}
}
return true;
})
.collect(Collectors.toList());
return list; return list;
} }
@ -190,7 +228,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
try { try {
List<EmisWaybill> waybills = future.get(); List<EmisWaybill> waybills = future.get();
allWaybills.addAll(waybills); allWaybills.addAll(waybills);
// totalProcessed += waybills.size(); totalProcessed += waybills.size();
} catch (Exception e) { } catch (Exception e) {
log.error("Error getting waybill results", e); log.error("Error getting waybill results", e);
} }
@ -199,34 +237,35 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
// 关闭线程池 // 关闭线程池
executorService.shutdown(); executorService.shutdown();
// 构建运单号到EmisWaybill的映射 // // 构建运单号到EmisWaybill的映射
Map<String, EmisWaybill> waybillMap = allWaybills.stream() // Map<String, EmisWaybill> waybillMap = allWaybills.stream()
.collect(Collectors.toMap(EmisWaybill::getBillCode, Function.identity(), (a, b) -> a)); // .collect(Collectors.toMap(EmisWaybill::getBillCode, Function.identity(), (a,
// b) -> a));
allWaybills = allWaybills.stream() //
.filter(wb -> { // allWaybills = allWaybills.stream()
String virtualRemark = wb.getVirtualRemark(); // .filter(wb -> {
if (StringUtils.isBlank(virtualRemark)) { // String virtualRemark = wb.getVirtualRemark();
return true; // if (StringUtils.isBlank(virtualRemark)) {
} // return true;
// 解析virtualRemark中的运单号 // }
String[] relatedNos = virtualRemark.split(","); // // 解析virtualRemark中的运单号
for (String no : relatedNos) { // String[] relatedNos = virtualRemark.split(",");
EmisWaybill related = waybillMap.get(no.trim()); // for (String no : relatedNos) {
if (related != null && Objects.equals(related.getProblemType(), 173)) { // EmisWaybill related = waybillMap.get(no.trim());
return false; // 只要有一个关联运单problemType=173,则过滤掉 // if (related != null && Objects.equals(related.getProblemType(), 173)) {
} // return false; // 只要有一个关联运单problemType=173,则过滤掉
} // }
return true; // }
}) // return true;
.collect(Collectors.toList()); // })
// .collect(Collectors.toList());
allWaybills = allWaybills.stream() //
.filter(wb -> !Objects.equals(wb.getProblemType(), 170)) // allWaybills = allWaybills.stream()
.filter(wb -> !Objects.equals(wb.getSiteBatchStatus(), "1")) // .filter(wb -> !Objects.equals(wb.getProblemType(), 170))
.collect(Collectors.toList()); //// .filter(wb -> !Objects.equals(wb.getSiteBatchStatus(), "1"))
// .collect(Collectors.toList());
totalProcessed = allWaybills.size(); //
// totalProcessed = allWaybills.size();
// 按1000条数据分组处理 // 按1000条数据分组处理
List<List<EmisWaybill>> batches = new ArrayList<>(); List<List<EmisWaybill>> batches = new ArrayList<>();

View File

@ -44,16 +44,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="waybillRemark" column="waybill_remark"/> <result property="waybillRemark" column="waybill_remark"/>
<result property="feeRemark" column="fee_remark"/> <result property="feeRemark" column="fee_remark"/>
<result property="missType" column="miss_type"/> <result property="missType" column="miss_type"/>
<result property="virtualRemark" column="virtual_remark" />
<result property="problemType" column="problem_type" />
</resultMap> </resultMap>
<sql id="selectEmisTmsSiteBatchMissVo"> <sql id="selectEmisTmsSiteBatchMissVo">
select select
m.id, m.bill_code, m.miss_reason, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.del_flag, m.id, m.bill_code, m.miss_reason, m.create_time, m.update_time, m.remark, m.del_flag,
m.line_code, m.product_type, m.start_site_code, m.next_site_code, m.supplier_code, m.start_date, m.end_date,m.miss_type, m.line_code, m.product_type, m.start_site_code, m.next_site_code, m.supplier_code, m.start_date, m.end_date,m.miss_type,
w.send_site_code, s1.site_name as send_site_name,s2.site_name as start_site_name,s3.site_name as next_site_name, w.send_country, c1.name as send_country_name, w.destination_code, n.dest_name as destination_name,w.bl_is_question, w.send_site_code, s1.site_name as send_site_name,s2.site_name as start_site_name,s3.site_name as next_site_name, w.send_country, c1.name as send_country_name, w.destination_code, n.dest_name as destination_name,w.bl_is_question,
l.line_name as line_name, l.line_name as line_name,
w.receive_country, c2.name as receive_country_name, w.send_date, w.bl_sign, w.sign_date, w.receive_country, c2.name as receive_country_name, w.send_date, w.bl_sign, w.sign_date,
w.product_type, w.product_type,w.problem_type,w.virtual_remark,
w.payment_type, w.parcel_qty, w.bill_weight, w.total_volume, w.volume_weight, w.payment_type, w.parcel_qty, w.bill_weight, w.total_volume, w.volume_weight,
w.settlement_weight, w.freight, w.remark as waybill_remark, w.fee_remark, m.manager, k.trans_manager, w.settlement_weight, w.freight, w.remark as waybill_remark, w.fee_remark, m.manager, k.trans_manager,
(SELECT GROUP_CONCAT(s.name) (SELECT GROUP_CONCAT(s.name)
@ -414,4 +416,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
HAVING COUNT(*) = #{count} HAVING COUNT(*) = #{count}
) )
</select> </select>
<select id="selectByBillCodes" resultMap="com.xdadan.erp.emis.mapper.EmisWaybillMapper.EmisWaybillResult">
select a.id, a.bill_code,a.trans_line_type,
a.product_type,a.start_site_code,a.send_site_code,a.problem_type,a.virtual_remark
from emis_waybill a
where bill_code in
<foreach collection="billCodes" item="billCode" open="(" separator="," close=")">
#{billCode}
</foreach>
</select>
</mapper> </mapper>

View File

@ -3814,17 +3814,17 @@
<select id="selectWaybillListBySiteBatchStatus" resultMap="EmisWaybillResult"> <select id="selectWaybillListBySiteBatchStatus" resultMap="EmisWaybillResult">
select a.id, a.bill_code,a.trans_line_type, select a.id, a.bill_code,a.trans_line_type,
a.product_type,a.start_site_code,a.send_site_code,a.problem_type,a.virtual_remark,b.site_batch_status a.product_type,a.start_site_code,a.send_site_code,a.problem_type,a.virtual_remark
from emis_waybill a from emis_waybill a
left join emis_waybill_batch_status b on a.bill_code = b.bill_code left join emis_waybill_batch_status b on a.bill_code = b.bill_code
and (b.site_batch_status is null or b.site_batch_status != '1')
where a.del_flag = '0' where a.del_flag = '0'
-- and (b.site_batch_status is null or b.site_batch_status != '1')
<if test="lineCode != null and lineCode != ''"> <if test="lineCode != null and lineCode != ''">
and a.trans_line_type = #{lineCode} and a.trans_line_type = #{lineCode}
</if> </if>
and DATE_FORMAT(a.send_date, '%Y-%m-%d') <![CDATA[ >= ]]> '2025-01-01' and DATE_FORMAT(a.send_date, '%Y-%m-%d') <![CDATA[ >= ]]> '2025-01-01'
and DATE_FORMAT(a.send_date, '%Y-%m-%d') <![CDATA[ <= ]]> DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 7 DAY), '%Y-%m-%d') and DATE_FORMAT(a.send_date, '%Y-%m-%d') <![CDATA[ <= ]]> DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 7 DAY), '%Y-%m-%d')
and (a.problem_type is null or a.problem_type != 151) and (a.problem_type is null or a.problem_type not in (151,170))
and a.order_status not in ('0','2') and a.order_status not in ('0','2')
order by a.create_time desc order by a.create_time desc
limit #{offset}, #{pageSize} limit #{offset}, #{pageSize}

View File

@ -22,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql> </sql>
<insert id="batchInsertEmisWaybillBatchStatus" parameterType="java.util.List"> <insert id="batchInsertEmisWaybillBatchStatus" parameterType="java.util.List">
insert into emis_waybill_batch_status ( insert ignore into emis_waybill_batch_status (
bill_code, site_batch_status, remark, bill_code, site_batch_status, remark,
create_by, create_time, update_by, update_time create_by, create_time, update_by, update_time
) values ) values