guoyujie
2025-07-08 7104751e2f26872d4891d01d42ee88cf19715d01
north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml
@@ -62,13 +62,14 @@
        c.product_name,
        b.project,
        sum(a.quantity) as quantity,
        sum(c.compute_gross_area) as compute_gross_area,
        sum(a.quantity) * c.area as compute_gross_area,
        a.founder,
        c.processing_note,
        b.customer_name,
        if(a.layout_status=0,'不可排版',if(a.layout_status=1,'可排版','已排版')) as layout_status,
        layout_status as layout_status,
        a.merge,
        a.rack
        a.rack,
        b.batch
        from (select id,order_id,process_id,order_number, quantity,founder,max(layout_status) as layout_status,create_time,max(merge) as merge,rack from flow_card
        group by process_Id,order_number) as a
        left join sd.`order` as b on a.order_Id=b.order_id
@@ -207,26 +208,36 @@
    <!--    分架明细查询-->
    <select id="detailsSelectMp">
        select od.order_id,
               ogd.production_id,
               od.product_id,
               od.product_name,
               ROUND(SUM(od.quantity)-IFNULL(sum(fc.quantity)/count(fc.technology_number),0))            as quantity,
               SUM(od.compute_gross_area)  as compute_gross_area,
               round(sum(od.perimeter), 2) as perimeter
        from sd.order_detail as od
                 left join
             (select order_id, order_number,technology_number, production_id, splitting_status
              from sd.order_glass_detail
              GROUP BY order_id, order_number) as ogd
             on od.order_id = ogd.order_id and od.order_number = ogd.order_number
                 left join flow_card as fc on fc.order_id = od.order_id and fc.order_number = od.order_number
            and fc.technology_number=ogd.technology_number
        where od.order_id = #{orderId}
          and ogd.splitting_status = 0
        SELECT
            od.order_id,
            ogd.production_id,
            od.product_id,
            od.product_name,
            ROUND(SUM(od.quantity) - IFNULL(SUM(fc.quantity), 0)) AS quantity,
            SUM(od.compute_gross_area) AS compute_gross_area,
            ROUND(SUM(od.perimeter), 2) AS perimeter
        FROM sd.order_detail AS od
                 LEFT JOIN (
            SELECT order_id, order_number, production_id, splitting_status,
                   technology_number
            FROM sd.order_glass_detail
            GROUP BY order_id, order_number, production_id, splitting_status
        ) AS ogd
                           ON od.order_id = ogd.order_id
                               AND od.order_number = ogd.order_number
                 LEFT JOIN (
            SELECT order_id, order_number, technology_number, SUM(quantity) AS quantity, layers_number
            FROM flow_card
            GROUP BY order_id, order_number, technology_number
        ) AS fc
                           ON fc.order_id = od.order_id
                               AND fc.order_number = od.order_number
                               AND fc.technology_number = ogd.technology_number
        WHERE od.order_id = #{orderId}
          AND ogd.splitting_status = 0
        GROUP BY od.order_id, ogd.production_id, od.product_id, od.product_name
        ORDER BY od.order_id DESC;
        group by od.order_id, ogd.production_id
        order by od.id desc
    </select>
    <!--    更新分架状态-->
@@ -272,7 +283,7 @@
               od.quantity,
               od.compute_gross_area,
               p.total_thickness,
               ROUND(od.quantity-IFNULL(sum(fc.quantity)/count(fc.technology_number),0))           as baiscQuantity,
               ROUND(od.quantity-IFNULL(sum(fc.quantity)/fc.layers_number,0))           as baiscQuantity,
               od.compute_gross_area as 'computeGrossArea',
               p.total_thickness     AS 'totalThickness',
               ifnull(p.thickness,'') as thickness,
@@ -289,7 +300,7 @@
        from sd.order_detail as od
                 left join sd.order_glass_detail as ogd
                           on od.order_id = ogd.order_id and od.order_number = ogd.order_number
                 left join sd.product as p on od.product_name = p.product_name
                 left join sd.product as p on od.product_id = p.id
                 left join (SELECT order_id,
                                   order_number,
                                   JSON_UNQUOTE(JSON_EXTRACT(other_columns, '$.S01')) AS S01,
@@ -520,7 +531,7 @@
    </select>
    <select id="selectPrintFlowCard">
        select op.project_no,glass_total,glass_total_area,labelPrintNum,processPrintNum
        select op.project_no,glass_total,glass_total_area,labelPrintNum,processPrintNum,glass_type,glass_thickness
        from pp.optimize_project as op
                 left join pp.flow_card as fc on op.project_no=fc.project_no
                 left join sd.`order` as o on o.order_id=fc.order_id
@@ -603,10 +614,11 @@
                                          GROUP_CONCAT(ogds.technology_number SEPARATOR '') AS technology_number,
                                          ogds.glass_child,
                                          GROUP_CONCAT(ogds.glass_child SEPARATOR '+')      AS concatenated_glass_child,
                                          SUBSTRING(process, LOCATE('夹胶', process))       AS processed_part
                                          SUBSTRING(process, LOCATE(bd.basic_name, process))       AS processed_part
                                   from sd.order_glass_detail as ogds
                                   left join sd.basic_data as bd on bd.nickname='stepC'
                                   where ogds.order_id = #{orderId}
                                     and LOCATE('夹胶', ogds.process) > 0
                                     and LOCATE(bd.basic_name, ogds.process) > 0
                                   GROUP BY order_id, order_number, ogds.group) as ogdss
                                  on fc.order_id = ogdss.order_id and ogdss.order_number = fc.order_number
               where fc.order_id = #{orderId}
@@ -641,13 +653,14 @@
                                          GROUP_CONCAT(pds.glass_sort SEPARATOR '')           AS technology_number,
                                          ogds.glass_child,
                                          GROUP_CONCAT(ogds.glass_child SEPARATOR '+')        AS concatenated_glass_child,
                                          SUBSTRING(ogds.process, LOCATE('中空', ogds.process)) AS processed_part
                                          SUBSTRING(ogds.process, LOCATE(bd.basic_name, ogds.process)) AS processed_part
                                   from sd.order_glass_detail as ogds
                                            left join sd.order_detail as ods
                                                      on ods.order_id = ogds.order_id and ods.order_number = ogds.order_number
                                            left join sd.product_detail as pds on pds.prod_id = ods.product_id and
                                                                                  pds.glass_sort =
                                                                                  ogds.technology_number
                                            left join sd.basic_data as bd on bd.nickname='stepD'
                                   where ogds.order_id = #{orderId}
                                   GROUP BY order_id, order_number) as ogdss
                                  on fc.order_id = ogdss.order_id and ogdss.order_number = fc.order_number
@@ -770,7 +783,28 @@
        where fc.process_id = #{processId}
          and position(fc.technology_number in #{technologyNumber})
        group by fc.process_id, fc.order_number
        order by IF(fcs.sort != NULL or fcs.sort != '', fcs.sort, fc.order_number)
        <choose>
            <!-- landingSequence != 1 时,优先按 landing_sequence 倒序 -->
            <when test="landingSequence != 1">
                ORDER BY landing_sequence DESC
            </when>
            <!-- flashback = 1 时正序 -->
            <when test="flashback == 1">
                ORDER BY
                CASE
                WHEN fcs.sort IS NOT NULL AND fcs.sort &lt;&gt;  '' THEN fcs.sort
                ELSE fc.order_number
                END ASC
            </when>
            <!-- flashback != 1 时倒序 -->
            <otherwise>
                ORDER BY
                CASE
                WHEN fcs.sort IS NOT NULL AND fcs.sort &lt;&gt;  '' THEN fcs.sort
                ELSE fc.order_number
                END DESC
            </otherwise>
        </choose>
    </select>
    <select id="getDetailLists">
@@ -842,19 +876,20 @@
               o.project,
               od.building_number,
               od.processing_note,
               ogd.child_width         as width,
               ogd.child_height        as height,
               opd.o_width         as width,
               opd.o_height        as height,
               ogd.glass_child,
               ogd.process,
               e.type_name,
               opd.stock_id,
               opd.polys_id,
               od.quantity,
               IFNULL(od.quantity,1) as quantity,
               od.other_columns,
               od.bend_radius,
               od.order_number as heat_layout_id,
               a.id as heat_layout_sort,
               od.product_name
               ifnull(od.order_number,0) as heat_layout_id,
               ifnull(a.id,0) as heat_layout_sort,
               od.product_name,
               opd.process_id
        from pp.optimize_detail opd
                 left join sd.`order` o on SUBSTR(opd.process_id, 1, 10) = o.order_id
                 left join sd.order_detail od
@@ -890,7 +925,8 @@
               od.bend_radius,
               opd.heat_layout_id,
               opd.heat_layout_sort,
               od.product_name
               od.product_name,
               opd.process_id
        from pp.optimize_detail opd
                 left join sd.`order` o on SUBSTR(opd.process_id, 1, 10) = o.order_id
                 left join sd.order_detail od
@@ -901,7 +937,7 @@
                 left join sd.product p on od.product_id = p.id
                 left join sd.basic_glass_type e on e.type_id = p.type_id
                 left join sd.customer c on c.id = o.customer_id
        where opd.project_no = #{projectNo}
        where opd.project_no = #{projectNo} and o.order_id is not null
        order by opd.heat_layout_id, opd.heat_layout_sort desc
    </select>
@@ -1440,7 +1476,28 @@
        where fc.process_id = #{processId}
          and position(fc.technology_number in #{technologyNumber})
        group by fc.process_id, fc.order_number, fc.technology_number
        order by IF(fcs.sort != NULL or fcs.sort != '', fcs.sort, fc.order_number)
        <choose>
            <!-- landingSequence != 1 时,优先按 landing_sequence 倒序 -->
            <when test="landingSequence != 1">
                ORDER BY landing_sequence DESC
            </when>
            <!-- flashback = 1 时正序 -->
            <when test="flashback == 1">
                ORDER BY
                CASE
                WHEN fcs.sort IS NOT NULL AND fcs.sort &lt;&gt;  '' THEN fcs.sort
                ELSE fc.order_number
                END ASC
            </when>
            <!-- flashback != 1 时倒序 -->
            <otherwise>
                ORDER BY
                CASE
                WHEN fcs.sort IS NOT NULL AND fcs.sort &lt;&gt;  '' THEN fcs.sort
                ELSE fc.order_number
                END DESC
            </otherwise>
        </choose>
    </select>
    <select id="getDetailListMerge">
@@ -1472,7 +1529,28 @@
                               and fcs.process = #{process}
        where fc.process_id = #{processId} and fc.`merge`=1
        group by fc.process_id, fc.order_number
        order by IF(fcs.sort != NULL or fcs.sort != '', fcs.sort, fc.order_number)
        <choose>
            <!-- landingSequence != 1 时,优先按 landing_sequence 倒序 -->
            <when test="landingSequence != 1">
                ORDER BY landing_sequence DESC
            </when>
            <!-- flashback = 1 时正序 -->
            <when test="flashback == 1">
                ORDER BY
                CASE
                WHEN fcs.sort IS NOT NULL AND fcs.sort &lt;&gt;  '' THEN fcs.sort
                ELSE fc.order_number
                END ASC
            </when>
            <!-- flashback != 1 时倒序 -->
            <otherwise>
                ORDER BY
                CASE
                WHEN fcs.sort IS NOT NULL AND fcs.sort &lt;&gt;  '' THEN fcs.sort
                ELSE fc.order_number
                END DESC
            </otherwise>
        </choose>
    </select>
    <select id="getDetailListLikes">
@@ -2181,10 +2259,11 @@
                                          GROUP_CONCAT(ogds.technology_number SEPARATOR '') AS technology_number,
                                          ogds.glass_child,
                                          GROUP_CONCAT(ogds.glass_child SEPARATOR '+')      AS concatenated_glass_child,
                                          SUBSTRING(process, LOCATE('夹胶', process))       AS processed_part
                                          SUBSTRING(process, LOCATE(bd.basic_name, process))       AS processed_part
                                   from sd.order_glass_detail as ogds
                                  left join sd.basic_data as bd on bd.nickname='stepC'
                                   where ogds.order_id = #{orderId}
                                     and LOCATE('夹胶', ogds.process) > 0
                                     and LOCATE(bd.basic_name, ogds.process) > 0
                                   GROUP BY order_id, order_number, ogds.group) as ogdss
                                  on fc.order_id = ogdss.order_id and ogdss.order_number = fc.order_number
               where fc.order_id = #{orderId}
@@ -2220,13 +2299,14 @@
                                          GROUP_CONCAT(pds.glass_sort SEPARATOR '')           AS technology_number,
                                          ogds.glass_child,
                                          GROUP_CONCAT(ogds.glass_child SEPARATOR '+')        AS concatenated_glass_child,
                                          SUBSTRING(pds.process, LOCATE('中空', pds.process)) AS processed_part
                                          SUBSTRING(pds.process, LOCATE(bd.basic_name, pds.process)) AS processed_part
                                   from sd.order_glass_detail as ogds
                                            left join sd.order_detail as ods
                                                      on ods.order_id = ogds.order_id and ods.order_number = ogds.order_number
                                            left join sd.product_detail as pds on pds.prod_id = ods.product_id and
                                                                                  pds.glass_sort =
                                                                                  ogds.technology_number
                                            left join sd.basic_data as bd on bd.nickname='stepD'
                                   where ogds.order_id = #{orderId}
                                   GROUP BY order_id, order_number) as ogdss
                                  on fc.order_id = ogdss.order_id and ogdss.order_number = fc.order_number
@@ -2354,7 +2434,13 @@
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01'))                  AS glassNumber,
               od.order_number,
               ogd.child_width as width,
               ogd.child_height as height
               ogd.child_height as height,
                ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber,
                JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS S01,
                JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S02')) AS S02,
                JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S03')) AS S03,
                JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S04')) AS S04,
                JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S05')) AS S05
        from flow_card as fc
                 left join sd.order_glass_detail as ogd
                           on ogd.order_id = fc.order_id and ogd.order_number = fc.order_number and
@@ -2394,11 +2480,16 @@
                   ' = ',#{printQuantity} )      as size,
               CONCAT(
                   od.order_number,')  ',
                   od.order_number,')      ',
                       TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM CAST(width AS CHAR))),
                       ' X ',
                       TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM CAST(height AS CHAR))),
                       ' = ',#{printQuantity} )      as numberSize,
               CONCAT(
                       od.order_number,')','   ',
                       TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM CAST(width AS CHAR))),
                       ' X ',
                       TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM CAST(height AS CHAR))))      as numberSizeQuantity,
               od.order_number                                       as orderNumber,
               fc.technology_number                                  as technologyNumber,
               od.building_number                                    as buildingNumber,
@@ -2408,6 +2499,7 @@
               c.customer_abbreviation                               as customerAbbreviation,
               p.product_abbreviation                                as productAbbreviation,
               fc.process_id                                         as processId,
               SUBSTRING(fc.process_id,12  )                                        as processIdAD ,/*-流程卡简写-*/
               o.create_time                                         as createTime,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS glassNumber,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S02')) AS figureNumber,
@@ -2442,7 +2534,7 @@
                              ogd.technology_number = fc.technology_number
        where fc.process_id = #{processId}
          and fc.order_number = #{orderNumber}
        group by od.order_number, width, height
        group by fc.process_id,od.order_number, width, height
        order by fc.process_id
    </select>
@@ -2779,7 +2871,7 @@
                 left join
             (select (@row_number := @row_number + 1) as id,process_id as process_id from (select process_id from pp.optimize_detail tt where project_no =#{projectNo} group by process_id) tt,(select @row_number := 0) as t) a
             on a.process_id=opd.process_id
        where opd.project_no = #{projectNo}
        where opd.project_no = #{projectNo} and o.order_id is not null
        group by  order_id,od.order_number
        order by ogd.child_width desc,ogd.child_height desc
    </select>
@@ -2836,7 +2928,7 @@
                  left join sd.order_detail as od on od.order_id = SUBSTRING(fc.process_id,1,10)  and od.order_number = fc.order_sort
                  left join sd.`order` as o on o.order_id = SUBSTRING(fc.process_id,1,10)
                  left join pp.`flow_card` as fcd on fcd.process_id=fc.process_id and fcd.technology_number=ogd.technology_number and fcd.order_number=od.order_number
        where fc.project_no = #{printProject}
        where fc.project_no = #{printProject} and fc.process_id is not null and fc.process_id!=""
        GROUP BY fc.process_id, ogd.technology_number
        order by fc.process_id, ogd.technology_number
    </select>
@@ -2900,6 +2992,7 @@
    <select id="getOrderDetailByProductionId">
        select * from (select a.*,
                              a.quantity as 'baiscQuantity',
                              #{glassThickness} as 'thickness',
        IF(a.height >= a.width, a.height, a.width) as 'long',
        IF(a.height &lt; a.width, a.height, a.width) as 'short'
        from sd.order_detail as a
@@ -3045,4 +3138,162 @@
        where process_id = #{processId}
          and order_number = #{orderNumber}
    </select>
    <select id="getOrderIdByProcessId">
        select order_id from pp.flow_card  where process_id = #{processId} limit 1;
    </select>
    <select id="flowCardDetailMergeMp">
        select merge from pp.flow_card where process_id = #{processId}  group by id ORDER BY merge desc LIMIT 1
    </select>
    <update id="updateFlowCardIsMerge">
        update  pp.flow_card fc set fc.merge=0
        where fc.process_id = #{processId}
    </update>
    <select id="getProcessName">
        select IFNULL(nickname,'') from sd.basic_data where basic_category='process' and basic_name=#{processSub}
    </select>
    <select id="getProcessNameList">
        SELECT id,basic_name,IFNULL(nickname,"") as nickname FROM sd.`basic_data` where basic_category='process'
    </select>
    <select id="exportDateProcessMp">
        select
        a.order_Id,
        a.process_Id,
        c.product_id,
        c.product_name,
        b.project,
        sum(a.quantity) as quantity,
        sum(a.quantity) * c.area as compute_gross_area,
        a.founder,
        c.processing_note,
        b.customer_name,
        layout_status as layout_status,
        a.merge,
        a.rack,
        b.batch
        from (select id,order_id,process_id,order_number, quantity,founder,max(layout_status) as layout_status,create_time,max(merge) as merge,rack from flow_card
        group by process_Id,order_number) as a
        left join sd.`order` as b on a.order_Id=b.order_id
        left join sd.order_detail as c on a.order_Id=c.order_id and a.order_Number=c.order_number
        where date(a.create_time) >= #{date[0]}
          and date(a.create_time) &lt;= #{date[1]}
        and b.create_order>0
        group by a.process_Id
        ORDER BY a.id desc
    </select>
    <select id="getSumQuantity">
        select quantity from  sd.`order` where order_id=#{orderId}
    </select>
    <select id="getDetailCompoundList">
        select fc.order_number,
        concat(IF(ROUND(ogd.child_width, 1) = FLOOR(ogd.child_width), FLOOR(ogd.child_width), ROUND(ogd.child_width, 1)), "*", IF(ROUND(child_height, 1) = FLOOR(child_height), FLOOR(child_height), ROUND(child_height, 1)))   as child_width,
        SUM(fc.quantity) as quantity,
        round(SUM(ogd.total_area), 2)                                       as total_area,
        SUM(od.perimeter) as perimeter,
        if(od.bend_radius!=null || od.bend_radius!='',od.bend_radius,if(od.shape=2,JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S04')),'')) as bend_radius,
        concat(IFNULL(od.processing_note, ''), IFNULL(od.remarks, '')) as remarks,
        od.other_columns,
        round(ogd.child_width)                                         as width,
        round(ogd.child_height)                                        as height,
        pd.separation,
        #{compound} as technology_number,
        IFNULL(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S02')),'') as mapNumber,
        od.building_number
        from flow_card as fc
        left join sd.order_glass_detail as ogd
        on fc.order_id = ogd.order_id and fc.order_number = ogd.order_number and
        fc.technology_number = ogd.technology_number
        left join sd.order_detail as od on od.order_id = fc.order_id and od.order_number = fc.order_number
        left join sd.product_detail as pd
        on pd.prod_id = od.product_id and pd.glass_sort = ogd.technology_number
        left join flow_card_sort as fcs
        on fcs.process_id = fc.process_id and fcs.order_number = fc.order_number and
        fcs.technology_number = fc.technology_number
        and fcs.process = #{process}
        where fc.process_id = #{processId}
        and position(fc.technology_number in #{compound})
        group by fc.process_id, fc.order_number
        <choose>
            <!-- landingSequence != 1 时,优先按 landing_sequence 倒序 -->
            <when test="landingSequence != 1">
                ORDER BY landing_sequence DESC
            </when>
            <!-- flashback = 1 时正序 -->
            <when test="flashback == 1">
                ORDER BY
                CASE
                WHEN fcs.sort IS NOT NULL AND fcs.sort &lt;&gt;  '' THEN fcs.sort
                ELSE fc.order_number
                END ASC
            </when>
            <!-- flashback != 1 时倒序 -->
            <otherwise>
                ORDER BY
                CASE
                WHEN fcs.sort IS NOT NULL AND fcs.sort &lt;&gt;  '' THEN fcs.sort
                ELSE fc.order_number
                END DESC
            </otherwise>
        </choose>
    </select>
    <select id="getDetailListLikeCompound">
        select fc.order_number,
        concat(IF(ROUND(ogd.child_width, 1) = FLOOR(ogd.child_width), FLOOR(ogd.child_width), ROUND(ogd.child_width, 1)), "*", IF(ROUND(child_height, 1) = FLOOR(child_height), FLOOR(child_height), ROUND(child_height, 1)))   as child_width,
        sum(fc.quantity) as quantity,
        round(sum(ogd.total_area), 2)                                       as total_area,
        sum(od.perimeter) as perimeter,
        if(od.bend_radius!=null || od.bend_radius!='',od.bend_radius,if(od.shape=2,JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S04')),'')) as bend_radius,
        concat(IFNULL(od.processing_note, ''), IFNULL(od.remarks, '')) as remarks,
        od.other_columns,
        round(ogd.child_width)                                         as width,
        round(ogd.child_height)                                        as height,
        pd.separation,
        #{compound} as technology_number,
        IFNULL(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S02')),'') as mapNumber,
        od.building_number
        from flow_card as fc
        left join sd.order_glass_detail as ogd
        on fc.order_id = ogd.order_id and fc.order_number = ogd.order_number and
        fc.technology_number = ogd.technology_number
        left join sd.order_detail as od on od.order_id = fc.order_id and od.order_number = fc.order_number
        left join sd.product_detail as pd
        on pd.prod_id = od.product_id and pd.glass_sort = ogd.technology_number
        left join flow_card_sort as fcs
        on fcs.process_id = fc.process_id and fcs.order_number = fc.order_number and
        fcs.technology_number = fc.technology_number
        and fcs.process = #{process}
        where fc.process_id = #{processId}
        and position(fc.technology_number in #{compound})
        group by fc.process_id, fc.order_number
        <choose>
            <!-- landingSequence != 1 时,优先按 landing_sequence 倒序 -->
            <when test="landingSequence != 1">
                ORDER BY landing_sequence DESC
            </when>
            <!-- flashback = 1 时正序 -->
            <when test="flashback == 1">
                ORDER BY
                CASE
                WHEN fcs.sort IS NOT NULL AND fcs.sort &lt;&gt;  '' THEN fcs.sort
                ELSE fc.order_number
                END ASC
            </when>
            <!-- flashback != 1 时倒序 -->
            <otherwise>
                ORDER BY
                CASE
                WHEN fcs.sort IS NOT NULL AND fcs.sort &lt;&gt;  '' THEN fcs.sort
                ELSE fc.order_number
                END DESC
            </otherwise>
        </choose>
    </select>
</mapper>