|
@@ -1,22 +1,28 @@
|
|
|
package com.ruoyi.project.training.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.DateUtils;
|
|
|
+import com.ruoyi.common.utils.file.ExcelUtils;
|
|
|
import com.ruoyi.project.plant.domain.TStaffmgr;
|
|
|
import com.ruoyi.project.plant.service.ITStaffmgrService;
|
|
|
+import com.ruoyi.project.system.domain.SysDept;
|
|
|
import com.ruoyi.project.system.domain.SysDictData;
|
|
|
+import com.ruoyi.project.system.service.ISysDeptService;
|
|
|
import com.ruoyi.project.system.service.ISysDictTypeService;
|
|
|
+import com.ruoyi.project.training.domain.TByxWorklicense;
|
|
|
+import com.ruoyi.project.training.mapper.TWorklicenseCertificateMapper;
|
|
|
+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.training.domain.TWorklicenseCertificate;
|
|
@@ -25,6 +31,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
|
|
@@ -39,12 +46,228 @@ public class TWorklicenseCertificateController extends BaseController
|
|
|
@Autowired
|
|
|
private ITWorklicenseCertificateService tWorklicenseCertificateService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TWorklicenseCertificateMapper tWorklicenseCertificateMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ITStaffmgrService staffmgrService;
|
|
|
|
|
|
@Autowired
|
|
|
private ISysDictTypeService iSysDictTypeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService iSysDeptService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量导入上岗证一览
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('training:worklicensecertificate:add')")
|
|
|
+ @PostMapping("/importData")
|
|
|
+ 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<TWorklicenseCertificate> list = new ArrayList<TWorklicenseCertificate>();
|
|
|
+ //字典查询
|
|
|
+ List<SysDictData> plant = iSysDictTypeService.selectDictDataByType("PLANT_DIVIDE");
|
|
|
+ List<SysDictData> classes = iSysDictTypeService.selectDictDataByType("CLASSES");
|
|
|
+ List<SysDictData> yesno = iSysDictTypeService.selectDictDataByType("YES_NO_EN");
|
|
|
+ //部门查询
|
|
|
+ List<SysDept> dept = iSysDeptService.selectDeptList(new SysDept());
|
|
|
+ int rowNum = sheet.getPhysicalNumberOfRows();
|
|
|
+ int failNumber = 0;
|
|
|
+ for (int i = 1; i < rowNum; i++) {
|
|
|
+ try {
|
|
|
+ logger.info("读取行数:" + i);
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ int cellNum = row.getLastCellNum();
|
|
|
+ TWorklicenseCertificate entity = new TWorklicenseCertificate();
|
|
|
+ for (int j = 0; j < cellNum; j++) {
|
|
|
+ Cell cell = row.getCell(j);
|
|
|
+ // cell.setCellType(CellType.STRING);
|
|
|
+ String cellValue = ExcelUtils.getCellValue(cell);
|
|
|
+ logger.info("cellValue:" + cellValue);
|
|
|
+ if (j == 0) {
|
|
|
+ entity.setName(cellValue);//姓名
|
|
|
+ } else if (j == 1) {
|
|
|
+ entity.setEmployeeid(cellValue);//员工号
|
|
|
+ Long id = tWorklicenseCertificateMapper.selectTWorklicenseCertificateByEmployeeid(Long.parseLong(cellValue)).getId();
|
|
|
+ if (id == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ entity.setId(id);
|
|
|
+ } else if (j == 2) {
|
|
|
+ entity.setIdnum(cellValue);//身份证件号
|
|
|
+ } else if (j == 3) {
|
|
|
+ entity.setClasses(cellValue);//班组
|
|
|
+ } else if (j == 4) {
|
|
|
+ entity.setPost(cellValue);//职务
|
|
|
+ } else if (j == 5) {
|
|
|
+ entity.setIdtype(cellValue);//证件类型
|
|
|
+ } else if (j == 6) {
|
|
|
+ entity.setCertificateNo(cellValue);//证件号
|
|
|
+ } else if (j == 7) {
|
|
|
+ for (SysDictData p : yesno) {
|
|
|
+ if (p.getDictLabel().equals(cellValue.trim())) {
|
|
|
+ entity.setBoiler(p.getDictValue());//开工锅炉
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (j == 8) {
|
|
|
+ for (SysDictData p : yesno) {
|
|
|
+ if (p.getDictLabel().equals(cellValue.trim())) {
|
|
|
+ entity.setCracking(p.getDictValue());//裂解
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (j == 9) {
|
|
|
+ for (SysDictData p : yesno) {
|
|
|
+ if (p.getDictLabel().equals(cellValue.trim())) {
|
|
|
+ entity.setHotarea(p.getDictValue());//热区
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (j == 10) {
|
|
|
+ for (SysDictData p : yesno) {
|
|
|
+ if (p.getDictLabel().equals(cellValue.trim())) {
|
|
|
+ entity.setColdarea(p.getDictValue());//冷区
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (j == 11) {
|
|
|
+ for (SysDictData p : yesno) {
|
|
|
+ if (p.getDictLabel().equals(cellValue.trim())) {
|
|
|
+ entity.setAromatic(p.getDictValue());//芳烃
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (j == 12) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setRecertificatedate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));//取复证日期
|
|
|
+ }
|
|
|
+ } else if (j == 13) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setValidity(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));//证书有效期
|
|
|
+ }
|
|
|
+ } else if (j == 14) {
|
|
|
+ entity.setContainer(cellValue);//压力容器
|
|
|
+ } else if (j == 15) {
|
|
|
+ entity.setPipe(cellValue);//压力管道
|
|
|
+ } else if (j == 16) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setReviewdate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 17) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setValidity(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 18) {
|
|
|
+ entity.setCertificateNo(cellValue);
|
|
|
+ } else if (j == 19) {
|
|
|
+ entity.setBoilerid(cellValue);//锅炉证
|
|
|
+ } else if (j == 20) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setBoilvalidity(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 21) {
|
|
|
+ entity.setHydrogenation(cellValue);//加氢工艺
|
|
|
+ } else if (j == 22) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setHydvalidity(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 23) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setHydnextreview(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ }else if (j == 24) {
|
|
|
+ entity.setCrackingid(cellValue);//裂化工艺
|
|
|
+ } else if (j == 25) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setCrackingvalidity(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 26) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setCrackingreview(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ }else if (j == 27) {
|
|
|
+ entity.setRefrigeration(cellValue);//制冷与空调作业
|
|
|
+ } else if (j == 28) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setRefrigerationvalidity(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 29) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setRefrigerationview(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 30) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setForemantrain(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 31) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setForemanreview(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 32) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setForemannextreview(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 33) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setFireProtection(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 34) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setWaterdate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 35) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setWatervalidity(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 36) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setWaterreview(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 37) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setEnergydate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 38) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setEnergyvalidity(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 39) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setEnergyreview(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(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 (TWorklicenseCertificate t : list
|
|
|
+ ) {
|
|
|
+ failNum++;
|
|
|
+ try {
|
|
|
+ tWorklicenseCertificateService.updateTWorklicenseCertificate(t);
|
|
|
+ successNumber++;
|
|
|
+ }catch (Exception e){
|
|
|
+ failNumber++;
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 同步人员数据
|
|
|
*/
|