Commit 9a8ca572 by 徐高华

群统计

parent 022f553a
package com.gic.haoban.manage.api.service.chat;
import java.util.List;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.chat.GroupChatDataDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.ChatDataSearchQDTO;
public interface GroupChatDataApiService {
/**
*
* @Title: chatDataTimer
* @Description: 统计数据定时从企微拉取
* @author xugh
* @param params
* @throws
*/
public ServiceResponse<Void> chatDataTimer(String params);
/**
*
* @Title: listTotalData
* @Description: 总计
* @author xugh
* @param qdto
* @return
* @throws
*/
public ServiceResponse<GroupChatDataDTO> listTotalData(ChatDataSearchQDTO qdto);
/**
*
* @Title: listForChat
* @Description: 图表数据
* @author xugh
* @param qdto
* @return
* @throws
*/
public ServiceResponse<List<GroupChatDataDTO>> listForChat(ChatDataSearchQDTO qdto);
/**
*
* @Title: listStaffData
* @Description: 群主数据
* @author xugh
* @param qdto
* @param basePageInfo
* @return
* @throws
*/
public ServiceResponse<Page<GroupChatDataDTO>> listStaffData(ChatDataSearchQDTO qdto, BasePageInfo basePageInfo);
}
......@@ -19,7 +19,9 @@ public interface GroupChatDataMapper {
public int insert(TabGroupChatData entity);
public List<GroupChatDataDTO> list(ChatDataSearchQDTO qdto);
public GroupChatDataDTO listTotalData(ChatDataSearchQDTO qdto);
public List<GroupChatDataDTO> listByPage(ChatDataSearchQDTO qdto);
public List<GroupChatDataDTO> listForChat(ChatDataSearchQDTO qdto);
public List<GroupChatDataDTO> listStaffData(ChatDataSearchQDTO qdto);
}
\ No newline at end of file
......@@ -19,8 +19,10 @@ public interface GroupChatDataService {
*/
public void chatDataTimer(String params);
public Page<GroupChatDataDTO> listPage(ChatDataSearchQDTO qdto, BasePageInfo basePageInfo);
public GroupChatDataDTO listTotalData(ChatDataSearchQDTO qdto);
public List<GroupChatDataDTO> list(ChatDataSearchQDTO qdto);
public List<GroupChatDataDTO> listForChat(ChatDataSearchQDTO qdto);
public Page<GroupChatDataDTO> listStaffData(ChatDataSearchQDTO qdto, BasePageInfo basePageInfo);
}
\ No newline at end of file
......@@ -18,6 +18,7 @@ import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatDataDTO;
......@@ -35,8 +36,9 @@ import com.gic.haoban.manage.service.service.chat.GroupChatDataService;
import com.gic.wechat.api.dto.qywx.chat.GroupChatQwDataDTO;
import com.gic.wechat.api.dto.qywx.chat.GroupChatQwDataItemDTO;
import com.gic.wechat.api.service.qywx.QywxChatApiService;
import com.github.pagehelper.PageHelper;
@Service
@Service("groupChatDataService")
public class GroupChatDataServiceImpl implements GroupChatDataService {
private static final Logger logger = LoggerFactory.getLogger(GroupChatDataService.class);
......@@ -55,13 +57,21 @@ public class GroupChatDataServiceImpl implements GroupChatDataService {
private WxEnterpriseMapper wxEnterpriseMapper;
@Override
public List<GroupChatDataDTO> list(ChatDataSearchQDTO qdto) {
return null;
public List<GroupChatDataDTO> listForChat(ChatDataSearchQDTO qdto) {
return this.groupChatDataMapper.listForChat(qdto);
}
@Override
public Page<GroupChatDataDTO> listPage(ChatDataSearchQDTO qdto, BasePageInfo basePageInfo) {
return null;
public Page<GroupChatDataDTO> listStaffData(ChatDataSearchQDTO qdto, BasePageInfo basePageInfo) {
PageHelper.startPage(basePageInfo);
List<GroupChatDataDTO> list = this.groupChatDataMapper.listStaffData(qdto);
Page<GroupChatDataDTO> retPage = PageHelperUtils.changePageHelperToCurrentPage(list, GroupChatDataDTO.class);
return retPage;
}
@Override
public GroupChatDataDTO listTotalData(ChatDataSearchQDTO qdto) {
return this.groupChatDataMapper.listTotalData(qdto);
}
@Override
......@@ -79,7 +89,7 @@ public class GroupChatDataServiceImpl implements GroupChatDataService {
}
private void getDataFormQw(String wxEnterpriseId) {
logger.info("开始处理wxEnterpriseId={}",wxEnterpriseId);
logger.info("开始处理wxEnterpriseId={}", wxEnterpriseId);
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (null == qwDTO) {
logger.info("wxEnterpriseId不存在,id={}", wxEnterpriseId);
......@@ -92,9 +102,9 @@ public class GroupChatDataServiceImpl implements GroupChatDataService {
OwnerSearchQDTO qdto = new OwnerSearchQDTO();
qdto.setWxEnterpriseId(wxEnterpriseId);
List<GroupChatOwnerDTO> list = this.groupChatOwnerMapper.listOwner(qdto);
if(CollectionUtils.isEmpty(list)) {
if (CollectionUtils.isEmpty(list)) {
logger.info("无群主记录,不处理");
return ;
return;
}
List<String> userIdList = null;
Map<String, String> staffIdMap = new HashMap<>();
......@@ -107,7 +117,7 @@ public class GroupChatDataServiceImpl implements GroupChatDataService {
staffIdMap = list.stream().collect(
Collectors.toMap(GroupChatOwnerDTO::getWxUserId, GroupChatOwnerDTO::getStaffId, (k1, k2) -> k1));
}
Date date = DateUtil.addDay(DateUtil.getStartTimeOfDay(), -1);
Long time = date.getTime() / 1000;
ServiceResponse<List<GroupChatQwDataDTO>> resp = this.qywxChatApiService.statistic(qwDTO.getThirdCorpid(),
......
package com.gic.haoban.manage.service.service.out.impl.chat;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.chat.GroupChatDataDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.ChatDataSearchQDTO;
import com.gic.haoban.manage.api.service.chat.GroupChatDataApiService;
import com.gic.haoban.manage.service.service.chat.GroupChatDataService;
@Service("groupChatDataApiService")
public class GroupChatDataApiServiceImpl implements GroupChatDataApiService {
@Autowired
private GroupChatDataService groupChatDataService;
@Override
public ServiceResponse<Void> chatDataTimer(String params) {
this.groupChatDataService.chatDataTimer(params);
return ServiceResponse.success();
}
@Override
public ServiceResponse<GroupChatDataDTO> listTotalData(ChatDataSearchQDTO qdto) {
GroupChatDataDTO dto = this.groupChatDataService.listTotalData(qdto);
return ServiceResponse.success(dto);
}
@Override
public ServiceResponse<List<GroupChatDataDTO>> listForChat(ChatDataSearchQDTO qdto) {
List<GroupChatDataDTO> list = this.groupChatDataService.listForChat(qdto);
return ServiceResponse.success(list);
}
@Override
public ServiceResponse<Page<GroupChatDataDTO>> listStaffData(ChatDataSearchQDTO qdto, BasePageInfo basePageInfo) {
Page<GroupChatDataDTO> page = this.groupChatDataService.listStaffData(qdto, basePageInfo);
return ServiceResponse.success(page);
}
}
......@@ -22,6 +22,7 @@
<constructor-arg index="0" value="haoban-manage-service"/>
</bean>
<dubbo:service interface="com.gic.haoban.manage.api.service.chat.GroupChatDataApiService" ref="groupChatDataApiService" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.chat.GroupChatPlanApiService" ref="groupChatPlanApiService" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.chat.GroupChatHmApiService" ref="groupChatHmApiService" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.chat.GroupChatApiService" ref="groupChatApiService" timeout="10000"/>
......
......@@ -68,23 +68,67 @@
)
]]>
</insert>
<select id="list" parameterType="com.gic.haoban.manage.api.dto.qdto.chat.ChatDataSearchQDTO"
<select id="listTotalData" parameterType="com.gic.haoban.manage.api.dto.qdto.chat.ChatDataSearchQDTO"
resultType="com.gic.haoban.manage.api.dto.chat.GroupChatDataDTO">
SELECT
staffId, `date`, chatTotal, memberTotal,
SUM(newChatCnt), SUM(chatHasMsg), SUM(newMemberCnt),
SUM(memberHasMsg), SUM(msgTotal)
FROM
(SELECT
a.staff_id staffId, a.date `date`,
a.chat_total chatTotal, a.member_total memberTotal,
a.new_chat_cnt newChatCnt, a.chat_has_msg chatHasMsg, a.new_member_cnt newMemberCnt,
a.member_has_msg memberHasMsg, a.msg_total msgTotal
FROM tab_haoban_group_chat_data a
where a.wx_enterprise_id = #{wxEnterpriseId}
and a.date >= #{startDate} and a.date <![CDATA[ <= ]]> #{endDate}
<if test="null != staffIdList and staffIdList.size > 0">
and a.staff_id in
<foreach collection="staffIdList" close=")" open="(" index="index" item="staffId" separator=",">
#{staffId}
</foreach>
</if>
ORDER BY a.date DESC
) tb GROUP BY staffId
</select>
<select id="listForChat" parameterType="com.gic.haoban.manage.api.dto.qdto.chat.ChatDataSearchQDTO"
resultType="com.gic.haoban.manage.api.dto.chat.GroupChatDataDTO">
select staffName , chatTotal from (
select
b.staff_name staffName ,
a.staff_id staffId ,
a.date date ,
a.new_chat_cnt newChatCnt ,
a.chat_total chatTotal,
a.chat_has_msg chatHasMsg ,
a.new_member_cnt newMemberCnt ,
a.member_total memberTotal ,
a.member_has_msg memberHasMsg ,
a.msg_total msgTotal ,
a. migrate_trainee_chat_cnt migrateTraineeChatCnt
from tab_haoban_group_chat_data a left join tab_haoban_staff b on a.staff_id = b.staff_id
sum(a.new_chat_cnt) newChatCnt ,
sum(a.chat_has_msg) chatHasMsg ,
sum(a.new_member_cnt) newMemberCnt ,
sum(a.member_has_msg) memberHasMsg ,
sum(a.msg_total) msgTotal
from tab_haoban_group_chat_data a
where a.wx_enterprise_id = #{wxEnterpriseId}
and a.date >= #{startDate} and a.date <![CDATA[ <= ]]> #{endDate}
<if test="null != staffIdList and staffIdList.size > 0">
and a.staff_id in
<foreach collection="staffIdList" close=")" open="(" index="index" item="staffId" separator=",">
#{staffId}
</foreach>
</if>
group by a.date
</select>
<select id="listStaffData" parameterType="com.gic.haoban.manage.api.dto.qdto.chat.ChatDataSearchQDTO"
resultType="com.gic.haoban.manage.api.dto.chat.GroupChatDataDTO">
SELECT
staffId, staffName, `date`, chatTotal, memberTotal,
SUM(newChatCnt), SUM(chatHasMsg), SUM(newMemberCnt),
SUM(memberHasMsg), SUM(msgTotal)
FROM
(SELECT
b.staff_name staffName, a.staff_id staffId, a.date `date`,
a.chat_total chatTotal, a.member_total memberTotal,
a.new_chat_cnt newChatCnt, a.chat_has_msg chatHasMsg, a.new_member_cnt newMemberCnt,
a.member_has_msg memberHasMsg, a.msg_total msgTotal
FROM tab_haoban_group_chat_data a LEFT JOIN tab_haoban_staff b ON a.staff_id = b.staff_id
where a.wx_enterprise_id = #{wxEnterpriseId}
and a.date >= #{startDate} and a.date <![CDATA[ <= ]]> #{endDate}
<if test="null != staffIdList and staffIdList.size > 0">
......@@ -94,6 +138,6 @@
</foreach>
</if>
ORDER BY a.date DESC
)
) tb GROUP BY staffId
</select>
</mapper>
\ No newline at end of file
......@@ -15,6 +15,7 @@
<dubbo:protocol name="dubbo" port="30009"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.chat.GroupChatDataApiService" id="groupChatDataApiService" timeout="10000"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.chat.GroupChatPlanApiService" id="groupChatPlanApiService" timeout="10000"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.chat.GroupChatApiService" id="groupChatApiService" timeout="10000"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.chat.GroupChatHmApiService" id="groupChatHmApiService" timeout="10000"/>
......
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