mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 13:42:07 +08:00
自定义板编号生成功能调整
This commit is contained in:
+21
-6
@@ -60,7 +60,9 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
|||||||
CustomPlateNoGenerateConfigVO generateConfig = getGenerateConfig(orderId);
|
CustomPlateNoGenerateConfigVO generateConfig = getGenerateConfig(orderId);
|
||||||
// 如果没有查到配置规则就不做后续生成操作了
|
// 如果没有查到配置规则就不做后续生成操作了
|
||||||
List<CustomPlateNoRuleVO> orgCustomPlateNoRuleVOList = generateConfig.getOrgCustomPlateNoRuleVOList();
|
List<CustomPlateNoRuleVO> orgCustomPlateNoRuleVOList = generateConfig.getOrgCustomPlateNoRuleVOList();
|
||||||
if (CollUtil.isEmpty(orgCustomPlateNoRuleVOList)) {
|
// 如果没有查到机构下配置就不做后续生成操作了
|
||||||
|
Long orgCustomPlateNoConfigId = generateConfig.getOrgCustomPlateNoConfigId();
|
||||||
|
if (ObjectUtil.isNull(orgCustomPlateNoConfigId) || CollUtil.isEmpty(orgCustomPlateNoRuleVOList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,12 +71,15 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
|||||||
orgCustomPlateNoRuleVOList.forEach(rule -> rule.setNow(now));
|
orgCustomPlateNoRuleVOList.forEach(rule -> rule.setNow(now));
|
||||||
|
|
||||||
// 2、遍历小板列表,生成板编号
|
// 2、遍历小板列表,生成板编号
|
||||||
for (PlateDO plateDO : plateDOList) {
|
for (int i = 0; i < plateDOList.size(); i++) {
|
||||||
loopGenerateNo(orderId, plateDO, orgCustomPlateNoRuleVOList, generateConfig);
|
PlateDO plateDO = plateDOList.get(i);
|
||||||
|
loopGenerateNo(orderId, plateDO, orgCustomPlateNoRuleVOList, generateConfig, i == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3、保存生产单序号json
|
// 3、保存生产单序号json、设置生产单所用配置id
|
||||||
orderDO.setCustomPlatenoSeq(JSON.toJSONString(generateConfig.getOrderCustomPlateNoSeqVO()));
|
orderDO.setCustomPlatenoSeq(JSON.toJSONString(generateConfig.getOrderCustomPlateNoSeqVO()));
|
||||||
|
orderDO.setCustomPlatenoConfigId(orgCustomPlateNoConfigId);
|
||||||
|
// 机构下序号配置同步
|
||||||
CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO = generateConfig.getOrgCustomPlateNoSeqRespDTO();
|
CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO = generateConfig.getOrgCustomPlateNoSeqRespDTO();
|
||||||
orgCustomPlateNoSeqRespDTO.setLastOrderNo(orderId);
|
orgCustomPlateNoSeqRespDTO.setLastOrderNo(orderId);
|
||||||
orgCustomPlateNoSeqRespDTO.setLastYear(Integer.parseInt(YEAR_FORMATTER.format(now)));
|
orgCustomPlateNoSeqRespDTO.setLastYear(Integer.parseInt(YEAR_FORMATTER.format(now)));
|
||||||
@@ -94,8 +99,9 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
|||||||
* @param plateDO
|
* @param plateDO
|
||||||
* @param orgCustomPlateNoRuleVOList
|
* @param orgCustomPlateNoRuleVOList
|
||||||
* @param generateConfig
|
* @param generateConfig
|
||||||
|
* @param
|
||||||
*/
|
*/
|
||||||
private void loopGenerateNo(Long orderId, PlateDO plateDO, List<CustomPlateNoRuleVO> orgCustomPlateNoRuleVOList, CustomPlateNoGenerateConfigVO generateConfig) {
|
private void loopGenerateNo(Long orderId, PlateDO plateDO, List<CustomPlateNoRuleVO> orgCustomPlateNoRuleVOList, CustomPlateNoGenerateConfigVO generateConfig, boolean firstPlate) {
|
||||||
// 遍历规则列表
|
// 遍历规则列表
|
||||||
for (CustomPlateNoRuleVO plateNoRule : orgCustomPlateNoRuleVOList) {
|
for (CustomPlateNoRuleVO plateNoRule : orgCustomPlateNoRuleVOList) {
|
||||||
if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.CUSTOM.getRuleCode(), plateNoRule.getRuleCode())) {
|
if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.CUSTOM.getRuleCode(), plateNoRule.getRuleCode())) {
|
||||||
@@ -107,7 +113,7 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
|||||||
// 遍历规则生成服务列表,获取对应的规则服务
|
// 遍历规则生成服务列表,获取对应的规则服务
|
||||||
for (CustomPlateNoGenerateRuleService ruleService : ruleServices) {
|
for (CustomPlateNoGenerateRuleService ruleService : ruleServices) {
|
||||||
if (ruleService.match(plateNoRule.getRuleCode())) {
|
if (ruleService.match(plateNoRule.getRuleCode())) {
|
||||||
generateConfig = ruleService.generateNo(orderId, plateNoRule, generateConfig, plateDO);
|
generateConfig = ruleService.generateNo(orderId, plateNoRule, generateConfig, plateDO, firstPlate);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,6 +121,14 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
|||||||
plateDO.setPlateNo(plateDO.getCustomPlateNo().toString());
|
plateDO.setPlateNo(plateDO.getCustomPlateNo().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据生产单id获取生成需要的配置
|
||||||
|
*
|
||||||
|
* @param orderId
|
||||||
|
* @return 1、生产单下的序号
|
||||||
|
* 2、机构下的序号
|
||||||
|
* 3、机构下全局配置的规则
|
||||||
|
*/
|
||||||
private CustomPlateNoGenerateConfigVO getGenerateConfig(Long orderId) {
|
private CustomPlateNoGenerateConfigVO getGenerateConfig(Long orderId) {
|
||||||
// 生成自定义版编号所需配置
|
// 生成自定义版编号所需配置
|
||||||
CustomPlateNoGenerateConfigVO customPlateNoGenerateConfigVO = new CustomPlateNoGenerateConfigVO();
|
CustomPlateNoGenerateConfigVO customPlateNoGenerateConfigVO = new CustomPlateNoGenerateConfigVO();
|
||||||
@@ -132,6 +146,7 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
|||||||
customPlateNoRuleVOS = Optional.ofNullable(orgCustomPlateNoConfig)
|
customPlateNoRuleVOS = Optional.ofNullable(orgCustomPlateNoConfig)
|
||||||
.map(config -> JSON.parseArray(config.getSetting(), CustomPlateNoRuleVO.class))
|
.map(config -> JSON.parseArray(config.getSetting(), CustomPlateNoRuleVO.class))
|
||||||
.orElse(List.of());
|
.orElse(List.of());
|
||||||
|
customPlateNoGenerateConfigVO.setOrgCustomPlateNoConfigId(orgCustomPlateNoConfig.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
OrderDO order = orderService.getOrder(orderId);
|
OrderDO order = orderService.getOrder(orderId);
|
||||||
|
|||||||
+5
@@ -24,6 +24,11 @@ public class CustomPlateNoGenerateConfigVO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private List<CustomPlateNoRuleVO> orgCustomPlateNoRuleVOList;
|
private List<CustomPlateNoRuleVO> orgCustomPlateNoRuleVOList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构下自定义板编号-系统配置id
|
||||||
|
*/
|
||||||
|
private Long orgCustomPlateNoConfigId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机构下的自定义板编号序号
|
* 机构下的自定义板编号序号
|
||||||
*/
|
*/
|
||||||
|
|||||||
+18
-18
@@ -33,22 +33,6 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
|||||||
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.BODYNO.getRuleCode(), ruleCode);
|
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.BODYNO.getRuleCode(), ruleCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
|
||||||
// 初始化配置
|
|
||||||
initConfig(generateConfig);
|
|
||||||
// 按复位模式走不同的生成方式
|
|
||||||
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(plateNoRule.getResetMode());
|
|
||||||
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
|
|
||||||
generateConfig = generateNoByOrderResetMode(orderId, plateNoRule, generateConfig, plateDO);
|
|
||||||
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
|
|
||||||
generateConfig = generateNoByRoomResetMode(plateNoRule, generateConfig, plateDO);
|
|
||||||
} else {
|
|
||||||
throw ServiceExceptionUtil.exception(CUSTOM_PLATENO_GENERATE_BODY_RULE_NOT_SUPPORT_RESETMODE, plateNoRule.getResetMode());
|
|
||||||
}
|
|
||||||
return generateConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化生成所需配置
|
* 初始化生成所需配置
|
||||||
*
|
*
|
||||||
@@ -72,6 +56,22 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||||
|
// 初始化配置
|
||||||
|
initConfig(generateConfig);
|
||||||
|
// 按复位模式走不同的生成方式
|
||||||
|
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(plateNoRule.getResetMode());
|
||||||
|
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
|
||||||
|
generateConfig = generateNoByOrderResetMode(orderId, plateNoRule, generateConfig, plateDO, firstPlate);
|
||||||
|
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
|
||||||
|
generateConfig = generateNoByRoomResetMode(plateNoRule, generateConfig, plateDO);
|
||||||
|
} else {
|
||||||
|
throw ServiceExceptionUtil.exception(CUSTOM_PLATENO_GENERATE_BODY_RULE_NOT_SUPPORT_RESETMODE, plateNoRule.getResetMode());
|
||||||
|
}
|
||||||
|
return generateConfig;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按生产单复位模式下的板编号生成
|
* 按生产单复位模式下的板编号生成
|
||||||
*
|
*
|
||||||
@@ -81,7 +81,7 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
|||||||
* @param plateDO 板件列表
|
* @param plateDO 板件列表
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||||
Integer incrementStep = plateNoRule.getIncrementStep();
|
Integer incrementStep = plateNoRule.getIncrementStep();
|
||||||
Integer initValue = plateNoRule.getInitValue() - incrementStep;
|
Integer initValue = plateNoRule.getInitValue() - incrementStep;
|
||||||
// 生产单下的序号
|
// 生产单下的序号
|
||||||
@@ -94,7 +94,7 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
|||||||
List<OrderCustomPlateNoSeqBodyVO> bodys = orderCustomPlateNoSeqVO.getBodys();
|
List<OrderCustomPlateNoSeqBodyVO> bodys = orderCustomPlateNoSeqVO.getBodys();
|
||||||
// 上次导入的生产单号
|
// 上次导入的生产单号
|
||||||
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
||||||
if (ObjectUtil.isNotNull(lastOrderNo) && ObjectUtil.notEqual(orderId, lastOrderNo)) {
|
if (firstPlate && (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo))) {
|
||||||
// 跨单复位到初始值
|
// 跨单复位到初始值
|
||||||
orderBodyNoSeq = initValue;
|
orderBodyNoSeq = initValue;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -23,11 +23,13 @@ public interface CustomPlateNoGenerateRuleService {
|
|||||||
* 生成编号
|
* 生成编号
|
||||||
*
|
*
|
||||||
* @param orderId 生产单号
|
* @param orderId 生产单号
|
||||||
* @param plateDO 板材列表
|
* @param plateNoRule 生成规则
|
||||||
* @param generateConfig 生成所需要的配置
|
* @param generateConfig 生成所需要的配置
|
||||||
|
* @param plateDO 板材列表
|
||||||
|
* @param firstPlate 是否循环的第一块板,只有第一块板需要做是否跨单判断,后续都是一个单内
|
||||||
* @return 生成后改变的配置
|
* @return 生成后改变的配置
|
||||||
*/
|
*/
|
||||||
CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO);
|
CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 左补零
|
* 左补零
|
||||||
|
|||||||
+32
-24
@@ -11,7 +11,6 @@ import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
|||||||
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
|
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -49,7 +48,7 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||||
// 初始化配置
|
// 初始化配置
|
||||||
initConfig(generateConfig);
|
initConfig(generateConfig);
|
||||||
// 生产单下的序号
|
// 生产单下的序号
|
||||||
@@ -68,8 +67,7 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
int currOrderNoSeq = Optional.ofNullable(orgCustomPlateNoSeqRespDTO.getOrderNoSeq()).orElse(plateNoRule.getInitValue() - plateNoRule.getIncrementStep());
|
int currOrderNoSeq = Optional.ofNullable(orgCustomPlateNoSeqRespDTO.getOrderNoSeq()).orElse(plateNoRule.getInitValue() - plateNoRule.getIncrementStep());
|
||||||
// 上次导入的生产单号
|
// 上次导入的生产单号
|
||||||
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
||||||
if (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo)) {
|
if (firstPlate && (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo))) {
|
||||||
// 跨单
|
|
||||||
// 根据复位模式计算序号
|
// 根据复位模式计算序号
|
||||||
currOrderNoSeq = generateNoByResetMode(currOrderNoSeq, ResetModeEnum.getByMode(plateNoRule.getResetMode()), plateNoRule, orgCustomPlateNoSeqRespDTO);
|
currOrderNoSeq = generateNoByResetMode(currOrderNoSeq, ResetModeEnum.getByMode(plateNoRule.getResetMode()), plateNoRule, orgCustomPlateNoSeqRespDTO);
|
||||||
}
|
}
|
||||||
@@ -93,20 +91,15 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
* @return 循环累加后的序号
|
* @return 循环累加后的序号
|
||||||
*/
|
*/
|
||||||
private int generateNoByResetMode(int orderNoSeq, ResetModeEnum resetModeEnum, CustomPlateNoRuleVO plateNoRule, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO) {
|
private int generateNoByResetMode(int orderNoSeq, ResetModeEnum resetModeEnum, CustomPlateNoRuleVO plateNoRule, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO) {
|
||||||
// 机构全局序号下的上一次年月日记录
|
|
||||||
int year = orgCustomPlateNoSeqRespDTO.getLastYear();
|
|
||||||
int month = orgCustomPlateNoSeqRespDTO.getLastMonth();
|
|
||||||
int day = orgCustomPlateNoSeqRespDTO.getLastDay();
|
|
||||||
|
|
||||||
// 根据不同复位模式生成序号
|
// 根据不同复位模式生成序号
|
||||||
if (ObjectUtil.equal(ResetModeEnum.DIGIT, resetModeEnum)) {
|
if (ObjectUtil.equal(ResetModeEnum.DIGIT, resetModeEnum)) {
|
||||||
orderNoSeq = resetByLength(orderNoSeq, plateNoRule);
|
orderNoSeq = resetByLength(orderNoSeq, plateNoRule);
|
||||||
} else if (ObjectUtil.equal(ResetModeEnum.YEAR, resetModeEnum)) {
|
} else if (ObjectUtil.equal(ResetModeEnum.YEAR, resetModeEnum)) {
|
||||||
orderNoSeq = resetByYear(orderNoSeq, year, plateNoRule);
|
orderNoSeq = resetByYear(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||||
} else if (ObjectUtil.equal(ResetModeEnum.MONTH, resetModeEnum)) {
|
} else if (ObjectUtil.equal(ResetModeEnum.MONTH, resetModeEnum)) {
|
||||||
orderNoSeq = resetByMonth(orderNoSeq, month, plateNoRule);
|
orderNoSeq = resetByMonth(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||||
} else if (ObjectUtil.equal(ResetModeEnum.DAY, resetModeEnum)) {
|
} else if (ObjectUtil.equal(ResetModeEnum.DAY, resetModeEnum)) {
|
||||||
orderNoSeq = resetByDay(orderNoSeq, day, plateNoRule);
|
orderNoSeq = resetByDay(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||||
} else {
|
} else {
|
||||||
throw ServiceExceptionUtil.exception(CUSTOM_PLATENO_GENERATE_ORDERNO_RULE_NOT_SUPPORT_RESETMODE, plateNoRule.getResetMode());
|
throw ServiceExceptionUtil.exception(CUSTOM_PLATENO_GENERATE_ORDERNO_RULE_NOT_SUPPORT_RESETMODE, plateNoRule.getResetMode());
|
||||||
}
|
}
|
||||||
@@ -136,14 +129,19 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
* 按年复位
|
* 按年复位
|
||||||
*
|
*
|
||||||
* @param curr
|
* @param curr
|
||||||
* @param year
|
* @param orgCustomPlateNoSeqRespDTO
|
||||||
* @param plateNoRule
|
* @param plateNoRule
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int resetByYear(int curr, int year, CustomPlateNoRuleVO plateNoRule) {
|
private int resetByYear(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||||
LocalDateTime now = plateNoRule.getNow();
|
// 上一次的年
|
||||||
|
Integer lastYear = orgCustomPlateNoSeqRespDTO.getLastYear();
|
||||||
Integer initValue = plateNoRule.getInitValue();
|
Integer initValue = plateNoRule.getInitValue();
|
||||||
if (ObjectUtil.notEqual(String.valueOf(year), now.format(YEAR_FORMATTER))) {
|
String nowYearFormat = plateNoRule.getNow().format(YEAR_FORMATTER);
|
||||||
|
if (ObjectUtil.notEqual(String.valueOf(lastYear), nowYearFormat)) {
|
||||||
|
// 跨年,把上一次的年设成当前年,后续不再跨年
|
||||||
|
orgCustomPlateNoSeqRespDTO.setLastYear(Integer.parseInt(nowYearFormat));
|
||||||
|
// 复位
|
||||||
return initValue;
|
return initValue;
|
||||||
}
|
}
|
||||||
return curr + plateNoRule.getIncrementStep();
|
return curr + plateNoRule.getIncrementStep();
|
||||||
@@ -153,14 +151,19 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
* 按月复位
|
* 按月复位
|
||||||
*
|
*
|
||||||
* @param curr
|
* @param curr
|
||||||
* @param month
|
* @param orgCustomPlateNoSeqRespDTO
|
||||||
* @param plateNoRule
|
* @param plateNoRule
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int resetByMonth(int curr, int month, CustomPlateNoRuleVO plateNoRule) {
|
private int resetByMonth(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||||
LocalDateTime now = plateNoRule.getNow();
|
// 上一次的月
|
||||||
|
Integer lastMonth = orgCustomPlateNoSeqRespDTO.getLastMonth();
|
||||||
Integer initValue = plateNoRule.getInitValue();
|
Integer initValue = plateNoRule.getInitValue();
|
||||||
if (ObjectUtil.notEqual(String.valueOf(month), now.format(MONTH_FORMATTER))) {
|
String nowMonthFormat = plateNoRule.getNow().format(MONTH_FORMATTER);
|
||||||
|
if (ObjectUtil.notEqual(String.valueOf(lastMonth), nowMonthFormat)) {
|
||||||
|
// 跨月,把上一次的月设成当前月,后续不再跨月
|
||||||
|
orgCustomPlateNoSeqRespDTO.setLastMonth(Integer.parseInt(nowMonthFormat));
|
||||||
|
// 复位
|
||||||
return initValue;
|
return initValue;
|
||||||
}
|
}
|
||||||
return curr + plateNoRule.getIncrementStep();
|
return curr + plateNoRule.getIncrementStep();
|
||||||
@@ -170,14 +173,19 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
* 按天复位
|
* 按天复位
|
||||||
*
|
*
|
||||||
* @param curr
|
* @param curr
|
||||||
* @param day
|
* @param orgCustomPlateNoSeqRespDTO
|
||||||
* @param plateNoRule
|
* @param plateNoRule
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int resetByDay(int curr, int day, CustomPlateNoRuleVO plateNoRule) {
|
private int resetByDay(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||||
LocalDateTime now = plateNoRule.getNow();
|
// 上一次的天
|
||||||
|
Integer lastDay = orgCustomPlateNoSeqRespDTO.getLastDay();
|
||||||
Integer initValue = plateNoRule.getInitValue();
|
Integer initValue = plateNoRule.getInitValue();
|
||||||
if (ObjectUtil.notEqual(String.valueOf(day), now.format(DAY_FORMATTER))) {
|
String nowDayFormat = plateNoRule.getNow().format(DAY_FORMATTER);
|
||||||
|
if (ObjectUtil.notEqual(String.valueOf(lastDay), nowDayFormat)) {
|
||||||
|
// 跨月,把上一次的月设成当前月,后续不再跨月
|
||||||
|
orgCustomPlateNoSeqRespDTO.setLastDay(Integer.parseInt(nowDayFormat));
|
||||||
|
// 复位
|
||||||
return initValue;
|
return initValue;
|
||||||
}
|
}
|
||||||
return curr + plateNoRule.getIncrementStep();
|
return curr + plateNoRule.getIncrementStep();
|
||||||
|
|||||||
+53
-44
@@ -14,7 +14,6 @@ import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
|||||||
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
|
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -38,14 +37,32 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.PLATENO.getRuleCode(), ruleCode);
|
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.PLATENO.getRuleCode(), ruleCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化生成所需配置
|
||||||
|
*
|
||||||
|
* @param generateConfigVO
|
||||||
|
*/
|
||||||
|
private void initConfig(CustomPlateNoGenerateConfigVO generateConfigVO) {
|
||||||
|
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfigVO.getOrderCustomPlateNoSeqVO();
|
||||||
|
if (ObjectUtil.isNull(orderCustomPlateNoSeqVO)) {
|
||||||
|
orderCustomPlateNoSeqVO = new OrderCustomPlateNoSeqVO();
|
||||||
|
generateConfigVO.setOrderCustomPlateNoSeqVO(orderCustomPlateNoSeqVO);
|
||||||
|
}
|
||||||
|
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
||||||
|
if (CollUtil.isEmpty(rooms)) {
|
||||||
|
rooms = new ArrayList<>();
|
||||||
|
orderCustomPlateNoSeqVO.setRooms(rooms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||||
// 初始化配置
|
// 初始化配置
|
||||||
initConfig(generateConfig);
|
initConfig(generateConfig);
|
||||||
// 按复位模式走不同的生成方式
|
// 按复位模式走不同的生成方式
|
||||||
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(plateNoRule.getResetMode());
|
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(plateNoRule.getResetMode());
|
||||||
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
|
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
|
||||||
return generateNoByOrderResetMode(orderId, plateNoRule, generateConfig, plateDO);
|
return generateNoByOrderResetMode(orderId, plateNoRule, generateConfig, plateDO, firstPlate);
|
||||||
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
|
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
|
||||||
return generateNoByRoomResetMode(plateNoRule, generateConfig, plateDO);
|
return generateNoByRoomResetMode(plateNoRule, generateConfig, plateDO);
|
||||||
} else if (ObjectUtil.equal(ResetModeEnum.BODY, resetModeEnum)) {
|
} else if (ObjectUtil.equal(ResetModeEnum.BODY, resetModeEnum)) {
|
||||||
@@ -63,10 +80,6 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
private CustomPlateNoGenerateConfigVO generateNoByDateResetMode(ResetModeEnum resetModeEnum, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
private CustomPlateNoGenerateConfigVO generateNoByDateResetMode(ResetModeEnum resetModeEnum, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
||||||
// 机构下的自定义板编号序号
|
// 机构下的自定义板编号序号
|
||||||
CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO = generateConfig.getOrgCustomPlateNoSeqRespDTO();
|
CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO = generateConfig.getOrgCustomPlateNoSeqRespDTO();
|
||||||
// 上一次自定义编号生成的年月日
|
|
||||||
int year = orgCustomPlateNoSeqRespDTO.getLastYear();
|
|
||||||
int month = orgCustomPlateNoSeqRespDTO.getLastMonth();
|
|
||||||
int day = orgCustomPlateNoSeqRespDTO.getLastDay();
|
|
||||||
// 从全局配置获取当前序号,取不到用初始值
|
// 从全局配置获取当前序号,取不到用初始值
|
||||||
Integer orderNoSeq = orgCustomPlateNoSeqRespDTO.getPlateNoSeq();
|
Integer orderNoSeq = orgCustomPlateNoSeqRespDTO.getPlateNoSeq();
|
||||||
if (ObjectUtil.isNull(orderNoSeq)) {
|
if (ObjectUtil.isNull(orderNoSeq)) {
|
||||||
@@ -74,14 +87,13 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ObjectUtil.equal(ResetModeEnum.YEAR, resetModeEnum)) {
|
if (ObjectUtil.equal(ResetModeEnum.YEAR, resetModeEnum)) {
|
||||||
orderNoSeq = resetByYear(orderNoSeq, year, plateNoRule);
|
orderNoSeq = resetByYear(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||||
} else if (ObjectUtil.equal(ResetModeEnum.MONTH, resetModeEnum)) {
|
} else if (ObjectUtil.equal(ResetModeEnum.MONTH, resetModeEnum)) {
|
||||||
orderNoSeq = resetByMonth(orderNoSeq, month, plateNoRule);
|
orderNoSeq = resetByMonth(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||||
} else if (ObjectUtil.equal(ResetModeEnum.DAY, resetModeEnum)) {
|
} else if (ObjectUtil.equal(ResetModeEnum.DAY, resetModeEnum)) {
|
||||||
orderNoSeq = resetByDay(orderNoSeq, day, plateNoRule);
|
orderNoSeq = resetByDay(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||||
}
|
}
|
||||||
// 跨板件累加步长,补零
|
// 补零
|
||||||
orderNoSeq += plateNoRule.getIncrementStep();
|
|
||||||
String noPartAfterFillZero = fillZero(orderNoSeq, plateNoRule);
|
String noPartAfterFillZero = fillZero(orderNoSeq, plateNoRule);
|
||||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
||||||
|
|
||||||
@@ -97,7 +109,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
* @param generateConfig
|
* @param generateConfig
|
||||||
* @param plateDO
|
* @param plateDO
|
||||||
*/
|
*/
|
||||||
private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||||
Integer incrementStep = plateNoRule.getIncrementStep();
|
Integer incrementStep = plateNoRule.getIncrementStep();
|
||||||
Integer initValue = plateNoRule.getInitValue() - incrementStep;
|
Integer initValue = plateNoRule.getInitValue() - incrementStep;
|
||||||
// 生产单下的序号
|
// 生产单下的序号
|
||||||
@@ -108,7 +120,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
Integer orderPlateNoSeq = Optional.ofNullable(orderCustomPlateNoSeqVO.getPlateNoSeq()).orElse(initValue);
|
Integer orderPlateNoSeq = Optional.ofNullable(orderCustomPlateNoSeqVO.getPlateNoSeq()).orElse(initValue);
|
||||||
// 上次导入的生产单号
|
// 上次导入的生产单号
|
||||||
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
||||||
if (ObjectUtil.isNotNull(lastOrderNo) && ObjectUtil.notEqual(orderId, lastOrderNo)) {
|
if (firstPlate && (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo))) {
|
||||||
// 跨单复位到初始值
|
// 跨单复位到初始值
|
||||||
orderPlateNoSeq = initValue;
|
orderPlateNoSeq = initValue;
|
||||||
}
|
}
|
||||||
@@ -240,36 +252,23 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化生成所需配置
|
|
||||||
*
|
|
||||||
* @param generateConfigVO
|
|
||||||
*/
|
|
||||||
private void initConfig(CustomPlateNoGenerateConfigVO generateConfigVO) {
|
|
||||||
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfigVO.getOrderCustomPlateNoSeqVO();
|
|
||||||
if (ObjectUtil.isNull(orderCustomPlateNoSeqVO)) {
|
|
||||||
orderCustomPlateNoSeqVO = new OrderCustomPlateNoSeqVO();
|
|
||||||
generateConfigVO.setOrderCustomPlateNoSeqVO(orderCustomPlateNoSeqVO);
|
|
||||||
}
|
|
||||||
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
|
||||||
if (CollUtil.isEmpty(rooms)) {
|
|
||||||
rooms = new ArrayList<>();
|
|
||||||
orderCustomPlateNoSeqVO.setRooms(rooms);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按年复位
|
* 按年复位
|
||||||
*
|
*
|
||||||
* @param curr
|
* @param curr
|
||||||
* @param year
|
* @param orgCustomPlateNoSeqRespDTO
|
||||||
* @param plateNoRule
|
* @param plateNoRule
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int resetByYear(int curr, int year, CustomPlateNoRuleVO plateNoRule) {
|
private int resetByYear(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||||
LocalDateTime now = plateNoRule.getNow();
|
// 上一次的年
|
||||||
|
Integer lastYear = orgCustomPlateNoSeqRespDTO.getLastYear();
|
||||||
Integer initValue = plateNoRule.getInitValue();
|
Integer initValue = plateNoRule.getInitValue();
|
||||||
if (ObjectUtil.notEqual(String.valueOf(year), now.format(YEAR_FORMATTER))) {
|
String nowYearFormat = plateNoRule.getNow().format(YEAR_FORMATTER);
|
||||||
|
if (ObjectUtil.notEqual(String.valueOf(lastYear), nowYearFormat)) {
|
||||||
|
// 跨年,把上一次的年设成当前年,后续不再跨年
|
||||||
|
orgCustomPlateNoSeqRespDTO.setLastYear(Integer.parseInt(nowYearFormat));
|
||||||
|
// 复位
|
||||||
return initValue;
|
return initValue;
|
||||||
}
|
}
|
||||||
return curr + plateNoRule.getIncrementStep();
|
return curr + plateNoRule.getIncrementStep();
|
||||||
@@ -279,14 +278,19 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
* 按月复位
|
* 按月复位
|
||||||
*
|
*
|
||||||
* @param curr
|
* @param curr
|
||||||
* @param month
|
* @param orgCustomPlateNoSeqRespDTO
|
||||||
* @param plateNoRule
|
* @param plateNoRule
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int resetByMonth(int curr, int month, CustomPlateNoRuleVO plateNoRule) {
|
private int resetByMonth(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||||
LocalDateTime now = plateNoRule.getNow();
|
// 上一次的月
|
||||||
|
Integer lastMonth = orgCustomPlateNoSeqRespDTO.getLastMonth();
|
||||||
Integer initValue = plateNoRule.getInitValue();
|
Integer initValue = plateNoRule.getInitValue();
|
||||||
if (ObjectUtil.notEqual(String.valueOf(month), now.format(MONTH_FORMATTER))) {
|
String nowMonthFormat = plateNoRule.getNow().format(MONTH_FORMATTER);
|
||||||
|
if (ObjectUtil.notEqual(String.valueOf(lastMonth), nowMonthFormat)) {
|
||||||
|
// 跨月,把上一次的月设成当前月,后续不再跨月
|
||||||
|
orgCustomPlateNoSeqRespDTO.setLastMonth(Integer.parseInt(nowMonthFormat));
|
||||||
|
// 复位
|
||||||
return initValue;
|
return initValue;
|
||||||
}
|
}
|
||||||
return curr + plateNoRule.getIncrementStep();
|
return curr + plateNoRule.getIncrementStep();
|
||||||
@@ -296,14 +300,19 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
* 按天复位
|
* 按天复位
|
||||||
*
|
*
|
||||||
* @param curr
|
* @param curr
|
||||||
* @param day
|
* @param orgCustomPlateNoSeqRespDTO
|
||||||
* @param plateNoRule
|
* @param plateNoRule
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int resetByDay(int curr, int day, CustomPlateNoRuleVO plateNoRule) {
|
private int resetByDay(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||||
LocalDateTime now = plateNoRule.getNow();
|
// 上一次的天
|
||||||
|
Integer lastDay = orgCustomPlateNoSeqRespDTO.getLastDay();
|
||||||
Integer initValue = plateNoRule.getInitValue();
|
Integer initValue = plateNoRule.getInitValue();
|
||||||
if (ObjectUtil.notEqual(String.valueOf(day), now.format(DAY_FORMATTER))) {
|
String nowDayFormat = plateNoRule.getNow().format(DAY_FORMATTER);
|
||||||
|
if (ObjectUtil.notEqual(String.valueOf(lastDay), nowDayFormat)) {
|
||||||
|
// 跨月,把上一次的月设成当前月,后续不再跨月
|
||||||
|
orgCustomPlateNoSeqRespDTO.setLastDay(Integer.parseInt(nowDayFormat));
|
||||||
|
// 复位
|
||||||
return initValue;
|
return initValue;
|
||||||
}
|
}
|
||||||
return curr + plateNoRule.getIncrementStep();
|
return curr + plateNoRule.getIncrementStep();
|
||||||
|
|||||||
+21
-15
@@ -1,5 +1,6 @@
|
|||||||
package com.cf.imes.module.executor.service.customplatenorule;
|
package com.cf.imes.module.executor.service.customplatenorule;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||||
@@ -27,8 +28,26 @@ public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
|||||||
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.ROOMNO.getRuleCode(), ruleCode);
|
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.ROOMNO.getRuleCode(), ruleCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化生成所需配置
|
||||||
|
*
|
||||||
|
* @param generateConfigVO
|
||||||
|
*/
|
||||||
|
private static void initConfig(CustomPlateNoGenerateConfigVO generateConfigVO) {
|
||||||
|
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfigVO.getOrderCustomPlateNoSeqVO();
|
||||||
|
if (ObjectUtil.isNull(orderCustomPlateNoSeqVO)) {
|
||||||
|
orderCustomPlateNoSeqVO = new OrderCustomPlateNoSeqVO();
|
||||||
|
generateConfigVO.setOrderCustomPlateNoSeqVO(orderCustomPlateNoSeqVO);
|
||||||
|
}
|
||||||
|
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
||||||
|
if (CollUtil.isEmpty(rooms)) {
|
||||||
|
rooms = new ArrayList<>();
|
||||||
|
orderCustomPlateNoSeqVO.setRooms(rooms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||||
Integer incrementStep = plateNoRule.getIncrementStep();
|
Integer incrementStep = plateNoRule.getIncrementStep();
|
||||||
Integer initValue = plateNoRule.getInitValue() - incrementStep;
|
Integer initValue = plateNoRule.getInitValue() - incrementStep;
|
||||||
// 初始化配置
|
// 初始化配置
|
||||||
@@ -43,7 +62,7 @@ public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
|||||||
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
||||||
// 上次导入的生产单号
|
// 上次导入的生产单号
|
||||||
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
||||||
if (ObjectUtil.isNotNull(lastOrderNo) && ObjectUtil.notEqual(orderId, lastOrderNo)) {
|
if (firstPlate && (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo))) {
|
||||||
// 跨单复位到初始值
|
// 跨单复位到初始值
|
||||||
orderRoomNoSeq = initValue;
|
orderRoomNoSeq = initValue;
|
||||||
}
|
}
|
||||||
@@ -81,19 +100,6 @@ public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
|||||||
return generateConfig;
|
return generateConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化生成所需配置
|
|
||||||
*
|
|
||||||
* @param generateConfigVO
|
|
||||||
*/
|
|
||||||
private static void initConfig(CustomPlateNoGenerateConfigVO generateConfigVO) {
|
|
||||||
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfigVO.getOrderCustomPlateNoSeqVO();
|
|
||||||
if (ObjectUtil.isNull(orderCustomPlateNoSeqVO)) {
|
|
||||||
orderCustomPlateNoSeqVO = new OrderCustomPlateNoSeqVO();
|
|
||||||
generateConfigVO.setOrderCustomPlateNoSeqVO(orderCustomPlateNoSeqVO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据房间名从生产单序号json中获取房间序号列表
|
* 根据房间名从生产单序号json中获取房间序号列表
|
||||||
*
|
*
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ import java.io.Serializable;
|
|||||||
* @author Gqr
|
* @author Gqr
|
||||||
* @since 2024/11/11 18:31
|
* @since 2024/11/11 18:31
|
||||||
*/
|
*/
|
||||||
@TableName(value = "custom_plateno_seq", autoResultMap = true)
|
@TableName(value = "custom_plateno_seq")
|
||||||
@KeySequence("custom_plateno_seq_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
@KeySequence("custom_plateno_seq_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
@Data
|
@Data
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
|
|||||||
+33
-16
@@ -15,14 +15,17 @@ import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteRe
|
|||||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigSaveReqVO;
|
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigSaveReqVO;
|
||||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateStatusReqVO;
|
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateStatusReqVO;
|
||||||
|
import com.cf.imes.module.system.dal.dataobject.customplateno.CustomPlateNoSeqDO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.dict.DictDataDO;
|
import com.cf.imes.module.system.dal.dataobject.dict.DictDataDO;
|
||||||
|
import com.cf.imes.module.system.dal.mysql.customplateno.CustomPlateNoSeqMapper;
|
||||||
import com.cf.imes.module.system.dal.mysql.systemconfig.SystemConfigMapper;
|
import com.cf.imes.module.system.dal.mysql.systemconfig.SystemConfigMapper;
|
||||||
import com.cf.imes.module.system.dal.redis.RedisKeyConstants;
|
import com.cf.imes.module.system.dal.redis.RedisKeyConstants;
|
||||||
import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
||||||
import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
|
import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
|
||||||
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
|
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
|
||||||
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigServiceHandler;
|
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigServiceHandler;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.CustomPlateNoSeqService;
|
||||||
import com.cf.imes.module.system.service.dict.DictDataService;
|
import com.cf.imes.module.system.service.dict.DictDataService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -52,10 +55,10 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
|
|||||||
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_RULECODE_NOT_MATCH_ERROR = new ErrorCode(1_002_040_003, "规则编码【{}】不合法,请检查配置规则");
|
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_RULECODE_NOT_MATCH_ERROR = new ErrorCode(1_002_040_003, "规则编码【{}】不合法,请检查配置规则");
|
||||||
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_DATE_TYPE_FORMAT_ERROR = new ErrorCode(1_002_040_003, "时间格式【{}】不合法,请检查配置规则");
|
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_DATE_TYPE_FORMAT_ERROR = new ErrorCode(1_002_040_003, "时间格式【{}】不合法,请检查配置规则");
|
||||||
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_CUSTOM_VALUE_EMPTY_ERROR = new ErrorCode(1_002_040_003, "自定义字符值不能为空,请检查配置规则");
|
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_CUSTOM_VALUE_EMPTY_ERROR = new ErrorCode(1_002_040_003, "自定义字符值不能为空,请检查配置规则");
|
||||||
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_RESETMODE_ERROR = new ErrorCode(1_002_040_003, "规则【{}】复位/清零模式【{}】不合法,请检查配置规则");
|
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_RESETMODE_ERROR = new ErrorCode(1_002_040_003, "规则【{}】复位/清零模式不合法,请检查配置规则");
|
||||||
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_INT_TYPE_NO_EMPTY = new ErrorCode(1_002_040_003, "参数【{}】不能为空,请检查配置规则");
|
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_INT_TYPE_NO_EMPTY = new ErrorCode(1_002_040_003, "【{}】下的【{}】不能为空,请检查配置规则");
|
||||||
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_INT_TYPE_ERROR = new ErrorCode(1_002_040_003, "数值类型参数{}:【{}】转换异常,请检查配置规则");
|
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_INT_TYPE_ERROR = new ErrorCode(1_002_040_003, "【{}】下的数值类型参数{}:【{}】转换异常,请检查配置规则");
|
||||||
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_BOL_TYPE_ERROR = new ErrorCode(1_002_040_003, "布尔类型参数{}:【{}】转换异常,请检查配置规则");
|
public static final ErrorCode CUSTOM_PLATE_NO_RULE_CHECK_BOL_TYPE_ERROR = new ErrorCode(1_002_040_003, "【{}】下的布尔类型参数{}:【{}】转换异常,请检查配置规则");
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@@ -67,6 +70,12 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
|
|||||||
@Resource
|
@Resource
|
||||||
private StringRedisTemplate stringRedisTemplate;
|
private StringRedisTemplate stringRedisTemplate;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomPlateNoSeqService customPlateNoSeqService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomPlateNoSeqMapper customPlateNoSeqMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SystemConfigDO> selectList(ConfigPageReqVO pageReqVO) {
|
public List<SystemConfigDO> selectList(ConfigPageReqVO pageReqVO) {
|
||||||
return null;
|
return null;
|
||||||
@@ -172,8 +181,9 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
|
|||||||
Map<String, String> bolTypeFieldMap = new HashMap<>() {{
|
Map<String, String> bolTypeFieldMap = new HashMap<>() {{
|
||||||
put("left_fill_zero", "是否左补零");
|
put("left_fill_zero", "是否左补零");
|
||||||
}};
|
}};
|
||||||
intTypeFieldMap.forEach((k, v) -> checkInt(object.get(k), v));
|
String ruleName = object.getString("ruleName");
|
||||||
bolTypeFieldMap.forEach((k, v) -> checkBol(object.get(k), v));
|
intTypeFieldMap.forEach((k, v) -> checkInt(object.get(k), v, ruleName));
|
||||||
|
bolTypeFieldMap.forEach((k, v) -> checkBol(object.get(k), v, ruleName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,12 +193,12 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
|
|||||||
* @param intObj
|
* @param intObj
|
||||||
* @param fieldName
|
* @param fieldName
|
||||||
*/
|
*/
|
||||||
private void checkInt(Object intObj, String fieldName) {
|
private void checkInt(Object intObj, String fieldName, String ruleName) {
|
||||||
if (ObjectUtil.isNull(intObj)) {
|
if (ObjectUtil.isEmpty(intObj)) {
|
||||||
throw ServiceExceptionUtil.exception(CUSTOM_PLATE_NO_RULE_CHECK_INT_TYPE_NO_EMPTY, fieldName);
|
throw ServiceExceptionUtil.exception(CUSTOM_PLATE_NO_RULE_CHECK_INT_TYPE_NO_EMPTY, ruleName, fieldName);
|
||||||
}
|
}
|
||||||
if (!NumberUtil.isInteger(intObj.toString())) {
|
if (!NumberUtil.isInteger(intObj.toString())) {
|
||||||
throw ServiceExceptionUtil.exception(CUSTOM_PLATE_NO_RULE_CHECK_INT_TYPE_ERROR, fieldName, intObj);
|
throw ServiceExceptionUtil.exception(CUSTOM_PLATE_NO_RULE_CHECK_INT_TYPE_ERROR, ruleName, fieldName, intObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,12 +208,12 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
|
|||||||
* @param bolObj
|
* @param bolObj
|
||||||
* @param fieldName
|
* @param fieldName
|
||||||
*/
|
*/
|
||||||
private void checkBol(Object bolObj, String fieldName) {
|
private void checkBol(Object bolObj, String fieldName, String ruleName) {
|
||||||
if (ObjectUtil.isNull(bolObj)) {
|
if (ObjectUtil.isEmpty(bolObj)) {
|
||||||
throw ServiceExceptionUtil.exception(CUSTOM_PLATE_NO_RULE_CHECK_INT_TYPE_NO_EMPTY, fieldName);
|
throw ServiceExceptionUtil.exception(CUSTOM_PLATE_NO_RULE_CHECK_INT_TYPE_NO_EMPTY, ruleName, fieldName);
|
||||||
}
|
}
|
||||||
if (!(bolObj instanceof Boolean)) {
|
if (!(bolObj instanceof Boolean)) {
|
||||||
throw ServiceExceptionUtil.exception(CUSTOM_PLATE_NO_RULE_CHECK_BOL_TYPE_ERROR, fieldName, bolObj);
|
throw ServiceExceptionUtil.exception(CUSTOM_PLATE_NO_RULE_CHECK_BOL_TYPE_ERROR, ruleName, fieldName, bolObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,8 +229,8 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
|
|||||||
|| ObjectUtil.equal(resetMode, ResetModeEnum.MONTH.getMode()) || ObjectUtil.equal(resetMode, ResetModeEnum.DAY.getMode());
|
|| ObjectUtil.equal(resetMode, ResetModeEnum.MONTH.getMode()) || ObjectUtil.equal(resetMode, ResetModeEnum.DAY.getMode());
|
||||||
} else if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.PLATENO, custBoardRuleCodeEnum)) {
|
} else if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.PLATENO, custBoardRuleCodeEnum)) {
|
||||||
checkSuccess = ObjectUtil.equal(resetMode, ResetModeEnum.ORDER.getMode()) || ObjectUtil.equal(resetMode, ResetModeEnum.YEAR.getMode())
|
checkSuccess = ObjectUtil.equal(resetMode, ResetModeEnum.ORDER.getMode()) || ObjectUtil.equal(resetMode, ResetModeEnum.YEAR.getMode())
|
||||||
|| ObjectUtil.equal(resetMode, ResetModeEnum.MONTH.getMode()) || ObjectUtil.equal(resetMode, ResetModeEnum.ROOM.getMode())
|
|| ObjectUtil.equal(resetMode, ResetModeEnum.MONTH.getMode()) || ObjectUtil.equal(resetMode, ResetModeEnum.DAY.getMode())
|
||||||
|| ObjectUtil.equal(resetMode, ResetModeEnum.BODY.getMode());
|
|| ObjectUtil.equal(resetMode, ResetModeEnum.BODY.getMode()) || ObjectUtil.equal(resetMode, ResetModeEnum.ROOM.getMode());
|
||||||
} else if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.ROOMNO, custBoardRuleCodeEnum)) {
|
} else if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.ROOMNO, custBoardRuleCodeEnum)) {
|
||||||
checkSuccess = ObjectUtil.equal(resetMode, ResetModeEnum.ORDER.getMode());
|
checkSuccess = ObjectUtil.equal(resetMode, ResetModeEnum.ORDER.getMode());
|
||||||
} else if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.BODYNO, custBoardRuleCodeEnum)) {
|
} else if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.BODYNO, custBoardRuleCodeEnum)) {
|
||||||
@@ -269,6 +279,13 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
|
|||||||
String redisKey = String.format("%s:%d:%s", RedisKeyConstants.SYSTEM_CONFIG, OrganContextHolder.getOrganId(), RedisKeyConstants.CUSTOM_PLATE_NO);
|
String redisKey = String.format("%s:%d:%s", RedisKeyConstants.SYSTEM_CONFIG, OrganContextHolder.getOrganId(), RedisKeyConstants.CUSTOM_PLATE_NO);
|
||||||
Boolean delete = stringRedisTemplate.delete(redisKey);
|
Boolean delete = stringRedisTemplate.delete(redisKey);
|
||||||
log.info("[CustomPlateNoGenerateService][afterUpdateStatus]key:{}缓存删除结果:{}", redisKey, delete);
|
log.info("[CustomPlateNoGenerateService][afterUpdateStatus]key:{}缓存删除结果:{}", redisKey, delete);
|
||||||
|
|
||||||
|
// 查询机构下全局序号
|
||||||
|
CustomPlateNoSeqDO plateNoSeqByConfigId = customPlateNoSeqService.getOrgCustomPlateNoSeq();
|
||||||
|
// 提前生成板编号序号,存在则不处理
|
||||||
|
if (ObjectUtil.isNull(plateNoSeqByConfigId)) {
|
||||||
|
customPlateNoSeqMapper.insert(new CustomPlateNoSeqDO());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user