mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 12:52:07 +08:00
Merge branch 'main' of http://192.168.1.205:9980/cf_devdept2/cf_imes_server
This commit is contained in:
+1
-1
@@ -72,7 +72,7 @@ public class ChenfengMybatisAutoConfiguration {
|
||||
}
|
||||
}
|
||||
// 找不到合适的 IKeyGenerator 实现类
|
||||
throw new IllegalArgumentException(CharSequenceUtil.format("DbType{} 找不到合适的 IKeyGenerator 实现类", dbType));
|
||||
throw new IllegalArgumentException("DbType为空");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-17
@@ -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> 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);
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -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 {
|
||||
}
|
||||
|
||||
+8
-8
@@ -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<String, String> 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<String, String> queryString, String requestBody, Exception ex) {
|
||||
// 处理用户信息
|
||||
accessLog.setUserId(WebFrameworkUtils.getLoginUserId(request));
|
||||
|
||||
-85
@@ -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;
|
||||
|
||||
}
|
||||
-17
@@ -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);
|
||||
|
||||
}
|
||||
-28
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
-107
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
-17
@@ -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);
|
||||
|
||||
}
|
||||
-28
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -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
|
||||
|
||||
+10
-19
@@ -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<String, Object> requestParams = MapUtil.<String, Object>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());
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -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<Boolean> createApiAccessLog(@Valid @RequestBody ApiAccessLogCreateReqDTO createDTO);
|
||||
|
||||
/**
|
||||
* 【异步】创建 API 访问日志
|
||||
*
|
||||
* @param createDTO 访问日志 DTO
|
||||
*/
|
||||
@Async
|
||||
default void createApiAccessLogAsync(ApiAccessLogCreateReqDTO createDTO) {
|
||||
createApiAccessLog(createDTO).checkError();
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -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<Boolean> createApiErrorLog(@Valid @RequestBody ApiErrorLogCreateReqDTO createDTO);
|
||||
|
||||
@Async
|
||||
default void createApiErrorLogAsync(ApiErrorLogCreateReqDTO createDTO) {
|
||||
createApiErrorLog(createDTO).checkError();
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -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;
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
|
||||
+5
@@ -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;
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
|
||||
+12
-3
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-6
@@ -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<Boolean> getOrder(Long orderId) {
|
||||
|
||||
List<Long> planIds = goodsMapper.selectNoPlanOrders(orderId, getUserOrganId());
|
||||
List<PlateDO> plateDOS = plateMapper.selectNoCutPlateByPlateId(Collections.singletonList(orderId), getUserOrganId());
|
||||
|
||||
List<Long> planList = planIds.stream().filter(f -> f == 0).toList();
|
||||
|
||||
if(planIds.isEmpty() || !planList.isEmpty()){
|
||||
if(CollUtil.isNotEmpty(plateDOS)){
|
||||
return CommonResult.success(false);
|
||||
}
|
||||
List<Long> planIdList = planMapper.selectPLanList(planIds, getUserOrganId());
|
||||
|
||||
return CommonResult.success(planIdList.isEmpty());
|
||||
List<PlanItemDO> planItemDOS = planItemMapper.selectOrderPlanList(orderId, getUserOrganId());
|
||||
|
||||
if(CollUtil.isNotEmpty(planItemDOS)){
|
||||
|
||||
List<Long> planIds = planItemDOS.stream().map(PlanItemDO::getPlanId).distinct().toList();
|
||||
|
||||
List<Long> planDOS = planMapper.selectPLanList(planIds,getUserOrganId());
|
||||
|
||||
if(CollUtil.isEmpty(planDOS)){
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return CommonResult.success(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+5
-4
@@ -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;
|
||||
@@ -381,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 {
|
||||
|
||||
+3
@@ -43,6 +43,9 @@ public class PlanPageReqVO extends PageParam {
|
||||
private List<Integer> status;
|
||||
|
||||
|
||||
@Schema(description = "是否已投产")
|
||||
private Boolean isScheduled;
|
||||
|
||||
@Schema(description = "机台 ID", example = "16707")
|
||||
private Long machineId;
|
||||
|
||||
|
||||
+3
@@ -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;
|
||||
|
||||
|
||||
+2
@@ -27,6 +27,8 @@ public class PlanSaveReqVO {
|
||||
@PlanStatusValid
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否已投产")
|
||||
private Boolean isScheduled;
|
||||
|
||||
@Schema(description = "需要进行排单的板材信息")
|
||||
private SavePlanPlateList savePlanPlateList;
|
||||
|
||||
+5
@@ -43,6 +43,11 @@ public class PlanDO extends BaseDO {
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否已投产:0未投产,1已投产
|
||||
*/
|
||||
private Boolean isScheduled;
|
||||
|
||||
/**
|
||||
* 板材过滤条件
|
||||
*/
|
||||
|
||||
+2
@@ -30,6 +30,7 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
|
||||
return selectJoinPage(reqVO, PlanDO.class, new MPJLambdaWrapperX<PlanDO>()
|
||||
.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<PlanDO> {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PlanDO>()
|
||||
.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())
|
||||
|
||||
+11
@@ -51,4 +51,15 @@ public interface PlanItemMapper extends BaseMapperX<PlanItemDO> {
|
||||
List<OrderGoodsResp> selectNoOrderGoodsIdList(@Param(Constants.WRAPPER) Wrapper<PlanItemDO> wrapper);
|
||||
|
||||
List<OrderPlateIds> selectPlanIncrementPlate(@Param("noPlanIds") List<Long> noPlanIds,@Param("organId") Long organId);
|
||||
|
||||
|
||||
default List<PlanItemDO> selectOrderPlanList(Long orderId,Long organId) {
|
||||
return selectList( new LambdaQueryWrapperX<PlanItemDO>()
|
||||
.eq(PlanItemDO::getOrganId, organId)
|
||||
.eq(PlanItemDO::getOrderId,orderId)
|
||||
.select(PlanItemDO::getPlanId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -402,7 +402,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
List<Integer> goodsNo = respVO.getGoodsNo();
|
||||
Integer cutedType = respVO.getCutedType();
|
||||
|
||||
if(goodsIds.isEmpty()){
|
||||
if(goodsIds.isEmpty() || goodsNo.isEmpty()){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -166,7 +166,8 @@ public class PlanServiceImpl implements PlanService {
|
||||
|
||||
List<PlanItemDO> 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);
|
||||
}
|
||||
|
||||
|
||||
+3
-6
@@ -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<String, OrderGroupDO> groupInfos,
|
||||
Map<String, Map<String, BasePosition>> boxBasePositionMap,
|
||||
Map<String, BasePosition> 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();
|
||||
|
||||
+1
@@ -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 ============
|
||||
|
||||
Reference in New Issue
Block a user