| | |
| | | package safeluck.drive.evaluation; |
| | | |
| | | import android.app.Application; |
| | | import android.text.TextUtils; |
| | | import android.widget.Toast; |
| | | |
| | | |
| | |
| | | import com.anyun.exam.lib.crash.CrashHandler; |
| | | import com.facebook.stetho.Stetho; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonArray; |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.JsonParser; |
| | | |
| | | |
| | | import org.json.JSONException; |
| | |
| | | import safeluck.drive.evaluation.DB.failitems.FailedProjRepository; |
| | | import safeluck.drive.evaluation.DB.rtktb.RTKConfig; |
| | | import safeluck.drive.evaluation.DB.rtktb.RTKWorkRepository; |
| | | import safeluck.drive.evaluation.cEventCenter.CEvent; |
| | | import safeluck.drive.evaluation.cEventCenter.CEventCenter; |
| | | import safeluck.drive.evaluation.util.FileUtil; |
| | | import safeluck.drive.evaluation.util.SystemUtil; |
| | | |
| | |
| | | Stetho.initializeWithDefaults(this); |
| | | |
| | | |
| | | //RTK配置信息 |
| | | // rtkConfig = new RTKConfig(); |
| | | // rtkConfig.setCity(12); |
| | | // rtkConfig.setImei("460123874561"); |
| | | // rtkConfig.setInterval(1); |
| | | // rtkConfig.setIp("47.93.80.84"); |
| | | // rtkConfig.setModel("123"); |
| | | // rtkConfig.setPhone("2019101500000001"); |
| | | // rtkConfig.setPort(12125); |
| | | // rtkConfig.setProvince(23); |
| | | // rtkConfig.setSn("2019101500000001"); |
| | | |
| | | //数据库操作 |
| | | MyLog.i(TAG, "onCreate111"); |
| | | failedProjRepository = new FailedProjRepository(this); |
| | |
| | | MyLog.d(TAG, String.format("收到命令[%d],Json内容为%s", cmd, json)); |
| | | switch (cmd) { |
| | | case Constant.NDK_START: |
| | | Toast.makeText(this, "NDK start", Toast.LENGTH_SHORT).show(); |
| | | |
| | | break; |
| | | case Constant.RTK_PLATFORM_REGISTER_STATUS: |
| | | //RTK平台注册状态,需要保存数据库 |
| | | CEventCenter.dispatchEvent(Constant.BIND_CONNECT_RTK_TOPIC,cmd,0,json); |
| | | |
| | | failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd + random.nextInt(26), Constant.TEST_STU_ID)); |
| | | rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); |
| | | |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(json); |
| | | String rtkLoginPwd = jsonObject.getString("password"); |
| | | int reg_code = jsonObject.getInt("register_code"); |
| | | rtkConfig.setPassword(rtkLoginPwd); |
| | | rtkConfig.setRegistered(reg_code); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | rtkWorkRepository.insertRTKConfig(rtkConfig); |
| | | break; |
| | | case Constant.RTK_PLATFORM_REGISTER_RESULT: |
| | | |
| | | failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd + random.nextInt(26), Constant.TEST_STU_ID)); |
| | | |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(json); |
| | | int rtklogincode = jsonObject.getInt("login_code"); |
| | | rtkConfig.setRegistered(rtklogincode); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //RTK平台登录结果 |
| | | CEventCenter.dispatchEvent(Constant.BIND_CONNECT_RTK_TOPIC,cmd,0,json); |
| | | |
| | | |
| | | break; |
| | | case Constant.FETCH_RTK_PLATFORM_INFO: |
| | | rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); |
| | | if (gson == null) { |
| | | gson = new Gson(); |
| | | } |
| | | if (rtkConfig==null){ |
| | | |
| | | rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); |
| | | } |
| | | if (rtkConfig != null){ |
| | | String rtkjson = gson.toJson(rtkConfig); |
| | | MyLog.i(TAG, "RTK配置信息:" + rtkjson); |
| | | |
| | | //去除id字段 |
| | | JSONObject jsonObject = null; |
| | | try { |
| | | jsonObject = new JSONObject(rtkjson); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | jsonObject.remove("_id"); |
| | | rtkjson = null; |
| | | rtkjson = jsonObject.toString(); |
| | | MyLog.i(TAG, "RTK配置信息:" + rtkjson); |
| | | AYSdk.getInstance().sendCmd(Constant.PUSH_RTK_PLATFORM_INFO, rtkjson); |
| | | } |
| | | |
| | | CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,cmd,0,""); |
| | | break; |
| | | case Constant.JUDGE_INFO: |
| | | |
| | | if(!TextUtils.isEmpty(json)){ |
| | | JsonArray jsonArray = JsonParser.parseString(json).getAsJsonArray(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JsonObject jsonObject = jsonArray.get(i).getAsJsonObject(); |
| | | int emp_id = jsonObject.get("wrong_id").getAsInt(); |
| | | |
| | | failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd, Constant.TEST_STU_ID)); |
| | | failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, emp_id, Constant.TEST_STU_ID)); |
| | | } |
| | | } |
| | | |
| | | break; |
| | | case Constant.EXAM_STATUS_REPLY: |
| | |
| | | failedProjRepository.deleteAll(); |
| | | break; |
| | | case Constant.RTK_PLATFORM_CONNECT_STATUS: |
| | | rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); |
| | | |
| | | try { |
| | | JSONObject jsonObject3 = new JSONObject(json); |
| | | String ip = jsonObject3.getString("ip"); |
| | | int port = jsonObject3.getInt("port"); |
| | | int reg_code = jsonObject3.getInt("connected"); |
| | | rtkConfig.setRegistered(reg_code); |
| | | rtkConfig.setIp(ip); |
| | | rtkConfig.setPort(port); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | rtkWorkRepository.insertRTKConfig(rtkConfig); |
| | | CEventCenter.dispatchEvent(Constant.BIND_CONNECT_RTK_TOPIC,cmd,0,json); |
| | | break; |
| | | case Constant.FETCH_MAP_INFO: |
| | | |