From bfc2915403df3f9a98fd866ef5fab106c0fbb043 Mon Sep 17 00:00:00 2001 From: sky121113 Date: Tue, 2 Jun 2026 17:49:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[FIX]=20=E4=BF=AE=E5=BE=A9=E4=B8=AD?= =?UTF-8?q?=E5=9C=8B=E9=86=AB=E5=A4=9A=E8=B2=A8=E9=81=93=E5=BA=AB=E5=AD=98?= =?UTF-8?q?=E5=88=86=E9=85=8D=E7=95=B0=E5=B8=B8=E8=88=87=E9=81=9E=E5=A2=9E?= =?UTF-8?q?=E7=99=BC=E7=89=88=E7=89=88=E8=99=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修復 SaleFlowHandler.java:重構中國醫客製領藥流程中的多商品貨道分配演算法,引進動態多貨道輪替分配機制,徹底解決一筆單多商品(如 3 個同商品)時貨道重複分配為 3, 4, 4 的 Bug。 2. 更新 build.gradle:配合生產發版,將修補版號 verPatch 遞增至 66,並在背景成功編譯產出正式 Release APK (CmuhS9XYURelease)。 --- app/build.gradle | 2 +- .../smartdevice/ui/SaleFlowHandler.java | 34 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6507b9b..6bc7304 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,7 @@ plugins { // 避免不同尺寸機台間版本號產生衝突。 // ========================================================================= def verMinor = 1 -def verPatch = 65 +def verPatch = 66 android { diff --git a/app/src/Cmuh/java/com/unibuy/smartdevice/ui/SaleFlowHandler.java b/app/src/Cmuh/java/com/unibuy/smartdevice/ui/SaleFlowHandler.java index 218ce96..2c94e2e 100644 --- a/app/src/Cmuh/java/com/unibuy/smartdevice/ui/SaleFlowHandler.java +++ b/app/src/Cmuh/java/com/unibuy/smartdevice/ui/SaleFlowHandler.java @@ -322,14 +322,36 @@ public class SaleFlowHandler { haveValuestate = true; if (requestQty > 1) { - int checkcount = 0; - int slotnum = 0; + class TempSlot { + int slotNo; + int stock; + TempSlot(int slotNo, int stock) { + this.slotNo = slotNo; + this.stock = stock; + } + } + String[] slotPairs = medicineList.get(i).getMedicineSlot().split(","); + java.util.List tempSlots = new java.util.ArrayList<>(); + for (String pair : slotPairs) { + if (pair.trim().isEmpty()) continue; + String[] parts = pair.split("-"); + if (parts.length == 2) { + tempSlots.add(new TempSlot(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]))); + } + } + + int slotIdx = 0; for (int j = 0; j < requestQty; j++) { - checkcount += 1; - if (checkcount > Integer.valueOf(medicineList.get(i).getMedicineSlot().split(",")[0].split("-")[1])) { - slotnum = Integer.valueOf(medicineList.get(i).getMedicineSlot().split(",")[1].split("-")[0]); + while (slotIdx < tempSlots.size() && tempSlots.get(slotIdx).stock <= 0) { + slotIdx++; + } + int slotnum; + if (slotIdx < tempSlots.size()) { + TempSlot activeSlot = tempSlots.get(slotIdx); + slotnum = activeSlot.slotNo; + activeSlot.stock--; } else { - slotnum = Integer.valueOf(medicineList.get(i).getMedicineSlot().split(",")[0].split("-")[0]); + slotnum = tempSlots.get(tempSlots.size() - 1).slotNo; } addMedicineToBuyList( medicineList.get(i).getProductId(), From 0637f71e3465621902f95e006f5a904457437816 Mon Sep 17 00:00:00 2001 From: sky121113 Date: Thu, 4 Jun 2026 16:07:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[FIX]=20=E5=84=AA=E5=8C=96=E6=A9=9F?= =?UTF-8?q?=E5=8F=B0=E9=8E=96=E5=AE=9A=E9=98=B2=E8=AD=B7=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E8=88=87=E9=81=9E=E5=A2=9E=E7=89=88=E6=9C=AC=E8=99=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 遞增修補版號 verPatch 至 67 以落實機台 OTA 更新規範。 2. 於 FontendActivity 的 onCreate 流程新增機台鎖定狀態檢查,若鎖定則強制跳轉至 MaintenanceActivity 並清除 Activity 棧。 3. 修正 MqttService 的鎖定命令跳轉旗標,改用 Intent.FLAG_ACTIVITY_CLEAR_TASK 確保舊 Activity 棧被完整清理。 4. 移除 AppUtils 中未使用的 MqttManager 引用。 --- .agents/rules/versioning.md | 11 ++++- AGENTS.md | 1 + app/build.gradle | 3 +- .../smartdevice/service/MqttService.java | 2 +- .../unibuy/smartdevice/tools/AppUtils.java | 49 +++++++++---------- .../smartdevice/ui/FontendActivity.java | 13 +++++ 6 files changed, 50 insertions(+), 29 deletions(-) diff --git a/.agents/rules/versioning.md b/.agents/rules/versioning.md index 2fdf7ab..dbf6b57 100644 --- a/.agents/rules/versioning.md +++ b/.agents/rules/versioning.md @@ -68,8 +68,17 @@ S _ 12 _ XY _ U _ Chengwai _ 10 _ 08 _ 8 _ R * **`Cmuh`** (中國醫客製):支援 QR Code 掃碼、處方籤醫令離線 AES 解密與解析領藥流程。 2. **`hardware` 維度 (硬體與系統規格區隔)**: * **`S12XYU`**:代表 `S` (來源) + `12` (安卓號) + `XY` (主板號) + `U` (機器系列/機型規格)。 + * **`S9XYU`**:代表中國醫現場使用的 Android 9 / 21.5 吋硬體規格;除非明確指定中國醫 10 吋或 `S12XYU`,中國醫 (`Cmuh`) 相關修正與驗證預設必須使用此硬體 flavor。 -### 4.2 實體機台 APK 命名鐵律 +### 4.2 Flavor 驗證與編譯指令選擇 + +針對特定客戶或現場問題修改後,必須編譯對應的 Gradle variant,不可只用通用 `assembleDebug` 或錯誤硬體 flavor 代替。 + +* **中國醫現場版 (`Cmuh`) 驗證指令**:`./gradlew :app:assembleCmuhS9XYUDebug --no-daemon` +* **晟崴版 (`Chengwai`) 預設驗證指令**:`./gradlew :app:assembleChengwaiS12XYUDebug --no-daemon` +* **通用版 (`General`) 預設驗證指令**:`./gradlew :app:assembleGeneralS12XYUDebug --no-daemon` + +### 4.3 實體機台 APK 命名鐵律 為了符合實體機台 OTA 平台發佈規範,打包輸出的 APK 檔名必須嚴格連動雙維度,並遵循以下格式: `app-[格式化硬體規格]_[專案名稱]-[版本號]-[BuildType].apk` diff --git a/AGENTS.md b/AGENTS.md index 45d7b68..bacc403 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -24,6 +24,7 @@ - 禁止直接手改成品 `versionCode`/`versionName` 值。 - 版號管理透過 `verMajor`、`verMinor`、`verPatch` 變數。 - OTA 發版時,`versionCode` 必須嚴格遞增。 +- 中國醫現場版 (`Cmuh`) 修正預設以 `:app:assembleCmuhS9XYUDebug` 驗證。 ## When Rules Conflict diff --git a/app/build.gradle b/app/build.gradle index 6bc7304..97dadd0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,8 @@ plugins { // 避免不同尺寸機台間版本號產生衝突。 // ========================================================================= def verMinor = 1 -def verPatch = 66 +def verPatch = 67 + android { diff --git a/app/src/main/java/com/unibuy/smartdevice/service/MqttService.java b/app/src/main/java/com/unibuy/smartdevice/service/MqttService.java index 9d6409a..19fa136 100644 --- a/app/src/main/java/com/unibuy/smartdevice/service/MqttService.java +++ b/app/src/main/java/com/unibuy/smartdevice/service/MqttService.java @@ -138,7 +138,7 @@ public class MqttService extends Service { new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> { Intent lockIntent = new Intent(getApplicationContext(), com.unibuy.smartdevice.ui.MaintenanceActivity.class); - lockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); + lockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(lockIntent); }); } else if ("unlock".equals(cmd)) { diff --git a/app/src/main/java/com/unibuy/smartdevice/tools/AppUtils.java b/app/src/main/java/com/unibuy/smartdevice/tools/AppUtils.java index 52d8ee6..8a91dca 100644 --- a/app/src/main/java/com/unibuy/smartdevice/tools/AppUtils.java +++ b/app/src/main/java/com/unibuy/smartdevice/tools/AppUtils.java @@ -1,26 +1,23 @@ -package com.unibuy.smartdevice.tools; - -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; - -import com.unibuy.smartdevice.external.mqtt.MqttManager; -import com.unibuy.smartdevice.ui.FontendActivity; - -public class AppUtils { - public static void resetApp(Context context) { - Intent intent = new Intent(context, FontendActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); - - PendingIntent pendingIntent = PendingIntent.getActivity( - context, 0, intent, PendingIntent.FLAG_IMMUTABLE); - - AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); - alarmManager.setExact(AlarmManager.RTC, System.currentTimeMillis() + 500, pendingIntent); - - - - android.os.Process.killProcess(android.os.Process.myPid()); - } -} +package com.unibuy.smartdevice.tools; + +import android.app.AlarmManager; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; + +import com.unibuy.smartdevice.ui.FontendActivity; + +public class AppUtils { + public static void resetApp(Context context) { + Intent intent = new Intent(context, FontendActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + + PendingIntent pendingIntent = PendingIntent.getActivity( + context, 0, intent, PendingIntent.FLAG_IMMUTABLE); + + AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + alarmManager.setExact(AlarmManager.RTC, System.currentTimeMillis() + 500, pendingIntent); + + android.os.Process.killProcess(android.os.Process.myPid()); + } +} diff --git a/app/src/main/java/com/unibuy/smartdevice/ui/FontendActivity.java b/app/src/main/java/com/unibuy/smartdevice/ui/FontendActivity.java index 0d16ca5..94a58bd 100644 --- a/app/src/main/java/com/unibuy/smartdevice/ui/FontendActivity.java +++ b/app/src/main/java/com/unibuy/smartdevice/ui/FontendActivity.java @@ -45,6 +45,7 @@ import androidx.fragment.app.FragmentManager; import com.unibuy.smartdevice.R; import com.unibuy.smartdevice.controller.DevController; import com.unibuy.smartdevice.controller.DevXinYuanController; +import com.unibuy.smartdevice.database.SettingsDao; import com.unibuy.smartdevice.database.SlotsDao; import com.unibuy.smartdevice.databinding.ActivityFontendBinding; import com.unibuy.smartdevice.devices.DevNFCPay; @@ -407,6 +408,18 @@ public class FontendActivity extends AppCompatActivityAbstract implements SaleFl @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + SettingsDao settingsDao = new SettingsDao(getApplicationContext()); + if (settingsDao.isMachineLocked()) { + settingsDao.close(); + Intent intent = new Intent(this, MaintenanceActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + startActivity(intent); + finish(); + return; + } + settingsDao.close(); + // 讀取最後設定語言的設定 // LanguageHelper.applySavedLanguage(this); binding = ActivityFontendBinding.inflate(getLayoutInflater());