Commit 25d7bfad by danmo

群发同步接口优化

1 parent 3092d0aa
...@@ -77,4 +77,14 @@ public class WeGroupMessageTask extends BaseEntity{ ...@@ -77,4 +77,14 @@ public class WeGroupMessageTask extends BaseEntity{
@ApiModelProperty("企业服务人员名称") @ApiModelProperty("企业服务人员名称")
@TableField(exist = false) @TableField(exist = false)
private String userName; private String userName;
@ApiModelProperty(value = "待发送客户",hidden = true)
@TableField(exist = false)
private String toBeCustomerName;
@ApiModelProperty(value = "已发送客户",hidden = true)
@TableField(exist = false)
private String alreadyCustomerName;
} }
...@@ -77,4 +77,11 @@ public class WeGroupMessageTemplate extends BaseEntity { ...@@ -77,4 +77,11 @@ public class WeGroupMessageTemplate extends BaseEntity {
*/ */
@ApiModelProperty("来源 0 群发 1 其他") @ApiModelProperty("来源 0 群发 1 其他")
private Integer source; private Integer source;
/**
* 刷新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("刷新时间")
private Date refreshTime;
} }
...@@ -28,6 +28,10 @@ public class WeGroupMessageDetailVo { ...@@ -28,6 +28,10 @@ public class WeGroupMessageDetailVo {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date sendTime; private Date sendTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("刷新时间")
private Date refreshTime;
@ApiModelProperty("附件") @ApiModelProperty("附件")
private List<WeGroupMessageAttachments> attachments; private List<WeGroupMessageAttachments> attachments;
......
...@@ -81,12 +81,16 @@ public class WeGroupMessageSendResultServiceImpl extends ServiceImpl<WeGroupMess ...@@ -81,12 +81,16 @@ public class WeGroupMessageSendResultServiceImpl extends ServiceImpl<WeGroupMess
sendResultList.forEach(item -> { sendResultList.forEach(item -> {
LambdaQueryWrapper<WeGroupMessageSendResult> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WeGroupMessageSendResult> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(WeGroupMessageSendResult::getMsgId, item.getMsgId()) wrapper.eq(WeGroupMessageSendResult::getMsgId, item.getMsgId())
.eq(WeGroupMessageSendResult::getExternalUserid, item.getExternalUserid()) .eq(WeGroupMessageSendResult::getUserId, item.getUserId());
.eq(WeGroupMessageSendResult::getUserId, item.getUserId())
.eq(WeGroupMessageSendResult::getChatId, item.getChatId());
if(item.getMsgTemplateId() != null){ if(item.getMsgTemplateId() != null){
wrapper.eq(WeGroupMessageSendResult::getMsgTemplateId,item.getMsgTemplateId()); wrapper.eq(WeGroupMessageSendResult::getMsgTemplateId,item.getMsgTemplateId());
} }
if(item.getExternalUserid() != null){
wrapper.eq(WeGroupMessageSendResult::getExternalUserid,item.getExternalUserid());
}
if(item.getChatId() != null){
wrapper.eq(WeGroupMessageSendResult::getChatId,item.getChatId());
}
if (!this.update(item, wrapper)) { if (!this.update(item, wrapper)) {
this.save(item); this.save(item);
} }
......
...@@ -93,30 +93,30 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag ...@@ -93,30 +93,30 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
WeGroupMessageDetailVo detailVo = new WeGroupMessageDetailVo(); WeGroupMessageDetailVo detailVo = new WeGroupMessageDetailVo();
detailVo.setChatType(msgTemplate); detailVo.setChatType(msgTemplate);
detailVo.setRefreshTime(weGroupMessageTemplate.getRefreshTime());
detailVo.setSendTime(weGroupMessageTemplate.getSendTime()); detailVo.setSendTime(weGroupMessageTemplate.getSendTime());
detailVo.setContent(weGroupMessageTemplate.getContent()); detailVo.setContent(weGroupMessageTemplate.getContent());
List<WeGroupMessageListVo> groupMsgDetail = weGroupMessageListService.getGroupMsgDetail(id); List<WeGroupMessageListVo> groupMsgDetail = weGroupMessageListService.getGroupMsgDetail(id);
if (CollectionUtil.isNotEmpty(groupMsgDetail)) { if (CollectionUtil.isNotEmpty(groupMsgDetail)) {
detailVo.setAttachments(groupMsgDetail.get(0).getAttachments()); detailVo.setAttachments(groupMsgDetail.get(0).getAttachments());
//待发送人员列表 //待发送人员列表
List<WeGroupMessageTask> toBeSent = groupMsgDetail.stream().map(WeGroupMessageListVo::getSenders) Long toBeSent = groupMsgDetail.stream().map(WeGroupMessageListVo::getSenders)
.flatMap(Collection::stream).filter(item -> ObjectUtil.equal(0, item.getStatus())).collect(Collectors.toList()); .flatMap(Collection::stream).filter(item -> ObjectUtil.equal(0, item.getStatus())).count();
detailVo.setToBeSendNum(toBeSent.intValue());
//已发送人员列表 //已发送人员列表
List<WeGroupMessageTask> alreadySent = groupMsgDetail.stream().map(WeGroupMessageListVo::getSenders) Long alreadySent = groupMsgDetail.stream().map(WeGroupMessageListVo::getSenders)
.flatMap(Collection::stream).filter(item -> ObjectUtil.equal(2, item.getStatus())).collect(Collectors.toList()); .flatMap(Collection::stream).filter(item -> ObjectUtil.equal(2, item.getStatus())).count();
detailVo.setAlreadySendNum(alreadySent.intValue());
//未发送客户数 //未发送客户数
Long toBeCustomerNum = groupMsgDetail.stream().map(WeGroupMessageListVo::getExtralInfos).flatMap(Collection::stream) Long toBeCustomerNum = groupMsgDetail.stream().map(WeGroupMessageListVo::getExtralInfos).flatMap(Collection::stream)
.filter(item -> ObjectUtil.equal(0, item.getStatus())).count(); .filter(item -> ObjectUtil.equal(0, item.getStatus())).count();
detailVo.setToBeSendCustomerNum(toBeCustomerNum.intValue()); detailVo.setToBeSendCustomerNum(toBeCustomerNum.intValue());
//已发送客户数 //已发送客户数
Long alreadyCustomerNum = groupMsgDetail.stream().map(WeGroupMessageListVo::getExtralInfos).flatMap(Collection::stream) Long alreadyCustomerNum = groupMsgDetail.stream().map(WeGroupMessageListVo::getExtralInfos).flatMap(Collection::stream)
.filter(item -> !ObjectUtil.equal(1, item.getStatus())).count(); .filter(item -> ObjectUtil.equal(1, item.getStatus())).count();
detailVo.setAlreadySendCustomerNum(alreadyCustomerNum.intValue()); detailVo.setAlreadySendCustomerNum(alreadyCustomerNum.intValue());
//未发送查询每个人员对应客户信息 //未发送查询每个人员对应客户信息
if (CollectionUtil.isNotEmpty(toBeSent)) { /*if (CollectionUtil.isNotEmpty(toBeSent)) {
List<WeGroupMessageTaskVo> toBeSentList = toBeSent.stream().map(userInfo -> { List<WeGroupMessageTaskVo> toBeSentList = toBeSent.stream().map(userInfo -> {
WeGroupMessageTaskVo weGroupMessageTaskVo = new WeGroupMessageTaskVo(); WeGroupMessageTaskVo weGroupMessageTaskVo = new WeGroupMessageTaskVo();
weGroupMessageTaskVo.setUserId(userInfo.getUserId()); weGroupMessageTaskVo.setUserId(userInfo.getUserId());
...@@ -138,9 +138,9 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag ...@@ -138,9 +138,9 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
}).collect(Collectors.toList()); }).collect(Collectors.toList());
detailVo.setToBeSendList(toBeSentList); detailVo.setToBeSendList(toBeSentList);
detailVo.setToBeSendNum(toBeSentList.size()); detailVo.setToBeSendNum(toBeSentList.size());
} }*/
//已发送查询每个人员对应客户信息 //已发送查询每个人员对应客户信息
if (CollectionUtil.isNotEmpty(alreadySent)) { /*if (CollectionUtil.isNotEmpty(alreadySent)) {
List<WeGroupMessageTaskVo> alreadySentList = alreadySent.stream().map(userInfo -> { List<WeGroupMessageTaskVo> alreadySentList = alreadySent.stream().map(userInfo -> {
WeGroupMessageTaskVo weGroupMessageTaskVo = new WeGroupMessageTaskVo(); WeGroupMessageTaskVo weGroupMessageTaskVo = new WeGroupMessageTaskVo();
weGroupMessageTaskVo.setUserId(userInfo.getUserId()); weGroupMessageTaskVo.setUserId(userInfo.getUserId());
...@@ -163,7 +163,7 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag ...@@ -163,7 +163,7 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
}).collect(Collectors.toList()); }).collect(Collectors.toList());
detailVo.setAlreadySendList(alreadySentList); detailVo.setAlreadySendList(alreadySentList);
detailVo.setAlreadySendNum(alreadySentList.size()); detailVo.setAlreadySendNum(alreadySentList.size());
} }*/
} }
return detailVo; return detailVo;
} }
...@@ -309,6 +309,9 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag ...@@ -309,6 +309,9 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
@Async @Async
@Override @Override
public void syncGroupMsgSendResultByIds(List<Long> asList) { public void syncGroupMsgSendResultByIds(List<Long> asList) {
WeGroupMessageTemplate template = new WeGroupMessageTemplate();
template.setRefreshTime(new Date());
this.update(template,new LambdaQueryWrapper<WeGroupMessageTemplate>().in(WeGroupMessageTemplate::getId,asList));
List<WeGroupMessageList> weGroupMessageLists = weGroupMessageListService.list(new LambdaQueryWrapper<WeGroupMessageList>() List<WeGroupMessageList> weGroupMessageLists = weGroupMessageListService.list(new LambdaQueryWrapper<WeGroupMessageList>()
.in(WeGroupMessageList::getMsgTemplateId, asList)); .in(WeGroupMessageList::getMsgTemplateId, asList));
List<WeGroupMessageTask> taskList = new ArrayList<>(); List<WeGroupMessageTask> taskList = new ArrayList<>();
......
...@@ -47,13 +47,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -47,13 +47,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and wgmsr.status = #{status} and wgmsr.status = #{status}
</if> </if>
<if test="customerName != null and customerName != ''"> <if test="customerName != null and customerName != ''">
and wc.name like concat('%', #{customerName}, '%') and exists
(select 1 from we_customer wc where
wc.external_userid = wgmsr.external_userid
and wc.name like concat('%', #{customerName}, '%'))
</if> </if>
<if test="userName != null and userName != ''"> <if test="userName != null and userName != ''">
and wu.user_name like concat('%', #{userName}, '%') and exists
(select 1 from we_user wu where
wu.user_id = wgmsr.user_id
and wu.user_name like concat('%', #{userName}, '%'))
</if> </if>
<if test="chatName != null and chatName != ''"> <if test="chatName != null and chatName != ''">
and wg.group_name like concat('%', #{chatName}, '%') and exists
(select 1 from we_group wg where wg.chat_id = wgmsr.chat_id
and wg.group_name like concat('%', #{chatName}, '%'))
</if> </if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 --> <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(wgmsr.send_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d') AND date_format(wgmsr.send_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
......
...@@ -10,6 +10,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -10,6 +10,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="msgId" column="msg_id" /> <result property="msgId" column="msg_id" />
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="userName" column="user_name" /> <result property="userName" column="user_name" />
<result property="toBeCustomerName" column="to_be_customer_name" />
<result property="alreadyCustomerName" column="already_customer_name" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="sendTime" column="send_time" /> <result property="sendTime" column="send_time" />
</resultMap> </resultMap>
...@@ -19,11 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -19,11 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wgmt.msg_template_id, wgmt.msg_template_id,
wgmt.msg_id, wgmt.msg_id,
wgmt.user_id, wgmt.user_id,
wu.user_name, (select wu.user_name from we_user wu where wu.user_id = wgmt.user_id limit 1) as user_name,
wgmt.status, wgmt.status,
wgmt.send_time wgmt.send_time,
(select group_concat((select wc.name from we_customer wc where wc.external_userid = wgmsr.external_userid limit 1)) as customer_name
from we_group_message_send_result wgmsr where wgmsr.user_id = wgmt.user_id and wgmsr.status = 0) as to_be_customer_name ,
(select group_concat((select wc.name from we_customer wc where wc.external_userid = wgmsr.external_userid limit 1)) as customer_name
from we_group_message_send_result wgmsr where wgmsr.user_id = wgmt.user_id and wgmsr.status = 1) as already_customer_name,
from we_group_message_task wgmt from we_group_message_task wgmt
left join we_user wu on wu.user_id = wgmt.user_id
<where> <where>
<if test="id != null"> <if test="id != null">
and wgmt.id = #{id} and wgmt.id = #{id}
...@@ -35,7 +40,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -35,7 +40,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and wgmt.msg_template_id = #{msgTemplateId} and wgmt.msg_template_id = #{msgTemplateId}
</if> </if>
<if test="userName != null and userName != ''"> <if test="userName != null and userName != ''">
and wu.user_name like concat('%', #{userName}, '%') and exists
(select 1 from we_user wu where wu.user_id = wgmt.user_id and wu.user_name like concat('%', #{userName}, '%'))
</if> </if>
<if test="status != null"> <if test="status != null">
and wgmt.status = #{status} and wgmt.status = #{status}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!