Commit 73b1e8e9 by 星梦苍天

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

2 parents d83c7df6 f2a7e829
Showing 25 changed files with 1055 additions and 11 deletions
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.wecom.service.IWeCorpAccountService;
import com.linkwechat.wecom.service.IWeUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author danmo
* @description 首页统计
* @date 2021/2/23 15:30
**/
@Api(description = "首页统计contraller")
@Slf4j
@RestController
@RequestMapping("wecom/page/")
public class WePageDateContraller {
@Autowired
private RedisCache redisCache;
/**
*
*/
@ApiOperation(value = "数据总览controller",httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:page:getCorpBasicData')")
@GetMapping("/getCorpBasicData")
public AjaxResult getCorpBasicData(){
return AjaxResult.success(redisCache.getCacheMap("getCorpBasicData"));
}
@ApiOperation(value = "实时数据controller",httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:page:getCorpRealTimeData')")
@GetMapping("/getCorpRealTimeData")
public AjaxResult getCorpRealTimeData(){
return AjaxResult.success(redisCache.getCacheList("getCorpRealTimeData"));
}
}
...@@ -198,6 +198,8 @@ wecome: ...@@ -198,6 +198,8 @@ wecome:
- /externalcontact/unionid_to_external_userid - /externalcontact/unionid_to_external_userid
- /externalcontact/add_msg_template - /externalcontact/add_msg_template
- /externalcontact/get_group_msg_result - /externalcontact/get_group_msg_result
- /externalcontact/get_user_behavior_data
- /externalcontact/groupchat/statistic
fileUplodUrl: /media/upload,/media/uploadimg fileUplodUrl: /media/upload,/media/uploadimg
needProviderTokenUrl: needProviderTokenUrl:
- /service/get_login_info - /service/get_login_info
......
...@@ -3,16 +3,21 @@ package com.tencent.wework; ...@@ -3,16 +3,21 @@ package com.tencent.wework;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.config.RuoYiConfig; import com.linkwechat.common.config.RuoYiConfig;
import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.redis.RedisCache; import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.common.utils.DateUtils; import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.spring.SpringUtils;
import com.linkwechat.common.utils.uuid.IdUtils; import com.linkwechat.common.utils.uuid.IdUtils;
import com.linkwechat.common.utils.wecom.RSAUtil; import com.linkwechat.common.utils.wecom.RSAUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -244,6 +249,7 @@ public class FinanceUtils { ...@@ -244,6 +249,7 @@ public class FinanceUtils {
getPath(realJsonData, msgType, fileName); getPath(realJsonData, msgType, fileName);
} }
/*//本地存储
private static void getPath(JSONObject realJsonData, String msgType, String fileName) { private static void getPath(JSONObject realJsonData, String msgType, String fileName) {
String filePath = getFilePath(msgType); String filePath = getFilePath(msgType);
JSONObject data = Optional.ofNullable(realJsonData.getJSONObject(msgType)) JSONObject data = Optional.ofNullable(realJsonData.getJSONObject(msgType))
...@@ -254,7 +260,39 @@ public class FinanceUtils { ...@@ -254,7 +260,39 @@ public class FinanceUtils {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
data.put("attachment", filePath + "/" + fileName); String currentDir = StringUtils.substring(filePath,downloadWeWorkPath.length()+1);
String pathFileName;
if(org.apache.commons.lang3.StringUtils.isBlank(currentDir)){
pathFileName = Constants.RESOURCE_PREFIX + "/" +fileName;
}else {
pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
}
data.put("attachment", pathFileName);
if (realJsonData.containsKey("content")) {
realJsonData.put("content", data);
} else {
realJsonData.put(msgType, data);
}
}*/
//云存储
private static void getPath(JSONObject realJsonData, String msgType, String fileName) {
String filePath = getFilePath(msgType);
JSONObject data = Optional.ofNullable(realJsonData.getJSONObject(msgType))
.orElse(realJsonData.getJSONObject("content"));
String sdkfileid = data.getString("sdkfileid");
try {
getMediaData(sdkfileid, "", "", filePath, fileName);
CosConfig cosConfig = SpringUtils.getBean(CosConfig.class);
String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
StringBuilder cosUrl = new StringBuilder(cosConfig.getImgUrlPrefix());
String cosFilePath = FileUploadUtils.upload2Cos(new FileInputStream(filePath + fileName), suffix, cosConfig);
cosUrl.append(cosFilePath);
data.put("attachment", cosUrl.toString());
} catch (Exception e) {
e.printStackTrace();
}
if (realJsonData.containsKey("content")) { if (realJsonData.containsKey("content")) {
realJsonData.put("content", data); realJsonData.put("content", data);
} else { } else {
......
package ${packageName}.domain;
#foreach ($import in $subImportList)
import ${import};
#end
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* ${subTable.functionName}对象 ${subTableName}
*
* @author ${author}
* @date ${datetime}
*/
public class ${subClassName} extends BaseEntity
{
private static final long serialVersionUID = 1L;
#foreach ($column in $subTable.columns)
#if(!$table.isSuperColumn($column.javaField))
/** $column.columnComment */
#if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf("("))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else
@Excel(name = "${comment}")
#end
#end
private $column.javaType $column.javaField;
#end
#end
#foreach ($column in $subTable.columns)
#if(!$table.isSuperColumn($column.javaField))
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
public void set${AttrName}($column.javaType $column.javaField)
{
this.$column.javaField = $column.javaField;
}
public $column.javaType get${AttrName}()
{
return $column.javaField;
}
#end
#end
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
#foreach ($column in $subTable.columns)
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
.append("${column.javaField}", get${AttrName}())
#end
.toString();
}
}
package com.linkwechat.quartz.task;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.client.WeCustomerClient;
import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.WeGroupStatistic;
import com.linkwechat.wecom.domain.dto.GroupChatStatisticDto;
import com.linkwechat.wecom.domain.query.GroupChatStatisticQuery;
import com.linkwechat.wecom.service.IWeGroupService;
import com.linkwechat.wecom.service.IWeGroupStatisticService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* @author sxw
* @description 群聊数据统计
* @date 2021/2/24 0:42
**/
@Slf4j
@Component("GroupChatStatisticTask")
public class GroupChatStatisticTask {
@Autowired
private WeCustomerClient weCustomerClient;
@Autowired
private IWeGroupService weGroupService;
@Autowired
private IWeGroupStatisticService weGroupStatisticService;
public void getGroupChatData() {
log.info("群聊数据统计>>>>>>>>>>>>>>>>>>>启动");
List<WeGroup> weGroupList = weGroupService.list(new LambdaQueryWrapper<WeGroup>().eq(WeGroup::getStatus, 0));
log.info("群聊数据统计>>>>>>>>>>>>>>>>>>>weGroupList:{}",weGroupList.size());
if (CollectionUtil.isNotEmpty(weGroupList)){
List<WeGroupStatistic> weGroupStatisticList = new ArrayList<>();
GroupChatStatisticQuery query = new GroupChatStatisticQuery();
//前一天的数据
Long startTime = strToDate(-1, 0);
Long endTime = strToDate(-1, 1);
query.setDay_begin_time(startTime);
query.setDay_end_time(endTime);
weGroupList.forEach(weGroup -> {
GroupChatStatisticQuery.OwnerFilter ownerFilter = new GroupChatStatisticQuery.OwnerFilter();
List<String> idList = new ArrayList<>();
idList.add(weGroup.getOwner());
ownerFilter.setUserid_list(idList);
query.setOwnerFilter(ownerFilter);
GroupChatStatisticDto groupChatStatistic = weCustomerClient.getGroupChatStatistic(query);
List<GroupChatStatisticDto.GroupchatStatisticData> items = groupChatStatistic.getItems();
if(CollectionUtil.isNotEmpty(items)){
items.forEach(groupchatStatisticData -> {
WeGroupStatistic weGroupStatistic = new WeGroupStatistic();
GroupChatStatisticDto.StatisticData data = groupchatStatisticData.getData();
BeanUtils.copyPropertiesignoreOther(data, weGroupStatistic);
weGroupStatistic.setChatId(weGroup.getChatId());
weGroupStatistic.setStatTime(groupchatStatisticData.getStatTime());
weGroupStatisticList.add(weGroupStatistic);
});
}
});
weGroupStatisticService.saveBatch(weGroupStatisticList);
}
}
private Long strToDate(int days, Integer type) {
Long time = null;
DateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
Calendar cale = Calendar.getInstance();
cale.add(Calendar.DATE, days);
String tarday = new SimpleDateFormat("yyyy-MM-dd").format(cale.getTime());
if (type.equals(0)) {
tarday += " 00:00:00";
} else {
tarday += " 23:59:59";
}
// String转Date
try {
date = format2.parse(tarday);
System.out.println(date.getTime());
time = date.getTime() / 1000;
System.out.println(time.toString());
} catch (ParseException e) {
e.printStackTrace();
}
return time;
}
}
package com.linkwechat.quartz.task;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.wecom.domain.WeCorpAccount;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @author danmo
* @description 首页数据统计
* @date 2021/2/23 23:51
**/
@Slf4j
@Component("PageHomeDataTask")
public class PageHomeDataTask {
@Autowired
private IWeCorpAccountService weCorpAccountService;
@Autowired
private IWeUserService weUserService;
@Autowired
private IWeCustomerService weCustomerService;
@Autowired
private IWeGroupService weGroupService;
@Autowired
private IWeGroupMemberService weGroupMemberService;
@Autowired
private RedisCache redisCache;
public void getCorpBasicData(){
//查询当前使用企业
//WeCorpAccount weCorpAccount = weCorpAccountService.findValidWeCorpAccount();
//String corpId = weCorpAccount.getCorpId();
Map<String,Object> totalMap = new HashMap<>(16);
//企业成员总数
int userCount = weUserService.count(new LambdaQueryWrapper<WeUser>().eq(WeUser::getIsActivate, WeConstans.WE_USER_IS_ACTIVATE));
//客户总人数
int customerCount = weCustomerService.count();
//客户群总数
int groupCount = weGroupService.count();
//群成员总数
int groupMemberCount = weGroupMemberService.count();
totalMap.put("userCount",userCount);
totalMap.put("customerCount",customerCount);
totalMap.put("groupCount",groupCount);
totalMap.put("groupMemberCount",groupMemberCount);
redisCache.setCacheMap("getCorpBasicData",totalMap);
}
public void getCorpRealTimeData(){
//今日
//发起申请数
}
}
package com.linkwechat.quartz.task;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.client.WeCustomerClient;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.WeUserBehaviorData;
import com.linkwechat.wecom.domain.dto.UserBehaviorDataDto;
import com.linkwechat.wecom.domain.query.UserBehaviorDataQuery;
import com.linkwechat.wecom.service.IWeUserBehaviorDataService;
import com.linkwechat.wecom.service.IWeUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* @author sxw
* @description 联系客户统计
* @date 2021/2/24 0:41
**/
@Slf4j
@Component("UserBehaviorDataTak")
public class UserBehaviorDataTak {
@Autowired
private WeCustomerClient weCustomerClient;
@Autowired
private IWeUserService weUserService;
@Autowired
private IWeUserBehaviorDataService weUserBehaviorDataService;
private final int offset = 500;
public void getUserBehaviorData() {
log.info("联系客户统计>>>>>>>>>>>>>>>>>>>启动");
LambdaQueryWrapper<WeUser> wrapper = new LambdaQueryWrapper<WeUser>().eq(WeUser::getIsActivate, WeConstans.WE_USER_IS_ACTIVATE);
int userCount = weUserService.count(wrapper);
log.info("联系客户统计>>>>>>>>>>>>>>>>>>>userCount:{}",userCount);
double num = 1;
if (userCount > offset) {
num = Math.ceil((double) userCount / offset);
}
int temp = 0;
for (int i = 0; i < num; i++) {
wrapper.last("limit " + temp + "," + offset);
List<WeUser> list = weUserService.list(wrapper);
if (CollectionUtil.isNotEmpty(list)) {
List<WeUserBehaviorData> dataList = new ArrayList<>();
UserBehaviorDataQuery query = new UserBehaviorDataQuery();
//前一天的数据
Long startTime = strToDate(-1, 0);
Long endTime = strToDate(-1, 1);
query.setStart_time(startTime);
query.setEnd_time(endTime);
list.forEach(weUser -> {
List<String> idList = new ArrayList<>();
idList.add(weUser.getUserId());
query.setUserid(idList);
UserBehaviorDataDto userBehaviorData = weCustomerClient.getUserBehaviorData(query);
List<UserBehaviorDataDto.BehaviorData> behaviorDataList = userBehaviorData.getBehaviorData();
for (UserBehaviorDataDto.BehaviorData data : behaviorDataList) {
WeUserBehaviorData weUserBehaviorData = new WeUserBehaviorData();
BeanUtils.copyPropertiesignoreOther(data, weUserBehaviorData);
weUserBehaviorData.setUserId(weUser.getUserId());
dataList.add(weUserBehaviorData);
}
});
weUserBehaviorDataService.saveBatch(dataList);
}
temp += offset;
}
}
private Long strToDate(int days, Integer type) {
Long time = null;
DateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
Calendar cale = Calendar.getInstance();
cale.add(Calendar.DATE, days);
String tarday = new SimpleDateFormat("yyyy-MM-dd").format(cale.getTime());
if (type.equals(0)) {
tarday += " 00:00:00";
} else {
tarday += " 23:59:59";
}
// String转Date
try {
date = format2.parse(tarday);
System.out.println(date.getTime());
time = date.getTime() / 1000;
System.out.println(time.toString());
} catch (ParseException e) {
e.printStackTrace();
}
return time;
}
}
package com.linkwechat.wecom.client; package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.DataObject; import com.dtflys.forest.annotation.DataObject;
import com.dtflys.forest.annotation.JSONBody;
import com.dtflys.forest.annotation.Query; import com.dtflys.forest.annotation.Query;
import com.dtflys.forest.annotation.Request; import com.dtflys.forest.annotation.Request;
import com.linkwechat.wecom.domain.dto.WeCustomerDto; import com.linkwechat.wecom.domain.dto.*;
import com.linkwechat.wecom.domain.dto.WeResultDto; import com.linkwechat.wecom.domain.dto.customer.*;
import com.linkwechat.wecom.domain.dto.WeWelcomeMsg; import com.linkwechat.wecom.domain.query.GroupChatStatisticQuery;
import com.linkwechat.wecom.domain.dto.customer.CutomerTagEdit; import com.linkwechat.wecom.domain.query.UserBehaviorDataQuery;
import com.linkwechat.wecom.domain.dto.customer.ExternalUserDetail;
import com.linkwechat.wecom.domain.dto.customer.ExternalUserList;
import com.linkwechat.wecom.domain.dto.customer.FollowUserList;
import java.util.Map; import java.util.Map;
...@@ -93,5 +91,19 @@ public interface WeCustomerClient { ...@@ -93,5 +91,19 @@ public interface WeCustomerClient {
ExternalUserDetail unionidToExternalUserid(@DataObject ExternalUserDetail.ExternalContact unionid); ExternalUserDetail unionidToExternalUserid(@DataObject ExternalUserDetail.ExternalContact unionid);
/**
* 联系客户统计
* @return
*/
@Request(url = "/externalcontact/get_user_behavior_data",
type = "POST")
UserBehaviorDataDto getUserBehaviorData(@JSONBody UserBehaviorDataQuery query);
/**
* 联系客户统计
* @return
*/
@Request(url = "/externalcontact/groupchat/statistic",
type = "POST")
GroupChatStatisticDto getGroupChatStatistic(@JSONBody GroupChatStatisticQuery query);
} }
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.annotation.Excel;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 群聊数据统计数据
* 对象 we_group_statistic
*
* @author ruoyi
* @date 2021-02-24
*/
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("we_group_statistic")
public class WeGroupStatistic implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@TableId(value = "id")
private Long id;
/**
* 群主ID
*/
@Excel(name = "群ID")
private String chatId;
/**
* 数据日期
*/
@Excel(name = "数据日期", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date statTime;
/**
* 新增客户群数量
*/
@Excel(name = "新增客户群数量")
private Integer newChatCnt;
/**
* 截至当天客户群总数量
*/
@Excel(name = "截至当天客户群总数量")
private Integer chatTotal;
/**
* 截至当天有发过消息的客户群数量
*/
@Excel(name = "截至当天有发过消息的客户群数量")
private Integer chatHasMsg;
/**
* 客户群新增群人数
*/
@Excel(name = "客户群新增群人数")
private Integer newMemberCnt;
/**
* 截至当天客户群总人数
*/
@Excel(name = "截至当天客户群总人数")
private Integer memberTotal;
/**
* 截至当天有发过消息的群成员数
*/
@Excel(name = "截至当天有发过消息的群成员数")
private Integer memberHasMsg;
/**
* 截至当天客户群消息总数
*/
@Excel(name = "截至当天客户群消息总数")
private Integer msgTotal;
@TableField(exist = false)
private Map<String, Object> params = new HashMap<>();
}
...@@ -114,7 +114,7 @@ public class WeUser ...@@ -114,7 +114,7 @@ public class WeUser
private String remark; private String remark;
@TableField(exist = false)
private String departmentStr; private String departmentStr;
......
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.annotation.Excel;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 联系客户统计数据 对象 we_user_behavior_data
*
* @author ruoyi
* @date 2021-02-24
*/
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("we_user_behavior_data")
public class WeUserBehaviorData implements Serializable {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
@TableId(value = "id")
private Long id;
/**
* 客户id
*/
@Excel(name = "客户id")
private String userId;
/**
* 数据日期,为当日0点的时间戳
*/
@Excel(name = "数据日期,为当日0点的时间戳", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date statTime;
/**
* 发起申请数
*/
@Excel(name = "发起申请数")
private Integer newApplyCnt;
/**
* 新增客户数,成员新添加的客户数量
*/
@Excel(name = "新增客户数,成员新添加的客户数量")
private Integer newContactCnt;
/**
* 聊天总数, 成员有主动发送过消息的单聊总数
*/
@Excel(name = "聊天总数, 成员有主动发送过消息的单聊总数")
private Integer chatCnt;
/**
* 发送消息数,成员在单聊中发送的消息总数
*/
@Excel(name = "发送消息数,成员在单聊中发送的消息总数")
private Integer messageCnt;
/**
* 已回复聊天占比,浮点型,客户主动发起聊天后,成员在一个自然日内有回复过消息的聊天数/客户主动发起的聊天数比例,不包括群聊,仅在确有聊天时返回
*/
@Excel(name = "已回复聊天占比,浮点型,客户主动发起聊天后,成员在一个自然日内有回复过消息的聊天数/客户主动发起的聊天数比例,不包括群聊,仅在确有聊天时返回")
private Long replyPercentage;
/**
* 平均首次回复时长
*/
@Excel(name = "平均首次回复时长")
private Integer avgReplyTime;
/**
* 删除/拉黑成员的客户数,即将成员删除或加入黑名单的客户数
*/
@Excel(name = "删除/拉黑成员的客户数,即将成员删除或加入黑名单的客户数")
private Long negativeFeedbackCnt;
@TableField(exist = false)
private Map<String, Object> params = new HashMap<>();
}
package com.linkwechat.wecom.domain.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author danmo
*/
@Data
public class GroupChatStatisticDto {
private List<GroupchatStatisticData> items;
@Data
public static class GroupchatStatisticData {
/**
* 数据日期,为当日0点的时间戳
*/
@JSONField(format="unixtime")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date statTime;
private StatisticData data;
}
@Data
public static class StatisticData {
/**
* 新增客户群数量
*/
private Integer newChatCnt;
/**
* 截至当天客户群总数量
*/
private Integer chatTotal;
/**
* 截至当天有发过消息的客户群数量
*/
private Integer chatHasMsg;
/**
* 客户群新增群人数
*/
private Integer newMemberCnt;
/**
* 截至当天客户群总人数
*/
private Integer memberTotal;
/**
* 截至当天有发过消息的群成员数
*/
private Integer memberHasMsg;
/**
* 截至当天客户群消息总数
*/
private Integer msgTotal;
}
}
package com.linkwechat.wecom.domain.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author danmo
*/
@Data
public class UserBehaviorDataDto {
private List<BehaviorData> behaviorData;
@Data
public static class BehaviorData{
/**
* 数据日期,为当日0点的时间戳
*/
@JSONField(format="unixtime")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date statTime;
/**
* 聊天总数, 成员有主动发送过消息的单聊总数。
*/
private Integer chatCnt;
/**
* 发送消息数,成员在单聊中发送的消息总数。
*/
private Integer messageCnt;
/**
* 已回复聊天占比,浮点型,客户主动发起聊天后,成员在一个自然日内有回复过消息的聊天数/客户主动发起的聊天数比例,不包括群聊,仅在确有聊天时返回。
*/
private Float replyPercentage;
/**
* 平均首次回复时长,单位为分钟,即客户主动发起聊天后,成员在一个自然日内首次回复的时长间隔为首次回复时长,所有聊天的首次回复总时长/已回复的聊天总数即为平均首次回复时长,不包括群聊,仅在确有聊天时返回。
*/
private Integer avgReplyTime;
/**
* 删除/拉黑成员的客户数,即将成员删除或加入黑名单的客户数。
*/
private Integer negativeFeedbackCnt;
/**
* 主动向客户发起的好友申请数量
*/
private Integer newApplyCnt;
/**
* 新增客户数,成员新添加的客户数量。
*/
private Integer newContactCnt;
}
}
package com.linkwechat.wecom.domain.query;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @author danmo
*/
@Data
public class GroupChatStatisticQuery {
@ApiModelProperty(value = "起始日期的时间戳")
private Long day_begin_time;
@ApiModelProperty(value = "结束日期的时间戳")
private Long day_end_time;
@ApiModelProperty(value = "群主过滤")
private OwnerFilter ownerFilter;
@Data
public static class OwnerFilter{
@ApiModelProperty(value = "群主ID列表")
private List<String> userid_list;
}
}
package com.linkwechat.wecom.domain.query;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author danmo
*/
@Data
public class UserBehaviorDataQuery {
@ApiModelProperty(value = "成员ID列表,最多100个")
private List<String> userid;
@ApiModelProperty(value = "部门ID列表,最多100个")
private List<String> partyid;
@ApiModelProperty(value = "数据起始时间")
private Long start_time;
@ApiModelProperty(value = "数据结束时间")
private Long end_time;
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeGroupStatistic;
/**
* 群聊数据统计数据
Mapper接口
*
* @author ruoyi
* @date 2021-02-24
*/
public interface WeGroupStatisticMapper extends BaseMapper<WeGroupStatistic> {
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeUserBehaviorData;
/**
* 联系客户统计数据 Mapper接口
*
* @author ruoyi
* @date 2021-02-24
*/
public interface WeUserBehaviorDataMapper extends BaseMapper<WeUserBehaviorData> {
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroupStatistic;
import java.util.List;
/**
* 群聊数据统计数据
Service接口
*
* @author ruoyi
* @date 2021-02-24
*/
public interface IWeGroupStatisticService extends IService<WeGroupStatistic> {
/**
* 查询列表
*/
List<WeGroupStatistic> queryList(WeGroupStatistic weGroupStatistic);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeUserBehaviorData;
import java.util.List;
/**
* 联系客户统计数据 Service接口
*
* @author ruoyi
* @date 2021-02-24
*/
public interface IWeUserBehaviorDataService extends IService<WeUserBehaviorData> {
/**
* 查询列表
*/
List<WeUserBehaviorData> queryList(WeUserBehaviorData weUserBehaviorData);
}
package com.linkwechat.wecom.service.impl;
import com.linkwechat.wecom.domain.WeGroupStatistic;
import com.linkwechat.wecom.mapper.WeGroupStatisticMapper;
import com.linkwechat.wecom.service.IWeGroupStatisticService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.Map;
/**
* 群聊数据统计数据
Service业务层处理
*
* @author ruoyi
* @date 2021-02-24
*/
@Service
public class WeGroupStatisticServiceImpl extends ServiceImpl<WeGroupStatisticMapper, WeGroupStatistic> implements IWeGroupStatisticService {
@Override
public List<WeGroupStatistic> queryList(WeGroupStatistic weGroupStatistic) {
LambdaQueryWrapper<WeGroupStatistic> lqw = Wrappers.lambdaQuery();
if (StringUtils.isNotBlank(weGroupStatistic.getChatId())){
lqw.eq(WeGroupStatistic::getChatId ,weGroupStatistic.getChatId());
}
if (weGroupStatistic.getStatTime() != null){
lqw.eq(WeGroupStatistic::getStatTime ,weGroupStatistic.getStatTime());
}
if (weGroupStatistic.getNewChatCnt() != null){
lqw.eq(WeGroupStatistic::getNewChatCnt ,weGroupStatistic.getNewChatCnt());
}
if (weGroupStatistic.getChatTotal() != null){
lqw.eq(WeGroupStatistic::getChatTotal ,weGroupStatistic.getChatTotal());
}
if (weGroupStatistic.getChatHasMsg() != null){
lqw.eq(WeGroupStatistic::getChatHasMsg ,weGroupStatistic.getChatHasMsg());
}
if (weGroupStatistic.getNewMemberCnt() != null){
lqw.eq(WeGroupStatistic::getNewMemberCnt ,weGroupStatistic.getNewMemberCnt());
}
if (weGroupStatistic.getMemberTotal() != null){
lqw.eq(WeGroupStatistic::getMemberTotal ,weGroupStatistic.getMemberTotal());
}
if (weGroupStatistic.getMemberHasMsg() != null){
lqw.eq(WeGroupStatistic::getMemberHasMsg ,weGroupStatistic.getMemberHasMsg());
}
if (weGroupStatistic.getMsgTotal() != null){
lqw.eq(WeGroupStatistic::getMsgTotal ,weGroupStatistic.getMsgTotal());
}
return this.list(lqw);
}
}
package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.domain.WeUserBehaviorData;
import com.linkwechat.wecom.mapper.WeUserBehaviorDataMapper;
import com.linkwechat.wecom.service.IWeUserBehaviorDataService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 联系客户统计数据 Service业务层处理
*
* @author ruoyi
* @date 2021-02-24
*/
@Service
public class WeUserBehaviorDataServiceImpl extends ServiceImpl<WeUserBehaviorDataMapper, WeUserBehaviorData> implements IWeUserBehaviorDataService {
@Override
public List<WeUserBehaviorData> queryList(WeUserBehaviorData weUserBehaviorData) {
LambdaQueryWrapper<WeUserBehaviorData> lqw = Wrappers.lambdaQuery();
if (StringUtils.isNotBlank(weUserBehaviorData.getUserId())){
lqw.eq(WeUserBehaviorData::getUserId ,weUserBehaviorData.getUserId());
}
if (weUserBehaviorData.getStatTime() != null){
lqw.eq(WeUserBehaviorData::getStatTime ,weUserBehaviorData.getStatTime());
}
if (weUserBehaviorData.getNewApplyCnt() != null){
lqw.eq(WeUserBehaviorData::getNewApplyCnt ,weUserBehaviorData.getNewApplyCnt());
}
if (weUserBehaviorData.getNewContactCnt() != null){
lqw.eq(WeUserBehaviorData::getNewContactCnt ,weUserBehaviorData.getNewContactCnt());
}
if (weUserBehaviorData.getChatCnt() != null){
lqw.eq(WeUserBehaviorData::getChatCnt ,weUserBehaviorData.getChatCnt());
}
if (weUserBehaviorData.getMessageCnt() != null){
lqw.eq(WeUserBehaviorData::getMessageCnt ,weUserBehaviorData.getMessageCnt());
}
if (weUserBehaviorData.getReplyPercentage() != null){
lqw.eq(WeUserBehaviorData::getReplyPercentage ,weUserBehaviorData.getReplyPercentage());
}
if (weUserBehaviorData.getAvgReplyTime() != null){
lqw.eq(WeUserBehaviorData::getAvgReplyTime ,weUserBehaviorData.getAvgReplyTime());
}
if (weUserBehaviorData.getNegativeFeedbackCnt() != null){
lqw.eq(WeUserBehaviorData::getNegativeFeedbackCnt ,weUserBehaviorData.getNegativeFeedbackCnt());
}
return this.list(lqw);
}
}
...@@ -222,8 +222,9 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen ...@@ -222,8 +222,9 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
List<WeUser> weUsers List<WeUser> weUsers
= weUserClient.list(WeConstans.WE_ROOT_DEPARMENT_ID, WeConstans.DEPARTMENT_SUB_WEUSER).getWeUsers(); = weUserClient.list(WeConstans.WE_ROOT_DEPARMENT_ID, WeConstans.DEPARTMENT_SUB_WEUSER).getWeUsers();
if(CollectionUtil.isNotEmpty(weUsers)){ if(CollectionUtil.isNotEmpty(weUsers)){
weUsers.forEach(userInfo ->{
this.saveOrUpdateBatch(weUsers); insertWeUserNoToWeCom(userInfo);
});
} }
} }
......
<?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.linkwechat.wecom.mapper.WeGroupStatisticMapper">
<resultMap type="WeGroupStatistic" id="WeGroupStatisticResult">
<result property="id" column="id" />
<result property="chatId" column="chat_id" />
<result property="statTime" column="stat_time" />
<result property="newChatCnt" column="new_chat_cnt" />
<result property="chatTotal" column="chat_total" />
<result property="chatHasMsg" column="chat_has_msg" />
<result property="newMemberCnt" column="new_member_cnt" />
<result property="memberTotal" column="member_total" />
<result property="memberHasMsg" column="member_has_msg" />
<result property="msgTotal" column="msg_total" />
</resultMap>
</mapper>
\ No newline at end of file \ No newline at end of file
<?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.linkwechat.wecom.mapper.WeUserBehaviorDataMapper">
<resultMap type="WeUserBehaviorData" id="WeUserBehaviorDataResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="statTime" column="stat_time" />
<result property="newApplyCnt" column="new_apply_cnt" />
<result property="newContactCnt" column="new_contact_cnt" />
<result property="chatCnt" column="chat_cnt" />
<result property="messageCnt" column="message_cnt" />
<result property="replyPercentage" column="reply_percentage" />
<result property="avgReplyTime" column="avg_reply_time" />
<result property="negativeFeedbackCnt" column="negative_feedback_cnt" />
</resultMap>
</mapper>
\ No newline at end of file \ No newline at end of file
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!