优化
This commit is contained in:
@@ -73,6 +73,7 @@ dependencies {
|
||||
implementation("com.geyifeng.immersionbar:immersionbar-ktx:3.2.2")
|
||||
|
||||
implementation("com.squareup.okhttp3:okhttp:4.9.1")
|
||||
implementation("com.squareup.okhttp3:logging-interceptor:4.9.1")
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
implementation("com.squareup.retrofit2:retrofit:2.9.0")
|
||||
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
|
||||
|
||||
@@ -183,8 +183,25 @@ class HomeActivity : BaseActivity() {
|
||||
|
||||
// viewModel.getAccessToken(App.deviceId)
|
||||
|
||||
viewModel.getShelfList(deviceId = App.deviceId)
|
||||
// viewModel.getShelfList(deviceId = App.deviceId)
|
||||
|
||||
binding.root.postDelayed({
|
||||
loadTestData()
|
||||
}, 30*1000)
|
||||
}
|
||||
|
||||
private fun loadTestData() {
|
||||
list.add(ShelfModel(deviceNo = 1, goodsName = "鸡蛋", deviceId = App.deviceId))
|
||||
list.add(ShelfModel(deviceNo = 6, goodsName = "", deviceId = App.deviceId))
|
||||
list.add(ShelfModel(deviceNo = 2, goodsName = "", deviceId = App.deviceId))
|
||||
list.add(ShelfModel(deviceNo = 7, goodsName = "生姜", deviceId = App.deviceId))
|
||||
list.add(ShelfModel(deviceNo = 3, goodsName = "黄瓜", deviceId = App.deviceId))
|
||||
list.add(ShelfModel(deviceNo = 8, goodsName = "", deviceId = App.deviceId))
|
||||
list.add(ShelfModel(deviceNo = 4, goodsName = "梨", deviceId = App.deviceId))
|
||||
list.add(ShelfModel(deviceNo = 9, goodsName = "梨", deviceId = App.deviceId))
|
||||
list.add(ShelfModel(deviceNo = 5, goodsName = "", deviceId = App.deviceId))
|
||||
list.add(ShelfModel(deviceNo = 10, goodsName = "", deviceId = App.deviceId))
|
||||
shelfAdapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun getTokenSuccess(data: RespData<*>) {
|
||||
@@ -318,7 +335,7 @@ class HomeActivity : BaseActivity() {
|
||||
"0101", "8101" -> {
|
||||
//心跳0102${p1}${p2}${version}
|
||||
//心跳81(终端发起,当终端发送此命令时需要服务端存储串口屏显示信息)
|
||||
val respCmd = "${HEADER}01020906${terminalVersion}$FOOTER"
|
||||
val respCmd = "${HEADER}01020506${terminalVersion}$FOOTER"
|
||||
log("${LOG_PREFIX}[心跳]${cmdFlag}指令:${data},发送应答指令:${respCmd}")
|
||||
sendCmd(respCmd)
|
||||
heartBeat(data)
|
||||
|
||||
@@ -375,6 +375,9 @@ class ShelfActivity : BaseActivity() {
|
||||
val zeroClearingCmd = "${HomeActivity.HEADER}0401${hex}${HomeActivity.FOOTER}"
|
||||
log("编号${shelfNo}货架执行清零指令:${zeroClearingCmd}")
|
||||
sendCmd(zeroClearingCmd)
|
||||
sendCmd(
|
||||
if (shelfNo in 1..5) HomeActivity.LEFT_SHELF_OPEN_CMD else HomeActivity.RIGHT_SHELF_OPEN_CMD
|
||||
)
|
||||
//清零
|
||||
realWeight = 0
|
||||
// binding.tvFoodWeight.text = "${realWeight}克"
|
||||
|
||||
@@ -45,6 +45,7 @@ interface ApiService {
|
||||
@Url url: String = UrlConfig.GET_SHELF_LIST,
|
||||
@Query("deviceId") deviceId: String,
|
||||
@Query("x-access-token") token: String = App.accessToken,
|
||||
@Header("X-DEVICE-CODE") deviceCode:String = App.deviceId,
|
||||
@Header("authorization") authorization: String = "57ee87183f2a4fa59683ec9ef41c8f5d"
|
||||
): RespData<ShelfResult>
|
||||
|
||||
@@ -56,6 +57,7 @@ interface ApiService {
|
||||
@Query("pageNo") pageNo: Int = 1,
|
||||
@Query("pageSize") pageSize: Int = 50,
|
||||
@Query("x-access-token") token: String = App.accessToken,
|
||||
@Header("X-DEVICE-CODE") deviceCode:String = App.deviceId,
|
||||
@Header("authorization") authorization: String = "57ee87183f2a4fa59683ec9ef41c8f5d"
|
||||
): RespData<MutableList<GoodsModel>?>
|
||||
|
||||
@@ -64,6 +66,7 @@ interface ApiService {
|
||||
@Url url: String = UrlConfig.SAVE_SHELF_GOODS_LIST,
|
||||
@Body body: ShelfBody,
|
||||
@Query("x-access-token") token: String = App.accessToken,
|
||||
@Header("X-DEVICE-CODE") deviceCode:String = App.deviceId,
|
||||
@Header("authorization") authorization: String = "57ee87183f2a4fa59683ec9ef41c8f5d"
|
||||
): RespData<Any?>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.shuwei.intelligent.shelves.App
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Response
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -33,6 +34,16 @@ class HttpManager private constructor() {
|
||||
sslSocketFactory(createSSLSocketFactory(), TrustAllCerts())
|
||||
hostnameVerifier { _, _ -> true }
|
||||
addInterceptor(LoggingInterceptor())
|
||||
addNetworkInterceptor(HttpLoggingInterceptor(logger = {
|
||||
Log.d("HttpManager","okhttp logger ==>${it}")
|
||||
}).apply {
|
||||
level =
|
||||
// if (MyApp.DEBUG) {
|
||||
HttpLoggingInterceptor.Level.BODY
|
||||
// } else {
|
||||
// HttpLoggingInterceptor.Level.NONE
|
||||
// }
|
||||
})
|
||||
// addInterceptor { chain ->
|
||||
// val request = chain.request().newBuilder()
|
||||
// .header("x-access-token", App.accessToken)
|
||||
|
||||
@@ -406,45 +406,45 @@ public class AppUtil {
|
||||
*/
|
||||
@SuppressLint("MissingPermission")
|
||||
public static String getUDID(Context context) {
|
||||
// return "SWZC-HG-001";
|
||||
// //"test111";
|
||||
String androidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
if (!androidID.equals("")) {
|
||||
try {
|
||||
if (!"9774d56d682e549c".equals(androidID)) {
|
||||
androidID = UUID.nameUUIDFromBytes(androidID.getBytes("utf8")).toString();
|
||||
} else {
|
||||
@SuppressLint("MissingPermission") final String deviceId = ((TelephonyManager) context.getSystemService(TELEPHONY_SERVICE)).getDeviceId();
|
||||
androidID = deviceId != null ? UUID.nameUUIDFromBytes(deviceId.getBytes("utf8")).toString() : UUID.randomUUID().toString();
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return androidID;
|
||||
}
|
||||
|
||||
//需要权限 android.permission.READ_PHONE_STATE
|
||||
TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
|
||||
String szImei = TelephonyMgr.getDeviceId();
|
||||
if (!szImei.equals("")) {
|
||||
return szImei;
|
||||
}
|
||||
|
||||
//需要权限 android.permission.ACCESS_WIFI_STATE
|
||||
WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
String m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
|
||||
if (!m_szWLANMAC.equals("")) {
|
||||
return m_szWLANMAC;
|
||||
}
|
||||
|
||||
//需要权限 android.permission.BLUETOOTH
|
||||
BluetoothAdapter m_BluetoothAdapter = null;
|
||||
m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
String m_szBTMAC = m_BluetoothAdapter.getAddress();
|
||||
if (!m_szBTMAC.equals("")) {
|
||||
return m_szBTMAC;
|
||||
}
|
||||
return getUniquePsuedoID();
|
||||
return "SWZC-HG-001";
|
||||
//// //"test111";
|
||||
// String androidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
// if (!androidID.equals("")) {
|
||||
// try {
|
||||
// if (!"9774d56d682e549c".equals(androidID)) {
|
||||
// androidID = UUID.nameUUIDFromBytes(androidID.getBytes("utf8")).toString();
|
||||
// } else {
|
||||
// @SuppressLint("MissingPermission") final String deviceId = ((TelephonyManager) context.getSystemService(TELEPHONY_SERVICE)).getDeviceId();
|
||||
// androidID = deviceId != null ? UUID.nameUUIDFromBytes(deviceId.getBytes("utf8")).toString() : UUID.randomUUID().toString();
|
||||
// }
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// return androidID;
|
||||
// }
|
||||
//
|
||||
// //需要权限 android.permission.READ_PHONE_STATE
|
||||
// TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
|
||||
// String szImei = TelephonyMgr.getDeviceId();
|
||||
// if (!szImei.equals("")) {
|
||||
// return szImei;
|
||||
// }
|
||||
//
|
||||
// //需要权限 android.permission.ACCESS_WIFI_STATE
|
||||
// WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
// String m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
|
||||
// if (!m_szWLANMAC.equals("")) {
|
||||
// return m_szWLANMAC;
|
||||
// }
|
||||
//
|
||||
// //需要权限 android.permission.BLUETOOTH
|
||||
// BluetoothAdapter m_BluetoothAdapter = null;
|
||||
// m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
// String m_szBTMAC = m_BluetoothAdapter.getAddress();
|
||||
// if (!m_szBTMAC.equals("")) {
|
||||
// return m_szBTMAC;
|
||||
// }
|
||||
// return getUniquePsuedoID();
|
||||
}
|
||||
|
||||
//获得 Psuedo ID
|
||||
|
||||
Reference in New Issue
Block a user