|
@@ -2,19 +2,33 @@ package com.xjrsoft.module.student.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+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.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.page.PageOutput;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
+import com.xjrsoft.module.base.entity.BaseGrade;
|
|
|
+import com.xjrsoft.module.base.entity.BaseMajorSet;
|
|
|
+import com.xjrsoft.module.organization.entity.User;
|
|
|
+import com.xjrsoft.module.organization.service.IUserService;
|
|
|
import com.xjrsoft.module.student.dto.AddBaseStudentScholarshipReleaseDto;
|
|
|
+import com.xjrsoft.module.student.dto.AddStudentScholarshipDto;
|
|
|
import com.xjrsoft.module.student.dto.BaseStudentScholarshipReleasePageDto;
|
|
|
import com.xjrsoft.module.student.dto.UpdateBaseStudentScholarshipReleaseDto;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentScholarshipApplicant;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentScholarshipRelease;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
+import com.xjrsoft.module.student.service.IBaseStudentScholarshipApplicantService;
|
|
|
import com.xjrsoft.module.student.service.IBaseStudentScholarshipReleaseService;
|
|
|
+import com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantVo;
|
|
|
import com.xjrsoft.module.student.vo.BaseStudentScholarshipReleasePageVo;
|
|
|
+import com.xjrsoft.module.student.vo.BaseStudentScholarshipReleaseRecordVo;
|
|
|
import com.xjrsoft.module.student.vo.BaseStudentScholarshipReleaseVo;
|
|
|
+import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -28,6 +42,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -42,44 +57,69 @@ import java.util.List;
|
|
|
@AllArgsConstructor
|
|
|
public class BaseStudentScholarshipReleaseController {
|
|
|
|
|
|
-
|
|
|
+ private final IBaseStudentScholarshipApplicantService applicantService;
|
|
|
private final IBaseStudentScholarshipReleaseService releaseService;
|
|
|
+ private final IUserService userService;
|
|
|
|
|
|
@GetMapping(value = "/page")
|
|
|
- @ApiOperation(value="奖学金发放记录表列表(分页)")
|
|
|
+ @ApiOperation(value = "奖学金发放记录表列表(分页)")
|
|
|
@SaCheckPermission("basestudentscholarshiprelease:detail")
|
|
|
- public RT<PageOutput<BaseStudentScholarshipReleasePageVo>> page(@Valid BaseStudentScholarshipReleasePageDto dto){
|
|
|
+ public RT<PageOutput<BaseStudentScholarshipReleasePageVo>> page(@Valid BaseStudentScholarshipReleasePageDto dto) {
|
|
|
|
|
|
Page<BaseStudentScholarshipReleasePageVo> page = releaseService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
|
|
|
PageOutput<BaseStudentScholarshipReleasePageVo> pageOutput = ConventPage.getPageOutput(page, BaseStudentScholarshipReleasePageVo.class);
|
|
|
return RT.ok(pageOutput);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping(value = "/record")
|
|
|
+ @ApiOperation(value = "奖学金发放记录表列表(分页)")
|
|
|
+ @SaCheckPermission("basestudentscholarshiprelease:detail")
|
|
|
+ public RT<PageOutput<BaseStudentScholarshipReleaseRecordVo>> record(@Valid BaseStudentScholarshipReleasePageDto dto) {
|
|
|
+
|
|
|
+ IPage<BaseStudentScholarshipReleaseRecordVo> page = releaseService.selectJoinListPage(ConventPage.getPage(dto), BaseStudentScholarshipReleaseRecordVo.class,
|
|
|
+ new MPJLambdaWrapper<BaseStudentScholarshipRelease>()
|
|
|
+ .select(BaseStudentScholarshipRelease::getId)
|
|
|
+ .select(BaseStudentScholarshipRelease.class,x -> VoToColumnUtil.fieldsToColumns(BaseStudentScholarshipRelease.class).contains(x.getProperty()))
|
|
|
+ .eq(BaseStudentScholarshipRelease::getBaseStudentScholarshipApplicantId, dto.getApplicantId())
|
|
|
+ );
|
|
|
+ PageOutput<BaseStudentScholarshipReleaseRecordVo> pageOutput = ConventPage.getPageOutput(page, BaseStudentScholarshipReleaseRecordVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping(value = "/info")
|
|
|
- @ApiOperation(value="根据id查询奖学金发放记录表信息")
|
|
|
+ @ApiOperation(value = "根据申请id查询奖学金发放记录表信息")
|
|
|
@SaCheckPermission("basestudentscholarshiprelease:detail")
|
|
|
- public RT<BaseStudentScholarshipReleaseVo> info(@RequestParam Long id){
|
|
|
- BaseStudentScholarshipRelease baseStudentScholarshipRelease = releaseService.getById(id);
|
|
|
- if (baseStudentScholarshipRelease == null) {
|
|
|
- return RT.error("找不到此数据!");
|
|
|
+ public RT<BaseStudentScholarshipReleaseVo> info(@RequestParam Long id) {
|
|
|
+ BaseStudentScholarshipApplicant applicant = applicantService.getById(id);
|
|
|
+ if (applicant == null) {
|
|
|
+ return RT.error("找不到此数据!");
|
|
|
}
|
|
|
- return RT.ok(BeanUtil.toBean(baseStudentScholarshipRelease, BaseStudentScholarshipReleaseVo.class));
|
|
|
+ List<BaseStudentScholarshipRelease> list = releaseService.list(
|
|
|
+ new QueryWrapper<BaseStudentScholarshipRelease>().lambda()
|
|
|
+ .eq(BaseStudentScholarshipRelease::getBaseStudentScholarshipApplicantId, id)
|
|
|
+ );
|
|
|
+ double sum = list.stream().filter(value -> value.getAmount() != null).mapToDouble(value -> value.getAmount()).sum();
|
|
|
+ BaseStudentScholarshipReleaseVo releaseVo = new BaseStudentScholarshipReleaseVo();
|
|
|
+ releaseVo.setScholarshipApplicantId(applicant.getBaseStudentScholarshipCategoryId());
|
|
|
+ releaseVo.setTotalAmount(applicant.getAmount());
|
|
|
+ releaseVo.setReleaseAmount(sum);
|
|
|
+ return RT.ok(releaseVo);
|
|
|
}
|
|
|
|
|
|
|
|
|
@PostMapping
|
|
|
@ApiOperation(value = "新增奖学金发放记录表")
|
|
|
@SaCheckPermission("basestudentscholarshiprelease:add")
|
|
|
- public RT<Boolean> add(@Valid @RequestBody AddBaseStudentScholarshipReleaseDto dto){
|
|
|
+ public RT<Boolean> add(@Valid @RequestBody AddBaseStudentScholarshipReleaseDto dto) {
|
|
|
BaseStudentScholarshipRelease baseStudentScholarshipRelease = BeanUtil.toBean(dto, BaseStudentScholarshipRelease.class);
|
|
|
boolean isSuccess = releaseService.save(baseStudentScholarshipRelease);
|
|
|
- return RT.ok(isSuccess);
|
|
|
+ return RT.ok(isSuccess);
|
|
|
}
|
|
|
|
|
|
@PutMapping
|
|
|
@ApiOperation(value = "修改奖学金发放记录表")
|
|
|
@SaCheckPermission("basestudentscholarshiprelease:edit")
|
|
|
- public RT<Boolean> update(@Valid @RequestBody UpdateBaseStudentScholarshipReleaseDto dto){
|
|
|
+ public RT<Boolean> update(@Valid @RequestBody UpdateBaseStudentScholarshipReleaseDto dto) {
|
|
|
|
|
|
BaseStudentScholarshipRelease baseStudentScholarshipRelease = BeanUtil.toBean(dto, BaseStudentScholarshipRelease.class);
|
|
|
return RT.ok(releaseService.updateById(baseStudentScholarshipRelease));
|
|
@@ -89,9 +129,54 @@ public class BaseStudentScholarshipReleaseController {
|
|
|
@DeleteMapping
|
|
|
@ApiOperation(value = "删除奖学金发放记录表")
|
|
|
@SaCheckPermission("basestudentscholarshiprelease:delete")
|
|
|
- public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
|
|
|
+ public RT<Boolean> delete(@Valid @RequestBody List<Long> ids) {
|
|
|
return RT.ok(releaseService.removeBatchByIds(ids));
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("add-student")
|
|
|
+ @ApiOperation(value = "添加学生")
|
|
|
+ @SaCheckPermission("basestudentscholarshiprelease:add")
|
|
|
+ public RT<Boolean> addStudent(@Valid @RequestBody AddStudentScholarshipDto dto) {
|
|
|
+ if(dto.getUserIds() != null && !dto.getUserIds().isEmpty()){
|
|
|
+
|
|
|
+ List<BaseStudentScholarshipApplicantVo> list = userService.selectJoinList(BaseStudentScholarshipApplicantVo.class,
|
|
|
+ new MPJLambdaWrapper<User>()
|
|
|
+ .selectAs(User::getId, BaseStudentScholarshipApplicantVo::getApplicantUserId)
|
|
|
+ .selectAs(User::getName, BaseStudentScholarshipApplicantVo::getName)
|
|
|
+ .selectAs(User::getCredentialNumber, BaseStudentScholarshipApplicantVo::getStudentId)
|
|
|
+ .select("t5.name", BaseStudentScholarshipApplicantVo::getGenderName)
|
|
|
+ .select("t4.name", BaseStudentScholarshipApplicantVo::getEnrollTypeCn)
|
|
|
+ .selectAs(BaseMajorSet::getName, BaseStudentScholarshipApplicantVo::getMajorName)
|
|
|
+ .selectAs(BaseClass::getName, BaseStudentScholarshipApplicantVo::getClassName)
|
|
|
+ .selectAs(BaseGrade::getName, BaseStudentScholarshipApplicantVo::getGradeName)
|
|
|
+ .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, User::getId)
|
|
|
+ .innerJoin(BaseClass.class, BaseClass::getId, BaseStudentSchoolRoll::getClassId)
|
|
|
+ .innerJoin(BaseGrade.class, BaseGrade::getId, BaseClass::getGradeId)
|
|
|
+ .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, BaseStudentSchoolRoll::getEnrollType)
|
|
|
+ .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, User::getGender)
|
|
|
+ .leftJoin(BaseMajorSet.class, BaseMajorSet::getId, BaseStudentSchoolRoll::getMajorSetId)
|
|
|
+ );
|
|
|
+ List<BaseStudentScholarshipApplicant> dataList = new ArrayList<>();
|
|
|
+ for (BaseStudentScholarshipApplicantVo applicantVo : list) {
|
|
|
+ dataList.add(
|
|
|
+ new BaseStudentScholarshipApplicant(){{
|
|
|
+ setStudentId(applicantVo.getStudentId());
|
|
|
+ setName(applicantVo.getName());
|
|
|
+ setClassName(applicantVo.getClassName());
|
|
|
+ setApplicantUserId(applicantVo.getApplicantUserId());
|
|
|
+ setGenderName(applicantVo.getGenderName());
|
|
|
+ setEnrollTypeCn(applicantVo.getEnrollTypeCn());
|
|
|
+ setMajorName(applicantVo.getMajorName());
|
|
|
+ setGradeName(applicantVo.getGradeName());
|
|
|
+ setStatus(1);
|
|
|
+ }}
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if(!dataList.isEmpty()){
|
|
|
+ applicantService.saveBatch(dataList);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return RT.ok(true);
|
|
|
+ }
|
|
|
}
|