|
@@ -0,0 +1,312 @@
|
|
|
+package com.gyee.backconfig.service.auto;
|
|
|
+
|
|
|
+
|
|
|
+import com.gyee.backconfig.model.auto.*;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 生成测点服务类
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class PointGenerateService {
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(PointGenerateService.class);
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProBasicEnergyGroupService proBasicEnergyGroupService;//集团
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IProBasicRegionService proBasicRegionService;//区域
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProBasicCompanyService proBasicCompanyService;//公司
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProBasicWindpowerstationService proBasicWindpowerstationService;//场站
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProBasicProjectService proBasicProjectService;//期次
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProBasicLineService proBasicLineService;//线路
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IProBasicWindturbineService proBasicWindturbineService;//风机
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IProBasicWppointService proBasicWppointService;//场站测点
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IProBasicEquipmentPointService proBasicEquipmentPointService;//设备测点
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IStandardpointService standardpointService;
|
|
|
+
|
|
|
+ public int addGeneratePoint(String[] points) {
|
|
|
+ int num = 0;
|
|
|
+
|
|
|
+ List<Standardpoint> pointList = standardpointService.list(points);
|
|
|
+ List<ProBasicEnergyGroup> companysList = proBasicEnergyGroupService.getCompanysByidAndRid("");
|
|
|
+
|
|
|
+ for (Standardpoint p : pointList) {
|
|
|
+
|
|
|
+ if ("czjs".equals(p.getType())) {
|
|
|
+
|
|
|
+ List<ProBasicWppoint> staionList = fjd(p, companysList);
|
|
|
+ for (ProBasicWppoint i : staionList) {
|
|
|
+ boolean b = proBasicWppointService.addOrUpdate(i);
|
|
|
+ if (!b) {
|
|
|
+ logger.error(i.getCode() + "测点插入失败");
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //fjjs
|
|
|
+ //fjjcd
|
|
|
+
|
|
|
+ for (ProBasicEnergyGroup c : companysList) {
|
|
|
+ List<ProBasicRegion> regionList = proBasicRegionService.getReginBycode(c.getCapacityUnit());
|
|
|
+ for (ProBasicRegion r : regionList) {
|
|
|
+ List<ProBasicWindpowerstation> windpowerstationList = proBasicWindpowerstationService.getList(r.getId());
|
|
|
+ List<ProBasicEquipmentPoint> testingList = czd(p, windpowerstationList, r);
|
|
|
+ for (ProBasicEquipmentPoint i : testingList) {
|
|
|
+ boolean b = proBasicEquipmentPointService.addOrUpdate(i);
|
|
|
+ if (!b) {
|
|
|
+ logger.error(i.getCode() + "测点插入失败");
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return num;
|
|
|
+ }
|
|
|
+ private List<ProBasicWppoint> fjd(Standardpoint p, List<ProBasicEnergyGroup> companysList) {
|
|
|
+ List<ProBasicWppoint> stationList = new ArrayList<>();
|
|
|
+
|
|
|
+ ProBasicWppoint stationpoint = null;
|
|
|
+
|
|
|
+ List<String> gflist = new ArrayList<>();
|
|
|
+ gflist.add("G");
|
|
|
+ gflist.add("F");
|
|
|
+
|
|
|
+ for (ProBasicEnergyGroup c : companysList) {
|
|
|
+ StringBuilder gssb = null;
|
|
|
+ List<ProBasicWppoint> list1 = proBasicWppointService.getStationpointByUniformcode(c.getId(), p.getUniformcode());
|
|
|
+ if (null == list1 || list1.size() <= 0) {
|
|
|
+ //"JSFW.QY_JN_XXXX_XX_XX_XX_XXX_CI0144" "区域限电停机台数(明细)"
|
|
|
+ gssb = new StringBuilder();
|
|
|
+ gssb.append("JSFW.").append(c.getId()).append("_");
|
|
|
+ stationpoint = new ProBasicWppoint();
|
|
|
+ stationpoint.setCode(gssb.toString() + "XXXX_XX_XX_XX_XXX_" + p.getPoint());
|
|
|
+ stationpoint.setName(c.getName() + p.getName());
|
|
|
+ stationpoint.setUniformCode(p.getUniformcode());
|
|
|
+ stationpoint.setWindpowerstationId(c.getId());
|
|
|
+ stationpoint.setRealtimeId("JSFW");
|
|
|
+ stationList.add(stationpoint);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (String gf : gflist) {
|
|
|
+ List<ProBasicWppoint> list1df = proBasicWppointService.getStationpointByUniformcode(c.getId() + "_" + gf, p.getUniformcode());
|
|
|
+ if (null == list1df || list1df.size() <= 0) {
|
|
|
+ //"JSFW.QY_JN_QYG_XX_XX_XX_XXX_CI0144" "区域光伏限电停机台数(明细)"
|
|
|
+ //"JSFW.QY_JN_QYF_XX_XX_XX_XXX_CI0144" "区域风场限电停机台数(明细)"
|
|
|
+ StringBuilder gsgfsb = new StringBuilder(gssb);
|
|
|
+ gsgfsb.append(c.getId()).append(gf)
|
|
|
+ .append("_XX_XX_XX_XXX_")
|
|
|
+ .append(p.getPoint());
|
|
|
+ stationpoint = new ProBasicWppoint();
|
|
|
+ stationpoint.setCode(gsgfsb.toString());
|
|
|
+ stationpoint.setName(c.getName() + p.getName());
|
|
|
+ stationpoint.setUniformCode(p.getUniformcode());
|
|
|
+ stationpoint.setWindpowerstationId(c.getId() + "_" + gf);
|
|
|
+ stationpoint.setRealtimeId("JSFW");
|
|
|
+ stationList.add(stationpoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProBasicRegion> regionList = proBasicRegionService.getReginBycode(c.getCapacityUnit());
|
|
|
+
|
|
|
+
|
|
|
+ for (ProBasicRegion r : regionList) {
|
|
|
+
|
|
|
+
|
|
|
+ StringBuilder qusb = new StringBuilder();
|
|
|
+ List<ProBasicWppoint> list2 = proBasicWppointService.getStationpointByUniformcode(r.getId(), p.getUniformcode());
|
|
|
+ if (null == list2 || list2.size() <= 0) {
|
|
|
+ //"JSFW.SX_JN_XXXX_XX_XX_XX_XXX_CI0144" "山西限电停机台数(明细)"
|
|
|
+
|
|
|
+ qusb.append("JSFW.").append(c.getId()).append("_");
|
|
|
+ qusb.append(r.getId()).append("_");
|
|
|
+ stationpoint = new ProBasicWppoint();
|
|
|
+ stationpoint.setCode(gssb.toString() + "XX_XX_XX_XXX_" + p.getPoint());
|
|
|
+ stationpoint.setName(c.getName() + p.getName());
|
|
|
+ stationpoint.setUniformCode(p.getUniformcode());
|
|
|
+ stationpoint.setWindpowerstationId(r.getId());
|
|
|
+ stationpoint.setRealtimeId("JSFW");
|
|
|
+ stationList.add(stationpoint);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String gf : gflist) {
|
|
|
+ List<ProBasicWppoint> list2df = proBasicWppointService.getStationpointByUniformcode(r.getId() + "_" + gf, p.getUniformcode());
|
|
|
+ if (null == list2df || list2df.size() <= 0) {
|
|
|
+ //"JSFW.SX_JN_SXG_XX_XX_XX_XXX_CI0144" "山西光伏限电停机台数(明细)"
|
|
|
+ //"JSFW.SX_JN_SXF_XX_XX_XX_XXX_CI0144" "山西风场限电停机台数(明细)"
|
|
|
+ StringBuilder qugfsb = new StringBuilder(qusb);
|
|
|
+ qugfsb.append(gf)
|
|
|
+ .append("_XX_XX_XX_XXX_")
|
|
|
+ .append(p.getPoint());
|
|
|
+ stationpoint = new ProBasicWppoint();
|
|
|
+ stationpoint.setCode(qugfsb.toString());
|
|
|
+ stationpoint.setName(c.getName() + p.getName());
|
|
|
+ stationpoint.setUniformCode(p.getUniformcode());
|
|
|
+ stationpoint.setWindpowerstationId(r.getId() + "_" + gf);
|
|
|
+ stationpoint.setRealtimeId("JSFW");
|
|
|
+ stationList.add(stationpoint);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<ProBasicWindpowerstation> windpowerstationList = proBasicWindpowerstationService.getList(r.getId());
|
|
|
+ for (ProBasicWindpowerstation station : windpowerstationList) {
|
|
|
+ List<ProBasicWppoint> list3 = proBasicWppointService.getStationpointByUniformcode(station.getId(), p.getUniformcode());
|
|
|
+ if (null != list3 && list3.size() > 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ stationpoint = new ProBasicWppoint();
|
|
|
+ //BHBFCJSFW.SX_JN_BHBF_JS_XX_XX_XXX_CI0079
|
|
|
+ //SYGCJSFW.SX_JN_SYG_JS_XX_XX_XXX_CI0001
|
|
|
+ //HSMFCJSFW.SX_JN_HSMF_JS_XX_XX_XXX_AI0002
|
|
|
+
|
|
|
+ //场站测点
|
|
|
+ StringBuilder stationsb = new StringBuilder();
|
|
|
+ String substaion = station.getId().substring(0, station.getId().indexOf("_"));
|
|
|
+ stationsb.append(substaion).append(station.getId().endsWith("_FDC") ? "FCJSFW." : "GCJSFW.");
|
|
|
+ stationsb.append(c.getId()).append("_").append(r.getId()).append("_").append(substaion);
|
|
|
+ stationsb.append(station.getId().endsWith("_FDC") ? "F" : "G").append("_");
|
|
|
+
|
|
|
+ stationpoint.setCode(stationsb.toString() + "XX_XX_XXX_" + p.getPoint());
|
|
|
+ stationpoint.setName(station.getName() + p.getName());
|
|
|
+ stationpoint.setUniformCode(p.getUniformcode());
|
|
|
+ stationpoint.setWindpowerstationId(station.getId());
|
|
|
+ stationpoint.setRealtimeId(substaion + (station.getId().endsWith("_FDC") ? "FCJSFW" : "GCJSFW"));
|
|
|
+ stationList.add(stationpoint);
|
|
|
+
|
|
|
+ List<ProBasicProject> projectList = proBasicProjectService.getList(station.getId());
|
|
|
+ for (ProBasicProject project : projectList) {
|
|
|
+ List<ProBasicWppoint> list4 = proBasicWppointService.getStationpointByUniformcode(project.getId(), p.getUniformcode());
|
|
|
+ if (null != list4 && list4.size() > 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //期次测点
|
|
|
+ stationpoint = new ProBasicWppoint();
|
|
|
+ StringBuilder projectsb = new StringBuilder(stationsb);
|
|
|
+ Integer pnum = Integer.valueOf(project.getId().substring(substaion.length(), project.getId().indexOf("_"))) * 1;
|
|
|
+ projectsb.append("P")
|
|
|
+ .append(pnum);
|
|
|
+
|
|
|
+ stationpoint.setCode(projectsb.toString() + "_XX_XXX_" + p.getPoint());
|
|
|
+ stationpoint.setName(project.getName() + p.getName());
|
|
|
+ stationpoint.setUniformCode(p.getUniformcode());
|
|
|
+ stationpoint.setWindpowerstationId(project.getId());
|
|
|
+ stationpoint.setRealtimeId(substaion + (station.getId().endsWith("_FDC") ? "FCJSFW" : "GCJSFW"));
|
|
|
+ stationList.add(stationpoint);
|
|
|
+
|
|
|
+ List<ProBasicLine> lineList = proBasicLineService.getList(project.getId());
|
|
|
+ for (ProBasicLine l : lineList) {
|
|
|
+
|
|
|
+ List<ProBasicWppoint> list5 = proBasicWppointService.getStationpointByUniformcode(l.getId(), p.getUniformcode());
|
|
|
+ if (null != list5 && list5.size() > 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ stationpoint = new ProBasicWppoint();
|
|
|
+ //线路测点
|
|
|
+ StringBuilder linesb = new StringBuilder(projectsb);
|
|
|
+
|
|
|
+ Integer lnum = Integer.valueOf(l.getId().substring(substaion.length(), project.getId().indexOf("_"))) * 1;
|
|
|
+ linesb.append("_L").append(lnum)
|
|
|
+ .append("_XXX_").append(p.getPoint());
|
|
|
+
|
|
|
+ stationpoint.setCode(linesb.toString());
|
|
|
+ stationpoint.setName(l.getName() + p.getName());
|
|
|
+ stationpoint.setUniformCode(p.getUniformcode());
|
|
|
+ stationpoint.setWindpowerstationId(l.getId());
|
|
|
+ stationpoint.setRealtimeId(substaion + (station.getId().endsWith("_FDC") ? "FCJSFW" : "GCJSFW"));
|
|
|
+ stationList.add(stationpoint);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return stationList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param p
|
|
|
+ * @param windpowerstationList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<ProBasicEquipmentPoint> czd(Standardpoint p, List<ProBasicWindpowerstation> windpowerstationList,ProBasicRegion region) {
|
|
|
+ ProBasicEquipmentPoint testing = null;
|
|
|
+ List<ProBasicEquipmentPoint> testingList = new ArrayList<>();
|
|
|
+ for (ProBasicWindpowerstation station : windpowerstationList) {
|
|
|
+
|
|
|
+
|
|
|
+ List<ProBasicWindturbine> windturbineList = proBasicWindturbineService.getWindturbineGyLine(station.getId(), "", "");
|
|
|
+ for (ProBasicWindturbine w : windturbineList) {
|
|
|
+ List<ProBasicEquipmentPoint> list = proBasicEquipmentPointService.list(w.getId(), p.getUniformcode());
|
|
|
+ if (null != list && list.size() > 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ testing = new ProBasicEquipmentPoint();
|
|
|
+ //fjjs
|
|
|
+ //fjjcd
|
|
|
+ String substaion = station.getId().substring(0, station.getId().indexOf("_"));
|
|
|
+ if ("fjjs".equals(p.getType())) {
|
|
|
+ StringBuilder stationsb = new StringBuilder();
|
|
|
+ stationsb.append(substaion).append(station.getId().endsWith("_FDC") ? "FJJSFW." : "GFJSFW.");
|
|
|
+ stationsb.append(region.getGroupId()).append("_").append(region.getId()).append("_").append(substaion);
|
|
|
+ stationsb.append(station.getId().endsWith("_FDC") ? "F" : "G").append("_JS_");
|
|
|
+ Integer pnum = Integer.valueOf(w.getProjectId().substring(substaion.length(), w.getProjectId().indexOf("_"))) * 1;
|
|
|
+ stationsb.append("P").append(pnum);
|
|
|
+ Integer lnum = Integer.valueOf(w.getLineId().substring(substaion.length(), w.getLineId().indexOf("_"))) * 1;
|
|
|
+ stationsb.append("_L").append(lnum);
|
|
|
+ String wnum = w.getId().substring(w.getId().indexOf("_") + 1, w.getId().length());
|
|
|
+ stationsb.append("_").append(wnum).append("_");
|
|
|
+
|
|
|
+ //BHB3FJJSFW.SX_JN_BHB3F_JS_P1_L30_001_CI0060
|
|
|
+ //SYGFJSFW.SX_JN_SYG_JS_P2_L3_NBQ0061_CI0174
|
|
|
+ testing.setCode(stationsb.toString() + p.getPoint());
|
|
|
+ testing.setRealtimeId(substaion + (station.getId().endsWith("_FDC") ? "FJJSFW" : "GFJSFW"));
|
|
|
+ } else if ("fjjcd".equals(p.getType())) {
|
|
|
+ testing.setCode("INITIAL");
|
|
|
+ testing.setRealtimeId(substaion + (station.getId().endsWith("_FDC") ? "FJ" : "GF"));
|
|
|
+ }
|
|
|
+
|
|
|
+ testing.setName(w.getName() + p.getName());
|
|
|
+ testing.setUniformCode(p.getUniformcode());
|
|
|
+ testing.setWindpowerstationId(w.getId());
|
|
|
+ testingList.add(testing);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return testingList;
|
|
|
+
|
|
|
+ }
|
|
|
+}
|