This commit is contained in:
wanghao
2025-12-12 17:27:43 +08:00
parent fe5ca6619c
commit 5e4f95c10d
3 changed files with 32 additions and 11 deletions
@@ -22,9 +22,9 @@ public class AedTempImportVO {
private String latitude; private String latitude;
@Excel(name = "东经", width = 15) @Excel(name = "东经", width = 15)
private String longitude; private String longitude;
@Excel(name = "配置时间", width = 15) @Excel(name = "配置时间", width = 15,format = "yyyy/MM/dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @JsonFormat(timezone = "GMT+8", pattern = "yyyy/MM/dd")
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy/MM/dd")
private Date installTime; private Date installTime;
@Excel(name = "设备型号", width = 15) @Excel(name = "设备型号", width = 15)
private String hostModel; private String hostModel;
@@ -20,6 +20,6 @@ public class XjAedController extends JeecgController<XjAed, IXjAedService> {
*/ */
@GetMapping("dataInit") @GetMapping("dataInit")
public void aedDataInit() { public void aedDataInit() {
xjAedService.aedDataUtil(); xjAedService.aedDataInit();
} }
} }
@@ -34,7 +34,7 @@ public class XjAedServiceImpl extends ServiceImpl<XjAedMapper, XjAed> implements
@Override @Override
public void aedDataInit() { public void aedDataInit() {
String filePath = "D:\\Project\\Java\\rk\\文档\\新疆油田-24\\各二级单位坐标位置更正统计9.15.xlsx"; String filePath = "C:\\Users\\Huawei\\Desktop\\AED.xlsx";
try (FileInputStream file = new FileInputStream(filePath); try (FileInputStream file = new FileInputStream(filePath);
XSSFWorkbook workbook = new XSSFWorkbook(file)) { XSSFWorkbook workbook = new XSSFWorkbook(file)) {
@@ -54,24 +54,44 @@ public class XjAedServiceImpl extends ServiceImpl<XjAedMapper, XjAed> implements
XSSFCell secondCell = row.getCell(1); XSSFCell secondCell = row.getCell(1);
String secondCellValue = secondCell != null ? getCellValue(secondCell) : "[空]"; String secondCellValue = secondCell != null ? getCellValue(secondCell) : "[空]";
// 获取第个单元格(索引6)的数据 设置地点 // 获取第个单元格(索引2)的数据 设置地点
XSSFCell threeCell = row.getCell(2);
String threeCellValue = secondCell != null ? getCellValue(threeCell) : "[空]";
// 获取第四个单元格(索引3)的数据 纬度
XSSFCell fourCell = row.getCell(3);
String fourCellValue = secondCell != null ? getCellValue(fourCell) : "[空]";
// 获取第五个单元格(索引4)的数据 精度
XSSFCell fiveCell = row.getCell(4);
String fiveCellValue = secondCell != null ? getCellValue(fiveCell) : "[空]";
// 获取第六个单元格(索引5)的数据 时间
XSSFCell sixCell = row.getCell(5);
String sixCellValue = secondCell != null ? getCellValue(sixCell) : "[空]";
// 获取第七个单元格(索引6)的数据 型号
XSSFCell sevenCell = row.getCell(6); XSSFCell sevenCell = row.getCell(6);
String sevenCellValue = secondCell != null ? getCellValue(sevenCell) : "[空]"; String sevenCellValue = secondCell != null ? getCellValue(sevenCell) : "[空]";
// 获取第个单元格(索引7)的数据 精度 // 获取第8个单元格(索引7)的数据 编号
XSSFCell eightCell = row.getCell(7); XSSFCell eightCell = row.getCell(7);
String eightCellValue = secondCell != null ? getCellValue(eightCell) : "[空]"; String eightCellValue = secondCell != null ? getCellValue(eightCell) : "[空]";
// 获取第个单元格(索引8)的数据 纬度 // 获取第9个单元格(索引8)的数据 AED管理人员
XSSFCell nineCell = row.getCell(8); XSSFCell nineCell = row.getCell(8);
String nineCellValue = secondCell != null ? getCellValue(nineCell) : "[空]"; String nineCellValue = secondCell != null ? getCellValue(nineCell) : "[空]";
// 获取第10个单元格(索引9)的数据 电话
XSSFCell tenCell = row.getCell(8);
String tenCellValue = secondCell != null ? getCellValue(tenCell) : "[空]";
XjAed xjAed = new XjAed(); XjAed xjAed = new XjAed();
xjAed.setName("自动体外除颤仪"); xjAed.setName("自动体外除颤仪");
xjAed.setAddress(firstCellValue+secondCellValue+sevenCellValue);
try { try {
String[] split = converter.run(eightCellValue + "-" + nineCellValue).split("-"); String[] split = converter.run(fiveCellValue + "-" + fourCellValue).split("-");
CoordinateConverter.Gps gps = CoordinateConverter.GPS84ToGCJ02( CoordinateConverter.Gps gps = CoordinateConverter.GPS84ToGCJ02(
TypeConversionUtil.toDoubleOfNull(split[0]), TypeConversionUtil.toDoubleOfNull(split[1])); TypeConversionUtil.toDoubleOfNull(split[0]), TypeConversionUtil.toDoubleOfNull(split[1]));
if (gps != null) { if (gps != null) {
@@ -89,7 +109,8 @@ public class XjAedServiceImpl extends ServiceImpl<XjAedMapper, XjAed> implements
xjAedList.removeIf(item -> { xjAedList.removeIf(item -> {
String address = item.getAddress(); String address = item.getAddress();
return address == null || address.isEmpty() || "/".equals(address) || "".equals(address);}); return address == null || address.isEmpty() || "/".equals(address) || "".equals(address);});
this.saveBatch(xjAedList); System.out.println(1);
// this.saveBatch(xjAedList);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();