Kaynağa Gözat

补充提交

liuyaowen 1 yıl önce
ebeveyn
işleme
28179b9bbc

+ 2 - 2
src/main/java/com/yunfeiyun/agmp/iots/device/serviceImp/CqCbdDeviceImpl.java

@@ -375,8 +375,8 @@ public class CqCbdDeviceImpl extends DeviceAbstractImpl implements ICbdDevice {
         if (!isCbd) {
         if (!isCbd) {
             return "暂不处理吸虫塔设备";
             return "暂不处理吸虫塔设备";
         }
         }
-
-        jsonObject = makeTestData(jsonObject);
+        // 测试数据
+//        jsonObject = makeTestData(jsonObject);
 
 
         String cbdimgAddr = jsonObject.getString("Image");
         String cbdimgAddr = jsonObject.getString("Image");
         if (StringUtils.isEmpty(cbdimgAddr)) {
         if (StringUtils.isEmpty(cbdimgAddr)) {

+ 9 - 18
src/main/java/com/yunfeiyun/agmp/iots/device/serviceImp/YfQxzDeviceImpl.java

@@ -394,25 +394,16 @@ public class YfQxzDeviceImpl extends DeviceAbstractImpl implements IYfQxzDevice
 
 
         iIotDeviceService.updateIotDevice(newIotDevice);
         iIotDeviceService.updateIotDevice(newIotDevice);
         // 主动进行查询,以确保不是误判离线
         // 主动进行查询,以确保不是误判离线
+
         if("offline".equalsIgnoreCase(cmd)){
         if("offline".equalsIgnoreCase(cmd)){
-            new Thread(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        Thread.sleep(2*1000);
-                    }catch (InterruptedException e){
-                        e.printStackTrace();
-                    }
-                    //主动进行查询,以确保不是误判离线
-                    log.info("【YFQXZ】主动进行查询,以确保不是误判离线" + iotDeviceOld);
-                    YfQxzReqMsg reqMsg = new YfQxzReqMsg();
-                    JSONObject jobjParams = new JSONObject();
-                    jobjParams.put("type","data");
-                    reqMsg.setExt(jobjParams);
-
-                    publishMsg(iotDeviceOld, reqMsg);
-                }
-            }).start();
+            //主动进行查询,以确保不是误判离线
+            log.info("【YFQXZ】主动进行查询,以确保不是误判离线" + iotDeviceOld);
+            YfQxzReqMsg reqMsg = new YfQxzReqMsg();
+            JSONObject jobjParams = new JSONObject();
+            jobjParams.put("type","data");
+            reqMsg.setExt(jobjParams);
+
+            publishMsg(iotDeviceOld, reqMsg);
         }
         }
     }
     }
 
 

+ 9 - 5
src/main/java/com/yunfeiyun/agmp/iots/task/YbqScheduler.java

@@ -20,6 +20,7 @@ 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;
 
 
+import java.util.Arrays;
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
@@ -80,7 +81,7 @@ public class YbqScheduler {
         log.info("【开始执行】同步预测数据任务,当前时间: {}", startDate);
         log.info("【开始执行】同步预测数据任务,当前时间: {}", startDate);
         for (YbqTypeConst ybqTypeConst : ybqTypeConsts) {
         for (YbqTypeConst ybqTypeConst : ybqTypeConsts) {
             try {
             try {
-                log.debug("正在处理设备类型: {}", ybqTypeConst.getMessage());
+                log.info("正在处理设备类型: {}", ybqTypeConst.getMessage());
                 // 同步赤霉病设备预测数据
                 // 同步赤霉病设备预测数据
                 List<IotDevice> iotDevices = getDevListByServiceName(ybqTypeConst.getServiceName());
                 List<IotDevice> iotDevices = getDevListByServiceName(ybqTypeConst.getServiceName());
                 for (IotDevice iotDevice : iotDevices) {
                 for (IotDevice iotDevice : iotDevices) {
@@ -153,7 +154,7 @@ public class YbqScheduler {
                         //预测value
                         //预测value
                         jsonObject.put("computeValue", value);
                         jsonObject.put("computeValue", value);
                         iIotDeviceService.updateIotDeviceExtInfo(devBid, jsonObject.toString());
                         iIotDeviceService.updateIotDeviceExtInfo(devBid, jsonObject.toString());
-                        log.debug("设备ID={} 的预测数据处理成功,computeDate={}, value={}", iotDevice.getDevBid(), computeDate, value);
+                        log.info("设备ID={} 的预测数据处理成功,computeDate={}, value={}", iotDevice.getDevBid(), computeDate, value);
                     }
                     }
                 } catch (Exception e) {
                 } catch (Exception e) {
                     log.error("处理设备ID={} 的预测数据时出错: ", iotDevice.getDevBid(), e);
                     log.error("处理设备ID={} 的预测数据时出错: ", iotDevice.getDevBid(), e);
@@ -178,8 +179,10 @@ public class YbqScheduler {
      * 延迟10分钟再拉取
      * 延迟10分钟再拉取
      * 我们:从10分开始,每一个小时拉取一次
      * 我们:从10分开始,每一个小时拉取一次
      */
      */
-    @Scheduled(cron = "0 10/59 0/1 * * ? ")
+    //@Scheduled(cron = "0 10/59 0/1 * * ? ")
+    @Scheduled(cron = "0 0/2 0/1 * * ?")
     public void synReportData() {
     public void synReportData() {
+        synPredictedData();
         String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(new Date(), -20));
         String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(new Date(), -20));
         String endTime = DateUtils.dateTimeNow();
         String endTime = DateUtils.dateTimeNow();
         log.info("【开始】同步上报数据任务执行于 {}", endTime);
         log.info("【开始】同步上报数据任务执行于 {}", endTime);
@@ -270,7 +273,7 @@ public class YbqScheduler {
         try {
         try {
 
 
 
 
-            String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(new Date(), -600 * 20));
+            String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addDays(new Date(), -30*3));
             String endTime = DateUtils.dateTimeNow();
             String endTime = DateUtils.dateTimeNow();
 
 
             //预测数据的时间,20200101格式
             //预测数据的时间,20200101格式
@@ -315,7 +318,8 @@ public class YbqScheduler {
      */
      */
     public List<IotDevice> getDevListByServiceName(String serviceName) {
     public List<IotDevice> getDevListByServiceName(String serviceName) {
         log.debug("开始根据服务名称 [{}] 查询设备", serviceName);
         log.debug("开始根据服务名称 [{}] 查询设备", serviceName);
-        List<IotDevice> iotDevices = iIotDeviceService.selectAllDeviceByDeviceServiceName(serviceName);
+        List<String> devTypeBidList = Arrays.asList(serviceName);
+        List<IotDevice> iotDevices = iIotDeviceService.selectIotDeviceByDevtypeBidList(devTypeBidList);
         log.debug("根据服务名称 [{}] 查询到 {} 台设备", serviceName, iotDevices.size());
         log.debug("根据服务名称 [{}] 查询到 {} 台设备", serviceName, iotDevices.size());
         return iotDevices;
         return iotDevices;
     }
     }

+ 6 - 4
src/main/resources/mapper/IotDeviceMapper.xml

@@ -511,15 +511,17 @@
         and d.devDelstatus='0'
         and d.devDelstatus='0'
         group by d.devBid
         group by d.devBid
     </select>
     </select>
-    <select id="getDeviceCodesByConectionId" resultType="java.lang.String">
-        select  devCode from IotDevice where devconnBid=#{connectionId} and devDelstatus='0'
+    <select id="getDeviceCodesByDevconnBid" resultType="java.lang.String">
+        select  devCode from IotDevice where devconnBid=#{devconnBid} and devDelstatus='0'
     </select>
     </select>
-    <select id="getDevicesByConectionId" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
-                select  * from IotDevice where devconnBid=#{connectionId} and devDelstatus='0'
+    <select id="getDevicesByDevconnBid" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
+        select * from IotDevice where devconnBid=#{devconnBid} and devDelstatus='0'
     </select>
     </select>
     <select id="selectIotDeviceByDevtypeBidList" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
     <select id="selectIotDeviceByDevtypeBidList" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
         <include refid="selectIotDeviceVo"/>
         <include refid="selectIotDeviceVo"/>
         <where>
         <where>
+             devDelstatus='0'
+             and
             devtypeBid in
             devtypeBid in
             <foreach collection="list" open="(" separator="," close=")" item="item" index="index">
             <foreach collection="list" open="(" separator="," close=")" item="item" index="index">
                 #{item}
                 #{item}