| | |
| | | import org.jeecg.common.util.FillRuleUtil; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.base.entity.EamBaseRepairDepart; |
| | | import org.jeecg.modules.eam.base.entity.EamBaseRepairDepartUser; |
| | | import org.jeecg.modules.eam.base.mapper.EamBaseRepairDepartUserMapper; |
| | | import org.jeecg.modules.eam.base.service.IEamBaseRepairDepartService; |
| | | import org.jeecg.modules.system.entity.*; |
| | | import org.jeecg.modules.eam.base.mapper.EamBaseRepairDepartMapper; |
| | | import org.jeecg.modules.eam.base.model.EamBaseRepairDepartTreeModel; |
| | | import org.jeecg.modules.eam.base.model.RepairDepartIdModel; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | |
| | | @Resource |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Resource |
| | | private EamBaseRepairDepartUserMapper repairDepartUserMapper; |
| | | |
| | | /** |
| | | * queryTreeList å¯¹åº queryTreeList æ¥è¯¢ææçç»´ä¿®é¨é¨çç»æ°æ®,以æ ç»æå½¢å¼ååºç»å端 |
| | | */ |
| | |
| | | query.orderByAsc(EamBaseRepairDepart::getDepartOrder); |
| | | List<EamBaseRepairDepart> list = this.list(query); |
| | | //è®¾ç½®ç¨æ·idï¼è®©åå°æ¾ç¤º |
| | | this.setUserIdsByProList(list); |
| | | // this.setUserIdsByProList(list); |
| | | //è°ç¨wrapTreeDataToTreeListæ¹æ³çææ ç¶æ°æ® |
| | | return FindsRepairDepartsChildrenUtil.wrapTreeDataToTreeList(list); |
| | | } |
| | |
| | | this.checkChildrenExists(id, idList); |
| | | boolean result = this.removeByIds(idList); |
| | | //æ ¹æ®ç»´ä¿®é¨é¨çç»idå é¤ç¨æ·ä¸ç»´ä¿®é¨é¨çç»å
³ç³» |
| | | repairDepartUserMapper.delete(new LambdaQueryWrapper<EamBaseRepairDepartUser>().in(EamBaseRepairDepartUser::getDepartId, idList)); |
| | | // repairDepartUserMapper.delete(new LambdaQueryWrapper<EamBaseRepairDepartUser>().in(EamBaseRepairDepartUser::getDepartId, idList)); |
| | | //æ ¹æ®ç»´ä¿®é¨é¨çç»idå é¤ç»´ä¿®é¨é¨çç»ä¸è®¾å¤å
³ç³» |
| | | // repairDepartEquipmentMapper.delete(new LambdaQueryWrapper<SysMaintainDepartEquipment>().in(SysMaintainDepartEquipment::getMaintainDepartId, idList)); |
| | | return result; |
| | |
| | | } |
| | | this.removeByIds(idList); |
| | | //æ ¹æ®ç»´ä¿®é¨é¨çç»idå é¤ç¨æ·ä¸ç»´ä¿®é¨é¨çç»å
³ç³» |
| | | repairDepartUserMapper.delete(new LambdaQueryWrapper<EamBaseRepairDepartUser>().in(EamBaseRepairDepartUser::getDepartId, idList)); |
| | | // repairDepartUserMapper.delete(new LambdaQueryWrapper<EamBaseRepairDepartUser>().in(EamBaseRepairDepartUser::getDepartId, idList)); |
| | | //æ ¹æ®ç»´ä¿®é¨é¨çç»idå é¤ç»´ä¿®é¨é¨çç»ä¸è®¾å¤å
³ç³» |
| | | // repairDepartEquipmentMapper.delete(new LambdaQueryWrapper<SysMaintainDepartEquipment>().in(SysMaintainDepartEquipment::getMaintainDepartId, idList)); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®idæ¥è¯¢ä¸çº§ç»´ä¿®é¨é¨çç» |
| | | */ |
| | | @Override |
| | | public List<EamBaseRepairDepart> queryRepDepByPid(String pid) { |
| | | return this.baseMapper.queryRepDepByPid(pid); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·idè·åç»´ä¿®é¨é¨çç»ä¸ææ é项 |
| | | */ |
| | | @Override |
| | | public List<RepairDepartIdModel> loadMaintainDepartTreeOptions(String userId) { |
| | | //è·åææç»´ä¿®é¨é¨çç»æ°æ® |
| | | List<EamBaseRepairDepart> repairDepartList = this.baseMapper.selectList(new LambdaQueryWrapper<EamBaseRepairDepart>().eq(EamBaseRepairDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(EamBaseRepairDepart::getDepartOrder)); |
| | | //æ ¹æ®ç¨æ·idè·åæ¥æçç»´ä¿®é¨é¨çç»ä¿¡æ¯éå |
| | | List<String> repairDepartIds = repairDepartUserMapper.queryRepairDepartIdsByUserId(userId); |
| | | List<String> allMaintainDepartIds = new ArrayList<>(); |
| | | //æ¾å°ææç»´ä¿®é¨é¨çç»idçä¸çº§id |
| | | if (repairDepartIds != null && !repairDepartIds.isEmpty()) { |
| | | for (String repairDepartId : repairDepartIds) { |
| | | this.getAllMaintainDepartIds(repairDepartList, repairDepartId, allMaintainDepartIds); |
| | | } |
| | | } |
| | | //è¿æ»¤ç»´ä¿®é¨é¨çç»æ°æ® |
| | | List<EamBaseRepairDepart> list = repairDepartList.stream().filter((EamBaseRepairDepart eamBaseRepairDepart) -> allMaintainDepartIds.contains(eamBaseRepairDepart.getId())).collect(Collectors.toList()); |
| | | return FindsRepairDepartsChildrenUtil.wrapTreeDataToMaintainDepartIdTreeList(list); |
| | | } |
| | | |
| | | /** |
| | | * é彿¥è¯¢ææåèç¹id |
| | | */ |
| | | @Override |
| | | public List<String> recursionChildren(String repairDepartId) { |
| | | return this.baseMapper.recursionChildren(repairDepartId); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·idå车é´idè·åç¨æ·æ¥æç车é´id |
| | | * @param userId |
| | | * @param repairDepartId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public String findFirstMaintainDepart(String userId, String repairDepartId) { |
| | | return this.baseMapper.findFirstMaintain(userId, repairDepartId); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·idæ¥è¯¢ç¨æ·ç»´ä¿®é¨é¨çç»æé |
| | | */ |
| | | @Override |
| | | public String findThreeMaintainDepartId(String userId) { |
| | | return this.baseMapper.findThreeMaintainId(userId); |
| | | } |
| | | |
| | | @Override |
| | | public EamBaseRepairDepart findMaintainDepartList(String equipmentId) { |
| | | return this.baseMapper.findMaintainList(equipmentId); |
| | | } |
| | | // /** |
| | | // * æ ¹æ®idæ¥è¯¢ä¸çº§ç»´ä¿®é¨é¨çç» |
| | | // */ |
| | | // @Override |
| | | // public List<EamBaseRepairDepart> queryRepDepByPid(String pid) { |
| | | // return this.baseMapper.queryRepDepByPid(pid); |
| | | // } |
| | | // |
| | | // /** |
| | | // * æ ¹æ®ç¨æ·idè·åç»´ä¿®é¨é¨çç»ä¸ææ é项 |
| | | // */ |
| | | // @Override |
| | | // public List<RepairDepartIdModel> loadMaintainDepartTreeOptions(String userId) { |
| | | // //è·åææç»´ä¿®é¨é¨çç»æ°æ® |
| | | // List<EamBaseRepairDepart> repairDepartList = this.baseMapper.selectList(new LambdaQueryWrapper<EamBaseRepairDepart>().eq(EamBaseRepairDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(EamBaseRepairDepart::getDepartOrder)); |
| | | // //æ ¹æ®ç¨æ·idè·åæ¥æçç»´ä¿®é¨é¨çç»ä¿¡æ¯éå |
| | | // List<String> repairDepartIds = repairDepartUserMapper.queryRepairDepartIdsByUserId(userId); |
| | | // List<String> allMaintainDepartIds = new ArrayList<>(); |
| | | // //æ¾å°ææç»´ä¿®é¨é¨çç»idçä¸çº§id |
| | | // if (repairDepartIds != null && !repairDepartIds.isEmpty()) { |
| | | // for (String repairDepartId : repairDepartIds) { |
| | | // this.getAllMaintainDepartIds(repairDepartList, repairDepartId, allMaintainDepartIds); |
| | | // } |
| | | // } |
| | | // //è¿æ»¤ç»´ä¿®é¨é¨çç»æ°æ® |
| | | // List<EamBaseRepairDepart> list = repairDepartList.stream().filter((EamBaseRepairDepart eamBaseRepairDepart) -> allMaintainDepartIds.contains(eamBaseRepairDepart.getId())).collect(Collectors.toList()); |
| | | // return FindsRepairDepartsChildrenUtil.wrapTreeDataToMaintainDepartIdTreeList(list); |
| | | // } |
| | | // |
| | | // /** |
| | | // * é彿¥è¯¢ææåèç¹id |
| | | // */ |
| | | // @Override |
| | | // public List<String> recursionChildren(String repairDepartId) { |
| | | // return this.baseMapper.recursionChildren(repairDepartId); |
| | | // } |
| | | // |
| | | // /** |
| | | // * æ ¹æ®ç¨æ·idå车é´idè·åç¨æ·æ¥æç车é´id |
| | | // * @param userId |
| | | // * @param repairDepartId |
| | | // * @return |
| | | // */ |
| | | // @Override |
| | | // public String findFirstMaintainDepart(String userId, String repairDepartId) { |
| | | // return this.baseMapper.findFirstMaintain(userId, repairDepartId); |
| | | // } |
| | | // |
| | | // /** |
| | | // * æ ¹æ®ç¨æ·idæ¥è¯¢ç¨æ·ç»´ä¿®é¨é¨çç»æé |
| | | // */ |
| | | // @Override |
| | | // public String findThreeMaintainDepartId(String userId) { |
| | | // return this.baseMapper.findThreeMaintainId(userId); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public EamBaseRepairDepart findMaintainDepartList(String equipmentId) { |
| | | // return this.baseMapper.findMaintainList(equipmentId); |
| | | // } |
| | | |
| | | /** |
| | | * delete æ¹æ³è°ç¨ é彿¥æ¾åéid |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åææçç»´ä¿®é¨é¨çç»idï¼å
嫿æä¸çº§ï¼ |
| | | */ |
| | | private void getAllMaintainDepartIds(List<EamBaseRepairDepart> repairDepartList, String repairDepartId, List<String> allMaintainDepartIds) { |
| | | if (!allMaintainDepartIds.contains(repairDepartId)) { |
| | | allMaintainDepartIds.add(repairDepartId); |
| | | } |
| | | for (EamBaseRepairDepart eamBaseRepairDepart : repairDepartList) { |
| | | if (StringUtils.isEmpty(eamBaseRepairDepart.getParentId())) { |
| | | continue; |
| | | } |
| | | if (repairDepartId.equals(eamBaseRepairDepart.getId())) { |
| | | if (!allMaintainDepartIds.contains(eamBaseRepairDepart.getParentId())) { |
| | | allMaintainDepartIds.add(eamBaseRepairDepart.getParentId()); |
| | | getAllMaintainDepartIds(repairDepartList, eamBaseRepairDepart.getParentId(), allMaintainDepartIds); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * éè¿ç»´ä¿®é¨é¨çç»éå为维修é¨é¨çç»è®¾ç½®ç¨æ·idï¼ç¨äºåå°å±ç¤º |
| | | */ |
| | | private void setUserIdsByProList(List<EamBaseRepairDepart> repairDepartList) { |
| | | //æ¥è¯¢è´è´£é¨é¨ä¸ä¸ºç©ºçæ
åµ |
| | | LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>(); |
| | | query.isNotNull(SysUser::getDepartIds); |
| | | List<SysUser> users = sysUserMapper.selectList(query); |
| | | Map<String, Object> map = new HashMap(5); |
| | | //å
循ç¯ä¸éæ¾å°ä¸åçè´è´£ç»´ä¿®é¨é¨çç»id |
| | | for (SysUser user : users) { |
| | | String repairDepartIds = user.getRepairDepartIds(); |
| | | if (StringUtils.isNotBlank(repairDepartIds)) { |
| | | String[] repairDepartIdArray = repairDepartIds.split(","); |
| | | for (String repairDepartId : repairDepartIdArray) { |
| | | if (map.containsKey(repairDepartId)) { |
| | | String userIds = map.get(repairDepartId) + "," + user.getId(); |
| | | map.put(repairDepartId, userIds); |
| | | } else { |
| | | map.put(repairDepartId, user.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //循ç¯ç»´ä¿®é¨é¨çç»éåæ¾å°ç»´ä¿®é¨é¨çç»id对åºçè´è´£ç¨æ· |
| | | for (EamBaseRepairDepart eamBaseRepairDepart : repairDepartList) { |
| | | if (map.containsKey(eamBaseRepairDepart.getId())) { |
| | | eamBaseRepairDepart.setDirectorUserIds(map.get(eamBaseRepairDepart.getId()).toString()); |
| | | } |
| | | } |
| | | } |
| | | // /** |
| | | // * è·åææçç»´ä¿®é¨é¨çç»idï¼å
嫿æä¸çº§ï¼ |
| | | // */ |
| | | // private void getAllMaintainDepartIds(List<EamBaseRepairDepart> repairDepartList, String repairDepartId, List<String> allMaintainDepartIds) { |
| | | // if (!allMaintainDepartIds.contains(repairDepartId)) { |
| | | // allMaintainDepartIds.add(repairDepartId); |
| | | // } |
| | | // for (EamBaseRepairDepart eamBaseRepairDepart : repairDepartList) { |
| | | // if (StringUtils.isEmpty(eamBaseRepairDepart.getParentId())) { |
| | | // continue; |
| | | // } |
| | | // if (repairDepartId.equals(eamBaseRepairDepart.getId())) { |
| | | // if (!allMaintainDepartIds.contains(eamBaseRepairDepart.getParentId())) { |
| | | // allMaintainDepartIds.add(eamBaseRepairDepart.getParentId()); |
| | | // getAllMaintainDepartIds(repairDepartList, eamBaseRepairDepart.getParentId(), allMaintainDepartIds); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // /** |
| | | // * éè¿ç»´ä¿®é¨é¨çç»éå为维修é¨é¨çç»è®¾ç½®ç¨æ·idï¼ç¨äºåå°å±ç¤º |
| | | // */ |
| | | // private void setUserIdsByProList(List<EamBaseRepairDepart> repairDepartList) { |
| | | // //æ¥è¯¢è´è´£é¨é¨ä¸ä¸ºç©ºçæ
åµ |
| | | // LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>(); |
| | | // query.isNotNull(SysUser::getDepartIds); |
| | | // List<SysUser> users = sysUserMapper.selectList(query); |
| | | // Map<String, Object> map = new HashMap(5); |
| | | // //å
循ç¯ä¸éæ¾å°ä¸åçè´è´£ç»´ä¿®é¨é¨çç»id |
| | | // for (SysUser user : users) { |
| | | // String repairDepartIds = user.getRepairDepartIds(); |
| | | // if (StringUtils.isNotBlank(repairDepartIds)) { |
| | | // String[] repairDepartIdArray = repairDepartIds.split(","); |
| | | // for (String repairDepartId : repairDepartIdArray) { |
| | | // if (map.containsKey(repairDepartId)) { |
| | | // String userIds = map.get(repairDepartId) + "," + user.getId(); |
| | | // map.put(repairDepartId, userIds); |
| | | // } else { |
| | | // map.put(repairDepartId, user.getId()); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // //循ç¯ç»´ä¿®é¨é¨çç»éåæ¾å°ç»´ä¿®é¨é¨çç»id对åºçè´è´£ç¨æ· |
| | | // for (EamBaseRepairDepart eamBaseRepairDepart : repairDepartList) { |
| | | // if (map.containsKey(eamBaseRepairDepart.getId())) { |
| | | // eamBaseRepairDepart.setDirectorUserIds(map.get(eamBaseRepairDepart.getId()).toString()); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | } |