guo00guo 5 gadi atpakaļ
vecāks
revīzija
feee640a85

+ 2 - 0
core/src/main/java/com/mooctest/crowd/domain/dao/UserTaskCountDao.java

@@ -26,4 +26,6 @@ public interface UserTaskCountDao extends CrudRepository<UserTaskCountPO, Long>,
     @Query(nativeQuery = true,value="UPDATE user_task_count SET UTC_COUNT=?1 WHERE UTC_USER_ID=?2")
     void updateCount(@Param("userId") long userId,@Param("count") long count);
 
+    @Override
+    <S extends UserTaskCountPO> S save(S s);
 }

+ 6 - 0
core/src/main/java/com/mooctest/crowd/domain/repository/EvaluationAgencyRepo.java

@@ -51,6 +51,12 @@ public class EvaluationAgencyRepo implements IEvaluationAgencyRepo {
     }
 
     @Override
+    public EvaluationAgency findAgencyByUserId(Long userId){
+        EvaluationAgencyPO evaluationAgencyPO = evaluationAgencyDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted);
+        return Converter.convert(EvaluationAgency.class, evaluationAgencyPO);
+    }
+
+    @Override
     public EvaluationAgencyResource findById(Long id){
         Optional<EvaluationAgencyResourcePO> evaluationAgencyResourcePOOptional = agencyResourceDao.findById(id);
         if(!evaluationAgencyResourcePOOptional.isPresent()){

+ 2 - 0
core/src/main/java/com/mooctest/crowd/domain/repository/IEvaluationAgencyRepo.java

@@ -16,6 +16,8 @@ public interface IEvaluationAgencyRepo {
 
     EvaluationAgency findAgencyById(Long id);
 
+    EvaluationAgency findAgencyByUserId(Long userId);
+
     EvaluationAgencyResource findById(Long id);
 
     List<EvaluationAgencyResource> findByEvaluationAgencyId(Long evaluationAgencyId);

+ 23 - 29
core/src/main/java/com/mooctest/crowd/domain/repository/UserRepo.java

@@ -14,7 +14,6 @@ import org.springframework.stereotype.Component;
 
 import java.sql.Timestamp;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
 
@@ -28,7 +27,7 @@ public class UserRepo implements IUserRepo {
     @Autowired
     private EvaluationAgencyDao agencyDao;
     @Autowired
-    private  TestTypeDao testTypeDao;
+    private TestTypeDao testTypeDao;
 
     @Autowired
     private UserDao userDao;
@@ -284,22 +283,22 @@ public class UserRepo implements IUserRepo {
         if (evaluationAgency != null) {
             EvaluationAgencyPO evaluationAgencyPO = Converter.convert(EvaluationAgencyPO.class, evaluationAgency);
             evaluationAgencyPO.setUserId(userPO.getId());
-            System.out.println(evaluationAgencyPO+"xxxxxxxxxxxxxxxxxxxxxxxx");
+            System.out.println(evaluationAgencyPO + "xxxxxxxxxxxxxxxxxxxxxxxx");
             evaluationAgencyPO = evaluationAgencyDao.save(evaluationAgencyPO);
             List<EvaluationAgencyResource> resources = evaluationAgency.getEvaluationAgencyResourceList();
             List<EvaluationAgencyAbility> abilities = evaluationAgency.getEvaluationAgencyAbilityList();
-           if(resources!=null) {
-               for (EvaluationAgencyResource resource : resources) {
-                   resource.setEvaluationAgencyId(evaluationAgencyPO.getId());
-                   resourceRepo.saveEvaluationAgencyResource(resource);
-               }
-           }
-           if(abilities!=null) {
-               for (EvaluationAgencyAbility ability : abilities) {
-                   ability.setEvaluationAgencyId(evaluationAgencyPO.getId());
-                   resourceRepo.saveEvaluationAgencyAbility(ability);
-               }
-           }
+            if (resources != null) {
+                for (EvaluationAgencyResource resource : resources) {
+                    resource.setEvaluationAgencyId(evaluationAgencyPO.getId());
+                    resourceRepo.saveEvaluationAgencyResource(resource);
+                }
+            }
+            if (abilities != null) {
+                for (EvaluationAgencyAbility ability : abilities) {
+                    ability.setEvaluationAgencyId(evaluationAgencyPO.getId());
+                    resourceRepo.saveEvaluationAgencyAbility(ability);
+                }
+            }
 //            // save测评机构资源
 //            EvaluationAgencyResource evaluationAgencyResource = evaluationAgency.getEvaluationAgencyResource();
 //            if(evaluationAgencyResource != null){
@@ -414,17 +413,15 @@ public class UserRepo implements IUserRepo {
             userResult.setEnterpriseAuthentication(Converter.convert(EnterpriseAuthentication.class, enterpriseAuthenticationPO));
         }
         //获取用户能力
-        List<String> abailities = new ArrayList<>();
-         if(userPO.getPersonalCompetence()!=null){
-             abailities= Arrays.asList(userPO.getPersonalCompetence().split(","));
-         }
-        {
-            for (int i = 0; i < abailities.size(); i++) {
-                String abilityName = testTypeDao.findByCode(abailities.get(i)).get().getName();
-                abailities.add(abilityName);
-            }
-        }
-        userResult.setPersonAbilities(abailities);
+//        List<String> abailities = new ArrayList<>();
+//        if (userPO.getPersonalCompetence() != null) {
+//            abailities = Arrays.asList(userPO.getPersonalCompetence().split(","));
+//            for (int i = 0; i < abailities.size(); i++) {
+//                String abilityName = testTypeDao.findByCode(abailities.get(i)).get().getName();
+//                abailities.add(abilityName);
+//            }
+//        }
+//        userResult.setPersonAbilities(abailities);
         /*获取区域管理员信息*/
         List<RegionalManagerToRegionalPO> regionalManagerToRegionalPOList = regionalManagerToRegionalDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
         if (regionalManagerToRegionalPOList.size() > 0) {
@@ -454,9 +451,6 @@ public class UserRepo implements IUserRepo {
     }
 
 
-
-
-
     private User getEvaluationInfo(User userResult) {
         /*获取测评机构信息*/
         EvaluationAgencyPO evaluationAgencyPO = evaluationAgencyDao.findByUserIdAndIsDeleted(userResult.getId(), DeletedStatus.isNotDeleted);

+ 5 - 0
site/src/main/java/com/mooctest/crowd/site/command/ApplyAgencyAuthCommand.java

@@ -3,6 +3,7 @@ package com.mooctest.crowd.site.command;
 import com.alibaba.fastjson.JSONObject;
 import com.mooctest.crowd.domain.domainobject.EvaluationAgency;
 import com.mooctest.crowd.domain.domainobject.EvaluationAgencyAbility;
+import com.mooctest.crowd.domain.exception.HttpBadRequestException;
 import com.mooctest.crowd.domain.factory.UserFactory;
 import lombok.Data;
 import org.springframework.beans.BeanUtils;
@@ -51,6 +52,10 @@ public class ApplyAgencyAuthCommand{
     private List<AgencyResourceCommand> evaluationAgencyResourceList;
 
     public EvaluationAgency toAgency(){
+        String reg = "\\d{15}(\\d{2}[0-9xX])?";
+        if(!IdCardNum.matches(reg)){
+            throw new HttpBadRequestException("身份证信息不合法");
+        }
         EvaluationAgency agency = UserFactory.defaultAgency();
         BeanUtils.copyProperties(this, agency, "evaluationAgencyAbilityList", "evaluationAgencyResourceList");
         if( this.evaluationAgencyAbilityList != null&&this.evaluationAgencyAbilityList.size() > 0 ){

+ 6 - 2
site/src/main/java/com/mooctest/crowd/site/command/ApplyPersonalAuthCommand.java

@@ -3,11 +3,11 @@ package com.mooctest.crowd.site.command;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.mooctest.crowd.domain.domainobject.PersonalAuthentication;
+import com.mooctest.crowd.domain.exception.HttpBadRequestException;
 import lombok.Data;
 import org.springframework.beans.BeanUtils;
 
 import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Pattern;
 import java.sql.Date;
 import java.sql.Timestamp;
 import java.util.List;
@@ -28,7 +28,7 @@ public class ApplyPersonalAuthCommand {
 
     @JsonProperty(value = "idCard")
     @NotNull(message = "请填写身份证号码")
-    @Pattern(regexp = "\\d{15}(\\d{2}[0-9xX])?", message = "身份证号格式错误")
+//    @Pattern(regexp = "\\d{15}(\\d{2}[0-9xX])?", message = "身份证号格式错误")
     private String idCard;
 
     @JsonProperty(value = "idCardPositivePhoto")
@@ -50,6 +50,10 @@ public class ApplyPersonalAuthCommand {
     private List<Integer> roleList;
 
     public PersonalAuthentication toPersonalAuth() {
+        String reg = "\\d{15}(\\d{2}[0-9xX])?";
+        if(!idCard.matches(reg)){
+            throw new HttpBadRequestException("身份证信息不合法");
+        }
         PersonalAuthentication personalAuthentication = new PersonalAuthentication();
         BeanUtils.copyProperties(this, personalAuthentication);
         personalAuthentication.setType(JSONObject.toJSONString(this.roleList));

+ 2 - 2
site/src/main/java/com/mooctest/crowd/site/controller/AgencyController.java

@@ -131,13 +131,13 @@ public class AgencyController extends BaseSearchController {
     /**
      * 获取机构认证信息
      *
-     * @param anencyId
+     * @param userId
      * @return
      */
     @LoginRequired
     @RequestMapping(value = "/user/{userId}/agency", method = RequestMethod.GET)
     public ResponseVO getAgencyInfo(@PathVariable("userId") Long userId) {
-        return     new ResponseVO(ServerCode.SUCCESS ,agencyService.getDetailById(userId));
+        return new ResponseVO(ServerCode.SUCCESS ,agencyService.getDetailById(userId));
     }
 
     @RequestMapping(value = "/agency/list", method = RequestMethod.GET)

+ 31 - 13
site/src/main/java/com/mooctest/crowd/site/data/vo/EvaluationAgencyVO.java

@@ -1,13 +1,16 @@
 package com.mooctest.crowd.site.data.vo;
 
 import com.mooctest.crowd.domain.domainobject.EvaluationAgency;
+import com.mooctest.crowd.domain.domainobject.EvaluationAgencyAbility;
+import com.mooctest.crowd.domain.domainobject.EvaluationAgencyResource;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
-import  java.util.*;
+import org.springframework.beans.BeanUtils;
 
 import java.io.Serializable;
 import java.sql.Timestamp;
+import java.util.List;
 
 /**
  * @Author: xuexb
@@ -23,25 +26,40 @@ public class EvaluationAgencyVO implements Serializable {
     private String agencyPhoto;
     private String evaluationAgencyName;
     private Double allTaskPrice;
-    private Long   taskCount;
-    private  int   authStatus;
+    private Long taskCount;
+    private int authStatus;
     private String address;
     private Timestamp updateTime;
     private Timestamp expireTime;
     private Timestamp checkTime;
     private Timestamp applyTime;
-    private List<String>  agencyAbilities;
+    private List<String> agencyAbilities;
 
+    private String businessLicensePhoto;
+    private String legalPersonName;
+//    private String IdCardNum;
+//    private String gender;
+//    private String idCardPositivePhoto;//身份证正面照
+//    private String idCardBackPhoto;//身份证反面照
+//    private Date idCardDeadTime;
 
+    private List<EvaluationAgencyAbility> evaluationAgencyAbilityList;
+    private List<EvaluationAgencyResource> evaluationAgencyResourceList;
+    private int isAuthentication;
+    private String explain;
+    private int isDeleted;
+    private String type;
 
-    public EvaluationAgencyVO(EvaluationAgency evaluationAgency){
-        id = evaluationAgency.getId();
-        agencyPhoto = evaluationAgency.getAgencyPhoto();
-        evaluationAgencyName = evaluationAgency.getEvaluationAgencyName();
-        userId = evaluationAgency.getUserId();
-        updateTime=evaluationAgency.getUpdateTime();
-        expireTime=evaluationAgency.getExpireTime();
-        checkTime=evaluationAgency.getCheckTime();
-        applyTime=evaluationAgency.getApplyTime();
+
+    public EvaluationAgencyVO(EvaluationAgency evaluationAgency) {
+        BeanUtils.copyProperties(evaluationAgency, this);
+//        id = evaluationAgency.getId();
+//        agencyPhoto = evaluationAgency.getAgencyPhoto();
+//        evaluationAgencyName = evaluationAgency.getEvaluationAgencyName();
+//        userId = evaluationAgency.getUserId();
+//        updateTime = evaluationAgency.getUpdateTime();
+//        expireTime = evaluationAgency.getExpireTime();
+//        checkTime = evaluationAgency.getCheckTime();
+//        applyTime = evaluationAgency.getApplyTime();
     }
 }

+ 2 - 2
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -661,12 +661,12 @@ public class WebMediatorImpl implements ViewMediator {
         UserVO userVO = new UserVO(user);
         userDataDTO.setMyProjects(myProjects);
         userDataDTO.setUserVO(userVO);
-        if (user.getRoleList().stream().noneMatch(role -> role.getName().equals("evaluationAgency")))
+        if (!AuthCheckServiceImpl.isAgency(user))
             return userDataDTO;
         List<CrowdTestTask> allTaskOfAgency = null;
         List<CrowdTestTask> unfinishedTasks = null;
         List<CrowdTestTask> finishedTasks = null;
-        if (user.getRoleList().stream().anyMatch(role -> role.getName().equals("evaluationAgency"))) {
+        if (AuthCheckServiceImpl.isAgency(user)) {
             List<TaskToUserPO> taskToUserPOS = taskToUserDao.findByUserId(user.getId());
             if (taskToUserPOS != null && taskToUserPOS.size() > 0) {
                 allTaskOfAgency = taskToUserPOS.stream().sorted(Comparator.comparing(TaskToUserPO::getAcceptTime))

+ 1 - 1
site/src/main/java/com/mooctest/crowd/site/service/AgencyService.java

@@ -16,7 +16,7 @@ import java.util.List;
  */
 public interface AgencyService {
 
-    EvaluationAgencyVO   getDetailById(long agencyId);
+    EvaluationAgencyVO getDetailById(long agencyId);
 
     List<EvaluationAgencyVO> findMoreAgencyVO(String keyword);
 

+ 45 - 40
site/src/main/java/com/mooctest/crowd/site/service/impl/AgencyServiceImpl.java

@@ -4,9 +4,9 @@ import com.mooctest.crowd.domain.dao.*;
 import com.mooctest.crowd.domain.domainobject.*;
 import com.mooctest.crowd.domain.exception.BaseException;
 import com.mooctest.crowd.domain.exception.EvaluationAgencyNotExistException;
-import com.mooctest.crowd.domain.exception.HttpBadRequestException;
 import com.mooctest.crowd.domain.exception.UserNotExistException;
-import com.mooctest.crowd.domain.model.*;
+import com.mooctest.crowd.domain.model.EvaluationAgencyPO;
+import com.mooctest.crowd.domain.model.UserTaskCountPO;
 import com.mooctest.crowd.domain.repository.EvaluationAgencyRepo;
 import com.mooctest.crowd.domain.repository.UserRepo;
 import com.mooctest.crowd.site.anticorruption.UserAntiCorruption;
@@ -25,7 +25,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
 import java.util.stream.Collectors;
 
 /**
@@ -62,46 +64,49 @@ public class AgencyServiceImpl implements AgencyService {
     private UserTaskCountDao userTaskCountDao;
 
     @Override
-    public EvaluationAgencyVO getDetailById(long  userId) {
+    public EvaluationAgencyVO getDetailById(long userId) {
+        EvaluationAgency agency = evaluationAgencyRepo.findAgencyByUserId(userId);
+        EvaluationAgencyVO agencyVO = new EvaluationAgencyVO(agency);
         /*
-        先根据机构id查询出机构信息,再从task-to-user表里面找到这个机构的接的任务的数量。
+        先根据机构的userId查询出机构信息,再从user_task_count表里面找到这个机构的接的任务的数量。
          */
+        UserTaskCount taskCountByUserId = userRepo.getUserTaskCountByUserId(userId);
+        agencyVO.setTaskCount(taskCountByUserId.getCount());
 
-
-        List<String> agencyAbilities = new ArrayList<>();//机构能力list
-        //根据compentence[]从test——type表利查询对应的能力名称
-        EvaluationAgencyPO agencyPO = agencyDao.findByUserId(userId);
-        if (agencyPO==null) {
-            throw new HttpBadRequestException("机构不存在!");
-        }
-        EvaluationAgency evaluationAgency = new EvaluationAgency(agencyPO);
-        Optional<UserPO> userPO = userDao.findById(userId);
-        String userCompetence="";
-        if(userPO.get().getPersonalCompetence()!=null) {
-             userCompetence = userPO.get().getPersonalCompetence();
-        }
-        //将 userConpetence按逗号分搁
-        List<String> compentenceList=new ArrayList<>();
-        System.out.println(userCompetence+"sasssss");
-        if (userCompetence!=null&&!userCompetence.trim().equals("")){
-            compentenceList= Arrays.asList(userCompetence.split(",")); //JKCS,JRXCE,KKXCS,WDXCS
-            for (int i = 0; i < compentenceList.size(); i++) {
-                //查询对应code的测试类型的名称比如接口测试,兼用型测试等。
-                Optional<TestTypePO> testTypePO = testTypeDao.findByCode(compentenceList.get(i));
-                agencyAbilities.add(testTypePO.get().getName());
-            }
-        }
-        EvaluationAgencyVO agencyVO = new EvaluationAgencyVO(evaluationAgency);
-        agencyVO.setAuthStatus(evaluationAgency.getIsAuthentication());
-        List<RankCountInfo> rankCountInfoList = taskToUserDao.findTotalCountOfUser();
-        long ids[] = new long[rankCountInfoList.size()];
-        for (int i = 0; i < ids.length; i++) {
-            ids[i] = rankCountInfoList.get(i).getEntityId();
-            if (ids[i] == agencyVO.getUserId()) {
-                agencyVO.setTaskCount(rankCountInfoList.get(i).getCount());
-            }
-        }
-        agencyVO.setAgencyAbilities(agencyAbilities);
+//        List<String> agencyAbilities = new ArrayList<>();//机构能力list
+//        //根据compentence[]从test——type表利查询对应的能力名称
+//        EvaluationAgencyPO agencyPO = agencyDao.findByUserId(userId);
+//        if (agencyPO==null) {
+//            throw new HttpBadRequestException("机构不存在!");
+//        }
+//        EvaluationAgency evaluationAgency = new EvaluationAgency(agencyPO);
+//        Optional<UserPO> userPO = userDao.findById(userId);
+//        String userCompetence="";
+//        if(userPO.get().getPersonalCompetence()!=null) {
+//             userCompetence = userPO.get().getPersonalCompetence();
+//        }
+//        //将 userConpetence按逗号分搁
+//        List<String> compentenceList=new ArrayList<>();
+//        System.out.println(userCompetence+"sasssss");
+//        if (userCompetence!=null&&!userCompetence.trim().equals("")){
+//            compentenceList= Arrays.asList(userCompetence.split(",")); //JKCS,JRXCE,KKXCS,WDXCS
+//            for (int i = 0; i < compentenceList.size(); i++) {
+//                //查询对应code的测试类型的名称比如接口测试,兼用型测试等。
+//                Optional<TestTypePO> testTypePO = testTypeDao.findByCode(compentenceList.get(i));
+//                agencyAbilities.add(testTypePO.get().getName());
+//            }
+//        }
+//        EvaluationAgencyVO agencyVO = new EvaluationAgencyVO(evaluationAgency);
+//        agencyVO.setAuthStatus(evaluationAgency.getIsAuthentication());
+//        List<RankCountInfo> rankCountInfoList = taskToUserDao.findTotalCountOfUser();
+//        long ids[] = new long[rankCountInfoList.size()];
+//        for (int i = 0; i < ids.length; i++) {
+//            ids[i] = rankCountInfoList.get(i).getEntityId();
+//            if (ids[i] == agencyVO.getUserId()) {
+//                agencyVO.setTaskCount(rankCountInfoList.get(i).getCount());
+//            }
+//        }
+//        agencyVO.setAgencyAbilities(agencyAbilities);
         return agencyVO;
     }
 

+ 12 - 17
site/src/main/java/com/mooctest/crowd/site/service/impl/CrowdProjectServiceImpl.java

@@ -368,24 +368,21 @@ public class CrowdProjectServiceImpl implements CrowdProjectService {
         CrowdTestProject project = projectRepo.getByProjectCode(projectCode);
 
         // 更新项目下测评机构或者测试人员的接包次数
-        project.getCrowdTestTaskList().stream().map(crowdTestTask -> {
+        List<CrowdTestTask> crowdTestTasks = project.getCrowdTestTaskList();
+        for(CrowdTestTask crowdTestTask : crowdTestTasks) {
             List<TaskToUser> acceptedUserList = crowdTestTask.getAcceptedUserList();
-            acceptedUserList.stream().map(taskToUser -> {
+            for (TaskToUser taskToUser : acceptedUserList) {
                 User user = userRepo.getByID(taskToUser.getUserId());
 
                 // 对用户判断认证类型 测评机构为2 测试人员为6
                 Optional<UserTaskCountPO> userTaskCountPOOptional = userTaskCountDao.findByUserId(user.getId());
                 if (!userTaskCountPOOptional.isPresent()) {
                     Long roleType = 2L;
-                    if(user.getRoleList().stream().anyMatch(role -> role.getName().equals(RoleType.EVALUATION_USER))){
+                    if (user.getRoleList().stream().anyMatch(role -> role.getName().equals(RoleType.EVALUATION_USER.getName()))) {
                         roleType = RoleType.EVALUATION_USER.getId();
+                    } else if (user.getRoleList().stream().anyMatch(role -> role.getName().equals(RoleType.AGENCY.getName()))) {
+                        roleType = RoleType.AGENCY.getId();
                     }
-                    else if(user.getRoleList().stream().anyMatch(role -> role.getName().equals(RoleType.EVALUATION_USER))){
-                        roleType = RoleType.EVALUATION_USER.getId();
-                    }
-//                    else{
-//                        throw new HttpBadRequestException("当前存在未认证的用户")
-//                    }
                     UserTaskCount userTaskCount = new UserTaskCount(user.getId(), 1L, roleType);
                     userTaskCountDao.save(Converter.convert(UserTaskCountPO.class, userTaskCount));
                 } else {
@@ -393,14 +390,12 @@ public class CrowdProjectServiceImpl implements CrowdProjectService {
                     userTaskCountPO.setCount(userTaskCountPO.getCount() + 1);
                     userTaskCountDao.save(userTaskCountPO);
                 }
-                return null;
-            });
-            return null;
-        }).collect(Collectors.toList());
-
-        project.finishCrowdTestProject(userRepo.getByID(userId));
-        projectRepo.saveCrowdTestProject(project);
-        return getProjectDetails(projectCode, userId);
+            }
+            project.finishCrowdTestProject(userRepo.getByID(userId));
+            projectRepo.saveCrowdTestProject(project);
+            return getProjectDetails(projectCode, userId);
+        }
+        return null;
     }
 
     @Override