|
@@ -11,33 +11,32 @@ import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
import com.ruoyi.project.apply.domain.TApplyLock;
|
|
|
import com.ruoyi.project.apply.service.ITApplyLockService;
|
|
|
-import com.ruoyi.project.pssr.domain.TPssrApprove;
|
|
|
-import com.ruoyi.project.pssr.domain.TPssrLock;
|
|
|
-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.TPssrLockMapper;
|
|
|
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.*;
|
|
|
|
|
|
/**
|
|
@@ -70,10 +69,94 @@ public class TPssrLockController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITApplyLockService tApplyLockService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService iSysDeptService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ISysUserService sysUserService;
|
|
|
private String forShort = "sksgfmzt";
|
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('pssr:lock: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<TPssrLock> list = new ArrayList<TPssrLock>();
|
|
|
+ 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.getLastCellNum();
|
|
|
+ TPssrLock entity = new TPssrLock();
|
|
|
+ entity.setDeptId(sysUserService.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.setUnit(cellValue);
|
|
|
+ } else if (j == 1) {
|
|
|
+ entity.setLockPost(cellValue);
|
|
|
+ } else if (j == 2) {
|
|
|
+ entity.setPidNo(cellValue);
|
|
|
+ } else if (j == 3) {
|
|
|
+ entity.setLockCode(cellValue);
|
|
|
+ } else if (j == 4) {
|
|
|
+ entity.setMedium(cellValue);
|
|
|
+ } else if (j == 5) {
|
|
|
+ entity.setPosition(cellValue);
|
|
|
+ }else if (j == 6) {
|
|
|
+ entity.setRiskLevel(cellValue);
|
|
|
+ }else if (j == 7) {
|
|
|
+ entity.setLockSize(cellValue);
|
|
|
+ }else if (j == 8) {
|
|
|
+ entity.setPidStatus(cellValue);
|
|
|
+ }else if (j == 9) {
|
|
|
+ entity.setLockeder(cellValue);
|
|
|
+ }else if (j == 10) {
|
|
|
+ entity.setConfirm(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 (TPssrLock t : list
|
|
|
+ ) {
|
|
|
+ failNum++;
|
|
|
+ try {
|
|
|
+ tPssrLockService.insertTPssrLock(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));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询锁开锁关阀门状态列表
|
|
|
*/
|
|
@@ -173,8 +256,8 @@ public class TPssrLockController extends BaseController {
|
|
|
String confirm2 = sysUser2.getSignUrl();
|
|
|
ExcelUtils.insertPicture(wb, sheet, confirm1, row.getRowNum(), 15, 1, 1);
|
|
|
ExcelUtils.insertPicture(wb, sheet, confirm2, row.getRowNum(), 16, 1, 1);
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
}
|
|
|
row.createCell(17).setCellValue(DateUtils.dateTime(t.getConfirmationDate()));
|
|
|
row.createCell(18).setCellValue(t.getRemarks());
|