StudentManagerServiceImpl.java 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952
  1. package com.xjrsoft.module.student.service.impl;
  2. import cn.dev33.satoken.secure.BCrypt;
  3. import cn.dev33.satoken.stp.StpUtil;
  4. import cn.hutool.core.bean.BeanUtil;
  5. import cn.hutool.core.util.IdUtil;
  6. import cn.hutool.core.util.StrUtil;
  7. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  8. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  9. import com.github.yulichang.base.MPJBaseServiceImpl;
  10. import com.github.yulichang.wrapper.MPJLambdaWrapper;
  11. import com.xjrsoft.common.enums.DeleteMark;
  12. import com.xjrsoft.common.enums.GenderDictionaryEnum;
  13. import com.xjrsoft.common.enums.RoleEnum;
  14. import com.xjrsoft.common.enums.YesOrNoEnum;
  15. import com.xjrsoft.common.exception.MyException;
  16. import com.xjrsoft.module.base.entity.BaseClass;
  17. import com.xjrsoft.module.base.entity.BaseGrade;
  18. import com.xjrsoft.module.base.entity.BaseMajorSet;
  19. import com.xjrsoft.module.base.mapper.BaseClassMapper;
  20. import com.xjrsoft.module.base.mapper.BaseGradeMapper;
  21. import com.xjrsoft.module.base.mapper.BaseMajorSetMapper;
  22. import com.xjrsoft.module.organization.entity.UserRoleRelation;
  23. import com.xjrsoft.module.organization.mapper.UserRoleRelationMapper;
  24. import com.xjrsoft.module.student.entity.BaseStudent;
  25. import com.xjrsoft.module.student.entity.BaseStudentContact;
  26. import com.xjrsoft.module.student.entity.BaseStudentFamily;
  27. import com.xjrsoft.module.student.entity.BaseStudentFamilyMember;
  28. import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
  29. import com.xjrsoft.module.student.entity.BaseStudentSubsidize;
  30. import com.xjrsoft.module.student.entity.BaseStudentUser;
  31. import com.xjrsoft.module.student.mapper.BaseStudentFamilyMapper;
  32. import com.xjrsoft.module.student.mapper.BaseStudentFamilyMemberMapper;
  33. import com.xjrsoft.module.student.mapper.BaseStudentUserMapper;
  34. import com.xjrsoft.module.student.service.IBaseStudentContactService;
  35. import com.xjrsoft.module.student.service.IBaseStudentFamilyService;
  36. import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
  37. import com.xjrsoft.module.student.service.IBaseStudentService;
  38. import com.xjrsoft.module.student.service.IBaseStudentSubsidizeService;
  39. import com.xjrsoft.module.student.service.IStudentManagerService;
  40. import com.xjrsoft.module.student.vo.BaseStudentClassVo;
  41. import com.xjrsoft.module.student.vo.PersonalPortraitPersonalInfoVo;
  42. import com.xjrsoft.module.student.vo.StudentPersonalInfoVo;
  43. import com.xjrsoft.module.system.entity.Area;
  44. import com.xjrsoft.module.system.entity.DictionaryDetail;
  45. import com.xjrsoft.module.system.entity.DictionaryItem;
  46. import com.xjrsoft.module.system.mapper.DictionarydetailMapper;
  47. import com.xjrsoft.module.system.mapper.DictionaryitemMapper;
  48. import com.xjrsoft.module.system.service.IAreaService;
  49. import lombok.AllArgsConstructor;
  50. import org.springframework.beans.BeanUtils;
  51. import org.springframework.stereotype.Service;
  52. import org.springframework.transaction.annotation.Transactional;
  53. import java.text.ParseException;
  54. import java.text.SimpleDateFormat;
  55. import java.time.LocalDate;
  56. import java.time.LocalDateTime;
  57. import java.time.format.DateTimeFormatter;
  58. import java.time.format.DateTimeParseException;
  59. import java.util.ArrayList;
  60. import java.util.HashMap;
  61. import java.util.HashSet;
  62. import java.util.List;
  63. import java.util.Map;
  64. import java.util.Objects;
  65. import java.util.Set;
  66. import java.util.stream.Collectors;
  67. @Service
  68. @AllArgsConstructor
  69. public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUserMapper, BaseStudentUser> implements IStudentManagerService {
  70. private final com.xjrsoft.module.student.mapper.BaseStudentUserMapper studentbaseManagerBaseStudentUserMapper;
  71. private final IBaseStudentService baseStudentService;
  72. private final BaseClassMapper baseClassMapper;
  73. private final IBaseStudentContactService studentContactService;
  74. private final BaseStudentFamilyMapper familyMapper;
  75. private final BaseStudentFamilyMemberMapper familyMemberMapper;
  76. private final UserRoleRelationMapper userRoleRelationMapper;
  77. private final DictionarydetailMapper dictionarydetailMapper;
  78. private final IAreaService areaService;
  79. private final BaseGradeMapper baseGradeMapper;
  80. private final BaseMajorSetMapper baseMajorSetMapper;
  81. private final DictionaryitemMapper dictionaryitemMapper;
  82. private final IBaseStudentSchoolRollService schoolRollService;
  83. private final IBaseStudentSubsidizeService subsidizeService;
  84. private final IBaseStudentFamilyService familyService;
  85. @Override
  86. @Transactional(rollbackFor = Exception.class)
  87. public Boolean add(BaseStudentUser baseStudentUser) {
  88. // 用户身份证后6位作为默认密码
  89. if (baseStudentUser.getCredentialNumber() != null && baseStudentUser.getCredentialNumber().length() > 6) {
  90. String str = baseStudentUser.getCredentialNumber();
  91. String lastSix = str.substring(str.length() - 6);
  92. baseStudentUser.setPassword(BCrypt.hashpw(lastSix, BCrypt.gensalt()));
  93. }
  94. studentbaseManagerBaseStudentUserMapper.insert(baseStudentUser);
  95. for (BaseStudent baseStudent : baseStudentUser.getBaseStudentList()) {
  96. baseStudent.setUserId(baseStudentUser.getId());
  97. baseStudentService.save(baseStudent);
  98. }
  99. for (BaseStudentContact baseStudentContact : baseStudentUser.getBaseStudentContactList()) {
  100. baseStudentContact.setUserId(baseStudentUser.getId());
  101. studentContactService.save(baseStudentContact);
  102. }
  103. for (BaseStudentFamily BaseStudentFamily : baseStudentUser.getBaseStudentFamilyList()) {
  104. BaseStudentFamily.setUserId(baseStudentUser.getId());
  105. familyMapper.insert(BaseStudentFamily);
  106. }
  107. for (BaseStudentFamilyMember BaseStudentFamilyMember : baseStudentUser.getBaseStudentFamilyMemberList()) {
  108. BaseStudentFamilyMember.setUserId(baseStudentUser.getId());
  109. familyMemberMapper.insert(BaseStudentFamilyMember);
  110. }
  111. for (BaseStudentSchoolRoll baseStudentSchoolRoll : baseStudentUser.getBaseStudentSchoolRollList()) {
  112. baseStudentSchoolRoll.setUserId(baseStudentUser.getId());
  113. schoolRollService.save(baseStudentSchoolRoll);
  114. }
  115. for (BaseStudentSubsidize baseStudentSubsidize : baseStudentUser.getBaseStudentSubsidizeList()) {
  116. baseStudentSubsidize.setUserId(baseStudentUser.getId());
  117. subsidizeService.save(baseStudentSubsidize);
  118. }
  119. // 添加角色
  120. UserRoleRelation userRoleRelation = new UserRoleRelation();
  121. userRoleRelation.setUserId(baseStudentUser.getId());
  122. userRoleRelation.setRoleId(RoleEnum.STUDENT.getCode());
  123. userRoleRelationMapper.insert(userRoleRelation);
  124. return true;
  125. }
  126. @Override
  127. @Transactional(rollbackFor = Exception.class)
  128. public Boolean update(BaseStudentUser baseStudentUser) {
  129. studentbaseManagerBaseStudentUserMapper.updateById(baseStudentUser);
  130. //********************************* BaseStudent 增删改 开始 *******************************************/
  131. {
  132. // 查出所有子级的id
  133. List<BaseStudent> baseStudentList = baseStudentService.list(Wrappers.lambdaQuery(BaseStudent.class).eq(BaseStudent::getUserId, baseStudentUser.getId()).select(BaseStudent::getId));
  134. List<Long> baseStudentIds = baseStudentList.stream().map(BaseStudent::getId).collect(Collectors.toList());
  135. //原有子表单 没有被删除的主键
  136. List<Long> baseStudentOldIds = baseStudentUser.getBaseStudentList().stream().map(BaseStudent::getId).filter(Objects::nonNull).collect(Collectors.toList());
  137. //找到需要删除的id
  138. List<Long> baseStudentRemoveIds = baseStudentIds.stream().filter(item -> !baseStudentOldIds.contains(item)).collect(Collectors.toList());
  139. for (BaseStudent baseStudent : baseStudentUser.getBaseStudentList()) {
  140. //如果不等于空则修改
  141. if (baseStudent.getId() != null) {
  142. baseStudentService.updateById(baseStudent);
  143. }
  144. //如果等于空 则新增
  145. else {
  146. //已经不存在的id 删除
  147. baseStudent.setUserId(baseStudentUser.getId());
  148. baseStudentService.save(baseStudent);
  149. }
  150. }
  151. //已经不存在的id 删除
  152. if (baseStudentRemoveIds.size() > 0) {
  153. baseStudentService.removeBatchByIds(baseStudentRemoveIds);
  154. }
  155. }
  156. //********************************* BaseStudent 增删改 结束 *******************************************/
  157. //********************************* BaseStudentContact 增删改 开始 *******************************************/
  158. {
  159. // 查出所有子级的id
  160. List<BaseStudentContact> baseStudentContactList = studentContactService.list(Wrappers.lambdaQuery(BaseStudentContact.class).eq(BaseStudentContact::getUserId, baseStudentUser.getId()).select(BaseStudentContact::getId));
  161. List<Long> baseStudentContactIds = baseStudentContactList.stream().map(BaseStudentContact::getId).collect(Collectors.toList());
  162. //原有子表单 没有被删除的主键
  163. List<Long> baseStudentContactOldIds = baseStudentUser.getBaseStudentContactList().stream().map(BaseStudentContact::getId).filter(Objects::nonNull).collect(Collectors.toList());
  164. //找到需要删除的id
  165. List<Long> baseStudentContactRemoveIds = baseStudentContactIds.stream().filter(item -> !baseStudentContactOldIds.contains(item)).collect(Collectors.toList());
  166. for (BaseStudentContact baseStudentContact : baseStudentUser.getBaseStudentContactList()) {
  167. //如果不等于空则修改
  168. if (baseStudentContact.getId() != null) {
  169. studentContactService.updateById(baseStudentContact);
  170. }
  171. //如果等于空 则新增
  172. else {
  173. //已经不存在的id 删除
  174. baseStudentContact.setUserId(baseStudentUser.getId());
  175. studentContactService.save(baseStudentContact);
  176. }
  177. }
  178. //已经不存在的id 删除
  179. if (baseStudentContactRemoveIds.size() > 0) {
  180. studentContactService.removeBatchByIds(baseStudentContactRemoveIds);
  181. }
  182. }
  183. //********************************* BaseStudentContact 增删改 结束 *******************************************/
  184. //********************************* BaseStudentFamily 增删改 开始 *******************************************/
  185. {
  186. // 查出所有子级的id
  187. List<BaseStudentFamily> BaseStudentFamilyList = familyMapper.selectList(Wrappers.lambdaQuery(BaseStudentFamily.class).eq(BaseStudentFamily::getUserId, baseStudentUser.getId()).select(BaseStudentFamily::getId));
  188. List<Long> BaseStudentFamilyIds = BaseStudentFamilyList.stream().map(BaseStudentFamily::getId).collect(Collectors.toList());
  189. //原有子表单 没有被删除的主键
  190. List<Long> BaseStudentFamilyOldIds = baseStudentUser.getBaseStudentFamilyList().stream().map(BaseStudentFamily::getId).filter(Objects::nonNull).collect(Collectors.toList());
  191. //找到需要删除的id
  192. List<Long> BaseStudentFamilyRemoveIds = BaseStudentFamilyIds.stream().filter(item -> !BaseStudentFamilyOldIds.contains(item)).collect(Collectors.toList());
  193. for (BaseStudentFamily BaseStudentFamily : baseStudentUser.getBaseStudentFamilyList()) {
  194. //如果不等于空则修改
  195. if (BaseStudentFamily.getId() != null) {
  196. familyMapper.updateById(BaseStudentFamily);
  197. }
  198. //如果等于空 则新增
  199. else {
  200. //已经不存在的id 删除
  201. BaseStudentFamily.setUserId(baseStudentUser.getId());
  202. familyMapper.insert(BaseStudentFamily);
  203. }
  204. }
  205. //已经不存在的id 删除
  206. if (BaseStudentFamilyRemoveIds.size() > 0) {
  207. familyMapper.deleteBatchIds(BaseStudentFamilyRemoveIds);
  208. }
  209. }
  210. //********************************* BaseStudentFamily 增删改 结束 *******************************************/
  211. //********************************* BaseStudentFamilyMember 增删改 开始 *******************************************/
  212. {
  213. // 查出所有子级的id
  214. List<BaseStudentFamilyMember> BaseStudentFamilyMemberList = familyMemberMapper.selectList(Wrappers.lambdaQuery(BaseStudentFamilyMember.class).eq(BaseStudentFamilyMember::getUserId, baseStudentUser.getId()).select(BaseStudentFamilyMember::getId));
  215. List<Long> BaseStudentFamilyMemberIds = BaseStudentFamilyMemberList.stream().map(BaseStudentFamilyMember::getId).collect(Collectors.toList());
  216. //原有子表单 没有被删除的主键
  217. List<Long> BaseStudentFamilyMemberOldIds = baseStudentUser.getBaseStudentFamilyMemberList().stream().map(BaseStudentFamilyMember::getId).filter(Objects::nonNull).collect(Collectors.toList());
  218. //找到需要删除的id
  219. List<Long> BaseStudentFamilyMemberRemoveIds = BaseStudentFamilyMemberIds.stream().filter(item -> !BaseStudentFamilyMemberOldIds.contains(item)).collect(Collectors.toList());
  220. for (BaseStudentFamilyMember BaseStudentFamilyMember : baseStudentUser.getBaseStudentFamilyMemberList()) {
  221. //如果不等于空则修改
  222. if (BaseStudentFamilyMember.getId() != null) {
  223. familyMemberMapper.updateById(BaseStudentFamilyMember);
  224. }
  225. //如果等于空 则新增
  226. else {
  227. //已经不存在的id 删除
  228. BaseStudentFamilyMember.setUserId(baseStudentUser.getId());
  229. familyMemberMapper.insert(BaseStudentFamilyMember);
  230. }
  231. }
  232. //已经不存在的id 删除
  233. if (BaseStudentFamilyMemberRemoveIds.size() > 0) {
  234. familyMemberMapper.deleteBatchIds(BaseStudentFamilyMemberRemoveIds);
  235. }
  236. }
  237. //********************************* BaseStudentFamilyMember 增删改 结束 *******************************************/
  238. //********************************* StudentSchoolRoll 增删改 开始 *******************************************/
  239. {
  240. // 查出所有子级的id
  241. List<BaseStudentSchoolRoll> baseStudentSchoolRollList = schoolRollService.list(Wrappers.lambdaQuery(BaseStudentSchoolRoll.class).eq(BaseStudentSchoolRoll::getUserId, baseStudentUser.getId()).select(BaseStudentSchoolRoll::getId));
  242. List<Long> baseStudentSchoolRollIds = baseStudentSchoolRollList.stream().map(BaseStudentSchoolRoll::getId).collect(Collectors.toList());
  243. //原有子表单 没有被删除的主键
  244. List<Long> baseStudentSchoolRollOldIds = baseStudentUser.getBaseStudentSchoolRollList().stream().map(BaseStudentSchoolRoll::getId).filter(Objects::nonNull).collect(Collectors.toList());
  245. //找到需要删除的id
  246. List<Long> baseStudentSchoolRollRemoveIds = baseStudentSchoolRollIds.stream().filter(item -> !baseStudentSchoolRollOldIds.contains(item)).collect(Collectors.toList());
  247. for (BaseStudentSchoolRoll baseStudentSchoolRoll : baseStudentUser.getBaseStudentSchoolRollList()) {
  248. //如果不等于空则修改
  249. if (baseStudentSchoolRoll.getId() != null) {
  250. schoolRollService.updateById(baseStudentSchoolRoll);
  251. }
  252. //如果等于空 则新增
  253. else {
  254. //已经不存在的id 删除
  255. baseStudentSchoolRoll.setUserId(baseStudentUser.getId());
  256. schoolRollService.save(baseStudentSchoolRoll);
  257. }
  258. }
  259. //已经不存在的id 删除
  260. if (baseStudentSchoolRollRemoveIds.size() > 0) {
  261. schoolRollService.removeBatchByIds(baseStudentSchoolRollRemoveIds);
  262. }
  263. }
  264. //********************************* StudentSchoolRoll 增删改 结束 *******************************************/
  265. //********************************* BaseStudentSubsidize 增删改 开始 *******************************************/
  266. {
  267. // 查出所有子级的id
  268. List<BaseStudentSubsidize> baseStudentSubsidizeList = subsidizeService.list(Wrappers.lambdaQuery(BaseStudentSubsidize.class).eq(BaseStudentSubsidize::getUserId, baseStudentUser.getId()).select(BaseStudentSubsidize::getId));
  269. List<Long> baseStudentSubsidizeIds = baseStudentSubsidizeList.stream().map(BaseStudentSubsidize::getId).collect(Collectors.toList());
  270. //原有子表单 没有被删除的主键
  271. List<Long> baseStudentSubsidizeOldIds = baseStudentUser.getBaseStudentSubsidizeList().stream().map(BaseStudentSubsidize::getId).filter(Objects::nonNull).collect(Collectors.toList());
  272. //找到需要删除的id
  273. List<Long> baseStudentSubsidizeRemoveIds = baseStudentSubsidizeIds.stream().filter(item -> !baseStudentSubsidizeOldIds.contains(item)).collect(Collectors.toList());
  274. for (BaseStudentSubsidize BaseStudentEducation : baseStudentUser.getBaseStudentSubsidizeList()) {
  275. //如果不等于空则修改
  276. if (BaseStudentEducation.getId() != null) {
  277. subsidizeService.updateById(BaseStudentEducation);
  278. }
  279. //如果等于空 则新增
  280. else {
  281. //已经不存在的id 删除
  282. BaseStudentEducation.setUserId(baseStudentUser.getId());
  283. subsidizeService.save(BaseStudentEducation);
  284. }
  285. }
  286. //已经不存在的id 删除
  287. if (baseStudentSubsidizeRemoveIds.size() > 0) {
  288. subsidizeService.removeBatchByIds(baseStudentSubsidizeRemoveIds);
  289. }
  290. }
  291. //********************************* BaseStudentEducation 增删改 结束 *******************************************/
  292. return true;
  293. }
  294. @Override
  295. @Transactional(rollbackFor = Exception.class)
  296. public Boolean delete(List<Long> ids) {
  297. studentbaseManagerBaseStudentUserMapper.deleteBatchIds(ids);
  298. baseStudentService.remove(Wrappers.lambdaQuery(BaseStudent.class).in(BaseStudent::getUserId, ids));
  299. studentContactService.remove(Wrappers.lambdaQuery(BaseStudentContact.class).in(BaseStudentContact::getUserId, ids));
  300. familyMapper.delete(Wrappers.lambdaQuery(BaseStudentFamily.class).in(BaseStudentFamily::getUserId, ids));
  301. familyMemberMapper.delete(Wrappers.lambdaQuery(BaseStudentFamilyMember.class).in(BaseStudentFamilyMember::getUserId, ids));
  302. schoolRollService.remove(Wrappers.lambdaQuery(BaseStudentSchoolRoll.class).in(BaseStudentSchoolRoll::getUserId, ids));
  303. subsidizeService.remove(Wrappers.lambdaQuery(BaseStudentSubsidize.class).in(BaseStudentSubsidize::getUserId, ids));
  304. return true;
  305. }
  306. @Override
  307. public BaseStudentClassVo getStudentClass(Long userId) {
  308. MPJLambdaWrapper<BaseClass> queryWrapper = new MPJLambdaWrapper<>();
  309. queryWrapper
  310. .disableSubLogicDel()
  311. .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getClassId, BaseStudent::getId)
  312. .eq(BaseStudentSchoolRoll::getUserId, userId)
  313. .selectAsClass(BaseClass.class, BaseStudentClassVo.class);
  314. BaseClass baseClass = baseClassMapper.selectOne(queryWrapper);
  315. return BeanUtil.toBean(baseClass, BaseStudentClassVo.class);
  316. }
  317. /**
  318. * 个人财务画像,获取学生个人信息
  319. */
  320. @Override
  321. public PersonalPortraitPersonalInfoVo getPersonalInfo(Long userId) {
  322. StudentPersonalInfoVo info = baseStudentService.getPersonalInfo(userId);
  323. PersonalPortraitPersonalInfoVo p = new PersonalPortraitPersonalInfoVo();
  324. BeanUtils.copyProperties(info, p);
  325. List<BaseStudentFamilyMember> members = familyMemberMapper.selectList(
  326. new QueryWrapper<BaseStudentFamilyMember>().lambda()
  327. .eq(BaseStudentFamilyMember::getUserId, userId)
  328. .eq(BaseStudentFamilyMember::getIsGuardian, 1)
  329. );
  330. String guardianPhone = "";
  331. for (int i = 0; i < members.size(); i ++){
  332. if(i > 0){
  333. guardianPhone += ",";
  334. }
  335. guardianPhone += members.get(i).getMobile();
  336. }
  337. if(StrUtil.isNotEmpty(guardianPhone)){
  338. info.setGuardianPhone(guardianPhone);
  339. }
  340. return p;
  341. }
  342. @Override
  343. public Boolean importStudentData(List<Map<Integer, Object>> excelDataList) throws ParseException {
  344. List<String> idNumbers = new ArrayList<>();
  345. for (Map<Integer, Object> integerObjectMap : excelDataList) {
  346. idNumbers.add(integerObjectMap.get(0).toString());
  347. }
  348. //查询所有学生的用户信息,组装起来备用
  349. List<BaseStudentUser> studentUsers = this.selectJoinList(BaseStudentUser.class,
  350. new MPJLambdaWrapper<BaseStudentUser>()
  351. .leftJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentUser::getId)
  352. .in(BaseStudentUser::getCredentialNumber, idNumbers)
  353. );
  354. Map<String, BaseStudentUser> studentUserMap = new HashMap<>();
  355. Set<Long> userIds = new HashSet<>();
  356. for (BaseStudentUser studentUser : studentUsers) {
  357. studentUserMap.put(studentUser.getCredentialNumber(), studentUser);
  358. userIds.add(studentUser.getId());
  359. }
  360. //查询所有的学生信息,组装起来备用
  361. List<BaseStudent> baseStudents = baseStudentService.selectJoinList(BaseStudent.class,
  362. new MPJLambdaWrapper<BaseStudent>()
  363. .leftJoin(BaseStudentUser.class, BaseStudentUser::getId, BaseStudent::getUserId)
  364. .in(BaseStudentUser::getCredentialNumber, idNumbers)
  365. );
  366. Map<Long, BaseStudent> baseStudentMap = new HashMap<>();
  367. for (BaseStudent studentUser : baseStudents) {
  368. baseStudentMap.put(studentUser.getUserId(), studentUser);
  369. }
  370. //查询所用到的字典
  371. Map<String, String> dictionary = initDictionary();
  372. //查行政区划
  373. List<Area> areaList = areaService.list();
  374. Map<String, Long> areaMap = new HashMap<>();
  375. for (Area area : areaList) {
  376. areaMap.put(area.getName(), Long.parseLong(area.getCode()));
  377. }
  378. List<BaseStudentSchoolRoll> baseStudentSchoolRolls = schoolRollService.selectJoinList(BaseStudentSchoolRoll.class,
  379. new MPJLambdaWrapper<BaseStudentSchoolRoll>()
  380. .leftJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentSchoolRoll::getUserId)
  381. .in(!userIds.isEmpty(), BaseStudentSchoolRoll::getUserId, userIds)
  382. );
  383. Map<Long, BaseStudentSchoolRoll> studentSchoolRollMap = new HashMap<>();
  384. for (BaseStudentSchoolRoll schoolRoll : baseStudentSchoolRolls) {
  385. studentSchoolRollMap.put(schoolRoll.getUserId(), schoolRoll);
  386. }
  387. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  388. //查询年级
  389. List<BaseGrade> gradeList = baseGradeMapper.selectList(new QueryWrapper<BaseGrade>().lambda().eq(BaseGrade::getDeleteMark, DeleteMark.NODELETE.getCode()));
  390. Map<String, Long> gradeMap = new HashMap<>();
  391. for (BaseGrade grade : gradeList) {
  392. gradeMap.put(grade.getName(), grade.getId());
  393. }
  394. //查询班级
  395. List<BaseClass> classList = baseClassMapper.selectList(new QueryWrapper<BaseClass>().lambda().eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode()));
  396. Map<String, Long> classMap = new HashMap<>();
  397. for (BaseClass grade : classList) {
  398. classMap.put(grade.getName(), grade.getId());
  399. }
  400. //查询专业
  401. List<BaseMajorSet> majorSetList = baseMajorSetMapper.selectList(new QueryWrapper<BaseMajorSet>().lambda().eq(BaseMajorSet::getDeleteMark, DeleteMark.NODELETE.getCode()));
  402. Map<String, Long> majorSetMap = new HashMap<>();
  403. for (BaseMajorSet baseMajorSet : majorSetList) {
  404. majorSetMap.put(baseMajorSet.getName(), baseMajorSet.getId());
  405. }
  406. //查询资助
  407. List<BaseStudentSubsidize> baseStudentSubsidizes = subsidizeService.list(null);
  408. Map<Long, BaseStudentSubsidize> subsidizesMap = new HashMap<>();
  409. for (BaseStudentSubsidize el : baseStudentSubsidizes) {
  410. subsidizesMap.put(el.getUserId(), el);
  411. }
  412. //查询家庭
  413. List<BaseStudentFamily> studentFamilies = familyMapper.selectList(null);
  414. Map<Long, BaseStudentFamily> familyMap = new HashMap<>();
  415. for (BaseStudentFamily el : studentFamilies) {
  416. familyMap.put(el.getUserId(), el);
  417. }
  418. //查询联系信息
  419. List<BaseStudentContact> contactList = studentContactService.list();
  420. Map<Long, BaseStudentContact> contactMap = new HashMap<>();
  421. for (BaseStudentContact el : contactList) {
  422. contactMap.put(el.getUserId(), el);
  423. }
  424. List<BaseStudentUser> updateStudentUserList = new ArrayList();
  425. List<BaseStudent> updateBaseStudentList = new ArrayList();
  426. List<BaseStudentSchoolRoll> updateSchoolRollList = new ArrayList();
  427. List<BaseStudentSubsidize> updateSubsidizeList = new ArrayList();
  428. List<BaseStudentFamily> updateFamilyList = new ArrayList();
  429. List<BaseStudentContact> updateContactList = new ArrayList();
  430. List<BaseStudentUser> insertStudentUserList = new ArrayList();
  431. List<BaseStudent> insertBaseStudentList = new ArrayList();
  432. List<BaseStudentSchoolRoll> insertSchoolRollList = new ArrayList();
  433. List<BaseStudentSubsidize> insertSubsidizeList = new ArrayList();
  434. List<BaseStudentFamily> insertFamilyList = new ArrayList();
  435. List<BaseStudentContact> insertContactList = new ArrayList();
  436. // long createUserId = StpUtil.getLoginIdAsLong();
  437. long createUserId = 1000000000000000000L;
  438. int row = 3;
  439. for (Map<Integer, Object> dataMaps : excelDataList) {
  440. if(dataMaps.get(0) == null){
  441. throw new MyException("第" + row + "行数据身份证号为空,无法导入");
  442. }
  443. String credentialNumber = dataMaps.get(0).toString();//身份证号
  444. //已存在,更新
  445. BaseStudentUser user = studentUserMap.get(credentialNumber);
  446. BaseStudent baseStudent;
  447. BaseStudentSchoolRoll schoolRoll;
  448. BaseStudentSubsidize subsidize;
  449. BaseStudentFamily studentFamily;
  450. BaseStudentContact contact;
  451. long userId = IdUtil.getSnowflakeNextId();
  452. if(user != null){
  453. userId = user.getId();
  454. user.setDeleteMark(DeleteMark.NODELETE.getCode());
  455. baseStudent = baseStudentMap.get(user.getId());
  456. if(baseStudent == null){
  457. baseStudent = new BaseStudent();
  458. baseStudent.setUserId(userId);
  459. baseStudent.setCreateUserId(createUserId);
  460. baseStudent.setCreateDate(LocalDateTime.now());
  461. }
  462. baseStudent.setDeleteMark(DeleteMark.NODELETE.getCode());
  463. schoolRoll = studentSchoolRollMap.get(user.getId());
  464. if(schoolRoll == null){
  465. schoolRoll = new BaseStudentSchoolRoll();
  466. schoolRoll.setUserId(userId);
  467. schoolRoll.setCreateUserId(createUserId);
  468. schoolRoll.setCreateDate(LocalDateTime.now());
  469. }
  470. schoolRoll.setDeleteMark(DeleteMark.NODELETE.getCode());
  471. subsidize = subsidizesMap.get(user.getId());
  472. if(subsidize == null){
  473. subsidize = new BaseStudentSubsidize();
  474. subsidize.setUserId(userId);
  475. subsidize.setCreateUserId(createUserId);
  476. subsidize.setCreateDate(LocalDateTime.now());
  477. }
  478. subsidize.setDeleteMark(DeleteMark.NODELETE.getCode());
  479. studentFamily = familyMap.get(user.getId());
  480. if(studentFamily == null){
  481. studentFamily = new BaseStudentFamily();
  482. studentFamily.setUserId(userId);
  483. studentFamily.setCreateUserId(createUserId);
  484. studentFamily.setCreateDate(LocalDateTime.now());
  485. }
  486. studentFamily.setDeleteMark(DeleteMark.NODELETE.getCode());
  487. contact = contactMap.get(user.getId());
  488. if(contact == null){
  489. contact = new BaseStudentContact();
  490. contact.setUserId(userId);
  491. contact.setCreateUserId(createUserId);
  492. contact.setCreateDate(LocalDateTime.now());
  493. }
  494. contact.setDeleteMark(DeleteMark.NODELETE.getCode());
  495. }else{
  496. user = new BaseStudentUser();
  497. user.setId(userId);
  498. user.setUserName(credentialNumber);
  499. user.setCredentialNumber(credentialNumber);
  500. user.setCreateUserId(createUserId);
  501. user.setCreateDate(LocalDateTime.now());
  502. baseStudent = new BaseStudent();
  503. baseStudent.setUserId(userId);
  504. baseStudent.setCreateUserId(createUserId);
  505. baseStudent.setCreateDate(LocalDateTime.now());
  506. schoolRoll = new BaseStudentSchoolRoll();
  507. schoolRoll.setUserId(userId);
  508. schoolRoll.setCreateUserId(createUserId);
  509. schoolRoll.setCreateDate(LocalDateTime.now());
  510. subsidize = new BaseStudentSubsidize();
  511. subsidize.setUserId(userId);
  512. subsidize.setCreateUserId(createUserId);
  513. subsidize.setCreateDate(LocalDateTime.now());
  514. studentFamily = new BaseStudentFamily();
  515. studentFamily.setUserId(userId);
  516. studentFamily.setCreateUserId(createUserId);
  517. studentFamily.setCreateDate(LocalDateTime.now());
  518. contact = new BaseStudentContact();
  519. contact.setUserId(userId);
  520. contact.setCreateUserId(createUserId);
  521. contact.setCreateDate(LocalDateTime.now());
  522. }
  523. //设置字段值
  524. if(dataMaps.get(1) != null && !"".equals(dataMaps.get(1).toString())){
  525. baseStudent.setStudentId(dataMaps.get(1).toString());//学号
  526. }
  527. if(dataMaps.get(2) != null && !"".equals(dataMaps.get(2).toString())){
  528. schoolRoll.setCandidateNumber(dataMaps.get(2).toString());//考号
  529. }
  530. if(dataMaps.get(3) != null && !"".equals(dataMaps.get(3).toString())){
  531. user.setName(dataMaps.get(3).toString());//姓名
  532. }
  533. if(dataMaps.get(4) != null && !"".equals(dataMaps.get(4).toString())){
  534. user.setGender(GenderDictionaryEnum.getCode(dataMaps.get(4).toString()));//性别
  535. }
  536. if(dataMaps.get(5) != null && !"".equals(dataMaps.get(5).toString())){
  537. user.setMobile(dataMaps.get(5).toString());//手机号
  538. }
  539. if(dataMaps.get(6) != null && !"".equals(dataMaps.get(6).toString())){
  540. user.setEmail(dataMaps.get(6).toString());//邮箱
  541. }
  542. if(dataMaps.get(7) != null && !"".equals(dataMaps.get(7).toString())){
  543. baseStudent.setAsName(dataMaps.get(7).toString());//别名
  544. }
  545. if(dataMaps.get(8) != null && !"".equals(dataMaps.get(8).toString())){
  546. baseStudent.setEnName(dataMaps.get(8).toString());//英文名
  547. }
  548. if(dataMaps.get(9) != null && !"".equals(dataMaps.get(9).toString())){
  549. baseStudent.setPyName(dataMaps.get(9).toString());//姓名拼音
  550. }
  551. if(dataMaps.get(10) != null && !"".equals(dataMaps.get(10).toString())){
  552. baseStudent.setFormerName(dataMaps.get(10).toString());//曾用名
  553. }
  554. if(dataMaps.get(11) != null && !"".equals(dataMaps.get(11).toString())){
  555. user.setCredentialType(dictionary.get("credential_type" + dataMaps.get(11).toString()));//证件类型
  556. }
  557. if(dataMaps.get(12) != null && !"".equals(dataMaps.get(12).toString())){
  558. LocalDateTime birthday = parseLocalDateTime(dataMaps.get(12).toString());
  559. user.setBirthDate(birthday);//出生日期
  560. baseStudent.setDayOfBirth(birthday.toLocalDate());//出生日期
  561. }
  562. if(dataMaps.get(13) != null && !"".equals(dataMaps.get(13).toString())){
  563. baseStudent.setBirthType(dictionary.get("date_type" + dataMaps.get(13).toString()));//生日类型
  564. }
  565. if(dataMaps.get(14) != null && !"".equals(dataMaps.get(14).toString())){
  566. baseStudent.setNation(dictionary.get("nation" + dataMaps.get(14).toString()));//民族
  567. }
  568. if(dataMaps.get(15) != null && !"".equals(dataMaps.get(15).toString())){
  569. baseStudent.setBloodType(dictionary.get("blood_type" + dataMaps.get(15).toString()));//血型
  570. }
  571. if(dataMaps.get(16) != null && !"".equals(dataMaps.get(16).toString())){
  572. baseStudent.setHealth(dictionary.get("health" + dataMaps.get(16).toString()));//健康状况
  573. }
  574. if(dataMaps.get(17) != null && !"".equals(dataMaps.get(17).toString())){
  575. baseStudent.setMaritalState(dictionary.get("marital_state" + dataMaps.get(17).toString()));//婚姻状况
  576. }
  577. if(dataMaps.get(18) != null && !"".equals(dataMaps.get(18).toString())){
  578. baseStudent.setPoliticalState(dictionary.get("political_state" + dataMaps.get(18).toString()));//政治面貌
  579. }
  580. if(dataMaps.get(19) != null && !"".equals(dataMaps.get(19).toString())){
  581. baseStudent.setNationality(dictionary.get("nationality" + dataMaps.get(19).toString()));//国籍地区
  582. }
  583. if(dataMaps.get(20) != null && !"".equals(dataMaps.get(20).toString())){
  584. baseStudent.setChineseType(dictionary.get("chinese_type" + dataMaps.get(20).toString()));//港澳台侨外
  585. }
  586. if(dataMaps.get(21) != null && !"".equals(dataMaps.get(21).toString())){
  587. baseStudent.setHouseHoldType(dictionary.get("house_hold_type" + dataMaps.get(21).toString()));//户口类别
  588. }
  589. if(dataMaps.get(22) != null && !"".equals(dataMaps.get(22).toString())){
  590. baseStudent.setNativePlaceType(dataMaps.get(22).toString());//籍贯类型
  591. }
  592. if(dataMaps.get(23) != null && !"".equals(dataMaps.get(23).toString())){
  593. baseStudent.setProvinces(areaMap.get(dataMaps.get(23).toString()));//省
  594. }
  595. if(dataMaps.get(24) != null && !"".equals(dataMaps.get(24).toString())){
  596. baseStudent.setCity(areaMap.get(dataMaps.get(23).toString()));//市
  597. }
  598. if(dataMaps.get(25) != null && !"".equals(dataMaps.get(25).toString())){
  599. baseStudent.setDistrict(areaMap.get(dataMaps.get(25).toString()));//区县
  600. }
  601. if(dataMaps.get(26) != null && !"".equals(dataMaps.get(26).toString())){
  602. baseStudent.setHouseProvinces(areaMap.get(dataMaps.get(26).toString()));//户口所在地省
  603. }
  604. if(dataMaps.get(27) != null && !"".equals(dataMaps.get(27).toString())){
  605. baseStudent.setHouseCity(areaMap.get(dataMaps.get(27).toString()));//户口所在地市
  606. }
  607. if(dataMaps.get(28) != null && !"".equals(dataMaps.get(28).toString())){
  608. baseStudent.setHouseDistrict(areaMap.get(dataMaps.get(28).toString()));//户口所在地区/县
  609. }
  610. if(dataMaps.get(29) != null && !"".equals(dataMaps.get(29).toString())){
  611. baseStudent.setBelongsPolice(dataMaps.get(29).toString());//户口所属派出所
  612. }
  613. if(dataMaps.get(30) != null && !"".equals(dataMaps.get(30).toString())){
  614. baseStudent.setBirthProvinces(areaMap.get(dataMaps.get(30).toString()));//出生所在地省
  615. }
  616. if(dataMaps.get(31) != null && !"".equals(dataMaps.get(31).toString())){
  617. baseStudent.setBirthCity(areaMap.get(dataMaps.get(31).toString()));//出生所在地市
  618. }
  619. if(dataMaps.get(32) != null && !"".equals(dataMaps.get(32).toString())){
  620. baseStudent.setBirthDistrict(areaMap.get(dataMaps.get(32).toString()));//出生所在地/区县
  621. }
  622. if(dataMaps.get(33) != null && !"".equals(dataMaps.get(33).toString())){
  623. baseStudent.setHouseHoldAddress(dataMaps.get(33).toString());//户籍地址
  624. }
  625. if(dataMaps.get(34) != null && !"".equals(dataMaps.get(34).toString())){
  626. baseStudent.setResidenceType(dictionary.get("residence_type" + dataMaps.get(34).toString()));//学生居住地类型
  627. }
  628. if(dataMaps.get(35) != null && !"".equals(dataMaps.get(35).toString())){
  629. baseStudent.setTrainInterval(dataMaps.get(35).toString());//乘火车区间
  630. }
  631. if(dataMaps.get(36) != null && !"".equals(dataMaps.get(36).toString())){
  632. baseStudent.setIsMigrateChildren(YesOrNoEnum.getCode(dataMaps.get(36).toString()));//是否随迁子女
  633. }
  634. if(dataMaps.get(37) != null && !"".equals(dataMaps.get(37).toString())){
  635. baseStudent.setIsFloatingPopulation(YesOrNoEnum.getCode(dataMaps.get(37).toString()));//是否流动人口
  636. }
  637. if(dataMaps.get(38) != null && !"".equals(dataMaps.get(38).toString())){
  638. baseStudent.setHeight(Double.parseDouble(dataMaps.get(38).toString()));//身高
  639. }
  640. if(dataMaps.get(39) != null && !"".equals(dataMaps.get(39).toString())){
  641. baseStudent.setWeight(Double.parseDouble(dataMaps.get(39).toString()));//体重
  642. }
  643. if(dataMaps.get(40) != null && !"".equals(dataMaps.get(40).toString())){
  644. baseStudent.setVision(Double.parseDouble(dataMaps.get(40).toString()));//视力
  645. }
  646. if(dataMaps.get(41) != null && !"".equals(dataMaps.get(41).toString())){
  647. baseStudent.setSpecialty(dataMaps.get(41).toString());//特长
  648. }
  649. if(dataMaps.get(42) != null && !"".equals(dataMaps.get(42).toString())){
  650. user.setQqNumber(dataMaps.get(42).toString());//QQ&MSN
  651. contact.setQqMsn(dataMaps.get(42).toString());//QQ&MSN
  652. }
  653. if(dataMaps.get(43) != null && !"".equals(dataMaps.get(43).toString())){
  654. user.setWechatNumber(dataMaps.get(43).toString());//微信号码
  655. contact.setWechat(dataMaps.get(43).toString());//微信号码
  656. }
  657. if(dataMaps.get(44) != null && !"".equals(dataMaps.get(44).toString())){
  658. contact.setUserPage(dataMaps.get(44).toString());//个人主页
  659. }
  660. if(dataMaps.get(45) != null && !"".equals(dataMaps.get(45).toString())){
  661. schoolRoll.setRollNumber(dataMaps.get(45).toString());//学籍号
  662. }
  663. if(dataMaps.get(46) != null && !"".equals(dataMaps.get(46).toString())){
  664. schoolRoll.setArchivesNumber(dataMaps.get(46).toString());//学生档案编号
  665. }
  666. if(dataMaps.get(47) != null && !"".equals(dataMaps.get(47).toString())){
  667. schoolRoll.setEnrollmentDate(sdf.parse(dataMaps.get(47).toString()));//入学年月
  668. }
  669. if(dataMaps.get(48) != null && !"".equals(dataMaps.get(48).toString())){
  670. schoolRoll.setEnrollmentType(dictionary.get("enrollment_type" + dataMaps.get(48).toString()));//入学方式
  671. }
  672. if(dataMaps.get(49) != null && !"".equals(dataMaps.get(49).toString())){
  673. schoolRoll.setGradeId(gradeMap.get(dataMaps.get(49).toString()));//入学年级
  674. }
  675. if(dataMaps.get(50) != null && !"".equals(dataMaps.get(50).toString())){
  676. schoolRoll.setEnrollType(dictionary.get("enroll_type" + dataMaps.get(50).toString()));//入学招生类型
  677. }
  678. if(dataMaps.get(51) != null && !"".equals(dataMaps.get(51).toString())){
  679. schoolRoll.setMajorSetId(majorSetMap.get(dataMaps.get(51).toString()));//在读专业方向
  680. }
  681. if(dataMaps.get(52) != null && !"".equals(dataMaps.get(52).toString())){
  682. schoolRoll.setStudyYear(Double.parseDouble(dataMaps.get(52).toString()));//学制
  683. }
  684. if(dataMaps.get(53) != null && !"".equals(dataMaps.get(53).toString())){
  685. schoolRoll.setClassId(classMap.get(dataMaps.get(53).toString()));//班级
  686. }
  687. if(dataMaps.get(54) != null && !"".equals(dataMaps.get(54).toString())){
  688. schoolRoll.setStudentSource(dictionary.get("student_type" + dataMaps.get(54).toString()));//学生来源
  689. }
  690. if(dataMaps.get(55) != null && !"".equals(dataMaps.get(55).toString())){
  691. schoolRoll.setStudentType(dictionary.get("student_type" + dataMaps.get(55).toString()));//学生类别
  692. }
  693. if(dataMaps.get(56) != null && !"".equals(dataMaps.get(56).toString())){
  694. schoolRoll.setArchivesStatus(dictionary.get("archives_status" + dataMaps.get(56).toString()));//学籍状态
  695. }
  696. if(dataMaps.get(57) != null && !"".equals(dataMaps.get(57).toString())){
  697. schoolRoll.setLearnStatus(dictionary.get("roll_modality" + dataMaps.get(57).toString()));//学习形式
  698. }
  699. if(dataMaps.get(58) != null && !"".equals(dataMaps.get(58).toString())){
  700. schoolRoll.setStduyStatus(dictionary.get("stduy_status" + dataMaps.get(58).toString()));//就读方式
  701. }
  702. if(dataMaps.get(59) != null && !"".equals(dataMaps.get(59).toString())){
  703. schoolRoll.setChooseStatus(dictionary.get("choose_status" + dataMaps.get(59).toString()));//分流状态
  704. }
  705. if(dataMaps.get(60) != null && !"".equals(dataMaps.get(60).toString())){
  706. schoolRoll.setFosterType(dictionary.get("foster_type" + dataMaps.get(60).toString()));//分段培养方式
  707. }
  708. if(dataMaps.get(61) != null && !"".equals(dataMaps.get(61).toString())){
  709. schoolRoll.setRecruitType(dictionary.get("recruit_type" + dataMaps.get(61).toString()));//招生类型
  710. }
  711. if(dataMaps.get(62) != null && !"".equals(dataMaps.get(62).toString())){
  712. schoolRoll.setRecruitTarget(dictionary.get("recruit_target" + dataMaps.get(62).toString()));//招生对象
  713. }
  714. if(dataMaps.get(63) != null && !"".equals(dataMaps.get(63).toString())){
  715. schoolRoll.setHighestEducation(dictionary.get("education" + dataMaps.get(63).toString()));//入学前最高学历
  716. }
  717. if(dataMaps.get(64) != null && !"".equals(dataMaps.get(64).toString())){
  718. schoolRoll.setGraduatedUniversity(dataMaps.get(64).toString());//入学前毕业院校
  719. }
  720. if(dataMaps.get(65) != null && !"".equals(dataMaps.get(65).toString())){
  721. schoolRoll.setGraduatedScore(Double.parseDouble(dataMaps.get(65).toString()));//入学前毕业成绩
  722. }
  723. if(dataMaps.get(66) != null && !"".equals(dataMaps.get(66).toString())){
  724. schoolRoll.setExamineeNumber(dataMaps.get(66).toString());//入学考试准考证号
  725. }
  726. if(dataMaps.get(67) != null && !"".equals(dataMaps.get(67).toString())){
  727. schoolRoll.setTicketNumber(dataMaps.get(67).toString());//入学考试准考证号
  728. }
  729. if(dataMaps.get(68) != null && !"".equals(dataMaps.get(68).toString())){
  730. schoolRoll.setAdmissionScores(Double.parseDouble(dataMaps.get(68).toString()));//入学考试成绩
  731. }
  732. if(dataMaps.get(69) != null && !"".equals(dataMaps.get(69).toString())){
  733. schoolRoll.setRemark(dataMaps.get(69).toString());//备注
  734. }
  735. if(dataMaps.get(69) != null && !"".equals(dataMaps.get(69).toString())){
  736. schoolRoll.setRemark(dataMaps.get(69).toString());//备注
  737. }
  738. if(dataMaps.get(70) != null && !"".equals(dataMaps.get(70).toString())){
  739. subsidize.setIsIndemnify(YesOrNoEnum.getCode(dataMaps.get(70).toString()));//是否低保户
  740. }
  741. if(dataMaps.get(71) != null && !"".equals(dataMaps.get(71).toString())){
  742. subsidize.setIsStipend(YesOrNoEnum.getCode(dataMaps.get(71).toString()));//是否享受国家助学金
  743. }
  744. if(dataMaps.get(72) != null && !"".equals(dataMaps.get(72).toString())){
  745. subsidize.setStipendStand(Double.parseDouble(dataMaps.get(72).toString()));//助学金发放标准(元)
  746. }
  747. if(dataMaps.get(73) != null && !"".equals(dataMaps.get(73).toString())){
  748. subsidize.setStipendNumber(dataMaps.get(73).toString());//学生资助卡号
  749. }
  750. if(dataMaps.get(74) != null && !"".equals(dataMaps.get(74).toString())){
  751. subsidize.setIsFree(YesOrNoEnum.getCode(dataMaps.get(74).toString()));//是否免学费
  752. }
  753. if(dataMaps.get(75) != null && !"".equals(dataMaps.get(75).toString())){
  754. subsidize.setIsFilingCard(YesOrNoEnum.getCode(dataMaps.get(75).toString()));//是否建档立卡
  755. }
  756. if(dataMaps.get(76) != null && !"".equals(dataMaps.get(76).toString())){
  757. studentFamily.setZipCode(dataMaps.get(76).toString());//家庭邮编
  758. }
  759. if(dataMaps.get(77) != null && !"".equals(dataMaps.get(77).toString())){
  760. studentFamily.setTelephone(dataMaps.get(77).toString());//家庭电话
  761. }
  762. if(dataMaps.get(78) != null && !"".equals(dataMaps.get(78).toString())){
  763. studentFamily.setContact(dataMaps.get(76).toString());//联系人姓名
  764. }
  765. if(dataMaps.get(79) != null && !"".equals(dataMaps.get(79).toString())){
  766. studentFamily.setPopulation(Integer.parseInt(dataMaps.get(79).toString()));//家庭人口
  767. }
  768. if(dataMaps.get(80) != null && !"".equals(dataMaps.get(80).toString())){
  769. studentFamily.setAddress(dataMaps.get(80).toString());//家庭地址
  770. }
  771. if(dataMaps.get(81) != null && !"".equals(dataMaps.get(81).toString())){
  772. studentFamily.setIncomeSource(dataMaps.get(81).toString());//家庭主要收入来源
  773. }
  774. if(dataMaps.get(82) != null && !"".equals(dataMaps.get(82).toString())){
  775. studentFamily.setIncomeNumber(Double.parseDouble(dataMaps.get(82).toString()));//家庭月收入(元)
  776. }
  777. if(dataMaps.get(83) != null && !"".equals(dataMaps.get(83).toString())){
  778. studentFamily.setRailwayStation(dataMaps.get(83).toString());//离家最近火车站
  779. }
  780. if(studentUserMap.containsKey(credentialNumber)){
  781. updateStudentUserList.add(user);
  782. updateBaseStudentList.add(baseStudent);
  783. updateSchoolRollList.add(schoolRoll);
  784. updateSubsidizeList.add(subsidize);
  785. updateFamilyList.add(studentFamily);
  786. updateContactList.add(contact);
  787. }else{
  788. insertStudentUserList.add(user);
  789. insertBaseStudentList.add(baseStudent);
  790. if(schoolRoll.getClassId() != null && schoolRoll.getGradeId() != null && schoolRoll.getMajorSetId() != null){
  791. insertSchoolRollList.add(schoolRoll);
  792. }
  793. insertSubsidizeList.add(subsidize);
  794. insertFamilyList.add(studentFamily);
  795. insertContactList.add(contact);
  796. }
  797. row ++;
  798. }
  799. //批量修改
  800. if(!updateStudentUserList.isEmpty()){
  801. this.updateBatchById(updateStudentUserList);
  802. }
  803. if(!updateSchoolRollList.isEmpty()){
  804. schoolRollService.updateBatchById(updateSchoolRollList);
  805. }
  806. if(!updateSubsidizeList.isEmpty()){
  807. subsidizeService.updateBatchById(updateSubsidizeList);
  808. }
  809. if(!updateFamilyList.isEmpty()){
  810. familyService.updateBatchById(updateFamilyList);
  811. }
  812. if(!updateBaseStudentList.isEmpty()){
  813. baseStudentService.updateBatchById(updateBaseStudentList);
  814. }
  815. if(!updateContactList.isEmpty()){
  816. studentContactService.updateBatchById(updateContactList);
  817. }
  818. //批量新增
  819. if(!insertStudentUserList.isEmpty()){
  820. this.saveBatch(insertStudentUserList);
  821. }
  822. if(!insertBaseStudentList.isEmpty()){
  823. baseStudentService.saveBatch(insertBaseStudentList);
  824. }
  825. if(!insertSubsidizeList.isEmpty()){
  826. subsidizeService.saveBatch(insertSubsidizeList);
  827. }
  828. if(!insertFamilyList.isEmpty()){
  829. familyService.saveBatch(insertFamilyList);
  830. }
  831. if(!insertSchoolRollList.isEmpty()){
  832. schoolRollService.saveBatch(insertSchoolRollList);
  833. }
  834. if(!insertContactList.isEmpty()){
  835. studentContactService.saveBatch(insertContactList);
  836. }
  837. return true;
  838. }
  839. /**
  840. * 初始化字典信息
  841. * 身份证类型、
  842. */
  843. private Map<String, String> initDictionary(){
  844. List<String> codeList = new ArrayList<>();
  845. codeList.add("credential_type");codeList.add("nation");
  846. codeList.add("blood_type");codeList.add("health");
  847. codeList.add("marital_state");codeList.add("political_state");
  848. codeList.add("nationality");codeList.add("chinese_type");
  849. codeList.add("house_hold_type");codeList.add("residence_type");
  850. codeList.add("enrollment_type");codeList.add("enroll_type");
  851. codeList.add("student_type");codeList.add("archives_status");
  852. codeList.add("roll_modality");codeList.add("stduy_status");
  853. codeList.add("choose_status");codeList.add("foster_type");
  854. codeList.add("recruit_type");codeList.add("recruit_target");
  855. codeList.add("education");codeList.add("recruit_target");
  856. codeList.add("date_type");
  857. List<DictionaryDetail> detailList = dictionarydetailMapper.selectJoinList(DictionaryDetail.class,
  858. new MPJLambdaWrapper<DictionaryDetail>()
  859. .leftJoin(DictionaryItem.class, DictionaryItem::getId, DictionaryDetail::getItemId)
  860. .in(DictionaryItem::getCode, codeList)
  861. );
  862. List<DictionaryItem> dictionaryItemList = dictionaryitemMapper.selectList(
  863. new QueryWrapper<DictionaryItem>().lambda()
  864. .eq(DictionaryItem::getDeleteMark, DeleteMark.NODELETE.getCode())
  865. );
  866. Map<Long, String> itemMap = new HashMap<>();
  867. for (DictionaryItem dictionaryItem : dictionaryItemList) {
  868. itemMap.put(dictionaryItem.getId(), dictionaryItem.getCode());
  869. }
  870. Map<String, String> resultMap = new HashMap<>();
  871. for (DictionaryDetail dictionaryDetail : detailList) {
  872. resultMap.put(itemMap.get(dictionaryDetail.getItemId()) + dictionaryDetail.getName(), dictionaryDetail.getCode());
  873. }
  874. return resultMap;
  875. }
  876. private LocalDateTime parseLocalDateTime(String dateStr){
  877. LocalDate time = null;
  878. try {
  879. time = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
  880. }catch (DateTimeParseException e){
  881. try {
  882. time = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy/MM/dd"));
  883. }catch (DateTimeParseException e2){
  884. try {
  885. time = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy年MM月dd日"));
  886. }catch (DateTimeParseException e3){
  887. try {
  888. time = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyyMMdd"));
  889. }catch (DateTimeParseException e4){
  890. throw new MyException("日期格式不正确");
  891. }
  892. }
  893. }
  894. }
  895. if(time != null){
  896. return time.atStartOfDay();
  897. }
  898. return null;
  899. }
  900. }