From c6eb2d4ecd99bee148892abfbdca3e42f3dd6084 Mon Sep 17 00:00:00 2001
From: cuilei <ray_tsu1@163.com>
Date: 星期三, 07 五月 2025 18:08:07 +0800
Subject: [PATCH] 工具管理-仓库管理功能
---
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceGroupServiceImpl.java | 333 -------------------------------------------------------
1 files changed, 0 insertions(+), 333 deletions(-)
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceGroupServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceGroupServiceImpl.java
index e518cdb..539911d 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceGroupServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceGroupServiceImpl.java
@@ -37,147 +37,10 @@
@Autowired
private IDevicePermissionStreamService devicePermissionStreamService;
@Autowired
- private IDeviceGroupDepartService deviceGroupDepartService;
- @Autowired
- private IDepartmentService departmentService;
- @Autowired
@Lazy
private IDeviceInfoService deviceInfoService;
- @Autowired
- private INcLogInfoService iNcLogInfoService;
- @Override
- @Transactional(rollbackFor = {Exception.class})
- public boolean addDeviceGroup(DeviceGroup deviceGroup) {
- if(deviceGroup == null)
- ExceptionCast.cast(CommonCode.INVALID_PARAM);
- if(!ValidateUtil.validateString(deviceGroup.getGroupName()))
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NAME);
- LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
- String userId = user.getId();
- if(!ValidateUtil.validateString(userId))
- ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
- DeviceGroup en = findByGroupName(deviceGroup.getGroupName());
- if(en != null) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_EXIST);
- }
- List<DevicePermissionStream> oldDepartPermList = null;
- if (ValidateUtil.validateString(deviceGroup.getParentId())) {
- en = super.getById(deviceGroup.getParentId());
- if(en == null) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PARENT_NOT_EXIST);
- }
- deviceGroup.setRankLevel(en.getRankLevel() + 1);
- oldDepartPermList = devicePermissionStreamService.getDepartPermByGroupId(en.getGroupId());
- } else {
- deviceGroup.setParentId(null);
- deviceGroup.setRankLevel(1);
- }
- //娣诲姞鏃ュ織
- NcLogInfo ncLogInfo = new NcLogInfo();
- //妯″潡
- ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�");
- //绫诲瀷
- ncLogInfo.setOperateType(2);
- //鏃ュ織鍐呭
- ncLogInfo.setLogContent("鍒嗙粍鍚嶇О锛�"+deviceGroup.getGroupName()+"锛屽垎缁勬弿杩帮細"+deviceGroup.getDescription());
- iNcLogInfoService.saveLogNcInfos(ncLogInfo);
- boolean b = super.save(deviceGroup);
- if(!b) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_SAVE_ERROR);
- }
- if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) {
- List<DeviceGroupDepart> groupDepartList = new ArrayList<>();
- List<DevicePermissionStream> permissionStreamList = new ArrayList<>();
- oldDepartPermList.forEach(item -> {
- DeviceGroupDepart dp = new DeviceGroupDepart();
- dp.setDepartId(item.getDepartId());
- dp.setGroupId(deviceGroup.getGroupId());
- groupDepartList.add(dp);
- DevicePermissionStream stream = new DevicePermissionStream();
- stream.setDepartId(item.getDepartId());
- stream.setGroupId(deviceGroup.getGroupId());
- permissionStreamList.add(stream);
- });
- if(!groupDepartList.isEmpty()) {
- b = deviceGroupDepartService.saveBatch(groupDepartList);
- if(!b)
- ExceptionCast.cast(CommonCode.FAIL);
- }
- if(!permissionStreamList.isEmpty()) {
- b = devicePermissionStreamService.saveBatch(permissionStreamList);
- if(!b)
- ExceptionCast.cast(CommonCode.FAIL);
- }
- }
- DeviceGroupPermission permission = new DeviceGroupPermission();
- permission.setGroupId(deviceGroup.getGroupId());
- permission.setUserId(userId);
- b = groupPermissionService.save(permission);
- if(!b) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_SAVE_ERROR);
- }
- DevicePermissionStream stream = new DevicePermissionStream();
- stream.setGroupId(deviceGroup.getGroupId());
- stream.setUserId(userId);
- if (StringUtils.isNotBlank(deviceGroup.getParentId())) {
- String path = null;
- List<String> strings = findListParentTree(deviceGroup.getParentId(),null);
- if (strings != null && !strings.isEmpty()) {
- path = StringUtils.join(strings.toArray(), "/");
- }
- FileUtilS.saveFileFromPath(path + "/" + deviceGroup.getGroupName());
- } else {
- FileUtilS.saveFileFromPath(deviceGroup.getGroupName());
- }
- return devicePermissionStreamService.save(stream);
- }
- @Override
- public DeviceGroup findByGroupName(String groupName) {
- if(!ValidateUtil.validateString(groupName))
- return null;
- List<DeviceGroup> list = super.lambdaQuery().eq(DeviceGroup::getGroupName, groupName).list();
- if(list == null || list.isEmpty())
- return null;
- return list.get(0);
- }
-
- @Override
- @Transactional(rollbackFor = {Exception.class})
- public boolean editDeviceGroup(String id, DeviceGroup deviceGroup) {
- if(!ValidateUtil.validateString(id) || deviceGroup == null)
- ExceptionCast.cast(CommonCode.INVALID_PARAM);
- DeviceGroup en = super.getById(id);
- if(en == null)
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST);
- deviceGroup.setGroupId(id);
- deviceGroup.setParentId(null);
- deviceGroup.setRankLevel(null);
- if (StringUtils.isNotBlank(en.getParentId())) {
- String path = null;
- List<String> strings = findListParentTree(en.getParentId(),null);
- if (strings != null && !strings.isEmpty()) {
- path = StringUtils.join(strings.toArray(), "/");
- }
- FileUtilS.updateFileFromPath( path + "/"+ deviceGroup.getGroupName(),
- path + "/"+ en.getGroupName());
- } else {
- FileUtilS.updateFileFromPath(deviceGroup.getGroupName(),en.getGroupName());
- }
- //娣诲姞鏃ュ織
- NcLogInfo ncLogInfo = new NcLogInfo();
- //妯″潡
- ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�");
- //绫诲瀷
- ncLogInfo.setOperateType(3);
- //鏃ュ織鍐呭
- ncLogInfo.setLogContent("鍒嗙粍鍚嶇О锛�"+deviceGroup.getGroupName());
- //淇敼淇濆瓨澶囨敞
- ncLogInfo.setRemark(JSONObject.toJSONString(en));
- iNcLogInfoService.saveLogNcInfos(ncLogInfo);
- return super.updateById(deviceGroup);
- }
// 鏌ヨ鎵�浠ョ埗鑺傜偣
@Override
public List<String> findListParentTree(String parentId,List<String> stringList){
@@ -202,44 +65,6 @@
}
}
return stringList;
- }
- @Override
- @Transactional(rollbackFor = {Exception.class})
- public boolean deleteDeviceGroup(String id) {
- if(!ValidateUtil.validateString(id))
- ExceptionCast.cast(CommonCode.INVALID_PARAM);
- DeviceGroup en = super.getById(id);
- if(en == null)
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST);
- List<DeviceGroup> childList = getChildrenByParentId(id);
- if(childList != null && !childList.isEmpty())
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_CHILD_EXIST);
- List<DeviceInfo> deviceInfoList = deviceInfoService.getByGroupId(en.getGroupId());
- if(deviceInfoList != null && !deviceInfoList.isEmpty())
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_DEVICE_EXIST);
- boolean b = groupPermissionService.deleteByGroupId(en.getGroupId());
- if(!b)
- ExceptionCast.cast(CommonCode.FAIL);
- b = deviceGroupDepartService.deleteByGroupId(en.getGroupId());
- if(!b)
- ExceptionCast.cast(CommonCode.FAIL);
- b = devicePermissionStreamService.deleteUserByGroupId(en.getGroupId());
- if(!b)
- ExceptionCast.cast(CommonCode.FAIL);
- b = devicePermissionStreamService.deleteDepartByGroupId(en.getGroupId());
- if(!b)
- ExceptionCast.cast(CommonCode.FAIL);
- //鍒犻櫎瀵瑰簲鏂囦欢
- //娣诲姞鏃ュ織
- NcLogInfo ncLogInfo = new NcLogInfo();
- //妯″潡
- ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�");
- //绫诲瀷
- ncLogInfo.setOperateType(4);
- //鏃ュ織鍐呭
- ncLogInfo.setLogContent("鍒嗙粍鍚嶇О锛�"+en.getGroupName());
- iNcLogInfoService.saveLogNcInfos(ncLogInfo);
- return super.removeById(en.getGroupId());
}
@Override
@@ -352,164 +177,6 @@
ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_USER_NONE);
if(!permissionList.isEmpty()) {
boolean b = groupPermissionService.removeByCollection(permissionList);
- if(!b) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
- }
- }
- if(!permissionStreamList.isEmpty()) {
- boolean b = devicePermissionStreamService.removeByCollection(permissionStreamList);
- if(!b) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
- }
- }
- return true;
- }
-
- @Override
- public List<Department> getDepartPermsList(String groupId) {
- return deviceGroupDepartService.getDepartPermsByGroupId(groupId);
- }
-
- @Override
- public List<Department> getDepartNonPermsList(String groupId) {
- return deviceGroupDepartService.getDepartNonPermsByGroupId(groupId);
- }
-
- @Override
- @Transactional(rollbackFor = {Exception.class})
- public boolean assignAddDepartment(String groupId, Integer relativeFlag, String[] departmentIds) {
- if(!ValidateUtil.validateString(groupId) || !ValidateUtil.validateInteger(relativeFlag) || departmentIds == null || departmentIds.length < 1)
- ExceptionCast.cast(CommonCode.INVALID_PARAM);
- List<String> ids = new ArrayList<>(departmentIds.length);
- Collections.addAll(ids, departmentIds);
- Collection<Department> departmentList = departmentService.listByIds(ids);
- if(departmentList == null || departmentList.isEmpty() || departmentList.size() != departmentIds.length)
- ExceptionCast.cast(CommonCode.INVALID_PARAM);
- DeviceGroup deviceGroup = super.getById(groupId);
- if(deviceGroup == null)
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST);
- boolean b1 = deviceInfoService.checkDevicePerm(1, deviceGroup.getGroupId());
- if(!b1) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
- }
- b1 = assignAddDepartment(deviceGroup, departmentList);
- if(!b1) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
- }
- if(relativeFlag == 1) {
- //鑾峰彇鍒嗙粍涓嬫墍鏈夌殑瀛愬垎缁�
- List<DeviceGroup> childrenList = getChildrenByParentId(deviceGroup.getGroupId());
- if(childrenList != null && !childrenList.isEmpty()) {
- childrenList.forEach(item -> {
- boolean b = deviceInfoService.checkDevicePerm(1, item.getGroupId());
- if(b) {
- b = assignAddDepartment(item, departmentList);
- if(!b) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
- }
- }
- });
- }
- }
- return true;
- }
-
- @Override
- @Transactional(rollbackFor = {Exception.class})
- public boolean assignRemoveDepartment(String groupId, Integer relativeFlag, String[] departmentIds) {
- if(!ValidateUtil.validateString(groupId) || !ValidateUtil.validateInteger(relativeFlag) || departmentIds == null || departmentIds.length < 1)
- ExceptionCast.cast(CommonCode.INVALID_PARAM);
- List<String> ids = new ArrayList<>(departmentIds.length);
- Collections.addAll(ids, departmentIds);
- Collection<Department> departmentList = departmentService.listByIds(ids);
- if(departmentList == null || departmentList.isEmpty() || departmentList.size() != departmentIds.length)
- ExceptionCast.cast(CommonCode.INVALID_PARAM);
- DeviceGroup deviceGroup = super.getById(groupId);
- if(deviceGroup == null)
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST);
- boolean b1 = deviceInfoService.checkDevicePerm(1, deviceGroup.getGroupId());
- if(!b1) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
- }
- b1 = assignRemoveDepartment(deviceGroup, departmentList);
- if(!b1) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
- }
- if(relativeFlag == 1) {
- //鑾峰彇鍒嗙粍涓嬫墍鏈夌殑瀛愬垎缁�
- List<DeviceGroup> childrenList = getChildrenByParentId(deviceGroup.getGroupId());
- if(childrenList != null && !childrenList.isEmpty()) {
- childrenList.forEach(item -> {
- boolean b = deviceInfoService.checkDevicePerm(1, item.getGroupId());
- if(b) {
- b = assignRemoveDepartment(item, departmentList);
- if(!b) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
- }
- }
- });
- }
- }
- return true;
- }
-
- @Override
- @Transactional(rollbackFor = {Exception.class})
- public boolean assignAddDepartment(DeviceGroup deviceGroup, Collection<Department> departmentList) {
- if(deviceGroup == null || departmentList == null || departmentList.isEmpty())
- ExceptionCast.cast(CommonCode.INVALID_PARAM);
- List<DeviceGroupDepart> deviceGroupDepartList = new ArrayList<>();
- List<DevicePermissionStream> permissionStreamList = new ArrayList<>();
- departmentList.forEach(item -> {
- DeviceGroupDepart en = deviceGroupDepartService.getDepartByGroupAndDepartId(deviceGroup.getGroupId(), item.getDepartId());
- if(en == null) {
- en = new DeviceGroupDepart();
- en.setDepartId(item.getDepartId());
- en.setGroupId(deviceGroup.getGroupId());
- deviceGroupDepartList.add(en);
- }
- DevicePermissionStream stream = devicePermissionStreamService.getByGroupIdAndDepartId(deviceGroup.getGroupId(), item.getDepartId());
- if(stream == null) {
- stream = new DevicePermissionStream();
- stream.setDepartId(item.getDepartId());
- stream.setGroupId(deviceGroup.getGroupId());
- permissionStreamList.add(stream);
- }
- });
- if(!deviceGroupDepartList.isEmpty()) {
- boolean b = deviceGroupDepartService.saveBatch(deviceGroupDepartList);
- if(!b) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
- }
- }
- if(!permissionStreamList.isEmpty()) {
- boolean b = devicePermissionStreamService.saveBatch(permissionStreamList);
- if(!b) {
- ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
- }
- }
- return true;
- }
-
- @Override
- @Transactional(rollbackFor = {Exception.class})
- public boolean assignRemoveDepartment(DeviceGroup deviceGroup, Collection<Department> departmentList) {
- if(deviceGroup == null || departmentList == null || departmentList.isEmpty())
- ExceptionCast.cast(CommonCode.INVALID_PARAM);
- List<DeviceGroupDepart> departList = new ArrayList<>();
- List<DevicePermissionStream> permissionStreamList = new ArrayList<>();
- departmentList.forEach(item -> {
- DeviceGroupDepart en = deviceGroupDepartService.getDepartByGroupAndDepartId(deviceGroup.getGroupId(), item.getDepartId());
- if(en != null) {
- departList.add(en);
- }
- DevicePermissionStream stream = devicePermissionStreamService.getByGroupIdAndDepartId(deviceGroup.getGroupId(), item.getDepartId());
- if(stream != null) {
- permissionStreamList.add(stream);
- }
- });
- if(!departList.isEmpty()) {
- boolean b = deviceGroupDepartService.removeByCollection(departList);
if(!b) {
ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR);
}
--
Gitblit v1.9.3