| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | @Resource |
| | | private ISysDeptService sysDeptService; |
| | | |
| | | @Resource |
| | | @Qualifier("wxService") |
| | | private WxCpService wxCpService; |
| | | |
| | | |
| | | /** |
| | | * @description 获取部门员工列表 |
| | |
| | | * @return List<MgtDeptStaffListVo> |
| | | */ |
| | | @Override |
| | | public List<MgtDeptStaffListVo> listMgtDeptStaff(){ |
| | | return sysStaffMapper.listMgtDeptStaff(); |
| | | public List<MgtDeptStaffListVo> listMgtDeptStaff(Long deptId,Long userId){ |
| | | return sysStaffMapper.listMgtDeptStaff(deptId,userId); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public List<MgtDeptStaffListVo>listMgtDeptStaffByPermission(Long userId){ |
| | | SysUser sysUser = sysUserService.selectUserById(userId); |
| | | String dataScope = sysUser.getDataScope(); |
| | | List<MgtDeptStaffListVo> deptStaffListVoList; |
| | | if(dataScope!=null&&dataScope.equals("4")){ |
| | | deptStaffListVoList = sysStaffMapper.listMgtDeptStaffByDept(sysUser.getDeptId(),null); |
| | | }else if(dataScope!=null&&dataScope.equals("5")){ |
| | | deptStaffListVoList = sysStaffMapper.listMgtDeptStaffByDept(sysUser.getDeptId(),sysUser.getUserId()); |
| | | }else{ |
| | | deptStaffListVoList = sysStaffMapper.listMgtDeptStaff(); |
| | | // 获取当前登陆人的可视权限 |
| | | SysUser sysUser = sysUserService.selectUserById(userId); |
| | | // 如果当前登陆人权限是查看部门数据 |
| | | Long deptId = null; |
| | | // 如果当前登陆人是查看个人数据 |
| | | Long userId1 = null; |
| | | if (sysUser!=null){ |
| | | String dataScope = sysUser.getDataScope(); |
| | | if (!sysUser.getUserName().equals("admin")){ |
| | | if (org.springframework.util.StringUtils.hasLength(dataScope)){ |
| | | switch (dataScope){ |
| | | case "3": |
| | | // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺 |
| | | deptId = sysUser.getDeptId(); |
| | | break; |
| | | case "5": |
| | | // 仅个人数据 查询当前登陆人关联店铺下的用户 |
| | | userId1 = sysUser.getUserId(); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | deptStaffListVoList = sysStaffMapper.listMgtDeptStaff(deptId,userId1); |
| | | return deptStaffListVoList; |
| | | } |
| | | |
| | |
| | | mgtShopStaffEditDto.setStaffAvatar(sysStaff.getStaffAvatar()); |
| | | remoteShopService.editMgtShopStaff(mgtShopStaffEditDto); |
| | | //如果wxUserId和wxDeptId不为空 同步到企业微信 |
| | | if(mgtStaffEditDto.getWxUserId()!=null&&sysDept.getWxDeptId()!=null){ |
| | | if(sysStaff.getWxUserId()!=null&&sysDept.getWxDeptId()!=null){ |
| | | log.debug("同步员工到企业微信:"+mgtStaffEditDto.getStaffName()); |
| | | MgtWxCPStaffDto mgtWxCPStaffDto = new MgtWxCPStaffDto(); |
| | | mgtWxCPStaffDto.setWxDeptId(sysDept.getWxDeptId()); |
| | | mgtWxCPStaffDto.setWxUserId(mgtStaffEditDto.getWxUserId()); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |