<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.casic.missiles.mapper.finance.FinanceAgreementInfoMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.casic.missiles.model.finance.FinanceAgreementInfo">
<id column="id" property="id" />
<result column="agreement_no" property="agreementNo" />
<result column="agreement_name" property="agreementName" />
<result column="agreement_kind" property="agreementKind" />
<result column="agreement_type" property="agreementType" />
<result column="dept_id" property="deptId" />
<result column="dept_name" property="deptName" />
<result column="estimate_sign_date" property="estimateSignDate" />
<result column="agreement_amount" property="agreementAmount" />
<result column="agreement_source" property="agreementSource" />
<result column="agreement_start_date" property="agreementStartDate" />
<result column="agreement_end_date" property="agreementEndDate" />
<result column="customer_id" property="customerId" />
<result column="first_party" property="firstParty" />
<result column="director" property="director" />
<result column="second_director" property="secondDirector" />
<result column="second_party" property="secondParty" />
<result column="agreement_important_content" property="agreementImportantContent" />
<result column="minio_file_name" property="minioFileName" />
<result column="status" property="status" />
<result column="approval_status" property="approvalStatus" />
<result column="process_id" property="processId" />
<result column="remark" property="remark" />
<result column="create_user" property="createUser" />
<result column="create_user_name" property="createUserName" />
<result column="is_del" property="isDel" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
<select id="selectDraftListForApproval" resultType="com.casic.missiles.model.finance.FinanceAgreementInfo">
SELECT *
FROM finance_agreement_info
WHERE is_del = 0
AND approval_status = #{request.approvalStatus}
AND create_user = #{request.createUserId}
<if test="request.agreementNo != null and request.agreementNo !=''">
and agreement_no like concat('%',#{request.agreementNo},'%')
</if>
<if test="request.agreementName != null and request.agreementName !=''">
and agreement_name like concat('%',#{request.agreementName},'%')
</if>
<if test="request.agreementKind != null and request.agreementKind !=''">
and agreement_kind = #{request.agreementKind}
</if>
<if test="request.agreementType != null and request.agreementType !=''">
and agreement_type = #{request.agreementType}
</if>
<if test="request.customerId != null and request.customerId !=''">
and customer_id = #{request.customerId}
</if>
<if test="request.firstParty != null and request.firstParty !=''">
and first_party like concat('%',#{request.firstParty},'%')
</if>
<if test="request.estimateSignStartDate != null and request.estimateSignStartDate !=''">
and estimate_sign_date >= #{request.estimateSignStartDate}
</if>
<if test="request.estimateSignEndDate != null and request.estimateSignEndDate !=''">
and estimate_sign_date <= #{request.estimateSignEndDate}
</if>
<if test="request.status != null and request.status !=''">
and status = #{request.status}
</if>
</select>
<select id="selectBatchForApproval" resultType="com.casic.missiles.model.finance.FinanceAgreementInfo">
SELECT *
FROM finance_agreement_info
WHERE is_del = 0
<if test="request.agreementNo != null and request.agreementNo !=''">
and agreement_no like concat('%',#{request.agreementNo},'%')
</if>
<if test="request.agreementName != null and request.agreementName !=''">
and agreement_name like concat('%',#{request.agreementName},'%')
</if>
<if test="request.agreementKind != null and request.agreementKind !=''">
and agreement_kind = #{request.agreementKind}
</if>
<if test="request.agreementType != null and request.agreementType !=''">
and agreement_type = #{request.agreementType}
</if>
<if test="request.customerId != null and request.customerId !=''">
and customer_id = #{request.customerId}
</if>
<if test="request.firstParty != null and request.firstParty !=''">
and first_party like concat('%',#{request.firstParty},'%')
</if>
<if test="request.estimateSignStartDate != null and request.estimateSignStartDate !=''">
and estimate_sign_date >= #{request.estimateSignStartDate}
</if>
<if test="request.estimateSignEndDate != null and request.estimateSignEndDate !=''">
and estimate_sign_date <= #{request.estimateSignEndDate}
</if>
<if test="request.status != null and request.status !=''">
and status = #{request.status}
</if>
and id in
<foreach collection="businessKey" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</select>
<select id="selectMaxAgreementNo" resultType="java.lang.Long">
SELECT IFNULL(max(RIGHT(agreement_no, 12)), 0) FROM finance_agreement_info
</select>
<select id="selectCustomerExcellentList" resultType="com.casic.missiles.dto.customer.CustomerExcellentResponse">
SELECT first_party AS customerName, SUM(agreement_amount) AS totalAmount
FROM finance_agreement_info
WHERE is_del = 0
GROUP BY first_party
ORDER BY SUM(agreement_amount) DESC
LIMIT 10
</select>
</mapper>