mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、sonarqube质量修复;2、短信模板增删查询移除短信渠道相关内容;
This commit is contained in:
+38
-30
@@ -64,41 +64,49 @@ public class HttpUtils {
|
||||
.userInfo(redirectUri.getUserInfo()).path(redirectUri.getPath());
|
||||
|
||||
if (fragment) {
|
||||
StringBuilder values = new StringBuilder();
|
||||
if (redirectUri.getFragment() != null) {
|
||||
String append = redirectUri.getFragment();
|
||||
values.append(append);
|
||||
}
|
||||
for (String key : query.keySet()) {
|
||||
if (values.length() > 0) {
|
||||
values.append("&");
|
||||
}
|
||||
String name = key;
|
||||
if (keys != null && keys.containsKey(key)) {
|
||||
name = keys.get(key);
|
||||
}
|
||||
values.append(name).append("={").append(key).append("}");
|
||||
}
|
||||
if (values.length() > 0) {
|
||||
template.fragment(values.toString());
|
||||
}
|
||||
UriComponents encoded = template.build().expand(query).encode();
|
||||
builder.fragment(encoded.getFragment());
|
||||
buildFragmentUri(template, builder, redirectUri, query, keys);
|
||||
} else {
|
||||
for (String key : query.keySet()) {
|
||||
String name = key;
|
||||
if (keys != null && keys.containsKey(key)) {
|
||||
name = keys.get(key);
|
||||
}
|
||||
template.queryParam(name, "{" + key + "}");
|
||||
}
|
||||
template.fragment(redirectUri.getFragment());
|
||||
UriComponents encoded = template.build().expand(query).encode();
|
||||
builder.query(encoded.getQuery());
|
||||
buildUri(template, builder, redirectUri, query, keys);
|
||||
}
|
||||
return builder.build().toUriString();
|
||||
}
|
||||
|
||||
private static void buildUri(UriComponentsBuilder template, UriComponentsBuilder builder, URI redirectUri, Map<String, ?> query, Map<String, String> keys) {
|
||||
for (String key : query.keySet()) {
|
||||
String name = key;
|
||||
if (keys != null && keys.containsKey(key)) {
|
||||
name = keys.get(key);
|
||||
}
|
||||
template.queryParam(name, "{" + key + "}");
|
||||
}
|
||||
template.fragment(redirectUri.getFragment());
|
||||
UriComponents encoded = template.build().expand(query).encode();
|
||||
builder.query(encoded.getQuery());
|
||||
}
|
||||
|
||||
private static void buildFragmentUri(UriComponentsBuilder template, UriComponentsBuilder builder, URI redirectUri, Map<String, ?> query, Map<String, String> keys) {
|
||||
StringBuilder values = new StringBuilder();
|
||||
if (redirectUri.getFragment() != null) {
|
||||
String append = redirectUri.getFragment();
|
||||
values.append(append);
|
||||
}
|
||||
for (String key : query.keySet()) {
|
||||
if (values.length() > 0) {
|
||||
values.append("&");
|
||||
}
|
||||
String name = key;
|
||||
if (keys != null && keys.containsKey(key)) {
|
||||
name = keys.get(key);
|
||||
}
|
||||
values.append(name).append("={").append(key).append("}");
|
||||
}
|
||||
if (values.length() > 0) {
|
||||
template.fragment(values.toString());
|
||||
}
|
||||
UriComponents encoded = template.build().expand(query).encode();
|
||||
builder.fragment(encoded.getFragment());
|
||||
}
|
||||
|
||||
public static String[] obtainBasicAuthorization(HttpServletRequest request) {
|
||||
String clientId;
|
||||
String clientSecret;
|
||||
|
||||
+30
-18
@@ -303,24 +303,7 @@ public class JsonUtils {
|
||||
for (JsonNode jsonObject : jsonArray) {
|
||||
List<Object> row = new ArrayList<>();
|
||||
for (String header : headers) {
|
||||
JsonNode valueNode = jsonObject.get(header);
|
||||
if (valueNode != null) {
|
||||
if (valueNode.isTextual()) {
|
||||
row.add(valueNode.asText());
|
||||
} else if (valueNode.isInt()) {
|
||||
row.add(valueNode.asInt());
|
||||
} else if (valueNode.isBoolean()) {
|
||||
row.add(valueNode.asBoolean());
|
||||
} else if (valueNode.isDouble()) {
|
||||
row.add(valueNode.asDouble());
|
||||
} else if (valueNode.isArray() || valueNode.isObject() ) {
|
||||
row.add(jsonTo2DArray(valueNode.toString()));
|
||||
} else {
|
||||
row.add(valueNode.asText());
|
||||
}
|
||||
} else {
|
||||
row.add(null); // 处理缺少的值
|
||||
}
|
||||
getRow(jsonObject, header, row);
|
||||
}
|
||||
result.add(row);
|
||||
}
|
||||
@@ -332,6 +315,35 @@ public class JsonUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取行
|
||||
*
|
||||
* @param jsonObject
|
||||
* @param header
|
||||
* @param row
|
||||
* @return
|
||||
*/
|
||||
private static void getRow(JsonNode jsonObject, String header, List<Object> row) {
|
||||
JsonNode valueNode = jsonObject.get(header);
|
||||
if (valueNode != null) {
|
||||
if (valueNode.isTextual()) {
|
||||
row.add(valueNode.asText());
|
||||
} else if (valueNode.isInt()) {
|
||||
row.add(valueNode.asInt());
|
||||
} else if (valueNode.isBoolean()) {
|
||||
row.add(valueNode.asBoolean());
|
||||
} else if (valueNode.isDouble()) {
|
||||
row.add(valueNode.asDouble());
|
||||
} else if (valueNode.isArray() || valueNode.isObject()) {
|
||||
row.add(jsonTo2DArray(valueNode.toString()));
|
||||
} else {
|
||||
row.add(valueNode.asText());
|
||||
}
|
||||
} else {
|
||||
row.add(null); // 处理缺少的值
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 抽取 json数据,不改变数据结构对应的值,只改变数据结构(参考 HPACK 算法) 实现json数据抽取
|
||||
public static List<List<Object>> getData(Object object) {
|
||||
|
||||
+3
-1
@@ -2,6 +2,8 @@ package com.cf.imes.framework.file.core.client;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文件客户端的配置
|
||||
* 不同实现的客户端,需要不同的配置,通过子类来定义
|
||||
@@ -12,5 +14,5 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
// @JsonTypeInfo 注解的作用,Jackson 多态
|
||||
// 1. 序列化到时数据库时,增加 @class 属性。
|
||||
// 2. 反序列化到内存对象时,通过 @class 属性,可以创建出正确的类型
|
||||
public interface FileClientConfig {
|
||||
public interface FileClientConfig extends Serializable {
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class ChenfengRedisAutoConfiguration {
|
||||
return template;
|
||||
}
|
||||
|
||||
public static RedisSerializer<?> buildRedisSerializer() {
|
||||
public static RedisSerializer buildRedisSerializer() {
|
||||
RedisSerializer<Object> json = RedisSerializer.json();
|
||||
// 解决 LocalDateTime 的序列化
|
||||
ObjectMapper objectMapper = (ObjectMapper) ReflectUtil.getFieldValue(json, "mapper");
|
||||
|
||||
+17
-17
@@ -59,7 +59,7 @@ public class GlobalExceptionHandler {
|
||||
* @param ex 异常
|
||||
* @return 通用返回
|
||||
*/
|
||||
public CommonResult<?> allExceptionHandler(HttpServletRequest request, Throwable ex) {
|
||||
public CommonResult allExceptionHandler(HttpServletRequest request, Throwable ex) {
|
||||
if (ex instanceof MissingServletRequestParameterException) {
|
||||
return missingServletRequestParameterExceptionHandler((MissingServletRequestParameterException) ex);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class GlobalExceptionHandler {
|
||||
* 例如说,接口上设置了 @RequestParam("xx") 参数,结果并未传递 xx 参数
|
||||
*/
|
||||
@ExceptionHandler(value = MissingServletRequestParameterException.class)
|
||||
public CommonResult<?> missingServletRequestParameterExceptionHandler(MissingServletRequestParameterException ex) {
|
||||
public CommonResult missingServletRequestParameterExceptionHandler(MissingServletRequestParameterException ex) {
|
||||
log.warn("[missingServletRequestParameterExceptionHandler]", ex);
|
||||
return CommonResult.error(BAD_REQUEST.getCode(), String.format("请求参数缺失:%s", ex.getParameterName()));
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class GlobalExceptionHandler {
|
||||
* 例如说,接口上设置了 @RequestParam("xx") 参数为 Integer,结果传递 xx 参数类型为 String
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||
public CommonResult<?> methodArgumentTypeMismatchExceptionHandler(MethodArgumentTypeMismatchException ex) {
|
||||
public CommonResult methodArgumentTypeMismatchExceptionHandler(MethodArgumentTypeMismatchException ex) {
|
||||
log.warn("[missingServletRequestParameterExceptionHandler]", ex);
|
||||
return CommonResult.error(BAD_REQUEST.getCode(), String.format("请求参数类型错误:%s", ex.getMessage()));
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class GlobalExceptionHandler {
|
||||
* 处理 SpringMVC 参数校验不正确
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public CommonResult<?> methodArgumentNotValidExceptionExceptionHandler(MethodArgumentNotValidException ex) {
|
||||
public CommonResult methodArgumentNotValidExceptionExceptionHandler(MethodArgumentNotValidException ex) {
|
||||
log.warn("[methodArgumentNotValidExceptionExceptionHandler]", ex);
|
||||
FieldError fieldError = ex.getBindingResult().getFieldError();
|
||||
assert fieldError != null; // 断言,避免告警
|
||||
@@ -131,7 +131,7 @@ public class GlobalExceptionHandler {
|
||||
* 处理 SpringMVC 参数绑定不正确,本质上也是通过 Validator 校验
|
||||
*/
|
||||
@ExceptionHandler(BindException.class)
|
||||
public CommonResult<?> bindExceptionHandler(BindException ex) {
|
||||
public CommonResult bindExceptionHandler(BindException ex) {
|
||||
log.warn("[handleBindException]", ex);
|
||||
FieldError fieldError = ex.getFieldError();
|
||||
assert fieldError != null; // 断言,避免告警
|
||||
@@ -142,9 +142,9 @@ public class GlobalExceptionHandler {
|
||||
* 处理 Validator 校验不通过产生的异常
|
||||
*/
|
||||
@ExceptionHandler(value = ConstraintViolationException.class)
|
||||
public CommonResult<?> constraintViolationExceptionHandler(ConstraintViolationException ex) {
|
||||
public CommonResult constraintViolationExceptionHandler(ConstraintViolationException ex) {
|
||||
log.warn("[constraintViolationExceptionHandler]", ex);
|
||||
ConstraintViolation<?> constraintViolation = ex.getConstraintViolations().iterator().next();
|
||||
ConstraintViolation constraintViolation = ex.getConstraintViolations().iterator().next();
|
||||
return CommonResult.error(BAD_REQUEST.getCode(), String.format("请求参数不正确:%s", constraintViolation.getMessage()));
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class GlobalExceptionHandler {
|
||||
* 处理 Dubbo Consumer 本地参数校验时,抛出的 ValidationException 异常
|
||||
*/
|
||||
@ExceptionHandler(value = ValidationException.class)
|
||||
public CommonResult<?> validationException(ValidationException ex) {
|
||||
public CommonResult validationException(ValidationException ex) {
|
||||
log.warn("[constraintViolationExceptionHandler]", ex);
|
||||
// 无法拼接明细的错误信息,因为 Dubbo Consumer 抛出 ValidationException 异常时,是直接的字符串信息,且人类不可读
|
||||
return CommonResult.error(BAD_REQUEST);
|
||||
@@ -166,7 +166,7 @@ public class GlobalExceptionHandler {
|
||||
* 2. spring.mvc.static-path-pattern 为 /statics/**
|
||||
*/
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
public CommonResult<?> noHandlerFoundExceptionHandler(NoHandlerFoundException ex) {
|
||||
public CommonResult noHandlerFoundExceptionHandler(NoHandlerFoundException ex) {
|
||||
log.warn("[noHandlerFoundExceptionHandler]", ex);
|
||||
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL()));
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public class GlobalExceptionHandler {
|
||||
* 例如说,A 接口的方法为 GET 方式,结果请求方法为 POST 方式,导致不匹配
|
||||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
public CommonResult<?> httpRequestMethodNotSupportedExceptionHandler(HttpRequestMethodNotSupportedException ex) {
|
||||
public CommonResult httpRequestMethodNotSupportedExceptionHandler(HttpRequestMethodNotSupportedException ex) {
|
||||
log.warn("[httpRequestMethodNotSupportedExceptionHandler]", ex);
|
||||
return CommonResult.error(METHOD_NOT_ALLOWED.getCode(), String.format("请求方法不正确:%s", ex.getMessage()));
|
||||
}
|
||||
@@ -185,7 +185,7 @@ public class GlobalExceptionHandler {
|
||||
/**
|
||||
* 处理 Resilience4j 限流抛出的异常
|
||||
*/
|
||||
public CommonResult<?> requestNotPermittedExceptionHandler(HttpServletRequest req, Throwable ex) {
|
||||
public CommonResult requestNotPermittedExceptionHandler(HttpServletRequest req, Throwable ex) {
|
||||
log.warn("[requestNotPermittedExceptionHandler][url({}) 访问过于频繁]", req.getRequestURL(), ex);
|
||||
return CommonResult.error(TOO_MANY_REQUESTS);
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public class GlobalExceptionHandler {
|
||||
* 来源是,使用 @PreAuthorize 注解,AOP 进行权限拦截
|
||||
*/
|
||||
@ExceptionHandler(value = AccessDeniedException.class)
|
||||
public CommonResult<?> accessDeniedExceptionHandler(HttpServletRequest req, AccessDeniedException ex) {
|
||||
public CommonResult accessDeniedExceptionHandler(HttpServletRequest req, AccessDeniedException ex) {
|
||||
log.warn("[accessDeniedExceptionHandler][userId({}) 无法访问 url({})]", WebFrameworkUtils.getLoginUserId(req),
|
||||
req.getRequestURL(), ex);
|
||||
return CommonResult.error(FORBIDDEN);
|
||||
@@ -208,7 +208,7 @@ public class GlobalExceptionHandler {
|
||||
* 例如说,商品库存不足,用户手机号已存在。
|
||||
*/
|
||||
@ExceptionHandler(value = ServiceException.class)
|
||||
public CommonResult<?> serviceExceptionHandler(ServiceException ex) {
|
||||
public CommonResult serviceExceptionHandler(ServiceException ex) {
|
||||
log.info("[serviceExceptionHandler]", ex);
|
||||
return CommonResult.error(ex.getCode(), ex.getMessage());
|
||||
}
|
||||
@@ -220,7 +220,7 @@ public class GlobalExceptionHandler {
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(value = DuplicateKeyException.class)
|
||||
public CommonResult<?> duplicateKeyExceptionHandler(DuplicateKeyException ex) {
|
||||
public CommonResult duplicateKeyExceptionHandler(DuplicateKeyException ex) {
|
||||
log.info("[duplicateKeyExceptionHandler]", ex);
|
||||
return CommonResult.error(INTERNAL_SERVER_ERROR.getCode(), "请求数据已存在,请检查");
|
||||
}
|
||||
@@ -229,9 +229,9 @@ public class GlobalExceptionHandler {
|
||||
* 处理系统异常,兜底处理所有的一切
|
||||
*/
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
public CommonResult<?> defaultExceptionHandler(HttpServletRequest req, Throwable ex) {
|
||||
public CommonResult defaultExceptionHandler(HttpServletRequest req, Throwable ex) {
|
||||
// 情况一:处理表不存在的异常
|
||||
CommonResult<?> tableNotExistsResult = handleTableNotExists(ex);
|
||||
CommonResult tableNotExistsResult = handleTableNotExists(ex);
|
||||
if (tableNotExistsResult != null) {
|
||||
return tableNotExistsResult;
|
||||
}
|
||||
@@ -306,7 +306,7 @@ public class GlobalExceptionHandler {
|
||||
* @param ex 异常
|
||||
* @return 如果是 Table 不存在的异常,则返回对应的 CommonResult
|
||||
*/
|
||||
private CommonResult<?> handleTableNotExists(Throwable ex) {
|
||||
private CommonResult handleTableNotExists(Throwable ex) {
|
||||
String message = ExceptionUtil.getRootCauseMessage(ex);
|
||||
if (!message.contains("doesn't exist")) {
|
||||
return null;
|
||||
|
||||
+2
-2
@@ -155,8 +155,8 @@ public class WebFrameworkUtils {
|
||||
request.setAttribute(REQUEST_ATTRIBUTE_COMMON_RESULT, result);
|
||||
}
|
||||
|
||||
public static CommonResult<?> getCommonResult(ServletRequest request) {
|
||||
return (CommonResult<?>) request.getAttribute(REQUEST_ATTRIBUTE_COMMON_RESULT);
|
||||
public static CommonResult getCommonResult(ServletRequest request) {
|
||||
return (CommonResult) request.getAttribute(REQUEST_ATTRIBUTE_COMMON_RESULT);
|
||||
}
|
||||
|
||||
public static HttpServletRequest getRequest() {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class GlobalExceptionHandler implements ErrorWebExceptionHandler {
|
||||
}
|
||||
|
||||
// 转换成 CommonResult
|
||||
CommonResult<?> result;
|
||||
CommonResult result;
|
||||
if (ex instanceof ResponseStatusException) {
|
||||
result = responseStatusExceptionHandler(exchange, (ResponseStatusException) ex);
|
||||
} else {
|
||||
@@ -50,7 +50,7 @@ public class GlobalExceptionHandler implements ErrorWebExceptionHandler {
|
||||
/**
|
||||
* 处理 Spring Cloud Gateway 默认抛出的 ResponseStatusException 异常
|
||||
*/
|
||||
private CommonResult<?> responseStatusExceptionHandler(ServerWebExchange exchange,
|
||||
private CommonResult responseStatusExceptionHandler(ServerWebExchange exchange,
|
||||
ResponseStatusException ex) {
|
||||
// TODO 晨丰:这里要精细化翻译,默认返回用户是看不懂的
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
@@ -62,7 +62,7 @@ public class GlobalExceptionHandler implements ErrorWebExceptionHandler {
|
||||
* 处理系统异常,兜底处理所有的一切
|
||||
*/
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
public CommonResult<?> defaultExceptionHandler(ServerWebExchange exchange,
|
||||
public CommonResult defaultExceptionHandler(ServerWebExchange exchange,
|
||||
Throwable ex) {
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
log.error("[defaultExceptionHandler][uri({}/{}) 发生异常]", request.getURI(), request.getMethod(), ex);
|
||||
|
||||
+3
-9
@@ -40,11 +40,11 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@@ -54,16 +54,10 @@ import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.IMPORT
|
||||
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
|
||||
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.module.executor.service.order.OrderService;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 生产单管理")
|
||||
@@ -165,7 +159,7 @@ public class OrderController {
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获得导入生产单模板")
|
||||
@Parameter(name = "value", description = "文件类型", required = true, example = "0")
|
||||
public void importTemplate(HttpServletResponse response, @RequestParam("value") String value) {
|
||||
public void importTemplate(HttpServletResponse response, @RequestParam("value") @NotEmpty(message = "文件路径不能为空") String value) {
|
||||
orderService.exportTemplate(response, value);
|
||||
}
|
||||
|
||||
@@ -404,7 +398,7 @@ public class OrderController {
|
||||
@Parameter(name = "deleted", description = "是否删除", example = "false")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('production:manager-list:detail')")
|
||||
public CommonResult<Map<String, List<?>>> getModule(@RequestParam("orderId") Long orderId,
|
||||
public CommonResult<Map<String, List>> getModule(@RequestParam("orderId") Long orderId,
|
||||
@RequestParam(value = "deleted", required = false, defaultValue = "false") Boolean deleted) {
|
||||
if (deleted == null) {
|
||||
deleted = false;
|
||||
|
||||
+4
-1
@@ -4,13 +4,16 @@ import com.cf.imes.module.executor.controller.admin.plan.dto.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Beal
|
||||
*/
|
||||
@Data
|
||||
public class PlateDetailVO {
|
||||
public class PlateDetailVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5934179383701994502L;
|
||||
|
||||
@Schema(description = "生产单id")
|
||||
private Long orderId;
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public interface OrderService {
|
||||
* @param orderId: 生产单Id
|
||||
* @return Map<String, List<?>>
|
||||
*/
|
||||
Map<String,List<?>> getModule(Long orderId, Integer deleted);
|
||||
Map<String,List> getModule(Long orderId, Integer deleted);
|
||||
|
||||
/**
|
||||
* @param orderId: 生产单id
|
||||
|
||||
+31
-37
File diff suppressed because one or more lines are too long
+37
-27
@@ -119,6 +119,16 @@ public class PlanServiceImpl implements PlanService {
|
||||
@Resource
|
||||
private OptimizePlanService optimizePlanService;
|
||||
|
||||
// 重复使用的常量
|
||||
private static final String FIELD_OG_ID = "og.id";
|
||||
private static final String FIELD_OP_FILTER_TYPE = "op.filter_type";
|
||||
private static final String FIELD_OP_IS_SPECIAL_SHAPED = "op.is_special_shaped";
|
||||
private static final String FIELD_IS_SCULPT = "op.is_sculpt";
|
||||
private static final String FIELD_IS_DOOR = "op.is_door";
|
||||
private static final String FIELD_OP_HEIGHT = "op.height";
|
||||
private static final String FIELD_OP_WIDTH = "op.width";
|
||||
private static final String FIELD_PLANID = "planId";
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String,Long> createPlan(PlanSaveReqVO createReqVO) {
|
||||
@@ -587,20 +597,20 @@ public class PlanServiceImpl implements PlanService {
|
||||
// .eq("og.deleted",false)
|
||||
// .isNull("opi.item_id")
|
||||
// todo 修改排单数据筛选,目前只解决了非混单的情况,混单情况待解决
|
||||
.inIfPresent("og.id",goodsIds)
|
||||
.inIfPresent(FIELD_OG_ID,goodsIds)
|
||||
.inIfPresent("o.id",pageReqVO.getOrderIds())
|
||||
.likeIfPresent("o.id", pageReqVO.getOrderId() != null ? pageReqVO.getOrderId().toString() : null)
|
||||
.inIfPresent("og.id",pageReqVO.getIds())
|
||||
.inIfPresent(FIELD_OG_ID,pageReqVO.getIds())
|
||||
.likeIfPresent("o.customer", pageReqVO.getConsignee())
|
||||
.likeIfPresent("o.custom_order_no", pageReqVO.getDefaultId())
|
||||
.likeIfPresent("o.address", pageReqVO.getConsigneeAddress())
|
||||
.betweenIfPresent("o.order_date", pageReqVO.getCreateTime())
|
||||
.eqIfPresent("op.is_special_shaped", pageReqVO.getRectangle() != null ? false: null)
|
||||
.eqIfPresent("op.is_special_shaped", pageReqVO.getSpecialShaped())
|
||||
.eqIfPresent("op.is_sculpt", pageReqVO.getSculpt())
|
||||
.eqIfPresent("op.is_door", pageReqVO.getIsDoor())
|
||||
.betweenIfPresent("op.height", new BigDecimal[]{pageReqVO.getLongMinRang(), pageReqVO.getLongMaxRang()})
|
||||
.betweenIfPresent("op.width", new BigDecimal[]{pageReqVO.getWidthMinRang(), pageReqVO.getWidthMaxRang()})
|
||||
.eqIfPresent(FIELD_OP_IS_SPECIAL_SHAPED, pageReqVO.getRectangle() != null ? false: null)
|
||||
.eqIfPresent(FIELD_OP_IS_SPECIAL_SHAPED, pageReqVO.getSpecialShaped())
|
||||
.eqIfPresent(FIELD_IS_SCULPT, pageReqVO.getSculpt())
|
||||
.eqIfPresent(FIELD_IS_DOOR, pageReqVO.getIsDoor())
|
||||
.betweenIfPresent(FIELD_OP_HEIGHT, new BigDecimal[]{pageReqVO.getLongMinRang(), pageReqVO.getLongMaxRang()})
|
||||
.betweenIfPresent(FIELD_OP_WIDTH, new BigDecimal[]{pageReqVO.getWidthMinRang(), pageReqVO.getWidthMaxRang()})
|
||||
.orderByDesc("o.id");
|
||||
|
||||
String filterTypes = "";
|
||||
@@ -614,7 +624,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
filterTypes += PlanFilterTypeEnum.TWODIMENSIONALCUTTINGPATH.getType().toString();
|
||||
}
|
||||
|
||||
queryWrapperX.likeIfPresent("op.filter_type", insertSeparator(filterTypes));
|
||||
queryWrapperX.likeIfPresent(FIELD_OP_FILTER_TYPE, insertSeparator(filterTypes));
|
||||
|
||||
|
||||
// todo 目前修改一半,速度无法再进行特别的优化,需等后面修改表结构再进行优化
|
||||
@@ -802,7 +812,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
// .eq("og.plan_id",0)
|
||||
// .eq("og.deleted",false)
|
||||
.inIfPresent("og.order_id", pageReqVO.getOrderIds())
|
||||
.inIfPresent("og.id", pageReqVO.getIds())
|
||||
.inIfPresent(FIELD_OG_ID, pageReqVO.getIds())
|
||||
// todo 修改排单数据筛选,目前只解决了非混单的情况,混单情况待解决
|
||||
.eqIfPresent("og.goods_id",pageReqVO.getGoodsId())
|
||||
.likeIfPresent("o.id", pageReqVO.getOrderId() != null ? pageReqVO.getOrderId().toString() : null)
|
||||
@@ -810,12 +820,12 @@ public class PlanServiceImpl implements PlanService {
|
||||
.likeIfPresent("o.custom_order_no", pageReqVO.getDefaultId())
|
||||
.likeIfPresent("o.address", pageReqVO.getConsigneeAddress())
|
||||
.betweenIfPresent("o.order_date", pageReqVO.getCreateTime())
|
||||
.eqIfPresent("op.is_special_shaped", pageReqVO.getRectangle() != null ? false: null)
|
||||
.eqIfPresent("op.is_special_shaped", pageReqVO.getSpecialShaped())
|
||||
.eqIfPresent("op.is_sculpt", pageReqVO.getSculpt())
|
||||
.eqIfPresent("op.is_door", pageReqVO.getIsDoor())
|
||||
.betweenIfPresent("op.height", new BigDecimal[]{pageReqVO.getLongMinRang(), pageReqVO.getLongMaxRang()})
|
||||
.betweenIfPresent("op.width", new BigDecimal[]{pageReqVO.getWidthMinRang(), pageReqVO.getWidthMaxRang()});
|
||||
.eqIfPresent(FIELD_OP_IS_SPECIAL_SHAPED, pageReqVO.getRectangle() != null ? false: null)
|
||||
.eqIfPresent(FIELD_OP_IS_SPECIAL_SHAPED, pageReqVO.getSpecialShaped())
|
||||
.eqIfPresent(FIELD_IS_SCULPT, pageReqVO.getSculpt())
|
||||
.eqIfPresent(FIELD_IS_DOOR, pageReqVO.getIsDoor())
|
||||
.betweenIfPresent(FIELD_OP_HEIGHT, new BigDecimal[]{pageReqVO.getLongMinRang(), pageReqVO.getLongMaxRang()})
|
||||
.betweenIfPresent(FIELD_OP_WIDTH, new BigDecimal[]{pageReqVO.getWidthMinRang(), pageReqVO.getWidthMaxRang()});
|
||||
String filterTypes = "";
|
||||
if (Objects.nonNull(pageReqVO.getHoleThrough()) && pageReqVO.getHoleThrough()) {
|
||||
filterTypes += PlanFilterTypeEnum.DIGGINGTHROUGHTHESHAPE.getType().toString();
|
||||
@@ -827,7 +837,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
filterTypes += PlanFilterTypeEnum.TWODIMENSIONALCUTTINGPATH.getType().toString();
|
||||
}
|
||||
|
||||
queryWrapperX.likeIfPresent("op.filter_type", insertSeparator(filterTypes));
|
||||
queryWrapperX.likeIfPresent(FIELD_OP_FILTER_TYPE, insertSeparator(filterTypes));
|
||||
|
||||
|
||||
IPage<OrderGoodsResp> orderGoodsResps = orderMapper.selectOrderIds(page,queryWrapperX);
|
||||
@@ -925,13 +935,13 @@ public class PlanServiceImpl implements PlanService {
|
||||
queryWrapperX.eq("og.organ_id",getUserOrganId())
|
||||
.eq("og.deleted",false)
|
||||
.in("og.plan_id", vo.getPlanIds())
|
||||
.eqIfPresent("op.is_door", vo.getIsDoor())
|
||||
.eqIfPresent("op.is_special_shaped", vo.getRectangle() != null ? false: null)
|
||||
.eqIfPresent("op.is_special_shaped", vo.getSpecialShaped())
|
||||
.eqIfPresent("op.is_sculpt", vo.getSculpt())
|
||||
.betweenIfPresent("op.width", new BigDecimal[]{vo.getWidthMinRang(), vo.getWidthMaxRang()})
|
||||
.betweenIfPresent("op.height", new BigDecimal[]{vo.getLongMinRang(), vo.getLongMaxRang()})
|
||||
.likeIfPresent("op.filter_type", insertSeparator(filterTypes));
|
||||
.eqIfPresent(FIELD_IS_DOOR, vo.getIsDoor())
|
||||
.eqIfPresent(FIELD_OP_IS_SPECIAL_SHAPED, vo.getRectangle() != null ? false: null)
|
||||
.eqIfPresent(FIELD_OP_IS_SPECIAL_SHAPED, vo.getSpecialShaped())
|
||||
.eqIfPresent(FIELD_IS_SCULPT, vo.getSculpt())
|
||||
.betweenIfPresent(FIELD_OP_WIDTH, new BigDecimal[]{vo.getWidthMinRang(), vo.getWidthMaxRang()})
|
||||
.betweenIfPresent(FIELD_OP_HEIGHT, new BigDecimal[]{vo.getLongMinRang(), vo.getLongMaxRang()})
|
||||
.likeIfPresent(FIELD_OP_FILTER_TYPE, insertSeparator(filterTypes));
|
||||
|
||||
PageDTO<PlateResList> page = new PageDTO<>(vo.getPageNo(), vo.getPageSize());
|
||||
|
||||
@@ -1057,7 +1067,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
DeleteByQueryRequest.Builder builder = new DeleteByQueryRequest.Builder();
|
||||
builder.index(index);
|
||||
|
||||
builder.query(q -> q.terms(b -> b.field("planId").terms(e -> e.value(fieldValues))));
|
||||
builder.query(q -> q.terms(b -> b.field(FIELD_PLANID).terms(e -> e.value(fieldValues))));
|
||||
|
||||
try {
|
||||
DeleteByQueryResponse response = elasticsearchClient.deleteByQuery(builder.build());
|
||||
@@ -1075,7 +1085,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
SearchRequest.Builder builder = new SearchRequest.Builder();
|
||||
builder.index(index);
|
||||
builder.size(size);
|
||||
builder.query(q -> q.terms(b -> b.field("planId").terms(e -> e.value(fieldValues))));
|
||||
builder.query(q -> q.terms(b -> b.field(FIELD_PLANID).terms(e -> e.value(fieldValues))));
|
||||
try {
|
||||
SearchResponse<OptimizeBoardModelDO> search = elasticsearchClient.search(builder.build(), OptimizeBoardModelDO.class);
|
||||
List<Hit<OptimizeBoardModelDO>> hits = search.hits().hits();
|
||||
@@ -1094,7 +1104,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
SearchRequest.Builder builder = new SearchRequest.Builder();
|
||||
builder.index(index);
|
||||
builder.size(size);
|
||||
builder.query(q -> q.term(b -> b.field("planId").value(planId)));
|
||||
builder.query(q -> q.term(b -> b.field(FIELD_PLANID).value(planId)));
|
||||
try {
|
||||
SearchResponse<OptimizeBoardModelDO> search = elasticsearchClient.search(builder.build(), OptimizeBoardModelDO.class);
|
||||
List<Hit<OptimizeBoardModelDO>> hits = search.hits().hits();
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.cf.imes.module.executor.util;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 生产单新增传入文件格式转换工具
|
||||
*/
|
||||
public interface FileTypeChangeUtil {
|
||||
// 文件数据格式转换
|
||||
<T> List<?> fileDataChange(MultipartFile file) throws IOException;
|
||||
|
||||
// Api数据格式转换
|
||||
|
||||
// ds数据转换
|
||||
|
||||
// 数据转换成功判断
|
||||
boolean getFlag();
|
||||
|
||||
// 根据文件类型判断使用那种方式进行数据转换
|
||||
default <T> List<?> chooseType(MultipartFile file, String type) throws IOException {
|
||||
if (type.equals("cf_cad"))
|
||||
return fileDataChange(file);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -34,20 +34,21 @@ public class ToolUtil {
|
||||
|
||||
// 日期格式转换
|
||||
public static Map<String, Object> changeDate(String date, DateTimeFormatter formatter) {
|
||||
String errorKey = "error";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
LocalDate localDate;
|
||||
if (date == null){
|
||||
localDate = LocalDate.now();
|
||||
map.put("date", localDate);
|
||||
map.put("error", 0);
|
||||
map.put(errorKey, 0);
|
||||
}else {
|
||||
try {
|
||||
localDate = LocalDate.parse(date, formatter);
|
||||
map.put("date", localDate);
|
||||
map.put("error", 1);
|
||||
map.put(errorKey, 1);
|
||||
} catch (DateTimeParseException e) {
|
||||
map.put("date", date);
|
||||
map.put("error", -1);
|
||||
map.put(errorKey, -1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+50
-43
@@ -1,10 +1,8 @@
|
||||
package com.cf.imes.module.executor.util.fileConversion.admin.api.webcad;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import com.cf.imes.module.executor.enums.ErrorCodeConstants;
|
||||
import com.cf.imes.module.system.api.application.ApplicationApi;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@@ -37,6 +35,15 @@ public class ApiDataAchieve {
|
||||
|
||||
private static final int PARTS_PAGE_MAX = 100;
|
||||
|
||||
// 重复使用的常量
|
||||
private static final String ORDER_NO_KEY = "order_no";
|
||||
private static final String CURR_PAGE_KEY = "curr_page";
|
||||
private static final String PAGE_COUNT_KEY = "page_count";
|
||||
private static final String ERR_CODE_KEY = "err_code";
|
||||
private static final String PAGECOUNT_KEY = "PageCount";
|
||||
private static final String VALUE_KEY = "value";
|
||||
|
||||
|
||||
// 获得token数据
|
||||
public Future<JSONObject> getApiToken(Long organId) {
|
||||
JSONObject app = applicationApi.getApplicationByOrganId(organId);
|
||||
@@ -55,7 +62,7 @@ public class ApiDataAchieve {
|
||||
@Async
|
||||
public Future<JSONObject> getApiPlateProData(String token, String orderNo) {
|
||||
JSONObject jsonPlatesData = new JSONObject();
|
||||
jsonPlatesData.put("order_no", "N" + orderNo);//生产单号需要传入赋值
|
||||
jsonPlatesData.put(ORDER_NO_KEY, "N" + orderNo);//生产单号需要传入赋值
|
||||
jsonPlatesData.put("format", "json");
|
||||
JSONObject dataPlates = apiDataProduction.getApiOrderMessage(token, jsonPlatesData);
|
||||
return new AsyncResult<>(dataPlates);
|
||||
@@ -65,17 +72,17 @@ public class ApiDataAchieve {
|
||||
@Async
|
||||
public Future<JSONObject> getApiPartsMessage(String token, String orderNo) {
|
||||
JSONObject jsonParts = new JSONObject();
|
||||
jsonParts.put("curr_page", 1);
|
||||
jsonParts.put("page_count", PARTS_PAGE_MAX);
|
||||
jsonParts.put("order_no", "N" + orderNo);
|
||||
jsonParts.put(CURR_PAGE_KEY, 1);
|
||||
jsonParts.put(PAGE_COUNT_KEY, PARTS_PAGE_MAX);
|
||||
jsonParts.put(ORDER_NO_KEY, "N" + orderNo);
|
||||
JSONObject parts = apiDataProduction.getApiOrderPartsMessage(token, jsonParts);
|
||||
if (!parts.getString("err_code").equals("0")) {
|
||||
if (!parts.getString(ERR_CODE_KEY).equals("0")) {
|
||||
log.error("配件数据获取错误" + "N" + orderNo);
|
||||
throw exception(PARTS_DATA_ERROR);
|
||||
}
|
||||
JSONObject dataParts = new JSONObject();
|
||||
for (int i = 1; i <= parts.getJSONObject("value").getInteger("PageCount"); i++) {
|
||||
jsonParts.put("curr_page", i);
|
||||
for (int i = 1; i <= parts.getJSONObject(VALUE_KEY).getInteger(PAGECOUNT_KEY); i++) {
|
||||
jsonParts.put(CURR_PAGE_KEY, i);
|
||||
JSONObject value = apiDataProduction.getApiOrderPartsMessage(token, jsonParts);
|
||||
dataParts = mergeJSONObjects(dataParts, value);
|
||||
}
|
||||
@@ -86,17 +93,17 @@ public class ApiDataAchieve {
|
||||
@Async
|
||||
public Future<JSONObject> getApiBodyMessage(String token, String orderNo) {
|
||||
JSONObject jsonBody = new JSONObject();
|
||||
jsonBody.put("curr_page", 1);
|
||||
jsonBody.put("page_count", PARTS_PAGE_MAX);
|
||||
jsonBody.put("order_no", "N" + orderNo);
|
||||
jsonBody.put(CURR_PAGE_KEY, 1);
|
||||
jsonBody.put(PAGE_COUNT_KEY, PARTS_PAGE_MAX);
|
||||
jsonBody.put(ORDER_NO_KEY, "N" + orderNo);
|
||||
JSONObject body = apiDataProduction.getApiOrderBodyMessage(token, jsonBody);
|
||||
if (!body.getString("err_code").equals("0")) {
|
||||
if (!body.getString(ERR_CODE_KEY).equals("0")) {
|
||||
log.error("柜体数据获取错误" + "N" + orderNo);
|
||||
throw exception(BODY_DATA_ERROR);
|
||||
}
|
||||
JSONObject dataBody = new JSONObject();
|
||||
for (int i = 1; i <= body.getJSONObject("value").getInteger("PageCount"); i++) {
|
||||
jsonBody.put("curr_page", i);
|
||||
for (int i = 1; i <= body.getJSONObject(VALUE_KEY).getInteger(PAGECOUNT_KEY); i++) {
|
||||
jsonBody.put(CURR_PAGE_KEY, i);
|
||||
JSONObject value = apiDataProduction.getApiOrderBodyMessage(token, jsonBody);
|
||||
dataBody = mergeJSONObjects(dataBody, value);
|
||||
}
|
||||
@@ -107,17 +114,17 @@ public class ApiDataAchieve {
|
||||
@Async
|
||||
public Future<JSONObject> getApiGoodsMessage(String token, String orderNo) {
|
||||
JSONObject jsonGoods = new JSONObject();
|
||||
jsonGoods.put("curr_page", 1);
|
||||
jsonGoods.put("page_count", PARTS_PAGE_MAX);
|
||||
jsonGoods.put("order_no", "N" + orderNo);
|
||||
jsonGoods.put(CURR_PAGE_KEY, 1);
|
||||
jsonGoods.put(PAGE_COUNT_KEY, PARTS_PAGE_MAX);
|
||||
jsonGoods.put(ORDER_NO_KEY, "N" + orderNo);
|
||||
JSONObject goods = apiDataProduction.getApiOrderGoodsMessage(token, jsonGoods);
|
||||
if (!goods.getString("err_code").equals("0")) {
|
||||
if (!goods.getString(ERR_CODE_KEY).equals("0")) {
|
||||
log.error("商品信息转换失败" + "N" + orderNo);
|
||||
throw exception(GOODS_DATA_ERROR);
|
||||
}
|
||||
JSONObject dataGoods = new JSONObject();
|
||||
for (int i = 1; i <= goods.getJSONObject("value").getInteger("PageCount"); i++) {
|
||||
jsonGoods.put("curr_page", i);
|
||||
for (int i = 1; i <= goods.getJSONObject(VALUE_KEY).getInteger(PAGECOUNT_KEY); i++) {
|
||||
jsonGoods.put(CURR_PAGE_KEY, i);
|
||||
JSONObject value = apiDataProduction.getApiOrderGoodsMessage(token, jsonGoods);
|
||||
dataGoods = mergeJSONObjects(dataGoods, value);
|
||||
}
|
||||
@@ -128,17 +135,17 @@ public class ApiDataAchieve {
|
||||
@Async
|
||||
public Future<JSONObject> getApiPlateDetailMessage(String token, String orderNo) {
|
||||
JSONObject jsonPlates = new JSONObject();
|
||||
jsonPlates.put("curr_page", 1);
|
||||
jsonPlates.put("page_count", PARTS_PAGE_MAX);
|
||||
jsonPlates.put("order_no", "N" + orderNo);
|
||||
jsonPlates.put(CURR_PAGE_KEY, 1);
|
||||
jsonPlates.put(PAGE_COUNT_KEY, PARTS_PAGE_MAX);
|
||||
jsonPlates.put(ORDER_NO_KEY, "N" + orderNo);
|
||||
JSONObject plates = apiDataProduction.getApiBlocksDataMessage(token, jsonPlates);
|
||||
if (!plates.getString("err_code").equals("0")) {
|
||||
if (!plates.getString(ERR_CODE_KEY).equals("0")) {
|
||||
log.error("板材明细获取错误" + "N" + orderNo);
|
||||
throw exception(PLATE_DATA_ERROR);
|
||||
}
|
||||
JSONObject plate = new JSONObject();
|
||||
for (int i = 1; i <= plates.getJSONObject("value").getInteger("PageCount"); i++) {
|
||||
jsonPlates.put("curr_page", i);
|
||||
for (int i = 1; i <= plates.getJSONObject(VALUE_KEY).getInteger(PAGECOUNT_KEY); i++) {
|
||||
jsonPlates.put(CURR_PAGE_KEY, i);
|
||||
JSONObject value = apiDataProduction.getApiBlocksDataMessage(token, jsonPlates);
|
||||
plate = mergeJSONObjects(plate, value);
|
||||
}
|
||||
@@ -149,7 +156,7 @@ public class ApiDataAchieve {
|
||||
@Async
|
||||
public Future<JSONObject> getApiGroupMessage(String token, String orderNo) {
|
||||
JSONObject jsonModule = new JSONObject();
|
||||
jsonModule.put("order_no", "N" + orderNo);
|
||||
jsonModule.put(ORDER_NO_KEY, "N" + orderNo);
|
||||
JSONObject dataModule = apiDataProduction.getApiModuleTypeDataMessage(token, jsonModule);
|
||||
return new AsyncResult<>(dataModule);
|
||||
}
|
||||
@@ -158,16 +165,16 @@ public class ApiDataAchieve {
|
||||
@Async
|
||||
public Future<JSONObject> getApiBlocksMessage(String token, String orderNo) {
|
||||
JSONObject jsonBlocks = new JSONObject();
|
||||
jsonBlocks.put("curr_page", 1);
|
||||
jsonBlocks.put("page_count", PARTS_PAGE_MAX);
|
||||
jsonBlocks.put("order_no", "N" + orderNo);
|
||||
jsonBlocks.put(CURR_PAGE_KEY, 1);
|
||||
jsonBlocks.put(PAGE_COUNT_KEY, PARTS_PAGE_MAX);
|
||||
jsonBlocks.put(ORDER_NO_KEY, "N" + orderNo);
|
||||
JSONObject blocks = apiDataProduction.getApiBlocksMessage(token, jsonBlocks);
|
||||
if (!blocks.getString("err_code").equals("0")) {
|
||||
if (!blocks.getString(ERR_CODE_KEY).equals("0")) {
|
||||
log.error("板材数据获取错误" + "N" + orderNo);
|
||||
}
|
||||
JSONObject block = new JSONObject();
|
||||
for (int i = 1; i <= blocks.getJSONObject("value").getInteger("PageCount"); i++) {
|
||||
jsonBlocks.put("curr_page", i);
|
||||
for (int i = 1; i <= blocks.getJSONObject(VALUE_KEY).getInteger(PAGECOUNT_KEY); i++) {
|
||||
jsonBlocks.put(CURR_PAGE_KEY, i);
|
||||
JSONObject value = apiDataProduction.getApiBlocksMessage(token, jsonBlocks);
|
||||
block = mergeJSONObjects(block, value);
|
||||
}
|
||||
@@ -177,7 +184,7 @@ public class ApiDataAchieve {
|
||||
// 订单获取
|
||||
public Future<JSONObject> getApiOrder(String token, String shopId, String orderNo) {
|
||||
JSONObject jsonOrders = new JSONObject();
|
||||
jsonOrders.put("order_no", shopId + "@N" +orderNo);
|
||||
jsonOrders.put(ORDER_NO_KEY, shopId + "@N" +orderNo);
|
||||
JSONObject order = apiDataProduction.getApiOrderList(token, jsonOrders);
|
||||
return new AsyncResult<>(order);
|
||||
}
|
||||
@@ -201,24 +208,24 @@ public class ApiDataAchieve {
|
||||
jsonOrders.put("create_date_max", createDateMax + " 23:59:59");
|
||||
}
|
||||
|
||||
jsonOrders.put("curr_page", 1);
|
||||
jsonOrders.put("page_count", PARTS_PAGE_MAX);
|
||||
jsonOrders.put(CURR_PAGE_KEY, 1);
|
||||
jsonOrders.put(PAGE_COUNT_KEY, PARTS_PAGE_MAX);
|
||||
|
||||
if (orderNo != null) {
|
||||
jsonOrders.put("order_no", shopId + "@N" +orderNo);
|
||||
jsonOrders.put(ORDER_NO_KEY, shopId + "@N" +orderNo);
|
||||
}
|
||||
if (customOrderNo != null){
|
||||
jsonOrders.put("custom_order_no", customOrderNo);
|
||||
}
|
||||
|
||||
JSONObject orders = apiDataProduction.getApiOrderList(token, jsonOrders);
|
||||
if (!orders.getString("err_code").equals("0")) {
|
||||
if (!orders.getString(ERR_CODE_KEY).equals("0")) {
|
||||
throw exception(ORDER_READ_ERR);
|
||||
}
|
||||
JSONObject order = new JSONObject();
|
||||
int countPage = divideWithPlusOne(orders.getInteger("count"), PARTS_PAGE_MAX);
|
||||
for (int i = 1; i <= countPage; i++) {
|
||||
jsonOrders.put("curr_page", i);
|
||||
jsonOrders.put(CURR_PAGE_KEY, i);
|
||||
JSONObject value = apiDataProduction.getApiOrderList(token, jsonOrders);
|
||||
order = mergeData(order, value);
|
||||
}
|
||||
@@ -232,8 +239,8 @@ public class ApiDataAchieve {
|
||||
// 合并 List 属性
|
||||
JSONArray mergedList = new JSONArray();
|
||||
JSONArray list1 = null;
|
||||
if (object1.getJSONObject("value") != null) {
|
||||
list1 = object1.getJSONObject("value").getJSONArray("List");
|
||||
if (object1.getJSONObject(VALUE_KEY) != null) {
|
||||
list1 = object1.getJSONObject(VALUE_KEY).getJSONArray("List");
|
||||
if (list1 != null) {
|
||||
for (int i = 0; i < list1.size(); i++) {
|
||||
mergedList.add(list1.getJSONObject(i));
|
||||
@@ -248,7 +255,7 @@ public class ApiDataAchieve {
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONArray list2 = object2.getJSONObject("value").getJSONArray("List");
|
||||
JSONArray list2 = object2.getJSONObject(VALUE_KEY).getJSONArray("List");
|
||||
if (list2 != null) {
|
||||
for (int i = 0; i < list2.size(); i++) {
|
||||
mergedList.add(list2.getJSONObject(i));
|
||||
|
||||
+4
-1
@@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@@ -15,7 +16,9 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
@XmlRootElement(name = "Remarks")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class RemarkXmlVOS {
|
||||
public class RemarkXmlVOS implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 720894888203768497L;
|
||||
|
||||
@XmlElement(name = "Remark")
|
||||
private List<RemarkXmlVO> remarkXmlVOList;
|
||||
|
||||
+5
-1
@@ -4,10 +4,14 @@ package com.cf.imes.module.manage.controller.admin.patching.vo;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class DataRangeList {
|
||||
public class DataRangeList implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5467901878313885959L;
|
||||
|
||||
// 最大值
|
||||
private Long maxaa;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
public class ReportExceptionHandler {
|
||||
|
||||
@ExceptionHandler(value = ReportException.class)
|
||||
public CommonResult<?> reportExceptionHandler(ReportException ex) {
|
||||
public CommonResult reportExceptionHandler(ReportException ex) {
|
||||
log.warn("[reportExceptionHandler]", ex);
|
||||
return CommonResult.error(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(), String.format("报表异常:%s", ex.getMessage()));
|
||||
}
|
||||
|
||||
-3
@@ -32,9 +32,6 @@ public class SmsTemplatePageReqVO extends PageParam {
|
||||
@Schema(description = "短信 API 的模板编号,模糊匹配", example = "4383920")
|
||||
private String apiTemplateId;
|
||||
|
||||
@Schema(description = "短信渠道编号", example = "10")
|
||||
private Long channelId;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
-9
@@ -53,15 +53,6 @@ public class SmsTemplateRespVO {
|
||||
@ExcelProperty("短信 API 的模板编号")
|
||||
private String apiTemplateId;
|
||||
|
||||
@Schema(description = "短信渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@ExcelProperty("短信渠道编号")
|
||||
private Long channelId;
|
||||
|
||||
@Schema(description = "短信渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "ALIYUN")
|
||||
@ExcelProperty(value = "短信渠道编码", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.SMS_CHANNEL_CODE)
|
||||
private String channelCode;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
-4
@@ -44,8 +44,4 @@ public class SmsTemplateSaveReqVO {
|
||||
@Length(min = 1, max = 64, message = "短信 API 的模板编号长度不能超过64个字符")
|
||||
private String apiTemplateId;
|
||||
|
||||
@Schema(description = "短信渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@NotNull(message = "短信渠道编号不能为空")
|
||||
private Long channelId;
|
||||
|
||||
}
|
||||
|
||||
-1
@@ -21,7 +21,6 @@ public interface SmsTemplateMapper extends BaseMapperX<SmsTemplateDO> {
|
||||
.likeIfPresent(SmsTemplateDO::getCode, reqVO.getCode())
|
||||
.likeIfPresent(SmsTemplateDO::getContent, reqVO.getContent())
|
||||
.likeIfPresent(SmsTemplateDO::getApiTemplateId, reqVO.getApiTemplateId())
|
||||
.eqIfPresent(SmsTemplateDO::getChannelId, reqVO.getChannelId())
|
||||
.betweenIfPresent(SmsTemplateDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(SmsTemplateDO::getId));
|
||||
}
|
||||
|
||||
+7
-14
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.service.sms;
|
||||
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
@@ -30,8 +31,6 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 短信模板 Service 实现类
|
||||
*
|
||||
@@ -55,17 +54,14 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
|
||||
|
||||
@Override
|
||||
public Long createSmsTemplate(SmsTemplateSaveReqVO createReqVO) {
|
||||
// 校验短信渠道
|
||||
SmsChannelDO channelDO = validateSmsChannel(createReqVO.getChannelId());
|
||||
// 校验短信编码是否重复
|
||||
validateSmsTemplateCodeDuplicate(null, createReqVO.getCode());
|
||||
// 校验短信模板
|
||||
validateApiTemplate(createReqVO.getChannelId(), createReqVO.getApiTemplateId());
|
||||
validateApiTemplate(createReqVO.getApiTemplateId());
|
||||
|
||||
// 插入
|
||||
SmsTemplateDO template = BeanUtils.toBean(createReqVO, SmsTemplateDO.class);
|
||||
template.setParams(parseTemplateContentParams(template.getContent()));
|
||||
template.setChannelCode(channelDO.getCode());
|
||||
smsTemplateMapper.insert(template);
|
||||
// 返回
|
||||
return template.getId();
|
||||
@@ -77,17 +73,14 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
|
||||
public void updateSmsTemplate(SmsTemplateSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateSmsTemplateExists(updateReqVO.getId());
|
||||
// 校验短信渠道
|
||||
SmsChannelDO channelDO = validateSmsChannel(updateReqVO.getChannelId());
|
||||
// 校验短信编码是否重复
|
||||
validateSmsTemplateCodeDuplicate(updateReqVO.getId(), updateReqVO.getCode());
|
||||
// 校验短信模板
|
||||
validateApiTemplate(updateReqVO.getChannelId(), updateReqVO.getApiTemplateId());
|
||||
validateApiTemplate(updateReqVO.getApiTemplateId());
|
||||
|
||||
// 更新
|
||||
SmsTemplateDO updateObj = BeanUtils.toBean(updateReqVO, SmsTemplateDO.class);
|
||||
updateObj.setParams(parseTemplateContentParams(updateObj.getContent()));
|
||||
updateObj.setChannelCode(channelDO.getCode());
|
||||
smsTemplateMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@@ -159,14 +152,14 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
|
||||
/**
|
||||
* 校验 API 短信平台的模板是否有效
|
||||
*
|
||||
* @param channelId 渠道编号
|
||||
* @param apiTemplateId API 模板编号
|
||||
*/
|
||||
@VisibleForTesting
|
||||
void validateApiTemplate(Long channelId, String apiTemplateId) {
|
||||
void validateApiTemplate(String apiTemplateId) {
|
||||
// 获得短信模板
|
||||
SmsClient smsClient = smsChannelService.getSmsClient();
|
||||
Assert.notNull(smsClient, String.format("短信客户端(%d) 不存在", channelId));
|
||||
if (ObjectUtil.isNull(smsClient)) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.SMS_CHANNEL_NOT_EXISTS);
|
||||
}
|
||||
SmsTemplateRespDTO template;
|
||||
try {
|
||||
template = smsClient.getSmsTemplate(apiTemplateId);
|
||||
|
||||
+2
-17
@@ -84,14 +84,8 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest {
|
||||
o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围
|
||||
o.setType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 type 的 范围
|
||||
}).setId(null); // 防止 id 被赋值
|
||||
// mock Channel 的方法
|
||||
SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> {
|
||||
o.setId(reqVO.getChannelId());
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 保证 status 开启,创建必须处于这个状态
|
||||
});
|
||||
when(smsChannelService.getSmsChannel(eq(channelDO.getId()))).thenReturn(channelDO);
|
||||
// mock 获得 API 短信模板成功
|
||||
when(smsChannelService.getSmsClient(eq(reqVO.getChannelId()))).thenReturn(smsClient);
|
||||
when(smsChannelService.getSmsClient()).thenReturn(smsClient);
|
||||
when(smsClient.getSmsTemplate(eq(reqVO.getApiTemplateId()))).thenReturn(
|
||||
randomPojo(SmsTemplateRespDTO.class, o -> o.setAuditStatus(SmsTemplateAuditStatusEnum.SUCCESS.getStatus())));
|
||||
|
||||
@@ -103,7 +97,6 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest {
|
||||
SmsTemplateDO smsTemplate = smsTemplateMapper.selectById(smsTemplateId);
|
||||
assertPojoEquals(reqVO, smsTemplate, "id");
|
||||
assertEquals(Lists.newArrayList("operation", "code"), smsTemplate.getParams());
|
||||
assertEquals(channelDO.getCode(), smsTemplate.getChannelCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -119,14 +112,8 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest {
|
||||
o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围
|
||||
o.setType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 type 的 范围
|
||||
});
|
||||
// mock 方法
|
||||
SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> {
|
||||
o.setId(reqVO.getChannelId());
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 保证 status 开启,创建必须处于这个状态
|
||||
});
|
||||
when(smsChannelService.getSmsChannel(eq(channelDO.getId()))).thenReturn(channelDO);
|
||||
// mock 获得 API 短信模板成功
|
||||
when(smsChannelService.getSmsClient(eq(reqVO.getChannelId()))).thenReturn(smsClient);
|
||||
when(smsChannelService.getSmsClient()).thenReturn(smsClient);
|
||||
when(smsClient.getSmsTemplate(eq(reqVO.getApiTemplateId()))).thenReturn(
|
||||
randomPojo(SmsTemplateRespDTO.class, o -> o.setAuditStatus(SmsTemplateAuditStatusEnum.SUCCESS.getStatus())));
|
||||
|
||||
@@ -136,7 +123,6 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest {
|
||||
SmsTemplateDO smsTemplate = smsTemplateMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, smsTemplate);
|
||||
assertEquals(Lists.newArrayList("operation", "code"), smsTemplate.getParams());
|
||||
assertEquals(channelDO.getCode(), smsTemplate.getChannelCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -233,7 +219,6 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest {
|
||||
reqVO.setCode("tu");
|
||||
reqVO.setContent("晨丰");
|
||||
reqVO.setApiTemplateId("yu");
|
||||
reqVO.setChannelId(1L);
|
||||
reqVO.setCreateTime(buildBetweenTime(2021, 11, 1, 2021, 12, 1));
|
||||
|
||||
// 调用
|
||||
|
||||
Reference in New Issue
Block a user