dzx 8 mesiacov pred
rodič
commit
e42eddaa6c

+ 47 - 1
src/main/java/com/xjrsoft/module/liteflow/node/StudentTransferNode.java

@@ -6,21 +6,28 @@ 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.enums.RoleEnum;
 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.entity.UserRoleRelation;
+import com.xjrsoft.module.organization.service.IUserRoleRelationService;
 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.BaseStudent;
+import com.xjrsoft.module.student.entity.BaseStudentFamily;
 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.IBaseStudentFamilyService;
 import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
+import com.xjrsoft.module.student.service.IBaseStudentService;
 import com.yomahub.liteflow.core.NodeComponent;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -54,6 +61,15 @@ public class StudentTransferNode extends NodeComponent {
     @Autowired
     private CommonPropertiesConfig propertiesConfig;
 
+    @Autowired
+    private IBaseStudentService studentService;
+
+    @Autowired
+    private IBaseStudentFamilyService familyService;
+
+    @Autowired
+    private IUserRoleRelationService roleRelationService;
+
     @Override
     public void process() throws Exception {
         // 获取表单中数据编号
@@ -72,9 +88,10 @@ public class StudentTransferNode extends NodeComponent {
             );
             LocalDate birthDate = LocalDateUtil.getBirthDate(newStudent.getCredentialNumber());
             BaseClass baseClass = baseClassMapper.selectById(studentTransfer.getClassId());
+            LocalDateTime now = LocalDateTime.now();
             if(user == null){
                 User xjrUser = new User() {{
-                    setCreateDate(LocalDateTime.now());
+                    setCreateDate(now);
                     setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
                     setName(newStudent.getName());
                     setUserName(newStudent.getCredentialNumber());
@@ -88,6 +105,25 @@ public class StudentTransferNode extends NodeComponent {
                 }};
                 userService.save(xjrUser);
 
+                UserRoleRelation userRoleRelation = new UserRoleRelation() {{
+                    setRoleId(RoleEnum.STUDENT.getCode());
+                    setUserId(xjrUser.getId());
+                }};
+                roleRelationService.save(userRoleRelation);
+
+                BaseStudent baseStudent = new BaseStudent() {{
+                    setUserId(xjrUser.getId());
+                    setCreateDate(now);
+                    setStudentId(newStudent.getCredentialNumber());
+                    if(newStudent.getHeight() != null){
+                        setHeight(newStudent.getHeight().doubleValue());
+                    }
+                    if(newStudent.getWeight() != null){
+                        setWeight(newStudent.getWeight().doubleValue());
+                    }
+                }};
+                studentService.save(baseStudent);
+
                 BaseClassMajorSet majorSet = baseClassMajorSetMapper.selectOne(
                         new QueryWrapper<BaseClassMajorSet>().lambda()
                                 .eq(BaseClassMajorSet::getClassId, studentTransfer.getClassId())
@@ -107,6 +143,16 @@ public class StudentTransferNode extends NodeComponent {
                 roll.setEnabledMark(EnabledMark.ENABLED.getCode());
                 //新增学籍信息
                 studentSchoolRollService.save(roll);
+
+
+                BaseStudentFamily studentFamily = new BaseStudentFamily() {{
+                    setCreateDate(now);
+                    setUserId(xjrUser.getId());
+                    setTelephone(newStudent.getFamilyMobile());
+                    setAddress(newStudent.getFamilyAddress());
+                }};
+                familyService.save(studentFamily);
+
             }else{
                 studentSchoolRollService.updateStudentClass(studentTransfer.getClassId(), user.getId());
             }