沈静伟 4 лет назад
Родитель
Сommit
a6e456e05d

+ 36 - 20
src/dsb/com/cnd3b/common/Controller.java

@@ -451,31 +451,51 @@ public class Controller extends BaseClass {
         return rows;
     }
 
-    public Row getAttachmentUrl(long tattachmentid) {
+    public Rows getAttachmentUrl(long tattachmentid) {
         SQLFactory docfactory = new SQLFactory("附件查询_ID");
         docfactory.addParameter("siteid", siteid);
         docfactory.addParameter("tattachmentid", tattachmentid);
-        return dbConnect.runSqlQuery(docfactory.getSQL()).getRow(0);
+        return dbConnect.runSqlQuery(docfactory.getSQL());
     }
 
-    public RowsMap getAttachmentUrl(String ownertable, String[] ownerids) {
-        return getAttachmentUrl(ownertable, ownerids, "default");
+    public Rows getAttachmentUrl(String serialnumber) {
+        SQLFactory docfactory = new SQLFactory("附件查询_名称");
+        docfactory.addParameter("siteid", siteid);
+        docfactory.addParameter("serialnumber", serialnumber);
+        return dbConnect.runSqlQuery(docfactory.getSQL());
     }
 
-    public RowsMap getAttachmentUrl(String ownertable, ArrayList<String> ownerids) {
-        return getAttachmentUrl(ownertable, ownerids, "default");
+    public Rows getAttachmentUrl(String ownertable, String ownerid) {
+        SQLFactory docfactory = new SQLFactory("附件查询");
+        docfactory.addParameter("siteid", siteid);
+        docfactory.addParameter("ownertable", ownertable);
+        docfactory.addParameter_in("ownerid", ownerid);
+        return dbConnect.runSqlQuery(docfactory.getSQL());
     }
 
-    public Rows getAttachmentUrl(String ownertable, String ownerid) {
-        return getAttachmentUrl(ownertable, ownerid, "default");
+    public RowsMap getAttachmentUrl(String ownertable, String[] ownerids) {
+        SQLFactory docfactory = new SQLFactory("附件查询");
+        docfactory.addParameter("siteid", siteid);
+        docfactory.addParameter("ownertable", ownertable);
+        docfactory.addParameter_in("ownerid", ownerids);
+        return dbConnect.runSqlQuery(docfactory.getSQL()).toRowsMap("ownerid");
     }
 
-    public RowsMap getAttachmentUrl(String ownertable, ArrayList<String> ownerids, String ftype) {
-        return getAttachmentUrl(ownertable, ownerids.toArray(new String[0]), ftype);
+    public RowsMap getAttachmentUrl(String ownertable, ArrayList<String> ownerids) {
+        return getAttachmentUrl(ownertable, ownerids.toArray(new String[0]));
+    }
+
+    public Rows getAttachmentUrl(String ownertable, String ownerid, String ftype) {
+        SQLFactory attquerysql = new SQLFactory("附件查询_类型");
+        attquerysql.addParameter("siteid", siteid);
+        attquerysql.addParameter("ownertable", ownertable);
+        attquerysql.addParameter_in("ownerid", ownerid);
+        attquerysql.addParameter("ftype", ftype);
+        return dbConnect.runSqlQuery(attquerysql.getSQL());
     }
 
     public RowsMap getAttachmentUrl(String ownertable, String[] ownerids, String ftype) {
-        SQLFactory docfactory = new SQLFactory("附件查询");
+        SQLFactory docfactory = new SQLFactory("附件查询_类型");
         docfactory.addParameter("siteid", siteid);
         docfactory.addParameter("ownertable", ownertable);
         docfactory.addParameter_in("ownerid", ownerids);
@@ -483,7 +503,12 @@ public class Controller extends BaseClass {
         return dbConnect.runSqlQuery(docfactory.getSQL()).toRowsMap("ownerid");
     }
 
+    public RowsMap getAttachmentUrl(String ownertable, ArrayList<String> ownerids, String ftype) {
+        return getAttachmentUrl(ownertable, ownerids.toArray(new String[0]), ftype);
+    }
+
     public static HashMap<Long, String> headPicMap = new HashMap<>();
+
     /**
      * 获取用户头像
      *
@@ -499,15 +524,6 @@ public class Controller extends BaseClass {
         return headPicMap.getOrDefault(userid, "");
     }
 
-    public Rows getAttachmentUrl(String ownertable, String ownerid, String ftype) {
-        SQLFactory docfactory = new SQLFactory("附件查询");
-        docfactory.addParameter("siteid", siteid);
-        docfactory.addParameter("ownertable", ownertable);
-        docfactory.addParameter_in("ownerid", ownerid);
-        docfactory.addParameter("ftype", ftype);
-        return dbConnect.runSqlQuery(docfactory.getSQL());
-    }
-
     public RowsMap getAttachmentQty(String ownertable, String[] ownerids) {
         return getAttachmentQty(ownertable, ownerids, "default");
     }

+ 1 - 0
src/dsb/com/cnd3b/common/data/SQL/附件数量查询.sql

@@ -1,4 +1,5 @@
 select ownerid, count(0) as fattachmentcount
 from tattachment
 where ownertable =$ownertable$ and ftype=$ftype$ and siteid=$siteid$ and ownerid in $ownerid$
+and isnull(fparentid,0)=0
 group by ownerid

+ 20 - 16
src/dsb/com/cnd3b/common/data/SQL/附件查询.sql

@@ -1,16 +1,20 @@
-select siteid
-     , ownerid
-     , ownertable
-     , ftype
-     , REPLACE(fdocument, '.' + postfix, '') as fdocument
-     , tattachmentid
-     , postfix
-     , fobsurl as url
-     , fobsurl_minimage
-     , fobsurl_compressimage
-     , fobsurl_hls
-     , createdate
-     , contentlength
-from tattachment
-where ownertable =$ownertable$ and ftype=$ftype$ and siteid=$siteid$ and ownerid in $ownerid$
-order by tattachmentid
+select t1.siteid
+     , t1.ownerid
+     , t1.ownertable
+     , t1.ftype
+     , t1.fdocument
+     , t1.tattachmentid
+     , t1.postfix
+     , t1.serialnumber
+     , t1.fobsurl
+     , t2.fobsurl as fobsurl_thumbnail
+     , t3.fobsurl as fobsurl_compressed
+     , t4.fobsurl as fobsurl_hls
+     , t1.createdate
+     , t1.contentlength
+from tattachment t1
+left join tattachment t2 on t1.siteid=t2.siteid and t1.tattachmentid=t2.fparentid and t2.ftype='thumbnail'
+left join tattachment t3 on t1.siteid=t3.siteid and t1.tattachmentid=t3.fparentid and t3.ftype='compressed'
+left join tattachment t4 on t1.siteid=t4.siteid and t1.tattachmentid=t4.fparentid and t4.ftype='hls'
+where t1.ownertable =$ownertable$ and t1.siteid=$siteid$ and t1.ownerid in $ownerid$ and isnull(t1.fparentid,0)=0
+order by t1.tattachmentid

+ 20 - 16
src/dsb/com/cnd3b/common/data/SQL/附件查询_ID.sql

@@ -1,16 +1,20 @@
-select siteid
-     , ownerid
-     , ownertable
-     , ftype
-     , REPLACE(fdocument, '.' + postfix, '') as fdocument
-     , tattachmentid
-     , postfix
-     , fobsurl as url
-     , fobsurl_minimage
-     , fobsurl_compressimage
-     , fobsurl_hls
-     , createdate
-     , contentlength
-from tattachment
-where siteid=$siteid$ and tattachmentid=$tattachmentid$
-order by tattachmentid
+select t1.siteid
+     , t1.ownerid
+     , t1.ownertable
+     , t1.ftype
+     , t1.fdocument
+     , t1.tattachmentid
+     , t1.postfix
+     , t1.serialnumber
+     , t1.fobsurl
+     , t2.fobsurl as fobsurl_thumbnail
+     , t3.fobsurl as fobsurl_compressed
+     , t4.fobsurl as fobsurl_hls
+     , t1.createdate
+     , t1.contentlength
+from tattachment t1
+left join tattachment t2 on t1.siteid=t2.siteid and t1.tattachmentid=t2.fparentid and t2.ftype='thumbnail'
+left join tattachment t3 on t1.siteid=t3.siteid and t1.tattachmentid=t3.fparentid and t3.ftype='compressed'
+left join tattachment t4 on t1.siteid=t4.siteid and t1.tattachmentid=t4.fparentid and t4.ftype='hls'
+where t1.siteid=$siteid$ and t1.tattachmentid=$tattachmentid$
+order by t1.tattachmentid

+ 20 - 0
src/dsb/com/cnd3b/common/data/SQL/附件查询_名称.sql

@@ -0,0 +1,20 @@
+select t1.siteid
+     , t1.ownerid
+     , t1.ownertable
+     , t1.ftype
+     , t1.fdocument
+     , t1.tattachmentid
+     , t1.postfix
+     , t1.serialnumber
+     , t1.fobsurl
+     , t2.fobsurl as fobsurl_thumbnail
+     , t3.fobsurl as fobsurl_compressed
+     , t4.fobsurl as fobsurl_hls
+     , t1.createdate
+     , t1.contentlength
+from tattachment t1
+left join tattachment t2 on t1.siteid=t2.siteid and t1.tattachmentid=t2.fparentid and t2.ftype='thumbnail'
+left join tattachment t3 on t1.siteid=t3.siteid and t1.tattachmentid=t3.fparentid and t3.ftype='compressed'
+left join tattachment t4 on t1.siteid=t4.siteid and t1.tattachmentid=t4.fparentid and t4.ftype='hls'
+where t1.siteid=$siteid$ and t1.serialnumber=$serialnumber$
+order by t1.tattachmentid

+ 20 - 0
src/dsb/com/cnd3b/common/data/SQL/附件查询_类型.sql

@@ -0,0 +1,20 @@
+select t1.siteid
+     , t1.ownerid
+     , t1.ownertable
+     , t1.ftype
+     , t1.fdocument
+     , t1.tattachmentid
+     , t1.postfix
+     , t1.serialnumber
+     , t1.fobsurl
+     , t2.fobsurl as fobsurl_thumbnail
+     , t3.fobsurl as fobsurl_compressed
+     , t4.fobsurl as fobsurl_hls
+     , t1.createdate
+     , t1.contentlength
+from tattachment t1
+left join tattachment t2 on t1.siteid=t2.siteid and t1.tattachmentid=t2.fparentid and t2.ftype='thumbnail'
+left join tattachment t3 on t1.siteid=t3.siteid and t1.tattachmentid=t3.fparentid and t3.ftype='compressed'
+left join tattachment t4 on t1.siteid=t4.siteid and t1.tattachmentid=t4.fparentid and t4.ftype='hls'
+where t1.ownertable =$ownertable$ and t1.ftype=$ftype$ and t1.siteid=$siteid$ and t1.ownerid in $ownerid$ and isnull(t1.fparentid,0)=0
+order by t1.tattachmentid

+ 0 - 39
src/dsb/com/cnd3b/restcontroller/system/system/SQL/单附件查询.sql

@@ -1,39 +0,0 @@
-select t1.siteid
-     , t1.ownerid
-     , t1.ownertable
-     , t1.ftype
-     , t1.createby
-     , t1.createdate
-     , t1.postfix
-     , t1.serialnumber
-     , REPLACE(t1.fdocument, '.' + t1.postfix, '') as fdocument
-     , t1.tattachmentid
-     , t1.fobsurl                                  as url
-     , case
-           when t1.postfix in ('jpg','jpeg', 'png', 'mp4', 'mov') then fobsurl_minimage
-           else t1.fobsurl end                     as show_url
-     , fobsurl_compressimage as compressimage_url
-     , t1.fobsurl_hls
-     , count(t2.tattachmentid)                     as fdownloadcount
-     , t1.contentlength
-from tattachment t1
-         left join tattachment_downlog t2 on t1.siteid = t2.siteid and t1.tattachmentid = t2.tattachmentid
-where t1.siteid =$siteid$
-  and t1.ownertable=$ownertable$
-  and t1.ownerid=$ownerid$
-  and t1.serialnumber=$serialnumber$
-group by t1.siteid
-        , t1.ownerid
-        , t1.ownertable
-        , t1.ftype
-        , t1.createby
-        , t1.createdate
-        , t1.postfix
-        , t1.serialnumber
-        , REPLACE(t1.fdocument, '.' + t1.postfix, '')
-        , t1.tattachmentid
-        , t1.fobsurl
-        , t1.postfix, case
-    when t1.postfix in ('jpg','jpeg', 'png', 'mp4', 'mov') then fobsurl_minimage
-else
-t1.fobsurl end, fobsurl_compressimage,t1.fobsurl_hls, t1.contentlength

+ 27 - 0
src/dsb/com/cnd3b/restcontroller/system/system/SQL/子附件信息插入.sql

@@ -0,0 +1,27 @@
+INSERT INTO tattachment
+( tattachmentid
+, siteid
+, ownerid
+, ownertable
+, ftype
+, createby
+, createdate
+, postfix
+, serialnumber
+, fdocument
+, fobsurl
+, contentlength
+, fparentid)
+VALUES ($tattachmentid$
+       , $siteid$
+       , $ownerid$
+       , $ownertable$
+       , $ftype$
+       , $createby$
+       , getDate()
+       , $postfix$
+       , $serialnumber$
+       , $fdocument$
+       , $fobsurl$
+       , $contentlength$
+       , $fparentid$)

+ 1 - 1
src/dsb/com/cnd3b/restcontroller/system/system/SQL/附件信息删除.sql

@@ -1 +1 @@
-delete from tattachment where siteid=$siteid$ and tattachmentid=$tattachmentid$
+delete from tattachment where siteid=$siteid$ and (tattachmentid=$tattachmentid$ or fparentid=$tattachmentid$)

+ 4 - 6
src/dsb/com/cnd3b/restcontroller/system/system/SQL/附件信息插入.sql

@@ -10,10 +10,9 @@ INSERT INTO tattachment
 , serialnumber
 , fdocument
 , fobsurl
-, fobsurl_minimage
 , mpctaskid
-, contentlength
-, fobsurl_compressimage)
+, mpctaskstatus
+, contentlength)
 VALUES ($tattachmentid$
        , $siteid$
        , $ownerid$
@@ -25,7 +24,6 @@ VALUES ($tattachmentid$
        , $serialnumber$
        , $fdocument$
        , $fobsurl$
-       , $fobsurl_minimage$
        , $mpctaskid$
-       , $contentlength$
-       , $fobsurl_compressimage$)
+       , 0
+       , $contentlength$)

+ 0 - 37
src/dsb/com/cnd3b/restcontroller/system/system/SQL/附件查询.sql

@@ -1,37 +0,0 @@
-select t1.siteid
-     , t1.ownerid
-     , t1.ownertable
-     , t1.ftype
-     , t1.createby
-     , t1.createdate
-     , t1.postfix
-     , t1.serialnumber
-     , REPLACE(t1.fdocument, '.' + t1.postfix, '') as fdocument
-     , t1.tattachmentid
-     , t1.fobsurl                                  as url
-     , case
-           when t1.postfix in ('jpg','jpeg', 'png', 'mp4', 'mov') then fobsurl_minimage
-           else t1.fobsurl end                     as show_url
-     , fobsurl_compressimage as compressimage_url
-     , t1.fobsurl_hls
-     , count(t2.tattachmentid)                     as fdownloadcount
-     , t1.contentlength
-from tattachment t1
-         left join tattachment_downlog t2 on t1.siteid = t2.siteid and t1.tattachmentid = t2.tattachmentid
-where t1.siteid =$siteid$ and t1.ownertable=$ownertable$ and t1.ownerid=$ownerid$
-group by t1.siteid
-        , t1.ownerid
-        , t1.ownertable
-        , t1.ftype
-        , t1.createby
-        , t1.createdate
-        , t1.postfix
-        , t1.serialnumber
-        , REPLACE(t1.fdocument, '.' + t1.postfix, '')
-        , t1.tattachmentid
-        , t1.fobsurl
-        , t1.postfix, case
-    when t1.postfix in ('jpg','jpeg', 'png', 'mp4', 'mov') then fobsurl_minimage
-else
-t1.fobsurl end, fobsurl_compressimage,t1.fobsurl_hls, t1.contentlength
-order by case when t1.ftype='cover' then 0 else 1 end,t1.ftype,t1.createdate

+ 0 - 37
src/dsb/com/cnd3b/restcontroller/system/system/SQL/附件查询_按类别.sql

@@ -1,37 +0,0 @@
-select t1.siteid
-     , t1.ownerid
-     , t1.ownertable
-     , t1.ftype
-     , t1.createby
-     , t1.createdate
-     , t1.postfix
-     , t1.serialnumber
-     , REPLACE(t1.fdocument, '.' + t1.postfix, '') as fdocument
-     , t1.tattachmentid
-     , t1.fobsurl                                  as url
-     , case
-           when t1.postfix in ('jpg','jpeg', 'png', 'mp4', 'mov') then fobsurl_minimage
-           else t1.fobsurl end                     as show_url
-     , fobsurl_compressimage as compressimage_url
-     , t1.fobsurl_hls
-     , count(t2.tattachmentid)                     as fdownloadcount
-     , t1.contentlength
-from tattachment t1
-         left join tattachment_downlog t2 on t1.siteid = t2.siteid and t1.tattachmentid = t2.tattachmentid
-where t1.siteid =$siteid$ and t1.ownertable=$ownertable$ and t1.ownerid=$ownerid$ and t1.ftype=$ftype$
-group by t1.siteid
-        , t1.ownerid
-        , t1.ownertable
-        , t1.ftype
-        , t1.createby
-        , t1.createdate
-        , t1.postfix
-        , t1.serialnumber
-        , REPLACE(t1.fdocument, '.' + t1.postfix, '')
-        , t1.tattachmentid
-        , t1.fobsurl
-        , t1.postfix, case
-    when t1.postfix in ('jpg','jpeg', 'png', 'mp4', 'mov') then fobsurl_minimage
-else
-t1.fobsurl end, fobsurl_compressimage,t1.fobsurl_hls, t1.contentlength
-order by case when t1.ftype='cover' then 0 else 1 end,t1.ftype,t1.createdate

+ 132 - 92
src/dsb/com/cnd3b/restcontroller/system/system/docManage.java

@@ -265,7 +265,6 @@ public class docManage extends Controller {
         String ownerid = obsfilemap.get(obsfilename).get("ownerid");
         String ftype = obsfilemap.get(obsfilename).get("ftype");
 
-
         JSONObject resultObject = new JSONObject();
         try {
 
@@ -273,22 +272,8 @@ public class docManage extends Controller {
             if (!bucketFile.doesObjectExist(obsfilename)) {
                 return getErrReturnObject().setErrMsg("找不到对应的云存储文件").toString();
             }
-            /**
-             * 获取原文件的访问地址
-             */
-            String obsurl = bucketFile.getFileUrl(obsfilename);
-            ObjectMetadata matedata = bucketFile.getObjectMetadata(obsfilename);
-            long contentlength = matedata.getContentLength();
-            /**
-             * 获取缩略图的访问地址
-             */
-            String obsurl_imageshort = "";
-            String obsurl_imagecompress = "";
-            if (isImage(filetype)) {
-                obsurl_imageshort = bucketFile.getMinImageUrl(obsfilename);
-                obsurl_imagecompress = bucketFile.getCompressImageUrl(obsfilename);
-            }
-            bucketFile.close();
+
+
             /**
              * 视频转码
              */
@@ -305,35 +290,81 @@ public class docManage extends Controller {
                 MpcFactory mpcFactory = new MpcFactory();
                 mpctaskid = mpcFactory.createMpcTask(siteid, obsfilename);
             }
+            ArrayList<String> SQlist = new ArrayList<>();
             /**
              * 本地信息插入
              */
-            SQLFactory sqlFactory = new SQLFactory(this, "附件信息插入");
-            sqlFactory.addParameter("tattachmentid", createTableID("tattachment", "tattachmentid"));
-            sqlFactory.addParameter("siteid", siteid);
-            sqlFactory.addParameter("ownertable", ownertable);
-            sqlFactory.addParameter("ownerid", ownerid);
-            sqlFactory.addParameter("createby", username);
-            sqlFactory.addParameter("ftype", ftype);
-            sqlFactory.addParameter("postfix", filetype);
-            sqlFactory.addParameter("serialnumber", obsfilename);
-            filename = filename.replace("'", "");
-            sqlFactory.addParameter("fdocument", filename);
-            sqlFactory.addParameter("fobsurl", obsurl);
-            sqlFactory.addParameter("fobsurl_minimage", obsurl_imageshort);
-            sqlFactory.addParameter("fobsurl_compressimage", obsurl_imagecompress);
-            sqlFactory.addParameter("mpctaskid", mpctaskid);
-            sqlFactory.addParameter("contentlength", contentlength);
-
-            dbConnect.runSqlUpdate(sqlFactory.getSQL());
+            long tattachmentid = createTableID("tattachment", "tattachmentid");
+            {
+                SQLFactory sqlFactory = new SQLFactory(this, "附件信息插入");
+                sqlFactory.addParameter("tattachmentid", tattachmentid);
+                sqlFactory.addParameter("siteid", siteid);
+                sqlFactory.addParameter("ownertable", ownertable);
+                sqlFactory.addParameter("ownerid", ownerid);
+                sqlFactory.addParameter("createby", username);
+                sqlFactory.addParameter("ftype", ftype);
+                sqlFactory.addParameter("postfix", filetype);
+                sqlFactory.addParameter("serialnumber", obsfilename);
+                filename = filename.replace("'", "");
+                sqlFactory.addParameter("fdocument", filename);
+                sqlFactory.addParameter("fobsurl", bucketFile.getFileUrl(obsfilename));
+                sqlFactory.addParameter("mpctaskid", mpctaskid);
+                sqlFactory.addParameter("contentlength", bucketFile.getObjectMetadata(obsfilename).getContentLength());
+
+                SQlist.add(sqlFactory.getSQL());
+            }
+            if (isImage(filetype)) {
+                {
+                    //生成缩略图附件信息
+                    SQLFactory sqlFactory = new SQLFactory(this, "子附件信息插入");
+                    sqlFactory.addParameter("fparentid", tattachmentid);
+                    sqlFactory.addParameter("tattachmentid", createTableID("tattachment", "tattachmentid"));
+                    sqlFactory.addParameter("siteid", siteid);
+                    sqlFactory.addParameter("ownertable", ownertable);
+                    sqlFactory.addParameter("ownerid", ownerid);
+                    sqlFactory.addParameter("createby", username);
+                    sqlFactory.addParameter("ftype", "thumbnail");
+                    sqlFactory.addParameter("postfix", filetype);
+                    sqlFactory.addParameter("serialnumber", "s_" + obsfilename);
+                    filename = filename.replace("'", "");
+                    sqlFactory.addParameter("fdocument", filename);
+                    sqlFactory.addParameter("fobsurl", bucketFile.getMinImageUrl(obsfilename));
+                    sqlFactory.addParameter("contentlength", bucketFile.getObjectMetadata("s_" + obsfilename).getContentLength());
+                    SQlist.add(sqlFactory.getSQL());
+                }
+                {
+                    /**
+                     * 生成压缩图附件信息
+                     */
+                    SQLFactory sqlFactory = new SQLFactory(this, "子附件信息插入");
+                    sqlFactory.addParameter("fparentid", tattachmentid);
+                    sqlFactory.addParameter("tattachmentid", createTableID("tattachment", "tattachmentid"));
+                    sqlFactory.addParameter("siteid", siteid);
+                    sqlFactory.addParameter("ownertable", ownertable);
+                    sqlFactory.addParameter("ownerid", ownerid);
+                    sqlFactory.addParameter("createby", username);
+                    sqlFactory.addParameter("ftype", "compressed");
+                    sqlFactory.addParameter("postfix", filetype);
+                    sqlFactory.addParameter("serialnumber", "c_" + obsfilename);
+                    filename = filename.replace("'", "");
+                    sqlFactory.addParameter("fdocument", filename);
+                    sqlFactory.addParameter("fobsurl", bucketFile.getCompressImageUrl(obsfilename));
+                    sqlFactory.addParameter("contentlength", bucketFile.getObjectMetadata("c_" + obsfilename).getContentLength());
+                    SQlist.add(sqlFactory.getSQL());
+                }
+            }
+
+            dbConnect.runSqlUpdate(SQlist);
             obsfilemap.remove(obsfilename);
             resultObject.put("code", 1);
             resultObject.put("msg", "成功");
+
             if (content.getBooleanValue("fisreturnallfile")) {
-                resultObject.put("data", queryDocRow(ownertable, ownerid, obsfilename));
-            } else {
                 resultObject.put("data", queryDocRows(ownertable, ownerid));
+            } else {
+                resultObject.put("data", queryDocRow(obsfilename));
             }
+            bucketFile.close();
         } catch (Exception exception) {
             resultObject.put("code", 0);
             resultObject.put("msg", exception.getMessage());
@@ -368,23 +399,7 @@ public class docManage extends Controller {
                 if (!bucketFile.doesObjectExist(obsfilename)) {
                     continue;
                 }
-                /**
-                 * 获取原文件的访问地址
-                 */
-                String obsurl = bucketFile.getFileUrl(obsfilename);
-                ObjectMetadata matedata = bucketFile.getObjectMetadata(obsfilename);
-                long contentlength = matedata.getContentLength();
-                String contenttype = matedata.getContentType();
-                /**
-                 * 获取缩略图的访问地址
-                 */
-                String obsurl_imageshort = "";
-                String obsurl_imagecompress = "";
-                if (isImage(filetype)) {
-                    obsurl_imageshort = bucketFile.getMinImageUrl(obsfilename);
-                    obsurl_imagecompress = bucketFile.getCompressImageUrl(obsfilename);
-                }
-                bucketFile.close();
+
                 /**
                  * 视频转码
                  */
@@ -404,25 +419,67 @@ public class docManage extends Controller {
                 /**
                  * 本地信息插入
                  */
-                SQLFactory sqlFactory = new SQLFactory(this, "附件信息插入");
-                sqlFactory.addParameter("tattachmentid", createTableID("tattachment", "tattachmentid"));
-                sqlFactory.addParameter("siteid", siteid);
-                sqlFactory.addParameter("ownertable", ownertable);
-                sqlFactory.addParameter("ownerid", ownerid);
-                sqlFactory.addParameter("createby", username);
-                sqlFactory.addParameter("ftype", ftype);
-                sqlFactory.addParameter("postfix", filetype);
-                sqlFactory.addParameter("serialnumber", obsfilename);
-                filename = filename.replace("'", "");
-                sqlFactory.addParameter("fdocument", filename);
-                sqlFactory.addParameter("fobsurl", obsurl);
-                sqlFactory.addParameter("fobsurl_minimage", obsurl_imageshort);
-                sqlFactory.addParameter("fobsurl_compressimage", obsurl_imagecompress);
-                sqlFactory.addParameter("mpctaskid", mpctaskid);
-                sqlFactory.addParameter("contentlength", contentlength);
+                long tattachmentid = createTableID("tattachment", "tattachmentid");
+                {
+                    SQLFactory sqlFactory = new SQLFactory(this, "附件信息插入");
+                    sqlFactory.addParameter("tattachmentid", tattachmentid);
+                    sqlFactory.addParameter("siteid", siteid);
+                    sqlFactory.addParameter("ownertable", ownertable);
+                    sqlFactory.addParameter("ownerid", ownerid);
+                    sqlFactory.addParameter("createby", username);
+                    sqlFactory.addParameter("ftype", ftype);
+                    sqlFactory.addParameter("postfix", filetype);
+                    sqlFactory.addParameter("serialnumber", obsfilename);
+                    filename = filename.replace("'", "");
+                    sqlFactory.addParameter("fdocument", filename);
+                    sqlFactory.addParameter("fobsurl", bucketFile.getFileUrl(obsfilename));
+                    sqlFactory.addParameter("mpctaskid", mpctaskid);
+                    sqlFactory.addParameter("contentlength", bucketFile.getObjectMetadata(obsfilename).getContentLength());
+                    SQLlist.add(sqlFactory.getSQL());
+                }
+                if (isImage(filetype)) {
+                    {
+                        //生成缩略图附件信息
+                        SQLFactory sqlFactory = new SQLFactory(this, "子附件信息插入");
+                        sqlFactory.addParameter("fparentid", tattachmentid);
+                        sqlFactory.addParameter("tattachmentid", createTableID("tattachment", "tattachmentid"));
+                        sqlFactory.addParameter("siteid", siteid);
+                        sqlFactory.addParameter("ownertable", ownertable);
+                        sqlFactory.addParameter("ownerid", ownerid);
+                        sqlFactory.addParameter("createby", username);
+                        sqlFactory.addParameter("ftype", "thumbnail");
+                        sqlFactory.addParameter("postfix", filetype);
+                        sqlFactory.addParameter("serialnumber", "s_" + obsfilename);
+                        filename = filename.replace("'", "");
+                        sqlFactory.addParameter("fdocument", filename);
+                        sqlFactory.addParameter("fobsurl", bucketFile.getMinImageUrl(obsfilename));
+                        sqlFactory.addParameter("contentlength", bucketFile.getObjectMetadata("s_" + obsfilename).getContentLength());
+                        SQLlist.add(sqlFactory.getSQL());
+                    }
+                    {
+                        /**
+                         * 生成压缩图附件信息
+                         */
+                        SQLFactory sqlFactory = new SQLFactory(this, "子附件信息插入");
+                        sqlFactory.addParameter("fparentid", tattachmentid);
+                        sqlFactory.addParameter("tattachmentid", createTableID("tattachment", "tattachmentid"));
+                        sqlFactory.addParameter("siteid", siteid);
+                        sqlFactory.addParameter("ownertable", ownertable);
+                        sqlFactory.addParameter("ownerid", ownerid);
+                        sqlFactory.addParameter("createby", username);
+                        sqlFactory.addParameter("ftype", "compressed");
+                        sqlFactory.addParameter("postfix", filetype);
+                        sqlFactory.addParameter("serialnumber", "c_" + obsfilename);
+                        filename = filename.replace("'", "");
+                        sqlFactory.addParameter("fdocument", filename);
+                        sqlFactory.addParameter("fobsurl", bucketFile.getCompressImageUrl(obsfilename));
+                        sqlFactory.addParameter("contentlength", bucketFile.getObjectMetadata("c_" + obsfilename).getContentLength());
+                        SQLlist.add(sqlFactory.getSQL());
+                    }
+                }
 
-                SQLlist.add(sqlFactory.getSQL());
                 obsfilemap.remove(obsfilename);
+                bucketFile.close();
             } catch (Exception exception) {
                 exception.printStackTrace();
             }
@@ -545,32 +602,15 @@ public class docManage extends Controller {
     }
 
     private Rows queryDocRows(String ownertable, String ownerid) {
-        DBConnect dbConnect = new DBConnect();
-        SQLFactory sqlFactory = new SQLFactory(this, "附件查询");
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("ownertable", ownertable);
-        sqlFactory.addParameter("ownerid", ownerid);
-        return dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getAttachmentUrl(ownertable, ownerid);
     }
 
     private Rows queryDocRows(String ownertable, String ownerid, String ftype) {
-        DBConnect dbConnect = new DBConnect();
-        SQLFactory sqlFactory = new SQLFactory(this, "附件查询_按类别");
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("ftype", ftype);
-        sqlFactory.addParameter("ownertable", ownertable);
-        sqlFactory.addParameter("ownerid", ownerid);
-        return dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getAttachmentUrl(ownertable, ownerid, ftype);
     }
 
-    private Rows queryDocRow(String ownertable, String ownerid, String obsfilename) {
-        DBConnect dbConnect = new DBConnect();
-        SQLFactory sqlFactory = new SQLFactory(this, "单附件查询");
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("ownertable", ownertable);
-        sqlFactory.addParameter("ownerid", ownerid);
-        sqlFactory.addParameter("serialnumber", obsfilename);
-        return dbConnect.runSqlQuery(sqlFactory.getSQL());
+    private Rows queryDocRow(String obsfilename) {
+        return getAttachmentUrl(obsfilename);
     }
 
 

+ 29 - 22
src/dsb/com/cnd3b/service/ObsMpcTaskQuery.java

@@ -1,6 +1,8 @@
 package com.cnd3b.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.BaseClass;
+import com.cnd3b.common.Controller;
 import com.cnd3b.common.data.Row;
 import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.SQLFactory;
@@ -22,7 +24,6 @@ public class ObsMpcTaskQuery extends BaseClass implements Runnable {
         try {
             if (new SQLiteJDBC().checkServicesUsed("ObsMpcTaskQuery", true)) {
                 mpcTask();
-                createMinImage();
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -31,8 +32,8 @@ public class ObsMpcTaskQuery extends BaseClass implements Runnable {
 
     public void mpcTask() {
         DBConnect dbConnect = new DBConnect();
-        SQLFactory sqlFactory = new SQLFactory(this, "转码任务查询");
-        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        SQLFactory taskquerySQl = new SQLFactory(this, "转码任务查询");
+        Rows rows = dbConnect.runSqlQuery(taskquerySQl.getSQL());
 
         ArrayList<String> list = new ArrayList<>();
         if (!rows.isEmpty()) {
@@ -44,6 +45,11 @@ public class ObsMpcTaskQuery extends BaseClass implements Runnable {
             String siteid = row.getString("siteid");
             String tattachmentid = row.getString("tattachmentid");
             String mpctaskid = row.getString("mpctaskid");
+            String ownertable = row.getString("ownertable");
+            String ownerid = row.getString("ownerid");
+            String postfix = row.getString("postfix");
+            String fdocument = row.getString("fdocument");
+
             System.err.println("转码任务查询:开始执行第" + (rownum++) + "条,siteid:" + siteid + "tattachmentid:" + tattachmentid + "mpctaskid:" + mpctaskid);
             MpcFile file = mpcFactory.queryMpcTask(mpctaskid);
             if (file != null) {
@@ -59,8 +65,26 @@ public class ObsMpcTaskQuery extends BaseClass implements Runnable {
                 }
                 String fileurl = bucketFile.getFileUrl(obsfilename);
                 System.err.println("转码任务查询:获取转码文件访问地址" + fileurl);
-                String sql = "update tattachment set serialnumber_hls='" + objectname + "', fobsurl_hls='" + fileurl + "' where siteid='" + siteid + "' and tattachmentid='" + tattachmentid + "'";
-                list.add(sql);
+
+                //生成缩略图附件信息
+                SQLFactory sqlFactory = new SQLFactory(this, "子附件信息插入");
+                sqlFactory.addParameter("fparentid", tattachmentid);
+                sqlFactory.addParameter("tattachmentid", new Controller(new JSONObject()).createTableID("tattachment", "tattachmentid"));
+                sqlFactory.addParameter("siteid", siteid);
+                sqlFactory.addParameter("ownertable", ownertable);
+                sqlFactory.addParameter("ownerid", ownerid);
+                sqlFactory.addParameter("createby", "system");
+                sqlFactory.addParameter("ftype", "hls");
+                sqlFactory.addParameter("postfix", postfix);
+                sqlFactory.addParameter("serialnumber", objectname);
+                sqlFactory.addParameter("fdocument", fdocument);
+                sqlFactory.addParameter("fobsurl", fileurl);
+                sqlFactory.addParameter("contentlength", bucketFile.getObjectMetadata(obsfilename).getContentLength());
+
+
+                // String sql = "update tattachment set serialnumber_hls='" + objectname + "', fobsurl_hls='" + fileurl + "' where siteid='" + siteid + "' and tattachmentid='" + tattachmentid + "'";
+                list.add(sqlFactory.getSQL());
+                list.add("update tattachment set mpctaskstatus=1 where tattachmentid='" + tattachmentid + "'");
                 bucketFile.close();
             } else {
                 System.err.println("转码任务查询:转码未完成");
@@ -75,21 +99,4 @@ public class ObsMpcTaskQuery extends BaseClass implements Runnable {
         }
     }
 
-    /**
-     * 缩略图生成
-     */
-    public void createMinImage() {
-        DBConnect dbConnect = new DBConnect();
-        SQLFactory sqlFactory = new SQLFactory(this, "生成缩略图附件查询");
-        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
-        for (Row row : rows) {
-            String siteid = row.getString("siteid");
-            String serialnumber = row.getString("serialnumber");
-            String tattachmentid = row.getString("tattachmentid");
-            BucketFile bucketFile = new BucketFile(siteid);
-            String obsurl_imageshort = bucketFile.getMinImageUrl(serialnumber);
-            String obsurl_imagecompress = bucketFile.getCompressImageUrl(serialnumber);
-            dbConnect.runSqlUpdate("update tattachment set fobsurl_minimage='" + obsurl_imageshort + "',fobsurl_compressimage='" + obsurl_imagecompress + "' where siteid='" + siteid + "' and tattachmentid='" + tattachmentid + "'");
-        }
-    }
 }

+ 0 - 60
src/dsb/com/cnd3b/service/ObsRefreshUrlService.java

@@ -1,60 +0,0 @@
-package com.cnd3b.service;
-
-import com.cnd3b.common.BaseClass;
-
-public class ObsRefreshUrlService extends BaseClass implements Runnable {
-
-    @Override
-    public void run() {
-        //   try {
-//            if (new SQLiteJDBC().checkServicesUsed("ObsRefreshUrlService")) {
-//                SQLFactory outdateUrl = new SQLFactory(this, "华为云存储文件Url失效查询");
-//                DBConnect dbConnect = new DBConnect();
-//                RowsMap rowsMap = dbConnect.runSqlQuery(outdateUrl.getSQL()).toRowsMap("siteid");
-//                for (String siteid : rowsMap.keySet()) {
-//                    BucketFile bucketFile = new BucketFile(siteid);
-//                    Rows rows = rowsMap.get(siteid);
-//                    for (Row row : rows) {
-//                        String tattachmentid = row.getString("tattachmentid");
-//                        String serialnumber = row.getString("serialnumber");
-//                        String postfix = row.getString("postfix");
-//
-//                        String fobsurl = bucketFile.getFileUrl(serialnumber);
-//                        String fobsurl_minimage = "";
-//                        if (isImage(postfix)) {
-//                            fobsurl_minimage = bucketFile.getMinImageUrl(serialnumber);
-//                        } else if ("mp4".equalsIgnoreCase(postfix)) {
-//                            /**
-//                             * 入股是mp4文件,则自动截取封面图
-//                             */
-//                            String filename_short = serialnumber + ".jpg";
-//                            fobsurl_minimage = bucketFile.getMinImageUrl(filename_short);
-//                        }
-//                        SQLFactory updateUrl = new SQLFactory(this, "华为云存储文件Url更新");
-//                        updateUrl.addParameter("siteid", siteid);
-//                        updateUrl.addParameter("tattachmentid", tattachmentid);
-//                        updateUrl.addParameter("fobsurl", fobsurl);
-//                        updateUrl.addParameter("fobsurl_minimage", fobsurl_minimage);
-//                        Calendar calendar = Calendar.getInstance();
-//                        calendar.setTimeInMillis(getDateTime().getTime() + parameter.OBS_expireSeconds() * 1000);
-//                        updateUrl.addParameter("fobsurl_enddate", getDateTime_Str(calendar.getTime()));
-//                        dbConnect.runSqlUpdate(updateUrl.getSQL());
-//                    }
-//                }
-//            }
-        //   } catch (Exception e) {
-        //     e.printStackTrace();
-        //  }
-    }
-
-    public boolean isImage(String filetype) {
-        if (filetype.equalsIgnoreCase("JPG")) {
-            return true;
-        }
-        if (filetype.equalsIgnoreCase("JPEG")) {
-            return true;
-        }
-        return filetype.equalsIgnoreCase("PNG");
-    }
-
-}

+ 27 - 0
src/dsb/com/cnd3b/service/SQL/子附件信息插入.sql

@@ -0,0 +1,27 @@
+INSERT INTO tattachment
+( tattachmentid
+, siteid
+, ownerid
+, ownertable
+, ftype
+, createby
+, createdate
+, postfix
+, serialnumber
+, fdocument
+, fobsurl
+, contentlength
+, fparentid)
+VALUES ($tattachmentid$
+       , $siteid$
+       , $ownerid$
+       , $ownertable$
+       , $ftype$
+       , $createby$
+       , getDate()
+       , $postfix$
+       , $serialnumber$
+       , $fdocument$
+       , $fobsurl$
+       , $contentlength$
+       , $fparentid$)

+ 0 - 1
src/dsb/com/cnd3b/service/SQL/生成缩略图附件查询.sql

@@ -1 +0,0 @@
-select tattachmentid,siteid,serialnumber from tattachment where postfix in('jpg','png','jpeg')and isnull(fobsurl_minimage,'')=''

+ 2 - 3
src/dsb/com/cnd3b/service/SQL/转码任务查询.sql

@@ -1,4 +1,3 @@
-select siteid,tattachmentid, mpctaskid
+select siteid,tattachmentid, mpctaskid,ownertable,ownerid,postfix,fdocument
 from tattachment
-where --convert(varchar(10), createdate, 120) >= convert(varchar(10), DATEADD(DD, -1, GETDATE()), 120)and
-      isnull(mpctaskid, '') != '' and isnull(serialnumber_hls, '') = ''
+where isnull(mpctaskid, '') != '' and mpctaskstatus =0