WelcomeStudentController.java 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386
  1. package com.template.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5. import com.baomidou.mybatisplus.core.metadata.IPage;
  6. import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
  7. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  8. import com.template.annotation.AWelcomeLevelLog;
  9. import com.template.annotation.AWelcomeLog;
  10. import com.template.annotation.AWelcomeLogMode;
  11. import com.template.annotation.AWelcomeTypeLog;
  12. import com.template.api.WelcomeStudentControllerAPI;
  13. import com.template.common.utils.*;
  14. import com.template.model.enumModel.eFileType;
  15. import com.template.model.enumModel.eSchool;
  16. import com.template.model.pojo.*;
  17. import com.template.model.request.InfoCollectionRequest;
  18. import com.template.model.request.InsertFamilyRequest;
  19. import com.template.model.request.InsertStudentRequest;
  20. import com.template.model.request.updateStudentRequest;
  21. import com.template.model.result.CommonResult;
  22. import com.template.model.result.PageUtils;
  23. import com.template.model.vo.*;
  24. import com.template.services.*;
  25. import io.swagger.models.auth.In;
  26. import org.apache.poi.hssf.usermodel.HSSFRow;
  27. import org.apache.poi.hssf.usermodel.HSSFSheet;
  28. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  29. import org.apache.poi.ss.usermodel.DataFormatter;
  30. import org.apache.poi.ss.usermodel.Row;
  31. import org.apache.poi.ss.usermodel.Sheet;
  32. import org.apache.poi.ss.usermodel.Workbook;
  33. import org.apache.poi.xssf.usermodel.XSSFRow;
  34. import org.apache.poi.xssf.usermodel.XSSFSheet;
  35. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  36. import org.slf4j.Logger;
  37. import org.slf4j.LoggerFactory;
  38. import org.springframework.beans.factory.annotation.Autowired;
  39. import org.springframework.transaction.annotation.Transactional;
  40. import org.springframework.util.StringUtils;
  41. import org.springframework.validation.BindingResult;
  42. import org.springframework.web.bind.annotation.RestController;
  43. import org.springframework.web.multipart.MultipartFile;
  44. import javax.servlet.http.HttpServletResponse;
  45. import java.io.IOException;
  46. import java.io.InputStream;
  47. import java.math.BigDecimal;
  48. import java.math.BigInteger;
  49. import java.text.ParseException;
  50. import java.time.LocalDateTime;
  51. import java.time.format.DateTimeFormatter;
  52. import java.util.*;
  53. import java.util.stream.Collectors;
  54. /**
  55. * <p>
  56. * 前端控制器
  57. * </p>
  58. *
  59. * @author ceshi
  60. * @since 2025-06-13
  61. */
  62. @RestController
  63. public class WelcomeStudentController implements WelcomeStudentControllerAPI {
  64. @Autowired
  65. private WelcomeStudentService welcomeStudentService;
  66. @Autowired
  67. private WelcomeFamilyService welcomeFamilyService;
  68. @Autowired
  69. private WelcomeAccompanyService welcomeAccompanyService;
  70. @Autowired
  71. private WelcomeBedService welcomeBedService;
  72. @Autowired
  73. private WelcomeAccountService welcomeAccountService;
  74. @Autowired
  75. private WelcomeSettingService welcomeSettingService;
  76. @Autowired
  77. private WelcomeArriveSettingService welcomeArriveSettingService;
  78. @Autowired
  79. private WelcomeOrgService welcomeOrgService;
  80. @Autowired
  81. private WelcomeCityService welcomeCityService;
  82. @Autowired
  83. private WelcomeSchoolService welcomeSchoolService;
  84. @Autowired
  85. private WelcomeBuildService welcomeBuildService;
  86. @Autowired
  87. private WelcomeDormitoryService welcomeDormitoryService;
  88. @Autowired
  89. private WelcomeVisitorService welcomeVisitorService;
  90. @Autowired
  91. private WelcomePaySettingService welcomePaySettingService;
  92. private static Logger logger = LoggerFactory.getLogger(WelcomeStudentController.class);
  93. @Override
  94. @AWelcomeLog("新增学生信息管理")
  95. @AWelcomeTypeLog("新增")
  96. @AWelcomeLogMode("学生信息管理")
  97. @AWelcomeLevelLog("信息")
  98. @Transactional(rollbackFor = {Exception.class})
  99. public CommonResult insertStudentInfo(InsertStudentRequest isr, BindingResult bindingResult) throws Exception {
  100. if (bindingResult.hasErrors()) {
  101. String st = paramUtils.getParamError(bindingResult);
  102. return CommonResult.fail(st);
  103. }
  104. if (!isr.getBatchValue().equals("本科") && !isr.getBatchValue().equals("专升本") && !isr.getBatchValue().equals("专科")) {
  105. return CommonResult.fail("层次为本科或专升本或专科");
  106. }
  107. int existCount = welcomeStudentService.existStudentInfo(isr.getAdmissNum(), isr.getCardId());
  108. if (existCount > 0) {
  109. return CommonResult.fail("当前录取号或身份证号已存在!");
  110. }
  111. //region 学生信息
  112. WelcomeStudent ws = new WelcomeStudent();
  113. ws.setAdmissNum(isr.getAdmissNum());
  114. ws.setName(isr.getName());
  115. ws.setPicture(StringUtils.hasText(isr.getPicture()) ? isr.getPicture() : "https://chtech.ncjti.edu.cn/welcome/homeimage/newStudentHeadImage.jpg");
  116. ws.setCardId(isr.getCardId());
  117. //region 校验身份证号 并根据身份证号获取出生年月和性别
  118. boolean isValidate = CardUtils.validateIdCard(isr.getCardId());//身份证是否合法
  119. if (!isValidate) {
  120. return CommonResult.fail("身份证不合法");
  121. }
  122. String sex = CardUtils.getSexByIdCard(isr.getCardId());
  123. if (!StringUtils.hasText(isr.getSex())) {
  124. ws.setSex(sex);
  125. } else {
  126. ws.setSex(isr.getSex());
  127. }
  128. String birthday = CardUtils.getBirthdayByIdCard(isr.getCardId());
  129. if (!StringUtils.hasText(isr.getBirthday())) {
  130. ws.setBirthday(birthday);
  131. } else {
  132. ws.setBirthday(isr.getBirthday());
  133. }
  134. //endregion
  135. ws.setSchool(isr.getSchool());
  136. ws.setSchoolId(isr.getSchoolId());
  137. ws.setCollege(isr.getCollege());
  138. ws.setMajor(isr.getMajor());
  139. ws.setClassstr(isr.getClassstr());
  140. ws.setCollegeId(isr.getCollegeId());
  141. ws.setMajorId(isr.getMajorId());
  142. ws.setClassstrId(isr.getClassstrId());
  143. ws.setExamNum(isr.getExamNum());
  144. ws.setEduSystem(isr.getEduSystem());
  145. ws.setGraduationSchool(isr.getGraduationSchool());
  146. ws.setBatchValue(isr.getBatchValue());
  147. ws.setPoliticalStatu(isr.getPoliticalStatu());
  148. ws.setNationality(isr.getNationality());
  149. ws.setPhone(isr.getPhone());
  150. ws.setOprovince(isr.getOprovince());
  151. ws.setOcity(isr.getOcity());
  152. ws.setOdistrict(isr.getOdistrict());
  153. ws.setOprovinceId(isr.getOprovinceId());
  154. ws.setOcityId(isr.getOcityId());
  155. ws.setOdistrictId(isr.getOdistrictId());
  156. ws.setProvinceId(isr.getProvinceId());
  157. ws.setCityId(isr.getCityId());
  158. ws.setDistrictId(isr.getDistrictId());
  159. ws.setProvince(isr.getProvince());
  160. ws.setCity(isr.getCity());
  161. ws.setDistrict(isr.getDistrict());
  162. ws.setAddress(isr.getAddress());
  163. ws.setTrafficMethod(isr.getTrafficMethod());
  164. ws.setArrive(isr.getArrive());
  165. ws.setArrvieDate(isr.getArrvieDate());
  166. ws.setArriveTime(isr.getArriveTime());
  167. ws.setArriveTimeId(isr.getArriveTimeId());
  168. ws.setZipCode(isr.getZipCode());
  169. ws.setRegisterOntime(isr.getRegisterOntime());
  170. ws.setIdenType(1);
  171. ws.setIsPay(0);
  172. ws.setFillStatus("未填报");
  173. ws.setIsRegistered(2);
  174. //ws.setAmountPayable(isr.getAmountPayable());
  175. //ws.setPayAmount(isr.getPayAmount());
  176. //ws.setIsDrive(isr.getIsDrive());
  177. //ws.setCarNumber(isr.getCarNumber());
  178. //endregion
  179. //region 家庭成员数据
  180. List<WelcomeFamily> wfs = new ArrayList<>();
  181. if (isr.getFvs() != null && isr.getFvs().size() > 0) {
  182. for (InsertFamilyRequest family : isr.getFvs()) {
  183. if (!(StringUtils.hasText(family.getFamilyShip()) && StringUtils.hasText(family.getName())
  184. && StringUtils.hasText(family.getWorkUnit()) && StringUtils.hasText(family.getPhone()))) {
  185. return CommonResult.fail("家庭成员信息不能为空!");
  186. }
  187. WelcomeFamily wf = new WelcomeFamily();
  188. wf.setStudentCard(ws.getCardId());
  189. wf.setFamilyShip(family.getFamilyShip());
  190. wf.setName(family.getName());
  191. wf.setWorkUnit(family.getWorkUnit());
  192. wf.setPhone(family.getPhone());
  193. wfs.add(wf);
  194. }
  195. }
  196. //endregion
  197. // //region 陪同人员数据
  198. // List<WelcomeAccompany> was = new ArrayList<>();
  199. // if (isr.getAvs() != null && isr.getAvs().size() > 0) {
  200. // for (InsertAccompanyRequest accompany : isr.getAvs()) {
  201. // if (!(StringUtils.hasText(accompany.getName()) && StringUtils.hasText(accompany.getPhone()))) {
  202. // return CommonResult.fail("陪同人员信息不能为空!");
  203. // }
  204. // WelcomeAccompany wa = new WelcomeAccompany();
  205. // wa.setStudentCard(ws.getCardId());
  206. // wa.setName(accompany.getName());
  207. // wa.setPhone(accompany.getPhone());
  208. // was.add(wa);
  209. // }
  210. // }
  211. //
  212. // //endregion
  213. //
  214. // //region 宿舍信息
  215. // WelcomeBed bedData = welcomeBedService.queryBedData(isr.getSchool(), isr.getBuildId(), isr.getDormitoryId(), Integer.valueOf(isr.getBed()));
  216. // if (bedData != null) {
  217. // if (StringUtils.hasText(bedData.getStudentCard())) {
  218. // return CommonResult.fail("当前床位已被他人入住,无法入住");
  219. // }
  220. // bedData.setStudentCard(isr.getCardId());
  221. // bedData.setCollege(isr.getCollege());
  222. // bedData.setCollegeId(isr.getCollegeId());
  223. // bedData.setMajor(isr.getMajor());
  224. // bedData.setMajorId(isr.getMajorId());
  225. // bedData.setClassstr(isr.getClassstr());
  226. // bedData.setClassstrId(isr.getClassstrId());
  227. // bedData.setIsCheck(1);
  228. // bedData.setCardNum(isr.getAdmissNum());
  229. // bedData.setName(isr.getName());
  230. // }
  231. //
  232. // //endregion
  233. try {
  234. int studentId = welcomeStudentService.insertWelcomeStudent(ws);
  235. if (studentId <= 0) {
  236. logger.error("添加学生失败,参数:" + JSON.toJSON(isr));
  237. throw new Exception("添加失败!");
  238. }
  239. if (wfs != null && wfs.size() > 0) {
  240. boolean insertBatch = welcomeFamilyService.saveBatch(wfs);
  241. if (!insertBatch) {
  242. logger.error("添加家庭成员失败,参数:" + JSON.toJSON(wfs));
  243. throw new Exception("添加失败!");
  244. }
  245. }
  246. // if (was != null && was.size() > 0) {
  247. // boolean insertBatch = welcomeAccompanyService.saveBatch(was);
  248. // if (!insertBatch) {
  249. // logger.error("添加陪同人员失败,参数:" + JSON.toJSON(was));
  250. // throw new Exception("添加失败!");
  251. // }
  252. // }
  253. //
  254. // int insertStudentDormitory = welcomeBedService.updateWelcomeBed(bedData);
  255. // if (insertStudentDormitory <= 0) {
  256. // logger.error("添加学生床位信息失败,参数:" + JSON.toJSON(bedData));
  257. // throw new Exception("添加失败!");
  258. // }
  259. } catch (Exception e) {
  260. logger.error(e.getMessage());
  261. throw new Exception("添加失败!");
  262. }
  263. return CommonResult.ok("添加成功");
  264. }
  265. @Override
  266. @AWelcomeLog("编辑学生信息管理")
  267. @AWelcomeTypeLog("编辑")
  268. @AWelcomeLogMode("学生信息管理")
  269. @AWelcomeLevelLog("信息")
  270. public CommonResult updateStudentInfo(updateStudentRequest usr, BindingResult bindingResult) throws Exception {
  271. if (bindingResult.hasErrors()) {
  272. String st = paramUtils.getParamError(bindingResult);
  273. return CommonResult.fail(st);
  274. }
  275. WelcomeStudent student = welcomeStudentService.getManageById(usr.getId());
  276. if (student == null) {
  277. return CommonResult.fail("学生数据已失效,编辑失败!");
  278. }
  279. if (!usr.getBatchValue().equals("本科") && !usr.getBatchValue().equals("专升本") && !usr.getBatchValue().equals("专科")) {
  280. return CommonResult.fail("层次为本科或专升本或专科");
  281. }
  282. //region 学生信息
  283. student.setAdmissNum(usr.getAdmissNum());
  284. student.setName(usr.getName());
  285. student.setPicture(StringUtils.hasText(usr.getPicture()) ? usr.getPicture() : "https://chtech.ncjti.edu.cn/welcome/homeimage/newStudentHeadImage.jpg");
  286. //student.setCardId(usr.getCardId());
  287. student.setSex(usr.getSex());
  288. student.setBirthday(usr.getBirthday());
  289. student.setSchool(usr.getSchool());
  290. student.setSchoolId(usr.getSchoolId());
  291. student.setCollege(usr.getCollege());
  292. student.setMajor(usr.getMajor());
  293. student.setClassstr(usr.getClassstr());
  294. student.setCollegeId(usr.getCollegeId());
  295. student.setMajorId(usr.getMajorId());
  296. student.setClassstrId(usr.getClassstrId());
  297. student.setExamNum(usr.getExamNum());
  298. student.setEduSystem(usr.getEduSystem());
  299. student.setGraduationSchool(usr.getGraduationSchool());
  300. student.setBatchValue(usr.getBatchValue());
  301. student.setPoliticalStatu(usr.getPoliticalStatu());
  302. student.setNationality(usr.getNationality());
  303. student.setPhone(usr.getPhone());
  304. student.setOprovince(usr.getOprovince());
  305. student.setOcity(usr.getOcity());
  306. student.setOdistrict(usr.getOdistrict());
  307. student.setOprovinceId(usr.getOprovinceId());
  308. student.setOcityId(usr.getOcityId());
  309. student.setOdistrictId(usr.getOdistrictId());
  310. student.setProvinceId(usr.getProvinceId());
  311. student.setCityId(usr.getCityId());
  312. student.setDistrictId(usr.getDistrictId());
  313. student.setProvince(usr.getProvince());
  314. student.setCity(usr.getCity());
  315. student.setDistrict(usr.getDistrict());
  316. student.setAddress(usr.getAddress());
  317. student.setTrafficMethod(usr.getTrafficMethod());
  318. student.setArrive(usr.getArrive());
  319. student.setArrvieDate(usr.getArrvieDate());
  320. student.setArriveTime(usr.getArriveTime());
  321. student.setArriveTimeId(usr.getArriveTimeId());
  322. student.setZipCode(usr.getZipCode());
  323. student.setRegisterOntime(usr.getRegisterOntime());
  324. student.setIdenType(1);
  325. //ws.setAmountPayable(isr.getAmountPayable());
  326. //ws.setPayAmount(isr.getPayAmount());
  327. //ws.setIsDrive(isr.getIsDrive());
  328. //ws.setCarNumber(isr.getCarNumber());
  329. //endregion
  330. //region 家庭成员数据
  331. List<WelcomeFamily> wfs = new ArrayList<>();
  332. if (usr.getFvs() != null && usr.getFvs().size() > 0) {
  333. for (InsertFamilyRequest family : usr.getFvs()) {
  334. if (!(StringUtils.hasText(family.getFamilyShip()) && StringUtils.hasText(family.getName())
  335. && StringUtils.hasText(family.getWorkUnit()) && StringUtils.hasText(family.getPhone()))) {
  336. return CommonResult.fail("家庭成员信息不能为空!");
  337. }
  338. WelcomeFamily wf = new WelcomeFamily();
  339. wf.setStudentCard(student.getCardId());
  340. wf.setFamilyShip(family.getFamilyShip());
  341. wf.setName(family.getName());
  342. wf.setWorkUnit(family.getWorkUnit());
  343. wf.setPhone(family.getPhone());
  344. wfs.add(wf);
  345. }
  346. }
  347. //endregion
  348. // //region 陪同人员数据
  349. // List<WelcomeAccompany> was = new ArrayList<>();
  350. // if (usr.getAvs() != null && usr.getAvs().size() > 0) {
  351. // for (InsertAccompanyRequest accompany : usr.getAvs()) {
  352. // if (!(StringUtils.hasText(accompany.getName()) && StringUtils.hasText(accompany.getPhone()))) {
  353. // return CommonResult.fail("陪同人员信息不能为空!");
  354. // }
  355. // WelcomeAccompany wa = new WelcomeAccompany();
  356. // wa.setStudentCard(student.getCardId());
  357. // wa.setName(accompany.getName());
  358. // wa.setPhone(accompany.getPhone());
  359. // was.add(wa);
  360. // }
  361. // }
  362. //
  363. // //endregion
  364. //
  365. // //region 宿舍信息
  366. // List<WelcomeBed> bedDatas = new ArrayList<>();
  367. // WelcomeBed bedData = welcomeBedService.queryBedData(usr.getSchool(), usr.getBuildId(), usr.getDormitoryId(), Integer.valueOf(usr.getBed()));
  368. // if (bedData != null) {//新床位
  369. // if (StringUtils.hasText(bedData.getStudentCard()) && !bedData.getStudentCard().equals(student.getCardId())) {
  370. // return CommonResult.fail("当前床位已被他人入住,无法入住");
  371. // }
  372. // if (!StringUtils.hasText(bedData.getStudentCard())) {
  373. // bedData.setStudentCard(student.getCardId());
  374. // bedData.setCollege(student.getCollege());
  375. // bedData.setCollegeId(student.getCollegeId());
  376. // bedData.setMajor(student.getMajor());
  377. // bedData.setMajorId(student.getMajorId());
  378. // bedData.setClassstr(student.getClassstr());
  379. // bedData.setClassstrId(student.getClassstrId());
  380. // bedData.setIsCheck(1);
  381. // bedData.setCardNum(student.getAdmissNum());
  382. // bedData.setName(student.getName());
  383. //
  384. // //把旧床位清空
  385. // WelcomeBed obedData = welcomeBedService.getBedByCardId(student.getCardId());
  386. // if (obedData == null) {
  387. // obedData = new WelcomeBed();
  388. // obedData.setStudentCard(null);
  389. // obedData.setCollege(null);
  390. // obedData.setCollegeId(null);
  391. // obedData.setMajor(null);
  392. // obedData.setMajorId(null);
  393. // obedData.setClassstr(null);
  394. // obedData.setClassstrId(null);
  395. // obedData.setIsCheck(0);
  396. // obedData.setCardNum(null);
  397. // obedData.setName(null);
  398. // bedDatas.add(obedData);
  399. // }
  400. // } else {
  401. // bedData.setStudentCard(student.getCardId());
  402. // bedData.setCollege(student.getCollege());
  403. // bedData.setCollegeId(student.getCollegeId());
  404. // bedData.setMajor(student.getMajor());
  405. // bedData.setMajorId(student.getMajorId());
  406. // bedData.setClassstr(student.getClassstr());
  407. // bedData.setClassstrId(student.getClassstrId());
  408. // bedData.setIsCheck(1);
  409. // bedData.setCardNum(student.getAdmissNum());
  410. // bedData.setName(student.getName());
  411. // }
  412. // bedDatas.add(bedData);
  413. //
  414. // }
  415. //
  416. // //endregion
  417. try {
  418. int studentId = welcomeStudentService.updateWelcomeStudent(student);
  419. if (studentId <= 0) {
  420. logger.error("编辑学生失败,参数:" + JSON.toJSON(usr));
  421. throw new Exception("编辑失败!");
  422. }
  423. int deleteF = welcomeFamilyService.deleteWelcomeFamilyByCard(student.getCardId());
  424. if (wfs != null && wfs.size() > 0) {
  425. boolean insertBatch = welcomeFamilyService.saveBatch(wfs);
  426. if (!insertBatch) {
  427. logger.error("编辑家庭成员失败,参数:" + JSON.toJSON(wfs));
  428. throw new Exception("编辑失败!");
  429. }
  430. }
  431. // int deleteA = welcomeAccompanyService.deleteWelcomeAccompanyByCard(student.getCardId());
  432. // if (was != null && was.size() > 0) {
  433. // boolean insertBatch = welcomeAccompanyService.saveBatch(was);
  434. // if (!insertBatch) {
  435. // logger.error("编辑陪同人员失败,参数:" + JSON.toJSON(was));
  436. // throw new Exception("编辑失败!");
  437. // }
  438. // }
  439. //
  440. // boolean updateBatch = welcomeBedService.updateBatchById(bedDatas);
  441. // if (!updateBatch) {
  442. // logger.error("添加宿舍信息失败,参数:" + JSON.toJSON(bedDatas));
  443. // throw new Exception("添加失败!");
  444. // }
  445. } catch (Exception e) {
  446. logger.error(e.getMessage());
  447. throw new Exception("编辑失败!");
  448. }
  449. return CommonResult.ok("编辑成功");
  450. }
  451. @Override
  452. public CommonResult queryPageStudents(String userId, int currentPage, int pageCount, Integer collegeId, Integer majorId, Integer classstrId, String trafficMethod, String name, String fillStatus, Integer isRegistered, Integer isPay, Integer isCheck, String school, String batchValue, Integer carNumber, Integer yearId) throws ParseException {
  453. String nstartTime = null;
  454. String nendTime = null;
  455. boolean isNowYear = false;
  456. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  457. if (yearId == null) {
  458. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  459. //当前时间小于本年度的7月1日 说明要查去年的数据
  460. if (lastYear) {
  461. nstartTime = (yearInt - 1) + "-06-01";
  462. nendTime = yearInt + "-06-01";
  463. } else {//今年
  464. isNowYear = true;
  465. nstartTime = yearInt + "-06-01";
  466. nendTime = (yearInt + 1) + "-06-01";
  467. }
  468. } else {
  469. nstartTime = yearId + "-06-01";
  470. nendTime = (yearId + 1) + "-06-01";
  471. }
  472. IPage<StudentPageVo> pages = new Page<>();
  473. PageUtils<StudentPageVo> result = new PageUtils<>(pages);
  474. WelcomeAccount wa = welcomeAccountService.getManageById(userId);
  475. if (wa == null) {
  476. return CommonResult.fail("当前账户已失效,无权限查看");
  477. }
  478. List<String> collegeIds = Arrays.asList(wa.getCollegeId().split(","));
  479. if (collegeId != null && collegeId.intValue() > 0) {
  480. if (!collegeIds.contains(String.valueOf(collegeId))) {
  481. pages.setCurrent(currentPage);
  482. pages.setSize(pageCount);
  483. return CommonResult.ok(result);
  484. } else {
  485. collegeIds = new ArrayList<>();
  486. collegeIds.add(String.valueOf(collegeId));
  487. }
  488. }
  489. result = welcomeStudentService.queryStudentPageList(currentPage, pageCount, collegeIds, majorId, classstrId, trafficMethod, name, fillStatus, isRegistered, isPay, isCheck, school, batchValue, carNumber, nstartTime, nendTime);
  490. if (result != null && result.getList() != null && result.getList().size() > 0) {
  491. List<StudentPageVo> students = result.getList().stream().filter(e -> e.getIsPay().intValue() == 0).collect(Collectors.toList());
  492. //只处理本学期的未达标人员的数据同步一下支付数据
  493. if (students != null && students.size() > 0 && isNowYear) {
  494. List<PayDetailsVo> pdvs = new ArrayList<>();
  495. List<Integer> ids = new ArrayList<>();
  496. for (StudentPageVo student : students) {
  497. List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(student.getAdmissNum(), TimeExchange.getYear());
  498. BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
  499. BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
  500. BigDecimal dkAmount = new BigDecimal(BigInteger.ZERO);//贷款金额
  501. for (JsonPayVo pi : payInfos) {
  502. dkAmount = dkAmount.add(pi.getDKJE());
  503. payAmount = payAmount.add(pi.getSJJE());
  504. yjPayAmount = yjPayAmount.add(pi.getYJJE());
  505. }
  506. BigDecimal studentPay = payAmount.add(dkAmount);
  507. student.setPayAmount(studentPay);
  508. student.setAmountPayable(yjPayAmount);
  509. System.out.println("进支付比较1" + JSON.toJSON(payInfos));
  510. if (payInfos != null && payInfos.size() > 0) {
  511. System.out.println("进支付比较2");
  512. WelcomePaySetting paySettings = welcomePaySettingService.queryPaySettingById(student.getCollegeId(), student.getMajorId(), student.getBatchValue(), nstartTime, nendTime);
  513. System.out.println("进支付比较3" + JSON.toJSON(paySettings));
  514. if (paySettings != null) {
  515. System.out.println("进支付比较4");
  516. if (studentPay.compareTo(paySettings.getPayAmount()) >= 0) {
  517. student.setIsPay(1);
  518. ids.add(student.getId());
  519. PayDetailsVo pdv = new PayDetailsVo();
  520. pdv.setId(student.getId());
  521. pdv.setPayAmount(studentPay);
  522. pdv.setAmountPayable(yjPayAmount);
  523. pdvs.add(pdv);
  524. } else {
  525. student.setIsPay(0);
  526. }
  527. } else {
  528. student.setIsPay(0);
  529. }
  530. } else {
  531. student.setIsPay(0);
  532. }
  533. }
  534. if (ids != null && ids.size() > 0) {
  535. List<WelcomeStudent> studentDatas = welcomeStudentService.queryStudents(ids);
  536. if(studentDatas != null && studentDatas.size() > 0){
  537. for (WelcomeStudent ws:studentDatas){
  538. Optional<PayDetailsVo> opdv = pdvs.stream().filter(e -> e.getId().intValue() == ws.getId().intValue()).findFirst();
  539. if(opdv != null && opdv.isPresent()){
  540. ws.setAmountPayable(opdv.get().getAmountPayable());
  541. ws.setPayAmount(opdv.get().getPayAmount());
  542. }
  543. ws.setIsPay(1);
  544. }
  545. boolean update = welcomeStudentService.updateBatchById(studentDatas);
  546. if (!update) {
  547. logger.error("获取支付信息导致学校信息查询失败");
  548. return CommonResult.fail("查询失败");
  549. }
  550. }
  551. }
  552. }
  553. }
  554. return CommonResult.ok(result);
  555. }
  556. @Override
  557. public CommonResult queryStudentDetail(int id) {
  558. StudentDetailVo result = new StudentDetailVo();
  559. WelcomeStudent ws = welcomeStudentService.getManageById(id);
  560. if (ws == null) {
  561. return CommonResult.ok("学生信息已失效,查看失败!");
  562. }
  563. //家庭成员
  564. List<FamilyVo> fvs = new ArrayList<>();
  565. List<WelcomeFamily> familys = welcomeFamilyService.getManageByCardId(ws.getCardId());
  566. if (familys != null && familys.size() > 0) {
  567. for (WelcomeFamily wf : familys) {
  568. FamilyVo fv = new FamilyVo();
  569. fv.setId(wf.getId());
  570. fv.setFamilyShip(wf.getFamilyShip());
  571. fv.setName(wf.getName());
  572. fv.setPhone(wf.getPhone());
  573. fv.setWorkUnit(wf.getWorkUnit());
  574. fvs.add(fv);
  575. }
  576. }
  577. result.setFvs(fvs);
  578. //陪同人员
  579. List<AccompanyVo> avs = new ArrayList<>();
  580. List<WelcomeAccompany> accompanys = welcomeAccompanyService.getManageByCardId(ws.getCardId());
  581. if (accompanys != null && accompanys.size() > 0) {
  582. for (WelcomeAccompany ac : accompanys) {
  583. AccompanyVo av = new AccompanyVo();
  584. av.setId(ac.getId());
  585. av.setName(ac.getName());
  586. av.setPhone(ac.getPhone());
  587. avs.add(av);
  588. }
  589. }
  590. result.setAvs(avs);
  591. //宿舍信息
  592. WelcomeBed wsd = welcomeBedService.getBedByCardId(ws.getCardId());
  593. if (wsd != null) {
  594. result.setBuild(wsd.getBuild());
  595. result.setBuildId(wsd.getBuildId());
  596. result.setDormitory(wsd.getDormitory());//寝室号
  597. result.setDormitoryId(wsd.getDormitoryId());//寝室号
  598. result.setBed(String.valueOf(wsd.getNumber()));//床位号
  599. result.setBedId(wsd.getId());//床位号
  600. }
  601. //时间段
  602. List<ArriveTimeVo> atvs = new ArrayList<>();
  603. List<WelcomeArriveSetting> wass = welcomeArriveSettingService.queryCheckDatas();
  604. if (wass != null && wass.size() > 0) {
  605. for (WelcomeArriveSetting was : wass) {
  606. ArriveTimeVo atv = new ArriveTimeVo();
  607. atv.setId(was.getId());
  608. atv.setStartTime(was.getStartTime());
  609. atv.setEndTime(was.getEndTime());
  610. atv.setTimeStr(was.getStartTime() + "-" + was.getEndTime());
  611. atv.setIsCheck((ws.getArriveTimeId() != null && was.getId().equals(ws.getArriveTimeId())) ? 1 : 0);
  612. atvs.add(atv);
  613. }
  614. }
  615. result.setAtvs(atvs);
  616. result.setId(ws.getId());
  617. result.setSchool(ws.getSchool());
  618. result.setSchoolId(ws.getSchoolId());
  619. result.setAdmissNum(ws.getAdmissNum());
  620. result.setName(ws.getName());
  621. result.setPicture(StringUtils.hasText(ws.getPicture()) ? ws.getPicture() : "https://chtech.ncjti.edu.cn/welcome/homeimage/newStudentHeadImage.jpg");
  622. result.setCardId(ws.getCardId());
  623. result.setSex(ws.getSex());
  624. result.setBirthday(ws.getBirthday());
  625. result.setCollege(ws.getCollege());
  626. result.setMajor(ws.getMajor());
  627. result.setClassstr(ws.getClassstr());
  628. result.setCollegeId(ws.getCollegeId());
  629. result.setMajorId(ws.getMajorId());
  630. result.setClassstrId(ws.getClassstrId());
  631. result.setExamNum(ws.getExamNum());
  632. result.setEduSystem(ws.getEduSystem());
  633. result.setGraduationSchool(ws.getGraduationSchool());
  634. result.setBatchValue(ws.getBatchValue());
  635. result.setPoliticalStatu(ws.getPoliticalStatu());
  636. result.setNationality(ws.getNationality());
  637. result.setPhone(ws.getPhone());
  638. result.setOprovinceId(ws.getOprovinceId());
  639. result.setOprovince(ws.getOprovince());
  640. result.setOcityId(ws.getOcityId());
  641. result.setOcity(ws.getOcity());
  642. result.setOdistrictId(ws.getOdistrictId());
  643. result.setOdistrict(ws.getOdistrict());
  644. result.setProvinceId(ws.getProvinceId());
  645. result.setProvince(ws.getProvince());
  646. result.setCityId(ws.getCityId());
  647. result.setCity(ws.getCity());
  648. result.setDistrictId(ws.getDistrictId());
  649. result.setDistrict(ws.getDistrict());
  650. result.setAddress(ws.getAddress());
  651. result.setRegisterOntime(ws.getRegisterOntime());
  652. result.setZipCode(ws.getZipCode());
  653. result.setTrafficMethod(ws.getTrafficMethod());
  654. result.setArrive(ws.getArrive());
  655. result.setArrvieDate(ws.getArrvieDate());
  656. result.setArriveTime(ws.getArriveTime());
  657. result.setArriveTimeId(ws.getArriveTimeId());
  658. result.setAmountPayable(ws.getAmountPayable());
  659. result.setPayAmount(ws.getPayAmount());
  660. result.setIsDrive(ws.getIsDrive());
  661. // 当前学生表里的车牌号为空
  662. WelcomeVisitorVO byCurUser = welcomeVisitorService.getByCurUser(ws.getCardId());
  663. if (ObjectUtils.isNotEmpty(byCurUser)) {
  664. result.setCarNumber(byCurUser.getCarNumber());
  665. }
  666. return CommonResult.ok(result);
  667. }
  668. @Override
  669. @AWelcomeLog("采集学生信息管理")
  670. @AWelcomeTypeLog("编辑")
  671. @AWelcomeLogMode("学生信息管理")
  672. @AWelcomeLevelLog("信息")
  673. @Transactional(rollbackFor = {Exception.class})
  674. public CommonResult infoCollection(InfoCollectionRequest icr, BindingResult bindingResult) throws Exception {
  675. logger.info("采集学生信息失败,icr参数:" + JSON.toJSON(icr));
  676. if (bindingResult.hasErrors()) {
  677. String st = paramUtils.getParamError(bindingResult);
  678. return CommonResult.fail(st);
  679. }
  680. if (!icr.getBatchValue().equals("本科") && !icr.getBatchValue().equals("专升本") && !icr.getBatchValue().equals("专科")) {
  681. return CommonResult.fail("层次为本科或专升本或专科");
  682. }
  683. WelcomeStudent ws = welcomeStudentService.getDataByIdcardOrNum(icr.getAdmissNum(), icr.getCardId());
  684. if (ws == null) {
  685. ws = new WelcomeStudent();
  686. }
  687. ws.setSchool(icr.getSchool());
  688. ws.setAdmissNum(icr.getAdmissNum());
  689. ws.setName(icr.getName());
  690. ws.setPicture(StringUtils.hasText(icr.getPicture()) ? icr.getPicture() : "https://chtech.ncjti.edu.cn/welcome/homeimage/newStudentHeadImage.jpg");
  691. //ws.setCardId(icr.getCardId());
  692. ws.setSex(icr.getSex());
  693. ws.setBirthday(icr.getBirthday());
  694. ws.setCollegeId(icr.getCollegeId());
  695. ws.setMajorId(icr.getMajorId());
  696. ws.setClassstrId(icr.getClassstrId());
  697. ws.setExamNum(icr.getExamNum());
  698. ws.setEduSystem(icr.getEduSystem());
  699. ws.setGraduationSchool(icr.getGraduationSchool());
  700. ws.setBatchValue(icr.getBatchValue());
  701. ws.setPoliticalStatu(icr.getPoliticalStatu());
  702. ws.setNationality(icr.getNationality());
  703. ws.setPhone(icr.getPhone());
  704. ws.setOprovinceId(icr.getOprovinceId());
  705. ws.setOprovince(icr.getOprovince());
  706. ws.setOcityId(icr.getOcityId());
  707. ws.setOcity(icr.getOcity());
  708. ws.setOdistrictId(icr.getOdistrictId());
  709. ws.setOdistrict(icr.getOdistrict());
  710. ws.setProvinceId(icr.getProvinceId());
  711. ws.setProvince(icr.getProvince());
  712. ws.setCityId(icr.getCityId());
  713. ws.setCity(icr.getCity());
  714. ws.setDistrictId(icr.getDistrictId());
  715. ws.setDistrict(icr.getDistrict());
  716. ws.setAddress(icr.getAddress());
  717. ws.setRegisterOntime(icr.getRegisterOntime());
  718. ws.setZipCode(icr.getZipCode());
  719. ws.setTrafficMethod(icr.getTrafficMethod());
  720. ws.setArrive(icr.getArrive());
  721. ws.setArrvieDate(icr.getArrvieDate());
  722. ws.setArriveTime(icr.getArriveTime());
  723. ws.setArriveTimeId(icr.getArriveTimeId());
  724. ws.setFillStatus("已填报");
  725. //家庭成员
  726. List<WelcomeFamily> wfs = new ArrayList<>();
  727. if (icr.getFvs() != null && icr.getFvs().size() > 0) {
  728. for (FamilyVo fv : icr.getFvs()) {
  729. if (!(StringUtils.hasText(fv.getName()) && StringUtils.hasText(fv.getPhone()) && StringUtils.hasText(fv.getWorkUnit()) && StringUtils.hasText(fv.getFamilyShip()))) {
  730. return CommonResult.fail("家庭成员信息不能为空!");
  731. }
  732. WelcomeFamily wf = new WelcomeFamily();
  733. wf.setName(fv.getName());
  734. wf.setPhone(fv.getPhone());
  735. wf.setWorkUnit(fv.getWorkUnit());
  736. wf.setFamilyShip(fv.getFamilyShip());
  737. wf.setStudentCard(ws.getCardId());
  738. wfs.add(wf);
  739. }
  740. }
  741. //陪同人员
  742. List<WelcomeAccompany> was = new ArrayList<>();
  743. if (icr.getAvs() != null && icr.getAvs().size() > 0) {
  744. for (AccompanyVo av : icr.getAvs()) {
  745. if (!(StringUtils.hasText(av.getName()) && StringUtils.hasText(av.getPhone()))) {
  746. return CommonResult.fail("家庭成员信息不能为空!");
  747. }
  748. WelcomeAccompany wa = new WelcomeAccompany();
  749. wa.setName(av.getName());
  750. wa.setPhone(av.getPhone());
  751. wa.setStudentCard(ws.getCardId());
  752. was.add(wa);
  753. }
  754. }
  755. if (!(ws.getIsPay() != null && ws.getIsPay().intValue() == 1)) {
  756. System.out.println("进支付比较");
  757. List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(ws.getAdmissNum(), TimeExchange.getYear());
  758. BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
  759. BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
  760. BigDecimal dkAmount = new BigDecimal(BigInteger.ZERO);//贷款金额
  761. for (JsonPayVo pi : payInfos) {
  762. dkAmount = dkAmount.add(pi.getDKJE());
  763. payAmount = payAmount.add(pi.getSJJE());
  764. yjPayAmount = yjPayAmount.add(pi.getYJJE());
  765. }
  766. BigDecimal studentPay = payAmount.add(dkAmount);
  767. ws.setPayAmount(studentPay);
  768. ws.setAmountPayable(yjPayAmount);
  769. System.out.println("进支付比较1" + JSON.toJSON(payInfos));
  770. if (payInfos != null && payInfos.size() > 0) {
  771. System.out.println("进支付比较2");
  772. String nstartTime = null;
  773. String nendTime = null;
  774. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  775. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  776. //当前时间小于本年度的7月1日 说明要查去年的数据
  777. if (lastYear) {
  778. nstartTime = (yearInt - 1) + "-06-01";
  779. nendTime = yearInt + "-06-01";
  780. } else {
  781. nstartTime = yearInt + "-06-01";
  782. nendTime = (yearInt + 1) + "-06-01";
  783. }
  784. WelcomePaySetting paySettings = welcomePaySettingService.queryPaySettingById(ws.getCollegeId(), ws.getMajorId(), ws.getBatchValue(), nstartTime, nendTime);
  785. System.out.println("进支付比较3" + JSON.toJSON(paySettings));
  786. if (paySettings != null) {
  787. System.out.println("进支付比较4");
  788. if (studentPay.compareTo(paySettings.getPayAmount()) >= 0) {
  789. ws.setIsPay(1);
  790. } else {
  791. ws.setIsPay(0);
  792. }
  793. } else {
  794. ws.setIsPay(0);
  795. }
  796. } else {
  797. ws.setIsPay(0);
  798. }
  799. }
  800. if (ws.getIsPay() == null) {
  801. ws.setIsPay(0);
  802. }
  803. try {
  804. System.out.println("信息采集1");
  805. if (ws.getId() != null) {
  806. int update = welcomeStudentService.updateWelcomeStudent(ws);
  807. if (update < 0) {
  808. System.out.println("信息采集1.1");
  809. logger.error("采集学生信息失败,ws参数:" + JSON.toJSON(ws));
  810. throw new Exception("采集学生信息失败!");
  811. //return CommonResult.fail("采集学生信息失败1");
  812. }
  813. } else {
  814. int insert = welcomeStudentService.insertWelcomeStudent(ws);
  815. if (insert < 0) {
  816. System.out.println("信息采集1.2");
  817. logger.error("采集学生信息失败,ws参数:" + JSON.toJSON(ws));
  818. throw new Exception("采集学生信息失败!");
  819. //return CommonResult.fail("采集学生信息失败1");
  820. }
  821. }
  822. System.out.println("信息采集2");
  823. if (wfs != null && wfs.size() > 0) {
  824. int deleteF = welcomeFamilyService.deleteWelcomeFamilyByCard(ws.getCardId());
  825. boolean resultWf = welcomeFamilyService.saveBatch(wfs);
  826. System.out.println("信息采集1.3");
  827. if (!resultWf) {
  828. System.out.println("信息采集1.4");
  829. logger.error("采集学生信息失败,wfs参数:" + JSON.toJSON(wfs));
  830. throw new Exception("采集学生信息失败!");
  831. //return CommonResult.fail("采集学生信息失败2");
  832. }
  833. }
  834. System.out.println("信息采集3");
  835. if (was != null && was.size() > 0) {
  836. int deleteF = welcomeAccompanyService.deleteWelcomeAccompanyByCard(ws.getCardId());
  837. boolean resultWa = welcomeAccompanyService.saveBatch(was);
  838. System.out.println("信息采集1.5");
  839. if (!resultWa) {
  840. System.out.println("信息采集1.6");
  841. logger.error("采集学生信息失败,was参数:" + JSON.toJSON(was));
  842. throw new Exception("采集学生信息失败!");
  843. //return CommonResult.fail("采集学生信息失败3");
  844. }
  845. }
  846. } catch (Exception e) {
  847. logger.error(e.getMessage());
  848. throw new Exception("采集失败!");
  849. //return CommonResult.fail("采集学生信息失败4");
  850. }
  851. System.out.println("信息采集1.7");
  852. return CommonResult.ok("采集完成!");
  853. }
  854. @Override
  855. @AWelcomeLog("删除学生信息管理")
  856. @AWelcomeTypeLog("删除")
  857. @AWelcomeLogMode("学生信息管理")
  858. @AWelcomeLevelLog("警告")
  859. @Transactional(rollbackFor = {Exception.class})
  860. public CommonResult deleteStudentInfo(int id) throws Exception {
  861. System.out.println("删除了学生信息:" + id);
  862. WelcomeStudent ws = welcomeStudentService.getManageById(id);
  863. if (ws == null) {
  864. return CommonResult.fail("学生信息已失效,无法进行删除操作!");
  865. }
  866. //把旧床位清空
  867. WelcomeBed obedData = welcomeBedService.getBedByCardId(ws.getCardId());
  868. // if (obedData != null) {
  869. // obedData.setStudentCard(null);
  870. // obedData.setIsCheck(0);
  871. // obedData.setCardNum(null);
  872. // obedData.setName(null);
  873. // }
  874. try {
  875. //删除学生数据
  876. int deleteStudent = welcomeStudentService.deleteWelcomeStudentById(id);
  877. if (deleteStudent <= 0) {
  878. logger.error("删除学生信息失败,id参数:" + JSON.toJSON(id));
  879. throw new Exception("删除学生信息失败!");
  880. }
  881. if (obedData != null) {
  882. //删除宿舍数据
  883. // int deleteSd = welcomeBedService.updateWelcomeBed(obedData);
  884. // if (deleteSd < 0) {
  885. // logger.error("删除宿舍失败,obedData参数:" + JSON.toJSON(obedData));
  886. // throw new Exception("删除学生信息失败!");
  887. // }
  888. welcomeBedService.updateData(obedData.getId());
  889. // 修改寝室信息
  890. WelcomeDormitory welcomeDormitory = welcomeDormitoryService.getById(obedData.getDormitoryId());
  891. if (ObjectUtils.isNotEmpty(welcomeDormitory)) {
  892. Integer freeBedNumber = welcomeDormitory.getFreeBedNumber();
  893. Integer bedNumber = welcomeDormitory.getBedNumber();
  894. freeBedNumber = freeBedNumber + 1;
  895. if (bedNumber.equals(freeBedNumber)) {
  896. welcomeDormitory.setFreeBedNumber(freeBedNumber);
  897. welcomeDormitory.setStatus(1);
  898. } else if (bedNumber > freeBedNumber) {
  899. welcomeDormitory.setFreeBedNumber(freeBedNumber);
  900. welcomeDormitory.setStatus(3);
  901. }
  902. welcomeDormitoryService.updateById(welcomeDormitory);
  903. }
  904. }
  905. //删除同行人员
  906. int deleteWa = welcomeAccompanyService.deleteWelcomeAccompanyByCard(ws.getCardId());
  907. //删除家庭成员
  908. int deletef = welcomeFamilyService.deleteWelcomeFamilyByCard(ws.getCardId());
  909. } catch (Exception e) {
  910. logger.error(e.getMessage());
  911. throw new Exception("删除失败!");
  912. }
  913. return CommonResult.ok("删除成功");
  914. }
  915. @Override
  916. @AWelcomeLog("导入学生信息管理")
  917. @AWelcomeTypeLog("导入")
  918. @AWelcomeLogMode("学生信息管理")
  919. @AWelcomeLevelLog("信息")
  920. public CommonResult importStudentExcel(MultipartFile file) throws IOException, ParseException {
  921. System.out.println("导入学生信息");
  922. if (file.isEmpty() || file.getSize() == 0) {
  923. return CommonResult.fail("导入文件不能为空");
  924. }
  925. String ContentType = file.getContentType();
  926. InputStream inputStream = file.getInputStream();
  927. List<WelcomeStudent> result = new ArrayList<>();
  928. //xls格式文件
  929. if (ContentType.equals(eFileType.Xls.getValue())) {
  930. CommonResult<List<WelcomeStudent>> resultData = readXls(inputStream);
  931. if (!resultData.isSuccess()) {
  932. return resultData;
  933. }
  934. result = resultData.getData();
  935. } else if (ContentType.equals(eFileType.Xlsx.getValue())) {
  936. CommonResult<List<WelcomeStudent>> resultData = readXlsx(inputStream);
  937. if (!resultData.isSuccess()) {
  938. return resultData;
  939. }
  940. result = resultData.getData();
  941. } else {
  942. return CommonResult.fail("学生信息数据导入只支持Xls或Xlsx格式文件");
  943. }
  944. StringBuilder sb = new StringBuilder();
  945. List<String> cardIds = result.stream().map(WelcomeStudent::getCardId).collect(Collectors.toList());
  946. List<WelcomeStudent> existStudents = welcomeStudentService.queryStudentByCardId(cardIds);
  947. if (existStudents != null && existStudents.size() > 0) {
  948. for (WelcomeStudent ws : result) {
  949. Optional<WelcomeStudent> ows = existStudents.stream().filter(e -> e.getCardId().equals(ws.getCardId())).findFirst();
  950. if (ows != null && ows.isPresent()) {
  951. sb.append(ows.get().getName() + ows.get().getCardId() + "数据在数据库中已存在;");
  952. ws.setId(ows.get().getId());
  953. ws.setAdmissNum(ws.getAdmissNum());//录取号
  954. ws.setName(ws.getName());//姓名
  955. ws.setCardId(ws.getCardId());//身份证号
  956. ws.setSchool(ws.getSchool());//校区
  957. ws.setSchoolId(eSchool.stringOf(ws.getSchool()));//校区
  958. ws.setCollege(ws.getCollege());
  959. ws.setCollegeId(ws.getCollegeId());
  960. ws.setMajor(ws.getMajor());
  961. ws.setMajorId(ws.getMajorId());
  962. ws.setClassstr(ws.getClassstr());
  963. ws.setClassstrId(ws.getClassstrId());
  964. ws.setExamNum(ws.getExamNum());//考生号
  965. ws.setEduSystem(ws.getEduSystem());//学制
  966. ws.setGraduationSchool(ws.getGraduationSchool());//毕业中学
  967. ws.setBatchValue(ws.getBatchValue());//层次
  968. ws.setPoliticalStatu(ws.getPoliticalStatu());//政治面貌
  969. ws.setNationality(ws.getNationality());//民族
  970. ws.setPhone(ws.getPhone());//手机号码
  971. ws.setOprovince(ws.getOprovince());
  972. ws.setOprovinceId(ws.getOprovinceId());
  973. ws.setOcity(ws.getOcity());
  974. ws.setOcityId(ws.getOcityId());
  975. ws.setOdistrict(ws.getOdistrict());
  976. ws.setOdistrictId(ws.getOdistrictId());
  977. ws.setProvince(ws.getProvince());
  978. ws.setProvinceId(ws.getProvinceId());
  979. ws.setCity(ws.getCity());
  980. ws.setCityId(ws.getCityId());
  981. ws.setDistrict(ws.getDistrict());
  982. ws.setDistrictId(ws.getDistrictId());
  983. ws.setAddress(ws.getAddress());
  984. ws.setZipCode(ws.getZipCode());
  985. ws.setIsPay(0);
  986. ws.setPicture("https://chtech.ncjti.edu.cn/welcome/homeimage/studentImage/" + ws.getCardId() + ".jpg");
  987. }
  988. }
  989. }
  990. boolean resultBool = welcomeStudentService.saveOrUpdateBatch(result);
  991. System.out.println("导入学生1");
  992. return resultBool ? CommonResult.ok("导入成功:" + sb.toString()) : CommonResult.fail("导入失败");
  993. }
  994. /**
  995. * xls文件读取方法
  996. *
  997. * @param inputStream
  998. * @return
  999. * @throws IOException
  1000. * @throws ParseException
  1001. */
  1002. private CommonResult<List<WelcomeStudent>> readXls(InputStream inputStream) throws IOException, ParseException {
  1003. List<WelcomeStudent> result = new ArrayList<>();
  1004. HSSFWorkbook sheets = new HSSFWorkbook(inputStream);
  1005. List<WelcomeOrg> ws = welcomeOrgService.list(null);
  1006. List<WelcomeCity> citys = welcomeCityService.list(null);
  1007. //读取第一张sheet
  1008. HSSFSheet sheetAt = sheets.getSheetAt(0);
  1009. DataFormatter dataFormatter = new DataFormatter();
  1010. try {
  1011. //rowNum = 3 从第三行开始获取值
  1012. //sheetAt.getLastRowNum():从0开始统计数量 所以得+1
  1013. for (int rowNum = 0; rowNum < sheetAt.getLastRowNum() + 1; rowNum++) {
  1014. HSSFRow row = sheetAt.getRow(rowNum);
  1015. if (row != null) {
  1016. //使用了getStringCellValue()方法来获取值,POI会判断单元格的类型,如果非字符串类型就会抛出上面的异常。
  1017. //所以先使用setCellType()方法先将该单元格的类型设置为STRING
  1018. //然后poi会根据字符串读取它
  1019. //第一行数据获取月份
  1020. if (rowNum == 0) {
  1021. String number = dataFormatter.formatCellValue(row.getCell(0));//序号
  1022. if (!number.equals("序号")) {
  1023. return CommonResult.fail("导入数据第一列为序号");
  1024. }
  1025. String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
  1026. if (!assNum.equals("录取号")) {
  1027. return CommonResult.fail("导入数据第二列为录取号");
  1028. }
  1029. String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
  1030. if (!name.equals("姓名")) {
  1031. return CommonResult.fail("导入数据第三列为姓名");
  1032. }
  1033. String cardId = dataFormatter.formatCellValue(row.getCell(3));//身份证号
  1034. if (!cardId.equals("身份证号")) {
  1035. return CommonResult.fail("导入数据第四列为身份证号");
  1036. }
  1037. String school = dataFormatter.formatCellValue(row.getCell(4));//校区
  1038. if (!school.equals("校区")) {
  1039. return CommonResult.fail("导入数据第五列为校区");
  1040. }
  1041. String college = dataFormatter.formatCellValue(row.getCell(5));//院系
  1042. if (!college.equals("院系")) {
  1043. return CommonResult.fail("导入数据第六列为院系");
  1044. }
  1045. String major = dataFormatter.formatCellValue(row.getCell(6));//专业
  1046. if (!major.equals("专业")) {
  1047. return CommonResult.fail("导入数据第七列为专业");
  1048. }
  1049. String classstr = dataFormatter.formatCellValue(row.getCell(7));//班级
  1050. if (!classstr.equals("班级")) {
  1051. return CommonResult.fail("导入数据第八列为班级");
  1052. }
  1053. String examNum = dataFormatter.formatCellValue(row.getCell(8));//考生号
  1054. if (!examNum.equals("考生号")) {
  1055. return CommonResult.fail("导入数据第九列为考生号");
  1056. }
  1057. String eduSystem = dataFormatter.formatCellValue(row.getCell(9));//学制
  1058. if (!eduSystem.equals("学制")) {
  1059. return CommonResult.fail("导入数据第十列为学制");
  1060. }
  1061. String graSchool = dataFormatter.formatCellValue(row.getCell(10));//毕业中学
  1062. if (!graSchool.equals("毕业中学")) {
  1063. return CommonResult.fail("导入数据第十一列为毕业中学层次");
  1064. }
  1065. String batchValue = dataFormatter.formatCellValue(row.getCell(11));//层次
  1066. if (!batchValue.equals("层次")) {
  1067. return CommonResult.fail("导入数据第十二列为层次");
  1068. }
  1069. String politicalStatu = dataFormatter.formatCellValue(row.getCell(12));//政治面貌
  1070. if (!politicalStatu.equals("政治面貌")) {
  1071. return CommonResult.fail("导入数据第十三列为政治面貌");
  1072. }
  1073. String nationality = dataFormatter.formatCellValue(row.getCell(13));//民族
  1074. if (!nationality.equals("民族")) {
  1075. return CommonResult.fail("导入数据第十四列为民族");
  1076. }
  1077. String phone = dataFormatter.formatCellValue(row.getCell(14));//手机号码
  1078. if (!phone.equals("手机号码")) {
  1079. return CommonResult.fail("导入数据第十五列为手机号码");
  1080. }
  1081. String nativePlace = dataFormatter.formatCellValue(row.getCell(15));//籍贯
  1082. if (!nativePlace.contains("籍贯")) {
  1083. return CommonResult.fail("导入数据第十六列为籍贯");
  1084. }
  1085. String addressPlace = dataFormatter.formatCellValue(row.getCell(16));//家庭住址
  1086. if (!addressPlace.contains("家庭住址")) {
  1087. return CommonResult.fail("导入数据第十七列为家庭住址");
  1088. }
  1089. String addressDetail = dataFormatter.formatCellValue(row.getCell(17));//详细住址
  1090. if (!addressDetail.equals("详细住址")) {
  1091. return CommonResult.fail("导入数据第十八列为详细住址");
  1092. }
  1093. String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
  1094. if (!zipCode.equals("邮编")) {
  1095. return CommonResult.fail("导入数据第十九列为邮编");
  1096. }
  1097. } else {
  1098. WelcomeStudent studentData = new WelcomeStudent();
  1099. String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
  1100. if (!StringUtils.hasText(assNum)) {
  1101. break;
  1102. }
  1103. studentData.setAdmissNum(assNum);
  1104. String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
  1105. studentData.setName(name);
  1106. String cardId = dataFormatter.formatCellValue(row.getCell(3));//身份证号
  1107. //region 校验身份证号 并根据身份证号获取出生年月和性别
  1108. boolean isValidate = CardUtils.validateIdCard(cardId);//身份证是否合法
  1109. if (!isValidate) {
  1110. return CommonResult.fail("录取编号为" + assNum + "的身份证不合法");
  1111. }
  1112. String sex = CardUtils.getSexByIdCard(cardId);
  1113. if (sex != null) {
  1114. studentData.setSex(sex);
  1115. }
  1116. String birthday = CardUtils.getBirthdayByIdCard(cardId);
  1117. if (birthday != null) {
  1118. studentData.setBirthday(birthday);
  1119. }
  1120. //endregion
  1121. studentData.setCardId(cardId);
  1122. String school = dataFormatter.formatCellValue(row.getCell(4));//校区
  1123. studentData.setSchool(school);
  1124. studentData.setSchoolId(eSchool.stringOf(school));
  1125. //region 院系专业
  1126. String college = dataFormatter.formatCellValue(row.getCell(5));//院系
  1127. Optional<WelcomeOrg> owo = ws.stream().filter(e -> e.getName().equals(college)).findFirst();
  1128. if (owo != null && owo.isPresent()) {
  1129. studentData.setCollege(college);
  1130. studentData.setCollegeId(owo.get().getId());
  1131. }
  1132. String major = dataFormatter.formatCellValue(row.getCell(6));//专业
  1133. Optional<WelcomeOrg> omwo = ws.stream().filter(e -> owo != null && owo.isPresent() && e.getParentId().intValue() == owo.get().getId().intValue() && e.getName().equals(major)).findFirst();
  1134. if (omwo != null && omwo.isPresent()) {
  1135. studentData.setMajor(major);
  1136. studentData.setMajorId(omwo.get().getId());
  1137. }
  1138. String classstr = dataFormatter.formatCellValue(row.getCell(7));//班级
  1139. Optional<WelcomeOrg> ocwo = ws.stream().filter(e -> omwo != null && omwo.isPresent() && e.getParentId().intValue() == omwo.get().getId().intValue() && e.getName().equals(classstr)).findFirst();
  1140. if (ocwo != null && ocwo.isPresent()) {
  1141. studentData.setClassstr(classstr);
  1142. studentData.setClassstrId(ocwo.get().getId());
  1143. }
  1144. //endregion
  1145. String examNum = dataFormatter.formatCellValue(row.getCell(8));//考生号
  1146. studentData.setExamNum(examNum);
  1147. String eduSystem = dataFormatter.formatCellValue(row.getCell(9));//学制
  1148. studentData.setEduSystem(eduSystem);
  1149. String graSchool = dataFormatter.formatCellValue(row.getCell(10));//毕业中学
  1150. studentData.setGraduationSchool(graSchool);
  1151. String batchValue = dataFormatter.formatCellValue(row.getCell(11));//层次
  1152. if (!batchValue.equals("本科") && !batchValue.equals("专升本") && !batchValue.equals("专科")) {
  1153. return CommonResult.fail("层次为本科或专升本或专科");
  1154. }
  1155. studentData.setBatchValue(batchValue);
  1156. String politicalStatu = dataFormatter.formatCellValue(row.getCell(12));//政治面貌
  1157. studentData.setPoliticalStatu(politicalStatu);
  1158. String nationality = dataFormatter.formatCellValue(row.getCell(13));//民族
  1159. studentData.setNationality(nationality);
  1160. String phone = dataFormatter.formatCellValue(row.getCell(14));//手机号码
  1161. studentData.setPhone(phone);
  1162. //region 籍贯
  1163. String nativePlace = dataFormatter.formatCellValue(row.getCell(15));//籍贯
  1164. String[] addressDatas = nativePlace.split("/");
  1165. if (citys != null && citys.size() > 0) {
  1166. if (addressDatas != null && addressDatas.length >= 1 && StringUtils.hasText(nativePlace)) {
  1167. if (!addressDatas[0].contains("省")) {
  1168. return CommonResult.fail("录取编号为\" + assNum + \"的籍贯格式应该是 省/市/县");
  1169. }
  1170. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressDatas[0])).findFirst();
  1171. if (oProvince != null && oProvince.isPresent()) {
  1172. studentData.setOprovince(addressDatas[0]);
  1173. studentData.setOprovinceId(oProvince.get().getId());
  1174. } else {
  1175. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  1176. }
  1177. }
  1178. if (addressDatas != null && addressDatas.length >= 2) {
  1179. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressDatas[1])).findFirst();
  1180. if (oProvince != null && oProvince.isPresent()) {
  1181. studentData.setOcity(addressDatas[1]);
  1182. studentData.setOcityId(oProvince.get().getId());
  1183. } else {
  1184. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  1185. }
  1186. }
  1187. if (addressDatas != null && addressDatas.length >= 3) {
  1188. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getCityZh().equals(addressDatas[1]) && addressDatas[2].contains(e.getDistrictZh())).findFirst();
  1189. if (oProvince != null && oProvince.isPresent()) {
  1190. studentData.setOdistrict(addressDatas[2]);
  1191. studentData.setOdistrictId(oProvince.get().getId());
  1192. } else {
  1193. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  1194. }
  1195. }
  1196. }
  1197. //endregion
  1198. //region 家庭住址
  1199. String addressPlace = dataFormatter.formatCellValue(row.getCell(16));//家庭住址
  1200. String[] addressPlaces = addressPlace.split("/");
  1201. if (citys != null && citys.size() > 0) {
  1202. if (addressPlaces != null && addressPlaces.length >= 1 && StringUtils.hasText(addressPlace)) {
  1203. if (!addressPlaces[0].contains("省")) {
  1204. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1205. }
  1206. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[0])).findFirst();
  1207. if (oProvince != null && oProvince.isPresent()) {
  1208. studentData.setProvince(addressPlaces[0]);
  1209. studentData.setProvinceId(oProvince.get().getId());
  1210. } else {
  1211. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1212. }
  1213. }
  1214. if (addressPlaces != null && addressPlaces.length >= 2) {
  1215. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[1])).findFirst();
  1216. if (oProvince != null && oProvince.isPresent()) {
  1217. studentData.setCity(addressPlaces[1]);
  1218. studentData.setCityId(oProvince.get().getId());
  1219. } else {
  1220. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1221. }
  1222. }
  1223. if (addressPlaces != null && addressPlaces.length >= 3) {
  1224. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getCityZh().equals(addressPlaces[1]) && addressPlaces[2].contains(e.getDistrictZh())).findFirst();
  1225. if (oProvince != null && oProvince.isPresent()) {
  1226. studentData.setDistrict(addressPlaces[2]);
  1227. studentData.setDistrictId(oProvince.get().getId());
  1228. } else {
  1229. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1230. }
  1231. }
  1232. }
  1233. //endregion
  1234. String addressDetail = dataFormatter.formatCellValue(row.getCell(17));//详细住址
  1235. studentData.setAddress(addressDetail);
  1236. String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
  1237. studentData.setZipCode(zipCode);
  1238. studentData.setIdenType(1);
  1239. studentData.setFillStatus("未填报");
  1240. studentData.setIsRegistered(2);
  1241. studentData.setIsPay(0);
  1242. //studentData.setPicture("https://chtech.ncjti.edu.cn/welcome/homeimage/newStudentHeadImage.jpg");
  1243. studentData.setPicture("https://chtech.ncjti.edu.cn/welcome/homeimage/studentImage/" + studentData.getCardId() + ".jpg");
  1244. result.add(studentData);
  1245. }
  1246. }
  1247. }
  1248. } catch (Exception e) {
  1249. return CommonResult.fail("请按模板格式导入数据");
  1250. }
  1251. return CommonResult.ok(result);
  1252. }
  1253. /**
  1254. * xls文件读取方法
  1255. *
  1256. * @param inputStream
  1257. * @return
  1258. * @throws IOException
  1259. * @throws ParseException
  1260. */
  1261. private CommonResult<List<WelcomeStudent>> readXlsx(InputStream inputStream) throws IOException, ParseException {
  1262. List<WelcomeStudent> result = new ArrayList<>();
  1263. XSSFWorkbook sheets = new XSSFWorkbook(inputStream);
  1264. List<WelcomeOrg> ws = welcomeOrgService.list(null);
  1265. List<WelcomeCity> citys = welcomeCityService.list(null);
  1266. //读取第一张sheet
  1267. XSSFSheet sheetAt = sheets.getSheetAt(0);
  1268. DataFormatter dataFormatter = new DataFormatter();
  1269. try {
  1270. //rowNum = 3 从第三行开始获取值
  1271. //sheetAt.getLastRowNum():从0开始统计数量 所以得+1
  1272. for (int rowNum = 0; rowNum < sheetAt.getLastRowNum() + 1; rowNum++) {
  1273. XSSFRow row = sheetAt.getRow(rowNum);
  1274. if (row != null) {
  1275. //使用了getStringCellValue()方法来获取值,POI会判断单元格的类型,如果非字符串类型就会抛出上面的异常。
  1276. //所以先使用setCellType()方法先将该单元格的类型设置为STRING
  1277. //然后poi会根据字符串读取它
  1278. //第一行数据获取月份
  1279. if (rowNum == 0) {
  1280. String number = dataFormatter.formatCellValue(row.getCell(0));//序号
  1281. if (!number.equals("序号")) {
  1282. return CommonResult.fail("导入数据第一列为序号");
  1283. }
  1284. String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
  1285. if (!assNum.equals("录取号")) {
  1286. return CommonResult.fail("导入数据第二列为录取号");
  1287. }
  1288. String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
  1289. if (!name.equals("姓名")) {
  1290. return CommonResult.fail("导入数据第三列为姓名");
  1291. }
  1292. String cardId = dataFormatter.formatCellValue(row.getCell(3));//身份证号
  1293. if (!cardId.equals("身份证号")) {
  1294. return CommonResult.fail("导入数据第四列为身份证号");
  1295. }
  1296. String school = dataFormatter.formatCellValue(row.getCell(4));//校区
  1297. if (!school.equals("校区")) {
  1298. return CommonResult.fail("导入数据第五列为校区");
  1299. }
  1300. String college = dataFormatter.formatCellValue(row.getCell(5));//院系
  1301. if (!college.equals("院系")) {
  1302. return CommonResult.fail("导入数据第六列为院系");
  1303. }
  1304. String major = dataFormatter.formatCellValue(row.getCell(6));//专业
  1305. if (!major.equals("专业")) {
  1306. return CommonResult.fail("导入数据第七列为专业");
  1307. }
  1308. String classstr = dataFormatter.formatCellValue(row.getCell(7));//班级
  1309. if (!classstr.equals("班级")) {
  1310. return CommonResult.fail("导入数据第八列为班级");
  1311. }
  1312. String examNum = dataFormatter.formatCellValue(row.getCell(8));//考生号
  1313. if (!examNum.equals("考生号")) {
  1314. return CommonResult.fail("导入数据第九列为考生号");
  1315. }
  1316. String eduSystem = dataFormatter.formatCellValue(row.getCell(9));//学制
  1317. if (!eduSystem.equals("学制")) {
  1318. return CommonResult.fail("导入数据第十列为学制");
  1319. }
  1320. String graSchool = dataFormatter.formatCellValue(row.getCell(10));//毕业中学
  1321. if (!graSchool.equals("毕业中学")) {
  1322. return CommonResult.fail("导入数据第十一列为毕业中学层次");
  1323. }
  1324. String batchValue = dataFormatter.formatCellValue(row.getCell(11));//层次
  1325. if (!batchValue.equals("层次")) {
  1326. return CommonResult.fail("导入数据第十二列为层次");
  1327. }
  1328. String politicalStatu = dataFormatter.formatCellValue(row.getCell(12));//政治面貌
  1329. if (!politicalStatu.equals("政治面貌")) {
  1330. return CommonResult.fail("导入数据第十三列为政治面貌");
  1331. }
  1332. String nationality = dataFormatter.formatCellValue(row.getCell(13));//民族
  1333. if (!nationality.equals("民族")) {
  1334. return CommonResult.fail("导入数据第十四列为民族");
  1335. }
  1336. String phone = dataFormatter.formatCellValue(row.getCell(14));//手机号码
  1337. if (!phone.equals("手机号码")) {
  1338. return CommonResult.fail("导入数据第十五列为手机号码");
  1339. }
  1340. String nativePlace = dataFormatter.formatCellValue(row.getCell(15));//籍贯
  1341. if (!nativePlace.contains("籍贯")) {
  1342. return CommonResult.fail("导入数据第十六列为籍贯");
  1343. }
  1344. String addressPlace = dataFormatter.formatCellValue(row.getCell(16));//家庭住址
  1345. if (!addressPlace.contains("家庭住址")) {
  1346. return CommonResult.fail("导入数据第十七列为家庭住址");
  1347. }
  1348. String addressDetail = dataFormatter.formatCellValue(row.getCell(17));//详细住址
  1349. if (!addressDetail.equals("详细住址")) {
  1350. return CommonResult.fail("导入数据第十八列为详细住址");
  1351. }
  1352. String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
  1353. if (!zipCode.equals("邮编")) {
  1354. return CommonResult.fail("导入数据第十九列为邮编");
  1355. }
  1356. } else {
  1357. WelcomeStudent studentData = new WelcomeStudent();
  1358. String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
  1359. if (!StringUtils.hasText(assNum)) {
  1360. break;
  1361. }
  1362. studentData.setAdmissNum(assNum);
  1363. String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
  1364. studentData.setName(name);
  1365. String cardId = dataFormatter.formatCellValue(row.getCell(3));//身份证号
  1366. //region 校验身份证号 并根据身份证号获取出生年月和性别
  1367. boolean isValidate = CardUtils.validateIdCard(cardId);//身份证是否合法
  1368. if (!isValidate) {
  1369. return CommonResult.fail("录取编号为" + assNum + "的身份证不合法");
  1370. }
  1371. String sex = CardUtils.getSexByIdCard(cardId);
  1372. if (sex != null) {
  1373. studentData.setSex(sex);
  1374. }
  1375. String birthday = CardUtils.getBirthdayByIdCard(cardId);
  1376. if (birthday != null) {
  1377. studentData.setBirthday(birthday);
  1378. }
  1379. //endregion
  1380. studentData.setCardId(cardId);
  1381. String school = dataFormatter.formatCellValue(row.getCell(4));//校区
  1382. studentData.setSchool(school);
  1383. studentData.setSchoolId(eSchool.stringOf(school));
  1384. //region 院系专业
  1385. String college = dataFormatter.formatCellValue(row.getCell(5));//院系
  1386. Optional<WelcomeOrg> owo = ws.stream().filter(e -> e.getName().equals(college)).findFirst();
  1387. if (owo != null && owo.isPresent()) {
  1388. studentData.setCollege(college);
  1389. studentData.setCollegeId(owo.get().getId());
  1390. }
  1391. String major = dataFormatter.formatCellValue(row.getCell(6));//专业
  1392. Optional<WelcomeOrg> omwo = ws.stream().filter(e -> owo != null && owo.isPresent() && e.getParentId().intValue() == owo.get().getId().intValue() && e.getName().equals(major)).findFirst();
  1393. if (omwo != null && omwo.isPresent()) {
  1394. studentData.setMajor(major);
  1395. studentData.setMajorId(omwo.get().getId());
  1396. }
  1397. String classstr = dataFormatter.formatCellValue(row.getCell(7));//班级
  1398. Optional<WelcomeOrg> ocwo = ws.stream().filter(e -> omwo != null && omwo.isPresent() && e.getParentId().intValue() == omwo.get().getId().intValue() && e.getName().equals(classstr)).findFirst();
  1399. if (ocwo != null && ocwo.isPresent()) {
  1400. studentData.setClassstr(classstr);
  1401. studentData.setClassstrId(ocwo.get().getId());
  1402. }
  1403. //endregion
  1404. String examNum = dataFormatter.formatCellValue(row.getCell(8));//考生号
  1405. studentData.setExamNum(examNum);
  1406. String eduSystem = dataFormatter.formatCellValue(row.getCell(9));//学制
  1407. studentData.setEduSystem(eduSystem);
  1408. String graSchool = dataFormatter.formatCellValue(row.getCell(10));//毕业中学
  1409. studentData.setGraduationSchool(graSchool);
  1410. String batchValue = dataFormatter.formatCellValue(row.getCell(11));//层次
  1411. if (!batchValue.equals("本科") && !batchValue.equals("专升本") && !batchValue.equals("专科")) {
  1412. return CommonResult.fail("层次为本科或专升本或专科");
  1413. }
  1414. studentData.setBatchValue(batchValue);
  1415. String politicalStatu = dataFormatter.formatCellValue(row.getCell(12));//政治面貌
  1416. studentData.setPoliticalStatu(politicalStatu);
  1417. String nationality = dataFormatter.formatCellValue(row.getCell(13));//民族
  1418. studentData.setNationality(nationality);
  1419. String phone = dataFormatter.formatCellValue(row.getCell(14));//手机号码
  1420. studentData.setPhone(phone);
  1421. //region 籍贯
  1422. String nativePlace = dataFormatter.formatCellValue(row.getCell(15));//籍贯
  1423. String[] addressDatas = nativePlace.split("/");
  1424. if (citys != null && citys.size() > 0) {
  1425. if (addressDatas != null && addressDatas.length >= 1 && StringUtils.hasText(nativePlace)) {
  1426. if (!addressDatas[0].contains("省")) {
  1427. return CommonResult.fail("录取编号为\" + assNum + \"的籍贯格式应该是 省/市/县区");
  1428. }
  1429. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressDatas[0])).findFirst();
  1430. if (oProvince != null && oProvince.isPresent()) {
  1431. studentData.setOprovince(addressDatas[0]);
  1432. studentData.setOprovinceId(oProvince.get().getId());
  1433. } else {
  1434. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  1435. }
  1436. }
  1437. if (addressDatas != null && addressDatas.length >= 2) {
  1438. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressDatas[1])).findFirst();
  1439. if (oProvince != null && oProvince.isPresent()) {
  1440. studentData.setOcity(addressDatas[1]);
  1441. studentData.setOcityId(oProvince.get().getId());
  1442. } else {
  1443. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  1444. }
  1445. }
  1446. if (addressDatas != null && addressDatas.length >= 3) {
  1447. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getCityZh().equals(addressDatas[1]) && addressDatas[2].contains(e.getDistrictZh())).findFirst();
  1448. if (oProvince != null && oProvince.isPresent()) {
  1449. studentData.setOdistrict(addressDatas[2]);
  1450. studentData.setOdistrictId(oProvince.get().getId());
  1451. } else {
  1452. return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县区");
  1453. }
  1454. }
  1455. }
  1456. //endregion
  1457. //region 家庭住址
  1458. String addressPlace = dataFormatter.formatCellValue(row.getCell(16));//家庭住址
  1459. String[] addressPlaces = addressPlace.split("/");
  1460. if (citys != null && citys.size() > 0) {
  1461. if (addressPlaces != null && addressPlaces.length >= 1 && StringUtils.hasText(addressPlace)) {
  1462. if (!addressPlaces[0].contains("省")) {
  1463. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1464. }
  1465. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[0])).findFirst();
  1466. if (oProvince != null && oProvince.isPresent()) {
  1467. studentData.setProvince(addressPlaces[0]);
  1468. studentData.setProvinceId(oProvince.get().getId());
  1469. } else {
  1470. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1471. }
  1472. }
  1473. if (addressPlaces != null && addressPlaces.length >= 2) {
  1474. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[1])).findFirst();
  1475. if (oProvince != null && oProvince.isPresent()) {
  1476. studentData.setCity(addressPlaces[1]);
  1477. studentData.setCityId(oProvince.get().getId());
  1478. } else {
  1479. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1480. }
  1481. }
  1482. if (addressPlaces != null && addressPlaces.length >= 3) {
  1483. Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getCityZh().equals(addressPlaces[1]) && addressPlaces[2].contains(e.getDistrictZh())).findFirst();
  1484. if (oProvince != null && oProvince.isPresent()) {
  1485. studentData.setDistrict(addressPlaces[2]);
  1486. studentData.setDistrictId(oProvince.get().getId());
  1487. } else {
  1488. return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县区");
  1489. }
  1490. }
  1491. }
  1492. //endregion
  1493. String addressDetail = dataFormatter.formatCellValue(row.getCell(17));//详细住址
  1494. studentData.setAddress(addressDetail);
  1495. String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
  1496. studentData.setZipCode(zipCode);
  1497. studentData.setIdenType(1);
  1498. studentData.setFillStatus("未填报");
  1499. studentData.setIsRegistered(2);
  1500. studentData.setIsPay(0);
  1501. //studentData.setPicture("https://chtech.ncjti.edu.cn/welcome/homeimage/newStudentHeadImage.jpg");
  1502. studentData.setPicture("https://chtech.ncjti.edu.cn/welcome/homeimage/studentImage/" + studentData.getCardId() + ".jpg");
  1503. result.add(studentData);
  1504. }
  1505. }
  1506. }
  1507. } catch (Exception e) {
  1508. return CommonResult.fail("请按模板格式导入数据");
  1509. }
  1510. return CommonResult.ok(result);
  1511. }
  1512. @Override
  1513. public CommonResult downloadStudentExcel() {
  1514. return CommonResult.ok("200", "操作成功", "https://chtech.ncjti.edu.cn/welcome/homeimage/学生信息管理.xlsx");
  1515. }
  1516. @Override
  1517. public void welcomeStudentExport(String userId, HttpServletResponse response, Integer collegeId, Integer majorId, Integer classstrId, String trafficMethod, String name, String fillStatus, Integer isRegistered, Integer isPay, Integer isCheck, String school, String batchValue, Integer carNumber, Integer yearId) throws ParseException {
  1518. String nstartTime = null;
  1519. String nendTime = null;
  1520. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  1521. if (yearId == null) {
  1522. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  1523. //当前时间小于本年度的7月1日 说明要查去年的数据
  1524. if (lastYear) {
  1525. nstartTime = (yearInt - 1) + "-06-01";
  1526. nendTime = yearInt + "-06-01";
  1527. } else {
  1528. nstartTime = yearInt + "-06-01";
  1529. nendTime = (yearInt + 1) + "-06-01";
  1530. }
  1531. } else {
  1532. nstartTime = yearId + "-06-01";
  1533. nendTime = (yearId + 1) + "-06-01";
  1534. }
  1535. Workbook workbook = new XSSFWorkbook();
  1536. Sheet sheet = workbook.createSheet("学生信息");
  1537. WelcomeAccount wa = welcomeAccountService.getManageById(userId);
  1538. if (wa == null) {
  1539. System.out.println("当前账户已失效,无权限查看");
  1540. ExcelUtils.excelDownload(workbook, "学生信息.xlsx", response);
  1541. }
  1542. List<String> collegeIds = Arrays.asList(wa.getCollegeId().split(","));
  1543. if (collegeId != null && collegeId.intValue() > 0) {
  1544. if (!collegeIds.contains(String.valueOf(collegeId))) {
  1545. ExcelUtils.excelDownload(workbook, "学生信息.xlsx", response);
  1546. } else {
  1547. collegeIds = new ArrayList<>();
  1548. collegeIds.add(String.valueOf(collegeId));
  1549. }
  1550. }
  1551. List<StudentPageVo> result = welcomeStudentService.queryStudentList(collegeIds, majorId, classstrId, trafficMethod, name, fillStatus, isRegistered, isPay, isCheck, school, batchValue, carNumber, nstartTime, nendTime);
  1552. //导出
  1553. DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  1554. DateTimeFormatter dateTimeFormatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
  1555. Row headerRow = sheet.createRow(0);
  1556. headerRow.createCell(0).setCellValue("序号");
  1557. headerRow.createCell(1).setCellValue("录取号");
  1558. headerRow.createCell(2).setCellValue("性别");
  1559. headerRow.createCell(3).setCellValue("姓名");
  1560. headerRow.createCell(4).setCellValue("身份证号");
  1561. headerRow.createCell(5).setCellValue("院系");
  1562. headerRow.createCell(6).setCellValue("专业");
  1563. headerRow.createCell(7).setCellValue("班级");
  1564. headerRow.createCell(8).setCellValue("交通方式");
  1565. headerRow.createCell(9).setCellValue("到站地点");
  1566. headerRow.createCell(10).setCellValue("车牌号");
  1567. headerRow.createCell(11).setCellValue("陪同人数");
  1568. headerRow.createCell(12).setCellValue("填报状态");
  1569. headerRow.createCell(13).setCellValue("应缴金额");
  1570. headerRow.createCell(14).setCellValue("实付金额");
  1571. headerRow.createCell(15).setCellValue("宿舍信息");
  1572. headerRow.createCell(16).setCellValue("学生手机号");
  1573. headerRow.createCell(17).setCellValue("家长名称");
  1574. headerRow.createCell(18).setCellValue("家长手机号");
  1575. headerRow.createCell(19).setCellValue("到站日期");
  1576. headerRow.createCell(20).setCellValue("是否已报到");
  1577. for (int i = 0; i < result.size(); i++) {
  1578. StudentPageVo studentData = result.get(i);
  1579. Row dataRow = sheet.createRow(i + 1);
  1580. dataRow.createCell(0).setCellValue(i + 1);
  1581. dataRow.createCell(1).setCellValue(studentData.getAdmissNum());
  1582. dataRow.createCell(2).setCellValue(studentData.getSex());
  1583. dataRow.createCell(3).setCellValue(studentData.getName());
  1584. dataRow.createCell(4).setCellValue(studentData.getCardId());
  1585. dataRow.createCell(5).setCellValue(studentData.getCollege());
  1586. dataRow.createCell(6).setCellValue(studentData.getMajor());
  1587. dataRow.createCell(7).setCellValue(studentData.getClassstr());
  1588. dataRow.createCell(8).setCellValue(studentData.getTrafficMethod());
  1589. dataRow.createCell(9).setCellValue(studentData.getArrive());
  1590. dataRow.createCell(10).setCellValue(studentData.getCarNumber());
  1591. dataRow.createCell(11).setCellValue(studentData.getAccompanyNum());
  1592. dataRow.createCell(12).setCellValue(studentData.getFillStatus());
  1593. dataRow.createCell(13).setCellValue(String.valueOf(studentData.getAmountPayable()));
  1594. dataRow.createCell(14).setCellValue(String.valueOf(studentData.getPayAmount()));
  1595. dataRow.createCell(15).setCellValue(studentData.getDormitory());
  1596. dataRow.createCell(16).setCellValue(studentData.getPhone());
  1597. dataRow.createCell(17).setCellValue(studentData.getFamilyName());
  1598. dataRow.createCell(18).setCellValue(studentData.getFamilyPhone());
  1599. if (ObjectUtils.isNotEmpty(studentData.getArrvieDate())) {
  1600. String arrvieDate = LocalDateTime.parse(studentData.getArrvieDate(), dateTimeFormatter1).toLocalDate().format(dateTimeFormatter2);
  1601. dataRow.createCell(19).setCellValue(arrvieDate);
  1602. }
  1603. String registered = "未报到";
  1604. if (ObjectUtils.isNotEmpty(studentData.getIsRegistered())) {
  1605. Integer isRegistered1 = studentData.getIsRegistered();
  1606. if (isRegistered1 == 1) {
  1607. registered = "已报到";
  1608. } else if (isRegistered1 == 2) {
  1609. registered = "未报到";
  1610. }
  1611. }
  1612. dataRow.createCell(20).setCellValue(registered);
  1613. }
  1614. // 将工作簿写入文件
  1615. ExcelUtils.excelDownload(workbook, "学生信息.xlsx", response);
  1616. }
  1617. @Override
  1618. public CommonResult studentOverview(Integer collegeId, Integer yearId) throws ParseException {
  1619. String nstartTime = null;
  1620. String nendTime = null;
  1621. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  1622. // 获取年份
  1623. String yearStr="";
  1624. if (yearId == null) {
  1625. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  1626. //当前时间小于本年度的7月1日 说明要查去年的数据
  1627. if (lastYear) {
  1628. yearStr=(yearInt - 1) +"级新生";
  1629. nstartTime = (yearInt - 1) + "-06-01";
  1630. nendTime = yearInt + "-06-01";
  1631. } else {
  1632. yearStr=yearInt +"级新生";
  1633. nstartTime = yearInt + "-06-01";
  1634. nendTime = (yearInt + 1) + "-06-01";
  1635. }
  1636. } else {
  1637. yearStr=yearId +"级新生";
  1638. nstartTime = yearId + "-06-01";
  1639. nendTime = (yearId + 1) + "-06-01";
  1640. }
  1641. //获取学生总数
  1642. int enrollmentTotal = welcomeStudentService.studentTotalCount(collegeId, nstartTime, nendTime);
  1643. //录取总数
  1644. //LambdaQueryWrapper<WelcomeStudent> queryWrapper=new LambdaQueryWrapper<>();
  1645. //queryWrapper.eq(WelcomeStudent::getIdenType,1);
  1646. //int enrollmentTotal = 8085;//welcomeStudentService.count(queryWrapper);
  1647. //全部缴费人数
  1648. int payCount = welcomeStudentService.payCount(collegeId, nstartTime, nendTime);
  1649. //全部缴费率
  1650. Double rate = enrollmentTotal <= 0 ? 0 : ((double) payCount / enrollmentTotal) * 100;
  1651. String payRate = String.format("%.2f", rate);
  1652. // 部分缴费人数,支付状态未缴费,并且实付金额大于0
  1653. int portionPayCount = welcomeStudentService.payPortionCount(collegeId, nstartTime, nendTime);
  1654. // 部分缴费率
  1655. Double portionRate = enrollmentTotal <= 0 ? 0 : ((double) portionPayCount / enrollmentTotal) * 100;
  1656. String portionPayRate = String.format("%.2f", portionRate);
  1657. // 总缴费人数(包括部分缴费人数)
  1658. int totalPayCount =payCount+portionPayCount;
  1659. // 总缴费率(包括部分缴费)
  1660. Double totalRate=enrollmentTotal <= 0 ? 0 : ((double) totalPayCount / enrollmentTotal) * 100;
  1661. String totalPayRate = String.format("%.2f", totalRate);
  1662. // 现场报到总人数
  1663. int registrationCount = welcomeStudentService.registrationCount(collegeId, nstartTime, nendTime);
  1664. Double result = enrollmentTotal <= 0 ? 0 : ((double) registrationCount / enrollmentTotal) * 100;
  1665. String registrationRate = String.format("%.2f", result);
  1666. // 未报道人数
  1667. int notRegistrationCount=enrollmentTotal-registrationCount;
  1668. // 已缴费但未现场报到人数
  1669. int payNotRegistrationCount=welcomeStudentService.payNotRegistrationCount(collegeId, nstartTime, nendTime);
  1670. // 已缴费但未现场报到比率
  1671. Double payNotReportCountRate = enrollmentTotal <= 0 ? 0 : ((double) payNotRegistrationCount / enrollmentTotal) * 100;
  1672. String payNotRegistrationRate = String.format("%.2f", payNotReportCountRate);
  1673. //已入住寝室数
  1674. // LambdaQueryWrapper<WelcomeBed> wrapper = new LambdaQueryWrapper<>();
  1675. // wrapper.eq(WelcomeBed::getIsCheck, 1)
  1676. // .eq(WelcomeBed::getRetentionState, 1)
  1677. // .eq(ObjectUtils.isNotEmpty(collegeId), WelcomeBed::getCollegeId, collegeId);
  1678. // wrapper.between(WelcomeBed::getCreateTime, nstartTime, nendTime);
  1679. // int checkInBedTotal = welcomeBedService.count(wrapper);
  1680. // Double result = enrollmentTotal <= 0 ? 0 : ((double) checkInBedTotal / enrollmentTotal) * 100;
  1681. // String registrationRate = String.format("%.2f", result);
  1682. LocalDateTime start = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
  1683. LocalDateTime end = start.plusDays(1);
  1684. DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  1685. String startTime = start.format(dateTimeFormatter1);
  1686. String endTime = end.format(dateTimeFormatter1);
  1687. Integer mVisitorTotal = welcomeVisitorService.countTotal(startTime, endTime, 1, nstartTime, nendTime);
  1688. Integer hVisitorTotal = welcomeVisitorService.countTotal(startTime, endTime, 2, nstartTime, nendTime);
  1689. List<WelcomeSetting> wss = welcomeSettingService.list(null);
  1690. //墨轩湖总车辆数
  1691. Integer mCarTotal = wss != null && wss.size() > 0 ? (wss.get(0).getMxhCarNum() == null ? 0 : wss.get(0).getMxhCarNum()) : 0;
  1692. //黄家湖总车辆数
  1693. Integer hCarTotal = wss != null && wss.size() > 0 ? (wss.get(0).getHjhCarNum() == null ? 0 : wss.get(0).getHjhCarNum()) : 0;
  1694. StudentOverviewVo vo = new StudentOverviewVo();
  1695. // 总人数
  1696. vo.setEnrollmentTotal(enrollmentTotal);
  1697. // 年份字段
  1698. vo.setYearStr(yearStr);
  1699. // 现场报到人数
  1700. vo.setRegistrationCount(registrationCount);
  1701. // 现场报到率
  1702. vo.setRegistrationRate(registrationRate);
  1703. // 未报到人数
  1704. vo.setNotRegistrationCount(notRegistrationCount);
  1705. // 总缴费人数(包括部分缴费)
  1706. vo.setTotalPayCount(totalPayCount);
  1707. // 总缴费率(包括部分缴费)
  1708. vo.setTotalPayRate(totalPayRate);
  1709. // 全部缴费人数
  1710. vo.setPayCount(payCount);
  1711. // 全部缴费率
  1712. vo.setPayRate(payRate);
  1713. // 部分缴费人数
  1714. vo.setPortionPayCount(portionPayCount);
  1715. // 部分缴费率
  1716. vo.setPortionPayRate(portionPayRate);
  1717. // 已缴费未报到人数
  1718. vo.setPayNotRegistrationCount(payNotRegistrationCount);
  1719. // 已缴费未报到率
  1720. vo.setPayNotRegistrationRate(payNotRegistrationRate);
  1721. // 黄家湖当日剩余总数
  1722. vo.setHCarTotal(hCarTotal - hVisitorTotal);
  1723. // 黄家湖当日预定数
  1724. vo.setHVisitorTotal(hVisitorTotal);
  1725. // 墨轩湖当日剩余数
  1726. vo.setMCarTotal(mCarTotal - mVisitorTotal);
  1727. // 墨轩湖当日预定数
  1728. vo.setMVisitorTotal(mVisitorTotal);
  1729. return CommonResult.ok(vo);
  1730. }
  1731. @Override
  1732. public CommonResult studentRegister(Integer collegeId, Integer yearId) throws ParseException {
  1733. String nstartTime = null;
  1734. String nendTime = null;
  1735. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  1736. if (yearId == null) {
  1737. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  1738. //当前时间小于本年度的7月1日 说明要查去年的数据
  1739. if (lastYear) {
  1740. nstartTime = (yearInt - 1) + "-06-01";
  1741. nendTime = yearInt + "-06-01";
  1742. } else {
  1743. nstartTime = yearInt + "-06-01";
  1744. nendTime = (yearInt + 1) + "-06-01";
  1745. }
  1746. } else {
  1747. nstartTime = yearId + "-06-01";
  1748. nendTime = (yearId + 1) + "-06-01";
  1749. }
  1750. // 学生总数
  1751. int enrollmentTotal = welcomeStudentService.studentTotalCount(collegeId, nstartTime, nendTime);
  1752. // 获取总数
  1753. Integer count = welcomeStudentService.totalCount(collegeId, nstartTime, nendTime);
  1754. // 获取比例
  1755. Double result = enrollmentTotal <= 0 ? 0 : ((double) count / enrollmentTotal) * 100;
  1756. String rate = String.format("%.2f", result);
  1757. StudentRegisterVo vo = new StudentRegisterVo();
  1758. vo.setName("报到总数");
  1759. vo.setCount(count);
  1760. vo.setRate(rate);
  1761. vo.setTotalCount(enrollmentTotal);
  1762. if (ObjectUtils.isNotEmpty(collegeId)) {
  1763. List<StudentRegisterVo> vos = welcomeStudentService.studentMajorRegister(collegeId, nstartTime, nendTime);
  1764. vos.add(vo);
  1765. return CommonResult.ok(vos);
  1766. } else {
  1767. List<StudentRegisterVo> vos = welcomeStudentService.studentRegister(nstartTime, nendTime);
  1768. vos.add(vo);
  1769. return CommonResult.ok(vos);
  1770. }
  1771. }
  1772. @Override
  1773. public CommonResult studentTraffic(Integer collegeId, Integer yearId) throws ParseException {
  1774. String nstartTime = null;
  1775. String nendTime = null;
  1776. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  1777. if (yearId == null) {
  1778. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  1779. //当前时间小于本年度的7月1日 说明要查去年的数据
  1780. if (lastYear) {
  1781. nstartTime = (yearInt - 1) + "-06-01";
  1782. nendTime = yearInt + "-06-01";
  1783. } else {
  1784. nstartTime = yearInt + "-06-01";
  1785. nendTime = (yearInt + 1) + "-06-01";
  1786. }
  1787. } else {
  1788. nstartTime = yearId + "-06-01";
  1789. nendTime = (yearId + 1) + "-06-01";
  1790. }
  1791. List<StudentTrafficVo> vos = welcomeStudentService.studentTraffic(collegeId, nstartTime, nendTime);
  1792. return CommonResult.ok(vos);
  1793. }
  1794. @Override
  1795. public CommonResult studentSexRatio(Integer yearId) throws ParseException {
  1796. String nstartTime = null;
  1797. String nendTime = null;
  1798. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  1799. if (yearId == null) {
  1800. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  1801. //当前时间小于本年度的7月1日 说明要查去年的数据
  1802. if (lastYear) {
  1803. nstartTime = (yearInt - 1) + "-06-01";
  1804. nendTime = yearInt + "-06-01";
  1805. } else {
  1806. nstartTime = yearInt + "-06-01";
  1807. nendTime = (yearInt + 1) + "-06-01";
  1808. }
  1809. } else {
  1810. nstartTime = yearId + "-06-01";
  1811. nendTime = (yearId + 1) + "-06-01";
  1812. }
  1813. Integer manCount = welcomeStudentService.genderCount("男");
  1814. Integer girlCount = welcomeStudentService.genderCount("女");
  1815. StudentSexRatioVo vo = new StudentSexRatioVo();
  1816. vo.setCollegeName("全部");
  1817. vo.setManCount(manCount);
  1818. vo.setGirlCount(girlCount);
  1819. List<StudentSexRatioVo> vos = welcomeStudentService.studentSexRatio(nstartTime, nendTime);
  1820. vos.add(vo);
  1821. return CommonResult.ok(vos);
  1822. }
  1823. @Override
  1824. public CommonResult studentStay(Integer yearId) throws ParseException {
  1825. String nstartTime = null;
  1826. String nendTime = null;
  1827. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  1828. if (yearId == null) {
  1829. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  1830. //当前时间小于本年度的7月1日 说明要查去年的数据
  1831. if (lastYear) {
  1832. nstartTime = (yearInt - 1) + "-06-01";
  1833. nendTime = yearInt + "-06-01";
  1834. } else {
  1835. nstartTime = yearInt + "-06-01";
  1836. nendTime = (yearInt + 1) + "-06-01";
  1837. }
  1838. } else {
  1839. nstartTime = yearId + "-06-01";
  1840. nendTime = (yearId + 1) + "-06-01";
  1841. }
  1842. ArrayList<StudentStayVo> vos = new ArrayList<>();
  1843. List<WelcomeSchool> list = welcomeSchoolService.list(new QueryWrapper<>());
  1844. for (WelcomeSchool welcomeSchool : list) {
  1845. Integer schoolId = welcomeSchool.getId();
  1846. List<WelcomeBuild> builds = welcomeBuildService.getBuild(schoolId);
  1847. for (WelcomeBuild build : builds) {
  1848. Integer buildId = build.getId();
  1849. StudentStayVo vo = welcomeDormitoryService.getTotalCount(buildId);
  1850. vo.setSchoolName(welcomeSchool.getSchool());
  1851. vo.setBuildName(build.getBuild());
  1852. vos.add(vo);
  1853. }
  1854. }
  1855. return CommonResult.ok(vos);
  1856. }
  1857. @Override
  1858. public CommonResult queryStudentByToken(String userId) throws ParseException {
  1859. WelcomeStudent student = welcomeStudentService.getManageById(Integer.valueOf(userId));
  1860. if (student == null) {
  1861. return CommonResult.fail("558", "学生信息已失效,查询失败");
  1862. }
  1863. //家庭成员
  1864. List<FamilyVo> fvs = new ArrayList<>();
  1865. List<WelcomeFamily> familys = welcomeFamilyService.getManageByCardId(student.getCardId());
  1866. if (familys != null && familys.size() > 0) {
  1867. for (WelcomeFamily wf : familys) {
  1868. FamilyVo fv = new FamilyVo();
  1869. fv.setId(wf.getId());
  1870. fv.setFamilyShip(wf.getFamilyShip());
  1871. fv.setName(wf.getName());
  1872. fv.setPhone(wf.getPhone());
  1873. fv.setWorkUnit(wf.getWorkUnit());
  1874. fvs.add(fv);
  1875. }
  1876. }
  1877. student.setFvs(fvs);
  1878. //陪同人员
  1879. List<AccompanyVo> avs = new ArrayList<>();
  1880. List<WelcomeAccompany> accompanys = welcomeAccompanyService.getManageByCardId(student.getCardId());
  1881. if (accompanys != null && accompanys.size() > 0) {
  1882. for (WelcomeAccompany ac : accompanys) {
  1883. AccompanyVo av = new AccompanyVo();
  1884. av.setId(ac.getId());
  1885. av.setName(ac.getName());
  1886. av.setPhone(ac.getPhone());
  1887. avs.add(av);
  1888. }
  1889. }
  1890. student.setAvs(avs);
  1891. //时间段
  1892. List<ArriveTimeVo> atvs = new ArrayList<>();
  1893. List<WelcomeArriveSetting> wass = welcomeArriveSettingService.queryCheckDatas();
  1894. if (wass != null && wass.size() > 0) {
  1895. for (WelcomeArriveSetting was : wass) {
  1896. ArriveTimeVo atv = new ArriveTimeVo();
  1897. atv.setId(was.getId());
  1898. atv.setStartTime(was.getStartTime());
  1899. atv.setEndTime(was.getEndTime());
  1900. atv.setTimeStr(was.getStartTime() + "-" + was.getEndTime());
  1901. atv.setIsCheck((student.getArriveTimeId() != null && was.getId().equals(student.getArriveTimeId())) ? 1 : 0);
  1902. atvs.add(atv);
  1903. }
  1904. }
  1905. student.setAtvs(atvs);
  1906. if (!(student.getIsPay() != null && student.getIsPay().intValue() == 1)) {
  1907. List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(student.getAdmissNum(), TimeExchange.getYear());
  1908. BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
  1909. BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
  1910. BigDecimal dkAmount = new BigDecimal(BigInteger.ZERO);//贷款金额
  1911. for (JsonPayVo pi : payInfos) {
  1912. dkAmount = dkAmount.add(pi.getDKJE());
  1913. payAmount = payAmount.add(pi.getSJJE());
  1914. yjPayAmount = yjPayAmount.add(pi.getYJJE());
  1915. }
  1916. BigDecimal studentPay = payAmount.add(dkAmount);
  1917. student.setPayAmount(studentPay);
  1918. student.setAmountPayable(yjPayAmount);
  1919. System.out.println("进支付比较1" + JSON.toJSON(payInfos));
  1920. if (payInfos != null && payInfos.size() > 0) {
  1921. System.out.println("进支付比较2");
  1922. String nstartTime = null;
  1923. String nendTime = null;
  1924. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  1925. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  1926. //当前时间小于本年度的7月1日 说明要查去年的数据
  1927. if (lastYear) {
  1928. nstartTime = (yearInt - 1) + "-06-01";
  1929. nendTime = yearInt + "-06-01";
  1930. } else {
  1931. nstartTime = yearInt + "-06-01";
  1932. nendTime = (yearInt + 1) + "-06-01";
  1933. }
  1934. WelcomePaySetting paySettings = welcomePaySettingService.queryPaySettingById(student.getCollegeId(), student.getMajorId(), student.getBatchValue(), nstartTime, nendTime);
  1935. System.out.println("进支付比较3" + JSON.toJSON(paySettings));
  1936. if (paySettings != null) {
  1937. System.out.println("进支付比较4");
  1938. if (studentPay.compareTo(paySettings.getPayAmount()) >= 0) {
  1939. student.setIsPay(1);
  1940. } else {
  1941. student.setIsPay(0);
  1942. }
  1943. } else {
  1944. student.setIsPay(0);
  1945. }
  1946. } else {
  1947. student.setIsPay(0);
  1948. }
  1949. if (payInfos != null && payInfos.size() > 0) {
  1950. int update = welcomeStudentService.updateWelcomeStudent(student);
  1951. if (update < 0) {
  1952. logger.error("获取支付信息导致学校信息查询失败");
  1953. return CommonResult.fail("查询失败");
  1954. }
  1955. }
  1956. }
  1957. if (student.getIsPay() == null) {
  1958. student.setIsPay(0);
  1959. }
  1960. long expired = 1000 * 60 * 60 * 24 * 365;
  1961. TokenDateVo token = JWTUtil.getToken(student.getCardId(), student.getId(), expired);
  1962. student.setToken(token.getToken());
  1963. return CommonResult.ok(student);
  1964. }
  1965. @Override
  1966. public CommonResult queryStudentInfo(String admissNum) throws ParseException {
  1967. WelcomeStudent ws = welcomeStudentService.getDataByNum(admissNum);
  1968. if (ws == null) {
  1969. return CommonResult.fail("558", "当前学生信息已失效,查询失败");
  1970. }
  1971. //家庭成员
  1972. List<FamilyVo> fvs = new ArrayList<>();
  1973. List<WelcomeFamily> familys = welcomeFamilyService.getManageByCardId(ws.getCardId());
  1974. if (familys != null && familys.size() > 0) {
  1975. for (WelcomeFamily wf : familys) {
  1976. FamilyVo fv = new FamilyVo();
  1977. fv.setId(wf.getId());
  1978. fv.setFamilyShip(wf.getFamilyShip());
  1979. fv.setName(wf.getName());
  1980. fv.setPhone(wf.getPhone());
  1981. fv.setWorkUnit(wf.getWorkUnit());
  1982. fvs.add(fv);
  1983. }
  1984. }
  1985. ws.setFvs(fvs);
  1986. //陪同人员
  1987. List<AccompanyVo> avs = new ArrayList<>();
  1988. List<WelcomeAccompany> accompanys = welcomeAccompanyService.getManageByCardId(ws.getCardId());
  1989. if (accompanys != null && accompanys.size() > 0) {
  1990. for (WelcomeAccompany ac : accompanys) {
  1991. AccompanyVo av = new AccompanyVo();
  1992. av.setId(ac.getId());
  1993. av.setName(ac.getName());
  1994. av.setPhone(ac.getPhone());
  1995. avs.add(av);
  1996. }
  1997. }
  1998. ws.setAvs(avs);
  1999. //时间段
  2000. List<ArriveTimeVo> atvs = new ArrayList<>();
  2001. List<WelcomeArriveSetting> wass = welcomeArriveSettingService.queryCheckDatas();
  2002. if (wass != null && wass.size() > 0) {
  2003. for (WelcomeArriveSetting was : wass) {
  2004. ArriveTimeVo atv = new ArriveTimeVo();
  2005. atv.setId(was.getId());
  2006. atv.setStartTime(was.getStartTime());
  2007. atv.setEndTime(was.getEndTime());
  2008. atv.setTimeStr(was.getStartTime() + "-" + was.getEndTime());
  2009. atv.setIsCheck((ws.getArriveTimeId() != null && was.getId().equals(ws.getArriveTimeId())) ? 1 : 0);
  2010. atvs.add(atv);
  2011. }
  2012. }
  2013. ws.setAtvs(atvs);
  2014. List<PayDetailVO> pdvs = new ArrayList<>();
  2015. System.out.println("进支付比较");
  2016. List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(ws.getAdmissNum(), TimeExchange.getYear());
  2017. BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
  2018. BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
  2019. BigDecimal dkAmount = new BigDecimal(BigInteger.ZERO);//贷款金额
  2020. for (JsonPayVo pi : payInfos) {
  2021. dkAmount = dkAmount.add(pi.getDKJE());
  2022. payAmount = payAmount.add(pi.getSJJE());
  2023. yjPayAmount = yjPayAmount.add(pi.getYJJE());
  2024. PayDetailVO pdv = new PayDetailVO();
  2025. pdv.setPayName(pi.getSFXMMC());
  2026. pdv.setYJJE(pi.getYJJE());
  2027. pdv.setSJJE(pi.getSJJE());
  2028. pdvs.add(pdv);
  2029. }
  2030. BigDecimal studentPay = payAmount.add(dkAmount);
  2031. ws.setPayAmount(studentPay);
  2032. ws.setAmountPayable(yjPayAmount);
  2033. System.out.println("进支付比较1" + JSON.toJSON(payInfos));
  2034. if (payInfos != null && payInfos.size() > 0) {
  2035. System.out.println("进支付比较2");
  2036. String nstartTime = null;
  2037. String nendTime = null;
  2038. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  2039. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  2040. //当前时间小于本年度的7月1日 说明要查去年的数据
  2041. if (lastYear) {
  2042. nstartTime = (yearInt - 1) + "-06-01";
  2043. nendTime = yearInt + "-06-01";
  2044. } else {
  2045. nstartTime = yearInt + "-06-01";
  2046. nendTime = (yearInt + 1) + "-06-01";
  2047. }
  2048. WelcomePaySetting paySettings = welcomePaySettingService.queryPaySettingById(ws.getCollegeId(), ws.getMajorId(), ws.getBatchValue(), nstartTime, nendTime);
  2049. System.out.println("进支付比较3" + JSON.toJSON(paySettings));
  2050. if (paySettings != null) {
  2051. System.out.println("进支付比较4");
  2052. if (studentPay.compareTo(paySettings.getPayAmount()) >= 0) {
  2053. ws.setIsPay(1);
  2054. } else {
  2055. ws.setIsPay(0);
  2056. }
  2057. } else {
  2058. ws.setIsPay(0);
  2059. }
  2060. } else {
  2061. ws.setIsPay(0);
  2062. }
  2063. if (ws.getIsPay() == null) {
  2064. ws.setIsPay(0);
  2065. }
  2066. if (!(ws.getIsPay() != null && ws.getIsPay().intValue() == 1)) {
  2067. int updateResult = welcomeStudentService.updateWelcomeStudent(ws);
  2068. if (updateResult < 0) {
  2069. return CommonResult.fail("查询支付信息失败");
  2070. }
  2071. }
  2072. PayInfoVO result = new PayInfoVO();
  2073. result.setId(ws.getId());
  2074. result.setName(ws.getName());
  2075. result.setAdmissNum(ws.getAdmissNum());
  2076. result.setIsPay(ws.getIsPay());
  2077. result.setPays(pdvs);
  2078. return CommonResult.ok(result);
  2079. }
  2080. @Override
  2081. @AWelcomeLog("学生报到")
  2082. @AWelcomeTypeLog("编辑")
  2083. @AWelcomeLogMode("学生信息管理")
  2084. @AWelcomeLevelLog("信息")
  2085. public CommonResult isRegistered(WelcomeStudent welcomeStudent) {
  2086. boolean update = welcomeStudentService.updateById(welcomeStudent);
  2087. return update ? CommonResult.ok() : CommonResult.fail();
  2088. }
  2089. @Override
  2090. public CommonResult levelRegister(Integer collegeId, Integer yearId) throws ParseException {
  2091. String nstartTime = null;
  2092. String nendTime = null;
  2093. boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
  2094. if (yearId == null) {
  2095. Integer yearInt = Integer.valueOf(TimeExchange.getYear());
  2096. //当前时间小于本年度的7月1日 说明要查去年的数据
  2097. if (lastYear) {
  2098. nstartTime = (yearInt - 1) + "-06-01";
  2099. nendTime = yearInt + "-06-01";
  2100. } else {
  2101. nstartTime = yearInt + "-06-01";
  2102. nendTime = (yearInt + 1) + "-06-01";
  2103. }
  2104. } else {
  2105. nstartTime = yearId + "-06-01";
  2106. nendTime = (yearId + 1) + "-06-01";
  2107. }
  2108. // 获取学生总数
  2109. int enrollmentTotal = welcomeStudentService.studentTotalCount(collegeId, nstartTime, nendTime);
  2110. // 获取报到总数
  2111. Integer count = welcomeStudentService.totalCount(collegeId, nstartTime, nendTime);
  2112. // 获取比例
  2113. Double result = ((double) count / enrollmentTotal) * 100;
  2114. String rate = String.format("%.2f", result);
  2115. StudentRegisterVo vo = new StudentRegisterVo();
  2116. vo.setName("报到总数");
  2117. vo.setCount(count);
  2118. vo.setRate(rate);
  2119. vo.setTotalCount(enrollmentTotal);
  2120. String bk = "本科";
  2121. String zsb = "专升本";
  2122. String zk = "专科";
  2123. // 获取总本科人数
  2124. Integer bkCount = welcomeStudentService.getLevelTotalCount(bk, collegeId, nstartTime, nendTime);
  2125. // 获取总专升本人数
  2126. Integer zsbCount = welcomeStudentService.getLevelTotalCount(zsb, collegeId, nstartTime, nendTime);
  2127. // 获取总专科人数
  2128. Integer zkCount = welcomeStudentService.getLevelTotalCount(zk, collegeId, nstartTime, nendTime);
  2129. List<StudentRegisterVo> vos = welcomeStudentService.levelRegister(collegeId, nstartTime, nendTime);
  2130. HashMap<String, StudentRegisterVo> map = new HashMap<>();
  2131. for (StudentRegisterVo studentRegisterVo : vos) {
  2132. Integer count1 = studentRegisterVo.getCount();
  2133. if (studentRegisterVo.getName().equals(bk)) {
  2134. Double result1 = ((double) count1 / bkCount) * 100;
  2135. String rate1 = String.format("%.2f", result1);
  2136. studentRegisterVo.setRate(rate1);
  2137. studentRegisterVo.setTotalCount(bkCount);
  2138. } else if (studentRegisterVo.getName().equals(zsb)) {
  2139. Double result1 = ((double) count1 / zsbCount) * 100;
  2140. String rate1 = String.format("%.2f", result1);
  2141. studentRegisterVo.setRate(rate1);
  2142. studentRegisterVo.setTotalCount(zsbCount);
  2143. } else if (studentRegisterVo.getName().equals(zk)) {
  2144. Double result1 = ((double) count1 / zkCount) * 100;
  2145. String rate1 = String.format("%.2f", result1);
  2146. studentRegisterVo.setRate(rate1);
  2147. studentRegisterVo.setTotalCount(zkCount);
  2148. }
  2149. map.put(studentRegisterVo.getName(), studentRegisterVo);
  2150. }
  2151. if (!map.containsKey("本科")) {
  2152. StudentRegisterVo vo1 = new StudentRegisterVo();
  2153. vo1.setName("本科");
  2154. vo1.setCount(0);
  2155. vo1.setRate("0.00");
  2156. vo1.setTotalCount(bkCount);
  2157. vos.add(vo1);
  2158. }
  2159. if (!map.containsKey("专升本")) {
  2160. StudentRegisterVo vo2 = new StudentRegisterVo();
  2161. vo2.setName("专升本");
  2162. vo2.setCount(0);
  2163. vo2.setRate("0.00");
  2164. vo2.setTotalCount(zsbCount);
  2165. vos.add(vo2);
  2166. }
  2167. if (!map.containsKey("专科")) {
  2168. StudentRegisterVo vo3 = new StudentRegisterVo();
  2169. vo3.setName("专科");
  2170. vo3.setCount(0);
  2171. vo3.setRate("0.00");
  2172. vo3.setTotalCount(zkCount);
  2173. vos.add(vo3);
  2174. }
  2175. vos.add(vo);
  2176. return CommonResult.ok(vos);
  2177. }
  2178. }