Commit 50510bef by fudahua

Merge remote-tracking branch 'origin/developer' into developer

parents 22ab6b9c 13cc1c78
package com.gic.haoban.manage.api.enums;
/**
* Created by tgs on 2020/2/20.
*/
public enum AppPageType {
//工作台
INDEX(1, ""),
//门店详情
STORE_DETAIL(2, "store_detail"),
//任务详情(会话、话务、不良评价)
TASK_DETAIL(3, "hbapp_task_detail"),
//日报详情
DAILY_DETAIL(4, "hbapp_task_daily_report_detail"),
//指标管理详情
PERFORMANCE_DETAIL(5, "hbapp_task_kpi_detail"),
//顾客详情
CUSTOMER_DETAIL(6, "hbapp_customer_detail"),
//会员列表
MEMBER_LIST(7, "hbapp_customer_list"),
//分配会员
DISTRIBUTE_MEMBER(8, "hbapp_customer_distribute"),
//任务列表
TASK_LIST(9, "hbapp_task_list"),
//商品详情
GOOD_DETAIL(10, "hbapp_commodity_detail");
AppPageType(int type, String desc){
this.code = type;
this.desc = desc;
}
private int code;
private String desc;
public static String getDescByCode(int type) {
for (AppPageType c : AppPageType.values()) {
if (c.getCode() == type) {
return c.desc;
}
}
return null;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
......@@ -27,4 +27,11 @@ public interface StaffDepartmentRelatedApiService {
StaffDepartmentRelatedDTO getOneByStaffIdAndDepartmentId(String staffId, String departmentId);
String getWxUserIdByClerkId(String clerkId);
String getPageUrl(int type,String data);
//发送消息,单人发送
boolean sendSingleMessage(String wxUserId,String title,String content,String pageUrl);
}
......@@ -18,8 +18,18 @@ public class Config {
private String host;
@Value("${wxSuiteid}")
private String wxSuiteid;
public String getCorpid() {
@Value("${appid}")
private String appid;
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getCorpid() {
return corpid;
}
......
......@@ -45,5 +45,7 @@ public interface StaffDepartmentRelatedMapper {
int countByDepartmentIds(@Param("departmentIds")List<String> departmentIds);
List<TabHaobanStaffDepartmentRelated> listByWxUserId(@Param("wxUserId")String wxUserId);
List<TabHaobanStaffDepartmentRelated> listByClerkCode(@Param("clerkCode")String clerkCode);
}
\ No newline at end of file
package com.gic.haoban.manage.service.service.out.impl;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.URLEncodedUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import cn.hutool.core.collection.CollectionUtil;
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.enums.AppPageType;
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(
......@@ -86,6 +106,60 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
StaffDepartmentRelatedDTO dto = EntityUtil.changeEntity(StaffDepartmentRelatedDTO.class, tab);
return dto;
}
@Override
public String getWxUserIdByClerkId(String clerkId) {
ClerkDTO clerkDTO = clerkService.getclerkById(clerkId);
if(clerkDTO == null){
return null;
}
String clerkCode =clerkDTO.getClerkCode();
if(StringUtil.isEmpty(clerkCode) ){
return null;
}
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedMapper.listByClerkCode(clerkCode);
if(CollectionUtil.isEmpty(list)){
return null;
}
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;
}
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
ArrayList<String> list = new ArrayList<>();
list.add(wxUserId);
messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(list);
messageDTO.setPage(pageUrl);
messageDTO.setTitle(title);
messageDTO.setDescription(content);
boolean b = qywxSuiteApiService.sendMessage(config.getCorpid(), config.getSuiteId(), messageDTO);
return b;
}
@Override
public String getPageUrl(int type, String data) {
String baseUrl = "/pages/route/index";
String addurl = AppPageType.getDescByCode(type);
String url = "";
if(type == AppPageType.INDEX.getCode()){
//工作台
url = baseUrl+"?pageType="+addurl;
}else{
url = baseUrl+"?pageType="+addurl;
}
url = url+"&data="+data;
String resultUrl = URLEncoder.encode(url);
return resultUrl;
}
}
......@@ -241,6 +241,14 @@
and status_flag = 1
</select>
<select id="listByClerkCode" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_staff_department_related
where clerk_code = #{clerkCode}
and status_flag = 1
</select>
<select id="countByDepartmentId" resultType="java.lang.Integer" parameterType="java.lang.String" >
select
......
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