Commit fa95cd9b authored by 董建华's avatar 董建华

增加异常控制

parent 5c4b10c3
......@@ -75,39 +75,42 @@ public class CleanDataServiceImp implements CleanDataService {
calendar.setTime(parse);
long all = 0L;
while (true) {
Timestamp start = new Timestamp(calendar.getTime().getTime());
calendar.add(Calendar.MONTH, 1);
Timestamp end = new Timestamp(calendar.getTime().getTime());
List<UserExtInfo> list = iUserExtInfoService.findByCreatedAtAfterAndCreatedAtBeforeAndOccupationEnum(start, end);
if (!CollectionUtils.isEmpty(list)) {
for (UserExtInfo userExtInfo : list) {
try {
userExtInfo.setOccupationEnum(OccupationEnum.OTHER);
iUserExtInfoService.save(userExtInfo);
all++;
} catch (Exception e) {
log.error("保存异常o:{} ", userExtInfo);
}
}
}
String starDate = (start.getYear() + 1900) + "年" + (start.getMonth() + 1) + "月" + start.getDate() + "日";
String endDate = (end.getYear() + 1900) + "年" + (end.getMonth() + 1) + "月" + end.getDate() + "日";
log.info("开始时间start:{},结束时间end: {} ,条数:{}", starDate, endDate, list.size());
try {
List<UserExtInfo> list = iUserExtInfoService.findByCreatedAtAfterAndCreatedAtBeforeAndOccupationEnum(start, end);
if (!CollectionUtils.isEmpty(list)) {
for (UserExtInfo userExtInfo : list) {
try {
userExtInfo.setOccupationEnum(OccupationEnum.OTHER);
iUserExtInfoService.save(userExtInfo);
all++;
} catch (Exception e) {
log.error("保存异常o:{} ", userExtInfo);
}
}
}
log.info("开始时间start:{},结束时间end: {} ,条数:{}", starDate, endDate, list.size());
re.put(starDate + "-" + endDate, list.size());
if (end.after(new Date())) {
break;
re.put(starDate + "-" + endDate, list.size());
if (end.after(new Date())) {
break;
}
} catch (Exception e) {
log.error("时间段:{}--{}执行异常,e", starDate, endDate, e);
}
log.info("清洗结束总共清洗了all:{}条,耗时:{}秒", all, s.elapsed(TimeUnit.SECONDS));
}
log.info("清洗结束总共清洗了all:{}条,耗时:{}秒", all, s.elapsed(TimeUnit.SECONDS));
log.info("清洗明细:{} ", re);
} catch (Exception e) {
log.error("清洗的时候出现了异常e:{}", e);
} finally {
stringRedisTemplate.delete(LOCKKEY);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment