Commit 8facbf37 authored by tianbo's avatar tianbo

bugfix:

1、管道列表查询优化
parent 4ab2d5e8
......@@ -11,7 +11,6 @@ import com.yeejoin.amos.boot.module.jg.api.dto.EquipmentClassifyDto;
import com.yeejoin.amos.boot.module.jg.api.dto.ReportAnalysisSearchDTO;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
......@@ -233,31 +232,6 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
void updateEnterpriseSafetyStatus(@Param("useUnitCodeList") Set<String> useUnitCodeList);
@Select("WITH RECURSIVE category_tree AS (\n" +
" SELECT \n" +
" tt.id,\n" +
" tt.code,\n" +
" tt.name,\n" +
" ifnull((SELECT code FROM tz_equipment_category WHERE id = tt.parent_id), 0) parent_id,\n" +
" 1 AS level -- 定义当前级别为1\n" +
" FROM \n" +
" tz_equipment_category tt\n" +
" WHERE \n" +
" code = #{parentCode}\n" +
" UNION ALL\n" +
" -- 递归成员:从子节点继续查找\n" +
" SELECT \n" +
" child.id,\n" +
" child.code,\n" +
" child.name,\n" +
" (SELECT code FROM tz_equipment_category WHERE id = child.parent_id) parent_id,\n" +
" parent.level + 1 \n" +
" FROM \n" +
" tz_equipment_category child\n" +
" INNER JOIN \n" +
" category_tree parent ON child.parent_id = parent.id\n" +
")\n" +
"SELECT * FROM category_tree ORDER BY level;")
List<EquipmentClassifyDto> getEquClassifyByCode(String parentCode);
List<EquipmentClassifyDto> getEquClassifyByCode(@Param("parentCode") String parentCode);
}
......@@ -2583,4 +2583,35 @@
</foreach>
</update>
<select id="getEquClassifyByCode" resultType="com.yeejoin.amos.boot.module.jg.api.dto.EquipmentClassifyDto">
WITH RECURSIVE category_tree AS (
SELECT
tt.id,
tt.code,
tt.name,
ifnull((SELECT code FROM tz_equipment_category WHERE id = tt.parent_id), 0) parent_id,
1 AS level
FROM
tz_equipment_category tt
WHERE
<if test="parentCode == null" >
tt.parent_id = 0 and code not in ('7000','F000', '8000')
</if>
<if test="parentCode != null">
tt.code = '8000'
</if>
UNION ALL
SELECT
child.id,
child.code,
child.name,
(SELECT code FROM tz_equipment_category WHERE id = child.parent_id) parent_id,
parent.level + 1
FROM
tz_equipment_category child
INNER JOIN
category_tree parent ON child.parent_id = parent.id
)
SELECT * FROM category_tree ORDER BY level;
</select>
</mapper>
......@@ -692,7 +692,7 @@ public class CommonController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getEquClassifyByCode")
@ApiOperation(httpMethod = "GET", value = "根据父级code查询子设备分类", notes = "根据父级code查询子设备分类")
public ResponseModel<List<EquipmentClassifyDto>> getEquClassifyByCode(@RequestParam(value = "parentCode") String parentCode) {
public ResponseModel<List<EquipmentClassifyDto>> getEquClassifyByCode(@RequestParam(value = "parentCode", required = false) String parentCode) {
return ResponseHelper.buildResponse(commonService.getEquClassifyByCode(parentCode));
}
}
......@@ -2149,9 +2149,13 @@ public List<EquipmentClassifyDto> getEquClassifyByCode(String parentCode) {
}
});
return rootNodes.stream()
.flatMap(root -> root.getChildren().stream())
.collect(Collectors.toList());
if (!ValidationUtil.isEmpty(parentCode)) {
return rootNodes.stream()
.flatMap(root -> root.getChildren().stream())
.collect(Collectors.toList());
}
return rootNodes;
}
......
......@@ -178,7 +178,6 @@
SELECT count(1)
FROM idx_biz_jg_use_info ibjui
LEFT JOIN idx_biz_jg_tech_params_pipeline ibjtpp ON ibjui.RECORD = ibjtpp.RECORD
LEFT JOIN idx_biz_jg_design_info ibjdi ON ibjui.RECORD = ibjdi.RECORD
WHERE ibjui.project_contraption_id = #{sequenceNbr}
ORDER BY ibjtpp.REC_DATE ASC
</select>
......@@ -268,8 +267,6 @@
( SELECT NEXT_INSPECT_DATE FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = ibjui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1 ) nextInspectDate
FROM
idx_biz_jg_use_info ibjui
LEFT JOIN idx_biz_jg_tech_params_pipeline ibjtpp ON ibjui.RECORD = ibjtpp.RECORD
LEFT JOIN idx_biz_jg_design_info ibjdi ON ibjui.RECORD = ibjdi.RECORD
WHERE
ibjui.project_contraption_id = #{sequenceNbr}
) A
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment