| | |
| | | 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.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; |
| | |
| | | |
| | | @Resource |
| | | private ISysParamsService sysParamsService; |
| | | |
| | | @Resource |
| | | private ISysDictService sysDictService; |
| | | /** |
| | | * queryTreeList 对应 queryTreeList 查询所有的产线数据,以树结构形式响应给前端 |
| | | */ |
| | |
| | | @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); |
| | |
| | | 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 |
| | |
| | | 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); |
| | | } |
| | | } |