Compare commits

2 Commits

Author SHA1 Message Date
7d256df790 Merge branch 'dyf-device' into prod 2025-12-19 16:22:55 +08:00
c0dfe36b59 cn.idev.excel 2025-12-19 16:21:56 +08:00
6 changed files with 46 additions and 36 deletions

View File

@ -74,6 +74,7 @@ public class ExcelUtil {
return listener.getExcelResult(); return listener.getExcelResult();
} }
/** /**
* 导出excel * 导出excel
* *
@ -92,6 +93,7 @@ public class ExcelUtil {
} }
} }
/** /**
* 导出excel * 导出excel
* *
@ -175,6 +177,7 @@ public class ExcelUtil {
exportExcel(list, sheetName, clazz, false, os, options); exportExcel(list, sheetName, clazz, false, os, options);
} }
/** /**
* 导出excel * 导出excel
* *
@ -187,13 +190,13 @@ public class ExcelUtil {
public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, boolean merge, public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, boolean merge,
OutputStream os, List<DropDownOptions> options) { OutputStream os, List<DropDownOptions> options) {
ExcelWriterSheetBuilder builder = FastExcel.write(os, clazz) ExcelWriterSheetBuilder builder = FastExcel.write(os, clazz)
.autoCloseStream(false) .autoCloseStream(false)
// 自动适配 // 自动适配
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
// 大数值自动转换 防止失真 // 大数值自动转换 防止失真
.registerConverter(new ExcelBigNumberConvert()) .registerConverter(new ExcelBigNumberConvert())
.registerWriteHandler(new DataWriteHandler(clazz)) .registerWriteHandler(new DataWriteHandler(clazz))
.sheet(sheetName); .sheet(sheetName);
if (merge) { if (merge) {
// 合并处理器 // 合并处理器
builder.registerWriteHandler(new CellMergeStrategy(list, true)); builder.registerWriteHandler(new CellMergeStrategy(list, true));
@ -203,6 +206,7 @@ public class ExcelUtil {
builder.doWrite(list); builder.doWrite(list);
} }
/** /**
* 单表多数据模板导出 模板格式为 {.属性} * 单表多数据模板导出 模板格式为 {.属性}
* *
@ -238,12 +242,12 @@ public class ExcelUtil {
public static <T> void exportTemplate(List<T> data, String templatePath, OutputStream os) { public static <T> void exportTemplate(List<T> data, String templatePath, OutputStream os) {
ClassPathResource templateResource = new ClassPathResource(templatePath); ClassPathResource templateResource = new ClassPathResource(templatePath);
ExcelWriter excelWriter = FastExcel.write(os) ExcelWriter excelWriter = FastExcel.write(os)
.withTemplate(templateResource.getStream()) .withTemplate(templateResource.getStream())
.autoCloseStream(false) .autoCloseStream(false)
// 大数值自动转换 防止失真 // 大数值自动转换 防止失真
.registerConverter(new ExcelBigNumberConvert()) .registerConverter(new ExcelBigNumberConvert())
.registerWriteHandler(new DataWriteHandler(data.get(0).getClass())) .registerWriteHandler(new DataWriteHandler(data.get(0).getClass()))
.build(); .build();
WriteSheet writeSheet = FastExcel.writerSheet().build(); WriteSheet writeSheet = FastExcel.writerSheet().build();
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
// 单表多数据导出 模板格式为 {.属性} // 单表多数据导出 模板格式为 {.属性}
@ -311,11 +315,11 @@ public class ExcelUtil {
public static void exportTemplateMultiList(Map<String, Object> data, String templatePath, OutputStream os) { public static void exportTemplateMultiList(Map<String, Object> data, String templatePath, OutputStream os) {
ClassPathResource templateResource = new ClassPathResource(templatePath); ClassPathResource templateResource = new ClassPathResource(templatePath);
ExcelWriter excelWriter = FastExcel.write(os) ExcelWriter excelWriter = FastExcel.write(os)
.withTemplate(templateResource.getStream()) .withTemplate(templateResource.getStream())
.autoCloseStream(false) .autoCloseStream(false)
// 大数值自动转换 防止失真 // 大数值自动转换 防止失真
.registerConverter(new ExcelBigNumberConvert()) .registerConverter(new ExcelBigNumberConvert())
.build(); .build();
WriteSheet writeSheet = FastExcel.writerSheet().build(); WriteSheet writeSheet = FastExcel.writerSheet().build();
for (Map.Entry<String, Object> map : data.entrySet()) { for (Map.Entry<String, Object> map : data.entrySet()) {
// 设置列表后续还有数据 // 设置列表后续还有数据
@ -342,11 +346,11 @@ public class ExcelUtil {
public static void exportTemplateMultiSheet(List<Map<String, Object>> data, String templatePath, OutputStream os) { public static void exportTemplateMultiSheet(List<Map<String, Object>> data, String templatePath, OutputStream os) {
ClassPathResource templateResource = new ClassPathResource(templatePath); ClassPathResource templateResource = new ClassPathResource(templatePath);
ExcelWriter excelWriter = FastExcel.write(os) ExcelWriter excelWriter = FastExcel.write(os)
.withTemplate(templateResource.getStream()) .withTemplate(templateResource.getStream())
.autoCloseStream(false) .autoCloseStream(false)
// 大数值自动转换 防止失真 // 大数值自动转换 防止失真
.registerConverter(new ExcelBigNumberConvert()) .registerConverter(new ExcelBigNumberConvert())
.build(); .build();
for (int i = 0; i < data.size(); i++) { for (int i = 0; i < data.size(); i++) {
WriteSheet writeSheet = FastExcel.writerSheet(i).build(); WriteSheet writeSheet = FastExcel.writerSheet(i).build();
for (Map.Entry<String, Object> map : data.get(i).entrySet()) { for (Map.Entry<String, Object> map : data.get(i).entrySet()) {

View File

@ -41,6 +41,7 @@ public class DeviceRepairRecordsController extends BaseController {
private final IDeviceRepairRecordsService deviceRepairRecordsService; private final IDeviceRepairRecordsService deviceRepairRecordsService;
/** /**
* 查询设备维修记录列表 * 查询设备维修记录列表
*/ */
@ -52,6 +53,7 @@ public class DeviceRepairRecordsController extends BaseController {
return deviceRepairRecordsService.queryPageList(criteria, page); return deviceRepairRecordsService.queryPageList(criteria, page);
} }
/** /**
* 导出设备维修记录列表 * 导出设备维修记录列表
*/ */
@ -63,6 +65,7 @@ public class DeviceRepairRecordsController extends BaseController {
ExcelUtil.exportExcel(list, "设备维修记录", DeviceRepairRecordsVo.class, response); ExcelUtil.exportExcel(list, "设备维修记录", DeviceRepairRecordsVo.class, response);
} }
/** /**
* 获取设备维修记录详细信息 * 获取设备维修记录详细信息
* *
@ -75,6 +78,7 @@ public class DeviceRepairRecordsController extends BaseController {
return R.ok(deviceRepairRecordsService.queryById(recordId)); return R.ok(deviceRepairRecordsService.queryById(recordId));
} }
/** /**
* 新增设备维修记录 * 新增设备维修记录
*/ */
@ -86,6 +90,7 @@ public class DeviceRepairRecordsController extends BaseController {
return toAjax(deviceRepairRecordsService.insertByBo(bo)); return toAjax(deviceRepairRecordsService.insertByBo(bo));
} }
/** /**
* 修改设备维修记录 * 修改设备维修记录
*/ */
@ -109,4 +114,5 @@ public class DeviceRepairRecordsController extends BaseController {
@PathVariable Long[] recordIds) { @PathVariable Long[] recordIds) {
return toAjax(deviceRepairRecordsService.deleteWithValidByIds(List.of(recordIds), true)); return toAjax(deviceRepairRecordsService.deleteWithValidByIds(List.of(recordIds), true));
} }
} }

View File

@ -108,7 +108,7 @@ public class DeviceFenceAccessRecordVo implements Serializable {
/** /**
* 记录创建时间 * 记录创建时间
*/ */
@ExcelProperty(value = "记录创建时间") // @ExcelProperty(value = "记录创建时间")
private Date createTime; private Date createTime;
} }

View File

@ -1,15 +1,11 @@
package com.fuyuanshen.equipment.domain.vo; package com.fuyuanshen.equipment.domain.vo;
import java.util.Date; import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth; import cn.idev.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fuyuanshen.common.tenant.core.TenantEntity; import com.fuyuanshen.common.tenant.core.TenantEntity;
import com.fuyuanshen.equipment.domain.DeviceRepairRecords; import com.fuyuanshen.equipment.domain.DeviceRepairRecords;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data; import lombok.Data;
@ -56,8 +52,8 @@ public class DeviceRepairRecordsVo extends TenantEntity implements Serializable
*/ */
@ExcelProperty(value = "维修时间") @ExcelProperty(value = "维修时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ColumnWidth(20) @ColumnWidth(value = 20)
private String repairTime; private Date repairTime;
/** /**
* 损坏部位 * 损坏部位

View File

@ -32,8 +32,8 @@ public interface IDeviceRepairRecordsService extends IService<DeviceRepairRecord
/** /**
* 分页查询设备维修记录列表 * 分页查询设备维修记录列表
* *
* @param bo 查询条件 * @param criteria 查询条件
* @param pageQuery 分页参数 * @param page 分页参数
* @return 设备维修记录分页列表 * @return 设备维修记录分页列表
*/ */
TableDataInfo<DeviceRepairRecordsVo> queryPageList(DeviceRepairRecordsQueryCriteria criteria, Page<DeviceRepairRecords> page); TableDataInfo<DeviceRepairRecordsVo> queryPageList(DeviceRepairRecordsQueryCriteria criteria, Page<DeviceRepairRecords> page);
@ -41,7 +41,7 @@ public interface IDeviceRepairRecordsService extends IService<DeviceRepairRecord
/** /**
* 查询符合条件的设备维修记录列表 * 查询符合条件的设备维修记录列表
* *
* @param bo 查询条件 * @param criteria 查询条件
* @return 设备维修记录列表 * @return 设备维修记录列表
*/ */
List<DeviceRepairRecordsVo> queryList(DeviceRepairRecordsQueryCriteria criteria); List<DeviceRepairRecordsVo> queryList(DeviceRepairRecordsQueryCriteria criteria);
@ -70,4 +70,5 @@ public interface IDeviceRepairRecordsService extends IService<DeviceRepairRecord
* @return 是否删除成功 * @return 是否删除成功
*/ */
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
} }

View File

@ -52,6 +52,7 @@ public class DeviceRepairRecordsServiceImpl extends ServiceImpl<DeviceRepairReco
private final ISysOssService ossService; private final ISysOssService ossService;
private final FileHashUtil fileHashUtil; private final FileHashUtil fileHashUtil;
/** /**
* 查询设备维修记录 * 查询设备维修记录
* *
@ -76,6 +77,7 @@ public class DeviceRepairRecordsServiceImpl extends ServiceImpl<DeviceRepairReco
return vo; return vo;
} }
/** /**
* 分页查询设备维修记录列表 * 分页查询设备维修记录列表
* *
@ -98,6 +100,7 @@ public class DeviceRepairRecordsServiceImpl extends ServiceImpl<DeviceRepairReco
return new TableDataInfo<DeviceRepairRecordsVo>(deviceRepairRecordsIPage.getRecords(), deviceRepairRecordsIPage.getTotal()); return new TableDataInfo<DeviceRepairRecordsVo>(deviceRepairRecordsIPage.getRecords(), deviceRepairRecordsIPage.getTotal());
} }
/** /**
* 查询符合条件的设备维修记录列表 * 查询符合条件的设备维修记录列表
* *