批量下载技术监督反馈文件
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
package com.njcn.oss.utils;
|
package com.njcn.oss.utils;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
|
||||||
import cn.hutool.http.HttpUtil;
|
|
||||||
import com.njcn.common.config.GeneralInfo;
|
import com.njcn.common.config.GeneralInfo;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.huawei.obs.util.OBSUtil;
|
import com.njcn.huawei.obs.util.OBSUtil;
|
||||||
@@ -17,7 +15,6 @@ import org.springframework.http.MediaType;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
@@ -90,7 +87,7 @@ public class FileStorageUtil {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
//把名称存入数据
|
//把名称存入数据
|
||||||
MinIoUploadResDTO minIoUploadResDTO = minIoUtils.uploadStream(fileStream, minIossProperties.getBucket(), dir,minIoUtils.minFileName(fileName));
|
MinIoUploadResDTO minIoUploadResDTO = minIoUtils.uploadStream(fileStream, minIossProperties.getBucket(), dir, minIoUtils.minFileName(fileName));
|
||||||
filePath = minIoUploadResDTO.getMinFileName();
|
filePath = minIoUploadResDTO.getMinFileName();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BusinessException(OssResponseEnum.UPLOAD_FILE_ERROR);
|
throw new BusinessException(OssResponseEnum.UPLOAD_FILE_ERROR);
|
||||||
@@ -106,7 +103,7 @@ public class FileStorageUtil {
|
|||||||
* @date 2023/3/7 23:04
|
* @date 2023/3/7 23:04
|
||||||
* @param filePath 文件在服务器的路径
|
* @param filePath 文件在服务器的路径
|
||||||
*/
|
*/
|
||||||
public String getFileUrl(String filePath){
|
public String getFileUrl(String filePath) {
|
||||||
String url;
|
String url;
|
||||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||||
url = obsUtil.getFileUrl(filePath);
|
url = obsUtil.getFileUrl(filePath);
|
||||||
@@ -117,14 +114,13 @@ public class FileStorageUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 根据文件路径获取文件流
|
* 根据文件路径获取文件流
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
* @date 2023/3/7 23:04
|
* @date 2023/3/7 23:04
|
||||||
* @param filePath 文件在服务器的路径
|
* @param filePath 文件在服务器的路径
|
||||||
*/
|
*/
|
||||||
public InputStream getFileStream(String filePath){
|
public InputStream getFileStream(String filePath) {
|
||||||
InputStream inputStream;
|
InputStream inputStream;
|
||||||
try {
|
try {
|
||||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||||
@@ -132,7 +128,7 @@ public class FileStorageUtil {
|
|||||||
} else {
|
} else {
|
||||||
inputStream = minIoUtils.downloadStream(minIossProperties.getBucket(), filePath);
|
inputStream = minIoUtils.downloadStream(minIossProperties.getBucket(), filePath);
|
||||||
}
|
}
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
throw new BusinessException(OssResponseEnum.DOWNLOAD_FILE_STREAM_ERROR);
|
throw new BusinessException(OssResponseEnum.DOWNLOAD_FILE_STREAM_ERROR);
|
||||||
}
|
}
|
||||||
return inputStream;
|
return inputStream;
|
||||||
@@ -147,17 +143,17 @@ public class FileStorageUtil {
|
|||||||
public void downloadStream(HttpServletResponse response, String filePath) throws IOException {
|
public void downloadStream(HttpServletResponse response, String filePath) throws IOException {
|
||||||
InputStream inputStream;
|
InputStream inputStream;
|
||||||
OutputStream toClient = null;
|
OutputStream toClient = null;
|
||||||
try{
|
try {
|
||||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||||
inputStream = obsUtil.downloadStream(filePath);
|
inputStream = obsUtil.downloadStream(filePath);
|
||||||
} else {
|
} else {
|
||||||
inputStream = minIoUtils.downloadStream(minIossProperties.getBucket(), filePath);
|
inputStream = minIoUtils.downloadStream(minIossProperties.getBucket(), filePath);
|
||||||
}
|
}
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
throw new BusinessException(OssResponseEnum.DOWNLOAD_FILE_STREAM_ERROR);
|
throw new BusinessException(OssResponseEnum.DOWNLOAD_FILE_STREAM_ERROR);
|
||||||
}
|
}
|
||||||
String fileType = filePath.substring(filePath.lastIndexOf('.')).toLowerCase();
|
String fileType = filePath.substring(filePath.lastIndexOf('.')).toLowerCase();
|
||||||
switch (fileType){
|
switch (fileType) {
|
||||||
case "jpg":
|
case "jpg":
|
||||||
case "jpeg":
|
case "jpeg":
|
||||||
case "png":
|
case "png":
|
||||||
@@ -187,8 +183,26 @@ public class FileStorageUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取下载文件流
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public InputStream downloadStream(String filePath) {
|
||||||
|
InputStream inputStream;
|
||||||
|
try {
|
||||||
|
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||||
|
inputStream = obsUtil.downloadStream(filePath);
|
||||||
|
} else {
|
||||||
|
inputStream = minIoUtils.downloadStream(minIossProperties.getBucket(), filePath);
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
throw new BusinessException(OssResponseEnum.DOWNLOAD_FILE_STREAM_ERROR);
|
||||||
|
}
|
||||||
|
return inputStream;
|
||||||
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 根据文件路径删除指定文件对象
|
* 根据文件路径删除指定文件对象
|
||||||
@@ -196,10 +210,10 @@ public class FileStorageUtil {
|
|||||||
* @date 2023/3/8 9:25
|
* @date 2023/3/8 9:25
|
||||||
* @param fileName 文件路径名
|
* @param fileName 文件路径名
|
||||||
*/
|
*/
|
||||||
public void deleteFile(String fileName){
|
public void deleteFile(String fileName) {
|
||||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||||
obsUtil.delete(fileName);
|
obsUtil.delete(fileName);
|
||||||
}else{
|
} else {
|
||||||
minIoUtils.removeObject(minIossProperties.getBucket(), fileName);
|
minIoUtils.removeObject(minIossProperties.getBucket(), fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.njcn.common.pojo.constant.ServerInfo;
|
|||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.prepare.harmonic.api.line.fallback.CoustomReportFeignClientFallbackFactory;
|
import com.njcn.prepare.harmonic.api.line.fallback.CoustomReportFeignClientFallbackFactory;
|
||||||
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
||||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@@ -23,5 +22,5 @@ public interface ThsSuperviseClient {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/initSupervise")
|
@PostMapping("/initSupervise")
|
||||||
HttpResult<SuperviceRunLogVo> initSupervise(@RequestBody @Validated SuperviseParam superviseParam);
|
HttpResult<String> initSupervise(@RequestBody @Validated SuperviseParam superviseParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.njcn.common.pojo.response.HttpResult;
|
|||||||
import com.njcn.device.pq.utils.DeviceEnumUtil;
|
import com.njcn.device.pq.utils.DeviceEnumUtil;
|
||||||
import com.njcn.prepare.harmonic.api.line.ThsSuperviseClient;
|
import com.njcn.prepare.harmonic.api.line.ThsSuperviseClient;
|
||||||
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
||||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
|
|
||||||
import feign.hystrix.FallbackFactory;
|
import feign.hystrix.FallbackFactory;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -26,7 +25,7 @@ public class ThsSuperviseClientFallbackFactory implements FallbackFactory<ThsSup
|
|||||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
return new ThsSuperviseClient() {
|
return new ThsSuperviseClient() {
|
||||||
@Override
|
@Override
|
||||||
public HttpResult<SuperviceRunLogVo> initSupervise(@RequestBody @Validated SuperviseParam superviseParam) {
|
public HttpResult<String> initSupervise(@RequestBody @Validated SuperviseParam superviseParam) {
|
||||||
log.error("{}异常,降级处理,异常为:{}", "预警/告警事务的生成: ", throwable.toString());
|
log.error("{}异常,降级处理,异常为:{}", "预警/告警事务的生成: ", throwable.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.njcn.prepare.harmonic.controller.line;
|
|||||||
|
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
||||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
|
|
||||||
import com.njcn.prepare.harmonic.service.mysql.line.ThsSuperviseService;
|
import com.njcn.prepare.harmonic.service.mysql.line.ThsSuperviseService;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -32,8 +31,8 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
@ApiImplicitParam(name = "superviseParam", value = "创建技术监督参数", required = true)
|
@ApiImplicitParam(name = "superviseParam", value = "创建技术监督参数", required = true)
|
||||||
@PostMapping("/initSupervise")
|
@PostMapping("/initSupervise")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public HttpResult<SuperviceRunLogVo> initSupervise(@RequestBody @Validated SuperviseParam superviseParam) {
|
public HttpResult<String> initSupervise(@RequestBody @Validated SuperviseParam superviseParam) {
|
||||||
HttpResult<SuperviceRunLogVo> superviceRunLogVoHttpResult = thsSuperviseService.initSupervise(superviseParam);
|
HttpResult<String> superviceRunLogVoHttpResult = thsSuperviseService.initSupervise(superviseParam);
|
||||||
return superviceRunLogVoHttpResult;
|
return superviceRunLogVoHttpResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.njcn.prepare.harmonic.service.mysql.Impl.line;
|
|||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -78,7 +79,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
private static final String DESCRIPTION = "description";
|
private static final String DESCRIPTION = "description";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpResult<SuperviceRunLogVo> initSupervise(SuperviseParam superviseParam) {
|
public HttpResult<String> initSupervise(SuperviseParam superviseParam) {
|
||||||
SuperviceRunLogVo superviceRunLogVo = new SuperviceRunLogVo();
|
SuperviceRunLogVo superviceRunLogVo = new SuperviceRunLogVo();
|
||||||
List<ThsOverRunLog> overRunLogList = new ArrayList<>();
|
List<ThsOverRunLog> overRunLogList = new ArrayList<>();
|
||||||
if (InitTypeEnum.MANUAL.getCode().equals(superviseParam.getInitType()) && StringUtils.isBlank(superviseParam.getDeptId())) {
|
if (InitTypeEnum.MANUAL.getCode().equals(superviseParam.getInitType()) && StringUtils.isBlank(superviseParam.getDeptId())) {
|
||||||
@@ -178,7 +179,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, superviceRunLogVo, "");
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, JSON.toJSONString(superviceRunLogVo), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
package com.njcn.prepare.harmonic.service.mysql.line;
|
package com.njcn.prepare.harmonic.service.mysql.line;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.device.pms.pojo.po.Monitor;
|
import com.njcn.device.pms.pojo.po.Monitor;
|
||||||
import com.njcn.harmonic.pojo.vo.SourceSteadyIndicator;
|
import com.njcn.harmonic.pojo.vo.SourceSteadyIndicator;
|
||||||
import com.njcn.harmonic.pojo.vo.ThsStrategyVo;
|
import com.njcn.harmonic.pojo.vo.ThsStrategyVo;
|
||||||
import com.njcn.prepare.enums.TypeEnum;
|
import com.njcn.prepare.enums.TypeEnum;
|
||||||
import com.njcn.prepare.harmonic.pojo.dto.SuperviseDto;
|
|
||||||
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
||||||
import com.njcn.prepare.harmonic.pojo.po.ThsOverRunLog;
|
import com.njcn.prepare.harmonic.pojo.po.ThsOverRunLog;
|
||||||
import com.njcn.prepare.harmonic.pojo.po.ThsSupervise;
|
import com.njcn.prepare.harmonic.pojo.po.ThsSupervise;
|
||||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
|
|
||||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviseVo;
|
|
||||||
import com.njcn.process.pojo.po.LimitRate;
|
import com.njcn.process.pojo.po.LimitRate;
|
||||||
import com.njcn.process.pojo.po.ThsWarnStrategyAss;
|
import com.njcn.process.pojo.po.ThsWarnStrategyAss;
|
||||||
import com.njcn.user.pojo.po.Dept;
|
import com.njcn.user.pojo.po.Dept;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -34,7 +28,7 @@ public interface ThsSuperviseService extends IService<ThsSupervise> {
|
|||||||
/**
|
/**
|
||||||
* 初始化技术监督
|
* 初始化技术监督
|
||||||
*/
|
*/
|
||||||
HttpResult<SuperviceRunLogVo> initSupervise(SuperviseParam superviseParam);
|
HttpResult<String> initSupervise(SuperviseParam superviseParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查新策略集合
|
* 查新策略集合
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.njcn.process.pojo.param;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FileParam {
|
||||||
|
@ApiModelProperty(value = "技术监督监测点记录id集合", required = true)
|
||||||
|
@NotNull(message = "技术监督监测点记录id集合不能为空")
|
||||||
|
private List<String> ids;
|
||||||
|
@ApiModelProperty(value = "下载的单据类型:1 反馈单,2 测试报告,4 整改通知反馈单", required = true)
|
||||||
|
@NotNull(message = "下载的单据类型不能为空")
|
||||||
|
private Integer ticketType;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
package com.njcn.process.controller;
|
package com.njcn.process.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
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.constant.OperateType;
|
||||||
|
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.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
@@ -11,6 +15,7 @@ import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
|||||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
|
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
|
||||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviseVo;
|
import com.njcn.prepare.harmonic.pojo.vo.SuperviseVo;
|
||||||
import com.njcn.prepare.harmonic.pojo.vo.ThsSuperviseVo;
|
import com.njcn.prepare.harmonic.pojo.vo.ThsSuperviseVo;
|
||||||
|
import com.njcn.process.pojo.param.FileParam;
|
||||||
import com.njcn.process.service.ThsOverRunLogService;
|
import com.njcn.process.service.ThsOverRunLogService;
|
||||||
import com.njcn.process.service.ThsSuperviseService;
|
import com.njcn.process.service.ThsSuperviseService;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
@@ -19,10 +24,12 @@ 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 org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -46,14 +53,18 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ThsSuperviseClient thsSuperviseClient;
|
private ThsSuperviseClient thsSuperviseClient;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@ApiOperation("预警/告警事务生成")
|
@ApiOperation("预警/告警事务生成")
|
||||||
@ApiImplicitParam(name = "superviseParam", value = "创建技术监督参数", required = true)
|
@ApiImplicitParam(name = "superviseParam", value = "创建技术监督参数", required = true)
|
||||||
@PostMapping("/initSupervise")
|
@PostMapping("/initSupervise")
|
||||||
public HttpResult<SuperviceRunLogVo> initSupervise(@RequestBody @Validated SuperviseParam superviseParam) {
|
public HttpResult<SuperviceRunLogVo> initSupervise(@RequestBody @Validated SuperviseParam superviseParam) {
|
||||||
HttpResult<SuperviceRunLogVo> superviceRunLogVoHttpResult = thsSuperviseService.initSupervise(superviseParam);
|
String methodDescribe = getMethodDescribe("initSupervise");
|
||||||
return superviceRunLogVoHttpResult;
|
HttpResult<String> superviceRunLogVoHttpResult = thsSuperviseClient.initSupervise(superviseParam);
|
||||||
|
SuperviceRunLogVo superviceRunLogVo = JSON.parseObject(superviceRunLogVoHttpResult.getData(), SuperviceRunLogVo.class);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, superviceRunLogVo, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||||
@ApiOperation("保存技术监督监测点")
|
@ApiOperation("保存技术监督监测点")
|
||||||
@ApiImplicitParam(name = "superviceRunLogVo", value = "技术监督监测点参数", required = true)
|
@ApiImplicitParam(name = "superviceRunLogVo", value = "技术监督监测点参数", required = true)
|
||||||
@PostMapping("/saveOverRunLog")
|
@PostMapping("/saveOverRunLog")
|
||||||
@@ -63,6 +74,7 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||||
@ApiOperation("更新技术监督")
|
@ApiOperation("更新技术监督")
|
||||||
@ApiImplicitParam(name = "superviceRunLogVo", value = "更新技术监督参数", required = true)
|
@ApiImplicitParam(name = "superviceRunLogVo", value = "更新技术监督参数", required = true)
|
||||||
@PostMapping("/updateSupervice")
|
@PostMapping("/updateSupervice")
|
||||||
@@ -70,7 +82,7 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
return thsOverRunLogService.updateSupervise(superviceRunLogVo);
|
return thsOverRunLogService.updateSupervise(superviceRunLogVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@ApiOperation("技术监督详情")
|
@ApiOperation("技术监督详情")
|
||||||
@ApiImplicitParam(name = "supIndex", value = "技术监督id", required = true)
|
@ApiImplicitParam(name = "supIndex", value = "技术监督id", required = true)
|
||||||
@PostMapping("/superviseDetail")
|
@PostMapping("/superviseDetail")
|
||||||
@@ -80,6 +92,8 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
|
||||||
@ApiOperation("删除技术监督")
|
@ApiOperation("删除技术监督")
|
||||||
@ApiImplicitParam(name = "superviseDto", value = "删除技术监督请求体", required = true)
|
@ApiImplicitParam(name = "superviseDto", value = "删除技术监督请求体", required = true)
|
||||||
@PostMapping("/deleteSupervise")
|
@PostMapping("/deleteSupervise")
|
||||||
@@ -87,6 +101,8 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
return thsSuperviseService.deleteSupervise(superviseDto);
|
return thsSuperviseService.deleteSupervise(superviseDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@ApiOperation("查询技术监督列表")
|
@ApiOperation("查询技术监督列表")
|
||||||
@ApiImplicitParam(name = "superviseDto", value = "查询技术监督列表参数", required = true)
|
@ApiImplicitParam(name = "superviseDto", value = "查询技术监督列表参数", required = true)
|
||||||
@PostMapping("/querySuperviseList")
|
@PostMapping("/querySuperviseList")
|
||||||
@@ -96,6 +112,7 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pageResult, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pageResult, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@ApiOperation("上传技术监督单据")
|
@ApiOperation("上传技术监督单据")
|
||||||
@PostMapping("/uploadSuperviseTicket")
|
@PostMapping("/uploadSuperviseTicket")
|
||||||
public HttpResult uploadSuperviseTicket(@ApiParam(value = "文件", required = true)
|
public HttpResult uploadSuperviseTicket(@ApiParam(value = "文件", required = true)
|
||||||
@@ -110,6 +127,8 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@ApiOperation("查询流程状态列表")
|
@ApiOperation("查询流程状态列表")
|
||||||
@PostMapping("/queryProgressValues")
|
@PostMapping("/queryProgressValues")
|
||||||
public HttpResult queryProgressValues() {
|
public HttpResult queryProgressValues() {
|
||||||
@@ -119,6 +138,7 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||||
@ApiOperation("上传单据模板")
|
@ApiOperation("上传单据模板")
|
||||||
@PostMapping("/uploadAlarmFormwork")
|
@PostMapping("/uploadAlarmFormwork")
|
||||||
public HttpResult uploadAlarmFormwork(@ApiParam(value = "文件", required = true)
|
public HttpResult uploadAlarmFormwork(@ApiParam(value = "文件", required = true)
|
||||||
@@ -131,6 +151,7 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||||
@ApiOperation("下载单据模板")
|
@ApiOperation("下载单据模板")
|
||||||
@PostMapping("/dowloadAlarmFormwork")
|
@PostMapping("/dowloadAlarmFormwork")
|
||||||
public HttpResult dowloadAlarmFormwork(@ApiParam(name = "type", value = "类型(0:预警;1:告警)", required = true) @RequestParam("type") Integer type,
|
public HttpResult dowloadAlarmFormwork(@ApiParam(name = "type", value = "类型(0:预警;1:告警)", required = true) @RequestParam("type") Integer type,
|
||||||
@@ -142,6 +163,7 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, httpPath, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, httpPath, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@ApiOperation("技术监督首页")
|
@ApiOperation("技术监督首页")
|
||||||
@ApiImplicitParam(name = "superviseDto", value = "查询技术监督列表参数", required = true)
|
@ApiImplicitParam(name = "superviseDto", value = "查询技术监督列表参数", required = true)
|
||||||
@PostMapping("/superviseIndex")
|
@PostMapping("/superviseIndex")
|
||||||
@@ -150,5 +172,16 @@ public class ThsSuperviseController extends BaseController {
|
|||||||
String methodDescribe = getMethodDescribe("superviseIndex");
|
String methodDescribe = getMethodDescribe("superviseIndex");
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pageResult, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pageResult, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||||
|
@PostMapping(value = "/downloadFeedBackFile", produces = {MediaType.APPLICATION_OCTET_STREAM_VALUE, MediaType.APPLICATION_JSON_VALUE})
|
||||||
|
@ApiOperation("技术监督反馈文件下载")
|
||||||
|
@ApiImplicitParam(name = "fileParam", value = "反馈文件下载参数", required = true)
|
||||||
|
public HttpResult downloadFeedBackFile(@RequestBody @Validated FileParam fileParam, HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
String methodDescribe = getMethodDescribe("downloadFeedBackFile");
|
||||||
|
HttpServletResponse resp = thsSuperviseService.downloadFeedBackFile(fileParam, request, response);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resp, methodDescribe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
|
|||||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviseVo;
|
import com.njcn.prepare.harmonic.pojo.vo.SuperviseVo;
|
||||||
import com.njcn.prepare.harmonic.pojo.vo.ThsSuperviseVo;
|
import com.njcn.prepare.harmonic.pojo.vo.ThsSuperviseVo;
|
||||||
import com.njcn.process.enums.TypeEnum;
|
import com.njcn.process.enums.TypeEnum;
|
||||||
|
import com.njcn.process.pojo.param.FileParam;
|
||||||
import com.njcn.process.pojo.po.LimitRate;
|
import com.njcn.process.pojo.po.LimitRate;
|
||||||
import com.njcn.process.pojo.po.ThsWarnStrategyAss;
|
import com.njcn.process.pojo.po.ThsWarnStrategyAss;
|
||||||
import com.njcn.user.pojo.po.Dept;
|
import com.njcn.user.pojo.po.Dept;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -87,8 +89,6 @@ public interface ThsSuperviseService extends IService<ThsSupervise> {
|
|||||||
void buildOverRunLog(SourceSteadyIndicator steady, ThsSupervise thsSupervise, Monitor monitor, LimitRate limitRate, Map<String, Object> limitBoolMap, Integer initType, List<ThsOverRunLog> thsOverRunLogs);
|
void buildOverRunLog(SourceSteadyIndicator steady, ThsSupervise thsSupervise, Monitor monitor, LimitRate limitRate, Map<String, Object> limitBoolMap, Integer initType, List<ThsOverRunLog> thsOverRunLogs);
|
||||||
|
|
||||||
|
|
||||||
void deleteTodayData(String depId, Integer initType);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成技术监督数据
|
* 生成技术监督数据
|
||||||
*
|
*
|
||||||
@@ -163,4 +163,13 @@ public interface ThsSuperviseService extends IService<ThsSupervise> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Page<ThsSuperviseVo> superviseIndex(SuperviseDto superviseDto);
|
Page<ThsSuperviseVo> superviseIndex(SuperviseDto superviseDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载反馈文件
|
||||||
|
*
|
||||||
|
* @param fileParam
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
HttpServletResponse downloadFeedBackFile(FileParam fileParam, HttpServletRequest request, HttpServletResponse response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import com.njcn.process.annotaion.HarVoltage;
|
|||||||
import com.njcn.process.annotaion.InterharVoltage;
|
import com.njcn.process.annotaion.InterharVoltage;
|
||||||
import com.njcn.process.enums.*;
|
import com.njcn.process.enums.*;
|
||||||
import com.njcn.process.mapper.*;
|
import com.njcn.process.mapper.*;
|
||||||
|
import com.njcn.process.pojo.param.FileParam;
|
||||||
import com.njcn.process.pojo.po.LimitRate;
|
import com.njcn.process.pojo.po.LimitRate;
|
||||||
import com.njcn.process.pojo.po.ThsAlarmFormwork;
|
import com.njcn.process.pojo.po.ThsAlarmFormwork;
|
||||||
import com.njcn.process.pojo.po.ThsWarnStrategyAss;
|
import com.njcn.process.pojo.po.ThsWarnStrategyAss;
|
||||||
@@ -49,10 +50,17 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.zip.Adler32;
|
||||||
|
import java.util.zip.CheckedOutputStream;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -461,7 +469,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
thsOverRunLog.setSupIndex(supIndex);
|
thsOverRunLog.setSupIndex(supIndex);
|
||||||
if (FormworkTypeEnum.ALARM_TICKET.getCode().equals(formworkType)) {
|
if (FormworkTypeEnum.ALARM_TICKET.getCode().equals(formworkType)) {
|
||||||
thsSupervise.setProgress(ProgressEnum.FEEDBACK_UPLOAD.getCode());
|
thsSupervise.setProgress(ProgressEnum.FEEDBACK_UPLOAD.getCode());
|
||||||
thsOverRunLog.setAlarmTicket(fileUrl);
|
thsOverRunLog.setAlarmTicket(thsAlarmFormwork.getPath());
|
||||||
}
|
}
|
||||||
if (FormworkTypeEnum.RECTIFY_TICKET.getCode().equals(formworkType)) {
|
if (FormworkTypeEnum.RECTIFY_TICKET.getCode().equals(formworkType)) {
|
||||||
thsSupervise.setProgress(ProgressEnum.REVISE_FEEDBACK.getCode());
|
thsSupervise.setProgress(ProgressEnum.REVISE_FEEDBACK.getCode());
|
||||||
@@ -663,24 +671,96 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重复执行删除旧数据
|
|
||||||
*
|
|
||||||
* @param depId
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
@DS("process")
|
public HttpServletResponse downloadFeedBackFile(FileParam fileParam, HttpServletRequest request, HttpServletResponse response) {
|
||||||
public void deleteTodayData(String depId, Integer initType) {
|
TicketTypeEnum ticketTypeEnum = TicketTypeEnum.getTicketTypeEnumByCode(fileParam.getTicketType());
|
||||||
ThsSupervise thsSupervise = thsSuperviseMapper.selectOne(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getDeptId, depId)
|
if (ticketTypeEnum == null) {
|
||||||
.eq(ThsSupervise::getCreateType, initType)
|
throw new BusinessException("上传单据参数类型错误!");
|
||||||
.between(ThsSupervise::getCreateTime,
|
|
||||||
DateUtil.beginOfDay(new Date()),
|
|
||||||
DateUtil.endOfDay(new Date())).last("limit 1"));
|
|
||||||
if (thsSupervise != null) {
|
|
||||||
thsOverRunLogMapper.delete(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, thsSupervise.getSupIndex()));
|
|
||||||
thsSuperviseMapper.delete(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, thsSupervise.getSupIndex()));
|
|
||||||
}
|
}
|
||||||
|
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().in(ThsOverRunLog::getId, fileParam.getIds()));
|
||||||
|
if (CollectionUtil.isNotEmpty(thsOverRunLogs)) {
|
||||||
|
Map<String, String> filePathMap = new HashedMap();
|
||||||
|
switch (ticketTypeEnum) {
|
||||||
|
case FEEDBACK:
|
||||||
|
filePathMap = thsOverRunLogs.stream().filter(r -> StringUtils.isNotBlank(r.getFeedback())).collect(Collectors.toMap(ThsOverRunLog::getId, ThsOverRunLog::getFeedback));
|
||||||
|
break;
|
||||||
|
case TEST_REPORT:
|
||||||
|
filePathMap = thsOverRunLogs.stream().filter(r -> StringUtils.isNotBlank(r.getTestReport())).collect(Collectors.toMap(ThsOverRunLog::getId, ThsOverRunLog::getTestReport));
|
||||||
|
|
||||||
|
break;
|
||||||
|
case REVISE_FEEDBACK:
|
||||||
|
filePathMap = thsOverRunLogs.stream().filter(r -> StringUtils.isNotBlank(r.getReviseFeedback())).collect(Collectors.toMap(ThsOverRunLog::getId, ThsOverRunLog::getReviseFeedback));
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
response = this.dowloadZipFile(fileParam, filePathMap, request, response, ticketTypeEnum);
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量下载.zip文件
|
||||||
|
*
|
||||||
|
* @param fileParam
|
||||||
|
* @param filePathMap
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private HttpServletResponse dowloadZipFile(FileParam fileParam, Map<String, String> filePathMap, HttpServletRequest request, HttpServletResponse response, TicketTypeEnum ticketTypeEnum) {
|
||||||
|
try {
|
||||||
|
if (CollectionUtil.isNotEmpty(filePathMap)) {
|
||||||
|
ThsOverRunLog thsOverRunLog = thsOverRunLogMapper.selectById(fileParam.getIds().get(0));
|
||||||
|
ThsSupervise thsSupervise = thsSuperviseMapper.selectOne(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, thsOverRunLog.getSupIndex()).last("limit 1"));
|
||||||
|
//改为自己的名称
|
||||||
|
String fileName = thsSupervise.getName() + ".zip";
|
||||||
|
// 创建临时文件
|
||||||
|
File zipFile = File.createTempFile(thsSupervise.getName(), ".zip");
|
||||||
|
FileOutputStream f = new FileOutputStream(zipFile);
|
||||||
|
/**
|
||||||
|
* 作用是为任何OutputStream产生校验和
|
||||||
|
* 第一个参数是制定产生校验和的输出流,第二个参数是指定Checksum的类型 (Adler32(较快)和CRC32两种)
|
||||||
|
*/
|
||||||
|
CheckedOutputStream csum = new CheckedOutputStream(f, new Adler32());
|
||||||
|
// 用于将数据压缩成Zip文件格式
|
||||||
|
ZipOutputStream zos = new ZipOutputStream(csum);
|
||||||
|
for (Map.Entry<String, String> entry : filePathMap.entrySet()) {
|
||||||
|
ThsOverRunLog runLog = thsOverRunLogMapper.selectById(entry.getKey());
|
||||||
|
Monitor monitor = pmsMonitorMapper.selectById(runLog.getLineIndex());
|
||||||
|
InputStream inputStream = fileStorageUtil.downloadStream(entry.getValue());
|
||||||
|
// 对于每一个要被存放到压缩包的文件,都必须调用ZipOutputStream对象的putNextEntry()方法,确保压缩包里面文件不同名
|
||||||
|
zos.putNextEntry(new ZipEntry(monitor.getName() + ticketTypeEnum.getMessage() + entry.getValue().substring(entry.getValue().lastIndexOf("."))));
|
||||||
|
int bytesRead = 0;
|
||||||
|
// 向压缩文件中输出数据
|
||||||
|
while ((bytesRead = inputStream.read()) != -1) {
|
||||||
|
zos.write(bytesRead);
|
||||||
|
}
|
||||||
|
inputStream.close();
|
||||||
|
zos.closeEntry(); // 当前文件写完,定位为写入下一条项目
|
||||||
|
}
|
||||||
|
zos.close();
|
||||||
|
InputStream fis = new BufferedInputStream(new FileInputStream(zipFile));
|
||||||
|
byte[] buffer = new byte[fis.available()];
|
||||||
|
fis.read(buffer);
|
||||||
|
fis.close();
|
||||||
|
// 清空response
|
||||||
|
response.reset();
|
||||||
|
// 设置response的Header
|
||||||
|
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
|
||||||
|
response.addHeader("Content-Length", "" + zipFile.length());
|
||||||
|
OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
toClient.write(buffer);
|
||||||
|
toClient.flush();
|
||||||
|
toClient.close();
|
||||||
|
zipFile.delete();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("批量下载.zip文件异常:{}", e.toString());
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断监测数据是否超标
|
* 判断监测数据是否超标
|
||||||
|
|||||||
Reference in New Issue
Block a user