add delete expired cdr
This commit is contained in:
parent
552b5505fe
commit
913c1b6789
@ -30,4 +30,11 @@ public interface CallDetailRecordMapper extends BaseMapper<Integer, CallDetailRe
|
|||||||
@Param("tenantId") Integer tenantId,
|
@Param("tenantId") Integer tenantId,
|
||||||
@Param("calledNumber") String calledNumber);
|
@Param("calledNumber") String calledNumber);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除过期记录
|
||||||
|
*
|
||||||
|
* @return delete row
|
||||||
|
*/
|
||||||
|
int deleteExpired();
|
||||||
}
|
}
|
||||||
|
@ -34,4 +34,12 @@
|
|||||||
) t
|
) t
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteExpired">
|
||||||
|
delete from
|
||||||
|
<include refid="table" />
|
||||||
|
where
|
||||||
|
<![CDATA[
|
||||||
|
start_stamp < date(now() - interval 31 day)
|
||||||
|
]]>
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -91,4 +91,9 @@ public class CallDetailRecordMapperTest {
|
|||||||
}
|
}
|
||||||
// mapper.list(new Search().desc(CallDetailRecord.ID).limit(20));
|
// mapper.list(new Search().desc(CallDetailRecord.ID).limit(20));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteExpired() {
|
||||||
|
mapper.deleteExpired();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import com.pudonghot.yo.mapper.PhoneAliasMapper;
|
|||||||
import com.pudonghot.yo.mapper.CallingListMapper;
|
import com.pudonghot.yo.mapper.CallingListMapper;
|
||||||
import com.pudonghot.yo.model.domain.CallingList;
|
import com.pudonghot.yo.model.domain.CallingList;
|
||||||
import com.pudonghot.yo.service.LeaderElectionService;
|
import com.pudonghot.yo.service.LeaderElectionService;
|
||||||
|
import com.pudonghot.yo.mapper.CallDetailRecordMapper;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import com.pudonghot.yo.mapper.CallingListHistoricalMapper;
|
import com.pudonghot.yo.mapper.CallingListHistoricalMapper;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
@ -39,6 +40,8 @@ public class CallingListServiceImpl
|
|||||||
private LeaderElectionService leaderElectionService;
|
private LeaderElectionService leaderElectionService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private PhoneAliasMapper phoneAliasMapper;
|
private PhoneAliasMapper phoneAliasMapper;
|
||||||
|
@Autowired
|
||||||
|
private CallDetailRecordMapper callDetailRecordMapper;
|
||||||
|
|
||||||
@Value("${yo.campaign.calling-list-lock-expire.seconds:300}")
|
@Value("${yo.campaign.calling-list-lock-expire.seconds:300}")
|
||||||
private int expireLockDuration;
|
private int expireLockDuration;
|
||||||
@ -70,11 +73,22 @@ public class CallingListServiceImpl
|
|||||||
phoneAliasMapper.deleteOutdated();
|
phoneAliasMapper.deleteOutdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "${yo.call-detail-record.delete-expired-cron:1 1 0 * * *}")
|
||||||
|
public void deleteExpiredCDR() {
|
||||||
|
if (!leaderElectionService.isLeader()) {
|
||||||
|
log.info("Server is not leader, ignore delete expired CDR scheduler task.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("Delete expired CDR.");
|
||||||
|
callDetailRecordMapper.deleteExpired();
|
||||||
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "${yo.campaign.calling-list.batch-cron:1 1 1 * * *}")
|
@Scheduled(cron = "${yo.campaign.calling-list.batch-cron:1 1 1 * * *}")
|
||||||
public void deleteCalled() {
|
public void callingListBatch() {
|
||||||
|
|
||||||
if (!leaderElectionService.isLeader()) {
|
if (!leaderElectionService.isLeader()) {
|
||||||
log.debug("Server is not leader, ignore campaign delete calling list scheduler task.");
|
log.debug("Server is not leader, ignore campaign calling list scheduler task.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user