增加正则判断一个字符串是否全为数字;不再TTSWorker里面执行插入数据库操作和语音播报工作;训练模式和考试模式评判信息按时间排序;收到评判消息在线程里面进行语音播报和数据库操作
| | |
| | | } else { |
| | | MyLog.i("读取Assert目录下初始化的地图") |
| | | var buffer: StringBuffer? |
| | | // buffer = FileUtil.readAssetTxtFile(applicationContext, safeluck.drive.evaluation.Constant.ROAD_MAP) |
| | | // if (buffer != null) { |
| | | // AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_ROAD_MAP_INFO, buffer.toString()) |
| | | // } else { |
| | | // MyLog.i( String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName)) |
| | | // CThreadPoolExecutor.runOnMainThread { Toast.makeText(app.getAppContext(), String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName), Toast.LENGTH_SHORT).show() } |
| | | // } |
| | | buffer = FileUtil.readAssetTxtFile(applicationContext, safeluck.drive.evaluation.Constant.ROAD_MAP) |
| | | if (buffer != null) { |
| | | AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_ROAD_MAP_INFO, buffer.toString()) |
| | | } else { |
| | | MyLog.i( String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName)) |
| | | CThreadPoolExecutor.runOnMainThread { Toast.makeText(app.getAppContext(), String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName), Toast.LENGTH_SHORT).show() } |
| | | } |
| | | buffer = FileUtil.readAssetTxtFile(applicationContext, safeluck.drive.evaluation.Constant.MAP) |
| | | if (buffer != null) { |
| | | AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_MAP_INFO, buffer.toString()) |
| | |
| | | |
| | | if(!TextUtils.isEmpty(json)){ |
| | | Data judgeData = new Data.Builder().putString(Constant.TTS,json).build(); |
| | | JsonArray jsonArray = (JsonArray) JsonParser.parseString(json); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JsonObject jsonObject = jsonArray.get(i).getAsJsonObject(); |
| | | int emp_id = jsonObject.get("wrong_id").getAsInt(); |
| | | if (emp_id>1000){ |
| | | CriteriaForIII ttsStr=WorkRoomDataBase.getWorkRoomDataBase(this).getCriteriaIIIDao().queryItemForCriteriaIIINoLive(emp_id-1000); |
| | | ExamPlatformData.getInstance().getTTS().speak(ttsStr.getDeducting_reason() + (ttsStr.getScore_deducting() == 100? "不合格" : "扣" + |
| | | ttsStr.getScore_deducting() + "分")); |
| | | }else{ |
| | | CriteriaForI ttsStr = WorkRoomDataBase.getWorkRoomDataBase(this).getCriteriaIDao().queryItemForCriteriaINoLive(emp_id); |
| | | ExamPlatformData.getInstance().getTTS().speak(ttsStr.getDeducting_reason() + (ttsStr.getScore_deducting() == 100? "不合格" : "扣" + |
| | | ttsStr.getScore_deducting() + "分")); |
| | | } |
| | | |
| | | } |
| | | final JsonArray jsonArray = (JsonArray) JsonParser.parseString(json); |
| | | |
| | | OneTimeWorkRequest ttswoker = new OneTimeWorkRequest.Builder(TTSWorker.class).setInputData(judgeData).build(); |
| | | WorkManager.getInstance(getAppContext()).enqueue(ttswoker); |
| | | |
| | | CThreadPoolExecutor.runInBackground(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JsonObject jsonObject = jsonArray.get(i).getAsJsonObject(); |
| | | int emp_id = jsonObject.get("wrong_id").getAsInt(); |
| | | String utc = jsonObject.get("utc").getAsString(); |
| | | int sn = jsonObject.get("sn").getAsInt(); |
| | | if (emp_id>1000){ |
| | | CriteriaForIII ttsStr=WorkRoomDataBase.getWorkRoomDataBase(getAppContext()).getCriteriaIIIDao().queryItemForCriteriaIIINoLive(emp_id-1000); |
| | | ExamPlatformData.getInstance().getTTS().speak(ttsStr.getDeducting_reason() + (ttsStr.getScore_deducting() == 100? "不合格" : "扣" + |
| | | ttsStr.getScore_deducting() + "分")); |
| | | }else{ |
| | | CriteriaForI ttsStr = WorkRoomDataBase.getWorkRoomDataBase(getAppContext()).getCriteriaIDao().queryItemForCriteriaINoLive(emp_id); |
| | | ExamPlatformData.getInstance().getTTS().speak(ttsStr.getDeducting_reason() + (ttsStr.getScore_deducting() == 100? "不合格" : "扣" + |
| | | ttsStr.getScore_deducting() + "分")); |
| | | } |
| | | |
| | | if (emp_id<1000) { //场地评判消息 |
| | | if (emp_id > 31 || emp_id < 0) { |
| | | MyLog.i("emp_id超出范围不能插入数据库(I类考场)"); |
| | | |
| | | }else{ |
| | | FailedProj failedProj = new FailedProj(Constant.SUBJECT_I, emp_id, Constant.TEST_STU_ID, utc, sn); |
| | | MyLog.i("插入fail_projects表=$failedProj"); |
| | | WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getFailProjDao().insert(failedProj); |
| | | } |
| | | |
| | | } |
| | | if (emp_id>1000) { //道路 评判消息 |
| | | |
| | | if (emp_id >1066 || emp_id < 1000) { |
| | | MyLog.i("emp_id超出范围不能插入数据库(路考类考场)"); |
| | | }else{ |
| | | LuKaoFailedProj failedProj = new LuKaoFailedProj(Constant.SUBJECT_III, (emp_id-1000), Constant.TEST_STU_ID, utc, sn); |
| | | MyLog.i("插入路考fail_projects表=$failedProj"); |
| | | WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getLuKaoFailProjDao().insert(failedProj); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | }); |
| | | StringBuffer buffer; |
| | | // buffer =FileUtil.readAssetTxtFile(getApplicationContext(),Constant.ROAD_MAP); |
| | | // if (buffer != null){ |
| | | // |
| | | // AYSdk.getInstance().sendCmd(Constant.PUSH_ROAD_MAP_INFO,buffer.toString()); |
| | | // }else{ |
| | | // MyLog.d(TAG,String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName())); |
| | | // CThreadPoolExecutor.runOnMainThread(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // Toast.makeText(getAppContext(), String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName()), Toast.LENGTH_SHORT).show(); |
| | | // } |
| | | // }); |
| | | // |
| | | // } |
| | | buffer =FileUtil.readAssetTxtFile(getApplicationContext(),Constant.ROAD_MAP); |
| | | if (buffer != null){ |
| | | |
| | | AYSdk.getInstance().sendCmd(Constant.PUSH_ROAD_MAP_INFO,buffer.toString()); |
| | | }else{ |
| | | MyLog.d(TAG,String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName())); |
| | | CThreadPoolExecutor.runOnMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Toast.makeText(getAppContext(), String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName()), Toast.LENGTH_SHORT).show(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | buffer =FileUtil.readAssetTxtFile(getApplicationContext(),Constant.MAP); |
| | | if (buffer != null){ |
| | | |
| | |
| | | package safeluck.drive.evaluation.bean; |
| | | |
| | | import com.anyun.exam.lib.MyLog; |
| | | |
| | | import safeluck.drive.evaluation.util.Utils; |
| | | |
| | | /** |
| | | * MyApplication2 |
| | | * Created by lzw on 2019/3/19. 14:17:11 |
| | | * 邮箱:632393724@qq.com |
| | | * All Rights Saved! Chongqing AnYun Tech co. LTD |
| | | */ |
| | | public class ScoreBean { |
| | | public class ScoreBean implements Comparable<ScoreBean>{ |
| | | /**扣分分数*/ |
| | | private float mScore; |
| | | /**扣分项目*/ |
| | |
| | | /**扣分原因*/ |
| | | private String reason; |
| | | |
| | | private long mUtc; |
| | | |
| | | |
| | | public ScoreBean(float mScore, String mItem, String reason) { |
| | | this.mScore = mScore; |
| | | this.mItem = mItem; |
| | | this.reason = reason; |
| | | } |
| | | public ScoreBean(float mScore, String mItem, String reason,String utc) { |
| | | this.mScore = mScore; |
| | | this.mItem = mItem; |
| | | this.reason = reason; |
| | | if (Utils.isDigital(utc)){ |
| | | MyLog.i("utc时间不是纯数字"); |
| | | }else{ |
| | | |
| | | |
| | | mUtc = Utils.dateToLongSec(utc); |
| | | } |
| | | } |
| | | |
| | | public long getUtc() { |
| | | return mUtc; |
| | | } |
| | | |
| | | |
| | | |
| | | public float getScore() { |
| | | return mScore; |
| | |
| | | public void setReason(String reason) { |
| | | this.reason = reason; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int compareTo(ScoreBean o) { |
| | | if (this.mUtc>o.getUtc()){ |
| | | return -1; |
| | | }else if (this.mUtc==o.getUtc()){ |
| | | return 0; |
| | | }else{ |
| | | return 1; |
| | | } |
| | | } |
| | | } |
| | |
| | | import safeluck.drive.evaluation.im.MessageProcessor; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0201; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0202; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0203; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0204; |
| | | import safeluck.drive.evaluation.util.Utils; |
| | | import safeluck.drive.evaluation.viewmodels.TimeViewModel; |
| | |
| | | failedProj_selects) { |
| | | item_id += f.getScore_deducting(); |
| | | Log.i(TAG, "onChanged: " + f.toString()); |
| | | mArrayList.add(new ScoreBean(f.getScore_deducting(), f.getItem_content(), f.getDeducting_reason())); |
| | | mArrayList.add(new ScoreBean(f.getScore_deducting(), f.getItem_content(), f.getDeducting_reason(),f.getUtc())); |
| | | item_conents.add(f.getItem_content()); |
| | | Collections.reverse(mArrayList); |
| | | Collections.sort(mArrayList); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | MyLog.i("item_score="+item_id); |
| | | } |
| | |
| | | item_id = 0; |
| | | mArrayList.clear(); |
| | | item_conents.clear(); |
| | | Collections.reverse(mArrayList); |
| | | Collections.sort(mArrayList); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | mHandler.obtainMessage(ADD_DATA).sendToTarget(); |
| | | } |
| | |
| | | failedProj_selects) { |
| | | item_id += f.getScore_deducting(); |
| | | Log.i(TAG, "onChanged: " + f.toString()); |
| | | mArrayList.add(new ScoreBean(f.getScore_deducting(), f.getItem_content(), f.getDeducting_reason())); |
| | | mArrayList.add(new ScoreBean(f.getScore_deducting(), f.getItem_content(), f.getDeducting_reason(),f.getUtc())); |
| | | item_conents.add(f.getItem_content()); |
| | | Collections.reverse(mArrayList); |
| | | Collections.sort(mArrayList); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | MyLog.i("item_score="+item_id); |
| | | } |
| | |
| | | item_id = 0; |
| | | mArrayList.clear(); |
| | | item_conents.clear(); |
| | | Collections.reverse(mArrayList); |
| | | Collections.sort(mArrayList); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | mHandler.obtainMessage(ADD_DATA).sendToTarget(); |
| | | } |
| | |
| | | package safeluck.drive.evaluation.fragment; |
| | | |
| | | import android.app.AlarmManager; |
| | | import android.app.PendingIntent; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Bundle; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.core.app.AlarmManagerCompat; |
| | | import androidx.lifecycle.Observer; |
| | | import androidx.lifecycle.ViewModelProviders; |
| | | import androidx.work.OneTimeWorkRequest; |
| | | import androidx.work.PeriodicWorkRequest; |
| | | import androidx.work.WorkInfo; |
| | | import androidx.work.WorkManager; |
| | | |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | | import android.os.SystemClock; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import me.yokeyword.fragmentation.SupportFragment; |
| | | import safeluck.drive.evaluation.Constant; |
| | |
| | | import safeluck.drive.evaluation.im.MessageProcessor; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0201; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0202; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0203; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0204; |
| | | import safeluck.drive.evaluation.util.Utils; |
| | | import safeluck.drive.evaluation.viewmodels.TimeViewModel; |
| | | import safeluck.drive.evaluation.worker.TimeWorker; |
| | | |
| | | import static androidx.work.PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS; |
| | | |
| | | /**单机训练UI |
| | | * MyApplication2 |
| | |
| | | failedProj_selects) { |
| | | item_id += f.getScore_deducting(); |
| | | Log.i(TAG, "onChanged: " + f.toString()); |
| | | mArrayList.add(new ScoreBean(f.getScore_deducting(), f.getItem_content(), f.getDeducting_reason())); |
| | | mArrayList.add(new ScoreBean(f.getScore_deducting(), f.getItem_content(), f.getDeducting_reason(),f.getUtc())); |
| | | item_conents.add(f.getItem_content()); |
| | | Collections.reverse(mArrayList); |
| | | Collections.sort(mArrayList); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | MyLog.i("item_score="+item_id); |
| | | } |
| | |
| | | item_id = 0; |
| | | mArrayList.clear(); |
| | | item_conents.clear(); |
| | | Collections.reverse(mArrayList); |
| | | Collections.sort(mArrayList); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | mHandler.obtainMessage(ADD_DATA).sendToTarget(); |
| | | } |
| | |
| | | failedProj_selects) { |
| | | item_id += f.getScore_deducting(); |
| | | Log.i(TAG, "onChanged: " + f.toString()); |
| | | mArrayList.add(new ScoreBean(f.getScore_deducting(), f.getItem_content(), f.getDeducting_reason())); |
| | | mArrayList.add(new ScoreBean(f.getScore_deducting(), f.getItem_content(), f.getDeducting_reason(),f.getUtc())); |
| | | item_conents.add(f.getItem_content()); |
| | | Collections.reverse(mArrayList); |
| | | Collections.sort(mArrayList); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | MyLog.i("item_score="+item_id); |
| | | } |
| | |
| | | item_id = 0; |
| | | mArrayList.clear(); |
| | | item_conents.clear(); |
| | | Collections.reverse(mArrayList); |
| | | Collections.sort(mArrayList); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | mHandler.obtainMessage(ADD_DATA).sendToTarget(); |
| | | } |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.security.SecureRandom; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Calendar; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.SecretKey; |
| | |
| | | return temp; |
| | | } |
| | | |
| | | public static boolean isDigital(String str) { |
| | | String regx= "^\\d+"; |
| | | return str.matches(regx); |
| | | } |
| | | // public static boolean isDigital(String str) { |
| | | // String regx= "^\\d+"; |
| | | // return str.matches(regx); |
| | | // } |
| | | |
| | | // public static void main(String []args){ |
| | | // String str = "EB00020000031420010000000400A5"; |
| | |
| | | Point p1 = new Point(2.55,1.0); |
| | | Point p2 = new Point(1.55,1.0); |
| | | System.out.println(Calc3Point(p1,p2,1.0).toString()); |
| | | System.out.println( isDigital("2003233d")); |
| | | System.out.println( isDigital("d2003233")); |
| | | System.out.println( dateToLongSec("20200330101455")); |
| | | |
| | | |
| | | |
| | | ; |
| | | } |
| | | |
| | | public static Point Calc3Point(Point p1,Point p2,double L ){ |
| | |
| | | |
| | | return simpleDateFormat.format(begin_time); |
| | | } |
| | | |
| | | public static boolean isDigital(String str){ |
| | | String regx = "^[0-9]*$"; |
| | | Pattern pattern = Pattern.compile(regx); |
| | | Matcher matcher = pattern.matcher(str); |
| | | return matcher.matches(); |
| | | } |
| | | |
| | | public static long dateToLongSec(String utc) { |
| | | |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | Date date = null; |
| | | try { |
| | | date = simpleDateFormat.parse(utc); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return date.getTime()/1000; |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | if (emp_id<1000) { //场地评判消息 |
| | | if (emp_id > 31 || emp_id < 0) { |
| | | MyLog.i("emp_id超出范围不能插入数据库(I类考场)") |
| | | |
| | | }else{ |
| | | val failedProj = FailedProj(Constant.SUBJECT_I, emp_id, Constant.TEST_STU_ID, utc, sn) |
| | | MyLog.i("插入fail_projects表=$failedProj") |
| | | WorkRoomDataBase.getWorkRoomDataBase(applicationContext).failProjDao.insert(failedProj) |
| | | } |
| | | |
| | | } |
| | | if (emp_id>1000) { //道路 评判消息 |
| | | |
| | | if (emp_id >1066 || emp_id < 1000) { |
| | | MyLog.i("emp_id超出范围不能插入数据库(路考类考场)") |
| | | }else{ |
| | | val failedProj = LuKaoFailedProj(Constant.SUBJECT_III, (emp_id-1000), Constant.TEST_STU_ID, utc, sn) |
| | | MyLog.i("插入路考fail_projects表=$failedProj") |
| | | WorkRoomDataBase.getWorkRoomDataBase(applicationContext).luKaoFailProjDao.insert(failedProj) |
| | | } |
| | | |
| | | } |
| | | // if (emp_id<1000) { //场地评判消息 |
| | | // if (emp_id > 31 || emp_id < 0) { |
| | | // MyLog.i("emp_id超出范围不能插入数据库(I类考场)") |
| | | // |
| | | // }else{ |
| | | // val failedProj = FailedProj(Constant.SUBJECT_I, emp_id, Constant.TEST_STU_ID, utc, sn) |
| | | // MyLog.i("插入fail_projects表=$failedProj") |
| | | // WorkRoomDataBase.getWorkRoomDataBase(applicationContext).failProjDao.insert(failedProj) |
| | | // } |
| | | // |
| | | // } |
| | | // if (emp_id>1000) { //道路 评判消息 |
| | | // |
| | | // if (emp_id >1066 || emp_id < 1000) { |
| | | // MyLog.i("emp_id超出范围不能插入数据库(路考类考场)") |
| | | // }else{ |
| | | // val failedProj = LuKaoFailedProj(Constant.SUBJECT_III, (emp_id-1000), Constant.TEST_STU_ID, utc, sn) |
| | | // MyLog.i("插入路考fail_projects表=$failedProj") |
| | | // WorkRoomDataBase.getWorkRoomDataBase(applicationContext).luKaoFailProjDao.insert(failedProj) |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | |
| | | } |