diff --git a/src/main/java/com/ydool/common/cache/ConfigCache.java b/src/main/java/com/ydool/common/cache/ConfigCache.java
index 3df12ea..496a216 100644
--- a/src/main/java/com/ydool/common/cache/ConfigCache.java
+++ b/src/main/java/com/ydool/common/cache/ConfigCache.java
@@ -8,7 +8,6 @@ import com.ydool.common.constant.CacheConst;
import com.ydool.common.constant.GrapeConst;
import com.ydool.common.utils.CacheUtil;
import com.ydool.system.entity.Config;
-import com.ydool.system.service.IConfigService;
import com.ydool.system.service.impl.ConfigServiceImpl;
import java.util.List;
@@ -28,6 +27,10 @@ public class ConfigCache {
*/
public static final String USER_INIT_PASSWORD = "sys.user.initPassword";
+
+ public static final String SYS_USER_LEADERSHIP = "sys.user.leadership";
+ public static final String SYS_USER_PERSONNEL_DIRECTOR= "sys.user.personnel.director";
+
/**
* 图片验证码
*/
diff --git a/src/main/java/com/ydool/common/constant/ArgsConst.java b/src/main/java/com/ydool/common/constant/ArgsConst.java
index 2bcc702..4584a11 100644
--- a/src/main/java/com/ydool/common/constant/ArgsConst.java
+++ b/src/main/java/com/ydool/common/constant/ArgsConst.java
@@ -71,6 +71,10 @@ public class ArgsConst {
* 拒绝
*/
public static final String REJECT = "reject";
+ /**
+ * 待处理
+ */
+ public static final String WAITING = "waiting";
/**
* 送审
diff --git a/src/main/java/com/ydool/staff/controller/AuditController.java b/src/main/java/com/ydool/staff/controller/AuditController.java
index 7820f12..5758599 100644
--- a/src/main/java/com/ydool/staff/controller/AuditController.java
+++ b/src/main/java/com/ydool/staff/controller/AuditController.java
@@ -4,6 +4,8 @@ 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.request.AuditRequest;
import com.ydool.staff.service.IAuditLogService;
import com.ydool.staff.service.IAuditService;
import io.swagger.annotations.Api;
@@ -11,6 +13,8 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -43,9 +47,19 @@ public class AuditController extends BaseController {
}
@GetMapping("audtiLog")
- @ApiOperation(value = "处理日志")
+ @ApiOperation(value = "处理日志",response = AuditLogDto.class)
@ApiImplicitParam(name = "id",value = "员工id")
public AjaxResult audtiLog(String id){
return auditLogService.auditLog(id);
}
+
+
+ @PostMapping("addAudit")
+ @ApiOperation(value = "同意/驳回审批")
+ public AjaxResult addAudit(@RequestBody AuditRequest auditRequest) {
+ if ("2".equals(auditRequest.getStatus()) || "3".equals(auditRequest.getStatus())) {
+ return auditService.audit(auditRequest);
+ }
+ return AjaxResult.fail().msg("审批状态错误");
+ }
}
diff --git a/src/main/java/com/ydool/staff/dto/AuditLogDto.java b/src/main/java/com/ydool/staff/dto/AuditLogDto.java
new file mode 100644
index 0000000..7b6dd21
--- /dev/null
+++ b/src/main/java/com/ydool/staff/dto/AuditLogDto.java
@@ -0,0 +1,35 @@
+package com.ydool.staff.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+
+ * @author msh
+ * @since 2023-02-16
+ */
+@Data
+public class AuditLogDto{
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "人员id")
+ private String personnelId;
+
+ @ApiModelProperty(value = "审批人")
+ private String approver;
+
+ @ApiModelProperty(value = "审批状态")
+ private String auditState;
+
+ @ApiModelProperty(value = "处理意见")
+ private String opinion;
+
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+ @ApiModelProperty(value = "处理时间")
+ private LocalDateTime createdAt;
+
+}
diff --git a/src/main/java/com/ydool/staff/request/AuditRequest.java b/src/main/java/com/ydool/staff/request/AuditRequest.java
new file mode 100644
index 0000000..553a7ab
--- /dev/null
+++ b/src/main/java/com/ydool/staff/request/AuditRequest.java
@@ -0,0 +1,29 @@
+package com.ydool.staff.request;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+
+/**
+ * @author msh
+ * @version 1.0
+ * @date 2022/10/14 14:18
+ */
+@Data
+public class AuditRequest {
+
+ @ApiModelProperty(value = "人员id")
+ @NotBlank(message = "id不能为空")
+ private String personnelId;
+
+ @ApiModelProperty(value = "审批状态 2:同意 3:拒绝 ")
+ @NotBlank(message = "审批状态不能为空")
+ private String status;
+
+
+ @ApiModelProperty(value = "审批意见")
+ private String auditOpinion;
+
+}
diff --git a/src/main/java/com/ydool/staff/service/IAuditService.java b/src/main/java/com/ydool/staff/service/IAuditService.java
index c259ff4..dff29b1 100644
--- a/src/main/java/com/ydool/staff/service/IAuditService.java
+++ b/src/main/java/com/ydool/staff/service/IAuditService.java
@@ -2,6 +2,7 @@ package com.ydool.staff.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.common.data.dto.AjaxResult;
+import com.ydool.staff.request.AuditRequest;
/**
*
@@ -14,5 +15,10 @@ import com.ydool.common.data.dto.AjaxResult;
public interface IAuditService {
AjaxResult getAuditList(Page page);
+
+ AjaxResult audit(AuditRequest auditRequest);
+
+ Integer saveAuditLog(String personnelId,String approverId,String auditSate);
+
}
diff --git a/src/main/java/com/ydool/staff/service/impl/AuditLogServiceImpl.java b/src/main/java/com/ydool/staff/service/impl/AuditLogServiceImpl.java
index 33a5d55..9c91368 100644
--- a/src/main/java/com/ydool/staff/service/impl/AuditLogServiceImpl.java
+++ b/src/main/java/com/ydool/staff/service/impl/AuditLogServiceImpl.java
@@ -1,13 +1,18 @@
package com.ydool.staff.service.impl;
+import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ydool.common.base.BaseService;
import com.ydool.common.data.dto.AjaxResult;
+import com.ydool.staff.dto.AuditLogDto;
import com.ydool.staff.entity.AuditLog;
import com.ydool.staff.mapper.AuditLogMapper;
import com.ydool.staff.service.IAuditLogService;
+import com.ydool.system.entity.User;
+import com.ydool.system.mapper.UserMapper;
import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
import java.util.List;
/**
@@ -20,12 +25,18 @@ import java.util.List;
*/
@Service
public class AuditLogServiceImpl extends BaseService implements IAuditLogService {
-
+ @Resource
+ private UserMapper userMapper;
@Override
public AjaxResult auditLog(String id) {
List list = list(new LambdaQueryWrapper().eq(AuditLog::getPersonnelId, id));
- return AjaxResult.ok().data(list);
+ List auditLogDtos = BeanUtil.copyToList(list, AuditLogDto.class);
+ for (AuditLogDto auditLogDto : auditLogDtos) {
+ User user = userMapper.selectById(auditLogDto.getApprover());
+ auditLogDto.setApprover(user.getUserName());
+ }
+ return AjaxResult.ok().data(auditLogDtos);
}
}
diff --git a/src/main/java/com/ydool/staff/service/impl/AuditServiceImpl.java b/src/main/java/com/ydool/staff/service/impl/AuditServiceImpl.java
index ab5b647..dfb9472 100644
--- a/src/main/java/com/ydool/staff/service/impl/AuditServiceImpl.java
+++ b/src/main/java/com/ydool/staff/service/impl/AuditServiceImpl.java
@@ -1,13 +1,30 @@
package com.ydool.staff.service.impl;
+import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydool.common.base.BaseService;
+import com.ydool.common.cache.ConfigCache;
+import com.ydool.common.constant.ArgsConst;
import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.entity.Audit;
-import com.ydool.common.base.BaseService;
+import com.ydool.staff.entity.AuditLog;
+import com.ydool.staff.entity.Personnel;
+import com.ydool.staff.mapper.AuditLogMapper;
import com.ydool.staff.mapper.AuditMapper;
+import com.ydool.staff.mapper.PersonnelMapper;
+import com.ydool.staff.request.AuditRequest;
import com.ydool.staff.service.IAuditService;
+import com.ydool.system.entity.Config;
+import com.ydool.system.entity.User;
+import com.ydool.system.mapper.ConfigMapper;
+import com.ydool.system.mapper.UserMapper;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
/**
*
@@ -20,10 +37,114 @@ import org.springframework.stereotype.Service;
@Service
public class AuditServiceImpl extends BaseService implements IAuditService {
+ @Resource
+ private ConfigMapper configMapper;
+ @Resource
+ private UserMapper userMapper;
+ @Resource
+ private AuditLogMapper auditLogMapper;
+
+ @Resource
+ private PersonnelMapper personnelMapper;
+
+
@Override
public AjaxResult getAuditList(Page page) {
Page AuditPage = page(page, new LambdaQueryWrapper().eq(Audit::getAuditState, "submit"));
return AjaxResult.ok().data(AuditPage);
}
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public AjaxResult audit(AuditRequest auditRequest) {
+ String loginId = (String) StpUtil.getLoginId();
+ Audit one = getOne(new LambdaQueryWrapper()
+ .eq(Audit::getPersonnelId, auditRequest.getPersonnelId())
+ .eq(Audit::getAuditOrder, ArgsConst.WAITING).eq(Audit::getApprover, loginId));
+ if (ObjectUtil.isEmpty(one)){
+ return AjaxResult.fail().msg("该用户不能审批!");
+ }
+ List list = list(new LambdaQueryWrapper().eq(Audit::getPersonnelId, auditRequest.getPersonnelId()));
+ //同意
+ if ("2".equals(auditRequest.getStatus())){
+ for (Audit audit : list) {
+ User byId = userMapper.selectById(audit.getAuditOrder());
+ Config director = configMapper.selectOne(new LambdaQueryWrapper().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR));
+ if (byId.getLoginName().equals(director.getParamValue())){
+ one.setAuditOrder(ArgsConst.PASS);
+ boolean update = updateById(one);
+ if (update){
+ User user = userMapper.selectOne(new LambdaQueryWrapper()
+ .eq(User::getLoginName, configMapper.selectOne(new LambdaQueryWrapper()
+ .eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP)).getParamValue()));
+ Audit auditOne = getOne(new LambdaQueryWrapper().eq(Audit::getApprover, user.getId()).eq(Audit::getPersonnelId, auditRequest.getPersonnelId()));
+ auditOne.setAuditOrder(ArgsConst.WAITING);
+ updateById(auditOne);
+ saveAuditLog(auditRequest.getPersonnelId(),loginId,"一般初审通过");
+ }
+ return update ? AjaxResult.ok().msg("审批成功!"):AjaxResult.fail().msg("审批成功!");
+ }
+ Config leadership = configMapper.selectOne(new LambdaQueryWrapper().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP));
+ if (leadership.getParamValue().equals(byId.getLoginName())){
+ one.setAuditOrder(ArgsConst.PASS);
+ boolean update = updateById(one);
+ if (update){
+ saveAuditLog(auditRequest.getPersonnelId(),loginId,"一般终审通过");
+ Personnel personnel = personnelMapper.selectById(auditRequest.getPersonnelId());
+ personnel.setAuditState(2);
+ personnel.setAlterationSign("2");
+ personnelMapper.updateById(personnel);
+ }
+
+ return update ? AjaxResult.ok().msg("审批成功!"):AjaxResult.fail().msg("审批成功!");
+ }
+
+ }
+ }
+ //拒绝
+ for (Audit audit : list) {
+ User byId = userMapper.selectById(audit.getAuditOrder());
+ Config director = configMapper.selectOne(new LambdaQueryWrapper().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR));
+ if (byId.getLoginName().equals(director.getParamValue())){
+ one.setAuditOrder(ArgsConst.REJECT);
+ one.setOpinion(audit.getOpinion());
+ boolean update = updateById(one);
+ if (update){
+
+ saveAuditLog(auditRequest.getPersonnelId(),loginId,"一般初审拒绝");
+ Personnel personnel = personnelMapper.selectById(auditRequest.getPersonnelId());
+ personnel.setAuditState(3);
+ personnel.setAlterationSign("2");
+ personnelMapper.updateById(personnel);
+ }
+ return update ? AjaxResult.ok().msg("审批成功!"):AjaxResult.fail().msg("审批成功!");
+ }
+ Config leadership = configMapper.selectOne(new LambdaQueryWrapper().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP));
+ if (leadership.getParamValue().equals(byId.getLoginName())){
+ one.setAuditOrder(ArgsConst.REJECT);
+ one.setOpinion(audit.getOpinion());
+ boolean update = updateById(one);
+ if (update){
+ saveAuditLog(auditRequest.getPersonnelId(),loginId,"一般终审拒绝");
+ Personnel personnel = personnelMapper.selectById(auditRequest.getPersonnelId());
+ personnel.setAuditState(3);
+ personnel.setAlterationSign("2");
+ personnelMapper.updateById(personnel);
+ }
+
+ return update ? AjaxResult.ok().msg("审批成功!"):AjaxResult.fail().msg("审批成功!");
+ }
+
+ }
+ return null;
+ }
+ public Integer saveAuditLog(String personnelId,String approverId,String auditSate){
+ AuditLog auditLog = new AuditLog();
+ auditLog.setPersonnelId(personnelId);
+ auditLog.setApprover(approverId);
+ auditLog.setAuditState(auditSate);
+ return auditLogMapper.insert(auditLog);
+ }
+
}
diff --git a/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java b/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java
index 5e43dbe..319b164 100644
--- a/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java
+++ b/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java
@@ -7,10 +7,11 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
-import cn.hutool.extra.spring.SpringUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.common.base.BaseService;
+import com.ydool.common.cache.ConfigCache;
import com.ydool.common.constant.ArgsConst;
import com.ydool.common.data.dto.AjaxResult;
import com.ydool.common.utils.ColumnUtil;
@@ -22,7 +23,6 @@ import com.ydool.staff.dto.PersonnelUpdateDto;
import com.ydool.staff.entity.Alteration;
import com.ydool.staff.entity.Attachment;
import com.ydool.staff.entity.Audit;
-import com.ydool.staff.entity.AuditLog;
import com.ydool.staff.entity.CompanyName;
import com.ydool.staff.entity.Personnel;
import com.ydool.staff.entity.SelectRequest;
@@ -40,9 +40,14 @@ import com.ydool.staff.request.PersonnelDeleteRequest;
import com.ydool.staff.request.PersonnelRequest;
import com.ydool.staff.request.PersonnelUpdateRequest;
import com.ydool.staff.service.IAttachmentService;
+import com.ydool.staff.service.IAuditService;
import com.ydool.staff.service.IPersonnelService;
+import com.ydool.system.entity.Config;
import com.ydool.system.entity.Dept;
+import com.ydool.system.entity.User;
+import com.ydool.system.mapper.ConfigMapper;
import com.ydool.system.mapper.DeptMapper;
+import com.ydool.system.mapper.UserMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -81,6 +86,21 @@ public class PersonnelServiceImpl extends BaseService engageFiles = request.getEngageFiles();
List educationFiles = request.getEducationFiles();
List auditFiles = request.getAuditFiles();
- if (per.getAuditState().equals(0) || per.getAuditState().equals(1)) {
+ if ("1".equals(per.getAlterationSign())) {
return AjaxResult.fail().msg("该人员修改的资料未审批完成,请联系管理员!");
}
String type = ArgsConst.CHANGE;
@@ -235,7 +255,7 @@ public class PersonnelServiceImpl extends BaseService0){
- auditLog.setPersonnelId(audit.getPersonnelId());
- auditLog.setApprover(audit.getApprover());
- auditLog.setAuditState("一般送审提交");
- auditLogMapper.insert(auditLog);
+
+ for(int i=0;i<2;i++ ){
+ Audit audit = new Audit();
+ audit.setPersonnelId(id);
+ audit.setPerType(type);
+ if(i==0){
+ audit.setAuditState(ArgsConst.SUBMIT);
+ audit.setAuditOrder(ArgsConst.GIVE_AUDIT);
+ audit.setApprover(loginId);
+ audit.setApproverTime(new Date());
+ }else if(i==1){
+ audit.setAuditOrder(ArgsConst.FIRST);
+ Config config = configMapper.selectOne(new LambdaQueryWrapper().eq(Config::getParamKey, ConfigCache.SYS_USER_PERSONNEL_DIRECTOR));
+ audit.setAuditOrder(ArgsConst.WAITING);
+ User user = userMapper.selectOne(new LambdaQueryWrapper().eq(User::getLoginName, config.getParamValue()));
+ audit.setApprover(user.getId());
+ }else {
+ audit.setAuditOrder(ArgsConst.LAST);
+ Config config = configMapper.selectOne(new LambdaQueryWrapper().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP));
+ User user = userMapper.selectOne(new LambdaQueryWrapper().eq(User::getLoginName, config.getParamValue()));
+ audit.setApprover(user.getId());
+ }
+ auditMapper.insert(audit);
}
- return i>0 ? AjaxResult.ok().msg("送审成功!") : AjaxResult.fail().msg("送审失败!");
+
+ Personnel personnel = get(id);
+ personnel.setAuditState(1);
+ personnel.setAlterationSign("1");
+ updateById(personnel);
+ Integer a = auditService.saveAuditLog(id, loginId, "一般送审提交");
+ return a>0 ? AjaxResult.ok().msg("送审成功!") : AjaxResult.fail().msg("送审失败!");
}
public PersonnelFailMsgVO checkPersonnelExportVO(PersonnelExportVO personnelExportVO) {
@@ -479,11 +513,7 @@ public class PersonnelServiceImpl extends BaseService