Lius
2025-03-12 da82d77c6773f65aadfde810233615b602da655a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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.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;
    }
}