1.技术监督回退接口

This commit is contained in:
wr
2024-01-19 11:00:29 +08:00
parent 1a17ac195a
commit cd12aeb57a
4 changed files with 78 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.process.pojo.param.SendParam;
import com.njcn.process.service.SupvPushGwService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
@@ -154,4 +155,14 @@ public class SupvPushGwController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
}
@PostMapping("/reject")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("接收总部技术监督工作计划数据回退接口")
public HttpResult<String> reject(@RequestBody SendParam.Extend param){
String methodDescribe = getMethodDescribe("reject");
String s = supvPushGwService.reject(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
}
}

View File

@@ -1,5 +1,7 @@
package com.njcn.process.service;
import com.njcn.process.pojo.param.SendParam;
import java.io.IOException;
import java.util.List;
@@ -74,4 +76,11 @@ public interface SupvPushGwService {
* @Date: 2023/9/5 10:35
*/
String pushAlarmHis(List<String> ids);
/**
* 总部技术监督工作计划数据回退接口
* @param param
* @return
*/
String reject(SendParam.Extend param);
}

View File

@@ -586,6 +586,50 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
}
@Override
public String reject(SendParam.Extend param) {
try {
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
log.info(Thread.currentThread().getName() + "1.信息:" + s);
ContentBody cb = new ContentBody(s);
//如果需要传递请求参数 可以拼接到请求URL中或者设置paramsMap参数由SDK内部进行拼接
HttpParameters.Builder builder = HttpParameters.newBuilder();
builder.requestURL(getUrl(10)) // 设置请求的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", "pqSupervisionReject");
//进行调用,返回结果
try {
HttpReturn ret = HttpCaller.invokeReturn(builder.build());
String responseStr = ret.getResponseStr();//获取响应的文本串
log.info(Thread.currentThread().getName() + "返回信息:" + responseStr);
if (responseStr.indexOf("\\\"") != -1) {
responseStr = responseStr.replace("\\\"", "\"");
}
Map map = JSON.parseObject(responseStr, Map.class);
String status = map.get("code").toString();
if ("0".equals(status)) {
String result = map.get("data").toString();
return "操作成功:成功数据" + result + "";
} else {
String errors = map.get("msg").toString();
throw new BusinessException("操作失败:" + status + "_" + errors);
}
} catch (HttpCallerException e) {
log.info(Thread.currentThread().getName() + "错误信息:" + e);
}
} catch (Exception e) {
throw new BusinessException("当前时间段国网上送请求过多,请稍后再试");
}
return "接收总部技术监督工作计划数据回退接口,推送失败!";
}
public Map<String, String> send(SendParam param, String url, String serviceName) {
Map<String, String> map = new LinkedHashMap<>();
try {
@@ -817,6 +861,12 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
*/
url += "/WMCenter/powerQuality/alarm/backCreate";
break;
case 10:
/**
* 接收电能质量技术监督预告警单反馈数据接口
*/
url += "/WMCenter/powerQuality/supervision/reject";
break;
}
return url;
}