From 1dcf43467f34eb70002be3c2f3cd7605ceb5dcdd Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期一, 17 二月 2025 10:18:18 +0800 Subject: [PATCH] 设备权限与车间权限 --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceGroupPermissionServiceImpl.java | 32 +++++++++++++++++--------------- 1 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceGroupPermissionServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceGroupPermissionServiceImpl.java index b790fd1..63f5d37 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceGroupPermissionServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceGroupPermissionServiceImpl.java @@ -15,8 +15,10 @@ import org.jeecg.modules.dnc.ucenter.UserDepartExt; import org.jeecg.modules.dnc.utils.ValidateUtil; import org.jeecg.modules.system.entity.MdcProduction; +import org.jeecg.modules.system.entity.MdcUserProduction; import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.dnc.service.IDeviceGroupPermissionService; +import org.jeecg.modules.system.service.IMdcUserProductionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -35,6 +37,8 @@ @Autowired @Lazy private IDevicePermissionStreamService devicePermissionStreamService; + @Autowired + private IMdcUserProductionService mdcUserProductionService; @Override public List<UserDepartExt> getUserPermsByGroupId(String groupId) { @@ -92,15 +96,13 @@ public boolean assignAddUser(MdcProduction mdcProduction, Collection<SysUser> userList) { if(mdcProduction == null || userList == null || userList.isEmpty()) ExceptionCast.cast(CommonCode.INVALID_PARAM); - List<DeviceGroupPermission> permissionList = new ArrayList<>(); + List<MdcUserProduction> mdcUserProductions=new ArrayList<>(); List<DevicePermissionStream> permissionStreamList = new ArrayList<>(); userList.forEach(item -> { - DeviceGroupPermission en = groupPermissionService.getByUserIdAndGroupId(item.getId(), mdcProduction.getId()); + MdcUserProduction en = mdcUserProductionService.getByUserIdAndGroupId(item.getId(), mdcProduction.getId()); if(en == null) { - en = new DeviceGroupPermission(); - en.setUserId(item.getId()); - en.setGroupId(mdcProduction.getId()); - permissionList.add(en); + en = new MdcUserProduction(item.getId(),mdcProduction.getId()); + mdcUserProductions.add(en); } DevicePermissionStream stream = devicePermissionStreamService.getByGroupIdAndUserId(mdcProduction.getId(), item.getId()); if(stream == null) { @@ -110,8 +112,8 @@ permissionStreamList.add(stream); } }); - if(!permissionList.isEmpty()) { - boolean b = groupPermissionService.saveBatch(permissionList); + if(!mdcUserProductions.isEmpty()) { + boolean b = mdcUserProductionService.saveBatch(mdcUserProductions); if(!b) { ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); } @@ -130,12 +132,12 @@ public boolean assignRemoveUser(MdcProduction mdcProduction, Collection<SysUser> userList) { if(mdcProduction == null || userList == null || userList.isEmpty()) ExceptionCast.cast(CommonCode.INVALID_PARAM); - List<DeviceGroupPermission> permissionList = new ArrayList<>(); + List<MdcUserProduction> mdcUserProductions=new ArrayList<>(); List<DevicePermissionStream> permissionStreamList = new ArrayList<>(); userList.forEach(item -> { - DeviceGroupPermission en = groupPermissionService.getByUserIdAndGroupId(item.getId(), mdcProduction.getId()); + MdcUserProduction en = mdcUserProductionService.getByUserIdAndGroupId(item.getId(), mdcProduction.getId()); if(en != null) { - permissionList.add(en); + mdcUserProductions.add(en); } DevicePermissionStream stream = devicePermissionStreamService.getByGroupIdAndUserId(mdcProduction.getId(), item.getId()); if(stream != null) { @@ -143,11 +145,11 @@ } }); //鏍¢獙娓呯┖璁惧鍒嗙粍鏉冮檺鎿嶄綔 - List<DeviceGroupPermission> existList = groupPermissionService.getByGroupId(mdcProduction.getId()); - if(existList.size() <= permissionList.size()) + List<MdcUserProduction> existList = mdcUserProductionService.list(new QueryWrapper<MdcUserProduction>().eq("pro_id",mdcProduction.getId())); + if(existList.size() <= mdcUserProductions.size()) ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_USER_NONE); - if(!permissionList.isEmpty()) { - boolean b = groupPermissionService.removeByCollection(permissionList); + if(!mdcUserProductions.isEmpty()) { + boolean b = mdcUserProductionService.removeByCollection(mdcUserProductions); if(!b) { ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); } -- Gitblit v1.9.3