|
@@ -56,7 +56,11 @@
|
|
|
creation_time,modifier,modified_time,
|
|
|
valid,ts
|
|
|
</sql>
|
|
|
- <insert id="insertObjectRelationByRelChain" parameterType="com.persagy.dmp.rwd.digital.domain.CalculatingDTO">
|
|
|
+ <sql id="insertObjectRelationCondition">
|
|
|
+
|
|
|
+
|
|
|
+ </sql>
|
|
|
+ <insert id="insertObjectRelationByRelChain">
|
|
|
INSERT INTO dt_relation (
|
|
|
id,
|
|
|
group_code,
|
|
@@ -94,7 +98,7 @@
|
|
|
1
|
|
|
FROM
|
|
|
(
|
|
|
- <if test="null!=chain and chain.size()>0">
|
|
|
+ <if test="null!=param.chain and param.chain.size()>0">
|
|
|
SELECT
|
|
|
dtr0.obj_from AS obj_from,
|
|
|
dtr${chain.size()-1}.obj_to AS obj_to,
|
|
@@ -102,16 +106,81 @@
|
|
|
dtr0.project_id AS project_id
|
|
|
FROM
|
|
|
(
|
|
|
- <foreach collection="chain" item="rule" index="index">
|
|
|
+ <foreach collection="param.chain" item="rule" index="index">
|
|
|
<choose>
|
|
|
<when test="index==0">
|
|
|
- ( SELECT * FROM dt_relation WHERE graph_code = 'ArchSubset' AND rel_code = 'Bd2Fl' AND valid = TRUE ) AS dtr${index}
|
|
|
+ ( SELECT obj_to, obj_from,group_code,project_id FROM dt_relation WHERE 1=1
|
|
|
+ <if test="null!=rule.graphCode and rule.graphCode.length>0">
|
|
|
+ AND graph_code = #{rule.graphCode}
|
|
|
+ </if>
|
|
|
+ <if test="null!=rule.relCode and rule.relCode.length>0">
|
|
|
+ AND rel_code = #{rule.relCode}
|
|
|
+ </if>
|
|
|
+ <if test="null!=rule.relValue and rule.relValue.length>0">
|
|
|
+ AND rel_value = #{rule.relValue}
|
|
|
+ </if>
|
|
|
+ <if test="null!=param.groupCode and param.groupCode.length>0">
|
|
|
+ AND group_code = #{param.groupCode}
|
|
|
+ </if>
|
|
|
+ <if test="null!=param.projectId and param.projectId.length>0">
|
|
|
+ AND project_id = #{param.projectId}
|
|
|
+ </if>
|
|
|
+ <if test="null!=param.fromIds and param.fromIds.size()>0">
|
|
|
+ <foreach collection="param.fromIds" item="fromId" separator="," open="AND obj_from IN(" close=")">
|
|
|
+ #{fromId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ AND valid = TRUE
|
|
|
+ ) AS dtr${index}
|
|
|
</when>
|
|
|
<when test="index==chain.size()-1">
|
|
|
- INNER JOIN dt_relation AS dtr${index} ON ( dtr${index-1}).obj_to = dtr${index}.obj_from AND dtr${index}.graph_code = 'ArchSubset' AND dtr${index}.rel_code = 'Fl2Sp' )
|
|
|
+ INNER JOIN (SELECT if(#{rule.currentRelDirection},obj_to,obj_from) AS obj_to,if(true,obj_from,obj_to) AS obj_from FROM dt_relation WHERE
|
|
|
+ (
|
|
|
+ 1=1
|
|
|
+ <if test="null!=rule.graphCode and rule.graphCode.length>0">
|
|
|
+ AND graph_code = #{rule.graphCode}
|
|
|
+ </if>
|
|
|
+ <if test="null!=rule.relCode and rule.relCode.length>0">
|
|
|
+ AND rel_code = #{rule.relCode}
|
|
|
+ </if>
|
|
|
+ <if test="null!=rule.relValue and rule.relValue.length>0">
|
|
|
+ AND rel_value = #{rule.relValue}
|
|
|
+ </if>
|
|
|
+ <if test="null!=param.groupCode and param.groupCode.length>0">
|
|
|
+ AND group_code = #{param.groupCode}
|
|
|
+ </if>
|
|
|
+ <if test="null!=param.projectId and param.projectId.length>0">
|
|
|
+ AND project_id = #{param.projectId}
|
|
|
+ </if>
|
|
|
+ AND valid=TRUE
|
|
|
+ <if test="null!=param.toIds and param.toIds.size()>0">
|
|
|
+ if(#{rule.currentRelDirection},obj_to,obj_from) IN(
|
|
|
+ <foreach collection="param.toIds" item="toId" separator=",">
|
|
|
+ #{toId}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ )) AS dtr${index} ON (if(#{rule.preRelDirection},dtr${index-1}.obj_to,dtr${index-1}.obj_from) = dtr${index}.obj_from)
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
- INNER JOIN dt_relation AS CONCAT('dtr',#{index}) ON ( CONCAT('dtr',#{index}).obj_to = CONCAT('dtr',#{index}).obj_from AND dtr${index}.graph_code = 'ArchSubset' AND dtr${index}.rel_code = 'Fl2Sp' )
|
|
|
+ INNER JOIN dt_relation AS dtr${index} ON (
|
|
|
+ if(#{rule.preRelDirection},dtr${index-1}.obj_to,dtr${index-1}.obj_from) = if(#{rule.currentRelDirection},dtr${index}.obj_from,dtr${index}.obj_to)
|
|
|
+ <if test="null!=rule.graphCode and rule.graphCode.length>0">
|
|
|
+ AND dtr${index}.graph_code = #{rule.graphCode}
|
|
|
+ </if>
|
|
|
+ <if test="null!=rule.relCode and rule.relCode.length>0">
|
|
|
+ AND dtr${index}.rel_code = #{rule.relCode}
|
|
|
+ </if>
|
|
|
+ <if test="null!=rule.relValue and rule.relValue.length>0">
|
|
|
+ AND dtr${index}.rel_value = #{rule.relValue}
|
|
|
+ </if>
|
|
|
+ <if test="null!=param.groupCode and param.groupCode.length>0">
|
|
|
+ AND dtr${index}.group_code = #{param.groupCode}
|
|
|
+ </if>
|
|
|
+ <if test="null!=param.projectId and param.projectId.length>0">
|
|
|
+ AND dtr${index}.project_id = #{param.projectId}
|
|
|
+ </if>
|
|
|
+ AND dtr${index}.valid=TRUE)
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
</foreach>
|