From 2f3e3ec2c0cad87eab8a6d170caffc06a4e11c2d Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期四, 07 十一月 2019 09:55:24 +0800
Subject: [PATCH] set getData 1 sec and add day task

---
 src/main/java/com/cloud/count/listener/CountThread.java |   43 +++++++++----------------------------------
 1 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/src/main/java/com/cloud/count/listener/CountThread.java b/src/main/java/com/cloud/count/listener/CountThread.java
index abd3000..2cabd09 100644
--- a/src/main/java/com/cloud/count/listener/CountThread.java
+++ b/src/main/java/com/cloud/count/listener/CountThread.java
@@ -14,7 +14,7 @@
 
 public class CountThread implements Runnable {
     private Logger logger = LoggerFactory.getLogger(this.getClass());
-    static boolean isServerReboot = false;
+
 
     private CountDao dao;
 
@@ -36,15 +36,16 @@
         try{
             iReader = new BufferedReader(new InputStreamReader(client.getInputStream(), encoding));
             iWriter = new BufferedWriter(new OutputStreamWriter(client.getOutputStream(), encoding));
-
+            String msgStr = "";
+            String xmlStr = "";
+            People people = null;
             while (true) {
-                String str = iReader.readLine();
+                msgStr = iReader.readLine();
                 sendAck(iWriter);
 
-                String xmlStr = XmlUtil.toXmlStr(str);
+                xmlStr = XmlUtil.toXmlStr(msgStr);
 
                 // 濡傛灉瀛樺湪TotalEnters銆傚垯璇佹槑杩斿洖鐨勬槸瀹炴椂鏁版嵁鐨剎ml
-                People people = null;
                 if(xmlStr.indexOf("TotalEnters")>-1){
                     people = XmlUtil.realTimeXmlToPeople(xmlStr);
                     int inCreEnter = CountServiceImpl.addEnter(people.getEnters());//杩涘叆浜烘暟澧為噺
@@ -55,36 +56,12 @@
                     people.setEnters(CountServiceImpl.totalEnters);//灏嗙疮鍔犲悗鐨勬暟閲忓瓨鍒版暟鎹簱涓�
                     people.setExits(CountServiceImpl.totalExits);
                     boolean resultB = dao.savePeople(people);
-                    System.out.println("totalEnters:"+CountServiceImpl.totalEnters);
 
                     //鎬昏繘鍏ユ暟閲忔垨鑰呮�诲嚭鍘绘暟閲忥紝涓嶄竴瀹氬摢涓�涓厛鍒�2瀛楄妭int鐨勪笂闄�65535
 //                                if( CountServiceImpl.totalEnters < CountServiceImpl.baseEnters){
 //                                    //琛ㄧず缁熻璁惧閲嶆柊鍚姩浜�,缁熻鍙傛暟褰掗浂
 //                                    CountServiceImpl.initCountArgs(people);
 //                                }
-                    op: if(!isServerReboot){
-                        isServerReboot = true;
-                        CountState state = dao.getCountState();//鎭㈠缁熻鐘舵��
-                        Date nowDate = new Date();
-                        Date BaseDate = new Date(state.getBaseTime()*1000L);
-                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-                        if(!sdf.format(nowDate).equals(sdf.format(BaseDate))){//鍘嗗彶鏁版嵁涓嶇瓑浜庡綋澶�
-                            CountServiceImpl.baseEnters  = people.getEnters();
-                            CountServiceImpl.baseExits = people.getExits();
-                            CountServiceImpl.realtimeBaseEnters = people.getEnters();
-                            CountServiceImpl.realtimebBaseExits =  people.getExits();
-                            CountServiceImpl.errorCount = 0;
-                            break op;
-                        }
-                        //杩樺師鐘舵��
-                        CountServiceImpl.baseEnters  = state.getBaseEnters();
-                        CountServiceImpl.baseExits = state.getBaseExits();
-                        CountServiceImpl.totalEnters = state.getTotalEnters();
-                        CountServiceImpl.totalExits = state.getTotalExits();
-                        CountServiceImpl.realtimeBaseEnters = state.getRealtimeBaseEnters();
-                        CountServiceImpl.realtimebBaseExits = state.getRealtimeBaseExits();
-                        CountServiceImpl.errorCount = state.getErrorCount();
-                    }
 
                     //鎬昏繘鍏ヤ汉鏁板皬浜庢�诲嚭鍘荤殑浜烘暟锛岃〃绀虹粺璁¤澶囧湪鏀惧鏃堕棿锛堝嚭鍘荤殑浜烘暟澶т簬杩涘叆鐨勪汉鏁帮級閲嶅惎浜�
                     if(CountServiceImpl.totalEnters < CountServiceImpl.totalExits){
@@ -112,8 +89,6 @@
                 }
             }
 
-        }catch (IOException ex){
-
         }catch (Exception e){
             System.out.println("exception:"+e.getMessage());
         }
@@ -135,13 +110,13 @@
     public static void sendAck(BufferedWriter iWriter) {
         String statusLine = "HTTP/1.0 200 OK"+CRLF;
         String contentTypeLine = "Content-type: text/html"+CRLF ;
-        String connectionClose = "Connection: Keep-Alive"+CRLF ;
-        String contentLengthLine = "Content-Length: 0"+CRLF +CRLF;;
+        String connectionAlive = "Connection: Keep-Alive"+CRLF ;
+        String contentLengthLine = "Content-Length: 0"+CRLF +CRLF;
 
         try {
             iWriter.write(statusLine);
             iWriter.write(contentTypeLine);
-            iWriter.write(connectionClose);
+            iWriter.write(connectionAlive);
             iWriter.write(contentLengthLine);
             iWriter.flush();
         } catch (IOException ex) {

--
Gitblit v1.8.0