|
@@ -1,7 +1,10 @@
|
|
|
package com.gyee.healthmodel.service;
|
|
|
|
|
|
|
|
|
+import com.gyee.common.model.DNAVal;
|
|
|
+import com.gyee.common.model.PointData;
|
|
|
import com.gyee.healthmodel.init.CacheContext;
|
|
|
+import com.gyee.healthmodel.init.Constant;
|
|
|
import com.gyee.healthmodel.model.auto.*;
|
|
|
import com.gyee.healthmodel.util.*;
|
|
|
import com.gyee.healthmodel.vo.healthsystem.DataVo;
|
|
@@ -14,6 +17,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.Map.Entry;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
@@ -31,6 +36,8 @@ public class HealthJudgeService {
|
|
|
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
@Resource
|
|
|
private Statejudgmentrecord2sService statejudgmentrecord2sService;
|
|
|
+ @Resource
|
|
|
+ private StatejudgmentrecordsService statejudgmentrecordsService;
|
|
|
@Resource
|
|
|
private HealthInitialService healthInitialService;
|
|
|
@Resource
|
|
@@ -51,17 +58,198 @@ public class HealthJudgeService {
|
|
|
private WobugeqsService wobugeqsService;
|
|
|
@Resource
|
|
|
private AlertrulefailuresubsService alertrulefailuresubsService;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private EarlywarningsService earlywarningsService;
|
|
|
private final double judgescore=80;
|
|
|
+ @Resource
|
|
|
+ private WindturbinetestingpointnewsService windturbinetestingpointnewsService;
|
|
|
+ @Resource
|
|
|
+ private CurvefittingsubsService curvefittingsubsService;
|
|
|
+ @Resource
|
|
|
+ private Windturbineinfodaytop2sService windturbineinfodaytop2sService;
|
|
|
+ IRealTimeDataBaseUtil realApiUtil = RealTimeDataBaseFactory.createRealTimeDataBase();
|
|
|
+ public void changeHealthModelValue() throws Exception {
|
|
|
+
|
|
|
+// healthInitialService.healthInitial();// 初始化函数算法模型数据
|
|
|
+
|
|
|
+ List<String> codels = new ArrayList<String>();
|
|
|
+ codels.add(Constant.CLXJKZT);
|
|
|
+ codels.add(Constant.FDJJKZT);
|
|
|
+ codels.add(Constant.BJJKZT);
|
|
|
+ codels.add(Constant.ZKJKZT);
|
|
|
+
|
|
|
+ List<Statejudgmentrecord> pols=new ArrayList<>();
|
|
|
+ for (Windturbine wt : CacheContext.wtls) {
|
|
|
+
|
|
|
+ if (wt.getWindpowerstationid().endsWith("FDC")) {
|
|
|
+
|
|
|
+ Statejudgmentrecord po = new Statejudgmentrecord();
|
|
|
+ po.setId(com.gyee.common.model.StringUtils.getUUID());
|
|
|
+ po.setWpid(wt.getWindpowerstationid());
|
|
|
+ po.setWtid(wt.getId());
|
|
|
+
|
|
|
+ StringBuilder statejudgment = new StringBuilder();
|
|
|
+
|
|
|
+ double fjzt=0;
|
|
|
+ double score=100;
|
|
|
+ Windturbinetestingpointnew ai = windturbinetestingpointnewsService.getWindTurbineTestingPointAi2(wt.getId(), Constant.FJZT);
|
|
|
+ PointData point=realApiUtil.getRealData(ai);
|
|
|
+
|
|
|
+ if(StringUtils.notEmp(point))
|
|
|
+ {
|
|
|
+ if(point.getPointValueInDouble()==2)
|
|
|
+ {
|
|
|
+ fjzt = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] points = new String[codels.size()];
|
|
|
+
|
|
|
+ for (int i = 0; i < codels.size(); i++) {
|
|
|
+ if (CacheContext.wtpAimap.containsKey(wt.getId())) {
|
|
|
+ Map<String, Windturbinetestingpointnew> wtmap = CacheContext.wtpAimap.get(wt.getId());
|
|
|
+ // 判断是否包含该统一编码
|
|
|
+ if (wtmap.containsKey(codels.get(i))) {
|
|
|
+ Windturbinetestingpointnew temp = wtmap.get(codels.get(i));
|
|
|
+ points[i] = temp.getCode();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Windturbinetestingpointnew fjjkzf = windturbinetestingpointnewsService.getWindTurbineTestingPointAi2(wt.getId(), Constant.FJJKZZ);
|
|
|
+
|
|
|
+ DNAVal[] ssvalues = realApiUtil.getRealtimeTagValues(points);
|
|
|
+
|
|
|
+ PointData fjjkzfpoint=new PointData();
|
|
|
+ fjjkzfpoint.setEdnaId(fjjkzf.getCode());
|
|
|
+ fjjkzfpoint.setPointTime(new BigDecimal(new Date().getTime()).divide(new BigDecimal(1000), 0, RoundingMode.HALF_EVEN).longValue());
|
|
|
+
|
|
|
+ double clxzt = ssvalues[0].DValue;
|
|
|
+ double fdjzt = ssvalues[1].DValue;
|
|
|
+ double bjzt = ssvalues[2].DValue;
|
|
|
+ double zkzt = ssvalues[3].DValue;
|
|
|
+
|
|
|
+ fjjkzfpoint.setPointValueInDouble(score);
|
|
|
+ realApiUtil.updatePoint(fjjkzfpoint);
|
|
|
+
|
|
|
+ // 出现故障状态,直接降到10分 差
|
|
|
+ if (fjzt == 2) {
|
|
|
+ score = 10.0;
|
|
|
+ statejudgment.append("1-");
|
|
|
+ } else {
|
|
|
+ statejudgment.append("0-");
|
|
|
+ }
|
|
|
+ // 齿轮箱、发电机、变浆、主控健康运行状态同时大于等于2
|
|
|
+ if (clxzt >= 2 && fdjzt >= 2 && bjzt >= 2 && zkzt >= 2
|
|
|
+ || (clxzt == 4 || fdjzt == 4 || bjzt == 4 || zkzt == 4)) {
|
|
|
+ score = setScoreValue(score);
|
|
|
+ statejudgment.append("1-");
|
|
|
+ } else {
|
|
|
+ statejudgment.append("0-");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Double> xnmap =windturbineinfodaytop2sService.findXnfx(Calendar.getInstance().getTime());
|
|
|
+
|
|
|
+ if(xnmap.containsKey(wt.getId()))
|
|
|
+ {
|
|
|
+ double djpgscore =xnmap.get(wt.getId());
|
|
|
+ if(djpgscore<60)
|
|
|
+ {
|
|
|
+ setScoreValue(score);
|
|
|
+ statejudgment.append("1-");
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ statejudgment.append("0-");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, List<Curvefittingsub>> cfmap =null;
|
|
|
+ Calendar c=Calendar.getInstance();
|
|
|
+ c.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
+
|
|
|
+
|
|
|
+ cfmap =curvefittingsubsService.findCurvefittingmapByDate(c.getTime(), wt, 3.0, 5.0);
|
|
|
+ double qxpc1 =curvefittingsubsService.getNuberValue(cfmap, wt);
|
|
|
+ double xfqrqc=Math.abs(qxpc1);
|
|
|
+ //小风曲线偏差
|
|
|
+ if(xfqrqc>5)
|
|
|
+ {
|
|
|
+ setScoreValue(score);
|
|
|
+ statejudgment.append("1-");
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ statejudgment.append("0-");
|
|
|
+ }
|
|
|
+ cfmap = curvefittingsubsService.findCurvefittingmapByDate(c.getTime(), wt, 5.0, 11.0);
|
|
|
+ double qxpc2 =curvefittingsubsService.getNuberValue(cfmap, wt);
|
|
|
+ double zcclqc=Math.abs(qxpc2);
|
|
|
+ //正常出力曲线偏差
|
|
|
+ if(zcclqc>5)
|
|
|
+ {
|
|
|
+ setScoreValue(score);
|
|
|
+ statejudgment.append("1-");
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ statejudgment.append("0-");
|
|
|
+ }
|
|
|
+ cfmap = curvefittingsubsService.findCurvefittingmapByDate(c.getTime(), wt, 11.0, 25.0);
|
|
|
+ double qxpc3 =curvefittingsubsService.getNuberValue(cfmap, wt);
|
|
|
+ double dfqrqc=Math.abs(qxpc3);
|
|
|
+ //大风曲线偏差
|
|
|
+ if(dfqrqc>5)
|
|
|
+ {
|
|
|
+ setScoreValue(score);
|
|
|
+ statejudgment.append("1-");
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ statejudgment.append("0-");
|
|
|
+ }
|
|
|
|
|
|
+ fjjkzf = windturbinetestingpointnewsService.getWindTurbineTestingPointAi2(wt.getId(), Constant.FJJKZZ);
|
|
|
|
|
|
+ fjjkzfpoint=new PointData();
|
|
|
+ fjjkzfpoint.setEdnaId(fjjkzf.getCode());
|
|
|
+ fjjkzfpoint.setPointTime(new BigDecimal(new Date().getTime()).divide(new BigDecimal(1000), 0, RoundingMode.HALF_EVEN).longValue());
|
|
|
|
|
|
+ fjjkzfpoint.setPointValueInDouble(score);
|
|
|
+ realApiUtil.updatePoint(fjjkzfpoint);
|
|
|
|
|
|
+ po.setStatejudgment(String.valueOf(statejudgment.substring(0, statejudgment.length() - 1)));
|
|
|
+
|
|
|
+ pols.add(po);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ statejudgmentrecordsService.deleteStatejudge();
|
|
|
+
|
|
|
+ if(!pols.isEmpty())
|
|
|
+ {
|
|
|
+ for(Statejudgmentrecord po:pols)
|
|
|
+ {
|
|
|
+ statejudgmentrecordsService.insertStatejudgmentrecord(po);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("结束健康模型分数计算!");
|
|
|
+ }
|
|
|
+
|
|
|
+ private double setScoreValue(double score) {
|
|
|
+ if (score >= 60) {
|
|
|
+ score = score - 20.0;
|
|
|
+ } else if (score < 60 && score >= 30) {
|
|
|
+ score = score - 10.0;
|
|
|
+ } else {
|
|
|
+ score = 10.0;
|
|
|
+ }
|
|
|
+ return score;
|
|
|
+ }
|
|
|
public void healthJudge3() throws Exception {
|
|
|
|
|
|
ScriptJava sj = new ScriptJava();
|
|
|
healthInitialService.healthInitial();// 初始化函数算法模型数据
|
|
|
|
|
|
+ Map<String, Integer> maps = new HashMap<>();
|
|
|
|
|
|
Map<String, List<Healthsystemsub>> hsmap = new HashMap<>();
|
|
|
|
|
@@ -73,17 +261,33 @@ public class HealthJudgeService {
|
|
|
hcmap.put(e.getName(), e);
|
|
|
}
|
|
|
List<Healthsystem> hsls = healthsystemsService.queryHealthSystem();
|
|
|
+
|
|
|
+ Map<String,List<Healthsystemsub>> map= healthsystemsubsService.queryHealthSystemSubMap();
|
|
|
if (!hsls.isEmpty()) {
|
|
|
for (Healthsystem hs : hsls) {
|
|
|
- List<Healthsystemsub> subls = healthsystemsubsService.queryHealthSystemSub(hs.getId());
|
|
|
- if (!subls.isEmpty()) {
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- sb.append(hs.getWpid()).append("_").append(hs.getModelid());
|
|
|
- if (!hsmap.containsKey(String.valueOf(sb))) {
|
|
|
- hsmap.put(String.valueOf(sb), subls);
|
|
|
- }
|
|
|
+// List<Healthsystemsub> subls = healthsystemsubsService.queryHealthSystemSub(hs.getId());
|
|
|
+// if (!subls.isEmpty()) {
|
|
|
+// StringBuilder sb = new StringBuilder();
|
|
|
+// sb.append(hs.getWpid()).append("_").append(hs.getModelid());
|
|
|
+// if (!hsmap.containsKey(String.valueOf(sb))) {
|
|
|
+// hsmap.put(String.valueOf(sb), subls);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ if(map.containsKey(hs.getId()))
|
|
|
+ {
|
|
|
+ List<Healthsystemsub> subls =map.get(hs.getId());
|
|
|
+ if (!subls.isEmpty()) {
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append(hs.getWpid()).append("_").append(hs.getModelid());
|
|
|
+ if (!hsmap.containsKey(String.valueOf(sb))) {
|
|
|
+ hsmap.put(String.valueOf(sb), subls);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -244,7 +448,24 @@ public class HealthJudgeService {
|
|
|
if (isHave == true) {
|
|
|
po.setMark("此风机近期有故障记录,故不在推荐范围之内!");
|
|
|
} else if (po.getScore() <=judgescore) {
|
|
|
- po.setMark("健康报告达到推荐级别,推荐检修!");
|
|
|
+
|
|
|
+ if(maps.containsKey(po.getWpid()))
|
|
|
+ {
|
|
|
+ int temp=maps.get(po.getWpid())+1;
|
|
|
+ if(temp>2)
|
|
|
+ {
|
|
|
+ po.setMark("健康指标未达到推荐级别,不予推荐!");
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ po.setMark("健康报告达到推荐级别,推荐检修!");
|
|
|
+ }
|
|
|
+ maps.put(po.getWpid(),temp);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ po.setMark("健康报告达到推荐级别,推荐检修!");
|
|
|
+ maps.put(po.getWpid(),1);
|
|
|
+ }
|
|
|
+ //po.setMark("健康报告达到推荐级别,推荐检修!");
|
|
|
} else {
|
|
|
po.setMark("健康指标未达到推荐级别,不予推荐!");
|
|
|
}
|