提交 0f5782d5 作者: 925993793@qq.com

测试bug修改

上级 d4a0d3b8
package com.zzsn.thinktank.config;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.binding.MapperMethod.ParamMap;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.plugin.*;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.util.*;
/**
* mybatis拦截器,自动注入创建人、创建时间、修改人、修改时间
*
* @Author scott
* @Date 2019-01-19
*/
@Slf4j
@Component
@Intercepts({@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})})
public class MybatisInterceptor implements Interceptor {
@Override
public Object intercept(Invocation invocation) throws Throwable {
MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
String sqlId = mappedStatement.getId();
log.debug("------sqlId------" + sqlId);
SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType();
Object parameter = invocation.getArgs()[1];
log.debug("------sqlCommandType------" + sqlCommandType);
if (parameter == null) {
return invocation.proceed();
}
Date date = new Date();
if (SqlCommandType.INSERT == sqlCommandType) {
Field[] fields = getAllFields(parameter);
for (Field field : fields) {
String fieldName = field.getName();
// 注入创建时间
if ("createTime".equals(fieldName)) {
field.setAccessible(true);
Object localCreateDate = field.get(parameter);
field.setAccessible(false);
if (localCreateDate == null || localCreateDate.equals("")) {
changeData(field, parameter, date);
}
}
}
}
if (SqlCommandType.UPDATE == sqlCommandType) {
Field[] fields;
if (parameter instanceof ParamMap) {
ParamMap<?> p = (ParamMap<?>) parameter;
if (p.containsKey("et")) {
parameter = p.get("et");
} else {
parameter = p.get("param1");
}
if (parameter == null) {
return invocation.proceed();
}
fields = getAllFields(parameter);
} else {
fields = getAllFields(parameter);
}
for (Field field : fields) {
String fieldName = field.getName();
log.debug("------field.name------" + fieldName);
if ("updateTime".equals(fieldName)) {
changeData(field, parameter, date);
}
}
}
return invocation.proceed();
}
@Override
public Object plugin(Object target) {
return Plugin.wrap(target, this);
}
@Override
public void setProperties(Properties properties) {
}
//修改对应字段的值
private void changeData(Field field, Object parameter,Object data){
try {
field.setAccessible(true);
field.set(parameter,data);
field.setAccessible(false);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
private Field[] getAllFields(Object object) {
Class<?> clazz = object.getClass();
List<Field> fieldList = new ArrayList<>();
while (clazz != null) {
fieldList.addAll(new ArrayList<>(Arrays.asList(clazz.getDeclaredFields())));
clazz = clazz.getSuperclass();
}
Field[] fields = new Field[fieldList.size()];
fieldList.toArray(fields);
return fields;
}
}
...@@ -143,12 +143,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -143,12 +143,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return ; return ;
} }
if (sourceBindType == 1) { if (sourceBindType == 1) {
//解绑通用信息源组 //解绑通用信息源栏目
unBindInfoSource(bindVO, BindTypeEnum.INFO_SOURCE_GROUP.getvalue()); unBindInfoSource(bindVO, BindTypeEnum.INFO_SOURCE_GROUP.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//解绑定向信息源 //解绑屏蔽信息源栏目
unBindInfoSource(bindVO,BindTypeEnum.DIRECTIONA_INFO_SOURCE_GROUP.getvalue()); unBindInfoSource(bindVO,BindTypeEnum.EXCLUDE_INFO_SOURCE_GROUP.getvalue());
} }
} }
private void unBindInfoSourceColumn(BindVO bindVO) { private void unBindInfoSourceColumn(BindVO bindVO) {
...@@ -158,12 +158,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -158,12 +158,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return ; return ;
} }
if (sourceBindType == 1) { if (sourceBindType == 1) {
//解绑通用信息源 //解绑通用信息源栏目
unBindInfoSource(bindVO, BindTypeEnum.INFO_SOURCE.getvalue()); unBindInfoSource(bindVO, BindTypeEnum.INFO_SOURCE.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//解绑定向信息源组 //解绑屏蔽信息源栏目
unBindInfoSource(bindVO,BindTypeEnum.DIRECTIONA_INFO_SOURCE.getvalue()); unBindInfoSource(bindVO,BindTypeEnum.EXCLUDE_INFO_SOURCE.getvalue());
} }
} }
...@@ -177,9 +177,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -177,9 +177,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//解绑通用信息源组 //解绑通用信息源组
unBindInfoSource(bindVO, BindTypeEnum.INFO_MAIN_SOURCE_GROUP.getvalue()); unBindInfoSource(bindVO, BindTypeEnum.INFO_MAIN_SOURCE_GROUP.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//解绑定向信息源组 //解绑屏蔽信息源组
unBindInfoSource(bindVO,BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE_GROUP.getvalue()); unBindInfoSource(bindVO,BindTypeEnum.EXCLUDE_MAIN_INFO_SOURCE_GROUP.getvalue());
} }
} }
private void unBindInfoSource(BindVO bindVO) { private void unBindInfoSource(BindVO bindVO) {
...@@ -192,9 +192,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -192,9 +192,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//解绑通用信息源 //解绑通用信息源
unBindInfoSource(bindVO, BindTypeEnum.INFO_MAIN_SOURCE.getvalue()); unBindInfoSource(bindVO, BindTypeEnum.INFO_MAIN_SOURCE.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//解绑定向信息源 //解绑屏蔽信息源
unBindInfoSource(bindVO,BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE.getvalue()); unBindInfoSource(bindVO,BindTypeEnum.EXCLUDE_MAIN_INFO_SOURCE.getvalue());
} }
} }
...@@ -205,12 +205,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -205,12 +205,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return ; return ;
} }
if (sourceBindType == 1) { if (sourceBindType == 1) {
//解绑通用标签 //解绑通用信息源栏目标签
unBindLabel(bindVO, BindTypeEnum.INFO_SOURCE_LABEL.getvalue()); unBindLabel(bindVO, BindTypeEnum.INFO_SOURCE_LABEL.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//解绑定向标签 //解绑屏蔽信息源栏目标签
unBindLabel(bindVO, BindTypeEnum.DIRECTIONA_INFO_SOURCE_LABEL.getvalue()); unBindLabel(bindVO, BindTypeEnum.EXCLUDE_INFO_SOURCE_LABEL.getvalue());
} }
} }
private void unBindInfoSourceLabels(BindVO bindVO) { private void unBindInfoSourceLabels(BindVO bindVO) {
...@@ -220,12 +220,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -220,12 +220,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return ; return ;
} }
if (sourceBindType == 1) { if (sourceBindType == 1) {
//解绑通用标签 //解绑通用信息源标签
unBindLabel(bindVO, BindTypeEnum.INFO_SOURCE_MAIN_LABEL.getvalue()); unBindLabel(bindVO, BindTypeEnum.INFO_SOURCE_MAIN_LABEL.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//解绑定向标签 //解绑屏蔽信息源标签
unBindLabel(bindVO, BindTypeEnum.DIRECTIONA_INFO_MAIN_SOURCE_LABEL.getvalue()); unBindLabel(bindVO, BindTypeEnum.EXCLUDE_INFO_MAIN_SOURCE_LABEL.getvalue());
} }
} }
...@@ -239,9 +239,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -239,9 +239,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//绑定通用信息源组 //绑定通用信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.INFO_SOURCE_GROUP.getvalue()); bindInfoSource(bindVO, idList, BindTypeEnum.INFO_SOURCE_GROUP.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//绑定定向信息源组 //绑定屏蔽信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.DIRECTIONA_INFO_SOURCE_GROUP.getvalue()); bindInfoSource(bindVO, idList, BindTypeEnum.EXCLUDE_INFO_SOURCE_GROUP.getvalue());
} }
} }
...@@ -255,9 +255,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -255,9 +255,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//绑定通用信息源组 //绑定通用信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.INFO_SOURCE.getvalue()); bindInfoSource(bindVO, idList, BindTypeEnum.INFO_SOURCE.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//绑定定向信息源组 //绑定屏蔽信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.DIRECTIONA_INFO_SOURCE.getvalue()); bindInfoSource(bindVO, idList, BindTypeEnum.EXCLUDE_INFO_SOURCE.getvalue());
} }
} }
...@@ -269,12 +269,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -269,12 +269,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return; return;
} }
if (sourceBindType == 1) { if (sourceBindType == 1) {
//绑定通用标签信息源 //绑定通用信息源栏目标签
bindLabels(thinkTankId, bindLabels, BindTypeEnum.INFO_SOURCE_LABEL.getvalue()); bindLabels(thinkTankId, bindLabels, BindTypeEnum.INFO_SOURCE_LABEL.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//绑定定向标签信息源 //绑定屏蔽信息源栏目标签
bindLabels(thinkTankId, bindLabels, BindTypeEnum.DIRECTIONA_INFO_SOURCE_LABEL.getvalue()); bindLabels(thinkTankId, bindLabels, BindTypeEnum.EXCLUDE_INFO_SOURCE_LABEL.getvalue());
} }
} }
...@@ -286,12 +286,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -286,12 +286,12 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
return; return;
} }
if (sourceBindType == 1) { if (sourceBindType == 1) {
//绑定通用标签信息源 //绑定通用信息源标签
bindLabels(thinkTankId, bindLabels, BindTypeEnum.INFO_SOURCE_MAIN_LABEL.getvalue()); bindLabels(thinkTankId, bindLabels, BindTypeEnum.INFO_SOURCE_MAIN_LABEL.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//绑定定向标签信息源 //绑定屏蔽信息源标签
bindLabels(thinkTankId, bindLabels, BindTypeEnum.DIRECTIONA_INFO_MAIN_SOURCE_LABEL.getvalue()); bindLabels(thinkTankId, bindLabels, BindTypeEnum.EXCLUDE_INFO_MAIN_SOURCE_LABEL.getvalue());
} }
} }
...@@ -305,9 +305,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -305,9 +305,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//绑定通用信息源组 //绑定通用信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.INFO_MAIN_SOURCE_GROUP.getvalue()); bindInfoSource(bindVO, idList, BindTypeEnum.INFO_MAIN_SOURCE_GROUP.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//绑定定向信息源组 //绑定屏蔽信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE_GROUP.getvalue()); bindInfoSource(bindVO, idList, BindTypeEnum.EXCLUDE_MAIN_INFO_SOURCE_GROUP.getvalue());
} }
} }
...@@ -321,9 +321,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa ...@@ -321,9 +321,9 @@ public class InfoSourceGroupMapServiceImpl extends ServiceImpl<InfoSourceGroupMa
//绑定通用信息源组 //绑定通用信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.INFO_MAIN_SOURCE.getvalue()); bindInfoSource(bindVO, idList, BindTypeEnum.INFO_MAIN_SOURCE.getvalue());
} }
if (sourceBindType == 2) { if (sourceBindType == 3) {
//绑定定向信息源组 //绑定屏蔽信息源组
bindInfoSource(bindVO, idList, BindTypeEnum.DIRECTIONA_MAIN_INFO_SOURCE.getvalue()); bindInfoSource(bindVO, idList, BindTypeEnum.EXCLUDE_MAIN_INFO_SOURCE.getvalue());
} }
} }
......
...@@ -19,7 +19,7 @@ public class BindVO { ...@@ -19,7 +19,7 @@ public class BindVO {
private List<String> bindIds; private List<String> bindIds;
//信息源标签 //信息源标签
private List<BindLabelVo> bindLabels; private List<BindLabelVo> bindLabels;
//绑定类型类型(1:通用 2:定向) //绑定类型类型(1:通用 2:定向 3:屏蔽
private Integer sourceBindType; private Integer sourceBindType;
//信息源类型(1:信息源栏目组 2:信息源栏目 3:信息源栏目标签 4:信息源组 5:信息源 6:信息源标签) //信息源类型(1:信息源栏目组 2:信息源栏目 3:信息源栏目标签 4:信息源组 5:信息源 6:信息源标签)
private Integer sourceType; private Integer sourceType;
......
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
thinktank_info_source_group_map sm thinktank_info_source_group_map sm
INNER JOIN info_source_main im ON im.id = sm.source_id INNER JOIN info_source_main im ON im.id = sm.source_id
WHERE WHERE
sm.type IN ( 31, 36 ) sm.type = 31
AND sm.group_id = #{thinkTankId} UNION AND sm.group_id = #{thinkTankId} UNION
SELECT SELECT
im.id im.id
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
INNER JOIN info_source_main_group_map m ON m.group_id = sm.source_id INNER JOIN info_source_main_group_map m ON m.group_id = sm.source_id
INNER JOIN info_source_main im ON im.id = m.source_id INNER JOIN info_source_main im ON im.id = m.source_id
WHERE WHERE
sm.type IN ( 32, 35 ) sm.type = 32
AND sm.group_id = #{thinkTankId} UNION AND sm.group_id = #{thinkTankId} UNION
SELECT SELECT
im.id im.id
...@@ -252,9 +252,40 @@ ...@@ -252,9 +252,40 @@
AND sm.source_item_id = lam.label_item_code AND sm.source_item_id = lam.label_item_code
INNER JOIN info_source_main im ON lam.entity_code = im.id INNER JOIN info_source_main im ON lam.entity_code = im.id
WHERE WHERE
sm.type IN ( 312, 315 ) sm.type = 312
AND sm.group_id = #{thinkTankId} AND sm.group_id = #{thinkTankId}
) bind ) bind
WHERE
1 = 1
AND bind.id NOT IN (
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN info_source_main_group_map m ON m.group_id = sm.source_id
INNER JOIN info_source_main im ON im.id = m.source_id
WHERE
sm.type = 34
AND sm.group_id = #{thinkTankId} UNION
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN info_source_main im ON im.id = sm.source_id
WHERE
sm.type = 33
AND sm.group_id = #{thinkTankId} UNION
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN clb_label_main_source_map lam ON sm.source_id = lam.label_code
AND sm.source_item_id = lam.label_item_code
INNER JOIN info_source_main im ON lam.entity_code = im.id
WHERE
sm.type = 314
AND sm.group_id = #{thinkTankId}
)
) b ON a.id = b.id ) b ON a.id = b.id
WHERE WHERE
b.id IS NOT NULL b.id IS NOT NULL
...@@ -286,7 +317,7 @@ ...@@ -286,7 +317,7 @@
thinktank_info_source_group_map sm thinktank_info_source_group_map sm
INNER JOIN info_source im ON im.id = sm.source_id INNER JOIN info_source im ON im.id = sm.source_id
WHERE WHERE
sm.type IN ( 1, 6 ) sm.type = 1
AND sm.group_id = #{thinkTankId} UNION AND sm.group_id = #{thinkTankId} UNION
SELECT SELECT
im.id im.id
...@@ -295,7 +326,7 @@ ...@@ -295,7 +326,7 @@
INNER JOIN info_source_group_map m ON m.group_id = sm.source_id INNER JOIN info_source_group_map m ON m.group_id = sm.source_id
INNER JOIN info_source im ON im.id = m.source_id INNER JOIN info_source im ON im.id = m.source_id
WHERE WHERE
sm.type IN ( 2, 5 ) sm.type = 2
AND sm.group_id = #{thinkTankId} UNION AND sm.group_id = #{thinkTankId} UNION
SELECT SELECT
im.id im.id
...@@ -304,9 +335,38 @@ ...@@ -304,9 +335,38 @@
INNER JOIN clb_label_info_source_map lam ON sm.source_id = lam.label_code AND sm.source_item_id = lam.label_item_code INNER JOIN clb_label_info_source_map lam ON sm.source_id = lam.label_code AND sm.source_item_id = lam.label_item_code
INNER JOIN info_source im ON lam.entity_code = im.id INNER JOIN info_source im ON lam.entity_code = im.id
WHERE WHERE
sm.type IN ( 12, 15 ) sm.type = 12
AND sm.group_id = #{thinkTankId} AND sm.group_id = #{thinkTankId}
) bind ) bind
where 1=1
and bind.id not in(
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN info_source im ON im.id = sm.source_id
WHERE
sm.type = 3
AND sm.group_id = #{thinkTankId} UNION
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN info_source_group_map m ON m.group_id = sm.source_id
INNER JOIN info_source im ON im.id = m.source_id
WHERE
sm.type = 4
AND sm.group_id = #{thinkTankId} UNION
SELECT
im.id
FROM
thinktank_info_source_group_map sm
INNER JOIN clb_label_info_source_map lam ON sm.source_id = lam.label_code AND sm.source_item_id = lam.label_item_code
INNER JOIN info_source im ON lam.entity_code = im.id
WHERE
sm.type = 14
AND sm.group_id = #{thinkTankId}
)
) b ON a.id = b.id ) b ON a.id = b.id
WHERE WHERE
b.id IS NOT NULL b.id IS NOT NULL
...@@ -397,10 +457,11 @@ ...@@ -397,10 +457,11 @@
</select> </select>
<select id="bindSourceCount" resultType="com.zzsn.thinktank.vo.BindSourceDetailVO"> <select id="bindSourceCount" resultType="com.zzsn.thinktank.vo.BindSourceDetailVO">
select distinct x.source_id,x.group_id as thinkTankId from ( select a.group_id as thinkTankId,a.source_id from (
select distinct x.source_id,x.group_id from (
select m.source_id,n.group_id from thinktank_info_source_group_map n select m.source_id,n.group_id from thinktank_info_source_group_map n
inner join info_source_group_map m on n.source_id = m.group_id inner join info_source_group_map m on n.source_id = m.group_id
where n.type in(2,5) where n.type = 2
<if test="thinkTankIds != null and thinkTankIds.size() > 0"> <if test="thinkTankIds != null and thinkTankIds.size() > 0">
and n.group_id in and n.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=","> <foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
...@@ -413,7 +474,7 @@ ...@@ -413,7 +474,7 @@
INNER JOIN info_source_main_group_map m ON m.group_id = sim.source_id INNER JOIN info_source_main_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source_main im ON im.id = m.source_id INNER JOIN info_source_main im ON im.id = m.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id INNER JOIN info_source iso ON im.id = iso.info_source_id
where sim.type IN ( 32, 35 ) where sim.type = 32
<if test="thinkTankIds != null and thinkTankIds.size() > 0"> <if test="thinkTankIds != null and thinkTankIds.size() > 0">
and sim.group_id in and sim.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=","> <foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
...@@ -421,7 +482,7 @@ ...@@ -421,7 +482,7 @@
</foreach> </foreach>
</if> </if>
union union
select sm.source_id,sm.group_id from thinktank_info_source_group_map sm where sm.type in(1,6) select sm.source_id,sm.group_id from thinktank_info_source_group_map sm where sm.type = 1
<if test="thinkTankIds != null and thinkTankIds.size() > 0"> <if test="thinkTankIds != null and thinkTankIds.size() > 0">
and sm.group_id in and sm.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=","> <foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
...@@ -434,7 +495,7 @@ ...@@ -434,7 +495,7 @@
INNER JOIN info_source_main im ON im.id = sm.source_id INNER JOIN info_source_main im ON im.id = sm.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE WHERE
sm.type IN ( 31, 36 ) sm.type = 31
<if test="thinkTankIds != null and thinkTankIds.size() > 0"> <if test="thinkTankIds != null and thinkTankIds.size() > 0">
and sm.group_id in and sm.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=","> <foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
...@@ -444,7 +505,7 @@ ...@@ -444,7 +505,7 @@
union union
select m.entity_code as source_id,n.group_id from thinktank_info_source_group_map n select m.entity_code as source_id,n.group_id from thinktank_info_source_group_map n
inner join clb_label_info_source_map m on n.source_id = m.label_code and n.source_item_id = m.label_item_code inner join clb_label_info_source_map m on n.source_id = m.label_code and n.source_item_id = m.label_item_code
where n.type in(12,15) where n.type = 12
<if test="thinkTankIds != null and thinkTankIds.size() > 0"> <if test="thinkTankIds != null and thinkTankIds.size() > 0">
and n.group_id in and n.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=","> <foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
...@@ -460,13 +521,94 @@ ...@@ -460,13 +521,94 @@
INNER JOIN info_source_main im ON lam.entity_code = im.id INNER JOIN info_source_main im ON lam.entity_code = im.id
INNER JOIN info_source isoo ON im.id = isoo.info_source_id INNER JOIN info_source isoo ON im.id = isoo.info_source_id
WHERE WHERE
smm.type IN ( 312, 315 ) smm.type = 312
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and smm.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
) x) a
LEFT JOIN
(select distinct x.source_id,x.group_id from (
select m.source_id,n.group_id from thinktank_info_source_group_map n
inner join info_source_group_map m on n.source_id = m.group_id
where n.type = 4
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and n.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
SELECT
iso.id as source_id,sim.group_id
FROM
thinktank_info_source_group_map sim
INNER JOIN info_source_main_group_map m ON m.group_id = sim.source_id
INNER JOIN info_source_main im ON im.id = m.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sim.type = 34
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and sim.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
select sm.source_id,sm.group_id from thinktank_info_source_group_map sm where sm.type = 3
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and sm.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
SELECT
iso.id as source_id,sm.group_id
FROM
thinktank_info_source_group_map sm
INNER JOIN info_source_main im ON im.id = sm.source_id
INNER JOIN info_source iso ON im.id = iso.info_source_id
WHERE
sm.type = 33
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and sm.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
select m.entity_code as source_id,n.group_id from thinktank_info_source_group_map n
inner join clb_label_info_source_map m on n.source_id = m.label_code and n.source_item_id = m.label_item_code
where n.type = 14
<if test="thinkTankIds != null and thinkTankIds.size() > 0">
and n.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
SELECT
isoo.id as source_id,smm.group_id
FROM
thinktank_info_source_group_map smm
INNER JOIN clb_label_main_source_map lam ON smm.source_id = lam.label_code
AND smm.source_item_id = lam.label_item_code
INNER JOIN info_source_main im ON lam.entity_code = im.id
INNER JOIN info_source isoo ON im.id = isoo.info_source_id
WHERE
smm.type = 314
<if test="thinkTankIds != null and thinkTankIds.size() > 0"> <if test="thinkTankIds != null and thinkTankIds.size() > 0">
and smm.group_id in and smm.group_id in
<foreach collection="thinkTankIds" item="item" open="(" close=")" separator=","> <foreach collection="thinkTankIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if>
) x ) x) b
on (a.group_id = b.group_id and a.source_id = b.source_id)
LEFT JOIN info_source x on(a.source_id = x.id)
where b.source_id is null and x.id is not null
</select> </select>
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论