Commit 652e35a9 authored by lcl's avatar lcl

逻辑优化

parent e377b95a
...@@ -3,6 +3,9 @@ package com.dsk.cscec.mapper; ...@@ -3,6 +3,9 @@ package com.dsk.cscec.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dsk.cscec.domain.DSubcontract; import com.dsk.cscec.domain.DSubcontract;
import com.dsk.cscec.domain.vo.DCustomerListVo;
import java.util.Map;
/** /**
* 分包分供合同(DSubcontract)表数据库访问层 * 分包分供合同(DSubcontract)表数据库访问层
...@@ -16,5 +19,7 @@ public interface DSubcontractMapper extends BaseMapper<DSubcontract> { ...@@ -16,5 +19,7 @@ public interface DSubcontractMapper extends BaseMapper<DSubcontract> {
Integer selectProjectCountByCustomerId(String customerId); Integer selectProjectCountByCustomerId(String customerId);
DCustomerListVo selectStatisticByCustomerId(String customerId);
} }
...@@ -45,10 +45,11 @@ public class DCustomerServiceImpl extends ServiceImpl<DCustomerMapper, DCustomer ...@@ -45,10 +45,11 @@ public class DCustomerServiceImpl extends ServiceImpl<DCustomerMapper, DCustomer
Page<DCustomerListVo> page = baseMapper.allSearchList(query.build(), bo); Page<DCustomerListVo> page = baseMapper.allSearchList(query.build(), bo);
if (CollectionUtils.isNotEmpty(page.getRecords())) { if (CollectionUtils.isNotEmpty(page.getRecords())) {
page.getRecords().parallelStream().forEach(item->{ page.getRecords().parallelStream().forEach(item->{
DCustomerListVo vo = subcontractMapper.selectStatisticByCustomerId(item.getCustomerId());
//企业合作数量 //企业合作数量
item.setEnterpriseCooperationCount(subcontractMapper.selectEnterpriseCountByCustomerId(item.getCustomerId())); item.setEnterpriseCooperationCount(vo.getEnterpriseCooperationCount());
//项目合作数量 //项目合作数量
item.setProjectCooperationCount(subcontractMapper.selectProjectCountByCustomerId(item.getCustomerId())); item.setProjectCooperationCount(vo.getProjectCooperationCount());
try { try {
Map<String, Object> map = opportunityRadarService.enterpriseByName(item.getCustomerName()); Map<String, Object> map = opportunityRadarService.enterpriseByName(item.getCustomerName());
if (!ObjectUtils.isEmpty(map.get("data"))) { if (!ObjectUtils.isEmpty(map.get("data"))) {
...@@ -71,10 +72,11 @@ public class DCustomerServiceImpl extends ServiceImpl<DCustomerMapper, DCustomer ...@@ -71,10 +72,11 @@ public class DCustomerServiceImpl extends ServiceImpl<DCustomerMapper, DCustomer
List<DCustomerListVo> records = baseMapper.allSearchList(query.build(), bo).getRecords(); List<DCustomerListVo> records = baseMapper.allSearchList(query.build(), bo).getRecords();
if(CollectionUtils.isNotEmpty(records)){ if(CollectionUtils.isNotEmpty(records)){
records.parallelStream().forEach(item->{ records.parallelStream().forEach(item->{
DCustomerListVo vo = subcontractMapper.selectStatisticByCustomerId(item.getCustomerId());
//企业合作数量 //企业合作数量
item.setEnterpriseCooperationCount(subcontractMapper.selectEnterpriseCountByCustomerId(item.getCustomerId())); item.setEnterpriseCooperationCount(vo.getEnterpriseCooperationCount());
//项目合作数量 //项目合作数量
item.setProjectCooperationCount(subcontractMapper.selectProjectCountByCustomerId(item.getCustomerId())); item.setProjectCooperationCount(vo.getProjectCooperationCount());
}); });
} }
return records; return records;
......
...@@ -17,4 +17,14 @@ ...@@ -17,4 +17,14 @@
) a ) a
</select> </select>
<select id="selectStatisticByCustomerId" resultType="com.dsk.cscec.domain.vo.DCustomerListVo">
select
count(DISTINCT org.customer_id) enterpriseCooperationCount,
count(DISTINCT project.customer_id) projectCooperationCount
from d_customer dc
left join d_subcontract org on org.customer_id = dc.customer_id
left join d_subcontract project on project.customer_id = dc.customer_id
where dc.customer_id = #{customerId}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment