mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 21:52:07 +08:00
Merge branch 'main' of http://192.168.1.205:9980/cf_devdept2/cf_imes_server
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package com.cf.imes.module.executor.api.customplateno;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
import com.cf.imes.module.executor.enums.ApiConstants;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2024/11/28 18:18
|
||||||
|
*/
|
||||||
|
@FeignClient(name = ApiConstants.NAME)
|
||||||
|
@Tag(name = "RPC 服务 - 生产单自定义板编号序号")
|
||||||
|
public interface OrderCustomPlateNoApi {
|
||||||
|
String PREFIX = ApiConstants.PREFIX + "/order/customplateno";
|
||||||
|
|
||||||
|
@PostMapping(PREFIX + "/initValue")
|
||||||
|
@Operation(summary = "复位/清零生产单下的序号")
|
||||||
|
CommonResult<Boolean> resetOrderSeq(@RequestBody CustomPlateNoRuleDTO ruleDTO);
|
||||||
|
}
|
||||||
+59
@@ -0,0 +1,59 @@
|
|||||||
|
package com.cf.imes.module.executor.api.customplateno.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统配置-自定义板编号setting项 vo
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2024/11/15 10:33
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CustomPlateNoRuleDTO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -5691595836226548840L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统配置 - 自定义板编号配置 id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "配置id不能为空")
|
||||||
|
private Long configId;
|
||||||
|
/**
|
||||||
|
* 规则编码
|
||||||
|
*/
|
||||||
|
private String ruleCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则值
|
||||||
|
*/
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始值
|
||||||
|
*/
|
||||||
|
private Integer initValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 位数
|
||||||
|
*/
|
||||||
|
private Integer length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否左补零
|
||||||
|
*/
|
||||||
|
private boolean leftFillZero;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 步长
|
||||||
|
*/
|
||||||
|
private Integer incrementStep;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复位/清零模式
|
||||||
|
*/
|
||||||
|
@NotNull(message = "复位模式不能为空")
|
||||||
|
private Integer resetMode;
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package com.cf.imes.module.executor.api.customplateno;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
import com.cf.imes.module.executor.service.customplatenorule.CustomPlateNoGenerateRuleService;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2024/11/28 18:24
|
||||||
|
*/
|
||||||
|
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||||
|
@Validated
|
||||||
|
public class OrderCustomPlateNoApiImpl implements OrderCustomPlateNoApi {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
List<CustomPlateNoGenerateRuleService> customPlateNoGenerateRuleServices;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public CommonResult<Boolean> resetOrderSeq(CustomPlateNoRuleDTO ruleDTO) {
|
||||||
|
for (CustomPlateNoGenerateRuleService ruleService : customPlateNoGenerateRuleServices) {
|
||||||
|
if (ruleService.match(ruleDTO.getRuleCode())) {
|
||||||
|
ruleService.reset(ruleDTO);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommonResult.success(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-1
@@ -186,6 +186,8 @@ public class PlateDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private Boolean deleted;
|
private Boolean deleted;
|
||||||
|
|
||||||
|
private String customPlateNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 房间名
|
* 房间名
|
||||||
*/
|
*/
|
||||||
@@ -199,5 +201,5 @@ public class PlateDO extends BaseDO {
|
|||||||
private String bodyName;
|
private String bodyName;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private StringBuilder customPlateNo;
|
private StringBuilder customPlateNoBuilder;
|
||||||
}
|
}
|
||||||
+24
-9
@@ -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,27 +99,36 @@ 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())) {
|
||||||
plateDO.getCustomPlateNo().append(plateNoRule.getValue());
|
plateDO.getCustomPlateNoBuilder().append(plateNoRule.getValue());
|
||||||
}
|
}
|
||||||
if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.DATE.getRuleCode(), plateNoRule.getRuleCode())) {
|
if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.DATE.getRuleCode(), plateNoRule.getRuleCode())) {
|
||||||
plateDO.getCustomPlateNo().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getValue())));
|
plateDO.getCustomPlateNoBuilder().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getValue())));
|
||||||
}
|
}
|
||||||
// 遍历规则生成服务列表,获取对应的规则服务
|
// 遍历规则生成服务列表,获取对应的规则服务
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plateDO.setPlateNo(plateDO.getCustomPlateNo().toString());
|
plateDO.setCustomPlateNo(plateDO.getCustomPlateNoBuilder().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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机构下的自定义板编号序号
|
* 机构下的自定义板编号序号
|
||||||
*/
|
*/
|
||||||
|
|||||||
+4
@@ -1,12 +1,16 @@
|
|||||||
package com.cf.imes.module.executor.service.customplateno.vo;
|
package com.cf.imes.module.executor.service.customplateno.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class OrderCustomPlateNoSeqBodyVO implements Serializable {
|
public class OrderCustomPlateNoSeqBodyVO implements Serializable {
|
||||||
private static final long serialVersionUID = 2686882895438975156L;
|
private static final long serialVersionUID = 2686882895438975156L;
|
||||||
/**
|
/**
|
||||||
|
|||||||
+4
@@ -1,13 +1,17 @@
|
|||||||
package com.cf.imes.module.executor.service.customplateno.vo;
|
package com.cf.imes.module.executor.service.customplateno.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class OrderCustomPlateNoSeqRoomVO implements Serializable {
|
public class OrderCustomPlateNoSeqRoomVO implements Serializable {
|
||||||
private static final long serialVersionUID = -127388898531267048L;
|
private static final long serialVersionUID = -127388898531267048L;
|
||||||
/**
|
/**
|
||||||
|
|||||||
+60
-20
@@ -2,8 +2,16 @@ package com.cf.imes.module.executor.service.customplatenorule;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
|
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||||
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||||
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.dal.mysql.order.OrderMapper;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqBodyVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqBodyVO;
|
||||||
@@ -14,6 +22,7 @@ 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 javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -28,27 +37,15 @@ import static com.cf.imes.module.executor.enums.ErrorCodeConstants.CUSTOM_PLATEN
|
|||||||
*/
|
*/
|
||||||
@Service("bodyNoGenerateRuleService")
|
@Service("bodyNoGenerateRuleService")
|
||||||
public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleService {
|
public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderMapper orderMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(String ruleCode) {
|
public boolean match(String ruleCode) {
|
||||||
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 +69,49 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||||
|
// 查询所有使用当前配置id的生产单列表
|
||||||
|
Long configId = ruleDTO.getConfigId();
|
||||||
|
List<OrderDO> orderDOS = orderMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getCustomPlatenoConfigId, configId).eq(OrderDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||||
|
|
||||||
|
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(ruleDTO.getResetMode());
|
||||||
|
// 根据复位模式更新生产单的序号
|
||||||
|
for (OrderDO orderDO : orderDOS) {
|
||||||
|
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = JSON.parseObject(orderDO.getCustomPlatenoSeq(), OrderCustomPlateNoSeqVO.class);
|
||||||
|
if (ObjectUtil.isNotNull(orderCustomPlateNoSeqVO)) {
|
||||||
|
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
|
||||||
|
orderCustomPlateNoSeqVO.setBodyNoSeq(ruleDTO.getInitValue());
|
||||||
|
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
|
||||||
|
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
||||||
|
if (CollUtil.isNotEmpty(rooms)) {
|
||||||
|
for (OrderCustomPlateNoSeqRoomVO roomVO : rooms) {
|
||||||
|
roomVO.setBodyNoSeq(ruleDTO.getInitValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderDO.getId()).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按生产单复位模式下的板编号生成
|
* 按生产单复位模式下的板编号生成
|
||||||
*
|
*
|
||||||
@@ -81,7 +121,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 +134,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;
|
||||||
}
|
}
|
||||||
@@ -123,7 +163,7 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
|||||||
|
|
||||||
// 补零
|
// 补零
|
||||||
String noPartAfterFillZero = fillZero(bodyNoSeq, plateNoRule);
|
String noPartAfterFillZero = fillZero(bodyNoSeq, plateNoRule);
|
||||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||||
// 累加后同步到json:柜体下累加到多少了
|
// 累加后同步到json:柜体下累加到多少了
|
||||||
bodySeqVo.setBodyNoSeq(bodyNoSeq);
|
bodySeqVo.setBodyNoSeq(bodyNoSeq);
|
||||||
|
|
||||||
@@ -189,7 +229,7 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
|||||||
|
|
||||||
// 补零
|
// 补零
|
||||||
String noPartAfterFillZero = fillZero(roomBodyNoSeq, plateNoRule);
|
String noPartAfterFillZero = fillZero(roomBodyNoSeq, plateNoRule);
|
||||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||||
// 累加后同步到json中,room下柜体累加到多少了
|
// 累加后同步到json中,room下柜体累加到多少了
|
||||||
roomBodySeqVo.setBodyNoSeq(roomBodyNoSeq);
|
roomBodySeqVo.setBodyNoSeq(roomBodyNoSeq);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@
|
|||||||
//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;
|
||||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleDTO;
|
||||||
//import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
//import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
||||||
//import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
//
|
//
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleDTO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||||
// for (PlateDO plateDO : plateDOList) {
|
// for (PlateDO plateDO : plateDOList) {
|
||||||
// plateDO.getCustomPlateNo().append(plateNoRule.getValue());
|
// plateDO.getCustomPlateNo().append(plateNoRule.getValue());
|
||||||
// }
|
// }
|
||||||
|
|||||||
+12
-2
@@ -1,5 +1,6 @@
|
|||||||
package com.cf.imes.module.executor.service.customplatenorule;
|
package com.cf.imes.module.executor.service.customplatenorule;
|
||||||
|
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
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;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||||
@@ -23,11 +24,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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 左补零
|
* 左补零
|
||||||
@@ -44,4 +47,11 @@ public interface CustomPlateNoGenerateRuleService {
|
|||||||
}
|
}
|
||||||
return String.valueOf(curr);
|
return String.valueOf(curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复位
|
||||||
|
*
|
||||||
|
* @param ruleDTO
|
||||||
|
*/
|
||||||
|
void reset(CustomPlateNoRuleDTO ruleDTO);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@
|
|||||||
//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;
|
||||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleDTO;
|
||||||
//import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
//import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
||||||
//import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
//
|
//
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleDTO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||||
// for (PlateDO plateDO : plateDOList) {
|
// for (PlateDO plateDO : plateDOList) {
|
||||||
// plateDO.getCustomPlateNo().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getValue())));
|
// plateDO.getCustomPlateNo().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getValue())));
|
||||||
// }
|
// }
|
||||||
|
|||||||
+64
-26
@@ -1,8 +1,16 @@
|
|||||||
package com.cf.imes.module.executor.service.customplatenorule;
|
package com.cf.imes.module.executor.service.customplatenorule;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
|
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||||
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||||
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.dal.mysql.order.OrderMapper;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqVO;
|
||||||
@@ -11,8 +19,9 @@ 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 javax.annotation.Resource;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.CUSTOM_PLATENO_GENERATE_ORDERNO_RULE_NOT_SUPPORT_RESETMODE;
|
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.CUSTOM_PLATENO_GENERATE_ORDERNO_RULE_NOT_SUPPORT_RESETMODE;
|
||||||
@@ -30,6 +39,9 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
|
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
|
||||||
private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderMapper orderMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(String ruleCode) {
|
public boolean match(String ruleCode) {
|
||||||
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.ORDERNO.getRuleCode(), ruleCode);
|
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.ORDERNO.getRuleCode(), ruleCode);
|
||||||
@@ -49,7 +61,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);
|
||||||
// 生产单下的序号
|
// 生产单下的序号
|
||||||
@@ -59,7 +71,7 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
if (ObjectUtil.isNotNull(orderNoSeq)) {
|
if (ObjectUtil.isNotNull(orderNoSeq)) {
|
||||||
// 补零
|
// 补零
|
||||||
String noPartAfterFill = this.fillZero(orderNoSeq, plateNoRule);
|
String noPartAfterFill = this.fillZero(orderNoSeq, plateNoRule);
|
||||||
plateDO.getCustomPlateNo().append(noPartAfterFill);
|
plateDO.getCustomPlateNoBuilder().append(noPartAfterFill);
|
||||||
return generateConfig;
|
return generateConfig;
|
||||||
}
|
}
|
||||||
// 机构下的自定义板编号序号
|
// 机构下的自定义板编号序号
|
||||||
@@ -68,14 +80,13 @@ 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);
|
||||||
}
|
}
|
||||||
// 补零
|
// 补零
|
||||||
String noPartAfterFill = this.fillZero(currOrderNoSeq, plateNoRule);
|
String noPartAfterFill = this.fillZero(currOrderNoSeq, plateNoRule);
|
||||||
plateDO.getCustomPlateNo().append(noPartAfterFill);
|
plateDO.getCustomPlateNoBuilder().append(noPartAfterFill);
|
||||||
|
|
||||||
// 累加后的值同步到当前生产单序号和机构序号中
|
// 累加后的值同步到当前生产单序号和机构序号中
|
||||||
orderCustomPlateNoSeqVO.setOrderNoSeq(currOrderNoSeq);
|
orderCustomPlateNoSeqVO.setOrderNoSeq(currOrderNoSeq);
|
||||||
@@ -83,6 +94,23 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
return generateConfig;
|
return generateConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||||
|
// 查询所有使用当前配置id的生产单列表
|
||||||
|
Long configId = ruleDTO.getConfigId();
|
||||||
|
List<OrderDO> orderDOS = orderMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getCustomPlatenoConfigId, configId).eq(OrderDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||||
|
|
||||||
|
// 更新生产单的序号
|
||||||
|
for (OrderDO orderDO : orderDOS) {
|
||||||
|
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = JSON.parseObject(orderDO.getCustomPlatenoSeq(), OrderCustomPlateNoSeqVO.class);
|
||||||
|
if (ObjectUtil.isNotNull(orderCustomPlateNoSeqVO)) {
|
||||||
|
orderCustomPlateNoSeqVO.setOrderNoSeq(ruleDTO.getInitValue());
|
||||||
|
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderDO.getId()).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基于复位模式的板编号生成
|
* 基于复位模式的板编号生成
|
||||||
*
|
*
|
||||||
@@ -93,20 +121,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 +159,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 +181,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 +203,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();
|
||||||
|
|||||||
+127
-48
@@ -2,8 +2,16 @@ package com.cf.imes.module.executor.service.customplatenorule;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
|
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||||
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||||
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.dal.mysql.order.OrderMapper;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqBodyVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqBodyVO;
|
||||||
@@ -14,7 +22,7 @@ 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 javax.annotation.Resource;
|
||||||
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;
|
||||||
@@ -33,19 +41,40 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
|
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
|
||||||
private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderMapper orderMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(String ruleCode) {
|
public boolean match(String ruleCode) {
|
||||||
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)) {
|
||||||
@@ -57,16 +86,70 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||||
|
// 查询所有使用当前配置id的生产单列表
|
||||||
|
Long configId = ruleDTO.getConfigId();
|
||||||
|
List<OrderDO> orderDOS = orderMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getCustomPlatenoConfigId, configId).eq(OrderDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||||
|
|
||||||
|
Integer initValue = ruleDTO.getInitValue();
|
||||||
|
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(ruleDTO.getResetMode());
|
||||||
|
// 根据复位模式更新生产单的序号
|
||||||
|
for (OrderDO orderDO : orderDOS) {
|
||||||
|
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = JSON.parseObject(orderDO.getCustomPlatenoSeq(), OrderCustomPlateNoSeqVO.class);
|
||||||
|
if (ObjectUtil.isNotNull(orderCustomPlateNoSeqVO)) {
|
||||||
|
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
|
||||||
|
orderCustomPlateNoSeqVO.setPlateNoSeq(initValue);
|
||||||
|
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
|
||||||
|
resetRoomPlateSeq(orderCustomPlateNoSeqVO.getRooms(), initValue);
|
||||||
|
} else if (ObjectUtil.equal(ResetModeEnum.BODY, resetModeEnum)) {
|
||||||
|
resetBodyPlateSeq(orderCustomPlateNoSeqVO.getRooms(), initValue);
|
||||||
|
}
|
||||||
|
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderDO.getId()).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复位生产单下房间中的板件序号
|
||||||
|
*
|
||||||
|
* @param rooms
|
||||||
|
* @param initValue
|
||||||
|
*/
|
||||||
|
private void resetRoomPlateSeq(List<OrderCustomPlateNoSeqRoomVO> rooms, Integer initValue) {
|
||||||
|
if (CollUtil.isNotEmpty(rooms)) {
|
||||||
|
for (OrderCustomPlateNoSeqRoomVO roomVO : rooms) {
|
||||||
|
roomVO.setPlateNoSeq(initValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复位生产单下柜体中的板件序号
|
||||||
|
*
|
||||||
|
* @param rooms
|
||||||
|
* @param initValue
|
||||||
|
*/
|
||||||
|
private void resetBodyPlateSeq(List<OrderCustomPlateNoSeqRoomVO> rooms, Integer initValue) {
|
||||||
|
if (CollUtil.isNotEmpty(rooms)) {
|
||||||
|
for (OrderCustomPlateNoSeqRoomVO roomVO : rooms) {
|
||||||
|
List<OrderCustomPlateNoSeqBodyVO> bodys = roomVO.getBodys();
|
||||||
|
if (CollUtil.isNotEmpty(bodys)) {
|
||||||
|
for (OrderCustomPlateNoSeqBodyVO bodyVO : bodys) {
|
||||||
|
bodyVO.setPlateNoSeq(initValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按年/月/日复位模式下的板编号生成
|
* 按年/月/日复位模式下的板编号生成
|
||||||
*/
|
*/
|
||||||
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,16 +157,15 @@ 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.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||||
|
|
||||||
orgCustomPlateNoSeqRespDTO.setPlateNoSeq(orderNoSeq);
|
orgCustomPlateNoSeqRespDTO.setPlateNoSeq(orderNoSeq);
|
||||||
return generateConfig;
|
return generateConfig;
|
||||||
@@ -97,7 +179,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,13 +190,13 @@ 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;
|
||||||
}
|
}
|
||||||
// 跨板件累加步长,补零
|
// 跨板件累加步长,补零
|
||||||
orderPlateNoSeq += incrementStep;
|
orderPlateNoSeq += incrementStep;
|
||||||
plateDO.getCustomPlateNo().append(fillZero(orderPlateNoSeq, plateNoRule));
|
plateDO.getCustomPlateNoBuilder().append(fillZero(orderPlateNoSeq, plateNoRule));
|
||||||
// 累加后的值同步到当前生产单序号中
|
// 累加后的值同步到当前生产单序号中
|
||||||
orderCustomPlateNoSeqVO.setPlateNoSeq(orderPlateNoSeq);
|
orderCustomPlateNoSeqVO.setPlateNoSeq(orderPlateNoSeq);
|
||||||
return generateConfig;
|
return generateConfig;
|
||||||
@@ -152,7 +234,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
// 累加后的值同步到当前生产单序号中
|
// 累加后的值同步到当前生产单序号中
|
||||||
roomSeqVo.setPlateNoSeq(roomPlateNoSeq);
|
roomSeqVo.setPlateNoSeq(roomPlateNoSeq);
|
||||||
// 补零
|
// 补零
|
||||||
plateDO.getCustomPlateNo().append(fillZero(roomPlateNoSeq, plateNoRule));
|
plateDO.getCustomPlateNoBuilder().append(fillZero(roomPlateNoSeq, plateNoRule));
|
||||||
return generateConfig;
|
return generateConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +296,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
|||||||
bodySeqVO.setPlateNoSeq(bodyPlateNoSeq);
|
bodySeqVO.setPlateNoSeq(bodyPlateNoSeq);
|
||||||
// 补零
|
// 补零
|
||||||
String noPartAfterFillZero = fillZero(bodyPlateNoSeq, plateNoRule);
|
String noPartAfterFillZero = fillZero(bodyPlateNoSeq, plateNoRule);
|
||||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||||
return generateConfig;
|
return generateConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,36 +322,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 +348,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 +370,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();
|
||||||
|
|||||||
+4
-4
@@ -5,7 +5,7 @@
|
|||||||
//import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
//import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
//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;
|
||||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleDTO;
|
||||||
//import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqProcessGroupVO;
|
//import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqProcessGroupVO;
|
||||||
//import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqRoomVO;
|
//import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqRoomVO;
|
||||||
//import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqVO;
|
//import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqVO;
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleDTO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||||
// // 初始化配置
|
// // 初始化配置
|
||||||
// initConfig(generateConfig);
|
// initConfig(generateConfig);
|
||||||
// // 按复位模式走不同的生成方式
|
// // 按复位模式走不同的生成方式
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
// * @param plateDOList 板件列表
|
// * @param plateDOList 板件列表
|
||||||
// * @return
|
// * @return
|
||||||
// */
|
// */
|
||||||
// private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
// private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleDTO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||||
// Integer initValue = plateNoRule.getInitValue() - plateNoRule.getIncrementStep();
|
// Integer initValue = plateNoRule.getInitValue() - plateNoRule.getIncrementStep();
|
||||||
// // 生产单下的序号
|
// // 生产单下的序号
|
||||||
// OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfig.getOrderCustomPlateNoSeqVO();
|
// OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfig.getOrderCustomPlateNoSeqVO();
|
||||||
@@ -143,7 +143,7 @@
|
|||||||
// * @param plateDOList
|
// * @param plateDOList
|
||||||
// * @return
|
// * @return
|
||||||
// */
|
// */
|
||||||
// private CustomPlateNoGenerateConfigVO generateNoByRoomResetMode(CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
// private CustomPlateNoGenerateConfigVO generateNoByRoomResetMode(CustomPlateNoRuleDTO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||||
// Integer initValue = plateNoRule.getInitValue() - plateNoRule.getIncrementStep();
|
// Integer initValue = plateNoRule.getInitValue() - plateNoRule.getIncrementStep();
|
||||||
// // 生产单下的序号
|
// // 生产单下的序号
|
||||||
// OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfig.getOrderCustomPlateNoSeqVO();
|
// OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfig.getOrderCustomPlateNoSeqVO();
|
||||||
|
|||||||
+48
-13
@@ -1,7 +1,16 @@
|
|||||||
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.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||||
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||||
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.dal.mysql.order.OrderMapper;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||||
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqRoomVO;
|
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqRoomVO;
|
||||||
@@ -10,6 +19,7 @@ import com.cf.imes.module.system.api.customplateno.dto.CustomPlateNoSeqDTO;
|
|||||||
import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -22,13 +32,34 @@ import java.util.Optional;
|
|||||||
*/
|
*/
|
||||||
@Service("roomNoGenerateRuleService")
|
@Service("roomNoGenerateRuleService")
|
||||||
public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleService {
|
public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleService {
|
||||||
|
@Resource
|
||||||
|
private OrderMapper orderMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(String ruleCode) {
|
public boolean match(String ruleCode) {
|
||||||
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 +74,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;
|
||||||
}
|
}
|
||||||
@@ -74,23 +105,27 @@ public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
|||||||
|
|
||||||
// 补零
|
// 补零
|
||||||
String noPartAfterFillZero = fillZero(roomNoSeq, plateNoRule);
|
String noPartAfterFillZero = fillZero(roomNoSeq, plateNoRule);
|
||||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||||
// 累加后同步到json:房间下累加到多少了
|
// 累加后同步到json:房间下累加到多少了
|
||||||
roomSeqVo.setRoomNoSeq(roomNoSeq);
|
roomSeqVo.setRoomNoSeq(roomNoSeq);
|
||||||
|
|
||||||
return generateConfig;
|
return generateConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 初始化生成所需配置
|
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||||
*
|
// 查询所有使用当前配置id的生产单列表
|
||||||
* @param generateConfigVO
|
Long configId = ruleDTO.getConfigId();
|
||||||
*/
|
List<OrderDO> orderDOS = orderMapper.selectList(
|
||||||
private static void initConfig(CustomPlateNoGenerateConfigVO generateConfigVO) {
|
new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getCustomPlatenoConfigId, configId).eq(OrderDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||||
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfigVO.getOrderCustomPlateNoSeqVO();
|
|
||||||
if (ObjectUtil.isNull(orderCustomPlateNoSeqVO)) {
|
// 更新生产单的序号
|
||||||
orderCustomPlateNoSeqVO = new OrderCustomPlateNoSeqVO();
|
for (OrderDO orderDO : orderDOS) {
|
||||||
generateConfigVO.setOrderCustomPlateNoSeqVO(orderCustomPlateNoSeqVO);
|
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = JSON.parseObject(orderDO.getCustomPlatenoSeq(), OrderCustomPlateNoSeqVO.class);
|
||||||
|
if (ObjectUtil.isNotNull(orderCustomPlateNoSeqVO)) {
|
||||||
|
orderCustomPlateNoSeqVO.setRoomNoSeq(ruleDTO.getInitValue());
|
||||||
|
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderDO.getId()).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-6
@@ -48,6 +48,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -109,6 +110,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
|
|
||||||
private static final String ES_SELECT_DATA_ERROR = "优化生产ES文档查询异常: ";
|
private static final String ES_SELECT_DATA_ERROR = "优化生产ES文档查询异常: ";
|
||||||
|
|
||||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PlateOptimize> getPlateListByPlanId(Long planId) {
|
public List<PlateOptimize> getPlateListByPlanId(Long planId) {
|
||||||
return planMapper.selectPlateListByPlanId(planId,getUserOrganId());
|
return planMapper.selectPlateListByPlanId(planId,getUserOrganId());
|
||||||
@@ -144,6 +147,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
|
|
||||||
AssertUtils.notEmpty(planDO,PLAN_NOT_EXISTS);
|
AssertUtils.notEmpty(planDO,PLAN_NOT_EXISTS);
|
||||||
|
|
||||||
|
Date date = new Date();
|
||||||
|
|
||||||
// todo 目前只解决了非混单的情况,混单情况待解决
|
// todo 目前只解决了非混单的情况,混单情况待解决
|
||||||
List<OptimizeBoardModelDO> optimizeBoardModelDOS = buildBoardByPlanId(planId, ORDER_REMAIN_PLATE_MODEL, 10);
|
List<OptimizeBoardModelDO> optimizeBoardModelDOS = buildBoardByPlanId(planId, ORDER_REMAIN_PLATE_MODEL, 10);
|
||||||
|
|
||||||
@@ -182,9 +187,9 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (Long goods : goodsNo) {
|
goodsNo.forEach(g->
|
||||||
plateNo.addAll(outputList.stream().filter(f -> f.getBi().equals(goods)).map(BlockPlaceInfo::getBo).distinct().toList());
|
plateNo.addAll(outputList.stream().filter(f -> f.getBi().equals(g)).map(BlockPlaceInfo::getBo).distinct().toList())
|
||||||
}
|
);
|
||||||
|
|
||||||
|
|
||||||
List<PlateDO> plateDOS = plateMapper.selectPlateByPlateNo(plateNo.stream().distinct().toList(), getUserOrganId());
|
List<PlateDO> plateDOS = plateMapper.selectPlateByPlateNo(plateNo.stream().distinct().toList(), getUserOrganId());
|
||||||
@@ -217,6 +222,10 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
|
|
||||||
long cutedBoardNumber = cutedBoardList.size();
|
long cutedBoardNumber = cutedBoardList.size();
|
||||||
|
|
||||||
|
if(CollUtil.isEmpty(cutedBoardList)){
|
||||||
|
cutedBoardNumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// 将需要更新更新的数据更新到原数据中
|
// 将需要更新更新的数据更新到原数据中
|
||||||
cutedBoardInfo.setCutedBoardNumber(cutedBoardNumber);
|
cutedBoardInfo.setCutedBoardNumber(cutedBoardNumber);
|
||||||
cutedBoardInfo.setCutedBoardList(cutedBoardList);
|
cutedBoardInfo.setCutedBoardList(cutedBoardList);
|
||||||
@@ -225,6 +234,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
// 更新开料相关的数据
|
// 更新开料相关的数据
|
||||||
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
|
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
|
||||||
objectObjectHashMap.put("cutedBoardInfo",cutedBoardInfo);
|
objectObjectHashMap.put("cutedBoardInfo",cutedBoardInfo);
|
||||||
|
objectObjectHashMap.put("updateTime",simpleDateFormat.format(date));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -293,6 +303,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Date date = new Date();
|
||||||
|
|
||||||
PlanDO planDO = planMapper.selectById(planId);
|
PlanDO planDO = planMapper.selectById(planId);
|
||||||
|
|
||||||
AssertUtils.notEmpty(planDO,PLAN_NOT_EXISTS);
|
AssertUtils.notEmpty(planDO,PLAN_NOT_EXISTS);
|
||||||
@@ -326,6 +338,9 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
// 减去取消开料的大板数量
|
// 减去取消开料的大板数量
|
||||||
cutedBoardNumber -= goodsNo.size();
|
cutedBoardNumber -= goodsNo.size();
|
||||||
|
|
||||||
|
if(CollUtil.isEmpty(cutedBoardList)){
|
||||||
|
cutedBoardNumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// 将需要更新更新的数据更新到原数据中
|
// 将需要更新更新的数据更新到原数据中
|
||||||
cutedBoardInfo.setCutedBoardNumber(cutedBoardNumber);
|
cutedBoardInfo.setCutedBoardNumber(cutedBoardNumber);
|
||||||
@@ -335,6 +350,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
// 更新开料相关的数据
|
// 更新开料相关的数据
|
||||||
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
|
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
|
||||||
objectObjectHashMap.put("cutedBoardInfo", cutedBoardInfo);
|
objectObjectHashMap.put("cutedBoardInfo", cutedBoardInfo);
|
||||||
|
objectObjectHashMap.put("updateTime",simpleDateFormat.format(date));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -377,9 +393,10 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
|
|
||||||
List<String> plateNo = new ArrayList<>();
|
List<String> plateNo = new ArrayList<>();
|
||||||
|
|
||||||
for (Long aLong : goodsNo) {
|
|
||||||
plateNo.addAll(asJsonObject.stream().filter(f->f.getBi().equals(aLong)).map(PlatePlaceInfo::getBo).toList());
|
goodsNo.forEach(g->{
|
||||||
}
|
plateNo.addAll(asJsonObject.stream().filter(f->f.getBi().equals(g)).map(PlatePlaceInfo::getBo).toList());
|
||||||
|
});
|
||||||
|
|
||||||
List<Long> orderIds = plateMapper.selectPlateByPlateNo(plateNo, getUserOrganId()).stream().map(PlateDO::getOrderId).toList();
|
List<Long> orderIds = plateMapper.selectPlateByPlateNo(plateNo, getUserOrganId()).stream().map(PlateDO::getOrderId).toList();
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -349,5 +349,8 @@ public class ErrorCodeConstants {
|
|||||||
//=========== 系统配置 1-002-040-000 ============
|
//=========== 系统配置 1-002-040-000 ============
|
||||||
public static final ErrorCode SYSTEM_CONFIG_NOT_EXISTS = new ErrorCode(1_002_040_001, "系统配置不存在");
|
public static final ErrorCode SYSTEM_CONFIG_NOT_EXISTS = new ErrorCode(1_002_040_001, "系统配置不存在");
|
||||||
public static final ErrorCode SYSTEM_CONFIG_TYPE_NOT_SUPPORT = new ErrorCode(1_002_040_002, "不支持的系统配置类型");
|
public static final ErrorCode SYSTEM_CONFIG_TYPE_NOT_SUPPORT = new ErrorCode(1_002_040_002, "不支持的系统配置类型");
|
||||||
public static final ErrorCode SYSTEM_CONFIG_CUSTOM_PLATE_NO_RULE_SAVE_CHECK_ERROR = new ErrorCode(1_002_040_003, "系统配置:自定义板编号保存解析失败,请检查配置规则或联系客服");
|
public static final ErrorCode SYSTEM_CONFIG_CUSTOM_PLATE_NO_RULE_SAVE_CHECK_ERROR = new ErrorCode(1_002_040_003, "自定义板编号配置:自定义板编号保存解析失败,请检查配置规则或联系客服");
|
||||||
|
public static final ErrorCode SYSTEM_CONFIG_CUSTOM_PLATE_NO_RULE_RESET_NOT_SUPPORT = new ErrorCode(1_002_040_004, "自定义板编号配置:该规则不支持手动复位/清零");
|
||||||
|
public static final ErrorCode SYSTEM_CONFIG_CUSTOM_PLATE_NO_RULE_FIND = new ErrorCode(1_002_040_005, "自定义板编号配置:找不到对应的规则项进行手动复位/清零");
|
||||||
|
public static final ErrorCode SYSTEM_CONFIG_CUSTOM_PLATE_NO_ORDER_RESET_UPDATE_ERROR = new ErrorCode(1_002_040_006, "自定义板编号配置:手动复位/清零生产单下序号失败,请联系客服");
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package com.cf.imes.module.system.api.systemconfig;
|
|||||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
import com.cf.imes.module.system.api.systemconfig.dto.SystemConfigRespDTO;
|
import com.cf.imes.module.system.api.systemconfig.dto.SystemConfigRespDTO;
|
||||||
import com.cf.imes.module.system.service.config.SystemConfigService;
|
import com.cf.imes.module.system.service.systemconfig.SystemConfigService;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package com.cf.imes.module.system.controller.admin.customplateno;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
|
import com.cf.imes.module.system.controller.admin.customplateno.vo.CustomPlateNoRuleResetModeReqVO;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.CustomPlateNoSeqService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义板编号管理控制器
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2024/11/7 16:36
|
||||||
|
*/
|
||||||
|
@Tag(name = "管理后台 - 系统配置 - 自定义板编号")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/config/customplateno")
|
||||||
|
@Validated
|
||||||
|
public class CustomPlateNoController {
|
||||||
|
@Resource
|
||||||
|
private CustomPlateNoSeqService customPlateNoSeqService;
|
||||||
|
|
||||||
|
@PostMapping("/initValue")
|
||||||
|
@Operation(summary = "手动复位/清零")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:base-setting:setting')")
|
||||||
|
public CommonResult<Boolean> updateRuleResetMode(@Valid @RequestBody CustomPlateNoRuleResetModeReqVO reqVO) {
|
||||||
|
customPlateNoSeqService.updateRuleResetMode(reqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
package com.cf.imes.module.system.controller.admin.customplateno.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2024/11/28 15:56
|
||||||
|
*/
|
||||||
|
@Schema(description = "管理后台 - 系统配置 - 自定义板编号规则复位 Request VO")
|
||||||
|
@Data
|
||||||
|
public class CustomPlateNoRuleResetModeReqVO {
|
||||||
|
@Schema(description = "系统配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
@NotNull(message = "系统配置编号不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "规则编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "生产单流水号")
|
||||||
|
@NotEmpty(message = "规则编号不能为空")
|
||||||
|
private String ruleCode;
|
||||||
|
}
|
||||||
+1
-1
@@ -4,7 +4,7 @@ import com.cf.imes.framework.common.pojo.CommonResult;
|
|||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.*;
|
import com.cf.imes.module.system.controller.admin.systemconfig.vo.*;
|
||||||
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.service.config.SystemConfigService;
|
import com.cf.imes.module.system.service.systemconfig.SystemConfigService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|||||||
+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)
|
||||||
|
|||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
package com.cf.imes.module.system.framework.rpc.config;
|
package com.cf.imes.module.system.framework.rpc.config;
|
||||||
|
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.OrderCustomPlateNoApi;
|
||||||
import com.cf.imes.module.executor.api.orderProcess.OrderProcessApi;
|
import com.cf.imes.module.executor.api.orderProcess.OrderProcessApi;
|
||||||
import com.cf.imes.module.executor.api.plan.OrderPlanApi;
|
import com.cf.imes.module.executor.api.plan.OrderPlanApi;
|
||||||
import com.cf.imes.module.infra.api.file.FileApi;
|
import com.cf.imes.module.infra.api.file.FileApi;
|
||||||
@@ -8,6 +9,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, OrderProcessApi.class, OrderPlanApi.class})
|
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, OrderProcessApi.class, OrderPlanApi.class, OrderCustomPlateNoApi.class})
|
||||||
public class RpcConfiguration {
|
public class RpcConfiguration {
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -1,5 +1,6 @@
|
|||||||
package com.cf.imes.module.system.service.customplateno;
|
package com.cf.imes.module.system.service.customplateno;
|
||||||
|
|
||||||
|
import com.cf.imes.module.system.controller.admin.customplateno.vo.CustomPlateNoRuleResetModeReqVO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.customplateno.CustomPlateNoSeqDO;
|
import com.cf.imes.module.system.dal.dataobject.customplateno.CustomPlateNoSeqDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,4 +23,11 @@ public interface CustomPlateNoSeqService {
|
|||||||
* @param seqDO
|
* @param seqDO
|
||||||
*/
|
*/
|
||||||
Boolean modifyOrgCustomPlateNoSeq(CustomPlateNoSeqDO seqDO);
|
Boolean modifyOrgCustomPlateNoSeq(CustomPlateNoSeqDO seqDO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则手动复位/清零
|
||||||
|
*
|
||||||
|
* @param reqVO
|
||||||
|
*/
|
||||||
|
void updateRuleResetMode(CustomPlateNoRuleResetModeReqVO reqVO);
|
||||||
}
|
}
|
||||||
|
|||||||
+61
-1
@@ -1,13 +1,31 @@
|
|||||||
package com.cf.imes.module.system.service.customplateno;
|
package com.cf.imes.module.system.service.customplateno;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
import com.cf.imes.module.system.controller.admin.customplateno.vo.CustomPlateNoRuleResetModeReqVO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.customplateno.CustomPlateNoSeqDO;
|
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.mysql.customplateno.CustomPlateNoSeqMapper;
|
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.enums.config.SystemConfigTypeEnum;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.factory.CustomPlateNoResetModeServiceFactory;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.factory.service.AbstractCustomPlateNoResetServiceHandler;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_CUSTOM_PLATE_NO_RULE_FIND;
|
||||||
|
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义板编号序号服务实现类
|
* 自定义板编号序号服务实现类
|
||||||
*
|
*
|
||||||
@@ -17,7 +35,13 @@ import javax.annotation.Resource;
|
|||||||
@Service
|
@Service
|
||||||
public class CustomPlateNoSeqServiceImpl implements CustomPlateNoSeqService {
|
public class CustomPlateNoSeqServiceImpl implements CustomPlateNoSeqService {
|
||||||
@Resource
|
@Resource
|
||||||
CustomPlateNoSeqMapper customPlateNoSeqMapper;
|
private CustomPlateNoSeqMapper customPlateNoSeqMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SystemConfigMapper systemConfigMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomPlateNoResetModeServiceFactory resetModeServiceFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomPlateNoSeqDO getOrgCustomPlateNoSeq() {
|
public CustomPlateNoSeqDO getOrgCustomPlateNoSeq() {
|
||||||
@@ -30,5 +54,41 @@ public class CustomPlateNoSeqServiceImpl implements CustomPlateNoSeqService {
|
|||||||
return customPlateNoSeqMapper.insertOrUpdate(seqDO);
|
return customPlateNoSeqMapper.insertOrUpdate(seqDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateRuleResetMode(CustomPlateNoRuleResetModeReqVO reqVO) {
|
||||||
|
// 校验配置是否存在
|
||||||
|
Long configId = reqVO.getId();
|
||||||
|
SystemConfigDO systemConfigDO = validateCustomPlateNoConfigExists(configId);
|
||||||
|
// 解析规则列表,获取对应的规则项
|
||||||
|
List<CustomPlateNoRuleDTO> customPlateNoRuleDTOS = JSON.parseArray(systemConfigDO.getSetting(), CustomPlateNoRuleDTO.class);
|
||||||
|
Optional<CustomPlateNoRuleDTO> ruleVOOptional = customPlateNoRuleDTOS.stream().filter(r -> reqVO.getRuleCode().equals(r.getRuleCode())).findFirst();
|
||||||
|
if (ruleVOOptional.isPresent()) {
|
||||||
|
CustomPlateNoRuleDTO customPlateNoRuleDTO = ruleVOOptional.get();
|
||||||
|
// 根据规则编码获取对应的复位处理器
|
||||||
|
AbstractCustomPlateNoResetServiceHandler resetServiceHandler = resetModeServiceFactory.getResetServiceHandler(customPlateNoRuleDTO.getRuleCode());
|
||||||
|
// 复位
|
||||||
|
customPlateNoRuleDTO.setConfigId(systemConfigDO.getId());
|
||||||
|
resetServiceHandler.reset(customPlateNoRuleDTO);
|
||||||
|
} else {
|
||||||
|
throw new ServiceException(SYSTEM_CONFIG_CUSTOM_PLATE_NO_RULE_FIND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验基础配置是否存在
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private SystemConfigDO validateCustomPlateNoConfigExists(Long id) {
|
||||||
|
SystemConfigDO systemConfigDO = systemConfigMapper.selectOne(new LambdaQueryWrapperX<SystemConfigDO>()
|
||||||
|
.eq(SystemConfigDO::getId, id)
|
||||||
|
.eq(SystemConfigDO::getType, SystemConfigTypeEnum.CUSTOM_PLATE_NO.getType())
|
||||||
|
.eq(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||||
|
if (ObjectUtil.isNull(systemConfigDO)) {
|
||||||
|
throw exception(SYSTEM_CONFIG_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
return systemConfigDO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
package com.cf.imes.module.system.service.customplateno.factory;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
|
import com.cf.imes.module.system.enums.ErrorCodeConstants;
|
||||||
|
import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.factory.service.AbstractCustomPlateNoResetServiceHandler;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.factory.service.impl.BodyNoRuleResetServiceHandler;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.factory.service.impl.OrderNoRuleResetServiceHandler;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.factory.service.impl.PlateNoRuleResetServiceHandler;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.factory.service.impl.RoomNoRuleResetServiceHandler;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义板编号规则复位处理器工厂类
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2024/11/28 16:21
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class CustomPlateNoResetModeServiceFactory {
|
||||||
|
private final ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public CustomPlateNoResetModeServiceFactory(ApplicationContext applicationContext) {
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据复位模式获取对应的处理器
|
||||||
|
*
|
||||||
|
* @param roleCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public AbstractCustomPlateNoResetServiceHandler getResetServiceHandler(String roleCode) {
|
||||||
|
CustomPlateNoRuleCodeEnum ruleCodeEnum = CustomPlateNoRuleCodeEnum.match(roleCode);
|
||||||
|
switch (ruleCodeEnum) {
|
||||||
|
case ORDERNO:
|
||||||
|
return applicationContext.getBean(OrderNoRuleResetServiceHandler.class);
|
||||||
|
case ROOMNO:
|
||||||
|
return applicationContext.getBean(RoomNoRuleResetServiceHandler.class);
|
||||||
|
case BODYNO:
|
||||||
|
return applicationContext.getBean(BodyNoRuleResetServiceHandler.class);
|
||||||
|
case PLATENO:
|
||||||
|
return applicationContext.getBean(PlateNoRuleResetServiceHandler.class);
|
||||||
|
default:
|
||||||
|
throw new ServiceException(ErrorCodeConstants.SYSTEM_CONFIG_CUSTOM_PLATE_NO_RULE_RESET_NOT_SUPPORT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package com.cf.imes.module.system.service.customplateno.factory.service;
|
||||||
|
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义板编号规则复位处理器抽象类
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2024/11/8 16:45
|
||||||
|
*/
|
||||||
|
public abstract class AbstractCustomPlateNoResetServiceHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复位
|
||||||
|
*
|
||||||
|
* @param ruleDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract void reset(CustomPlateNoRuleDTO ruleDTO);
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package com.cf.imes.module.system.service.customplateno.factory.service.impl;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.OrderCustomPlateNoApi;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.factory.service.AbstractCustomPlateNoResetServiceHandler;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_CUSTOM_PLATE_NO_ORDER_RESET_UPDATE_ERROR;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义板编号柜体序号规则复位处理器
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2024/11/28 19:01
|
||||||
|
*/
|
||||||
|
@Service("bodyNoRuleResetServiceHandler")
|
||||||
|
@Slf4j
|
||||||
|
public class BodyNoRuleResetServiceHandler extends AbstractCustomPlateNoResetServiceHandler {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderCustomPlateNoApi orderCustomPlateNoApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||||
|
// 更新使用该配置的生产单中的orderNoSeq
|
||||||
|
CommonResult<Boolean> orderResetResult = orderCustomPlateNoApi.resetOrderSeq(ruleDTO);
|
||||||
|
if(orderResetResult.isError()) {
|
||||||
|
ServiceException serviceException = new ServiceException(SYSTEM_CONFIG_CUSTOM_PLATE_NO_ORDER_RESET_UPDATE_ERROR);
|
||||||
|
log.error(orderResetResult.getMsg(), serviceException);
|
||||||
|
throw serviceException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
package com.cf.imes.module.system.service.customplateno.factory.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.OrderCustomPlateNoApi;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
import com.cf.imes.module.system.dal.dataobject.customplateno.CustomPlateNoSeqDO;
|
||||||
|
import com.cf.imes.module.system.dal.mysql.customplateno.CustomPlateNoSeqMapper;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.factory.service.AbstractCustomPlateNoResetServiceHandler;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_CUSTOM_PLATE_NO_ORDER_RESET_UPDATE_ERROR;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义板编号生产单序号规则复位处理器
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2024/11/28 16:45
|
||||||
|
*/
|
||||||
|
@Service("orderNoRuleResetServiceHandler")
|
||||||
|
@Slf4j
|
||||||
|
public class OrderNoRuleResetServiceHandler extends AbstractCustomPlateNoResetServiceHandler {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomPlateNoSeqMapper customPlateNoSeqMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderCustomPlateNoApi orderCustomPlateNoApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||||
|
// 更新机构下全局序号中的生产单前序值
|
||||||
|
LambdaUpdateWrapper<CustomPlateNoSeqDO> seqLambdaUpdateWrapper = new LambdaUpdateWrapper<CustomPlateNoSeqDO>()
|
||||||
|
.eq(CustomPlateNoSeqDO::getOrganId, OrganContextHolder.getOrganId())
|
||||||
|
.set(CustomPlateNoSeqDO::getOrderNoSeq, ruleDTO.getInitValue());
|
||||||
|
customPlateNoSeqMapper.update(seqLambdaUpdateWrapper);
|
||||||
|
|
||||||
|
// 更新使用该配置的生产单中的orderNoSeq
|
||||||
|
CommonResult<Boolean> orderResetResult = orderCustomPlateNoApi.resetOrderSeq(ruleDTO);
|
||||||
|
if(orderResetResult.isError()) {
|
||||||
|
ServiceException serviceException = new ServiceException(SYSTEM_CONFIG_CUSTOM_PLATE_NO_ORDER_RESET_UPDATE_ERROR);
|
||||||
|
log.error(orderResetResult.getMsg(), serviceException);
|
||||||
|
throw serviceException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
package com.cf.imes.module.system.service.customplateno.factory.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.OrderCustomPlateNoApi;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
import com.cf.imes.module.system.dal.dataobject.customplateno.CustomPlateNoSeqDO;
|
||||||
|
import com.cf.imes.module.system.dal.mysql.customplateno.CustomPlateNoSeqMapper;
|
||||||
|
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.factory.service.AbstractCustomPlateNoResetServiceHandler;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_CUSTOM_PLATE_NO_ORDER_RESET_UPDATE_ERROR;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义板编号板件序号规则复位处理器
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2024/11/28 19:01
|
||||||
|
*/
|
||||||
|
@Service("plateNoRuleResetServiceHandler")
|
||||||
|
@Slf4j
|
||||||
|
public class PlateNoRuleResetServiceHandler extends AbstractCustomPlateNoResetServiceHandler {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomPlateNoSeqMapper customPlateNoSeqMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderCustomPlateNoApi orderCustomPlateNoApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||||
|
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(ruleDTO.getResetMode());
|
||||||
|
if (ObjectUtil.equal(resetModeEnum, ResetModeEnum.ORDER) || ObjectUtil.equal(resetModeEnum, ResetModeEnum.YEAR)
|
||||||
|
|| ObjectUtil.equal(resetModeEnum, ResetModeEnum.MONTH) || ObjectUtil.equal(resetModeEnum, ResetModeEnum.DAY)) {
|
||||||
|
// 更新机构下全局序号中的板件序号前序值
|
||||||
|
LambdaUpdateWrapper<CustomPlateNoSeqDO> seqLambdaUpdateWrapper = new LambdaUpdateWrapper<CustomPlateNoSeqDO>()
|
||||||
|
.eq(CustomPlateNoSeqDO::getOrganId, OrganContextHolder.getOrganId())
|
||||||
|
.set(CustomPlateNoSeqDO::getPlateNoSeq, ruleDTO.getInitValue());
|
||||||
|
customPlateNoSeqMapper.update(seqLambdaUpdateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新使用该配置的生产单中的orderNoSeq
|
||||||
|
CommonResult<Boolean> orderResetResult = orderCustomPlateNoApi.resetOrderSeq(ruleDTO);
|
||||||
|
if(orderResetResult.isError()) {
|
||||||
|
ServiceException serviceException = new ServiceException(SYSTEM_CONFIG_CUSTOM_PLATE_NO_ORDER_RESET_UPDATE_ERROR);
|
||||||
|
log.error(orderResetResult.getMsg(), serviceException);
|
||||||
|
throw serviceException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package com.cf.imes.module.system.service.customplateno.factory.service.impl;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.OrderCustomPlateNoApi;
|
||||||
|
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||||
|
import com.cf.imes.module.system.service.customplateno.factory.service.AbstractCustomPlateNoResetServiceHandler;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_CUSTOM_PLATE_NO_ORDER_RESET_UPDATE_ERROR;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义板编号房间序号规则复位处理器
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2024/11/28 19:01
|
||||||
|
*/
|
||||||
|
@Service("roomNoRuleResetServiceHandler")
|
||||||
|
@Slf4j
|
||||||
|
public class RoomNoRuleResetServiceHandler extends AbstractCustomPlateNoResetServiceHandler {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderCustomPlateNoApi orderCustomPlateNoApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||||
|
// 更新使用该配置的生产单中的orderNoSeq
|
||||||
|
CommonResult<Boolean> orderResetResult = orderCustomPlateNoApi.resetOrderSeq(ruleDTO);
|
||||||
|
if(orderResetResult.isError()) {
|
||||||
|
ServiceException serviceException = new ServiceException(SYSTEM_CONFIG_CUSTOM_PLATE_NO_ORDER_RESET_UPDATE_ERROR);
|
||||||
|
log.error(orderResetResult.getMsg(), serviceException);
|
||||||
|
throw serviceException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.cf.imes.module.system.service.config;
|
package com.cf.imes.module.system.service.systemconfig;
|
||||||
|
|
||||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
|
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
|
||||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
package com.cf.imes.module.system.service.config;
|
package com.cf.imes.module.system.service.systemconfig;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
@@ -14,8 +14,8 @@ import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
|||||||
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.config.SystemConfigTypeEnum;
|
import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
|
||||||
import com.cf.imes.module.system.service.config.factory.SystemConfigServiceFactory;
|
import com.cf.imes.module.system.service.systemconfig.factory.SystemConfigServiceFactory;
|
||||||
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigServiceHandler;
|
import com.cf.imes.module.system.service.systemconfig.factory.service.AbstractSystemConfigServiceHandler;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
+5
-5
@@ -1,13 +1,13 @@
|
|||||||
package com.cf.imes.module.system.service.config.factory;
|
package com.cf.imes.module.system.service.systemconfig.factory;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.cf.imes.framework.common.exception.ServiceException;
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
import com.cf.imes.module.system.enums.ErrorCodeConstants;
|
import com.cf.imes.module.system.enums.ErrorCodeConstants;
|
||||||
import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
|
import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
|
||||||
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigServiceHandler;
|
import com.cf.imes.module.system.service.systemconfig.factory.service.AbstractSystemConfigServiceHandler;
|
||||||
import com.cf.imes.module.system.service.config.factory.service.impl.CustomPlateNoServiceHandler;
|
import com.cf.imes.module.system.service.systemconfig.factory.service.impl.CustomPlateNoServiceHandler;
|
||||||
import com.cf.imes.module.system.service.config.factory.service.impl.DefaultSystemConfigServiceHandler;
|
import com.cf.imes.module.system.service.systemconfig.factory.service.impl.DefaultSystemConfigServiceHandler;
|
||||||
import com.cf.imes.module.system.service.config.factory.service.impl.IntellectBranchingService;
|
import com.cf.imes.module.system.service.systemconfig.factory.service.impl.IntellectBranchingService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.cf.imes.module.system.service.config.factory.service;
|
package com.cf.imes.module.system.service.systemconfig.factory.service;
|
||||||
|
|
||||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
|
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
|
||||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||||
+35
-18
@@ -1,4 +1,4 @@
|
|||||||
package com.cf.imes.module.system.service.config.factory.service.impl;
|
package com.cf.imes.module.system.service.systemconfig.factory.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
@@ -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.systemconfig.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
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package com.cf.imes.module.system.service.config.factory.service.impl;
|
package com.cf.imes.module.system.service.systemconfig.factory.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||||
@@ -11,7 +11,7 @@ import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateSt
|
|||||||
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.mysql.systemconfig.SystemConfigMapper;
|
import com.cf.imes.module.system.dal.mysql.systemconfig.SystemConfigMapper;
|
||||||
import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
|
import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
|
||||||
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigServiceHandler;
|
import com.cf.imes.module.system.service.systemconfig.factory.service.AbstractSystemConfigServiceHandler;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package com.cf.imes.module.system.service.config.factory.service.impl;
|
package com.cf.imes.module.system.service.systemconfig.factory.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
@@ -15,7 +15,7 @@ import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigSaveReqV
|
|||||||
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.systemconfig.SystemConfigDO;
|
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
||||||
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.service.config.factory.service.AbstractSystemConfigServiceHandler;
|
import com.cf.imes.module.system.service.systemconfig.factory.service.AbstractSystemConfigServiceHandler;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
Reference in New Issue
Block a user