廖井涛
2024-03-13 b13c552870d145f287dfd93a502e91cf9efc8ec3
north-glass-erp/src/main/resources/mapper/pp/ReportingWork.xml
@@ -9,6 +9,8 @@
        <result property="previousProcess" column="previous_process"/>
        <result property="nextProcess" column="next_process"/>
        <result property="thisProcess" column="this_process"/>
        <result property="reviewedState" column="reviewed_state"/>
        <result property="previousProcessQuantity" column="previous_process_quantity"/>
        <association property="order" javaType="com.example.erp.entity.sd.Order">
            <result property="customerId" column="customer_id"/>
            <result property="customerName" column="customer_name"/>
@@ -17,7 +19,6 @@
        <association property="flowCard" javaType="com.example.erp.entity.pp.FlowCard">
            <result property="orderId" column="order_id"/>
            <result property="productionId" column="production_id"/>
            <result property="quantity" column="quantity"/>
        </association>
        <association property="reportingWorkDetail" javaType="com.example.erp.entity.pp.ReportingWorkDetail">
            <result property="completedQuantity" column="completed_quantity"/>
@@ -31,14 +32,20 @@
               o.customer_id,
               o.customer_name,
               o.project,
               SUM(fc.quantity)   as quantity,
               SUM(fc.quantity)   as previous_process_quantity,
               #{previousProcess} as previous_process,
               #{nextProcess}     as next_process,
               #{process} as  this_process
               #{process} as  this_process,
               ifnull((rw.reviewed_state),1) as reviewed_state  -- 下工序审核状态
        from sd.order as o
                 left join flow_card as fc on fc.order_id = o.order_id
        left join flow_card as fc on fc.order_id = o.order_id
        left join (select if(count(reviewed_state)>0 and process_id=null,1,0) as reviewed_state ,
                          process_id
                   from reporting_work
                   where this_process=#{previousProcess} and reviewed_state=0 and process_id=#{processIdStr}) as rw
        on rw.process_id = fc.process_id
        where fc.process_id = #{processIdStr}
          and position(fc.technology_number in #{technologyStr})
          and fc.technology_number = #{technologyStr}
        GROUP BY fc.process_id
    </select>
@@ -80,7 +87,7 @@
            ogd.child_width,
            ogd.child_height,
            od.shape,
            fc.quantity -odpd.reporting_work_num + ifnull(c.patchNumSum,0) as quantity,
            fc.quantity -odpd.reporting_work_num -odpd.broken_num + ifnull(c.patchNumSum,0) as quantity,
            odpd.reporting_work_num_count as completed,
            odpd.broken_num as onceBroken
        FROM
@@ -97,6 +104,7 @@
            ON  odpd.order_id = fc.order_id
            AND odpd.order_number = fc.order_number
            AND odpd.technology_number = fc.technology_number
            and  odpd.process_id = fc.process_id
        left join
                (select sum(patch_num) as patchNumSum,order_sort,technology_number,process_id
                   from patch_log
@@ -122,14 +130,26 @@
            ogd.child_width,
            ogd.child_height,
            od.shape,
            odpds.reporting_work_num -odpd.reporting_work_num + ifnull(c.patchNumSum,0) as quantity,
            odpds.reporting_work_num -odpd.reporting_work_num -odpd.broken_num + ifnull(c.patchNumSum,0) as quantity,
            odpd.reporting_work_num_count as completed,
            odpd.broken_num as onceBroken
            odpd.broken_num as onceBroken,
            ogd.`group`
        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
        <if test="process == '夹胶'">
            AND ogd.`group` = (select `group`
                               from sd.order_glass_detail
                               where order_id = ogd.order_id
                               and order_number = ogd.order_number
                               and technology_number =#{technologyStr}
                               limit 1)
        </if>
        LEFT JOIN flow_card AS fc
                ON fc.order_id = ogd.order_id
                and fc.production_id=ogd.production_id
@@ -139,6 +159,7 @@
                ON  odpd.order_id = fc.order_id
                AND odpd.order_number = fc.order_number
                AND odpd.technology_number = fc.technology_number
                and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
                ON  odpds.id = odpd.id-1
        left join
@@ -150,8 +171,10 @@
            and c.technology_number = fc.technology_number
        WHERE
            fc.process_id = #{processIdStr}
          AND fc.technology_number = #{technologyStr}
          AND odpd.process = #{process}
        <if test="process != '中空' and process != '夹胶' and process != '包装'">
           AND fc.technology_number = #{technologyStr}
        </if>
        AND odpd.process = #{process}
        order by fc.order_number
    </select>
@@ -244,6 +267,7 @@
            and b.technology_number = a.technology_number
            and b.order_id = SUBSTR(#{processId} from 1 for 10)
            and b.process = #{thisProcess}
            and b.process_id = a.process_id
        left join sd.order_process_detail as d
            on d.id=b.id-1
        left join (select sum(patch_num) as patchNumSum,order_sort,technology_number,process_id
@@ -269,6 +293,7 @@
                                   and b.technology_number = a.technology_number
                                   and b.order_id = SUBSTR(#{processId} from 1 for 10)
                                   and b.process = #{thisProcess}
                                   and b.process_id = a.process_id
                 left join (select sum(patch_num) as patchNumSum,order_sort,technology_number,process_id
                            from patch_log
                            group by reporting_work_id,order_sort,technology_number) as c