Merge branch 'main' of ssh://192.168.1.205:9922/cf_devdept2/cf_imes_server

This commit is contained in:
lym
2024-10-30 10:56:02 +08:00
15 changed files with 138 additions and 166 deletions
@@ -226,7 +226,7 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
processOtherFromItem((FromItem) where);
return;
}
if (where.toString().indexOf("SELECT") > 0) {
if (where.toString().indexOf("SELECT") >= 1) {
// 有子查询
if (where instanceof BinaryExpression) {
// 比较符号 , and , or , 等等
@@ -167,39 +167,13 @@ public class OperateLogAspect {
ProceedingJoinPoint joinPoint,
com.cf.imes.framework.operatelog.core.annotations.OperateLog operateLog,
Operation operation) {
// module 属性
if (operateLog != null) {
operateLogObj.setModule(operateLog.module());
}
if (CharSequenceUtil.isEmpty(operateLogObj.getModule())) {
Tag tag = getClassAnnotation(joinPoint, Tag.class);
if (tag != null) {
// 优先读取 @Tag 的 name 属性
if (CharSequenceUtil.isNotEmpty(tag.name())) {
operateLogObj.setModule(tag.name());
}
// 没有的话,读取 @API 的 description 属性
if (CharSequenceUtil.isEmpty(operateLogObj.getModule()) && ArrayUtil.isNotEmpty(tag.description())) {
operateLogObj.setModule(tag.description());
}
}
}
// name 属性
if (operateLog != null) {
operateLogObj.setName(operateLog.name());
}
if (CharSequenceUtil.isEmpty(operateLogObj.getName()) && operation != null) {
operateLogObj.setName(operation.summary());
}
// type 属性
if (operateLog != null && ArrayUtil.isNotEmpty(operateLog.type())) {
operateLogObj.setType(operateLog.type()[0].getType());
}
if (operateLogObj.getType() == null) {
RequestMethod requestMethod = obtainFirstMatchRequestMethod(obtainRequestMethod(joinPoint));
OperateTypeEnum operateLogType = convertOperateLogType(requestMethod);
operateLogObj.setType(operateLogType != null ? operateLogType.getType() : null);
}
setModule(operateLogObj, joinPoint, operateLog);
setName(operateLogObj, operateLog, operation);
setType(operateLogObj, joinPoint, operateLog);
// content 和 exts 属性
operateLogObj.setContent(CONTENT.get());
operateLogObj.setExts(EXTS.get());
@@ -371,4 +345,61 @@ public class OperateLogAspect {
|| object instanceof BindingResult;
}
// module 属性
private static void setModule(OperateLog operateLogObj, ProceedingJoinPoint joinPoint,
com.cf.imes.framework.operatelog.core.annotations.OperateLog operateLog) {
if (operateLog != null) {
operateLogObj.setModule(operateLog.module());
}
if (CharSequenceUtil.isEmpty(operateLogObj.getModule())) {
Tag tag = getClassAnnotation(joinPoint, Tag.class);
if (tag != null) {
// 优先读取 @Tag 的 name 属性
if (CharSequenceUtil.isNotEmpty(tag.name())) {
operateLogObj.setModule(tag.name());
}
// 没有的话,读取 @API 的 description 属性
if (CharSequenceUtil.isEmpty(operateLogObj.getModule()) && ArrayUtil.isNotEmpty(tag.description())) {
operateLogObj.setModule(tag.description());
}
}
}
}
// name 属性
private static void setName(OperateLog operateLogObj,
com.cf.imes.framework.operatelog.core.annotations.OperateLog operateLog,
Operation operation) {
if (operateLog != null) {
operateLogObj.setName(operateLog.name());
}
if (CharSequenceUtil.isEmpty(operateLogObj.getName()) && operation != null) {
operateLogObj.setName(operation.summary());
}
}
// type 属性
private static void setType(OperateLog operateLogObj,
ProceedingJoinPoint joinPoint,
com.cf.imes.framework.operatelog.core.annotations.OperateLog operateLog) {
if (operateLog != null && ArrayUtil.isNotEmpty(operateLog.type())) {
operateLogObj.setType(operateLog.type()[0].getType());
}
if (operateLogObj.getType() == null) {
RequestMethod requestMethod = obtainFirstMatchRequestMethod(obtainRequestMethod(joinPoint));
OperateTypeEnum operateLogType = convertOperateLogType(requestMethod);
operateLogObj.setType(operateLogType != null ? operateLogType.getType() : null);
}
}
}
@@ -9,6 +9,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.io.Serial;
/**
* XSS 过滤 jackson 反序列化器。
@@ -55,5 +56,19 @@ public class XssStringJsonDeserializer extends StringDeserializer {
}
return (String) ctxt.handleUnexpectedToken(_valueClass, p);
}
@Serial
private void writeObject(java.io.ObjectOutputStream stream)
throws IOException {
stream.defaultWriteObject();
}
@Serial
private void readObject(java.io.ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
}
}
@@ -123,12 +123,12 @@ public class OptimizationSavePlateReqVO {
@Schema(description = "备注1")
@Length(max = 127, message = "备注长度不能超过 127 个字符")
@Length(max = 127, message = "备注1长度不能超过 127 个字符")
private String remake1;
@Schema(description = "备注2")
@Length(max = 127, message = "备注长度不能超过 127 个字符")
@Length(max = 127, message = "备注2长度不能超过 127 个字符")
private String remake2;
}
@@ -18,6 +18,7 @@ import com.cf.imes.module.executor.controller.admin.plan.bo.OrderIds;
import com.cf.imes.module.executor.controller.admin.plan.vo.OrderGoodsResp;
import com.cf.imes.module.executor.controller.admin.plan.vo.OrderPageReqVOCopy;
import com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy;
import com.cf.imes.module.executor.controller.admin.plan.vo.PlanOrderRespVO;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.enums.OrderDeletedEnum;
import com.cf.imes.module.executor.enums.OrderStatusEnum;
@@ -280,4 +281,5 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
}
List<PlanOrderRespVO> selectPlanOrderList(@Param("planIds") List<Long> planIds, @Param("organId") Long organId);
}
@@ -37,7 +37,6 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
.eqIfPresent(PlanDO::getSort, reqVO.getSort())
.eqIfPresent(PlanDO::getType, reqVO.getType())
.eqIfPresent(PlanDO::getStatus, reqVO.getStatus())
// .eqIfPresent(PlanDO::getIsPay, reqVO.getIsPay())
.eqIfPresent(PlanDO::getMachineId, reqVO.getMachineId())
.betweenIfPresent(PlanDO::getPlanTime, reqVO.getPlanTime())
.likeIfPresent(PlanDO::getOrderNos, reqVO.getOrderNos())
@@ -45,14 +44,11 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
.betweenIfPresent(PlanDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PlanDO::getOperator, reqVO.getOperator())
.betweenIfPresent(PlanDO::getProduceTime, reqVO.getProduceTime())
// todo 如果后续生产单加入排单状态,这里可以更改只连 orders 表
.leftJoin(GoodsDO.class, GoodsDO::getPlanId, PlanDO::getId)
// .leftJoin(OrderItemDO.class, OrderItemDO::getId, PlanItemDO::getItemId)
.leftJoin(OrderDO.class, OrderDO::getId, GoodsDO::getOrderId)
.like(OrderDO::getCustomer, reqVO.getCustomer())
// .orderBy(true, true, PlanDO::getSort)
.orderByDesc(PlanDO::getCreateTime)
.distinct()
);
}
@@ -63,7 +59,6 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
.eqIfPresent(PlanDO::getSort, reqVO.getSort())
.eqIfPresent(PlanDO::getType, reqVO.getType())
.eqIfPresent(PlanDO::getStatus, reqVO.getStatus())
// .eqIfPresent(PlanDO::getIsPay, reqVO.getIsPay())
.eqIfPresent(PlanDO::getMachineId, reqVO.getMachineId())
.betweenIfPresent(PlanDO::getPlanTime, reqVO.getPlanTime())
.likeIfPresent(PlanDO::getOrderNos, reqVO.getOrderNos())
@@ -71,7 +66,6 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
.betweenIfPresent(PlanDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PlanDO::getOperator, reqVO.getOperator())
.betweenIfPresent(PlanDO::getProduceTime, reqVO.getProduceTime())
// .orderBy(true, true, PlanDO::getSort)
.orderByDesc(PlanDO::getCreateTime));
}
@@ -124,7 +118,4 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
// List<PlanDO> seleTestSQL(@Param("sql") String sql);
}
@@ -1,12 +1,8 @@
package com.cf.imes.module.executor.dal.mysql.planitem;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.module.executor.controller.admin.plan.vo.PlanOrderRespVO;
import com.cf.imes.module.executor.dal.dataobject.planitem.PlanItemDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 生产单开料排单明细 Mapper
@@ -17,6 +13,4 @@ import java.util.List;
public interface PlanItemMapper extends BaseMapperX<PlanItemDO> {
List<PlanOrderRespVO> selectOrderList(@Param("planIds") List<Long> planIds, @Param("organId") Long userOrganId);
}
@@ -389,7 +389,6 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
}
// todo 待确认,是否要达到这样的需求 : 生产单的状态也应该更改,如果大板变为未开料,生产单对应的状态应该变为已排单(这时取消开料对应的大板对应的生产单应该在其他排单中不存在,可修改)
}
@@ -301,17 +301,6 @@ public class OrderServiceImpl implements OrderService {
AssertUtils.notEmpty(orderDO,ORDER_NOT_EXISTS);
// List<Long> bodyIds = new ArrayList<>();
//
// Integer index = status == 1 ? 0 : 1;
//
// if (roomIds != null && !roomIds.isEmpty()) {
// bodyIds = orderBodyMapper.selectBodyIdByRoomId(orderId, roomIds, getUserOrganId(), index);
// } else if (bodyId != null && bodyId != 0) {
// validateOrderBodyExists(orderId, bodyId, getUserOrganId(), roomIds,index);
// bodyIds.add(bodyId);
// }
List<Long> bodyIds = validateOrderBodyExists(orderId, bodyId, getUserOrganId(), roomIds, OrderDeletedEnum.DELETED.getStatus());
@@ -289,69 +289,9 @@ public class PlanServiceImpl implements PlanService {
planMapper.updateById(plan);
// // todo 目前只解决非混单的情况,混单的情况待解决,这个逻辑目前应该不用(这个逻辑用于判断大板下的小板是否开料,后期应该可用于混单时增加的判断),排单是否开料判断了,可保留,万一以后需求更改
// if(!updateReqVO.getItemList().isEmpty()){
//
// List<OptimizeBoardModelDO> optimizeBoardModelDOS = buildBoardByPlanId(plan.getId(), ORDER_REMAIN_PLATE_MODEL, 10);
//
// OptimizeBoardModelDO optimizeBoardModelDO = optimizeBoardModelDOS.get(0);
//
// List<Long> goodsNo = optimizeBoardModelDO.getCutedBoardInfo().getCutedBoardList();
//
// List<Long> plateNo = new ArrayList<>();
//
// // 创建一个列表存储 BlockPlaceInfo 对象,将优化的小板信息拿出,获取到小板编号,查询生产单,修改生产单的状态
// List<BlockPlaceInfo> outputList = new ArrayList<>();
//
// ObjectMapper mapper = new ObjectMapper();
//
// try {
// // 解析 JSON 字符串
// JsonNode jsonArray = mapper.readTree(optimizeBoardModelDO.getBlockPlaceInfo());
//
// // 遍历 JSON 数组并提取所需字段
// if (jsonArray.isArray()) {
// for (JsonNode jsonNode : jsonArray) {
// Long bi = jsonNode.get("bi").asLong();
// Long bo = jsonNode.get("bo").asLong();
// outputList.add(new BlockPlaceInfo(bi,bo));
// }
// }
// } catch (JsonProcessingException e) {
// e.printStackTrace();
// }
//
// for (Long goods : goodsNo) {
// plateNo.addAll(outputList.stream().filter(f -> f.getBi().equals(goods)).map(BlockPlaceInfo::getBo).distinct().toList());
// }
//
// if(updateReqVO.getDeleteIds() != null) {
//
// List<PlateDO> plateDOS = plateMapper.selectPlateListByGoodsIds(updateReqVO.getDeleteIds(), getUserOrganId());
//
// List<Long> deletePlateNos = plateDOS.stream().map(PlateDO::getPlateNo).map(Long::valueOf).toList();
//
// List<Long> plateNoCopyList = new ArrayList<>(plateNo);
//
// // 使用retainAll方法保留 plateNo 中与 deletePlateNos 相同的元素
// plateNoCopyList.retainAll(deletePlateNos);
//
// // 如果 plateNoCopyList 不为空,说明两个List有共同的元素
// boolean b = !plateNoCopyList.isEmpty();
//
// if (b) {
//
// throw exception(THE_BOARD_HAS_BEEN_CUT_INTO_PIECES);
//
// }
//
// }
// }
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deletePlan(List<Long> ids) {
@@ -510,7 +450,7 @@ public class PlanServiceImpl implements PlanService {
// 获取排单对应的生产单的信息
List<PlanOrderRespVO> planOrderRespVOS = planItemMapper.selectOrderList(planIds, getUserOrganId());
List<PlanOrderRespVO> planOrderRespVOS = orderMapper.selectPlanOrderList(planIds, getUserOrganId());
PageResult<PlanRespVO> planRespVOPageResult = BeanUtils.toBean(planDOPageResult, PlanRespVO.class);
@@ -285,4 +285,36 @@
</select>
<select id="selectPlanOrderList"
resultType="com.cf.imes.module.executor.controller.admin.plan.vo.PlanOrderRespVO">
select distinct
o.id,
og.plan_id,
o.order_date,
o.delivery_date,
o.custom_order_no,
o.customer,
o.address,
o.phone_number,
o.salesman,
o.splitter,
o.remark
from orders o
left join order_goods og on o.organ_id = og.organ_id and o.id = og.order_id
where og.organ_id = #{organId}
and og.deleted = false
and og.plan_id in
<foreach collection="planIds" item="ids" open="(" close=")" separator=",">
#{ids}
</foreach>
</select>
</mapper>
@@ -5,36 +5,5 @@
<select id="selectOrderList"
resultType="com.cf.imes.module.executor.controller.admin.plan.vo.PlanOrderRespVO">
select distinct
o.id,
og.plan_id,
o.order_date,
o.delivery_date,
o.custom_order_no,
o.customer,
o.address,
o.phone_number,
o.salesman,
o.splitter,
o.remark
from orders o
left join order_goods og on o.organ_id = og.organ_id and o.id = og.order_id
where og.organ_id = #{organId}
and og.plan_id in
<foreach collection="planIds" item="ids" open="(" close=")" separator=",">
#{ids}
</foreach>
</select>
</mapper>
@@ -54,6 +54,9 @@ public class MenuServiceImpl implements MenuService {
@Autowired
private RedisTemplate redisTemplate;
private static final String FIELD_CHARACTER = ":*:%s";
@Override
@CacheEvict(value = RedisKeyConstants.PERMISSION_MENU_ID_LIST, key = "#createReqVO.permission",
condition = "#createReqVO.permission != null")
@@ -137,21 +140,21 @@ public class MenuServiceImpl implements MenuService {
CompletableFuture.runAsync(() -> {
if (ObjectUtil.isNotNull(oldPermission)) {
// 移除 USER_ROLE_ID_LIST:*:旧的permission
String oldMenuPerPattern = String.format(String.valueOf(new StringBuffer(RedisKeyConstants.PERMISSION_MENU_ID_LIST).append(":*:%s")), oldPermission);
String oldMenuPerPattern = String.format(String.valueOf(new StringBuffer(RedisKeyConstants.PERMISSION_MENU_ID_LIST).append(FIELD_CHARACTER)), oldPermission);
Long oldBatchDelPerNum = scanAndDelKeys(oldMenuPerPattern);
log.info("[updateMenu] 批量删除redis[{}]数量:{}", oldMenuPerPattern, oldBatchDelPerNum);
}
if (ObjectUtil.isNotNull(newPermission)) {
// 移除 USER_ROLE_ID_LIST:*:新的permission
String newMenuPerPattern = String.format(String.valueOf(new StringBuffer(RedisKeyConstants.PERMISSION_MENU_ID_LIST).append(":*:%s")), newPermission);
String newMenuPerPattern = String.format(String.valueOf(new StringBuffer(RedisKeyConstants.PERMISSION_MENU_ID_LIST).append(FIELD_CHARACTER)), newPermission);
Long newBatchDelPerNum = scanAndDelKeys(newMenuPerPattern);
log.info("[updateMenu] 批量删除redis[{}]数量:{}", newMenuPerPattern, newBatchDelPerNum);
}
if (ObjectUtil.isNotNull(menuId)) {
// 移除 MENU_ROLE_ID_LIST:*:menuId
String menuRolePattern = String.format(String.valueOf(new StringBuffer(RedisKeyConstants.MENU_ROLE_ID_LIST).append(":*:%s")), menuId);
String menuRolePattern = String.format(String.valueOf(new StringBuffer(RedisKeyConstants.MENU_ROLE_ID_LIST).append(FIELD_CHARACTER)), menuId);
Long batchDelRoleNum = scanAndDelKeys(menuRolePattern);
log.info("[deleteMenu] 批量删除redis[{}]数量:{}", menuRolePattern, batchDelRoleNum);
}
@@ -46,6 +46,9 @@ public class SocialUserServiceImpl implements SocialUserService {
@Resource
private SocialClientService socialClientService;
private static final String FIELD_SOCIAL = "社交用户不能为空";
@Override
public List<SocialUserDO> getSocialUserList(Long userId, Integer userType) {
// 获得绑定
@@ -63,7 +66,7 @@ public class SocialUserServiceImpl implements SocialUserService {
// 获得社交用户
SocialUserDO socialUser = authSocialUser(reqDTO.getSocialType(), reqDTO.getUserType(),
reqDTO.getCode(), reqDTO.getState());
Assert.notNull(socialUser, "社交用户不能为空");
Assert.notNull(socialUser, FIELD_SOCIAL);
// 社交用户可能之前绑定过别的用户,需要进行解绑
socialUserBindMapper.deleteByUserTypeAndSocialUserId(reqDTO.getUserType(), socialUser.getId());
@@ -101,7 +104,7 @@ public class SocialUserServiceImpl implements SocialUserService {
}
// 获得社交用户
SocialUserDO socialUser = socialUserMapper.selectById(socialUserBind.getSocialUserId());
Assert.notNull(socialUser, "社交用户不能为空");
Assert.notNull(socialUser, FIELD_SOCIAL);
return new SocialUserRespDTO(socialUser.getOpenid(), socialUser.getNickname(), socialUser.getAvatar(),
socialUserBind.getUserId());
}
@@ -110,7 +113,7 @@ public class SocialUserServiceImpl implements SocialUserService {
public SocialUserRespDTO getSocialUserByCode(Integer userType, Integer socialType, String code, String state) {
// 获得社交用户
SocialUserDO socialUser = authSocialUser(socialType, userType, code, state);
Assert.notNull(socialUser, "社交用户不能为空");
Assert.notNull(socialUser, FIELD_SOCIAL);
// 获得绑定用户
SocialUserBindDO socialUserBind = socialUserBindMapper.selectByUserTypeAndSocialUserId(userType,
@@ -17,6 +17,10 @@ import java.util.*;
*/
public class OAuth2Utils {
private static final String FIELD_STATE = "state";
/**
* 构建授权码模式下,重定向的 URI
*
@@ -31,7 +35,7 @@ public class OAuth2Utils {
Map<String, String> query = new LinkedHashMap<>();
query.put("code", authorizationCode);
if (state != null) {
query.put("state", state);
query.put(FIELD_STATE, state);
}
return HttpUtils.append(redirectUri, query, null, false);
}
@@ -56,7 +60,7 @@ public class OAuth2Utils {
vars.put("access_token", accessToken);
vars.put("token_type", SecurityFrameworkUtils.AUTHORIZATION_BEARER.toLowerCase());
if (state != null) {
vars.put("state", state);
vars.put(FIELD_STATE, state);
}
if (expireTime != null) {
vars.put("expires_in", getExpiresIn(expireTime));
@@ -83,7 +87,7 @@ public class OAuth2Utils {
query.put("error", error);
query.put("error_description", description);
if (state != null) {
query.put("state", state);
query.put(FIELD_STATE, state);
}
return HttpUtils.append(redirectUri, query, null, !responseType.contains("code"));
}