查询优化
This commit is contained in:
parent
80d8a3b752
commit
b3cf44e961
@ -70,10 +70,27 @@ public class CusMainServiceImpl extends ServiceImpl<CusMainMapper,CusMain> impl
|
|||||||
@DataScope(deptAlias = "cm", userAlias = "cm")
|
@DataScope(deptAlias = "cm", userAlias = "cm")
|
||||||
public IPage<MainVO> queryListPage(MainVO pageReqVO, Page<CusMain> page) {
|
public IPage<MainVO> queryListPage(MainVO pageReqVO, Page<CusMain> page) {
|
||||||
IPage<MainVO> list = cusMainMapper.queryListPage(pageReqVO, page);
|
IPage<MainVO> list = cusMainMapper.queryListPage(pageReqVO, page);
|
||||||
|
List<String> cusIdList = list.getRecords().stream().map(MainVO::getId).collect(Collectors.toList());
|
||||||
|
//公司信息
|
||||||
|
List<CusCompany> companyList = cusCompanyService.list(new LambdaQueryWrapper<CusCompany>().in(CusCompany::getCusId, cusIdList).eq(DlBaseEntity::getDelFlag,'0'));
|
||||||
|
Map<String, CusCompany> companyMap = companyList.stream().collect(Collectors.toMap(CusCompany::getCusId, Function.identity()));
|
||||||
|
//联系人信息
|
||||||
|
List<CusContacts> contacts = cusContactsService.list(new LambdaQueryWrapper<CusContacts>().in(CusContacts::getCusId, cusIdList).eq(DlBaseEntity::getDelFlag,'0').eq(CusContacts::getIfDefault,true));
|
||||||
|
Map<String, CusContacts> contactsMap = contacts.stream().collect(Collectors.toMap(CusContacts::getCusId, Function.identity()));
|
||||||
list.getRecords().forEach(item->{
|
list.getRecords().forEach(item->{
|
||||||
if(StringUtils.isNotEmpty(item.getCusLabels())){
|
if(StringUtils.isNotEmpty(item.getCusLabels())){
|
||||||
item.setCusLabelList(JSON.parseArray(item.getCusLabels()));
|
item.setCusLabelList(JSON.parseArray(item.getCusLabels()));
|
||||||
}
|
}
|
||||||
|
if(companyMap.containsKey(item.getId())){
|
||||||
|
CusCompany company = companyMap.get(item.getId());
|
||||||
|
item.setCusFrom(company.getCusFrom());
|
||||||
|
item.setCusLevel(company.getCusLevel());
|
||||||
|
item.setBusiType(company.getBusiType());
|
||||||
|
item.setContactAddress(company.getContactAddress());
|
||||||
|
}
|
||||||
|
if(contactsMap.containsKey(item.getId())){
|
||||||
|
item.setContactName(contactsMap.get(item.getId()).getName());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,25 +55,15 @@
|
|||||||
|
|
||||||
<select id="queryListPage" parameterType="com.ruoyi.cus.vo.MainVO" resultType="com.ruoyi.cus.vo.MainVO">
|
<select id="queryListPage" parameterType="com.ruoyi.cus.vo.MainVO" resultType="com.ruoyi.cus.vo.MainVO">
|
||||||
SELECT
|
SELECT
|
||||||
cm.*,
|
cm.*
|
||||||
cc.cus_from AS cusFrom,
|
|
||||||
cc.cus_level AS cusLevel,
|
|
||||||
cc.busi_type AS busiType,
|
|
||||||
cc.contact_address AS contactAddress,
|
|
||||||
cct.`name` AS contactName
|
|
||||||
FROM
|
FROM
|
||||||
cus_main cm
|
cus_main cm
|
||||||
LEFT JOIN cus_company cc ON cm.id = cc.cus_id
|
|
||||||
AND cc.del_flag = '0'
|
|
||||||
LEFT JOIN cus_contacts cct ON cm.id = cct.cus_id
|
|
||||||
AND cct.if_default = 1
|
|
||||||
AND cct.del_flag = '0'
|
|
||||||
WHERE
|
WHERE
|
||||||
cm.del_flag = '0'
|
cm.del_flag = '0'
|
||||||
<if test="entity.cusCode!=null and entity.cusCode!=''">
|
<if test="entity.cusCode!=null and entity.cusCode!=''">
|
||||||
AND cm.cus_code = #{entity.cusCode}
|
AND cm.cus_code = #{entity.cusCode}
|
||||||
</if>
|
</if>
|
||||||
<if test="entity.fullName!=null and entity.cusCode!=''">
|
<if test="entity.fullName!=null and entity.fullName!=''">
|
||||||
AND cm.full_name LIKE CONCAT('%',#{entity.fullName},'%')
|
AND cm.full_name LIKE CONCAT('%',#{entity.fullName},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="entity.shortName!=null and entity.shortName!=''">
|
<if test="entity.shortName!=null and entity.shortName!=''">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user