StudentManagerServiceImpl.java 51 KB

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