mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、系统管理配置列表改为不分页,自定义板编号筛选返回最大版本号;2、系统配置服务处理器抽象修改;3、新增自定义板编号相关feign服务;
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
package com.cf.imes.module.system.api.customplateno;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.system.api.customplateno.dto.CustomPlateNoSeqRespDTO;
|
||||
import com.cf.imes.module.system.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.GetMapping;
|
||||
|
||||
|
||||
/**
|
||||
* 自定义板编号序号feign接口
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/15 11:26
|
||||
*/
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 晨丰:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 自定义板编号序号")
|
||||
public interface CustomPlateNoSeqApi {
|
||||
String PREFIX = ApiConstants.PREFIX + "/custom-plateno-seq";
|
||||
|
||||
@GetMapping(PREFIX + "/organ")
|
||||
@Operation(summary = "获取组织下自定义版编号序号")
|
||||
CommonResult<CustomPlateNoSeqRespDTO> getOrgCustomPlateNoSeq();
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.cf.imes.module.system.api.customplateno.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/11/15 14:18
|
||||
*/
|
||||
@Schema(description = "RPC 服务 - 自定义板编号序号 Resp DTO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CustomPlateNoSeqRespDTO implements Serializable {
|
||||
private static final long serialVersionUID = -3415615478757941611L;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 组织ID
|
||||
*/
|
||||
private Long organId;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private Long configId;
|
||||
|
||||
/**
|
||||
* 上次生产单号
|
||||
*/
|
||||
private Long lastOrderNo;
|
||||
|
||||
/**
|
||||
* 生产单序号前值
|
||||
*/
|
||||
private Integer orderNoSeq;
|
||||
|
||||
/**
|
||||
* 板序号前值
|
||||
*/
|
||||
private Integer plateNoSeq;
|
||||
|
||||
/**
|
||||
* 上次年
|
||||
*/
|
||||
private int lastYear;
|
||||
|
||||
/**
|
||||
* 上次月
|
||||
*/
|
||||
private int lastMonth;
|
||||
|
||||
/**
|
||||
* 上次天
|
||||
*/
|
||||
private int lastDay;
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.cf.imes.module.system.api.systemconfig;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.system.api.systemconfig.dto.SystemConfigRespDTO;
|
||||
import com.cf.imes.module.system.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.GetMapping;
|
||||
|
||||
|
||||
/**
|
||||
* 系统配置feign接口
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/15 11:26
|
||||
*/
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 晨丰:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 系统配置")
|
||||
public interface SystemConfigApi {
|
||||
String PREFIX = ApiConstants.PREFIX + "/system-config";
|
||||
|
||||
@GetMapping(PREFIX + "/organ/custom-plateno-config")
|
||||
@Operation(summary = "获取组织下自定义版编号配置")
|
||||
CommonResult<SystemConfigRespDTO> getOrgCustomPlateNoConfig();
|
||||
|
||||
@GetMapping(PREFIX + "/organ/custom-plateno-config/{id}")
|
||||
@Operation(summary = "获取组织下自定义版编号配置")
|
||||
CommonResult<SystemConfigRespDTO> getById(Long id);
|
||||
}
|
||||
+6
-8
@@ -1,25 +1,23 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.systemconfig;
|
||||
package com.cf.imes.module.system.api.systemconfig.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
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
|
||||
*/
|
||||
@Schema(description = "RPC 服务 - 系统配置 Resp DTO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SystemConfigCopyDO implements Serializable {
|
||||
public class SystemConfigRespDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1788458794035807655L;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class SystemConfigCopyDO implements Serializable {
|
||||
/**
|
||||
* 配置规则
|
||||
*/
|
||||
private List<SystemConfigCustomPlateNoRuleItemCopyDO> ruleList;
|
||||
private String setting;
|
||||
|
||||
/**
|
||||
* 组织id
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.cf.imes.module.system.api.customplateno;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.api.customplateno.dto.CustomPlateNoSeqRespDTO;
|
||||
import com.cf.imes.module.system.service.customplateno.CustomPlateNoSeqService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 自定义板编号序号feign实现类
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/15 11:39
|
||||
*/
|
||||
@RestController
|
||||
@Validated
|
||||
public class CustomPlateNoSeqApiImpl implements CustomPlateNoSeqApi {
|
||||
|
||||
@Resource
|
||||
private CustomPlateNoSeqService customPlateNoSeqService;
|
||||
|
||||
@Override
|
||||
public CommonResult<CustomPlateNoSeqRespDTO> getOrgCustomPlateNoSeq() {
|
||||
return CommonResult.success(BeanUtils.toBean(customPlateNoSeqService.getOrgCustomPlateNoSeq(), CustomPlateNoSeqRespDTO.class));
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
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 org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 系统配置feign实现类
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/15 11:39
|
||||
*/
|
||||
@RestController
|
||||
@Validated
|
||||
public class SystemConfigApiImpl implements SystemConfigApi {
|
||||
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Override
|
||||
public CommonResult<SystemConfigRespDTO> getOrgCustomPlateNoConfig() {
|
||||
return success(BeanUtils.toBean(systemConfigService.getOrgCustomPlateNoConfig(), SystemConfigRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<SystemConfigRespDTO> getById(Long id) {
|
||||
return success(BeanUtils.toBean(systemConfigService.getSystemConfig(id), SystemConfigRespDTO.class));
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -1,7 +1,6 @@
|
||||
package com.cf.imes.module.system.controller.admin.systemconfig;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
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;
|
||||
@@ -15,6 +14,8 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
@@ -34,8 +35,8 @@ public class SystemConfigController {
|
||||
@GetMapping()
|
||||
@Operation(summary = "获得系统配置的分页列表")
|
||||
@PreAuthorize("@ss.hasPermission('system:base-setting:query')")
|
||||
public CommonResult<PageResult<ConfigRespVO>> getSystemConfigPage(@Valid ConfigPageReqVO pageReqVO) {
|
||||
PageResult<SystemConfigDO> pageResult = systemConfigService.getSystemConfigPage(pageReqVO);
|
||||
public CommonResult<List<ConfigRespVO>> getSystemConfigPage(@Valid ConfigPageReqVO pageReqVO) {
|
||||
List<SystemConfigDO> pageResult = systemConfigService.getSystemConfigList(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ConfigRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
-2
@@ -7,7 +7,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
@@ -30,7 +29,6 @@ public class ConfigPageReqVO extends PageParam {
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "配置类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "配置类型不能为空")
|
||||
@SystemConfigTypeEnumValid
|
||||
private Integer type;
|
||||
}
|
||||
|
||||
+5
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.system.controller.admin.systemconfig.vo;
|
||||
|
||||
import com.cf.imes.module.system.validation.config.SystemConfigTypeEnumValid;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -32,4 +33,8 @@ public class ConfigSaveReqVO {
|
||||
|
||||
@Schema(description = "配置规则")
|
||||
private String setting;
|
||||
|
||||
@JsonIgnore
|
||||
@Schema(hidden = true)
|
||||
private int version;
|
||||
}
|
||||
|
||||
+3
-8
@@ -42,11 +42,6 @@ public class CustomPlateNoSeqDO implements Serializable {
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Long organId;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private Long configId;
|
||||
|
||||
/**
|
||||
* 上次生产单号
|
||||
*/
|
||||
@@ -68,15 +63,15 @@ public class CustomPlateNoSeqDO implements Serializable {
|
||||
/**
|
||||
* 上次年
|
||||
*/
|
||||
private Short lastYear;
|
||||
private int lastYear;
|
||||
|
||||
/**
|
||||
* 上次月
|
||||
*/
|
||||
private Short lastMonth;
|
||||
private int lastMonth;
|
||||
|
||||
/**
|
||||
* 上次天
|
||||
*/
|
||||
private Short lastDay;
|
||||
private int lastDay;
|
||||
}
|
||||
|
||||
-13
@@ -1,8 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -14,15 +12,4 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
*/
|
||||
@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()));
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -9,6 +9,7 @@ import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqV
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
||||
import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,7 +23,7 @@ import java.util.List;
|
||||
public interface SystemConfigMapper extends BaseMapperX<SystemConfigDO> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* 查询列表
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
@@ -56,4 +57,11 @@ public interface SystemConfigMapper extends BaseMapperX<SystemConfigDO> {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询组织下自定义板编号配置最大版本号
|
||||
* @param organId
|
||||
* @return
|
||||
*/
|
||||
@Select("select max(version) from system_config where type = 1")
|
||||
Integer selectOrgMaxCustomPlateNoSystemConfigVersion(Long organId);
|
||||
}
|
||||
|
||||
+6
-4
@@ -1,13 +1,13 @@
|
||||
package com.cf.imes.module.system.service.config;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
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.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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统配置接口
|
||||
*
|
||||
@@ -21,7 +21,8 @@ public interface SystemConfigService {
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
PageResult<SystemConfigDO> getSystemConfigPage(ConfigPageReqVO reqVO);
|
||||
List<SystemConfigDO> getSystemConfigList(ConfigPageReqVO reqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 根据id查询基础配置
|
||||
@@ -47,9 +48,10 @@ public interface SystemConfigService {
|
||||
|
||||
/**
|
||||
* 查询组织下自定义板编号配置(缓存)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
SystemConfigCopyDO getOrgCustomPlateNoConfig();
|
||||
SystemConfigDO getOrgCustomPlateNoConfig();
|
||||
|
||||
void deleteSystemConfig(ConfigDeleteReqVO reqVO);
|
||||
|
||||
|
||||
+8
-18
@@ -1,10 +1,8 @@
|
||||
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;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
@@ -12,8 +10,6 @@ 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.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;
|
||||
@@ -27,6 +23,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_NOT_EXISTS;
|
||||
|
||||
@@ -47,10 +45,10 @@ public class SystemConfigServiceImpl implements SystemConfigService {
|
||||
private SystemConfigServiceFactory configServiceFactory;
|
||||
|
||||
@Override
|
||||
public PageResult<SystemConfigDO> getSystemConfigPage(ConfigPageReqVO reqVO) {
|
||||
public List<SystemConfigDO> getSystemConfigList(ConfigPageReqVO reqVO) {
|
||||
// 根据配置类型选择对应的service
|
||||
AbstractSystemConfigServiceHandler configService = configServiceFactory.getConfigServiceHandler(reqVO.getType());
|
||||
return configService.selectPage(reqVO);
|
||||
return configService.selectList(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,7 +59,6 @@ public class SystemConfigServiceImpl implements SystemConfigService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifySystemConfig(ConfigSaveReqVO reqVO) {
|
||||
Long id = reqVO.getId();
|
||||
// 根据配置类型选择对应的service
|
||||
AbstractSystemConfigServiceHandler configService = configServiceFactory.getConfigServiceHandler(reqVO.getType());
|
||||
// 校验规则
|
||||
@@ -69,8 +66,8 @@ public class SystemConfigServiceImpl implements SystemConfigService {
|
||||
// 系统配置保存前操作
|
||||
configService.beforeSaveConfig(reqVO);
|
||||
SystemConfigDO systemConfigDO;
|
||||
if (ObjectUtil.isNotNull(id)) {
|
||||
systemConfigDO = validateSystemConfigExists(id);
|
||||
if (ObjectUtil.isNotNull(reqVO.getId())) {
|
||||
systemConfigDO = validateSystemConfigExists(reqVO.getId());
|
||||
// 覆盖配置
|
||||
systemConfigDO.setSetting(reqVO.getSetting());
|
||||
// 覆盖名称
|
||||
@@ -102,18 +99,11 @@ public class SystemConfigServiceImpl implements SystemConfigService {
|
||||
|
||||
@Override
|
||||
@Cacheable(cacheNames = RedisKeyConstants.SYSTEM_CONFIG, key = "'" + RedisKeyConstants.CUSTOM_PLATE_NO + "'", unless = "#result == null")
|
||||
public SystemConfigCopyDO getOrgCustomPlateNoConfig() {
|
||||
SystemConfigDO systemConfigDO = systemConfigMapper.selectOne(new LambdaUpdateWrapper<SystemConfigDO>()
|
||||
public SystemConfigDO getOrgCustomPlateNoConfig() {
|
||||
return systemConfigMapper.selectOne(new LambdaUpdateWrapper<SystemConfigDO>()
|
||||
.eq(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId())
|
||||
.eq(SystemConfigDO::getType, SystemConfigTypeEnum.CUSTOM_PLATE_NO.getType())
|
||||
.eq(SystemConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus()));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+10
-3
@@ -1,5 +1,8 @@
|
||||
package com.cf.imes.module.system.service.config.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;
|
||||
@@ -30,8 +33,12 @@ public class SystemConfigServiceFactory {
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public AbstractSystemConfigServiceHandler getConfigServiceHandler(int type) {
|
||||
switch (SystemConfigTypeEnum.fromType(type)) {
|
||||
public AbstractSystemConfigServiceHandler getConfigServiceHandler(Integer type) {
|
||||
SystemConfigTypeEnum systemConfigTypeEnum = SystemConfigTypeEnum.fromType(type);
|
||||
if (ObjectUtil.isNull(systemConfigTypeEnum)) {
|
||||
return applicationContext.getBean(DefaultSystemConfigServiceHandler.class);
|
||||
}
|
||||
switch (systemConfigTypeEnum) {
|
||||
case CUSTOM_PLATE_NO:
|
||||
return applicationContext.getBean(CustomPlateNoServiceHandler.class);
|
||||
case INTELLIGENT_BRANCH:
|
||||
@@ -39,7 +46,7 @@ public class SystemConfigServiceFactory {
|
||||
case ADVANCED_SCREEN:
|
||||
// todo 高级筛选
|
||||
default:
|
||||
return applicationContext.getBean(DefaultSystemConfigServiceHandler.class);
|
||||
throw new ServiceException(ErrorCodeConstants.SYSTEM_CONFIG_TYPE_NOT_SUPPORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,12 +1,13 @@
|
||||
package com.cf.imes.module.system.service.config.factory.service;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
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.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateStatusReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统配置服务处理器抽象类
|
||||
*
|
||||
@@ -21,7 +22,7 @@ public abstract class AbstractSystemConfigServiceHandler {
|
||||
* @param pageReqVO
|
||||
* @return
|
||||
*/
|
||||
public abstract PageResult<SystemConfigDO> selectPage(ConfigPageReqVO pageReqVO);
|
||||
public abstract List<SystemConfigDO> selectList(ConfigPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 校验配置的合法性
|
||||
|
||||
+32
-10
@@ -5,22 +5,23 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
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.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
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.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.mysql.systemconfig.SystemConfigMapper;
|
||||
import com.cf.imes.module.system.dal.redis.RedisKeyConstants;
|
||||
import com.cf.imes.module.system.enums.config.CustBoardRuleCodeEnum;
|
||||
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.dict.DictDataService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -62,11 +63,14 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
|
||||
@Resource
|
||||
private CustomPlateNoSeqMapper customPlateNoSeqMapper;
|
||||
|
||||
@Resource
|
||||
private SystemConfigMapper systemConfigMapper;
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Override
|
||||
public PageResult<SystemConfigDO> selectPage(ConfigPageReqVO pageReqVO) {
|
||||
public List<SystemConfigDO> selectList(ConfigPageReqVO pageReqVO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -212,17 +216,35 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
|
||||
|
||||
@Override
|
||||
public void beforeSaveConfig(ConfigSaveReqVO reqVO) {
|
||||
// todo beforeSaveConfig
|
||||
// 查询机构下的现有自定义板编号配置最大版本号
|
||||
Integer maxCustomPlateNoSystemConfigVersion = systemConfigMapper.selectOrgMaxCustomPlateNoSystemConfigVersion(OrganContextHolder.getOrganId());
|
||||
// 版本号 + 1
|
||||
reqVO.setVersion(maxCustomPlateNoSystemConfigVersion + 1);
|
||||
// 自定义板编号每次保存都创建新版本
|
||||
reqVO.setId(null);
|
||||
}
|
||||
|
||||
@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());
|
||||
int currentVersion = systemConfigDO.getVersion();
|
||||
// 保留的最小版本号,小于他的都要删除
|
||||
int minReserveVersion = 0;
|
||||
if (currentVersion > 10) {
|
||||
minReserveVersion = currentVersion - 10;
|
||||
}
|
||||
// 更新机构下的前置版本号status为禁用
|
||||
systemConfigMapper.update(new LambdaUpdateWrapper<SystemConfigDO>()
|
||||
.eq(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId())
|
||||
.eq(SystemConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||
.eq(SystemConfigDO::getType, SystemConfigTypeEnum.CUSTOM_PLATE_NO.getType())
|
||||
.lt(SystemConfigDO::getVersion, currentVersion)
|
||||
.set(SystemConfigDO::getStatus, CommonStatusEnum.DISABLE.getStatus()));
|
||||
// 删除本次版本号往前10个以外的配置
|
||||
if (minReserveVersion != 0) {
|
||||
systemConfigMapper.delete(new LambdaUpdateWrapper<SystemConfigDO>()
|
||||
.eq(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId())
|
||||
.eq(SystemConfigDO::getType, SystemConfigTypeEnum.CUSTOM_PLATE_NO.getType())
|
||||
.le(SystemConfigDO::getVersion, minReserveVersion));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+26
-8
@@ -1,7 +1,8 @@
|
||||
package com.cf.imes.module.system.service.config.factory.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
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.ConfigSaveReqVO;
|
||||
@@ -11,8 +12,12 @@ 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.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@@ -21,24 +26,37 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
* @author Gqr
|
||||
* @since 2024/11/14 14:30
|
||||
*/
|
||||
@Service("defaultSystemConfigServiceHandler")
|
||||
@Slf4j
|
||||
public class DefaultSystemConfigServiceHandler extends AbstractSystemConfigServiceHandler {
|
||||
|
||||
@Resource
|
||||
private SystemConfigMapper systemConfigMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<SystemConfigDO> selectPage(ConfigPageReqVO reqVO) {
|
||||
PageResult<SystemConfigDO> configDOPageResult = systemConfigMapper.selectPage(reqVO);
|
||||
public List<SystemConfigDO> selectList(ConfigPageReqVO reqVO) {
|
||||
List<SystemConfigDO> systemConfigDOS = systemConfigMapper.selectList(new LambdaQueryWrapperX<SystemConfigDO>()
|
||||
.likeIfPresent(SystemConfigDO::getName, reqVO.getName())
|
||||
.eqIfPresent(SystemConfigDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId())
|
||||
.orderByAsc(SystemConfigDO::getId));
|
||||
// todo 后续所有configTypeEnum中的类型需要上到列表补全时通过遍历enum来补充
|
||||
SystemConfigTypeEnum customplateNoEnum = SystemConfigTypeEnum.CUSTOM_PLATE_NO;
|
||||
CopyOnWriteArrayList<SystemConfigDO> configDOS = Lists.newCopyOnWriteArrayList(configDOPageResult.getList());
|
||||
CopyOnWriteArrayList<SystemConfigDO> configDOS = Lists.newCopyOnWriteArrayList(systemConfigDOS);
|
||||
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(customplateNoEnum.getName()).type(customplateNoEnum.getType()).build());
|
||||
configDOPageResult.setList(configDOS);
|
||||
configDOPageResult.setTotal(configDOPageResult.getTotal() + 1);
|
||||
SystemConfigDO initCustomPlateNoConfig = new SystemConfigDO().builder().id(null).name(customplateNoEnum.getName()).type(customplateNoEnum.getType()).build();
|
||||
return List.of(initCustomPlateNoConfig);
|
||||
} else {
|
||||
// configDOPageResult下的自定义板编号配置只保留version最大的一项
|
||||
Optional<SystemConfigDO> maxVersionCustPlateNoConfigOptinal = systemConfigDOS.stream()
|
||||
.filter(s -> ObjectUtil.equal(SystemConfigTypeEnum.CUSTOM_PLATE_NO.getType(), s.getType()))
|
||||
.max(Comparator.comparing(SystemConfigDO::getVersion));
|
||||
if(maxVersionCustPlateNoConfigOptinal.isPresent()) {
|
||||
systemConfigDOS.removeIf(s -> ObjectUtil.equal(SystemConfigTypeEnum.CUSTOM_PLATE_NO.getType(), s.getType()) && ObjectUtil.notEqual(s.getId(), maxVersionCustPlateNoConfigOptinal.get().getId()));
|
||||
}
|
||||
return systemConfigDOS;
|
||||
}
|
||||
return configDOPageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-7
@@ -8,7 +8,6 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||
@@ -37,7 +36,7 @@ public class IntellectBranchingService extends AbstractSystemConfigServiceHandle
|
||||
|
||||
|
||||
@Override
|
||||
public PageResult<SystemConfigDO> selectPage(ConfigPageReqVO pageReqVO) {
|
||||
public List<SystemConfigDO> selectList(ConfigPageReqVO pageReqVO) {
|
||||
|
||||
List<SystemConfigDO> systemConfigDOS = systemConfigMapper.selectSystemConfigList(pageReqVO.getType(),null);
|
||||
|
||||
@@ -45,11 +44,7 @@ public class IntellectBranchingService extends AbstractSystemConfigServiceHandle
|
||||
return null;
|
||||
}
|
||||
|
||||
PageResult<SystemConfigDO> pageResult = new PageResult<>();
|
||||
|
||||
pageResult.setList(systemConfigDOS);
|
||||
|
||||
return pageResult;
|
||||
return systemConfigDOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.cf.imes.module.system.service.customplateno;
|
||||
|
||||
import com.cf.imes.module.system.dal.dataobject.customplateno.CustomPlateNoSeqDO;
|
||||
|
||||
/**
|
||||
* 自定义板编号序号服务
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/15 13:53
|
||||
*/
|
||||
public interface CustomPlateNoSeqService {
|
||||
/**
|
||||
* 查询机构的自定义版编号序号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
CustomPlateNoSeqDO getOrgCustomPlateNoSeq();
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.cf.imes.module.system.service.customplateno;
|
||||
|
||||
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 com.cf.imes.module.system.dal.mysql.customplateno.CustomPlateNoSeqMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 自定义板编号序号服务实现类
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/15 13:54
|
||||
*/
|
||||
@Service
|
||||
public class CustomPlateNoSeqServiceImpl implements CustomPlateNoSeqService {
|
||||
@Resource
|
||||
CustomPlateNoSeqMapper customPlateNoSeqMapper;
|
||||
|
||||
@Override
|
||||
public CustomPlateNoSeqDO getOrgCustomPlateNoSeq() {
|
||||
return customPlateNoSeqMapper.selectOne(new LambdaQueryWrapperX<CustomPlateNoSeqDO>()
|
||||
.eq(CustomPlateNoSeqDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user