WelcomeStudentController.java 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631
  1. package com.template.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.auth0.jwt.interfaces.Claim;
  4. import com.baomidou.mybatisplus.core.conditions.Wrapper;
  5. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  6. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  7. import com.baomidou.mybatisplus.extension.api.R;
  8. import com.template.annotation.PassToken;
  9. import com.template.api.WelcomeStudentControllerAPI;
  10. import com.template.common.utils.ExcelUtils;
  11. import com.template.common.utils.JWTUtil;
  12. import com.template.common.utils.TimeExchange;
  13. import com.template.common.utils.paramUtils;
  14. import com.template.model.enumModel.eFileType;
  15. import com.template.model.enumModel.eProjectType;
  16. import com.template.model.pojo.*;
  17. import com.template.model.request.*;
  18. import com.template.model.result.CommonResult;
  19. import com.template.model.result.PageUtils;
  20. import com.template.model.vo.*;
  21. import com.template.services.*;
  22. import io.swagger.annotations.ApiModelProperty;
  23. import org.apache.poi.hssf.usermodel.HSSFRow;
  24. import org.apache.poi.hssf.usermodel.HSSFSheet;
  25. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  26. import org.apache.poi.ss.usermodel.DataFormatter;
  27. import org.apache.poi.ss.usermodel.Row;
  28. import org.apache.poi.ss.usermodel.Sheet;
  29. import org.apache.poi.ss.usermodel.Workbook;
  30. import org.apache.poi.xssf.usermodel.XSSFRow;
  31. import org.apache.poi.xssf.usermodel.XSSFSheet;
  32. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  33. import org.slf4j.Logger;
  34. import org.slf4j.LoggerFactory;
  35. import org.springframework.beans.factory.annotation.Autowired;
  36. import org.springframework.transaction.annotation.Transactional;
  37. import org.springframework.util.StringUtils;
  38. import org.springframework.validation.BindingResult;
  39. import org.springframework.web.bind.annotation.RestController;
  40. import org.springframework.web.multipart.MultipartFile;
  41. import javax.servlet.http.HttpServletResponse;
  42. import java.io.IOException;
  43. import java.io.InputStream;
  44. import java.math.BigDecimal;
  45. import java.math.BigInteger;
  46. import java.math.RoundingMode;
  47. import java.text.ParseException;
  48. import java.time.LocalDateTime;
  49. import java.time.format.DateTimeFormatter;
  50. import java.util.*;
  51. import java.util.stream.Collectors;
  52. /**
  53. * <p>
  54. * 前端控制器
  55. * </p>
  56. *
  57. * @author ceshi
  58. * @since 2025-06-13
  59. */
  60. @RestController
  61. public class WelcomeStudentController implements WelcomeStudentControllerAPI {
  62. @Autowired
  63. private WelcomeStudentService welcomeStudentService;
  64. @Autowired
  65. private WelcomeFamilyService welcomeFamilyService;
  66. @Autowired
  67. private WelcomeAccompanyService welcomeAccompanyService;
  68. @Autowired
  69. private WelcomeBedService welcomeBedService;
  70. @Autowired
  71. private WelcomeSettingService welcomeSettingService;
  72. @Autowired
  73. private WelcomeArriveSettingService welcomeArriveSettingService;
  74. @Autowired
  75. private WelcomeOrgService welcomeOrgService;
  76. @Autowired
  77. private WelcomeCityService welcomeCityService;
  78. @Autowired
  79. private WelcomeSchoolService welcomeSchoolService;
  80. @Autowired
  81. private WelcomeBuildService welcomeBuildService;
  82. @Autowired
  83. private WelcomeDormitoryService welcomeDormitoryService;
  84. @Autowired
  85. private WelcomeVisitorService welcomeVisitorService;
  86. @Autowired
  87. private WelcomePaySettingService welcomePaySettingService;
  88. private static Logger logger = LoggerFactory.getLogger(WelcomeStudentController.class);
  89. @Override
  90. @Transactional(rollbackFor = {Exception.class})
  91. public CommonResult insertStudentInfo(InsertStudentRequest isr, BindingResult bindingResult) throws Exception {
  92. if (bindingResult.hasErrors()) {
  93. String st = paramUtils.getParamError(bindingResult);
  94. return CommonResult.fail(st);
  95. }
  96. int existCount = welcomeStudentService.existStudentInfo(isr.getAdmissNum(), isr.getCardId());
  97. if (existCount > 0) {
  98. return CommonResult.fail("当前录取号或身份证号已存在!");
  99. }
  100. //region 学生信息
  101. WelcomeStudent ws = new WelcomeStudent();
  102. ws.setAdmissNum(isr.getAdmissNum());
  103. ws.setName(isr.getName());
  104. ws.setPicture(isr.getPicture());
  105. ws.setCardId(isr.getCardId());
  106. ws.setSex(isr.getSex());
  107. ws.setBirthday(isr.getBirthday());
  108. ws.setSchool(isr.getSchool());
  109. ws.setSchoolId(isr.getSchoolId());
  110. ws.setCollege(isr.getCollege());
  111. ws.setMajor(isr.getMajor());
  112. ws.setClassstr(isr.getClassstr());
  113. ws.setCollegeId(isr.getCollegeId());
  114. ws.setMajorId(isr.getMajorId());
  115. ws.setClassstrId(isr.getClassstrId());
  116. ws.setExamNum(isr.getExamNum());
  117. ws.setEduSystem(isr.getEduSystem());
  118. ws.setGraduationSchool(isr.getGraduationSchool());
  119. ws.setBatchValue(isr.getBatchValue());
  120. ws.setPoliticalStatu(isr.getPoliticalStatu());
  121. ws.setNationality(isr.getNationality());
  122. ws.setPhone(isr.getPhone());
  123. ws.setOprovince(isr.getOprovince());
  124. ws.setOcity(isr.getOcity());
  125. ws.setOdistrict(isr.getOdistrict());
  126. ws.setOprovinceId(isr.getOprovinceId());
  127. ws.setOcityId(isr.getOcityId());
  128. ws.setOdistrictId(isr.getOdistrictId());
  129. ws.setProvinceId(isr.getProvinceId());
  130. ws.setCityId(isr.getCityId());
  131. ws.setDistrictId(isr.getDistrictId());
  132. ws.setProvince(isr.getProvince());
  133. ws.setCity(isr.getCity());
  134. ws.setDistrict(isr.getDistrict());
  135. ws.setAddress(isr.getAddress());
  136. ws.setTrafficMethod(isr.getTrafficMethod());
  137. ws.setArrive(isr.getArrive());
  138. ws.setArrvieDate(isr.getArrvieDate());
  139. ws.setArriveTime(isr.getArriveTime());
  140. ws.setArriveTimeId(isr.getArriveTimeId());
  141. ws.setZipCode(isr.getZipCode());
  142. ws.setRegisterOntime(isr.getRegisterOntime());
  143. ws.setIdenType(1);
  144. ws.setFillStatus("未填报");
  145. //ws.setAmountPayable(isr.getAmountPayable());
  146. //ws.setPayAmount(isr.getPayAmount());
  147. //ws.setIsDrive(isr.getIsDrive());
  148. //ws.setCarNumber(isr.getCarNumber());
  149. //endregion
  150. //region 家庭成员数据
  151. List<WelcomeFamily> wfs = new ArrayList<>();
  152. if (isr.getFvs() != null && isr.getFvs().size() > 0) {
  153. for (InsertFamilyRequest family : isr.getFvs()) {
  154. if (!(StringUtils.hasText(family.getFamilyShip()) && StringUtils.hasText(family.getName())
  155. && StringUtils.hasText(family.getWorkUnit()) && StringUtils.hasText(family.getPhone()))) {
  156. return CommonResult.fail("家庭成员信息不能为空!");
  157. }
  158. WelcomeFamily wf = new WelcomeFamily();
  159. wf.setStudentCard(ws.getCardId());
  160. wf.setFamilyShip(family.getFamilyShip());
  161. wf.setName(family.getName());
  162. wf.setWorkUnit(family.getWorkUnit());
  163. wf.setPhone(family.getPhone());
  164. wfs.add(wf);
  165. }
  166. }
  167. //endregion
  168. // //region 陪同人员数据
  169. // List<WelcomeAccompany> was = new ArrayList<>();
  170. // if (isr.getAvs() != null && isr.getAvs().size() > 0) {
  171. // for (InsertAccompanyRequest accompany : isr.getAvs()) {
  172. // if (!(StringUtils.hasText(accompany.getName()) && StringUtils.hasText(accompany.getPhone()))) {
  173. // return CommonResult.fail("陪同人员信息不能为空!");
  174. // }
  175. // WelcomeAccompany wa = new WelcomeAccompany();
  176. // wa.setStudentCard(ws.getCardId());
  177. // wa.setName(accompany.getName());
  178. // wa.setPhone(accompany.getPhone());
  179. // was.add(wa);
  180. // }
  181. // }
  182. //
  183. // //endregion
  184. //
  185. // //region 宿舍信息
  186. // WelcomeBed bedData = welcomeBedService.queryBedData(isr.getSchool(), isr.getBuildId(), isr.getDormitoryId(), Integer.valueOf(isr.getBed()));
  187. // if (bedData != null) {
  188. // if (StringUtils.hasText(bedData.getStudentCard())) {
  189. // return CommonResult.fail("当前床位已被他人入住,无法入住");
  190. // }
  191. // bedData.setStudentCard(isr.getCardId());
  192. // bedData.setCollege(isr.getCollege());
  193. // bedData.setCollegeId(isr.getCollegeId());
  194. // bedData.setMajor(isr.getMajor());
  195. // bedData.setMajorId(isr.getMajorId());
  196. // bedData.setClassstr(isr.getClassstr());
  197. // bedData.setClassstrId(isr.getClassstrId());
  198. // bedData.setIsCheck(1);
  199. // bedData.setCardNum(isr.getAdmissNum());
  200. // bedData.setName(isr.getName());
  201. // }
  202. //
  203. // //endregion
  204. try {
  205. int studentId = welcomeStudentService.insertWelcomeStudent(ws);
  206. if (studentId <= 0) {
  207. logger.error("添加学生失败,参数:" + JSON.toJSON(isr));
  208. throw new Exception("添加失败!");
  209. }
  210. if (wfs != null && wfs.size() > 0) {
  211. boolean insertBatch = welcomeFamilyService.saveBatch(wfs);
  212. if (!insertBatch) {
  213. logger.error("添加家庭成员失败,参数:" + JSON.toJSON(wfs));
  214. throw new Exception("添加失败!");
  215. }
  216. }
  217. // if (was != null && was.size() > 0) {
  218. // boolean insertBatch = welcomeAccompanyService.saveBatch(was);
  219. // if (!insertBatch) {
  220. // logger.error("添加陪同人员失败,参数:" + JSON.toJSON(was));
  221. // throw new Exception("添加失败!");
  222. // }
  223. // }
  224. //
  225. // int insertStudentDormitory = welcomeBedService.updateWelcomeBed(bedData);
  226. // if (insertStudentDormitory <= 0) {
  227. // logger.error("添加学生床位信息失败,参数:" + JSON.toJSON(bedData));
  228. // throw new Exception("添加失败!");
  229. // }
  230. } catch (Exception e) {
  231. logger.error(e.getMessage());
  232. throw new Exception("添加失败!");
  233. }
  234. return CommonResult.ok("添加成功");
  235. }
  236. @Override
  237. public CommonResult updateStudentInfo(updateStudentRequest usr, BindingResult bindingResult) throws Exception {
  238. if (bindingResult.hasErrors()) {
  239. String st = paramUtils.getParamError(bindingResult);
  240. return CommonResult.fail(st);
  241. }
  242. WelcomeStudent student = welcomeStudentService.getManageById(usr.getId());
  243. if (student == null) {
  244. return CommonResult.fail("学生数据已失效,编辑失败!");
  245. }
  246. //region 学生信息
  247. student.setAdmissNum(usr.getAdmissNum());
  248. student.setName(usr.getName());
  249. student.setPicture(usr.getPicture());
  250. //student.setCardId(usr.getCardId());
  251. student.setSex(usr.getSex());
  252. student.setBirthday(usr.getBirthday());
  253. student.setSchool(usr.getSchool());
  254. student.setSchoolId(usr.getSchoolId());
  255. student.setCollege(usr.getCollege());
  256. student.setMajor(usr.getMajor());
  257. student.setClassstr(usr.getClassstr());
  258. student.setCollegeId(usr.getCollegeId());
  259. student.setMajorId(usr.getMajorId());
  260. student.setClassstrId(usr.getClassstrId());
  261. student.setExamNum(usr.getExamNum());
  262. student.setEduSystem(usr.getEduSystem());
  263. student.setGraduationSchool(usr.getGraduationSchool());
  264. student.setBatchValue(usr.getBatchValue());
  265. student.setPoliticalStatu(usr.getPoliticalStatu());
  266. student.setNationality(usr.getNationality());
  267. student.setPhone(usr.getPhone());
  268. student.setOprovince(usr.getOprovince());
  269. student.setOcity(usr.getOcity());
  270. student.setOdistrict(usr.getOdistrict());
  271. student.setOprovinceId(usr.getOprovinceId());
  272. student.setOcityId(usr.getOcityId());
  273. student.setOdistrictId(usr.getOdistrictId());
  274. student.setProvinceId(usr.getProvinceId());
  275. student.setCityId(usr.getCityId());
  276. student.setDistrictId(usr.getDistrictId());
  277. student.setProvince(usr.getProvince());
  278. student.setCity(usr.getCity());
  279. student.setDistrict(usr.getDistrict());
  280. student.setAddress(usr.getAddress());
  281. student.setTrafficMethod(usr.getTrafficMethod());
  282. student.setArrive(usr.getArrive());
  283. student.setArrvieDate(usr.getArrvieDate());
  284. student.setArriveTime(usr.getArriveTime());
  285. student.setArriveTimeId(usr.getArriveTimeId());
  286. student.setZipCode(usr.getZipCode());
  287. student.setRegisterOntime(usr.getRegisterOntime());
  288. student.setIdenType(1);
  289. //ws.setAmountPayable(isr.getAmountPayable());
  290. //ws.setPayAmount(isr.getPayAmount());
  291. //ws.setIsDrive(isr.getIsDrive());
  292. //ws.setCarNumber(isr.getCarNumber());
  293. //endregion
  294. //region 家庭成员数据
  295. List<WelcomeFamily> wfs = new ArrayList<>();
  296. if (usr.getFvs() != null && usr.getFvs().size() > 0) {
  297. for (InsertFamilyRequest family : usr.getFvs()) {
  298. if (!(StringUtils.hasText(family.getFamilyShip()) && StringUtils.hasText(family.getName())
  299. && StringUtils.hasText(family.getWorkUnit()) && StringUtils.hasText(family.getPhone()))) {
  300. return CommonResult.fail("家庭成员信息不能为空!");
  301. }
  302. WelcomeFamily wf = new WelcomeFamily();
  303. wf.setStudentCard(student.getCardId());
  304. wf.setFamilyShip(family.getFamilyShip());
  305. wf.setName(family.getName());
  306. wf.setWorkUnit(family.getWorkUnit());
  307. wf.setPhone(family.getPhone());
  308. wfs.add(wf);
  309. }
  310. }
  311. //endregion
  312. // //region 陪同人员数据
  313. // List<WelcomeAccompany> was = new ArrayList<>();
  314. // if (usr.getAvs() != null && usr.getAvs().size() > 0) {
  315. // for (InsertAccompanyRequest accompany : usr.getAvs()) {
  316. // if (!(StringUtils.hasText(accompany.getName()) && StringUtils.hasText(accompany.getPhone()))) {
  317. // return CommonResult.fail("陪同人员信息不能为空!");
  318. // }
  319. // WelcomeAccompany wa = new WelcomeAccompany();
  320. // wa.setStudentCard(student.getCardId());
  321. // wa.setName(accompany.getName());
  322. // wa.setPhone(accompany.getPhone());
  323. // was.add(wa);
  324. // }
  325. // }
  326. //
  327. // //endregion
  328. //
  329. // //region 宿舍信息
  330. // List<WelcomeBed> bedDatas = new ArrayList<>();
  331. // WelcomeBed bedData = welcomeBedService.queryBedData(usr.getSchool(), usr.getBuildId(), usr.getDormitoryId(), Integer.valueOf(usr.getBed()));
  332. // if (bedData != null) {//新床位
  333. // if (StringUtils.hasText(bedData.getStudentCard()) && !bedData.getStudentCard().equals(student.getCardId())) {
  334. // return CommonResult.fail("当前床位已被他人入住,无法入住");
  335. // }
  336. // if (!StringUtils.hasText(bedData.getStudentCard())) {
  337. // bedData.setStudentCard(student.getCardId());
  338. // bedData.setCollege(student.getCollege());
  339. // bedData.setCollegeId(student.getCollegeId());
  340. // bedData.setMajor(student.getMajor());
  341. // bedData.setMajorId(student.getMajorId());
  342. // bedData.setClassstr(student.getClassstr());
  343. // bedData.setClassstrId(student.getClassstrId());
  344. // bedData.setIsCheck(1);
  345. // bedData.setCardNum(student.getAdmissNum());
  346. // bedData.setName(student.getName());
  347. //
  348. // //把旧床位清空
  349. // WelcomeBed obedData = welcomeBedService.getBedByCardId(student.getCardId());
  350. // if (obedData == null) {
  351. // obedData = new WelcomeBed();
  352. // obedData.setStudentCard(null);
  353. // obedData.setCollege(null);
  354. // obedData.setCollegeId(null);
  355. // obedData.setMajor(null);
  356. // obedData.setMajorId(null);
  357. // obedData.setClassstr(null);
  358. // obedData.setClassstrId(null);
  359. // obedData.setIsCheck(0);
  360. // obedData.setCardNum(null);
  361. // obedData.setName(null);
  362. // bedDatas.add(obedData);
  363. // }
  364. // } else {
  365. // bedData.setStudentCard(student.getCardId());
  366. // bedData.setCollege(student.getCollege());
  367. // bedData.setCollegeId(student.getCollegeId());
  368. // bedData.setMajor(student.getMajor());
  369. // bedData.setMajorId(student.getMajorId());
  370. // bedData.setClassstr(student.getClassstr());
  371. // bedData.setClassstrId(student.getClassstrId());
  372. // bedData.setIsCheck(1);
  373. // bedData.setCardNum(student.getAdmissNum());
  374. // bedData.setName(student.getName());
  375. // }
  376. // bedDatas.add(bedData);
  377. //
  378. // }
  379. //
  380. // //endregion
  381. try {
  382. int studentId = welcomeStudentService.updateWelcomeStudent(student);
  383. if (studentId <= 0) {
  384. logger.error("编辑学生失败,参数:" + JSON.toJSON(usr));
  385. throw new Exception("编辑失败!");
  386. }
  387. int deleteF = welcomeFamilyService.deleteWelcomeFamilyByCard(student.getCardId());
  388. if (wfs != null && wfs.size() > 0) {
  389. boolean insertBatch = welcomeFamilyService.saveBatch(wfs);
  390. if (!insertBatch) {
  391. logger.error("编辑家庭成员失败,参数:" + JSON.toJSON(wfs));
  392. throw new Exception("编辑失败!");
  393. }
  394. }
  395. // int deleteA = welcomeAccompanyService.deleteWelcomeAccompanyByCard(student.getCardId());
  396. // if (was != null && was.size() > 0) {
  397. // boolean insertBatch = welcomeAccompanyService.saveBatch(was);
  398. // if (!insertBatch) {
  399. // logger.error("编辑陪同人员失败,参数:" + JSON.toJSON(was));
  400. // throw new Exception("编辑失败!");
  401. // }
  402. // }
  403. //
  404. // boolean updateBatch = welcomeBedService.updateBatchById(bedDatas);
  405. // if (!updateBatch) {
  406. // logger.error("添加宿舍信息失败,参数:" + JSON.toJSON(bedDatas));
  407. // throw new Exception("添加失败!");
  408. // }
  409. } catch (Exception e) {
  410. logger.error(e.getMessage());
  411. throw new Exception("编辑失败!");
  412. }
  413. return CommonResult.ok("编辑成功");
  414. }
  415. @Override
  416. public CommonResult queryPageStudents(int currentPage, int pageCount, Integer collegeId, Integer majorId, Integer classstrId, String trafficMethod, String name) {
  417. PageUtils<StudentPageVo> result = welcomeStudentService.queryStudentPageList(currentPage, pageCount, collegeId, majorId, classstrId, trafficMethod, name);
  418. return CommonResult.ok(result);
  419. }
  420. @Override
  421. public CommonResult queryStudentDetail(int id) {
  422. StudentDetailVo result = new StudentDetailVo();
  423. WelcomeStudent ws = welcomeStudentService.getManageById(id);
  424. if (ws == null) {
  425. return CommonResult.ok("学生信息已失效,查看失败!");
  426. }
  427. //家庭成员
  428. List<FamilyVo> fvs = new ArrayList<>();
  429. List<WelcomeFamily> familys = welcomeFamilyService.getManageByCardId(ws.getCardId());
  430. if (familys != null && familys.size() > 0) {
  431. for (WelcomeFamily wf : familys) {
  432. FamilyVo fv = new FamilyVo();
  433. fv.setId(wf.getId());
  434. fv.setFamilyShip(wf.getFamilyShip());
  435. fv.setName(wf.getName());
  436. fv.setPhone(wf.getPhone());
  437. fv.setWorkUnit(wf.getWorkUnit());
  438. fvs.add(fv);
  439. }
  440. }
  441. result.setFvs(fvs);
  442. //陪同人员
  443. List<AccompanyVo> avs = new ArrayList<>();
  444. List<WelcomeAccompany> accompanys = welcomeAccompanyService.getManageByCardId(ws.getCardId());
  445. if (accompanys != null && accompanys.size() > 0) {
  446. for (WelcomeAccompany ac : accompanys) {
  447. AccompanyVo av = new AccompanyVo();
  448. av.setId(ac.getId());
  449. av.setName(ac.getName());
  450. av.setPhone(ac.getPhone());
  451. avs.add(av);
  452. }
  453. }
  454. result.setAvs(avs);
  455. //宿舍信息
  456. WelcomeBed wsd = welcomeBedService.getBedByCardId(ws.getCardId());
  457. if (wsd != null) {
  458. result.setBuild(wsd.getBuild());
  459. result.setBuildId(wsd.getBuildId());
  460. result.setDormitory(wsd.getDormitory());//寝室号
  461. result.setDormitoryId(wsd.getDormitoryId());//寝室号
  462. result.setBed(String.valueOf(wsd.getNumber()));//床位号
  463. result.setBedId(wsd.getId());//床位号
  464. }
  465. //时间段
  466. List<ArriveTimeVo> atvs = new ArrayList<>();
  467. List<WelcomeArriveSetting> wass = welcomeArriveSettingService.queryCheckDatas();
  468. if (wass != null && wass.size() > 0) {
  469. for (WelcomeArriveSetting was : wass) {
  470. ArriveTimeVo atv = new ArriveTimeVo();
  471. atv.setId(was.getId());
  472. atv.setStartTime(was.getStartTime());
  473. atv.setEndTime(was.getEndTime());
  474. atv.setTimeStr(was.getStartTime() + "-" + was.getEndTime());
  475. atv.setIsCheck((ws.getArriveTimeId() != null && was.getId().equals(ws.getArriveTimeId())) ? 1 : 0);
  476. atvs.add(atv);
  477. }
  478. }
  479. result.setAtvs(atvs);
  480. result.setId(ws.getId());
  481. result.setSchool(ws.getSchool());
  482. result.setSchoolId(ws.getSchoolId());
  483. result.setAdmissNum(ws.getAdmissNum());
  484. result.setName(ws.getName());
  485. result.setPicture(ws.getPicture());
  486. result.setCardId(ws.getCardId());
  487. result.setSex(ws.getSex());
  488. result.setBirthday(ws.getBirthday());
  489. result.setCollege(ws.getCollege());
  490. result.setMajor(ws.getMajor());
  491. result.setClassstr(ws.getClassstr());
  492. result.setCollegeId(ws.getCollegeId());
  493. result.setMajorId(ws.getMajorId());
  494. result.setClassstrId(ws.getClassstrId());
  495. result.setExamNum(ws.getExamNum());
  496. result.setEduSystem(ws.getEduSystem());
  497. result.setGraduationSchool(ws.getGraduationSchool());
  498. result.setBatchValue(ws.getBatchValue());
  499. result.setPoliticalStatu(ws.getPoliticalStatu());
  500. result.setNationality(ws.getNationality());
  501. result.setPhone(ws.getPhone());
  502. result.setOprovinceId(ws.getOprovinceId());
  503. result.setOprovince(ws.getOprovince());
  504. result.setOcityId(ws.getOcityId());
  505. result.setOcity(ws.getOcity());
  506. result.setOdistrictId(ws.getOdistrictId());
  507. result.setOdistrict(ws.getOdistrict());
  508. result.setProvinceId(ws.getProvinceId());
  509. result.setProvince(ws.getProvince());
  510. result.setCityId(ws.getCityId());
  511. result.setCity(ws.getCity());
  512. result.setDistrictId(ws.getDistrictId());
  513. result.setDistrict(ws.getDistrict());
  514. result.setAddress(ws.getAddress());
  515. result.setRegisterOntime(ws.getRegisterOntime());
  516. result.setZipCode(ws.getZipCode());
  517. result.setTrafficMethod(ws.getTrafficMethod());
  518. result.setArrive(ws.getArrive());
  519. result.setArrvieDate(ws.getArrvieDate());
  520. result.setArriveTime(ws.getArriveTime());
  521. result.setArriveTimeId(ws.getArriveTimeId());
  522. result.setAmountPayable(ws.getAmountPayable());
  523. result.setPayAmount(ws.getPayAmount());
  524. result.setIsDrive(ws.getIsDrive());
  525. result.setCarNumber(ws.getCarNumber());
  526. return CommonResult.ok(result);
  527. }
  528. @Override
  529. @Transactional(rollbackFor = {Exception.class})
  530. public CommonResult infoCollection(InfoCollectionRequest icr, BindingResult bindingResult) throws Exception {
  531. logger.info("采集学生信息失败,icr参数:" + JSON.toJSON(icr));
  532. if (bindingResult.hasErrors()) {
  533. String st = paramUtils.getParamError(bindingResult);
  534. return CommonResult.fail(st);
  535. }
  536. WelcomeStudent ws = welcomeStudentService.getDataByIdcardOrNum(icr.getAdmissNum(), icr.getCardId());
  537. if (ws == null) {
  538. ws = new WelcomeStudent();
  539. }
  540. ws.setSchool(icr.getSchool());
  541. ws.setAdmissNum(icr.getAdmissNum());
  542. ws.setName(icr.getName());
  543. ws.setPicture(icr.getPicture());
  544. //ws.setCardId(icr.getCardId());
  545. ws.setSex(icr.getSex());
  546. ws.setBirthday(icr.getBirthday());
  547. ws.setCollegeId(icr.getCollegeId());
  548. ws.setMajorId(icr.getMajorId());
  549. ws.setClassstrId(icr.getClassstrId());
  550. ws.setExamNum(icr.getExamNum());
  551. ws.setEduSystem(icr.getEduSystem());
  552. ws.setGraduationSchool(icr.getGraduationSchool());
  553. ws.setBatchValue(icr.getBatchValue());
  554. ws.setPoliticalStatu(icr.getPoliticalStatu());
  555. ws.setNationality(icr.getNationality());
  556. ws.setPhone(icr.getPhone());
  557. ws.setOprovinceId(icr.getOprovinceId());
  558. ws.setOprovince(icr.getOprovince());
  559. ws.setOcityId(icr.getOcityId());
  560. ws.setOcity(icr.getOcity());
  561. ws.setOdistrictId(icr.getOdistrictId());
  562. ws.setOdistrict(icr.getOdistrict());
  563. ws.setProvinceId(icr.getProvinceId());
  564. ws.setProvince(icr.getProvince());
  565. ws.setCityId(icr.getCityId());
  566. ws.setCity(icr.getCity());
  567. ws.setDistrictId(icr.getDistrictId());
  568. ws.setDistrict(icr.getDistrict());
  569. ws.setAddress(icr.getAddress());
  570. ws.setRegisterOntime(icr.getRegisterOntime());
  571. ws.setZipCode(icr.getZipCode());
  572. ws.setTrafficMethod(icr.getTrafficMethod());
  573. ws.setArrive(icr.getArrive());
  574. ws.setArrvieDate(icr.getArrvieDate());
  575. ws.setArriveTime(icr.getArriveTime());
  576. ws.setArriveTimeId(icr.getArriveTimeId());
  577. ws.setFillStatus("已填报");
  578. //家庭成员
  579. List<WelcomeFamily> wfs = new ArrayList<>();
  580. if (icr.getFvs() != null && icr.getFvs().size() > 0) {
  581. for (FamilyVo fv : icr.getFvs()) {
  582. if (!(StringUtils.hasText(fv.getName()) && StringUtils.hasText(fv.getPhone()) && StringUtils.hasText(fv.getWorkUnit()) && StringUtils.hasText(fv.getFamilyShip()))) {
  583. return CommonResult.fail("家庭成员信息不能为空!");
  584. }
  585. WelcomeFamily wf = new WelcomeFamily();
  586. wf.setName(fv.getName());
  587. wf.setPhone(fv.getPhone());
  588. wf.setWorkUnit(fv.getWorkUnit());
  589. wf.setFamilyShip(fv.getFamilyShip());
  590. wf.setStudentCard(icr.getCardId());
  591. wfs.add(wf);
  592. }
  593. }
  594. //陪同人员
  595. List<WelcomeAccompany> was = new ArrayList<>();
  596. if (icr.getAvs() != null && icr.getAvs().size() > 0) {
  597. for (AccompanyVo av : icr.getAvs()) {
  598. if (!(StringUtils.hasText(av.getName()) && StringUtils.hasText(av.getPhone()))) {
  599. return CommonResult.fail("家庭成员信息不能为空!");
  600. }
  601. WelcomeAccompany wa = new WelcomeAccompany();
  602. wa.setName(av.getName());
  603. wa.setPhone(av.getPhone());
  604. wa.setStudentCard(icr.getCardId());
  605. was.add(wa);
  606. }
  607. }
  608. if (!(ws.getIsPay() != null && ws.getIsPay().intValue() == 1)) {
  609. System.out.println("进支付比较");
  610. List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(ws.getAdmissNum(), TimeExchange.getYear());
  611. BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
  612. BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
  613. for (JsonPayVo pi : payInfos) {
  614. payAmount = payAmount.add(pi.getSJJE());
  615. yjPayAmount = yjPayAmount.add(pi.getYJJE());
  616. }
  617. ws.setPayAmount(payAmount);
  618. ws.setAmountPayable(yjPayAmount);
  619. System.out.println("进支付比较1" + JSON.toJSON(payInfos));
  620. if (payInfos != null && payInfos.size() > 0) {
  621. System.out.println("进支付比较2");
  622. List<WelcomePaySetting> paySettings = welcomePaySettingService.queryPaySettings(ws.getSchool());
  623. System.out.println("进支付比较3" + JSON.toJSON(paySettings));
  624. if (paySettings != null && paySettings.size() > 0) {
  625. System.out.println("进支付比较4");
  626. for (WelcomePaySetting pay : paySettings) {
  627. System.out.println("进支付比较5");
  628. BigDecimal money = pay.getPayAmount();
  629. if (pay.getMethod().equals("全部")) {
  630. BigDecimal totalSj = new BigDecimal(BigInteger.ZERO);
  631. for (JsonPayVo jpv : payInfos) {
  632. totalSj = totalSj.add(jpv.getSJJE());
  633. }
  634. if (totalSj.compareTo(money) >= 0) {
  635. ws.setIsPay(1);
  636. }
  637. }
  638. Optional<JsonPayVo> ojpv = payInfos.stream().filter(e -> e.getSFXMMC().equals(pay.getMethod())).findFirst();
  639. if (ojpv != null && ojpv.isPresent()) {
  640. if (ojpv.get().getSJJE().compareTo(money) >= 0) {
  641. ws.setIsPay(1);
  642. }
  643. }
  644. }
  645. } else {
  646. ws.setIsPay(0);
  647. }
  648. } else {
  649. ws.setIsPay(0);
  650. }
  651. }
  652. try {
  653. System.out.println("信息采集1");
  654. if (ws.getId() != null) {
  655. int update = welcomeStudentService.updateWelcomeStudent(ws);
  656. if (update < 0) {
  657. System.out.println("信息采集1.1");
  658. logger.error("采集学生信息失败,ws参数:" + JSON.toJSON(ws));
  659. throw new Exception("采集学生信息失败!");
  660. //return CommonResult.fail("采集学生信息失败1");
  661. }
  662. } else {
  663. int insert = welcomeStudentService.insertWelcomeStudent(ws);
  664. if (insert < 0) {
  665. System.out.println("信息采集1.2");
  666. logger.error("采集学生信息失败,ws参数:" + JSON.toJSON(ws));
  667. throw new Exception("采集学生信息失败!");
  668. //return CommonResult.fail("采集学生信息失败1");
  669. }
  670. }
  671. System.out.println("信息采集2");
  672. if (wfs != null && wfs.size() > 0) {
  673. boolean resultWf = welcomeFamilyService.saveBatch(wfs);
  674. System.out.println("信息采集1.3");
  675. if (!resultWf) {
  676. System.out.println("信息采集1.4");
  677. logger.error("采集学生信息失败,wfs参数:" + JSON.toJSON(wfs));
  678. throw new Exception("采集学生信息失败!");
  679. //return CommonResult.fail("采集学生信息失败2");
  680. }
  681. }
  682. System.out.println("信息采集3");
  683. if (was != null && was.size() > 0) {
  684. boolean resultWa = welcomeAccompanyService.saveBatch(was);
  685. System.out.println("信息采集1.5");
  686. if (!resultWa) {
  687. System.out.println("信息采集1.6");
  688. logger.error("采集学生信息失败,was参数:" + JSON.toJSON(was));
  689. throw new Exception("采集学生信息失败!");
  690. //return CommonResult.fail("采集学生信息失败3");
  691. }
  692. }
  693. } catch (Exception e) {
  694. logger.error(e.getMessage());
  695. throw new Exception("采集失败!");
  696. //return CommonResult.fail("采集学生信息失败4");
  697. }
  698. System.out.println("信息采集1.7");
  699. return CommonResult.ok("采集完成!");
  700. }
  701. @Override
  702. @Transactional(rollbackFor = {Exception.class})
  703. public CommonResult deleteStudentInfo(int id) throws Exception {
  704. WelcomeStudent ws = welcomeStudentService.getManageById(id);
  705. if (ws == null) {
  706. return CommonResult.fail("学生信息已失效,无法进行删除操作!");
  707. }
  708. //把旧床位清空
  709. WelcomeBed obedData = welcomeBedService.getBedByCardId(ws.getCardId());
  710. if (obedData != null) {
  711. obedData.setStudentCard(null);
  712. obedData.setCollege(null);
  713. obedData.setCollegeId(null);
  714. obedData.setMajor(null);
  715. obedData.setMajorId(null);
  716. obedData.setClassstr(null);
  717. obedData.setClassstrId(null);
  718. obedData.setIsCheck(0);
  719. obedData.setCardNum(null);
  720. obedData.setName(null);
  721. }
  722. try {
  723. //删除学生数据
  724. int deleteStudent = welcomeStudentService.deleteWelcomeStudentById(id);
  725. if (deleteStudent <= 0) {
  726. logger.error("删除学生信息失败,id参数:" + JSON.toJSON(id));
  727. throw new Exception("删除学生信息失败!");
  728. }
  729. if (obedData != null) {
  730. //删除宿舍数据
  731. int deleteSd = welcomeBedService.updateWelcomeBed(obedData);
  732. if (deleteSd < 0) {
  733. logger.error("删除宿舍失败,obedData参数:" + JSON.toJSON(obedData));
  734. throw new Exception("删除学生信息失败!");
  735. }
  736. }
  737. //删除同行人员
  738. int deleteWa = welcomeAccompanyService.deleteWelcomeAccompanyByCard(ws.getCardId());
  739. //删除家庭成员
  740. int deletef = welcomeFamilyService.deleteWelcomeFamilyByCard(ws.getCardId());
  741. } catch (Exception e) {
  742. logger.error(e.getMessage());
  743. throw new Exception("删除失败!");
  744. }
  745. return CommonResult.ok("删除成功");
  746. }
  747. @Override
  748. public CommonResult importStudentExcel(MultipartFile file) throws IOException, ParseException {
  749. System.out.println("导入学生信息");
  750. if (file.isEmpty() || file.getSize() == 0) {
  751. return CommonResult.fail("导入文件不能为空");
  752. }
  753. String ContentType = file.getContentType();
  754. InputStream inputStream = file.getInputStream();
  755. List<WelcomeStudent> result = new ArrayList<>();
  756. //xls格式文件
  757. if (ContentType.equals(eFileType.Xls.getValue())) {
  758. CommonResult<List<WelcomeStudent>> resultData = readXls(inputStream);
  759. if (!resultData.isSuccess()) {
  760. return resultData;
  761. }
  762. result = resultData.getData();
  763. } else if (ContentType.equals(eFileType.Xlsx.getValue())) {
  764. CommonResult<List<WelcomeStudent>> resultData = readXlsx(inputStream);
  765. if (!resultData.isSuccess()) {
  766. return resultData;
  767. }
  768. result = resultData.getData();
  769. } else {
  770. return CommonResult.fail("学生信息数据导入只支持Xls或Xlsx格式文件");
  771. }
  772. List<String> cardIds = result.stream().map(WelcomeStudent::getCardId).collect(Collectors.toList());
  773. List<WelcomeStudent> existStudents = welcomeStudentService.queryStudentByCardId(cardIds);
  774. if (existStudents != null && existStudents.size() > 0) {
  775. for (WelcomeStudent ws : result) {
  776. Optional<WelcomeStudent> ows = existStudents.stream().filter(e -> e.getCardId().equals(ws.getCardId())).findFirst();
  777. if (ows != null && ows.isPresent()) {
  778. ws.setId(ows.get().getId());
  779. ws.setAdmissNum(ws.getAdmissNum());//录取号
  780. ws.setName(ws.getName());//姓名
  781. ws.setCardId(ws.getCardId());//身份证号
  782. ws.setSchool(ws.getSchool());//校区
  783. ws.setCollege(ws.getCollege());
  784. ws.setCollegeId(ws.getCollegeId());
  785. ws.setMajor(ws.getMajor());
  786. ws.setMajorId(ws.getMajorId());
  787. ws.setClassstr(ws.getClassstr());
  788. ws.setClassstrId(ws.getClassstrId());
  789. ws.setExamNum(ws.getExamNum());//考生号
  790. ws.setEduSystem(ws.getEduSystem());//学制
  791. ws.setGraduationSchool(ws.getGraduationSchool());//毕业中学
  792. ws.setBatchValue(ws.getBatchValue());//批次
  793. ws.setPoliticalStatu(ws.getPoliticalStatu());//政治面貌
  794. ws.setNationality(ws.getNationality());//民族
  795. ws.setPhone(ws.getPhone());//手机号码
  796. ws.setOprovince(ws.getOprovince());
  797. ws.setOprovinceId(ws.getOprovinceId());
  798. ws.setOcity(ws.getOcity());
  799. ws.setOcityId(ws.getOcityId());
  800. ws.setOdistrict(ws.getOdistrict());
  801. ws.setOdistrictId(ws.getOdistrictId());
  802. ws.setProvince(ws.getProvince());
  803. ws.setProvinceId(ws.getProvinceId());
  804. ws.setCity(ws.getCity());
  805. ws.setCityId(ws.getCityId());
  806. ws.setDistrict(ws.getDistrict());
  807. ws.setDistrictId(ws.getDistrictId());
  808. ws.setAddress(ws.getAddress());
  809. ws.setZipCode(ws.getZipCode());
  810. }
  811. }
  812. }
  813. boolean resultBool = welcomeStudentService.saveOrUpdateBatch(result);
  814. System.out.println("导入学生1");
  815. return resultBool ? CommonResult.ok("导入成功") : CommonResult.fail("导入失败");
  816. }
  817. /**
  818. * xls文件读取方法
  819. *
  820. * @param inputStream
  821. * @return
  822. * @throws IOException
  823. * @throws ParseException
  824. */
  825. private CommonResult<List<WelcomeStudent>> readXls(InputStream inputStream) throws IOException, ParseException {
  826. List<WelcomeStudent> result = new ArrayList<>();
  827. HSSFWorkbook sheets = new HSSFWorkbook(inputStream);
  828. List<WelcomeOrg> ws = welcomeOrgService.list(null);
  829. List<WelcomeCity> citys = welcomeCityService.list(null);
  830. //读取第一张sheet
  831. HSSFSheet sheetAt = sheets.getSheetAt(0);
  832. DataFormatter dataFormatter = new DataFormatter();
  833. try {
  834. //rowNum = 3 从第三行开始获取值
  835. //sheetAt.getLastRowNum():从0开始统计数量 所以得+1
  836. for (int rowNum = 0; rowNum < sheetAt.getLastRowNum() + 1; rowNum++) {
  837. HSSFRow row = sheetAt.getRow(rowNum);
  838. if (row != null) {
  839. //使用了getStringCellValue()方法来获取值,POI会判断单元格的类型,如果非字符串类型就会抛出上面的异常。
  840. //所以先使用setCellType()方法先将该单元格的类型设置为STRING
  841. //然后poi会根据字符串读取它
  842. //第一行数据获取月份
  843. if (rowNum == 0) {
  844. String number = dataFormatter.formatCellValue(row.getCell(0));//序号
  845. if (!number.equals("序号")) {
  846. return CommonResult.fail("导入数据第一列为序号");
  847. }
  848. String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
  849. if (!assNum.equals("录取号")) {
  850. return CommonResult.fail("导入数据第二列为录取号");
  851. }
  852. String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
  853. if (!name.equals("姓名")) {
  854. return CommonResult.fail("导入数据第三列为姓名");
  855. }
  856. String cardId = dataFormatter.formatCellValue(row.getCell(3));//身份证号
  857. if (!cardId.equals("身份证号")) {
  858. return CommonResult.fail("导入数据第四列为身份证号");
  859. }
  860. String school = dataFormatter.formatCellValue(row.getCell(4));//校区
  861. if (!school.equals("校区")) {
  862. return CommonResult.fail("导入数据第五列为校区");
  863. }
  864. String college = dataFormatter.formatCellValue(row.getCell(5));//院系
  865. if (!college.equals("院系")) {
  866. return CommonResult.fail("导入数据第六列为院系");
  867. }
  868. String major = dataFormatter.formatCellValue(row.getCell(6));//专业
  869. if (!major.equals("专业")) {
  870. return CommonResult.fail("导入数据第七列为专业");
  871. }
  872. String classstr = dataFormatter.formatCellValue(row.getCell(7));//班级
  873. if (!classstr.equals("班级")) {
  874. return CommonResult.fail("导入数据第八列为班级");
  875. }
  876. String examNum = dataFormatter.formatCellValue(row.getCell(8));//考生号
  877. if (!examNum.equals("考生号")) {
  878. return CommonResult.fail("导入数据第九列为考生号");
  879. }
  880. String eduSystem = dataFormatter.formatCellValue(row.getCell(9));//学制
  881. if (!eduSystem.equals("学制")) {
  882. return CommonResult.fail("导入数据第十列为学制");
  883. }
  884. String graSchool = dataFormatter.formatCellValue(row.getCell(10));//毕业中学
  885. if (!graSchool.equals("毕业中学")) {
  886. return CommonResult.fail("导入数据第十一列为毕业中学批次");
  887. }
  888. String batchValue = dataFormatter.formatCellValue(row.getCell(11));//批次
  889. if (!batchValue.equals("批次")) {
  890. return CommonResult.fail("导入数据第十二列为批次");
  891. }
  892. String politicalStatu = dataFormatter.formatCellValue(row.getCell(12));//政治面貌
  893. if (!politicalStatu.equals("政治面貌")) {
  894. return CommonResult.fail("导入数据第十三列为政治面貌");
  895. }
  896. String nationality = dataFormatter.formatCellValue(row.getCell(13));//民族
  897. if (!nationality.equals("民族")) {
  898. return CommonResult.fail("导入数据第十四列为民族");
  899. }
  900. String phone = dataFormatter.formatCellValue(row.getCell(14));//手机号码
  901. if (!phone.equals("手机号码")) {
  902. return CommonResult.fail("导入数据第十五列为手机号码");
  903. }
  904. String nativePlace = dataFormatter.formatCellValue(row.getCell(15));//籍贯
  905. if (!nativePlace.contains("籍贯")) {
  906. return CommonResult.fail("导入数据第十六列为籍贯");
  907. }
  908. String addressPlace = dataFormatter.formatCellValue(row.getCell(16));//家庭住址
  909. if (!addressPlace.contains("家庭住址")) {
  910. return CommonResult.fail("导入数据第十七列为家庭住址");
  911. }
  912. String addressDetail = dataFormatter.formatCellValue(row.getCell(17));//详细住址
  913. if (!addressDetail.equals("详细住址")) {
  914. return CommonResult.fail("导入数据第十八列为详细住址");
  915. }
  916. String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
  917. if (!zipCode.equals("邮编")) {
  918. return CommonResult.fail("导入数据第十九列为邮编");
  919. }
  920. } else {
  921. WelcomeStudent studentData = new WelcomeStudent();
  922. String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
  923. if (!StringUtils.hasText(assNum)) {
  924. break;
  925. }
  926. studentData.setAdmissNum(assNum);
  927. String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
  928. studentData.setName(name);
  929. String cardId = dataFormatter.formatCellValue(row.getCell(3));//身份证号
  930. studentData.setCardId(cardId);
  931. String school = dataFormatter.formatCellValue(row.getCell(4));//校区
  932. studentData.setSchool(school);
  933. //region 院系专业
  934. String college = dataFormatter.formatCellValue(row.getCell(5));//院系
  935. Optional<WelcomeOrg> owo = ws.stream().filter(e -> e.getName().equals(college)).findFirst();
  936. if (owo != null && owo.isPresent()) {
  937. studentData.setCollege(college);
  938. studentData.setCollegeId(owo.get().getId());
  939. }
  940. String major = dataFormatter.formatCellValue(row.getCell(6));//专业
  941. Optional<WelcomeOrg> omwo = ws.stream().filter(e -> e.getName().equals(major)).findFirst();
  942. if (omwo != null && omwo.isPresent()) {
  943. studentData.setMajor(major);
  944. studentData.setMajorId(omwo.get().getId());
  945. }
  946. String classstr = dataFormatter.formatCellValue(row.getCell(7));//班级
  947. Optional<WelcomeOrg> ocwo = ws.stream().filter(e -> e.getName().equals(classstr)).findFirst();
  948. if (ocwo != null && ocwo.isPresent()) {
  949. studentData.setClassstr(classstr);
  950. studentData.setClassstrId(ocwo.get().getId());
  951. }
  952. //endregion
  953. String examNum = dataFormatter.formatCellValue(row.getCell(8));//考生号
  954. studentData.setExamNum(examNum);
  955. String eduSystem = dataFormatter.formatCellValue(row.getCell(9));//学制
  956. studentData.setEduSystem(eduSystem);
  957. String graSchool = dataFormatter.formatCellValue(row.getCell(10));//毕业中学
  958. studentData.setGraduationSchool(graSchool);
  959. String batchValue = dataFormatter.formatCellValue(row.getCell(11));//批次
  960. studentData.setBatchValue(batchValue);
  961. String politicalStatu = dataFormatter.formatCellValue(row.getCell(12));//政治面貌
  962. studentData.setPoliticalStatu(politicalStatu);
  963. String nationality = dataFormatter.formatCellValue(row.getCell(13));//民族
  964. studentData.setNationality(nationality);
  965. String phone = dataFormatter.formatCellValue(row.getCell(14));//手机号码
  966. studentData.setPhone(phone);
  967. //region 籍贯
  968. String nativePlace = dataFormatter.formatCellValue(row.getCell(15));//籍贯
  969. String[] addressDatas = nativePlace.split("/");
  970. if (citys != null && citys.size() > 0) {
  971. if (addressDatas != null && addressDatas.length >= 1) {
  972. if (!addressDatas[0].contains("省")) {
  973. return CommonResult.fail("录取编号为\" + assNum + \"的籍贯格式应该是 省/市/县");
  974. }
  975. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressDatas[0])).findFirst();
  976. if (oProvince != null && oProvince.isPresent()) {
  977. studentData.setOprovince(addressDatas[0]);
  978. studentData.setOprovinceId(oProvince.get().getId());
  979. } else {
  980. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  981. }
  982. }
  983. if (addressDatas != null && addressDatas.length >= 2) {
  984. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressDatas[1])).findFirst();
  985. if (oProvince != null && oProvince.isPresent()) {
  986. studentData.setOcity(addressDatas[1]);
  987. studentData.setOcityId(oProvince.get().getId());
  988. } else {
  989. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  990. }
  991. }
  992. if (addressDatas != null && addressDatas.length >= 3) {
  993. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getCityZh().equals(addressDatas[1]) && e.getDistrictZh().equals(addressDatas[2])).findFirst();
  994. if (oProvince != null && oProvince.isPresent()) {
  995. studentData.setOdistrict(addressDatas[2]);
  996. studentData.setOdistrictId(oProvince.get().getId());
  997. } else {
  998. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  999. }
  1000. }
  1001. }
  1002. //endregion
  1003. //region 家庭住址
  1004. String addressPlace = dataFormatter.formatCellValue(row.getCell(16));//家庭住址
  1005. String[] addressPlaces = addressPlace.split("/");
  1006. if (citys != null && citys.size() > 0) {
  1007. if (addressPlaces != null && addressPlaces.length >= 1) {
  1008. if (!addressPlaces[0].contains("省")) {
  1009. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1010. }
  1011. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[0])).findFirst();
  1012. if (oProvince != null && oProvince.isPresent()) {
  1013. studentData.setProvince(addressPlaces[0]);
  1014. studentData.setProvinceId(oProvince.get().getId());
  1015. } else {
  1016. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1017. }
  1018. }
  1019. if (addressPlaces != null && addressPlaces.length >= 2) {
  1020. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[1])).findFirst();
  1021. if (oProvince != null && oProvince.isPresent()) {
  1022. studentData.setCity(addressPlaces[1]);
  1023. studentData.setCityId(oProvince.get().getId());
  1024. } else {
  1025. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1026. }
  1027. }
  1028. if (addressPlaces != null && addressPlaces.length >= 3) {
  1029. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getCityZh().equals(addressPlaces[1]) && e.getDistrictZh().equals(addressPlaces[2])).findFirst();
  1030. if (oProvince != null && oProvince.isPresent()) {
  1031. studentData.setDistrict(addressPlaces[2]);
  1032. studentData.setDistrictId(oProvince.get().getId());
  1033. } else {
  1034. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1035. }
  1036. }
  1037. }
  1038. //endregion
  1039. String addressDetail = dataFormatter.formatCellValue(row.getCell(17));//详细住址
  1040. studentData.setAddress(addressDetail);
  1041. String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
  1042. studentData.setZipCode(zipCode);
  1043. studentData.setIdenType(1);
  1044. studentData.setFillStatus("未填报");
  1045. result.add(studentData);
  1046. }
  1047. }
  1048. }
  1049. } catch (Exception e) {
  1050. return CommonResult.fail("请按模板格式导入数据");
  1051. }
  1052. return CommonResult.ok(result);
  1053. }
  1054. /**
  1055. * xls文件读取方法
  1056. *
  1057. * @param inputStream
  1058. * @return
  1059. * @throws IOException
  1060. * @throws ParseException
  1061. */
  1062. private CommonResult<List<WelcomeStudent>> readXlsx(InputStream inputStream) throws IOException, ParseException {
  1063. List<WelcomeStudent> result = new ArrayList<>();
  1064. XSSFWorkbook sheets = new XSSFWorkbook(inputStream);
  1065. List<WelcomeOrg> ws = welcomeOrgService.list(null);
  1066. List<WelcomeCity> citys = welcomeCityService.list(null);
  1067. //读取第一张sheet
  1068. XSSFSheet sheetAt = sheets.getSheetAt(0);
  1069. DataFormatter dataFormatter = new DataFormatter();
  1070. try {
  1071. //rowNum = 3 从第三行开始获取值
  1072. //sheetAt.getLastRowNum():从0开始统计数量 所以得+1
  1073. for (int rowNum = 0; rowNum < sheetAt.getLastRowNum() + 1; rowNum++) {
  1074. XSSFRow row = sheetAt.getRow(rowNum);
  1075. if (row != null) {
  1076. //使用了getStringCellValue()方法来获取值,POI会判断单元格的类型,如果非字符串类型就会抛出上面的异常。
  1077. //所以先使用setCellType()方法先将该单元格的类型设置为STRING
  1078. //然后poi会根据字符串读取它
  1079. //第一行数据获取月份
  1080. if (rowNum == 0) {
  1081. String number = dataFormatter.formatCellValue(row.getCell(0));//序号
  1082. if (!number.equals("序号")) {
  1083. return CommonResult.fail("导入数据第一列为序号");
  1084. }
  1085. String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
  1086. if (!assNum.equals("录取号")) {
  1087. return CommonResult.fail("导入数据第二列为录取号");
  1088. }
  1089. String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
  1090. if (!name.equals("姓名")) {
  1091. return CommonResult.fail("导入数据第三列为姓名");
  1092. }
  1093. String cardId = dataFormatter.formatCellValue(row.getCell(3));//身份证号
  1094. if (!cardId.equals("身份证号")) {
  1095. return CommonResult.fail("导入数据第四列为身份证号");
  1096. }
  1097. String school = dataFormatter.formatCellValue(row.getCell(4));//校区
  1098. if (!school.equals("校区")) {
  1099. return CommonResult.fail("导入数据第五列为校区");
  1100. }
  1101. String college = dataFormatter.formatCellValue(row.getCell(5));//院系
  1102. if (!college.equals("院系")) {
  1103. return CommonResult.fail("导入数据第六列为院系");
  1104. }
  1105. String major = dataFormatter.formatCellValue(row.getCell(6));//专业
  1106. if (!major.equals("专业")) {
  1107. return CommonResult.fail("导入数据第七列为专业");
  1108. }
  1109. String classstr = dataFormatter.formatCellValue(row.getCell(7));//班级
  1110. if (!classstr.equals("班级")) {
  1111. return CommonResult.fail("导入数据第八列为班级");
  1112. }
  1113. String examNum = dataFormatter.formatCellValue(row.getCell(8));//考生号
  1114. if (!examNum.equals("考生号")) {
  1115. return CommonResult.fail("导入数据第九列为考生号");
  1116. }
  1117. String eduSystem = dataFormatter.formatCellValue(row.getCell(9));//学制
  1118. if (!eduSystem.equals("学制")) {
  1119. return CommonResult.fail("导入数据第十列为学制");
  1120. }
  1121. String graSchool = dataFormatter.formatCellValue(row.getCell(10));//毕业中学
  1122. if (!graSchool.equals("毕业中学")) {
  1123. return CommonResult.fail("导入数据第十一列为毕业中学批次");
  1124. }
  1125. String batchValue = dataFormatter.formatCellValue(row.getCell(11));//批次
  1126. if (!batchValue.equals("批次")) {
  1127. return CommonResult.fail("导入数据第十二列为批次");
  1128. }
  1129. String politicalStatu = dataFormatter.formatCellValue(row.getCell(12));//政治面貌
  1130. if (!politicalStatu.equals("政治面貌")) {
  1131. return CommonResult.fail("导入数据第十三列为政治面貌");
  1132. }
  1133. String nationality = dataFormatter.formatCellValue(row.getCell(13));//民族
  1134. if (!nationality.equals("民族")) {
  1135. return CommonResult.fail("导入数据第十四列为民族");
  1136. }
  1137. String phone = dataFormatter.formatCellValue(row.getCell(14));//手机号码
  1138. if (!phone.equals("手机号码")) {
  1139. return CommonResult.fail("导入数据第十五列为手机号码");
  1140. }
  1141. String nativePlace = dataFormatter.formatCellValue(row.getCell(15));//籍贯
  1142. if (!nativePlace.contains("籍贯")) {
  1143. return CommonResult.fail("导入数据第十六列为籍贯");
  1144. }
  1145. String addressPlace = dataFormatter.formatCellValue(row.getCell(16));//家庭住址
  1146. if (!addressPlace.contains("家庭住址")) {
  1147. return CommonResult.fail("导入数据第十七列为家庭住址");
  1148. }
  1149. String addressDetail = dataFormatter.formatCellValue(row.getCell(17));//详细住址
  1150. if (!addressDetail.equals("详细住址")) {
  1151. return CommonResult.fail("导入数据第十八列为详细住址");
  1152. }
  1153. String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
  1154. if (!zipCode.equals("邮编")) {
  1155. return CommonResult.fail("导入数据第十九列为邮编");
  1156. }
  1157. } else {
  1158. WelcomeStudent studentData = new WelcomeStudent();
  1159. String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
  1160. if (!StringUtils.hasText(assNum)) {
  1161. break;
  1162. }
  1163. studentData.setAdmissNum(assNum);
  1164. String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
  1165. studentData.setName(name);
  1166. String cardId = dataFormatter.formatCellValue(row.getCell(3));//身份证号
  1167. studentData.setCardId(cardId);
  1168. String school = dataFormatter.formatCellValue(row.getCell(4));//校区
  1169. studentData.setSchool(school);
  1170. //region 院系专业
  1171. String college = dataFormatter.formatCellValue(row.getCell(5));//院系
  1172. Optional<WelcomeOrg> owo = ws.stream().filter(e -> e.getName().equals(college)).findFirst();
  1173. if (owo != null && owo.isPresent()) {
  1174. studentData.setCollege(college);
  1175. studentData.setCollegeId(owo.get().getId());
  1176. }
  1177. String major = dataFormatter.formatCellValue(row.getCell(6));//专业
  1178. Optional<WelcomeOrg> omwo = ws.stream().filter(e -> e.getName().equals(major)).findFirst();
  1179. if (omwo != null && omwo.isPresent()) {
  1180. studentData.setMajor(major);
  1181. studentData.setMajorId(omwo.get().getId());
  1182. }
  1183. String classstr = dataFormatter.formatCellValue(row.getCell(7));//班级
  1184. Optional<WelcomeOrg> ocwo = ws.stream().filter(e -> e.getName().equals(classstr)).findFirst();
  1185. if (ocwo != null && ocwo.isPresent()) {
  1186. studentData.setClassstr(classstr);
  1187. studentData.setClassstrId(ocwo.get().getId());
  1188. }
  1189. //endregion
  1190. String examNum = dataFormatter.formatCellValue(row.getCell(8));//考生号
  1191. studentData.setExamNum(examNum);
  1192. String eduSystem = dataFormatter.formatCellValue(row.getCell(9));//学制
  1193. studentData.setEduSystem(eduSystem);
  1194. String graSchool = dataFormatter.formatCellValue(row.getCell(10));//毕业中学
  1195. studentData.setGraduationSchool(graSchool);
  1196. String batchValue = dataFormatter.formatCellValue(row.getCell(11));//批次
  1197. studentData.setBatchValue(batchValue);
  1198. String politicalStatu = dataFormatter.formatCellValue(row.getCell(12));//政治面貌
  1199. studentData.setPoliticalStatu(politicalStatu);
  1200. String nationality = dataFormatter.formatCellValue(row.getCell(13));//民族
  1201. studentData.setNationality(nationality);
  1202. String phone = dataFormatter.formatCellValue(row.getCell(14));//手机号码
  1203. studentData.setPhone(phone);
  1204. //region 籍贯
  1205. String nativePlace = dataFormatter.formatCellValue(row.getCell(15));//籍贯
  1206. String[] addressDatas = nativePlace.split("/");
  1207. if (citys != null && citys.size() > 0) {
  1208. if (addressDatas != null && addressDatas.length >= 1) {
  1209. if (!addressDatas[0].contains("省")) {
  1210. return CommonResult.fail("录取编号为\" + assNum + \"的籍贯格式应该是 省/市/县区");
  1211. }
  1212. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressDatas[0])).findFirst();
  1213. if (oProvince != null && oProvince.isPresent()) {
  1214. studentData.setOprovince(addressDatas[0]);
  1215. studentData.setOprovinceId(oProvince.get().getId());
  1216. } else {
  1217. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  1218. }
  1219. }
  1220. if (addressDatas != null && addressDatas.length >= 2) {
  1221. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressDatas[1])).findFirst();
  1222. if (oProvince != null && oProvince.isPresent()) {
  1223. studentData.setOcity(addressDatas[1]);
  1224. studentData.setOcityId(oProvince.get().getId());
  1225. } else {
  1226. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  1227. }
  1228. }
  1229. if (addressDatas != null && addressDatas.length >= 3) {
  1230. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getCityZh().equals(addressDatas[1]) && e.getDistrictZh().equals(addressDatas[2])).findFirst();
  1231. if (oProvince != null && oProvince.isPresent()) {
  1232. studentData.setOdistrict(addressDatas[2]);
  1233. studentData.setOdistrictId(oProvince.get().getId());
  1234. } else {
  1235. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  1236. }
  1237. }
  1238. }
  1239. //endregion
  1240. //region 家庭住址
  1241. String addressPlace = dataFormatter.formatCellValue(row.getCell(16));//家庭住址
  1242. String[] addressPlaces = addressPlace.split("/");
  1243. if (citys != null && citys.size() > 0) {
  1244. if (addressPlaces != null && addressPlaces.length >= 1) {
  1245. if (!addressPlaces[0].contains("省")) {
  1246. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1247. }
  1248. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[0])).findFirst();
  1249. if (oProvince != null && oProvince.isPresent()) {
  1250. studentData.setProvince(addressPlaces[0]);
  1251. studentData.setProvinceId(oProvince.get().getId());
  1252. } else {
  1253. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1254. }
  1255. }
  1256. if (addressPlaces != null && addressPlaces.length >= 2) {
  1257. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[1])).findFirst();
  1258. if (oProvince != null && oProvince.isPresent()) {
  1259. studentData.setCity(addressPlaces[1]);
  1260. studentData.setCityId(oProvince.get().getId());
  1261. } else {
  1262. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1263. }
  1264. }
  1265. if (addressPlaces != null && addressPlaces.length >= 3) {
  1266. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getCityZh().equals(addressPlaces[1]) && e.getDistrictZh().equals(addressPlaces[2])).findFirst();
  1267. if (oProvince != null && oProvince.isPresent()) {
  1268. studentData.setDistrict(addressPlaces[2]);
  1269. studentData.setDistrictId(oProvince.get().getId());
  1270. } else {
  1271. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1272. }
  1273. }
  1274. }
  1275. //endregion
  1276. String addressDetail = dataFormatter.formatCellValue(row.getCell(17));//详细住址
  1277. studentData.setAddress(addressDetail);
  1278. String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
  1279. studentData.setZipCode(zipCode);
  1280. studentData.setIdenType(1);
  1281. studentData.setFillStatus("未填报");
  1282. result.add(studentData);
  1283. }
  1284. }
  1285. }
  1286. } catch (Exception e) {
  1287. return CommonResult.fail("请按模板格式导入数据");
  1288. }
  1289. return CommonResult.ok(result);
  1290. }
  1291. @Override
  1292. public CommonResult downloadStudentExcel() {
  1293. return CommonResult.ok("200", "操作成功", "https://chtech.ncjti.edu.cn/welcome/homeimage/学生信息管理.xlsx");
  1294. }
  1295. @Override
  1296. public void welcomeStudentExport(HttpServletResponse response, Integer collegeId, Integer majorId, Integer classstrId, String trafficMethod, String name) {
  1297. List<StudentPageVo> result = welcomeStudentService.queryStudentList(collegeId, majorId, classstrId, trafficMethod, name);
  1298. //导出
  1299. Workbook workbook = new XSSFWorkbook();
  1300. Sheet sheet = workbook.createSheet("学生信息");
  1301. Row headerRow = sheet.createRow(0);
  1302. headerRow.createCell(0).setCellValue("序号");
  1303. headerRow.createCell(1).setCellValue("录取号");
  1304. headerRow.createCell(2).setCellValue("姓名");
  1305. headerRow.createCell(3).setCellValue("身份证号");
  1306. headerRow.createCell(4).setCellValue("院系");
  1307. headerRow.createCell(5).setCellValue("专业");
  1308. headerRow.createCell(6).setCellValue("班级");
  1309. headerRow.createCell(7).setCellValue("交通方式");
  1310. headerRow.createCell(8).setCellValue("到站地点");
  1311. headerRow.createCell(9).setCellValue("陪同人数");
  1312. headerRow.createCell(10).setCellValue("填报状态");
  1313. headerRow.createCell(11).setCellValue("应缴金额");
  1314. headerRow.createCell(12).setCellValue("实付金额");
  1315. headerRow.createCell(13).setCellValue("宿舍信息");
  1316. for (int i = 0; i < result.size(); i++) {
  1317. StudentPageVo studentData = result.get(i);
  1318. Row dataRow = sheet.createRow(i + 1);
  1319. dataRow.createCell(0).setCellValue(i + 1);
  1320. dataRow.createCell(1).setCellValue(studentData.getAdmissNum());
  1321. dataRow.createCell(2).setCellValue(studentData.getName());
  1322. dataRow.createCell(3).setCellValue(studentData.getCardId());
  1323. dataRow.createCell(4).setCellValue(studentData.getCollege());
  1324. dataRow.createCell(5).setCellValue(studentData.getMajor());
  1325. dataRow.createCell(6).setCellValue(studentData.getClassstr());
  1326. dataRow.createCell(7).setCellValue(studentData.getTrafficMethod());
  1327. dataRow.createCell(8).setCellValue(studentData.getArrive());
  1328. dataRow.createCell(9).setCellValue(studentData.getAccompanyNum());
  1329. dataRow.createCell(10).setCellValue(studentData.getFillStatus());
  1330. dataRow.createCell(11).setCellValue(String.valueOf(studentData.getAmountPayable()));
  1331. dataRow.createCell(12).setCellValue(String.valueOf(studentData.getPayAmount()));
  1332. dataRow.createCell(13).setCellValue(studentData.getDormitory());
  1333. }
  1334. // 将工作簿写入文件
  1335. ExcelUtils.excelDownload(workbook, "学生信息.xlsx", response);
  1336. }
  1337. @Override
  1338. public CommonResult studentOverview() {
  1339. // 录取总数
  1340. // LambdaQueryWrapper<WelcomeStudent> queryWrapper=new LambdaQueryWrapper<>();
  1341. // queryWrapper.eq(WelcomeStudent::getIdenType,1);
  1342. int enrollmentTotal = 6352;//welcomeStudentService.count(queryWrapper);
  1343. // 缴费人数
  1344. int payCount = welcomeStudentService.payCount();
  1345. // 已入住寝室数
  1346. LambdaQueryWrapper<WelcomeBed> wrapper = new LambdaQueryWrapper<>();
  1347. wrapper.eq(WelcomeBed::getIsCheck, 1)
  1348. .eq(WelcomeBed::getRetentionState, 1);
  1349. int checkInBedTotal = welcomeBedService.count(wrapper);
  1350. // 报到率
  1351. // BigDecimal total = new BigDecimal(enrollmentTotal);
  1352. // BigDecimal bedTotal = new BigDecimal(checkInBedTotal);
  1353. // BigDecimal bigDecimal = bedTotal.divide(total).setScale(4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
  1354. String registrationRate = String.format("%.2f",(double)(checkInBedTotal/enrollmentTotal) * 100);
  1355. LocalDateTime start = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
  1356. LocalDateTime end = start.plusDays(1);
  1357. Integer mVisitorTotal = welcomeVisitorService.countTotal(start, end, 1);
  1358. Integer hVisitorTotal = welcomeVisitorService.countTotal(start, end, 2);
  1359. List<WelcomeSetting> wss = welcomeSettingService.list(null);
  1360. // 墨轩湖总车辆数
  1361. Integer mCarTotal = wss != null && wss.size() > 0 ? (wss.get(0).getMxhCarNum() == null ? 0 : wss.get(0).getMxhCarNum()) : 0;
  1362. // 黄家湖总车辆数
  1363. Integer hCarTotal = wss != null && wss.size() > 0 ? (wss.get(0).getHjhCarNum() == null ? 0 : wss.get(0).getHjhCarNum()) : 0;
  1364. StudentOverviewVo vo = new StudentOverviewVo();
  1365. vo.setEnrollmentTotal(enrollmentTotal);
  1366. vo.setPayCount(payCount);
  1367. vo.setCheckInBedTotal(checkInBedTotal);
  1368. vo.setRegistrationRate(registrationRate);
  1369. vo.setHCarTotal(hCarTotal - hVisitorTotal);
  1370. vo.setHVisitorTotal(hVisitorTotal);
  1371. vo.setMCarTotal(mCarTotal - mVisitorTotal);
  1372. vo.setMVisitorTotal(mVisitorTotal);
  1373. return CommonResult.ok(vo);
  1374. }
  1375. @Override
  1376. public CommonResult studentRegister() {
  1377. // 获取总数
  1378. Integer count = welcomeStudentService.totalCount();
  1379. List<StudentRegisterVo> vos = welcomeStudentService.studentRegister();
  1380. StudentRegisterVo vo = new StudentRegisterVo();
  1381. vo.setCollegeName("报到总数");
  1382. vo.setCount(count);
  1383. vos.add(vo);
  1384. return CommonResult.ok(vos);
  1385. }
  1386. @Override
  1387. public CommonResult studentTraffic() {
  1388. List<StudentTrafficVo> vos = welcomeStudentService.studentTraffic();
  1389. return CommonResult.ok(vos);
  1390. }
  1391. @Override
  1392. public CommonResult studentSexRatio() {
  1393. Integer manCount = welcomeStudentService.genderCount("男");
  1394. Integer girlCount = welcomeStudentService.genderCount("女");
  1395. StudentSexRatioVo vo = new StudentSexRatioVo();
  1396. vo.setCollegeName("全部");
  1397. vo.setManCount(manCount);
  1398. vo.setGirlCount(girlCount);
  1399. List<StudentSexRatioVo> vos = welcomeStudentService.studentSexRatio();
  1400. vos.add(vo);
  1401. return CommonResult.ok(vos);
  1402. }
  1403. @Override
  1404. public CommonResult studentStay() {
  1405. ArrayList<StudentStayVo> vos = new ArrayList<>();
  1406. List<WelcomeSchool> list = welcomeSchoolService.list(new QueryWrapper<>());
  1407. for (WelcomeSchool welcomeSchool : list) {
  1408. Integer schoolId = welcomeSchool.getId();
  1409. List<WelcomeBuild> builds = welcomeBuildService.getBuild(schoolId);
  1410. for (WelcomeBuild build : builds) {
  1411. Integer buildId = build.getId();
  1412. StudentStayVo vo = welcomeDormitoryService.getTotalCount(buildId);
  1413. vo.setSchoolName(welcomeSchool.getSchool());
  1414. vo.setBuildName(build.getBuild());
  1415. vos.add(vo);
  1416. }
  1417. }
  1418. return CommonResult.ok(vos);
  1419. }
  1420. @Override
  1421. public CommonResult queryStudentByToken(String userId) {
  1422. WelcomeStudent student = welcomeStudentService.getManageById(Integer.valueOf(userId));
  1423. if (!(student.getIsPay() != null && student.getIsPay().intValue() == 1)) {
  1424. List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(student.getAdmissNum(), TimeExchange.getYear());
  1425. BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
  1426. BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
  1427. for (JsonPayVo pi : payInfos) {
  1428. payAmount = payAmount.add(pi.getSJJE());
  1429. yjPayAmount = yjPayAmount.add(pi.getYJJE());
  1430. }
  1431. student.setPayAmount(payAmount);
  1432. student.setAmountPayable(yjPayAmount);
  1433. if (payInfos != null && payInfos.size() > 0) {
  1434. List<WelcomePaySetting> paySettings = welcomePaySettingService.queryPaySettings(student.getSchool());
  1435. if (paySettings != null && paySettings.size() > 0) {
  1436. for (WelcomePaySetting pay : paySettings) {
  1437. BigDecimal money = pay.getPayAmount();
  1438. if (pay.getMethod().equals("全部")) {
  1439. BigDecimal totalSj = new BigDecimal(BigInteger.ZERO);
  1440. for (JsonPayVo jpv : payInfos) {
  1441. totalSj = totalSj.add(jpv.getSJJE());
  1442. }
  1443. if (totalSj.compareTo(money) >= 0) {
  1444. student.setIsPay(1);
  1445. }
  1446. }
  1447. Optional<JsonPayVo> ojpv = payInfos.stream().filter(e -> e.getSFXMMC().equals(pay.getMethod())).findFirst();
  1448. if (ojpv != null && ojpv.isPresent()) {
  1449. if (ojpv.get().getSJJE().compareTo(money) >= 0) {
  1450. student.setIsPay(1);
  1451. }
  1452. }
  1453. }
  1454. } else {
  1455. student.setIsPay(0);
  1456. }
  1457. } else {
  1458. student.setIsPay(0);
  1459. }
  1460. if (payInfos != null && payInfos.size() > 0) {
  1461. int update = welcomeStudentService.updateWelcomeStudent(student);
  1462. if (update < 0) {
  1463. logger.error("获取支付信息导致学校信息查询失败");
  1464. return CommonResult.fail("查询失败");
  1465. }
  1466. }
  1467. }
  1468. return CommonResult.ok(student);
  1469. }
  1470. @Override
  1471. public CommonResult queryStudentInfo(String admissNum) {
  1472. return null;
  1473. }
  1474. }