波形下载接口开发
This commit is contained in:
@@ -14,6 +14,7 @@ import com.njcn.csdevice.pojo.po.PortableOfflLog;
|
|||||||
import com.njcn.csdevice.service.IPortableOfflLogService;
|
import com.njcn.csdevice.service.IPortableOfflLogService;
|
||||||
import com.njcn.csdevice.utils.ExcelStyleUtil;
|
import com.njcn.csdevice.utils.ExcelStyleUtil;
|
||||||
import com.njcn.csdevice.param.UploadDataParam;
|
import com.njcn.csdevice.param.UploadDataParam;
|
||||||
|
import com.njcn.minioss.config.MinIossProperties;
|
||||||
import com.njcn.oss.utils.FileStorageUtil;
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
import com.njcn.poi.excel.ExcelUtil;
|
import com.njcn.poi.excel.ExcelUtil;
|
||||||
import com.njcn.poi.util.PoiUtil;
|
import com.njcn.poi.util.PoiUtil;
|
||||||
@@ -56,7 +57,7 @@ public class PortableOfflLogController extends BaseController {
|
|||||||
private final DicDataFeignClient dicDataFeignClient;
|
private final DicDataFeignClient dicDataFeignClient;
|
||||||
|
|
||||||
private final FileStorageUtil fileStorageUtil;
|
private final FileStorageUtil fileStorageUtil;
|
||||||
|
private final MinIossProperties minIossProperties;
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ApiOperation("导出设备基础数据模板")
|
@ApiOperation("导出设备基础数据模板")
|
||||||
@GetMapping(value = "getExcelTemplate")
|
@GetMapping(value = "getExcelTemplate")
|
||||||
@@ -120,7 +121,7 @@ public class PortableOfflLogController extends BaseController {
|
|||||||
|
|
||||||
List<MultipartFile> excelreport = null;
|
List<MultipartFile> excelreport = null;
|
||||||
try {
|
try {
|
||||||
excelreport = fileStorageUtil.getAllFile("excelreport", path);
|
excelreport = fileStorageUtil.getAllFile(minIossProperties.getBucket(), path);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
</if>
|
</if>
|
||||||
exists
|
exists
|
||||||
(select 1 from wl_record_test_data wd where wd.test_item_id = #{wlRecordPageParam.id} and wd.data_id = a.id)
|
(select 1 from wl_record_test_data wd where wd.test_item_id = #{wlRecordPageParam.id} and wd.data_id = a.id)
|
||||||
|
order by a.start_time asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getAll" resultType="com.njcn.csdevice.pojo.vo.CsLedgerVO">
|
<select id="getAll" resultType="com.njcn.csdevice.pojo.vo.CsLedgerVO">
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -83,6 +84,16 @@ public class CsEventController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventVO, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventVO, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/getFileZip")
|
||||||
|
@ApiOperation("下载事件原始文件压缩包")
|
||||||
|
@ApiImplicitParam(name = "eventId", value = "暂态事件索引", required = true)
|
||||||
|
public void getFileZip(String eventId, HttpServletResponse response) {
|
||||||
|
String methodDescribe = getMethodDescribe("getFileZip");
|
||||||
|
csEventPOService.getFileZip(eventId,response);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/saveBatchEventList")
|
@PostMapping("/saveBatchEventList")
|
||||||
@ApiOperation("批量新增事件")
|
@ApiOperation("批量新增事件")
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.njcn.csharmonic.pojo.vo.CsEventVO;
|
|||||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||||
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,4 +47,6 @@ public interface CsEventPOService extends IService<CsEventPO>{
|
|||||||
Page<DataGroupEventVO> pageQueryByLineId(CsEventUserQueryPage csEventUserQueryPage);
|
Page<DataGroupEventVO> pageQueryByLineId(CsEventUserQueryPage csEventUserQueryPage);
|
||||||
|
|
||||||
void saveBatchEventList(List<CsEventPO> csEventPOS);
|
void saveBatchEventList(List<CsEventPO> csEventPOS);
|
||||||
|
|
||||||
|
void getFileZip(String eventId,HttpServletResponse response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import cn.hutool.core.date.DatePattern;
|
|||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.core.util.ZipUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
@@ -29,6 +30,7 @@ import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
|
|||||||
import com.njcn.event.file.utils.WaveUtil;
|
import com.njcn.event.file.utils.WaveUtil;
|
||||||
import com.njcn.influx.pojo.dto.EventDataSetDTO;
|
import com.njcn.influx.pojo.dto.EventDataSetDTO;
|
||||||
import com.njcn.influx.service.EvtDataService;
|
import com.njcn.influx.service.EvtDataService;
|
||||||
|
import com.njcn.minioss.config.MinIossProperties;
|
||||||
import com.njcn.oss.constant.GeneralConstant;
|
import com.njcn.oss.constant.GeneralConstant;
|
||||||
import com.njcn.oss.utils.FileStorageUtil;
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
import com.njcn.system.api.EleEvtFeignClient;
|
import com.njcn.system.api.EleEvtFeignClient;
|
||||||
@@ -37,6 +39,7 @@ import com.njcn.system.pojo.po.EleEpdPqd;
|
|||||||
import com.njcn.system.pojo.po.EleEvtParm;
|
import com.njcn.system.pojo.po.EleEvtParm;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -45,7 +48,11 @@ import com.njcn.csharmonic.mapper.CsEventPOMapper;
|
|||||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||||
import com.njcn.csharmonic.service.CsEventPOService;
|
import com.njcn.csharmonic.service.CsEventPOService;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
@@ -82,6 +89,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
|||||||
private final EleEvtFeignClient eleEvtFeignClient;
|
private final EleEvtFeignClient eleEvtFeignClient;
|
||||||
|
|
||||||
private final WavePicComponent wavePicComponent;
|
private final WavePicComponent wavePicComponent;
|
||||||
|
private final MinIossProperties minIossProperties;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) {
|
public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) {
|
||||||
@@ -157,6 +165,47 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
|||||||
this.saveBatch(csEventPOS);
|
this.saveBatch(csEventPOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getFileZip(String eventId, HttpServletResponse response) {
|
||||||
|
CsEventPO eventDetail = this.baseMapper.selectById(eventId);
|
||||||
|
String waveName = eventDetail.getWavePath();
|
||||||
|
if (StrUtil.isBlank(waveName)) {
|
||||||
|
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
String baseName="";
|
||||||
|
try {
|
||||||
|
List<MultipartFile> excelreport = fileStorageUtil.getAllFile(minIossProperties.getBucket(), waveName);
|
||||||
|
//被压缩文件流集合
|
||||||
|
InputStream[] srcFiles = new InputStream[excelreport.size()];
|
||||||
|
//被压缩文件名称
|
||||||
|
String[] srcFileNames = new String[excelreport.size()];
|
||||||
|
for (MultipartFile entity : excelreport) {
|
||||||
|
//以下代码为获取图片inputStream
|
||||||
|
InputStream ins = entity.getInputStream();
|
||||||
|
if (ins == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//塞入流数组中
|
||||||
|
srcFiles[i] = ins;
|
||||||
|
int lastIndex = entity.getOriginalFilename().lastIndexOf('/');
|
||||||
|
String fileName = entity.getOriginalFilename().substring(lastIndex + 1);
|
||||||
|
baseName = FilenameUtils.getBaseName(fileName);
|
||||||
|
srcFileNames[i] = fileName;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(baseName+".zip", "UTF-8"));
|
||||||
|
//多个文件压缩成压缩包返回
|
||||||
|
ZipUtil.zip(response.getOutputStream(), srcFileNames, srcFiles);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return WaveDataDTO
|
* @return WaveDataDTO
|
||||||
|
|||||||
Reference in New Issue
Block a user