From 7ff5fb90567aa225cb1b5915bd8644780f190268 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 2 Apr 2023 15:35:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=89=E5=8F=96=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../idc/service/impl/IdcServiceImpl.java | 30 +++++++++---------- .../sale/admin/thread/AsyncFetchTask.java | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/IdcServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/IdcServiceImpl.java index b6dfe84..92349cf 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/IdcServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/IdcServiceImpl.java @@ -108,9 +108,9 @@ public class IdcServiceImpl implements IdcService { if(map==null) ResultVOUtils.error(9000, "下载任务不存在"); String json = FileUtils.readFileAll(map.get("cacheFilePath").toString()); - logger.info("download-->"+json); + JSONObject object = JSON.parseObject(json); - if(object!=null&&object.getInteger("code")!=null&&object.getInteger("code")==20000) { + if(object!=null&&object.getInteger("code")!=null) { BaseResponse response = JSON.parseObject(json,BaseResponse.class); return response; } @@ -157,7 +157,7 @@ public class IdcServiceImpl implements IdcService { logger.info("fetch from ip:"+host); if(!StringUtils.isEmpty(host)) { String result = post(host+"/spssync/common/list",null); - logger.info("fetchTask--->"+result); + if(IDCUtils.isJson(result)) { JSONObject json = JSON.parseObject(result); if(json!=null&&json.getInteger("code")==20000&&json.getString("data")!=null) { @@ -166,7 +166,7 @@ public class IdcServiceImpl implements IdcService { for(Map map:list) { Map params = new HashMap(); params.put("taskId", map.get("taskId")); - fetchData(host+"/spssync/common/download",params); + fetchData(host,params); } } } @@ -254,13 +254,13 @@ public class IdcServiceImpl implements IdcService { - private String fetchData(String url,Map params) { + private String fetchData(String host,Map params) { OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(params)); Request request = new Request.Builder() - .url(url) + .url(host+"/spssync/common/download") .method("POST", body) .addHeader("Content-Type", "application/json") .build(); @@ -270,7 +270,6 @@ public class IdcServiceImpl implements IdcService { boolean success=true; Response response = client.newCall(request).execute(); result = response.body().string(); - logger.info("fetchData-->"+result); JSONObject json = JSONObject.parseObject(result); if(isLastLevel()) { success = analyToDB(json,files); @@ -280,7 +279,6 @@ public class IdcServiceImpl implements IdcService { syncAddTaskStatus(json,false,success); } - String host = getNextHost(); if(success) { String ret = post(host+"/spssync/common/success",params); @@ -310,7 +308,6 @@ public class IdcServiceImpl implements IdcService { try { Response response = client.newCall(request).execute(); result = response.body().string(); - logger.info("post-result-->"+result); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -607,16 +604,17 @@ public class IdcServiceImpl implements IdcService { if(jsonObject.getJSONObject("data")!=null) { JSONObject object = jsonObject.getJSONObject("data"); List> list = new ArrayList<>(); - if(object instanceof List) { list = jsonObject.getObject("data", List.class); } else { - object = jsonObject; - if(object.get("data")!=null) - list = object.getObject("data", List.class); + list = object.getObject("data", List.class); + + } + if(!StringUtils.isEmpty(object.getString("tableName"))) { + return analyData(object.getString("tableName"),object.getString("uniqueColumn"),list); + } else { + logger.error("数据格式错误:无数据标记"); } - if(!StringUtils.isEmpty(object.getString("tableName"))) - return analyData(object.getString("tableName"),jsonObject.getString("uniqueColumn"),list); //图片处理 } return false; @@ -738,6 +736,8 @@ public class IdcServiceImpl implements IdcService { } if(n>0) { result = (dbDao.save(sql)>0); + if(!result) + logger.error(tableName+"-->fetchSave Fail"); } } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/AsyncFetchTask.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/AsyncFetchTask.java index 1865da9..c088e99 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/thread/AsyncFetchTask.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/AsyncFetchTask.java @@ -35,7 +35,7 @@ public class AsyncFetchTask implements SchedulingConfigurer { scheduledRequest.setCronName("syncFetch"); logger.info("syncFetch----------------"); ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest); - String cron = scheduledEntity!=null ? scheduledEntity.getCron() : "* 0/5 * * * ?"; + String cron = scheduledEntity!=null ? scheduledEntity.getCron() : "* 0/2 * * * ?"; if (cron.isEmpty()) { logger.error("cron is null");