|
@@ -1,5 +1,6 @@
|
|
|
package com.citu.module.menduner.system.service.job;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.citu.framework.common.pojo.PageResult;
|
|
|
import com.citu.framework.common.util.object.BeanUtils;
|
|
@@ -8,7 +9,7 @@ import com.citu.module.menduner.system.controller.app.job.hire.AppHireJobCvRelQu
|
|
|
import com.citu.module.menduner.system.controller.app.job.hire.AppHireJobCvRelReqVO;
|
|
|
import com.citu.module.menduner.system.controller.app.job.hire.AppHireJobCvRelRespVO;
|
|
|
import com.citu.module.menduner.system.controller.app.job.vo.AppJobCvRelReqVO;
|
|
|
-import com.citu.module.menduner.system.controller.appadmin.person.cv.AppAdminJobCvRelInviteReqVO;
|
|
|
+import com.citu.module.menduner.system.controller.appadmin.analysis.vo.AppAdminAnalysisReqVO;
|
|
|
import com.citu.module.menduner.system.controller.appadmin.person.hire.AppAdminHireJobCvRelPageReqVO;
|
|
|
import com.citu.module.menduner.system.controller.appadmin.person.hire.AppAdminHireJobCvRelRespVO;
|
|
|
import com.citu.module.menduner.system.controller.base.CommonRespVO;
|
|
@@ -16,18 +17,18 @@ import com.citu.module.menduner.system.controller.base.job.JobCvRelPageReqVO;
|
|
|
import com.citu.module.menduner.system.controller.base.job.JobCvRelSaveReqVO;
|
|
|
import com.citu.module.menduner.system.dal.dataobject.job.JobAdvertisedDO;
|
|
|
import com.citu.module.menduner.system.dal.dataobject.job.JobCvRelDO;
|
|
|
-import com.citu.module.menduner.system.dal.mysql.job.JobAdvertisedMapper;
|
|
|
import com.citu.module.menduner.system.dal.mysql.job.JobCvRelMapper;
|
|
|
import com.citu.module.menduner.system.enums.MendunerStatusEnum;
|
|
|
import com.citu.module.menduner.system.enums.cv.JobCvRelStatusEnum;
|
|
|
-import com.citu.module.menduner.system.service.interview.InterviewInviteService;
|
|
|
+import com.citu.module.menduner.system.enums.eduexp.EducationTypeEnum;
|
|
|
+import com.citu.module.menduner.system.enums.person.PersonSexEnum;
|
|
|
+import com.citu.module.menduner.system.enums.workexp.ExpTypeEnum;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.citu.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
@@ -191,7 +192,7 @@ public class JobCvRelServiceImpl implements JobCvRelService {
|
|
|
|
|
|
@Override
|
|
|
public PageResult<AppHireJobCvRelRespVO> page(AppHireJobCvRelQueryReqVO reqVO) {
|
|
|
- return jobCvRelMapper.page(reqVO,LoginUserContext.getUserId());
|
|
|
+ return jobCvRelMapper.page(reqVO, LoginUserContext.getUserId());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -209,4 +210,157 @@ public class JobCvRelServiceImpl implements JobCvRelService {
|
|
|
public PageResult<AppAdminHireJobCvRelRespVO> page(AppAdminHireJobCvRelPageReqVO reqVO) {
|
|
|
return jobCvRelMapper.page(reqVO);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CommonRespVO> getJobCvSexCount(AppAdminAnalysisReqVO reqVO) {
|
|
|
+ LocalDateTime[] timeRange = generateDateTimeRange(reqVO);
|
|
|
+ List<CommonRespVO> result = jobCvRelMapper.getJobCvSexCount(timeRange[0], timeRange[1]);
|
|
|
+ for (PersonSexEnum value : PersonSexEnum.values()) {
|
|
|
+ CommonRespVO respVO = result.stream()
|
|
|
+ .filter(c -> c.getKey().equals(value.getType())).findFirst().orElse(null);
|
|
|
+ if (null == respVO) {
|
|
|
+ CommonRespVO newResp = new CommonRespVO();
|
|
|
+ newResp.setKey(value.getName());
|
|
|
+ newResp.setValue(0L);
|
|
|
+ result.add(newResp);
|
|
|
+ } else {
|
|
|
+ respVO.setKey(value.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object[]> getJobCvAgeCount(AppAdminAnalysisReqVO reqVO) {
|
|
|
+ LocalDateTime[] timeRange = generateDateTimeRange(reqVO);
|
|
|
+ List<CommonRespVO> result = jobCvRelMapper.getJobCvAgeCount(timeRange[0], timeRange[1]);
|
|
|
+ // 填充
|
|
|
+ String[] ageArr = new String[]{"18-22岁", "23-30岁", "31-39岁", "40-49岁", "50-59岁", "其他年龄段"};
|
|
|
+ for (String age : ageArr) {
|
|
|
+ CommonRespVO respVO = result.stream()
|
|
|
+ .filter(c -> c.getKey().equals(age)).findFirst().orElse(null);
|
|
|
+ if (null == respVO) {
|
|
|
+ CommonRespVO newResp = new CommonRespVO();
|
|
|
+ newResp.setKey(age);
|
|
|
+ newResp.setValue(0L);
|
|
|
+ result.add(newResp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 对 result 的 key 进行排序
|
|
|
+ List<CommonRespVO> sortedResult = result.stream()
|
|
|
+ .sorted(Comparator.comparing(CommonRespVO::getKey))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ // 对result的key进行排序
|
|
|
+ return packBarCount(sortedResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object[]> getJobCvEduCount(AppAdminAnalysisReqVO reqVO) {
|
|
|
+ LocalDateTime[] timeRange = generateDateTimeRange(reqVO);
|
|
|
+ List<CommonRespVO> result = jobCvRelMapper.getJobCvEduCount(timeRange[0], timeRange[1]);
|
|
|
+ // 填充
|
|
|
+ for (EducationTypeEnum value : EducationTypeEnum.values()) {
|
|
|
+ CommonRespVO respVO = result.stream()
|
|
|
+ .filter(c -> c.getKey().equals(value.getType())).findFirst().orElse(null);
|
|
|
+ if (null == respVO) {
|
|
|
+ CommonRespVO newResp = new CommonRespVO();
|
|
|
+ newResp.setKey(value.getName());
|
|
|
+ newResp.setValue(0L);
|
|
|
+ result.add(newResp);
|
|
|
+ } else {
|
|
|
+ respVO.setKey(value.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 对 result 的 key 进行排序
|
|
|
+ List<CommonRespVO> sortedResult = result.stream()
|
|
|
+ .sorted(Comparator.comparing(s->
|
|
|
+ EducationTypeEnum.getEnumByName(s.getKey()).getType())
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return packBarCount(sortedResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object[]> getJobCvExpCount(AppAdminAnalysisReqVO reqVO) {
|
|
|
+ LocalDateTime[] timeRange = generateDateTimeRange(reqVO);
|
|
|
+ List<CommonRespVO> result = jobCvRelMapper.getJobCvExpCount(timeRange[0], timeRange[1]);
|
|
|
+ // 填充
|
|
|
+ for (ExpTypeEnum value : ExpTypeEnum.values()) {
|
|
|
+ CommonRespVO respVO = result.stream()
|
|
|
+ .filter(c -> c.getKey().equals(value.getType())).findFirst().orElse(null);
|
|
|
+ if (null == respVO) {
|
|
|
+ CommonRespVO newResp = new CommonRespVO();
|
|
|
+ newResp.setKey(value.getName());
|
|
|
+ newResp.setValue(0L);
|
|
|
+ result.add(newResp);
|
|
|
+ } else {
|
|
|
+ respVO.setKey(value.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 对 result 的 key 进行排序
|
|
|
+ List<CommonRespVO> sortedResult = result.stream()
|
|
|
+ .sorted(Comparator.comparing(s->
|
|
|
+ EducationTypeEnum.getEnumByName(s.getKey()).getType())
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return packBarCount(sortedResult);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 包装柱状图格式
|
|
|
+ **/
|
|
|
+ public Map<String, Object[]> packBarCount(List<CommonRespVO> result) {
|
|
|
+ if (CollUtil.isEmpty(result)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object[]> map = new LinkedHashMap<>();
|
|
|
+ String[] keys = result.stream()
|
|
|
+ .map(CommonRespVO::getKey)
|
|
|
+ .toArray(String[]::new);
|
|
|
+ map.put("x", keys);
|
|
|
+
|
|
|
+ Object[] values = result.stream()
|
|
|
+ .map(CommonRespVO::getValue)
|
|
|
+ .toArray();
|
|
|
+
|
|
|
+ map.put("y", values);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成时间范围
|
|
|
+ **/
|
|
|
+ public LocalDateTime[] generateDateTimeRange(AppAdminAnalysisReqVO reqVO) {
|
|
|
+ if (AppAdminAnalysisReqVO.TYPE_CUSTOM.equals(reqVO.getType())) {
|
|
|
+ return reqVO.getTime();
|
|
|
+ }
|
|
|
+ LocalDateTime[] dateTimeRange = new LocalDateTime[2];
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ switch (reqVO.getType()) {
|
|
|
+ case AppAdminAnalysisReqVO.TYPE_RECENT_7_DAYS:
|
|
|
+ // 最新7天内
|
|
|
+ dateTimeRange[0] = now.minusDays(7);
|
|
|
+ dateTimeRange[1] = now;
|
|
|
+ break;
|
|
|
+ case AppAdminAnalysisReqVO.TYPE_LAST_MONTH:
|
|
|
+ // 上个月
|
|
|
+ dateTimeRange[0] = now.minusMonths(1).withDayOfMonth(1);
|
|
|
+ dateTimeRange[1] = now.withDayOfMonth(1).minusNanos(1);
|
|
|
+ break;
|
|
|
+ case AppAdminAnalysisReqVO.TYPE_LAST_QUARTER:
|
|
|
+ // 上季度
|
|
|
+ int currentMonth = now.getMonthValue();
|
|
|
+ // 计算上一季度的起始月份
|
|
|
+ int quarterStartMonth = ((currentMonth - 1) / 3) * 3 + 1;
|
|
|
+ int lastQuarterStartMonth = quarterStartMonth - 3;
|
|
|
+ dateTimeRange[0] = now.withMonth(lastQuarterStartMonth).withDayOfMonth(1);
|
|
|
+ dateTimeRange[1] = now.withMonth(quarterStartMonth).withDayOfMonth(1).minusNanos(1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return dateTimeRange;
|
|
|
+ }
|
|
|
}
|