|
@@ -15,26 +15,173 @@
|
|
|
<select id="getTotal" resultType="java.lang.Integer">
|
|
|
SELECT COUNT(1) FROM (<include refid="getListSql"/>) AS C
|
|
|
</select>
|
|
|
- <select id="statistics" resultType="java.util.List">
|
|
|
+ <select id="statistics" resultType="resStatisticsVo" >
|
|
|
+ SELECT
|
|
|
+ tt1.company_id as companyId,
|
|
|
+ tt1.name as companyName,
|
|
|
+ tt1.task_type_id as taskTypeId,
|
|
|
+ tt1.typeName,
|
|
|
+ tt1.contract_id as contractId,
|
|
|
+ tt1.contract_no as contractNo,
|
|
|
+ date_format(tt1.daozhangriqi, '%Y-%m-%d') as receiptDate,
|
|
|
+ tt1.tishoukuanjine as withdrawalAmount,
|
|
|
+ tt1.hetongleixing as contractType,
|
|
|
+ tt1.shenqingren as applierName,
|
|
|
+ tt1.shifouweixiangmu as isProject,
|
|
|
+ tt1.fuwujine as detailAllAmount,
|
|
|
+ tt1.shishoujine as reallyDetailAmount,
|
|
|
+ tt1.daishoukuanjine as waitDetailAmount,
|
|
|
+ tt1.shenheshijian as examineTime,
|
|
|
+ tt2.zhichu as outAmount
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ c.company_id,
|
|
|
+ com.NAME,
|
|
|
+ detail.task_type_id,
|
|
|
+ type.`name` as typeName,
|
|
|
+ c.contract_id,
|
|
|
+ input.contract_no,
|
|
|
+ GROUP_CONCAT( DISTINCT arrive_date ) AS daozhangriqi,
|
|
|
+ SUM( detail.arrive_amount ) AS tishoukuanjine,
|
|
|
+ GROUP_CONCAT( DISTINCT u.nick_name ) AS shenqingren,
|
|
|
+ CASE
|
|
|
+
|
|
|
+ WHEN input.contract_type = 1 THEN
|
|
|
+ "续签" ELSE "新签"
|
|
|
+ END AS hetongleixing,
|
|
|
+ CASE
|
|
|
+
|
|
|
+ WHEN c.is_project = 1 THEN
|
|
|
+ "项目" ELSE
|
|
|
+ CASE
|
|
|
+
|
|
|
+ WHEN c.is_project = 2 THEN
|
|
|
+ "非项目" ELSE ""
|
|
|
+ END
|
|
|
+ END AS shifouweixiangmu,
|
|
|
+ detail.amount AS fuwujine,
|
|
|
+ SUM( CASE WHEN c.STATUS = 1 THEN detail.arrive_amount ELSE 0 END ) AS shishoujine,
|
|
|
+ (
|
|
|
+ SUM( detail.arrive_amount ) - SUM( CASE WHEN c.STATUS = 1 THEN detail.arrive_amount ELSE 0 END )) AS
|
|
|
+ daishoukuanjine,
|
|
|
+ GROUP_CONCAT(
|
|
|
+ IF
|
|
|
+ ( c.STATUS = 1, c.verify_date, NULL )) AS shenheshijian
|
|
|
+ FROM
|
|
|
+ biz_collection c
|
|
|
+ LEFT JOIN biz_collection_detail detail ON c.id = detail.collection_id
|
|
|
+ LEFT JOIN biz_company com ON com.id = c.company_id
|
|
|
+ LEFT JOIN biz_archive_input input ON input.id = c.contract_id
|
|
|
+ LEFT JOIN sys_user u ON u.user_id = c.applier_id
|
|
|
+ LEFT JOIN biz_task_type type on type.id = detail.task_type_id
|
|
|
+ WHERE
|
|
|
+ c.deleted = 0
|
|
|
+ AND c.STATUS != 2
|
|
|
+ AND com.tenant_id = #{conditions.tenantId}
|
|
|
+ <if test="conditions.companyName != null and conditions.companyName != ''">
|
|
|
+ AND com.NAME LIKE CONCAT('%',#{conditions.companyName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="conditions.contractNo != null and conditions.contractNo != ''">
|
|
|
+ AND input.contract_no LIKE CONCAT('%',#{conditions.contractNo},'%')
|
|
|
+ </if>
|
|
|
+ <if test="conditions.taskTypeIds != null and conditions.taskTypeIds.size() > 0">
|
|
|
+ AND detail.task_type_id IN
|
|
|
+ <foreach collection="conditions.taskTypeIds" index="index" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="conditions.receiptDateFilter != null and conditions.receiptDateFilter.size() ">
|
|
|
+ AND (
|
|
|
+ DATE_FORMAT(c.arrive_date,'%Y-%m-%d') >= #{conditions.receiptDateFilter[0]}
|
|
|
+ AND
|
|
|
+ DATE_FORMAT(c.arrive_date,'%Y-%m-%d') <= #{conditions.receiptDateFilter[1]}
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="conditions.examineTimeFilter != null and conditions.examineTimeFilter.size() ">
|
|
|
+ AND(
|
|
|
+ DATE_FORMAT(c.verify_date,'%Y-%m-%d') >= #{conditions.examineTimeFilter[1]}
|
|
|
+ AND
|
|
|
+ DATE_FORMAT(c.verify_date,'%Y-%m-%d') <= #{conditions.examineTimeFilter[1]}
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="conditions.isProject != null">
|
|
|
+ AND c.is_project = #{conditions.isProject}
|
|
|
+ </if>
|
|
|
+ <if test="conditions.isNew != null">
|
|
|
+ AND c.is_new = #{conditions.isNew}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ c.company_id,
|
|
|
+ detail.task_type_id,
|
|
|
+ c.contract_id
|
|
|
+ order by
|
|
|
+ c.create_time desc
|
|
|
+ ) tt1
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ t1.company_id,
|
|
|
+ t3.task_type_id,
|
|
|
+ t1.contract_id,
|
|
|
+ SUM( CASE WHEN t1.payment_status = 1 THEN t3.payment_amount ELSE 0 END ) zhichu
|
|
|
+ FROM
|
|
|
+ biz_payment t1
|
|
|
+ LEFT JOIN biz_archive_input t2 ON t1.contract_id = t2.id
|
|
|
+ LEFT JOIN biz_payment_detail t3 ON t1.id = t3.payment_id
|
|
|
+ left join biz_company com on com.id = t1.company_id
|
|
|
+ left join biz_archive_input input on input.id = t1.contract_id
|
|
|
+ WHERE
|
|
|
+ t1.deleted = 0
|
|
|
+ AND t1.payment_status = 1
|
|
|
+ AND t1.verify_status = 3
|
|
|
+ AND com.tenant_id = #{conditions.tenantId}
|
|
|
+ <if test="conditions.companyName != null and conditions.companyName != ''">
|
|
|
+ AND com.NAME LIKE CONCAT('%',#{conditions.companyName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="conditions.contractNo != null and conditions.contractNo != ''">
|
|
|
+ AND input.contract_no LIKE CONCAT('%',#{conditions.contractNo},'%')
|
|
|
+ </if>
|
|
|
+ <if test="conditions.taskTypeIds != null and conditions.taskTypeIds.size() > 0">
|
|
|
+ AND t3.task_type_id IN
|
|
|
+ <foreach collection="conditions.taskTypeIds" index="index" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="conditions.receiptDateFilter != null and conditions.receiptDateFilter.size() ">
|
|
|
+ AND (
|
|
|
+ DATE_FORMAT(t1.verify_date,'%Y-%m-%d') >= #{conditions.receiptDateFilter[0]}
|
|
|
+ AND
|
|
|
+ DATE_FORMAT(t1.verify_date,'%Y-%m-%d') <= #{conditions.receiptDateFilter[1]}
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+
|
|
|
+ GROUP BY
|
|
|
+ t1.company_id,
|
|
|
+ t3.task_type_id,
|
|
|
+ t1.contract_id
|
|
|
+ ) tt2 ON tt1.company_id = tt2.company_id
|
|
|
+ AND tt1.task_type_id = tt2.task_type_id
|
|
|
+ AND tt1.contract_id = tt2.contract_id
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<sql id="getListSql">
|
|
|
SELECT a.id, a.flow_no, a.subsidiary_id, a.subsidiary, a.subsidiary_name, a.subsidiary_bank_account, a.form_date
|
|
|
- , a.subsidiary_bank_name, a.company_id, b.name as company_name
|
|
|
- , a.is_new, a.is_project, a.project_name, a.project_no, a.project_main_name
|
|
|
- , a.amount
|
|
|
- , a.verify_status
|
|
|
- , a.arrive_amount
|
|
|
- , a.arrive_date
|
|
|
- , a.arrive_time, a.status, a.applier_id, a.verify_date, a.verify_comment
|
|
|
- , a.arrive_status, a.apply_name
|
|
|
- , a.appy_account, a.create_time, a.creator_id, a.update_time, a.updater_id
|
|
|
- , a.deleted, a.version, a.remark
|
|
|
- , a.actually_date
|
|
|
- , b.name as company_name, t5.nick_name as applier_name
|
|
|
- , ai.contract_no
|
|
|
- , (select ifnull(sum(amount), 0) from biz_collection col where col.contract_id = a.contract_id and col.status = 1) payment_amount
|
|
|
+ , a.subsidiary_bank_name, a.company_id, b.name as company_name
|
|
|
+ , a.is_new, a.is_project, a.project_name, a.project_no, a.project_main_name
|
|
|
+ , a.amount
|
|
|
+ , a.verify_status
|
|
|
+ , a.arrive_amount
|
|
|
+ , a.arrive_date
|
|
|
+ , a.arrive_time, a.status, a.applier_id, a.verify_date, a.verify_comment
|
|
|
+ , a.arrive_status, a.apply_name
|
|
|
+ , a.appy_account, a.create_time, a.creator_id, a.update_time, a.updater_id
|
|
|
+ , a.deleted, a.version, a.remark
|
|
|
+ , a.actually_date
|
|
|
+ , b.name as company_name, t5.nick_name as applier_name
|
|
|
+ , ai.contract_no
|
|
|
+ , (select ifnull(sum(amount), 0) from biz_collection col where col.contract_id = a.contract_id and col.status =
|
|
|
+ 1) payment_amount
|
|
|
FROM biz_collection a left join biz_company b on b.id = a.company_id
|
|
|
left join biz_archive_input ai on ai.id = a.contract_id
|
|
|
left join sys_user t5 on t5.user_id = a.applier_id
|
|
@@ -115,7 +262,7 @@
|
|
|
<if test="appyAccount != null and appyAccount != '' ">
|
|
|
a.appy_account = #{appyAccount} AND
|
|
|
</if>
|
|
|
- <if test="verifyDate != null" >
|
|
|
+ <if test="verifyDate != null">
|
|
|
a.verify_date = #{verifyDate}
|
|
|
</if>
|
|
|
<if test="remark != null and remark != '' ">
|