id, major_id, deleted, created, modified, report_no, production,signatory, name, client_name, client_tel, client_address, owner, value_timing, evaluate_acreage, evaluate_amount, evaluate_price , comment,qr_code,repertory_state,first_check,second_check,third_check,save_file_check,save_file_second_check,if_save_file SELECT mp.id AS id, m.id as businessId, m.order_id, IF(mp.name IS NULL, m.name, mp.name) AS orderName, mp.report_no as productionNo, mp.production, mp.if_save_file, mp.evaluate_amount, u.name as principal, u1.name as clientManager, cc.name as clienteleName, cc1.name as clienteleSubName, cl.name as clienteleContactName, m.bailor, m.owner, m.created, orf.id as orderFundId, orf.should_amount as orderShouldAmount, orf.real_amount as orderRealAmount, pf.remark, pf.id as productionFundId, pf.real_amount, pf.production_should_amount as shouldAmount, fi.invoiceAmount, mp.delivery, ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 ) as mDeclareResult, ( SELECT declare_result FROM commission_declare WHERE business_id = m.id AND production_id IS NULL AND business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 ) as eDeclareResult FROM major m left join (select id,name,major_id,report_no,evaluate_amount,production,if_save_file,delivery from major_production where deleted = 0 ) mp on mp.major_id = m.id left join user u on u.id = m.principal_id left join user u1 on u1.id = m.client_manager_id left join customer_company cc on cc.id = m.clientele_id left join customer_company cc1 on cc1.id = m.clientele_sub_id left join customer_linkman cl on cl.id = m.clientele_contact_id left join (select * from order_fund where business_type ='MAJOR_BUSINESS' and deleted = 0) orf on orf.business_id = m.id left join (select * from production_fund where business_type = 'MAJOR_BUSINESS' and deleted = 0) pf on (pf.business_id = m.id and pf.production_no = mp.report_no and mp.production = pf.production_type) left join (select sum(real_amount) as invoiceAmount,order_fund_id,production_fund_id from finance_invoice where state='已开票' and deleted = 0 group by production_fund_id) fi on (fi.order_fund_id = orf.id and fi.production_fund_id = pf.id) where m.deleted = 0 and m.client_manager_id = #{vo.clientManagerId} and ( m.name like concat ('%',#{keyword},'%') or m.order_id like concat('%',#{keyword},'%') or u.name like concat('%',#{keyword},'%') or u1.name like concat('%',#{keyword},'%') or cc.name like concat('%',#{keyword},'%') or cc1.name like concat('%',#{keyword},'%') or cl.name like concat('%',#{keyword},'%') or m.bailor like concat('%',#{keyword},'%') or m.owner like concat('%',#{keyword},'%') or orf.should_amount like concat('%',#{keyword},'%') or orf.real_amount like concat('%',#{keyword},'%') or orf.remark like concat('%',#{keyword},'%') or mp.report_no like concat('%',#{keyword},'%') ) AND m.principal_id like concat('%',#{vo.principalId},'%') AND m.order_id like concat('%',#{vo.orderId},'%') AND mp.report_no like concat('%',#{vo.productionNo},'%') AND cc.name like concat('%',#{vo.clienteleName},'%') AND cc1.name like concat('%',#{vo.clienteleSubName},'%') and m.created >= #{vo.startDate} and m.created <= #{vo.endDate} AND mp.production = #{vo.production} AND mp.id is null AND mp.delivery = #{vo.delivery} AND (mp.delivery = #{vo.delivery} OR mp.delivery IS NULL) AND (pf.real_amount IS NOT NULL OR pf.real_amount > 0) AND (pf.real_amount IS NULL OR pf.real_amount = 0) AND (orf.should_amount IS NOT NULL OR orf.should_amount > 0 OR pf.production_should_amount IS NOT NULL OR pf.production_should_amount > 0) AND (orf.should_amount IS NULL OR orf.should_amount = 0) AND (pf.production_should_amount IS NULL OR pf.production_should_amount = 0) order by m.created DESC update major_production set if_save_file = 1 ,save_file_date= now() where id in ( #{item} ) update major_production set delivery = 0 ,delivery_date = null where major_id = #{businessId} and report_no = #{businessSubId} and production = #{productionType}