Explorar o código

添加导入名单文件字段

houlai hai 6 meses
pai
achega
931f00c3e0
Modificáronse 11 ficheiros con 148 adicións e 10 borrados
  1. 11 1
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/AidingStudentsImportListController.java
  2. 8 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsmanage/AidingStudentsManageController.java
  3. 6 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsmanage/vo/AidingStudentsManagePageReqVO.java
  4. 8 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsmanage/vo/AidingStudentsManageRespVO.java
  5. 6 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsmanage/vo/AidingStudentsManageSaveReqVO.java
  6. 8 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/dataobject/aidingstudentsmanage/AidingStudentsManageDO.java
  7. 1 1
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/redis/RedisKeyConstants.java
  8. 17 6
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/redis/aidingstudentsimportlist/AidingStudentsImportListRedisDAO.java
  9. 62 1
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentsimportlist/AidingStudentsImportListServiceImpl.java
  10. 1 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentsmanage/AidingStudentsManageService.java
  11. 20 1
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentsmanage/AidingStudentsManageServiceImpl.java

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

@@ -93,15 +93,25 @@ public class AidingStudentsImportListController {
     }
 
 
-    @PostMapping("/import-excel-to-redis")
+   /* @PostMapping("/import-excel-to-redis")
     @Operation(summary = "导入家庭情况困难认定学生 Excel到redis中")
     @PreAuthorize("@ss.hasPermission('as:aiding-students-import-list:importtoredis')")
     public CommonResult<String> importExcelToRedis(@RequestParam("file") MultipartFile file) throws Exception {
         List<AidingStudentsImportExcelVO> list = ExcelUtils.read(file, AidingStudentsImportExcelVO.class);
         String redisUUID = aidingStudentsImportListService.aidingStudentsImportExcelToRedis(list);
         return success(redisUUID);
+    }*/
+
+    @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);
     }
 
+
     @PostMapping("/reimport-excel")
     @Operation(summary = "重复导入家庭情况困难认定excel")
     @Parameters({

+ 8 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsmanage/AidingStudentsManageController.java

@@ -92,4 +92,12 @@ public class AidingStudentsManageController {
                         BeanUtils.toBean(list, AidingStudentsManageRespVO.class));
     }
 
+    @PutMapping("/publish")
+    @Operation(summary = "更新家庭困难认定项目管理状态")
+    @PreAuthorize("@ss.hasPermission('as:aiding-students-manage:update')")
+    public CommonResult<Boolean> updateAidingStudentsManageStatus(@RequestParam("id") Long id) {
+        aidingStudentsManageService.updateAidingStudentsManageStatus(id);
+        return success(true);
+    }
+
 }

+ 6 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsmanage/vo/AidingStudentsManagePageReqVO.java

@@ -38,4 +38,10 @@ public class AidingStudentsManagePageReqVO extends PageParam {
     @Schema(description = "家庭经济困难学生认定项目评审规则文件名称", example = "芋艿")
     private String diNoticeFileName;
 
+    @Schema(description = "自治区导入名单")
+    private String diImportListFile;
+
+    @Schema(description = "自治区导入名单名称")
+    private String diImportListFileName;
+
 }

+ 8 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsmanage/vo/AidingStudentsManageRespVO.java

@@ -45,4 +45,12 @@ public class AidingStudentsManageRespVO {
     @ExcelProperty("家庭经济困难学生认定项目评审规则文件名称")
     private String diNoticeFileName;
 
+    @Schema(description = "自治区导入名单文件")
+    @ExcelProperty("自治区导入名单文件")
+    private String diImportListFile;
+
+    @Schema(description = "自治区导入名单文件名称")
+    @ExcelProperty("自治区导入名单文件名称")
+    private String diImportListFileName;
+
 }

+ 6 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsmanage/vo/AidingStudentsManageSaveReqVO.java

@@ -32,4 +32,10 @@ public class AidingStudentsManageSaveReqVO {
     @Schema(description = "家庭经济困难学生认定项目评审规则文件名称", example = "芋艿")
     private String diNoticeFileName;
 
+    @Schema(description = "自治区导入名单")
+    private String diImportListFile;
+
+    @Schema(description = "自治区导入名单名称")
+    private String diImportListFileName;
+
 }

+ 8 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/dataobject/aidingstudentsmanage/AidingStudentsManageDO.java

@@ -52,5 +52,13 @@ public class AidingStudentsManageDO extends BaseDO {
      * 家庭经济困难学生认定项目评审规则文件名称
      */
     private String diNoticeFileName;
+    /**
+     * 自治区导入名单文件
+     */
+    private String diImportListFile;
+    /**
+     * 自治区导入名单文件名称
+     */
+    private String diImportListFileName;
 
 }

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

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

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

@@ -28,7 +28,7 @@ public class AidingStudentsImportListRedisDAO {
 
 
     public AidingStudentsImportExcelListDO get(String uniId,String studentCode) {
-        String redisKey = formatKey(uniId,studentCode);
+        String redisKey = formatKey(studentCode);
         return JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(redisKey), AidingStudentsImportExcelListDO.class);
     }
 
@@ -75,22 +75,30 @@ public class AidingStudentsImportListRedisDAO {
         return result;
     }
 
-    public void setWithredisUUID(String redisUUID,AidingStudentsImportExcelListDO aidingStudentsImportExcelListDO) {
+/*    public void setWithredisUUID(String redisUUID,AidingStudentsImportExcelListDO aidingStudentsImportExcelListDO) {
         String redisKey = formatKey(redisUUID,aidingStudentsImportExcelListDO.getStudentCode());
         // 清理多余字段,避免缓存
         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 setWithredisUUID(AidingStudentsImportExcelListDO aidingStudentsImportExcelListDO) {
+    String redisKey = formatKey(aidingStudentsImportExcelListDO.getStudentCode());
+    // 清理多余字段,避免缓存
+    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 studentCode) {
-        String redisKey = formatKey(uniId,studentCode);
+    public void delete(String studentCode) {
+        String redisKey = formatKey(studentCode);
         stringRedisTemplate.delete(redisKey);
     }
 
@@ -105,7 +113,10 @@ public class AidingStudentsImportListRedisDAO {
 
 
 
-    private static String formatKey(String uniId,String studentCode) {
+    /*private static String formatKey(String uniId,String studentCode) {
         return String.format(AIDING_STUDENTS_IMPORT_LIST_KEY, uniId,studentCode);
+    }*/
+    private static String formatKey(String studentCode) {
+        return String.format(AIDING_STUDENTS_IMPORT_LIST_KEY, studentCode);
     }
 }

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

@@ -189,8 +189,48 @@ public class AidingStudentsImportListServiceImpl implements AidingStudentsImport
     }
 
 
+
+    //根据项目id和list导入数据库
+    @Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
+    public AidingStudentsImportExcelRespVO aidingStudentsImportExcelListFromCloud( Long asAidingStudentsManageId,List<AidingStudentsImportExcelListDO> list) {
+        // 校验是否为空
+        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);
+            aidingStudentsImportEecleListDO.setCollegeId(getCollegeIdByStudentCode(aidingStudentsImportEecleListDO.getStudentCode()));
+
+            //判断此次项目数据库是否已经存在
+            if (checkStudentCodeExists(aidingStudentsImportEecleListDO.getStudentCode(),asAidingStudentsManageId)) {
+                respVO.getFailureStudentNames().put(aidingStudentsImportEecleListDO.getStudentName(), "该学生已导入过一次");
+                return;
+            }
+            //插入数据库
+            aidingStudentsImportListMapper.insert(aidingStudentsImportEecleListDO);
+            respVO.getCreateStudentNames().add(aidingStudentsImportEecleListDO.getStudentName());
+        });
+        return respVO;
+    }
+
+
     //导入到redis中
-    @Override
+/*    @Override
     public String aidingStudentsImportExcelToRedis(List<AidingStudentsImportExcelVO> list) {
         if (CollUtil.isEmpty(list)) {
             throw exception(AIDING_STUDENTS_IMPORT_LIST_IS_NULL);
@@ -205,6 +245,27 @@ public class AidingStudentsImportListServiceImpl implements AidingStudentsImport
             log.error("导入redis失败", e);
             throw new RuntimeException(e);
 
+        }
+        return redisUUID;
+    }*/
+
+
+
+    @Override
+    public String aidingStudentsImportExcelToRedis(List<AidingStudentsImportExcelVO> list) {
+        if (CollUtil.isEmpty(list)) {
+            throw exception(AIDING_STUDENTS_IMPORT_LIST_IS_NULL);
+        }
+        String redisUUID = String.valueOf(UUID.randomUUID());
+        try {
+            List<AidingStudentsImportExcelListDO> aidingStudentsImportEecleListDOS = BeanUtils.toBean(list, AidingStudentsImportExcelListDO.class);
+            aidingStudentsImportEecleListDOS.forEach(aidingStudentsImportEecleListDO -> {
+                aidingStudentsImportListRedisDAO.setWithredisUUID(aidingStudentsImportEecleListDO);
+            });
+        } catch (Exception e) {
+            log.error("导入redis失败", e);
+            throw new RuntimeException(e);
+
         }
         return redisUUID;
     }

+ 1 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentsmanage/AidingStudentsManageService.java

@@ -52,4 +52,5 @@ public interface AidingStudentsManageService {
      */
     PageResult<AidingStudentsManageDO> getAidingStudentsManagePage(AidingStudentsManagePageReqVO pageReqVO);
 
+    void updateAidingStudentsManageStatus(Long id);
 }

+ 20 - 1
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentsmanage/AidingStudentsManageServiceImpl.java

@@ -1,5 +1,7 @@
 package cn.iocoder.yudao.module.as.service.aidingstudentsmanage;
 
+import cn.iocoder.yudao.module.as.service.aidingstudentsimportlist.AidingStudentsImportListService;
+import cn.iocoder.yudao.module.as.service.aidingstudentsimportlist.AidingStudentsImportListServiceImpl;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import org.springframework.validation.annotation.Validated;
@@ -28,6 +30,8 @@ public class AidingStudentsManageServiceImpl implements AidingStudentsManageServ
 
     @Resource
     private AidingStudentsManageMapper aidingStudentsManageMapper;
+    @Resource
+    private AidingStudentsImportListServiceImpl aidingStudentsImportListService;
 
     @Override
     public Long createAidingStudentsManage(AidingStudentsManageSaveReqVO createReqVO) {
@@ -35,7 +39,14 @@ public class AidingStudentsManageServiceImpl implements AidingStudentsManageServ
         AidingStudentsManageDO aidingStudentsManage = BeanUtils.toBean(createReqVO, AidingStudentsManageDO.class);
         aidingStudentsManageMapper.insert(aidingStudentsManage);
         //改变状态
-        aidingStudentsManage.setDiStatus(1);
+        aidingStudentsManage.setDiStatus(0);
+
+        //解析excel
+
+        //导入名单
+        //aidingStudentsImportListService.aidingStudentsImportExcelListFromCloud(aidingStudentsManage.getId(),)
+
+
         // 返回
         return aidingStudentsManage.getId();
     }
@@ -74,4 +85,12 @@ public class AidingStudentsManageServiceImpl implements AidingStudentsManageServ
         return aidingStudentsManageMapper.selectPage(pageReqVO);
     }
 
+    @Override
+    public void updateAidingStudentsManageStatus(Long id) {
+        AidingStudentsManageDO aidingStudentsManageDO = new AidingStudentsManageDO();
+        aidingStudentsManageDO.setDiStatus(1);
+        aidingStudentsManageDO.setId(id);
+        aidingStudentsManageMapper.updateById(aidingStudentsManageDO);
+    }
+
 }