|
|
|
|
@ -6,25 +6,25 @@
|
|
|
|
|
|
|
|
|
|
<select id="selectContractLedgerList" resultType="org.dromara.oa.erp.domain.vo.ContractLedgerReportVo">
|
|
|
|
|
SELECT
|
|
|
|
|
c.contract_id,
|
|
|
|
|
t.contract_id,
|
|
|
|
|
<!-- 合同信息 -->
|
|
|
|
|
c.internal_contract_code,
|
|
|
|
|
c.external_contract_code,
|
|
|
|
|
c.customer_contract_code,
|
|
|
|
|
DATE_FORMAT(c.contract_date, '%Y-%m-%d') AS contract_date,
|
|
|
|
|
DATE_FORMAT(c.create_time, '%Y-%m') AS month,
|
|
|
|
|
c.order_contract_code,
|
|
|
|
|
c.project_contract_code,
|
|
|
|
|
t.internal_contract_code,
|
|
|
|
|
t.external_contract_code,
|
|
|
|
|
t.customer_contract_code,
|
|
|
|
|
DATE_FORMAT(t.contract_date, '%Y-%m-%d') AS contract_date,
|
|
|
|
|
DATE_FORMAT(t.create_time, '%Y-%m') AS month,
|
|
|
|
|
t.order_contract_code,
|
|
|
|
|
t.project_contract_code,
|
|
|
|
|
cust.customer_name AS customer_name,
|
|
|
|
|
mat_sub.product_name AS product_name,
|
|
|
|
|
c.mesnac_contract_price,
|
|
|
|
|
c.total_price,
|
|
|
|
|
c.payment_method,
|
|
|
|
|
c.delivery_start,
|
|
|
|
|
c.warranty_period,
|
|
|
|
|
t.mesnac_contract_price,
|
|
|
|
|
t.total_price,
|
|
|
|
|
t.payment_method,
|
|
|
|
|
t.delivery_start,
|
|
|
|
|
t.warranty_period,
|
|
|
|
|
u1.nick_name AS contract_manager_name,
|
|
|
|
|
d.dept_name AS contract_dept_name,
|
|
|
|
|
c.business_direction,
|
|
|
|
|
t.business_direction,
|
|
|
|
|
<!-- 项目基本信息 -->
|
|
|
|
|
p.project_code,
|
|
|
|
|
p.project_name,
|
|
|
|
|
@ -32,48 +32,21 @@
|
|
|
|
|
pt.type_name,
|
|
|
|
|
<!-- 备注 -->
|
|
|
|
|
fcust.customer_name AS final_customer_name
|
|
|
|
|
FROM erp_contract_info c
|
|
|
|
|
FROM erp_contract_info t
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT contract_id, GROUP_CONCAT(DISTINCT product_name SEPARATOR ',') AS product_name
|
|
|
|
|
FROM erp_contract_material
|
|
|
|
|
WHERE del_flag = '0'
|
|
|
|
|
GROUP BY contract_id
|
|
|
|
|
) mat_sub ON c.contract_id = mat_sub.contract_id
|
|
|
|
|
LEFT JOIN crm_customer_info cust ON c.one_customer_id = cust.customer_id AND cust.del_flag = '0'
|
|
|
|
|
LEFT JOIN sys_user u1 ON u1.user_id = c.contract_manager_id
|
|
|
|
|
LEFT JOIN sys_dept d ON d.dept_id = c.contract_dept_id
|
|
|
|
|
LEFT JOIN erp_project_contracts pc ON pc.contract_id = c.contract_id AND pc.del_flag = '0'
|
|
|
|
|
) mat_sub ON t.contract_id = mat_sub.contract_id
|
|
|
|
|
LEFT JOIN crm_customer_info cust ON t.one_customer_id = cust.customer_id AND cust.del_flag = '0'
|
|
|
|
|
LEFT JOIN sys_user u1 ON u1.user_id = t.contract_manager_id
|
|
|
|
|
LEFT JOIN sys_dept d ON d.dept_id = t.contract_dept_id
|
|
|
|
|
LEFT JOIN erp_project_contracts pc ON pc.contract_id = t.contract_id AND pc.del_flag = '0'
|
|
|
|
|
LEFT JOIN erp_project_info p ON p.project_id = pc.project_id AND p.del_flag = '0'
|
|
|
|
|
LEFT JOIN sys_user u2 ON u2.user_id = p.manager_id
|
|
|
|
|
LEFT JOIN erp_project_type pt ON pt.project_type_id = p.project_type_id
|
|
|
|
|
LEFT JOIN crm_customer_info fcust ON c.final_customer_id = fcust.customer_id AND fcust.del_flag = '0'
|
|
|
|
|
<where>
|
|
|
|
|
c.del_flag = '0'
|
|
|
|
|
<if test="bo.contractIdList != null and bo.contractIdList.size() > 0">
|
|
|
|
|
AND c.contract_id IN
|
|
|
|
|
<foreach collection="bo.contractIdList" item="id" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.customerContractCode != null and bo.customerContractCode != ''">
|
|
|
|
|
AND c.customer_contract_code LIKE CONCAT('%', #{bo.customerContractCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.internalContractCode != null and bo.internalContractCode != ''">
|
|
|
|
|
AND c.internal_contract_code LIKE CONCAT('%', #{bo.internalContractCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.projectCode != null and bo.projectCode != ''">
|
|
|
|
|
AND p.project_code LIKE CONCAT('%', #{bo.projectCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.businessDirection != null and bo.businessDirection != ''">
|
|
|
|
|
AND c.business_direction = #{bo.businessDirection}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.params != null and bo.params.beginContractDate != null and bo.params.beginContractDate != ''">
|
|
|
|
|
AND DATE_FORMAT(c.contract_date,'%y%m%d') >= DATE_FORMAT(#{bo.params.beginContractDate},'%y%m%d')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bo.params != null and bo.params.endContractDate != null and bo.params.endContractDate != ''">
|
|
|
|
|
AND DATE_FORMAT(c.contract_date,'%y%m%d') <= DATE_FORMAT(#{bo.params.endContractDate},'%y%m%d')
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
ORDER BY c.create_time DESC
|
|
|
|
|
LEFT JOIN crm_customer_info fcust ON t.final_customer_id = fcust.customer_id AND fcust.del_flag = '0'
|
|
|
|
|
${ew.customSqlSegment}
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|
|
|
|
|
|