demand: 批量修改报重精确指出重复信息

committer: heyu
This commit is contained in:
aike 2025-07-02 13:50:29 +08:00
parent 39800dac0c
commit 3480cf0de2
3 changed files with 28 additions and 8 deletions

View File

@ -4666,7 +4666,7 @@ public class EmisBaseService {
* @param supplierCode2 第二个供应商代码字符串
* @return 如果包含相同的供应商返回true,否则返回false
*/
private boolean compareSupplierCodes(String supplierCode1, String supplierCode2) {
public boolean compareSupplierCodes(String supplierCode1, String supplierCode2) {
if (supplierCode1 == null || supplierCode2 == null) {
return supplierCode1 == supplierCode2;
}

View File

@ -461,14 +461,22 @@ public class EmisTransPlanRuleServiceImpl extends EmisBaseService implements IEm
List<EmisTransPlanRule> existingRules = checkDuplicateDirectionForUpdate(emisTransPlanRule,
emisTransPlanRule.getStartSiteCode(), emisTransPlanRule.getNextSiteCode());
if (existingRules != null && !existingRules.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.EXISTS, "已存在相同的规则配置");
EmisTransPlanRule rule = existingRules.get(0);
String msg = String.format("已存在相同的规则配置,重复规则信息:线路名称[%s],产品类型[%s],起始网点[%s],下一网点[%s],供应商[%s]",
rule.getLineName(), rule.getProductTypeName(), rule.getStartSiteName(), rule.getNextSiteName(),
rule.getSupplierName());
throw new EmisBizError(EmisBizErrorType.EXISTS, msg);
}
// 检查反向规则(下一网点到起始网点)
List<EmisTransPlanRule> existingRules1 = checkDuplicateDirectionForUpdate(emisTransPlanRule,
emisTransPlanRule.getNextSiteCode(), emisTransPlanRule.getStartSiteCode());
if (existingRules1 != null && !existingRules1.isEmpty()) {
throw new EmisBizError(EmisBizErrorType.EXISTS, "已存在相同的规则配置");
EmisTransPlanRule rule = existingRules1.get(0);
String msg = String.format("已存在相同的规则配置,重复规则信息:线路名称[%s],产品类型[%s],起始网点[%s],下一网点[%s],供应商[%s]",
rule.getLineName(), rule.getProductTypeName(), rule.getStartSiteName(), rule.getNextSiteName(),
rule.getSupplierName());
throw new EmisBizError(EmisBizErrorType.EXISTS, msg);
}
}
@ -506,11 +514,9 @@ public class EmisTransPlanRuleServiceImpl extends EmisBaseService implements IEm
for (EmisTransPlanRule existingRule : allRules) {
// 检查产品类型是否有交集
boolean productTypeOverlap = hasOverlap(newProductType, existingRule.getProductType());
// 检查供应商编码是否有交集
boolean supplierCodeOverlap = hasOverlap(newSupplierCode, existingRule.getSupplierCode());
// 如果产品类型和供应商编码都有交集,则认为重复
if (productTypeOverlap && supplierCodeOverlap) {
// 如果产品类型有交集且供应商编码相同,则认为重复
if (productTypeOverlap && compareSupplierCodes(newSupplierCode, existingRule.getSupplierCode())) {
return Arrays.asList(existingRule);
}
}

View File

@ -181,8 +181,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="checkDuplicate" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
select r.*
select r.id, r.line_code, r.product_type, r.start_site_code,
s1.site_name as start_site_name, r.next_site_code, s2.site_name as next_site_name,
r.manager, r.supplier_code, r.start_date, r.end_date,
l.line_name,l.trans_manager,
(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,
(SELECT GROUP_CONCAT(p.prod_name ORDER BY FIND_IN_SET(p.prod_code, r.product_type))
FROM emis_trans_product p
WHERE FIND_IN_SET(p.prod_code, r.product_type)
AND p.del_flag = '0') as product_type_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'
left join emis_trans_line l on r.line_code = l.line_code and l.del_flag='0'
<where>
r.del_flag = '0'
<if test="lineCode != null and lineCode != ''">and r.line_code = #{lineCode}</if>