Browse Source

Merge branch 'develop'

沈静伟 3 years ago
parent
commit
0ce89e578b

+ 27 - 9
src/dsb/com/cnd3b/common/Controller.java

@@ -19,6 +19,8 @@ import p2.util.P2Exception;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.lang.reflect.Method;
 import java.sql.Connection;
 import java.sql.Connection;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
 
 
 public class Controller extends BaseClass {
 public class Controller extends BaseClass {
@@ -533,15 +535,15 @@ public class Controller extends BaseClass {
      */
      */
     public String getHeadPic(long userid) {
     public String getHeadPic(long userid) {
 //        if (!headPicMap.containsKey(userid)) {
 //        if (!headPicMap.containsKey(userid)) {
-            Rows rows = getAttachmentUrl("tenterprise_users", String.valueOf(userid), "headportrait");
-            if (!rows.isEmpty()) {
-                if(rows.get(0).getString("fobsurl_thumbnail").equals("")){
-                    headPicMap.put(userid, rows.get(0).getString("fobsurl"));
-                }else{
-                    headPicMap.put(userid, rows.get(0).getString("fobsurl_thumbnail"));
-                }
-
+        Rows rows = getAttachmentUrl("tenterprise_users", String.valueOf(userid), "headportrait");
+        if (!rows.isEmpty()) {
+            if (rows.get(0).getString("fobsurl_thumbnail").equals("")) {
+                headPicMap.put(userid, rows.get(0).getString("fobsurl"));
+            } else {
+                headPicMap.put(userid, rows.get(0).getString("fobsurl_thumbnail"));
             }
             }
+
+        }
 //        }
 //        }
         return headPicMap.getOrDefault(userid, "");
         return headPicMap.getOrDefault(userid, "");
     }
     }
@@ -666,7 +668,7 @@ public class Controller extends BaseClass {
     /**
     /**
      * 通知前端执行指定方法
      * 通知前端执行指定方法
      */
      */
-    public void sendSystemWebSocketMessage(String classname, String method,long userid) {
+    public void sendSystemWebSocketMessage(String classname, String method, long userid) {
         if (parameter.websocketClients.containsKey(userid)) {
         if (parameter.websocketClients.containsKey(userid)) {
             JSONObject methodobject = new JSONObject();
             JSONObject methodobject = new JSONObject();
             methodobject.put("type", "callmethod");
             methodobject.put("type", "callmethod");
@@ -677,6 +679,7 @@ public class Controller extends BaseClass {
             }
             }
         }
         }
     }
     }
+
     /**
     /**
      * 通知前端执行指定方法
      * 通知前端执行指定方法
      */
      */
@@ -836,4 +839,19 @@ public class Controller extends BaseClass {
     public Date getLoginDate(long userid) {
     public Date getLoginDate(long userid) {
         return parameter.loginDate.getOrDefault(userid, getDateTime());
         return parameter.loginDate.getOrDefault(userid, getDateTime());
     }
     }
+
+    public long getTimestamp(String time) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        Date date = null;
+        try {
+            date = format.parse(time);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        //日期转时间戳(毫秒)
+        return date.getTime();
+    }
+
+
 }
 }

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

@@ -111,6 +111,20 @@ public class live extends Controller {
      * @return
      * @return
      */
      */
     public String getLiveInfo() throws P2Exception {
     public String getLiveInfo() throws P2Exception {
+        try {
+            Rows channelidrows = dbConnect.runSqlQuery("select channelid from tlive where tagentsid='" + tagentsid + "' and categoryName = 'Õ¹»áÖ±²¥'");
+            for (Row row : channelidrows) {
+                String channelid = row.getString("channelid");
+                Polyv polyv = new Polyv();
+                LiveChannelInfoResponse liveChannelInfoResponse = polyv.getChannelInfo(channelid);
+                if (liveChannelInfoResponse != null) {
+                    String channelpasswd = liveChannelInfoResponse.getChannelPasswd();
+                    dbConnect.runSqlUpdate("update tlive set channelpasswd='" + channelpasswd + "' where channelid='" + channelid + "'");
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         SQLFactory sqlFactory = new SQLFactory(this, "Õ¹»áÖ±²¥ÏêÇé");
         SQLFactory sqlFactory = new SQLFactory(this, "Õ¹»áÖ±²¥ÏêÇé");
         sqlFactory.addParameter("siteid", siteid);
         sqlFactory.addParameter("siteid", siteid);
         sqlFactory.addParameter("tagentsid", tagentsid);
         sqlFactory.addParameter("tagentsid", tagentsid);

+ 20 - 4
src/dsb/com/cnd3b/restcontroller/publicmethod/live/live.java

@@ -19,9 +19,11 @@ public class live extends Controller {
      * @return
      * @return
      */
      */
     public String getLiveChannelData() {
     public String getLiveChannelData() {
+
+
         String tactivityid = content.getString("tactivityid");
         String tactivityid = content.getString("tactivityid");
         String saleprodclass = content.getString("saleprodclass");
         String saleprodclass = content.getString("saleprodclass");
-        if(saleprodclass==null){
+        if (saleprodclass == null) {
             saleprodclass = "";
             saleprodclass = "";
         }
         }
         JSONObject resultObject = new JSONObject();
         JSONObject resultObject = new JSONObject();
@@ -42,7 +44,7 @@ public class live extends Controller {
         SQLFactory livecustcount = new SQLFactory(this, "当前线上观众人数查询");
         SQLFactory livecustcount = new SQLFactory(this, "当前线上观众人数查询");
         livecustcount.addParameter("tactivityid", tactivityid);
         livecustcount.addParameter("tactivityid", tactivityid);
         livecustcount.addParameter("siteid", siteid);
         livecustcount.addParameter("siteid", siteid);
-        livecustcount.addParameter("saleprodclass","%"+saleprodclass+"%");
+        livecustcount.addParameter("saleprodclass", "%" + saleprodclass + "%");
         Rows liverows = dbConnect.runSqlQuery(livecustcount.getSQL());
         Rows liverows = dbConnect.runSqlQuery(livecustcount.getSQL());
 
 
         String sql = livecustcount.getSQL();
         String sql = livecustcount.getSQL();
@@ -56,7 +58,7 @@ public class live extends Controller {
         resultObject.put("flivecount", flivecount);
         resultObject.put("flivecount", flivecount);
         //当前在线观众人数
         //当前在线观众人数
         resultObject.put("fcustcount", liverows.isEmpty() ? 0 : liverows.sum("fcustcount"));
         resultObject.put("fcustcount", liverows.isEmpty() ? 0 : liverows.sum("fcustcount"));
-        for(Row row:liverows){
+        for (Row row : liverows) {
             //观看次数(次)
             //观看次数(次)
             String channelid = row.getString("channelid");
             String channelid = row.getString("channelid");
             //观看人数(人)
             //观看人数(人)
@@ -82,7 +84,21 @@ public class live extends Controller {
                     newliverows.add(liverows.get(i));
                     newliverows.add(liverows.get(i));
                 }
                 }
             }
             }
-            resultObject.put("tlivelist", newliverows);
+            //限制在2022-03-17,2022-03-19
+            Long time1 = getTimestamp("2022-03-17 19:30:00");
+            Long time2 = getTimestamp("2022-03-18 19:30:00");
+            Long time3 = getTimestamp("2022-03-19 19:30:00");
+            Long timeEnd = getTimestamp("2022-03-20 00:00:00");
+            Long timeNow = System.currentTimeMillis();
+            System.err.println(time1);
+            long hour = 3600000*2;
+            System.err.println(time2+hour);
+            if ((timeNow >= time1 && timeNow <= time1 + hour) || (timeNow >= time2 && timeNow <= time2 + hour) || (timeNow >= time3 && timeNow <= time3 + hour) || (timeNow >= timeEnd)) {
+                resultObject.put("tlivelist", newliverows);
+            } else {
+                resultObject.put("tlivelist", new Rows());
+            }
+
             resultObject.put("pageSize", pageSize);
             resultObject.put("pageSize", pageSize);
             resultObject.put("pageNumber", pageNumber);
             resultObject.put("pageNumber", pageNumber);
             resultObject.put("total", flivecount);
             resultObject.put("total", flivecount);

+ 27 - 1
src/dsb/com/cnd3b/service/GetPolyvAnalysisData.java

@@ -1,7 +1,9 @@
 package com.cnd3b.service;
 package com.cnd3b.service;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.BaseClass;
 import com.cnd3b.common.BaseClass;
+import com.cnd3b.common.data.Row;
 import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.RowsMap;
 import com.cnd3b.common.data.RowsMap;
 import com.cnd3b.common.data.SQLFactory;
 import com.cnd3b.common.data.SQLFactory;
@@ -23,6 +25,7 @@ public class GetPolyvAnalysisData extends BaseClass implements Runnable {
     public void run() {
     public void run() {
         if (new SQLiteJDBC().checkServicesUsed("GetPolyvAnalysisData", false)) {
         if (new SQLiteJDBC().checkServicesUsed("GetPolyvAnalysisData", false)) {
             try {
             try {
+                checkChannelids();
                 getLiveStatusAndCoverImageUrl();
                 getLiveStatusAndCoverImageUrl();
             } catch (Exception e) {
             } catch (Exception e) {
                 e.printStackTrace();
                 e.printStackTrace();
@@ -35,12 +38,35 @@ public class GetPolyvAnalysisData extends BaseClass implements Runnable {
         }
         }
     }
     }
 
 
+    /**
+     * ¼ì²éƵµÀºÅ
+     */
+    public void checkChannelids() {
+        Polyv polyv = new Polyv();
+        JSONArray channelids = polyv.getChannelids();
+        if (channelids != null) {
+            ArrayList<String> list = new ArrayList<>();
+            for (Object o : channelids) {
+                list.add(String.valueOf(o));
+            }
+            DBConnect dbConnect = new DBConnect();
+            Rows channelRows = dbConnect.runSqlQuery("select channelid from tlive");
+            for (Row row : channelRows) {
+                String channelid = row.getString("channelid");
+                if (!list.contains(channelid)) {
+                    System.err.println(channelid);
+                    dbConnect.runSqlUpdate("update tlive set livestatus='deleted' where channelid='" + channelid + "'");
+                }
+            }
+        }
+    }
+
     /**
     /**
      * ͬ²½ÆµµÀÖ±²¥×´Ì¬,¼°»ñȡֱ²¥·âÃæÍ¼
      * ͬ²½ÆµµÀÖ±²¥×´Ì¬,¼°»ñȡֱ²¥·âÃæÍ¼
      */
      */
     public void getLiveStatusAndCoverImageUrl() {
     public void getLiveStatusAndCoverImageUrl() {
         DBConnect dbConnect = new DBConnect();
         DBConnect dbConnect = new DBConnect();
-        Rows channelRows = dbConnect.runSqlQuery("select channelid,livestatus,tagentsid,siteid from tlive");
+        Rows channelRows = dbConnect.runSqlQuery("select channelid,livestatus,tagentsid,siteid from tlive where livestatus!='deleted'");
         String[] channelids = channelRows.toArray("channelid");
         String[] channelids = channelRows.toArray("channelid");
         RowsMap map = channelRows.toRowsMap("channelid");
         RowsMap map = channelRows.toRowsMap("channelid");
         Polyv polyv = new Polyv();
         Polyv polyv = new Polyv();

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

@@ -597,4 +597,30 @@ public class Polyv extends BaseClass {
         return categoryMap;
         return categoryMap;
     }
     }
 
 
+    public JSONArray getChannelids() {
+        //公共参数,填写自己的实际
+        try {
+            String timestamp = String.valueOf(System.currentTimeMillis());
+            //业务参数
+            String url = "http://api.polyv.net/live/v3/user/channels";
+            // String categoryId = "340019";
+            //String keyword = "讨论";
+
+            //http 调用逻辑
+            Map<String, String> requestMap = new HashMap<>();
+            requestMap.put("appId", appid);
+            requestMap.put("timestamp", timestamp);
+            /// requestMap.put("categoryId", categoryId);
+            // requestMap.put("keyword", keyword);
+            requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
+            String response = HttpUtil.get(url, requestMap, null);
+            JSONObject object = JSONObject.parseObject(response);
+            if ("success".equalsIgnoreCase(object.getString("status"))) {
+                return object.getJSONObject("data").getJSONArray("channels");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 }
 }