|
@@ -1,17 +1,19 @@
|
|
|
package com.ruoyi.project.sems.controller;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.ruoyi.common.utils.file.ExcelUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
|
|
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
|
|
import com.ruoyi.project.sems.domain.TReportYlrq;
|
|
@@ -20,6 +22,7 @@ import com.ruoyi.framework.web.controller.BaseController;
|
|
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
/**
|
|
|
* 压力容器年检报告Controller
|
|
@@ -68,6 +71,173 @@ public class TReportYlrqController extends BaseController {
|
|
|
return util.exportExcel(list, "reportYlrq");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量导入
|
|
|
+ */
|
|
|
+ @Log(title = "压力容器批量导入更新", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/importForUpdate")
|
|
|
+ public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException {
|
|
|
+ //获取操作人员ID
|
|
|
+ Long userId = getUserId();
|
|
|
+ //报错行数统计
|
|
|
+ List<Integer> failRow = new ArrayList<Integer>();
|
|
|
+ Workbook workbook = ExcelUtils.getWorkBook(file);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ List<TReportYlrq> list = new ArrayList<>();
|
|
|
+
|
|
|
+ int rowNum = sheet.getPhysicalNumberOfRows();
|
|
|
+ int failNumber = 0;
|
|
|
+ for (int i = 2; i < rowNum; i++) {
|
|
|
+ try {
|
|
|
+ logger.info("读取行数:" + i);
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ int cellNum = row.getPhysicalNumberOfCells();
|
|
|
+ TReportYlrq entity = new TReportYlrq();
|
|
|
+ for (int j = 0; j < cellNum; j++) {
|
|
|
+ Cell cell = row.getCell(j);
|
|
|
+ if (cell == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String cellValue = ExcelUtils.getCellValue(cell);
|
|
|
+ logger.info("cellValue:" + cellValue);
|
|
|
+ if (j == 0) {
|
|
|
+ //使用证
|
|
|
+ entity.setUseno(cellValue);
|
|
|
+ } else if (j == 1) {
|
|
|
+ //注册编号
|
|
|
+ entity.setRegno(cellValue);
|
|
|
+ } else if (j == 2) {
|
|
|
+ //位号
|
|
|
+ entity.setDevno(cellValue);
|
|
|
+ } else if (j == 3) {
|
|
|
+ //位号
|
|
|
+ entity.setPj1(cellValue);
|
|
|
+ } else if (j == 4) {
|
|
|
+ //位号
|
|
|
+ entity.setPj2(cellValue);
|
|
|
+ } else if (j == 5) {
|
|
|
+ //位号
|
|
|
+ entity.setPj3(cellValue);
|
|
|
+ } else if (j == 6) {
|
|
|
+ //位号
|
|
|
+ entity.setPj4(cellValue);
|
|
|
+ } else if (j == 7) {
|
|
|
+ //位号
|
|
|
+ entity.setPj5(cellValue);
|
|
|
+ } else if (j == 8) {
|
|
|
+ //位号
|
|
|
+ entity.setPj6(cellValue);
|
|
|
+ } else if (j == 9) {
|
|
|
+ //位号
|
|
|
+ entity.setPj7(cellValue);
|
|
|
+ } else if (j == 10) {
|
|
|
+ //位号
|
|
|
+ entity.setPj8(cellValue);
|
|
|
+ } else if (j == 11) {
|
|
|
+ //位号
|
|
|
+ entity.setPj9(cellValue);
|
|
|
+ } else if (j == 12) {
|
|
|
+ //位号
|
|
|
+ entity.setPj10(cellValue);
|
|
|
+ } else if (j == 13) {
|
|
|
+ //位号
|
|
|
+ entity.setPj11(cellValue);
|
|
|
+ } else if (j == 14) {
|
|
|
+ //位号
|
|
|
+ entity.setPj12(cellValue);
|
|
|
+ } else if (j == 15) {
|
|
|
+ //位号
|
|
|
+ entity.setPj13(cellValue);
|
|
|
+ } else if (j == 16) {
|
|
|
+ //位号
|
|
|
+ entity.setPj14(cellValue);
|
|
|
+ } else if (j == 17) {
|
|
|
+ //位号
|
|
|
+ entity.setPj15(cellValue);
|
|
|
+ } else if (j == 18) {
|
|
|
+ //位号
|
|
|
+ entity.setPj16(cellValue);
|
|
|
+ } else if (j == 19) {
|
|
|
+ //位号
|
|
|
+ entity.setPj17(cellValue);
|
|
|
+ } else if (j == 20) {
|
|
|
+ //位号
|
|
|
+ entity.setPj18(cellValue);
|
|
|
+ } else if (j == 21) {
|
|
|
+ //位号
|
|
|
+ entity.setPj19(cellValue);
|
|
|
+ } else if (j == 22) {
|
|
|
+ //位号
|
|
|
+ entity.setPj20(cellValue);
|
|
|
+ } else if (j == 23) {
|
|
|
+ //位号
|
|
|
+ entity.setPj21(cellValue);
|
|
|
+ } else if (j == 24) {
|
|
|
+ //位号
|
|
|
+ entity.setPj22(cellValue);
|
|
|
+ } else if (j == 25) {
|
|
|
+ //位号
|
|
|
+ entity.setPj23(cellValue);
|
|
|
+ } else if (j == 26) {
|
|
|
+ //位号
|
|
|
+ entity.setPj24(cellValue);
|
|
|
+ } else if (j == 27) {
|
|
|
+ //位号
|
|
|
+ entity.setPj25(cellValue);
|
|
|
+ } else if (j == 28) {
|
|
|
+ //位号
|
|
|
+ entity.setPj26(cellValue);
|
|
|
+ } else if (j == 29) {
|
|
|
+ //位号
|
|
|
+ entity.setPj27(cellValue);
|
|
|
+ } else if (j == 30) {
|
|
|
+ //位号
|
|
|
+ entity.setPj28(cellValue);
|
|
|
+ } else if (j == 31) {
|
|
|
+ //位号
|
|
|
+ entity.setPj29(cellValue);
|
|
|
+ } else if (j == 32) {
|
|
|
+ //位号
|
|
|
+ entity.setPj30(cellValue);
|
|
|
+ } else if (j == 33) {
|
|
|
+ //位号
|
|
|
+ entity.setPj31(cellValue);
|
|
|
+ } else if (j == 34) {
|
|
|
+ //位号
|
|
|
+ entity.setPj32(cellValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ entity.setCreaterCode(userId);
|
|
|
+ logger.info("entity:" + entity);
|
|
|
+ list.add(entity);
|
|
|
+ } catch (Exception e) {
|
|
|
+ failNumber++;
|
|
|
+ logger.info("e:" + JSON.toJSONString(e));
|
|
|
+ failRow.add(i + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int successNumber = 0;
|
|
|
+ int failNum = 0;
|
|
|
+ for (TReportYlrq t : list
|
|
|
+ ) {
|
|
|
+ failNum++;
|
|
|
+ try {
|
|
|
+ //TODO 根据使用证、注册编号、位号,进行数据更新
|
|
|
+ this.tReportYlrqService.updateForImport(t);
|
|
|
+ successNumber++;
|
|
|
+ } catch (Exception e) {
|
|
|
+ failNumber++;
|
|
|
+ logger.info("e:" + e);
|
|
|
+ failRow.add(failNum + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("list:" + JSON.toJSONString(list));
|
|
|
+ logger.info("successNumber:" + String.valueOf(successNumber));
|
|
|
+ logger.info("failNumber:" + String.valueOf(failNumber));
|
|
|
+ logger.info("failRow:" + String.valueOf(failRow));
|
|
|
+ return AjaxResult.success(String.valueOf(successNumber), failRow);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取压力容器年检报告详细信息
|
|
|
*/
|