Ver Fonte

培训矩阵导入

jiangbiao há 1 ano atrás
pai
commit
536e10792d

+ 3 - 0
master/src/main/java/com/ruoyi/project/common/CommonController.java

@@ -312,6 +312,9 @@ public class CommonController extends BaseController
         }else if( type.equals("quality") ) {
             downloadname = "质量月报批量导入模板.xlsx";
             url = "static/template/production/quality.xlsx";
+        }else if( type.equals("trainingMatrix") ) {
+            downloadname = "培训矩阵导入模板.xlsx";
+            url = "static/template/training/trainingMatrix.xlsx";
         }
 
         InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(url);

+ 358 - 46
master/src/main/java/com/ruoyi/project/training/controller/TTrainingMatrixController.java

@@ -1,33 +1,37 @@
 package com.ruoyi.project.training.controller;
 
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
+import com.alibaba.fastjson.JSON;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.file.ExcelUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.framework.aspectj.lang.annotation.Log;
+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.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.TTrainingCompanylevel;
+import com.ruoyi.project.training.domain.TTrainingMatrix;
 import com.ruoyi.project.training.domain.TTrainingRegular;
 import com.ruoyi.project.training.service.ITTrainingCompanylevelService;
+import com.ruoyi.project.training.service.ITTrainingMatrixService;
 import com.ruoyi.project.training.service.ITTrainingRegularService;
-import org.springframework.security.access.prepost.PreAuthorize;
+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.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 com.ruoyi.framework.aspectj.lang.annotation.Log;
-import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
-import com.ruoyi.project.training.domain.TTrainingMatrix;
-import com.ruoyi.project.training.service.ITTrainingMatrixService;
-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.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
 
 /**
  * 培训矩阵Controller
@@ -37,30 +41,32 @@ import com.ruoyi.framework.web.page.TableDataInfo;
  */
 @RestController
 @RequestMapping("/training/matrix")
-public class TTrainingMatrixController extends BaseController
-{
+public class TTrainingMatrixController extends BaseController {
     @Autowired
     private ITTrainingMatrixService tTrainingMatrixService;
 
     @Autowired
     private ISysDictTypeService iSysDictTypeService;
+    @Autowired
+    private ISysDeptService iSysDeptService;
 
     @Autowired
     private ITTrainingRegularService tTrainingRegularService;
     @Autowired
     private ITTrainingCompanylevelService tTrainingCompanylevelService;
+
     /**
      * 查询培训矩阵列表
      */
     @PreAuthorize("@ss.hasPermi('training:matrix:list')")
     @GetMapping("/list")
-    public TableDataInfo list(TTrainingMatrix tTrainingMatrix)
-    {
+    public TableDataInfo list(TTrainingMatrix tTrainingMatrix) {
         startPage();
         List<TTrainingMatrix> list = tTrainingMatrixService.selectTTrainingMatrixList(tTrainingMatrix);
         List<SysDictData> actualpost = iSysDictTypeService.selectDictDataByType("ACTUALPOST");
         for (TTrainingMatrix t : list) {
-            String[] actualpostId = new String[0];;
+            String[] actualpostId = new String[0];
+            ;
             if (t.getActualpostId() != null) {
                 actualpostId = t.getActualpostId().split(",");
             }
@@ -82,9 +88,9 @@ public class TTrainingMatrixController extends BaseController
                 }
                 if (i == 1) {
                     postStatu.add("M");
-                }else if (i == 2) {
+                } else if (i == 2) {
                     postStatu.add("|");
-                }else {
+                } else {
                     postStatu.add("-");
                 }
             }
@@ -93,13 +99,13 @@ public class TTrainingMatrixController extends BaseController
                     String[] designatedOther = t.getDesignatedOther().split(",");
                     for (String d : designatedOther) {
                         if (d.equals("28")) {
-                            postStatu.set(postStatu.size() - 3, "(M)");
+                            postStatu.set(postStatu.size() - 5, "(M)");
                         }
                         if (d.equals("30")) {
-                            postStatu.set(postStatu.size() - 2, "(M)");
+                            postStatu.set(postStatu.size() - 4, "(M)");
                         }
                         if (d.equals("32")) {
-                            postStatu.set(postStatu.size() - 1, "(M)");
+                            postStatu.set(postStatu.size() - 3, "(M)");
                         }
                     }
                 }
@@ -115,8 +121,7 @@ public class TTrainingMatrixController extends BaseController
     @PreAuthorize("@ss.hasPermi('training:matrix:export')")
     @Log(title = "培训矩阵", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
-    public AjaxResult export(TTrainingMatrix tTrainingMatrix)
-    {
+    public AjaxResult export(TTrainingMatrix tTrainingMatrix) {
         List<TTrainingMatrix> list = tTrainingMatrixService.selectTTrainingMatrixList(tTrainingMatrix);
         ExcelUtil<TTrainingMatrix> util = new ExcelUtil<TTrainingMatrix>(TTrainingMatrix.class);
         return util.exportExcel(list, "matrix");
@@ -127,8 +132,7 @@ public class TTrainingMatrixController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('training:matrix:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return AjaxResult.success(tTrainingMatrixService.selectTTrainingMatrixById(id));
     }
 
@@ -138,8 +142,7 @@ public class TTrainingMatrixController extends BaseController
     @PreAuthorize("@ss.hasPermi('training:matrix:add')")
     @Log(title = "培训矩阵", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TTrainingMatrix tTrainingMatrix)
-    {
+    public AjaxResult add(@RequestBody TTrainingMatrix tTrainingMatrix) {
         return toAjax(tTrainingMatrixService.insertTTrainingMatrix(tTrainingMatrix));
     }
 
@@ -149,8 +152,7 @@ public class TTrainingMatrixController extends BaseController
     @PreAuthorize("@ss.hasPermi('training:matrix:add')")
     @Log(title = "批量添加装置培训", businessType = BusinessType.INSERT)
     @GetMapping("batchAddTraining/{ids}")
-    public AjaxResult batchAddTraining(@PathVariable Long[] ids)
-    {
+    public AjaxResult batchAddTraining(@PathVariable Long[] ids) {
         for (int i = 0; i < ids.length; i++) {
             TTrainingMatrix tm = tTrainingMatrixService.selectTTrainingMatrixById(ids[i]);
             TTrainingRegular tr = new TTrainingRegular();
@@ -174,8 +176,7 @@ public class TTrainingMatrixController extends BaseController
     @PreAuthorize("@ss.hasPermi('training:matrix:add')")
     @Log(title = "批量添加公司培训", businessType = BusinessType.INSERT)
     @GetMapping("batchAddCompany/{ids}")
-    public AjaxResult batchAddCompany(@PathVariable Long[] ids)
-    {
+    public AjaxResult batchAddCompany(@PathVariable Long[] ids) {
         for (int i = 0; i < ids.length; i++) {
             TTrainingMatrix tm = tTrainingMatrixService.selectTTrainingMatrixById(ids[i]);
             TTrainingCompanylevel tr = new TTrainingCompanylevel();
@@ -195,8 +196,7 @@ public class TTrainingMatrixController extends BaseController
     @PreAuthorize("@ss.hasPermi('training:matrix:edit')")
     @Log(title = "培训矩阵", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody TTrainingMatrix tTrainingMatrix)
-    {
+    public AjaxResult edit(@RequestBody TTrainingMatrix tTrainingMatrix) {
         return toAjax(tTrainingMatrixService.updateTTrainingMatrix(tTrainingMatrix));
     }
 
@@ -205,9 +205,321 @@ public class TTrainingMatrixController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('training:matrix:remove')")
     @Log(title = "培训矩阵", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(tTrainingMatrixService.deleteTTrainingMatrixByIds(ids));
     }
+
+    @PreAuthorize("@ss.hasPermi('training:byxWorklicense:add')")
+    @Log(title = "培训矩阵", businessType = BusinessType.INSERT)
+    @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<TTrainingMatrix> list = new ArrayList<>();
+        //字典查询
+        List<SysDictData> levels = iSysDictTypeService.selectDictDataByType("TRAINING_LEVEL");
+        List<SysDictData> responsDepts = iSysDictTypeService.selectDictDataByType("RESPONS_DEPT");
+        List<SysDictData> actualposts = iSysDictTypeService.selectDictDataByType("ACTUALPOST");
+        //部门查询
+        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();
+                TTrainingMatrix entity = new TTrainingMatrix();
+                StringBuilder actualpostId = new StringBuilder();
+                StringBuilder designatedPosition = new StringBuilder();
+                StringBuilder designatedOther = new StringBuilder();
+                for (int j = 0; j < cellNum; j++) {
+                    Cell cell = row.getCell(j);
+                    String cellValue = ExcelUtils.getCellValue(cell);
+                    logger.info("cellValue:" + cellValue);
+                    if (j == 0) {
+                        for (SysDictData level : levels) {
+                            if (level.getDictLabel().equals(cellValue.trim())) {
+                                entity.setTrainingLevel(level.getDictValue());//培训级别
+                            }
+                        }
+                    } else if (j == 1) {
+                        entity.setItem(cellValue);
+                    } else if (j == 2) {
+                        entity.setCourseCode(cellValue);
+                    } else if (j == 3) {
+                        entity.setFrequency(cellValue);
+                    } else if (j == 4) {
+                        for (SysDictData responsDept : responsDepts) {
+                            if (responsDept.getDictLabel().equals(cellValue.trim())) {
+                                entity.setResponsDept(responsDept.getDictValue());
+                            }
+                        }
+                    } else if (j == 5) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals(cellValue.trim())) {
+                                entity.setLecturer(actualpost.getDictValue());
+                            }
+                        }
+                    } else if (j == 6) {
+                        entity.setHour(cellValue);
+                    } else if (j == 7) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("装置经理")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 8) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("装置副经理")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 9) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("资深工程师")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 10) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("生产主管")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 11) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("片区工长")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 12) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("职员")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 13) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("EHS督导")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 14) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("倒班班长")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 15) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("倒班副班长")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 16) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("主操")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 17) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("副操")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 18) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("主操(白班)")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 19) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("机械维修人员")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 20) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("电仪维修人员")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 21) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("实验室人员")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 22) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("见习生")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 23) {
+                        for (SysDictData actualpost : actualposts) {
+                            if (actualpost.getDictLabel().equals("工程师")) {
+                                if ("M".equals(cellValue) || "X".equals(cellValue) || "m".equals(cellValue) || "x".equals(cellValue)) {
+                                    actualpostId.append(actualpost.getDictValue()).append(",");
+                                } else if ("(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)||"(M)".equals(cellValue) || "(X)".equals(cellValue) || "(m)".equals(cellValue) || "(x)".equals(cellValue)) {
+                                    designatedOther.append(actualpost.getDictValue()).append(",");
+                                } else if ("I".equals(cellValue) || "i".equals(cellValue)) {
+                                    designatedPosition.append(actualpost.getDictValue()).append(",");
+                                }
+                            }
+                        }
+                    } else if (j == 24) {
+                        entity.setRemarks(cellValue);
+                    } else if (j == 25) {
+                        for (SysDept d : dept) {
+                            if (d.getDeptName().equals(cellValue.trim())) {
+                                entity.setDeptId(d.getDeptId());//部门编号
+                            }
+                        }
+                    }
+                }
+                entity.setCreaterCode(userId.toString());
+                if (StringUtils.isNotEmpty(actualpostId)) {
+                    entity.setActualpostId(actualpostId.substring(0, actualpostId.lastIndexOf(",")));
+                }
+                if (StringUtils.isNotEmpty(designatedOther)) {
+                    entity.setInvolvedMoc("true");
+                    entity.setDesignatedOther(designatedOther.substring(0, designatedOther.lastIndexOf(",")));
+                } else {
+                    entity.setInvolvedMoc("false");
+                }
+                if (StringUtils.isNotEmpty(designatedPosition)) {
+                    entity.setDesignatedPosition(designatedPosition.substring(0, designatedPosition.lastIndexOf(",")));
+                }
+                logger.info("entity:" + entity);
+                list.add(entity);
+            } catch (Exception e) {
+                failNumber++;
+                failRow.add(i + 1);
+            }
+        }
+        int successNumber = 0;
+        int failNum = 0;
+        for (TTrainingMatrix t : list
+        ) {
+            failNum++;
+            try {
+                tTrainingMatrixService.insertTTrainingMatrix(t);
+                successNumber++;
+            } catch (Exception e) {
+                failNumber++;
+                failRow.add(failNum + 1);
+                e.printStackTrace();
+            }
+        }
+        logger.info("list:" + JSON.toJSONString(list));
+        logger.info("successNumber:" + successNumber);
+        logger.info("failNumber:" + failNumber);
+        logger.info("failRow:" + failRow);
+        return AjaxResult.success(String.valueOf(successNumber), failRow);
+    }
 }

BIN
master/src/main/resources/static/template/training/trainingMatrix.xlsx


+ 17 - 9
ui/src/views/training/matrix/index.vue

@@ -260,9 +260,12 @@
                   <em>{{ $t('点击上传') }}</em>
               </div>
               <div class="el-upload__tip" slot="tip">
-                  <el-checkbox v-model="upload.updateSupport" />{{ $t('是否更新已经存在的用户数据') }}
+<!--                  <el-checkbox v-model="upload.updateSupport" />{{ $t('是否更新已经存在的用户数据') }}-->
                   <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
               </div>
+              <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
+                  <input name="type" :value="upload.type" hidden />
+              </form>
               <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“xls”或“xlsx”格式文件!')}}</div>
           </el-upload>
           <div slot="footer" class="dialog-footer">
@@ -337,6 +340,9 @@ export default {
       },
       // 用户导入参数
       upload: {
+          downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
+          //下载模板类型
+          type: "trainingMatrix",
           // 是否显示弹出层(用户导入)
           open: false,
           // 弹出层标题(用户导入)
@@ -677,9 +683,7 @@ export default {
       },
       /** 下载模板操作 */
       importTemplate() {
-          importTemplate().then(response => {
-              this.download(response.msg);
-          });
+          this.$refs['downloadFileForm'].submit()
       },
       // 文件上传中处理
       handleFileUploadProgress(event, file, fileList) {
@@ -687,11 +691,15 @@ export default {
       },
       // 文件上传成功处理
       handleFileSuccess(response, file, fileList) {
-          this.upload.open = false;
-          this.upload.isUploading = false;
-          this.$refs.upload.clearFiles();
-          this.$alert(response.msg, this.$t('导入结果'), { dangerouslyUseHTMLString: true });
-          this.getList();
+        this.upload.open = false;
+        this.upload.isUploading = false;
+        this.$refs.upload.clearFiles();
+        if (response.data[0] != null) {
+          this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败')+"。", this.$t('导入结果'), { dangerouslyUseHTMLString: true });
+        }else {
+          this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), { dangerouslyUseHTMLString: true });
+        }
+        this.getList();
       },
       // 提交上传文件
       submitFileForm() {