谐波普测模块修改

This commit is contained in:
huangzj
2023-03-15 18:46:18 +08:00
parent c29e445933
commit 61216a0b37
25 changed files with 1192 additions and 178 deletions

View File

@@ -92,7 +92,7 @@ public enum CommonResponseEnum {
TIME_ERROR("A0101","时间格式有误"), TIME_ERROR("A0101","时间格式有误"),
CLOSE_RESOURCE_ERROR("A0102","关闭资源有误"), CLOSE_RESOURCE_ERROR("A0102","关闭资源有误"),
MATH_ERROR("A0103","比例总和大于100%"),
; ;

View File

@@ -1,7 +1,6 @@
package com.njcn.process.pojo.param; package com.njcn.process.pojo.param;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@@ -41,10 +40,10 @@ public class RGeneralSurveyPlanAddParm {
@ApiModelProperty(value="详细情况") @ApiModelProperty(value="详细情况")
private String description; private String description;
@ApiModelProperty(value="计划详细情况母线相关") @ApiModelProperty(value="选中的电站集合")
private List<RGeneralSurveyPlanDetailAddParm> rGeneralSurveyPlanDetailAddParm; private List<String> subIds;
@Data /* @Data
@ApiModel(value="计划详细情况母线相关") @ApiModel(value="计划详细情况电站相关")
public static class RGeneralSurveyPlanDetailAddParm{ public static class RGeneralSurveyPlanDetailAddParm{
@ApiModelProperty(value = "组织id") @ApiModelProperty(value = "组织id")
@@ -69,33 +68,33 @@ public class RGeneralSurveyPlanAddParm {
@ApiModelProperty(value="离线监测点id") @ApiModelProperty(value="离线监测点id")
private String measurementPointId; private String measurementPointId;
/** *//**
* 测试开始时间 * 测试开始时间
*/ *//*
@ApiModelProperty(value="测试开始时间") @ApiModelProperty(value="测试开始时间")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date generalSurveyStartTime; private Date generalSurveyStartTime;
/** *//**
* 测试结束时间 * 测试结束时间
*/ *//*
@ApiModelProperty(value="测试结束时间") @ApiModelProperty(value="测试结束时间")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date generalSurveyEndTime; private Date generalSurveyEndTime;
/** *//**
* 测试日期 * 测试日期
*/ *//*
@ApiModelProperty(value="测试日期") @ApiModelProperty(value="测试日期")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date generalSurveyTime; private Date generalSurveyTime;
/** *//**
* 测试负责人 * 测试负责人
*/ *//*
@ApiModelProperty(value="测试负责人") @ApiModelProperty(value="测试负责人")
private String generalSurveyLeader; private String generalSurveyLeader;
} }*/
} }

View File

@@ -37,7 +37,7 @@ public class RGeneralSurveyPlanDetail {
* 母线ID * 母线ID
*/ */
@MppMultiId(value = "busbar_id") @TableField(value = "busbar_id")
private String busbarId; private String busbarId;
/** /**
@@ -67,7 +67,7 @@ public class RGeneralSurveyPlanDetail {
/** /**
* 变电站ID * 变电站ID
*/ */
@TableField(value = "sub_id") @MppMultiId(value = "sub_id")
private String subId; private String subId;
/** /**

View File

@@ -35,6 +35,12 @@ public class RGeneralSurveyPlanPO {
*/ */
@MppMultiId(value = "plan_no") @MppMultiId(value = "plan_no")
private String planNo; private String planNo;
/**
* 普测周期id
*
*/
@TableField(value = "cycle_id")
private String cycleId;
/** /**
* 普测计划名称 * 普测计划名称

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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<DeptSubstationVO> children = new ArrayList<> ();
}

View File

@@ -41,7 +41,7 @@ public class RGeneralSurveyPlanVO {
private Date planEndTime; private Date planEndTime;
@ApiModelProperty(value="变电站数量") @ApiModelProperty(value="变电站数量")
private Long subCount; private Integer subCount;
@ApiModelProperty(value="母线数量") @ApiModelProperty(value="母线数量")
private Long busCount; private Long busCount;
@@ -51,7 +51,7 @@ public class RGeneralSurveyPlanVO {
@ApiModelProperty(value="文件是否上传(0:否 1:是)") @ApiModelProperty(value="文件是否上传(0:否 1:是)")
private Integer isFileUpload; private Integer isFileUpload;
private String leader;
/** /**
* 上传文件数量 * 上传文件数量
*/ */
@@ -77,9 +77,10 @@ public class RGeneralSurveyPlanVO {
*/ */
@ApiModelProperty(value="上传时间") @ApiModelProperty(value="上传时间")
private Date uploadTime; private Date uploadTime;
@ApiModelProperty(value="选中的电站集合")
@ApiModelProperty(value="计划详细情况母线相关") private List<String> subIds;
private List<RGeneralSurveyPlanDetailVO> rGeneralSurveyPlanDetailVOList; // @ApiModelProperty(value="计划详细情况母线相关")
// private List<RGeneralSurveyPlanDetailVO> rGeneralSurveyPlanDetailVOList;
@Data @Data
@ApiModel(value="计划详细情况母线相关") @ApiModel(value="计划详细情况母线相关")
public static class RGeneralSurveyPlanDetailVO{ public static class RGeneralSurveyPlanDetailVO{

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -13,21 +13,23 @@ import com.njcn.minioss.bo.MinIoUploadResDTO;
import com.njcn.poi.util.PoiUtil; import com.njcn.poi.util.PoiUtil;
import com.njcn.process.pojo.param.*; import com.njcn.process.pojo.param.*;
import com.njcn.process.pojo.po.RGeneralSurveyPlanPO; import com.njcn.process.pojo.po.RGeneralSurveyPlanPO;
import com.njcn.process.pojo.vo.SurveyPlanExcel; import com.njcn.process.pojo.po.RSurveyPlanConfigPO;
import com.njcn.process.pojo.vo.RGeneralSurveyPlanDetailOnQuestionVO; import com.njcn.process.pojo.vo.*;
import com.njcn.process.pojo.vo.RGeneralSurveyPlanVO;
import com.njcn.process.service.RGeneralSurveyPlanDetailService; import com.njcn.process.service.RGeneralSurveyPlanDetailService;
import com.njcn.process.service.RGeneralSurveyPlanPOService; import com.njcn.process.service.RGeneralSurveyPlanPOService;
import com.njcn.process.service.impl.RSurveyPlanConfigService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook; 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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@@ -52,8 +54,10 @@ public class RGeneralSurveyPlanController extends BaseController {
private final RGeneralSurveyPlanPOService rGeneralSurveyPlanPOService; private final RGeneralSurveyPlanPOService rGeneralSurveyPlanPOService;
private @Autowired private final
RGeneralSurveyPlanDetailService rGeneralSurveyPlanDetailService; RGeneralSurveyPlanDetailService rGeneralSurveyPlanDetailService;
private final
RSurveyPlanConfigService rSurveyPlanConfigService;
/** /**
* @Description: 新增/修改普测计划 * @Description: 新增/修改普测计划
* @Param: [rGeneralSurveyPlanAddParm] * @Param: [rGeneralSurveyPlanAddParm]
@@ -72,7 +76,80 @@ public class RGeneralSurveyPlanController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, addFlag, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, addFlag, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addPlanCycle")
@ApiOperation("设置普测周期")
@ApiImplicitParam(name = "cycleNum", value = "普测周期", required = true)
public HttpResult<RSurveyCycleVO> 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<String> 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<List<DeptSubstationVO>> initDetpStataionTree(@RequestParam("orgId") String orgId ){
String methodDescribe = getMethodDescribe("initDetpStataionTree");
List<DeptSubstationVO> 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<Boolean> addPlanConfig(@Validated @RequestBody List<RSurveyPlanConfigVO> 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<RSurveyPlanConfigPO> 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<List<RSurveyPlanConfigVO>> queryPlanConfig(){
String methodDescribe = getMethodDescribe("queryPlanConfig");
List<RSurveyPlanConfigPO> list = rSurveyPlanConfigService.list ( );
List<RSurveyPlanConfigVO> 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<RGeneralSurveyPlanAddParm> 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) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryPlan") @PostMapping("/queryPlan")
@@ -118,16 +195,16 @@ public class RGeneralSurveyPlanController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rGeneralSurveyPlanVOS, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rGeneralSurveyPlanVOS, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON) // @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryPlandetail") // @PostMapping("/queryPlandetail")
@ApiOperation("根据planNO查询普测计划详情") // @ApiOperation("根据planNO查询普测计划详情")
@ApiImplicitParam(name = "rGeneralSurveyPlandetailQueryParm", value = "普测计划详情查询参数", required = true) // @ApiImplicitParam(name = "rGeneralSurveyPlandetailQueryParm", value = "普测计划详情查询参数", required = true)
public HttpResult<IPage<RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO>> queryPlandetail(@Validated @RequestBody RGeneralSurveyPlandetailQueryParm rGeneralSurveyPlandetailQueryParm){ // public HttpResult<IPage<RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO>> queryPlandetail(@Validated @RequestBody RGeneralSurveyPlandetailQueryParm rGeneralSurveyPlandetailQueryParm){
String methodDescribe = getMethodDescribe("queryPlandetail"); // String methodDescribe = getMethodDescribe("queryPlandetail");
//
IPage<RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO> rGeneralSurveyPlanDetailVOIPage = rGeneralSurveyPlanDetailService.queryPlandetail (rGeneralSurveyPlandetailQueryParm); // IPage<RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO> rGeneralSurveyPlanDetailVOIPage = rGeneralSurveyPlanDetailService.queryPlandetail (rGeneralSurveyPlandetailQueryParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rGeneralSurveyPlanDetailVOIPage, methodDescribe); // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rGeneralSurveyPlanDetailVOIPage, methodDescribe);
} // }

View File

@@ -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<RSurveyCyclePO> {
}

View File

@@ -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<RSurveyPlanConfigPO> {
}

View File

@@ -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;
/**
* <p>
* Mapper 接口
* </p>
*
* @author hongawen
* @since 2022-10-14
*/
public interface StatationStatMapper extends BaseMapper<StatationStat> {
/**
* 获取指定的变电站信息
*
* @param pmsStatationStatInfoParam 变电站详情数据入参
* @return 指定的变电站信息
*/
List<PmsStatationStatInfoDTO> getStatationStatInfo(@Param("pmsStatationStatInfoParam") PmsStatationStatInfoParam pmsStatationStatInfoParam);
/**
* 分页查询电站信息
* @author cdf
* @date 2022/11/18
*/
Page<StatationStatVO> getStatationStatPageList(Page<StatationStatVO> page, @Param("baseParam") BaseParam baseParam);
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.process.mapper.RSurveyCycleMapper">
<resultMap id="BaseResultMap" type="com.njcn.process.pojo.po.RSurveyCyclePO">
<!--@mbg.generated-->
<!--@Table r_survey_cycle-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="start_year" jdbcType="DATE" property="startYear" />
<result column="end_year" jdbcType="DATE" property="endYear" />
<result column="survey_cycle" jdbcType="INTEGER" property="surveyCycle" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, start_year, end_year, survey_cycle
</sql>
</mapper>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.process.mapper.RSurveyPlanConfigMapper">
<resultMap id="BaseResultMap" type="com.njcn.process.pojo.po.RSurveyPlanConfigPO">
<!--@mbg.generated-->
<!--@Table r_survey_plan_config-->
<id column="Id" jdbcType="CHAR" property="id" />
<result column="Org_Name" jdbcType="VARCHAR" property="orgName" />
<result column="Org_Id" jdbcType="CHAR" property="orgId" />
<result column="stat_num" jdbcType="INTEGER" property="statNum" />
<result column="proportion" jdbcType="FLOAT" property="proportion" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
Id, Org_Name, Org_Id, stat_num, proportion
</sql>
</mapper>

View File

@@ -5,10 +5,10 @@ import com.github.jeffreyning.mybatisplus.service.IMppService;
import com.njcn.minioss.bo.MinIoUploadResDTO; import com.njcn.minioss.bo.MinIoUploadResDTO;
import com.njcn.process.pojo.param.*; import com.njcn.process.pojo.param.*;
import com.njcn.process.pojo.po.RGeneralSurveyPlanPO; import com.njcn.process.pojo.po.RGeneralSurveyPlanPO;
import com.njcn.process.pojo.vo.SurveyPlanExcel; import com.njcn.process.pojo.vo.*;
import com.njcn.process.pojo.vo.RGeneralSurveyPlanDetailOnQuestionVO; import org.springframework.web.multipart.MultipartFile;
import com.njcn.process.pojo.vo.RGeneralSurveyPlanVO;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
@@ -86,4 +86,18 @@ public interface RGeneralSurveyPlanPOService extends IMppService<RGeneralSurveyP
* @Date: 2023/2/22 * @Date: 2023/2/22
*/ */
Boolean checkPlanAudit(RGeneralSurveyPlanChcekParm rGeneralSurveyPlanChcekParm); Boolean checkPlanAudit(RGeneralSurveyPlanChcekParm rGeneralSurveyPlanChcekParm);
void importSubStatation(MultipartFile file, HttpServletResponse response);
RGeneralSurveyPlanAddParm querySubStatation(Integer statetionNum);
List<DeptSubstationVO> initDetpStataionTree(String orgid);
/**
* @Description: 设置普测周期
* @Param: [cycleNum]
* @return: java.lang.Boolean
* @Author: clam
* @Date: 2023/3/15
*/
RSurveyCycleVO addPlanCycle(Integer cycleNum);
} }

View File

@@ -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<RSurveyCycleMapper, RSurveyCyclePO> implements RSurveyCycleService{
}

View File

@@ -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<RSurveyPlanConfigMapper, RSurveyPlanConfigPO> implements RSurveyPlanConfigService{
}

View File

@@ -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<StatationStat> {
}

View File

@@ -1,28 +1,42 @@
package com.njcn.process.service.impl; 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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; 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.common.pojo.exception.BusinessException;
import com.njcn.device.pms.pojo.po.StatationStat;
import com.njcn.minioss.bo.MinIoUploadResDTO; import com.njcn.minioss.bo.MinIoUploadResDTO;
import com.njcn.oss.constant.OssPath; import com.njcn.oss.constant.OssPath;
import com.njcn.oss.enums.OssResponseEnum; import com.njcn.oss.enums.OssResponseEnum;
import com.njcn.oss.utils.FileStorageUtil; import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.poi.util.PoiUtil;
import com.njcn.process.mapper.RGeneralSurveyPlanDetailMapper; import com.njcn.process.mapper.RGeneralSurveyPlanDetailMapper;
import com.njcn.process.mapper.RGeneralSurveyPlanPOMapper; import com.njcn.process.mapper.RGeneralSurveyPlanPOMapper;
import com.njcn.process.mapper.RSurveyCycleMapper;
import com.njcn.process.pojo.param.*; import com.njcn.process.pojo.param.*;
import com.njcn.process.pojo.po.RGeneralSurveyPlanDetail; import com.njcn.process.pojo.po.RGeneralSurveyPlanDetail;
import com.njcn.process.pojo.po.RGeneralSurveyPlanPO; import com.njcn.process.pojo.po.RGeneralSurveyPlanPO;
import com.njcn.process.pojo.vo.RGeneralSurveyPlanDetailOnQuestionVO; import com.njcn.process.pojo.po.RSurveyCyclePO;
import com.njcn.process.pojo.vo.RGeneralSurveyPlanVO; import com.njcn.process.pojo.po.RSurveyPlanConfigPO;
import com.njcn.process.pojo.vo.SurveyPlanExcel; import com.njcn.process.pojo.vo.*;
import com.njcn.process.service.RGeneralSurveyPlanDetailService; import com.njcn.process.service.RGeneralSurveyPlanDetailService;
import com.njcn.process.service.RGeneralSurveyPlanPOService; 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.api.DeptFeignClient;
import com.njcn.user.pojo.vo.PvTerminalTreeVO; import com.njcn.user.pojo.vo.PvTerminalTreeVO;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -32,7 +46,9 @@ import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -63,6 +79,17 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl<RGeneralSurv
@Resource @Resource
private FileStorageUtil fileStorageUtil; private FileStorageUtil fileStorageUtil;
@Autowired
private StatationStatService statationStatService;
@Autowired
private DicDataFeignClient dicDataFeignClient;
@Autowired
private RSurveyCycleMapper rSurveyCycleMapper;
@Autowired
private RSurveyPlanConfigService rSurveyPlanConfigService;
/** /**
* @param rGeneralSurveyPlanAddParm * @param rGeneralSurveyPlanAddParm
@@ -80,16 +107,27 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl<RGeneralSurv
BeanUtils.copyProperties (rGeneralSurveyPlanAddParm, rGeneralSurveyPlanPO); BeanUtils.copyProperties (rGeneralSurveyPlanAddParm, rGeneralSurveyPlanPO);
/*todo 后期与工作流绑定*/ /*todo 后期与工作流绑定*/
rGeneralSurveyPlanPO.setStatus (1); rGeneralSurveyPlanPO.setStatus (1);
/**查出周期id**/
QueryWrapper<RSurveyCyclePO> rSurveyCyclePOQueryWrapper = new QueryWrapper ( );
rSurveyCyclePOQueryWrapper.le ("start_year", rGeneralSurveyPlanPO.getPlanEndTime ( ));
rSurveyCyclePOQueryWrapper.ge ("end_year", rGeneralSurveyPlanPO.getPlanEndTime ( ));
RSurveyCyclePO rSurveyCyclePO = rSurveyCycleMapper.selectOne (rSurveyCyclePOQueryWrapper);
rGeneralSurveyPlanPO.setCycleId (rSurveyCyclePO.getId ( ));
boolean b = this.saveOrUpdateByMultiId (rGeneralSurveyPlanPO); boolean b = this.saveOrUpdateByMultiId (rGeneralSurveyPlanPO);
List<RGeneralSurveyPlanAddParm.RGeneralSurveyPlanDetailAddParm> rGeneralSurveyPlanDetailAddParm = rGeneralSurveyPlanAddParm.getRGeneralSurveyPlanDetailAddParm();
QueryWrapper<RGeneralSurveyPlanDetail> queryWrapper = new QueryWrapper ( ); QueryWrapper<RGeneralSurveyPlanDetail> queryWrapper = new QueryWrapper ( );
queryWrapper.lambda ( ).eq (RGeneralSurveyPlanDetail::getPlanNo, rGeneralSurveyPlanAddParm.getPlanNo ( )); queryWrapper.lambda ( ).eq (RGeneralSurveyPlanDetail::getPlanNo, rGeneralSurveyPlanAddParm.getPlanNo ( ));
rGeneralSurveyPlanDetailService.remove (queryWrapper); rGeneralSurveyPlanDetailService.remove (queryWrapper);
List<RGeneralSurveyPlanDetail> rGeneralSurveyPlanDetailList = new ArrayList<> ( ); List<RGeneralSurveyPlanDetail> rGeneralSurveyPlanDetailList = new ArrayList<> ( );
rGeneralSurveyPlanDetailAddParm.forEach(temp -> { rGeneralSurveyPlanAddParm.getSubIds ( ).forEach (temp -> {
StatationStat byId = statationStatService.getById (temp);
RGeneralSurveyPlanDetail rGeneralSurveyPlanDetail = new RGeneralSurveyPlanDetail ( ); RGeneralSurveyPlanDetail rGeneralSurveyPlanDetail = new RGeneralSurveyPlanDetail ( );
BeanUtils.copyProperties(temp, 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.setGeneralSurveyStartTime (rGeneralSurveyPlanAddParm.getPlanStartTime ( ));
rGeneralSurveyPlanDetail.setGeneralSurveyTime (rGeneralSurveyPlanAddParm.getPlanStartTime ( )); rGeneralSurveyPlanDetail.setGeneralSurveyTime (rGeneralSurveyPlanAddParm.getPlanStartTime ( ));
@@ -98,7 +136,7 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl<RGeneralSurv
rGeneralSurveyPlanDetail.setGeneralSurveyLeader (rGeneralSurveyPlanAddParm.getLeader ( )); rGeneralSurveyPlanDetail.setGeneralSurveyLeader (rGeneralSurveyPlanAddParm.getLeader ( ));
rGeneralSurveyPlanDetailList.add (rGeneralSurveyPlanDetail); rGeneralSurveyPlanDetailList.add (rGeneralSurveyPlanDetail);
}); });
boolean b1 = rGeneralSurveyPlanDetailService.saveOrUpdateBatchByMultiId(rGeneralSurveyPlanDetailList, 5); boolean b1 = rGeneralSurveyPlanDetailService.saveOrUpdateBatchByMultiId (rGeneralSurveyPlanDetailList, 500);
return b && b1; return b && b1;
} }
@@ -132,7 +170,7 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl<RGeneralSurv
queryWrapper.ge (RGeneralSurveyPlanPO::getPlanStartTime, rGeneralSurveyPlanQueryParm.getPlanStartTime ( )); queryWrapper.ge (RGeneralSurveyPlanPO::getPlanStartTime, rGeneralSurveyPlanQueryParm.getPlanStartTime ( ));
} }
if (!Objects.isNull (rGeneralSurveyPlanQueryParm.getPlanEndTime ( ))) { if (!Objects.isNull (rGeneralSurveyPlanQueryParm.getPlanEndTime ( ))) {
queryWrapper.le(RGeneralSurveyPlanPO::getPlanEndTime, rGeneralSurveyPlanQueryParm.getPlanEndTime()); queryWrapper.le (RGeneralSurveyPlanPO::getPlanStartTime, rGeneralSurveyPlanQueryParm.getPlanEndTime ( ));
} }
queryWrapper.in (RGeneralSurveyPlanPO::getStatus, statusList); queryWrapper.in (RGeneralSurveyPlanPO::getStatus, statusList);
queryWrapper.orderByAsc (RGeneralSurveyPlanPO::getStatus).orderByDesc (RGeneralSurveyPlanPO::getPlanCreateTime); queryWrapper.orderByAsc (RGeneralSurveyPlanPO::getStatus).orderByDesc (RGeneralSurveyPlanPO::getPlanCreateTime);
@@ -158,25 +196,27 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl<RGeneralSurv
rGeneralSurveyPlanPOS.forEach (temp -> { rGeneralSurveyPlanPOS.forEach (temp -> {
RGeneralSurveyPlanVO rGeneralSurveyPlanVO = new RGeneralSurveyPlanVO ( ); RGeneralSurveyPlanVO rGeneralSurveyPlanVO = new RGeneralSurveyPlanVO ( );
BeanUtils.copyProperties (temp, rGeneralSurveyPlanVO); BeanUtils.copyProperties (temp, rGeneralSurveyPlanVO);
long Busbarcount = rGeneralSurveyPlanDetails.stream(). List<String> collect1 = rGeneralSurveyPlanDetails.stream ( ).
filter (surveyPlanDetail -> Objects.equals (surveyPlanDetail.getPlanNo ( ), temp.getPlanNo ( ))). filter (surveyPlanDetail -> Objects.equals (surveyPlanDetail.getPlanNo ( ), temp.getPlanNo ( ))).
map(RGeneralSurveyPlanDetail::getBusbarId).distinct().count(); map (RGeneralSurveyPlanDetail::getSubId).collect (Collectors.toList ( ));
rGeneralSurveyPlanVO.setSubCount (collect1.size ( ));
rGeneralSurveyPlanVO.setSubIds (collect1);
/*
long Subcount = rGeneralSurveyPlanDetails.stream ( ). long Subcount = rGeneralSurveyPlanDetails.stream ( ).
filter (surveyPlanDetail -> Objects.equals (surveyPlanDetail.getPlanNo ( ), temp.getPlanNo ( ))). filter (surveyPlanDetail -> Objects.equals (surveyPlanDetail.getPlanNo ( ), temp.getPlanNo ( ))).
map(RGeneralSurveyPlanDetail::getSubId).distinct().count(); map (RGeneralSurveyPlanDetail::getSubId).distinct ( ).count ( );*/
rGeneralSurveyPlanVO.setBusCount(Busbarcount); // rGeneralSurveyPlanVO.setBusCount (Busbarcount);
rGeneralSurveyPlanVO.setSubCount(Subcount); // List<RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO> collect1 = rGeneralSurveyPlanDetails.stream ( ).
List<RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO> collect1 = rGeneralSurveyPlanDetails.stream(). // filter (surveyPlanDetail -> Objects.equals (surveyPlanDetail.getPlanNo ( ), temp.getPlanNo ( ))).
filter(surveyPlanDetail -> Objects.equals(surveyPlanDetail.getPlanNo(), temp.getPlanNo())). // map (surveyPlanDetail -> {
map(surveyPlanDetail -> { // RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO rGeneralSurveyPlanDetailVO = new RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO ( );
RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO rGeneralSurveyPlanDetailVO = new RGeneralSurveyPlanVO.RGeneralSurveyPlanDetailVO(); // BeanUtils.copyProperties (surveyPlanDetail, rGeneralSurveyPlanDetailVO);
BeanUtils.copyProperties(surveyPlanDetail, rGeneralSurveyPlanDetailVO); // return rGeneralSurveyPlanDetailVO;
return rGeneralSurveyPlanDetailVO; // }).collect (Collectors.toList ( ));
}).collect(Collectors.toList());
rGeneralSurveyPlanVO.setOrgName (pvTerminalTreeVOMap.get (temp.getOrgNo ( ))); //单位名称 rGeneralSurveyPlanVO.setOrgName (pvTerminalTreeVOMap.get (temp.getOrgNo ( ))); //单位名称
//
// rGeneralSurveyPlanVO.setRGeneralSurveyPlanDetailVOList (collect1);
rGeneralSurveyPlanVO.setRGeneralSurveyPlanDetailVOList(collect1);
rGeneralSurveyPlanVOList.add (rGeneralSurveyPlanVO); rGeneralSurveyPlanVOList.add (rGeneralSurveyPlanVO);
}); });
returnpage.setRecords (rGeneralSurveyPlanVOList); returnpage.setRecords (rGeneralSurveyPlanVOList);
@@ -349,4 +389,262 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl<RGeneralSurv
return result; 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<StatationStatExcel> terminalBaseList = ExcelImportUtil.importExcelMore (file.getInputStream ( ), StatationStatExcel.class, params);
//如果存在非法数据,将不合格的数据导出
/*规则1:StatationStat的orgName要在原系统存在2:电压等级不对*/
List<PvTerminalTreeVO> data = deptFeignClient.allDeptList ( ).getData ( );
Map<String, PvTerminalTreeVO> pvTerminalTreeVOMap = data.stream ( ).collect (Collectors.toMap (PvTerminalTreeVO::getName, pvTerminalTreeVO -> pvTerminalTreeVO));
//获取电压等级的字典
List<DictData> voltageLevelList = dicDataFeignClient.getDicDataByTypeCode (DicDataTypeEnum.DEV_VOLTAGE.getCode ( )).getData ( );
//将电压信息转成mapkeyid valuename
Map<String, DictData> voltageLevelMap = voltageLevelList.stream ( ).collect (Collectors.toMap (DictData::getName, voltageLevel -> voltageLevel));
List<StatationStatExcel> trueCollect = new ArrayList<> ( );
List<StatationStatExcel> 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<StatationStat> 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<StatationStat> list = statationStatService.list ( );
/**查出当前周期id**/
QueryWrapper<RSurveyCyclePO> rSurveyCyclePOQueryWrapper = new QueryWrapper ( );
rSurveyCyclePOQueryWrapper.le ("start_year", LocalDate.now ( ));
rSurveyCyclePOQueryWrapper.ge ("end_year", LocalDate.now ( ));
RSurveyCyclePO rSurveyCyclePO = rSurveyCycleMapper.selectOne (rSurveyCyclePOQueryWrapper);
LambdaQueryWrapper<RGeneralSurveyPlanPO> queryWrapper = new LambdaQueryWrapper<> ( );
queryWrapper.eq (RGeneralSurveyPlanPO::getCycleId, rSurveyCyclePO.getId ( ));
List<RGeneralSurveyPlanPO> rGeneralSurveyPlanPOS = rGeneralSurveyPlanPOMapper.selectList (queryWrapper);
List<String> planIds = rGeneralSurveyPlanPOS.stream ( ).map (RGeneralSurveyPlanPO::getPlanNo).collect (Collectors.toList ( ));
List<String> subIds = new ArrayList<> ( );
if (!CollectionUtils.isEmpty (planIds)) {
QueryWrapper<RGeneralSurveyPlanDetail> rGeneralSurveyPlanDetailQueryWrapper = new QueryWrapper ( );
rGeneralSurveyPlanDetailQueryWrapper.in ("plan_no", planIds);
List<RGeneralSurveyPlanDetail> rGeneralSurveyPlanDetails = rGeneralSurveyPlanDetailMapper.selectList (rGeneralSurveyPlanDetailQueryWrapper);
subIds = rGeneralSurveyPlanDetails.stream ( ).map (RGeneralSurveyPlanDetail::getSubId).collect (Collectors.toList ( ));
}
List<String> finalSubIds = subIds;
List<StatationStat> filterList = list.stream ( ).filter (temp -> !finalSubIds.contains (temp.getPowerId ( ))).collect (Collectors.toList ( ));
List<StatationStat> addList = new ArrayList<> ( );
List<RSurveyPlanConfigPO> rSurveyPlanConfigPOList = rSurveyPlanConfigService.list ( );
Map<String, RSurveyPlanConfigPO> orgIdMap = rSurveyPlanConfigPOList.stream ( ).
collect (Collectors.toMap (RSurveyPlanConfigPO::getOrgId, temp -> temp));
List<PvTerminalTreeVO> data = deptFeignClient.allDeptList ( ).getData ( );
data.stream ( ).forEach (temp -> {
DeptSubstationVO deptSubstationVO = new DeptSubstationVO ( );
BeanUtils.copyProperties (temp, deptSubstationVO);
/*如果存在电站占比配置随机抽出配置电站个数*/
if (orgIdMap.containsKey (temp.getId ( ))) {
List<StatationStat> 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<StatationStat> lastList = collect.stream ( ).limit (v).collect (Collectors.toList ( ));
addList.addAll (lastList);
} else {
addList.addAll (collect);
}
}
});
if (statetionNum > addList.size ( )) {
/*取差集,当通过比例抽取变电站不够时 重差集里取*/
List<StatationStat> collect = filterList.stream ( ).filter (o -> !addList.contains (o)).collect (Collectors.toList ( ));
int differenceCount = statetionNum - addList.size ( );
Collections.shuffle (collect);
List<StatationStat> lastList = collect.stream ( ).limit (differenceCount).collect (Collectors.toList ( ));
addList.addAll (lastList);
}
List<String> result = addList.stream ( ).map (StatationStat::getPowerId).collect (Collectors.toList ( ));
RGeneralSurveyPlanAddParm rGeneralSurveyPlanAddParm = new RGeneralSurveyPlanAddParm ( );
rGeneralSurveyPlanAddParm.setSubIds (result);
return rGeneralSurveyPlanAddParm;
}
@Override
public List<DeptSubstationVO> initDetpStataionTree(String orgdid) {
/*查询所有电站并过滤已经参加当期普测电站*/
List<StatationStat> list = statationStatService.list ( );
/**查出当前周期id**/
QueryWrapper<RSurveyCyclePO> 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<RSurveyCyclePO> 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<RGeneralSurveyPlanPO> queryWrapper1 = new LambdaQueryWrapper<> ( );
queryWrapper1.eq (RGeneralSurveyPlanPO::getCycleId, rSurveyCyclePO.getId ( ));
List<RGeneralSurveyPlanPO> rGeneralSurveyPlanPOS = rGeneralSurveyPlanPOMapper.selectList (queryWrapper1);
List<String> planIds = rGeneralSurveyPlanPOS.stream ( ).map (RGeneralSurveyPlanPO::getPlanNo).collect (Collectors.toList ( ));
List<String> subIds = new ArrayList<> ( );
if (!CollectionUtils.isEmpty (planIds)) {
QueryWrapper<RGeneralSurveyPlanDetail> rGeneralSurveyPlanDetailQueryWrapper = new QueryWrapper ( );
rGeneralSurveyPlanDetailQueryWrapper.in ("plan_no", planIds);
List<RGeneralSurveyPlanDetail> rGeneralSurveyPlanDetails = rGeneralSurveyPlanDetailMapper.selectList (rGeneralSurveyPlanDetailQueryWrapper);
subIds = rGeneralSurveyPlanDetails.stream ( ).map (RGeneralSurveyPlanDetail::getSubId).collect (Collectors.toList ( ));
}
List<String> finalSubIds = subIds;
List<PvTerminalTreeVO> data = deptFeignClient.allDeptList ( ).getData ( );
List<DeptSubstationVO> deptSubstationVOList = data.stream ( ).map (temp -> {
DeptSubstationVO deptSubstationVO = new DeptSubstationVO ( );
BeanUtils.copyProperties (temp, deptSubstationVO);
deptSubstationVO.setDisabled (true);
deptSubstationVO.setFlag (true);
QueryWrapper<StatationStat> queryWrapper = new QueryWrapper<> ( );
queryWrapper.eq ("org_id", temp.getCode ( ));
List<StatationStat> list1 = statationStatService.list (queryWrapper);
List<DeptSubstationVO> children = deptSubstationVO.getChildren ( );
List<DeptSubstationVO> 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<DeptSubstationVO> 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<RSurveyCyclePO> 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;
}
} }

View File

@@ -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<RSurveyCyclePO>{
}

View File

@@ -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<RSurveyPlanConfigPO> {
}

View File

@@ -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<StatationStatMapper,StatationStat> implements StatationStatService {
}