提交 a42f0244 编写于 作者: rushui.chen's avatar rushui.chen

20191112 定时任务跑批量脚本

上级 cad555c1
流水线 #16952 已失败 于阶段
in 0 second
package com.pica.cloud.account.account.server.job;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created on 2019/10/29 15:37
* author:crs
* Description:doctor表重复记录处理
*/
@JobHandler(value = "AccountRepeatDataJob")
@Component
public class AccountRepeatDataJob extends IJobHandler {
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
@Override
public ReturnT<String> execute(String s) throws Exception {
accountInfoDetailMapper.processAccountRepeatData();
XxlJobLogger.log("刷新数据");
return null;
}
}
...@@ -32,7 +32,7 @@ public class DoctorRepeatDataJob { ...@@ -32,7 +32,7 @@ public class DoctorRepeatDataJob {
* 1、使用分布式锁保证一个微服务执行; * 1、使用分布式锁保证一个微服务执行;
* 2、定时任务; * 2、定时任务;
*/ */
@Scheduled(cron = "0 0 0 * * ?") @Scheduled(cron = "0 0 0/1 * * ?")
public void processDoctorRepeatData() { public void processDoctorRepeatData() {
//通过接口幂等性逻辑处理 //通过接口幂等性逻辑处理
String exist = cacheClient.get(KEY); String exist = cacheClient.get(KEY);
......
...@@ -59,4 +59,7 @@ public interface AccountInfoDetailMapper { ...@@ -59,4 +59,7 @@ public interface AccountInfoDetailMapper {
int insertSelective(AccountInfoEntity record); int insertSelective(AccountInfoEntity record);
void updateDeleteByPrimaryKey(Integer acctId); void updateDeleteByPrimaryKey(Integer acctId);
void processAccountRepeatData();
} }
...@@ -61,6 +61,12 @@ ...@@ -61,6 +61,12 @@
update account_info set modified_id=#{id}, modified_time=#{modifiedTime},mobile_phone=#{mobilePhone} where id=#{id} and delete_flag=1 update account_info set modified_id=#{id}, modified_time=#{modifiedTime},mobile_phone=#{mobilePhone} where id=#{id} and delete_flag=1
</update> </update>
<update id="processAccountRepeatData">
update account_info set delete_flag=2, modified_id=101432928, modified_time=now() where id in (select id from (select pd.id from account_info pd
inner JOIN (SELECT mobile_phone,MIN(id) as id FROM account_info WHERE delete_flag=1 and mobile_phone is not null GROUP BY mobile_phone having count(*)>1) inn
on pd.id != inn.id and pd.mobile_phone = inn.mobile_phone) ttt);
</update>
<!--修改用户的密码--> <!--修改用户的密码-->
<update id="updatePasswordByPrimaryKey" <update id="updatePasswordByPrimaryKey"
parameterType="com.pica.cloud.account.account.server.entity.AccountInfoEntity"> parameterType="com.pica.cloud.account.account.server.entity.AccountInfoEntity">
......
...@@ -84,12 +84,13 @@ ...@@ -84,12 +84,13 @@
<!--刷新重复的记录--> <!--刷新重复的记录-->
<update id="processDoctorRepeatData"> <update id="processDoctorRepeatData">
update p_doctor set delete_flag=2, modify_id=101432928, modify_time=now() where id in ( update p_doctor set delete_flag=2, modify_id=101432928, modify_time=now() where id in (select id from (select pd.id from p_doctor pd
select id from (select pd.id from account_info pd inner JOIN (SELECT mobile_phone,MIN(id) as id FROM p_doctor WHERE delete_flag=1 and mobile_phone is not null GROUP BY mobile_phone having count(*)>1) inn
inner JOIN (SELECT mobile_phone,MIN(id) as id FROM account_info WHERE delete_flag=1 and mobile_phone is not null GROUP BY mobile_phone having count(*)>1) inn on pd.id != inn.id and pd.mobile_phone = inn.mobile_phone) ttt);
on pd.id <![CDATA[!= ]]> inn.id and pd.mobile_phone = inn.mobile_phone) ttt )
</update> </update>
<!--通过手机号查询用户id--> <!--通过手机号查询用户id-->
<select id="selectDoctorIdByMobile" parameterType="java.lang.String" resultType="java.lang.Long"> <select id="selectDoctorIdByMobile" parameterType="java.lang.String" resultType="java.lang.Long">
SELECT id SELECT id
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册