From 4fb49825b6148351b9ccf3b66c86a8ffeb18af22 Mon Sep 17 00:00:00 2001 From: gaoqr <13665037151@163.com> Date: Tue, 14 Jan 2025 11:32:31 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=98=BE=E5=BC=8F=E7=A9=BA=E6=8C=87?= =?UTF-8?q?=E9=92=88=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/ChenfengMybatisAutoConfiguration.java | 2 +- .../controller/admin/order/OrderController.java | 10 +++++----- .../fileConversion/admin/files/xml/XmlTypeRealize.java | 9 +++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cf-framework/cf-spring-boot-starter-mybatis/src/main/java/com/cf/imes/framework/mybatis/config/ChenfengMybatisAutoConfiguration.java b/cf-framework/cf-spring-boot-starter-mybatis/src/main/java/com/cf/imes/framework/mybatis/config/ChenfengMybatisAutoConfiguration.java index f69420a5a..1cca14d3b 100644 --- a/cf-framework/cf-spring-boot-starter-mybatis/src/main/java/com/cf/imes/framework/mybatis/config/ChenfengMybatisAutoConfiguration.java +++ b/cf-framework/cf-spring-boot-starter-mybatis/src/main/java/com/cf/imes/framework/mybatis/config/ChenfengMybatisAutoConfiguration.java @@ -72,7 +72,7 @@ public class ChenfengMybatisAutoConfiguration { } } // 找不到合适的 IKeyGenerator 实现类 - throw new IllegalArgumentException(CharSequenceUtil.format("DbType{} 找不到合适的 IKeyGenerator 实现类", dbType)); + throw new IllegalArgumentException("DbType为空"); } } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java index c668f8b75..e4732d000 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java @@ -1,5 +1,6 @@ package com.cf.imes.module.executor.controller.admin.order; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; import com.cf.imes.framework.common.exception.ServiceException; @@ -48,7 +49,6 @@ import javax.validation.constraints.NotEmpty; import java.io.File; import java.util.*; import java.util.concurrent.ExecutionException; -import java.util.concurrent.atomic.AtomicBoolean; import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.cf.imes.framework.common.pojo.CommonResult.error; @@ -382,10 +382,10 @@ public class OrderController { } // 进行判断,为空,写入时出现了错误,数据库数据回滚,此时删除 ES 里的数据 - OrderDO order = orderMapper.selectById(orderDO.getId()); - if (order == null) { - orderInputProcessor.deleteByOrderId(orderDO.getId(), ORDER_PLATE_MODEL); - orderInputProcessor.deleteByOrderId(orderDO.getId(), ORDER_PLATE_MODEL_COMPRESS); + if (ObjectUtil.isNotNull(orderDO) && ObjectUtil.isNotNull(orderMapper.selectById(orderDO.getId()))) { + Long deleteOrderId = orderDO.getId(); + orderInputProcessor.deleteByOrderId(deleteOrderId, ORDER_PLATE_MODEL); + orderInputProcessor.deleteByOrderId(deleteOrderId, ORDER_PLATE_MODEL_COMPRESS); } } finally { diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/XmlTypeRealize.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/XmlTypeRealize.java index f7b2b3028..f089b3718 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/XmlTypeRealize.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/xml/XmlTypeRealize.java @@ -1,5 +1,7 @@ package com.cf.imes.module.executor.util.fileConversion.admin.files.xml; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.common.utils.StringUtils; @@ -793,12 +795,7 @@ public class XmlTypeRealize { Map groupInfos, Map> boxBasePositionMap, Map roomBasePositions) { - - if (blockXmlVOS != null && blockXmlVOS.getBlockXmlVOList() == null || blockXmlVOS.getBlockXmlVOList().isEmpty()) { - - } - - if (blockXmlVOS != null && blockXmlVOS.getBlockXmlVOList() != null && !blockXmlVOS.getBlockXmlVOList().isEmpty()) { + if (ObjectUtil.isNotNull(blockXmlVOS) && CollUtil.isNotEmpty(blockXmlVOS.getBlockXmlVOList())) { for (BlockXmlVO blockXmlVO : blockXmlVOS.getBlockXmlVOList()) { long plateNo = idWorker.nextId(); From bc6275bca3fdbc0dcb84128b7edb6b4468bd7028 Mon Sep 17 00:00:00 2001 From: gaoqr <13665037151@163.com> Date: Tue, 14 Jan 2025 11:47:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?accesslog=E3=80=81errorlog=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=AE=B0=E5=BD=95=E7=AE=80=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChenfengApiLogAutoConfiguration.java | 19 +--- .../ChenfengApiLogRpcAutoConfiguration.java | 3 +- .../core/filter/ApiAccessLogFilter.java | 16 +-- .../apilog/core/service/ApiAccessLog.java | 85 -------------- .../service/ApiAccessLogFrameworkService.java | 17 --- .../ApiAccessLogFrameworkServiceImpl.java | 28 ----- .../apilog/core/service/ApiErrorLog.java | 107 ------------------ .../service/ApiErrorLogFrameworkService.java | 17 --- .../ApiErrorLogFrameworkServiceImpl.java | 28 ----- .../config/ChenfengWebAutoConfiguration.java | 6 +- .../core/handler/GlobalExceptionHandler.java | 29 ++--- .../infra/api/logger/ApiAccessLogApi.java | 10 ++ .../infra/api/logger/ApiErrorLogApi.java | 5 + .../dal/dataobject/logger/ApiAccessLogDO.java | 10 ++ .../dal/dataobject/logger/ApiErrorLogDO.java | 5 + .../logger/ApiAccessLogServiceImpl.java | 15 ++- .../logger/ApiErrorLogServiceImpl.java | 12 +- 17 files changed, 75 insertions(+), 337 deletions(-) delete mode 100644 cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLog.java delete mode 100644 cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLogFrameworkService.java delete mode 100644 cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java delete mode 100644 cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLog.java delete mode 100644 cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLogFrameworkService.java delete mode 100644 cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/config/ChenfengApiLogAutoConfiguration.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/config/ChenfengApiLogAutoConfiguration.java index 3daeb38b7..df5498d15 100644 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/config/ChenfengApiLogAutoConfiguration.java +++ b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/config/ChenfengApiLogAutoConfiguration.java @@ -1,15 +1,10 @@ package com.cf.imes.framework.apilog.config; import com.cf.imes.framework.apilog.core.filter.ApiAccessLogFilter; -import com.cf.imes.framework.apilog.core.service.ApiAccessLogFrameworkService; -import com.cf.imes.framework.apilog.core.service.ApiAccessLogFrameworkServiceImpl; -import com.cf.imes.framework.apilog.core.service.ApiErrorLogFrameworkService; -import com.cf.imes.framework.apilog.core.service.ApiErrorLogFrameworkServiceImpl; import com.cf.imes.framework.common.enums.WebFilterOrderEnum; import com.cf.imes.framework.web.config.WebProperties; import com.cf.imes.framework.web.config.ChenfengWebAutoConfiguration; import com.cf.imes.module.infra.api.logger.ApiAccessLogApi; -import com.cf.imes.module.infra.api.logger.ApiErrorLogApi; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -21,16 +16,6 @@ import javax.servlet.Filter; @AutoConfiguration(after = ChenfengWebAutoConfiguration.class) public class ChenfengApiLogAutoConfiguration { - @Bean - public ApiAccessLogFrameworkService apiAccessLogFrameworkService(ApiAccessLogApi apiAccessLogApi) { - return new ApiAccessLogFrameworkServiceImpl(apiAccessLogApi); - } - - @Bean - public ApiErrorLogFrameworkService apiErrorLogFrameworkService(ApiErrorLogApi apiErrorLogApi) { - return new ApiErrorLogFrameworkServiceImpl(apiErrorLogApi); - } - /** * 创建 ApiAccessLogFilter Bean,记录 API 请求日志 */ @@ -38,8 +23,8 @@ public class ChenfengApiLogAutoConfiguration { @ConditionalOnProperty(prefix = "chenfeng.access-log", value = "enable", matchIfMissing = true) // 允许使用 chenfeng.access-log.enable=false 禁用访问日志 public FilterRegistrationBean apiAccessLogFilter(WebProperties webProperties, @Value("${spring.application.name}") String applicationName, - ApiAccessLogFrameworkService apiAccessLogFrameworkService) { - ApiAccessLogFilter filter = new ApiAccessLogFilter(webProperties, applicationName, apiAccessLogFrameworkService); + ApiAccessLogApi apiAccessLogApi) { + ApiAccessLogFilter filter = new ApiAccessLogFilter(webProperties, applicationName, apiAccessLogApi); return createFilterBean(filter, WebFilterOrderEnum.API_ACCESS_LOG_FILTER); } diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/config/ChenfengApiLogRpcAutoConfiguration.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/config/ChenfengApiLogRpcAutoConfiguration.java index 743777b1d..1cc5660cc 100644 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/config/ChenfengApiLogRpcAutoConfiguration.java +++ b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/config/ChenfengApiLogRpcAutoConfiguration.java @@ -11,7 +11,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients; * @author 晨丰科技 */ @AutoConfiguration -@EnableFeignClients(clients = {ApiAccessLogApi.class, // 主要是引入相关的 API 服务 - ApiErrorLogApi.class}) +@EnableFeignClients(clients = {ApiAccessLogApi.class, ApiErrorLogApi.class}) public class ChenfengApiLogRpcAutoConfiguration { } diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/filter/ApiAccessLogFilter.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/filter/ApiAccessLogFilter.java index cf53089cf..fc2a9f5d2 100644 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/filter/ApiAccessLogFilter.java +++ b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/filter/ApiAccessLogFilter.java @@ -3,8 +3,6 @@ package com.cf.imes.framework.apilog.core.filter; import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.map.MapUtil; -import com.cf.imes.framework.apilog.core.service.ApiAccessLog; -import com.cf.imes.framework.apilog.core.service.ApiAccessLogFrameworkService; import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants; import com.cf.imes.framework.common.pojo.CommonResult; import com.cf.imes.framework.common.util.monitor.TracerUtils; @@ -12,6 +10,8 @@ import com.cf.imes.framework.common.util.servlet.ServletUtils; import com.cf.imes.framework.web.config.WebProperties; import com.cf.imes.framework.web.core.filter.ApiRequestFilter; import com.cf.imes.framework.web.core.util.WebFrameworkUtils; +import com.cf.imes.module.infra.api.logger.ApiAccessLogApi; +import com.cf.imes.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; import lombok.extern.slf4j.Slf4j; import javax.servlet.FilterChain; @@ -35,12 +35,12 @@ public class ApiAccessLogFilter extends ApiRequestFilter { private final String applicationName; - private final ApiAccessLogFrameworkService apiAccessLogFrameworkService; + private final ApiAccessLogApi apiAccessLogApi; - public ApiAccessLogFilter(WebProperties webProperties, String applicationName, ApiAccessLogFrameworkService apiAccessLogFrameworkService) { + public ApiAccessLogFilter(WebProperties webProperties, String applicationName, ApiAccessLogApi apiAccessLogApi) { super(webProperties); this.applicationName = applicationName; - this.apiAccessLogFrameworkService = apiAccessLogFrameworkService; + this.apiAccessLogApi = apiAccessLogApi; } @Override @@ -66,16 +66,16 @@ public class ApiAccessLogFilter extends ApiRequestFilter { private void createApiAccessLog(HttpServletRequest request, LocalDateTime beginTime, Map queryString, String requestBody, Exception ex) { - ApiAccessLog accessLog = new ApiAccessLog(); + ApiAccessLogCreateReqDTO accessLog = new ApiAccessLogCreateReqDTO(); try { this.buildApiAccessLogDTO(accessLog, request, beginTime, queryString, requestBody, ex); - apiAccessLogFrameworkService.createApiAccessLog(accessLog); + apiAccessLogApi.createApiAccessLogAsync(accessLog); } catch (Throwable th) { log.error("[createApiAccessLog][url({}) log({}) 发生异常]", request.getRequestURI(), toJsonString(accessLog), th); } } - private void buildApiAccessLogDTO(ApiAccessLog accessLog, HttpServletRequest request, LocalDateTime beginTime, + private void buildApiAccessLogDTO(ApiAccessLogCreateReqDTO accessLog, HttpServletRequest request, LocalDateTime beginTime, Map queryString, String requestBody, Exception ex) { // 处理用户信息 accessLog.setUserId(WebFrameworkUtils.getLoginUserId(request)); diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLog.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLog.java deleted file mode 100644 index 326ddc98d..000000000 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLog.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.cf.imes.framework.apilog.core.service; - -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -/** - * API 访问日志 - * - * @author 晨丰科技 - */ -@Data -public class ApiAccessLog { - - /** - * 链路追踪编号 - */ - private String traceId; - /** - * 用户编号 - */ - private Long userId; - /** - * 用户类型 - */ - private Integer userType; - /** - * 应用名 - */ - @NotNull(message = "应用名不能为空") - private String applicationName; - - /** - * 请求方法名 - */ - @NotNull(message = "http 请求方法不能为空") - private String requestMethod; - /** - * 访问地址 - */ - @NotNull(message = "访问地址不能为空") - private String requestUrl; - /** - * 请求参数 - */ - @NotNull(message = "请求参数不能为空") - private String requestParams; - /** - * 用户 IP - */ - @NotNull(message = "ip 不能为空") - private String userIp; - /** - * 浏览器 UA - */ - @NotNull(message = "User-Agent 不能为空") - private String userAgent; - - /** - * 开始请求时间 - */ - @NotNull(message = "开始请求时间不能为空") - private LocalDateTime beginTime; - /** - * 结束请求时间 - */ - @NotNull(message = "结束请求时间不能为空") - private LocalDateTime endTime; - /** - * 执行时长,单位:毫秒 - */ - @NotNull(message = "执行时长不能为空") - private Integer duration; - /** - * 结果码 - */ - @NotNull(message = "错误码不能为空") - private Integer resultCode; - /** - * 结果提示 - */ - private String resultMsg; - -} diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLogFrameworkService.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLogFrameworkService.java deleted file mode 100644 index 471fe27ea..000000000 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLogFrameworkService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.cf.imes.framework.apilog.core.service; - -/** - * API 访问日志 Framework Service 接口 - * - * @author 晨丰科技 - */ -public interface ApiAccessLogFrameworkService { - - /** - * 创建 API 访问日志 - * - * @param apiAccessLog API 访问日志 - */ - void createApiAccessLog(ApiAccessLog apiAccessLog); - -} diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java deleted file mode 100644 index b3194163d..000000000 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiAccessLogFrameworkServiceImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.cf.imes.framework.apilog.core.service; - -import cn.hutool.core.bean.BeanUtil; -import com.cf.imes.module.infra.api.logger.ApiAccessLogApi; -import com.cf.imes.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; -import lombok.RequiredArgsConstructor; -import org.springframework.scheduling.annotation.Async; - -/** - * API 访问日志 Framework Service 实现类 - * - * 基于 {@link ApiAccessLogApi} 远程服务,记录访问日志 - * - * @author 晨丰科技 - */ -@RequiredArgsConstructor -public class ApiAccessLogFrameworkServiceImpl implements ApiAccessLogFrameworkService { - - private final ApiAccessLogApi apiAccessLogApi; - - @Override - @Async - public void createApiAccessLog(ApiAccessLog apiAccessLog) { - ApiAccessLogCreateReqDTO reqDTO = BeanUtil.copyProperties(apiAccessLog, ApiAccessLogCreateReqDTO.class); - apiAccessLogApi.createApiAccessLog(reqDTO).checkError(); - } - -} diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLog.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLog.java deleted file mode 100644 index 7475b8045..000000000 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLog.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.cf.imes.framework.apilog.core.service; - -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -/** - * API 错误日志 - * - * @author 晨丰科技 - */ -@Data -public class ApiErrorLog { - - /** - * 链路编号 - */ - private String traceId; - /** - * 账号编号 - */ - private Long userId; - /** - * 用户类型 - */ - private Integer userType; - /** - * 应用名 - */ - @NotNull(message = "应用名不能为空") - private String applicationName; - - /** - * 请求方法名 - */ - @NotNull(message = "http 请求方法不能为空") - private String requestMethod; - /** - * 访问地址 - */ - @NotNull(message = "访问地址不能为空") - private String requestUrl; - /** - * 请求参数 - */ - @NotNull(message = "请求参数不能为空") - private String requestParams; - /** - * 用户 IP - */ - @NotNull(message = "ip 不能为空") - private String userIp; - /** - * 浏览器 UA - */ - @NotNull(message = "User-Agent 不能为空") - private String userAgent; - - /** - * 异常时间 - */ - @NotNull(message = "异常时间不能为空") - private LocalDateTime exceptionTime; - /** - * 异常名 - */ - @NotNull(message = "异常名不能为空") - private String exceptionName; - /** - * 异常发生的类全名 - */ - @NotNull(message = "异常发生的类全名不能为空") - private String exceptionClassName; - /** - * 异常发生的类文件 - */ - @NotNull(message = "异常发生的类文件不能为空") - private String exceptionFileName; - /** - * 异常发生的方法名 - */ - @NotNull(message = "异常发生的方法名不能为空") - private String exceptionMethodName; - /** - * 异常发生的方法所在行 - */ - @NotNull(message = "异常发生的方法所在行不能为空") - private Integer exceptionLineNumber; - /** - * 异常的栈轨迹异常的栈轨迹 - */ - @NotNull(message = "异常的栈轨迹不能为空") - private String exceptionStackTrace; - /** - * 异常导致的根消息 - */ - @NotNull(message = "异常导致的根消息不能为空") - private String exceptionRootCauseMessage; - /** - * 异常导致的消息 - */ - @NotNull(message = "异常导致的消息不能为空") - private String exceptionMessage; - - -} diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLogFrameworkService.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLogFrameworkService.java deleted file mode 100644 index 2d5c1c780..000000000 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLogFrameworkService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.cf.imes.framework.apilog.core.service; - -/** - * API 错误日志 Framework Service 接口 - * - * @author 晨丰科技 - */ -public interface ApiErrorLogFrameworkService { - - /** - * 创建 API 错误日志 - * - * @param apiErrorLog API 错误日志 - */ - void createApiErrorLog(ApiErrorLog apiErrorLog); - -} diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java deleted file mode 100644 index 7eba3625c..000000000 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.cf.imes.framework.apilog.core.service; - -import cn.hutool.core.bean.BeanUtil; -import com.cf.imes.module.infra.api.logger.ApiErrorLogApi; -import com.cf.imes.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; -import lombok.RequiredArgsConstructor; -import org.springframework.scheduling.annotation.Async; - -/** - * API 错误日志 Framework Service 实现类 - * - * 基于 {@link ApiErrorLogApi} 远程服务,记录错误日志 - * - * @author 晨丰科技 - */ -@RequiredArgsConstructor -public class ApiErrorLogFrameworkServiceImpl implements ApiErrorLogFrameworkService { - - private final ApiErrorLogApi apiErrorLogApi; - - @Override - @Async - public void createApiErrorLog(ApiErrorLog apiErrorLog) { - ApiErrorLogCreateReqDTO reqDTO = BeanUtil.copyProperties(apiErrorLog, ApiErrorLogCreateReqDTO.class); - apiErrorLogApi.createApiErrorLog(reqDTO).checkError(); - } - -} diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/web/config/ChenfengWebAutoConfiguration.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/web/config/ChenfengWebAutoConfiguration.java index e34d08f56..bc0df4635 100644 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/web/config/ChenfengWebAutoConfiguration.java +++ b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/web/config/ChenfengWebAutoConfiguration.java @@ -1,13 +1,13 @@ package com.cf.imes.framework.web.config; import com.cf.imes.framework.aop.ControllerResolver; -import com.cf.imes.framework.apilog.core.service.ApiErrorLogFrameworkService; import com.cf.imes.framework.common.enums.WebFilterOrderEnum; import com.cf.imes.framework.web.core.filter.CacheRequestBodyFilter; import com.cf.imes.framework.web.core.filter.DataSourceFilter; import com.cf.imes.framework.web.core.handler.GlobalExceptionHandler; import com.cf.imes.framework.web.core.handler.GlobalResponseBodyHandler; import com.cf.imes.framework.web.core.util.WebFrameworkUtils; +import com.cf.imes.module.infra.api.logger.ApiErrorLogApi; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -59,8 +59,8 @@ public class ChenfengWebAutoConfiguration implements WebMvcConfigurer { } @Bean - public GlobalExceptionHandler globalExceptionHandler(ApiErrorLogFrameworkService ApiErrorLogFrameworkService) { - return new GlobalExceptionHandler(applicationName, ApiErrorLogFrameworkService); + public GlobalExceptionHandler globalExceptionHandler(ApiErrorLogApi apiErrorLogApi) { + return new GlobalExceptionHandler(applicationName, apiErrorLogApi); } @Bean diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/web/core/handler/GlobalExceptionHandler.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/web/core/handler/GlobalExceptionHandler.java index a3782a321..0ae4cfe59 100644 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/web/core/handler/GlobalExceptionHandler.java +++ b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/web/core/handler/GlobalExceptionHandler.java @@ -3,15 +3,14 @@ package com.cf.imes.framework.web.core.handler; import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.CharSequenceUtil; -import cn.hutool.extra.servlet.ServletUtil; -import com.cf.imes.framework.apilog.core.service.ApiErrorLog; -import com.cf.imes.framework.apilog.core.service.ApiErrorLogFrameworkService; import com.cf.imes.framework.common.exception.ServiceException; import com.cf.imes.framework.common.pojo.CommonResult; import com.cf.imes.framework.common.util.monitor.TracerUtils; import com.cf.imes.framework.web.core.util.WebFrameworkUtils; import com.cf.imes.framework.common.util.json.JsonUtils; import com.cf.imes.framework.common.util.servlet.ServletUtils; +import com.cf.imes.module.infra.api.logger.ApiErrorLogApi; +import com.cf.imes.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.dao.DuplicateKeyException; @@ -50,7 +49,7 @@ public class GlobalExceptionHandler { private final String applicationName; - private final ApiErrorLogFrameworkService apiErrorLogFrameworkService; + private final ApiErrorLogApi apiErrorLogApi; /** * 处理所有异常,主要是提供给 Filter 使用 @@ -251,14 +250,6 @@ public class GlobalExceptionHandler { return tableNotExistsResult; } - if(ex instanceof NullPointerException){ - // 处理异常 - log.error("[defaultExceptionHandler]", ex); - // 插入异常日志 - this.createExceptionLog(req, ex); - return CommonResult.error(DATA_EXCEPTION_ERROR.getCode(), DATA_EXCEPTION_ERROR.getMsg()); - } - // 情况二:部分特殊的库的处理 if (Objects.equals("io.github.resilience4j.ratelimiter.RequestNotPermitted", ex.getClass().getName())) { return requestNotPermittedExceptionHandler(req, ex); @@ -274,18 +265,18 @@ public class GlobalExceptionHandler { private void createExceptionLog(HttpServletRequest req, Throwable e) { // 插入错误日志 - ApiErrorLog errorLog = new ApiErrorLog(); + ApiErrorLogCreateReqDTO errorLog = new ApiErrorLogCreateReqDTO(); try { // 初始化 errorLog - initExceptionLog(errorLog, req, e); + buildExceptionLog(errorLog, req, e); // 执行插入 errorLog - apiErrorLogFrameworkService.createApiErrorLog(errorLog); + apiErrorLogApi.createApiErrorLogAsync(errorLog); } catch (Throwable th) { log.error("[createExceptionLog][url({}) log({}) 发生异常]", req.getRequestURI(), JsonUtils.toJsonString(errorLog), th); } } - private void initExceptionLog(ApiErrorLog errorLog, HttpServletRequest request, Throwable e) { + private void buildExceptionLog(ApiErrorLogCreateReqDTO errorLog, HttpServletRequest request, Throwable e) { // 处理用户信息 errorLog.setUserId(WebFrameworkUtils.getLoginUserId(request)); errorLog.setUserType(WebFrameworkUtils.getLoginUserType(request)); @@ -306,12 +297,12 @@ public class GlobalExceptionHandler { errorLog.setApplicationName(applicationName); errorLog.setRequestUrl(request.getRequestURI()); Map requestParams = MapUtil.builder() - .put("query", ServletUtil.getParamMap(request)) - .put("body", ServletUtil.getBody(request)).build(); + .put("query", ServletUtils.getParamMap(request)) + .put("body", ServletUtils.getBody(request)).build(); errorLog.setRequestParams(JsonUtils.toJsonString(requestParams)); errorLog.setRequestMethod(request.getMethod()); errorLog.setUserAgent(ServletUtils.getUserAgent(request)); - errorLog.setUserIp(ServletUtil.getClientIP(request)); + errorLog.setUserIp(ServletUtils.getClientIP(request)); errorLog.setExceptionTime(LocalDateTime.now()); } diff --git a/cf-module-infra/cf-module-infra-api/src/main/java/com/cf/imes/module/infra/api/logger/ApiAccessLogApi.java b/cf-module-infra/cf-module-infra-api/src/main/java/com/cf/imes/module/infra/api/logger/ApiAccessLogApi.java index 984736286..678ea53d4 100644 --- a/cf-module-infra/cf-module-infra-api/src/main/java/com/cf/imes/module/infra/api/logger/ApiAccessLogApi.java +++ b/cf-module-infra/cf-module-infra-api/src/main/java/com/cf/imes/module/infra/api/logger/ApiAccessLogApi.java @@ -6,6 +6,7 @@ import com.cf.imes.module.infra.enums.ApiConstants; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.scheduling.annotation.Async; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -21,4 +22,13 @@ public interface ApiAccessLogApi { @Operation(summary = "创建 API 访问日志") CommonResult createApiAccessLog(@Valid @RequestBody ApiAccessLogCreateReqDTO createDTO); + /** + * 【异步】创建 API 访问日志 + * + * @param createDTO 访问日志 DTO + */ + @Async + default void createApiAccessLogAsync(ApiAccessLogCreateReqDTO createDTO) { + createApiAccessLog(createDTO).checkError(); + } } diff --git a/cf-module-infra/cf-module-infra-api/src/main/java/com/cf/imes/module/infra/api/logger/ApiErrorLogApi.java b/cf-module-infra/cf-module-infra-api/src/main/java/com/cf/imes/module/infra/api/logger/ApiErrorLogApi.java index c54586a4f..7568d25e0 100644 --- a/cf-module-infra/cf-module-infra-api/src/main/java/com/cf/imes/module/infra/api/logger/ApiErrorLogApi.java +++ b/cf-module-infra/cf-module-infra-api/src/main/java/com/cf/imes/module/infra/api/logger/ApiErrorLogApi.java @@ -6,6 +6,7 @@ import com.cf.imes.module.infra.enums.ApiConstants; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.scheduling.annotation.Async; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -21,4 +22,8 @@ public interface ApiErrorLogApi { @Operation(summary = "创建 API 异常日志") CommonResult createApiErrorLog(@Valid @RequestBody ApiErrorLogCreateReqDTO createDTO); + @Async + default void createApiErrorLogAsync(ApiErrorLogCreateReqDTO createDTO) { + createApiErrorLog(createDTO).checkError(); + } } diff --git a/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/dal/dataobject/logger/ApiAccessLogDO.java b/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/dal/dataobject/logger/ApiAccessLogDO.java index 243fe084b..f4892aa73 100644 --- a/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/dal/dataobject/logger/ApiAccessLogDO.java +++ b/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/dal/dataobject/logger/ApiAccessLogDO.java @@ -25,6 +25,16 @@ import java.time.LocalDateTime; @AllArgsConstructor public class ApiAccessLogDO extends BaseDO { + /** + * {@link #requestParams} 的最大长度 + */ + public static final Integer REQUEST_PARAMS_MAX_LENGTH = 8000; + + /** + * {@link #resultMsg} 的最大长度 + */ + public static final Integer RESULT_MSG_MAX_LENGTH = 512; + /** * 编号 */ diff --git a/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/dal/dataobject/logger/ApiErrorLogDO.java b/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/dal/dataobject/logger/ApiErrorLogDO.java index ddaa6cc7d..e17434517 100644 --- a/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/dal/dataobject/logger/ApiErrorLogDO.java +++ b/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/dal/dataobject/logger/ApiErrorLogDO.java @@ -25,6 +25,11 @@ import java.time.LocalDateTime; @KeySequence(value = "infra_api_error_log_seq") public class ApiErrorLogDO extends BaseDO { + /** + * {@link #requestParams} 的最大长度 + */ + public static final Integer REQUEST_PARAMS_MAX_LENGTH = 8000; + /** * 编号 */ diff --git a/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/service/logger/ApiAccessLogServiceImpl.java b/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/service/logger/ApiAccessLogServiceImpl.java index ac886b21a..0066867ee 100644 --- a/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/service/logger/ApiAccessLogServiceImpl.java +++ b/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/service/logger/ApiAccessLogServiceImpl.java @@ -1,7 +1,10 @@ package com.cf.imes.module.infra.service.logger; +import cn.hutool.core.util.StrUtil; import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.common.util.object.BeanUtils; +import com.cf.imes.framework.organ.core.context.OrganContextHolder; +import com.cf.imes.framework.organ.core.util.OrganUtils; import com.cf.imes.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; import com.cf.imes.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO; import com.cf.imes.module.infra.dal.dataobject.logger.ApiAccessLogDO; @@ -13,6 +16,9 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.time.LocalDateTime; +import static com.cf.imes.module.infra.dal.dataobject.logger.ApiAccessLogDO.REQUEST_PARAMS_MAX_LENGTH; +import static com.cf.imes.module.infra.dal.dataobject.logger.ApiAccessLogDO.RESULT_MSG_MAX_LENGTH; + /** * API 访问日志 Service 实现类 * @@ -29,10 +35,13 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService { @Override public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) { ApiAccessLogDO apiAccessLog = BeanUtils.toBean(createDTO, ApiAccessLogDO.class); - try { + apiAccessLog.setRequestParams(StrUtil.maxLength(apiAccessLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH)); + apiAccessLog.setResultMsg(StrUtil.maxLength(apiAccessLog.getResultMsg(), RESULT_MSG_MAX_LENGTH)); + if (OrganContextHolder.getOrganId() != null) { apiAccessLogMapper.insert(apiAccessLog); - }catch (Exception e) { - log.error("插入API 访问日志发生异常,异常信息{},日志内容{}", e.getMessage(), apiAccessLog); + } else { + // 极端情况下,上下文中没有租户时,此时忽略租户上下文,避免插入失败! + OrganUtils.executeIgnore(() -> apiAccessLogMapper.insert(apiAccessLog)); } } diff --git a/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/service/logger/ApiErrorLogServiceImpl.java b/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/service/logger/ApiErrorLogServiceImpl.java index faf39f684..67b13914a 100644 --- a/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/service/logger/ApiErrorLogServiceImpl.java +++ b/cf-module-infra/cf-module-infra-biz/src/main/java/com/cf/imes/module/infra/service/logger/ApiErrorLogServiceImpl.java @@ -1,7 +1,10 @@ package com.cf.imes.module.infra.service.logger; +import cn.hutool.core.util.StrUtil; import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.common.util.object.BeanUtils; +import com.cf.imes.framework.organ.core.context.OrganContextHolder; +import com.cf.imes.framework.organ.core.util.OrganUtils; import com.cf.imes.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; import com.cf.imes.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO; import com.cf.imes.module.infra.dal.dataobject.logger.ApiErrorLogDO; @@ -15,6 +18,7 @@ import javax.annotation.Resource; import java.time.LocalDateTime; import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.cf.imes.module.infra.dal.dataobject.logger.ApiErrorLogDO.REQUEST_PARAMS_MAX_LENGTH; import static com.cf.imes.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_NOT_FOUND; import static com.cf.imes.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_PROCESSED; @@ -35,10 +39,12 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService { public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) { ApiErrorLogDO apiErrorLog = BeanUtils.toBean(createDTO, ApiErrorLogDO.class) .setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus()); - try { + apiErrorLog.setRequestParams(StrUtil.maxLength(apiErrorLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH)); + if (OrganContextHolder.getOrganId() != null) { apiErrorLogMapper.insert(apiErrorLog); - }catch (Exception e) { - log.error("插入系统异常日志发生异常,异常信息{},日志内容{}",e.getMessage(), apiErrorLog); + } else { + // 极端情况下,上下文中没有租户时,此时忽略租户上下文,避免插入失败! + OrganUtils.executeIgnore(() -> apiErrorLogMapper.insert(apiErrorLog)); } } From 7344694252b2adec042faa3eb946880b24f0a1c8 Mon Sep 17 00:00:00 2001 From: liuzhaotian Date: Tue, 14 Jan 2025 13:36:36 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8E=92=E5=8D=95=E6=8A=95=E5=85=A5?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E9=80=BB=E8=BE=91=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/api/plan/OrderPlanApiImpl.java | 29 +++++++++++++++---- .../admin/plan/vo/PlanPageReqVO.java | 3 ++ .../controller/admin/plan/vo/PlanRespVO.java | 3 ++ .../admin/plan/vo/PlanSaveReqVO.java | 2 ++ .../executor/dal/dataobject/plan/PlanDO.java | 5 ++++ .../executor/dal/mysql/plan/PlanMapper.java | 2 ++ .../dal/mysql/planitem/PlanItemMapper.java | 11 +++++++ .../optimizeplan/OptimizePlanServiceImpl.java | 2 +- .../service/plan/PlanServiceImpl.java | 5 ++-- .../system/enums/ErrorCodeConstants.java | 1 + 10 files changed, 54 insertions(+), 9 deletions(-) diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/api/plan/OrderPlanApiImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/api/plan/OrderPlanApiImpl.java index 885619c97..555997b25 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/api/plan/OrderPlanApiImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/api/plan/OrderPlanApiImpl.java @@ -22,6 +22,8 @@ import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO; import com.cf.imes.module.executor.dal.dataobject.orderParts.OrderPartsDO; import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO; import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO; +import com.cf.imes.module.executor.dal.dataobject.planitem.PlanItemDO; +import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO; import com.cf.imes.module.executor.dal.dataobject.remainplaten.RemainPlateDO; import com.cf.imes.module.executor.dal.mysql.goods.GoodsMapper; import com.cf.imes.module.executor.dal.mysql.order.OrderMapper; @@ -30,6 +32,7 @@ import com.cf.imes.module.executor.dal.mysql.orderGroup.OrderGroupMapper; import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper; import com.cf.imes.module.executor.dal.mysql.orderParts.OrderPartsMapper; import com.cf.imes.module.executor.dal.mysql.plan.PlanMapper; +import com.cf.imes.module.executor.dal.mysql.planItem.PlanItemMapper; import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper; import com.cf.imes.module.executor.dal.mysql.remainplaten.RemainPlateMapper; import com.fasterxml.jackson.databind.JsonNode; @@ -42,6 +45,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR; @@ -87,6 +91,8 @@ public class OrderPlanApiImpl implements OrderPlanApi{ @Resource private OrderPartsMapper orderPartsMapper; + @Resource + private PlanItemMapper planItemMapper; @Resource private ElasticsearchClient elasticsearchClient; @@ -122,16 +128,27 @@ public class OrderPlanApiImpl implements OrderPlanApi{ @Override public CommonResult getOrder(Long orderId) { - List planIds = goodsMapper.selectNoPlanOrders(orderId, getUserOrganId()); + List plateDOS = plateMapper.selectNoCutPlateByPlateId(Collections.singletonList(orderId), getUserOrganId()); - List planList = planIds.stream().filter(f -> f == 0).toList(); - - if(planIds.isEmpty() || !planList.isEmpty()){ + if(CollUtil.isNotEmpty(plateDOS)){ return CommonResult.success(false); } - List planIdList = planMapper.selectPLanList(planIds, getUserOrganId()); - return CommonResult.success(planIdList.isEmpty()); + List planItemDOS = planItemMapper.selectOrderPlanList(orderId, getUserOrganId()); + + if(CollUtil.isNotEmpty(planItemDOS)){ + + List planIds = planItemDOS.stream().map(PlanItemDO::getPlanId).distinct().toList(); + + List planDOS = planMapper.selectPLanList(planIds,getUserOrganId()); + + if(CollUtil.isEmpty(planDOS)){ + return CommonResult.success(true); + } + + } + + return CommonResult.success(false); } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanPageReqVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanPageReqVO.java index 95827a517..92465507a 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanPageReqVO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanPageReqVO.java @@ -43,6 +43,9 @@ public class PlanPageReqVO extends PageParam { private List status; + @Schema(description = "是否已投产") + private Boolean isScheduled; + @Schema(description = "机台 ID", example = "16707") private Long machineId; diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanRespVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanRespVO.java index f7c5d3e6e..90672f235 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanRespVO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanRespVO.java @@ -29,6 +29,9 @@ public class PlanRespVO { @ExcelProperty("排单状态:0 新单,1 板材已申请,2 开料中,3 已开料") private Integer status; + @Schema(description = "是否已投产") + private Boolean isScheduled; + @Schema(description = "板材过滤条件") private String filter; diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanSaveReqVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanSaveReqVO.java index 183445095..981c28a75 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanSaveReqVO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanSaveReqVO.java @@ -27,6 +27,8 @@ public class PlanSaveReqVO { @PlanStatusValid private Integer status; + @Schema(description = "是否已投产") + private Boolean isScheduled; @Schema(description = "需要进行排单的板材信息") private SavePlanPlateList savePlanPlateList; diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plan/PlanDO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plan/PlanDO.java index b88c34d69..a56a42260 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plan/PlanDO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/plan/PlanDO.java @@ -43,6 +43,11 @@ public class PlanDO extends BaseDO { */ private Integer status; + /** + * 是否已投产:0未投产,1已投产 + */ + private Boolean isScheduled; + /** * 板材过滤条件 */ diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plan/PlanMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plan/PlanMapper.java index e6cedc353..078afc5c7 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plan/PlanMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plan/PlanMapper.java @@ -30,6 +30,7 @@ public interface PlanMapper extends BaseMapperX { return selectJoinPage(reqVO, PlanDO.class, new MPJLambdaWrapperX() .eq(PlanDO::getDeleted,false) .eq(PlanDO::getOrganId,getUserOrganId()) + .eqIfPresent(PlanDO::getIsScheduled,reqVO.getIsScheduled()) .eqIfPresent(PlanDO::getId, reqVO.getId()) .eqIfPresent(PlanDO::getSort, reqVO.getSort()) .eqIfPresent(PlanDO::getType, reqVO.getType()) @@ -52,6 +53,7 @@ public interface PlanMapper extends BaseMapperX { return selectPage(reqVO, new LambdaQueryWrapperX() .eq(PlanDO::getDeleted,false) .eq(PlanDO::getOrganId,getUserOrganId()) + .eqIfPresent(PlanDO::getIsScheduled,reqVO.getIsScheduled()) .eqIfPresent(PlanDO::getId, reqVO.getId()) .eqIfPresent(PlanDO::getSort, reqVO.getSort()) .eqIfPresent(PlanDO::getType, reqVO.getType()) diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/planitem/PlanItemMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/planitem/PlanItemMapper.java index e421037c6..890f6cb85 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/planitem/PlanItemMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/planitem/PlanItemMapper.java @@ -51,4 +51,15 @@ public interface PlanItemMapper extends BaseMapperX { List selectNoOrderGoodsIdList(@Param(Constants.WRAPPER) Wrapper wrapper); List selectPlanIncrementPlate(@Param("noPlanIds") List noPlanIds,@Param("organId") Long organId); + + + default List selectOrderPlanList(Long orderId,Long organId) { + return selectList( new LambdaQueryWrapperX() + .eq(PlanItemDO::getOrganId, organId) + .eq(PlanItemDO::getOrderId,orderId) + .select(PlanItemDO::getPlanId)); + } + + + } \ 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/service/optimizeplan/OptimizePlanServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java index 2d6b77e45..e725966fa 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java @@ -402,7 +402,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { List goodsNo = respVO.getGoodsNo(); Integer cutedType = respVO.getCutedType(); - if(goodsIds.isEmpty()){ + if(goodsIds.isEmpty() || goodsNo.isEmpty()){ return; } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java index ad49c3389..f854b5f89 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java @@ -166,7 +166,8 @@ public class PlanServiceImpl implements PlanService { List planItemDOS = new ArrayList<>(); - SavePlanPlateList savePlanPlateList = createReqVO.getSavePlanPlateList(); + SavePlanPlateList savePlanPlateList = Optional.ofNullable(createReqVO.getSavePlanPlateList()).orElseThrow(()-> new ServiceException(PLAN_PLATE_DATA_ERROR)); + if (Boolean.TRUE.equals(createReqVO.getIsMix())) { @@ -330,7 +331,7 @@ public class PlanServiceImpl implements PlanService { }else { - planDO.setStatus(updateReqVO.getStatus()); + planDO.setIsScheduled(updateReqVO.getIsScheduled()); planMapper.updateById(planDO); } diff --git a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java index ee406e45f..5888a3581 100644 --- a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java +++ b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java @@ -339,6 +339,7 @@ public class ErrorCodeConstants { public static final ErrorCode THIS_PROCESS_CONFIG_DATA_ERROR = new ErrorCode(1_002_041_032, "当前选择的加工方案组配置有误,请选择其他方案组或重新配置该方案组"); public static final ErrorCode CREAT_PLAN_PLATE_DATA_ERROR = new ErrorCode(1_002_041_033, "当前板材已有小板创建板材,请重新查询生产单信息再创建"); public static final ErrorCode UPDATE_NO_PLAN_PLATE_DATA_ERROR = new ErrorCode(1_002_041_034, "当前排单无开料板,无法取消开料,请重新尝试"); + public static final ErrorCode PLAN_PLATE_DATA_ERROR = new ErrorCode(1_002_041_035, "当前排单没有选择板材数据,请进行选择"); //=========== 应用信息 1-002-037-000 ============