Ver Fonte

Merge branch 'master' of https://git.steerinfo.com/DAL-DAZHOU/DAL-DAZHOU-API

luobang há 2 anos atrás
pai
commit
d7786af195

+ 2 - 2
src/main/java/com/steerinfo/dil/config/ImageFileUtils.java

@@ -122,13 +122,13 @@ public class ImageFileUtils implements FileUtils {
      * @return
      * @throws Exception
      */
-    public synchronized String updateFile(MultipartFile file) throws Exception {
+    public synchronized String updateFile(MultipartFile file,long workerId) throws Exception {
         //首先通过Calendard对象获得年月日
         Calendar calendar= Calendar.getInstance();
         int year = calendar.get(Calendar.YEAR);
         int month = calendar.get(Calendar.MONTH);
         int day= calendar.get(Calendar.DAY_OF_MONTH);
-        String url = UploadUtils.uploadFile(file, new IdGenerator(0, 10), path, File.separator+year+ File.separator+month+ File.separator+day+ File.separator);
+        String url = UploadUtils.uploadFile(file, new IdGenerator(workerId%31, 10), path, File.separator+year+ File.separator+month+ File.separator+day+ File.separator);
         return url;
     }
 

+ 61 - 62
src/main/java/com/steerinfo/dil/controller/OTMSController.java

@@ -81,11 +81,36 @@ public class OTMSController {
         //添加到files数组
         List<MultipartFile> files = new ArrayList<>();
         String file="";
+        int index=0;
         //第一张和第二张必填
-        files.add(request.getFile("file1"));
-        files.add(request.getFile("file2"));
-        for(MultipartFile item:files){
-            file+=imageFileUtils.updateFile(item)+';';
+        for(int i=1;i<=2;i++){
+            MultipartFile temp = request.getFile("file"+i);
+            if(temp!=null){
+                files.add(temp);
+                index=i;//记录是新上传了第一张还是第二张图片
+            }
+        }
+        //没有上传,当做重复上传
+        if(files.size() == 0){
+            return  new RESTfulResult("201","若要重复上传,必须两张都是新图片!","请勿重复上传!");
+        }
+        //上传图片
+        for(int i=0;i<files.size();i++){
+            file+=imageFileUtils.updateFile(files.get(i),i)+';';
+        }
+        //只上传了一张图片,补足另一张
+        if(files.size() == 1){
+            try{
+                String arrivalPhoto=otmsFeign.getArrivalPhoto(orderNumber);
+                String[] olds=arrivalPhoto.split(";");
+                if(index==1){
+                    file=file+olds[1]+";";
+                }else if(index==2){
+                    file=olds[0]+";"+file;
+                }
+            }catch (Exception e){
+
+            }
         }
         return otmsFeign.addtmstruckArrivalResult(orderNumber,resultArrivalAddress,file);
     }
@@ -95,31 +120,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);
-            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 +188,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 +212,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")

+ 2 - 2
src/main/java/com/steerinfo/dil/service/impl/UniversalServiceImpl.java

@@ -240,7 +240,7 @@ public class UniversalServiceImpl implements UniversalService {
      * 关闭过期运输订单
      * @return
      */
-    //@Scheduled(cron = "0 0,5 8 * * ?")
+    @Scheduled(cron = "0 0,5 8 * * ?")
     public void closePassedOrder() {
         List<Map<String,Object>> passedOrderList = universalMapper.findPassedOrder();
         System.out.println("关闭的未出厂过期订单如下:<" + passedOrderList + ">");
@@ -260,7 +260,7 @@ public class UniversalServiceImpl implements UniversalService {
                     }else {
                         result+=universalMapper.updateStatusSeven(orderId);
                     }
-                    BigDecimal capacityIdS=universalMapper.queueSingle(orderId);
+                   /* BigDecimal capacityIdS=universalMapper.queueSingle(orderId);*/
                     /*if (capacityIdS !=null){
                         //删除单拼
                         universalMapper.delectQueueS(capacityIdS);

+ 7 - 0
src/main/java/com/steerinfo/dil/util/test.java

@@ -1,4 +1,11 @@
 package com.steerinfo.dil.util;
 
+import com.steerinfo.framework.utils.misc.IdGenerator;
+
 public class test {
+    public static void main(String[] args) {
+        for(int i=0;i<1000;i++){
+            System.out.println(new IdGenerator(i%31,10).getNextStr());
+        }
+    }
 }

+ 1 - 1
src/main/resources/com/steerinfo/dil/mapper/UniversalMapper.xml

@@ -898,7 +898,7 @@
         </where>
         <include refid="orderBy"></include>
         <if test="orderField == null  ">
-            order by "materialCount" DESC
+            order by "materialCount" DESC nulls last
         </if>
     </select>