|
@@ -13,11 +13,11 @@ import androidx.activity.result.ActivityResultLauncher;
|
|
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
+import androidx.fragment.app.Fragment;
|
|
|
|
|
+import androidx.fragment.app.FragmentManager;
|
|
|
import androidx.viewpager2.widget.ViewPager2;
|
|
import androidx.viewpager2.widget.ViewPager2;
|
|
|
|
|
|
|
|
-import com.blankj.utilcode.util.GsonUtils;
|
|
|
|
|
import com.blankj.utilcode.util.LogUtils;
|
|
import com.blankj.utilcode.util.LogUtils;
|
|
|
-import com.blankj.utilcode.util.ThreadUtils;
|
|
|
|
|
import com.blankj.utilcode.util.TimeUtils;
|
|
import com.blankj.utilcode.util.TimeUtils;
|
|
|
import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.Glide;
|
|
|
import com.example.chemical.ChemicalApp;
|
|
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.add.AddActivity;
|
|
|
import com.example.chemical.ui.plan.locker.LockerAdapter;
|
|
import com.example.chemical.ui.plan.locker.LockerAdapter;
|
|
|
import com.example.chemical.ui.plan.room.RoomTool;
|
|
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.HxpCabinetDAO;
|
|
|
import com.example.chemical.ui.plan.room.dao.HxpDoorDAO;
|
|
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.ui.plan.room.dao.HxpLayerDAO;
|
|
|
import com.example.chemical.utils.UiManager;
|
|
import com.example.chemical.utils.UiManager;
|
|
|
import com.rc.httpcore.HttpConfig;
|
|
import com.rc.httpcore.HttpConfig;
|
|
|
import com.rc.httpcore.bean.ChemicalInfoBean;
|
|
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.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.HxpCabinetVo;
|
|
|
import com.example.chemical.ui.plan.room.bean.locker.CabinetLayerSelect;
|
|
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.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
-import io.reactivex.functions.Consumer;
|
|
|
|
|
import kotlin.Unit;
|
|
import kotlin.Unit;
|
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.functions.Function1;
|
|
|
-import okhttp3.Response;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 待录入页面
|
|
* 待录入页面
|
|
|
*/
|
|
*/
|
|
|
public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBinding> {
|
|
public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBinding> {
|
|
|
|
|
|
|
|
- private ActivityPlanAddBinding binding;
|
|
|
|
|
|
|
+ protected ActivityPlanAddBinding binding;
|
|
|
// 柜子fragmentAdapter
|
|
// 柜子fragmentAdapter
|
|
|
- private LockerAdapter lockerAdapter;
|
|
|
|
|
|
|
+ protected LockerAdapter lockerAdapter;
|
|
|
// 二维码/条形码扫描工具
|
|
// 二维码/条形码扫描工具
|
|
|
private ScanKeyEventHelper scanKeyEventHelper;
|
|
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
|
|
// 柜子DAO
|
|
|
- private HxpCabinetDAO hxpCabinetDAO;
|
|
|
|
|
|
|
+ protected HxpCabinetDAO hxpCabinetDAO;
|
|
|
// 柜门DAO
|
|
// 柜门DAO
|
|
|
- private HxpDoorDAO hxpDoorDAO;
|
|
|
|
|
|
|
+ protected HxpDoorDAO hxpDoorDAO;
|
|
|
// 柜层DAO
|
|
// 柜层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;
|
|
private ActivityResultLauncher<Intent> intentActivityResultLauncher;
|
|
|
|
|
|
|
@@ -91,6 +90,11 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
|
|
|
@Override
|
|
@Override
|
|
|
protected void initViews(@Nullable Bundle savedInstanceState) {
|
|
protected void initViews(@Nullable Bundle savedInstanceState) {
|
|
|
super.initViews(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() {
|
|
binding.lockerVP2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onPageSelected(int position) {
|
|
public void onPageSelected(int position) {
|
|
@@ -104,58 +108,39 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
|
|
|
scanKeyEventHelper = new ScanKeyEventHelper(new Function1<String, Unit>() {
|
|
scanKeyEventHelper = new ScanKeyEventHelper(new Function1<String, Unit>() {
|
|
|
@Override
|
|
@Override
|
|
|
public Unit invoke(String s) {
|
|
public Unit invoke(String s) {
|
|
|
|
|
+ if (binding.inputRL.getVisibility() == View.GONE) {
|
|
|
|
|
+ showToast("请先选择化学品柜层!");
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
Log.d("结果", s);
|
|
Log.d("结果", s);
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ // 待存储
|
|
|
intentActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
|
|
intentActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onActivityResult(ActivityResult result) {
|
|
public void onActivityResult(ActivityResult result) {
|
|
|
if (result.getResultCode() == RESULT_OK) {
|
|
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);
|
|
planAdapter = new PlanAdapter(this, inventoryItemBeanList);
|
|
|
binding.planLV.setAdapter(planAdapter);
|
|
binding.planLV.setAdapter(planAdapter);
|
|
|
|
|
+
|
|
|
|
|
+ LogUtils.json(hxpInventoryDAO.getAll());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void initData() {
|
|
protected void initData() {
|
|
|
super.initData();
|
|
super.initData();
|
|
|
- hxpCabinetDAO = RoomTool.getInstance().hxpCabinetDAO();
|
|
|
|
|
- hxpDoorDAO = RoomTool.getInstance().hxpDoorDAO();
|
|
|
|
|
- hxpLayerDAO = RoomTool.getInstance().hxpLayerDAO();
|
|
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
// 日期
|
|
// 日期
|
|
|
binding.nowTime.setText(TimeUtils.getNowString(new SimpleDateFormat("MM月dd日 EEEE ", Locale.getDefault())));
|
|
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() {
|
|
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
|
|
@Override
|
|
@@ -269,34 +186,11 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- FragmentCallBack fragmentCallBack = new FragmentCallBack() {
|
|
|
|
|
|
|
+ protected FragmentCallBack fragmentCallBack = new FragmentCallBack() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onSelected(CabinetLayerSelect lastSelectInfo) {
|
|
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
|
|
@Override
|