guoyujie
4 小时以前 9ccc8bd3a53160a40cf60f14e5867f6ce9f6c58f
north-glass-erp/src/main/resources/mapper/pp/ProductionScheduling.xml
@@ -8,13 +8,16 @@
        <result column="scheduling_quantity" property="schedulingQuantity"/>
        <result column="order_number" property="orderNumber"/>
        <result column="scheduling_id" property="schedulingId"/>
        <result column="order_id" property="orderGlassDetail.orderId"/>
        <result column="order_id" property="order.orderId"/>
        <result column="technology_number" property="technologyNumber"/>
        <result column="pendingProductionQuantity" property="pendingProductionQuantity"/>
        <result column="pendingProductionArea" property="pendingProductionArea"/>
        <result column="productionScheduledQuantity" property="productionScheduledQuantity"/>
        <result column="productionScheduledArea" property="productionScheduledArea"/>
        <result column="review_status" property="reviewStatus"/>
        <result column="scheduled_start_time" property="scheduledStartTime"/>
        <result column="plan_end_time" property="planEndTime"/>
        <result column="reviewer" property="reviewer"/>
        <!--接收其他外键实体类数据-->
        <result column="project" property="order.project"/>
        <result column="customer_name" property="order.customerName"/>
@@ -42,76 +45,63 @@
    <!--    查询已排版数据-->
    <select id="selectOkSchedulingMp">
        select date(ps.scheduled_start_time)                          as scheduled_start_time,
               date(ps.plan_end_time)                                 as plan_end_time,
               od.order_id,
               o.customer_name,
               o.project,
               od.order_number,
               od.width,
               od.height,
               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,
               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,
                     2)                                               as productionScheduledArea,
               IF(ps.review_status = 0, "未审核", "已审核")           as review_status,
               ps.reviewer,
               od.product_name,
               od.shape,
               ps.scheduling_id
    <select id="selectOkSchedulingMp" resultMap="productionSchedulingMap">
        select date(ps.scheduled_start_time) as scheduled_start_time,
        date(ps.plan_end_time) as plan_end_time,
        od.order_id,
        o.customer_name,
        o.project,
        ps.order_number,
        ps.technology_number,
        ogd.child_width,
        ogd.child_height,
        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,
        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,
        2) as productionScheduledArea,
        IF(ps.review_status = 0, "未审核", "已审核") as review_status,
        ps.reviewer,
        od.product_name,
        if(od.shape=1,'普形',if(od.shape=2,'异形','')) as shape,
        ps.scheduling_id,
        ps.notes
        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
        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
        left join sd.order_glass_detail as ogd on ogd.order_id=od.order_id and ogd.order_number=od.order_number and
        ogd.technology_number=ps.technology_number
        where ps.scheduling_id IS NOT NULL
          and od.create_time between #{selectTime1} and #{selectTime2}
          and position(#{processes} in ps.processes)
          and position(#{orderId} in ps.order_id)
        group by od.order_id, od.order_number
          and o.create_order>0
        and  DATE_FORMAT((od.create_time), '%Y-%m-%d') between #{selectTime1} and #{selectTime2}
        and position(#{processes} in ps.processes)
        and position(#{orderIds} in ps.order_id)
        <if test="productionScheduling.order.orderId != null and productionScheduling.order.orderId != ''">
            and ogd.order_id regexp #{productionScheduling.order.orderId}
        </if>
        <if test="productionScheduling.order.customerName != null and productionScheduling.order.customerName != ''">
            and o.customer_name regexp #{productionScheduling.order.customerName}
        </if>
        <if test="productionScheduling.order.project != null and productionScheduling.order.project != ''">
            and o.project regexp #{productionScheduling.order.project}
        </if>
        <if test="productionScheduling.orderNumber != null and productionScheduling.orderNumber != ''">
            and ogd.order_number regexp #{productionScheduling.orderNumber}
        </if>
        <if test="productionScheduling.technologyNumber != null and productionScheduling.technologyNumber != ''">
            and ogd.technology_number regexp #{productionScheduling.technologyNumber}
        </if>
        group by ps.id
        order by ps.id desc
        limit #{offset},#{pageSize};
    </select>
    <!--    查询已排产的数据-->
    <select id="selectSchedulingNotMp">
        select date(ps.scheduled_start_time)                          as scheduled_start_time,
               date(ps.plan_end_time)                                 as plan_end_time,
               od.order_id,
               o.customer_name,
               o.project,
               od.order_number,
               od.width,
               od.height,
               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 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,
               round(od.width * od.height * (IFNULL(ps.scheduling_quantity, 0)) / 1000000, 2)
                                                                      as productionScheduledArea,
               IF(ps.review_status = 0, "未审核", "已审核")
                                                                      as review_status,
               ps.reviewer,
               od.product_name,
               od.shape,
               ps.scheduling_id
        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 (ps.scheduling_id IS NOT NULL)
          and position(#{processes} in ps.processes)
          and position(#{orderId} in ps.order_id)
        group by od.order_id, od.order_number
        order by ps.id desc
    </select>
    <!--    查询未排产数据-->
    <select id="selectNoSchedulingMp" resultMap="productionSchedulingMap">
        select ogd.order_id,
@@ -131,8 +121,8 @@
        IFNULL(ps.schedulingQuantity, 0) as productionScheduledQuantity,
        round(ogd.child_width * ogd.child_height * (IFNULL(ps.schedulingQuantity, 0)) / 1000000,
        2) as productionScheduledArea,
        ogd.glass_child,
        od.shape
        od.product_name,
        if(od.shape=1,'普形',if(od.shape=2,'异形','')) as shape
        from sd.order_glass_detail as ogd
        left join sd.order as o on ogd.order_id = o.order_id
@@ -149,13 +139,13 @@
        ps.technology_number = ogd.technology_number
        where (od.quantity - IFNULL((ps.schedulingQuantity), 0)) > 0
        and od.create_time between #{selectTime1} and #{selectTime2}
        and  DATE_FORMAT((od.create_time), '%Y-%m-%d') between #{selectTime1} and #{selectTime2}
        and opd.reporting_work_num_count = 0
        and position(#{orderId} in ogd.order_id)
        and o.create_order>0
        and position(#{orderIds} in ogd.order_id)
        -- and position("切割" in ps.processes)
        <if test="productionScheduling.orderId != null and productionScheduling.orderId != ''">
            and ogd.order_id regexp #{productionScheduling.orderId}
        <if test="productionScheduling.order.orderId != null and productionScheduling.order.orderId != ''">
            and ogd.order_id regexp #{productionScheduling.order.orderId}
        </if>
        <if test="productionScheduling.order.customerName != null and productionScheduling.order.customerName != ''">
            and o.customer_name regexp #{productionScheduling.order.customerName}
@@ -173,52 +163,7 @@
        order by ogd.order_id desc
        limit #{offset},#{pageSize};
    </select>
    <!--    首次查询排产数据-->
    <select id="selectLastSchedulingMp">
        select ogd.order_id,
               o.customer_name,
               o.project,
               ogd.order_number,
               ogd.technology_number,
               ogd.child_width,
               ogd.child_height,
               od.quantity,
               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,
               ogd.glass_child,
               od.shape
        from sd.order_glass_detail as ogd
                 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">
        select COUNT(ps.scheduling_id)
@@ -252,7 +197,9 @@
    <update id="examineSchedulingMp">
        update production_scheduling
        set review_status=1,
            reviewer=#{userName}
            reviewer=#{userName},
            scheduling_quantity=#{schedulingQuantity},
            notes=#{notes}
        where scheduling_id = #{schedulingId}
    </update>
@@ -288,9 +235,9 @@
        ps.technology_number = ogd.technology_number
        where (od.quantity - IFNULL((ps.schedulingQuantity), 0)) > 0
        and od.create_time between #{selectTime1} and #{selectTime2}
        and  DATE_FORMAT((od.create_time), '%Y-%m-%d') between #{selectTime1} and #{selectTime2}
        and opd.reporting_work_num_count = 0
        and o.create_order>0
        and position(#{orderId} in ogd.order_id)
        -- and position("切割" in ps.processes)
        <if test="productionScheduling.orderId != null and productionScheduling.orderId != ''">
@@ -311,4 +258,41 @@
        order by ogd.order_id desc
        limit #{offset},#{pageSize};
    </select>
    <select id="getOkPageTotal">
        select CEILING(count(ps.id)/#{pageSize}) as 'pageTotal',
        count(distinct ps.id) as 'total'
        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
        left join sd.order_glass_detail as ogd on ogd.order_id=od.order_id and ogd.order_number=od.order_number and
        ogd.technology_number=ps.technology_number
        where ps.scheduling_id IS NOT NULL
        and  DATE_FORMAT((od.create_time), '%Y-%m-%d') between #{selectTime1} and #{selectTime2}
        and o.create_order>0
        and position(#{processes} in ps.processes)
        and position(#{orderId} in ps.order_id)
        <if test="productionScheduling.orderId != null and productionScheduling.orderId != ''">
            and ogd.order_id regexp #{productionScheduling.orderId}
        </if>
        <if test="productionScheduling.order.customerName != null and productionScheduling.order.customerName != ''">
            and o.customer_name regexp #{productionScheduling.order.customerName}
        </if>
        <if test="productionScheduling.order.project != null and productionScheduling.order.project != ''">
            and o.project regexp #{productionScheduling.order.project}
        </if>
        <if test="productionScheduling.orderNumber != null and productionScheduling.orderNumber != ''">
            and ogd.order_number regexp #{productionScheduling.orderNumber}
        </if>
        <if test="productionScheduling.technologyNumber != null and productionScheduling.technologyNumber != ''">
            and ogd.technology_number regexp #{productionScheduling.technologyNumber}
        </if>
        order by ps.id desc
        limit #{offset},#{pageSize};
    </select>
    <update id="cancelReviewSchedulingMp">
        update production_scheduling set   review_status=0    where scheduling_id = #{schedulingId}
    </update>
</mapper>