Commit 47a71b949cf5838ac376ebcba57586f5ca45dc48
1 parent
e1aafd5be3
Exists in
master
and in
6 other branches
2.0同步3.0系统,民族不显示修改
Showing 2 changed files with 52 additions and 57 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SaveByV2ThreadPoolFacade.java
View file @
47a71b9
... | ... | @@ -50,34 +50,22 @@ |
50 | 50 | * @return BaseResponse |
51 | 51 | */ |
52 | 52 | public BaseResponse saveByV2(SyncV2HistoryRequest param) { |
53 | - //获取2.0历史建档数据 | |
53 | + | |
54 | 54 | String startTime = param.getStartTime(); |
55 | 55 | String endTime = param.getEndTime(); |
56 | - Connection connection = null; | |
57 | 56 | // 同步计数器 |
58 | 57 | AtomicInteger okSize=new AtomicInteger(0); |
59 | 58 | AtomicInteger existSize=new AtomicInteger(0); |
60 | 59 | AtomicInteger errorSize=new AtomicInteger(0); |
61 | 60 | |
61 | + Connection connection = null; | |
62 | + List<SyncV2HistoryRequest> lists=null; | |
62 | 63 | try { |
63 | 64 | connection = bookbuildingFacade.getConnection(); |
64 | 65 | String sql = getSqlString(startTime, endTime); |
65 | 66 | QueryRunner queryRunner = new QueryRunner(true); |
66 | - List<SyncV2HistoryRequest> lists = queryRunner.query(connection, sql, new BeanListHandler<SyncV2HistoryRequest>(SyncV2HistoryRequest.class)); | |
67 | + lists = queryRunner.query(connection, sql, new BeanListHandler<SyncV2HistoryRequest>(SyncV2HistoryRequest.class)); | |
67 | 68 | |
68 | - if (CollectionUtils.isNotEmpty(lists)) { | |
69 | - int batchSize = 2; | |
70 | - int end = 0; | |
71 | - for (int i = 0; i < lists.size(); i += batchSize) { | |
72 | - end = (end + batchSize); | |
73 | - if (end > lists.size()) { | |
74 | - end = lists.size(); | |
75 | - } | |
76 | - Future f = commonThreadPool.submit(new SyncV2HistoryWorkerx(bookbuildingFacade, lists.subList(i, end), mongoTemplate, okSize, existSize, errorSize)); | |
77 | -// Future f = commonThreadPool.submit(new SyncV2HistoryWorkerx(bookbuildingFacade, lists.subList(i, end), mongoTemplate,basicConfigDao)); | |
78 | - } | |
79 | - } | |
80 | - | |
81 | 69 | } catch (Exception e) { |
82 | 70 | logger.info(e.getMessage()); |
83 | 71 | return new BaseResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR).setErrormsg("系统异常"); |
... | ... | @@ -90,8 +78,18 @@ |
90 | 78 | } |
91 | 79 | } |
92 | 80 | } |
93 | - return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
94 | - | |
81 | + if (CollectionUtils.isNotEmpty(lists)) { | |
82 | + int batchSize = 2; | |
83 | + int end = 0; | |
84 | + for (int i = 0; i < lists.size(); i += batchSize) { | |
85 | + end = (end + batchSize); | |
86 | + if (end > lists.size()) { | |
87 | + end = lists.size(); | |
88 | + } | |
89 | + Future f = commonThreadPool.submit(new SyncV2HistoryWorkerx(bookbuildingFacade, lists.subList(i, end), mongoTemplate, okSize, existSize, errorSize,basicConfigDao)); | |
90 | + } | |
91 | + } | |
92 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("同步结果: ok ===>" + okSize + "exist===>" + existSize + "error===>" + errorSize); | |
95 | 93 | } |
96 | 94 | |
97 | 95 | private String getSqlString(String startTime, String endTime) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/SyncV2HistoryWorkerx.java
View file @
47a71b9
... | ... | @@ -40,71 +40,68 @@ |
40 | 40 | public class SyncV2HistoryWorkerx implements Callable { |
41 | 41 | |
42 | 42 | private BookbuildingFacade bookbuildingFacade; |
43 | - | |
44 | 43 | private List<SyncV2HistoryRequest> lists; |
45 | - | |
46 | 44 | private MongoTemplate mongoTemplate; |
47 | - | |
48 | 45 | private AtomicInteger okSize; |
49 | 46 | private AtomicInteger existSize; |
50 | 47 | private AtomicInteger errorSize; |
48 | + private IBasicConfigDao basicConfigDao; | |
51 | 49 | |
52 | 50 | public SyncV2HistoryWorkerx(BookbuildingFacade bookbuildingFacade, |
53 | 51 | List<SyncV2HistoryRequest> lists, |
54 | 52 | MongoTemplate mongoTemplate, |
55 | 53 | AtomicInteger okSize, |
56 | 54 | AtomicInteger existSize, |
57 | - AtomicInteger errorSize | |
58 | - ) { | |
59 | - private IBasicConfigDao basicConfigDao; | |
60 | - | |
61 | - public SyncV2HistoryWorkerx(BookbuildingFacade bookbuildingFacade, List<SyncV2HistoryRequest> lists, MongoTemplate mongoTemplate,IBasicConfigDao basicConfigDao) { | |
55 | + AtomicInteger errorSize, | |
56 | + IBasicConfigDao basicConfigDao) { | |
62 | 57 | this.bookbuildingFacade = bookbuildingFacade; |
63 | 58 | this.lists = lists; |
64 | 59 | this.mongoTemplate = mongoTemplate; |
65 | 60 | this.okSize = okSize; |
66 | 61 | this.existSize = existSize; |
67 | 62 | this.errorSize = errorSize; |
68 | - | |
69 | 63 | this.basicConfigDao = basicConfigDao; |
70 | 64 | } |
71 | 65 | |
72 | 66 | @Override |
73 | - public BaseObjectResponse call() throws Exception { | |
74 | - BaseObjectResponse p=null; | |
75 | - for (YunBookbuildingAddRequest list : lists) { | |
76 | - Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("cardNo").is(list.getPregnantCertificateNum())), Patients.class); | |
77 | - if (patients != null) { | |
78 | - existSize.incrementAndGet(); | |
79 | - continue; | |
80 | - } | |
67 | + public BaseObjectResponse call() throws Exception { | |
68 | + BaseObjectResponse p=null; | |
69 | + for (YunBookbuildingAddRequest list : lists) { | |
70 | + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("cardNo").is(list.getPregnantCertificateNum())), Patients.class); | |
71 | + if (patients != null) { | |
72 | + existSize.incrementAndGet(); | |
73 | + continue; | |
74 | + } | |
81 | 75 | |
82 | - list.setHospitalId("216");//todo | |
83 | - list.setBookbuildingDoctor("1000000185");//todo | |
84 | - list.setBookbuildingDate(DateUtil.getyyyy_MM_dd(new Date())); | |
85 | - list.setHusbandNationId(queryParentConfig(list.getHusbandNationId())); | |
86 | - list.setPregnantNationId(queryParentConfig(list.getHusbandNationId())); | |
87 | - p = bookbuildingFacade.addPregnantBookbuilding(list, null, false); | |
88 | - if (ErrorCodeConstants.SUCCESS == p.getErrorcode()) { | |
89 | - okSize.incrementAndGet(); | |
90 | - } else { | |
91 | - errorSize.incrementAndGet(); | |
76 | + list.setHospitalId("216");//todo | |
77 | + list.setBookbuildingDoctor("1000000185");//todo | |
78 | + list.setBookbuildingDate(DateUtil.getyyyy_MM_dd(new Date())); | |
79 | + list.setHusbandNationId(queryParentConfig(list.getHusbandNationId())); | |
80 | + list.setPregnantNationId(queryParentConfig(list.getPregnantNationId())); | |
81 | + p = bookbuildingFacade.addPregnantBookbuilding(list, null, false); | |
82 | + if (ErrorCodeConstants.SUCCESS == p.getErrorcode()) { | |
83 | + okSize.incrementAndGet(); | |
84 | + } else { | |
85 | + errorSize.incrementAndGet(); | |
86 | + } | |
92 | 87 | } |
88 | + return p; | |
93 | 89 | } |
94 | - return p; | |
95 | - } | |
96 | 90 | |
97 | 91 | |
98 | 92 | |
99 | - public String queryParentConfig(String name) { | |
100 | - List<BasicConfig> basicConfigs = basicConfigDao.queryBasicConfig( | |
101 | - MongoCondition.newInstance("parentId", "4bc86dd6-2217-4a33-95f4-dc22ee70f2e3", MongoOper.IS). | |
102 | - and("yn", YnEnums.YES.getId(), MongoOper.IS). | |
103 | - and("name", name, MongoOper.IS).toMongoQuery() | |
93 | + public String queryParentConfig(String name) { | |
94 | + List<BasicConfig> basicConfigs = basicConfigDao.queryBasicConfig( | |
95 | + MongoCondition.newInstance("parentId", "4bc86dd6-2217-4a33-95f4-dc22ee70f2e3", MongoOper.IS). | |
96 | + and("yn", YnEnums.YES.getId(), MongoOper.IS). | |
97 | + and("name", name, MongoOper.IS).toMongoQuery() | |
104 | 98 | |
105 | - ); | |
106 | - return basicConfigs.get(0).getId(); | |
107 | - } | |
99 | + ); | |
100 | + if(basicConfigs.size()==0 || basicConfigs==null){ | |
101 | + return ""; | |
102 | + } | |
103 | + return basicConfigs.get(0).getId(); | |
104 | + } | |
108 | 105 | |
109 | -} | |
106 | + } |