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 >= #{ 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 > #{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); } } } } } } }