From 3e0157e88908b9063342757533b2a5fc832a0a80 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Fri, 28 Jul 2023 17:31:46 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=8A=80=E6=9C=AF?= =?UTF-8?q?=E7=9B=91=E7=9D=A3=E9=83=A8=E5=88=86=E7=BC=BA=E5=B0=91=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=A1=E6=81=AF=202.=E4=BF=AE=E6=94=B9=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=B1=9E=E6=80=A7=E5=AF=B9=E5=BA=94=E7=9A=84=E5=80=BC?= =?UTF-8?q?powerTotalConductedNum=E6=94=B9=E4=B8=BApowerMonthConductedNum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../njcn/process/pojo/param/SendParam.java | 17 + .../com/njcn/process/pojo/po/SupvFile.java | 5 + .../com/njcn/process/pojo/po/SupvPlan.java | 29 +- .../com/njcn/process/pojo/po/SupvProblem.java | 12 +- .../com/njcn/process/pojo/po/SupvReportM.java | 20 +- pqs-process/process-boot/pom.xml | 7 + .../service/impl/SupvPushGwServiceImpl.java | 352 +++++++++++------- .../service/impl/SupvReportMServiceImpl.java | 2 +- 8 files changed, 306 insertions(+), 138 deletions(-) create mode 100644 pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/SendParam.java diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/SendParam.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/SendParam.java new file mode 100644 index 000000000..e3bb3bc4c --- /dev/null +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/SendParam.java @@ -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; +} diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvFile.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvFile.java index 82c7c61a6..7aec0c632 100644 --- a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvFile.java +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvFile.java @@ -25,6 +25,11 @@ public class SupvFile { @TableId private String uuid; + /** + * 所属网省id + */ + @TableField(exist = false) + private String provinceId; /** * 附件路径 diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvPlan.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvPlan.java index eb4f1b342..0f2801430 100644 --- a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvPlan.java +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvPlan.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import com.njcn.db.bo.BaseEntity; + import java.io.Serializable; import java.time.LocalDate; 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; - /** * 报告出具时间 */ @@ -200,15 +200,30 @@ public class SupvPlan extends BaseEntity { private LocalDateTime problemOcTime; - - - /** * 0.未上送 1.上送 2.取消上送 */ private Integer isUploadHead; - - + /** + * 删除标识 0否1是 + */ + private String deleteFlag; + /** + * 计划状态 1新建2变更 3取消 + */ + private String planStatus; + /** + * 删除时间 + */ + private LocalDateTime deleteTime; + /** + * 实施人id + */ + private String effectUserId; + /** + * 实施人姓名 + */ + private String effectUserName; } diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvProblem.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvProblem.java index 2e73734d8..8ca710b65 100644 --- a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvProblem.java +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvProblem.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import com.njcn.db.bo.BaseEntity; import java.io.Serializable; import java.time.LocalDate; @@ -35,6 +36,13 @@ public class SupvProblem extends BaseEntity { @TableId 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) private LocalDate rectificationTime; @@ -145,6 +154,7 @@ public class SupvProblem extends BaseEntity { @ApiModelProperty(name = "attachmentNameTwo",value = "佐证材料") private String attachmentNameTwo; - + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime discoveryTime; } diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvReportM.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvReportM.java index b423166e3..7b0ee9fa7 100644 --- a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvReportM.java +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvReportM.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.github.jeffreyning.mybatisplus.anno.MppMultiId; import com.njcn.db.bo.BaseEntity; + import java.io.Serializable; 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; diff --git a/pqs-process/process-boot/pom.xml b/pqs-process/process-boot/pom.xml index a8be926fb..c4aebed81 100644 --- a/pqs-process/process-boot/pom.xml +++ b/pqs-process/process-boot/pom.xml @@ -106,6 +106,13 @@ + + + + com.alibaba.csb.sdk + http-client + 1.1.5.11 + diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java index aa83f1aa1..30b755c79 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java @@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.csb.sdk.*; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.SupvProblemMapper; 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.SupvPlan; import com.njcn.process.pojo.po.SupvProblem; import com.njcn.process.pojo.po.SupvReportM; -import com.njcn.process.pojo.vo.SupvPlanVO; import com.njcn.process.service.SupvPushGwService; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.enums.DicDataTypeEnum; @@ -76,65 +78,65 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { @Override public boolean pushPlan(List planIds) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(SupvPlan::getPlanId,planIds); + lambdaQueryWrapper.in(SupvPlan::getPlanId, planIds); List supvPlanList = supvPlanMapper.selectList(lambdaQueryWrapper); - if(CollUtil.isEmpty(supvPlanList)){ + if (CollUtil.isEmpty(supvPlanList)) { return false; } List deptList = deptFeignClient.allDeptList().getData(); - Map mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity())); - Map mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity())); + Map mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity())); + Map mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity())); List supvDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_TYPE.getCode()).getData(); - Map mapType = supvDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); + Map mapType = supvDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); List supvStateDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_STAGE.getCode()).getData(); - Map mapSupvState = supvStateDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); + Map mapSupvState = supvStateDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); List supveffectDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EFFECT_STATUS.getCode()).getData(); - Map mapSupvEffect = supveffectDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); + Map mapSupvEffect = supveffectDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); List supvObjTypeDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_OBJ_TYPE.getCode()).getData(); - Map mapSubvObjType = supvObjTypeDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); + Map mapSubvObjType = supvObjTypeDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); List supvVoltageDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData(); - Map mapVoltage = supvVoltageDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); + Map mapVoltage = supvVoltageDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); List userIds = supvPlanList.stream().map(SupvPlan::getUpdateBy).distinct().collect(Collectors.toList()); List userList = userFeignClient.getUserByIdList(userIds).getData(); Map map = userList.stream().collect(Collectors.toMap(User::getId, Function.identity())); - for(SupvPlan supvPlan:supvPlanList){ + for (SupvPlan supvPlan : supvPlanList) { PvTerminalTreeVO pvTerminalTreeVO = null; - if(mapCode.containsKey(supvPlan.getSupvOrgId())) { + if (mapCode.containsKey(supvPlan.getSupvOrgId())) { pvTerminalTreeVO = mapCode.get(supvPlan.getSupvOrgId()); supvPlan.setSupvOrgName(pvTerminalTreeVO.getName()); int deptLevel = pvTerminalTreeVO.getPids().split(StrUtil.COMMA).length; - if(deptLevel == 2){ + if (deptLevel == 2) { //省 supvPlan.setProvinceName(pvTerminalTreeVO.getName()); supvPlan.setProvinceId(pvTerminalTreeVO.getCode()); - }else if(deptLevel == 3){ + } else if (deptLevel == 3) { //市 supvPlan.setCityName(pvTerminalTreeVO.getName()); supvPlan.setCityId(pvTerminalTreeVO.getCode()); - if(mapList.containsKey(pvTerminalTreeVO.getPid())) { + if (mapList.containsKey(pvTerminalTreeVO.getPid())) { PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid()); supvPlan.setProvinceName(pvTerminalTreeOne.getName()); 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.setCountyId(pvTerminalTreeVO.getCode()); PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid()); if (Objects.nonNull(pvTerminalTreeOne)) { supvPlan.setCityName(pvTerminalTreeOne.getName()); supvPlan.setCityId(pvTerminalTreeOne.getCode()); - if(mapList.containsKey(pvTerminalTreeOne.getPid())) { + if (mapList.containsKey(pvTerminalTreeOne.getPid())) { PvTerminalTreeVO pvTerminalTreeTwo = mapList.get(pvTerminalTreeOne.getPid()); if (Objects.nonNull(pvTerminalTreeTwo)) { 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())); } //监督类型编码 - if(mapSupvState.containsKey(supvPlan.getSupvStage())) { + if (mapSupvState.containsKey(supvPlan.getSupvStage())) { 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())); } //监督对象类型 - if(mapSubvObjType.containsKey(supvPlan.getSupvObjType())) { + if (mapSubvObjType.containsKey(supvPlan.getSupvObjType())) { 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.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()); supvPlan.setObjVoltageLevel(String.format("%02d", dictData.getAlgoDescribe())); supvPlan.setObjVoltageLevelName(dictData.getName()); @@ -185,86 +187,112 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { supvPlan.setPlanUserName(map.get(supvPlan.getPlanUserId()).getName()); } //添加计划单位名称 - if(mapCode.containsKey(supvPlan.getPlanOrgId())){ + if (mapCode.containsKey(supvPlan.getPlanOrgId())) { pvTerminalTreeVO = mapCode.get(supvPlan.getPlanOrgId()); supvPlan.setPlanOrgName(pvTerminalTreeVO.getName()); } supvPlan.setSupvObjId(IdUtil.simpleUUID()); } - if(supvPlanList.size()>100){ + if (supvPlanList.size() > 100) { throw new BusinessException("一次最多上送100条数据"); } - - - //TODO 调用国网接口 -// Map map = postStatsUrl(getUrl(1), null, supvPlanList); - JSONArray objects = new JSONArray(Collections.singletonList(supvPlanList)); - String s = objects.toString(); - log.info(Thread.currentThread().getName() + "获取返回体 推送技术监督工作计划:" + s + "结束----!"); -// for(SupvPlan supvPlan: supvPlanList){ -// SupvPlan supvPlanPO = new SupvPlan(); -// supvPlanPO.setPlanId(supvPlan.getPlanId()); -// supvPlanPO.setIsUploadHead(1); -// supvPlanMapper.updateById(supvPlanPO); + SendParam param = new SendParam(); + param.setStats(supvPlanList); + param.setProvinceId("13B9B47F1E483324E05338297A0A0595"); + String s = JSON.toJSONString(param); + log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督工作计划数据接口数据:" + s + "结束----!"); +// Map send = send(param, getUrl(1), "pqPlanCreate"); +// log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督工作计划数据接口响应结果:" + send + "结束----!"); +// if (send.containsKey("succeed")) { +// String succeed = send.get("succeed"); +// String replace = succeed.replace("\\\"", "\""); +// Map mapData = JSON.parseObject(replace, Map.class); +// 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; } @Override public boolean pushQuestion(List problemIds) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(SupvProblem::getProblemId,problemIds); + lambdaQueryWrapper.in(SupvProblem::getProblemId, problemIds); List supvProblemList = supvProblemMapper.selectList(lambdaQueryWrapper); List monitorTypeList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.MONITOR_TYPE.getCode()).getData(); - Map mapMonitorType = monitorTypeList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); + Map mapMonitorType = monitorTypeList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); List problemTypeList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_PROBLEM_TYPE.getCode()).getData(); - Map mapProblemType = problemTypeList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); + Map mapProblemType = problemTypeList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); List reList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.RECTIFICATION_MEASURE.getCode()).getData(); - Map mapRe = reList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); + Map 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(); supvProblem.setDutyOrgName(dept.getName()); - if(mapMonitorType.containsKey(supvProblem.getMonitorType())){ - supvProblem.setMonitorType(String.format("%02d",mapMonitorType.get(supvProblem.getMonitorType()).getAlgoDescribe())); + if (mapMonitorType.containsKey(supvProblem.getMonitorType())) { + supvProblem.setMonitorType(String.format("%02d", mapMonitorType.get(supvProblem.getMonitorType()).getAlgoDescribe())); } - if(mapProblemType.containsKey(supvProblem.getProblemType())){ - supvProblem.setProblemType(String.format("%02d",mapProblemType.get(supvProblem.getProblemType()).getAlgoDescribe())); + if (mapProblemType.containsKey(supvProblem.getProblemType())) { + supvProblem.setProblemType(String.format("%02d", mapProblemType.get(supvProblem.getProblemType()).getAlgoDescribe())); } - if(mapRe.containsKey(supvProblem.getRectificationMeasure())){ - supvProblem.setRectificationMeasure(String.format("%02d",mapRe.get(supvProblem.getRectificationMeasure()).getAlgoDescribe())); + if (mapRe.containsKey(supvProblem.getRectificationMeasure())) { + 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条数据"); } //TODO // 目前一个问题对应一个措施,上送一个问题需要调用问题接口和整改措施接口 -// Map map = postStatsUrl(getUrl(2), null, supvProblemList); -// Map map = postStatsUrl(getUrl(3), null, supvProblemList); - JSONArray objects = new JSONArray(Collections.singletonList(supvProblemList)); - String s = objects.toString(); - log.info(Thread.currentThread().getName() + "获取返回体 推送技术监督实施问题:" + s + "结束----!"); -// for(SupvProblem supvProblem:supvProblemList){ -// SupvProblem supvProblemPO = new SupvProblem(); -// supvProblemPO.setProblemId(supvProblem.getProblemId()); -// supvProblemPO.setIsUploadHead(1); -// supvProblemMapper.updateById(supvProblemPO); + SendParam param = new SendParam(); + param.setStats(supvProblemList); + param.setProvinceId("13B9B47F1E483324E05338297A0A0595"); + String s = JSON.toJSONString(param); + log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口数据:" + s + "结束----!"); +// Map send = send(param, getUrl(2), "pqProblemCreate"); +// Map send2 = send(param, getUrl(3), "pqProblemUpdate"); +// log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督实施问题数据接口响应结果:" + send + "结束----!"); +// log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督实施问题整改数据接口响应结果:" + send2 + "结束----!"); +// 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; } @@ -272,9 +300,9 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { @Override public boolean pushFile(List busIds) throws IOException { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(SupvFile::getBusiId,busIds); + lambdaQueryWrapper.in(SupvFile::getBusiId, busIds); List supvFiles = supvFileMapper.selectList(lambdaQueryWrapper); - if(supvFiles.size()>100){ + if (supvFiles.size() > 100) { throw new BusinessException("一次最多上送100条数据"); } JSONArray objects = new JSONArray(Collections.singletonList(supvFiles)); @@ -290,24 +318,39 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { @Override public boolean pushMonthReportStatistic(List monthReportId) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(SupvReportM::getMonthReportId,monthReportId); + lambdaQueryWrapper.in(SupvReportM::getMonthReportId, monthReportId); List supvReportMList = supvReportMMapper.selectList(lambdaQueryWrapper); - if(supvReportMList.size()>100){ + if (supvReportMList.size() > 100) { throw new BusinessException("一次最多上送100条数据"); } //TODO 调用上送接口 -// Map map = postStatsUrl(getUrl(5), null, supvReportMList); - JSONArray objects = new JSONArray(Collections.singletonList(supvReportMList)); - String s = objects.toString(); - log.info(Thread.currentThread().getName() + "获取返回体 推送技术监督月报统计数据接口:" + s + "结束----!"); -// for(SupvReportM supvReportM : supvReportMList){ -// SupvReportM supvReportMPO = new SupvReportM(); -// supvReportMPO.setMonthReportId(supvReportM.getMonthReportId()); -// supvReportMPO.setIsUploadHead(1); -// supvReportMMapper.updateById(supvReportMPO); + SendParam param = new SendParam(); + param.setStats(supvReportMList); + param.setProvinceId("13B9B47F1E483324E05338297A0A0595"); + String s = JSON.toJSONString(param); + log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口数据:" + s + "结束----!"); +// Map send = send(param, getUrl(5), "pqMonthReportCreate"); +// 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 (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; } @@ -315,85 +358,137 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { public boolean deletePlan(List planIds) { //判断是否已经取消上送 LambdaQueryWrapper 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); - if(count>0){ + if (count > 0) { throw new BusinessException("请选择已上送计划"); } List supvPlanList = new ArrayList<>(); - for(String id : planIds) { + for (String id : planIds) { SupvPlan supvPlan = new SupvPlan(); supvPlan.setPlanId(id); + supvPlan.setProvinceId("13B9B47F1E483324E05338297A0A0595"); supvPlanList.add(supvPlan); } //TODO -// Map map = postStatsUrl(getUrl(6), null, supvPlanList); - JSONArray objects = new JSONArray(Collections.singletonList(supvPlanList)); - String s = objects.toString(); - log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口:" + s + "结束----!"); -// for(SupvPlan supvPlan : supvPlanList) { -// supvPlan.setIsUploadHead(2); -// supvPlanMapper.updateById(supvPlan); + SendParam param = new SendParam(); + param.setStats(supvPlanList); + param.setProvinceId("13B9B47F1E483324E05338297A0A0595"); + String s = JSON.toJSONString(param); + log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口数据:" + s + "结束----!"); +// Map send = send(param, getUrl(6), "pqPlanDelete"); +// 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; } - /** - * 通用上送提交 - * @param url - * @param token - * @param list - * @return - */ - public Map postStatsUrl(String url,String token,List list){ - Map body = new HashMap(); - Map mapHeader = new HashMap<>(); - 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 mapBody = new HashMap<>(); - mapBody.put("stats", list); - - ResponseEntity userEntity = RestTemplateUtil.post(url, mapHeader, mapBody, Map.class, new ArrayList<>()); - if (userEntity.getStatusCodeValue() == 200) { - //获取返回体 - body = userEntity.getBody(); - log.info(Thread.currentThread().getName() + "获取返回体 getResourceData:" + body + "结束----!"); + public static Map send(SendParam param, String url, String serviceName) { + Map map = new LinkedHashMap<>(); + ContentBody cb; + if (ObjectUtil.isNull(param)) { + cb = new ContentBody(""); + } else { + String s = JSON.toJSONString(param); + log.info(Thread.currentThread().getName() + "1.信息:" + JSON.toJSONString(param)); + log.info(Thread.currentThread().getName() + "2.信息:" + s); + cb = new ContentBody(s); } - 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 map = new HashMap<>(); + map.put("grant_type", "credentials"); + map.put("client_id", clientId); + map.put("client_secret", clientSecret); + ResponseEntity 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 token * @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 mapHeader = new HashMap<>(); mapHeader.put("Content-Type", "multipart/form-data"); - String path=supvFile.getFileUrl(); - if(StrUtil.isBlank(path)){ + String path = supvFile.getFileUrl(); + if (StrUtil.isBlank(path)) { throw new BusinessException("获取文件上传路径为空!请检查原始路径是否存在"); } String suffix = path.substring(path.lastIndexOf(".")); String attachmentName = supvFile.getAttachmentName(); - if(StrUtil.isNotBlank(attachmentName)){ + if (StrUtil.isNotBlank(attachmentName)) { int i = attachmentName.lastIndexOf("."); - if(i!=-1){ - attachmentName = attachmentName.substring(0,i); + if (i != -1) { + attachmentName = attachmentName.substring(0, i); } - }else{ + } else { throw new BusinessException("不存在文件,文件名称"); } InputStream fileStream = fileStorageUtil.getFileStream(path); - if(ObjectUtil.isNull(fileStream)){ + if (ObjectUtil.isNull(fileStream)) { throw new BusinessException("文件服务器,文件不存在"); } byte[] fileBytes = IOUtils.toByteArray(fileStream); @@ -427,48 +522,49 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { /** * 根据type获取上送地址 + * * @param type * @return */ - public static String getUrl(Integer type){ - String url="http://25.36.214.86:32234/CSB"; + public static String getUrl(Integer type) { + String url = "http://25.36.214.86:32234/CSB"; - switch (type){ + switch (type) { case 1: /** * 接收电能质量技术监督工作计划数据接口 */ - url+="/WMCenter/powerQuality/plan/create"; + url += "/WMCenter/powerQuality/plan/create"; break; case 2: /** * 接收电能质量技术监督实施问题数据接口 */ - url+="/WMCenter/powerQuality/problem/create"; + url += "/WMCenter/powerQuality/problem/create"; break; case 3: /** * 接收电能质量技术监督实施问题整改数据接口 */ - url+="/WMCenter/powerQuality/problem/update"; + url += "/WMCenter/powerQuality/problem/update"; break; case 4: /** * 总部提供附件接收接口,省公司调用此接口,完成附件上报 */ - url+="/WMCenter/powerQuality/file/create"; + url += "/WMCenter/powerQuality/file/create"; break; case 5: /** * 接收电能质量技术监督月报统计数据接口 */ - url+="/WMCenter/powerQuality/monthReport/create"; + url += "/WMCenter/powerQuality/monthReport/create"; break; case 6: /** * 删除电能质量技术监督工作计划接口 */ - url+="/WMCenter/powerQuality/plan/delete"; + url += "/WMCenter/powerQuality/plan/delete"; break; } return url; diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvReportMServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvReportMServiceImpl.java index d05133e64..95c087809 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvReportMServiceImpl.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvReportMServiceImpl.java @@ -208,7 +208,7 @@ public class SupvReportMServiceImpl extends MppServiceImpl