Pārlūkot izejas kodu

增加五项损失实时计算

wangb 3 nedēļas atpakaļ
vecāks
revīzija
c4772f631a

+ 23 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/annotation/DataSource.java

@@ -0,0 +1,23 @@
+package com.gyee.runeconomy.annotation;
+
+import com.gyee.runeconomy.enums.DataSourceType;
+
+import java.lang.annotation.*;
+
+/**
+ * 自定义多数据源切换注解
+ * <p>
+ * 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
+ *
+ * @author ruoyi
+ */
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+public @interface DataSource {
+    /**
+     * 切换数据源名称
+     */
+    public DataSourceType value() default DataSourceType.MASTER;
+}

+ 21 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/enums/DataSourceType.java

@@ -0,0 +1,21 @@
+package com.gyee.runeconomy.enums;
+
+/**
+ * 数据源
+ *
+ * @author ruoyi
+ */
+public enum DataSourceType {
+    /**
+     * 主库
+     */
+    MASTER,
+
+    /**
+     * 从库
+     */
+    SLAVE,
+
+    TAOS,
+    GLYC
+}

+ 16 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/mapper/auto/TurbineInfoMinMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.runeconomy.mapper.auto;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.runeconomy.model.auto.TurbineInfoMin;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+public interface TurbineInfoMinMapper extends BaseMapper<TurbineInfoMin> {
+
+}

+ 54 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/model/auto/TurbineInfoMin.java

@@ -0,0 +1,54 @@
+package com.gyee.runeconomy.model.auto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+@Data
+@TableName("turbine_info_min")
+public class TurbineInfoMin implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private String stationId;
+
+    private String projectId;
+
+    private String lineId;
+
+    private String turbineId;
+
+    private Date recordDate;
+
+    private Double pjfs;
+
+    private Double pjgl;
+
+    private Double llgl;
+
+    private Double kygl;
+
+    private Double jhjxss;
+    private Double fjhjxss;
+    private Double xdss;
+    private Double slss;
+    private Double xnss;
+    private Double djss;
+    private Double gzss;
+    private Double llfdl;
+}

+ 16 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/ITurbineInfoMinService.java

@@ -0,0 +1,16 @@
+package com.gyee.runeconomy.service.auto;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.runeconomy.model.auto.TurbineInfoMin;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+public interface ITurbineInfoMinService extends IService<TurbineInfoMin> {
+
+}

+ 46 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/TurbineInfoMinServiceImpl.java

@@ -0,0 +1,46 @@
+package com.gyee.runeconomy.service.auto.impl;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.runeconomy.annotation.DataSource;
+import com.gyee.runeconomy.enums.DataSourceType;
+import com.gyee.runeconomy.mapper.auto.TurbineInfoMinMapper;
+import com.gyee.runeconomy.model.auto.TurbineInfoMin;
+import com.gyee.runeconomy.service.auto.ITurbineInfoMinService;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+@Service
+@DataSource(DataSourceType.SLAVE)
+public class TurbineInfoMinServiceImpl extends ServiceImpl<TurbineInfoMinMapper, TurbineInfoMin> implements ITurbineInfoMinService {
+
+    @Override
+    public boolean saveOrUpdate(TurbineInfoMin entity) {
+        return super.saveOrUpdate(entity);
+    }
+
+    @Override
+    public boolean saveOrUpdateBatch(Collection<TurbineInfoMin> entityList) {
+        return super.saveOrUpdateBatch(entityList);
+    }
+
+    @Override
+    public List<TurbineInfoMin> list() {
+        return super.list();
+    }
+
+    @Override
+    public List<TurbineInfoMin> list(Wrapper<TurbineInfoMin> queryWrapper) {
+        return super.list(queryWrapper);
+    }
+}

+ 129 - 1
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/goodness/WindturbinegoodnessService.java

@@ -1,6 +1,9 @@
 package com.gyee.runeconomy.service.goodness;
 
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.NumberUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.common.contant.ContantXk;
 import com.gyee.common.model.PointData;
@@ -13,6 +16,7 @@ import com.gyee.runeconomy.init.CacheContext;
 import com.gyee.runeconomy.model.auto.*;
 import com.gyee.runeconomy.service.auto.IProEconEquipmentInfoDay6Service;
 import com.gyee.runeconomy.service.auto.IProEconWindturbineGoodnessService;
+import com.gyee.runeconomy.service.auto.ITurbineInfoMinService;
 import com.gyee.runeconomy.util.DateUtils;
 import com.gyee.runeconomy.util.StringUtils;
 import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
@@ -40,6 +44,9 @@ public class WindturbinegoodnessService {
     @Resource
     private IEdosUtil edosUtil;
 
+    @Resource
+    private ITurbineInfoMinService iTurbineInfoMinService;
+
     public Page<ProEconWindturbineGoodness> windturbinegoodnessList(Integer pageNum, Integer pageSize, String cmId, String type, String wpId, String recorddate) {
 
         if (StringUtils.empty(pageNum)) {
@@ -552,7 +559,7 @@ public class WindturbinegoodnessService {
         return String.valueOf(temp);
     }
 
-    public List<DataVo> findRealPowerCharBy24(String wtId, Date recorddate) throws Exception {
+    public List<DataVo> findRealPowerCharBy24bak(String wtId, Date recorddate) throws Exception {
         List<DataVo> vos = new ArrayList<DataVo>();
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -876,6 +883,127 @@ public class WindturbinegoodnessService {
         return vos;
     }
 
+    public List<DataVo> findRealPowerCharBy24(String wtId, Date recorddate) throws Exception {
+        List<DataVo> vos = new ArrayList<DataVo>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        Date endDate = sdfs.parse(sdf.format(DateUtils.addDays(recorddate, 1)) + " 00:0:00");
+        Date beginDate = sdfs.parse(sdf.format(recorddate) + " 00:00:00");
+
+        int length = 24;
+        for (int i = 0; i < length; i++) {
+            DataVo vo = new DataVo();
+
+            vo.setValue1(0.0);// scada发电量
+            vo.setValue2(0.0);// 维护损失
+            vo.setValue3(0.0);// 故障损失
+            vo.setValue4(0.0);// 限电损失
+            vo.setValue5(0.0);// 欠发损失
+            vo.setValue6(0.0);// 风速
+
+            vos.add(vo);
+        }
+        Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wtId);
+
+
+        ProBasicEquipmentPoint fdl = wtpointmap.get(ContantXk.RFDL);
+        ProBasicEquipmentPoint fs = wtpointmap.get(ContantXk.CJ_SSFS);
+
+        try {
+            if (null != fdl) {
+                List<PointData> fdlls = edosUtil.getHistoryDatasSnap(fdl, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
+                int count = 0;
+                double temp1 = 0;
+                for (int i = 0; i < length; i++) {
+
+                    if (i < fdlls.size() && StringUtils.notEmp(fdlls.get(i + 1).getPointTime())) {
+
+                        vos.get(i).setTime(fdlls.get(i + 1).getPointTime());
+                        if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
+
+                            if (i != 0) {
+                                temp1 = fdlls.get(i + 1).getPointValueInDouble();
+                                double temp2 = fdlls.get(i).getPointValueInDouble();
+                                temp1 = temp1 - temp2;
+                                vos.get(i).setValue1(StringUtils.round(temp1 * 1000, 2));// 发电量
+
+                            } else {
+                                temp1 = fdlls.get(i + 1).getPointValueInDouble();
+                                vos.get(i).setValue1(StringUtils.round(temp1 * 1000, 2));// 发电量
+                            }
+                            count++;
+                        } else {
+                            vos.get(i).setTime(fdlls.get(i).getPointTime());
+                            vos.get(i).setValue1(0d);// 发电量
+                        }
+
+                    }
+                }
+            }
+        } catch (Exception e) {
+            // TODO: handle exception
+        }
+        /*
+         * 维护损失
+         */
+        try {
+            QueryWrapper<TurbineInfoMin> qw = new QueryWrapper<>();
+            qw.lambda().eq(TurbineInfoMin::getTurbineId, wtId)
+                    .between(TurbineInfoMin::getRecordDate, beginDate, endDate)
+                    .isNotNull(TurbineInfoMin::getGzss)
+                    .orderByAsc(TurbineInfoMin::getRecordDate);
+            List<TurbineInfoMin> turbineMins = iTurbineInfoMinService.list(qw);
+            for (int i = 0; i < length; i++) {
+                if (i < turbineMins.size()) {
+                    TurbineInfoMin tm = turbineMins.get(i);
+                    Date recordDate = tm.getRecordDate();
+                    int hour = DateUtil.hour(recordDate, true);
+                    if (i == hour) {
+                        vos.get(i).setValue2(NumberUtil.round(tm.getJhjxss() + tm.getFjhjxss(), 2).doubleValue());
+                        vos.get(i).setValue3(NumberUtil.round(tm.getGzss(), 2).doubleValue());
+                        vos.get(i).setValue4(NumberUtil.round(tm.getXdss(), 2).doubleValue());
+                        vos.get(i).setValue4(NumberUtil.round(tm.getXnss(), 2).doubleValue());
+                    }
+                }
+            }
+        } catch (Exception e) {
+            // TODO: handle exception
+        }
+        /*
+         * 风速
+         */
+        try {
+            if (null != fs) {
+                List<PointData> fsls = edosUtil.getHistoryDatasSnap(fs, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
+
+                int count = 0;
+                double temp1 = 0;
+                for (int i = 0; i < 24; i++) {
+
+                    if (i < fsls.size() && StringUtils.notEmp(fsls.get(i + 1).getPointTime())) {
+
+                        vos.get(i).setTime(fsls.get(i + 1).getPointTime());
+                        if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
+
+                            temp1 = fsls.get(i + 1).getPointValueInDouble();
+                            vos.get(i).setValue6(StringUtils.round(temp1, 2));// 风速
+                            count++;
+
+                        } else {
+                            vos.get(i).setValue6(0d);// 风速
+                        }
+
+                    }
+                }
+            }
+        } catch (Exception e) {
+            // TODO: handle exception
+        }
+
+        return vos;
+    }
+
     public List<PvVo> pvgoodness(String companys, String wpid, String recorddate, String target, String sort) {
 
         Map<String, ProEconEquipmentmodel> modelMap = CacheContext.modelMap;