From 0c7662223279a3d18197c47180bbd132d6020906 Mon Sep 17 00:00:00 2001 From: chenrui <1187576398@qq.com> Date: 星期二, 08 四月 2025 13:36:10 +0800 Subject: [PATCH] 标准库添加委托要求功能 --- basic-server/src/main/resources/mapper/StructureItemParameterMapper.xml | 130 +++++++++++++++++++++++++++++------------- 1 files changed, 89 insertions(+), 41 deletions(-) diff --git a/basic-server/src/main/resources/mapper/StructureItemParameterMapper.xml b/basic-server/src/main/resources/mapper/StructureItemParameterMapper.xml index c8c4ea8..069bacb 100644 --- a/basic-server/src/main/resources/mapper/StructureItemParameterMapper.xml +++ b/basic-server/src/main/resources/mapper/StructureItemParameterMapper.xml @@ -43,7 +43,25 @@ where sample like concat('%', #{sample}, '%') </delete> <select id="selectItemParameterList" resultType="com.ruoyi.basic.pojo.StructureItemParameter"> - select * from (select A.id, + 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, @@ -74,32 +92,41 @@ inspection_item_class_en, code, radius_list, - rates - from (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) A - left join structure_test_object sto on samples = specimen_name + rates, + delegate_request_flag + 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>)B - order by CASE + </if> + ) + SELECT + * + FROM + temp_join + ORDER BY + -- 澶勭悊 code 瀛楁鐨勬帓搴� + CASE WHEN code IS NULL THEN 1 ELSE 0 END, CAST(code AS UNSIGNED), - case when man_hour_group is NULL then 1 - when man_hour_group ='' then 1 else 0 end, + -- 澶勭悊 man_hour_group 瀛楁鐨勬帓搴� 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) END -- 鎻愬彇瀛楁瘝鍚庨潰鐨勬暟瀛楅儴鍒� - ,id asc + 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"> @@ -119,28 +146,46 @@ <result property="name" column="subclass"/> </resultMap> <select id="getInsProduction" resultMap="getInsProductions"> - select distinct id, - CASE - WHEN INSTR(sample, ',') > 0 THEN - 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 inspection_item_subclass = '' then inspection_item - else inspection_item_subclass end as subclass, - case - when inspection_item_class is null or inspection_item_class = '' then inspection_item - else inspection_item_class end as item_class - from structure_item_parameter + 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 sId, sto.specimen_name sName, p.id pId, p.name pName - from structure_test_object sto - left join product p on p.object_id = sto.id + SELECT + sto.id AS sId, + 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"> @@ -160,8 +205,11 @@ sample is NULL OR sample = '' or sample = '[]' - OR sample LIKE CONCAT('%', #{sample}, '%') + OR sample LIKE CONCAT('%', #{structureItemParameterDto.tree}, '%') ) + <if test="structureItemParameterDto.delegateRequestFlag != null and structureItemParameterDto.delegateRequestFlag !='' and structureItemParameterDto.delegateRequestFlag == '1' "> + AND delegate_request_flag = #{structureItemParameterDto.delegateRequestFlag} + </if> order by id asc </select> -- Gitblit v1.9.3