|
@@ -1,10 +1,16 @@
|
|
|
package com.ozs.controller.upload;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.ozs.common.core.domain.AjaxResult;
|
|
|
import com.ozs.common.utils.MinioUtils;
|
|
|
import com.ozs.common.utils.StringUtils;
|
|
|
import com.ozs.common.utils.uuid.IdUtils;
|
|
|
+import com.ozs.service.entity.BaseDynamicManagement;
|
|
|
+import com.ozs.service.entity.MsgAlarm;
|
|
|
+import com.ozs.service.service.MsgAlarmService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -14,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/system/upLoad")
|
|
@@ -24,26 +31,38 @@ public class UploadController {
|
|
|
|
|
|
@Resource
|
|
|
MinioUtils minioUtils;
|
|
|
+ @Autowired
|
|
|
+ MsgAlarmService msgAlarmService;
|
|
|
|
|
|
|
|
|
@PostMapping("/upLoadImage")
|
|
|
public AjaxResult upLoadImage(@RequestParam("file") MultipartFile image,
|
|
|
- @RequestParam(value = "storagePath", required = false) String storagePath) throws Exception {
|
|
|
+ @RequestParam(value = "cameraCode", required = false) String cameraCode,
|
|
|
+ @RequestParam(value = "lineType", required = false) String lineType) throws Exception {
|
|
|
if (image.isEmpty()) {
|
|
|
return AjaxResult.error("不能上传空文件哦");
|
|
|
}
|
|
|
//图片保存路径
|
|
|
//String fileUploadPath ="/"+userId+"/image";
|
|
|
- String uploadFile=null;
|
|
|
+ String uploadFile = null;
|
|
|
if (image != null && !image.isEmpty()) {
|
|
|
|
|
|
String imageName = image.getOriginalFilename();
|
|
|
if (StringUtils.isNotBlank(imageName)) {
|
|
|
+ LambdaQueryWrapper<MsgAlarm> lw = new LambdaQueryWrapper<MsgAlarm>();
|
|
|
+ if (!ObjectUtils.isEmpty(cameraCode)) {
|
|
|
+ lw.eq(MsgAlarm::getAlarmCamera, cameraCode);
|
|
|
+ lw.orderByDesc(MsgAlarm::getAlarmTime);
|
|
|
+ }
|
|
|
+ List<MsgAlarm> list = msgAlarmService.list(lw);
|
|
|
+ MsgAlarm msgAlarm = list.get(0);
|
|
|
String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
|
|
String filename = IdUtils.fastSimpleUUID() + image.getOriginalFilename().substring(image.getOriginalFilename().lastIndexOf("."));
|
|
|
- String imgName = storagePath + "/" + filename;
|
|
|
+ SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String format1 = dateFormat1.format(new Date(msgAlarm.getAlarmTime()));
|
|
|
+ String imgName = msgAlarm.getAlarmLine() + "/" + lineType + "/" + msgAlarm.getAlarmMile() + format1 + "/" + filename;
|
|
|
minioUtils.minIoClientUpload(image.getInputStream(), imgName);
|
|
|
- uploadFile = "/" + storagePath + "/" + filename;
|
|
|
+ uploadFile = "/" + msgAlarm.getAlarmLine() + "/" + lineType + "/" + msgAlarm.getAlarmMile() + "/" + format1 + "/" + filename;
|
|
|
|
|
|
}
|
|
|
} else {
|