Prechádzať zdrojové kódy

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

沈静伟 3 rokov pred
rodič
commit
9521b9e084

+ 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.Method;
 import java.sql.Connection;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 public class Controller extends BaseClass {
@@ -533,15 +535,15 @@ public class Controller extends BaseClass {
      */
     public String getHeadPic(long 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, "");
     }
@@ -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)) {
             JSONObject methodobject = new JSONObject();
             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) {
         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();
+    }
+
+
 }

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

@@ -19,9 +19,11 @@ public class live extends Controller {
      * @return
      */
     public String getLiveChannelData() {
+
+
         String tactivityid = content.getString("tactivityid");
         String saleprodclass = content.getString("saleprodclass");
-        if(saleprodclass==null){
+        if (saleprodclass == null) {
             saleprodclass = "";
         }
         JSONObject resultObject = new JSONObject();
@@ -42,7 +44,7 @@ public class live extends Controller {
         SQLFactory livecustcount = new SQLFactory(this, "当前线上观众人数查询");
         livecustcount.addParameter("tactivityid", tactivityid);
         livecustcount.addParameter("siteid", siteid);
-        livecustcount.addParameter("saleprodclass","%"+saleprodclass+"%");
+        livecustcount.addParameter("saleprodclass", "%" + saleprodclass + "%");
         Rows liverows = dbConnect.runSqlQuery(livecustcount.getSQL());
 
         String sql = livecustcount.getSQL();
@@ -56,7 +58,7 @@ public class live extends Controller {
         resultObject.put("flivecount", flivecount);
         //当前在线观众人数
         resultObject.put("fcustcount", liverows.isEmpty() ? 0 : liverows.sum("fcustcount"));
-        for(Row row:liverows){
+        for (Row row : liverows) {
             //观看次数(次)
             String channelid = row.getString("channelid");
             //观看人数(人)
@@ -82,7 +84,21 @@ public class live extends Controller {
                     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("pageNumber", pageNumber);
             resultObject.put("total", flivecount);