|
@@ -1,19 +1,21 @@
|
|
|
package com.ym.mec.student.controller.degree;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.microsvc.toolkit.common.response.paging.PageInfo;
|
|
|
import com.microsvc.toolkit.common.response.paging.QueryInfo;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
+import com.ym.mec.biz.dal.enums.EDegreeStatus;
|
|
|
import com.ym.mec.biz.dal.wrapper.DegreeWrapper;
|
|
|
import com.ym.mec.biz.service.DegreeService;
|
|
|
-import com.ym.mec.biz.service.StudentService;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -24,7 +26,12 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Validated
|
|
@@ -51,13 +58,17 @@ public class DegreeInfoController extends BaseController {
|
|
|
// 考级信息
|
|
|
DegreeWrapper.StudentDegreeInfo wrapper = degreeService.studentDegreeInfoById(id);
|
|
|
|
|
|
- // 机构ID不匹配
|
|
|
+ // 考级机构-暂未开放此活动
|
|
|
if (!user.getTenantId().equals(wrapper.getTenantId())) {
|
|
|
throw new BizException("暂未开放此活动");
|
|
|
}
|
|
|
|
|
|
- // 分部城市未开放活动
|
|
|
-
|
|
|
+ // 考级城市-暂未开放此活动
|
|
|
+ boolean noneMatch = Arrays.stream(wrapper.getOrganIds().split(","))
|
|
|
+ .mapToInt(Integer::parseInt).noneMatch(x -> x == user.getOrganId());
|
|
|
+ if (Objects.nonNull(user.getOrganId()) && noneMatch) {
|
|
|
+ throw new BizException("暂未开放此活动");
|
|
|
+ }
|
|
|
|
|
|
// 查询机构信息
|
|
|
return succeed(wrapper);
|
|
@@ -73,7 +84,40 @@ public class DegreeInfoController extends BaseController {
|
|
|
return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
}
|
|
|
|
|
|
+ // 设置用户机构ID和城市分部ID
|
|
|
+ query.tenantId(user.getTenantId()).organId(user.getOrganId()).setDegreeStatuses(Lists.newArrayList(EDegreeStatus.END));
|
|
|
+
|
|
|
IPage<DegreeWrapper.Degree> pages = degreeService.selectPage(QueryInfo.getPage(query), query);
|
|
|
+
|
|
|
+ // 首页查询时,默认查询进行中,未开始插入首页
|
|
|
+ if (query.getPage() == 1) {
|
|
|
+
|
|
|
+ // 设置分页查询参数
|
|
|
+ query.rows(1000).degreeStatuses(Lists.newArrayList(EDegreeStatus.NOT_START, EDegreeStatus.START));
|
|
|
+
|
|
|
+ // 考级信息
|
|
|
+ Map<EDegreeStatus, List<DegreeWrapper.Degree>> collect = degreeService.selectPage(QueryInfo.getPage(query), query).getRecords().stream()
|
|
|
+ .collect(Collectors.groupingBy(DegreeWrapper.Degree::getStatus));
|
|
|
+
|
|
|
+ List<DegreeWrapper.Degree> degrees = Lists.newArrayList();
|
|
|
+ // 进行中
|
|
|
+ if (collect.containsKey(EDegreeStatus.START)) {
|
|
|
+ degrees.addAll(collect.get(EDegreeStatus.START).stream()
|
|
|
+ .sorted(Comparator.comparing(DegreeWrapper.Degree::getStartTime))
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 未开始
|
|
|
+ if (collect.containsKey(EDegreeStatus.NOT_START)) {
|
|
|
+ degrees.addAll(collect.get(EDegreeStatus.NOT_START).stream()
|
|
|
+ .sorted(Comparator.comparing(DegreeWrapper.Degree::getStartTime))
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(degrees)) {
|
|
|
+ pages.getRecords().addAll(0, degrees);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return succeed(QueryInfo.pageInfo(pages));
|
|
|
}
|