mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
余料库逻辑修改,柜体删除修改1
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 192.168.1.205:8848
|
||||
username: nacos
|
||||
password: nacos
|
||||
discovery:
|
||||
@@ -18,7 +18,7 @@ spring:
|
||||
nacos:
|
||||
# Nacos Config 配置项,对应 NacosConfigProperties 配置属性类
|
||||
config:
|
||||
server-addr: 127.0.0.1:8848 # Nacos 服务器地址
|
||||
server-addr: 192.168.1.205:8848 # Nacos 服务器地址
|
||||
namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境
|
||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
||||
name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.cf.imes.module.executor.controller.admin.plan.bo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
|
||||
public class GoodsIds {
|
||||
|
||||
|
||||
@Schema(description = "大板ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "生产单ID")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "板材库的大板ID")
|
||||
private Long goodsId;
|
||||
|
||||
@Schema(description = "余料板ID")
|
||||
private Long remainId;
|
||||
|
||||
}
|
||||
+9
@@ -16,6 +16,8 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -40,6 +42,11 @@ public class OrderSource {
|
||||
@Schema(description = "排单数据")
|
||||
private PlanDO plan;
|
||||
|
||||
|
||||
@Schema(description = "大板ID列表")
|
||||
private List<GoodsIds> goodsIdList;
|
||||
|
||||
|
||||
@Schema(description = "生产单列表")
|
||||
private List<OrderDO> orderList;
|
||||
|
||||
@@ -61,4 +68,6 @@ public class OrderSource {
|
||||
private List<PrintOrderPackReqVO> orderPackReqVOS;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -32,8 +32,8 @@ public class OrderPageReqVOCopy extends PageParam {
|
||||
private String consigneeAddress;
|
||||
@Schema(description = "状态列表")
|
||||
private List<Integer> stateList;
|
||||
/*@Schema(description = "矩形")
|
||||
private Boolean rectangle;*/
|
||||
@Schema(description = "矩形")
|
||||
private Boolean rectangle;
|
||||
@Schema(description = "异形")
|
||||
private Boolean specialShaped;
|
||||
@Schema(description = "造型")
|
||||
|
||||
+3
@@ -52,6 +52,9 @@ public class PlanSaveReqVO {
|
||||
@Schema(description = "生产单id与商品id 列表",requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<Item> itemList;
|
||||
|
||||
@Schema(description = "商品数量")
|
||||
private Long goodsNum;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class PlatePage {
|
||||
@Schema(description = "生产单id")
|
||||
private Long orderId;
|
||||
@Schema(description = "商品id")
|
||||
private String goodsId;
|
||||
private Long goodsId;
|
||||
@Schema(description = "板名称")
|
||||
private String name;
|
||||
@Schema(description = "商品名称")
|
||||
|
||||
+2
-1
@@ -336,6 +336,7 @@
|
||||
|
||||
|
||||
select distinct b.id as orderId,
|
||||
c.id as goodsId,
|
||||
c.width,
|
||||
c.height,
|
||||
c.thickness,
|
||||
@@ -359,7 +360,7 @@
|
||||
#{orderIds}
|
||||
</foreach>
|
||||
|
||||
group by b.id ,c.goods_name,c.width,c.height,c.thickness, c.material, c.color;
|
||||
group by c.id,b.id ,c.goods_name,c.width,c.height,c.thickness, c.material, c.color;
|
||||
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ public class PlateDetailsRespVO {
|
||||
|
||||
@Schema(description = "排孔", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("排孔")
|
||||
private String rowHole;
|
||||
private Boolean rowHole;
|
||||
|
||||
@Schema(description = "加工组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("加工组")
|
||||
|
||||
+4
@@ -14,6 +14,10 @@ public class PackageDetailsRespVO {
|
||||
@Schema(description = "柜体名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String cabinetName;
|
||||
|
||||
|
||||
@Schema(description = "板材ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String plateId;
|
||||
|
||||
@Schema(description = "板编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String plateNo;
|
||||
|
||||
|
||||
+2
-2
@@ -22,8 +22,8 @@ public interface RemainPlateMapper extends BaseMapperX<RemainPlateDO> {
|
||||
|
||||
default PageResult<RemainPlateDO> selectPage(RemainPlatePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<RemainPlateDO>()
|
||||
.eqIfPresent(RemainPlateDO::getId, reqVO.getId())
|
||||
.eqIfPresent(RemainPlateDO::getPlanId, reqVO.getPlanId())
|
||||
.likeIfPresent(RemainPlateDO::getId,reqVO.getId() != null ? reqVO.getId().toString() : null)
|
||||
.eqIfPresent(RemainPlateDO::getPlanId, reqVO.getPlanId() != null ? reqVO.getPlanId().toString() : null)
|
||||
.eqIfPresent(RemainPlateDO::getInitPlanId, reqVO.getInitPlanId())
|
||||
.eqIfPresent(RemainPlateDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(RemainPlateDO::getGoodsId, reqVO.getGoodsId())
|
||||
|
||||
+7
-8
@@ -6,7 +6,8 @@
|
||||
<resultMap id="orderItemMap" type="com.cf.imes.module.manage.controller.admin.query.vo.pack.PackageDetailsRespVO">
|
||||
<result property="roomName" column="roomName"/>
|
||||
<result property="cabinetName" column="bodyName"/>
|
||||
<result property="plateNo" column="palteId"/>
|
||||
<result property="plateId" column="plateId"/>
|
||||
<result property="plateNo" column="plateNo"/>
|
||||
<result property="plateName" column="plateName"/>
|
||||
<result property="material" column="plateMaterial"/>
|
||||
<result property="color" column="palteColor"/>
|
||||
@@ -32,7 +33,8 @@
|
||||
og.name as name,
|
||||
ob.room_name as roomName,
|
||||
ob.name as bodyName,
|
||||
op.id as palteId,
|
||||
op.plate_no as plateNo,
|
||||
op.id as plateId,
|
||||
op.name as plateName,
|
||||
ogs.material as plateMaterial,
|
||||
ogs.color as palteColor,
|
||||
@@ -44,8 +46,7 @@
|
||||
op.remark as remark,
|
||||
op.is_special_shaped as specialShaped,
|
||||
op.is_sculpt as profiling,
|
||||
|
||||
CASE WHEN op.front_hole_count = 0 or op.back_model_count = 0 or op.side_hole_count = 0 THEN false ELSE true END AS rowHole
|
||||
op.is_row_hole as rowHole
|
||||
|
||||
from order_item oi
|
||||
join order_plate op on oi.plate_id = op.id and oi.organ_id = op.organ_id
|
||||
@@ -150,8 +151,7 @@
|
||||
op.remark as remark,
|
||||
op.is_special_shaped as specialShaped,
|
||||
op.is_sculpt as profiling,
|
||||
|
||||
CASE WHEN op.front_hole_count = 0 or op.back_model_count = 0 or op.side_hole_count = 0 THEN false ELSE true END AS rowHole
|
||||
op.is_row_hole as rowHole
|
||||
|
||||
from order_item oi
|
||||
join order_plate op on oi.plate_id = op.id and oi.organ_id = op.organ_id
|
||||
@@ -433,8 +433,7 @@
|
||||
op.remark as remark,
|
||||
op.is_special_shaped as specialShaped,
|
||||
op.is_sculpt as profiling,
|
||||
|
||||
CASE WHEN op.front_hole_count = 0 or op.back_model_count = 0 or op.side_hole_count = 0 THEN false ELSE true END AS rowHole
|
||||
op.is_row_hole as rowHole
|
||||
|
||||
from order_item oi
|
||||
join order_plate op on oi.plate_id = op.id and oi.organ_id = op.organ_id
|
||||
|
||||
+2
-1
@@ -31,7 +31,8 @@ public class ProcessApiImpl implements ProcessApi {
|
||||
|
||||
ProcessDO processDO = processMapper.selectByType(ProcessProcessingTypeEnum.COMPONENTPROCESSING.getNumber(),getUserOrganId());
|
||||
|
||||
return processDO.getPieceRate();
|
||||
|
||||
return processDO == null ? BigDecimal.ZERO : processDO.getPieceRate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -37,7 +37,7 @@ public class LabelController {
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建标签")
|
||||
//@PreAuthorize("@ss.hasPermission('system:label:create')")
|
||||
@PreAuthorize("@ss.hasPermission('sysTagDesignManager:create')")
|
||||
@OperateLog(enable = false)
|
||||
public CommonResult<Long> createLabel(@Valid @RequestBody LabelSaveReqVO createReqVO) {
|
||||
return success(labelService.createLabel(createReqVO));
|
||||
@@ -45,7 +45,7 @@ public class LabelController {
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新标签")
|
||||
//@PreAuthorize("@ss.hasPermission('system:label:update')")
|
||||
@PreAuthorize("@ss.hasPermission('sysTagDesignManager:update')")
|
||||
@OperateLog(enable = false)
|
||||
public CommonResult<Boolean> updateLabel(@Valid @RequestBody LabelSaveReqVO updateReqVO) {
|
||||
labelService.updateLabel(updateReqVO);
|
||||
@@ -55,7 +55,7 @@ public class LabelController {
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除标签")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
//@PreAuthorize("@ss.hasPermission('system:label:delete')")
|
||||
@PreAuthorize("@ss.hasPermission('sysTagDesignManager:delete')")
|
||||
public CommonResult<Boolean> deleteLabel(@RequestParam("id") Long id) {
|
||||
labelService.deleteLabel(id);
|
||||
return success(true);
|
||||
@@ -90,7 +90,7 @@ public class LabelController {
|
||||
|
||||
@GetMapping("/group-list")
|
||||
@Operation(summary = "获得分组标签列表")
|
||||
//@PreAuthorize("@ss.hasPermission('system:label:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermissions('system:label-template:query','sysTagDesignManager:query')")
|
||||
@OperateLog(enable = false)
|
||||
public CommonResult<Map<String, List<LabelRespVO>>> getGroupList(@RequestParam(value = "organId", required = false) Long organId) {
|
||||
return success(labelService.getGroupList(organId));
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ public class LabelTemplateController {
|
||||
@GetMapping("/getDefault")
|
||||
@Operation(summary = "获得默认标签模板")
|
||||
@Parameter(name = "type", description = "标签类型", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:label-template:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermissions('system:label-template:query','sysTagDesignManager:query')")
|
||||
@OperateLog(enable = false)
|
||||
public CommonResult<LabelTemplateRespVO> getDefaultLabelTemplate(@RequestParam("type") String type) {
|
||||
return success(labelTemplateService.getDefaultLabelTemplate(type));
|
||||
|
||||
+4
-4
@@ -17,10 +17,10 @@ public class UserSaveReqVO {
|
||||
@Schema(description = "用户编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "chenfeng")
|
||||
@NotBlank(message = "用户账号不能为空")
|
||||
@Pattern(regexp = "^[a-zA-Z0-9]{4,30}$", message = "用户账号由 数字、字母 组成")
|
||||
@Size(min = 4, max = 30, message = "用户账号长度为 4-30 个字符")
|
||||
@Schema(description = "a", requiredMode = Schema.RequiredMode.REQUIRED, example = "chenfeng")
|
||||
@NotBlank(message = "用户名不能为空")
|
||||
@Pattern(regexp = "^[a-zA-Z0-9]{4,30}$", message = "用户名由 数字、字母 组成")
|
||||
@Size(min = 4, max = 30, message = "用户名长度为 4-30 个字符")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰")
|
||||
|
||||
+90
-3
@@ -1,6 +1,8 @@
|
||||
package com.cf.imes.module.system.service.permission;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
|
||||
import com.cf.imes.module.system.controller.admin.permission.vo.menu.MenuListReqVO;
|
||||
@@ -8,13 +10,18 @@ import com.cf.imes.module.system.controller.admin.permission.vo.menu.MenuSaveVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.permission.MenuDO;
|
||||
import com.cf.imes.module.system.dal.mysql.permission.MenuMapper;
|
||||
import com.cf.imes.module.system.dal.redis.RedisKeyConstants;
|
||||
import com.cf.imes.module.system.dal.redis.RedisRefreshChannelTopicConstants;
|
||||
import com.cf.imes.module.system.enums.permission.MenuTypeEnum;
|
||||
import com.cf.imes.module.system.service.organ.OrganService;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -22,6 +29,7 @@ import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.framework.common.util.collection.CollectionUtils.convertList;
|
||||
@@ -44,6 +52,9 @@ public class MenuServiceImpl implements MenuService {
|
||||
@Lazy // 延迟,避免循环依赖报错
|
||||
private OrganService organService;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = RedisKeyConstants.PERMISSION_MENU_ID_LIST, key = "#createReqVO.permission",
|
||||
condition = "#createReqVO.permission != null")
|
||||
@@ -57,8 +68,13 @@ public class MenuServiceImpl implements MenuService {
|
||||
MenuDO menu = BeanUtils.toBean(createReqVO, MenuDO.class);
|
||||
initMenuProperty(menu);
|
||||
menuMapper.insert(menu);
|
||||
|
||||
Long menuId = menu.getId();
|
||||
// 清理缓存
|
||||
flushCacheWhenOperateMenu(menuId, createReqVO.getPermission(), null);
|
||||
|
||||
// 返回
|
||||
return menu.getId();
|
||||
return menuId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,7 +82,8 @@ public class MenuServiceImpl implements MenuService {
|
||||
allEntries = true) // allEntries 清空所有缓存,因为 permission 如果变更,涉及到新老两个 permission。直接清理,简单有效
|
||||
public void updateMenu(MenuSaveVO updateReqVO) {
|
||||
// 校验更新的菜单是否存在
|
||||
if (menuMapper.selectById(updateReqVO.getId()) == null) {
|
||||
MenuDO menuDO = menuMapper.selectById(updateReqVO.getId());
|
||||
if (menuDO == null) {
|
||||
throw exception(MENU_NOT_EXISTS);
|
||||
}
|
||||
// 校验父菜单存在
|
||||
@@ -78,6 +95,13 @@ public class MenuServiceImpl implements MenuService {
|
||||
MenuDO updateObj = BeanUtils.toBean(updateReqVO, MenuDO.class);
|
||||
initMenuProperty(updateObj);
|
||||
menuMapper.updateById(updateObj);
|
||||
|
||||
// 权限串发生改变清空缓存
|
||||
String oldPermission = menuDO.getPermission();
|
||||
String newPermission = updateReqVO.getPermission();
|
||||
if (ObjectUtil.notEqual(oldPermission, newPermission)) {
|
||||
flushCacheWhenOperateMenu(menuDO.getId(), newPermission, oldPermission);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,13 +114,76 @@ public class MenuServiceImpl implements MenuService {
|
||||
throw exception(MENU_EXISTS_CHILDREN);
|
||||
}
|
||||
// 校验删除的菜单是否存在
|
||||
if (menuMapper.selectById(id) == null) {
|
||||
MenuDO menuDO = menuMapper.selectById(id);
|
||||
if (menuDO == null) {
|
||||
throw exception(MENU_NOT_EXISTS);
|
||||
}
|
||||
// 标记删除
|
||||
menuMapper.deleteById(id);
|
||||
// 删除授予给角色的权限
|
||||
permissionService.processMenuDeleted(id);
|
||||
|
||||
// 清理缓存
|
||||
flushCacheWhenOperateMenu(id, null, menuDO.getPermission());
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单增删改时清理缓存
|
||||
*
|
||||
* @param menuId 菜单id
|
||||
* @param newPermission 新权限串
|
||||
* @param oldPermission 旧权限串
|
||||
*/
|
||||
private void flushCacheWhenOperateMenu(Long menuId, String newPermission, String oldPermission) {
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
Long batchDelRoleNum = scanAndDelKeys(menuRolePattern);
|
||||
log.info("[deleteMenu] 批量删除redis[{}]数量:{}", menuRolePattern, batchDelRoleNum);
|
||||
}
|
||||
|
||||
// 清空本地缓存
|
||||
redisTemplate.convertAndSend(RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, "");
|
||||
}).exceptionally(e -> {
|
||||
log.error("[deleteMenu] redis 清空PERMISSION_MENU_ID_LIST或message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, e);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* scan所有匹配的redis key并删除
|
||||
*
|
||||
* @param keyPattern 模糊匹配的表达式
|
||||
*/
|
||||
private Long scanAndDelKeys(String keyPattern) {
|
||||
// 根据keyPattern scan匹配的redis key
|
||||
List<String> delKeys = new ArrayList<>();
|
||||
Cursor<String> cursor = redisTemplate.scan(ScanOptions.scanOptions().match(keyPattern).count(200).build());
|
||||
while (cursor.hasNext()) {
|
||||
delKeys.add(cursor.next());
|
||||
}
|
||||
cursor.close();
|
||||
// 删除匹配到的key
|
||||
if (CollectionUtil.isNotEmpty(delKeys)) {
|
||||
return redisTemplate.delete(delKeys);
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+37
-13
@@ -39,7 +39,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -205,23 +207,44 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
// 角色菜单权限发生修改,通知刷新本地缓存
|
||||
if (CollectionUtil.isNotEmpty(createMenuIds) || CollectionUtil.isNotEmpty(deleteMenuIds)) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
// 当前操作人和所操作的目标菜单机构不同时,清空MENU_ROLE_ID_LIST:目标机构id:菜单id的缓存
|
||||
// 当前操作人和所操作的目标菜单机构不同时,清空MENU_ROLE_ID_LIST:*:菜单id的缓存
|
||||
if (ObjectUtil.notEqual(finalOrganId, currentOrganId)) {
|
||||
// 获取新增和删除菜单id的并集
|
||||
Collection<Long> delMenuIds = CollUtil.union(createMenuIds, deleteMenuIds);
|
||||
// 构建批量删除的key集合
|
||||
Set<String> delKeys = delMenuIds.stream().map(menuId -> String.format(String.valueOf(new StringBuffer(RedisKeyConstants.MENU_ROLE_ID_LIST).append(":%s:%s")), finalOrganId, menuId)).collect(Collectors.toSet());
|
||||
Long batchDelNum = redisTemplate.delete(delKeys);
|
||||
log.info("[assignRoleMenu] 批量删除redis[MENU_ROLE_ID_LIST]数量:{}", batchDelNum);
|
||||
delMenuIds.forEach(delMenuId -> {
|
||||
String patternKey = String.format(String.valueOf(new StringBuffer(RedisKeyConstants.MENU_ROLE_ID_LIST).append(":*:%s")), delMenuId);
|
||||
Long batchDelNum = scanAndDelKeys(patternKey);
|
||||
log.info("[assignRoleMenu] 批量删除redis[{}]数量:{}", patternKey, batchDelNum);
|
||||
});
|
||||
}
|
||||
redisTemplate.convertAndSend(RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, "");
|
||||
}).exceptionally(e -> {
|
||||
log.error("[assignRoleMenu] redis message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, e);
|
||||
log.error("[assignRoleMenu] redis 清空MENU_ROLE_ID_LIST或message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, e);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* scan所有匹配的redis key并删除
|
||||
*
|
||||
* @param keyPattern 模糊匹配的表达式
|
||||
*/
|
||||
private Long scanAndDelKeys(String keyPattern) {
|
||||
// 根据keyPattern scan匹配的redis key
|
||||
List<String> delKeys = new ArrayList<>();
|
||||
Cursor<String> cursor = redisTemplate.scan(ScanOptions.scanOptions().match(keyPattern).count(200).build());
|
||||
while (cursor.hasNext()) {
|
||||
delKeys.add(cursor.next());
|
||||
}
|
||||
cursor.close();
|
||||
// 删除匹配到的key
|
||||
if (CollectionUtil.isNotEmpty(delKeys)) {
|
||||
return redisTemplate.delete(delKeys);
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Caching(evict = {
|
||||
@@ -362,18 +385,19 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
// 角色菜单权限发生修改,通知刷新本地缓存
|
||||
if (CollectionUtil.isNotEmpty(createRoleUserIds) || CollectionUtil.isNotEmpty(deleteRoleUserIds)) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
// 当前操作人和所操作的目标菜单机构不同时,清空USER_ROLE_ID_LIST:目标机构id:用户id的缓存
|
||||
// 当前操作人和所操作的目标菜单机构不同时,清空USER_ROLE_ID_LIST:*:用户id的缓存
|
||||
if (ObjectUtil.notEqual(finalOrganId, currentOrganId)) {
|
||||
// 获取新增和删除用户id的并集
|
||||
Collection<Long> delRoleUserIds = CollUtil.union(createRoleUserIds, deleteRoleUserIds);
|
||||
// 构建批量删除的key集合
|
||||
Set<String> delKeys = delRoleUserIds.stream().map(userId -> String.format(String.valueOf(new StringBuffer(RedisKeyConstants.USER_ROLE_ID_LIST).append(":%s:%s")), finalOrganId, userId)).collect(Collectors.toSet());
|
||||
Long batchDelNum = redisTemplate.delete(delKeys);
|
||||
log.info("[batchAssignRoleUsers] 批量删除redis[USER_ROLE_ID_LIST]数量:{}", batchDelNum);
|
||||
delRoleUserIds.forEach(delRoleUserId -> {
|
||||
String patternKey = String.format(String.valueOf(new StringBuffer(RedisKeyConstants.USER_ROLE_ID_LIST).append(":*:%s")), delRoleUserId);
|
||||
Long batchDelNum = scanAndDelKeys(patternKey);
|
||||
log.info("[batchAssignRoleUsers] 批量删除redis[{}]数量:{}", patternKey, batchDelNum);
|
||||
});
|
||||
}
|
||||
redisTemplate.convertAndSend(RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, "");
|
||||
}).exceptionally(e -> {
|
||||
log.error("[batchAssignRoleUsers] redis message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, e);
|
||||
log.error("[batchAssignRoleUsers] redis 清空USER_ROLE_ID_LIST或message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, e);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
@@ -455,7 +479,7 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
redisTemplate.delete(String.format(String.valueOf(new StringBuffer(RedisKeyConstants.USER_ROLE_ID_LIST).append(":%s:%s")), organId, userId));
|
||||
redisTemplate.convertAndSend(RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, "");
|
||||
}).exceptionally(e -> {
|
||||
log.error("[assignUserRole] redis 清空USER_ROLE_ID_LIST或message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, e);
|
||||
log.error("[assignUserRole] redis message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, e);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
+3
-1
@@ -363,7 +363,9 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
||||
DataPermissionUtils.executeIgnore(() -> {
|
||||
// 校验用户的密码是否符合规则
|
||||
validatePassword(password);
|
||||
if(password != null) {
|
||||
validatePassword(password);
|
||||
}
|
||||
// 校验用户存在
|
||||
validateUserExists(id);
|
||||
// 校验用户名唯一
|
||||
|
||||
Reference in New Issue
Block a user