Min 1 năm trước cách đây
mục cha
commit
6a30a944e5

+ 15 - 15
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -1155,21 +1155,21 @@ public class TimingTask {
         }
     }
 
-    public static void main(String[] args) {
-        int passwordLength = 30;
-        List<String> stringList=new ArrayList<>();
-        new SecureRandom().ints(passwordLength, 0, VALID_TOKEN_CHARS.size())
-                .map(VALID_TOKEN_CHARS::get).forEach(v->stringList.add(String.valueOf((char) v)));
-        String token="";
-        for (String s : stringList) {
-            token+=s;
-        }
-        System.out.println(token);
-        LocalDate now=LocalDate.now().minusMonths(1);
-        LocalDate end=now.with(TemporalAdjusters.lastDayOfMonth());
-        LocalDate start=now.with(TemporalAdjusters.firstDayOfMonth());
-        System.out.println(start+"----"+end);
-    }
+//    public static void main(String[] args) {
+//        int passwordLength = 30;
+//        List<String> stringList=new ArrayList<>();
+//        new SecureRandom().ints(passwordLength, 0, VALID_TOKEN_CHARS.size())
+//                .map(VALID_TOKEN_CHARS::get).forEach(v->stringList.add(String.valueOf((char) v)));
+//        String token="";
+//        for (String s : stringList) {
+//            token+=s;
+//        }
+//        System.out.println(token);
+//        LocalDate now=LocalDate.now().minusMonths(1);
+//        LocalDate end=now.with(TemporalAdjusters.lastDayOfMonth());
+//        LocalDate start=now.with(TemporalAdjusters.firstDayOfMonth());
+//        System.out.println(start+"----"+end);
+//    }
 
     //发送上周填写的工时统计
     @Scheduled(cron = "0 0 8 ? * *")

+ 53 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/CommonUtils.java

@@ -0,0 +1,53 @@
+package com.management.platform.util;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+public class CommonUtils {
+
+    /**
+     * 将String类型的xml转换成对象
+     */
+    public static Object convertXmlStrToObject(Class clazz, String xmlStr) {
+        Object xmlObject = null;
+        try {
+            JAXBContext context = JAXBContext.newInstance(clazz);
+            // 进行将Xml转成对象的核心接口
+            Unmarshaller unmarshaller = context.createUnmarshaller();
+            StringReader sr = new StringReader(xmlStr);
+            xmlObject = unmarshaller.unmarshal(sr);
+        } catch (JAXBException e) {
+            e.printStackTrace();
+        }
+        return xmlObject;
+    }
+
+
+    /**
+     * 对象转xml
+     * @param obj
+     * @return
+     */
+    public static String convertToXml(Object obj) {
+        // 创建输出流
+        StringWriter sw = new StringWriter();
+        try {
+            // 利用jdk中自带的转换类实现
+            JAXBContext context = JAXBContext.newInstance(obj.getClass());
+            Marshaller marshaller = context.createMarshaller();
+            // 格式化xml输出的格式
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
+                    Boolean.TRUE);
+            // 将对象转换成输出流形式的xml
+            marshaller.marshal(obj, sw);
+        } catch (JAXBException e) {
+            e.printStackTrace();
+        }
+        return sw.toString();
+    }
+
+}

+ 123 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/EasyExcelUtil.java

@@ -0,0 +1,123 @@
+package com.management.platform.util;
+
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.support.ExcelTypeEnum;
+import com.alibaba.excel.write.metadata.WriteSheet;
+import com.alibaba.excel.write.metadata.WriteTable;
+import com.alibaba.excel.write.metadata.WriteWorkbook;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+@Slf4j
+@Component
+public class EasyExcelUtil {
+    /**
+     * 导出逻辑代码
+     *
+     * @param
+     */
+    FileOutputStream outputStream=null;
+    public void dataExport(List<List<String>> list,String downloadPath,String fileName) {
+        try {
+            outputStream = new FileOutputStream(downloadPath+fileName);
+            long startTime = System.currentTimeMillis();
+            log.info("导出开始时间:{}", startTime);
+            WriteWorkbook writeWorkbook = new WriteWorkbook();
+            writeWorkbook.setOutputStream(outputStream);
+            writeWorkbook.setExcelType(ExcelTypeEnum.XLSX);
+            ExcelWriter writer = new ExcelWriter(writeWorkbook);
+            // TODO WriteTable 标题这块可以作为公共的封装起来:通过反射获取变量上注解等
+            WriteTable table = new WriteTable();
+            List<List<String>> titles = new ArrayList<List<String>>();
+            List<String> itemList = list.get(0);
+            for (String s : itemList) {
+                titles.add(Collections.singletonList(s));
+            }
+            table.setHead(titles);
+            // 记录总数:实际中需要根据查询条件(过滤数据)进行统计即可,
+            // TODO 此处写入限定的条数进行自测
+//            Integer totalCount = actResultLogService.count();
+            Integer totalCount = 200 * 10000;
+            // 每一个Sheet存放100w条数据
+            Integer sheetDataRows = 100*10000;
+            // 每次写入的数据量20w
+            Integer writeDataRows = 20*10000;
+            // 计算需要的Sheet数量
+            int sheetNum = totalCount % sheetDataRows == 0 ? (totalCount / sheetDataRows) : (totalCount / sheetDataRows + 1);
+            // 计算一般情况下每一个Sheet需要写入的次数(一般情况不包含最后一个sheet,因为最后一个sheet不确定会写入多少条数据)
+            int oneSheetWriteCount = totalCount > sheetDataRows ? sheetDataRows / writeDataRows : totalCount % writeDataRows > 0 ? totalCount / writeDataRows + 1 : totalCount / writeDataRows;
+            // 计算最后一个sheet需要写入的次数
+            int lastSheetWriteCount = totalCount % sheetDataRows == 0 ? oneSheetWriteCount : (totalCount % sheetDataRows % writeDataRows == 0 ? (totalCount / sheetDataRows / writeDataRows) : (totalCount / sheetDataRows / writeDataRows + 1));
+
+            // 开始分批查询分次写入
+            // 注意这次的循环就需要进行嵌套循环了,外层循环是Sheet数目,内层循环是写入次数
+            List<List<String>> dataList = new ArrayList<>();
+            for (int i = 0; i < sheetNum; i++) {
+                //创建Sheet
+                WriteSheet sheet = new WriteSheet();
+                sheet.setSheetNo(i);
+                sheet.setSheetName(fileName + i);
+                // 循环写入次数: j的自增条件是当不是最后一个Sheet的时候写入次数为正常的每个Sheet写入的次数,如果是最后一个就需要使用计算的次数lastSheetWriteCount
+                for (int j = 0; j < (i != sheetNum - 1 || i==0 ? oneSheetWriteCount : lastSheetWriteCount); j++) {
+                    // 集合复用,便于GC清理
+                    dataList.clear();
+                    // 分页查询一次20w
+//                    List<ActResultLogDO> resultList = actResultLogService.findByPage100w(j + 1 + oneSheetWriteCount * i, writeDataRows);
+//                    if (!CollectionUtils.isEmpty(resultList)) {
+//                        resultList.forEach(item -> {
+//                            dataList.add(Arrays.asList());
+//                        });
+//                    }
+                    // 写数据
+                    writer.write(dataList, sheet, table);
+                }
+            }
+
+
+            writer.finish();
+            outputStream.flush();
+            // 导出时间结束
+            long endTime = System.currentTimeMillis();
+            log.info("导出结束时间:{}", endTime + "ms");
+            log.info("导出所用时间:{}", (endTime - startTime) / 1000 + "秒");
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * 设置excel下载响应头属性
+     */
+    public static void setExcelRespProp(HttpServletResponse response, String rawFileName){
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setCharacterEncoding("utf-8");
+        String fileName = null;
+        try {
+            fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20");
+        } catch (UnsupportedEncodingException e) {
+            log.error("设置excel下载响应头属性,失败 {}",e.getMessage());
+        }
+        response.setHeader("Content-disposition", "attachment;filename=utf-8''" + fileName + ".xlsx");
+    }
+}

+ 357 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/VoiceSpeechUtil.java

@@ -0,0 +1,357 @@
+package com.management.platform.util;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import okhttp3.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+public class VoiceSpeechUtil extends WebSocketListener {
+    private static final String hostUrl = "https://iat-api.xfyun.cn/v2/iat"; //中英文,http url 不支持解析 ws/wss schema
+    // private static final String hostUrl = "https://iat-niche-api.xfyun.cn/v2/iat";//小语种
+    private static final String appid = "e1c8844d"; //在控制台-我的应用获取
+    private static final String apiSecret = "OWYyMDg2NWNiMWI0YzU1YmY0N2E4YmM4"; //在控制台-我的应用-语音听写(流式版)获取
+    private static final String apiKey = "bc025820fffc5bcd93c04bb3977e1ea6"; //在控制台-我的应用-语音听写(流式版)获取
+    private static  String filePath; // 中文
+    private static  File file; // 中文
+    public   String result; // 中文
+    public static final int StatusFirstFrame = 0;
+    public static final int StatusContinueFrame = 1;
+    public static final int StatusLastFrame = 2;
+    public static final Gson json = new Gson();
+    Decoder decoder = new Decoder();
+    // 开始时间
+    private static Date dateBegin = new Date();
+    // 结束时间
+    private static Date dateEnd = new Date();
+    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss.SSS");
+
+
+    public static void main(String[] args) throws Exception {
+        // 构建鉴权url
+        String authUrl = getAuthUrl(hostUrl, apiKey, apiSecret,file);
+        OkHttpClient client = new OkHttpClient.Builder().build();
+        //将url中的 schema http://和https://分别替换为ws:// 和 wss://
+        String url = authUrl.toString().replace("http://", "ws://").replace("https://", "wss://");
+        //System.out.println(url);
+        Request request = new Request.Builder().url(url).build();
+        // System.out.println(client.newCall(request).execute());
+        //System.out.println("url===>" + url);
+        WebSocket webSocket = client.newWebSocket(request, new VoiceSpeechUtil());
+    }
+
+    @Override
+    public void onOpen(WebSocket webSocket, Response response) {
+        super.onOpen(webSocket, response);
+        new Thread(()->{
+            //连接成功,开始发送数据
+            int frameSize = 1280; //每一帧音频的大小,建议每 40ms 发送 122B
+            int intervel = 40;
+            int status = 0;  // 音频的状态
+            try (FileInputStream fs = new FileInputStream(filePath)) {
+                byte[] buffer = new byte[frameSize];
+                // 发送音频
+                end:
+                while (true) {
+                    int len = fs.read(buffer);
+                    if (len == -1) {
+                        status = StatusLastFrame;  //文件读完,改变status 为 2
+                    }
+                    switch (status) {
+                        case StatusFirstFrame:   // 第一帧音频status = 0
+                            JsonObject frame = new JsonObject();
+                            JsonObject business = new JsonObject();  //第一帧必须发送
+                            JsonObject common = new JsonObject();  //第一帧必须发送
+                            JsonObject data = new JsonObject();  //每一帧都要发送
+                            // 填充common
+                            common.addProperty("app_id", appid);
+                            //填充business
+                            business.addProperty("language", "zh_cn");
+                            //business.addProperty("language", "en_us");//英文
+                            //business.addProperty("language", "ja_jp");//日语,在控制台可添加试用或购买
+                            //business.addProperty("language", "ko_kr");//韩语,在控制台可添加试用或购买
+                            //business.addProperty("language", "ru-ru");//俄语,在控制台可添加试用或购买
+                            business.addProperty("domain", "iat");
+                            business.addProperty("accent", "mandarin");//中文方言请在控制台添加试用,添加后即展示相应参数值
+                            //business.addProperty("nunum", 0);
+                            //business.addProperty("ptt", 0);//标点符号
+                            //business.addProperty("rlang", "zh-hk"); // zh-cn :简体中文(默认值)zh-hk :繁体香港(若未授权不生效,在控制台可免费开通)
+                            //business.addProperty("vinfo", 1);
+                            //business.addProperty("dwa", "wpgs");//动态修正(若未授权不生效,在控制台可免费开通)
+                            //business.addProperty("nbest", 5);// 句子多候选(若未授权不生效,在控制台可免费开通)
+                            //business.addProperty("wbest", 3);// 词级多候选(若未授权不生效,在控制台可免费开通)
+                            //填充data
+                            data.addProperty("status", StatusFirstFrame);
+                            data.addProperty("format", "audio/L16;rate=16000");
+                            data.addProperty("encoding", "raw");
+                            data.addProperty("audio", Base64.getEncoder().encodeToString(Arrays.copyOf(buffer, len)));
+                            //填充frame
+                            frame.add("common", common);
+                            frame.add("business", business);
+                            frame.add("data", data);
+                            webSocket.send(frame.toString());
+                            status = StatusContinueFrame;  // 发送完第一帧改变status 为 1
+                            break;
+                        case StatusContinueFrame:  //中间帧status = 1
+                            JsonObject frame1 = new JsonObject();
+                            JsonObject data1 = new JsonObject();
+                            data1.addProperty("status", StatusContinueFrame);
+                            data1.addProperty("format", "audio/L16;rate=16000");
+                            data1.addProperty("encoding", "raw");
+                            data1.addProperty("audio", Base64.getEncoder().encodeToString(Arrays.copyOf(buffer, len)));
+                            frame1.add("data", data1);
+                            webSocket.send(frame1.toString());
+                            // System.out.println("send continue");
+                            break;
+                        case StatusLastFrame:    // 最后一帧音频status = 2 ,标志音频发送结束
+                            JsonObject frame2 = new JsonObject();
+                            JsonObject data2 = new JsonObject();
+                            data2.addProperty("status", StatusLastFrame);
+                            data2.addProperty("audio", "");
+                            data2.addProperty("format", "audio/L16;rate=16000");
+                            data2.addProperty("encoding", "raw");
+                            frame2.add("data", data2);
+                            webSocket.send(frame2.toString());
+                            System.out.println("sendlast");
+                            break end;
+                    }
+                    Thread.sleep(intervel); //模拟音频采样延时
+                }
+                System.out.println("all data is send");
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }).start();
+    }
+
+    @Override
+    public void onMessage(WebSocket webSocket, String text) {
+        super.onMessage(webSocket, text);
+        //System.out.println(text);
+        ResponseData resp = json.fromJson(text, ResponseData.class);
+        if (resp != null) {
+            if (resp.getCode() != 0) {
+                System.out.println( "code=>" + resp.getCode() + " error=>" + resp.getMessage() + " sid=" + resp.getSid());
+                System.out.println( "错误码查询链接:https://www.xfyun.cn/document/error-code");
+                return;
+            }
+            if (resp.getData() != null) {
+                if (resp.getData().getResult() != null) {
+                    Text te = resp.getData().getResult().getText();
+                    //System.out.println(te.toString());
+                    try {
+                        decoder.decode(te);
+                        System.out.println("中间识别结果 ==》" + decoder.toString());
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+                if (resp.getData().getStatus() == 2) {
+                    // todo  resp.data.status ==2 说明数据全部返回完毕,可以关闭连接,释放资源
+                    System.out.println("session end ");
+                    dateEnd = new Date();
+                    System.out.println(sdf.format(dateBegin) + "开始");
+                    System.out.println(sdf.format(dateEnd) + "结束");
+                    System.out.println("耗时:" + (dateEnd.getTime() - dateBegin.getTime()) + "ms");
+                    System.out.println("最终识别结果 ==》" + decoder.toString());
+                    result=decoder.toString();
+                    System.out.println("本次识别sid ==》" + resp.getSid());
+                    decoder.discard();
+                    webSocket.close(1000, "");
+                } else {
+                    // todo 根据返回的数据处理
+                }
+            }
+        }
+    }
+    @Override
+    public void onFailure(WebSocket webSocket, Throwable t, Response response) {
+        super.onFailure(webSocket, t, response);
+        try {
+            if (null != response) {
+                int code = response.code();
+                System.out.println("onFailure code:" + code);
+                System.out.println("onFailure body:" + response.body().string());
+                if (101 != code) {
+                    System.out.println("connection failed");
+                    System.exit(0);
+                }
+            }
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+    public static String getAuthUrl(String hostUrl, String apiKey, String apiSecret, File file) throws Exception {
+        URL url = new URL(hostUrl);
+        filePath="C:\\upload\\pcm\\"+file.getName();
+        SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
+        format.setTimeZone(TimeZone.getTimeZone("GMT"));
+        String date = format.format(new Date());
+        StringBuilder builder = new StringBuilder("host: ").append(url.getHost()).append("\n").//
+                append("date: ").append(date).append("\n").//
+                append("GET ").append(url.getPath()).append(" HTTP/1.1");
+        //System.out.println(builder);
+        Charset charset = Charset.forName("UTF-8");
+        Mac mac = Mac.getInstance("hmacsha256");
+        SecretKeySpec spec = new SecretKeySpec(apiSecret.getBytes(charset), "hmacsha256");
+        mac.init(spec);
+        byte[] hexDigits = mac.doFinal(builder.toString().getBytes(charset));
+        String sha = Base64.getEncoder().encodeToString(hexDigits);
+
+        //System.out.println(sha);
+        String authorization = String.format("api_key=\"%s\", algorithm=\"%s\", headers=\"%s\", signature=\"%s\"", apiKey, "hmac-sha256", "host date request-line", sha);
+        //System.out.println(authorization);
+        HttpUrl httpUrl = HttpUrl.parse("https://" + url.getHost() + url.getPath()).newBuilder().//
+                addQueryParameter("authorization", Base64.getEncoder().encodeToString(authorization.getBytes(charset))).//
+                addQueryParameter("date", date).//
+                addQueryParameter("host", url.getHost()).//
+                build();
+        return httpUrl.toString();
+    }
+    public static class ResponseData {
+        private int code;
+        private String message;
+        private String sid;
+        private Data data;
+        public int getCode() {
+            return code;
+        }
+        public String getMessage() {
+            return this.message;
+        }
+        public String getSid() {
+            return sid;
+        }
+        public Data getData() {
+            return data;
+        }
+    }
+    public static class Data {
+        private int status;
+        private Result result;
+        public int getStatus() {
+            return status;
+        }
+        public Result getResult() {
+            return result;
+        }
+    }
+    public static class Result {
+        int bg;
+        int ed;
+        String pgs;
+        int[] rg;
+        int sn;
+        Ws[] ws;
+        boolean ls;
+        JsonObject vad;
+        public Text getText() {
+            Text text = new Text();
+            StringBuilder sb = new StringBuilder();
+            for (Ws ws : this.ws) {
+                sb.append(ws.cw[0].w);
+            }
+            text.sn = this.sn;
+            text.text = sb.toString();
+            text.sn = this.sn;
+            text.rg = this.rg;
+            text.pgs = this.pgs;
+            text.bg = this.bg;
+            text.ed = this.ed;
+            text.ls = this.ls;
+            text.vad = this.vad==null ? null : this.vad;
+            return text;
+        }
+    }
+    public static class Ws {
+        Cw[] cw;
+        int bg;
+        int ed;
+    }
+    public static class Cw {
+        int sc;
+        String w;
+    }
+    public static class Text {
+        int sn;
+        int bg;
+        int ed;
+        String text;
+        String pgs;
+        int[] rg;
+        boolean deleted;
+        boolean ls;
+        JsonObject vad;
+        @Override
+        public String toString() {
+            return "Text{" +
+                    "bg=" + bg +
+                    ", ed=" + ed +
+                    ", ls=" + ls +
+                    ", sn=" + sn +
+                    ", text='" + text + '\'' +
+                    ", pgs=" + pgs +
+                    ", rg=" + Arrays.toString(rg) +
+                    ", deleted=" + deleted +
+                    ", vad=" + (vad==null ? "null" : vad.getAsJsonArray("ws").toString()) +
+                    '}';
+        }
+    }
+    //解析返回数据,仅供参考
+    public static class Decoder {
+        private Text[] texts;
+        private int defc = 10;
+        public Decoder() {
+            this.texts = new Text[this.defc];
+        }
+        public synchronized void decode(Text text) {
+            if (text.sn >= this.defc) {
+                this.resize();
+            }
+            if ("rpl".equals(text.pgs)) {
+                for (int i = text.rg[0]; i <= text.rg[1]; i++) {
+                    this.texts[i].deleted = true;
+                }
+            }
+            this.texts[text.sn] = text;
+        }
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            for (Text t : this.texts) {
+                if (t != null && !t.deleted) {
+                    sb.append(t.text);
+                }
+            }
+            return sb.toString();
+        }
+        public void resize() {
+            int oc = this.defc;
+            this.defc <<= 1;
+            Text[] old = this.texts;
+            this.texts = new Text[this.defc];
+            for (int i = 0; i < oc; i++) {
+                this.texts[i] = old[i];
+            }
+        }
+        public void discard(){
+            for(int i=0;i<this.texts.length;i++){
+                this.texts[i]= null;
+            }
+        }
+    }
+}

+ 76 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/WebServiceUtils.java

@@ -0,0 +1,76 @@
+package com.management.platform.util;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+@Slf4j
+public class WebServiceUtils {
+
+    public static String requestByXml(String reqUrl, String sendMsg,int timeout) throws Exception {
+        // 开启HTTP连接ַ
+        InputStreamReader isr = null;
+        BufferedReader inReader = null;
+        StringBuffer resultSb = null;
+        String result =  null;
+        OutputStream outObject = null;
+        try {
+            URL url = new URL(reqUrl);
+            HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+
+            // 设置HTTP请求相关信息
+            httpConn.setRequestProperty("Content-Length",
+                    String.valueOf(sendMsg.getBytes().length));
+            httpConn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
+            httpConn.setRequestMethod("POST");
+            httpConn.setDoOutput(true);
+            httpConn.setDoInput(true);
+            if(timeout >0){
+                httpConn.setConnectTimeout(timeout);
+            }else{
+                httpConn.setConnectTimeout(1000*60);
+            }
+
+            // 进行HTTP请求
+            outObject = httpConn.getOutputStream();
+            outObject.write(sendMsg.getBytes("UTF-8"));
+
+            if (200 != (httpConn.getResponseCode())) {
+                throw new Exception("HTTP Request is not success, Response code is " + httpConn.getResponseCode());
+            }
+            // 获取HTTP响应数据
+            isr = new InputStreamReader(
+                    httpConn.getInputStream(), "utf-8");
+            inReader = new BufferedReader(isr);
+            resultSb = new StringBuffer();
+            String inputLine;
+            while ((inputLine = inReader.readLine()) != null) {
+                resultSb.append(inputLine);
+            }
+            if(resultSb != null && resultSb.length()>0){
+                result=resultSb.toString().replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&quot;", "\"").replaceAll("&#xD;", "").trim();;
+            }
+            log.debug("result================"+result);
+            return result.toString();
+        } catch (IOException e) {
+            throw e;
+        } finally {
+            // 关闭输入流
+            if (inReader != null) {
+                inReader.close();
+            }
+            if (isr != null) {
+                isr.close();
+            }
+            // 关闭输出流
+            if (outObject != null) {
+                outObject.close();
+            }
+        }
+    }
+}