Browse Source

测试记录接口调整

zsf 1 year ago
parent
commit
15a2c7761b

+ 0 - 40
src/main/java/com/rf/psychological/dao/model/AviationEntity.java

@@ -1,40 +0,0 @@
-package com.rf.psychological.dao.model;
-
-import com.rf.psychological.base.model.BaseEntity;
-import lombok.*;
-import org.hibernate.annotations.DynamicUpdate;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Table;
-
-/**
- * @author zzf
- * @description:汉化版美国航空航天局任务负荷指数量表
- * @date 2021/1/20 17:47
- */
-@Entity
-@Data
-@Getter
-@Setter
-@NoArgsConstructor
-@AllArgsConstructor
-@Table(name = "t_aviation_info")
-@org.hibernate.annotations.Table(appliesTo = "t_aviation_info", comment = "汉化版美国航空航天局任务负荷指数量表")
-@DynamicUpdate
-public class AviationEntity extends BaseEntity {
-    /**
-     * 编号
-     */
-    @Column(name = "no", columnDefinition = "int(10) comment '编号'")
-    private int no;
-
-    /**
-     * 内容
-     */
-    @Column(name = "content", columnDefinition = "text comment '内容'")
-    private String content;
-
-    @Column(name = "checked", columnDefinition = "varchar(10) comment '得分'")
-    private String checked;
-}

+ 0 - 12
src/main/java/com/rf/psychological/dao/repository/AviationRepository.java

@@ -1,12 +0,0 @@
-package com.rf.psychological.dao.repository;
-
-import com.rf.psychological.base.repository.BaseRepository;
-import com.rf.psychological.dao.model.AviationEntity;
-
-/**
- * @author zzf
- * @description:
- * @date 2021/1/20 17:49
- */
-public interface AviationRepository extends BaseRepository<AviationEntity,String> {
-}

+ 0 - 18
src/main/java/com/rf/psychological/scale/rest/ScaleResultController.java

@@ -89,24 +89,6 @@ public class ScaleResultController extends BaseController {
             resultMapList = new ArrayList<>();
             resultMapList.add(resultMap);
             ExcelUtil.createExcelFile(SCLEntity.class,jsonArray.toJavaList(SCLEntity.class),resultMapList,new ExcelClass().contentExcel(Constant.QUEST_TYPE_SCL),fileName,Constant.SHEET_NAME_SCL);
-            //汉化版美国航空航天局任务负荷指数量表
-        }else if(Constant.QUEST_TYPE_AVAI.equals(type)){
-            int score = 0 ;
-            for (int i = 0; i < jsonArray.size(); i++) {
-                JSONObject jsonObject1 = jsonArray.getJSONObject(i);
-                score += jsonObject1.getInteger("checked");
-            }
-            //平均分保留两位小数
-            double avgScore = new BigDecimal((double)score/(double)jsonArray.size()).setScale(2, RoundingMode.HALF_UP).doubleValue();
-            System.out.println("总得分:"+score+";平均得分:"+avgScore);
-            fileName = fileName+"-"+Constant.SHEET_NAME_AVAI+".xlsx";
-            Map<String,String> resultMap = new LinkedHashMap<>();
-            resultMap.put("总得分",String.valueOf(score));
-            resultMap.put("平均得分",String.valueOf(avgScore));
-            resultMapList = new ArrayList<>();
-            resultMapList.add(resultMap);
-            ExcelUtil.createExcelFile(AviationEntity.class,jsonArray.toJavaList(AviationEntity.class),resultMapList,new ExcelClass().contentExcel(Constant.QUEST_TYPE_AVAI),fileName,Constant.SHEET_NAME_AVAI);
-            //社会支持评定量表
         }else if (Constant.QUEST_TYPE_DEPR.equals(type)){
             //压力的分  焦虑得分  抑郁得分
             int [] score = {0,0,0};

+ 0 - 5
src/main/java/com/rf/psychological/scale/rest/SubjectController.java

@@ -44,8 +44,6 @@ public class SubjectController extends BaseController {
     @Autowired
     private SCLService sclService;
 
-    @Autowired
-    private AviationService aviationService;
 
     @Autowired
     private DepressService depressService;
@@ -72,9 +70,6 @@ public class SubjectController extends BaseController {
         if(Constant.QUEST_TYPE_SCL.equals(type)){
             List<SCLEntity> sclEntityList = this.sclService.findAll();
             return success(sclEntityList);
-        }else if(Constant.QUEST_TYPE_AVAI.equals(type)){
-            List<AviationEntity> aviationEntityList = this.aviationService.findAll();
-            return success(aviationEntityList);
         }else if(Constant.QUEST_TYPE_DEPR.equals(type)){
             List<DepressEntity> depressEntityList = this.depressService.findAll();
             return success(depressEntityList);

+ 0 - 18
src/main/java/com/rf/psychological/service/AviationService.java

@@ -1,18 +0,0 @@
-package com.rf.psychological.service;
-
-import com.rf.psychological.dao.model.AviationEntity;
-
-import java.util.List;
-
-/**
- * @author zzf
- * @description:
- * @date 2021/1/20 17:50
- */
-public interface AviationService {
-    /**
-     * 全量查询
-     * @return
-     */
-    List<AviationEntity> findAll();
-}

+ 0 - 30
src/main/java/com/rf/psychological/service/impl/AviationServiceImpl.java

@@ -1,30 +0,0 @@
-package com.rf.psychological.service.impl;
-
-import com.rf.psychological.dao.model.AviationEntity;
-import com.rf.psychological.dao.repository.AviationRepository;
-import com.rf.psychological.service.AviationService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * @author zzf
- * @description:
- * @date 2021/1/20 17:50
- */
-@Service
-
-public class AviationServiceImpl implements AviationService {
-    @Autowired
-    private AviationRepository aviationRepository;
-    /**
-     * 全量查询
-     *
-     * @return
-     */
-    @Override
-    public List<AviationEntity> findAll() {
-        return this.aviationRepository.findAll();
-    }
-}

+ 2 - 0
src/main/java/com/rf/psychological/structure/dao/repository/StructureRepository.java

@@ -15,4 +15,6 @@ public interface StructureRepository extends BaseRepository<StructureEntity,Stri
     List<String> findStructureNoByIdRecursion(String structureNo, @Param("structureNo2")String structureNo2);
 
     List<StructureEntity> findByInstitutionNo(String institutionNo);
+
+    StructureEntity findByStructureNoAndInstitutionNo(String structureNo,String institutionNo);
 }

+ 2 - 0
src/main/java/com/rf/psychological/structure/service/StructureService.java

@@ -16,4 +16,6 @@ public interface StructureService {
     List<String> findStructureNoByIdRecursion(String structureNo);
 
     List<StructureEntity> findByInstitutionNo(String institutionNo);
+
+    String getPath(String path,String structureNo,String institutionNo);
 }

+ 24 - 0
src/main/java/com/rf/psychological/structure/service/impl/StructureServiceImpl.java

@@ -3,6 +3,8 @@ package com.rf.psychological.structure.service.impl;
 import com.rf.psychological.structure.dao.model.StructureEntity;
 import com.rf.psychological.structure.dao.repository.StructureRepository;
 import com.rf.psychological.structure.service.StructureService;
+import com.rf.psychological.utils.Constant;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -47,4 +49,26 @@ public class StructureServiceImpl implements StructureService {
     public List<StructureEntity> findByInstitutionNo(String institutionNo) {
         return this.repository.findByInstitutionNo(institutionNo);
     }
+
+    @Override
+    public String getPath(String path,String structureNo,String institutionNo) {
+        if (StringUtils.isEmpty(structureNo)){
+            return null;
+        }
+        StructureEntity entity = this.repository.findByStructureNoAndInstitutionNo(structureNo,institutionNo);
+        if ( entity == null){
+            return null;
+        }else {
+            if (StringUtils.isEmpty(path)){
+                path = entity.getStructureName();
+            }else {
+                path = entity.getStructureName()+"->"+path;
+            }
+        }
+        if (Constant.DEFAULT_VALUE_ZERO.equals(entity.getParentStructureNo()) && entity.getParentStructureNo().length()<3){
+            return path;
+        }else {
+            return getPath(path,entity.getParentStructureNo(),institutionNo);
+        }
+    }
 }

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

@@ -80,7 +80,7 @@ public interface UserRepository extends BaseRepository<UserEntity, String> {
      * @param searchKey
      * @return
      */
-    @Query(value = "select distinct tui.id,gender,password,pet_name,tui.phone,birthday,profession,institution_name,tui.institution_no,user_status,g_id,model,role_type from t_user_info tui join t_user_record tur on  tui.phone=tur.phone and tui.institution_no=tur.institution_no " +
+    @Query(value = "select distinct tui.* from t_user_info tui join t_user_record tur on  tui.phone=tur.phone and tui.institution_no=tur.institution_no " +
             " where tui.institution_no = :institutionNo  and role_type ='1' and (pet_name like %:searchKey% or tui.phone like %:searchKey% ) and structure_no like :structureNo% order by id  limit :pageNum ,:pageSize ", nativeQuery = true)
     List<UserEntity> getTestListByInstitutionNo(@Param("pageNum") int pageNum, @Param("pageSize") int pageSize, @Param("institutionNo") String institutionNo, @Param("searchKey") String searchKey, @Param("structureNo") String structureNo);
 

+ 22 - 1
src/main/java/com/rf/psychological/user/rest/UserController.java

@@ -2,6 +2,7 @@ package com.rf.psychological.user.rest;
 
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.lang.Validator;
+import cn.hutool.core.util.IdcardUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.rf.psychological.base.rest.BaseController;
 import com.rf.psychological.enums.UserRole;
@@ -15,6 +16,7 @@ import com.rf.psychological.plan.service.PlanGroupService;
 import com.rf.psychological.plan.service.TestPlanUserService;
 import com.rf.psychological.security.AesEncryptUtils;
 import com.rf.psychological.security.SafetyProcess;
+import com.rf.psychological.structure.service.StructureService;
 import com.rf.psychological.user.dao.model.UserEntity;
 import com.rf.psychological.user.service.UserService;
 import com.rf.psychological.utils.Constant;
@@ -22,6 +24,7 @@ import com.rf.psychological.utils.Result;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -58,6 +61,9 @@ public class UserController extends BaseController {
     @Autowired
     private InstitutionService institutionService;
 
+    @Autowired
+    private StructureService structureService;
+
 
     /**
      * 修改密码
@@ -193,8 +199,17 @@ public class UserController extends BaseController {
             pageSize = 20;
         }
         int num;
+        if (StringUtils.isEmpty(structureNo)){
+            structureNo="";
+        }
         List<UserEntity> userRecordEntityList = this.userService.getTestListByInstitutionNo(pageNum, pageSize, institutionNo, searchKey,structureNo);
         num = this.userService.allNumByInstitutionNo(institutionNo, searchKey,structureNo);
+        if (CollectionUtils.isNotEmpty(userRecordEntityList)){
+            userRecordEntityList.forEach(item->{
+                String path=null;
+                item.setGId(structureService.getPath(path,item.getStructureNo(),item.getInstitutionNo()));
+            });
+        }
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("userRecordEntityList", userRecordEntityList);
         jsonObject.put("allNum", num);
@@ -352,12 +367,18 @@ public class UserController extends BaseController {
 
                     return fail("账号不符合身份证规则");
 
+                }if (!Validator.isMobile(userEntity.getModel())){
+
+                    return fail("手机号不符合规则");
+
                 }
                 userEntity.setPassword(DigestUtils.md5DigestAsHex(idCardStr.substring(12).getBytes()));
                 userEntity.setUserStatus(Constant.USER_STATUS_NORMAL);
                 userEntity.setRoleType(UserRole.COMMON.getType());
-                userEntity.setBirthday(idCardStr.substring(6,10)+"-"+idCardStr.substring(10,12)+"-"+idCardStr.substring(12,14));
+                //userEntity.setBirthday(idCardStr.substring(6,10)+"-"+idCardStr.substring(10,12)+"-"+idCardStr.substring(12,14));
+                userEntity.setBirthday(IdcardUtil.getYearByIdCard(idCardStr)+"-"+IdcardUtil.getMonthByIdCard(idCardStr)+"-"+IdcardUtil.getDayByIdCard(idCardStr));
                 userEntity.setIdCard(idCardStr);
+                userEntity.setGender(String.valueOf(IdcardUtil.getGenderByIdCard(idCardStr)));
                 userEntity.setCreateTime(DateUtil.now());
                 this.userService.save(userEntity);
                 return success();