Commit 0dc20b9af69e5ee13ea95523322f06631be7f8a1

Authored by liquanyu
1 parent 2327098a02

update

Showing 1 changed file with 58 additions and 0 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java View file @ 0dc20b9
... ... @@ -237,8 +237,59 @@
237 237 }
238 238 }
239 239  
  240 +
240 241 /**
  242 + * 同步南充中心医院的数据到线上
241 243 * 定时任务配置applicationContext.xml
  244 + */
  245 + public void nczxyySyncDataSSL() {
  246 +
  247 + try{
  248 + String json = HttpClientUtil.doPost("https://area-nc-api.healthbaby.com.cn:12356/findSyncData", new HashMap<String, String>(), "utf-8");
  249 + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(json))
  250 + {
  251 + List<SyncDataModel> list = JsonUtil.toList(json, SyncDataModel.class);
  252 + System.out.println("nczxyy syncdata size = "+ list.size());
  253 + int batchSize = 200;
  254 + int end = 0;
  255 + for (int i = 0; i < list.size(); i += batchSize) {
  256 + end = (end + batchSize);
  257 + if (end > list.size()) {
  258 + end = list.size();
  259 + }
  260 + System.out.println("nczxyy start:" + i + ",end:" + end);
  261 + final List<SyncDataModel> tempList = list.subList(i, end);
  262 + new Thread(new Runnable() {
  263 + @Override
  264 + public void run() {
  265 + if (CollectionUtils.isNotEmpty(tempList))
  266 + {
  267 + StringBuffer ids = new StringBuffer();
  268 + for (SyncDataModel model : tempList) {
  269 + boolean boo = mongoSyncService.syncData(model.getAction(), model.getDataId(), model.getClassName(), model.getJsonData());
  270 + if (boo) {
  271 + ids.append(model.getId());
  272 + ids.append(",");
  273 + }
  274 + }
  275 + if (ids.length() > 0) {
  276 + Map<String,String> params = new HashMap<String, String>();
  277 + params.put("ids", ids.toString());
  278 + String result = HttpClientUtil.doPost("https://area-nc-api.healthbaby.com.cn:12356/updateSyncData", params, "utf-8");
  279 + System.out.println("exc result = "+ result);
  280 + }
  281 + }
  282 + }
  283 + }).start();
  284 + }
  285 + }
  286 + }catch(Exception ex){
  287 + ExceptionUtils.catchException(ex, "nczxyySyncDataSSL Error.");
  288 + }
  289 + }
  290 +
  291 + /**
  292 + * 定时任务配置applicationContext.xml
242 293 *
243 294 */
244 295 public void syncDataSSL()
... ... @@ -257,6 +308,13 @@
257 308 dzfySyncDataSSL();
258 309 }
259 310 },"dzfy-thread").start();
  311 +
  312 + new Thread(new Runnable() {
  313 + @Override
  314 + public void run() {
  315 + nczxyySyncDataSSL();
  316 + }
  317 + },"nczxyy-thread").start();
260 318  
261 319 }
262 320