廖井涛
2024-03-12 a97c0e84c8d1f50aa65935643a580527f30b7ece
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
@@ -123,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
@@ -152,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>