Commit 4553770c authored by 刘斌's avatar 刘斌

feat: 增加在职人员分析

parent 0432fba1
package com.anplus.hr.constant;
/**
* @author 刘斌
* @date 2025/11/25 10:20
*/
public interface HrGenderConstant {
String MALE = "0";
String FEMALE = "1";
String UNKNOWN = "2";
}
package com.anplus.hr.constant;
/**
* @author 刘斌
* @date 2025/11/25 10:23
*/
public interface hrEducationCategoryConstant {
/**
* 专科以下
*/
String UNDER_COLLEGE = "1";
/**
* 专科以下
*/
String JUNIOR_COLLEGE = "2";
/**
* 本科
*/
String BACHELOR = "3";
/**
* 硕士
*/
String POSTGRADUATE = "4";
}
......@@ -40,7 +40,7 @@ public class EmployeeChangeAnalysisCtrl {
/**
* 导出人员变化分析列表
*/
@ExcelExport
@ExcelExport(template = "人员变化分析模板.xlsx", fill = true)
@SaCheckPermission("employee:changeAnalysis:export")
@PinSysLog(value = "人员变化分析", businessType = BusinessType.EXPORT)
@PostMapping("/export")
......
package com.anplus.hr.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.alibaba.cola.dto.MultiResponse;
import com.anplus.hr.domain.params.EmployeeStatusAnalysisListParam;
import com.anplus.hr.domain.vo.EmployeeStatusAnalysisVo;
import com.anplus.hr.service.EmployeeStatusAnalysisServ;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.binfast.common.core.constant.BusinessType;
import top.binfast.common.excel.annotion.ExcelExport;
import top.binfast.common.log.annotation.PinSysLog;
import java.util.List;
/**
* 在职人员情况分析
*
* @author LiuBin
* @date 2025-11-25
*/
//@Validated
@RestController
@RequestMapping("/employee/statusAnalysis")
public class EmployeeStatusAnalysisCtrl {
@Resource
private EmployeeStatusAnalysisServ employeeStatusAnalysisServ;
/**
* 查询在职人员情况分析列表
*/
@SaCheckPermission("employee:statusAnalysis:list")
@GetMapping("/page")
public MultiResponse<EmployeeStatusAnalysisVo> pageList(EmployeeStatusAnalysisListParam param) {
return MultiResponse.of(employeeStatusAnalysisServ.queryList(param));
}
/**
* 导出在职人员情况分析列表
*/
@ExcelExport(template = "在职人员分析模板.xlsx", fill = true)
@SaCheckPermission("employee:statusAnalysis:export")
@PinSysLog(value = "在职人员情况分析", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public List<EmployeeStatusAnalysisVo> export(EmployeeStatusAnalysisListParam param) {
return employeeStatusAnalysisServ.queryList(param);
}
// /**
// * 获取在职人员情况分析详细信息
// *
// * @param id 主键
// */
// @SaCheckPermission("employee:employeeStatusAnalysis:query")
// @GetMapping("/{id}")
// public SingleResponse<EmployeeStatusAnalysisVo> getDetail(@PathVariable @Min(1)
// Long id) {
// return SingleResponse.of(employeeStatusAnalysisServ.queryById(id));
// }
//
// /**
// * 新增在职人员情况分析
// */
// @SaCheckPermission("employee:employeeStatusAnalysis:add")
// @PinSysLog(value = "在职人员情况分析", businessType = BusinessType.INSERT)
// @PostMapping()
// public Response add(@Validated(AddGroup.class) @RequestBody EmployeeStatusAnalysisParam param) {
// return ResponseUtils.ofResult(employeeStatusAnalysisServ.insertByParam(param));
// }
//
// /**
// * 修改在职人员情况分析
// */
// @SaCheckPermission("employee:employeeStatusAnalysis:edit")
// @PinSysLog(value = "在职人员情况分析", businessType = BusinessType.UPDATE)
// @PutMapping()
// public Response edit(@Validated(EditGroup.class) @RequestBody EmployeeStatusAnalysisParam param) {
// return ResponseUtils.ofResult(employeeStatusAnalysisServ.updateByParam(param));
// }
//
// /**
// * 删除在职人员情况分析
// *
// * @param ids 主键串
// */
// @SaCheckPermission("employee:employeeStatusAnalysis:remove")
// @PinSysLog(value = "在职人员情况分析", businessType = BusinessType.DELETE)
// @DeleteMapping("/{ids}")
// public Response remove(@NotEmpty(message = "主键不能为空")
// @PathVariable Long[] ids) {
// return ResponseUtils.ofResult(employeeStatusAnalysisServ.delByIds(List.of(ids)));
// }
}
\ No newline at end of file
package com.anplus.hr.domain.params;
import lombok.Getter;
import lombok.Setter;
import java.util.HashMap;
import java.util.Map;
/**
* 在职人员情况分析分页对象 employee_status_analysis
*
* @author LiuBin
* @date 2025-11-25
*/
@Getter
@Setter
public class EmployeeStatusAnalysisListParam {
/**
* 公司
*/
private String plate;
// /**
// * 总人数
// */
// private Integer totalCount;
//
/// / /**
/// / * 男性人数
/// / */
/// / private Integer maleCount;
/// /
/// / /**
/// / * 女性人数
/// / */
/// / private Integer femaleCount;
/// /
/// / /**
/// / * 24岁以下人数
/// / */
/// / private Integer under24Count;
/// /
/// / /**
/// / * 25-34岁人数
/// / */
/// / private Integer age25To34Count;
/// /
/// / /**
/// / * 35-44岁人数
/// / */
/// / private Integer age35To44Count;
/// /
/// / /**
/// / * 45岁以上人数
/// / */
/// / private Integer over45Count;
/// /
/// / /**
/// / * 专科以下人数
/// / */
/// / private Integer belowCollegeCount;
/// /
/// / /**
/// / * 专科人数
/// / */
/// / private Integer collegeCount;
/// /
/// / /**
/// / * 本科人数
/// / */
/// / private Integer bachelorCount;
/// /
/// / /**
/// / * 硕士人数
/// / */
/// / private Integer masterCount;
/// /
/// / /**
/// / * 小于2年人数
/// / */
/// / private Integer lessThan2YearsCount;
/// /
/// / /**
/// / * 2年到5年人数
/// / */
/// / private Integer years2To5Count;
/// /
/// / /**
/// / * 5年到10年人数
/// / */
/// / private Integer years5To10Count;
/// /
/// / /**
/// / * 10年以上人数
/// / */
/// / private Integer over10YearsCount;
/// /
/// / /**
/// / * 男性占比
/// / */
/// / private BigDecimal maleRatio;
/// /
/// / /**
/// / * 女性占比
/// / */
/// / private BigDecimal femaleRatio;
/// /
/// / /**
/// / * 24岁以下占比
/// / */
/// / private BigDecimal under24Ratio;
/// /
/// / /**
/// / * 25-34岁占比
/// / */
/// / private BigDecimal age25To34Ratio;
/// /
/// / /**
/// / * 35-44岁占比
/// / */
/// / private BigDecimal age35To44Ratio;
/// /
/// / /**
/// / * 45岁以上占比
/// / */
/// / private BigDecimal over45Ratio;
/// /
/// / /**
/// / * 专科以下占比
/// / */
/// / private BigDecimal belowCollegeRatio;
/// /
/// / /**
/// / * 专科占比
/// / */
/// / private BigDecimal collegeRatio;
/// /
/// / /**
/// / * 本科占比
/// / */
/// / private BigDecimal bachelorRatio;
/// /
/// / /**
/// / * 硕士占比
/// / */
/// / private BigDecimal masterRatio;
/// /
/// / /**
/// / * 小于2年占比
/// / */
/// / private BigDecimal lessThan2YearsRatio;
/// /
/// / /**
/// / * 2年到5年占比
/// / */
/// / private BigDecimal years2To5Ratio;
/// /
/// / /**
/// / * 5年到10年占比
/// / */
/// / private BigDecimal years5To10Ratio;
/// /
/// / /**
/// / * 10年以上占比
/// / */
/// / private BigDecimal over10YearsRatio;
private Map<String, Object> params = new HashMap<>();
}
......@@ -138,4 +138,18 @@ public class EmployeeChangeAnalysisVo implements Serializable {
private String totalResignationRate;
public EmployeeChangeAnalysisVo(String plate) {
this.plate = plate;
this.beginningCount = 0;
this.entryCount = 0;
this.regularCount = 0;
this.transferIn = 0;
this.transferOut = 0;
this.probationPeriod = 0;
this.within3Years = 0;
this.over3Years = 0;
this.passiveResignation = 0;
this.totalResignation = 0;
this.endingCount = 0;
}
}
package com.anplus.hr.domain.vo;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.lang.String;
/**
* 在职人员情况分析视图对象 employee_status_analysis
*
* @author LiuBin
* @date 2025-11-25
*/
@Data
@ExcelIgnoreUnannotated
//@AutoMapper(target = EmployeeStatusAnalysis.class)
public class EmployeeStatusAnalysisVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Long id;
/**
* 公司
*/
@ExcelProperty(value = "公司")
private String plate;
/**
* 总人数
*/
@ExcelProperty(value = "总人数")
private Integer totalCount;
/**
* 男性人数
*/
@ExcelProperty(value = "男性人数")
private Integer maleCount;
/**
* 女性人数
*/
@ExcelProperty(value = "女性人数")
private Integer femaleCount;
/**
* 24岁以下人数
*/
@ExcelProperty(value = "24岁以下人数")
private Integer under24Count;
/**
* 25-34岁人数
*/
@ExcelProperty(value = "25-34岁人数")
private Integer age25To34Count;
/**
* 35-44岁人数
*/
@ExcelProperty(value = "35-44岁人数")
private Integer age35To44Count;
/**
* 45岁以上人数
*/
@ExcelProperty(value = "45岁以上人数")
private Integer over45Count;
/**
* 专科以下人数
*/
@ExcelProperty(value = "专科以下人数")
private Integer belowCollegeCount;
/**
* 专科人数
*/
@ExcelProperty(value = "专科人数")
private Integer juniorCollegeCount;
/**
* 本科人数
*/
@ExcelProperty(value = "本科人数")
private Integer bachelorCount;
/**
* 硕士人数
*/
@ExcelProperty(value = "硕士人数")
private Integer postgraduateCount;
/**
* 小于2年人数
*/
@ExcelProperty(value = "小于2年人数")
private Integer lessThan2YearsCount;
/**
* 2年到5年人数
*/
@ExcelProperty(value = "2年到5年人数")
private Integer years2To5Count;
/**
* 5年到10年人数
*/
@ExcelProperty(value = "5年到10年人数")
private Integer years5To10Count;
/**
* 10年以上人数
*/
@ExcelProperty(value = "10年以上人数")
private Integer over10YearsCount;
/**
* 男性占比
*/
@ExcelProperty(value = "男性占比")
private String maleRatio;
/**
* 女性占比
*/
@ExcelProperty(value = "女性占比")
private String femaleRatio;
/**
* 24岁以下占比
*/
@ExcelProperty(value = "24岁以下占比")
private String under24Ratio;
/**
* 25-34岁占比
*/
@ExcelProperty(value = "25-34岁占比")
private String age25To34Ratio;
/**
* 35-44岁占比
*/
@ExcelProperty(value = "35-44岁占比")
private String age35To44Ratio;
/**
* 45岁以上占比
*/
@ExcelProperty(value = "45岁以上占比")
private String over45Ratio;
/**
* 专科以下占比
*/
@ExcelProperty(value = "专科以下占比")
private String belowCollegeRatio;
/**
* 专科占比
*/
@ExcelProperty(value = "专科占比")
private String juniorCollegeRatio;
/**
* 本科占比
*/
@ExcelProperty(value = "本科占比")
private String bachelorRatio;
/**
* 硕士占比
*/
@ExcelProperty(value = "硕士占比")
private String postgraduateRatio;
/**
* 小于2年占比
*/
@ExcelProperty(value = "小于2年占比")
private String lessThan2YearsRatio;
/**
* 2年到5年占比
*/
@ExcelProperty(value = "2年到5年占比")
private String years2To5Ratio;
/**
* 5年到10年占比
*/
@ExcelProperty(value = "5年到10年占比")
private String years5To10Ratio;
/**
* 10年以上占比
*/
@ExcelProperty(value = "10年以上占比")
private String over10YearsRatio;
public EmployeeStatusAnalysisVo(String plate) {
this.plate = plate;
this.totalCount = 0;
this.maleCount = 0;
this.femaleCount = 0;
this.under24Count = 0;
this.age25To34Count = 0;
this.age35To44Count = 0;
this.over45Count = 0;
this.belowCollegeCount = 0;
this.juniorCollegeCount = 0;
this.bachelorCount = 0;
this.postgraduateCount = 0;
this.lessThan2YearsCount = 0;
this.years2To5Count = 0;
this.years5To10Count = 0;
this.over10YearsCount = 0;
}
}
......@@ -2,6 +2,7 @@ package com.anplus.hr.mapper;
import com.anplus.hr.domain.EmployeeInfo;
import com.anplus.hr.domain.vo.EmployeeChangeAnalysisVo;
import com.anplus.hr.domain.vo.EmployeeStatusAnalysisVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import top.binfast.common.mybatis.datascope.annotation.DataColumn;
......@@ -26,4 +27,10 @@ public interface EmployeeInfoMapper extends BinBaseMapper<EmployeeInfo> {
})
List<EmployeeChangeAnalysisVo> queryChangeAnalysisList(@Param("beginTime") String beginTime, @Param("endTime") String endTime);
@DataPermission(type = DeptDataScope.DATA_SCOPE_TYPE, value = {
@DataColumn(key = DeptDataScope.DEPT_DATA_SCOPE_KEY, value = "t.dept_id"),
@DataColumn(key = DeptDataScope.USER_DATA_SCOPE_KEY, value = "t.create_by")
})
List<EmployeeStatusAnalysisVo> queryStatusAnalysisList();
}
......@@ -51,7 +51,7 @@ public interface EmployeeChangeLogServ extends IService<EmployeeChangeLog> {
* @param changeType 变更类型
* @return 是否新增成功
*/
Boolean insertByEmployee(EmployeeInfo employeeInfo, LocalDate changeDate, String changeType);
Boolean insertByEmployee(String applyCode, EmployeeInfo employeeInfo, LocalDate changeDate, String changeType);
/**
* 新增员工异动记录
......
package com.anplus.hr.service;
import com.anplus.hr.domain.params.EmployeeStatusAnalysisListParam;
import com.anplus.hr.domain.vo.EmployeeStatusAnalysisVo;
import java.util.List;
/**
* 在职人员情况分析Service接口
*
* @author LiuBin
* @date 2025-11-25
*/
public interface EmployeeStatusAnalysisServ {
// /**
// * 分页查询在职人员情况分析列表
// *
// * @param param 查询条件
// * @return 在职人员情况分析分页列表
// */
// PageResponse<EmployeeStatusAnalysisVo> queryPageList(EmployeeStatusAnalysisListParam param);
/**
* 查询符合条件的在职人员情况分析列表
*
* @param param 查询条件
* @return 在职人员情况分析列表
*/
List<EmployeeStatusAnalysisVo> queryList(EmployeeStatusAnalysisListParam param);
// /**
// * 查询在职人员情况分析
// *
// * @param id 主键
// * @return 在职人员情况分析
// */
// EmployeeStatusAnalysisVo queryById(Long id);
//
// /**
// * 新增在职人员情况分析
// *
// * @param param 在职人员情况分析
// * @return 是否新增成功
// */
// Boolean insertByParam(EmployeeStatusAnalysisParam param);
//
// /**
// * 修改在职人员情况分析
// *
// * @param param 在职人员情况分析
// * @return 是否修改成功
// */
// Boolean updateByParam(EmployeeStatusAnalysisParam param);
//
// /**
// * 校验并批量删除在职人员情况分析信息
// *
// * @param ids 待删除的主键集合
// * @return 是否删除成功
// */
// Boolean delByIds(List<Long> ids);
}
......@@ -8,6 +8,7 @@ import com.anplus.hr.mapper.EmployeeInfoMapper;
import com.anplus.hr.service.EmployeeChangeAnalysisServ;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
import top.binfast.common.core.exception.PlatformException;
......@@ -57,6 +58,8 @@ public class EmployeeChangeAnalysisServImpl extends ServiceImpl<EmployeeInfoMapp
}
List<EmployeeChangeAnalysisVo> analysisVoList = employeeInfoMapper.queryChangeAnalysisList(param.getBeginTime(), param.getEndTime());
if (!analysisVoList.isEmpty()) {
EmployeeChangeAnalysisVo sumVo = getChangeAnalysisSumVo(analysisVoList);
analysisVoList.add(sumVo);
for (EmployeeChangeAnalysisVo analysisVo : analysisVoList) {
analysisVo.setProbationResignationRate(calcResignationRate(analysisVo.getProbationPeriod(), analysisVo.getEndingCount()));
analysisVo.setWithin3YearsResignationRate(calcResignationRate(analysisVo.getWithin3Years(), analysisVo.getEndingCount()));
......@@ -68,7 +71,29 @@ public class EmployeeChangeAnalysisServImpl extends ServiceImpl<EmployeeInfoMapp
return analysisVoList;
}
@NotNull
private static EmployeeChangeAnalysisVo getChangeAnalysisSumVo(List<EmployeeChangeAnalysisVo> analysisVoList) {
EmployeeChangeAnalysisVo sumVo = new EmployeeChangeAnalysisVo("合计");
for (EmployeeChangeAnalysisVo changeAnalysisVo : analysisVoList) {
sumVo.setBeginningCount(sumVo.getBeginningCount() + changeAnalysisVo.getBeginningCount());
sumVo.setEntryCount(sumVo.getEntryCount() + changeAnalysisVo.getEntryCount());
sumVo.setRegularCount(sumVo.getRegularCount() + changeAnalysisVo.getRegularCount());
sumVo.setTransferIn(sumVo.getTransferIn() + changeAnalysisVo.getTransferIn());
sumVo.setTransferOut(sumVo.getTransferOut() + changeAnalysisVo.getTransferOut());
sumVo.setProbationPeriod(sumVo.getProbationPeriod() + changeAnalysisVo.getProbationPeriod());
sumVo.setWithin3Years(sumVo.getWithin3Years() + changeAnalysisVo.getWithin3Years());
sumVo.setOver3Years(sumVo.getOver3Years() + changeAnalysisVo.getOver3Years());
sumVo.setPassiveResignation(sumVo.getPassiveResignation() + changeAnalysisVo.getPassiveResignation());
sumVo.setTotalResignation(sumVo.getTotalResignation() + changeAnalysisVo.getTotalResignation());
sumVo.setEndingCount(sumVo.getEndingCount() + changeAnalysisVo.getEndingCount());
}
return sumVo;
}
private String calcResignationRate(Integer count, Integer total) {
if (count == null || count == 0 || total == null || total == 0) {
return "0.00%";
}
String rate = new BigDecimal(count).divide(new BigDecimal(total + count), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP).toString();
return rate + "%";
}
......
......@@ -104,7 +104,7 @@ public class EmployeeChangeLogServImpl extends ServiceImpl<EmployeeChangeLogMapp
}
@Override
public Boolean insertByEmployee(EmployeeInfo employeeInfo, LocalDate changeDate, String changeType) {
public Boolean insertByEmployee(String applyCode, EmployeeInfo employeeInfo, LocalDate changeDate, String changeType) {
SysDeptDTO childDept = sysDeptServ.selectDeptById(employeeInfo.getDeptId());
List<String> split = StrUtil.splitTrim(childDept.getNodePath(), '/');
if (split.size() < 2) {
......@@ -115,6 +115,7 @@ public class EmployeeChangeLogServImpl extends ServiceImpl<EmployeeChangeLogMapp
// List<EmployeeChangeLog> changeLogList = new ArrayList<>();
// for (String changeType : changeTypes) {
EmployeeChangeLog changeLog = new EmployeeChangeLog();
changeLog.setApplyCode(applyCode);
changeLog.setEmployeeId(employeeInfo.getId());
changeLog.setDeptId(employeeInfo.getDeptId());
changeLog.setPlateId(parentDeptId);
......
......@@ -299,7 +299,7 @@ public class EmployeeFlowServImpl extends ServiceImpl<EmployeeFlowMapper, Employ
employeeInfo.setEntryDate(LocalDateTimeUtil.parseDate(auditLog.getAfterVal(), DatePattern.NORM_DATE_PATTERN));
}
}
employeeChangeLogServ.insertByEmployee(employeeInfo, employeeInfo.getEntryDate(), EmployeeChangeLogTypeConstant.Entry);
employeeChangeLogServ.insertByEmployee(employeeFlow.getApplyCode(), employeeInfo, employeeInfo.getEntryDate(), EmployeeChangeLogTypeConstant.Entry);
break;
case HrFlowTypeConstant.REGULARIZATION_CODE:
// 转正流程结束
......@@ -353,7 +353,7 @@ public class EmployeeFlowServImpl extends ServiceImpl<EmployeeFlowMapper, Employ
break;
}
}
employeeChangeLogServ.insertByEmployee(employeeInfo, employeeInfo.getRegularizationDate(), EmployeeChangeLogTypeConstant.Regularization);
employeeChangeLogServ.insertByEmployee(employeeFlow.getApplyCode(), employeeInfo, employeeInfo.getRegularizationDate(), EmployeeChangeLogTypeConstant.Regularization);
break;
case HrFlowTypeConstant.RESIGN_CODE:
// 离职流程结束
......@@ -377,7 +377,7 @@ public class EmployeeFlowServImpl extends ServiceImpl<EmployeeFlowMapper, Employ
break;
}
}
employeeChangeLogServ.insertByEmployee(employeeInfo, employeeInfo.getResignationDate(), EmployeeChangeLogTypeConstant.Resign);
employeeChangeLogServ.insertByEmployee(employeeFlow.getApplyCode(), employeeInfo, employeeInfo.getResignationDate(), EmployeeChangeLogTypeConstant.Resign);
break;
case HrFlowTypeConstant.TRANSFER_CODE:
// 调配流程结束
......@@ -410,8 +410,8 @@ public class EmployeeFlowServImpl extends ServiceImpl<EmployeeFlowMapper, Employ
break;
}
}
employeeChangeLogServ.insertByEmployee(oldEmployeeInfo, transferDate, EmployeeChangeLogTypeConstant.TransferOut);
employeeChangeLogServ.insertByEmployee(employeeInfo, transferDate, EmployeeChangeLogTypeConstant.TransferIn);
employeeChangeLogServ.insertByEmployee(employeeFlow.getApplyCode(), oldEmployeeInfo, transferDate, EmployeeChangeLogTypeConstant.TransferOut);
employeeChangeLogServ.insertByEmployee(employeeFlow.getApplyCode(), employeeInfo, transferDate, EmployeeChangeLogTypeConstant.TransferIn);
break;
case HrFlowTypeConstant.RENEWAL_CONTRACT:
// 续签流程结束
......@@ -440,7 +440,7 @@ public class EmployeeFlowServImpl extends ServiceImpl<EmployeeFlowMapper, Employ
break;
}
}
employeeChangeLogServ.insertByEmployee(employeeInfo, employeeInfo.getContractStartDate(), EmployeeChangeLogTypeConstant.RenewalContract);
employeeChangeLogServ.insertByEmployee(employeeFlow.getApplyCode(), employeeInfo, employeeInfo.getContractStartDate(), EmployeeChangeLogTypeConstant.RenewalContract);
break;
default: {
// 其他流程结束
......
......@@ -64,4 +64,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY t.plate_id;
]]>
</select>
<select id="queryStatusAnalysisList" resultType="com.anplus.hr.domain.vo.EmployeeStatusAnalysisVo">
SELECT
plate,
-- 总人数
COUNT(1) AS totalCount,
-- 性别统计
SUM(IF(gender = ${@com.anplus.hr.constant.HrGenderConstant@MALE}, 1, 0)) AS maleCount,
SUM(IF(gender = ${@com.anplus.hr.constant.HrGenderConstant@FEMALE}, 1, 0)) AS femaleCount,
-- 年龄段统计
SUM(IF(age_group = ${@com.anplus.hr.constant.HrAgeGroupEnum@UNDER_24.getCode()}, 1, 0)) AS under24Count,
SUM(IF(age_group = ${@com.anplus.hr.constant.HrAgeGroupEnum@AGE_25_TO_34.getCode()}, 1, 0)) AS age25To34Count,
SUM(IF(age_group = ${@com.anplus.hr.constant.HrAgeGroupEnum@AGE_35_TO_44.getCode()}, 1, 0)) AS age35To44Count,
SUM(IF(age_group = ${@com.anplus.hr.constant.HrAgeGroupEnum@OVER_45.getCode()}, 1, 0)) AS over45Count,
-- 学历统计(基于最高学历)
SUM(IF(education_category = ${@com.anplus.hr.constant.hrEducationCategoryConstant@UNDER_COLLEGE}, 1, 0)) AS belowCollegeCount,
SUM(IF(education_category = ${@com.anplus.hr.constant.hrEducationCategoryConstant@JUNIOR_COLLEGE}, 1, 0)) AS juniorCollegeCount,
SUM(IF(education_category = ${@com.anplus.hr.constant.hrEducationCategoryConstant@BACHELOR}, 1, 0)) AS bachelorCount,
SUM(IF(education_category = ${@com.anplus.hr.constant.hrEducationCategoryConstant@POSTGRADUATE}, 1, 0)) AS postgraduateCount,
-- 工龄统计
SUM(IF(years_of_service_segment = ${@com.anplus.hr.constant.HrYearsOfServiceSegmentEnum@UNDER_TWO.getCode()}, 1, 0)) AS lessThan2YearsCount,
SUM(IF(years_of_service_segment = ${@com.anplus.hr.constant.HrYearsOfServiceSegmentEnum@TWO_TO_FIVE.getCode()}, 1, 0)) AS years2To5Count,
SUM(IF(years_of_service_segment = ${@com.anplus.hr.constant.HrYearsOfServiceSegmentEnum@FIVE_TO_TEN.getCode()}, 1, 0)) AS years5To10Count,
SUM(IF(years_of_service_segment = ${@com.anplus.hr.constant.HrYearsOfServiceSegmentEnum@OVER_TEN.getCode()}, 1, 0)) AS over10YearsCount
FROM employee_info
WHERE status in (1, 2) -- 只统计在职员工
GROUP BY plate
ORDER BY plate;
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment