TaiwanStar_general_size_s_C.../app/build.gradle
sky121113 71a059183a [REFACTOR] 優化中國醫(Cmuh)售貨與領藥流程,重構 API 連線模組,並自動升版至 24
1. 重構 Cmuh 的 SaleFlowHandler:新增 ORDC_EMPTY、MATERIAL_NOT_FOUND、STOCK_NOT_ENOUGH 等明確領藥錯誤代碼,最佳化多貨道庫存匹配與扣減邏輯,改善掃碼按鈕的動態 UI 綁定時序。
2. 增強 Dialog UI 提示:重構 PickupErrorTipDialog 與 DispatchDialog,優化 dialog_pickup_error_tip.xml 佈局結構,確保出貨異常時能正確顯示對應的中文 Toast 與圖示。
3. 重構 HttpAPI 與網路層:重構後台 API 與 HttpConnect 的 Socket/連線異常處理,確實向 UI 回傳網路錯誤訊息(非吞例外),提升在極端網路環境下的穩定度。
4. 健全持久化與日誌模組:強化 StarCloudAPI 機台 Token 變更時的本地 SQLite 同步邏輯,提升 Logs 模組的非同步儲存與排程上傳穩定性。
5. 自動升版:配合實體機台 OTA 發版鐵律,將 app/build.gradle 中的 verPatch 變數由 23 遞增至 24。
6. 更新工作流說明:優化 .agents/workflows/compiler-apk.md 文件中的智慧尺寸判斷指令說明。
2026-05-28 17:48:03 +08:00

149 lines
4.9 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

plugins {
alias(libs.plugins.android.application)
}
// =========================================================================
// 核心版號與自動連動定義
// 每次發佈新版本給機台時,只需遞增 verPatch (修補版號)。
// 螢幕尺寸 (verMajor) 已改為下方依據編譯 Flavor (S12XYU / S9XYU) 自動動態判定,
// 避免不同尺寸機台間版本號產生衝突。
// =========================================================================
def verMinor = 1
def verPatch = 24
android {
namespace 'com.unibuy.smartdevice'
compileSdk 35
defaultConfig {
applicationId "com.unibuy.smartdevice"
minSdk 21
targetSdk 34
// 預設以 10 吋進行基礎 Sync 估算,實際打包會由下方 applicationVariants 動態覆寫
versionCode 10 * 10000 + verMinor * 100 + verPatch
versionName "10_0${verMinor}_${verPatch}_R"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
// =====================================================================
// 雙維度 Flavorproject客戶專案× hardware硬體規格
// =====================================================================
flavorDimensions "project", "hardware"
productFlavors {
General {
dimension "project"
}
Chengwai {
dimension "project"
}
Cmuh {
dimension "project"
}
S12XYU {
dimension "hardware"
}
S9XYU {
dimension "hardware"
minSdk 28
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
}
// 自定義打包檔案名稱與動態版本號計算
// 遵循公司命名規範來源_安卓號_主板號_機器系列_專案名稱_螢幕大小_次版號_修補版號_環境
applicationVariants.all { variant ->
def project = variant.productFlavors[0].name // project dimension
def hardware = variant.productFlavors[1].name // hardware dimension
def buildType = variant.buildType.name
// 根據硬體規格自動動態判定螢幕吋數 (verMajor) 與版號
def verMajor = 10
def calculatedMinor = verMinor // 預設套用全域次版號
def calculatedPatch = verPatch // 預設套用全域修補版號
if (hardware == "S9XYU") {
verMajor = 21 // 21.5 吋
// 【預留擴充】若中國醫安卓 9 機台未來需要獨立的發版節奏,可直接在此單獨覆寫:
// calculatedMinor = 1
// calculatedPatch = 6
} else if (hardware == "S12XYU") {
verMajor = 10 // 10 吋
}
// 動態重算並覆寫此 Variant 的版本號,避免互相污染
def calculatedVersionCode = verMajor * 10000 + calculatedMinor * 100 + calculatedPatch
def calculatedVersionName = "${verMajor}_0${calculatedMinor}_${calculatedPatch}_R"
variant.outputs.each { output ->
output.versionCodeOverride = calculatedVersionCode
output.versionNameOverride = calculatedVersionName
// 將 hardware flavor 名稱展開為公司規範格式 S12XYU → S_12_XY_U
def hwFormatted = hardware
.replaceAll(/^([A-Z])(\d+)([A-Z]+)([A-Z])$/, '$1_$2_$3_$4')
// 輸出範例app-S_12_XY_U_Chengwai-10_08_8_R-release.apk
output.outputFileName = "app-${hwFormatted}_${project}-${calculatedVersionName}-${buildType}.apk"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
buildFeatures {
viewBinding true
buildConfig true
}
packaging {
resources {
excludes += ['META-INF/INDEX.LIST', 'META-INF/io.netty.versions.properties']
}
}
}
dependencies {
implementation libs.appcompat
implementation libs.material
implementation libs.activity
implementation libs.constraintlayout
implementation libs.work.runtime
testImplementation libs.junit
androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core
annotationProcessor libs.compiler
implementation libs.usb.serial.for.android
implementation libs.android.serialport
implementation libs.glide
implementation libs.media3.exoplayer
implementation libs.media3.ui
implementation libs.tsnackBar
implementation 'com.blankj:utilcodex:1.31.1'
implementation 'com.hivemq:hivemq-mqtt-client:1.3.3'
implementation 'io.netty:netty-codec-http:4.1.94.Final'
implementation 'io.netty:netty-handler:4.1.94.Final'
implementation 'com.google.code.gson:gson:2.10.1'
}