|
@@ -2,6 +2,7 @@ package com.huimv.farm.damsubsidy.controller;
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
@@ -104,30 +105,36 @@ public class BillLandingInspectionController {
|
|
|
public Result addPay(HttpServletRequest httpServletRequest,
|
|
|
@RequestParam(name = "idCordBackUrl",required = false) MultipartFile idCordBackUrl,
|
|
|
@RequestParam("id") String id) {
|
|
|
- String imgname = "成功";
|
|
|
- String originalFilename = idCordBackUrl.getOriginalFilename();
|
|
|
- String filenameExtension = StringUtils.getFilenameExtension(originalFilename);
|
|
|
- String path = DateUtil.format(new Date(), "yyyy-MM");
|
|
|
- try {
|
|
|
- InputStream inputStream = idCordBackUrl.getInputStream();
|
|
|
- BufferedInputStream in = new BufferedInputStream(inputStream);
|
|
|
- ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
|
|
|
- byte[] temp = new byte[1024];
|
|
|
- int size = 0;
|
|
|
- while ((size = in.read(temp)) != -1) {
|
|
|
- out.write(temp, 0, size);
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(idCordBackUrl)) {
|
|
|
+ String imgname = "成功";
|
|
|
+ String originalFilename = idCordBackUrl.getOriginalFilename();
|
|
|
+ String filenameExtension = StringUtils.getFilenameExtension(originalFilename);
|
|
|
+ String path = DateUtil.format(new Date(), "yyyy-MM");
|
|
|
+ try {
|
|
|
+ InputStream inputStream = idCordBackUrl.getInputStream();
|
|
|
+ BufferedInputStream in = new BufferedInputStream(inputStream);
|
|
|
+ ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
|
|
|
+ byte[] temp = new byte[1024];
|
|
|
+ int size = 0;
|
|
|
+ while ((size = in.read(temp)) != -1) {
|
|
|
+ out.write(temp, 0, size);
|
|
|
+ }
|
|
|
+ in.close();
|
|
|
+ byte[] content = out.toByteArray();
|
|
|
+ imgname = UUID.randomUUID() + "." + filenameExtension;
|
|
|
+ UploadImage.sshSftp(content, path, imgname);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- in.close();
|
|
|
- byte[] content = out.toByteArray();
|
|
|
- imgname = UUID.randomUUID() + "." + filenameExtension;
|
|
|
- UploadImage.sshSftp(content, path, imgname);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ String content = "https://img.ifarmcloud.com/images/" + path + "/" + imgname;
|
|
|
+ map.put("url", content);
|
|
|
+ } else {
|
|
|
+ String content = null;
|
|
|
+ map.put("url", "");
|
|
|
}
|
|
|
- String content = "https://img.ifarmcloud.com/images/" + path + "/" + imgname;
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
map.put("id", id);
|
|
|
- map.put("url", content);
|
|
|
+
|
|
|
return billLandingInspectionService.addPay(httpServletRequest, map);
|
|
|
}
|
|
|
|