1.技术监督附件上传调整

This commit is contained in:
wr
2023-09-15 15:00:44 +08:00
parent 4e76669d4e
commit a169e7db19
8 changed files with 74 additions and 27 deletions

View File

@@ -3,6 +3,7 @@ package com.njcn.process.pojo.param;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
/** /**
@@ -19,8 +20,11 @@ public class SupvFileParam {
@ApiModelProperty(value = "业务id集合") @ApiModelProperty(value = "业务id集合")
private List<String> ids; private List<String> ids;
@ApiModelProperty(value = "0.计划 1.问题") @ApiModelProperty(value = "0.计划 1.问题")
@NotNull(message = "选择类型不能为空")
private Integer type; private Integer type;
@ApiModelProperty(value = "区分类型") @ApiModelProperty(value = "区分类型")
private String attachmentType; private String attachmentType;

View File

@@ -1,11 +1,13 @@
package com.njcn.process.controller; package com.njcn.process.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType; import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; 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.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.process.pojo.param.SupvAlarmParam; 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.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
@@ -49,11 +52,16 @@ public class SupvFileController extends BaseController {
public HttpResult<Object> planUpload(@ApiParam(value = "文件", required = true) @RequestPart("files") MultipartFile file, public HttpResult<Object> planUpload(@ApiParam(value = "文件", required = true) @RequestPart("files") MultipartFile file,
@RequestParam("planId") String planId, @RequestParam("planId") String planId,
@RequestParam("type") Integer type, @RequestParam("type") Integer type,
@RequestParam("uploaderId") String uploaderId,
@RequestParam("uploaderName") String uploaderName,
@RequestParam("attachmentType")String attachmentType, @RequestParam("attachmentType")String attachmentType,
@RequestParam("uploadTime")String uploadTime @RequestParam("uploadTime")String uploadTime
){ ){
String methodDescribe = getMethodDescribe("planUpload"); 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); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }

View File

@@ -18,5 +18,7 @@ import java.util.List;
*/ */
public interface SupvFileMapper extends BaseMapper<SupvFile> { public interface SupvFileMapper extends BaseMapper<SupvFile> {
List<SupvFile> selectFile(@Param("param") SupvFileParam param); List<SupvFile> selectPlanFile(@Param("param") SupvFileParam param);
List<SupvFile> selecProblemtFile(@Param("param") SupvFileParam param);
} }

View File

@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.process.mapper.SupvFileMapper"> <mapper namespace="com.njcn.process.mapper.SupvFileMapper">
<select id="selectFile" resultType="com.njcn.process.pojo.po.SupvFile"> <select id="selectPlanFile" resultType="com.njcn.process.pojo.po.SupvFile">
select select
sp.work_plan_name busiName, sp.work_plan_name busiName,
sf.* sf.*
@@ -20,7 +20,30 @@
AND sf.type = #{param.type} AND sf.type = #{param.type}
</if> </if>
<if test="param!=null and param.attachmentType != null and param.attachmentType != ''"> <if test="param!=null and param.attachmentType != null and param.attachmentType != ''">
AND sf.attachment_Type &lt;= #{param.attachmentType} AND sf.attachment_Type = #{param.attachmentType}
</if>
</where>
</select>
<select id="selecProblemtFile" resultType="com.njcn.process.pojo.po.SupvFile">
select
sp.simple_Problem_Desc busiName,
sf.*
from
supv_file sf
INNER JOIN supv_problem sp on sp.problem_Id= sf.busi_Id
<where>
<if test="param!=null and param.ids != null and param.ids.size > 0">
AND busi_Id IN
<foreach collection='param.ids' item='item' index="index" open='(' separator=',' close=')'>
#{item}
</foreach>
</if>
<if test="param!=null and param.type != null ">
AND sf.type = #{param.type}
</if>
<if test="param!=null and param.attachmentType != null and param.attachmentType != ''">
AND sf.attachment_Type = #{param.attachmentType}
</if> </if>
</where> </where>
</select> </select>

View File

@@ -24,7 +24,13 @@ public interface ISupvFileService extends IService<SupvFile> {
* @author cdf * @author cdf
* @date 2023/6/25 * @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<SupvFile> listFile(SupvFileParam param); List<SupvFile> listFile(SupvFileParam param);

View File

@@ -53,8 +53,14 @@ public class SupvFileServiceImpl extends ServiceImpl<SupvFileMapper, SupvFile> i
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean planUpload(MultipartFile file, String planId, Integer type,String attachmentType,String uploadTime) { public boolean planUpload(MultipartFile file,
Boolean fly=false; String planId,
Integer type,
String uploaderId,
String uploaderName,
String attachmentType,
String uploadTime) {
Boolean fly;
SupvFile supvFile = this.getOne(new LambdaQueryWrapper<SupvFile>().eq(SupvFile::getBusiId,planId).eq(SupvFile::getType,type).eq(SupvFile::getAttachmentType,attachmentType)); SupvFile supvFile = this.getOne(new LambdaQueryWrapper<SupvFile>().eq(SupvFile::getBusiId,planId).eq(SupvFile::getType,type).eq(SupvFile::getAttachmentType,attachmentType));
String url = fileStorageUtil.uploadMultipart(file, OssPath.SURVEY_RESULT); String url = fileStorageUtil.uploadMultipart(file, OssPath.SURVEY_RESULT);
SupvFile supvFilePO = new SupvFile(); SupvFile supvFilePO = new SupvFile();
@@ -63,9 +69,9 @@ public class SupvFileServiceImpl extends ServiceImpl<SupvFileMapper, SupvFile> i
supvFilePO.setAttachmentType(attachmentType); supvFilePO.setAttachmentType(attachmentType);
supvFilePO.setBusiId(planId); supvFilePO.setBusiId(planId);
supvFilePO.setType(type); supvFilePO.setType(type);
supvFilePO.setUploaderId(RequestUtil.getUserIndex()); supvFilePO.setUploaderId(uploaderId);
supvFilePO.setUploadTime(DateUtil.parseLocalDateTime(uploadTime)); supvFilePO.setUploadTime(DateUtil.parseLocalDateTime(uploadTime));
supvFilePO.setUploaderName(RequestUtil.getUsername()); supvFilePO.setUploaderName(uploaderName);
if(Objects.nonNull(supvFile)){ if(Objects.nonNull(supvFile)){
fileStorageUtil.deleteFile(supvFile.getFileUrl()); fileStorageUtil.deleteFile(supvFile.getFileUrl());
supvFilePO.setUuid(supvFile.getUuid()); supvFilePO.setUuid(supvFile.getUuid());
@@ -83,7 +89,10 @@ public class SupvFileServiceImpl extends ServiceImpl<SupvFileMapper, SupvFile> i
@Override @Override
public List<SupvFile> listFile(SupvFileParam param) { public List<SupvFile> listFile(SupvFileParam param) {
return this.baseMapper.selectFile(param); if (param.getType()==0){
return this.baseMapper.selectPlanFile(param);
}
return this.baseMapper.selecProblemtFile(param);
} }
@Override @Override

View File

@@ -322,10 +322,10 @@ public class SupvPlanServiceImpl extends ServiceImpl<SupvPlanMapper, SupvPlan> i
item.setPlanOrgName(mapCode.get(item.getPlanOrgId()).getName()); item.setPlanOrgName(mapCode.get(item.getPlanOrgId()).getName());
} }
SupvFile supvFile = supvFileMapper.selectOne(new LambdaQueryWrapper<SupvFile>().eq(SupvFile::getBusiId, item.getPlanId()).eq(SupvFile::getType, 0)); // SupvFile supvFile = supvFileMapper.selectOne(new LambdaQueryWrapper<SupvFile>().eq(SupvFile::getBusiId, item.getPlanId()).eq(SupvFile::getType, 0));
if (Objects.nonNull(supvFile)) { // if (Objects.nonNull(supvFile)) {
item.setAttachmentName(supvFile.getAttachmentName()); // item.setAttachmentName(supvFile.getAttachmentName());
} // }
List<User> userList = userFeignClient.getUserByIdList(userIds).getData(); List<User> userList = userFeignClient.getUserByIdList(userIds).getData();
Map<String, User> map = userList.stream().collect(Collectors.toMap(User::getId, Function.identity())); Map<String, User> map = userList.stream().collect(Collectors.toMap(User::getId, Function.identity()));

View File

@@ -233,7 +233,6 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT); String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督工作计划数据接口数据:" + s + "结束----"); log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督工作计划数据接口数据:" + s + "结束----");
Map<String, String> send = send(param, getUrl(1), "pqPlanCreate"); Map<String, String> send = send(param, getUrl(1), "pqPlanCreate");
// Map<String, String> send = new HashMap<>();
log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督工作计划数据接口响应结果:" + send + "结束----"); log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督工作计划数据接口响应结果:" + send + "结束----");
if (send.containsKey("succeed")) { if (send.containsKey("succeed")) {
String succeed = send.get("succeed"); String succeed = send.get("succeed");
@@ -314,8 +313,6 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
send = send(param, getUrl(3), "pqProblemUpdate"); send = send(param, getUrl(3), "pqProblemUpdate");
log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督实施问题整改数据接口响应结果:" + send + "结束----"); log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督实施问题整改数据接口响应结果:" + send + "结束----");
} }
// Map<String, String> send = new HashMap<>();
if (send.containsKey("succeed")) { if (send.containsKey("succeed")) {
String succeed = send.get("succeed"); String succeed = send.get("succeed");
if (succeed.indexOf("\\\"") != -1) { if (succeed.indexOf("\\\"") != -1) {
@@ -345,7 +342,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
public String pushFile(List<String> busIds) { public String pushFile(List<String> busIds) {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
LambdaQueryWrapper<SupvFile> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SupvFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(SupvFile::getBusiId, busIds); lambdaQueryWrapper.in(SupvFile::getUuid, busIds);
List<SupvFile> supvFiles = supvFileService.list(lambdaQueryWrapper); List<SupvFile> supvFiles = supvFileService.list(lambdaQueryWrapper);
if (supvFiles.size() > 100) { if (supvFiles.size() > 100) {
throw new BusinessException("一次最多上送100条数据"); throw new BusinessException("一次最多上送100条数据");
@@ -353,7 +350,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
JSONArray objects = new JSONArray(Collections.singletonList(supvFiles)); JSONArray objects = new JSONArray(Collections.singletonList(supvFiles));
String s = objects.toString(); String s = objects.toString();
log.info(Thread.currentThread().getName() + "获取返回体 推送附件接口:" + s + "结束----"); log.info(Thread.currentThread().getName() + "获取返回体 推送附件接口:" + s + "结束----");
List<DictData> fileList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.file_type.getCode()).getData(); List<DictData> fileList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.file_type.getCode().trim()).getData();
Map<String, DictData> mapFile = fileList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); Map<String, DictData> mapFile = fileList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
DictData dictData ; DictData dictData ;
//TODO 调用上送接口 //TODO 调用上送接口
@@ -362,7 +359,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
dictData = mapFile.get(supvFiles.get(i).getAttachmentType()); dictData = mapFile.get(supvFiles.get(i).getAttachmentType());
supvFiles.get(i).setAttachmentType(dictData.getValue()); supvFiles.get(i).setAttachmentType(dictData.getValue());
}else{ }else{
stringBuilder.append("" + i + "次操作失败: 请检查上送附件类型是否正确"); stringBuilder.append("" + (i+1) + "行文件上送失败: 请检查上送附件类型是否正确;</br>");
continue; continue;
} }
Map<String, String> sendFile = sendFile(getUrl(4), supvFiles.get(i)); Map<String, String> sendFile = sendFile(getUrl(4), supvFiles.get(i));
@@ -382,13 +379,13 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
String result = map.get("result").toString(); String result = map.get("result").toString();
Map mapCount = JSON.parseObject(result, Map.class); Map mapCount = JSON.parseObject(result, Map.class);
String count = mapCount.get("count").toString(); String count = mapCount.get("count").toString();
stringBuilder.append("" + i + "次操作成功:成功数据" + count + ""); stringBuilder.append("" + (i+1) + "行文件上送失败:成功数据" + count + ";</br>");
} else { } else {
String errors = map.get("errors").toString(); String errors = map.get("errors").toString();
stringBuilder.append("" + i + "操作失败:" + status + "_" + errors); stringBuilder.append("" + (i+1) + "行文件上送失败:" + status + "_" + errors+";</br>");
} }
} else { } else {
stringBuilder.append("" + i + "当前时间段国网上送请求过多,请稍后再试"); stringBuilder.append("" + (i+1)+ "行文件上送失败:当前时间段国网上送请求过多,请稍后再试;</br>");
} }
} }
return stringBuilder.toString(); return stringBuilder.toString();
@@ -410,7 +407,6 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT); String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口数据:" + s + "结束----"); log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口数据:" + s + "结束----");
Map<String, String> send = send(param, getUrl(5), "pqMonthReportCreate"); Map<String, String> send = send(param, getUrl(5), "pqMonthReportCreate");
// Map<String, String> send = new HashMap<>();
log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口响应结果:" + send + "结束----"); log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口响应结果:" + send + "结束----");
if (send.containsKey("succeed")) { if (send.containsKey("succeed")) {
String succeed = send.get("succeed"); String succeed = send.get("succeed");
@@ -461,7 +457,6 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT); String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口数据:" + s + "结束----"); log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口数据:" + s + "结束----");
Map<String, String> send = send(param, getUrl(6), "pqPlanDelete"); Map<String, String> send = send(param, getUrl(6), "pqPlanDelete");
// Map<String, String> send = new HashMap<>();
log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口响应结果:" + send + "结束----"); log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口响应结果:" + send + "结束----");
if (send.containsKey("succeed")) { if (send.containsKey("succeed")) {
String succeed = send.get("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")); String uploadTime = supvFile.getUploadTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// 设置form请求参数 // 设置form请求参数
builder.putParamsMap("uuid", supvFile.getFileUrl()) builder.putParamsMap("uuid", supvFile.getUuid())
.putParamsMap("attachmentName", supvFile.getAttachmentName())
.putParamsMap("provinceId", code) .putParamsMap("provinceId", code)
.putParamsMap("attachmentName", supvFile.getAttachmentName())
.putParamsMap("attachmentType", supvFile.getAttachmentType()) .putParamsMap("attachmentType", supvFile.getAttachmentType())
.putParamsMap("busiId", supvFile.getBusiId()) .putParamsMap("busiId", supvFile.getBusiId())
.putParamsMap("uploaderName", supvFile.getUploaderName()) .putParamsMap("uploaderName", supvFile.getUploaderName())