Browse Source

奖助学金导入

dzx 1 year ago
parent
commit
cb2e576132

+ 18 - 0
src/main/java/com/xjrsoft/module/student/controller/BaseStudentScholarshipApplicantController.java

@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+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.toolkit.MPJWrappers;
@@ -22,6 +23,7 @@ import com.xjrsoft.module.student.service.IBaseStudentScholarshipApplicantServic
 import com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantCategoryPageVo;
 import com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantPageVo;
 import com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantVo;
+import com.xjrsoft.module.student.vo.ScholarshipApplicantOptionVo;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -124,7 +126,23 @@ public class BaseStudentScholarshipApplicantController {
     @SaCheckPermission("basestudentscholarshipapplicant:delete")
     public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
         return RT.ok(applicantService.removeBatchByIds(ids));
+    }
 
+    @GetMapping(value = "/option-select")
+    @ApiOperation(value="申请人下拉列表")
+    @SaCheckPermission("basestudentscholarshipapplicant:detail")
+    public RT<List<ScholarshipApplicantOptionVo>> optionSelect(@Valid BaseStudentScholarshipApplicantPageDto dto){
+        List<BaseStudentScholarshipApplicant> applicantList = applicantService.list(
+            new QueryWrapper<BaseStudentScholarshipApplicant>().lambda()
+            .select(BaseStudentScholarshipApplicant::getId)
+            .select(BaseStudentScholarshipApplicant.class,x -> VoToColumnUtil.fieldsToColumns(BaseStudentScholarshipApplicantPageVo.class).contains(x.getProperty()))
+            .eq(ObjectUtil.isNotNull(dto.getBaseStudentScholarshipCategoryId()),BaseStudentScholarshipApplicant::getBaseStudentScholarshipCategoryId, dto.getBaseStudentScholarshipCategoryId())
+            .eq(ObjectUtil.isNotNull(dto.getSemesterId()), BaseStudentScholarshipApplicant::getBaseSemesterId, dto.getSemesterId())
+            .eq(BaseStudentScholarshipApplicant::getStatus, 1)
+            .eq(BaseStudentScholarshipApplicant::getReviewStatus, 0)
+        );
+        List<ScholarshipApplicantOptionVo> voList = BeanUtil.copyToList(applicantList, ScholarshipApplicantOptionVo.class);
+        return RT.ok(voList);
     }
 
 }

+ 5 - 10
src/main/java/com/xjrsoft/module/student/controller/BaseStudentScholarshipReleaseController.java

@@ -19,10 +19,10 @@ import com.xjrsoft.module.student.entity.BaseStudentScholarshipApplicant;
 import com.xjrsoft.module.student.entity.BaseStudentScholarshipRelease;
 import com.xjrsoft.module.student.service.IBaseStudentScholarshipApplicantService;
 import com.xjrsoft.module.student.service.IBaseStudentScholarshipReleaseService;
-import com.xjrsoft.module.student.vo.BaseNewStudentScoreExcelVo;
 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.student.vo.ScholarshipApplicantImportVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -37,6 +37,7 @@ import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.Valid;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -154,18 +155,12 @@ public class BaseStudentScholarshipReleaseController {
 
     @PostMapping("/import")
     @ApiOperation(value = "成绩导入")
-    public RT<List<Map<String, String>>> scoreImport(@RequestParam MultipartFile file) {
-        List<BaseNewStudentScoreExcelVo> errorList = new ArrayList<>();
+    public RT<List<Map<String, String>>> scoreImport(@RequestParam MultipartFile file) throws IOException {
+        List<ScholarshipApplicantImportVo> errorList = applicantService.importData(file);
         List<Map<String, String>> result = new ArrayList<>();
 
-        for (BaseNewStudentScoreExcelVo objectMap : errorList) {
+        for (ScholarshipApplicantImportVo objectMap : errorList) {
             Map<String, String> object = new LinkedHashMap<>();
-            object.put("毕业学校", objectMap.getGraduateSchool());
-            object.put("姓名", objectMap.getName());
-            object.put("性别", objectMap.getGender());
-            object.put("班级", objectMap.getGraduateClass());
-            object.put("总成绩", objectMap.getScore().intValue() + "");
-            object.put("错误信息", "未能查询到该学生或该学生存在多个");
             result.add(object);
         }
         return RT.ok(result);

+ 4 - 1
src/main/java/com/xjrsoft/module/student/entity/BaseStudentScholarshipApplicant.java

@@ -88,7 +88,7 @@ public class BaseStudentScholarshipApplicant implements Serializable {
     * 学期名称
     */
     @ApiModelProperty("学期Id")
-    private String baseSemesterId;
+    private Long baseSemesterId;
     /**
     * 年级名称
     */
@@ -164,4 +164,7 @@ public class BaseStudentScholarshipApplicant implements Serializable {
 
     @ApiModelProperty("奖学金等级 0=无等级")
     private Integer scholarshipLevel;
+
+    @ApiModelProperty("评审状态")
+    private Integer reviewStatus;
 }

+ 4 - 1
src/main/java/com/xjrsoft/module/student/service/IBaseStudentScholarshipApplicantService.java

@@ -5,9 +5,12 @@ import com.github.yulichang.base.MPJBaseService;
 import com.xjrsoft.module.student.dto.BaseStudentScholarshipApplicantCategoryPageDto;
 import com.xjrsoft.module.student.entity.BaseStudentScholarshipApplicant;
 import com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantCategoryPageVo;
+import com.xjrsoft.module.student.vo.ScholarshipApplicantImportVo;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.util.List;
+import java.util.Map;
 
 /**
 * @title: 奖学金申请
@@ -33,5 +36,5 @@ public interface IBaseStudentScholarshipApplicantService extends MPJBaseService<
      */
     Page<BaseStudentScholarshipApplicantCategoryPageVo> getScholarshiPage(Page<BaseStudentScholarshipApplicantCategoryPageDto> page, BaseStudentScholarshipApplicantCategoryPageDto dto);
 
-    List<?> importData(MultipartFile file);
+    List<Map<String, String>> importData(MultipartFile file) throws IOException;
 }

+ 85 - 4
src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentScholarshipApplicantServiceImpl.java

@@ -1,20 +1,36 @@
 package com.xjrsoft.module.student.service.impl;
 
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.excel.EasyExcel;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.enums.GenderEnum;
+import com.xjrsoft.common.utils.VoToColumnUtil;
+import com.xjrsoft.module.base.entity.BaseSemester;
+import com.xjrsoft.module.base.service.IBaseSemesterService;
 import com.xjrsoft.module.student.dto.BaseStudentScholarshipApplicantCategoryPageDto;
 import com.xjrsoft.module.student.entity.BaseStudentScholarshipApplicant;
+import com.xjrsoft.module.student.entity.BaseStudentScholarshipCategory;
 import com.xjrsoft.module.student.mapper.BaseStudentMapper;
 import com.xjrsoft.module.student.mapper.BaseStudentScholarshipApplicantMapper;
 import com.xjrsoft.module.student.service.IBaseStudentScholarshipApplicantService;
+import com.xjrsoft.module.student.service.IBaseStudentScholarshipCategoryService;
 import com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantCategoryPageVo;
+import com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantPageVo;
+import com.xjrsoft.module.student.vo.ScholarshipApplicantImportVo;
 import com.xjrsoft.module.student.vo.StudentInfoVo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @title: 奖学金申请
@@ -25,10 +41,12 @@ import java.util.List;
 @Service
 @AllArgsConstructor
 public class BaseStudentScholarshipApplicantServiceImpl extends MPJBaseServiceImpl<BaseStudentScholarshipApplicantMapper, BaseStudentScholarshipApplicant> implements IBaseStudentScholarshipApplicantService {
-    private final BaseStudentScholarshipApplicantMapper baseStudentScholarshipApplicantMapper;
+    private final BaseStudentScholarshipApplicantMapper applicantMapper;
+    private final IBaseSemesterService semesterService;
+    private final IBaseStudentScholarshipCategoryService categoryService;
     @Override
     public Page<BaseStudentScholarshipApplicantCategoryPageVo> getScholarshiPage(Page<BaseStudentScholarshipApplicantCategoryPageDto> page, BaseStudentScholarshipApplicantCategoryPageDto dto) {
-        Page<BaseStudentScholarshipApplicantCategoryPageVo> result = baseStudentScholarshipApplicantMapper.getScholarshiPage(page, dto);
+        Page<BaseStudentScholarshipApplicantCategoryPageVo> result = applicantMapper.getScholarshiPage(page, dto);
         return result;
     }
 
@@ -58,7 +76,70 @@ public class BaseStudentScholarshipApplicantServiceImpl extends MPJBaseServiceIm
     }
 
     @Override
-    public List<?> importData(MultipartFile file) {
-        return null;
+    public List<Map<String, String>> importData(MultipartFile file) throws IOException {
+        List<ScholarshipApplicantImportVo> dataList = EasyExcel.read(file.getInputStream()).headRowNumber(2).head(ScholarshipApplicantImportVo.class).sheet().doReadSync();
+        List<BaseStudentScholarshipApplicant> applicantList = this.list(
+                new QueryWrapper<BaseStudentScholarshipApplicant>().lambda()
+                        .select(BaseStudentScholarshipApplicant::getId)
+                        .select(BaseStudentScholarshipApplicant.class,x -> VoToColumnUtil.fieldsToColumns(BaseStudentScholarshipApplicantPageVo.class).contains(x.getProperty()))
+                        .eq(BaseStudentScholarshipApplicant::getStatus, 1)
+        );
+
+        List<BaseSemester> semesterList = semesterService.list(
+                new QueryWrapper<BaseSemester>().lambda()
+                        .select(BaseSemester::getId)
+                        .select(BaseSemester.class, x -> VoToColumnUtil.fieldsToColumns(BaseSemester.class).contains(x.getProperty()))
+                        .eq(BaseSemester::getDeleteMark, DeleteMark.NODELETE.getCode())
+        );
+        Map<String, Long> semesterMap = semesterList.stream().collect(Collectors.toMap(BaseSemester::getName, BaseSemester::getId));
+
+        List<BaseStudentScholarshipCategory> categoryList = categoryService.list(
+                new QueryWrapper<BaseStudentScholarshipCategory>().lambda()
+                        .select(BaseStudentScholarshipCategory::getId)
+                        .select(BaseStudentScholarshipCategory.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentScholarshipCategory.class).contains(x.getProperty()))
+                        .eq(BaseStudentScholarshipCategory::getDeleteMark, DeleteMark.NODELETE.getCode())
+        );
+
+        Map<String, Long> categoryMap = categoryList.stream().collect(Collectors.toMap(BaseStudentScholarshipCategory::getName, BaseStudentScholarshipCategory::getId));
+
+        List<Map<String, String>> errorList = new ArrayList<>();
+        List<BaseStudentScholarshipApplicant> updateList = new ArrayList<>();
+        for (ScholarshipApplicantImportVo importVo : dataList) {
+            List<String> errorMsg = new ArrayList<>();
+            if(StrUtil.isEmpty(importVo.getSemesterName()) || StrUtil.isEmpty(importVo.getName()) || StrUtil.isEmpty(importVo.getCredentialNumber())
+            || StrUtil.isEmpty(importVo.getScholarshipCategoryName()) || importVo.getScholarshipLevel() == null){
+                errorMsg.add("有未填写的列");
+            }
+            if(semesterMap.get(importVo.getSemesterName()) == null){
+                errorMsg.add("学期名称填写不正确");
+            }
+            Long semesterId = semesterMap.get(importVo.getSemesterName());
+            if(categoryMap.get(importVo.getScholarshipCategoryName()) == null){
+                errorMsg.add("奖学金名称填写不正确");
+            }
+            Long categoryId = categoryMap.get(importVo.getScholarshipCategoryName());
+            for (BaseStudentScholarshipApplicant applicant : applicantList) {
+                if(applicant.getBaseSemesterId() == semesterId && importVo.getName().equals(applicant.getName()) && importVo.getCredentialNumber().equals(applicant.getStudentId())){
+                    applicant.setBaseStudentScholarshipCategoryId(categoryId);
+                    applicant.setReviewStatus(1);
+                    applicant.setScholarshipLevel(importVo.getScholarshipLevel());
+                    updateList.add(applicant);
+                }
+            }
+            if(!errorMsg.isEmpty()){
+                LinkedHashMap<String, String> map = new LinkedHashMap<>();
+                map.put("学期名称", importVo.getSemesterName());
+                map.put("姓名", importVo.getName());
+                map.put("身份证号", importVo.getCredentialNumber());
+                map.put("奖学金名称", importVo.getScholarshipCategoryName());
+                map.put("获奖等级", importVo.getScholarshipLevel() + "");
+                map.put("错误信息", errorMsg.toString().replace("[", "").replace("]", ""));
+                errorList.add(map);
+            }
+        }
+        if(!updateList.isEmpty()){
+            this.updateBatchById(updateList);
+        }
+        return errorList;
     }
 }

+ 38 - 0
src/main/java/com/xjrsoft/module/student/vo/ScholarshipApplicantImportVo.java

@@ -0,0 +1,38 @@
+package com.xjrsoft.module.student.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+* @title: 奖学金申请表单出参
+* @Author dzx
+* @Date: 2023-11-23
+* @Version 1.0
+*/
+@Data
+public class ScholarshipApplicantImportVo {
+
+    @ExcelProperty("学期名称")
+    @ApiModelProperty("学期名称")
+    private String semesterName;
+
+    @ExcelProperty("姓名")
+    @ApiModelProperty("姓名")
+    private String name;
+
+    @ExcelProperty("身份证号")
+    @ApiModelProperty("身份证号")
+    private String credentialNumber;
+
+    @ExcelProperty("奖学金名称")
+    @ApiModelProperty("奖学金名称")
+    private String scholarshipCategoryName;
+
+    @ExcelProperty("获奖等级")
+    @ApiModelProperty("获奖等级")
+    private Integer scholarshipLevel;
+
+}

+ 110 - 0
src/main/java/com/xjrsoft/module/student/vo/ScholarshipApplicantOptionVo.java

@@ -0,0 +1,110 @@
+package com.xjrsoft.module.student.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+* @title: 奖学金申请表单出参
+* @Author dzx
+* @Date: 2023-11-23
+* @Version 1.0
+*/
+@Data
+public class ScholarshipApplicantOptionVo {
+
+    /**
+    * 主键编号
+    */
+    @ApiModelProperty("主键编号")
+    private Long id;
+    /**
+    * 序号
+    */
+    @ApiModelProperty("序号")
+    private Integer sortCode;
+    /**
+    * 奖学金类别ID(base_student_scholarship_category)
+    */
+    @ApiModelProperty("奖学金类别ID(base_student_scholarship_category)")
+    private Long baseStudentScholarshipCategoryId;
+    /**
+    * 申请人
+    */
+    @ApiModelProperty("申请人")
+    private Long applicantUserId;
+    /**
+    * 学期名称
+    */
+    @ApiModelProperty("学期名称")
+    private String semesterName;
+    /**
+    * 入学名称
+    */
+    @ApiModelProperty("入学名称")
+    private String gradeName;
+    /**
+    * 班级名称
+    */
+    @ApiModelProperty("班级名称")
+    private String className;
+    /**
+    * 姓名
+    */
+    @ApiModelProperty("姓名")
+    private String name;
+    /**
+    * 学号
+    */
+    @ApiModelProperty("学号")
+    private String studentId;
+    /**
+    * 性别
+    */
+    @ApiModelProperty("性别")
+    private String genderName;
+    /**
+    * 招生类型名称
+    */
+    @ApiModelProperty("招生类型名称")
+    private String enrollTypeCn;
+    /**
+    * 在读专业
+    */
+    @ApiModelProperty("在读专业")
+    private String majorName;
+    /**
+    * 获奖日期
+    */
+    @ApiModelProperty("获奖日期")
+    private Date awardDate;
+    /**
+    * 收款银行(xjr_dictionary_item[bank_type])
+    */
+    @ApiModelProperty("收款银行(xjr_dictionary_item[bank_type])")
+    private String bankType;
+    /**
+    * 银行卡号
+    */
+    @ApiModelProperty("银行卡号")
+    private String bankNo;
+    /**
+    * 文件ID(xjr_file)
+    */
+    @ApiModelProperty("文件ID(xjr_file)")
+    private Long fileId;
+    /**
+    * 状态(1:结束 0:未结束)
+    */
+    @ApiModelProperty("状态(1:结束 0:未结束)")
+    private Integer status;
+    /**
+    * 发放状态(1:已发放 0:未发放)
+    */
+    @ApiModelProperty("发放状态(1:已发放 0:未发放)")
+    private Integer releaseStatus;
+
+
+
+}