|
@@ -0,0 +1,421 @@
|
|
|
+package com.gyee.failurestatistics.service;
|
|
|
+
|
|
|
+import com.gyee.common.model.PointData;
|
|
|
+import com.gyee.common.model.StringUtils;
|
|
|
+import com.gyee.failurestatistics.init.CacheContext;
|
|
|
+import com.gyee.failurestatistics.init.Constant;
|
|
|
+import com.gyee.failurestatistics.model.auto.*;
|
|
|
+import com.gyee.failurestatistics.service.auto.IParttemperaturemainService;
|
|
|
+import com.gyee.failurestatistics.service.auto.IParttemperaturesubService;
|
|
|
+import com.gyee.failurestatistics.util.DateUtils;
|
|
|
+import com.gyee.failurestatistics.util.realtimesource.EdosUtil;
|
|
|
+import com.gyee.failurestatistics.util.realtimesource.IEdosUtil;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.Map.Entry;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName : ParttemperatureService
|
|
|
+ * @Description : 部件温度统计service
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ParttemperatureService {
|
|
|
+
|
|
|
+ private IEdosUtil ednaApiUtil = new EdosUtil();
|
|
|
+ @Resource
|
|
|
+ private IParttemperaturemainService parttemperaturemainService;
|
|
|
+ @Resource
|
|
|
+ private IParttemperaturesubService parttemperaturesubService;
|
|
|
+ private final long STEP = 900;
|
|
|
+ private final long DAYSTEP = 96;
|
|
|
+
|
|
|
+ SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+
|
|
|
+ private String CLXSRZYW1 = "AI038";// 齿轮箱输入轴油温1
|
|
|
+ private String CLXSRZYW2 = "AI039";// 齿轮箱输入轴油温2
|
|
|
+ private String CLXRKYW = "AI040";// 齿轮箱入口温度
|
|
|
+ private String CLXYW = "AI041";// 齿轮箱油温
|
|
|
+
|
|
|
+ private String FDJZCWDA = "AI052";// 发电机轴承温度A
|
|
|
+ private String FDJZCWDB = "AI053";// 发电机轴承温度B
|
|
|
+ private String FDJUXYZWD = "AI045";// 发电机U相绕组温度
|
|
|
+ private String FDJVXYZWD = "AI047";// 发电机V相绕组温度
|
|
|
+ private String FDJWXYZWD = "AI049";// 发电机W相绕组温度
|
|
|
+ private String FDJLQFWD = "AI054";// 发电机冷却风温度
|
|
|
+
|
|
|
+ private String BJDRQWD = "AI113";// 变浆电容器温度
|
|
|
+ private String BJDRDY = "AI236";// 变浆电容温度
|
|
|
+ private String BJDLQWD = "AI239";// 变浆电流器温度
|
|
|
+ private String BJDJWD = "AI242";// 电机温度
|
|
|
+ private String BJKZGWD = "AI233";// 变浆控制柜温度
|
|
|
+
|
|
|
+ private String TDGWD = "AI069";// 塔底柜温度
|
|
|
+ private String TDJGWD = "AI070";// 塔顶机柜温度
|
|
|
+
|
|
|
+ public void deleteParttemperaturemain(Date recodedate) {
|
|
|
+ parttemperaturemainService.deleteParttemperaturemain(recodedate);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public int insertParttemperaturemain(Parttemperaturemain po) {
|
|
|
+
|
|
|
+ return parttemperaturemainService.insertParttemperaturemain(po);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void saveParttemperaturestattics() throws Exception {
|
|
|
+
|
|
|
+ System.out.println("开始统计温度对应部件指标统计");
|
|
|
+
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ cal.set(Calendar.MINUTE, 0);
|
|
|
+ cal.set(Calendar.SECOND, 0);
|
|
|
+ Date endDate = cal.getTime();
|
|
|
+ cal.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
+ Date beginDate = cal.getTime();
|
|
|
+
|
|
|
+ List<String> codels = new ArrayList<String>();
|
|
|
+ Map<String, String> codeParentmap = new HashMap<String, String>();
|
|
|
+ Map<String, String> codenamemap = new HashMap<String, String>();
|
|
|
+
|
|
|
+ initialCodeValue(codels, codeParentmap, codenamemap);
|
|
|
+
|
|
|
+ cal.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
+
|
|
|
+ deleteParttemperaturemain(cal.getTime());
|
|
|
+ for (Windpowerstation wp : CacheContext.wpls) {
|
|
|
+ if (wp.getId().endsWith("FDC")) {
|
|
|
+
|
|
|
+ List<Windturbine> wtls = CacheContext.wtsmap.get(wp.getId());
|
|
|
+
|
|
|
+ // 初始化当日数据
|
|
|
+ statticsData(cal,endDate, beginDate, wtls,codeParentmap, codenamemap);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("结束统计温度对应部件指标统计");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void statticsData(Calendar cal,Date endDate, Date beginDate, List<Windturbine> wtls,Map<String, String> codeParentmap,Map<String, String> codenamemap) throws Exception {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for (Windturbine wt : wtls) {
|
|
|
+
|
|
|
+ Map<String, Windturbinetestingpointai> map = CacheContext.wtpAimap.get(wt.getId());
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Double> wdmap = getWdValue(wt, Constant.TPOINT_WT_JCWD, endDate, beginDate, map);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Double> cLXSRZYW1map = getPartTargetValue(wt, CLXSRZYW1, endDate, beginDate, map);
|
|
|
+ Map<String, Double> cLXSRZYW2map = getPartTargetValue(wt, CLXSRZYW2, endDate, beginDate, map);
|
|
|
+ Map<String, Double> cLXRKYWmap = getPartTargetValue(wt, CLXRKYW, endDate, beginDate, map);
|
|
|
+ Map<String, Double> cLXYWmap = getPartTargetValue(wt, CLXYW, endDate, beginDate, map);
|
|
|
+
|
|
|
+ Map<String, Double> fDJZCWDAmap = getPartTargetValue(wt, FDJZCWDA, endDate, beginDate, map);
|
|
|
+ Map<String, Double> fDJZCWDBmap = getPartTargetValue(wt, FDJZCWDB, endDate, beginDate, map);
|
|
|
+ Map<String, Double> fDJUXYZWDmap = getPartTargetValue(wt, FDJUXYZWD, endDate, beginDate, map);
|
|
|
+ Map<String, Double> fDJVXYZWDmap = getPartTargetValue(wt, FDJVXYZWD, endDate, beginDate, map);
|
|
|
+ Map<String, Double> fDJWXYZWDmap = getPartTargetValue(wt, FDJWXYZWD, endDate, beginDate, map);
|
|
|
+ Map<String, Double> fDJLQFWDmap = getPartTargetValue(wt, FDJLQFWD, endDate, beginDate, map);
|
|
|
+
|
|
|
+ Map<String, Double> bJDRQWDmap = getPartTargetValue(wt, BJDRQWD, endDate, beginDate, map);
|
|
|
+ Map<String, Double> bJDRDYmap = getPartTargetValue(wt, BJDRDY, endDate, beginDate, map);
|
|
|
+ Map<String, Double> bJDLQWDmap = getPartTargetValue(wt, BJDLQWD, endDate, beginDate, map);
|
|
|
+ Map<String, Double> bJDJWDmap = getPartTargetValue(wt, BJDJWD, endDate, beginDate, map);
|
|
|
+ Map<String, Double> bJKZGWDmap = getPartTargetValue(wt, BJKZGWD, endDate, beginDate, map);
|
|
|
+
|
|
|
+ Map<String, Double> tDGWDmap = getPartTargetValue(wt, TDGWD, endDate, beginDate, map);
|
|
|
+ Map<String, Double> tDJGWDmap = getPartTargetValue(wt, TDJGWD, endDate, beginDate, map);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Map<String, Integer>> pointmap =new HashMap<>();
|
|
|
+ if (!wdmap.isEmpty() ) {
|
|
|
+
|
|
|
+ Set<Map.Entry<String, Double>> wdset = wdmap.entrySet();
|
|
|
+ //按照温度区间》测点》统计数量
|
|
|
+ for (Iterator<Map.Entry<String, Double>> wdit = wdset.iterator(); wdit.hasNext();) {
|
|
|
+
|
|
|
+ Map.Entry<String, Double> wdentry = (Map.Entry<String, Double>) wdit.next();
|
|
|
+
|
|
|
+
|
|
|
+ setPointValues(CLXSRZYW1, cLXSRZYW1map, pointmap, wdentry);
|
|
|
+ setPointValues(CLXSRZYW2, cLXSRZYW2map, pointmap, wdentry);
|
|
|
+ setPointValues(CLXRKYW, cLXRKYWmap, pointmap, wdentry);
|
|
|
+ setPointValues(CLXYW, cLXYWmap, pointmap, wdentry);
|
|
|
+
|
|
|
+ setPointValues(FDJZCWDA, fDJZCWDAmap, pointmap, wdentry);
|
|
|
+ setPointValues(FDJZCWDB, fDJZCWDBmap, pointmap, wdentry);
|
|
|
+ setPointValues(FDJUXYZWD, fDJUXYZWDmap, pointmap, wdentry);
|
|
|
+ setPointValues(FDJVXYZWD, fDJVXYZWDmap, pointmap, wdentry);
|
|
|
+ setPointValues(FDJWXYZWD, fDJWXYZWDmap, pointmap, wdentry);
|
|
|
+ setPointValues(FDJLQFWD, fDJLQFWDmap, pointmap, wdentry);
|
|
|
+
|
|
|
+ setPointValues(BJDRQWD, bJDRQWDmap, pointmap, wdentry);
|
|
|
+ setPointValues(BJDRDY, bJDRDYmap, pointmap, wdentry);
|
|
|
+ setPointValues(BJDLQWD, bJDLQWDmap, pointmap, wdentry);
|
|
|
+ setPointValues(BJDJWD, bJDJWDmap, pointmap, wdentry);
|
|
|
+ setPointValues(BJKZGWD, bJKZGWDmap, pointmap, wdentry);
|
|
|
+
|
|
|
+ setPointValues(TDGWD, tDGWDmap, pointmap, wdentry);
|
|
|
+ setPointValues(TDJGWD, tDJGWDmap, pointmap, wdentry);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Set<Map.Entry<String, Map<String, Integer>>> pointset = pointmap.entrySet();
|
|
|
+ //按照温度区间》测点》统计数量
|
|
|
+ for (Iterator<Map.Entry<String, Map<String, Integer>>> pointit = pointset.iterator(); pointit.hasNext();) {
|
|
|
+
|
|
|
+ Map.Entry<String, Map<String, Integer>> pointentry = (Map.Entry<String, Map<String, Integer>>) pointit.next();
|
|
|
+
|
|
|
+ int num=0;
|
|
|
+ Parttemperaturemain po = new Parttemperaturemain();
|
|
|
+ po.setId(StringUtils.getUUID());
|
|
|
+ po.setWpid(wt.getWindpowerstationid());
|
|
|
+ po.setWtid(wt.getId());
|
|
|
+ po.setWtname(wt.getName());
|
|
|
+ po.setRecodedate(cal.getTime());
|
|
|
+ po.setTrange(pointentry.getKey());
|
|
|
+
|
|
|
+ Set<Map.Entry<String, Integer>> pset = pointentry.getValue().entrySet();
|
|
|
+ //测点》统计数量
|
|
|
+ for (Iterator<Map.Entry<String, Integer>> pit = pset.iterator(); pit.hasNext();) {
|
|
|
+
|
|
|
+ Map.Entry<String, Integer> pentry = (Map.Entry<String, Integer>) pit.next();
|
|
|
+ Parttemperaturesub sub = new Parttemperaturesub();
|
|
|
+ sub.setId(StringUtils.getUUID());
|
|
|
+ sub.setWpid(wt.getWindpowerstationid());
|
|
|
+ sub.setWtid(wt.getId());
|
|
|
+ sub.setWtname(wt.getName());
|
|
|
+ sub.setRecodedate(cal.getTime());
|
|
|
+ sub.setTrange(pointentry.getKey());
|
|
|
+ sub.setPointname(codenamemap.get(pentry.getKey()));
|
|
|
+ sub.setPartname(codeParentmap.get(pentry.getKey()));
|
|
|
+ sub.setTsnumber(pentry.getValue());
|
|
|
+ num=num+pentry.getValue();
|
|
|
+ parttemperaturesubService.insertParttemperaturesub(sub);
|
|
|
+ }
|
|
|
+
|
|
|
+ po.setTsnumber(num);
|
|
|
+ insertParttemperaturemain(po);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //System.out.println("初始化当日数据报错!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setPointValues(String code,Map<String, Double> valuemap, Map<String, Map<String, Integer>> pointmap, Map.Entry<String, Double> wdentry) {
|
|
|
+
|
|
|
+ if(StringUtils.notEmp(valuemap))
|
|
|
+ {
|
|
|
+ String wdkey=getPoStringInfo(wdentry.getValue());
|
|
|
+
|
|
|
+ if(pointmap.containsKey(wdkey))
|
|
|
+ {
|
|
|
+ Map<String, Integer> pmap=pointmap.get(wdkey);
|
|
|
+
|
|
|
+ if(pmap.containsKey(code))
|
|
|
+ {
|
|
|
+ int num=pmap.get(code);
|
|
|
+
|
|
|
+ num=num+setPointValue(wdentry.getKey(), valuemap);
|
|
|
+ pmap.put(code, num);
|
|
|
+ pointmap.put(wdkey, pmap);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ int num=0;
|
|
|
+ num=num+setPointValue(wdentry.getKey(), valuemap);
|
|
|
+ pmap.put(code, num);
|
|
|
+ pointmap.put(wdkey, pmap);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ Map<String, Integer> pmap=new HashMap<>();
|
|
|
+ int num=0;
|
|
|
+ num=num+setPointValue(wdentry.getKey(), valuemap);
|
|
|
+ pmap.put(code, num);
|
|
|
+ pointmap.put(wdkey, pmap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getPoStringInfo(double value) {
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ int num =0;
|
|
|
+ int WDSTEP = 5;
|
|
|
+ if (value < 0) {
|
|
|
+ num = (int) value / WDSTEP;
|
|
|
+ sb.append((num - 1) * WDSTEP).append("-").append(num * WDSTEP);
|
|
|
+ } else {
|
|
|
+ num = (int) value / WDSTEP;
|
|
|
+ sb.append(num * WDSTEP).append("-").append((num + 1) * WDSTEP);
|
|
|
+ }
|
|
|
+ return String.valueOf(sb);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initialCodeValue(List<String> codels, Map<String, String> codeParentmap, Map<String, String> codenamemap) {
|
|
|
+
|
|
|
+ codels.add(CLXSRZYW1);
|
|
|
+ codels.add(CLXSRZYW2);
|
|
|
+ codels.add(CLXRKYW);
|
|
|
+ codels.add(CLXYW);
|
|
|
+
|
|
|
+ codels.add(FDJZCWDA);
|
|
|
+ codels.add(FDJZCWDB);
|
|
|
+ codels.add(FDJUXYZWD);
|
|
|
+ codels.add(FDJVXYZWD);
|
|
|
+ codels.add(FDJWXYZWD);
|
|
|
+ codels.add(FDJLQFWD);
|
|
|
+
|
|
|
+ codels.add(BJDRQWD);
|
|
|
+ codels.add(BJDRDY);
|
|
|
+ codels.add(BJDLQWD);
|
|
|
+ codels.add(BJDJWD);
|
|
|
+ codels.add(BJKZGWD);
|
|
|
+
|
|
|
+ codels.add(TDGWD);
|
|
|
+ codels.add(TDJGWD);
|
|
|
+
|
|
|
+ codeParentmap.put(CLXSRZYW1, "clx");
|
|
|
+ codeParentmap.put(CLXSRZYW2, "clx");
|
|
|
+ codeParentmap.put(CLXRKYW, "clx");
|
|
|
+ codeParentmap.put(CLXYW, "clx");
|
|
|
+
|
|
|
+ codeParentmap.put(FDJZCWDA, "fdj");
|
|
|
+ codeParentmap.put(FDJZCWDB, "fdj");
|
|
|
+ codeParentmap.put(FDJUXYZWD, "fdj");
|
|
|
+ codeParentmap.put(FDJVXYZWD, "fdj");
|
|
|
+ codeParentmap.put(FDJWXYZWD, "fdj");
|
|
|
+ codeParentmap.put(FDJLQFWD, "fdj");
|
|
|
+
|
|
|
+ codeParentmap.put(BJDRQWD, "bj");
|
|
|
+ codeParentmap.put(BJDRDY, "bj");
|
|
|
+ codeParentmap.put(BJDLQWD, "bj");
|
|
|
+ codeParentmap.put(BJDJWD, "bj");
|
|
|
+ codeParentmap.put(BJKZGWD, "bj");
|
|
|
+
|
|
|
+ codeParentmap.put(TDGWD, "zk");
|
|
|
+ codeParentmap.put(TDJGWD, "zk");
|
|
|
+
|
|
|
+ codenamemap.put(CLXSRZYW1, "齿轮箱输入轴油温1");
|
|
|
+ codenamemap.put(CLXSRZYW2, "齿轮箱输入轴油温2");
|
|
|
+ codenamemap.put(CLXRKYW, "齿轮箱入口温度");
|
|
|
+ codenamemap.put(CLXYW, "齿轮箱油温");
|
|
|
+
|
|
|
+ codenamemap.put(FDJZCWDA, "发电机轴承温度A");
|
|
|
+ codenamemap.put(FDJZCWDB, "发电机轴承温度B");
|
|
|
+ codenamemap.put(FDJUXYZWD, "发电机U相绕组温度");
|
|
|
+ codenamemap.put(FDJVXYZWD, "发电机V相绕组温度");
|
|
|
+ codenamemap.put(FDJWXYZWD, "发电机W相绕组温度");
|
|
|
+ codenamemap.put(FDJLQFWD, "发电机冷却风温度");
|
|
|
+
|
|
|
+ codenamemap.put(BJDRQWD, "变浆电容器温度");
|
|
|
+ codenamemap.put(BJDRDY, "变浆电容温度");
|
|
|
+ codenamemap.put(BJDLQWD, "变浆电流器温度");
|
|
|
+ codenamemap.put(BJDJWD, "电机温度");
|
|
|
+ codenamemap.put(BJKZGWD, "变浆控制柜温度");
|
|
|
+
|
|
|
+ codenamemap.put(TDGWD, "塔底柜温度");
|
|
|
+ codenamemap.put(TDJGWD, "塔顶机柜温度");
|
|
|
+ }
|
|
|
+
|
|
|
+ private int setPointValue(String step,Map<String, Double> pointmap) {
|
|
|
+ int num=0;
|
|
|
+ if (pointmap.containsKey(step)) {
|
|
|
+
|
|
|
+ Double value=pointmap.get(step);
|
|
|
+ if(value>0)
|
|
|
+ {
|
|
|
+ num=1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return num;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private Map<String, Double> getPartTargetValue(Windturbine wt, String code, Date endDate, Date beginDate, Map<String, Windturbinetestingpointai> map) throws Exception {
|
|
|
+
|
|
|
+ Map<String, Double> resultmap = new TreeMap<String, Double>();
|
|
|
+
|
|
|
+ if (map.containsKey(code)) {
|
|
|
+ Windturbinetestingpointai point = map.get(code);
|
|
|
+
|
|
|
+ double max=null!=point.getReasonablemaxval()?point.getReasonablemaxval():10000.0;
|
|
|
+ double min=null!=point.getReasonableminval()?point.getReasonableminval():0.0;
|
|
|
+ try {
|
|
|
+ List<PointData> pointls = ednaApiUtil.getHistoryDatasSnap(point, beginDate.getTime() / 1000, endDate.getTime() / 1000, DAYSTEP, STEP);
|
|
|
+
|
|
|
+ if (!pointls.isEmpty()) {
|
|
|
+
|
|
|
+ for (PointData pd : pointls) {
|
|
|
+ Date date = DateUtils.parseLongToDate(pd.getPointTime() * 1000);
|
|
|
+ double value=pd.getPointValueInDouble();
|
|
|
+ if(value>max || value<min)
|
|
|
+ {
|
|
|
+ resultmap.put(df2.format(date), 1.0);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ resultmap.put(df2.format(date), 0.0);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e.getMessage()+point.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultmap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private Map<String, Double> getWdValue(Windturbine wt, String code, Date endDate, Date beginDate, Map<String, Windturbinetestingpointai> map) throws Exception {
|
|
|
+
|
|
|
+ Map<String, Double> resultmap = new TreeMap<String, Double>();
|
|
|
+
|
|
|
+ if (map.containsKey(code)) {
|
|
|
+ Windturbinetestingpointai point = map.get(code);
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<PointData> pointls = ednaApiUtil.getHistoryDatasSnap(point, beginDate.getTime() / 1000, endDate.getTime() / 1000, DAYSTEP, STEP);
|
|
|
+
|
|
|
+ if (!pointls.isEmpty()) {
|
|
|
+
|
|
|
+ for (PointData pd : pointls) {
|
|
|
+ Date date = DateUtils.parseLongToDate(pd.getPointTime() * 1000);
|
|
|
+ double value=pd.getPointValueInDouble();
|
|
|
+ resultmap.put(df2.format(date), value);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e.getMessage()+point.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultmap;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|