lyh
2025-06-30 e3a037adf3861fee78ad5478784f24e59cc598a2
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
88
89
90
91
92
93
94
95
96
package org.jeecg.modules.eam.service.impl;
 
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.jeecg.modules.eam.entity.Equipment;
import org.jeecg.modules.eam.entity.EquipmentMaintenancePlan;
import org.jeecg.modules.eam.entity.MaintenanceStandard;
import org.jeecg.modules.eam.entity.MaintenanceStandardDetail;
import org.jeecg.modules.eam.mapper.EamEquipmentMapper;
import org.jeecg.modules.eam.mapper.EquipmentMaintenancePlanDetailMapper;
import org.jeecg.modules.eam.mapper.EquipmentMaintenancePlanMapper;
import org.jeecg.modules.eam.service.IEquipmentMaintenancePlanService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.*;
 
/**
 * @Description: 保养计划
 * @Author: jeecg-boot
 * @Date:   2023-10-16
 * @Version: V1.0
 */
@Service
public class EquipmentMaintenancePlanServiceImpl extends ServiceImpl<EquipmentMaintenancePlanMapper, EquipmentMaintenancePlan> implements IEquipmentMaintenancePlanService {
 
    @Autowired
    private EquipmentMaintenancePlanMapper equipmentMaintenancePlanMapper;
    @Autowired
    private EquipmentMaintenancePlanDetailMapper equipmentMaintenancePlanDetailMapper;
    @Autowired
    private EamEquipmentMapper equipmentMapper;
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delMain(String id) {
        equipmentMaintenancePlanDetailMapper.deleteByMainId(id);
        equipmentMaintenancePlanMapper.deleteById(id);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delBatchMain(Collection<? extends Serializable> idList) {
        for(Serializable id:idList) {
            equipmentMaintenancePlanDetailMapper.deleteByMainId(id.toString());
            equipmentMaintenancePlanMapper.deleteById(id);
        }
    }
 
    @Override
    public List<MaintenanceStandardDetail> getCycle(String mainId, String type) {
        return baseMapper.getCycle(mainId,type);
    }
 
    @Override
    public Map<String,Object> getStandards(List<String> equipmentIds, String maintenanceType) {
        String msg = "";
        Map<String,Object> map = new HashMap<>(2);
        List<MaintenanceStandard> maintenanceStandards = new ArrayList<>();
        for(String equipmentId:equipmentIds){
            Equipment equipment = equipmentMapper.selectById(equipmentId);
            List<MaintenanceStandard> list = baseMapper.getStandards(equipmentId,maintenanceType);
            if(list.size()==0){
                msg = msg+"统一编码为"+equipment.getNum()+"的设备不存在生效保养标注;";
            }else if(list.size()>1){
                msg = msg+"统一编码为"+equipment.getNum()+"的设备存在多条生效保养标注;";
            }else {
                if(equipment.getIsLineEquip().equals("yes")&&maintenanceType.equals("3")){
                    String lineId = equipment.getLineId();
                    if(StringUtils.isNotBlank(lineId)){
                      List<MaintenanceStandard> lineStandard = baseMapper.getStandards(lineId,maintenanceType);
                        if(lineStandard.size()==0){
                            msg = msg+"统一编码为"+equipment.getNum()+"的设备不存在生效保养标注;";
                        }else if(list.size()>1){
                            msg = msg+"统一编码为"+equipment.getNum()+"的设备存在多条生效保养标注;";
                        }else{
                            maintenanceStandards.add(lineStandard.get(0));
                        }
                    }else {
                        msg = msg+"统一编码为"+equipment.getNum()+"的设备不存在生效保养标注;";
                    }
                }else{
                    maintenanceStandards.add(list.get(0));
                }
            }
 
        }
        map.put("records",maintenanceStandards);
        map.put("message",msg);
        return map ;
    }
 
 
 
}