Quellcode durchsuchen

1.国睿一键入库提测

JaycePC vor 1 Monat
Ursprung
Commit
2be798b692
49 geänderte Dateien mit 3823 neuen und 1692 gelöschten Zeilen
  1. 12 10
      app/src/main/AndroidManifest.xml
  2. 178 0
      app/src/main/java/com/rc/httpcore/bean/HxpChemicalVo.java
  3. 3 1
      app/src/main/java/com/rc/httpcore/bean/ReturnDetailsBean.kt
  4. 50 0
      app/src/main/java/com/rc/httpcore/client/HttpTool.java
  5. 693 0
      app/src/main/java/xn/hxp/ui/MainActivity.java
  6. 0 829
      app/src/main/java/xn/hxp/ui/MainActivity.kt
  7. 3 1
      app/src/main/java/xn/hxp/ui/StartActivity.java
  8. 27 19
      app/src/main/java/xn/hxp/ui/inquiry/InquiryActivity.kt
  9. 452 0
      app/src/main/java/xn/hxp/ui/login/FaceLoginActivity.java
  10. 0 362
      app/src/main/java/xn/hxp/ui/login/FacialLoginActivity.kt
  11. 2 2
      app/src/main/java/xn/hxp/ui/login/ScanLoginActivity.kt
  12. 3 3
      app/src/main/java/xn/hxp/ui/login/SwipeActivity.kt
  13. 14 3
      app/src/main/java/xn/hxp/ui/plan/PlanAddData.java
  14. 590 0
      app/src/main/java/xn/hxp/ui/plan/already/AlreadyActivity.java
  15. 206 0
      app/src/main/java/xn/hxp/ui/plan/already/AlreadyAdapter.java
  16. 69 0
      app/src/main/java/xn/hxp/ui/plan/already/AlreadyBean.java
  17. 42 0
      app/src/main/java/xn/hxp/ui/plan/already/AlreadyTool.java
  18. 49 0
      app/src/main/java/xn/hxp/ui/plan/already/AutoChemicalBean.java
  19. 11 2
      app/src/main/java/xn/hxp/ui/plan/room/bean/input_add/InventoryItemBean.java
  20. 3 4
      app/src/main/java/xn/hxp/ui/plan/room/bean/locker/HxpCabinetDoorVo.java
  21. 21 3
      app/src/main/java/xn/hxp/ui/plan/room/dao/HxpInventoryDAO.java
  22. 1 1
      app/src/main/java/xn/hxp/ui/plan/save_list/SaveListActivity.java
  23. 3 1
      app/src/main/java/xn/hxp/ui/plan/unlock/UnlockActivity.java
  24. 125 74
      app/src/main/java/xn/hxp/ui/plan/unlock/UnlockActivityHelp.java
  25. 8 5
      app/src/main/java/xn/hxp/ui/still/ChemicalsAlsoActivity.kt
  26. 4 3
      app/src/main/java/xn/hxp/ui/warehousing/ChemicalLabelingActivity.kt
  27. 261 0
      app/src/main/java/xn/hxp/utils/BitmapUtils.java
  28. 0 182
      app/src/main/java/xn/hxp/utils/BitmapUtils.kt
  29. 47 5
      app/src/main/java/xn/hxp/utils/PrintTool.java
  30. 52 0
      app/src/main/java/xn/hxp/weidith/PlanDialog.java
  31. 126 0
      app/src/main/java/xn/hxp/weidith/PromptDialog.java
  32. 0 109
      app/src/main/java/xn/hxp/weidith/PromptDialog.kt
  33. 3 3
      app/src/main/java/xn/hxp/weidith/prin_label_dialog/PrintLabelDialog.java
  34. 16 0
      app/src/main/res/drawable/button_custom_background.xml
  35. 15 0
      app/src/main/res/drawable/selector_check_bt.xml
  36. 43 44
      app/src/main/res/layout/activity_added_chemicals.xml
  37. 453 0
      app/src/main/res/layout/activity_already.xml
  38. 12 9
      app/src/main/res/layout/activity_chemical_labeling.xml
  39. 1 2
      app/src/main/res/layout/activity_chemicals_also.xml
  40. 3 4
      app/src/main/res/layout/activity_demonstrate.xml
  41. 1 1
      app/src/main/res/layout/activity_facial_login.xml
  42. 1 2
      app/src/main/res/layout/activity_list_returned.xml
  43. 1 2
      app/src/main/res/layout/activity_splash.xml
  44. 4 5
      app/src/main/res/layout/activity_warehousing.xml
  45. 53 0
      app/src/main/res/layout/dialog_plan.xml
  46. 159 0
      app/src/main/res/layout/item_already.xml
  47. 3 1
      app/src/main/res/layout/item_chemical_labeling.xml
  48. BIN
      app/src/main/res/mipmap-xhdpi/img_bg_qthxpcc.png
  49. BIN
      app/src/main/res/mipmap-xhdpi/img_bg_whpcc.png

+ 12 - 10
app/src/main/AndroidManifest.xml

@@ -38,6 +38,7 @@
         android:name="android.permission.WRITE_SETTINGS"
         tools:ignore="ProtectedPermissions" /> <!-- 手机定位信息,用来为语义等功能提供定位,提供更精准的服务 -->
     <!-- 定位信息是敏感信息,可通过Setting.setLocationEnable(false)关闭定位请求 -->
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 如需使用人脸识别,还要添加:摄相头权限,拍照需要用到 -->
     <uses-permission android:name="android.permission.CAMERA" />
     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
@@ -46,8 +47,7 @@
     <uses-feature android:name="android.hardware.usb.accessory" /> <!-- //android 6.0+以上需要进行动态权限申请 -->
     <uses-permission android:name="android.permission.BLUETOOTH" />
     <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
-    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
-    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 安卓13 -->
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 安卓13 -->
     <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
     <uses-permission android:name="BLUETOOTH_CONNECT" />
     <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
@@ -76,6 +76,9 @@
         android:theme="@style/Theme.AppFullTheme"
         tools:targetApi="m">
         <activity
+            android:name=".ui.plan.already.AlreadyActivity"
+            android:exported="false" />
+        <activity
             android:name=".ui.SettingActivity"
             android:exported="false" />
         <activity
@@ -214,13 +217,12 @@
             android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
             android:launchMode="singleTask"
             android:screenOrientation="landscape"
-            android:windowSoftInputMode="adjustPan" />
-        <activity
-            android:name=".ui.warehousing.WarehousingActivity"
-            android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
-            android:launchMode="singleTask"
-            android:screenOrientation="landscape"
-            android:windowSoftInputMode="adjustPan" />
+            android:windowSoftInputMode="adjustPan" /> <!-- <activity -->
+        <!-- android:name=".ui.warehousing.WarehousingActivity" -->
+        <!-- android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale" -->
+        <!-- android:launchMode="singleTask" -->
+        <!-- android:screenOrientation="landscape" -->
+        <!-- android:windowSoftInputMode="adjustPan" /> -->
         <activity
             android:name=".ui.login.SwipeActivity"
             android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
@@ -228,7 +230,7 @@
             android:screenOrientation="landscape"
             android:windowSoftInputMode="adjustPan" />
         <activity
-            android:name=".ui.login.FacialLoginActivity"
+            android:name=".ui.login.FaceLoginActivity"
             android:screenOrientation="landscape"
             android:windowSoftInputMode="adjustPan" />
         <activity

+ 178 - 0
app/src/main/java/com/rc/httpcore/bean/HxpChemicalVo.java

@@ -4,6 +4,8 @@ package com.rc.httpcore.bean;
 import java.io.Serializable;
 import java.util.List;
 
+import xn.hxp.ui.plan.room.bean.locker.HxpCabinetVo;
+
 public class HxpChemicalVo implements Serializable {
 
     // 实验室id
@@ -112,6 +114,182 @@ public class HxpChemicalVo implements Serializable {
      */
     private int joinType = 2;
 
+
+    // 唯一ID
+    private String waitId;
+    // 是否被选择
+    private boolean isSelect = false;
+    // 申购单号
+    private String applyOrder;
+    // 编码
+    private String labels;
+    private String doorUniqueId;
+    private int doorLayers;
+    // 是否是课题组
+    private boolean topicGroup;
+    // 申领人
+    private String applyUserId;
+    private String applyUserName;
+    private String applyUserPhone;
+    // 课题组
+    private String topicGroupId;
+    private String topicGroupName;
+    private String topicUserName;
+    private String topicUserPhone;
+    // 规格
+    private String normsNum;
+    // 规格单位
+    private String normsUnit;
+    // 化学品柜子
+    private HxpCabinetVo hxpCabinetVo;
+
+    // 是否国睿
+    private boolean isGr;
+
+    public boolean isGr() {
+        return isGr;
+    }
+
+    public void setGr(boolean gr) {
+        isGr = gr;
+    }
+
+    public String getWaitId() {
+        return waitId;
+    }
+
+    public void setWaitId(String waitId) {
+        this.waitId = waitId;
+    }
+
+    public boolean isSelect() {
+        return isSelect;
+    }
+
+    public void setSelect(boolean select) {
+        isSelect = select;
+    }
+
+    public String getApplyOrder() {
+        return applyOrder;
+    }
+
+    public void setApplyOrder(String applyOrder) {
+        this.applyOrder = applyOrder;
+    }
+
+    public String getLabels() {
+        return labels;
+    }
+
+    public void setLabels(String labels) {
+        this.labels = labels;
+    }
+
+    public String getDoorUniqueId() {
+        return doorUniqueId;
+    }
+
+    public void setDoorUniqueId(String doorUniqueId) {
+        this.doorUniqueId = doorUniqueId;
+    }
+
+    public int getDoorLayers() {
+        return doorLayers;
+    }
+
+    public void setDoorLayers(int doorLayers) {
+        this.doorLayers = doorLayers;
+    }
+
+    public boolean isTopicGroup() {
+        return topicGroup;
+    }
+
+    public void setTopicGroup(boolean topicGroup) {
+        this.topicGroup = topicGroup;
+    }
+
+    public String getApplyUserId() {
+        return applyUserId;
+    }
+
+    public void setApplyUserId(String applyUserId) {
+        this.applyUserId = applyUserId;
+    }
+
+    public String getApplyUserName() {
+        return applyUserName;
+    }
+
+    public void setApplyUserName(String applyUserName) {
+        this.applyUserName = applyUserName;
+    }
+
+    public String getApplyUserPhone() {
+        return applyUserPhone;
+    }
+
+    public void setApplyUserPhone(String applyUserPhone) {
+        this.applyUserPhone = applyUserPhone;
+    }
+
+    public String getTopicGroupId() {
+        return topicGroupId;
+    }
+
+    public void setTopicGroupId(String topicGroupId) {
+        this.topicGroupId = topicGroupId;
+    }
+
+    public String getTopicGroupName() {
+        return topicGroupName;
+    }
+
+    public void setTopicGroupName(String topicGroupName) {
+        this.topicGroupName = topicGroupName;
+    }
+
+    public String getTopicUserName() {
+        return topicUserName;
+    }
+
+    public void setTopicUserName(String topicUserName) {
+        this.topicUserName = topicUserName;
+    }
+
+    public String getTopicUserPhone() {
+        return topicUserPhone;
+    }
+
+    public void setTopicUserPhone(String topicUserPhone) {
+        this.topicUserPhone = topicUserPhone;
+    }
+
+    public String getNormsNum() {
+        return normsNum;
+    }
+
+    public void setNormsNum(String normsNum) {
+        this.normsNum = normsNum;
+    }
+
+    public String getNormsUnit() {
+        return normsUnit;
+    }
+
+    public void setNormsUnit(String normsUnit) {
+        this.normsUnit = normsUnit;
+    }
+
+    public HxpCabinetVo getHxpCabinetVo() {
+        return hxpCabinetVo;
+    }
+
+    public void setHxpCabinetVo(HxpCabinetVo hxpCabinetVo) {
+        this.hxpCabinetVo = hxpCabinetVo;
+    }
+
     public int getStockType() {
         return stockType;
     }

+ 3 - 1
app/src/main/java/com/rc/httpcore/bean/ReturnDetailsBean.kt

@@ -73,9 +73,11 @@ data class ReturnDetailsBean(
     val useStatus: Int,
     val useStatusName: Any,
     val userecordId: String,
-    val wxCode: String?="",
+    val wxCode: String? = "",
     val stockTypeStr: String = "领用",
     var isType: Boolean = false,  //不选中 true选中
     var verify: Boolean = true,  //是否需要双人认证
     var cabinetLockVoList: List<LockVoListBean>? = null,  //柜锁有几个
+
+    var isGr: Boolean = false // 是否国睿的码
 )

+ 50 - 0
app/src/main/java/com/rc/httpcore/client/HttpTool.java

@@ -60,6 +60,13 @@ public final class HttpTool {
     }
 
     /**
+     * 获取柜子信息
+     */
+    public static Response getApplyOrder(String labId) throws IOException {
+        return OkHttpUtils.getSync(HttpConfig.Companion.getAPI_BASE_URL() + "chemical/aio/getApplyOrder?subId=" + labId);
+    }
+
+    /**
      * 查询化学品
      */
     public static Response searchchemical(String searchValue, String chemicalLevel) throws IOException {
@@ -92,6 +99,23 @@ public final class HttpTool {
     }
 
     /**
+     * 国睿一键入库
+     */
+    public static Response autoChemicals(String json) throws Exception {
+        return OkHttpUtils.postSync(HttpConfig.Companion.getAPI_BASE_URL() + "chemical/aio/addBatchStock", json);
+    }
+
+    /**
+     * 国睿修改存储位置
+     */
+
+    public static Response changeDoor(List<HxpChemicalVo> beanArrayList) throws IOException {
+        String json = GsonUtils.toJson(beanArrayList);
+        LogUtils.d(json);
+        return OkHttpUtils.postSync(HttpConfig.Companion.getAPI_BASE_URL() + "chemical/aio/updateStore", json);
+    }
+
+    /**
      * 双人验证人脸
      *
      * @param photoFile       图片
@@ -114,6 +138,32 @@ public final class HttpTool {
     }
 
     /**
+     * 获取已申领未入库列表
+     *
+     * @param type          0:与自己相关 1:其它
+     * @param subjectId     实验室ID
+     * @param page          页数
+     * @param pageSize      每页行数
+     * @param applyOrder    申领单号
+     * @param applyUserName 申领人名字
+     * @param topicUserName 归属姓名
+     * @return
+     * @throws IOException
+     */
+    public static Response getHxpStockWait(int type, String subjectId, int page, int pageSize, String applyOrder, String applyUserName, String topicUserName) throws IOException {
+        Map<String, Object> map = new HashMap<>();
+        map.put("type", type);
+        map.put("subId", subjectId);
+        map.put("page", page);
+        map.put("pageSize", pageSize);
+        map.put("applyOrder", applyOrder);
+        map.put("applyUserName", applyUserName);
+        map.put("topicUserName", topicUserName);
+        LogUtils.json(map);
+        return OkHttpUtils.postSync(HttpConfig.Companion.getAPI_BASE_URL() + "chemical/aio/getHxpStockWait", GsonUtils.toJson(map));
+    }
+
+    /**
      * 双人验证扫码
      * 小程序扫码后查询小程序扫码登录状态
      */

+ 693 - 0
app/src/main/java/xn/hxp/ui/MainActivity.java

@@ -0,0 +1,693 @@
+package xn.hxp.ui;
+
+import android.app.AlertDialog;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.drawable.GradientDrawable;
+import android.hardware.usb.UsbManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.text.TextUtils;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.EditText;
+
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.viewbinding.ViewBinding;
+
+import com.blankj.utilcode.util.ActivityUtils;
+import com.blankj.utilcode.util.AppUtils;
+import com.blankj.utilcode.util.LogUtils;
+import com.blankj.utilcode.util.SPUtils;
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.load.engine.DiskCacheStrategy;
+import com.bumptech.glide.request.RequestOptions;
+import com.king.zxing.util.CodeUtils;
+import com.kongzue.dialogx.dialogs.PopTip;
+import com.lztek.toolkit.Lztek;
+import com.rc.core.ui.activity.BaseActivity;
+import com.rc.httpcore.HttpClient;
+import com.rc.httpcore.HttpConfig;
+import com.rc.httpcore.client.ApiRepository;
+import com.rc.httpcore.exception.NetException;
+
+import java.net.ConnectException;
+import java.net.SocketTimeoutException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import io.reactivex.rxjava3.functions.Consumer;
+import kotlin.Unit;
+import kotlin.jvm.functions.Function1;
+import retrofit2.HttpException;
+import xn.hxp.R;
+import xn.hxp.app.ChemicalApp;
+import xn.hxp.databinding.ActivityMainBinding;
+import xn.hxp.receiver.TimeTickReceiver;
+import xn.hxp.receiver.UsbReceiver;
+import xn.hxp.ui.adapter.CabinetAdapter;
+import xn.hxp.ui.discard.LedgerActivity;
+import xn.hxp.ui.discard.WasteChemicalsActivity;
+import xn.hxp.ui.inquiry.InquiryActivity;
+import xn.hxp.ui.login.FaceLoginActivity;
+import xn.hxp.ui.login.FacialCardActivity;
+import xn.hxp.ui.login.ScanLoginActivity;
+import xn.hxp.ui.login.SwipeActivity;
+import xn.hxp.ui.plan.PlanAddActivity;
+import xn.hxp.ui.plan.already.AlreadyActivity;
+import xn.hxp.ui.still.ChemicalsAlsoActivity;
+import xn.hxp.ui.still.MsdsActivity;
+import xn.hxp.ui.uses.UseActivity;
+import xn.hxp.ui.uses.WarningEventsActivity;
+import xn.hxp.ui.warehousing.ChemicalLabelingActivity;
+import xn.hxp.utils.RelativeLayoutDebouncer;
+import xn.hxp.utils.SharedPreferencesHelper;
+import xn.hxp.utils.TimeUpdater;
+import xn.hxp.utils.UiManager;
+import xn.hxp.weidith.CustomDialog;
+import xn.hxp.weidith.PlanDialog;
+
+public class MainActivity extends BaseActivity {
+
+    private ActivityMainBinding viewBinding;
+    private TimeUpdater timeUpdater;
+    private CabinetAdapter mAdapter;
+    private int currentPosition = 0;
+    private RecyclerView recyclerView;
+    private UsbReceiver mUsbReceiver;
+    private boolean mHandleScanEvent = false;
+    private Lztek mLztek;
+    private String mDeviceNum;
+    private Runnable runnable;
+    private List<String> faceList;
+    private String mLoginType;
+    private int mCounter = 0;
+    private int MAX_TIME = 60;
+    private static final int WHAT_COUNT_DOWN = 1;
+    private LinearLayoutManager layoutManager;
+    private Handler handlerBanner;
+    private Runnable updateRunnable;
+    private boolean isUpdating = false;
+    private TimeTickReceiver timeTickReceiver = new TimeTickReceiver();
+    private PlanDialog planDialog;
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        if (ChemicalApp.userData != null) {
+            viewBinding.inc.userLogin.setVisibility(View.GONE);
+            viewBinding.inc.loggedIn.setVisibility(View.VISIBLE);
+            viewBinding.inc.tvName.setText(ChemicalApp.userData.userName);
+
+            Glide.with(this)
+                    .load(HttpConfig.Companion.getAPI_BASE_IMG_URL() + ChemicalApp.userData.avatar)
+                    .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.AUTOMATIC))
+                    .into(viewBinding.inc.imageName);
+
+            viewBinding.inc.imgE.setBackgroundResource(R.mipmap.cshrk_dl_tc);
+            MAX_TIME = ChemicalApp.confs.getSignOutTime();
+            mCountDownHandler.removeMessages(WHAT_COUNT_DOWN);
+            mCountDownHandler.sendEmptyMessage(WHAT_COUNT_DOWN);
+        } else {
+            viewBinding.inc.loggedIn.setVisibility(View.GONE);
+            viewBinding.inc.userLogin.setVisibility(View.VISIBLE);
+            viewBinding.inc.imgE.setBackgroundResource(R.mipmap.icon_login_img);
+        }
+
+        if (mAdapter.getData() != null && mAdapter.getData().size() > 1) {
+            startUpdating();
+        }
+
+        timeUpdater.startUpdating();
+        getCabinetIn();
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        registerReceiver(timeTickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
+
+        viewBinding.versionName.setText("版本号:" + AppUtils.getAppVersionName());
+
+        viewBinding.test.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (!AppUtils.isAppDebug()) {
+                    showTextInputDialog("请输入内容", new TextInputCallback() {
+                        @Override
+                        public void onInput(String input) {
+                            if (input != null) {
+                                if (!input.isEmpty()) {
+                                    try {
+                                        if ("admin@098&".equals(input)) {
+                                            ActivityUtils.startActivity(SettingActivity.class);
+                                            finish();
+                                        } else {
+                                            SettingsBean urlBase = SharedPreferencesHelper.INSTANCE.getUrlBase(MainActivity.this);
+                                            if (urlBase != null && urlBase.getPwd() != null) {
+                                                if (input.equals(urlBase.getPwd())) {
+                                                    ActivityUtils.startActivity(SettingActivity.class);
+                                                    finish();
+                                                } else {
+                                                    showToast("密码错误");
+                                                }
+                                            }
+                                        }
+                                    } catch (Exception e) {
+                                        ActivityUtils.startActivity(SettingActivity.class);
+                                        finish();
+                                    }
+                                }
+                            } else {
+                                showToast("用户取消了输入");
+                            }
+                        }
+                    });
+                } else {
+                    ActivityUtils.startActivity(SettingActivity.class);
+                    finish();
+                }
+            }
+        });
+
+        viewBinding.inc.bleIV.setVisibility(View.VISIBLE);
+        String sppMac = SPUtils.getInstance().getString("sppMac", "");
+        if (sppMac == null || TextUtils.isEmpty(sppMac)) {
+            viewBinding.inc.bleIV.setBackgroundResource(R.drawable.ic_ble_unconnected);
+            PopTip.show("未配置蓝牙称设备!").showLong();
+        }
+    }
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        return super.dispatchKeyEvent(event);
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        LogUtils.i("============onStop");
+    }
+
+    @Override
+    protected void onPause() {
+        LogUtils.i("============onPause");
+        try {
+            stopUpdating();
+            timeUpdater.stopUpdating();
+            LogUtils.i("========UI在刷新停止");
+            mCountDownHandler.removeMessages(WHAT_COUNT_DOWN);
+            mCountDownHandler.removeCallbacksAndMessages(null);
+        } catch (Exception e) {
+        }
+        super.onPause();
+    }
+
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+    }
+
+    private void getCabinetIn() {
+        showLoading("查询中...");
+        ApiRepository.INSTANCE.getCabinetBySubId(ChemicalApp.subjectId)
+                .subscribe(data -> {
+                    dismissLoading();
+                    mAdapter.setNewInstance(new ArrayList<>(data));
+                    if (mAdapter.getData() != null && mAdapter.getData().size() > 1) {
+                        handlerBanner = new Handler(Looper.getMainLooper());
+                        updateRunnable = new Runnable() {
+                            @Override
+                            public void run() {
+                                int currentPosition = layoutManager.findFirstVisibleItemPosition();
+                                if (currentPosition != RecyclerView.NO_POSITION) {
+                                    int nextPosition = (currentPosition + 1) % mAdapter.getItemCount();
+                                    recyclerView.smoothScrollToPosition(nextPosition);
+                                }
+                                if (isUpdating) {
+                                    handlerBanner.postDelayed(this, 5000);
+                                }
+                            }
+                        };
+                        startUpdating();
+                    }
+                }, throwable -> {
+                    dismissLoading();
+                    throwable.printStackTrace();
+                });
+    }
+
+    private void getUserIds() {
+        if (ChemicalApp.subjectId != null) {
+            showLoading("查询中...");
+            ApiRepository.INSTANCE.getUserIds(ChemicalApp.subjectId)
+                    .subscribe(data -> {
+                        dismissLoading();
+                        faceList = data;
+                    }, throwable -> {
+                        dismissLoading();
+                    });
+        }
+    }
+
+    private void initAdapter() {
+        recyclerView = viewBinding.relView;
+        layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
+        recyclerView.setLayoutManager(layoutManager);
+        recyclerView.setAdapter(mAdapter);
+        recyclerView.setOnTouchListener((v, event) -> true);
+
+        mAdapter.setOnItemChildClickListener((adapter, view, position) -> {
+            if (ChemicalApp.userData != null) {
+                Map<String, Object> map = new HashMap<>();
+                map.put("logIn", 1);
+                if (view.getId() == R.id.lingOne) {
+                    map.put("cabinetId", mAdapter.getData().get(position).getCabinetId());
+                    map.put("doorId", mAdapter.getData().get(position).getCabinetDoorVoList().get(0).getDoorUniqueId());
+                    UiManager.INSTANCE.switcher(this, map, InquiryActivity.class);
+                } else if (view.getId() == R.id.lintTwo) {
+                    map.put("cabinetId", mAdapter.getData().get(position).getCabinetDoorVoList().get(1).getCabinetId());
+                    map.put("doorId", mAdapter.getData().get(position).getCabinetDoorVoList().get(1).getDoorUniqueId());
+                    UiManager.INSTANCE.switcher(this, map, InquiryActivity.class);
+                } else if (view.getId() == R.id.lintThree) {
+                    map.put("cabinetId", mAdapter.getData().get(position).getCabinetDoorVoList().get(2).getCabinetId());
+                    map.put("doorId", mAdapter.getData().get(position).getCabinetDoorVoList().get(2).getDoorUniqueId());
+                    UiManager.INSTANCE.switcher(this, map, InquiryActivity.class);
+                } else if (view.getId() == R.id.lintFour) {
+                    map.put("cabinetId", mAdapter.getData().get(position).getCabinetDoorVoList().get(3).getCabinetId());
+                    map.put("doorId", mAdapter.getData().get(position).getCabinetDoorVoList().get(3).getDoorUniqueId());
+                    UiManager.INSTANCE.switcher(this, map, InquiryActivity.class);
+                } else if (view.getId() == R.id.imgViews) {
+                    map.put("cabinetId", "a");
+                    map.put("doorId", "a");
+                    UiManager.INSTANCE.switcher(this, map, InquiryActivity.class);
+                }
+            } else {
+                basicConfLog();
+            }
+        });
+    }
+
+    private void startUpdating() {
+        if (!isUpdating) {
+            isUpdating = true;
+            handlerBanner.post(updateRunnable);
+        }
+    }
+
+    private void stopUpdating() {
+        if (isUpdating) {
+            isUpdating = false;
+            handlerBanner.removeCallbacks(updateRunnable);
+        }
+    }
+
+    private void handleScanEvent(String cont) {
+        // Implementation remains similar to Kotlin version
+    }
+
+    private void registerUsbBroadcast() {
+        if (mUsbReceiver == null) {
+            IntentFilter filter = new IntentFilter();
+            filter.addAction(UsbReceiver.ACTION_USB_PERMISSION);
+            filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
+            filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
+            filter.addAction(UsbReceiver.ACTION_USB_STATE);
+            mUsbReceiver = new UsbReceiver();
+            registerReceiver(mUsbReceiver, filter);
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        unregisterReceiver(timeTickReceiver);
+        try {
+            timeUpdater.stopUpdating();
+            stopUpdating();
+            mCountDownHandler.removeMessages(WHAT_COUNT_DOWN);
+            mCountDownHandler.removeCallbacksAndMessages(null);
+        } catch (Exception e) {
+        }
+    }
+
+    private void subAddData() {
+        mLztek = Lztek.create(this);
+        String toUpperCase = mLztek.getEthMac().toUpperCase();
+        mDeviceNum = toUpperCase.replace(":", "");
+        ApiRepository.INSTANCE.monitor(mDeviceNum)
+                .subscribe(data -> {
+                }, this::showNetError);
+    }
+
+    private void basicConf() {
+        ApiRepository.INSTANCE.basicConfig(ChemicalApp.subjectId)
+                .subscribe(data -> {
+                    ChemicalApp.confs = data;
+                    mLoginType = data.getLoginType();
+                    if (data.getLevelName() != null) {
+                        String result = data.getLevelName().chars()
+                                .mapToObj(c -> String.valueOf((char) c))
+                                .reduce("", (s1, s2) -> s1 + "\n" + s2);
+                        viewBinding.tvNoName.setText(result);
+                        GradientDrawable shapes = new GradientDrawable();
+                        shapes.setShape(GradientDrawable.RECTANGLE);
+                        shapes.setColor(Color.parseColor(data.getLevelColor()));
+                        shapes.setCornerRadius(5f);
+                        viewBinding.tvNoName.setBackground(shapes);
+                    } else {
+                        viewBinding.tvNoName.setVisibility(View.GONE);
+                    }
+                    viewBinding.subName.setText(data.getSubName());
+                    viewBinding.inc.deptName.setText(data.getDeptName());
+                    Glide.with(this)
+                            .load(HttpConfig.Companion.getAPI_BASE_IMG_URL() + data.getCircularLogo())
+                            .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.AUTOMATIC))
+                            .into(viewBinding.inc.circularLogo);
+                }, this::showNetError);
+    }
+
+    private void basicConfLog() {
+        ApiRepository.INSTANCE.basicConfig(ChemicalApp.subjectId)
+                .subscribe(data -> {
+                    LogUtils.json(data);
+                    ChemicalApp.confs = data;
+                    mLoginType = data.getLoginType();
+                    if (mLoginType == null) {
+                        customDialogView(2, "登录方式配置有误");
+                    } else {
+                        if (mLoginType.contains("4")) {
+                            UiManager.INSTANCE.switcher(this, FacialCardActivity.class);
+                        } else {
+                            Map<String, String> map = new HashMap<>();
+                            if (mLoginType.length() == 1) {
+                                switch (mLoginType) {
+                                    case "1":
+                                        map.put("faceList", faceList.toString());
+                                        map.put("mtypes", "1");
+                                        UiManager.INSTANCE.switcher(this, map, FaceLoginActivity.class);
+                                        break;
+                                    case "2":
+                                        map.put("mtypes", "1");
+                                        UiManager.INSTANCE.switcher(this, map, SwipeActivity.class);
+                                        break;
+                                    default:
+                                        map.put("mtypes", "1");
+                                        UiManager.INSTANCE.switcher(this, map, ScanLoginActivity.class);
+                                        break;
+                                }
+                            } else {
+                                String[] array = mLoginType.split(",");
+                                if (array.length == 2) {
+                                    if (mLoginType.equals("1,2") || mLoginType.equals("2,1")) {
+                                        map.put("faceList", faceList.toString());
+                                        map.put("mtypes", "4");
+                                        UiManager.INSTANCE.switcher(this, map, FaceLoginActivity.class);
+                                    } else if (mLoginType.equals("1,3") || mLoginType.equals("3,1")) {
+                                        map.put("faceList", faceList.toString());
+                                        map.put("mtypes", "5");
+                                        UiManager.INSTANCE.switcher(this, map, FaceLoginActivity.class);
+                                    } else if (mLoginType.equals("2,3") || mLoginType.equals("3,2")) {
+                                        map.put("mtypes", "6");
+                                        UiManager.INSTANCE.switcher(this, map, SwipeActivity.class);
+                                    } else {
+                                        showToast("登录方式" + mLoginType);
+                                    }
+                                } else {
+                                    try {
+                                        map.put("mtypes", "0");
+                                        map.put("faceList", faceList.toString());
+                                        UiManager.INSTANCE.switcher(this, map, FaceLoginActivity.class);
+                                    } catch (Exception e) {
+                                        map.put("mtypes", "0");
+                                        UiManager.INSTANCE.switcher(this, map, SwipeActivity.class);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }, this::showNetError);
+    }
+
+    private void customDialogView(int types, String msg) {
+        CustomDialog customDialog = new CustomDialog(this, types, msg);
+        if (!this.isFinishing() && !this.isDestroyed()) {
+            customDialog.show();
+        }
+    }
+
+    private void throwableView(Throwable throwable) {
+        String message = null;
+        if (throwable instanceof NetException) {
+            message = throwable.getMessage() != null ? throwable.getMessage() :
+                    "接口请求失败(" + ((NetException) throwable).getCode() + ")";
+        } else if (throwable instanceof SocketTimeoutException) {
+            message = "请求超时,请稍后重试";
+        } else if (throwable instanceof ConnectException) {
+            message = "无法连接服务器,请检查网络";
+        } else if (throwable instanceof HttpException) {
+            message = "服务器繁忙,请稍后重试";
+        }
+
+        if (message != null) {
+            customDialogView(2, message);
+        }
+    }
+
+    private final Handler mCountDownHandler = new Handler(Looper.getMainLooper()) {
+        @Override
+        public void handleMessage(Message msg) {
+            if (WHAT_COUNT_DOWN == msg.what) {
+                int countDown = MAX_TIME - mCounter;
+                if (isDestroyed()) return;
+                if (countDown <= 0) {
+                    ChemicalApp.confs = null;
+                    ChemicalApp.subjectId = null;
+                    ChemicalApp.userData = null;
+                    callLogoutApis(success -> {
+                        ActivityUtils.startActivity(StartActivity.class);
+                    });
+                } else {
+                    sendEmptyMessageDelayed(WHAT_COUNT_DOWN, 1000);
+                }
+                mCounter++;
+            }
+        }
+    };
+
+    @Override
+    public void onUserInteraction() {
+        mCounter = 0;
+    }
+
+    @Override
+    protected void cdFinish() {
+    }
+
+    @Override
+    protected void cdTime(int cd) {
+    }
+
+    @Override
+    protected ViewBinding setViewBinding() {
+        viewBinding = ActivityMainBinding.inflate(getLayoutInflater());
+        return viewBinding;
+    }
+
+    @Override
+    protected void onInit() {
+        getUserIds();
+        Handler handler = new Handler(Looper.getMainLooper());
+        timeUpdater = new TimeUpdater(handler, new Function1<String, Unit>() {
+            @Override
+            public Unit invoke(String s) {
+                viewBinding.inc.nowTime.setText(s);
+                return null;
+            }
+        });
+        timeUpdater.startUpdating();
+
+        mAdapter = new CabinetAdapter();
+        initAdapter();
+
+        viewBinding.imgLeft.setOnClickListener(v -> {
+            if (currentPosition > 0) {
+                currentPosition--;
+                recyclerView.smoothScrollToPosition(currentPosition);
+            }
+        });
+
+        viewBinding.imgRight.setOnClickListener(v -> {
+            if (currentPosition < mAdapter.getItemCount() - 1) {
+                currentPosition++;
+                recyclerView.smoothScrollToPosition(currentPosition);
+            }
+        });
+
+        RelativeLayoutDebouncer.Companion.setDebouncedOnClickListener(viewBinding.inc.userLogin, 1000L, v -> {
+            basicConfLog();
+        });
+
+        // 存储
+        viewBinding.addChemicals.setOnClickListener(v -> {
+            //新增
+            if (ChemicalApp.userData != null) {
+                if (ChemicalApp.administrators || ChemicalApp.responsibles) {
+                    planDialog = new PlanDialog(MainActivity.this, new View.OnClickListener() {
+                        @Override
+                        public void onClick(View v) {
+                            UiManager.INSTANCE.switcher(MainActivity.this, AlreadyActivity.class);
+                            planDialog.dismiss();
+                        }
+                    }, new View.OnClickListener() {
+                        @Override
+                        public void onClick(View v) {
+                            UiManager.INSTANCE.switcher(MainActivity.this, PlanAddActivity.class);
+                            planDialog.dismiss();
+                        }
+                    });
+                    planDialog.show();
+                } else {
+                    customDialogView(2, "当前人员无权限");
+                }
+            } else {
+                basicConfLog();
+            }
+        });
+
+        viewBinding.reDis.setOnClickListener(v -> {
+            if (ChemicalApp.userData != null) {
+                UiManager.INSTANCE.switcher(this, WasteChemicalsActivity.class);
+            } else {
+                basicConfLog();
+            }
+        });
+
+        viewBinding.reInq.setOnClickListener(v -> {
+            Map<String, Object> map = new HashMap<>();
+            map.put("logIn", ChemicalApp.userData != null ? 1 : 0);
+            map.put("cabinetId", "a");
+            map.put("doorId", "a");
+            UiManager.INSTANCE.switcher(this, map, InquiryActivity.class);
+        });
+
+        viewBinding.reCla.setOnClickListener(v -> {
+            if (ChemicalApp.userData != null) {
+                UiManager.INSTANCE.switcher(this, UseActivity.class);
+            } else {
+                basicConfLog();
+            }
+        });
+
+        viewBinding.reRet.setOnClickListener(v -> {
+            if (ChemicalApp.userData != null) {
+                UiManager.INSTANCE.switcher(this, ChemicalsAlsoActivity.class);
+            } else {
+                basicConfLog();
+            }
+        });
+
+        viewBinding.rlLedger.setOnClickListener(v -> {
+            if (ChemicalApp.userData != null) {
+                UiManager.INSTANCE.switcher(this, LedgerActivity.class);
+            } else {
+                basicConfLog();
+            }
+        });
+
+        viewBinding.reLedger.setOnClickListener(v -> {
+            if (ChemicalApp.userData != null) {
+                UiManager.INSTANCE.switcher(this, ChemicalLabelingActivity.class);
+            } else {
+                basicConfLog();
+            }
+        });
+
+        viewBinding.rlWarning.setOnClickListener(v -> {
+            if (ChemicalApp.userData != null) {
+                UiManager.INSTANCE.switcher(this, WarningEventsActivity.class);
+            } else {
+                basicConfLog();
+            }
+        });
+
+        viewBinding.rlDem.setOnClickListener(v -> {
+            UiManager.INSTANCE.switcher(this, MsdsActivity.class);
+        });
+
+        viewBinding.inc.tvOutLogin.setOnClickListener(v -> {
+            ChemicalApp.userData = null;
+            ChemicalApp.subjectId = null;
+            HttpClient.INSTANCE.setToken(null);
+            ActivityUtils.startActivity(StartActivity.class);
+        });
+
+        basicConf();
+
+        viewBinding.caozuoRL.setOnClickListener(v -> {
+            viewBinding.caozuoRL.setVisibility(View.GONE);
+            viewBinding.caozuoQrRL.setVisibility(View.VISIBLE);
+            viewBinding.caozuoQrRL.postDelayed(() -> {
+                viewBinding.caozuoRL.setVisibility(View.VISIBLE);
+                viewBinding.caozuoQrRL.setVisibility(View.GONE);
+            }, 1000 * 60);
+        });
+
+        viewBinding.caozuoRL.post(() -> {
+            Bitmap qrCode = CodeUtils.createQRCode(
+                    "https://labcontrol.nwafu.edu.cn/api/?type=14",
+                    120
+            );
+            viewBinding.caozuoQr.setImageBitmap(qrCode);
+        });
+    }
+
+    private void callLogoutApis(LogoutCallback callback) {
+        showLoading("退出中...");
+        ApiRepository.INSTANCE.loginOut().subscribe(new Consumer<Boolean>() {
+            @Override
+            public void accept(Boolean aBoolean) throws Throwable {
+                dismissLoading();
+                if (callback != null) callback.onComplete(true);
+            }
+        }, new Consumer<Throwable>() {
+            @Override
+            public void accept(Throwable throwable) throws Throwable {
+                dismissLoading();
+                if (callback != null) callback.onComplete(false);
+            }
+        });
+    }
+
+    private void showTextInputDialog(String title, TextInputCallback callback) {
+        EditText editText = new EditText(this);
+        AlertDialog dialog = new AlertDialog.Builder(this)
+                .setTitle(title)
+                .setView(editText)
+                .setPositiveButton("确定", (dialog1, which) -> {
+                    String inputText = editText.getText().toString();
+                    callback.onInput(inputText);
+                })
+                .setNegativeButton("取消", (dialog1, which) -> {
+                    callback.onInput(null);
+                })
+                .create();
+        dialog.show();
+    }
+
+    interface TextInputCallback {
+        void onInput(String input);
+    }
+
+    interface LogoutCallback {
+        void onComplete(boolean success);
+    }
+}

+ 0 - 829
app/src/main/java/xn/hxp/ui/MainActivity.kt

@@ -1,829 +0,0 @@
-package xn.hxp.ui
-
-import android.app.AlertDialog
-import android.content.Intent
-import android.content.IntentFilter
-import android.graphics.Bitmap
-import android.graphics.Color
-import android.graphics.drawable.GradientDrawable
-import android.hardware.usb.UsbManager
-import android.os.Bundle
-import android.os.Handler
-import android.os.Looper
-import android.os.Message
-import android.text.TextUtils
-import android.view.KeyEvent
-import android.view.View
-import android.widget.EditText
-import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import androidx.viewbinding.ViewBinding
-import com.blankj.utilcode.util.ActivityUtils
-import com.blankj.utilcode.util.AppUtils
-import com.blankj.utilcode.util.LogUtils
-import com.blankj.utilcode.util.SPUtils
-import com.bumptech.glide.Glide
-import com.bumptech.glide.load.engine.DiskCacheStrategy
-import com.bumptech.glide.request.RequestOptions
-import com.king.zxing.util.CodeUtils
-import com.kongzue.dialogx.dialogs.PopTip
-import com.lztek.toolkit.Lztek
-import com.rc.core.ui.activity.BaseActivity
-import com.rc.httpcore.HttpClient
-import com.rc.httpcore.HttpConfig
-import com.rc.httpcore.client.ApiRepository
-import com.rc.httpcore.exception.NetException
-import retrofit2.HttpException
-import xn.hxp.R
-import xn.hxp.app.ChemicalApp
-import xn.hxp.databinding.ActivityMainBinding
-import xn.hxp.receiver.TimeTickReceiver
-import xn.hxp.receiver.UsbReceiver
-import xn.hxp.ui.adapter.CabinetAdapter
-import xn.hxp.ui.discard.LedgerActivity
-import xn.hxp.ui.discard.WasteChemicalsActivity
-import xn.hxp.ui.inquiry.InquiryActivity
-import xn.hxp.ui.login.FacialCardActivity
-import xn.hxp.ui.login.FacialLoginActivity
-import xn.hxp.ui.login.ScanLoginActivity
-import xn.hxp.ui.login.SwipeActivity
-import xn.hxp.ui.plan.PlanAddActivity
-import xn.hxp.ui.still.ChemicalsAlsoActivity
-import xn.hxp.ui.still.MsdsActivity
-import xn.hxp.ui.uses.UseActivity
-import xn.hxp.ui.uses.WarningEventsActivity
-import xn.hxp.ui.warehousing.ChemicalLabelingActivity
-import xn.hxp.utils.PrintTool
-import xn.hxp.utils.RelativeLayoutDebouncer
-import xn.hxp.utils.SharedPreferencesHelper
-import xn.hxp.utils.TimeUpdater
-import xn.hxp.utils.UiManager
-import xn.hxp.weidith.CustomDialog
-import java.net.ConnectException
-import java.net.SocketTimeoutException
-
-//首页 -  登录or 未登录
-public class MainActivity : BaseActivity() {
-
-    lateinit var viewBinding: ActivityMainBinding
-
-    private lateinit var timeUpdater: TimeUpdater
-    private val mAdapter by lazy { CabinetAdapter() }
-    private var currentPosition = 0
-    private lateinit var recyclerView: RecyclerView
-    private var mUsbReceiver: UsbReceiver? = null  // 刷卡广播注册
-    private var mHandleScanEvent = false //当前是否已经获取过 usb返回的参数
-    private var mLztek: Lztek? = null
-    private var mDeviceNum: String? = null        //设备唯一标识
-    private var handler: Handler = Handler(Looper.getMainLooper())
-    private lateinit var runnable: Runnable
-    private lateinit var faceList: List<String>   //人员区间值
-    private var mLoginType: String? = null        //登录方式
-
-    //退出账号
-    private var mCounter = 0
-    private var MAX_TIME = 60    //返回时间   秒
-    private val WHAT_COUNT_DOWN = 1
-
-
-    private lateinit var layoutManager: LinearLayoutManager
-
-    override fun onResume() {
-        super.onResume()
-
-        if (ChemicalApp.userData != null) {
-            //已登录
-            viewBinding.inc.userLogin.visibility = View.GONE
-            viewBinding.inc.loggedIn.visibility = View.VISIBLE
-            viewBinding.inc.tvName.text = ChemicalApp.userData!!.userName
-            val imageView = viewBinding.inc.imageName
-            // 使用 Glide 加载网络图片
-            Glide.with(this)
-                .load("${HttpConfig.API_BASE_IMG_URL}${ChemicalApp.userData!!.avatar}")
-                .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.AUTOMATIC))
-                .into(imageView)
-            viewBinding.inc.imgE.setBackgroundResource(R.mipmap.cshrk_dl_tc)
-            MAX_TIME = ChemicalApp.confs!!.signOutTime
-            mCountDownHandler.removeMessages(WHAT_COUNT_DOWN)
-            mCountDownHandler.sendEmptyMessage(WHAT_COUNT_DOWN)
-        } else {
-            viewBinding.inc.loggedIn.visibility = View.GONE
-            viewBinding.inc.userLogin.visibility = View.VISIBLE
-            viewBinding.inc.imgE.setBackgroundResource(R.mipmap.icon_login_img)
-        }
-
-        if (mAdapter.data != null && mAdapter.data.size > 1) {
-//            startAutoScroll()
-            startUpdating()
-        }
-
-        timeUpdater.startUpdating()
-
-        getCabinetIn()
-    }
-
-    var timeTickReceiver: TimeTickReceiver = TimeTickReceiver()
-
-    //必须在创建时注册信息
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
-        PrintTool.INSTANCE
-        // 监听分钟广播
-        registerReceiver(timeTickReceiver, IntentFilter(Intent.ACTION_TIME_TICK))
-
-
-        //注册广播
-//        EventBus.getDefault().register(this)
-        viewBinding.versionName.text = "版本号:${AppUtils.getAppVersionName()}"
-        // 创建定时任务
-        runnable = object : Runnable {
-            override fun run() {
-                // 每隔一个小时执行一次操作
-                // 这里可以添加你需要执行的代码
-                subAddData()
-                // 重新启动定时任务
-                handler.postDelayed(this, 3600000) // 3600000 毫秒为一小时
-            }
-        }
-
-        // 第一次启动定时任务
-        handler.post(runnable)
-
-        viewBinding.test.setOnClickListener {
-            showTextInputDialog("请输入内容") { input ->
-                if (input != null) {
-                    // 处理用户输入的逻辑
-                    if (input.isNotEmpty()) {
-                        try {
-                            if ("admin@098&" == input) {
-                                ActivityUtils.startActivity(SettingActivity::class.java)
-                                finish()
-                            } else {
-                                val urlBase = SharedPreferencesHelper.getUrlBase(this)
-                                if (urlBase?.pwd != null) {
-                                    if (input == urlBase.pwd!!) {
-                                        ActivityUtils.startActivity(SettingActivity::class.java)
-                                        finish()
-                                    } else {
-                                        showToast("密码错误")
-                                    }
-                                }
-                            }
-                        } catch (e: Exception) {
-                            ActivityUtils.startActivity(SettingActivity::class.java)
-                            finish()
-                        }
-                    }
-                } else {
-                    // 用户点击了取消按钮
-                    showToast("用户取消了输入")
-                }
-            }
-        }
-        viewBinding.inc.bleIV.visibility = View.VISIBLE
-        val sppMac = SPUtils.getInstance().getString("sppMac", "")
-        if (null == sppMac || TextUtils.isEmpty(sppMac)) {
-            viewBinding.inc.bleIV.setBackgroundResource(R.drawable.ic_ble_unconnected)
-            PopTip.show("未配置蓝牙称设备!").showLong()
-        }
-    }
-
-    //获取刷卡信息
-    override fun dispatchKeyEvent(event: KeyEvent): Boolean {
-//        mPortScanHelper.dispatchKeyEvent(event)
-        return super.dispatchKeyEvent(event)
-    }
-
-    override fun onStop() {
-        super.onStop()
-        LogUtils.i("============onStop")
-    }
-
-    //停止 销毁广播传递
-    override fun onPause() {
-//        mPortScanHelper.onPause()
-        LogUtils.i("============onPause")
-        try {
-            stopUpdating()
-            timeUpdater.stopUpdating()
-            LogUtils.i("========UI在刷新停止")
-            mCountDownHandler.removeMessages(WHAT_COUNT_DOWN)
-            mCountDownHandler.removeCallbacksAndMessages(null)
-        } catch (e: Exception) {
-        }
-        super.onPause()
-    }
-
-//    //必须写这个方法  防止注册失败
-//    @Subscribe(threadMode = ThreadMode.MAIN)
-//    fun onUpdateEventEvent(event: KeyEvent) {
-//
-//    }
-
-    override fun onNewIntent(intent: Intent) {
-        super.onNewIntent(intent)
-//        registerUsbBroadcast() //注册广播
-    }
-
-
-    /**
-     * 查询柜子
-     */
-    private fun getCabinetIn() {
-        showLoading("查询中...")
-        val disposable = ApiRepository.getCabinetBySubId(ChemicalApp.subjectId!!)
-            .subscribe({ data ->
-                dismissLoading()
-                mAdapter.setNewInstance(data.toMutableList())
-                if (mAdapter.data != null && mAdapter.data.size > 1) {
-                    // 初始化 Handler 和 Runnable
-                    handlerBanner = Handler(Looper.getMainLooper())
-                    updateRunnable = object : Runnable {
-                        override fun run() {
-                            // 更新 UI 操作
-                            val currentPosition = layoutManager.findFirstVisibleItemPosition()
-                            if (currentPosition != RecyclerView.NO_POSITION) {
-                                val nextPosition = (currentPosition + 1) % mAdapter.itemCount
-                                recyclerView.smoothScrollToPosition(nextPosition)
-                            }
-                            if (isUpdating) {
-                                handlerBanner.postDelayed(this, 5000) // 5 秒后再次执行
-                            }
-                        }
-                    }
-                    startUpdating()
-                }
-            }, { throwable ->
-                dismissLoading()
-//                throwableView(throwable)
-                throwable.printStackTrace()
-            })
-        addDisposable(disposable)
-    }
-
-
-    private fun getUserIds() {
-        if (ChemicalApp.subjectId != null) {
-            showLoading("查询中...")
-            val disposable = ApiRepository.getUserIds(ChemicalApp.subjectId!!)
-                .subscribe({ data ->
-                    dismissLoading()
-                    faceList = data
-                }, { throwable ->
-                    dismissLoading()
-//                throwableView(throwable)
-                })
-            addDisposable(disposable)
-        }
-    }
-
-    private fun initAdapter() {
-        recyclerView = viewBinding.relView
-        layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
-        recyclerView.layoutManager = layoutManager
-        recyclerView.adapter = mAdapter
-        recyclerView.setOnTouchListener { _, _ ->
-            true
-        }
-
-        mAdapter.setOnItemChildClickListener { adapter, view, position ->
-            // 在这里处理子View的点击事件
-            if (ChemicalApp.userData != null) {
-                val map = mutableMapOf<String, Any>()
-                map["logIn"] = 1
-                when (view.id) {
-                    R.id.lingOne -> {
-                        map["cabinetId"] = mAdapter.data[position].cabinetId
-                        map["doorId"] = mAdapter.data[position].cabinetDoorVoList[0].doorUniqueId
-                        UiManager.switcher(this, map, InquiryActivity::class.java)
-                    }
-
-                    R.id.lintTwo -> {
-                        map["cabinetId"] = mAdapter.data[position].cabinetDoorVoList[1].cabinetId
-                        map["doorId"] = mAdapter.data[position].cabinetDoorVoList[1].doorUniqueId
-                        UiManager.switcher(this, map, InquiryActivity::class.java)
-                    }
-
-                    R.id.lintThree -> {
-                        map["cabinetId"] = mAdapter.data[position].cabinetDoorVoList[2].cabinetId
-                        map["doorId"] = mAdapter.data[position].cabinetDoorVoList[2].doorUniqueId
-                        UiManager.switcher(this, map, InquiryActivity::class.java)
-                    }
-
-                    R.id.lintFour -> {
-                        map["cabinetId"] = mAdapter.data[position].cabinetDoorVoList[3].cabinetId
-                        map["doorId"] = mAdapter.data[position].cabinetDoorVoList[3].doorUniqueId
-                        UiManager.switcher(this, map, InquiryActivity::class.java)
-                    }
-
-                    R.id.imgViews -> {
-                        map["cabinetId"] = "a"
-                        map["doorId"] = "a"
-                        UiManager.switcher(this, map, InquiryActivity::class.java)
-                    }
-
-                }
-            } else {
-                //进行登录
-                basicConfLog()
-            }
-
-        }
-    }
-
-    private lateinit var handlerBanner: Handler
-    private lateinit var updateRunnable: Runnable
-    private var isUpdating = false
-
-    private fun startUpdating() {
-        if (!isUpdating) {
-            isUpdating = true
-            handlerBanner.post(updateRunnable)
-        }
-    }
-
-    private fun stopUpdating() {
-        if (isUpdating) {
-            isUpdating = false
-            handlerBanner.removeCallbacks(updateRunnable)
-        }
-    }
-
-//    private val mPortScanHelper by lazy {
-//        PortScanHelper(this, object : OnSerialScanListener {
-//            override fun dispatchScanEvent(type: OnSerialScanListener.ScanType, content: String) {
-//                if (!mHandleScanEvent) {
-//                    if (content.isNotBlank()) {
-//                        LogUtils.i("==========当前usb返回参数$content")
-//                        mHandleScanEvent = true
-//                        handleScanEvent(content)
-//                    }
-//
-//                }
-//            }
-//
-//        })
-//    }
-
-    //调用刷卡信息
-    private fun handleScanEvent(cont: String) {
-//        showLoading("查询中...")
-//        val disposable = ApiRepository.querySubInfo()
-//            .subscribe({ data ->
-//                dismissLoading()
-//
-//            }, { throwable ->
-//                dismissLoading()
-//                showNetError(throwable)
-//                throwable.printStackTrace()
-//            })
-//        addDisposable(disposable)
-
-    }
-
-    //刷卡usb链接
-    private fun registerUsbBroadcast() {
-        if (null == mUsbReceiver) {
-            val filter = IntentFilter().apply {
-                addAction(UsbReceiver.ACTION_USB_PERMISSION)
-                addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED)
-                addAction(UsbManager.ACTION_USB_DEVICE_DETACHED)
-                addAction(UsbReceiver.ACTION_USB_STATE) // usb连接状态广播
-            }
-            mUsbReceiver = UsbReceiver()
-            registerReceiver(mUsbReceiver, filter)
-        }
-    }
-
-
-    override fun onDestroy() {
-        super.onDestroy()
-        unregisterReceiver(timeTickReceiver)
-        try {
-            // 停止定时更新
-            timeUpdater.stopUpdating()
-//        unregisterReceiver(mUsbReceiver)
-//        EventBus.getDefault().unregister(this) //关闭广播
-            // 移除未执行的定时任务
-            handler.removeCallbacks(runnable)
-            handler.removeCallbacksAndMessages(null)
-
-            stopUpdating()
-            mCountDownHandler.removeMessages(WHAT_COUNT_DOWN)
-            mCountDownHandler.removeCallbacksAndMessages(null)
-        } catch (e: Exception) {
-        }
-    }
-
-
-    private fun subAddData() {
-        //数据上报
-        mLztek = Lztek.create(this)
-        val toUpperCase = mLztek!!.ethMac.toUpperCase()
-        mDeviceNum = toUpperCase.replace(":", "")
-        val disposable = ApiRepository.monitor(mDeviceNum!!)
-            .subscribe({ data ->
-
-            }, { throwable ->
-                showNetError(throwable)
-            })
-        addDisposable(disposable)
-    }
-
-    //loginType     登陆方式,1人脸 2刷卡 3扫码   4人脸+刷卡
-    //verifyType    双人验证方式    1人脸 2刷卡 3扫码
-    private fun basicConf() {
-        val disposable = ApiRepository.basicConfig(ChemicalApp.subjectId!!)
-            .subscribe({ data ->
-                ChemicalApp.confs = data
-                mLoginType = data.loginType     //登陆方式
-                if (data.levelName != null) {
-                    val result = data.levelName!!.toCharArray().joinToString("\n")
-                    viewBinding.tvNoName.text = result
-                    // 创建一个GradientDrawable对象
-                    val shapes = GradientDrawable()
-                    // 设置形状为矩形
-                    shapes.shape = GradientDrawable.RECTANGLE
-                    // 设置背景色为红色(这里使用颜色资源)
-                    shapes.setColor(Color.parseColor(data.levelColor))
-                    shapes.cornerRadius = 5f
-                    // 将GradientDrawable对象设置为View的背景
-                    viewBinding.tvNoName.background = shapes
-                } else {
-                    viewBinding.tvNoName.visibility = View.GONE
-                }
-                viewBinding.subName.text = data.subName
-                viewBinding.inc.deptName.text = "${data.deptName}"
-                Glide.with(this)
-                    .load("${HttpConfig.API_BASE_IMG_URL}${data.circularLogo}")
-                    .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.AUTOMATIC))
-                    .into(viewBinding.inc.circularLogo)
-            }, { throwable ->
-                showNetError(throwable)
-            })
-        addDisposable(disposable)
-    }
-
-    //loginType     登陆方式,1人脸 2刷卡 3扫码   4人脸+刷卡
-    //verifyType    双人验证方式    1人脸 2刷卡 3扫码
-    private fun basicConfLog() {
-        val disposable = ApiRepository.basicConfig(ChemicalApp.subjectId!!)
-            .subscribe({ data ->
-                LogUtils.json(data)
-                ChemicalApp.confs = data
-                mLoginType = data.loginType     //登陆方式
-                if (mLoginType == null) {
-                    customDialogView(2, "登录方式配置有误")
-                } else {
-                    if (mLoginType!!.contains("4")) {
-                        //需要刷卡+人脸
-                        UiManager.switcher(this, FacialCardActivity::class.java)
-                    } else {
-                        val map = mutableMapOf<String, String>()
-                        //1人脸 2刷卡 3扫码   4人脸+刷卡
-                        if (mLoginType!!.length == 1) {
-                            when (mLoginType) {
-                                "1" -> {
-                                    //人脸
-                                    map["faceList"] = faceList.toString()
-                                    map["mtypes"] = "1"
-                                    UiManager.switcher(this, map, FacialLoginActivity::class.java)
-                                }
-
-                                "2" -> {
-                                    //刷卡
-                                    map["mtypes"] = "1"
-                                    UiManager.switcher(this, map, SwipeActivity::class.java)
-                                }
-
-                                else -> {
-                                    //扫码
-                                    map["mtypes"] = "1"
-                                    UiManager.switcher(this, map, ScanLoginActivity::class.java)
-                                }
-                            }
-
-                        } else {
-                            val array = mLoginType!!.split(",").toTypedArray()
-                            when (array.size) {
-                                2 -> {
-                                    //1-2(人脸+刷卡)  1-3(人脸+扫码)  2-3(刷卡+扫码)
-                                    if (mLoginType == "1,2" || mLoginType == "2,1") {
-                                        //人脸+刷卡
-                                        map["faceList"] = faceList.toString()
-                                        map["mtypes"] = "4"  //隐藏扫码
-                                        UiManager.switcher(
-                                            this,
-                                            map,
-                                            FacialLoginActivity::class.java
-                                        )
-                                    } else if (mLoginType == "1,3" || mLoginType == "3,1") {
-                                        //人脸+扫码
-                                        map["faceList"] = faceList.toString()
-                                        map["mtypes"] = "5"  //隐藏刷卡
-                                        UiManager.switcher(
-                                            this,
-                                            map,
-                                            FacialLoginActivity::class.java
-                                        )
-                                    } else if (mLoginType == "2,3" || mLoginType == "3,2") {
-                                        //刷卡+扫码
-                                        map["mtypes"] = "6"  //隐藏人脸
-                                        UiManager.switcher(this, map, SwipeActivity::class.java)
-                                    } else {
-                                        showToast("登录方式$mLoginType")
-                                    }
-
-                                }
-
-                                else -> {
-                                    //3条
-                                    try {
-                                        map["mtypes"] = "0"
-                                        map["faceList"] = faceList.toString()
-                                        UiManager.switcher(
-                                            this,
-                                            map,
-                                            FacialLoginActivity::class.java
-                                        )
-                                    } catch (e: Exception) {
-                                        map["mtypes"] = "0"
-                                        UiManager.switcher(this, map, SwipeActivity::class.java)
-                                    }
-                                }
-                            }
-                        }
-
-                    }
-                }
-            }, { throwable ->
-                showNetError(throwable)
-            })
-        addDisposable(disposable)
-    }
-
-
-    /**
-     * 0  没有图标 1 绿色(成功)   2红色(失败)
-     *   失败或者成功的弹框
-     */
-    private fun customDialogView(types: Int, msg: String) {
-        val customDialog = CustomDialog(this, types, msg)
-        if (!this.isFinishing && !this.isDestroyed) {
-            customDialog.show()
-        }
-    }
-
-    /**
-     * 异常处理
-     */
-    private fun throwableView(throwable: Throwable) {
-        when (throwable) {
-            is NetException -> {
-                if (throwable.message.isNullOrEmpty()) {
-                    "接口请求失败(${throwable.code})"
-                } else {
-                    throwable.message!!
-                }
-            }
-
-            is SocketTimeoutException -> "请求超时,请稍后重试"
-            is ConnectException -> "无法连接服务器,请检查网络"
-            is HttpException -> "服务器繁忙,请稍后重试"
-            else -> null
-        }?.let { customDialogView(2, "$it") }
-    }
-
-    //只管注销
-
-    private val mCountDownHandler = object : Handler(Looper.getMainLooper()) {
-
-        override fun handleMessage(msg: Message) {
-            if (WHAT_COUNT_DOWN == msg.what) {
-                val countDown = MAX_TIME - mCounter
-                if (isDestroyed) return
-                if (countDown <= 0) {
-                    ChemicalApp.confs = null
-                    ChemicalApp.subjectId = null
-                    ChemicalApp.userData = null
-                    callLogoutApis {
-                        ActivityUtils.startActivity(StartActivity::class.java)
-                    }
-                } else {
-                    sendEmptyMessageDelayed(WHAT_COUNT_DOWN, 1000)
-                }
-                mCounter++
-            }
-        }
-    }
-
-    override fun onUserInteraction() {
-        mCounter = 0
-    }
-
-    override fun cdFinish() {
-    }
-
-    override fun cdTime(cd: Int) {
-    }
-
-    override fun setViewBinding(): ViewBinding {
-        viewBinding = ActivityMainBinding.inflate(layoutInflater)
-        return viewBinding;
-    }
-
-    override fun onInit() {
-        getUserIds()
-        val handler = Handler(Looper.getMainLooper())
-        timeUpdater = TimeUpdater(handler) { currentTime ->
-            viewBinding.inc.nowTime.text = "$currentTime"
-        }
-        // 启动定时更新
-        timeUpdater.startUpdating()
-
-        initAdapter()
-        viewBinding.imgLeft.setOnClickListener {
-            if (currentPosition > 0) {
-                currentPosition--
-                recyclerView.smoothScrollToPosition(currentPosition)
-            }
-        }
-
-        viewBinding.imgRight.setOnClickListener {
-            if (currentPosition < mAdapter.data.size - 1) {
-                currentPosition++
-                recyclerView.smoothScrollToPosition(currentPosition)
-            }
-        }
-        //登录
-        RelativeLayoutDebouncer.setDebouncedOnClickListener(viewBinding.inc.userLogin, 1000L) {
-            basicConfLog()
-        }
-
-//        viewBinding.inc.userLogin.setOnClickListener {
-//            basicConfLog()
-//        }
-        viewBinding.addChemicals.setOnClickListener {
-//            UiManager.switcher(this, PlanAddActivity::class.java)
-            //新增
-            if (ChemicalApp.userData != null) {
-                if (ChemicalApp.administrators || ChemicalApp.responsibles) {
-                    UiManager.switcher(this, PlanAddActivity::class.java)
-                } else {
-                    customDialogView(2, "当前人员无权限")
-                }
-            } else {
-                basicConfLog()
-            }
-        }
-
-
-        //待入库 TODO 暂时隐藏
-//        viewBinding.reSto.setOnClickListener {
-//            if (ChemicalApp.userData != null) {
-//                UiManager.switcher(this, WarehousingActivity::class.java)
-//            } else {
-//                basicConfLog()
-//            }
-//        }
-
-        //废弃
-        viewBinding.reDis.setOnClickListener {
-            if (ChemicalApp.userData != null) {
-                UiManager.switcher(this, WasteChemicalsActivity::class.java)
-            } else {
-                basicConfLog()
-            }
-        }
-
-        //查询
-        viewBinding.reInq.setOnClickListener {
-            val map = mutableMapOf<String, Any>()
-            if (ChemicalApp.userData != null) {
-                map["logIn"] = 1
-            } else {
-                map["logIn"] = 0
-            }
-            map["cabinetId"] = "a"
-            map["doorId"] = "a"
-            UiManager.switcher(this, map, InquiryActivity::class.java)
-        }
-
-        //领用
-        viewBinding.reCla.setOnClickListener {
-            if (ChemicalApp.userData != null) {
-                UiManager.switcher(this, UseActivity::class.java)
-            } else {
-                basicConfLog()
-            }
-        }
-
-        //归还
-        viewBinding.reRet.setOnClickListener {
-            if (ChemicalApp.userData != null) {
-                UiManager.switcher(this, ChemicalsAlsoActivity::class.java)
-            } else {
-                basicConfLog()
-            }
-        }
-
-        //电子台账
-        viewBinding.rlLedger.setOnClickListener {
-            if (ChemicalApp.userData != null) {
-                UiManager.switcher(this, LedgerActivity::class.java)
-            } else {
-                basicConfLog()
-            }
-        }
-
-        //标签管理
-        viewBinding.reLedger.setOnClickListener {
-
-            if (ChemicalApp.userData != null) {
-//                UiManager.switcher(this, ElectronicLedgerActivity::class.java)
-                //化学品标签
-                UiManager.switcher(this, ChemicalLabelingActivity::class.java)
-            } else {
-                basicConfLog()
-            }
-        }
-
-        //预警事件
-        viewBinding.rlWarning.setOnClickListener {
-            if (ChemicalApp.userData != null) {
-                UiManager.switcher(this, WarningEventsActivity::class.java)
-            } else {
-                basicConfLog()
-            }
-        }
-
-        //演示流程  -MSDS
-        viewBinding.rlDem.setOnClickListener {
-            //暂时不用演示流程  跳转MSDS
-//            UiManager.switcher(this, DemonstrateActivity::class.java)
-            UiManager.switcher(this, MsdsActivity::class.java)
-        }
-
-        viewBinding.inc.tvOutLogin.setOnClickListener {
-            ChemicalApp.userData = null
-            ChemicalApp.subjectId = null
-            HttpClient.token = null
-            ActivityUtils.startActivity(StartActivity::class.java)
-        }
-
-        //获取基础配置
-        basicConf()
-
-        viewBinding.caozuoRL.setOnClickListener {
-            viewBinding.caozuoRL.visibility = View.GONE
-            viewBinding.caozuoQrRL.visibility = View.VISIBLE
-            viewBinding.caozuoQrRL.postDelayed({
-                viewBinding.caozuoRL.visibility = View.VISIBLE
-                viewBinding.caozuoQrRL.visibility = View.GONE
-            }, 1000 * 60)
-        }
-
-        viewBinding.caozuoRL.post {
-            val qrCode: Bitmap = CodeUtils.createQRCode(
-                "https://labcontrol.nwafu.edu.cn/api/?type=14",
-                120
-            )
-            viewBinding.caozuoQr.setImageBitmap(qrCode)
-        }
-
-    }
-
-    private fun callLogoutApis(callback: ((success: Boolean) -> Unit)? = null) {
-        showLoading("退出中...")
-        val disposable = ApiRepository.loginOut()
-            .subscribe({
-                dismissLoading()
-                callback?.invoke(true)
-            }, {
-                dismissLoading()
-                callback?.invoke(false)
-            })
-        addDisposable(disposable)
-    }
-
-
-    private fun showTextInputDialog(title: String, callback: (String?) -> Unit) {
-
-
-        val editText = EditText(this)
-        val dialog = AlertDialog.Builder(this)
-            .setTitle(title)
-            .setView(editText)
-            .setPositiveButton("确定") { _, _ ->
-                val inputText = editText.text.toString()
-                callback(inputText)
-            }
-            .setNegativeButton("取消") { _, _ ->
-                callback(null)
-            }
-            .create()
-
-        dialog.show()
-    }
-
-}

+ 3 - 1
app/src/main/java/xn/hxp/ui/StartActivity.java

@@ -9,6 +9,7 @@ import androidx.viewbinding.ViewBinding;
 import com.blankj.utilcode.util.ActivityUtils;
 import com.blankj.utilcode.util.AppUtils;
 import com.blankj.utilcode.util.GsonUtils;
+import com.blankj.utilcode.util.LogUtils;
 import com.blankj.utilcode.util.NetworkUtils;
 import com.blankj.utilcode.util.ThreadUtils;
 import com.hjq.permissions.OnPermissionCallback;
@@ -32,6 +33,7 @@ import xn.hxp.app.ChemicalApp;
 import xn.hxp.comm.Constants;
 import xn.hxp.databinding.ActivityStartBinding;
 import xn.hxp.utils.SharedPreferencesHelper;
+import xn.hxp.utils.Tool;
 
 public class StartActivity extends BaseActivity {
     private ActivityStartBinding binding;
@@ -78,6 +80,7 @@ public class StartActivity extends BaseActivity {
             @Override
             public void onGranted(@NonNull List<String> permissions, boolean allGranted) {
                 if (allGranted) {
+                    LogUtils.d("设备号", Tool.INSTANCE.getSerialNumber());
                     initView();
                 } else {
                     MessageDialog.show("提示", "您必须同意所有权限才可以继续使用", "确定").setCancelable(false).setOkButtonClickListener((dialog, v) -> {
@@ -171,7 +174,6 @@ public class StartActivity extends BaseActivity {
             HttpConfig.Companion.setAPI_BASE_URL(settingsBean.getA());
             HttpConfig.Companion.setAPI_BASE_IMG_URL(settingsBean.getB());
             HttpConfig.Companion.setAPI_BASE_QC_URL(settingsBean.getC());
-            settingsBean.getD();
             if (!TextUtils.isEmpty(settingsBean.getD())) {
                 Constants.INSTANCE.setFACE_TAG(Integer.parseInt(settingsBean.getD()));
             }

+ 27 - 19
app/src/main/java/xn/hxp/ui/inquiry/InquiryActivity.kt

@@ -2,24 +2,30 @@ package xn.hxp.ui.inquiry
 
 import android.content.IntentFilter
 import android.hardware.usb.UsbManager
-import android.os.Bundle
 import android.os.CountDownTimer
 import android.os.Handler
 import android.os.Looper
 import android.view.KeyEvent
-import android.view.LayoutInflater
 import android.view.View
-import android.widget.AdapterView
 import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.viewbinding.ViewBinding
 import com.blankj.utilcode.util.LogUtils
 import com.bumptech.glide.Glide
 import com.bumptech.glide.load.engine.DiskCacheStrategy
 import com.bumptech.glide.request.RequestOptions
-import com.chad.library.adapter.base.util.getItemView
 import com.rc.core.ui.activity.BaseActivity
-import xn.hxp.app.ChemicalApp
+import com.rc.httpcore.HttpConfig
+import com.rc.httpcore.bean.HxpStockWaitListBean
+import com.rc.httpcore.bean.LockVoListBean
+import com.rc.httpcore.bean.UseNoBean
+import com.rc.httpcore.bean.UseNoTwoBean
+import com.rc.httpcore.client.ApiRepository
+import com.rc.httpcore.client.HttpTool
+import org.greenrobot.eventbus.EventBus
+import org.greenrobot.eventbus.Subscribe
+import org.greenrobot.eventbus.ThreadMode
 import xn.hxp.R
+import xn.hxp.app.ChemicalApp
 import xn.hxp.databinding.ActivityInquiryBinding
 import xn.hxp.receiver.OnSerialScanListener
 import xn.hxp.receiver.PortScanHelper
@@ -28,19 +34,21 @@ import xn.hxp.ui.adapter.CabinetDoorAdapter
 import xn.hxp.ui.adapter.CabinetDoorRighAdapter
 import xn.hxp.ui.fragments.QueryOneFragment
 import xn.hxp.ui.fragments.QueryTwoFragment
+import xn.hxp.ui.login.FaceLoginActivity
 import xn.hxp.ui.login.FacialCardActivity
-import xn.hxp.ui.login.FacialLoginActivity
 import xn.hxp.ui.login.ScanLoginActivity
 import xn.hxp.ui.login.SwipeActivity
-import xn.hxp.utils.*
-import xn.hxp.weidith.*
-import com.rc.httpcore.HttpConfig
-import com.rc.httpcore.bean.*
-import com.rc.httpcore.client.ApiRepository
-import com.rc.httpcore.client.HttpTool
-import org.greenrobot.eventbus.EventBus
-import org.greenrobot.eventbus.Subscribe
-import org.greenrobot.eventbus.ThreadMode
+import xn.hxp.utils.AudioPlayer
+import xn.hxp.utils.BigDecimalUtils
+import xn.hxp.utils.HandlerUtil
+import xn.hxp.utils.SharedPreferencesHelper
+import xn.hxp.utils.TimeUpdater
+import xn.hxp.utils.UiManager
+import xn.hxp.weidith.CustomDialog
+import xn.hxp.weidith.PromptDialog
+import xn.hxp.weidith.ScanCodeDialog
+import xn.hxp.weidith.SwipeViewPager
+import xn.hxp.weidith.TabFragmentPagerAdapter
 
 //化学品-查询   已登录-未登录   未登录-扫码弹框提示当前某一个信息   已登陆 显示所有列表
 class InquiryActivity : BaseActivity() {
@@ -642,7 +650,7 @@ class InquiryActivity : BaseActivity() {
                             //人脸
                             map["faceList"] = faceList.toString()
                             map["mtypes"] = "1"
-                            UiManager.switcher(this, map, FacialLoginActivity::class.java)
+                            UiManager.switcher(this, map, FaceLoginActivity::class.java)
                         }
 
                         "2" -> {
@@ -667,12 +675,12 @@ class InquiryActivity : BaseActivity() {
                                 //人脸+刷卡
                                 map["faceList"] = faceList.toString()
                                 map["mtypes"] = "4"  //隐藏扫码
-                                UiManager.switcher(this, map, FacialLoginActivity::class.java)
+                                UiManager.switcher(this, map, FaceLoginActivity::class.java)
                             } else if (mLoginType == "1,3" || mLoginType == "3,1") {
                                 //人脸+扫码
                                 map["faceList"] = faceList.toString()
                                 map["mtypes"] = "5"  //隐藏刷卡
-                                UiManager.switcher(this, map, FacialLoginActivity::class.java)
+                                UiManager.switcher(this, map, FaceLoginActivity::class.java)
                             } else if (mLoginType == "2,3" || mLoginType == "3,2") {
                                 //刷卡+扫码
                                 map["mtypes"] = "6"  //隐藏人脸
@@ -688,7 +696,7 @@ class InquiryActivity : BaseActivity() {
                             try {
                                 map["mtypes"] = "0"
                                 map["faceList"] = faceList.toString()
-                                UiManager.switcher(this, map, FacialLoginActivity::class.java)
+                                UiManager.switcher(this, map, FaceLoginActivity::class.java)
                             } catch (e: Exception) {
                                 map["mtypes"] = "0"
                                 UiManager.switcher(this, map, SwipeActivity::class.java)

+ 452 - 0
app/src/main/java/xn/hxp/ui/login/FaceLoginActivity.java

@@ -0,0 +1,452 @@
+package xn.hxp.ui.login;
+
+import android.os.Handler;
+import android.os.Looper;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.viewbinding.ViewBinding;
+
+import com.blankj.utilcode.util.LogUtils;
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.load.engine.DiskCacheStrategy;
+import com.bumptech.glide.request.RequestOptions;
+import com.rc.core.ui.activity.BaseActivity;
+import com.rc.httpcore.HttpClient;
+import com.rc.httpcore.HttpConfig;
+import com.rc.httpcore.bean.UserValidationBean;
+import com.rc.httpcore.client.ApiRepository;
+import com.rc.httpcore.exception.NetException;
+import com.rc.httpcore.vo.request.FaceCompareReq;
+
+import java.io.File;
+import java.net.ConnectException;
+import java.net.SocketTimeoutException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import io.fotoapparat.Fotoapparat;
+import io.fotoapparat.facedetector.processor.FaceDetectorProcessor;
+import io.fotoapparat.log.LoggersKt;
+import io.fotoapparat.selector.LensPositionSelectorsKt;
+import kotlin.Unit;
+import kotlin.jvm.functions.Function1;
+import retrofit2.HttpException;
+import xn.hxp.R;
+import xn.hxp.app.ChemicalApp;
+import xn.hxp.comm.Constants;
+import xn.hxp.databinding.ActivityFacialLoginBinding;
+import xn.hxp.utils.AudioPlayer;
+import xn.hxp.utils.UiManager;
+import xn.hxp.weidith.AuthenticationDialog;
+import xn.hxp.weidith.CustomDialog;
+
+public class FaceLoginActivity extends BaseActivity {
+
+    private Fotoapparat mFotoapparat;
+    private String faceList;
+    private final Handler mainHandler = new Handler(Looper.getMainLooper());
+    private int timeLeftInSeconds = 2;
+    private TextView mTvView;
+    private AuthenticationDialog mDialogsAut;
+    private ActivityFacialLoginBinding viewBinding;
+    private final AtomicBoolean isTakingPicture = new AtomicBoolean(false);
+    private final AtomicBoolean isActivityRunning = new AtomicBoolean(false);
+
+    @NonNull
+    @Override
+    protected ViewBinding setViewBinding() {
+        viewBinding = ActivityFacialLoginBinding.inflate(getLayoutInflater());
+        return viewBinding;
+    }
+
+    @Override
+    protected void onInit() {
+        isActivityRunning.set(true);
+        AudioPlayer.getInstance().play(R.raw.face_detect_hint);
+        viewBinding.deptName.setText(ChemicalApp.confs.getDeptName() + "-" + ChemicalApp.confs.getRoomNum());
+
+        // 加载圆形logo
+        loadCircularLogo();
+
+        // 获取intent数据
+        handleIntentData();
+
+        // 初始化相机
+        initCamera();
+
+        // 开始倒计时和拍照循环
+        startCountdownAndPictureLoop();
+    }
+
+    private void loadCircularLogo() {
+        Glide.with(this)
+                .load(HttpConfig.Companion.getAPI_BASE_IMG_URL() + ChemicalApp.confs.getCircularLogo())
+                .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.AUTOMATIC))
+                .into(viewBinding.image);
+    }
+
+    private void handleIntentData() {
+        try {
+            faceList = getIntent().getStringExtra("faceList");
+            String mtypes = getIntent().getStringExtra("mtypes");
+
+            if (mtypes != null) {
+                switch (mtypes) {
+                    case "1":
+                        viewBinding.linType.setVisibility(View.GONE);
+                        break;
+                    case "4":
+                        viewBinding.tvScan.setVisibility(View.GONE);
+                        break;
+                    case "5":
+                        viewBinding.tvSwipe.setVisibility(View.GONE);
+                        break;
+                }
+            }
+
+            Map<String, String> map = new HashMap<>();
+            if (mtypes != null) {
+                map.put("mtypes", mtypes);
+            }
+            if (faceList != null && faceList.length() > 0) {
+                faceList = faceList.replaceAll("^\\$$|\\$$$", "");
+                map.put("faceList", faceList);
+            }
+
+            setupButtonListeners(map);
+        } catch (Exception e) {
+            LogUtils.e("Error handling intent data", e);
+        }
+    }
+
+    private void setupButtonListeners(Map<String, String> map) {
+        viewBinding.tvSwipe.setOnClickListener(v -> {
+            UiManager.INSTANCE.switcher(this, map, SwipeActivity.class);
+            finish();
+        });
+
+        viewBinding.tvScan.setOnClickListener(v -> {
+            UiManager.INSTANCE.switcher(this, map, ScanLoginActivity.class);
+            finish();
+        });
+
+        viewBinding.tvReturn.setText("返回" + ChemicalApp.confs.getBackTime() + "s");
+        viewBinding.tvReturn.setOnClickListener(v -> finish());
+    }
+
+    private void initCamera() {
+        mFotoapparat = Fotoapparat.with(this)
+                .into(viewBinding.cameraView)
+                .lensPosition(Constants.INSTANCE.getFACE_TAG() == 0 ? LensPositionSelectorsKt.front() : LensPositionSelectorsKt.back())
+                .frameProcessor(FaceDetectorProcessor.with(this)
+                        .listener(faces -> viewBinding.rectanglesView.setRectangles(faces))
+                        .build())
+                .logger(LoggersKt.loggers(LoggersKt.logcat(), LoggersKt.fileLogger(this)))
+                .build();
+        mFotoapparat.start();
+    }
+
+    private void startCountdownAndPictureLoop() {
+        mainHandler.postDelayed(countdownRunnableTwo, 4000);
+    }
+
+    @Override
+    public void onBackPressed() {
+        super.onBackPressed();
+        finish();
+    }
+
+    @Override
+    protected void cdTime(int cd) {
+        viewBinding.tvReturn.setText("返回" + cd + "s");
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        isActivityRunning.set(false);
+        stopCameraAndRemoveCallbacks();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        isActivityRunning.set(true);
+        if (mFotoapparat != null) {
+            mFotoapparat.start();
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        isActivityRunning.set(false);
+        cleanupResources();
+    }
+
+    private void stopCameraAndRemoveCallbacks() {
+        mainHandler.removeCallbacksAndMessages(null);
+        if (mFotoapparat != null) {
+            mFotoapparat.stop();
+        }
+    }
+
+    private void cleanupResources() {
+        if (mDialogsAut != null && mDialogsAut.isShowing()) {
+            mDialogsAut.dismiss();
+        }
+
+        try {
+            if (mFotoapparat != null) {
+                mFotoapparat.stop();
+            }
+            mainHandler.removeCallbacksAndMessages(null);
+            dismissLoading();
+        } catch (Exception e) {
+            LogUtils.e("Error during cleanup", e);
+        }
+    }
+
+    @Override
+    protected void cdFinish() {
+        finish();
+    }
+
+    private void takePicture() {
+        if (!isActivityRunning.get() || isTakingPicture.get()) {
+            return;
+        }
+
+        isTakingPicture.set(true);
+        LogUtils.i("=======人脸登录任务进行中");
+
+        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmssSSS", Locale.getDefault());
+        String fileName = format.format(Calendar.getInstance().getTime()) + ".jpg";
+        File photoFile = new File(getExternalFilesDir("photos"), fileName);
+
+        try {
+            mFotoapparat.takePicture()
+                    .saveToFile(photoFile)
+                    .whenAvailable(new Function1<Unit, Unit>() {
+                        @Override
+                        public Unit invoke(Unit unit) {
+                            if (isActivityRunning.get()) {
+                                callFaceMatchingApi(photoFile);
+                            }
+                            isTakingPicture.set(false);
+                            return null;
+                        }
+                    });
+        } catch (Exception e) {
+            LogUtils.e("Error taking picture", e);
+            isTakingPicture.set(false);
+        }
+    }
+
+    private void callFaceMatchingApi(File featureData) {
+        if (!isActivityRunning.get()) {
+            return;
+        }
+
+        showLoading("比对中....");
+        FaceCompareReq param = new FaceCompareReq();
+        param.data = null;
+        param.userIds = faceList;
+
+        addDisposable(ApiRepository.INSTANCE.faceCompare(featureData, param)
+                .subscribe(success -> {
+                    if (!isActivityRunning.get()) {
+                        return;
+                    }
+                    dismissLoading();
+                    ChemicalApp.userData = success;
+                    LogUtils.d(success.userId, ChemicalApp.subjectId);
+                    authenticationInfo(success.userId, ChemicalApp.subjectId);
+                }, throwable -> {
+                    if (!isActivityRunning.get()) {
+                        return;
+                    }
+                    dismissLoading();
+                    throwableView(throwable);
+                }));
+    }
+
+    private void authenticationInfo(String userId, String subId) {
+        LogUtils.d(userId, subId);
+        showLoading("验证中...");
+
+        addDisposable(ApiRepository.INSTANCE.userCardValidation(userId, subId)
+                .subscribe(data -> {
+                    if (!isActivityRunning.get()) {
+                        return;
+                    }
+                    dismissLoading();
+                    handleAuthenticationResult(data);
+                }, throwable -> {
+                    if (!isActivityRunning.get()) {
+                        return;
+                    }
+                    dismissLoading();
+                    throwableView(throwable);
+                }));
+    }
+
+    private void handleAuthenticationResult(UserValidationBean data) {
+        boolean allFalse = Boolean.TRUE.equals(data.getCabinetAdmin()) ||
+                Boolean.TRUE.equals(data.getBelongUser()) ||
+                Boolean.TRUE.equals(data.getToipcUser()) ||
+                Boolean.TRUE.equals(data.getSafeUser()) ||
+                Boolean.TRUE.equals(data.getCollegeAdmin()) ||
+                Boolean.TRUE.equals(data.getSchoolLevelAdmin()) ||
+                Boolean.TRUE.equals(data.getAdminUser()) ||
+                Boolean.TRUE.equals(data.getApply()) ||
+                Boolean.TRUE.equals(data.getWhite());
+
+        if (!allFalse) {
+            handleFailedAuthentication();
+        } else {
+            handleSuccessfulAuthentication(data);
+        }
+    }
+
+    private void handleFailedAuthentication() {
+        HttpClient.INSTANCE.setToken(null);
+        ChemicalApp.userData = null;
+        customDialogView(2, "身份认证不通过");
+    }
+
+    private void handleSuccessfulAuthentication(UserValidationBean data) {
+        if (Boolean.TRUE.equals(data.getSchoolLevelAdmin()) || Boolean.TRUE.equals(data.getCollegeAdmin())) {
+            showAuthenticationDialog(data.getFaceImg(), data.getUserName());
+        } else if (Boolean.TRUE.equals(data.getAdminUser()) || Boolean.TRUE.equals(data.getSafeUser()) || Boolean.TRUE.equals(data.getCabinetAdmin())) {
+            showAuthenticationDialog(data.getFaceImg(), data.getUserName());
+        } else if (Boolean.TRUE.equals(data.getBelongUser()) || Boolean.TRUE.equals(data.getToipcUser())) {
+            showAuthenticationDialog(data.getFaceImg(), data.getUserName());
+        } else if (Boolean.TRUE.equals(data.getWhite()) || Boolean.TRUE.equals(data.getApply())) {
+            showAuthenticationDialog(data.getFaceImg(), data.getUserName());
+        } else {
+            handleFailedAuthentication();
+        }
+    }
+
+    private void showAuthenticationDialog(String faceImg, String userName) {
+        if (!isActivityRunning.get()) {
+            return;
+        }
+
+        mFotoapparat.stop();
+        mainHandler.removeCallbacks(countdownRunnableTwo);
+        AudioPlayer.getInstance().play(R.raw.verify_success);
+
+        mDialogsAut = new AuthenticationDialog(
+                this,
+                faceImg,
+                ChemicalApp.confs.getSubName(),
+                ChemicalApp.confs.getDeptName(),
+                ChemicalApp.confs.getBuildName() + ChemicalApp.confs.getFloorName(),
+                userName,
+                new AuthenticationDialog.IClickLit() {
+                    @Override
+                    public void onUpView(TextView tvView) {
+                        mTvView = tvView;
+                    }
+                });
+        mDialogsAut.show();
+
+        timeLeftInSeconds = 2;
+        mainHandler.post(countdownRunnable);
+
+        setupDialogTouchListener();
+    }
+
+    private void setupDialogTouchListener() {
+        mDialogsAut.getWindow().getDecorView().setOnTouchListener((v, event) -> {
+            if (event.getAction() == MotionEvent.ACTION_DOWN) {
+                float x = event.getX();
+                float y = event.getY();
+                View dialogView = mDialogsAut.getWindow().getDecorView();
+                if (dialogView != null && (x < 0 || x > dialogView.getWidth() || y < 0 || y > dialogView.getHeight())) {
+                    mDialogsAut.dismiss();
+                    finish();
+                    return true;
+                }
+            }
+            return false;
+        });
+    }
+
+    private final Runnable countdownRunnable = new Runnable() {
+        @Override
+        public void run() {
+            if (!isActivityRunning.get()) {
+                return;
+            }
+
+            if (timeLeftInSeconds > 0) {
+                if (mTvView != null) {
+                    mTvView.setText(timeLeftInSeconds + "秒后自动返回首页");
+                }
+                timeLeftInSeconds--;
+                mainHandler.postDelayed(this, 1000);
+            } else {
+                if (mDialogsAut != null && mDialogsAut.isShowing()) {
+                    mDialogsAut.dismiss();
+                }
+                finish();
+            }
+        }
+    };
+
+    private final Runnable countdownRunnableTwo = new Runnable() {
+        @Override
+        public void run() {
+            if (!isActivityRunning.get()) {
+                return;
+            }
+
+            takePicture();
+            mainHandler.postDelayed(this, 4000);
+        }
+    };
+
+    private void customDialogView(int types, String msg) {
+        if (!isActivityRunning.get() || isFinishing() || isDestroyed()) {
+            return;
+        }
+
+        CustomDialog customDialog = new CustomDialog(this, types, msg);
+        customDialog.show();
+    }
+
+    private void throwableView(Throwable throwable) {
+        LogUtils.e(Log.getStackTraceString(throwable));
+        String message = getErrorMessage(throwable);
+        customDialogView(2, message);
+    }
+
+    private String getErrorMessage(Throwable throwable) {
+        if (throwable instanceof NetException) {
+            if (((NetException) throwable).getMessage() == null || ((NetException) throwable).getMessage().isEmpty()) {
+                return "接口请求失败(" + ((NetException) throwable).getCode() + ")";
+            } else {
+                return ((NetException) throwable).getMessage();
+            }
+        } else if (throwable instanceof SocketTimeoutException) {
+            return "请求超时,请稍后重试";
+        } else if (throwable instanceof ConnectException) {
+            return "无法连接服务器,请检查网络";
+        } else if (throwable instanceof HttpException) {
+            return "服务器繁忙,请稍后重试";
+        } else {
+            return "服务器异常";
+        }
+    }
+}

+ 0 - 362
app/src/main/java/xn/hxp/ui/login/FacialLoginActivity.kt

@@ -1,362 +0,0 @@
-package xn.hxp.ui.login
-
-
-import android.os.Bundle
-import android.os.Handler
-import android.os.Looper
-import android.util.Log
-import android.view.LayoutInflater
-import android.view.MotionEvent
-import android.view.View
-import android.widget.TextView
-import androidx.viewbinding.ViewBinding
-import com.blankj.utilcode.util.LogUtils
-import com.bumptech.glide.Glide
-import com.bumptech.glide.load.engine.DiskCacheStrategy
-import com.bumptech.glide.request.RequestOptions
-import com.rc.core.ui.activity.BaseActivity
-import com.rc.httpcore.HttpClient
-import com.rc.httpcore.HttpConfig
-import com.rc.httpcore.client.ApiRepository
-import com.rc.httpcore.exception.NetException
-import com.rc.httpcore.vo.request.FaceCompareReq
-import io.fotoapparat.Fotoapparat
-import io.fotoapparat.facedetector.processor.FaceDetectorProcessor
-import io.fotoapparat.log.fileLogger
-import io.fotoapparat.log.logcat
-import io.fotoapparat.log.loggers
-import io.fotoapparat.selector.back
-import io.fotoapparat.selector.front
-import retrofit2.HttpException
-import xn.hxp.R
-import xn.hxp.app.ChemicalApp
-import xn.hxp.comm.Constants
-import xn.hxp.databinding.ActivityFacialLoginBinding
-import xn.hxp.utils.AudioPlayer
-import xn.hxp.utils.UiManager
-import xn.hxp.weidith.AuthenticationDialog
-import xn.hxp.weidith.CustomDialog
-import java.io.File
-import java.lang.Boolean
-import java.net.ConnectException
-import java.net.SocketTimeoutException
-import java.text.SimpleDateFormat
-import java.util.Calendar
-import java.util.Locale
-
-/**
- * 人脸登录
- */
-class FacialLoginActivity : BaseActivity() {
-
-    private lateinit var mFotoapparat: Fotoapparat
-//    private lateinit var mCountDownTimer: CountDownTimer
-
-    private lateinit var faceList: String
-    private val handlerBack = Handler(Looper.getMainLooper())
-    private var timeLeftInSeconds = 2
-    private var mTvView: TextView? = null
-    private var mDialogsAut: AuthenticationDialog? = null
-
-    lateinit var viewBinding: ActivityFacialLoginBinding
-    override fun setViewBinding(): ViewBinding {
-        viewBinding = ActivityFacialLoginBinding.inflate(layoutInflater)
-        return viewBinding
-    }
-
-    override fun onInit() {
-        AudioPlayer.getInstance().play(R.raw.face_detect_hint)
-        // 使用 Glide 加载网络图片
-        viewBinding.deptName.text = "${ChemicalApp.confs!!.deptName}-${ChemicalApp.confs!!.roomNum}"
-
-        Glide.with(this)
-            .load("${HttpConfig.API_BASE_IMG_URL}${ChemicalApp.confs!!.circularLogo}")
-            .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.AUTOMATIC))
-            .into(viewBinding.image)
-        var str = ""
-
-        try {
-            str = intent.getStringExtra("faceList")!!
-        } catch (e: Exception) {
-        }
-        val mtypes = intent.getStringExtra("mtypes")
-        try {
-            when (mtypes) {
-                "1" -> {
-                    viewBinding.linType.visibility = View.GONE
-                }
-
-                "4" -> {
-                    viewBinding.tvScan.visibility = View.GONE
-                }
-
-                "5" -> {
-                    viewBinding.tvSwipe.visibility = View.GONE
-                }
-
-            }
-        } catch (e: Exception) {
-
-        }
-
-        val map = mutableMapOf<String, String>()
-        if (mtypes != null) {
-            map["mtypes"] = mtypes
-        }
-        if (str != null && str.length > 0) {
-            // 去除字符串首尾的中括号
-            faceList = str.removeSurrounding("[", "]")
-            map["faceList"] = str
-        }
-
-        //跳转刷卡登录
-        viewBinding.tvSwipe.setOnClickListener {
-            UiManager.switcher(this, map, SwipeActivity::class.java)
-            finish()
-        }
-        //跳转扫码登录
-        viewBinding.tvScan.setOnClickListener {
-            UiManager.switcher(this, map, ScanLoginActivity::class.java)
-            finish()
-        }
-
-        viewBinding.tvReturn.text = "返回${ChemicalApp.confs!!.backTime}s"
-        viewBinding.tvReturn.setOnClickListener {
-            finish()
-        }
-
-        mFotoapparat = Fotoapparat.with(this)
-            .into(viewBinding.cameraView)
-            .lensPosition(
-                if (Constants.FACE_TAG == 0) {
-                    front()
-                } else {
-                    back()
-                }
-            )//front()前置  back 后置
-            .frameProcessor(
-                FaceDetectorProcessor.with(this)
-                    .listener { faces ->
-                        viewBinding.rectanglesView.setRectangles(faces)
-                    }.build()
-            )
-            .logger(loggers(logcat(), fileLogger(this)))
-            .build()
-        mFotoapparat.stop()
-        mFotoapparat.start()
-        handlerBack.post(countdownRunnableTwo)
-    }
-
-    override fun onBackPressed() {
-        super.onBackPressed()
-        finish()
-    }
-
-    override fun cdTime(cd: Int) {
-        viewBinding.tvReturn.text = "返回${cd}s"
-    }
-
-
-    override fun onDestroy() {
-        super.onDestroy()
-        if (null != mDialogsAut && mDialogsAut!!.isShowing) {
-            mDialogsAut!!.dismiss()
-        }
-//        cancelTime()//手动关闭
-        LogUtils.i("=============onDestroy")
-
-//        handlerUtil.removeCallbacks(task)
-//        handlerUtil.stopAllTasks()
-        // 移除回调,以防止内存泄漏
-        try {
-            mFotoapparat.stop()
-            handlerBack.removeCallbacks(countdownRunnable)
-            handlerBack.removeCallbacks(countdownRunnableTwo)
-            handlerBack.removeCallbacksAndMessages(null)
-            dismissLoading()
-        } catch (e: Exception) {
-
-        }
-    }
-
-    override fun cdFinish() {
-        finish()
-    }
-
-    private fun takePicture() {
-        LogUtils.i("=======111人脸登录任务进行中")
-        val format = SimpleDateFormat("yyyyMMdd_HHmmssSSS", Locale.getDefault())
-        val fileName = "${format.format(Calendar.getInstance().time)}.jpg"
-        val photoFile = File(this.getExternalFilesDir("photos"), fileName)
-        try {
-            mFotoapparat.takePicture()
-                .saveToFile(photoFile)
-                .whenAvailable {
-                    callFaceMatchingApi(photoFile)
-                }
-        } catch (e: Exception) {
-        }
-    }
-
-    private fun callFaceMatchingApi(
-        featureData: File,
-    ) {
-        showLoading("比对中....")
-        val param = FaceCompareReq().apply {
-            data = null
-            userIds = faceList
-        }
-        val disposable = ApiRepository.faceCompare(featureData, param)
-            .subscribe({ success ->
-                dismissLoading()
-                ChemicalApp.userData = success
-                LogUtils.d(success.userId, ChemicalApp.subjectId)
-                authenticationInfo(success.userId, ChemicalApp.subjectId!!)
-            }, { throwable ->
-                dismissLoading()
-                throwableView(throwable)
-            })
-        addDisposable(disposable)
-    }
-
-    //验证当前人员身份
-    private fun authenticationInfo(userId: String, subId: String) {
-        LogUtils.d(userId, subId)
-        showLoading("验证中...")
-        val disposable = ApiRepository.userCardValidation(userId, subId)
-            .subscribe({ data ->
-                dismissLoading()
-                val allFalse =
-                    Boolean.TRUE == data.cabinetAdmin || Boolean.TRUE == data.belongUser || Boolean.TRUE == data.toipcUser || Boolean.TRUE == data.safeUser || Boolean.TRUE == data.collegeAdmin || Boolean.TRUE == data.schoolLevelAdmin || Boolean.TRUE == data.adminUser || Boolean.TRUE == data.apply || Boolean.TRUE == data.white
-                if (!allFalse) {
-                    HttpClient.token = null
-                    ChemicalApp.userData = null
-                    customDialogView(2, "身份认证不通过")
-                } else {
-                    //校级管理员 schoolLevelAdmin
-                    //院级管理员  collegeAdmin
-                    //实验室负责人 adminUser
-                    //安全负责人 safeUser
-                    //柜锁管理员 cabinetAdmin
-                    //是否化学品归属人 belongUser
-                    //是否化学品归属课题组下成员  toipcUser
-                    if (data.schoolLevelAdmin == true || data.collegeAdmin == true) {
-                        //院级管理员 or 校级管理员
-                        authenticationDialog(data.faceImg, data.userName)
-                    } else if (data.adminUser == true || data.safeUser == true || data.cabinetAdmin == true) {
-                        //实验室负责人 or  安全负责人 or 柜锁管理员
-                        authenticationDialog(data.faceImg, data.userName)
-                    } else if (data.belongUser == true || data.toipcUser == true) {  //当前身份 归属人or课题组
-                        authenticationDialog(data.faceImg, data.userName)
-                    } else if (data.white == true || data.apply == true) {// 白名单和实验室准入
-                        authenticationDialog(data.faceImg, data.userName)
-                    } else {
-                        HttpClient.token = null
-                        ChemicalApp.userData = null
-                        customDialogView(2, "身份认证不通过")
-                    }
-
-                }
-
-            }, { throwable ->
-                dismissLoading()
-                //暂时注释掉  防止异步请求后 在认证时 token 丢失
-//                startCountdownAndExecuteMethod()
-                throwableView(throwable)
-            })
-        addDisposable(disposable)
-    }
-
-    //身份认证成功
-    private fun authenticationDialog(faceImg: String?, userName: String) {
-        mFotoapparat.stop()
-        handlerBack.removeCallbacks(countdownRunnableTwo)
-        AudioPlayer.getInstance().play(R.raw.verify_success)
-        mDialogsAut = AuthenticationDialog(
-            this,
-            faceImg,
-            ChemicalApp.confs!!.subName,
-            ChemicalApp.confs!!.deptName,
-            "${ChemicalApp.confs!!.buildName}${ChemicalApp.confs!!.floorName}",
-            userName, object : AuthenticationDialog.IClickLit {
-                override fun onUpView(tvView: TextView) {
-                    mTvView = tvView
-                }
-            })
-        mDialogsAut!!.show()
-        // 开始倒计时
-        handlerBack.post(countdownRunnable)
-        // 获取对话框的 Window 对象
-        mDialogsAut!!.window?.decorView?.setOnTouchListener { _, event ->
-            // 判断是否点击了对话框外部空白区域
-            if (event.action == MotionEvent.ACTION_DOWN) {
-                val x = event.x
-                val y = event.y
-                val dialogView = mDialogsAut!!.window?.decorView
-                if (dialogView != null && (x < 0 || x > dialogView.width || y < 0 || y > dialogView.height)) {
-                    // 在此处执行点击对话框外部空白区域时的操作
-                    // 例如关闭对话框
-                    // 移除回调,以防止内存泄漏
-                    mDialogsAut!!.dismiss()
-                    finish()
-                    return@setOnTouchListener true
-                }
-            }
-            return@setOnTouchListener false
-        }
-
-    }
-
-    private val countdownRunnable = object : Runnable {
-        override fun run() {
-            if (timeLeftInSeconds > 0) {
-                mTvView!!.text = "${timeLeftInSeconds}秒后自动返回首页"
-                timeLeftInSeconds--
-                handlerBack.postDelayed(this, 1000)
-            } else {
-                mDialogsAut!!.dismiss()
-                finish()
-            }
-        }
-    }
-
-    private val countdownRunnableTwo = object : Runnable {
-        override fun run() {
-            takePicture()
-            handlerBack.postDelayed(this, 4000)
-        }
-    }
-
-    /**
-     * 0  没有图标 1 绿色(成功)   2红色(失败)
-     *   失败或者成功的弹框
-     */
-    private fun customDialogView(types: Int, msg: String) {
-        val customDialog = CustomDialog(this, types, msg)
-        if (!this.isFinishing && !this.isDestroyed) {
-            customDialog.show()
-        }
-    }
-
-    /**
-     * 异常处理
-     */
-    private fun throwableView(throwable: Throwable) {
-        LogUtils.e(Log.getStackTraceString(throwable))
-        when (throwable) {
-            is NetException -> {
-                if (throwable.message.isNullOrEmpty()) {
-                    "接口请求失败(${throwable.code})"
-                } else {
-                    throwable.message!!
-                }
-            }
-
-            is SocketTimeoutException -> "请求超时,请稍后重试"
-            is ConnectException -> "无法连接服务器,请检查网络"
-            is HttpException -> "服务器繁忙,请稍后重试"
-            else -> "服务器异常"
-        }?.let { customDialogView(2, "$it") }
-    }
-
-}

+ 2 - 2
app/src/main/java/xn/hxp/ui/login/ScanLoginActivity.kt

@@ -71,7 +71,7 @@ class ScanLoginActivity : BaseActivity() {
             if (str != null) {
                 map["faceList"] = str
             }
-            UiManager.switcher(this, map, FacialLoginActivity::class.java)
+            UiManager.switcher(this, map, FaceLoginActivity::class.java)
             finish()
         }
         viewBinding.tvCrad.setOnClickListener {
@@ -131,7 +131,7 @@ class ScanLoginActivity : BaseActivity() {
         }
         //人脸识别
         viewBinding.tvFace.setOnClickListener {
-            UiManager.switcher(this, map, FacialLoginActivity::class.java)
+            UiManager.switcher(this, map, FaceLoginActivity::class.java)
             finish()
         }
         //刷卡

+ 3 - 3
app/src/main/java/xn/hxp/ui/login/SwipeActivity.kt

@@ -59,7 +59,7 @@ class SwipeActivity : BaseActivity() {
         EventBus.getDefault().register(this)
         viewBinding.tvReturn.text = "返回${ChemicalApp.confs!!.backTime}s"
         viewBinding.tvReturn.setOnClickListener {
-            ActivityUtils.finishToActivity(MainActivity::class.java, true)
+            ActivityUtils.finishToActivity(MainActivity::class.java, false)
         }
 
         val stringExtra = intent.getStringExtra("mtypes")
@@ -95,7 +95,7 @@ class SwipeActivity : BaseActivity() {
 
         }
         viewBinding.tvFace.setOnClickListener {
-            UiManager.switcher(this, map, FacialLoginActivity::class.java)
+            UiManager.switcher(this, map, FaceLoginActivity::class.java)
             finish()
         }
 
@@ -250,7 +250,7 @@ class SwipeActivity : BaseActivity() {
 
     override fun onBackPressed() {
         super.onBackPressed()
-        ActivityUtils.finishToActivity(MainActivity::class.java, true)
+        ActivityUtils.finishToActivity(MainActivity::class.java, false)
     }
 
     override fun cdTime(cd: Int) {

+ 14 - 3
app/src/main/java/xn/hxp/ui/plan/PlanAddData.java

@@ -1,14 +1,26 @@
 package xn.hxp.ui.plan;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import xn.hxp.ui.plan.room.bean.locker.HxpCabinetDoorVo;
 import xn.hxp.ui.plan.room.bean.locker.HxpCabinetVo;
 
-import java.util.List;
-
 public class PlanAddData {
     private List<HxpCabinetVo> cabinetList;
     private List<HxpCabinetDoorVo> doorList;
 
+    // 国睿申领未入库需要入库的化学品ID
+    private List<String> autoChemicalList = new ArrayList<>();
+
+    public List<String> getAutoChemicalList() {
+        return autoChemicalList;
+    }
+
+    public void setAutoChemicalList(List<String> autoChemicalList) {
+        this.autoChemicalList = autoChemicalList;
+    }
+
     public List<HxpCabinetVo> getCabinetList() {
         return cabinetList;
     }
@@ -24,5 +36,4 @@ public class PlanAddData {
     public void setDoorList(List<HxpCabinetDoorVo> doorList) {
         this.doorList = doorList;
     }
-
 }

+ 590 - 0
app/src/main/java/xn/hxp/ui/plan/already/AlreadyActivity.java

@@ -0,0 +1,590 @@
+package xn.hxp.ui.plan.already;
+
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.InputType;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RadioGroup;
+
+import androidx.activity.result.ActivityResult;
+import androidx.activity.result.ActivityResultCallback;
+import androidx.activity.result.ActivityResultLauncher;
+import androidx.activity.result.contract.ActivityResultContracts;
+import androidx.appcompat.app.AlertDialog;
+import androidx.viewbinding.ViewBinding;
+
+import com.blankj.utilcode.util.GsonUtils;
+import com.blankj.utilcode.util.LogUtils;
+import com.blankj.utilcode.util.ThreadUtils;
+import com.blankj.utilcode.util.TimeUtils;
+import com.blankj.utilcode.util.ToastUtils;
+import com.bumptech.glide.Glide;
+import com.google.gson.reflect.TypeToken;
+import com.kongzue.dialogx.dialogs.PopTip;
+import com.rc.core.ui.activity.BaseActivity;
+import com.rc.httpcore.HttpConfig;
+import com.rc.httpcore.bean.HxpChemicalVo;
+import com.rc.httpcore.client.HttpTool;
+import com.rc.httpcore.exception.NetException;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import okhttp3.Response;
+import xn.hxp.app.ChemicalApp;
+import xn.hxp.databinding.ActivityAlreadyBinding;
+import xn.hxp.ui.plan.PlanAddData;
+import xn.hxp.ui.plan.room.RoomTool;
+import xn.hxp.ui.plan.room.bean.input_add.InventoryItemBean;
+import xn.hxp.ui.plan.room.bean.locker.CabinetLayerSelect;
+import xn.hxp.ui.plan.room.bean.locker.HxpCabinetDoorVo;
+import xn.hxp.ui.plan.room.bean.locker.HxpCabinetLockVo;
+import xn.hxp.ui.plan.room.bean.locker.HxpCabinetVo;
+import xn.hxp.ui.plan.room.bean.locker.HxpLabCabinetListVo;
+import xn.hxp.ui.plan.room.bean.locker.HxpLabCabinetVo;
+import xn.hxp.ui.plan.room.dao.HxpCabinetDAO;
+import xn.hxp.ui.plan.room.dao.HxpDoorDAO;
+import xn.hxp.ui.plan.room.dao.HxpInventoryDAO;
+import xn.hxp.ui.plan.unlock.UnlockActivity;
+
+public class AlreadyActivity extends BaseActivity {
+    private ActivityAlreadyBinding binding;
+    private List<HxpChemicalVo> hxpChemicalVoList = new ArrayList<>();
+    private AlreadyAdapter alreadyAdapter;
+
+    private int page = 1; // 页数
+    private int type; // 0:与自己相关 1:其它
+    private String applyOrder; // 申领单号
+    private String applyUserName;// 申领人
+    private String topicUserName;// 归属人
+
+    private String[] applyArray;
+
+    private ActivityResultLauncher<Intent> intentActivityResultLauncher;
+
+    @Override
+    protected ViewBinding setViewBinding() {
+        return binding = ActivityAlreadyBinding.inflate(getLayoutInflater());
+    }
+
+    @Override
+    protected void onInit() {
+        RoomTool.getInstance().hxpCabinetDAO().deleteAll();
+        RoomTool.getInstance().hxpDoorDAO().deleteAll();
+        RoomTool.getInstance().hxpLayerDAO().deleteAll();
+        RoomTool.getInstance().hxpInventoryDAO().deleteAll();
+        RoomTool.getInstance().hxpLabDirectorDAO().deleteAll();
+        RoomTool.getInstance().hxpLabSafeDAO().deleteAll();
+        // 位置选择
+        intentActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
+            @Override
+            public void onActivityResult(ActivityResult result) {
+                if (result.getResultCode() == RESULT_OK) {
+                    Intent resultData = result.getData();
+                    if (null != resultData && resultData.hasExtra("data")) {
+                        Bundle bundle = resultData.getBundleExtra("data");
+                        if (null != bundle) {
+                            CabinetLayerSelect cabinetLayerSelect = (CabinetLayerSelect) bundle.getSerializable("Change");
+                            LogUtils.json("选择的柜层", cabinetLayerSelect);
+                            if (null != cabinetLayerSelect) {
+
+                                List<HxpChemicalVo> beanArrayList = new ArrayList<>();
+                                for (int i = 0; i < hxpChemicalVoList.size(); i++) {
+                                    HxpChemicalVo recordsBean = hxpChemicalVoList.get(i);
+                                    if (recordsBean.isSelect()) {
+                                        beanArrayList.add(recordsBean);
+                                    }
+                                }
+
+                                for (int i = 0; i < beanArrayList.size(); i++) {
+                                    HxpChemicalVo recordsBean = beanArrayList.get(i);
+                                    recordsBean.setCabinetId(cabinetLayerSelect.getCabinetId());
+                                    recordsBean.setDoorId(cabinetLayerSelect.getDoorId());
+                                    recordsBean.setDoorLayers(cabinetLayerSelect.getLayer());
+                                }
+
+                                showLoading("正在修改存储位置...");
+                                ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<Object>() {
+                                    @Override
+                                    public Object doInBackground() throws Throwable {
+                                        Response response = HttpTool.changeDoor(beanArrayList);
+                                        String json = response.body().string();
+                                        LogUtils.d(json);
+                                        return null;
+                                    }
+
+                                    @Override
+                                    public void onSuccess(Object result) {
+                                        dismissLoading();
+                                        alreadyAdapter.notifyDataSetChanged();
+                                    }
+                                });
+                            }
+                        }
+                    }
+                }
+            }
+        });
+
+        // 全选/全返选
+        binding.selectAllCB.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                List<String> waitArray = new ArrayList<>();
+                for (int i = 0; i < hxpChemicalVoList.size(); i++) {
+                    HxpChemicalVo recordsBean = hxpChemicalVoList.get(i);
+                    recordsBean.setSelect(binding.selectAllCB.isChecked());
+                    if (binding.selectAllCB.isChecked()) {
+                        waitArray.add(recordsBean.getWaitId());
+                    }
+                }
+                if (binding.selectAllCB.isChecked()) {
+                    PopTip.show("全选" + waitArray.size());
+                } else {
+                    PopTip.show("全反选" + waitArray.size());
+                }
+                alreadyAdapter.notifyDataSetChanged();
+                LogUtils.json(waitArray);
+            }
+        });
+        // 已申领类型选择
+        binding.typeRG.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                // 与我相关
+                if (checkedId == binding.relatedRB.getId()) {
+                    binding.otherRB.setText("其它");
+                    type = 1;
+                }
+                // 其它
+                else if (checkedId == binding.otherRB.getId()) {
+                    binding.relatedRB.setText("与我相关");
+                    type = 0;
+                }
+                getHxpStockWait();
+            }
+        });
+        // 根据申领单号查询
+        binding.applicantCodeSearchRL.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (null != applyArray) {
+                    AlertDialog.Builder builder = new AlertDialog.Builder(AlreadyActivity.this);
+                    builder.setTitle("选择申领单号查询");
+                    builder.setItems(applyArray, (dialog, which) -> {
+                        applyOrder = applyArray[which];
+                        binding.applicantCodeSearchTV.setText(applyOrder);
+                        binding.applicantCodeSearchTV.setSelected(true);
+                        getHxpStockWait();
+                    });
+                    builder.setNeutralButton("清空", new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            applyOrder = "";
+                            binding.applicantCodeSearchTV.setText("申领单号");
+                            getHxpStockWait();
+                        }
+                    });
+                    builder.show();
+                } else {
+                    showLoading("申领单号查询中...");
+                    getApplyList();
+                }
+
+            }
+        });
+        // 根据申领人查询
+        binding.applicantSearchRL.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                AlertDialog.Builder builder = new AlertDialog.Builder(AlreadyActivity.this);
+                builder.setTitle("请输入申领人姓名");
+                final EditText editText = new EditText(AlreadyActivity.this);
+                editText.setInputType(InputType.TYPE_CLASS_TEXT); // 设置输入类型为文本
+                builder.setView(editText);
+                builder.setNeutralButton("清空", new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        applyUserName = "";
+                        binding.applicantSearchTV.setText("申领人");
+                        if (!TextUtils.isEmpty(editText.getText())) {
+                            getHxpStockWait();
+                        }
+                    }
+                });
+                builder.setPositiveButton("确定", null);
+                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        dialog.dismiss();
+                    }
+                });
+                AlertDialog dialog = builder.create();
+                dialog.show();
+                Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
+                positiveButton.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        String input = editText.getText().toString();
+                        if (input.isEmpty()) {
+                            editText.setSelected(true);
+                            editText.setError("请输入姓名!");
+                        } else {
+                            applyUserName = input;
+                            binding.applicantSearchTV.setText(applyUserName);
+                            getHxpStockWait();
+                            dialog.dismiss();
+                        }
+                    }
+                });
+            }
+        });
+        // 根据归属人查询
+        binding.belongSearchRL.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                AlertDialog.Builder builder = new AlertDialog.Builder(AlreadyActivity.this);
+                builder.setTitle("请输入归属人姓名");
+                final EditText editText = new EditText(AlreadyActivity.this);
+                editText.setInputType(InputType.TYPE_CLASS_TEXT); // 设置输入类型为文本
+                builder.setView(editText);
+                builder.setPositiveButton("确定", null);
+                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        dialog.dismiss();
+                    }
+                });
+                builder.setNeutralButton("清空", new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        topicUserName = "";
+                        binding.belongSearchTV.setText("归属人");
+                        if (!TextUtils.isEmpty(editText.getText())) {
+                            getHxpStockWait();
+                        }
+                    }
+                });
+                AlertDialog dialog = builder.create();
+                dialog.show();
+                Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
+                positiveButton.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        String input = editText.getText().toString();
+                        if (input.isEmpty()) {
+                            editText.setSelected(true);
+                            editText.setError("请输入姓名!");
+                        } else {
+                            topicUserName = input;
+                            binding.belongSearchTV.setText(topicUserName);
+                            getHxpStockWait();
+                            dialog.dismiss();
+                        }
+                    }
+                });
+            }
+        });
+        // 一键入库
+        binding.subAdd.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                showLoading("处理中...");
+                ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<PlanAddData>() {
+                    @Override
+                    public PlanAddData doInBackground() throws Throwable {
+                        List<HxpChemicalVo> autoChemicalList = new ArrayList<>();
+                        List<String> autoChemicalIdList = new ArrayList<>();
+                        for (int i = 0; i < hxpChemicalVoList.size(); i++) {
+                            HxpChemicalVo recordsBean = hxpChemicalVoList.get(i);
+                            if (recordsBean.isSelect()) {
+                                autoChemicalIdList.add(recordsBean.getWaitId());
+                                autoChemicalList.add(recordsBean);
+                            }
+                        }
+
+                        // 为需要自动入库的化学品创建清单
+                        AlreadyTool.INSTANCE.updateHxpInventoryList(autoChemicalList);
+                        HxpDoorDAO hxpDoorDAO = RoomTool.getInstance().hxpDoorDAO();
+                        HxpInventoryDAO hxpInventoryDAO = RoomTool.getInstance().hxpInventoryDAO();
+                        HxpCabinetDAO hxpCabinetDAO = RoomTool.getInstance().hxpCabinetDAO();
+                        List<InventoryItemBean> inventoryItemBeanList = hxpInventoryDAO.getAll();
+                        List<HxpCabinetVo> cabinetList = hxpCabinetDAO.getAll();
+                        List<HxpCabinetDoorVo> doorList = hxpDoorDAO.getAll();
+                        // 删除清单外的柜门
+                        for (int i = 0; i < doorList.size(); i++) {
+                            HxpCabinetDoorVo doorVo = doorList.get(i);
+                            boolean hasDoorId = false;
+                            for (int j = 0; j < inventoryItemBeanList.size(); j++) {
+                                InventoryItemBean inventoryItemBean = inventoryItemBeanList.get(j);
+                                if (inventoryItemBean.getDoorId() == doorVo.getDoorId()) {
+                                    hasDoorId = true;
+                                    break;
+                                }
+                            }
+                            if (!hasDoorId) {
+                                doorList.remove(i);
+                                i--;
+                            }
+
+                        }
+                        // 删除没有智能锁的柜门
+                        Iterator<HxpCabinetDoorVo> doorVoIterator = doorList.iterator();
+                        while (doorVoIterator.hasNext()) {
+                            HxpCabinetDoorVo doorVo = doorVoIterator.next();
+                            List<HxpCabinetLockVo> hxpCabinetLockVoList = doorVo.getCabinetLockVoList();
+                            if (null == hxpCabinetLockVoList || hxpCabinetLockVoList.isEmpty()) {
+                                doorVoIterator.remove();
+                            } else {
+                                HxpCabinetLockVo cabinetLockVo = hxpCabinetLockVoList.get(0);
+                                if (2 != cabinetLockVo.getUnlockingMethod()) {
+                                    doorVoIterator.remove();
+                                }
+                            }
+                        }
+                        // 删除不需要开门的柜子
+                        Iterator<HxpCabinetVo> cabinetVoIterator = cabinetList.iterator();
+                        while (cabinetVoIterator.hasNext()) {
+                            HxpCabinetVo cabinetVo = cabinetVoIterator.next();
+                            boolean hasDoor = false;
+                            for (int i = 0; i < doorList.size(); i++) {
+                                HxpCabinetDoorVo doorVo = doorList.get(i);
+                                if (cabinetVo.getCabinetId() == doorVo.getCabinetId()) {
+                                    hasDoor = true;
+                                    break;
+                                }
+                            }
+                            if (!hasDoor) {
+                                cabinetVoIterator.remove();
+                            }
+                        }
+                        PlanAddData planAddData = new PlanAddData();
+                        planAddData.setCabinetList(cabinetList);
+                        planAddData.setDoorList(doorList);
+                        planAddData.setAutoChemicalList(autoChemicalIdList);
+                        return planAddData;
+                    }
+
+                    @Override
+                    public void onSuccess(PlanAddData planAddData) {
+                        dismissLoading();
+                        LogUtils.json(planAddData);
+                        List<HxpCabinetVo> cabinetList = planAddData.getCabinetList();
+                        List<HxpCabinetDoorVo> doorList = planAddData.getDoorList();
+                        LogUtils.d("需要开锁", cabinetList.size(), doorList.size());
+                        // 不需要开门
+                        if (cabinetList.isEmpty() || doorList.isEmpty()) {
+                            showToast("不需要开门");
+                            return;
+                        }
+                        String json = GsonUtils.toJson(planAddData);
+                        Intent intent = new Intent(AlreadyActivity.this, UnlockActivity.class);
+                        intent.putExtra("data", json);
+                        intent.putExtra("isAuto", true);
+                        startActivity(intent);
+                        finish();
+                    }
+                });
+            }
+        });
+
+        try {
+            // 日期
+            binding.nowTime.setText(TimeUtils.getNowString(new SimpleDateFormat("MM月dd日 EEEE ", Locale.getDefault())));
+            // 用户
+            Glide.with(this).load(HttpConfig.Companion.getAPI_BASE_IMG_URL() + ChemicalApp.userData.getAvatar()).into(binding.imageName);
+            String userName = ChemicalApp.userData.getUserName();
+            binding.tvName.setText(TextUtils.isEmpty(userName) ? "" : userName);
+            // 实验室logo
+            Glide.with(this).load(HttpConfig.Companion.getAPI_BASE_IMG_URL() + ChemicalApp.confs.getCircularLogo()).into(binding.image);
+            // 实验室名称
+            String subName = ChemicalApp.subjectName;
+            subName = TextUtils.isEmpty(subName) ? "" : subName;
+            // 房间号
+            String roomNum = ChemicalApp.subRoom;
+            roomNum = TextUtils.isEmpty(roomNum) ? "" : roomNum;
+            binding.deptName.setText(subName + "-" + roomNum);
+            getHxpStockWait();
+            getHxpCabinetList(ChemicalApp.subjectId);
+            getApplyList();
+        } catch (Exception e) {
+            LogUtils.e(Log.getStackTraceString(e));
+        }
+        // 退出
+        binding.tvOutLogin.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                try {
+                    HttpTool.logout();
+                } catch (IOException e) {
+                    LogUtils.e(Log.getStackTraceString(e));
+                }
+            }
+        });
+        binding.tvReturn.setOnClickListener(v -> finish());
+    }
+
+    /**
+     * 获取单号检索列表
+     */
+    private void getApplyList() {
+        ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<List<String>>() {
+            @Override
+            public List<String> doInBackground() throws Throwable {
+                Response response = HttpTool.getApplyOrder(ChemicalApp.subjectId);
+                String json = response.body().string();
+                JSONObject jsonObject = new JSONObject(json);
+                if (jsonObject.getInt("code") == 200) {
+                    JSONArray jsonArray = jsonObject.getJSONArray("data");
+                    return GsonUtils.fromJson(jsonArray.toString(), new TypeToken<ArrayList<String>>() {
+                    }.getType());
+                } else {
+                    String msg = jsonObject.getString("message");
+                    ToastUtils.showLong(msg);
+                    return null;
+                }
+            }
+
+            @Override
+            public void onSuccess(List<String> applyList) {
+                dismissLoading();
+                if (applyList == null) {
+                    showToast("获取申领单号失败!");
+                } else {
+                    applyArray = applyList.toArray(new String[0]);
+                }
+            }
+        });
+    }
+
+    /**
+     * 获取指定实验室的柜子信息
+     */
+    private void getHxpCabinetList(String subjectId) {
+        ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<List<HxpCabinetVo>>() {
+            @Override
+            public List<HxpCabinetVo> doInBackground() throws Throwable {
+                Response response = HttpTool.getCabinetList(subjectId);
+                if (response.isSuccessful()) {
+                    String json = response.body().string();
+                    HxpLabCabinetListVo hxpCabinetListVo = GsonUtils.fromJson(json, HxpLabCabinetListVo.class);
+                    if (hxpCabinetListVo.getCode() == 200) {
+                        HxpLabCabinetVo hxpLabCabinetVo = hxpCabinetListVo.getData();
+                        try {
+                            // 实验室负责人
+                            RoomTool.getInstance().hxpLabDirectorDAO().insertAll(hxpLabCabinetVo.getAdminList());
+                            // 实验室安全员
+                            RoomTool.getInstance().hxpLabSafeDAO().insertAll(hxpLabCabinetVo.getSafeList());
+                        } catch (Exception e) {
+                            LogUtils.e(Log.getStackTraceString(e));
+                        }
+
+                        List<HxpCabinetVo> hxpCabinetVoList = hxpLabCabinetVo.getCabinetList();
+                        if (null != hxpCabinetVoList && !hxpCabinetVoList.isEmpty()) {
+                            RoomTool.getInstance().hxpCabinetDAO().insertAll(hxpCabinetVoList);
+                            // 录入柜子
+                            for (int i = 0; i < hxpCabinetVoList.size(); i++) {
+                                HxpCabinetVo hxpCabinetVo = hxpCabinetVoList.get(i);
+                                List<HxpCabinetDoorVo> hxpCabinetDoorVoList = hxpCabinetVo.getCabinetDoorVoList();
+                                if (null != hxpCabinetDoorVoList && !hxpCabinetDoorVoList.isEmpty()) {
+                                    // 录入柜门
+                                    RoomTool.getInstance().hxpDoorDAO().insertAll(hxpCabinetDoorVoList);
+                                }
+                            }
+
+                        }
+                    } else {
+                        throw new NetException("" + hxpCabinetListVo.getCode(), hxpCabinetListVo.getMessage());
+                    }
+                } else {
+                    throw new NetException("" + response.code(), response.message());
+                }
+                return null;
+            }
+
+            @Override
+            public void onSuccess(List<HxpCabinetVo> hxpCabinetVoList) {
+
+            }
+        });
+    }
+
+    /**
+     * 获取已申领未入库列表
+     */
+    private void getHxpStockWait() {
+        showLoading("加载中...");
+        ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<AlreadyBean>() {
+            @Override
+            public AlreadyBean doInBackground() throws Throwable {
+                Response response = HttpTool.getHxpStockWait(type, ChemicalApp.subjectId, page, 10, applyOrder, applyUserName, topicUserName);
+                String json = response.body().string();
+                JSONObject jsonObject = new JSONObject(json);
+                if (jsonObject.getInt("code") == 200) {
+                    return GsonUtils.fromJson(jsonObject.getJSONObject("data").toString(), AlreadyBean.class);
+                } else {
+                    String msg = jsonObject.getString("message");
+                    ToastUtils.showLong(msg);
+                    return null;
+                }
+            }
+
+            @Override
+            public void onSuccess(AlreadyBean result) {
+                dismissLoading();
+                if (null != result) {
+                    hxpChemicalVoList.clear();
+                    List<HxpChemicalVo> resultRecords = result.getPageData().getRecords();
+                    if (null != resultRecords && !resultRecords.isEmpty()) {
+                        hxpChemicalVoList.addAll(resultRecords);
+                    }
+                    alreadyAdapter = new AlreadyAdapter(AlreadyActivity.this, hxpChemicalVoList, intentActivityResultLauncher);
+                    binding.alreadyLV.setAdapter(alreadyAdapter);
+                    int total = result.getPageData().getTotal();
+                    if (result.isAdmin()) {
+                        binding.typeRG.setVisibility(View.VISIBLE);
+                        if (binding.relatedRB.isChecked()) {
+                            binding.relatedRB.setText("与我相关(" + total + ")");
+                        }
+                        if (binding.otherRB.isChecked()) {
+                            binding.otherRB.setText("其它(" + total + ")");
+                        }
+                    } else {
+                        binding.alreadyName.setText("已申领危化品存储(" + total + ")");
+                        if (total == 0) {
+                            showToast("暂无您可处理的危化品!");
+                        }
+                    }
+                }
+            }
+        });
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        intentActivityResultLauncher.unregister();
+    }
+
+    @Override
+    protected void cdFinish() {
+        finish();
+    }
+
+    @Override
+    protected void cdTime(int cd) {
+        binding.tvReturn.setText("返回" + cd + "s");
+    }
+}

+ 206 - 0
app/src/main/java/xn/hxp/ui/plan/already/AlreadyAdapter.java

@@ -0,0 +1,206 @@
+package xn.hxp.ui.plan.already;
+
+import android.content.Context;
+import android.content.Intent;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+
+import androidx.activity.result.ActivityResultLauncher;
+
+import com.blankj.utilcode.util.LogUtils;
+import com.kongzue.dialogx.dialogs.PopTip;
+import com.rc.httpcore.bean.HxpChemicalVo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import xn.hxp.databinding.ItemAlreadyBinding;
+import xn.hxp.ui.PrintBean;
+import xn.hxp.ui.plan.change.ChangeCabinetActivity;
+import xn.hxp.utils.PrintTool;
+
+public class AlreadyAdapter extends BaseAdapter {
+    private Context context;
+    private List<HxpChemicalVo> recordsBeanList;
+
+    // 存储位置替换的回调
+    private ActivityResultLauncher<Intent> intentActivityResultLauncher;
+
+    public AlreadyAdapter(Context context, List<HxpChemicalVo> recordsBeanList, ActivityResultLauncher<Intent> intentActivityResultLauncher) {
+        this.context = context;
+        this.recordsBeanList = recordsBeanList;
+        this.intentActivityResultLauncher = intentActivityResultLauncher;
+    }
+
+    @Override
+    public int getCount() {
+        return recordsBeanList.size();
+    }
+
+    @Override
+    public HxpChemicalVo getItem(int position) {
+        return recordsBeanList.get(position);
+    }
+
+    @Override
+    public long getItemId(int position) {
+        return 0;
+    }
+
+    @Override
+    public View getView(int position, View convertView, ViewGroup parent) {
+        ViewHolder viewHolder;
+        if (convertView == null) {
+            ItemAlreadyBinding binding = ItemAlreadyBinding.inflate(LayoutInflater.from(context), parent, false);
+            convertView = binding.getRoot();
+            viewHolder = new ViewHolder(binding);
+            convertView.setTag(viewHolder);
+        } else {
+            viewHolder = (ViewHolder) convertView.getTag();
+        }
+
+        try {
+            HxpChemicalVo recordsBean = getItem(position);
+            ItemAlreadyBinding binding = viewHolder.binding;
+            // 申领单号
+            String applyOrder = recordsBean.getApplyOrder();
+            binding.alreadyCodeTV.setText(TextUtils.isEmpty(applyOrder) ? "" : applyOrder);
+            // 化学品名称
+            String chemicalName = recordsBean.getChemicalName();
+            binding.name.setText(TextUtils.isEmpty(chemicalName) ? "" : chemicalName);
+            // 类别
+            String chemicalCategoryName = recordsBean.getChemicalCategoryName();
+            binding.type.setText(TextUtils.isEmpty(chemicalCategoryName) ? "" : chemicalCategoryName);
+            // CAS
+            String casNum = recordsBean.getCasNum();
+            binding.cas.setText(TextUtils.isEmpty(casNum) ? "" : casNum);
+            // 纯度
+            String chemicalPurity = recordsBean.getChemicalPurity();
+            binding.purity.setText(TextUtils.isEmpty(chemicalPurity) ? "" : chemicalPurity);
+            // 规格
+            String normsNum = recordsBean.getNormsNum();
+            String normsUnit = recordsBean.getNormsUnit();
+            binding.specs.setText(normsNum + (TextUtils.isEmpty(normsUnit) ? "" : normsUnit));
+            // 申领人
+            String applyUserName = recordsBean.getApplyUserName();
+            binding.applicantTV.setText(TextUtils.isEmpty(applyUserName) ? "" : applyUserName);
+            // 归属人
+            boolean topicGroup = recordsBean.isTopicGroup();
+            // 是否是课题组
+            if (topicGroup) {
+                String topicGroupName = recordsBean.getTopicGroupName();
+                binding.belongTV.setText(TextUtils.isEmpty(topicGroupName) ? "" : topicGroupName);
+            } else {
+                binding.belongTV.setText(TextUtils.isEmpty(applyUserName) ? "" : applyUserName);
+            }
+            // 编码
+            String labels = recordsBean.getLabels();
+            binding.code.setText(TextUtils.isEmpty(labels) ? "" : labels);
+            // 存储位置
+            String cabinetName = recordsBean.getCabinetName();
+            String doorName = recordsBean.getDoorName();
+            int doorLayers = recordsBean.getDoorLayers();
+            binding.save.setText(cabinetName + "-" + doorName + "-" + doorLayers + "层");
+            // 是否被选择
+            binding.selectCB.setChecked(recordsBean.isSelect());
+            binding.selectCB.setOnCheckedChangeListener(null);
+            binding.selectCB.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    if (binding.selectCB.isChecked()) {
+                        PopTip.show("选择" + position);
+                    } else {
+                        PopTip.show("反选" + position);
+                    }
+                    HxpChemicalVo recordsBean = getItem(position);
+                    recordsBean.setSelect(binding.selectCB.isChecked());
+                }
+            });
+            binding.save.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    recordsBeanList.get(position).setSelect(true);
+                    notifyDataSetChanged();
+                    List<String> waitArray = new ArrayList<>();
+                    for (int i = 0; i < recordsBeanList.size(); i++) {
+                        HxpChemicalVo recordsBean = recordsBeanList.get(i);
+                        if (recordsBean.isSelect()) {
+                            waitArray.add(recordsBean.getWaitId());
+                        }
+                    }
+                    LogUtils.json(waitArray);
+
+                    intentActivityResultLauncher.launch(new Intent(context, ChangeCabinetActivity.class));
+                    PopTip.show("存储" + position + " ," + waitArray.size() + "个");
+
+                }
+            });
+
+            binding.operate.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    try {
+                        HxpChemicalVo printAlreadyBean = recordsBeanList.get(position);
+                        printAlreadyBean.setSelect(true);
+                        notifyDataSetChanged();
+                        List<HxpChemicalVo> rrintBeanList = new ArrayList<>();
+                        for (int i = 0; i < recordsBeanList.size(); i++) {
+                            HxpChemicalVo recordsBean = recordsBeanList.get(i);
+                            if (recordsBean.isSelect()) {
+                                rrintBeanList.add(recordsBean);
+                            }
+                        }
+                        LogUtils.json(rrintBeanList);
+                        PopTip.show("打印" + position + " ," + rrintBeanList.size() + "个");
+                        for (int i = 0; i < rrintBeanList.size(); i++) {
+                            PrintBean printBean = new PrintBean();
+                            // 化学品编码
+                            HxpChemicalVo itemBean = rrintBeanList.get(i);
+                            String tagCode = itemBean.getLabels();
+                            printBean.setTag(TextUtils.isEmpty(tagCode) ? "" : tagCode);
+                            // 二维码
+                            printBean.setWxCode(TextUtils.isEmpty(tagCode) ? "" : tagCode);
+                            // 化学品名
+                            printBean.setName(TextUtils.isEmpty(chemicalName) ? "" : chemicalName);
+                            // CAS
+                            String casNum = itemBean.getCasNum();
+                            printBean.setCasNo(TextUtils.isEmpty(casNum) ? "" : casNum);
+                            int belongType = itemBean.getBelongType();
+                            String name = "";
+                            // 是否是课题组
+                            if (itemBean.isTopicGroup()) {
+                                name = itemBean.getTopicGroupName();
+                            } else {
+                                name = itemBean.getApplyUserName();
+                            }
+                            printBean.setPerson(TextUtils.isEmpty(name) ? "" : name);
+                            // 化学品类型
+                            CharSequence chemicalCategory = itemBean.getChemicalCategoryName();
+                            printBean.setTypes(TextUtils.isEmpty(chemicalCategory) ? "" : chemicalCategory.toString());
+                            PrintTool.INSTANCE.print(true, !itemBean.isTopicGroup(), printBean);
+                        }
+
+                    } catch (Exception e) {
+                        LogUtils.e(Log.getStackTraceString(e));
+                    }
+                }
+            });
+        } catch (Exception e) {
+            LogUtils.e(Log.getStackTraceString(e));
+        }
+
+        return convertView;
+    }
+
+    static class ViewHolder {
+        ItemAlreadyBinding binding;
+
+        public ViewHolder(ItemAlreadyBinding binding) {
+            this.binding = binding;
+        }
+    }
+}

+ 69 - 0
app/src/main/java/xn/hxp/ui/plan/already/AlreadyBean.java

@@ -0,0 +1,69 @@
+package xn.hxp.ui.plan.already;
+
+import com.rc.httpcore.bean.HxpChemicalVo;
+
+import java.util.List;
+
+public class AlreadyBean {
+    // 是否是管理身份
+    private boolean isAdmin;
+
+    private PageData pageData;
+
+
+    public class PageData {
+        private int total;// 总数
+        private int size;// 分页条数
+        private int current;// 页码
+        private List<HxpChemicalVo> records;
+
+
+        public int getTotal() {
+            return total;
+        }
+
+        public void setTotal(int total) {
+            this.total = total;
+        }
+
+        public int getSize() {
+            return size;
+        }
+
+        public void setSize(int size) {
+            this.size = size;
+        }
+
+        public int getCurrent() {
+            return current;
+        }
+
+        public void setCurrent(int current) {
+            this.current = current;
+        }
+
+        public List<HxpChemicalVo> getRecords() {
+            return records;
+        }
+
+        public void setRecords(List<HxpChemicalVo> records) {
+            this.records = records;
+        }
+    }
+
+    public boolean isAdmin() {
+        return isAdmin;
+    }
+
+    public void setAdmin(boolean admin) {
+        isAdmin = admin;
+    }
+
+    public PageData getPageData() {
+        return pageData;
+    }
+
+    public void setPageData(PageData pageData) {
+        this.pageData = pageData;
+    }
+}

+ 42 - 0
app/src/main/java/xn/hxp/ui/plan/already/AlreadyTool.java

@@ -0,0 +1,42 @@
+package xn.hxp.ui.plan.already;
+
+import com.blankj.utilcode.util.LogUtils;
+import com.rc.httpcore.bean.BelongingPersonBean;
+import com.rc.httpcore.bean.HxpChemicalVo;
+import com.rc.httpcore.bean.TopicDataBean;
+
+import java.util.List;
+
+import xn.hxp.ui.plan.room.RoomTool;
+import xn.hxp.ui.plan.room.bean.input_add.InventoryItemBean;
+import xn.hxp.ui.plan.room.dao.HxpInventoryDAO;
+
+public enum AlreadyTool {
+    INSTANCE;
+
+    public void updateHxpInventoryList(List<HxpChemicalVo> hxpChemicalVoList) {
+        HxpInventoryDAO hxpInventoryDAO = RoomTool.getInstance().hxpInventoryDAO();
+        for (int i = 0; i < hxpChemicalVoList.size(); i++) {
+            HxpChemicalVo hxpChemicalVo = hxpChemicalVoList.get(i);
+            // 清单Item
+            InventoryItemBean inventoryItemBean = new InventoryItemBean(hxpChemicalVo.getCabinetId(), hxpChemicalVo.getDoorId(), hxpChemicalVo.getDoorLayers());
+            inventoryItemBean.setWaitId(Long.parseLong(hxpChemicalVo.getWaitId()));
+            inventoryItemBean.setSize(1);
+            // 是否课题
+            if (hxpChemicalVo.isTopicGroup()) {
+                TopicDataBean topicDataBean = new TopicDataBean(String.valueOf(hxpChemicalVo.getTopicGroupId()), hxpChemicalVo.getTopicGroupName());
+                inventoryItemBean.setTopicDataBean(topicDataBean);
+            } else {
+                // 归属人信息
+                BelongingPersonBean belongingPersonBean = new BelongingPersonBean(String.valueOf(hxpChemicalVo.getApplyUserId()), hxpChemicalVo.getApplyUserName(), hxpChemicalVo.getBelongAccount(), hxpChemicalVo.getApplyUserPhone(), "");
+                inventoryItemBean.setBelongingPersonBean(belongingPersonBean);
+            }
+            // 设置化学品
+            inventoryItemBean.setHxpChemicalVo(hxpChemicalVo);
+
+            hxpInventoryDAO.upsert(inventoryItemBean);
+        }
+        LogUtils.json(hxpInventoryDAO.getAll());
+    }
+
+}

+ 49 - 0
app/src/main/java/xn/hxp/ui/plan/already/AutoChemicalBean.java

@@ -0,0 +1,49 @@
+package xn.hxp.ui.plan.already;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import xn.hxp.ui.plan.room.bean.locker.HxpCabinetDoorVo;
+
+/**
+ * 用于国睿待入库的需要开锁的对象
+ */
+public class AutoChemicalBean {
+    private String waitId;
+    private String oneUserId;
+    private String twoUserId;
+    // 需要开锁的柜门集合
+    private List<HxpCabinetDoorVo> hxpCabinetDoorVoList = new ArrayList<>();
+
+    public String getWaitId() {
+        return waitId;
+    }
+
+    public void setWaitId(String waitId) {
+        this.waitId = waitId;
+    }
+
+    public String getOneUserId() {
+        return oneUserId;
+    }
+
+    public void setOneUserId(String oneUserId) {
+        this.oneUserId = oneUserId;
+    }
+
+    public String getTwoUserId() {
+        return twoUserId;
+    }
+
+    public void setTwoUserId(String twoUserId) {
+        this.twoUserId = twoUserId;
+    }
+
+    public List<HxpCabinetDoorVo> getHxpCabinetDoorVoList() {
+        return hxpCabinetDoorVoList;
+    }
+
+    public void setHxpCabinetDoorVoList(List<HxpCabinetDoorVo> hxpCabinetDoorVoList) {
+        this.hxpCabinetDoorVoList = hxpCabinetDoorVoList;
+    }
+}

+ 11 - 2
app/src/main/java/xn/hxp/ui/plan/room/bean/input_add/InventoryItemBean.java

@@ -4,19 +4,20 @@ import androidx.room.Entity;
 import androidx.room.PrimaryKey;
 import androidx.room.TypeConverters;
 
-import xn.hxp.ui.plan.room.RoomConverter;
-import xn.hxp.ui.plan.room.bean.locker.CabinetLayerSelect;
 import com.rc.httpcore.bean.BelongingPersonBean;
 import com.rc.httpcore.bean.HxpChemicalVo;
 import com.rc.httpcore.bean.TopicDataBean;
 
 import java.io.Serializable;
 
+import xn.hxp.ui.plan.room.RoomConverter;
+
 @Entity
 @TypeConverters(RoomConverter.class)
 public class InventoryItemBean implements Serializable {
     @PrimaryKey(autoGenerate = true)
     private int id;
+    private long waitId;
     private long cabinetId;
     private long doorId;
     private int layer;
@@ -35,6 +36,14 @@ public class InventoryItemBean implements Serializable {
         this.layer = layer;
     }
 
+    public long getWaitId() {
+        return waitId;
+    }
+
+    public void setWaitId(long waitId) {
+        this.waitId = waitId;
+    }
+
     public int getId() {
         return id;
     }

+ 3 - 4
app/src/main/java/xn/hxp/ui/plan/room/bean/locker/HxpCabinetDoorVo.java

@@ -1,16 +1,15 @@
 package xn.hxp.ui.plan.room.bean.locker;
 
 import androidx.room.Entity;
-import androidx.room.ForeignKey;
-import androidx.room.Ignore;
 import androidx.room.PrimaryKey;
 import androidx.room.TypeConverters;
 
-import xn.hxp.ui.plan.room.RoomConverter;
-
 import java.util.ArrayList;
 import java.util.List;
 
+import xn.hxp.ui.plan.room.RoomConverter;
+
+
 /**
  * 柜门
  */

+ 21 - 3
app/src/main/java/xn/hxp/ui/plan/room/dao/HxpInventoryDAO.java

@@ -5,16 +5,19 @@ import androidx.room.Delete;
 import androidx.room.Insert;
 import androidx.room.OnConflictStrategy;
 import androidx.room.Query;
+import androidx.room.Transaction;
 import androidx.room.Update;
 
-import xn.hxp.ui.plan.room.bean.input_add.InventoryItemBean;
-import xn.hxp.ui.plan.room.bean.locker.CabinetLayerSelect;
-
 import java.util.List;
 
+import xn.hxp.ui.plan.room.bean.input_add.InventoryItemBean;
+
 @Dao
 public interface HxpInventoryDAO {
 
+    @Insert
+    void justInsert(InventoryItemBean inventoryItemBean);
+
     @Insert(onConflict = OnConflictStrategy.REPLACE)
     void insert(InventoryItemBean inventoryItemBean);
 
@@ -42,4 +45,19 @@ public interface HxpInventoryDAO {
     @Query("DELETE FROM inventoryitembean")
     void deleteAll();
 
+
+    @Query("SELECT COUNT(*) FROM inventoryitembean WHERE waitId = :waitId")
+    int checkWaitIdExists(long waitId);
+
+    @Transaction
+    default void upsert(InventoryItemBean inventoryItemBean) {
+        int exist = checkWaitIdExists(inventoryItemBean.getWaitId());
+        if (exist > 0) {
+            update(inventoryItemBean);
+        } else {
+            justInsert(inventoryItemBean);
+        }
+    }
+
+
 }

+ 1 - 1
app/src/main/java/xn/hxp/ui/plan/save_list/SaveListActivity.java

@@ -101,7 +101,6 @@ public class SaveListActivity extends BaseActivity {
         cabinetDAO = RoomTool.getInstance().hxpCabinetDAO();
         doorDAO = RoomTool.getInstance().hxpDoorDAO();
         List<InventoryItemBean> inventoryItemBeanList = inventoryDAO.getAll();
-
         for (int i = 0; i < inventoryItemBeanList.size(); i++) {
             InventoryItemBean inventoryItemBean = inventoryItemBeanList.get(i);
             SaveListBean saveListBean = new SaveListBean();
@@ -137,6 +136,7 @@ public class SaveListActivity extends BaseActivity {
         Intent getIntent = getIntent();
         if (null != getIntent && getIntent.hasExtra("data")) {
             planAddData = GsonUtils.fromJson(getIntent.getStringExtra("data"), PlanAddData.class);
+            LogUtils.json(planAddData);
             userValidation1 = GsonUtils.fromJson(getIntent.getStringExtra("userValidation1"), UserValidationBean.class);
             userValidation2 = GsonUtils.fromJson(getIntent.getStringExtra("userValidation2"), UserValidationBean.class);
         }

+ 3 - 1
app/src/main/java/xn/hxp/ui/plan/unlock/UnlockActivity.java

@@ -39,6 +39,7 @@ public class UnlockActivity extends BaseActivity {
     private UserValidationBean userValidation2;
 
     protected UnlockAdapter unlockAdapter;
+    private boolean isAuto;
 
 
     @Override
@@ -51,6 +52,7 @@ public class UnlockActivity extends BaseActivity {
         Intent getIntent = getIntent();
         if (null != getIntent && getIntent.hasExtra("data")) {
             String json = getIntent.getStringExtra("data");
+            isAuto = getIntent.getBooleanExtra("isAuto", false);
             if (null != json && !TextUtils.isEmpty(json)) {
                 planAddData = GsonUtils.fromJson(json, PlanAddData.class);
                 activityHelp = new UnlockActivityHelp(this, planAddData);
@@ -81,7 +83,7 @@ public class UnlockActivity extends BaseActivity {
                 binding.saveBT.setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View v) {
-                        activityHelp.save();
+                        activityHelp.save(isAuto);
                     }
                 });
             }

+ 125 - 74
app/src/main/java/xn/hxp/ui/plan/unlock/UnlockActivityHelp.java

@@ -17,6 +17,7 @@ import com.rc.httpcore.bean.UserValidationBean;
 import com.rc.httpcore.client.ApiRepository;
 import com.rc.httpcore.client.HttpTool;
 
+import org.json.JSONArray;
 import org.json.JSONObject;
 
 import java.util.ArrayList;
@@ -493,91 +494,141 @@ public class UnlockActivityHelp {
         return null;
     }
 
-    public void save() {
+    public void save(boolean isAuto) {
         activity.binding.saveBT.setEnabled(false);
         activity.showLoading("入库中...");
-        ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<String>() {
-            @Override
-            public String doInBackground() throws Throwable {
-                HxpInventoryDAO hxpInventoryDAO = RoomTool.getInstance().hxpInventoryDAO();
-                HxpCabinetDAO cabinetDAO = RoomTool.getInstance().hxpCabinetDAO();
-                HxpDoorDAO doorDAO = RoomTool.getInstance().hxpDoorDAO();
-                List<InventoryItemBean> inventoryItemBeanList = hxpInventoryDAO.getAll();
-                List<HxpChemicalVo> hxpChemicalVoList = new ArrayList<>();
-                for (int i = 0; i < inventoryItemBeanList.size(); i++) {
-                    InventoryItemBean inventoryItemBean = inventoryItemBeanList.get(i);
-                    BelongingPersonBean belongingPersonBean = inventoryItemBean.getBelongingPersonBean();
-                    TopicDataBean topicDataBean = inventoryItemBean.getTopicDataBean();
-                    HxpChemicalVo hxpChemicalVo = inventoryItemBean.getHxpChemicalVo();
-                    if (null == belongingPersonBean) {
-                        hxpChemicalVo.setBelongId(Long.parseLong(topicDataBean.getTopicId()));
-                        hxpChemicalVo.setBelongName(topicDataBean.getTopicName());
-                        hxpChemicalVo.setBelongType(1);
+        if (isAuto) {
+            ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<String>() {
+                @Override
+                public String doInBackground() throws Throwable {
+
+                    List<String> autoChemicalList = activity.planAddData.getAutoChemicalList();
+                    JSONArray jsonArray = new JSONArray();
+                    for (int i = 0; i < autoChemicalList.size(); i++) {
+                        String waitId = autoChemicalList.get(i);
+                        JSONObject jsonObject = new JSONObject();
+                        jsonObject.put("waitId", waitId);
+                        jsonObject.put("oneUserId", userValidation1.getUserId());
+                        jsonObject.put("twoUserId", userValidation2.getUserId());
+                        jsonArray.put(jsonObject);
+                    }
+                    LogUtils.d(jsonArray);
+                    Response response = HttpTool.autoChemicals(jsonArray.toString());
+                    if (response.isSuccessful()) {
+                        String json = response.body().string();
+                        JSONObject jsonObject = new JSONObject(json);
+                        int code = jsonObject.getInt("code");
+                        if (code == 200) {
+                            return "";
+                        } else {
+                            return jsonObject.getString("message");
+                        }
                     } else {
-                        hxpChemicalVo.setBelongId(Long.parseLong(belongingPersonBean.getUserId()));
-                        hxpChemicalVo.setBelongName(belongingPersonBean.getUserName());
-                        hxpChemicalVo.setBelongType(2);
+                        return response.message();
                     }
-                    hxpChemicalVo.setOneUserId(Long.parseLong(userValidation1.getUserId()));
-                    hxpChemicalVo.setOneUserName(userValidation1.getUserName());
-                    hxpChemicalVo.setTwoUserId(Long.parseLong(userValidation2.getUserId()));
-                    hxpChemicalVo.setTwoUserName(userValidation2.getUserName());
-                    hxpChemicalVo.setSubId(Long.parseLong(ChemicalApp.subjectId));
-
-                    hxpChemicalVo.setChemicalNumber(inventoryItemBean.getSize());
-                    HxpCabinetVo cabinetVo = cabinetDAO.getById(inventoryItemBean.getCabinetId());
-                    hxpChemicalVo.setCabinetId(cabinetVo.getCabinetId());
-                    hxpChemicalVo.setCabinetName(cabinetVo.getCabinetName());
-
-                    HxpCabinetDoorVo doorVo = doorDAO.getById(inventoryItemBean.getDoorId());
-                    // 后台要求这么干
-                    hxpChemicalVo.setDoorId(doorVo.getDoorUniqueId());
-                    hxpChemicalVo.setDoorName(doorVo.getDoorName());
-
-                    hxpChemicalVo.setLayers(String.valueOf(inventoryItemBean.getLayer()));
-                    hxpChemicalVoList.add(hxpChemicalVo);
                 }
-                LogUtils.json(hxpChemicalVoList);
-                Response response = HttpTool.addChemical(hxpChemicalVoList);
-                if (response.isSuccessful()) {
-                    String json = response.body().string();
-                    JSONObject jsonObject = new JSONObject(json);
-                    int code = jsonObject.getInt("code");
-                    if (code == 200) {
-                        return "";
+
+                @Override
+                public void onSuccess(String result) {
+                    activity.dismissLoading();
+                    if (!TextUtils.isEmpty(result)) {
+                        PopTip.show(result);
+                        activity.binding.saveBT.setEnabled(true);
                     } else {
-                        return jsonObject.getString("message");
+                        activity.finish();
+                        Intent intent = new Intent(activity, SaveListActivity.class);
+                        intent.putExtra("data", GsonUtils.toJson(activity.planAddData));
+                        intent.putExtra("userValidation1", GsonUtils.toJson(userValidation1));
+                        intent.putExtra("userValidation2", GsonUtils.toJson(userValidation1));
+                        activity.startActivity(intent);
                     }
-                } else {
-                    return response.message();
                 }
-            }
+            });
 
-            @Override
-            public void onSuccess(String result) {
-                activity.dismissLoading();
-                if (!TextUtils.isEmpty(result)) {
-                    PopTip.show(result);
-                    activity.binding.saveBT.setEnabled(true);
-                } else {
-                    activity.finish();
-
-                    Intent intent = new Intent(activity, SaveListActivity.class);
-                    intent.putExtra("data", GsonUtils.toJson(activity.planAddData));
-                    intent.putExtra("userValidation1", GsonUtils.toJson(userValidation1));
-                    intent.putExtra("userValidation2", GsonUtils.toJson(userValidation1));
-                    activity.startActivity(intent);
+        } else {
+            ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<String>() {
+                @Override
+                public String doInBackground() throws Throwable {
+                    HxpInventoryDAO hxpInventoryDAO = RoomTool.getInstance().hxpInventoryDAO();
+                    HxpCabinetDAO cabinetDAO = RoomTool.getInstance().hxpCabinetDAO();
+                    HxpDoorDAO doorDAO = RoomTool.getInstance().hxpDoorDAO();
+                    List<InventoryItemBean> inventoryItemBeanList = hxpInventoryDAO.getAll();
+                    List<HxpChemicalVo> hxpChemicalVoList = new ArrayList<>();
+                    for (int i = 0; i < inventoryItemBeanList.size(); i++) {
+                        InventoryItemBean inventoryItemBean = inventoryItemBeanList.get(i);
+                        BelongingPersonBean belongingPersonBean = inventoryItemBean.getBelongingPersonBean();
+                        TopicDataBean topicDataBean = inventoryItemBean.getTopicDataBean();
+                        HxpChemicalVo hxpChemicalVo = inventoryItemBean.getHxpChemicalVo();
+                        if (null == belongingPersonBean) {
+                            hxpChemicalVo.setBelongId(Long.parseLong(topicDataBean.getTopicId()));
+                            hxpChemicalVo.setBelongName(topicDataBean.getTopicName());
+                            hxpChemicalVo.setBelongType(1);
+                        } else {
+                            hxpChemicalVo.setBelongId(Long.parseLong(belongingPersonBean.getUserId()));
+                            hxpChemicalVo.setBelongName(belongingPersonBean.getUserName());
+                            hxpChemicalVo.setBelongType(2);
+                        }
+                        hxpChemicalVo.setOneUserId(Long.parseLong(userValidation1.getUserId()));
+                        hxpChemicalVo.setOneUserName(userValidation1.getUserName());
+                        hxpChemicalVo.setTwoUserId(Long.parseLong(userValidation2.getUserId()));
+                        hxpChemicalVo.setTwoUserName(userValidation2.getUserName());
+                        hxpChemicalVo.setSubId(Long.parseLong(ChemicalApp.subjectId));
+
+                        hxpChemicalVo.setChemicalNumber(inventoryItemBean.getSize());
+                        HxpCabinetVo cabinetVo = cabinetDAO.getById(inventoryItemBean.getCabinetId());
+                        hxpChemicalVo.setCabinetId(cabinetVo.getCabinetId());
+                        hxpChemicalVo.setCabinetName(cabinetVo.getCabinetName());
+
+                        HxpCabinetDoorVo doorVo = doorDAO.getById(inventoryItemBean.getDoorId());
+                        // 后台要求这么干
+                        hxpChemicalVo.setDoorId(doorVo.getDoorUniqueId());
+                        hxpChemicalVo.setDoorName(doorVo.getDoorName());
+
+                        hxpChemicalVo.setLayers(String.valueOf(inventoryItemBean.getLayer()));
+                        hxpChemicalVoList.add(hxpChemicalVo);
+                    }
+                    LogUtils.json(hxpChemicalVoList);
+                    Response response = HttpTool.addChemical(hxpChemicalVoList);
+                    if (response.isSuccessful()) {
+                        String json = response.body().string();
+                        JSONObject jsonObject = new JSONObject(json);
+                        int code = jsonObject.getInt("code");
+                        if (code == 200) {
+                            return "";
+                        } else {
+                            return jsonObject.getString("message");
+                        }
+                    } else {
+                        return response.message();
+                    }
                 }
-            }
 
-            @Override
-            public void onFail(Throwable t) {
-                super.onFail(t);
-                activity.dismissLoading();
-                activity.binding.saveBT.setEnabled(true);
-                PopTip.show(t.getMessage());
-            }
-        });
+                @Override
+                public void onSuccess(String result) {
+                    activity.dismissLoading();
+                    if (!TextUtils.isEmpty(result)) {
+                        PopTip.show(result);
+                        activity.binding.saveBT.setEnabled(true);
+                    } else {
+                        activity.finish();
+
+                        Intent intent = new Intent(activity, SaveListActivity.class);
+                        intent.putExtra("data", GsonUtils.toJson(activity.planAddData));
+                        intent.putExtra("userValidation1", GsonUtils.toJson(userValidation1));
+                        intent.putExtra("userValidation2", GsonUtils.toJson(userValidation1));
+                        activity.startActivity(intent);
+                    }
+                }
+
+                @Override
+                public void onFail(Throwable t) {
+                    super.onFail(t);
+                    activity.dismissLoading();
+                    activity.binding.saveBT.setEnabled(true);
+                    PopTip.show(t.getMessage());
+                }
+            });
+        }
     }
 
 }

+ 8 - 5
app/src/main/java/xn/hxp/ui/still/ChemicalsAlsoActivity.kt

@@ -275,7 +275,7 @@ class ChemicalsAlsoActivity : BaseActivity() {
             }
             //
             print.types = "${mDataBean.chemicalCategoryName}"
-            PrintTool.INSTANCE.print(mDataBean.belongType == 2, print)
+            PrintTool.INSTANCE.print(mDataBean.isGr, mDataBean.belongType == 2, print)
         }
 
         viewBinding.replaceLabel.setOnClickListener {
@@ -418,7 +418,7 @@ class ChemicalsAlsoActivity : BaseActivity() {
             }
             //
             print.types = "${mDataBean.chemicalCategoryName}"
-            PrintTool.INSTANCE.print(mDataBean.belongType == 2, print)
+            PrintTool.INSTANCE.print(mDataBean.isGr,mDataBean.belongType == 2, print)
         }, { throwable ->
             dismissLoading()
             showNetError(throwable)
@@ -664,7 +664,8 @@ class ChemicalsAlsoActivity : BaseActivity() {
         if (::mDataBean.isInitialized) {
             var density = "${mDataBean.specNum}${mDataBean.specUnit}/${mDataBean.packUnit}"
             //确定  链接蓝牙
-            mWeighDialog = WeighDialog(this@ChemicalsAlsoActivity,
+            mWeighDialog = WeighDialog(
+                this@ChemicalsAlsoActivity,
                 density, object : WeighDialog.IViewLint {
                     override fun weighingView(weighingValue: EditText) {
                         //称重页面 获取的文本TextView  后期可能是输入框
@@ -879,7 +880,8 @@ class ChemicalsAlsoActivity : BaseActivity() {
                 }
 
                 val cabinetOpenDialog =
-                    CabinetOpenDialog(this@ChemicalsAlsoActivity,
+                    CabinetOpenDialog(
+                        this@ChemicalsAlsoActivity,
                         isLock,
                         "${data.useAmount!!}${data.specUnit}",
                         "${data.remark!!}${data.specUnit}",
@@ -935,7 +937,8 @@ class ChemicalsAlsoActivity : BaseActivity() {
         customDialogView(1, "请将化学品放入化学品柜")
         AudioPlayer.getInstance().play(R.raw.gui_men_yi_kai_fang_ru_hxp)
         val cabinetOpenDialog =
-            CabinetOpenDialog(this@ChemicalsAlsoActivity,
+            CabinetOpenDialog(
+                this@ChemicalsAlsoActivity,
                 false,
                 "${mReturnDetailsBean.useAmount!!}${mReturnDetailsBean.specUnit}",
                 "${mReturnDetailsBean.remark!!}${mReturnDetailsBean.specUnit}",

+ 4 - 3
app/src/main/java/xn/hxp/ui/warehousing/ChemicalLabelingActivity.kt

@@ -139,7 +139,7 @@ class ChemicalLabelingActivity : BaseActivity() {
             }
             //
             print.types = "${mData.chemicalCategoryName}"
-            PrintTool.INSTANCE.print(mData.belongType == 2, print)
+            PrintTool.INSTANCE.print(mData.isGr, mData.belongType == 2, print)
         }
 
         viewBinding.replaceLabel.setOnClickListener {
@@ -474,7 +474,7 @@ class ChemicalLabelingActivity : BaseActivity() {
             }
             //
             print.types = "${mData.chemicalCategoryName}"
-            PrintTool.INSTANCE.print(mData.belongType == 2, print)
+            PrintTool.INSTANCE.print(mData.isGr, mData.belongType == 2, print)
             mAdapter.data[mAdIndex].rfidCode = rfid
             mAdapter.notifyItemChanged(mAdIndex)
         }, { throwable ->
@@ -1013,7 +1013,8 @@ class ChemicalLabelingActivity : BaseActivity() {
             .subscribe({ data ->
                 dismissLoading()
                 val storageDialog =
-                    StorageDialog(ct = this,
+                    StorageDialog(
+                        ct = this,
                         listData = data!!,
                         lint = object : StorageDialog.IonClickListener {
                             override fun onClick(

+ 261 - 0
app/src/main/java/xn/hxp/utils/BitmapUtils.java

@@ -0,0 +1,261 @@
+package xn.hxp.utils;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Typeface;
+import android.util.Log;
+
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.WriterException;
+import com.google.zxing.common.BitMatrix;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import xn.hxp.ui.PrintBean;
+
+public final class BitmapUtils {
+
+    private BitmapUtils() {
+        // 私有构造函数防止实例化
+    }
+
+    public static Bitmap generateBitmap(PrintBean printDate) {
+        // 设置画布尺寸
+        int width = 400;
+        int height = 400;
+
+        // 创建 Bitmap
+        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+
+        // 创建 Canvas
+        Canvas canvas = new Canvas(bitmap);
+
+        // 设置背景色
+        canvas.drawColor(Color.WHITE);
+
+        // 居中绘制二维码
+        int qrCodeSize = 225;
+        int qrCodeX = (width - qrCodeSize) / 2;
+        int qrCodeY = 0;
+        drawQRCode(printDate.getWxCode(), canvas, qrCodeX, qrCodeY, 230);
+
+        // 在二维码下方居中绘制文本
+        String text = "编码:" + printDate.getTag();
+        float textX = (width - getTextWidth(text, 20)) / 2;
+        float textY = qrCodeY + qrCodeSize - 6;
+        drawText(canvas, text, textX, textY, 19);
+
+        // 计算剩余内容的起始 Y 坐标
+        float contentStartY = textY + 30;
+
+        // 绘制剩余的内容,左对齐显示
+        List<String> content = List.of(
+                printDate.getLevel() + " 一 " + printDate.getName(),
+                "CAS:" + printDate.getCasNo() + "      " + printDate.getTypes(),
+                "归属人:" + printDate.getPerson()
+        );
+
+        int lineHeight = 24;
+        for (int index = 0; index < content.size(); index++) {
+            drawText(canvas, content.get(index), 10f, contentStartY + index * lineHeight, 20);
+        }
+        return bitmap;
+    }
+
+    public static Bitmap drawBarCode(String number, Canvas canvas, int qrCodeX, int qrCodeY, int barW, int barH) {
+        Bitmap bitmap = Bitmap.createBitmap(barW, barH, Bitmap.Config.ARGB_8888);
+        try {
+            Map<EncodeHintType, Object> hints = new HashMap<>();
+            hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
+            BitMatrix bitMatrix = new MultiFormatWriter().encode(number, BarcodeFormat.CODE_128, barW, barH, hints);
+            int[] pixels = new int[barW * barH];
+            for (int y = 0; y < barH; y++) {
+                for (int x = 0; x < barW; x++) {
+                    pixels[y * barW + x] = bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF;
+                }
+            }
+
+            bitmap.setPixels(pixels, 0, barW, 0, 0, barW, barH);
+            canvas.drawBitmap(bitmap, 0, qrCodeY, null);
+        } catch (WriterException e) {
+            return null;
+        }
+        return bitmap;
+    }
+
+
+    public static Bitmap generateBarBitmap(boolean isBelong, PrintBean printBean) {
+        int width = 400;
+        int height = 400;
+
+        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+        Canvas canvas = new Canvas(bitmap);
+        canvas.drawColor(Color.WHITE);
+
+        int barH = 180;
+        int barW = 400;
+        int qrCodeY = 10;
+        drawBarCode(printBean.getTag(), canvas, 0, qrCodeY, barW, barH);
+
+        int textSize = 20;
+        String text = printBean.getTag();
+        float textX = (width - getTextWidth(text, textSize)) / 2;
+        float textY = qrCodeY + barH + textSize;
+        drawText(canvas, text, textX, textY, textSize);
+
+        float contentStartY = textY + 30;
+        String string = isBelong ?
+                "归属人:" + printBean.getPerson() :
+                "课题组:" + printBean.getPerson();
+
+        List<String> content = List.of(
+                printBean.getLevel() + " 一 " + printBean.getName(),
+                "CAS:" + printBean.getCasNo() + "      " + printBean.getTypes(),
+                string
+        );
+
+        int lineHeight = 24;
+        for (int index = 0; index < content.size(); index++) {
+            drawText(canvas, content.get(index), 10f, contentStartY + index * lineHeight, textSize);
+        }
+        return bitmap;
+    }
+
+
+    public static Bitmap generateBitmap(boolean isBelong, PrintBean printDate) {
+        int width = 400;
+        int height = 400;
+
+        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+        Canvas canvas = new Canvas(bitmap);
+        canvas.drawColor(Color.WHITE);
+
+        int qrCodeSize = 225;
+        int qrCodeX = (width - qrCodeSize) / 2;
+        int qrCodeY = 0;
+        drawQRCode(printDate.getWxCode(), canvas, qrCodeX, qrCodeY, 230);
+
+        String text = "编码:" + printDate.getTag();
+        float textX = (width - getTextWidth(text, 20)) / 2;
+        float textY = qrCodeY + qrCodeSize - 6;
+        drawText(canvas, text, textX, textY, 19);
+
+        float contentStartY = textY + 30;
+        String string = isBelong ?
+                "归属人:" + printDate.getPerson() :
+                "课题组:" + printDate.getPerson();
+
+        List<String> content = List.of(
+                printDate.getLevel() + " 一 " + printDate.getName(),
+                "CAS:" + printDate.getCasNo() + "      " + printDate.getTypes(),
+                string
+        );
+
+        int lineHeight = 24;
+        for (int index = 0; index < content.size(); index++) {
+            drawText(canvas, content.get(index), 10f, contentStartY + index * lineHeight, 20);
+        }
+        return bitmap;
+    }
+
+    private static void drawQRCode(String tag, Canvas canvas, int x, int y, int size) {
+        MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
+        try {
+            Map<EncodeHintType, String> hints = new HashMap<>();
+            hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
+
+            BitMatrix bitMatrix = multiFormatWriter.encode(
+                    tag,
+                    BarcodeFormat.QR_CODE,
+                    size,
+                    size,
+                    hints
+            );
+
+            int width = bitMatrix.getWidth();
+            int height = bitMatrix.getHeight();
+            int[] pixels = new int[width * height];
+
+            for (int yPos = 0; yPos < height; yPos++) {
+                int offset = yPos * width;
+                for (int xPos = 0; xPos < width; xPos++) {
+                    pixels[offset + xPos] = bitMatrix.get(xPos, yPos) ? Color.BLACK : Color.WHITE;
+                }
+            }
+
+            Bitmap qrCodeBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+            qrCodeBitmap.setPixels(pixels, 0, width, 0, 0, width, height);
+            canvas.drawBitmap(qrCodeBitmap, x, y, null);
+
+        } catch (WriterException e) {
+            Log.e("BitmapUtils", "Failed to generate QR code: " + e.getMessage());
+        }
+    }
+
+    private static void drawText(Canvas canvas, String text, float x, float y, int textSize) {
+        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+        paint.setColor(Color.BLACK);
+        paint.setTextSize(textSize);
+        paint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
+        canvas.drawText(text, x, y, paint);
+    }
+
+    private static float getTextWidth(String text, int textSize) {
+        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+        paint.setTextSize(textSize);
+        return paint.measureText(text);
+    }
+
+    public static Bitmap airBottlePrint(String rfid) {
+        int width = 400;
+        int height = 400;
+
+        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+        Canvas canvas = new Canvas(bitmap);
+        canvas.drawColor(Color.WHITE);
+
+        int qrCodeSize = 225;
+        int qrCodeX = (width - qrCodeSize) / 2;
+        int qrCodeY = 6;
+        drawQRCode(rfid, canvas, qrCodeX, qrCodeY, 230);
+
+        String text = rfid;
+        float textX = (width - getTextWidth(text, 20)) / 2;
+        float textY = qrCodeY + qrCodeSize - 6;
+        drawText(canvas, text, textX, textY, 19);
+
+        float contentStartY = textY + 30;
+        List<String> content = List.of("", "", "");
+
+        int lineHeight = 24;
+        for (int index = 0; index < content.size(); index++) {
+            drawText(canvas, content.get(index), 10f, contentStartY + index * lineHeight, 20);
+        }
+        return bitmap;
+    }
+
+    /**
+     * 将BitMatrix转换为Bitmap
+     */
+    private static Bitmap bitMatrixToBitmap(BitMatrix matrix) {
+        int width = matrix.getWidth();
+        int height = matrix.getHeight();
+        int[] pixels = new int[width * height];
+
+        for (int y = 0; y < height; y++) {
+            for (int x = 0; x < width; x++) {
+                pixels[y * width + x] = matrix.get(x, y) ? Color.BLACK : Color.WHITE;
+            }
+        }
+
+        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+        bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
+        return bitmap;
+    }
+}

+ 0 - 182
app/src/main/java/xn/hxp/utils/BitmapUtils.kt

@@ -1,182 +0,0 @@
-package xn.hxp.utils
-
-import android.graphics.*
-import android.util.Log
-import xn.hxp.ui.PrintBean
-import com.google.zxing.BarcodeFormat
-import com.google.zxing.EncodeHintType
-import com.google.zxing.MultiFormatWriter
-import com.google.zxing.WriterException
-import com.blankj.utilcode.util.LogUtils
-
-
-object BitmapUtils {
-
-
-    fun generateBitmap(printDate: PrintBean): Bitmap? {
-        // 设置画布尺寸
-        val width = 400
-        val height = 400 // 225 * 3,每行占 225 的高度
-
-        // 创建 Bitmap
-        val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
-
-        // 创建 Canvas
-        val canvas = Canvas(bitmap)
-
-        // 设置背景色
-        canvas.drawColor(Color.WHITE)
-
-        // 居中绘制二维码
-        val qrCodeSize = 225
-        val qrCodeX = (width - qrCodeSize) / 2
-        val qrCodeY = 0
-        drawQRCode(printDate.wxCode, canvas, qrCodeX, qrCodeY, 230)
-        // 在二维码下方居中绘制文本
-        val text = "编码:${printDate.tag}"
-        val textX = (width - getTextWidth(text, 20)) / 2
-        val textY = qrCodeY + qrCodeSize - 6
-        drawText(canvas, text, textX, textY.toFloat(), 19)
-        // 计算剩余内容的起始 Y 坐标
-        val contentStartY = textY + 30
-        // 绘制剩余的内容,左对齐显示
-        val content = listOf(
-            "${printDate.level} 一 ${printDate.name}",
-            "CAS:${printDate.casNo}      ${printDate.types}",
-            "归属人:${printDate.person}",
-        )
-        val lineHeight = 24
-        content.forEachIndexed { index, line ->
-            drawText(canvas, line, 10f, contentStartY + index * lineHeight.toFloat(), 20)
-        }
-        return bitmap
-    }
-
-    fun generateBitmap(isBelong: Boolean, printDate: PrintBean): Bitmap? {
-        // 设置画布尺寸
-        val width = 400
-        val height = 400 // 225 * 3,每行占 225 的高度
-
-        // 创建 Bitmap
-        val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
-
-        // 创建 Canvas
-        val canvas = Canvas(bitmap)
-
-        // 设置背景色
-        canvas.drawColor(Color.WHITE)
-
-        // 居中绘制二维码
-        val qrCodeSize = 225
-        val qrCodeX = (width - qrCodeSize) / 2
-        val qrCodeY = 0
-        drawQRCode(printDate.wxCode, canvas, qrCodeX, qrCodeY, 230)
-        // 在二维码下方居中绘制文本
-        val text = "编码:${printDate.tag}"
-        val textX = (width - getTextWidth(text, 20)) / 2
-        val textY = qrCodeY + qrCodeSize - 6
-        drawText(canvas, text, textX, textY.toFloat(), 19)
-        // 计算剩余内容的起始 Y 坐标
-        val contentStartY = textY + 30
-        // 绘制剩余的内容,左对齐显示
-        val string: String = if (isBelong) {
-            "归属人:${printDate.person} "
-        } else {
-            "课题组:${printDate.person} "
-        }
-        val content = listOf(
-            "${printDate.level} 一 ${printDate.name}",
-            "CAS:${printDate.casNo}      ${printDate.types}",
-            string,
-        )
-        val lineHeight = 24
-        content.forEachIndexed { index, line ->
-            drawText(canvas, line, 10f, contentStartY + index * lineHeight.toFloat(), 20)
-        }
-        return bitmap
-    }
-
-    //编码 生成二维码
-    private fun drawQRCode(tag: String, canvas: Canvas, x: Int, y: Int, size: Int) {
-        val multiFormatWriter = MultiFormatWriter()
-        try {
-            val bitMatrix = multiFormatWriter.encode(
-                "$tag", // 你想要生成二维码的内容
-                BarcodeFormat.QR_CODE,
-                size,
-                size,
-                hashMapOf(EncodeHintType.CHARACTER_SET to "UTF-8")
-            )
-            val width = bitMatrix.width
-            val height = bitMatrix.height
-            val pixels = IntArray(width * height)
-            for (y in 0 until height) {
-                val offset = y * width
-                for (x in 0 until width) {
-                    pixels[offset + x] = if (bitMatrix.get(x, y)) Color.BLACK else Color.WHITE
-                }
-            }
-            val qrCodeBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
-            qrCodeBitmap.setPixels(pixels, 0, width, 0, 0, width, height)
-            canvas.drawBitmap(qrCodeBitmap, x.toFloat(), y.toFloat(), null)
-        } catch (e: WriterException) {
-            Log.e("BitmapUtils", "Failed to generate QR code: ${e.message}")
-        }
-    }
-
-    private fun drawText(canvas: Canvas, text: String, x: Float, y: Float, textSize: Int) {
-        val paint = Paint(Paint.ANTI_ALIAS_FLAG)
-        paint.color = Color.BLACK
-        paint.textSize = textSize.toFloat()
-        paint.typeface = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)
-        canvas.drawText(text, x, y, paint)
-    }
-
-    private fun getTextWidth(text: String, textSize: Int): Float {
-        val paint = Paint(Paint.ANTI_ALIAS_FLAG)
-        paint.textSize = textSize.toFloat()
-        return paint.measureText(text)
-    }
-
-    //气瓶信息打印
-    fun airBottlePrint(rfid: String): Bitmap? {
-        // 设置画布尺寸
-        val width = 400
-        val height = 400 // 225 * 3,每行占 225 的高度
-
-        // 创建 Bitmap
-        val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
-
-        // 创建 Canvas
-        val canvas = Canvas(bitmap)
-
-        // 设置背景色
-        canvas.drawColor(Color.WHITE)
-
-        // 居中绘制二维码
-        val qrCodeSize = 225
-        val qrCodeX = (width - qrCodeSize) / 2
-        LogUtils.i("======二维码剧中数据$qrCodeX")
-        val qrCodeY = 6
-        drawQRCode(rfid, canvas, qrCodeX, qrCodeY, 230)
-        // 在二维码下方居中绘制文本
-        val text = "" +
-                "$rfid"
-        val textX = (width - getTextWidth(text, 20)) / 2
-        val textY = qrCodeY + qrCodeSize - 6
-        drawText(canvas, text, textX, textY.toFloat(), 19)
-        // 计算剩余内容的起始 Y 坐标
-        val contentStartY = textY + 30
-        // 绘制剩余的内容,左对齐显示
-        val content = listOf(
-            "",
-            "",
-            "",
-        )
-        val lineHeight = 24
-        content.forEachIndexed { index, line ->
-            drawText(canvas, line, 10f, contentStartY + index * lineHeight.toFloat(), 20)
-        }
-        return bitmap
-    }
-}

+ 47 - 5
app/src/main/java/xn/hxp/utils/PrintTool.java

@@ -22,7 +22,7 @@ public enum PrintTool {
     private AutoReplyPrint.CP_OnPrinterStatusEvent_Callback statusEventCallback;
     private AutoReplyPrint.CP_OnPrinterReceivedEvent_Callback receivedEventCallback;
 
-    public void print(boolean isBelong, PrintBean printBean) throws Exception {
+    public void print(boolean isGR, boolean isBelong, PrintBean printBean) throws Exception {
         try {
             if (null != openedEventCallback) {
                 openedEventCallback = (handle, name, private_data) -> LogUtils.d("打印机打开成功");
@@ -77,19 +77,61 @@ public enum PrintTool {
             }
             // 判断是否打开打印机
             if (AutoReplyPrint.INSTANCE.CP_Port_IsOpened(pointer)) {
-                startPrint(isBelong, printBean);
+                if (isGR) {
+                    startPrintGR(isBelong, printBean);
+                } else {
+                    startPrint(isBelong, printBean);
+                }
             } else {
                 pointer = AutoReplyPrint.INSTANCE.CP_Port_OpenUsb("VID:0x0FE6,PID:0x811E", 1);
                 LogUtils.d("打开打印机", pointer);
-                startPrint(isBelong, printBean);
+                if (isGR) {
+                    startPrintGR(isBelong, printBean);
+                } else {
+                    startPrint(isBelong, printBean);
+                }
             }
         } catch (Exception e) {
             LogUtils.d(Log.getStackTraceString(e));
         }
     }
 
+    private void startPrintGR(boolean isBelong, PrintBean printBean) {
+
+        Bitmap bitmap = BitmapUtils.generateBarBitmap(isBelong, printBean);
+
+        if (AutoReplyPrint.INSTANCE.CP_Label_BackPaperToPrintPosition(pointer)) {
+            LogUtils.d("打印机退纸成功");
+            if (AutoReplyPrint.CP_Pos_PrintRasterImageFromData_Helper.PrintRasterImageFromBitmap(pointer,
+                    bitmap.getWidth(),
+                    bitmap.getHeight(),
+                    bitmap,
+                    AutoReplyPrint.CP_ImageBinarizationMethod_Thresholding,
+                    AutoReplyPrint.CP_ImageCompressionMethod_None
+            )) {
+                LogUtils.d("打印机打印图片成功");
+                if (AutoReplyPrint.INSTANCE.CP_Label_PagePrint(pointer, 1)) {
+                    LogUtils.d("打印机文字成功");
+                    if (AutoReplyPrint.INSTANCE.CP_Pos_HalfCutPaper(pointer)) {
+                        LogUtils.d("打印机切割成功");
+                        AudioPlayer.getInstance().play(R.raw.label_to_the_package);
+                    } else {
+                        ThreadUtils.runOnUiThread(() -> Toast.makeText(ActivityUtils.getTopActivity(), "打印机切割失败", Toast.LENGTH_LONG).show());
+                    }
+                } else {
+                    ThreadUtils.runOnUiThread(() -> Toast.makeText(ActivityUtils.getTopActivity(), "打印机文字失败", Toast.LENGTH_LONG).show());
+                }
+            } else {
+                ThreadUtils.runOnUiThread(() -> Toast.makeText(ActivityUtils.getTopActivity(), "打印机打印图片失败", Toast.LENGTH_LONG).show());
+            }
+        } else {
+            ThreadUtils.runOnUiThread(() -> Toast.makeText(ActivityUtils.getTopActivity(), "打印机退纸失败", Toast.LENGTH_LONG).show());
+        }
+    }
+
     private void startPrint(boolean isBelong, PrintBean printBean) {
-        Bitmap bitmap = BitmapUtils.INSTANCE.generateBitmap(isBelong, printBean);
+        Bitmap bitmap = BitmapUtils.generateBitmap(isBelong, printBean);
+
         if (AutoReplyPrint.INSTANCE.CP_Label_BackPaperToPrintPosition(pointer)) {
             LogUtils.d("打印机退纸成功");
             if (AutoReplyPrint.CP_Pos_PrintRasterImageFromData_Helper.PrintRasterImageFromBitmap(pointer,
@@ -141,7 +183,7 @@ public enum PrintTool {
 
     private void startPrint(String string) {
         LogUtils.d("打印机打开成功");
-        Bitmap bitmap = BitmapUtils.INSTANCE.airBottlePrint(string);
+        Bitmap bitmap = BitmapUtils.airBottlePrint(string);
         if (AutoReplyPrint.INSTANCE.CP_Label_BackPaperToPrintPosition(pointer)) {
             LogUtils.d("打印机退纸成功");
             if (AutoReplyPrint.CP_Pos_PrintRasterImageFromData_Helper.PrintRasterImageFromBitmap(pointer,

+ 52 - 0
app/src/main/java/xn/hxp/weidith/PlanDialog.java

@@ -0,0 +1,52 @@
+package xn.hxp.weidith;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
+import android.view.Gravity;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+
+import androidx.annotation.NonNull;
+
+import xn.hxp.databinding.DialogPlanBinding;
+
+public class PlanDialog extends Dialog {
+    private DialogPlanBinding binding;
+    private View.OnClickListener alreadyClickListener;
+    private View.OnClickListener otherClickListener;
+
+    public PlanDialog(@NonNull Context context, View.OnClickListener alreadyClickListener, View.OnClickListener otherClickListener) {
+        super(context);
+        this.alreadyClickListener = alreadyClickListener;
+        this.otherClickListener = otherClickListener;
+        Window window = getWindow();
+        requestWindowFeature(Window.FEATURE_NO_TITLE);
+        if (null != window) {
+            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+            window.setGravity(Gravity.CENTER);
+            window.setLayout(
+                    WindowManager.LayoutParams.MATCH_PARENT,
+                    WindowManager.LayoutParams.WRAP_CONTENT
+            );
+        }
+
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        binding = DialogPlanBinding.inflate(getLayoutInflater());
+        setContentView(binding.getRoot());
+        binding.alreadyRL.setOnClickListener(alreadyClickListener);
+        binding.otherRL.setOnClickListener(otherClickListener);
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+    }
+}

+ 126 - 0
app/src/main/java/xn/hxp/weidith/PromptDialog.java

@@ -0,0 +1,126 @@
+package xn.hxp.weidith;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
+import android.os.CountDownTimer;
+import android.text.TextUtils;
+import android.view.Gravity;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+
+import androidx.annotation.NonNull;
+
+import com.rc.httpcore.bean.UseNoBean;
+
+import xn.hxp.databinding.PromptDialogBinding;
+
+public class PromptDialog extends Dialog {
+    private PromptDialogBinding binding;
+    private UseNoBean useNoBean;
+    private CountDownTimer countDownTimer;
+
+    public PromptDialog(@NonNull Context context, UseNoBean useNoBean) {
+        super(context);
+        this.useNoBean = useNoBean;
+        Window window = getWindow();
+        requestWindowFeature(Window.FEATURE_NO_TITLE);
+        if (null != window) {
+            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+            window.setGravity(Gravity.CENTER);
+            window.setLayout(
+                    WindowManager.LayoutParams.MATCH_PARENT,
+                    WindowManager.LayoutParams.WRAP_CONTENT
+            );
+        }
+
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        binding = PromptDialogBinding.inflate(getLayoutInflater());
+        setContentView(binding.getRoot());
+
+        String chemicalName = useNoBean.getChemicalName();
+        binding.chemicalName.setText(TextUtils.isEmpty(chemicalName) ? "无" : chemicalName);
+
+        String casNum = useNoBean.getCasNum();
+        binding.casNum.setText(TextUtils.isEmpty(casNum) ? "CAS:无" : "CAS:" + casNum);
+
+        String chemicalCategory = useNoBean.getChemicalCategory();
+        binding.chemicalCategory.setText(TextUtils.isEmpty(chemicalCategory) ? "类别:无" : "类别:" + chemicalCategory);
+
+        String specUnit = useNoBean.getSpecUnit();
+        String packUnit = useNoBean.getPackUnit();
+        int specNum = useNoBean.getSpecNum();
+        binding.sepl.setText("规格:" + specNum + (TextUtils.isEmpty(specUnit) ? "" : specUnit + "/" + (TextUtils.isEmpty(packUnit) ? "" : packUnit)));
+
+        String expireTime = useNoBean.getExpireTime();
+        Integer expireStatus = useNoBean.getExpireStatus();
+        if (!TextUtils.isEmpty(expireTime) && null != expireStatus) {
+            switch (expireStatus) {
+                case 1:
+                    binding.expireTime.setText("过期时间: " + expireTime);
+                    binding.expire.setText("已过期");
+                    break;
+                case 2:
+                    binding.expireTime.setText("过期时间: " + expireTime);
+                    binding.expire.setText("即将过期");
+                    break;
+                default:
+                    binding.expireTime.setText("过期时间: " + expireTime);
+                    break;
+            }
+        } else {
+            binding.expireTime.setText("过期时间:");
+        }
+
+        String tagCode = useNoBean.getTagCode();
+        binding.tagCode.setText(TextUtils.isEmpty(tagCode) ? "编码:无" : "编码:" + tagCode);
+
+        String chemicalLevelName = useNoBean.getChemicalLevelName();
+        binding.chemicalLevelName.setText(TextUtils.isEmpty(chemicalLevelName) ? "级别:无" : "级别:" + chemicalLevelName);
+
+        String surplus = useNoBean.getSurplus();
+        binding.surplus.setText(TextUtils.isEmpty(surplus) ? "库存量:无" : "库存量:" + surplus);
+
+        String belongName = useNoBean.getBelongName();
+        binding.belongName.setText(TextUtils.isEmpty(belongName) ? "归属人:无" : "归属人:" + belongName);
+
+        binding.butClos.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                dismiss();
+            }
+        });
+        countDownTimer = new CountDownTimer(15 * 1000, 1000) {
+            @Override
+            public void onTick(long millisUntilFinished) {
+                if (isShowing()) {
+                    binding.butClos.setText("关闭(" + millisUntilFinished / 1000 + ")");
+                }
+            }
+
+            @Override
+            public void onFinish() {
+                if (isShowing()) {
+                    dismiss();
+                }
+            }
+        };
+        countDownTimer.start();
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        if (countDownTimer != null) {
+            countDownTimer.cancel();
+            countDownTimer = null;
+        }
+    }
+}

+ 0 - 109
app/src/main/java/xn/hxp/weidith/PromptDialog.kt

@@ -1,109 +0,0 @@
-package xn.hxp.weidith
-
-import android.app.Dialog
-import android.content.Context
-import android.graphics.Color
-import android.graphics.drawable.ColorDrawable
-import android.os.Bundle
-import android.os.Handler
-import android.os.Looper
-import android.view.Gravity
-import android.view.Window
-import android.view.WindowManager
-import android.widget.Button
-import android.widget.TextView
-import xn.hxp.R
-import com.rc.httpcore.bean.UseNoBean
-
-//查询-未登录-提示
-class PromptDialog(ct: Context, private val data: UseNoBean) : Dialog(ct) {
-    private var mHandler: Handler = Handler(Looper.getMainLooper())
-
-    init {
-        requestWindowFeature(Window.FEATURE_NO_TITLE)
-        setContentView(R.layout.prompt_dialog)
-        window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
-        window?.setGravity(Gravity.CENTER)
-        window?.setLayout(
-            WindowManager.LayoutParams.MATCH_PARENT,
-            WindowManager.LayoutParams.WRAP_CONTENT
-        )
-    }
-
-
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
-        findViewById<TextView>(R.id.chemicalName).text = "${data.chemicalName}"
-        if (data.casNum != null) {
-            findViewById<TextView>(R.id.casNum).text = "CAS: ${data.casNum}"
-        } else {
-            findViewById<TextView>(R.id.casNum).text = "CAS:"
-        }
-        if (data.chemicalCategory != null) {
-            findViewById<TextView>(R.id.chemicalCategory).text = "类别: ${data.chemicalCategory}"
-        } else {
-            findViewById<TextView>(R.id.chemicalCategory).text = "类别: "
-        }
-        if (data.specUnit != null && data.packUnit != null) {
-            findViewById<TextView>(R.id.sepl).text =
-                "规格: ${data.specNum}${data.specUnit}/${data.packUnit}"
-        } else {
-            findViewById<TextView>(R.id.sepl).text =
-                "规格: ${data.specNum}${data.specUnit}/${data.packUnit}"
-        }
-
-        if (data.expireTime != null) {
-            when (data.expireStatus) {
-                1 -> {
-                    findViewById<TextView>(R.id.expireTime).text = "过期时间: ${data.expireTime}"
-                    findViewById<TextView>(R.id.expire).text = "已过期"
-                }
-                2 -> {
-                    findViewById<TextView>(R.id.expireTime).text = "过期时间: ${data.expireTime}"
-                    findViewById<TextView>(R.id.expire).text = "即将过期"
-                }
-                else -> {
-                    findViewById<TextView>(R.id.expireTime).text = "过期时间: ${data.expireTime}"
-                }
-            }
-        } else {
-            findViewById<TextView>(R.id.expireTime).text = "过期时间:"
-        }
-
-        if (data.tagCode != null) {
-            findViewById<TextView>(R.id.tagCode).text = "编码: ${data.tagCode}"
-        } else {
-            findViewById<TextView>(R.id.tagCode).text = "编码: "
-        }
-        if (data.chemicalLevelName != null) {
-            findViewById<TextView>(R.id.chemicalLevelName).text = "级别: ${data.chemicalLevelName}"
-        } else {
-            findViewById<TextView>(R.id.chemicalLevelName).text = "级别: "
-        }
-
-        if (data.surplus != null) {
-            findViewById<TextView>(R.id.surplus).text = "库存量: ${data.surplus}${data.specUnit}"
-        } else {
-            findViewById<TextView>(R.id.surplus).text = "库存量: "
-        }
-        if (data.belongName != null) {
-            findViewById<TextView>(R.id.belongName).text = "归属人: ${data.belongName}"
-        } else {
-            findViewById<TextView>(R.id.belongName).text = "归属人: "
-        }
-
-
-
-        findViewById<Button>(R.id.butClos).setOnClickListener { dismiss() }
-
-        mHandler.postDelayed({
-            dismiss()
-        }, 1000 * 15) // 15秒后关闭对话框
-
-    }
-
-    override fun onStop() {
-        super.onStop()
-        mHandler.removeCallbacksAndMessages(null)
-    }
-}

+ 3 - 3
app/src/main/java/xn/hxp/weidith/prin_label_dialog/PrintLabelDialog.java

@@ -173,15 +173,15 @@ public class PrintLabelDialog extends AppCompatDialog {
                         }
                         printBean.setPerson(TextUtils.isEmpty(name) ? "" : name);
                         // 管控非管控
-                        int chemicalLevel = hxpChemicalVo.getChemicalLevel();
-                        printBean.setLevel(1 == chemicalLevel ? "管控" : "非管控");
+//                        int chemicalLevel = hxpChemicalVo.getChemicalLevel();
+//                        printBean.setLevel(1 == chemicalLevel ? "管控" : "非管控");
                         // 化学品类型
                         CharSequence chemicalCategory = hxpChemicalVo.getChemicalCategoryName();
                         printBean.setTypes(TextUtils.isEmpty(chemicalCategory) ? "" : chemicalCategory.toString());
                         // 打印
                         if (isPrint) {
                             LogUtils.json("打印机前", labelList);
-                            PrintTool.INSTANCE.print(belongType == 2, printBean);
+                            PrintTool.INSTANCE.print(hxpChemicalVo.isGr(), belongType == 2, printBean);
                         }
                         Thread.sleep(200);
                     }

+ 16 - 0
app/src/main/res/drawable/button_custom_background.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- 按下状态:使用系统默认的波纹效果 -->
+    <item android:state_pressed="true">
+        <shape>
+            <solid android:color="?attr/colorControlHighlight" /> <!-- 引用系统主题中的波纹颜色 -->
+        </shape>
+    </item>
+    <!-- 默认状态:显示蓝色 -->
+    <item>
+        <shape>
+            <solid android:color="#0183FA" /> <!-- 自定义默认颜色 -->
+            <corners android:radius="10px" />  <!-- 可选:圆角 -->
+        </shape>
+    </item>
+</selector>

+ 15 - 0
app/src/main/res/drawable/selector_check_bt.xml

@@ -0,0 +1,15 @@
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_checked="true">
+        <shape android:shape="rectangle">
+            <solid android:color="#0183FA" />
+            <corners android:radius="10px" />
+        </shape>
+    </item>
+    <item android:state_checked="false">
+        <shape android:shape="rectangle">
+            <stroke android:width="1dp" android:color="#e0e0e0" />
+            <solid android:color="#ffffff" />
+            <corners android:radius="10px" />
+        </shape>
+    </item>
+</selector>

+ 43 - 44
app/src/main/res/layout/activity_added_chemicals.xml

@@ -2,11 +2,10 @@
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/contents"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:id="@+id/contents"
-    android:background="@mipmap/icon_add_bg"
-    tools:context=".ui.newly.AddedChemicalsActivity">
+    android:background="@mipmap/icon_add_bg">
 
     <RelativeLayout
         android:id="@+id/rel1"
@@ -188,8 +187,8 @@
             <RelativeLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:gravity="center_vertical"
                 android:layout_marginTop="20dp"
+                android:gravity="center_vertical"
                 android:paddingLeft="10dp">
 
                 <TextView
@@ -232,8 +231,8 @@
             <RelativeLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:gravity="center_vertical"
                 android:layout_marginTop="20dp"
+                android:gravity="center_vertical"
                 android:paddingLeft="10dp">
 
                 <TextView
@@ -270,15 +269,15 @@
                     android:layout_toRightOf="@id/casNum"
                     android:background="@drawable/bg_sou_suo"
                     android:text="搜索"
-                    android:textSize="12sp"
-                    android:textColor="@color/white" />
+                    android:textColor="@color/white"
+                    android:textSize="12sp" />
             </RelativeLayout>
 
             <RelativeLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:gravity="center_vertical"
                 android:layout_marginTop="20dp"
+                android:gravity="center_vertical"
                 android:paddingLeft="10dp">
 
                 <TextView
@@ -304,10 +303,10 @@
                         android:layout_marginLeft="10dp"
                         android:background="@drawable/bg_shu_ru_kuang_twoe"
                         android:gravity="center_vertical"
-                        android:singleLine="true"
                         android:hint="请选择化学品类别"
-                        android:textColor="@color/black"
                         android:paddingLeft="7.5dp"
+                        android:singleLine="true"
+                        android:textColor="@color/black"
                         android:textSize="10sp" />
 
                     <ImageView
@@ -324,8 +323,8 @@
             <RelativeLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:gravity="center_vertical"
                 android:layout_marginTop="20dp"
+                android:gravity="center_vertical"
                 android:paddingLeft="10dp">
 
                 <TextView
@@ -402,13 +401,13 @@
                     android:id="@+id/butName"
                     android:layout_width="40dp"
                     android:layout_height="25dp"
-                    android:layout_marginLeft="4dp"
                     android:layout_centerVertical="true"
+                    android:layout_marginLeft="4dp"
                     android:layout_toRightOf="@id/edName"
                     android:background="@drawable/bg_sou_suo"
                     android:text="搜索"
-                    android:textSize="12sp"
-                    android:textColor="@color/white" />
+                    android:textColor="@color/white"
+                    android:textSize="12sp" />
             </RelativeLayout>
 
             <RelativeLayout
@@ -449,8 +448,8 @@
                     android:layout_toRightOf="@id/topicName"
                     android:background="@drawable/bg_sou_suo"
                     android:text="搜索"
-                    android:textSize="12sp"
-                    android:textColor="@color/white" />
+                    android:textColor="@color/white"
+                    android:textSize="12sp" />
             </RelativeLayout>
 
 
@@ -682,8 +681,8 @@
                         android:gravity="center_vertical"
                         android:paddingLeft="11.5dp"
                         android:text="瓶"
-                        android:textSize="12sp"
-                        android:textColor="@color/white" />
+                        android:textColor="@color/white"
+                        android:textSize="12sp" />
 
                     <ImageView
                         android:layout_width="12dp"
@@ -716,13 +715,13 @@
                     android:layout_width="135dp"
                     android:layout_height="25dp"
                     android:layout_centerVertical="true"
+                    android:layout_marginLeft="10dp"
                     android:layout_toRightOf="@+id/tvNum"
                     android:background="@drawable/bg_shu_ru_kuang_twoe"
                     android:gravity="center_vertical"
+                    android:imeOptions="actionDone"
                     android:inputType="number"
-                    android:layout_marginLeft="10dp"
                     android:paddingLeft="7.5dp"
-                    android:imeOptions="actionDone"
                     android:singleLine="true"
                     android:text="1"
                     android:textColor="@color/black"
@@ -743,8 +742,8 @@
                     android:background="@drawable/bg_ji_ka_feng_twoe"
                     android:gravity="center"
                     android:text="重置"
-                    android:textSize="12sp"
-                    android:textColor="@color/black" />
+                    android:textColor="@color/black"
+                    android:textSize="12sp" />
 
                 <Button
                     android:id="@+id/butDetermine"
@@ -754,9 +753,9 @@
                     android:layout_toRightOf="@+id/butResetting"
                     android:background="@drawable/bg_quan_xin_twoe"
                     android:gravity="center"
-                    android:textSize="12sp"
                     android:text="确定"
-                    android:textColor="@color/white" />
+                    android:textColor="@color/white"
+                    android:textSize="12sp" />
             </RelativeLayout>
         </LinearLayout>
 
@@ -769,9 +768,9 @@
             android:id="@+id/relOne"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
+            android:layout_weight="0.85"
             android:paddingLeft="14.5dp"
-            android:paddingRight="13dp"
-            android:layout_weight="0.85">
+            android:paddingRight="13dp">
 
             <LinearLayout
                 android:layout_width="match_parent"
@@ -800,46 +799,46 @@
                         android:layout_height="wrap_content"
                         android:layout_weight="1"
                         android:gravity="center"
-                        android:textSize="12sp"
                         android:text="名称"
-                        android:textColor="@color/black" />
+                        android:textColor="@color/black"
+                        android:textSize="12sp" />
 
                     <TextView
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:layout_weight="1"
                         android:gravity="center"
-                        android:textSize="12sp"
                         android:text="规格"
-                        android:textColor="@color/black" />
+                        android:textColor="@color/black"
+                        android:textSize="12sp" />
 
                     <TextView
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:layout_weight="1"
                         android:gravity="center"
-                        android:textSize="12sp"
                         android:text="净含量"
-                        android:textColor="@color/black" />
+                        android:textColor="@color/black"
+                        android:textSize="12sp" />
 
                     <TextView
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:layout_weight="1"
                         android:gravity="center"
-                        android:textSize="12sp"
                         android:text="数量"
-                        android:textColor="@color/black" />
+                        android:textColor="@color/black"
+                        android:textSize="12sp" />
 
                     <TextView
                         android:id="@+id/storey"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:layout_weight="1"
-                        android:textSize="12sp"
                         android:gravity="center"
                         android:text="柜层"
-                        android:textColor="@color/black" />
+                        android:textColor="@color/black"
+                        android:textSize="12sp" />
 
                     <TextView
                         android:layout_width="30dp"
@@ -873,18 +872,18 @@
                 <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:text="请在左侧区域录入化学品信息"
-                    android:textSize="10sp"
                     android:layout_marginTop="11dp"
-                    android:textColor="@color/purple_ff999999" />
+                    android:text="请在左侧区域录入化学品信息"
+                    android:textColor="@color/purple_ff999999"
+                    android:textSize="10sp" />
 
                 <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:text="或直接扫描化学品标签"
-                    android:textSize="10sp"
                     android:layout_marginTop="6dp"
-                    android:textColor="@color/purple_ff999999" />
+                    android:text="或直接扫描化学品标签"
+                    android:textColor="@color/purple_ff999999"
+                    android:textSize="10sp" />
             </LinearLayout>
 
 
@@ -908,8 +907,8 @@
                         android:layout_centerVertical="true"
                         android:layout_marginLeft="6dp"
                         android:gravity="center_vertical"
-                        android:textSize="10sp"
-                        android:textColor="@color/black" />
+                        android:textColor="@color/black"
+                        android:textSize="10sp" />
 
                     <ImageView
                         android:id="@+id/imgPosition"

+ 453 - 0
app/src/main/res/layout/activity_already.xml

@@ -0,0 +1,453 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/main"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@mipmap/icon_add_bg"
+    tools:context=".ui.plan.already.AlreadyActivity"
+    tools:ignore="PxUsage">
+
+    <RelativeLayout
+        android:id="@+id/rel1"
+        android:layout_width="match_parent"
+        android:layout_height="45dp"
+        android:layout_marginTop="10dp">
+
+        <ImageView
+            android:id="@+id/image"
+            android:layout_width="30dp"
+            android:layout_height="30dp"
+            android:layout_centerVertical="true"
+            android:layout_marginStart="20dp" />
+
+        <TextView
+            android:id="@+id/deptName"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerVertical="true"
+            android:layout_marginStart="10dp"
+            android:layout_toEndOf="@+id/image"
+            android:text="实验室名称-房间号"
+            android:textColor="@color/white"
+            android:textSize="22sp" />
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerInParent="true"
+            android:layout_centerVertical="true"
+            android:layout_marginTop="2dp">
+
+            <TextView
+                android:id="@+id/tvTitle"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="化学品智能管理"
+                android:textColor="@color/white"
+                android:textSize="24sp"
+                android:textStyle="bold" />
+
+            <TextView
+                android:id="@+id/nowTime"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="6dp"
+                android:textColor="@color/white" />
+
+        </LinearLayout>
+
+
+        <RelativeLayout
+            android:id="@+id/loggedIn"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentEnd="true"
+            android:layout_centerVertical="true"
+            android:gravity="center_vertical"
+            android:paddingEnd="18dp">
+
+            <ImageView
+                android:id="@+id/imageName"
+                android:layout_width="30dp"
+                android:layout_height="30dp"
+                android:layout_centerVertical="true"
+                android:layout_marginEnd="6dp" />
+
+            <TextView
+                android:id="@+id/tvName"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_marginLeft="6dp"
+                android:layout_marginRight="6dp"
+                android:layout_toEndOf="@+id/imageName"
+                android:text="李XX"
+                android:textColor="@color/white" />
+
+            <ImageView
+                android:id="@+id/imgOut"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_marginLeft="6dp"
+                android:layout_marginRight="6dp"
+                android:layout_toEndOf="@+id/tvName"
+                android:background="@mipmap/cshrk_dl_tc" />
+
+            <TextView
+                android:id="@+id/tvOutLogin"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_marginEnd="10dp"
+                android:layout_toEndOf="@+id/imgOut"
+                android:text="退出"
+                android:textColor="@color/white"
+                android:textSize="16sp" />
+        </RelativeLayout>
+    </RelativeLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_below="@+id/rel1"
+        android:layout_marginLeft="31dp"
+        android:layout_marginTop="15dp"
+        android:layout_marginRight="31dp"
+        android:layout_marginBottom="69dp"
+        android:background="@drawable/bg_add_chemicals_one"
+        android:orientation="vertical">
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginHorizontal="50px"
+            android:layout_marginTop="50px">
+
+            <TextView
+                android:id="@+id/alreadyName"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:text="已申领危化品存储"
+                android:textSize="30px"
+                android:textStyle="bold" />
+
+            <RadioGroup
+                android:id="@+id/typeRG"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_marginStart="350px"
+                android:checkedButton="@id/relatedRB"
+                android:orientation="horizontal"
+                android:visibility="gone">
+
+                <RadioButton
+                    android:id="@+id/relatedRB"
+                    android:layout_width="200px"
+                    android:layout_height="30dp"
+                    android:background="@drawable/selector_check_bt"
+                    android:button="@null"
+                    android:gravity="center"
+                    android:text="与我相关"
+                    android:textColor="@drawable/selector_input_select_text_color"
+                    android:textSize="18sp" />
+
+                <RadioButton
+                    android:id="@+id/otherRB"
+                    android:layout_width="200px"
+                    android:layout_height="30dp"
+                    android:layout_marginStart="10dp"
+                    android:background="@drawable/selector_check_bt"
+                    android:button="@null"
+                    android:gravity="center"
+                    android:text="其它"
+                    android:textColor="@drawable/selector_input_select_text_color"
+                    android:textSize="18sp" />
+            </RadioGroup>
+
+            <RelativeLayout
+                android:id="@+id/belongSearchRL"
+                android:layout_width="220px"
+                android:layout_height="60px"
+                android:layout_alignParentEnd="true"
+                android:background="@drawable/shape_input_box">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentEnd="true"
+                    android:layout_centerVertical="true"
+                    android:layout_marginEnd="15px"
+                    android:rotation="90"
+                    android:text=">"
+                    android:textSize="20px" />
+
+                <TextView
+                    android:id="@+id/belongSearchTV"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_centerVertical="true"
+                    android:layout_marginStart="15px"
+                    android:text="归属人"
+                    android:textSize="20px" />
+
+            </RelativeLayout>
+
+            <RelativeLayout
+                android:id="@+id/applicantSearchRL"
+                android:layout_width="220px"
+                android:layout_height="60px"
+                android:layout_marginEnd="20px"
+                android:layout_toStartOf="@id/belongSearchRL"
+                android:background="@drawable/shape_input_box">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentEnd="true"
+                    android:layout_centerVertical="true"
+                    android:layout_marginEnd="15px"
+                    android:rotation="90"
+                    android:text=">"
+                    android:textSize="20px" />
+
+                <TextView
+                    android:id="@+id/applicantSearchTV"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_centerVertical="true"
+                    android:layout_marginStart="15px"
+                    android:text="申领人"
+                    android:textSize="20px" />
+
+            </RelativeLayout>
+
+            <RelativeLayout
+                android:id="@+id/applicantCodeSearchRL"
+                android:layout_width="220px"
+                android:layout_height="60px"
+                android:layout_marginEnd="20px"
+                android:layout_toStartOf="@id/applicantSearchRL"
+                android:background="@drawable/shape_input_box">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentEnd="true"
+                    android:layout_centerVertical="true"
+                    android:layout_marginEnd="15px"
+                    android:rotation="90"
+                    android:text=">"
+                    android:textSize="20px" />
+
+                <TextView
+                    android:id="@+id/applicantCodeSearchTV"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_centerVertical="true"
+                    android:layout_marginStart="15px"
+                    android:ellipsize="marquee"
+                    android:focusable="true"
+                    android:focusableInTouchMode="true"
+                    android:marqueeRepeatLimit="marquee_forever"
+                    android:singleLine="true"
+                    android:text="申领单号"
+                    android:textSize="20px" />
+
+            </RelativeLayout>
+
+
+        </RelativeLayout>
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="end"
+            android:layout_marginTop="10px"
+            android:layout_marginEnd="50px"
+            android:text="*该处显示已从危化品服务中心申领完成,未使用终端存入危化品柜中的危化品" />
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="80px"
+            android:layout_marginHorizontal="50px"
+            android:layout_marginTop="10px"
+            android:background="#F5F5F5">
+
+            <CheckBox
+                android:id="@+id/selectAllCB"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_marginStart="10px" />
+
+            <TextView
+                android:id="@+id/alreadyCodeTV"
+                android:layout_width="195px"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toEndOf="@id/selectAllCB"
+                android:paddingStart="15px"
+                android:text="申领单号"
+                android:textColor="#333333"
+                android:textSize="26px" />
+
+            <TextView
+                android:id="@+id/name"
+                android:layout_width="145px"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toEndOf="@id/alreadyCodeTV"
+                android:paddingStart="15px"
+                android:text="名称"
+                android:textColor="#333333"
+                android:textSize="26px" />
+
+            <TextView
+                android:id="@+id/type"
+                android:layout_width="120px"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toEndOf="@id/name"
+                android:paddingStart="15px"
+                android:text="类别"
+                android:textColor="#333333"
+                android:textSize="26px" />
+
+            <TextView
+                android:id="@+id/cas"
+                android:layout_width="120px"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toEndOf="@id/type"
+                android:paddingStart="15px"
+                android:text="CAS"
+                android:textColor="#333333"
+                android:textSize="26px" />
+
+            <TextView
+                android:id="@+id/purity"
+                android:layout_width="110px"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toEndOf="@id/cas"
+                android:paddingStart="15px"
+                android:text="纯度"
+                android:textColor="#333333"
+                android:textSize="26px" />
+
+            <TextView
+                android:id="@+id/specs"
+                android:layout_width="126px"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toEndOf="@id/purity"
+                android:paddingStart="15px"
+                android:text="规格"
+                android:textColor="#333333"
+                android:textSize="26px" />
+
+            <TextView
+                android:id="@+id/belongTV"
+                android:layout_width="126px"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toEndOf="@id/specs"
+                android:paddingStart="15px"
+                android:text="归属人"
+                android:textColor="#333333"
+                android:textSize="26px" />
+
+            <TextView
+                android:id="@+id/applicantTV"
+                android:layout_width="108px"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toEndOf="@id/belongTV"
+                android:paddingStart="15px"
+                android:text="申领人"
+                android:textColor="#333333"
+                android:textSize="26px" />
+
+            <TextView
+                android:id="@+id/code"
+                android:layout_width="218px"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toEndOf="@id/applicantTV"
+                android:paddingStart="15px"
+                android:text="编码"
+                android:textColor="#333333"
+                android:textSize="26px" />
+
+            <TextView
+                android:id="@+id/save"
+                android:layout_width="227px"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toEndOf="@id/code"
+                android:paddingStart="15px"
+                android:text="存储位置"
+                android:textColor="#333333"
+                android:textSize="26px" />
+
+            <TextView
+                android:id="@+id/operate"
+                android:layout_width="227px"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toEndOf="@id/save"
+                android:paddingStart="15px"
+                android:text="操作"
+                android:textColor="#333333"
+                android:textSize="26px" />
+
+
+        </RelativeLayout>
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginHorizontal="50px"
+            android:layout_marginBottom="20px">
+
+            <ListView
+                android:id="@+id/alreadyLV"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                tools:listitem="@layout/item_already" />
+
+        </RelativeLayout>
+
+
+    </LinearLayout>
+
+    <TextView
+        android:id="@+id/tvReturn"
+        android:layout_width="85dp"
+        android:layout_height="30dp"
+        android:layout_alignParentBottom="true"
+        android:layout_marginBottom="20dp"
+        android:background="@drawable/bg_retrun"
+        android:gravity="center"
+        android:text="返回"
+        android:textColor="@color/white"
+        android:textSize="10sp" />
+
+
+    <Button
+        android:id="@+id/subAdd"
+        android:layout_width="85dp"
+        android:layout_height="30dp"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentBottom="true"
+        android:layout_marginBottom="20dp"
+        android:background="@drawable/bg_retrun_two"
+        android:text="开门入库"
+        android:textColor="@color/white"
+        android:textSize="10sp" />
+</RelativeLayout>

+ 12 - 9
app/src/main/res/layout/activity_chemical_labeling.xml

@@ -196,8 +196,8 @@
                                 android:gravity="center"
                                 android:paddingRight="12dp"
                                 android:text="化学品柜"
-                                android:textSize="12sp"
-                                android:textColor="@color/black" />
+                                android:textColor="@color/black"
+                                android:textSize="12sp" />
 
                             <ImageView
                                 android:layout_width="wrap_content"
@@ -242,7 +242,7 @@
                             android:gravity="center"
                             android:text="重置"
                             android:textColor="@color/purple_FF666666"
-                            android:textSize="12sp"/>
+                            android:textSize="12sp" />
                     </LinearLayout>
                 </LinearLayout>
 
@@ -278,7 +278,8 @@
                         android:gravity="center"
                         android:text="RFID编号"
                         android:textColor="@color/black"
-                        android:textSize="12sp" />
+                        android:textSize="12sp"
+                        android:visibility="gone" />
 
                     <TextView
                         android:layout_width="match_parent"
@@ -395,8 +396,8 @@
                     android:id="@+id/butNext"
                     android:layout_width="65dp"
                     android:layout_height="25dp"
-                    android:layout_marginLeft="10dp"
                     android:layout_centerVertical="true"
+                    android:layout_marginLeft="10dp"
                     android:layout_toRightOf="@+id/rvPage"
                     android:background="@drawable/bg_sou_suo_page"
                     android:text="下一页"
@@ -417,7 +418,8 @@
             android:layout_height="match_parent"
             android:layout_weight="0.5"
             android:paddingLeft="15dp"
-            android:paddingRight="15dp">
+            android:paddingRight="15dp"
+            android:visibility="visible">
 
             <LinearLayout
                 android:layout_width="match_parent"
@@ -538,7 +540,8 @@
                     android:gravity="center"
                     android:text="更换RFID"
                     android:textColor="@color/purple_0072dd"
-                    android:textSize="12sp" />
+                    android:textSize="12sp"
+                    android:visibility="invisible" />
 
                 <TextView
                     android:id="@+id/reLabel"
@@ -682,9 +685,9 @@
                 android:layout_marginTop="45dp"
                 android:background="@drawable/bg_sou_suo_page"
                 android:text="打开柜门"
-                android:visibility="gone"
                 android:textColor="@color/white"
-                android:textSize="10sp" />
+                android:textSize="10sp"
+                android:visibility="gone" />
         </LinearLayout>
 
     </LinearLayout>

+ 1 - 2
app/src/main/res/layout/activity_chemicals_also.xml

@@ -420,8 +420,7 @@
             android:orientation="vertical"
             android:paddingLeft="15dp"
             android:paddingRight="15dp"
-            android:visibility="gone
-">
+            android:visibility="gone">
 
             <RelativeLayout
                 android:layout_width="match_parent"

+ 3 - 4
app/src/main/res/layout/activity_demonstrate.xml

@@ -4,8 +4,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@mipmap/icon_bgm"
-    tools:context=".ui.still.DemonstrateActivity">
+    android:background="@mipmap/icon_bgm">
 
     <RelativeLayout
         android:id="@+id/rel1"
@@ -292,8 +291,8 @@
         android:layout_alignParentBottom="true"
         android:layout_marginBottom="20dp"
         android:background="@drawable/bg_retrun"
-        android:textSize="12sp"
         android:text="返回180s"
-        android:textColor="@color/white" />
+        android:textColor="@color/white"
+        android:textSize="12sp" />
 
 </RelativeLayout>

+ 1 - 1
app/src/main/res/layout/activity_facial_login.xml

@@ -5,7 +5,7 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@mipmap/icon_bgm"
-    tools:context=".ui.login.FacialLoginActivity">
+    tools:context=".ui.login.FaceLoginActivity">
 
     <RelativeLayout
         android:id="@+id/rel1"

+ 1 - 2
app/src/main/res/layout/activity_list_returned.xml

@@ -3,7 +3,6 @@
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    tools:context=".ui.discard.ListReturnedActivity">
+    android:layout_height="match_parent">
 
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 1 - 2
app/src/main/res/layout/activity_splash.xml

@@ -4,8 +4,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@mipmap/img_hxpglpt_bg"
-    tools:context=".ui.SplashActivity">
+    android:background="@mipmap/img_hxpglpt_bg">
 
     <TextView
         android:id="@+id/versionName"

+ 4 - 5
app/src/main/res/layout/activity_warehousing.xml

@@ -4,8 +4,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@mipmap/icon_wsp"
-    tools:context=".ui.warehousing.WarehousingActivity">
+    android:background="@mipmap/icon_wsp">
 
     <RelativeLayout
         android:id="@+id/rel1"
@@ -506,10 +505,10 @@
             <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_marginTop="60dp"
                 android:layout_alignParentBottom="true"
-                android:layout_marginBottom="19dp"
-                android:layout_marginRight="10dp">
+                android:layout_marginTop="60dp"
+                android:layout_marginRight="10dp"
+                android:layout_marginBottom="19dp">
 
                 <RelativeLayout
                     android:layout_width="225dp"

+ 53 - 0
app/src/main/res/layout/dialog_plan.xml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:ignore="PxUsage">
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true"
+        android:orientation="horizontal">
+
+        <RelativeLayout
+            android:id="@+id/alreadyRL"
+            android:layout_width="360px"
+            android:layout_height="450px"
+            android:layout_marginEnd="48px"
+            android:background="@mipmap/img_bg_whpcc">
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentBottom="true"
+                android:layout_centerHorizontal="true"
+                android:layout_marginBottom="62px"
+                android:text="已申领危化品存储"
+                android:textColor="@color/white"
+                android:textSize="36px" />
+        </RelativeLayout>
+
+        <RelativeLayout
+            android:id="@+id/otherRL"
+            android:layout_width="360px"
+            android:layout_height="450px"
+            android:layout_marginStart="48px"
+            android:background="@mipmap/img_bg_qthxpcc">
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentBottom="true"
+                android:layout_centerHorizontal="true"
+                android:layout_marginBottom="62px"
+                android:text="其它化学品存储"
+                android:textColor="@color/white"
+                android:textSize="36px" />
+        </RelativeLayout>
+
+
+    </LinearLayout>
+
+</RelativeLayout>

+ 159 - 0
app/src/main/res/layout/item_already.xml

@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    tools:ignore="PxUsage">
+
+    <CheckBox
+        android:id="@+id/selectCB"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_marginStart="10px"
+        android:focusable="false"
+        android:focusableInTouchMode="false" />
+
+    <TextView
+        android:id="@+id/alreadyCodeTV"
+        android:layout_width="195px"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/selectCB"
+        android:ellipsize="middle"
+        android:maxLines="2"
+        android:paddingStart="15px"
+        android:text="申领单号"
+        android:textColor="#333333"
+        android:textSize="26px" />
+
+    <TextView
+        android:id="@+id/name"
+        android:layout_width="145px"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/alreadyCodeTV"
+        android:ellipsize="middle"
+        android:maxLines="2"
+        android:paddingStart="15px"
+        android:text="名称"
+        android:textColor="#333333"
+        android:textSize="26px" />
+
+    <TextView
+        android:id="@+id/type"
+        android:layout_width="120px"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/name"
+        android:ellipsize="middle"
+        android:maxLines="2"
+        android:paddingStart="15px"
+        android:text="类别"
+        android:textColor="#333333"
+        android:textSize="26px" />
+
+    <TextView
+        android:id="@+id/cas"
+        android:layout_width="120px"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/type"
+        android:ellipsize="middle"
+        android:maxLines="2"
+        android:paddingStart="15px"
+        android:text="CAS"
+        android:textColor="#333333"
+        android:textSize="26px" />
+
+    <TextView
+        android:id="@+id/purity"
+        android:layout_width="110px"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/cas"
+        android:ellipsize="middle"
+        android:maxLines="2"
+        android:paddingStart="15px"
+        android:text="纯度"
+        android:textColor="#333333"
+        android:textSize="26px" />
+
+    <TextView
+        android:id="@+id/specs"
+        android:layout_width="126px"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/purity"
+        android:ellipsize="middle"
+        android:maxLines="2"
+        android:paddingStart="15px"
+        android:text="规格"
+        android:textColor="#333333"
+        android:textSize="26px" />
+
+    <TextView
+        android:id="@+id/belongTV"
+        android:layout_width="126px"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/specs"
+        android:ellipsize="middle"
+        android:maxLines="2"
+        android:paddingStart="15px"
+        android:text="归属人"
+        android:textColor="#333333"
+        android:textSize="26px" />
+
+    <TextView
+        android:id="@+id/applicantTV"
+        android:layout_width="108px"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/belongTV"
+        android:ellipsize="middle"
+        android:maxLines="2"
+        android:paddingStart="15px"
+        android:text="申领人"
+        android:textColor="#333333"
+        android:textSize="26px" />
+
+    <TextView
+        android:id="@+id/code"
+        android:layout_width="218px"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/applicantTV"
+        android:ellipsize="middle"
+        android:maxLines="2"
+        android:paddingStart="15px"
+        android:text="编码"
+        android:textColor="#333333"
+        android:textSize="26px" />
+
+    <TextView
+        android:id="@+id/save"
+        android:layout_width="227px"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/code"
+        android:ellipsize="middle"
+        android:maxLines="2"
+        android:paddingStart="15px"
+        android:text="存储位置"
+        android:textColor="#0183FA"
+        android:textSize="26px" />
+
+    <TextView
+        android:id="@+id/operate"
+        android:layout_width="227px"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/save"
+        android:paddingStart="15px"
+        android:text="打印标签"
+        android:textColor="#0183FA"
+        android:textSize="26px" />
+
+
+</RelativeLayout>

+ 3 - 1
app/src/main/res/layout/item_chemical_labeling.xml

@@ -38,7 +38,8 @@
             android:layout_weight="1"
             android:gravity="center"
             android:textColor="@color/black"
-            android:textSize="10sp" />
+            android:textSize="10sp"
+            android:visibility="gone" />
 
         <TextView
             android:id="@+id/specNum"
@@ -58,6 +59,7 @@
             android:textColor="@color/black"
             android:textSize="10sp" />
     </LinearLayout>
+
     <View
         android:layout_width="match_parent"
         android:layout_height="0.5dp"

BIN
app/src/main/res/mipmap-xhdpi/img_bg_qthxpcc.png


BIN
app/src/main/res/mipmap-xhdpi/img_bg_whpcc.png