|
@@ -1,9 +1,17 @@
|
|
package com.fjhx.sale.service.contract.impl;
|
|
package com.fjhx.sale.service.contract.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.fjhx.customer.entity.customer.po.Customer;
|
|
|
|
+import com.fjhx.customer.service.customer.CustomerService;
|
|
import com.fjhx.sale.entity.contract.po.Contract;
|
|
import com.fjhx.sale.entity.contract.po.Contract;
|
|
import com.fjhx.sale.mapper.contract.ContractMapper;
|
|
import com.fjhx.sale.mapper.contract.ContractMapper;
|
|
import com.fjhx.sale.service.contract.ContractService;
|
|
import com.fjhx.sale.service.contract.ContractService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
|
+import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
|
+import org.apache.commons.collections4.MapUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.fjhx.sale.entity.contract.vo.ContractVo;
|
|
import com.fjhx.sale.entity.contract.vo.ContractVo;
|
|
@@ -12,6 +20,10 @@ import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.fjhx.sale.entity.contract.dto.ContractDto;
|
|
import com.fjhx.sale.entity.contract.dto.ContractDto;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -24,11 +36,38 @@ import cn.hutool.core.bean.BeanUtil;
|
|
@Service
|
|
@Service
|
|
public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> implements ContractService {
|
|
public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> implements ContractService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private CustomerService customerService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页
|
|
|
|
+ * @param dto
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public Page<ContractVo> getPage(ContractSelectDto dto) {
|
|
public Page<ContractVo> getPage(ContractSelectDto dto) {
|
|
IWrapper<Contract> wrapper = getWrapper();
|
|
IWrapper<Contract> wrapper = getWrapper();
|
|
- wrapper.orderByDesc("c", Contract::getId);
|
|
|
|
|
|
+ wrapper.orderByDesc(Contract::getCreateTime);
|
|
|
|
+ if(StringUtils.isNotEmpty(dto.getStatus())){
|
|
|
|
+ wrapper.eq(Contract::getStatus,dto.getStatus());
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotEmpty(dto.getKeyword())){
|
|
|
|
+ wrapper.keyword(dto.getKeyword(),new SqlField(Contract::getCode));
|
|
|
|
+ }
|
|
Page<ContractVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
Page<ContractVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
|
+ List<ContractVo> list = page.getRecords();
|
|
|
|
+ if(CollectionUtils.isNotEmpty(list)){
|
|
|
|
+ List<Long> companyIds = list.stream().map(Contract::getSellCorporationId).collect(Collectors.toList());
|
|
|
|
+ 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));
|
|
|
|
+ if(MapUtils.isNotEmpty(cusMap)){//客户
|
|
|
|
+ for(ContractVo p:list){
|
|
|
|
+ List<Customer> customers = cusMap.getOrDefault(p.getBuyCorporationId(),null);
|
|
|
|
+ p.setBuyCorporationName(customers==null?null:customers.get(0).getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
|
|
|