1.添加了技术监督部分缺少字段信息

2.修改字段属性对应的值powerTotalConductedNum改为powerMonthConductedNum
This commit is contained in:
wr
2023-07-28 17:31:46 +08:00
parent 4a2522e90b
commit 3e0157e889
8 changed files with 306 additions and 138 deletions

View File

@@ -0,0 +1,17 @@
package com.njcn.process.pojo.param;
import lombok.Data;
import java.util.List;
/**
* @author wr
* @description
* @date 2023/7/28 9:47
*/
@Data
public class SendParam {
private String provinceId;
private List stats;
}

View File

@@ -25,6 +25,11 @@ public class SupvFile {
@TableId @TableId
private String uuid; private String uuid;
/**
* 所属网省id
*/
@TableField(exist = false)
private String provinceId;
/** /**
* 附件路径 * 附件路径

View File

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.njcn.db.bo.BaseEntity; import com.njcn.db.bo.BaseEntity;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -121,7 +122,7 @@ public class SupvPlan extends BaseEntity {
/** /**
* 实施状态 * 实施状态
*/ */
private String effectStatus; private String effectStatus;
/** /**
* 监督对象名称 * 监督对象名称
@@ -184,7 +185,6 @@ public class SupvPlan extends BaseEntity {
private Double objCapacity; private Double objCapacity;
/** /**
* 报告出具时间 * 报告出具时间
*/ */
@@ -200,15 +200,30 @@ public class SupvPlan extends BaseEntity {
private LocalDateTime problemOcTime; private LocalDateTime problemOcTime;
/** /**
* 0.未上送 1.上送 2.取消上送 * 0.未上送 1.上送 2.取消上送
*/ */
private Integer isUploadHead; private Integer isUploadHead;
/**
* 删除标识 0否1是
*/
private String deleteFlag;
/**
* 计划状态 1新建2变更 3取消
*/
private String planStatus;
/**
* 删除时间
*/
private LocalDateTime deleteTime;
/**
* 实施人id
*/
private String effectUserId;
/**
* 实施人姓名
*/
private String effectUserName;
} }

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.njcn.db.bo.BaseEntity; import com.njcn.db.bo.BaseEntity;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate; import java.time.LocalDate;
@@ -35,6 +36,13 @@ public class SupvProblem extends BaseEntity {
@TableId @TableId
private String problemId; private String problemId;
/**
* 所属网省id
*/
@TableField(exist = false)
private String provinceId;
/** /**
* 关联计划表 * 关联计划表
*/ */
@@ -56,6 +64,7 @@ public class SupvProblem extends BaseEntity {
/** /**
* 整改时间 * 整改时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(updateStrategy = FieldStrategy.IGNORED) @TableField(updateStrategy = FieldStrategy.IGNORED)
private LocalDate rectificationTime; private LocalDate rectificationTime;
@@ -145,6 +154,7 @@ public class SupvProblem extends BaseEntity {
@ApiModelProperty(name = "attachmentNameTwo",value = "佐证材料") @ApiModelProperty(name = "attachmentNameTwo",value = "佐证材料")
private String attachmentNameTwo; private String attachmentNameTwo;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime discoveryTime;
} }

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId; import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import com.njcn.db.bo.BaseEntity; import com.njcn.db.bo.BaseEntity;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate; import java.time.LocalDate;
@@ -201,7 +202,24 @@ public class SupvReportM {
/** /**
* 供电电压本月前已开展数量 * 供电电压本月前已开展数量
*/ */
private Integer powerTotalConductedNum; private Integer powerMonthConductedNum;
/**
* 供电电压本月问题数量
*/
private Integer powerMonthQuesNum;
/**
*供电电压累计问题数量
*/
private Integer powerTotalQuesNum;
/**
*供电电压本月整改问题数量
*/
private Integer powerMonthReformNum;
/**
*供电电压累计整改问题数量
*/
private Integer powerTotalReformNum;
private Integer isUploadHead; private Integer isUploadHead;

View File

@@ -106,6 +106,13 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<!--阿里的csb-->
<dependency>
<groupId>com.alibaba.csb.sdk</groupId>
<artifactId>http-client</artifactId>
<version>1.1.5.11</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.csb.sdk.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
@@ -12,11 +14,11 @@ import com.njcn.process.mapper.SupvFileMapper;
import com.njcn.process.mapper.SupvPlanMapper; import com.njcn.process.mapper.SupvPlanMapper;
import com.njcn.process.mapper.SupvProblemMapper; import com.njcn.process.mapper.SupvProblemMapper;
import com.njcn.process.mapper.SupvReportMMapper; import com.njcn.process.mapper.SupvReportMMapper;
import com.njcn.process.pojo.param.SendParam;
import com.njcn.process.pojo.po.SupvFile; import com.njcn.process.pojo.po.SupvFile;
import com.njcn.process.pojo.po.SupvPlan; import com.njcn.process.pojo.po.SupvPlan;
import com.njcn.process.pojo.po.SupvProblem; import com.njcn.process.pojo.po.SupvProblem;
import com.njcn.process.pojo.po.SupvReportM; import com.njcn.process.pojo.po.SupvReportM;
import com.njcn.process.pojo.vo.SupvPlanVO;
import com.njcn.process.service.SupvPushGwService; import com.njcn.process.service.SupvPushGwService;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.enums.DicDataTypeEnum;
@@ -76,65 +78,65 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
@Override @Override
public boolean pushPlan(List<String> planIds) { public boolean pushPlan(List<String> planIds) {
LambdaQueryWrapper<SupvPlan> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SupvPlan> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(SupvPlan::getPlanId,planIds); lambdaQueryWrapper.in(SupvPlan::getPlanId, planIds);
List<SupvPlan> supvPlanList = supvPlanMapper.selectList(lambdaQueryWrapper); List<SupvPlan> supvPlanList = supvPlanMapper.selectList(lambdaQueryWrapper);
if(CollUtil.isEmpty(supvPlanList)){ if (CollUtil.isEmpty(supvPlanList)) {
return false; return false;
} }
List<PvTerminalTreeVO> deptList = deptFeignClient.allDeptList().getData(); List<PvTerminalTreeVO> deptList = deptFeignClient.allDeptList().getData();
Map<String,PvTerminalTreeVO> mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity())); Map<String, PvTerminalTreeVO> mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity()));
Map<String,PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity())); Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity()));
List<DictData> supvDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_TYPE.getCode()).getData(); List<DictData> supvDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_TYPE.getCode()).getData();
Map<String, DictData> mapType = supvDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); Map<String, DictData> mapType = supvDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
List<DictData> supvStateDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_STAGE.getCode()).getData(); List<DictData> supvStateDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_STAGE.getCode()).getData();
Map<String, DictData> mapSupvState = supvStateDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); Map<String, DictData> mapSupvState = supvStateDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
List<DictData> supveffectDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EFFECT_STATUS.getCode()).getData(); List<DictData> supveffectDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EFFECT_STATUS.getCode()).getData();
Map<String, DictData> mapSupvEffect = supveffectDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); Map<String, DictData> mapSupvEffect = supveffectDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
List<DictData> supvObjTypeDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_OBJ_TYPE.getCode()).getData(); List<DictData> supvObjTypeDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_OBJ_TYPE.getCode()).getData();
Map<String, DictData> mapSubvObjType = supvObjTypeDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); Map<String, DictData> mapSubvObjType = supvObjTypeDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
List<DictData> supvVoltageDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData(); List<DictData> supvVoltageDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
Map<String, DictData> mapVoltage = supvVoltageDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); Map<String, DictData> mapVoltage = supvVoltageDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
List<String> userIds = supvPlanList.stream().map(SupvPlan::getUpdateBy).distinct().collect(Collectors.toList()); List<String> userIds = supvPlanList.stream().map(SupvPlan::getUpdateBy).distinct().collect(Collectors.toList());
List<User> userList = userFeignClient.getUserByIdList(userIds).getData(); List<User> userList = userFeignClient.getUserByIdList(userIds).getData();
Map<String, User> map = userList.stream().collect(Collectors.toMap(User::getId, Function.identity())); Map<String, User> map = userList.stream().collect(Collectors.toMap(User::getId, Function.identity()));
for(SupvPlan supvPlan:supvPlanList){ for (SupvPlan supvPlan : supvPlanList) {
PvTerminalTreeVO pvTerminalTreeVO = null; PvTerminalTreeVO pvTerminalTreeVO = null;
if(mapCode.containsKey(supvPlan.getSupvOrgId())) { if (mapCode.containsKey(supvPlan.getSupvOrgId())) {
pvTerminalTreeVO = mapCode.get(supvPlan.getSupvOrgId()); pvTerminalTreeVO = mapCode.get(supvPlan.getSupvOrgId());
supvPlan.setSupvOrgName(pvTerminalTreeVO.getName()); supvPlan.setSupvOrgName(pvTerminalTreeVO.getName());
int deptLevel = pvTerminalTreeVO.getPids().split(StrUtil.COMMA).length; int deptLevel = pvTerminalTreeVO.getPids().split(StrUtil.COMMA).length;
if(deptLevel == 2){ if (deptLevel == 2) {
//省 //省
supvPlan.setProvinceName(pvTerminalTreeVO.getName()); supvPlan.setProvinceName(pvTerminalTreeVO.getName());
supvPlan.setProvinceId(pvTerminalTreeVO.getCode()); supvPlan.setProvinceId(pvTerminalTreeVO.getCode());
}else if(deptLevel == 3){ } else if (deptLevel == 3) {
//市 //市
supvPlan.setCityName(pvTerminalTreeVO.getName()); supvPlan.setCityName(pvTerminalTreeVO.getName());
supvPlan.setCityId(pvTerminalTreeVO.getCode()); supvPlan.setCityId(pvTerminalTreeVO.getCode());
if(mapList.containsKey(pvTerminalTreeVO.getPid())) { if (mapList.containsKey(pvTerminalTreeVO.getPid())) {
PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid()); PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid());
supvPlan.setProvinceName(pvTerminalTreeOne.getName()); supvPlan.setProvinceName(pvTerminalTreeOne.getName());
supvPlan.setProvinceId(pvTerminalTreeOne.getCode()); supvPlan.setProvinceId(pvTerminalTreeOne.getCode());
} }
}else if(deptLevel == 4){ } else if (deptLevel == 4) {
//县 //县
if(mapList.containsKey(pvTerminalTreeVO.getPid())) { if (mapList.containsKey(pvTerminalTreeVO.getPid())) {
supvPlan.setCountyName(pvTerminalTreeVO.getName()); supvPlan.setCountyName(pvTerminalTreeVO.getName());
supvPlan.setCountyId(pvTerminalTreeVO.getCode()); supvPlan.setCountyId(pvTerminalTreeVO.getCode());
PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid()); PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid());
if (Objects.nonNull(pvTerminalTreeOne)) { if (Objects.nonNull(pvTerminalTreeOne)) {
supvPlan.setCityName(pvTerminalTreeOne.getName()); supvPlan.setCityName(pvTerminalTreeOne.getName());
supvPlan.setCityId(pvTerminalTreeOne.getCode()); supvPlan.setCityId(pvTerminalTreeOne.getCode());
if(mapList.containsKey(pvTerminalTreeOne.getPid())) { if (mapList.containsKey(pvTerminalTreeOne.getPid())) {
PvTerminalTreeVO pvTerminalTreeTwo = mapList.get(pvTerminalTreeOne.getPid()); PvTerminalTreeVO pvTerminalTreeTwo = mapList.get(pvTerminalTreeOne.getPid());
if (Objects.nonNull(pvTerminalTreeTwo)) { if (Objects.nonNull(pvTerminalTreeTwo)) {
supvPlan.setProvinceName(pvTerminalTreeTwo.getName()); supvPlan.setProvinceName(pvTerminalTreeTwo.getName());
@@ -148,33 +150,33 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
//处理字典 //处理字典
//监督类型编码 //监督类型编码
if(mapType.containsKey(supvPlan.getSupvType())) { if (mapType.containsKey(supvPlan.getSupvType())) {
supvPlan.setSupvType(String.format("%02d", mapType.get(supvPlan.getSupvType()).getAlgoDescribe())); supvPlan.setSupvType(String.format("%02d", mapType.get(supvPlan.getSupvType()).getAlgoDescribe()));
} }
//监督类型编码 //监督类型编码
if(mapSupvState.containsKey(supvPlan.getSupvStage())) { if (mapSupvState.containsKey(supvPlan.getSupvStage())) {
supvPlan.setSupvStage(String.format("%02d", mapSupvState.get(supvPlan.getSupvStage()).getAlgoDescribe())); supvPlan.setSupvStage(String.format("%02d", mapSupvState.get(supvPlan.getSupvStage()).getAlgoDescribe()));
} }
//监督阶段 //监督阶段
if(mapSupvEffect.containsKey(supvPlan.getEffectStatus())) { if (mapSupvEffect.containsKey(supvPlan.getEffectStatus())) {
supvPlan.setEffectStatus(String.format("%02d", mapSupvEffect.get(supvPlan.getEffectStatus()).getAlgoDescribe())); supvPlan.setEffectStatus(String.format("%02d", mapSupvEffect.get(supvPlan.getEffectStatus()).getAlgoDescribe()));
} }
//监督对象类型 //监督对象类型
if(mapSubvObjType.containsKey(supvPlan.getSupvObjType())) { if (mapSubvObjType.containsKey(supvPlan.getSupvObjType())) {
supvPlan.setSupvType(String.format("%02d", mapSubvObjType.get(supvPlan.getSupvObjType()).getAlgoDescribe())); supvPlan.setSupvType(String.format("%02d", mapSubvObjType.get(supvPlan.getSupvObjType()).getAlgoDescribe()));
} }
//电站等级 //电站等级
if(mapVoltage.containsKey(supvPlan.getSubstationVoltageLevel())) { if (mapVoltage.containsKey(supvPlan.getSubstationVoltageLevel())) {
supvPlan.setSubstationVoltageLevelName(mapVoltage.get(supvPlan.getSubstationVoltageLevel()).getName()); supvPlan.setSubstationVoltageLevelName(mapVoltage.get(supvPlan.getSubstationVoltageLevel()).getName());
supvPlan.setSubstationVoltageLevel(String.format("%02d", mapVoltage.get(supvPlan.getSubstationVoltageLevel()).getAlgoDescribe())); supvPlan.setSubstationVoltageLevel(String.format("%02d", mapVoltage.get(supvPlan.getSubstationVoltageLevel()).getAlgoDescribe()));
} }
if(mapVoltage.containsKey(supvPlan.getObjVoltageLevel())) { if (mapVoltage.containsKey(supvPlan.getObjVoltageLevel())) {
DictData dictData = mapVoltage.get(supvPlan.getObjVoltageLevel()); DictData dictData = mapVoltage.get(supvPlan.getObjVoltageLevel());
supvPlan.setObjVoltageLevel(String.format("%02d", dictData.getAlgoDescribe())); supvPlan.setObjVoltageLevel(String.format("%02d", dictData.getAlgoDescribe()));
supvPlan.setObjVoltageLevelName(dictData.getName()); supvPlan.setObjVoltageLevelName(dictData.getName());
@@ -185,86 +187,112 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
supvPlan.setPlanUserName(map.get(supvPlan.getPlanUserId()).getName()); supvPlan.setPlanUserName(map.get(supvPlan.getPlanUserId()).getName());
} }
//添加计划单位名称 //添加计划单位名称
if(mapCode.containsKey(supvPlan.getPlanOrgId())){ if (mapCode.containsKey(supvPlan.getPlanOrgId())) {
pvTerminalTreeVO = mapCode.get(supvPlan.getPlanOrgId()); pvTerminalTreeVO = mapCode.get(supvPlan.getPlanOrgId());
supvPlan.setPlanOrgName(pvTerminalTreeVO.getName()); supvPlan.setPlanOrgName(pvTerminalTreeVO.getName());
} }
supvPlan.setSupvObjId(IdUtil.simpleUUID()); supvPlan.setSupvObjId(IdUtil.simpleUUID());
} }
if(supvPlanList.size()>100){ if (supvPlanList.size() > 100) {
throw new BusinessException("一次最多上送100条数据"); throw new BusinessException("一次最多上送100条数据");
} }
SendParam param = new SendParam();
param.setStats(supvPlanList);
//TODO 调用国网接口 param.setProvinceId("13B9B47F1E483324E05338297A0A0595");
// Map map = postStatsUrl(getUrl(1), null, supvPlanList); String s = JSON.toJSONString(param);
JSONArray objects = new JSONArray(Collections.singletonList(supvPlanList)); log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督工作计划数据接口数据:" + s + "结束----");
String s = objects.toString(); // Map<String, String> send = send(param, getUrl(1), "pqPlanCreate");
log.info(Thread.currentThread().getName() + "获取返回体 推送技术监督工作计划:" + s + "结束----"); // log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督工作计划数据接口响应结果:" + send + "结束----");
// for(SupvPlan supvPlan: supvPlanList){ // if (send.containsKey("succeed")) {
// SupvPlan supvPlanPO = new SupvPlan(); // String succeed = send.get("succeed");
// supvPlanPO.setPlanId(supvPlan.getPlanId()); // String replace = succeed.replace("\\\"", "\"");
// supvPlanPO.setIsUploadHead(1); // Map mapData = JSON.parseObject(replace, Map.class);
// supvPlanMapper.updateById(supvPlanPO); // String status = mapData.get("status").toString();
// if ("000000".equals(status)) {
// for (SupvPlan supvPlan : supvPlanList) {
// SupvPlan supvPlanPO = new SupvPlan();
// supvPlanPO.setPlanId(supvPlan.getPlanId());
// supvPlanPO.setIsUploadHead(1);
// supvPlanMapper.updateById(supvPlanPO);
// }
// } else {
// return false;
// }
// } else {
// return false;
// } // }
return true; return true;
} }
@Override @Override
public boolean pushQuestion(List<String> problemIds) { public boolean pushQuestion(List<String> problemIds) {
LambdaQueryWrapper<SupvProblem> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SupvProblem> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(SupvProblem::getProblemId,problemIds); lambdaQueryWrapper.in(SupvProblem::getProblemId, problemIds);
List<SupvProblem> supvProblemList = supvProblemMapper.selectList(lambdaQueryWrapper); List<SupvProblem> supvProblemList = supvProblemMapper.selectList(lambdaQueryWrapper);
List<DictData> monitorTypeList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.MONITOR_TYPE.getCode()).getData(); List<DictData> monitorTypeList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.MONITOR_TYPE.getCode()).getData();
Map<String, DictData> mapMonitorType = monitorTypeList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); Map<String, DictData> mapMonitorType = monitorTypeList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
List<DictData> problemTypeList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_PROBLEM_TYPE.getCode()).getData(); List<DictData> problemTypeList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_PROBLEM_TYPE.getCode()).getData();
Map<String, DictData> mapProblemType = problemTypeList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); Map<String, DictData> mapProblemType = problemTypeList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
List<DictData> reList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.RECTIFICATION_MEASURE.getCode()).getData(); List<DictData> reList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.RECTIFICATION_MEASURE.getCode()).getData();
Map<String, DictData> mapRe = reList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); Map<String, DictData> mapRe = reList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
for(SupvProblem supvProblem : supvProblemList){ for (SupvProblem supvProblem : supvProblemList) {
Dept dept = deptFeignClient.getDeptByCode(supvProblem.getDutyOrgId()).getData(); Dept dept = deptFeignClient.getDeptByCode(supvProblem.getDutyOrgId()).getData();
supvProblem.setDutyOrgName(dept.getName()); supvProblem.setDutyOrgName(dept.getName());
if(mapMonitorType.containsKey(supvProblem.getMonitorType())){ if (mapMonitorType.containsKey(supvProblem.getMonitorType())) {
supvProblem.setMonitorType(String.format("%02d",mapMonitorType.get(supvProblem.getMonitorType()).getAlgoDescribe())); supvProblem.setMonitorType(String.format("%02d", mapMonitorType.get(supvProblem.getMonitorType()).getAlgoDescribe()));
} }
if(mapProblemType.containsKey(supvProblem.getProblemType())){ if (mapProblemType.containsKey(supvProblem.getProblemType())) {
supvProblem.setProblemType(String.format("%02d",mapProblemType.get(supvProblem.getProblemType()).getAlgoDescribe())); supvProblem.setProblemType(String.format("%02d", mapProblemType.get(supvProblem.getProblemType()).getAlgoDescribe()));
} }
if(mapRe.containsKey(supvProblem.getRectificationMeasure())){ if (mapRe.containsKey(supvProblem.getRectificationMeasure())) {
supvProblem.setRectificationMeasure(String.format("%02d",mapRe.get(supvProblem.getRectificationMeasure()).getAlgoDescribe())); supvProblem.setRectificationMeasure(String.format("%02d", mapRe.get(supvProblem.getRectificationMeasure()).getAlgoDescribe()));
} }
supvProblem.setProvinceId("13B9B47F1E483324E05338297A0A0595");
} }
if(supvProblemList.size()>100){ if (supvProblemList.size() > 100) {
throw new BusinessException("一次最多上送100条数据"); throw new BusinessException("一次最多上送100条数据");
} }
//TODO //TODO
// 目前一个问题对应一个措施,上送一个问题需要调用问题接口和整改措施接口 // 目前一个问题对应一个措施,上送一个问题需要调用问题接口和整改措施接口
// Map map = postStatsUrl(getUrl(2), null, supvProblemList); SendParam param = new SendParam();
// Map map = postStatsUrl(getUrl(3), null, supvProblemList); param.setStats(supvProblemList);
JSONArray objects = new JSONArray(Collections.singletonList(supvProblemList)); param.setProvinceId("13B9B47F1E483324E05338297A0A0595");
String s = objects.toString(); String s = JSON.toJSONString(param);
log.info(Thread.currentThread().getName() + "获取返回体 推送技术监督实施问题" + s + "结束----"); log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口数据" + s + "结束----");
// for(SupvProblem supvProblem:supvProblemList){ // Map<String, String> send = send(param, getUrl(2), "pqProblemCreate");
// SupvProblem supvProblemPO = new SupvProblem(); // Map<String, String> send2 = send(param, getUrl(3), "pqProblemUpdate");
// supvProblemPO.setProblemId(supvProblem.getProblemId()); // log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督实施问题数据接口响应结果:" + send + "结束----");
// supvProblemPO.setIsUploadHead(1); // log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督实施问题整改数据接口响应结果:" + send2 + "结束----");
// supvProblemMapper.updateById(supvProblemPO); // if (send.containsKey("succeed")) {
// String succeed = send.get("succeed");
// String replace = succeed.replace("\\\"", "\"");
// Map map = JSON.parseObject(replace, Map.class);
// String status = map.get("status").toString();
// if ("000000".equals(status)) {
// for (SupvProblem supvProblem : supvProblemList) {
// SupvProblem supvProblemPO = new SupvProblem();
// supvProblemPO.setProblemId(supvProblem.getProblemId());
// supvProblemPO.setIsUploadHead(1);
// supvProblemMapper.updateById(supvProblemPO);
// }
// } else {
// return false;
// }
// } else {
// return false;
// } // }
return true; return true;
} }
@@ -272,9 +300,9 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
@Override @Override
public boolean pushFile(List<String> busIds) throws IOException { public boolean pushFile(List<String> busIds) throws IOException {
LambdaQueryWrapper<SupvFile> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SupvFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(SupvFile::getBusiId,busIds); lambdaQueryWrapper.in(SupvFile::getBusiId, busIds);
List<SupvFile> supvFiles = supvFileMapper.selectList(lambdaQueryWrapper); List<SupvFile> supvFiles = supvFileMapper.selectList(lambdaQueryWrapper);
if(supvFiles.size()>100){ if (supvFiles.size() > 100) {
throw new BusinessException("一次最多上送100条数据"); throw new BusinessException("一次最多上送100条数据");
} }
JSONArray objects = new JSONArray(Collections.singletonList(supvFiles)); JSONArray objects = new JSONArray(Collections.singletonList(supvFiles));
@@ -290,24 +318,39 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
@Override @Override
public boolean pushMonthReportStatistic(List<String> monthReportId) { public boolean pushMonthReportStatistic(List<String> monthReportId) {
LambdaQueryWrapper<SupvReportM> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SupvReportM> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(SupvReportM::getMonthReportId,monthReportId); lambdaQueryWrapper.in(SupvReportM::getMonthReportId, monthReportId);
List<SupvReportM> supvReportMList = supvReportMMapper.selectList(lambdaQueryWrapper); List<SupvReportM> supvReportMList = supvReportMMapper.selectList(lambdaQueryWrapper);
if(supvReportMList.size()>100){ if (supvReportMList.size() > 100) {
throw new BusinessException("一次最多上送100条数据"); throw new BusinessException("一次最多上送100条数据");
} }
//TODO 调用上送接口 //TODO 调用上送接口
// Map map = postStatsUrl(getUrl(5), null, supvReportMList); SendParam param = new SendParam();
JSONArray objects = new JSONArray(Collections.singletonList(supvReportMList)); param.setStats(supvReportMList);
String s = objects.toString(); param.setProvinceId("13B9B47F1E483324E05338297A0A0595");
log.info(Thread.currentThread().getName() + "获取返回体 推送技术监督月报统计数据接口:" + s + "结束----"); String s = JSON.toJSONString(param);
// for(SupvReportM supvReportM : supvReportMList){ log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口数据:" + s + "结束----");
// SupvReportM supvReportMPO = new SupvReportM(); // Map<String, String> send = send(param, getUrl(5), "pqMonthReportCreate");
// supvReportMPO.setMonthReportId(supvReportM.getMonthReportId()); // log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口响应结果:" + s + "结束----");
// supvReportMPO.setIsUploadHead(1); // if (send.containsKey("succeed")) {
// supvReportMMapper.updateById(supvReportMPO); // String succeed = send.get("succeed");
// String replace = succeed.replace("\\\"", "\"");
// Map map = JSON.parseObject(replace, Map.class);
// String status = map.get("status").toString();
// if ("000000".equals(status)) {
// for (SupvReportM supvReportM : supvReportMList) {
// SupvReportM supvReportMPO = new SupvReportM();
// supvReportMPO.setMonthReportId(supvReportM.getMonthReportId());
// supvReportMPO.setIsUploadHead(1);
// supvReportMMapper.updateById(supvReportMPO);
// }
// } else {
// return false;
// }
//
// } else {
// return false;
// } // }
return true; return true;
} }
@@ -315,85 +358,137 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
public boolean deletePlan(List<String> planIds) { public boolean deletePlan(List<String> planIds) {
//判断是否已经取消上送 //判断是否已经取消上送
LambdaQueryWrapper<SupvPlan> supvPlanLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SupvPlan> supvPlanLambdaQueryWrapper = new LambdaQueryWrapper<>();
supvPlanLambdaQueryWrapper.in(SupvPlan::getIsUploadHead, Stream.of(0,2).collect(Collectors.toList())).in(SupvPlan::getPlanId,planIds); supvPlanLambdaQueryWrapper.in(SupvPlan::getIsUploadHead, Stream.of(0, 2).collect(Collectors.toList())).in(SupvPlan::getPlanId, planIds);
int count = supvPlanMapper.selectCount(supvPlanLambdaQueryWrapper); int count = supvPlanMapper.selectCount(supvPlanLambdaQueryWrapper);
if(count>0){ if (count > 0) {
throw new BusinessException("请选择已上送计划"); throw new BusinessException("请选择已上送计划");
} }
List<SupvPlan> supvPlanList = new ArrayList<>(); List<SupvPlan> supvPlanList = new ArrayList<>();
for(String id : planIds) { for (String id : planIds) {
SupvPlan supvPlan = new SupvPlan(); SupvPlan supvPlan = new SupvPlan();
supvPlan.setPlanId(id); supvPlan.setPlanId(id);
supvPlan.setProvinceId("13B9B47F1E483324E05338297A0A0595");
supvPlanList.add(supvPlan); supvPlanList.add(supvPlan);
} }
//TODO //TODO
// Map map = postStatsUrl(getUrl(6), null, supvPlanList); SendParam param = new SendParam();
JSONArray objects = new JSONArray(Collections.singletonList(supvPlanList)); param.setStats(supvPlanList);
String s = objects.toString(); param.setProvinceId("13B9B47F1E483324E05338297A0A0595");
log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口:" + s + "结束----"); String s = JSON.toJSONString(param);
// for(SupvPlan supvPlan : supvPlanList) { log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口数据:" + s + "结束----");
// supvPlan.setIsUploadHead(2); // Map<String, String> send = send(param, getUrl(6), "pqPlanDelete");
// supvPlanMapper.updateById(supvPlan); // log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口响应结果:" + s + "结束----");
// if (send.containsKey("succeed")) {
// String succeed = send.get("succeed");
// String replace = succeed.replace("\\\"", "\"");
// Map map = JSON.parseObject(replace, Map.class);
// String status = map.get("status").toString();
// if ("000000".equals(status)) {
// for (SupvPlan supvPlan : supvPlanList) {
// supvPlan.setIsUploadHead(2);
// supvPlanMapper.updateById(supvPlan);
// }
// } else {
// return false;
// }
// } else {
// return false;
// } // }
return true; return true;
} }
/** public static Map<String, String> send(SendParam param, String url, String serviceName) {
* 通用上送提交 Map<String, String> map = new LinkedHashMap<>();
* @param url ContentBody cb;
* @param token if (ObjectUtil.isNull(param)) {
* @param list cb = new ContentBody("");
* @return } else {
*/ String s = JSON.toJSONString(param);
public Map postStatsUrl(String url,String token,List<?> list){ log.info(Thread.currentThread().getName() + "1.信息:" + JSON.toJSONString(param));
Map body = new HashMap(); log.info(Thread.currentThread().getName() + "2.信息:" + s);
Map<String, String> mapHeader = new HashMap<>(); cb = new ContentBody(s);
mapHeader.put("Content-Type", "application/json; charset=utf-8");
mapHeader.put("x-token", token);
mapHeader.put("x-date", System.currentTimeMillis() + "");
mapHeader.put("x-signature", "123");
//设置入参
Map<String, Object> mapBody = new HashMap<>();
mapBody.put("stats", list);
ResponseEntity<Map> userEntity = RestTemplateUtil.post(url, mapHeader, mapBody, Map.class, new ArrayList<>());
if (userEntity.getStatusCodeValue() == 200) {
//获取返回体
body = userEntity.getBody();
log.info(Thread.currentThread().getName() + "获取返回体 getResourceData" + body + "结束----");
} }
return body; //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();
log.info(Thread.currentThread().getName() + "3.错误信息:" + token);
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());
}
return map;
}
public static String LoginToken() {
String token = null;
String clientId = "942a9278671711eda2e10ae0b5517f6c";
String clientSecret = "3Psd2VEhsA3dVsSPHW0ll5r/03kAqlA2P4w2IiWPA8UWSadcX0we2wffjyTUYGsK";
String userUrl = "http://25.36.214.86:32234/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();
}
return token;
} }
/** /**
* 文件上送提交 * 文件上送提交
*
* @param url * @param url
* @param token * @param token
* @return * @return
*/ */
public Map postFileUrl(String url,String token,SupvFile supvFile) throws IOException { public Map postFileUrl(String url, String token, SupvFile supvFile) throws IOException {
Map body = new HashMap(); Map body = new HashMap();
Map<String, String> mapHeader = new HashMap<>(); Map<String, String> mapHeader = new HashMap<>();
mapHeader.put("Content-Type", "multipart/form-data"); mapHeader.put("Content-Type", "multipart/form-data");
String path=supvFile.getFileUrl(); String path = supvFile.getFileUrl();
if(StrUtil.isBlank(path)){ if (StrUtil.isBlank(path)) {
throw new BusinessException("获取文件上传路径为空!请检查原始路径是否存在"); throw new BusinessException("获取文件上传路径为空!请检查原始路径是否存在");
} }
String suffix = path.substring(path.lastIndexOf(".")); String suffix = path.substring(path.lastIndexOf("."));
String attachmentName = supvFile.getAttachmentName(); String attachmentName = supvFile.getAttachmentName();
if(StrUtil.isNotBlank(attachmentName)){ if (StrUtil.isNotBlank(attachmentName)) {
int i = attachmentName.lastIndexOf("."); int i = attachmentName.lastIndexOf(".");
if(i!=-1){ if (i != -1) {
attachmentName = attachmentName.substring(0,i); attachmentName = attachmentName.substring(0, i);
} }
}else{ } else {
throw new BusinessException("不存在文件,文件名称"); throw new BusinessException("不存在文件,文件名称");
} }
InputStream fileStream = fileStorageUtil.getFileStream(path); InputStream fileStream = fileStorageUtil.getFileStream(path);
if(ObjectUtil.isNull(fileStream)){ if (ObjectUtil.isNull(fileStream)) {
throw new BusinessException("文件服务器,文件不存在"); throw new BusinessException("文件服务器,文件不存在");
} }
byte[] fileBytes = IOUtils.toByteArray(fileStream); byte[] fileBytes = IOUtils.toByteArray(fileStream);
@@ -427,48 +522,49 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
/** /**
* 根据type获取上送地址 * 根据type获取上送地址
*
* @param type * @param type
* @return * @return
*/ */
public static String getUrl(Integer type){ public static String getUrl(Integer type) {
String url="http://25.36.214.86:32234/CSB"; String url = "http://25.36.214.86:32234/CSB";
switch (type){ switch (type) {
case 1: case 1:
/** /**
* 接收电能质量技术监督工作计划数据接口 * 接收电能质量技术监督工作计划数据接口
*/ */
url+="/WMCenter/powerQuality/plan/create"; url += "/WMCenter/powerQuality/plan/create";
break; break;
case 2: case 2:
/** /**
* 接收电能质量技术监督实施问题数据接口 * 接收电能质量技术监督实施问题数据接口
*/ */
url+="/WMCenter/powerQuality/problem/create"; url += "/WMCenter/powerQuality/problem/create";
break; break;
case 3: case 3:
/** /**
* 接收电能质量技术监督实施问题整改数据接口 * 接收电能质量技术监督实施问题整改数据接口
*/ */
url+="/WMCenter/powerQuality/problem/update"; url += "/WMCenter/powerQuality/problem/update";
break; break;
case 4: case 4:
/** /**
* 总部提供附件接收接口,省公司调用此接口,完成附件上报 * 总部提供附件接收接口,省公司调用此接口,完成附件上报
*/ */
url+="/WMCenter/powerQuality/file/create"; url += "/WMCenter/powerQuality/file/create";
break; break;
case 5: case 5:
/** /**
* 接收电能质量技术监督月报统计数据接口 * 接收电能质量技术监督月报统计数据接口
*/ */
url+="/WMCenter/powerQuality/monthReport/create"; url += "/WMCenter/powerQuality/monthReport/create";
break; break;
case 6: case 6:
/** /**
* 删除电能质量技术监督工作计划接口 * 删除电能质量技术监督工作计划接口
*/ */
url+="/WMCenter/powerQuality/plan/delete"; url += "/WMCenter/powerQuality/plan/delete";
break; break;
} }
return url; return url;

View File

@@ -208,7 +208,7 @@ public class SupvReportMServiceImpl extends MppServiceImpl<SupvReportMMapper, Su
//电压 //电压
supvReportM.setPowerMonthPlanNum(dealData(childrenDeptList,processPublicDTODianYaListM)); supvReportM.setPowerMonthPlanNum(dealData(childrenDeptList,processPublicDTODianYaListM));
Integer d = dealData(childrenDeptList,processPublicDTODianYaListAll); Integer d = dealData(childrenDeptList,processPublicDTODianYaListAll);
supvReportM.setPowerTotalConductedNum(d); supvReportM.setPowerMonthConductedNum(d);
all+=d; all+=d;
} }