| | |
| | | <select id="contractIncomeAnalysis" |
| | | resultType="com.by4cloud.platformx.business.vo.ContractIncomeAnalysisVo"> |
| | | SELECT |
| | | compName, |
| | | compId, |
| | | SUM(CASE WHEN month_num = 1 THEN total_amount ELSE 0 END) AS 'srMonth1', |
| | | SUM(CASE WHEN month_num = 1 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'xhMonth1', |
| | | SUM(CASE WHEN month_num = 1 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth1', |
| | |
| | | SUM(CASE WHEN month_num = 4 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth4', |
| | | SUM(CASE WHEN month_num = 4 AND pay_type = 3 THEN total_amount ELSE 0 END) AS 'qtMonth4', |
| | | SUM(CASE WHEN month_num = 5 THEN total_amount ELSE 0 END) AS 'srMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 0 THEN total_amount ELSE 0 END) AS 'xhMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'cdMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'qtMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'xhMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 3 THEN total_amount ELSE 0 END) AS 'qtMonth5', |
| | | SUM(CASE WHEN month_num = 6 THEN total_amount ELSE 0 END) AS 'srMonth6', |
| | | SUM(CASE WHEN month_num = 6 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'xhMonth6', |
| | | SUM(CASE WHEN month_num = 6 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth6', |
| | |
| | | SUM(CASE WHEN month_num = 12 AND pay_type = 3 THEN total_amount ELSE 0 END) AS 'qtMonth12' |
| | | FROM ( |
| | | SELECT |
| | | COALESCE(pc.payee_comp_id, '未知单位') AS compName, |
| | | COALESCE(pc.payee_comp_id, '未知单位') AS compId, |
| | | MONTH(payment_time) AS month_num, |
| | | pay_type, |
| | | COALESCE(payment_amount, 0) AS total_amount |
| | |
| | | #{id} |
| | | </foreach> |
| | | ) AS source_data |
| | | GROUP BY compName |
| | | GROUP BY compId |
| | | |
| | | </select> |
| | | <select id="contractIncomeAnalysisByComp" |
| | |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract |
| | | contract ct |
| | | WHERE |
| | | party_b_id IN |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract |
| | | contract ct |
| | | WHERE |
| | | party_b_id IN |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract |
| | | contract ct |
| | | WHERE |
| | | party_b_id IN |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract |
| | | contract ct |
| | | WHERE |
| | | party_b_id IN |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract |
| | | contract ct |
| | | WHERE |
| | | party_b_id IN |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | |
| | | FROM |
| | | contract c |
| | | WHERE |
| | | c.supply_attribute IS NOT NULL |
| | | c.del_flag = '0' |
| | | and c.supply_attribute IS NOT NULL |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | GROUP BY |
| | | c.supply_attribute |
| | |
| | | ORDER BY m.month_num |
| | | |
| | | </select> |
| | | <select id="contractAmountAnalysisBySaleModel" |
| | | resultType="com.by4cloud.platformx.business.vo.ContractIncomeAnalysisAreaVo"> |
| | | SELECT |
| | | b.sales_model area_id, |
| | | SUM( CASE WHEN c.party_b_id = #{sgbCompId} THEN c.amount ELSE 0 END ) AS sgbze, |
| | | ROUND( |
| | | SUM( CASE WHEN c.party_b_id = #{sgbCompId} THEN c.amount ELSE 0 END ) / ( |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract c, business_customer bc |
| | | WHERE |
| | | bc.id = c.party_a_id |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) * 100, |
| | | 2 |
| | | ) AS sgbzb, |
| | | SUM( CASE WHEN c.party_b_id = #{jxcCompId} THEN c.amount ELSE 0 END ) AS jxcze, |
| | | ROUND( |
| | | SUM( CASE WHEN c.party_b_id = #{jxcCompId} THEN c.amount ELSE 0 END ) / ( |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract c, business_customer bc |
| | | WHERE |
| | | bc.id = c.party_a_id |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) * 100, |
| | | 2 |
| | | ) AS jxczb , |
| | | SUM( CASE WHEN c.party_b_id = #{smjCompId} THEN c.amount ELSE 0 END ) AS smjze, |
| | | ROUND( |
| | | SUM( CASE WHEN c.party_b_id = #{smjCompId} THEN c.amount ELSE 0 END ) / ( |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract c, business_customer bc |
| | | WHERE |
| | | bc.id = c.party_a_id |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) * 100, |
| | | 2 |
| | | ) AS smjzb , |
| | | SUM( CASE WHEN c.party_b_id = #{ymjCompId} THEN c.amount ELSE 0 END ) AS ymjze, |
| | | ROUND( |
| | | SUM( CASE WHEN c.party_b_id = #{ymjCompId} THEN c.amount ELSE 0 END ) / ( |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract c, business_customer bc |
| | | WHERE |
| | | bc.id = c.party_a_id |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) * 100, |
| | | 2 |
| | | ) AS ymjzb , |
| | | SUM( CASE WHEN c.party_b_id = #{tfCompId} THEN c.amount ELSE 0 END ) AS tfze, |
| | | ROUND( |
| | | SUM( CASE WHEN c.party_b_id = #{tfCompId} THEN c.amount ELSE 0 END ) / ( |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract c, business_customer bc |
| | | WHERE |
| | | bc.id = c.party_a_id |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) * 100, |
| | | 2 |
| | | ) AS tfzb |
| | | FROM |
| | | contract c |
| | | JOIN business_customer b ON c.party_a_id = b.id |
| | | WHERE |
| | | b.sales_model IS NOT NULL |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | GROUP BY |
| | | b.sales_model |
| | | |
| | | </select> |
| | | <select id="pageScope" resultType="com.by4cloud.platformx.business.vo.ContractPageVo"> |
| | | SELECT |
| | | id, |
| | | contract_no, |
| | | contract_name, |
| | | party_a_id, |
| | | party_a, |
| | | party_b_id, |
| | | party_b, |
| | | amount, |
| | | currency, |
| | | contract_type, |
| | | supply_attribute, |
| | | contract_status, |
| | | contract_attribute, |
| | | sign_date, |
| | | sign_place, |
| | | effective_date, |
| | | delivery_cycle, |
| | | expiration_date, |
| | | attachment_url, |
| | | remark, |
| | | parent_id, |
| | | approve_time, |
| | | arrival_schedule_id, |
| | | accept_schedule_id, |
| | | erp_push_flag, |
| | | billing_status, |
| | | billing_amout, |
| | | next_schedule_name, |
| | | template_id, |
| | | sales_model, |
| | | paid_amount, |
| | | contract_category, |
| | | exec_frequency, |
| | | exec_times, |
| | | exec_day, |
| | | environment, |
| | | standard, |
| | | use_month, |
| | | after_ship_month, |
| | | ship_method, |
| | | ship_address, |
| | | packaging, |
| | | repair_period, |
| | | repair_breach_amount, |
| | | goods_short, |
| | | goods_short_breach_amount, |
| | | overdue_breach_amount, |
| | | terminate_contract, |
| | | court, |
| | | contract_attchment, |
| | | city, |
| | | region, |
| | | invoice_notice, |
| | | contract_tax, |
| | | create_by, |
| | | update_by, |
| | | create_time, |
| | | update_time, |
| | | del_flag, |
| | | comp_id, |
| | | (select sum(delivered_quantity*unit_price) from contract_subject_matter csm where csm.contract_id = c.id) outAmount |
| | | FROM |
| | | contract c |
| | | WHERE |
| | | del_flag = '0' |
| | | <if test="queryDTO.contractName !=null and queryDTO.contractName !=''"> |
| | | AND contract_name LIKE CONCAT('%', #{queryDTO.contractName}, '%') |
| | | </if> |
| | | <if test="queryDTO.partyA !=null and queryDTO.partyA !=''"> |
| | | AND party_a LIKE CONCAT('%', #{queryDTO.partyA}, '%') |
| | | </if> |
| | | <if test="queryDTO.contractStatus !=null and queryDTO.contractStatus !=''"> |
| | | AND contract_status = #{queryDTO.contractStatus} |
| | | </if> |
| | | ORDER BY |
| | | create_time DESC |
| | | </select> |
| | | </mapper> |