Browse Source

用户记录调整

zsf 1 year ago
parent
commit
3e0350e66b

+ 1 - 27
src/main/java/com/rf/psychological/dao/repository/CategoryRepository.java

@@ -32,26 +32,6 @@ public interface CategoryRepository extends BaseRepository<CategoryEntity, Strin
     @Query(value = "select count(1) from t_category_info   ", nativeQuery = true)
     int allNum();
 
-    /**
-     * 根据名称模糊查询  分页
-     *
-     * @param pageNum
-     * @param pageSize
-     * @param searchStr
-     * @return
-     */
-    @Query(value = "select id,ename,name,sequence,type from t_category_info where name like %:searchStr% or ename like %:searchStr% order by sequence limit :pageNum ,:pageSize ", nativeQuery = true)
-    List<CategoryEntity> getSubjectListByName(@Param("pageNum") int pageNum, @Param("pageSize") int pageSize, @Param("searchStr") String searchStr);
-
-    /**
-     * 根据名称模糊查询总条数
-     *
-     * @param searchStr
-     * @return
-     */
-    @Query(value = "select count(1) from t_category_info where name like %:searchStr% or ename like %:searchStr%   ", nativeQuery = true)
-    int allNumByName(@Param("searchStr") String searchStr);
-
     /**
      * 效验是否存在
      *
@@ -63,13 +43,7 @@ public interface CategoryRepository extends BaseRepository<CategoryEntity, Strin
     @Query(value = "select id,ename,name,sequence,type from t_category_info where name = :name or ename = :ename or sequence = :sequence", nativeQuery = true)
     List<CategoryEntity> getCategoryByName(@Param("name") String name, @Param("ename") String ename, @Param("sequence") String sequence);
 
-    /**
-     * 查询所有类别信息
-     *
-     * @return
-     */
-    @Query(value = "select id,ename,name,sequence,type from t_category_info where type = :type and ename in (SELECT a.ename FROM t_category_subject a GROUP BY a.ename) order by sequence", nativeQuery = true)
-    List<CategoryEntity> findAllOrder(@Param("type") String type);
+
 
 
     /**

+ 0 - 17
src/main/java/com/rf/psychological/rest/ServerController.java

@@ -51,7 +51,6 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import java.io.*;
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
@@ -693,22 +692,6 @@ public class ServerController extends BaseController {
     }
 
 
-
-    /**
-     * 用户查询枪林弹雨
-     *
-     * @return
-     */
-    @SafetyProcess
-    @GetMapping("GUNSBULLETS/{userId}")
-    @ApiOperation(value = "用户查询枪林弹雨记录")
-    public Result GUNSBULLETS(@PathVariable String userId) {
-        UserEntity one = this.userService.getOne(userId);
-        List<UserRecordEntity> gunsbullets = this.userRecordService.getGUNSBULLETS(one.getPhone(), one.getInstitutionNo());
-        return success(gunsbullets);
-    }
-
-
     /**
      * 根据id查询测试详细信息
      *

+ 5 - 12
src/main/java/com/rf/psychological/scale/dao/repository/UserRecordRepository.java

@@ -59,7 +59,7 @@ public interface UserRecordRepository extends BaseRepository<UserRecordEntity, S
      * @param type
      * @return
      */
-    @Query(value = "select a.id,a.flag,b.pet_name as phone,a.test_date,a.file_name,a.test_result,a.type,a.name,a.img,a.test_record,a.test_results,b.institution_no,a.test_plan_id from t_user_record a INNER JOIN t_user_info b ON a.phone = b.phone  and b.role_type='1' and  a.institution_no=b.institution_no where a.phone = :phone and " +
+    @Query(value = "select a.id,a.flag,b.pet_name as phone,a.test_date,a.file_name,a.test_result,a.type,a.name,a.img,a.test_record,a.test_results,b.institution_no,a.test_plan_id ,a.conclusion from t_user_record a INNER JOIN t_user_info b ON a.phone = b.phone  and b.role_type='1' and  a.institution_no=b.institution_no where a.phone = :phone and " +
             "b.institution_no= :institutionNo and if(:beginTime is not null and :beginTime!='',a.test_date>:beginTime ,1=1)  and if(:endTime is not null and :endTime!='', a.test_date<:endTime ,1=1) and type= :type order by test_date desc limit :pageNum ,:pageSize ", nativeQuery = true)
     List<UserRecordEntity> getListByPhoneAndType(@Param("pageNum") int pageNum, @Param("pageSize") int pageSize, @Param("phone") String phone, @Param("institutionNo") String institutionNo, @Param("type") String type, @Param("beginTime") String beginTime, @Param("endTime") String
             endTime);
@@ -88,7 +88,7 @@ public interface UserRecordRepository extends BaseRepository<UserRecordEntity, S
      *
      * @return
      */
-    @Query(value = "select id,flag,phone,test_date,file_name,test_result,type,name,img,test_record,test_results,institution_no,test_plan_id from t_user_record where id = :id ", nativeQuery = true)
+    @Query(value = "select id,flag,phone,test_date,file_name,test_result,type,name,img,test_record,test_results,institution_no,test_plan_id,conclusion from t_user_record where id = :id ", nativeQuery = true)
     UserRecordEntity getUserRecordById(@Param("id") String id);
 
     /**
@@ -96,16 +96,10 @@ public interface UserRecordRepository extends BaseRepository<UserRecordEntity, S
      *
      * @return
      */
-    @Query(value = "select id,flag,phone,test_date,file_name,test_result,type,name,img,test_record,test_results,institution_no,test_plan_id from t_user_record where phone = :phone and flag = 'RHYTHM' and institution_no=:institutionNo ORDER BY test_date DESC LIMIT 1", nativeQuery = true)
+    @Query(value = "select id,flag,phone,test_date,file_name,test_result,type,name,img,test_record,test_results,institution_no,test_plan_id,conclusion from t_user_record where phone = :phone and flag = 'RHYTHM' and institution_no=:institutionNo ORDER BY test_date DESC LIMIT 1", nativeQuery = true)
     UserRecordEntity getRHYTHM(@Param("phone") String phone, @Param("institutionNo") String institutionNo);
 
-    /**
-     * 用户查询枪林弹雨
-     *
-     * @return
-     */
-    @Query(value = "select id,flag,phone,test_date,file_name,test_result,type,name,img,test_record,test_results,institution_no,test_plan_id from t_user_record where phone = :phone and flag = 'GUNSBULLETS' and institution_no=:institutionNo ORDER BY test_date DESC LIMIT 1", nativeQuery = true)
-    List<UserRecordEntity> getGUNSBULLETS(@Param("phone") String phone, @Param("institutionNo") String institutionNo);
+
 
     /**
      * 查询机构下所有用户已经做的测试记录
@@ -219,8 +213,7 @@ public interface UserRecordRepository extends BaseRepository<UserRecordEntity, S
     @Query(value = "SELECT * FROM t_user_record WHERE test_plan_id = :testPlanId", nativeQuery = true)
     List<UserRecordEntity> getUserRecordByPlanId(@Param("testPlanId") String testPlanId);
 
-    @Query(value = "select id,flag,phone,test_date,file_name,test_result,type,name,img,test_record,test_results,institution_no,test_plan_id from t_user_record where phone = :phone and flag = :flag", nativeQuery = true)
-    List<UserRecordEntity> getuserRecordByPhone(@Param("phone") String phone,@Param("flag") String flag);
+
 
     @Query(value = "select tui.id             userId,\n" +
             "       gender,\n" +

+ 32 - 0
src/main/java/com/rf/psychological/scale/rest/UserRecordController.java

@@ -0,0 +1,32 @@
+package com.rf.psychological.scale.rest;
+
+import com.rf.psychological.base.rest.BaseController;
+import com.rf.psychological.utils.Result;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Description:用户测试记录
+ * @Author: mimang
+ * @Date: 2024/1/25
+ */
+@Slf4j
+@RestController
+@RequestMapping("/user/record")
+@Api(tags = "用户测试记录")
+public class UserRecordController extends BaseController {
+
+    
+
+    public Result getPlanUserRecord(String planId){
+        try {
+
+            return success();
+        }catch (Exception e){
+            log.error(e.getMessage());
+            return fail();
+        }
+    }
+}

+ 0 - 24
src/main/java/com/rf/psychological/scale/service/CategoryService.java

@@ -19,30 +19,6 @@ public interface CategoryService {
      */
     void save(CategoryEntity categoryEntity);
 
-    /**
-     * 获取量表类别列表
-     * @return
-     */
-    //List<CategoryEntity> findAll(int pageNum, int pageSize);
-
-    /**
-     * 总条数
-     * @return
-     */
-    //int allNum();
-
-    /**
-     * 根据名称模糊查询列表
-     * @return
-     */
-    //List<CategoryEntity> getSubjectListByName(int pageNum, int pageSize, String searchStr);
-
-    /**
-     * 根据名称模糊查询总条数
-     * @return
-     */
-    //int allNumByName(String searchStr);
-
     /**
      * 效验是否存在
      *

+ 0 - 10
src/main/java/com/rf/psychological/scale/service/UserRecordService.java

@@ -2,7 +2,6 @@ package com.rf.psychological.scale.service;
 
 import com.alibaba.fastjson.JSONObject;
 import com.rf.psychological.dao.dto.InstitutionRecordingDTO;
-import com.rf.psychological.dao.dto.InstitutionRecordingUserDTO;
 import com.rf.psychological.dao.dto.InstitutionRecordingUsersDTO;
 import com.rf.psychological.dao.dto.UserRecordsDto;
 import com.rf.psychological.scale.dao.model.UserRecordEntity;
@@ -91,14 +90,6 @@ public interface UserRecordService {
      */
     UserRecordEntity getRHYTHM(String phone, String institutionNo);
 
-    /**
-     * 查询枪林弹雨
-     *
-     * @param phone
-     * @return
-     */
-    List<UserRecordEntity> getGUNSBULLETS(String phone, String institutionNo);
-
     /**
      * 查询机构下所有用户已经做的测试记录
      *
@@ -163,7 +154,6 @@ public interface UserRecordService {
      */
     List<UserRecordEntity> getUserRecordByPlanId(String testPlanId);
 
-    List<UserRecordEntity> getuserRecordByPhone(String phone,String flag);
 
     InstitutionRecordingUsersDTO getRecordingUsersDTOById(String id);
 }

+ 1 - 38
src/main/java/com/rf/psychological/scale/service/impl/CategoryServiceImpl.java

@@ -1,8 +1,8 @@
 package com.rf.psychological.scale.service.impl;
 
 
-import com.rf.psychological.scale.dao.model.CategoryEntity;
 import com.rf.psychological.dao.repository.CategoryRepository;
+import com.rf.psychological.scale.dao.model.CategoryEntity;
 import com.rf.psychological.scale.service.CategoryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -31,43 +31,6 @@ public class CategoryServiceImpl implements CategoryService {
         this.categoryRepository.save(categoryEntity);
     }
 
-    /**
-     * 获取量表类别列表
-     * @return
-     *//*
-    @Override
-    public List<CategoryEntity> findAll(int pageNum, int pageSize) {
-        int beginIndex = (pageNum-1)*pageSize;
-        return this.categoryRepository.findAll( beginIndex,  pageSize);
-    }
-
-    *//**
-     * 总条数
-     * @return
-     *//*
-    @Override
-    public int allNum() {
-        return this.categoryRepository.allNum();
-    }
-
-    *//**
-     * 根据名称模糊查询列表
-     * @return
-     *//*
-    @Override
-    public List<CategoryEntity> getSubjectListByName(int pageNum, int pageSize, String searchStr) {
-        int beginIndex = (pageNum-1)*pageSize;
-        return this.categoryRepository.getSubjectListByName( beginIndex,  pageSize, searchStr);
-    }
-
-    *//**
-     * 根据名称模糊查询总条数
-     * @return
-     *//*
-    @Override
-    public int allNumByName(String searchStr) {
-        return this.categoryRepository.allNumByName(searchStr);
-    }*/
 
     /**
      * 效验是否存在

+ 5 - 12
src/main/java/com/rf/psychological/scale/service/impl/UserRecordServiceImpl.java

@@ -7,7 +7,6 @@ import com.querydsl.core.types.Projections;
 import com.querydsl.core.types.dsl.Wildcard;
 import com.querydsl.jpa.impl.JPAQueryFactory;
 import com.rf.psychological.dao.dto.InstitutionRecordingDTO;
-import com.rf.psychological.dao.dto.InstitutionRecordingUserDTO;
 import com.rf.psychological.dao.dto.InstitutionRecordingUsersDTO;
 import com.rf.psychological.dao.dto.UserRecordsDto;
 import com.rf.psychological.dao.model.CognitiveTaskEntity;
@@ -24,14 +23,15 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.*;
-import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
-import javax.persistence.criteria.Predicate;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -229,10 +229,7 @@ public class UserRecordServiceImpl implements UserRecordService {
         return this.userRecordRepository.getRHYTHM(phone, institutionNo);
     }
 
-    @Override
-    public List<UserRecordEntity> getGUNSBULLETS(String phone, String institutionNo) {
-        return this.userRecordRepository.getGUNSBULLETS(phone, institutionNo);
-    }
+
 
     @Override
     public List<InstitutionRecordingDTO> getInstitutionUserRecording(int pageNum, int pageSize, String type, String institutionNo, String searchKey, String beginTime, String endTime) {
@@ -337,10 +334,6 @@ public class UserRecordServiceImpl implements UserRecordService {
         return this.userRecordRepository.getUserRecordByPlanId(testPlanId);
     }
 
-    @Override
-    public List<UserRecordEntity> getuserRecordByPhone(String phone,String flag) {
-        return this.userRecordRepository.getuserRecordByPhone(phone,flag);
-    }
 
     @Override
     public InstitutionRecordingUsersDTO getRecordingUsersDTOById(String id) {

+ 3 - 0
src/main/java/com/rf/psychological/user/dao/repository/UserRepository.java

@@ -204,4 +204,7 @@ public interface UserRepository extends BaseRepository<UserEntity, String> {
 
     @Query(value="select count(1) from t_user_info where institution_no =:institutionNo and role_type =1 and structure_no like:structureNo" ,nativeQuery = true)
     int countByStructureNo(@Param("institutionNo")String institutionNo, @Param("structureNo")String structureNo);
+
+    @Query(value="select * from t_user_info where id in (select u_id from t_test_plan_user where test_plan_id =:planId and is_complete =9 )" ,nativeQuery = true)
+    Page<UserEntity> getPlanCompleteUser(String planId, Pageable of);
 }

+ 14 - 0
src/main/java/com/rf/psychological/user/rest/UserController.java

@@ -437,6 +437,20 @@ public class UserController extends BaseController {
         }catch (Exception e){
             return fail("操作失败");
         }
+    }
 
+    @GetMapping("/getPlanCompleteUser")
+    @ApiOperation(value = "获取计划下完成用户信息")
+    public Result getPlanCompleteUser(@RequestParam int pageNum,@RequestParam int pageSize, @RequestParam String planId){
+        try {
+            Page<UserEntity> userEntityPage = userService.getPlanCompleteUser(pageNum,pageSize,planId);
+            userEntityPage.getContent().forEach(item->{
+                String path=null;
+                item.setGId(structureService.getPath(path,item.getStructureNo(),item.getInstitutionNo()));
+            });
+            return success(userEntityPage);
+        }catch (Exception e){
+            return fail("操作失败");
+        }
     }
 }

+ 3 - 1
src/main/java/com/rf/psychological/user/service/UserService.java

@@ -1,9 +1,9 @@
 package com.rf.psychological.user.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.rf.psychological.enums.UserRole;
 import com.rf.psychological.scale.dao.model.SubjectEntity;
 import com.rf.psychological.user.dao.model.UserEntity;
-import com.rf.psychological.enums.UserRole;
 import org.springframework.data.domain.Page;
 
 import java.util.List;
@@ -230,4 +230,6 @@ public interface UserService {
     Page<UserEntity> findAdmin(int pageNum, int pageSize, String institutionNo,String phone);
 
     int countByStructureNo(String institutionNo, String structureNo);
+
+    Page<UserEntity> getPlanCompleteUser(int pageNum, int pageSize, String planId);
 }

+ 8 - 3
src/main/java/com/rf/psychological/user/service/impl/UserServiceImpl.java

@@ -2,12 +2,12 @@ package com.rf.psychological.user.service.impl;
 
 
 import com.alibaba.fastjson.JSONObject;
-import com.rf.psychological.scale.dao.model.SubjectEntity;
-import com.rf.psychological.user.dao.model.UserEntity;
-import com.rf.psychological.scale.dao.repository.SubjectRepository;
 import com.rf.psychological.enums.UserRole;
 import com.rf.psychological.plan.dao.repository.TestPlanUserRepository;
+import com.rf.psychological.scale.dao.model.SubjectEntity;
+import com.rf.psychological.scale.dao.repository.SubjectRepository;
 import com.rf.psychological.scale.dao.repository.UserRecordRepository;
+import com.rf.psychological.user.dao.model.UserEntity;
 import com.rf.psychological.user.dao.repository.UserRepository;
 import com.rf.psychological.user.service.UserService;
 import com.rf.psychological.utils.PageRequestUtil;
@@ -360,6 +360,11 @@ public class UserServiceImpl implements UserService {
         return userRepository.countByStructureNo(institutionNo,structureNo);
     }
 
+    @Override
+    public Page<UserEntity> getPlanCompleteUser(int pageNum, int pageSize, String planId) {
+        return userRepository.getPlanCompleteUser(planId,PageRequestUtil.of(pageNum,pageSize));
+    }
+
 
     /**
      * 改变用户状态