自定义板编号配置:1、前端入参自定义类型、时间类型value字段名调整;2、时间类型复位问题修复;

This commit is contained in:
gaoqr
2025-01-20 19:39:14 +08:00
parent 59083285de
commit 494cb02f28
4 changed files with 23 additions and 18 deletions
@@ -123,10 +123,10 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
// 遍历规则列表 // 遍历规则列表
for (CustomPlateNoRuleVO plateNoRule : orgCustomPlateNoRuleVOList) { for (CustomPlateNoRuleVO plateNoRule : orgCustomPlateNoRuleVOList) {
if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.CUSTOM.getRuleCode(), plateNoRule.getRuleCode())) { if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.CUSTOM.getRuleCode(), plateNoRule.getRuleCode())) {
plateDO.getCustomPlateNoBuilder().append(plateNoRule.getValue()); plateDO.getCustomPlateNoBuilder().append(plateNoRule.getStrValue());
} }
if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.DATE.getRuleCode(), plateNoRule.getRuleCode())) { if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.DATE.getRuleCode(), plateNoRule.getRuleCode())) {
plateDO.getCustomPlateNoBuilder().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getValue()))); plateDO.getCustomPlateNoBuilder().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getDateValue())));
} }
// 遍历规则生成服务列表,获取对应的规则服务 // 遍历规则生成服务列表,获取对应的规则服务
for (CustomPlateNoGenerateRuleService ruleService : ruleServices) { for (CustomPlateNoGenerateRuleService ruleService : ruleServices) {
@@ -21,9 +21,14 @@ public class CustomPlateNoRuleVO implements Serializable {
private String ruleCode; private String ruleCode;
/** /**
* 规则值 * 自定义类型字符串规则值
*/ */
private String value; private String strValue;
/**
* 时间类型字符串规则值
*/
private String dateValue;
/** /**
* 初始值 * 初始值
@@ -166,15 +166,15 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
private int resetByYear(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) { private int resetByYear(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
// 上一次的年 // 上一次的年
Integer lastYear = orgCustomPlateNoSeqRespDTO.getLastYear(); Integer lastYear = orgCustomPlateNoSeqRespDTO.getLastYear();
Integer initValue = plateNoRule.getInitValue();
String nowYearFormat = plateNoRule.getNow().format(YEAR_FORMATTER); String nowYearFormat = plateNoRule.getNow().format(YEAR_FORMATTER);
if (ObjectUtil.notEqual(String.valueOf(lastYear), nowYearFormat)) { if (ObjectUtil.notEqual(String.valueOf(lastYear), nowYearFormat)) {
int nowDayNum = Integer.parseInt(nowYearFormat);
// 跨年,把上一次的年设成当前年,后续不再跨年 // 跨年,把上一次的年设成当前年,后续不再跨年
orgCustomPlateNoSeqRespDTO.setLastYear(Integer.parseInt(nowYearFormat)); orgCustomPlateNoSeqRespDTO.setLastYear(nowDayNum);
// 复位 // 复位
return initValue; return nowDayNum;
} }
return curr + plateNoRule.getIncrementStep(); return curr;
} }
/** /**
@@ -188,15 +188,15 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
private int resetByMonth(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) { private int resetByMonth(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
// 上一次的月 // 上一次的月
Integer lastMonth = orgCustomPlateNoSeqRespDTO.getLastMonth(); Integer lastMonth = orgCustomPlateNoSeqRespDTO.getLastMonth();
Integer initValue = plateNoRule.getInitValue();
String nowMonthFormat = plateNoRule.getNow().format(MONTH_FORMATTER); String nowMonthFormat = plateNoRule.getNow().format(MONTH_FORMATTER);
if (ObjectUtil.notEqual(String.valueOf(lastMonth), nowMonthFormat)) { if (ObjectUtil.notEqual(String.valueOf(lastMonth), nowMonthFormat)) {
int nowDayNum = Integer.parseInt(nowMonthFormat);
// 跨月,把上一次的月设成当前月,后续不再跨月 // 跨月,把上一次的月设成当前月,后续不再跨月
orgCustomPlateNoSeqRespDTO.setLastMonth(Integer.parseInt(nowMonthFormat)); orgCustomPlateNoSeqRespDTO.setLastMonth(nowDayNum);
// 复位 // 复位
return initValue; return nowDayNum;
} }
return curr + plateNoRule.getIncrementStep(); return curr;
} }
/** /**
@@ -210,14 +210,14 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
private int resetByDay(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) { private int resetByDay(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
// 上一次的天 // 上一次的天
Integer lastDay = orgCustomPlateNoSeqRespDTO.getLastDay(); Integer lastDay = orgCustomPlateNoSeqRespDTO.getLastDay();
Integer initValue = plateNoRule.getInitValue();
String nowDayFormat = plateNoRule.getNow().format(DAY_FORMATTER); String nowDayFormat = plateNoRule.getNow().format(DAY_FORMATTER);
if (ObjectUtil.notEqual(String.valueOf(lastDay), nowDayFormat)) { if (ObjectUtil.notEqual(String.valueOf(lastDay), nowDayFormat)) {
int nowDayNum = Integer.parseInt(nowDayFormat);
// 跨月,把上一次的月设成当前月,后续不再跨月 // 跨月,把上一次的月设成当前月,后续不再跨月
orgCustomPlateNoSeqRespDTO.setLastDay(Integer.parseInt(nowDayFormat)); orgCustomPlateNoSeqRespDTO.setLastDay(nowDayNum);
// 复位 // 复位
return initValue; return nowDayNum;
} }
return curr + plateNoRule.getIncrementStep(); return curr;
} }
} }
@@ -113,7 +113,7 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
checkCustom(custBoardRuleCodeEnum, jsonObject); checkCustom(custBoardRuleCodeEnum, jsonObject);
// 3.时间格式校验 // 3.时间格式校验
checkDateFormat(custBoardRuleCodeEnum, jsonObject.getString("value"), dateTypeFormatDictList); checkDateFormat(custBoardRuleCodeEnum, jsonObject.getString("dateValue"), dateTypeFormatDictList);
// 4.序号类型校验数字和布尔类型 // 4.序号类型校验数字和布尔类型
checkNoType(custBoardRuleCodeEnum, jsonObject); checkNoType(custBoardRuleCodeEnum, jsonObject);
@@ -169,7 +169,7 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
*/ */
private void checkCustom(CustomPlateNoRuleCodeEnum custBoardRuleCodeEnum, JSONObject jsonObject) { private void checkCustom(CustomPlateNoRuleCodeEnum custBoardRuleCodeEnum, JSONObject jsonObject) {
if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.CUSTOM, custBoardRuleCodeEnum)) { if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.CUSTOM, custBoardRuleCodeEnum)) {
if (ObjectUtil.isEmpty(jsonObject.get("value"))) { if (ObjectUtil.isEmpty(jsonObject.get("strValue"))) {
throw ServiceExceptionUtil.exception(CUSTOM_PLATE_NO_RULE_CHECK_CUSTOM_VALUE_EMPTY_ERROR, jsonObject.get("ruleCode")); throw ServiceExceptionUtil.exception(CUSTOM_PLATE_NO_RULE_CHECK_CUSTOM_VALUE_EMPTY_ERROR, jsonObject.get("ruleCode"));
} }
} }