|
@@ -0,0 +1,375 @@
|
|
|
+package com.gyee.frame.service.health;
|
|
|
+
|
|
|
+import com.gyee.common.model.PointData;
|
|
|
+import com.gyee.frame.common.spring.Constant;
|
|
|
+import com.gyee.frame.common.spring.InitialRunner;
|
|
|
+import com.gyee.frame.model.auto.ProBasicPowerstation;
|
|
|
+import com.gyee.frame.model.auto.ProBasicPowerstationPoint;
|
|
|
+import com.gyee.frame.model.auto.ProBasicProject;
|
|
|
+import com.gyee.frame.service.auto.*;
|
|
|
+import com.gyee.frame.util.IRealTimeDataBaseUtil;
|
|
|
+import com.gyee.frame.util.RealTimeDataBaseFactory;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class HealthOperationService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProBasicEquipmentPointService proBasicEquipmentPointService;
|
|
|
+ @Resource
|
|
|
+ private IProEconWeatherFdService proEconWeatherFdService;
|
|
|
+ @Resource
|
|
|
+ private IProEconWeatherFhService proEconWeatherFhService;
|
|
|
+ @Resource
|
|
|
+ private IProEconShutdownEventService proEconShutdownEventService;
|
|
|
+ @Resource
|
|
|
+ private IProBasicPowerstationPointService proBasicPowerstationPointService;
|
|
|
+
|
|
|
+ private final String QS = "0";
|
|
|
+
|
|
|
+ private final int digit = 2;
|
|
|
+ private final double NUM = 3.6;
|
|
|
+ private final double XZNUM = 1.25;
|
|
|
+ IRealTimeDataBaseUtil realApiUtil = RealTimeDataBaseFactory.createRealTimeDataBase();
|
|
|
+
|
|
|
+
|
|
|
+ * 获得全省各种状态数量
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public Map<String, Integer> countWpNumStatus() throws Exception {
|
|
|
+
|
|
|
+ Map<String, Integer> mapstatus = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+ List<String> idls=new ArrayList<>();
|
|
|
+
|
|
|
+ ProBasicPowerstationPoint point = proBasicPowerstationPointService.getPowerstationPoint(QS, Constant.FJZCSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(QS, Constant.FJLHSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(QS, Constant.FJZYSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(QS, Constant.FJYZSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+
|
|
|
+
|
|
|
+ List<PointData> pols=realApiUtil.getRealData(idls);
|
|
|
+
|
|
|
+ if(!pols.isEmpty() && pols.size()==idls.size())
|
|
|
+ {
|
|
|
+ Integer zc = ((Double) pols.get(0).getPointValueInDouble()).intValue();
|
|
|
+ Integer lh = ((Double) pols.get(1).getPointValueInDouble()).intValue();
|
|
|
+ Integer zy = ((Double) pols.get(2).getPointValueInDouble()).intValue();
|
|
|
+ Integer yz = ((Double) pols.get(3).getPointValueInDouble()).intValue();
|
|
|
+
|
|
|
+ mapstatus.put("zc", zc);
|
|
|
+ mapstatus.put("lh", lh);
|
|
|
+ mapstatus.put("zy", zy);
|
|
|
+ mapstatus.put("yz", yz);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return mapstatus;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 健康状态占比图表
|
|
|
+ * @param type
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public Map<String, Object> countWpOrProStatus(String type) throws Exception {
|
|
|
+
|
|
|
+ Map<String, Object> mapstatus = new HashMap<String, Object>();
|
|
|
+
|
|
|
+
|
|
|
+ List<Integer> hgList = new ArrayList<Integer>();
|
|
|
+ List<Integer> lhList = new ArrayList<Integer>();
|
|
|
+ List<Integer> zyList = new ArrayList<Integer>();
|
|
|
+ List<Integer> yzList = new ArrayList<Integer>();
|
|
|
+ List<String> name = new ArrayList<String>();
|
|
|
+ if ("1".equals(type)) {
|
|
|
+ List<ProBasicPowerstation> wpList = InitialRunner.wpls;
|
|
|
+ for (int i = 0; i < wpList.size(); i++) {
|
|
|
+
|
|
|
+ List<String> idls=new ArrayList<>();
|
|
|
+
|
|
|
+ ProBasicPowerstationPoint point = proBasicPowerstationPointService.getPowerstationPoint(wpList.get(i).getId(), Constant.FJZCSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(wpList.get(i).getId(), Constant.FJLHSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(wpList.get(i).getId(), Constant.FJZYSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(wpList.get(i).getId(), Constant.FJYZSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+
|
|
|
+
|
|
|
+ List<PointData> pols=realApiUtil.getRealData(idls);
|
|
|
+
|
|
|
+ if(!pols.isEmpty() && pols.size()==idls.size())
|
|
|
+ {
|
|
|
+
|
|
|
+ Integer zc = ((Double) pols.get(0).getPointValueInDouble()).intValue();
|
|
|
+
|
|
|
+ Integer lh = ((Double) pols.get(1).getPointValueInDouble()).intValue();
|
|
|
+
|
|
|
+ Integer zy = ((Double) pols.get(2).getPointValueInDouble()).intValue();
|
|
|
+
|
|
|
+ Integer yz = ((Double) pols.get(3).getPointValueInDouble()).intValue();
|
|
|
+
|
|
|
+
|
|
|
+ hgList.add(zc);
|
|
|
+ lhList.add(lh);
|
|
|
+ zyList.add(zy);
|
|
|
+ yzList.add(yz);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ name.add(wpList.get(i).getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ mapstatus.put("hgList", hgList);
|
|
|
+ mapstatus.put("lhList", lhList);
|
|
|
+ mapstatus.put("zyList", zyList);
|
|
|
+ mapstatus.put("yzList", yzList);
|
|
|
+ mapstatus.put("name", name);
|
|
|
+
|
|
|
+ } else if ("2".equals(type)) {
|
|
|
+ List<ProBasicProject> pList = InitialRunner.pjls;
|
|
|
+ for (int i = 0; i < pList.size(); i++) {
|
|
|
+
|
|
|
+ List<String> idls=new ArrayList<>();
|
|
|
+
|
|
|
+ ProBasicPowerstationPoint point = proBasicPowerstationPointService.getPowerstationPoint(pList.get(i).getId(), Constant.FJZCSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(pList.get(i).getId(), Constant.FJLHSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(pList.get(i).getId(), Constant.FJZYSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(pList.get(i).getId(), Constant.FJYZSL);
|
|
|
+ idls.add(point.getNemCode());
|
|
|
+
|
|
|
+ List<PointData> pols=realApiUtil.getRealData(idls);
|
|
|
+
|
|
|
+ if(!pols.isEmpty() && pols.size()==idls.size())
|
|
|
+ {
|
|
|
+ Integer zc = ((Double) pols.get(0).getPointValueInDouble()).intValue();
|
|
|
+ Integer lh = ((Double) pols.get(1).getPointValueInDouble()).intValue();
|
|
|
+ Integer zy = ((Double) pols.get(2).getPointValueInDouble()).intValue();
|
|
|
+ Integer yz = ((Double) pols.get(3).getPointValueInDouble()).intValue();
|
|
|
+
|
|
|
+ hgList.add(zc);
|
|
|
+ lhList.add(lh);
|
|
|
+ zyList.add(zy);
|
|
|
+ yzList.add(yz);
|
|
|
+
|
|
|
+ }
|
|
|
+ name.add(pList.get(i).getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ mapstatus.put("hgList", hgList);
|
|
|
+ mapstatus.put("lhList", lhList);
|
|
|
+ mapstatus.put("zyList", zyList);
|
|
|
+ mapstatus.put("yzList", yzList);
|
|
|
+ mapstatus.put("name", name);
|
|
|
+ }
|
|
|
+
|
|
|
+ return mapstatus;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Map<String, Object> findWpOrProStatusForHistory(String type, String status) throws Exception {
|
|
|
+ Map<String, Object> mapstatus = new HashMap<String, Object>();
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+ List<Integer> lhList = new ArrayList<Integer>();
|
|
|
+ List<Integer> zyList = new ArrayList<Integer>();
|
|
|
+ List<Integer> yzList = new ArrayList<Integer>();
|
|
|
+ Calendar cl = Calendar.getInstance();
|
|
|
+ cl.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ cl.set(Calendar.MINUTE, 0);
|
|
|
+ cl.set(Calendar.SECOND, 0);
|
|
|
+ Long start = cl.getTimeInMillis();
|
|
|
+ Long end = new Date().getTime();
|
|
|
+ List<Map<String,String>> nameList = new ArrayList<Map<String,String>>();
|
|
|
+ if ("1".equals(type)) {
|
|
|
+ List<ProBasicPowerstation> wpList = InitialRunner.wpls;
|
|
|
+ Map<String,String> map=new HashMap<>();
|
|
|
+ for (int i = 0; i < wpList.size(); i++) {
|
|
|
+ List<Integer> hgList = new ArrayList<Integer>();
|
|
|
+ List<String> tList = new ArrayList<String>();
|
|
|
+
|
|
|
+ if ("1".equals(status)) {
|
|
|
+ ProBasicPowerstationPoint point = proBasicPowerstationPointService.getPowerstationPoint(wpList.get(i).getId(), Constant.FJZCSL);
|
|
|
+ String hgCode = point.getNemCode();
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(wpList.get(i).getId(), Constant.FJLHSL);
|
|
|
+ String lhCode = point.getNemCode();
|
|
|
+ List<PointData> phgList = realApiUtil.getHistoryDatasSnap(hgCode, start / 1000, end / 1000, 1L,
|
|
|
+ 15 * 60L);
|
|
|
+ List<PointData> plhList = realApiUtil.getHistoryDatasSnap(lhCode, start / 1000, end / 1000, 1L,
|
|
|
+ 15 * 60L);
|
|
|
+
|
|
|
+ if (!phgList.isEmpty() && !plhList.isEmpty() && phgList.size() >= plhList.size()) {
|
|
|
+ for (int ii = 0; ii < phgList.size(); ii++) {
|
|
|
+ if (plhList.get(ii) == null) {
|
|
|
+ Integer total = ((Double) phgList.get(ii).getPointValueInDouble()).intValue();
|
|
|
+ String time = sdf.format(new Date(phgList.get(ii).getPointTime() * 1000));
|
|
|
+ time = time.substring(time.length() - 5);
|
|
|
+ hgList.add(total);
|
|
|
+ tList.add(time);
|
|
|
+ } else {
|
|
|
+ Integer total = ((Double) phgList.get(ii).getPointValueInDouble()).intValue()
|
|
|
+ + ((Double) plhList.get(ii).getPointValueInDouble()).intValue();
|
|
|
+ String time = sdf.format(new Date(phgList.get(ii).getPointTime() * 1000));
|
|
|
+ time = time.substring(time.length() - 5);
|
|
|
+ hgList.add(total);
|
|
|
+ tList.add(time);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ mapstatus.put(wpList.get(i).getId(), hgList);
|
|
|
+ mapstatus.put("time", tList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ ProBasicPowerstationPoint point = proBasicPowerstationPointService.getPowerstationPoint(wpList.get(i).getId(), Constant.FJZYSL);
|
|
|
+ String zyCode = point.getNemCode();
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(wpList.get(i).getId(), Constant.FJYZSL);
|
|
|
+ String yzCode = point.getNemCode();
|
|
|
+ List<PointData> pzyList = realApiUtil.getHistoryDatasSnap(zyCode, start / 1000, end / 1000, 0L,
|
|
|
+ 15 * 60L);
|
|
|
+ List<PointData> pyzList = realApiUtil.getHistoryDatasSnap(yzCode, start / 1000, end / 1000, 0L,
|
|
|
+ 15 * 60L);
|
|
|
+
|
|
|
+ if (!pzyList.isEmpty() && !pyzList.isEmpty() && pzyList.size() >= pyzList.size()) {
|
|
|
+ for (int ii = 0; ii < pzyList.size(); ii++) {
|
|
|
+ if (pyzList.get(ii) == null) {
|
|
|
+ Integer total = ((Double) pzyList.get(ii).getPointValueInDouble()).intValue();
|
|
|
+ String time = sdf.format(new Date(pzyList.get(ii).getPointTime() * 1000));
|
|
|
+ time = time.substring(time.length() - 5);
|
|
|
+ hgList.add(total);
|
|
|
+ tList.add(time);
|
|
|
+ } else {
|
|
|
+ Integer total = ((Double) pzyList.get(ii).getPointValueInDouble()).intValue()
|
|
|
+ + ((Double) pyzList.get(ii).getPointValueInDouble()).intValue();
|
|
|
+ String time = sdf.format(new Date(pzyList.get(ii).getPointTime() * 1000));
|
|
|
+ time = time.substring(time.length() - 5);
|
|
|
+ hgList.add(total);
|
|
|
+ tList.add(time);
|
|
|
+ }
|
|
|
+
|
|
|
+ mapstatus.put(wpList.get(i).getId(), hgList);
|
|
|
+ mapstatus.put("time", tList);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ map.put(wpList.get(i).getId(),wpList.get(i).getName());
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ nameList.add(map);
|
|
|
+ mapstatus.put("name", nameList);
|
|
|
+
|
|
|
+ } else if ("2".equals(type)) {
|
|
|
+ List<ProBasicProject> pList = InitialRunner.pjls;
|
|
|
+ Map<String,String> map=new HashMap<>();
|
|
|
+ for (int i = 0; i < pList.size(); i++) {
|
|
|
+ List<Integer> hgList = new ArrayList<Integer>();
|
|
|
+ List<String> tList = new ArrayList<String>();
|
|
|
+
|
|
|
+
|
|
|
+ if ("1".equals(status)) {
|
|
|
+ ProBasicPowerstationPoint point = proBasicPowerstationPointService.getPowerstationPoint(pList.get(i).getId(), Constant.FJZCSL);
|
|
|
+ String hgCode = point.getNemCode();
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(pList.get(i).getId(), Constant.FJLHSL);
|
|
|
+ String lhCode = point.getNemCode();
|
|
|
+ List<PointData> phgList = realApiUtil.getHistoryDatasSnap(hgCode, start / 1000, end / 1000, 0L,
|
|
|
+ 15 * 60L);
|
|
|
+ List<PointData> plhList = realApiUtil.getHistoryDatasSnap(lhCode, start / 1000, end / 1000, 0L,
|
|
|
+ 15 * 60L);
|
|
|
+
|
|
|
+ if (!phgList.isEmpty() && !plhList.isEmpty() && phgList.size() >= plhList.size()) {
|
|
|
+ for (int ii = 0; ii < phgList.size(); ii++) {
|
|
|
+ if (plhList.get(ii) == null) {
|
|
|
+ Integer total = ((Double) phgList.get(ii).getPointValueInDouble()).intValue();
|
|
|
+ String time = sdf.format(new Date(phgList.get(ii).getPointTime() * 1000));
|
|
|
+ time = time.substring(time.length() - 5);
|
|
|
+ hgList.add(total);
|
|
|
+ tList.add(time);
|
|
|
+ } else {
|
|
|
+ Integer total = ((Double) phgList.get(ii).getPointValueInDouble()).intValue()
|
|
|
+ + ((Double) plhList.get(ii).getPointValueInDouble()).intValue();
|
|
|
+ String time = sdf.format(new Date(phgList.get(ii).getPointTime() * 1000));
|
|
|
+ time = time.substring(time.length() - 5);
|
|
|
+ hgList.add(total);
|
|
|
+ tList.add(time);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ mapstatus.put(pList.get(i).getNemCode(), hgList);
|
|
|
+ mapstatus.put("time", tList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ ProBasicPowerstationPoint point = proBasicPowerstationPointService.getPowerstationPoint(pList.get(i).getId(), Constant.FJZYSL);
|
|
|
+ String zyCode = point.getNemCode();
|
|
|
+ point = proBasicPowerstationPointService.getPowerstationPoint(pList.get(i).getId(), Constant.FJYZSL);
|
|
|
+ String yzCode = point.getNemCode();
|
|
|
+ List<PointData> pzyList = realApiUtil.getHistoryDatasSnap(zyCode, start / 1000, end / 1000, 0L,
|
|
|
+ 15 * 60L);
|
|
|
+ List<PointData> pyzList = realApiUtil.getHistoryDatasSnap(yzCode, start / 1000, end / 1000, 0L,
|
|
|
+ 15 * 60L);
|
|
|
+
|
|
|
+ if (!pzyList.isEmpty() && !pyzList.isEmpty() && pzyList.size() >= pyzList.size()) {
|
|
|
+ for (int ii = 0; ii < pzyList.size(); ii++) {
|
|
|
+ if (pyzList.get(ii) == null) {
|
|
|
+ Integer total = ((Double) pzyList.get(ii).getPointValueInDouble()).intValue();
|
|
|
+ String time = sdf.format(new Date(pzyList.get(ii).getPointTime() * 1000));
|
|
|
+ time = time.substring(time.length() - 5);
|
|
|
+ hgList.add(total);
|
|
|
+ tList.add(time);
|
|
|
+ } else {
|
|
|
+ Integer total = ((Double) pzyList.get(ii).getPointValueInDouble()).intValue()
|
|
|
+ + ((Double) pyzList.get(ii).getPointValueInDouble()).intValue();
|
|
|
+ String time = sdf.format(new Date(pzyList.get(ii).getPointTime() * 1000));
|
|
|
+ time = time.substring(time.length() - 5);
|
|
|
+ hgList.add(total);
|
|
|
+ tList.add(time);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mapstatus.put(pList.get(i).getNemCode(), hgList);
|
|
|
+ mapstatus.put("time", tList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ map.put(pList.get(i).getId(),pList.get(i).getName());
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ nameList.add(map);
|
|
|
+ mapstatus.put("name", nameList);
|
|
|
+ }
|
|
|
+ return mapstatus;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|