From 9321fafdaaae44e011acbdba1c6fefa0e9ba6c2d Mon Sep 17 00:00:00 2001 From: wulin Date: Thu, 19 Nov 2020 11:18:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BE=85=E5=8A=9E=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lz/common/emun/WorkMsgTypeEnum.java | 7 +- .../com/lz/common/utils/DingTalkUtil.java | 23 +++--- .../modules/app/entity/StaffSimpleInfo.java | 10 +-- .../service/impl/FlowStartServiceImpl.java | 10 +-- .../job/business/DingtalkBusiness.java | 72 ++++++++++++++----- 5 files changed, 85 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/lz/common/emun/WorkMsgTypeEnum.java b/src/main/java/com/lz/common/emun/WorkMsgTypeEnum.java index c12a39a6..848e08fa 100644 --- a/src/main/java/com/lz/common/emun/WorkMsgTypeEnum.java +++ b/src/main/java/com/lz/common/emun/WorkMsgTypeEnum.java @@ -16,9 +16,10 @@ public enum WorkMsgTypeEnum { PASS(3, "绩效通过", "去查看", "# 绩效通过\n ## 你的绩效已经通过"), URGING(4, "绩效催办", "去审批", "# 绩效催办\n ## @提醒您审批"), END(5, "绩效终止", "去查看", "# 绩效终止\n ## @,你的绩效终止"), - START_WORK(6, "绩效考评待办事项", "去查看", "\n 绩效目标制定\n \n @,你的绩效需要制定目标"), - START_SCORE(7, "绩效考评待办事项", "去查看", "\n 绩效结果输入\n \n @,你的绩效需要输入结果"), - PROCESS(8, "绩效考评待办事项", "去查看", "\n @的绩效\n \n 需您去处理"), + START_WORK(6, "绩效考评待办事项", "制定目标", "\n 绩效目标制定\n \n @,你的绩效需要制定目标"), + START_SCORE(7, "绩效考评待办事项", "输入结果", "\n 绩效结果输入\n \n @,你的绩效需要输入结果"), + PROCESS(8, "绩效考评待办事项", "目标确认", "\n @的绩效\n \n 需您去目标确认"), + SCORE(8, "绩效考评待办事项", "评分", "\n @的绩效\n \n 需您去评分"), // 您的2020年10月绩效考核已经开始,请尽快制定绩效目标 // 吴林的2020年12月绩效考核的目标需要您确认,点击前往确认 ; diff --git a/src/main/java/com/lz/common/utils/DingTalkUtil.java b/src/main/java/com/lz/common/utils/DingTalkUtil.java index 1be706b1..ceffca49 100644 --- a/src/main/java/com/lz/common/utils/DingTalkUtil.java +++ b/src/main/java/com/lz/common/utils/DingTalkUtil.java @@ -319,17 +319,19 @@ public class DingTalkUtil { return msg; } //发送待办任务 - public String sendSingleWorkMSG(String appid, StaffEntity staff, String title, String marDown, - String singleTitle, String singleUrl, String token) { + public String sendSingleWorkMSG(String appid, StaffEntity staff, String title, String title1, + String content1, String title2, + String content2, String title3, + String content3, String singleUrl, String token, String from) { String msg = "OK"; ThirdMsgSendRecord thirdMsgSendRecord = new ThirdMsgSendRecord(); thirdMsgSendRecord.setMsgType("work_msg"); thirdMsgSendRecord.setStaffId(staff.getId()); - thirdMsgSendRecord.setMsgTitle(singleTitle); + thirdMsgSendRecord.setMsgTitle(title1 + "#" + title2 + "#" + title3); thirdMsgSendRecord.setAppId(appid); thirdMsgSendRecord.setHeadText(title); - thirdMsgSendRecord.setMsgContent(marDown); + thirdMsgSendRecord.setMsgContent(content1 + "#" + content2 + "#" + content3); thirdMsgSendRecord.setMsgUrl(singleUrl); thirdMsgSendRecord.setStatus(0); try{ @@ -339,15 +341,20 @@ public class DingTalkUtil { req.setCreateTime(System.currentTimeMillis()); req.setTitle(title); req.setUrl(singleUrl); + req.setSourceName(from); List list2 = new ArrayList(); OapiWorkrecordAddRequest.FormItemVo obj3 = new OapiWorkrecordAddRequest.FormItemVo(); list2.add(obj3); - obj3.setTitle(title); - obj3.setContent(marDown); + obj3.setTitle(title1); + obj3.setContent(content1); obj3 = new OapiWorkrecordAddRequest.FormItemVo(); list2.add(obj3); - obj3.setTitle(marDown); - obj3.setContent("123"); + obj3.setTitle(title2); + obj3.setContent(content2); + obj3 = new OapiWorkrecordAddRequest.FormItemVo(); + list2.add(obj3); + obj3.setTitle(title3); + obj3.setContent(content3); req.setFormItemList(list2); OapiWorkrecordAddResponse rsp = client.execute(req, token); diff --git a/src/main/java/com/lz/modules/app/entity/StaffSimpleInfo.java b/src/main/java/com/lz/modules/app/entity/StaffSimpleInfo.java index 86eb9f05..3fc76ecd 100644 --- a/src/main/java/com/lz/modules/app/entity/StaffSimpleInfo.java +++ b/src/main/java/com/lz/modules/app/entity/StaffSimpleInfo.java @@ -2,6 +2,8 @@ package com.lz.modules.app.entity; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.lz.modules.flow.entity.FlowStart; +import com.lz.modules.sys.entity.app.ResultRecord; import lombok.Data; import java.io.Serializable; @@ -46,10 +48,10 @@ public class StaffSimpleInfo implements Serializable { private String employeeId; //头像 private String avatar; - //本次发起任务的id - private Long startId; - //本次发起绩效的id - private Long recordId; + //本次发起任务的 + private ResultRecord resultRecord; + //本次发起的任务信息 + private FlowStart flowStart; diff --git a/src/main/java/com/lz/modules/flow/service/impl/FlowStartServiceImpl.java b/src/main/java/com/lz/modules/flow/service/impl/FlowStartServiceImpl.java index 6418b9c9..727a3f44 100644 --- a/src/main/java/com/lz/modules/flow/service/impl/FlowStartServiceImpl.java +++ b/src/main/java/com/lz/modules/flow/service/impl/FlowStartServiceImpl.java @@ -456,7 +456,7 @@ public class FlowStartServiceImpl extends ServiceImpl toStaffids; if(type == WorkMsgTypeEnum.REJECT.getType()){//被拒 toStaffids = new ArrayList<>(); @@ -232,8 +238,8 @@ public class DingtalkBusiness { toStaffids = staffService.selectStaffSimpleInfos(ids); for (StaffSimpleInfo simpleInfo:toStaffids ) { - simpleInfo.setRecordId(resultRecord.getId()); - simpleInfo.setStartId(resultRecord.getStartId()); + simpleInfo.setResultRecord(resultRecord); + simpleInfo.setFlowStart(flowStart); } sendWorkMSGWithAsyn(fromStaff, toStaffids, WorkMsgTypeEnum.PROCESS.getType()); } @@ -374,30 +380,62 @@ public class DingtalkBusiness { }else{ url += "?halokit=" + System.currentTimeMillis(); } - url += ("&detail=1&id=" + info.getRecordId()); + url += ("&detail=1&id=" + info.getResultRecord().getId()); url = URLEncoder.encode(url); url = "dingtalk://dingtalkclient/action/openapp?corpid=" + thirdAppConfig.getCorpId() + "&container_type=work_platform&app_id=0_" + appid + "&redirect_type=jump&redirect_url=" + url; - String content = null; - if(fromStaff == null){ - content = workMsgTypeEnum.getContent().replace("@", info.getName()); + if(workMsgTypeEnum.getType() == WorkMsgTypeEnum.START_WORK.getType()){ + //发送制定目标通知 + StaffEntity entity = new StaffEntity(); + entity.setId(info.getId()); + entity.setEmployeeId(info.getEmployeeId()); + dingTalkUtil.sendSingleWorkMSG(appid, entity, workMsgTypeEnum.getTitle(), + "任务内容", "目标制定", + "考核名称", info.getFlowStart().getName(), + "被考核人", info.getResultRecord().getStaffName(), + url, token, "霖梓控股"); + }else if(workMsgTypeEnum.getType() == WorkMsgTypeEnum.START_SCORE.getType()){ + //发送开始评分通知 + StaffEntity entity = new StaffEntity(); + entity.setId(info.getId()); + entity.setEmployeeId(info.getEmployeeId()); + dingTalkUtil.sendSingleWorkMSG(appid, entity, workMsgTypeEnum.getTitle(), + "任务内容", "结果录入", + "考核名称", info.getFlowStart().getName(), + "被考核人", info.getResultRecord().getStaffName(), + url, token, "霖梓控股"); }else{ - if(fromStaff.getId() == info.getId()){ - content = workMsgTypeEnum.getContent().replace("@", "您"); + //流程流转通知 + List flowRecords = flowRecordService.selectFlowRecordByRecordIdStatus(info.getResultRecord().getId(), 2); + if(flowRecords.size() == 0){ + //任务结束 }else{ - content = workMsgTypeEnum.getContent().replace("@", fromStaff.getName()); - } + List ids = flowRecords.stream().map(new Function() { + @Override + public Long apply(FlowRecord flowRecord) { + return flowRecord.getApprovalStaffId(); + } + }).collect(Collectors.toList()); + List staffSimpleInfos = staffService.selectStaffSimpleInfos(ids); + for (StaffSimpleInfo staffSimpleInfo:staffSimpleInfos + ) { + StaffEntity entity = new StaffEntity(); + entity.setId(staffSimpleInfo.getId()); + entity.setEmployeeId(staffSimpleInfo.getEmployeeId()); + dingTalkUtil.sendSingleWorkMSG(appid, entity, workMsgTypeEnum.getTitle(), + "任务内容", flowRecords.get(0).getFlowName(), + "考核名称", info.getFlowStart().getName(), + "被考核人", info.getResultRecord().getStaffName(), + url, token, "霖梓控股"); + } + } } - StaffEntity entity = new StaffEntity(); - entity.setId(info.getId()); - entity.setEmployeeId(info.getEmployeeId()); - dingTalkUtil.sendSingleWorkMSG(appid, entity, workMsgTypeEnum.getTitle(), - content, workMsgTypeEnum.getBtnText(), url, token); + }else{ logger.info("ThreadSendMessage token无效"); ; }