ly 1 mese fa
parent
commit
1724170b54

+ 6 - 25
master/src/main/java/com/ruoyi/common/utils/file/ExcelUtils.java

@@ -119,34 +119,15 @@ public class ExcelUtils {
                 cellValue = cell.toString();
                 break;
         }
-        //判断数据的类型
-//        switch (cell.getCellType()) {
-//            case Cell.CELL_TYPE_NUMERIC: //数字
-//                cellValue = stringDateProcess(cell);
-//                break;
-//            case Cell.CELL_TYPE_STRING: //字符串
-//                cellValue = String.valueOf(cell.getStringCellValue());
-//                break;
-//            case Cell.CELL_TYPE_BOOLEAN: //Boolean
-//                cellValue = String.valueOf(cell.getBooleanCellValue());
-//                break;
-//            case Cell.CELL_TYPE_FORMULA: //公式
-//                cellValue = String.valueOf(cell.getCellFormula());
-//                break;
-//            case Cell.CELL_TYPE_BLANK: //空值
-//                cellValue = "";
-//                break;
-//            case Cell.CELL_TYPE_ERROR: //故障
-//                cellValue = "非法字符";
-//                break;
-//            default:
-//                cellValue = "未知类型";
-//                break;
-//        }
-//        cellValue = String.valueOf(cell.getStringCellValue());
         return cellValue;
     }
 
+    public static String getCellValueText(Cell cell) {
+        if (cell == null) return "";
+        DataFormatter formatter = new DataFormatter();
+        return formatter.formatCellValue(cell); // 返回视觉显示的文本
+    }
+
     /**
      * 时间格式处理
      *

+ 3 - 1
master/src/main/java/com/ruoyi/project/training/controller/TTrainingHisparticipantsController.java

@@ -158,6 +158,8 @@ public class TTrainingHisparticipantsController extends BaseController {
                         entity.setRemark(String.valueOf(finalI +1));
                         if (j == 0) {
                             entity.setStaffId(cellValue.trim());
+                        }if (j == 1) {
+                            entity.setDeptName(cellValue);
                         } else if (j == 5) {
                             if (cellValue.length() > 3) {
                                 entity.setStartDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
@@ -170,7 +172,7 @@ public class TTrainingHisparticipantsController extends BaseController {
                             entity.setCourseCode(cellValue.trim());
                             for (TTrainingCompanylevel t : levelList
                             ) {
-                                if (t.getCourseCode().equals(cellValue.trim())) {
+                                if (t.getCourseCode().equals(cellValue.trim()) && t.getDeptName().equals(entity.getDeptName())) {
                                     entity.setCompanyId(t.getId());
                                 }
                             }

+ 11 - 0
master/src/main/java/com/ruoyi/project/training/domain/TTrainingHisparticipants.java

@@ -95,6 +95,9 @@ public class TTrainingHisparticipants extends BaseEntity
     @Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date updatedate;
 
+    /** 部门名称 */
+    private String deptName;
+
     public void setId(Long id)
     {
         this.id = id;
@@ -263,6 +266,14 @@ public class TTrainingHisparticipants extends BaseEntity
         this.item = item;
     }
 
+    public String getDeptName() {
+        return deptName;
+    }
+
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

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