|
@@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.huimv.video.dhicc.entity.SysTelecom;
|
|
import com.huimv.video.dhicc.entity.SysTelecom;
|
|
import com.huimv.video.dhicc.entity.SysTelecomEvent;
|
|
import com.huimv.video.dhicc.entity.SysTelecomEvent;
|
|
|
|
+import com.huimv.video.dhicc.entity.SysThreshold;
|
|
|
|
+import com.huimv.video.dhicc.mapper.SysTelecomEventMapper;
|
|
import com.huimv.video.dhicc.mapper.SysTelecomMapper;
|
|
import com.huimv.video.dhicc.mapper.SysTelecomMapper;
|
|
|
|
+import com.huimv.video.dhicc.mapper.SysThresholdMapper;
|
|
import com.huimv.video.dhicc.service.ISysTelecomEventService;
|
|
import com.huimv.video.dhicc.service.ISysTelecomEventService;
|
|
|
|
+import jdk.jfr.Threshold;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -22,14 +26,80 @@ import java.util.stream.Collectors;
|
|
public class SysTelcomEnentTimmer {
|
|
public class SysTelcomEnentTimmer {
|
|
@Autowired
|
|
@Autowired
|
|
private SysTelecomMapper sysTelecomMapper;
|
|
private SysTelecomMapper sysTelecomMapper;
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysTelecomEventMapper sysTelecomEventMapperMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private ISysTelecomEventService sysTelecomEventService;
|
|
private ISysTelecomEventService sysTelecomEventService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysThresholdMapper sysThresholdMapper ;
|
|
|
|
+ //检查烘干是否合格--找出时间 阈值直接计算
|
|
|
|
+ // @Scheduled(cron = " 0/10 * * * * ? ")
|
|
|
|
+ @Scheduled(cron = " 0 */59 * * * ? ")
|
|
|
|
+ private void checkOk() {
|
|
|
|
+
|
|
|
|
+ //拿对应牧场的阈值
|
|
|
|
+ LambdaQueryWrapper<SysThreshold> wrapper1 = Wrappers.lambdaQuery();
|
|
|
|
+ wrapper1.eq(SysThreshold::getFarmId, 1);
|
|
|
|
+ SysThreshold sysThreshold = sysThresholdMapper.selectOne(wrapper1);//System.out.println(sysTelecoms);
|
|
|
|
+ // System.out.println("yuzhi"+sysThreshold);
|
|
|
|
+
|
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ Calendar TimeDeviceId = Calendar.getInstance();
|
|
|
|
+ TimeDeviceId.setTime(new Date());
|
|
|
|
+ TimeDeviceId.add(Calendar.HOUR_OF_DAY, -300);
|
|
|
|
+ Date began1time = TimeDeviceId.getTime();
|
|
|
|
+ String startTime1 = format.format(began1time);
|
|
|
|
+ String endTime1 = format.format(new Date());
|
|
|
|
+
|
|
|
|
+ //拿事件
|
|
|
|
+ LambdaQueryWrapper<SysTelecomEvent> wrapper = Wrappers.lambdaQuery();
|
|
|
|
+ wrapper.eq(SysTelecomEvent::getFarmId, 1);
|
|
|
|
+ wrapper.between(SysTelecomEvent::getEventTime, startTime1, endTime1);
|
|
|
|
+ List<SysTelecomEvent> SysTelecomEvent = sysTelecomEventMapperMapper.selectList(wrapper);//System.out.println(sysTelecoms);
|
|
|
|
+ // System.out.println("yuzhi"+SysTelecomEvent);
|
|
|
|
+
|
|
|
|
+ for (SysTelecomEvent sysTelecomEvent : SysTelecomEvent) {
|
|
|
|
+ // System.out.println("yuzhi"+sysTelecomEvent);
|
|
|
|
+ Calendar eventTime = Calendar.getInstance();
|
|
|
|
+ eventTime.setTime(sysTelecomEvent.getEventTime());
|
|
|
|
+ //事件时间就是开始时间
|
|
|
|
+ String EventStartTime = format.format(sysTelecomEvent.getEventTime());
|
|
|
|
+ //一次烘干50度以上一般在8次左右 就是说40分钟 这里取一小时
|
|
|
|
+ eventTime.add(Calendar.MINUTE, +60);
|
|
|
|
+ Date EventEndTime1 = eventTime.getTime();
|
|
|
|
+ String EventEndTime = format.format(EventEndTime1);
|
|
|
|
+
|
|
|
|
+ //查第一次五十度事件之后的数据 统计持续在设定温度之上的事件
|
|
|
|
+ LambdaQueryWrapper<SysTelecom> wrapper3 = Wrappers.lambdaQuery();
|
|
|
|
+ wrapper3.eq(SysTelecom::getDeviceId, sysTelecomEvent.getDeviceId());
|
|
|
|
+ wrapper3.eq(SysTelecom::getFarmId, 1);
|
|
|
|
+ wrapper3.between(SysTelecom::getTimestamp, EventStartTime, EventEndTime);
|
|
|
|
+ List<SysTelecom> sysTelecoms = sysTelecomMapper.selectList(wrapper3);//System.out.println(sysTelecoms);
|
|
|
|
+
|
|
|
|
+ Integer count =0;
|
|
|
|
+ for (SysTelecom sysTelecom : sysTelecoms) {
|
|
|
|
+ if (Double.parseDouble(sysTelecom.getTemp())>Double.parseDouble(sysThreshold.getBenconValue())){
|
|
|
|
+ count++;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if( Double.parseDouble(sysThreshold.getBenconValue())< count*5){
|
|
|
|
+ // System.out.println("高于阈值温度时间"+count*5);
|
|
|
|
+ //正确烘干为1
|
|
|
|
+ sysTelecomEvent.setRemark("1");
|
|
|
|
+ }else { sysTelecomEvent.setRemark("0");}
|
|
|
|
+
|
|
|
|
+ sysTelecomEventService.updateById(sysTelecomEvent);
|
|
|
|
+
|
|
|
|
+ //System.out.println("事件时间=" + EventStartTime + sysTelecoms);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//每小时执行一次
|
|
//每小时执行一次
|
|
//@Scheduled(cron = " 0 */59 * * * ? ")
|
|
//@Scheduled(cron = " 0 */59 * * * ? ")
|
|
// @Scheduled(cron = " 0/5 * * * * ? ")
|
|
// @Scheduled(cron = " 0/5 * * * * ? ")
|
|
- //@Scheduled(cron = " 0/50 * * * * ? ")
|
|
|
|
|
|
+ // @Scheduled(cron = " 0/50 * * * * ? ")
|
|
private void updateBox() {
|
|
private void updateBox() {
|
|
//获得设备列表 查找烘干数据
|
|
//获得设备列表 查找烘干数据
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
@@ -83,6 +153,7 @@ public class SysTelcomEnentTimmer {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|