|
@@ -48,16 +48,16 @@ public class SysAutoCodePartServiceImpl implements IAutoCodePartService {
|
|
|
SysAutoCodeRule sysAutoCodeRule = sysAutoCodeRuleMapper.findById(sysAutoCodePart.getRuleId());
|
|
SysAutoCodeRule sysAutoCodeRule = sysAutoCodeRuleMapper.findById(sysAutoCodePart.getRuleId());
|
|
|
Integer maxLength = sysAutoCodeRule.getMaxLength();
|
|
Integer maxLength = sysAutoCodeRule.getMaxLength();
|
|
|
// 2.获取细则里的所有长度
|
|
// 2.获取细则里的所有长度
|
|
|
- long lengthSum = sysAutoCodePart.getPartLength();
|
|
|
|
|
|
|
+ Integer lengthSum = sysAutoCodePart.getPartLength();
|
|
|
|
|
|
|
|
SysAutoCodePart dto = new SysAutoCodePart();
|
|
SysAutoCodePart dto = new SysAutoCodePart();
|
|
|
dto.setRuleId(sysAutoCodePart.getRuleId());
|
|
dto.setRuleId(sysAutoCodePart.getRuleId());
|
|
|
List<SysAutoCodePart> sysAutoCodeParts = sysAutoCodePartMapper.selectSysAutoCodePartList(dto);
|
|
List<SysAutoCodePart> sysAutoCodeParts = sysAutoCodePartMapper.selectSysAutoCodePartList(dto);
|
|
|
if (!sysAutoCodeParts.isEmpty()) {
|
|
if (!sysAutoCodeParts.isEmpty()) {
|
|
|
long sum = sysAutoCodeParts.stream().mapToLong(SysAutoCodePart::getPartLength).sum();
|
|
long sum = sysAutoCodeParts.stream().mapToLong(SysAutoCodePart::getPartLength).sum();
|
|
|
- lengthSum = lengthSum + sum;
|
|
|
|
|
|
|
+ lengthSum = Math.toIntExact(lengthSum + sum);
|
|
|
}
|
|
}
|
|
|
- Assert.isFalse(maxLength < lengthSum, "最大长度" + maxLength + "小于分段长度总和" + lengthSum + ",请扩容最大长度!");
|
|
|
|
|
|
|
+ Assert.isFalse(maxLength != null && lengthSum != null && maxLength < lengthSum, "最大长度" + maxLength + "小于分段长度总和" + lengthSum + ",请扩容最大长度!");
|
|
|
return sysAutoCodePartMapper.add(sysAutoCodePart);
|
|
return sysAutoCodePartMapper.add(sysAutoCodePart);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -67,16 +67,16 @@ public class SysAutoCodePartServiceImpl implements IAutoCodePartService {
|
|
|
SysAutoCodeRule sysAutoCodeRule = sysAutoCodeRuleMapper.findById(sysAutoCodePart.getRuleId());
|
|
SysAutoCodeRule sysAutoCodeRule = sysAutoCodeRuleMapper.findById(sysAutoCodePart.getRuleId());
|
|
|
Integer maxLength = sysAutoCodeRule.getMaxLength();
|
|
Integer maxLength = sysAutoCodeRule.getMaxLength();
|
|
|
// 2.获取细则里的所有长度
|
|
// 2.获取细则里的所有长度
|
|
|
- long lengthSum = sysAutoCodePart.getPartLength();
|
|
|
|
|
|
|
+ Integer lengthSum = sysAutoCodePart.getPartLength();
|
|
|
|
|
|
|
|
SysAutoCodePart dto = new SysAutoCodePart();
|
|
SysAutoCodePart dto = new SysAutoCodePart();
|
|
|
dto.setRuleId(sysAutoCodePart.getRuleId());
|
|
dto.setRuleId(sysAutoCodePart.getRuleId());
|
|
|
List<SysAutoCodePart> sysAutoCodeParts = sysAutoCodePartMapper.selectSysAutoCodePartList(dto);
|
|
List<SysAutoCodePart> sysAutoCodeParts = sysAutoCodePartMapper.selectSysAutoCodePartList(dto);
|
|
|
if (!sysAutoCodeParts.isEmpty()) {
|
|
if (!sysAutoCodeParts.isEmpty()) {
|
|
|
long sum = sysAutoCodeParts.stream().filter(o -> !Objects.equals(o.getPartId(), sysAutoCodePart.getPartId())).mapToLong(SysAutoCodePart::getPartLength).sum();
|
|
long sum = sysAutoCodeParts.stream().filter(o -> !Objects.equals(o.getPartId(), sysAutoCodePart.getPartId())).mapToLong(SysAutoCodePart::getPartLength).sum();
|
|
|
- lengthSum = lengthSum + sum;
|
|
|
|
|
|
|
+ lengthSum = Math.toIntExact(lengthSum + sum);
|
|
|
}
|
|
}
|
|
|
- Assert.isFalse(maxLength < lengthSum, "最大长度" + maxLength + "小于分段长度总和" + lengthSum + ",请扩容最大长度!");
|
|
|
|
|
|
|
+ Assert.isFalse(maxLength != null && lengthSum != null && maxLength < lengthSum, "最大长度" + maxLength + "小于分段长度总和" + lengthSum + ",请扩容最大长度!");
|
|
|
return sysAutoCodePartMapper.updateSysAutoCodePart(sysAutoCodePart);
|
|
return sysAutoCodePartMapper.updateSysAutoCodePart(sysAutoCodePart);
|
|
|
}
|
|
}
|
|
|
|
|
|