Lius
2025-03-03 5ae1b71ab6b57140d46e6a8b9e606bb4a390ce27
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -1,6 +1,5 @@
package org.jeecg.modules.mdc.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -9,6 +8,7 @@
import org.jeecg.common.api.dto.message.MessageDTO;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.mdc.dto.MdcEquDepDto;
import org.jeecg.modules.mdc.dto.MdcEquProDto;
@@ -29,10 +29,7 @@
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.mapper.MdcEquipmentDepartMapper;
import org.jeecg.modules.system.mapper.MdcProductionEquipmentMapper;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.IMdcUserProductionService;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysUserDepartService;
import org.jeecg.modules.system.service.*;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -67,8 +64,6 @@
    @Resource
    private IMdcProductionService mdcProductionService;
    @Resource
    private IControlSystemService controlSystemService;
    @Resource
    private IEquipmentWorkLineService equipmentWorkLineService;
    @Resource
    private IMdcDriveTypeParamConfigService mdcDriveTypeParamConfigService;
@@ -77,9 +72,6 @@
    @Resource
    private IEquipmentLogService equipmentLogService;
    @Resource
    private IEquipmentBaseInfoService equipmentBaseInfoService;
    @Resource
    private ISysBaseAPI sysBaseApi;
@@ -93,6 +85,11 @@
    @Resource
    private IMdcOverrunAlarmService mdcOverrunAlarmService;
    @Resource
    private IEquipmentXYZService equipmentXYZService;
    @Resource
    private ISysDictService sysDictService;
    @Override
    public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) {
@@ -326,25 +323,35 @@
        List<MdcEquipmentMonitor> result = this.baseMapper.checkStatusFromEquipmentIds(equipmentIds);
        if (result != null && !result.isEmpty()) {
            for (MdcEquipmentMonitor mdcEquipmentMonitor : result) {
                if (mdcEquipmentMonitor.getOporation() != null) {
                    switch (mdcEquipmentMonitor.getOporation()) {
                        case 1:
                        case 2:
                            mdcEquipmentMonitor.setOporationDict("待机");
                            break;
                        case 3:
                            mdcEquipmentMonitor.setOporationDict("运行");
                            break;
                        case 22:
                            mdcEquipmentMonitor.setOporationDict("报警");
                            break;
                        default:
                            mdcEquipmentMonitor.setOporationDict("关机");
                            break;
                if (mdcEquipmentMonitor.getEquipmentStatus() == 0) {
                    if (mdcEquipmentMonitor.getOporation() != null) {
                        switch (mdcEquipmentMonitor.getOporation()) {
                            case 1:
                            case 2:
                                mdcEquipmentMonitor.setOporationDict("待机");
                                break;
                            case 3:
                                mdcEquipmentMonitor.setOporationDict("运行");
                                break;
                            case 22:
                                mdcEquipmentMonitor.setOporationDict("报警");
                                break;
                            default:
                                mdcEquipmentMonitor.setOporationDict("关机");
                                break;
                        }
                    } else {
                        mdcEquipmentMonitor.setOporationDict("关机");
                        mdcEquipmentMonitor.setOporation(0);
                    }
                } else {
                    mdcEquipmentMonitor.setOporationDict("关机");
                    mdcEquipmentMonitor.setOporation(0);
                    List<DictModel> dictList = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_EQUIPMENT_STATUS);
                    for (DictModel dictModel : dictList) {
                        if (Integer.valueOf(dictModel.getValue()).equals(mdcEquipmentMonitor.getEquipmentStatus())) {
                            mdcEquipmentMonitor.setOporationDict(dictModel.getLabel());
                            mdcEquipmentMonitor.setOporation(88);
                        }
                    }
                }
            }
        }
@@ -369,13 +376,16 @@
        String saveTableName = mdcEquipmentDetailedDto.getSaveTableName();
        Map<String, Object> mapData = equipmentWorkLineService.getDataList(saveTableName);
        if (mapData != null) {
            Map<String, Object> runData = new LinkedHashMap<>();
//            Map<String, Object> runData = new LinkedHashMap<>();
            List<Map<String, Object>> runData = new ArrayList<>();
            //获取 MDC 驱动对应的展示参数   并根据key 拼装从 workData  查询的数据
            List<MdcDriveTypeParamConfig> mdcDriveTypeParamList = mdcDriveTypeParamConfigService.getShowDriveParam(mdcEquipmentDetailedDto.getDriveType());
            if (mdcDriveTypeParamList != null && !mdcDriveTypeParamList.isEmpty()) {
                for (MdcDriveTypeParamConfig mdcDriveTypeParamConfig : mdcDriveTypeParamList) {
                    Map<String, Object> map = new LinkedHashMap<>();
                    String englishName = mdcDriveTypeParamConfig.getEnglishName();
                    String chineseName = mdcDriveTypeParamConfig.getChineseName();
                    map.put("key", chineseName);
                    if (mapData.containsKey(englishName)) {
                        Object object = mapData.get(englishName);
                        String value = "";
@@ -433,11 +443,45 @@
                        } else {
                            value = object == null ? "" : object.toString();
                        }
                        runData.put(chineseName, value);
                        map.put("value", value);
                        runData.add(map);
                        if ("spindlebeilv".equals(englishName) && !"".equals(value)) {
                            result.put("spindlebeilv", value);
                        }
                        if ("feedbeilv".equals(englishName) && !"".equals(value)) {
                            result.put("feedbeilv", value);
                        }
                        if ("spindleload".equals(englishName) && !"".equals(value)) {
                            result.put("spindleload", value);
                        }
                        if ("rapidfeed".equals(englishName) && !"".equals(value)) {
                            result.put("rapidfeed", value);
                        }
                    }
                }
            }
            result.put("runData", runData);
            // 查询坐标信息
            if (!"ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && !"CurrentState".equals(mdcEquipmentDetailedDto.getDriveType())) {
                EquipmentXYZ equipmentXYZ = equipmentXYZService.getByEquipmentId(mdcEquipmentDetailedDto.getEquipmentId());
                if (equipmentXYZ != null) {
                    Map<String, Object> map = new HashMap<>();
                    map.put("xmachine", equipmentXYZ.getXMachine());
                    map.put("ymachine", equipmentXYZ.getYMachine());
                    map.put("zmachine", equipmentXYZ.getZMachine());
                    map.put("amachine", equipmentXYZ.getAMachine());
                    map.put("bmachine", equipmentXYZ.getBMachine());
                    map.put("xabsolute", equipmentXYZ.getXAbsolute());
                    map.put("yabsolute", equipmentXYZ.getYAbsolute());
                    map.put("zabsolute", equipmentXYZ.getZAbsolute());
                    map.put("aabsolute", equipmentXYZ.getAAbsolute());
                    map.put("babsolute", equipmentXYZ.getBAbsolute());
                    result.put("xyzList", map);
                }
            }
        }
        return result;
    }
@@ -561,6 +605,9 @@
        }
        if (StringUtils.isNotEmpty(mdcEquipment.getEquipmentName())) {
            queryWrapper.like(MdcEquipment::getEquipmentName, mdcEquipment.getEquipmentName());
        }
        if (mdcEquipment.getEquipmentStatus() != null) {
            queryWrapper.eq(MdcEquipment::getEquipmentStatus, mdcEquipment.getEquipmentStatus());
        }
        if (!allEquipments.isEmpty()) {
            queryWrapper.in(MdcEquipment::getEquipmentId, allEquipments);
@@ -858,4 +905,15 @@
        return list.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList());
    }
    /**
     * 根据产线id获取设备状态列表
     *
     * @param workshopId
     * @return
     */
    @Override
    public List<MdcEquipmentMonitor> getEquipmentMonitorList(String workshopId) {
        return this.baseMapper.getEquipmentMonitorList(workshopId);
    }
}