Commit 8140beee authored by lcl's avatar lcl

列表查询优化

parent d8ee0ae6
......@@ -51,16 +51,17 @@ public class CustomerServiceImpl implements ICustomerService {
@Override
public List<CustomerListVo> selectList(CustomerSearchDto dto) {
dto.setUserId(SecurityUtils.getUserId());
List<CustomerListVo> vos = baseMapper.selectList(dto);
vos.parallelStream().forEach(vo -> {
//合作项目
vo.setCooperationProject(businessInfoService.selectCountByStatusAndCustomerId(2, vo.getCustomerId()));
//跟进项目
vo.setFollowProject(businessInfoService.selectCountByStatusAndCustomerId(1, vo.getCustomerId()));
//储备项目
vo.setReserveProject(businessInfoService.selectCountByStatusAndCustomerId(0, vo.getCustomerId()));
});
return vos;
// List<CustomerListVo> vos = baseMapper.selectList(dto);
// vos.parallelStream().forEach(vo -> {
// //合作项目
// vo.setCooperationProject(businessInfoService.selectCountByStatusAndCustomerId(2, vo.getCustomerId()));
// //跟进项目
// vo.setFollowProject(businessInfoService.selectCountByStatusAndCustomerId(1, vo.getCustomerId()));
// //储备项目
// vo.setReserveProject(businessInfoService.selectCountByStatusAndCustomerId(0, vo.getCustomerId()));
// });
// return vos;
return baseMapper.selectList(dto);
}
@Override
......
......@@ -10,7 +10,7 @@
ct.performance_characteristic, ct.other_ms_characteistic, ct.create_id, ct.create_time, ct.update_id, ct.update_time
</sql>
<select id="selectList" resultType="com.dsk.system.domain.customer.vo.CustomerListVo">
<select id="selectList1" resultType="com.dsk.system.domain.customer.vo.CustomerListVo">
select
u.nick_name followUser,
<include refid="Base_Bean"></include>
......@@ -21,6 +21,26 @@
<if test="dto.companyName != null and dto.companyName != '' "> and ct.company_name like concat('%',#{dto.companyName},'%')</if>
</select>
<select id="selectList" resultType="com.dsk.system.domain.customer.vo.CustomerListVo">
select
u.nick_name followUser, bi1.num reserveProject, bi2.num followProject, bi3.num cooperationProject,
<include refid="Base_Bean"></include>
from customer ct
join customer_user ctu on ct.customer_id = ctu.customer_id
join sys_user u on ctu.user_id = u.user_id
left join (
select count(status) num,customer_id from business_info where `status` = '储备中' group by customer_id
) bi1 on bi1.customer_id = ct.customer_id
left join (
select count(status) num,customer_id from business_info where `status` = '跟进中' group by customer_id
) bi2 on bi2.customer_id = ct.customer_id
left join (
select count(status) num,customer_id from business_info where `status` = '已合作' group by customer_id
) bi3 on bi3.customer_id = ct.customer_id
where ctu.user_id = #{dto.userId}
<if test="dto.companyName != null and dto.companyName != '' "> and ct.company_name like concat('%',#{dto.companyName},'%')</if>
</select>
<select id="selectUserList" resultType="com.dsk.system.domain.customer.Customer">
select
ct.customer_id, ct.company_name
......
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