Commit e610b5b0 by xmh

<feat>修正pom文件,导出超链接测试

1 parent 86f9720e
...@@ -71,6 +71,9 @@ ...@@ -71,6 +71,9 @@
<include>**/*.xml</include> <include>**/*.xml</include>
</includes> </includes>
</resource> </resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources> </resources>
</build> </build>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -64,8 +64,10 @@ ...@@ -64,8 +64,10 @@
<include>**/*.xml</include> <include>**/*.xml</include>
</includes> </includes>
</resource> </resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources> </resources>
</build> </build>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -55,6 +55,9 @@ ...@@ -55,6 +55,9 @@
<include>**/*.xml</include> <include>**/*.xml</include>
</includes> </includes>
</resource> </resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources> </resources>
</build> </build>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -65,6 +65,9 @@ ...@@ -65,6 +65,9 @@
<include>**/*.xml</include> <include>**/*.xml</include>
</includes> </includes>
</resource> </resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources> </resources>
</build> </build>
</project> </project>
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.query.model.export; package com.viontech.fanxing.query.model.export;
import cn.hutool.poi.excel.cell.FormulaCellValue;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -13,7 +14,7 @@ import lombok.Setter; ...@@ -13,7 +14,7 @@ import lombok.Setter;
@Getter @Getter
@Setter @Setter
public class ExportBaseModel { public class ExportBaseModel {
private String picName; private FormulaCellValue picName;
private String videoName; private FormulaCellValue videoName;
private String eventTime; private String eventTime;
} }
...@@ -3,6 +3,8 @@ package com.viontech.fanxing.query.runner; ...@@ -3,6 +3,8 @@ package com.viontech.fanxing.query.runner;
import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter; import cn.hutool.poi.excel.ExcelWriter;
import cn.hutool.poi.excel.StyleSet; import cn.hutool.poi.excel.StyleSet;
import cn.hutool.poi.excel.cell.CellSetter;
import cn.hutool.poi.excel.cell.FormulaCellValue;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -223,7 +225,7 @@ public class ExportDataJob { ...@@ -223,7 +225,7 @@ public class ExportDataJob {
// 写入图片文件 // 写入图片文件
if (withPic && StringUtils.isNotEmpty(vo.getPics())) { if (withPic && StringUtils.isNotEmpty(vo.getPics())) {
File file = new File(vo.getPics()); File file = new File(vo.getPics());
o.setPicName(file.getName()); o.setPicName(new FormulaCellValue(getHyperLink(file.getName())));
if (file.exists()) { if (file.exists()) {
try { try {
byte[] bytes = FileUtils.readFileToByteArray(file); byte[] bytes = FileUtils.readFileToByteArray(file);
...@@ -238,7 +240,7 @@ public class ExportDataJob { ...@@ -238,7 +240,7 @@ public class ExportDataJob {
// 写入视频文件 // 写入视频文件
if (withVideo && StringUtils.isNotEmpty(vo.getVideoName())) { if (withVideo && StringUtils.isNotEmpty(vo.getVideoName())) {
File file = new File(vo.getVideoName()); File file = new File(vo.getVideoName());
o.setVideoName(file.getName()); o.setVideoName(new FormulaCellValue(getHyperLink(file.getName())));
if (file.exists()) { if (file.exists()) {
try { try {
byte[] bytes = FileUtils.readFileToByteArray(file); byte[] bytes = FileUtils.readFileToByteArray(file);
...@@ -305,7 +307,7 @@ public class ExportDataJob { ...@@ -305,7 +307,7 @@ public class ExportDataJob {
byte[] bytes = FileUtils.readFileToByteArray(file); byte[] bytes = FileUtils.readFileToByteArray(file);
zipO.putNextEntry(new ZipEntry(file.getName())); zipO.putNextEntry(new ZipEntry(file.getName()));
zipO.write(bytes); zipO.write(bytes);
o.setPicName(file.getName()); o.setPicName(new FormulaCellValue(getHyperLink(file.getName())));
} catch (Exception e) { } catch (Exception e) {
log.error("", e); log.error("", e);
} }
...@@ -319,7 +321,7 @@ public class ExportDataJob { ...@@ -319,7 +321,7 @@ public class ExportDataJob {
byte[] bytes = FileUtils.readFileToByteArray(file); byte[] bytes = FileUtils.readFileToByteArray(file);
zipO.putNextEntry(new ZipEntry(file.getName())); zipO.putNextEntry(new ZipEntry(file.getName()));
zipO.write(bytes); zipO.write(bytes);
o.setVideoName(file.getName()); o.setVideoName(new FormulaCellValue(getHyperLink(file.getName())));
} catch (Exception e) { } catch (Exception e) {
log.error("", e); log.error("", e);
} }
...@@ -474,4 +476,8 @@ public class ExportDataJob { ...@@ -474,4 +476,8 @@ public class ExportDataJob {
return writer; return writer;
} }
private String getHyperLink(String str) {
return "HYPERLINK(" + "\"" + str + "\"," + "\"" + str + "\")";
}
} }
package com.viontech.fanxing.query; package com.viontech.fanxing.query;
import cn.hutool.poi.excel.cell.FormulaCellValue;
import com.viontech.fanxing.commons.model.DictCode; import com.viontech.fanxing.commons.model.DictCode;
import com.viontech.fanxing.commons.model.Traffic; import com.viontech.fanxing.commons.model.Traffic;
import com.viontech.fanxing.commons.vo.TrafficVo; import com.viontech.fanxing.commons.vo.TrafficVo;
...@@ -46,7 +47,7 @@ public class MainTest { ...@@ -46,7 +47,7 @@ public class MainTest {
ETrafficModel e = new ETrafficModel(); ETrafficModel e = new ETrafficModel();
Date eventTime = trafficVo.getEventTime(); Date eventTime = trafficVo.getEventTime();
e.setEventTime(DateUtil.format(DateUtil.FORMAT_FULL, eventTime)); e.setEventTime(DateUtil.format(DateUtil.FORMAT_FULL, eventTime));
e.setPicName(UUID.randomUUID() + ".pic"); e.setPicName(new FormulaCellValue("HYPERLINK(\"https://www.baidu.com/\",\"下载\")"));
e.setLocation(trafficVo.getLocationName()); e.setLocation(trafficVo.getLocationName());
e.setPlateNumber(trafficVo.getPlateNumber()); e.setPlateNumber(trafficVo.getPlateNumber());
Map<String, DictCode> vehicleTypeDict = opsClientService.vehicleTypeDict(); Map<String, DictCode> vehicleTypeDict = opsClientService.vehicleTypeDict();
......
...@@ -61,6 +61,9 @@ ...@@ -61,6 +61,9 @@
<include>**/*.xml</include> <include>**/*.xml</include>
</includes> </includes>
</resource> </resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources> </resources>
</build> </build>
</project> </project>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!