@ -18,7 +18,6 @@
package com.epmet.service.impl ;
import cn.hutool.core.bean.BeanUtil ;
import com.alibaba.fastjson.JSON ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl ;
@ -710,11 +709,27 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
queryDTO . setFormCode ( formCode ) ;
//所有的子表
Result < List < SubTableJoinDTO > > subTablesRes = operCustomizeOpenFeignClient . querySubTables ( queryDTO ) ;
List < String > subTables = new ArrayList < > ( ) ;
/ * List < String > subTablesBak = new ArrayList < > ( ) ;
if ( subTablesRes . success ( ) & & CollectionUtils . isNotEmpty ( subTablesRes . getData ( ) ) ) {
subTables = subTablesRes . getData ( ) . stream ( ) . map ( SubTableJoinDTO : : getJoinTableSql ) . collect ( Collectors . toList ( ) ) ;
}
return baseDao . dynamicQuery ( customerId , resultTableName , conditions , subTables , currentStaffAgencyId , staffOrgPath ) ;
subTablesBak = subTablesRes . getData ( ) . stream ( ) . map ( SubTableJoinDTO : : getJoinTableSql ) . collect ( Collectors . toList ( ) ) ;
} * /
List < SubTableJoinDTO > subTables = subTablesRes . getData ( ) ;
// log.info("1、所有的子表subTables:"+JSON.toJSONString(subTables,true));
//关联哪些子表:查询条件用到的表名+查询的列对应的表 并集去重
Set < String > whereConditionTables = conditions . stream ( ) . map ( ResiUserQueryValueDTO : : getTableName ) . collect ( Collectors . toSet ( ) ) ;
Set < String > tables = new HashSet < > ( ) ;
tables . addAll ( whereConditionTables ) ;
tables . add ( resultTableName ) ;
// log.info("2、查询条件+查询列对应的tables并集去重:"+ JSON.toJSONString(tables,true));
//最终关联的子表对应的sql:
List < String > finalSubTables = new ArrayList < > ( ) ;
subTables . forEach ( subTable - > {
if ( tables . contains ( subTable . getTableName ( ) ) ) {
finalSubTables . add ( subTable . getJoinTableSql ( ) ) ;
}
} ) ;
return baseDao . dynamicQuery ( customerId , resultTableName , conditions , finalSubTables , currentStaffAgencyId , staffOrgPath ) ;
}
/ * *