技术监督模板、文件(批量)上传

This commit is contained in:
Lee
2023-03-30 16:22:05 +08:00
parent 0efaa37d87
commit 0dc06679d8
17 changed files with 211 additions and 342 deletions

View File

@@ -59,10 +59,18 @@ public class ThsSuperviseController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@ApiOperation("更新技术监督")
@ApiImplicitParam(name = "superviceRunLogVo", value = "更新技术监督参数", required = true)
@PostMapping("/updateSupervice")
public HttpResult updateSupervice(@RequestBody SuperviceRunLogVo superviceRunLogVo) {
return thsOverRunLogService.updateSupervise(superviceRunLogVo);
}
@ApiOperation("技术监督详情")
@ApiImplicitParam(name = "supIndex", value = "技术监督id", required = true)
@PostMapping("/superviseDetail")
public HttpResult superviseDetail(@RequestParam String supIndex) {
public HttpResult<SuperviceRunLogVo> superviseDetail(@RequestParam String supIndex) {
SuperviceRunLogVo result = thsOverRunLogService.superviseDetail(supIndex);
String methodDescribe = getMethodDescribe("superviseDetail");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
@@ -88,9 +96,9 @@ public class ThsSuperviseController extends BaseController {
@PostMapping("/uploadSuperviseTicket")
public HttpResult uploadSuperviseTicket(@ApiParam(value = "文件", required = true)
@RequestPart(value = "files") MultipartFile[] files,
@ApiParam(name = "id", value = "越限监测点记录id", required = true) @RequestParam("id") String id,
@ApiParam(name = "id", value = "越限监测点记录id") @RequestParam(value = "id", required = false) String id,
@ApiParam(name = "supIndex", value = "技术监督id", required = true) @RequestParam("supIndex") String supIndex,
@ApiParam(name = "ticketType", value = "上传单据类型", required = true) @RequestParam("ticketType") String ticketType,
@ApiParam(name = "ticketType", value = "上传单据类型:1 反馈单,2 测试报告,4 整改通知反馈单", required = true) @RequestParam("ticketType") Integer ticketType,
HttpServletResponse response) {
thsSuperviseService.uploadSuperviseTicket(id, supIndex, ticketType, files, response);
String methodDescribe = getMethodDescribe("uploadSuperviseTicket");
@@ -122,14 +130,15 @@ public class ThsSuperviseController extends BaseController {
@ApiOperation("下载单据模板")
@PostMapping("/dowloadAlarmFormwork")
public HttpResult dowloadAlarmFormwork(@ApiParam(name = "type", value = "类型0预警1告警", required = true) @RequestParam("type") Integer type,
@ApiParam(name = "supIndex", value = "技术监督id", required = true) @RequestParam("supIndex") String supIndex,
@ApiParam(name = "formworkType", value = "0预/告警单模板1整改通知反馈单模板", required = true) @RequestParam("formworkType") Integer formworkType,
HttpServletResponse response) {
String httpPath = thsSuperviseService.dowloadAlarmFormwork(type, formworkType, response);
String httpPath = thsSuperviseService.dowloadAlarmFormwork(type, formworkType, supIndex, response);
String methodDescribe = getMethodDescribe("uploadAlarmFormwork");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, httpPath, methodDescribe);
}
@ApiOperation("监督首页")
@ApiOperation("技术监督首页")
@ApiImplicitParam(name = "superviseDto", value = "查询技术监督列表参数", required = true)
@PostMapping("/superviseIndex")
public HttpResult<Page<ThsSuperviseVo>> superviseIndex(@RequestBody SuperviseDto superviseDto) {

View File

@@ -81,12 +81,6 @@
<if test="param.type !=null">
and tda.type=#{param.type}
</if>
<!-- <if test="param != null and param.overRunLog != null and param.overRunLog.size > 0">
AND tda.Monitor_Id IN
<foreach collection='param.overRunLog' item='item' index="index" open='(' separator=',' close=')'>
#{item.lineIndex}
</foreach>
</if>-->
and tws.Big_Type=1
</where>
</select>

View File

@@ -2,7 +2,6 @@ package com.njcn.process.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
import com.njcn.prepare.harmonic.pojo.po.ThsOverRunLog;
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
@@ -16,14 +15,6 @@ import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
*/
public interface ThsOverRunLogService extends IService<ThsOverRunLog> {
/**
* 保存技术监督监测点
*
* @param superviseParam
* @return
*/
void saveOverRunLog(SuperviseParam superviseParam);
/**
* 查询技术监督监测点集合
*
@@ -37,5 +28,5 @@ public interface ThsOverRunLogService extends IService<ThsOverRunLog> {
*
* @param superviseParam
*/
HttpResult updateSupervise(SuperviseParam superviseParam);
HttpResult updateSupervise(SuperviceRunLogVo superviseParam);
}

View File

@@ -127,7 +127,7 @@ public interface ThsSuperviseService extends IService<ThsSupervise> {
* @param files
* @param response
*/
void uploadSuperviseTicket(String id, String supIndex, String ticketType, MultipartFile[] files, HttpServletResponse response);
void uploadSuperviseTicket(String id, String supIndex, Integer ticketType, MultipartFile[] files, HttpServletResponse response);
/**
* 查询流程状态枚举列表
@@ -154,7 +154,7 @@ public interface ThsSuperviseService extends IService<ThsSupervise> {
* @param response
* @return
*/
String dowloadAlarmFormwork(Integer type, Integer formworkType, HttpServletResponse response);
String dowloadAlarmFormwork(Integer type, Integer formworkType, String supIndex, HttpServletResponse response);
/**
* 技术监督首页

View File

@@ -7,19 +7,21 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
import com.njcn.prepare.harmonic.pojo.po.ThsOverRunLog;
import com.njcn.prepare.harmonic.pojo.po.ThsSupervise;
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
import com.njcn.process.enums.ProgressEnum;
import com.njcn.process.mapper.PmsMonitorMapper;
import com.njcn.process.mapper.ThsOverRunLogMapper;
import com.njcn.process.mapper.ThsSuperviseMapper;
import com.njcn.process.service.ThsOverRunLogService;
import com.njcn.user.api.DeptFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
@@ -42,12 +44,10 @@ public class ThsOverRunLogServiceImpl extends ServiceImpl<ThsOverRunLogMapper, T
private ThsSuperviseMapper thsSuperviseMapper;
@Autowired
private FileStorageUtil fileStorageUtil;
@Override
@Transactional(rollbackFor = Exception.class)
public void saveOverRunLog(SuperviseParam superviseParam) {
this.saveBatch(superviseParam.getOverRunLog());
}
@Autowired
private DeptFeignClient deptFeignClient;
@Autowired
private PmsMonitorMapper pmsMonitorMapper;
@Override
public SuperviceRunLogVo superviseDetail(String supIndex) {
@@ -55,6 +55,9 @@ public class ThsOverRunLogServiceImpl extends ServiceImpl<ThsOverRunLogMapper, T
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, supIndex));
if (CollectionUtil.isNotEmpty(thsOverRunLogs)) {
thsOverRunLogs.forEach(item -> {
Monitor monitor = pmsMonitorMapper.selectById(item.getLineIndex());
item.setCompanyName(monitor.getOrgName());
item.setLineIndexName(monitor.getName());
if (StringUtils.isNotBlank(item.getAlarmTicket())) {
item.setAlarmTicket(fileStorageUtil.getFileUrl(item.getAlarmTicket()));
}
@@ -77,12 +80,21 @@ public class ThsOverRunLogServiceImpl extends ServiceImpl<ThsOverRunLogMapper, T
}
@Override
public HttpResult updateSupervise(SuperviseParam superviseParam) {
public HttpResult updateSupervise(SuperviceRunLogVo superviseParam) {
List<ThsOverRunLog> overRunLog = superviseParam.getOverRunLog();
if (CollectionUtil.isEmpty(overRunLog)) {
if (CollectionUtil.isEmpty(overRunLog) ||
CollectionUtil.isEmpty(overRunLog.stream().map(ThsOverRunLog::getId).collect(Collectors.toList()))) {
HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "监测点不能为空", null);
}
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, superviseParam.getSupIndex()));
ThsSupervise thsSupervise = superviseParam.getThsSupervise();
if (StringUtils.isBlank(thsSupervise.getSupIndex())) {
HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "技术监督id不能为空", null);
}
ThsSupervise supervise = thsSuperviseMapper.selectOne(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, thsSupervise.getSupIndex()));
if (!ProgressEnum.START.getCode().equals(supervise.getProgress())) {
HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "流程状态为开始才可以更新", null);
}
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, thsSupervise.getSupIndex()));
List<String> saveIds = superviseParam.getOverRunLog().stream().map(ThsOverRunLog::getId).collect(Collectors.toList());
List<String> allIds = thsOverRunLogs.stream().map(ThsOverRunLog::getId).collect(Collectors.toList());
allIds.removeAll(saveIds);

View File

@@ -264,23 +264,23 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
superviseVo.setCompanyName(deptFeignClient.getDeptById(superviseVo.getDeptId()).getData().getName());
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, superviseVo.getSupIndex()));
if (CollectionUtil.isNotEmpty(thsOverRunLogs)) {
List<String> alarmTickets = thsOverRunLogs.stream().map(ThsOverRunLog::getAlarmTicket).collect(Collectors.toList());
List<String> alarmTickets = thsOverRunLogs.stream().filter(r -> StringUtils.isNotBlank(r.getAlarmTicket())).map(ThsOverRunLog::getAlarmTicket).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(alarmTickets)) {
superviseVo.setHaveAlarmticket(true);
}
List<String> feedbacks = thsOverRunLogs.stream().map(ThsOverRunLog::getFeedback).collect(Collectors.toList());
List<String> feedbacks = thsOverRunLogs.stream().filter(r -> StringUtils.isNotBlank(r.getFeedback())).map(ThsOverRunLog::getFeedback).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(feedbacks)) {
superviseVo.setHaveFeedback(true);
}
List<String> testReports = thsOverRunLogs.stream().map(ThsOverRunLog::getTestReport).collect(Collectors.toList());
List<String> testReports = thsOverRunLogs.stream().filter(r -> StringUtils.isNotBlank(r.getTestReport())).map(ThsOverRunLog::getTestReport).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(testReports)) {
superviseVo.setHaveTestReport(true);
}
List<String> reviseNotices = thsOverRunLogs.stream().map(ThsOverRunLog::getReviseNotice).collect(Collectors.toList());
List<String> reviseNotices = thsOverRunLogs.stream().filter(r -> StringUtils.isNotBlank(r.getReviseNotice())).map(ThsOverRunLog::getReviseNotice).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(reviseNotices)) {
superviseVo.setHaveReviseNotice(true);
}
List<String> reviseFeedbacks = thsOverRunLogs.stream().map(ThsOverRunLog::getReviseFeedback).collect(Collectors.toList());
List<String> reviseFeedbacks = thsOverRunLogs.stream().filter(r -> StringUtils.isNotBlank(r.getReviseFeedback())).map(ThsOverRunLog::getReviseFeedback).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(reviseFeedbacks)) {
superviseVo.setHaveReviseFeedback(true);
}
@@ -296,27 +296,56 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
if (CollectionUtil.isNotEmpty(superviseDto.getDeleteIds())) {
superviseDto.getDeleteIds().forEach(id -> {
thsOverRunLogMapper.delete(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, id));
thsSuperviseMapper.deleteById(id);
thsSuperviseMapper.delete(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, id));
});
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, null);
}
@Override
public void uploadSuperviseTicket(String id, String supIndex, String ticketType, MultipartFile[] files, HttpServletResponse response) {
ThsSupervise thsSupervise = thsSuperviseMapper.selectOne(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, supIndex).last("limit 1"));
ThsOverRunLog thsOverRunLog = thsOverRunLogMapper.selectById(id);
thsSupervise.setSupIndex(thsOverRunLog.getSupIndex());
thsOverRunLog.setId(id);
public void uploadSuperviseTicket(String id, String supIndex, Integer ticketType, MultipartFile[] files, HttpServletResponse response) {
ThsSupervise thsSupervise = new ThsSupervise();
thsSupervise.setSupIndex(supIndex);
if (files != null && files.length == 1) {
ThsOverRunLog thsOverRunLog = thsOverRunLogMapper.selectById(id);
thsOverRunLog.setId(id);
String path = fileStorageUtil.uploadMultipart(files[0], OssPath.ELECTRICITY_QUALITY);
this.updateSuperviesData(path, thsOverRunLog, ticketType);
} else {
this.updateSuperviesData(path, thsOverRunLog, ticketType, thsSupervise);
this.updateProcess(thsSupervise, ticketType);
}
if (files != null && files.length > 1) {
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, supIndex));
this.batchUploadFile(thsSupervise, thsOverRunLogs, files, ticketType);
this.updateProcess(thsSupervise, ticketType);
}
}
/**
* 更新技术监督流程
*
* @param thsSupervise
* @param ticketType
*/
private void updateProcess(ThsSupervise thsSupervise, Integer ticketType) {
TicketTypeEnum ticketTypeEnum = TicketTypeEnum.getTicketTypeEnumByCode(ticketType);
if (ticketTypeEnum == null) {
throw new BusinessException("上传单据参数类型错误!");
}
switch (ticketTypeEnum) {
case FEEDBACK:
thsSupervise.setProgress(ProgressEnum.TEST_REPORT.getCode());
break;
case TEST_REPORT:
thsSupervise.setProgress(ProgressEnum.REVISE_NOTICE_ISSUE.getCode());
break;
case REVISE_FEEDBACK:
thsSupervise.setProgress(ProgressEnum.END.getCode());
break;
}
thsSupervise.setModifyTime(new Date());
thsSuperviseMapper.update(thsSupervise, new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, thsSupervise.getSupIndex()));
}
/**
* 批量上传文件
*
@@ -325,7 +354,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
* @param files
* @param ticketType
*/
private void batchUploadFile(ThsSupervise thsSupervise, List<ThsOverRunLog> thsOverRunLogs, MultipartFile[] files, String ticketType) {
private void batchUploadFile(ThsSupervise thsSupervise, List<ThsOverRunLog> thsOverRunLogs, MultipartFile[] files, Integer ticketType) {
if (files != null && files.length > 1) {
List<ThsOverRunLog> excelData = new ArrayList<>();
for (int i = 0; i < files.length; i++) {
@@ -346,7 +375,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
String originalFilename = files[i].getOriginalFilename();
String filename = originalFilename.substring(0, originalFilename.lastIndexOf("."));
if (StringUtils.equals(filename, thsOverRunLogDto.getLineIndexName())) {
this.uploadFile(files[i], ticketType, thsOverRunLog);
this.uploadFile(files[i], ticketType, thsOverRunLog, thsSupervise);
}
}
}
@@ -355,12 +384,20 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
}
}
private void uploadFile(MultipartFile file, String ticketType, ThsOverRunLog thsOverRunLog) {
private void uploadFile(MultipartFile file, Integer ticketType, ThsOverRunLog thsOverRunLog, ThsSupervise thsSupervise) {
String path = fileStorageUtil.uploadMultipart(file, OssPath.ELECTRICITY_QUALITY);
this.updateSuperviesData(path, thsOverRunLog, ticketType);
this.updateSuperviesData(path, thsOverRunLog, ticketType, thsSupervise);
}
private void updateSuperviesData(String path, ThsOverRunLog thsOverRunLog, String ticketType) {
/**
* 更新技术监督监测点数据
*
* @param path
* @param thsOverRunLog
* @param ticketType
* @param thsSupervise
*/
private void updateSuperviesData(String path, ThsOverRunLog thsOverRunLog, Integer ticketType, ThsSupervise thsSupervise) {
TicketTypeEnum ticketTypeEnum = TicketTypeEnum.getTicketTypeEnumByCode(ticketType);
if (ticketTypeEnum == null) {
throw new BusinessException("上传单据参数类型错误!");
@@ -411,10 +448,25 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
}
@Override
public String dowloadAlarmFormwork(Integer type, Integer formworkType, HttpServletResponse response) {
public String dowloadAlarmFormwork(Integer type, Integer formworkType, String supIndex, HttpServletResponse response) {
ThsAlarmFormwork thsAlarmFormwork = thsAlarmFormworkMapper.selectOne(new LambdaQueryWrapper<ThsAlarmFormwork>().eq(ThsAlarmFormwork::getFormworkType, formworkType)
.eq(ThsAlarmFormwork::getType, type).last("limit 1"));
return fileStorageUtil.getFileUrl(thsAlarmFormwork.getPath());
String fileUrl = fileStorageUtil.getFileUrl(thsAlarmFormwork.getPath());
ThsSupervise thsSupervise = new ThsSupervise();
thsSupervise.setModifyTime(new Date());
ThsOverRunLog thsOverRunLog = new ThsOverRunLog();
thsOverRunLog.setSupIndex(supIndex);
if (FormworkTypeEnum.ALARM_TICKET.getCode().equals(formworkType)) {
thsSupervise.setProgress(ProgressEnum.FEEDBACK_UPLOAD.getCode());
thsOverRunLog.setAlarmTicket(fileUrl);
}
if (FormworkTypeEnum.RECTIFY_TICKET.getCode().equals(formworkType)) {
thsSupervise.setProgress(ProgressEnum.REVISE_FEEDBACK.getCode());
thsOverRunLog.setReviseNotice(thsAlarmFormwork.getPath());
}
thsOverRunLogMapper.update(thsOverRunLog, new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, supIndex));
thsSuperviseMapper.update(thsSupervise, new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, supIndex));
return fileUrl;
}
@Override
@@ -455,7 +507,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
}
}
thsSuperviseVo.setSuperviseVoList(pageRecords);
//分组处理每种流程状态的数量
//分组计算每种流程状态的数量
Map<Integer, List<SuperviseVo>> map = pageRecords.stream().collect(Collectors.groupingBy(SuperviseVo::getProgress));
for (Map.Entry<Integer, List<SuperviseVo>> entry : map.entrySet()) {
Integer code = entry.getKey();
@@ -483,7 +535,19 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
break;
}
}
//分组计算预/告警单数量
Map<Integer, List<SuperviseVo>> typeMap = pageRecords.stream().collect(Collectors.groupingBy(SuperviseVo::getType));
for (Map.Entry<Integer, List<SuperviseVo>> entry : typeMap.entrySet()) {
Integer code = entry.getKey();
switch (AlarmTypeEnum.getAlarmTypeEnumByCode(code)) {
case EARLY_WARN:
thsSuperviseVo.setEarlyWarnNum(entry.getValue().size());
break;
case REPORT_WARN:
thsSuperviseVo.setReportWarnNum(entry.getValue().size());
break;
}
}
}
thsSuperviseVoPage.setRecords(Collections.singletonList(thsSuperviseVo));
return thsSuperviseVoPage;
@@ -577,9 +641,9 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
thsOverRunLog.setCreateTime(new Date());
thsOverRunLog.setCompanyName(monitor.getOrgName());
thsOverRunLog.setLineIndexName(monitor.getName());
List<String> descriptionList = (List) limitBoolMap.get(DESCRIPTION);
List descriptionList = (List) limitBoolMap.get(DESCRIPTION);
thsOverRunLog.setDescription(StringUtils.join(descriptionList, ","));
thsOverRunLog.setOverTime(limitRate.getAlltime());
thsOverRunLogs.add(thsOverRunLog);
}