From f2f8241dd52ef12ec109f6f4f0f13042055338ac Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期五, 14 二月 2025 14:55:56 +0800 Subject: [PATCH] 修改指派设备 修改设备结构树权限 优化查询 优化排序 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java | 101 ++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 85 insertions(+), 16 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java index ad9d45f..84ee56f 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java @@ -1,20 +1,24 @@ package org.jeecg.modules.mdc.service.impl; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.dto.message.MessageDTO; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.system.api.ISysBaseAPI; +import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.mdc.dto.MdcEquDepDto; import org.jeecg.modules.mdc.dto.MdcEquProDto; import org.jeecg.modules.mdc.dto.MdcEquipmentDetailedDto; import org.jeecg.modules.mdc.dto.MdcEquipmentDto; import org.jeecg.modules.mdc.entity.*; +import org.jeecg.modules.mdc.mapper.DncDevicePermissionMapper; import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper; import org.jeecg.modules.mdc.mapper.MdcTorqueConfigMapper; import org.jeecg.modules.mdc.model.MdcEquipmentTree; @@ -23,16 +27,11 @@ import org.jeecg.modules.mdc.util.FindsEquipmentDepartUtil; import org.jeecg.modules.mdc.util.FindsEquipmentProductionUtil; import org.jeecg.modules.mdc.vo.*; -import org.jeecg.modules.system.entity.MdcEquipmentDepart; -import org.jeecg.modules.system.entity.MdcProduction; -import org.jeecg.modules.system.entity.MdcProductionEquipment; -import org.jeecg.modules.system.entity.SysDepart; +import org.jeecg.modules.system.entity.*; import org.jeecg.modules.system.mapper.MdcEquipmentDepartMapper; import org.jeecg.modules.system.mapper.MdcProductionEquipmentMapper; -import org.jeecg.modules.system.service.IMdcProductionService; -import org.jeecg.modules.system.service.IMdcUserProductionService; -import org.jeecg.modules.system.service.ISysDepartService; -import org.jeecg.modules.system.service.ISysUserDepartService; +import org.jeecg.modules.system.service.*; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -93,6 +92,12 @@ @Resource private IMdcOverrunAlarmService mdcOverrunAlarmService; + @Resource + private ISysParamsService ISysParamsService; + + @Resource + private DncDevicePermissionMapper dncDevicePermissionMapper; + @Override public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) { @@ -113,8 +118,40 @@ @Override @Transactional(rollbackFor = Exception.class) public void saveMdcEquipment(MdcEquipment mdcEquipment, String selectedDeparts, String selectedProduction) { + if (mdcEquipment.getSystemValue()!=null) { + switch (mdcEquipment.getSystemValue()){ + case "1": + mdcEquipment.setDeviceTypeDnc("1"); + break; + case "2": + mdcEquipment.setDeviceTypeMdc("1"); + break; + case "3": + mdcEquipment.setDeviceTypeDnc("1"); + mdcEquipment.setDeviceTypeMdc("1"); + break; + } + }else { + //鑾峰彇绯荤粺绫诲瀷 + SysParams sysParams = ISysParamsService.getSysPramBySettingKey("system_type"); + //MDC绯荤粺 + if ("-1".equals(sysParams.getSettingValue())){ + mdcEquipment.setDeviceTypeMdc("1"); + } + //DNC绯荤粺 + if ("1".equals(sysParams.getSettingValue())) { + mdcEquipment.setDeviceTypeDnc("1"); + } + } //step.1 淇濆瓨璁惧 this.save(mdcEquipment); + //DNC娣诲姞璁惧鏉冮檺 + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = user.getId(); + DncDevicePermission dncDevicePermission=new DncDevicePermission(); + dncDevicePermission.setDeviceId(mdcEquipment.getId()); + dncDevicePermission.setUserId(userId); + dncDevicePermissionMapper.insert(dncDevicePermission); //step.2 淇濆瓨鎵�灞為儴闂� if (oConvertUtils.isNotEmpty(selectedDeparts)) { String[] arr = selectedDeparts.split(","); @@ -137,6 +174,22 @@ @Transactional(rollbackFor = Exception.class) @CacheEvict(value = {"mdc:cache:encrypt:equipment"}, allEntries = true) public void editMdcEquipment(MdcEquipment mdcEquipment) { + if (mdcEquipment.getSystemValue()!=null) { + switch (mdcEquipment.getSystemValue()){ + case "1": + mdcEquipment.setDeviceTypeDnc("1"); + mdcEquipment.setDeviceTypeMdc("0"); + break; + case "2": + mdcEquipment.setDeviceTypeDnc("0"); + mdcEquipment.setDeviceTypeMdc("1"); + break; + case "3": + mdcEquipment.setDeviceTypeDnc("1"); + mdcEquipment.setDeviceTypeMdc("1"); + break; + } + } //step.1 淇敼璁惧鍩虹淇℃伅 this.updateById(mdcEquipment); //step.2 淇敼閮ㄩ棬 @@ -260,6 +313,7 @@ if (equipmentList != null && !equipmentList.isEmpty()) { for (MdcEquipment mdcEquipment : equipmentList) { MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment); + tree.setParentId(mdcEquipmentTree.getKey()); mdcEquipmentTree.getChildren().add(tree); } @@ -293,7 +347,7 @@ @Override - public List<MdcEquipmentTree> loadTreeListByProduction(String userId) { + public List<MdcEquipmentTree> loadTreeListByProduction(String userId,String type) { //鑾峰彇鎵�鏈変骇绾挎暟鎹� List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); //鏍规嵁鐢ㄦ埛id鑾峰彇鎷ユ湁鐨勪骇绾夸俊鎭泦鍚� @@ -310,7 +364,7 @@ //缁勮浜х嚎璁惧鏍� List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); //濉厖璁惧鏁版嵁 - FillEquipmentByProduction(treeList); + FillEquipmentByProduction(treeList,type); return treeList; } @@ -609,19 +663,21 @@ /** * 浜х嚎璁惧鏍戝~鍏呰澶囨暟鎹� */ - private void FillEquipmentByProduction(List<MdcEquipmentTree> treeList) { + private void FillEquipmentByProduction(List<MdcEquipmentTree> treeList,String type) { for (MdcEquipmentTree mdcEquipmentTree : treeList) { - List<MdcEquipment> equipmentList = this.baseMapper.queryByProductionId(mdcEquipmentTree.getKey()); + List<MdcEquipment> equipmentList = this.baseMapper.queryByProductionId(mdcEquipmentTree.getKey(),type); if (equipmentList != null && !equipmentList.isEmpty()) { for (MdcEquipment mdcEquipment : equipmentList) { MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment); tree.setParentId(mdcEquipmentTree.getKey()); + tree.setEntity(mdcEquipment); + tree.setType(2); mdcEquipmentTree.getChildren().add(tree); } mdcEquipmentTree.setLeaf(false); } if (!mdcEquipmentTree.getChildren().isEmpty()) { - FillEquipmentByProduction(mdcEquipmentTree.getChildren()); + FillEquipmentByProduction(mdcEquipmentTree.getChildren(),type); } } } @@ -730,7 +786,20 @@ List<String> productionIds = mdcProductionService.recursionChildren(mdcEquipment.getProductionName()); mdcEquipment.setProductionIds(productionIds); } - return this.baseMapper.pageList(page, mdcEquipment); + IPage<MdcEquipment> equipmentIPage= this.baseMapper.pageList(page, mdcEquipment); + equipmentIPage.getRecords().forEach(item->{ + if (("1").equals(item.getDeviceTypeDnc())&&("1").equals(item.getDeviceTypeMdc())){ + item.setSystemValue("3"); + }else { + if (("1").equals(item.getDeviceTypeDnc())){ + item.setSystemValue("1"); + } + if (("1").equals(item.getDeviceTypeMdc())){ + item.setSystemValue("2"); + } + } + }); + return equipmentIPage; } /** @@ -816,7 +885,7 @@ * @return */ @Override - public List<MdcEquipmentTree> loadTreeListByProductionIds(String ids) { + public List<MdcEquipmentTree> loadTreeListByProductionIds(String ids,String type) { List<String> productionIds = Arrays.asList(ids.split(",")); //鑾峰彇鎵�鏈変骇绾挎暟鎹� List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); @@ -832,7 +901,7 @@ //缁勮浜х嚎璁惧鏍� List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); //濉厖璁惧鏁版嵁 - FillEquipmentByProduction(treeList); + FillEquipmentByProduction(treeList,type); return treeList; } -- Gitblit v1.9.3