From 552b5505fecacb47263c75583964e24797877efa Mon Sep 17 00:00:00 2001 From: Donghuang Date: Tue, 5 Oct 2021 12:43:46 +0800 Subject: [PATCH] opt import history sql --- .../yo/mapper/CallingListHistoricalMapper.xml | 91 +++++++++++++------ 1 file changed, 62 insertions(+), 29 deletions(-) diff --git a/lib/mapper/src/main/java/com/pudonghot/yo/mapper/CallingListHistoricalMapper.xml b/lib/mapper/src/main/java/com/pudonghot/yo/mapper/CallingListHistoricalMapper.xml index 8b9db214..0efe5fad 100644 --- a/lib/mapper/src/main/java/com/pudonghot/yo/mapper/CallingListHistoricalMapper.xml +++ b/lib/mapper/src/main/java/com/pudonghot/yo/mapper/CallingListHistoricalMapper.xml @@ -162,16 +162,24 @@ join ( date(now() - interval 21 day) - and tenant_id = #{arg.tenantId} - and answer_stamp is not null - group by called_number - having count(answer_stamp) > 0 + select c.phone + from br_calling_list_historical c + + join br_call_detail_record cdr + on c.phone = cdr.called_number + + where cdr.start_stamp > date(now() - interval 21 day) + and cdr.tenant_id = #{arg.tenantId} + and cdr.answer_stamp is not null + and c.tenant_id = #{arg.tenantId} + and c.campaign_id = #{arg.campaignId} + and c.export_batch_key = #{arg.exportBatchKey} + + group by cdr.called_number + having count(cdr.id) > 0 ]]> ) t1 - on c.phone = t1.called_number + on c.phone = t1.phone set c.active = 0, c.note = 'Answered', @@ -189,15 +197,23 @@ join ( date(now() - interval 21 day) - and tenant_id = #{arg.tenantId} - group by called_number - having count(start_stamp) > 6 + select c.phone + from br_calling_list_historical c + + join br_call_detail_record cdr + on c.phone = cdr.called_number + + where cdr.start_stamp > date(now() - interval 21 day) + and cdr.tenant_id = #{arg.tenantId} + and c.tenant_id = #{arg.tenantId} + and c.campaign_id = #{arg.campaignId} + and c.export_batch_key = #{arg.exportBatchKey} + + group by cdr.called_number + having count(cdr.id) > 6 ]]> ) t1 - on c.phone = t1.called_number + on c.phone = t1.phone set c.active = 0, c.note = 'Exceed 6 Times', @@ -208,6 +224,7 @@ and c.campaign_id = #{arg.campaignId} and c.export_batch_key = #{arg.exportBatchKey} and c.active = 1 + @@ -215,15 +232,23 @@ join ( date(now()) - and tenant_id = #{arg.tenantId} - group by called_number - having count(start_stamp) > 1 + select c.phone + from br_calling_list_historical c + + join br_call_detail_record cdr + on c.phone = cdr.called_number + + where cdr.start_stamp > date(now()) + and cdr.tenant_id = #{arg.tenantId} + and c.tenant_id = #{arg.tenantId} + and c.campaign_id = #{arg.campaignId} + and c.export_batch_key = #{arg.exportBatchKey} + + group by cdr.called_number + having count(cdr.id) > 1 ]]> ) t1 - on c.phone = t1.called_number + on c.phone = t1.phone set c.active = 0, c.note = 'Exceed 1 Times Today', @@ -241,15 +266,23 @@ join ( now() - interval 4 hour - and tenant_id = #{arg.tenantId} - group by called_number - having count(start_stamp) > 0 + select c.phone + from br_calling_list_historical c + + join br_call_detail_record cdr + on c.phone = cdr.called_number + + where cdr.start_stamp > now() - interval 4 hour + and cdr.tenant_id = #{arg.tenantId} + and c.tenant_id = #{arg.tenantId} + and c.campaign_id = #{arg.campaignId} + and c.export_batch_key = #{arg.exportBatchKey} + + group by cdr.called_number + having count(cdr.id) > 0 ]]> ) t1 - on c.phone = t1.called_number + on c.phone = t1.phone set c.active = 0, c.note = 'Called In 4 Hours',