left join mini_supplier_info msi on msi.id = mpo.supplier
left join sys_user su on su.user_id = mpo.purchaser
where 1 = 1
?{documentNumber != null and documentNumber != '', and mpo.document_number = #{documentNumber}}
?{documentNumber != null and documentNumber != '', and mpo.document_number like concat('%', #{documentNumber} ,'%')}
?{supplier != null and supplier != '', and mpo.supplier = #{supplier}}
?{purchaseDate != null and purchaseDate != '', and mpo.purchase_date = #{purchaseDate}}
?{purchaseDateRang != null and purchaseDateRang != '' and purchaseDateRang.size() > 0, and date(mpo.purchase_date) between #{purchaseDateRang[0]} and #{purchaseDateRang[1]}}
?{purchaser != null and purchaser != '', and mpo.purchaser = #{purchaser}}
?{price != null and price != '', and mpo.price = #{price}}
?{deliveryDate != null and deliveryDate != '', and mpo.delivery_date = #{deliveryDate}}
?{deliveryDateRang != null and deliveryDateRang != '' and deliveryDateRang.size() > 0, and date(mpo.delivery_date) between #{deliveryDateRang[0]} and #{deliveryDateRang[1]}}
?{status != null and status != '', and mpo.status = #{status}}
"""
// ?{purchaseDate != null and purchaseDate != '', and mpo.purchase_date = #{purchaseDate}}
// ?{deliveryDate != null and deliveryDate != '', and mpo.delivery_date = #{deliveryDate}}
List salesDateRang = body.salesDateRang; // 销售日期范围
List deliveryDateRang = body.deliveryDateRang; // 交货日期范围
var sql = """
select
mso.id,
@ -78,12 +85,17 @@ var sql = """
left join mini_customer_info mci on mci.customer_code = mso.customer_id
where 1 = 1
?{documentNumber != null and documentNumber != '', and mso.document_number like concat('%', #{documentNumber}, '%')}
?{salesperson != null and salesperson != '', and mso.salesperson like concat('%', #{salesperson}, '%')}
?{salesDate != null and salesDate != '', and mso.sales_date like concat('%', #{salesDate}, '%')}
?{price != null and price != '', and mso.price = #{price}}
?{customerId != null and customerId != '', and mso.customer_id like concat('%', #{customerId}, '%')}
?{deliveryDate != null and deliveryDate != '', and mso.delivery_date = #{deliveryDate}}
?{status != null and status != '', and mso.status = #{status}}
?{salesperson != null and salesperson != '', and mso.salesperson = #{salesperson}}
?{remarks != null and remarks != '', and mso.remarks like concat('%', #{remarks}, '%')}
?{customerId != null and customerId != '', and mso.customer_id = #{customerId}}
?{salesDateRang != null and salesDateRang != '' and salesDateRang.size() > 0, and date(mso.sales_date) between #{salesDateRang[0]} and #{salesDateRang[1]}}
?{deliveryDateRang != null and deliveryDateRang != '' and deliveryDateRang.size() > 0, and date(mso.delivery_date) between #{deliveryDateRang[0]} and #{deliveryDateRang[1]}}
left join mini_sales_orders mso on msom.sales_order_code = mso.document_number
left join mini_surface_methods msm on msm.color_code = msom.surface_method
left join sys_user su on su.user_id = mso.salesperson
left join mini_customer_info mci on mci.customer_code = mso.customer_id
left join mini_warehouse_product mwp on
mwp.order_no = msom.order_no
and mwp.sales_order_code = msom.sales_order_code
where 1=1
?{salesOrderCode != null and salesOrderCode != "", and msom.sales_order_code list concat('%',#{salesOrderCode},'%') }
?{status != null and status != "", and msom.status = #{status} }
@ -91,4 +109,15 @@ return db.page("""
?{profileModel != null and profileModel != '', and msom.profile_model like concat('%', #{profileModel}, '%')}
?{customerId != null and customerId != '', and mso.customer_id = #{customerId}}
?{surfaceMethod != null and surfaceMethod != '', and msom.surface_method = #{surfaceMethod}}
?{salesperson != null and salesperson != '', and mso.salesperson = #{salesperson}}
?{salesDateRang != null and salesDateRang != '' and salesDateRang.size() > 0, and date(mso.sales_date) between #{salesDateRang[0]} and #{salesDateRang[1]}}
?{deliveryDateRang != null and deliveryDateRang != '' and deliveryDateRang.size() > 0, and date(mso.delivery_date) between #{deliveryDateRang[0]} and #{deliveryDateRang[1]}}
?{materialName != null and materialName != '', and msom.material_name like concat('%', #{materialName}, '%')}
?{specification != null and specification != '', and msom.specification like concat('%', #{specification}, '%')}
?{orderLength != null and orderLength != '', and msom.order_length = #{orderLength}}
on mesd.sales_order_code = msm.sales_order_code and mesd.material_code = msm.material_code and mesd.order_no = msm.order_no
left join mini_sales_orders mso on mso.document_number = msm.sales_order_code
left join sys_user su2 on su2.user_id = mso.salesperson
left join (select schedule_number, sales_order_code, material_code, order_no, sum(production_number) as production_number, sum(production_weight) as production_weight
from mini_process_report where is_completed = 1 group by schedule_number, sales_order_code, material_code, order_no) mpr
on mesd.schedule_number = mpr.schedule_number and mesd.sales_order_code = mpr.sales_order_code
and mesd.material_code = mpr.material_code and mesd.order_no = mpr.order_no
where 1=1
?{scheduleNumber != null and scheduleNumber != '', and mesd.schedule_number like concat('%', #{scheduleNumber}, '%')}
?{salesOrderCode != null and salesOrderCode != '', and msm.sales_order_code like concat('%', #{salesOrderCode}, '%')}
@ -64,6 +80,14 @@ var list = db.page("""
?{extrusionDate!=null && extrusionDate!="", and date(mes.extrusion_date) = #{extrusionDate} }
?{customerId != null and customerId != '', and mso.customer_id = #{customerId}}
?{surfaceMethod != null and surfaceMethod != '', and msm.surface_method = #{surfaceMethod}}
?{extrusionDateRang != null and extrusionDateRang != '' and extrusionDateRang.size() > 0,
and date(mes.extrusion_date) between #{extrusionDateRang[0]} and #{extrusionDateRang[1]}}
?{extrusionMachine != null and extrusionMachine != '', and mes.extrusion_machine = #{extrusionMachine}}
?{extrusionTeam != null and extrusionTeam != '', and mes.extrusion_team = #{extrusionTeam}}
?{materialName != null and materialName != '', and msm.material_name like concat('%', #{materialName}, '%')}
?{specification != null and specification != '', and msm.specification like concat('%', #{specification}, '%')}
?{orderLength != null and orderLength != '', and msm.order_length = #{orderLength}}
on mesd.sales_order_code = msm.sales_order_code and mesd.material_code = msm.material_code and mesd.order_no = msm.order_no
left join mini_sales_orders mso on mso.document_number = msm.sales_order_code
left join sys_user su2 on su2.user_id = mso.salesperson
left join (select schedule_number, sales_order_code, material_code, order_no, sum(production_number) as production_number, sum(production_weight) as production_weight
from mini_process_report where is_completed = 1 group by schedule_number, sales_order_code, material_code, order_no) mpr
on mesd.schedule_number = mpr.schedule_number and mesd.sales_order_code = mpr.sales_order_code
and mesd.material_code = mpr.material_code and mesd.order_no = mpr.order_no
where 1=1
?{scheduleNumber != null and scheduleNumber != '', and mesd.schedule_number like concat('%', #{scheduleNumber}, '%')}
?{salesOrderCode != null and salesOrderCode != '', and msm.sales_order_code like concat('%', #{salesOrderCode}, '%')}
@ -66,4 +77,12 @@ return db.selectInt("""
?{extrusionDate!=null && extrusionDate!="", and date(mes.extrusion_date) = #{extrusionDate} }
?{customerId != null and customerId != '', and mso.customer_id = #{customerId}}
?{surfaceMethod != null and surfaceMethod != '', and msm.surface_method = #{surfaceMethod}}
?{extrusionDateRang != null and extrusionDateRang != '' and extrusionDateRang.size() > 0,
and date(mes.extrusion_date) between #{extrusionDateRang[0]} and #{extrusionDateRang[1]}}
?{extrusionMachine != null and extrusionMachine != '', and mes.extrusion_machine = #{extrusionMachine}}
?{extrusionTeam != null and extrusionTeam != '', and mes.extrusion_team = #{extrusionTeam}}
?{materialName != null and materialName != '', and msm.material_name like concat('%', #{materialName}, '%')}
?{specification != null and specification != '', and msm.specification like concat('%', #{specification}, '%')}
?{orderLength != null and orderLength != '', and msm.order_length = #{orderLength}}