From 61216a0b376f4bf070f3ee34bf0a20f1c1784ba9 Mon Sep 17 00:00:00 2001 From: huangzj <826100833@qq.com> Date: Wed, 15 Mar 2023 18:46:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=90=E6=B3=A2=E6=99=AE=E6=B5=8B=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/response/CommonResponseEnum.java | 2 +- .../pojo/param/RGeneralSurveyPlanAddParm.java | 27 +- .../pojo/po/RGeneralSurveyPlanDetail.java | 4 +- .../process/pojo/po/RGeneralSurveyPlanPO.java | 6 + .../njcn/process/pojo/po/RSurveyCyclePO.java | 32 + .../process/pojo/po/RSurveyPlanConfigPO.java | 117 ++++ .../process/pojo/vo/DeptSubstationVO.java | 40 ++ .../process/pojo/vo/RGeneralSurveyPlanVO.java | 11 +- .../njcn/process/pojo/vo/RSurveyCycleVO.java | 27 + .../process/pojo/vo/RSurveyPlanConfigVO.java | 110 ++++ .../process/pojo/vo/StatationStatExcel.java | 73 +++ .../RGeneralSurveyPlanController.java | 107 +++- .../process/mapper/RSurveyCycleMapper.java | 16 + .../mapper/RSurveyPlanConfigMapper.java | 17 + .../process/mapper/StatationStatMapper.java | 43 ++ .../mapper/mapping/RSurveyCycleMapper.xml | 16 + .../mapping/RSurveyPlanConfigMapper.xml | 17 + .../service/RGeneralSurveyPlanPOService.java | 20 +- .../service/RSurveyCycleServiceImpl.java | 22 + .../service/RSurveyPlanConfigServiceImpl.java | 20 + .../process/service/StatationStatService.java | 15 + .../impl/RGeneralSurveyPlanPOServiceImpl.java | 574 +++++++++++++----- .../service/impl/RSurveyCycleService.java | 17 + .../impl/RSurveyPlanConfigService.java | 17 + .../impl/StatationStatServiceImpl.java | 20 + 25 files changed, 1192 insertions(+), 178 deletions(-) create mode 100644 pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RSurveyCyclePO.java create mode 100644 pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RSurveyPlanConfigPO.java create mode 100644 pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/DeptSubstationVO.java create mode 100644 pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RSurveyCycleVO.java create mode 100644 pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RSurveyPlanConfigVO.java create mode 100644 pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/StatationStatExcel.java create mode 100644 pqs-process/process-boot/src/main/java/com/njcn/process/mapper/RSurveyCycleMapper.java create mode 100644 pqs-process/process-boot/src/main/java/com/njcn/process/mapper/RSurveyPlanConfigMapper.java create mode 100644 pqs-process/process-boot/src/main/java/com/njcn/process/mapper/StatationStatMapper.java create mode 100644 pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/RSurveyCycleMapper.xml create mode 100644 pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/RSurveyPlanConfigMapper.xml create mode 100644 pqs-process/process-boot/src/main/java/com/njcn/process/service/RSurveyCycleServiceImpl.java create mode 100644 pqs-process/process-boot/src/main/java/com/njcn/process/service/RSurveyPlanConfigServiceImpl.java create mode 100644 pqs-process/process-boot/src/main/java/com/njcn/process/service/StatationStatService.java create mode 100644 pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RSurveyCycleService.java create mode 100644 pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RSurveyPlanConfigService.java create mode 100644 pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/StatationStatServiceImpl.java diff --git a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java index c76a2c16c..160e0804f 100644 --- a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java +++ b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java @@ -92,7 +92,7 @@ public enum CommonResponseEnum { TIME_ERROR("A0101","时间格式有误"), CLOSE_RESOURCE_ERROR("A0102","关闭资源有误"), - + MATH_ERROR("A0103","比例总和大于100%"), ; diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/RGeneralSurveyPlanAddParm.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/RGeneralSurveyPlanAddParm.java index 187c936b7..59c6c4ff6 100644 --- a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/RGeneralSurveyPlanAddParm.java +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/RGeneralSurveyPlanAddParm.java @@ -1,7 +1,6 @@ package com.njcn.process.pojo.param; import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -41,10 +40,10 @@ public class RGeneralSurveyPlanAddParm { @ApiModelProperty(value="详细情况") private String description; - @ApiModelProperty(value="计划详细情况母线相关") - private List rGeneralSurveyPlanDetailAddParm; - @Data - @ApiModel(value="计划详细情况母线相关") + @ApiModelProperty(value="选中的电站集合") + private List subIds; +/* @Data + @ApiModel(value="计划详细情况电站相关") public static class RGeneralSurveyPlanDetailAddParm{ @ApiModelProperty(value = "组织id") @@ -69,33 +68,33 @@ public class RGeneralSurveyPlanAddParm { @ApiModelProperty(value="离线监测点id") private String measurementPointId; - /** + *//** * 测试开始时间 - */ + *//* @ApiModelProperty(value="测试开始时间") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") private Date generalSurveyStartTime; - /** + *//** * 测试结束时间 - */ + *//* @ApiModelProperty(value="测试结束时间") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") private Date generalSurveyEndTime; - /** + *//** * 测试日期 - */ + *//* @ApiModelProperty(value="测试日期") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") private Date generalSurveyTime; - /** + *//** * 测试负责人 - */ + *//* @ApiModelProperty(value="测试负责人") private String generalSurveyLeader; - } + }*/ } diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RGeneralSurveyPlanDetail.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RGeneralSurveyPlanDetail.java index aa59b43ea..d9f1213fa 100644 --- a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RGeneralSurveyPlanDetail.java +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RGeneralSurveyPlanDetail.java @@ -37,7 +37,7 @@ public class RGeneralSurveyPlanDetail { * 母线ID */ - @MppMultiId(value = "busbar_id") + @TableField(value = "busbar_id") private String busbarId; /** @@ -67,7 +67,7 @@ public class RGeneralSurveyPlanDetail { /** * 变电站ID */ - @TableField(value = "sub_id") + @MppMultiId(value = "sub_id") private String subId; /** diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RGeneralSurveyPlanPO.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RGeneralSurveyPlanPO.java index 13362c3b4..67f5f441c 100644 --- a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RGeneralSurveyPlanPO.java +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RGeneralSurveyPlanPO.java @@ -35,6 +35,12 @@ public class RGeneralSurveyPlanPO { */ @MppMultiId(value = "plan_no") private String planNo; + /** + * 普测周期id + * + */ + @TableField(value = "cycle_id") + private String cycleId; /** * 普测计划名称 diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RSurveyCyclePO.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RSurveyCyclePO.java new file mode 100644 index 000000000..60315f4ed --- /dev/null +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RSurveyCyclePO.java @@ -0,0 +1,32 @@ +package com.njcn.process.pojo.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.time.LocalDate; + +/** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/13 9:23【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +@Data +@TableName(value = "r_survey_cycle") +public class RSurveyCyclePO { + @TableField(value = "id") + private String id; + + @TableField(value = "start_year") + private LocalDate startYear; + + @TableField(value = "end_year") + private LocalDate endYear; + + @TableField(value = "survey_cycle") + private Integer surveyCycle; +} \ No newline at end of file diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RSurveyPlanConfigPO.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RSurveyPlanConfigPO.java new file mode 100644 index 000000000..37489433a --- /dev/null +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/RSurveyPlanConfigPO.java @@ -0,0 +1,117 @@ +package com.njcn.process.pojo.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.github.jeffreyning.mybatisplus.anno.MppMultiId; + +/** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/9 10:13【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +@TableName(value = "r_survey_plan_config") +public class RSurveyPlanConfigPO { + + /** + * 组织机构名称 + */ + @TableField(value = "Org_Name") + private String orgName; + + /** + * 组织机构ID(外键) + */ + @MppMultiId(value = "Org_Id") + private String orgId; + + /** + * 普测电站总数 + */ + @TableField(value = "stat_num") + private Integer statNum; + + /** + * 该机构普测占比 + */ + @TableField(value = "proportion") + private Double proportion; + + + + /** + * 获取组织机构名称 + * + * @return Org_Name - 组织机构名称 + */ + public String getOrgName() { + return orgName; + } + + /** + * 设置组织机构名称 + * + * @param orgName 组织机构名称 + */ + public void setOrgName(String orgName) { + this.orgName = orgName; + } + + /** + * 获取组织机构ID(外键) + * + * @return Org_Id - 组织机构ID(外键) + */ + public String getOrgId() { + return orgId; + } + + /** + * 设置组织机构ID(外键) + * + * @param orgId 组织机构ID(外键) + */ + public void setOrgId(String orgId) { + this.orgId = orgId; + } + + /** + * 获取普测电站总数 + * + * @return stat_num - 普测电站总数 + */ + public Integer getStatNum() { + return statNum; + } + + /** + * 设置普测电站总数 + * + * @param statNum 普测电站总数 + */ + public void setStatNum(Integer statNum) { + this.statNum = statNum; + } + + /** + * 获取该机构普测占比 + * + * @return proportion - 该机构普测占比 + */ + public Double getProportion() { + return proportion; + } + + /** + * 设置该机构普测占比 + * + * @param proportion 该机构普测占比 + */ + public void setProportion(Double proportion) { + this.proportion = proportion; + } +} \ No newline at end of file diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/DeptSubstationVO.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/DeptSubstationVO.java new file mode 100644 index 000000000..8bb8f8afb --- /dev/null +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/DeptSubstationVO.java @@ -0,0 +1,40 @@ +package com.njcn.process.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/9 14:00【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +@Data +public class DeptSubstationVO { + @ApiModelProperty(name = "id",value = "id") + private String id; + + @ApiModelProperty(name = "pid",value = "父级id") + private String pid; + + @ApiModelProperty(name = "name",value = "名称") + private String name; + + @ApiModelProperty(name = "code",value = "单位编号") + private String code; + + @ApiModelProperty(name = "disabled",value = "是否可以选择,电站不用塞,部门塞disabled: true") + private boolean disabled; + @ApiModelProperty(name = "flag",value = "前端标志") + private boolean flag; + + + + @ApiModelProperty(name = "children",value = "子级") + private List children = new ArrayList<> (); +} diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RGeneralSurveyPlanVO.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RGeneralSurveyPlanVO.java index c1f308884..6052d7753 100644 --- a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RGeneralSurveyPlanVO.java +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RGeneralSurveyPlanVO.java @@ -41,7 +41,7 @@ public class RGeneralSurveyPlanVO { private Date planEndTime; @ApiModelProperty(value="变电站数量") - private Long subCount; + private Integer subCount; @ApiModelProperty(value="母线数量") private Long busCount; @@ -51,7 +51,7 @@ public class RGeneralSurveyPlanVO { @ApiModelProperty(value="文件是否上传(0:否 1:是)") private Integer isFileUpload; - + private String leader; /** * 上传文件数量 */ @@ -77,9 +77,10 @@ public class RGeneralSurveyPlanVO { */ @ApiModelProperty(value="上传时间") private Date uploadTime; - - @ApiModelProperty(value="计划详细情况母线相关") - private List rGeneralSurveyPlanDetailVOList; + @ApiModelProperty(value="选中的电站集合") + private List subIds; +// @ApiModelProperty(value="计划详细情况母线相关") +// private List rGeneralSurveyPlanDetailVOList; @Data @ApiModel(value="计划详细情况母线相关") public static class RGeneralSurveyPlanDetailVO{ diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RSurveyCycleVO.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RSurveyCycleVO.java new file mode 100644 index 000000000..3e18254ec --- /dev/null +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RSurveyCycleVO.java @@ -0,0 +1,27 @@ +package com.njcn.process.pojo.vo; + +import lombok.Data; + +import java.time.LocalDate; + +/** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/13 9:23【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +@Data +public class RSurveyCycleVO { + private String id; + + private LocalDate startYear; + + private LocalDate endYear; + + private Integer surveyCycle; + + private Boolean flag; +} \ No newline at end of file diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RSurveyPlanConfigVO.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RSurveyPlanConfigVO.java new file mode 100644 index 000000000..d9eb5f356 --- /dev/null +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/RSurveyPlanConfigVO.java @@ -0,0 +1,110 @@ +package com.njcn.process.pojo.vo; + +/** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/9 10:13【需求编号】 + * + * @author clam + * @version V1.0.0 + */ + +public class RSurveyPlanConfigVO { + + + + /** + * 组织机构名称 + */ + private String orgName; + + /** + * 组织机构ID(外键) + */ + private String orgId; + + /** + * 普测电站总数 + */ + private Integer statNum; + + /** + * 该机构普测占比 + */ + private Double proportion; + + + + /** + * 获取组织机构名称 + * + * @return Org_Name - 组织机构名称 + */ + public String getOrgName() { + return orgName; + } + + /** + * 设置组织机构名称 + * + * @param orgName 组织机构名称 + */ + public void setOrgName(String orgName) { + this.orgName = orgName; + } + + /** + * 获取组织机构ID(外键) + * + * @return Org_Id - 组织机构ID(外键) + */ + public String getOrgId() { + return orgId; + } + + /** + * 设置组织机构ID(外键) + * + * @param orgId 组织机构ID(外键) + */ + public void setOrgId(String orgId) { + this.orgId = orgId; + } + + /** + * 获取普测电站总数 + * + * @return stat_num - 普测电站总数 + */ + public Integer getStatNum() { + return statNum; + } + + /** + * 设置普测电站总数 + * + * @param statNum 普测电站总数 + */ + public void setStatNum(Integer statNum) { + this.statNum = statNum; + } + + /** + * 获取该机构普测占比 + * + * @return proportion - 该机构普测占比 + */ + public Double getProportion() { + return proportion; + } + + /** + * 设置该机构普测占比 + * + * @param proportion 该机构普测占比 + */ + public void setProportion(Double proportion) { + this.proportion = proportion; + } +} \ No newline at end of file diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/StatationStatExcel.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/StatationStatExcel.java new file mode 100644 index 000000000..9e7890ebd --- /dev/null +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/vo/StatationStatExcel.java @@ -0,0 +1,73 @@ +package com.njcn.process.pojo.vo; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.io.Serializable; + +/** + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/8 15:18【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +@Data +public class StatationStatExcel implements Serializable { + + @Excel(name = "电站", width = 15) + private String powerId; + + /** + * 电站名称 + */ + @Excel(name = "电站名称", width = 15) + private String powerName; + + /** + * 机构组织id + */ + @Excel(name = "机构组织", width = 15) + private String orgId; + + /** + * 机构组织名称 + */ + @Excel(name = "机构组织名称", width = 15) + private String orgName; + + /** + * 应设点数量 + */ + @Excel(name = "应设点数量", width = 15) + private Integer shouldBeNum; + + /** + * 电压等级 + */ + @Excel(name = "电压等级", width = 15) + private String voltageLevel; + + /** + * 经度 + */ + @Excel(name = "经度", width = 15) + private Double longitude; + + /** + * 维度 + */ + @Excel(name = "维度", width = 15) + private Double latitude; + + /** + * 数据状态:0-删除;1-正常; + */ + @Excel(name = "数据状态", width = 15) + private Integer status; + @Excel(name = "数据状态", width = 15) + private String exceptionMessage; + + +} diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/controller/RGeneralSurveyPlanController.java b/pqs-process/process-boot/src/main/java/com/njcn/process/controller/RGeneralSurveyPlanController.java index 91b57fb45..7d8363c41 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/controller/RGeneralSurveyPlanController.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/controller/RGeneralSurveyPlanController.java @@ -13,21 +13,23 @@ import com.njcn.minioss.bo.MinIoUploadResDTO; import com.njcn.poi.util.PoiUtil; import com.njcn.process.pojo.param.*; import com.njcn.process.pojo.po.RGeneralSurveyPlanPO; -import com.njcn.process.pojo.vo.SurveyPlanExcel; -import com.njcn.process.pojo.vo.RGeneralSurveyPlanDetailOnQuestionVO; -import com.njcn.process.pojo.vo.RGeneralSurveyPlanVO; +import com.njcn.process.pojo.po.RSurveyPlanConfigPO; +import com.njcn.process.pojo.vo.*; import com.njcn.process.service.RGeneralSurveyPlanDetailService; import com.njcn.process.service.RGeneralSurveyPlanPOService; +import com.njcn.process.service.impl.RSurveyPlanConfigService; import com.njcn.web.controller.BaseController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.usermodel.Workbook; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.BeanUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -52,8 +54,10 @@ public class RGeneralSurveyPlanController extends BaseController { private final RGeneralSurveyPlanPOService rGeneralSurveyPlanPOService; - private @Autowired + private final RGeneralSurveyPlanDetailService rGeneralSurveyPlanDetailService; + private final + RSurveyPlanConfigService rSurveyPlanConfigService; /** * @Description: 新增/修改普测计划 * @Param: [rGeneralSurveyPlanAddParm] @@ -72,7 +76,80 @@ public class RGeneralSurveyPlanController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, addFlag, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/addPlanCycle") + @ApiOperation("设置普测周期") + @ApiImplicitParam(name = "cycleNum", value = "普测周期", required = true) + public HttpResult addPlanCycle(@RequestParam("cycleNum") Integer cycleNum ){ + String methodDescribe = getMethodDescribe("addPlanCycle"); + RSurveyCycleVO rSurveyCycleVO = rGeneralSurveyPlanPOService.addPlanCycle(cycleNum); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rSurveyCycleVO, methodDescribe); + } + + @ResponseBody + @ApiOperation("excel批量导入电站信息") + @PostMapping(value = "importSubStatation") + public HttpResult importSubStatation(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) { + String methodDescribe = getMethodDescribe("importSubStatation"); + rGeneralSurveyPlanPOService.importSubStatation(file, response); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/initDetpStataionTree") + @ApiOperation("初始化部门") + @ApiImplicitParam(name = "orgId", value = "部门号", required = true) + public HttpResult> initDetpStataionTree(@RequestParam("orgId") String orgId ){ + String methodDescribe = getMethodDescribe("initDetpStataionTree"); + + List list = rGeneralSurveyPlanPOService.initDetpStataionTree ( orgId); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/addPlanConfig") + @ApiOperation("增加普测计划参数") + @ApiImplicitParam(name = "rSurveyPlanConfigVOList", value = "", required = true) + public HttpResult addPlanConfig(@Validated @RequestBody List rSurveyPlanConfigVOList){ + String methodDescribe = getMethodDescribe("querySubStatation"); + double sum = rSurveyPlanConfigVOList.stream ( ).mapToDouble (RSurveyPlanConfigVO::getProportion).sum ( ); + if(sum>1){ + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.MATH_ERROR, false, methodDescribe); + } + List collect = rSurveyPlanConfigVOList.stream ( ).map (temp -> { + RSurveyPlanConfigPO rs = new RSurveyPlanConfigPO ( ); + BeanUtils.copyProperties (temp, rs); + return rs; + }).collect (Collectors.toList ( )); + boolean b = rSurveyPlanConfigService.saveOrUpdateBatchByMultiId (collect, 500); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/queryPlanConfig") + @ApiOperation("查询普测计划参数") + public HttpResult> queryPlanConfig(){ + String methodDescribe = getMethodDescribe("queryPlanConfig"); + List list = rSurveyPlanConfigService.list ( ); + List collect = list.stream ( ).map (temp -> { + RSurveyPlanConfigVO rs = new RSurveyPlanConfigVO ( ); + BeanUtils.copyProperties (temp, rs); + return rs; + }).collect (Collectors.toList ( )); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, collect, methodDescribe); + } + + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/querySubStatation") + @ApiOperation("电站勾选接口") + @ApiImplicitParam(name = "statetionNum", value = "电站数量", required = true) + public HttpResult querySubStatation(@RequestParam("statetionNum") Integer statetionNum ){ + String methodDescribe = getMethodDescribe("querySubStatation"); + + RGeneralSurveyPlanAddParm rGeneralSurveyPlanAddParm = rGeneralSurveyPlanPOService.querySubStatation (statetionNum); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rGeneralSurveyPlanAddParm, methodDescribe); + } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/queryPlan") @@ -118,16 +195,16 @@ public class RGeneralSurveyPlanController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rGeneralSurveyPlanVOS, methodDescribe); } - @OperateInfo(info = LogEnum.BUSINESS_COMMON) - @PostMapping("/queryPlandetail") - @ApiOperation("根据planNO查询普测计划详情") - @ApiImplicitParam(name = "rGeneralSurveyPlandetailQueryParm", value = "普测计划详情查询参数", required = true) - public HttpResult> queryPlandetail(@Validated @RequestBody RGeneralSurveyPlandetailQueryParm rGeneralSurveyPlandetailQueryParm){ - String methodDescribe = getMethodDescribe("queryPlandetail"); - - IPage rGeneralSurveyPlanDetailVOIPage = rGeneralSurveyPlanDetailService.queryPlandetail (rGeneralSurveyPlandetailQueryParm); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rGeneralSurveyPlanDetailVOIPage, methodDescribe); - } +// @OperateInfo(info = LogEnum.BUSINESS_COMMON) +// @PostMapping("/queryPlandetail") +// @ApiOperation("根据planNO查询普测计划详情") +// @ApiImplicitParam(name = "rGeneralSurveyPlandetailQueryParm", value = "普测计划详情查询参数", required = true) +// public HttpResult> queryPlandetail(@Validated @RequestBody RGeneralSurveyPlandetailQueryParm rGeneralSurveyPlandetailQueryParm){ +// String methodDescribe = getMethodDescribe("queryPlandetail"); +// +// IPage rGeneralSurveyPlanDetailVOIPage = rGeneralSurveyPlanDetailService.queryPlandetail (rGeneralSurveyPlandetailQueryParm); +// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rGeneralSurveyPlanDetailVOIPage, methodDescribe); +// } diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/RSurveyCycleMapper.java b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/RSurveyCycleMapper.java new file mode 100644 index 000000000..6b81ba223 --- /dev/null +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/RSurveyCycleMapper.java @@ -0,0 +1,16 @@ +package com.njcn.process.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.process.pojo.po.RSurveyCyclePO; + +/** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/13 9:23【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +public interface RSurveyCycleMapper extends BaseMapper { +} \ No newline at end of file diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/RSurveyPlanConfigMapper.java b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/RSurveyPlanConfigMapper.java new file mode 100644 index 000000000..03367bd33 --- /dev/null +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/RSurveyPlanConfigMapper.java @@ -0,0 +1,17 @@ +package com.njcn.process.mapper; + +import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; +import com.njcn.process.pojo.po.RSurveyPlanConfigPO; + +/** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/9 10:13【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +public interface RSurveyPlanConfigMapper extends MppBaseMapper { + +} \ No newline at end of file diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/StatationStatMapper.java b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/StatationStatMapper.java new file mode 100644 index 000000000..52cad9769 --- /dev/null +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/StatationStatMapper.java @@ -0,0 +1,43 @@ +package com.njcn.process.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.device.pms.pojo.dto.PmsStatationStatInfoDTO; +import com.njcn.device.pms.pojo.param.PmsStatationStatInfoParam; +import com.njcn.device.pms.pojo.po.StatationStat; +import com.njcn.device.pms.pojo.vo.StatationStatVO; +import com.njcn.web.pojo.param.BaseParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author hongawen + * @since 2022-10-14 + */ +public interface StatationStatMapper extends BaseMapper { + + /** + * 获取指定的变电站信息 + * + * @param pmsStatationStatInfoParam 变电站详情数据入参 + * @return 指定的变电站信息 + */ + List getStatationStatInfo(@Param("pmsStatationStatInfoParam") PmsStatationStatInfoParam pmsStatationStatInfoParam); + + + + /** + * 分页查询电站信息 + * @author cdf + * @date 2022/11/18 + */ + Page getStatationStatPageList(Page page, @Param("baseParam") BaseParam baseParam); + + +} diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/RSurveyCycleMapper.xml b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/RSurveyCycleMapper.xml new file mode 100644 index 000000000..b868e5c39 --- /dev/null +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/RSurveyCycleMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + id, start_year, end_year, survey_cycle + + \ No newline at end of file diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/RSurveyPlanConfigMapper.xml b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/RSurveyPlanConfigMapper.xml new file mode 100644 index 000000000..8864072fa --- /dev/null +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/RSurveyPlanConfigMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + Id, Org_Name, Org_Id, stat_num, proportion + + \ No newline at end of file diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/RGeneralSurveyPlanPOService.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/RGeneralSurveyPlanPOService.java index cb8c2b461..029abf2d2 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/RGeneralSurveyPlanPOService.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/RGeneralSurveyPlanPOService.java @@ -5,10 +5,10 @@ import com.github.jeffreyning.mybatisplus.service.IMppService; import com.njcn.minioss.bo.MinIoUploadResDTO; import com.njcn.process.pojo.param.*; import com.njcn.process.pojo.po.RGeneralSurveyPlanPO; -import com.njcn.process.pojo.vo.SurveyPlanExcel; -import com.njcn.process.pojo.vo.RGeneralSurveyPlanDetailOnQuestionVO; -import com.njcn.process.pojo.vo.RGeneralSurveyPlanVO; +import com.njcn.process.pojo.vo.*; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; import java.util.List; /** @@ -86,4 +86,18 @@ public interface RGeneralSurveyPlanPOService extends IMppService initDetpStataionTree(String orgid); + /** + * @Description: 设置普测周期 + * @Param: [cycleNum] + * @return: java.lang.Boolean + * @Author: clam + * @Date: 2023/3/15 + */ + RSurveyCycleVO addPlanCycle(Integer cycleNum); } diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/RSurveyCycleServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/RSurveyCycleServiceImpl.java new file mode 100644 index 000000000..9e6ce56fa --- /dev/null +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/RSurveyCycleServiceImpl.java @@ -0,0 +1,22 @@ +package com.njcn.process.service; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.List; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.process.pojo.po.RSurveyCyclePO; +import com.njcn.process.mapper.RSurveyCycleMapper; +import com.njcn.process.service.impl.RSurveyCycleService; +/** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/13 9:23【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +@Service +public class RSurveyCycleServiceImpl extends ServiceImpl implements RSurveyCycleService{ + +} diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/RSurveyPlanConfigServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/RSurveyPlanConfigServiceImpl.java new file mode 100644 index 000000000..b8242dd4f --- /dev/null +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/RSurveyPlanConfigServiceImpl.java @@ -0,0 +1,20 @@ +package com.njcn.process.service; + +import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; +import com.njcn.process.mapper.RSurveyPlanConfigMapper; +import com.njcn.process.pojo.po.RSurveyPlanConfigPO; +import com.njcn.process.service.impl.RSurveyPlanConfigService; +import org.springframework.stereotype.Service; +/** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/9 10:13【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +@Service +public class RSurveyPlanConfigServiceImpl extends MppServiceImpl implements RSurveyPlanConfigService{ + +} diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/StatationStatService.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/StatationStatService.java new file mode 100644 index 000000000..596791469 --- /dev/null +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/StatationStatService.java @@ -0,0 +1,15 @@ +package com.njcn.process.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.device.pms.pojo.po.StatationStat; + +/** + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/8 18:21【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +public interface StatationStatService extends IService { +} diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RGeneralSurveyPlanPOServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RGeneralSurveyPlanPOServiceImpl.java index 8d4e09779..467445f5a 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RGeneralSurveyPlanPOServiceImpl.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RGeneralSurveyPlanPOServiceImpl.java @@ -1,28 +1,42 @@ package com.njcn.process.service.impl; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.ExcelImportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.ImportParams; +import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.device.pms.pojo.po.StatationStat; import com.njcn.minioss.bo.MinIoUploadResDTO; import com.njcn.oss.constant.OssPath; import com.njcn.oss.enums.OssResponseEnum; import com.njcn.oss.utils.FileStorageUtil; +import com.njcn.poi.util.PoiUtil; import com.njcn.process.mapper.RGeneralSurveyPlanDetailMapper; import com.njcn.process.mapper.RGeneralSurveyPlanPOMapper; +import com.njcn.process.mapper.RSurveyCycleMapper; import com.njcn.process.pojo.param.*; import com.njcn.process.pojo.po.RGeneralSurveyPlanDetail; import com.njcn.process.pojo.po.RGeneralSurveyPlanPO; -import com.njcn.process.pojo.vo.RGeneralSurveyPlanDetailOnQuestionVO; -import com.njcn.process.pojo.vo.RGeneralSurveyPlanVO; -import com.njcn.process.pojo.vo.SurveyPlanExcel; +import com.njcn.process.pojo.po.RSurveyCyclePO; +import com.njcn.process.pojo.po.RSurveyPlanConfigPO; +import com.njcn.process.pojo.vo.*; import com.njcn.process.service.RGeneralSurveyPlanDetailService; import com.njcn.process.service.RGeneralSurveyPlanPOService; +import com.njcn.process.service.StatationStatService; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.enums.DicDataTypeEnum; +import com.njcn.system.pojo.po.DictData; import com.njcn.user.api.DeptFeignClient; import com.njcn.user.pojo.vo.PvTerminalTreeVO; +import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -32,7 +46,9 @@ import org.springframework.util.StringUtils; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -63,6 +79,17 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl rSurveyCyclePOQueryWrapper = new QueryWrapper ( ); + rSurveyCyclePOQueryWrapper.le ("start_year", rGeneralSurveyPlanPO.getPlanEndTime ( )); + rSurveyCyclePOQueryWrapper.ge ("end_year", rGeneralSurveyPlanPO.getPlanEndTime ( )); + RSurveyCyclePO rSurveyCyclePO = rSurveyCycleMapper.selectOne (rSurveyCyclePOQueryWrapper); - List rGeneralSurveyPlanDetailAddParm = rGeneralSurveyPlanAddParm.getRGeneralSurveyPlanDetailAddParm(); - QueryWrapper queryWrapper = new QueryWrapper(); - queryWrapper.lambda().eq(RGeneralSurveyPlanDetail::getPlanNo, rGeneralSurveyPlanAddParm.getPlanNo()); - rGeneralSurveyPlanDetailService.remove(queryWrapper); - List rGeneralSurveyPlanDetailList = new ArrayList<>(); - rGeneralSurveyPlanDetailAddParm.forEach(temp -> { - RGeneralSurveyPlanDetail rGeneralSurveyPlanDetail = new RGeneralSurveyPlanDetail(); - BeanUtils.copyProperties(temp, rGeneralSurveyPlanDetail); + rGeneralSurveyPlanPO.setCycleId (rSurveyCyclePO.getId ( )); + boolean b = this.saveOrUpdateByMultiId (rGeneralSurveyPlanPO); + + QueryWrapper queryWrapper = new QueryWrapper ( ); + queryWrapper.lambda ( ).eq (RGeneralSurveyPlanDetail::getPlanNo, rGeneralSurveyPlanAddParm.getPlanNo ( )); + rGeneralSurveyPlanDetailService.remove (queryWrapper); + List rGeneralSurveyPlanDetailList = new ArrayList<> ( ); + rGeneralSurveyPlanAddParm.getSubIds ( ).forEach (temp -> { + StatationStat byId = statationStatService.getById (temp); + RGeneralSurveyPlanDetail rGeneralSurveyPlanDetail = new RGeneralSurveyPlanDetail ( ); + rGeneralSurveyPlanDetail.setPlanNo (rGeneralSurveyPlanAddParm.getPlanNo ( )); + rGeneralSurveyPlanDetail.setOrgNo (byId.getOrgId ( )); + rGeneralSurveyPlanDetail.setOrgName (byId.getOrgName ( )); + rGeneralSurveyPlanDetail.setSubId (byId.getPowerId ( )); + rGeneralSurveyPlanDetail.setSubName (byId.getPowerName ( )); /*目前时间与计划开始时间,结束时间一致*/ - rGeneralSurveyPlanDetail.setGeneralSurveyStartTime(rGeneralSurveyPlanAddParm.getPlanStartTime()); - rGeneralSurveyPlanDetail.setGeneralSurveyTime(rGeneralSurveyPlanAddParm.getPlanStartTime()); - rGeneralSurveyPlanDetail.setGeneralSurveyEndTime(rGeneralSurveyPlanAddParm.getPlanEndTime()); - rGeneralSurveyPlanDetail.setPlanNo(rGeneralSurveyPlanAddParm.getPlanNo()); - rGeneralSurveyPlanDetail.setGeneralSurveyLeader(rGeneralSurveyPlanAddParm.getLeader()); - rGeneralSurveyPlanDetailList.add(rGeneralSurveyPlanDetail); + rGeneralSurveyPlanDetail.setGeneralSurveyStartTime (rGeneralSurveyPlanAddParm.getPlanStartTime ( )); + rGeneralSurveyPlanDetail.setGeneralSurveyTime (rGeneralSurveyPlanAddParm.getPlanStartTime ( )); + rGeneralSurveyPlanDetail.setGeneralSurveyEndTime (rGeneralSurveyPlanAddParm.getPlanEndTime ( )); + rGeneralSurveyPlanDetail.setPlanNo (rGeneralSurveyPlanAddParm.getPlanNo ( )); + rGeneralSurveyPlanDetail.setGeneralSurveyLeader (rGeneralSurveyPlanAddParm.getLeader ( )); + rGeneralSurveyPlanDetailList.add (rGeneralSurveyPlanDetail); }); - boolean b1 = rGeneralSurveyPlanDetailService.saveOrUpdateBatchByMultiId(rGeneralSurveyPlanDetailList, 5); + boolean b1 = rGeneralSurveyPlanDetailService.saveOrUpdateBatchByMultiId (rGeneralSurveyPlanDetailList, 500); return b && b1; } @@ -113,73 +151,75 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl query(RGeneralSurveyPlanQueryParm rGeneralSurveyPlanQueryParm, List statusList) { - IPage page = new Page<>(rGeneralSurveyPlanQueryParm.getCurrentPage(), rGeneralSurveyPlanQueryParm.getPageSize()); - IPage returnpage = new Page<>(rGeneralSurveyPlanQueryParm.getCurrentPage(), rGeneralSurveyPlanQueryParm.getPageSize()); + IPage page = new Page<> (rGeneralSurveyPlanQueryParm.getCurrentPage ( ), rGeneralSurveyPlanQueryParm.getPageSize ( )); + IPage returnpage = new Page<> (rGeneralSurveyPlanQueryParm.getCurrentPage ( ), rGeneralSurveyPlanQueryParm.getPageSize ( )); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - if (!StringUtils.isEmpty(rGeneralSurveyPlanQueryParm.getOrgNo())) { - List data = deptFeignClient.getDepSonIdtByDeptId(rGeneralSurveyPlanQueryParm.getOrgNo()).getData(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<> ( ); + if (!StringUtils.isEmpty (rGeneralSurveyPlanQueryParm.getOrgNo ( ))) { + List data = deptFeignClient.getDepSonIdtByDeptId (rGeneralSurveyPlanQueryParm.getOrgNo ( )).getData ( ); - queryWrapper.in(RGeneralSurveyPlanPO::getOrgNo, data); + queryWrapper.in (RGeneralSurveyPlanPO::getOrgNo, data); } - if (!StringUtils.isEmpty(rGeneralSurveyPlanQueryParm.getStatus())) { - queryWrapper.eq(RGeneralSurveyPlanPO::getStatus, rGeneralSurveyPlanQueryParm.getStatus()); + if (!StringUtils.isEmpty (rGeneralSurveyPlanQueryParm.getStatus ( ))) { + queryWrapper.eq (RGeneralSurveyPlanPO::getStatus, rGeneralSurveyPlanQueryParm.getStatus ( )); } - if (!StringUtils.isEmpty(rGeneralSurveyPlanQueryParm.getIsFileUpload())) { - queryWrapper.eq(RGeneralSurveyPlanPO::getIsFileUpload, rGeneralSurveyPlanQueryParm.getIsFileUpload()); + if (!StringUtils.isEmpty (rGeneralSurveyPlanQueryParm.getIsFileUpload ( ))) { + queryWrapper.eq (RGeneralSurveyPlanPO::getIsFileUpload, rGeneralSurveyPlanQueryParm.getIsFileUpload ( )); } - if (!Objects.isNull(rGeneralSurveyPlanQueryParm.getPlanStartTime())) { - queryWrapper.ge(RGeneralSurveyPlanPO::getPlanStartTime, rGeneralSurveyPlanQueryParm.getPlanStartTime()); + if (!Objects.isNull (rGeneralSurveyPlanQueryParm.getPlanStartTime ( ))) { + queryWrapper.ge (RGeneralSurveyPlanPO::getPlanStartTime, rGeneralSurveyPlanQueryParm.getPlanStartTime ( )); } - if (!Objects.isNull(rGeneralSurveyPlanQueryParm.getPlanEndTime())) { - queryWrapper.le(RGeneralSurveyPlanPO::getPlanEndTime, rGeneralSurveyPlanQueryParm.getPlanEndTime()); + if (!Objects.isNull (rGeneralSurveyPlanQueryParm.getPlanEndTime ( ))) { + queryWrapper.le (RGeneralSurveyPlanPO::getPlanStartTime, rGeneralSurveyPlanQueryParm.getPlanEndTime ( )); } - queryWrapper.in(RGeneralSurveyPlanPO::getStatus, statusList); - queryWrapper.orderByAsc(RGeneralSurveyPlanPO::getStatus).orderByDesc(RGeneralSurveyPlanPO::getPlanCreateTime); + queryWrapper.in (RGeneralSurveyPlanPO::getStatus, statusList); + queryWrapper.orderByAsc (RGeneralSurveyPlanPO::getStatus).orderByDesc (RGeneralSurveyPlanPO::getPlanCreateTime); - List rGeneralSurveyPlanPOS = rGeneralSurveyPlanPOMapper.selectPage(page, queryWrapper).getRecords(); - if (CollectionUtils.isEmpty(rGeneralSurveyPlanPOS)) { + List rGeneralSurveyPlanPOS = rGeneralSurveyPlanPOMapper.selectPage (page, queryWrapper).getRecords ( ); + if (CollectionUtils.isEmpty (rGeneralSurveyPlanPOS)) { return returnpage; } //部门处理:根据部门code取名称 - List dept = deptFeignClient.allDeptList().getData(); - Map pvTerminalTreeVOMap = dept.stream(). - collect(Collectors. - toMap(PvTerminalTreeVO::getId, + List dept = deptFeignClient.allDeptList ( ).getData ( ); + Map pvTerminalTreeVOMap = dept.stream ( ). + collect (Collectors. + toMap (PvTerminalTreeVO::getId, PvTerminalTreeVO::getName)); - List collect = rGeneralSurveyPlanPOS.stream().map(RGeneralSurveyPlanPO::getPlanNo).collect(Collectors.toList()); - LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(RGeneralSurveyPlanDetail::getPlanNo, collect); - List rGeneralSurveyPlanDetails = rGeneralSurveyPlanDetailMapper.selectList(lambdaQueryWrapper); - List rGeneralSurveyPlanVOList = new ArrayList<>(); - rGeneralSurveyPlanPOS.forEach(temp -> { - RGeneralSurveyPlanVO rGeneralSurveyPlanVO = new RGeneralSurveyPlanVO(); - BeanUtils.copyProperties(temp, rGeneralSurveyPlanVO); - long Busbarcount = rGeneralSurveyPlanDetails.stream(). - filter(surveyPlanDetail -> Objects.equals(surveyPlanDetail.getPlanNo(), temp.getPlanNo())). - map(RGeneralSurveyPlanDetail::getBusbarId).distinct().count(); + List collect = rGeneralSurveyPlanPOS.stream ( ).map (RGeneralSurveyPlanPO::getPlanNo).collect (Collectors.toList ( )); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<> ( ); + lambdaQueryWrapper.in (RGeneralSurveyPlanDetail::getPlanNo, collect); + List rGeneralSurveyPlanDetails = rGeneralSurveyPlanDetailMapper.selectList (lambdaQueryWrapper); + List rGeneralSurveyPlanVOList = new ArrayList<> ( ); + rGeneralSurveyPlanPOS.forEach (temp -> { + RGeneralSurveyPlanVO rGeneralSurveyPlanVO = new RGeneralSurveyPlanVO ( ); + BeanUtils.copyProperties (temp, rGeneralSurveyPlanVO); + List collect1 = rGeneralSurveyPlanDetails.stream ( ). + filter (surveyPlanDetail -> Objects.equals (surveyPlanDetail.getPlanNo ( ), temp.getPlanNo ( ))). + map (RGeneralSurveyPlanDetail::getSubId).collect (Collectors.toList ( )); + rGeneralSurveyPlanVO.setSubCount (collect1.size ( )); + rGeneralSurveyPlanVO.setSubIds (collect1); +/* + long Subcount = rGeneralSurveyPlanDetails.stream ( ). + filter (surveyPlanDetail -> Objects.equals (surveyPlanDetail.getPlanNo ( ), temp.getPlanNo ( ))). + map (RGeneralSurveyPlanDetail::getSubId).distinct ( ).count ( );*/ +// rGeneralSurveyPlanVO.setBusCount (Busbarcount); +// List collect1 = rGeneralSurveyPlanDetails.stream ( ). +// filter (surveyPlanDetail -> Objects.equals (surveyPlanDetail.getPlanNo ( ), temp.getPlanNo ( ))). +// map (surveyPlanDetail -> { +// RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO rGeneralSurveyPlanDetailVO = new RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO ( ); +// BeanUtils.copyProperties (surveyPlanDetail, rGeneralSurveyPlanDetailVO); +// return rGeneralSurveyPlanDetailVO; +// }).collect (Collectors.toList ( )); + rGeneralSurveyPlanVO.setOrgName (pvTerminalTreeVOMap.get (temp.getOrgNo ( ))); //单位名称 +// +// rGeneralSurveyPlanVO.setRGeneralSurveyPlanDetailVOList (collect1); - long Subcount = rGeneralSurveyPlanDetails.stream(). - filter(surveyPlanDetail -> Objects.equals(surveyPlanDetail.getPlanNo(), temp.getPlanNo())). - map(RGeneralSurveyPlanDetail::getSubId).distinct().count(); - rGeneralSurveyPlanVO.setBusCount(Busbarcount); - rGeneralSurveyPlanVO.setSubCount(Subcount); - List collect1 = rGeneralSurveyPlanDetails.stream(). - filter(surveyPlanDetail -> Objects.equals(surveyPlanDetail.getPlanNo(), temp.getPlanNo())). - map(surveyPlanDetail -> { - RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO rGeneralSurveyPlanDetailVO = new RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO(); - BeanUtils.copyProperties(surveyPlanDetail, rGeneralSurveyPlanDetailVO); - return rGeneralSurveyPlanDetailVO; - }).collect(Collectors.toList()); - rGeneralSurveyPlanVO.setOrgName(pvTerminalTreeVOMap.get(temp.getOrgNo())); //单位名称 - - rGeneralSurveyPlanVO.setRGeneralSurveyPlanDetailVOList(collect1); - rGeneralSurveyPlanVOList.add(rGeneralSurveyPlanVO); + rGeneralSurveyPlanVOList.add (rGeneralSurveyPlanVO); }); - returnpage.setRecords(rGeneralSurveyPlanVOList); + returnpage.setRecords (rGeneralSurveyPlanVOList); return returnpage; } @@ -195,26 +235,26 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl surveyResultDownload(String planNo) { - RGeneralSurveyPlanPO rGeneralSurveyPlanPO = new RGeneralSurveyPlanPO(); - rGeneralSurveyPlanPO.setPlanNo(planNo); - rGeneralSurveyPlanPO = this.selectByMultiId(rGeneralSurveyPlanPO); - String filePath = rGeneralSurveyPlanPO.getFilePath(); - if (StringUtils.isEmpty(filePath)) { - throw new BusinessException(OssResponseEnum.DOWNLOAD_FILE_ERROR); + RGeneralSurveyPlanPO rGeneralSurveyPlanPO = new RGeneralSurveyPlanPO ( ); + rGeneralSurveyPlanPO.setPlanNo (planNo); + rGeneralSurveyPlanPO = this.selectByMultiId (rGeneralSurveyPlanPO); + String filePath = rGeneralSurveyPlanPO.getFilePath ( ); + if (StringUtils.isEmpty (filePath)) { + throw new BusinessException (OssResponseEnum.DOWNLOAD_FILE_ERROR); } - String[] split = filePath.substring(0, filePath.length() - 1).split(";"); - List collect = Stream.of(split).map(temp -> { - String[] split1 = temp.split("##"); + String[] split = filePath.substring (0, filePath.length ( ) - 1).split (";"); + List collect = Stream.of (split).map (temp -> { + String[] split1 = temp.split ("##"); String OriginalFilename = split1[1]; String minoFileName = split1[0]; - MinIoUploadResDTO dto = new MinIoUploadResDTO(OriginalFilename, fileStorageUtil.getFileUrl(minoFileName)); + MinIoUploadResDTO dto = new MinIoUploadResDTO (OriginalFilename, fileStorageUtil.getFileUrl (minoFileName)); return dto; - }).collect(Collectors.toList()); + }).collect (Collectors.toList ( )); return collect; } @@ -255,35 +295,35 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl exportSurveyPlan(List planIdList) { - List surveyPlanExcels = new ArrayList<>(); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.in(RGeneralSurveyPlanPO::getPlanNo, planIdList); - List rGeneralSurveyPlanPOS = rGeneralSurveyPlanPOMapper.selectList(queryWrapper); - LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(RGeneralSurveyPlanDetail::getPlanNo, planIdList); - List rGeneralSurveyPlanDetails = rGeneralSurveyPlanDetailMapper.selectList(lambdaQueryWrapper); + List surveyPlanExcels = new ArrayList<> ( ); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<> ( ); + queryWrapper.in (RGeneralSurveyPlanPO::getPlanNo, planIdList); + List rGeneralSurveyPlanPOS = rGeneralSurveyPlanPOMapper.selectList (queryWrapper); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<> ( ); + lambdaQueryWrapper.in (RGeneralSurveyPlanDetail::getPlanNo, planIdList); + List rGeneralSurveyPlanDetails = rGeneralSurveyPlanDetailMapper.selectList (lambdaQueryWrapper); //部门处理:根据部门code取名称 - List dept = deptFeignClient.allDeptList().getData(); - Map pvTerminalTreeVOMap = dept.stream(). - collect(Collectors. - toMap(PvTerminalTreeVO::getId, + List dept = deptFeignClient.allDeptList ( ).getData ( ); + Map pvTerminalTreeVOMap = dept.stream ( ). + collect (Collectors. + toMap (PvTerminalTreeVO::getId, PvTerminalTreeVO::getName)); - rGeneralSurveyPlanPOS.forEach(temp -> { - SurveyPlanExcel surveyPlanExcel = new SurveyPlanExcel(); - BeanUtils.copyProperties(temp, surveyPlanExcel); + rGeneralSurveyPlanPOS.forEach (temp -> { + SurveyPlanExcel surveyPlanExcel = new SurveyPlanExcel ( ); + BeanUtils.copyProperties (temp, surveyPlanExcel); - long Busbarcount = rGeneralSurveyPlanDetails.stream(). - filter(surveyPlanDetail -> Objects.equals(surveyPlanDetail.getPlanNo(), temp.getPlanNo())). - map(RGeneralSurveyPlanDetail::getBusbarId).distinct().count(); + long Busbarcount = rGeneralSurveyPlanDetails.stream ( ). + filter (surveyPlanDetail -> Objects.equals (surveyPlanDetail.getPlanNo ( ), temp.getPlanNo ( ))). + map (RGeneralSurveyPlanDetail::getBusbarId).distinct ( ).count ( ); - long Subcount = rGeneralSurveyPlanDetails.stream(). - filter(surveyPlanDetail -> Objects.equals(surveyPlanDetail.getPlanNo(), temp.getPlanNo())). - map(RGeneralSurveyPlanDetail::getSubId).distinct().count(); - surveyPlanExcel.setBusCount(Busbarcount); - surveyPlanExcel.setSubCount(Subcount); - surveyPlanExcel.setOrgNo(pvTerminalTreeVOMap.get(surveyPlanExcel.getOrgNo())); - surveyPlanExcels.add(surveyPlanExcel); + long Subcount = rGeneralSurveyPlanDetails.stream ( ). + filter (surveyPlanDetail -> Objects.equals (surveyPlanDetail.getPlanNo ( ), temp.getPlanNo ( ))). + map (RGeneralSurveyPlanDetail::getSubId).distinct ( ).count ( ); + surveyPlanExcel.setBusCount (Busbarcount); + surveyPlanExcel.setSubCount (Subcount); + surveyPlanExcel.setOrgNo (pvTerminalTreeVOMap.get (surveyPlanExcel.getOrgNo ( ))); + surveyPlanExcels.add (surveyPlanExcel); }); return surveyPlanExcels; @@ -299,8 +339,8 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl querySurveyPlanOnQuestion(SurveyPlanQuestionQueryParm questionQueryParm) { - List rGeneralSurveyPlanDetailOnQuestionVOS = new ArrayList<>(); - rGeneralSurveyPlanDetailOnQuestionVOS = rGeneralSurveyPlanDetailMapper.querySurveyPlanOnQuestion(questionQueryParm); + List rGeneralSurveyPlanDetailOnQuestionVOS = new ArrayList<> ( ); + rGeneralSurveyPlanDetailOnQuestionVOS = rGeneralSurveyPlanDetailMapper.querySurveyPlanOnQuestion (questionQueryParm); return rGeneralSurveyPlanDetailOnQuestionVOS; } @@ -316,14 +356,14 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl querySurveyPlanName(SurveyPlanQuestionQueryParm questionQueryParm) { - List data = deptFeignClient.getDepSonIdtByDeptId(questionQueryParm.getOrgNo()).getData(); + List data = deptFeignClient.getDepSonIdtByDeptId (questionQueryParm.getOrgNo ( )).getData ( ); - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.select("plan_name"). - in("org_no", data). - eq("DATE_FORMAT(upload_time, '%Y-%m')", new SimpleDateFormat("yyyy-MM"). - format(questionQueryParm.getPlanStartTime())); - List list = this.list(queryWrapper); + QueryWrapper queryWrapper = new QueryWrapper<> ( ); + queryWrapper.select ("plan_name"). + in ("org_no", data). + eq ("DATE_FORMAT(upload_time, '%Y-%m')", new SimpleDateFormat ("yyyy-MM"). + format (questionQueryParm.getPlanStartTime ( ))); + List list = this.list (queryWrapper); return list; } @@ -340,13 +380,271 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl updateWrapper = new UpdateWrapper(); - updateWrapper.eq("plan_no", rGeneralSurveyPlanChcekParm.getPlanNo()); - updateWrapper.set("check_comment", rGeneralSurveyPlanChcekParm.getCheckComment()); - updateWrapper.set("check_person", rGeneralSurveyPlanChcekParm.getCheckPerson()); - updateWrapper.set("status", Objects.equals("1", rGeneralSurveyPlanChcekParm.getCheckResult()) ? 3 : 2); - result = this.update(updateWrapper); + UpdateWrapper updateWrapper = new UpdateWrapper ( ); + updateWrapper.eq ("plan_no", rGeneralSurveyPlanChcekParm.getPlanNo ( )); + updateWrapper.set ("check_comment", rGeneralSurveyPlanChcekParm.getCheckComment ( )); + updateWrapper.set ("check_person", rGeneralSurveyPlanChcekParm.getCheckPerson ( )); + updateWrapper.set ("status", Objects.equals ("1", rGeneralSurveyPlanChcekParm.getCheckResult ( )) ? 3 : 2); + result = this.update (updateWrapper); return result; } + @Override + public void importSubStatation(MultipartFile file, HttpServletResponse response) { + ImportParams params = new ImportParams ( ); + params.setHeadRows (1); + params.setTitleRows (0); + //params.setNeedVerify(true); + //第一个sheet为台账信息 + params.setStartSheetIndex (0); + params.setSheetNum (1); + try { + ExcelImportResult terminalBaseList = ExcelImportUtil.importExcelMore (file.getInputStream ( ), StatationStatExcel.class, params); + //如果存在非法数据,将不合格的数据导出 + + /*规则1:StatationStat的orgName要在原系统存在2:电压等级不对*/ + List data = deptFeignClient.allDeptList ( ).getData ( ); + Map pvTerminalTreeVOMap = data.stream ( ).collect (Collectors.toMap (PvTerminalTreeVO::getName, pvTerminalTreeVO -> pvTerminalTreeVO)); + //获取电压等级的字典 + List voltageLevelList = dicDataFeignClient.getDicDataByTypeCode (DicDataTypeEnum.DEV_VOLTAGE.getCode ( )).getData ( ); + //将电压信息转成map,key:id value:name + Map voltageLevelMap = voltageLevelList.stream ( ).collect (Collectors.toMap (DictData::getName, voltageLevel -> voltageLevel)); + List trueCollect = new ArrayList<> ( ); + List falseCollect = new ArrayList<> ( ); + for (int i = 0; i < terminalBaseList.getList ( ).size ( ); i++) { + StatationStatExcel statationStatExcel = terminalBaseList.getList ( ).get (i); + if (pvTerminalTreeVOMap.containsKey (statationStatExcel.getOrgName ( ))) { + statationStatExcel.setOrgId (pvTerminalTreeVOMap.get (statationStatExcel.getOrgName ( )).getId ( )); + } else { + statationStatExcel.setExceptionMessage ("系统中不存在此电站的部门"); + falseCollect.add (statationStatExcel); + continue; + } + if (voltageLevelMap.containsKey (statationStatExcel.getVoltageLevel ( ))) { + statationStatExcel.setVoltageLevel (voltageLevelMap.get (statationStatExcel.getVoltageLevel ( )).getId ( )); + } else { + statationStatExcel.setExceptionMessage ("系统中不存在此电站的电压等级"); + falseCollect.add (statationStatExcel); + continue; + } + trueCollect.add (statationStatExcel); + + } + if (!CollectionUtils.isEmpty (trueCollect)) { + List collect = trueCollect.stream ( ).map (temp -> { + StatationStat statationStat = new StatationStat ( ); + BeanUtils.copyProperties (temp, statationStat); + return statationStat; + }).collect (Collectors.toList ( )); + statationStatService.saveOrUpdateBatch (collect, 500); + } + if (!CollectionUtils.isEmpty (falseCollect)) { + ExportParams exportExcel = new ExportParams ("批量导入模板(请严格按照模板标准填入数据)", "非法电站信息"); + Workbook workbook = ExcelExportUtil.exportExcel (exportExcel, StatationStatExcel.class, falseCollect); + PoiUtil.exportFileByWorkbook (workbook, "非法台账信息.xlsx", response); + + } + + } catch (Exception e) { + e.printStackTrace ( ); + } + } + + @Override + public RGeneralSurveyPlanAddParm querySubStatation(Integer statetionNum) { + /*查询所有电站并过滤已经参加当期普测电站*/ + List list = statationStatService.list ( ); + + /**查出当前周期id**/ + QueryWrapper rSurveyCyclePOQueryWrapper = new QueryWrapper ( ); + rSurveyCyclePOQueryWrapper.le ("start_year", LocalDate.now ( )); + rSurveyCyclePOQueryWrapper.ge ("end_year", LocalDate.now ( )); + RSurveyCyclePO rSurveyCyclePO = rSurveyCycleMapper.selectOne (rSurveyCyclePOQueryWrapper); + + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<> ( ); + queryWrapper.eq (RGeneralSurveyPlanPO::getCycleId, rSurveyCyclePO.getId ( )); + List rGeneralSurveyPlanPOS = rGeneralSurveyPlanPOMapper.selectList (queryWrapper); + List planIds = rGeneralSurveyPlanPOS.stream ( ).map (RGeneralSurveyPlanPO::getPlanNo).collect (Collectors.toList ( )); + List subIds = new ArrayList<> ( ); + if (!CollectionUtils.isEmpty (planIds)) { + QueryWrapper rGeneralSurveyPlanDetailQueryWrapper = new QueryWrapper ( ); + rGeneralSurveyPlanDetailQueryWrapper.in ("plan_no", planIds); + List rGeneralSurveyPlanDetails = rGeneralSurveyPlanDetailMapper.selectList (rGeneralSurveyPlanDetailQueryWrapper); + subIds = rGeneralSurveyPlanDetails.stream ( ).map (RGeneralSurveyPlanDetail::getSubId).collect (Collectors.toList ( )); + } + + + List finalSubIds = subIds; + List filterList = list.stream ( ).filter (temp -> !finalSubIds.contains (temp.getPowerId ( ))).collect (Collectors.toList ( )); + List addList = new ArrayList<> ( ); + + List rSurveyPlanConfigPOList = rSurveyPlanConfigService.list ( ); + Map orgIdMap = rSurveyPlanConfigPOList.stream ( ). + collect (Collectors.toMap (RSurveyPlanConfigPO::getOrgId, temp -> temp)); + List data = deptFeignClient.allDeptList ( ).getData ( ); + data.stream ( ).forEach (temp -> { + DeptSubstationVO deptSubstationVO = new DeptSubstationVO ( ); + BeanUtils.copyProperties (temp, deptSubstationVO); + /*如果存在电站占比配置随机抽出配置电站个数*/ + if (orgIdMap.containsKey (temp.getId ( ))) { + List collect = filterList.stream ( ).filter (statationStat -> Objects. + equals (statationStat.getOrgId ( ), temp.getId ( ))).collect (Collectors.toList ( )); + RSurveyPlanConfigPO rSurveyPlanConfigPO = orgIdMap.get (temp.getId ( )); + //向上取整 + int v = (int) Math.ceil (rSurveyPlanConfigPO.getProportion ( ) * + statetionNum); + if (collect.size ( ) >= v) { + Collections.shuffle (collect); + List lastList = collect.stream ( ).limit (v).collect (Collectors.toList ( )); + addList.addAll (lastList); + } else { + addList.addAll (collect); + } + } + + }); + + + if (statetionNum > addList.size ( )) { + /*取差集,当通过比例抽取变电站不够时 重差集里取*/ + List collect = filterList.stream ( ).filter (o -> !addList.contains (o)).collect (Collectors.toList ( )); + int differenceCount = statetionNum - addList.size ( ); + Collections.shuffle (collect); + List lastList = collect.stream ( ).limit (differenceCount).collect (Collectors.toList ( )); + addList.addAll (lastList); + } + List result = addList.stream ( ).map (StatationStat::getPowerId).collect (Collectors.toList ( )); + RGeneralSurveyPlanAddParm rGeneralSurveyPlanAddParm = new RGeneralSurveyPlanAddParm ( ); + rGeneralSurveyPlanAddParm.setSubIds (result); + return rGeneralSurveyPlanAddParm; + } + + @Override + public List initDetpStataionTree(String orgdid) { + + /*查询所有电站并过滤已经参加当期普测电站*/ + List list = statationStatService.list ( ); + + /**查出当前周期id**/ + QueryWrapper rSurveyCyclePOQueryWrapper = new QueryWrapper ( ); + rSurveyCyclePOQueryWrapper.le ("start_year", LocalDate.now ( )); + rSurveyCyclePOQueryWrapper.ge ("end_year", LocalDate.now ( )); + RSurveyCyclePO rSurveyCyclePO = rSurveyCycleMapper.selectOne (rSurveyCyclePOQueryWrapper); +/** + * 不存则新建周期 + */ + if (Objects.equals (rSurveyCyclePO, null)) { + List rSurveyCyclePOS = rSurveyCycleMapper.selectList (null); + int cycleNum = 0; + if (CollectionUtils.isEmpty (rSurveyCyclePOS)) { + + cycleNum = 5; + } else { + rSurveyCyclePOS = rSurveyCyclePOS.stream ( ) + .sorted (Comparator.comparing (RSurveyCyclePO::getEndYear).reversed ( )) + .collect (Collectors.toList ( )); + + cycleNum = rSurveyCyclePOS.get (0).getSurveyCycle ( ); + } + LocalDate enddate = LocalDate.now ( ).plusYears (cycleNum); + rSurveyCyclePO = new RSurveyCyclePO(); + rSurveyCyclePO.setStartYear (LocalDate.now ( )); + rSurveyCyclePO.setEndYear (enddate); + rSurveyCyclePO.setSurveyCycle (cycleNum); + rSurveyCycleMapper.insert (rSurveyCyclePO); + } + + LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<> ( ); + queryWrapper1.eq (RGeneralSurveyPlanPO::getCycleId, rSurveyCyclePO.getId ( )); + List rGeneralSurveyPlanPOS = rGeneralSurveyPlanPOMapper.selectList (queryWrapper1); + List planIds = rGeneralSurveyPlanPOS.stream ( ).map (RGeneralSurveyPlanPO::getPlanNo).collect (Collectors.toList ( )); + List subIds = new ArrayList<> ( ); + if (!CollectionUtils.isEmpty (planIds)) { + QueryWrapper rGeneralSurveyPlanDetailQueryWrapper = new QueryWrapper ( ); + rGeneralSurveyPlanDetailQueryWrapper.in ("plan_no", planIds); + List rGeneralSurveyPlanDetails = rGeneralSurveyPlanDetailMapper.selectList (rGeneralSurveyPlanDetailQueryWrapper); + subIds = rGeneralSurveyPlanDetails.stream ( ).map (RGeneralSurveyPlanDetail::getSubId).collect (Collectors.toList ( )); + } + + + List finalSubIds = subIds; + + List data = deptFeignClient.allDeptList ( ).getData ( ); + List deptSubstationVOList = data.stream ( ).map (temp -> { + DeptSubstationVO deptSubstationVO = new DeptSubstationVO ( ); + BeanUtils.copyProperties (temp, deptSubstationVO); + deptSubstationVO.setDisabled (true); + deptSubstationVO.setFlag (true); + QueryWrapper queryWrapper = new QueryWrapper<> ( ); + queryWrapper.eq ("org_id", temp.getCode ( )); + List list1 = statationStatService.list (queryWrapper); + List children = deptSubstationVO.getChildren ( ); + List collect = list1.stream ( ).map (statationStat -> { + DeptSubstationVO deptSubstationVO1 = new DeptSubstationVO ( ); + deptSubstationVO1.setId (statationStat.getPowerId ( )); + deptSubstationVO1.setPid (temp.getId ( )); + deptSubstationVO1.setName (statationStat.getPowerName ( )); + if (finalSubIds.contains (statationStat.getPowerId ( ))) { + deptSubstationVO1.setDisabled (true); + } + deptSubstationVO1.setFlag (true); + return deptSubstationVO1; + }).collect (Collectors.toList ( )); + children.addAll (collect); + + return deptSubstationVO; + }).collect (Collectors.toList ( )); + + /* + 遍历两次data来组装带有children关联性的对象,如果找到子级就删除result的数据 + +*/ + List result = new ArrayList<> (deptSubstationVOList); + + for (DeptSubstationVO pv : deptSubstationVOList) { + for (DeptSubstationVO pv2 : deptSubstationVOList) { + + /*如果本级id与数据的父id相同,就说明是子父级关系*/ + + if (pv.getId ( ).equals (pv2.getPid ( ))) { + pv.getChildren ( ).add (pv2); + result.remove (pv2); + } + } + } + + result = result.stream ( ).filter (temp -> Objects.equals (temp.getId ( ), orgdid)).collect (Collectors.toList ( )); + + return result; + } + + @Override + @Transactional(rollbackFor = {Exception.class}) + public RSurveyCycleVO addPlanCycle(Integer cycleNum) { + + /**查出当前周期id**/ + QueryWrapper rSurveyCyclePOQueryWrapper = new QueryWrapper ( ); + rSurveyCyclePOQueryWrapper.le ("start_year", LocalDate.now ( )); + rSurveyCyclePOQueryWrapper.ge ("end_year", LocalDate.now ( )); + RSurveyCyclePO rSurveyCyclePO = rSurveyCycleMapper.selectOne (rSurveyCyclePOQueryWrapper); + + int insert = 0; + Boolean flag = true; + if (Objects.equals (rSurveyCyclePO, null)) { + rSurveyCyclePO = new RSurveyCyclePO ( ); + LocalDate enddate = LocalDate.now ( ).plusYears (cycleNum); + rSurveyCyclePO.setStartYear (LocalDate.now ( )); + rSurveyCyclePO.setEndYear (enddate); + rSurveyCyclePO.setSurveyCycle (cycleNum); + insert = rSurveyCycleMapper.insert (rSurveyCyclePO); + } else { + flag = false; + } + RSurveyCycleVO rSurveyCycleVO = new RSurveyCycleVO(); + BeanUtils.copyProperties (rSurveyCyclePO, rSurveyCycleVO); + rSurveyCycleVO.setFlag (flag); + return rSurveyCycleVO; + } + } diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RSurveyCycleService.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RSurveyCycleService.java new file mode 100644 index 000000000..3446a91ba --- /dev/null +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RSurveyCycleService.java @@ -0,0 +1,17 @@ +package com.njcn.process.service.impl; + +import com.njcn.process.pojo.po.RSurveyCyclePO; +import com.baomidou.mybatisplus.extension.service.IService; + /** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/13 9:23【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +public interface RSurveyCycleService extends IService{ + + +} diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RSurveyPlanConfigService.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RSurveyPlanConfigService.java new file mode 100644 index 000000000..6175ffda0 --- /dev/null +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/RSurveyPlanConfigService.java @@ -0,0 +1,17 @@ +package com.njcn.process.service.impl; + +import com.github.jeffreyning.mybatisplus.service.IMppService; +import com.njcn.process.pojo.po.RSurveyPlanConfigPO; + /** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/9 10:13【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +public interface RSurveyPlanConfigService extends IMppService { + + +} diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/StatationStatServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/StatationStatServiceImpl.java new file mode 100644 index 000000000..a2f02762b --- /dev/null +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/StatationStatServiceImpl.java @@ -0,0 +1,20 @@ +package com.njcn.process.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.device.pms.pojo.po.StatationStat; +import com.njcn.process.mapper.StatationStatMapper; +import com.njcn.process.service.StatationStatService; +import org.springframework.stereotype.Service; + +/** + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/8 18:22【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +@Service +public class StatationStatServiceImpl extends ServiceImpl implements StatationStatService { + +}