Ver código fonte

Merge remote-tracking branch 'origin/dev' into dev

大数据与最优化研究所 3 meses atrás
pai
commit
c54a26beee

+ 14 - 8
src/main/java/com/xjrsoft/module/job/BaseNewStudentTask.java

@@ -117,7 +117,13 @@ public class BaseNewStudentTask {
                 new QueryWrapper<BaseNewStudent>().lambda()
                         .eq(BaseNewStudent::getDeleteMark, DeleteMark.NODELETE.getCode())
         );
-        Map<String, BaseNewStudent> existsNewStudentMap = existsNewStudentList.stream().filter(x -> StrUtil.isEmpty(x.getDeleteReason())).collect(Collectors.toMap(BaseNewStudent::getCredentialNumber, x -> x));
+        Map<String, BaseNewStudent> existsNewStudentMap = existsNewStudentList.stream()
+                .filter(x -> StrUtil.isEmpty(x.getDeleteReason()))
+                .collect(Collectors.toMap(
+                        BaseNewStudent::getCredentialNumber,
+                        x -> x,
+                        (existing, replacement) -> existing
+                ));
 
         List<BaseMajorSet> majorSetList = majorSetService.list(
                 new QueryWrapper<BaseMajorSet>().lambda()
@@ -135,14 +141,14 @@ public class BaseNewStudentTask {
             BaseNewStudent existsNewStudent = existsNewStudentMap.get(feeobjupdate.getPersonalid());
             Long planId = planMap.get(feeobjupdate.getEnteryear() + feeobjupdate.getUserdef6());
             if (existsNewStudent != null) {
-                if(existsNewStudent.getStatus() != null && existsNewStudent.getStatus() == 1){
+                if (existsNewStudent.getStatus() != null && existsNewStudent.getStatus() == 1) {
                     continue;
                 }
                 existsNewStudent.setName(feeobjupdate.getFeeobjname());
                 existsNewStudent.setPaymnystate(feeobjupdate.getPaymnystate());
-                if("未交费".equals(feeobjupdate.getPaymnystate())){
+                if ("未交费".equals(feeobjupdate.getPaymnystate())) {
                     existsNewStudent.setIsCanBanding(0);
-                }else{
+                } else {
                     existsNewStudent.setIsCanBanding(1);
                 }
                 existsNewStudent.setPrevious(feeobjupdate.getPrevious());
@@ -172,14 +178,14 @@ public class BaseNewStudentTask {
                 existsNewStudent.setSecondAmbitionId(majorSetNameMap.get(feeobjupdate.getZytjspec()));
                 existsNewStudent.setGender(GenderDictionaryEnum.getCode(feeobjupdate.getSex()));
                 existsNewStudent.setModifyDate(new Date());
-                if(!planId.equals(existsNewStudent.getEnrollmentPlanId())){
+                if (!planId.equals(existsNewStudent.getEnrollmentPlanId())) {
                     existsNewStudent.setStatus(0);
                 }
                 existsNewStudent.setEnrollmentPlanId(planId);
                 updateList.add(existsNewStudent);
                 continue;
             }
-            if(insCredentialNumber.contains(feeobjupdate.getPersonalid())){
+            if (insCredentialNumber.contains(feeobjupdate.getPersonalid())) {
                 continue;
             }
             insertList.add(
@@ -216,9 +222,9 @@ public class BaseNewStudentTask {
                         setEnrollmentPlanId(planId);
                         setCreateDate(new Date());
                         setStatus(0);
-                        if("未交费".equals(feeobjupdate.getPaymnystate())){
+                        if ("未交费".equals(feeobjupdate.getPaymnystate())) {
                             setIsCanBanding(0);
-                        }else{
+                        } else {
                             setIsCanBanding(1);
                         }
                     }}

+ 1 - 1
src/main/java/com/xjrsoft/module/student/controller/StudentManagerController.java

@@ -291,7 +291,7 @@ public class StudentManagerController {
 
     @PostMapping("/import")
     @ApiOperation(value = "导入学生信息")
-    @SaCheckPermission("studentmanager:import")
+//    @SaCheckPermission("studentmanager:import")
     @XjrLog(value = "导入学生信息", saveRequestData = false, saveResponseData = true)
     public RT<List<BaseStudentSompleInfoVo>> importData(@RequestParam("file") MultipartFile file) throws IOException, ParseException {
         List<Map<Integer, Object>> excelDataList = EasyExcel.read(file.getInputStream()).sheet().headRowNumber(3).doReadSync();

+ 57 - 21
src/main/java/com/xjrsoft/module/student/service/impl/StudentManagerServiceImpl.java

@@ -37,6 +37,7 @@ import com.xjrsoft.module.organization.mapper.UserMapper;
 import com.xjrsoft.module.organization.mapper.UserRoleRelationMapper;
 import com.xjrsoft.module.organization.service.IDepartmentService;
 import com.xjrsoft.module.organization.service.IUserDeptRelationService;
+import com.xjrsoft.module.organization.service.IUserRoleRelationService;
 import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.student.dto.AddBaseStudentUserDto;
 import com.xjrsoft.module.student.dto.BaseStudentSimpleInfoDto;
@@ -83,6 +84,7 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
     private final IBaseStudentService baseStudentService;
     private final BaseClassMapper baseClassMapper;
     private final IBaseStudentContactService studentContactService;
+    private final IUserRoleRelationService userRoleRelationService;
     private final BaseStudentFamilyMapper familyMapper;
     private final BaseStudentFamilyMemberMapper familyMemberMapper;
 
@@ -222,7 +224,7 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
                         .eq(BaseStudentUser::getCredentialNumber, dto.getCredentialNumber())
                         .ne(BaseStudentUser::getId, dto.getId())
         );
-        if(!studentUserList.isEmpty()){
+        if (!studentUserList.isEmpty()) {
             throw new MyException("该身份证已被其他人占用,请检查是否正确");
         }
         BaseStudentUser baseStudentUser = BeanUtil.toBean(dto, BaseStudentUser.class);
@@ -508,12 +510,12 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
             idNumbers.add(integerObjectMap.get(0).toString());
         }
 
-        List<BaseStudentSompleInfoVo> infos = userMapper.getInfosByParam(new BaseStudentSimpleInfoDto() {{
-            setIdNumberList(idNumbers);
-        }});
-        if(!infos.isEmpty()){
-           return infos;
-        }
+//        List<BaseStudentSompleInfoVo> infos = userMapper.getInfosByParam(new BaseStudentSimpleInfoDto() {{
+//            setIdNumberList(idNumbers);
+//        }});
+//        if(!infos.isEmpty()){
+//           return infos;
+//        }
 
         //查询所有学生的用户信息,组装起来备用
         List<BaseStudentUser> studentUsers = this.selectJoinList(BaseStudentUser.class,
@@ -602,6 +604,12 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
         for (BaseStudentContact el : contactList) {
             contactMap.put(el.getUserId(), el);
         }
+        //查询用户角色
+        List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectList(null);
+        Map<Long, UserRoleRelation> userRoleRelationsMap = new HashMap<>();
+        for (UserRoleRelation el : userRoleRelations) {
+            userRoleRelationsMap.put(el.getUserId(), el);
+        }
 
         List<BaseStudentUser> updateStudentUserList = new ArrayList();
         List<BaseStudent> updateBaseStudentList = new ArrayList();
@@ -609,6 +617,7 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
         List<BaseStudentSubsidize> updateSubsidizeList = new ArrayList();
         List<BaseStudentFamily> updateFamilyList = new ArrayList();
         List<BaseStudentContact> updateContactList = new ArrayList();
+        List<UserRoleRelation> updateRoleRelationList = new ArrayList();
 
         List<BaseStudentUser> insertStudentUserList = new ArrayList();
         List<BaseStudent> insertBaseStudentList = new ArrayList();
@@ -616,6 +625,7 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
         List<BaseStudentSubsidize> insertSubsidizeList = new ArrayList();
         List<BaseStudentFamily> insertFamilyList = new ArrayList();
         List<BaseStudentContact> insertContactList = new ArrayList();
+        List<UserRoleRelation> insertRoleRelationList = new ArrayList();
 
         //异动记录
         List<StudentChangeRecord> changeRecordList = new ArrayList();
@@ -635,6 +645,7 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
             BaseStudentSubsidize subsidize;
             BaseStudentFamily studentFamily;
             BaseStudentContact contact;
+            UserRoleRelation roleRelation;
             long userId = IdUtil.getSnowflakeNextId();
             if (user != null) {
                 userId = user.getId();
@@ -684,6 +695,14 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
                     contact.setCreateDate(LocalDateTime.now());
                 }
                 contact.setDeleteMark(DeleteMark.NODELETE.getCode());
+
+                // 更新角色
+                roleRelation = userRoleRelationsMap.get(user.getId());
+                if (roleRelation == null) {
+                    roleRelation = new UserRoleRelation();
+                    roleRelation.setUserId(userId);
+                    roleRelation.setRoleId(RoleEnum.STUDENT.getCode());
+                }
             } else {
                 user = new BaseStudentUser();
                 user.setId(userId);
@@ -720,6 +739,11 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
                 contact.setUserId(userId);
                 contact.setCreateUserId(createUserId);
                 contact.setCreateDate(LocalDateTime.now());
+
+                // 角色
+                roleRelation = new UserRoleRelation();
+                roleRelation.setUserId(userId);
+                roleRelation.setRoleId(RoleEnum.STUDENT.getCode());
             }
             //设置字段值
             if (dataMaps.get(1) != null && !"".equals(dataMaps.get(1).toString())) {
@@ -884,7 +908,7 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
             }
             if (dataMaps.get(53) != null && !"".equals(dataMaps.get(53).toString()) && schoolRoll.getId() == null) {
                 schoolRoll.setClassId(classMap.get(dataMaps.get(53).toString()).getId());//班级
-                if(schoolRoll.getMajorSetId() == null){
+                if (schoolRoll.getMajorSetId() == null) {
                     schoolRoll.setMajorSetId(classMap.get(dataMaps.get(53).toString()).getMajorSetId());
                 }
             }
@@ -984,45 +1008,51 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
                 studentFamily.setRailwayStation(dataMaps.get(83).toString());//离家最近火车站
             }
 
-            if(studentUserMap.containsKey(credentialNumber)){
+            if (studentUserMap.containsKey(credentialNumber)) {
                 updateStudentUserList.add(user);
-            }else{
+            } else {
                 insertStudentUserList.add(user);
             }
 
-            if(baseStudent.getId() == null){
+            if (baseStudent.getId() == null) {
                 insertBaseStudentList.add(baseStudent);
-            }else{
+            } else {
                 updateBaseStudentList.add(baseStudent);
             }
 
-            if(schoolRoll.getId() == null){
-                if(schoolRoll.getArchivesStatus() == null){
+            if (schoolRoll.getId() == null) {
+                if (schoolRoll.getArchivesStatus() == null) {
                     schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
                 }
                 insertSchoolRollList.add(schoolRoll);
-            }else{
+            } else {
                 updateSchoolRollList.add(schoolRoll);
             }
 
-            if(subsidize.getId() == null){
+            if (subsidize.getId() == null) {
                 insertSubsidizeList.add(subsidize);
-            }else{
+            } else {
                 updateSubsidizeList.add(subsidize);
             }
 
-            if(studentFamily.getId() == null){
+            if (studentFamily.getId() == null) {
                 insertFamilyList.add(studentFamily);
-            }else{
+            } else {
                 updateFamilyList.add(studentFamily);
             }
 
-            if(contact.getId() == null){
+            if (contact.getId() == null) {
                 insertContactList.add(contact);
-            }else{
+            } else {
                 updateContactList.add(contact);
             }
 
+            if (roleRelation.getId() == null) {
+                insertRoleRelationList.add(roleRelation);
+            } else {
+                updateRoleRelationList.add(roleRelation);
+            }
+
             row++;
         }
         //批量修改
@@ -1044,6 +1074,9 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
         if (!updateContactList.isEmpty()) {
             studentContactService.updateBatchById(updateContactList);
         }
+        if (!updateRoleRelationList.isEmpty()) {
+            userRoleRelationService.updateBatchById(updateRoleRelationList);
+        }
         //批量新增
         if (!insertStudentUserList.isEmpty()) {
             this.saveBatch(insertStudentUserList);
@@ -1063,6 +1096,9 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
         if (!insertContactList.isEmpty()) {
             studentContactService.saveBatch(insertContactList);
         }
+        if (!insertRoleRelationList.isEmpty()) {
+            userRoleRelationService.saveBatch(insertRoleRelationList);
+        }
         return new ArrayList<>();
     }
 

+ 3 - 0
src/main/java/com/xjrsoft/module/system/service/ILoginService.java

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.system.service;
 
+import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.system.dto.*;
 import com.xjrsoft.module.system.vo.CreateTokenVo;
 import com.xjrsoft.module.system.vo.ImgCaptchaVo;
@@ -14,6 +15,8 @@ public interface ILoginService {
 
     LoginVo login(LoginDto dto) throws Exception;
 
+    LoginVo getLoginInfo(User loginUser, String loginType);
+
     LoginVo loginByCode(LoginByCodeDto dto) throws Exception;
 
     LoginByCodeVo bindOpenid(LoginByCodeDto dto) throws Exception;

+ 2 - 1
src/main/java/com/xjrsoft/module/system/service/impl/LoginServiceImpl.java

@@ -358,7 +358,8 @@ public class LoginServiceImpl implements ILoginService {
         return sb.toString();
     }
 
-    private LoginVo getLoginInfo(User loginUser, String loginType) throws Exception {
+    @Override
+    public LoginVo getLoginInfo(User loginUser, String loginType) {
         LoginVo result = new LoginVo();
         if (loginUser.getEnabledMark() == EnabledMark.DISABLED.getCode()) {
             throw new MyException("账户未启用");

+ 1 - 0
src/main/resources/application-dev.yml

@@ -121,6 +121,7 @@ xjrsoft:
       - /student/basestudentinfo/studentinfoByKeyWord
       - /student/pbCseFeeobjupdate/enrollment-statistics-start
       - /student/basestudentinfo/studentinfoByKeyWordNotReading
+      - /student/baseNewStudent/basenewstudent-task-start
     approval-time: 300 # 审核超时时间 目前设为5分钟
   email:
     host:  #邮件服务器的SMTP地址,可选,默认为smtp.<发件人邮箱后缀>

+ 5 - 1
src/test/java/com/xjrsoft/module/job/BaseNewStudentTaskTest.java

@@ -81,8 +81,12 @@ class BaseNewStudentTaskTest {
 
     @Test
     public void execute(){
-        doExecute();
+        BaseNewStudentTask basenewstudenttask = new BaseNewStudentTask();
+        basenewstudenttask.doExecute(newStudentService, cseFeeobjupdateService, planService, gradeService, majorSetService);
     }
+
+
+
     void doExecute() {
         List<PbCseFeeobjupdate> dataList = cseFeeobjupdateService.list();
 

+ 17 - 2
src/test/java/com/xjrsoft/module/system/controller/LoginControllerTest.java

@@ -3,6 +3,10 @@ package com.xjrsoft.module.system.controller;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.xjrsoft.common.sms.SmsCtcc;
 import com.xjrsoft.common.utils.RedisUtil;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.system.service.ILoginService;
+import com.xjrsoft.module.system.vo.LoginVo;
 import org.apache.commons.lang3.RandomUtils;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,18 +25,29 @@ class LoginControllerTest {
     private RedisUtil redisUtil;
     @Autowired
     private SmsCtcc smsCtcc;
+    @Autowired
+    private ILoginService loginService;
+    @Autowired
+    private IUserService userService;
 
     @Test
-    void test(){
+    void test() {
         String key = "imgCaptcha:15898a7f-984c-402d-806e-b5a0d79845fa";
         System.out.println(redisUtil.get(key));
     }
 
     @Test
-    void test2(){
+    void test2() {
         String code = RandomUtils.nextInt(100000, 999999) + StringPool.EMPTY;
         String mobile = "13389612083";
         smsCtcc.sendCaptcha(mobile, code, true);
     }
 
+    @Test
+    void testToken() {
+        User user = userService.getById("1000000000000000000");
+        LoginVo pc = loginService.getLoginInfo(user, "PC");
+        System.out.println(pc);
+    }
+
 }