¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.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; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: 产线表 |
| | | * @Author: liuS |
| | | * @Date: 2023-03-23 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class MdcProductionServiceImpl extends ServiceImpl<MdcProductionMapper, MdcProduction> implements IMdcProductionService { |
| | | |
| | | @Resource |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Resource |
| | | private MdcUserProductionMapper userProductionMapper; |
| | | |
| | | @Resource |
| | | private MdcProductionEquipmentMapper productionEquipmentMapper; |
| | | |
| | | @Resource |
| | | private ISysParamsService sysParamsService; |
| | | |
| | | @Resource |
| | | private ISysDictService sysDictService; |
| | | /** |
| | | * queryTreeList å¯¹åº queryTreeList æ¥è¯¢ææçäº§çº¿æ°æ®,以æ ç»æå½¢å¼ååºç»å端 |
| | | */ |
| | | @Override |
| | | @Cacheable(value = "mdc:cache:production:alldata") |
| | | public List<MdcProductionTreeModel> queryTreeList() { |
| | | LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ææäº§çº¿ä¿¡æ¯ï¼å¹¶åèç¹è¿è¡æ¾ç¤º(æ·»å ç³»ç»é
ç½®) |
| | | */ |
| | | @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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * queryTreeList æ ¹æ®äº§çº¿idæ¥è¯¢,åç«¯åæ¾è°ç¨ |
| | | */ |
| | | @Override |
| | | public List<MdcProductionTreeModel> queryTreeList(String ids) { |
| | | List<MdcProductionTreeModel> listResult = new ArrayList<>(); |
| | | LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); |
| | | query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); |
| | | 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 |
| | | @Cacheable(value = "mdc:cache:production:allids") |
| | | public List<ProductionIdModel> queryProductionIdTreeList() { |
| | | LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>(); |
| | | query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); |
| | | query.orderByAsc(MdcProduction::getProductionOrder); |
| | | List<MdcProduction> list = this.list(query); |
| | | //è°ç¨wrapTreeDataToTreeListæ¹æ³çææ ç¶æ°æ® |
| | | return FindsProductionsChildrenUtil.wrapTreeDataToProductionIdTreeList(list); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®å
³é®åæç´¢ç¸å
³çé¨é¨æ°æ® |
| | | */ |
| | | @Override |
| | | public List<MdcProductionTreeModel> searchByKeyWord(String keyWord) { |
| | | LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>(); |
| | | List<MdcProductionTreeModel> newList = new ArrayList<>(); |
| | | query.like(MdcProduction::getProductionName, keyWord); |
| | | MdcProductionTreeModel model = new MdcProductionTreeModel(); |
| | | List<MdcProduction> productionList = this.list(query); |
| | | if (!productionList.isEmpty()) { |
| | | for (MdcProduction mdcProduction : productionList) { |
| | | model = new MdcProductionTreeModel(mdcProduction); |
| | | model.setChildren(null); |
| | | newList.add(model); |
| | | } |
| | | return newList; |
| | | } |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | /** |
| | | * saveProductionData å¯¹åº add ä¿åç¨æ·å¨é¡µé¢æ·»å çæ°çäº§çº¿å¯¹è±¡æ°æ® |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveProductionData(MdcProduction mdcProduction) { |
| | | if (mdcProduction != null) { |
| | | if (mdcProduction.getParentId() == null) { |
| | | mdcProduction.setParentId(""); |
| | | } |
| | | mdcProduction.setId(IdWorker.getIdStr(mdcProduction)); |
| | | // å
å¤æè¯¥å¯¹è±¡ææ ç¶çº§ID,æåæå³ç䏿¯æé«çº§,å¦åæå³çæ¯æé«çº§ |
| | | // è·åç¶çº§ID |
| | | String parentId = mdcProduction.getParentId(); |
| | | JSONObject formData = new JSONObject(); |
| | | formData.put("parentId",parentId); |
| | | String[] codeArray = (String[]) FillRuleUtil.executeRule(FillRuleConstant.PRODUCTION,formData); |
| | | mdcProduction.setOrgCode(codeArray[0]); |
| | | String orgType = codeArray[1]; |
| | | mdcProduction.setOrgType(String.valueOf(orgType)); |
| | | mdcProduction.setDelFlag(CommonConstant.DEL_FLAG_0.toString()); |
| | | this.save(mdcProduction); |
| | | |
| | | //å¤çåå¨ç¶åå
³ç³» mdcæ è®°ç»ä¸çé®é¢ |
| | | //1.mdcæ è®° 为 1 å¼å¯ ç¶çº§èç¹è¦ç»ä¸å¼å¯ |
| | | //2.mdcæ è®° 为 0 å
³é å级èç¹è¦ç»ä¸å
³é æ°å¢æä½ ä¸å卿¤æ
åµ |
| | | if(StringUtils.isNotBlank(parentId) && CommonConstant.DEFAULT_1.equals(mdcProduction.getMdcFlag())){ |
| | | openParentMdcFlag(parentId); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * updateProductionDataById å¯¹åº edit æ ¹æ®äº§çº¿ä¸»é®æ¥æ´æ°å¯¹åºçäº§çº¿æ°æ® |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®äº§çº¿idå é¤å¹¶å é¤å
¶å¯è½åå¨çå级产线 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean delete(String id) { |
| | | List<String> idList = new ArrayList<>(); |
| | | idList.add(id); |
| | | this.checkChildrenExists(id, idList); |
| | | boolean result = this.removeByIds(idList); |
| | | //æ ¹æ®äº§çº¿idå é¤ç¨æ·ä¸äº§çº¿å
³ç³» |
| | | userProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getProId, idList)); |
| | | //æ ¹æ®äº§çº¿idå é¤äº§çº¿ä¸è®¾å¤å
³ç³» |
| | | productionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getProductionId, idList)); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®äº§çº¿idæ¹éå é¤å¹¶å é¤å
¶å¯è½åå¨çå级产线 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteBatchWithChildren(List<String> ids) { |
| | | List<String> idList = new ArrayList<>(); |
| | | for (String id : ids) { |
| | | idList.add(id); |
| | | this.checkChildrenExists(id, idList); |
| | | } |
| | | this.removeByIds(idList); |
| | | //æ ¹æ®äº§çº¿idå é¤ç¨æ·ä¸äº§çº¿å
³ç³» |
| | | userProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getProId, idList)); |
| | | //æ ¹æ®äº§çº¿idå é¤äº§çº¿ä¸è®¾å¤å
³ç³» |
| | | productionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getProductionId, idList)); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®idæ¥è¯¢ä¸çº§äº§çº¿ |
| | | */ |
| | | @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)); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·idè·åäº§çº¿ä¸ææ é项 |
| | | */ |
| | | @Override |
| | | public List<ProductionIdModel> loadProductionTreeOptions(String userId) { |
| | | //è·åææäº§çº¿æ°æ® |
| | | List<MdcProduction> productionList = this.baseMapper.selectList(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); |
| | | //æ ¹æ®ç¨æ·idè·åæ¥æç产线信æ¯éå |
| | | List<String> productionIds = userProductionMapper.queryProductionIdsByUserId(userId); |
| | | List<String> allProductionIds = new ArrayList<>(); |
| | | //æ¾å°ææäº§çº¿idçä¸çº§id |
| | | if (productionIds != null && !productionIds.isEmpty()) { |
| | | for (String productionId : productionIds) { |
| | | this.getAllProductionIds(productionList, productionId, allProductionIds); |
| | | } |
| | | } |
| | | //è¿æ»¤äº§çº¿æ°æ® |
| | | List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); |
| | | return FindsProductionsChildrenUtil.wrapTreeDataToProductionIdTreeList(list); |
| | | } |
| | | |
| | | /** |
| | | * é彿¥è¯¢ææåèç¹id |
| | | */ |
| | | @Override |
| | | public List<String> recursionChildren(String productionId) { |
| | | return this.baseMapper.recursionChildren(productionId); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·idå车é´idè·åç¨æ·æ¥æç车é´id |
| | | * @param userId |
| | | * @param productionId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public String findFirstProduction(String userId, String productionId) { |
| | | return this.baseMapper.findFirstProduction(userId, productionId); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·idæ¥è¯¢ç¨æ·å·¥æ®µæé |
| | | */ |
| | | @Override |
| | | public String findThreeProductionId(String userId) { |
| | | return this.baseMapper.findThreeProductionId(userId); |
| | | } |
| | | |
| | | /** |
| | | * delete æ¹æ³è°ç¨ é彿¥æ¾åéid |
| | | */ |
| | | private void checkChildrenExists(String id, List<String> idList) { |
| | | LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>(); |
| | | query.eq(MdcProduction::getParentId, id); |
| | | List<MdcProduction> productionList = this.list(query); |
| | | if (productionList != null && !productionList.isEmpty()) { |
| | | for (MdcProduction production : productionList) { |
| | | idList.add(production.getId()); |
| | | this.checkChildrenExists(production.getId(), idList); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åææç产线idï¼å
嫿æä¸çº§ï¼ |
| | | */ |
| | | private void getAllProductionIds(List<MdcProduction> productionList, String productionId, List<String> allProductionIds) { |
| | | if (!allProductionIds.contains(productionId)) { |
| | | allProductionIds.add(productionId); |
| | | } |
| | | for (MdcProduction mdcProduction : productionList) { |
| | | if (StringUtils.isEmpty(mdcProduction.getParentId())) { |
| | | continue; |
| | | } |
| | | if (productionId.equals(mdcProduction.getId())) { |
| | | if (!allProductionIds.contains(mdcProduction.getParentId())) { |
| | | allProductionIds.add(mdcProduction.getParentId()); |
| | | getAllProductionIds(productionList, mdcProduction.getParentId(), allProductionIds); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * éè¿äº§çº¿éåä¸ºäº§çº¿è®¾ç½®ç¨æ·idï¼ç¨äºåå°å±ç¤º |
| | | */ |
| | | private void setUserIdsByProList(List<MdcProduction> productionList) { |
| | | //æ¥è¯¢è´è´£é¨é¨ä¸ä¸ºç©ºçæ
åµ |
| | | 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 productionIds = user.getProductionIds(); |
| | | if (StringUtils.isNotBlank(productionIds)) { |
| | | String[] productionIdArray = productionIds.split(","); |
| | | for (String productionId : productionIdArray) { |
| | | if (map.containsKey(productionId)) { |
| | | String userIds = map.get(productionId) + "," + user.getId(); |
| | | map.put(productionId, userIds); |
| | | } else { |
| | | map.put(productionId, user.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //循ç¯äº§çº¿éåæ¾å°äº§çº¿id对åºçè´è´£ç¨æ· |
| | | for (MdcProduction mdcProduction : productionList) { |
| | | if (map.containsKey(mdcProduction.getId())) { |
| | | mdcProduction.setDirectorUserIds(map.get(mdcProduction.getId()).toString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ææç¶èç¹åæ¬èç¹åç§° |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<String> findListParentTreeAll(String id){ |
| | | MdcProductionEquipment mdcProductionEquipment=productionEquipmentMapper.selectOne(new QueryWrapper<MdcProductionEquipment>().eq("equipment_id",id)); |
| | | if (mdcProductionEquipment==null) { |
| | | return null; |
| | | } |
| | | List<String> strings = new ArrayList<>(); |
| | | MdcProduction en=super.getById(mdcProductionEquipment.getProductionId()); |
| | | if (en == null) { |
| | | return null; |
| | | } |
| | | strings.add(en.getProductionName()); |
| | | if (StringUtils.isEmpty(en.getParentId())) { |
| | | return strings; |
| | | } else { |
| | | return findListParentTree(en.getParentId(),strings); |
| | | } |
| | | } |
| | | |
| | | // æ¥è¯¢æä»¥ç¶èç¹ |
| | | @Override |
| | | public List<String> findListParentTree(String parentId,List<String> stringList){ |
| | | if (StringUtils.isEmpty(parentId)) { |
| | | return null; |
| | | } |
| | | if (stringList == null || stringList.isEmpty()) { |
| | | stringList = new ArrayList<>(); |
| | | } |
| | | boolean p = true; |
| | | if (p) { |
| | | MdcProduction en = super.getById(parentId); |
| | | if (en != null) { |
| | | stringList.add(0,en.getProductionName()); |
| | | } |
| | | if (StringUtils.isNotBlank(en.getParentId())) { |
| | | parentId = en.getParentId(); |
| | | findListParentTree(parentId,stringList); |
| | | } else { |
| | | p = false; |
| | | return stringList; |
| | | } |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * éè¿ä¸ç»idè·åé¨é¨ |
| | | * @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<MdcProduction> findMdcPros(String userId, String productionId) { |
| | | return this.baseMapper.loadProductionOptions(userId, productionId); |
| | | } |
| | | |
| | | @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; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> findProIdsByUId(String userId, List<String> allProductionIds) { |
| | | return this.baseMapper.findProIdsByUId(userId, allProductionIds); |
| | | } |
| | | |
| | | /** |
| | | * æå¼ ç¶èç¹ å 以ä¸çmdcæ è®° |
| | | * @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); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å
³éææåèç¹çmdcæ è®° |
| | | * @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); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<String> findChildByProId(String productionId) { |
| | | return this.baseMapper.findChildByProId(productionId); |
| | | } |
| | | |
| | | @Override |
| | | public String findProName(String equipmentId) { |
| | | return this.baseMapper.findProName(equipmentId); |
| | | } |
| | | |
| | | @Override |
| | | public MdcProduction findByOrgCode(String orgCode){ |
| | | return this.baseMapper.selectOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgCode, orgCode)); |
| | | } |
| | | } |