|
@@ -1,23 +1,26 @@
|
|
|
package com.platform.manage;
|
|
package com.platform.manage;
|
|
|
|
|
|
|
|
import com.platform.api.request.LicensePlateValidateRequest;
|
|
import com.platform.api.request.LicensePlateValidateRequest;
|
|
|
|
|
+import com.google.common.collect.Maps;
|
|
|
import com.platform.api.request.WeighbridgePushRequest;
|
|
import com.platform.api.request.WeighbridgePushRequest;
|
|
|
-import com.platform.entity.ValidateLicensePlate;
|
|
|
|
|
import com.platform.entity.WeighbridgeRecord;
|
|
import com.platform.entity.WeighbridgeRecord;
|
|
|
import com.platform.enums.ErrorCodeEnum;
|
|
import com.platform.enums.ErrorCodeEnum;
|
|
|
import com.platform.exception.IotException;
|
|
import com.platform.exception.IotException;
|
|
|
import com.platform.response.LicensePlateValidateResponse;
|
|
import com.platform.response.LicensePlateValidateResponse;
|
|
|
import com.platform.service.ValidateLicensePlateService;
|
|
import com.platform.service.ValidateLicensePlateService;
|
|
|
|
|
+import com.platform.result.HttpStatus;
|
|
|
import com.platform.service.WeighbridgeRecordService;
|
|
import com.platform.service.WeighbridgeRecordService;
|
|
|
|
|
+import com.platform.utils.FileUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import java.time.Instant;
|
|
import java.time.Instant;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
-import java.util.Arrays;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -60,8 +63,6 @@ public class WeighbridgeRecordManage {
|
|
|
throw new IotException(ErrorCodeEnum.DATA_SAVE_FAIL, "地磅数据保存失败");
|
|
throw new IotException(ErrorCodeEnum.DATA_SAVE_FAIL, "地磅数据保存失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- } catch (IotException e) {
|
|
|
|
|
- throw e;
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("地磅数据上报处理异常", e);
|
|
log.error("地磅数据上报处理异常", e);
|
|
|
throw new IotException(ErrorCodeEnum.SYSTEM_ERROR, "地磅数据上报异常: " + e.getMessage());
|
|
throw new IotException(ErrorCodeEnum.SYSTEM_ERROR, "地磅数据上报异常: " + e.getMessage());
|
|
@@ -102,10 +103,33 @@ public class WeighbridgeRecordManage {
|
|
|
* @return 逗号分隔的文件名字符串
|
|
* @return 逗号分隔的文件名字符串
|
|
|
*/
|
|
*/
|
|
|
private String processImageFiles(MultipartFile[] images) {
|
|
private String processImageFiles(MultipartFile[] images) {
|
|
|
- return Arrays.stream(images)
|
|
|
|
|
- .map(MultipartFile::getOriginalFilename)
|
|
|
|
|
- .filter(name -> name != null && !name.isEmpty())
|
|
|
|
|
- .collect(Collectors.joining(","));
|
|
|
|
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
|
|
+ Arrays.stream(images).forEach(x->{
|
|
|
|
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
|
|
|
+ //文件名称
|
|
|
|
|
+ String originalFilename = x.getOriginalFilename();
|
|
|
|
|
+ map.put("code", HttpStatus.SUCCESS_CODE);
|
|
|
|
|
+ map.put("fileName", originalFilename);
|
|
|
|
|
+ map.put("message", HttpStatus.SUCCESS_MESSAGE);
|
|
|
|
|
+ String oosUrl = null;
|
|
|
|
|
+ //上传文件是否成功
|
|
|
|
|
+ try {
|
|
|
|
|
+ oosUrl = FileUtils.uploadFile(x);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ map.put("code", HttpStatus.GLOBAL_EXCEPTION_CODE);
|
|
|
|
|
+ map.put("fileName", originalFilename);
|
|
|
|
|
+ map.put("message", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(oosUrl)) {
|
|
|
|
|
+ map.put("code", HttpStatus.GLOBAL_EXCEPTION_CODE);
|
|
|
|
|
+ map.put("fileName", originalFilename);
|
|
|
|
|
+ map.put("message", HttpStatus.SUCCESS_MESSAGE);
|
|
|
|
|
+ }
|
|
|
|
|
+ //上传至oss文件地址
|
|
|
|
|
+ map.put("oosUrl", oosUrl);
|
|
|
|
|
+ resultList.add(map);
|
|
|
|
|
+ });
|
|
|
|
|
+ return resultList.stream().map(x -> x.get("fileName").toString()).collect(Collectors.joining(","));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|