chenlu
2024-09-24 edc227277159601c5cb86829f1c5ce14cf7903a4
north-glass-erp/src/main/resources/mapper/pp/WordOrder.xml
@@ -8,100 +8,202 @@
        <result column="order_id" property="orderId"/>
        <result column="production_id" property="productionId"/>
        <result column="splitting_status" property="splittingStatus"/>
        <result column="founder" property="founder"/>
        <result column="create_time" property="createTime"/>
        <!--接收其他外键实体类数据-->
        <association property="order" javaType="com.example.erp.entity.sd.Order">
            <result column="batch" property="batch"/>
        </association>
        <association property="orderDetail" javaType="com.example.erp.entity.sd.OrderDetail">
            <result column="product_name" property="productName"/>
            <result column="compute_area" property="computeArea"/>
            <result column="quantity" property="quantity"/>
            <result column="compute_gross_area" property="computeGrossArea"/>
            <result column="perimeter" property="perimeter"/>
            <result column="bend_radius" property="bendRadius"/>
            <result column="processing_note" property="processingNote"/>
        </association>
            <result column="batch" property="order.batch"/>
            <result column="order_type" property="order.orderType"/>
            <result column="project" property="order.project"/>
            <result column="area" property="order.area"/>
            <result column="creator" property="order.creator"/>
        <result column="customer_name" property="order.customerName"/>
        <result column="processing_note" property="order.processingNote"/>
<!--        <association property="orderDetail" javaType="com.example.erp.entity.sd.OrderDetail">-->
<!--            <result column="product_id" property="productId"/>-->
<!--            <result column="product_name" property="productName"/>-->
<!--            <result column="compute_area" property="computeArea"/>-->
            <result column="quantity" property="orderDetail.quantity"/>
<!--            <result column="compute_gross_area" property="computeGrossArea"/>-->
<!--            <result column="perimeter" property="perimeter"/>-->
<!--            <result column="bend_radius" property="bendRadius"/>-->
<!--            <result column="processing_note" property="processingNote"/>-->
            <result column="gross_area" property="orderDetail.grossArea"/>
        <!--<result column="g_typeId" property="glassTypes.typeId"/>
        <result column="g_type" property="glassTypes.type"/>-->
<!--        </association>-->
    </resultMap>
    <select id="selectWordOrder" resultMap="wordOrderMap">
        select
        a.order_id,
        a.production_id,
        c.batch,
        b.product_name,
        b.compute_area,
        b.quantity,
        b.compute_gross_area,
        b.perimeter,
        b.bend_radius,
        b.processing_note
        from order_glass_detail as a
        LEFT JOIN order_detail as b on a.order_id=b.order_id and a.order_number=b.order_number LEFT JOIN
        `order` as c on a.order_id=c.order_id
        <where>
            <if test="orderGlassDetail.orderId != null and orderGlassDetail.orderId != ''">
                and a.order_id regexp #{orderGlassDetail.orderId}
            </if>
            <if test="orderGlassDetail.productionId != null and orderGlassDetail.productionId != ''">
                and a.production_id regexp #{orderGlassDetail.productionId}
            </if>
            <if test="orderGlassDetail.order.batch != null and orderGlassDetail.order.batch != ''">
                and c.batch regexp #{orderGlassDetail.order.batch}
            </if>
            <if test="orderGlassDetail.orderDetail.productName != null and orderGlassDetail.orderDetail.productName!= ''">
                and b.product_name regexp #{orderGlassDetail.orderDetail.productName}
            </if>
            <if test="orderGlassDetail.splittingStatus=0 " >
                and a.splitting_status regexp #{state}
            </if>
            <if test="orderGlassDetail.splittingStatus=1">
                and a.splitting_status regexp #{state}
            </if>
            <if test="orderGlassDetail.createTime != ''">
                and DATE_FORMAT((a.create_time),'%Y-%m-%d')  BETWEEN #{ selectTime1 } AND #{ selectTime2 }
            </if>
        </where>
        group by a.production_id,a.order_number
        order by a.id desc
        o.order_id,
        o.batch,
        o.project,
        o.order_type,
        o.area as gross_area,
        o.quantity as quantity,
        o.creator,
        o.customer_name,
        o.processing_note
        from sd.order_detail  as od
        left join `order` as o
        on o.order_id=od.order_id
        where o.production_order!=2 and o.order_review=2
        <if test="orderGlassDetail.orderId != null and orderGlassDetail.orderId != ''">
            and o.order_id regexp #{orderGlassDetail.orderId}
        </if>
        <if test="orderGlassDetail.order.batch != null and orderGlassDetail.order.batch != ''">
            and o.batch regexp #{orderGlassDetail.order.batch}
        </if>
        <if test="orderGlassDetail.order.project != null and orderGlassDetail.order.project!= ''">
            and o.project regexp #{orderGlassDetail.order.project}
        </if>
        <if test="orderGlassDetail.order.orderType != null and orderGlassDetail.order.orderType!= ''">
            and o.order_type regexp #{orderGlassDetail.order.orderType}
        </if>
        <if test="orderGlassDetail.order.customerName != null and orderGlassDetail.order.customerName!= ''">
            and o.customer_name regexp #{orderGlassDetail.order.customerName}
        </if>
        <if test="orderGlassDetail.order.processingNote != null and orderGlassDetail.order.processingNote!= ''">
            and o.processing_note regexp #{orderGlassDetail.order.processingNote}
        </if>
        <if test="orderGlassDetail.createTime != ''">
            and DATE_FORMAT((o.create_time),'%Y-%m-%d') BETWEEN #{ selectTime1 } AND #{ selectTime2 }
        </if>
        group by o.order_id
        order by o.id desc
        ;
    </select>
    <!--    <select id="getPageTotal" >-->
    <!--        select-->
    <!--        CEILING(count(a.id)/#{pageSize})-->
    <!--        from product as a-->
    <!--        left join basic_glass_type bgt on bgt.type_id = a.type_id-->
    <!--        <where>-->
    <!--            <if test="glassTypeId != null and glassTypeId != ''">-->
    <!--                and a.type_id regexp #{glassTypeId}-->
    <!--            </if>-->
    <!--            <if test="product.id != null and product.id != ''">-->
    <!--                and a.id regexp #{product.id}-->
    <!--            </if>-->
    <!--            <if test="product.productName != null and product.productName != ''">-->
    <!--                and a.product_name regexp #{product.productName}-->
    <!--            </if>-->
    <!--            <if test="product.basicGlassType.typeName != null and product.basicGlassType.typeName!= ''">-->
    <!--                and bgt.type_name regexp #{product.basicGlassType.typeName}-->
    <!--            </if>-->
    <!--            <if test="product.query != null and product.query != ''">-->
    <!--                and a.query regexp #{product.query}-->
    <!--            </if>-->
    <!--            <if test="product.creator != null and product.creator != ''">-->
    <!--                and a.creator regexp #{product.creator}-->
    <!--            </if>-->
    <!--            <if test="product.createTime != null and product.createTime != ''">-->
    <!--                and date(a.create_time) regexp #{product.createTime}-->
    <!--            </if>-->
    <!--        </where>-->
    <select id="selectWordOrderNo" resultMap="wordOrderMap">
        select
        o.order_id,
        od.order_number,
        ogd.production_id,
        ogd.founder,
        o.batch,
        o.project,
        o.order_type,
        (od.gross_area) as gross_area,
        (od.quantity) as quantity,
        o.creator,
        od.id,
        o.customer_name,
        o.processing_note
        from sd.order_glass_detail  as ogd
        left join  order_detail as od
        on od.order_id=ogd.order_id
        and ogd.order_number=od.order_number
        left join `order` as o
        on o.order_id=ogd.order_id
        where ogd.production_id IS NOT NULL
        and o.order_review>0
        <if test="orderGlassDetail.orderId != null and orderGlassDetail.orderId != ''">
            and o.order_id regexp #{orderGlassDetail.orderId}
        </if>
        <if test="orderGlassDetail.productionId != null and orderGlassDetail.productionId != ''">
            and ogd.production_id regexp #{orderGlassDetail.productionId}
        </if>
        <if test="orderGlassDetail.order.batch != null and orderGlassDetail.order.batch != ''">
            and o.batch regexp #{orderGlassDetail.order.batch}
        </if>
        <if test="orderGlassDetail.order.project != null and orderGlassDetail.order.project!= ''">
            and o.project regexp #{orderGlassDetail.order.project}
        </if>
        <if test="orderGlassDetail.order.orderType != null and orderGlassDetail.order.orderType!= ''">
            and o.order_type regexp #{orderGlassDetail.order.orderType}
        </if>
        <if test="orderGlassDetail.order.customerName != null and orderGlassDetail.order.customerName!= ''">
            and o.customer_name regexp #{orderGlassDetail.order.customerName}
        </if>
        <if test="orderGlassDetail.order.processingNote != null and orderGlassDetail.order.processingNote!= ''">
            and o.processing_note regexp #{orderGlassDetail.order.processingNote}
        </if>
    <!--        order by a.id desc-->
    <!--        ;-->
    <!--    </select>-->
        <if test="orderGlassDetail.createTime != ''">
            and DATE_FORMAT((o.create_time),'%Y-%m-%d') BETWEEN #{ selectTime1 } AND #{ selectTime2 }
        </if>
        group by od.id,ogd.order_id,od.order_number
        order by od.id desc
    </select>
    <select id="addWordOrder">
        select od.order_id,
        od.product_id,
        od.product_name,
        sum( od.quantity) as quantity,
        od.compute_gross_area,
        od.perimeter
        from sd.order_detail as od
        left join sd.order as o
        on od.order_id =o.order_id
        where FIND_IN_SET(od.order_id,#{orderId})    and o.production_order!=2
        <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
            and od.order_id regexp #{orderDetail.orderId}
        </if>
        <if test="orderDetail.productId != null and orderDetail.productId != ''">
            and od.product_id regexp #{orderDetail.productId}
        </if>
        <if test="orderDetail.productName != null and orderDetail.productName != ''">
            and od.product_name regexp #{orderDetail.productName}
        </if>
        group by od.order_id, od.product_id, od.product_name
        ;
    </select>
    <select id="selectOrderNumber">
        select ifnull(count(ogd.production_id), 0)
        from sd.order_glass_detail as ogd
        where ogd.production_id = #{productIdVl}
    </select>
    <update id="addOrderWorkMp">
        update 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
        set ogd.production_id=#{productIdVl},
            ogd.production_time=NOW(),
            ogd.founder=#{userName}
        where od.order_id = #{orderId}
          and od.product_id = #{productId}
          and od.product_name = #{productName}
    </update>
    <!--    删除工单-->
    <update id="deleteOrderWorkMp">
        update 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
        set ogd.production_id=null,
            ogd.production_time=null,
            ogd.founder=null
        where od.order_id = #{orderId}
    </update>
    <select id="selectWorkCount">
        select COUNT(distinct order_number)
        from order_glass_detail
        where ISNULL(production_id)
          and order_id = #{orderId}
    </select>
    <select id="selectYesWorkCount">
        select COUNT(distinct order_number)
        from order_glass_detail
        where order_id = #{orderId}
    </select>
    <update id="updateWorkType">
        update sd.order as o
        set o.production_order=#{state}
        where o.order_id = #{orderId}
    </update>
    <select id="selectProcessCard">
        select processing_card from sd.`order` where order_id = #{orderId}
    </select>
</mapper>