mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、systemconfig部分属性、字段、接口名修正;2、自定义板编号配置支持基于机构缓存,保存新增自定义板编号序号配置;3、自定义板编号规则保存校验完善;
This commit is contained in:
+14
-14
@@ -35,39 +35,39 @@ import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
@RestController
|
||||
@RequestMapping("/system/config")
|
||||
@Validated
|
||||
public class ConfigController {
|
||||
public class SystemConfigController {
|
||||
@Resource
|
||||
private SystemConfigService baseConfigService;
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@GetMapping()
|
||||
@Operation(summary = "获得系统配置的分页列表")
|
||||
@PreAuthorize("@ss.hasPermission('baseconfig:query')")
|
||||
public CommonResult<PageResult<ConfigRespVO>> getBaseConfigPage(@Valid ConfigPageReqVO pageReqVO) {
|
||||
PageResult<SystemConfigDO> pageResult = baseConfigService.getBaseConfigPage(pageReqVO);
|
||||
@PreAuthorize("@ss.hasPermission('system:base-setting:query')")
|
||||
public CommonResult<PageResult<ConfigRespVO>> getSystemConfigPage(@Valid ConfigPageReqVO pageReqVO) {
|
||||
PageResult<SystemConfigDO> pageResult = systemConfigService.getSystemConfigPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "根据id查询系统配置")
|
||||
@PreAuthorize("@ss.hasPermission('baseconfig:query')")
|
||||
public CommonResult<ConfigRespVO> getBaseConfig(@PathVariable Long id) {
|
||||
SystemConfigDO baseConfig = baseConfigService.getBaseConfig(id);
|
||||
return success(BeanUtils.toBean(baseConfig, ConfigRespVO.class));
|
||||
@PreAuthorize("@ss.hasPermission('system:base-setting:query')")
|
||||
public CommonResult<ConfigRespVO> getSystemConfig(@PathVariable("id") Long id) {
|
||||
SystemConfigDO systemConfigDO = systemConfigService.getSystemConfig(id);
|
||||
return success(BeanUtils.toBean(systemConfigDO, ConfigRespVO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/status")
|
||||
@Operation(summary = "修改系统配置状态")
|
||||
@PreAuthorize("@ss.hasPermission('baseconfig:update')")
|
||||
@PreAuthorize("@ss.hasPermission('system:base-setting:setting')")
|
||||
public CommonResult<Boolean> updateConfigStatus(@Valid @RequestBody ConfigUpdateStatusReqVO reqVO){
|
||||
baseConfigService.updateStatus(reqVO);
|
||||
systemConfigService.updateStatus(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
@Operation(summary = "修改系统配置")
|
||||
@PreAuthorize("@ss.hasPermission('baseconfig:update')")
|
||||
public CommonResult<Boolean> modifyBaseConfig(@Valid @RequestBody ConfigSaveReqVO reqVO) {
|
||||
baseConfigService.modifyBaseConfig(reqVO);
|
||||
@PreAuthorize("@ss.hasPermission('system:base-setting:setting')")
|
||||
public CommonResult<Boolean> modifySystemConfig(@Valid @RequestBody ConfigSaveReqVO reqVO) {
|
||||
systemConfigService.modifySystemConfig(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
}
|
||||
+24
-9
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.customblockno;
|
||||
package com.cf.imes.module.system.dal.dataobject.customplateno;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
@@ -11,7 +11,6 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@@ -20,14 +19,14 @@ import java.io.Serializable;
|
||||
* @author Gqr
|
||||
* @since 2024/11/11 18:31
|
||||
*/
|
||||
@TableName(value = "custom_blockno_seq", autoResultMap = true)
|
||||
@KeySequence("custom_blockno_seq_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@TableName(value = "custom_plateno_seq", autoResultMap = true)
|
||||
@KeySequence("custom_plateno_seq_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CustomBlockNoSeqDO implements Serializable {
|
||||
public class CustomPlateNoSeqDO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4362641672146584682L;
|
||||
|
||||
@@ -51,13 +50,27 @@ public class CustomBlockNoSeqDO implements Serializable {
|
||||
/**
|
||||
* 上次生产单号
|
||||
*/
|
||||
@TableField(value = "last_orderNo")
|
||||
private Long lastOrderNo;
|
||||
|
||||
/**
|
||||
* 生产单序号前值
|
||||
*/
|
||||
@TableField(value = "orderNo_seq")
|
||||
private Integer orderNoSeq;
|
||||
|
||||
/**
|
||||
* 上次板件号
|
||||
*/
|
||||
@TableField(value = "last_plateNo")
|
||||
private String lastPlateNo;
|
||||
|
||||
/**
|
||||
* 板件序号前值
|
||||
*/
|
||||
@TableField(value = "plateNo_seq")
|
||||
private Integer plateNoSeq;
|
||||
|
||||
/**
|
||||
* 上次房间
|
||||
*/
|
||||
@@ -71,22 +84,24 @@ public class CustomBlockNoSeqDO implements Serializable {
|
||||
/**
|
||||
* 上次柜体
|
||||
*/
|
||||
private String lastCabinet;
|
||||
private String lastBody;
|
||||
|
||||
/**
|
||||
* 柜体序号前值
|
||||
*/
|
||||
private Integer cabinetSeq;
|
||||
private Integer bodySeq;
|
||||
|
||||
/**
|
||||
* 上次加工组
|
||||
*/
|
||||
private String lastProcessingGroup;
|
||||
@TableField(value = "last_process_group")
|
||||
private String lastProcessGroup;
|
||||
|
||||
/**
|
||||
* 加工组序号前值
|
||||
*/
|
||||
private Integer processingGroupSeq;
|
||||
@TableField(value = "process_group_seq")
|
||||
private Integer processGroupSeq;
|
||||
|
||||
/**
|
||||
* 上次年
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.systemconfig;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 系统配置copydo 用于缓存
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/7 16:12
|
||||
*/
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SystemConfigCopyDO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1788458794035807655L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 配置项名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private int status;
|
||||
|
||||
/**
|
||||
* 配置类型
|
||||
*/
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* 配置规则
|
||||
*/
|
||||
private List<SystemConfigCustomPlateNoRuleItemCopyDO> ruleList;
|
||||
|
||||
/**
|
||||
* 组织id
|
||||
*/
|
||||
private Long organId;
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.systemconfig;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统配置copydo 用于缓存
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/12 11:21
|
||||
*/
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SystemConfigCustomPlateNoRuleItemCopyDO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5691595836226548840L;
|
||||
/**
|
||||
* 规则编码
|
||||
*/
|
||||
private String ruleCode;
|
||||
|
||||
/**
|
||||
* 规则值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 初始值
|
||||
*/
|
||||
private Integer initValue;
|
||||
|
||||
/**
|
||||
* 位数
|
||||
*/
|
||||
private Integer length;
|
||||
|
||||
/**
|
||||
* 是否左补零
|
||||
*/
|
||||
private boolean leftFillZero;
|
||||
|
||||
/**
|
||||
* 步长
|
||||
*/
|
||||
private Integer incrementStep;
|
||||
|
||||
/**
|
||||
* 复位/清零模式
|
||||
*/
|
||||
private Integer resetMode;
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.cf.imes.module.system.dal.mysql.customblockno;
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.system.dal.dataobject.customblockno.CustomBlockNoSeqDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 自定义板编号序号 mapper
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/11 18:38
|
||||
*/
|
||||
@Mapper
|
||||
public interface CustomBlockNoSeqMapper extends BaseMapperX<CustomBlockNoSeqDO> {
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.cf.imes.module.system.dal.mysql.customplateno;
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.dal.dataobject.customplateno.CustomPlateNoSeqDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 自定义板编号序号 mapper
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/11 18:38
|
||||
*/
|
||||
@Mapper
|
||||
public interface CustomPlateNoSeqMapper extends BaseMapperX<CustomPlateNoSeqDO> {
|
||||
|
||||
/**
|
||||
* 查询系统配置编号下的自定义板编号序号
|
||||
* @param configId
|
||||
* @return
|
||||
*/
|
||||
default CustomPlateNoSeqDO getPlateNoSeqByConfigId(Long configId) {
|
||||
return selectOne(new LambdaQueryWrapperX<CustomPlateNoSeqDO>()
|
||||
.eq(CustomPlateNoSeqDO::getConfigId, configId)
|
||||
.eq(CustomPlateNoSeqDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||
}
|
||||
}
|
||||
+10
@@ -114,4 +114,14 @@ public class RedisKeyConstants {
|
||||
* !!!!注意同步修改OrganRedisCacheManager中的key字符串
|
||||
*/
|
||||
public static final String TENANT_PACKAGE_MENU_IDS = "tenant_package_menu_ids#12h";
|
||||
|
||||
/**
|
||||
* 系统配置
|
||||
*/
|
||||
public static final String SYSTEM_CONFIG = "system_config";
|
||||
|
||||
/**
|
||||
* 自定义板编号
|
||||
*/
|
||||
public static final String CUSTOM_PLATE_NO = "custom_plateno";
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@ public enum SystemConfigTypeEnum {
|
||||
/**
|
||||
* 自定义板编号
|
||||
*/
|
||||
CUSTOM_BOARD_NO(1, "自定义板编号"),
|
||||
CUSTOM_PLATE_NO(1, "自定义板编号"),
|
||||
|
||||
/**
|
||||
* 智能分线
|
||||
|
||||
+10
-3
@@ -4,6 +4,7 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
||||
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.ConfigUpdateStatusReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigCopyDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
||||
|
||||
/**
|
||||
@@ -19,7 +20,7 @@ public interface SystemConfigService {
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
PageResult<SystemConfigDO> getBaseConfigPage(ConfigPageReqVO reqVO);
|
||||
PageResult<SystemConfigDO> getSystemConfigPage(ConfigPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 根据id查询基础配置
|
||||
@@ -27,14 +28,14 @@ public interface SystemConfigService {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
SystemConfigDO getBaseConfig(Long id);
|
||||
SystemConfigDO getSystemConfig(Long id);
|
||||
|
||||
/**
|
||||
* 新增/修改基础配置
|
||||
*
|
||||
* @param reqVO
|
||||
*/
|
||||
void modifyBaseConfig(ConfigSaveReqVO reqVO);
|
||||
void modifySystemConfig(ConfigSaveReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 更新基础配置状态
|
||||
@@ -42,4 +43,10 @@ public interface SystemConfigService {
|
||||
* @param reqVO
|
||||
*/
|
||||
void updateStatus(ConfigUpdateStatusReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 查询组织下自定义板编号配置(缓存)
|
||||
* @return
|
||||
*/
|
||||
SystemConfigCopyDO getOrgCustomPlateNoConfig();
|
||||
}
|
||||
|
||||
+40
-22
@@ -1,7 +1,9 @@
|
||||
package com.cf.imes.module.system.service.config;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
@@ -9,13 +11,17 @@ import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
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.ConfigUpdateStatusReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigCopyDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigCustomPlateNoRuleItemCopyDO;
|
||||
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.AbstractSystemConfigGenerateService;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -38,20 +44,20 @@ import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_N
|
||||
public class SystemConfigServiceImpl implements SystemConfigService {
|
||||
|
||||
@Resource
|
||||
private SystemConfigMapper baseConfigMapper;
|
||||
private SystemConfigMapper systemConfigMapper;
|
||||
|
||||
@Resource
|
||||
private SystemConfigServiceFactory configServiceFactory;
|
||||
|
||||
@Override
|
||||
public PageResult<SystemConfigDO> getBaseConfigPage(ConfigPageReqVO reqVO) {
|
||||
PageResult<SystemConfigDO> configDOPageResult = baseConfigMapper.selectPage(reqVO);
|
||||
public PageResult<SystemConfigDO> getSystemConfigPage(ConfigPageReqVO reqVO) {
|
||||
PageResult<SystemConfigDO> configDOPageResult = systemConfigMapper.selectPage(reqVO);
|
||||
// todo 后续所有configTypeEnum中的类型需要上到列表补全时通过遍历enum来补充
|
||||
SystemConfigTypeEnum customBoardNoEnum = SystemConfigTypeEnum.CUSTOM_BOARD_NO;
|
||||
SystemConfigTypeEnum customplateNoEnum = SystemConfigTypeEnum.CUSTOM_PLATE_NO;
|
||||
CopyOnWriteArrayList<SystemConfigDO> configDOS = Lists.newCopyOnWriteArrayList(configDOPageResult.getList());
|
||||
Optional<SystemConfigDO> configDOOptional = configDOS.stream().filter(c -> ObjectUtil.equal(customBoardNoEnum.getType(), c.getType())).findAny();
|
||||
Optional<SystemConfigDO> configDOOptional = configDOS.stream().filter(c -> ObjectUtil.equal(customplateNoEnum.getType(), c.getType())).findAny();
|
||||
if (configDOOptional.isEmpty()) {
|
||||
configDOS.add(new SystemConfigDO().builder().id(null).name(customBoardNoEnum.getName()).type(customBoardNoEnum.getType()).build());
|
||||
configDOS.add(new SystemConfigDO().builder().id(null).name(customplateNoEnum.getName()).type(customplateNoEnum.getType()).build());
|
||||
configDOPageResult.setList(configDOS);
|
||||
configDOPageResult.setTotal(configDOPageResult.getTotal() + 1);
|
||||
}
|
||||
@@ -59,13 +65,13 @@ public class SystemConfigServiceImpl implements SystemConfigService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemConfigDO getBaseConfig(Long id) {
|
||||
return validateBaseConfigExists(id);
|
||||
public SystemConfigDO getSystemConfig(Long id) {
|
||||
return validateSystemConfigExists(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyBaseConfig(ConfigSaveReqVO reqVO) {
|
||||
public void modifySystemConfig(ConfigSaveReqVO reqVO) {
|
||||
Long id = reqVO.getId();
|
||||
// 根据配置类型选择对应的service
|
||||
AbstractSystemConfigGenerateService configService = configServiceFactory.getConfigService(reqVO.getType());
|
||||
@@ -73,45 +79,57 @@ public class SystemConfigServiceImpl implements SystemConfigService {
|
||||
configService.checkValid(reqVO.getSetting());
|
||||
// 系统配置保存前操作
|
||||
configService.beforeSaveConfig(reqVO);
|
||||
SystemConfigDO baseConfigDO;
|
||||
SystemConfigDO systemConfigDO;
|
||||
if (ObjectUtil.isNotNull(id)) {
|
||||
baseConfigDO = validateBaseConfigExists(id);
|
||||
systemConfigDO = validateSystemConfigExists(id);
|
||||
// 覆盖配置
|
||||
baseConfigDO.setSetting(reqVO.getSetting());
|
||||
systemConfigDO.setSetting(reqVO.getSetting());
|
||||
// 更新
|
||||
baseConfigMapper.updateById(baseConfigDO);
|
||||
systemConfigMapper.updateById(systemConfigDO);
|
||||
} else {
|
||||
baseConfigDO = BeanUtils.toBean(reqVO, SystemConfigDO.class);
|
||||
systemConfigDO = BeanUtils.toBean(reqVO, SystemConfigDO.class);
|
||||
// 新增
|
||||
baseConfigMapper.insert(baseConfigDO);
|
||||
systemConfigMapper.insert(systemConfigDO);
|
||||
}
|
||||
// 系统配置保存后操作
|
||||
configService.afterSaveConfig(baseConfigDO, reqVO);
|
||||
configService.afterSaveConfig(systemConfigDO, reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(ConfigUpdateStatusReqVO reqVO) {
|
||||
Long id = reqVO.getId();
|
||||
// 校验存在
|
||||
validateBaseConfigExists(id);
|
||||
validateSystemConfigExists(id);
|
||||
// 更新状态
|
||||
baseConfigMapper.update(new LambdaUpdateWrapper<SystemConfigDO>().eq(SystemConfigDO::getId, id).set(SystemConfigDO::getStatus, reqVO.getStatus()));
|
||||
systemConfigMapper.update(new LambdaUpdateWrapper<SystemConfigDO>().eq(SystemConfigDO::getId, id).set(SystemConfigDO::getStatus, reqVO.getStatus()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Cacheable(cacheNames = RedisKeyConstants.SYSTEM_CONFIG, key = "'" + RedisKeyConstants.CUSTOM_PLATE_NO + "'")
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验基础配置是否存在
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private SystemConfigDO validateBaseConfigExists(Long id) {
|
||||
SystemConfigDO baseConfigDO = baseConfigMapper.selectOne(new LambdaQueryWrapperX<SystemConfigDO>()
|
||||
private SystemConfigDO validateSystemConfigExists(Long id) {
|
||||
SystemConfigDO systemConfigDO = systemConfigMapper.selectOne(new LambdaQueryWrapperX<SystemConfigDO>()
|
||||
.eq(SystemConfigDO::getId, id)
|
||||
.eq(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||
if (ObjectUtil.isNull(baseConfigDO)) {
|
||||
if (ObjectUtil.isNull(systemConfigDO)) {
|
||||
throw exception(SYSTEM_CONFIG_NOT_EXISTS);
|
||||
}
|
||||
return baseConfigDO;
|
||||
return systemConfigDO;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ 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.CustomBoardNoGenerateService;
|
||||
import com.cf.imes.module.system.service.config.factory.service.impl.CustomPlateNoGenerateService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -34,8 +34,8 @@ public class SystemConfigServiceFactory {
|
||||
*/
|
||||
public AbstractSystemConfigGenerateService getConfigService(int type) {
|
||||
switch (SystemConfigTypeEnum.fromType(type)) {
|
||||
case CUSTOM_BOARD_NO:
|
||||
return applicationContext.getBean(CustomBoardNoGenerateService.class);
|
||||
case CUSTOM_PLATE_NO:
|
||||
return applicationContext.getBean(CustomPlateNoGenerateService.class);
|
||||
case INTELLIGENT_BRANCH:
|
||||
// todo 智能分线
|
||||
case ADVANCED_SCREEN:
|
||||
|
||||
+39
-25
@@ -10,9 +10,10 @@ 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.module.system.controller.admin.systemconfig.vo.ConfigSaveReqVO;
|
||||
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.customblockno.CustomBlockNoSeqMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.customplateno.CustomPlateNoSeqMapper;
|
||||
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.dict.DictDataService;
|
||||
@@ -21,7 +22,9 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_CUSTOM_BOARD_NO_RULE_SAVE_CHECK_ERROR;
|
||||
@@ -32,16 +35,16 @@ import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_C
|
||||
* @author Gqr
|
||||
* @since 2024/11/8 16:48
|
||||
*/
|
||||
@Service("customBoardNoGenerateService")
|
||||
@Service("customPlateNoGenerateService")
|
||||
@Slf4j
|
||||
public class CustomBoardNoGenerateService extends AbstractSystemConfigGenerateService {
|
||||
public class CustomPlateNoGenerateService extends AbstractSystemConfigGenerateService {
|
||||
|
||||
// 自定义板编号校验错误全部统一编号:1_002_040_003
|
||||
public static final ErrorCode CUSTOM_BOARD_NO_RULE_CHECK_RULECODE_EMPTY_ERROR = new ErrorCode(1_002_040_003, "规则编码不能为空");
|
||||
public static final ErrorCode CUSTOM_BOARD_NO_RULE_CHECK_RULECODE_NOT_MATCH_ERROR = new ErrorCode(1_002_040_003, "规则编码【{}】不合法,请检查配置规则");
|
||||
public static final ErrorCode CUSTOM_BOARD_NO_RULE_CHECK_DATE_TYPE_FORMAT_ERROR = new ErrorCode(1_002_040_003, "时间格式【{}】不合法,请检查配置规则");
|
||||
public static final ErrorCode CUSTOM_BOARD_NO_RULE_CHECK_RESETMODE_ERROR = new ErrorCode(1_002_040_003, "复位/清零模式【{}】不合法,请检查配置规则");
|
||||
public static final ErrorCode CUSTOM_BOARD_NO_RULE_CHECK_INT_TYPE_NO_EMPTY = new ErrorCode(1_002_040_003, "数字类型【{}】不能为空,请检查配置规则");
|
||||
public static final ErrorCode CUSTOM_BOARD_NO_RULE_CHECK_INT_TYPE_NO_EMPTY = new ErrorCode(1_002_040_003, "参数【{}】不能为空,请检查配置规则");
|
||||
public static final ErrorCode CUSTOM_BOARD_NO_RULE_CHECK_INT_TYPE_ERROR = new ErrorCode(1_002_040_003, "数值类型参数{}:【{}】转换异常,请检查配置规则");
|
||||
public static final ErrorCode CUSTOM_BOARD_NO_RULE_CHECK_BOL_TYPE_ERROR = new ErrorCode(1_002_040_003, "布尔类型参数{}:【{}】转换异常,请检查配置规则");
|
||||
|
||||
@@ -50,7 +53,7 @@ public class CustomBoardNoGenerateService extends AbstractSystemConfigGenerateSe
|
||||
private DictDataService dictDataService;
|
||||
|
||||
@Resource
|
||||
private CustomBlockNoSeqMapper customBlockNoSeqMapper;
|
||||
private CustomPlateNoSeqMapper customPlateNoSeqMapper;
|
||||
|
||||
@Override
|
||||
public void checkValid(String setting) {
|
||||
@@ -79,11 +82,10 @@ public class CustomBoardNoGenerateService extends AbstractSystemConfigGenerateSe
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
ErrorCode systemConfigCustomBoardNoRuleSaveCheckError = SYSTEM_CONFIG_CUSTOM_BOARD_NO_RULE_SAVE_CHECK_ERROR;
|
||||
log.error(systemConfigCustomBoardNoRuleSaveCheckError.getMsg(), e);
|
||||
throw new ServiceException(systemConfigCustomBoardNoRuleSaveCheckError);
|
||||
ErrorCode systemConfigCustomPlateNoRuleSaveCheckError = SYSTEM_CONFIG_CUSTOM_BOARD_NO_RULE_SAVE_CHECK_ERROR;
|
||||
log.error(systemConfigCustomPlateNoRuleSaveCheckError.getMsg(), e);
|
||||
throw new ServiceException(systemConfigCustomPlateNoRuleSaveCheckError);
|
||||
}
|
||||
throw new ServiceException();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,41 +132,47 @@ public class CustomBoardNoGenerateService extends AbstractSystemConfigGenerateSe
|
||||
|| ObjectUtil.equal(CustBoardRuleCodeEnum.ROOMNO, custBoardRuleCodeEnum)
|
||||
|| ObjectUtil.equal(CustBoardRuleCodeEnum.BODYNO, custBoardRuleCodeEnum)
|
||||
|| ObjectUtil.equal(CustBoardRuleCodeEnum.PROCESSGROUP, custBoardRuleCodeEnum)) {
|
||||
String[] intTypeFieldArr = new String[]{"initValue", "length", "resetMode", "increment_step"};
|
||||
String[] bolTypeFieldArr = new String[]{"left_fill_zero"};
|
||||
for (String field : intTypeFieldArr) {
|
||||
checkInt(field, object.get(field));
|
||||
}
|
||||
for (String field : bolTypeFieldArr) {
|
||||
checkBol(field, object.get(field));
|
||||
}
|
||||
Map<String, String> intTypeFieldMap = new HashMap<>() {{
|
||||
put("initValue", "起始值");
|
||||
put("length", "位数");
|
||||
put("resetMode", "复位/清零模式");
|
||||
put("increment_step", "递增值");
|
||||
}};
|
||||
Map<String, String> bolTypeFieldMap = new HashMap<>() {{
|
||||
put("left_fill_zero", "是否左补零");
|
||||
}};
|
||||
intTypeFieldMap.forEach((k, v) -> checkInt(object.get(k), v));
|
||||
bolTypeFieldMap.forEach((k, v) -> checkBol(object.get(k), v));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验整型
|
||||
*
|
||||
* @param intObj
|
||||
* @param fieldName
|
||||
*/
|
||||
private void checkInt(String field, Object intObj) {
|
||||
private void checkInt(Object intObj, String fieldName) {
|
||||
if (ObjectUtil.isNull(intObj)) {
|
||||
throw ServiceExceptionUtil.exception(CUSTOM_BOARD_NO_RULE_CHECK_INT_TYPE_NO_EMPTY, field);
|
||||
throw ServiceExceptionUtil.exception(CUSTOM_BOARD_NO_RULE_CHECK_INT_TYPE_NO_EMPTY, fieldName);
|
||||
}
|
||||
if (!NumberUtil.isInteger(intObj.toString())) {
|
||||
throw ServiceExceptionUtil.exception(CUSTOM_BOARD_NO_RULE_CHECK_INT_TYPE_ERROR, field, intObj);
|
||||
throw ServiceExceptionUtil.exception(CUSTOM_BOARD_NO_RULE_CHECK_INT_TYPE_ERROR, fieldName, intObj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验布尔型
|
||||
*
|
||||
* @param field
|
||||
* @param bolObj
|
||||
* @param fieldName
|
||||
*/
|
||||
private void checkBol(String field, Object bolObj) {
|
||||
private void checkBol(Object bolObj, String fieldName) {
|
||||
if (ObjectUtil.isNull(bolObj)) {
|
||||
throw ServiceExceptionUtil.exception(CUSTOM_BOARD_NO_RULE_CHECK_INT_TYPE_NO_EMPTY, field);
|
||||
throw ServiceExceptionUtil.exception(CUSTOM_BOARD_NO_RULE_CHECK_INT_TYPE_NO_EMPTY, fieldName);
|
||||
}
|
||||
if (!(bolObj instanceof Boolean)) {
|
||||
throw ServiceExceptionUtil.exception(CUSTOM_BOARD_NO_RULE_CHECK_BOL_TYPE_ERROR, field, bolObj);
|
||||
throw ServiceExceptionUtil.exception(CUSTOM_BOARD_NO_RULE_CHECK_BOL_TYPE_ERROR, fieldName, bolObj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,6 +202,12 @@ public class CustomBoardNoGenerateService extends AbstractSystemConfigGenerateSe
|
||||
|
||||
@Override
|
||||
public void afterSaveConfig(SystemConfigDO systemConfigDO, ConfigSaveReqVO reqVO) {
|
||||
|
||||
Long configId = systemConfigDO.getId();
|
||||
// 查询机构下组织id的自增序号
|
||||
CustomPlateNoSeqDO plateNoSeqByConfigId = customPlateNoSeqMapper.getPlateNoSeqByConfigId(configId);
|
||||
// 提前生成板编号序号,存在则不处理
|
||||
if (ObjectUtil.isNull(plateNoSeqByConfigId)) {
|
||||
customPlateNoSeqMapper.insert(CustomPlateNoSeqDO.builder().configId(configId).build());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user