| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.tree.FindsEquipmentProductionUtil; |
| | | import org.jeecg.modules.eam.vo.EamEquipmentTree; |
| | | import org.jeecg.modules.eam.vo.EquipmentSearchResult; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | /** |
| | | * @Description: 设å¤å°è´¦ |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-03-19 |
| | | * @Date: 2025-03-19 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | |
| | | QueryWrapper<EamEquipment> queryWrapper = new QueryWrapper<>(); |
| | | //ç¨æ·æ°æ®æé |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if(sysUser == null){ |
| | | if (sysUser == null) { |
| | | return page; |
| | | } |
| | | if(StringUtils.isNotBlank(sysUser.getEquipmentIds())){ |
| | | if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | //éæ©äºè®¾å¤ï¼æ ¹æ®è®¾å¤idè¿æ»¤è®¾å¤ |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | queryWrapper.in("e.equipment_code", equipArr); |
| | | }else { |
| | | } else { |
| | | //没æéæ©è®¾å¤ï¼æ ¹æ®è½¦é´è¿æ»¤è®¾å¤ |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id", sysUser.getId()); |
| | | } |
| | | //æ¥è¯¢æ¡ä»¶è¿æ»¤ |
| | | if(eamEquipment != null){ |
| | | if(StringUtils.isNotBlank(eamEquipment.getEquipmentCode())){ |
| | | if (eamEquipment != null) { |
| | | if (StringUtils.isNotBlank(eamEquipment.getEquipmentCode())) { |
| | | queryWrapper.like("e.equipment_code", eamEquipment.getEquipmentCode()); |
| | | } |
| | | if(StringUtils.isNotBlank(eamEquipment.getEquipmentName())){ |
| | | if (StringUtils.isNotBlank(eamEquipment.getEquipmentName())) { |
| | | queryWrapper.like("e.equipment_name", eamEquipment.getEquipmentName()); |
| | | } |
| | | if(StringUtils.isNotBlank(eamEquipment.getEquipmentImportance())){ |
| | | if (StringUtils.isNotBlank(eamEquipment.getEquipmentImportance())) { |
| | | queryWrapper.eq("e.equipment_importance", eamEquipment.getEquipmentImportance()); |
| | | } |
| | | if(StringUtils.isNotBlank(eamEquipment.getAssetStatus())){ |
| | | if (StringUtils.isNotBlank(eamEquipment.getAssetStatus())) { |
| | | queryWrapper.like("e.asset_status", eamEquipment.getAssetStatus()); |
| | | } |
| | | if(StringUtils.isNotBlank(eamEquipment.getTechnologyStatus())){ |
| | | if (StringUtils.isNotBlank(eamEquipment.getTechnologyStatus())) { |
| | | queryWrapper.like("e.technology_status", eamEquipment.getTechnologyStatus()); |
| | | } |
| | | if(StringUtils.isNotBlank(eamEquipment.getOperationSystem())){ |
| | | if (StringUtils.isNotBlank(eamEquipment.getOperationSystem())) { |
| | | queryWrapper.like("e.operation_system", eamEquipment.getOperationSystem()); |
| | | } |
| | | if(StringUtils.isNotBlank(eamEquipment.getOrgId())){ |
| | | if (StringUtils.isNotBlank(eamEquipment.getOrgId())) { |
| | | queryWrapper.like("e.org_id", eamEquipment.getOrgId()); |
| | | } |
| | | if(StringUtils.isNotBlank(eamEquipment.getEquipmentCategory())){ |
| | | if (StringUtils.isNotBlank(eamEquipment.getEquipmentCategory())) { |
| | | queryWrapper.like("e.equipment_category", eamEquipment.getEquipmentCategory()); |
| | | } |
| | | //æåº |
| | | if(StringUtils.isNotBlank(eamEquipment.getColumn()) && StringUtils.isNotBlank(eamEquipment.getOrder())){ |
| | | if (StringUtils.isNotBlank(eamEquipment.getColumn()) && StringUtils.isNotBlank(eamEquipment.getOrder())) { |
| | | //queryWrapper.like("column", eamEquipment.getColumn()); |
| | | String column = eamEquipment.getColumn(); |
| | | if(column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { |
| | | if (column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { |
| | | column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX)); |
| | | } |
| | | if(DataBaseConstant.SQL_ASC.equalsIgnoreCase(eamEquipment.getOrder())){ |
| | | if (DataBaseConstant.SQL_ASC.equalsIgnoreCase(eamEquipment.getOrder())) { |
| | | queryWrapper.orderByAsc("e." + oConvertUtils.camelToUnderline(column)); |
| | | }else { |
| | | } else { |
| | | queryWrapper.orderByDesc("e." + oConvertUtils.camelToUnderline(column)); |
| | | } |
| | | }else { |
| | | } else { |
| | | queryWrapper.orderByDesc("e.create_time"); |
| | | } |
| | | }else { |
| | | } else { |
| | | queryWrapper.orderByDesc("e.create_time"); |
| | | } |
| | | |
| | | IPage<EamEquipment> ipage = eamEquipmentMapper.queryPageList(page, queryWrapper); |
| | | IPage<EamEquipment> ipage = eamEquipmentMapper.queryPageList(page, queryWrapper); |
| | | return ipage; |
| | | } |
| | | |
| | | @Override |
| | | public List<EquipmentSearchResult> asyncLoadEquipment(String keyword, Integer pageSize) { |
| | | IPage<EamEquipment> page = new Page<>(1, pageSize); |
| | | QueryWrapper<EamEquipment> queryWrapper = new QueryWrapper<>(); |
| | | //ç¨æ·æ°æ®æé |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | | return Collections.emptyList(); |
| | | } |
| | | if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | //éæ©äºè®¾å¤ï¼æ ¹æ®è®¾å¤idè¿æ»¤è®¾å¤ |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | queryWrapper.in("equipment_code", equipArr); |
| | | } else { |
| | | //没æéæ©è®¾å¤ï¼æ ¹æ®è½¦é´è¿æ»¤è®¾å¤ |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=org_id", sysUser.getId()); |
| | | } |
| | | if (StringUtils.isNotBlank(keyword)) { |
| | | queryWrapper.like("equipment_code", keyword); |
| | | queryWrapper.or().like("equipment_name", keyword); |
| | | } |
| | | IPage<EamEquipment> pageResult = eamEquipmentMapper.queryPageList(page, queryWrapper); |
| | | if (pageResult != null && CollectionUtil.isNotEmpty(pageResult.getRecords())) { |
| | | List<EquipmentSearchResult> resultList = new ArrayList<>(); |
| | | pageResult.getRecords().forEach((record) -> { |
| | | resultList.add(new EquipmentSearchResult(record)); |
| | | }); |
| | | return resultList; |
| | | } |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | /** |
| | | * è·åææç产线idï¼å
嫿æä¸çº§ï¼ |
| | | */ |