Переглянути джерело

Merge branch 'master' of http://47.100.3.209:3000/gdc/yiliangyiyun

ccjgmwz 3 роки тому
батько
коміт
1a1a6c1dd3

+ 31 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/constant/ImageCensorConsts.java

@@ -0,0 +1,31 @@
+package com.yh.saas.plugin.yiliangyiyun.constant;
+
+public class ImageCensorConsts {
+	/**
+	 * 图像审核接口
+	 */
+	public static final String ANTI_USER_DEFINED_URL = "https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/user_defined";
+	/**
+	 * 
+	 */
+	public static final String ANTI_PORN_URL = "https://aip.baidubce.com/rest/2.0/antiporn/v1/detect";
+	/**
+	 * GIF色情图像识别
+	 */
+	public static final String ANTI_PORN_GIF_URL ="https://aip.baidubce.com/rest/2.0/antiporn/v1/detect_gif";
+	/**
+	 * 
+	 */
+	public static final String ANTI_TERROR_URL = "https://aip.baidubce.com/rest/2.0/antiterror/v1/detect";
+	/**
+	 * 图像审核组合服务接口
+	 */
+	public static final String IMAGE_CENSOR_COMB_URL = "https://aip.baidubce.com/api/v1/solution/direct/img_censor";
+	/**
+	 * 用户头像审核
+	 */
+	public static final String FACE_AUDIT_URL = "https://aip.baidubce.com/rest/2.0/solution/v1/face_audit";
+	private ImageCensorConsts() {
+
+	}
+}

+ 72 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/BDAccessToken.java

@@ -0,0 +1,72 @@
+package com.yh.saas.plugin.yiliangyiyun.controller;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/BDAccessToken")
+public class BDAccessToken {
+
+    /**
+     * 获取API访问token
+     * 该token有一定的有效期,需要自行管理,当失效时需重新获取.
+     * @param ak - 百度云官网获取的 API Key
+     * @param sk - 百度云官网获取的 Secret Key
+     * @return assess_token 示例:
+     * "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567"
+     */
+    @GetMapping("/getAuth")
+    public static String getAuth(String apiKey, String secretKey) {
+        // 获取token地址
+        String authHost = "https://aip.baidubce.com/oauth/2.0/token?";
+        String getAccessTokenUrl = authHost
+                // 1. grant_type为固定参数
+                + "grant_type=client_credentials"
+                // 2. 官网获取的 API Key
+                + "&client_id=" + apiKey
+                // 3. 官网获取的 Secret Key
+                + "&client_secret=" + secretKey;
+        try {
+            URL realUrl = new URL(getAccessTokenUrl);
+            // 打开和URL之间的连接
+            HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection();
+            connection.setRequestMethod("GET");
+            connection.connect();
+            // 获取所有响应头字段
+            Map<String, List<String>> map = connection.getHeaderFields();
+            // 遍历所有的响应头字段
+            for (String key : map.keySet()) {
+                System.err.println(key + "--->" + map.get(key));
+            }
+            // 定义 BufferedReader输入流来读取URL的响应
+            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+            String result = "";
+            String line;
+            while ((line = in.readLine()) != null) {
+                result += line;
+            }
+            /**
+             * 返回结果示例
+             */
+            System.err.println("result:" + result);
+            JSONObject jsonObject = JSON.parseObject(result);
+            String access_token = jsonObject.getString("access_token");
+            return access_token;
+        } catch (Exception e) {
+            System.err.printf("获取token失败!");
+            e.printStackTrace(System.err);
+        }
+        return null;
+    }
+}

+ 27 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/CommonUserController.java

@@ -22,11 +22,16 @@ import com.winsea.svc.base.workflow.entity.WorkflowStep;
 import com.winsea.svc.notice.entity.NoticeTaskInfo;
 import com.yh.saas.common.support.util.IdGenerator;
 import com.yh.saas.common.support.util.StringUtils;
+import com.yh.saas.plugin.yiliangyiyun.constant.ImageCensorConsts;
 import com.yh.saas.plugin.yiliangyiyun.entity.CommonUser;
 import com.yh.saas.plugin.yiliangyiyun.entity.UnimallMessage;
+import com.yh.saas.plugin.yiliangyiyun.entity.view.UserDefinedBean;
 import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
 import com.yh.saas.plugin.yiliangyiyun.service.ICommonUserService;
 import com.yh.saas.plugin.yiliangyiyun.service.INewWorkflowService;
+import com.yh.saas.plugin.yiliangyiyun.util.Base64Util;
+import com.yh.saas.plugin.yiliangyiyun.util.FileUtil;
+import com.yh.saas.plugin.yiliangyiyun.util.HttpUtil;
 import com.yh.saas.plugin.yiliangyiyun.util.WebSocket;
 import com.yh.saas.toolkit.workflow.service.IWorkflowHistoryService;
 import org.activiti.engine.impl.util.CollectionUtil;
@@ -38,7 +43,8 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
-
+import com.alibaba.fastjson.JSON;
+import java.net.URLEncoder;
 /**
  * <p>
  * 前端控制器
@@ -71,6 +77,26 @@ public class CommonUserController {
     @Autowired
     private WebSocket webSocket;
 
+
+    /**
+     * 图像审核识别Demo
+     * @param imagePath
+     * @param accessToken
+     * @return UserDefinedBean
+     * @throws Exception
+     */
+    @PostMapping("/getUserDefinedBean")
+    public static UserDefinedBean getUserDefinedBean(String imagePath, String accessToken) throws Exception{
+        byte[] imgData = FileUtil.readFileByBytes(imagePath);
+        String imgStr = Base64Util.encode(imgData);
+        String param = "image=" + URLEncoder.encode(imgStr,"UTF-8");
+//		String jsonParam = "{\"top_num\":5,\"image\":\"图片的base64\"}";
+        // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。
+        String result = HttpUtil.post(ImageCensorConsts.ANTI_USER_DEFINED_URL, accessToken, param);
+        UserDefinedBean userDefinedBean = JSON.parseObject(result, UserDefinedBean.class);
+        return userDefinedBean;
+    }
+
     /**
      * 查询历史
      *

+ 121 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/view/UserDefinedBean.java

@@ -0,0 +1,121 @@
+package com.yh.saas.plugin.yiliangyiyun.entity.view;
+
+import lombok.Data;
+
+import java.util.List;
+/**
+ * 图像审核Java对象
+ * @author 小帅丶
+ *
+ */
+@Data
+public class UserDefinedBean {
+		//审核结果,成功才返回,失败不返回。可取值1.合规,2.疑似,3.不合规
+	 	private String conclusion;
+	 	//请求唯一id 
+	    private long log_id;
+	    //错误提示信息,失败才返回,成功不返回
+	    private String error_msg;
+	    //错误提示码,失败才返回,成功不返回
+	    private long error_code;
+	 	//审核项详细信息,响应成功并且conclusion为疑似或不合规时才返回,响应失败或conclusion为合规是不返回。
+	 	private List<Data> data;
+	    
+	    public String getError_msg() {
+			return error_msg;
+		}
+		public void setError_msg(String error_msg) {
+			this.error_msg = error_msg;
+		}
+		public long getError_code() {
+			return error_code;
+		}
+		public void setError_code(long error_code) {
+			this.error_code = error_code;
+		}
+		public String getConclusion() {
+			return conclusion;
+		}
+		public void setConclusion(String conclusion) {
+			this.conclusion = conclusion;
+		}
+		public long getLog_id() {
+			return log_id;
+		}
+		public void setLog_id(long log_id) {
+			this.log_id = log_id;
+		}
+		public List<Data> getData() {
+			return data;
+		}
+		public void setData(List<Data> data) {
+			this.data = data;
+		}
+	    public static class Data{
+	    	//内层错误提示信息,底层服务失败才返回,成功不返回
+		    private String error_msg;
+		    //内层错误提示码,底层服务失败才返回,成功不返回
+		    private long error_code;
+	    	//不合规项描述信息
+	    	private String msg;
+	    	//不合规项置信度
+	    	private double probability;
+	    	//审核类型,1:色情、2:性感、3:暴恐、4:恶心、5:水印码、6:二维码、7:条形码、8:政治人物、9:敏感词、10:自定义敏感词
+	    	private int type;
+	    	private List<Stars> stars;
+			public List<Stars> getStars() {
+				return stars;
+			}
+			public void setStars(List<Stars> stars) {
+				this.stars = stars;
+			}
+			public String getError_msg() {
+				return error_msg;
+			}
+			public void setError_msg(String error_msg) {
+				this.error_msg = error_msg;
+			}
+			public long getError_code() {
+				return error_code;
+			}
+			public void setError_code(long error_code) {
+				this.error_code = error_code;
+			}
+			public String getMsg() {
+				return msg;
+			}
+			public void setMsg(String msg) {
+				this.msg = msg;
+			}
+			public double getProbability() {
+				return probability;
+			}
+			public void setProbability(double probability) {
+				this.probability = probability;
+			}
+			public int getType() {
+				return type;
+			}
+			public void setType(int type) {
+				this.type = type;
+			}
+			public static class Stars{
+				//置信度
+				private double probability;
+				//政治人物名称
+				private String name;
+				public double getProbability() {
+					return probability;
+				}
+				public void setProbability(double probability) {
+					this.probability = probability;
+				}
+				public String getName() {
+					return name;
+				}
+				public void setName(String name) {
+					this.name = name;
+				}
+			}
+	    }
+}

+ 65 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/Base64Util.java

@@ -0,0 +1,65 @@
+package com.yh.saas.plugin.yiliangyiyun.util;
+
+/**
+ * Base64 工具类
+ */
+public class Base64Util {
+    private static final char last2byte = (char) Integer.parseInt("00000011", 2);
+    private static final char last4byte = (char) Integer.parseInt("00001111", 2);
+    private static final char last6byte = (char) Integer.parseInt("00111111", 2);
+    private static final char lead6byte = (char) Integer.parseInt("11111100", 2);
+    private static final char lead4byte = (char) Integer.parseInt("11110000", 2);
+    private static final char lead2byte = (char) Integer.parseInt("11000000", 2);
+    private static final char[] encodeTable = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
+
+    public Base64Util() {
+    }
+
+    public static String encode(byte[] from) {
+        StringBuilder to = new StringBuilder((int) ((double) from.length * 1.34D) + 3);
+        int num = 0;
+        char currentByte = 0;
+
+        int i;
+        for (i = 0; i < from.length; ++i) {
+            for (num %= 8; num < 8; num += 6) {
+                switch (num) {
+                    case 0:
+                        currentByte = (char) (from[i] & lead6byte);
+                        currentByte = (char) (currentByte >>> 2);
+                    case 1:
+                    case 3:
+                    case 5:
+                    default:
+                        break;
+                    case 2:
+                        currentByte = (char) (from[i] & last6byte);
+                        break;
+                    case 4:
+                        currentByte = (char) (from[i] & last4byte);
+                        currentByte = (char) (currentByte << 2);
+                        if (i + 1 < from.length) {
+                            currentByte = (char) (currentByte | (from[i + 1] & lead2byte) >>> 6);
+                        }
+                        break;
+                    case 6:
+                        currentByte = (char) (from[i] & last2byte);
+                        currentByte = (char) (currentByte << 4);
+                        if (i + 1 < from.length) {
+                            currentByte = (char) (currentByte | (from[i + 1] & lead4byte) >>> 4);
+                        }
+                }
+
+                to.append(encodeTable[currentByte]);
+            }
+        }
+
+        if (to.length() % 4 != 0) {
+            for (i = 4 - to.length() % 4; i > 0; --i) {
+                to.append("=");
+            }
+        }
+
+        return to.toString();
+    }
+}

+ 45 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/FileUtil.java

@@ -0,0 +1,45 @@
+package com.yh.saas.plugin.yiliangyiyun.util;
+
+import java.io.*;
+
+/**
+ * 文件读取工具类
+ */
+public class FileUtil {
+
+    /**
+     * 根据文件路径读取byte[] 数组
+     */
+    public static byte[] readFileByBytes(String filePath) throws IOException {
+        File file = new File(filePath);
+        if (!file.exists()) {
+            throw new FileNotFoundException(filePath);
+        } else {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream((int) file.length());
+            BufferedInputStream in = null;
+
+            try {
+                in = new BufferedInputStream(new FileInputStream(file));
+                short bufSize = 1024;
+                byte[] buffer = new byte[bufSize];
+                int len1;
+                while (-1 != (len1 = in.read(buffer, 0, bufSize))) {
+                    bos.write(buffer, 0, len1);
+                }
+
+                byte[] var7 = bos.toByteArray();
+                return var7;
+            } finally {
+                try {
+                    if (in != null) {
+                        in.close();
+                    }
+                } catch (IOException var14) {
+                    var14.printStackTrace();
+                }
+
+                bos.close();
+            }
+        }
+    }
+}

+ 372 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/HttpUtil.java

@@ -0,0 +1,372 @@
+package com.yh.saas.plugin.yiliangyiyun.util;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * http 工具类
+ */
+public class HttpUtil {
+
+    public static String post(String requestUrl, String accessToken, String params) throws Exception {
+    	System.out.println(params);
+    	String generalUrl = "";
+    	generalUrl = requestUrl + "?access_token=" + accessToken;
+        System.out.println("发送的连接为:"+generalUrl);
+        URL url = new URL(generalUrl);
+        // 打开和URL之间的连接
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+    	System.out.println("打开链接,开始发送请求"+new Date().getTime()/1000);
+        connection.setRequestMethod("POST");
+        // 设置通用的请求属性
+        connection.setRequestProperty("Content-Type", "application/json");
+        connection.setRequestProperty("Connection", "Keep-Alive");
+        connection.setUseCaches(false);
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+
+        // 得到请求的输出流对象
+        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
+        out.writeBytes(params);
+        out.flush();
+        out.close();
+
+        // 建立实际的连接
+        connection.connect();
+        // 获取所有响应头字段
+        Map<String, List<String>> headers = connection.getHeaderFields();
+        // 遍历所有的响应头字段
+        for (String key : headers.keySet()) {
+            System.out.println(key + "--->" + headers.get(key));
+        }
+        // 定义 BufferedReader输入流来读取URL的响应
+        BufferedReader in = null;
+        if (requestUrl.contains("nlp"))
+            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "GBK"));
+        else
+            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
+        String result = "";
+        String getLine;
+        while ((getLine = in.readLine()) != null) {
+            result += getLine;
+        }
+        in.close();
+        System.out.println("请求结束"+new Date().getTime()/1000);
+        System.out.println("result:" + result);
+        return result;
+    }
+    public static String postUnit(String requestUrl, String accessToken, String params) throws Exception {
+        String generalUrl = requestUrl + "?access_token=" + accessToken;
+        System.out.println("发送的连接为:"+generalUrl);
+        URL url = new URL(generalUrl);
+        // 打开和URL之间的连接
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+    	System.out.println("打开链接,开始发送请求"+new Date().getTime()/1000);
+        connection.setRequestMethod("POST");
+        // 设置通用的请求属性
+        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+        connection.setRequestProperty("Connection", "Keep-Alive");
+        connection.setUseCaches(false);
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+
+        // 得到请求的输出流对象
+        OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(),"UTF-8");
+        out.write(params);
+        out.flush();
+        out.close();
+
+        // 建立实际的连接
+        connection.connect();
+        // 获取所有响应头字段
+        Map<String, List<String>> headers = connection.getHeaderFields();
+        // 遍历所有的响应头字段
+        for (String key : headers.keySet()) {
+            System.out.println(key + "--->" + headers.get(key));
+        }
+        // 定义 BufferedReader输入流来读取URL的响应
+        BufferedReader in = null;
+        if (requestUrl.contains("nlp"))
+            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "GBK"));
+        else
+            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
+        String result = "";
+        String getLine;
+        while ((getLine = in.readLine()) != null) {
+            result += getLine;
+        }
+        in.close();
+        System.out.println("请求结束"+new Date().getTime()/1000);
+        System.out.println("result:" + result);
+        return result;
+    }
+    /**
+     * 语音合成HTTP方法
+     * @param requestUrl 请求的接口地址 拼接access_token后的
+     * @param params 语音合成的参数
+     * @throws Exception
+     */
+    public static String postVoice(String requestUrl,String params) throws Exception {
+    	String workspace = System.getProperty("user.home");
+    	String path = workspace+"/text2audio/";
+    	try {
+			if (!(new File(path).isDirectory())) {
+				new File(path).mkdir();
+			}
+		} catch (SecurityException e) {
+			e.printStackTrace();
+		}
+    	String filePath = path+"VOICE"+new Date().getTime()/1000+".mp3";
+        String generalUrl = requestUrl;
+        URL url = new URL(generalUrl);
+        System.out.println(generalUrl);
+        // 打开和URL之间的连接
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+    	System.out.println("打开链接,开始发送请求"+new Date().getTime()/1000);
+        connection.setRequestMethod("POST");
+        // 设置通用的请求属性
+        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+        connection.setRequestProperty("Connection", "Keep-Alive");
+        connection.setUseCaches(false);
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+
+        // 得到请求的输出流对象
+        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
+        out.writeBytes(params);
+        out.flush();
+        out.close();
+
+        // 建立实际的连接
+        connection.connect();
+        // 获取所有响应头字段
+        Map<String, List<String>> headers = connection.getHeaderFields();
+        // 遍历所有的响应头字段
+        for (String key : headers.keySet()) {
+        		System.out.println(key + "--->" + headers.get(key));
+        }
+        // 定义 BufferedReader输入流来读取URL的响应
+        InputStream inputStream = connection.getInputStream();
+        FileOutputStream outputStream = new FileOutputStream(filePath);
+        byte[] buffer = new byte[1024];
+        int len = -1;
+        while ((len=inputStream.read(buffer))!=-1) {
+        	outputStream.write(buffer,0,len);
+		}
+        outputStream.close();
+        System.out.println("请求结束"+new Date().getTime()/1000);
+        System.out.println("MP3文件保存目录:" + filePath);
+        return filePath;
+    }
+    /**
+     * 获取语音识别内容
+     * @param requestUrl
+     * @param params 
+     * @return
+     * @throws Exception
+     */
+    public static String postASR(String requestUrl, String params) throws Exception {
+    	System.out.println(params);
+    	String generalUrl = requestUrl;
+        System.out.println("发送的连接为:"+generalUrl);
+        URL url = new URL(generalUrl);
+        // 打开和URL之间的连接
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+    	System.out.println("打开链接,开始发送请求"+new Date().getTime()/1000);
+        connection.setRequestMethod("POST");
+        // 设置通用的请求属性
+        connection.setRequestProperty("Content-Type", "application/json");
+        connection.setRequestProperty("Connection", "Keep-Alive");
+        connection.setUseCaches(false);
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+        // 得到请求的输出流对象
+        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
+        out.writeBytes(params);
+        out.flush();
+        out.close();
+        // 建立实际的连接
+        connection.connect();
+        // 获取所有响应头字段
+        Map<String, List<String>> headers = connection.getHeaderFields();
+        // 遍历所有的响应头字段
+        for (String key : headers.keySet()) {
+            System.out.println(key + "--->" + headers.get(key));
+        }
+        // 定义 BufferedReader输入流来读取URL的响应
+        BufferedReader in = null;
+        if (requestUrl.contains("nlp"))
+            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "GBK"));
+        else
+            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
+        String result = "";
+        String getLine;
+        while ((getLine = in.readLine()) != null) {
+            result += getLine;
+        }
+        in.close();
+        System.out.println("请求结束"+new Date().getTime()/1000);
+        System.out.println("result:" + result);
+        return result;
+    }
+    public static String postTest(String requestUrl,String params) throws Exception {
+    	String workspace = System.getProperty("user.home");
+    	String path = workspace+"/text2audio/";
+    	try {
+			if (!(new File(path).isDirectory())) {
+				new File(path).mkdir();
+			}
+		} catch (SecurityException e) {
+			e.printStackTrace();
+		}
+    	String filePath = path+"VOICE"+new Date().getTime()/1000+".apk";
+        String generalUrl = requestUrl;
+        URL url = new URL(generalUrl);
+        // 打开和URL之间的连接
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+    	System.out.println("打开链接,开始发送请求"+new Date().getTime()/1000);
+        connection.setRequestMethod("GET");
+        // 设置通用的请求属性
+        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+        connection.setRequestProperty("Connection", "Keep-Alive");
+        connection.setUseCaches(false);
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+
+        // 得到请求的输出流对象
+        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
+        out.writeBytes(params);
+        out.flush();
+        out.close();
+
+        // 建立实际的连接
+        connection.connect();
+        // 获取所有响应头字段
+        Map<String, List<String>> headers = connection.getHeaderFields();
+        // 遍历所有的响应头字段
+        for (String key : headers.keySet()) {
+            System.out.println(key + "--->" + headers.get(key));
+        }
+        // 定义 BufferedReader输入流来读取URL的响应
+        InputStream inputStream = connection.getInputStream();
+//        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        FileOutputStream outputStream = new FileOutputStream(filePath);
+        byte[] buffer = new byte[1024];
+        int len = -1;
+        while ((len=inputStream.read(buffer))!=-1) {
+        	outputStream.write(buffer,0,len);
+		}
+        outputStream.close();
+        System.out.println("请求结束"+new Date().getTime()/1000);
+        System.out.println("MP3文件保存目录:" + filePath);
+        return filePath;
+    }
+    public static String post(String requestUrl,String params) throws Exception {
+        String generalUrl = requestUrl;
+        URL url = new URL(generalUrl);
+        // 打开和URL之间的连接
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        connection.setRequestMethod("POST");
+        // 设置通用的请求属性
+        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+        connection.setRequestProperty("Connection", "Keep-Alive");
+        connection.setUseCaches(false);
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+        // 得到请求的输出流对象
+        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
+        out.writeBytes(params);
+        out.flush();
+        out.close();
+        // 建立实际的连接
+        connection.connect();
+        // 获取所有响应头字段
+        Map<String, List<String>> headers = connection.getHeaderFields();
+        // 遍历所有的响应头字段
+        for (String key : headers.keySet()) {
+            System.out.println(key + "--->" + headers.get(key));
+        }
+        // 定义 BufferedReader输入流来读取URL的响应
+        BufferedReader in = null;
+        if (requestUrl.contains("nlp"))
+            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
+        else
+            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
+        String result = "";
+        String getLine;
+        while ((getLine = in.readLine()) != null) {
+            result += getLine;
+        }
+        in.close();
+        System.out.println("result:" + result);
+        return result;
+    }
+    /**
+     * NLP接口HTTP请求方法
+     * @param requestUrl
+     * @param params
+     * @return
+     * @throws Exception
+     */
+    public static String postNLP(String requestUrl,String params) throws Exception {
+    	String encoding = "";
+    	if(requestUrl.contains("nlp")){
+    		encoding = "GBK";
+    	}else{
+    		encoding = "UTF-8";
+    	}
+        String generalUrl = requestUrl;
+        URL url = new URL(generalUrl);
+        // 打开和URL之间的连接
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        connection.setRequestMethod("POST");
+        // 设置通用的请求属性
+        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+        connection.setRequestProperty("Connection", "Keep-Alive");
+        connection.setUseCaches(false);
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+        // 得到请求的输出流对象
+        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
+        out.write(params.getBytes(encoding));
+        out.flush();
+        out.close();
+        // 建立实际的连接
+        connection.connect();
+        // 获取所有响应头字段
+        Map<String, List<String>> headers = connection.getHeaderFields();
+        // 遍历所有的响应头字段
+        for (String key : headers.keySet()) {
+            System.out.println(key + "--->" + headers.get(key));
+        }
+        // 定义 BufferedReader输入流来读取URL的响应
+        BufferedReader in = null;
+        if (requestUrl.contains("nlp_wordseg")||requestUrl.contains("nlp_wordpos")||requestUrl.contains("nlp_wordner")||requestUrl.contains("nlp_wordsyn"))
+            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "GBK"));
+        else
+            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
+        String result = "";
+        String getLine;
+        while ((getLine = in.readLine()) != null) {
+            result += getLine;
+        }
+        in.close();
+        System.out.println("result:" + result);
+        return result;
+    }
+    
+}
+

+ 64 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/WarehouseBaseInfoMapper.xml

@@ -222,6 +222,70 @@
             AND (DATE_FORMAT(w.in_out_date,"%Y%m%d") &lt;=
             DATE_FORMAT(#{endDate},"%Y%m%d"))
         </if>
+        UNION ALL
+        SELECT
+        c.comp_name as compName,
+        w.warehouse_name as warehouseName,
+        w.bin_number as binNumber,
+        w.create_date as createDate,
+        w.contract_no as contractNo,
+        '' as paymentNo,
+        '' as customerName,
+        '退库' as inOutType,
+        '' as deliveryVolume,
+        '' as sendWarehouse,
+        0 as tranPrice,
+        0 as freight,
+        '' as supplier,
+        w.goods_name as goodsName,
+        case when w.goods_name = '玉米(潮粮)' then '潮粮' else '干粮' end as type,
+        w.grade as grade,
+        d.water_content as waterContent,
+        d.impurity as impurity,
+        d.mildew_grain as mildewGrain,
+        d.imperfect_grain as imperfectGrain,
+        d.bulk_density as bulkDensity,
+        d.jiaorenli as jiaorenli,
+        w.car_no as carNo,
+        w.box_no as boxNo,
+        w.box_no_other as boxNoOther,
+        w.title_no as titleNo,
+        w.title_no_other as titleNoOther,
+        0 as netWeightPrice,
+        w.gross_weight as grossWeight,
+        w.tare as tare,
+        w.deduction_weight as buckleWeight,
+        w.net_weight as netWeight,
+        '' as unitDeduction,
+        '' as pureWeightPrice,
+        w.pure_weight as pureWeight,
+        0 as amountIngPayable,
+        0 as amountEdPayable,
+        '' as payeeName,
+        '' as cardNo,
+        '' as bankDeposit,
+        '' as bankDepositBranch
+        FROM warehouse_in_out_info w
+        left join warehouse_in_out_detail d on w.id=d.info_id and d.delete_flag = 0
+        left join warehouse_base_info b on b.id=w.base_id and b.delete_flag = 0
+        left join common_company c on c.comp_id = b.comp_id and c.delete_flag = 0
+        WHERE w.delete_flag = '0'
+        AND b.comp_id = #{compId}
+        and w.in_out_flag = 2
+        and w.in_out_type='退库'
+        and w.status_flag=3
+        <if test="warehouseName != null and warehouseName != ''">
+            AND w.warehouse_name= #{warehouseName}
+        </if>
+        <if test="startDate != null">
+            AND (DATE_FORMAT(w.in_out_date,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null">
+            AND (DATE_FORMAT(w.in_out_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        </if>
+        group by w.id
     </select>
     <!-- 获得出库导出列表 -->
     <select id="getListByConditionOut" parameterType="Map"