Просмотр исходного кода

导出卡类型转换及无定向时保存异常

mingfu 1 месяц назад
Родитель
Сommit
6e158ff404

+ 1 - 1
ie-admin/src/main/java/com/ruoyi/web/domain/DzCardExport.java

@@ -33,7 +33,7 @@ public class DzCardExport {
     private String campusName;
     @Excel(name = "培训班级")
     private String campusClassName;
-    @Excel(name = "考生类型(注册)")
+    @Excel(name = "考生类型(注册)", readConverterExp = "OHS=单招(应届普高),SVS=单招(中职),VHS=职高对口升学")
     private String examType;
     @Excel(name = "卡类型", readConverterExp = "2=机构VIP,6=vip卡,7=电子卡,8=测试卡,9=体验卡")
     private Integer type;

+ 10 - 7
ie-admin/src/main/java/com/ruoyi/web/service/SysRegisterService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.web.service;
 
+import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.google.common.collect.Lists;
 import com.ruoyi.common.core.domain.model.LoginUser;
@@ -175,13 +176,15 @@ public class SysRegisterService
         if (!userService.checkPhoneUnique(upUser)) {
             throw new ValidationException("保存用户'" + upUser.getNickName() + "'失败,注册手机已存在" + cardUserBody.getMobile());
         }
-        JSONObject directed = cardUserBody.getDirectionStudy().getJSONObject(0);
-        Long planId = directed.getLongValue("majorId");
-        Long universityId = directed.getLongValue("universityId");
-        directed.put("notice", learnTeacherService.updateDirected(userId, universityId, planId));
-        cardUserBody.getDirectionStudy().set(0, directed);
-        upUser.setDirectedStudy(cardUserBody.getDirectionStudy().toJSONString());
-
+        JSONArray directList = cardUserBody.getDirectionStudy();
+        if (null != directList && !directList.isEmpty()) {
+            JSONObject directed = directList.getJSONObject(0);
+            Long planId = directed.getLongValue("majorId");
+            Long universityId = directed.getLongValue("universityId");
+            directed.put("notice", learnTeacherService.updateDirected(userId, universityId, planId));
+            cardUserBody.getDirectionStudy().set(0, directed);
+            upUser.setDirectedStudy(cardUserBody.getDirectionStudy().toJSONString());
+        }
         DzCards upCard = new DzCards();
         upCard.setCardId(card.getCardId());
         upCard.setSchoolId(cardUserBody.getSchoolId());