Commit bbc3bf26 by pye52

Merge branch 'fea-cmpt' into develop

# Conflicts:
#	app/build.gradle
#	app/src/main/java/com/bgycc/smartcanteen/RootApp.java
#	app/src/main/java/com/bgycc/smartcanteen/activity/MainActivity.java
#	app/src/main/java/com/bgycc/smartcanteen/entity/PayData.java
#	app/src/main/java/com/bgycc/smartcanteen/qrcode/DefaultQRCodeScan.java
#	app/src/main/java/com/bgycc/smartcanteen/socket/SCWebSocketClient.java
#	app/src/main/java/com/bgycc/smartcanteen/utils/DangerousUtils.java
#	app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOfflineViewModel.java
#	app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOnlineViewModel.java
#	app/src/main/java/com/bgycc/smartcanteen/viewModel/QRCodeViewModel.java
#	build.gradle
#	daemon/build.gradle
#	智慧食堂开发文档.docx
parents 8a3cbba7 4249d8f8
......@@ -53,6 +53,11 @@ android {
buildConfigField "String", "MainWebSocketServerUrl", '"wss://diningservice.bgy.com.cn/websocket/%s/V%s"'
buildConfigField "String", "MainHttpServerHost", '"https://diningback.bgy.com.cn"'
}
pro_cloud {
dimension "smart_canteen"
buildConfigField "String", "MainWebSocketServerUrl", '"wss://diningservice-cloud.bgy.com.cn/websocket/%s/V%s"'
buildConfigField "String", "MainHttpServerHost", '"https://diningback-cloud.bgy.com.cn"'
}
}
signingConfigs {
canteen {
......@@ -97,24 +102,26 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
def room_version = "2.2.5"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
def lifecycle_version = "2.2.0"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "org.java-websocket:Java-WebSocket:1.4.0"
implementation 'com.blankj:utilcodex:1.26.0'
implementation 'com.squareup.okhttp3:okhttp:4.3.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.3.1'
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
implementation 'com.squareup.retrofit2:converter-scalars:2.7.1'
implementation 'com.blankj:utilcodex:1.28.3'
def okhttp_version = "4.5.0"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
def retrofit_version = "2.7.1"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "com.squareup.retrofit2:converter-scalars:$retrofit_version"
implementation 'com.google.code.gson:gson:2.8.6'
def room_version = "2.2.4"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
def lifecycle_version = "2.2.0"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
implementation 'com.liulishuo.filedownloader:library:1.7.7'
}
......@@ -16,7 +16,7 @@ public class RootApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Utils.init(getApplicationContext());
Utils.init(this);
String logDir = PathUtils.getExternalStoragePath() + File.separator + LOG_DIR;
CrashUtils.init(logDir);
LogUtils.getConfig()
......
......@@ -222,7 +222,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
qrCodeText.setText(msg);
break;
case QRCodeState.FAILED:
TTSHelper.speak("无效二维码");
String failedText = event.getMessage();
if (TextUtils.isEmpty(failedText)) {
TTSHelper.speak("无效二维码");
} else {
TTSHelper.speak(failedText);
}
qrCodeViewModel.scan();
break;
case QRCodeState.ILLEGAL:
......@@ -370,6 +375,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
logoLayout.setVisibility(View.GONE);
debugLayout.setOnClickListener(this);
logoLayout.setOnClickListener(this);
refreshEthInfo();
refreshWifiInfo();
refreshPackageInfo();
}
......
......@@ -52,6 +52,14 @@ public class PayData {
return payState == PAY_SUCCESS;
}
public boolean failed() {
return payState == PAY_FAILED;
}
public boolean offline() {
return payState == PAY_OFFLINE;
}
public void paySuccess() {
payState = PAY_SUCCESS;
}
......
......@@ -13,8 +13,8 @@ public class DefaultQRCodeScan implements IQRCodeScan {
private Serial serial;
private InputStream serialPortIS;
public DefaultQRCodeScan(String filePath) throws Exception {
serial = new Serial(filePath, 115200, 0);
public DefaultQRCodeScan(String portPath) throws Exception {
serial = new Serial(portPath, 115200, 0);
this.serialPortIS = serial.getInputStream();
}
......
......@@ -40,7 +40,7 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
public class SCWebSocketClient extends WebSocketClient {
private static final long HEARTBEAT_INTERVAL = 3 * 60 * 1000;
private static final long RECONNECT_DELAY = 5 * 1000;
private static final long SWITCH_INTERVAL = 15 * 1000;
private static final long SWITCH_INTERVAL = 10 * 1000;
private static final String RESPONSE_ACTION = "action";
private static final String RESPONSE_DATA = "data";
......
......@@ -7,10 +7,10 @@ import android.os.PowerManager;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.RequiresPermission;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ShellUtils;
import com.blankj.utilcode.util.Utils;
......@@ -20,6 +20,7 @@ import java.util.List;
import static android.Manifest.permission.MODIFY_PHONE_STATE;
import static android.Manifest.permission.SEND_SMS;
import static android.content.ContentValues.TAG;
/**
* <pre>
......@@ -118,7 +119,7 @@ public class DangerousUtils {
&& commandResult.successMsg.toLowerCase().contains("success")) {
return true;
} else {
Log.e("AppUtils", "installAppSilent successMsg: " + commandResult.successMsg +
LogUtils.e(TAG, "installAppSilent successMsg: " + commandResult.successMsg +
", errorMsg: " + commandResult.errorMsg);
return false;
}
......@@ -174,7 +175,7 @@ public class DangerousUtils {
&& commandResult.successMsg.toLowerCase().contains("success")) {
return true;
} else {
Log.e("AppUtils", "uninstallAppSilent successMsg: " + commandResult.successMsg +
LogUtils.e(TAG, "uninstallAppSilent successMsg: " + commandResult.successMsg +
", errorMsg: " + commandResult.errorMsg);
return false;
}
......@@ -326,7 +327,7 @@ public class DangerousUtils {
setDataEnabledMethod.invoke(tm, enabled);
return true;
} catch (Exception e) {
Log.e("NetworkUtils", "setMobileDataEnabled: ", e);
LogUtils.e(TAG, "setMobileDataEnabled: ", e);
}
return false;
}
......
......@@ -37,7 +37,9 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
* "标记成功"状态: 在WebSocket未链接时,"在线支付"订单直接标记为"离线支付",并更新到数据库成功的状态
*/
public class PayOfflineViewModel extends ViewModel {
private static final long TIMEOUT = 5;
private static final long TIMEOUT = 5 * 1000;
// 在线支付延迟150ms执行,留出时间给扫码反馈
private static final long REQUEST_DELAY = 150;
private static final long DEFAULT_DELAY = 3 * 1000;
private Gson gson;
private String deviceSN;
......@@ -69,7 +71,7 @@ public class PayOfflineViewModel extends ViewModel {
public void exec(PayData payData) {
MarkRunnable runnable = new MarkRunnable(payData);
SCTaskExecutor.getInstance().executeOnDiskIO(runnable);
SCTaskExecutor.getInstance().schedule(runnable, REQUEST_DELAY, TimeUnit.MILLISECONDS);
}
private void cancelTimeout() {
......@@ -87,7 +89,7 @@ public class PayOfflineViewModel extends ViewModel {
// 只要Socket链接成功,则搜索数据库需要离线支付的订单,并发送给后台
cancelTimeout();
TimeoutRunnable timeoutRunnable = new TimeoutRunnable();
timeoutFuture = SCTaskExecutor.getInstance().schedule(timeoutRunnable, TIMEOUT, TimeUnit.SECONDS);
timeoutFuture = SCTaskExecutor.getInstance().schedule(timeoutRunnable, TIMEOUT, TimeUnit.MILLISECONDS);
RequestRunnable runnable = new RequestRunnable();
SCTaskExecutor.getInstance().executeOnDiskIO(runnable);
}
......
......@@ -38,8 +38,8 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
*/
public class PayOnlineViewModel extends ViewModel {
private static final long TIMEOUT = 5 * 1000;
// 在线支付延迟100ms执行,留出时间给扫码反馈
private static final long REQUEST_DELAY = 100;
// 在线支付延迟150ms执行,留出时间给扫码反馈
private static final long REQUEST_DELAY = 150;
private static final long DEFAULT_DELAY = 3 * 1000;
private Gson gson;
private String deviceSN;
......
......@@ -119,6 +119,13 @@ public class QRCodeViewModel extends ViewModel {
}
PayData newPay = new PayData(deviceSN, scanData, terminalType);
// 扫描到的二维码,先检查该订单是否已存在
PayData existsPay = payDataRepository.queryPayDataByPayCode(scanData);
if (existsPay != null) {
LogUtils.w(TAG, "该订单已存在: " + scanData);
qrCodeState.postValue(new QRCodeState(QRCodeState.FAILED, "请不要重复扫码"));
return;
}
// 扫描到的二维码保存到数据库
long lastInsertId = payDataRepository.insertPayData(newPay);
if (lastInsertId == -1) {
......
......@@ -9,7 +9,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.android.tools.build:gradle:3.6.3'
}
}
......@@ -25,8 +25,8 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
Task appPreBuildTask;
Task daemonBuildTask;
Task appPreBuildTask
Task daemonBuildTask
subprojects.forEach { project ->
if (project.name == "app") {
......
apply plugin: 'com.android.application'
def signed = "Daemon.apk"
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
......@@ -13,10 +14,25 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
debug {
keyAlias 'town'
keyPassword 'maxrocky'
storeFile file('canteen.jks')
storePassword 'maxrocky'
}
release {
keyAlias 'town'
keyPassword 'maxrocky'
storeFile file('canteen.jks')
storePassword 'maxrocky'
}
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
release {
postprocessing {
......@@ -27,6 +43,7 @@ android {
proguardFiles 'proguard-rules.pro'
}
zipAlignEnabled true
signingConfig signingConfigs.release
}
}
compileOptions {
......@@ -46,7 +63,7 @@ android {
.get()
.outputScope
.apkDatas
.forEach { apkData -> apkData.outputFileName = "Daemon.apk" }
.forEach { apkData -> apkData.outputFileName = signed }
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment