mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
sonarqube质量修复
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
package com.cf.imes.framework.common.core;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Key Value 的键值对
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class KeyValue<K, V> implements Serializable {
|
||||
|
||||
private K key;
|
||||
private V value;
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.framework.common.util.collection;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class MapUtils {
|
||||
consumer.accept(value);
|
||||
}
|
||||
|
||||
public static <K, V> Map<K, V> convertMap(List<KeyValue<K, V>> keyValues) {
|
||||
public static <K, V> Map<K, V> convertMap(List<Pair<K, V>> keyValues) {
|
||||
Map<K, V> map = Maps.newLinkedHashMapWithExpectedSize(keyValues.size());
|
||||
keyValues.forEach(keyValue -> map.put(keyValue.getKey(), keyValue.getValue()));
|
||||
return map;
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ public class HttpUtils {
|
||||
}
|
||||
|
||||
// 如果两者非空,则返回
|
||||
if (StrUtil.isNotEmpty(clientId) && StrUtil.isNotEmpty(clientSecret)) {
|
||||
if (CharSequenceUtil.isNotEmpty(clientId) && CharSequenceUtil.isNotEmpty(clientSecret)) {
|
||||
return new String[]{clientId, clientSecret};
|
||||
}
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class ChenfengDataSourceAutoConfiguration {
|
||||
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
|
||||
// 提取 common.js 的配置路径
|
||||
String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*";
|
||||
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
|
||||
String commonJsPattern = pattern.replace("\\*", "js/common.js");
|
||||
// 创建 DruidAdRemoveFilter Bean
|
||||
FilterRegistrationBean<DruidAdRemoveFilter> registrationBean = new FilterRegistrationBean<>();
|
||||
registrationBean.setFilter(new DruidAdRemoveFilter());
|
||||
|
||||
+2
-2
@@ -82,7 +82,7 @@ public class ChenfengCacheAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisLockUtil lockUtil(RedisTemplate<String, Object> redisTemplate, RedissonClient client) {
|
||||
return new RedisLockUtil(redisTemplate, client);
|
||||
public RedisLockUtil lockUtil(RedisTemplate<String, Object> redisTemplate) {
|
||||
return new RedisLockUtil(redisTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
-38
@@ -3,8 +3,6 @@ package com.cf.imes.framework.redis.util;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -21,42 +19,6 @@ public class RedisLockUtil {
|
||||
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
/**
|
||||
* 加锁
|
||||
*
|
||||
* @param key rediskey
|
||||
* @param timeout 锁的超时时间,传空则按照默认配置
|
||||
* @param waitTime 等待获取锁的时间,传空则按照默认配置
|
||||
* @return true拿到锁,反之没有做对应的业务提醒
|
||||
*/
|
||||
public boolean redissonLock(String key, Integer waitTime, Integer timeout) {
|
||||
boolean getLock = false;
|
||||
try {
|
||||
RLock rLock = redissonClient.getLock(key);
|
||||
return rLock.tryLock(waitTime, timeout, TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
log.error("[RedisLockUtil][lock]加锁失败", e);
|
||||
return getLock;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解锁
|
||||
* 使用注意:配合以上redisson的lock只能在当前线程中unlock,否则失败!!!
|
||||
*
|
||||
* @param key rediskey
|
||||
*/
|
||||
public void redissonReleaseLock(String key) {
|
||||
try {
|
||||
RLock rLock = redissonClient.getLock(key);
|
||||
rLock.unlock();
|
||||
} catch (Exception e) {
|
||||
log.error("[RedisLockUtil][unlock]解锁失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动set nx ex加锁
|
||||
* 使用注意:可用于跨服务
|
||||
|
||||
+7
-1
@@ -157,6 +157,9 @@ public class SecurityFrameworkUtils {
|
||||
*/
|
||||
public static boolean isSuperAdmin() {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
|
||||
}
|
||||
return ObjectUtil.isNotNull(loginUser) && loginUser.getIsSupAdmin();
|
||||
}
|
||||
|
||||
@@ -167,6 +170,9 @@ public class SecurityFrameworkUtils {
|
||||
*/
|
||||
public static boolean isManageEndPoint() {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
|
||||
}
|
||||
return Objects.equals(loginUser.getUserType(), UserTypeEnum.ADMIN.getValue());
|
||||
}
|
||||
|
||||
@@ -186,7 +192,7 @@ public class SecurityFrameworkUtils {
|
||||
*/
|
||||
public static Long getProductId() {
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
if (loginUser == null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
|
||||
}
|
||||
return loginUser.getProductId();
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.module.infra.service.logger;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
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;
|
||||
@@ -35,8 +35,8 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService {
|
||||
@Override
|
||||
public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) {
|
||||
ApiAccessLogDO apiAccessLog = BeanUtils.toBean(createDTO, ApiAccessLogDO.class);
|
||||
apiAccessLog.setRequestParams(StrUtil.maxLength(apiAccessLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
|
||||
apiAccessLog.setResultMsg(StrUtil.maxLength(apiAccessLog.getResultMsg(), RESULT_MSG_MAX_LENGTH));
|
||||
apiAccessLog.setRequestParams(CharSequenceUtil.maxLength(apiAccessLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
|
||||
apiAccessLog.setResultMsg(CharSequenceUtil.maxLength(apiAccessLog.getResultMsg(), RESULT_MSG_MAX_LENGTH));
|
||||
if (OrganContextHolder.getOrganId() != null) {
|
||||
apiAccessLogMapper.insert(apiAccessLog);
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.module.infra.service.logger;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
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;
|
||||
@@ -39,7 +39,7 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
|
||||
public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
|
||||
ApiErrorLogDO apiErrorLog = BeanUtils.toBean(createDTO, ApiErrorLogDO.class)
|
||||
.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
|
||||
apiErrorLog.setRequestParams(StrUtil.maxLength(apiErrorLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
|
||||
apiErrorLog.setRequestParams(CharSequenceUtil.maxLength(apiErrorLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
|
||||
if (OrganContextHolder.getOrganId() != null) {
|
||||
apiErrorLogMapper.insert(apiErrorLog);
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.executor.dal.mysql.planItem;
|
||||
package com.cf.imes.module.executor.dal.mysql.planitem;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
+8
-18
@@ -42,7 +42,7 @@ import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.PLATE_IMPORT_INTERRUPT_ERROR;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.PLATE_IMPORT_QUERY_INTERRUPT_ERROR;
|
||||
import static com.cf.imes.module.executor.framework.executor.config.ExecutorThreadPoolConfiguration.EXECUTOR_IMPOT_THREAD_POOL_TASK_EXECUTOR;
|
||||
@@ -89,7 +89,7 @@ public class PlateManageServiceImpl implements PlateManageService {
|
||||
public Long createPlate(PlateSaveReqVO createReqVO) {
|
||||
PlateGoodDO plate = BeanUtils.toBean(createReqVO, PlateGoodDO.class);
|
||||
|
||||
Long organId = getOrganId(BASE_PLATE_CREATE_PERMISSION, getLoginUser().getId(), plate.getOrganId());
|
||||
Long organId = getOrganId(BASE_PLATE_CREATE_PERMISSION, getLoginUserId(), plate.getOrganId());
|
||||
// 判断板材是否存在
|
||||
validateGoodExists(plate.getGoodsId(), organId);
|
||||
|
||||
@@ -106,7 +106,7 @@ public class PlateManageServiceImpl implements PlateManageService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updatePlate(PlateSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
Long organId = getOrganId(BASE_PLATE_UPDATE_PERMISSION, getLoginUser().getId(), updateReqVO.getOrganId());
|
||||
Long organId = getOrganId(BASE_PLATE_UPDATE_PERMISSION, getLoginUserId(), updateReqVO.getOrganId());
|
||||
if (updateReqVO.getId() == null) {
|
||||
throw exception(ErrorCodeConstants.PLATE_NOT_EXISTS);
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public class PlateManageServiceImpl implements PlateManageService {
|
||||
public void deletePlate(Long id, Long organId) {
|
||||
// 校验存在
|
||||
validatePlateExists(id,
|
||||
getOrganId(BASE_PLATE_DELETE_PERMISSION, getLoginUser().getId(), organId));
|
||||
getOrganId(BASE_PLATE_DELETE_PERMISSION, getLoginUserId(), organId));
|
||||
// 删除
|
||||
plateGoodMapper.deleteById(id);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class PlateManageServiceImpl implements PlateManageService {
|
||||
|
||||
@Override
|
||||
public PlateGoodDO getPlateGoods(String id) {
|
||||
Long organId = getOrganId(BASE_PLATE_QUERY_PERMISSION, getLoginUser().getId(), null);
|
||||
Long organId = getOrganId(BASE_PLATE_QUERY_PERMISSION, getLoginUserId(), null);
|
||||
return plateGoodMapper.selectByGoodID(id, organId , false);
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public class PlateManageServiceImpl implements PlateManageService {
|
||||
// pageReqVO.setOrganId(OrganContextHolder.getOrganId());
|
||||
// }
|
||||
// if (pageReqVO.getOrganId() == null || pageReqVO.getOrganId() == 0) {
|
||||
pageReqVO.setOrganId(getOrganId(BASE_PLATE_QUERY_PERMISSION, getLoginUser().getId(), pageReqVO.getOrganId()));
|
||||
pageReqVO.setOrganId(getOrganId(BASE_PLATE_QUERY_PERMISSION, getLoginUserId(), pageReqVO.getOrganId()));
|
||||
// }
|
||||
PageResult<PlateGoodDO> plateGoodDOPageResult = plateGoodMapper.selectPage(pageReqVO);
|
||||
plateGoodDOPageResult.getList().forEach(plateGoodDO -> plateGoodDO.setWidth(Objects.equals(plateGoodDO.getWidth(), ZERO) ? null : plateGoodDO.getWidth())
|
||||
@@ -204,7 +204,7 @@ public class PlateManageServiceImpl implements PlateManageService {
|
||||
@Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
|
||||
public void importPlateList(List<PlateImportExcelVO> importPlates, boolean isUpdateSupport, Long organId) {
|
||||
|
||||
organId = getOrganId(BASE_PLATE_IMPORT_PERMISSION, getLoginUser().getId(), organId);
|
||||
organId = getOrganId(BASE_PLATE_IMPORT_PERMISSION, getLoginUserId(), organId);
|
||||
|
||||
// 批量插入集合
|
||||
List<PlateGoodDO> insertList = new CopyOnWriteArrayList<>();
|
||||
@@ -364,16 +364,6 @@ public class PlateManageServiceImpl implements PlateManageService {
|
||||
return StringUtils.defaultIfEmpty(value, EMPTY_STRING);
|
||||
}
|
||||
|
||||
/**
|
||||
* value为空返回0.0
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private double getZeroDouble(Double value) {
|
||||
return ObjectUtil.defaultIfNull(value, 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* value为空返回false
|
||||
*
|
||||
@@ -400,7 +390,7 @@ public class PlateManageServiceImpl implements PlateManageService {
|
||||
@OrganIgnore
|
||||
public Set<String> getOrgPlateGoodsId(Long organId) {
|
||||
return plateGoodMapper.selectList(new LambdaQueryWrapper<PlateGoodDO>()
|
||||
.eq(PlateGoodDO::getOrganId, getOrganId(BASE_PLATE_IMPORT_PERMISSION, getLoginUser().getId(), organId))
|
||||
.eq(PlateGoodDO::getOrganId, getOrganId(BASE_PLATE_IMPORT_PERMISSION, getLoginUserId(), organId))
|
||||
.eq(PlateGoodDO::getDeleted, false)
|
||||
.select(PlateGoodDO::getGoodsId))
|
||||
.stream().map(PlateGoodDO::getGoodsId).collect(Collectors.toSet());
|
||||
|
||||
+7
-9
@@ -60,7 +60,7 @@ import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.orderGroup.OrderGroupMapper;
|
||||
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.planitem.PlanItemMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.remainplaten.RemainPlateMapper;
|
||||
@@ -165,7 +165,6 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
private static final String FIELD_SORT = " order by createTime desc ";
|
||||
private static final String FIELD_IS_OPTIMIZED = " op.is_optimized";
|
||||
private static final String FIELD_PLAN_CONFIG_ID = "planConfigId";
|
||||
private static final String FIELD_PROCESS_ID = "processId";
|
||||
private static final String FIELD_UPDATETIME = "updateTime";
|
||||
|
||||
private static final String ES_ORDER_MODEL_DATA_ERROR = "生产单板材造型信息ES文档查询数据异常: ";
|
||||
@@ -1246,8 +1245,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
|
||||
if(CharSequenceUtil.isNotBlank(goodsIdList)){
|
||||
|
||||
filterSql = " SELECT orderId,goodsId FROM " + ORDER_PLATE_MODEL.getIndex() + " WHERE "
|
||||
+ "isOptimized = false " +
|
||||
filterSql = " SELECT orderId,goodsId FROM " + ORDER_PLATE_MODEL.getIndex()
|
||||
+ " WHERE isOptimized = false " +
|
||||
"and ( orderId in ( " + orderIds + " ) and goodsId in ( " + goodsIdList + " ) )"
|
||||
+ logicalOperator
|
||||
+ config
|
||||
@@ -1255,9 +1254,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
|
||||
}else {
|
||||
|
||||
filterSql = "SELECT orderId,goodsId FROM " + ORDER_PLATE_MODEL.getIndex() + " WHERE "
|
||||
+ " " +
|
||||
" ( orderId in ( " + orderIds + "))"
|
||||
filterSql = "SELECT orderId,goodsId FROM " + ORDER_PLATE_MODEL.getIndex()
|
||||
+ " WHERE ( orderId in ( " + orderIds + "))"
|
||||
+ logicalOperator
|
||||
+ config
|
||||
+ FIELD_SORT;
|
||||
@@ -1265,8 +1263,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
}
|
||||
}else {
|
||||
|
||||
filterSql = "SELECT orderId,goodsId FROM " + ORDER_PLATE_MODEL.getIndex() + " WHERE "
|
||||
+ "isOptimized = false and "
|
||||
filterSql = "SELECT orderId,goodsId FROM " + ORDER_PLATE_MODEL.getIndex()
|
||||
+ " WHERE isOptimized = false and "
|
||||
+ config
|
||||
+ FIELD_SORT;
|
||||
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ import com.cf.imes.module.executor.dal.mysql.orderParts.PartsMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.pack.OrderPackageMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.pack.OrderPrepackagedMapper;
|
||||
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.planitem.PlanItemMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.rawgoods.RawGoodsMapper;
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.orderBody.OrderBodyMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper;
|
||||
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.planitem.PlanItemMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.remainplaten.RemainPlateMapper;
|
||||
import com.cf.imes.module.executor.enums.ErrorCodeConstants;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.cf.imes.module.executor.dal.mysql.planItem.PlanItemMapper">
|
||||
<mapper namespace="com.cf.imes.module.executor.dal.mysql.planitem.PlanItemMapper">
|
||||
|
||||
|
||||
<resultMap id="OrderPageMap" type="com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy">
|
||||
|
||||
+1
-1
@@ -799,7 +799,7 @@ public class WebCadOrderImportAsyncFactory {
|
||||
//批量保存板件
|
||||
// 达到板件数量阈值,停止入库,更新全局参数停止后续入库
|
||||
currentPlateNum += 1;
|
||||
currentPlateArea.add(BigDecimal.valueOf(area));
|
||||
currentPlateArea = currentPlateArea.add(BigDecimal.valueOf(area));
|
||||
if (currentPlateNum > cadImportPlateNumThreshold) {
|
||||
plateNumReachThreshold = true;
|
||||
return;
|
||||
|
||||
+1
-1
@@ -710,7 +710,7 @@ public class WebCadOrderImportFactory {
|
||||
//批量保存板件
|
||||
// 达到板件数量阈值,停止入库,更新全局参数停止后续入库
|
||||
currentPlateNum += 1;
|
||||
currentPlateArea.add(BigDecimal.valueOf(area));
|
||||
currentPlateArea = currentPlateArea.add(BigDecimal.valueOf(area));
|
||||
if (currentPlateNum > cadImportPlateNumThreshold) {
|
||||
plateNumReachThreshold = true;
|
||||
return;
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
package com.cf.imes.module.system.controller.admin.permission;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||
@@ -83,7 +82,7 @@ public class MenuController {
|
||||
public CommonResult<List<MenuRespVO>> getCustomMenuList() {
|
||||
List <MenuDO> list;
|
||||
LoginUser loginUser = getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
if (loginUser == null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
|
||||
}
|
||||
AdminUserDO user = userService.getUser(loginUser.getId());
|
||||
@@ -113,7 +112,7 @@ public class MenuController {
|
||||
public CommonResult<List<MenuRespVO>> getMenuList(MenuListReqVO reqVO) {
|
||||
List <MenuDO> list;
|
||||
LoginUser loginUser = getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
if (loginUser == null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.module.system.framework.sms.core.client;
|
||||
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.cf.imes.module.system.framework.sms.core.client.dto.SmsReceiveRespDTO;
|
||||
import com.cf.imes.module.system.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||
import com.cf.imes.module.system.framework.sms.core.client.dto.SmsTemplateRespDTO;
|
||||
@@ -24,7 +24,7 @@ public interface SmsClient {
|
||||
* @return 短信发送结果
|
||||
*/
|
||||
SmsSendRespDTO sendSms(Long logId, String mobile, String apiTemplateId,
|
||||
List<KeyValue<String, Object>> templateParams) throws Throwable;
|
||||
List<Pair<String, Object>> templateParams) throws Throwable;
|
||||
|
||||
/**
|
||||
* 解析接收短信的接收结果
|
||||
|
||||
+6
-5
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.framework.sms.core.client.impl.aliyun;
|
||||
|
||||
import cn.hutool.core.date.format.FastDateFormat;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
@@ -9,7 +10,6 @@ import cn.hutool.crypto.digest.DigestUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import com.cf.imes.framework.common.util.collection.MapUtils;
|
||||
import com.cf.imes.framework.common.util.http.HttpUtils;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
@@ -45,6 +45,7 @@ public class AliyunSmsClient extends AbstractSmsClient {
|
||||
private static final String URL = "https://dysmsapi.aliyuncs.com";
|
||||
private static final String HOST = "dysmsapi.aliyuncs.com";
|
||||
private static final String VERSION = "2017-05-25";
|
||||
private static final String TEMPLATECODE_KEY = "TemplateCode";
|
||||
|
||||
private static final String RESPONSE_CODE_SUCCESS = "OK";
|
||||
|
||||
@@ -56,14 +57,14 @@ public class AliyunSmsClient extends AbstractSmsClient {
|
||||
|
||||
@Override
|
||||
public SmsSendRespDTO sendSms(Long sendLogId, String mobile, String apiTemplateId,
|
||||
List<KeyValue<String, Object>> templateParams) throws Throwable {
|
||||
List<Pair<String, Object>> templateParams) throws Throwable {
|
||||
Assert.notBlank(properties.getSignature(), "短信签名不能为空");
|
||||
// 1. 执行请求
|
||||
// 参考链接 https://api.aliyun.com/document/Dysmsapi/2017-05-25/SendSms
|
||||
TreeMap<String, Object> queryParam = new TreeMap<>();
|
||||
queryParam.put("PhoneNumbers", mobile);
|
||||
queryParam.put("SignName", properties.getSignature());
|
||||
queryParam.put("TemplateCode", apiTemplateId);
|
||||
queryParam.put(TEMPLATECODE_KEY, apiTemplateId);
|
||||
queryParam.put("TemplateParam", JsonUtils.toJsonString(MapUtils.convertMap(templateParams)));
|
||||
queryParam.put("OutId", sendLogId);
|
||||
JSONObject response = request("SendSms", queryParam);
|
||||
@@ -101,7 +102,7 @@ public class AliyunSmsClient extends AbstractSmsClient {
|
||||
// 1. 执行请求
|
||||
// 参考链接 https://api.aliyun.com/document/Dysmsapi/2017-05-25/QuerySmsTemplate
|
||||
TreeMap<String, Object> queryParam = new TreeMap<>();
|
||||
queryParam.put("TemplateCode", apiTemplateId);
|
||||
queryParam.put(TEMPLATECODE_KEY, apiTemplateId);
|
||||
JSONObject response = request("QuerySmsTemplate", queryParam);
|
||||
|
||||
// 2.1 请求失败
|
||||
@@ -112,7 +113,7 @@ public class AliyunSmsClient extends AbstractSmsClient {
|
||||
}
|
||||
// 2.2 请求成功
|
||||
return new SmsTemplateRespDTO()
|
||||
.setId(response.getStr("TemplateCode"))
|
||||
.setId(response.getStr(TEMPLATECODE_KEY))
|
||||
.setContent(response.getStr("TemplateContent"))
|
||||
.setAuditStatus(convertSmsTemplateAuditStatus(response.getInt("TemplateStatus")))
|
||||
.setAuditReason(response.getStr("Reason"));
|
||||
|
||||
+2
-2
@@ -2,13 +2,13 @@ package com.cf.imes.module.system.framework.sms.core.client.impl.debug;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
import cn.hutool.crypto.digest.HmacAlgorithm;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import com.cf.imes.framework.common.util.collection.MapUtils;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.module.system.framework.sms.core.client.dto.SmsReceiveRespDTO;
|
||||
@@ -40,7 +40,7 @@ public class DebugDingTalkSmsClient extends AbstractSmsClient {
|
||||
|
||||
@Override
|
||||
public SmsSendRespDTO sendSms(Long sendLogId, String mobile,
|
||||
String apiTemplateId, List<KeyValue<String, Object>> templateParams) throws Throwable {
|
||||
String apiTemplateId, List<Pair<String, Object>> templateParams) throws Throwable {
|
||||
// 构建请求
|
||||
String url = buildUrl("robot/send");
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.module.system.mq.message.sms;
|
||||
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -37,7 +37,7 @@ public class SmsSendMessage {
|
||||
/**
|
||||
* 短信模板参数
|
||||
*/
|
||||
private List<KeyValue<String, Object>> templateParams;
|
||||
private List<Pair<String, Object>> templateParams;
|
||||
|
||||
/**
|
||||
* 短信消息模板类型:system_sms_template.type
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.module.system.mq.producer.sms;
|
||||
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.cf.imes.module.system.dal.dataobject.sms.SmsTemplateDO;
|
||||
import com.cf.imes.module.system.mq.message.sms.SmsSendMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -32,7 +32,7 @@ public class SmsProducer {
|
||||
* @param template 模板信息
|
||||
* @param templateParams 短信模板参数
|
||||
*/
|
||||
public void sendSmsSendMessage(Long logId, String mobile, SmsTemplateDO template, List<KeyValue<String, Object>> templateParams) {
|
||||
public void sendSmsSendMessage(Long logId, String mobile, SmsTemplateDO template, List<Pair<String, Object>> templateParams) {
|
||||
SmsSendMessage message = new SmsSendMessage().setLogId(logId).setMobile(mobile);
|
||||
message.setChannelId(template.getChannelId()).setApiTemplateId(template.getApiTemplateId()).setTemplateType(template.getType()).setTemplateParams(templateParams);
|
||||
// event异步发送短信,保证子线程内部request不为空
|
||||
|
||||
+9
-1
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.Assert.AssertUtils;
|
||||
import com.cf.imes.framework.common.util.date.LocalDateTimeUtils;
|
||||
@@ -222,6 +223,9 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||
public void applyInvoice(InvoiceRecordsReqVO reqVO) {
|
||||
Long organId = SecurityFrameworkUtils.getUserOrganId();
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
if (loginUser == null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
|
||||
}
|
||||
List<Long> purchaseRecordId = reqVO.getPurchaseRecordId();
|
||||
// 查询发票抬头
|
||||
InvoiceTitleInfoDO invoiceTitleInfoDO = invoiceTitleInfoMapper.selectOne(new LambdaQueryWrapper<InvoiceTitleInfoDO>()
|
||||
@@ -329,6 +333,11 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void confirmInvoice(InvoiceConfirmReqVO reqVO, MultipartFile file) throws IOException {
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
if (loginUser == null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
// 校验发票申请记录是否存在
|
||||
InvoiceRecordsDO invoiceRecordsDO = validateInvoiceExists(reqVO.getId());
|
||||
|
||||
@@ -378,7 +387,6 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||
|
||||
}
|
||||
// 更新开票人信息
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
invoiceRecordsDO.setInvoicePerson(loginUser.getNickname());
|
||||
invoiceRecordsDO.setInvoicePersonId(loginUser.getId());
|
||||
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public class ManualAdjustAccountBalanceServiceImpl implements ManualAdjustAccoun
|
||||
OrganAmountDO organAmountDO = organAmountService.validOrganAmount(organId);
|
||||
|
||||
Integer incomeExpenseType = IncomeExpenseTypeEnum.INCOME.getCode();
|
||||
OrganRechargeAmountRespVO rechargeRespVO = null;
|
||||
OrganRechargeAmountRespVO rechargeRespVO = new OrganRechargeAmountRespVO();;
|
||||
switch (AdjustTypeEnum.getByType(saveReqVO.getAdjustType())) {
|
||||
case INCREASE:
|
||||
// 调增直接累加
|
||||
|
||||
+6
-10
@@ -3,7 +3,7 @@ package com.cf.imes.module.system.service.sms;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.module.system.dal.redis.RedisKeyConstants;
|
||||
@@ -13,7 +13,6 @@ import com.cf.imes.module.system.framework.sms.core.client.dto.SmsReceiveRespDTO
|
||||
import com.cf.imes.module.system.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||
import com.cf.imes.module.system.dal.dataobject.sms.SmsTemplateDO;
|
||||
import com.cf.imes.module.system.mq.message.sms.SmsSendMessage;
|
||||
import com.cf.imes.module.system.mq.producer.sms.SmsProducer;
|
||||
import com.cf.imes.module.system.enums.ErrorCodeConstants;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -42,9 +41,6 @@ public class SmsSendServiceImpl implements SmsSendService {
|
||||
@Resource
|
||||
private SmsLogService smsLogService;
|
||||
|
||||
@Resource
|
||||
private SmsProducer smsProducer;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@@ -60,7 +56,7 @@ public class SmsSendServiceImpl implements SmsSendService {
|
||||
// 校验手机号码是否存在
|
||||
mobile = validateMobile(mobile);
|
||||
// 构建有序的模板参数。为什么放在这个位置,是提前保证模板参数的正确性,而不是到了插入发送日志
|
||||
List<KeyValue<String, Object>> newTemplateParams = buildTemplateParams(template, templateParams);
|
||||
List<Pair<String, Object>> newTemplateParams = buildTemplateParams(template, templateParams);
|
||||
|
||||
// 创建发送日志。如果模板被禁用,则不发送短信,只记录日志
|
||||
Boolean isSend = CommonStatusEnum.ENABLE.getStatus().equals(template.getStatus());
|
||||
@@ -97,13 +93,13 @@ public class SmsSendServiceImpl implements SmsSendService {
|
||||
* @return 处理后的参数
|
||||
*/
|
||||
@VisibleForTesting
|
||||
List<KeyValue<String, Object>> buildTemplateParams(SmsTemplateDO template, Map<String, Object> templateParams) {
|
||||
List<Pair<String, Object>> buildTemplateParams(SmsTemplateDO template, Map<String, Object> templateParams) {
|
||||
return template.getParams().stream().map(key -> {
|
||||
Object value = templateParams.get(key);
|
||||
if (value == null) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS, key);
|
||||
}
|
||||
return new KeyValue<>(key, value);
|
||||
return new Pair<>(key, value);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -121,7 +117,7 @@ public class SmsSendServiceImpl implements SmsSendService {
|
||||
SmsClient smsClient = smsChannelService.getSmsClient();
|
||||
Assert.notNull(smsClient, "短信客户端({}) 不存在", message.getChannelId());
|
||||
|
||||
List<KeyValue<String, Object>> templateParams = message.getTemplateParams();
|
||||
List<Pair<String, Object>> templateParams = message.getTemplateParams();
|
||||
String channelCode = null;
|
||||
// 发送短信
|
||||
try {
|
||||
@@ -130,7 +126,7 @@ public class SmsSendServiceImpl implements SmsSendService {
|
||||
channelCode = sendResponse.getChannelCode();
|
||||
// 发送成功后操作
|
||||
if (sendResponse.getSuccess()) {
|
||||
for (KeyValue<String, Object> keyValue : templateParams) {
|
||||
for (Pair<String, Object> keyValue : templateParams) {
|
||||
if ("code".equals(keyValue.getKey())) {
|
||||
redisTemplate.opsForValue().set(String.format(RedisKeyConstants.SMS_CAPTCHA_VERIFICATION, sendResponse.getMobile()), keyValue.getValue(), smsCodeProperties.getExpireTimes());
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.module.system.service.sms;
|
||||
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.enums.UserTypeEnum;
|
||||
import com.cf.imes.framework.test.core.ut.BaseRedisUnitTest;
|
||||
@@ -100,7 +100,7 @@ public class SmsSendServiceImplTest extends BaseRedisUnitTest {
|
||||
assertEquals(smsLogId, resultSmsLogId);
|
||||
// 断言调用
|
||||
verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(mobile), eq(template),
|
||||
eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login"))));
|
||||
eq(Lists.newArrayList(new Pair<>("code", "1234"), new Pair<>("op", "login"))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +192,7 @@ public class SmsSendServiceImplTest extends BaseRedisUnitTest {
|
||||
// 准备参数
|
||||
SmsSendMessage message = randomPojo(SmsSendMessage.class);
|
||||
message.setMobile("15601691300");
|
||||
message.setTemplateParams(List.of(new KeyValue<>("code", "123456")));
|
||||
message.setTemplateParams(List.of(new Pair<>("code", "123456")));
|
||||
// mock SmsClientFactory 的方法
|
||||
SmsClient smsClient = mock(SmsClient.class);
|
||||
when(smsChannelService.getSmsClient()).thenReturn(smsClient);
|
||||
@@ -221,7 +221,7 @@ public class SmsSendServiceImplTest extends BaseRedisUnitTest {
|
||||
@Test
|
||||
void testDoSendSms_fail() throws Throwable {
|
||||
SmsSendMessage message = randomPojo(SmsSendMessage.class);
|
||||
message.setTemplateParams(List.of(new KeyValue<>("code", "999999")));
|
||||
message.setTemplateParams(List.of(new Pair<>("code", "999999")));
|
||||
// mock SmsClientFactory 的方法
|
||||
SmsClient smsClient = spy(SmsClient.class);
|
||||
when(smsChannelService.getSmsClient()).thenReturn(smsClient);
|
||||
|
||||
Reference in New Issue
Block a user