diff --git a/src/main/java/com/lz/common/utils/DingTalkUtil.java b/src/main/java/com/lz/common/utils/DingTalkUtil.java index 5ad039d0..23a45b7e 100644 --- a/src/main/java/com/lz/common/utils/DingTalkUtil.java +++ b/src/main/java/com/lz/common/utils/DingTalkUtil.java @@ -267,7 +267,8 @@ public class DingTalkUtil { } - public String sendSingleActionCardMSG(String appid, StaffEntity staff, String title, String marDown, String singleTitle, String singleUrl, String token) { + public String sendSingleActionCardMSG(String appid, StaffEntity staff, String title, String marDown, + String singleTitle, String singleUrl, String token) { String msg = "OK"; ThirdMsgSendRecord thirdMsgSendRecord = new ThirdMsgSendRecord(); 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 df8fc507..cb6203f2 100644 --- a/src/main/java/com/lz/modules/app/entity/StaffSimpleInfo.java +++ b/src/main/java/com/lz/modules/app/entity/StaffSimpleInfo.java @@ -46,6 +46,10 @@ public class StaffSimpleInfo implements Serializable { private String employeeId; //头像 private String avatar; + //本次发起任务的id + private Long startId; + //本次发起绩效的id + private Long recordId; } 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 f016bc44..ee5c37a2 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 @@ -3,6 +3,7 @@ package com.lz.modules.flow.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.lz.common.emun.ChartOptType; import com.lz.common.emun.CheckStaffType; +import com.lz.common.emun.WorkMsgTypeEnum; import com.lz.common.utils.R; import com.lz.common.utils.StringUtil; import com.lz.modules.app.entity.StaffEntity; @@ -13,6 +14,7 @@ import com.lz.modules.flow.dao.FlowStartMapper; import com.lz.modules.flow.entity.*; import com.lz.modules.flow.model.*; import com.lz.modules.flow.service.*; +import com.lz.modules.job.business.DingtalkBusiness; import com.lz.modules.performance.service.ResultTagetLibService; import com.lz.modules.sys.entity.app.ResultDetail; import com.lz.modules.sys.entity.app.ResultRecord; @@ -81,6 +83,9 @@ public class FlowStartServiceImpl extends ServiceImpl toStaffids, int type) { + + List staffSimpleInfos = staffService.selectStaffSimpleInfos(toStaffids); + return sendWorkMSGWithThread(staffSimpleInfos, type); + } + + public String sendWorkMSGWithThread(List toStaffids, int type) { + + WorkMsgTypeEnum workMsgTypeEnum = WorkMsgTypeEnum.findRoleTypeByCode(type); + + ThreadSendMessage threadSendMessage = new ThreadSendMessage(toStaffids, workMsgTypeEnum, appid); + Thread thread = new Thread(threadSendMessage); + thread.start(); + return "OK"; + } + public String sendWorkMSGByEntity(String appid, StaffEntity fromStaffEntity, StaffEntity toStaffEntity, WorkMsgTypeEnum workMsgTypeEnum, String url){ if(toStaffEntity != null && fromStaffEntity != null){ @@ -250,4 +270,48 @@ public class DingtalkBusiness { logger.info("token的token_code不存在"); return R.error("未授权登录"); } + + public class ThreadSendMessage implements Runnable{ + List toStaffids; + WorkMsgTypeEnum workMsgTypeEnum; + String appid; + String url = ""; + public ThreadSendMessage(List toStaffids, WorkMsgTypeEnum typeEnum, String appid){ + this.toStaffids = toStaffids; + workMsgTypeEnum = typeEnum; + this.appid = appid; + } + + @Override + public void run() { + logger.info("开始批量推送消息,数量{}, appid", toStaffids.size(), appid); + ThirdAppConfig thirdAppConfig = thirdAppConfigService.getByAppId(appid); + String token = dingTalkUtil.getAccessTokenWitchEntity(thirdAppConfig); + for (StaffSimpleInfo info:toStaffids + ) { + if(token != null && token.length() > 0){ + //下面防止第二次发送消息时钉钉不推送 + if(url.contains("?")){ + url += "&halokit=" + System.currentTimeMillis(); + }else{ + url += "?halokit=" + System.currentTimeMillis(); + } + 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;*/ + + url = "dingtalk://dingtalkclient/page/link?pc_slide=true&url=" + url; + + String content = workMsgTypeEnum.getContent().replace("@", info.getName()); + StaffEntity entity = new StaffEntity(); + entity.setId(info.getId()); + entity.setEmployeeId(info.getEmployeeId()); + dingTalkUtil.sendSingleActionCardMSG(appid, entity, workMsgTypeEnum.getTitle(), + content, workMsgTypeEnum.getBtnText(), url, token); + }else{ + logger.info("ThreadSendMessage token无效"); ; + } + } + } + } }