|
|
|
@ -8,15 +8,12 @@ import com.jiashi.service.CardInfo;
|
|
|
|
|
import com.jiashi.service.FormField;
|
|
|
|
|
import com.jiashi.service.Picture;
|
|
|
|
|
import com.jiashi.service.UploadInfo;
|
|
|
|
|
import com.sun.xml.internal.ws.util.CompletedFuture;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
@ -27,8 +24,11 @@ import java.io.IOException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.concurrent.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author YongBin Wen
|
|
|
|
@ -268,15 +268,45 @@ public class LianZhongSyncController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 额外的表单字段参数
|
|
|
|
|
List<FormField> params = new ArrayList<>();
|
|
|
|
|
String s = new Gson().toJson(uploadInfos);
|
|
|
|
|
params.add(new FormField("uploadFileParams", s));
|
|
|
|
|
log.info("请求参数:" + cardInfo.getPatno());
|
|
|
|
|
Map<String, UploadInfo> uploadInfosMap = uploadInfos.stream().collect(Collectors.toMap(UploadInfo::getUploadFileName, Function.identity()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean success = true;
|
|
|
|
|
// 上传
|
|
|
|
|
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, "http://192.168.161.102:9511/fileUploadJpg", params);
|
|
|
|
|
if (commonResult.getCode() == 0) {
|
|
|
|
|
int totalSize = files.size();
|
|
|
|
|
int batchSize = 500;
|
|
|
|
|
if (totalSize > batchSize) {
|
|
|
|
|
for (int i = 0; i < totalSize; i += batchSize) {
|
|
|
|
|
ArrayList<File> batch = new ArrayList<>();
|
|
|
|
|
List<UploadInfo> uploadInfoParams = new ArrayList<>();
|
|
|
|
|
// 计算当前批次的结束索引
|
|
|
|
|
int end = Math.min(i + batchSize, totalSize);
|
|
|
|
|
for (int j = i; j < end; j++) {
|
|
|
|
|
batch.add(files.get(j));
|
|
|
|
|
uploadInfoParams.add(uploadInfosMap.get(files.get(j).getName()));
|
|
|
|
|
}
|
|
|
|
|
// 额外的表单字段参数
|
|
|
|
|
List<FormField> params = new ArrayList<>();
|
|
|
|
|
String s = new Gson().toJson(uploadInfoParams);
|
|
|
|
|
params.add(new FormField("uploadFileParams", s));
|
|
|
|
|
log.info("请求参数:" + cardInfo.getPatno());
|
|
|
|
|
CommonResult commonResult = FileUploader.uploadFilesWithParams(batch, "http://192.168.161.102:9511/batchFileUploadJpg", params);
|
|
|
|
|
boolean res = commonResult.getCode() == 0;
|
|
|
|
|
success = success && res;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 额外的表单字段参数
|
|
|
|
|
List<FormField> params = new ArrayList<>();
|
|
|
|
|
String s = new Gson().toJson(uploadInfos);
|
|
|
|
|
params.add(new FormField("uploadFileParams", s));
|
|
|
|
|
log.info("请求参数:" + cardInfo.getPatno());
|
|
|
|
|
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, "http://192.168.161.102:9511/fileUploadJpg", params);
|
|
|
|
|
success = commonResult.getCode() == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
|
dataQuery.updateBatchState(cardInfo, 3);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -295,4 +325,5 @@ public class LianZhongSyncController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|