13 files modified
9 files added
| | |
| | | @ApiModelProperty(value = "下载类型,sjzx:数据中心,aisb:ai识别,htsjzx:后台数据中心") |
| | | String type; |
| | | |
| | | @ApiModelProperty(value = "任务id集合") |
| | | List<String> wayLineJobIds; |
| | | |
| | | // 开始时间 |
| | | @ApiModelProperty(value = "开始时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | |
| | | |
| | | @ApiModelProperty(value = "区域编码") |
| | | String areaCode; |
| | | // dockSn |
| | | @ApiModelProperty(value = "设备sn") |
| | | String dockSn; |
| | | // 任务名称 |
| | | @ApiModelProperty(value = "任务名称") |
| | | private String jobName; |
| | | // 文件名称 |
| | | @ApiModelProperty(value = "文件名称") |
| | | private String fileName; |
| | | // 文件类型 |
| | | @ApiModelProperty(value = "文件类型 visable:可见光,ir:红外 ") |
| | | private String fileType; |
| | | // 文件格式 成果类型:0图片,1=视频,2=ai,3=三维,4=正射,5=全景, 6=图片压缩小(后缀small),7=图片压缩中(后缀show),8视频一帧图,9视频压缩,10ai压缩小,11ai压缩中,12水印 |
| | | @ApiModelProperty(value = "文件格式 0图片,1=视频 ,2=ai,4=正射,5=全景") |
| | | private String resultType; |
| | | |
| | | @ApiModelProperty(value = "下载结构带不带任务文件夹") |
| | | private boolean withFolder = false; |
| | | |
| | | @ApiModelProperty(value = "照片结果类型") |
| | | private List<Integer> resultTypes; |
| | | |
| | | } |
| | |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "机构编码") |
| | | private String deptCode; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | |
| | | */ |
| | | @ApiModelProperty(value = "飞手姓名") |
| | | private String flyerName; |
| | | |
| | | @ApiModelProperty(value = "飞手Id(星图)") |
| | | private String flyerId; |
| | | /** |
| | | * 飞手电话(唯一) |
| | | */ |
| | | @ApiModelProperty(value = "飞手电话(唯一)") |
| | | private String flyerPhone; |
| | | |
| | | @ApiModelProperty(value = "区域cod :1200,1201,120105") |
| | | private String regionCode; |
| | | /** |
| | | * 飞行时长(小时) |
| | | */ |
| | |
| | | <select id="selectGdFlyerPage" resultMap="gdFlyerVOResultMap"> |
| | | select * from ja_gd_flyer |
| | | <where> |
| | | is_deleted = 0 |
| | | <if test="param2.flyerName != null and param2.flyerName != ''"> |
| | | and flyer_name like concat('%',#{param2.flyerName},'%') |
| | | </if> |
| | |
| | | @ApiModelProperty("主键id") |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "飞手Id(星图)") |
| | | private String flyerId; |
| | | |
| | | /** |
| | | * 飞手姓名 |
| | | */ |
| | |
| | | */ |
| | | @ApiModelProperty(value = "飞手电话(唯一)") |
| | | private String flyerPhone; |
| | | |
| | | @ApiModelProperty(value = "区域cod :1200,1201,120105") |
| | | private String regionCode; |
| | | /** |
| | | * 飞行时长(小时) |
| | | */ |
| | |
| | | @ApiModelProperty("主键id") |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "飞手Id(星图)") |
| | | private String flyerId; |
| | | /** |
| | | * 飞手姓名 |
| | | */ |
| | |
| | | |
| | | |
| | | <select id="selectGdDataObjectionPage" resultMap="gdDataObjectionResultMap"> |
| | | select do.*, GROUP_CONCAT(da.attach_name SEPARATOR ',') as attach_names |
| | | from ja_gd_data_objection do |
| | | left join ja_gd_data_objection_attachment da on do.id = da.objection_id |
| | | select |
| | | do.*, |
| | | GROUP_CONCAT(da.attach_name SEPARATOR ',') as attach_names, |
| | | bd.dept_name as create_dept_name |
| | | from |
| | | ja_gd_data_objection do |
| | | left join |
| | | ja_gd_data_objection_attachment da |
| | | on do.id = da.objection_id |
| | | left join blade_dept bd on bd.id = do.create_dept |
| | | <where> |
| | | do.is_deleted = 0 |
| | | <if test="param2.title != null and param2.title != ''"> |
| | | and do.title like concat('%',#{param2.title},'%') |
| | | </if> |
| | |
| | | */ |
| | | @ApiModelProperty(value = "创建部门") |
| | | private Long createDept; |
| | | |
| | | /** |
| | | * 创建部门 |
| | | */ |
| | | @ApiModelProperty(value = "创建部门") |
| | | private String createDeptName; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | |
| | | @ApiModelProperty(value = "执行时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date executeTime; |
| | | |
| | | @ApiModelProperty(value = "巡查任务航线ID") |
| | | private String airlineId; |
| | | /** |
| | | * 巡查任务航线URL |
| | | */ |
| | |
| | | */ |
| | | @ApiModelProperty(value = "执行时间") |
| | | private Date executeTime; |
| | | |
| | | @ApiModelProperty(value = "巡查任务航线ID") |
| | | private String airlineId; |
| | | |
| | | /** |
| | | * 巡查任务航线URL |
| | | */ |
| | |
| | | import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
| | | import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
| | | import lombok.Data; |
| | | import org.sxkj.system.util.excel.ExcelDictConverter; |
| | | import org.sxkj.system.util.excel.ExcelDictItem; |
| | | import org.sxkj.system.util.excel.ExcelDictItemLabel; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | |
| | | @ExcelProperty("机构描述") |
| | | @ColumnWidth(20) |
| | | private String deptDesc; |
| | | private String remark; |
| | | |
| | | @ExcelProperty("机构状态") |
| | | @ColumnWidth(20) |
| | | private String deptStatus; |
| | | @ExcelProperty(value = "机构状态", converter = ExcelDictConverter.class) |
| | | @ExcelDictItemLabel(type = "institutionStatus") |
| | | @ExcelDictItem(type = "institutionStatus") |
| | | private String status; |
| | | } |
| | |
| | | import com.alibaba.excel.annotation.write.style.ColumnWidth; |
| | | import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
| | | import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.sxkj.system.util.excel.ExcelDictConverter; |
| | | import org.sxkj.system.util.excel.ExcelDictItem; |
| | | import org.sxkj.system.util.excel.ExcelDictItemLabel; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | public class RegionExcel implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("区划编号") |
| | | private String code; |
| | | |
| | | @ExcelProperty("父区划编号") |
| | | private String parentCode; |
| | | |
| | | @ExcelProperty("祖区划编号") |
| | | private String ancestors; |
| | | |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("区划名称") |
| | | private String name; |
| | | |
| | | @ExcelProperty("省级区划编号") |
| | | private String provinceCode; |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("上级区划名称") |
| | | private String parentName; |
| | | |
| | | @ExcelProperty("省级名称") |
| | | private String provinceName; |
| | | |
| | | @ExcelProperty("市级区划编号") |
| | | private String cityCode; |
| | | |
| | | @ExcelProperty("市级名称") |
| | | private String cityName; |
| | | |
| | | @ExcelProperty("区级区划编号") |
| | | private String districtCode; |
| | | |
| | | @ExcelProperty("区级名称") |
| | | private String districtName; |
| | | |
| | | @ExcelProperty("镇级区划编号") |
| | | private String townCode; |
| | | |
| | | @ExcelProperty("镇级名称") |
| | | private String townName; |
| | | |
| | | @ExcelProperty("村级区划编号") |
| | | private String villageCode; |
| | | |
| | | @ExcelProperty("村级名称") |
| | | private String villageName; |
| | | |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("层级") |
| | | private Integer regionLevel; |
| | | |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("排序") |
| | | private Integer sort; |
| | | |
| | | @ExcelProperty("备注") |
| | | private String remark; |
| | | @ColumnWidth(20) |
| | | @ExcelProperty(value = "机构状态", converter = ExcelDictConverter.class) |
| | | @ExcelDictItemLabel(type = "institutionStatus") |
| | | @ExcelDictItem(type = "institutionStatus") |
| | | private String status; |
| | | |
| | | } |
| | |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "机构编码") |
| | | private String deptCode; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | |
| | | @ApiModelProperty(value = "组织id") |
| | | private Integer bingId; |
| | | |
| | | /** |
| | | * 是否已删除 |
| New file |
| | |
| | | package org.sxkj.system.util.excel; |
| | | |
| | | import com.alibaba.excel.write.style.row.AbstractRowHeightStyleStrategy; |
| | | import org.apache.poi.ss.usermodel.Cell; |
| | | import org.apache.poi.ss.usermodel.Row; |
| | | |
| | | import java.util.Iterator; |
| | | |
| | | /** |
| | | * 自适应行高 |
| | | * @author zhongrj |
| | | * @since 2021-10-29 |
| | | */ |
| | | public class CustomCellWriteHeightConfig extends AbstractRowHeightStyleStrategy { |
| | | /** |
| | | * 默认高度 |
| | | */ |
| | | private static final Integer DEFAULT_HEIGHT = 300; |
| | | |
| | | @Override |
| | | protected void setHeadColumnHeight(Row row, int relativeRowIndex) { |
| | | } |
| | | |
| | | @Override |
| | | protected void setContentColumnHeight(Row row, int relativeRowIndex) { |
| | | Iterator<Cell> cellIterator = row.cellIterator(); |
| | | if (!cellIterator.hasNext()) { |
| | | return; |
| | | } |
| | | |
| | | // 默认为 1行高度 |
| | | Integer maxHeight = 1; |
| | | while (cellIterator.hasNext()) { |
| | | Cell cell = cellIterator.next(); |
| | | switch (cell.getCellType()) { |
| | | case STRING: |
| | | if (cell.getStringCellValue().indexOf("\n") != -1) { |
| | | int length = cell.getStringCellValue().split("\n").length; |
| | | maxHeight = Math.max(maxHeight, length); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | row.setHeight((short) (maxHeight * DEFAULT_HEIGHT)); |
| | | } |
| | | } |
| New file |
| | |
| | | package org.sxkj.system.util.excel; |
| | | |
| | | import com.alibaba.excel.enums.CellDataTypeEnum; |
| | | import com.alibaba.excel.metadata.Head; |
| | | import com.alibaba.excel.metadata.data.CellData; |
| | | import com.alibaba.excel.metadata.data.WriteCellData; |
| | | import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
| | | import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy; |
| | | import org.apache.poi.ss.usermodel.Cell; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 自适应行款 |
| | | * @author zhongrj |
| | | * @since 2021-10-29 |
| | | */ |
| | | public class CustomCellWriteWeightConfig extends AbstractColumnWidthStyleStrategy { |
| | | private Map<Integer, Map<Integer, Integer>> CACHE = new HashMap<>(); |
| | | |
| | | @Override |
| | | protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { |
| | | // 在3.0版本中,列宽设置逻辑已改变,使用此方法进行设置 |
| | | Sheet sheet = writeSheetHolder.getSheet(); |
| | | Integer columnWidth = CACHE.get(writeSheetHolder.getSheetNo()) != null ? |
| | | CACHE.get(writeSheetHolder.getSheetNo()).get(cell.getColumnIndex()) : null; |
| | | if (columnWidth != null) { |
| | | sheet.setColumnWidth(cell.getColumnIndex(), columnWidth * 256); |
| | | } |
| | | |
| | | super.setColumnWidth(writeSheetHolder, cellDataList, cell, head, relativeRowIndex, isHead); |
| | | } |
| | | |
| | | /** |
| | | * 计算长度 |
| | | * @param cellDataList |
| | | * @param cell |
| | | * @param isHead |
| | | * @return |
| | | */ |
| | | private Integer dataLength(List<CellData> cellDataList, Cell cell, Boolean isHead) { |
| | | if (isHead) { |
| | | return cell.getStringCellValue().getBytes().length; |
| | | } else { |
| | | CellData cellData = cellDataList.get(0); |
| | | CellDataTypeEnum type = cellData.getType(); |
| | | if (type == null) { |
| | | return -1; |
| | | } else { |
| | | switch (type) { |
| | | case STRING: |
| | | // 换行符(数据需要提前解析好) |
| | | int index = cellData.getStringValue().indexOf("\n"); |
| | | return index != -1 ? |
| | | cellData.getStringValue().substring(0, index).getBytes().length + 1 : cellData.getStringValue().getBytes().length + 1; |
| | | case BOOLEAN: |
| | | return cellData.getBooleanValue().toString().getBytes().length; |
| | | case NUMBER: |
| | | return cellData.getNumberValue().toString().getBytes().length; |
| | | default: |
| | | return -1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | package org.sxkj.system.util.excel; |
| | | |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.alibaba.excel.enums.CellDataTypeEnum; |
| | | import com.alibaba.excel.metadata.GlobalConfiguration; |
| | | import com.alibaba.excel.metadata.data.ReadCellData; |
| | | import com.alibaba.excel.metadata.data.WriteCellData; |
| | | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| | | import com.github.xiaoymin.knife4j.core.util.StrUtil; |
| | | import org.springframework.stereotype.Component; |
| | | import org.sxkj.system.cache.DictBizCache; |
| | | import org.sxkj.system.entity.DictBiz; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典映射 |
| | | * |
| | | * @author zhongrj |
| | | * @date 2023-11-17 |
| | | */ |
| | | @Component |
| | | public class ExcelDictConverter implements Converter<String> { |
| | | |
| | | @Override |
| | | public Class supportJavaTypeKey() { |
| | | return Integer.class; |
| | | } |
| | | |
| | | @Override |
| | | public CellDataTypeEnum supportExcelTypeKey() { |
| | | return CellDataTypeEnum.STRING; |
| | | } |
| | | |
| | | /** |
| | | * 导入excel 解析到java 对象 |
| | | * @param cellData |
| | | * @param contentProperty |
| | | * @param globalConfiguration |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
| | | // 获取字典类型 |
| | | Field field = contentProperty.getField(); |
| | | ExcelDictItemLabel excel = field.getAnnotation(ExcelDictItemLabel.class); |
| | | String dictType = excel.type(); |
| | | // 为空返回 |
| | | String dictLabel = cellData.getStringValue(); |
| | | if (StrUtil.isBlank(dictLabel)) { |
| | | return dictLabel; |
| | | } |
| | | // 查询字典 |
| | | List<DictBiz> list = DictBizCache.getList(dictType); |
| | | //解析返回 |
| | | String key = ""; |
| | | for (DictBiz dictBiz : list) { |
| | | if (dictBiz.getDictValue().equals(dictLabel)){ |
| | | key = dictBiz.getDictKey(); |
| | | break; |
| | | } |
| | | } |
| | | // 返回key |
| | | return key; |
| | | } |
| | | |
| | | /** |
| | | * java 导出到 excel |
| | | * |
| | | * @param dictValue |
| | | * @param excelContentProperty |
| | | * @param globalConfiguration |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public WriteCellData<?> convertToExcelData(String dictValue, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
| | | // 获取字典类型 |
| | | Field field = excelContentProperty.getField(); |
| | | ExcelDictItem excel = field.getAnnotation(ExcelDictItem.class); |
| | | String dictType = excel.type(); |
| | | List<DictBiz> list = DictBizCache.getList(dictType); |
| | | String value = ""; |
| | | //解析返回 |
| | | for (DictBiz dictBiz : list) { |
| | | if (dictBiz.getDictKey().equals(dictValue)){ |
| | | value = dictBiz.getDictValue(); |
| | | break; |
| | | } |
| | | } |
| | | return new WriteCellData<>(value); |
| | | } |
| | | } |
| New file |
| | |
| | | package org.sxkj.system.util.excel; |
| | | |
| | | import com.fasterxml.jackson.annotation.JacksonAnnotationsInside; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * excel导出字典转换注解 |
| | | * <p> |
| | | * 将excel导出的字典code自动转换为字典label |
| | | */ |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Target(ElementType.FIELD) |
| | | @JacksonAnnotationsInside |
| | | public @interface ExcelDictItem { |
| | | |
| | | /** |
| | | * 字典type |
| | | */ |
| | | String type(); |
| | | |
| | | } |
| New file |
| | |
| | | package org.sxkj.system.util.excel; |
| | | |
| | | import com.fasterxml.jackson.annotation.JacksonAnnotationsInside; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * excel导入字典转换注解 |
| | | * <p> |
| | | * 将excel导入的字典label自动转换为字典code |
| | | */ |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Target(ElementType.FIELD) |
| | | @JacksonAnnotationsInside |
| | | public @interface ExcelDictItemLabel { |
| | | |
| | | /** |
| | | * 字典type |
| | | */ |
| | | String type(); |
| | | |
| | | } |
| New file |
| | |
| | | package org.sxkj.system.util.excel; |
| | | |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.alibaba.excel.converters.WriteConverterContext; |
| | | import com.alibaba.excel.enums.CellDataTypeEnum; |
| | | import com.alibaba.excel.metadata.GlobalConfiguration; |
| | | import com.alibaba.excel.metadata.data.ReadCellData; |
| | | import com.alibaba.excel.metadata.data.WriteCellData; |
| | | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | |
| | | /** |
| | | * LocalDateTime转换器 |
| | | * |
| | | * @author |
| | | * @since 2026-01-08 |
| | | */ |
| | | public class LocalDateTimeConverter implements Converter<LocalDateTime> { |
| | | |
| | | private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | @Override |
| | | public Class<LocalDateTime> supportJavaTypeKey() { |
| | | return LocalDateTime.class; |
| | | } |
| | | |
| | | @Override |
| | | public CellDataTypeEnum supportExcelTypeKey() { |
| | | return CellDataTypeEnum.STRING; |
| | | } |
| | | |
| | | @Override |
| | | public LocalDateTime convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
| | | if (cellData == null || cellData.getStringValue() == null || cellData.getStringValue().trim().isEmpty()) { |
| | | return null; |
| | | } |
| | | try { |
| | | return LocalDateTime.parse(cellData.getStringValue(), TIME_FORMATTER); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public WriteCellData<?> convertToExcelData(WriteConverterContext<LocalDateTime> context) throws Exception { |
| | | if (context.getValue() == null) { |
| | | return new WriteCellData<>(""); |
| | | } |
| | | return new WriteCellData<>(context.getValue().format(TIME_FORMATTER)); |
| | | } |
| | | } |
| New file |
| | |
| | | package org.sxkj.system.util.excel; |
| | | |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.alibaba.excel.converters.WriteConverterContext; |
| | | import com.alibaba.excel.enums.CellDataTypeEnum; |
| | | import com.alibaba.excel.metadata.GlobalConfiguration; |
| | | import com.alibaba.excel.metadata.data.ReadCellData; |
| | | import com.alibaba.excel.metadata.data.WriteCellData; |
| | | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| | | |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | |
| | | /** |
| | | * LocalTime转换器 |
| | | * |
| | | * @author |
| | | * @since 2026-01-09 |
| | | */ |
| | | public class LocalTimeConverter implements Converter<LocalTime> { |
| | | |
| | | private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss"); |
| | | |
| | | @Override |
| | | public Class<LocalTime> supportJavaTypeKey() { |
| | | return LocalTime.class; |
| | | } |
| | | |
| | | @Override |
| | | public CellDataTypeEnum supportExcelTypeKey() { |
| | | return CellDataTypeEnum.STRING; |
| | | } |
| | | |
| | | @Override |
| | | public LocalTime convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
| | | if (cellData == null || cellData.getStringValue() == null || cellData.getStringValue().trim().isEmpty()) { |
| | | return null; |
| | | } |
| | | try { |
| | | return LocalTime.parse(cellData.getStringValue(), TIME_FORMATTER); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public WriteCellData<?> convertToExcelData(WriteConverterContext<LocalTime> context) throws Exception { |
| | | if (context.getValue() == null) { |
| | | return new WriteCellData<>(""); |
| | | } |
| | | return new WriteCellData<>(context.getValue().format(TIME_FORMATTER)); |
| | | } |
| | | } |
| New file |
| | |
| | | package org.sxkj.system.util.excel; |
| | | |
| | | import com.alibaba.excel.write.handler.SheetWriteHandler; |
| | | import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
| | | import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.ss.util.CellRangeAddress; |
| | | |
| | | public class MySheetWriteHandler implements SheetWriteHandler { |
| | | @Override |
| | | public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { |
| | | Workbook workbook = writeWorkbookHolder.getWorkbook(); |
| | | Sheet sheet = workbook.getSheetAt(0); |
| | | Row row1 = sheet.createRow(0); |
| | | row1.setHeight((short) 500); |
| | | Cell cell = row1.createCell(0); |
| | | //设置单元格内容 |
| | | cell.setCellValue("附件2"); |
| | | //设置标题 |
| | | Row row2 = sheet.createRow(1); |
| | | row2.setHeight((short) 800); |
| | | Cell cell1 = row2.createCell(0); |
| | | cell1.setCellValue("存量建筑垃圾堆体治理进度月报表"); |
| | | CellStyle cellStyle = workbook.createCellStyle(); |
| | | cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | cellStyle.setAlignment(HorizontalAlignment.CENTER); |
| | | Font font = workbook.createFont(); |
| | | font.setBold(true); |
| | | font.setFontHeight((short) 400); |
| | | cellStyle.setFont(font); |
| | | cell1.setCellStyle(cellStyle); |
| | | sheet.addMergedRegionUnsafe(new CellRangeAddress(1, 1, 0, 17)); |
| | | //设置填表日期,填报人,联系方式 |
| | | Row row3 = sheet.createRow(2); |
| | | row3.setHeight((short) 500); |
| | | row3.createCell(1).setCellValue("填表日期"); |
| | | row3.createCell(11).setCellValue("填表人"); |
| | | row3.createCell(15).setCellValue("联系方式"); |
| | | } |
| | | } |
| New file |
| | |
| | | package org.sxkj.system.util.excel; |
| | | |
| | | import com.alibaba.excel.metadata.Head; |
| | | import com.alibaba.excel.metadata.data.CellData; |
| | | import com.alibaba.excel.write.handler.CellWriteHandler; |
| | | import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
| | | import com.alibaba.excel.write.metadata.holder.WriteTableHolder; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.springblade.core.tool.utils.Func; |
| | | |
| | | /** |
| | | * 修改单元格格式为文本格式 |
| | | * @author zhongrj |
| | | * @since 2021-9-26 |
| | | */ |
| | | public class RowWriteHandler implements CellWriteHandler { |
| | | |
| | | public static CellStyle cellStyle; |
| | | |
| | | /** |
| | | * 设置全局变量,防止 cellStyle 创建过多报错 2021-12-16 zrj |
| | | * The maximum number of cell styles was exceeded. You can define up to 64000styles in a .xlsx workbook |
| | | * @param cellStyle |
| | | */ |
| | | public static void setCellStyle(CellStyle cellStyle) { |
| | | RowWriteHandler.cellStyle = cellStyle; |
| | | } |
| | | |
| | | @Override |
| | | public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer integer, Integer integer1, Boolean aBoolean) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer integer, Boolean aBoolean) { |
| | | //设置单元格格式为文本 |
| | | Workbook workbook = writeSheetHolder.getSheet().getWorkbook(); |
| | | //自定义样式不为空时,重复利用 |
| | | if(Func.isEmpty(cellStyle)){ |
| | | cellStyle = workbook.createCellStyle(); |
| | | setCellStyle(cellStyle); |
| | | } |
| | | DataFormat dataFormat = workbook.createDataFormat(); |
| | | cellStyle.setDataFormat(dataFormat.getFormat("@")); |
| | | cell.setCellStyle(cellStyle); |
| | | } |
| | | |
| | | //@Override 加上会报错 |
| | | public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, CellData cellData, Cell cell, Head head, Integer integer, Boolean aBoolean) { |
| | | |
| | | } |
| | | |
| | | // @Override |
| | | // public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<CellData> list, Cell cell, Head head, Integer integer, Boolean aBoolean) { |
| | | // |
| | | // } |
| | | } |