廖井涛
2024-03-15 5a5e59f8aaa2a030511ef245886bf6d1db9bf774
north-glass-erp/src/main/resources/mapper/pp/ProductionScheduling.xml
@@ -91,7 +91,7 @@
               od.quantity,
               round(od.width * od.height * od.quantity / 1000000, 2) as area,
               ps.scheduling_quantity,
               (od.quantity - IFNULL(sum(ps.scheduling_quantity), 0)) as pendingProductionQuantity,
               (od.quantity - IFNULL(sum(ps.scheduling_quantity), 0)) as scheduling_quantity,
               round(od.width * od.height * (od.quantity - IFNULL(sum(ps.scheduling_quantity), 0)) / 1000000, 2)
                                                                      as pendingProductionArea,
               IFNULL(ps.scheduling_quantity, 0)                      as productionScheduledQuantity,
@@ -115,62 +115,77 @@
    </select>
    <!--    查询未排产数据-->
    <select id="selectNoSchedulingMp">
        select od.order_id,
        select ogd.order_id,
               o.customer_name,
               o.project,
               od.order_number,
               od.width,
               od.height,
               ogd.order_number,
               ogd.technology_number,
               ogd.child_width,
               ogd.child_height,
               od.quantity,
               round(od.width * od.height * od.quantity / 1000000, 2) as area,
               (od.quantity - IFNULL(sum(ps.scheduling_quantity), 0)) as pendingProductionQuantity,
               round(od.width * od.height * (od.quantity - IFNULL(sum(ps.scheduling_quantity), 0)) / 1000000, 2)
                                                                      as pendingProductionArea,
               IFNULL(ps.scheduling_quantity, 0)                      as productionScheduledQuantity,
               round(od.width * od.height * (IFNULL(ps.scheduling_quantity, 0)) / 1000000,
               round(ogd.child_width * ogd.child_height * od.quantity / 1000000, 2) as area,
               (od.quantity - IFNULL((ps.schedulingQuantity), 0)) as scheduling_quantity,
               (od.quantity - IFNULL((ps.schedulingQuantity), 0)) as pendingProductionQuantity,
               round(ogd.child_width * ogd.child_height * (od.quantity - IFNULL((ps.schedulingQuantity), 0)) / 1000000, 2)
                                                                                    as pendingProductionArea,
               IFNULL(ps.schedulingQuantity, 0)                      as productionScheduledQuantity,
               round(ogd.child_width * ogd.child_height * (IFNULL(ps.schedulingQuantity, 0)) / 1000000,
                     2)                                               as productionScheduledArea,
               od.product_name,
               ogd.glass_child,
               od.shape
        from sd.order_detail as od
                 left join sd.order as o on od.order_id = o.order_id
                 left join production_scheduling as ps
                           on ps.order_id = od.order_id and ps.order_number = od.order_number
        where (od.quantity - IFNULL((ps.scheduling_quantity), 0)) > 0
          and od.create_time between #{selectTime1} and #{selectTime2}
        from sd.order_glass_detail as ogd
          and position(#{orderId} in ps.order_id)
          and position(#{processes} in ps.processes)
                 left join sd.order as o on ogd.order_id = o.order_id
                 left join sd.order_detail as od on od.order_id=ogd.order_id and od.order_number=ogd.order_number
                 left join sd.order_process_detail as opd on opd.order_id=ogd.order_id and opd.order_number=ogd.order_number and opd.technology_number=ogd.technology_number
                 left join
             (select order_id,order_number,technology_number,SUM(scheduling_quantity) as schedulingQuantity from production_scheduling where processes=#{processes} group by order_id,order_number,technology_number) as ps on ps.order_id = ogd.order_id and ps.order_number = ogd.order_number and ps.technology_number=ogd.technology_number
        group by od.order_id, od.order_number
        order by ps.id desc
        where (od.quantity - IFNULL((ps.schedulingQuantity), 0)) > 0
          and od.create_time between #{selectTime1} and #{selectTime2} and opd.reporting_work_num_count=0
          and position(#{orderId} in ogd.order_id)
--           and position("切割" in ps.processes)
        group by ogd.order_id, ogd.order_number,ogd.technology_number
        order by ogd.order_id desc
    </select>
    <!--    首次查询排产数据-->
    <select id="selectLastSchedulingMp">
        select od.order_id,
        select ogd.order_id,
               o.customer_name,
               o.project,
               od.order_number,
               od.width,
               od.height,
               ogd.order_number,
               ogd.technology_number,
               ogd.child_width,
               ogd.child_height,
               od.quantity,
               round(od.width * od.height * od.quantity / 1000000, 2) as area,
               (od.quantity - IFNULL(sum(ps.scheduling_quantity), 0)) as pendingProductionQuantity,
               round(od.width * od.height * (od.quantity - IFNULL(sum(ps.scheduling_quantity), 0)) / 1000000,
                     2)                                               as pendingProductionArea,
               IFNULL(sum(ps.scheduling_quantity), 0)                 as productionScheduledQuantity,
               round(od.width * od.height * (IFNULL(sum(ps.scheduling_quantity), 0)) / 1000000,
               round(ogd.child_width * ogd.child_height * od.quantity / 1000000, 2) as area,
               (od.quantity - IFNULL((ps.schedulingQuantity), 0)) as scheduling_quantity,
               (od.quantity - IFNULL((ps.schedulingQuantity), 0)) as pendingProductionQuantity,
               round(ogd.child_width * ogd.child_height * (od.quantity - IFNULL((ps.schedulingQuantity), 0)) / 1000000, 2)
                                                                                    as pendingProductionArea,
               IFNULL(ps.schedulingQuantity, 0)                      as productionScheduledQuantity,
               round(ogd.child_width * ogd.child_height * (IFNULL(ps.schedulingQuantity, 0)) / 1000000,
                     2)                                               as productionScheduledArea,
               od.product_name,
               ogd.glass_child,
               od.shape
        from sd.order_detail as od
                 left join sd.order as o on od.order_id = o.order_id
                 left join production_scheduling as ps
                           on ps.order_id = od.order_id and ps.order_number = od.order_number
        where od.create_time between #{selectTime1} and #{selectTime2}
          and (od.quantity - IFNULL((ps.scheduling_quantity), 0)) > 0
        from sd.order_glass_detail as ogd
        group by od.order_id, od.order_number
        order by ps.id desc
                 left join sd.order as o on ogd.order_id = o.order_id
                 left join sd.order_detail as od on od.order_id=ogd.order_id and od.order_number=ogd.order_number
                 left join sd.order_process_detail as opd on opd.order_id=ogd.order_id and opd.order_number=ogd.order_number and opd.technology_number=ogd.technology_number
                 left join
             (select order_id,order_number,technology_number,SUM(scheduling_quantity) as schedulingQuantity from production_scheduling where processes=#{processes} group by order_id,order_number,technology_number) as ps on ps.order_id = ogd.order_id and ps.order_number = ogd.order_number and ps.technology_number=ogd.technology_number
        where (od.quantity - IFNULL((ps.schedulingQuantity), 0)) > 0
          and od.create_time between #{selectTime1} and #{selectTime2} and opd.reporting_work_num_count=0
          and position(#{orderId} in ogd.order_id)
--           and position("切割" in ps.processes)
        group by ogd.order_id, ogd.order_number,ogd.technology_number
        order by ogd.order_id desc
    </select>
    <select id="selectMaxId">
@@ -183,6 +198,7 @@
        insert into production_scheduling(scheduling_id,
                                          order_id,
                                          order_number,
                                          technology_number,
                                          processes,
                                          scheduling_quantity,
                                          scheduled_start_time,
@@ -192,6 +208,7 @@
        VALUES (#{schedulingId},
                #{orderId},
                #{orderNumber},
                #{technologyNumber},
                #{processes},
                #{schedulingQuantity},
                #{scheduledStartTime},