|
@@ -1,5 +1,6 @@
|
|
|
package com.ruoyi.project.pssr.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.file.ExcelUtils;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
@@ -8,33 +9,32 @@ import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
|
|
import com.ruoyi.framework.web.controller.BaseController;
|
|
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
-import com.ruoyi.project.pssr.domain.TPssrApprove;
|
|
|
-import com.ruoyi.project.pssr.domain.TPssrFrame;
|
|
|
-import com.ruoyi.project.pssr.domain.TPssrSubcontent;
|
|
|
-import com.ruoyi.project.pssr.domain.TPssrTurndown;
|
|
|
+import com.ruoyi.project.pssr.domain.*;
|
|
|
import com.ruoyi.project.pssr.mapper.TPssrFrameMapper;
|
|
|
import com.ruoyi.project.pssr.service.*;
|
|
|
+import com.ruoyi.project.system.domain.SysDept;
|
|
|
import com.ruoyi.project.system.domain.SysUser;
|
|
|
+import com.ruoyi.project.system.service.ISysDeptService;
|
|
|
import com.ruoyi.project.system.service.ISysUserService;
|
|
|
import org.activiti.engine.ProcessEngine;
|
|
|
import org.activiti.engine.ProcessEngines;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
import org.activiti.engine.task.Task;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
-import org.apache.poi.ss.usermodel.Cell;
|
|
|
-import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
-import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -65,6 +65,121 @@ public class TPssrFrameController extends BaseController {
|
|
|
private ISysUserService sysUserService;
|
|
|
private String forShort = "zdj";
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService iSysDeptService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量导入
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('pssr:frame:add')")
|
|
|
+ @PostMapping("/importData")
|
|
|
+ public AjaxResult importInterlockData(MultipartFile file, Long subId) throws IOException
|
|
|
+ {
|
|
|
+ //获取操作人员ID
|
|
|
+ Long userId = getUserId();
|
|
|
+ //报错行数统计
|
|
|
+ List<Integer> failRow =new ArrayList<Integer>();
|
|
|
+ Workbook workbook = ExcelUtils.getWorkBook(file);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ List<TPssrFrame> list = new ArrayList<TPssrFrame>();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ //部门查询
|
|
|
+ List<SysDept> dept = iSysDeptService.selectDeptList(new SysDept());
|
|
|
+ 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();
|
|
|
+ TPssrFrame entity = new TPssrFrame();
|
|
|
+ entity.setDeptId(userService.selectUserById(getUserId()).getDeptId());
|
|
|
+ entity.setSubId(subId);
|
|
|
+ entity.setApproveStatus(0L);
|
|
|
+ for (int j = 0; j < cellNum; j++) {
|
|
|
+ Cell cell = row.getCell(j);
|
|
|
+ String cellValue = ExcelUtils.getCellValue(cell);
|
|
|
+ logger.info("cellValue:" + cellValue);
|
|
|
+ if (j == 0) {
|
|
|
+ entity.setRegion(cellValue);
|
|
|
+ } else if (j == 1) {
|
|
|
+ entity.setBracketNumber(cellValue);
|
|
|
+ } else if (j == 2) {
|
|
|
+ entity.setPipelineNumber(cellValue);
|
|
|
+ } else if (j == 3) {
|
|
|
+ entity.setDevNo(cellValue);
|
|
|
+ } else if (j == 4) {
|
|
|
+ entity.setSupportType(cellValue);
|
|
|
+ } else if (j == 5) {
|
|
|
+ entity.setFramePipe1(cellValue);
|
|
|
+ } else if (j == 6) {
|
|
|
+ entity.setFramePipe2(cellValue);
|
|
|
+ } else if (j == 7) {
|
|
|
+ entity.setFrameRoot1(cellValue);
|
|
|
+ } else if (j == 8) {
|
|
|
+ entity.setFrameRoot2(cellValue);
|
|
|
+ } else if (j == 9) {
|
|
|
+ entity.setFrameRoot3(cellValue);
|
|
|
+ } else if (j == 10) {
|
|
|
+ entity.setFrameRoot4(cellValue);
|
|
|
+ } else if (j == 11) {
|
|
|
+ entity.setFunctionalPart1(cellValue);
|
|
|
+ } else if (j == 12) {
|
|
|
+ entity.setFunctionalPart2(cellValue);
|
|
|
+ } else if (j == 13) {
|
|
|
+ entity.setFunctionalPart3(cellValue);
|
|
|
+ } else if (j == 14) {
|
|
|
+ entity.setFunctionalPart4(cellValue);
|
|
|
+ } else if (j == 15) {
|
|
|
+ entity.setConnector1(cellValue);
|
|
|
+ } else if (j == 16) {
|
|
|
+ entity.setConnector2(cellValue);
|
|
|
+ } else if (j == 17) {
|
|
|
+ entity.setConnector3(cellValue);
|
|
|
+ } else if (j == 18) {
|
|
|
+ entity.setConnector4(cellValue);
|
|
|
+ } else if (j == 19) {
|
|
|
+ entity.setProcessingResult(cellValue);
|
|
|
+ } else if (j == 20) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setConfirmationDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 21) {
|
|
|
+ entity.setRemarks(cellValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ entity.setCreaterCode(userId.toString());
|
|
|
+ logger.info("entity:" + entity);
|
|
|
+ list.add(entity);
|
|
|
+ }catch (Exception e){
|
|
|
+ failNumber++;
|
|
|
+ failRow.add(i+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int successNumber = 0;
|
|
|
+ int failNum = 0;
|
|
|
+ for (TPssrFrame t : list
|
|
|
+ ) {
|
|
|
+ failNum++;
|
|
|
+ try {
|
|
|
+ this.add(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));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询支(吊)架列表
|
|
|
*/
|