|
@@ -1,20 +1,30 @@
|
|
|
package com.fjhx.customer.service.customer.impl;
|
|
|
|
|
|
-import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
+import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.common.constant.SourceConstant;
|
|
|
+import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsDto;
|
|
|
+import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsSelectDto;
|
|
|
import com.fjhx.customer.entity.customer.po.CustomerFollowRecords;
|
|
|
+import com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo;
|
|
|
import com.fjhx.customer.mapper.customer.CustomerFollowRecordsMapper;
|
|
|
import com.fjhx.customer.service.customer.CustomerFollowRecordsService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.file.entity.FileInfo;
|
|
|
+import com.fjhx.file.entity.ObsFile;
|
|
|
+import com.fjhx.file.service.FileInfoService;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo;
|
|
|
-import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsSelectDto;
|
|
|
+import com.obs.services.internal.ServiceException;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
-import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsDto;
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
-import oshi.util.FileUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -22,21 +32,58 @@ import oshi.util.FileUtil;
|
|
|
* 客户跟进记录 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
- * @author
|
|
|
+ * @author
|
|
|
* @since 2023-05-05
|
|
|
*/
|
|
|
@Service
|
|
|
public class CustomerFollowRecordsServiceImpl extends ServiceImpl<CustomerFollowRecordsMapper, CustomerFollowRecords> implements CustomerFollowRecordsService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ FileInfoService fileInfoService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<CustomerFollowRecordsVo> getPage(CustomerFollowRecordsSelectDto dto) {
|
|
|
IWrapper<CustomerFollowRecords> wrapper = getWrapper();
|
|
|
+ wrapper.eq("cfr",CustomerFollowRecords::getCustomerId,dto.getCustomerId());//根据客户id过滤
|
|
|
wrapper.orderByDesc("cfr", CustomerFollowRecords::getId);
|
|
|
Page<CustomerFollowRecordsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ List<CustomerFollowRecordsVo> records = page.getRecords();
|
|
|
+ //赋值文件列表信息
|
|
|
+ List<Long> ids = records.stream().map(CustomerFollowRecordsVo::getId).filter(ObjectUtil::isNotNull).distinct().collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(ids)) {
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
|
+ Map<Long, List<FileInfo>> longListMap = fileInfoService.mapKGroup(FileInfo::getBusinessId, q -> q.in(FileInfo::getBusinessId, ids));
|
|
|
+ for (CustomerFollowRecordsVo record : records) {
|
|
|
+ List<ObsFile> obsFiles = BeanUtil.copyToList(longListMap.get(record.getId()), ObsFile.class);
|
|
|
+ record.setFileList(obsFiles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public List<CustomerFollowRecordsVo> followList(Long customerId){
|
|
|
+ if(ObjectUtil.isEmpty(customerId)){
|
|
|
+ throw new ServiceException("客户id不能为空");
|
|
|
+ }
|
|
|
+ List<CustomerFollowRecords> customerFollowRecords = list(q->q.eq(CustomerFollowRecords::getCustomerId,customerId)
|
|
|
+ .orderByDesc(CustomerFollowRecords::getDate));
|
|
|
+ List<CustomerFollowRecordsVo> customerFollowRecordsVos = BeanUtil.copyToList(customerFollowRecords, CustomerFollowRecordsVo.class);
|
|
|
+ //赋值文件列表信息
|
|
|
+ List<Long> ids = customerFollowRecordsVos.stream().map(CustomerFollowRecordsVo::getId).filter(ObjectUtil::isNotNull).distinct().collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(ids)) {
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
|
+ Map<Long, List<FileInfo>> longListMap = fileInfoService.mapKGroup(FileInfo::getBusinessId, q -> q.in(FileInfo::getBusinessId, ids));
|
|
|
+ for (CustomerFollowRecordsVo record : customerFollowRecordsVos) {
|
|
|
+ List<ObsFile> obsFiles = BeanUtil.copyToList(longListMap.get(record.getId()), ObsFile.class);
|
|
|
+ record.setFileList(obsFiles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return customerFollowRecordsVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public CustomerFollowRecordsVo detail(Long id) {
|
|
|
CustomerFollowRecords CustomerFollowRecords = this.getById(id);
|
|
|
CustomerFollowRecordsVo result = BeanUtil.toBean(CustomerFollowRecords, CustomerFollowRecordsVo.class);
|
|
@@ -47,14 +94,14 @@ public class CustomerFollowRecordsServiceImpl extends ServiceImpl<CustomerFollow
|
|
|
@Override
|
|
|
public void add(CustomerFollowRecordsDto customerFollowRecordsDto) {
|
|
|
this.save(customerFollowRecordsDto);
|
|
|
- ObsFileUtil.saveFile(customerFollowRecordsDto.getFileList(),customerFollowRecordsDto.getId());
|
|
|
+ ObsFileUtil.saveFile(customerFollowRecordsDto.getFileList(), customerFollowRecordsDto.getId());
|
|
|
}
|
|
|
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public void edit(CustomerFollowRecordsDto customerFollowRecordsDto) {
|
|
|
this.updateById(customerFollowRecordsDto);
|
|
|
- ObsFileUtil.editFile(customerFollowRecordsDto.getFileList(),customerFollowRecordsDto.getId());
|
|
|
+ ObsFileUtil.editFile(customerFollowRecordsDto.getFileList(), customerFollowRecordsDto.getId());
|
|
|
}
|
|
|
|
|
|
@DSTransactional
|