|
@@ -35,8 +35,6 @@ public class UploadController {
|
|
MinioUtils minioUtils;
|
|
MinioUtils minioUtils;
|
|
@Autowired
|
|
@Autowired
|
|
BaseCameraManagementService baseCameraManagementService;
|
|
BaseCameraManagementService baseCameraManagementService;
|
|
- @Value("${base.imgUrl}")
|
|
|
|
- private String imgUrl;
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private BaseRailwayManagementService baseRailwayManagementService;
|
|
private BaseRailwayManagementService baseRailwayManagementService;
|
|
|
|
|
|
@@ -48,6 +46,8 @@ public class UploadController {
|
|
@RequestParam(value = "alarmMile", required = false) Integer alarmMile,
|
|
@RequestParam(value = "alarmMile", required = false) Integer alarmMile,
|
|
@RequestParam(value = "alarmRailway", required = false) String alarmRailway,
|
|
@RequestParam(value = "alarmRailway", required = false) String alarmRailway,
|
|
@RequestParam(value = "fileType", required = false) Integer fileType,
|
|
@RequestParam(value = "fileType", required = false) Integer fileType,
|
|
|
|
+ @RequestParam(value = "fileName", required = false) String fileName,
|
|
|
|
+ @RequestParam(value = "pointCode", required = false) String pointCode,
|
|
@RequestParam(value = "lineDir", required = false) Integer lineDir) throws Exception {
|
|
@RequestParam(value = "lineDir", required = false) Integer lineDir) throws Exception {
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
@@ -57,7 +57,7 @@ public class UploadController {
|
|
jsonObject.put("data", "不能上传空文件哦");
|
|
jsonObject.put("data", "不能上传空文件哦");
|
|
return jsonObject;
|
|
return jsonObject;
|
|
}
|
|
}
|
|
- if (lineDir!=1&&lineDir!=2){
|
|
|
|
|
|
+ if (lineDir != 1 && lineDir != 2) {
|
|
jsonObject.put("resultCode", 0);
|
|
jsonObject.put("resultCode", 0);
|
|
jsonObject.put("message", "失败");
|
|
jsonObject.put("message", "失败");
|
|
jsonObject.put("data", "行别填写错误");
|
|
jsonObject.put("data", "行别填写错误");
|
|
@@ -75,36 +75,42 @@ public class UploadController {
|
|
jsonObject.put("data", "要上传的stream的填写格式不正确");
|
|
jsonObject.put("data", "要上传的stream的填写格式不正确");
|
|
return jsonObject;
|
|
return jsonObject;
|
|
}
|
|
}
|
|
- if (ObjectUtils.isEmpty(contentType)){
|
|
|
|
|
|
+ if (ObjectUtils.isEmpty(contentType)) {
|
|
jsonObject.put("resultCode", 0);
|
|
jsonObject.put("resultCode", 0);
|
|
jsonObject.put("message", "失败");
|
|
jsonObject.put("message", "失败");
|
|
jsonObject.put("data", "Content Type不能为空");
|
|
jsonObject.put("data", "Content Type不能为空");
|
|
return jsonObject;
|
|
return jsonObject;
|
|
}
|
|
}
|
|
|
|
+ if (ObjectUtils.isEmpty(pointCode)) {
|
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
|
+ jsonObject.put("message", "失败");
|
|
|
|
+ jsonObject.put("data", "测点编码不能为空");
|
|
|
|
+ return jsonObject;
|
|
|
|
+ }
|
|
|
|
+ if (ObjectUtils.isEmpty(fileName)) {
|
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
|
+ jsonObject.put("message", "失败");
|
|
|
|
+ jsonObject.put("data", "文件名不能为空");
|
|
|
|
+ return jsonObject;
|
|
|
|
+ }
|
|
LambdaQueryWrapper<BaseRailwayManagement> queryWrapper = new LambdaQueryWrapper<BaseRailwayManagement>();
|
|
LambdaQueryWrapper<BaseRailwayManagement> queryWrapper = new LambdaQueryWrapper<BaseRailwayManagement>();
|
|
if (!ObjectUtils.isEmpty(alarmRailway)) {
|
|
if (!ObjectUtils.isEmpty(alarmRailway)) {
|
|
queryWrapper.eq(BaseRailwayManagement::getRailwayCode, alarmRailway);
|
|
queryWrapper.eq(BaseRailwayManagement::getRailwayCode, alarmRailway);
|
|
}
|
|
}
|
|
BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
|
|
BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
|
|
- if (ObjectUtils.isEmpty(baseRailwayManagement)){
|
|
|
|
|
|
+ if (ObjectUtils.isEmpty(baseRailwayManagement)) {
|
|
jsonObject.put("resultCode", 0);
|
|
jsonObject.put("resultCode", 0);
|
|
jsonObject.put("message", "失败");
|
|
jsonObject.put("message", "失败");
|
|
jsonObject.put("data", "填写的报警线路编码不存在");
|
|
jsonObject.put("data", "填写的报警线路编码不存在");
|
|
return jsonObject;
|
|
return jsonObject;
|
|
}
|
|
}
|
|
- //图片保存路径
|
|
|
|
- //String fileUploadPath ="/"+userId+"/image";
|
|
|
|
- String uploadFile = null;
|
|
|
|
if (!stream.isEmpty()) {
|
|
if (!stream.isEmpty()) {
|
|
-
|
|
|
|
String imageName = stream.getOriginalFilename();
|
|
String imageName = stream.getOriginalFilename();
|
|
if (StringUtils.isNotBlank(imageName)) {
|
|
if (StringUtils.isNotBlank(imageName)) {
|
|
-// String filename = IdUtils.fastSimpleUUID() + stream.getOriginalFilename().substring(stream.getOriginalFilename().lastIndexOf("."));
|
|
|
|
- SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
+ SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyyMMdd");
|
|
String format1 = dateFormat1.format(new Date());
|
|
String format1 = dateFormat1.format(new Date());
|
|
- String imgName = alarmRailway + "/" + lineDir + "/" + alarmMile + "/" + format1 + "/" + imageName;
|
|
|
|
|
|
+ String imgName = "yiwuqinxian/"+alarmRailway + "/" + pointCode + "/" + format1 + "/" + imageName;
|
|
minioUtils.minIoClientUpload(stream.getInputStream(), imgName);
|
|
minioUtils.minIoClientUpload(stream.getInputStream(), imgName);
|
|
- uploadFile = imgUrl+"/" + alarmRailway + "/" + lineDir + "/" + alarmMile + "/" + format1 + "/" + imageName;
|
|
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
jsonObject.put("resultCode", 0);
|
|
jsonObject.put("resultCode", 0);
|
|
@@ -112,11 +118,9 @@ public class UploadController {
|
|
jsonObject.put("data", "图片为null");
|
|
jsonObject.put("data", "图片为null");
|
|
return jsonObject;
|
|
return jsonObject;
|
|
}
|
|
}
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("url", uploadFile);
|
|
|
|
jsonObject.put("resultCode", 1);
|
|
jsonObject.put("resultCode", 1);
|
|
jsonObject.put("message", "成功");
|
|
jsonObject.put("message", "成功");
|
|
- jsonObject.put("data", map);
|
|
|
|
|
|
+ jsonObject.put("data", null);
|
|
return jsonObject;
|
|
return jsonObject;
|
|
}
|
|
}
|
|
}
|
|
}
|