Commit cb2b42bfbed2ef1d6b104b1aac053ecc132eb90d
1 parent
d531bc79
feat(garden): 优化城市部件导出功能并添加二维码页面
- 实现三级合并表头的Excel导出功能,支持资产类型、基础信息和规格设备信息分类 - 在导出文件的图片列中嵌入实际图片,提升数据可视化效果 - 添加城市部件二维码扫码展示页面,提供移动端友好的资产信息查看界面 - 更新坐标字段命名从xCoord/yCoord/zCoord改为coordx/coordy/coordz - 调整导入模板读取配置,支持多级表头结构解析 - 重构CityComponentExportVO数据传输对象,优化字段结构和排序
Showing
7 changed files
with
202 additions
and
83 deletions
docs/城市部件-建表SQL.sql
| @@ -168,9 +168,9 @@ CREATE TABLE `garden_city_component` ( | @@ -168,9 +168,9 @@ CREATE TABLE `garden_city_component` ( | ||
| 168 | `area` varchar(128) DEFAULT NULL COMMENT '所属区域', | 168 | `area` varchar(128) DEFAULT NULL COMMENT '所属区域', |
| 169 | `road_code` varchar(16) DEFAULT NULL COMMENT '道路编码', | 169 | `road_code` varchar(16) DEFAULT NULL COMMENT '道路编码', |
| 170 | `road_name` varchar(128) DEFAULT NULL COMMENT '道路名称', | 170 | `road_name` varchar(128) DEFAULT NULL COMMENT '道路名称', |
| 171 | - `x_coord` decimal(12,8) DEFAULT NULL COMMENT 'X坐标(WGS84经度)', | ||
| 172 | - `y_coord` decimal(12,8) DEFAULT NULL COMMENT 'Y坐标(WGS84纬度)', | ||
| 173 | - `z_coord` decimal(10,4) DEFAULT NULL COMMENT 'Z坐标(高程)', | 171 | + `coordx` decimal(18,8) DEFAULT NULL COMMENT 'X坐标(WGS84经度)', |
| 172 | + `coordy` decimal(18,8) DEFAULT NULL COMMENT 'Y坐标(WGS84纬度)', | ||
| 173 | + `coordz` decimal(18,8) DEFAULT NULL COMMENT 'Z坐标(高程)', | ||
| 174 | `longitude_amap` decimal(12,8) DEFAULT NULL COMMENT '高德经度(GCJ02,自动转换)', | 174 | `longitude_amap` decimal(12,8) DEFAULT NULL COMMENT '高德经度(GCJ02,自动转换)', |
| 175 | `latitude_amap` decimal(12,8) DEFAULT NULL COMMENT '高德纬度(GCJ02,自动转换)', | 175 | `latitude_amap` decimal(12,8) DEFAULT NULL COMMENT '高德纬度(GCJ02,自动转换)', |
| 176 | `install_orientation` varchar(32) DEFAULT NULL COMMENT '安装方位(人行道/车行道/绿化带)', | 176 | `install_orientation` varchar(32) DEFAULT NULL COMMENT '安装方位(人行道/车行道/绿化带)', |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/citycomponent/CityComponentController.java
| 1 | package com.zteits.urbanops.module.garden.controller.admin.citycomponent; | 1 | package com.zteits.urbanops.module.garden.controller.admin.citycomponent; |
| 2 | 2 | ||
| 3 | import cn.idev.excel.FastExcelFactory; | 3 | import cn.idev.excel.FastExcelFactory; |
| 4 | +import cn.idev.excel.converters.longconverter.LongStringConverter; | ||
| 4 | import com.zteits.urbanops.framework.excel.core.handler.ColumnWidthMatchStyleStrategy; | 5 | import com.zteits.urbanops.framework.excel.core.handler.ColumnWidthMatchStyleStrategy; |
| 5 | -import com.zteits.urbanops.framework.excel.core.handler.SelectSheetWriteHandler; | ||
| 6 | -import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; | ||
| 7 | import com.zteits.urbanops.module.garden.controller.admin.citycomponent.vo.*; | 6 | import com.zteits.urbanops.module.garden.controller.admin.citycomponent.vo.*; |
| 8 | import com.zteits.urbanops.module.garden.dal.dataobject.citycomponent.CityComponentDO; | 7 | import com.zteits.urbanops.module.garden.dal.dataobject.citycomponent.CityComponentDO; |
| 9 | import com.zteits.urbanops.module.garden.dal.dataobject.citycomponenttype.CityComponentTypeDO; | 8 | import com.zteits.urbanops.module.garden.dal.dataobject.citycomponenttype.CityComponentTypeDO; |
| 10 | import com.zteits.urbanops.module.garden.dal.mysql.citycomponenttype.CityComponentTypeMapper; | 9 | import com.zteits.urbanops.module.garden.dal.mysql.citycomponenttype.CityComponentTypeMapper; |
| 11 | import com.zteits.urbanops.module.garden.service.citycomponent.CityComponentService; | 10 | import com.zteits.urbanops.module.garden.service.citycomponent.CityComponentService; |
| 11 | +import org.apache.poi.ss.usermodel.*; | ||
| 12 | import org.springframework.web.bind.annotation.*; | 12 | import org.springframework.web.bind.annotation.*; |
| 13 | import org.springframework.web.multipart.MultipartFile; | 13 | import org.springframework.web.multipart.MultipartFile; |
| 14 | import jakarta.annotation.Resource; | 14 | import jakarta.annotation.Resource; |
| @@ -19,8 +19,13 @@ import io.swagger.v3.oas.annotations.Operation; | @@ -19,8 +19,13 @@ import io.swagger.v3.oas.annotations.Operation; | ||
| 19 | import jakarta.validation.*; | 19 | import jakarta.validation.*; |
| 20 | import jakarta.servlet.http.HttpServletResponse; | 20 | import jakarta.servlet.http.HttpServletResponse; |
| 21 | 21 | ||
| 22 | +import javax.imageio.ImageIO; | ||
| 23 | +import java.awt.image.BufferedImage; | ||
| 22 | import java.math.BigDecimal; | 24 | import java.math.BigDecimal; |
| 25 | +import java.io.ByteArrayOutputStream; | ||
| 26 | +import java.io.ByteArrayInputStream; | ||
| 23 | import java.io.IOException; | 27 | import java.io.IOException; |
| 28 | +import java.net.URL; | ||
| 24 | import java.net.URLEncoder; | 29 | import java.net.URLEncoder; |
| 25 | import java.nio.charset.StandardCharsets; | 30 | import java.nio.charset.StandardCharsets; |
| 26 | import java.time.LocalDate; | 31 | import java.time.LocalDate; |
| @@ -89,14 +94,97 @@ public class CityComponentController { | @@ -89,14 +94,97 @@ public class CityComponentController { | ||
| 89 | List<CityComponentDO> list = cityComponentService.getList(reqVO); | 94 | List<CityComponentDO> list = cityComponentService.getList(reqVO); |
| 90 | List<CityComponentExportVO> exportList = BeanUtils.toBean(list, CityComponentExportVO.class); | 95 | List<CityComponentExportVO> exportList = BeanUtils.toBean(list, CityComponentExportVO.class); |
| 91 | String filename = "城市部件" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx"; | 96 | String filename = "城市部件" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx"; |
| 92 | - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); | ||
| 93 | - response.setCharacterEncoding("utf-8"); | ||
| 94 | - response.setHeader("Content-disposition", | ||
| 95 | - "attachment;filename*=utf-8''" + URLEncoder.encode(filename, StandardCharsets.UTF_8)); | ||
| 96 | - FastExcelFactory.write(response.getOutputStream(), CityComponentExportVO.class) | 97 | + |
| 98 | + // 三级合并表头(列优先:headList.get(col).get(row)) | ||
| 99 | + List<List<String>> headList = new ArrayList<>(); | ||
| 100 | + // 资产类型(col 0-2) | ||
| 101 | + headList.add(java.util.Arrays.asList("资产类型", "一级资产类型")); | ||
| 102 | + headList.add(java.util.Arrays.asList("", "二级资产类型")); | ||
| 103 | + headList.add(java.util.Arrays.asList("", "三级资产类型")); | ||
| 104 | + // 基础信息(col 3-10) | ||
| 105 | + headList.add(java.util.Arrays.asList("基础信息", "资产ID")); | ||
| 106 | + headList.add(java.util.Arrays.asList("", "所属区域")); | ||
| 107 | + headList.add(java.util.Arrays.asList("", "X")); | ||
| 108 | + headList.add(java.util.Arrays.asList("", "Y")); | ||
| 109 | + headList.add(java.util.Arrays.asList("", "Z")); | ||
| 110 | + headList.add(java.util.Arrays.asList("", "道路名称")); | ||
| 111 | + headList.add(java.util.Arrays.asList("", "安装方位")); | ||
| 112 | + headList.add(java.util.Arrays.asList("", "所属网格")); | ||
| 113 | + // 规格与设备信息(col 11-25) | ||
| 114 | + headList.add(java.util.Arrays.asList("规格与设备信息", "品牌/厂家")); | ||
| 115 | + headList.add(java.util.Arrays.asList("", "型号规格")); | ||
| 116 | + headList.add(java.util.Arrays.asList("", "材质")); | ||
| 117 | + headList.add(java.util.Arrays.asList("", "长")); | ||
| 118 | + headList.add(java.util.Arrays.asList("", "宽")); | ||
| 119 | + headList.add(java.util.Arrays.asList("", "高")); | ||
| 120 | + headList.add(java.util.Arrays.asList("", "胸径")); | ||
| 121 | + headList.add(java.util.Arrays.asList("", "安装时间/种植时间")); | ||
| 122 | + headList.add(java.util.Arrays.asList("", "资产状态")); | ||
| 123 | + headList.add(java.util.Arrays.asList("", "管理单位")); | ||
| 124 | + headList.add(java.util.Arrays.asList("", "责任人")); | ||
| 125 | + headList.add(java.util.Arrays.asList("", "投入年限")); | ||
| 126 | + headList.add(java.util.Arrays.asList("", "维保到期日")); | ||
| 127 | + headList.add(java.util.Arrays.asList("", "采购批次/项目名称")); | ||
| 128 | + headList.add(java.util.Arrays.asList("", "图片")); | ||
| 129 | + List<org.apache.poi.ss.util.CellRangeAddress> mergeList = java.util.Arrays.asList( | ||
| 130 | + new org.apache.poi.ss.util.CellRangeAddress(0, 0, 0, 2), | ||
| 131 | + new org.apache.poi.ss.util.CellRangeAddress(0, 0, 3, 10), | ||
| 132 | + new org.apache.poi.ss.util.CellRangeAddress(0, 0, 11, 25) | ||
| 133 | + ); | ||
| 134 | + | ||
| 135 | + // 先写数据到内存(含三级合并表头) | ||
| 136 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
| 137 | + FastExcelFactory.write(baos) | ||
| 138 | + .head(headList) | ||
| 97 | .registerWriteHandler(new ColumnWidthMatchStyleStrategy()) | 139 | .registerWriteHandler(new ColumnWidthMatchStyleStrategy()) |
| 98 | - .registerWriteHandler(new SelectSheetWriteHandler(CityComponentExportVO.class)) | 140 | + .registerWriteHandler(new com.zteits.urbanops.framework.excel.core.handler.HeadMergeHandler( |
| 141 | + mergeList.toArray(new org.apache.poi.ss.util.CellRangeAddress[0]))) | ||
| 142 | + .registerConverter(new LongStringConverter()) | ||
| 99 | .sheet("数据").doWrite(exportList); | 143 | .sheet("数据").doWrite(exportList); |
| 144 | + | ||
| 145 | + // 重新打开 workbook,在"图片"列嵌入图片(列索引 25) | ||
| 146 | + try (Workbook workbook = WorkbookFactory.create(new ByteArrayInputStream(baos.toByteArray()))) { | ||
| 147 | + Sheet sheet = workbook.getSheetAt(0); | ||
| 148 | + int imgCol = 25; // "图片"列固定在第26列(索引25) | ||
| 149 | + if (imgCol >= 0) { | ||
| 150 | + sheet.setColumnWidth(imgCol, 25 * 256); | ||
| 151 | + for (int i = 0; i < exportList.size(); i++) { | ||
| 152 | + String urls = exportList.get(i).getImageUrls(); | ||
| 153 | + if (urls == null || urls.isEmpty()) continue; | ||
| 154 | + String[] parts = urls.split(","); | ||
| 155 | + Row row = sheet.getRow(i + 2); // +2 跳过两行表头 | ||
| 156 | + if (row == null) row = sheet.createRow(i + 2); | ||
| 157 | + row.setHeightInPoints(70); | ||
| 158 | + Cell urlCell = row.getCell(imgCol); | ||
| 159 | + if (urlCell != null) urlCell.setBlank(); | ||
| 160 | + | ||
| 161 | + for (int j = 0; j < Math.min(parts.length, 3); j++) { | ||
| 162 | + try { | ||
| 163 | + BufferedImage img = ImageIO.read(new URL(parts[j].trim())); | ||
| 164 | + if (img == null) continue; | ||
| 165 | + ByteArrayOutputStream ibaos = new ByteArrayOutputStream(); | ||
| 166 | + ImageIO.write(img, "jpg", ibaos); | ||
| 167 | + int picIdx = workbook.addPicture(ibaos.toByteArray(), Workbook.PICTURE_TYPE_JPEG); | ||
| 168 | + | ||
| 169 | + Drawing<?> drawing = sheet.createDrawingPatriarch(); | ||
| 170 | + ClientAnchor anchor = workbook.getCreationHelper().createClientAnchor(); | ||
| 171 | + anchor.setCol1(imgCol + j * 2); | ||
| 172 | + anchor.setRow1(i + 2); | ||
| 173 | + anchor.setDx1(200); anchor.setDy1(200); | ||
| 174 | + anchor.setCol2(imgCol + j * 2 + 2); | ||
| 175 | + anchor.setRow2(i + 3); | ||
| 176 | + anchor.setDx2(-200); anchor.setDy2(-200); | ||
| 177 | + drawing.createPicture(anchor, picIdx); | ||
| 178 | + } catch (Exception ignored) {} | ||
| 179 | + } | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); | ||
| 184 | + response.setHeader("Content-Disposition", | ||
| 185 | + "attachment;filename*=UTF-8''" + URLEncoder.encode(filename, StandardCharsets.UTF_8)); | ||
| 186 | + workbook.write(response.getOutputStream()); | ||
| 187 | + } | ||
| 100 | } | 188 | } |
| 101 | 189 | ||
| 102 | @GetMapping("/generate-qr") | 190 | @GetMapping("/generate-qr") |
| @@ -106,6 +194,51 @@ public class CityComponentController { | @@ -106,6 +194,51 @@ public class CityComponentController { | ||
| 106 | return success(cityComponentService.generateQrCode(id)); | 194 | return success(cityComponentService.generateQrCode(id)); |
| 107 | } | 195 | } |
| 108 | 196 | ||
| 197 | + @GetMapping("/qr-page") | ||
| 198 | + @Operation(summary = "二维码扫码页面(公开)") | ||
| 199 | + @jakarta.annotation.security.PermitAll | ||
| 200 | + public void qrPage(@RequestParam("code") String componentCode, HttpServletResponse response) throws IOException { | ||
| 201 | + CityComponentDO comp = cityComponentService.getByComponentCode(componentCode); | ||
| 202 | + StringBuilder html = new StringBuilder(); | ||
| 203 | + html.append("<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">"); | ||
| 204 | + html.append("<title>").append(comp.getComponentCode()).append("</title>"); | ||
| 205 | + html.append("<style>body{font-family:-apple-system,BlinkMacSystemFont,sans-serif;margin:0;padding:16px;background:#f5f5f5}"); | ||
| 206 | + html.append(".card{background:#fff;border-radius:8px;padding:16px;margin-bottom:12px;box-shadow:0 1px 3px rgba(0,0,0,.1)}"); | ||
| 207 | + html.append(".label{color:#999;font-size:12px;margin-bottom:4px}.val{color:#333;font-size:16px;font-weight:500}"); | ||
| 208 | + html.append(".title{text-align:center;font-size:18px;font-weight:bold;color:#1a73e8;margin-bottom:16px}"); | ||
| 209 | + html.append(".row{display:flex;flex-wrap:wrap}.col{width:50%;margin-bottom:12px}</style></head><body>"); | ||
| 210 | + html.append("<div class=\"card title\">资产信息</div>"); | ||
| 211 | + html.append("<div class=\"card\">"); | ||
| 212 | + html.append("<div class=\"row\"><div class=\"col\"><div class=\"label\">资产ID</div><div class=\"val\">").append(nvl(comp.getComponentCode())).append("</div></div>"); | ||
| 213 | + html.append("<div class=\"col\"><div class=\"label\">资产状态</div><div class=\"val\">").append(nvl(comp.getAssetStatus())).append("</div></div></div>"); | ||
| 214 | + html.append("<div class=\"row\"><div class=\"col\"><div class=\"label\">一级类型</div><div class=\"val\">").append(nvl(comp.getLevelOneTypeName())).append("</div></div>"); | ||
| 215 | + html.append("<div class=\"col\"><div class=\"label\">二级类型</div><div class=\"val\">").append(nvl(comp.getLevelTwoTypeName())).append("</div></div></div>"); | ||
| 216 | + html.append("<div class=\"row\"><div class=\"col\"><div class=\"label\">三级类型</div><div class=\"val\">").append(nvl(comp.getLevelThreeTypeName())).append("</div></div>"); | ||
| 217 | + html.append("<div class=\"col\"><div class=\"label\">所属区域</div><div class=\"val\">").append(nvl(comp.getArea())).append("</div></div></div>"); | ||
| 218 | + html.append("<div class=\"row\"><div class=\"col\"><div class=\"label\">道路名称</div><div class=\"val\">").append(nvl(comp.getRoadName())).append("</div></div>"); | ||
| 219 | + html.append("<div class=\"col\"><div class=\"label\">安装方位</div><div class=\"val\">").append(nvl(comp.getInstallOrientation())).append("</div></div></div>"); | ||
| 220 | + html.append("<div class=\"row\"><div class=\"col\"><div class=\"label\">品牌/厂家</div><div class=\"val\">").append(nvl(comp.getBrand())).append("</div></div>"); | ||
| 221 | + html.append("<div class=\"col\"><div class=\"label\">型号规格</div><div class=\"val\">").append(nvl(comp.getModelSpec())).append("</div></div></div>"); | ||
| 222 | + html.append("<div class=\"row\"><div class=\"col\"><div class=\"label\">材质</div><div class=\"val\">").append(nvl(comp.getMaterial())).append("</div></div>"); | ||
| 223 | + html.append("<div class=\"col\"><div class=\"label\">管理单位</div><div class=\"val\">").append(nvl(comp.getManagementUnit())).append("</div></div></div>"); | ||
| 224 | + html.append("<div class=\"row\"><div class=\"col\"><div class=\"label\">责任人</div><div class=\"val\">").append(nvl(comp.getResponsiblePerson())).append("</div></div>"); | ||
| 225 | + html.append("<div class=\"col\"><div class=\"label\">安装时间</div><div class=\"val\">").append(comp.getInstallDate()!=null?comp.getInstallDate().toString():"-").append("</div></div></div>"); | ||
| 226 | + html.append("<div class=\"row\"><div class=\"col\"><div class=\"label\">维保到期日</div><div class=\"val\">").append(comp.getMaintenanceDeadline()!=null?comp.getMaintenanceDeadline().toString():"-").append("</div></div>"); | ||
| 227 | + html.append("<div class=\"col\"><div class=\"label\">采购批次</div><div class=\"val\">").append(nvl(comp.getProcurementBatch())).append("</div></div></div>"); | ||
| 228 | + html.append("</div>"); | ||
| 229 | + // 显示图片 | ||
| 230 | + if (comp.getImageUrls() != null && !comp.getImageUrls().isEmpty()) { | ||
| 231 | + html.append("<div class=\"card\"><div class=\"label\">图片信息</div>"); | ||
| 232 | + for (String url : comp.getImageUrls().split(",")) { | ||
| 233 | + html.append("<img src=\"").append(url.trim()).append("\" style=\"width:100%;max-width:300px;margin:4px 0;border-radius:4px\"/>"); | ||
| 234 | + } | ||
| 235 | + html.append("</div>"); | ||
| 236 | + } | ||
| 237 | + html.append("</body></html>"); | ||
| 238 | + response.setContentType("text/html;charset=UTF-8"); | ||
| 239 | + response.getWriter().write(html.toString()); | ||
| 240 | + } | ||
| 241 | + | ||
| 109 | @GetMapping("/import-template") | 242 | @GetMapping("/import-template") |
| 110 | @Operation(summary = "下载导入模板") | 243 | @Operation(summary = "下载导入模板") |
| 111 | @jakarta.annotation.security.PermitAll | 244 | @jakarta.annotation.security.PermitAll |
| @@ -122,7 +255,7 @@ public class CityComponentController { | @@ -122,7 +255,7 @@ public class CityComponentController { | ||
| 122 | @PreAuthorize("@ss.hasPermission('garden:city-component:create')") | 255 | @PreAuthorize("@ss.hasPermission('garden:city-component:create')") |
| 123 | public CommonResult<String> importExcel(@RequestParam("file") MultipartFile file) throws IOException { | 256 | public CommonResult<String> importExcel(@RequestParam("file") MultipartFile file) throws IOException { |
| 124 | List<CityComponentImportVO> importList = FastExcelFactory.read(file.getInputStream()) | 257 | List<CityComponentImportVO> importList = FastExcelFactory.read(file.getInputStream()) |
| 125 | - .head(CityComponentImportVO.class).headRowNumber(1).sheet().doReadSync(); | 258 | + .head(CityComponentImportVO.class).headRowNumber(2).sheet().doReadSync(); |
| 126 | List<String> errors = new ArrayList<>(); | 259 | List<String> errors = new ArrayList<>(); |
| 127 | // 第一遍:全量校验 | 260 | // 第一遍:全量校验 |
| 128 | for (int i = 0; i < importList.size(); i++) { | 261 | for (int i = 0; i < importList.size(); i++) { |
| @@ -178,4 +311,6 @@ public class CityComponentController { | @@ -178,4 +311,6 @@ public class CityComponentController { | ||
| 178 | } | 311 | } |
| 179 | return success("成功导入 " + count + " 条记录"); | 312 | return success("成功导入 " + count + " 条记录"); |
| 180 | } | 313 | } |
| 314 | + | ||
| 315 | + private String nvl(String s) { return s != null ? s : "-"; } | ||
| 181 | } | 316 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/citycomponent/vo/CityComponentExportVO.java
| 1 | package com.zteits.urbanops.module.garden.controller.admin.citycomponent.vo; | 1 | package com.zteits.urbanops.module.garden.controller.admin.citycomponent.vo; |
| 2 | 2 | ||
| 3 | -import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | ||
| 4 | -import cn.idev.excel.annotation.ExcelProperty; | ||
| 5 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | import lombok.Data; | 4 | import lombok.Data; |
| 7 | 5 | ||
| 8 | import java.math.BigDecimal; | 6 | import java.math.BigDecimal; |
| 9 | import java.time.LocalDate; | 7 | import java.time.LocalDate; |
| 10 | -import java.time.LocalDateTime; | ||
| 11 | 8 | ||
| 12 | @Schema(description = "城市部件导出 VO") | 9 | @Schema(description = "城市部件导出 VO") |
| 13 | @Data | 10 | @Data |
| 14 | -@ExcelIgnoreUnannotated | ||
| 15 | public class CityComponentExportVO { | 11 | public class CityComponentExportVO { |
| 16 | 12 | ||
| 17 | - @ExcelProperty("资产ID") | ||
| 18 | - private String componentCode; | ||
| 19 | - @ExcelProperty("一级类型") | ||
| 20 | - private String levelOneTypeName; | ||
| 21 | - @ExcelProperty("二级类型") | ||
| 22 | - private String levelTwoTypeName; | ||
| 23 | - @ExcelProperty("三级类型") | ||
| 24 | - private String levelThreeTypeName; | ||
| 25 | - @ExcelProperty("所属区域") | ||
| 26 | - private String area; | ||
| 27 | - @ExcelProperty("道路名称") | ||
| 28 | - private String roadName; | ||
| 29 | - @ExcelProperty("安装方位") | ||
| 30 | - private String installOrientation; | ||
| 31 | - @ExcelProperty("所属网格") | ||
| 32 | - private String grid; | ||
| 33 | - @ExcelProperty("品牌") | ||
| 34 | - private String brand; | ||
| 35 | - @ExcelProperty("型号规格") | ||
| 36 | - private String modelSpec; | ||
| 37 | - @ExcelProperty("材质") | ||
| 38 | - private String material; | ||
| 39 | - @ExcelProperty("安装时间") | ||
| 40 | - private LocalDate installDate; | ||
| 41 | - @ExcelProperty("资产状态") | ||
| 42 | - private String assetStatus; | ||
| 43 | - @ExcelProperty("管理单位") | ||
| 44 | - private String managementUnit; | ||
| 45 | - @ExcelProperty("责任人") | ||
| 46 | - private String responsiblePerson; | ||
| 47 | - @ExcelProperty("维保到期日") | ||
| 48 | - private LocalDate maintenanceDeadline; | ||
| 49 | - @ExcelProperty("巡检周期") | ||
| 50 | - private String inspectionCycle; | ||
| 51 | - @ExcelProperty("最近巡检时间") | ||
| 52 | - private LocalDateTime lastInspectionTime; | ||
| 53 | - @ExcelProperty("巡检结果") | ||
| 54 | - private String inspectionResult; | ||
| 55 | - @ExcelProperty("异常描述") | ||
| 56 | - private String abnormalDescription; | ||
| 57 | - @ExcelProperty("报修工单编号") | ||
| 58 | - private String repairOrderNo; | ||
| 59 | - @ExcelProperty("维修完成时间") | ||
| 60 | - private LocalDateTime repairCompleteTime; | ||
| 61 | - @ExcelProperty("维修单位") | ||
| 62 | - private String repairUnit; | ||
| 63 | - @ExcelProperty("图片信息") | ||
| 64 | - private String imageUrls; | ||
| 65 | - @ExcelProperty("备注") | ||
| 66 | - private String remark; | 13 | + private String levelOneTypeName; // 1. 一级资产类型 |
| 14 | + private String levelTwoTypeName; // 2. 二级资产类型 | ||
| 15 | + private String levelThreeTypeName; // 3. 三级资产类型 | ||
| 16 | + | ||
| 17 | + private String componentCode; // 4. 资产ID | ||
| 18 | + private String area; // 5. 所属区域 | ||
| 19 | + private BigDecimal coordx; // 6. X | ||
| 20 | + private BigDecimal coordy; // 7. Y | ||
| 21 | + private BigDecimal coordz; // 8. Z | ||
| 22 | + private String roadName; // 9. 道路名称 | ||
| 23 | + private String installOrientation; // 10. 安装方位 | ||
| 24 | + private String grid; // 11. 所属网格 | ||
| 25 | + | ||
| 26 | + private String brand; // 12. 品牌/厂家 | ||
| 27 | + private String modelSpec; // 13. 型号规格 | ||
| 28 | + private String material; // 14. 材质 | ||
| 29 | + private BigDecimal length; // 15. 长 | ||
| 30 | + private BigDecimal width; // 16. 宽 | ||
| 31 | + private BigDecimal height; // 17. 高 | ||
| 32 | + private BigDecimal dbh; // 18. 胸径 | ||
| 33 | + private LocalDate installDate; // 19. 安装时间/种植时间 | ||
| 34 | + private String assetStatus; // 20. 资产状态 | ||
| 35 | + private String managementUnit; // 21. 管理单位 | ||
| 36 | + private String responsiblePerson; // 22. 责任人 | ||
| 37 | + private BigDecimal serviceYears; // 23. 投入年限 | ||
| 38 | + private LocalDate maintenanceDeadline; // 24. 维保到期日 | ||
| 39 | + private String procurementBatch; // 25. 采购批次/项目名称 | ||
| 40 | + private String imageUrls; // 26. 图片 | ||
| 67 | } | 41 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/citycomponent/vo/CityComponentRespVO.java
| @@ -43,11 +43,10 @@ public class CityComponentRespVO { | @@ -43,11 +43,10 @@ public class CityComponentRespVO { | ||
| 43 | private String roadCode; | 43 | private String roadCode; |
| 44 | 44 | ||
| 45 | @ExcelProperty("X坐标") | 45 | @ExcelProperty("X坐标") |
| 46 | - private BigDecimal xCoord; | 46 | + private BigDecimal coordx; |
| 47 | @ExcelProperty("Y坐标") | 47 | @ExcelProperty("Y坐标") |
| 48 | - private BigDecimal yCoord; | ||
| 49 | - | ||
| 50 | - private BigDecimal zCoord; | 48 | + private BigDecimal coordy; |
| 49 | + private BigDecimal coordz; | ||
| 51 | private BigDecimal longitudeAmap; | 50 | private BigDecimal longitudeAmap; |
| 52 | private BigDecimal latitudeAmap; | 51 | private BigDecimal latitudeAmap; |
| 53 | 52 |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/citycomponent/CityComponentDO.java
| @@ -37,9 +37,9 @@ public class CityComponentDO extends BaseDO { | @@ -37,9 +37,9 @@ public class CityComponentDO extends BaseDO { | ||
| 37 | private String area; | 37 | private String area; |
| 38 | private String roadCode; | 38 | private String roadCode; |
| 39 | private String roadName; | 39 | private String roadName; |
| 40 | - private BigDecimal xCoord; | ||
| 41 | - private BigDecimal yCoord; | ||
| 42 | - private BigDecimal zCoord; | 40 | + private BigDecimal coordx; |
| 41 | + private BigDecimal coordy; | ||
| 42 | + private BigDecimal coordz; | ||
| 43 | private BigDecimal longitudeAmap; | 43 | private BigDecimal longitudeAmap; |
| 44 | private BigDecimal latitudeAmap; | 44 | private BigDecimal latitudeAmap; |
| 45 | private String installOrientation; | 45 | private String installOrientation; |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/citycomponent/CityComponentService.java
| @@ -23,4 +23,6 @@ public interface CityComponentService { | @@ -23,4 +23,6 @@ public interface CityComponentService { | ||
| 23 | List<CityComponentDO> getList(CityComponentPageReqVO reqVO); | 23 | List<CityComponentDO> getList(CityComponentPageReqVO reqVO); |
| 24 | 24 | ||
| 25 | String generateQrCode(Long id); | 25 | String generateQrCode(Long id); |
| 26 | + | ||
| 27 | + CityComponentDO getByComponentCode(String componentCode); | ||
| 26 | } | 28 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/citycomponent/CityComponentServiceImpl.java
| @@ -34,9 +34,9 @@ public class CityComponentServiceImpl implements CityComponentService { | @@ -34,9 +34,9 @@ public class CityComponentServiceImpl implements CityComponentService { | ||
| 34 | public Long create(@Valid CityComponentSaveReqVO reqVO) { | 34 | public Long create(@Valid CityComponentSaveReqVO reqVO) { |
| 35 | validateCodeUnique(reqVO.getComponentCode(), null); | 35 | validateCodeUnique(reqVO.getComponentCode(), null); |
| 36 | CityComponentDO comp = BeanUtils.toBean(reqVO, CityComponentDO.class); | 36 | CityComponentDO comp = BeanUtils.toBean(reqVO, CityComponentDO.class); |
| 37 | - if (reqVO.getCoordx() != null) comp.setXCoord(new BigDecimal(reqVO.getCoordx())); | ||
| 38 | - if (reqVO.getCoordy() != null) comp.setYCoord(new BigDecimal(reqVO.getCoordy())); | ||
| 39 | - if (reqVO.getCoordz() != null) comp.setZCoord(new BigDecimal(reqVO.getCoordz())); | 37 | + if (reqVO.getCoordx() != null) comp.setCoordx(new BigDecimal(reqVO.getCoordx())); |
| 38 | + if (reqVO.getCoordy() != null) comp.setCoordy(new BigDecimal(reqVO.getCoordy())); | ||
| 39 | + if (reqVO.getCoordz() != null) comp.setCoordz(new BigDecimal(reqVO.getCoordz())); | ||
| 40 | fillTypeNames(comp); | 40 | fillTypeNames(comp); |
| 41 | convertCoordinates(comp); | 41 | convertCoordinates(comp); |
| 42 | cityComponentMapper.insert(comp); | 42 | cityComponentMapper.insert(comp); |
| @@ -55,9 +55,9 @@ public class CityComponentServiceImpl implements CityComponentService { | @@ -55,9 +55,9 @@ public class CityComponentServiceImpl implements CityComponentService { | ||
| 55 | } | 55 | } |
| 56 | validateCodeUnique(reqVO.getComponentCode(), reqVO.getId()); | 56 | validateCodeUnique(reqVO.getComponentCode(), reqVO.getId()); |
| 57 | CityComponentDO comp = BeanUtils.toBean(reqVO, CityComponentDO.class); | 57 | CityComponentDO comp = BeanUtils.toBean(reqVO, CityComponentDO.class); |
| 58 | - if (reqVO.getCoordx() != null) comp.setXCoord(new BigDecimal(reqVO.getCoordx())); | ||
| 59 | - if (reqVO.getCoordy() != null) comp.setYCoord(new BigDecimal(reqVO.getCoordy())); | ||
| 60 | - if (reqVO.getCoordz() != null) comp.setZCoord(new BigDecimal(reqVO.getCoordz())); | 58 | + if (reqVO.getCoordx() != null) comp.setCoordx(new BigDecimal(reqVO.getCoordx())); |
| 59 | + if (reqVO.getCoordy() != null) comp.setCoordy(new BigDecimal(reqVO.getCoordy())); | ||
| 60 | + if (reqVO.getCoordz() != null) comp.setCoordz(new BigDecimal(reqVO.getCoordz())); | ||
| 61 | fillTypeNames(comp); | 61 | fillTypeNames(comp); |
| 62 | convertCoordinates(comp); | 62 | convertCoordinates(comp); |
| 63 | cityComponentMapper.updateById(comp); | 63 | cityComponentMapper.updateById(comp); |
| @@ -95,12 +95,21 @@ public class CityComponentServiceImpl implements CityComponentService { | @@ -95,12 +95,21 @@ public class CityComponentServiceImpl implements CityComponentService { | ||
| 95 | @Override | 95 | @Override |
| 96 | public String generateQrCode(Long id) { | 96 | public String generateQrCode(Long id) { |
| 97 | CityComponentDO comp = get(id); | 97 | CityComponentDO comp = get(id); |
| 98 | - String url = "https://urbanops.zteits.com/component/" + comp.getComponentCode(); | 98 | + String url = "https://test.jichengshanshui.com.cn:28302/admin-api/garden/city-component/qr-page?code=" + comp.getComponentCode(); |
| 99 | comp.setQrCodeUrl(url); | 99 | comp.setQrCodeUrl(url); |
| 100 | cityComponentMapper.updateById(comp); | 100 | cityComponentMapper.updateById(comp); |
| 101 | return url; | 101 | return url; |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | + @Override | ||
| 105 | + public CityComponentDO getByComponentCode(String componentCode) { | ||
| 106 | + CityComponentDO comp = cityComponentMapper.selectByComponentCode(componentCode); | ||
| 107 | + if (comp == null) { | ||
| 108 | + throw ServiceExceptionUtil.exception(ErrorCodeConstants.CITY_COMPONENT_NOT_EXISTS); | ||
| 109 | + } | ||
| 110 | + return comp; | ||
| 111 | + } | ||
| 112 | + | ||
| 104 | private void validateCodeUnique(String code, Long excludeId) { | 113 | private void validateCodeUnique(String code, Long excludeId) { |
| 105 | if (code == null || code.isEmpty()) return; | 114 | if (code == null || code.isEmpty()) return; |
| 106 | CityComponentDO exist = cityComponentMapper.selectByComponentCode(code); | 115 | CityComponentDO exist = cityComponentMapper.selectByComponentCode(code); |
| @@ -125,10 +134,10 @@ public class CityComponentServiceImpl implements CityComponentService { | @@ -125,10 +134,10 @@ public class CityComponentServiceImpl implements CityComponentService { | ||
| 125 | } | 134 | } |
| 126 | 135 | ||
| 127 | private void convertCoordinates(CityComponentDO comp) { | 136 | private void convertCoordinates(CityComponentDO comp) { |
| 128 | - if (comp.getXCoord() != null && comp.getYCoord() != null) { | 137 | + if (comp.getCoordx() != null && comp.getCoordy() != null) { |
| 129 | double[] gcj02 = GisCoordinateUtil.wgs84ToGcj02( | 138 | double[] gcj02 = GisCoordinateUtil.wgs84ToGcj02( |
| 130 | - comp.getXCoord().doubleValue(), | ||
| 131 | - comp.getYCoord().doubleValue()); | 139 | + comp.getCoordx().doubleValue(), |
| 140 | + comp.getCoordy().doubleValue()); | ||
| 132 | comp.setLongitudeAmap(BigDecimal.valueOf(gcj02[0])); | 141 | comp.setLongitudeAmap(BigDecimal.valueOf(gcj02[0])); |
| 133 | comp.setLatitudeAmap(BigDecimal.valueOf(gcj02[1])); | 142 | comp.setLatitudeAmap(BigDecimal.valueOf(gcj02[1])); |
| 134 | } | 143 | } |