Commit 0432fba1 authored by 刘斌's avatar 刘斌

feat: 增加人员变动分析

parent bd1dc723
......@@ -80,4 +80,14 @@ public interface HrConstant {
* 员工离职类型
*/
String HR_RESIGNATION_TYPE = "hr_resignation_type";
/**
* 员工离职工龄段
*/
String HR_RESIGN_YEARS_OF_SERVICE_TYPE = "hr_resign_years_of_service_type";
/**
* 员工异动类型
*/
String HR_CHANGE_LOG_TYPE = "hr_change_log_type";
}
package com.anplus.hr.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.alibaba.cola.dto.MultiResponse;
import com.anplus.hr.domain.params.EmployeeChangeAnalysisListParam;
import com.anplus.hr.domain.vo.EmployeeChangeAnalysisVo;
import com.anplus.hr.service.EmployeeChangeAnalysisServ;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
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-23
*/
@Validated
@RestController
@RequestMapping("/employee/changeAnalysis")
public class EmployeeChangeAnalysisCtrl {
@Resource
private EmployeeChangeAnalysisServ employeeChangeAnalysisServ;
/**
* 查询人员变化分析列表
*/
@SaCheckPermission("employee:changeAnalysis:list")
@GetMapping("/page")
public MultiResponse<EmployeeChangeAnalysisVo> pageList(EmployeeChangeAnalysisListParam param) {
return MultiResponse.of(employeeChangeAnalysisServ.queryList(param));
}
/**
* 导出人员变化分析列表
*/
@ExcelExport
@SaCheckPermission("employee:changeAnalysis:export")
@PinSysLog(value = "人员变化分析", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public List<EmployeeChangeAnalysisVo> export(EmployeeChangeAnalysisListParam param) {
return employeeChangeAnalysisServ.queryList(param);
}
// /**
// * 获取人员变化分析详细信息
// *
// * @param id 主键
// */
// @SaCheckPermission("hr:changeAnalysis:query")
// @GetMapping("/{id}")
// public SingleResponse<EmployeeChangeAnalysisVo> getDetail(@PathVariable @Min(1)
// Long id) {
// return SingleResponse.of(employeeChangeAnalysisServ.queryById(id));
// }
//
// /**
// * 新增人员变化分析
// */
// @SaCheckPermission("hr:changeAnalysis:add")
// @PinSysLog(value = "人员变化分析", businessType = BusinessType.INSERT)
// @PostMapping()
// public Response add(@Validated(AddGroup.class) @RequestBody EmployeeChangeAnalysisParam param) {
// return ResponseUtils.ofResult(employeeChangeAnalysisServ.insertByParam(param));
// }
//
// /**
// * 修改人员变化分析
// */
// @SaCheckPermission("hr:changeAnalysis:edit")
// @PinSysLog(value = "人员变化分析", businessType = BusinessType.UPDATE)
// @PutMapping()
// public Response edit(@Validated(EditGroup.class) @RequestBody EmployeeChangeAnalysisParam param) {
// return ResponseUtils.ofResult(employeeChangeAnalysisServ.updateByParam(param));
// }
//
// /**
// * 删除人员变化分析
// *
// * @param ids 主键串
// */
// @SaCheckPermission("hr:changeAnalysis:remove")
// @PinSysLog(value = "人员变化分析", businessType = BusinessType.DELETE)
// @DeleteMapping("/{ids}")
// public Response remove(@NotEmpty(message = "主键不能为空")
// @PathVariable Long[] ids) {
// return ResponseUtils.ofResult(employeeChangeAnalysisServ.delByIds(List.of(ids)));
// }
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ import java.time.LocalDateTime;
import java.io.Serial;
/**
* 员工动记录对象 employee_change_log
* 员工动记录对象 employee_change_log
*
* @author LiuBin
* @date 2025-11-17
......@@ -27,7 +27,7 @@ public class EmployeeChangeLog extends TenantModel {
private static final long serialVersionUID = 1L;
/**
* 动类型
* 动类型
*/
private String type;
......@@ -57,7 +57,7 @@ public class EmployeeChangeLog extends TenantModel {
private Long employeeId;
/**
* 动时间
* 动时间
*/
private LocalDate changeDate;
......
package com.anplus.hr.domain.params;
import lombok.Getter;
import lombok.Setter;
import java.util.HashMap;
import java.util.Map;
/**
* 人员变化分析分页对象 employee_change_analysis
*
* @author LiuBin
* @date 2025-11-23
*/
@Getter
@Setter
public class EmployeeChangeAnalysisListParam {
/**
* 板块
*/
private String plate;
/**
* 板块ID
*/
private String plateId;
/**
* 开始时间
*/
private String beginTime;
/**
* 结束时间
*/
private String endTime;
// /**
// * 期初人数
// */
// private Integer beginningCount;
//
// /**
// * 入职人数
// */
// private Integer entryCount;
//
// /**
// * 转正人数
// */
// private Integer regularCount;
//
// /**
// * 转入
// */
// private Integer transferIn;
//
// /**
// * 转出
// */
// private Integer transferOut;
//
// /**
// * 试用期内
// */
// private Integer probationPeriod;
//
// /**
// * 入职3年内
// */
// private Integer within3Years;
//
// /**
// * 入职3年以上
// */
// private Integer over3Years;
//
// /**
// * 被动离职
// */
// private Integer passiveResignation;
//
// /**
// * 总离职
// */
// private Integer totalResignation;
//
// /**
// * 期末人数
// */
// private Integer endingCount;
//
// /**
// * 试用期内离职率
// */
// private BigDecimal probationResignationRate;
//
// /**
// * 入职3年内离职率
// */
// private BigDecimal within3YearsResignationRate;
//
// /**
// * 入职3年以上离职率
// */
// private BigDecimal over3YearsResignationRate;
//
// /**
// * 被动离职率
// */
// private BigDecimal passiveResignationRate;
//
// /**
// * 总离职率
// */
// private BigDecimal totalResignationRate;
private Map<String, Object> params = new HashMap<>();
}
......@@ -3,25 +3,38 @@ package com.anplus.hr.domain.params;
import lombok.Getter;
import lombok.Setter;
import top.binfast.common.core.bean.params.PageQueryParam;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import java.time.LocalDateTime;
;
/**
* 员工动记录分页对象 employee_change_log
* 员工动记录分页对象 employee_change_log
*
* @author LiuBin
* @date 2025-11-17
* @date 2025-11-24
*/
@Getter
@Setter
public class EmployeeChangeLogListParam extends PageQueryParam {
/**
* 动类型
* 动类型
*/
private String type;
/**
* 流程申请编号
*/
private String applyCode;
/**
* 板块ID
*/
private Long plateId;
/**
* 板块
*/
......@@ -38,9 +51,9 @@ public class EmployeeChangeLogListParam extends PageQueryParam {
private Long employeeId;
/**
* 动时间
* 动时间
*/
private LocalDateTime changeDate;
private LocalDate changeDate;
/**
* 离职类型
......
package com.anplus.hr.domain.params;
import cn.idev.excel.annotation.ExcelProperty;
import com.anplus.hr.domain.EmployeeChangeLog;
import top.binfast.common.core.validate.AddGroup;
import top.binfast.common.core.validate.EditGroup;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import jakarta.validation.constraints.*;
import java.time.LocalDateTime;;
import top.binfast.common.core.validate.AddGroup;
import top.binfast.common.core.validate.EditGroup;
import java.time.LocalDate;
;
/**
* 员工动记录业务对象 employee_change_log
* 员工动记录业务对象 employee_change_log
*
* @author LiuBin
* @date 2025-11-17
* @date 2025-11-24
*/
@Data
@AutoMapper(target = EmployeeChangeLog.class, reverseConvertGenerate = false)
......@@ -26,14 +29,27 @@ public class EmployeeChangeLogParam {
private Long id;
/**
* 动类型
* 动类型
*/
@NotBlank(message = "动类型不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "动类型不能为空", groups = { AddGroup.class, EditGroup.class })
private String type;
/**
* 流程申请编号
*/
@NotBlank(message = "流程申请编号不能为空", groups = { AddGroup.class, EditGroup.class })
private String applyCode;
/**
* 板块ID
*/
@NotNull(message = "板块ID不能为空", groups = { AddGroup.class, EditGroup.class })
private Long plateId;
/**
* 板块
*/
@NotBlank(message = "板块不能为空", groups = { AddGroup.class, EditGroup.class })
private String plate;
/**
......@@ -49,10 +65,10 @@ public class EmployeeChangeLogParam {
private Long employeeId;
/**
* 动时间
* 动时间
*/
@NotNull(message = "动时间不能为空", groups = { AddGroup.class, EditGroup.class })
private LocalDateTime changeDate;
@NotNull(message = "动时间不能为空", groups = { AddGroup.class, EditGroup.class })
private LocalDate changeDate;
/**
* 离职类型
......
package com.anplus.hr.domain.vo;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 人员变化分析视图对象 employee_change_analysis
*
* @author LiuBin
* @date 2025-11-23
*/
@Data
@ExcelIgnoreUnannotated
//@AutoMapper(target = EmployeeChangeAnalysis.class)
public class EmployeeChangeAnalysisVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Long id;
/**
* 板块
*/
@ExcelProperty(value = "公司")
private String plate;
/**
* 板块ID
*/
@ExcelIgnore
private String plateId;
/**
* 期初人数
*/
@ExcelProperty(value = "期初人数")
private Integer beginningCount;
/**
* 入职人数
*/
@ExcelProperty(value = "入职人数")
private Integer entryCount;
/**
* 转正人数
*/
@ExcelProperty(value = "转正人数")
private Integer regularCount;
/**
* 转入
*/
@ExcelProperty(value = {"异动人数", "调入"})
private Integer transferIn;
/**
* 转出
*/
@ExcelProperty(value = {"异动人数", "调出"})
private Integer transferOut;
/**
* 试用期内
*/
@ExcelProperty(value = {"月离职人数", "主动离职", "试用期内(6个月)"})
private Integer probationPeriod;
/**
* 入职3年内
*/
@ExcelProperty(value = {"月离职人数", "主动离职", "入职3年内"})
private Integer within3Years;
/**
* 入职3年以上
*/
@ExcelProperty(value = {"月离职人数", "主动离职", "入职3年以上"})
private Integer over3Years;
/**
* 被动离职
*/
@ExcelProperty(value = {"月离职人数", "被动离职"})
private Integer passiveResignation;
/**
* 总离职
*/
@ExcelProperty(value = {"月离职人数", "总离职"})
private Integer totalResignation;
/**
* 期末人数
*/
@ExcelProperty(value = "期末人数")
private Integer endingCount;
/**
* 试用期内离职率
*/
@ExcelProperty(value = {"月离职率", "主动离职率", "试用期内(6个月)"})
private String probationResignationRate;
/**
* 入职3年内离职率
*/
@ExcelProperty(value = {"月离职率", "主动离职率", "入职3年内离职率"})
private String within3YearsResignationRate;
/**
* 入职3年以上离职率
*/
@ExcelProperty(value = {"月离职率", "主动离职率", "入职3年以上离职率"})
private String over3YearsResignationRate;
/**
* 被动离职率
*/
@ExcelProperty(value = {"月离职率", "被动离职率"})
private String passiveResignationRate;
/**
* 总离职率
*/
@ExcelProperty(value = {"月离职率", "总离职率"})
private String totalResignationRate;
}
package com.anplus.hr.domain.vo;
import java.time.LocalDateTime;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelIgnore;
import com.anplus.hr.constant.HrConstant;
import com.anplus.hr.domain.EmployeeChangeLog;
import top.binfast.common.excel.annotion.ExcelDictFormat;
import top.binfast.common.excel.converters.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import top.binfast.common.excel.annotion.ExcelDictFormat;
import top.binfast.common.excel.converters.ExcelDictConvert;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDate;
/**
* 员工动记录视图对象 employee_change_log
* 员工动记录视图对象 employee_change_log
*
* @author LiuBin
* @date 2025-11-17
* @date 2025-11-24
*/
@Data
@ExcelIgnoreUnannotated
......@@ -35,12 +35,24 @@ public class EmployeeChangeLogVo implements Serializable {
private Long id;
/**
* 动类型
* 动类型
*/
@ExcelProperty(value = "动类型", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "HR_CHANGE_LOG_TYPE")
@ExcelProperty(value = "动类型", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = HrConstant.HR_CHANGE_LOG_TYPE)
private String type;
/**
* 流程申请编号
*/
@ExcelProperty(value = "流程申请编号")
private String applyCode;
/**
* 板块ID
*/
@ExcelProperty(value = "板块ID")
private Long plateId;
/**
* 板块
*/
......@@ -60,23 +72,23 @@ public class EmployeeChangeLogVo implements Serializable {
private Long employeeId;
/**
* 动时间
* 动时间
*/
@ExcelProperty(value = "动时间")
private LocalDateTime changeDate;
@ExcelProperty(value = "动时间")
private LocalDate changeDate;
/**
* 离职类型
*/
@ExcelProperty(value = "离职类型", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "HR_RESIGNATION_TYPE")
@ExcelDictFormat(dictType = HrConstant.HR_RESIGNATION_TYPE)
private String resignType;
/**
* 离职工龄类型
*/
@ExcelProperty(value = "离职工龄类型", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "HR_RESIGN_YEARS_OF_SERVICE_TYPE")
// @ExcelDictFormat(dictType = HrConstant.HR_RESIGN_YEARS_OF_SERVICE_TYPE)
private String resignYearsOfServiceType;
......
package com.anplus.hr.mapper;
import com.anplus.hr.domain.EmployeeInfo;
import com.anplus.hr.domain.vo.EmployeeChangeAnalysisVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import top.binfast.common.mybatis.datascope.annotation.DataColumn;
import top.binfast.common.mybatis.datascope.annotation.DataPermission;
import top.binfast.common.mybatis.datascope.core.DeptDataScope;
import top.binfast.common.mybatis.mapper.BinBaseMapper;
import java.util.List;
/**
* 员工信息Mapper接口
*
......@@ -13,4 +20,10 @@ import top.binfast.common.mybatis.mapper.BinBaseMapper;
@Mapper
public interface EmployeeInfoMapper extends BinBaseMapper<EmployeeInfo> {
@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<EmployeeChangeAnalysisVo> queryChangeAnalysisList(@Param("beginTime") String beginTime, @Param("endTime") String endTime);
}
package com.anplus.hr.service;
import com.alibaba.cola.dto.PageResponse;
import com.anplus.hr.domain.params.EmployeeChangeAnalysisListParam;
import com.anplus.hr.domain.vo.EmployeeChangeAnalysisVo;
import java.util.List;
/**
* 人员变化分析Service接口
*
* @author LiuBin
* @date 2025-11-23
*/
public interface EmployeeChangeAnalysisServ {
// /**
// * 分页查询人员变化分析列表
// *
// * @param param 查询条件
// * @return 人员变化分析分页列表
// */
// PageResponse<EmployeeChangeAnalysisVo> queryPageList(EmployeeChangeAnalysisListParam param);
/**
* 查询符合条件的人员变化分析列表
*
* @param param 查询条件
* @return 人员变化分析列表
*/
List<EmployeeChangeAnalysisVo> queryList(EmployeeChangeAnalysisListParam param);
// /**
// * 查询人员变化分析
// *
// * @param id 主键
// * @return 人员变化分析
// */
// EmployeeChangeAnalysisVo queryById(Long id);
//
// /**
// * 新增人员变化分析
// *
// * @param param 人员变化分析
// * @return 是否新增成功
// */
// Boolean insertByParam(EmployeeChangeAnalysisParam param);
//
// /**
// * 修改人员变化分析
// *
// * @param param 人员变化分析
// * @return 是否修改成功
// */
// Boolean updateByParam(EmployeeChangeAnalysisParam param);
//
// /**
// * 校验并批量删除人员变化分析信息
// *
// * @param ids 待删除的主键集合
// * @return 是否删除成功
// */
// Boolean delByIds(List<Long> ids);
}
package com.anplus.hr.service.impl;
import cn.hutool.core.util.StrUtil;
import com.anplus.hr.domain.EmployeeInfo;
import com.anplus.hr.domain.params.EmployeeChangeAnalysisListParam;
import com.anplus.hr.domain.vo.EmployeeChangeAnalysisVo;
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.springframework.stereotype.Service;
import top.binfast.common.core.exception.PlatformException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
/**
* 人员变化分析Service业务层处理
*
* @author LiuBin
* @date 2025-11-23
*/
@RequiredArgsConstructor
@Service
public class EmployeeChangeAnalysisServImpl extends ServiceImpl<EmployeeInfoMapper, EmployeeInfo> implements EmployeeChangeAnalysisServ {
private final EmployeeInfoMapper employeeInfoMapper;
/**
* 分页查询人员变化分析列表
*
* @param param 查询条件
* @return 人员变化分析分页列表
*/
// @Override
// public PageResponse<EmployeeChangeAnalysisVo> queryPageList(EmployeeChangeAnalysisListParam param) {
// Page<EmployeeChangeAnalysis> page = QueryUtil.getPage(param);
// LambdaQueryWrapper<EmployeeChangeAnalysis> lambdaQuery = this.buildQueryWrapper(param);
// employeeChangeAnalysisMapper.selectPage(page, lambdaQuery);
// return QueryUtil.getPageResponse(page, MapstructUtils.convert(page.getRecords(), EmployeeChangeAnalysisVo.class));
// }
/**
* 查询符合条件的人员变化分析列表
*
* @param param 查询条件
* @return 人员变化分析列表
*/
@Override
public List<EmployeeChangeAnalysisVo> queryList(EmployeeChangeAnalysisListParam param) {
// LambdaQueryWrapper<EmployeeChangeAnalysis> lambdaQuery = this.buildQueryWrapper(param);
// Map<String, Object> params = param.getParams();
if (StrUtil.isBlank(param.getBeginTime()) || StrUtil.isBlank(param.getEndTime())) {
throw new PlatformException("请选择时间范围");
}
List<EmployeeChangeAnalysisVo> analysisVoList = employeeInfoMapper.queryChangeAnalysisList(param.getBeginTime(), param.getEndTime());
if (!analysisVoList.isEmpty()) {
for (EmployeeChangeAnalysisVo analysisVo : analysisVoList) {
analysisVo.setProbationResignationRate(calcResignationRate(analysisVo.getProbationPeriod(), analysisVo.getEndingCount()));
analysisVo.setWithin3YearsResignationRate(calcResignationRate(analysisVo.getWithin3Years(), analysisVo.getEndingCount()));
analysisVo.setOver3YearsResignationRate(calcResignationRate(analysisVo.getOver3Years(), analysisVo.getEndingCount()));
analysisVo.setPassiveResignationRate(calcResignationRate(analysisVo.getPassiveResignation(), analysisVo.getEndingCount()));
analysisVo.setTotalResignationRate(calcResignationRate(analysisVo.getTotalResignation(), analysisVo.getEndingCount()));
}
}
return analysisVoList;
}
private String calcResignationRate(Integer count, Integer total) {
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 + "%";
}
// private LambdaQueryWrapper<EmployeeChangeAnalysis> buildQueryWrapper(EmployeeChangeAnalysisListParam param) {
// LambdaQueryWrapper<EmployeeChangeAnalysis> lambdaQuery = Wrappers.<EmployeeChangeAnalysis>lambdaQuery();
// lambdaQuery.orderByDesc(EmployeeChangeAnalysis::getId);
// lambdaQuery.eq(StrUtil.isNotBlank(param.getPlate()), EmployeeChangeAnalysis::getPlate, param.getPlate());
// lambdaQuery.eq(StrUtil.isNotBlank(param.getPlateId()), EmployeeChangeAnalysis::getPlateId, param.getPlateId());
// lambdaQuery.eq(param.getBeginningCount() != null, EmployeeChangeAnalysis::getBeginningCount, param.getBeginningCount());
// lambdaQuery.eq(param.getEntryCount() != null, EmployeeChangeAnalysis::getEntryCount, param.getEntryCount());
// lambdaQuery.eq(param.getRegularCount() != null, EmployeeChangeAnalysis::getRegularCount, param.getRegularCount());
// lambdaQuery.eq(param.getTransferIn() != null, EmployeeChangeAnalysis::getTransferIn, param.getTransferIn());
// lambdaQuery.eq(param.getTransferOut() != null, EmployeeChangeAnalysis::getTransferOut, param.getTransferOut());
// lambdaQuery.eq(param.getProbationPeriod() != null, EmployeeChangeAnalysis::getProbationPeriod, param.getProbationPeriod());
// lambdaQuery.eq(param.getWithin3Years() != null, EmployeeChangeAnalysis::getWithin3Years, param.getWithin3Years());
// lambdaQuery.eq(param.getOver3Years() != null, EmployeeChangeAnalysis::getOver3Years, param.getOver3Years());
// lambdaQuery.eq(param.getPassiveResignation() != null, EmployeeChangeAnalysis::getPassiveResignation, param.getPassiveResignation());
// lambdaQuery.eq(param.getTotalResignation() != null, EmployeeChangeAnalysis::getTotalResignation, param.getTotalResignation());
// lambdaQuery.eq(param.getEndingCount() != null, EmployeeChangeAnalysis::getEndingCount, param.getEndingCount());
// lambdaQuery.eq(param.getProbationResignationRate() != null, EmployeeChangeAnalysis::getProbationResignationRate, param.getProbationResignationRate());
// lambdaQuery.eq(param.getWithin3YearsResignationRate() != null, EmployeeChangeAnalysis::getWithin3YearsResignationRate, param.getWithin3YearsResignationRate());
// lambdaQuery.eq(param.getOver3YearsResignationRate() != null, EmployeeChangeAnalysis::getOver3YearsResignationRate, param.getOver3YearsResignationRate());
// lambdaQuery.eq(param.getPassiveResignationRate() != null, EmployeeChangeAnalysis::getPassiveResignationRate, param.getPassiveResignationRate());
// lambdaQuery.eq(param.getTotalResignationRate() != null, EmployeeChangeAnalysis::getTotalResignationRate, param.getTotalResignationRate());
// return lambdaQuery;
// }
/**
* 查询人员变化分析
*
* @param id 主键
* @return 人员变化分析
*/
// @Override
// public EmployeeChangeAnalysisVo queryById(Long id){
// EmployeeChangeAnalysis employeeChangeAnalysis = employeeChangeAnalysisMapper.selectById(id);
// return MapstructUtils.convert(employeeChangeAnalysis, EmployeeChangeAnalysisVo.class);
// }
//
// /**
// * 新增人员变化分析
// *
// * @param param 人员变化分析
// * @return 是否新增成功
// */
// @Override
// public Boolean insertByParam(EmployeeChangeAnalysisParam param) {
// EmployeeChangeAnalysis employeeChangeAnalysis = MapstructUtils.convert(param, EmployeeChangeAnalysis.class);
// return this.save(employeeChangeAnalysis);
// }
//
// /**
// * 修改人员变化分析
// *
// * @param param 人员变化分析
// * @return 是否修改成功
// */
// @Override
// public Boolean updateByParam(EmployeeChangeAnalysisParam param) {
// EmployeeChangeAnalysis employeeChangeAnalysis = MapstructUtils.convert(param, EmployeeChangeAnalysis.class);
// return this.updateById(employeeChangeAnalysis);
// }
//
// /**
// * 保存前的数据校验
// */
// private void validEntityBeforeSave(EmployeeChangeAnalysis entity){
// // 做一些数据校验,如唯一约束
// }
//
// /**
// * 校验并批量删除人员变化分析信息
// *
// * @param ids 待删除的主键集合
// * @return 是否删除成功
// */
// @Override
// @Transactional(rollbackFor = {Exception.class})
// public Boolean delByIds(List<Long> ids) {
// //做一些业务上的校验,判断是否需要校验
// return this.removeByIds(ids);
// }
}
......@@ -4,4 +4,64 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.anplus.hr.mapper.EmployeeInfoMapper">
<select id="queryChangeAnalysisList" resultType="com.anplus.hr.domain.vo.EmployeeChangeAnalysisVo">
<![CDATA[
SELECT
t.plate AS plate,
t.plate_id AS plateId,
-- 期初人数:按板块统计期初在职员工数
(SELECT COUNT(1) FROM employee_info
WHERE entry_date IS NOT NULL
AND entry_date <= #{beginTime}
AND (resignation_date IS NULL OR resignation_date > #{beginTime})
AND plate_id = t.plate_id) AS beginningCount,
-- 入职人数:统计本段时间入职员工数
SUM(IF(t.type = ${@com.anplus.hr.constant.EmployeeChangeLogTypeConstant@Entry}, 1, 0)) AS entryCount,
-- 转正人数:统计本段时间转正员工数
SUM(IF(t.type = ${@com.anplus.hr.constant.EmployeeChangeLogTypeConstant@Regularization}, 1, 0)) AS regularCount,
-- 转入:统计本段时间部门转入员工数
SUM(IF(t.type = ${@com.anplus.hr.constant.EmployeeChangeLogTypeConstant@TransferIn}, 1, 0)) AS transferIn,
-- 转出:统计本段时间部门转出员工数
SUM(IF(t.type = ${@com.anplus.hr.constant.EmployeeChangeLogTypeConstant@TransferOut}, 1, 0)) AS transferOut,
-- 离职并试用期内:统计本段时间离职时仍在试用期的员工数
SUM(IF(t.type = ${@com.anplus.hr.constant.EmployeeChangeLogTypeConstant@Resign}
AND t.resign_type = ${@com.anplus.hr.constant.HrResignationTypeConstant@HAND_IN_WORK}
AND t.resign_years_of_service_type = ${@com.anplus.hr.constant.HrResignYearsOfServiceTypeEnum@PROBATION_PERIOD.getCode()}, 1, 0)) AS probationPeriod,
-- 离职并入职3年内:统计本段时间离职时入职3年内的员工数
SUM(IF(t.type = ${@com.anplus.hr.constant.EmployeeChangeLogTypeConstant@Resign}
AND t.resign_type = ${@com.anplus.hr.constant.HrResignationTypeConstant@HAND_IN_WORK}
AND t.resign_years_of_service_type = ${@com.anplus.hr.constant.HrResignYearsOfServiceTypeEnum@UNDER_THREE_YEARS.getCode()}, 1, 0)) AS within3Years,
-- 离职并入职3年以上:统计本段时间离职时入职3年以上的员工数
SUM(IF(t.type = ${@com.anplus.hr.constant.EmployeeChangeLogTypeConstant@Resign}
AND t.resign_type = ${@com.anplus.hr.constant.HrResignationTypeConstant@HAND_IN_WORK}
AND t.resign_years_of_service_type = ${@com.anplus.hr.constant.HrResignYearsOfServiceTypeEnum@OVER_THREE_YEARS.getCode()}, 1, 0)) AS over3Years,
-- 被动离职:统计本段时间被动离职人数
SUM(IF(t.type = ${@com.anplus.hr.constant.EmployeeChangeLogTypeConstant@Resign}
AND t.resign_type = ${@com.anplus.hr.constant.HrResignationTypeConstant@FIRED}, 1, 0)) AS passiveResignation,
-- 总离职:统计本段时间总离职人数
SUM(IF(t.type = ${@com.anplus.hr.constant.EmployeeChangeLogTypeConstant@Resign}, 1, 0)) AS totalResignation,
-- 期末人数:按板块统计期末在职员工数
(SELECT COUNT(1) FROM employee_info
WHERE entry_date IS NOT NULL
AND entry_date <= #{endTime}
AND (resignation_date IS NULL OR resignation_date > #{endTime})
AND plate_id = t.plate_id) AS endingCount
FROM (SELECT * FROM employee_change_log
WHERE change_date >= #{beginTime} AND change_date <= #{endTime}) AS t
GROUP BY t.plate_id, t.plate
ORDER BY t.plate_id;
]]>
</select>
</mapper>
......@@ -18,7 +18,7 @@
<mapstruct-plus.version>1.4.8</mapstruct-plus.version>
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
<therapi-javadoc.version>0.15.0</therapi-javadoc.version>
<binfast.version>1.2.6</binfast.version>
<binfast.version>1.2.7</binfast.version>
<lombok.version>1.18.38</lombok.version>
</properties>
......
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