|
@@ -0,0 +1,161 @@
|
|
|
+package com.gyee.datacenter.service;
|
|
|
+
|
|
|
+
|
|
|
+import com.gyee.common.model.PointData;
|
|
|
+import com.gyee.common.model.StringUtils;
|
|
|
+import com.gyee.common.util.ClassUtil;
|
|
|
+import com.gyee.common.util.DateUtils;
|
|
|
+import com.gyee.common.vo.datacenter.CurveVo;
|
|
|
+import com.gyee.common.vo.datacenter.ParameterComparisonVo;
|
|
|
+import com.gyee.datacenter.init.CacheContext;
|
|
|
+
|
|
|
+import com.gyee.datacenter.model.auto.Windturbinetestingpointai;
|
|
|
+import com.gyee.datacenter.util.realtimesource.EdosUtil;
|
|
|
+import com.gyee.datacenter.util.realtimesource.IEdosUtil;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName : ParameterComparisonService
|
|
|
+ * @Author : xieshengjie
|
|
|
+ * @Date: 2021/5/25 8:52
|
|
|
+ * @Description : 参数对比service
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ParameterComparisonService {
|
|
|
+
|
|
|
+
|
|
|
+ private IEdosUtil edosUtil = new EdosUtil();
|
|
|
+
|
|
|
+ public List<Object> generatingCurveBywt(String begin, String end, String interval, String type, String wt, String params) throws Exception {
|
|
|
+ List<Object> resultList = new ArrayList<>();
|
|
|
+ Date beginDate = DateUtils.parseDate1(begin);
|
|
|
+ Date endDate = DateUtils.parseDate1(end);
|
|
|
+ Map<String,List<ParameterComparisonVo>> result = new HashMap<>();
|
|
|
+// List<List<ParameterComparisonVo>> result = new ArrayList<>();
|
|
|
+ Map<String, Map<String, Windturbinetestingpointai>> wtpointmap = CacheContext.wtpointmap;
|
|
|
+ Map<String, String> codemap = CacheContext.codemap;
|
|
|
+
|
|
|
+ String[] paramArray = params.split(",");
|
|
|
+ Map<String, Windturbinetestingpointai> stringWindturbinetestingpointai2Map = wtpointmap.get(wt);
|
|
|
+ for (String param : paramArray) {
|
|
|
+ List<ParameterComparisonVo> paramList = new ArrayList<>();
|
|
|
+ List<PointData> pointDatas = null;
|
|
|
+ Windturbinetestingpointai windturbinetestingpointai2 = stringWindturbinetestingpointai2Map.get(param);
|
|
|
+ if(null !=windturbinetestingpointai2){
|
|
|
+ if (interval != null) {
|
|
|
+ if (type!=null){
|
|
|
+ pointDatas = edosUtil.getHistStat(windturbinetestingpointai2,beginDate.getTime()/1000, endDate.getTime()/1000,null,Long.parseLong(interval),Integer.parseInt(type));
|
|
|
+ }else{
|
|
|
+ pointDatas = edosUtil.getHistoryDatasSnap(windturbinetestingpointai2,beginDate.getTime()/1000, endDate.getTime()/1000,null,Long.parseLong(interval));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ pointDatas = edosUtil.getHistoryDatasRaw(windturbinetestingpointai2, beginDate.getTime(), endDate.getTime());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(pointDatas)){
|
|
|
+ pointDatas.stream().forEach(pointData->{
|
|
|
+ ParameterComparisonVo vo = new ParameterComparisonVo();
|
|
|
+ vo.setWtid(wt);
|
|
|
+ vo.setTagetName(codemap.get(param));
|
|
|
+ vo.setValue(pointData.getPointValueInDouble());
|
|
|
+ vo.setTime(DateUtils.parseLongToDate(pointData.getPointTime()*1000));
|
|
|
+ paramList.add(vo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ result.put(codemap.get(param),paramList);
|
|
|
+// result.add(paramList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (result !=null && result.size()>0){
|
|
|
+ List<ParameterComparisonVo> parameterComparisonVos = result.values().stream().findFirst().get();
|
|
|
+ parameterComparisonVos.stream().forEach(i->{
|
|
|
+ CurveVo vo = new CurveVo();
|
|
|
+ vo.setTime(i.getTime());
|
|
|
+// vo.setWtid(i.getWtid());
|
|
|
+ resultList.add(vo);
|
|
|
+ });
|
|
|
+ Set<String> paramsString = result.keySet();
|
|
|
+ for (int i = 0;i<resultList.size();i++){
|
|
|
+ LinkedHashMap addMap = new LinkedHashMap();
|
|
|
+ LinkedHashMap addValMap = new LinkedHashMap();
|
|
|
+ for (String param : paramsString) {
|
|
|
+ addMap.put(param,Class.forName("java.lang.Double"));
|
|
|
+ addValMap.put(param, result.get(param).get(i).getValue());
|
|
|
+ }
|
|
|
+ addMap.put("风机",Class.forName("java.lang.String"));
|
|
|
+ addValMap.put("风机", wt);
|
|
|
+ Object blo = new ClassUtil().dynamicClass(resultList.get(i), addMap, addValMap);
|
|
|
+ resultList.set(i,blo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Object> generatingCurveByParam(String begin, String end, String interval, String type, String wts, String params) throws Exception {
|
|
|
+ List<Object> resultList = new ArrayList<>();
|
|
|
+ Date beginDate = DateUtils.parseDate1(begin);
|
|
|
+ Date endDate = DateUtils.parseDate1(end);
|
|
|
+ Map<String,List<ParameterComparisonVo>> result = new HashMap<>();
|
|
|
+
|
|
|
+ Map<String, Map<String, Windturbinetestingpointai>> wtpointmap = CacheContext.wtpointmap;
|
|
|
+ Map<String, String> codemap = CacheContext.codemap;
|
|
|
+ Map<String, String> wtmap = CacheContext.wtmap;
|
|
|
+
|
|
|
+ String[] wtArray = wts.split(",");
|
|
|
+ for (String wt : wtArray) {
|
|
|
+ List<ParameterComparisonVo> wtsList = new ArrayList<>();
|
|
|
+ List<PointData> pointDatas = null;
|
|
|
+ Windturbinetestingpointai windturbinetestingpointai2 = wtpointmap.get(wt).get(params);
|
|
|
+ if (null != windturbinetestingpointai2){
|
|
|
+ if (interval != null) {
|
|
|
+ if (type!=null){
|
|
|
+ pointDatas = edosUtil.getHistStat(windturbinetestingpointai2,beginDate.getTime()/1000, endDate.getTime()/1000,null,Long.parseLong(interval),Integer.parseInt(type));
|
|
|
+ }else{
|
|
|
+ pointDatas = edosUtil.getHistoryDatasSnap(windturbinetestingpointai2,beginDate.getTime()/1000, endDate.getTime()/1000,null,Long.parseLong(interval));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ pointDatas = edosUtil.getHistoryDatasRaw(windturbinetestingpointai2, beginDate.getTime(), endDate.getTime());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(pointDatas)){
|
|
|
+ pointDatas.stream().forEach(pointData->{
|
|
|
+ ParameterComparisonVo vo = new ParameterComparisonVo();
|
|
|
+ vo.setWtid(wt);
|
|
|
+ vo.setTagetName(codemap.get(params));
|
|
|
+ vo.setValue(pointData.getPointValueInDouble());
|
|
|
+ vo.setTime(DateUtils.parseLongToDate(pointData.getPointTime()*1000));
|
|
|
+ wtsList.add(vo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ result.put(wt,wtsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (result !=null && result.size()>0){
|
|
|
+ List<ParameterComparisonVo> parameterComparisonVos = result.values().stream().findFirst().get();
|
|
|
+ parameterComparisonVos.stream().forEach(i->{
|
|
|
+ CurveVo vo = new CurveVo();
|
|
|
+ vo.setTime(i.getTime());
|
|
|
+// vo.setWtid(i.getWtid());
|
|
|
+ resultList.add(vo);
|
|
|
+ });
|
|
|
+ Set<String> wtstring = result.keySet();
|
|
|
+ for (int i = 0;i<resultList.size();i++){
|
|
|
+ if (resultList.get(i)==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ LinkedHashMap addMap = new LinkedHashMap();
|
|
|
+ LinkedHashMap addValMap = new LinkedHashMap();
|
|
|
+ for (String wt : wtstring) {
|
|
|
+ addMap.put(wtmap.get(wt),Class.forName("java.lang.Double"));
|
|
|
+ addValMap.put(wtmap.get(wt), result.get(wt).size()>0?result.get(wt).get(i).getValue():0);
|
|
|
+ }
|
|
|
+ addMap.put("指标",Class.forName("java.lang.String"));
|
|
|
+ addValMap.put("指标", CacheContext.codemap.get(params));
|
|
|
+ Object blo = new ClassUtil().dynamicClass(resultList.get(i), addMap, addValMap);
|
|
|
+ resultList.set(i,blo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|