|
@@ -1,6 +1,7 @@
|
|
|
package cn.start.tz.module.pressure2.controller.admin.equipboiler;
|
|
package cn.start.tz.module.pressure2.controller.admin.equipboiler;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
@@ -117,8 +118,29 @@ public class EquipBoilerController {
|
|
|
@Operation(summary = "导入锅炉受压元件 Excel")
|
|
@Operation(summary = "导入锅炉受压元件 Excel")
|
|
|
@ApiAccessLog(operateType = IMPORT)
|
|
@ApiAccessLog(operateType = IMPORT)
|
|
|
public CommonResult<List<EquipBoilerPressurePartExportVO>> importPressureParts(@RequestParam("file") MultipartFile file) throws IOException {
|
|
public CommonResult<List<EquipBoilerPressurePartExportVO>> importPressureParts(@RequestParam("file") MultipartFile file) throws IOException {
|
|
|
- List<EquipBoilerPressurePartExportVO> list = ExcelUtils.read(file, EquipBoilerPressurePartExportVO.class);
|
|
|
|
|
- return success(list);
|
|
|
|
|
|
|
+ log.info("importPressureParts file: name={}, size={}", file.getOriginalFilename(), file.getSize());
|
|
|
|
|
+ // 先用 raw map 读取看看原始单元格内容
|
|
|
|
|
+ List<Map<Integer, String>> rawList = EasyExcel.read(file.getInputStream())
|
|
|
|
|
+ .sheet(0).headRowNumber(0).doReadSync();
|
|
|
|
|
+ log.info("importPressureParts raw parsed {} rows", rawList != null ? rawList.size() : 0);
|
|
|
|
|
+ if (rawList != null && !rawList.isEmpty()) {
|
|
|
|
|
+ // 映射 raw 到 export
|
|
|
|
|
+ List<EquipBoilerPressurePartExportVO> exportList = new ArrayList<>();
|
|
|
|
|
+ for (Map<Integer, String> map : rawList) {
|
|
|
|
|
+ EquipBoilerPressurePartExportVO vo = new EquipBoilerPressurePartExportVO();
|
|
|
|
|
+ vo.setPartType(map.getOrDefault(0, ""));
|
|
|
|
|
+ vo.setPartName(map.getOrDefault(1, ""));
|
|
|
|
|
+ vo.setSpecification(map.getOrDefault(2, ""));
|
|
|
|
|
+ vo.setMaterial(map.getOrDefault(3, ""));
|
|
|
|
|
+ vo.setRemark(map.getOrDefault(4, ""));
|
|
|
|
|
+ exportList.add(vo);
|
|
|
|
|
+ log.info("importPressureParts raw->export: partType={}, partName={}, specification={}, material={}, remark={}",
|
|
|
|
|
+ vo.getPartType(), vo.getPartName(), vo.getSpecification(), vo.getMaterial(), vo.getRemark());
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("importPressureParts exportList: {}", exportList.size());
|
|
|
|
|
+ return success(exportList);
|
|
|
|
|
+ }
|
|
|
|
|
+ return success(Collections.emptyList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/pressure-parts/get-import-template")
|
|
@GetMapping("/pressure-parts/get-import-template")
|