1.业务中台变电站代码提交
This commit is contained in:
@@ -8,6 +8,7 @@ import com.alibaba.excel.EasyExcel;
|
||||
import com.njcn.jbsyncdata.pojo.*;
|
||||
import com.njcn.jbsyncdata.service.DisPhotovoltaicService;
|
||||
import com.njcn.jbsyncdata.service.IBusinessService;
|
||||
import com.njcn.jbsyncdata.service.IPmsSubstationService;
|
||||
import com.njcn.jbsyncdata.util.RestTemplateUtil;
|
||||
import com.njcn.jbsyncdata.util.StreamUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -17,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -40,6 +42,7 @@ public class DisPhotovoltaicController {
|
||||
|
||||
private final IBusinessService businessService;
|
||||
private final DisPhotovoltaicService disPhotovoltaicService;
|
||||
private final IPmsSubstationService substationService;
|
||||
|
||||
/**
|
||||
* @param date yyyy-MM-dd
|
||||
@@ -246,6 +249,17 @@ public class DisPhotovoltaicController {
|
||||
}
|
||||
return "数据导入失败";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "业务中台")
|
||||
@GetMapping("/addYwZtSubstation")
|
||||
public String addYwZtSubstation(String distribution, String psrType) {
|
||||
Boolean aBoolean = substationService.addYwZtSubstation(distribution,psrType);
|
||||
if (aBoolean) {
|
||||
return "数据导入成功";
|
||||
}
|
||||
return "数据导入失败";
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 30 0 * * ?")
|
||||
public void insert() {
|
||||
log.error(Thread.currentThread().getName(),"1.定时器启动----!");
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.jbsyncdata.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.jbsyncdata.pojo.PmsSubstation;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2024-08-07
|
||||
*/
|
||||
public interface PmsSubstationMapper extends BaseMapper<PmsSubstation> {
|
||||
|
||||
}
|
||||
113
src/main/java/com/njcn/jbsyncdata/pojo/PmsSubstation.java
Normal file
113
src/main/java/com/njcn/jbsyncdata/pojo/PmsSubstation.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package com.njcn.jbsyncdata.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2024-08-07
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("pq_ywzt_substation")
|
||||
public class PmsSubstation {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 变电站序号
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 所属地市
|
||||
*/
|
||||
private String orgId;
|
||||
|
||||
/**
|
||||
* 数据类型zf01:变电站 zf05:电厂
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 运维单位
|
||||
*/
|
||||
private String operationName;
|
||||
|
||||
/**
|
||||
* 电站名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 电压等级Id,字典表
|
||||
*/
|
||||
private String scale;
|
||||
|
||||
/**
|
||||
* 电压等级名称
|
||||
*/
|
||||
private String scaleName;
|
||||
|
||||
/**
|
||||
* 维护班组
|
||||
*/
|
||||
private String maintenanceName;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
*/
|
||||
private String runStatus;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
private String deviceCoding;
|
||||
|
||||
/**
|
||||
* 投运日期
|
||||
*/
|
||||
private LocalDateTime runTime;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private BigDecimal lng;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private BigDecimal lat;
|
||||
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
235
src/main/java/com/njcn/jbsyncdata/pojo/YWZTSubstation.java
Normal file
235
src/main/java/com/njcn/jbsyncdata/pojo/YWZTSubstation.java
Normal file
@@ -0,0 +1,235 @@
|
||||
package com.njcn.jbsyncdata.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2024/8/28 14:55
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class YWZTSubstation {
|
||||
|
||||
@JsonProperty("errors")
|
||||
private String errors;
|
||||
@JsonProperty("message")
|
||||
private String message;
|
||||
@JsonProperty("result")
|
||||
private ResultDTO result;
|
||||
@JsonProperty("status")
|
||||
private String status;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class ResultDTO {
|
||||
@JsonProperty("zf01")
|
||||
private Zf01DTO zf01;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class Zf01DTO {
|
||||
@JsonProperty("current")
|
||||
private Integer current;
|
||||
@JsonProperty("pages")
|
||||
private Integer pages;
|
||||
@JsonProperty("records")
|
||||
private List<RecordsDTO> records;
|
||||
@JsonProperty("size")
|
||||
private Integer size;
|
||||
@JsonProperty("total")
|
||||
private Integer total;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class RecordsDTO {
|
||||
@JsonProperty("assets")
|
||||
private List<AssetsDTO> assets;
|
||||
@JsonProperty("distribution")
|
||||
private Integer distribution;
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
@JsonProperty("modelId")
|
||||
private String modelId;
|
||||
@JsonProperty("resource")
|
||||
private ResourceDTO resource;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class ResourceDTO {
|
||||
@JsonProperty("maintOrg")
|
||||
private String maintOrg;
|
||||
@JsonProperty("stationType")
|
||||
private String stationType;
|
||||
@JsonProperty("voltageLevelName")
|
||||
private String voltageLevelName;// FIXME check this code
|
||||
@JsonProperty("contaminationLevelName")
|
||||
private String contaminationLevelName;// FIXME check this code
|
||||
@JsonProperty("dispatchMonitor")
|
||||
private String dispatchMonitor;
|
||||
@JsonProperty("fireAcceptance")
|
||||
private String fireAcceptance;
|
||||
@JsonProperty("type")
|
||||
private String type;
|
||||
@JsonProperty("pubPrivFlagName")
|
||||
private String pubPrivFlagName;// FIXME check this code
|
||||
@JsonProperty("arrangement")
|
||||
private String arrangement;
|
||||
@JsonProperty("regionalismName")
|
||||
private String regionalismName;// FIXME check this code
|
||||
@JsonProperty("coverArea")
|
||||
private Double coverArea;
|
||||
@JsonProperty("isTelecontrol")
|
||||
private String isTelecontrol;
|
||||
@JsonProperty("isRural")
|
||||
private String isRural;
|
||||
@JsonProperty("isRuralName")
|
||||
private String isRuralName;// FIXME check this code
|
||||
@JsonProperty("ctime")
|
||||
private String ctime;
|
||||
@JsonProperty("geoPositon")
|
||||
private String geoPositon;
|
||||
@JsonProperty("isSmartStationName")
|
||||
private String isSmartStationName;// FIXME check this code
|
||||
@JsonProperty("dutyModeName")
|
||||
private String dutyModeName;// FIXME check this code
|
||||
@JsonProperty("stationCapacity")
|
||||
private Double stationCapacity;
|
||||
@JsonProperty("isAvcName")
|
||||
private String isAvcName;// FIXME check this code
|
||||
@JsonProperty("equipmentOwner")
|
||||
private String equipmentOwner;
|
||||
@JsonProperty("arrangementName")
|
||||
private String arrangementName;// FIXME check this code
|
||||
@JsonProperty("importantLevelName")
|
||||
private String importantLevelName;// FIXME check this code
|
||||
@JsonProperty("psrId")
|
||||
private String psrId;
|
||||
@JsonProperty("telephone")
|
||||
private String telephone;
|
||||
@JsonProperty("dispatchJurisdiction")
|
||||
private String dispatchJurisdiction;
|
||||
@JsonProperty("isFirtsName")
|
||||
private String isFirtsName;// FIXME check this code
|
||||
@JsonProperty("isN1Name")
|
||||
private String isN1Name;// FIXME check this code
|
||||
@JsonProperty("astId")
|
||||
private String astId;
|
||||
@JsonProperty("isSmartStation")
|
||||
private String isSmartStation;
|
||||
@JsonProperty("isLoadStation")
|
||||
private String isLoadStation;
|
||||
@JsonProperty("maintOrgName")
|
||||
private String maintOrgName;// FIXME check this code
|
||||
@JsonProperty("dispatchName")
|
||||
private String dispatchName;
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
@JsonProperty("isAvc")
|
||||
private String isAvc;
|
||||
@JsonProperty("isLoadStationName")
|
||||
private String isLoadStationName;// FIXME check this code
|
||||
@JsonProperty("isGis")
|
||||
private String isGis;
|
||||
@JsonProperty("hisCrestStage")
|
||||
private Double hisCrestStage;
|
||||
@JsonProperty("isMultiStationIntegration")
|
||||
private String isMultiStationIntegration;
|
||||
@JsonProperty("lastUpdateTime")
|
||||
private String lastUpdateTime;
|
||||
@JsonProperty("dispatchPermission")
|
||||
private String dispatchPermission;
|
||||
@JsonProperty("psrState")
|
||||
private String psrState;
|
||||
@JsonProperty("regionalism")
|
||||
private String regionalism;
|
||||
@JsonProperty("city")
|
||||
private String city;
|
||||
@JsonProperty("importance")
|
||||
private String importance;
|
||||
@JsonProperty("isRemoteIntellpatrol")
|
||||
private String isRemoteIntellpatrol;
|
||||
@JsonProperty("isCentralMonitor")
|
||||
private String isCentralMonitor;
|
||||
@JsonProperty("dispatchOperation")
|
||||
private String dispatchOperation;
|
||||
@JsonProperty("highestDispatchJurisdiction")
|
||||
private String highestDispatchJurisdiction;
|
||||
@JsonProperty("importanceName")
|
||||
private String importanceName;// FIXME check this code
|
||||
@JsonProperty("runDevName")
|
||||
private String runDevName;
|
||||
@JsonProperty("fireTypeName")
|
||||
private String fireTypeName;// FIXME check this code
|
||||
@JsonProperty("psrStateName")
|
||||
private String psrStateName;// FIXME check this code
|
||||
@JsonProperty("startTime")
|
||||
private String startTime;
|
||||
@JsonProperty("pubPrivFlag")
|
||||
private String pubPrivFlag;
|
||||
@JsonProperty("isCentralMonitorName")
|
||||
private String isCentralMonitorName;// FIXME check this code
|
||||
@JsonProperty("transformerQuantity")
|
||||
private Integer transformerQuantity;
|
||||
@JsonProperty("hisLargestRainfall")
|
||||
private Double hisLargestRainfall;
|
||||
@JsonProperty("fireAcceptanceName")
|
||||
private String fireAcceptanceName;// FIXME check this code
|
||||
@JsonProperty("address")
|
||||
private String address;
|
||||
@JsonProperty("maintGroupName")
|
||||
private String maintGroupName;// FIXME check this code
|
||||
@JsonProperty("maintGroup")
|
||||
private String maintGroup;
|
||||
@JsonProperty("importantLevel")
|
||||
private String importantLevel;
|
||||
@JsonProperty("isGisName")
|
||||
private String isGisName;// FIXME check this code
|
||||
@JsonProperty("contaminationLevel")
|
||||
private String contaminationLevel;
|
||||
@JsonProperty("cityName")
|
||||
private String cityName;// FIXME check this code
|
||||
@JsonProperty("isJunctionStationName")
|
||||
private String isJunctionStationName;// FIXME check this code
|
||||
@JsonProperty("voltageLevel")
|
||||
private String voltageLevel;
|
||||
@JsonProperty("isFirts")
|
||||
private String isFirts;
|
||||
@JsonProperty("fireType")
|
||||
private String fireType;
|
||||
@JsonProperty("dutyMode")
|
||||
private String dutyMode;
|
||||
@JsonProperty("isJunctionStation")
|
||||
private String isJunctionStation;
|
||||
@JsonProperty("stationTypeName")
|
||||
private String StationTypeName;// FIXME check this code
|
||||
@JsonProperty("equipmentOwnerName")
|
||||
private String equipmentOwnerName;// FIXME check this code
|
||||
@JsonProperty("isFloodImportance")
|
||||
private String isFloodImportance;
|
||||
@JsonProperty("isN1")
|
||||
private String isN1;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class AssetsDTO {
|
||||
@JsonProperty("astId")
|
||||
private String astId;
|
||||
@JsonProperty("stationType")
|
||||
private String stationType;
|
||||
@JsonProperty("stationTypeName")
|
||||
private String stationTypeName;// FIXME check this code
|
||||
@JsonProperty("ctime")
|
||||
private String ctime;
|
||||
@JsonProperty("lastUpdateTime")
|
||||
private String lastUpdateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.jbsyncdata.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.jbsyncdata.pojo.PmsSubstation;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2024-08-07
|
||||
*/
|
||||
public interface IPmsSubstationService extends IService<PmsSubstation> {
|
||||
|
||||
|
||||
Boolean addYwZtSubstation(String distribution, String psrType);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.njcn.jbsyncdata.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.jbsyncdata.component.TokenComponent;
|
||||
import com.njcn.jbsyncdata.mapper.DictDataMapper;
|
||||
import com.njcn.jbsyncdata.mapper.PmsSubstationMapper;
|
||||
import com.njcn.jbsyncdata.pojo.DictData;
|
||||
import com.njcn.jbsyncdata.pojo.PmsSubstation;
|
||||
import com.njcn.jbsyncdata.pojo.YWZTSubstation;
|
||||
import com.njcn.jbsyncdata.pojo.result.TokenResult;
|
||||
import com.njcn.jbsyncdata.service.IPmsSubstationService;
|
||||
import com.njcn.jbsyncdata.util.RestTemplateUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2024-08-07
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PmsSubstationServiceImpl extends ServiceImpl<PmsSubstationMapper, PmsSubstation> implements IPmsSubstationService {
|
||||
|
||||
private final DictDataMapper dictDataMapper;
|
||||
|
||||
private final TokenComponent tokenComponent;
|
||||
|
||||
@Override
|
||||
public Boolean addYwZtSubstation(String distribution, String psrType) {
|
||||
//数据中心(电压等级)
|
||||
List<DictData> devVoltage = dictDataMapper.selectList("Dev_Voltage_Stand");
|
||||
TokenResult tokenWithRestTemplate = tokenComponent.getTokenWithRestTemplate();
|
||||
if (null == tokenWithRestTemplate) {
|
||||
log.error("token信息获取失败");
|
||||
return false;
|
||||
}
|
||||
RestTemplateUtil restTemplateUtil = new RestTemplateUtil();
|
||||
JSONObject param = new JSONObject();
|
||||
JSONObject params = new JSONObject();
|
||||
List<cn.hutool.json.JSONObject> paramList = new ArrayList<>();
|
||||
param.put("distribution", distribution);
|
||||
param.put("psrType", psrType);
|
||||
param.put("params", params);
|
||||
//当前页数
|
||||
params.put("current", "1");
|
||||
//每页数据量
|
||||
params.put("size", "2000");
|
||||
cn.hutool.json.JSONObject filter = JSONUtil.createObj();
|
||||
params.put("fieldName", "");
|
||||
params.put("compare", "");
|
||||
params.put("fieldValue", "");
|
||||
paramList.add(filter);
|
||||
params.put("filters", paramList);
|
||||
//组装好json开始发送请求
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("x-token", tokenWithRestTemplate.getAccess_token());
|
||||
|
||||
ResponseEntity<String> post = restTemplateUtil.post(tokenComponent.getUrl().concat("/PSRCenter/queryServices/listPropertiesByFilters"), headers, param, String.class);
|
||||
String body = post.getBody().replaceAll("#", "").replaceAll(psrType, "zf01");
|
||||
YWZTSubstation ywztSubstation = JSONObject.parseObject(body, YWZTSubstation.class);
|
||||
YWZTSubstation.ResultDTO.Zf01DTO zf01 = ywztSubstation.getResult().getZf01();
|
||||
List<YWZTSubstation.ResultDTO.Zf01DTO.RecordsDTO> records = zf01.getRecords();
|
||||
List<PmsSubstation> info = new ArrayList<>();
|
||||
for (YWZTSubstation.ResultDTO.Zf01DTO.RecordsDTO record : records) {
|
||||
YWZTSubstation.ResultDTO.Zf01DTO.RecordsDTO.ResourceDTO resource = record.getResource();
|
||||
|
||||
PmsSubstation substation = new PmsSubstation();
|
||||
substation.setId(record.getId());
|
||||
substation.setOrgId(resource.getCity());
|
||||
substation.setOperationName(resource.getCityName());
|
||||
substation.setType(psrType);
|
||||
substation.setName(resource.getName());
|
||||
substation.setScale(getAlgoDescribe(resource.getVoltageLevel(), devVoltage));
|
||||
substation.setScaleName(resource.getVoltageLevelName());
|
||||
substation.setMaintenanceName(resource.getMaintGroupName());
|
||||
substation.setRunStatus(resource.getPsrStateName());
|
||||
substation.setRunTime(LocalDateTimeUtil.parse(resource.getCtime(), "yyyy-MM-dd HH:mm:ss"));
|
||||
//经纬度
|
||||
String geoPositon = resource.getGeoPositon();
|
||||
String[] split = geoPositon.split(",");
|
||||
substation.setLng(new BigDecimal(split[0]));
|
||||
substation.setLat(new BigDecimal(split[1]));
|
||||
substation.setCreateTime(LocalDateTime.now());
|
||||
substation.setUpdateTime(LocalDateTime.now());
|
||||
info.add(substation);
|
||||
}
|
||||
|
||||
System.out.println(info);
|
||||
return this.saveOrUpdateBatch(info);
|
||||
}
|
||||
|
||||
public String getAlgoDescribe(String name, List<DictData> dictData) {
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
List<DictData> dictDataList = dictData.stream().filter(x -> x.getAlgoDescribe() == Integer.valueOf(name)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dictDataList)) {
|
||||
return dictDataList.get(0).getId();
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user