mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
自定义板编号生成功能调整
This commit is contained in:
+21
-6
@@ -60,7 +60,9 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
CustomPlateNoGenerateConfigVO generateConfig = getGenerateConfig(orderId);
|
||||
// 如果没有查到配置规则就不做后续生成操作了
|
||||
List<CustomPlateNoRuleVO> orgCustomPlateNoRuleVOList = generateConfig.getOrgCustomPlateNoRuleVOList();
|
||||
if (CollUtil.isEmpty(orgCustomPlateNoRuleVOList)) {
|
||||
// 如果没有查到机构下配置就不做后续生成操作了
|
||||
Long orgCustomPlateNoConfigId = generateConfig.getOrgCustomPlateNoConfigId();
|
||||
if (ObjectUtil.isNull(orgCustomPlateNoConfigId) || CollUtil.isEmpty(orgCustomPlateNoRuleVOList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,12 +71,15 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
orgCustomPlateNoRuleVOList.forEach(rule -> rule.setNow(now));
|
||||
|
||||
// 2、遍历小板列表,生成板编号
|
||||
for (PlateDO plateDO : plateDOList) {
|
||||
loopGenerateNo(orderId, plateDO, orgCustomPlateNoRuleVOList, generateConfig);
|
||||
for (int i = 0; i < plateDOList.size(); i++) {
|
||||
PlateDO plateDO = plateDOList.get(i);
|
||||
loopGenerateNo(orderId, plateDO, orgCustomPlateNoRuleVOList, generateConfig, i == 0);
|
||||
}
|
||||
|
||||
// 3、保存生产单序号json
|
||||
// 3、保存生产单序号json、设置生产单所用配置id
|
||||
orderDO.setCustomPlatenoSeq(JSON.toJSONString(generateConfig.getOrderCustomPlateNoSeqVO()));
|
||||
orderDO.setCustomPlatenoConfigId(orgCustomPlateNoConfigId);
|
||||
// 机构下序号配置同步
|
||||
CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO = generateConfig.getOrgCustomPlateNoSeqRespDTO();
|
||||
orgCustomPlateNoSeqRespDTO.setLastOrderNo(orderId);
|
||||
orgCustomPlateNoSeqRespDTO.setLastYear(Integer.parseInt(YEAR_FORMATTER.format(now)));
|
||||
@@ -94,8 +99,9 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
* @param plateDO
|
||||
* @param orgCustomPlateNoRuleVOList
|
||||
* @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) {
|
||||
if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.CUSTOM.getRuleCode(), plateNoRule.getRuleCode())) {
|
||||
@@ -107,7 +113,7 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
// 遍历规则生成服务列表,获取对应的规则服务
|
||||
for (CustomPlateNoGenerateRuleService ruleService : ruleServices) {
|
||||
if (ruleService.match(plateNoRule.getRuleCode())) {
|
||||
generateConfig = ruleService.generateNo(orderId, plateNoRule, generateConfig, plateDO);
|
||||
generateConfig = ruleService.generateNo(orderId, plateNoRule, generateConfig, plateDO, firstPlate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -115,6 +121,14 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
plateDO.setPlateNo(plateDO.getCustomPlateNo().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据生产单id获取生成需要的配置
|
||||
*
|
||||
* @param orderId
|
||||
* @return 1、生产单下的序号
|
||||
* 2、机构下的序号
|
||||
* 3、机构下全局配置的规则
|
||||
*/
|
||||
private CustomPlateNoGenerateConfigVO getGenerateConfig(Long orderId) {
|
||||
// 生成自定义版编号所需配置
|
||||
CustomPlateNoGenerateConfigVO customPlateNoGenerateConfigVO = new CustomPlateNoGenerateConfigVO();
|
||||
@@ -132,6 +146,7 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
customPlateNoRuleVOS = Optional.ofNullable(orgCustomPlateNoConfig)
|
||||
.map(config -> JSON.parseArray(config.getSetting(), CustomPlateNoRuleVO.class))
|
||||
.orElse(List.of());
|
||||
customPlateNoGenerateConfigVO.setOrgCustomPlateNoConfigId(orgCustomPlateNoConfig.getId());
|
||||
}
|
||||
|
||||
OrderDO order = orderService.getOrder(orderId);
|
||||
|
||||
+5
@@ -24,6 +24,11 @@ public class CustomPlateNoGenerateConfigVO implements Serializable {
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@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 板件列表
|
||||
* @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 initValue = plateNoRule.getInitValue() - incrementStep;
|
||||
// 生产单下的序号
|
||||
@@ -94,7 +94,7 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
List<OrderCustomPlateNoSeqBodyVO> bodys = orderCustomPlateNoSeqVO.getBodys();
|
||||
// 上次导入的生产单号
|
||||
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
||||
if (ObjectUtil.isNotNull(lastOrderNo) && ObjectUtil.notEqual(orderId, lastOrderNo)) {
|
||||
if (firstPlate && (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo))) {
|
||||
// 跨单复位到初始值
|
||||
orderBodyNoSeq = initValue;
|
||||
}
|
||||
|
||||
+4
-2
@@ -23,11 +23,13 @@ public interface CustomPlateNoGenerateRuleService {
|
||||
* 生成编号
|
||||
*
|
||||
* @param orderId 生产单号
|
||||
* @param plateDO 板材列表
|
||||
* @param plateNoRule 生成规则
|
||||
* @param generateConfig 生成所需要的配置
|
||||
* @param plateDO 板材列表
|
||||
* @param firstPlate 是否循环的第一块板,只有第一块板需要做是否跨单判断,后续都是一个单内
|
||||
* @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 org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -49,7 +48,7 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
}
|
||||
|
||||
@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);
|
||||
// 生产单下的序号
|
||||
@@ -68,8 +67,7 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
int currOrderNoSeq = Optional.ofNullable(orgCustomPlateNoSeqRespDTO.getOrderNoSeq()).orElse(plateNoRule.getInitValue() - plateNoRule.getIncrementStep());
|
||||
// 上次导入的生产单号
|
||||
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);
|
||||
}
|
||||
@@ -93,20 +91,15 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* @return 循环累加后的序号
|
||||
*/
|
||||
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)) {
|
||||
orderNoSeq = resetByLength(orderNoSeq, plateNoRule);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.YEAR, resetModeEnum)) {
|
||||
orderNoSeq = resetByYear(orderNoSeq, year, plateNoRule);
|
||||
orderNoSeq = resetByYear(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.MONTH, resetModeEnum)) {
|
||||
orderNoSeq = resetByMonth(orderNoSeq, month, plateNoRule);
|
||||
orderNoSeq = resetByMonth(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.DAY, resetModeEnum)) {
|
||||
orderNoSeq = resetByDay(orderNoSeq, day, plateNoRule);
|
||||
orderNoSeq = resetByDay(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||
} else {
|
||||
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 year
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByYear(int curr, int year, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByYear(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的年
|
||||
Integer lastYear = orgCustomPlateNoSeqRespDTO.getLastYear();
|
||||
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 curr + plateNoRule.getIncrementStep();
|
||||
@@ -153,14 +151,19 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* 按月复位
|
||||
*
|
||||
* @param curr
|
||||
* @param month
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByMonth(int curr, int month, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByMonth(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的月
|
||||
Integer lastMonth = orgCustomPlateNoSeqRespDTO.getLastMonth();
|
||||
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 curr + plateNoRule.getIncrementStep();
|
||||
@@ -170,14 +173,19 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* 按天复位
|
||||
*
|
||||
* @param curr
|
||||
* @param day
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByDay(int curr, int day, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByDay(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的天
|
||||
Integer lastDay = orgCustomPlateNoSeqRespDTO.getLastDay();
|
||||
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 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 org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -38,14 +37,32 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
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
|
||||
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);
|
||||
// 按复位模式走不同的生成方式
|
||||
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(plateNoRule.getResetMode());
|
||||
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)) {
|
||||
return generateNoByRoomResetMode(plateNoRule, generateConfig, plateDO);
|
||||
} 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) {
|
||||
// 机构下的自定义板编号序号
|
||||
CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO = generateConfig.getOrgCustomPlateNoSeqRespDTO();
|
||||
// 上一次自定义编号生成的年月日
|
||||
int year = orgCustomPlateNoSeqRespDTO.getLastYear();
|
||||
int month = orgCustomPlateNoSeqRespDTO.getLastMonth();
|
||||
int day = orgCustomPlateNoSeqRespDTO.getLastDay();
|
||||
// 从全局配置获取当前序号,取不到用初始值
|
||||
Integer orderNoSeq = orgCustomPlateNoSeqRespDTO.getPlateNoSeq();
|
||||
if (ObjectUtil.isNull(orderNoSeq)) {
|
||||
@@ -74,14 +87,13 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
}
|
||||
|
||||
if (ObjectUtil.equal(ResetModeEnum.YEAR, resetModeEnum)) {
|
||||
orderNoSeq = resetByYear(orderNoSeq, year, plateNoRule);
|
||||
orderNoSeq = resetByYear(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.MONTH, resetModeEnum)) {
|
||||
orderNoSeq = resetByMonth(orderNoSeq, month, plateNoRule);
|
||||
orderNoSeq = resetByMonth(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||
} 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);
|
||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
||||
|
||||
@@ -97,7 +109,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* @param generateConfig
|
||||
* @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 initValue = plateNoRule.getInitValue() - incrementStep;
|
||||
// 生产单下的序号
|
||||
@@ -108,7 +120,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
Integer orderPlateNoSeq = Optional.ofNullable(orderCustomPlateNoSeqVO.getPlateNoSeq()).orElse(initValue);
|
||||
// 上次导入的生产单号
|
||||
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
||||
if (ObjectUtil.isNotNull(lastOrderNo) && ObjectUtil.notEqual(orderId, lastOrderNo)) {
|
||||
if (firstPlate && (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo))) {
|
||||
// 跨单复位到初始值
|
||||
orderPlateNoSeq = initValue;
|
||||
}
|
||||
@@ -240,36 +252,23 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
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 year
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByYear(int curr, int year, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByYear(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的年
|
||||
Integer lastYear = orgCustomPlateNoSeqRespDTO.getLastYear();
|
||||
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 curr + plateNoRule.getIncrementStep();
|
||||
@@ -279,14 +278,19 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* 按月复位
|
||||
*
|
||||
* @param curr
|
||||
* @param month
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByMonth(int curr, int month, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByMonth(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的月
|
||||
Integer lastMonth = orgCustomPlateNoSeqRespDTO.getLastMonth();
|
||||
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 curr + plateNoRule.getIncrementStep();
|
||||
@@ -296,14 +300,19 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* 按天复位
|
||||
*
|
||||
* @param curr
|
||||
* @param day
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByDay(int curr, int day, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByDay(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的天
|
||||
Integer lastDay = orgCustomPlateNoSeqRespDTO.getLastDay();
|
||||
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 curr + plateNoRule.getIncrementStep();
|
||||
|
||||
+21
-15
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.module.executor.service.customplatenorule;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化生成所需配置
|
||||
*
|
||||
* @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
|
||||
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 initValue = plateNoRule.getInitValue() - incrementStep;
|
||||
// 初始化配置
|
||||
@@ -43,7 +62,7 @@ public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
||||
// 上次导入的生产单号
|
||||
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
||||
if (ObjectUtil.isNotNull(lastOrderNo) && ObjectUtil.notEqual(orderId, lastOrderNo)) {
|
||||
if (firstPlate && (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo))) {
|
||||
// 跨单复位到初始值
|
||||
orderRoomNoSeq = initValue;
|
||||
}
|
||||
@@ -81,19 +100,6 @@ public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
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中获取房间序号列表
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user