|
@@ -10,6 +10,7 @@ import com.rongwei.bsentity.dto.ApiReturnDto;
|
|
|
import com.rongwei.commonservice.service.ApiLogService;
|
|
|
import com.rongwei.commonservice.service.RedisService;
|
|
|
import com.rongwei.commonservice.service.SysConfigService;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.Constants;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
@@ -18,8 +19,13 @@ import com.rongwei.rwcommonentity.commonservers.domain.ApiLogDo;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.io.FileSystemResource;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
+import org.springframework.util.MultiValueMap;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
@@ -116,6 +122,47 @@ public class AttendanceAssessmentSdk {
|
|
|
return apiReturnDto;
|
|
|
}
|
|
|
|
|
|
+ public R fileUploadApiCall(ApiCallDto paramVo) {
|
|
|
+ logger.info("接口调用开始:{}", paramVo.getApiCode());
|
|
|
+ // 请求地址
|
|
|
+ String url = this.clientIp + this.apiVirtualDirectoryMap.get(paramVo.getApiCode());
|
|
|
+ logger.info("api地址:{}", url);
|
|
|
+
|
|
|
+ String apiResult = null;
|
|
|
+ String fileId = "";
|
|
|
+
|
|
|
+ /**********************组装请求参数**************************************/
|
|
|
+ MultiValueMap<String, Object> postData = new LinkedMultiValueMap<>();
|
|
|
+ Map<String, Object> requestData = getRequestData();
|
|
|
+ requestData.put("TOKEN", getToken());
|
|
|
+ postData.set("STANDARD_DATA", requestData);
|
|
|
+ FileSystemResource resource = new FileSystemResource((File) paramVo.getData());
|
|
|
+ postData.set("UPLOAD_FILE", resource);
|
|
|
+ JSONConfig config = new JSONConfig();
|
|
|
+ config.setIgnoreNullValue(false);
|
|
|
+ String jsonStr = JSONUtil.toJsonStr(postData, config);
|
|
|
+ logger.info("入参:{}", jsonStr);
|
|
|
+ try {
|
|
|
+ RestTemplate rest = new RestTemplate();
|
|
|
+ url = "http://localhost:9689/synchronization/file";
|
|
|
+ apiResult = rest.postForObject(url, postData, String.class);
|
|
|
+
|
|
|
+ logger.info("接口返回报文:{}", apiResult);
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(apiResult);
|
|
|
+ fileId = jsonObject.getOrDefault("FILE_ID", "").toString();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.error("接口调用异常", e.getMessage());
|
|
|
+ apiResult = "接口调用异常:" + e.getMessage();
|
|
|
+ } finally {
|
|
|
+ // 接口调用结束后续逻辑处理
|
|
|
+ String finalApiResult = apiResult;
|
|
|
+ Thread td = new Thread(() -> afterAll(paramVo, jsonStr, finalApiResult));
|
|
|
+ td.start();
|
|
|
+ }
|
|
|
+ return R.ok(fileId);
|
|
|
+ }
|
|
|
+
|
|
|
private String getToken() {
|
|
|
logger.info("获取token开始");
|
|
|
if (redisService.hasKey(REDIS_KEY_NAME)) {
|