|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.management.platform.controller.AuditWorkflowSettingController;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.vo.SysRichFunction;
|
|
import com.management.platform.entity.vo.SysRichFunction;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.mapper.*;
|
|
@@ -23,6 +24,7 @@ import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.xml.transform.Source;
|
|
import javax.xml.transform.Source;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
|
+import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -39,6 +41,7 @@ import java.util.stream.Collectors;
|
|
@Transactional
|
|
@Transactional
|
|
public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSheet> implements LeaveSheetService {
|
|
public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSheet> implements LeaveSheetService {
|
|
public static final Integer exLeaveDay = 6;
|
|
public static final Integer exLeaveDay = 6;
|
|
|
|
+ public static final String[] LEAVE_TYPES = new String[]{"事假","病假","年假","产假","婚假","丧假","调休假","陪产假","其他"};
|
|
@Resource
|
|
@Resource
|
|
private UserMapper userMapper;
|
|
private UserMapper userMapper;
|
|
@Resource
|
|
@Resource
|
|
@@ -48,14 +51,12 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
@Resource
|
|
@Resource
|
|
private ReportMapper reportMapper;
|
|
private ReportMapper reportMapper;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ private AuditWorkflowSettingService auditWorkflowSettingService;
|
|
|
|
+ @Resource
|
|
private AuditWorkflowSettingMapper auditWorkflowSettingMapper;
|
|
private AuditWorkflowSettingMapper auditWorkflowSettingMapper;
|
|
@Resource
|
|
@Resource
|
|
private DepartmentMapper departmentMapper;
|
|
private DepartmentMapper departmentMapper;
|
|
@Resource
|
|
@Resource
|
|
- private LeavePmauditService leavePmauditService;
|
|
|
|
- @Resource
|
|
|
|
- private UserYearleaveSettingMapper userYearleaveSettingMapper;
|
|
|
|
- @Resource
|
|
|
|
private HttpServletRequest request;
|
|
private HttpServletRequest request;
|
|
@Resource
|
|
@Resource
|
|
SysFunctionMapper sysFunctionMapper;
|
|
SysFunctionMapper sysFunctionMapper;
|
|
@@ -65,6 +66,15 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
WxCorpInfoMapper wxCorpInfoMapper;
|
|
WxCorpInfoMapper wxCorpInfoMapper;
|
|
@Resource
|
|
@Resource
|
|
ExcelExportService excelExportService;
|
|
ExcelExportService excelExportService;
|
|
|
|
+ @Resource
|
|
|
|
+ LeaveAuditLogMapper leaveAuditLogMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ WxCorpInfoService wxCorpInfoService;
|
|
|
|
+ @Resource
|
|
|
|
+ InformationMapper informationMapper;
|
|
|
|
+
|
|
|
|
+ @Value(value = "${upload.path}")
|
|
|
|
+ private String path;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg add(LeaveSheet sheet, String userId) {
|
|
public HttpRespMsg add(LeaveSheet sheet, String userId) {
|
|
@@ -94,36 +104,174 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
//msg.setError("该时间段已有请假申请,不能重复请假");
|
|
//msg.setError("该时间段已有请假申请,不能重复请假");
|
|
msg.setError(MessageUtils.message("leave.repeatedLeave"));
|
|
msg.setError(MessageUtils.message("leave.repeatedLeave"));
|
|
- } else {
|
|
|
|
- //校验当前的指定的项目审核人
|
|
|
|
- //获取第一个审批人
|
|
|
|
- User owner = userMapper.selectById(sheet.getOwnerId());
|
|
|
|
- AuditWorkflowSetting workflowNode = auditWorkflowSettingMapper.selectOne(new QueryWrapper<AuditWorkflowSetting>().eq("type", 0)
|
|
|
|
- .eq("dept_id", owner.getDepartmentId()).orderByAsc("seq").last("limit 1"));
|
|
|
|
- if (workflowNode != null) {
|
|
|
|
- if (workflowNode.getAuditorType() == 0) {
|
|
|
|
- //项目负责人审核, 创建时指定的项目审核人
|
|
|
|
-
|
|
|
|
- } else if (workflowNode.getAuditorType() == 1) {
|
|
|
|
- //部门负责人
|
|
|
|
- Department dept = departmentMapper.selectById(workflowNode.getAuditDeptId());
|
|
|
|
- sheet.setAuditorId(dept.getManagerId());
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- //指定一个人审批
|
|
|
|
- sheet.setAuditorId(workflowNode.getUserId());
|
|
|
|
- sheet.setAuditorName(workflowNode.getUserName());
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取第一个审批人
|
|
|
|
+ User owner = userMapper.selectById(sheet.getOwnerId());
|
|
|
|
+ if (owner.getDepartmentId() == 0) {
|
|
|
|
+ //没有部门,不能提交请假申请
|
|
|
|
+ msg.setError("请联系管理员设置您所在部门");
|
|
|
|
+ return msg;
|
|
|
|
+ } else {
|
|
|
|
+ List<AuditWorkflowSetting> auditList = auditWorkflowSettingService.get(owner.getDepartmentId(), AuditWorkflowSettingController.TYPE_LEAVE);
|
|
|
|
+ if (auditList.size() > 0) {
|
|
|
|
+ AuditWorkflowSetting workflowNode = auditList.get(0);
|
|
|
|
+ if (workflowNode.getAuditorType() == 1) {
|
|
|
|
+ //部门负责人
|
|
|
|
+ Department dept = departmentMapper.selectById(workflowNode.getAuditDeptId());
|
|
|
|
+ if (dept.getManagerId() == null) {
|
|
|
|
+ msg.setError("请联系管理员设置您所在部门的主要负责人");
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
|
|
+ sheet.setAuditorId(dept.getManagerId());
|
|
|
|
+ sheet.setAuditorName(userMapper.selectById(dept.getManagerId()).getName());
|
|
|
|
+ } else if (workflowNode.getAuditorType() == 2) {
|
|
|
|
+ //指定一个人审批
|
|
|
|
+ sheet.setAuditorId(workflowNode.getUserId());
|
|
|
|
+ sheet.setAuditorName(workflowNode.getUserName());
|
|
}
|
|
}
|
|
- leaveSheetMapper.insert(sheet);
|
|
|
|
|
|
+ sheet.setCurAuditSettingId(workflowNode.getId());
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (isNew) {
|
|
|
|
+ leaveSheetMapper.insert(sheet);
|
|
} else {
|
|
} else {
|
|
|
|
+ //编辑修改
|
|
leaveSheetMapper.updateById(sheet);
|
|
leaveSheetMapper.updateById(sheet);
|
|
|
|
+ //之前的审批流程要删除
|
|
|
|
+ leaveAuditLogMapper.delete(new QueryWrapper<LeaveAuditLog>().eq("sheet_id", sheet.getId()));
|
|
|
|
+ }
|
|
|
|
+ sheet = leaveSheetMapper.selectById(sheet.getId());
|
|
|
|
+ saveNotifyToAuditor(sheet);
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ if (wxCorpInfo != null) {
|
|
|
|
+ sendAuditNotifyMsg(wxCorpInfo, user, sheet);
|
|
}
|
|
}
|
|
-
|
|
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //发送审核结果消息提醒
|
|
|
|
+ private void sendAuditResult(WxCorpInfo wxCorpInfo, User auditor, LeaveSheet sheet, String denyReason) {
|
|
|
|
+ //推送到企业微信
|
|
|
|
+ JSONObject json=new JSONObject();
|
|
|
|
+ JSONArray dataJson=new JSONArray();
|
|
|
|
+ JSONObject jsonObj=new JSONObject();
|
|
|
|
+ jsonObj.put("key", "审核结果");
|
|
|
|
+ jsonObj.put("value",sheet.getStatus() == 0?"通过":"驳回");
|
|
|
|
+// jsonObj.put("value",("$userName="+applier.getCorpwxUserid()+"$"));
|
|
|
|
+ JSONObject jsonObj1=new JSONObject();
|
|
|
|
+ jsonObj1.put("key", "审核人");
|
|
|
|
+ jsonObj1.put("value",("$userName="+auditor.getCorpwxUserid()+"$"));
|
|
|
|
+ String applyTimeDesc = "";
|
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("M月d日");
|
|
|
|
+ if (sheet.getStartDate().isEqual(sheet.getEndDate())) {
|
|
|
|
+ applyTimeDesc = dateTimeFormatter.format(sheet.getStartDate()) + ", "+sheet.getTimeHours()+"小时";
|
|
|
|
+ } else {
|
|
|
|
+ applyTimeDesc = dateTimeFormatter.format(sheet.getStartDate()) +"至" + dateTimeFormatter.format(sheet.getEndDate()) + ", "+sheet.getTimeHours()+"小时";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject jsonObj2=new JSONObject();
|
|
|
|
+ jsonObj2.put("key", "请假时间");
|
|
|
|
+ jsonObj2.put("value",applyTimeDesc);
|
|
|
|
+ JSONObject jsonObj4=new JSONObject();
|
|
|
|
+ jsonObj4.put("key", "备注");
|
|
|
|
+ jsonObj4.put("value",sheet.getStatus()==2?("原因:"+denyReason):"请假申请通过了");
|
|
|
|
+ dataJson.add(jsonObj);
|
|
|
|
+ dataJson.add(jsonObj1);
|
|
|
|
+ dataJson.add(jsonObj2);
|
|
|
|
+ dataJson.add(jsonObj4);
|
|
|
|
+ json.put("template_id","tty9TkCAAARfwRKiqfj47qNE70KvGhqg");
|
|
|
|
+ json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=leave#wechat_redirect");
|
|
|
|
+ json.put("content_item",dataJson);
|
|
|
|
+ String ownerId = sheet.getOwnerId();
|
|
|
|
+ User owner = userMapper.selectById(ownerId);
|
|
|
|
+ wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,owner.getCorpwxUserid(), json);
|
|
|
|
+
|
|
|
|
+ //系统内消息
|
|
|
|
+ Information information=new Information();
|
|
|
|
+ information.setUserId(owner.getId());
|
|
|
|
+ information.setTime(LocalDateTime.now());
|
|
|
|
+ information.setMsg("您"+applyTimeDesc + "请假申请审核"+(sheet.getStatus() == 1?"已通过":"已驳回")+", 审核人:"+("$userName="+auditor.getCorpwxUserid()+"$"));
|
|
|
|
+ information.setType(4);
|
|
|
|
+ information.setContent(sheet.getId()+"");
|
|
|
|
+ information.setMsg(applyTimeDesc);
|
|
|
|
+ informationMapper.insert(information);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void saveNotifyToApplier(LeaveSheet sheet) {
|
|
|
|
+ //推送到企业微信
|
|
|
|
+ String applyTimeDesc = "";
|
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("M月d日");
|
|
|
|
+ if (sheet.getStartDate().isEqual(sheet.getEndDate())) {
|
|
|
|
+ applyTimeDesc = dateTimeFormatter.format(sheet.getStartDate()) + ", "+sheet.getTimeHours()+"小时";
|
|
|
|
+ } else {
|
|
|
|
+ applyTimeDesc = dateTimeFormatter.format(sheet.getStartDate()) +"至" + dateTimeFormatter.format(sheet.getEndDate()) + ", "+sheet.getTimeHours()+"小时";
|
|
|
|
+ }
|
|
|
|
+ String ownerId = sheet.getOwnerId();
|
|
|
|
+ User owner = userMapper.selectById(ownerId);
|
|
|
|
+ User auditor = userMapper.selectById(sheet.getAuditorId());
|
|
|
|
+ //系统内消息
|
|
|
|
+ Information information=new Information();
|
|
|
|
+ information.setUserId(owner.getId());
|
|
|
|
+ information.setTime(LocalDateTime.now());
|
|
|
|
+ information.setMsg("您"+applyTimeDesc + "请假申请审核"+(sheet.getStatus() == 1?"已通过":"已驳回")+", 审核人:"
|
|
|
|
+ +(auditor.getCorpwxUserid() != null ? ("$userName="+auditor.getCorpwxUserid()+"$"):auditor.getName()));
|
|
|
|
+ information.setType(4);
|
|
|
|
+ information.setContent(sheet.getId()+"");
|
|
|
|
+ informationMapper.insert(information);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void saveNotifyToAuditor(LeaveSheet sheet) {
|
|
|
|
+ //系统内消息
|
|
|
|
+ Information information=new Information();
|
|
|
|
+ information.setUserId(sheet.getAuditorId());
|
|
|
|
+ information.setTime(LocalDateTime.now());
|
|
|
|
+ User owner = userMapper.selectById(sheet.getOwnerId());
|
|
|
|
+ information.setMsg("请假待审核, 请假人:" + (owner.getCorpwxUserid() != null?("$userName="+owner.getCorpwxUserid()+"$"):owner.getName()));
|
|
|
|
+ information.setType(4);
|
|
|
|
+ information.setContent(sheet.getId()+"");
|
|
|
|
+ informationMapper.insert(information);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //发送待审核提醒
|
|
|
|
+ private void sendAuditNotifyMsg(WxCorpInfo wxCorpInfo, User applier, LeaveSheet sheet) {
|
|
|
|
+ //推送到企业微信
|
|
|
|
+ JSONObject json=new JSONObject();
|
|
|
|
+ JSONArray dataJson=new JSONArray();
|
|
|
|
+ JSONObject jsonObj=new JSONObject();
|
|
|
|
+ jsonObj.put("key", "请假人");
|
|
|
|
+ jsonObj.put("value",("$userName="+applier.getCorpwxUserid()+"$"));
|
|
|
|
+ JSONObject jsonObj1=new JSONObject();
|
|
|
|
+ jsonObj1.put("key", "请假类型");
|
|
|
|
+ jsonObj1.put("value",LEAVE_TYPES[sheet.getLeaveType()]);
|
|
|
|
+ String applyTimeDesc = "";
|
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("M月d日");
|
|
|
|
+ if (sheet.getStartDate().isEqual(sheet.getEndDate())) {
|
|
|
|
+ applyTimeDesc = dateTimeFormatter.format(sheet.getStartDate()) + ", "+sheet.getTimeHours()+"小时";
|
|
|
|
+ } else {
|
|
|
|
+ applyTimeDesc = dateTimeFormatter.format(sheet.getStartDate()) +"至" + dateTimeFormatter.format(sheet.getEndDate()) + ", "+sheet.getTimeHours()+"小时";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject jsonObj2=new JSONObject();
|
|
|
|
+ jsonObj2.put("key", "请假时间");
|
|
|
|
+ jsonObj2.put("value",applyTimeDesc);
|
|
|
|
+ JSONObject jsonObj4=new JSONObject();
|
|
|
|
+ jsonObj4.put("key", "备注");
|
|
|
|
+ jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
|
|
|
|
+ dataJson.add(jsonObj);
|
|
|
|
+ dataJson.add(jsonObj1);
|
|
|
|
+ dataJson.add(jsonObj2);
|
|
|
|
+ dataJson.add(jsonObj4);
|
|
|
|
+ json.put("template_id","tty9TkCAAA4WvYmTnsAVoUmdYxHdSG9A");
|
|
|
|
+ json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=leave#wechat_redirect");
|
|
|
|
+ json.put("content_item",dataJson);
|
|
|
|
+ String auditorId = sheet.getAuditorId();
|
|
|
|
+ User auditor = userMapper.selectById(auditorId);
|
|
|
|
+ wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,auditor.getCorpwxUserid(), json);
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg delete(Integer id) {
|
|
public HttpRespMsg delete(Integer id) {
|
|
leaveSheetMapper.deleteById(id);
|
|
leaveSheetMapper.deleteById(id);
|
|
@@ -135,6 +283,7 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
QueryWrapper<LeaveSheet> queryWrapper = new QueryWrapper<LeaveSheet>();
|
|
QueryWrapper<LeaveSheet> queryWrapper = new QueryWrapper<LeaveSheet>();
|
|
String token = request.getHeader("TOKEN");
|
|
String token = request.getHeader("TOKEN");
|
|
User user = userMapper.selectById(token);
|
|
User user = userMapper.selectById(token);
|
|
|
|
+
|
|
List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部请假单");
|
|
List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部请假单");
|
|
if (functionList.size() == 0) {
|
|
if (functionList.size() == 0) {
|
|
//部门负责人可以看这个部门的
|
|
//部门负责人可以看这个部门的
|
|
@@ -197,20 +346,127 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg approve(Integer id) {
|
|
public HttpRespMsg approve(Integer id) {
|
|
- LeaveSheet sheet = new LeaveSheet();
|
|
|
|
- sheet.setId(id);
|
|
|
|
- sheet.setStatus(0);
|
|
|
|
- leaveSheetMapper.updateById(sheet);
|
|
|
|
- return new HttpRespMsg();
|
|
|
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
|
+ //检查操作人权限
|
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ LeaveSheet originSheet = leaveSheetMapper.selectById(id);
|
|
|
|
+ if (user.getId().equals(originSheet.getAuditorId())) {
|
|
|
|
+ //是当前的审核人,获取下个审核节点
|
|
|
|
+ AuditWorkflowSetting auditWorkflowSetting = auditWorkflowSettingMapper.selectById(originSheet.getCurAuditSettingId());
|
|
|
|
+ LeaveSheet sheet = new LeaveSheet();
|
|
|
|
+ sheet.setId(id);
|
|
|
|
+ if (auditWorkflowSetting == null) {
|
|
|
|
+ //当前审核节点已不存在,直接审核通过
|
|
|
|
+ sheet.setStatus(0);
|
|
|
|
+ } else {
|
|
|
|
+ Integer seq = auditWorkflowSetting.getSeq();
|
|
|
|
+ AuditWorkflowSetting nextAuditNode = auditWorkflowSettingMapper.selectOne(new QueryWrapper<AuditWorkflowSetting>().eq("seq", (seq + 1)).eq("dept_id", auditWorkflowSetting.getDeptId()));
|
|
|
|
+ if (nextAuditNode == null) {
|
|
|
|
+ sheet.setStatus(0);
|
|
|
|
+ } else {
|
|
|
|
+ //进入下个审核节点
|
|
|
|
+ if (nextAuditNode.getAuditorType() == 1) {
|
|
|
|
+ //部门负责人审核
|
|
|
|
+ Department department = departmentMapper.selectById(nextAuditNode.getAuditDeptId());
|
|
|
|
+ if (department == null) {
|
|
|
|
+ //部门已被删除,直接审核通过
|
|
|
|
+ sheet.setStatus(0);
|
|
|
|
+ } else {
|
|
|
|
+ if (department.getManagerId() == null) {
|
|
|
|
+ httpRespMsg.setError("尚未设置下个节点的部门负责人,请联系管理员");
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ } else {
|
|
|
|
+ sheet.setCurAuditSettingId(nextAuditNode.getId());
|
|
|
|
+ sheet.setAuditorId(department.getManagerId());
|
|
|
|
+ sheet.setAuditorName(userMapper.selectById(department.getManagerId()).getName());
|
|
|
|
+ sheet.setAuditorType(nextAuditNode.getAuditorType());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (nextAuditNode.getAuditorType() == 2){
|
|
|
|
+ //指定人员审核
|
|
|
|
+ sheet.setCurAuditSettingId(nextAuditNode.getId());
|
|
|
|
+ sheet.setAuditorId(nextAuditNode.getUserId());
|
|
|
|
+ sheet.setAuditorName(nextAuditNode.getUserName());
|
|
|
|
+ sheet.setAuditorType(nextAuditNode.getAuditorType());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ leaveSheetMapper.updateById(sheet);
|
|
|
|
+ //保存审核记录
|
|
|
|
+ saveAgreeLog(id, auditWorkflowSetting, user);
|
|
|
|
+ //最终审核通过,发送通过消息
|
|
|
|
+ sheet = leaveSheetMapper.selectById(id);
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ if (wxCorpInfo != null) {
|
|
|
|
+ if (sheet.getStatus() == 0) {
|
|
|
|
+ //最终通过
|
|
|
|
+ sendAuditResult(wxCorpInfo, user, sheet, null);
|
|
|
|
+ } else {
|
|
|
|
+ //通知下个节点的审核人去审核
|
|
|
|
+ sendAuditNotifyMsg(wxCorpInfo, user, sheet);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (sheet.getStatus() == 0) {
|
|
|
|
+ //最终通过
|
|
|
|
+ saveNotifyToApplier(sheet);
|
|
|
|
+ } else {
|
|
|
|
+ //通知下个节点的审核人去审核
|
|
|
|
+ saveNotifyToAuditor(sheet);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void saveAgreeLog(int sheetId, AuditWorkflowSetting curAuditNode, User operator) {
|
|
|
|
+ LeaveAuditLog log = new LeaveAuditLog();
|
|
|
|
+ log.setSheetId(sheetId);
|
|
|
|
+ if (curAuditNode != null) {
|
|
|
|
+ log.setAuditNodeId(curAuditNode.getId());
|
|
|
|
+ }
|
|
|
|
+ log.setAuditorId(operator.getId());
|
|
|
|
+ log.setAuditorName(operator.getName());
|
|
|
|
+ log.setIsPass(1);
|
|
|
|
+ leaveAuditLogMapper.insert(log);
|
|
|
|
+ }
|
|
|
|
+ private void saveDenyLog(int sheetId, AuditWorkflowSetting curAuditNode, User operator, String reason) {
|
|
|
|
+ LeaveAuditLog log = new LeaveAuditLog();
|
|
|
|
+ log.setSheetId(sheetId);
|
|
|
|
+ if (curAuditNode != null) {
|
|
|
|
+ log.setAuditNodeId(curAuditNode.getId());
|
|
|
|
+ }
|
|
|
|
+ log.setAuditorId(operator.getId());
|
|
|
|
+ log.setAuditorName(operator.getName());
|
|
|
|
+ log.setIsPass(0);
|
|
|
|
+ log.setDenyReason(reason);
|
|
|
|
+ leaveAuditLogMapper.insert(log);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg deny(Integer id) {
|
|
|
|
- LeaveSheet sheet = new LeaveSheet();
|
|
|
|
- sheet.setId(id);
|
|
|
|
- sheet.setStatus(2);
|
|
|
|
- leaveSheetMapper.updateById(sheet);
|
|
|
|
- return new HttpRespMsg();
|
|
|
|
|
|
+ public HttpRespMsg deny(Integer id, String reason) {
|
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
|
+ //检查操作人权限
|
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ LeaveSheet originSheet = leaveSheetMapper.selectById(id);
|
|
|
|
+ if (user.getId().equals(originSheet.getAuditorId())) {
|
|
|
|
+ //是当前的审核人,获取当前审核节点
|
|
|
|
+ AuditWorkflowSetting auditWorkflowSetting = auditWorkflowSettingMapper.selectById(originSheet.getCurAuditSettingId());
|
|
|
|
+ LeaveSheet sheet = new LeaveSheet();
|
|
|
|
+ sheet.setId(id);
|
|
|
|
+ sheet.setStatus(2);
|
|
|
|
+ leaveSheetMapper.updateById(sheet);
|
|
|
|
+ saveDenyLog(id, auditWorkflowSetting, user, reason);
|
|
|
|
+ sheet = leaveSheetMapper.selectById(id);
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ if (wxCorpInfo != null) {
|
|
|
|
+ sendAuditResult(wxCorpInfo, user, sheet, reason);
|
|
|
|
+ }
|
|
|
|
+ saveNotifyToApplier(sheet);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -238,22 +494,54 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
- @Value(value = "${upload.path}")
|
|
|
|
- private String path;
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg exportLeaveData(String userId,Integer status,Integer leaveType,String startTime,String endTime) {
|
|
public HttpRespMsg exportLeaveData(String userId,Integer status,Integer leaveType,String startTime,String endTime) {
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
Integer companyId = userMapper.selectById(userId).getCompanyId();
|
|
Integer companyId = userMapper.selectById(userId).getCompanyId();
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).select("id","name","corpwx_userid"));
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).select("id","name","corpwx_userid"));
|
|
- QueryWrapper<LeaveSheet> qw = new QueryWrapper<LeaveSheet>()
|
|
|
|
- .select("owner_id","tel","owner_name", "leave_type", "start_date","end_date","time_days", "time_hours", "status", "remark")
|
|
|
|
- .eq("company_id", companyId)
|
|
|
|
- .eq(status != null, "status", status)
|
|
|
|
- .eq(leaveType != null, "leave_type", leaveType)
|
|
|
|
- .le(endTime != "" && endTime != null, "start_date", endTime)
|
|
|
|
- .ge(startTime != "" && startTime != null, "end_date", startTime).orderByDesc("id");
|
|
|
|
- List<LeaveSheet> leaveSheets = leaveSheetMapper.selectList(qw);
|
|
|
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
|
+ QueryWrapper<LeaveSheet> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ LeaveSheet sheet = new LeaveSheet();
|
|
|
|
+ List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部请假单");
|
|
|
|
+ if (functionList.size() == 0) {
|
|
|
|
+ //部门负责人可以看这个部门的
|
|
|
|
+ List<Integer> mdids = departmentService.getAllManagedDeptIdList(user, null);
|
|
|
|
+// List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()));
|
|
|
|
+ if (mdids.size() > 0) {
|
|
|
|
+ //负责的部门的人员
|
|
|
|
+ //先是自己的
|
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
|
+ userIds.add(user.getId());
|
|
|
|
+ List<User> deptUserList = userMapper.selectList(new QueryWrapper<User>().select("id").in("department_id", mdids));
|
|
|
|
+ List<String> collect = deptUserList.stream().map(User::getId).collect(Collectors.toList());
|
|
|
|
+ userIds.addAll(collect);
|
|
|
|
+ queryWrapper.in("owner_id", userIds);
|
|
|
|
+ } else {
|
|
|
|
+ //普通员工只能看自己的
|
|
|
|
+ sheet.setOwnerId(user.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ sheet.setCompanyId(user.getCompanyId());
|
|
|
|
+
|
|
|
|
+ queryWrapper.eq("company_id", sheet.getCompanyId()).orderByDesc("id");
|
|
|
|
+ //增加状态
|
|
|
|
+ if (sheet.getStatus() != null) {
|
|
|
|
+ queryWrapper.eq("status", sheet.getStatus());
|
|
|
|
+ }
|
|
|
|
+ if (!StringUtils.isEmpty(sheet.getOwnerId())) {
|
|
|
|
+ queryWrapper.eq("owner_id", sheet.getOwnerId());
|
|
|
|
+ }
|
|
|
|
+ if (sheet.getLeaveType() != null) {
|
|
|
|
+ queryWrapper.eq("leave_type", leaveType);
|
|
|
|
+ }
|
|
|
|
+ if (sheet.getStartDate() != null && sheet.getEndDate() != null) {
|
|
|
|
+ queryWrapper.le("start_date", startTime).ge("end_date", endTime);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<LeaveSheet> leaveSheets = leaveSheetMapper.selectList(queryWrapper);
|
|
if (leaveSheets.size()==0){
|
|
if (leaveSheets.size()==0){
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
};
|
|
};
|
|
@@ -330,6 +618,12 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
item.add(eds);
|
|
item.add(eds);
|
|
item.add(leaveSheet.getTimeDays()==null?"":leaveSheet.getTimeDays().toString());
|
|
item.add(leaveSheet.getTimeDays()==null?"":leaveSheet.getTimeDays().toString());
|
|
item.add(leaveSheet.getTimeHours()==null?"":leaveSheet.getTimeHours().toString());
|
|
item.add(leaveSheet.getTimeHours()==null?"":leaveSheet.getTimeHours().toString());
|
|
|
|
+ Optional<User> first = userList.stream().filter(u -> u.getId().equals(leaveSheet.getAuditorId())).findFirst();
|
|
|
|
+ String auditorName = first.isPresent()?first.get().getName():"";
|
|
|
|
+ //转译处理
|
|
|
|
+ if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
|
|
|
|
+ auditorName = "$userName="+auditorName+"$";
|
|
|
|
+ }
|
|
String statusS = "";
|
|
String statusS = "";
|
|
switch (leaveSheet.getStatus()){
|
|
switch (leaveSheet.getStatus()){
|
|
case 0:
|
|
case 0:
|
|
@@ -338,7 +632,8 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
break;
|
|
break;
|
|
case 1:
|
|
case 1:
|
|
//statusS = "待审核";
|
|
//statusS = "待审核";
|
|
- statusS = MessageUtils.message("stages.reviewed");
|
|
|
|
|
|
+ statusS = MessageUtils.message("stages.reviewed")
|
|
|
|
+ + "-" + auditorName;
|
|
break;
|
|
break;
|
|
case 2:
|
|
case 2:
|
|
//statusS = "驳回";
|
|
//statusS = "驳回";
|
|
@@ -362,4 +657,68 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
}
|
|
}
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg cancel(Integer id, String userId) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ LeaveSheet oldSheet = leaveSheetMapper.selectById(id);
|
|
|
|
+ if (oldSheet.getStatus() == 0) {
|
|
|
|
+ msg.setError("当前请假申请已通过,无法撤销");
|
|
|
|
+ } else if (oldSheet.getStatus() == 2) {
|
|
|
|
+ msg.setError("当前请假申已驳回,无法撤销");
|
|
|
|
+ } else {
|
|
|
|
+ LeaveSheet sheet = new LeaveSheet();
|
|
|
|
+ sheet.setId(id);
|
|
|
|
+ sheet.setStatus(3);//撤销状态
|
|
|
|
+ leaveSheetMapper.updateById(sheet);
|
|
|
|
+ //删除相关的审批记录
|
|
|
|
+ leaveAuditLogMapper.delete(new QueryWrapper<LeaveAuditLog>().eq("sheet_id", id));
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg auditList(LeaveSheet sheet, Integer pageIndex, Integer pageSize) {
|
|
|
|
+ QueryWrapper<LeaveSheet> queryWrapper = new QueryWrapper<LeaveSheet>();
|
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
|
+
|
|
|
|
+ sheet.setCompanyId(user.getCompanyId());
|
|
|
|
+
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ queryWrapper.eq("company_id", sheet.getCompanyId()).orderByDesc("id");
|
|
|
|
+ queryWrapper.eq("status", 1);
|
|
|
|
+ queryWrapper.eq("auditor_id", user.getId());
|
|
|
|
+
|
|
|
|
+ if (!StringUtils.isEmpty(sheet.getOwnerId())) {
|
|
|
|
+ queryWrapper.eq("owner_id", sheet.getOwnerId());
|
|
|
|
+ }
|
|
|
|
+ if (sheet.getLeaveType() != null) {
|
|
|
|
+ queryWrapper.eq("leave_type", sheet.getLeaveType());
|
|
|
|
+ }
|
|
|
|
+ if (sheet.getStartDate() != null && sheet.getEndDate() != null) {
|
|
|
|
+ queryWrapper.le("start_date", sheet.getEndDate()).ge("end_date", sheet.getStartDate());
|
|
|
|
+ }
|
|
|
|
+ IPage<LeaveSheet> listIPager = leaveSheetMapper.selectPage(new Page<>(pageIndex, pageSize),
|
|
|
|
+ queryWrapper);
|
|
|
|
+ List<LeaveSheet> records = listIPager.getRecords();
|
|
|
|
+ List<String> userIds = records.stream().map(LeaveSheet::getOwnerId).collect(Collectors.toList());
|
|
|
|
+ if (userIds.size() > 0) {
|
|
|
|
+ List<User> userList = userMapper.getUserWithDept(new QueryWrapper<User>().in("id", userIds));
|
|
|
|
+ records.stream().forEach(r->{
|
|
|
|
+ Optional<User> find = userList.stream().filter(u->u.getId().equals(r.getOwnerId())).findFirst();
|
|
|
|
+ if (find.isPresent()) {
|
|
|
|
+ r.setDept(find.get().getDepartmentName());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Long total = listIPager.getTotal();
|
|
|
|
+
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("records", records);
|
|
|
|
+ map.put("total", total);
|
|
|
|
+ httpRespMsg.data = map;
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
}
|
|
}
|