From a169e7db1976113109bc12e4680f64e85a3e6c74 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Fri, 15 Sep 2023 15:00:44 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=8A=80=E6=9C=AF=E7=9B=91=E7=9D=A3=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/pojo/param/SupvFileParam.java | 4 +++ .../controller/SupvFileController.java | 10 ++++++- .../njcn/process/mapper/SupvFileMapper.java | 4 ++- .../process/mapper/mapping/SupvFileMapper.xml | 27 +++++++++++++++++-- .../process/service/ISupvFileService.java | 8 +++++- .../service/impl/SupvFileServiceImpl.java | 19 +++++++++---- .../service/impl/SupvPlanServiceImpl.java | 8 +++--- .../service/impl/SupvPushGwServiceImpl.java | 21 ++++++--------- 8 files changed, 74 insertions(+), 27 deletions(-) diff --git a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/SupvFileParam.java b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/SupvFileParam.java index 37d0fdfd5..651bff28c 100644 --- a/pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/SupvFileParam.java +++ b/pqs-process/process-api/src/main/java/com/njcn/process/pojo/param/SupvFileParam.java @@ -3,6 +3,7 @@ package com.njcn.process.pojo.param; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.NotNull; import java.util.List; /** @@ -19,8 +20,11 @@ public class SupvFileParam { @ApiModelProperty(value = "业务id集合") private List ids; + @ApiModelProperty(value = "0.计划 1.问题") + @NotNull(message = "选择类型不能为空") private Integer type; + @ApiModelProperty(value = "区分类型") private String attachmentType; 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 53cafb6e9..cf648eb01 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 @@ -1,11 +1,13 @@ package com.njcn.process.controller; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.constant.OperateType; import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; +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.SupvAlarmParam; @@ -18,6 +20,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import com.njcn.web.controller.BaseController; @@ -49,11 +52,16 @@ public class SupvFileController extends BaseController { public HttpResult planUpload(@ApiParam(value = "文件", required = true) @RequestPart("files") MultipartFile file, @RequestParam("planId") String planId, @RequestParam("type") Integer type, + @RequestParam("uploaderId") String uploaderId, + @RequestParam("uploaderName") String uploaderName, @RequestParam("attachmentType")String attachmentType, @RequestParam("uploadTime")String uploadTime ){ String methodDescribe = getMethodDescribe("planUpload"); - iSupvFileService.planUpload(file,planId,type,attachmentType,uploadTime); + if(!StrUtil.isAllNotBlank(planId,uploaderId,uploaderName,attachmentType,uploadTime)||type==null){ + throw new BusinessException("必填字段不能为空"); + } + iSupvFileService.planUpload(file,planId,type,uploaderId,uploaderName,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 634a9b1b4..310e8a3bd 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 @@ -18,5 +18,7 @@ import java.util.List; */ public interface SupvFileMapper extends BaseMapper { - List selectFile(@Param("param") SupvFileParam param); + List selectPlanFile(@Param("param") SupvFileParam param); + + List selecProblemtFile(@Param("param") SupvFileParam param); } diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/SupvFileMapper.xml b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/SupvFileMapper.xml index a9c4ca948..e3504fdc8 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/SupvFileMapper.xml +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/mapper/mapping/SupvFileMapper.xml @@ -2,7 +2,7 @@ - select sp.work_plan_name busiName, sf.* @@ -20,7 +20,30 @@ AND sf.type = #{param.type} - AND sf.attachment_Type <= #{param.attachmentType} + AND sf.attachment_Type = #{param.attachmentType} + + + + + 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 c749c5641..6857fb18f 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 @@ -24,7 +24,13 @@ public interface ISupvFileService extends IService { * @author cdf * @date 2023/6/25 */ - boolean planUpload(MultipartFile file,String planId, Integer type,String attachmentType,String uploadTime); + boolean planUpload(MultipartFile file, + String planId, + Integer type, + String uploaderId, + String uploaderName, + String attachmentType, + String uploadTime); List listFile(SupvFileParam param); 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 6d413172f..a9cd92d2c 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 @@ -53,8 +53,14 @@ public class SupvFileServiceImpl extends ServiceImpl i @Override @Transactional(rollbackFor = Exception.class) - public boolean planUpload(MultipartFile file, String planId, Integer type,String attachmentType,String uploadTime) { - Boolean fly=false; + public boolean planUpload(MultipartFile file, + String planId, + Integer type, + String uploaderId, + String uploaderName, + String attachmentType, + String uploadTime) { + Boolean fly; 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(); @@ -63,9 +69,9 @@ public class SupvFileServiceImpl extends ServiceImpl i supvFilePO.setAttachmentType(attachmentType); supvFilePO.setBusiId(planId); supvFilePO.setType(type); - supvFilePO.setUploaderId(RequestUtil.getUserIndex()); + supvFilePO.setUploaderId(uploaderId); supvFilePO.setUploadTime(DateUtil.parseLocalDateTime(uploadTime)); - supvFilePO.setUploaderName(RequestUtil.getUsername()); + supvFilePO.setUploaderName(uploaderName); if(Objects.nonNull(supvFile)){ fileStorageUtil.deleteFile(supvFile.getFileUrl()); supvFilePO.setUuid(supvFile.getUuid()); @@ -83,7 +89,10 @@ public class SupvFileServiceImpl extends ServiceImpl i @Override public List listFile(SupvFileParam param) { - return this.baseMapper.selectFile(param); + if (param.getType()==0){ + return this.baseMapper.selectPlanFile(param); + } + return this.baseMapper.selecProblemtFile(param); } @Override 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 8df43e11b..db0915a8b 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 @@ -322,10 +322,10 @@ public class SupvPlanServiceImpl extends ServiceImpl i 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)) { - item.setAttachmentName(supvFile.getAttachmentName()); - } +// 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())); diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java index 1632b9f38..11784ae76 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java @@ -233,7 +233,6 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT); log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督工作计划数据接口数据:" + s + "结束----!"); Map send = send(param, getUrl(1), "pqPlanCreate"); -// Map send = new HashMap<>(); log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督工作计划数据接口响应结果:" + send + "结束----!"); if (send.containsKey("succeed")) { String succeed = send.get("succeed"); @@ -314,8 +313,6 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { send = send(param, getUrl(3), "pqProblemUpdate"); log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督实施问题整改数据接口响应结果:" + send + "结束----!"); } -// Map send = new HashMap<>(); - if (send.containsKey("succeed")) { String succeed = send.get("succeed"); if (succeed.indexOf("\\\"") != -1) { @@ -345,7 +342,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { public String pushFile(List busIds) { StringBuilder stringBuilder = new StringBuilder(); LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(SupvFile::getBusiId, busIds); + lambdaQueryWrapper.in(SupvFile::getUuid, busIds); List supvFiles = supvFileService.list(lambdaQueryWrapper); if (supvFiles.size() > 100) { throw new BusinessException("一次最多上送100条数据"); @@ -353,7 +350,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { JSONArray objects = new JSONArray(Collections.singletonList(supvFiles)); String s = objects.toString(); log.info(Thread.currentThread().getName() + "获取返回体 推送附件接口:" + s + "结束----!"); - List fileList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.file_type.getCode()).getData(); + List fileList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.file_type.getCode().trim()).getData(); Map mapFile = fileList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); DictData dictData ; //TODO 调用上送接口 @@ -362,7 +359,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { dictData = mapFile.get(supvFiles.get(i).getAttachmentType()); supvFiles.get(i).setAttachmentType(dictData.getValue()); }else{ - stringBuilder.append("第" + i + "次操作失败: 请检查上送附件类型是否正确"); + stringBuilder.append("第" + (i+1) + "行文件上送失败: 请检查上送附件类型是否正确;
"); continue; } Map sendFile = sendFile(getUrl(4), supvFiles.get(i)); @@ -382,13 +379,13 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { String result = map.get("result").toString(); Map mapCount = JSON.parseObject(result, Map.class); String count = mapCount.get("count").toString(); - stringBuilder.append("第" + i + "次操作成功:成功数据" + count + "条"); + stringBuilder.append("第" + (i+1) + "行文件上送失败:成功数据" + count + "条;
"); } else { String errors = map.get("errors").toString(); - stringBuilder.append("第" + i + "次操作失败:" + status + "_" + errors); + stringBuilder.append("第" + (i+1) + "次行文件上送失败:" + status + "_" + errors+";
"); } } else { - stringBuilder.append("第" + i + "次当前时间段国网上送请求过多,请稍后再试"); + stringBuilder.append("第" + (i+1)+ "行文件上送失败:当前时间段国网上送请求过多,请稍后再试;
"); } } return stringBuilder.toString(); @@ -410,7 +407,6 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT); log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口数据:" + s + "结束----!"); Map send = send(param, getUrl(5), "pqMonthReportCreate"); -// Map send = new HashMap<>(); log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口响应结果:" + send + "结束----!"); if (send.containsKey("succeed")) { String succeed = send.get("succeed"); @@ -461,7 +457,6 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT); log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口数据:" + s + "结束----!"); Map send = send(param, getUrl(6), "pqPlanDelete"); -// Map send = new HashMap<>(); log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口响应结果:" + send + "结束----!"); if (send.containsKey("succeed")) { String succeed = send.get("succeed"); @@ -753,9 +748,9 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { String uploadTime = supvFile.getUploadTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); // 设置form请求参数 - builder.putParamsMap("uuid", supvFile.getFileUrl()) - .putParamsMap("attachmentName", supvFile.getAttachmentName()) + builder.putParamsMap("uuid", supvFile.getUuid()) .putParamsMap("provinceId", code) + .putParamsMap("attachmentName", supvFile.getAttachmentName()) .putParamsMap("attachmentType", supvFile.getAttachmentType()) .putParamsMap("busiId", supvFile.getBusiId()) .putParamsMap("uploaderName", supvFile.getUploaderName())