From 64251287f735a6a26bc585a8ca593c3936113137 Mon Sep 17 00:00:00 2001 From: jiangqs <jiangqs> Date: 星期四, 07 九月 2023 18:04:47 +0800 Subject: [PATCH] bug --- ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java index d414340..c69d991 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java @@ -16,6 +16,7 @@ import com.ruoyi.system.api.domain.dto.MgtShopStaffEditDto; import com.ruoyi.system.api.domain.poji.sys.SysDept; import com.ruoyi.system.api.domain.poji.sys.SysUser; +import com.ruoyi.system.api.domain.vo.MgtUserTaskMsgVo; import com.ruoyi.system.api.service.RemoteShopService; import com.ruoyi.system.domain.dto.MgtStaffEditDto; import com.ruoyi.system.domain.dto.MgtStaffPageDto; @@ -31,6 +32,11 @@ import com.ruoyi.system.service.sys.ISysDeptService; import com.ruoyi.system.service.sys.ISysUserService; import com.ruoyi.system.util.QiYeUtils; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.message.WxCpMessage; +import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -69,6 +75,10 @@ @Resource private ISysDeptService sysDeptService; + + @Resource + @Qualifier("wxService") + private WxCpService wxCpService; /** @@ -436,4 +446,37 @@ public List<SysStaff> listSysStaffByIds(List<Long> userIdList){ return sysStaffMapper.listSysStaffByIds(userIdList); } + + /** + * @description 企业微信消息推送 + * @author jqs + * @date 2023/8/29 11:05 + * @return void + */ + @Override + public void sendTaskMessage(){ + //获取员工任务列表 + List<MgtUserTaskMsgVo> userTaskMsgVoList = remoteShopService.getTaskMsgList().getData(); + WxCpMessage message; + SysStaff sysStaff; + if(userTaskMsgVoList!=null&&!userTaskMsgVoList.isEmpty()){ + //循环发送消息 + for(MgtUserTaskMsgVo mgtUserTaskMsgVo : userTaskMsgVoList){ + sysStaff = this.getByUserId(mgtUserTaskMsgVo.getUserId()); + if(sysStaff!=null&& StringUtils.isNotBlank(sysStaff.getWxUserId())){ + message = new WxCpMessage(); + message.setAgentId(1000024); + message.setToUser(sysStaff.getWxUserId()); + message.setMsgType("text"); + message.setContent(mgtUserTaskMsgVo.getTaskTitle()+"今日需要任务跟进,请注意!"); + try { + WxCpMessageSendResult result = wxCpService.getMessageService().send(message); + System.out.println(result); + } catch (WxErrorException e) { + throw new RuntimeException(e); + } + } + } + } + } } -- Gitblit v1.7.1