廖井涛
2024-04-18 4688ec39bdff70a1754597cbd86e96e261311fb8
north-glass-erp/src/main/resources/mapper/sd/Customer.xml
@@ -3,6 +3,162 @@
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.erp.mapper.sd.CustomerMapper">
    <resultMap id="selectCustomerOrderDetail" type="com.example.erp.entity.sd.OrderDetail">
        <result column="order_id" property="orderId"/>
        <result column="order_number" property="orderNumber"/>
        <result column="quantity" property="quantity"/>
        <result column="building_number" property="buildingNumber"/>
        <result column="product_name" property="productName"/>
        <result column="product_id" property="productId"/>
        <result column="price" property="price"/>
        <result column="width" property="width"/>
        <result column="height" property="height"/>
        <result column="area" property="area"/>
        <result column="shape" property="shape"/>
        <result column="gross_area" property="grossArea"/>
        <result column="compute_area" property="computeArea"/>
        <result column="compute_gross_area" property="computeGrossArea"/>
        <result column="processing_note" property="processingNote"/>
        <result column="edging_type" property="edgingType"/>
        <result column="perimeter" property="perimeter"/>
        <result column="batch" property="order.batch"/>
        <result column="project" property="order.project"/>
        <result column="customer_id" property="order.customerId"/>
        <result column="customer_name" property="order.customerName"/>
        <result column="money" property="order.money"/>
        <result column="order_type" property="order.orderType"/>
        <result column="salesman" property="order.salesman"/>
        <result column="create_time" property="order.createTime"/>
    </resultMap>
    <select id="getSelectCustomerOderDate" resultMap="selectCustomerOrderDetail">
        select od.order_id,
               od.order_number,
               o.project,
               od.product_id,
               od.product_name,
               o.customer_id,
               o.customer_name,
               sum(od.quantity) as quantity,
               sum(od.area) as area,
               od.shape,
               od.width,
               od.height,
               o.batch,
               o.money,
               o.order_type,
               o.salesman,
               o.create_time
        from order_detail od
                 left join `order` o on o.order_id = od.order_id
        <where>
                and date(o.create_time)>=#{startDate} and date(o.create_time) &lt;= #{endDate}
            <if test="orderDetail.order.customerId != null and orderDetail.order.customerId != ''">
                and o.customer_id = #{orderDetail.order.customerId}
            </if>
            <if test="orderDetail.order.project != null and orderDetail.order.project != ''">
                and o.project regexp #{orderDetail.order.project}
            </if>
            <if test="orderDetail.order.batch != null and orderDetail.order.batch != ''">
                and o.batch regexp #{orderDetail.order.batch}
            </if>
            <if test="orderDetail.order.money != null and orderDetail.order.money != ''">
                and o.money regexp REGEXP_REPLACE(#{orderDetail.order.money},'\\.0+$','')
            </if>
            <if test="orderDetail.order.orderType != null and orderDetail.order.orderType != ''">
                and o.order_type regexp #{orderDetail.order.orderType}
            </if>
            <if test="orderDetail.order.salesman != null and orderDetail.order.salesman != ''">
                and o.salesman regexp #{orderDetail.order.salesman}
            </if>
            <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
                and od.order_id regexp #{orderDetail.orderId}
            </if>
            <if test="orderDetail.orderNumber != null and orderDetail.orderNumber != ''">
                and od.order_number regexp #{orderDetail.orderNumber}
            </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>
            <if test="orderDetail.shape != null and orderDetail.shape != ''">
                and od.shape regexp #{orderDetail.shape}
            </if>
            <if test="orderDetail.width != null and orderDetail.width != ''">
                and od.width regexp  REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
            </if>
            <if test="orderDetail.height != null and orderDetail.height != ''">
                and od.height regexp  REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
            </if>
        </where>
        group by od.product_id, od.width, od.height
        limit #{offset},#{pageSize};
    </select>
    <select id="getSelectCustomerOderDatePageTotal" >
        select
        CEILING(count(zu.id)/#{pageSize}) as 'pageTotal',
        count(zu.id) as 'total' from (select od.product_id,od.id
        from order_detail od
        left join `order` o on o.order_id = od.order_id
        <where>
            and date(o.create_time)>=#{startDate} and date(o.create_time) &lt;= #{endDate}
            <if test="orderDetail.order.customerId != null and orderDetail.order.customerId != ''">
                and o.customer_id = #{orderDetail.order.customerId}
            </if>
            <if test="orderDetail.order.project != null and orderDetail.order.project != ''">
                and o.project regexp #{orderDetail.order.project}
            </if>
            <if test="orderDetail.order.batch != null and orderDetail.order.batch != ''">
                and o.batch regexp #{orderDetail.order.batch}
            </if>
            <if test="orderDetail.order.money != null and orderDetail.order.money != ''">
                and o.money regexp REGEXP_REPLACE(#{orderDetail.order.money},'\\.0+$','')
            </if>
            <if test="orderDetail.order.orderType != null and orderDetail.order.orderType != ''">
                and o.order_type regexp #{orderDetail.order.orderType}
            </if>
            <if test="orderDetail.order.salesman != null and orderDetail.order.salesman != ''">
                and o.salesman regexp #{orderDetail.order.salesman}
            </if>
            <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
                and od.order_id regexp #{orderDetail.orderId}
            </if>
            <if test="orderDetail.orderNumber != null and orderDetail.orderNumber != ''">
                and od.order_number regexp #{orderDetail.orderNumber}
            </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>
            <if test="orderDetail.shape != null and orderDetail.shape != ''">
                and od.shape regexp #{orderDetail.shape}
            </if>
            <if test="orderDetail.width != null and orderDetail.width != ''">
                and od.width regexp  REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
            </if>
            <if test="orderDetail.height != null and orderDetail.height != ''">
                and od.height regexp  REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
            </if>
        </where>
        group by od.product_id, od.width, od.height) as zu
    </select>
    <select id="getCustomerList">
        select
            *