From 8bb73c6f5cca1f7cde201b9894fdca6757c3891d Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 6 Apr 2023 06:50:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=89=E5=8F=96=E7=8A=B6=E6=80=81=E4=BF=9D?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/idc/service/impl/IdcServiceImpl.java | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java b/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java index f8a769f99..acf50e066 100644 --- a/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java +++ b/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java @@ -301,11 +301,11 @@ public class IdcServiceImpl implements IdcService { } else { success = false; } - + syncAddTaskStatus(json.getJSONObject("data"),3,success); } else { if(json.get("code")!=null&&json.get("data")!=null) { logger.info("res1-->"+JSON.toJSONString(json)); - syncAddTaskStatus(json.getJSONObject("data"),false,success); + syncAddTaskStatus(json.getJSONObject("data"),0,success); analyMiddle(host,json.getJSONObject("data"),files,false,false); } } @@ -396,20 +396,27 @@ public class IdcServiceImpl implements IdcService { } } - syncAddTaskStatus(json,true,true); + /*解析入库*/ + boolean success = false; if(isLastLevel()) { - if(!analyMiddle("",json,files,true,true)) + success = analyMiddle("",json,files,true,true); + syncAddTaskStatus(json,2,success); + if(!success) { + return ResultVOUtils.error(9000, "解析失败"); + } } else { //需要转发 if(isRelay()) { String host = getNextHost(); String result = relay(request.getHeader("reqNo"),content,saveFiles,host); if(IDCUtils.isJson(result)) { + syncAddTaskStatus(json,1,true); BaseResponse object = JSON.parseObject(result,BaseResponse.class); return object; } else { + syncAddTaskStatus(json,1,false); return ResultVOUtils.error(9000, "转发失败"); } @@ -438,7 +445,9 @@ public class IdcServiceImpl implements IdcService { public void downloadFile(String fileName,HttpServletResponse response) { OutputStream os; String filePathSlash = filePath.substring(filePath.length() -1).equals("/") ? "" : fileName.substring(0,1).equals("/") ? "" : "/"; - + if(!FileUtils.isFileExist(filePath+filePathSlash+fileName)) + fileName = "11.jpg"; + logger.info(filePath+filePathSlash+fileName); try { if(FileUtils.isFileExist(filePath+filePathSlash+fileName)) { byte[] bytes = FileUtils.readFileByBytes(filePath+filePathSlash+fileName); @@ -475,14 +484,12 @@ public class IdcServiceImpl implements IdcService { dbDao.save(sql); } - private void saveDownloadStatus(String messageType,String taskId,String remark) { + private void saveDownloadStatus(Map params) { Map map = new HashMap(); + map.put("receiveStatus", "0"); + map.putAll(params); map.put("id", CustomUtil.getId()); - map.put("taskId", taskId); - map.put("status", "0"); - map.put("type", messageType); map.put("updateTime", new Date()); - map.put("remark", remark); Map columns = getColumn("basic_download_status"); String sql = "insert into basic_download_status "+DBAUtils.parseInsert(map, columns); @@ -616,24 +623,24 @@ public class IdcServiceImpl implements IdcService { if(!StringUtils.isEmpty(recordSql)) { dbDao.save("insert into idc_record (id,type,fkId,isEnd,createTime) values "+recordSql); } - saveDownloadStatus(messageType,json.getString("reqNo"),messageType+" 记录数:"+list.size()+"/"+total); saveIdcLog(messageType,"",tableName +">success",i *limit,total); } else { success = false; - logger.error(result); + saveIdcLog(messageType,"",tableName +">"+result,i *limit,total); } } else { success = false; saveIdcLog(messageType,"",syncIp+":"+tableName +">fail:上传地址未连通",i *limit,total); } + } else { if(!StringUtils.isEmpty(recordSql)) { dbDao.save("insert into idc_record (id,type,fkId,isEnd,createTime) values "+recordSql); } saveIdcLog(messageType,"",tableName +">success",i *limit,total); } - syncAddTaskStatus(data,isUpload,success); + syncAddTaskStatus(data,isUpload ? 1 : 0 ,success); } } } @@ -644,7 +651,7 @@ public class IdcServiceImpl implements IdcService { } /*增加同步任务状态*/ - private void syncAddTaskStatus(Map json,boolean isUpload,boolean success) { + private void syncAddTaskStatus(Map json,int scheduleType,boolean success) { try { String content = JSON.toJSONString(json); @@ -662,13 +669,18 @@ public class IdcServiceImpl implements IdcService { //type,transportType,superiorService,subordinateService,cacheFilePath Map map = new HashMap<>(); map.put("type", json.get("messageType")); - map.put("transportType", isUpload ? "1" : "2"); - map.put("scheduleType", isUpload ? "1" : "0"); + map.put("transportType", scheduleType == 0 ? "1" : "2"); + map.put("scheduleType", scheduleType); map.put("taskId", json.get("messageId")); map.put("cacheFilePath", fileName); map.put("status", success ? "1" : "0"); - - saveExportStatus(map); + if(scheduleType==2) { + saveUploadStatus(map); + } else if (scheduleType==3) { + saveDownloadStatus(map); + } else { + saveExportStatus(map); + } } catch (Exception ex) { logger.error(ex.getMessage()); }