|
@@ -0,0 +1,439 @@
|
|
|
+package com.gyee.generation.service;
|
|
|
+
|
|
|
+import com.gyee.common.contant.Contant;
|
|
|
+import com.gyee.common.model.PointData;
|
|
|
+import com.gyee.common.model.StringUtils;
|
|
|
+import com.gyee.common.util.DateUtils;
|
|
|
+import com.gyee.common.util.algorithm.Underdelivery;
|
|
|
+import com.gyee.generation.init.CacheContext;
|
|
|
+import com.gyee.generation.model.auto.*;
|
|
|
+import com.gyee.generation.util.realtimesource.IEdosUtil;
|
|
|
+import com.gyee.generation.util.redis.RedisService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+
|
|
|
+ * @ClassName : StatusService
|
|
|
+ * @Author : xieshengjie
|
|
|
+ * @Date: 2022/3/28 14:22
|
|
|
+ * @Description : 状态计算
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class Status_HF_Service {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IEdosUtil edosUtil;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private RedisService redisService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 判断故障状态
|
|
|
+ *
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public void calculateGzStatus() throws Exception {
|
|
|
+
|
|
|
+ Map<String, Map<String, Object>> pipelinedmap = new HashMap<>();
|
|
|
+ if (!CacheContext.wtls.isEmpty()) {
|
|
|
+
|
|
|
+
|
|
|
+ for (Windturbine wt : CacheContext.wtls) {
|
|
|
+
|
|
|
+
|
|
|
+ if (CacheContext.wtPointmap.containsKey(wt.getId())) {
|
|
|
+ Map<String, Windturbinetestingpointai> map = CacheContext.wtPointmap.get(wt.getId());
|
|
|
+ if (map.containsKey(Contant.GZZT)) {
|
|
|
+ Windturbinetestingpointai pt = map.get(Contant.GZZT);
|
|
|
+ redisService.select(8);
|
|
|
+
|
|
|
+ Map<String, Object> pomap = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ pomap.put("pointid", pt.getId());
|
|
|
+ Date date = new Date();
|
|
|
+ pomap.put("value", 0);
|
|
|
+ pomap.put("timestamp", date.getTime() / 1000);
|
|
|
+ pomap.put("datetime", DateUtils.toDate(date));
|
|
|
+ pomap.put("status", 0);
|
|
|
+ pipelinedmap.put(pt.getId(), pomap);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (wt.getModelid().equals("SL1500-77") || wt.getModelid().equals("SL1500-82")) {
|
|
|
+ List<Windturbinetestingpointdis> disLs = CacheContext.pointdis.stream().filter(i -> i.getWindturbineid().equals(wt.getId()) && i.getUniformcode().equals("ZT001")).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (!disLs.isEmpty()) {
|
|
|
+ Windturbinetestingpointdis key = disLs.get(0);
|
|
|
+ if (CacheContext.redisDbMap.containsKey(key.getId())) {
|
|
|
+ int dbnum = CacheContext.redisDbMap.get(key.getId());
|
|
|
+ redisService.select(dbnum);
|
|
|
+
|
|
|
+ if (redisService.hasKey(key.getId(), "value")) {
|
|
|
+
|
|
|
+ double value = 0.0;
|
|
|
+ try {
|
|
|
+ Map<Object, Object> map = redisService.getHashEntries(key.getId());
|
|
|
+ if (map.containsKey("value")) {
|
|
|
+ value = Double.valueOf((String) map.get("value"));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("calculateGzStatus" + " " + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CacheContext.wtPointmap.containsKey(wt.getId())) {
|
|
|
+ Map<String, Windturbinetestingpointai> map = CacheContext.wtPointmap.get(wt.getId());
|
|
|
+ if (map.containsKey(Contant.GZZT)) {
|
|
|
+ Windturbinetestingpointai pt = map.get(Contant.GZZT);
|
|
|
+
|
|
|
+ if (StringUtils.notEmp(value) && value == 3) {
|
|
|
+ redisService.select(8);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> pomap = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ pomap.put("pointid", pt.getId());
|
|
|
+ Date date = new Date();
|
|
|
+ pomap.put("value", 1);
|
|
|
+ pomap.put("timestamp", date.getTime() / 1000);
|
|
|
+ pomap.put("datetime", DateUtils.toDate(date));
|
|
|
+ pomap.put("status", 0);
|
|
|
+
|
|
|
+ pipelinedmap.put(pt.getId(), pomap);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<Windturbinetestingpointdis> disLs = CacheContext.pointdis.stream().filter(i -> i.getWindturbineid().equals(wt.getId()) && i.getUniformcode().equals("ZT002")).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ if (!disLs.isEmpty()) {
|
|
|
+ Windturbinetestingpointdis key = disLs.get(0);
|
|
|
+ if (CacheContext.redisDbMap.containsKey(key.getId())) {
|
|
|
+ int dbnum = CacheContext.redisDbMap.get(key.getId());
|
|
|
+ redisService.select(dbnum);
|
|
|
+
|
|
|
+ if (redisService.hasKey(key.getId(), "value")) {
|
|
|
+ double value = 0.0;
|
|
|
+ try {
|
|
|
+
|
|
|
+ Map<Object, Object> map = redisService.getHashEntries(key.getId());
|
|
|
+ if (map.containsKey("value")) {
|
|
|
+ value = Double.valueOf((String) map.get("value"));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("calculateGzStatus" + " " + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (CacheContext.wtPointmap.containsKey(wt.getId())) {
|
|
|
+ Map<String, Windturbinetestingpointai> map = CacheContext.wtPointmap.get(wt.getId());
|
|
|
+ if (map.containsKey(Contant.GZZT)) {
|
|
|
+ Windturbinetestingpointai pt = map.get(Contant.GZZT);
|
|
|
+
|
|
|
+ if (StringUtils.notEmp(value) && value == 1) {
|
|
|
+ redisService.select(8);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> pomap = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ pomap.put("pointid", pt.getId());
|
|
|
+ Date date = new Date();
|
|
|
+ pomap.put("value", 1);
|
|
|
+ pomap.put("timestamp", date.getTime() / 1000);
|
|
|
+ pomap.put("datetime", DateUtils.toDate(date));
|
|
|
+ pomap.put("status", 0);
|
|
|
+ pipelinedmap.put(pt.getId(), pomap);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ redisService.putHashAllPipeObj(pipelinedmap);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 判断欠发状态
|
|
|
+ *
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public void calculateQfStatus() throws Exception {
|
|
|
+
|
|
|
+ Map<String, Map<String, Object>> pipelinedmap = new HashMap<>();
|
|
|
+ if (!CacheContext.wtls.isEmpty()) {
|
|
|
+ for (Windturbine wt : CacheContext.wtls) {
|
|
|
+
|
|
|
+ if (CacheContext.wtPointmap.containsKey(wt.getId())) {
|
|
|
+ Map<String, Windturbinetestingpointai> map = CacheContext.wtPointmap.get(wt.getId());
|
|
|
+
|
|
|
+
|
|
|
+ if (map.containsKey(Contant.RSSQFZT)) {
|
|
|
+ Windturbinetestingpointai qfpt = map.get(Contant.RSSQFZT);
|
|
|
+ redisService.select(8);
|
|
|
+ Map<String, Object> pomap = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ pomap.put("pointid", qfpt.getId());
|
|
|
+ Date date = new Date();
|
|
|
+ pomap.put("value", 0);
|
|
|
+ pomap.put("timestamp", date.getTime() / 1000);
|
|
|
+ pomap.put("datetime", DateUtils.toDate(date));
|
|
|
+ pomap.put("status", 0);
|
|
|
+ pipelinedmap.put(qfpt.getId(), pomap);
|
|
|
+
|
|
|
+ }
|
|
|
+ if (map.containsKey(Contant.AI130) && map.containsKey(Contant.AI022)) {
|
|
|
+ Windturbinetestingpointai powerpoint = map.get(Contant.AI130);
|
|
|
+ Windturbinetestingpointai speedpoint = map.get(Contant.AI022);
|
|
|
+ if (CacheContext.redisDbMap.containsKey(powerpoint.getId()) && CacheContext.redisDbMap.containsKey(speedpoint.getId())) {
|
|
|
+
|
|
|
+ int dbnum = CacheContext.redisDbMap.get(powerpoint.getId());
|
|
|
+ redisService.select(dbnum);
|
|
|
+ double power = 0.0;
|
|
|
+ if (redisService.hasKey(powerpoint.getId(), "value")) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ Map<Object, Object> tempmap = redisService.getHashEntries(powerpoint.getId());
|
|
|
+ if (tempmap.containsKey("value")) {
|
|
|
+ power = Double.valueOf((String) tempmap.get("value"));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("calculateQfStatus" + " " + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ dbnum = CacheContext.redisDbMap.get(speedpoint.getId());
|
|
|
+ redisService.select(dbnum);
|
|
|
+
|
|
|
+ double speed = 0.0;
|
|
|
+ if (redisService.hasKey(speedpoint.getId(), "value")) {
|
|
|
+ try {
|
|
|
+
|
|
|
+ Map<Object, Object> tempmap = redisService.getHashEntries(speedpoint.getId());
|
|
|
+ if (tempmap.containsKey("value")) {
|
|
|
+ speed = Double.valueOf((String) tempmap.get("value"));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("calculateQfStatus" + " " + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ((speed != 0 && power != 0) && CacheContext.curveFittingPowerMap.containsKey(wt.getId()) && StringUtils.notEmp(power) && StringUtils.notEmp(speed)) {
|
|
|
+ Map<Double, Windturbinepowercurvefitting> wtcurvemap = CacheContext.curveFittingPowerMap.get(wt.getId());
|
|
|
+
|
|
|
+ if (wtcurvemap.containsKey(StringUtils.round(speed, 2))) {
|
|
|
+ Windturbinepowercurvefitting wtcurve = wtcurvemap.get(StringUtils.round(speed, 2));
|
|
|
+
|
|
|
+ Double actualpower = wtcurve.getActualpower();
|
|
|
+
|
|
|
+ double qfzt = Underdelivery.underdeliveryStatusReal(power, actualpower);
|
|
|
+ if (map.containsKey(Contant.RSSQFZT)) {
|
|
|
+ Windturbinetestingpointai qfpt = map.get(Contant.RSSQFZT);
|
|
|
+ redisService.select(8);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> pomap = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ pomap.put("pointid", qfpt.getId());
|
|
|
+ Date date = new Date();
|
|
|
+ pomap.put("value", qfzt);
|
|
|
+ pomap.put("timestamp", date.getTime() / 1000);
|
|
|
+ pomap.put("datetime", DateUtils.toDate(date));
|
|
|
+ pomap.put("status", 0);
|
|
|
+ pipelinedmap.put(qfpt.getId(), pomap);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ redisService.putHashAllPipeObj(pipelinedmap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 判断理论功率
|
|
|
+ *
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public void calculateLlgl() throws Exception {
|
|
|
+
|
|
|
+ Map<String, Map<String, Object>> pipelinedmap = new HashMap<>();
|
|
|
+ if (!CacheContext.wtls.isEmpty()) {
|
|
|
+ for (Windturbine wt : CacheContext.wtls) {
|
|
|
+
|
|
|
+ if (CacheContext.wtPointmap.containsKey(wt.getId())) {
|
|
|
+ Map<String, Windturbinetestingpointai> map = CacheContext.wtPointmap.get(wt.getId());
|
|
|
+ if (map.containsKey(Contant.LLGL)) {
|
|
|
+ Windturbinetestingpointai qfpt = map.get(Contant.LLGL);
|
|
|
+ redisService.select(8);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> pomap = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ pomap.put("pointid", qfpt.getId());
|
|
|
+ Date date = new Date();
|
|
|
+ pomap.put("value", 0);
|
|
|
+ pomap.put("timestamp", date.getTime() / 1000);
|
|
|
+ pomap.put("datetime", DateUtils.toDate(date));
|
|
|
+ pomap.put("status", 0);
|
|
|
+ pipelinedmap.put(qfpt.getId(), pomap);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CacheContext.wtPointmap.containsKey(wt.getId())) {
|
|
|
+ Map<String, Windturbinetestingpointai> map = CacheContext.wtPointmap.get(wt.getId());
|
|
|
+ if (map.containsKey(Contant.AI022)) {
|
|
|
+ Windturbinetestingpointai speedpoint = map.get(Contant.AI022);
|
|
|
+ if (CacheContext.redisDbMap.containsKey(speedpoint.getId())) {
|
|
|
+
|
|
|
+ int dbnum = CacheContext.redisDbMap.get(speedpoint.getId());
|
|
|
+ redisService.select(dbnum);
|
|
|
+ double speed = 0.0;
|
|
|
+ if (redisService.hasKey(speedpoint.getId(), "value")) {
|
|
|
+ try {
|
|
|
+
|
|
|
+ Map<Object, Object> tempmap = redisService.getHashEntries(speedpoint.getId());
|
|
|
+ if (tempmap.containsKey("value")) {
|
|
|
+ speed = Double.valueOf((String) tempmap.get("value"));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("calculateLlgl " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (speed != 0 && CacheContext.curveFittingPowerMap.containsKey(wt.getId()) && StringUtils.notEmp(speed)) {
|
|
|
+ Map<Double, Windturbinepowercurvefitting> wtcurvemap = CacheContext.curveFittingPowerMap.get(wt.getId());
|
|
|
+
|
|
|
+ if (wtcurvemap.containsKey(StringUtils.round(speed, 2))) {
|
|
|
+ Windturbinepowercurvefitting wtcurve = wtcurvemap.get(StringUtils.round(speed, 2));
|
|
|
+
|
|
|
+ Double actualpower = wtcurve.getOptimalpower();
|
|
|
+
|
|
|
+ if (CacheContext.wtPointmap.containsKey(wt.getId())) {
|
|
|
+
|
|
|
+ if (map.containsKey(Contant.LLGL)) {
|
|
|
+ Windturbinetestingpointai qfpt = map.get(Contant.LLGL);
|
|
|
+ redisService.select(8);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> pomap = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ pomap.put("pointid", qfpt.getId());
|
|
|
+ Date date = new Date();
|
|
|
+ pomap.put("value", actualpower);
|
|
|
+ pomap.put("timestamp", date.getTime() / 1000);
|
|
|
+ pomap.put("datetime", DateUtils.toDate(date));
|
|
|
+ pomap.put("status", 0);
|
|
|
+ pipelinedmap.put(qfpt.getId(), pomap);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ redisService.putHashAllPipeObj(pipelinedmap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 转存场站计算指标
|
|
|
+ *
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public void calculateWpPoint() throws Exception {
|
|
|
+ Map<String, Map<String, Object>> pipelinedmap = new HashMap<>();
|
|
|
+ if (!CacheContext.wpls.isEmpty()) {
|
|
|
+ for (Windpowerstation wp : CacheContext.wpls) {
|
|
|
+
|
|
|
+
|
|
|
+ if (CacheContext.wpPointmap.containsKey(wp.getId())) {
|
|
|
+ Map<String, Windpowerstationtestingpoint> map = CacheContext.wpPointmap.get(wp.getId());
|
|
|
+
|
|
|
+ List<String> ls = new ArrayList<>();
|
|
|
+
|
|
|
+ ls.add(map.get("CYDLB").getCode());
|
|
|
+ ls.add(map.get("RFDLB").getCode());
|
|
|
+ ls.add(map.get("RFDLC").getCode());
|
|
|
+ ls.add(map.get("RGZSSDL").getCode());
|
|
|
+ ls.add(map.get("RJXSSDL").getCode());
|
|
|
+ ls.add(map.get("RWZSSDL").getCode());
|
|
|
+ ls.add(map.get("RXDSSDL").getCode());
|
|
|
+ ls.add(map.get("SSFS").getCode());
|
|
|
+ ls.add(map.get("SSZGL").getCode());
|
|
|
+ ls.add(map.get("ZLLGL").getCode());
|
|
|
+ ls.add(map.get("ZZSGL").getCode());
|
|
|
+ ls.add(map.get("XDZT").getCode());
|
|
|
+ ls.add(map.get("RXNSSDL").getCode());
|
|
|
+ ls.add(map.get("QXPCL").getCode());
|
|
|
+
|
|
|
+ List<PointData> vos = edosUtil.getRealData(ls);
|
|
|
+ if (!vos.isEmpty()) {
|
|
|
+ redisService.select(8);
|
|
|
+ for (PointData vo : vos) {
|
|
|
+ Map<String, Object> pomap = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ pomap.put("pointid", vo.getEdnaId());
|
|
|
+ pomap.put("value", vo.getPointValueInDouble());
|
|
|
+ pomap.put("timestamp", vo.getPointTime());
|
|
|
+ pomap.put("datetime", DateUtils.toDate(new Date(vo.getPointTime())));
|
|
|
+ pomap.put("status", 0);
|
|
|
+ pipelinedmap.put(vo.getEdnaId(), pomap);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ redisService.putHashAllPipeObj(pipelinedmap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|