Lius
2024-03-14 1292cf73f7db223f35ab450eabeeedbf8802eb5a
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -21,10 +21,7 @@
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.util.FindsEquipmentDepartUtil;
import org.jeecg.modules.mdc.util.FindsEquipmentProductionUtil;
import org.jeecg.modules.mdc.vo.MdcEquipmentDepVo;
import org.jeecg.modules.mdc.vo.MdcEquipmentProVo;
import org.jeecg.modules.mdc.vo.MdcEquipmentVo;
import org.jeecg.modules.mdc.vo.WorkshopEquipmentVo;
import org.jeecg.modules.mdc.vo.*;
import org.jeecg.modules.system.entity.MdcEquipmentDepart;
import org.jeecg.modules.system.entity.MdcProduction;
import org.jeecg.modules.system.entity.MdcProductionEquipment;
@@ -759,8 +756,13 @@
                Map<String, Object> param = new HashMap<>();
                param.put("columns", builder.toString());
                param.put("tableName", saveTableName);
                Map<String, Object> map = this.baseMapper.getWorkLineLast(param);
                if (map != null) {
                Map<String, Object> map = new HashMap<>();
                try {
                    map = this.baseMapper.getWorkLineLast(param);
                } catch (Exception e) {
                    log.error("查询单表数据出差!", e);
                }
                if (!map.isEmpty()) {
                    for (MdcEquipmentThreshold mdcEquipmentThreshold : mdcEquipmentThresholdList) {
                        Integer actualValue = Integer.valueOf(map.get(mdcEquipmentThreshold.getEnglishName()).toString());
                        Integer max = mdcEquipmentThreshold.getMaxThreshold();
@@ -837,4 +839,85 @@
        return treeList;
    }
    /**
     * 查询单表数据
     * @param tableName
     * @return
     */
    @Override
    public MdcEquipmentDto getWorkLineLast(String tableName) {
        return this.baseMapper.findWorkLineLast(tableName);
    }
    /**
     * 设备运行状态统计
     */
    @Override
    public List<MdcCommonVo> getEquipmentStatusStatistics(String userId, String key) {
        List<MdcCommonVo> result = new ArrayList<>();
        MdcCommonVo mdcCommonVo1 = new MdcCommonVo();
        mdcCommonVo1.setName("关机");
        mdcCommonVo1.setValue(0);
        result.add(mdcCommonVo1);
        MdcCommonVo mdcCommonVo2 = new MdcCommonVo();
        mdcCommonVo2.setName("报警");
        mdcCommonVo2.setValue(0);
        result.add(mdcCommonVo2);
        MdcCommonVo mdcCommonVo3 = new MdcCommonVo();
        mdcCommonVo3.setName("待机");
        mdcCommonVo3.setValue(0);
        result.add(mdcCommonVo3);
        MdcCommonVo mdcCommonVo4 = new MdcCommonVo();
        mdcCommonVo4.setName("运行");
        mdcCommonVo4.setValue(0);
        result.add(mdcCommonVo4);
        MdcEquipmentStatusVo mdcEquipmentStatusVo = new MdcEquipmentStatusVo();
        List<String> equipmentIdList = this.getEquipmentIdsProduction(userId, key);
        if (equipmentIdList == null || equipmentIdList.isEmpty()) {
            return result;
        }
        List<EquipmentLog> logList = this.baseMapper.getEquipmentStatusList(equipmentIdList);
        if (logList != null && !logList.isEmpty()) {
            for (EquipmentLog equipmentLog : logList) {
                if (equipmentLog.getOporation() != null) {
                    switch (equipmentLog.getOporation()) {
                        case 1:
                        case 2:
                            mdcEquipmentStatusVo.setWaitCount(mdcEquipmentStatusVo.getWaitCount() + 1);
                            break;
                        case 3:
                            mdcEquipmentStatusVo.setRunCount(mdcEquipmentStatusVo.getRunCount() + 1);
                            break;
                        case 22:
                            mdcEquipmentStatusVo.setAlarmCount(mdcEquipmentStatusVo.getAlarmCount() + 1);
                            break;
                        default:
                            mdcEquipmentStatusVo.setCloseCount(mdcEquipmentStatusVo.getCloseCount() + 1);
                            break;
                    }
                } else {
                    mdcEquipmentStatusVo.setCloseCount(mdcEquipmentStatusVo.getCloseCount() + 1);
                }
            }
        }
        result.clear();
        MdcCommonVo mdcCommonVo5 = new MdcCommonVo();
        mdcCommonVo5.setName("关机");
        mdcCommonVo5.setValue(mdcEquipmentStatusVo.getCloseCount());
        result.add(mdcCommonVo5);
        MdcCommonVo mdcCommonVo6 = new MdcCommonVo();
        mdcCommonVo6.setName("报警");
        mdcCommonVo6.setValue(mdcEquipmentStatusVo.getAlarmCount());
        result.add(mdcCommonVo6);
        MdcCommonVo mdcCommonVo7 = new MdcCommonVo();
        mdcCommonVo7.setName("待机");
        mdcCommonVo7.setValue(mdcEquipmentStatusVo.getWaitCount());
        result.add(mdcCommonVo7);
        MdcCommonVo mdcCommonVo8 = new MdcCommonVo();
        mdcCommonVo8.setName("运行");
        mdcCommonVo8.setValue(mdcEquipmentStatusVo.getRunCount());
        result.add(mdcCommonVo8);
        return result;
    }
}