Merge pull request 'demand: 组树添加南京分拨中心、柯桥分拨中心' (#86) from develop into master

Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/86
This commit is contained in:
heyu 2025-07-02 19:53:34 +08:00
commit e3c2fe6a92
4 changed files with 123 additions and 69 deletions

View File

@ -4030,7 +4030,8 @@ public class EmisBaseService {
for (EmisTransPlanRule rule : lineRules) { for (EmisTransPlanRule rule : lineRules) {
if (rule.getProductType() != null) { if (rule.getProductType() != null) {
String[] types = rule.getProductType().split(","); String[] types = rule.getProductType().split(",");
String[] typeNames = rule.getProductTypeName() != null ? rule.getProductTypeName().split(",") : new String[0]; String[] typeNames = rule.getProductTypeName() != null ? rule.getProductTypeName().split(",")
: new String[0];
for (int i = 0; i < types.length; i++) { for (int i = 0; i < types.length; i++) {
String type = types[i].trim(); String type = types[i].trim();
if (!type.isEmpty()) { if (!type.isEmpty()) {
@ -4069,7 +4070,8 @@ public class EmisBaseService {
Map<String, List<EmisTransPlanRule>> tempMap = new HashMap<>(); Map<String, List<EmisTransPlanRule>> tempMap = new HashMap<>();
if (StringUtil.isNotBlank(emisTransPlanRule.getProductType())) { if (StringUtil.isNotBlank(emisTransPlanRule.getProductType())) {
Iterator<Map.Entry<String, List<EmisTransPlanRule>>> iterator = groupByProductType.entrySet().iterator(); Iterator<Map.Entry<String, List<EmisTransPlanRule>>> iterator = groupByProductType.entrySet()
.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<String, List<EmisTransPlanRule>> entry = iterator.next(); Map.Entry<String, List<EmisTransPlanRule>> entry = iterator.next();
if (emisTransPlanRule.getProductType().equals(entry.getKey())) { if (emisTransPlanRule.getProductType().equals(entry.getKey())) {
@ -4116,12 +4118,14 @@ public class EmisBaseService {
String siteCode1 = child.getStartSiteCode() + "," + child.getNextSiteCode(); String siteCode1 = child.getStartSiteCode() + "," + child.getNextSiteCode();
String siteCode2 = parent.getStartSiteCode() + "," + parent.getNextSiteCode(); String siteCode2 = parent.getStartSiteCode() + "," + parent.getNextSiteCode();
if (!parent.getChildren().contains(child) && !compareSiteCodes(siteCode1, siteCode2)) { if (!parent.getChildren().contains(child) && !compareSiteCodes(siteCode1, siteCode2)) {
if (!wouldFormCycle(parent, child)) {
parent.getChildren().add(child); parent.getChildren().add(child);
} }
} }
} }
} }
} }
}
// 找出顶级节点(没有父节点的节点) // 找出顶级节点(没有父节点的节点)
List<EmisTransPlanRule> topLevelNodes = productRules.stream() List<EmisTransPlanRule> topLevelNodes = productRules.stream()
@ -4250,7 +4254,7 @@ public class EmisBaseService {
errorMsg.append("节点ID:").append(id); errorMsg.append("节点ID:").append(id);
} }
} }
// errorMsg.append("\n循环引用发生在节点,详细信息见上"); // errorMsg.append("\n循环引用发生在节点,详细信息见上");
throw new RuntimeException(errorMsg.toString()); throw new RuntimeException(errorMsg.toString());
} }
} }
@ -4285,6 +4289,22 @@ public class EmisBaseService {
return emisTransPlanRuleMapper.selectEmisTransPlanRuleById(id); return emisTransPlanRuleMapper.selectEmisTransPlanRuleById(id);
} }
/**
* 判断添加child到parent后是否会形成环
*/
private boolean wouldFormCycle(EmisTransPlanRule parent, EmisTransPlanRule child) {
if (child == null)
return false;
if (child.getId() != null && parent.getId() != null && child.getId().equals(parent.getId()))
return true;
if (child.getChildren() == null || child.getChildren().isEmpty())
return false;
for (EmisTransPlanRule c : child.getChildren()) {
if (wouldFormCycle(parent, c))
return true;
}
return false;
}
/** /**
* 检查月结客户首次签约日期,首次签约之前开的不允许修改 * 检查月结客户首次签约日期,首次签约之前开的不允许修改
* *
@ -4849,6 +4869,9 @@ public class EmisBaseService {
if (currentLevelMatch) { if (currentLevelMatch) {
hasCurrentLevelMatch = true; hasCurrentLevelMatch = true;
if (CollectionUtil.isEmpty(currentLevelRule.getChildren())) {
return true;
}
} }
// 收集当前级节点的所有子节点到下一级集合中 // 收集当前级节点的所有子节点到下一级集合中
@ -4943,6 +4966,13 @@ public class EmisBaseService {
Objects.equals(filterRule.getNextSiteCode(), levelRule.getNextSiteCode()) && Objects.equals(filterRule.getNextSiteCode(), levelRule.getNextSiteCode()) &&
compareSupplierCodes(filterRule.getSupplierCode(), levelRule.getSupplierCode()))); compareSupplierCodes(filterRule.getSupplierCode(), levelRule.getSupplierCode())));
if (!matched && !group.isEmpty()) { if (!matched && !group.isEmpty()) {
// if (CollectionUtil.isNotEmpty(missRecords)) {
// List<EmisTmsSiteBatchMiss> list = missRecords.stream().filter(i -> waybill.getBillCode().equals(i.getBillCode())).collect(Collectors.toList());
// if (CollectionUtil.isNotEmpty(list) && list.size() > 10) {
// break;
// }
// }
// 聚合supplierCode、supplierName等 // 聚合supplierCode、supplierName等
String supplierCodes = group.stream().map(EmisTransPlanRule::getSupplierCode) String supplierCodes = group.stream().map(EmisTransPlanRule::getSupplierCode)
.filter(Objects::nonNull).distinct().collect(Collectors.joining(",")); .filter(Objects::nonNull).distinct().collect(Collectors.joining(","));
@ -5026,7 +5056,11 @@ public class EmisBaseService {
} }
public void scanProblemInfo(EmisWaybill emisWaybillSave, EmisWaybill emisWaybillOld) { public void scanProblemInfo(EmisWaybill emisWaybillSave, EmisWaybill emisWaybillOld) {
if ("078".equals(emisWaybillSave.getTransLineType())) { Set<String> allowedTypes = new HashSet<>();
allowedTypes.add("078");
allowedTypes.add("012");
allowedTypes.add("014");
if (allowedTypes.contains(emisWaybillSave.getTransLineType())) {
return; return;
} }
String dispatchOrSendManCode = ""; String dispatchOrSendManCode = "";
@ -5119,7 +5153,7 @@ public class EmisBaseService {
long count = Arrays.stream(virtualRemark.split(",")) long count = Arrays.stream(virtualRemark.split(","))
.filter(s -> s != null && !s.trim().isEmpty()) .filter(s -> s != null && !s.trim().isEmpty())
.count(); .count();
if (count >= masterWaybill.getParcelQty()) { if (("078".equals(emisWaybillSave.getTransLineType()) || "002".equals(emisWaybillSave.getTransLineType())) && count >= masterWaybill.getParcelQty()) {
throw new EmisBizError(EmisBizErrorType.FAIL, throw new EmisBizError(EmisBizErrorType.FAIL,
emisWaybillSave.getMasterBillCode() + "最多只能绑定" + masterWaybill.getParcelQty() + "个虚拟单"); emisWaybillSave.getMasterBillCode() + "最多只能绑定" + masterWaybill.getParcelQty() + "个虚拟单");
} }
@ -5139,12 +5173,16 @@ public class EmisBaseService {
} else { } else {
String masterBillCode = emisWaybillOld.getMasterBillCode(); String masterBillCode = emisWaybillOld.getMasterBillCode();
if (StringUtil.isNotBlank(masterBillCode)) { if (StringUtil.isNotBlank(masterBillCode)) {
emisWaybillSave.setMasterBillCode(" ");
String virtualBillCode = emisWaybillSave.getBillCode(); String virtualBillCode = emisWaybillSave.getBillCode();
EmisWaybill masterWaybill = emisWaybillMapper EmisWaybill masterWaybill = emisWaybillMapper
.selectEmisWaybillByBillCode(masterBillCode); .selectEmisWaybillByBillCode(masterBillCode);
List<String> filterVirtualRemark = Arrays.stream(masterWaybill.getVirtualRemark().split(",")) List<String> filterVirtualRemark = Arrays.stream(masterWaybill.getVirtualRemark().split(","))
.filter(i -> !i.equals(virtualBillCode)).collect(Collectors.toList()); .filter(i -> !i.equals(virtualBillCode)).collect(Collectors.toList());
String virtualRemark = String.join(",", filterVirtualRemark); String virtualRemark = String.join(",", filterVirtualRemark);
if(StringUtil.isBlank(virtualRemark)) {
virtualRemark = " ";
}
masterWaybill.setVirtualRemark(virtualRemark); masterWaybill.setVirtualRemark(virtualRemark);
emisWaybillMapper.updateEmisWaybill(masterWaybill); emisWaybillMapper.updateEmisWaybill(masterWaybill);
if (!"078".equals(emisWaybillSave.getTransLineType())) { if (!"078".equals(emisWaybillSave.getTransLineType())) {

View File

@ -47,6 +47,23 @@
<association property="nextSiteName" column="next_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/> <association property="nextSiteName" column="next_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
</resultMap> </resultMap>
<resultMap type="EmisTmsSiteBatch" id="EmisTransPlanRuleSimpleResult">
<result property="id" column="id"/>
<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="manager" column="manager"/>
<result property="supplierCode" column="supplier_code"/>
<result property="startDate" column="start_date"/>
<result property="endDate" column="end_date"/>
<result property="etd" column="etd" />
<collection property="batchDtlList" ofType="com.xdadan.erp.emis.domain.EmisTmsSiteBatchDtl">
<result property="billCode" column="bill_code"/>
</collection>
</resultMap>
<resultMap type="EmisTmsSiteBatch" id="EmisTmsSiteBatchDtlResult" extends="EmisTmsSiteBatchResult"> <resultMap type="EmisTmsSiteBatch" id="EmisTmsSiteBatchDtlResult" extends="EmisTmsSiteBatchResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="batchNo" column="batch_no" /> <result property="batchNo" column="batch_no" />
@ -493,8 +510,8 @@
</delete> </delete>
<!-- 根据运单号列表查询组批次信息 --> <!-- 根据运单号列表查询组批次信息 -->
<select id="selectEmisTmsSiteBatchListByBillCodes" resultMap="EmisTmsSiteBatchDtlResult"> <select id="selectEmisTmsSiteBatchListByBillCodes" resultMap="EmisTransPlanRuleSimpleResult">
select distinct b.id, b.batch_no, b.supplier_code, b.trans_line_type, b.product_type, b.trans_type, b.start_site_code, b.next_site_code, b.etd select distinct b.id, b.batch_no, b.supplier_code, b.trans_line_type, b.product_type, b.trans_type, b.start_site_code, b.next_site_code, b.etd, d.bill_code
from emis_tms_site_batch b from emis_tms_site_batch b
inner join emis_tms_site_batch_dtl d on b.batch_no = d.batch_no inner join emis_tms_site_batch_dtl d on b.batch_no = d.batch_no
where d.bill_code in where d.bill_code in

View File

@ -385,7 +385,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="emisTransPlanRule.supplierCode != null and emisTransPlanRule.supplierCode != ''">and ( FIND_IN_SET(#{emisTransPlanRule.supplierCode},r.supplier_code) )</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.startDate != null">and r.start_date = #{emisTransPlanRule.startDate}</if>
<if test="emisTransPlanRule.endDate != null">and r.end_date = #{emisTransPlanRule.endDate}</if> <if test="emisTransPlanRule.endDate != null">and r.end_date = #{emisTransPlanRule.endDate}</if>
and r.line_code not in ('014','012','077') -- and r.line_code not in ('014','012','077')
</where> </where>
order by id desc order by id desc
limit #{offset}, #{pageSize} limit #{offset}, #{pageSize}
@ -404,7 +404,7 @@ 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="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="startDate != null">and r.start_date = #{startDate}</if>
<if test="endDate != null">and r.end_date = #{endDate}</if> <if test="endDate != null">and r.end_date = #{endDate}</if>
and r.line_code not in ('014','012','077') -- and r.line_code not in ('014','012','077')
</where> </where>
</select> </select>

View File

@ -3201,8 +3201,8 @@
<if test="blSensitive != null and blSensitive != ''">bl_sensitive = #{blSensitive},</if> <if test="blSensitive != null and blSensitive != ''">bl_sensitive = #{blSensitive},</if>
<if test="blOverLong != null and blOverLong != ''">bl_over_long = #{blOverLong},</if> <if test="blOverLong != null and blOverLong != ''">bl_over_long = #{blOverLong},</if>
<if test="blVirtual != null and blVirtual != ''">bl_virtual = #{blVirtual},</if> <if test="blVirtual != null and blVirtual != ''">bl_virtual = #{blVirtual},</if>
master_bill_code= #{masterBillCode}, <if test="masterBillCode != null and masterBillCode != ''">master_bill_code= #{masterBillCode},</if>
virtual_remark= #{virtualRemark}, <if test="virtualRemark != null and virtualRemark != ''">virtual_remark= #{virtualRemark},</if>
<if test="blBill != null and blBill != ''">bl_bill = #{blBill},</if> <if test="blBill != null and blBill != ''">bl_bill = #{blBill},</if>
<if test="blBillText != null and blBillText != ''">bl_bill_text = #{blBillText},</if> <if test="blBillText != null and blBillText != ''">bl_bill_text = #{blBillText},</if>
<if test="blProfit != null and blProfit != ''">bl_profit = #{blProfit},</if> <if test="blProfit != null and blProfit != ''">bl_profit = #{blProfit},</if>
@ -3390,8 +3390,8 @@
<if test="blSensitive != null and blSensitive != ''">bl_sensitive = #{blSensitive},</if> <if test="blSensitive != null and blSensitive != ''">bl_sensitive = #{blSensitive},</if>
<if test="blOverLong != null and blOverLong != ''">bl_over_long = #{blOverLong},</if> <if test="blOverLong != null and blOverLong != ''">bl_over_long = #{blOverLong},</if>
<if test="blVirtual != null and blVirtual != ''">bl_virtual = #{blVirtual},</if> <if test="blVirtual != null and blVirtual != ''">bl_virtual = #{blVirtual},</if>
master_bill_code= #{masterBillCode}, <if test="masterBillCode != null and masterBillCode != ''">master_bill_code= #{masterBillCode},</if>
virtual_remark= #{virtualRemark}, <if test="virtualRemark != null and virtualRemark != ''">virtual_remark= #{virtualRemark},</if>
<if test="blBill != null and blBill != ''">bl_bill = #{blBill},</if> <if test="blBill != null and blBill != ''">bl_bill = #{blBill},</if>
<if test="blBillText != null and blBillText != ''">bl_bill_text = #{blBillText},</if> <if test="blBillText != null and blBillText != ''">bl_bill_text = #{blBillText},</if>
<if test="blProfit != null and blProfit != ''">bl_profit = #{blProfit},</if> <if test="blProfit != null and blProfit != ''">bl_profit = #{blProfit},</if>
@ -3825,8 +3825,7 @@
from emis_waybill a from emis_waybill a
where a.del_flag = '0' and where a.del_flag = '0' and
a.problem_type in (173,170) a.problem_type in (173,170)
and (master_bill_code is null or master_bill_code='') and (master_bill_code is null or master_bill_code='' or master_bill_code=' ')
-- and a.bill_code ='T708030039025903'
order by a.create_time desc order by a.create_time desc
limit #{offset}, #{pageSize} limit #{offset}, #{pageSize}
</select> </select>