diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/order/OrderDO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/order/OrderDO.java index 382bbb008..77b44d398 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/order/OrderDO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/order/OrderDO.java @@ -2,6 +2,7 @@ package com.cf.imes.module.executor.dal.dataobject.order; import com.baomidou.mybatisplus.annotation.*; import com.cf.imes.framework.mybatis.core.dataobject.BaseDO; +import com.cf.imes.framework.mybatis.core.type.CompressStringTypeHandler; import lombok.*; import java.time.LocalDateTime; @@ -11,7 +12,7 @@ import java.time.LocalDateTime; * * @author 晨丰科技 */ -@TableName("`orders`") +@TableName(value = "`orders`", autoResultMap = true) @KeySequence("order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data @EqualsAndHashCode(callSuper = true) @@ -110,4 +111,16 @@ public class OrderDO extends BaseDO { * 是否删除 */ private Boolean deleted; + + /** + * 自定义板编号配置id + */ + @TableField(value = "custom_plateno_config_id") + private Long customPlatenoConfigId; + + /** + * 自定义板编号序号 + */ + @TableField(value = "custom_plateno_seq", typeHandler = CompressStringTypeHandler.class) + private String customPlatenoSeq; } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plate/PlateDO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plate/PlateDO.java index 9a91b2192..b43a00a23 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plate/PlateDO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plate/PlateDO.java @@ -186,4 +186,18 @@ public class PlateDO extends BaseDO { */ private Boolean deleted; + /** + * 房间名 + */ + private String roomName; + + /** + * 柜体名 + */ + private String bodyName; + + /** + * 加工组名 + */ + private String processGroupName; } \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/framework/rpc/config/RpcConfiguration.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/framework/rpc/config/RpcConfiguration.java index fbfab77bf..f5118b830 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/framework/rpc/config/RpcConfiguration.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/framework/rpc/config/RpcConfiguration.java @@ -2,11 +2,13 @@ package com.cf.imes.module.executor.framework.rpc.config; import com.cf.imes.module.infra.api.file.FileApi; import com.cf.imes.module.system.api.application.ApplicationApi; +import com.cf.imes.module.system.api.customplateno.CustomPlateNoSeqApi; import com.cf.imes.module.system.api.dataSource.DataSourceApi; import com.cf.imes.module.system.api.machine.MachineApi; import com.cf.imes.module.system.api.organ.OrganApi; import com.cf.imes.module.system.api.process.ProcessApi; import com.cf.imes.module.system.api.process.ProcessGroupApi; +import com.cf.imes.module.system.api.systemconfig.SystemConfigApi; import com.cf.imes.module.system.api.user.AdminUserApi; import com.cf.imes.module.system.api.dict.DictDataApi; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -16,7 +18,8 @@ import org.springframework.context.annotation.Configuration; * @author there */ @Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {AdminUserApi.class, MachineApi.class, DictDataApi.class,AdminUserApi.class, - FileApi.class, ProcessGroupApi.class, FileApi.class, DataSourceApi.class, ApplicationApi.class, ProcessApi.class, OrganApi.class}) +@EnableFeignClients(clients = {AdminUserApi.class, MachineApi.class, DictDataApi.class, AdminUserApi.class, + FileApi.class, ProcessGroupApi.class, FileApi.class, DataSourceApi.class, ApplicationApi.class, + ProcessApi.class, OrganApi.class, SystemConfigApi.class, CustomPlateNoSeqApi.class}) public class RpcConfiguration { } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/CustomPlateNoGenerateService.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/CustomPlateNoGenerateService.java new file mode 100644 index 000000000..fa956ae83 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/CustomPlateNoGenerateService.java @@ -0,0 +1,20 @@ +package com.cf.imes.module.executor.service.customplateno; + +import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO; + +import java.util.List; + +/** + * 自定义板编号生成服务 + * + * @author Gqr + * @since 2024/11/15 10:18 + */ +public interface CustomPlateNoGenerateService { + /** + * 生成自定义板编号 + * + * @param plateDOList 板件列表 + */ + void generateCustomPlateNo(List plateDOList); +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/CustomPlateNoGenerateServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/CustomPlateNoGenerateServiceImpl.java new file mode 100644 index 000000000..eb1dbff85 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/CustomPlateNoGenerateServiceImpl.java @@ -0,0 +1,21 @@ +package com.cf.imes.module.executor.service.customplateno; + +import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author Gqr + * @since 2024/11/14 11:41 + */ +@Service +@Slf4j +public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateService { + + @Override + public void generateCustomPlateNo(List plateDOList) { + // todo generateCustomPlateNo + } +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/vo/CustomPlateNoGenerateConfigVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/vo/CustomPlateNoGenerateConfigVO.java new file mode 100644 index 000000000..178e45358 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/vo/CustomPlateNoGenerateConfigVO.java @@ -0,0 +1,31 @@ +package com.cf.imes.module.executor.service.customplateno.vo; + +import com.cf.imes.module.system.api.customplateno.dto.CustomPlateNoSeqRespDTO; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author Gqr + * @since 2024/11/15 10:40 + */ +@Data +public class CustomPlateNoGenerateConfigVO implements Serializable { + private static final long serialVersionUID = -7383861104153624467L; + + /** + * 生产单下的之定义板编号序号内容 + */ + private OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO; + + /** + * 自定义板编号规则 + */ + private List orgCustomPlateNoRuleVOList; + + /** + * 机构下的自定义板编号序号 + */ + private CustomPlateNoSeqRespDTO orgCustomPlateNoSeqRespDTO; +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/vo/CustomPlateNoRuleVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/vo/CustomPlateNoRuleVO.java new file mode 100644 index 000000000..98cfbea73 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/vo/CustomPlateNoRuleVO.java @@ -0,0 +1,51 @@ +package com.cf.imes.module.executor.service.customplateno.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 系统配置-自定义板编号setting项 vo + * + * @author Gqr + * @since 2024/11/15 10:33 + */ +@Data +public class CustomPlateNoRuleVO 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; +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/vo/OrderCustomPlateNoSeqVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/vo/OrderCustomPlateNoSeqVO.java new file mode 100644 index 000000000..810c3c6d8 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/customplateno/vo/OrderCustomPlateNoSeqVO.java @@ -0,0 +1,103 @@ +package com.cf.imes.module.executor.service.customplateno.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 生产单-自定义板编号序号(custom_plateno_seq)vo + * + * @author Gqr + * @since 2024/11/15 10:41 + */ +@Data +public class OrderCustomPlateNoSeqVO implements Serializable { + private static final long serialVersionUID = 5841977329049878792L; + /** + * 生产单下房间序号 + */ + private int roomSeq; + + /** + * 生产单下柜体序号 + */ + private int bodySeq; + + /** + * 生产单下加工组序号 + */ + private int processGroupSeq; + + /** + * 生产单下板件序号 + */ + private int plateNoSeq; + + /** + * 生产单下房间列表 + */ + private List rooms; +} + +@Data +class Room implements Serializable { + private static final long serialVersionUID = -127388898531267048L; + /** + * 房间名 + */ + private String roomNo; + + /** + * 房间下板件序号 + */ + private int plateNoSeq; + + /** + * 房间下柜体序号 + */ + private int bodySeq; + + /** + * 房间下柜体列表 + */ + private List bodys; + + /** + * 房间下加工组序号 + */ + private int processGroupSeq; + + /** + * 房间下加工组列表 + */ + private List processGroups; +} + +@Data +class Body implements Serializable { + private static final long serialVersionUID = 2686882895438975156L; + /** + * 柜体名 + */ + private String bodyNo; + + /** + * 柜体下板件序号 + */ + private int plateNoSeq; +} + +@Data +class ProcessGroup implements Serializable { + private static final long serialVersionUID = -6834098282222544638L; + /** + * 加工组名 + */ + private String processGroupNo; + + /** + * 加工组下板件序号 + */ + private int plateNoSeq; +} \ No newline at end of file diff --git a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/customplateno/CustomPlateNoSeqApi.java b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/customplateno/CustomPlateNoSeqApi.java new file mode 100644 index 000000000..45c9a4105 --- /dev/null +++ b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/customplateno/CustomPlateNoSeqApi.java @@ -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 getOrgCustomPlateNoSeq(); +} diff --git a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/customplateno/dto/CustomPlateNoSeqRespDTO.java b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/customplateno/dto/CustomPlateNoSeqRespDTO.java new file mode 100644 index 000000000..f4322d3f9 --- /dev/null +++ b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/customplateno/dto/CustomPlateNoSeqRespDTO.java @@ -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; +} diff --git a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/systemconfig/SystemConfigApi.java b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/systemconfig/SystemConfigApi.java new file mode 100644 index 000000000..15744ef09 --- /dev/null +++ b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/systemconfig/SystemConfigApi.java @@ -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 getOrgCustomPlateNoConfig(); + + @GetMapping(PREFIX + "/organ/custom-plateno-config/{id}") + @Operation(summary = "获取组织下自定义版编号配置") + CommonResult getById(Long id); +} diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/dataobject/systemconfig/SystemConfigCopyDO.java b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/systemconfig/dto/SystemConfigRespDTO.java similarity index 67% rename from cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/dataobject/systemconfig/SystemConfigCopyDO.java rename to cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/systemconfig/dto/SystemConfigRespDTO.java index 4a1ceec98..d4c8741ee 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/dataobject/systemconfig/SystemConfigCopyDO.java +++ b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/systemconfig/dto/SystemConfigRespDTO.java @@ -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 ruleList; + private String setting; /** * 组织id diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/customplateno/CustomPlateNoSeqApiImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/customplateno/CustomPlateNoSeqApiImpl.java new file mode 100644 index 000000000..140285783 --- /dev/null +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/customplateno/CustomPlateNoSeqApiImpl.java @@ -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 getOrgCustomPlateNoSeq() { + return CommonResult.success(BeanUtils.toBean(customPlateNoSeqService.getOrgCustomPlateNoSeq(), CustomPlateNoSeqRespDTO.class)); + } +} diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/systemconfig/SystemConfigApiImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/systemconfig/SystemConfigApiImpl.java new file mode 100644 index 000000000..f41b943e7 --- /dev/null +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/systemconfig/SystemConfigApiImpl.java @@ -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 getOrgCustomPlateNoConfig() { + return success(BeanUtils.toBean(systemConfigService.getOrgCustomPlateNoConfig(), SystemConfigRespDTO.class)); + } + + @Override + public CommonResult getById(Long id) { + return success(BeanUtils.toBean(systemConfigService.getSystemConfig(id), SystemConfigRespDTO.class)); + } +} diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/SystemConfigController.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/SystemConfigController.java index dc2b11a16..042975a8c 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/SystemConfigController.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/SystemConfigController.java @@ -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> getSystemConfigPage(@Valid ConfigPageReqVO pageReqVO) { - PageResult pageResult = systemConfigService.getSystemConfigPage(pageReqVO); + public CommonResult> getSystemConfigPage(@Valid ConfigPageReqVO pageReqVO) { + List pageResult = systemConfigService.getSystemConfigList(pageReqVO); return success(BeanUtils.toBean(pageResult, ConfigRespVO.class)); } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/vo/ConfigPageReqVO.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/vo/ConfigPageReqVO.java index 30f4565eb..611be24e1 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/vo/ConfigPageReqVO.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/vo/ConfigPageReqVO.java @@ -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; } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/vo/ConfigSaveReqVO.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/vo/ConfigSaveReqVO.java index 625b461d6..33e60c11a 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/vo/ConfigSaveReqVO.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/systemconfig/vo/ConfigSaveReqVO.java @@ -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; } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/dataobject/customplateno/CustomPlateNoSeqDO.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/dataobject/customplateno/CustomPlateNoSeqDO.java index 1d0510c86..57ae61c42 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/dataobject/customplateno/CustomPlateNoSeqDO.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/dataobject/customplateno/CustomPlateNoSeqDO.java @@ -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; } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/customplateno/CustomPlateNoSeqMapper.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/customplateno/CustomPlateNoSeqMapper.java index 4928dbcec..2d0c71de0 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/customplateno/CustomPlateNoSeqMapper.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/customplateno/CustomPlateNoSeqMapper.java @@ -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 { - - /** - * 查询系统配置编号下的自定义板编号序号 - * @param configId - * @return - */ - default CustomPlateNoSeqDO getPlateNoSeqByConfigId(Long configId) { - return selectOne(new LambdaQueryWrapperX() - .eq(CustomPlateNoSeqDO::getConfigId, configId) - .eq(CustomPlateNoSeqDO::getOrganId, OrganContextHolder.getOrganId())); - } } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/systemconfig/SystemConfigMapper.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/systemconfig/SystemConfigMapper.java index 851241e3e..731a6b7ae 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/systemconfig/SystemConfigMapper.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/systemconfig/SystemConfigMapper.java @@ -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 { /** - * 分页查询 + * 查询列表 * * @param reqVO * @return @@ -56,4 +57,11 @@ public interface SystemConfigMapper extends BaseMapperX { } + /** + * 查询组织下自定义板编号配置最大版本号 + * @param organId + * @return + */ + @Select("select max(version) from system_config where type = 1") + Integer selectOrgMaxCustomPlateNoSystemConfigVersion(Long organId); } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/SystemConfigService.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/SystemConfigService.java index 2c4273ea3..c629ab8d2 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/SystemConfigService.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/SystemConfigService.java @@ -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 getSystemConfigPage(ConfigPageReqVO reqVO); + List getSystemConfigList(ConfigPageReqVO reqVO); + /** * 根据id查询基础配置 @@ -47,9 +48,10 @@ public interface SystemConfigService { /** * 查询组织下自定义板编号配置(缓存) + * * @return */ - SystemConfigCopyDO getOrgCustomPlateNoConfig(); + SystemConfigDO getOrgCustomPlateNoConfig(); void deleteSystemConfig(ConfigDeleteReqVO reqVO); diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/SystemConfigServiceImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/SystemConfigServiceImpl.java index 1e09ad0bf..03b38e1f2 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/SystemConfigServiceImpl.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/SystemConfigServiceImpl.java @@ -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 getSystemConfigPage(ConfigPageReqVO reqVO) { + public List 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() + public SystemConfigDO getOrgCustomPlateNoConfig() { + return systemConfigMapper.selectOne(new LambdaUpdateWrapper() .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; - } } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/SystemConfigServiceFactory.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/SystemConfigServiceFactory.java index 09212f8d8..022136456 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/SystemConfigServiceFactory.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/SystemConfigServiceFactory.java @@ -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); } } } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/AbstractSystemConfigServiceHandler.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/AbstractSystemConfigServiceHandler.java index ce7f87ecb..df81e5b0f 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/AbstractSystemConfigServiceHandler.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/AbstractSystemConfigServiceHandler.java @@ -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 selectPage(ConfigPageReqVO pageReqVO); + public abstract List selectList(ConfigPageReqVO pageReqVO); /** * 校验配置的合法性 diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/CustomPlateNoServiceHandler.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/CustomPlateNoServiceHandler.java index 4c67c23a2..437213964 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/CustomPlateNoServiceHandler.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/CustomPlateNoServiceHandler.java @@ -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 selectPage(ConfigPageReqVO pageReqVO) { + public List 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() + .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() + .eq(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId()) + .eq(SystemConfigDO::getType, SystemConfigTypeEnum.CUSTOM_PLATE_NO.getType()) + .le(SystemConfigDO::getVersion, minReserveVersion)); } } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/DefaultSystemConfigServiceHandler.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/DefaultSystemConfigServiceHandler.java index 441d2a482..cc29a0002 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/DefaultSystemConfigServiceHandler.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/DefaultSystemConfigServiceHandler.java @@ -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 selectPage(ConfigPageReqVO reqVO) { - PageResult configDOPageResult = systemConfigMapper.selectPage(reqVO); + public List selectList(ConfigPageReqVO reqVO) { + List systemConfigDOS = systemConfigMapper.selectList(new LambdaQueryWrapperX() + .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 configDOS = Lists.newCopyOnWriteArrayList(configDOPageResult.getList()); + CopyOnWriteArrayList configDOS = Lists.newCopyOnWriteArrayList(systemConfigDOS); Optional 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 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 diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/IntellectBranchingService.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/IntellectBranchingService.java index 986929783..a1d2c7f1e 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/IntellectBranchingService.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/config/factory/service/impl/IntellectBranchingService.java @@ -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 selectPage(ConfigPageReqVO pageReqVO) { + public List selectList(ConfigPageReqVO pageReqVO) { List systemConfigDOS = systemConfigMapper.selectSystemConfigList(pageReqVO.getType(),null); @@ -45,11 +44,7 @@ public class IntellectBranchingService extends AbstractSystemConfigServiceHandle return null; } - PageResult pageResult = new PageResult<>(); - - pageResult.setList(systemConfigDOS); - - return pageResult; + return systemConfigDOS; } @Override diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/customplateno/CustomPlateNoSeqService.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/customplateno/CustomPlateNoSeqService.java new file mode 100644 index 000000000..3887fc884 --- /dev/null +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/customplateno/CustomPlateNoSeqService.java @@ -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(); +} diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/customplateno/CustomPlateNoSeqServiceImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/customplateno/CustomPlateNoSeqServiceImpl.java new file mode 100644 index 000000000..d640e10e5 --- /dev/null +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/customplateno/CustomPlateNoSeqServiceImpl.java @@ -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() + .eq(CustomPlateNoSeqDO::getOrganId, OrganContextHolder.getOrganId())); + } +}