ConsumptionController.java 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. package com.xjrsoft.module.student.controller;
  2. import cn.dev33.satoken.annotation.SaCheckPermission;
  3. import cn.dev33.satoken.stp.StpUtil;
  4. import com.alibaba.excel.EasyExcel;
  5. import com.alibaba.excel.support.ExcelTypeEnum;
  6. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  7. import com.baomidou.mybatisplus.core.metadata.IPage;
  8. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  9. import com.xjrsoft.common.annotation.XjrLog;
  10. import com.xjrsoft.common.enums.DeleteMark;
  11. import com.xjrsoft.common.model.result.RT;
  12. import com.xjrsoft.common.page.ConventPage;
  13. import com.xjrsoft.common.page.PageOutput;
  14. import com.xjrsoft.common.utils.TreeUtil;
  15. import com.xjrsoft.module.base.entity.BaseClass;
  16. import com.xjrsoft.module.base.service.IBaseClassService;
  17. import com.xjrsoft.module.base.service.IBaseGradeService;
  18. import com.xjrsoft.module.student.dto.*;
  19. import com.xjrsoft.module.student.service.IPbVXssfdetailService;
  20. import com.xjrsoft.module.student.service.IPbVXsxxsfytbService;
  21. import com.xjrsoft.module.student.vo.*;
  22. import io.swagger.annotations.Api;
  23. import io.swagger.annotations.ApiOperation;
  24. import lombok.AllArgsConstructor;
  25. import org.springframework.http.ResponseEntity;
  26. import org.springframework.web.bind.annotation.*;
  27. import javax.validation.Valid;
  28. import java.io.ByteArrayOutputStream;
  29. import java.util.ArrayList;
  30. import java.util.HashMap;
  31. import java.util.List;
  32. import java.util.Map;
  33. /**
  34. * @title: 学生消费管理
  35. * @Author dzx
  36. * @Date: 2024年6月3日
  37. * @Version 1.0
  38. */
  39. @RestController
  40. @RequestMapping("/student" + "/consumption")
  41. @Api(value = "/student" + "/consumption", tags = "学生消费管理")
  42. @AllArgsConstructor
  43. public class ConsumptionController {
  44. private final IPbVXssfdetailService pbVXssfdetailService;
  45. private final IPbVXsxxsfytbService pbVXsxxsfytbService;
  46. private final IBaseGradeService baseGradeService;
  47. private final IBaseClassService baseClassService;
  48. @GetMapping(value = "/tree")
  49. @ApiOperation(value = "学生在读毕业年级班级树")
  50. @SaCheckPermission("studentmanager:detail")
  51. @XjrLog(value = "学生在读毕业年级班级树")
  52. public RT<List<BaseClassTreeVo>> tree() {
  53. List<BaseClassTreeVo> voList = new ArrayList<>();
  54. List<BaseClassQfCountVo> qfCount = pbVXsxxsfytbService.getClassQfCount();
  55. Map<Long, Integer> qfCountMap = new HashMap<>();
  56. for (BaseClassQfCountVo qfCountVo : qfCount) {
  57. qfCountMap.put(qfCountVo.getId(), qfCountVo.getCount());
  58. }
  59. voList.add(new BaseClassTreeVo() {{
  60. setId(6L);
  61. setName("年级");
  62. }});
  63. baseGradeService.list().forEach((node) -> {
  64. if (node.getStatus() == 1) {
  65. voList.add(new BaseClassTreeVo() {{
  66. setId(node.getId());
  67. setName(node.getName());
  68. setParentId(6L);
  69. }});
  70. }
  71. });
  72. baseClassService.list(new QueryWrapper<BaseClass>().lambda().eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())).forEach((node) -> {
  73. voList.add(new BaseClassTreeVo() {{
  74. setId(node.getId());
  75. setName(node.getName());
  76. setParentId(node.getGradeId());
  77. setStatus(0);
  78. if (qfCountMap.get(node.getId()) != null && qfCountMap.get(node.getId()) > 0) {
  79. setStatus(1);
  80. }
  81. }});
  82. });
  83. List<BaseClassTreeVo> treeVoList = TreeUtil.build(voList);
  84. return RT.ok(treeVoList);
  85. }
  86. @GetMapping(value = "/personal-info")
  87. @ApiOperation(value = "学生个人信息")
  88. @SaCheckPermission("consumption:detail")
  89. @XjrLog(value = "学生个人信息", saveResponseData = true)
  90. public RT<PersonalPortraitPersonalInfoVo> personalInfo(@Valid PersonalInfoDto dto) {
  91. PersonalPortraitPersonalInfoVo info = pbVXssfdetailService.getPersonalInfo(dto);
  92. return RT.ok(info);
  93. }
  94. @GetMapping(value = "/detail-page")
  95. @ApiOperation(value = "学生收费明细分页查询")
  96. @SaCheckPermission("consumption:detail")
  97. @XjrLog(value = "学生收费明细分页查询")
  98. public RT<PageOutput<PbVXssfdetailPageVo>> detailPage(@Valid PbVXssfdetailPageDto dto) {
  99. Page<PbVXssfdetailPageVo> page = pbVXssfdetailService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
  100. PageOutput<PbVXssfdetailPageVo> pageOutput = ConventPage.getPageOutput(page, PbVXssfdetailPageVo.class);
  101. return RT.ok(pageOutput);
  102. }
  103. @GetMapping(value = "/pb_vx_sxxsfytbPage")
  104. @ApiOperation(value = "学生消费管理页分页查询")
  105. @SaCheckPermission("consumption:detail")
  106. @XjrLog(value = "学生消费管理页分页查询")
  107. public RT<PageOutput<PbVXsxxsfytbPageVo>> pbVXsxxsfytbPage(@Valid PbVXsxxsfytbPageDto dto) {
  108. List<String> roleList = StpUtil.getRoleList();
  109. if (roleList.size() == 2 && roleList.contains("TEACHER") && roleList.contains("CLASSTE")) {
  110. dto.setTeacherId(StpUtil.getLoginIdAsLong());
  111. }
  112. IPage<PbVXsxxsfytbPageVo> page = pbVXsxxsfytbService.getPage(dto);
  113. PageOutput<PbVXsxxsfytbPageVo> pageOutput = ConventPage.getPageOutput(page, PbVXsxxsfytbPageVo.class);
  114. return RT.ok(pageOutput);
  115. }
  116. @GetMapping(value = "/cost-information")
  117. @ApiOperation(value = "费用信息")
  118. @SaCheckPermission("consumption:detail")
  119. @XjrLog(value = "费用信息", saveResponseData = true)
  120. public RT<PersonalPortraitFeeInformationVo> costInformation(@Valid PersonalPortraitFeeInformationDto dto) {
  121. return RT.ok(pbVXsxxsfytbService.listCostInformation(dto));
  122. }
  123. @PostMapping("/export-query")
  124. @ApiOperation(value = "有参导出")
  125. @XjrLog(value = "有参导出")
  126. public ResponseEntity<byte[]> exportData(@RequestBody PbVXsxxsfytbExcelDto dto) {
  127. List<PbVXsxxsfytbExcelVo> dataList = pbVXsxxsfytbService.getList(dto);
  128. ByteArrayOutputStream bot = new ByteArrayOutputStream();
  129. EasyExcel.write(bot, PbVXsxxsfytbExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(dataList);
  130. return RT.fileStream(bot.toByteArray(), "PbVXsxxsfytbExcel" + ExcelTypeEnum.XLSX.getValue());
  131. }
  132. @GetMapping(value = "/fee-detail")
  133. @ApiOperation(value = "学生缴费的详情")
  134. @SaCheckPermission("consumption:detail")
  135. @XjrLog(value = "学生缴费的详情")
  136. public RT<List<FeeDetailListVo>> feeDetail(@RequestParam String studentcode, String beltcode) {
  137. return RT.ok(pbVXsxxsfytbService.getFeeDetail(studentcode, beltcode));
  138. }
  139. @GetMapping(value = "/student-category-stat")
  140. @ApiOperation(value = "学生类别的人数统计")
  141. @SaCheckPermission("consumption:detail")
  142. @XjrLog(value = "学生类别的人数统计", saveResponseData = true)
  143. public RT<PbStudentCategoryVo> studentCategory(@Valid PbVXsxxsfytbStatDto dto) {
  144. return RT.ok(pbVXsxxsfytbService.studentCategoryStat(dto));
  145. }
  146. @GetMapping(value = "/stduy-status-stat")
  147. @ApiOperation(value = "就读方式的统计")
  148. @SaCheckPermission("consumption:detail")
  149. @XjrLog(value = "就读方式的统计", saveResponseData = true)
  150. public RT<PbStduyStatusVo> stduyStatus(@Valid PbVXsxxsfytbStatDto dto) {
  151. return RT.ok(pbVXsxxsfytbService.stduyStatusStat(dto));
  152. }
  153. @GetMapping(value = "/class-qf-page")
  154. @ApiOperation(value = "班级欠费排序")
  155. @SaCheckPermission("consumption:detail")
  156. @XjrLog(value = "班级欠费排序")
  157. public RT<PageOutput<ClassQfPageVo>> classQfPage(@Valid PbVXsxxsfytbStatDto dto) {
  158. Page<ClassQfPageVo> classQfPage = pbVXsxxsfytbService.getClassQfPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
  159. PageOutput<ClassQfPageVo> pageOutput = ConventPage.getPageOutput(classQfPage, ClassQfPageVo.class);
  160. return RT.ok(pageOutput);
  161. }
  162. @GetMapping(value = "/feeitem-stat")
  163. @ApiOperation(value = "各年级的教材费、住宿费、军训费缴费统计")
  164. @SaCheckPermission("consumption:detail")
  165. @XjrLog(value = "各年级的教材费、住宿费、军训费缴费统计", saveResponseData = true)
  166. public RT<PbFeeitemStatVo> feeitemStat(@Valid PbVXsxxsfytbStatDto dto) {
  167. return RT.ok(pbVXsxxsfytbService.feeitemStat(dto));
  168. }
  169. @PostMapping(value = "/class-qf-export-query")
  170. @ApiOperation(value = "班级欠费排序-导出")
  171. @SaCheckPermission("consumption:detail")
  172. @XjrLog(value = "班级欠费排序-导出")
  173. public ResponseEntity<byte[]> classQfExpert(@Valid @RequestBody PbVXsxxsfytbStatDto dto) {
  174. long count = baseClassService.count();
  175. dto.setLimit(1);
  176. dto.setSize(Integer.parseInt(count + ""));
  177. List<ClassQfPageVo> records = pbVXsxxsfytbService.getClassQfPage(new Page<>(dto.getLimit(), dto.getSize()), dto).getRecords();
  178. ByteArrayOutputStream bot = new ByteArrayOutputStream();
  179. EasyExcel.write(bot, ClassQfPageVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(records);
  180. return RT.fileStream(bot.toByteArray(), "classQf" + ExcelTypeEnum.XLSX.getValue());
  181. }
  182. }