|
@@ -5,15 +5,15 @@ import com.gyee.common.contant.ContantXk;
|
|
|
import com.gyee.common.model.PointData;
|
|
|
import com.gyee.healthmodel.init.CacheContext;
|
|
|
import com.gyee.healthmodel.model.auto.*;
|
|
|
+import com.gyee.healthmodel.model.vo.AlarmCustomType;
|
|
|
+import com.gyee.healthmodel.model.vo.AlarmStatVo;
|
|
|
import com.gyee.healthmodel.model.vo.StatusDetailValue;
|
|
|
import com.gyee.healthmodel.service.auto.*;
|
|
|
import com.gyee.healthmodel.util.*;
|
|
|
-import com.gyee.healthmodel.vo.healthsystem.DataVo;
|
|
|
import com.gyee.healthmodel.vo.healthsystem.HealthExpression;
|
|
|
import com.gyee.healthmodel.vo.healthsystem.ResultVo;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -21,7 +21,6 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.Map.Entry;
|
|
|
-import java.util.concurrent.CountDownLatch;
|
|
|
|
|
|
|
|
|
@Service
|
|
@@ -32,8 +31,7 @@ public class HealthJudgeService {
|
|
|
private IProEconHealthSystemService proEconHealthSystemService;
|
|
|
@Resource
|
|
|
private IProEconHealthSystemSubService proEconHealthSystemSubService;
|
|
|
- @Resource
|
|
|
- private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
+
|
|
|
@Resource
|
|
|
private IProEconStateJudgmentDayService proEconStateJudgmentDayService;
|
|
|
@Resource
|
|
@@ -43,32 +41,14 @@ public class HealthJudgeService {
|
|
|
@Resource
|
|
|
private HealthFactoryService healthFactoryService;
|
|
|
|
|
|
- @Resource
|
|
|
- private AlarmcountsService alarmcountsService;
|
|
|
- @Resource
|
|
|
- private AlarmsnapsService alarmsnapsService;
|
|
|
- @Resource
|
|
|
- private Alertrule2sService alertrule2sService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private IProEconWindturbineWarnCountService proEconWindturbineWarnCountService;
|
|
|
- @Resource
|
|
|
- private IProEconPartWarnCountService proEconPartWarnCountService;
|
|
|
- @Resource
|
|
|
- private IProEconPartWarnCountSubService proEconPartWarnCountSubService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private AlertrulefailuresubsService alertrulefailuresubsService;
|
|
|
- @Resource
|
|
|
- private IProEconEarlyWarningMainService proEconEarlyWarningMainService;
|
|
|
private final double judgescore = 80;
|
|
|
@Resource
|
|
|
private IProBasicEquipmentPointService proBasicEquipmentPointsService;
|
|
|
- @Resource
|
|
|
- private IProEconCurveFittingSubService proEconCurveFittingSubService;
|
|
|
- @Resource
|
|
|
- private IProEconEquipmentInfoDayTopService proEconEquipmentInfoDayTopService;
|
|
|
+
|
|
|
+
|
|
|
IRealTimeDataBaseUtil realApiUtil = RealTimeDataBaseFactory.createRealTimeDataBase();
|
|
|
+ @Resource
|
|
|
+ private AlarmHistoryService alarmHistoryService;
|
|
|
|
|
|
public void changeHealthModelValue() throws Exception {
|
|
|
|
|
@@ -152,18 +132,17 @@ public class HealthJudgeService {
|
|
|
|
|
|
if(clxzt==4 || fdjzt==4 || bjzt==4 || zkzt==4)
|
|
|
{
|
|
|
- score = score=setScoreValue(score);
|
|
|
+ score=setScoreValue(score);
|
|
|
statejudgment.append("1-");
|
|
|
}else if(clxzt==3 || fdjzt==3 || bjzt==3 || zkzt==3)
|
|
|
{
|
|
|
- score = score=setScoreValue(score);
|
|
|
+ score=setScoreValue(score);
|
|
|
statejudgment.append("1-");
|
|
|
}else {
|
|
|
statejudgment.append("0-");
|
|
|
}
|
|
|
|
|
|
|
|
|
-// Map<String, Double> xnmap = proEconEquipmentInfoDayTopService.findXnfx(Calendar.getInstance().getTime());
|
|
|
Map<String, Double> xnmap=HealthInitialService.djpgchagemap;
|
|
|
if (xnmap.containsKey(wt.getId())) {
|
|
|
double djpgscore = xnmap.get(wt.getId());
|
|
@@ -177,15 +156,7 @@ public class HealthJudgeService {
|
|
|
statejudgment.append("0-");
|
|
|
}
|
|
|
|
|
|
-// Map<String, List<ProEconCurveFittingSub>> cfmap = null;
|
|
|
-// Calendar c = Calendar.getInstance();
|
|
|
-// c.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
-//
|
|
|
-//
|
|
|
-//// cfmap = proEconCurveFittingSubService.findCurvefittingmapByDate(c.getTime(), wt.getId(), 3.0, 5.0);
|
|
|
-//
|
|
|
-// double qxpc1 = proEconCurveFittingSubService.getNuberValue(cfmap, wt);
|
|
|
-// double xfqrqc = Math.abs(qxpc1);
|
|
|
+
|
|
|
Map<String, Double> xfpdmap=HealthInitialService.xfpdchagemap;
|
|
|
if(xfpdmap.containsKey(wt.getId()))
|
|
|
{
|
|
@@ -201,9 +172,6 @@ public class HealthJudgeService {
|
|
|
statejudgment.append("0-");
|
|
|
}
|
|
|
|
|
|
-// cfmap = proEconCurveFittingSubService.findCurvefittingmapByDate(c.getTime(), wt.getId(), 5.0, 11.0);
|
|
|
-// double qxpc2 = proEconCurveFittingSubService.getNuberValue(cfmap, wt);
|
|
|
-// double zcclqc = Math.abs(qxpc2);
|
|
|
|
|
|
Map<String, Double> clpdmap=HealthInitialService.clpdchagemap;
|
|
|
if(clpdmap.containsKey(wt.getId()))
|
|
@@ -219,10 +187,7 @@ public class HealthJudgeService {
|
|
|
}else {
|
|
|
statejudgment.append("0-");
|
|
|
}
|
|
|
-//
|
|
|
-// cfmap = proEconCurveFittingSubService.findCurvefittingmapByDate(c.getTime(), wt.getId(), 11.0, 25.0);
|
|
|
-// double qxpc3 = proEconCurveFittingSubService.getNuberValue(cfmap, wt);
|
|
|
-// double dfqrqc = Math.abs(qxpc3);
|
|
|
+
|
|
|
|
|
|
Map<String, Double> dfpdmap=HealthInitialService.dfpdchagemap;
|
|
|
if(dfpdmap.containsKey(wt.getId()))
|
|
@@ -239,13 +204,12 @@ public class HealthJudgeService {
|
|
|
statejudgment.append("0-");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
po.setStateJudgment(String.valueOf(statejudgment.substring(0, statejudgment.length() - 1)));
|
|
|
|
|
|
pols.add(po);
|
|
|
|
|
|
fjjkzfpoint.setPointValueInDouble(score);
|
|
|
+
|
|
|
realApiUtil.updatePoint(fjjkzfpoint);
|
|
|
|
|
|
}
|
|
@@ -511,14 +475,14 @@ public class HealthJudgeService {
|
|
|
Date beginDate = c.getTime();
|
|
|
Map<String, ResultVo> map = new HashMap<String, ResultVo>();
|
|
|
List<String> resultList = new ArrayList<String>();
|
|
|
- List<Alertrule2> voList = findArsubs(wt.getWindpowerstationId(), wt.getModelId());
|
|
|
- for (Alertrule2 arv : voList) {
|
|
|
- Long snapid = findAlarmsnap(wt, arv.getEdnavalue());
|
|
|
- String cc = findAlarmcount(snapid, beginDate, endDate);
|
|
|
- String[] temp = cc.split(",");
|
|
|
- Double countsum = Double.parseDouble(temp[0]);
|
|
|
+ List<ProEconAlarmRule> voList = findArsubs(wt.getWindpowerstationId(), wt.getModelId());
|
|
|
+ for (ProEconAlarmRule arv : voList) {
|
|
|
+
|
|
|
+ String temp = findAlarmcount(wt.getId(),arv.getStationId(),arv.getModelId(),arv.getId(), beginDate, endDate);
|
|
|
+ Double countsum = Double.parseDouble(temp);
|
|
|
Double benchmark = countsum / 3;
|
|
|
- Double yestodayCount = findyearstodayAlarmcount(snapid, date, date);
|
|
|
+ String yestodayTemp =findAlarmcount(wt.getId(),arv.getStationId(),arv.getModelId(),arv.getId(), date, date);
|
|
|
+ Double yestodayCount =Double.valueOf(yestodayTemp);
|
|
|
Double deviation = 0.0;
|
|
|
if (benchmark != 0) {
|
|
|
deviation = (double) (Math.abs((yestodayCount - benchmark)) / benchmark);
|
|
@@ -656,53 +620,46 @@ public class HealthJudgeService {
|
|
|
/**
|
|
|
* 查询指定时间区间内的规则报警次数
|
|
|
*
|
|
|
- * @param snapid
|
|
|
+ * @param stationId
|
|
|
+ * @param modelId
|
|
|
+ * @param alarmIds
|
|
|
* @param beginDate
|
|
|
* @param endDate
|
|
|
* @return
|
|
|
*/
|
|
|
- private String findAlarmcount(Long snapid, Date beginDate, Date endDate) {
|
|
|
-
|
|
|
- if (snapid != 0) {
|
|
|
+ private String findAlarmcount(String wtId,String stationId, String modelId,String alarmIds, Date beginDate, Date endDate) {
|
|
|
|
|
|
- String result = alarmcountsService.findAlarmcount(snapid, beginDate, endDate);
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
- return "0.0,0.0";
|
|
|
+ String result = "0.0";
|
|
|
+ if(StringUtils.notEmp(stationId) && StringUtils.notEmp(modelId) && StringUtils.notEmp(modelId))
|
|
|
+ {
|
|
|
+ List<AlarmStatVo> pressureList =new ArrayList<>();
|
|
|
|
|
|
- }
|
|
|
+ if(StringUtils.notEmp(stationId) && stationId.contains("FDC"))
|
|
|
+ { String deviceType= AlarmCustomType.WT.getCode();
|
|
|
+ pressureList = alarmHistoryService.findCtFeatureStat(wtId,stationId,modelId, beginDate, endDate,null,deviceType,alarmIds,"m");
|
|
|
|
|
|
- private Double findyearstodayAlarmcount(Long snapid, Date beginDate, Date endDate) {
|
|
|
+ }else if(StringUtils.notEmp(stationId) && stationId.contains("GDC"))
|
|
|
+ { String deviceType= AlarmCustomType.IN.getCode();
|
|
|
+ pressureList = alarmHistoryService.findCtFeatureStat(wtId,stationId,modelId, beginDate, endDate,null,deviceType,alarmIds,"m");
|
|
|
|
|
|
- if (snapid != 0) {
|
|
|
- Double result = alarmcountsService.findyearstodayAlarmcount(snapid, beginDate, endDate);
|
|
|
+ }
|
|
|
|
|
|
- return result;
|
|
|
+ if(!pressureList.isEmpty())
|
|
|
+ {
|
|
|
+ AlarmStatVo vo=pressureList.get(0);
|
|
|
+ StringBuilder sb=new StringBuilder();
|
|
|
+ sb.append(vo.getCount());
|
|
|
+ result = String.valueOf(sb);
|
|
|
+ }
|
|
|
}
|
|
|
- return 0.0;
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 查询风机单个规则在alermsnap表里id snapid:此id可以关联到alarmcount表查询次数
|
|
|
- *
|
|
|
- * @param wt
|
|
|
- * @param ednavalue
|
|
|
- * @return
|
|
|
- */
|
|
|
-
|
|
|
- private Long findAlarmsnap(ProBasicEquipment wt, Long ednavalue) {
|
|
|
+ return result;
|
|
|
|
|
|
- if (StringUtils.notEmp(wt) && StringUtils.notEmp(ednavalue)) {
|
|
|
- Long result = alarmsnapsService.getAlarmsnapid(wt.getId(), ednavalue);
|
|
|
- return result;
|
|
|
- }
|
|
|
|
|
|
- return 0l;
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 查询单个风场型号的特征规则
|
|
|
*
|
|
@@ -710,10 +667,20 @@ public class HealthJudgeService {
|
|
|
* @param staionid
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<Alertrule2> findArsubs(String staionid, String modelid) {
|
|
|
+ private List<ProEconAlarmRule> findArsubs(String staionid, String modelid) {
|
|
|
+
|
|
|
+ List<ProEconAlarmRule> voList =new ArrayList<>();
|
|
|
|
|
|
if (StringUtils.notEmp(modelid) && StringUtils.notEmp(staionid)) {
|
|
|
- List<Alertrule2> voList = alertrule2sService.findAlertRuleList(staionid, modelid);
|
|
|
+
|
|
|
+ StringBuilder sb=new StringBuilder();
|
|
|
+ sb.append(staionid).append("_").append(modelid);
|
|
|
+
|
|
|
+ if(CacheContext.alarmRulesModelMap.containsKey(String.valueOf(sb)))
|
|
|
+ {
|
|
|
+ voList=CacheContext.alarmRulesModelMap.get(String.valueOf(sb));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return voList;
|
|
|
}
|
|
@@ -775,364 +742,8 @@ public class HealthJudgeService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<ProEconWindturbineWarnCount> queryWindturbinebjCountByLineAndAlertrule(Alertrule2 ar, String lnid) {
|
|
|
-
|
|
|
- if (StringUtils.notEmp(ar) && StringUtils.notEmp(lnid)) {
|
|
|
- List<ProEconWindturbineWarnCount> list = proEconWindturbineWarnCountService.queryWindturbinebjCountByLineAndAlertrule(ar.getId(), lnid);
|
|
|
- return list;
|
|
|
- }
|
|
|
- return new ArrayList<>();
|
|
|
- }
|
|
|
-
|
|
|
- private Boolean isExceedingStandard(ProEconWindturbineWarnCount wb) {
|
|
|
- if (wb.getTotal() == 0 || wb.getTotal() <= wb.getAverageQuantity()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (("" + wb.getAverageQuantity()).length() == 1) {
|
|
|
- if (wb.getAverageQuantity() == 0 && wb.getTotal() >= 8) {
|
|
|
- return true;
|
|
|
- } else if (wb.getAverageQuantity() == 1 && wb.getTotal() >= 20) {
|
|
|
- return true;
|
|
|
- } else if (wb.getAverageQuantity() == 2 && wb.getTotal() >= 30) {
|
|
|
- return true;
|
|
|
- } else if (wb.getAverageQuantity() == 3 && wb.getTotal() >= 30) {
|
|
|
- return true;
|
|
|
- } else if (wb.getAverageQuantity() == 4 && wb.getTotal() >= 30) {
|
|
|
- return true;
|
|
|
- } else if (wb.getAverageQuantity() == 5 && wb.getTotal() >= 30) {
|
|
|
- return true;
|
|
|
- } else if (wb.getAverageQuantity() == 6 && wb.getTotal() >= 30) {
|
|
|
- return true;
|
|
|
- } else if (wb.getAverageQuantity() == 7 && wb.getTotal() >= 30) {
|
|
|
- return true;
|
|
|
- } else if (wb.getAverageQuantity() == 8 && wb.getTotal() >= 30) {
|
|
|
- return true;
|
|
|
- } else if (wb.getAverageQuantity() == 9 && wb.getTotal() >= 30) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- } else if (("" + wb.getAverageQuantity()).length() == 2) {
|
|
|
- if (getFirstDigit(wb.getAverageQuantity().intValue()) == 1 && wb.getTotal() >= (wb.getAverageQuantity() * 3)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 2 && wb.getTotal() >= (wb.getAverageQuantity() * 2)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 3 && wb.getTotal() >= (wb.getAverageQuantity() * 1.5)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 4 && wb.getTotal() >= (wb.getAverageQuantity() * 1.4)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 5 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 6 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 7 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 8 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 9 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- } else if (("" + wb.getAverageQuantity()).length() == 3) {
|
|
|
- if (getFirstDigit(wb.getAverageQuantity().intValue()) == 1 && wb.getTotal() >= (wb.getAverageQuantity() * 2)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 2 && wb.getTotal() >= (wb.getAverageQuantity() * 1.5)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 3 && wb.getTotal() >= (wb.getAverageQuantity() * 1.4)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 4 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 5 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 6 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 7 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 8 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 9 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (getFirstDigit(wb.getAverageQuantity().intValue()) == 1 && wb.getTotal() >= (wb.getAverageQuantity() * 1.9)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 2 && wb.getTotal() >= (wb.getAverageQuantity() * 1.5)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 3 && wb.getTotal() >= (wb.getAverageQuantity() * 1.4)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 4 && wb.getTotal() >= (wb.getAverageQuantity() * 1.3)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 5 && wb.getTotal() >= (wb.getAverageQuantity() * 1.2)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 6 && wb.getTotal() >= (wb.getAverageQuantity() * 1.2)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 7 && wb.getTotal() >= (wb.getAverageQuantity() * 1.2)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 8 && wb.getTotal() >= (wb.getAverageQuantity() * 1.2)) {
|
|
|
- return true;
|
|
|
- } else if (getFirstDigit(wb.getAverageQuantity().intValue()) == 9 && wb.getTotal() >= (wb.getAverageQuantity() * 1.2)) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private List<String> queryWindturbinebjCountLine(Alertrule2 ar) {
|
|
|
-
|
|
|
- if (StringUtils.notEmp(ar)) {
|
|
|
- List<String> lnids = proEconWindturbineWarnCountService.queryWindturbinebjCountLine(ar.getId());
|
|
|
- return lnids;
|
|
|
- }
|
|
|
- return new ArrayList<>();
|
|
|
- }
|
|
|
-
|
|
|
- public void savePartbjcount() {
|
|
|
-
|
|
|
-
|
|
|
- Calendar c = Calendar.getInstance();
|
|
|
- c.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
- c.set(Calendar.MINUTE, 0);
|
|
|
- c.set(Calendar.SECOND, 0);
|
|
|
- c.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
- Date date = c.getTime();
|
|
|
|
|
|
- proEconPartWarnCountService.deletePartbjcount(date);
|
|
|
-
|
|
|
- List<Alertrule2> ars = CacheContext.alarmrulels;
|
|
|
- for (Alertrule2 ar : ars) {
|
|
|
- List<String> lnids = queryWindturbinebjCountLine(ar);
|
|
|
- for (String lnid : lnids) {
|
|
|
- int count = 0;
|
|
|
- String part = null;
|
|
|
- List<ProEconWindturbineWarnCount> wclist = queryWindturbinebjCountByLineAndAlertrule(ar, lnid);
|
|
|
- for (ProEconWindturbineWarnCount wc : wclist) {
|
|
|
- boolean temp = isExceedingStandard(wc);
|
|
|
- part = wc.getPart();
|
|
|
- if (temp == true) {
|
|
|
-
|
|
|
- count++;
|
|
|
- }
|
|
|
- }
|
|
|
- if (count >= (wclist.size() * 0.9)) {
|
|
|
- String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
-
|
|
|
- ProEconPartWarnCount po = new ProEconPartWarnCount();
|
|
|
- po.setId(uuid);
|
|
|
- po.setLnId(lnid);
|
|
|
- po.setAlertruleId(ar.getId());
|
|
|
- po.setPart(part);
|
|
|
- po.setRecordDate(DateUtils.truncate(date));
|
|
|
- proEconPartWarnCountService.insertPartbjcount(po);
|
|
|
-
|
|
|
- for (ProEconWindturbineWarnCount wbc : wclist) {
|
|
|
- if (isExceedingStandard(wbc) == true) {
|
|
|
- String id = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
- ProEconPartWarnCountSub posub = new ProEconPartWarnCountSub();
|
|
|
- posub.setId(id);
|
|
|
- posub.setWtId(wbc.getWtId());
|
|
|
- posub.setTotal(wbc.getTotal());
|
|
|
- posub.setAverageQuantity(wbc.getAverageQuantity());
|
|
|
- posub.setPid(uuid);
|
|
|
- proEconPartWarnCountSubService.insertPartbjcountsub(posub);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- public void saveWindturbineBjCount() {
|
|
|
- Calendar c = Calendar.getInstance();
|
|
|
- c.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
- c.set(Calendar.MINUTE, 0);
|
|
|
- c.set(Calendar.SECOND, 0);
|
|
|
- c.add(Calendar.DAY_OF_MONTH, -2);
|
|
|
- Date endDate = c.getTime();
|
|
|
- c.add(Calendar.DAY_OF_MONTH, -6);
|
|
|
- Date beginDate = c.getTime();
|
|
|
- c.add(Calendar.DAY_OF_MONTH, 7);
|
|
|
- Date date = c.getTime();
|
|
|
- List<ProEconWindturbineWarnCount> melist = new ArrayList<ProEconWindturbineWarnCount>();
|
|
|
-
|
|
|
- proEconWindturbineWarnCountService.deleteWindturbinebjcount(date);
|
|
|
-
|
|
|
- for (ProBasicLine line : CacheContext.lines) {
|
|
|
- List<ProBasicEquipment> wtls = CacheContext.wtlinemap.get(line.getId());
|
|
|
- List<DataVo> arlist = findAlertRuleList(line);
|
|
|
- if (arlist != null && arlist.size() > 0) {
|
|
|
-
|
|
|
- for (DataVo ar : arlist) {
|
|
|
-
|
|
|
- for (ProBasicEquipment w : wtls) {
|
|
|
-// if (wobugeqsService
|
|
|
-// .isQueryThreeDayWobugeqs(w.getId()) == false) {
|
|
|
- Long snapid = getAlarmsnapid(w.getId(), ar.getEdnavalue());
|
|
|
- String cc = findAlarmcount(snapid, beginDate, endDate);
|
|
|
- String[] s = cc.split(",");
|
|
|
- Double avg = 0.0;
|
|
|
- if (Double.parseDouble(s[1]) != 0) {
|
|
|
- avg = (Double.parseDouble(s[0]) / Double.parseDouble(s[1]));
|
|
|
- }
|
|
|
-
|
|
|
- Double sjcount = findyearstodayAlarmcount(snapid, date, date);
|
|
|
- String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
- String part = getPartByAlertruleid(ar.getId());
|
|
|
- ProEconWindturbineWarnCount wbc = new ProEconWindturbineWarnCount();
|
|
|
- wbc.setId(uuid);
|
|
|
- wbc.setWtId(w.getId());
|
|
|
- wbc.setLnId(w.getLineId());
|
|
|
- wbc.setWpId(w.getWindpowerstationId());
|
|
|
- wbc.setAlertruleId(ar.getId());
|
|
|
- wbc.setAlertruleName(ar.getName());
|
|
|
- wbc.setPart(part);
|
|
|
- wbc.setTotal(sjcount.intValue());
|
|
|
- wbc.setAverageQuantity(avg);
|
|
|
- wbc.setRecordDate(date);
|
|
|
- melist.add(wbc);
|
|
|
-// }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- insertWindturbineBjCount(melist);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 向WindturbineBjCount表插入数据
|
|
|
- *
|
|
|
- * @param melist
|
|
|
- */
|
|
|
- private void insertWindturbineBjCount(List<ProEconWindturbineWarnCount> melist) {
|
|
|
-
|
|
|
- for (ProEconWindturbineWarnCount wb : melist) {
|
|
|
- proEconWindturbineWarnCountService.insertWindturbineBjCount(wb);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据alertrule2id查询所属分组
|
|
|
- *
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
-
|
|
|
- private String getPartByAlertruleid(String id) {
|
|
|
-
|
|
|
- if (StringUtils.notEmp(id)) {
|
|
|
- List<String> list = alertrulefailuresubsService.getPartByAlertruleid(id);
|
|
|
- if (!list.isEmpty()) {
|
|
|
- return list.get(0);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return "";
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private Long getAlarmsnapid(String wtid, Long ednavalue) {
|
|
|
-
|
|
|
- if (StringUtils.notEmp(wtid) && StringUtils.notEmp(ednavalue)) {
|
|
|
- Long snapid = alarmsnapsService.getAlarmsnapid(wtid, ednavalue);
|
|
|
- return snapid;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return 0l;
|
|
|
- }
|
|
|
-
|
|
|
- private List<DataVo> findAlertRuleList(ProBasicLine line) {
|
|
|
- List<ProBasicEquipment> wt1 = CacheContext.wtlinemap.get(line.getId());
|
|
|
- ProBasicEquipment wt = wt1.get(0);
|
|
|
- List<DataVo> dos = new ArrayList<>();
|
|
|
- if (StringUtils.notEmp(line)) {
|
|
|
- List<Alertrule2> ls = alertrule2sService.findAlertRuleList(wt.getWindpowerstationId(), wt.getModelId());
|
|
|
- if (!ls.isEmpty()) {
|
|
|
- for (Alertrule2 ar : ls) {
|
|
|
- DataVo vo = new DataVo();
|
|
|
- vo.setId(ar.getId());
|
|
|
- vo.setEdnavalue(ar.getEdnavalue());
|
|
|
- vo.setName(ar.getName());
|
|
|
- dos.add(vo);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return dos;
|
|
|
- }
|
|
|
-
|
|
|
- public void test1() {
|
|
|
- final CountDownLatch countDownLatch = new CountDownLatch(6);
|
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
-
|
|
|
- threadPoolTaskExecutor.execute(new Runnable() {
|
|
|
- // 解决多线程操作同一集合
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- // logger.debug("启动:" + wt.getId() + "---" + ar.getId()
|
|
|
- // + "--特征分析子线程--");
|
|
|
-
|
|
|
- //synchronized (this) {
|
|
|
- try {
|
|
|
-
|
|
|
- for (int j = 0; j < 2; j++) {
|
|
|
-
|
|
|
- System.out.println("======" + j);
|
|
|
-
|
|
|
- // if(i==funList.size()-1)
|
|
|
- // {
|
|
|
- // if (obj instanceof Boolean) {
|
|
|
- // if (true == (boolean) obj) {
|
|
|
- // // atomic.getAndIncrement();
|
|
|
- // time++;
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- Thread.sleep(10000);
|
|
|
-
|
|
|
- // logger.debug("剩余线程数:"+countDownLatch.getTotal());
|
|
|
- // logger.debug("完成:" + wt.getId() + "---" +
|
|
|
- // ar.getId() + "--特征分析子线程--");
|
|
|
- //
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- countDownLatch.countDown();// 工人完成工作,计数器减一
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
- // threadPoolTaskExecutor.shutdown();
|
|
|
- try {
|
|
|
- countDownLatch.await();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- // logger.debug("特征提取完成!");
|
|
|
- }
|
|
|
|
|
|
|
|
|
}
|