人事报表导出

This commit is contained in:
mash 2023-02-23 14:37:07 +08:00
parent 0cee91d90a
commit ec2c86e7fe
8 changed files with 207 additions and 16 deletions

View File

@ -11,7 +11,11 @@ import com.ydool.staff.dto.EnterpriseIndicatorsExportDto;
import com.ydool.staff.dto.PersonnelReportExportDto; import com.ydool.staff.dto.PersonnelReportExportDto;
import com.ydool.staff.dto.PersonnelStatementDto; import com.ydool.staff.dto.PersonnelStatementDto;
import com.ydool.staff.excel.EnterpriseIndicatorsExportVO; import com.ydool.staff.excel.EnterpriseIndicatorsExportVO;
import com.ydool.staff.excel.ExcelPersonnel;
import com.ydool.staff.excel.ExcelPersonnelStatement;
import com.ydool.staff.excel.PersonnelReportExportVO; import com.ydool.staff.excel.PersonnelReportExportVO;
import com.ydool.staff.request.ExcelPersonnelStatementRequest;
import com.ydool.staff.request.PersonnelDeleteRequest;
import com.ydool.staff.service.ICompanyNameService; import com.ydool.staff.service.ICompanyNameService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@ -25,6 +29,9 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/** /**
* @Author Zhuyy * @Author Zhuyy
@ -75,8 +82,24 @@ public class PersonnelReportController extends BaseController {
@GetMapping("perStatement") @GetMapping("perStatement")
@ApiOperation(value = "人事信息报表",response = PersonnelStatementDto.class) @ApiOperation(value = "人事信息报表",response = PersonnelStatementDto.class)
@ApiImplicitParam(name = "id",value = "企业id") @ApiImplicitParams({
public AjaxResult perStatement(String id) { @ApiImplicitParam(name = "id",value = "企业id"),
return companyNameService.perStatement(id); @ApiImplicitParam(name = "firstDate",value = "起始时间"),
@ApiImplicitParam(name = "finalDate",value = "最终时间"),
})
public AjaxResult perStatement(String id, String firstDate,String finalDate) {
return AjaxResult.ok().data(companyNameService.perStatement(id, firstDate, finalDate));
}
@GetMapping("getEntityParam")
@ApiOperation(value = "获取人事报表参数名",response = ExcelPersonnelStatement.class)
public AjaxResult getEntityParam(){
return companyNameService.getEntityParam();
}
@PostMapping("export")
@ApiOperation(value = "人事报表导出接口")
public void export(@RequestBody ExcelPersonnelStatementRequest personnelParam, HttpServletResponse response){
companyNameService.export(personnelParam,response);
} }
} }

View File

@ -26,10 +26,10 @@ public class PersonnelStatementDto {
private Integer mechanismNum; private Integer mechanismNum;
@ApiModelProperty(value = "用工计划数") @ApiModelProperty(value = "用工计划数")
private Integer EmploymentNum; private Long EmploymentNum;
@ApiModelProperty(value = "现用工人数") @ApiModelProperty(value = "现用工人数")
private Integer num; private Long num;
@ApiModelProperty(value = "其中:用工计划数") @ApiModelProperty(value = "其中:用工计划数")
private Integer thereIntoNum; private Integer thereIntoNum;

View File

@ -57,4 +57,10 @@ public class Exchange extends BaseEntity{
@ApiModelProperty(value = "数据状态0历史数据 1当前数据") @ApiModelProperty(value = "数据状态0历史数据 1当前数据")
private String state; private String state;
@ApiModelProperty(value = "初审意见")
private String firstTrialRemark;
@ApiModelProperty(value = "终审意见")
private String finalTrialRemark;
} }

View File

@ -0,0 +1,59 @@
package com.ydool.staff.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.alibaba.excel.annotation.write.style.HeadStyle;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
/**
* @author msh
* @version 1.0
* @date 2023/2/23 13:49
*/
@Data
@HeadRowHeight(20)
@ColumnWidth(20)
@HeadStyle(horizontalAlignment = HorizontalAlignment.CENTER)
@ContentStyle(verticalAlignment = VerticalAlignment.CENTER)
public class ExcelPersonnelStatement {
@ExcelProperty(value = "主管部门名称" )
@ApiModelProperty(value = "主管部门名称")
private String competentDeptName;
@ExcelProperty(value = "统一社会信用代码" )
@ApiModelProperty(value = "统一社会信用代码")
private String socialCreditCode;
@ExcelProperty(value = "国有企业名称" )
@ApiModelProperty(value = "国有企业名称")
private String competent;
@ExcelProperty(value = "注册资本" )
@ApiModelProperty(value = "注册资本")
private Integer capital;
@ExcelProperty(value = "内设机构数" )
@ApiModelProperty(value = "内设机构数")
private Integer mechanismNum;
@ExcelProperty(value = "用工计划数" )
@ApiModelProperty(value = "用工计划数")
private Long EmploymentNum;
@ExcelProperty(value = "现用工人数" )
@ApiModelProperty(value = "现用工人数")
private Long num;
@ExcelProperty(value = "其中:用工计划数" )
@ApiModelProperty(value = "其中:用工计划数")
private Integer thereIntoNum;
@ExcelProperty(value = "董监人数" )
@ApiModelProperty(value = "董监人数")
private Integer supervisorsNum;
}

View File

@ -0,0 +1,29 @@
package com.ydool.staff.request;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author msh
* @version 1.0
* @date 2023/2/23 14:01
*/
@Data
public class ExcelPersonnelStatementRequest {
@ApiModelProperty(value = "导出参数")
private String[] prams;
@ApiModelProperty(value = "企业id")
private String id;
@ApiModelProperty(value = "起始时间 例2022-01-01")
private String firstDate;
@ApiModelProperty(value = "最终时间 例2022-12-31")
private String finalDate;
}

View File

@ -3,8 +3,12 @@ package com.ydool.staff.service;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.dto.EnterpriseIndicatorsExportDto; import com.ydool.staff.dto.EnterpriseIndicatorsExportDto;
import com.ydool.staff.dto.PersonnelReportExportDto; import com.ydool.staff.dto.PersonnelReportExportDto;
import com.ydool.staff.dto.PersonnelStatementDto;
import com.ydool.staff.request.ExcelPersonnelStatementRequest;
import com.ydool.staff.request.PersonnelDeleteRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Date;
/** /**
* <p> * <p>
@ -30,6 +34,10 @@ public interface ICompanyNameService {
void exportEnterpriseIndicators(EnterpriseIndicatorsExportDto enterpriseIndicatorsExportVO, HttpServletResponse response); void exportEnterpriseIndicators(EnterpriseIndicatorsExportDto enterpriseIndicatorsExportVO, HttpServletResponse response);
AjaxResult perStatement(String id); PersonnelStatementDto perStatement(String id, String firstDate, String finalDate);
AjaxResult getEntityParam();
void export(ExcelPersonnelStatementRequest personnelParam, HttpServletResponse response);
} }

View File

@ -13,6 +13,7 @@ import com.ydool.staff.entity.*;
import com.ydool.staff.mapper.*; import com.ydool.staff.mapper.*;
import com.ydool.staff.request.AuditRequest; import com.ydool.staff.request.AuditRequest;
import com.ydool.staff.service.IAuditService; import com.ydool.staff.service.IAuditService;
import com.ydool.staff.service.IPersonnelService;
import com.ydool.system.entity.Config; import com.ydool.system.entity.Config;
import com.ydool.system.entity.User; import com.ydool.system.entity.User;
import com.ydool.system.mapper.ConfigMapper; import com.ydool.system.mapper.ConfigMapper;
@ -106,12 +107,15 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
Personnel personnel = personnelMapper.selectById(auditOne.getPersonnelId()); Personnel personnel = personnelMapper.selectById(auditOne.getPersonnelId());
if (ArgsConst.PERSONNEL.equals(auditRequest.getType())){ if (ArgsConst.PERSONNEL.equals(auditRequest.getType())){
personnel.setAuditState(2); personnel.setAuditState(2);
personnel.setFirstTrialRemark(auditRequest.getAuditOpinion());
}else if (ArgsConst.CHANGE.equals(auditRequest.getType())){ }else if (ArgsConst.CHANGE.equals(auditRequest.getType())){
personnel.setChangeAuditState(2); personnel.setChangeAuditState(2);
personnel.setFirstTrialRemark(auditRequest.getAuditOpinion());
} }
personnelMapper.updateById(personnel); personnelMapper.updateById(personnel);
}else if(ArgsConst.EXCHANGE.equals(auditRequest.getType())){ }else if(ArgsConst.EXCHANGE.equals(auditRequest.getType())){
Exchange exchange = exchangeMapper.selectById(auditOne.getPersonnelId()); Exchange exchange = exchangeMapper.selectById(auditOne.getPersonnelId());
exchange.setFirstTrialRemark(auditRequest.getAuditOpinion());
exchange.setAuditState(2); exchange.setAuditState(2);
exchangeMapper.updateById(exchange); exchangeMapper.updateById(exchange);
} }
@ -135,10 +139,12 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
String id = personnelOne.getId(); String id = personnelOne.getId();
personnelOne.setState("2"); personnelOne.setState("2");
if (ArgsConst.PERSONNEL.equals(auditRequest.getType())){ if (ArgsConst.PERSONNEL.equals(auditRequest.getType())){
personnelOne.setFinalTrialRemark(auditRequest.getAuditOpinion());
personnelOne.setAlterationSign("2"); personnelOne.setAlterationSign("2");
personnelOne.setAuditState(3); personnelOne.setAuditState(3);
} }
if (ArgsConst.CHANGE.equals(auditRequest.getType())){ if (ArgsConst.CHANGE.equals(auditRequest.getType())){
personnelOne.setFinalTrialRemark(auditRequest.getAuditOpinion());
personnelOne.setChangeAlterationSign("2"); personnelOne.setChangeAlterationSign("2");
personnelOne.setChangeAuditState(3); personnelOne.setChangeAuditState(3);
} }
@ -151,9 +157,10 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
personnelMiddleMapper.updateById(middle); personnelMiddleMapper.updateById(middle);
}else if (ArgsConst.EXCHANGE.equals(auditRequest.getType())){ }else if (ArgsConst.EXCHANGE.equals(auditRequest.getType())){
Exchange exchange = exchangeMapper.selectOne(new LambdaQueryWrapper<Exchange>().eq(Exchange::getState,"1").eq(Exchange::getId,auditRequest.getPersonnelId())); Exchange exchange = exchangeMapper.selectOne(new LambdaQueryWrapper<Exchange>().eq(Exchange::getState,"1").eq(Exchange::getId,auditRequest.getPersonnelId()));
Personnel personnel = personnelMapper.selectById(exchange.getPersonnelId());
exchange.setAuditState(3); exchange.setAuditState(3);
exchange.setState("0"); exchange.setState("0");
Personnel personnel = personnelMapper.selectById(exchange.getPersonnelId()); exchange.setFinalTrialRemark(auditRequest.getAuditOpinion());
personnel.setCompanyName(exchange.getWillCompanyId()); personnel.setCompanyName(exchange.getWillCompanyId());
personnel.setPresentDept(exchange.getWillDept()); personnel.setPresentDept(exchange.getWillDept());
personnel.setPosition(exchange.getWillPosition()); personnel.setPosition(exchange.getWillPosition());
@ -180,11 +187,12 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
if (update){ if (update){
saveAuditLog(auditRequest.getPersonnelId(),loginId,auditRequest.getType(),"一般初审拒绝",auditRequest.getAuditOpinion()); saveAuditLog(auditRequest.getPersonnelId(),loginId,auditRequest.getType(),"一般初审拒绝",auditRequest.getAuditOpinion());
if (ArgsConst.PERSONNEL.equals(auditRequest.getType())||ArgsConst.CHANGE.equals(auditRequest.getType())){ if (ArgsConst.PERSONNEL.equals(auditRequest.getType())||ArgsConst.CHANGE.equals(auditRequest.getType())){
updateByPer(afterPersonnel.getId(),personnel,auditRequest.getType()); updateByPer(1,afterPersonnel.getId(),personnel,auditRequest.getType(),auditRequest.getAuditOpinion());
} }
if(ArgsConst.EXCHANGE.equals(auditRequest.getType())){ if(ArgsConst.EXCHANGE.equals(auditRequest.getType())){
exchange.setAuditState(4); exchange.setAuditState(4);
exchange.setState("0"); exchange.setState("0");
exchange.setFirstTrialRemark(auditRequest.getAuditOpinion());
exchangeMapper.updateById(exchange); exchangeMapper.updateById(exchange);
} }
for (Audit auditOne : auditList) { for (Audit auditOne : auditList) {
@ -201,10 +209,11 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
if (update){ if (update){
saveAuditLog(auditRequest.getPersonnelId(),loginId,auditRequest.getType(),"一般终审拒绝",auditRequest.getAuditOpinion()); saveAuditLog(auditRequest.getPersonnelId(),loginId,auditRequest.getType(),"一般终审拒绝",auditRequest.getAuditOpinion());
if (ArgsConst.PERSONNEL.equals(auditRequest.getType())||ArgsConst.CHANGE.equals(auditRequest.getType())){ if (ArgsConst.PERSONNEL.equals(auditRequest.getType())||ArgsConst.CHANGE.equals(auditRequest.getType())){
updateByPer(afterPersonnel.getId(),personnel,auditRequest.getType()); updateByPer(2,afterPersonnel.getId(),personnel,auditRequest.getType(),auditRequest.getAuditOpinion());
}else if(ArgsConst.EXCHANGE.equals(auditRequest.getType())){ }else if(ArgsConst.EXCHANGE.equals(auditRequest.getType())){
exchange.setAuditState(4); exchange.setAuditState(4);
exchange.setState("0"); exchange.setState("0");
exchange.setFinalTrialRemark(auditRequest.getAuditOpinion());
exchangeMapper.updateById(exchange); exchangeMapper.updateById(exchange);
} }
for (Audit auditOne : auditList) { for (Audit auditOne : auditList) {
@ -226,9 +235,13 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
auditLog.setAuditState(auditSate); auditLog.setAuditState(auditSate);
return auditLogMapper.insert(auditLog); return auditLogMapper.insert(auditLog);
} }
public void updateByPer(Integer num,String afterId,Personnel personnel,String type,String auditOpinion){
public void updateByPer(String afterId,Personnel personnel,String type){
delete(afterId); delete(afterId);
if (1==num){
personnel.setFirstTrialRemark(auditOpinion);
}else if (2==num){
personnel.setFinalTrialRemark(auditOpinion);
}
if (ArgsConst.PERSONNEL.equals(type)){ if (ArgsConst.PERSONNEL.equals(type)){
personnel.setAuditState(4); personnel.setAuditState(4);
personnel.setAlterationSign("2"); personnel.setAlterationSign("2");

View File

@ -1,5 +1,6 @@
package com.ydool.staff.service.impl; package com.ydool.staff.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
@ -16,12 +17,16 @@ import com.ydool.staff.entity.DirectorsSupervisors;
import com.ydool.staff.entity.Personnel; import com.ydool.staff.entity.Personnel;
import com.ydool.staff.entity.Recruitment; import com.ydool.staff.entity.Recruitment;
import com.ydool.staff.excel.EnterpriseIndicatorsExportVO; import com.ydool.staff.excel.EnterpriseIndicatorsExportVO;
import com.ydool.staff.excel.ExcelPersonnel;
import com.ydool.staff.excel.ExcelPersonnelStatement;
import com.ydool.staff.excel.PersonnelReportExportVO; import com.ydool.staff.excel.PersonnelReportExportVO;
import com.ydool.staff.mapper.CompanyNameMapper; import com.ydool.staff.mapper.CompanyNameMapper;
import com.ydool.staff.mapper.DirectorsSupervisorsMapper; import com.ydool.staff.mapper.DirectorsSupervisorsMapper;
import com.ydool.staff.mapper.PersonnelMapper; import com.ydool.staff.mapper.PersonnelMapper;
import com.ydool.staff.mapper.RecruitmentMapper; import com.ydool.staff.mapper.RecruitmentMapper;
import com.ydool.staff.request.CompanyNameRequest; import com.ydool.staff.request.CompanyNameRequest;
import com.ydool.staff.request.ExcelPersonnelStatementRequest;
import com.ydool.staff.request.PersonnelDeleteRequest;
import com.ydool.staff.service.ICompanyNameService; import com.ydool.staff.service.ICompanyNameService;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -29,7 +34,14 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* <p> * <p>
@ -123,21 +135,62 @@ public class CompanyNameServiceImpl extends BaseService<CompanyNameMapper, Compa
} }
@Override @Override
public AjaxResult perStatement(String id) { public PersonnelStatementDto perStatement(String id, String firstDate,String finalDate) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date first;Date finals;
try {
first = format.parse(firstDate);
finals = format.parse(finalDate);
} catch (ParseException e) {
throw new RuntimeException(e);
}
CompanyNameMapper companyNameMapper = SpringUtil.getBean(CompanyNameMapper.class); CompanyNameMapper companyNameMapper = SpringUtil.getBean(CompanyNameMapper.class);
PersonnelStatementDto statementDto = new PersonnelStatementDto(); PersonnelStatementDto statementDto = new PersonnelStatementDto();
CompanyName companyName = companyNameMapper.selectById(id); CompanyName companyName = companyNameMapper.selectById(id);
Integer count = directorsSupervisorsMapper.selectCount(new LambdaQueryWrapper<DirectorsSupervisors>().eq(DirectorsSupervisors::getOrganizationId, companyName.getId())); Integer count = directorsSupervisorsMapper.selectCount(new LambdaQueryWrapper<DirectorsSupervisors>().eq(DirectorsSupervisors::getAuditState,3).eq(DirectorsSupervisors::getOrganizationId, companyName.getId()));
LambdaQueryWrapper<Personnel> wrapper = new LambdaQueryWrapper<Personnel>()
.eq(Personnel::getCompanyName, companyName.getId())
.ge(Personnel::getHireDate,first)
.le(Personnel::getHireDate,finals);
List<Personnel> list = personnelMapper.selectList(wrapper);
statementDto.setSupervisorsNum(count); statementDto.setSupervisorsNum(count);
statementDto.setCompetentDeptName("县发展和改革局"); statementDto.setCompetentDeptName("县发展和改革局");
statementDto.setSocialCreditCode(companyName.getCreditCode()); statementDto.setSocialCreditCode(companyName.getCreditCode());
statementDto.setCompetent(companyName.getCompanyName()); statementDto.setCompetent(companyName.getCompanyName());
statementDto.setCapital(100); statementDto.setCapital(100);
statementDto.setMechanismNum(5); statementDto.setMechanismNum(5);
statementDto.setEmploymentNum(16); statementDto.setEmploymentNum(companyName.getCheckNumber());
statementDto.setNum(1); statementDto.setNum(Long.valueOf(list.size()));
statementDto.setThereIntoNum(0); statementDto.setThereIntoNum(0);
return AjaxResult.ok().data(statementDto); return statementDto;
}
@Override
public AjaxResult getEntityParam() {
Field[] declaredFields = ExcelPersonnelStatement.class.getDeclaredFields();
List<String> list = new ArrayList<>();
for (Field declaredField : declaredFields) {
list.add(declaredField.getName());
}
return AjaxResult.ok().data(list).msg("查询成功");
}
@Override
public void export(ExcelPersonnelStatementRequest personnelParam, HttpServletResponse response) {
PersonnelStatementDto dto = perStatement(personnelParam.getId(), personnelParam.getFirstDate(), personnelParam.getFinalDate());
ExcelPersonnelStatement statement = BeanUtil.copyProperties(dto, ExcelPersonnelStatement.class);
List<ExcelPersonnelStatement> statements = new ArrayList<>();
statements.add(statement);
String fileName = "国有企业人事信息查询表" + System.currentTimeMillis() + ".xlsx";
Set<String> includeColumnFiledNames = new HashSet<>();
for (String s : personnelParam.getPrams()) {
includeColumnFiledNames.add(s);
}
//导出
EasyExcelAlibabaUtil.exportDownload(response, ExcelPersonnelStatement.class, statements, fileName,includeColumnFiledNames);
} }