| | |
| | | package com.ruoyi.system.service.impl.staff; |
| | | |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.system.api.domain.poji.sys.SysDept; |
| | | import com.ruoyi.system.api.domain.vo.MgtUserTaskMsgVo; |
| | | import com.ruoyi.system.api.service.RemoteShopService; |
| | | import com.ruoyi.system.domain.pojo.staff.SysStaff; |
| | | import com.ruoyi.system.service.staff.SysStaffService; |
| | | import com.ruoyi.system.service.staff.SysWxCpService; |
| | | import com.ruoyi.system.service.sys.ISysDeptService; |
| | | import lombok.extern.log4j.Log4j2; |
| | |
| | | import me.chanjar.weixin.cp.api.WxCpDepartmentService; |
| | | import me.chanjar.weixin.cp.api.WxCpService; |
| | | import me.chanjar.weixin.cp.bean.WxCpDepart; |
| | | import me.chanjar.weixin.cp.bean.message.WxCpMessage; |
| | | import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | private WxCpService wxCpService; |
| | | |
| | | @Resource |
| | | private RemoteShopService remoteShopService; |
| | | |
| | | @Resource |
| | | private ISysDeptService sysDeptService; |
| | | |
| | | @Resource |
| | | private SysStaffService sysStaffService; |
| | | /** |
| | | * @description |
| | | * @author jqs |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @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 = sysStaffService.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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |