Compare commits
3 Commits
1d50981a84
...
da0833a400
| Author | SHA1 | Date | |
|---|---|---|---|
| da0833a400 | |||
| 418fb55bf0 | |||
| 2f80c450c5 |
@ -59,9 +59,15 @@ public class DeviceGeoFenceController extends BaseController {
|
|||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(DeviceGeoFenceBo bo, HttpServletResponse response) {
|
public void export(DeviceGeoFenceBo bo, HttpServletResponse response) {
|
||||||
List<DeviceGeoFenceVo> list = deviceGeoFenceService.queryList(bo);
|
List<DeviceGeoFenceVo> list = deviceGeoFenceService.queryList(bo);
|
||||||
|
// 设置区域类型名称
|
||||||
|
list.forEach(item -> {
|
||||||
|
item.setAreaTypeNameByAreaType();
|
||||||
|
item.setIsActiveNameByIsActive(); // 添加这行来设置激活状态名称
|
||||||
|
});
|
||||||
ExcelUtil.exportExcel(list, "电子围栏", DeviceGeoFenceVo.class, response);
|
ExcelUtil.exportExcel(list, "电子围栏", DeviceGeoFenceVo.class, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取电子围栏详细信息
|
* 获取电子围栏详细信息
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.fuyuanshen.equipment.domain.vo;
|
package com.fuyuanshen.equipment.domain.vo;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import cn.idev.excel.annotation.ExcelProperty;
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
@ -15,7 +16,6 @@ import java.io.Serializable;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 电子围栏视图对象 device_geo_fence
|
* 电子围栏视图对象 device_geo_fence
|
||||||
*
|
*
|
||||||
@ -33,7 +33,7 @@ public class DeviceGeoFenceVo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 围栏唯一标识
|
* 围栏唯一标识
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "围栏唯一标识")
|
// @ExcelProperty(value = "围栏唯一标识")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,22 +42,22 @@ public class DeviceGeoFenceVo implements Serializable {
|
|||||||
@ExcelProperty(value = "围栏名称")
|
@ExcelProperty(value = "围栏名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
|
||||||
* 围栏描述
|
|
||||||
*/
|
|
||||||
@ExcelProperty(value = "围栏描述")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 围栏区域类型, 0 POLYGON, 1 CIRCLE
|
* 围栏区域类型, 0 POLYGON, 1 CIRCLE
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "围栏区域类型, 0 POLYGON, 1 CIRCLE")
|
// @ExcelProperty(value = "围栏区域类型")
|
||||||
private Integer areaType;
|
private Integer areaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 围栏区域类型, 0 POLYGON 多边形, 1 CIRCLE 圆形
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "围栏区域类型")
|
||||||
|
private String areaTypeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 围栏坐标数据
|
* 围栏坐标数据
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "围栏坐标数据")
|
// @ExcelProperty(value = "围栏坐标数据")
|
||||||
private String coordinates;
|
private String coordinates;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,26 +69,78 @@ public class DeviceGeoFenceVo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 是否激活
|
* 是否激活
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "是否激活")
|
// @ExcelProperty(value = "是否激活")
|
||||||
private Long isActive;
|
private Long isActive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 激活状态名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "是否激活")
|
||||||
|
private String isActiveName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 围栏描述
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "围栏描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建人
|
* 创建人
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "创建人")
|
// @ExcelProperty(value = "创建人")
|
||||||
private Long createBy;
|
private Long createBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "创建时间")
|
// @ExcelProperty(value = "创建时间")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "更新时间")
|
// @ExcelProperty(value = "更新时间")
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
public void setAreaTypeNameByAreaType() {
|
||||||
|
if (this.areaType != null) {
|
||||||
|
switch (this.areaType) {
|
||||||
|
case 0:
|
||||||
|
this.areaTypeName = "多边形";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
this.areaTypeName = "圆形";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.areaTypeName = "未知";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.areaTypeName = "未知";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setIsActiveNameByIsActive() {
|
||||||
|
if (this.isActive != null) {
|
||||||
|
switch (this.isActive.intValue()) {
|
||||||
|
case 0:
|
||||||
|
this.isActiveName = "未激活";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
this.isActiveName = "已激活";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.isActiveName = "未知";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.isActiveName = "未知";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import java.net.URL;
|
|||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,30 +75,39 @@ public class DeviceExportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 在DeviceExportService中添加并发控制
|
||||||
|
private static final Semaphore imageLoadSemaphore = new Semaphore(5); // 最多同时加载5张图片
|
||||||
|
|
||||||
private void handleDevicePic(Device device, DeviceExcelExportDTO dto) {
|
private void handleDevicePic(Device device, DeviceExcelExportDTO dto) {
|
||||||
String picUrl = device.getDevicePic();
|
String picUrl = device.getDevicePic();
|
||||||
log.info("处理设备图片,设备ID: {}, 图片URL: {}", device.getId(), picUrl);
|
log.debug("处理设备图片,设备ID: {}, 图片URL: {}", device.getId(), picUrl);
|
||||||
|
|
||||||
if (picUrl != null && !picUrl.trim().isEmpty()) {
|
if (picUrl != null && !picUrl.trim().isEmpty()) {
|
||||||
try {
|
try {
|
||||||
// 自动将HTTP转换为HTTPS以避免重定向问题
|
// 获取加载图片的许可
|
||||||
if (picUrl.startsWith("http://")) {
|
imageLoadSemaphore.acquire();
|
||||||
picUrl = "https://" + picUrl.substring(7);
|
|
||||||
log.info("自动将HTTP转换为HTTPS: {}", picUrl);
|
try {
|
||||||
|
// 自动将HTTP转换为HTTPS以避免重定向问题
|
||||||
|
if (picUrl.startsWith("http://")) {
|
||||||
|
picUrl = "https://" + picUrl.substring(7);
|
||||||
|
log.debug("自动将HTTP转换为HTTPS: {}", picUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尝试创建URL对象(会自动验证格式)
|
||||||
|
URL url = new URL(picUrl);
|
||||||
|
dto.setDevicePic(url);
|
||||||
|
log.debug("成功设置设备图片URL到DTO");
|
||||||
|
} finally {
|
||||||
|
// 释放许可
|
||||||
|
imageLoadSemaphore.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 尝试创建URL对象(会自动验证格式)
|
|
||||||
URL url = new URL(picUrl);
|
|
||||||
|
|
||||||
dto.setDevicePic(url);
|
|
||||||
log.info("成功设置设备图片URL到DTO");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 不是有效URL时设置为null
|
log.warn("设置设备图片失败,设备ID: {}, URL: {}, 错误: {}", device.getId(), picUrl, e.getMessage());
|
||||||
log.info("设置设备图片失败,设备ID: {}, URL: {}, 错误: {}", device.getId(), picUrl, e.getMessage());
|
|
||||||
dto.setDevicePic(null);
|
dto.setDevicePic(null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info("设备没有设置图片,设备ID: {}", device.getId());
|
log.debug("设备没有设置图片,设备ID: {}", device.getId());
|
||||||
dto.setDevicePic(null);
|
dto.setDevicePic(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user