Parcourir la source

Merge branch 'master' into dev

# Conflicts:
#	hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java
24282 il y a 2 ans
Parent
commit
51fd153955

+ 7 - 1
hx-customer/src/main/java/com/fjhx/customer/service/customer/CustomerService.java

@@ -66,10 +66,16 @@ public interface CustomerService extends BaseService<Customer> {
     /**
      * 客户来源统计
      */
-    Map<String,Object> sourceStatistics(CustomerSelectDto customerDto);
+    Map<String, Object> sourceStatistics(CustomerSelectDto customerDto);
 
     /**
      * 客户分配
      */
     void customerAllocation(CustomerDto dto);
+
+    /**
+     * 获取私海客户idList
+     */
+    List<Long> getAuthIdList();
+
 }

+ 22 - 11
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerServiceImpl.java

@@ -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();

+ 23 - 23
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -139,6 +139,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
      */
     @Override
     public Page<ContractVo> getPage(ContractSelectDto dto) {
+
         IWrapper<Contract> wrapper = getWrapper();
         wrapper.orderByDesc("t1", Contract::getCreateTime);
         wrapper.between("t1", Contract::getStatus, FlowStatusEnum.DRAFT.getKey(), FlowStatusEnum.CANCELLATION.getKey() - 1);
@@ -154,31 +155,29 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         if (StringUtils.isNotEmpty(dto.getKeyword())) {
             wrapper.keyword(dto.getKeyword(), new SqlField("t1", Contract::getCode));
         }
-        Page<ContractVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
-        List<ContractVo> list = page.getRecords();
-        if (CollectionUtils.isEmpty(list)) {
-            return page;
-        }
-
-        List<Long> customerIds = list.stream().map(Contract::getBuyCorporationId).collect(Collectors.toList());
-        List<Customer> customerList = customerService.list(Wrappers.<Customer>query().lambda().in(Customer::getId, customerIds));
-        Map<Long, List<Customer>> cusMap = customerList.stream().distinct().collect(Collectors.groupingBy(Customer::getId));
-
-        List<Long> ids = list.stream().map(ContractVo::getId).collect(Collectors.toList());
 
-        // 获取交接单附件
-        Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(ids, 1);
+        wrapper.in("t1", Contract::getBuyCorporationId, customerService.getAuthIdList());
 
-        // 获取包装附件
-        Map<Long, List<FileInfoVo>> packageFileMap = ObsFileUtil.getFileMap(ids, 2);
-
-        for (ContractVo p : list) {
-            if (MapUtils.isNotEmpty(cusMap)) {// 客户
-                List<Customer> customers = cusMap.getOrDefault(p.getBuyCorporationId(), null);
-                p.setBuyCorporationName(customers == null ? null : customers.get(0).getName());
-                // 赋值客户标签
-                p.setTag(customers == null ? null : customers.get(0).getTag());
-            }
+        Page<ContractVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        List<ContractVo> list = page.getRecords();
+        if (CollectionUtils.isNotEmpty(list)) {
+            List<Long> customerIds = list.stream().map(Contract::getBuyCorporationId).collect(Collectors.toList());
+            List<Customer> customerList = customerService.list(Wrappers.<Customer>query().lambda().in(Customer::getId, customerIds));
+            Map<Long, List<Customer>> cusMap = customerList.stream().distinct().collect(Collectors.groupingBy(Customer::getId));
+
+            List<Long> ids = list.stream().map(ContractVo::getId).collect(Collectors.toList());
+            // 获取交接单附件
+            Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(ids, 1);
+
+            // 获取包装附件
+            Map<Long, List<FileInfoVo>> packageFileMap = ObsFileUtil.getFileMap(ids, 2);
+            for (ContractVo p : list) {
+                if (MapUtils.isNotEmpty(cusMap)) {//客户
+                    List<Customer> customers = cusMap.getOrDefault(p.getBuyCorporationId(), null);
+                    p.setBuyCorporationName(customers == null ? null : customers.get(0).getName());
+                    //赋值客户标签
+                    p.setTag(customers == null ? null : customers.get(0).getTag());
+                }
 
             // 赋值交接单附件
             if (MapUtils.isNotEmpty(fileMap)) {
@@ -192,6 +191,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
                 p.setPackageFileInfoVOList(packageFileInfoVOList);
             }
 
+            }
         }
         return page;
     }

+ 10 - 1
hx-sale/src/main/java/com/fjhx/sale/service/sale/impl/SaleQuotationServiceImpl.java

@@ -75,15 +75,24 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
      */
     @Override
     public Page<SaleQuotationVo> getPage(SaleQuotationSelectDto dto) {
+
+        List<Long> authIdList = customerService.getAuthIdList();
+
+        if (authIdList.size() == 0) {
+            return new Page<>();
+        }
+
         LambdaQueryWrapper<SaleQuotation> wrapper = Wrappers.lambdaQuery();
         wrapper.eq(ObjectUtil.isNotEmpty(dto.getSellCorporationId()),
                 SaleQuotation::getSellCorporationId, dto.getSellCorporationId());
         wrapper.eq(ObjectUtil.isNotEmpty(dto.getStatus()), SaleQuotation::getStatus, dto.getStatus());
         wrapper.orderByDesc(SaleQuotation::getCreateTime);
+        wrapper.in(SaleQuotation::getBuyCorporationId, authIdList);
+
         Page<SaleQuotationVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         List<SaleQuotationVo> saleQuotationVoList = page.getRecords();
 
-        //赋值用户名称
+        // 赋值用户名称
         UserUtil.assignmentNickName(saleQuotationVoList, BasePo::getCreateUser, SaleQuotationVo::setUserName);
         return page;
     }