liyg 2 роки тому
батько
коміт
71aeb80ff4

+ 32 - 58
src/main/java/com/steerinfo/dil/controller/OTMSController.java

@@ -95,31 +95,25 @@ public class OTMSController {
     public synchronized RESTfulResult addTmstruckReceiptResult(MultipartRequest request, Integer num, String orderNumber, String resultArrivalAddress, Integer imgcount3, Integer imgcount4) throws Exception {
         //添加到files数组
         List<MultipartFile> files = new ArrayList<>();
-        //第一张和第二张必填
-        files.add(request.getFile("file0"));
-        files.add(request.getFile("file1"));
-        //第三张选填
-        if (request.getFile("file2")!=null){
-            files.add(request.getFile("file2"));
-        }
-        //追加的三张,num=6则取到file3,4,5
-        for(int i=3;i<num;i++){
-            if(request.getFile("file"+i)!=null){
-                files.add(request.getFile("file"+i));
+        for(int i=0;i<11;i++){
+            MultipartFile file = request.getFile("file"+i);
+            if(file!=null){
+                files.add(file);
+            }else{
+                break;
             }
         }
-        //上传图片,追加的三张图片放在fourFiles里
-        List<String> fourFiles=new ArrayList<>();
+        if(files.size()<3){
+            return  new RESTfulResult("201","至少上传三张图片!");
+        }
+        //上传图片,拼接在一个url里
         Map<String,Object> mapValue=new HashMap<>();
+        String url="";
         for (int i=0;i<files.size();i++){
             MultipartFile file=files.get(i);
-            String url = imageFileUtils.updateFile(file,i);
-            mapValue.put("url"+i,url);
-            if(i>=3) {
-                fourFiles.add(url);
-            }
+            url += imageFileUtils.updateFile(file,i)+';';
         }
-        mapValue.put("fourFiles",fourFiles);
+        mapValue.put("url",url);
         return otmsFeign.addTmstruckReceiptResult(mapValue,num,orderNumber,resultArrivalAddress,imgcount3,imgcount4);
     }
 
@@ -169,17 +163,12 @@ public class OTMSController {
         return otmsFeign.getArrivalResult(mapValue==null?new HashMap<>():mapValue, apiId, pageNum, pageSize,con,startTime,endTime);
     }
 
-    @ApiOperation("展示满货箱的照片")
+    @ApiOperation("查询抵达图片")
     @PostMapping("/getArrivalPhoto")
     public List<String> getArrivalPhoto(@RequestParam String orderNumber) throws Exception{
         try{
             String arrivalPhoto=otmsFeign.getArrivalPhoto(orderNumber);
-            String files[]=arrivalPhoto.split(";");
-            List<String> file=new ArrayList<>();
-            for(int i=0;i<files.length&& files[i].length()>5;i++){
-                file.add((String)imageFileUtils.downloadFile(files[i]));
-            }
-            return file;
+            return getPhotoByUrl(arrivalPhoto);
         }catch (Exception e){
             e.printStackTrace();
             return null;
@@ -198,41 +187,26 @@ public class OTMSController {
         return otmsFeign.getReceiptResult(mapValue==null?new HashMap<>():mapValue, apiId, pageNum, pageSize,con,startTime,endTime);
     }
 
-    @ApiOperation("展示收货的照片")
+    @ApiOperation("查询签收图片")
     @PostMapping("/getReceivingPhotoByUrl")
-    public Map<String,Object> getReceivingPhotoByUrl(@RequestParam String orderNumber) throws Exception {
-        Map<String,Object> map=otmsFeign.getReceivingPhotoByUrl(orderNumber);
-        if(map==null){
-          map =new HashMap<>();
-          return  map;
-        }
-        if(map.containsKey("resultEmptyContainerPhoto") && map.get("resultEmptyContainerPhoto")!=null){
-            String resultEmptyContainerPhoto = (String) imageFileUtils.downloadFile(map.get("resultEmptyContainerPhoto").toString());
-            map.put("resultEmptyContainerPhoto",resultEmptyContainerPhoto);
-        }
-        if(map.containsKey("resultSignedNotePhoto") && map.get("resultSignedNotePhoto")!=null){
-            String resultSignedNotePhoto = (String) imageFileUtils.downloadFile(map.get("resultSignedNotePhoto").toString());
-            map.put("resultSignedNotePhoto",resultSignedNotePhoto);
-        }
-        if(map.containsKey("resultReceiveNotePhoto") && map.get("resultReceiveNotePhoto")!=null){
-            String resultSignedNotePhoto = (String) imageFileUtils.downloadFile(map.get("resultReceiveNotePhoto").toString());
-            map.put("resultReceiveNotePhoto",resultSignedNotePhoto);
-        }
-        //追加的图片
-        if(map.containsKey("otherPhoto1") && map.get("otherPhoto1")!=null){
-            String resultSignedNotePhoto =(String) imageFileUtils.downloadFile(map.get("otherPhoto1").toString());
-            map.put("otherPhoto1",resultSignedNotePhoto);
-        }
-        if(map.containsKey("otherPhoto2") && map.get("otherPhoto2") !=null){
-            String resultSignedNotePhoto =(String) imageFileUtils.downloadFile(map.get("otherPhoto2").toString());
-            map.put("otherPhoto2",resultSignedNotePhoto);
-        }
-        if(map.containsKey("otherPhoto3") && map.get("otherPhoto3") !=null){
-            String resultSignedNotePhoto =(String) imageFileUtils.downloadFile(map.get("otherPhoto3").toString());
-            map.put("otherPhoto3",resultSignedNotePhoto);
+    public List<String> getReceivingPhotoByUrl(@RequestParam String orderNumber) throws Exception {
+        try{
+            String receivePhoto=otmsFeign.getReceivingPhotoByUrl(orderNumber);
+            return getPhotoByUrl(receivePhoto);
+        }catch (Exception e){
+            e.printStackTrace();
+            return null;
         }
+    }
 
-        return map;
+    //切割字符串,下载图片并返回
+    private List<String> getPhotoByUrl(String urls) throws Exception {
+        List<String> results=new ArrayList<>();
+        String files[]=urls.split(";");
+        for(int i=0;i<files.length && files[i].length()>5;i++){
+            results.add((String)imageFileUtils.downloadFile(files[i]));
+        }
+        return results;
     }
 
     @GetMapping("/getCurrentLocation")

+ 1 - 1
src/main/java/com/steerinfo/dil/feign/OtmsFeign.java

@@ -71,7 +71,7 @@ public interface OtmsFeign {
 
     //获取收货作业照片
     @PostMapping("/api/v1/otms/tmstruckreceiptresults/getReceivingPhotoByUrl")
-    public Map<String,Object> getReceivingPhotoByUrl(@RequestParam String orderNumber);
+    public String getReceivingPhotoByUrl(@RequestParam String orderNumber);
 
     //获得抵达实集
     @PostMapping(value = "/api/v1/otms/tmstruckarrivalresults/addtmstruckArrivalResult")