From e1347cd944f48aad353c29dcdefda2da5799911a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E6=9C=A8c?= <857448963@qq.com> Date: Tue, 4 Jul 2023 16:42:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=80=E6=9C=AF=E7=9B=91=E7=9D=A3=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/njcn/process/pojo/po/SupvProblem.java | 3 + .../controller/SupvProblemController.java | 6 +- .../service/impl/SupvPlanServiceImpl.java | 107 ++++++++++-------- .../service/impl/SupvProblemServiceImpl.java | 44 +++++-- .../service/impl/SupvReportMServiceImpl.java | 4 +- 5 files changed, 105 insertions(+), 59 deletions(-) diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvProblem.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvProblem.java index 63c115093..ec70b2b0d 100644 --- a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvProblem.java +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvProblem.java @@ -124,6 +124,9 @@ public class SupvProblem extends BaseEntity { */ private String remark; + @TableField(exist = false) + private String attachmentName; + } diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/controller/SupvProblemController.java b/pqs-process/process-boot/src/main/java/com/njcn/process/controller/SupvProblemController.java index ea5889a6c..9ec870a1e 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/controller/SupvProblemController.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/controller/SupvProblemController.java @@ -2,6 +2,7 @@ package com.njcn.process.controller; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.constant.OperateType; @@ -11,6 +12,7 @@ import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; import com.njcn.process.pojo.param.SupvProblemParam; +import com.njcn.process.pojo.po.SupvFile; import com.njcn.process.pojo.po.SupvProblem; import com.njcn.process.service.ISupvProblemService; import com.njcn.system.api.DicDataFeignClient; @@ -30,6 +32,7 @@ import com.njcn.web.controller.BaseController; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; @@ -52,6 +55,8 @@ public class SupvProblemController extends BaseController { + + @PostMapping("addProblem") @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) @ApiOperation("新增技术监督问题") @@ -92,7 +97,6 @@ public class SupvProblemController extends BaseController { throw new BusinessException("监督计划索引不可为空"); } Page page = iSupvProblemService.pageProblem(supvProblemParam); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } } diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPlanServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPlanServiceImpl.java index 1fc6ea02d..e5435606c 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPlanServiceImpl.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPlanServiceImpl.java @@ -15,9 +15,11 @@ import com.njcn.oss.utils.FileStorageUtil; import com.njcn.process.enums.ProcessResponseEnum; import com.njcn.process.mapper.SupvFileMapper; import com.njcn.process.mapper.SupvPlanMapper; +import com.njcn.process.mapper.SupvProblemMapper; import com.njcn.process.pojo.param.SupvPlanParam; 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.vo.SupvPlanVO; import com.njcn.process.service.ISupvFileService; import com.njcn.process.service.ISupvPlanService; @@ -45,7 +47,7 @@ import java.util.stream.Collectors; /** *

- * 服务实现类 + * 服务实现类 *

* * @author hongawen @@ -63,12 +65,14 @@ public class SupvPlanServiceImpl extends ServiceImpl i private final UserFeignClient userFeignClient; + private final SupvProblemMapper supvProblemMapper; + @Override public boolean addPlan(SupvPlanParam supvPlanParam) { - checkParam(supvPlanParam,false); + checkParam(supvPlanParam, false); SupvPlan supvPlan = new SupvPlan(); - BeanUtil.copyProperties(supvPlanParam,supvPlan); + BeanUtil.copyProperties(supvPlanParam, supvPlan); supvPlan.setPlanSupvDate(PubUtils.localDateFormat(supvPlanParam.getPlanSupvDate())); supvPlan.setEffectEndTime(PubUtils.localDateFormat(supvPlanParam.getEffectEndTime())); supvPlan.setEffectStartTime(PubUtils.localDateFormat(supvPlanParam.getEffectStartTime())); @@ -82,9 +86,9 @@ public class SupvPlanServiceImpl extends ServiceImpl i @Override public boolean updatePlan(SupvPlanParam supvPlanParam) { - checkParam(supvPlanParam,true); + checkParam(supvPlanParam, true); SupvPlan supvPlan = new SupvPlan(); - BeanUtil.copyProperties(supvPlanParam,supvPlan); + BeanUtil.copyProperties(supvPlanParam, supvPlan); supvPlan.setPlanSupvDate(PubUtils.localDateFormat(supvPlanParam.getPlanSupvDate())); supvPlan.setEffectEndTime(PubUtils.localDateFormat(supvPlanParam.getEffectEndTime())); supvPlan.setEffectStartTime(PubUtils.localDateFormat(supvPlanParam.getEffectStartTime())); @@ -97,53 +101,68 @@ public class SupvPlanServiceImpl extends ServiceImpl i @Override public boolean delPlan(List planIds) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(SupvPlan::getIsUploadHead,1).eq(SupvPlan::getPlanId,planIds); + lambdaQueryWrapper.eq(SupvPlan::getIsUploadHead, 1).eq(SupvPlan::getPlanId, planIds); int count = this.count(lambdaQueryWrapper); - if(count > 0){ + if (count > 0) { throw new BusinessException("请选择未上送国网的删除"); } - return this.removeByIds(planIds); + this.removeByIds(planIds); + //删除问题 + + LambdaQueryWrapper supvProblemLambdaQueryWrapper = new LambdaQueryWrapper<>(); + supvProblemLambdaQueryWrapper.in(SupvProblem::getPlanId, planIds); + List supvProblemList = this.supvProblemMapper.selectList(supvProblemLambdaQueryWrapper); + + this.supvProblemMapper.delete(supvProblemLambdaQueryWrapper); + + List busIds = supvProblemList.stream().map(SupvProblem::getProblemId).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(busIds)) { + LambdaQueryWrapper fileLambdaQueryWrapper = new LambdaQueryWrapper<>(); + fileLambdaQueryWrapper.in(SupvFile::getBusiId, busIds); + supvFileMapper.delete(fileLambdaQueryWrapper); + } + return true; } @Override public Page pagePlan(SupvPlanParam supvPlanParam) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - if(StrUtil.isNotBlank(supvPlanParam.getSupvOrgId())){ + if (StrUtil.isNotBlank(supvPlanParam.getSupvOrgId())) { List deptIds = deptFeignClient.getDepSonSelfCodetByCode(supvPlanParam.getSupvOrgId()).getData(); - lambdaQueryWrapper.in(SupvPlan::getSupvOrgId,deptIds).between(SupvPlan::getPlanSupvDate,supvPlanParam.getSearchBeginTime(),supvPlanParam.getSearchEndTime()); + lambdaQueryWrapper.in(SupvPlan::getSupvOrgId, deptIds).between(SupvPlan::getPlanSupvDate, supvPlanParam.getSearchBeginTime(), supvPlanParam.getSearchEndTime()); } List deptList = deptFeignClient.allDeptList().getData(); - Map mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity())); - Map mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity())); + Map mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity())); + Map mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity())); - Page page = this.page(new Page<>(PageFactory.getPageNum(supvPlanParam), PageFactory.getPageSize(supvPlanParam)),lambdaQueryWrapper); - List supvPlanVOList = BeanUtil.copyToList(page.getRecords(),SupvPlanVO.class); + Page page = this.page(new Page<>(PageFactory.getPageNum(supvPlanParam), PageFactory.getPageSize(supvPlanParam)), lambdaQueryWrapper); + List supvPlanVOList = BeanUtil.copyToList(page.getRecords(), SupvPlanVO.class); List userIds = supvPlanVOList.stream().map(SupvPlanVO::getCreateBy).distinct().collect(Collectors.toList()); - supvPlanVOList.forEach(item->{ + supvPlanVOList.forEach(item -> { PvTerminalTreeVO pvTerminalTreeVO = null; - if(mapCode.containsKey(item.getSupvOrgId())) { + if (mapCode.containsKey(item.getSupvOrgId())) { pvTerminalTreeVO = mapCode.get(item.getSupvOrgId()); item.setSupvOrgName(pvTerminalTreeVO.getName()); int deptLevel = pvTerminalTreeVO.getPids().split(StrUtil.COMMA).length; - if(deptLevel == 2){ + if (deptLevel == 2) { //省 item.setProvince(pvTerminalTreeVO.getName()); - }else if(deptLevel == 3){ + } else if (deptLevel == 3) { //市 item.setCity(pvTerminalTreeVO.getName()); - if(mapList.containsKey(pvTerminalTreeVO.getPid())) { + if (mapList.containsKey(pvTerminalTreeVO.getPid())) { PvTerminalTreeVO pvTerminalTreeOne = mapList.get(pvTerminalTreeVO.getPid()); item.setProvince(pvTerminalTreeOne.getName()); } - }else if(deptLevel == 4){ + } else if (deptLevel == 4) { //县 - if(mapList.containsKey(pvTerminalTreeVO.getPid())) { + 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())) { + if (mapList.containsKey(pvTerminalTreeOne.getPid())) { PvTerminalTreeVO pvTerminalTreeTwo = mapList.get(pvTerminalTreeOne.getPid()); if (Objects.nonNull(pvTerminalTreeTwo)) { item.setProvince(pvTerminalTreeTwo.getName()); @@ -154,24 +173,23 @@ public class SupvPlanServiceImpl extends ServiceImpl i } } - if(mapCode.containsKey(item.getPlanOrgId())) { + if (mapCode.containsKey(item.getPlanOrgId())) { item.setPlanOrgName(mapCode.get(item.getPlanOrgId()).getName()); } - SupvFile supvFile = supvFileMapper.selectOne(new LambdaQueryWrapper().eq(SupvFile::getBusiId,item.getPlanId()).eq(SupvFile::getType,0)); - if(Objects.nonNull(supvFile)){ + SupvFile supvFile = supvFileMapper.selectOne(new LambdaQueryWrapper().eq(SupvFile::getBusiId, item.getPlanId()).eq(SupvFile::getType, 0)); + if (Objects.nonNull(supvFile)) { item.setAttachmentName(supvFile.getAttachmentName()); } - List userList= userFeignClient.getUserByIdList(userIds).getData(); - Map map = userList.stream().collect(Collectors.toMap(User::getId,Function.identity())); + List userList = userFeignClient.getUserByIdList(userIds).getData(); + Map map = userList.stream().collect(Collectors.toMap(User::getId, Function.identity())); - if(map.containsKey(item.getCreateBy())) { + if (map.containsKey(item.getCreateBy())) { item.setCreateBy(map.get(item.getCreateBy()).getName()); } - }); Page pageVo = new Page<>(); pageVo.setTotal(page.getTotal()); @@ -182,14 +200,12 @@ public class SupvPlanServiceImpl extends ServiceImpl i } - - - private void checkParam(SupvPlanParam supvPlanParam,Boolean updateFlag){ + private void checkParam(SupvPlanParam supvPlanParam, Boolean updateFlag) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(SupvPlan::getWorkPlanName,supvPlanParam.getWorkPlanName()); + lambdaQueryWrapper.eq(SupvPlan::getWorkPlanName, supvPlanParam.getWorkPlanName()); - if(updateFlag) { + if (updateFlag) { if (supvPlanParam instanceof SupvPlanParam.UpdateSupvPlanParam) { //修改 lambdaQueryWrapper.ne(SupvPlan::getPlanId, ((SupvPlanParam.UpdateSupvPlanParam) supvPlanParam).getPlanId()); @@ -197,40 +213,39 @@ public class SupvPlanServiceImpl extends ServiceImpl i } int count = this.count(lambdaQueryWrapper); - if(count>0){ + if (count > 0) { throw new BusinessException(ProcessResponseEnum.SUPV_PLAN_REPEAT); } //判断监督对象类型 - if(StrUtil.isNotBlank(supvPlanParam.getSupvObjType())){ + if (StrUtil.isNotBlank(supvPlanParam.getSupvObjType())) { DictData dictData = dicDataFeignClient.getDicDataById(supvPlanParam.getSupvType()).getData(); - if(dictData.getCode().equals(DicDataEnum.New_Energy.getCode())){ - if(StrUtil.isBlank(supvPlanParam.getSupvObjType())){ + if (dictData.getCode().equals(DicDataEnum.New_Energy.getCode())) { + if (StrUtil.isBlank(supvPlanParam.getSupvObjType())) { throw new BusinessException("监督对象类型不可为空"); } - if(StrUtil.isBlank(supvPlanParam.getObjType())){ + if (StrUtil.isBlank(supvPlanParam.getObjType())) { throw new BusinessException("监督对象属性名称不可为空"); } - if(Objects.isNull(supvPlanParam.getObjCapacity())){ + if (Objects.isNull(supvPlanParam.getObjCapacity())) { throw new BusinessException("监督对象协议容量不可为空"); } - }else if(!dictData.getCode().equals(DicDataEnum.Technical_Super.getCode())){ - if(StrUtil.isBlank(supvPlanParam.getSupvObjName())){ + } else if (!dictData.getCode().equals(DicDataEnum.Technical_Super.getCode())) { + if (StrUtil.isBlank(supvPlanParam.getSupvObjName())) { throw new BusinessException("监督对象名称不可为空"); } - if(StrUtil.isBlank(supvPlanParam.getObjVoltageLevel())){ + if (StrUtil.isBlank(supvPlanParam.getObjVoltageLevel())) { throw new BusinessException("监督对象电压等级不可为空"); } - }else if(!dictData.getCode().equals(DicDataEnum.POWER_QUALITY.getCode())){ - if(Objects.isNull(supvPlanParam.getObjCapacity())){ + } else if (!dictData.getCode().equals(DicDataEnum.POWER_QUALITY.getCode())) { + if (Objects.isNull(supvPlanParam.getObjCapacity())) { throw new BusinessException("监督对象协议容量不可为空"); } } } - } diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvProblemServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvProblemServiceImpl.java index 900024304..9fbaeb37b 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvProblemServiceImpl.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvProblemServiceImpl.java @@ -2,14 +2,18 @@ package com.njcn.process.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.utils.PubUtils; +import com.njcn.oss.utils.FileStorageUtil; import com.njcn.process.enums.ProcessResponseEnum; +import com.njcn.process.mapper.SupvFileMapper; import com.njcn.process.mapper.SupvProblemMapper; import com.njcn.process.pojo.param.SupvProblemParam; +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.SupvProblem; @@ -23,12 +27,13 @@ import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; /** *

- * 服务实现类 + * 服务实现类 *

* * @author hongawen @@ -42,10 +47,14 @@ public class SupvProblemServiceImpl extends ServiceImpl problemIds) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(SupvProblem::getIsUploadHead,1).eq(SupvProblem::getProblemId,problemIds); + lambdaQueryWrapper.eq(SupvProblem::getIsUploadHead, 1).eq(SupvProblem::getProblemId, problemIds); int count = this.count(lambdaQueryWrapper); - if(count > 0){ + if (count > 0) { throw new BusinessException("请选择未上送国网的删除"); } - return this.removeByIds(problemIds); + this.removeByIds(problemIds); + if (CollUtil.isNotEmpty(problemIds)) { + LambdaQueryWrapper fileLambdaQueryWrapper = new LambdaQueryWrapper<>(); + fileLambdaQueryWrapper.in(SupvFile::getBusiId, problemIds); + List supvFileList = supvFileMapper.selectList(fileLambdaQueryWrapper); + supvFileList.forEach(item-> fileStorageUtil.downloadStream(item.getFileUrl())); + supvFileMapper.delete(fileLambdaQueryWrapper); + } + return true; } @Override public Page pageProblem(SupvProblemParam supvProblemParam) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(SupvProblem::getPlanId,supvProblemParam.getPlanId()); - Page page = this.page(new Page<>(PageFactory.getPageNum(supvProblemParam), PageFactory.getPageSize(supvProblemParam)),lambdaQueryWrapper); + lambdaQueryWrapper.eq(SupvProblem::getPlanId, supvProblemParam.getPlanId()); + Page page = this.page(new Page<>(PageFactory.getPageNum(supvProblemParam), PageFactory.getPageSize(supvProblemParam)), lambdaQueryWrapper); List deptList = deptFeignClient.allDeptList().getData(); - Map mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity())); + Map mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity())); for (SupvProblem item : page.getRecords()) { - if(mapCode.containsKey(item.getDutyOrgId())) { + if (mapCode.containsKey(item.getDutyOrgId())) { item.setDutyOrgName(mapCode.get(item.getDutyOrgId()).getName()); } + + SupvFile supvFile = supvFileMapper.selectOne(new LambdaQueryWrapper().eq(SupvFile::getBusiId, item.getProblemId()).eq(SupvFile::getType, 1)); + if (Objects.nonNull(supvFile)) { + item.setAttachmentName(supvFile.getAttachmentName()); + } + } return page; } - } diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvReportMServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvReportMServiceImpl.java index 06f2b3463..d05133e64 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvReportMServiceImpl.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvReportMServiceImpl.java @@ -24,6 +24,7 @@ import com.njcn.system.enums.DicDataEnum; 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 com.njcn.web.factory.PageFactory; import com.njcn.web.pojo.param.BaseParam; @@ -263,7 +264,8 @@ public class SupvReportMServiceImpl extends MppServiceImpl statisticReportPage(BaseParam baseParam) { List deptCodes = new ArrayList<>(); if(StrUtil.isNotBlank(baseParam.getSearchValue())){ - deptCodes = deptFeignClient.getDepSonSelfCodetByCode(baseParam.getSearchValue()).getData(); + ListdeptList = deptFeignClient.getDirectSonSelf(baseParam.getSearchValue()).getData(); + deptCodes = deptList.stream().map(Dept::getCode).collect(Collectors.toList()); } LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.in(StrUtil.isNotBlank(baseParam.getSearchValue()),SupvReportM::getStatisticsDept,deptCodes)