Lius
2025-03-03 5ae1b71ab6b57140d46e6a8b9e606bb4a390ce27
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
package org.jeecg.modules.screen.service.impl;
 
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.screen.dto.EquipmentStatusOverview;
import org.jeecg.modules.screen.service.MdcLargeScreenService;
import org.jeecg.modules.system.service.ISysDictService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * @Author: Lius
 * @CreateTime: 2025-02-28
 * @Description:
 */
@Service
public class MdcLargeScreenServiceImpl implements MdcLargeScreenService {
 
    @Resource
    private IMdcEquipmentService mdcEquipmentService;
 
    @Resource
    private ISysDictService sysDictService;
 
    /**
     * 设备状态情况
     *
     * @param workshopId
     * @return
     */
    @Override
    public EquipmentStatusOverview equipmentStatusOverview(String workshopId) {
        EquipmentStatusOverview equipmentStatusOverview = new EquipmentStatusOverview();
        List<MdcEquipmentMonitor> equipmentMonitorList = mdcEquipmentService.getEquipmentMonitorList(workshopId);
        if (equipmentMonitorList != null && !equipmentMonitorList.isEmpty()) {
            equipmentStatusOverview.setEquipmentCount(equipmentMonitorList.size());
            for (MdcEquipmentMonitor mdcEquipmentMonitor : equipmentMonitorList) {
                if (mdcEquipmentMonitor.getEquipmentStatus() == 0) {
                    if (mdcEquipmentMonitor.getOporation() != null) {
                        switch (mdcEquipmentMonitor.getOporation()) {
                            case 1:
                            case 2:
                                equipmentStatusOverview.setWaitCount(equipmentStatusOverview.getWaitCount() + 1);
                                break;
                            case 3:
                                equipmentStatusOverview.setRunCount(equipmentStatusOverview.getRunCount());
                                break;
                            case 22:
                                equipmentStatusOverview.setErrorCount(equipmentStatusOverview.getErrorCount() + 1);
                                break;
                            default:
                                equipmentStatusOverview.setCloseCount(equipmentStatusOverview.getCloseCount() + 1);
                                break;
                        }
                    } else {
                        equipmentStatusOverview.setCloseCount(equipmentStatusOverview.getCloseCount() + 1);
                        mdcEquipmentMonitor.setOporation(0);
                    }
                } else {
                    List<DictModel> dictList = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_EQUIPMENT_STATUS);
                    for (DictModel dictModel : dictList) {
                        if (Integer.valueOf(dictModel.getValue()).equals(mdcEquipmentMonitor.getEquipmentStatus())) {
                            equipmentStatusOverview.setRepairCount(equipmentStatusOverview.getRepairCount() + 1);
                        }
                    }
                }
            }
        }
        return equipmentStatusOverview;
    }
}