1.添加pms国网上送定时接口
2.处理上送国网bug
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.njcn.device.pms.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pms.api.fallback.GwMonitorPushClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/12/22
|
||||
*/
|
||||
|
||||
@FeignClient(value = ServerInfo.DEVICE,
|
||||
path = "gwTerminalPush",
|
||||
contextId = "gwTerminalPush",
|
||||
fallbackFactory = GwMonitorPushClientFallbackFactory.class)
|
||||
public interface GwMonitorPushFeignClient {
|
||||
|
||||
/**
|
||||
* 定时推送国网监测点
|
||||
* @author cdf
|
||||
* @date 2023/12/22
|
||||
*/
|
||||
@PostMapping("/pushMonitor")
|
||||
HttpResult<String> timeTaskPushMonitor(@RequestBody List<String> ids);
|
||||
|
||||
|
||||
/**
|
||||
* 定时推送国网监测点
|
||||
* @author cdf
|
||||
* @date 2023/12/22
|
||||
*/
|
||||
@PostMapping("/pushMonitorOverLimit")
|
||||
HttpResult<Object> pushMonitorOverLimit(@RequestBody List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.njcn.device.pms.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pms.api.GwMonitorPushFeignClient;
|
||||
import com.njcn.device.pms.utils.PmsDeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yzh
|
||||
* @date 2022/10/18
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class GwMonitorPushClientFallbackFactory implements FallbackFactory<GwMonitorPushFeignClient> {
|
||||
|
||||
@Override
|
||||
public GwMonitorPushFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = PmsDeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new GwMonitorPushFeignClient() {
|
||||
@Override
|
||||
public HttpResult<String> timeTaskPushMonitor(List<String> ids) {
|
||||
log.error("{}异常,降级处理,异常为:{}", LocalDate.now()+"定时推送主网监测点", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Object> pushMonitorOverLimit(List<String> ids) {
|
||||
log.error("{}异常,降级处理,异常为:{}", LocalDate.now()+"定时推送主网监测点限值", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -242,6 +242,11 @@ public class MonitorParam {
|
||||
@ApiModelProperty(value = "行业分类")
|
||||
private String tradeCode;
|
||||
|
||||
/**
|
||||
* 牵引站id
|
||||
*/
|
||||
private String tractionId;
|
||||
|
||||
@Data
|
||||
public static class Info implements Serializable {
|
||||
@ApiModelProperty(name = "monitorTag",value = "监测点对象标签")
|
||||
|
||||
@@ -61,6 +61,9 @@ public class GwMonitorPushController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, msg, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 推送监测点限值台账数据接口
|
||||
* @author cdf
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
or b.name like concat('%',#{baseParam.searchValue},'%')
|
||||
)
|
||||
</if>
|
||||
order by a.Create_Time desc
|
||||
order by a.Power_Name asc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.device.pms.service.gwPush.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
@@ -24,6 +25,7 @@ import com.njcn.device.pms.service.gwPush.GwMonitorPushService;
|
||||
import com.njcn.device.pms.service.majornetwork.IMonitorService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
@@ -42,6 +44,7 @@ import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
@@ -71,6 +74,10 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService {
|
||||
@Override
|
||||
public String pushMonitor(List<String> ids) {
|
||||
|
||||
if (ids.size() > 100) {
|
||||
throw new BusinessException("一次最多上送100条数据");
|
||||
}
|
||||
|
||||
List<PushMonitorDTO> pushResult = new ArrayList<>();
|
||||
|
||||
//电压等级
|
||||
@@ -89,20 +96,20 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService {
|
||||
List<DictData> tranDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.VOLTAGE_TRANSFORMER.getCode()).getData();
|
||||
Map<String, DictData> tranMap = tranDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
|
||||
DictData monitorStateDic = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.LINE_STATE.getName(), DicDataEnum.RUN.getName()).getData();
|
||||
|
||||
|
||||
LambdaQueryWrapper<Monitor> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(Monitor::getId, ids).eq(Monitor::getStatus, DataStateEnum.ENABLE.getCode());
|
||||
List<Monitor> monitorList = monitorService.list(lambdaQueryWrapper);
|
||||
|
||||
if (monitorList.size() > 100) {
|
||||
throw new BusinessException("一次最多上送100条数据");
|
||||
if(CollUtil.isEmpty(ids)){
|
||||
lambdaQueryWrapper.in(Monitor::getMonitorUploadStatus, Stream.of(0,3).collect(Collectors.toList())).eq(Monitor::getMonitorState,monitorStateDic.getId())
|
||||
.eq(Monitor::getStatus, DataStateEnum.ENABLE.getCode()).eq(Monitor::getIsUpToGrid,1);
|
||||
}else {
|
||||
lambdaQueryWrapper.in(Monitor::getId, ids).eq(Monitor::getStatus, DataStateEnum.ENABLE.getCode());
|
||||
}
|
||||
List<Monitor> monitorList = monitorService.list(lambdaQueryWrapper);
|
||||
if(CollUtil.isEmpty(monitorList)){
|
||||
throw new BusinessException("未查询到有效监测点!");
|
||||
}
|
||||
|
||||
/*long count = monitorList.stream().filter(item->item.getMonitorUploadStatus() == 1).count();
|
||||
if (count > 0) {
|
||||
throw new BusinessException("存在以上送监测点,请勿重复上送");
|
||||
}*/
|
||||
|
||||
|
||||
List<String> stationIds = monitorList.stream().map(Monitor::getPowerrId).distinct().collect(Collectors.toList());
|
||||
List<String> terminalIds = monitorList.stream().map(Monitor::getTerminalId).distinct().collect(Collectors.toList());
|
||||
@@ -223,40 +230,85 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService {
|
||||
|
||||
|
||||
|
||||
if(pushResult.size()>100){
|
||||
List<List<PushMonitorDTO>> pushMonitorDTOList = ListUtil.split(pushResult,100);
|
||||
|
||||
int countAll = 0;
|
||||
for(List<PushMonitorDTO> list : pushMonitorDTOList){
|
||||
SendParam sendParam = new SendParam();
|
||||
sendParam.setStats(list);
|
||||
Map<String, String> sendRes = GwSendUtil.send(sendParam, GWSendEnum.MONITOR);
|
||||
List<String> mIds = list.stream().map(PushMonitorDTO::getId).distinct().collect(Collectors.toList());
|
||||
|
||||
if (sendRes.containsKey("succeed")) {
|
||||
String succeed = sendRes.get("succeed");
|
||||
if (succeed.indexOf("\\\"") != -1) {
|
||||
succeed = succeed.replace("\\\"", "\"");
|
||||
}
|
||||
Map mapData = JSON.parseObject(succeed, Map.class);
|
||||
String status = mapData.get("status").toString();
|
||||
if ("000000".equals(status)) {
|
||||
//修改信息状态
|
||||
updateIsUploadHead(1, mIds);
|
||||
String result = mapData.get("result").toString();
|
||||
Map mapCount = JSON.parseObject(result, Map.class);
|
||||
int count = Integer.parseInt(mapCount.get("count").toString());
|
||||
countAll+=count;
|
||||
} else {
|
||||
String errors = mapData.get("errors").toString();
|
||||
throw new BusinessException("操作失败:" + status + "_" + errors);
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException("当前时间段国网上送请求过多,请稍后再试");
|
||||
}
|
||||
}
|
||||
return "操作成功:成功数据" + countAll + "条";
|
||||
}else {
|
||||
SendParam sendParam = new SendParam();
|
||||
sendParam.setStats(pushResult);
|
||||
Map<String, String> sendRes = GwSendUtil.send(sendParam, GWSendEnum.MONITOR);
|
||||
List<String> mIds = monitorList.stream().map(Monitor::getId).distinct().collect(Collectors.toList());
|
||||
String msg = returnInformation(1, mIds, sendRes);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
SendParam sendParam = new SendParam();
|
||||
sendParam.setStats(pushResult);
|
||||
Map<String, String> sendRes = GwSendUtil.send(sendParam, GWSendEnum.MONITOR);
|
||||
List<String> mIds = monitorList.stream().map(Monitor::getId).distinct().collect(Collectors.toList());
|
||||
String msg = returnInformation(1, mIds, sendRes);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String pushMonitorOverLimit(List<String> ids) {
|
||||
if (ids.size() > 100) {
|
||||
throw new BusinessException("一次最多上送100条数据");
|
||||
}
|
||||
|
||||
List<MonitorLimitDTO> pushResult = new ArrayList<>();
|
||||
|
||||
//电压等级
|
||||
List<DictData> voltageDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
|
||||
Map<String, DictData> voltageMap = voltageDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
|
||||
DictData monitorStateDic = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.LINE_STATE.getName(), DicDataEnum.RUN.getName()).getData();
|
||||
|
||||
|
||||
LambdaQueryWrapper<Monitor> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(Monitor::getId, ids).eq(Monitor::getStatus, DataStateEnum.ENABLE.getCode());
|
||||
if(CollUtil.isEmpty(ids)){
|
||||
lambdaQueryWrapper.in(Monitor::getMonitorUploadStatus, Stream.of(0,3).collect(Collectors.toList())).eq(Monitor::getMonitorState,monitorStateDic.getId())
|
||||
.eq(Monitor::getStatus, DataStateEnum.ENABLE.getCode()).eq(Monitor::getIsUpToGrid,1);
|
||||
}else {
|
||||
lambdaQueryWrapper.in(Monitor::getId, ids).eq(Monitor::getStatus, DataStateEnum.ENABLE.getCode());
|
||||
}
|
||||
List<Monitor> monitorList = monitorService.list(lambdaQueryWrapper);
|
||||
|
||||
if (monitorList.size() > 100) {
|
||||
throw new BusinessException("一次最多上送100条数据");
|
||||
if(CollUtil.isEmpty(monitorList)){
|
||||
throw new BusinessException("未查询到有效监测点!");
|
||||
}
|
||||
List<String> monitorIds = monitorList.stream().map(Monitor::getId).distinct().collect(Collectors.toList());
|
||||
|
||||
|
||||
/* long count = monitorList.stream().filter(item->item.getMonitorOverlimitStatus() == 1).count();
|
||||
if (count > 0) {
|
||||
throw new BusinessException("存在以上送限值,请勿重复上送");
|
||||
}*/
|
||||
|
||||
LambdaQueryWrapper<Overlimit> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(Overlimit::getId, ids);
|
||||
queryWrapper.in(Overlimit::getId, monitorIds);
|
||||
List<Overlimit> overlimitList = overlimitMapper.selectList(queryWrapper);
|
||||
Map<String, Overlimit> map = overlimitList.stream().collect(Collectors.toMap(Overlimit::getId, Function.identity()));
|
||||
|
||||
@@ -351,12 +403,49 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService {
|
||||
pushResult.add(monitorLimitDTO);
|
||||
}
|
||||
|
||||
SendParam sendParam = new SendParam();
|
||||
sendParam.setStats(pushResult);
|
||||
Map<String, String> sendRes = GwSendUtil.send(sendParam, GWSendEnum.LIMIT_CREATE);
|
||||
List<String> mIds = monitorList.stream().map(Monitor::getId).distinct().collect(Collectors.toList());
|
||||
String msg = returnInformation(2, mIds, sendRes);
|
||||
return msg;
|
||||
if(pushResult.size()>100){
|
||||
List<List<MonitorLimitDTO>> pushMonitorDTOList = ListUtil.split(pushResult,100);
|
||||
|
||||
int countAll = 0;
|
||||
for(List<MonitorLimitDTO> list : pushMonitorDTOList){
|
||||
SendParam sendParam = new SendParam();
|
||||
sendParam.setStats(list);
|
||||
Map<String, String> sendRes = GwSendUtil.send(sendParam, GWSendEnum.LIMIT_CREATE);
|
||||
List<String> mIds = list.stream().map(MonitorLimitDTO::getId).distinct().collect(Collectors.toList());
|
||||
|
||||
if (sendRes.containsKey("succeed")) {
|
||||
String succeed = sendRes.get("succeed");
|
||||
if (succeed.indexOf("\\\"") != -1) {
|
||||
succeed = succeed.replace("\\\"", "\"");
|
||||
}
|
||||
Map mapData = JSON.parseObject(succeed, Map.class);
|
||||
String status = mapData.get("status").toString();
|
||||
if ("000000".equals(status)) {
|
||||
//修改信息状态
|
||||
updateIsUploadHead(2, mIds);
|
||||
String result = mapData.get("result").toString();
|
||||
Map mapCount = JSON.parseObject(result, Map.class);
|
||||
int count = Integer.parseInt(mapCount.get("count").toString());
|
||||
countAll+=count;
|
||||
} else {
|
||||
String errors = mapData.get("errors").toString();
|
||||
throw new BusinessException("操作失败:" + status + "_" + errors);
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException("当前时间段国网上送请求过多,请稍后再试");
|
||||
}
|
||||
}
|
||||
return "操作成功:成功数据" + countAll + "条";
|
||||
}else {
|
||||
SendParam sendParam = new SendParam();
|
||||
sendParam.setStats(pushResult);
|
||||
Map<String, String> sendRes = GwSendUtil.send(sendParam, GWSendEnum.LIMIT_CREATE);
|
||||
List<String> mIds = monitorList.stream().map(Monitor::getId).distinct().collect(Collectors.toList());
|
||||
String msg = returnInformation(2, mIds, sendRes);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
throw new BusinessException("暂无监测点信息");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user