修改指标,登记

This commit is contained in:
zhuyy 2023-06-16 15:04:29 +08:00
parent ab5b421bf1
commit 72ff161ca6
27 changed files with 570 additions and 221 deletions

View File

@ -0,0 +1,31 @@
package com.ydool.staff.controller;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ydool.common.base.BaseController;
import com.ydool.common.constant.UrlConstant;
import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.dto.AuditLogDto;
import com.ydool.staff.service.impl.AuditLogServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(UrlConstant.ALTERATION)
@Api(tags = "人事日志", value = "人事日志")
@ApiSupport(order = 12)
public class AuditLogControoller extends BaseController {
@Autowired
AuditLogServiceImpl auditLogService;
@GetMapping("/log")
@ApiOperation(value = "人事日志", response = AuditLogDto.class)
public AjaxResult audtiLog() {
return auditLogService.auditLog(getPage());
}
}

View File

@ -4,14 +4,13 @@ import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ydool.common.base.BaseController; import com.ydool.common.base.BaseController;
import com.ydool.common.constant.UrlConstant; import com.ydool.common.constant.UrlConstant;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.dto.CompanyNameDto;
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;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@ -36,4 +35,10 @@ public class CompanyNameController extends BaseController {
return companyNameService.companyName(id); return companyNameService.companyName(id);
} }
@PutMapping("/update")
@ApiOperation(value = "修改总指标人数")
public AjaxResult update(@RequestBody CompanyNameDto companyNameDto) {
return companyNameService.update(companyNameDto);
}
} }

View File

@ -13,6 +13,7 @@ import com.ydool.staff.entity.Organization;
import com.ydool.staff.request.OrganizationSearch; import com.ydool.staff.request.OrganizationSearch;
import com.ydool.staff.service.*; import com.ydool.staff.service.*;
import com.ydool.system.request.IdsRequest; import com.ydool.system.request.IdsRequest;
import com.ydool.system.service.impl.ConfigServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
@ -28,6 +29,8 @@ public class OrganizationController extends BaseController {
@Autowired @Autowired
IOrganizationService organizationService; IOrganizationService organizationService;
@Autowired
ConfigServiceImpl configService;
@GetMapping("/selectOrganizationPersonnelIndicatorsList") @GetMapping("/selectOrganizationPersonnelIndicatorsList")
@ApiOperation(value = "人员招聘登记人员指标申报列表") @ApiOperation(value = "人员招聘登记人员指标申报列表")
@ -44,6 +47,12 @@ public class OrganizationController extends BaseController {
return organizationService.deleteOrganization(id); return organizationService.deleteOrganization(id);
} }
@GetMapping(value = "/approval")
@ApiOperation(value = "招聘单号")
public AjaxResult approval() {
return organizationService.approval();
}
@GetMapping("/submitRecruitment") @GetMapping("/submitRecruitment")
@ApiOperation(value = "人员招聘登记送审") @ApiOperation(value = "人员招聘登记送审")
@ApiImplicitParams({@ApiImplicitParam(value = "登记id", name = "id")}) @ApiImplicitParams({@ApiImplicitParam(value = "登记id", name = "id")})
@ -57,4 +66,5 @@ public class OrganizationController extends BaseController {
public AjaxResult submitPersonnelIndicators(String id) { public AjaxResult submitPersonnelIndicators(String id) {
return organizationService.submitRecruitment(id, ArgsConst.PERSONNEL_INDICATORS); return organizationService.submitRecruitment(id, ArgsConst.PERSONNEL_INDICATORS);
} }
} }

View File

@ -1,5 +1,6 @@
package com.ydool.staff.controller; package com.ydool.staff.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport; import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.github.xiaoymin.knife4j.annotations.DynamicParameter; import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
@ -8,7 +9,9 @@ import com.ydool.common.base.BaseController;
import com.ydool.common.constant.UrlConstant; import com.ydool.common.constant.UrlConstant;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.dto.RecruitmentDto; import com.ydool.staff.dto.RecruitmentDto;
import com.ydool.staff.entity.Audit;
import com.ydool.staff.request.RecruitmentRequest; import com.ydool.staff.request.RecruitmentRequest;
import com.ydool.staff.service.IAuditService;
import com.ydool.staff.service.IRecruitmentService; import com.ydool.staff.service.IRecruitmentService;
import com.ydool.system.request.IdsRequest; import com.ydool.system.request.IdsRequest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -26,6 +29,8 @@ public class RecruitmentController extends BaseController {
@Autowired @Autowired
IRecruitmentService recruitmentService; IRecruitmentService recruitmentService;
@Autowired
IAuditService auditService;
@GetMapping("/selectCompanyNameById") @GetMapping("/selectCompanyNameById")
@ApiOperation(value = "人员招聘登记详情") @ApiOperation(value = "人员招聘登记详情")
@ -48,4 +53,16 @@ public class RecruitmentController extends BaseController {
return recruitmentService.deleteRecruitment(id); return recruitmentService.deleteRecruitment(id);
} }
// @GetMapping(value = "/submit")
// @ApiOperation(value = "已提交审批")
// public AjaxResult submit() {
// return auditService.submitAudit(getPage());
// }
@GetMapping(value = "/waiting")
@ApiOperation(value = "待我审批")
public AjaxResult waiting() {
return auditService.waitingAudit(getPage());
}
} }

View File

@ -0,0 +1,14 @@
package com.ydool.staff.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CompanyNameDto {
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "总指标人数")
private Long checkNumber;
}

View File

@ -0,0 +1,11 @@
package com.ydool.staff.dto;
import lombok.Data;
@Data
public class PlacesDto {
private String id;
private String odd;
}

View File

@ -47,6 +47,9 @@ public class CompanyName extends BaseEntity {
@ApiModelProperty(value = "本次核准后总指标人数") @ApiModelProperty(value = "本次核准后总指标人数")
private Long thisApprovalNumber; private Long thisApprovalNumber;
@ApiModelProperty(value = "核定用工指标人数")
private Long recruit;
@ApiModelProperty(value = "类型 登记organization 申报personnel_indicators") @ApiModelProperty(value = "类型 登记organization 申报personnel_indicators")
private String type; private String type;

View File

@ -42,6 +42,9 @@ public class Organization extends BaseEntity{
@ApiModelProperty(value = "核定用工人数") @ApiModelProperty(value = "核定用工人数")
private Long checkNumber; private Long checkNumber;
@ApiModelProperty(value = "剩余指标人数")
private Long addNumber;
@ApiModelProperty(value = "剩余指标人数") @ApiModelProperty(value = "剩余指标人数")
private Long residualNumber; private Long residualNumber;

View File

@ -0,0 +1,23 @@
package com.ydool.staff.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ydool.common.base.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("t_lc_places")
public class Places extends BaseEntity {
@ApiModelProperty(value = "登记id")
private String organizationId;
@ApiModelProperty(value = "单号")
private String odd;
@ApiModelProperty(value = "状态")
private Boolean status;
}

View File

@ -1,8 +1,11 @@
package com.ydool.staff.mapper; package com.ydool.staff.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ydool.staff.entity.PersonnelIndicators; import com.ydool.staff.entity.PersonnelIndicators;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
/** /**
@ -29,6 +32,6 @@ public interface PersonnelIndicatorsMapper extends MPJBaseMapper<PersonnelIndica
* @param id * @param id
* @return * @return
*/ */
@Select("SELECT sum(add_number) add_number FROM `t_lc_personnel_indicators` where organization_id = '#{id}'") @Select("SELECT sum(add_number) add_number FROM `t_lc_personnel_indicators` ${ew.customSqlSegment}")
Long personnelIndicatorsAddNumber(String id); Long personnelIndicatorsAddNumber(@Param(Constants.WRAPPER) QueryWrapper<PersonnelIndicators> wrapper);
} }

View File

@ -0,0 +1,15 @@
package com.ydool.staff.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.github.yulichang.base.MPJBaseMapper;
import com.ydool.staff.entity.Places;
import com.ydool.staff.entity.Recruitment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface PlacesMapper extends MPJBaseMapper<Places> {
}

View File

@ -1,5 +1,7 @@
package com.ydool.staff.mapper; package com.ydool.staff.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ydool.staff.entity.Recruitment; import com.ydool.staff.entity.Recruitment;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import com.ydool.staff.request.CompanyNameRequest; import com.ydool.staff.request.CompanyNameRequest;
@ -27,6 +29,6 @@ public interface RecruitmentMapper extends MPJBaseMapper<Recruitment> {
List<CompanyNameRequest> recruitmentList(); List<CompanyNameRequest> recruitmentList();
@Select("SELECT SUM(places) places FROM `t_lc_recruitment` WHERE company_id = #{companyId}") @Select("SELECT SUM(places) places FROM `t_lc_recruitment` ${ew.customSqlSegment}")
Long recruitmentPlaces(String companyId); Long recruitmentPlaces(@Param(Constants.WRAPPER) QueryWrapper<Recruitment> wrapper);
} }

View File

@ -26,7 +26,7 @@ public class AuditRequest {
@ApiModelProperty(value = "审批意见") @ApiModelProperty(value = "审批意见")
private String auditOpinion; private String auditOpinion;
@ApiModelProperty(value = "人员类型personnel人员 change变更 exchange:选调") @ApiModelProperty(value = "人员类型personnel人员 change变更 exchange:选调 personnel_indicators申报 organization登记")
private String type; private String type;

View File

@ -21,6 +21,9 @@ public class OrganizationRequest implements Serializable {
@ApiModelProperty(value = "核定用工人数") @ApiModelProperty(value = "核定用工人数")
private Long checkNumber; private Long checkNumber;
@ApiModelProperty(value = "核定用工人数")
private Long addNumber;
@ApiModelProperty(value = "在职人数") @ApiModelProperty(value = "在职人数")
private Long activeStaff; private Long activeStaff;

View File

@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
@ -18,10 +20,15 @@ import java.util.List;
@Data @Data
public class PersonnelIndicatorsRequest implements Serializable { public class PersonnelIndicatorsRequest implements Serializable {
@ApiModelProperty(value = "保存preserve/送审approval")
@NotBlank(message = "类型不能为空")
private String type;
@ApiModelProperty(value = "人员指标") @ApiModelProperty(value = "人员指标")
@Valid @Valid
private OrganizationRequest organizationRequest; private OrganizationRequest organizationRequest;
@ApiModelProperty(value = "人员指标申报") @ApiModelProperty(value = "人员指标申报")
@NotEmpty(message = "人员指标申报不能为空")
private List<PersonnelIndicators> personnelIndicators; private List<PersonnelIndicators> personnelIndicators;
} }

View File

@ -5,17 +5,24 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
@Data @Data
public class RecruitmentRequest implements Serializable { public class RecruitmentRequest implements Serializable {
@ApiModelProperty(value = "保存preserve/送审approval")
@NotBlank(message = "类型不能为空")
private String type;
@ApiModelProperty(value = "招聘登记") @ApiModelProperty(value = "招聘登记")
@Valid @Valid
private OrganizationRequest organizationRequest; private OrganizationRequest organizationRequest;
@ApiModelProperty(value = "人员招聘登记") @ApiModelProperty(value = "人员招聘登记")
@NotEmpty(message = "人员登记不能为空")
private List<Recruitment> recruitments; private List<Recruitment> recruitments;
} }

View File

@ -1,5 +1,6 @@
package com.ydool.staff.service; package com.ydool.staff.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
/** /**
@ -13,5 +14,7 @@ import com.ydool.common.data.dto.AjaxResult;
public interface IAuditLogService { public interface IAuditLogService {
AjaxResult auditLog(String id, String personnelType); AjaxResult auditLog(String id, String personnelType);
AjaxResult auditLog(Page page);
} }

View File

@ -2,6 +2,7 @@ package com.ydool.staff.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.entity.Audit;
import com.ydool.staff.request.AuditRequest; import com.ydool.staff.request.AuditRequest;
/** /**
@ -25,5 +26,9 @@ public interface IAuditService {
AjaxResult submitRecruitmentAudit(AuditRequest auditRequest); AjaxResult submitRecruitmentAudit(AuditRequest auditRequest);
AjaxResult submitPersonnelIndicatorsAudit(AuditRequest auditRequest); AjaxResult submitPersonnelIndicatorsAudit(AuditRequest auditRequest);
AjaxResult submitAudit(Page page);
AjaxResult waitingAudit(Page page);
} }

View File

@ -1,6 +1,7 @@
package com.ydool.staff.service; package com.ydool.staff.service;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.dto.CompanyNameDto;
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.dto.PersonnelStatementDto;
@ -40,5 +41,7 @@ public interface ICompanyNameService {
AjaxResult getEntityParam(); AjaxResult getEntityParam();
void export(ExcelPersonnelStatementRequest personnelParam, HttpServletResponse response); void export(ExcelPersonnelStatementRequest personnelParam, HttpServletResponse response);
AjaxResult update(CompanyNameDto companyNameDto);
} }

View File

@ -23,5 +23,6 @@ public interface IOrganizationService {
AjaxResult submitRecruitment(String id, String type); AjaxResult submitRecruitment(String id, String type);
AjaxResult approval();
} }

View File

@ -1,8 +1,12 @@
package com.ydool.staff.service.impl; package com.ydool.staff.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.common.base.BaseService; import com.ydool.common.base.BaseService;
import com.ydool.common.constant.ArgsConst; import com.ydool.common.constant.ArgsConst;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
@ -13,10 +17,12 @@ import com.ydool.staff.mapper.AuditLogMapper;
import com.ydool.staff.service.IAuditLogService; import com.ydool.staff.service.IAuditLogService;
import com.ydool.system.entity.User; import com.ydool.system.entity.User;
import com.ydool.system.mapper.UserMapper; import com.ydool.system.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@ -34,7 +40,7 @@ public class AuditLogServiceImpl extends BaseService<AuditLogMapper, AuditLog> i
@Override @Override
public AjaxResult auditLog(String id, String personnelType) { public AjaxResult auditLog(String id, String personnelType) {
LambdaQueryWrapper<AuditLog> wrapper = new LambdaQueryWrapper<AuditLog>() LambdaQueryWrapper<AuditLog> wrapper = new LambdaQueryWrapper<AuditLog>()
.eq(AuditLog::getType,personnelType) .eq(AuditLog::getType, personnelType)
.eq(AuditLog::getPersonnelId, id).orderByDesc(AuditLog::getCreatedAt); .eq(AuditLog::getPersonnelId, id).orderByDesc(AuditLog::getCreatedAt);
List<AuditLog> list = list(wrapper); List<AuditLog> list = list(wrapper);
List<AuditLogDto> auditLogDtos = BeanUtil.copyToList(list, AuditLogDto.class); List<AuditLogDto> auditLogDtos = BeanUtil.copyToList(list, AuditLogDto.class);
@ -44,5 +50,19 @@ public class AuditLogServiceImpl extends BaseService<AuditLogMapper, AuditLog> i
} }
return AjaxResult.ok().data(auditLogDtos); return AjaxResult.ok().data(auditLogDtos);
} }
@Override
public AjaxResult auditLog(Page page) {
Page selectPage = page(page, Wrappers.lambdaQuery(AuditLog.class).orderByDesc(AuditLog::getCreatedAt));
List<AuditLog> records = selectPage.getRecords();
for (AuditLog record : records) {
User userName = userMapper.selectById(record.getApprover());
if (ObjectUtil.isNotNull(userName)) {
record.setApprover(userName.getUserName());
}
}
selectPage.setRecords(records);
return AjaxResult.ok().data(selectPage);
}
} }

View File

@ -1,14 +1,20 @@
package com.ydool.staff.service.impl; package com.ydool.staff.service.impl;
import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.query.MPJQueryWrapper; import com.github.yulichang.query.MPJQueryWrapper;
import com.ydool.common.base.BaseService; import com.ydool.common.base.BaseService;
import com.ydool.common.cache.ConfigCache; import com.ydool.common.cache.ConfigCache;
import com.ydool.common.constant.ArgsConst; import com.ydool.common.constant.ArgsConst;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.oa.workFlow.data.entity.WorkFlowNotice;
import com.ydool.oa.workFlow.service.WorkFlowNoticeService;
import com.ydool.staff.entity.*; 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;
@ -26,6 +32,8 @@ import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@ -38,6 +46,7 @@ import java.util.List;
@Service @Service
public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements IAuditService { public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements IAuditService {
private static final AtomicInteger counter = new AtomicInteger(0);
@Resource @Resource
private ConfigMapper configMapper; private ConfigMapper configMapper;
@Resource @Resource
@ -65,6 +74,16 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
CompanyNameMapper companyNameMapper; CompanyNameMapper companyNameMapper;
@Autowired @Autowired
RecruitmentMapper recruitmentMapper; RecruitmentMapper recruitmentMapper;
@Autowired
PlacesMapper placesMapper;
@Autowired
WorkFlowNoticeService workFlowNoticeService;
public static String getNextId() {
int value = counter.incrementAndGet();
return String.format("%04d", value);
}
@Override @Override
public AjaxResult getAuditList(Page page) { public AjaxResult getAuditList(Page page) {
@ -79,79 +98,79 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
User loginUser = userMapper.selectById(loginId); User loginUser = userMapper.selectById(loginId);
Audit one = getOne(new LambdaQueryWrapper<Audit>() Audit one = getOne(new LambdaQueryWrapper<Audit>()
.eq(Audit::getPersonnelId, auditRequest.getPersonnelId()) .eq(Audit::getPersonnelId, auditRequest.getPersonnelId())
.eq(Audit::getPerType,auditRequest.getType()) .eq(Audit::getPerType, auditRequest.getType())
.eq(Audit::getAuditOrder, ArgsConst.WAITING) .eq(Audit::getAuditOrder, ArgsConst.WAITING)
.eq(Audit::getApprover, loginId)); .eq(Audit::getApprover, loginId));
if(ObjectUtil.isEmpty(one)){ if (ObjectUtil.isEmpty(one)) {
return AjaxResult.fail().msg("该用户不能审批!"); return AjaxResult.fail().msg("该用户不能审批!");
} }
if(ArgsConst.PASS.equals(one.getAuditState())){ if (ArgsConst.PASS.equals(one.getAuditState())) {
return AjaxResult.fail().msg("用户已审批,请勿重复操作!"); return AjaxResult.fail().msg("用户已审批,请勿重复操作!");
} }
one.setOpinion(auditRequest.getAuditOpinion()); one.setOpinion(auditRequest.getAuditOpinion());
one.setApproverTime(new Date()); one.setApproverTime(new Date());
//同意 // 同意
if ("2".equals(auditRequest.getStatus())){ if ("2".equals(auditRequest.getStatus())) {
Config director = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR)); Config director = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR));
if (loginUser.getLoginName().equals(director.getParamValue())){ if (loginUser.getLoginName().equals(director.getParamValue())) {
one.setAuditOrder(ArgsConst.FIRST); one.setAuditOrder(ArgsConst.FIRST);
one.setAuditState(ArgsConst.PASS); one.setAuditState(ArgsConst.PASS);
boolean update = updateById(one); boolean update = updateById(one);
if (update){ if (update) {
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getLoginName, configMapper.selectOne(new LambdaQueryWrapper<Config>() .eq(User::getLoginName, configMapper.selectOne(new LambdaQueryWrapper<Config>()
.eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP)).getParamValue())); .eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP)).getParamValue()));
Audit auditOne = getOne(new LambdaQueryWrapper<Audit>().eq(Audit::getApprover, user.getId()).eq(Audit::getPerType,auditRequest.getType()).eq(Audit::getPersonnelId, auditRequest.getPersonnelId())); Audit auditOne = getOne(new LambdaQueryWrapper<Audit>().eq(Audit::getApprover, user.getId()).eq(Audit::getPerType, auditRequest.getType()).eq(Audit::getPersonnelId, auditRequest.getPersonnelId()));
auditOne.setAuditOrder(ArgsConst.WAITING); auditOne.setAuditOrder(ArgsConst.WAITING);
updateById(auditOne); updateById(auditOne);
if (ArgsConst.PERSONNEL.equals(auditRequest.getType())||ArgsConst.CHANGE.equals(auditRequest.getType())){ if (ArgsConst.PERSONNEL.equals(auditRequest.getType()) || ArgsConst.CHANGE.equals(auditRequest.getType())) {
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()); 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()); 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.setFirstTrialRemark(auditRequest.getAuditOpinion());
exchange.setAuditState(2); exchange.setAuditState(2);
exchangeMapper.updateById(exchange); exchangeMapper.updateById(exchange);
} }
saveAuditLog(auditRequest.getPersonnelId(),loginId,auditRequest.getType(),"一般初审通过",auditRequest.getAuditOpinion()); saveAuditLog(auditRequest.getPersonnelId(), loginId, auditRequest.getType(), "一般初审通过", auditRequest.getAuditOpinion());
} }
return update ? AjaxResult.ok().msg("审批成功!"):AjaxResult.fail().msg("审批成功!"); return update ? AjaxResult.ok().msg("审批成功!") : AjaxResult.fail().msg("审批成功!");
} }
Config leadership = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP)); Config leadership = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP));
if (leadership.getParamValue().equals(loginUser.getLoginName())){ if (leadership.getParamValue().equals(loginUser.getLoginName())) {
one.setAuditOrder(ArgsConst.LAST); one.setAuditOrder(ArgsConst.LAST);
one.setAuditState(ArgsConst.PASS); one.setAuditState(ArgsConst.PASS);
boolean update = updateById(one); boolean update = updateById(one);
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())) {
Personnel personnel = personnelMapper.selectById(auditRequest.getPersonnelId()); Personnel personnel = personnelMapper.selectById(auditRequest.getPersonnelId());
LambdaQueryWrapper<PersonnelMiddle> wrapper = new LambdaQueryWrapper<PersonnelMiddle>().eq(PersonnelMiddle::getBeforeId, personnel.getId()).eq(PersonnelMiddle::getState, "1"); LambdaQueryWrapper<PersonnelMiddle> wrapper = new LambdaQueryWrapper<PersonnelMiddle>().eq(PersonnelMiddle::getBeforeId, personnel.getId()).eq(PersonnelMiddle::getState, "1");
if (ArgsConst.PERSONNEL.equals(auditRequest.getType())){ if (ArgsConst.PERSONNEL.equals(auditRequest.getType())) {
wrapper.eq(PersonnelMiddle::getType,ArgsConst.PERSONNEL); wrapper.eq(PersonnelMiddle::getType, ArgsConst.PERSONNEL);
}else if (ArgsConst.CHANGE.equals(auditRequest.getType())){ } else if (ArgsConst.CHANGE.equals(auditRequest.getType())) {
wrapper.eq(PersonnelMiddle::getType,ArgsConst.CHANGE); wrapper.eq(PersonnelMiddle::getType, ArgsConst.CHANGE);
} }
PersonnelMiddle middle = personnelMiddleMapper.selectOne(wrapper); PersonnelMiddle middle = personnelMiddleMapper.selectOne(wrapper);
Personnel personnelOne = personnelMapper.selectById(middle.getAfterId()); Personnel personnelOne = personnelMapper.selectById(middle.getAfterId());
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.setFinalTrialRemark(auditRequest.getAuditOpinion());
personnelOne.setWorkState("在职"); personnelOne.setWorkState("在职");
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.setFinalTrialRemark(auditRequest.getAuditOpinion());
personnelOne.setChangeAlterationSign("2"); personnelOne.setChangeAlterationSign("2");
personnelOne.setChangeAuditState(3); personnelOne.setChangeAuditState(3);
@ -163,8 +182,8 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
personnelMapper.updateById(personnelOne); personnelMapper.updateById(personnelOne);
personnelMapper.updateById(personnel); personnelMapper.updateById(personnel);
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()); Personnel personnel = personnelMapper.selectById(exchange.getPersonnelId());
exchange.setAuditState(3); exchange.setAuditState(3);
exchange.setState("0"); exchange.setState("0");
@ -176,10 +195,10 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
personnelMapper.updateById(personnel); personnelMapper.updateById(personnel);
} }
} }
return update ? AjaxResult.ok().msg("审批成功!"):AjaxResult.fail().msg("审批成功!"); return update ? AjaxResult.ok().msg("审批成功!") : AjaxResult.fail().msg("审批成功!");
} }
} }
//拒绝 // 拒绝
List<Audit> auditList = list(new LambdaQueryWrapper<Audit>().eq(Audit::getPersonnelId, auditRequest.getPersonnelId())); List<Audit> auditList = list(new LambdaQueryWrapper<Audit>().eq(Audit::getPersonnelId, auditRequest.getPersonnelId()));
Config director = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR)); Config director = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR));
@ -187,17 +206,17 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
Personnel afterPersonnel = personnelMapper.selectById(middle.getAfterId()); Personnel afterPersonnel = personnelMapper.selectById(middle.getAfterId());
Personnel personnel = personnelMapper.selectById(auditRequest.getPersonnelId()); Personnel personnel = personnelMapper.selectById(auditRequest.getPersonnelId());
Exchange exchange = exchangeMapper.selectById(auditRequest.getPersonnelId()); Exchange exchange = exchangeMapper.selectById(auditRequest.getPersonnelId());
if (loginUser.getLoginName().equals(director.getParamValue())){ if (loginUser.getLoginName().equals(director.getParamValue())) {
one.setAuditOrder(ArgsConst.REJECT); one.setAuditOrder(ArgsConst.REJECT);
one.setOpinion(auditRequest.getAuditOpinion()); one.setOpinion(auditRequest.getAuditOpinion());
boolean update = updateById(one); boolean update = updateById(one);
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(1,afterPersonnel.getId(),personnel,auditRequest.getType(),auditRequest.getAuditOpinion()); 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()); exchange.setFirstTrialRemark(auditRequest.getAuditOpinion());
@ -207,18 +226,18 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
delete(auditOne.getId()); delete(auditOne.getId());
} }
} }
return update ? AjaxResult.ok().msg("审批成功!"):AjaxResult.fail().msg("审批成功!"); return update ? AjaxResult.ok().msg("审批成功!") : AjaxResult.fail().msg("审批成功!");
} }
Config leadership = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP)); Config leadership = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP));
if (leadership.getParamValue().equals(loginUser.getLoginName())){ if (leadership.getParamValue().equals(loginUser.getLoginName())) {
one.setAuditOrder(ArgsConst.REJECT); one.setAuditOrder(ArgsConst.REJECT);
one.setOpinion(auditRequest.getAuditOpinion()); one.setOpinion(auditRequest.getAuditOpinion());
boolean update = updateById(one); boolean update = updateById(one);
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(2,afterPersonnel.getId(),personnel,auditRequest.getType(),auditRequest.getAuditOpinion()); 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()); exchange.setFinalTrialRemark(auditRequest.getAuditOpinion());
@ -228,13 +247,13 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
delete(auditOne.getId()); delete(auditOne.getId());
} }
} }
return update ? AjaxResult.ok().msg("审批成功!"):AjaxResult.fail().msg("审批成功!"); return update ? AjaxResult.ok().msg("审批成功!") : AjaxResult.fail().msg("审批成功!");
} }
return null; return null;
} }
public Integer saveAuditLog(String personnelId,String approverId,String type,String auditSate,String opinion){ public Integer saveAuditLog(String personnelId, String approverId, String type, String auditSate, String opinion) {
AuditLog auditLog = new AuditLog(); AuditLog auditLog = new AuditLog();
auditLog.setPersonnelId(personnelId); auditLog.setPersonnelId(personnelId);
auditLog.setType(type); auditLog.setType(type);
@ -243,17 +262,18 @@ 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(Integer num, String afterId, Personnel personnel, String type, String auditOpinion) {
delete(afterId); delete(afterId);
if (1==num){ if (1 == num) {
personnel.setFirstTrialRemark(auditOpinion); personnel.setFirstTrialRemark(auditOpinion);
}else if (2==num){ } else if (2 == num) {
personnel.setFinalTrialRemark(auditOpinion); 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");
}else if (ArgsConst.CHANGE.equals(type)){ } else if (ArgsConst.CHANGE.equals(type)) {
personnel.setChangeAuditState(4); personnel.setChangeAuditState(4);
personnel.setChangeAlterationSign("2"); personnel.setChangeAlterationSign("2");
} }
@ -271,7 +291,6 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult submitRecruitmentAudit(AuditRequest auditRequest) { public AjaxResult submitRecruitmentAudit(AuditRequest auditRequest) {
Organization organization = organizationMapper.selectById(auditRequest.getPersonnelId()); Organization organization = organizationMapper.selectById(auditRequest.getPersonnelId());
if (3 == organization.getAuditState()) { if (3 == organization.getAuditState()) {
return AjaxResult.fail().msg("已拒绝请勿重复审批!"); return AjaxResult.fail().msg("已拒绝请勿重复审批!");
} }
@ -281,72 +300,85 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
return AjaxResult.fail().msg("该用户不能审批!"); return AjaxResult.fail().msg("该用户不能审批!");
} }
// 人事部负责人 // 人事部负责人
Config director = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR)); // Config director = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR));
// 领导 // 领导
Config leadership = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP)); Config leadership = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP));
User byId = userMapper.selectById(one.getApprover()); User byId = userMapper.selectById(one.getApprover());
// 同意 // 同意
if ("2".equals(auditRequest.getStatus())) { if ("2".equals(auditRequest.getStatus())) {
// 人事初审批同意 // 人事初审批同意
if (director.getParamValue().equals(byId.getLoginName())) { // if (director.getParamValue().equals(byId.getLoginName())) {
one.setAuditOrder(ArgsConst.FIRST); // one.setAuditOrder(ArgsConst.FIRST);
one.setAuditState(ArgsConst.PASS); // one.setAuditState(ArgsConst.PASS);
boolean update = updateById(one); // boolean update = updateById(one);
if (update) { // if (update) {
Audit one1 = getOne(new LambdaQueryWrapper<Audit>().eq(Audit::getPersonnelId, auditRequest.getPersonnelId()).eq(Audit::getAuditOrder, ArgsConst.LAST)); // Audit one1 = getOne(new LambdaQueryWrapper<Audit>().eq(Audit::getPersonnelId, auditRequest.getPersonnelId()).eq(Audit::getAuditOrder, ArgsConst.LAST));
one1.setAuditOrder(ArgsConst.WAITING); // one1.setAuditOrder(ArgsConst.WAITING);
updateById(one1); // updateById(one1);
organization.setAuditState(2); // organization.setAuditState(2);
organization.setFirstTime(new Date()); // organization.setFirstTime(new Date());
organization.setFirstTrial(auditRequest.getAuditOpinion()); // organization.setFirstTrial(auditRequest.getAuditOpinion());
organizationMapper.updateById(organization); // organizationMapper.updateById(organization);
} // }
return update ? AjaxResult.ok().msg("人事审批成功!") : AjaxResult.fail().msg("人事审批失败!"); // saveAuditLog(auditRequest.getPersonnelId(), loginId, "organization", "人事审批通过", auditRequest.getAuditOpinion());
} // return update ? AjaxResult.ok().msg("人事审批成功!") : AjaxResult.fail().msg("人事审批失败!");
// 领导终审批同意 // }
// // 领导终审批同意
if (leadership.getParamValue().equals(byId.getLoginName())) { if (leadership.getParamValue().equals(byId.getLoginName())) {
CompanyName companyName = companyNameMapper.selectOne(new LambdaQueryWrapper<CompanyName>().eq(CompanyName::getId, organization.getCompanyId())); CompanyName companyName = companyNameMapper.selectOne(new LambdaQueryWrapper<CompanyName>().eq(CompanyName::getId, organization.getCompanyId()));
// 名额 // 名额
Long places = recruitmentMapper.selectOne(new MPJQueryWrapper<Recruitment>().select(" SUM(places) places ").eq("company_id", organization.getId())).getPlaces(); // Long places = recruitmentMapper.selectOne(new MPJQueryWrapper<Recruitment>().select(" SUM(places) places ").eq("company_id", organization.getId())).getPlaces();
Long quota = companyName.getResidualNumber() - places;
// 剩余指标人数 = 剩余指标人数 - 名额
if(quota < 0){
return AjaxResult.fail().msg("招聘人数不能大于剩余人数!");
}
one.setAuditOrder(ArgsConst.LAST); one.setAuditOrder(ArgsConst.LAST);
one.setAuditState(ArgsConst.PASS); one.setAuditState(ArgsConst.PASS);
one.setApproverTime(new Date());
boolean update = updateById(one); boolean update = updateById(one);
if (update) { if (update) {
// 剩余指标人数 = 原核定用工指标人数 - 名额 QueryWrapper<Recruitment> queryWrapper = new QueryWrapper<Recruitment>().eq("company_id", organization.getId());
companyName.setResidualNumber(quota); Long places = recruitmentMapper.recruitmentPlaces(queryWrapper);
companyName.setThisApprovalNumber(organization.getThisApprovalNumber()); // companyNameMapper.update(null, new LambdaUpdateWrapper<CompanyName>().set(CompanyName::getThisApprovalNumber, companyName.getThisApprovalNumber() - places).eq(CompanyName::getId, companyName.getId()));
companyNameMapper.updateById(companyName); companyNameMapper.update(null, new LambdaUpdateWrapper<CompanyName>().set(CompanyName::getResidualNumber, companyName.getResidualNumber() - places)
// .set(CompanyName::getResidualNumber, companyName.getResidualNumber() - addNumber)
// .set(CompanyName::getRecruit, companyName.getCheckNumber() - companyName.getThisApprovalNumber())
.eq(CompanyName::getId, companyName.getId()));
organization.setAuditState(3); organization.setAuditState(3);
organization.setResidualNumber(companyName.getResidualNumber());
organization.setLastTime(new Date()); organization.setLastTime(new Date());
organization.setLastInstance(auditRequest.getAuditOpinion()); organization.setLastInstance(auditRequest.getAuditOpinion());
organizationMapper.updateById(organization); organizationMapper.updateById(organization);
} }
List<Recruitment> recruitments = recruitmentMapper.selectList(Wrappers.lambdaQuery(Recruitment.class).eq(Recruitment::getCompanyId, organization.getId()));
List<Long> list = recruitments.stream().map(Recruitment::getPlaces).collect(Collectors.toList());
for (Long aLong : list) {
for (int i = 0; i < aLong.intValue(); i++) {
Places places = new Places();
places.setStatus(Boolean.FALSE);
places.setOrganizationId(organization.getId());
places.setOdd(DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss" + getNextId()));
placesMapper.insert(places);
}
}
saveAuditLog(auditRequest.getPersonnelId(), loginId, ArgsConst.ORGANIZATION, "领导审批通过", auditRequest.getAuditOpinion());
return update ? AjaxResult.ok().msg("领导审批成功!") : AjaxResult.fail().msg("领导审批失败!"); return update ? AjaxResult.ok().msg("领导审批成功!") : AjaxResult.fail().msg("领导审批失败!");
} }
} else { } else {
// 人事初审批拒绝 // 人事初审批拒绝
if (director.getParamValue().equals(byId.getLoginName())) { // if (director.getParamValue().equals(byId.getLoginName())) {
one.setAuditOrder(ArgsConst.FIRST); // one.setAuditOrder(ArgsConst.FIRST);
one.setAuditState(ArgsConst.REJECT); // one.setAuditState(ArgsConst.REJECT);
boolean update = updateById(one); // boolean update = updateById(one);
if (update) { // if (update) {
organization.setAuditState(4); // organization.setAuditState(4);
organization.setFirstTime(new Date()); // organization.setFirstTime(new Date());
organization.setFirstTrial(auditRequest.getAuditOpinion()); // organization.setFirstTrial(auditRequest.getAuditOpinion());
organizationMapper.updateById(organization); // organizationMapper.updateById(organization);
} // }
return update ? AjaxResult.ok().msg("人事审批拒绝!") : AjaxResult.fail().msg("人事审批失败!"); // saveAuditLog(auditRequest.getPersonnelId(), loginId, "organization", "人事审批拒绝", auditRequest.getAuditOpinion());
} // return update ? AjaxResult.ok().msg("人事审批拒绝!") : AjaxResult.fail().msg("人事审批失败!");
// }
// 领导终审批拒绝 // 领导终审批拒绝
if (leadership.getParamValue().equals(byId.getLoginName())) { if (leadership.getParamValue().equals(byId.getLoginName())) {
one.setAuditOrder(ArgsConst.LAST); one.setAuditOrder(ArgsConst.LAST);
one.setAuditState(ArgsConst.REJECT); one.setAuditState(ArgsConst.REJECT);
one.setApproverTime(new Date());
boolean update = updateById(one); boolean update = updateById(one);
if (update) { if (update) {
organization.setAuditState(4); organization.setAuditState(4);
@ -354,6 +386,7 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
organization.setLastInstance(auditRequest.getAuditOpinion()); organization.setLastInstance(auditRequest.getAuditOpinion());
organizationMapper.updateById(organization); organizationMapper.updateById(organization);
} }
saveAuditLog(auditRequest.getPersonnelId(), loginId, ArgsConst.ORGANIZATION, "领导审批拒绝", auditRequest.getAuditOpinion());
return update ? AjaxResult.ok().msg("领导审批拒绝!") : AjaxResult.fail().msg("领导审批失败!"); return update ? AjaxResult.ok().msg("领导审批拒绝!") : AjaxResult.fail().msg("领导审批失败!");
} }
} }
@ -370,7 +403,6 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult submitPersonnelIndicatorsAudit(AuditRequest auditRequest) { public AjaxResult submitPersonnelIndicatorsAudit(AuditRequest auditRequest) {
Organization organization = organizationMapper.selectById(auditRequest.getPersonnelId()); Organization organization = organizationMapper.selectById(auditRequest.getPersonnelId());
if (3 == organization.getAuditState()) { if (3 == organization.getAuditState()) {
return AjaxResult.fail().msg("已拒绝请勿重复审批!"); return AjaxResult.fail().msg("已拒绝请勿重复审批!");
} }
@ -380,75 +412,82 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
return AjaxResult.fail().msg("该用户不能审批!"); return AjaxResult.fail().msg("该用户不能审批!");
} }
// 人事部负责人 // 人事部负责人
Config director = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR)); // Config director = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR));
// 领导 // 领导
Config leadership = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP)); Config leadership = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP));
// 同意 // 同意
User byId = userMapper.selectById(one.getApprover());
if ("2".equals(auditRequest.getStatus())) { if ("2".equals(auditRequest.getStatus())) {
User byId = userMapper.selectById(one.getApprover()); // // 人事初审批同意
// 人事初审批同意 // if (director.getParamValue().equals(byId.getLoginName())) {
if (director.getParamValue().equals(byId.getLoginName())) { // one.setAuditOrder(ArgsConst.FIRST);
one.setAuditOrder(ArgsConst.FIRST); // one.setAuditState(ArgsConst.PASS);
one.setAuditState(ArgsConst.PASS); // boolean update = updateById(one);
boolean update = updateById(one); // if (update) {
if (update) { // Audit one1 = getOne(new LambdaQueryWrapper<Audit>().eq(Audit::getPersonnelId, auditRequest.getPersonnelId()).eq(Audit::getAuditOrder, ArgsConst.LAST));
Audit one1 = getOne(new LambdaQueryWrapper<Audit>().eq(Audit::getPersonnelId, auditRequest.getPersonnelId()).eq(Audit::getAuditOrder, ArgsConst.LAST)); // one1.setAuditOrder(ArgsConst.WAITING);
one1.setAuditOrder(ArgsConst.WAITING); // updateById(one1);
updateById(one1); // organization.setAuditState(2);
organization.setAuditState(2); // organization.setFirstTime(new Date());
organization.setFirstTime(new Date()); // organization.setFirstTrial(auditRequest.getAuditOpinion());
organization.setFirstTrial(auditRequest.getAuditOpinion()); // organizationMapper.updateById(organization);
organizationMapper.updateById(organization); // }
} // saveAuditLog(auditRequest.getPersonnelId(), loginId, "personnel_indicators", "人事审批通过", auditRequest.getAuditOpinion());
return update ? AjaxResult.ok().msg("人事审批成功!") : AjaxResult.fail().msg("人事审批失败!"); // return update ? AjaxResult.ok().msg("人事审批成功!") : AjaxResult.fail().msg("人事审批失败!");
} // }
// 领导终审批同意 // 领导终审批同意
if (leadership.getParamValue().equals(byId.getLoginName())) { if (leadership.getParamValue().equals(byId.getLoginName())) {
//统计核准指标人数
Long addNumber = personnelIndicatorsMapper.selectOne(new MPJQueryWrapper<PersonnelIndicators>().select(" SUM(add_number) addNumber ").eq("organization_id", organization.getId())).getAddNumber();
//统计要求增加指标人数
Long standardNumber = personnelIndicatorsMapper.selectOne(new MPJQueryWrapper<PersonnelIndicators>().select(" SUM(standard_number) standardNumber ").eq("organization_id", organization.getId())).getStandardNumber();
Long thisApprovalNumber = organizationMapper.selectOne(new MPJQueryWrapper<Organization>().select(" SUM(this_approval_number) thisApprovalNumber ").eq("company_id", organization.getCompanyId()).eq("type", ArgsConst.PERSONNEL_INDICATORS)).getThisApprovalNumber();
CompanyName companyName = companyNameMapper.selectOne(new LambdaQueryWrapper<CompanyName>().eq(CompanyName::getId, organization.getCompanyId())); CompanyName companyName = companyNameMapper.selectOne(new LambdaQueryWrapper<CompanyName>().eq(CompanyName::getId, organization.getCompanyId()));
// 统计要求增加指标人数
QueryWrapper<PersonnelIndicators> queryWrapper = new QueryWrapper<PersonnelIndicators>().eq("organization_id", organization.getId());
Long addNumber = personnelIndicatorsMapper.personnelIndicatorsAddNumber(queryWrapper);
// Long thisApprovalNumber = organizationMapper.selectOne(new MPJQueryWrapper<Organization>().select(" SUM(this_approval_number) thisApprovalNumber ").eq("company_id", organization.getCompanyId()).eq("type", ArgsConst.PERSONNEL_INDICATORS)).getThisApprovalNumber();
one.setAuditOrder(ArgsConst.LAST); one.setAuditOrder(ArgsConst.LAST);
one.setAuditState(ArgsConst.PASS); one.setAuditState(ArgsConst.PASS);
one.setApproverTime(new Date());
boolean update = updateById(one); boolean update = updateById(one);
if (update) { if (update) {
//原核定用工指标人数 companyNameMapper.update(null, new LambdaUpdateWrapper<CompanyName>().set(CompanyName::getThisApprovalNumber, companyName.getThisApprovalNumber() - addNumber)
companyName.setCheckNumber(addNumber + companyName.getCheckNumber()); .set(CompanyName::getResidualNumber, companyName.getResidualNumber() + addNumber)
// 指标加了剩余人数也加 // .set(CompanyName::getResidualNumber, companyName.getResidualNumber() + addNumber)
companyName.setResidualNumber(standardNumber + companyName.getResidualNumber()); .set(CompanyName::getRecruit, companyName.getRecruit() + addNumber)
//本次核准后总指标人数 .eq(CompanyName::getId, companyName.getId()));
companyName.setThisApprovalNumber(standardNumber + companyName.getThisApprovalNumber());
companyNameMapper.updateById(companyName);
organization.setCheckNumber(companyName.getCheckNumber());
organization.setThisApprovalNumber(thisApprovalNumber);
organization.setAuditState(3); organization.setAuditState(3);
organization.setLastTime(new Date()); organization.setLastTime(new Date());
organization.setLastInstance(auditRequest.getAuditOpinion()); organization.setLastInstance(auditRequest.getAuditOpinion());
organizationMapper.updateById(organization); organizationMapper.updateById(organization);
} }
// WorkFlowNotice workFlowNotice = new WorkFlowNotice();
// workFlowNotice.setStatus(Boolean.FALSE);
// workFlowNotice.setFlowType(ArgsConst.PERSONNEL_INDICATORS);
// workFlowNotice.setUserId(one.getApprover());
// workFlowNotice.setTitle(byId.getUserName() + "的指标申报待你审批");
// workFlowNotice.setFlowId(auditRequest.getPersonnelId());
// workFlowNoticeService.save(workFlowNotice);
saveAuditLog(auditRequest.getPersonnelId(), loginId, ArgsConst.PERSONNEL_INDICATORS, "领导审批通过", auditRequest.getAuditOpinion());
return update ? AjaxResult.ok().msg("领导审批成功!") : AjaxResult.fail().msg("领导审批失败!"); return update ? AjaxResult.ok().msg("领导审批成功!") : AjaxResult.fail().msg("领导审批失败!");
} }
} else { } else {
// 人事初审批拒绝 // 人事初审批拒绝
User byId = userMapper.selectById(one.getApprover()); // User byId = userMapper.selectById(one.getApprover());
if (director.getParamValue().equals(byId.getLoginName())) { // if (director.getParamValue().equals(byId.getLoginName())) {
one.setAuditOrder(ArgsConst.FIRST); // one.setAuditOrder(ArgsConst.FIRST);
one.setAuditState(ArgsConst.REJECT); // one.setAuditState(ArgsConst.REJECT);
boolean update = updateById(one); // boolean update = updateById(one);
if (update) { // if (update) {
organization.setAuditState(4); // organization.setAuditState(4);
organization.setFirstTime(new Date()); // organization.setFirstTime(new Date());
organization.setFirstTrial(auditRequest.getAuditOpinion()); // organization.setFirstTrial(auditRequest.getAuditOpinion());
organizationMapper.updateById(organization); // organizationMapper.updateById(organization);
} // }
return update ? AjaxResult.ok().msg("人事审批拒绝!") : AjaxResult.fail().msg("人事审批失败!"); // saveAuditLog(auditRequest.getPersonnelId(), loginId, "personnel_indicators", "人事审批拒绝", auditRequest.getAuditOpinion());
} // return update ? AjaxResult.ok().msg("人事审批拒绝!") : AjaxResult.fail().msg("人事审批失败!");
// }
// 领导终审批拒绝 // 领导终审批拒绝
if (leadership.getParamValue().equals(byId.getLoginName())) { if (leadership.getParamValue().equals(byId.getLoginName())) {
one.setAuditOrder(ArgsConst.LAST); one.setAuditOrder(ArgsConst.LAST);
one.setAuditState(ArgsConst.REJECT); one.setAuditState(ArgsConst.REJECT);
one.setApproverTime(new Date());
boolean update = updateById(one); boolean update = updateById(one);
if (update) { if (update) {
organization.setAuditState(4); organization.setAuditState(4);
@ -456,6 +495,14 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
organization.setLastInstance(auditRequest.getAuditOpinion()); organization.setLastInstance(auditRequest.getAuditOpinion());
organizationMapper.updateById(organization); organizationMapper.updateById(organization);
} }
// WorkFlowNotice workFlowNotice = new WorkFlowNotice();
// workFlowNotice.setStatus(Boolean.FALSE);
// workFlowNotice.setFlowType(ArgsConst.PERSONNEL_INDICATORS);
// workFlowNotice.setUserId(one.getApprover());
// workFlowNotice.setTitle(byId.getUserName() + "的指标申报已驳回");
// workFlowNotice.setFlowId(auditRequest.getPersonnelId());
// workFlowNoticeService.save(workFlowNotice);
saveAuditLog(auditRequest.getPersonnelId(), loginId, ArgsConst.PERSONNEL_INDICATORS, "领导审批拒绝", auditRequest.getAuditOpinion());
return update ? AjaxResult.ok().msg("领导审批拒绝!") : AjaxResult.fail().msg("领导审批失败!"); return update ? AjaxResult.ok().msg("领导审批拒绝!") : AjaxResult.fail().msg("领导审批失败!");
} }
} }
@ -482,31 +529,32 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
return AjaxResult.fail().msg("该用户不能审批!"); return AjaxResult.fail().msg("该用户不能审批!");
} }
// 人事部负责人 // 人事部负责人
Config director = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR)); // Config director = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR));
// 领导 // 领导
Config leadership = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP)); Config leadership = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP));
User byId = userMapper.selectById(audit.getApprover()); User byId = userMapper.selectById(audit.getApprover());
if ("2".equals(auditRequest.getStatus())) { if ("2".equals(auditRequest.getStatus())) {
// 人事初审批同意 // 人事初审批同意
if (director.getParamValue().equals(byId.getLoginName())) { // if (director.getParamValue().equals(byId.getLoginName())) {
audit.setAuditOrder(ArgsConst.FIRST); // audit.setAuditOrder(ArgsConst.FIRST);
audit.setAuditState(ArgsConst.PASS); // audit.setAuditState(ArgsConst.PASS);
boolean update = updateById(audit); // boolean update = updateById(audit);
if (update) { // if (update) {
Audit one1 = getOne(new LambdaQueryWrapper<Audit>().eq(Audit::getPersonnelId, auditRequest.getPersonnelId()).eq(Audit::getAuditOrder, ArgsConst.LAST)); // Audit one1 = getOne(new LambdaQueryWrapper<Audit>().eq(Audit::getPersonnelId, auditRequest.getPersonnelId()).eq(Audit::getAuditOrder, ArgsConst.LAST));
one1.setAuditOrder(ArgsConst.WAITING); // one1.setAuditOrder(ArgsConst.WAITING);
updateById(one1); // updateById(one1);
recruitment.setAuditState(2); // recruitment.setAuditState(2);
recruitment.setFirstTime(new Date()); // recruitment.setFirstTime(new Date());
recruitment.setFirstTrial(auditRequest.getAuditOpinion()); // recruitment.setFirstTrial(auditRequest.getAuditOpinion());
directorsSupervisorsMapper.updateById(recruitment); // directorsSupervisorsMapper.updateById(recruitment);
} // }
return update ? AjaxResult.ok().msg("人事审批成功!") : AjaxResult.fail().msg("人事审批失败!"); // return update ? AjaxResult.ok().msg("人事审批成功!") : AjaxResult.fail().msg("人事审批失败!");
} // }
// 领导终审批同意 // 领导终审批同意
if (leadership.getParamValue().equals(byId.getLoginName())) { if (leadership.getParamValue().equals(byId.getLoginName())) {
audit.setAuditOrder(ArgsConst.LAST); audit.setAuditOrder(ArgsConst.LAST);
audit.setAuditState(ArgsConst.PASS); audit.setAuditState(ArgsConst.PASS);
audit.setApproverTime(new Date());
boolean update = updateById(audit); boolean update = updateById(audit);
if (update) { if (update) {
recruitment.setAuditState(3); recruitment.setAuditState(3);
@ -514,26 +562,28 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
recruitment.setLastInstance(auditRequest.getAuditOpinion()); recruitment.setLastInstance(auditRequest.getAuditOpinion());
directorsSupervisorsMapper.updateById(recruitment); directorsSupervisorsMapper.updateById(recruitment);
} }
saveAuditLog(auditRequest.getPersonnelId(), loginId, ArgsConst.DIRECTORS, "领导审批通过", auditRequest.getAuditOpinion());
return update ? AjaxResult.ok().msg("领导审批成功!") : AjaxResult.fail().msg("领导审批失败!"); return update ? AjaxResult.ok().msg("领导审批成功!") : AjaxResult.fail().msg("领导审批失败!");
} }
} else { } else {
// 人事初审批拒绝 // 人事初审批拒绝
if (director.getParamValue().equals(byId.getLoginName())) { // if (director.getParamValue().equals(byId.getLoginName())) {
audit.setAuditOrder(ArgsConst.FIRST); // audit.setAuditOrder(ArgsConst.FIRST);
audit.setAuditState(ArgsConst.REJECT); // audit.setAuditState(ArgsConst.REJECT);
boolean update = updateById(audit); // boolean update = updateById(audit);
if (update) { // if (update) {
recruitment.setAuditState(4); // recruitment.setAuditState(4);
recruitment.setFirstTime(new Date()); // recruitment.setFirstTime(new Date());
recruitment.setFirstTrial(auditRequest.getAuditOpinion()); // recruitment.setFirstTrial(auditRequest.getAuditOpinion());
directorsSupervisorsMapper.updateById(recruitment); // directorsSupervisorsMapper.updateById(recruitment);
} // }
return update ? AjaxResult.ok().msg("人事审批拒绝!") : AjaxResult.fail().msg("人事审批失败!"); // return update ? AjaxResult.ok().msg("人事审批拒绝!") : AjaxResult.fail().msg("人事审批失败!");
} // }
// 领导终审批拒绝 // 领导终审批拒绝
if (leadership.getParamValue().equals(byId.getLoginName())) { if (leadership.getParamValue().equals(byId.getLoginName())) {
audit.setAuditOrder(ArgsConst.LAST); audit.setAuditOrder(ArgsConst.LAST);
audit.setAuditState(ArgsConst.REJECT); audit.setAuditState(ArgsConst.REJECT);
audit.setApproverTime(new Date());
boolean update = updateById(audit); boolean update = updateById(audit);
if (update) { if (update) {
recruitment.setAuditState(4); recruitment.setAuditState(4);
@ -541,6 +591,7 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
recruitment.setLastInstance(auditRequest.getAuditOpinion()); recruitment.setLastInstance(auditRequest.getAuditOpinion());
directorsSupervisorsMapper.updateById(recruitment); directorsSupervisorsMapper.updateById(recruitment);
} }
saveAuditLog(auditRequest.getPersonnelId(), loginId, ArgsConst.DIRECTORS, "领导审批拒绝", auditRequest.getAuditOpinion());
return update ? AjaxResult.ok().msg("领导审批拒绝!") : AjaxResult.fail().msg("领导审批失败!"); return update ? AjaxResult.ok().msg("领导审批拒绝!") : AjaxResult.fail().msg("领导审批失败!");
} }
} }
@ -548,5 +599,31 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
} }
/**
* 已提交审批
*
* @param page
* @return
*/
@Override
public AjaxResult submitAudit(Page page) {
Page selectPage = auditMapper.selectPage(page, Wrappers.lambdaQuery(Audit.class)
.eq(Audit::getAuditState, "submit").eq(Audit::getApprover, StpUtil.getLoginIdAsString()));
return AjaxResult.ok().data(selectPage);
}
/**
* 待我审批日志
*
* @param page
* @return
*/
@Override
public AjaxResult waitingAudit(Page page) {
Page selectPage = auditMapper.selectPage(page, Wrappers.lambdaQuery(Audit.class)
.eq(Audit::getAuditOrder, "waiting").eq(Audit::getApprover, StpUtil.getLoginIdAsString()));
return AjaxResult.ok().data(selectPage);
}
} }

View File

@ -5,10 +5,14 @@ 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;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.yulichang.query.MPJQueryWrapper; import com.github.yulichang.query.MPJQueryWrapper;
import com.ydool.common.base.BaseService; import com.ydool.common.base.BaseService;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.common.utils.EasyExcelAlibabaUtil; import com.ydool.common.utils.EasyExcelAlibabaUtil;
import com.ydool.staff.dto.CompanyNameDto;
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.dto.PersonnelStatementDto;
@ -135,7 +139,7 @@ public class CompanyNameServiceImpl extends BaseService<CompanyNameMapper, Compa
} }
@Override @Override
public List<PersonnelStatementDto> perStatement(String id, String firstDate,String finalDate) { public List<PersonnelStatementDto> perStatement(String id, String firstDate, String finalDate) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date first = null; Date first = null;
Date finals = null; Date finals = null;
@ -152,14 +156,14 @@ public class CompanyNameServiceImpl extends BaseService<CompanyNameMapper, Compa
CompanyNameMapper companyNameMapper = SpringUtil.getBean(CompanyNameMapper.class); CompanyNameMapper companyNameMapper = SpringUtil.getBean(CompanyNameMapper.class);
List<PersonnelStatementDto> statementDtos = new ArrayList<>(); List<PersonnelStatementDto> statementDtos = new ArrayList<>();
LambdaQueryWrapper<CompanyName> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CompanyName> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrUtil.isNotBlank(id),CompanyName::getId,id); queryWrapper.eq(StrUtil.isNotBlank(id), CompanyName::getId, id);
List<CompanyName> list = companyNameMapper.selectList(queryWrapper); List<CompanyName> list = companyNameMapper.selectList(queryWrapper);
for (CompanyName companyName : list) { for (CompanyName companyName : list) {
Integer count = directorsSupervisorsMapper.selectCount(new LambdaQueryWrapper<DirectorsSupervisors>().eq(DirectorsSupervisors::getAuditState, 3).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>() LambdaQueryWrapper<Personnel> wrapper = new LambdaQueryWrapper<Personnel>()
.eq(Personnel::getCompanyName, companyName.getId()) .eq(Personnel::getCompanyName, companyName.getId())
.eq(Personnel::getWorkState,"在职") .eq(Personnel::getWorkState, "在职")
.eq(Personnel::getState,"2") .eq(Personnel::getState, "2")
.ge(ObjectUtil.isNotNull(first), Personnel::getHireDate, first) .ge(ObjectUtil.isNotNull(first), Personnel::getHireDate, first)
.le(ObjectUtil.isNotNull(finals), Personnel::getHireDate, finals); .le(ObjectUtil.isNotNull(finals), Personnel::getHireDate, finals);
List<Personnel> listPersonnel = personnelMapper.selectList(wrapper); List<Personnel> listPersonnel = personnelMapper.selectList(wrapper);
@ -179,7 +183,6 @@ public class CompanyNameServiceImpl extends BaseService<CompanyNameMapper, Compa
} }
@Override @Override
public AjaxResult getEntityParam() { public AjaxResult getEntityParam() {
Field[] declaredFields = ExcelPersonnelStatement.class.getDeclaredFields(); Field[] declaredFields = ExcelPersonnelStatement.class.getDeclaredFields();
@ -199,10 +202,17 @@ public class CompanyNameServiceImpl extends BaseService<CompanyNameMapper, Compa
for (String s : personnelParam.getPrams()) { for (String s : personnelParam.getPrams()) {
includeColumnFiledNames.add(s); includeColumnFiledNames.add(s);
} }
//导出 // 导出
EasyExcelAlibabaUtil.exportDownload(response, ExcelPersonnelStatement.class, statement, fileName,includeColumnFiledNames); EasyExcelAlibabaUtil.exportDownload(response, ExcelPersonnelStatement.class, statement, fileName, includeColumnFiledNames);
} }
@Override
public AjaxResult update(CompanyNameDto companyNameDto) {
int i = companyNameMapper.update(null, new UpdateWrapper<CompanyName>().set("check_number", companyNameDto.getCheckNumber()).eq("id", companyNameDto.getId()));
if (i > 0) {
return AjaxResult.ok().msg("修改成功!");
}
return AjaxResult.fail().msg("修改失败!");
}
} }

View File

@ -7,16 +7,14 @@ import cn.hutool.core.util.IdcardUtil;
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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.common.cache.ConfigCache; import com.ydool.common.cache.ConfigCache;
import com.ydool.common.constant.ArgsConst; import com.ydool.common.constant.ArgsConst;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.dto.AttachmentDto; import com.ydool.staff.dto.AttachmentDto;
import com.ydool.staff.dto.DirectorsSupervisorsDto; import com.ydool.staff.dto.DirectorsSupervisorsDto;
import com.ydool.staff.entity.Attachment; import com.ydool.staff.entity.*;
import com.ydool.staff.entity.Audit;
import com.ydool.staff.entity.CompanyName;
import com.ydool.staff.entity.DirectorsSupervisors;
import com.ydool.common.base.BaseService; import com.ydool.common.base.BaseService;
import com.ydool.staff.mapper.AttachmentMapper; import com.ydool.staff.mapper.AttachmentMapper;
import com.ydool.staff.mapper.AuditMapper; import com.ydool.staff.mapper.AuditMapper;
@ -156,12 +154,16 @@ public class DirectorsSupervisorsServiceImpl extends BaseService<DirectorsSuperv
@Override @Override
public AjaxResult submitDirectorsSupervisors(String id, String type) { public AjaxResult submitDirectorsSupervisors(String id, String type) {
Integer count = directorsSupervisorsMapper.selectCount(Wrappers.lambdaQuery(DirectorsSupervisors.class).eq(DirectorsSupervisors::getAuditState, 2));
if (count > 0) {
return AjaxResult.fail("当前有未审批的董监申报!");
}
String loginId = StpUtil.getLoginIdAsString(); String loginId = StpUtil.getLoginIdAsString();
DirectorsSupervisors directorsSupervisors = get(id); DirectorsSupervisors directorsSupervisors = get(id);
if (1 == directorsSupervisors.getAuditState()) { if (1 == directorsSupervisors.getAuditState()) {
return AjaxResult.fail().msg("该数据已送审,请勿重复操作!"); return AjaxResult.fail().msg("该数据已送审,请勿重复操作!");
} }
for (int i = 0; i <= 2; i++) { for (int i = 0; i <= 1; i++) {
Audit audit = new Audit(); Audit audit = new Audit();
audit.setPersonnelId(id); audit.setPersonnelId(id);
audit.setPerType(type); audit.setPerType(type);
@ -171,26 +173,25 @@ public class DirectorsSupervisorsServiceImpl extends BaseService<DirectorsSuperv
audit.setAuditOrder(ArgsConst.GIVE_AUDIT); audit.setAuditOrder(ArgsConst.GIVE_AUDIT);
audit.setApprover(loginId); audit.setApprover(loginId);
audit.setApproverTime(new Date()); audit.setApproverTime(new Date());
} else if (i == 1) { // } else if (i == 1) {
// 待审批 人事部负责人 // // 待审批 人事部负责人
Config config = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR)); // Config config = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR));
User user1 = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getLoginName, config.getParamValue())); // User user1 = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getLoginName, config.getParamValue()));
audit.setAuditOrder(ArgsConst.WAITING); // audit.setAuditOrder(ArgsConst.WAITING);
audit.setApprover(user1.getId()); // audit.setApprover(user1.getId());
audit.setApproverTime(new Date()); // audit.setApproverTime(new Date());
directorsSupervisors.setFirstId(user1.getUserName()); // directorsSupervisors.setFirstId(user1.getUserName());
} else { } else {
// 领导 // 领导
Config config = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP)); Config config = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP));
User user2 = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getLoginName, config.getParamValue())); User user2 = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getLoginName, config.getParamValue()));
audit.setAuditOrder(ArgsConst.LAST); audit.setAuditOrder(ArgsConst.WAITING);
audit.setApprover(user2.getId()); audit.setApprover(user2.getId());
audit.setApproverTime(new Date());
directorsSupervisors.setLastId(user2.getUserName()); directorsSupervisors.setLastId(user2.getUserName());
} }
auditMapper.insert(audit); auditMapper.insert(audit);
} }
directorsSupervisors.setAuditState(1); directorsSupervisors.setAuditState(2);
return updateById(directorsSupervisors) ? AjaxResult.ok().msg("送审成功!") : AjaxResult.fail().msg("送审失败!"); return updateById(directorsSupervisors) ? AjaxResult.ok().msg("送审成功!") : AjaxResult.fail().msg("送审失败!");
} }
} }

View File

@ -1,19 +1,23 @@
package com.ydool.staff.service.impl; package com.ydool.staff.service.impl;
import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.common.cache.ConfigCache; import com.ydool.common.cache.ConfigCache;
import com.ydool.common.constant.ArgsConst; import com.ydool.common.constant.ArgsConst;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.oa.workFlow.data.entity.WorkFlowNotice;
import com.ydool.oa.workFlow.service.WorkFlowNoticeService;
import com.ydool.staff.dto.PlacesDto;
import com.ydool.staff.entity.*; import com.ydool.staff.entity.*;
import com.ydool.common.base.BaseService; import com.ydool.common.base.BaseService;
import com.ydool.staff.mapper.*; import com.ydool.staff.mapper.*;
import com.ydool.staff.request.OrganizationSearch; import com.ydool.staff.request.OrganizationSearch;
import com.ydool.staff.service.IAuditService;
import com.ydool.staff.service.IOrganizationService; import com.ydool.staff.service.IOrganizationService;
import com.ydool.system.entity.Config; import com.ydool.system.entity.Config;
import com.ydool.system.entity.User; import com.ydool.system.entity.User;
@ -53,6 +57,10 @@ public class OrganizationServiceImpl extends BaseService<OrganizationMapper, Org
ConfigMapper configMapper; ConfigMapper configMapper;
@Autowired @Autowired
UserMapper userMapper; UserMapper userMapper;
@Autowired
PlacesMapper placesMapper;
@Autowired
WorkFlowNoticeService workFlowNoticeService;
@Override @Override
public AjaxResult selectOrganizationList(Page<Organization> page, OrganizationSearch organizationSearch) { public AjaxResult selectOrganizationList(Page<Organization> page, OrganizationSearch organizationSearch) {
@ -104,11 +112,12 @@ public class OrganizationServiceImpl extends BaseService<OrganizationMapper, Org
@Override @Override
public AjaxResult submitRecruitment(String id, String type) { public AjaxResult submitRecruitment(String id, String type) {
String loginId = StpUtil.getLoginIdAsString(); String loginId = StpUtil.getLoginIdAsString();
User user = userMapper.selectById(loginId);
Organization organization = get(id); Organization organization = get(id);
if (1 == organization.getAuditState()) { if (1 == organization.getAuditState()) {
return AjaxResult.fail().msg("该数据已送审,请勿重复操作!"); return AjaxResult.fail().msg("该数据已送审,请勿重复操作!");
} }
for (int i = 0; i <= 2; i++) { for (int i = 0; i <= 1; i++) {
Audit audit = new Audit(); Audit audit = new Audit();
audit.setPersonnelId(id); audit.setPersonnelId(id);
audit.setPerType(type); audit.setPerType(type);
@ -118,28 +127,40 @@ public class OrganizationServiceImpl extends BaseService<OrganizationMapper, Org
audit.setAuditOrder(ArgsConst.GIVE_AUDIT); audit.setAuditOrder(ArgsConst.GIVE_AUDIT);
audit.setApprover(loginId); audit.setApprover(loginId);
audit.setApproverTime(new Date()); audit.setApproverTime(new Date());
} else if (i == 1) { // } else if (i == 1) {
// 待审批 人事部负责人 // // 待审批 人事部负责人
Config config = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR)); // Config config = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR));
User user1 = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getLoginName, config.getParamValue())); // User user1 = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getLoginName, config.getParamValue()));
audit.setAuditOrder(ArgsConst.WAITING); // audit.setAuditOrder(ArgsConst.WAITING);
audit.setApprover(user1.getId()); // audit.setApprover(user1.getId());
audit.setApproverTime(new Date()); // audit.setApproverTime(new Date());
organization.setFirstId(user1.getUserName()); // organization.setFirstId(user1.getUserName());
} else { } else {
// 领导 // 领导
Config config = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP)); Config config = configMapper.selectOne(new LambdaQueryWrapper<Config>().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP));
User user2 = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getLoginName, config.getParamValue())); User user2 = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getLoginName, config.getParamValue()));
audit.setAuditOrder(ArgsConst.LAST); audit.setAuditOrder(ArgsConst.WAITING);
audit.setApprover(user2.getId()); audit.setApprover(user2.getId());
audit.setApproverTime(new Date());
organization.setLastId(user2.getUserName()); organization.setLastId(user2.getUserName());
WorkFlowNotice workFlowNotice = new WorkFlowNotice();
workFlowNotice.setStatus(Boolean.FALSE);
workFlowNotice.setFlowType(ArgsConst.PERSONNEL_INDICATORS);
workFlowNotice.setUserId(user2.getId());
workFlowNotice.setTitle(user.getUserName() + "的指标申报待你审批");
workFlowNotice.setFlowId(organization.getId());
workFlowNoticeService.save(workFlowNotice);
} }
auditMapper.insert(audit); auditMapper.insert(audit);
} }
organization.setAuditState(1); organization.setAuditState(2);
return updateById(organization) ? AjaxResult.ok().msg("送审成功!") : AjaxResult.ok().msg("送审失败!"); return updateById(organization) ? AjaxResult.ok().msg("送审成功!") : AjaxResult.ok().msg("送审失败!");
} }
@Override
public AjaxResult approval() {
List<Places> places = placesMapper.selectList(Wrappers.lambdaQuery(Places.class).eq(Places::getStatus, Boolean.FALSE).orderByAsc(Places::getOdd));
return AjaxResult.ok().data(BeanUtil.copyToList(places, PlacesDto.class));
}
} }

View File

@ -1,10 +1,14 @@
package com.ydool.staff.service.impl; package com.ydool.staff.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ydool.common.constant.ArgsConst; import com.ydool.common.constant.ArgsConst;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.dto.PersonnelIndicatorsDto; import com.ydool.staff.dto.PersonnelIndicatorsDto;
@ -17,11 +21,13 @@ import com.ydool.staff.mapper.PersonnelIndicatorsMapper;
import com.ydool.staff.mapper.PersonnelMapper; import com.ydool.staff.mapper.PersonnelMapper;
import com.ydool.staff.request.OrganizationRequest; import com.ydool.staff.request.OrganizationRequest;
import com.ydool.staff.request.PersonnelIndicatorsRequest; import com.ydool.staff.request.PersonnelIndicatorsRequest;
import com.ydool.staff.service.IOrganizationService;
import com.ydool.staff.service.IPersonnelIndicatorsService; import com.ydool.staff.service.IPersonnelIndicatorsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -35,25 +41,44 @@ import java.util.stream.Collectors;
@Service @Service
public class PersonnelIndicatorsServiceImpl extends BaseService<PersonnelIndicatorsMapper, PersonnelIndicators> implements IPersonnelIndicatorsService { public class PersonnelIndicatorsServiceImpl extends BaseService<PersonnelIndicatorsMapper, PersonnelIndicators> implements IPersonnelIndicatorsService {
private static final AtomicInteger counter = new AtomicInteger(0);
@Autowired @Autowired
PersonnelIndicatorsMapper personnelIndicatorsMapper; PersonnelIndicatorsMapper personnelIndicatorsMapper;
@Autowired @Autowired
OrganizationMapper organizationMapper; OrganizationMapper organizationMapper;
@Autowired @Autowired
CompanyNameMapper companyNameMapper; CompanyNameMapper companyNameMapper;
@Autowired
IOrganizationService organizationService;
public static String getNextId() {
int value = counter.incrementAndGet();
return String.format("%04d", value);
}
@Override @Override
public AjaxResult savePersonnelIndicators(PersonnelIndicatorsRequest personnelIndicatorsRequest) { public AjaxResult savePersonnelIndicators(PersonnelIndicatorsRequest personnelIndicatorsRequest) {
Integer count = organizationMapper.selectCount(Wrappers.lambdaQuery(Organization.class).in(Organization::getAuditState, 0, 2).eq(Organization::getType, ArgsConst.PERSONNEL_INDICATORS));
if (count > 0) {
return AjaxResult.fail("当前有未审批的指标申请!");
}
OrganizationRequest organizationRequest = personnelIndicatorsRequest.getOrganizationRequest(); OrganizationRequest organizationRequest = personnelIndicatorsRequest.getOrganizationRequest();
Organization organization = BeanUtil.copyProperties(organizationRequest, Organization.class); Organization organization = BeanUtil.copyProperties(organizationRequest, Organization.class);
// organization.setApprovalNumber(DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss" + getNextId()));
organization.setType(ArgsConst.PERSONNEL_INDICATORS); organization.setType(ArgsConst.PERSONNEL_INDICATORS);
int i = organizationMapper.insert(organization); int i = organizationMapper.insert(organization);
if (i > 0) { if (i > 0) {
List<PersonnelIndicators> personnelIndicators = personnelIndicatorsRequest.getPersonnelIndicators(); List<PersonnelIndicators> personnelIndicators = personnelIndicatorsRequest.getPersonnelIndicators();
for (PersonnelIndicators personnelIndicator : personnelIndicators) { if (CollUtil.isEmpty(personnelIndicators)) {
personnelIndicator.setOrganizationId(organization.getId()); return AjaxResult.fail("人员指标申报不能为空!");
} }
personnelIndicators.forEach(e -> e.setOrganizationId(organization.getId()));
saveBatch(personnelIndicators); saveBatch(personnelIndicators);
// 保存并且送审
if ("approval".equals(personnelIndicatorsRequest.getType())) {
return organizationService.submitRecruitment(organization.getId(), ArgsConst.PERSONNEL_INDICATORS);
}
return AjaxResult.ok().msg("添加成功!"); return AjaxResult.ok().msg("添加成功!");
} }
return AjaxResult.fail().msg("添加失败!"); return AjaxResult.fail().msg("添加失败!");

View File

@ -1,24 +1,22 @@
package com.ydool.staff.service.impl; package com.ydool.staff.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ydool.common.constant.ArgsConst; import com.ydool.common.constant.ArgsConst;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.dto.RecruitmentDto; import com.ydool.staff.dto.RecruitmentDto;
import com.ydool.staff.entity.CompanyName; import com.ydool.staff.entity.*;
import com.ydool.staff.entity.Organization;
import com.ydool.staff.entity.Personnel;
import com.ydool.staff.entity.Recruitment;
import com.ydool.common.base.BaseService; import com.ydool.common.base.BaseService;
import com.ydool.staff.mapper.CompanyNameMapper; import com.ydool.staff.mapper.*;
import com.ydool.staff.mapper.OrganizationMapper;
import com.ydool.staff.mapper.PersonnelMapper;
import com.ydool.staff.mapper.RecruitmentMapper;
import com.ydool.staff.request.OrganizationRequest; import com.ydool.staff.request.OrganizationRequest;
import com.ydool.staff.request.RecruitmentRequest; import com.ydool.staff.request.RecruitmentRequest;
import com.ydool.staff.service.IOrganizationService;
import com.ydool.staff.service.IRecruitmentService; import com.ydool.staff.service.IRecruitmentService;
import com.ydool.system.request.IdsRequest; import com.ydool.system.request.IdsRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -27,6 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@ -39,26 +39,55 @@ import java.util.List;
@Service @Service
public class RecruitmentServiceImpl extends BaseService<RecruitmentMapper, Recruitment> implements IRecruitmentService { public class RecruitmentServiceImpl extends BaseService<RecruitmentMapper, Recruitment> implements IRecruitmentService {
private static final AtomicInteger counter = new AtomicInteger(0);
@Autowired @Autowired
RecruitmentMapper recruitmentMapper; RecruitmentMapper recruitmentMapper;
@Autowired @Autowired
CompanyNameMapper companyNameMapper; CompanyNameMapper companyNameMapper;
@Autowired @Autowired
OrganizationMapper organizationMapper; OrganizationMapper organizationMapper;
@Autowired
IOrganizationService organizationService;
@Autowired
PlacesMapper placesMapper;
public static String getNextId() {
int value = counter.incrementAndGet();
return String.format("%04d", value);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult saveRecruitment(RecruitmentRequest recruitmentRequest) { public AjaxResult saveRecruitment(RecruitmentRequest recruitmentRequest) {
Integer count = organizationMapper.selectCount(Wrappers.lambdaQuery(Organization.class).in(Organization::getAuditState, 0, 2).eq(Organization::getType, ArgsConst.PERSONNEL_INDICATORS));
if (count > 0) {
return AjaxResult.fail("当前有未审批的招聘登记!");
}
OrganizationRequest organizationRequest = recruitmentRequest.getOrganizationRequest(); OrganizationRequest organizationRequest = recruitmentRequest.getOrganizationRequest();
Organization organization = BeanUtil.copyProperties(organizationRequest, Organization.class); Organization organization = BeanUtil.copyProperties(organizationRequest, Organization.class);
// organization.setApprovalNumber(DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss" + getNextId()));
organization.setType(ArgsConst.ORGANIZATION); organization.setType(ArgsConst.ORGANIZATION);
int i = organizationMapper.insert(organization); int i = organizationMapper.insert(organization);
if (i > 0) { if (i > 0) {
List<Recruitment> recruitments = recruitmentRequest.getRecruitments(); List<Recruitment> recruitments = recruitmentRequest.getRecruitments();
for (Recruitment recruitment : recruitments) { if (CollUtil.isEmpty(recruitments)) {
recruitment.setCompanyId(organization.getId()); return AjaxResult.fail("人员登记不能为空!");
} }
recruitments.forEach(e -> e.setCompanyId(organization.getId()));
saveBatch(recruitments); saveBatch(recruitments);
// List<Long> list = recruitments.stream().map(Recruitment::getPlaces).collect(Collectors.toList());
// for (int j = 0; j < list.size(); j++) {
// Places places = new Places();
// places.setStatus(Boolean.FALSE);
// places.setOrganizationId(organization.getId());
// places.setOdd(DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss" + getNextId()));
// placesMapper.insert(places);
// }
// 保存并且送审
if ("approval".equals(recruitmentRequest.getType())) {
return organizationService.submitRecruitment(organization.getId(), ArgsConst.RECRUITMENT);
}
return AjaxResult.ok().msg("添加成功!"); return AjaxResult.ok().msg("添加成功!");
} }
return AjaxResult.fail().msg("添加失败!"); return AjaxResult.fail().msg("添加失败!");