|
@@ -4,11 +4,13 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
+import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.area.utils.CustomizeAreaUtil;
|
|
|
+import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.common.entity.coding.bo.CustomerCodeAndCountryId;
|
|
|
import com.fjhx.common.service.coding.CodingRuleCustomerService;
|
|
|
import com.fjhx.customer.entity.customer.dto.CustomerDto;
|
|
@@ -271,34 +273,34 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
//存放统计数据
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
QueryWrapper<Customer> query = Wrappers.query();
|
|
|
- if (ObjectUtil.isNotEmpty(customerDto.getType())){
|
|
|
- //私海客户查询
|
|
|
+ if (ObjectUtil.isNotEmpty(customerDto.getType())) {
|
|
|
+ // 私海客户查询
|
|
|
if (customerDto.getType().equals("1")) {
|
|
|
query.isNotNull("user_id");
|
|
|
- //私海客户需要添加权限(自己查自己)
|
|
|
+ // 私海客户需要添加权限(自己查自己)
|
|
|
query.eq("user_id", SecurityUtils.getUserId());
|
|
|
- } else if (customerDto.getType().equals("0")) {//公海客户
|
|
|
+ } else if (customerDto.getType().equals("0")) {// 公海客户
|
|
|
query.and(wrapper1 -> wrapper1.isNull("user_id").or().eq("user_id", ""));
|
|
|
}
|
|
|
}
|
|
|
- if (customerDto.getStatisticsType() == 1){//来源统计
|
|
|
+ if (customerDto.getStatisticsType() == 1) {// 来源统计
|
|
|
query.groupBy("source");
|
|
|
query.select("count(*) count,source");
|
|
|
- }else if (customerDto.getStatisticsType() == 2){//数据类型统计
|
|
|
+ } else if (customerDto.getStatisticsType() == 2) {// 数据类型统计
|
|
|
query.groupBy("status");
|
|
|
query.select("count(*) count,status");
|
|
|
- }else if (customerDto.getStatisticsType() == 3){//业务员统计
|
|
|
+ } else if (customerDto.getStatisticsType() == 3) {// 业务员统计
|
|
|
query.groupBy("user_id");
|
|
|
query.select("count(*) count,user_id");
|
|
|
}
|
|
|
List<Customer> customerList = baseMapper.selectList(query);
|
|
|
|
|
|
|
|
|
- UserUtil.assignmentNickName(customerList, Customer::getUserId,Customer::setUserName);
|
|
|
+ UserUtil.assignmentNickName(customerList, Customer::getUserId, Customer::setUserName);
|
|
|
|
|
|
- Integer countAmount = customerList.stream().map(customer -> customer.getCount()).reduce(Integer::sum).orElse(0);
|
|
|
- map.put("countAmount",countAmount);
|
|
|
- map.put("customerList",customerList);
|
|
|
+ Integer countAmount = customerList.stream().map(Customer::getCount).reduce(Integer::sum).orElse(0);
|
|
|
+ map.put("countAmount", countAmount);
|
|
|
+ map.put("customerList", customerList);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -310,6 +312,15 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
baseMapper.customerAllocation(dto);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Long> getAuthIdList() {
|
|
|
+ List<Long> authUserIdList = UserUtil.getAuthUserIdList();
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.CUSTOMER);
|
|
|
+ List<Long> customer = listObject(Customer::getId, q -> q.in(Customer::getUserId, authUserIdList));
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
+ return customer;
|
|
|
+ }
|
|
|
+
|
|
|
// 根据字典编码获取字典的数据
|
|
|
private List<DictTenantDataVo> getDict(String code) {
|
|
|
DictTenantDataSelectDto dto = new DictTenantDataSelectDto();
|