Merge pull request 'demand: 线路规则、漏组批次相关逻辑调整' (#50) from develop into master

Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/50
This commit is contained in:
heyu 2025-06-11 16:09:52 +08:00
commit 23e050fd44
8 changed files with 283 additions and 34 deletions

View File

@ -37,13 +37,36 @@ public class EmisTmsSiteBatchMissController extends BaseController {
/**
* 查询TMS漏组批次信息列表
*/
// @PreAuthorize("@ss.hasPermi('emis:tms:site:batch:miss:list')")
@PreAuthorize("@ss.hasPermi('emis:tms:site:batch:miss:list')")
@GetMapping("/list")
public TableDataInfo list(EmisTmsSiteBatchMiss emisTmsSiteBatchMiss) {
startPage();
setPrivParams(emisTmsSiteBatchMiss);
List<EmisTmsSiteBatchMiss> list = emisTmsSiteBatchMissService
.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
// List<EmisTmsSiteBatchMiss> list;
// Integer missCount = emisTmsSiteBatchMiss.getMissCount();
//
// if (missCount != null) {
// if (missCount == -1) {
// emisTmsSiteBatchMiss.setMissType("2");
// list = emisTmsSiteBatchMissService.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
// } else if (missCount == -2) {
// emisTmsSiteBatchMiss.setMissType("3");
// list = emisTmsSiteBatchMissService.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
// }else if (missCount == -3) {
// emisTmsSiteBatchMiss.setMissType("1");
// list = emisTmsSiteBatchMissService.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
// }else if (missCount > 0) {
// // 查询bill_code出现次数等于missCount的记录
// list = emisTmsSiteBatchMissService.selectByBillCodeCount(missCount);
// }
// else {
// list = emisTmsSiteBatchMissService.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
// }
// } else {
// list = emisTmsSiteBatchMissService.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
// }
List<EmisTmsSiteBatchMiss> list = emisTmsSiteBatchMissService.selectEmisTmsSiteBatchMissList(emisTmsSiteBatchMiss);
return getDataTable(list);
}

View File

@ -1,8 +1,10 @@
package com.xdadan.erp.emis.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xdadan.erp.common.annotation.audit.DataAuditField;
import com.xdadan.erp.common.core.domain.BaseEntity;
import lombok.Data;
@ -55,14 +57,6 @@ public class EmisTmsSiteBatchMiss extends BaseEntity {
/* 签收时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date signDate;
/* 所属线路编码 */
private String transLineType;
/* 所属线路名称 */
private String transLineTypeName;
/* 产品类型编码 */
private String productType;
/* 产品类型名称 */
private String productTypeName;
/* 支付方式 : 现金或月结 */
private String paymentType;
/* 件数 */
@ -83,4 +77,53 @@ public class EmisTmsSiteBatchMiss extends BaseEntity {
private String feeRemark;
/* 漏组原因 */
private String missReason;
/** 线路编码 */
private String lineCode;
/** 线路名称 (仅用于查询结果) */
private String lineName;
/* 产品类型编码 */
private String productType;
/* 产品类型名称 */
private String productTypeName;
/**
* 起始网点编码
*/
private String startSiteCode;
/** 下一网点编码 */
private String nextSiteCode;
/** 起始网点名称 */
private String startSiteName;
/** 下一网点名称 */
private String nextSiteName;
/** 供应商编码 */
private String supplierCode;
/** 供应商名称 */
private String supplierName;
/** 生效时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date startDate;
/** 失效时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endDate;
/** 运单漏组次数 */
private Integer missCount;
/**
* 漏组属性.0:其他,1:没有创建线路,2:没有组批次,3:组批次全错,默认为0
*/
private String missType;
/* 是否问题件 1-是 0-否 */
private String blIsQuestion;
}

View File

@ -62,6 +62,9 @@ public class EmisTransPlanRule extends BaseEntity {
/** 节点负责人 */
private String manager;
/* 线路负责人 */
private String transManager;
/** 供应商编码 */
private String supplierCode;

View File

@ -66,4 +66,12 @@ public interface EmisTmsSiteBatchMissMapper {
public int batchInsertEmisTmsSiteBatchMiss(List<EmisTmsSiteBatchMiss> list);
void deleteAll();
/**
* 根据bill_code出现次数查询TMS漏组批次信息
*
* @param count bill_code出现次数
* @return TMS漏组批次信息列表
*/
public List<EmisTmsSiteBatchMiss> selectByBillCodeCount(Integer count);
}

View File

@ -62,4 +62,12 @@ public interface IEmisTmsSiteBatchMissService {
*
*/
void autoScanSiteBatch();
/**
* 根据bill_code出现次数查询TMS漏组批次信息
*
* @param count bill_code出现次数
* @return TMS漏组批次信息列表
*/
public List<EmisTmsSiteBatchMiss> selectByBillCodeCount(Integer count);
}

View File

@ -123,6 +123,14 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
return emisTmsSiteBatchMissMapper.deleteEmisTmsSiteBatchMissById(id);
}
/**
* 根据bill_code出现次数查询TMS漏组批次信息
*/
@Override
public List<EmisTmsSiteBatchMiss> selectByBillCodeCount(Integer count) {
return emisTmsSiteBatchMissMapper.selectByBillCodeCount(count);
}
@Async
@Override
public void autoScanSiteBatch() {
@ -335,6 +343,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
// 创建漏组记录
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
miss.setMissReason("当前线路没有创建对应的线路规划");
miss.setMissType("1");
missRecords.add(miss);
successCount++;
continue;
@ -349,6 +358,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
// 创建漏组记录
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
miss.setMissReason("当前线路没有创建对应的产品类型");
miss.setMissType("1");
missRecords.add(miss);
successCount++;
continue;
@ -360,6 +370,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
// 创建漏组记录
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
miss.setMissReason("当前运单没有组批次");
miss.setMissType("2");
missRecords.add(miss);
successCount++;
continue;
@ -456,6 +467,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
// 创建漏组记录
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
miss.setMissReason("该运单所有组批次信息都不匹配,请仔细核对");
miss.setMissType("3");
missRecords.add(miss);
return false;
}
@ -542,7 +554,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
rule.getStartSiteName(),
rule.getNextSiteName(),
rule.getSupplierName()));
miss.setTransPlanRuleId(rule.getId());
setRule(rule, miss);
missRecords.add(miss);
}
@ -554,6 +566,19 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
checkChildrens(missRecords, childrens, filterRules, waybill);
}
private static void setRule(EmisTransPlanRule rule, EmisTmsSiteBatchMiss miss) {
miss.setTransPlanRuleId(rule.getId());
miss.setLineCode(rule.getLineCode());
miss.setProductType(rule.getProductType());
miss.setStartSiteCode(rule.getStartSiteCode());
miss.setNextSiteCode(rule.getNextSiteCode());
miss.setManager(rule.getManager());
miss.setSupplierCode(rule.getSupplierCode());
miss.setStartDate(rule.getStartDate());
miss.setEndDate(rule.getEndDate());
miss.setMissType("0");
}
private void checkChildrens(List<EmisTmsSiteBatchMiss> missRecords, List<EmisTransPlanRule> childrens,
List<EmisTransPlanRule> filterRules, EmisWaybill waybill) {
// 检查子节点是否至少有一个匹配
@ -581,7 +606,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
// 创建漏组记录
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
miss.setMissReason(missReason.toString());
miss.setTransPlanRuleId(childrens.get(0).getId());
setRule(childrens.get(0), miss);
missRecords.add(miss);
}

View File

@ -4,12 +4,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xdadan.erp.emis.mapper.EmisTmsSiteBatchMissMapper">
<resultMap type="EmisTmsSiteBatchMiss" id="EmisTmsSiteBatchMissResult">
<resultMap type="EmisTmsSiteBatchMiss" id="EmisTmsSiteBatchMissResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id"/>
<result property="billCode" column="bill_code"/>
<result property="manager" column="manager"/>
<result property="transManager" column="trans_manager"/>
<result property="missReason" column="miss_reason"/>
<result property="lineCode" column="line_code"/>
<result property="productType" column="product_type"/>
<result property="startSiteCode" column="start_site_code"/>
<result property="nextSiteCode" column="next_site_code"/>
<result property="supplierCode" column="supplier_code"/>
<result property="startDate" column="start_date"/>
<result property="endDate" column="end_date"/>
<result property="lineName" column="line_name"/>
<result property="productTypeName" column="product_type_name"/>
<result property="startSiteName" column="start_site_name"/>
<result property="nextSiteName" column="next_site_name"/>
<result property="supplierName" column="supplier_name"/>
<result property="sendSiteCode" column="send_site_code"/>
<result property="sendSiteName" column="send_site_name"/>
<result property="sendCountry" column="send_country"/>
@ -18,13 +30,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="destinationName" column="destination_name"/>
<result property="receiveCountry" column="receive_country"/>
<result property="receiveCountryName" column="receive_country_name"/>
<result property="blIsQuestion" column="bl_is_question"/>
<result property="sendDate" column="send_date"/>
<result property="blSign" column="bl_sign"/>
<result property="signDate" column="sign_date"/>
<result property="transLineType" column="trans_line_type"/>
<result property="transLineTypeName" column="trans_line_type_name"/>
<result property="productType" column="product_type"/>
<result property="productTypeName" column="product_type_name"/>
<result property="paymentType" column="payment_type"/>
<result property="parcelQty" column="parcel_qty"/>
<result property="billWeight" column="bill_weight"/>
@ -34,21 +43,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="freight" column="freight"/>
<result property="waybillRemark" column="waybill_remark"/>
<result property="feeRemark" column="fee_remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
<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,
w.send_site_code, s.site_name as send_site_name, w.send_country, c1.name as send_country_name, w.destination_code, n.dest_name as destination_name,
w.receive_country, c2.name as receive_country_name, w.send_date, w.bl_sign, w.sign_date, w.trans_line_type, k.line_name as trans_line_type_name,
m.line_code, m.product_type, m.start_site_code, m.next_site_code, m.supplier_code, m.start_date, m.end_date,
w.send_site_code, s.site_name as send_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.receive_country, c2.name as receive_country_name, w.send_date, w.bl_sign, w.sign_date,
w.product_type, j.prod_name as product_type_name, 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, r.manager, k.trans_manager
w.settlement_weight, w.freight, w.remark as waybill_remark, w.fee_remark, m.manager, k.trans_manager
from emis_tms_site_batch_miss m
left join emis_waybill w on m.bill_code = w.bill_code and w.del_flag='0'
left join emis_site s on w.send_site_code=s.site_code and s.del_flag=0
@ -58,12 +62,88 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join emis_trans_line k on w.trans_line_type=k.line_code and k.del_flag='0'
left join emis_trans_product j on w.product_type=j.prod_code and j.del_flag='0'
left join emis_trans_plan_rule r on m.trans_plan_rule_id=r.id and r.del_flag='0'
left join emis_trans_line l on m.line_code=l.line_code and l.del_flag='0'
left join emis_trans_product p on m.product_type=p.prod_code and p.del_flag='0'
left join emis_site s1 on m.start_site_code=s1.site_code and s1.del_flag='0'
left join emis_site s2 on m.next_site_code=s2.site_code and s2.del_flag='0'
left join emis_supplier sup on m.supplier_code=sup.code and sup.del_flag='0'
</sql>
<!-- <select id="selectEmisTmsSiteBatchMissList" parameterType="EmisTmsSiteBatchMiss" resultMap="EmisTmsSiteBatchMissResult">-->
<!-- <include refid="selectEmisTmsSiteBatchMissVo"/>-->
<!-- <where>-->
<!-- m.del_flag = '0'-->
<!-- <if test="billCode != null and billCode != ''">-->
<!-- AND m.bill_code = #{billCode}-->
<!-- </if>-->
<!-- <if test="missReason != null and missReason != ''">-->
<!-- AND m.miss_reason like concat('%', #{missReason}, '%')-->
<!-- </if>-->
<!-- <if test="missType != null and missType != ''">-->
<!-- AND m.miss_type=#{missType}-->
<!-- </if>-->
<!-- <if test="manager != null and manager != ''">-->
<!-- AND m.manager like concat('%', #{manager}, '%')-->
<!-- </if>-->
<!-- <if test="transManager != null and transManager != ''">-->
<!-- AND k.trans_manager like concat('%', #{transManager}, '%')-->
<!-- </if>-->
<!-- <if test="lineCode != null and lineCode != ''">-->
<!-- AND m.line_code = #{lineCode}-->
<!-- </if>-->
<!-- <if test="productType != null and productType != ''">-->
<!-- AND m.product_type = #{productType}-->
<!-- </if>-->
<!-- <if test="startSiteCode != null and startSiteCode != ''">-->
<!-- AND m.start_site_code = #{startSiteCode}-->
<!-- </if>-->
<!-- <if test="nextSiteCode != null and nextSiteCode != ''">-->
<!-- AND m.next_site_code = #{nextSiteCode}-->
<!-- </if>-->
<!-- <if test="supplierCode != null and supplierCode != ''">-->
<!-- AND m.supplier_code = #{supplierCode}-->
<!-- </if>-->
<!-- <if test="startDate != null">-->
<!-- AND m.start_date = #{startDate}-->
<!-- </if>-->
<!-- <if test="endDate != null">-->
<!-- AND m.end_date = #{endDate}-->
<!-- </if>-->
<!-- <if test="blIsQuestion != null and blIsQuestion != ''">-->
<!-- AND w.bl_is_question = #{blIsQuestion}-->
<!-- </if>-->
<!-- <if test="params.privSiteCode != null and params.privSiteCode != '88888'">-->
<!-- and (r.manager=#{params.privEmpName} or k.trans_manager=#{params.privEmpName})-->
<!-- </if>-->
<!-- </where>-->
<!-- </select>-->
<select id="selectEmisTmsSiteBatchMissList" parameterType="EmisTmsSiteBatchMiss" resultMap="EmisTmsSiteBatchMissResult">
<include refid="selectEmisTmsSiteBatchMissVo"/>
<where>
m.del_flag = '0'
<if test="missCount != null">
<choose>
<when test="missCount == -1">
AND m.miss_type = 2
</when>
<when test="missCount == -2">
AND m.miss_type = 3
</when>
<when test="missCount == -3">
AND m.miss_type = 1
</when>
<when test="missCount > 0">
AND m.bill_code IN (
SELECT bill_code
FROM emis_tms_site_batch_miss
WHERE del_flag = '0'
GROUP BY bill_code
HAVING COUNT(*) = #{missCount}
)
</when>
</choose>
</if>
<if test="billCode != null and billCode != ''">
AND m.bill_code = #{billCode}
</if>
@ -79,6 +159,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and (r.manager=#{params.privEmpName} or k.trans_manager=#{params.privEmpName})
</if>
<if test="lineCode != null and lineCode != ''">
AND m.line_code = #{lineCode}
</if>
<if test="productType != null and productType != ''">
AND m.product_type = #{productType}
</if>
<if test="startSiteCode != null and startSiteCode != ''">
AND m.start_site_code = #{startSiteCode}
</if>
<if test="nextSiteCode != null and nextSiteCode != ''">
AND m.next_site_code = #{nextSiteCode}
</if>
<if test="supplierCode != null and supplierCode != ''">
AND m.supplier_code = #{supplierCode}
</if>
<if test="startDate != null">
AND m.start_date = #{startDate}
</if>
<if test="endDate != null">
AND m.end_date = #{endDate}
</if>
<if test="blIsQuestion != null and blIsQuestion != ''">
AND w.bl_is_question = #{blIsQuestion}
</if>
</where>
</select>
@ -138,12 +242,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchInsertEmisTmsSiteBatchMiss" parameterType="java.util.List">
insert into emis_tms_site_batch_miss
(trans_plan_rule_id,bill_code, create_by, create_time,
update_by, update_time, remark,miss_reason)
(trans_plan_rule_id, bill_code, miss_reason, line_code,manager, product_type,
start_site_code, next_site_code, supplier_code, start_date, end_date,
create_by, create_time, update_by, update_time, remark,
create_site, update_site, miss_type)
values
<foreach collection="list" item="item" separator=",">
(#{item.transPlanRuleId},#{item.billCode}, #{item.createBy}, #{item.createTime},
#{item.updateBy}, #{item.updateTime}, #{item.remark}, #{item.missReason})
(
#{item.transPlanRuleId,jdbcType=BIGINT},
#{item.billCode,jdbcType=VARCHAR},
#{item.missReason,jdbcType=VARCHAR},
#{item.lineCode,jdbcType=VARCHAR},
#{item.manager,jdbcType=VARCHAR},
#{item.productType,jdbcType=VARCHAR},
#{item.startSiteCode,jdbcType=VARCHAR},
#{item.nextSiteCode,jdbcType=VARCHAR},
#{item.supplierCode,jdbcType=VARCHAR},
#{item.startDate,jdbcType=TIMESTAMP},
#{item.endDate,jdbcType=TIMESTAMP},
#{item.createBy,jdbcType=VARCHAR},
#{item.createTime,jdbcType=TIMESTAMP},
#{item.updateBy,jdbcType=VARCHAR},
#{item.updateTime,jdbcType=TIMESTAMP},
#{item.remark,jdbcType=VARCHAR},
#{item.createSite,jdbcType=VARCHAR},
#{item.updateSite,jdbcType=VARCHAR},
#{item.missType,jdbcType=VARCHAR}
)
</foreach>
</insert>
<select id="selectByBillCodeCount" parameterType="Integer" resultMap="EmisTmsSiteBatchMissResult">
SELECT t.*
FROM emis_tms_site_batch_miss t
WHERE t.bill_code IN (
SELECT bill_code
FROM emis_tms_site_batch_miss
GROUP BY bill_code
HAVING COUNT(*) = #{count}
)
</select>
</mapper>

View File

@ -44,6 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectEmisTransPlanRuleList" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
<include refid="selectEmisTransPlanRuleVo"/>
<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>
@ -52,7 +53,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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.del_flag = '0'
<if test="transManager != null and transManager != ''">
AND l.trans_manager like concat('%', #{transManager}, '%')
</if>
</where>
order by id desc
</select>
@ -60,12 +63,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="checkDuplicate" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
<include refid="selectEmisTransPlanRuleVo"/>
<where>
r.del_flag = '0'
<if test="lineCode != null and lineCode != ''">and r.line_code = #{lineCode}</if>
<if test="productType != null and productType != ''">and r.product_type=#{productType}</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="supplierCode != null and supplierCode != ''">and r.supplier_code=#{supplierCode}</if>
and r.del_flag = '0'
</where>
order by id desc
</select>