|
@@ -0,0 +1,162 @@
|
|
|
+package com.gyee.generation.service;
|
|
|
+
|
|
|
+import com.gyee.benchmarkinghistroy.util.realtimesource.IEdosUtil;
|
|
|
+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.generation.init.CacheContext;
|
|
|
+import com.gyee.generation.model.auto.*;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+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 StatusService {
|
|
|
+
|
|
|
+ private Map<String, List<Windturbinestatusdi>> statusMap;
|
|
|
+ private List<Windturbine> wtls;
|
|
|
+ private Map<String, Map<String, Windturbinetestingpointnew>> wtpAimap;
|
|
|
+ private Date currentDate;
|
|
|
+ private List<Windpowerstation> wpls;
|
|
|
+ private Map<String, Equipmentmodel> modelMap;
|
|
|
+ @Resource
|
|
|
+ private IEdosUtil edosUtil;
|
|
|
+ @Value("${clauStatus.ai}")
|
|
|
+ private String clauStatusAi;
|
|
|
+ @Value("${clauStatus.di}")
|
|
|
+ private String clauStatusDi;
|
|
|
+ @Value("${second}")
|
|
|
+ private String second;
|
|
|
+ @Value("${AI134}")
|
|
|
+ private String AI134;
|
|
|
+ @Value("${AI178}")
|
|
|
+ private String AI178;
|
|
|
+
|
|
|
+
|
|
|
+ public void init(){
|
|
|
+ statusMap = CacheContext.statusMap;
|
|
|
+ wtls = CacheContext.wtls;
|
|
|
+ wpls = CacheContext.wpls;
|
|
|
+ wtpAimap = CacheContext.wtpAimap;
|
|
|
+ currentDate = DateUtils.getCurrentDate();
|
|
|
+ modelMap = CacheContext.modelMap;
|
|
|
+ }
|
|
|
+ public void calculateStatus() throws Exception {
|
|
|
+ init();
|
|
|
+ List<PointData> resultList = new ArrayList<>();
|
|
|
+ wpls.stream().forEach(wp->{
|
|
|
+ wtls.stream().filter(i->i.getWindpowerstationid().equals(wp.getId())).forEach(wt->{
|
|
|
+ Map<String, Windturbinetestingpointnew> stringWindturbinetestingpointnewMap = wtpAimap.get(wt.getId());
|
|
|
+ Windturbinetestingpointnew ztmxPoint = stringWindturbinetestingpointnewMap.get(Contant.ZTMX);
|
|
|
+ Windturbinetestingpointnew fj5tPoint = stringWindturbinetestingpointnewMap.get(Contant.FJ5T);
|
|
|
+ String[] interruption = Contant.INTERRUPTION.split(",");
|
|
|
+ List<String> interruptionList = new ArrayList<>();
|
|
|
+ Arrays.stream(interruption).forEach(i->{
|
|
|
+ Windturbinetestingpointnew windturbinetestingpointnew = stringWindturbinetestingpointnewMap.get(i);
|
|
|
+ if (!windturbinetestingpointnew.getCode().equals("INITIAL")){
|
|
|
+ interruptionList.add(windturbinetestingpointnew.getCode());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Integer status = 2;
|
|
|
+ Integer mxstatus = 2;
|
|
|
+ try {
|
|
|
+ List<PointData> interruptionRealData = edosUtil.getRealData(interruptionList);
|
|
|
+ List<PointData> collect = interruptionRealData.stream().filter(i -> Math.abs(currentDate.getTime() - i.getPointTime()) / 1000 < Integer.parseInt(second)).collect(Collectors.toList());
|
|
|
+ if (StringUtils.isEmpty(collect)){
|
|
|
+ Integer ztmx = Integer.parseInt(edosUtil.getRealData(ztmxPoint).getPointValue());
|
|
|
+ if (ztmx == 7 || ztmx == 9 || ztmx == 10 || ztmx == 11 ){
|
|
|
+ mxstatus = ztmx;
|
|
|
+ }
|
|
|
+ if (clauStatusAi.contains(wt.getWindpowerstationid())){
|
|
|
+ //多状态根据一个点来判断
|
|
|
+
|
|
|
+ }
|
|
|
+ if (clauStatusDi.contains(wt.getWindpowerstationid())){
|
|
|
+ //每个状态一个状态点
|
|
|
+ List<Windturbinestatusdi> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.MX000) || w.getUniformcode().equals(Contant.MX002) || w.getUniformcode().equals(Contant.MX006) || w.getUniformcode().equals(Contant.MX008)).collect(Collectors.toList());
|
|
|
+ for(Windturbinestatusdi w : windturbinestatusdis){
|
|
|
+ PointData realData = edosUtil.getRealData(w.getId());
|
|
|
+ if (realData.getPointValueInDouble()==1){
|
|
|
+ mxstatus = Integer.parseInt(w.getTypeid());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (mxstatus == 2){
|
|
|
+ boolean isJcl = false;
|
|
|
+ Windturbinetestingpointnew ai134point = stringWindturbinetestingpointnewMap.get(Contant.AI134);
|
|
|
+ Windturbinetestingpointnew ai178point = stringWindturbinetestingpointnewMap.get(Contant.AI178);
|
|
|
+ Windturbinetestingpointnew ai443point = stringWindturbinetestingpointnewMap.get(Contant.AI443);
|
|
|
+ if (!ai134point.getCode().equals("INITIAL")){
|
|
|
+ Double realData = edosUtil.getRealData(ai134point).getPointValueInDouble();
|
|
|
+ if (realData<Double.parseDouble(AI134)){
|
|
|
+ isJcl = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!ai178point.getCode().equals("INITIAL")){
|
|
|
+ Double realData = edosUtil.getRealData(ai178point).getPointValueInDouble();
|
|
|
+ if (realData<Double.parseDouble(AI178)){
|
|
|
+ isJcl = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!ai443point.getCode().equals("INITIAL")){
|
|
|
+ Double realData = edosUtil.getRealData(ai443point).getPointValueInDouble();
|
|
|
+ if (realData<modelMap.get(wt.getModelid()).getPowerproduction()){
|
|
|
+ isJcl = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isJcl){
|
|
|
+ mxstatus = 3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //离线
|
|
|
+ mxstatus = 12;
|
|
|
+ }
|
|
|
+ if (mxstatus == 0 || mxstatus == 1){
|
|
|
+ status = 0;
|
|
|
+ }else if(mxstatus == 2 || mxstatus == 3){
|
|
|
+ status = 1;
|
|
|
+ }else if(mxstatus == 4 || mxstatus == 5){
|
|
|
+ status = 5;
|
|
|
+ }else if(mxstatus == 6 || mxstatus == 7){
|
|
|
+ status = 2;
|
|
|
+ }else if(mxstatus == 8 || mxstatus == 9){
|
|
|
+ status = 4;
|
|
|
+ }else if(mxstatus == 10 || mxstatus == 11){
|
|
|
+ status = 2;
|
|
|
+ }else if(mxstatus == 12){
|
|
|
+ status = 6;
|
|
|
+ }
|
|
|
+ PointData ztmx = createPointData(ztmxPoint, mxstatus);
|
|
|
+ PointData fj5t = createPointData(fj5tPoint, status);
|
|
|
+ resultList.add(ztmx);
|
|
|
+ resultList.add(fj5t);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ edosUtil.sendMultiPoint(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private PointData createPointData(Windturbinetestingpointnew ztmxPoint, Integer mxstatus) {
|
|
|
+ PointData pointData = new PointData();
|
|
|
+ pointData.setEdnaId(ztmxPoint.getCode());
|
|
|
+ pointData.setPointName(ztmxPoint.getName());
|
|
|
+ pointData.setPointTime(currentDate.getTime());
|
|
|
+ pointData.setPointValue(String.valueOf(mxstatus));
|
|
|
+ pointData.setPointValueInDouble(mxstatus);
|
|
|
+ return pointData;
|
|
|
+ }
|
|
|
+}
|