Commit 968cd8916064d4977f2d1976aef77441ff2baae8
1 parent
0fa67c72be
Exists in
master
and in
6 other branches
lis
Showing 1 changed file with 29 additions and 24 deletions
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java
View file @
968cd89
| ... | ... | @@ -38,6 +38,8 @@ |
| 38 | 38 | @Service("lisService") |
| 39 | 39 | public class LisServiceImpl implements LisService { |
| 40 | 40 | |
| 41 | + private static final int BATCH_SIZE = 10; | |
| 42 | + | |
| 41 | 43 | @Autowired |
| 42 | 44 | private MasterLisMapper masterLisMapper; |
| 43 | 45 | @Autowired |
| 44 | 46 | |
| 45 | 47 | |
| ... | ... | @@ -52,14 +54,13 @@ |
| 52 | 54 | System.out.println("saveLis data size = "+ lisList.size()); |
| 53 | 55 | if (CollectionUtils.isNotEmpty(lisList)) |
| 54 | 56 | { |
| 55 | - int batchSize = 10; | |
| 56 | 57 | //线程数 |
| 57 | - int threadCount = lisList.size()%batchSize == 0 ? lisList.size()/batchSize : lisList.size()/batchSize+1; | |
| 58 | + int threadCount = lisList.size()%BATCH_SIZE == 0 ? lisList.size()/BATCH_SIZE : lisList.size()/BATCH_SIZE+1; | |
| 58 | 59 | System.out.println("threadCount = "+ threadCount); |
| 59 | 60 | CountDownLatch countDownLatch = new CountDownLatch(threadCount); |
| 60 | 61 | int end = 0; |
| 61 | - for (int i = 0; i < lisList.size(); i += batchSize) { | |
| 62 | - end = (end + batchSize); | |
| 62 | + for (int i = 0; i < lisList.size(); i += BATCH_SIZE) { | |
| 63 | + end = (end + BATCH_SIZE); | |
| 63 | 64 | if (end > lisList.size()) { |
| 64 | 65 | end = lisList.size(); |
| 65 | 66 | } |
| 66 | 67 | |
| 67 | 68 | |
| 68 | 69 | |
| 69 | 70 | |
| 70 | 71 | |
| ... | ... | @@ -141,28 +142,32 @@ |
| 141 | 142 | |
| 142 | 143 | @Override |
| 143 | 144 | public void run() { |
| 144 | - for(LisReportModel model : lisList) | |
| 145 | - { | |
| 146 | - try { | |
| 147 | - masterLisMapper.deleteLisData(model); | |
| 148 | - masterLisMapper.saveLisData(model); | |
| 145 | + try { | |
| 146 | + for (LisReportModel model : lisList) { | |
| 147 | + try { | |
| 148 | + masterLisMapper.deleteLisData(model); | |
| 149 | + masterLisMapper.saveLisData(model); | |
| 149 | 150 | |
| 150 | - //临时用一下,未确定使用查询方式 | |
| 151 | - LisReportQuery lisReportQuery = new LisReportQuery(); | |
| 152 | - lisReportQuery.setLisId(model.getLisId()); | |
| 153 | - lisReportQuery.setVcCardNo(model.getVcCardNo()); | |
| 154 | - lisReportQuery.setHospitalId(model.getHospitalId()); | |
| 151 | + //临时用一下,未确定使用查询方式 | |
| 152 | + LisReportQuery lisReportQuery = new LisReportQuery(); | |
| 153 | + lisReportQuery.setLisId(model.getLisId()); | |
| 154 | + lisReportQuery.setVcCardNo(model.getVcCardNo()); | |
| 155 | + lisReportQuery.setHospitalId(model.getHospitalId()); | |
| 155 | 156 | |
| 156 | - List<LisReportModel> lisReportModels = masterLisMapper.queryLisDataByModel(lisReportQuery); | |
| 157 | - saveLisUpdateData(lisReportModels.get(0)); | |
| 157 | + List<LisReportModel> lisReportModels = masterLisMapper.queryLisDataByModel(lisReportQuery); | |
| 158 | + saveLisUpdateData(lisReportModels.get(0)); | |
| 158 | 159 | |
| 159 | - } catch (Exception e) | |
| 160 | - { | |
| 161 | - continue; | |
| 162 | - } | |
| 160 | + } catch (Exception e) { | |
| 161 | + continue; | |
| 162 | + } | |
| 163 | 163 | |
| 164 | + } | |
| 164 | 165 | } |
| 165 | - countDownLatch.countDown(); | |
| 166 | + finally | |
| 167 | + { | |
| 168 | + countDownLatch.countDown(); | |
| 169 | + } | |
| 170 | + | |
| 166 | 171 | } |
| 167 | 172 | } |
| 168 | 173 |