Browse Source

修改bug

shilin 4 years ago
parent
commit
c0bf7910a7

+ 1 - 1
app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt

@@ -1,4 +1,4 @@
-#Tue Oct 13 10:54:13 CST 2020
+#Tue Oct 13 16:09:48 CST 2020
 path.1=classes.dex
 path.0=classes.dex
 renamed.6=classes7.dex

BIN
app/build/intermediates/transforms/dexBuilder/debug/100.jar


BIN
app/build/intermediates/transforms/dexBuilder/debug/101.jar


BIN
app/build/intermediates/transforms/dexBuilder/debug/102.jar


BIN
app/build/intermediates/transforms/dexBuilder/debug/99.jar


File diff suppressed because it is too large
+ 1 - 1
app/build/intermediates/transforms/dexBuilder/debug/__content__.json


BIN
app/build/outputs/apk/debug/智慧新能源.apk


+ 15 - 0
uniplugin_module/src/main/java/com/sxr/sdk/ble/keepfit/client/GyeeActivity.java

@@ -356,6 +356,7 @@ public class GyeeActivity extends Activity {
      */
     @OnClick(R2.id.bt_close_blood)
     void eventDeviceCloseBlood() {
+        Log.e("=======measure", "测量关闭");
         restBinder.callRemoteOpenBlood(false);
     }
 
@@ -558,6 +559,20 @@ public class GyeeActivity extends Activity {
         timer.schedule(task,60*1000,60*1000);
     }
 
+    /**
+     * 控制测量频率
+     */
+    private void timerMeasure(){
+//        TimerTask measure = new TimerTask() {
+//            @Override
+//            public void run() {
+//                Log.e("=======measure", "测量启动");
+//                restBinder.callRemoteOpenBlood(true);
+//            }
+//        };
+//        timer.schedule(measure,0,5 * 60*1000);
+    }
+
 //    //申请两个权限,录音和文件读写
 //    //1、首先声明一个数组permissions,将需要的权限都放在里面
 //    String[] permissions = new String[]{

+ 33 - 0
uniplugin_module/src/main/java/com/sxr/sdk/ble/keepfit/client/RestService.java

@@ -70,6 +70,39 @@ public class RestService {
             jsonObject.put("szxy", reportData.getSzxy());
             jsonObject.put("xtpl", reportData.getXtpl());
             jsonObject.put("xynd", reportData.getXynd());
+
+            StringEntity entity = new StringEntity(jsonObject.toString(), HTTP.UTF_8);
+
+            entity.setContentType("application/json");
+
+            // URL使用基本URL即可,其中不需要加参数
+            HttpPost httpPost = new HttpPost(url);
+            // 将请求体内容加入请求中
+
+            httpPost.setEntity(entity);
+
+            HttpClient httpClient = new DefaultHttpClient();
+            // 发送请求
+            HttpResponse response = httpClient.execute(httpPost);
+            // 显示响应
+            //showResponseResult(response);
+
+            System.out.println(response.getStatusLine());
+
+
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    public static void  GPSPost(ReportData reportData) {
+        String url = baseURL + "/shbruser/insertBraceletUserInfo";
+        try
+        {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("mobile", reportData.getMobile());
             jsonObject.put("bs", reportData.getBs());
             jsonObject.put("lng", reportData.getLng());
             jsonObject.put("lat", reportData.getLat());

+ 49 - 88
uniplugin_module/src/main/java/com/sxr/sdk/ble/keepfit/service/ReportService.java

@@ -21,6 +21,7 @@ import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
 import android.os.RemoteException;
+import android.text.TextUtils;
 import android.util.Log;
 import android.widget.Toast;
 
@@ -43,6 +44,8 @@ import java.util.Locale;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
+import retrofit2.http.POST;
+
 
 //接口地址:
 //
@@ -112,14 +115,34 @@ public class ReportService extends Service {
     public void onCreate() {
         //TODO 在单纯提高优先级时,服务在关闭APP并关屏的情况下走了30分钟
         super.onCreate();
+        initLocationManager();
+
         //TODO 起一个ScheduledThreadPoolExecutor线程池,无延迟、1分钟执行1次来提高service的优先级,未必好用,聊胜于无
         executor = new ScheduledThreadPoolExecutor(1);
         executor.scheduleAtFixedRate(() -> {
             startForeground(NOTICE_ID, new Notification());
             //TODO 提交改在这里
-            Post();
-        }, 0, 1, TimeUnit.MINUTES);
-        initLocationManager();
+            if (locationManager != null && locationProvider != null && locationProvider != "") {
+                @SuppressLint("MissingPermission")
+                Location location = locationManager.getLastKnownLocation(locationProvider);
+
+                if (location != null) {
+                    reportData.setLat(location.getLatitude() + "");
+                    reportData.setLng(location.getLongitude() + "");
+                }
+            }
+
+//            if (mService != null) {
+//                try {
+//                    int step = mService.getCurSportData();
+//                    if (step > 0)
+//                        reportData.setBs(step + "");
+//                } catch (RemoteException e) {
+//                    e.printStackTrace();
+//                }
+//            }
+            GPSPost();
+        }, 0, 5, TimeUnit.SECONDS);
         startAlarmService();
     }
 
@@ -157,38 +180,18 @@ public class ReportService extends Service {
         }
     }
 
+    /**
+     * 采集手环数据
+     */
     public static void Post() {
-
         RestService.Post(reportData);
+    }
 
-//        String action = "/shbruser/insertBraceletUserInfo";
-//        Log.e("测试", "服务还在");
-
-//        Gson gson = new Gson();
-//        //使用RXJAVA来实现的异步提交的监听,不要单独使用线程来做管理,最起码也得用线程池
-//        new SimpleRequest().post(action, gson.toJson(reportData), new DefaultObserver<ResponseBody>() {
-//            @Override
-//            public void onNext(ResponseBody responseBody) {
-//                try {
-//                    String resultJson = responseBody.string();
-//                    System.out.println("服务器返回值:" + resultJson);
-//                } catch (IOException e) {
-//                    Log.e("SimpleRequest", "获取返回值失败");
-//                    e.printStackTrace();
-//                }
-//            }
-//
-//            @Override
-//            public void onError(Throwable e) {
-//                Log.e("SimpleRequest", "请求失败");
-//                e.printStackTrace();
-//            }
-//
-//            @Override
-//            public void onComplete() {
-//                Log.e("SimpleRequest", "请求完成");
-//            }
-//        });
+    /**
+     * 采集手机数据
+     */
+    public static void GPSPost() {
+        RestService.GPSPost(reportData);
     }
 
     @Override
@@ -634,14 +637,13 @@ public class ReportService extends Service {
         @Override
         public void onGetCurSportData(int type, long timestamp, int step, int distance,
                                       int cal, int cursleeptime, int totalrunningtime, int steptime) throws RemoteException {
-            Date date = new Date(timestamp * 1000);
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
-            String time = sdf.format(date);
-            showToast("onGetCurSportData", "type : " + type + " , time :" + time + " , step: " + step + ", distance :" + distance + ", cal :" + cal + ", cursleeptime :" + cursleeptime + ", totalrunningtime:" + totalrunningtime);
-
-            if (reportData != null && step > 0)
-                reportData.setBs(step + "");
-
+//            Date date = new Date(timestamp * 1000);
+//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
+//            String time = sdf.format(date);
+//            showToast("onGetCurSportData", "type : " + type + " , time :" + time + " , step: " + step + ", distance :" + distance + ", cal :" + cal + ", cursleeptime :" + cursleeptime + ", totalrunningtime:" + totalrunningtime);
+//            Log.i("========运动数据", "type : " + type + " , time :" + time + " , step: " + step + ", distance :" + distance + ", cal :" + cal + ", cursleeptime :" + cursleeptime + ", totalrunningtime:" + totalrunningtime);
+//            if (reportData != null && step > 0)
+//                reportData.setBs(step + "");
         }
 
         @Override
@@ -750,59 +752,18 @@ public class ReportService extends Service {
         public void onReceiveSensorData(int arg0, int arg1, int arg2, int arg3, int arg4) throws RemoteException {
 //            showToast("======onReceiveSensorData", "result:" + arg0 + " , " + arg1 + " , " + arg2 + " , " + arg3 + " , " + arg4);
             Log.e("=========", "result:" + arg0 + " , " + arg1 + " , " + arg2 + " , " + arg3 + " , " + arg4);
-
-//            reportData.setPld("");
-//            reportData.setSsxy("");
-//            reportData.setSzxy("");
-//            reportData.setXtpl("");
-//            reportData.setXynd("");
-
-            //当手环采集到有效心率血压血氧值后,会通过此命令返回数据给app
-//            void onReceiveSensorData(int heartrate, int Systolicpressure, int Diastolicpressure, int Oxygen, int Fatiguevalue);
-//            heartrate:心率,
-//            Systolicpressure:血压,收缩压
-//            Diastolicpressure:血压,舒张压
-//            Oxygen:血氧
-//            Fatiguevalue:疲劳值
-
-            long ts = new Date().getTime();
-            if (arg0 > 0) {
+            // 采集到数据后写入数据库且关闭测量
+            if (arg0 > 0 && arg1 > 0 && arg2 > 0 && arg3 > 0 && arg4 > 0){
                 reportData.setXtpl(arg0 + "");
-            }
-
-            if (arg1 > 0) {
                 reportData.setSzxy(arg1 + "");
-            }
-
-            if (arg2 > 0) {
                 reportData.setSsxy(arg2 + "");
-            }
-
-            if (arg3 > 0) {
                 reportData.setXynd(arg3 + "");
-            }
-
-            if (arg4 > 0) {
                 reportData.setPld(arg4 + "");
-            }
-
-            if (locationManager != null && locationProvider != null && locationProvider != "") {
-                @SuppressLint("MissingPermission")
-                Location location = locationManager.getLastKnownLocation(locationProvider);
 
-                    if (location != null) {
-                    reportData.setLat(location.getLatitude() + "");
-                    reportData.setLng(location.getLongitude() + "");
-                }
-            }
-
-            if (mService != null) {
-                try {
-                    int step = mService.getCurSportData();
-                    if (step > 0)
-                    reportData.setBs(step + "");
-                } catch (RemoteException e) {
-                    e.printStackTrace();
+                Post();
+                if (restBinder != null){
+                    Log.e("=========", "回调关闭");
+                    restBinder.callRemoteOpenBlood(false);
                 }
             }
         }
@@ -884,7 +845,7 @@ public class ReportService extends Service {
         Intent intent = new Intent();
         intent.setAction("action.STARTEARTBEATTEST");
         pendingIntent = PendingIntent.getBroadcast(this, 100, intent, PendingIntent.FLAG_CANCEL_CURRENT);
-        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 5000, 60000, pendingIntent);
+        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 0, 5 * 60 * 1000, pendingIntent);
 
         showToast("AlarmBroadcastReceiver", "报警服务start!!!!!");