Parcourir la source

修改图片上传

humuyu il y a 3 ans
Parent
commit
82e93db49f

+ 2 - 2
eladmin-system/src/main/java/me/zhengjie/appapi/util/FileUploadUtil.java

@@ -233,7 +233,7 @@ public class FileUploadUtil {
 			return null;
 		}
 
-		String logo = file.getFilePath();
+		String filePath = file.getFilePath();
 		MultipartFile multipartFile = file.getFile();
 		String uploadFileName = multipartFile.getOriginalFilename();
 
@@ -244,7 +244,7 @@ public class FileUploadUtil {
 		String suffix = uploadFileName.substring(index);
 		String fileName = uuid + "_" + file.getFileType() + suffix;
 		file.setFileName(fileName);
-		String imagePath = logo + "/" + fileName;
+		String imagePath = filePath + "/" + fileName;
 		try {
 			FileHandleVo fileHandlevo = new FileHandleVo();
 			fileHandlevo.setFilePath(imagePath);

+ 3 - 1
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/FileInfoController.java

@@ -16,6 +16,7 @@ import me.zhengjie.appapi.entity.FileInfoEntity;
 import me.zhengjie.appapi.service.ApiBankService;
 import me.zhengjie.appapi.service.FileInfoService;
 import me.zhengjie.appapi.util.FileUploadUtil;
+import me.zhengjie.appapi.util.StatusEnum.StepStatusEnum;
 import me.zhengjie.appapi.vo.FileUploadVo;
 import me.zhengjie.appapi.vo.FileVo;
 import me.zhengjie.base.ResponseDTO;
@@ -84,10 +85,11 @@ public class FileInfoController {
 		if (fileType == null) {
 			return ResponseDTO.error(ResultCode.PARAM_NOT_COMPLETE);
 		}
+		String path = businessNo + "/" + StepStatusEnum.getType(orderId) + "/" ;
 		log.info("文件上传参数:" + file);
 		FileVo filevo = new FileVo();
 		filevo.setFile(file);
-		filevo.setFilePath(type);
+		filevo.setFilePath(path);
 		filevo.setFileType(String.valueOf(fileType.getCode()));
 		String filePath = FileUploadUtil.upload(filevo);
 

+ 24 - 18
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/NotaryOrderServiceImpl.java

@@ -14,6 +14,7 @@ import me.zhengjie.appapi.util.BeanCopyUtils;
 import me.zhengjie.appapi.util.DateUtils;
 import me.zhengjie.appapi.util.FileUploadUtil;
 import me.zhengjie.appapi.util.StatusEnum;
+import me.zhengjie.appapi.util.StatusEnum.StepStatusEnum;
 import me.zhengjie.appapi.vo.FileVo;
 import me.zhengjie.base.ResultCode;
 import me.zhengjie.modules.security.service.dto.JwtUserDto;
@@ -553,29 +554,35 @@ public class NotaryOrderServiceImpl extends ServiceImpl<NotaryOrderMapper, Notar
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public BaseResponse uploadNotarization(FileVo file) {
+
 		BaseResponse response = new BaseResponse<>();
-		String uploadFileName = file.getFile().getOriginalFilename();
-		int index = uploadFileName.lastIndexOf(".");
-		String suffix = uploadFileName.substring(index);
-		String fileName = file.getFileName() + suffix;
-		String filePath = AppConfigInfo.APP_UPLOAD_PATH + "notarization/" + fileName;
-		String fileUrl =  "notarization/" + fileName;
-		File fullPath = new File(filePath);
-		if (fullPath.exists()) {
-			response.fail(ResultCode.FILE_EXISTING);
-		}
-		try {
-			FileUtils.copyInputStreamToFile(file.getFile().getInputStream(), fullPath);
-		} catch (Exception e) {
-			e.printStackTrace();
-			response.fail(ResultCode.INTERFACE_INNER_INVOKE_ERROR);
-		}
+//		String uploadFileName = file.getFile().getOriginalFilename();
+//		int index = uploadFileName.lastIndexOf(".");
+//		String suffix = uploadFileName.substring(index);
+//		String fileName = file.getFileName() + suffix;
+//		String filePath = AppConfigInfo.APP_UPLOAD_PATH + "notarization/" + fileName;
+//		String fileUrl =  "notarization/" + fileName;
+//		File fullPath = new File(filePath);
+//		if (fullPath.exists()) {
+//			response.fail(ResultCode.FILE_EXISTING);
+//		}
+//		try {
+//			FileUtils.copyInputStreamToFile(file.getFile().getInputStream(), fullPath);
+//		} catch (Exception e) {
+//			e.printStackTrace();
+//			response.fail(ResultCode.INTERFACE_INNER_INVOKE_ERROR);
+//		}
+
 		QueryWrapper<OrderDocEntity> orderDocQw = new QueryWrapper<>();
 		orderDocQw.eq("contract_id", file.getContractId());
 		OrderDocEntity orderDoc = orderDocMapper.selectOne(orderDocQw);
+		String path = orderDoc.getBusinessNo()+ "/" + StepStatusEnum.getType(orderDoc.getContractId()) + "/" ;
+		file.setFilePath(path);
+		String filePath = FileUploadUtil.upload(file);
+		
 		OrderDocEntity saveOrderDoc = new OrderDocEntity();
 		saveOrderDoc.setId(orderDoc.getId());
-		saveOrderDoc.setAuthNotarization(fileUrl);
+		saveOrderDoc.setAuthNotarization(filePath);
 		orderDocMapper.updateById(saveOrderDoc);
 		updateStatusPass(file.getContractId(), orderDoc.getBusinessNo());
 		return response;
@@ -705,7 +712,6 @@ public class NotaryOrderServiceImpl extends ServiceImpl<NotaryOrderMapper, Notar
 
 	public String getPreviewUrl(String path) {
 
-		 
 		return FileUploadUtil.getPreviewUrl(path);
 	}