1、自定义板编号配置相关实体字段调整;2、服务处理类AbstractSystemConfigGenerateService相关命名修改;3、新增自定义板编号配置修改状态后缓存移除操作;

This commit is contained in:
gaoqr
2024-11-14 11:39:16 +08:00
parent 86603f927e
commit 265fd60474
6 changed files with 39 additions and 57 deletions
@@ -60,49 +60,11 @@ public class CustomPlateNoSeqDO implements Serializable {
private Integer orderNoSeq;
/**
* 上次板件号
*/
@TableField(value = "last_plateNo")
private String lastPlateNo;
/**
* 板件序号前值
* 板序号前值
*/
@TableField(value = "plateNo_seq")
private Integer plateNoSeq;
/**
* 上次房间
*/
private String lastRoom;
/**
* 房间序号前值
*/
private Integer roomSeq;
/**
* 上次柜体
*/
private String lastBody;
/**
* 柜体序号前值
*/
private Integer bodySeq;
/**
* 上次加工组
*/
@TableField(value = "last_process_group")
private String lastProcessGroup;
/**
* 加工组序号前值
*/
@TableField(value = "process_group_seq")
private Integer processGroupSeq;
/**
* 上次年
*/
@@ -63,4 +63,9 @@ public class SystemConfigDO extends BaseDO {
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long organId;
/**
* 版本号
*/
private int version;
}
@@ -18,7 +18,7 @@ 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.AbstractSystemConfigGenerateService;
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigServiceHandler;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
@@ -74,7 +74,7 @@ public class SystemConfigServiceImpl implements SystemConfigService {
public void modifySystemConfig(ConfigSaveReqVO reqVO) {
Long id = reqVO.getId();
// 根据配置类型选择对应的service
AbstractSystemConfigGenerateService configService = configServiceFactory.getConfigService(reqVO.getType());
AbstractSystemConfigServiceHandler configService = configServiceFactory.getConfigServiceHandler(reqVO.getType());
// 校验规则
configService.checkValid(reqVO.getSetting());
// 系统配置保存前操作
@@ -98,7 +98,7 @@ public class SystemConfigServiceImpl implements SystemConfigService {
@Override
public void updateStatus(ConfigUpdateStatusReqVO reqVO) {
// 根据配置类型选择对应的service
AbstractSystemConfigGenerateService configService = configServiceFactory.getConfigService(reqVO.getType());
AbstractSystemConfigServiceHandler configService = configServiceFactory.getConfigServiceHandler(reqVO.getType());
Long id = reqVO.getId();
// 校验存在
SystemConfigDO systemConfigDO = validateSystemConfigExists(id);
@@ -110,15 +110,19 @@ public class SystemConfigServiceImpl implements SystemConfigService {
@Override
@Cacheable(cacheNames = RedisKeyConstants.SYSTEM_CONFIG, key = "'" + RedisKeyConstants.CUSTOM_PLATE_NO + "'")
@Cacheable(cacheNames = RedisKeyConstants.SYSTEM_CONFIG, key = "'" + RedisKeyConstants.CUSTOM_PLATE_NO + "'", unless = "#result == null")
public SystemConfigCopyDO getOrgCustomPlateNoConfig() {
SystemConfigDO systemConfigDO = systemConfigMapper.selectOne(new LambdaUpdateWrapper<SystemConfigDO>()
.eq(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId())
.eq(SystemConfigDO::getType, SystemConfigTypeEnum.CUSTOM_PLATE_NO.getType())
.eq(SystemConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus()));
SystemConfigCopyDO copyDO = JSON.parseObject(JSON.toJSONString(systemConfigDO), SystemConfigCopyDO.class);
copyDO.setRuleList(JSON.parseArray(systemConfigDO.getSetting(), SystemConfigCustomPlateNoRuleItemCopyDO.class));
return copyDO;
if (ObjectUtil.isNotNull(systemConfigDO)) {
SystemConfigCopyDO copyDO = JSON.parseObject(JSON.toJSONString(systemConfigDO), SystemConfigCopyDO.class);
copyDO.setRuleList(JSON.parseArray(systemConfigDO.getSetting(), SystemConfigCustomPlateNoRuleItemCopyDO.class));
return copyDO;
} else {
return null;
}
}
/**
@@ -2,8 +2,8 @@ package com.cf.imes.module.system.service.config.factory;
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigGenerateService;
import com.cf.imes.module.system.service.config.factory.service.impl.CustomPlateNoGenerateService;
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigServiceHandler;
import com.cf.imes.module.system.service.config.factory.service.impl.CustomPlateNoGenerateServiceHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
@@ -32,10 +32,10 @@ public class SystemConfigServiceFactory {
* @param type
* @return
*/
public AbstractSystemConfigGenerateService getConfigService(int type) {
public AbstractSystemConfigServiceHandler getConfigServiceHandler(int type) {
switch (SystemConfigTypeEnum.fromType(type)) {
case CUSTOM_PLATE_NO:
return applicationContext.getBean(CustomPlateNoGenerateService.class);
return applicationContext.getBean(CustomPlateNoGenerateServiceHandler.class);
case INTELLIGENT_BRANCH:
// todo 智能分线
case ADVANCED_SCREEN:
@@ -5,12 +5,12 @@ import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateSt
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
/**
* 系统配置生成服务抽象类
* 系统配置服务处理器抽象类
*
* @author Gqr
* @since 2024/11/8 16:45
*/
public abstract class AbstractSystemConfigGenerateService {
public abstract class AbstractSystemConfigServiceHandler {
/**
* 校验配置的合法性
@@ -9,17 +9,20 @@ import com.cf.imes.framework.common.enums.CommonStatusEnum;
import com.cf.imes.framework.common.exception.ErrorCode;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
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.dal.dataobject.customplateno.CustomPlateNoSeqDO;
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.mysql.customplateno.CustomPlateNoSeqMapper;
import com.cf.imes.module.system.dal.redis.RedisKeyConstants;
import com.cf.imes.module.system.enums.config.CustBoardRuleCodeEnum;
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigGenerateService;
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigServiceHandler;
import com.cf.imes.module.system.service.dict.DictDataService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -31,14 +34,14 @@ import java.util.Optional;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_CUSTOM_BOARD_NO_RULE_SAVE_CHECK_ERROR;
/**
* 自定义板编号生成服务
* 自定义板编号服务处理器
*
* @author Gqr
* @since 2024/11/8 16:48
*/
@Service("customPlateNoGenerateService")
@Service("customPlateNoGenerateServiceHandler")
@Slf4j
public class CustomPlateNoGenerateService extends AbstractSystemConfigGenerateService {
public class CustomPlateNoGenerateServiceHandler extends AbstractSystemConfigServiceHandler {
// 自定义板编号校验错误全部统一编号1_002_040_003
public static final ErrorCode CUSTOM_BOARD_NO_RULE_CHECK_RULECODE_EMPTY_ERROR = new ErrorCode(1_002_040_003, "规则编码不能为空");
@@ -56,6 +59,9 @@ public class CustomPlateNoGenerateService extends AbstractSystemConfigGenerateSe
@Resource
private CustomPlateNoSeqMapper customPlateNoSeqMapper;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Override
public void checkValid(String setting) {
// 字典中的时间格式
@@ -214,6 +220,11 @@ public class CustomPlateNoGenerateService extends AbstractSystemConfigGenerateSe
@Override
public void afterUpdateStatus(SystemConfigDO systemConfigDO, ConfigUpdateStatusReqVO reqVO) {
// todo afterUpdateStatus
if (CommonStatusEnum.DISABLE.getStatus().equals(reqVO.getStatus())) {
// 禁用配置移除缓存
String redisKey = String.format("%s:%d:%s", RedisKeyConstants.SYSTEM_CONFIG, OrganContextHolder.getOrganId(), RedisKeyConstants.CUSTOM_PLATE_NO);
Boolean delete = stringRedisTemplate.delete(redisKey);
log.info("[CustomPlateNoGenerateService][afterUpdateStatus]key{}缓存删除结果:{}", redisKey, delete);
}
}
}