zhangherong
2025-06-25 23855599412c4d61b38d78f0f3abd3430a48b5b1
lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionEquipmentServiceImpl.java
对比新文件
@@ -0,0 +1,88 @@
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;
    }
}