瀏覽代碼

Merge remote-tracking branch 'origin/develop' into develop

吴志根 3 年之前
父節點
當前提交
4dc13d477d

+ 1 - 1
src/dsb/com/cnd3b/restcontroller/customer/live/live.java

@@ -361,7 +361,7 @@ public class live extends Controller {
     public String getRealTimeViewers() {
         String channelid = content.getString("channelid");
         //String sql = "SELECT [count] FROM tlive_usercount WHERE [time]='" + getDateTime_Str() + "' AND channelid='" + channelid + "'";
-        String sql = "select channelid,count as fcustcount from (select ROW_NUMBER()over(partition by t1.channelid order by t1.time desc)as num,t1.channelid,t1.count from tlive_usercount t1 where t1. channelid='" + channelid + "')t where t.num=1";
+        String sql = "select channelid,count as fcustcount from (select ROW_NUMBER()over(partition by t1.channelid order by t1.time desc)as num,t1.channelid,(t1.count+t1.fadjustcount) as count from tlive_usercount t1 where t1. channelid='" + channelid + "')t where t.num=1";
         System.err.println(sql);
         Rows rows = dbConnect.runSqlQuery(sql);
         JSONObject resultObject = new JSONObject();

+ 1 - 1
src/dsb/com/cnd3b/restcontroller/enterprise/data/SQL/直播观众数.sql

@@ -1,7 +1,7 @@
 select sum(count) as fcustcount
 from (
          select ROW_NUMBER() over(partition by t1.channelid order by t1.time desc)as num,
-                t1.count
+                (t1.count+t1.fadjustcount) as count
          from tlive_usercount t1
                   inner join tlive t2 on t1.channelid = t2.channelid --and t2.livestatus='live'
      ) t

+ 1 - 1
src/dsb/com/cnd3b/restcontroller/publicmethod/live/SQL/当前线上观众人数查询.sql

@@ -12,7 +12,7 @@ from (
          select ROW_NUMBER() over(partition by t1.channelid order by t1.time desc)as num,t1.channelid,
                 t2.tagentsid,
                 t2.livestatus,
-                t1.count,
+                (t1.count+t1.fadjustcount)as count,
                 t2.channelcoverimageurl,
                 t2.fliveshowurl,
                 t3.fbrand,

+ 1 - 1
src/dsb/com/cnd3b/restcontroller/publicmethod/live/SQL/线上观众人数趋势.sql

@@ -1,3 +1,3 @@
-select right(convert(varchar(16),time,120),5)as time,max(count) as fcount from tlive_usercount
+select right(convert(varchar(16),time,120),5)as time,max(count+fadjustcount) as fcount from tlive_usercount
 where convert(varchar(10),time,120)=convert(varchar(10),getdate(),120)
 group by convert(varchar(16),time,120) order by time

+ 4 - 0
src/dsb/com/cnd3b/service/GetPolyvAnalysisData.java

@@ -137,6 +137,10 @@ public class GetPolyvAnalysisData extends BaseClass implements Runnable {
             sqllist.add(sqlFactory.getSQL());
         }
         dbConnect.runSqlUpdate(sqllist);
+
+        SQLFactory sqlFactory = new SQLFactory(this, "直播频道在线用户调整数更新");
+        sqlFactory.addParameter_in("channelid", channelids);
+        dbConnect.runSqlUpdate(sqlFactory);
     }
 
 }

+ 12 - 0
src/dsb/com/cnd3b/service/SQL/直播频道在线用户调整数更新.sql

@@ -0,0 +1,12 @@
+update tlive_usercount set fadjustcount=t.fadjustcount from (
+	select t.channelid,t.time,(case when t.fadjustcount+t.fadjustcount2<0 or t.fadjustcount+t.fadjustcount2>200 then t.fadjustcount else t.fadjustcount+t.fadjustcount2 end )as fadjustcount from (
+	select t.channelid,t.time,t.fadjustcount,
+	case when RAND()>0.4 then cast(floor(rand()*10) as int ) else -cast(floor(rand()*7) as int ) end as fadjustcount2 
+	from (
+	select ROW_NUMBER()over(partition by channelid order by time desc)as row, channelid,time,count,isnull(fadjustcount,0)as fadjustcount from tlive_usercount where fadjustcount is not null
+	and channelid in $channelid$
+	)t where t.row=1 and count>0
+)t
+)t where t.channelid=tlive_usercount.channelid and tlive_usercount.fadjustcount is null
+
+update tlive_usercount set fadjustcount=0 where (fadjustcount is null or count=0)and channelid in $channelid$

+ 17 - 2
src/dsb/com/cnd3b/utility/obs/Bucket.java

@@ -144,9 +144,24 @@ public class Bucket {
         return storageInfo.getObjectNumber();
     }
 
+    public void getFiles() {
+        ListObjectsRequest request = new ListObjectsRequest("bucketname");
+        // 设置文件夹对象名"dir/"为前缀
+        //request.setPrefix("dir/");
+        request.setMaxKeys(1000);
+        ObjectListing result;
+        do {
+            result = obsClient.listObjects(request);
+            for (ObsObject obsObject : result.getObjects()) {
+                System.out.println("\t" + obsObject.getObjectKey());
+                System.out.println("\t" + obsObject.getOwner());
+            }
+            request.setMarker(result.getNextMarker());
+        } while (result.isTruncated());
+    }
 
     public static void main(String[] args) {
-        Bucket bucket = new Bucket("jxyl");
-        bucket.setBucketCors();
+        Bucket bucket = new Bucket("bwj");
+        bucket.getFiles();
     }
 }

+ 1 - 1
src/dsb/com/cnd3b/utility/obs/BucketFileTest.java

@@ -13,7 +13,7 @@ public class BucketFileTest {
 
     public BucketFileTest(String siteid) {
         // ´´½¨ObsClientʵÀý
-        obsClient = new ObsClient("EKJMDXUVJLBGDRCVVVLP", "9EUAXeFmxKjJ5x12lYVTzCCUuIQIjrO6VAyzGr9u", "obs.cn-east-2.myhuaweicloud.com");
+        obsClient = new ObsClient("4RMST7WMRECXTYVMFVZQ", "YbxBUDT2UeohsWi7dyZ8MCUKOTodjrqNwnZ0VjEL", "obs.cn-east-2.myhuaweicloud.com");
         this.bucketname = siteid.toLowerCase();
     }
 

+ 169 - 0
src/dsb/com/cnd3b/utility/obs/BucketTest.java

@@ -0,0 +1,169 @@
+package com.cnd3b.utility.obs;
+
+import com.cnd3b.common.parameter.parameter;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BucketTest {
+    protected String bucketname;
+    ObsClient obsClient;
+
+    public BucketTest(String siteid) {
+        // 创建ObsClient实例
+        obsClient = new ObsClient("4RMST7WMRECXTYVMFVZQ", "YbxBUDT2UeohsWi7dyZ8MCUKOTodjrqNwnZ0VjEL", "obs.cn-east-2.myhuaweicloud.com");
+        this.bucketname = siteid.toLowerCase();
+        //a();
+    }
+
+    public void setBucketCors() {
+        BucketCors cors = new BucketCors();
+
+        List<BucketCorsRule> rules = new ArrayList<BucketCorsRule>();
+        BucketCorsRule rule = new BucketCorsRule();
+
+        ArrayList<String> allowedOrigin = new ArrayList<String>();
+// 指定允许跨域请求的来源
+        allowedOrigin.add("*");
+        rule.setAllowedOrigin(allowedOrigin);
+
+        ArrayList<String> allowedMethod = new ArrayList<String>();
+// 指定允许的跨域请求方法(GET/PUT/DELETE/POST/HEAD)
+        allowedMethod.add("GET");
+        allowedMethod.add("HEAD");
+        allowedMethod.add("PUT");
+        allowedMethod.add("POST");
+        allowedMethod.add("DELETE");
+        rule.setAllowedMethod(allowedMethod);
+
+        ArrayList<String> allowedHeader = new ArrayList<String>();
+// 控制在OPTIONS预取指令中Access-Control-Request-Headers头中指定的header是否被允许使用
+        allowedHeader.add("*");
+        rule.setAllowedHeader(allowedHeader);
+
+        //ArrayList<String> exposeHeader = new ArrayList<String>();
+// 指定允许用户从应用程序中访问的header
+//        exposeHeader.add("x-obs-expose-header");
+//        rule.setExposeHeader(exposeHeader);
+
+// 指定浏览器对特定资源的预取(OPTIONS)请求返回结果的缓存时间,单位为秒
+        rule.setMaxAgeSecond(3600);
+        rules.add(rule);
+        cors.setRules(rules);
+        obsClient.setBucketCors(bucketname, cors);
+    }
+
+    public String getBucketName() {
+        return this.bucketname;
+    }
+
+
+    /**
+     * 创建桶
+     */
+    public boolean create() {
+        // 创建桶
+        try {
+            ObsBucket obsBucket = new ObsBucket();
+            obsBucket.setBucketName(bucketname);
+            // 设置桶访问权限为公共读写
+            obsBucket.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ_WRITE);
+            // 设置桶区域位置
+            obsBucket.setLocation(parameter.Bucket_location());
+            // 创建桶
+            HeaderResponse response = obsClient.createBucket(obsBucket);
+            setBucketCors();
+        } catch (ObsException e) {
+            // 创建桶失败
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            System.out.println("Error Code:" + e.getErrorCode());
+            System.out.println("Error Message: " + e.getErrorMessage());
+
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 是否已存在桶
+     *
+     * @return
+     */
+    public boolean isAllReadyUsed() {
+        return obsClient.headBucket(bucketname);
+    }
+
+
+    /**
+     * 删除桶
+     *
+     * @return
+     */
+    public void delete() {
+        // 删除桶
+        obsClient.deleteBucket(bucketname);
+    }
+
+    /**
+     * 设置桶配额,单位G
+     */
+    public void setVolume(long volume) {
+        BucketQuota quota = new BucketQuota(1024 * 1024 * 1024 * volume);
+        obsClient.setBucketQuota(bucketname, quota);
+    }
+
+    /**
+     * 获取桶配额,单位字节
+     */
+    public long getMaxVolume() {
+        BucketQuota quota = obsClient.getBucketQuota(bucketname);
+        return quota.getBucketQuota();
+    }
+
+    /**
+     * 获取桶存量
+     *
+     * @return
+     */
+    public long getVolume() {
+        BucketStorageInfo storageInfo = obsClient.getBucketStorageInfo(bucketname);
+        return storageInfo.getSize();
+    }
+
+    /**
+     * 获取文件数量
+     *
+     * @return
+     */
+    public long getFileCount() {
+        BucketStorageInfo storageInfo = obsClient.getBucketStorageInfo(bucketname);
+        return storageInfo.getObjectNumber();
+    }
+
+    public void getFiles() {
+        ListObjectsRequest request = new ListObjectsRequest(bucketname);
+        // 设置文件夹对象名"dir/"为前缀
+        //request.setPrefix("dir/");
+        request.setMaxKeys(1000);
+        ObjectListing result;
+        int i = 0;
+        do {
+            result = obsClient.listObjects(request);
+            for (ObsObject obsObject : result.getObjects()) {
+                System.out.println(++i + ":" + obsObject.getObjectKey());
+                //System.out.println("\t" + obsObject.getOwner());
+            }
+            request.setMarker(result.getNextMarker());
+        } while (result.isTruncated());
+    }
+
+    public static void main(String[] args) {
+        BucketTest bucket = new BucketTest("bwj");
+        bucket.getFiles();
+    }
+}

+ 1 - 1
src/dsb/com/cnd3b/utility/polyv/Polyv.java

@@ -298,7 +298,7 @@ public class Polyv extends BaseClass {
             if ("".equals(channelIds)) {
                 channelIds = channelId;
             } else {
-                if(channelId!=null){
+                if (channelId != null) {
                     channelIds = channelIds + "," + channelId;
                 }