소스 검색

1.细化待存储首页逻辑和UI
2.细化手动录入逻辑和UI
3.修复选中柜层引发的同步UI的BUG

JaycePC 8 달 전
부모
커밋
b91cadf2cf
21개의 변경된 파일466개의 추가작업 그리고 375개의 파일을 삭제
  1. 3 1
      HttpCoreLibrary/src/main/java/com/rc/httpcore/bean/TopicDataBean.kt
  2. 7 0
      app/src/main/java/com/example/chemical/ChemicalApp.kt
  3. 40 146
      app/src/main/java/com/example/chemical/ui/plan/PlanAddActivity.java
  4. 23 30
      app/src/main/java/com/example/chemical/ui/plan/add/AddActivity.java
  5. 24 10
      app/src/main/java/com/example/chemical/ui/plan/add/AddActivityHelp.java
  6. 13 21
      app/src/main/java/com/example/chemical/ui/plan/locker/LockerAdapter.java
  7. 138 75
      app/src/main/java/com/example/chemical/ui/plan/locker/LockerFragment.java
  8. 33 0
      app/src/main/java/com/example/chemical/ui/plan/room/RoomConverter.java
  9. 10 1
      app/src/main/java/com/example/chemical/ui/plan/room/RoomTool.java
  10. 66 4
      app/src/main/java/com/example/chemical/ui/plan/room/bean/input_add/InventoryItemBean.java
  11. 7 27
      app/src/main/java/com/example/chemical/ui/plan/room/bean/locker/CabinetLayerSelect.java
  12. 1 1
      app/src/main/java/com/example/chemical/ui/plan/room/bean/locker/HxpCabinetDoorVo.java
  13. 0 11
      app/src/main/java/com/example/chemical/ui/plan/room/bean/locker/HxpCabinetVo.java
  14. 3 0
      app/src/main/java/com/example/chemical/ui/plan/room/dao/HxpDoorDAO.java
  15. 9 0
      app/src/main/java/com/example/chemical/ui/plan/room/dao/HxpLayerDAO.java
  16. 7 1
      app/src/main/java/com/example/chemical/weidith/prin_label_dialog/PrintLabelDialog.java
  17. 21 9
      app/src/main/res/layout/activity_add.xml
  18. 34 24
      app/src/main/res/layout/activity_plan_add.xml
  19. 2 1
      app/src/main/res/layout/dialog_bluetooth_weigh.xml
  20. 8 4
      app/src/main/res/layout/fragment_locker.xml
  21. 17 9
      app/src/main/res/layout/item_in_storage.xml

+ 3 - 1
HttpCoreLibrary/src/main/java/com/rc/httpcore/bean/TopicDataBean.kt

@@ -1,5 +1,7 @@
 package com.rc.httpcore.bean
 
+import java.io.Serializable
+
 data class TopicDataBean(
     val account: String,
     val createBy: Long,
@@ -19,4 +21,4 @@ data class TopicDataBean(
     val userId: String,
     val userName: String,
     val userPhone: String
-)
+) : Serializable

+ 7 - 0
app/src/main/java/com/example/chemical/ChemicalApp.kt

@@ -25,18 +25,25 @@ class ChemicalApp : Application() {
 
         @JvmField
         var userData: UserData? = null
+
         @JvmField
         var subjectId: String? = null   //实验室id
+
         @JvmField
         var subjectName: String? = null //实验室name
+
         @JvmField
         var confs: ConfigBean? = null   //基础信息以及 双人 认证方式
+
         @JvmField
         var labInfo: LabInfo? = null    //基础信息以及 双人 认证方式
+
         @JvmField
         var subRoom: String? = null     //房间号
+
         @JvmField
         var administrators = false      //是否是校院级管理员  管控类的仅校级管理员或院级管理员可操作  新增入库  操作管控or非管控
+
         @JvmField
         var responsibles = false        //是否是 责任人      实验室负责人或安全责任人、柜门管理员   新增入库  只能操作非管控
     }

+ 40 - 146
app/src/main/java/com/example/chemical/ui/plan/PlanAddActivity.java

@@ -13,11 +13,11 @@ import androidx.activity.result.ActivityResultLauncher;
 import androidx.activity.result.contract.ActivityResultContracts;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
 import androidx.viewpager2.widget.ViewPager2;
 
-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.bumptech.glide.Glide;
 import com.example.chemical.ChemicalApp;
@@ -28,57 +28,56 @@ import com.example.chemical.ui.common.BaseCountDownActivity;
 import com.example.chemical.ui.plan.add.AddActivity;
 import com.example.chemical.ui.plan.locker.LockerAdapter;
 import com.example.chemical.ui.plan.room.RoomTool;
-import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetDoorVo;
 import com.example.chemical.ui.plan.room.dao.HxpCabinetDAO;
 import com.example.chemical.ui.plan.room.dao.HxpDoorDAO;
+import com.example.chemical.ui.plan.room.dao.HxpInventoryDAO;
 import com.example.chemical.ui.plan.room.dao.HxpLayerDAO;
 import com.example.chemical.utils.UiManager;
 import com.rc.httpcore.HttpConfig;
 import com.rc.httpcore.bean.ChemicalInfoBean;
 import com.example.chemical.ui.plan.room.bean.input_add.InventoryItemBean;
-import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetListVo;
 import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetVo;
 import com.example.chemical.ui.plan.room.bean.locker.CabinetLayerSelect;
-import com.rc.httpcore.client.ApiRepository;
-import com.rc.httpcore.client.HttpTool;
-import com.rc.httpcore.exception.NetException;
 
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 
-import io.reactivex.functions.Consumer;
 import kotlin.Unit;
 import kotlin.jvm.functions.Function1;
-import okhttp3.Response;
 
 /**
  * 待录入页面
  */
 public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBinding> {
 
-    private ActivityPlanAddBinding binding;
+    protected ActivityPlanAddBinding binding;
     // 柜子fragmentAdapter
-    private LockerAdapter lockerAdapter;
+    protected LockerAdapter lockerAdapter;
     // 二维码/条形码扫描工具
     private ScanKeyEventHelper scanKeyEventHelper;
     // 实验室基本信息
-    private ChemicalInfoBean chemicalInfo;
+    protected ChemicalInfoBean chemicalInfo;
     // 服务端实验室所有柜子信息
-    private List<HxpCabinetVo> serverCabinetVoList;
-    // 当前选择信息
-    private CabinetLayerSelect nowSelectInfo;
+    protected List<HxpCabinetVo> cabinetVoList;
     // 当前展示的待存储列表
-    private List<InventoryItemBean> inventoryItemBeanList = new ArrayList<>();
+    protected List<InventoryItemBean> inventoryItemBeanList = new ArrayList<>();
     // 当前展示的待存储列表适配器
-    private PlanAdapter planAdapter;
+    protected PlanAdapter planAdapter;
     // 柜子DAO
-    private HxpCabinetDAO hxpCabinetDAO;
+    protected HxpCabinetDAO hxpCabinetDAO;
     // 柜门DAO
-    private HxpDoorDAO hxpDoorDAO;
+    protected HxpDoorDAO hxpDoorDAO;
     // 柜层DAO
-    private HxpLayerDAO hxpLayerDAO;
+    protected HxpLayerDAO hxpLayerDAO;
+    // 待入库清单item
+    protected HxpInventoryDAO hxpInventoryDAO;
+    // 柜子fragments
+    protected List<Fragment> cabinetFragmentList = new LinkedList<>();
+
+    private PlanAddActivityHelp planAddActivityHelp;
 
     private ActivityResultLauncher<Intent> intentActivityResultLauncher;
 
@@ -91,6 +90,11 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
     @Override
     protected void initViews(@Nullable Bundle savedInstanceState) {
         super.initViews(savedInstanceState);
+        hxpCabinetDAO = RoomTool.getInstance().hxpCabinetDAO();
+        hxpDoorDAO = RoomTool.getInstance().hxpDoorDAO();
+        hxpLayerDAO = RoomTool.getInstance().hxpLayerDAO();
+        hxpInventoryDAO = RoomTool.getInstance().hxpInventoryDAO();
+        planAddActivityHelp = new PlanAddActivityHelp(this);
         binding.lockerVP2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
             @Override
             public void onPageSelected(int position) {
@@ -104,58 +108,39 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
         scanKeyEventHelper = new ScanKeyEventHelper(new Function1<String, Unit>() {
             @Override
             public Unit invoke(String s) {
+                if (binding.inputRL.getVisibility() == View.GONE) {
+                    showToast("请先选择化学品柜层!");
+                    return null;
+                }
                 Log.d("结果", s);
                 return null;
             }
         });
 
+        // 待存储
         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) {
-                            InventoryItemBean inventoryItemBean = (InventoryItemBean) bundle.getSerializable("Inventory");
-                            LogUtils.json(inventoryItemBean);
-                            CabinetLayerSelect cabinetLayerSelect = hxpLayerDAO.getById(nowSelectInfo.getCabinetId(), nowSelectInfo.getDoorId(), nowSelectInfo.getLayer());
-                            if (cabinetLayerSelect == null) {
-                                cabinetLayerSelect = new CabinetLayerSelect(nowSelectInfo.getCabinetId(), nowSelectInfo.getDoorId(), nowSelectInfo.getLayer());
-                            }
-                            inventoryItemBeanList.add(inventoryItemBean);
-                            cabinetLayerSelect.setInventoryItemBeanList(inventoryItemBeanList);
-                            hxpLayerDAO.insert(cabinetLayerSelect);
-                            LogUtils.json(hxpLayerDAO.getAll());
-                            if (binding.scanLL.getVisibility() == View.VISIBLE) {
-                                binding.scanLL.setVisibility(View.GONE);
-                                binding.planLV.setVisibility(View.VISIBLE);
-                            }
-                            planAdapter.notifyDataSetChanged();
-                        }
-                    }
+                    planAddActivityHelp.updateInventoryUi();
                 }
             }
+
         });
-        binding.inputBT.setOnClickListener(v -> {
-            // 启动目标 Activity
-            Intent intent = new Intent(PlanAddActivity.this, AddActivity.class);
-            Bundle bundle = new Bundle();
-            bundle.putSerializable("LayerSelect", nowSelectInfo);
-            intent.putExtra("data", bundle);
-            intentActivityResultLauncher.launch(intent);
-        });
+
+        // 手动录入化学品
+        binding.inputBT.setOnClickListener(v -> intentActivityResultLauncher.launch(new Intent(PlanAddActivity.this, AddActivity.class)));
 
         planAdapter = new PlanAdapter(this, inventoryItemBeanList);
         binding.planLV.setAdapter(planAdapter);
+
+        LogUtils.json(hxpInventoryDAO.getAll());
     }
 
     @Override
     protected void initData() {
         super.initData();
-        hxpCabinetDAO = RoomTool.getInstance().hxpCabinetDAO();
-        hxpDoorDAO = RoomTool.getInstance().hxpDoorDAO();
-        hxpLayerDAO = RoomTool.getInstance().hxpLayerDAO();
+
         try {
             // 日期
             binding.nowTime.setText(TimeUtils.getNowString(new SimpleDateFormat("MM月dd日 EEEE ", Locale.getDefault())));
@@ -191,75 +176,7 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
      * 获取实验室基本信息
      */
     private void getLabInfo() {
-        showLoading("加载中...", false);
-        // 实验室基本信息
-        addDisposable(ApiRepository.INSTANCE.getRelList(ChemicalApp.subjectId).subscribe(new Consumer<ChemicalInfoBean>() {
-            @Override
-            public void accept(ChemicalInfoBean chemicalInfoBean) throws Exception {
-                chemicalInfo = chemicalInfoBean;
-                // 获取实验室柜子信息
-                ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<List<HxpCabinetVo>>() {
-                    @Override
-                    public List<HxpCabinetVo> doInBackground() throws Throwable {
-                        Response response = HttpTool.getCabinetList(chemicalInfoBean.getSubId());
-                        if (response.isSuccessful()) {
-                            String json = response.body().string();
-                            HxpCabinetListVo hxpCabinetListVo = GsonUtils.fromJson(json, HxpCabinetListVo.class);
-                            if (hxpCabinetListVo.getCode() == 200) {
-                                return hxpCabinetListVo.getData();
-                            } else {
-                                throw new NetException("" + hxpCabinetListVo.getCode(), hxpCabinetListVo.getMessage());
-                            }
-                        } else {
-                            throw new NetException("" + response.code(), response.message());
-                        }
-                    }
-
-                    @Override
-                    public void onSuccess(List<HxpCabinetVo> hxpCabinetVoList) {
-                        dismissLoading();
-                        if (null != hxpCabinetVoList && !hxpCabinetVoList.isEmpty()) {
-                            serverCabinetVoList = hxpCabinetVoList;
-                            hxpCabinetDAO.insertAll(serverCabinetVoList);
-                            for (int i = 0; i < serverCabinetVoList.size(); i++) {
-                                HxpCabinetVo hxpCabinetVo = serverCabinetVoList.get(i);
-                                List<HxpCabinetDoorVo> hxpCabinetDoorVoList = hxpCabinetVo.getCabinetDoorVoList();
-                                if (null != hxpCabinetDoorVoList && !hxpCabinetDoorVoList.isEmpty()) {
-                                    // 录入柜门
-                                    hxpDoorDAO.insertAll(hxpCabinetDoorVoList);
-                                    for (int j = 0; j < hxpCabinetDoorVoList.size(); j++) {
-                                        HxpCabinetDoorVo hxpCabinetDoorVo = hxpCabinetDoorVoList.get(j);
-                                        List<CabinetLayerSelect> cabinetLayerSelectList = hxpCabinetDoorVo.getCabinetLayerSelectList();
-                                        if (null != cabinetLayerSelectList && !cabinetLayerSelectList.isEmpty()) {
-                                            // 录入柜层
-                                            hxpLayerDAO.insertAll(cabinetLayerSelectList);
-                                        }
-
-                                    }
-                                }
-                            }
-                            lockerAdapter = new LockerAdapter(PlanAddActivity.this, serverCabinetVoList, fragmentCallBack);
-                            binding.lockerVP2.setAdapter(lockerAdapter);
-                            binding.lockerVP2.setOffscreenPageLimit(1);
-                        } else {
-                            showToast("未找到化学品柜!");
-                        }
-                    }
-
-                    @Override
-                    public void onFail(Throwable t) {
-                        super.onFail(t);
-                        showNetError(t);
-                        dismissLoading();
-                        LogUtils.d(ThreadUtils.isMainThread());
-                    }
-                });
-            }
-        }, throwable -> {
-            LogUtils.e(Log.getStackTraceString(throwable));
-            dismissLoading();
-            showNetError(throwable);
-        }));
+        planAddActivityHelp.getLabInfo();
     }
 
     @Override
@@ -269,34 +186,11 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
     }
 
 
-    FragmentCallBack fragmentCallBack = new FragmentCallBack() {
+    protected FragmentCallBack fragmentCallBack = new FragmentCallBack() {
         @Override
         public void onSelected(CabinetLayerSelect lastSelectInfo) {
-            nowSelectInfo = lastSelectInfo;
-            hxpLayerDAO.insert(lastSelectInfo);
-            // 展示选择层数的待存储列表
-            if (binding.inputRL.getVisibility() == View.GONE) {
-                binding.inputRL.setVisibility(View.VISIBLE);
-                binding.addIndexTV.setVisibility(View.GONE);
-            }
-            CabinetLayerSelect cabinetLayerSelect = hxpLayerDAO.getById(lastSelectInfo.getCabinetId(), lastSelectInfo.getDoorId(), lastSelectInfo.getLayer());
-            LogUtils.d(cabinetLayerSelect);
-            if (null == cabinetLayerSelect) {
-                inventoryItemBeanList.clear();
-                if (binding.scanLL.getVisibility() != View.VISIBLE) {
-                    binding.scanLL.setVisibility(View.VISIBLE);
-                    binding.planLV.setVisibility(View.GONE);
-                }
-            } else {
-                if (binding.scanLL.getVisibility() == View.VISIBLE) {
-                    binding.scanLL.setVisibility(View.GONE);
-                    binding.planLV.setVisibility(View.VISIBLE);
-                }
-                inventoryItemBeanList.addAll(cabinetLayerSelect.getInventoryItemBeanList());
-            }
-            planAdapter.notifyDataSetChanged();
+            planAddActivityHelp.selectCabinetLayer(lastSelectInfo);
         }
-
     };
 
     @Override

+ 23 - 30
app/src/main/java/com/example/chemical/ui/plan/add/AddActivity.java

@@ -30,6 +30,7 @@ import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetDoorVo;
 import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetVo;
 import com.example.chemical.ui.plan.room.dao.HxpCabinetDAO;
 import com.example.chemical.ui.plan.room.dao.HxpDoorDAO;
+import com.example.chemical.ui.plan.room.dao.HxpInventoryDAO;
 import com.example.chemical.ui.plan.room.dao.HxpLayerDAO;
 import com.example.chemical.utils.UiManager;
 import com.example.chemical.weidith.ChemicalTypeDialog;
@@ -38,6 +39,7 @@ import com.rc.httpcore.bean.BelongingPersonBean;
 import com.rc.httpcore.bean.ChemicalTypeBean;
 import com.rc.httpcore.bean.HxpChemicalVo;
 import com.rc.httpcore.bean.HxpControlConfig;
+import com.rc.httpcore.bean.TopicDataBean;
 import com.rc.httpcore.client.ApiRepository;
 
 import java.text.SimpleDateFormat;
@@ -50,7 +52,9 @@ public class AddActivity extends BaseCountDownActivity<ActivityAddBinding> {
     // 化学品信息
     protected HxpChemicalVo hxpChemicalVo = new HxpChemicalVo();
     // 化学品清单item
-    protected InventoryItemBean inventoryItemBean = new InventoryItemBean();
+    protected InventoryItemBean inventoryItemBean;
+    // 课题组
+    protected TopicDataBean topicDataBean;
     // 化学品类别
     protected List<ChemicalTypeBean> chemicalTypeList;
     // 归属人
@@ -65,7 +69,7 @@ public class AddActivity extends BaseCountDownActivity<ActivityAddBinding> {
     private HxpLayerDAO hxpLayerDAO;
 
     // 当前选中信息
-    protected CabinetLayerSelect sqlCabinetLayerSelect;
+    protected CabinetLayerSelect cabinetLayerSelect;
     // 当前选中的柜子
     protected HxpCabinetVo sqlHxpCabinetVo;
     // 当前选中的柜门
@@ -73,6 +77,8 @@ public class AddActivity extends BaseCountDownActivity<ActivityAddBinding> {
 
     private ActivityResultLauncher<Intent> intentActivityResultLauncher;
 
+    protected HxpInventoryDAO hxpInventoryDAO;
+
     @NonNull
     @Override
     protected ActivityAddBinding createViewBinding() {
@@ -173,12 +179,7 @@ public class AddActivity extends BaseCountDownActivity<ActivityAddBinding> {
             }
         });
         //  称重存储
-        binding.weighSaveBT.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                addActivityHelp.weighSave();
-            }
-        });
+        binding.weighSaveBT.setOnClickListener(v -> addActivityHelp.weighSave());
         // ml选择
         binding.chemicalSpecMlRB.setOnClickListener(v -> {
             String ml = binding.chemicalSpecMlRB.getText().toString();
@@ -205,7 +206,7 @@ public class AddActivity extends BaseCountDownActivity<ActivityAddBinding> {
                     if (null != resultData && resultData.hasExtra("data")) {
                         Bundle bundle = resultData.getBundleExtra("data");
                         if (null != bundle) {
-                            sqlCabinetLayerSelect = (CabinetLayerSelect) bundle.getSerializable("Change");
+                            cabinetLayerSelect = (CabinetLayerSelect) bundle.getSerializable("Change");
                         }
                     }
                 }
@@ -220,6 +221,19 @@ public class AddActivity extends BaseCountDownActivity<ActivityAddBinding> {
         hxpCabinetDAO = RoomTool.getInstance().hxpCabinetDAO();
         hxpDoorDAO = RoomTool.getInstance().hxpDoorDAO();
         hxpLayerDAO = RoomTool.getInstance().hxpLayerDAO();
+        hxpInventoryDAO = RoomTool.getInstance().hxpInventoryDAO();
+        CabinetLayerSelect cabinetLayerSelect = hxpLayerDAO.getChanged();
+        inventoryItemBean = new InventoryItemBean(cabinetLayerSelect.getCabinetId(), cabinetLayerSelect.getDoorId(), cabinetLayerSelect.getLayer());
+        this.cabinetLayerSelect = hxpLayerDAO.getById(cabinetLayerSelect.getCabinetId(), cabinetLayerSelect.getDoorId(), cabinetLayerSelect.getLayer());
+        int layer = this.cabinetLayerSelect.getLayer();
+        sqlHxpCabinetVo = hxpCabinetDAO.getById(cabinetLayerSelect.getCabinetId());
+        String cabinetName = sqlHxpCabinetVo.getCabinetName();
+        cabinetName = TextUtils.isEmpty(cabinetName) ? "" : cabinetName;
+        sqlHxpCabinetDoorVo = hxpDoorDAO.getById(cabinetLayerSelect.getDoorId());
+        String doorName = sqlHxpCabinetDoorVo.getDoorName();
+        doorName = TextUtils.isEmpty(doorName) ? "" : doorName;
+        binding.cabinetLayerSelectTV.setText(cabinetName + "-" + doorName + "-" + layer + "层");
+        binding.cabinetLayerSelectTV.setSelected(true);
         // 化学品类别列表获取
         addDisposable(ApiRepository.INSTANCE.getOptions("chemicals_category").subscribe(chemicalTypeBeans -> chemicalTypeList = chemicalTypeBeans, throwable -> {
             LogUtils.e(Log.getStackTraceString(throwable));
@@ -227,27 +241,6 @@ public class AddActivity extends BaseCountDownActivity<ActivityAddBinding> {
         }));
 
         addActivityHelp = new AddActivityHelp(AddActivity.this);
-
-        Intent getIntent = getIntent();
-        if (null != getIntent) {
-            Bundle getIntentExtras = getIntent.getBundleExtra("data");
-            if (null != getIntentExtras) {
-                CabinetLayerSelect cabinetLayerSelect = (CabinetLayerSelect) getIntentExtras.getSerializable("LayerSelect");
-                if (null != cabinetLayerSelect) {
-                    sqlCabinetLayerSelect = hxpLayerDAO.getById(cabinetLayerSelect.getCabinetId(), cabinetLayerSelect.getDoorId(), cabinetLayerSelect.getLayer());
-                    int layer = sqlCabinetLayerSelect.getLayer();
-                    sqlHxpCabinetVo = hxpCabinetDAO.getById(cabinetLayerSelect.getCabinetId());
-                    String cabinetName = sqlHxpCabinetVo.getCabinetName();
-                    cabinetName = TextUtils.isEmpty(cabinetName) ? "" : cabinetName;
-                    sqlHxpCabinetDoorVo = hxpDoorDAO.getById(cabinetLayerSelect.getDoorId());
-                    String doorName = sqlHxpCabinetDoorVo.getDoorName();
-                    doorName = TextUtils.isEmpty(doorName) ? "" : doorName;
-                    binding.cabinetLayerSelectTV.setText(cabinetName + "-" + doorName + "-" + layer + "层");
-                    binding.cabinetLayerSelectTV.setSelected(true);
-                }
-            }
-
-        }
     }
 
     @Override

+ 24 - 10
app/src/main/java/com/example/chemical/ui/plan/add/AddActivityHelp.java

@@ -1,9 +1,6 @@
 package com.example.chemical.ui.plan.add;
 
 import android.app.Activity;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.os.Bundle;
 import android.text.Editable;
 import android.text.TextUtils;
 import android.util.Log;
@@ -12,12 +9,11 @@ import com.blankj.utilcode.util.GsonUtils;
 import com.blankj.utilcode.util.LogUtils;
 import com.blankj.utilcode.util.ThreadUtils;
 import com.blankj.utilcode.util.ToastUtils;
-import com.example.chemical.ui.plan.room.bean.input_add.InventoryItemBean;
+import com.example.chemical.ui.plan.room.bean.input_add.HxpChemical;
 import com.example.chemical.weidith.BelongingPersonDialog;
 import com.example.chemical.weidith.BluetoothWeighDialog;
 import com.example.chemical.weidith.SelectChemicalDialog;
 import com.example.chemical.weidith.SelectTopicDialog;
-import com.example.chemical.ui.plan.room.bean.input_add.HxpChemical;
 import com.example.chemical.weidith.prin_label_dialog.PrintLabelDialog;
 import com.rc.httpcore.bean.HxpChemicalVo;
 import com.rc.httpcore.client.ApiRepository;
@@ -50,6 +46,7 @@ public class AddActivityHelp {
         addActivity.addDisposable(ApiRepository.INSTANCE.getTopicList(userId).subscribe(topicDataBeans -> {
             addActivity.dismissLoading();
             new SelectTopicDialog(addActivity, topicDataBeans, topicDataBean -> {
+                addActivity.topicDataBean = topicDataBean;
                 String topicName = topicDataBean.getTopicName();
                 addActivity.binding.topicET.setText(TextUtils.isEmpty(topicName) ? "" : topicName);
                 addActivity.binding.topicET.setTag(topicDataBean.getTopicId());
@@ -307,7 +304,27 @@ public class AddActivityHelp {
             return;
         }
 
+        /*-- 非必填 --*/
+        // 纯度
+        Editable purityETText = addActivity.binding.purityET.getText();
+        if (null != purityETText && !TextUtils.isEmpty(purityETText)) {
+            addActivity.hxpChemicalVo.setChemicalPurity(purityETText.toString());
+        }
+        // 厂家
+        Editable factoryETText = addActivity.binding.factoryET.getText();
+        if (null != factoryETText && !TextUtils.isEmpty(factoryETText)) {
+            addActivity.hxpChemicalVo.setFactory(factoryETText.toString());
+        }
+        // 课题组
+        Editable topicETText = addActivity.binding.topicET.getText();
+        if (null != topicETText && !TextUtils.isEmpty(topicETText)) {
+            // SQL课题组
+            addActivity.inventoryItemBean.setTopicDataBean(addActivity.topicDataBean);
+        }
+
+        // SQL化学品信息
         addActivity.inventoryItemBean.setHxpChemicalVo(addActivity.hxpChemicalVo);
+        // SQL归属人信息
         addActivity.inventoryItemBean.setBelongingPersonBean(addActivity.belongingPerson);
 
         // 化学品基础信息配置
@@ -325,11 +342,8 @@ public class AddActivityHelp {
                             public void confirm() {
                                 BluetoothWeighDialog bluetoothWeighDialog = new BluetoothWeighDialog(addActivity, addActivity.hxpChemicalVo);
                                 bluetoothWeighDialog.setOnDismissListener(dialog -> {
-                                    Intent intent = new Intent();
-                                    Bundle bundle = new Bundle();
-                                    bundle.putSerializable("Inventory", addActivity.inventoryItemBean);
-                                    intent.putExtra("data", bundle);
-                                    addActivity.setResult(Activity.RESULT_OK, intent);
+                                    addActivity.hxpInventoryDAO.insert(addActivity.inventoryItemBean);
+                                    addActivity.setResult(Activity.RESULT_OK);
                                     addActivity.finish();
                                 });
                                 bluetoothWeighDialog.show();

+ 13 - 21
app/src/main/java/com/example/chemical/ui/plan/locker/LockerAdapter.java

@@ -5,43 +5,35 @@ import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentActivity;
 import androidx.viewpager2.adapter.FragmentStateAdapter;
 
-import com.example.chemical.ui.plan.FragmentCallBack;
-import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetVo;
-
-import java.util.LinkedList;
 import java.util.List;
 
 public class LockerAdapter extends FragmentStateAdapter {
-    private List<Fragment> fragments = new LinkedList<>();
-    private List<HxpCabinetVo> hxpCabinetVoList;
+    private final List<Fragment> fragments;
 
-    public LockerAdapter(@NonNull FragmentActivity fragmentActivity, List<HxpCabinetVo> hxpCabinetVoList, FragmentCallBack fragmentCallBack) {
+    public LockerAdapter(@NonNull FragmentActivity fragmentActivity, List<Fragment> cabinetFragmentList) {
         super(fragmentActivity);
-        for (int i = 0; i < hxpCabinetVoList.size(); i++) {
-            HxpCabinetVo hxpCabinetVo = hxpCabinetVoList.get(i);
-            fragments.add(new LockerFragment(hxpCabinetVo, fragmentCallBack));
-        }
+        fragments = cabinetFragmentList;
     }
 
-    @Override
-    public long getItemId(int position) {
-        return fragments.get(position).hashCode();
-    }
+//    @Override
+//    public long getItemId(int position) {
+//        return null == fragments ? super.getItemId(position) : fragments.get(position).hashCode();
+//    }
 
-    @Override
-    public boolean containsItem(long itemId) {
-        return false;
-    }
+//    @Override
+//    public boolean containsItem(long itemId) {
+//        return false;
+//    }
 
     @NonNull
     @Override
     public Fragment createFragment(int position) {
-        return fragments.get(position);
+        return null == fragments ? null : fragments.get(position);
     }
 
     @Override
     public int getItemCount() {
-        return fragments.size();
+        return null == fragments ? 0 : fragments.size();
     }
 
 }

+ 138 - 75
app/src/main/java/com/example/chemical/ui/plan/locker/LockerFragment.java

@@ -11,11 +11,16 @@ import androidx.annotation.Nullable;
 import androidx.fragment.app.Fragment;
 
 import com.blankj.utilcode.util.LogUtils;
+import com.example.chemical.R;
 import com.example.chemical.databinding.FragmentLockerBinding;
 import com.example.chemical.ui.plan.FragmentCallBack;
+import com.example.chemical.ui.plan.room.RoomTool;
 import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetDoorVo;
 import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetVo;
 import com.example.chemical.ui.plan.room.bean.locker.CabinetLayerSelect;
+import com.example.chemical.ui.plan.room.dao.HxpCabinetDAO;
+import com.example.chemical.ui.plan.room.dao.HxpDoorDAO;
+import com.example.chemical.ui.plan.room.dao.HxpLayerDAO;
 
 import java.util.LinkedList;
 import java.util.List;
@@ -23,16 +28,23 @@ import java.util.List;
 public class LockerFragment extends Fragment {
     private FragmentLockerBinding binding;
 
-    // 柜子信息
-    private HxpCabinetVo hxpCabinetVo;
     // 上柜门柜层
     private List<DrawerUiBean> drawerUiUpList = new LinkedList<>();
     // 下柜门柜层
     private List<DrawerUiBean> drawerUiDownList = new LinkedList<>();
     private FragmentCallBack fragmentCallBack;
 
-    public LockerFragment(HxpCabinetVo hxpCabinetVo, FragmentCallBack fragmentCallBack) {
-        this.hxpCabinetVo = hxpCabinetVo;
+    private List<HxpCabinetDoorVo> doorVoList;
+
+    // 柜子
+    private long cabinetId;
+    private HxpCabinetDAO hxpCabinetDAO;
+    private HxpDoorDAO hxpDoorDAO;
+    private HxpLayerDAO hxpLayerDAO;
+    private HxpCabinetVo hxpCabinetVo;
+
+    public LockerFragment(long cabinetId, FragmentCallBack fragmentCallBack) {
+        this.cabinetId = cabinetId;
         this.fragmentCallBack = fragmentCallBack;
     }
 
@@ -44,12 +56,22 @@ public class LockerFragment extends Fragment {
     }
 
     @Override
-    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
-        super.onViewCreated(view, savedInstanceState);
-        if (savedInstanceState != null) {
-            drawerUiUpList.clear();
-            drawerUiDownList.clear();
-        }
+    public void onResume() {
+        super.onResume();
+        updateUi();
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        updateUi();
+    }
+
+    private void updateUi() {
+        drawerUiUpList.clear();
+        drawerUiDownList.clear();
+        binding.lockerUpDrawerRG.clearCheck();
+        binding.lockerDownDrawerRG.clearCheck();
         // 上柜view控制
         drawerUiUpList.add(new DrawerUiBean(binding.lockerUpDrawer1RB, binding.lockerUpDrawer1TV, false));
         drawerUiUpList.add(new DrawerUiBean(binding.lockerUpDrawer2RB, binding.lockerUpDrawer2TV, false));
@@ -66,84 +88,121 @@ public class LockerFragment extends Fragment {
         drawerUiDownList.add(new DrawerUiBean(binding.lockerDownDrawer3RB, binding.lockerDownDrawer3TV, false));
         drawerUiDownList.add(new DrawerUiBean(binding.lockerDownDrawer4RB, binding.lockerDownDrawer4TV, false));
 
+        hxpCabinetDAO = RoomTool.getInstance().hxpCabinetDAO();
+        hxpDoorDAO = RoomTool.getInstance().hxpDoorDAO();
+        hxpLayerDAO = RoomTool.getInstance().hxpLayerDAO();
+        hxpCabinetVo = hxpCabinetDAO.getById(cabinetId);
+        // 所有柜门
+        doorVoList = hxpDoorDAO.getByCabinetId(cabinetId);
         for (int i = 0; i < drawerUiUpList.size(); i++) {
             drawerUiUpList.get(i).getRadioButton().setOnClickListener(onClickDoorUpListener);
         }
         for (int i = 0; i < drawerUiDownList.size(); i++) {
             drawerUiDownList.get(i).getRadioButton().setOnClickListener(onClickDoorDownListener);
         }
-        // 所有柜门
-        List<HxpCabinetDoorVo> doorVoList = hxpCabinetVo.getCabinetDoorVoList();
-
-        // 柜子名称
-        String cabinetName = hxpCabinetVo.getCabinetName();
-        binding.lockerNameTV.setText(TextUtils.isEmpty(cabinetName) ? "" : cabinetName);
-
-        // 一个柜门
-        if (doorVoList.size() == 1) {
-            HxpCabinetDoorVo hxpCabinetDoorVo = doorVoList.get(0);
-            // 柜门名称
-            String doorName = hxpCabinetDoorVo.getDoorName();
-            binding.upDoorNameTV.setText(TextUtils.isEmpty(doorName) ? "" : doorName);
-            // 层数
-            int doorLayers = hxpCabinetDoorVo.getDoorLayers();
-            for (int i = 0; i < 8; i++) {
-                DrawerUiBean drawerUiBean = drawerUiUpList.get(i);
-                drawerUiBean.setVisible(i < doorLayers);
-            }
+        if (null != doorVoList) {
+            // 柜子名称
+            String cabinetName = hxpCabinetVo.getCabinetName();
+            binding.lockerNameTV.setText(TextUtils.isEmpty(cabinetName) ? "" : cabinetName);
+            // 选中的柜层信息
+            CabinetLayerSelect cabinetLayerSelect = hxpLayerDAO.getCabinetChanged(cabinetId);
+            // 一个柜门
+            if (doorVoList.size() == 1) {
+                HxpCabinetDoorVo hxpCabinetDoorVo = doorVoList.get(0);
+                binding.cabinetRL.setBackgroundResource(R.mipmap.locker_one);
+                // 柜门名称
+                String doorName = hxpCabinetDoorVo.getDoorName();
+                binding.upDoorNameTV.setText(TextUtils.isEmpty(doorName) ? "" : doorName);
+                // 选中的柜层
+                int layer = -1;
+                if (null != cabinetLayerSelect) {
+                    if (hxpCabinetDoorVo.getDoorId() == cabinetLayerSelect.getDoorId()) {
+                        layer = cabinetLayerSelect.getLayer();
+                    }
+                }
+                // 层数
+                int doorLayers = hxpCabinetDoorVo.getDoorLayers();
+                for (int i = 0; i < 8; i++) {
+                    DrawerUiBean drawerUiBean = drawerUiUpList.get(i);
+                    drawerUiBean.setVisible(i < doorLayers);
+                }
 
-            for (int i = 0; i < drawerUiUpList.size(); i++) {
-                DrawerUiBean drawerUiBean = drawerUiUpList.get(i);
-                if (drawerUiBean.isVisible()) {
-                    drawerUiBean.getRadioButton().setVisibility(View.VISIBLE);
-                    drawerUiBean.getTextView().setVisibility(View.VISIBLE);
+                for (int i = 0; i < drawerUiUpList.size(); i++) {
+                    DrawerUiBean drawerUiBean = drawerUiUpList.get(i);
+                    if (drawerUiBean.isVisible()) {
+                        drawerUiBean.getRadioButton().setVisibility(View.VISIBLE);
+                        drawerUiBean.getTextView().setVisibility(View.VISIBLE);
+                        if (layer > 0 && (i + 1) == layer) {
+                            drawerUiBean.getRadioButton().setChecked(true);
+                        }
+                    }
                 }
             }
-        }
-        // 两个柜门
-        else if (doorVoList.size() > 1) {
-            // 上柜门
-            HxpCabinetDoorVo hxpCabinetDoorUpVo = doorVoList.get(0);
-            String doorName = hxpCabinetDoorUpVo.getDoorName();
-            binding.upDoorNameTV.setText(TextUtils.isEmpty(doorName) ? "" : doorName);
-            // 层数
-            int doorUpLayers = hxpCabinetDoorUpVo.getDoorLayers();
-            for (int i = 0; i < 4; i++) {
-                DrawerUiBean drawerUiBean = drawerUiUpList.get(i);
-                drawerUiBean.setVisible(i < doorUpLayers);
-            }
+            // 两个柜门
+            else if (doorVoList.size() > 1) {
+                // 上柜门
+                HxpCabinetDoorVo hxpCabinetDoorUpVo = doorVoList.get(0);
+                binding.cabinetRL.setBackgroundResource(R.mipmap.locker);
+                String doorName = hxpCabinetDoorUpVo.getDoorName();
+                binding.upDoorNameTV.setText(TextUtils.isEmpty(doorName) ? "" : doorName);
+                int layerUp = -1;
+                if (null != cabinetLayerSelect) {
+                    if (hxpCabinetDoorUpVo.getDoorId() == cabinetLayerSelect.getDoorId()) {
+                        layerUp = cabinetLayerSelect.getLayer();
+                    }
+                }
+                // 层数
+                int doorUpLayers = hxpCabinetDoorUpVo.getDoorLayers();
+                for (int i = 0; i < 4; i++) {
+                    DrawerUiBean drawerUiBean = drawerUiUpList.get(i);
+                    drawerUiBean.setVisible(i < doorUpLayers);
+                }
 
-            for (int i = 0; i < drawerUiUpList.size(); i++) {
-                DrawerUiBean drawerUiBean = drawerUiUpList.get(i);
-                if (drawerUiBean.isVisible()) {
-                    drawerUiBean.getRadioButton().setVisibility(View.VISIBLE);
-                    drawerUiBean.getTextView().setVisibility(View.VISIBLE);
+                for (int i = 0; i < drawerUiUpList.size(); i++) {
+                    DrawerUiBean drawerUiBean = drawerUiUpList.get(i);
+                    if (drawerUiBean.isVisible()) {
+                        drawerUiBean.getRadioButton().setVisibility(View.VISIBLE);
+                        drawerUiBean.getTextView().setVisibility(View.VISIBLE);
+                        if (layerUp > 0 && (i + 1) == layerUp) {
+                            drawerUiBean.getRadioButton().setChecked(true);
+                        }
+                    }
                 }
-            }
 
-            binding.lockerDownDrawerLL.setVisibility(View.VISIBLE);
-            binding.lockerDownDrawerRG.setVisibility(View.VISIBLE);
-
-            // 下柜门
-            HxpCabinetDoorVo hxpCabinetDoorDownVo = doorVoList.get(1);
-            String doorDownName = hxpCabinetDoorDownVo.getDoorName();
-            binding.downDoorNameTV.setText(TextUtils.isEmpty(doorDownName) ? "" : doorDownName);
-            // 层数
-            int doorDownLayers = hxpCabinetDoorDownVo.getDoorLayers();
-            for (int i = 0; i < 4; i++) {
-                DrawerUiBean drawerUiBean = drawerUiDownList.get(i);
-                drawerUiBean.setVisible(i < doorDownLayers);
-            }
+                binding.lockerDownDrawerLL.setVisibility(View.VISIBLE);
+                binding.lockerDownDrawerRG.setVisibility(View.VISIBLE);
+
+                // 下柜门
+                HxpCabinetDoorVo hxpCabinetDoorDownVo = doorVoList.get(1);
+                String doorDownName = hxpCabinetDoorDownVo.getDoorName();
+                binding.downDoorNameTV.setText(TextUtils.isEmpty(doorDownName) ? "" : doorDownName);
+                int layerDown = -1;
+                if (null != cabinetLayerSelect) {
+                    if (hxpCabinetDoorDownVo.getDoorId() == cabinetLayerSelect.getDoorId()) {
+                        layerDown = cabinetLayerSelect.getLayer();
+                    }
+                }
+                // 层数
+                int doorDownLayers = hxpCabinetDoorDownVo.getDoorLayers();
+                for (int i = 0; i < 4; i++) {
+                    DrawerUiBean drawerUiBean = drawerUiDownList.get(i);
+                    drawerUiBean.setVisible(i < doorDownLayers);
+                }
 
-            for (int i = 0; i < drawerUiDownList.size(); i++) {
-                DrawerUiBean drawerUiBean = drawerUiDownList.get(i);
-                if (drawerUiBean.isVisible()) {
-                    drawerUiBean.getRadioButton().setVisibility(View.VISIBLE);
-                    drawerUiBean.getTextView().setVisibility(View.VISIBLE);
+                for (int i = 0; i < drawerUiDownList.size(); i++) {
+                    DrawerUiBean drawerUiBean = drawerUiDownList.get(i);
+                    if (drawerUiBean.isVisible()) {
+                        drawerUiBean.getRadioButton().setVisibility(View.VISIBLE);
+                        drawerUiBean.getTextView().setVisibility(View.VISIBLE);
+                        if (layerDown > 0 && (i + 1) == layerDown) {
+                            drawerUiBean.getRadioButton().setChecked(true);
+                        }
+                    }
                 }
-            }
 
+            }
         }
+
     }
 
     private final View.OnClickListener onClickDoorUpListener = new View.OnClickListener() {
@@ -167,8 +226,7 @@ public class LockerFragment extends Fragment {
             } else if (binding.lockerUpDrawer8RB.getId() == v.getId()) {
                 layer = 8;
             }
-            LogUtils.d("上柜", layer + "层");
-            fragmentCallBack.onSelected(new CabinetLayerSelect(hxpCabinetVo.getCabinetId(), hxpCabinetVo.getCabinetDoorVoList().get(0).getDoorId(), layer));
+            fragmentCallBack.onSelected(new CabinetLayerSelect(hxpCabinetVo.getCabinetId(), doorVoList.get(0).getDoorId(), layer));
         }
     };
     private final View.OnClickListener onClickDoorDownListener = new View.OnClickListener() {
@@ -185,8 +243,13 @@ public class LockerFragment extends Fragment {
                 layer = 4;
             }
             LogUtils.d("下柜", layer + "层");
-            fragmentCallBack.onSelected(new CabinetLayerSelect(hxpCabinetVo.getCabinetId(), hxpCabinetVo.getCabinetDoorVoList().get(1).getDoorId(), layer));
+            fragmentCallBack.onSelected(new CabinetLayerSelect(hxpCabinetVo.getCabinetId(), doorVoList.get(1).getDoorId(), layer));
         }
     };
 
+    @Override
+    public void onDestroyView() {
+        super.onDestroyView();
+        binding = null;
+    }
 }

+ 33 - 0
app/src/main/java/com/example/chemical/ui/plan/room/RoomConverter.java

@@ -9,6 +9,9 @@ import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetAdminVo;
 import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetDoorVo;
 import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetLockVo;
 import com.google.gson.reflect.TypeToken;
+import com.rc.httpcore.bean.BelongingPersonBean;
+import com.rc.httpcore.bean.HxpChemicalVo;
+import com.rc.httpcore.bean.TopicDataBean;
 
 import java.lang.reflect.Type;
 import java.util.List;
@@ -16,6 +19,36 @@ import java.util.List;
 public class RoomConverter {
 
     @TypeConverter
+    public String topicToString(TopicDataBean topicDataBean) {
+        return GsonUtils.toJson(topicDataBean);
+    }
+
+    @TypeConverter
+    public TopicDataBean stringToTopic(String json) {
+        return GsonUtils.fromJson(json, TopicDataBean.class);
+    }
+
+    @TypeConverter
+    public String hxpToString(HxpChemicalVo hxpChemicalVo) {
+        return GsonUtils.toJson(hxpChemicalVo);
+    }
+
+    @TypeConverter
+    public HxpChemicalVo stringToHxp(String json) {
+        return GsonUtils.fromJson(json, HxpChemicalVo.class);
+    }
+
+    @TypeConverter
+    public String belongToString(BelongingPersonBean belongingPersonBean) {
+        return GsonUtils.toJson(belongingPersonBean);
+    }
+
+    @TypeConverter
+    public BelongingPersonBean stringToBelong(String json) {
+        return GsonUtils.fromJson(json, BelongingPersonBean.class);
+    }
+
+    @TypeConverter
     public String doorListToString(List<HxpCabinetDoorVo> list) {
         return GsonUtils.toJson(list);
     }

+ 10 - 1
app/src/main/java/com/example/chemical/ui/plan/room/RoomTool.java

@@ -6,14 +6,20 @@ import androidx.room.RoomDatabase;
 
 import com.blankj.utilcode.util.Utils;
 import com.example.chemical.BuildConfig;
+import com.example.chemical.ui.plan.room.bean.input_add.InventoryItemBean;
 import com.example.chemical.ui.plan.room.bean.locker.CabinetLayerSelect;
 import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetDoorVo;
 import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetVo;
 import com.example.chemical.ui.plan.room.dao.HxpCabinetDAO;
 import com.example.chemical.ui.plan.room.dao.HxpDoorDAO;
+import com.example.chemical.ui.plan.room.dao.HxpInventoryDAO;
 import com.example.chemical.ui.plan.room.dao.HxpLayerDAO;
 
-@Database(entities = {HxpCabinetVo.class, HxpCabinetDoorVo.class, CabinetLayerSelect.class}, version = BuildConfig.VERSION_CODE, exportSchema = false)
+@Database(entities = {HxpCabinetVo.class,
+        HxpCabinetDoorVo.class,
+        CabinetLayerSelect.class,
+        InventoryItemBean.class},
+        version = BuildConfig.VERSION_CODE, exportSchema = false)
 public abstract class RoomTool extends RoomDatabase {
 
     private static RoomTool INSTANCE;
@@ -33,4 +39,7 @@ public abstract class RoomTool extends RoomDatabase {
 
     // 柜层
     public abstract HxpLayerDAO hxpLayerDAO();
+
+    // 待入库清单item
+    public abstract HxpInventoryDAO hxpInventoryDAO();
 }

+ 66 - 4
app/src/main/java/com/example/chemical/ui/plan/room/bean/input_add/InventoryItemBean.java

@@ -1,24 +1,70 @@
 package com.example.chemical.ui.plan.room.bean.input_add;
 
+import androidx.room.Entity;
+import androidx.room.PrimaryKey;
+import androidx.room.TypeConverters;
+
+import com.example.chemical.ui.plan.room.RoomConverter;
+import com.example.chemical.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;
 
+@Entity
+@TypeConverters(RoomConverter.class)
 public class InventoryItemBean implements Serializable {
+    @PrimaryKey(autoGenerate = true)
+    private int id;
+    private long cabinetId;
+    private long doorId;
+    private int layer;
     // 化学品信息
     private HxpChemicalVo hxpChemicalVo;
     // 归属人信息
     private BelongingPersonBean belongingPersonBean;
+    // 课题组
+    private TopicDataBean topicDataBean;
     // 化学品数量
     private int size;
 
-    public int getSize() {
-        return size;
+    public InventoryItemBean(long cabinetId, long doorId, int layer) {
+        this.cabinetId = cabinetId;
+        this.doorId = doorId;
+        this.layer = layer;
     }
 
-    public void setSize(int size) {
-        this.size = size;
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public long getCabinetId() {
+        return cabinetId;
+    }
+
+    public void setCabinetId(long cabinetId) {
+        this.cabinetId = cabinetId;
+    }
+
+    public long getDoorId() {
+        return doorId;
+    }
+
+    public void setDoorId(long doorId) {
+        this.doorId = doorId;
+    }
+
+    public int getLayer() {
+        return layer;
+    }
+
+    public void setLayer(int layer) {
+        this.layer = layer;
     }
 
     public HxpChemicalVo getHxpChemicalVo() {
@@ -36,4 +82,20 @@ public class InventoryItemBean implements Serializable {
     public void setBelongingPersonBean(BelongingPersonBean belongingPersonBean) {
         this.belongingPersonBean = belongingPersonBean;
     }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+
+    public TopicDataBean getTopicDataBean() {
+        return topicDataBean;
+    }
+
+    public void setTopicDataBean(TopicDataBean topicDataBean) {
+        this.topicDataBean = topicDataBean;
+    }
 }

+ 7 - 27
app/src/main/java/com/example/chemical/ui/plan/room/bean/locker/CabinetLayerSelect.java

@@ -1,18 +1,12 @@
 package com.example.chemical.ui.plan.room.bean.locker;
 
-import android.os.Parcel;
-import android.os.Parcelable;
-
 import androidx.room.Entity;
 import androidx.room.PrimaryKey;
 import androidx.room.TypeConverters;
 
 import com.example.chemical.ui.plan.room.RoomConverter;
-import com.example.chemical.ui.plan.room.bean.input_add.InventoryItemBean;
 
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
 
 @Entity
 @TypeConverters(RoomConverter.class)
@@ -25,18 +19,8 @@ public class CabinetLayerSelect implements Serializable {
     private long doorId;
     // 当前选择存储柜子的哪一层
     private int layer;
-
-    // 待存储的化学品列表
-    private List<InventoryItemBean> inventoryItemBeanList = new ArrayList<>();
-
-
-    public List<InventoryItemBean> getInventoryItemBeanList() {
-        return inventoryItemBeanList;
-    }
-
-    public void setInventoryItemBeanList(List<InventoryItemBean> inventoryItemBeanList) {
-        this.inventoryItemBeanList = inventoryItemBeanList;
-    }
+    // 当前是否选中
+    private boolean isChange = false;
 
     public CabinetLayerSelect(long cabinetId, long doorId, int layer) {
         this.cabinetId = cabinetId;
@@ -68,15 +52,11 @@ public class CabinetLayerSelect implements Serializable {
         this.layer = layer;
     }
 
-
-    @Override
-    public String toString() {
-        return "LastSelectInfo{" +
-                "cabinetId=" + cabinetId +
-                ", doorId=" + doorId +
-                ", layer=" + layer +
-                ", inventoryItemBeanList=" + inventoryItemBeanList +
-                '}';
+    public boolean isChange() {
+        return isChange;
     }
 
+    public void setChange(boolean change) {
+        isChange = change;
+    }
 }

+ 1 - 1
app/src/main/java/com/example/chemical/ui/plan/room/bean/locker/HxpCabinetDoorVo.java

@@ -18,6 +18,7 @@ import java.util.List;
 @TypeConverters(RoomConverter.class)
 public class HxpCabinetDoorVo {
     // ("柜门id")
+    @PrimaryKey
     private long doorId;
     // ("关键机柜id")
     private long cabinetId;
@@ -26,7 +27,6 @@ public class HxpCabinetDoorVo {
     // ("门里面的层数")
     private int doorLayers;
     // ("机柜唯一id,用于化学品入库绑定唯一编码")
-    @PrimaryKey
     private long doorUniqueId;
     // ("开始方式:1无锁,2是智能锁,3是钥匙柜")
     private int unlockingMethod;

+ 0 - 11
app/src/main/java/com/example/chemical/ui/plan/room/bean/locker/HxpCabinetVo.java

@@ -67,17 +67,6 @@ public class HxpCabinetVo {
     // ("柜门列表")
     private List<HxpCabinetDoorVo> cabinetDoorVoList = new ArrayList<>();
 
-    // 选择信息
-    private CabinetLayerSelect lastSelectInfo;
-
-    public CabinetLayerSelect getLastSelectInfo() {
-        return lastSelectInfo;
-    }
-
-    public void setLastSelectInfo(CabinetLayerSelect lastSelectInfo) {
-        this.lastSelectInfo = lastSelectInfo;
-    }
-
     public long getCabinetId() {
         return cabinetId;
     }

+ 3 - 0
app/src/main/java/com/example/chemical/ui/plan/room/dao/HxpDoorDAO.java

@@ -27,6 +27,9 @@ public interface HxpDoorDAO {
     @Query("SELECT * FROM hxpcabinetdoorvo WHERE doorId = :dooId")
     HxpCabinetDoorVo getById(long dooId);
 
+    @Query("SELECT * FROM hxpcabinetdoorvo WHERE cabinetId = :cabinetId")
+    List<HxpCabinetDoorVo> getByCabinetId(long cabinetId);
+
     @Update
     void update(HxpCabinetDoorVo hxpcabinetdoorvo);
 

+ 9 - 0
app/src/main/java/com/example/chemical/ui/plan/room/dao/HxpLayerDAO.java

@@ -26,6 +26,15 @@ public interface HxpLayerDAO {
     @Query("SELECT * FROM cabinetlayerselect WHERE layer = :layer AND cabinetId =:cabinetId AND doorId =:doorId")
     CabinetLayerSelect getById(long cabinetId, long doorId, long layer);
 
+    @Query("UPDATE cabinetlayerselect SET isChange = CASE WHEN (layer = :layer AND cabinetId =:cabinetId AND doorId =:doorId) THEN 1 ELSE 0 END")
+    void change(long cabinetId, long doorId, long layer);
+
+    @Query("SELECT * FROM cabinetlayerselect WHERE isChange = 1")
+    CabinetLayerSelect getChanged();
+
+    @Query("SELECT * FROM cabinetlayerselect WHERE isChange = 1 AND cabinetId =:cabinetId")
+    CabinetLayerSelect getCabinetChanged(long cabinetId);
+
     @Update
     void update(CabinetLayerSelect cabinetlayerselect);
 

+ 7 - 1
app/src/main/java/com/example/chemical/weidith/prin_label_dialog/PrintLabelDialog.java

@@ -86,9 +86,11 @@ public class PrintLabelDialog extends AppCompatDialog {
         // 化学品名
         String chemicalName = hxpChemicalVo.getChemicalName();
         binding.chemicalName.setText(TextUtils.isEmpty(chemicalName) ? "" : chemicalName);
+        // 总标签数
+        binding.sumTV.setText("共  " + inventoryItemBean.getSize() + "  张");
         // 净含量
         double netWt = hxpChemicalVo.getNetWt();
-        binding.netWtTV.setText("净含量:" + netWt);
+        binding.netWtTV.setText("净含量:" + netWt + hxpChemicalVo.getSpecUnit());
         // 存储位置
         binding.layerTV.setText(planPath);
         ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<Object>() {
@@ -117,11 +119,15 @@ public class PrintLabelDialog extends AppCompatDialog {
                 labelDialogAdapter.setOnItemChildClickListener((adapter, view, position) -> {
                     if (view.getId() == R.id.imgDelete) {
                         try {
+                            if (labelList.size() == 1) {
+                                throw new Exception();
+                            }
                             labelList.remove(position);
                             for (int i = 0; i < labelList.size(); i++) {
                                 labelList.get(i).setNo(++i);
                             }
                             labelDialogAdapter.setList(labelList);
+                            binding.sumTV.setText("共  " + labelList.size() + "  张");
                         } catch (Exception e) {
                             LogUtils.e(Log.getStackTraceString(e));
                             ToastUtils.showLong("删除失败!");

+ 21 - 9
app/src/main/res/layout/activity_add.xml

@@ -141,21 +141,32 @@
             android:gravity="center">
 
             <Button
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="重置" />
+                android:layout_width="150px"
+                android:layout_height="50px"
+                android:layout_marginHorizontal="15px"
+                android:background="@drawable/bg_closes"
+                android:text="重置"
+                android:textSize="24px" />
 
             <Button
                 android:id="@+id/weigh_save_BT"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="称重存储" />
+                android:layout_width="150px"
+                android:layout_height="50px"
+                android:layout_marginHorizontal="15px"
+                android:background="@drawable/selector_input_select_bt"
+                android:text="称重存储"
+                android:textColor="@color/white"
+                android:textSize="24px" />
 
             <Button
                 android:id="@+id/save_BT"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
+                android:layout_width="150px"
+                android:layout_height="50px"
+                android:layout_marginHorizontal="15px"
+                android:background="@drawable/selector_input_select_bt"
                 android:text="存储"
+                android:textColor="@color/white"
+                android:textSize="24px"
                 android:visibility="gone" />
         </LinearLayout>
 
@@ -492,7 +503,7 @@
                         android:imeOptions="actionDone"
                         android:inputType="number"
                         android:paddingHorizontal="10px"
-                        android:text="2"
+                        android:text="1"
                         android:textAppearance="@style/input_hint_text_size" />
 
                 </LinearLayout>
@@ -644,6 +655,7 @@
                         android:textColor="#333" />
 
                     <androidx.appcompat.widget.AppCompatEditText
+                        android:id="@+id/purity_ET"
                         android:layout_width="250px"
                         android:layout_height="50px"
                         android:layout_marginStart="20px"

+ 34 - 24
app/src/main/res/layout/activity_plan_add.xml

@@ -7,7 +7,8 @@
     android:layout_height="match_parent"
     android:animateLayoutChanges="true"
     android:background="@mipmap/icon_add_bg"
-    tools:context=".ui.plan.PlanAddActivity">
+    tools:context=".ui.plan.PlanAddActivity"
+    tools:ignore="PxUsage">
 
     <RelativeLayout
         android:id="@+id/rel1"
@@ -20,15 +21,15 @@
             android:layout_width="30dp"
             android:layout_height="30dp"
             android:layout_centerVertical="true"
-            android:layout_marginLeft="20dp" />
+            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_marginLeft="10dp"
-            android:layout_toRightOf="@+id/image"
+            android:layout_marginStart="10dp"
+            android:layout_toEndOf="@+id/image"
             android:text="实验室名称-房间号"
             android:textColor="@color/white"
             android:textSize="22sp" />
@@ -44,8 +45,6 @@
                 android:id="@+id/tvTitle"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_centerHorizontal="true"
-                android:layout_centerVertical="true"
                 android:text="化学品智能管理"
                 android:textColor="@color/white"
                 android:textSize="24sp"
@@ -55,8 +54,7 @@
                 android:id="@+id/nowTime"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginLeft="6dp"
-                android:layout_toRightOf="@+id/tvTitle"
+                android:layout_marginStart="6dp"
                 android:textColor="@color/white" />
 
         </LinearLayout>
@@ -66,17 +64,17 @@
             android:id="@+id/loggedIn"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_alignParentRight="true"
+            android:layout_alignParentEnd="true"
             android:layout_centerVertical="true"
             android:gravity="center_vertical"
-            android:paddingRight="18dp">
+            android:paddingEnd="18dp">
 
             <ImageView
                 android:id="@+id/imageName"
                 android:layout_width="30dp"
                 android:layout_height="30dp"
                 android:layout_centerVertical="true"
-                android:layout_marginRight="6dp" />
+                android:layout_marginEnd="6dp" />
 
             <TextView
                 android:id="@+id/tvName"
@@ -85,7 +83,7 @@
                 android:layout_centerVertical="true"
                 android:layout_marginLeft="6dp"
                 android:layout_marginRight="6dp"
-                android:layout_toRightOf="@+id/imageName"
+                android:layout_toEndOf="@+id/imageName"
                 android:text="李XX"
                 android:textColor="@color/white" />
 
@@ -96,7 +94,7 @@
                 android:layout_centerVertical="true"
                 android:layout_marginLeft="6dp"
                 android:layout_marginRight="6dp"
-                android:layout_toRightOf="@+id/tvName"
+                android:layout_toEndOf="@+id/tvName"
                 android:background="@mipmap/cshrk_dl_tc" />
 
             <TextView
@@ -104,8 +102,8 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_centerVertical="true"
-                android:layout_marginRight="10dp"
-                android:layout_toRightOf="@+id/imgOut"
+                android:layout_marginEnd="10dp"
+                android:layout_toEndOf="@+id/imgOut"
                 android:text="退出"
                 android:textColor="@color/white"
                 android:textSize="16sp" />
@@ -131,26 +129,33 @@
             <LinearLayout
                 android:id="@+id/count_LL"
                 android:layout_width="match_parent"
-                android:layout_height="wrap_content"
+                android:layout_height="100px"
                 android:layout_alignParentBottom="true"
                 android:gravity="center"
                 android:orientation="horizontal">
 
-                <Button
+                <ImageButton
                     android:id="@+id/last_BT"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:text="上一页" />
+                    android:layout_marginEnd="50px"
+                    android:background="@mipmap/icon_dcc_z" />
 
                 <TextView
                     android:id="@+id/countTV"
                     android:layout_width="wrap_content"
-                    android:layout_height="wrap_content" />
+                    android:layout_height="wrap_content"
+                    android:text="0/0"
+                    android:textColor="#333"
+                    android:textStyle="bold" />
 
-                <Button
+                <ImageButton
                     android:id="@+id/next_BT"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
+                    android:layout_marginStart="50px"
+                    android:background="@mipmap/icon_dcc_z"
+                    android:rotation="180"
                     android:text="下一页" />
             </LinearLayout>
 
@@ -181,11 +186,16 @@
 
             <Button
                 android:id="@+id/input_BT"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
+                android:layout_width="200px"
+                android:layout_height="60px"
                 android:layout_alignParentBottom="true"
                 android:layout_centerHorizontal="true"
-                android:text="手动录入化学品" />
+                android:layout_marginBottom="20px"
+                android:background="@drawable/selector_input_select_bt"
+                android:gravity="center"
+                android:text="手动录入化学品"
+                android:textColor="@color/white"
+                android:textSize="20px" />
 
             <LinearLayout
                 android:layout_width="match_parent"
@@ -275,7 +285,7 @@
                     <TextView
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
-                        android:layout_weight="1"
+                        android:layout_weight="1.1"
                         android:textSize="16sp" />
                 </LinearLayout>
 

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

@@ -145,7 +145,8 @@
                         android:gravity="center"
                         android:hint="手动输入"
                         android:inputType="numberDecimal"
-                        android:textAppearance="@style/input_hint_text_size" />
+                        android:textAppearance="@style/input_hint_text_size"
+                        android:textSize="30px" />
                 </RelativeLayout>
 
             </RelativeLayout>

+ 8 - 4
app/src/main/res/layout/fragment_locker.xml

@@ -6,11 +6,16 @@
     android:animateLayoutChanges="true"
     tools:ignore="PxUsage">
 
+    <ProgressBar
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true" />
+
     <RelativeLayout
+        android:id="@+id/cabinet_RL"
         android:layout_width="610px"
         android:layout_height="650px"
-        android:layout_centerInParent="true"
-        android:background="@mipmap/locker">
+        android:layout_centerInParent="true">
 
         <RelativeLayout
             android:layout_width="372px"
@@ -334,8 +339,7 @@
             android:layout_marginStart="33px"
             android:layout_marginTop="410px"
             android:maxLines="4"
-            android:textColor="@color/white"
-            android:visibility="gone" />
+            android:textColor="@color/white" />
 
         <TextView
             android:id="@+id/locker_name_TV"

+ 17 - 9
app/src/main/res/layout/item_in_storage.xml

@@ -19,7 +19,8 @@
         android:focusableInTouchMode="true"
         android:marqueeRepeatLimit="marquee_forever"
         android:singleLine="true"
-        android:text="化学品名称" />
+        android:text="化学品名称"
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/cas_TV"
@@ -32,7 +33,8 @@
         android:focusableInTouchMode="true"
         android:marqueeRepeatLimit="marquee_forever"
         android:singleLine="true"
-        android:text="123456789" />
+        android:text="123456789"
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/item_type_TV"
@@ -45,14 +47,16 @@
         android:focusableInTouchMode="true"
         android:marqueeRepeatLimit="marquee_forever"
         android:singleLine="true"
-        android:text="普通危化品" />
+        android:text="普通危化品"
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/item_level_TV"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_weight="1"
-        android:text="非管控" />
+        android:text="非管控"
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/item_norms_TV"
@@ -65,14 +69,16 @@
         android:focusableInTouchMode="true"
         android:marqueeRepeatLimit="marquee_forever"
         android:singleLine="true"
-        android:text="AR(分析纯)" />
+        android:text="AR(分析纯)"
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/item_net_Wt_TV"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_weight="1"
-        android:text="300ml" />
+        android:text="300ml"
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/item_num_TV"
@@ -80,13 +86,15 @@
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:gravity="center"
-        android:text="100" />
+        android:text="100"
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/item_del_TV"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_weight="1"
+        android:layout_weight="1.1"
         android:gravity="center"
-        android:text="删除" />
+        android:text="删除"
+        android:textSize="20px" />
 </LinearLayout>