Newspaper 2 vuotta sitten
vanhempi
commit
45626f64e7

+ 2 - 1
admin/src/main/java/com/huimv/farm/damsubsidy/controller/BillIsolatedController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
 import java.text.ParseException;
 import java.util.Map;
 
@@ -50,7 +51,7 @@ public class BillIsolatedController {
                                   @RequestParam("image") MultipartFile image,
                                   @RequestParam("id") String id,
                                   @RequestParam("isDead") String isDead,
-                                  @RequestParam("deaths") String deaths){
+                                  @RequestParam("deaths") String deaths) throws IOException {
         return iBillIsolatedService.cancelIsolation(httpServletRequest,image,id,isDead,deaths);
     }
 

+ 2 - 1
admin/src/main/java/com/huimv/farm/damsubsidy/service/IBillIsolatedService.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
 import java.text.ParseException;
 import java.util.Map;
 
@@ -25,5 +26,5 @@ public interface IBillIsolatedService extends IService<BillIsolated> {
 
     Result delayedIsolation(HttpServletRequest httpServletRequest, Map<String, String> paramsMap);
 
-    Result cancelIsolation(HttpServletRequest httpServletRequest, MultipartFile image, String id, String idDead, String deaths);
+    Result cancelIsolation(HttpServletRequest httpServletRequest, MultipartFile image, String id, String idDead, String deaths) throws IOException;
 }

+ 3 - 23
admin/src/main/java/com/huimv/farm/damsubsidy/service/impl/BillIsolatedServiceImpl.java

@@ -26,6 +26,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.io.BufferedInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -261,29 +262,8 @@ public class BillIsolatedServiceImpl extends ServiceImpl<BillIsolatedMapper, Bil
 
     @Override
     @Transactional
-    public Result cancelIsolation(HttpServletRequest httpServletRequest, MultipartFile image, String id, String isDead, String deaths) {
-        String imgname = "成功";
-        String originalFilename = image.getOriginalFilename();
-        String filenameExtension = StringUtils.getFilenameExtension(originalFilename);
-        String path = DateUtil.format(new Date(),"yyyy-MM");
-        try {
-            InputStream inputStream = image.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();
-        }
-        String content = "https://dam.img.ifarmcloud.com:8030/images/"+path +"/"+imgname;
+    public Result cancelIsolation(HttpServletRequest httpServletRequest, MultipartFile image, String id, String isDead, String deaths) throws IOException {
+        String content = UploadImage.getImageCom(image);
         BillIsolated isolation = this.getById(id);
         isolation.setIsolatedPicUrl(content);
         isolation.setIsolatedSch(2);