package com.xjrsoft.module.student.controller; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.stp.StpUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.support.ExcelTypeEnum; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.xjrsoft.common.annotation.XjrLog; import com.xjrsoft.common.enums.DeleteMark; import com.xjrsoft.common.model.result.RT; import com.xjrsoft.common.page.ConventPage; import com.xjrsoft.common.page.PageOutput; import com.xjrsoft.common.utils.TreeUtil; import com.xjrsoft.module.base.entity.BaseClass; import com.xjrsoft.module.base.service.IBaseClassService; import com.xjrsoft.module.base.service.IBaseGradeService; import com.xjrsoft.module.student.dto.*; import com.xjrsoft.module.student.service.IPbVXssfdetailService; import com.xjrsoft.module.student.service.IPbVXsxxsfytbService; import com.xjrsoft.module.student.vo.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @title: 学生消费管理 * @Author dzx * @Date: 2024年6月3日 * @Version 1.0 */ @RestController @RequestMapping("/student" + "/consumption") @Api(value = "/student" + "/consumption", tags = "学生消费管理") @AllArgsConstructor public class ConsumptionController { private final IPbVXssfdetailService pbVXssfdetailService; private final IPbVXsxxsfytbService pbVXsxxsfytbService; private final IBaseGradeService baseGradeService; private final IBaseClassService baseClassService; @GetMapping(value = "/tree") @ApiOperation(value = "学生在读毕业年级班级树") @SaCheckPermission("studentmanager:detail") @XjrLog(value = "学生在读毕业年级班级树") public RT> tree() { List voList = new ArrayList<>(); List qfCount = pbVXsxxsfytbService.getClassQfCount(); Map qfCountMap = new HashMap<>(); for (BaseClassQfCountVo qfCountVo : qfCount) { qfCountMap.put(qfCountVo.getId(), qfCountVo.getCount()); } voList.add(new BaseClassTreeVo() {{ setId(6L); setName("年级"); }}); baseGradeService.list().forEach((node) -> { if (node.getStatus() == 1) { voList.add(new BaseClassTreeVo() {{ setId(node.getId()); setName(node.getName()); setParentId(6L); }}); } }); baseClassService.list(new QueryWrapper().lambda().eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())).forEach((node) -> { voList.add(new BaseClassTreeVo() {{ setId(node.getId()); setName(node.getName()); setParentId(node.getGradeId()); setStatus(0); if (qfCountMap.get(node.getId()) != null && qfCountMap.get(node.getId()) > 0) { setStatus(1); } }}); }); List treeVoList = TreeUtil.build(voList); return RT.ok(treeVoList); } @GetMapping(value = "/personal-info") @ApiOperation(value = "学生个人信息") @SaCheckPermission("consumption:detail") @XjrLog(value = "学生个人信息", saveResponseData = true) public RT personalInfo(@Valid PersonalInfoDto dto) { PersonalPortraitPersonalInfoVo info = pbVXssfdetailService.getPersonalInfo(dto); return RT.ok(info); } @GetMapping(value = "/detail-page") @ApiOperation(value = "学生收费明细分页查询") @SaCheckPermission("consumption:detail") @XjrLog(value = "学生收费明细分页查询") public RT> detailPage(@Valid PbVXssfdetailPageDto dto) { Page page = pbVXssfdetailService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto); PageOutput pageOutput = ConventPage.getPageOutput(page, PbVXssfdetailPageVo.class); return RT.ok(pageOutput); } @GetMapping(value = "/pb_vx_sxxsfytbPage") @ApiOperation(value = "学生消费管理页分页查询") @SaCheckPermission("consumption:detail") @XjrLog(value = "学生消费管理页分页查询") public RT> pbVXsxxsfytbPage(@Valid PbVXsxxsfytbPageDto dto) { List roleList = StpUtil.getRoleList(); if (roleList.size() == 2 && roleList.contains("TEACHER") && roleList.contains("CLASSTE")) { dto.setTeacherId(StpUtil.getLoginIdAsLong()); } IPage page = pbVXsxxsfytbService.getPage(dto); PageOutput pageOutput = ConventPage.getPageOutput(page, PbVXsxxsfytbPageVo.class); return RT.ok(pageOutput); } @GetMapping(value = "/cost-information") @ApiOperation(value = "费用信息") @SaCheckPermission("consumption:detail") @XjrLog(value = "费用信息", saveResponseData = true) public RT costInformation(@Valid PersonalPortraitFeeInformationDto dto) { return RT.ok(pbVXsxxsfytbService.listCostInformation(dto)); } @PostMapping("/export-query") @ApiOperation(value = "有参导出") @XjrLog(value = "有参导出") public ResponseEntity exportData(@RequestBody PbVXsxxsfytbExcelDto dto) { List dataList = pbVXsxxsfytbService.getList(dto); ByteArrayOutputStream bot = new ByteArrayOutputStream(); EasyExcel.write(bot, PbVXsxxsfytbExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(dataList); return RT.fileStream(bot.toByteArray(), "PbVXsxxsfytbExcel" + ExcelTypeEnum.XLSX.getValue()); } @GetMapping(value = "/fee-detail") @ApiOperation(value = "学生缴费的详情") @SaCheckPermission("consumption:detail") @XjrLog(value = "学生缴费的详情") public RT> feeDetail(@RequestParam String studentcode, String beltcode) { return RT.ok(pbVXsxxsfytbService.getFeeDetail(studentcode, beltcode)); } @GetMapping(value = "/student-category-stat") @ApiOperation(value = "学生类别的人数统计") @SaCheckPermission("consumption:detail") @XjrLog(value = "学生类别的人数统计", saveResponseData = true) public RT studentCategory(@Valid PbVXsxxsfytbStatDto dto) { return RT.ok(pbVXsxxsfytbService.studentCategoryStat(dto)); } @GetMapping(value = "/stduy-status-stat") @ApiOperation(value = "就读方式的统计") @SaCheckPermission("consumption:detail") @XjrLog(value = "就读方式的统计", saveResponseData = true) public RT stduyStatus(@Valid PbVXsxxsfytbStatDto dto) { return RT.ok(pbVXsxxsfytbService.stduyStatusStat(dto)); } @GetMapping(value = "/class-qf-page") @ApiOperation(value = "班级欠费排序") @SaCheckPermission("consumption:detail") @XjrLog(value = "班级欠费排序") public RT> classQfPage(@Valid PbVXsxxsfytbStatDto dto) { Page classQfPage = pbVXsxxsfytbService.getClassQfPage(new Page<>(dto.getLimit(), dto.getSize()), dto); PageOutput pageOutput = ConventPage.getPageOutput(classQfPage, ClassQfPageVo.class); return RT.ok(pageOutput); } @GetMapping(value = "/feeitem-stat") @ApiOperation(value = "各年级的教材费、住宿费、军训费缴费统计") @SaCheckPermission("consumption:detail") @XjrLog(value = "各年级的教材费、住宿费、军训费缴费统计", saveResponseData = true) public RT feeitemStat(@Valid PbVXsxxsfytbStatDto dto) { return RT.ok(pbVXsxxsfytbService.feeitemStat(dto)); } @PostMapping(value = "/class-qf-export-query") @ApiOperation(value = "班级欠费排序-导出") @SaCheckPermission("consumption:detail") @XjrLog(value = "班级欠费排序-导出") public ResponseEntity classQfExpert(@Valid @RequestBody PbVXsxxsfytbStatDto dto) { long count = baseClassService.count(); dto.setLimit(1); dto.setSize(Integer.parseInt(count + "")); List records = pbVXsxxsfytbService.getClassQfPage(new Page<>(dto.getLimit(), dto.getSize()), dto).getRecords(); ByteArrayOutputStream bot = new ByteArrayOutputStream(); EasyExcel.write(bot, ClassQfPageVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(records); return RT.fileStream(bot.toByteArray(), "classQf" + ExcelTypeEnum.XLSX.getValue()); } }