Commit 2e1f9aa6203409345c2952914d44623a143c8644
1 parent
e81632e03c
Exists in
master
and in
6 other branches
数据同步
Showing 3 changed files with 32 additions and 19 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java
View file @
2e1f9aa
| ... | ... | @@ -3007,7 +3007,7 @@ |
| 3007 | 3007 | } |
| 3008 | 3008 | } |
| 3009 | 3009 | |
| 3010 | - ExecutorService service = new ThreadPoolExecutor(5, 10, 9000, TimeUnit.MILLISECONDS, | |
| 3010 | + ExecutorService service = new ThreadPoolExecutor(3, 6, 9000, TimeUnit.MILLISECONDS, | |
| 3011 | 3011 | new ArrayBlockingQueue<Runnable>(1), |
| 3012 | 3012 | new RejectedExecutionHandler() { |
| 3013 | 3013 | @Override |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SaveByV2ThreadPoolFacade.java
View file @
2e1f9aa
| ... | ... | @@ -23,6 +23,7 @@ |
| 23 | 23 | import java.util.concurrent.ExecutorService; |
| 24 | 24 | import java.util.concurrent.Executors; |
| 25 | 25 | import java.util.concurrent.Future; |
| 26 | +import java.util.concurrent.atomic.AtomicInteger; | |
| 26 | 27 | |
| 27 | 28 | @Component |
| 28 | 29 | public class SaveByV2ThreadPoolFacade { |
| ... | ... | @@ -49,6 +50,11 @@ |
| 49 | 50 | String startTime = param.getStartTime(); |
| 50 | 51 | String endTime = param.getEndTime(); |
| 51 | 52 | Connection connection = null; |
| 53 | + // 同步计数器 | |
| 54 | + AtomicInteger okSize=new AtomicInteger(0); | |
| 55 | + AtomicInteger existSize=new AtomicInteger(0); | |
| 56 | + AtomicInteger errorSize=new AtomicInteger(0); | |
| 57 | + | |
| 52 | 58 | try { |
| 53 | 59 | connection = bookbuildingFacade.getConnection(); |
| 54 | 60 | String sql = getSqlString(startTime, endTime); |
| ... | ... | @@ -63,7 +69,7 @@ |
| 63 | 69 | if (end > lists.size()) { |
| 64 | 70 | end = lists.size(); |
| 65 | 71 | } |
| 66 | - Future f = commonThreadPool.submit(new SyncV2HistoryWorkerx(bookbuildingFacade, lists.subList(i, end), mongoTemplate)); | |
| 72 | + Future f = commonThreadPool.submit(new SyncV2HistoryWorkerx(bookbuildingFacade, lists.subList(i, end), mongoTemplate, okSize, existSize, errorSize)); | |
| 67 | 73 | } |
| 68 | 74 | } |
| 69 | 75 | |
| ... | ... | @@ -79,7 +85,7 @@ |
| 79 | 85 | } |
| 80 | 86 | } |
| 81 | 87 | } |
| 82 | - return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
| 88 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("同步结果: ok ===>" + okSize + "exist===>" + existSize + "error===>" + errorSize); | |
| 83 | 89 | |
| 84 | 90 | } |
| 85 | 91 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/SyncV2HistoryWorkerx.java
View file @
2e1f9aa
| 1 | 1 | package com.lyms.platform.operate.web.worker; |
| 2 | 2 | |
| 3 | -import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | -import com.lyms.platform.biz.service.PatientsService; | |
| 5 | -import com.lyms.platform.biz.service.PostReviewService; | |
| 6 | -import com.lyms.platform.common.enums.YnEnums; | |
| 3 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 7 | 4 | import com.lyms.platform.common.result.BaseObjectResponse; |
| 8 | 5 | import com.lyms.platform.common.utils.DateUtil; |
| 9 | -import com.lyms.platform.common.utils.ExceptionUtils; | |
| 10 | -import com.lyms.platform.operate.web.facade.AntenatalExaminationFacade; | |
| 11 | 6 | import com.lyms.platform.operate.web.facade.BookbuildingFacade; |
| 12 | 7 | import com.lyms.platform.operate.web.request.SyncV2HistoryRequest; |
| 13 | 8 | import com.lyms.platform.operate.web.request.YunBookbuildingAddRequest; |
| 14 | -import com.lyms.platform.pojo.AntExChuModel; | |
| 15 | -import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 16 | 9 | import com.lyms.platform.pojo.Patients; |
| 17 | -import com.lyms.platform.query.AntExChuQuery; | |
| 18 | -import com.lyms.platform.query.AntExQuery; | |
| 19 | -import com.lyms.platform.query.PostReviewQuery; | |
| 20 | -import org.apache.commons.collections.CollectionUtils; | |
| 21 | -import org.springframework.data.domain.Sort; | |
| 22 | 10 | import org.springframework.data.mongodb.core.MongoTemplate; |
| 23 | 11 | import org.springframework.data.mongodb.core.query.Criteria; |
| 24 | 12 | import org.springframework.data.mongodb.core.query.Query; |
| ... | ... | @@ -26,7 +14,7 @@ |
| 26 | 14 | import java.util.Date; |
| 27 | 15 | import java.util.List; |
| 28 | 16 | import java.util.concurrent.Callable; |
| 29 | -import java.util.concurrent.atomic.AtomicLong; | |
| 17 | +import java.util.concurrent.atomic.AtomicInteger; | |
| 30 | 18 | |
| 31 | 19 | /** |
| 32 | 20 | * 纠正数据线程 |
| 33 | 21 | |
| ... | ... | @@ -41,10 +29,24 @@ |
| 41 | 29 | |
| 42 | 30 | private MongoTemplate mongoTemplate; |
| 43 | 31 | |
| 44 | - public SyncV2HistoryWorkerx(BookbuildingFacade bookbuildingFacade, List<SyncV2HistoryRequest> lists, MongoTemplate mongoTemplate) { | |
| 32 | + private AtomicInteger okSize; | |
| 33 | + private AtomicInteger existSize; | |
| 34 | + private AtomicInteger errorSize; | |
| 35 | + | |
| 36 | + public SyncV2HistoryWorkerx(BookbuildingFacade bookbuildingFacade, | |
| 37 | + List<SyncV2HistoryRequest> lists, | |
| 38 | + MongoTemplate mongoTemplate, | |
| 39 | + AtomicInteger okSize, | |
| 40 | + AtomicInteger existSize, | |
| 41 | + AtomicInteger errorSize | |
| 42 | + ) { | |
| 45 | 43 | this.bookbuildingFacade = bookbuildingFacade; |
| 46 | 44 | this.lists = lists; |
| 47 | 45 | this.mongoTemplate = mongoTemplate; |
| 46 | + this.okSize = okSize; | |
| 47 | + this.existSize = existSize; | |
| 48 | + this.errorSize = errorSize; | |
| 49 | + | |
| 48 | 50 | } |
| 49 | 51 | |
| 50 | 52 | @Override |
| ... | ... | @@ -53,6 +55,7 @@ |
| 53 | 55 | for (YunBookbuildingAddRequest list : lists) { |
| 54 | 56 | Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("cardNo").is(list.getPregnantCertificateNum())), Patients.class); |
| 55 | 57 | if (patients != null) { |
| 58 | + existSize.incrementAndGet(); | |
| 56 | 59 | continue; |
| 57 | 60 | } |
| 58 | 61 | |
| ... | ... | @@ -60,7 +63,11 @@ |
| 60 | 63 | list.setBookbuildingDoctor("1000000185");//todo |
| 61 | 64 | list.setBookbuildingDate(DateUtil.getyyyy_MM_dd(new Date())); |
| 62 | 65 | p = bookbuildingFacade.addPregnantBookbuilding(list, null, false); |
| 63 | - //System.out.println("当前线程名称:"+Thread.currentThread().getName()+"===保存好建档_id:"+p.getData()); | |
| 66 | + if (ErrorCodeConstants.SUCCESS == p.getErrorcode()) { | |
| 67 | + okSize.incrementAndGet(); | |
| 68 | + } else { | |
| 69 | + errorSize.incrementAndGet(); | |
| 70 | + } | |
| 64 | 71 | } |
| 65 | 72 | return p; |
| 66 | 73 | } |