<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.ruoyi.inspect.mapper.ReliabilityPlanProductItemMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.inspect.pojo.ReliabilityPlanProductItem">
|
<id column="id" property="id" />
|
<result column="inspection_item" property="inspectionItem" />
|
<result column="standard" property="standard" />
|
<result column="frequency" property="frequency" />
|
<result column="remark" property="remark" />
|
<result column="plan_id" property="planId" />
|
</resultMap>
|
<select id="itemList" resultType="java.util.Map">
|
WITH flattened_samples AS (
|
SELECT
|
sp.id,
|
JSON_ARRAYAGG(VALUE) AS flattened_sample
|
FROM
|
structure_item_parameter sp
|
JOIN JSON_TABLE (sp.sample, '$[*][*]' COLUMNS (VALUE VARCHAR (255) PATH '$')) AS inner_arr
|
GROUP BY
|
sp.id
|
) SELECT
|
sp.inspection_item AS inspectionItem,
|
sm.`code`,
|
sm.id
|
FROM
|
flattened_samples fs
|
JOIN structure_item_parameter sp ON fs.id = sp.id
|
JOIN reliability_plan_product rp ON JSON_OVERLAPS (fs.flattened_sample, JSON_ARRAY(rp.product_name))
|
LEFT JOIN standard_product_list spl ON spl.structure_item_parameter_id = sp.id
|
AND spl.model = rp.product_type
|
LEFT JOIN standard_method sm ON sm.id = spl.standard_method_list_id
|
WHERE rp.id = #{planId}
|
</select>
|
<select id="codeList" resultType="java.util.Map">
|
WITH flattened_samples AS (
|
SELECT
|
sp.id,
|
JSON_ARRAYAGG(VALUE) AS flattened_sample
|
FROM
|
structure_item_parameter sp
|
JOIN JSON_TABLE (sp.sample, '$[*][*]' COLUMNS (VALUE VARCHAR (255) PATH '$')) AS inner_arr
|
GROUP BY
|
sp.id
|
) SELECT DISTINCT
|
sm.`code`as standard,
|
sm.id
|
FROM
|
flattened_samples fs
|
JOIN structure_item_parameter sp ON fs.id = sp.id
|
JOIN reliability_plan_product rp ON JSON_OVERLAPS (fs.flattened_sample, JSON_ARRAY(rp.product_name))
|
LEFT JOIN standard_product_list spl ON spl.structure_item_parameter_id = sp.id
|
AND spl.model = rp.product_type
|
LEFT JOIN standard_method sm ON sm.id = spl.standard_method_list_id
|
WHERE rp.id = #{planId}
|
</select>
|
|
</mapper>
|