From bc263d8bed5d1405f275bb8638a9bec9eaf06585 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期一, 31 三月 2025 09:42:00 +0800 Subject: [PATCH] 添加审签逻辑,移动flow通用代码,添加根据角色查询用户,新增时间工具类,修改指派设备bug --- lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java | 267 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 258 insertions(+), 9 deletions(-) diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java index e39af4e..bc363c2 100644 --- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java @@ -1,23 +1,33 @@ package org.jeecg.modules.system.service.impl; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.FillRuleConstant; +import org.jeecg.common.system.vo.DictModel; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.FillRuleUtil; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.system.entity.*; -import org.jeecg.modules.system.mapper.*; +import org.jeecg.modules.system.mapper.MdcProductionEquipmentMapper; +import org.jeecg.modules.system.mapper.MdcProductionMapper; +import org.jeecg.modules.system.mapper.MdcUserProductionMapper; +import org.jeecg.modules.system.mapper.SysUserMapper; import org.jeecg.modules.system.model.MdcProductionTreeModel; import org.jeecg.modules.system.model.ProductionIdModel; import org.jeecg.modules.system.service.IMdcProductionService; +import org.jeecg.modules.system.service.ISysDictService; +import org.jeecg.modules.system.service.ISysParamsService; import org.jeecg.modules.system.util.FindsProductionsChildrenUtil; +import org.jeecg.modules.system.vo.MdcProOptionsVo; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -45,7 +55,10 @@ private MdcProductionEquipmentMapper productionEquipmentMapper; @Resource - private DncDeviceGroupPermissionMapper dncDeviceGroupPermissionMapper; + private ISysParamsService sysParamsService; + + @Resource + private ISysDictService sysDictService; /** * queryTreeList 瀵瑰簲 queryTreeList 鏌ヨ鎵�鏈夌殑浜х嚎鏁版嵁,浠ユ爲缁撴瀯褰㈠紡鍝嶅簲缁欏墠绔� */ @@ -60,6 +73,58 @@ this.setUserIdsByProList(list); //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list); + } + + /** + * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず(娣诲姞绯荤粺閰嶇疆) + */ + @Override + public List<MdcProductionTreeModel> queryTreeListByConfig(){ + SysParams sysParams = sysParamsService.getSysPramBySettingKey("dnc_production"); + LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); + if (sysParams == null) { + return null; + }else { + List<String> productionIds = new ArrayList<>(); + if (!("admin").equals(loginUser.getUsername())) { + //涓嶆槸瓒呯骇绠$悊鍛橈紝鑾峰彇鐢ㄦ埛鎷ユ湁鐨勪骇绾� + if (loginUser.getProductionIds() != null) { + if (loginUser.getProductionIds().contains(",")) { + productionIds = Arrays.asList(loginUser.getProductionIds().split(",")); + } else { + productionIds = Collections.singletonList(loginUser.getProductionIds()); + } + } + } + if (("0").equals(sysParams.getSettingValue())){ + query.eq(MdcProduction::getOrgType,"2"); + query.in(!productionIds.isEmpty(), MdcProduction::getId, productionIds); + query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); + query.orderByAsc(MdcProduction::getProductionOrder); + List<MdcProduction> list = this.list(query); + //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず + this.setUserIdsByProList(list); + //灏佽涓�绾ф爲 + List<MdcProductionTreeModel> listResult = new ArrayList<>(); + for (MdcProduction production : list) { + if (production.getDescription().isEmpty()){ + production.setDescription(""); + } + listResult.add(new MdcProductionTreeModel(production)); + } + //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 + return listResult; + }else { + query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); + query.orderByAsc(MdcProduction::getProductionOrder); + List<MdcProduction> list = this.list(query); + //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず + this.setUserIdsByProList(list); + //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 + return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list); + } + } } /** @@ -138,13 +203,13 @@ mdcProduction.setOrgType(String.valueOf(orgType)); mdcProduction.setDelFlag(CommonConstant.DEL_FLAG_0.toString()); this.save(mdcProduction); - //鏂板DNC杞﹂棿鏉冮檺 - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - DncDeviceGroupPermission dncDeviceGroupPermission=new DncDeviceGroupPermission(); - dncDeviceGroupPermission.setGroupPermId(mdcProduction.getId()); - dncDeviceGroupPermission.setUserId(userId); - dncDeviceGroupPermissionMapper.insert(dncDeviceGroupPermission); + + //澶勭悊瀛樺湪鐖跺瓙鍏崇郴 mdc鏍囪缁熶竴鐨勯棶棰� + //1.mdc鏍囪 涓� 1 寮�鍚� 鐖剁骇鑺傜偣瑕佺粺涓�寮�鍚� + //2.mdc鏍囪 涓� 0 鍏抽棴 瀛愮骇鑺傜偣瑕佺粺涓�鍏抽棴 鏂板鎿嶄綔 涓嶅瓨鍦ㄦ鎯呭喌 + if(StringUtils.isNotBlank(parentId) && CommonConstant.DEFAULT_1.equals(mdcProduction.getMdcFlag())){ + openParentMdcFlag(parentId); + } } } @@ -156,6 +221,18 @@ public boolean updateProductionDataById(MdcProduction mdcProduction) { if (mdcProduction != null) { this.updateById(mdcProduction); + + //澶勭悊瀛樺湪鐖跺瓙鍏崇郴 mdc鏍囪缁熶竴鐨勯棶棰� + //1.mdc鏍囪 涓� 1 寮�鍚� 鐖剁骇鑺傜偣瑕佺粺涓�寮�鍚� + //2.mdc鏍囪 涓� 0 鍏抽棴 瀛愮骇鑺傜偣瑕佺粺涓�鍏抽棴 + String parentId = mdcProduction.getParentId(); + if(StringUtils.isNotBlank(parentId) && CommonConstant.DEFAULT_1.equals(mdcProduction.getMdcFlag())){ + openParentMdcFlag(parentId); + } + if(CommonConstant.DEFAULT_0.equals(mdcProduction.getMdcFlag())){ + //鍏抽棴 + closeChildrenMdcFlag(mdcProduction.getId()); + } return true; } return false; @@ -202,6 +279,15 @@ @Override public List<MdcProduction> queryProdByPid(String pid) { return this.baseMapper.queryProdByPid(pid); + } + + /** + * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 + */ + @Override + public List<MdcProduction> recursionChildrenByPid(String pid){ + List<String> ids=this.recursionChildren(pid); + return super.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).in(MdcProduction::getId, ids)); } /** @@ -368,4 +454,167 @@ } return stringList; } + + /** + * 鑾峰彇鐢ㄦ埛宸插垎閰嶇殑閮ㄩ棬鍒楄〃 + * @param userId + * @return + */ + @Override + public Map<String, MdcProduction> getUserAssignedDepart(String userId){ + if(StrUtil.isEmpty(userId)) + return null; + List<MdcProduction> userPermDepart = this.baseMapper.findAllProductionId(userId); + if(userPermDepart == null || userPermDepart.isEmpty()) + return null; + Map<String, MdcProduction> map = new HashMap<>(); + userPermDepart.forEach(item -> { + map.put(item.getId(), item); + }); + return map; + } + + /** + * 閫氳繃涓�缁刬d鑾峰彇閮ㄩ棬 + * @param ids + * @return + */ + @Override + public List<String> findAllProductionIds(List<String> ids){ + return this.baseMapper.recursionChildrenByList(ids); + } + + @Override + public List<String> findParentIdsForProduction(String parentId, List<String> idList) { + if (StringUtils.isEmpty(parentId)) { + return null; + } + if (idList == null || idList.isEmpty()) { + idList = new ArrayList<>(); + } + boolean p = true; + if (p) { + MdcProduction en = super.getById(parentId); + if (en != null) { + idList.add(0, en.getId()); + } + if (StringUtils.isNotBlank(en.getParentId())) { + parentId = en.getParentId(); + findParentIdsForProduction(parentId, idList); + } else { + p = false; + return idList; + } + } + return idList; + } + + @Override + public List<MdcProductionTreeModel> queryTreeListByMdc(String ids) { + List<MdcProductionTreeModel> listResult = new ArrayList<>(); + LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); + query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); + query.eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1); + if (oConvertUtils.isNotEmpty(ids)) { + query.in(true, MdcProduction::getId, ids.split(",")); + } + query.orderByAsc(MdcProduction::getProductionOrder); + List<MdcProduction> list = this.list(query); + for (MdcProduction production : list) { + if (production.getDescription().isEmpty()){ + production.setDescription(""); + } + listResult.add(new MdcProductionTreeModel(production)); + } + return listResult; + } + + @Override + public List<MdcProductionTreeModel> queryTreeListByMdc() { + LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); + query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); + query.eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1); + query.orderByAsc(MdcProduction::getProductionOrder); + List<MdcProduction> list = this.list(query); + //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず + this.setUserIdsByProList(list); + //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 + return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list); + } + + @Override + public List<String> findChildren(List<String> mdcProductionIds) { + return this.baseMapper.findChildren(mdcProductionIds); + } + + /** + * 鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎(涓績)鎴栫彮缁勪笅鎷夐�夐」 + * @param userId + * @param productionId + * @return + */ + @Override + public List<MdcProOptionsVo> loadProductionOptions(String userId, String productionId) { + List<MdcProOptionsVo> result = new ArrayList<>(); + List<MdcProduction> mdcProductionList = this.baseMapper.loadProductionOptions(userId, productionId); + if (mdcProductionList != null && !mdcProductionList.isEmpty()) { + for (MdcProduction mdcProduction : mdcProductionList) { + MdcProOptionsVo vo = new MdcProOptionsVo().convert(mdcProduction); + result.add(vo); + } + } + return result; + } + + @Override + public List<MdcProOptionsVo> loadTeamOptions(String userId, String productionId) { + List<MdcProOptionsVo> result = new ArrayList<>(); + List<String> productionList = this.findChildren(Arrays.asList(productionId.split(","))); + if (productionList != null && !productionList.isEmpty()) { + List<String> dictValues = this.baseMapper.findTeamValue(userId, productionList); + if (dictValues != null && !dictValues.isEmpty()) { + List<DictModel> dictModels = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_MDC_STAFF_TEAM); + if (dictModels != null && !dictModels.isEmpty()) { + for (DictModel dictModel : dictModels) { + if (dictValues.contains(dictModel.getValue())) { + MdcProOptionsVo vo = new MdcProOptionsVo(); + vo.setKey(dictModel.getValue()); + vo.setValue(dictModel.getValue()); + vo.setTitle(dictModel.getText()); + result.add(vo); + } + } + } + } + } + return result; + } + + /** + * 鎵撳紑 鐖惰妭鐐� 鍙� 浠ヤ笂鐨刴dc鏍囪 + * @param parentId + */ + private void openParentMdcFlag(String parentId) { + List<String> listParentTree = findParentIdsForProduction(parentId, new ArrayList<>()); + if (!CollectionUtil.isEmpty(listParentTree)) { + UpdateWrapper<MdcProduction> updateWrapper = new UpdateWrapper<>(); + updateWrapper.in("id", listParentTree); + updateWrapper.set("mdc_flag", "1"); + super.update(updateWrapper); + } + } + + /** + * 鍏抽棴鎵�鏈夊瓙鑺傜偣鐨刴dc鏍囪 + * @param productionId + */ + private void closeChildrenMdcFlag(String productionId) { + List<String> childrenList = recursionChildren(productionId); + if (!CollectionUtil.isEmpty(childrenList)) { + UpdateWrapper<MdcProduction> updateWrapper = new UpdateWrapper<>(); + updateWrapper.in("id", childrenList); + updateWrapper.set("mdc_flag", "0"); + super.update(updateWrapper); + } + } } -- Gitblit v1.9.3