Commit 9e3440cf by huangZW

111

parent 55a2cebb
......@@ -28,4 +28,8 @@ public interface StaffDepartmentRelatedApiService {
StaffDepartmentRelatedDTO getOneByStaffIdAndDepartmentId(String staffId, String departmentId);
String getWxUserIdByClerkId(String clerkId);
//发送消息,单人发送
boolean sendSingleMessage(String wxUserId,String title,String content,String pageUrl);
}
......@@ -47,5 +47,5 @@ public interface StaffDepartmentRelatedMapper {
List<TabHaobanStaffDepartmentRelated> listByWxUserId(@Param("wxUserId")String wxUserId);
List<TabHaobanStaffDepartmentRelated> listByClerkCode(@Param("clerkCode")String clerkCode);
}
\ No newline at end of file
......@@ -4,6 +4,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import cn.hutool.core.collection.CollectionUtil;
......@@ -12,27 +15,37 @@ import com.alibaba.csp.sentinel.util.StringUtil;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.api.dto.MessageDTO;
import com.gic.haoban.manage.api.dto.ApplicationDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.service.ApplicationApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHaobanApplication;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.service.ApplicationService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import org.springframework.stereotype.Service;
@Service
public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRelatedApiService {
private static Logger logger= LoggerFactory.getLogger(StaffDepartmentRelatedApiServiceImpl.class);
@Autowired
private StaffDepartmentRelatedService staffDepartmentRelatedService;
@Autowired
private StaffDepartmentRelatedMapper staffDepartmentRelatedMapper;
@Autowired
private ClerkService clerkService;
@Autowired
private QywxSuiteApiService qywxSuiteApiService;
@Autowired
private Config config;
@Override
public List<StaffDepartmentRelatedDTO> listByDepartmentId(
String departmentId) {
......@@ -108,6 +121,27 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
String wxUserId = list.get(0).getWxUserId();
return wxUserId;
}
@Override
public boolean sendSingleMessage(String clerkId, String title,
String content, String pageUrl) {
String wxUserId = getWxUserIdByClerkId(clerkId);
if(StringUtils.isEmpty(wxUserId)){
logger.info("wxUserId不存在============clerkId={}",clerkId);
return false;
}
String appId = "";
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
ArrayList<String> list = new ArrayList<>();
list.add(wxUserId);
messageDTO.setAppid(appId);
messageDTO.setUserIds(list);
messageDTO.setPage(pageUrl);
messageDTO.setTitle(title);
messageDTO.setDescription(content);
boolean b = qywxSuiteApiService.sendMessage(config.getCorpid(), config.getSuiteId(), messageDTO);
return b;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment