Browse Source

插班规则调整

dzx 8 tháng trước cách đây
mục cha
commit
7edd87e5ad

+ 18 - 0
src/main/java/com/xjrsoft/common/utils/LocalDateUtil.java

@@ -1,6 +1,9 @@
 package com.xjrsoft.common.utils;
 
+import com.xjrsoft.common.exception.MyException;
+
 import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 
 /**
  * @author dzx
@@ -19,4 +22,19 @@ public class LocalDateUtil {
         // 检查目标日期是否在开始日期和结束日期之间(包含边界)
         return !targetDate.isBefore(startDate) && !targetDate.isAfter(endDate);
     }
+
+
+    public static LocalDate getBirthDate(String idCardNumber){
+        // 获取出生日期前6位,即yyyyMM
+        String birthdayString = idCardNumber.substring(6, 14);
+
+        // 将字符串解析为LocalDate对象
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+        try {
+            LocalDate parse = LocalDate.parse(birthdayString, formatter);
+            return parse;
+        }catch (Exception e){
+            throw new MyException("身份证号填写错误,无法提取出生日期");
+        }
+    }
 }

+ 2 - 15
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassStudentServiceImpl.java

@@ -12,6 +12,7 @@ import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.enums.EnabledMark;
 import com.xjrsoft.common.enums.RoleEnum;
 import com.xjrsoft.common.exception.MyException;
+import com.xjrsoft.common.utils.LocalDateUtil;
 import com.xjrsoft.common.utils.RedisUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.config.CommonPropertiesConfig;
@@ -292,7 +293,7 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
                         }
                         continue;
                     }
-                    LocalDate birthDate = getBirthDate(student.getCredentialNumber());
+                    LocalDate birthDate = LocalDateUtil.getBirthDate(student.getCredentialNumber());
                     User xjrUser = new User() {{
                         setCreateDate(now);
                         setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
@@ -365,20 +366,6 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
         return true;
     }
 
-    LocalDate getBirthDate(String idCardNumber){
-        // 获取出生日期前6位,即yyyyMM
-        String birthdayString = idCardNumber.substring(6, 14);
-
-        // 将字符串解析为LocalDate对象
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
-        try {
-            LocalDate parse = LocalDate.parse(birthdayString, formatter);
-            return parse;
-        }catch (Exception e){
-            throw new MyException("身份证号填写错误,无法提取出生日期");
-        }
-    }
-
     @Override
     @Transactional
     public Boolean removeStudent(ChangeClassDto dto) {

+ 61 - 19
src/main/java/com/xjrsoft/module/liteflow/node/StudentTransferNode.java

@@ -1,22 +1,31 @@
 package com.xjrsoft.module.liteflow.node;
 
+import cn.dev33.satoken.secure.BCrypt;
 import cn.hutool.core.convert.Convert;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.xjrsoft.common.enums.ArchivesStatusEnum;
 import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.common.utils.LocalDateUtil;
+import com.xjrsoft.config.CommonPropertiesConfig;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.mapper.BaseClassMapper;
+import com.xjrsoft.module.organization.dto.GetUserByParamDto;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.student.entity.BaseClassMajorSet;
+import com.xjrsoft.module.student.entity.BaseNewStudent;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.entity.StudentTransfer;
 import com.xjrsoft.module.student.mapper.BaseClassMajorSetMapper;
 import com.xjrsoft.module.student.mapper.StudentTransferMapper;
+import com.xjrsoft.module.student.service.IBaseNewStudentService;
 import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
-import com.xjrsoft.module.student.service.IStudentChangeRecordService;
 import com.yomahub.liteflow.core.NodeComponent;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.Map;
 
@@ -37,7 +46,13 @@ public class StudentTransferNode extends NodeComponent {
     private BaseClassMajorSetMapper baseClassMajorSetMapper;
 
     @Autowired
-    private IStudentChangeRecordService changeRecordService;
+    private IBaseNewStudentService newStudentService;
+
+    @Autowired
+    private IUserService userService;
+
+    @Autowired
+    private CommonPropertiesConfig propertiesConfig;
 
     @Override
     public void process() throws Exception {
@@ -48,24 +63,51 @@ public class StudentTransferNode extends NodeComponent {
         if (formId != null) {
             //查询出数据
             StudentTransfer studentTransfer = studentTransferMapper.selectById(formId);
-            BaseClass baseClass = baseClassMapper.selectById(studentTransfer.getClassId());
-            BaseClassMajorSet majorSet = baseClassMajorSetMapper.selectOne(
-                    new QueryWrapper<BaseClassMajorSet>().lambda()
-                            .eq(BaseClassMajorSet::getClassId, studentTransfer.getClassId())
-                            .eq(BaseClassMajorSet::getDeleteMark, DeleteMark.NODELETE.getCode())
+
+            BaseNewStudent newStudent = newStudentService.getById(studentTransfer.getStudentUserId());
+            User user = userService.getUserByParam(
+                    new GetUserByParamDto() {{
+                        setCredentialNumber(newStudent.getCredentialNumber());
+                    }}
             );
-            BaseStudentSchoolRoll roll = new BaseStudentSchoolRoll();
-            roll.setStduyStatus(studentTransfer.getStudyStatus());
-            roll.setClassId(studentTransfer.getClassId());
-            roll.setEnrollType(baseClass.getEnrollType());
-            roll.setCreateDate(LocalDateTime.now());
-            roll.setGradeId(baseClass.getGradeId());
-            roll.setMajorSetId(majorSet.getMajorSetId());
-            roll.setCreateUserId(studentTransfer.getCreateUserId());
-            roll.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
-            roll.setUserId(studentTransfer.getStudentUserId());
-            //新增学籍信息
-            studentSchoolRollService.save(roll);
+            LocalDate birthDate = LocalDateUtil.getBirthDate(newStudent.getCredentialNumber());
+            if(user == null){
+                User xjrUser = new User() {{
+                    setCreateDate(LocalDateTime.now());
+                    setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
+                    setName(newStudent.getName());
+                    setUserName(newStudent.getCredentialNumber());
+                    setCredentialNumber(newStudent.getCredentialNumber());
+                    setCredentialType("ZZLS10007");
+                    setMobile(newStudent.getMobile());
+                    setEnabledMark(EnabledMark.DISABLED.getCode());
+                    setGender(newStudent.getGender());
+                    setIsChangePassword(1);
+                    setBirthDate(birthDate.atStartOfDay());
+                }};
+                userService.save(xjrUser);
+
+                BaseClass baseClass = baseClassMapper.selectById(studentTransfer.getClassId());
+                BaseClassMajorSet majorSet = baseClassMajorSetMapper.selectOne(
+                        new QueryWrapper<BaseClassMajorSet>().lambda()
+                                .eq(BaseClassMajorSet::getClassId, studentTransfer.getClassId())
+                                .eq(BaseClassMajorSet::getDeleteMark, DeleteMark.NODELETE.getCode())
+                );
+                BaseStudentSchoolRoll roll = new BaseStudentSchoolRoll();
+                roll.setStduyStatus(studentTransfer.getStudyStatus());
+                roll.setClassId(studentTransfer.getClassId());
+                roll.setEnrollType(baseClass.getEnrollType());
+                roll.setCreateDate(LocalDateTime.now());
+                roll.setGradeId(baseClass.getGradeId());
+                roll.setMajorSetId(majorSet.getMajorSetId());
+                roll.setCreateUserId(studentTransfer.getCreateUserId());
+                roll.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
+                roll.setUserId(studentTransfer.getStudentUserId());
+                //新增学籍信息
+                studentSchoolRollService.save(roll);
+            }else{
+                studentSchoolRollService.updateStudentClass(studentTransfer.getClassId(), user.getId());
+            }
         }
     }
 }