1.国网工具类提交
This commit is contained in:
@@ -69,6 +69,11 @@
|
|||||||
<groupId>com.nimbusds</groupId>
|
<groupId>com.nimbusds</groupId>
|
||||||
<artifactId>nimbus-jose-jwt</artifactId>
|
<artifactId>nimbus-jose-jwt</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.csb.sdk</groupId>
|
||||||
|
<artifactId>http-client</artifactId>
|
||||||
|
<version>1.1.5.11</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.njcn.web.enums;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 上送枚举
|
||||||
|
* @Author: wr
|
||||||
|
* @Date: 2023/12/7 10:53
|
||||||
|
*/
|
||||||
|
public enum GWSendEnum {
|
||||||
|
|
||||||
|
|
||||||
|
//接收电能质量基准水平评估数据接口
|
||||||
|
EVALUATION("pqEvaluationCreate", "/WMCenter/powerQuality/evaluation/create"),
|
||||||
|
//接收电能质量典型源荷指标统计数据接口
|
||||||
|
TYPICAL_SOURCE("pqTypicalSourceCreate", "/WMCenter/powerQuality/typicalSource/create"),
|
||||||
|
//接收电能质量风电场台账数据接口
|
||||||
|
WIND_CREATE("pqArchivalInformationWindCreate", "/WMCenter/powerQuality/archivalInformation/windCreate"),
|
||||||
|
//接收电能质量光伏电站台账数据接口
|
||||||
|
PHOTOVOLTAIC_CREATE("pqArchivalInformationPhotovoltaicCreate", "/WMCenter/powerQuality/archivalInformation/photovoltaicCreate"),
|
||||||
|
//接收电能质量重要、敏感用户台账数据接口
|
||||||
|
SENSITIVE_USER_CREATE("pqArchivalInformationSensitiveUserCreate", "/WMCenter/powerQuality/archivalInformation/sensitiveUserCreate"),
|
||||||
|
//接收电能质量牵引站台账数据接口
|
||||||
|
TRACTION_STATION("pqTractionStationCreate", "/WMCenter/powerQuality/tractionStation/create"),
|
||||||
|
//接收电能质量监测点台账数据接口
|
||||||
|
MONITOR("pqMonitorCreate", "/WMCenter/powerQuality/monitor/create"),
|
||||||
|
//接收电能质量监测点限值台账数据接口
|
||||||
|
LIMIT_CREATE("pqMonitorLimitCreate", "/WMCenter/powerQuality/monitor/limitCreate"),
|
||||||
|
//接收电能质量主配网监测点统计数据接口
|
||||||
|
STATISTICAL_CREATE("pqMonitorStatisticalCreate", "/WMCenter/powerQuality/monitor/statisticalCreate"),
|
||||||
|
//接收电能质量换流站指标汇总统计数据接口
|
||||||
|
INDEX_CREATE("pqConverterMonitorIndexCreate", "/WMCenter/powerQuality/converterMonitor/indexCreate"),
|
||||||
|
//接收电能质量换流站指标统计明细数据接口
|
||||||
|
DETAIL_CREATE("pqConverterMonitorDetailCreate", "/WMCenter/powerQuality/converterMonitor/detailCreate"),
|
||||||
|
//接收电能质量变电站监测统计数据接口
|
||||||
|
SUBSTATION_MONITOR("pqSubstationMonitorCreate", "/WMCenter/powerQuality/substationMonitor/create"),
|
||||||
|
//2.4.1.21接收其他干扰用户台账数据接口
|
||||||
|
OTHER_USER_CREATE("pqArchivalInformationOtherUserCreate", "/WMCenter/powerQuality/archivalInformation/otherUserCreate"),
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private final String serviceName;
|
||||||
|
|
||||||
|
private final String url;
|
||||||
|
|
||||||
|
GWSendEnum(String serviceName, String url) {
|
||||||
|
this.serviceName = serviceName;
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServiceName() {
|
||||||
|
return serviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return "http://dwzyywzt-pms3-proxy.com/CSB" + url;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.njcn.web.pojo.param;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wr
|
||||||
|
* @description
|
||||||
|
* @date 2023/7/28 9:47
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SendParam {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "省id")
|
||||||
|
private String provinceId="13B9B47F1E483324E05338297A0A0595";
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "密钥")
|
||||||
|
private String secretKey="lW2xr6zKjbaqVDOSgQpcGrM6Rg0=";
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "统计日期")
|
||||||
|
private String statisticalDate;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "上报参数")
|
||||||
|
private List stats;
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package com.njcn.web.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.csb.sdk.*;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.web.pojo.param.SendParam;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wr
|
||||||
|
* @description
|
||||||
|
* @date 2023/12/6 13:59
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class GwSendUtil {
|
||||||
|
|
||||||
|
private static final String GWURL = "dwzyywzt-pms3-proxy.com";
|
||||||
|
private static final String CODE = "13B9B47F1E483324E05338297A0A0595";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param param 上报入参数据
|
||||||
|
* @param url 上报地址 例如(http://dwzyywzt-pms3-proxy.com/CSB/WMCenter/powerQuality/plan/create)
|
||||||
|
* @param serviceName 例如(pqPlanCreate)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String, String> send(SendParam param, String url, String serviceName) {
|
||||||
|
Map<String, String> map = new LinkedHashMap<>();
|
||||||
|
try {
|
||||||
|
ContentBody cb;
|
||||||
|
if (ObjectUtil.isNull(param)) {
|
||||||
|
cb = new ContentBody("");
|
||||||
|
} else {
|
||||||
|
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
|
||||||
|
log.info(Thread.currentThread().getName() + "1.信息:" + s);
|
||||||
|
cb = new ContentBody(s);
|
||||||
|
}
|
||||||
|
//ContentBody传递,要求使用post方式进行调用
|
||||||
|
//如果需要传递请求参数 可以拼接到请求URL中,或者设置paramsMap参数由SDK内部进行拼接
|
||||||
|
HttpParameters.Builder builder = HttpParameters.newBuilder();
|
||||||
|
|
||||||
|
builder.requestURL(url) // 设置请求的URL,可以拼接URL请求参数
|
||||||
|
.api("zongbuSync") // 设置服务名
|
||||||
|
.version("1.0.0") // 设置版本号
|
||||||
|
.method("post") // 设置调用方式, 必须为 post
|
||||||
|
.contentType("application/json; charset=UTF-8") //设置请求content-type
|
||||||
|
.accessKey("7d4cb2c0afb5468ca56e0654b1a442ef").secretKey("lW2xr6zKjbaqVDOSgQpcGrM6Rg0=");// 设置accessKey 和 设置secretKey
|
||||||
|
|
||||||
|
|
||||||
|
builder.contentBody(cb);
|
||||||
|
String token = LoginToken();
|
||||||
|
builder.putHeaderParamsMap("x-token", token);
|
||||||
|
builder.putHeaderParamsMap("serviceName", serviceName);
|
||||||
|
//进行调用,返回结果
|
||||||
|
try {
|
||||||
|
HttpReturn ret = HttpCaller.invokeReturn(builder.build());
|
||||||
|
String responseStr = ret.getResponseStr();//获取响应的文本串
|
||||||
|
map.put("succeed", responseStr);
|
||||||
|
} catch (HttpCallerException e) {
|
||||||
|
// error process
|
||||||
|
log.info(Thread.currentThread().getName() + "错误信息:" + e);
|
||||||
|
map.put("error", e.toString());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
map.put("error", "当前时间段国网上送请求过多,请稍后再试");
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取token
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String LoginToken() {
|
||||||
|
String token;
|
||||||
|
String clientId = "942a9278671711eda2e10ae0b5517f6c";
|
||||||
|
String clientSecret = "3Psd2VEhsA3dVsSPHW0ll5r/03kAqlA2P4w2IiWPA8UWSadcX0we2wffjyTUYGsK";
|
||||||
|
|
||||||
|
String userUrl = "http://" + GWURL + "/psr-auth/oauth/accessToken?grant_type={grant_type}&client_id={client_id}&client_secret={client_secret}";
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
map.put("grant_type", "credentials");
|
||||||
|
map.put("client_id", clientId);
|
||||||
|
map.put("client_secret", clientSecret);
|
||||||
|
ResponseEntity<Map> userEntity = RestTemplateUtil.get(userUrl, Map.class, map);
|
||||||
|
|
||||||
|
if (userEntity.getStatusCodeValue() == 200) {
|
||||||
|
log.info(Thread.currentThread().getName() + "数据:" + userEntity.getBody() + "结束----!");
|
||||||
|
//获取返回体
|
||||||
|
Map body = userEntity.getBody();
|
||||||
|
token = body.get("access_token").toString();
|
||||||
|
} else {
|
||||||
|
throw new BusinessException("获取数据token出现未知异常!请检查ip端口是否正确!");
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,5 +13,6 @@ import java.util.List;
|
|||||||
public class SendParam {
|
public class SendParam {
|
||||||
|
|
||||||
private String provinceId;
|
private String provinceId;
|
||||||
|
private String secretKey="lW2xr6zKjbaqVDOSgQpcGrM6Rg0=";
|
||||||
private List stats;
|
private List stats;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
@@ -55,12 +56,14 @@ public class SupvFile {
|
|||||||
private String uploaderName;
|
private String uploaderName;
|
||||||
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime uploadTime;
|
private LocalDateTime uploadTime;
|
||||||
|
|
||||||
@ApiModelProperty("上传人id")
|
@ApiModelProperty("上传人id")
|
||||||
private String uploaderId;
|
private String uploaderId;
|
||||||
|
|
||||||
@ApiModelProperty("创建时间")
|
@ApiModelProperty("创建时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@ApiModelProperty("0.未上送 1.已上送 2.取消上送")
|
@ApiModelProperty("0.未上送 1.已上送 2.取消上送")
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import java.util.stream.Stream;
|
|||||||
public class SupvPushGwServiceImpl implements SupvPushGwService {
|
public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||||
|
|
||||||
private final SupvPlanMapper supvPlanMapper;
|
private final SupvPlanMapper supvPlanMapper;
|
||||||
|
private final ISupvPlanService iSupvPlanService;
|
||||||
|
|
||||||
private final SupvProblemMapper supvProblemMapper;
|
private final SupvProblemMapper supvProblemMapper;
|
||||||
|
|
||||||
@@ -418,45 +419,12 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
|||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
throw new BusinessException("请选择已上送计划");
|
throw new BusinessException("请选择已上送计划");
|
||||||
}
|
}
|
||||||
|
iSupvPlanService.update(new LambdaUpdateWrapper<SupvPlan>()
|
||||||
List<SupvPlan> supvPlanList = new ArrayList<>();
|
.set(SupvPlan::getDeleteFlag, 1)
|
||||||
for (String id : planIds) {
|
.set(SupvPlan::getDeleteTime, LocalDateTime.now())
|
||||||
SupvPlan supvPlan = new SupvPlan();
|
.in(SupvPlan::getPlanId, planIds)
|
||||||
supvPlan.setPlanId(id);
|
);
|
||||||
supvPlan.setDeleteFlag(null);
|
return this.pushPlan(planIds);
|
||||||
supvPlanList.add(supvPlan);
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
SendParam param = new SendParam();
|
|
||||||
param.setStats(supvPlanList);
|
|
||||||
param.setProvinceId(code);
|
|
||||||
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
|
|
||||||
log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口数据:" + s + "结束----!");
|
|
||||||
Map<String, String> send = send(param, getUrl(6), "pqPlanDelete");
|
|
||||||
log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口响应结果:" + send + "结束----!");
|
|
||||||
if (send.containsKey("succeed")) {
|
|
||||||
String succeed = send.get("succeed");
|
|
||||||
if (succeed.indexOf("\\\"") != -1) {
|
|
||||||
succeed = succeed.replace("\\\"", "\"");
|
|
||||||
}
|
|
||||||
Map map = JSON.parseObject(succeed, Map.class);
|
|
||||||
String status = map.get("status").toString();
|
|
||||||
if ("000000".equals(status)) {
|
|
||||||
for (SupvPlan supvPlan : supvPlanList) {
|
|
||||||
supvPlanMapper.updateId(2, supvPlan.getPlanId());
|
|
||||||
}
|
|
||||||
String result = map.get("result").toString();
|
|
||||||
Map mapCount = JSON.parseObject(result, Map.class);
|
|
||||||
String countNum = mapCount.get("count").toString();
|
|
||||||
return "操作成功:成功数据" + countNum + "条";
|
|
||||||
} else {
|
|
||||||
String errors = map.get("errors").toString();
|
|
||||||
throw new BusinessException("操作失败:" + status + "_" + errors);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new BusinessException("当前时间段国网上送请求过多,请稍后再试");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user