|
|
@@ -55,7 +55,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
@@ -95,72 +98,87 @@ public class ActivityInfoController {
|
|
|
@GetMapping(value = "/info")
|
|
|
@ApiOperation(value="根据id查询活动信息信息")
|
|
|
@SaCheckPermission("activityinfo:detail")
|
|
|
- public RT<ActivityInfoVo> info(@RequestParam Long id){
|
|
|
- ActivityInfo activityInfo = activityInfoService.getByIdDeep(id);
|
|
|
- if (activityInfo == null) {
|
|
|
- return RT.error("找不到此数据!");
|
|
|
- }
|
|
|
- ActivityInfoVo infoVo = BeanUtil.toBean(activityInfo, ActivityInfoVo.class);
|
|
|
- if(infoVo.getOrgId() != null){
|
|
|
- Department department = departmentService.getById(infoVo.getOrgId());
|
|
|
- if(department != null){
|
|
|
- infoVo.setOrgName(department.getName());
|
|
|
+ public RT<ActivityInfoVo> info(@RequestParam Long id, Integer category){
|
|
|
+ ActivityInfoVo infoVo = null;
|
|
|
+ if(category != null && (category == 1 || category == 2)){
|
|
|
+ ActivityInfo activityInfo = activityInfoService.getByIdDeep(id);
|
|
|
+ if (activityInfo == null) {
|
|
|
+ return RT.error("找不到此数据!");
|
|
|
}
|
|
|
- }
|
|
|
- if(infoVo.getEnterpriseId() != null){
|
|
|
- String tableName = "company_coop";
|
|
|
- Entity where = Entity.create(tableName);
|
|
|
- where.set("id", infoVo.getEnterpriseId());
|
|
|
- Map<String, Object> objectMap = SqlRunnerAdapter.db().dynamicSelectOne(tableName, where);
|
|
|
+ infoVo = BeanUtil.toBean(activityInfo, ActivityInfoVo.class);
|
|
|
+ if(infoVo.getOrgId() != null){
|
|
|
+ Department department = departmentService.getById(infoVo.getOrgId());
|
|
|
+ if(department != null){
|
|
|
+ infoVo.setOrgName(department.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(infoVo.getEnterpriseId() != null){
|
|
|
+ String tableName = "company_coop";
|
|
|
+ Entity where = Entity.create(tableName);
|
|
|
+ where.set("id", infoVo.getEnterpriseId());
|
|
|
+ Map<String, Object> objectMap = SqlRunnerAdapter.db().dynamicSelectOne(tableName, where);
|
|
|
|
|
|
- if(objectMap != null && objectMap.containsKey("company_name")){
|
|
|
- infoVo.setEnterpriseName(objectMap.get("company_name").toString());
|
|
|
+ if(objectMap != null && objectMap.containsKey("company_name")){
|
|
|
+ infoVo.setEnterpriseName(objectMap.get("company_name").toString());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- List<ActivityEnrollRangeVo> userRelationList = new ArrayList<>();
|
|
|
- if(activityInfo.getEnrollRange() != null && !activityInfo.getEnrollRange().isEmpty()){
|
|
|
- JSONArray asJsonArray = JSONUtil.parseArray(activityInfo.getEnrollRange());
|
|
|
- for (Object jsonElement : asJsonArray) {
|
|
|
- ActivityEnrollRangeVo relationDto = JSONUtil.toBean(JSONUtil.parseObj(jsonElement), ActivityEnrollRangeVo.class);
|
|
|
- if(relationDto.getUserId() != null){
|
|
|
- XjrUser xjrUser = xjrUserService.getById(relationDto.getUserId());
|
|
|
- if(xjrUser != null){
|
|
|
- relationDto.setName(xjrUser.getName());
|
|
|
- }
|
|
|
- }else if(relationDto.getDeptId() != null){
|
|
|
- Department department = departmentService.getById(relationDto.getDeptId());
|
|
|
- if(department != null){
|
|
|
- relationDto.setName(department.getName());
|
|
|
- }
|
|
|
+ List<ActivityEnrollRangeVo> userRelationList = new ArrayList<>();
|
|
|
+ if(activityInfo.getEnrollRange() != null && !activityInfo.getEnrollRange().isEmpty()){
|
|
|
+ JSONArray asJsonArray = JSONUtil.parseArray(activityInfo.getEnrollRange());
|
|
|
+ for (Object jsonElement : asJsonArray) {
|
|
|
+ ActivityEnrollRangeVo relationDto = JSONUtil.toBean(JSONUtil.parseObj(jsonElement), ActivityEnrollRangeVo.class);
|
|
|
+ if(relationDto.getUserId() != null){
|
|
|
+ XjrUser xjrUser = xjrUserService.getById(relationDto.getUserId());
|
|
|
+ if(xjrUser != null){
|
|
|
+ relationDto.setName(xjrUser.getName());
|
|
|
+ }
|
|
|
+ }else if(relationDto.getDeptId() != null){
|
|
|
+ Department department = departmentService.getById(relationDto.getDeptId());
|
|
|
+ if(department != null){
|
|
|
+ relationDto.setName(department.getName());
|
|
|
+ }
|
|
|
|
|
|
- }else if(relationDto.getClassId() != null){
|
|
|
- BaseClass aClass = classService.getById(relationDto.getClassId());
|
|
|
- if(aClass != null){
|
|
|
- relationDto.setName(aClass.getName());
|
|
|
+ }else if(relationDto.getClassId() != null){
|
|
|
+ BaseClass aClass = classService.getById(relationDto.getClassId());
|
|
|
+ if(aClass != null){
|
|
|
+ relationDto.setName(aClass.getName());
|
|
|
+ }
|
|
|
}
|
|
|
+ userRelationList.add(relationDto);
|
|
|
}
|
|
|
- userRelationList.add(relationDto);
|
|
|
}
|
|
|
- }
|
|
|
- infoVo.setActivityEnrollRangeList(userRelationList);
|
|
|
+ infoVo.setActivityEnrollRangeList(userRelationList);
|
|
|
+
|
|
|
+ ActivityEnrollExportDto dto = new ActivityEnrollExportDto();
|
|
|
+ dto.setActivityInfoId(id);
|
|
|
+ List<ActivityEnrollPageVo> enrollList = enrollService.getList(dto);
|
|
|
+ infoVo.setEnrollCount(enrollList.size());
|
|
|
|
|
|
- ActivityEnrollExportDto dto = new ActivityEnrollExportDto();
|
|
|
- dto.setActivityInfoId(id);
|
|
|
- List<ActivityEnrollPageVo> enrollList = enrollService.getList(dto);
|
|
|
- infoVo.setEnrollCount(enrollList.size());
|
|
|
+ Set<ActivityEnrollPageVo> teacherSet = enrollList.stream().filter(x -> x.getTeacherId() != null).collect(Collectors.toSet());
|
|
|
+ infoVo.setTeacherCount(teacherSet.size());
|
|
|
|
|
|
- Set<ActivityEnrollPageVo> teacherSet = enrollList.stream().filter(x -> x.getTeacherId() != null).collect(Collectors.toSet());
|
|
|
- infoVo.setTeacherCount(teacherSet.size());
|
|
|
+ Set<ActivityEnrollPageVo> studentSet = enrollList.stream().filter(x -> x.getStudentId() != null).collect(Collectors.toSet());
|
|
|
+ infoVo.setStudentCount(studentSet.size());
|
|
|
|
|
|
- Set<ActivityEnrollPageVo> studentSet = enrollList.stream().filter(x -> x.getStudentId() != null).collect(Collectors.toSet());
|
|
|
- infoVo.setStudentCount(studentSet.size());
|
|
|
+ Set<ActivityEnrollPageVo> suretSet = enrollList.stream().filter(x -> (x.getStatus() == 1 || x.getStatus() == 2)).collect(Collectors.toSet());
|
|
|
+ infoVo.setSureCount(suretSet.size());
|
|
|
|
|
|
- Set<ActivityEnrollPageVo> suretSet = enrollList.stream().filter(x -> (x.getStatus() == 1 || x.getStatus() == 2)).collect(Collectors.toSet());
|
|
|
- infoVo.setSureCount(suretSet.size());
|
|
|
+ Set<ActivityEnrollPageVo> notSuretSet = enrollList.stream().filter(x -> x.getStatus() == 0).collect(Collectors.toSet());
|
|
|
+ infoVo.setNotSureCount(notSuretSet.size());
|
|
|
+ }else if(category != null && category == 3){
|
|
|
+ String tableName = "club_activities";
|
|
|
+ Entity where = Entity.create(tableName);
|
|
|
+ where.set("id", id);
|
|
|
+ Map<String, Object> objectMap = SqlRunnerAdapter.db().dynamicSelectOne(tableName, where);
|
|
|
+ infoVo = new ActivityInfoVo();
|
|
|
+ infoVo.setName(objectMap.get("club_activities_name").toString());
|
|
|
+ infoVo.setContent(objectMap.get("club_activities_content").toString());
|
|
|
+ infoVo.setStartDate(Date.from(((LocalDateTime)objectMap.get("start_time")).atZone(ZoneId.systemDefault()).toInstant()));
|
|
|
+ infoVo.setEndDate(Date.from(((LocalDateTime)objectMap.get("end_time")).atZone(ZoneId.systemDefault()).toInstant()));
|
|
|
+ infoVo.setPlace(objectMap.get("activity_location").toString());
|
|
|
+ }
|
|
|
|
|
|
- Set<ActivityEnrollPageVo> notSuretSet = enrollList.stream().filter(x -> x.getStatus() == 0).collect(Collectors.toSet());
|
|
|
- infoVo.setNotSureCount(notSuretSet.size());
|
|
|
return RT.ok(infoVo);
|
|
|
}
|
|
|
|