Commit 26e9ab3e authored by 王亚雷's avatar 王亚雷

Merge remote-tracking branch 'origin/v2.3.1'

parents d3a9f93c 7dd7863c
package com.tanpu.community.api.beans.vo.feign.fatools;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Description 用户信息
* @Author wangyalei
* @Date 2020/10/20 16:50
**/
@ApiModel("用户简要信息")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SimpleUserInfo {
@ApiModelProperty("用户id")
private String id;
@ApiModelProperty("用户昵称")
private String uiNickname;
@ApiModelProperty("用户姓名")
private String uiUsernameMp;
@ApiModelProperty("用户头像")
private String uiHeadimgMp;
@ApiModelProperty("所属机构Id")
private String orgId;
@ApiModelProperty("微信授权手机号")
private String wxAuthPhone;
@ApiModelProperty("注册时间")
private Long uiRegisterTime;
@ApiModelProperty("用户等级")
private Integer levelGrade;
@ApiModelProperty("realname")
private String realname;
@ApiModelProperty("注册手机号")
private String uiTelphone;
}
package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@ApiModel(value="wx_cp_user")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "wx_cp_user")
public class WxCpUser {
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty(value="主键")
private Long id;
/**
* 成员UserID。对应管理端的帐号
*/
@TableField(value = "user_id")
@ApiModelProperty(value="成员UserID。对应管理端的帐号")
private String userId;
/**
* 成员名称
*/
@TableField(value = "`name`")
@ApiModelProperty(value="成员名称")
private String name;
/**
* 手机号码
*/
@TableField(value = "mobile")
@ApiModelProperty(value="手机号码")
private String mobile;
/**
* 成员所属部门id列表
*/
@TableField(value = "department")
@ApiModelProperty(value="成员所属部门id列表")
private String department;
/**
* 部门内的排序值,默认为0。数量必须和department一致,数值越大排序越前面。值范围是[0, 2^32)
*/
@TableField(value = "`order`")
@ApiModelProperty(value="部门内的排序值,默认为0。数量必须和department一致,数值越大排序越前面。值范围是[0, 2^32)")
private String order;
/**
* 职务信息
*/
@TableField(value = "`position`")
@ApiModelProperty(value="职务信息")
private String position;
/**
* 0表示未定义,1表示男性,2表示女性
*/
@TableField(value = "gender")
@ApiModelProperty(value="0表示未定义,1表示男性,2表示女性")
private Integer gender;
/**
* 邮箱
*/
@TableField(value = "email")
@ApiModelProperty(value="邮箱")
private String email;
/**
* 表示在所在的部门内是否为部门负责人,数量与department一致
*/
@TableField(value = "is_leader_in_dept")
@ApiModelProperty(value="表示在所在的部门内是否为部门负责人,数量与department一致")
private String isLeaderInDept;
/**
* 头像url
*/
@TableField(value = "avatar")
@ApiModelProperty(value="头像url")
private String avatar;
/**
* 头像缩略图url
*/
@TableField(value = "thumb_avatar")
@ApiModelProperty(value="头像缩略图url")
private String thumbAvatar;
/**
* 激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业
*/
@TableField(value = "`status`")
@ApiModelProperty(value="激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业")
private Integer status;
/**
* 员工个人二维码,扫描可添加为外部联系人
*/
@TableField(value = "qr_code")
@ApiModelProperty(value="员工个人二维码,扫描可添加为外部联系人")
private String qrCode;
/**
* 地址
*/
@TableField(value = "address")
@ApiModelProperty(value="地址")
private String address;
/**
* 主部门
*/
@TableField(value = "main_department")
@ApiModelProperty(value="主部门")
private Long mainDepartment;
/**
* 删除标识
*/
@TableField(value = "delete_tag")
@ApiModelProperty(value="删除标识")
private Integer deleteTag;
public static final String COL_ID = "id";
public static final String COL_USER_ID = "user_id";
public static final String COL_NAME = "name";
public static final String COL_MOBILE = "mobile";
public static final String COL_DEPARTMENT = "department";
public static final String COL_ORDER = "order";
public static final String COL_POSITION = "position";
public static final String COL_GENDER = "gender";
public static final String COL_EMAIL = "email";
public static final String COL_IS_LEADER_IN_DEPT = "is_leader_in_dept";
public static final String COL_AVATAR = "avatar";
public static final String COL_THUMB_AVATAR = "thumb_avatar";
public static final String COL_STATUS = "status";
public static final String COL_QR_CODE = "qr_code";
public static final String COL_ADDRESS = "address";
public static final String COL_MAIN_DEPARTMENT = "main_department";
public static final String COL_DELETE_TAG = "delete_tag";
}
\ No newline at end of file
package com.tanpu.community.dao.mapper.community;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanpu.community.dao.entity.community.WxCpUser;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface WxCpUserMapper extends BaseMapper<WxCpUser> {
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.tanpu.community.api.beans.qo.feign.fatools.UserInfoCorpReq;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.resp.SysConstantResp;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.fatools.SimpleUserInfo;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoChiefInvAdvResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoCorpResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief;
......@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
......@@ -78,4 +80,9 @@ public interface FeignClientForFatools {
@GetMapping(value = "/h5/sysconstant/queryByconstantGroup", produces = {"application/json"})
CommonResp<List<SysConstantResp>> queryLabels(@ApiParam(value = "分组类型") @RequestParam("constantGroup") String constantGroup);
@ApiIgnore
@ApiOperation(value = "根据Id查询用户基本信息")
@PostMapping(value = "/userInfo/simpleUserList", produces = {"application/json"})
CommonResp<List<SimpleUserInfo>> simpleUserList(@RequestBody List<String> idList);
}
package com.tanpu.community.feign.fatools;
import com.alibaba.fastjson.JSON;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.qo.feign.fatools.UserInfoCorpReq;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.resp.SysConstantResp;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.fatools.SimpleUserInfo;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoChiefInvAdvResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoCorpResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief;
......@@ -99,6 +101,12 @@ public class FeignbackForFatools implements FallbackFactory<FeignClientForFatool
log.error("FeignbackForFatools.queryLabels", throwable);
return CommonResp.error();
}
@Override
public CommonResp<List<SimpleUserInfo>> simpleUserList(List<String> idList) {
log.error("查询参数: {}", JSON.toJSONString(idList));
log.error("查询异常", throwable);
return CommonResp.error();
}
};
}
......
package com.tanpu.community.service.quartz;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.constant.BizStatus;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.util.DateUtils;
import com.tanpu.community.api.beans.vo.feign.user.UserInfoVo;
import com.tanpu.community.api.beans.vo.feign.fatools.SimpleUserInfo;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.entity.community.TopicManagerEntity;
import com.tanpu.community.dao.entity.community.WxCpUser;
import com.tanpu.community.dao.mapper.community.WxCpUserMapper;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.wxcp.FeignClientForWxcp;
import com.tanpu.community.service.CommentService;
......@@ -12,16 +19,19 @@ import com.tanpu.community.service.ThemeService;
import com.tanpu.community.service.TopicService;
import com.tanpu.community.service.VisitLogService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
......@@ -51,6 +61,9 @@ public class TopicReportService {
@Autowired
private FeignClientForFatools feignClientForFatools;
@Resource
private WxCpUserMapper wxCpUserMapper;
public static String content_report_topic_ontime = "话题(%s) 有一个新的讨论/评论";
public void reportTopicOnTime(String topicId) {
......@@ -58,7 +71,7 @@ public class TopicReportService {
if (topic == null || topic.getSyncCorpWechat() == 0) return;
String content = String.format(content_report_topic_ontime, topic.getTopicTitle());
List<String> wxcpIds = getTopicManagerWxcpIds(topic.getTopicId());
List<String> wxcpIds = getTopicManagerWxCpIds(topic.getTopicId());
sendReportMessage(content, wxcpIds);
}
......@@ -100,7 +113,7 @@ public class TopicReportService {
Integer newDiscussNum = newThemeIds.size() + newCommentNum;
String content = String.format(content_report_topic_weekday, topic.getTopicTitle(), totalFollowNum, totalVisitNum, totalDiscussNum, newFollowNum, newDiscussNum);
List<String> wxcpIds = getTopicManagerWxcpIds(topic.getTopicId());
List<String> wxcpIds = getTopicManagerWxCpIds(topic.getTopicId());
sendReportMessage(content, wxcpIds);
}
}
......@@ -146,19 +159,23 @@ public class TopicReportService {
Integer newDiscussNum = newThemeIds.size() + newCommentNum;
String content = String.format(content_report_topic_saturday, topic.getTopicTitle(), totalFollowNum, totalVisitNum, totalDiscussNum, newFollowNum, newDiscussNum);
List<String> wxcpIds = getTopicManagerWxcpIds(topic.getTopicId());
List<String> wxcpIds = getTopicManagerWxCpIds(topic.getTopicId());
sendReportMessage(content, wxcpIds);
}
}
public void sendReportMessage(String content, List<String> wxcpIds) {
log.info("sendTopicReportMessage wxcpIds: {}, content: {}", JSON.toJSONString(wxcpIds), content);
if (CollectionUtils.isEmpty(wxcpIds)) {
return;
}
Map<String, Object> parmMap = new HashMap<>();
parmMap.put("type", "text");
parmMap.put("content", content);
parmMap.put("list", wxcpIds);
log.info("sendTopicReportMessage wxcpIds: {}, content: {}", JSON.toJSONString(wxcpIds), content);
try {
feignClientForWxcp.sendMessage(agentId, corpId, JSON.toJSONString(parmMap));
}catch (Exception e){
......@@ -166,17 +183,26 @@ public class TopicReportService {
}
}
public List<String> getTopicManagerWxcpIds(String topicId) {
List<String> retList = new ArrayList<>();
public List<String> getTopicManagerWxCpIds(String topicId) {
List<TopicManagerEntity> managers = topicService.getManagersByTopic(topicId);
for (TopicManagerEntity mgr : managers) {
UserInfoVo user = feignClientForFatools.getUserInfoById(mgr.getUserId());
if (user != null && user.getUiTelphone() != null) {
// todo 应该用企业微信 这里暂时用手机号代替
retList.add(user.getUiTelphone());
List<String> userIdList = managers.stream().map(TopicManagerEntity::getUserId).collect(Collectors.toList());
CommonResp<List<SimpleUserInfo>> resp = feignClientForFatools.simpleUserList(userIdList);
if (resp.isNotSuccess()) {
throw new BizException(resp.getCode(), resp.getMsg());
}
List<String> mobileList = resp.getData().stream()
.map(SimpleUserInfo::getUiTelphone)
.filter(StringUtils::isNotEmpty).collect(Collectors.toList());
if (CollectionUtils.isEmpty(mobileList)) {
return Lists.newArrayListWithCapacity(0);
}
return retList;
List<WxCpUser> wxCpUsers = wxCpUserMapper.selectList(
Wrappers.<WxCpUser>lambdaQuery()
.in(WxCpUser::getMobile, mobileList)
.eq(WxCpUser::getDeleteTag, BizStatus.DeleteTag.tag_init)
.select(WxCpUser::getUserId)
);
return wxCpUsers.stream().map(WxCpUser::getUserId).collect(Collectors.toList());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tanpu.community.dao.mapper.community.WxCpUserMapper">
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.community.WxCpUser">
<!--@mbg.generated-->
<!--@Table wx_cp_user-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="mobile" jdbcType="VARCHAR" property="mobile" />
<result column="department" jdbcType="VARCHAR" property="department" />
<result column="order" jdbcType="VARCHAR" property="order" />
<result column="position" jdbcType="VARCHAR" property="position" />
<result column="gender" jdbcType="INTEGER" property="gender" />
<result column="email" jdbcType="VARCHAR" property="email" />
<result column="is_leader_in_dept" jdbcType="VARCHAR" property="isLeaderInDept" />
<result column="avatar" jdbcType="VARCHAR" property="avatar" />
<result column="thumb_avatar" jdbcType="VARCHAR" property="thumbAvatar" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="qr_code" jdbcType="VARCHAR" property="qrCode" />
<result column="address" jdbcType="VARCHAR" property="address" />
<result column="main_department" jdbcType="BIGINT" property="mainDepartment" />
<result column="delete_tag" jdbcType="INTEGER" property="deleteTag" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, user_id, `name`, mobile, department, `order`, `position`, gender, email, is_leader_in_dept,
avatar, thumb_avatar, `status`, qr_code, address, main_department, delete_tag
</sql>
</mapper>
\ No newline at end of file
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