Browse Source

Merge remote-tracking branch 'origin/master'

全业务考评 1 year ago
parent
commit
764dbc641e
17 changed files with 596 additions and 56 deletions
  1. 56 45
      power-fitting-JN/src/main/java/com.gyee.power.fitting/common/alg/WindDirectionALG.java
  2. 3 2
      power-fitting-JN/src/main/java/com.gyee.power.fitting/controller/alarm/AlarmTsController.java
  3. 187 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/dispersionanalysis/CalculateTask.java
  4. 7 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/mapper/AlarmTsMapper.java
  5. 24 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/mapper/StateCauseMapper.java
  6. 181 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/model/StateCause.java
  7. 2 1
      power-fitting-JN/src/main/java/com.gyee.power.fitting/model/custom/PowerPointData.java
  8. 2 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/IAlarmTsService.java
  9. 20 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/IStateCauseService.java
  10. 4 1
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/ProBasicEquipmentPointService.java
  11. 2 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/ProBasicEquipmentService.java
  12. 3 3
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/custom/curve/NewDataFittingService.java
  13. 17 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/AlarmTsServiceImpl.java
  14. 15 2
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/ProBasicEquipmentPointServiceImpl.java
  15. 7 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/ProBasicEquipmentServiceImpl.java
  16. 59 0
      power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/StateCauseServiceImpl.java
  17. 7 2
      power-fitting-JN/src/main/resources/application.yaml

+ 56 - 45
power-fitting-JN/src/main/java/com.gyee.power.fitting/common/alg/WindDirectionALG.java

@@ -55,15 +55,21 @@ public class WindDirectionALG {
      * @return
      */
     public static int[] fxRadarRoses(List<PowerPointData> list){
-        int[] count = new int[16];
-        list.stream().sorted(Comparator.comparing(PowerPointData::getSpeed)).forEach(item -> {
-            int df = windDFAngle(item.getDfwc());
-            if (count[df] < 1000) {
-                count[df]++;
-            }
-        });
 
-        return count;
+        try {
+            int[] count = new int[16];
+            list.stream().sorted(Comparator.comparing(PowerPointData::getSpeed)).forEach(item -> {
+                int df = windDFAngle(item.getDfwc());
+                if (count.length > df && count[df] < 1000) {
+                    count[df]++;
+                }
+            });
+            return count;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+
     }
 
 
@@ -129,47 +135,52 @@ public class WindDirectionALG {
      * @return
      */
     public static Map<String, Object> windDeviationPoint(List<PowerPointData> points){
-        List<PowerPointData> list = new ArrayList<>();
-        List<Object> temp = new ArrayList<>();
-        Map<String, Object> result = new HashMap<>();
-        Map<Integer, double[]> map = new LinkedHashMap<>();
-
-        //过滤对风偏差
-        for (int i = 0; i < points.size(); i++){
-            PowerPointData item = points.get(i);
-            if ((item.getSpeed() < 4.5 || item.getSpeed() >= 10.5) && item.getMxzt() != 2)
-                continue;
-
-            list.add(item);
-            Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
-            if (!map.containsKey(speed))
-                map.put(speed, new double[2]);  //[0]最小值 [1]最大值
-
-            double[] value = map.get(speed);
-            double power = item.getPower() < 0 ? 0 : item.getPower();
-            value[0] = power < value[0] ? power : value[0]; //最小值
-            value[1] = power > value[1] ? power : value[1]; //最大值
-        }
+        try {
+            List<PowerPointData> list = new ArrayList<>();
+            List<Object> temp = new ArrayList<>();
+            Map<String, Object> result = new HashMap<>();
+            Map<Integer, double[]> map = new LinkedHashMap<>();
+
+            //过滤对风偏差
+            for (int i = 0; i < points.size(); i++){
+                PowerPointData item = points.get(i);
+                if ((item.getSpeed() < 4.5 || item.getSpeed() >= 10.5) && item.getMxzt() != 2)
+                    continue;
+
+                list.add(item);
+                Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
+                if (!map.containsKey(speed))
+                    map.put(speed, new double[2]);  //[0]最小值 [1]最大值
 
-        int avg = 0;
-        DecimalFormat sf = new DecimalFormat("0.00");
-        for (int i = 0; i < list.size(); i++){
-            PowerPointData item = list.get(i);
-            Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
-            int ele = (int) (Math.abs(item.getFx()) + Math.abs(item.getAngle()));
-            int index = ele - 180;
-            if (index >= -30 && index <= 30 && item.getPower() > 0) {
-                avg += index;
                 double[] value = map.get(speed);
-                double v = (item.getPower() - value[0]) / (value[1] - value[0]);
-                double s[] = {speed, index, Double.valueOf(sf.format(v)).doubleValue()};
-                temp.add(s);
+                double power = item.getPower() < 0 ? 0 : item.getPower();
+                value[0] = power < value[0] ? power : value[0]; //最小值
+                value[1] = power > value[1] ? power : value[1]; //最大值
             }
-        }
-        result.put("data", temp);
-        result.put("avg", temp.size() > 0 ? avg/temp.size() : 0);
 
-        return result;
+            int avg = 0;
+            DecimalFormat sf = new DecimalFormat("0.00");
+            for (int i = 0; i < list.size(); i++){
+                PowerPointData item = list.get(i);
+                Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
+                int ele = (int) (Math.abs(item.getFx()) + Math.abs(item.getAngle()));
+                int index = ele - 180;
+                if (index >= -30 && index <= 30 && item.getPower() > 0) {
+                    avg += index;
+                    double[] value = map.get(speed);
+                    double v = (item.getPower() - value[0]) / (value[1] - value[0]);
+                    double s[] = {speed, index, Double.valueOf(sf.format(v)).doubleValue()};
+                    temp.add(s);
+                }
+            }
+            result.put("data", temp);
+            result.put("avg", temp.size() > 0 ? avg/temp.size() : 0);
+
+            return result;
+        } catch (NumberFormatException e) {
+            e.printStackTrace();
+        }
+        return null;
     }
 
 

+ 3 - 2
power-fitting-JN/src/main/java/com.gyee.power.fitting/controller/alarm/AlarmTsController.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.gyee.power.fitting.common.result.JsonResult;
 import com.gyee.power.fitting.common.result.ResultCode;
 import com.gyee.power.fitting.model.vo.AlarmTsVo;
+import com.gyee.power.fitting.model.vo.AlarmVo;
 import com.gyee.power.fitting.service.IAlarmTsService;
 import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,8 +30,8 @@ public class AlarmTsController {
      * @return
      */
     @GetMapping("getData")
-    public JSONObject dataProcessTree(String superTableName, String stationid, long begin, long end){
-        List<AlarmTsVo> result = alarmTsService.selectByWpGroup(superTableName,stationid,begin,end);
+    public JSONObject dataProcessTree(String superTableName, String stationid,String deviceid, long begin, long end){
+        List<AlarmVo> result = alarmTsService.findTagsByDeviceid(superTableName,stationid,deviceid,begin,end);
         return JsonResult.successData(ResultCode.SUCCESS, result);
     }
 

+ 187 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/dispersionanalysis/CalculateTask.java

@@ -0,0 +1,187 @@
+package com.gyee.power.fitting.dispersionanalysis;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.power.fitting.common.feign.RemoteServiceBuilder;
+import com.gyee.power.fitting.model.ProBasicEquipment;
+import com.gyee.power.fitting.model.ProBasicEquipmentPoint;
+import com.gyee.power.fitting.model.StateCause;
+import com.gyee.power.fitting.model.custom.TsDoubleData;
+import com.gyee.power.fitting.service.IStateCauseService;
+import com.gyee.power.fitting.service.ProBasicEquipmentPointService;
+import com.gyee.power.fitting.service.ProBasicEquipmentService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Component
+public class CalculateTask {
+    @Resource
+    private IStateCauseService stateCauseService;
+    @Resource
+    private ProBasicEquipmentService proBasicEquipmentService;
+    @Resource
+    private ProBasicEquipmentPointService proBasicEquipmentPointService;
+    @Resource
+    private RemoteServiceBuilder remoteService;
+
+    //秒 分 时 日 月 周
+    @Scheduled(cron = "0 06 15 * * ?")
+    public void doTask() {
+        List<ProBasicEquipment> equipmentList = proBasicEquipmentService.getCacheList();
+        Map<String, ProBasicEquipmentPoint> sbztMap = proBasicEquipmentPointService.getEquipmentMapByUniformcode("SBZT");
+        Map<String, ProBasicEquipmentPoint> mxztMap = proBasicEquipmentPointService.getEquipmentMapByUniformcode("MXZT");
+        //获取最新更新时间
+        QueryWrapper<StateCause> scWrapper = new QueryWrapper<>();
+        scWrapper.select("last_row(end_time) end_time").groupBy("equipment_id");
+        List<StateCause> scList = stateCauseService.list(scWrapper);
+        Map<String, StateCause> stateCauseMap;
+        if (scList.isEmpty()) {
+            stateCauseMap = new HashMap<>();
+        } else {
+            stateCauseMap = scList.stream().collect(Collectors.toMap(StateCause::getEquipmentId, Function.identity()));
+        }
+
+        String equipmentId, tbName;
+        long starttime, endtime = DateUtil.date().getTime();
+        List<StateCause> stateCauseList = new ArrayList<>();
+
+        for (ProBasicEquipment equipment : equipmentList) {
+            equipmentId = equipment.getId();
+            StateCause stateCause = stateCauseMap.get(equipmentId);
+            if (stateCause == null) {
+                starttime = DateUtil.yesterday().getTime();
+            } else {
+                starttime = stateCause.getEndTime() != null ? stateCause.getEndTime().getTime() - 6000 : DateUtil.yesterday().getTime();
+            }
+            List<TsDoubleData> datas8 = getDatas(sbztMap.get(equipmentId).getNemCode(), starttime, endtime);
+
+            tbName = equipmentId + "_SC_CI08";
+            if (CollUtil.isNotEmpty(datas8)) {
+                TsDoubleData remove = datas8.remove(0);
+                long ts0 = remove != null ? remove.getTs() : starttime;
+                long ts1;
+                int doubleValue1;
+                for (TsDoubleData data : datas8) {
+                    ts1 = data.getTs();
+                    doubleValue1 = (int) data.getDoubleValue();
+
+                    //0待机, 1运行, 2故障, 3检修, 4限电, 5受累, 6离线
+                    if (doubleValue1 == 1) {
+                        stateCauseList.add(new StateCause(tbName, 1, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 2) {
+                        stateCauseList.add(new StateCause(tbName, 2, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 3) {
+                        stateCauseList.add(new StateCause(tbName, 3, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 4) {
+                        stateCauseList.add(new StateCause(tbName, 4, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 5) {
+                        stateCauseList.add(new StateCause(tbName, 5, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 6) {
+                        stateCauseList.add(new StateCause(tbName, 6, ts1, ts0, ts0 - ts1));
+                    } else {
+                        stateCauseList.add(new StateCause(tbName, 0, ts1, ts0, ts0 - ts1));
+                    }
+                    if (ts1 <= starttime) break;
+                    ts0 = ts1;
+                }
+            }
+
+            List<TsDoubleData> datas14 = getDatas(mxztMap.get(equipmentId).getNemCode(), starttime, endtime);
+
+            tbName = equipmentId + "_SC_CI14";
+            if (CollUtil.isNotEmpty(datas14)) {
+                TsDoubleData remove = datas14.remove(0);
+                long ts0 = remove != null ? remove.getTs() : starttime;
+                long ts1;
+                int doubleValue1;
+                for (TsDoubleData data : datas14) {
+                    ts1 = data.getTs();
+                    doubleValue1 = (int) data.getDoubleValue();
+
+                    //0待机, 1手动停机, 2正常发电, 3发电降出力, 4故障, 5故障受累, 6检修, 7检修受累, 8限电降出力, 9限电停机, 10电网受累, 11环境受累, 12通讯中断, 13设备离线
+                    if (doubleValue1 == 1) {
+                        stateCauseList.add(new StateCause(tbName, 1, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 2) {
+                        stateCauseList.add(new StateCause(tbName, 2, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 3) {
+                        stateCauseList.add(new StateCause(tbName, 3, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 4) {
+                        stateCauseList.add(new StateCause(tbName, 4, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 5) {
+                        stateCauseList.add(new StateCause(tbName, 5, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 6) {
+                        stateCauseList.add(new StateCause(tbName, 6, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 7) {
+                        stateCauseList.add(new StateCause(tbName, 7, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 8) {
+                        stateCauseList.add(new StateCause(tbName, 8, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 9) {
+                        stateCauseList.add(new StateCause(tbName, 9, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 10) {
+                        stateCauseList.add(new StateCause(tbName, 10, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 11) {
+                        stateCauseList.add(new StateCause(tbName, 11, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 12) {
+                        stateCauseList.add(new StateCause(tbName, 12, ts1, ts0, ts0 - ts1));
+                    } else if (doubleValue1 == 13) {
+                        stateCauseList.add(new StateCause(tbName, 13, ts1, ts0, ts0 - ts1));
+                    } else {
+                        stateCauseList.add(new StateCause(tbName, 0, ts1, ts0, ts0 - ts1));
+                    }
+                    if (ts1 <= starttime) break;
+                    ts0 = ts1;
+                }
+            }
+        }
+        stateCauseService.saveBatch(stateCauseList);
+    }
+
+    private List<TsDoubleData> getDatas(String nemCode, long starttime, long endtime) {
+        List<TsDoubleData> rawValuesByKey;
+        if (nemCode.startsWith("GF")) {
+            rawValuesByKey = remoteService.adaptergf().getRawValuesByKey(nemCode, starttime, endtime);
+        } else {
+            rawValuesByKey = remoteService.adapterfd().getRawValuesByKey(nemCode, starttime, endtime);
+        }
+        rawValuesByKey.sort(Comparator.comparing(TsDoubleData::getTs).reversed());
+        return rawValuesByKey;
+    }
+
+    //秒 分 时 日 月 周
+    //@Scheduled(cron = "0 06 15 * * ?")
+    public void creatStables() {
+        List<ProBasicEquipment> equipmentList = proBasicEquipmentService.getCacheList();
+
+        String equipmentId, tbName;
+        List<StateCause> stateCauseList = new ArrayList<>();
+
+        for (ProBasicEquipment equipment : equipmentList) {
+            equipmentId = equipment.getId();
+
+            tbName = equipmentId + "_SC_CI08";
+            StateCause sc1 = new StateCause();
+            sc1.setEquipmentId(equipmentId);
+            sc1.setTbname(tbName);
+            sc1.setStationId(equipment.getWindpowerstationId());
+            sc1.setStateType("8种状态");
+            stateCauseList.add(sc1);
+
+            tbName = equipmentId + "_SC_CI14";
+            StateCause sc2 = new StateCause();
+            sc2.setEquipmentId(equipmentId);
+            sc2.setTbname(tbName);
+            sc2.setStationId(equipment.getWindpowerstationId());
+            sc2.setStateType("14种状态");
+            stateCauseList.add(sc2);
+        }
+        stateCauseService.creatTablesBatch(stateCauseList);
+    }
+}

+ 7 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/mapper/AlarmTsMapper.java

@@ -80,6 +80,13 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
     List<AlarmVo> findTags(@Param("stbaleName") String stbaleName);
 
 
+
+
+
+    @Select("select * from ${superTableName} where ts>=${begin} and ts<=${end} and   stationid=#{stationid} and   deviceid=#{deviceid}")
+    List<AlarmVo> findTagsByDeviceid(@Param("superTableName") String superTableName, @Param("stationid") String stationid, @Param("deviceid")  String deviceid, @Param("begin")long begin, @Param("end") long end);
+
+
     @Select("select deviceid,description,count(*) as val from #{superTableName} where ts>=#{begin} and ts<=#{end}  stationid=#{stationid}  group by description,deviceid  ")
     List<AlarmTsVo> selectByWpGroup(@Param("superTableName") String superTableName, @Param("stationid") String stationid, @Param("begin")long begin, @Param("end") long end);
 

+ 24 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/mapper/StateCauseMapper.java

@@ -0,0 +1,24 @@
+package com.gyee.power.fitting.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.power.fitting.model.StateCause;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Update;
+
+/**
+ * <p>
+ * Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-05-04
+ */
+@Mapper
+public interface StateCauseMapper extends BaseMapper<StateCause> {
+    @Insert("insert into ${entity}")
+    int insert(String entity);
+
+    @Update("CREATE TABLE ${entity}")
+    int creatTables(String entity);
+}

+ 181 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/model/StateCause.java

@@ -0,0 +1,181 @@
+package com.gyee.power.fitting.model;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.Date;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-05-04
+ */
+@TableName("state_cause")
+public class StateCause implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String tbname;
+
+    /**
+     * 开始时间
+     */
+    private Timestamp startTime;
+
+    /**
+     * 结束时间
+     */
+    private Timestamp endTime;
+
+    /**
+     * 事件-运行、限电、故障、受累、计划检修、待机
+     */
+    private Short event;
+
+    /**
+     * 事前状态
+     */
+    private Short advanceState;
+
+    /**
+     * 事后状态
+     */
+    private Short afterState;
+
+    /**
+     * 用户标记
+     */
+    private Short userFlag;
+
+    private Long time;
+
+    /**
+     * 场站
+     */
+    private String stationId;
+
+    /**
+     * 设备
+     */
+    private String equipmentId;
+
+    private String stateType;
+
+    public StateCause() {
+    }
+
+    public StateCause(String tbname, int event, long startTime, long endTime, long time) {
+        this.tbname = tbname;
+        this.event = (short) event;
+        this.startTime = new Timestamp(startTime);
+        this.endTime = new Timestamp(endTime);
+        this.time = time / 1000;
+    }
+
+    public String getTbname() {
+        return tbname;
+    }
+
+    public void setTbname(String tbname) {
+        this.tbname = tbname;
+    }
+
+    public String getStationId() {
+        return stationId;
+    }
+
+    public void setStationId(String stationId) {
+        this.stationId = stationId;
+    }
+
+    public String getEquipmentId() {
+        return equipmentId;
+    }
+
+    public void setEquipmentId(String equipmentId) {
+        this.equipmentId = equipmentId;
+    }
+
+    public Short getEvent() {
+        return event;
+    }
+
+    public void setEvent(Short event) {
+        this.event = event;
+    }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Timestamp startTime) {
+        this.startTime = startTime;
+    }
+
+    public Timestamp getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Timestamp endTime) {
+        this.endTime = endTime;
+    }
+
+    public Short getAdvanceState() {
+        return advanceState;
+    }
+
+    public void setAdvanceState(Short advanceState) {
+        this.advanceState = advanceState;
+    }
+
+    public Short getAfterState() {
+        return afterState;
+    }
+
+    public void setAfterState(Short afterState) {
+        this.afterState = afterState;
+    }
+
+    public Short getUserFlag() {
+        return userFlag;
+    }
+
+    public void setUserFlag(Short userFlag) {
+        this.userFlag = userFlag;
+    }
+
+    public Long getTime() {
+        return time;
+    }
+
+    public void setTime(Long time) {
+        this.time = time;
+    }
+
+    public String getStateType() {
+        return stateType;
+    }
+
+    public void setStateType(String stateType) {
+        this.stateType = stateType;
+    }
+
+    @Override
+    public String toString() {
+        return "StateCause{" +
+                "tbname = " + tbname +
+                ", stationId = " + stationId +
+                ", equipmentId = " + equipmentId +
+                ", event = " + event +
+                ", startTime = " + startTime +
+                ", endTime = " + endTime +
+                ", advanceState = " + advanceState +
+                ", afterState = " + afterState +
+                ", userFlag = " + userFlag +
+                "}";
+    }
+}

+ 2 - 1
power-fitting-JN/src/main/java/com.gyee.power.fitting/model/custom/PowerPointData.java

@@ -68,9 +68,10 @@ public class PowerPointData {
     private double dl = 0;
 
     //欠发状态 SSQFZT
-    @Desc(des = "欠发状态",  uniformCode = "SSQFZT", remark = "1")
+    @Desc(des = "欠发状态",  uniformCode = "RQFZT", remark = "1")
     private int qfzt = 0;
 
+
     //风向 AI067
     @Desc(des = "风向",  uniformCode = "AI067", remark = "1")
     private double fx = 0;

+ 2 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/IAlarmTsService.java

@@ -53,5 +53,7 @@ public interface IAlarmTsService extends IService<AlarmTs> {
     List<AlarmVo> selectByTbName(String tbName, long limit, long offset);
 
     List<AlarmSimpleVo> selectLastRowByTbname(String superTableName, String tbnames);
+
+    List<AlarmVo> findTagsByDeviceid(String superTableName, String stationid,String deviceid, long begin, long end);
 }
 

+ 20 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/IStateCauseService.java

@@ -0,0 +1,20 @@
+package com.gyee.power.fitting.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.power.fitting.model.StateCause;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-05-04
+ */
+public interface IStateCauseService extends IService<StateCause> {
+    int saveBatch(List<StateCause> entityList);
+
+    int creatTablesBatch(List<StateCause> entityList);
+}

+ 4 - 1
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/ProBasicEquipmentPointService.java

@@ -1,9 +1,10 @@
 package com.gyee.power.fitting.service;
 
-import com.gyee.power.fitting.model.ProBasicEquipmentPoint;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.power.fitting.model.ProBasicEquipmentPoint;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -19,4 +20,6 @@ public interface ProBasicEquipmentPointService extends IService<ProBasicEquipmen
 
     List<ProBasicEquipmentPoint> getPoints(String station, String windturbine, String uniformcode);
 
+    Map<String, ProBasicEquipmentPoint> getEquipmentMapByUniformcode(String uniformcode);
+
 }

+ 2 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/ProBasicEquipmentService.java

@@ -22,4 +22,6 @@ public interface ProBasicEquipmentService extends IService<ProBasicEquipment> {
     List<ProBasicEquipment> selectList(String station);
 
     Map<String, String> getStationMap(String type);
+
+    List<ProBasicEquipment> getCacheList();
 }

+ 3 - 3
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/custom/curve/NewDataFittingService.java

@@ -68,7 +68,7 @@ public class NewDataFittingService {
 
         //1.数据获取
         List<String> wtIds = Arrays.asList(vo.getWtIds().split(","));
-        deleteDir(config.getFilePathPrepare());
+//        deleteDir(config.getFilePathPrepare());
         for (int k = 0; k < wtIds.size(); k++) {
             String wt = wtIds.get(k);
             List<List<TsDoubleData>> result = new ArrayList<>();
@@ -124,7 +124,7 @@ public class NewDataFittingService {
         //2.数据筛选
 
         try {
-            deleteDir(config.getFilePathProcess());
+//            deleteDir(config.getFilePathProcess());
             for (String key : prepareMap.keySet()){
 
                 ProEconPowerFittingAnalySis obj = proEconPowerFittingAnalySisService.getById(key);
@@ -167,7 +167,7 @@ public class NewDataFittingService {
         //3.数据拟合
 
         AtomicReference<ProEconPowerFittingAnalySis> object = new AtomicReference<>();
-        deleteDir(config.getFilePathFitting());
+//        deleteDir(config.getFilePathFitting());
         if (vo.getMode() == 0){  //单台拟合
             for (String processkey : processMap.keySet()){
                 List<ProEconPowerFittingAnalySis> list = proEconPowerFittingAnalySisService.selectListByIds(processkey);

+ 17 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/AlarmTsServiceImpl.java

@@ -171,4 +171,21 @@ public class AlarmTsServiceImpl extends ServiceImpl<AlarmTsMapper, AlarmTs> impl
 
         return ls;
     }
+
+
+    @Override
+    public List<AlarmVo> findTagsByDeviceid(String superTableName, String stationid, String deviceid, long begin, long end) {
+        try {
+            List<AlarmVo> ls=new ArrayList<>();
+            if(StringUtils.notEmp(superTableName) && StringUtils.notEmp(stationid) && StringUtils.notEmp(begin) && StringUtils.notEmp(end))
+            {
+                ls= alarmTsMapper.findTagsByDeviceid(superTableName, stationid,deviceid, begin, end);
+            }
+
+            return ls;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 }

+ 15 - 2
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/ProBasicEquipmentPointServiceImpl.java

@@ -1,17 +1,20 @@
 package com.gyee.power.fitting.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.power.fitting.common.base.ExcludeQueryWrapper;
-import com.gyee.power.fitting.model.ProBasicEquipmentPoint;
 import com.gyee.power.fitting.mapper.ProBasicEquipmentPointMapper;
+import com.gyee.power.fitting.model.ProBasicEquipmentPoint;
 import com.gyee.power.fitting.service.ProBasicEquipmentPointService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -41,6 +44,7 @@ public class ProBasicEquipmentPointServiceImpl extends ServiceImpl<ProBasicEquip
 
         return list;
     }
+
     @Override
     @Cacheable("wtpoint")
     public List<ProBasicEquipmentPoint> getPoints(String station, String windturbine, String uniformcode) {
@@ -58,4 +62,13 @@ public class ProBasicEquipmentPointServiceImpl extends ServiceImpl<ProBasicEquip
         return baseMapper.selectList(wrapper);
     }
 
+    @Cacheable("getEquipmentMapByUniformcode")
+    public Map<String, ProBasicEquipmentPoint> getEquipmentMapByUniformcode(String uniformcode) {
+
+        QueryWrapper<ProBasicEquipmentPoint> wrapper = new QueryWrapper<>();
+        wrapper.eq("uniform_code", uniformcode).orderByAsc("windturbine_id");
+        List<ProBasicEquipmentPoint> points = baseMapper.selectList(wrapper);
+        Map<String, ProBasicEquipmentPoint> collect = points.stream().collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, Function.identity()));
+        return collect;
+    }
 }

+ 7 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/ProBasicEquipmentServiceImpl.java

@@ -57,4 +57,11 @@ public class ProBasicEquipmentServiceImpl extends ServiceImpl<ProBasicEquipmentM
         Map<String, String> collect = eList.stream().collect(Collectors.toMap(ProBasicEquipment::getId, ProBasicEquipment::getNemCode));
         return collect;
     }
+
+    @Cacheable("getCacheList")
+    public List<ProBasicEquipment> getCacheList() {
+        QueryWrapper<ProBasicEquipment> wrapper = new QueryWrapper<>();
+        wrapper.orderByAsc("id");
+        return baseMapper.selectList(wrapper);
+    }
 }

+ 59 - 0
power-fitting-JN/src/main/java/com.gyee.power.fitting/service/impl/StateCauseServiceImpl.java

@@ -0,0 +1,59 @@
+package com.gyee.power.fitting.service.impl;
+
+import cn.hutool.core.collection.ListUtil;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.power.fitting.mapper.StateCauseMapper;
+import com.gyee.power.fitting.model.StateCause;
+import com.gyee.power.fitting.service.IStateCauseService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-05-04
+ */
+@DS("jsfw")
+@Service
+public class StateCauseServiceImpl extends ServiceImpl<StateCauseMapper, StateCause> implements IStateCauseService {
+
+    public int saveBatch(List<StateCause> entityList) {
+        List<List<StateCause>> split = ListUtil.split(entityList, 3000);
+
+        int count = 0;
+        for (List<StateCause> targets : split) {
+            StringBuilder sb = new StringBuilder();
+            for (StateCause target : targets) {
+                sb.append(target.getTbname()).append(" values(").append(target.getStartTime().getTime())
+                        .append(",").append(target.getEndTime().getTime()).append(",'").append(target.getEvent())
+                        .append("','").append(target.getAdvanceState()).append("','").append(target.getAfterState())
+                        .append("','").append(target.getUserFlag()).append("',").append(target.getTime())
+                        .append(") ");
+            }
+            count += baseMapper.insert(sb.toString());
+        }
+        return count;
+    }
+
+    public int creatTablesBatch(List<StateCause> entityList) {
+        List<List<StateCause>> split = ListUtil.split(entityList, 3000);
+
+        int count = 0;
+        for (List<StateCause> targets : split) {
+            StringBuilder sb = new StringBuilder();
+            for (StateCause target : targets) {
+                sb.append("IF NOT EXISTS ").append(target.getTbname())
+                        .append(" USING state_cause TAGS ('").append(target.getStationId()).append("','")
+                        .append(target.getEquipmentId()).append("','").append(target.getStateType())
+                        .append("') ");
+            }
+            count += baseMapper.creatTables(sb.toString());
+        }
+        return count;
+    }
+}

+ 7 - 2
power-fitting-JN/src/main/resources/application.yaml

@@ -72,6 +72,11 @@ spring:
           url: jdbc:TAOS://10.81.3.154:6030/nemjn?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8
           username: root
           password: taosdata
+        jsfw: #taos数据库
+          driver-class-name: com.taosdata.jdbc.TSDBDriver
+          url: jdbc:TAOS://10.81.3.154:6030/jsfw?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8
+          username: root
+          password: taosdata
 
       #配置初始化连接数大小
       initial-size: 10
@@ -107,8 +112,8 @@ spring:
             multi-statement-allow: true
 
   redis:
-    host: 127.0.0.1
-    #host: 10.81.3.155
+    #host: 127.0.0.1
+    host: 10.81.3.155
     port: 6379
     timeout: 100000
     password: