Browse Source

优化预警规则列表

minghao-chen 2 years ago
parent
commit
a972b4ee71
1 changed files with 36 additions and 21 deletions
  1. 36 21
      beidou-ship/src/main/resources/mapper/ShipWarningModelMapper.xml

+ 36 - 21
beidou-ship/src/main/resources/mapper/ShipWarningModelMapper.xml

@@ -39,31 +39,46 @@
         ORDER BY rule.create_time DESC
     </select>
 
-    <select id="modelList" parameterType="string" resultMap="ruleModelResult">
-        select model.id as id,rm.rule_id as rule_id,model.`name` as model_name,model.code,model.description,model.del_flag
-		from ax_beidou_warning_rule_model rm
-        inner join ax_beidou_warning_model model on model.id = rm.model_id
-        where model.del_flag='0' and rm.rule_id = #{id}
-    </select>
+    <resultMap id="ruleModelResult1" type="warningModelResult">
+        <id property="id" column="id"/>
+        <result property="modelName" column="model_name"/>
+        <result property="code" column="code"/>
+        <result property="description" column="description"/>
+        <collection property="paramList" ofType="warningParamVo"
+                    column="{modelId=id,ruleId=rule_id}">
+            <id property="id" column="param_id"/>
+            <result property="paramProperty" column="param_property"/>
+            <result property="paramName" column="param_name"/>
+            <result property="paramValue" column="param_value"/>
+            <result property="isMust" column="is_must"/>
+            <result property="dictId" column="dict_id"/>
+            <result property="recommend" column="recommend"/>
+        </collection>
 
-    <select id="ruleParamList" resultMap="paramVo">
-        select param.id as param_id,rp.param_value,param.recommend,
-                param.is_must,param.del_flag as param_del_flag,
-                dict.param_code as param_property,dict.param_name,dict.id as dict_id
-        from ax_beidou_warning_model_param mp
-        inner join ax_beidou_warning_rule_model_param rp on mp.param_id = rp.param_id
-        left join ax_beidou_warning_param param on param.id = mp.param_id
+        <collection property="areaList" ofType="warningAreaVo"
+                    column="{modelId=id,ruleId=rule_id}">
+            <id property="id" column="area_id"/>
+            <result property="name" column="area_name"/>
+            <result property="location" column="location"/>
+        </collection>
+    </resultMap>
+
+    <select id="modelList" resultMap="ruleModelResult1">
+        select model.id as id,rm.rule_id as rule_id,model.`name` as model_name,model.code,model.description,model.del_flag,
+                param.id as param_id,rp.param_value,param.recommend,param.is_must,param.del_flag as param_del_flag,
+                dict.param_code as param_property,dict.param_name,dict.id as dict_id,
+                area.id as area_id,area.`name` as area_name,area.location
+        from ax_beidou_warning_rule_model rm
+        inner join ax_beidou_warning_model model on model.id = rm.model_id and model.del_flag = '0'
+        left JOIN ax_beidou_warning_model_param mp on mp.model_id = model.id
+        left join ax_beidou_warning_rule_model_param rp on mp.param_id = rp.param_id and rp.model_id = rm.model_id and rp.rule_id = rm.rule_id
+        left join ax_beidou_warning_param param on param.id = mp.param_id and param.del_flag = '0'
         left join ax_beidou_warning_param_dict dict on param.dict_id = dict.id
-        where param.del_flag = '0' and mp.model_id = #{modelId} and rp.rule_id = #{ruleId}
+        left JOIN ax_beidou_warning_rule_model_area ma on ma.model_id = model.id and ma.rule_id = rm.rule_id
+        left join ax_beidou_warning_area area on area.id = ma.area_id and area.del_flag = '0'
+        where model.del_flag='0' and rm.rule_id = #{id}
     </select>
 
-    <select id="ruleAreaList"  resultMap="areaVo">
-        select area.id as area_id,area.`name` as area_name,area.location,
-        area.del_flag as area_del_flag
-        from ax_beidou_warning_rule_model_area ma
-        left join ax_beidou_warning_area area on area.id = ma.area_id
-        where  area.del_flag = '0' and ma.model_id = #{modelId} and ma.rule_id = #{ruleId}
-    </select>
     <!--预警规则列表 end-->