Commit 1031aa2b8e3106d3d56d1e507d5220534bf8c197
1 parent
5067ce7e
update...
Showing
1 changed file
with
27 additions
and
13 deletions
src/main/java/com/bsth/data/schedule/thread/SchedulePstThread.java
| 1 | 1 | package com.bsth.data.schedule.thread; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.fastjson.JSON; |
| 4 | +import com.alibaba.fastjson.serializer.PropertyFilter; | |
| 4 | 5 | import com.bsth.data.schedule.DayOfSchedule; |
| 5 | 6 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 6 | 7 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| ... | ... | @@ -45,31 +46,44 @@ public class SchedulePstThread extends Thread { |
| 45 | 46 | @Override |
| 46 | 47 | public void run() { |
| 47 | 48 | |
| 48 | - ScheduleRealInfo schedule; | |
| 49 | - for (int i = 0; i < 500; i++) { | |
| 50 | - schedule = DayOfSchedule.pstBuffer.poll(); | |
| 51 | - if (null == schedule) | |
| 52 | - break; | |
| 49 | + try{ | |
| 50 | + ScheduleRealInfo schedule; | |
| 51 | + for (int i = 0; i < 500; i++) { | |
| 52 | + schedule = DayOfSchedule.pstBuffer.poll(); | |
| 53 | + if (null == schedule) | |
| 54 | + break; | |
| 55 | + | |
| 56 | + if (schedule.isDeleted()) { | |
| 57 | + logger.error("save 发现 deleted=true 的班次,id: " + schedule.getId()); | |
| 58 | + continue; | |
| 59 | + } | |
| 53 | 60 | |
| 54 | - if (schedule.isDeleted()) { | |
| 55 | - logger.error("save 发现 deleted=true 的班次,id: " + schedule.getId()); | |
| 56 | - continue; | |
| 61 | + saveList.add(schedule); | |
| 57 | 62 | } |
| 58 | 63 | |
| 59 | - saveList.add(schedule); | |
| 64 | + //写入数据库 | |
| 65 | + save(); | |
| 66 | + }catch (Exception e){ | |
| 67 | + logger.error("", e); | |
| 60 | 68 | } |
| 61 | - | |
| 62 | - //写入数据库 | |
| 63 | - save(); | |
| 64 | 69 | } |
| 65 | 70 | |
| 71 | + PropertyFilter filter = new PropertyFilter() { | |
| 72 | + //过滤不需要的字段 | |
| 73 | + public boolean apply(Object source, String name, Object value) { | |
| 74 | + if("cTasks".equals(name)||"createBy".equals(name)||"updateBy".equals(name)){ | |
| 75 | + return false; | |
| 76 | + } | |
| 77 | + return true; | |
| 78 | + } | |
| 79 | + }; | |
| 66 | 80 | |
| 67 | 81 | private void save(){ |
| 68 | 82 | if(saveList.size() == 0) |
| 69 | 83 | return; |
| 70 | 84 | //记录同步数据 |
| 71 | 85 | logger.info("real schedule update size: " + saveList.size()); |
| 72 | - logger.info(JSON.toJSONString(saveList)); | |
| 86 | + logger.info(JSON.toJSONString(saveList, filter)); | |
| 73 | 87 | |
| 74 | 88 | //批量入库 |
| 75 | 89 | update2Db(); | ... | ... |