From 932f24fcd7af530b4922c9084b2582674f3ca50b Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Tue, 12 Sep 2023 13:30:38 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E6=97=B6=E9=97=B4=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E9=AA=8C=E8=AF=81=202.=E9=99=84=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=97=B6=E9=97=B4=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=EF=BC=8C=E6=8A=A5=E5=91=8A=E5=87=BA=E5=85=B7=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/njcn/process/pojo/po/SupvFile.java | 2 +- .../controller/SupvFileController.java | 9 +- .../njcn/process/mapper/SupvFileMapper.java | 1 + .../process/service/ISupvFileService.java | 2 +- .../service/impl/SupvFileServiceImpl.java | 83 +++++++++++++++++-- .../service/impl/SupvPlanServiceImpl.java | 46 +++++++++- .../service/impl/SupvProblemServiceImpl.java | 50 ++++++++++- .../service/impl/SupvPushGwServiceImpl.java | 66 +++++++++++++-- 8 files changed, 234 insertions(+), 25 deletions(-) diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvFile.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvFile.java index 7aec0c632..d159f0ac3 100644 --- a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvFile.java +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/po/SupvFile.java @@ -64,5 +64,5 @@ public class SupvFile { private String uploaderId; - + private LocalDateTime createTime; } diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/controller/SupvFileController.java b/pqs-process/process-boot/src/main/java/com/njcn/process/controller/SupvFileController.java index 78c4fdbe9..4c36d32b4 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/controller/SupvFileController.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/controller/SupvFileController.java @@ -39,9 +39,14 @@ public class SupvFileController extends BaseController { @PostMapping("planUpload") @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPLOAD) @ApiOperation("监督计划问题附件上传") - public HttpResult planUpload(@ApiParam(value = "文件", required = true) @RequestPart("files") MultipartFile file, @RequestParam("planId") String planId, @RequestParam("type") Integer type,@RequestParam("attachmentType")String attachmentType){ + public HttpResult planUpload(@ApiParam(value = "文件", required = true) @RequestPart("files") MultipartFile file, + @RequestParam("planId") String planId, + @RequestParam("type") Integer type, + @RequestParam("attachmentType")String attachmentType, + @RequestParam("uploadTime")String uploadTime + ){ String methodDescribe = getMethodDescribe("planUpload"); - iSupvFileService.planUpload(file,planId,type,attachmentType); + iSupvFileService.planUpload(file,planId,type,attachmentType,uploadTime); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/SupvFileMapper.java b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/SupvFileMapper.java index bab6b74cc..dac2c77a6 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/SupvFileMapper.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/SupvFileMapper.java @@ -14,4 +14,5 @@ import com.njcn.process.pojo.po.SupvFile; */ public interface SupvFileMapper extends BaseMapper { + SupvFile selectFile(String ids); } diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/ISupvFileService.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/ISupvFileService.java index a644eac53..c736a7646 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/ISupvFileService.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/ISupvFileService.java @@ -22,7 +22,7 @@ public interface ISupvFileService extends IService { * @author cdf * @date 2023/6/25 */ - boolean planUpload(MultipartFile file,String planId, Integer type,String attachmentType); + boolean planUpload(MultipartFile file,String planId, Integer type,String attachmentType,String uploadTime); String detail(HttpServletResponse response,String busId,Integer type,String attachmentType); diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvFileServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvFileServiceImpl.java index 38832b296..f904a22f1 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvFileServiceImpl.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvFileServiceImpl.java @@ -1,22 +1,34 @@ package com.njcn.process.service.impl; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.oss.constant.OssPath; import com.njcn.oss.utils.FileStorageUtil; import com.njcn.process.mapper.SupvFileMapper; 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.service.ISupvFileService; +import com.njcn.process.service.ISupvPlanService; +import com.njcn.process.service.ISupvProblemService; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.pojo.po.DictData; import com.njcn.web.utils.RequestUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.time.LocalDateTime; +import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** *

@@ -32,28 +44,37 @@ public class SupvFileServiceImpl extends ServiceImpl i private final FileStorageUtil fileStorageUtil; + private final ISupvProblemService supvProblemService; + private final ISupvPlanService supvPlanService; + private final DicDataFeignClient dicDataFeignClient; - private final SupvFileMapper supvFileMapper; @Override - public boolean planUpload(MultipartFile file, String planId, Integer type,String attachmentType) { + @Transactional(rollbackFor = Exception.class) + public boolean planUpload(MultipartFile file, String planId, Integer type,String attachmentType,String uploadTime) { + Boolean fly=false; SupvFile supvFile = this.getOne(new LambdaQueryWrapper().eq(SupvFile::getBusiId,planId).eq(SupvFile::getType,type).eq(SupvFile::getAttachmentType,attachmentType)); String url = fileStorageUtil.uploadMultipart(file, OssPath.SURVEY_RESULT); SupvFile supvFilePO = new SupvFile(); supvFilePO.setAttachmentName(file.getOriginalFilename()); supvFilePO.setFileUrl(url); - if(Objects.nonNull(supvFile)){ - fileStorageUtil.deleteFile(supvFile.getFileUrl()); - supvFilePO.setUuid(supvFile.getUuid()); - return this.updateById(supvFilePO); - } supvFilePO.setAttachmentType(attachmentType); supvFilePO.setBusiId(planId); supvFilePO.setType(type); supvFilePO.setUploaderId(RequestUtil.getUserIndex()); - supvFilePO.setUploadTime(LocalDateTime.now()); + supvFilePO.setUploadTime(DateUtil.parseLocalDateTime(uploadTime)); supvFilePO.setUploaderName(RequestUtil.getUsername()); - return this.save(supvFilePO); + if(Objects.nonNull(supvFile)){ + fileStorageUtil.deleteFile(supvFile.getFileUrl()); + supvFilePO.setUuid(supvFile.getUuid()); + fly= this.updateById(supvFilePO); + updateTime(type,planId,uploadTime,attachmentType,supvFile.getUuid()); + }else{ + supvFilePO.setCreateTime(LocalDateTime.now()); + fly= this.save(supvFilePO); + updateTime(type,planId,uploadTime,attachmentType,null); + } + return fly; } @Override @@ -66,4 +87,48 @@ public class SupvFileServiceImpl extends ServiceImpl i throw new BusinessException("不存在附件"); } } + + /** + * @Description: + * @param type 区分问题计划 + * @param planId 业务id(问题id) + * @param uploadTime 上传时间 + * @param attachmentType 下拉选择类型 + * @param id 附件id + * @Author: wr + * @Date: 2023/9/12 8:59 + */ + private void updateTime(Integer type,String planId,String uploadTime,String attachmentType,String id){ + DictData stamped_report = dicDataFeignClient.getDicDataByCode("Stamped_Report").getData(); + if(type==1&&attachmentType.equals(stamped_report.getId())){ + //获取问题信息,查询所有问题 + SupvProblem byId = supvProblemService.getById(planId); + List list = supvProblemService.list(new LambdaQueryWrapper() + .eq(SupvProblem::getPlanId, byId.getPlanId())); + if(list.size()<2){ + supvPlanService.update(new LambdaUpdateWrapper() + .eq(SupvPlan::getPlanId,list.get(0).getPlanId()) + .set(SupvPlan::getReportIssueTime,uploadTime) + ); + }else{ + //根据问题查询上传附件信息,在排序取第一条 + List ids = list.stream().map(SupvProblem::getProblemId).collect(Collectors.toList()); + List files = this.list(new LambdaQueryWrapper() + .in(SupvFile::getBusiId, ids) + .eq(SupvFile::getType, type) + .eq(SupvFile::getAttachmentType, stamped_report.getId()) + .orderByAsc(SupvFile::getCreateTime) + ); + if(CollUtil.isNotEmpty(files)){ + if(files.get(0).getUuid().equals(id)){ + supvPlanService.update(new LambdaUpdateWrapper() + .eq(SupvPlan::getPlanId,list.get(0).getPlanId()) + .set(SupvPlan::getReportIssueTime,uploadTime)); + } + } + + } + } + + } } 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 2c0f3702a..8df43e11b 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 @@ -3,6 +3,7 @@ package com.njcn.process.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.ObjectUtil; @@ -50,6 +51,8 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; @@ -169,6 +172,8 @@ public class SupvPlanServiceImpl extends ServiceImpl i } } SupvPlan byId = this.getById(supvPlan.getPlanId()); + //实施问题 + List list =new ArrayList<>(); if(1==byId.getIsUploadHead()){ supvPlan.setIsUploadHead(3); @@ -192,7 +197,7 @@ public class SupvPlanServiceImpl extends ServiceImpl i planHis.setUpdateTime(LocalDateTime.now()); planHis.setDeleteFlag("0"); //判断是否已存在问题 - List list = supvPlanHisService.list(new LambdaQueryWrapper() + list = supvPlanHisService.list(new LambdaQueryWrapper() .eq(SupvPlanHis::getPlanId, planHis.getPlanId()) .orderByDesc(SupvPlanHis::getUpdateTime) @@ -204,6 +209,13 @@ public class SupvPlanServiceImpl extends ServiceImpl i planHis.setIsUploadHead(0); supvPlanHisService.save(planHis); } + //报告出具时间 + if(StrUtil.isNotBlank(supvPlanParam.getReportIssueTime())){ + //查询是否存在实施问题 + if(CollUtil.isNotEmpty(list)){ + + } + } return this.updateById(supvPlan); } @@ -377,8 +389,36 @@ public class SupvPlanServiceImpl extends ServiceImpl i } } } - - + //判断时间范围 + if(StrUtil.isAllNotBlank(supvPlanParam.getEffectStartTime(),supvPlanParam.getEffectEndTime())|| + StrUtil.isAllNotBlank(supvPlanParam.getEffectStartTime(),supvPlanParam.getReportIssueTime()) + ){ + String problemOcTime1 = supvPlanParam.getProblemOcTime(); + if(StrUtil.isNotBlank(problemOcTime1)){ + //实施开始时间 + DateTime effectStartTime = DateUtil.parse(supvPlanParam.getEffectStartTime(), "yyyy-MM-dd HH:mm:ss"); + //问题发现时间 + DateTime problemOcTime = DateUtil.parse(problemOcTime1, "yyyy-MM-dd HH:mm:ss"); + Boolean fly = false; + if(StrUtil.isNotBlank(supvPlanParam.getEffectEndTime())){ + //实施结束时间 + DateTime effectEndTime = DateUtil.parse(supvPlanParam.getEffectEndTime(), "yyyy-MM-dd HH:mm:ss"); + if (DateUtil.isIn(problemOcTime, effectStartTime, effectEndTime)) { + fly = true; + } + } + if(StrUtil.isNotBlank(supvPlanParam.getReportIssueTime())){ + //报告出具时间 + DateTime reportIssueTime = DateUtil.parse(supvPlanParam.getReportIssueTime(), "yyyy-MM-dd HH:mm:ss"); + if (DateUtil.isIn(problemOcTime, effectStartTime, reportIssueTime)) { + fly = true; + } + } + if (!fly) { + 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 aa72e74f3..c0702dd25 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 @@ -3,6 +3,9 @@ package com.njcn.process.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -15,8 +18,10 @@ 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.vo.SupvProblemVO; +import com.njcn.process.service.ISupvPlanService; import com.njcn.process.service.ISupvProblemService; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.enums.DicDataTypeEnum; @@ -29,6 +34,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; import java.util.List; import java.util.Map; import java.util.function.Function; @@ -54,9 +60,12 @@ public class SupvProblemServiceImpl extends ServiceImpl pageProblem(SupvProblemParam supvProblemParam) { + DictData stamped_report = dicDataFeignClient.getDicDataByCode("Stamped_Report").getData(); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(SupvProblem::getPlanId, supvProblemParam.getPlanId()); Page page = this.page(new Page<>(PageFactory.getPageNum(supvProblemParam), PageFactory.getPageSize(supvProblemParam)), lambdaQueryWrapper); @@ -122,7 +134,7 @@ public class SupvProblemServiceImpl extends ServiceImpl supvFileList = supvFileMapper.selectList(new LambdaQueryWrapper().eq(SupvFile::getBusiId, item.getProblemId()).eq(SupvFile::getType, 1)); if (CollUtil.isNotEmpty(supvFileList)) { for(SupvFile supvFile:supvFileList){ - if(supvFile.getAttachmentType().equals("01")){ + if(supvFile.getAttachmentType().equals(stamped_report.getId())){ item.setAttachmentName(supvFile.getAttachmentName()); }else { item.setAttachmentNameTwo(supvFile.getAttachmentName()); @@ -167,6 +179,42 @@ public class SupvProblemServiceImpl extends ServiceImpl fileList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.file_type.getCode()).getData(); + Map mapFile = fileList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); + DictData dictData ; //TODO 调用上送接口 for (int i = 0; i < supvFiles.size(); i++) { + + if(mapFile.containsKey(supvFiles.get(i).getAttachmentType())){ + dictData = mapFile.get(supvFiles.get(i).getAttachmentType()); + supvFiles.get(i).setAttachmentType(dictData.getValue()); + }else{ + stringBuilder.append("第" + i + "次操作失败: 请检查上送附件类型是否正确"); + continue; + } + // Map sendFile = sendFile(getUrl(4), supvFiles.get(i)); Map sendFile = new HashMap<>(); log.info(Thread.currentThread().getName() + "获取返回体 总部提供附件接收接口,省公司调用此接口,完成附件上报响应结果:" + sendFile + "结束----!"); @@ -430,7 +447,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { for (String id : planIds) { SupvPlan supvPlan = new SupvPlan(); supvPlan.setPlanId(id); - supvPlan.setProvinceId("13B9B47F1E483324E05338297A0A0595"); + supvPlan.setDeleteFlag(null); supvPlanList.add(supvPlan); } @@ -663,7 +680,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { log.info(Thread.currentThread().getName() + "错误信息:" + e); map.put("error", e.toString()); } - }catch (Exception e){ + } catch (Exception e) { map.put("error", "当前时间段国网上送请求过多,请稍后再试"); } return map; @@ -885,4 +902,37 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { return url; } + private void checkParam(SupvPlan supvPlan) { + //判断时间范围 + if (ObjectUtil.isAllNotEmpty(supvPlan.getEffectStartTime(), supvPlan.getEffectEndTime())|| + ObjectUtil.isAllNotEmpty(supvPlan.getEffectStartTime(), supvPlan.getReportIssueTime()) + ) { + LocalDateTime problemOcTime1 = supvPlan.getProblemOcTime(); + if (ObjectUtil.isNotNull(problemOcTime1)) { + //实施开始时间 + DateTime effectStartTime = DateUtil.parse(DateUtil.formatLocalDateTime(supvPlan.getEffectStartTime()), "yyyy-MM-dd HH:mm:ss"); + //问题发现时间 + DateTime problemOcTime = DateUtil.parse(DateUtil.formatLocalDateTime(problemOcTime1), "yyyy-MM-dd HH:mm:ss"); + Boolean fly = false; + if(ObjectUtil.isNotNull(supvPlan.getEffectEndTime())){ + //实施结束时间 + DateTime effectEndTime = DateUtil.parse(DateUtil.formatLocalDateTime(supvPlan.getEffectEndTime()), "yyyy-MM-dd HH:mm:ss"); + if (DateUtil.isIn(problemOcTime, effectStartTime, effectEndTime)) { + fly = true; + } + } + if(ObjectUtil.isNotNull(supvPlan.getReportIssueTime())){ + //报告出具时间 + DateTime reportIssueTime = DateUtil.parse(DateUtil.formatLocalDateTime(supvPlan.getReportIssueTime()), "yyyy-MM-dd HH:mm:ss"); + if (DateUtil.isIn(problemOcTime, effectStartTime, reportIssueTime)) { + fly = true; + } + } + if (!fly) { + throw new BusinessException("问题发现时时间,不在实施开始时间到(实施结束时间/报告出具时间)范围内"); + + } + } + } + } }