|
@@ -10,6 +10,7 @@ import com.mooctest.crowd.domain.repository.CrowdTestProjectRepo;
|
|
|
import com.mooctest.crowd.domain.repository.EvaluationAgencyRepo;
|
|
|
import com.mooctest.crowd.domain.repository.UserRepo;
|
|
|
import com.mooctest.crowd.domain.util.Converter;
|
|
|
+import com.mooctest.crowd.site.command.ApplyPersonalAuthCommand;
|
|
|
import com.mooctest.crowd.site.command.LoginCommand;
|
|
|
import com.mooctest.crowd.site.command.RegisterCommand;
|
|
|
import com.mooctest.crowd.site.data.ProjectOperationControl;
|
|
@@ -21,6 +22,7 @@ import com.mooctest.crowd.site.mediator.ViewMediator;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.codehaus.jettison.json.JSONException;
|
|
|
import org.codehaus.jettison.json.JSONObject;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -113,9 +115,48 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
|
|
|
@Value("${agency}")
|
|
|
private String agencyId;
|
|
|
+ @Autowired
|
|
|
+ private UserToRoleDao userToRoleDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void saveUserRole(User user, ApplyPersonalAuthCommand command) {
|
|
|
+ if (command.getRoleList().size() == 0 || command.getRoleList() == null) {
|
|
|
+ throw new BaseException("请选择成为发包或者接包用户");
|
|
|
+ }
|
|
|
+ //如果选择成为发包用户
|
|
|
+ UserPO userPO = userDao.save(Converter.convert(UserPO.class, user));
|
|
|
+ if (command.getRoleList().contains(0)) {
|
|
|
+ UserToRolePO u2r = new UserToRolePO();
|
|
|
+ u2r.setUserId(userPO.getId());
|
|
|
+ u2r.setRoleId(7L);
|
|
|
+ userToRoleDao.save(u2r);
|
|
|
+ }
|
|
|
+ //如果选择成为接包用户
|
|
|
+ if (command.getRoleList().contains(1)) {
|
|
|
+ UserToRolePO u2r = new UserToRolePO();
|
|
|
+ u2r.setUserId(userPO.getId());
|
|
|
+ u2r.setRoleId(6L);
|
|
|
+ userToRoleDao.save(u2r);
|
|
|
+
|
|
|
+ //如果两个都选择那么权限都给
|
|
|
+ } else if (command.getRoleList().contains(1) && command.getRoleList().contains(0)) {
|
|
|
+ UserToRolePO u2r = new UserToRolePO();
|
|
|
+ u2r.setUserId(userPO.getId());
|
|
|
+ u2r.setRoleId(7L);
|
|
|
+ userToRoleDao.save(u2r);
|
|
|
+ UserToRolePO u2rl = new UserToRolePO();
|
|
|
+ u2r.setUserId(userPO.getId());
|
|
|
+ u2r.setRoleId(6L);
|
|
|
+ userToRoleDao.save(u2rl);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
- public List<UserVO> renderMoreUser(Pageable pageable) {
|
|
|
+ public List<UserVO> renderMoreUser(Pageable pageable,String keyword) {
|
|
|
//获取众测人员排名
|
|
|
// String agencyName = agencyDao.findById(Long.parseLong(agencyId)).get().getEvaluationAgencyName();
|
|
|
// List<UserVO> userVOS = taskToUserDao.findTotalCountOfUser().stream().map(rankInfo -> {
|
|
@@ -128,17 +169,18 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
// }
|
|
|
// return null;
|
|
|
// }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
-
|
|
|
-
|
|
|
List<UserVO> userVOS = userTaskCountDao.findByType(RoleType.EVALUATION_USER.getId())
|
|
|
.stream().sorted(Comparator.comparing(UserTaskCountPO::getCount)).collect(Collectors.toList())
|
|
|
.stream().map(userTaskCountPO -> {
|
|
|
User user = userRepo.getByIDJustInfo(userTaskCountPO.getUserId());
|
|
|
UserVO userVO = new UserVO(user);
|
|
|
userVO.setTaskCount(userTaskCountPO.getCount());
|
|
|
- return userVO;
|
|
|
+ return userVO;
|
|
|
}).collect(Collectors.toList());
|
|
|
- return userVOS;
|
|
|
+ if (keyword != null && keyword.trim() != "") {
|
|
|
+ return userVOS.stream().filter(userVO -> userVO.getName().contains(keyword)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return userVOS;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -279,13 +321,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
IndexInfoDTO indexInfoDTO = new IndexInfoDTO();
|
|
|
Pageable pageable = PageRequest.of(0, 3);
|
|
|
int top = 3;
|
|
|
- //获取热门众测
|
|
|
- List<ApplicationTypeVO> applicationTypeRank = projectDao.findTotalCountOfApplicationType(pageable).stream().map(rankInfos -> {
|
|
|
- ApplicationType applicationType = commonRepo.getApplicationTypeByAppCode(rankInfos.getCode());
|
|
|
- ApplicationTypeVO applicationTypeVO = new ApplicationTypeVO(applicationType);
|
|
|
- applicationTypeVO.setCount(rankInfos.getCount());
|
|
|
- return applicationTypeVO;
|
|
|
- }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ List<ApplicationTypeVO> applicationTypeRank = getApplicationTypeRankVOS(pageable);
|
|
|
List<ApplicationTypeVO> applicationTypeRanks = new ArrayList<>();
|
|
|
if (applicationTypeRanks.size() > top) {
|
|
|
for (int i = 0; i < top; i++) {
|
|
@@ -312,7 +348,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
// }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
|
|
List<EvaluationAgencyVO> agencyRanks = userTaskCountDao.findByType(RoleType.AGENCY.getId())
|
|
|
- .stream().sorted(Comparator.comparing(UserTaskCountPO::getCount)).limit(top).collect(Collectors.toList())
|
|
|
+ .stream().sorted(Comparator.comparing(UserTaskCountPO::getCount).reversed()).limit(top).collect(Collectors.toList())
|
|
|
.stream().map(userTaskCountPO -> {
|
|
|
EvaluationAgencyPO agency = agencyDao.findByUserId(userTaskCountPO.getUserId());
|
|
|
EvaluationAgencyVO agencyVO = new EvaluationAgencyVO();
|
|
@@ -346,13 +382,13 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
// }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
|
|
List<UserVO> userRanks = userTaskCountDao.findByType(RoleType.EVALUATION_USER.getId())
|
|
|
- .stream().sorted(Comparator.comparing(UserTaskCountPO::getCount)).limit(top).collect(Collectors.toList())
|
|
|
+ .stream().sorted(Comparator.comparing(UserTaskCountPO::getCount).reversed()).limit(top).collect(Collectors.toList())
|
|
|
.stream().map(userTaskCountPO -> {
|
|
|
- User user = userRepo.getByIDJustInfo(userTaskCountPO.getUserId());
|
|
|
- UserVO userVO = new UserVO(user);
|
|
|
- userVO.setTaskCount(userTaskCountPO.getCount());
|
|
|
- return userVO;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ User user = userRepo.getByIDJustInfo(userTaskCountPO.getUserId());
|
|
|
+ UserVO userVO = new UserVO(user);
|
|
|
+ userVO.setTaskCount(userTaskCountPO.getCount());
|
|
|
+ return userVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
|
// List<UserVO> userRanks = new ArrayList<>();
|
|
|
// if (userRank.size() > top) {
|
|
@@ -378,6 +414,17 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
return indexInfoDTO;
|
|
|
}
|
|
|
|
|
|
+ @NotNull
|
|
|
+ public List<ApplicationTypeVO> getApplicationTypeRankVOS(Pageable pageable) {
|
|
|
+ //获取热门众测
|
|
|
+ return projectDao.findTotalCountOfApplicationType(pageable).stream().map(rankInfos -> {
|
|
|
+ ApplicationType applicationType = commonRepo.getApplicationTypeByAppCode(rankInfos.getCode());
|
|
|
+ ApplicationTypeVO applicationTypeVO = new ApplicationTypeVO(applicationType);
|
|
|
+ applicationTypeVO.setCount(rankInfos.getCount());
|
|
|
+ return applicationTypeVO;
|
|
|
+ }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public IndexDTO renderIndex() {
|
|
|
Pageable pageable = PageRequest.of(0, 10);
|
|
@@ -736,7 +783,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ReportDetailsDTO renderProjectReportDetails(String projectCode, String reportCode, Long userId){
|
|
|
+ public ReportDetailsDTO renderProjectReportDetails(String projectCode, String reportCode, Long userId) {
|
|
|
CrowdTestProject project = projectRepo.getByProjectCode(projectCode);
|
|
|
CrowdTestReport report = project.getCrowdTestReportForProject();
|
|
|
if (report == null)
|
|
@@ -745,7 +792,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
/*
|
|
|
如果该项目是已经完成的那么报告是不能修改的这边我在Vo上面加了一个属性Updated
|
|
|
*/
|
|
|
- if (project.getStatus() == CrowdTestProjectStatus.HAS_FINISHED){
|
|
|
+ if (project.getStatus() == CrowdTestProjectStatus.HAS_FINISHED) {
|
|
|
report.setUpdated(false);
|
|
|
}
|
|
|
reportDetailsDTO.setCrowdReportVO(new CrowdReportVO(report));
|
|
@@ -1023,6 +1070,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
if (userVO.getUnit() == null || userVO.getUnit().length() <= 0) {
|
|
|
throw new HttpBadRequestException("请输入企业简称");
|
|
|
}
|
|
|
+ userPO.get().setPhotoUrl(userVO.getPhotoUrl());
|
|
|
userPO.get().setUnit(userVO.getUnit());
|
|
|
userPO.get().setGender(userVO.getGender());
|
|
|
userPO.get().setBirthday(userVO.getBirthday());
|
|
@@ -1056,9 +1104,9 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
@Override
|
|
|
public QualificationDTO addQualification(long userId, QualificationVO qualificationVO) {
|
|
|
QualificationPO qualificationPO = new QualificationPO();
|
|
|
- List<QualificationPO> qualificationPOList=qualificationDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted);
|
|
|
- for(int i=0;i<qualificationPOList.size();i++){
|
|
|
- if(qualificationVO.getName().equals(qualificationPOList.get(i).getName())){
|
|
|
+ List<QualificationPO> qualificationPOList = qualificationDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted);
|
|
|
+ for (int i = 0; i < qualificationPOList.size(); i++) {
|
|
|
+ if (qualificationVO.getName().equals(qualificationPOList.get(i).getName())) {
|
|
|
throw new HttpBadRequestException("资质已存在");
|
|
|
}
|
|
|
}
|
|
@@ -1100,16 +1148,16 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
BankCardVO bankCardVO = new BankCardVO();
|
|
|
bankCardVO.setId(bankCardPO.getId());
|
|
|
bankCardVO.setUser(bankCardPO.getUser());
|
|
|
- int length=bankCardPO.getNumber().length();
|
|
|
+ int length = bankCardPO.getNumber().length();
|
|
|
int afterLength = 4;
|
|
|
String replaceSymbol = "*";
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
if (i >= (length - afterLength)) {
|
|
|
- sb.append(bankCardPO.getNumber().charAt(i));
|
|
|
+ sb.append(bankCardPO.getNumber().charAt(i));
|
|
|
} else {
|
|
|
- sb.append(replaceSymbol);
|
|
|
- }
|
|
|
+ sb.append(replaceSymbol);
|
|
|
+ }
|
|
|
bankCardVO.setNumber(sb.toString());
|
|
|
}
|
|
|
Optional<BankLogoPO> bankLogo = bankLogoDao.findByCode(bankCardPO.getCode());
|
|
@@ -1135,13 +1183,13 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
throw new HttpBadRequestException("请输入正确的卡号");
|
|
|
}
|
|
|
String bank = String.valueOf(json.get("bank"));
|
|
|
- Optional<BankLogoPO> bankLogoPO=bankLogoDao.findByName(bankCardVO.getName());
|
|
|
- if(!bank.equals(bankLogoPO.get().getName())){
|
|
|
+ Optional<BankLogoPO> bankLogoPO = bankLogoDao.findByName(bankCardVO.getName());
|
|
|
+ if (!bank.equals(bankLogoPO.get().getName())) {
|
|
|
throw new HttpBadRequestException("请输入与选定银行一致的账号");
|
|
|
}
|
|
|
- List<BankCardPO> bankCardPOList=bankCardDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted);
|
|
|
- for(int i=0;i<bankCardPOList.size();i++){
|
|
|
- if(bankCardVO.getNumber().equals(bankCardPOList.get(i).getNumber())){
|
|
|
+ List<BankCardPO> bankCardPOList = bankCardDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted);
|
|
|
+ for (int i = 0; i < bankCardPOList.size(); i++) {
|
|
|
+ if (bankCardVO.getNumber().equals(bankCardPOList.get(i).getNumber())) {
|
|
|
throw new HttpBadRequestException("银行卡已存在");
|
|
|
}
|
|
|
}
|
|
@@ -1186,6 +1234,20 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
resourceVO.setStandard(resourcePO.getStandard());
|
|
|
resourceVO.setUnit(resourcePO.getUnit());
|
|
|
resourceVO.setState(resourcePO.getState());
|
|
|
+ StatusVO statusVO = new StatusVO();
|
|
|
+ if(resourcePO.getState()==0){
|
|
|
+ statusVO.setText("空闲");
|
|
|
+ resourceVO.setStatusVO(statusVO);
|
|
|
+ }else if(resourcePO.getState()==1){
|
|
|
+ statusVO.setText("占用");
|
|
|
+ resourceVO.setStatusVO(statusVO);
|
|
|
+ }else if(resourcePO.getState()==2){
|
|
|
+ statusVO.setText("可用");
|
|
|
+ resourceVO.setStatusVO(statusVO);
|
|
|
+ }else if(resourcePO.getState()==3){
|
|
|
+ statusVO.setText("故障");
|
|
|
+ resourceVO.setStatusVO(statusVO);
|
|
|
+ }
|
|
|
resourceVO.setStartTime(resourcePO.getStartTime());
|
|
|
resourceVO.setPersonnel(resourcePO.getPersonnel());
|
|
|
resourceVO.setRemarks(resourcePO.getRemarks());
|
|
@@ -1210,14 +1272,20 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
resourceVO.setUnitWork(resourcePO.get().getUnitWork());
|
|
|
resourceVO.setStandard(resourcePO.get().getStandard());
|
|
|
resourceVO.setUnit(resourcePO.get().getUnit());
|
|
|
+ resourceVO.setState(resourcePO.get().getState());
|
|
|
+ StatusVO statusVO = new StatusVO();
|
|
|
if(resourcePO.get().getState()==0){
|
|
|
- resourceVO.setState(ResourceStatus.R_FREE);
|
|
|
+ statusVO.setText("空闲");
|
|
|
+ resourceVO.setStatusVO(statusVO);
|
|
|
}else if(resourcePO.get().getState()==1){
|
|
|
- resourceVO.setState(ResourceStatus.R_OCCUPY);
|
|
|
+ statusVO.setText("占用");
|
|
|
+ resourceVO.setStatusVO(statusVO);
|
|
|
}else if(resourcePO.get().getState()==2){
|
|
|
- resourceVO.setState(ResourceStatus.R_USABLE);
|
|
|
- }else {
|
|
|
- resourceVO.setState(ResourceStatus.R_FAULT);
|
|
|
+ statusVO.setText("可用");
|
|
|
+ resourceVO.setStatusVO(statusVO);
|
|
|
+ }else if(resourcePO.get().getState()==3){
|
|
|
+ statusVO.setText("故障");
|
|
|
+ resourceVO.setStatusVO(statusVO);
|
|
|
}
|
|
|
resourceVO.setStartTime(resourcePO.get().getStartTime());
|
|
|
resourceVO.setPersonnel(resourcePO.get().getPersonnel());
|
|
@@ -1264,7 +1332,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
qualificationVO.setIsPublic(qualificationPO.get().getIsPublic());
|
|
|
qualificationDTO.setQualificationVO(qualificationVO);
|
|
|
return qualificationDTO;
|
|
|
-}
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public BankCardDTO getBankType() {
|