...
|
...
|
@@ -2,7 +2,7 @@ package com.yoho.unions.server.task; |
|
|
|
|
|
import com.yoho.error.utils.LocalhostIpFetcher;
|
|
|
import com.yoho.service.model.union.bo.CpsMessageTaskBo;
|
|
|
import com.yoho.unions.common.redis.RedisValueCache;
|
|
|
import com.yoho.unions.common.redis.GlobalRedisValueCache;
|
|
|
import com.yoho.unions.common.utils.DateUtil;
|
|
|
import com.yoho.unions.server.service.IUnionShareService;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -25,7 +25,7 @@ public class CpsSettlementMessageTask { |
|
|
@Autowired
|
|
|
IUnionShareService unionShareService;
|
|
|
@Resource
|
|
|
RedisValueCache redisValueCache;
|
|
|
GlobalRedisValueCache redisValueCache;
|
|
|
|
|
|
private static String SETTLEMENT_TASK_KEY = "yh:union:share:CpsSettlementMessageTask:";
|
|
|
|
...
|
...
|
@@ -34,29 +34,35 @@ public class CpsSettlementMessageTask { |
|
|
// @Scheduled(cron = "0 0 10 20,28 * ?")
|
|
|
public void run(){
|
|
|
//竞争任务处理者
|
|
|
CpsMessageTaskBo bo = new CpsMessageTaskBo();
|
|
|
bo.setIp(LocalhostIpFetcher.fetchLocalIP());
|
|
|
bo.setTime(Long.toString(System.currentTimeMillis()));
|
|
|
CpsMessageTaskBo cacheBo=redisValueCache.get(SETTLEMENT_TASK_KEY+ DateUtil.getToday("yyyyMMdd"), CpsMessageTaskBo.class);
|
|
|
if (cacheBo != null) {
|
|
|
logger.info("other get task,it is {}.this is {}.",cacheBo,bo);
|
|
|
}
|
|
|
redisValueCache.set(SETTLEMENT_TASK_KEY+DateUtil.getToday("yyyyMMdd"),bo,2, TimeUnit.DAYS);
|
|
|
try {
|
|
|
Thread.sleep(1000);
|
|
|
} catch (InterruptedException e) {
|
|
|
logger.warn("thread sleep error,e is {}",e);
|
|
|
}
|
|
|
cacheBo=redisValueCache.get(SETTLEMENT_TASK_KEY+DateUtil.getToday("yyyyMMdd"), CpsMessageTaskBo.class);
|
|
|
if (cacheBo == null) {
|
|
|
logger.error("redis error.");
|
|
|
return;
|
|
|
}
|
|
|
if (!cacheBo.getIp().equals(bo.getIp()) || !cacheBo.getTime().equals(bo.getTime())) {
|
|
|
logger.info("The competition failure,other get task,it is {}.this is {}.",cacheBo,bo);
|
|
|
return;
|
|
|
}
|
|
|
// CpsMessageTaskBo bo = new CpsMessageTaskBo();
|
|
|
// bo.setIp(LocalhostIpFetcher.fetchLocalIP());
|
|
|
// bo.setTime(Long.toString(System.currentTimeMillis()));
|
|
|
// CpsMessageTaskBo cacheBo=redisValueCache.get(SETTLEMENT_TASK_KEY+ DateUtil.getToday("yyyyMMdd"), CpsMessageTaskBo.class);
|
|
|
// if (cacheBo != null) {
|
|
|
// logger.info("other get task,it is {}.this is {}.",cacheBo,bo);
|
|
|
// }
|
|
|
// redisValueCache.set(SETTLEMENT_TASK_KEY+DateUtil.getToday("yyyyMMdd"),bo,2, TimeUnit.DAYS);
|
|
|
// try {
|
|
|
// Thread.sleep(1000);
|
|
|
// } catch (InterruptedException e) {
|
|
|
// logger.warn("thread sleep error,e is {}",e);
|
|
|
// }
|
|
|
// cacheBo=redisValueCache.get(SETTLEMENT_TASK_KEY+DateUtil.getToday("yyyyMMdd"), CpsMessageTaskBo.class);
|
|
|
// if (cacheBo == null) {
|
|
|
// logger.error("redis error.");
|
|
|
// return;
|
|
|
// }
|
|
|
// if (!cacheBo.getIp().equals(bo.getIp()) || !cacheBo.getTime().equals(bo.getTime())) {
|
|
|
// logger.info("The competition failure,other get task,it is {}.this is {}.",cacheBo,bo);
|
|
|
// return;
|
|
|
// }
|
|
|
|
|
|
String key = SETTLEMENT_TASK_KEY + DateUtil.getToday("yyyyMMdd");
|
|
|
boolean lock = redisValueCache.getLock(key,2, TimeUnit.DAYS);
|
|
|
if (!lock) {
|
|
|
logger.info("The competition failure,other get task.");
|
|
|
}
|
|
|
logger.info("get this task,ip is {}",LocalhostIpFetcher.fetchLocalIP());
|
|
|
//今天更新的数据
|
|
|
int startTime=DateUtil.getLastDayInt(0);
|
|
|
int endTime= DateUtil.getLastDayInt(-1);
|
...
|
...
|
|