|
@@ -24,6 +24,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.xml.transform.Source;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -40,6 +41,7 @@ import java.util.stream.Collectors;
|
|
|
@Transactional
|
|
|
public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSheet> implements LeaveSheetService {
|
|
|
public static final Integer exLeaveDay = 6;
|
|
|
+ public static final String[] LEAVE_TYPES = new String[]{"事假","病假","年假","产假","婚假","丧假","调休假","陪产假","其他"};
|
|
|
@Resource
|
|
|
private UserMapper userMapper;
|
|
|
@Resource
|
|
@@ -55,10 +57,6 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
|
@Resource
|
|
|
private DepartmentMapper departmentMapper;
|
|
|
@Resource
|
|
|
- private LeavePmauditService leavePmauditService;
|
|
|
- @Resource
|
|
|
- private UserYearleaveSettingMapper userYearleaveSettingMapper;
|
|
|
- @Resource
|
|
|
private HttpServletRequest request;
|
|
|
@Resource
|
|
|
SysFunctionMapper sysFunctionMapper;
|
|
@@ -70,6 +68,11 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
|
ExcelExportService excelExportService;
|
|
|
@Resource
|
|
|
LeaveAuditLogMapper leaveAuditLogMapper;
|
|
|
+ @Resource
|
|
|
+ WxCorpInfoService wxCorpInfoService;
|
|
|
+ @Resource
|
|
|
+ InformationMapper informationMapper;
|
|
|
+
|
|
|
@Value(value = "${upload.path}")
|
|
|
private String path;
|
|
|
|
|
@@ -128,6 +131,7 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
|
sheet.setAuditorId(workflowNode.getUserId());
|
|
|
sheet.setAuditorName(workflowNode.getUserName());
|
|
|
}
|
|
|
+ sheet.setCurAuditSettingId(workflowNode.getId());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -136,10 +140,138 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
|
} else {
|
|
|
//编辑修改
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
+ //发送审核结果消息提醒
|
|
|
+ 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("MM/dd");
|
|
|
+ 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("MM/dd");
|
|
|
+ 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("MM/dd");
|
|
|
+ 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
|
|
|
public HttpRespMsg delete(Integer id) {
|
|
|
leaveSheetMapper.deleteById(id);
|
|
@@ -251,14 +383,38 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
|
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;
|
|
|
}
|
|
|
|
|
@@ -302,6 +458,12 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
|
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;
|