|
@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
|
+import com.fjhx.customer.entity.customer.vo.CustomerVo;
|
|
|
+import com.fjhx.customer.service.customer.CustomerService;
|
|
|
import com.fjhx.mail.config.MailServiceConfig;
|
|
|
import com.fjhx.mail.entity.dto.GetMessagePageDto;
|
|
|
import com.fjhx.mail.entity.enterprise.po.EnterpriseDomain;
|
|
@@ -36,7 +38,6 @@ import com.fjhx.mail.service.personal.PersonalMessageService;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
-import com.ruoyi.common.utils.PageWrapper;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
@@ -44,6 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -79,6 +81,8 @@ public class InfoServiceImpl implements InfoService {
|
|
|
private EnterpriseMessageMapper enterpriseMessageMapper;
|
|
|
@Autowired
|
|
|
private PersonalMessageMapper personalMessageMapper;
|
|
|
+ @Autowired
|
|
|
+ private CustomerService customerService;
|
|
|
|
|
|
@Override
|
|
|
public List<SysUser> getUserList() {
|
|
@@ -235,7 +239,8 @@ public class InfoServiceImpl implements InfoService {
|
|
|
|
|
|
@Override
|
|
|
public Object getMessagePage(GetMessagePageDto dto) {
|
|
|
- PageWrapper<MessageVo> pageWrapper;
|
|
|
+
|
|
|
+ Page<MessageVo> page;
|
|
|
|
|
|
|
|
|
if (dto.getType().equals(1)) {
|
|
@@ -249,13 +254,12 @@ public class InfoServiceImpl implements InfoService {
|
|
|
.or().like("cu.name", dto.getKeyword())
|
|
|
.or().like("pm.from_personal_name", dto.getKeyword())
|
|
|
);
|
|
|
+ wrapper.groupBy("pm.id");
|
|
|
wrapper.orderByDesc("pm.send_date");
|
|
|
- Page<PersonalMessage> page = personalMessageMapper.getPage(dto.getPage(), wrapper);
|
|
|
-
|
|
|
- pageWrapper = new PageWrapper<>(page, MessageVo.class);
|
|
|
+ page = personalMessageMapper.getPage(dto.getPage(), wrapper, SecurityUtils.getTenantId());
|
|
|
|
|
|
if (page.getSize() == 0) {
|
|
|
- return pageWrapper;
|
|
|
+ return page;
|
|
|
}
|
|
|
|
|
|
PersonalFolder personalFolder = personalFolderService.getById(dto.getFolderId());
|
|
@@ -276,14 +280,12 @@ public class InfoServiceImpl implements InfoService {
|
|
|
.or().like("cu.name", dto.getKeyword())
|
|
|
.or().like("em.from_personal_name", dto.getKeyword())
|
|
|
);
|
|
|
+ wrapper.groupBy("em.id");
|
|
|
wrapper.orderByDesc("em.send_date");
|
|
|
- Page<EnterpriseMessage> page = enterpriseMessageMapper.getPage(dto.getPage(), wrapper);
|
|
|
-
|
|
|
-
|
|
|
- pageWrapper = new PageWrapper<>(page, MessageVo.class);
|
|
|
+ page = enterpriseMessageMapper.getPage(dto.getPage(), wrapper, SecurityUtils.getTenantId());
|
|
|
|
|
|
if (page.getSize() == 0) {
|
|
|
- return pageWrapper;
|
|
|
+ return page;
|
|
|
}
|
|
|
|
|
|
EnterpriseFolder enterpriseFolder = enterpriseFolderService.getById(dto.getFolderId());
|
|
@@ -291,7 +293,18 @@ public class InfoServiceImpl implements InfoService {
|
|
|
throw new ServiceException("文件夹已被删除");
|
|
|
}
|
|
|
}
|
|
|
- return pageWrapper;
|
|
|
+
|
|
|
+ List<MessageVo> records = page.getRecords();
|
|
|
+ List<Long> customerIds = records.stream().map(MessageVo::getCustomerId).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ List<CustomerVo> customerInfoByIds = customerService.getCustomerInfoByIds(customerIds);
|
|
|
+ Map<Long, CustomerVo> customerInfoMap = customerInfoByIds.stream().collect(Collectors.toMap(CustomerVo::getId, Function.identity()));
|
|
|
+ for (MessageVo record : records) {
|
|
|
+ record.setCustomerInfo(customerInfoMap.get(record.getCustomerId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ return page;
|
|
|
}
|
|
|
|
|
|
|