From 6f859a234fd0c01b64f467aef6f03e9e394665b2 Mon Sep 17 00:00:00 2001
From: wr <1754607820@qq.com>
Date: Thu, 8 Jun 2023 16:06:18 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=A8=A1=E6=8B=9F=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 20 ++
.../controller/DataImportController.java | 64 +++++++
.../mapper/PowerDistributionareaMapper.java | 19 ++
.../pojo/po/AdsAstXbjcptGetFctgDi.java | 76 ++++++++
.../syncdata/pojo/po/PWFeederLinePSR.java | 50 +++++
.../syncdata/pojo/po/PWOPTransformerPSR.java | 38 ++++
.../pojo/po/PowerDistributionarea.java | 156 +++++++++++++++
.../com/njcn/syncdata/pojo/po/Substation.java | 27 +++
.../IPowerDistributionareaService.java | 39 ++++
.../PowerDistributionareaServiceImpl.java | 177 ++++++++++++++++++
10 files changed, 666 insertions(+)
create mode 100644 src/main/java/com/njcn/syncdata/controller/DataImportController.java
create mode 100644 src/main/java/com/njcn/syncdata/mapper/PowerDistributionareaMapper.java
create mode 100644 src/main/java/com/njcn/syncdata/pojo/po/AdsAstXbjcptGetFctgDi.java
create mode 100644 src/main/java/com/njcn/syncdata/pojo/po/PWFeederLinePSR.java
create mode 100644 src/main/java/com/njcn/syncdata/pojo/po/PWOPTransformerPSR.java
create mode 100644 src/main/java/com/njcn/syncdata/pojo/po/PowerDistributionarea.java
create mode 100644 src/main/java/com/njcn/syncdata/pojo/po/Substation.java
create mode 100644 src/main/java/com/njcn/syncdata/service/IPowerDistributionareaService.java
create mode 100644 src/main/java/com/njcn/syncdata/service/impl/PowerDistributionareaServiceImpl.java
diff --git a/pom.xml b/pom.xml
index dc5d1ed..18e4654 100644
--- a/pom.xml
+++ b/pom.xml
@@ -111,6 +111,25 @@
${commons-codec.version}
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.13
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.75
+
+
+
+ com.huawei.apigateway
+ java-sdk-core
+ 3.0.10
+
+
com.njcn
common-db
@@ -127,6 +146,7 @@
+
diff --git a/src/main/java/com/njcn/syncdata/controller/DataImportController.java b/src/main/java/com/njcn/syncdata/controller/DataImportController.java
new file mode 100644
index 0000000..50914d7
--- /dev/null
+++ b/src/main/java/com/njcn/syncdata/controller/DataImportController.java
@@ -0,0 +1,64 @@
+package com.njcn.syncdata.controller;
+
+import com.njcn.syncdata.service.IPowerDistributionareaService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/dataImport")
+@RequiredArgsConstructor
+public class DataImportController {
+
+ private final IPowerDistributionareaService service;
+
+ /**
+ * 登录获取token
+ * @return
+ */
+ @GetMapping("/token")
+ public String token(){
+ return service.LoginToken();
+ }
+
+ /**
+ * 获取数据中台数据
+ * @return
+ */
+ @GetMapping("/getAdsList")
+ public String adsList(){
+ return service.adsList();
+ }
+
+ /**
+ * 获取数据中台返回体
+ * @param token
+ * @param psrType
+ * @param fieldName
+ * @param fieldValue
+ * @return
+ */
+ @GetMapping("/getResource")
+ public Map getResource(String token,String psrType, String fieldName,String fieldValue){
+ return service.staticMethod(token,psrType,fieldName,fieldValue);
+ }
+
+ /**
+ * 获取数据中台返回数据
+ * @param token
+ * @param psrType
+ * @param fieldName
+ * @param fieldValue
+ * @return
+ */
+ @GetMapping("/getResourceData")
+ public List getResourceData(String token,String psrType, String fieldName,String fieldValue){
+ Map map = service.staticMethod(token, psrType, fieldName, fieldValue);
+ List data = (List) map.get("data");
+ return data;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/njcn/syncdata/mapper/PowerDistributionareaMapper.java b/src/main/java/com/njcn/syncdata/mapper/PowerDistributionareaMapper.java
new file mode 100644
index 0000000..e748bbd
--- /dev/null
+++ b/src/main/java/com/njcn/syncdata/mapper/PowerDistributionareaMapper.java
@@ -0,0 +1,19 @@
+package com.njcn.syncdata.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.njcn.syncdata.pojo.po.PowerDistributionarea;
+
+
+/**
+ *
+ * Mapper 台区
+ *
+ *
+ * @author hongawen
+ * @since 2022-10-14
+ */
+public interface PowerDistributionareaMapper extends BaseMapper {
+
+
+}
diff --git a/src/main/java/com/njcn/syncdata/pojo/po/AdsAstXbjcptGetFctgDi.java b/src/main/java/com/njcn/syncdata/pojo/po/AdsAstXbjcptGetFctgDi.java
new file mode 100644
index 0000000..bf5299c
--- /dev/null
+++ b/src/main/java/com/njcn/syncdata/pojo/po/AdsAstXbjcptGetFctgDi.java
@@ -0,0 +1,76 @@
+package com.njcn.syncdata.pojo.po;
+
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wr
+ * @description
+ * @date 2023/6/7 8:57
+ */
+@Data
+public class AdsAstXbjcptGetFctgDi {
+
+ /**
+ * 台区标识
+ */
+ private String tg_id;
+ /**
+ * PMS侧变压器ID
+ */
+ private String trans_pms_id;
+ /**
+ * 计量点号
+ */
+ private Integer id;
+ /**
+ * 台区名称
+ */
+ private String tg_name;
+ /**
+ * 台区编号
+ */
+ private String tg_no;
+ /**
+ * 台区区域划分类别,01、市中心区,02、市区,03、 城镇,04、农村
+ */
+ private String area_type;
+ /**
+ * 公变专变标志台区是0.公变或者1.专变
+ */
+ private String pub_priv_flag;
+ /**
+ * 台区管理单位编号
+ */
+ private String org_no;
+ /**
+ * 供电单位名称
+ */
+ private String org_name;
+ /**
+ * 供电单位类别:单位类别:国网公司、省公司、地市公司、区县公司、分公司、供电所等。01 国网公司、02 省公司、03 地市公司 、04 区县公司、05 分公司、06 供电所
+ */
+ private String org_type;
+ /**
+ * 上级供电单位编号
+ */
+ private String p_org_no;
+ /**
+ * 运行状态台区运行状态
+ */
+ private String run_status_code;
+ /**
+ * 容量台区容量,为可并列运行的变压器容量之和
+ */
+ private BigDecimal tg_cap;
+ /**
+ * 分布式光伏用户数
+ */
+ private Integer fc_num;
+ /**
+ * 分布式光伏用户总容量(MW)
+ */
+ private BigDecimal fc_sum_cap;
+}
diff --git a/src/main/java/com/njcn/syncdata/pojo/po/PWFeederLinePSR.java b/src/main/java/com/njcn/syncdata/pojo/po/PWFeederLinePSR.java
new file mode 100644
index 0000000..7de5b39
--- /dev/null
+++ b/src/main/java/com/njcn/syncdata/pojo/po/PWFeederLinePSR.java
@@ -0,0 +1,50 @@
+package com.njcn.syncdata.pojo.po;
+
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wr
+ * @description
+ * @date 2023/6/7 11:18
+ */
+@Data
+public class PWFeederLinePSR {
+ /**
+ * 设备id
+ */
+ private String ID;
+
+ /**
+ * 起点电站id
+ */
+ private String start_station_id;
+
+ /**
+ * 设备名称
+ */
+ private String Name;
+
+ /**
+ * 组织机构
+ */
+ private String DEPART;
+
+ /**
+ * 维护班组
+ */
+ private String MAINTENANCE_TEAM;
+
+ /**
+ * 供电半径
+ */
+ private BigDecimal SUPPLY_RADIUS;
+
+ /**
+ * 供电线路总长度
+ */
+ private BigDecimal LENGTH;
+
+}
diff --git a/src/main/java/com/njcn/syncdata/pojo/po/PWOPTransformerPSR.java b/src/main/java/com/njcn/syncdata/pojo/po/PWOPTransformerPSR.java
new file mode 100644
index 0000000..b9fd754
--- /dev/null
+++ b/src/main/java/com/njcn/syncdata/pojo/po/PWOPTransformerPSR.java
@@ -0,0 +1,38 @@
+package com.njcn.syncdata.pojo.po;
+
+import lombok.Data;
+
+/**
+ * @author wr
+ * @description
+ * @date 2023/6/7 10:25
+ */
+@Data
+public class PWOPTransformerPSR {
+
+ /**
+ * 外部系统id
+ */
+ private String ACCOUNT_ID;
+
+ /**
+ * 根设备id
+ */
+ private String ROOT_ID;
+
+ /**
+ * 是否是农网
+ */
+ private Integer IS_RURAL_GRID;
+
+ /**
+ * 使用性质
+ */
+ private String use_nature;
+
+ /**
+ * 运行状态
+ */
+ private String RUN_STATUS;
+
+}
diff --git a/src/main/java/com/njcn/syncdata/pojo/po/PowerDistributionarea.java b/src/main/java/com/njcn/syncdata/pojo/po/PowerDistributionarea.java
new file mode 100644
index 0000000..6e93a9c
--- /dev/null
+++ b/src/main/java/com/njcn/syncdata/pojo/po/PowerDistributionarea.java
@@ -0,0 +1,156 @@
+package com.njcn.syncdata.pojo.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.njcn.db.bo.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ *
+ *
+ *
+ *
+ * @author hongawen
+ * @since 2022-10-14
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("pms_power_distributionarea")
+public class PowerDistributionarea extends BaseEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 台区编号
+ */
+ private String id;
+
+ /**
+ * 台区名称
+ */
+ private String name;
+
+ /**
+ * 组织机构名称
+ */
+ private String orgName;
+
+ /**
+ * 组织机构ID(外键)
+ */
+ private String orgId;
+
+ /**
+ * 运维单位名称
+ */
+ private String operationName;
+
+ /**
+ * 运维单位ID(外键)
+ */
+ private String operationId;
+
+ /**
+ * 变电站名称
+ */
+ private String powerrName;
+
+ /**
+ * 电站ID(外键)
+ */
+ private String powerStationId;
+
+ /**
+ * 监测线路名称
+ */
+ private String lineName;
+
+ /**
+ * 所属线路ID(外键)
+ */
+ private String lineId;
+
+ /**
+ * 电压等级
+ */
+ private String voltageLevel;
+
+
+ /**
+ * 配变容量
+ */
+ private Float pCapacity;
+
+ /**
+ * 地区特征(字典)
+ */
+ private String regionalism;
+
+ /**
+ * 是否农网:0-否;1:是;
+ */
+ private Integer ifRuralPowerGrid;
+
+ /**
+ * 使用性质
+ */
+ private String natureOfUse;
+
+ /**
+ * 供电半径
+ */
+ private Float powerSupplyRadius;
+
+ /**
+ * 供电线路总长度
+ */
+ private Float lineLength;
+
+ /**
+ * 运行状态(字典)
+ */
+ private String state;
+
+ /**
+ * 分布式光伏用户数
+ */
+ private Integer distributedPhotovoltaicNum;
+
+ /**
+ * 分布式光伏总装机容量
+ */
+ private Float photovoltaicCapacity;
+
+ /**
+ * 是否有电动汽车接入:0-否;1:是;
+ */
+ private Integer ifBevAp;
+
+ /**
+ * 接入负荷类型(字典)
+ */
+ private String apLoadType;
+
+ /**
+ * 是否是上送国网监测点,0-否 1-是
+ */
+ private Integer isUpToGrid;
+
+ /**
+ * 经度
+ */
+ private Double longitude;
+
+ /**
+ * 维度
+ */
+ private Double latitude;
+
+ /**
+ * 数据状态:0-删除;1-正常;
+ */
+ private Integer status;
+
+
+
+}
diff --git a/src/main/java/com/njcn/syncdata/pojo/po/Substation.java b/src/main/java/com/njcn/syncdata/pojo/po/Substation.java
new file mode 100644
index 0000000..7779c97
--- /dev/null
+++ b/src/main/java/com/njcn/syncdata/pojo/po/Substation.java
@@ -0,0 +1,27 @@
+package com.njcn.syncdata.pojo.po;
+
+import lombok.Data;
+
+/**
+ * @author wr
+ * @description
+ * @date 2023/6/7 11:15
+ */
+@Data
+public class Substation {
+
+ /**
+ * 设备id
+ */
+ private String ID;
+
+ /**
+ * 设备名称
+ */
+ private String NAME;
+
+ /**
+ * 电压等级
+ */
+ private String VOLTAGELEVEL_ID;
+}
diff --git a/src/main/java/com/njcn/syncdata/service/IPowerDistributionareaService.java b/src/main/java/com/njcn/syncdata/service/IPowerDistributionareaService.java
new file mode 100644
index 0000000..0f11d98
--- /dev/null
+++ b/src/main/java/com/njcn/syncdata/service/IPowerDistributionareaService.java
@@ -0,0 +1,39 @@
+package com.njcn.syncdata.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.njcn.syncdata.pojo.po.PowerDistributionarea;
+
+import java.util.Map;
+
+/**
+ *
+ * 服务类
+ *
+ *
+ * @author hongawen
+ * @since 2022-10-14
+ */
+public interface IPowerDistributionareaService extends IService {
+
+ /**
+ * 登录获取token
+ * @return
+ */
+ String LoginToken();
+
+ /**
+ * 获取数据中台数据
+ * @return
+ */
+ String adsList();
+
+ /**
+ * 通用资源数据中台数据查询
+ * @param token 数据token
+ * @param psrType 对应需要查询的表
+ * @param fieldName 数据的列名
+ * @param fieldValue 数据id集合
+ * @return
+ */
+ Map staticMethod(String token,String psrType, String fieldName,String fieldValue);
+}
diff --git a/src/main/java/com/njcn/syncdata/service/impl/PowerDistributionareaServiceImpl.java b/src/main/java/com/njcn/syncdata/service/impl/PowerDistributionareaServiceImpl.java
new file mode 100644
index 0000000..1bf0c72
--- /dev/null
+++ b/src/main/java/com/njcn/syncdata/service/impl/PowerDistributionareaServiceImpl.java
@@ -0,0 +1,177 @@
+package com.njcn.syncdata.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cloud.apigateway.sdk.utils.Client;
+import com.cloud.apigateway.sdk.utils.Request;
+import com.njcn.syncdata.mapper.PowerDistributionareaMapper;
+import com.njcn.syncdata.pojo.po.AdsAstXbjcptGetFctgDi;
+import com.njcn.syncdata.pojo.po.PowerDistributionarea;
+import com.njcn.syncdata.service.IPowerDistributionareaService;
+import com.njcn.syncdata.utils.RestTemplateUtil;
+import lombok.RequiredArgsConstructor;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * 台区信息
+ *
+ *
+ * @author hongawen
+ * @since 2022-10-14
+ */
+@Service
+@RequiredArgsConstructor
+public class PowerDistributionareaServiceImpl extends ServiceImpl implements IPowerDistributionareaService {
+
+ private static Logger logger = LoggerFactory.getLogger(PowerDistributionareaServiceImpl.class);
+
+ @Override
+ public String LoginToken() {
+ String token = null;
+ String userName = "04ba64fc640040efba9c9e76d434fbe3f06e91f17fc1a863fd47ce1efba69e1f44d5948560499999e21bc21b3ec2cdf565534e74e227fb79545c88637c5d16ad893090e941b97aa64b5db28153903c4f11412b3466950bdd8c623b1250be802939e5450b5282f5ae7032e22c";
+ String password = "048d108b7d88345094ca5278e7361e4bfb6d6d2864a855a1c36afe33f50c4eb609dd08b6a73a89f976a6fc6d428d635b10183a8844db94d1f1697b83ba5beac26130e343a81b1b4ba12ee4212310e8833de39d7032409dff3848c10e654efb2ce4136a0c0bdd02097b48e792e66a7723154afa4977";
+ String clientId = "3DEB086AF4E9638EC2F6909A2EBAE559";
+ String clientSecret = "7E974718AB96E7EDC09F9E184F7F25BC";
+
+ String userUrl = "http://dwzyywzt.com/baseCenter/oauth2/accessToken";
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(userUrl)
+ .queryParam("grant_type", "password")
+ .queryParam("username", userName)
+ .queryParam("password", password)
+ .queryParam("client_id", clientId)
+ .queryParam("client_secret", clientSecret);
+ URI uri = builder.build().encode().toUri();
+ ResponseEntity