技术监督管理

This commit is contained in:
2023-06-28 15:58:46 +08:00
parent 2eb2a41744
commit 970cd5b3dd
20 changed files with 765 additions and 47 deletions

View File

@@ -22,7 +22,7 @@ public interface ISupvFileService extends IService<SupvFile> {
* @author cdf
* @date 2023/6/25
*/
boolean planUpload(MultipartFile file,String planId, Integer type);
boolean planUpload(MultipartFile file,String planId, Integer type,String attachmentType);
String detail(HttpServletResponse response,String busId,Integer type);

View File

@@ -0,0 +1,50 @@
package com.njcn.process.service;
import java.util.List;
/**
* pqs
*
* @author cdf
* @date 2023/6/28
*/
public interface SupvPushGwService {
/**
*
* @author cdf
* @date 2023/6/28
*/
boolean pushPlan(List<String> planIds);
/**
*
* @author cdf
* @date 2023/6/28
*/
boolean pushQuestion(List<String> problemIds);
/**
*
* @author cdf
* @date 2023/6/28
*/
boolean pushFile(List<String> busIds);
/**
*
* @author cdf
* @date 2023/6/28
*/
boolean pushMonthReportStatistic(List<String> monthReportId);
/**
*
* @author cdf
* @date 2023/6/28
*/
boolean deletePlan(List<String> planIds);
}

View File

@@ -9,11 +9,13 @@ import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.process.mapper.SupvFileMapper;
import com.njcn.process.pojo.po.SupvFile;
import com.njcn.process.service.ISupvFileService;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.Objects;
/**
@@ -34,20 +36,23 @@ public class SupvFileServiceImpl extends ServiceImpl<SupvFileMapper, SupvFile> i
private final SupvFileMapper supvFileMapper;
@Override
public boolean planUpload(MultipartFile file, String planId, Integer type) {
public boolean planUpload(MultipartFile file, String planId, Integer type,String attachmentType) {
SupvFile supvFile = this.getOne(new LambdaQueryWrapper<SupvFile>().eq(SupvFile::getBusiId,planId).eq(SupvFile::getType,type));
String url = fileStorageUtil.uploadMultipart(file, OssPath.SURVEY_RESULT);
SupvFile supvFilePO = new SupvFile();
supvFilePO.setAttachmentName(file.getOriginalFilename());
supvFilePO.setFile(url);
supvFilePO.setFileUrl(url);
if(Objects.nonNull(supvFile)){
fileStorageUtil.deleteFile(supvFile.getFile());
supvFilePO.setId(supvFile.getId());
fileStorageUtil.deleteFile(supvFile.getFileUrl());
supvFilePO.setUuid(supvFile.getUuid());
return this.updateById(supvFilePO);
}
supvFilePO.setAttachmentType("01");
supvFilePO.setAttachmentType(attachmentType);
supvFilePO.setBusiId(planId);
supvFilePO.setType(type);
supvFilePO.setUploaderId(RequestUtil.getUserIndex());
supvFilePO.setUploadTime(LocalDateTime.now());
supvFilePO.setUploaderName(RequestUtil.getUsername());
return this.save(supvFilePO);
}
@@ -55,7 +60,7 @@ public class SupvFileServiceImpl extends ServiceImpl<SupvFileMapper, SupvFile> i
public String detail(HttpServletResponse response,String busId, Integer type) {
SupvFile supvFile = this.getOne(new LambdaQueryWrapper<SupvFile>().eq(SupvFile::getBusiId,busId).eq(SupvFile::getType,type));
if(Objects.nonNull(supvFile)){
fileStorageUtil.downloadStream(response,supvFile.getFile());
fileStorageUtil.downloadStream(response,supvFile.getFileUrl());
return null;
}else {
throw new BusinessException("不存在附件");

View File

@@ -22,6 +22,8 @@ import com.njcn.process.pojo.vo.SupvPlanVO;
import com.njcn.process.service.ISupvFileService;
import com.njcn.process.service.ISupvPlanService;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.api.UserFeignClient;
import com.njcn.user.pojo.po.User;
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.RequestUtil;
@@ -54,6 +56,8 @@ public class SupvPlanServiceImpl extends ServiceImpl<SupvPlanMapper, SupvPlan> i
private final SupvFileMapper supvFileMapper;
private final UserFeignClient userFeignClient;
@Override
public boolean addPlan(SupvPlanParam supvPlanParam) {
@@ -61,12 +65,13 @@ public class SupvPlanServiceImpl extends ServiceImpl<SupvPlanMapper, SupvPlan> i
SupvPlan supvPlan = new SupvPlan();
BeanUtil.copyProperties(supvPlanParam,supvPlan);
supvPlan.setPlanSupvDate(PubUtils.localDateFormat(supvPlanParam.getPlanSupvDate()));
supvPlan.setSupvEndTime(PubUtils.localDateFormat(supvPlanParam.getSupvEndTime()));
supvPlan.setSupvStartTime(PubUtils.localDateFormat(supvPlanParam.getSupvStartTime()));
supvPlan.setEffectEndTime(PubUtils.localDateFormat(supvPlanParam.getEffectEndTime()));
supvPlan.setEffectStartTime(PubUtils.localDateFormat(supvPlanParam.getEffectStartTime()));
supvPlan.setProblemOcTime(PubUtils.localDateTimeFormat(supvPlanParam.getProblemOcTime()));
supvPlan.setReportIssueTime(PubUtils.localDateTimeFormat(supvPlanParam.getReportIssueTime()));
supvPlan.setIsUploadHead(0);
supvPlan.setPlanUserId(RequestUtil.getUserIndex());
this.save(supvPlan);
return true;
}
@@ -77,8 +82,8 @@ public class SupvPlanServiceImpl extends ServiceImpl<SupvPlanMapper, SupvPlan> i
SupvPlan supvPlan = new SupvPlan();
BeanUtil.copyProperties(supvPlanParam,supvPlan);
supvPlan.setPlanSupvDate(PubUtils.localDateFormat(supvPlanParam.getPlanSupvDate()));
supvPlan.setSupvEndTime(PubUtils.localDateFormat(supvPlanParam.getSupvEndTime()));
supvPlan.setSupvStartTime(PubUtils.localDateFormat(supvPlanParam.getSupvStartTime()));
supvPlan.setEffectEndTime(PubUtils.localDateFormat(supvPlanParam.getEffectEndTime()));
supvPlan.setEffectStartTime(PubUtils.localDateFormat(supvPlanParam.getEffectStartTime()));
supvPlan.setProblemOcTime(PubUtils.localDateTimeFormat(supvPlanParam.getProblemOcTime()));
supvPlan.setReportIssueTime(PubUtils.localDateTimeFormat(supvPlanParam.getReportIssueTime()));
this.updateById(supvPlan);
@@ -100,7 +105,7 @@ public class SupvPlanServiceImpl extends ServiceImpl<SupvPlanMapper, SupvPlan> i
public Page<SupvPlanVO> pagePlan(SupvPlanParam supvPlanParam) {
LambdaQueryWrapper<SupvPlan> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if(StrUtil.isNotBlank(supvPlanParam.getSupvOrgId())){
List<String> deptIds = deptFeignClient.getDepSonSelfCodetByDeptId(supvPlanParam.getSupvOrgId()).getData();
List<String> deptIds = deptFeignClient.getDepSonSelfCodetByCode(supvPlanParam.getSupvOrgId()).getData();
lambdaQueryWrapper.in(SupvPlan::getSupvOrgId,deptIds);
}
List<PvTerminalTreeVO> deptList = deptFeignClient.allDeptList().getData();
@@ -110,20 +115,35 @@ public class SupvPlanServiceImpl extends ServiceImpl<SupvPlanMapper, SupvPlan> i
Page<SupvPlan> page = this.page(new Page<>(PageFactory.getPageNum(supvPlanParam), PageFactory.getPageSize(supvPlanParam)),lambdaQueryWrapper);
List<SupvPlanVO> supvPlanVOList = BeanUtil.copyToList(page.getRecords(),SupvPlanVO.class);
List<String> userIds = supvPlanVOList.stream().map(SupvPlanVO::getCreateBy).distinct().collect(Collectors.toList());
supvPlanVOList.forEach(item->{
PvTerminalTreeVO pvTerminalTreeVO = null;
if(mapCode.containsKey(item.getSupvOrgId())) {
pvTerminalTreeVO = mapCode.get(item.getSupvOrgId());
item.setSupvOrgName(pvTerminalTreeVO.getName());
item.setCounty(pvTerminalTreeVO.getName());
if(mapList.containsKey(pvTerminalTreeVO.getPid())) {
PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid());
if (Objects.nonNull(pvTerminalTreeOne)) {
item.setCity(pvTerminalTreeOne.getName());
if(mapList.containsKey(pvTerminalTreeOne.getPid())) {
PvTerminalTreeVO pvTerminalTreeTwo = mapList.get(pvTerminalTreeOne.getPid());
if (Objects.nonNull(pvTerminalTreeTwo)) {
item.setProvince(pvTerminalTreeTwo.getName());
int deptLevel = pvTerminalTreeVO.getPids().split(StrUtil.COMMA).length;
if(deptLevel == 2){
//省
item.setProvince(pvTerminalTreeVO.getName());
}else if(deptLevel == 3){
//市
item.setCity(pvTerminalTreeVO.getName());
if(mapList.containsKey(pvTerminalTreeVO.getPid())) {
PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid());
item.setProvince(pvTerminalTreeOne.getName());
}
}else if(deptLevel == 4){
//县
if(mapList.containsKey(pvTerminalTreeVO.getPid())) {
item.setCounty(pvTerminalTreeVO.getName());
PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid());
if (Objects.nonNull(pvTerminalTreeOne)) {
item.setCity(pvTerminalTreeOne.getName());
if(mapList.containsKey(pvTerminalTreeOne.getPid())) {
PvTerminalTreeVO pvTerminalTreeTwo = mapList.get(pvTerminalTreeOne.getPid());
if (Objects.nonNull(pvTerminalTreeTwo)) {
item.setProvince(pvTerminalTreeTwo.getName());
}
}
}
}
@@ -138,6 +158,13 @@ public class SupvPlanServiceImpl extends ServiceImpl<SupvPlanMapper, SupvPlan> i
if(Objects.nonNull(supvFile)){
item.setAttachmentName(supvFile.getAttachmentName());
}
List<User> userList= userFeignClient.getUserByIdList(userIds).getData();
Map<String, User> map = userList.stream().collect(Collectors.toMap(User::getId,Function.identity()));
if(map.containsKey(item.getCreateBy())) {
item.setCreateBy(map.get(item.getCreateBy()).getName());
}
});
Page<SupvPlanVO> pageVo = new Page<>();
pageVo.setTotal(page.getTotal());

View File

@@ -0,0 +1,240 @@
package com.njcn.process.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.process.mapper.SupvFileMapper;
import com.njcn.process.mapper.SupvPlanMapper;
import com.njcn.process.mapper.SupvProblemMapper;
import com.njcn.process.mapper.SupvReportMMapper;
import com.njcn.process.pojo.dto.supv.PlanProblemData;
import com.njcn.process.pojo.dto.supv.WorkPlanData;
import com.njcn.process.pojo.po.SupvFile;
import com.njcn.process.pojo.po.SupvPlan;
import com.njcn.process.pojo.po.SupvProblem;
import com.njcn.process.pojo.po.SupvReportM;
import com.njcn.process.service.SupvPushGwService;
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.po.Dept;
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
import liquibase.pro.packaged.W;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* pqs
*
* @author cdf
* @date 2023/6/28
*/
@Service
@RequiredArgsConstructor
public class SupvPushGwServiceImpl implements SupvPushGwService {
private final SupvPlanMapper supvPlanMapper;
private final SupvProblemMapper supvProblemMapper;
private final SupvFileMapper supvFileMapper;
private final SupvReportMMapper supvReportMMapper;
private final DicDataFeignClient dicDataFeignClient;
private final DeptFeignClient deptFeignClient;
@Override
public boolean pushPlan(List<String> planIds) {
LambdaQueryWrapper<SupvPlan> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(SupvPlan::getPlanId,planIds);
List<SupvPlan> supvPlanList = supvPlanMapper.selectList(lambdaQueryWrapper);
if(CollUtil.isEmpty(supvPlanList)){
return false;
}
List<PvTerminalTreeVO> deptList = deptFeignClient.allDeptList().getData();
Map<String,PvTerminalTreeVO> mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity()));
Map<String,PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity()));
List<DictData> supvDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_TYPE.getCode()).getData();
Map<String, DictData> mapType = supvDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity()));
List<DictData> supvStateDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_STAGE.getCode()).getData();
Map<String, DictData> mapSupvState = supvStateDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity()));
List<DictData> supveffectDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EFFECT_STATUS.getCode()).getData();
Map<String, DictData> mapSupvEffect = supveffectDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity()));
List<DictData> supvObjTypeDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_OBJ_TYPE.getCode()).getData();
Map<String, DictData> mapObjType = supvObjTypeDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity()));
List<DictData> supvVoltageDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
Map<String, DictData> mapVoltage = supvVoltageDicList.stream().collect(Collectors.toMap(DictData::getId,Function.identity()));
List<WorkPlanData> workPlanDataList = new ArrayList<>();
for(SupvPlan supvPlan:supvPlanList){
WorkPlanData workPlanData = new WorkPlanData();
BeanUtil.copyProperties(supvPlan,workPlanData);
PvTerminalTreeVO pvTerminalTreeVO = null;
if(mapCode.containsKey(supvPlan.getSupvOrgId())) {
pvTerminalTreeVO = mapCode.get(supvPlan.getSupvOrgId());
workPlanData.setSupvOrgName(pvTerminalTreeVO.getName());
int deptLevel = pvTerminalTreeVO.getPids().split(StrUtil.COMMA).length;
if(deptLevel == 2){
//省
workPlanData.setProvinceName(pvTerminalTreeVO.getName());
}else if(deptLevel == 3){
//市
workPlanData.setCityName(pvTerminalTreeVO.getName());
if(mapList.containsKey(pvTerminalTreeVO.getPid())) {
PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid());
workPlanData.setProvinceName(pvTerminalTreeOne.getName());
}
}else if(deptLevel == 4){
//县
if(mapList.containsKey(pvTerminalTreeVO.getPid())) {
workPlanData.setCountyName(pvTerminalTreeVO.getName());
PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid());
if (Objects.nonNull(pvTerminalTreeOne)) {
workPlanData.setCityName(pvTerminalTreeOne.getName());
if(mapList.containsKey(pvTerminalTreeOne.getPid())) {
PvTerminalTreeVO pvTerminalTreeTwo = mapList.get(pvTerminalTreeOne.getPid());
if (Objects.nonNull(pvTerminalTreeTwo)) {
workPlanData.setProvinceName(pvTerminalTreeTwo.getName());
}
}
}
}
}
}
//处理字典
//监督类型编码
if(mapType.containsKey(workPlanData.getSupvType())) {
workPlanData.setSupvType(String.format("%02d", mapType.get(workPlanData.getSupvType()).getAlgoDescribe()));
}
//监督类型编码
if(mapType.containsKey(workPlanData.getSupvStage())) {
workPlanData.setSupvStage(String.format("%02d", mapSupvState.get(workPlanData.getSupvType()).getAlgoDescribe()));
}
//监督阶段
if(mapType.containsKey(workPlanData.getEffectStatus())) {
workPlanData.setEffectStatus(String.format("%02d", mapSupvState.get(workPlanData.getEffectStatus()).getAlgoDescribe()));
}
//监督对象类型
if(mapType.containsKey(workPlanData.getSupvType())) {
workPlanData.setSupvType(String.format("%02d", mapSupvState.get(workPlanData.getSupvType()).getAlgoDescribe()));
}
//电站等级
if(mapType.containsKey(workPlanData.getSubstationVoltageLevel())) {
workPlanData.setSubstationVoltageLevel(String.format("%02d", mapSupvState.get(workPlanData.getSubstationVoltageLevel()).getAlgoDescribe()));
}
workPlanDataList.add(workPlanData);
}
if(workPlanDataList.size()>100){
throw new BusinessException("一次最多上送100条数据");
}
//TODO 调用国网接口
return true;
}
@Override
public boolean pushQuestion(List<String> problemIds) {
LambdaQueryWrapper<SupvProblem> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(SupvProblem::getProblemId,problemIds);
List<SupvProblem> supvProblemList = supvProblemMapper.selectList(lambdaQueryWrapper);
List<DictData> monitorTypeList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.MONITOR_TYPE.getCode()).getData();
Map<String, DictData> mapMonitorType = monitorTypeList.stream().collect(Collectors.toMap(DictData::getId,Function.identity()));
List<DictData> problemTypeList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_PROBLEM_TYPE.getCode()).getData();
Map<String, DictData> mapProblemType = problemTypeList.stream().collect(Collectors.toMap(DictData::getId,Function.identity()));
List<DictData> reList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.RECTIFICATION_MEASURE.getCode()).getData();
Map<String, DictData> mapRe = reList.stream().collect(Collectors.toMap(DictData::getId,Function.identity()));
List<PlanProblemData> planProblemDataList = new ArrayList<>();
for(SupvProblem supvProblem : supvProblemList){
PlanProblemData planProblemData = new PlanProblemData();
BeanUtil.copyProperties(supvProblem,planProblemData);
Dept dept = deptFeignClient.getDeptByCode(planProblemData.getDutyOrgId()).getData();
planProblemData.setDutyOrgName(dept.getName());
if(mapMonitorType.containsKey(planProblemData.getMonitorType())){
planProblemData.setMonitorType(String.format("%02d",mapMonitorType.get(planProblemData.getMonitorType()).getAlgoDescribe()));
}
if(mapProblemType.containsKey(planProblemData.getProblemType())){
planProblemData.setProblemType(String.format("%02d",mapMonitorType.get(planProblemData.getMonitorType()).getAlgoDescribe()));
}
if(mapRe.containsKey(planProblemData.getRectificationMeasure())){
planProblemData.setRectificationMeasure(String.format("%02d",mapMonitorType.get(planProblemData.getRectificationMeasure()).getAlgoDescribe()));
}
planProblemDataList.add(planProblemData);
}
if(planProblemDataList.size()>100){
throw new BusinessException("一次最多上送100条数据");
}
//TODO
// 目前一个问题对应一个措施,上送一个问题需要调用问题接口和整改措施接口
return true;
}
@Override
public boolean pushFile(List<String> busIds) {
LambdaQueryWrapper<SupvFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SupvFile::getBusiId,busIds);
List<SupvFile> supvFiles = supvFileMapper.selectList(lambdaQueryWrapper);
if(supvFiles.size()>100){
throw new BusinessException("一次最多上送100条数据");
}
//TODO 调用上送接口
return true;
}
@Override
public boolean pushMonthReportStatistic(List<String> monthReportId) {
LambdaQueryWrapper<SupvReportM> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SupvReportM::getMonthReportId,monthReportId);
List<SupvReportM> supvReportMList = supvReportMMapper.selectList(lambdaQueryWrapper);
if(supvReportMList.size()>100){
throw new BusinessException("一次最多上送100条数据");
}
//TODO 调用上送接口
return true;
}
@Override
public boolean deletePlan(List<String> planIds) {
return false;
}
}

View File

@@ -235,10 +235,14 @@ public class SupvReportMServiceImpl extends MppServiceImpl<SupvReportMMapper, Su
@Override
public Page<SupvReportM> statisticReportPage(BaseParam baseParam) {
List<String> deptCodes = new ArrayList<>();
if(StrUtil.isNotBlank(baseParam.getSearchValue())){
deptCodes = deptFeignClient.getDepSonSelfCodetByCode(baseParam.getSearchValue()).getData();
}
LambdaQueryWrapper<SupvReportM> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(StrUtil.isNotBlank(baseParam.getSearchValue()),SupvReportM::getStatisticsDept,baseParam.getSearchValue())
lambdaQueryWrapper.in(StrUtil.isNotBlank(baseParam.getSearchValue()),SupvReportM::getStatisticsDept,deptCodes)
.between(StrUtil.isNotBlank(baseParam.getSearchBeginTime()),SupvReportM::getStatisticsDate,baseParam.getSearchBeginTime(),baseParam.getSearchEndTime());
return this.page(new Page<SupvReportM>(PageFactory.getPageNum(baseParam),PageFactory.getPageSize(baseParam)),lambdaQueryWrapper);
return this.page(new Page<>(PageFactory.getPageNum(baseParam),PageFactory.getPageSize(baseParam)),lambdaQueryWrapper);
}