Commit 4f117ce1 authored by danmo's avatar danmo
Browse files

Merge branch 'back_end_dev_2.0' into back_end_dev

No related merge requests found
Showing with 85 additions and 22 deletions
+85 -22
......@@ -77,4 +77,14 @@ public class WeGroupMessageTask extends BaseEntity{
@ApiModelProperty("企业服务人员名称")
@TableField(exist = false)
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 {
*/
@ApiModelProperty("来源 0 群发 1 其他")
private Integer source;
/**
* 刷新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("刷新时间")
private Date refreshTime;
}
......@@ -28,6 +28,10 @@ public class WeGroupMessageDetailVo {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date sendTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("刷新时间")
private Date refreshTime;
@ApiModelProperty("附件")
private List<WeGroupMessageAttachments> attachments;
......
......@@ -81,12 +81,16 @@ public class WeGroupMessageSendResultServiceImpl extends ServiceImpl<WeGroupMess
sendResultList.forEach(item -> {
LambdaQueryWrapper<WeGroupMessageSendResult> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(WeGroupMessageSendResult::getMsgId, item.getMsgId())
.eq(WeGroupMessageSendResult::getExternalUserid, item.getExternalUserid())
.eq(WeGroupMessageSendResult::getUserId, item.getUserId())
.eq(WeGroupMessageSendResult::getChatId, item.getChatId());
.eq(WeGroupMessageSendResult::getUserId, item.getUserId());
if(item.getMsgTemplateId() != null){
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)) {
this.save(item);
}
......
......@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.WeConstans;
......@@ -93,27 +94,47 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
WeGroupMessageDetailVo detailVo = new WeGroupMessageDetailVo();
detailVo.setChatType(msgTemplate);
detailVo.setRefreshTime(weGroupMessageTemplate.getRefreshTime());
detailVo.setSendTime(weGroupMessageTemplate.getSendTime());
detailVo.setContent(weGroupMessageTemplate.getContent());
List<WeGroupMessageListVo> groupMsgDetail = weGroupMessageListService.getGroupMsgDetail(id);
List<WeGroupMessageAttachments> attachmentsList = attachmentsService.lambdaQuery().eq(WeGroupMessageAttachments::getMsgTemplateId, id).list();
detailVo.setAttachments(attachmentsList);
List<WeGroupMessageTask> taskList = messageTaskService.lambdaQuery().eq(WeGroupMessageTask::getMsgTemplateId, id).list();
if(CollectionUtil.isNotEmpty(taskList)){
//待发送人员列表
Long toBeSent = taskList.stream().filter(item -> ObjectUtil.equal(0, item.getStatus())).count();
detailVo.setToBeSendNum(toBeSent.intValue());
//已发送人员列表
Long alreadySent = taskList.stream().filter(item -> ObjectUtil.equal(2, item.getStatus())).count();
detailVo.setAlreadySendNum(alreadySent.intValue());
}
List<WeGroupMessageSendResult> resultList = messageSendResultService.lambdaQuery().eq(WeGroupMessageSendResult::getMsgTemplateId, id).list();
if(CollectionUtil.isNotEmpty(resultList)){
//未发送客户数
Long toBeCustomerNum = resultList.stream().filter(item -> ObjectUtil.equal(0, item.getStatus())).count();
detailVo.setToBeSendCustomerNum(toBeCustomerNum.intValue());
//已发送客户数
Long alreadyCustomerNum = resultList.stream().filter(item -> ObjectUtil.equal(1, item.getStatus())).count();
detailVo.setAlreadySendCustomerNum(alreadyCustomerNum.intValue());
}
/*List<WeGroupMessageListVo> groupMsgDetail = weGroupMessageListService.getGroupMsgDetail(id);
if (CollectionUtil.isNotEmpty(groupMsgDetail)) {
detailVo.setAttachments(groupMsgDetail.get(0).getAttachments());
//待发送人员列表
List<WeGroupMessageTask> toBeSent = groupMsgDetail.stream().map(WeGroupMessageListVo::getSenders)
.flatMap(Collection::stream).filter(item -> ObjectUtil.equal(0, item.getStatus())).collect(Collectors.toList());
Long toBeSent = groupMsgDetail.stream().map(WeGroupMessageListVo::getSenders)
.flatMap(Collection::stream).filter(item -> ObjectUtil.equal(0, item.getStatus())).count();
detailVo.setToBeSendNum(toBeSent.intValue());
//已发送人员列表
List<WeGroupMessageTask> alreadySent = groupMsgDetail.stream().map(WeGroupMessageListVo::getSenders)
.flatMap(Collection::stream).filter(item -> ObjectUtil.equal(2, item.getStatus())).collect(Collectors.toList());
Long alreadySent = groupMsgDetail.stream().map(WeGroupMessageListVo::getSenders)
.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)
.filter(item -> ObjectUtil.equal(0, item.getStatus())).count();
detailVo.setToBeSendCustomerNum(toBeCustomerNum.intValue());
//已发送客户数
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());
//未发送查询每个人员对应客户信息
if (CollectionUtil.isNotEmpty(toBeSent)) {
......@@ -138,9 +159,9 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
}).collect(Collectors.toList());
detailVo.setToBeSendList(toBeSentList);
detailVo.setToBeSendNum(toBeSentList.size());
}
}*/
//已发送查询每个人员对应客户信息
if (CollectionUtil.isNotEmpty(alreadySent)) {
/*if (CollectionUtil.isNotEmpty(alreadySent)) {
List<WeGroupMessageTaskVo> alreadySentList = alreadySent.stream().map(userInfo -> {
WeGroupMessageTaskVo weGroupMessageTaskVo = new WeGroupMessageTaskVo();
weGroupMessageTaskVo.setUserId(userInfo.getUserId());
......@@ -164,7 +185,7 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
detailVo.setAlreadySendList(alreadySentList);
detailVo.setAlreadySendNum(alreadySentList.size());
}
}
}*/
return detailVo;
}
......@@ -309,6 +330,9 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
@Async
@Override
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>()
.in(WeGroupMessageList::getMsgTemplateId, asList));
List<WeGroupMessageTask> taskList = new ArrayList<>();
......
......@@ -47,13 +47,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and wgmsr.status = #{status}
</if>
<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 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 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 test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
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"
<result property="msgId" column="msg_id" />
<result property="userId" column="user_id" />
<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="sendTime" column="send_time" />
</resultMap>
......@@ -19,11 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wgmt.msg_template_id,
wgmt.msg_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.send_time
wgmt.send_time,
(select group_concat(distinct (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(distinct (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
left join we_user wu on wu.user_id = wgmt.user_id
<where>
<if test="id != null">
and wgmt.id = #{id}
......@@ -35,7 +40,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and wgmt.msg_template_id = #{msgTemplateId}
</if>
<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 test="status != null">
and wgmt.status = #{status}
......
Supports Markdown
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