自定义板编号手动复位功能实现

This commit is contained in:
gaoqr
2024-11-29 12:11:59 +08:00
parent d02bef7436
commit 0de7725788
36 changed files with 738 additions and 42 deletions
@@ -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);
}
@@ -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;
}
@@ -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);
}
}
@@ -186,6 +186,8 @@ public class PlateDO extends BaseDO {
*/
private Boolean deleted;
private String customPlateNo;
/**
* 房间名
*/
@@ -199,5 +201,5 @@ public class PlateDO extends BaseDO {
private String bodyName;
@TableField(exist = false)
private StringBuilder customPlateNo;
private StringBuilder customPlateNoBuilder;
}
@@ -105,10 +105,10 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
// 遍历规则列表
for (CustomPlateNoRuleVO plateNoRule : orgCustomPlateNoRuleVOList) {
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())) {
plateDO.getCustomPlateNo().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getValue())));
plateDO.getCustomPlateNoBuilder().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getValue())));
}
// 遍历规则生成服务列表,获取对应的规则服务
for (CustomPlateNoGenerateRuleService ruleService : ruleServices) {
@@ -118,7 +118,7 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
}
}
}
plateDO.setPlateNo(plateDO.getCustomPlateNo().toString());
plateDO.setCustomPlateNo(plateDO.getCustomPlateNoBuilder().toString());
}
/**
@@ -1,12 +1,16 @@
package com.cf.imes.module.executor.service.customplateno.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrderCustomPlateNoSeqBodyVO implements Serializable {
private static final long serialVersionUID = 2686882895438975156L;
/**
@@ -1,13 +1,17 @@
package com.cf.imes.module.executor.service.customplateno.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrderCustomPlateNoSeqRoomVO implements Serializable {
private static final long serialVersionUID = -127388898531267048L;
/**
@@ -2,8 +2,16 @@ package com.cf.imes.module.executor.service.customplatenorule;
import cn.hutool.core.collection.CollUtil;
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.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.mysql.order.OrderMapper;
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.OrderCustomPlateNoSeqBodyVO;
@@ -14,6 +22,7 @@ import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -28,6 +37,10 @@ import static com.cf.imes.module.executor.enums.ErrorCodeConstants.CUSTOM_PLATEN
*/
@Service("bodyNoGenerateRuleService")
public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleService {
@Resource
private OrderMapper orderMapper;
@Override
public boolean match(String ruleCode) {
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.BODYNO.getRuleCode(), ruleCode);
@@ -72,6 +85,33 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
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))));
}
}
}
/**
* 按生产单复位模式下的板编号生成
*
@@ -123,7 +163,7 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
// 补零
String noPartAfterFillZero = fillZero(bodyNoSeq, plateNoRule);
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
// 累加后同步到json:柜体下累加到多少了
bodySeqVo.setBodyNoSeq(bodyNoSeq);
@@ -189,7 +229,7 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
// 补零
String noPartAfterFillZero = fillZero(roomBodyNoSeq, plateNoRule);
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
// 累加后同步到json中,room下柜体累加到多少了
roomBodySeqVo.setBodyNoSeq(roomBodyNoSeq);
@@ -3,7 +3,7 @@
//import cn.hutool.core.util.ObjectUtil;
//import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
//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 org.springframework.stereotype.Service;
//
@@ -23,7 +23,7 @@
// }
//
// @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) {
// plateDO.getCustomPlateNo().append(plateNoRule.getValue());
// }
@@ -1,5 +1,6 @@
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.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
@@ -46,4 +47,11 @@ public interface CustomPlateNoGenerateRuleService {
}
return String.valueOf(curr);
}
/**
* 复位
*
* @param ruleDTO
*/
void reset(CustomPlateNoRuleDTO ruleDTO);
}
@@ -3,7 +3,7 @@
//import cn.hutool.core.util.ObjectUtil;
//import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
//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 org.springframework.stereotype.Service;
//
@@ -24,7 +24,7 @@
// }
//
// @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) {
// plateDO.getCustomPlateNo().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getValue())));
// }
@@ -1,8 +1,16 @@
package com.cf.imes.module.executor.service.customplatenorule;
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.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.mysql.order.OrderMapper;
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.OrderCustomPlateNoSeqVO;
@@ -11,7 +19,9 @@ import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Optional;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.CUSTOM_PLATENO_GENERATE_ORDERNO_RULE_NOT_SUPPORT_RESETMODE;
@@ -29,6 +39,9 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
@Resource
private OrderMapper orderMapper;
@Override
public boolean match(String ruleCode) {
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.ORDERNO.getRuleCode(), ruleCode);
@@ -58,7 +71,7 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
if (ObjectUtil.isNotNull(orderNoSeq)) {
// 补零
String noPartAfterFill = this.fillZero(orderNoSeq, plateNoRule);
plateDO.getCustomPlateNo().append(noPartAfterFill);
plateDO.getCustomPlateNoBuilder().append(noPartAfterFill);
return generateConfig;
}
// 机构下的自定义板编号序号
@@ -73,7 +86,7 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
}
// 补零
String noPartAfterFill = this.fillZero(currOrderNoSeq, plateNoRule);
plateDO.getCustomPlateNo().append(noPartAfterFill);
plateDO.getCustomPlateNoBuilder().append(noPartAfterFill);
// 累加后的值同步到当前生产单序号和机构序号中
orderCustomPlateNoSeqVO.setOrderNoSeq(currOrderNoSeq);
@@ -81,6 +94,23 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
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))));
}
}
}
/**
* 基于复位模式的板编号生成
*
@@ -2,8 +2,16 @@ package com.cf.imes.module.executor.service.customplatenorule;
import cn.hutool.core.collection.CollUtil;
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.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.mysql.order.OrderMapper;
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.OrderCustomPlateNoSeqBodyVO;
@@ -14,6 +22,7 @@ import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
@@ -32,6 +41,9 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
@Resource
private OrderMapper orderMapper;
@Override
public boolean match(String ruleCode) {
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.PLATENO.getRuleCode(), ruleCode);
@@ -74,6 +86,64 @@ 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);
}
}
}
}
}
/**
* 按年/月/日复位模式下的板编号生成
*/
@@ -95,7 +165,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
}
// 补零
String noPartAfterFillZero = fillZero(orderNoSeq, plateNoRule);
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
orgCustomPlateNoSeqRespDTO.setPlateNoSeq(orderNoSeq);
return generateConfig;
@@ -126,7 +196,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
}
// 跨板件累加步长,补零
orderPlateNoSeq += incrementStep;
plateDO.getCustomPlateNo().append(fillZero(orderPlateNoSeq, plateNoRule));
plateDO.getCustomPlateNoBuilder().append(fillZero(orderPlateNoSeq, plateNoRule));
// 累加后的值同步到当前生产单序号中
orderCustomPlateNoSeqVO.setPlateNoSeq(orderPlateNoSeq);
return generateConfig;
@@ -164,7 +234,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
// 累加后的值同步到当前生产单序号中
roomSeqVo.setPlateNoSeq(roomPlateNoSeq);
// 补零
plateDO.getCustomPlateNo().append(fillZero(roomPlateNoSeq, plateNoRule));
plateDO.getCustomPlateNoBuilder().append(fillZero(roomPlateNoSeq, plateNoRule));
return generateConfig;
}
@@ -226,7 +296,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
bodySeqVO.setPlateNoSeq(bodyPlateNoSeq);
// 补零
String noPartAfterFillZero = fillZero(bodyPlateNoSeq, plateNoRule);
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
return generateConfig;
}
@@ -5,7 +5,7 @@
//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.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.OrderCustomPlateNoSeqRoomVO;
//import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqVO;
@@ -37,7 +37,7 @@
// }
//
// @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);
// // 按复位模式走不同的生成方式
@@ -85,7 +85,7 @@
// * @param plateDOList 板件列表
// * @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();
// // 生产单下的序号
// OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfig.getOrderCustomPlateNoSeqVO();
@@ -143,7 +143,7 @@
// * @param plateDOList
// * @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();
// // 生产单下的序号
// OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfig.getOrderCustomPlateNoSeqVO();
@@ -2,7 +2,15 @@ package com.cf.imes.module.executor.service.customplatenorule;
import cn.hutool.core.collection.CollUtil;
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.mysql.order.OrderMapper;
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.OrderCustomPlateNoSeqRoomVO;
@@ -11,6 +19,7 @@ import com.cf.imes.module.system.api.customplateno.dto.CustomPlateNoSeqDTO;
import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -23,6 +32,9 @@ import java.util.Optional;
*/
@Service("roomNoGenerateRuleService")
public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleService {
@Resource
private OrderMapper orderMapper;
@Override
public boolean match(String ruleCode) {
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.ROOMNO.getRuleCode(), ruleCode);
@@ -93,13 +105,30 @@ public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
// 补零
String noPartAfterFillZero = fillZero(roomNoSeq, plateNoRule);
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
// 累加后同步到json:房间下累加到多少了
roomSeqVo.setRoomNoSeq(roomNoSeq);
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.setRoomNoSeq(ruleDTO.getInitValue());
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderDO.getId()).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
}
}
}
/**
* 根据房间名从生产单序号json中获取房间序号列表
*
@@ -349,5 +349,8 @@ public class ErrorCodeConstants {
//=========== 系统配置 1-002-040-000 ============
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_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, "自定义板编号配置:手动复位/清零生产单下序号失败,请联系客服");
}
@@ -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.util.object.BeanUtils;
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.web.bind.annotation.RestController;
@@ -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);
}
}
@@ -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;
}
@@ -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.module.system.controller.admin.systemconfig.vo.*;
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.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -1,5 +1,6 @@
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.plan.OrderPlanApi;
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;
@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 {
}
@@ -1,5 +1,6 @@
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;
/**
@@ -22,4 +23,11 @@ public interface CustomPlateNoSeqService {
* @param seqDO
*/
Boolean modifyOrgCustomPlateNoSeq(CustomPlateNoSeqDO seqDO);
/**
* 规则手动复位/清零
*
* @param reqVO
*/
void updateRuleResetMode(CustomPlateNoRuleResetModeReqVO reqVO);
}
@@ -1,13 +1,31 @@
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.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.systemconfig.SystemConfigDO;
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.transaction.annotation.Transactional;
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
public class CustomPlateNoSeqServiceImpl implements CustomPlateNoSeqService {
@Resource
CustomPlateNoSeqMapper customPlateNoSeqMapper;
private CustomPlateNoSeqMapper customPlateNoSeqMapper;
@Resource
private SystemConfigMapper systemConfigMapper;
@Resource
private CustomPlateNoResetModeServiceFactory resetModeServiceFactory;
@Override
public CustomPlateNoSeqDO getOrgCustomPlateNoSeq() {
@@ -30,5 +54,41 @@ public class CustomPlateNoSeqServiceImpl implements CustomPlateNoSeqService {
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;
}
}
@@ -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);
}
}
}
@@ -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);
}
@@ -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;
}
}
}
@@ -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;
}
}
}
@@ -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;
}
}
}
@@ -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,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.ConfigPageReqVO;
@@ -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 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.redis.RedisKeyConstants;
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.config.factory.service.AbstractSystemConfigServiceHandler;
import com.cf.imes.module.system.service.systemconfig.factory.SystemConfigServiceFactory;
import com.cf.imes.module.system.service.systemconfig.factory.service.AbstractSystemConfigServiceHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@@ -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 com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.module.system.enums.ErrorCodeConstants;
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.config.factory.service.impl.CustomPlateNoServiceHandler;
import com.cf.imes.module.system.service.config.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.AbstractSystemConfigServiceHandler;
import com.cf.imes.module.system.service.systemconfig.factory.service.impl.CustomPlateNoServiceHandler;
import com.cf.imes.module.system.service.systemconfig.factory.service.impl.DefaultSystemConfigServiceHandler;
import com.cf.imes.module.system.service.systemconfig.factory.service.impl.IntellectBranchingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
@@ -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.ConfigPageReqVO;
@@ -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.ObjectUtil;
@@ -24,7 +24,7 @@ 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.config.SystemConfigTypeEnum;
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 lombok.extern.slf4j.Slf4j;
@@ -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 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.mysql.systemconfig.SystemConfigMapper;
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 org.springframework.stereotype.Service;
@@ -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;
@@ -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.dal.dataobject.systemconfig.SystemConfigDO;
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.springframework.stereotype.Service;