Browse Source

更新文件上传替换

123456 1 year ago
parent
commit
9cc3fb2a1b

+ 1 - 1
src/com/trs/web2frame/tool/tyjyh/ggzyzheng/Annex.java

@@ -45,7 +45,7 @@ public class Annex {
                 while (set.next()){
                     String url = set.getString("url");
                     String name = set.getString("name");
-                    String file_url = saveBaseUrl +"" +url;
+                    String file_url = saveBaseUrl  +url;
                     String sUploadFile = updateFile(file_url);
                     if(!CMyString.isEmpty(sUploadFile)) {
                         JSONObject docRelObj = new JSONObject();

+ 4 - 70
src/com/trs/web2frame/tool/tyjyh/ggzyzheng/JsoupUtilsView.java

@@ -29,59 +29,27 @@ public class JsoupUtilsView {
     /*
      * 下载a标签对应的文件
      * */
-    public String rexStringHtml(String html) throws Exception {
+    public String rexStringHtml(String html,String filePath) throws Exception {
         Document doc = Jsoup.parse(html);
         try {
             Elements links = doc.select("a[href]");
-            System.out.println("==============");
-            System.out.println("=============="+links.text());
             for (Element link : links) {
                 String text = link.attr("href");
-                String name = updateFile(text);
+                String name = updateFile(filePath+text);
                 link.attr("href",name);
             }
             Elements linksrc = doc.select("img[src]");
             for (Element element : linksrc) {
                 String textsrc = element.attr("src");
-                String name = updateFile(textsrc);
+                String name = updateFile(filePath+textsrc);
                 element.attr("src",name);
             }
             Elements linkimg = doc.select("IMG[src]");
             for (Element element : linkimg) {
                 String textsrc = element.attr("src");
-                String name = updateFile(textsrc);
+                String name = updateFile(filePath+textsrc);
                 element.attr("src",name);
             }
-            Elements linkvideo = doc.select("video[src]");
-            for (Element element : linkvideo) {
-                String shtml = element.toString();
-                String[] split1 = html.split("<video");
-                System.out.println("+++++++++++++++++++++++++++");
-                String s1 = split1[0];
-                System.out.println(s1);
-                String s2 = split1[1];
-                String s3 = s2.split("</video>")[1];
-                System.out.println(s3);
-
-                String textsrc = element.attr("src");
-                try {
-                    String[] splitMp4 = textsrc.split("id=");
-                    String str = splitMp4[1];
-                    String[] split = str.split("&type=");
-                    String mp4 = split[0]+".mp4";
-                    System.out.println("====================="+mp4);
-                    String iframeHtml = "<p>\n" +
-                            "<iframe frameborder=\"0\" src=\"/masvod/public/video/player.html?data-src=oldvideo/"+mp4+"\" width=\"640\" height=\"480\" style=\"width:640px;height:480px;margin:auto;text-align: center;display:block\"></iframe>\n" +
-                            "</p><p>\n" +
-                            "<br/>\n" +
-                            "</p>";
-                    html = s1 + iframeHtml + s3;
-                    System.out.println("=============================new ");
-                    System.out.println(html);
-                }catch (Exception e){
-                    e.printStackTrace();
-                }
-            }
         }catch (Exception e){
             e.printStackTrace();
         }
@@ -90,36 +58,6 @@ public class JsoupUtilsView {
             Elements linkH = parse.select("a[href]");
             for (Element element : linkH) {
                 String href = element.attr("href");
-                int i = href.indexOf("down.asp");
-                if(i >= 0){
-                    continue;
-                }
-                int i1 = href.indexOf("_data/");
-                if(i1 >=0){
-                    continue;
-                }
-                int ia = href.indexOf("_Data/");
-                if(ia >=0){
-                    continue;
-                }
-                int ii = href.indexOf("/app-editor/");
-                if(ii >=0){
-                    continue;
-                }
-
-                int iiii = href.indexOf("_data/file");
-                if(iiii >=0){
-                    continue;
-                }
-
-                int iiiii = href.indexOf("/uploads/soft/");
-                if(iiiii >=0){
-                    continue;
-                }
-                int iiiiii = href.indexOf("common/preview_resource.action");
-                if(iiiiii >=0){
-                    continue;
-                }
                 String fileType = getFileTypeText(href);
                 if(fileType != null && fileType != ""){
                     element.attr("appendix","true");
@@ -129,10 +67,6 @@ public class JsoupUtilsView {
             Elements linkImg = parse.select("img[src]");
             for (Element element : linkImg) {
                 String src = element.attr("src");
-                int i = src.indexOf("images/doc.gif");
-                if(i >= 0){
-                    continue;
-                }
                 String fileType = getFileTypeText(src);
                 if(fileType != null && fileType != ""){
                     element.attr("needdownload","true");

+ 4 - 4
src/com/trs/web2frame/tool/tyjyh/ggzyzheng/ServiceImplGgzy.java

@@ -28,11 +28,11 @@ public class ServiceImplGgzy {
         try {
             StringBuilder sb=new StringBuilder(
                     "select " +
-                            "nmg.*, " +
-                            "from '"+tableName+"' nmg" +
-                            "where nmg.channle = '"+channelName+"' " +
+                            " nmg.*, " +
+                            " from  '"+tableName+"'  nmg" +
+                            " where  nmg.channle = '"+channelName+"' " +
                             " " +
-                            "order by nmg.time asc"
+                            " order by nmg.time asc "
             );
             System.out.println(sb);
             connection = ConnectionUtil.getConnectionBenji("mysql");

+ 8 - 11
src/com/trs/web2frame/tool/tyjyh/ggzyzheng/ViewMoveGgzy.java

@@ -28,20 +28,21 @@ public class ViewMoveGgzy {
 
     public static void main(String[] args) {
         ViewMoveGgzy viewMove = new ViewMoveGgzy();
+        viewMove.DataZhiXunByChannel("121","工作动态","nmgggzy",JsoupUtilsView.filePath);
     }
     /**
      * 资讯视图
-     * @param kpChannelId
+     * @param channelName
      * @param hyChannelId
      */
-    public void DataZhiXunByChannel(String kpChannelId,String hyChannelId,String tableName){
-        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + kpChannelId + "--hyChannelId:" + hyChannelId + "---------Start--------");
+    public void DataZhiXunByChannel(String channelName,String hyChannelId,String tableName,String filePath){
+        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + channelName + "--hyChannelId:" + hyChannelId + "---------Start--------");
         String sServiceId = "gov_webdocument";
         String sMethodName = "saveDocumentInWeb";//自定义视图
         ServiceImplGgzy serviceImplKp=new ServiceImplGgzy();
         Annex annex = new Annex();
         try {
-            List<Map<String,String>> allDocInfoFromKPDBdMaps = serviceImplKp.getNmgGgzy(kpChannelId,tableName);
+            List<Map<String,String>> allDocInfoFromKPDBdMaps = serviceImplKp.getNmgGgzy(channelName,tableName);
             if(allDocInfoFromKPDBdMaps!=null){
                 int count=0;
                 for (Map<String,String> map : allDocInfoFromKPDBdMaps) {
@@ -77,7 +78,7 @@ public class ViewMoveGgzy {
                     //处理附件
                     try {
                         if (documentData.getId() != null) {
-                            Map<String, Object> getRelFileInfoByDocId = annex.getZhiXunFileInfoByDocId(JsoupUtilsView.filePath,documentData.getId());
+                            Map<String, Object> getRelFileInfoByDocId = annex.getZhiXunFileInfoByDocId(filePath,documentData.getId());
                             if( getRelFileInfoByDocId.get("docRelFile") != null){
                                 oPostData.put("docRelFile", getRelFileInfoByDocId.get("docRelFile"));
                             }
@@ -95,7 +96,7 @@ public class ViewMoveGgzy {
                             System.out.println("===================start=======================");
                             System.out.println(currentFilePathHtmlUrl);
                             JsoupUtilsView jsoupUtils = new JsoupUtilsView();
-                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
+                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl,filePath);
                             System.out.println("==============================================");
                             System.out.println(html);
                             System.out.println("===================end========================");
@@ -118,7 +119,7 @@ public class ViewMoveGgzy {
                         }
                     }
                     if(content.equals("文件文章")){
-                        String url = JsoupUtilsView.filePath +""+ documentData.getUrl();
+                        String url = filePath+ documentData.getUrl();
                         String filename = documentData.getUrl();
                         String docTitle = documentData.getTitle();
                         if (documentData.getContent() != null && documentData.getContent() != "") {
@@ -130,15 +131,12 @@ public class ViewMoveGgzy {
                                         + "\",\"AppendixId\":\"0\", \"SrcFile\":\"" + filename
                                         + "\",\"OTHEROPERATION\":0 }";
                                 DOCFILE += "]";
-
                                 oPostData.put("DocFileName", docfilename);
                                 oPostData.put("DOCFILE", DOCFILE);
                                 // oPostData.put("DOCPUBURL",oDispatch);
                             }
-
                         }
                     }
-
                     try {
                         System.out.println(oPostData);
                         Dispatch result = WCMServiceCaller.Call(sServiceId, sMethodName, oPostData, true);
@@ -210,7 +208,6 @@ public class ViewMoveGgzy {
 
     public String getJg(String jgmc)
     {
-
         String code = null;
         List<DemoDataJiGou> list = new ArrayList<>();
         EasyExcel.read(ColumnConfig.fileName, DemoDataJiGou.class, new PageReadListener<DemoDataJiGou>(dataList -> {