demand: 查询组批次供应商名称取值问题修复 查询漏组批次效率优化

committer: heyu
This commit is contained in:
aike 2025-07-03 11:24:09 +08:00
parent eaf74a5405
commit c47956c5da
6 changed files with 26 additions and 77 deletions

View File

@ -141,22 +141,14 @@ public interface EmisTransPlanRuleMapper {
*/
List<EmisTransPlanRule> selectEmisTransPlanRuleByLineCodes(@Param("lineCodes") List<String> lineCodes);
/**
*
* @param emisTransPlanRule
* @return
*/
List<EmisTransPlanRule> selectRulesForAllScan(EmisTransPlanRule emisTransPlanRule);
/**
* 分页查询供应商线路规划(多线程用)
* 查询供应商线路规划
*
* @param emisTransPlanRule 查询条件
* @param offset 偏移量
* @param pageSize 每页数量
* @return 供应商线路规划集合
*/
List<EmisTransPlanRule> selectRulesForAllScanPaged(@Param("emisTransPlanRule") EmisTransPlanRule emisTransPlanRule, @Param("offset") int offset, @Param("pageSize") int pageSize);
List<EmisTransPlanRule> selectRulesForAllScan(EmisTransPlanRule emisTransPlanRule);
/**
* 查询总数(多线程分页用)

View File

@ -4698,6 +4698,13 @@ public class EmisBaseService {
.collect(Collectors.toList());
EmisTransPlanRule rule = rules.get(0);
setMissRecords(missRecords, rule, filterRules, waybill);
if(CollectionUtil.isEmpty(missRecords)){
return true;
}
List<EmisTmsSiteBatchMiss> list = missRecords.stream().filter(i -> waybill.getBillCode().equals(i.getBillCode())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(list)) {
return true;
}
return false;
}

View File

@ -276,34 +276,10 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
}
public List<EmisTransPlanRule> selectEmisTransPlanRuleTree(String lineCode) {
log.info("Start querying supplier route plan tree (multi-threaded)");
EmisTransPlanRule emisTransPlanRule = new EmisTransPlanRule();
emisTransPlanRule.setLineCode(lineCode);
int pageSize = 100;
int total = emisTransPlanRuleMapper.countForAllScan(emisTransPlanRule);
int pageCount = (total + pageSize - 1) / pageSize;
int processors = Runtime.getRuntime().availableProcessors();
ExecutorService executor = Executors.newFixedThreadPool(processors);
List<Future<List<EmisTransPlanRule>>> futures = new ArrayList<>();
for (int i = 0; i < pageCount; i++) {
int offset = i * pageSize;
futures.add(executor.submit(
() -> emisTransPlanRuleMapper.selectRulesForAllScanPaged(emisTransPlanRule, offset, pageSize)));
}
List<EmisTransPlanRule> allRules = new ArrayList<>();
for (Future<List<EmisTransPlanRule>> future : futures) {
try {
List<EmisTransPlanRule> rules = future.get();
if (rules != null) {
allRules.addAll(rules);
}
} catch (Exception e) {
log.error("Error getting trans plan rule results", e);
}
}
executor.shutdown();
List<EmisTransPlanRule> allRules = emisTransPlanRuleMapper.selectRulesForAllScan(emisTransPlanRule);
List<EmisTransPlanRule> tree = buildTree(allRules, new EmisTransPlanRule());
log.info("Queried supplier route plan tree, node count={}", tree != null ? tree.size() : 0);
return tree;
}

View File

@ -285,4 +285,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
order by id desc
</select>
<select id="selectSupplierNameByCode" parameterType="String" resultType="String">
SELECT name FROM emis_supplier WHERE code = #{code} LIMIT 1
</select>
</mapper>

View File

@ -10,7 +10,6 @@
<result property="batchName" column="batch_name" />
<result property="batchDate" column="batch_date" />
<result property="supplierCode" column="supplier_code" />
<result property="supplierName" column="supplier_name" />
<result property="transLineType" column="trans_line_type" />
<result property="productType" column="product_type" />
<result property="batchType" column="batch_type" />
@ -37,6 +36,7 @@
<result property="blEntering" column="bl_entering" />
<!-- 扩展 -->
<association property="supplierName" column="supplier_code" select="com.xdadan.erp.emis.mapper.EmisSupplierMapper.selectSupplierNameByCode"/>
<association property="productTypeName" column="product_type" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectProdNameByCode"/>
<association property="transLineTypeName" column="trans_line_type" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectLineNameByCode"/>
@ -70,7 +70,6 @@
<result property="batchName" column="batch_name" />
<result property="batchDate" column="batch_date" />
<result property="supplierCode" column="supplier_code" />
<result property="supplierName" column="supplier_name" />
<result property="transLineType" column="trans_line_type" />
<result property="productType" column="product_type" />
<result property="batchType" column="batch_type" />
@ -97,6 +96,7 @@
<result property="blEntering" column="bl_entering" />
<!-- 扩展 -->
<association property="supplierName" column="supplier_code" select="com.xdadan.erp.emis.mapper.EmisSupplierMapper.selectSupplierNameByCode"/>
<association property="productTypeName" column="product_type" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectProdNameByCode"/>
<association property="transLineTypeName" column="trans_line_type" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectLineNameByCode"/>

View File

@ -131,36 +131,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by id desc
</select>
<select id="selectRulesForAllScan" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
select r.id, r.line_code, r.product_type, r.start_site_code,r.next_site_code, s1.site_name as start_site_name,
s2.site_name as next_site_name,
r.manager, r.supplier_code, r.start_date, r.end_date, (SELECT GROUP_CONCAT(s.name ORDER BY FIND_IN_SET(s.code, r.supplier_code))
FROM emis_supplier s
WHERE FIND_IN_SET(s.code, r.supplier_code)
AND s.del_flag = '0') as supplier_name
from emis_trans_plan_rule r
left join emis_site s1 on r.start_site_code = s1.site_code and s1.del_flag='0'
left join emis_site s2 on r.next_site_code = s2.site_code and s2.del_flag='0'
<where>
r.del_flag = '0'
<if test="lineCode != null and lineCode != ''">and r.line_code = #{lineCode}</if>
<if test="productType != null and productType != ''">and ( FIND_IN_SET(#{productType},r.product_type) )
</if>
<if test="startSiteCode != null and startSiteCode != ''">and r.start_site_code = #{startSiteCode}</if>
<if test="nextSiteCode != null and nextSiteCode != ''">and r.next_site_code = #{nextSiteCode}</if>
<if test="manager != null and manager != ''">and r.manager = #{manager}</if>
<if test="supplierCode != null and supplierCode != ''">and ( FIND_IN_SET(#{supplierCode},r.supplier_code)
)
</if>
<if test="startDate != null">and r.start_date = #{startDate}</if>
<if test="endDate != null">and r.end_date = #{endDate}</if>
<if test="transManager != null and transManager != ''">
AND l.trans_manager like concat('%', #{transManager}, '%')
</if>
</where>
order by id desc
</select>
<select id="selectEmisTransPlanRuleByLineCodes" parameterType="list" resultMap="EmisTransPlanRuleResult">
select r.id, r.line_code, r.product_type, r.start_site_code,r.next_site_code, s1.site_name as start_site_name,
s2.site_name as next_site_name,
@ -365,7 +335,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND del_flag = '0'
</select>
<select id="selectRulesForAllScanPaged" resultMap="EmisTransPlanRuleResult">
<select id="selectRulesForAllScan" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
select r.id, r.line_code, r.product_type, r.start_site_code, r.next_site_code, s1.site_name as start_site_name,
s2.site_name as next_site_name,
r.manager, r.supplier_code, r.start_date, r.end_date, (SELECT GROUP_CONCAT(s.name)
@ -377,18 +347,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join emis_site s2 on r.next_site_code = s2.site_code and s2.del_flag='0'
<where>
r.del_flag = '0'
<if test="emisTransPlanRule.lineCode != null and emisTransPlanRule.lineCode != ''">and r.line_code = #{emisTransPlanRule.lineCode}</if>
<if test="emisTransPlanRule.productType != null and emisTransPlanRule.productType != ''">and ( FIND_IN_SET(#{emisTransPlanRule.productType},r.product_type) )</if>
<if test="emisTransPlanRule.startSiteCode != null and emisTransPlanRule.startSiteCode != ''">and r.start_site_code = #{emisTransPlanRule.startSiteCode}</if>
<if test="emisTransPlanRule.nextSiteCode != null and emisTransPlanRule.nextSiteCode != ''">and r.next_site_code = #{emisTransPlanRule.nextSiteCode}</if>
<if test="emisTransPlanRule.manager != null and emisTransPlanRule.manager != ''">and r.manager = #{emisTransPlanRule.manager}</if>
<if test="emisTransPlanRule.supplierCode != null and emisTransPlanRule.supplierCode != ''">and ( FIND_IN_SET(#{emisTransPlanRule.supplierCode},r.supplier_code) )</if>
<if test="emisTransPlanRule.startDate != null">and r.start_date = #{emisTransPlanRule.startDate}</if>
<if test="emisTransPlanRule.endDate != null">and r.end_date = #{emisTransPlanRule.endDate}</if>
<if test="lineCode != null and lineCode != ''">and r.line_code = #{lineCode}</if>
<if test="productType != null and productType != ''">and ( FIND_IN_SET(#{productType},r.product_type) )</if>
<if test="startSiteCode != null and startSiteCode != ''">and r.start_site_code = #{startSiteCode}</if>
<if test="nextSiteCode != null and nextSiteCode != ''">and r.next_site_code = #{nextSiteCode}</if>
<if test="manager != null and manager != ''">and r.manager = #{manager}</if>
<if test="supplierCode != null and supplierCode != ''">and ( FIND_IN_SET(#{supplierCode},r.supplier_code) )</if>
<if test="startDate != null">and r.start_date = #{startDate}</if>
<if test="endDate != null">and r.end_date = #{endDate}</if>
-- and r.line_code not in ('014','012','077')
</where>
order by id desc
limit #{offset}, #{pageSize}
</select>
<select id="countForAllScan" resultType="int">