StudentManagerServiceImpl.java 53 KB

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