Browse Source

添加测试完成度统计

zsf 1 year ago
parent
commit
64d48efe0a

+ 3 - 0
src/main/java/com/rf/psychological/plan/dao/repository/TestPlanUserRepository.java

@@ -96,4 +96,7 @@ public interface TestPlanUserRepository extends BaseRepository<TestPlanUserEntit
 
     @Query(value="select count(1)  from t_test_plan_user pu LEFT JOIN t_user_info u ON pu.u_id = u.id where pu.test_plan_id = :planId and u.institution_no =:institutionNo and u.structure_no like :structureNo",nativeQuery = true)
     int countByTestPlanIdAndStructureNo(@Param("planId")String planId, @Param("structureNo")String structureNo, @Param("institutionNo")String institutionNo);
+
+    @Query(value="select count(1)  from t_test_plan_user pu LEFT JOIN t_user_info u ON pu.u_id = u.id where pu.test_plan_id = :planId and is_complete=:isComplete and u.institution_no =:institutionNo and u.structure_no like :structureNo",nativeQuery = true)
+    int countByCompletionStatus(@Param("planId")String planId, @Param("structureNo")String structureNo, @Param("institutionNo")String institutionNo, @Param("isComplete")String isComplete);
 }

+ 2 - 0
src/main/java/com/rf/psychological/plan/service/TestPlanUserService.java

@@ -28,6 +28,8 @@ public interface TestPlanUserService {
 
     int countByTestPlanIdAndStructureNo(String planId,String structureNo,String institutionNo);
 
+    int countByCompletionStatus(String planId,String structureNo,String institutionNo,String isComplete);
+
     List<TestPlanUserEntity> findTestPlanByUId(String uId, int beginNum, int pageSize, String status);
 
     void deleteAllByTestPlanId(String testPlanId);

+ 5 - 0
src/main/java/com/rf/psychological/plan/service/impl/TestPlanUserServiceImpl.java

@@ -55,6 +55,11 @@ public class TestPlanUserServiceImpl implements TestPlanUserService {
         return testPlanUserRepository.countByTestPlanIdAndStructureNo(planId,structureNo,institutionNo);
     }
 
+    @Override
+    public int countByCompletionStatus(String planId, String structureNo, String institutionNo, String isComplete) {
+        return testPlanUserRepository.countByCompletionStatus( planId,  structureNo,  institutionNo,  isComplete);
+    }
+
 
     @Override
     public Page<TestPlanUserEntity> findTestPlanUserByTestId(String testId, String searchKey, int beginNum, int pageSize) {

+ 23 - 3
src/main/java/com/rf/psychological/rest/ReportAnalysisController.java

@@ -1,14 +1,11 @@
 package com.rf.psychological.rest;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.rf.psychological.base.rest.BaseController;
 import com.rf.psychological.plan.dao.model.HisTestPlanEntry;
 import com.rf.psychological.plan.dao.model.TestPlanContendEntity;
-import com.rf.psychological.plan.dao.model.TestPlanEntity;
 import com.rf.psychological.plan.service.HisTestPlanService;
 import com.rf.psychological.plan.service.TestPlanContendService;
-import com.rf.psychological.plan.service.TestPlanService;
 import com.rf.psychological.plan.service.TestPlanUserService;
 import com.rf.psychological.scale.dao.model.ScaleMarksEntity;
 import com.rf.psychological.scale.service.ScaleMarksService;
@@ -185,4 +182,27 @@ public class ReportAnalysisController extends BaseController {
             return fail();
         }
     }
+
+    @GetMapping("/completionStatus")
+    @ApiOperation(value = "计划完成占比数据")
+    @SafetyProcess
+    public Result completionStatus(@Param(value = "planId") String planId,@Param(value = "structureNo") String structureNo){
+        try {
+            HisTestPlanEntry plan = hisTestPlanService.findById(planId);
+            if (plan== null){
+                return fail("计划不存在请确认,请联系管理员");
+            }
+            //首先获取到计划下参与总人数
+            if (StringUtils.isEmpty(structureNo)){
+                structureNo = "%";
+            }
+            Map map = new HashMap();
+            map.put("0",planUserService.countByCompletionStatus(planId,structureNo,plan.getInstitutionNo(),"0"));
+            map.put("1",planUserService.countByCompletionStatus(planId,structureNo,plan.getInstitutionNo(),"9"));
+            return success(map);
+        }catch (Exception e){
+            log.error(e.getMessage());
+            return fail();
+        }
+    }
 }