对比新文件 |
| | |
| | | package org.jeecg.modules.mdc.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.service.IMdcProductionEquipmentService; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.entity.MdcProductionEquipment; |
| | | import org.jeecg.modules.system.mapper.MdcProductionEquipmentMapper; |
| | | import org.jeecg.modules.system.model.ProductionIdModel; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author: LiuS |
| | | * @create: 2023-03-28 10:31 |
| | | */ |
| | | @Service |
| | | public class MdcProductionEquipmentServiceImpl extends ServiceImpl<MdcProductionEquipmentMapper, MdcProductionEquipment> implements IMdcProductionEquipmentService { |
| | | |
| | | @Resource |
| | | private IMdcProductionService mdcProductionService; |
| | | @Resource |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | |
| | | /** |
| | | * 鏍规嵁璁惧id鏌ヨ浜х嚎淇℃伅 |
| | | */ |
| | | @Override |
| | | public List<ProductionIdModel> queryProductionIdsOfEquipment(String equipmentId) { |
| | | LambdaQueryWrapper<MdcProductionEquipment> queryEquipmentPro = new LambdaQueryWrapper<>(); |
| | | LambdaQueryWrapper<MdcProduction> queryPro = new LambdaQueryWrapper<>(); |
| | | try { |
| | | queryEquipmentPro.eq(MdcProductionEquipment::getEquipmentId, equipmentId); |
| | | List<String> proIdList = new ArrayList<>(); |
| | | List<ProductionIdModel> proIdModelList = new ArrayList<>(); |
| | | List<MdcProductionEquipment> equipmentProList = this.list(queryEquipmentPro); |
| | | if (equipmentProList != null && !equipmentProList.isEmpty()) { |
| | | for (MdcProductionEquipment productionEquipment : equipmentProList) { |
| | | proIdList.add(productionEquipment.getProductionId()); |
| | | } |
| | | queryPro.in(MdcProduction::getId, proIdList); |
| | | List<MdcProduction> proList = mdcProductionService.list(queryPro); |
| | | if (proList != null && !proList.isEmpty()) { |
| | | for (MdcProduction mdcProduction : proList) { |
| | | proIdModelList.add(new ProductionIdModel().convertByUserProduction(mdcProduction)); |
| | | } |
| | | } |
| | | return proIdModelList; |
| | | } |
| | | } catch (Exception e) { |
| | | e.fillInStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | * 鏍规嵁鎸囧畾浜х嚎id鏌ヨ璁惧淇℃伅 |
| | | */ |
| | | @Override |
| | | public List<MdcEquipment> queryEquipmentsOfProduction(String productionId){ |
| | | List<String> equipmentIds = this.list(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId)) |
| | | .stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); |
| | | if (!equipmentIds.isEmpty()) { |
| | | return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds)); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 鏍规嵁鎸囧畾浜х嚎ids鏌ヨ璁惧淇℃伅 |
| | | */ |
| | | @Override |
| | | public List<MdcEquipment> queryEquipmentsOfProductions(List<String> productionIds){ |
| | | List<String> equipmentIds = this.list(new LambdaQueryWrapper<MdcProductionEquipment>() |
| | | .in(MdcProductionEquipment::getProductionId, productionIds)).stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); |
| | | if (!equipmentIds.isEmpty()) { |
| | | return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds)); |
| | | } |
| | | return null; |
| | | } |
| | | } |