1.技术监督附件上传调整
This commit is contained in:
@@ -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<String> ids;
|
||||
|
||||
@ApiModelProperty(value = "0.计划 1.问题")
|
||||
@NotNull(message = "选择类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "区分类型")
|
||||
private String attachmentType;
|
||||
|
||||
|
||||
@@ -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<Object> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,5 +18,7 @@ import java.util.List;
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!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">
|
||||
|
||||
<select id="selectFile" resultType="com.njcn.process.pojo.po.SupvFile">
|
||||
<select id="selectPlanFile" resultType="com.njcn.process.pojo.po.SupvFile">
|
||||
select
|
||||
sp.work_plan_name busiName,
|
||||
sf.*
|
||||
@@ -20,7 +20,30 @@
|
||||
AND sf.type = #{param.type}
|
||||
</if>
|
||||
<if test="param!=null and param.attachmentType != null and param.attachmentType != ''">
|
||||
AND sf.attachment_Type <= #{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>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@@ -24,7 +24,13 @@ public interface ISupvFileService extends IService<SupvFile> {
|
||||
* @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<SupvFile> listFile(SupvFileParam param);
|
||||
|
||||
|
||||
@@ -53,8 +53,14 @@ public class SupvFileServiceImpl extends ServiceImpl<SupvFileMapper, SupvFile> 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<SupvFile>().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<SupvFileMapper, SupvFile> 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<SupvFileMapper, SupvFile> i
|
||||
|
||||
@Override
|
||||
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
|
||||
|
||||
@@ -322,10 +322,10 @@ public class SupvPlanServiceImpl extends ServiceImpl<SupvPlanMapper, SupvPlan> i
|
||||
item.setPlanOrgName(mapCode.get(item.getPlanOrgId()).getName());
|
||||
}
|
||||
|
||||
SupvFile supvFile = supvFileMapper.selectOne(new LambdaQueryWrapper<SupvFile>().eq(SupvFile::getBusiId, item.getPlanId()).eq(SupvFile::getType, 0));
|
||||
if (Objects.nonNull(supvFile)) {
|
||||
item.setAttachmentName(supvFile.getAttachmentName());
|
||||
}
|
||||
// SupvFile supvFile = supvFileMapper.selectOne(new LambdaQueryWrapper<SupvFile>().eq(SupvFile::getBusiId, item.getPlanId()).eq(SupvFile::getType, 0));
|
||||
// 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()));
|
||||
|
||||
@@ -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<String, String> send = send(param, getUrl(1), "pqPlanCreate");
|
||||
// Map<String, String> 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<String, String> 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<String> busIds) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
LambdaQueryWrapper<SupvFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(SupvFile::getBusiId, busIds);
|
||||
lambdaQueryWrapper.in(SupvFile::getUuid, busIds);
|
||||
List<SupvFile> 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<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()));
|
||||
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) + "行文件上送失败: 请检查上送附件类型是否正确;</br>");
|
||||
continue;
|
||||
}
|
||||
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();
|
||||
Map mapCount = JSON.parseObject(result, Map.class);
|
||||
String count = mapCount.get("count").toString();
|
||||
stringBuilder.append("第" + i + "次操作成功:成功数据" + count + "条");
|
||||
stringBuilder.append("第" + (i+1) + "行文件上送失败:成功数据" + count + "条;</br>");
|
||||
} else {
|
||||
String errors = map.get("errors").toString();
|
||||
stringBuilder.append("第" + i + "次操作失败:" + status + "_" + errors);
|
||||
stringBuilder.append("第" + (i+1) + "次行文件上送失败:" + status + "_" + errors+";</br>");
|
||||
}
|
||||
} else {
|
||||
stringBuilder.append("第" + i + "次当前时间段国网上送请求过多,请稍后再试");
|
||||
stringBuilder.append("第" + (i+1)+ "行文件上送失败:当前时间段国网上送请求过多,请稍后再试;</br>");
|
||||
}
|
||||
}
|
||||
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<String, String> send = send(param, getUrl(5), "pqMonthReportCreate");
|
||||
// Map<String, String> 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<String, String> send = send(param, getUrl(6), "pqPlanDelete");
|
||||
// Map<String, String> 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())
|
||||
|
||||
Reference in New Issue
Block a user