delete from sd.delivery_detail where delivery_id=#{deliveryId}
update sd.order_detail set delivery_num=delivery_num+#{deliveryDetail.quantity} where order_id=#{orderId} and order_number=#{orderNumber}
update sd.order_detail set delivery_num=delivery_num-#{quantity} where order_id=#{orderId} and order_number=#{orderNumber}
update sd.`order` set delivery=#{state} where order_id=#{orderDetail.orderId}
select count(*) from sd.delivery_detail where delivery_id=#{deliveryId}
select * from sd.delivery_detail where delivery_id=#{deliveryId}
select quantity from sd.`order` where order_id=#{orderId}
select sum(quantity) from sd.order_detail where order_id=#{orderId}
SELECT * FROM sd.order_detail where order_id=#{orderDetail.orderId} and order_number=#{orderDetail.orderNumber}
insert into sd.delivery_detail (delivery_id,delivery_number,order_number,
area,order_id,quantity,money,delivery_detail_remakes,delivery_detail_state,other_columns,create_time,price,other_money,box_no)
values (
#{number} ,#{deliveryNumber},#{orderDetail.orderNumber},#{deliveryDetailArea},
#{orderDetail.orderId},#{orderDetail.deliveryDetail.quantity},
#{deliveryDetailMoney},'',1,#{orderDetail.otherColumns},now(),#{orderDetail.price},#{otherMoneys},#{orderDetail.finishedGoodsInventory.boxNo}
)
select od.order_id,
o.batch,
dd.delivery_number,
fgi.quantity_available + dd.quantity as quantity_available,
od.order_number,
od.quantity-od.delivery_num as t_quantity,
(fgi.quantity_available+ifnull(dd1.sumQuantity,0)) as o_quantity,
dd.quantity as d_quantity,
od.building_number,
od.product_id,
od.product_name,
dd.price,
fgi.storage_region,
dd.money,
od.width,
od.height,
od.shape,
fgi.actual_signal_area,
dd.box_no,
od.area,
dd.area as gross_area,
od.compute_area,
dd.area as compute_gross_area,
od.processing_note,
od.edging_type,
od.perimeter,
dd.delivery_detail_remakes,
dd.other_columns
from sd.delivery_detail dd
left join sd.delivery d on dd.delivery_id=d.delivery_id
left join sd.order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
left join sd.`order` o on dd.order_id=o.order_id
left join mm.finished_goods_inventory fgi on dd.order_id=fgi.order_id and dd.order_number=fgi.order_number and fgi.box_no = dd.box_no
left join (SELECT IFNULL(sum(quantity),0) as sumQuantity,dd.*
from sd.delivery_detail dd
GROUP BY dd.order_id,dd.order_number,dd.box_no) AS dd1
on od.order_id = dd1.order_id and od.order_number = dd1.order_number and dd1.box_no = fgi.box_no
and dd.delivery_id = #{orderDetail.deliveryDetail.deliveryId}
and od.order_id regexp #{orderDetail.orderId}
and o.batch regexp #{orderDetail.order.batch}
and fgi.quantity_available regexp #{orderDetail.finishedGoodsInventory.quantityAvailable}
and od.quantity regexp #{orderDetail.quantity}
and dd.quantity regexp #{orderDetail.deliveryDetail.quantity}
and od.building_number regexp #{orderDetail.buildingNumber}
and od.product_id regexp #{orderDetail.productId}
and od.product_name regexp #{orderDetail.productName}
and od.price regexp #{orderDetail.price}
and fgi.storage_region regexp #{orderDetail.finishedGoodsInventory.storageRegion}
and dd.box_no regexp #{orderDetail.deliveryDetail.boxNo}
and dd.money regexp REGEXP_REPLACE(#{orderDetail.deliveryDetail.money},'\\.0+$','')
and od.width regexp REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
and od.height regexp REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
and od.shape regexp #{orderDetail.shape}
and fgi.actual_signal_area regexp REGEXP_REPLACE(#{orderDetail.finishedGoodsInventory.actualSignalArea},'\\.0+$','')
and od.gross_area regexp REGEXP_REPLACE(#{orderDetail.grossArea},'\\.0+$','')
and od.compute_area regexp REGEXP_REPLACE(#{orderDetail.computeArea},'\\.0+$','')
and od.compute_gross_area regexp REGEXP_REPLACE(#{orderDetail.computeGrossArea},'\\.0+$','')
and od.processing_note regexp #{orderDetail.processingNote}
and od.edging_type regexp #{orderDetail.edgingType}
and od.perimeter regexp #{orderDetail.perimeter}
and dd.delivery_detail_remakes regexp #{orderDetail.deliveryDetail.deliveryDetailRemakes}
order by dd.box_no,dd.order_id,dd.order_number
select
CEILING(count(dd.id)/#{pageSize})
from sd.delivery_detail dd
left join sd.delivery d on dd.delivery_id=d.delivery_id
left join sd.order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
left join sd.`order` o on dd.order_id=o.order_id
left join mm.finished_goods_inventory fgi on dd.order_id=fgi.order_id and dd.order_number=fgi.order_number
and dd.delivery_id regexp #{orderDetail.deliveryDetail.deliveryId}
and od.order_id regexp #{orderDetail.orderId}
and o.batch regexp #{orderDetail.order.batch}
and fgi.quantity_available regexp #{orderDetail.finishedGoodsInventory.quantityAvailable}
and od.quantity regexp #{orderDetail.quantity}
and dd.quantity regexp #{orderDetail.deliveryDetail.quantity}
and od.building_number regexp #{orderDetail.buildingNumber}
and od.product_id regexp #{orderDetail.productId}
and od.product_name regexp #{orderDetail.productName}
and od.price regexp #{orderDetail.price}
and fgi.storage_region regexp #{orderDetail.finishedGoodsInventory.storageRegion}
and dd.box_no regexp #{orderDetail.deliveryDetail.boxNo}
and dd.money regexp REGEXP_REPLACE(#{orderDetail.deliveryDetail.money},'\\.0+$','')
and od.width regexp REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
and od.height regexp REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
and od.shape regexp #{orderDetail.shape}
and fgi.actual_signal_area regexp REGEXP_REPLACE(#{orderDetail.finishedGoodsInventory.actualSignalArea},'\\.0+$','')
and od.gross_area regexp REGEXP_REPLACE(#{orderDetail.grossArea},'\\.0+$','')
and od.compute_area regexp REGEXP_REPLACE(#{orderDetail.computeArea},'\\.0+$','')
and od.compute_gross_area regexp REGEXP_REPLACE(#{orderDetail.computeGrossArea},'\\.0+$','')
and od.processing_note regexp #{orderDetail.processingNote}
and od.edging_type regexp #{orderDetail.edgingType}
and od.perimeter regexp #{orderDetail.perimeter}
and dd.delivery_detail_remakes regexp #{orderDetail.deliveryDetail.deliveryDetailRemakes}
select
fgi.id,
od.order_id,
od.order_number,
o.batch,
o.calculate_type,
fgi.quantity_available,
od.quantity- od.delivery_num as t_quantity,-- 未发数量
ifnull(dd1.sumQuantity,0)+fgi.quantity_available as o_quantity,-- 数量
fgi.quantity_available as d_quantity,-- 发货数量
od.building_number,
od.product_id,
od.product_name,
od.price,
fgi.storage_region,
od.width,
od.height,
od.shape,
fgi.actual_signal_area,
fgi.box_no,
od.area,
od.gross_area,
od.compute_area,
od.compute_gross_area,
od.processing_note,
od.edging_type,
od.perimeter,
od.other_columns
from sd.order_detail od
left join sd.`order` o on od.order_id = o.order_id
left join mm.finished_goods_inventory fgi
on od.order_id = fgi.order_id and od.order_number = fgi.order_number
left join (SELECT IFNULL(sum(quantity),0) as sumQuantity,dd.*
from sd.delivery_detail dd
where dd.order_id regexp #{orderDetail.orderId}
GROUP BY dd.order_id,dd.order_number,dd.box_no) AS dd1
on od.order_id = dd1.order_id and od.order_number = dd1.order_number and dd1.box_no = fgi.box_no
fgi.quantity_available > 0 and od.quantity > od.delivery_num
and od.order_id regexp #{orderDetail.orderId}
and o.batch regexp #{orderDetail.order.batch}
and fgi.quantity_available regexp #{orderDetail.finishedGoodsInventory.quantityAvailable}
and od.quantity regexp #{orderDetail.quantity}
and od.delivery_num regexp #{orderDetail.deliveryNum}
and od.building_number regexp #{orderDetail.buildingNumber}
and od.product_id regexp #{orderDetail.productId}
and od.product_name regexp #{orderDetail.productName}
and od.price regexp REGEXP_REPLACE(#{orderDetail.price},'\\.0+$','')
and fgi.storage_region regexp #{orderDetail.finishedGoodsInventory.storageRegion}
and fgi.box_no regexp #{orderDetail.finishedGoodsInventory.boxNo}
and od.width regexp REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
and od.height regexp REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
and od.shape regexp #{orderDetail.shape}
and fgi.actual_signal_area regexp REGEXP_REPLACE(#{orderDetail.finishedGoodsInventory.actualSignalArea},'\\.0+$','')
and od.gross_area regexp REGEXP_REPLACE(#{orderDetail.grossArea},'\\.0+$','')
and od.compute_area regexp REGEXP_REPLACE(#{orderDetail.computeArea},'\\.0+$','')
and od.compute_gross_area regexp REGEXP_REPLACE(#{orderDetail.computeGrossArea},'\\.0+$','')
and od.processing_note regexp #{orderDetail.processingNote}
and od.edging_type regexp #{orderDetail.edgingType}
and od.perimeter regexp #{orderDetail.perimeter}
order by od.order_id,od.order_number
select
CEILING(count(od.id)/#{pageSize})
from sd.order_detail od
left join sd.`order` o on od.order_id = o.order_id
left join mm.finished_goods_inventory fgi
on od.order_id = fgi.order_id and od.order_number = fgi.order_number
fgi.quantity_available > 0 and od.quantity > od.delivery_num
and od.order_id regexp #{orderDetail.orderId}
and o.batch regexp #{orderDetail.order.batch}
and fgi.quantity_available regexp #{orderDetail.finishedGoodsInventory.quantityAvailable}
and od.quantity regexp #{orderDetail.quantity}
and od.delivery_num regexp #{orderDetail.deliveryNum}
and od.building_number regexp #{orderDetail.buildingNumber}
and od.product_id regexp #{orderDetail.productId}
and od.product_name regexp #{orderDetail.productName}
and od.price regexp REGEXP_REPLACE(#{orderDetail.price},'\\.0+$','')
and fgi.storage_region regexp #{orderDetail.finishedGoodsInventory.storageRegion}
and fgi.box_no regexp #{orderDetail.finishedGoodsInventory.boxNo}
and od.width regexp REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
and od.height regexp REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
and od.shape regexp #{orderDetail.shape}
and fgi.actual_signal_area regexp REGEXP_REPLACE(#{orderDetail.finishedGoodsInventory.actualSignalArea},'\\.0+$','')
and od.gross_area regexp REGEXP_REPLACE(#{orderDetail.grossArea},'\\.0+$','')
and od.compute_area regexp REGEXP_REPLACE(#{orderDetail.computeArea},'\\.0+$','')
and od.compute_gross_area regexp REGEXP_REPLACE(#{orderDetail.computeGrossArea},'\\.0+$','')
and od.processing_note regexp #{orderDetail.processingNote}
and od.edging_type regexp #{orderDetail.edgingType}
and od.perimeter regexp #{orderDetail.perimeter}
select dd.delivery_id,
dd.delivery_number,
od.product_id,
od.product_name,
d.payment_terms,
d.project,
d.customer_id,
d.customer_name,
d.delivery_date,
d.pay_method,
d.pay_date,
d.salesman,
d.creator,
d.contacts,
d.contact_number,
d.delivery_address,
dd.order_id,
dd.order_number,
dd.area,
dd.price,
dd.money,
dd.quantity,
dd.delivery_detail_remakes,
dd.create_time,
o.other_money,
d.freight_price,
d.freight_quantity,
d.freight,
o.batch,
od.width,
od.height,
od.building_number,
dd.box_no
from sd.delivery_detail dd
left join sd.delivery d on dd.delivery_id=d.delivery_id
left join order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
left join sd.`order` o on dd.order_id=o.order_id
and date(dd.create_time)>=#{startDate} and date(dd.create_time) <= #{endDate}
and o.batch like concat('%',#{deliveryDetail.order.batch},'%')
and od.width regexp REGEXP_REPLACE(#{deliveryDetail.orderDetail.width},'\\.0+$','')
and od.height regexp REGEXP_REPLACE(#{deliveryDetail.orderDetail.height},'\\.0+$','')
and od.building_number like concat('%',#{deliveryDetail.orderDetail.buildingNumber},'%')
and dd.box_no like concat('%',#{deliveryDetail.boxNo},'%')
and dd.delivery_id like concat('%',#{deliveryDetail.deliveryId},'%')
and dd.delivery_number like concat('%',#{deliveryDetail.deliveryNumber},'%')
and od.product_id like concat('%',#{deliveryDetail.orderDetail.productId},'%')
and od.product_name like concat('%', #{deliveryDetail.orderDetail.productName},'%')
and dd.order_id like concat('%', #{deliveryDetail.orderId},'%')
and dd.order_number like concat('%', #{deliveryDetail.orderNumber},'%')
and dd.area regexp REGEXP_REPLACE(#{deliveryDetail.area},'\\.0+$','')
and dd.price regexp REGEXP_REPLACE(#{deliveryDetail.price},'\\.0+$','')
and dd.money regexp REGEXP_REPLACE(#{deliveryDetail.money},'\\.0+$','')
and dd.quantity regexp REGEXP_REPLACE(#{deliveryDetail.quantity},'\\.0+$','')
and dd.delivery_detail_remakes like concat('%', #{deliveryDetail.deliveryDetailRemakes},'%')
and dd.create_time like concat('%', #{deliveryDetail.createTime},'%')
and d.payment_terms like concat('%', #{deliveryDetail.delivery.paymentTerms},'%')
and d.project like concat('%', #{deliveryDetail.delivery.project},'%')
and d.customer_id like concat('%', #{deliveryDetail.delivery.customerId},'%')
and d.customer_name like concat('%', #{deliveryDetail.delivery.customerName},'%')
and d.delivery_date like concat('%', #{deliveryDetail.delivery.deliveryDate},'%')
and d.pay_method like concat('%', #{deliveryDetail.delivery.payMethod},'%')
and d.pay_date like concat('%', #{deliveryDetail.delivery.payDate},'%')
and d.salesman like concat('%', #{deliveryDetail.delivery.salesman},'%')
and d.creator like concat('%', #{deliveryDetail.delivery.creator},'%')
and d.contacts like concat('%', #{deliveryDetail.delivery.contacts},'%')
and d.contact_number like concat('%', #{deliveryDetail.delivery.contactNumber},'%')
and d.delivery_address like concat('%', #{deliveryDetail.delivery.deliveryAddress},'%')
and o.other_money regexp REGEXP_REPLACE(#{deliveryDetail.order.otherMoney},'\\.0+$','')
and d.freight regexp REGEXP_REPLACE(#{deliveryDetail.delivery.freight},'\\.0+$','')
and d.freight_quantity regexp REGEXP_REPLACE(#{deliveryDetail.delivery.freightQuantity},'\\.0+$','')
and d.freight_price regexp REGEXP_REPLACE(#{deliveryDetail.delivery.freightPrice},'\\.0+$','')
order by dd.delivery_id,dd.delivery_number
limit #{offset},#{pageSize};
select CEILING(count(dd.id)/#{pageSize}) as 'pageTotal',
count(dd.id) as 'total'
from sd.delivery_detail dd
left join sd.delivery d on dd.delivery_id=d.delivery_id
left join order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
left join sd.`order` o on dd.order_id=o.order_id
and date(dd.create_time)>=#{startDate} and date(dd.create_time) <= #{endDate}
and o.batch like concat('%',#{deliveryDetail.order.batch},'%')
and od.width regexp REGEXP_REPLACE(#{deliveryDetail.orderDetail.width},'\\.0+$','')
and od.height regexp REGEXP_REPLACE(#{deliveryDetail.orderDetail.height},'\\.0+$','')
and od.building_number like concat('%',#{deliveryDetail.orderDetail.buildingNumber},'%')
and dd.box_no like concat('%',#{deliveryDetail.boxNo},'%')
and dd.delivery_id like concat('%',#{deliveryDetail.deliveryId},'%')
and dd.delivery_number like concat('%',#{deliveryDetail.deliveryNumber},'%')
and od.product_id like concat('%',#{deliveryDetail.orderDetail.productId},'%')
and od.product_name like concat('%', #{deliveryDetail.orderDetail.productName},'%')
and dd.order_id like concat('%', #{deliveryDetail.orderId},'%')
and dd.order_number like concat('%', #{deliveryDetail.orderNumber},'%')
and dd.area regexp REGEXP_REPLACE(#{deliveryDetail.area},'\\.0+$','')
and dd.price regexp REGEXP_REPLACE(#{deliveryDetail.price},'\\.0+$','')
and dd.money regexp REGEXP_REPLACE(#{deliveryDetail.money},'\\.0+$','')
and dd.quantity regexp REGEXP_REPLACE(#{deliveryDetail.quantity},'\\.0+$','')
and dd.delivery_detail_remakes like concat('%', #{deliveryDetail.deliveryDetailRemakes},'%')
and dd.create_time like concat('%', #{deliveryDetail.createTime},'%')
and d.payment_terms like concat('%', #{deliveryDetail.delivery.paymentTerms},'%')
and d.project like concat('%', #{deliveryDetail.delivery.project},'%')
and d.customer_id like concat('%', #{deliveryDetail.delivery.customerId},'%')
and d.customer_name like concat('%', #{deliveryDetail.delivery.customerName},'%')
and d.delivery_date like concat('%', #{deliveryDetail.delivery.deliveryDate},'%')
and d.pay_method like concat('%', #{deliveryDetail.delivery.payMethod},'%')
and d.pay_date like concat('%', #{deliveryDetail.delivery.payDate},'%')
and d.salesman like concat('%', #{deliveryDetail.delivery.salesman},'%')
and d.creator like concat('%', #{deliveryDetail.delivery.creator},'%')
and d.contacts like concat('%', #{deliveryDetail.delivery.contacts},'%')
and d.contact_number like concat('%', #{deliveryDetail.delivery.contactNumber},'%')
and d.delivery_address like concat('%', #{deliveryDetail.delivery.deliveryAddress},'%')
and o.other_money regexp REGEXP_REPLACE(#{deliveryDetail.order.otherMoney},'\\.0+$','')
and d.freight regexp REGEXP_REPLACE(#{deliveryDetail.delivery.freight},'\\.0+$','')
and d.freight_quantity regexp REGEXP_REPLACE(#{deliveryDetail.delivery.freightQuantity},'\\.0+$','')
and d.freight_price regexp REGEXP_REPLACE(#{deliveryDetail.delivery.freightPrice},'\\.0+$','')
order by dd.delivery_id,dd.delivery_number
select dd.delivery_id,
dd.delivery_number,
od.product_id,
od.product_name,
d.payment_terms,
d.project,
d.customer_id,
d.customer_name,
d.delivery_date,
d.pay_method,
d.pay_date,
d.salesman,
d.creator,
d.contacts,
d.contact_number,
d.delivery_address,
dd.order_id,
dd.order_number,
sum(dd.area) as area,
dd.price,
sum(dd.money) as money,
sum(dd.quantity) as quantity,
dd.delivery_detail_remakes,
dd.create_time,
o.other_money,
d.freight_price,
d.freight_quantity,
d.freight
from sd.delivery_detail dd left join delivery d on dd.delivery_id=d.delivery_id
left join order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
left join sd.`order` o on dd.order_id=o.order_id
and date(dd.create_time)>=#{startDate} and date(dd.create_time) <= #{endDate}
and dd.delivery_id like concat('%',#{deliveryDetail.deliveryId},'%')
and dd.delivery_number like concat('%',#{deliveryDetail.deliveryNumber},'%')
and dd.order_id like concat('%', #{deliveryDetail.orderId},'%')
and dd.order_number like concat('%', #{deliveryDetail.orderNumber},'%')
and dd.area regexp REGEXP_REPLACE(#{deliveryDetail.area},'\\.0+$','')
and dd.price regexp REGEXP_REPLACE(#{deliveryDetail.price},'\\.0+$','')
and dd.money regexp REGEXP_REPLACE(#{deliveryDetail.money},'\\.0+$','')
and dd.quantity regexp REGEXP_REPLACE(#{deliveryDetail.quantity},'\\.0+$','')
and dd.delivery_detail_remakes like concat('%', #{deliveryDetail.deliveryDetailRemakes},'%')
and dd.create_time like concat('%', #{deliveryDetail.createTime},'%')
and d.payment_terms like concat('%', #{deliveryDetail.delivery.paymentTerms},'%')
and d.project like concat('%', #{deliveryDetail.delivery.project},'%')
and d.customer_id like concat('%', #{deliveryDetail.delivery.customerId},'%')
and d.customer_name like concat('%', #{deliveryDetail.delivery.customerName},'%')
and d.delivery_date like concat('%', #{deliveryDetail.delivery.deliveryDate},'%')
and d.pay_method like concat('%', #{deliveryDetail.delivery.payMethod},'%')
and d.pay_date like concat('%', #{deliveryDetail.delivery.payDate},'%')
and d.salesman like concat('%', #{deliveryDetail.delivery.salesman},'%')
and d.creator like concat('%', #{deliveryDetail.delivery.creator},'%')
and d.contacts like concat('%', #{deliveryDetail.delivery.contacts},'%')
and d.contact_number like concat('%', #{deliveryDetail.delivery.contactNumber},'%')
and d.delivery_address like concat('%', #{deliveryDetail.delivery.deliveryAddress},'%')
and od.product_name like concat('%', #{deliveryDetail.orderDetail.productName},'%')
and od.product_id like concat('%', #{deliveryDetail.orderDetail.productId},'%')
and o.other_money regexp REGEXP_REPLACE(#{deliveryDetail.order.otherMoney},'\\.0+$','')
and d.freight regexp REGEXP_REPLACE(#{deliveryDetail.delivery.freight},'\\.0+$','')
and d.freight_quantity like concat('%', #{deliveryDetail.delivery.freightQuantity},'%')
and d.freight_price regexp REGEXP_REPLACE(#{deliveryDetail.delivery.freightPrice},'\\.0+$','')
group by dd.delivery_id,dd.order_id,od.product_id
order by dd.delivery_id,dd.delivery_number
limit #{offset},#{pageSize};
select
CEILING(count(zu.id)/#{pageSize}) as 'pageTotal',
count(zu.id) as 'total' from (
select dd.id as id
from sd.delivery_detail dd left join delivery d on dd.delivery_id=d.delivery_id
left join order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
left join sd.`order` o on dd.order_id=o.order_id
and date(dd.create_time)>=#{startDate} and date(dd.create_time) <= #{endDate}
and dd.delivery_id like concat('%',#{deliveryDetail.deliveryId},'%')
and dd.delivery_number like concat('%',#{deliveryDetail.deliveryNumber},'%')
and dd.order_id like concat('%', #{deliveryDetail.orderId},'%')
and dd.order_number like concat('%', #{deliveryDetail.orderNumber},'%')
and dd.area regexp REGEXP_REPLACE(#{deliveryDetail.area},'\\.0+$','')
and dd.price regexp REGEXP_REPLACE(#{deliveryDetail.price},'\\.0+$','')
and dd.money regexp REGEXP_REPLACE(#{deliveryDetail.money},'\\.0+$','')
and dd.quantity regexp REGEXP_REPLACE(#{deliveryDetail.quantity},'\\.0+$','')
and dd.delivery_detail_remakes like concat('%', #{deliveryDetail.deliveryDetailRemakes},'%')
and dd.create_time like concat('%', #{deliveryDetail.createTime},'%')
and d.payment_terms like concat('%', #{deliveryDetail.delivery.paymentTerms},'%')
and d.project like concat('%', #{deliveryDetail.delivery.project},'%')
and d.customer_id like concat('%', #{deliveryDetail.delivery.customerId},'%')
and d.customer_name like concat('%', #{deliveryDetail.delivery.customerName},'%')
and d.delivery_date like concat('%', #{deliveryDetail.delivery.deliveryDate},'%')
and d.pay_method like concat('%', #{deliveryDetail.delivery.payMethod},'%')
and d.pay_date like concat('%', #{deliveryDetail.delivery.payDate},'%')
and d.salesman like concat('%', #{deliveryDetail.delivery.salesman},'%')
and d.creator like concat('%', #{deliveryDetail.delivery.creator},'%')
and d.contacts like concat('%', #{deliveryDetail.delivery.contacts},'%')
and d.contact_number like concat('%', #{deliveryDetail.delivery.contactNumber},'%')
and d.delivery_address like concat('%', #{deliveryDetail.delivery.deliveryAddress},'%')
and od.product_name like concat('%', #{deliveryDetail.orderDetail.productName},'%')
and od.product_id like concat('%', #{deliveryDetail.orderDetail.productId},'%')
and o.other_money regexp REGEXP_REPLACE(#{deliveryDetail.order.otherMoney},'\\.0+$','')
and d.freight regexp REGEXP_REPLACE(#{deliveryDetail.delivery.freight},'\\.0+$','')
and d.freight_quantity like concat('%', #{deliveryDetail.delivery.freightQuantity},'%')
and d.freight_price regexp REGEXP_REPLACE(#{deliveryDetail.delivery.freightPrice},'\\.0+$','')
group by dd.delivery_id,dd.order_id,od.product_id) as zu
select dd.delivery_id,od.order_id,od.product_id,IF(#{type}='product_abbreviation',pt.remarks,od.product_name) as product_name,dd.price,sum(dd.area) as area,
sum(dd.money) as money,sum(dd.quantity) as quantity,o.contract_id,o.batch from
delivery_detail dd left join order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
left join product pt on pt.id=od.product_id
left join sd.`order` o on o.order_id=dd.order_id
where dd.delivery_id like concat('%',#{deliveryId},'%')
group by od.order_id,od.product_name,od.product_id
select dd.delivery_id,
od.order_id,
IF(#{type} = 'product_abbreviation', pt.remarks, od.product_name) as product_name,
dd.price,
sum(dd.area) as area,
sum(dd.money) as money,
sum(dd.quantity) as quantity,
o.contract_id,
od.width,
od.height
from delivery_detail dd
left join (select product_name,
order_id,
product_id,
order_number,
CASE
WHEN height < 4000 AND height >= 3660 and height>width THEN
'3660<H<4000'
WHEN height < 5000 AND height >= 4000 and height>width THEN
'4000<H<5000'
WHEN height < 6000 AND height >= 5000 and height>width THEN
'5000<H<6000'
WHEN height < 7000 AND height >= 6000 and height>width THEN
'6000<H<7000'
WHEN height < 8000 AND height >= 7000 and height>width THEN
'7000<H<8000'
WHEN height < 9000 AND height >= 8000 and height>width THEN
'8000<H<9000'
WHEN height < 10000 AND height >= 9000 and height>width THEN
'9000<H<10000'
WHEN height < 11000 AND height >= 10000 and height>width THEN
'10000<H<11000'
WHEN height < 12000 AND height >= 11000 and height>width THEN
'11000<H<12000'
ELSE
''
END height,
CASE
WHEN width < 4000 AND width >= 3660 and width>height THEN
'3660<H<4000'
WHEN width < 5000 AND width >= 4000 and width>height THEN
'4000<H<5000'
WHEN width < 6000 AND width >= 5000 and width>height THEN
'5000<H<6000'
WHEN width < 7000 AND width >= 6000 and width>height THEN
'6000<H<7000'
WHEN width < 8000 AND width >= 7000 and width>height THEN
'7000<H<8000'
WHEN width < 9000 AND width >= 8000 and width>height THEN
'8000<H<9000'
WHEN width < 10000 AND width >= 9000 and width>height THEN
'9000<H<10000'
WHEN width < 11000 AND width >= 10000 and width>height THEN
'10000<H<11000'
WHEN width < 12000 AND width >= 11000 and width>height THEN
'11000<H<12000'
ELSE
''
END width
from order_detail) as od on dd.order_id = od.order_id and dd.order_number = od.order_number
left join product pt on pt.id = od.product_id
left join sd.`order` o on o.order_id = dd.order_id
where dd.delivery_id like concat('%', #{deliveryId}, '%')
group by od.order_id, od.product_name,od.width,od.height, dd.price
select dd.delivery_id,
od.order_id,
IF(#{type} = 'product_abbreviation', pt.remarks, od.product_name) as product_name,
sum(dd.area) as area,
sum(dd.quantity) as quantity,
o.contract_id,
od.width,
od.height
from delivery_detail dd
left join (select product_name,
order_id,
product_id,
order_number,
CASE
WHEN height < 4000 AND height >= 3660 and height>width THEN
'3660<H<4000'
WHEN height < 5000 AND height >= 4000 and height>width THEN
'4000<H<5000'
WHEN height < 6000 AND height >= 5000 and height>width THEN
'5000<H<6000'
WHEN height < 7000 AND height >= 6000 and height>width THEN
'6000<H<7000'
WHEN height < 8000 AND height >= 7000 and height>width THEN
'7000<H<8000'
WHEN height < 9000 AND height >= 8000 and height>width THEN
'8000<H<9000'
WHEN height < 10000 AND height >= 9000 and height>width THEN
'9000<H<10000'
WHEN height < 11000 AND height >= 10000 and height>width THEN
'10000<H<11000'
WHEN height < 12000 AND height >= 11000 and height>width THEN
'11000<H<12000'
ELSE
''
END height,
CASE
WHEN width < 4000 AND width >= 3660 and width>height THEN
'3660<H<4000'
WHEN width < 5000 AND width >= 4000 and width>height THEN
'4000<H<5000'
WHEN width < 6000 AND width >= 5000 and width>height THEN
'5000<H<6000'
WHEN width < 7000 AND width >= 6000 and width>height THEN
'6000<H<7000'
WHEN width < 8000 AND width >= 7000 and width>height THEN
'7000<H<8000'
WHEN width < 9000 AND width >= 8000 and width>height THEN
'8000<H<9000'
WHEN width < 10000 AND width >= 9000 and width>height THEN
'9000<H<10000'
WHEN width < 11000 AND width >= 10000 and width>height THEN
'10000<H<11000'
WHEN width < 12000 AND width >= 11000 and width>height THEN
'11000<H<12000'
ELSE
''
END width
from order_detail) as od on dd.order_id = od.order_id and dd.order_number = od.order_number
left join product pt on pt.id = od.product_id
left join sd.`order` o on o.order_id = dd.order_id
where dd.delivery_id like concat('%', #{deliveryId}, '%')
group by od.order_id, od.product_name, width, height
select od.order_id,
od.building_number,
od.width,
od.height,
od.product_name,
sum(dd.area) as area,
sum(dd.money) as money,
sum(dd.quantity) as quantity,
dd.price
from delivery_detail dd
left join order_detail od on dd.order_id = od.order_id and dd.order_number = od.order_number
left join product p on od.product_id = p.id
where delivery_id = #{deliveryId}
and od.order_id = #{orderId}
and od.product_id = #{productId}
group by od.width,od.height, dd.price
select od.order_id,
od.building_number,
od.width,
od.height,
od.product_name,
sum(dd.area) as area,
sum(dd.quantity) as quantity
from delivery_detail dd
left join order_detail od on dd.order_id = od.order_id and dd.order_number = od.order_number
left join product p on od.product_id = p.id
where delivery_id = #{deliveryId}
and od.order_id = #{orderId}
and od.product_id = #{productId}
group by od.width,od.height
select od.order_id,od.product_id,od.product_name,sum(od.compute_gross_area) as area,sum(od.gross_amount) as gross_amount ,sum(od.quantity) as quantity from
order_detail od left join product p on od.product_id=p.id
where od.order_id = #{orderId}
and od.product_id = #{productId}
group by od.product_name,od.product_id ;
select od.order_id,
od.order_number,
od.product_name,
od.width,
od.height,
dd.quantity,
dd.money,
dd.area,
ifnull(od.processing_note,"") as processingNote,
ifnull(od.building_number,"") as buildingNumber,
dd.box_no,
dd.price,
od.other_columns,
od.remarks
from delivery_detail dd
left join order_detail od on dd.order_id = od.order_id and dd.order_number = od.order_number
left join product p on od.product_id = p.id
where delivery_id = #{deliveryId}
and od.order_id = #{orderId}
and od.product_id = #{productId}
select bom.alias,oom.price,#{value}*dd.quantity as count,oom.price*#{value}*dd.quantity as monery
from delivery_detail dd
left join order_detail od on dd.order_id = od.order_id and dd.order_number = od.order_number
left join order_other_money oom on oom.order_id=dd.order_id and oom.column=#{key}
left join basic_other_money bom on bom.`column`=oom.`column`
where delivery_id = #{deliveryId}
and od.order_id = #{orderId} and od.order_number=#{orderNumber} and (od.other_columns!='{}' or od.other_columns!=null)
select bom.alias,ifnull(oom.price,0) as price,#{value}*#{quantity} as count,ifnull(oom.price,0)*#{value}*#{quantity} as monery
from order_detail od
left join order_other_money oom on oom.order_id=od.order_id and oom.column=#{key}
left join basic_other_money bom on bom.`column`=oom.`column`
where od.order_id = #{orderId} and od.order_number=#{orderNumber} and (od.other_columns!='{}' or od.other_columns!=null)
select bom.alias,ifnull(oom.price,0) as price,#{value}*od.quantity as count,ifnull(oom.price,0)*#{value}*od.quantity as monery
from order_detail od
left join order_other_money oom on oom.order_id=od.order_id and oom.column=#{key}
left join basic_other_money bom on bom.`column`=oom.`column`
where od.order_id = #{orderId} and od.order_number=#{orderNumber} and (od.other_columns!='{}' or od.other_columns!=null)
select od.order_id,
od.order_number,
od.product_name,
od.width,
od.height,
od.quantity,
od.gross_amount,
od.compute_gross_area,
od.area,
ifnull(od.processing_note,"") as processingNote,
ifnull(od.building_number,"") as buildingNumber,
od.price,
od.other_columns,
od.remarks
from order_detail od
where od.order_id = #{orderId}
and od.product_id = #{productId}
select dd.id,
dd.delivery_id,
dd.delivery_number,
od.product_id,
od.product_name,
d.payment_terms,
d.project,
d.customer_id,
d.customer_name,
c.customer_abbreviation,
d.delivery_date,
d.pay_method,
d.pay_date,
d.salesman,
d.creator,
d.contacts,
d.contact_number,
d.delivery_address,
dd.order_id,
dd.order_number,
dd.area,
dd.price,
dd.money,
dd.quantity,
dd.delivery_detail_remakes,
dd.create_time,
o.other_money,
d.freight,
d.freight_price,
d.freight_quantity,
od.width,
od.height,
o.batch,
od.building_number,
dd.box_no
from sd.delivery_detail dd
left join sd.delivery d on dd.delivery_id=d.delivery_id
left join order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
left join sd.`order` o on dd.order_id=o.order_id
left join sd.customer c on d.customer_id=c.id
where date(d.create_time)>=#{dates[0]} and date(d.create_time) <= #{dates[1]}
select dd.id,
dd.delivery_id,
dd.delivery_number,
od.product_id,
od.product_name,
d.payment_terms,
d.project,
d.customer_id,
d.customer_name,
c.customer_abbreviation,
d.delivery_date,
d.pay_method,
d.pay_date,
d.salesman,
d.creator,
d.contacts,
d.contact_number,
d.delivery_address,
dd.order_id,
dd.order_number,
sum(dd.area) as area,
sum(dd.money) as money,
sum(dd.quantity) as quantity,
dd.delivery_detail_remakes,
dd.price,
dd.create_time,
o.other_money,
d.freight,
d.freight_price,
d.freight_quantity
from sd.delivery_detail dd left join delivery d on dd.delivery_id=d.delivery_id
left join order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
left join sd.`order` o on dd.order_id=o.order_id
left join sd.customer c on d.customer_id=c.id
where date(d.create_time)>=#{dates[0]} and date(d.create_time) <= #{dates[1]}
group by dd.delivery_id,dd.order_id,od.product_id
order by dd.delivery_id,dd.delivery_number