From d6a0c57043e8cc20694a3c678bf8e3a8f28f6499 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 29 五月 2025 11:20:14 +0800
Subject: [PATCH] 新增加用户端接口
---
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java | 81 +++++++++++++++++++++++++++++++++++-----
1 files changed, 70 insertions(+), 11 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..c22c30b 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;
@@ -70,6 +76,10 @@
@Resource
private ISysDeptService sysDeptService;
+ @Resource
+ @Qualifier("wxService")
+ private WxCpService wxCpService;
+
/**
* @description 获取部门员工列表
@@ -79,8 +89,8 @@
* @return List<MgtDeptStaffListVo>
*/
@Override
- public List<MgtDeptStaffListVo> listMgtDeptStaff(){
- return sysStaffMapper.listMgtDeptStaff();
+ public List<MgtDeptStaffListVo> listMgtDeptStaff(Long deptId,Long userId, String name){
+ return sysStaffMapper.listMgtDeptStaff(deptId,userId, name);
}
/**
@@ -92,16 +102,31 @@
*/
@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, null);
return deptStaffListVoList;
}
@@ -190,7 +215,8 @@
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());
@@ -436,4 +462,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