Browse Source

自治区名单导入管理

houlai 6 months ago
parent
commit
79711e7abf
14 changed files with 781 additions and 6 deletions
  1. 4 0
      yudao-module-as/yudao-module-as-api/src/main/java/cn/iocoder/yudao/module/as/enums/ErrorCodeConstants.java
  2. 103 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/AidingStudentsImportListController.java
  3. 23 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/vo/AidingStudentsImportExcelRespVO.java
  4. 51 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/vo/AidingStudentsImportExcelVO.java
  5. 45 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/vo/AidingStudentsImportListPageResqVO.java
  6. 48 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/vo/AidingStudentsImportListRespVO.java
  7. 49 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/vo/AidingStudentsImportListSaveReqVO.java
  8. 65 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/dataobject/aidingstudentsimportlist/AidingStudentsImportExcelListDO.java
  9. 24 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/mysql/aidingstudentsimportlist/AidingStudentsImportListMapper.java
  10. 5 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/redis/RedisKeyConstants.java
  11. 111 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/redis/aidingstudentsimportlist/AidingStudentsImportListRedisDAO.java
  12. 58 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentsimportlist/AidingStudentsImportListService.java
  13. 194 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentsimportlist/AidingStudentsImportListServiceImpl.java
  14. 1 6
      yudao-module-bpm/yudao-module-bpm-biz/pom.xml

+ 4 - 0
yudao-module-as/yudao-module-as-api/src/main/java/cn/iocoder/yudao/module/as/enums/ErrorCodeConstants.java

@@ -10,5 +10,9 @@ public interface ErrorCodeConstants {
     ErrorCode AIDING_STUDENTS_COLLEGE_MANAGE_NOT_EXISTS = new ErrorCode(2_009_000_002, "综测项目学院管理不存在");
     ErrorCode FINANCIAL_AID_MANAGE_NOT_EXISTS = new ErrorCode(2_009_000_003, "助学金项目管理不存在");
     ErrorCode FINANCIAL_AID_COLLEGE_MANAGE_NOT_EXISTS = new ErrorCode(2_009_000_004,  "助学金评定项目学院管理不存在");
+    ErrorCode AIDING_STUDENTS_IMPORT_LIST_NOT_EXISTS = new ErrorCode(2_009_000_005,  "自治区名单中该学生不存在");
+    ErrorCode AIDING_STUDENTS_IMPORT_LIST_IS_NULL = new ErrorCode(2_009_000_006,  "excel表解析为空");
+    ErrorCode AIDING_STUDENTS_IMPORT_LIST_STUDENT_EXISTS = new ErrorCode(2_009_000_007,  "自治区名单中该学生已存在");
+
 
 }

+ 103 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/AidingStudentsImportListController.java

@@ -0,0 +1,103 @@
+package cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo.*;
+import cn.iocoder.yudao.module.as.dal.dataobject.aidingstudentsimportlist.AidingStudentsImportExcelListDO;
+import cn.iocoder.yudao.module.as.service.aidingstudentsimportlist.AidingStudentsImportListService;
+import io.swagger.v3.oas.annotations.Parameters;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import javax.validation.*;
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+
+import org.springframework.web.multipart.MultipartFile;
+
+@Tag(name = "管理后台 - 贫困学生自治区名单导入")
+@RestController
+@RequestMapping("/as/aiding-students-import-list")
+@Validated
+public class AidingStudentsImportListController {
+
+    @Resource
+    private AidingStudentsImportListService aidingStudentsImportListService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建贫困学生自治区名单导入")
+    @PreAuthorize("@ss.hasPermission('as:aiding-students-import-list:create')")
+    public CommonResult<Long> createAidingStudentsImportList(@Valid @RequestBody AidingStudentsImportListSaveReqVO createReqVO,
+                                                             @RequestParam(value = "aidingStudentsManageId") Long aidingStudentsManageId) {
+        return success(aidingStudentsImportListService.createAidingStudentsImportList(createReqVO, aidingStudentsManageId));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新贫困学生自治区名单导入管理")
+    @PreAuthorize("@ss.hasPermission('as:aiding-students-import-list:update')")
+    public CommonResult<Boolean> updateAidingStudentsImportList(@Valid @RequestBody AidingStudentsImportListSaveReqVO updateReqVO) {
+        aidingStudentsImportListService.updateAidingStudentsImportList(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除贫困学生自治区名单导入管理")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('as:aiding-students-import-list:delete')")
+    public CommonResult<Boolean> deleteAidingStudentsImportList(@RequestParam("id") Long id) {
+        aidingStudentsImportListService.deleteAidingStudentsImportList(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "通过id获得贫困学生自治区名单导入中的学生")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('as:aiding-students-import-list:query')")
+    public CommonResult<AidingStudentsImportListRespVO> getAidingStudentsImportList(@RequestParam("id") Long id) {
+        AidingStudentsImportExcelListDO aidingStudentsImportList = aidingStudentsImportListService.getAidingStudentsImportList(id);
+        return success(BeanUtils.toBean(aidingStudentsImportList, AidingStudentsImportListRespVO.class));
+    }
+
+
+    @GetMapping("/page")
+    @Operation(summary = "获得贫困学生自治区名单导入管理分页")
+    @PreAuthorize("@ss.hasPermission('as:aiding-students-import-list:query')")
+    public CommonResult<PageResult<AidingStudentsImportListRespVO>> getAidingStudentsCollegeManagePage(@Valid AidingStudentsImportListPageResqVO pageReqVO, @RequestParam(value = "aidingStudentsManageId", required = false) Long aidingStudentsManageId) {
+        PageResult<AidingStudentsImportExcelListDO> pageResult =
+                aidingStudentsImportListService.getAidingStudentsImportListPage(pageReqVO, aidingStudentsManageId);
+        return success(BeanUtils.toBean(pageResult, AidingStudentsImportListRespVO.class));
+    }
+
+    @PostMapping("/import-excel")
+    @Operation(summary = "导入家庭情况困难认定学生 把Excel从redis导入到到mysql中")
+    @Parameters({
+            @Parameter(name = "aidingStudentsManageId", description = "助学学校项目id", example = "5")
+    })
+    @PreAuthorize("@ss.hasPermission('as:aiding-students-import-list:import')")
+    public CommonResult<AidingStudentsImportExcelRespVO> importExcel(@RequestParam(value = "aidingStudentsManageId", required = true) Long aidingStudentsManageId) throws Exception {
+        return success(aidingStudentsImportListService.aidingStudentsImportExcelList( aidingStudentsManageId));
+    }
+
+
+    @PostMapping("/import-excel-to-redis")
+    @Operation(summary = "导入家庭情况困难认定学生 Excel到redis中")
+    @PreAuthorize("@ss.hasPermission('as:aiding-students-import-list:importtoredis')")
+    public CommonResult<Boolean> importExcelToRedis(@RequestParam("file") MultipartFile file) throws Exception {
+        List<AidingStudentsImportExcelVO> list = ExcelUtils.read(file, AidingStudentsImportExcelVO.class);
+        aidingStudentsImportListService.aidingStudentsImportExcelToRedis(list);
+        return success(true);
+    }
+
+}

+ 23 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/vo/AidingStudentsImportExcelRespVO.java

@@ -0,0 +1,23 @@
+package cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Builder;
+import lombok.Data;
+
+import java.util.List;
+import java.util.Map;
+
+
+@Schema(description = "管理后台 - 贫困学生自治区名单导入 Response VO")
+@Data
+@Builder
+public class AidingStudentsImportExcelRespVO {
+    @Schema(description = "创建成功的学生名数组", requiredMode = Schema.RequiredMode.REQUIRED)
+    private List<String> createStudentNames;
+
+/*    @Schema(description = "更新成功的学生名数组", requiredMode = Schema.RequiredMode.REQUIRED)
+    private List<String> updateStudentNames;*/
+
+    @Schema(description = "导入失败的学生集合,key 为用户名,value 为失败原因", requiredMode = Schema.RequiredMode.REQUIRED)
+    private Map<String, String> failureStudentNames;
+}

+ 51 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/vo/AidingStudentsImportExcelVO.java

@@ -0,0 +1,51 @@
+package cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo;
+
+import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
+import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
+import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@Accessors(chain = false) // 设置 chain = false,避免贫困学生导入有问题
+public class AidingStudentsImportExcelVO {
+    @Schema(description = "姓名")
+    @ExcelProperty("姓名")
+    private String studentName;
+
+    @Schema(description = "学号")
+    @ExcelProperty("学号")
+    private String studentCode;
+
+    @Schema(description = "性别,1表示男,2表示女,3表示未知")
+    @ExcelProperty(value = "性别", converter = DictConvert.class)
+    @DictFormat(DictTypeConstants.USER_SEX)
+    private Integer studentSex;
+
+    @Schema(description = "年龄")
+    @ExcelProperty("年龄")
+    private Integer studentAge;
+
+    @Schema(description = "身份证号")
+    @ExcelProperty("身份证号")
+    private String studentIdNumber;
+
+    @Schema(description = "家庭地址")
+    @ExcelProperty("家庭地址")
+    private String studentAddress;
+
+    @Schema(description = "类型")
+    @ExcelProperty("类型")
+    private String studentType;
+
+
+}

+ 45 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/vo/AidingStudentsImportListPageResqVO.java

@@ -0,0 +1,45 @@
+package cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+@Schema(description = "管理后台 - 贫困学生自治区名单导入分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class AidingStudentsImportListPageResqVO extends PageParam {
+
+
+    @Schema(description = "姓名")
+    private String studentName;
+
+
+    @Schema(description = "学号")
+    private String studentCode;
+
+
+    @Schema(description = "性别,1表示男,2表示女,3表示未知")
+    private Integer studentSex;
+
+
+
+    @Schema(description = "年龄")
+    private Integer studentAge;
+
+
+    @Schema(description = "身份证号")
+    private String studentIdNumber;
+
+
+    @Schema(description = "家庭地址")
+    private String studentAddress;
+
+
+    @Schema(description = "类型")
+    private String studentType;
+
+
+}

+ 48 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/vo/AidingStudentsImportListRespVO.java

@@ -0,0 +1,48 @@
+package cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo;
+
+
+import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
+import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
+import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "管理后台 - 贫困学生自治区名单导入 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class AidingStudentsImportListRespVO {
+    @Schema(description = "id")
+    private Long id;
+
+
+    @Schema(description = "姓名")
+    private String studentName;
+
+
+    @Schema(description = "学号")
+    private String studentCode;
+
+
+    @Schema(description = "性别,1表示男,2表示女,3表示未知")
+    private Integer studentSex;
+
+
+
+    @Schema(description = "年龄")
+    private Integer studentAge;
+
+
+    @Schema(description = "身份证号")
+    private String studentIdNumber;
+
+
+    @Schema(description = "家庭地址")
+    private String studentAddress;
+
+
+    @Schema(description = "类型")
+    private String studentType;
+
+}

+ 49 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/vo/AidingStudentsImportListSaveReqVO.java

@@ -0,0 +1,49 @@
+package cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo;
+
+import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
+import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
+
+@Schema(description = "管理后台 - 贫困学生自治区名单导入新增/修改 Request VO")
+@Data
+public class AidingStudentsImportListSaveReqVO {
+    @Schema(description = "id", example = "2482")
+    private Long id;
+
+    @Schema(description = "姓名")
+    @NotBlank(message = "姓名不能为空")
+    private String studentName;
+
+
+    @Schema(description = "学号")
+    @NotBlank(message = "学号不能为空")
+    @Length(min = 1, max = 30, message = "学号长度需在1到=30个字符之间")
+    private String studentCode;
+
+
+    @Schema(description = "性别,1表示男,2表示女,3表示未知")
+    @DictFormat(DictTypeConstants.USER_SEX)
+    private Integer studentSex;
+
+    @Min(value = 1, message = "年龄必须大于0")
+    @Max(value = 150, message = "年龄不能超过150岁")
+    @Schema(description = "年龄")
+    private Integer studentAge;
+
+
+    @Schema(description = "身份证号")
+    @Length(min = 18, max = 18, message = "身份证号长度必须 18 位")
+    private String studentIdNumber;
+
+    @Schema(description = "家庭地址")
+    private String studentAddress;
+
+    @Schema(description = "类型")
+    private String studentType;
+}

+ 65 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/dataobject/aidingstudentsimportlist/AidingStudentsImportExcelListDO.java

@@ -0,0 +1,65 @@
+package cn.iocoder.yudao.module.as.dal.dataobject.aidingstudentsimportlist;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+@TableName("as_aiding_students_import_list")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class AidingStudentsImportExcelListDO extends BaseDO {
+    /**
+     * id
+     */
+    @TableId
+    private Long id;
+
+    /**
+     * 助学项目管理ID,外键
+     */
+    private Long asAidingStudentsManageId;
+
+    /**
+     * 学生姓名
+     */
+    private String studentName;
+
+    /**
+     * 学号
+     */
+    private String studentCode;
+
+    /**
+     * 学生性别
+     * 枚举类 男生为1,女生为2,未知为3
+     */
+    private Integer studentSex;
+
+    /**
+     * 学生年龄
+     */
+    private Integer studentAge;
+
+    /**
+     * 学生身份证号
+     */
+    private String studentIdNumber;
+
+    /**
+     * 学生住址
+     */
+    private String studentAddress;
+
+    /**
+     * 贫困类型,如:建档立卡
+     */
+    private String studentType;
+
+
+
+}

+ 24 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/mysql/aidingstudentsimportlist/AidingStudentsImportListMapper.java

@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.as.dal.mysql.aidingstudentsimportlist;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo.AidingStudentsImportListPageResqVO;
+import cn.iocoder.yudao.module.as.dal.dataobject.aidingstudentsimportlist.AidingStudentsImportExcelListDO;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface AidingStudentsImportListMapper extends BaseMapperX<AidingStudentsImportExcelListDO> {
+    default PageResult<AidingStudentsImportExcelListDO> selectPage(AidingStudentsImportListPageResqVO reqVO, Long asAidingStudentsManageId) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<AidingStudentsImportExcelListDO>()
+                .eqIfPresent(AidingStudentsImportExcelListDO::getAsAidingStudentsManageId, asAidingStudentsManageId)
+                .eqIfPresent(AidingStudentsImportExcelListDO::getStudentName, reqVO.getStudentName())
+                .eqIfPresent(AidingStudentsImportExcelListDO::getStudentSex, reqVO.getStudentSex())
+                .eqIfPresent(AidingStudentsImportExcelListDO::getStudentAge, reqVO.getStudentAge())
+                .eqIfPresent(AidingStudentsImportExcelListDO::getStudentCode, reqVO.getStudentCode())
+                .eqIfPresent(AidingStudentsImportExcelListDO::getStudentIdNumber, reqVO.getStudentIdNumber())
+                .likeIfPresent(AidingStudentsImportExcelListDO::getStudentAddress, reqVO.getStudentAddress())
+                .eqIfPresent(AidingStudentsImportExcelListDO::getStudentType, reqVO.getStudentType())
+                .orderByDesc(AidingStudentsImportExcelListDO::getId));
+    }
+}

+ 5 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/redis/RedisKeyConstants.java

@@ -0,0 +1,5 @@
+package cn.iocoder.yudao.module.as.dal.redis;
+
+public interface RedisKeyConstants {
+    String AIDING_STUDENTS_IMPORT_LIST_KEY = "aiding_students_import_list:%s";
+}

+ 111 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/redis/aidingstudentsimportlist/AidingStudentsImportListRedisDAO.java

@@ -0,0 +1,111 @@
+package cn.iocoder.yudao.module.as.dal.redis.aidingstudentsimportlist;
+
+import cn.hutool.core.date.LocalDateTimeUtil;
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
+import cn.iocoder.yudao.module.as.dal.dataobject.aidingstudentsimportlist.AidingStudentsImportExcelListDO;
+import org.springframework.data.redis.core.Cursor;
+import org.springframework.data.redis.core.RedisCallback;
+import org.springframework.data.redis.core.ScanOptions;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.nio.charset.StandardCharsets;
+import java.time.LocalDateTime;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+import static cn.iocoder.yudao.module.as.dal.redis.RedisKeyConstants.AIDING_STUDENTS_IMPORT_LIST_KEY;
+@Component
+public class AidingStudentsImportListRedisDAO {
+    @Resource
+    private StringRedisTemplate stringRedisTemplate;
+
+
+    public AidingStudentsImportExcelListDO get(String uniId) {
+        String redisKey = formatKey(uniId);
+        return JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(redisKey), AidingStudentsImportExcelListDO.class);
+    }
+
+
+
+
+
+    //找到redis中对应的内容
+    public List<AidingStudentsImportExcelListDO> getAllMatchingValues() {
+        // 定义匹配模式,%s会被实际的studentIdNumber替换,但这里我们直接使用%s作为通配符
+        String pattern = "aiding_students_import_list:*";
+
+        // 使用SCAN命令遍历匹配的键,ScanOptions.NONE表示使用默认配置
+        ScanOptions scanOptions = ScanOptions.scanOptions().match(pattern).build();
+
+        // 结果容器,用于收集所有匹配键对应的值
+        List<String> values = new ArrayList<>();
+        List<String> keys = new ArrayList<>();
+        List<AidingStudentsImportExcelListDO> result = new ArrayList<>();
+
+        // 执行 SCAN 命令并处理结果
+        stringRedisTemplate.execute((RedisCallback<Object>) connection -> {
+            Cursor<byte[]> cursor = connection.scan(scanOptions);
+            while (cursor.hasNext()) {
+                byte[] keyBytes = cursor.next();
+                String key = new String(keyBytes, StandardCharsets.UTF_8);
+                // 获取每个键对应的值
+                String value = stringRedisTemplate.opsForValue().get(key);
+                if (value != null) {
+                    values.add(value);
+                    keys.add(key);
+                }
+            }
+            cursor.close();
+            for (String value : values) {
+                result.add(JsonUtils.parseObject(value, AidingStudentsImportExcelListDO.class));
+            }
+            for (String key : keys){
+                stringRedisTemplate.delete(key);
+            }
+            return result;
+        });
+
+        return result;
+    }
+
+    public void set(AidingStudentsImportExcelListDO aidingStudentsImportExcelListDO) {
+        String redisKey = formatKey(aidingStudentsImportExcelListDO.getStudentIdNumber());
+        // 清理多余字段,避免缓存
+        aidingStudentsImportExcelListDO.setUpdater(null).setUpdateTime(null).setCreateTime(null).setCreator(null).setDeleted(null);
+
+        stringRedisTemplate.opsForValue().set(redisKey, JsonUtils.toJsonString(aidingStudentsImportExcelListDO), 60*60*24, TimeUnit.SECONDS);
+
+    }
+
+
+
+
+
+
+    public void delete(String uniId) {
+        String redisKey = formatKey(uniId);
+        stringRedisTemplate.delete(redisKey);
+    }
+
+
+    public void deleteList(Collection<String> uniIds) {
+        List<String> redisKeys = CollectionUtils.convertList(uniIds, AidingStudentsImportListRedisDAO::formatKey);
+        stringRedisTemplate.delete(redisKeys);
+    }
+
+
+
+
+
+
+    private static String formatKey(String uniId) {
+        return String.format(AIDING_STUDENTS_IMPORT_LIST_KEY, uniId);
+    }
+}

+ 58 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentsimportlist/AidingStudentsImportListService.java

@@ -0,0 +1,58 @@
+package cn.iocoder.yudao.module.as.service.aidingstudentsimportlist;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo.AidingStudentsImportExcelRespVO;
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo.AidingStudentsImportExcelVO;
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo.AidingStudentsImportListPageResqVO;
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo.AidingStudentsImportListSaveReqVO;
+import cn.iocoder.yudao.module.as.dal.dataobject.aidingstudentsimportlist.AidingStudentsImportExcelListDO;
+
+import javax.validation.Valid;
+import java.util.List;
+
+public interface AidingStudentsImportListService {
+    /**
+     * 创建贫困学生自治区名单管理
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createAidingStudentsImportList(@Valid AidingStudentsImportListSaveReqVO createReqVO, Long aidingStudentsManageId);
+
+
+    /**
+     * 更新贫困学生自治区名单管理
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateAidingStudentsImportList(@Valid AidingStudentsImportListSaveReqVO updateReqVO);
+
+    /**
+     * 删除贫困学生自治区名单
+     *
+     * @param id 编号
+     */
+    void deleteAidingStudentsImportList(Long id);
+
+    /**
+     * 获得贫困学生自治区名单
+     *
+     * @param id                     编号
+     * @return 贫困学生自治区名单
+     */
+    AidingStudentsImportExcelListDO getAidingStudentsImportList(Long id);
+
+    /**
+     * 获得贫困学生自治区名单分页
+     *
+     * @param //pageReqVO 分页查询
+     * @return 贫困学生自治区名单分页
+     */
+    PageResult<AidingStudentsImportExcelListDO> getAidingStudentsImportListPage(AidingStudentsImportListPageResqVO pageReqVO,Long asAidingStudentsManageId);
+
+    AidingStudentsImportExcelRespVO aidingStudentsImportExcelList(Long aidingStudentsManageId);
+
+
+    void
+    aidingStudentsImportExcelToRedis(List<AidingStudentsImportExcelVO> list);
+}

+ 194 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentsimportlist/AidingStudentsImportListServiceImpl.java

@@ -0,0 +1,194 @@
+package cn.iocoder.yudao.module.as.service.aidingstudentsimportlist;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.log.Log;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo.AidingStudentsImportExcelRespVO;
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo.AidingStudentsImportExcelVO;
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo.AidingStudentsImportListPageResqVO;
+import cn.iocoder.yudao.module.as.controller.admin.aidingstudentsimportlist.vo.AidingStudentsImportListSaveReqVO;
+import cn.iocoder.yudao.module.as.dal.dataobject.aidingstudentsimportlist.AidingStudentsImportExcelListDO;
+import cn.iocoder.yudao.module.as.dal.mysql.aidingstudentsimportlist.AidingStudentsImportListMapper;
+import cn.iocoder.yudao.module.as.dal.redis.aidingstudentsimportlist.AidingStudentsImportListRedisDAO;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import javax.validation.ValidationException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.as.enums.ErrorCodeConstants.*;
+
+@Service
+@Validated
+@Slf4j
+public class AidingStudentsImportListServiceImpl implements AidingStudentsImportListService {
+    @Resource
+    private AidingStudentsImportListMapper aidingStudentsImportListMapper;
+    @Resource
+    private AidingStudentsImportListRedisDAO aidingStudentsImportListRedisDAO;
+
+    @Override
+    public Long createAidingStudentsImportList(AidingStudentsImportListSaveReqVO createReqVO, Long aidingStudentsManageId) {
+        // 插入
+        AidingStudentsImportExcelListDO aidingStudentsImportListDO = BeanUtils.toBean(createReqVO, AidingStudentsImportExcelListDO.class);
+        aidingStudentsImportListDO.setAsAidingStudentsManageId(aidingStudentsManageId);
+        if (checkStudentIdNumberExists(aidingStudentsImportListDO.getStudentIdNumber(),aidingStudentsManageId)) {
+            throw exception(AIDING_STUDENTS_IMPORT_LIST_STUDENT_EXISTS);
+        }
+        aidingStudentsImportListMapper.insert(aidingStudentsImportListDO);
+        // 返回
+        return aidingStudentsImportListDO.getId();
+    }
+
+
+    @Override
+    public void updateAidingStudentsImportList(AidingStudentsImportListSaveReqVO updateReqVO) {
+        // 校验存在
+        validateAidingStudentsImportListExists(updateReqVO.getId());
+        // 更新
+        AidingStudentsImportExcelListDO updateObj = BeanUtils.toBean(updateReqVO, AidingStudentsImportExcelListDO.class);
+        aidingStudentsImportListMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteAidingStudentsImportList(Long id) {
+        // 校验存在
+        validateAidingStudentsImportListExists(id);
+        // 删除
+        aidingStudentsImportListMapper.deleteById(id);
+    }
+
+    private void validateAidingStudentsImportListExists(Long id) {
+        if (aidingStudentsImportListMapper.selectById(id) == null) {
+            throw exception(AIDING_STUDENTS_IMPORT_LIST_NOT_EXISTS);
+        }
+    }
+
+    //根据身份证号校验这次项目是否已经导入
+    private boolean checkStudentIdNumberExists(String studentIdNumber, Long asAidingStudentsManageId) {
+        return aidingStudentsImportListMapper.selectCount(
+                Wrappers.lambdaQuery(AidingStudentsImportExcelListDO.class)
+                                .eq(AidingStudentsImportExcelListDO::getStudentIdNumber, studentIdNumber)
+                                .eq(AidingStudentsImportExcelListDO::getAsAidingStudentsManageId, asAidingStudentsManageId)
+                ) > 0;
+
+
+    }
+
+    @Override
+    public AidingStudentsImportExcelListDO getAidingStudentsImportList(Long id) {
+        return aidingStudentsImportListMapper.selectById(id);
+    }
+
+
+    @Override
+    public PageResult<AidingStudentsImportExcelListDO> getAidingStudentsImportListPage(AidingStudentsImportListPageResqVO pageReqVO,Long asAidingStudentsManageId) {
+        return aidingStudentsImportListMapper.selectPage(pageReqVO,asAidingStudentsManageId);
+    }
+
+
+
+    //校验excel导入的内容
+    public String validateImportListForCreateOrUpdate(String studentName, String studentIdNumber, String studentCode, int studentAge, int studentSex) throws ValidationException {
+        String message = null;
+        // 验证学生姓名
+        if (studentName == null || studentName.isEmpty()) {
+            message="姓名不能为空";
+
+        }
+
+        // 验证学生学号
+        if (studentCode == null || studentCode.isEmpty()) {
+            message="学号不能为空";
+
+        }
+
+        // 验证学生性别
+        if (studentSex != 1 && studentSex != 2 && studentSex != 3) {
+            message="性别必须为 1(男)、2(女)或 3(未知)";
+
+        }
+
+        // 验证学生年龄
+        if (studentAge <= 0 || studentAge > 150) {
+            message="年龄必须大于0且不能超过150岁";
+
+        }
+
+        // 验证学生身份证号
+        if (studentIdNumber == null || studentIdNumber.length() != 18) {
+            message="身份证号长度必须为18位";
+
+        }
+        return message;
+
+    }
+
+
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
+    public AidingStudentsImportExcelRespVO aidingStudentsImportExcelList( Long asAidingStudentsManageId) {
+        List<AidingStudentsImportExcelListDO> list = aidingStudentsImportListRedisDAO.getAllMatchingValues();
+        if (CollUtil.isEmpty(list)) {
+            throw exception(AIDING_STUDENTS_IMPORT_LIST_IS_NULL);
+        }
+        AidingStudentsImportExcelRespVO respVO = AidingStudentsImportExcelRespVO.builder().createStudentNames(new ArrayList<>())
+                .failureStudentNames(new LinkedHashMap<>()).build();
+        List<AidingStudentsImportExcelListDO> aidingStudentsImportEecleListDOS = BeanUtils.toBean(list, AidingStudentsImportExcelListDO.class);
+        aidingStudentsImportEecleListDOS.forEach(aidingStudentsImportEecleListDO -> {
+
+            // 校验,判断是否有不符合的原因
+
+            String result = validateImportListForCreateOrUpdate(aidingStudentsImportEecleListDO.getStudentName(), aidingStudentsImportEecleListDO.getStudentIdNumber(),
+                    aidingStudentsImportEecleListDO.getStudentCode(), aidingStudentsImportEecleListDO.getStudentAge(), aidingStudentsImportEecleListDO.getStudentSex());
+            if (result != null){
+                respVO.getFailureStudentNames().put(aidingStudentsImportEecleListDO.getStudentName(), result);
+                return;
+            }
+            //赋值给外键
+            aidingStudentsImportEecleListDO.setAsAidingStudentsManageId(asAidingStudentsManageId);
+            if (checkStudentIdNumberExists(aidingStudentsImportEecleListDO.getStudentIdNumber(),asAidingStudentsManageId)) {
+                respVO.getFailureStudentNames().put(aidingStudentsImportEecleListDO.getStudentName(), "该学生已导入过一次");
+                return;
+            }
+            aidingStudentsImportEecleListDO.setAsAidingStudentsManageId(asAidingStudentsManageId);
+            aidingStudentsImportListMapper.insert(aidingStudentsImportEecleListDO);
+            respVO.getCreateStudentNames().add(aidingStudentsImportEecleListDO.getStudentName());
+        });
+        return respVO;
+    }
+
+
+    //导入到redis中
+    @Override
+    public void aidingStudentsImportExcelToRedis(List<AidingStudentsImportExcelVO> list) {
+        if (CollUtil.isEmpty(list)) {
+            throw exception(AIDING_STUDENTS_IMPORT_LIST_IS_NULL);
+        }
+        try {
+            List<AidingStudentsImportExcelListDO> aidingStudentsImportEecleListDOS = BeanUtils.toBean(list, AidingStudentsImportExcelListDO.class);
+            aidingStudentsImportEecleListDOS.forEach(aidingStudentsImportEecleListDO -> {
+                aidingStudentsImportListRedisDAO.set(aidingStudentsImportEecleListDO);
+            });
+        } catch (Exception e) {
+            log.error("导入redis失败", e);
+            throw new RuntimeException(e);
+
+        }
+
+    }
+}

+ 1 - 6
yudao-module-bpm/yudao-module-bpm-biz/pom.xml

@@ -80,11 +80,6 @@
             <groupId>org.flowable</groupId>
             <artifactId>flowable-spring-boot-starter-actuator</artifactId>
         </dependency>
-        <dependency>
-            <groupId>cn.iocoder.boot</groupId>
-            <artifactId>yudao-module-eve-api</artifactId>
-            <version>2.1.0-jdk8-snapshot</version>
-            <scope>compile</scope>
-        </dependency>
+
     </dependencies>
 </project>