<?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.basic.mapper.StructureItemParameterMapper">
|
<sql id="selectStandardTree">
|
sample sample2,
|
inspection_item,
|
inspection_item_en,
|
inspection_item_subclass,
|
inspection_item_subclass_en,
|
inspection_item_class,
|
inspection_item_class_en,
|
method,
|
son_laboratory,
|
unit,
|
ask_tell tell,
|
ask,
|
price,
|
man_hour,
|
man_hour_group,
|
man_day,
|
inspection_item_type,
|
inspection_value_type,
|
bsm,
|
template_id,
|
laboratory,
|
checkout_number,
|
section,
|
dic,
|
0 state,
|
#{trees}
|
tree,
|
id
|
structure_item_parameter_id,
|
radius_list,
|
rates
|
</sql>
|
|
<delete id="removeNoSample">
|
delete
|
from structure_item_parameter
|
where sample like concat('%', #{sample}, '%')
|
</delete>
|
<select id="selectItemParameterList" resultType="com.ruoyi.basic.pojo.StructureItemParameter">
|
WITH temp_sample AS (
|
SELECT
|
*,
|
CASE
|
WHEN INSTR(sample, ',') > 0 THEN
|
SUBSTRING_INDEX(SUBSTRING_INDEX(sample, '","', 1), '"', -1)
|
WHEN sample = '[""]' THEN
|
NULL
|
WHEN sample = '[]' THEN
|
NULL
|
ELSE
|
TRIM(BOTH '["]' FROM SUBSTRING_INDEX(REPLACE(sample, '[["', ''), '"]]', 1))
|
END AS samples
|
FROM
|
structure_item_parameter
|
),
|
temp_join AS (
|
SELECT DISTINCT
|
A.id,
|
inspection_item,
|
inspection_item_en,
|
inspection_item_subclass,
|
inspection_item_subclass_en,
|
laboratory,
|
unit,
|
price,
|
man_hour,
|
man_hour_group,
|
inspection_item_type,
|
checkout_number,
|
section,
|
A.create_user,
|
A.update_user,
|
A.create_time,
|
A.update_time,
|
method,
|
man_day,
|
bsm,
|
sample,
|
inspection_value_type,
|
dic,
|
template_id,
|
son_laboratory,
|
ask,
|
ask_tell,
|
inspection_item_class,
|
inspection_item_class_en,
|
code,
|
radius_list,
|
rates,
|
delegate_request_flag,frequency,rates_group
|
FROM
|
temp_sample A
|
LEFT JOIN
|
structure_test_object sto ON A.samples = sto.specimen_name
|
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
|
${ew.customSqlSegment}
|
</if>
|
)
|
SELECT
|
*
|
FROM
|
temp_join
|
ORDER BY
|
-- 处理 code 字段的排序
|
CASE
|
WHEN code IS NULL THEN 1
|
ELSE 0
|
END,
|
CAST(code AS UNSIGNED),
|
-- 处理 man_hour_group 字段的排序
|
CASE
|
WHEN man_hour_group IS NULL OR man_hour_group = '' THEN 1
|
ELSE 0
|
END,
|
CASE
|
WHEN man_hour_group REGEXP '^[0-9]' THEN
|
CAST(man_hour_group AS UNSIGNED)
|
WHEN man_hour_group REGEXP '[0-9]+' THEN
|
CAST(SUBSTRING(man_hour_group, 2) AS UNSIGNED)
|
ELSE
|
NULL
|
END,
|
id ASC
|
</select>
|
|
<resultMap id="getInsProductions" type="map">
|
<result property="name" column="sample"/>
|
<collection property="children" resultMap="itemClass" javaType="List"/>
|
</resultMap>
|
<resultMap id="itemClass" type="map">
|
<result property="name" column="item_class"/>
|
<collection property="children" resultMap="item" javaType="List"/>
|
</resultMap>
|
<resultMap id="item" type="map">
|
<result property="name" column="inspection_item"/>
|
<collection property="children" resultMap="itemSubClass" javaType="List"/>
|
</resultMap>
|
<resultMap id="itemSubClass" type="map">
|
<id property="id" column="id"/>
|
<result property="name" column="subclass"/>
|
</resultMap>
|
<select id="getInsProduction" resultMap="getInsProductions">
|
SELECT DISTINCT
|
id,
|
CASE
|
WHEN INSTR(sample, ',') > 0 THEN
|
TRIM(BOTH '"' FROM SUBSTRING_INDEX(SUBSTRING_INDEX(sample, '","', - 1), '"]]', 1))
|
WHEN sample = '[""]' THEN
|
'*'
|
ELSE
|
TRIM(BOTH '["]' FROM SUBSTRING_INDEX(REPLACE(sample, '[["', ''), '"]]', 1))
|
END AS sample,
|
inspection_item,
|
CASE
|
WHEN inspection_item_subclass IS NULL
|
OR TRIM(inspection_item_subclass) = '' THEN
|
inspection_item
|
ELSE
|
inspection_item_subclass
|
END AS subclass,
|
CASE
|
WHEN inspection_item_class IS NULL
|
OR TRIM(inspection_item_class) = '' THEN
|
inspection_item
|
ELSE
|
inspection_item_class
|
END AS item_class
|
FROM
|
structure_item_parameter;
|
</select>
|
<select id="getItemTree" resultMap="itemDto">
|
SELECT
|
sto.id AS sId,
|
sto.specimen_name AS labelName,
|
CONCAT(sto.specimen_name, ' (', sto.object_type, ')') AS sName,
|
p.id AS pId,
|
p.name AS pName,
|
sto.object_type
|
FROM
|
structure_test_object sto
|
LEFT JOIN
|
product p
|
ON p.object_id = sto.id;
|
</select>
|
|
<resultMap id="itemDto" type="com.ruoyi.basic.dto.TestItemDto">
|
<result column="sId" property="id"/>
|
<result column="sName" property="name"/>
|
<result column="labelName" property="labelName"/>
|
<collection property="children" resultMap="productDto"/>
|
</resultMap>
|
<resultMap id="productDto" type="com.ruoyi.basic.dto.ProductDto">
|
<result column="pId" property="id"/>
|
<result column="pName" property="name"/>
|
<result column="labelName" property="labelName"/>
|
</resultMap>
|
|
<resultMap id="itemDto1" type="com.ruoyi.basic.dto.TestItemDto">
|
<result column="sId" property="id"/>
|
<result column="sName" property="name"/>
|
<collection property="children" resultMap="productDto1"/>
|
</resultMap>
|
<resultMap id="productDto1" type="com.ruoyi.basic.dto.ProductDto">
|
<result column="pId" property="id"/>
|
<result column="pName" property="name"/>
|
</resultMap>
|
|
<select id="selectItemParameterBySample" resultType="com.ruoyi.basic.pojo.StructureItemParameter">
|
select *
|
from structure_item_parameter
|
where (
|
sample is NULL
|
OR sample = ''
|
or sample = '[]'
|
OR sample LIKE CONCAT('%', #{structureItemParameterDto.tree}, '%')
|
)
|
<if test="structureItemParameterDto.delegateRequestFlag != null and structureItemParameterDto.delegateRequestFlag !='' ">
|
AND delegate_request_flag = #{structureItemParameterDto.delegateRequestFlag}
|
</if>
|
|
order by id asc
|
</select>
|
|
<select id="getItemTreeProduct" resultMap="itemDto1">
|
select sto.id sId, sto.specimen_name sName, p.name labelName, p.id pId, p.name pName
|
from structure_test_object sto
|
left join product p on p.object_id = sto.id
|
WHERE sto.object_type = #{objectType}
|
</select>
|
</mapper>
|