文件下载问题

pro
wj 2 years ago
parent bd8bd6820d
commit 7a3e8b72cb

@ -39,4 +39,6 @@ public interface IdcService {
BaseResponse onceSync(String tableName,boolean isUpload); BaseResponse onceSync(String tableName,boolean isUpload);
boolean signleDownloadFile(String syncIp, String fileName); boolean signleDownloadFile(String syncIp, String fileName);
boolean batchDownloadFile(String syncIp, String[] files);
} }

@ -1145,7 +1145,7 @@ public class IdcServiceImpl implements IdcService {
} }
/*下载文件*/ /*下载文件*/
private boolean batchDownloadFile(String syncIp, String[] files) { public boolean batchDownloadFile(String syncIp, String[] files) {
boolean success = true; boolean success = true;
for (String fileName : files) { for (String fileName : files) {
if (!StringUtils.isEmpty(fileName)) { if (!StringUtils.isEmpty(fileName)) {

@ -20,4 +20,5 @@ public class SpsSyncBasicDataResponse extends BaseSyncResponse {
List<SupCompanyEntity> supCompanyList; List<SupCompanyEntity> supCompanyList;
List<SupManufacturerEntity> supManufacturerList; List<SupManufacturerEntity> supManufacturerList;
List<SupProductEntity> supProductList; List<SupProductEntity> supProductList;
List<String> syncFiles;
} }

@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
@ -30,6 +31,7 @@ import com.glxp.api.entity.system.*;
import com.glxp.api.entity.thrsys.*; import com.glxp.api.entity.thrsys.*;
import com.glxp.api.http.sync.SpGetHttpClient; import com.glxp.api.http.sync.SpGetHttpClient;
import com.glxp.api.idc.service.FileService; import com.glxp.api.idc.service.FileService;
import com.glxp.api.idc.service.IdcService;
import com.glxp.api.req.sync.SpsSyncDataRequest; import com.glxp.api.req.sync.SpsSyncDataRequest;
import com.glxp.api.res.sync.*; import com.glxp.api.res.sync.*;
import com.glxp.api.service.auth.*; import com.glxp.api.service.auth.*;
@ -241,14 +243,14 @@ public class HeartService {
String taskId = CustomUtil.getId(); String taskId = CustomUtil.getId();
switch (exportType) { switch (exportType) {
case BASIC_DATA: case BASIC_DATA:
if (needExec(info.getBasicProducts(), info.getBasicCorp(), info.getSupCert())) { // if (needExec(info.getBasicProducts(), info.getBasicCorp(), info.getSupCert())) {
uploadData(exportType, taskId, x -> x.getBasicData(info, taskId, now, syncTime)); // uploadData(exportType, taskId, x -> x.getBasicData(info, taskId, now, syncTime));
} // }
break; break;
case OTHER_DATA: case OTHER_DATA:
if (needExec(info.getUdiCodeLost(), info.getUdiCodeRel())) { // if (needExec(info.getUdiCodeLost(), info.getUdiCodeRel())) {
uploadData(exportType, taskId, x -> x.getOtherData(info, taskId, now, syncTime)); // uploadData(exportType, taskId, x -> x.getOtherData(info, taskId, now, syncTime));
} // }
break; break;
case DOCUMENT_TYPE_DATA: case DOCUMENT_TYPE_DATA:
if (needExec(info.getTypeBus(), info.getTypeScan(), info.getTypeThird())) { if (needExec(info.getTypeBus(), info.getTypeScan(), info.getTypeThird())) {
@ -1370,6 +1372,8 @@ public class HeartService {
}); });
if (response.getCode() == 20000 && response.getData() != null) { if (response.getCode() == 20000 && response.getData() != null) {
JSONArray fileJson = JSONUtil.parseObj(response.getData()).getJSONArray("files");
SpsSyncOrderResponse syncDataResponse = JSONObject.parseObject(response.getData(), new TypeReference<SpsSyncOrderResponse>() { SpsSyncOrderResponse syncDataResponse = JSONObject.parseObject(response.getData(), new TypeReference<SpsSyncOrderResponse>() {
}); });
BasicDownloadStatusEntity basicDownloadStatusEntity = new BasicDownloadStatusEntity(); BasicDownloadStatusEntity basicDownloadStatusEntity = new BasicDownloadStatusEntity();
@ -1404,7 +1408,12 @@ public class HeartService {
} }
} }
} }
if (fileJson != null&&fileJson.size()>0) {
List<String> syncFiles = fileJson.toList(String.class);
if (CollUtil.isNotEmpty(syncFiles)) {
idcService.batchDownloadFile(spGetHttp.getIpUrl(), syncFiles.toArray(new String[syncFiles.size()]));
}
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -1638,13 +1647,14 @@ public class HeartService {
supProductDao.replaceBatch(supProductList); supProductDao.replaceBatch(supProductList);
} }
if (CollUtil.isNotEmpty(syncFiles)) { if (CollUtil.isNotEmpty(syncFiles)) {
fileService.download(syncFiles); // fileService.download(syncFiles);
idcService.batchDownloadFile(spGetHttp.getIpUrl(), syncFiles.toArray(new String[syncFiles.size()]));
} }
} }
@Resource @Resource
FileService fileService; FileService fileService;
private final IdcService idcService;
private final IoCodeLostMapper ioCodeLostMapper; private final IoCodeLostMapper ioCodeLostMapper;
private final IoCodeRelMapper ioCodeRelMapper; private final IoCodeRelMapper ioCodeRelMapper;

Loading…
Cancel
Save