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

20191029 刷doctor脚本定时任务

上级 e50f1f0a
流水线 #16449 已失败 于阶段
in 0 second
package com.pica.cloud.account.account.server.job;
import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.foundation.redis.ICacheClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* Created on 2019/10/29 15:37
* author:crs
* Description:doctor表重复记录处理
*/
@Component
public class DoctorRepeatDataJob {
private static final String key = "cache_process_doctor_repeat";
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient cacheClient;
@Autowired
private DoctorMapper doctorMapper;
/**
* 1、使用分布式锁保证一个微服务执行;
* 2、定时任务;
*/
@Scheduled(cron = "0 0 0 1/1 * ?")
public void processDoctorRepeatData() {
Long result = cacheClient.setnx(key, "1");
//如果为1说明获取到分布式锁
if (result == 1) {
//10分钟后锁过期
cacheClient.expire(key, 60 * 10);
logger.info("开始执行刷新doctor表中重复的记录");
int row = doctorMapper.processDoctorRepeatData();
logger.info("此次数据刷新影响的行数:{}", row);
try {
//防止任务一秒跑完,其他机器的时间晚了几秒
Thread.sleep(30*1000);
} catch (InterruptedException ex) {
logger.error(ex.getMessage(), ex);
}
//释放锁
cacheClient.del(key);
}
}
}
...@@ -44,10 +44,16 @@ public interface DoctorMapper { ...@@ -44,10 +44,16 @@ public interface DoctorMapper {
/** /**
* 通过账户id更新用户信息 * 通过账户id更新用户信息
*
* @param doctor * @param doctor
*/ */
void updateByAcctId(Doctor doctor); void updateByAcctId(Doctor doctor);
/**
* 处理重复的记录(相同手机号多条记录一致)
*/
int processDoctorRepeatData();
void updateByMobile(Doctor doctor); void updateByMobile(Doctor doctor);
int deleteByPrimaryKey(Integer id); int deleteByPrimaryKey(Integer id);
...@@ -60,6 +66,7 @@ public interface DoctorMapper { ...@@ -60,6 +66,7 @@ public interface DoctorMapper {
/** /**
* 绑定微信 * 绑定微信
*
* @param acctId * @param acctId
* @param unionId * @param unionId
* @return * @return
...@@ -68,6 +75,7 @@ public interface DoctorMapper { ...@@ -68,6 +75,7 @@ public interface DoctorMapper {
/** /**
* 解绑微信 * 解绑微信
*
* @param acctId * @param acctId
* @return * @return
*/ */
...@@ -78,7 +86,6 @@ public interface DoctorMapper { ...@@ -78,7 +86,6 @@ public interface DoctorMapper {
void updateDeleteByPrimaryKey(Integer id); void updateDeleteByPrimaryKey(Integer id);
/** /**
* 通过手机号获取用户id * 通过手机号获取用户id
* @param mobile * @param mobile
......
...@@ -168,7 +168,7 @@ public class AESUtil { ...@@ -168,7 +168,7 @@ public class AESUtil {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String KEY="zJJ$c5md3$yuuhWW"; String KEY="zJJ$c5md3$yuuhWW";
System.out.println("-------------加密---------"); System.out.println("-------------加密---------");
String content = "18111110070"; String content = "13916000007";
System.out.println("加密前:" + content); System.out.println("加密前:" + content);
System.out.println("加密密钥和解密密钥:" + KEY); System.out.println("加密密钥和解密密钥:" + KEY);
......
...@@ -82,6 +82,14 @@ ...@@ -82,6 +82,14 @@
and delete_flag = 1 and delete_flag = 1
</select> </select>
<!--刷新重复的记录-->
<update id="processDoctorRepeatData">
update p_doctor set delete_flag=2, modify_id=101432928, modify_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 <![CDATA[!= ]]> inn.id and pd.mobile_phone = inn.mobile_phone) ttt )
</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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册