Kaynağa Gözat

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

zhouzh 3 yıl önce
ebeveyn
işleme
72410500ec

+ 12 - 0
src/main/java/com/steerinfo/dil/config/FileUtils.java

@@ -0,0 +1,12 @@
+package com.steerinfo.dil.config;
+
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+public interface FileUtils {
+
+    public List<String> updateFiles(MultipartFile files[])throws Exception;
+
+     public Object downloadFile(String url) throws Exception;
+}

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

@@ -0,0 +1,234 @@
+package com.steerinfo.dil.config;
+
+import com.steerinfo.framework.utils.misc.IdGenerator;
+import com.steerinfo.framework.utils.upload.UploadUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.*;
+
+@Component
+public class ImageFileUtils implements FileUtils {
+
+    @Value(value = "${piction.path:/shared}" )
+    private String path;
+
+    public static final HashMap fileTypes = new HashMap();
+
+    static {
+
+        // images
+
+        fileTypes.put("FFD8FF", "jpg");
+
+        fileTypes.put("89504E47", "png");
+
+        fileTypes.put("47494638", "gif");
+
+        fileTypes.put("49492A00", "tif");
+
+        fileTypes.put("424D", "bmp");
+
+        // CAD
+
+        fileTypes.put("41433130", "dwg");
+
+        fileTypes.put("38425053", "psd");
+
+        // 日记本
+
+        fileTypes.put("7B5C727466", "rtf");
+
+        fileTypes.put("3C3F786D6C", "xml");
+
+        fileTypes.put("68746D6C3E", "html");
+
+        // 邮件
+
+        fileTypes.put("44656C69766572792D646174653A", "eml");
+
+        fileTypes.put("D0CF11E0", "doc");
+
+        //excel2003版本文件
+
+        fileTypes.put("D0CF11E0", "xls");
+
+        fileTypes.put("5374616E64617264204A", "mdb");
+
+        fileTypes.put("252150532D41646F6265", "ps");
+
+        fileTypes.put("255044462D312E", "pdf");
+
+        fileTypes.put("504B0304", "docx");
+
+        //excel2007以上版本文件
+
+        fileTypes.put("504B0304", "xlsx");
+
+        fileTypes.put("52617221", "rar");
+
+        fileTypes.put("57415645", "wav");
+
+        fileTypes.put("41564920", "avi");
+
+        fileTypes.put("2E524D46", "rm");
+
+        fileTypes.put("000001BA", "mpg");
+
+        fileTypes.put("000001B3", "mpg");
+
+        fileTypes.put("6D6F6F76", "mov");
+
+        fileTypes.put("3026B2758E66CF11", "asf");
+
+        fileTypes.put("4D546864", "mid");
+
+        fileTypes.put("1F8B08", "gz");
+
+    }
+
+
+    /**
+     * 上传多张图片
+     * @param files
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public synchronized List<String> updateFiles(MultipartFile files[]) 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);
+        //上传文件夹路径
+        List<String> urls=new ArrayList<>();
+        for (int i=0;i<files.length;i++){
+            String url = UploadUtils.uploadFile(files[i], new IdGenerator(i, 10), path, File.separator+year+ File.separator+month+ File.separator+day+ File.separator);
+            urls.add(url);
+        }
+        return urls;
+    }
+
+
+    /**
+     * 上传单张图片
+     * @param file
+     * @return
+     * @throws Exception
+     */
+    public synchronized String updateFile(MultipartFile file) 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);
+        return url;
+    }
+
+    /**
+     * 下载图片获得字节码
+     * @param filePath
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public Object downloadFile(String filePath) throws Exception {
+        File file = new File(filePath);
+        if(file.isDirectory()){
+
+            throw new RuntimeException("当前路径是目录");
+
+        }
+        byte[] b = bytes(file);
+        String type =getFileHeader(b);
+        String src="data:image/"+type+";base64,"+ Base64.getEncoder().encodeToString(b);
+        return src;
+    }
+
+
+
+
+    /**
+     * @return 文件头信息
+     * @author liang.pan
+     * <p>
+     * 方法描述:根据输入流获取文件头信息
+     */
+    public static String getFileHeader(byte[] b) {
+        String value = bytesToHexString(b);
+
+        if (StringUtils.startsWith(value, "FFD8FF")) {
+            value = value.substring(0, 6);
+        }
+
+        //判断什么类型的
+        Set set = fileTypes.keySet();
+        Iterator iterator = set.iterator();
+        while(iterator.hasNext()){
+            String key=iterator.next().toString();
+            if (value.contains(key)){
+                return fileTypes.get(key).toString();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * @param src 要读取文件头信息的文件的byte数组
+     * @return 文件头信息
+     * @author liang.pan
+     * <p>
+     * 方法描述:将要读取文件头信息的文件的byte数组转换成string类型表示
+     */
+    private static String bytesToHexString(byte[] src) {
+        StringBuilder builder = new StringBuilder();
+        if (src == null || src.length <= 0) {
+            return null;
+        }
+        String hv;
+        for (int i = 0; i < src.length; i++) {
+            // 以十六进制(基数 16)无符号整数形式返回一个整数参数的字符串表示形式,并转换为大写
+            hv = Integer.toHexString(src[i] & 0xFF).toUpperCase();
+            if (hv.length() < 2) {
+                builder.append(0);
+            }
+            builder.append(hv);
+        }
+        return builder.toString();
+    }
+
+
+    public byte[] bytes(File file) throws Exception {
+        FileInputStream fin = new FileInputStream(file);
+        try {
+            //可能溢出,简单起见就不考虑太多,如果太大就要另外想办法,比如一次传入固定长度byte[]
+            byte[] bytes  = new byte[fin.available()];
+            //将文件内容写入字节数组,提供测试的case
+            fin.read(bytes);
+            fin.close();
+            return bytes;
+        }catch (Exception ex){
+            throw ex;
+        }
+        finally {
+            if (null != fin) {
+
+                try {
+
+                    fin.close();
+
+                } catch (IOException e) {
+
+                }
+
+            }
+        }
+    }
+}

+ 19 - 3
src/main/java/com/steerinfo/dil/controller/OTMSController.java

@@ -1,15 +1,20 @@
 package com.steerinfo.dil.controller;
 
+import com.steerinfo.dil.config.ImageFileUtils;
 import com.steerinfo.dil.feign.TmsTruckFeign;
 import com.steerinfo.dil.util.PageListAdd;
 import com.steerinfo.framework.controller.RESTfulResult;
 import com.steerinfo.framework.service.pagehelper.PageHelper;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.util.MultiValueMap;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartRequest;
 
+import java.awt.*;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -19,6 +24,8 @@ import java.util.Map;
 public class OTMSController {
     @Autowired
     private TmsTruckFeign tmsTruckFeign;
+    @Autowired
+    private ImageFileUtils imageFileUtils;
     @ApiOperation(value="全路径展示接口")
     @PostMapping("/fullPath")
     public Object fullPath(@RequestParam("orderNumber") String orderNumber) throws Exception {
@@ -39,8 +46,17 @@ public class OTMSController {
         return tmsTruckFeign.addtmstruckArrivalResult(orderNumber,resultArrivalAddress,file);
     }
 
-    @PostMapping(value = "/addTmstruckReceiptResult", headers = "content-type=multipart/form-data")
-    public synchronized RESTfulResult addTmstruckReceiptResult(MultipartRequest request, Integer num, String orderNumber, String resultArrivalAddress, Integer imgcount3, Integer imgcount4){
-        return tmsTruckFeign.addTmstruckReceiptResult(request,num,orderNumber,resultArrivalAddress,imgcount3,imgcount4);
+    @PostMapping(value = "/addTmstruckReceiptResult")
+    public synchronized RESTfulResult addTmstruckReceiptResult(MultipartRequest request, Integer num, String orderNumber, String resultArrivalAddress, Integer imgcount3, Integer imgcount4) throws Exception {
+        List<MultipartFile> files = new ArrayList<>();
+        files.add(request.getFile("file0"));
+        files.add(request.getFile("file1"));
+        Map<String,Object> mapValue=new HashMap<>();
+        for (int i=0;i<files.size();i++){
+            MultipartFile file=files.get(i);
+            String url = imageFileUtils.updateFile(file);
+            mapValue.put("url"+i,url);
+        }
+        return tmsTruckFeign.addTmstruckReceiptResult(mapValue,num,orderNumber,resultArrivalAddress,imgcount3,imgcount4);
     }
 }

+ 6 - 0
src/main/java/com/steerinfo/dil/controller/UniversalController.java

@@ -774,6 +774,12 @@ public class UniversalController extends BaseRESTfulController {
 //       return success(list);
 //    }
 
+    @ApiOperation(value = "收货地址下匹配不到任何承运商")
+    @GetMapping("/getNoListCarrier")
+    public RESTfulResult getNoListCarrier() {
+        return success(universalMapper.getNoListCarrier());
+    }
+
     @ApiOperation(value = "查询承运起止地点下拉框")
     @GetMapping("/getNotReceiveOrderQuantity")
     public Integer getNotReceiveOrderQuantity(@RequestParam("capacityNumber") String capacityNumber){

+ 9 - 2
src/main/java/com/steerinfo/dil/feign/TmsTruckFeign.java

@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.http.MediaType;
+import org.springframework.util.MultiValueMap;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartRequest;
@@ -529,8 +530,14 @@ public interface TmsTruckFeign {
     @PostMapping(value = "/api/v1/truckTms/tmstruckarrivalresults/addtmstruckArrivalResult",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
     public RESTfulResult addtmstruckArrivalResult(@RequestParam("orderNumber")String orderNumber, @RequestParam("resultArrivalAddress")String resultArrivalAddress,@RequestPart("file") MultipartFile file);
 
-    @PostMapping(value = "/api/v1/truckTms/pathDisplay/addTmstruckReceiptResult", headers = "content-type=multipart/form-data",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
-    public  RESTfulResult addTmstruckReceiptResult(@RequestPart("file")MultipartRequest request,@RequestParam("num") Integer num,@RequestParam("orderNumber")  String orderNumber, @RequestParam("resultArrivalAddress")String resultArrivalAddress,@RequestParam("imgcount3") Integer imgcount3, @RequestParam("imgcount4")Integer imgcount4);
+    @PostMapping(value = "/api/v1/truckTms/pathDisplay/addTmstruckReceiptResult")
+    public  RESTfulResult addTmstruckReceiptResult(@RequestBody Map<String,Object>  mapValaue  , @RequestParam("num") Integer num, @RequestParam("orderNumber")  String orderNumber, @RequestParam("resultArrivalAddress")String resultArrivalAddress, @RequestParam("imgcount3") Integer imgcount3, @RequestParam("imgcount4")Integer imgcount4);
+
+    @PostMapping(value = "/api/v1/truckTms/tmstruckarrivalresults/uploadImage",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+    public String uploadImage(@RequestParam("orderNumber")String orderNumber,@RequestPart("file") MultipartFile file);
+
+//    @PostMapping(value = "/api/v1/truckTms/pathDisplay/addTmstruckReceiptResult", headers = "content-type=multipart/form-data",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+//    public  RESTfulResult addTmstruckReceiptResult(@RequestPart("file")MultipartRequest request,@RequestParam("num") Integer num,@RequestParam("orderNumber")  String orderNumber, @RequestParam("resultArrivalAddress")String resultArrivalAddress,@RequestParam("imgcount3") Integer imgcount3, @RequestParam("imgcount4")Integer imgcount4);
 
 }
 

+ 1 - 0
src/main/java/com/steerinfo/dil/mapper/UniversalMapper.java

@@ -175,6 +175,7 @@ public interface UniversalMapper {
 
     List<Map<String, Object>> selectOutbound(String orderNumber);
 
+    List<Map<String,Object>> getNoListCarrier();
     //通过车牌号查询未接收的订单数量(用于APP显示未接收小红点)
     Integer getNotReceiveOrderQuantity(String capacityNumber);
 }

+ 5 - 0
src/main/resources/application-dev.yml

@@ -35,6 +35,11 @@ openfeign:
     url: ${RMSFEIGN_HRL:172.16.33.162:8014}
   JoinFeign:
     url: ${JOINFEIGN_URL:172.16.33.162:8006}
+piction:
+  # path: /usr/share/nginx/html/image
+  #  path: /test/data/nginx/html/image
+  path: C:\Users\24390\Desktop\work\a
+#  path: /shared
 
 server:
   port: 8019

+ 5 - 0
src/main/resources/application-prod.yml

@@ -36,5 +36,10 @@ openfeign:
     url: ${RMSFEIGN_URL:172.16.33.166:8060}
   JoinFeign:
     url: ${JOINFEIGN_URL:172.16.33.166:8066}
+piction:
+  # path: /usr/share/nginx/html/image
+  #  path: /test/data/nginx/html/image
+  #  path: C:\Users\24390\Desktop\work\a
+  path: /shared
 server:
   port: 8080

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

@@ -917,6 +917,15 @@
         WHERE RC.CONSIGNEE_ID = #{receiveId}
     </select>
 
+    <select id="getNoListCarrier" resultType="java.util.Map" >
+        SELECT RC.CARRIER_ID AS "id",
+               RC.CARRIER_ID AS "value",
+               RC.CARRIER_NAME AS "label"
+        FROM RMS_CARRIER RC
+        WHERE RC.CARRIER_ID &gt;= 3720
+        AND RC.CARRIER_ID &lt;= 3727
+    </select>
+
     <select id="getNotReceiveOrderQuantity" resultType="java.lang.Integer">
         select count(ORDER_ID)
         from OMSTRUCK_ORDER OO