Lius
2024-01-17 cf89583e4dd54632a0f11c06b859315c03958820
设备运行状态及利用率预警任务
已添加2个文件
已修改13个文件
373 ■■■■■ 文件已修改
lxzn-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunMonitoringSpeedJob.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningEquipmentStatusJob.java 150 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEfficiencyReportMapper.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java
@@ -577,4 +577,19 @@
     */
    String DICT_OPERATING_SPEED_RANGE = "operating_speed_range";
    /**
     * åˆ©ç”¨çŽ‡åˆ¤å®šé—´éš”å­—å…¸ç¼–å·
     */
    String DICT_EQUIPMENT_RATE_JUDGE = "equipment_rate_judge";
    /**
     * è®¾å¤‡çŠ¶æ€åˆ¤æ–­é—´éš”å­—å…¸ç¼–å·
     */
    String DICT_EQUIPMENT_SPEED_JUDGE = "equipment_status_judge";
    /**
     * åˆ©ç”¨çŽ‡æ­£å¸¸å€¼å­—å…¸ç¼–å·
     */
    String DICT_EQUIPMENT_RATE_NORMAL = "equipment_rate_normal";
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunMonitoringSpeedJob.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,63 @@
package org.jeecg.modules.mdc.job;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.mdc.util.ThrowableUtil;
import org.jeecg.modules.quartz.entity.QuartzJob;
import org.jeecg.modules.quartz.entity.SysQuartzLog;
import org.jeecg.modules.quartz.service.IQuartzJobService;
import org.jeecg.modules.quartz.service.ISysQuartzLogService;
import org.jeecg.modules.system.service.ISysAnnouncementService;
import org.quartz.*;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
 * @author Lius
 * @Description: ç›‘控设备转速任务
 * @date 2024/1/16 17:36
 */
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
@Slf4j
public class RunMonitoringSpeedJob implements Job {
    @Resource
    private IQuartzJobService quartzJobService;
    @Resource
    private ISysQuartzLogService sysQuartzLogService;
    @Resource
    private ISysAnnouncementService sysAnnouncementService;
    @Resource
    private IMdcEquipmentService mdcEquipmentService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        SysQuartzLog quartzLog = new SysQuartzLog();
        quartzLog.setCreateTime(new Date());
        List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName());
        if (byJobClassName != null && !byJobClassName.isEmpty()) {
            quartzLog.setJobId(byJobClassName.get(0).getId());
        }
        log.info("监控设备转速任务 RunMonitoringSpeedJob start!  æ—¶é—´:" + DateUtils.now());
        long startTime = System.currentTimeMillis();
        try {
            mdcEquipmentService.monitoringSpeedProcess();
            quartzLog.setIsSuccess(0);
        } catch (Exception e) {
            quartzLog.setIsSuccess(-1);
            quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e));
            // å‘送消息通知
            sysAnnouncementService.jobSendMessage("监控设备转速任务失败!", quartzLog.getExceptionDetail());
        }
        long endTime = System.currentTimeMillis();
        quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime)));
        sysQuartzLogService.save(quartzLog);
    }
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningEquipmentStatusJob.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,150 @@
package org.jeecg.modules.mdc.job;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
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.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.service.IMdcEquipmentRunningSectionService;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.mdc.service.MdcEfficiencyReportService;
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.util.ThrowableUtil;
import org.jeecg.modules.quartz.entity.QuartzJob;
import org.jeecg.modules.quartz.entity.SysQuartzLog;
import org.jeecg.modules.quartz.service.IQuartzJobService;
import org.jeecg.modules.quartz.service.ISysQuartzLogService;
import org.jeecg.modules.system.service.ISysAnnouncementService;
import org.jeecg.modules.system.service.ISysDictService;
import org.quartz.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
/**
 * @author Lius
 * @Description: åˆ©ç”¨çŽ‡æ­£å¸¸å€¼ï¼Œè®¾å¤‡çŠ¶æ€é•¿æœŸæ— å˜åŒ–æŠ¥è­¦
 * @date 2024/1/17 14:10
 */
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
@Slf4j
public class RunningEquipmentStatusJob implements Job {
    @Resource
    private IQuartzJobService quartzJobService;
    @Resource
    private ISysQuartzLogService sysQuartzLogService;
    @Resource
    private ISysAnnouncementService sysAnnouncementService;
    @Resource
    private IMdcEquipmentService mdcEquipmentService;
    @Resource
    private ISysDictService sysDictService;
    @Resource
    private MdcEfficiencyReportService mdcEfficiencyReportService;
    @Resource
    private ISysBaseAPI sysBaseApi;
    @Resource
    private IMdcEquipmentRunningSectionService mdcEquipmentRunningSectionService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        SysQuartzLog quartzLog = new SysQuartzLog();
        quartzLog.setCreateTime(new Date());
        List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName());
        if (byJobClassName != null && !byJobClassName.isEmpty()) {
            quartzLog.setJobId(byJobClassName.get(0).getId());
        }
        log.info("设备状态长期无变化报警任务 RunningEquipmentStatusJob start!  æ—¶é—´:" + DateUtils.getNow());
        long startTime = System.currentTimeMillis();
        try {
            //List<MdcEquipment> equipmentList = mdcEquipmentService.list(new LambdaQueryWrapper<>());
            List<MdcEquipment> equipmentList = mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, "2140198"));
            // èŽ·å–åˆ©ç”¨çŽ‡åˆ¤å®šå¤©æ•°
            List<DictModel> dictModelList1 = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_EQUIPMENT_RATE_JUDGE);
            Integer equipmentRateJudge = 5;
            if (dictModelList1 != null && !dictModelList1.isEmpty()) {
                equipmentRateJudge = Integer.valueOf(dictModelList1.get(0).getValue());
            }
            // èŽ·å–åˆ©ç”¨çŽ‡æ­£å¸¸å€¼
            List<DictModel> dictModelList2 = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_EQUIPMENT_SPEED_JUDGE);
            Integer equipmentRateNormal = 20;
            if (dictModelList2 != null && !dictModelList2.isEmpty()) {
                equipmentRateNormal = Integer.valueOf(dictModelList2.get(0).getValue());
            }
            // èŽ·å–è®¾å¤‡çŠ¶æ€å¤©æ•°
            List<DictModel> dictModelList3 = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_EQUIPMENT_RATE_NORMAL);
            Integer equipmentStatusJudge = 5;
            if (dictModelList3 != null && !dictModelList3.isEmpty()) {
                equipmentStatusJudge = Integer.valueOf(dictModelList3.get(0).getValue());
            }
            for (MdcEquipment mdcEquipment : equipmentList) {
                // åˆ¤æ–­åˆ©ç”¨çއ
                String date = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-equipmentRateJudge).toString(), DateUtils.STR_DATE), DateUtils.STRDATE);
                List<BigDecimal> efficiencyRateList = mdcEfficiencyReportService.getEfficiencyRate(mdcEquipment.getEquipmentId(), date);
                if (efficiencyRateList != null && !efficiencyRateList.isEmpty()) {
                    boolean flag = true;
                    for (BigDecimal processLong : efficiencyRateList) {
                        BigDecimal efficiencyRate = processLong.divide(new BigDecimal("86400"), 4, RoundingMode.HALF_UP);
                        if (efficiencyRate.compareTo(new BigDecimal(equipmentRateNormal)) > -1) {
                            flag = false;
                        }
                    }
                    if (flag) {
                        // ä¸ŠæŠ¥
                        MessageDTO messageDTO = new MessageDTO();
                        messageDTO.setCategory("预警消息");
                        messageDTO.setFromUser("admin");
                        messageDTO.setToUser("admin");
                        messageDTO.setContent("设备编号为 [" + mdcEquipment.getEquipmentId() + "] çš„设备利用率低于正常值报警!");
                        sysBaseApi.sendSysAnnouncement(messageDTO);
                    }
                }
                // åˆ¤æ–­è®¾å¤‡çŠ¶æ€
                Date date1 = DateUtils.toDate(LocalDate.now().plusDays(-equipmentStatusJudge).toString(), DateUtils.STR_DATE);
                List<Integer> sectionList = mdcEquipmentRunningSectionService.getDataList(mdcEquipment.getEquipmentId(), date1);
                if (sectionList != null && !sectionList.isEmpty() && sectionList.size() > 1) {
                    boolean flag = true;
                    Integer integer = sectionList.get(0);
                    for (Integer integer1 : sectionList) {
                        if (!integer.equals(integer1)) {
                            flag = false;
                        }
                    }
                    if (flag) {
                        // ä¸ŠæŠ¥
                        MessageDTO messageDTO = new MessageDTO();
                        messageDTO.setCategory("预警消息");
                        messageDTO.setFromUser("admin");
                        messageDTO.setToUser("admin");
                        messageDTO.setContent("设备编号为 [" + mdcEquipment.getEquipmentId() + "] çš„设备状态长期无变化报警!");
                        sysBaseApi.sendSysAnnouncement(messageDTO);
                    }
                }
            }
            quartzLog.setIsSuccess(0);
        } catch (Exception e) {
            quartzLog.setIsSuccess(-1);
            quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e));
            // å‘送消息通知
            sysAnnouncementService.jobSendMessage("设备状态长期无变化报警任务失败!", quartzLog.getExceptionDetail());
        }
        long endTime = System.currentTimeMillis();
        quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime)));
        sysQuartzLogService.save(quartzLog);
    }
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEfficiencyReportMapper.java
@@ -3,12 +3,12 @@
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.mdc.dto.MdcComAnaDto;
import org.jeecg.modules.mdc.dto.MdcEfficiencyDto;
import org.jeecg.modules.mdc.dto.MdcEfficiencyResultDto;
import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo;
import org.jeecg.modules.mdc.vo.ComparativeAnalysisQueryVo;
import org.jeecg.modules.mdc.vo.MdcEfficiencyReportQueryVo;
import org.jeecg.modules.mdc.vo.MdcEfficiencyReportShiftQueryVo;
import java.math.BigDecimal;
import java.util.List;
/**
@@ -48,4 +48,6 @@
     * @return
     */
    List<MdcComAnaDto> comparativeAnalysis(@Param("vo") ComparativeAnalysisQueryVo vo);
    List<BigDecimal> getEfficiencyRate(@Param("equipmentId") String equipmentId, @Param("date") String date);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java
@@ -1,11 +1,13 @@
package org.jeecg.modules.mdc.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.mdc.dto.MdcEquDepDto;
import org.jeecg.modules.mdc.dto.MdcEquProDto;
import org.jeecg.modules.mdc.dto.MdcEquipmentDto;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor;
import org.jeecg.modules.mdc.vo.MdcEquipmentDepVo;
@@ -93,4 +95,7 @@
     * åˆ†é¡µåˆ—表
     */
    IPage<MdcEquipment> pageList(Page<MdcEquipment> page, @Param("mdcEquipment") MdcEquipmentVo mdcEquipment);
    @InterceptorIgnore(tenantLine = "1")
    MdcEquipmentDto getWorkLineLast(@Param("tableName") String saveTableName);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java
@@ -73,4 +73,6 @@
    List<MdcEquipmentRunningSection> selectRunningData(@Param("equipmentId") String equipmentId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
    List<MdcAlarmListDto> selectAlarmList(@Param("vo") MdcAlarmAnalyzeQueryVo mdcAlarmAnalyzeQueryVo, @Param("startDate") String startDate, @Param("endDate") String endDate);
    List<Integer> getDataList(@Param("equipmentId") String equipmentId, @Param("date") Date date);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml
@@ -148,4 +148,15 @@
        GROUP BY
            mesi.equipment_id
    </select>
    <select id="getEfficiencyRate" resultType="java.math.BigDecimal">
        SELECT
            process_long
        FROM
            mdc_equipment_statistical_info
        WHERE
            equipment_id = #{ equipmentId } AND the_date &gt;= #{ date }
        ORDER BY the_date ASC
    </select>
</mapper>
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml
@@ -246,4 +246,8 @@
    </select>
    <select id="getWorkLineLast" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentDto">
        select top 1 spindlespeed, actualspindlespeed from [${tableName}] order by CollectTime  desc
    </select>
</mapper>
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml
@@ -162,5 +162,16 @@
        </where>
    </select>
    <select id="getDataList" resultType="java.lang.Integer">
        SELECT
            status
        FROM
            mdc_equipment_running_section
        WHERE
            equipment_id = #{ equipmentId }
          AND start_time &gt; #{date}
          AND status IS NOT NULL
    </select>
</mapper>
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java
@@ -85,4 +85,7 @@
    List<MdcEquipmentRunningSection> selectRunningData(String equipmentId, Date startDate, Date endDate);
    List<MdcAlarmListDto> selectAlarmList(MdcAlarmAnalyzeQueryVo mdcAlarmAnalyzeQueryVo, String startDate, String endDate);
    List<Integer> getDataList(String equipmentId, Date date);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java
@@ -176,4 +176,11 @@
     * åˆ—表查询
     */
    IPage<MdcEquipment> pageList(Page<MdcEquipment> page, MdcEquipmentVo mdcEquipment, HttpServletRequest req);
    /**
     * ç›‘控设备转速任务
     */
    void monitoringSpeedProcess();
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java
@@ -4,6 +4,9 @@
import org.jeecg.modules.mdc.dto.DayUtilizationRateDto;
import org.jeecg.modules.mdc.vo.*;
import java.math.BigDecimal;
import java.util.List;
/**
 * @author: LiuS
 * @create: 2023-06-15 17:25
@@ -90,4 +93,13 @@
     * @return
     */
    MdcUtilizationRateDto utilizationRateTrendAnalyze(String userId, DayUtilizationRateContrastQueryVo vo);
    /**
     * èŽ·å–åˆ©ç”¨çŽ‡
     *
     * @param equipmentId
     * @param date
     * @return
     */
    List<BigDecimal> getEfficiencyRate(String equipmentId, String date);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
@@ -1729,6 +1729,11 @@
        return result;
    }
    @Override
    public List<BigDecimal> getEfficiencyRate(String equipmentId, String date) {
        return mdcEfficiencyReportMapper.getEfficiencyRate(equipmentId, date);
    }
    private MdcUtilizationResultDto utilizationRate(String equipmentId, String equipmentName, String equipmentType, Date startTime, Date endTime, String date, List<MdcUtilizationRate> mdcUtilizationRateList) {
        MdcUtilizationResultDto dto = new MdcUtilizationResultDto();
        dto.setEquipmentId(equipmentId);
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java
@@ -697,6 +697,11 @@
        return this.baseMapper.selectAlarmList(mdcAlarmAnalyzeQueryVo, startDate, endDate);
    }
    @Override
    public List<Integer> getDataList(String equipmentId, Date date) {
        return this.baseMapper.getDataList(equipmentId, date);
    }
    private Map<String, List<MdcEquipmentRunningSectionDto>> logCharts(MdcEquipmentRunningSectionVo equipmentRunningSectionVo, String date) {
        Map<String, List<MdcEquipmentRunningSectionDto>> map = new HashMap<>();
        List<MdcEquipmentRunningSectionDto> normal = new ArrayList<>();
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -6,7 +6,10 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
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;
@@ -19,17 +22,17 @@
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.*;
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.system.entity.MdcEquipmentDepart;
import org.jeecg.modules.system.entity.MdcProduction;
import org.jeecg.modules.system.entity.MdcProductionEquipment;
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;
@@ -77,6 +80,13 @@
    @Resource
    private IEquipmentBaseInfoService equipmentBaseInfoService;
    @Resource
    private ISysDictService sysDictService;
    @Resource
    private ISysBaseAPI sysBaseApi;
    @Override
    public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) {
@@ -700,4 +710,60 @@
        return this.baseMapper.pageList(page, mdcEquipment);
    }
    /**
     * ç›‘控设备转速任务
     */
    @Override
    public void monitoringSpeedProcess() {
        List<MdcEquipment> equipmentList = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getDriveType, "FANUC"));
        //List<MdcEquipment> equipmentList = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, "2140198"));
        // èŽ·å–å­—å…¸æ•°æ®
        List<DictModel> dictModelList = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_OPERATING_SPEED_RANGE);
        Integer range = 0;
        if (dictModelList != null && !dictModelList.isEmpty()) {
            range = Integer.valueOf(dictModelList.get(0).getValue());
        }
        for (MdcEquipment mdcEquipment : equipmentList) {
            String saveTableName = mdcEquipment.getSaveTableName();
            //查询单表数据
            MdcEquipmentDto mdcEquipmentDto = this.baseMapper.getWorkLineLast(saveTableName);
            if (mdcEquipmentDto != null) {
                MessageDTO messageDTO = new MessageDTO();
                messageDTO.setTitle("设备运行转速报警!");
                messageDTO.setCategory("预警消息");
                messageDTO.setFromUser("admin");
                messageDTO.setToUser("admin");
                Integer spindlespeed = Integer.valueOf(mdcEquipmentDto.getSpindlespeed());
                Integer actualspindlespeed = Integer.valueOf(mdcEquipmentDto.getActualspindlespeed());
                if (range.equals(0)) {
                    if (spindlespeed > actualspindlespeed) {
                        // å®žé™…值大于设定值   é«˜
                        messageDTO.setContent("设备编号为 [" + mdcEquipment.getEquipmentId() + "] çš„设备运行转速高报警!");
                        sysBaseApi.sendSysAnnouncement(messageDTO);
                    } else if (spindlespeed < actualspindlespeed) {
                        // å®žé™…值小于设定值   ä½Ž
                        messageDTO.setContent("设备编号为 [" + mdcEquipment.getEquipmentId() + "] çš„设备运行转速低报警!");
                        sysBaseApi.sendSysAnnouncement(messageDTO);
                    }
                } else {
                    int max = actualspindlespeed + actualspindlespeed * (range / 100);
                    int min = actualspindlespeed - actualspindlespeed * (range / 100);
                    if (spindlespeed > max || spindlespeed < min) {
                        if (spindlespeed > actualspindlespeed) {
                            // å®žé™…值大于设定值   é«˜
                            messageDTO.setContent("设备编号为 [" + mdcEquipment.getEquipmentId() + "] çš„设备运行转速高报警!");
                            sysBaseApi.sendSysAnnouncement(messageDTO);
                        } else if (spindlespeed < actualspindlespeed) {
                            // å®žé™…值小于设定值   ä½Ž
                            messageDTO.setContent("设备编号为 [" + mdcEquipment.getEquipmentId() + "] çš„设备运行转速低报警!");
                            sysBaseApi.sendSysAnnouncement(messageDTO);
                        }
                    }
                }
            }
        }
    }
}