parent
47b3f68b9d
commit
a34423fca8
@ -0,0 +1,44 @@
|
||||
package com.xjs.common.task;
|
||||
|
||||
import com.xjs.copywriting.service.CopyWritingService;
|
||||
import com.xjs.topsearch.service.ApiTopsearchAllnetworkService;
|
||||
import com.xjs.topsearch.service.ApiTopsearchWechatService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author xiejs
|
||||
* @desc 删除重复文案数据
|
||||
* @create 2022-01-06
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class DeleteRepeatTask {
|
||||
@Autowired
|
||||
private CopyWritingService copyWritingService;
|
||||
@Autowired
|
||||
private ApiTopsearchAllnetworkService apiTopsearchAllnetworkService;
|
||||
@Autowired
|
||||
private ApiTopsearchWechatService apiTopsearchWechatService;
|
||||
|
||||
|
||||
/**
|
||||
* 2022-01-07 07:00:00
|
||||
* 2022-01-07 08:00:00
|
||||
* 2022-01-07 09:00:00
|
||||
* 2022-01-07 10:00:00
|
||||
*/
|
||||
@Scheduled(cron = "0 0 7-23 * * ? ")
|
||||
public void execute() {
|
||||
int copyWritingCount = copyWritingService.deleteRepeatData();
|
||||
log.info("thread id:{},定时清除文案重复数据,重复数:{}", Thread.currentThread().getId(),copyWritingCount);
|
||||
Integer allNetworkCount = apiTopsearchAllnetworkService.deleteRepeatData();
|
||||
log.info("thread id:{},定时清除全网热搜榜重复数据,重复数:{}", Thread.currentThread().getId(),allNetworkCount);
|
||||
Integer wechatCount = apiTopsearchWechatService.deleteRepeatData();
|
||||
log.info("thread id:{},定时清除微信热搜榜重复数据,重复数:{}", Thread.currentThread().getId(),wechatCount);
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.xjs.copywriting.task;
|
||||
|
||||
import com.xjs.copywriting.service.CopyWritingService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author xiejs
|
||||
* @desc 删除重复文案数据
|
||||
* @create 2022-01-06
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class DeleteRepeatTask {
|
||||
@Resource
|
||||
private CopyWritingService copyWritingService;
|
||||
|
||||
/**
|
||||
* 2022-01-07 07:00:00
|
||||
* 2022-01-07 08:00:00
|
||||
* 2022-01-07 09:00:00
|
||||
* 2022-01-07 10:00:00
|
||||
*/
|
||||
@Scheduled(cron = "0 0 7-23 * * ? ")
|
||||
public void execute() {
|
||||
int count = copyWritingService.deleteRepeatData();
|
||||
log.info("thread id:{},定时清除文案重复数据,重复数:{}", Thread.currentThread().getId(),count);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?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.xjs.topsearch.mapper.ApiTopsearchAllnetworkMapper">
|
||||
|
||||
<delete id="deleteRepeatData">
|
||||
DELETE
|
||||
FROM
|
||||
api_topsearch_allnetwork
|
||||
WHERE
|
||||
title IN ( SELECT t.title FROM ( SELECT title FROM api_topsearch_allnetwork GROUP BY title HAVING count( title ) > 1 ) t )
|
||||
AND id NOT IN (
|
||||
SELECT
|
||||
c.id
|
||||
FROM
|
||||
( SELECT min( id ) id FROM api_topsearch_allnetwork GROUP BY title HAVING count( title )> 1 ) c
|
||||
)
|
||||
</delete>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,21 @@
|
||||
<?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.xjs.topsearch.mapper.ApiTopsearchWechatMapper">
|
||||
|
||||
<delete id="deleteRepeatData">
|
||||
DELETE
|
||||
FROM
|
||||
api_topsearch_wechat
|
||||
WHERE
|
||||
word IN ( SELECT t.word FROM ( SELECT word FROM api_topsearch_wechat GROUP BY word HAVING count( word ) > 1 ) t )
|
||||
AND id NOT IN (
|
||||
SELECT
|
||||
c.id
|
||||
FROM
|
||||
( SELECT min( id ) id FROM api_topsearch_wechat GROUP BY word HAVING count( word )> 1 ) c
|
||||
)
|
||||
</delete>
|
||||
|
||||
</mapper>
|
Loading…
Reference in new issue