|
|
@@ -0,0 +1,196 @@
|
|
|
+package com.xjrsoft.module.job;
|
|
|
+
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.xjrsoft.XjrSoftApplication;
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
+import com.xjrsoft.common.enums.EnabledMark;
|
|
|
+import com.xjrsoft.common.enums.EnrollTypeEnum;
|
|
|
+import com.xjrsoft.common.enums.GenderDictionaryEnum;
|
|
|
+import com.xjrsoft.common.enums.StudentTypeEnum;
|
|
|
+import com.xjrsoft.common.enums.StudyStatusEnum;
|
|
|
+import com.xjrsoft.module.base.entity.BaseGrade;
|
|
|
+import com.xjrsoft.module.base.entity.BaseMajorSet;
|
|
|
+import com.xjrsoft.module.base.service.IBaseGradeService;
|
|
|
+import com.xjrsoft.module.base.service.IBaseMajorSetService;
|
|
|
+import com.xjrsoft.module.student.entity.BaseNewStudent;
|
|
|
+import com.xjrsoft.module.student.entity.EnrollmentPlan;
|
|
|
+import com.xjrsoft.module.student.entity.PbCseFeeobjupdate;
|
|
|
+import com.xjrsoft.module.student.service.IBaseNewStudentService;
|
|
|
+import com.xjrsoft.module.student.service.IEnrollmentPlanService;
|
|
|
+import com.xjrsoft.module.student.service.IPbCseFeeobjupdateService;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author dzx
|
|
|
+ * @date 2025/3/4
|
|
|
+ */
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
+@SpringBootTest(classes = XjrSoftApplication.class)
|
|
|
+class BaseNewStudentTaskTest {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBaseNewStudentService newStudentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IPbCseFeeobjupdateService cseFeeobjupdateService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IEnrollmentPlanService planService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBaseGradeService gradeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBaseMajorSetService majorSetService;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void execute(){
|
|
|
+ doExecute();
|
|
|
+ }
|
|
|
+
|
|
|
+ void doExecute(){
|
|
|
+ List<PbCseFeeobjupdate> dataList = cseFeeobjupdateService.list();
|
|
|
+ Map<String, String> gradeMap = dataList.stream().filter(x -> StrUtil.isNotEmpty(x.getEnteryear()) && StrUtil.isNotEmpty(x.getUserdef6()))
|
|
|
+ .collect(Collectors.toMap(PbCseFeeobjupdate::getEnteryear, PbCseFeeobjupdate::getUserdef6));
|
|
|
+
|
|
|
+ List<EnrollmentPlan> planDataList = planService.list(
|
|
|
+ new QueryWrapper<EnrollmentPlan>().lambda()
|
|
|
+ .eq(EnrollmentPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(EnrollmentPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
|
|
|
+ );
|
|
|
+ Map<String, Long> planDataMap = planDataList.stream().collect(Collectors.toMap(x -> x.getEnrollType() + x.getGradeId(), EnrollmentPlan::getId));
|
|
|
+
|
|
|
+ Map<String, Long> planMap = new HashMap<>();
|
|
|
+ //插入招生计划数据
|
|
|
+ gradeMap.forEach((enteryear, userdef6)->{
|
|
|
+ EnrollmentPlan plan = new EnrollmentPlan();
|
|
|
+ plan.setCreateDate(new Date());
|
|
|
+ plan.setEnabledMark(EnabledMark.ENABLED.getCode());
|
|
|
+ plan.setDeleteMark(DeleteMark.NODELETE.getCode());
|
|
|
+ if("1".equals(userdef6)){
|
|
|
+ plan.setEnrollType(EnrollTypeEnum.SPRING_ENROLLMENT.getCode());
|
|
|
+ }else if("2".equals(userdef6)){
|
|
|
+ plan.setEnrollType(EnrollTypeEnum.AUTUMN_ENROLLMENT.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询年级
|
|
|
+ BaseGrade grade = gradeService.getOne(
|
|
|
+ new QueryWrapper<BaseGrade>().lambda()
|
|
|
+ .eq(BaseGrade::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .like(BaseGrade::getTitle, enteryear)
|
|
|
+ );
|
|
|
+ plan.setGradeId(grade.getId());
|
|
|
+
|
|
|
+ Long oldPlanId = planDataMap.get(plan.getEnrollType() + plan.getGradeId());
|
|
|
+
|
|
|
+ planMap.put(enteryear + userdef6, oldPlanId);
|
|
|
+
|
|
|
+ //判断是否已经存在,不存在就新增
|
|
|
+ if(oldPlanId == null){
|
|
|
+ planService.save(plan);
|
|
|
+ planMap.put(enteryear + userdef6, plan.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //查询已存在的新生信息
|
|
|
+ List<BaseNewStudent> existsNewStudentList = newStudentService.list(
|
|
|
+ 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));
|
|
|
+
|
|
|
+ List<BaseMajorSet> majorSetList = majorSetService.list(
|
|
|
+ new QueryWrapper<BaseMajorSet>().lambda()
|
|
|
+ .eq(BaseMajorSet::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(BaseMajorSet::getEnabledMark, EnabledMark.ENABLED.getCode())
|
|
|
+ );
|
|
|
+ Map<String, Long> majorSetMap = majorSetList.stream().collect(Collectors.toMap(BaseMajorSet::getCode, BaseMajorSet::getId));
|
|
|
+
|
|
|
+ //循环攀宝的数据,准备更新到新生表中
|
|
|
+ List<BaseNewStudent> updateList = new ArrayList<>();
|
|
|
+ List<BaseNewStudent> insertList = new ArrayList<>();
|
|
|
+ for (PbCseFeeobjupdate feeobjupdate : dataList) {
|
|
|
+ BaseNewStudent existsNewStudent = existsNewStudentMap.get(feeobjupdate.getPersonalid());
|
|
|
+
|
|
|
+ if(existsNewStudent != null){
|
|
|
+ existsNewStudent.setName(feeobjupdate.getFeeobjname());
|
|
|
+ existsNewStudent.setPaymnystate(feeobjupdate.getPaymnystate());
|
|
|
+ existsNewStudent.setPrevious(feeobjupdate.getPrevious());
|
|
|
+ existsNewStudent.setProvince(feeobjupdate.getProvince());
|
|
|
+ existsNewStudent.setCity(feeobjupdate.getCity());
|
|
|
+ existsNewStudent.setMyarea(feeobjupdate.getMyarea());
|
|
|
+ existsNewStudent.setHeight(BigDecimal.valueOf(Double.parseDouble(feeobjupdate.getSg())));
|
|
|
+ existsNewStudent.setWeight(BigDecimal.valueOf(Double.parseDouble(feeobjupdate.getTz())));
|
|
|
+ existsNewStudent.setGraduateSchool(feeobjupdate.getGraduations());
|
|
|
+ existsNewStudent.setStduyStatus(StudyStatusEnum.getCode(feeobjupdate.getQuartername()));
|
|
|
+ existsNewStudent.setSource(StudentTypeEnum.getCode(feeobjupdate.getResourcename()));
|
|
|
+ existsNewStudent.setMobile(feeobjupdate.getTelephone());
|
|
|
+ existsNewStudent.setFamilyMobile(feeobjupdate.getJzlxdh());
|
|
|
+ existsNewStudent.setFamilyAddress(feeobjupdate.getAddress());
|
|
|
+ existsNewStudent.setFirstAmbition(majorSetMap.get(feeobjupdate.getSpeccode()));
|
|
|
+ existsNewStudent.setFirstAmbitionId(majorSetMap.get(feeobjupdate.getSpeccode()));
|
|
|
+ existsNewStudent.setSecondAmbition(majorSetMap.get(feeobjupdate.getZytjspec()));
|
|
|
+ existsNewStudent.setSecondAmbitionId(majorSetMap.get(feeobjupdate.getZytjspec()));
|
|
|
+ existsNewStudent.setGender(GenderDictionaryEnum.getCode(feeobjupdate.getSex()));
|
|
|
+ existsNewStudent.setModifyDate(new Date());
|
|
|
+
|
|
|
+ updateList.add(existsNewStudent);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Long planId = planMap.get(feeobjupdate.getEnteryear() + feeobjupdate.getUserdef6());
|
|
|
+ insertList.add(
|
|
|
+ new BaseNewStudent(){{
|
|
|
+ setCredentialNumber(feeobjupdate.getPersonalid());
|
|
|
+ setName(feeobjupdate.getFeeobjname());
|
|
|
+ setPaymnystate(feeobjupdate.getPaymnystate());
|
|
|
+ setPrevious(feeobjupdate.getPrevious());
|
|
|
+ setProvince(feeobjupdate.getProvince());
|
|
|
+ setCity(feeobjupdate.getCity());
|
|
|
+ setMyarea(feeobjupdate.getMyarea());
|
|
|
+ setHeight(BigDecimal.valueOf(Double.parseDouble(feeobjupdate.getSg())));
|
|
|
+ setWeight(BigDecimal.valueOf(Double.parseDouble(feeobjupdate.getTz())));
|
|
|
+ setGraduateSchool(feeobjupdate.getGraduations());
|
|
|
+ setStduyStatus(StudyStatusEnum.getCode(feeobjupdate.getQuartername()));
|
|
|
+ setSource(StudentTypeEnum.getCode(feeobjupdate.getResourcename()));
|
|
|
+ setMobile(feeobjupdate.getTelephone());
|
|
|
+ setFamilyMobile(feeobjupdate.getJzlxdh());
|
|
|
+ setFamilyAddress(feeobjupdate.getAddress());
|
|
|
+ setFirstAmbition(majorSetMap.get(feeobjupdate.getSpeccode()));
|
|
|
+ setFirstAmbitionId(majorSetMap.get(feeobjupdate.getSpeccode()));
|
|
|
+ setSecondAmbition(majorSetMap.get(feeobjupdate.getZytjspec()));
|
|
|
+ setSecondAmbitionId(majorSetMap.get(feeobjupdate.getZytjspec()));
|
|
|
+ setGender(GenderDictionaryEnum.getCode(feeobjupdate.getSex()));
|
|
|
+ setEnrollmentPlanId(planId);
|
|
|
+ setCreateDate(new Date());
|
|
|
+ }}
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!updateList.isEmpty()){
|
|
|
+ newStudentService.updateBatchById(updateList);
|
|
|
+ }
|
|
|
+ if(!insertList.isEmpty()){
|
|
|
+ newStudentService.saveBatch(insertList);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|