Browse Source

获取各个状态数

houlai 6 months ago
parent
commit
099f1c174d

+ 10 - 1
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentscollegemanage/AidingStudentsCollegeManageController.java

@@ -65,12 +65,21 @@ public class AidingStudentsCollegeManageController {
     @GetMapping("/get")
     @Operation(summary = "获得家庭困难认定项目学院管理")
     @Parameter(name = "id", description = "编号", required = true, example = "1024")
-    @PreAuthorize("@ss.hasPermission('as:aiding-students-college-manage:query')")
+    @PreAuthorize("@ss.hasPermission('as:aiding-students-college-manage:get')")
     public CommonResult<AidingStudentsCollegeManageRespVO> getAidingStudentsCollegeManage(@RequestParam("id") Long id) {
         AidingStudentsCollegeManageDO aidingStudentsCollegeManage = aidingStudentsCollegeManageService.getAidingStudentsCollegeManage(id);
         return success(BeanUtils.toBean(aidingStudentsCollegeManage, AidingStudentsCollegeManageRespVO.class));
     }
 
+    @GetMapping("/getCount")
+    @Operation(summary = "获得家庭困难认定项目学院管理各个状态人数")
+    @PreAuthorize("@ss.hasPermission('as:aiding-students-college-manage:get-count')")
+    public CommonResult<Map<String, Long>> getAidingStudentsCollegeManageCount() {
+        Map<String, Long> map = aidingStudentsCollegeManageService.getAidingStudentsCollegeManageCount();
+        return success(map);
+    }
+
+
     @GetMapping("/page")
     @Operation(summary = "获得家庭困难认定项目学院管理分页")
     @PreAuthorize("@ss.hasPermission('as:aiding-students-college-manage:query')")

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

@@ -52,4 +52,5 @@ public interface AidingStudentsCollegeManageService {
      */
     PageResult<AidingStudentsCollegeManageDO> getAidingStudentsCollegeManagePage(AidingStudentsCollegeManagePageReqVO pageReqVO);
 
+    Map<String, Long> getAidingStudentsCollegeManageCount();
 }

+ 32 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentscollegemanage/AidingStudentsCollegeManageServiceImpl.java

@@ -1,5 +1,7 @@
 package cn.iocoder.yudao.module.as.service.aidingstudentscollegemanage;
 
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import org.springframework.validation.annotation.Validated;
@@ -15,6 +17,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.module.as.dal.mysql.aidingstudentscollegemanage.AidingStudentsCollegeManageMapper;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
 import static cn.iocoder.yudao.module.as.enums.ErrorCodeConstants.*;
 
 /**
@@ -28,9 +31,18 @@ public class AidingStudentsCollegeManageServiceImpl implements AidingStudentsCol
 
     @Resource
     private AidingStudentsCollegeManageMapper aidingStudentsCollegeManageMapper;
+    @Resource
+    private AdminUserApi adminUserApi;
+    @Resource
+    private DeptApi deptApi;
 
     @Override
     public Long createAidingStudentsCollegeManage(AidingStudentsCollegeManageSaveReqVO createReqVO) {
+        // 获得学院id
+        Long deptId = adminUserApi.getUser(getLoginUserId()).getDeptId();
+        Long collegeId =  deptApi.getCollegeId(deptId);
+        createReqVO.setCollegeId(collegeId);
+
         // 插入
         AidingStudentsCollegeManageDO aidingStudentsCollegeManage = BeanUtils.toBean(createReqVO, AidingStudentsCollegeManageDO.class);
         aidingStudentsCollegeManageMapper.insert(aidingStudentsCollegeManage);
@@ -71,4 +83,24 @@ public class AidingStudentsCollegeManageServiceImpl implements AidingStudentsCol
         return aidingStudentsCollegeManageMapper.selectPage(pageReqVO);
     }
 
+    @Override
+
+    public Map<String, Long> getAidingStudentsCollegeManageCount() {
+        Map<String, Long> map = new LinkedHashMap<>();
+        //总人数
+        map.put("sum", aidingStudentsCollegeManageMapper.selectCount());
+        //未发布
+        map.put("unpublished", aidingStudentsCollegeManageMapper.selectCount(AidingStudentsCollegeManageDO::getComStatus, 0));
+        //审核中
+        //map.put("review", aidingStudentsCollegeManageMapper.selectCount(AidingStudentsCollegeManageDO::getComStatus, 1));
+        //公示中
+        //map.put("publicity", aidingStudentsCollegeManageMapper.selectCount(AidingStudentsCollegeManageDO::getComStatus, 2));
+        //进行中
+        map.put("ongoing", aidingStudentsCollegeManageMapper.selectCount(AidingStudentsCollegeManageDO::getComStatus, 1)
+                +aidingStudentsCollegeManageMapper.selectCount(AidingStudentsCollegeManageDO::getComStatus, 2));
+        //已完成
+        map.put("completed", aidingStudentsCollegeManageMapper.selectCount(AidingStudentsCollegeManageDO::getComStatus, 3));
+        return map;
+    }
+
 }

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

@@ -11,6 +11,8 @@ import cn.iocoder.yudao.module.as.dal.dataobject.aidingstudentsimportlist.Aiding
 import cn.iocoder.yudao.module.as.dal.mysql.aidingstudentsimportlist.AidingStudentsImportListMapper;
 import cn.iocoder.yudao.module.as.dal.redis.aidingstudentsimportlist.AidingStudentsImportListRedisDAO;
 
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
 import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
@@ -42,9 +44,8 @@ public class AidingStudentsImportListServiceImpl implements AidingStudentsImport
     private AidingStudentsImportListRedisDAO aidingStudentsImportListRedisDAO;
     @Resource
     private AdminUserMapper userMapper;
-
     @Resource
-    private DeptMapper deptMapper;
+    private DeptApi deptApi;
 
     @Override
     public Long createAidingStudentsImportList(AidingStudentsImportListSaveReqVO createReqVO, Long aidingStudentsManageId) {
@@ -267,14 +268,17 @@ public class AidingStudentsImportListServiceImpl implements AidingStudentsImport
         if (adminUserDO == null){
             throw exception(AIDING_STUDENTS_IMPORT_LIST_STUDENT_CODE_NOT_EXISTS);
         }
+
+        return deptApi.getCollegeId(adminUserDO.getDeptId());
+
         //循环查询父级部门
-        DeptDO deptDO = new DeptDO();
+        /*DeptDO deptDO = new DeptDO();
         Long parentId = deptMapper.selectById(adminUserDO.getDeptId()).getParentId();
         while (parentId != 0) {
              deptDO = deptMapper.selectById(parentId);
             parentId= deptDO.getParentId();
         }
-        return deptDO.getId();
+        return deptDO.getId();*/
     }