Parcourir la source

故障样本库加环境温度

xushili il y a 2 ans
Parent
commit
997445d110

+ 8 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/mapper/slave/Windturbinetestingpointai2Mapper.java

@@ -2,7 +2,13 @@ package com.gyee.impala.mapper.slave;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.impala.model.slave.Temperatureinfo;
 import com.gyee.impala.model.slave.Windturbinetestingpointai2;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -13,5 +19,6 @@ import com.gyee.impala.model.slave.Windturbinetestingpointai2;
  * @since 2022-03-02
  */
 public interface Windturbinetestingpointai2Mapper extends BaseMapper<Windturbinetestingpointai2> {
-
+    @Select("select * from temperatureinfo where name='环境温度'")
+    List<Temperatureinfo> getTemperature();
 }

+ 2 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/model/master/Casefault.java

@@ -67,6 +67,8 @@ public class Casefault extends Model<Casefault> implements ToData<Object> {
 
     private Float powerloos;
 
+    private Float temperature;
+
 
 
     /**

+ 2 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/model/master/Casefaultalg.java

@@ -71,6 +71,8 @@ public class Casefaultalg extends Model<Casefaultalg> {
 
     private Float powerloos;
 
+    private Float temperature;
+
 
     @Override
     protected Serializable pkVal() {

+ 110 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/model/slave/Temperatureinfo.java

@@ -0,0 +1,110 @@
+package com.gyee.impala.model.slave;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author gfhd
+ * @since 2022-09-20
+ */
+public class Temperatureinfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Short id;
+
+    private String tag;
+
+    private String windpowerstationid;
+
+    private String windturbineid;
+
+    private String component;
+
+    private String name;
+
+    private Short reasonablemaxval;
+
+    private Short maxval;
+
+    public Short getId() {
+        return id;
+    }
+
+    public void setId(Short id) {
+        this.id = id;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public void setTag(String tag) {
+        this.tag = tag;
+    }
+
+    public String getWindpowerstationid() {
+        return windpowerstationid;
+    }
+
+    public void setWindpowerstationid(String windpowerstationid) {
+        this.windpowerstationid = windpowerstationid;
+    }
+
+    public String getWindturbineid() {
+        return windturbineid;
+    }
+
+    public void setWindturbineid(String windturbineid) {
+        this.windturbineid = windturbineid;
+    }
+
+    public String getComponent() {
+        return component;
+    }
+
+    public void setComponent(String component) {
+        this.component = component;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Short getReasonablemaxval() {
+        return reasonablemaxval;
+    }
+
+    public void setReasonablemaxval(Short reasonablemaxval) {
+        this.reasonablemaxval = reasonablemaxval;
+    }
+
+    public Short getMaxval() {
+        return maxval;
+    }
+
+    public void setMaxval(Short maxval) {
+        this.maxval = maxval;
+    }
+
+    @Override
+    public String toString() {
+        return "Temperatureinfo{" +
+            "id = " + id +
+            ", tag = " + tag +
+            ", windpowerstationid = " + windpowerstationid +
+            ", windturbineid = " + windturbineid +
+            ", component = " + component +
+            ", name = " + name +
+            ", reasonablemaxval = " + reasonablemaxval +
+            ", maxval = " + maxval +
+        "}";
+    }
+}

+ 8 - 9
gyee-sample-impala/src/main/java/com/gyee/impala/schdule/TaskCasefaultReplenish.java

@@ -43,7 +43,7 @@ public class TaskCasefaultReplenish {
     @Resource
     private RemoteServiceBuilder remoteServiceBuilder;
 
-    @Scheduled(cron = "0 36 9 * * ?")
+    @Scheduled(cron = "0 15 3 * * ?")
     public void creatEndtime(){
         Calendar instance = Calendar.getInstance();
         instance.add(Calendar.DATE, -8);
@@ -119,23 +119,26 @@ public class TaskCasefaultReplenish {
         casefaultService.updateBatchById(casefaultList,300);
     }
 
-    @Scheduled(cron = "0 46 11 * * ?")
+    /**
+     * 计算损失电量
+     */
+    @Scheduled(cron = "0 35 3 * * ?")
     public void creatPowerloss(){
         List<Casefaultalg> casefaultalgList = new ArrayList<>();
         List<Casefault> casefaultList = new ArrayList<>();
 
         QueryWrapper<Casefaultalg> cfawrapper = new QueryWrapper<>();
-        cfawrapper.isNull("faultsecond");
+        cfawrapper.isNull("faultsecond").apply("starttime!=endtime");
         List<Casefaultalg> casefaultalgs = casefaultalgMapper.selectList(cfawrapper);
 
         QueryWrapper<Casefault> cfwrapper = new QueryWrapper<>();
-        cfwrapper.isNull("faultsecond");
+        cfwrapper.isNull("faultsecond").ne("endtime","").apply("starttime!=endtime");
         List<Casefault> casefaults = casefaultMapper.selectList(cfwrapper);
 
         QueryWrapper<Windturbinetestingpointai2> wpwrapper = new QueryWrapper<>();
         wpwrapper.eq("UNIFORMCODE", "RFDLLL").likeLeft("WINDPOWERSTATIONID", "FDC");
         List<Windturbinetestingpointai2> windturbinetestingpointai2s = windturbinetestingpointai2Mapper.selectList(wpwrapper);
-        //风机、理论日发电量
+        //风机id、理论日发电量
         Map<String, Windturbinetestingpointai2> collect = windturbinetestingpointai2s.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Function.identity()));
 
         for (Casefaultalg casefaultalg : casefaultalgs) {
@@ -165,11 +168,7 @@ public class TaskCasefaultReplenish {
         }
         casefaultalgService.updateBatchById(casefaultalgList,300);
 
-
-        int k = 0;
         for (Casefault casefault : casefaults) {
-            System.out.println(k);
-            k++;
             String starttime = casefault.getStarttime();
             String endtime = casefault.getEndtime();
             if(StringUtils.isEmpty(starttime)||StringUtils.isEmpty(endtime)) continue;

+ 14 - 4
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/CasefaultalgServiceImpl.java

@@ -16,19 +16,17 @@ import com.gyee.impala.mapper.slave.Windturbinetestingpointai2Mapper;
 import com.gyee.impala.model.custom.TsDoubleData;
 import com.gyee.impala.model.master.Casefault;
 import com.gyee.impala.model.master.Casefaultalg;
+import com.gyee.impala.model.slave.Temperatureinfo;
 import com.gyee.impala.model.slave.Windturbinetestingpointai2;
 import com.gyee.impala.service.master.CasefaultService;
 import com.gyee.impala.service.master.CasefaultalgService;
-import org.apache.ibatis.session.SqlSession;
 import org.apache.kudu.client.*;
-import org.mybatis.spring.SqlSessionTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -55,7 +53,6 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
 
     /**
      * 获取所有风机风速测点
-     * @return
      */
     @Cacheable("aisAI022")
     public Map<String, Windturbinetestingpointai2> getWindpointai2s() {
@@ -65,6 +62,15 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
         return ai2s.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Function.identity()));
     }
 
+    /**
+     * 获取所有风机环境温度测点
+     */
+    @Cacheable("aishjwd")
+    public Map<String, String> gethjwd() {
+        List<Temperatureinfo> temperature = windturbinetestingpointai2Mapper.getTemperature();
+        return temperature.stream().collect(Collectors.toMap(Temperatureinfo::getWindturbineid, Temperatureinfo::getTag));
+    }
+
     @Override
     public void insertBatch(List<Casefaultalg> list) {
         if (list == null || list.size() == 0)
@@ -85,7 +91,10 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
             for (Casefaultalg casefaultalg : list) {
                 Map<String,TsDoubleData> historySection = remoteServiceBuilder.adapter().getHistorySection(windpointai2s.get(casefaultalg.getWindturbineid()).getId(), DateUtil.str2DateTime(casefaultalg.getStarttime()).getTime());
                 TsDoubleData value = historySection.entrySet().iterator().next().getValue();
+                Map<String,TsDoubleData> historySectionHjwd = remoteServiceBuilder.adapter().getHistorySection(gethjwd().get(casefaultalg.getWindturbineid()), DateUtil.str2DateTime(casefaultalg.getStarttime()).getTime());
+                TsDoubleData valueHjwd = historySectionHjwd.entrySet().iterator().next().getValue();
                 casefaultalg.setSpeed(String.valueOf(value.getDoubleValue()));
+                casefaultalg.setTemperature((float) valueHjwd.getDoubleValue());
             }
             insert(list);
         } catch (Exception e) {
@@ -240,6 +249,7 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
             row.addObject("category", obj.getCategory());
             row.addObject("createtime", DateUtil.getCurrentDate());
             row.addObject("speed", obj.getSpeed());
+            row.addObject("temperature", obj.getTemperature());
 
             // 先不提交kudu
             kuduSession.apply(insert);