Просмотр исходного кода

1.修复部分显示边界的BUG
2.修复各种小BUG

JaycePC 1 месяц назад
Родитель
Сommit
b3d82b2dc5

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

@@ -7,8 +7,11 @@ import android.widget.Toast;
 import androidx.annotation.NonNull;
 
 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.ShellUtils;
 import com.blankj.utilcode.util.ThreadUtils;
 import com.kongzue.dialogx.dialogs.WaitDialog;
 import com.rc.httpcore.HttpClient;
@@ -18,8 +21,14 @@ import com.rc.httpcore.bean.AddChemical;
 import com.rc.httpcore.bean.HxpChemicalVo;
 import com.rc.httpcore.vo.request.FaceCompare1Req;
 
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -208,4 +217,34 @@ public final class HttpTool {
         });
     }
 
+    public static Response heartbeat() throws JSONException, IOException {
+        JSONObject jsonObject = new JSONObject();
+        ShellUtils.CommandResult commandResult = ShellUtils.execCmd("dumpsys activity activities", true);
+        BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(commandResult.successMsg.getBytes())));
+        String line;
+        boolean isShow = false;
+        while ((line = reader.readLine()) != null) {
+            if (line.contains("mResumedActivity") || line.contains("mCurrentFocus")) {
+                String[] itemArray = line.split(" ", -1);
+                for (String item : itemArray) {
+                    if (item.contains("/")) {
+                        String packageName = item.substring(0, item.indexOf("/"));
+                        isShow = AppUtils.getAppPackageName().equals(packageName);
+                        break;
+                    }
+                }
+                break;
+            }
+        }
+
+        jsonObject.put("deviceNo", Tool.INSTANCE.getSerialNumber());
+        jsonObject.put("versionName", AppUtils.getAppVersionName());
+        jsonObject.put("packageName", AppUtils.getAppPackageName());
+        jsonObject.put("isShow", isShow);
+        jsonObject.put("adbEnabled", true);
+        jsonObject.put("ip", NetworkUtils.getIPAddress(true));
+        LogUtils.d("心跳", jsonObject);
+        return OkHttpUtils.postSync(Tool.INSTANCE.getBaseUrl() + "terminal/machine/upgrade/heartbeat", jsonObject.toString());
+    }
+
 }

+ 2 - 18
app/src/main/java/com/rc/httpcore/client/retrofit/ChemicalRetrofit.kt

@@ -106,6 +106,7 @@ class ChemicalRetrofit : ChemicalClient {
                 }
 
                 HttpClient.token = response.data?.token!!
+                LogUtils.json("token", response.data)
                 return@map response.data!!
             }
     }
@@ -121,23 +122,6 @@ class ChemicalRetrofit : ChemicalClient {
             }
     }
 
-//    //    override fun userValidation(cardNum: String,subId:String,doorId:String,stockId:String): Observable<String> {
-//    override fun userValidation(map: Map<String, String>): Observable<UserValidationBean> {
-//        val gson = Gson()
-//        val json = gson.toJson(map)
-//        Log.d("=====q==", json)
-//        val requestBody = RequestBody.create("application/json".toMediaTypeOrNull(), json)
-//        return apiService.userValidation(requestBody)
-//            .map { response ->
-//                if (!response.isSuccess()) {
-//                    throw NetException(response.code, response.message)
-//                }
-//
-////                HttpClient.token = response.data?.token
-//                return@map response.data!!
-//            }
-//    }
-
     override fun useCardVerify(map: Map<String, String>): Observable<UserValidationBean> {
         val gson = Gson()
         val json = gson.toJson(map)
@@ -456,7 +440,7 @@ class ChemicalRetrofit : ChemicalClient {
     }
 
     override fun backDetail(rfidCode: String, subId: String): Observable<ReturnDetailsBean> {
-        return apiService.backDetail(rfidCode,subId)
+        return apiService.backDetail(rfidCode, subId)
             .map { response ->
                 if (!response.isSuccess()) {
                     throw NetException(response.code, response.message)

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

@@ -7,11 +7,14 @@ import android.graphics.Bitmap;
 import android.graphics.Color;
 import android.graphics.drawable.GradientDrawable;
 import android.hardware.usb.UsbManager;
+import android.os.AsyncTask;
 import android.os.Bundle;
+import android.os.CountDownTimer;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
 import android.text.TextUtils;
+import android.util.Log;
 import android.view.KeyEvent;
 import android.view.View;
 import android.widget.EditText;
@@ -34,6 +37,7 @@ 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.client.HttpTool;
 import com.rc.httpcore.exception.NetException;
 
 import java.net.ConnectException;
@@ -97,6 +101,7 @@ public class MainActivity extends BaseActivity {
     private boolean isUpdating = false;
     private TimeTickReceiver timeTickReceiver = new TimeTickReceiver();
     private PlanDialog planDialog;
+    private CountDownTimer heartbeatCdTimer;
 
     @Override
     protected void onResume() {
@@ -128,6 +133,7 @@ public class MainActivity extends BaseActivity {
 
         timeUpdater.startUpdating();
         getCabinetIn();
+        basicConf();
     }
 
     @Override
@@ -184,6 +190,27 @@ public class MainActivity extends BaseActivity {
             viewBinding.inc.bleIV.setBackgroundResource(R.drawable.ic_ble_unconnected);
             PopTip.show("未配置蓝牙称设备!").showLong();
         }
+
+        // 心跳上报
+        heartbeatCdTimer = new CountDownTimer(20000, 1000) {
+            @Override
+            public void onTick(long millisUntilFinished) {
+
+            }
+
+            @Override
+            public void onFinish() {
+                AsyncTask.execute(() -> {
+                    try {
+                        HttpTool.heartbeat();
+                    } catch (Exception e) {
+                        LogUtils.e(Log.getStackTraceString(e));
+                    }
+                });
+                heartbeatCdTimer.start();
+            }
+        };
+        heartbeatCdTimer.start();
     }
 
     @Override

+ 2 - 0
app/src/main/java/xn/hxp/ui/adapter/InquiryItemAdapter.kt

@@ -1,5 +1,6 @@
 package xn.hxp.ui.adapter
 
+import android.widget.TextView
 import com.chad.library.adapter.base.BaseQuickAdapter
 import com.chad.library.adapter.base.viewholder.BaseViewHolder
 import xn.hxp.R
@@ -13,6 +14,7 @@ class InquiryItemAdapter :
 
     override fun convert(holder: BaseViewHolder, item: HxpStockWaitListBean) {
         holder.setText(R.id.chemicalName, "${item.chemicalName}")
+        holder.getView<TextView>(R.id.chemicalName).isSelected = true
         LogUtils.i("===${holder.adapterPosition}====${item.casNum}")
         if (item.casNum != null) {
             holder.setText(R.id.casNum, "${item.casNum}")

+ 9 - 1
app/src/main/java/xn/hxp/ui/adapter/UsageLabelDialogAdapter.kt

@@ -4,6 +4,7 @@ import android.content.Context
 import android.view.View
 import android.widget.AdapterView
 import android.widget.Spinner
+import android.widget.TextView
 import com.chad.library.adapter.base.BaseQuickAdapter
 import com.chad.library.adapter.base.viewholder.BaseViewHolder
 import xn.hxp.R
@@ -17,10 +18,15 @@ class UsageLabelDialogAdapter(private val ct: Context) :
     init {
         addChildClickViewIds(R.id.imgDelete)
     }
+
     private val spinnerArray = listOf("否", "是")
     override fun convert(holder: BaseViewHolder, item: ChemistryBean) {
         holder.setText(R.id.chemicalName, "${item.chemicalName}")
+        val chemicalName = holder.getView<TextView>(R.id.chemicalName)
+        chemicalName.isSelected = true
         holder.setText(R.id.code, "${item.code}")
+        val code = holder.getView<TextView>(R.id.code)
+        code.isSelected = true
         if (item.weigh != null) {
             when {
                 item.specUnit.equals("g") -> {
@@ -29,12 +35,14 @@ class UsageLabelDialogAdapter(private val ct: Context) :
                         "${item.weigh!!.subtract(item.packNum)}${item.specUnit}"
                     )
                 }
+
                 item.specUnit.equals("ml") -> {
                     val subtract = item.weigh!!.subtract(item.packNum)
                     val gramsToMilliliters =
                         ConversionUtils.gramsToMilliliters(subtract, item.chemicalDensity)
                     holder.setText(R.id.surplus, "$gramsToMilliliters${item.specUnit}")
                 }
+
                 else -> {
                     holder.setText(R.id.surplus, "${item.surplus}${item.specUnit}")
                 }
@@ -47,7 +55,7 @@ class UsageLabelDialogAdapter(private val ct: Context) :
 //        holder.setText(R.id.surplus, "${item.weigh}${item.specUnit}")
         holder.setText(R.id.duration, "${item.duration}")
         val sPinner = holder.getView<Spinner>(R.id.sPinner)
-        val adapter = CustomSpinnerFoutAdapter(ct,spinnerArray)
+        val adapter = CustomSpinnerFoutAdapter(ct, spinnerArray)
         sPinner.adapter = adapter
         sPinner.setSelection(0)
         sPinner.onItemSelectedListener =

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

@@ -167,7 +167,7 @@ class SwipeActivity : BaseActivity() {
             .subscribe({ data ->
                 ChemicalApp.userData!!.userValidationBean = data
                 dismissLoading()
-                LogUtils.json(data)
+                LogUtils.json("登录人", data)
                 val allFalse =
                     java.lang.Boolean.TRUE == data.cabinetAdmin || java.lang.Boolean.TRUE == data.belongUser || java.lang.Boolean.TRUE == data.toipcUser || java.lang.Boolean.TRUE == data.safeUser || java.lang.Boolean.TRUE == data.collegeAdmin || java.lang.Boolean.TRUE == data.schoolLevelAdmin || java.lang.Boolean.TRUE == data.adminUser || java.lang.Boolean.TRUE == data.apply || java.lang.Boolean.TRUE == data.white
                 if (!allFalse) {

+ 151 - 31
app/src/main/java/xn/hxp/ui/plan/already/AlreadyActivity.java

@@ -18,6 +18,7 @@ import androidx.activity.result.contract.ActivityResultContracts;
 import androidx.appcompat.app.AlertDialog;
 import androidx.viewbinding.ViewBinding;
 
+import com.blankj.utilcode.util.ClickUtils;
 import com.blankj.utilcode.util.GsonUtils;
 import com.blankj.utilcode.util.LogUtils;
 import com.blankj.utilcode.util.ThreadUtils;
@@ -38,9 +39,11 @@ import org.json.JSONObject;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
+import java.util.Set;
 
 import okhttp3.Response;
 import xn.hxp.app.ChemicalApp;
@@ -57,15 +60,18 @@ 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.save_list.SaveListActivity;
 import xn.hxp.ui.plan.unlock.UnlockActivity;
 
 public class AlreadyActivity extends BaseActivity {
     private ActivityAlreadyBinding binding;
     private List<HxpChemicalVo> hxpChemicalVoList = new ArrayList<>();
+    private Set<String> checkWaitIdSet = new HashSet<>();
     private AlreadyAdapter alreadyAdapter;
 
     private int page = 1; // 页数
-    private int type; // 0:与自己相关 1:其它
+    private int pages = Integer.MAX_VALUE;
+    private int type = 0; // 0:与自己相关 1:其它
     private String applyOrder; // 申领单号
     private String applyUserName;// 申领人
     private String topicUserName;// 归属人
@@ -74,6 +80,7 @@ public class AlreadyActivity extends BaseActivity {
 
     private ActivityResultLauncher<Intent> intentActivityResultLauncher;
 
+
     @Override
     protected ViewBinding setViewBinding() {
         return binding = ActivityAlreadyBinding.inflate(getLayoutInflater());
@@ -92,6 +99,7 @@ public class AlreadyActivity extends BaseActivity {
             @Override
             public void onActivityResult(ActivityResult result) {
                 if (result.getResultCode() == RESULT_OK) {
+                    showLoading("正在修改存储位置...");
                     Intent resultData = result.getData();
                     if (null != resultData && resultData.hasExtra("data")) {
                         Bundle bundle = resultData.getBundleExtra("data");
@@ -114,21 +122,19 @@ public class AlreadyActivity extends BaseActivity {
                                     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);
+                                        LogUtils.d("柜层", json);
                                         return null;
                                     }
 
                                     @Override
                                     public void onSuccess(Object result) {
                                         dismissLoading();
-                                        alreadyAdapter.notifyDataSetChanged();
+                                        getHxpStockWait();
                                     }
                                 });
                             }
@@ -142,36 +148,37 @@ public class AlreadyActivity extends BaseActivity {
         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 (null != hxpChemicalVoList && !hxpChemicalVoList.isEmpty()) {
+                    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());
+                    alreadyAdapter.update(type);
+                    LogUtils.json(waitArray);
                 } else {
-                    PopTip.show("全反选" + waitArray.size());
+                    showLoading("未有可操作的数据!");
+                    binding.selectAllCB.setChecked(false);
                 }
-                alreadyAdapter.notifyDataSetChanged();
-                LogUtils.json(waitArray);
             }
         });
         // 已申领类型选择
         binding.typeRG.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
             @Override
             public void onCheckedChanged(RadioGroup group, int checkedId) {
+                page = 1;
                 // 与我相关
                 if (checkedId == binding.relatedRB.getId()) {
                     binding.otherRB.setText("其它");
-                    type = 1;
+                    type = 0;
                 }
                 // 其它
                 else if (checkedId == binding.otherRB.getId()) {
                     binding.relatedRB.setText("与我相关");
-                    type = 0;
+                    type = 1;
                 }
                 getHxpStockWait();
             }
@@ -219,9 +226,7 @@ public class AlreadyActivity extends BaseActivity {
                     public void onClick(DialogInterface dialog, int which) {
                         applyUserName = "";
                         binding.applicantSearchTV.setText("申领人");
-                        if (!TextUtils.isEmpty(editText.getText())) {
-                            getHxpStockWait();
-                        }
+                        getHxpStockWait();
                     }
                 });
                 builder.setPositiveButton("确定", null);
@@ -272,9 +277,7 @@ public class AlreadyActivity extends BaseActivity {
                     public void onClick(DialogInterface dialog, int which) {
                         topicUserName = "";
                         binding.belongSearchTV.setText("归属人");
-                        if (!TextUtils.isEmpty(editText.getText())) {
-                            getHxpStockWait();
-                        }
+                        getHxpStockWait();
                     }
                 });
                 AlertDialog dialog = builder.create();
@@ -298,9 +301,10 @@ public class AlreadyActivity extends BaseActivity {
             }
         });
         // 一键入库
-        binding.subAdd.setOnClickListener(new View.OnClickListener() {
+        ClickUtils.applySingleDebouncing(binding.subAdd, new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+
                 showLoading("处理中...");
                 ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<PlanAddData>() {
                     @Override
@@ -314,7 +318,6 @@ public class AlreadyActivity extends BaseActivity {
                                 autoChemicalList.add(recordsBean);
                             }
                         }
-
                         // 为需要自动入库的化学品创建清单
                         AlreadyTool.INSTANCE.updateHxpInventoryList(autoChemicalList);
                         HxpDoorDAO hxpDoorDAO = RoomTool.getInstance().hxpDoorDAO();
@@ -386,7 +389,7 @@ public class AlreadyActivity extends BaseActivity {
                         LogUtils.d("需要开锁", cabinetList.size(), doorList.size());
                         // 不需要开门
                         if (cabinetList.isEmpty() || doorList.isEmpty()) {
-                            showToast("不需要开门");
+                            autoSave(planAddData);
                             return;
                         }
                         String json = GsonUtils.toJson(planAddData);
@@ -400,6 +403,33 @@ public class AlreadyActivity extends BaseActivity {
             }
         });
 
+        // 上一页
+        binding.lastPage.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                int last = page - 1;
+                if (last < 1) {
+                    showToast("没有更多数据!");
+                    return;
+                }
+                page = last;
+                getHxpStockWait();
+            }
+        });
+        // 下一页
+        binding.nextPage.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                int next = page + 1;
+                if (next > pages) {
+                    showToast("没有更多数据!");
+                    return;
+                }
+                page = next;
+                getHxpStockWait();
+            }
+        });
+
         try {
             // 日期
             binding.nowTime.setText(TimeUtils.getNowString(new SimpleDateFormat("MM月dd日 EEEE ", Locale.getDefault())));
@@ -436,6 +466,49 @@ public class AlreadyActivity extends BaseActivity {
         binding.tvReturn.setOnClickListener(v -> finish());
     }
 
+    private void autoSave(PlanAddData planAddData) {
+        ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<String>() {
+            @Override
+            public String doInBackground() throws Throwable {
+
+                List<String> autoChemicalList = 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);
+                    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 {
+                    return response.message();
+                }
+            }
+
+            @Override
+            public void onSuccess(String result) {
+                dismissLoading();
+                if (!TextUtils.isEmpty(result)) {
+                    binding.subAdd.setEnabled(true);
+                    PopTip.show(result);
+                } else {
+                    finish();
+                    startActivity(new Intent(AlreadyActivity.this, SaveListActivity.class));
+                }
+            }
+        });
+    }
+
     /**
      * 获取单号检索列表
      */
@@ -526,6 +599,15 @@ public class AlreadyActivity extends BaseActivity {
      */
     private void getHxpStockWait() {
         showLoading("加载中...");
+        for (int i = 0; i < hxpChemicalVoList.size(); i++) {
+            HxpChemicalVo hxpChemicalVo = hxpChemicalVoList.get(i);
+            if (hxpChemicalVo.isSelect()) {
+                checkWaitIdSet.add(hxpChemicalVo.getWaitId());
+            } else {
+                checkWaitIdSet.remove(hxpChemicalVo.getWaitId());
+            }
+        }
+
         ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<AlreadyBean>() {
             @Override
             public AlreadyBean doInBackground() throws Throwable {
@@ -543,15 +625,28 @@ public class AlreadyActivity extends BaseActivity {
 
             @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);
+
+                    for (String checkWaitId : checkWaitIdSet) {
+                        for (int i = 0; i < hxpChemicalVoList.size(); i++) {
+                            HxpChemicalVo hxpChemicalVo = hxpChemicalVoList.get(i);
+                            if (hxpChemicalVo.getWaitId().equals(checkWaitId)) {
+                                hxpChemicalVo.setSelect(true);
+                                break;
+                            }
+                        }
+                    }
+                    if (null == alreadyAdapter) {
+                        alreadyAdapter = new AlreadyAdapter(AlreadyActivity.this, hxpChemicalVoList, intentActivityResultLauncher);
+                        binding.alreadyLV.setAdapter(alreadyAdapter);
+                    } else {
+                        alreadyAdapter.update(type);
+                    }
                     int total = result.getPageData().getTotal();
                     if (result.isAdmin()) {
                         binding.typeRG.setVisibility(View.VISIBLE);
@@ -567,7 +662,32 @@ public class AlreadyActivity extends BaseActivity {
                             showToast("暂无您可处理的危化品!");
                         }
                     }
+                    // 最大页数
+                    pages = result.getPageData().getPages();
+
+                    binding.pageItem.setText(page + "/" + pages);
+
+                    // 是否全选
+                    boolean isAllCheck = true;
+                    for (int i = 0; i < hxpChemicalVoList.size(); i++) {
+                        HxpChemicalVo hxpChemicalVo = hxpChemicalVoList.get(i);
+                        if (!hxpChemicalVo.isSelect()) {
+                            isAllCheck = false;
+                            break;
+                        }
+                    }
+                    if (hxpChemicalVoList.isEmpty()) {
+                        binding.pageControl.setVisibility(View.INVISIBLE);
+                        binding.selectAllCB.setChecked(false);
+                    } else {
+                        binding.pageControl.setVisibility(View.VISIBLE);
+                        binding.selectAllCB.setChecked(isAllCheck);
+                    }
+
+                    binding.selectAllCB.setEnabled(type == 0);
+
                 }
+                dismissLoading();
             }
         });
     }

+ 93 - 82
app/src/main/java/xn/hxp/ui/plan/already/AlreadyAdapter.java

@@ -1,7 +1,8 @@
 package xn.hxp.ui.plan.already;
 
-import android.content.Context;
 import android.content.Intent;
+import android.graphics.Color;
+import android.os.AsyncTask;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -11,7 +12,9 @@ import android.widget.BaseAdapter;
 
 import androidx.activity.result.ActivityResultLauncher;
 
+import com.blankj.utilcode.util.ClickUtils;
 import com.blankj.utilcode.util.LogUtils;
+import com.blankj.utilcode.util.StringUtils;
 import com.kongzue.dialogx.dialogs.PopTip;
 import com.rc.httpcore.bean.HxpChemicalVo;
 
@@ -24,13 +27,14 @@ import xn.hxp.ui.plan.change.ChangeCabinetActivity;
 import xn.hxp.utils.PrintTool;
 
 public class AlreadyAdapter extends BaseAdapter {
-    private Context context;
+    private AlreadyActivity context;
     private List<HxpChemicalVo> recordsBeanList;
+    private int type = 0; // 0:与自己相关 1:其它
 
     // 存储位置替换的回调
     private ActivityResultLauncher<Intent> intentActivityResultLauncher;
 
-    public AlreadyAdapter(Context context, List<HxpChemicalVo> recordsBeanList, ActivityResultLauncher<Intent> intentActivityResultLauncher) {
+    public AlreadyAdapter(AlreadyActivity context, List<HxpChemicalVo> recordsBeanList, ActivityResultLauncher<Intent> intentActivityResultLauncher) {
         this.context = context;
         this.recordsBeanList = recordsBeanList;
         this.intentActivityResultLauncher = intentActivityResultLauncher;
@@ -105,90 +109,92 @@ public class AlreadyAdapter extends BaseAdapter {
             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);
+            if (0 == type) {
+                binding.save.setTextColor(Color.parseColor("#ff0183FA"));
+                binding.operate.setTextColor(Color.parseColor("#ff0183FA"));
+                binding.selectCB.setEnabled(true);
+                binding.selectCB.setOnCheckedChangeListener(null);
+                binding.selectCB.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        HxpChemicalVo recordsBean = getItem(position);
+                        recordsBean.setSelect(binding.selectCB.isChecked());
                     }
-                    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);
+                });
+                ClickUtils.applySingleDebouncing(binding.save, new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        context.showLoading("");
+                        recordsBeanList.get(position).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();
+                        intentActivityResultLauncher.launch(new Intent(context, ChangeCabinetActivity.class));
+                        context.dismissLoading();
+                    }
+                });
+
+                binding.operate.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        context.showLoading("打印中...");
+                        AsyncTask.execute(() -> {
+                            try {
+                                HxpChemicalVo printAlreadyBean = recordsBeanList.get(position);
+                                printAlreadyBean.setSelect(true);
+                                notifyDataSetChanged();
+                                List<HxpChemicalVo> printBeanList = new ArrayList<>();
+                                for (int i = 0; i < recordsBeanList.size(); i++) {
+                                    HxpChemicalVo recordsBean1 = recordsBeanList.get(i);
+                                    if (recordsBean1.isSelect()) {
+                                        printBeanList.add(recordsBean1);
+                                    }
+                                }
+                                for (int i = 0; i < printBeanList.size(); i++) {
+                                    PrintBean printBean = new PrintBean();
+                                    // 化学品编码
+                                    HxpChemicalVo itemBean = printBeanList.get(i);
+                                    String tagCode = itemBean.getLabels();
+                                    printBean.setTag(TextUtils.isEmpty(tagCode) ? "" : tagCode);
+                                    // 二维码
+                                    printBean.setWxCode(TextUtils.isEmpty(tagCode) ? "" : tagCode);
+                                    // 化学品名
+                                    printBean.setName(TextUtils.isEmpty(itemBean.getChemicalName()) ? "" : itemBean.getChemicalName());
+                                    // CAS
+                                    String casNum1 = itemBean.getCasNum();
+                                    printBean.setCasNo(TextUtils.isEmpty(casNum1) ? "" : casNum1);
+                                    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());
+                                    if (StringUtils.isEmpty(tagCode)) {
+                                        PopTip.show("打印参数异常!");
+                                    } else {
+                                        PrintTool.INSTANCE.print(true, !itemBean.isTopicGroup(), printBean);
+                                    }
+                                }
+
+                            } catch (Exception e) {
+                                LogUtils.e(Log.getStackTraceString(e));
                             }
-                            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));
+                            context.dismissLoading();
+                        });
                     }
-                }
-            });
+                });
+            } else {
+                binding.save.setTextColor(Color.parseColor("#ff333333"));
+                binding.operate.setTextColor(Color.parseColor("#ff333333"));
+                binding.selectCB.setEnabled(false);
+                binding.save.setOnClickListener(null);
+                binding.operate.setOnClickListener(null);
+            }
         } catch (Exception e) {
             LogUtils.e(Log.getStackTraceString(e));
         }
@@ -196,6 +202,11 @@ public class AlreadyAdapter extends BaseAdapter {
         return convertView;
     }
 
+    public void update(int type) {
+        this.type = type;
+        notifyDataSetChanged();
+    }
+
     static class ViewHolder {
         ItemAlreadyBinding binding;
 

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

@@ -14,10 +14,19 @@ public class AlreadyBean {
     public class PageData {
         private int total;// 总数
         private int size;// 分页条数
+        private int pages;
         private int current;// 页码
         private List<HxpChemicalVo> records;
 
 
+        public int getPages() {
+            return pages;
+        }
+
+        public void setPages(int pages) {
+            this.pages = pages;
+        }
+
         public int getTotal() {
             return total;
         }

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

@@ -101,6 +101,7 @@ public class SaveListActivity extends BaseActivity {
         cabinetDAO = RoomTool.getInstance().hxpCabinetDAO();
         doorDAO = RoomTool.getInstance().hxpDoorDAO();
         List<InventoryItemBean> inventoryItemBeanList = inventoryDAO.getAll();
+        LogUtils.json("清单", inventoryItemBeanList);
         for (int i = 0; i < inventoryItemBeanList.size(); i++) {
             InventoryItemBean inventoryItemBean = inventoryItemBeanList.get(i);
             SaveListBean saveListBean = new SaveListBean();

+ 1 - 0
app/src/main/java/xn/hxp/ui/warehousing/ChemicalLabelingActivity.kt

@@ -870,6 +870,7 @@ class ChemicalLabelingActivity : BaseActivity() {
         viewBinding.relOne.visibility = View.GONE
         viewBinding.linTow.visibility = View.VISIBLE
         viewBinding.chemicalName.text = "${data.chemicalName}"
+        viewBinding.chemicalName.isSelected = true
         viewBinding.tagCode.text = "编码${data.tagCode}"
         viewBinding.chemicalLevelName.text = "${data.chemicalLevelName}"
         viewBinding.chemicalCategoryName.text = "${data.chemicalCategoryName}"

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

@@ -71,9 +71,9 @@ public final class BitmapUtils {
     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);
+//            Map<EncodeHintType, Object> hints = new HashMap<>();
+//            hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
+            BitMatrix bitMatrix = new MultiFormatWriter().encode(number, BarcodeFormat.CODE_128, barW, barH);
             int[] pixels = new int[barW * barH];
             for (int y = 0; y < barH; y++) {
                 for (int x = 0; x < barW; x++) {

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

@@ -97,7 +97,7 @@ public enum PrintTool {
     }
 
     private void startPrintGR(boolean isBelong, PrintBean printBean) {
-
+        LogUtils.json("打印", printBean);
         Bitmap bitmap = BitmapUtils.generateBarBitmap(isBelong, printBean);
 
         if (AutoReplyPrint.INSTANCE.CP_Label_BackPaperToPrintPosition(pointer)) {

+ 5 - 0
app/src/main/res/drawable/cb.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@mipmap/selected_cb" android:state_checked="true" />
+    <item android:drawable="@mipmap/unselected_cb" android:state_checked="false" />
+</selector>

+ 49 - 5
app/src/main/res/layout/activity_already.xml

@@ -283,11 +283,13 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_centerVertical="true"
-                android:layout_marginStart="10px" />
+                android:layout_marginHorizontal="10px"
+                android:background="@drawable/cb"
+                android:button="@null" />
 
             <TextView
                 android:id="@+id/alreadyCodeTV"
-                android:layout_width="195px"
+                android:layout_width="175px"
                 android:layout_height="wrap_content"
                 android:layout_centerVertical="true"
                 android:layout_toEndOf="@id/selectAllCB"
@@ -298,7 +300,7 @@
 
             <TextView
                 android:id="@+id/name"
-                android:layout_width="145px"
+                android:layout_width="200px"
                 android:layout_height="wrap_content"
                 android:layout_centerVertical="true"
                 android:layout_toEndOf="@id/alreadyCodeTV"
@@ -397,11 +399,11 @@
 
             <TextView
                 android:id="@+id/operate"
-                android:layout_width="227px"
+                android:layout_width="100px"
                 android:layout_height="wrap_content"
                 android:layout_centerVertical="true"
                 android:layout_toEndOf="@id/save"
-                android:paddingStart="15px"
+                android:gravity="center"
                 android:text="操作"
                 android:textColor="#333333"
                 android:textSize="26px" />
@@ -415,10 +417,52 @@
             android:layout_marginHorizontal="50px"
             android:layout_marginBottom="20px">
 
+            <RelativeLayout
+                android:id="@+id/pageControl"
+                android:layout_width="match_parent"
+                android:layout_height="30dp"
+                android:layout_alignParentBottom="true"
+                android:layout_marginTop="10dp"
+                android:layout_marginBottom="19dp">
+
+                <TextView
+                    android:id="@+id/pageItem"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_centerInParent="true"
+                    android:layout_marginHorizontal="20dp"
+                    android:text="0/0" />
+
+                <Button
+                    android:id="@+id/lastPage"
+                    android:layout_width="65dp"
+                    android:layout_height="25dp"
+                    android:layout_centerVertical="true"
+                    android:layout_marginRight="10dp"
+                    android:layout_toLeftOf="@+id/pageItem"
+                    android:background="@drawable/bg_up_page"
+                    android:text="上一页"
+                    android:textColor="@color/black"
+                    android:textSize="10sp" />
+
+                <Button
+                    android:id="@+id/nextPage"
+                    android:layout_width="65dp"
+                    android:layout_height="25dp"
+                    android:layout_centerVertical="true"
+                    android:layout_marginLeft="10dp"
+                    android:layout_toRightOf="@id/pageItem"
+                    android:background="@drawable/bg_sou_suo_page"
+                    android:text="下一页"
+                    android:textColor="@color/white"
+                    android:textSize="10sp" />
+            </RelativeLayout>
+
             <ListView
                 android:id="@+id/alreadyLV"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
+                android:layout_above="@id/pageControl"
                 tools:listitem="@layout/item_already" />
 
         </RelativeLayout>

+ 6 - 1
app/src/main/res/layout/activity_chemical_labeling.xml

@@ -469,9 +469,14 @@
 
                 <TextView
                     android:id="@+id/chemicalName"
-                    android:layout_width="wrap_content"
+                    android:layout_width="300px"
                     android:layout_height="wrap_content"
                     android:layout_centerVertical="true"
+                    android:ellipsize="marquee"
+                    android:focusable="true"
+                    android:focusableInTouchMode="true"
+                    android:marqueeRepeatLimit="marquee_forever"
+                    android:singleLine="true"
                     android:text="化学品名称化学品名称"
                     android:textColor="@color/black"
                     android:textSize="15sp" />

+ 20 - 18
app/src/main/res/layout/item_already.xml

@@ -10,13 +10,15 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerVertical="true"
-        android:layout_marginStart="10px"
+        android:layout_marginHorizontal="10px"
+        android:background="@drawable/cb"
+        android:button="@null"
         android:focusable="false"
         android:focusableInTouchMode="false" />
 
     <TextView
         android:id="@+id/alreadyCodeTV"
-        android:layout_width="195px"
+        android:layout_width="175px"
         android:layout_height="wrap_content"
         android:layout_centerVertical="true"
         android:layout_toEndOf="@id/selectCB"
@@ -25,11 +27,11 @@
         android:paddingStart="15px"
         android:text="申领单号"
         android:textColor="#333333"
-        android:textSize="26px" />
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/name"
-        android:layout_width="145px"
+        android:layout_width="200px"
         android:layout_height="wrap_content"
         android:layout_centerVertical="true"
         android:layout_toEndOf="@id/alreadyCodeTV"
@@ -38,7 +40,7 @@
         android:paddingStart="15px"
         android:text="名称"
         android:textColor="#333333"
-        android:textSize="26px" />
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/type"
@@ -51,7 +53,7 @@
         android:paddingStart="15px"
         android:text="类别"
         android:textColor="#333333"
-        android:textSize="26px" />
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/cas"
@@ -64,7 +66,7 @@
         android:paddingStart="15px"
         android:text="CAS"
         android:textColor="#333333"
-        android:textSize="26px" />
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/purity"
@@ -77,11 +79,11 @@
         android:paddingStart="15px"
         android:text="纯度"
         android:textColor="#333333"
-        android:textSize="26px" />
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/specs"
-        android:layout_width="126px"
+        android:layout_width="120px"
         android:layout_height="wrap_content"
         android:layout_centerVertical="true"
         android:layout_toEndOf="@id/purity"
@@ -90,11 +92,11 @@
         android:paddingStart="15px"
         android:text="规格"
         android:textColor="#333333"
-        android:textSize="26px" />
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/belongTV"
-        android:layout_width="126px"
+        android:layout_width="120px"
         android:layout_height="wrap_content"
         android:layout_centerVertical="true"
         android:layout_toEndOf="@id/specs"
@@ -103,7 +105,7 @@
         android:paddingStart="15px"
         android:text="归属人"
         android:textColor="#333333"
-        android:textSize="26px" />
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/applicantTV"
@@ -116,7 +118,7 @@
         android:paddingStart="15px"
         android:text="申领人"
         android:textColor="#333333"
-        android:textSize="26px" />
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/code"
@@ -129,7 +131,7 @@
         android:paddingStart="15px"
         android:text="编码"
         android:textColor="#333333"
-        android:textSize="26px" />
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/save"
@@ -142,18 +144,18 @@
         android:paddingStart="15px"
         android:text="存储位置"
         android:textColor="#0183FA"
-        android:textSize="26px" />
+        android:textSize="20px" />
 
     <TextView
         android:id="@+id/operate"
-        android:layout_width="227px"
+        android:layout_width="100px"
         android:layout_height="wrap_content"
         android:layout_centerVertical="true"
         android:layout_toEndOf="@id/save"
-        android:paddingStart="15px"
+        android:gravity="center"
         android:text="打印标签"
         android:textColor="#0183FA"
-        android:textSize="26px" />
+        android:textSize="20px" />
 
 
 </RelativeLayout>

+ 6 - 0
app/src/main/res/layout/item_inquiry.xml

@@ -15,7 +15,12 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_weight="1"
+            android:ellipsize="marquee"
+            android:focusable="true"
+            android:focusableInTouchMode="true"
             android:gravity="center"
+            android:marqueeRepeatLimit="marquee_forever"
+            android:singleLine="true"
             android:textColor="@color/black"
             android:textSize="10sp" />
 
@@ -73,6 +78,7 @@
             android:textColor="@color/black"
             android:textSize="10sp" />
     </LinearLayout>
+
     <View
         android:layout_width="match_parent"
         android:layout_height="0.5dp"

+ 12 - 2
app/src/main/res/layout/item_usage_label_dialog.xml

@@ -15,7 +15,12 @@
             android:layout_width="match_parent"
             android:layout_height="25dp"
             android:layout_weight="1"
+            android:ellipsize="marquee"
+            android:focusable="true"
+            android:focusableInTouchMode="true"
             android:gravity="center"
+            android:marqueeRepeatLimit="marquee_forever"
+            android:singleLine="true"
             android:textColor="@color/black"
             android:textSize="12sp" />
 
@@ -24,7 +29,12 @@
             android:layout_width="match_parent"
             android:layout_height="25dp"
             android:layout_weight="1"
+            android:ellipsize="marquee"
+            android:focusable="true"
+            android:focusableInTouchMode="true"
             android:gravity="center"
+            android:marqueeRepeatLimit="marquee_forever"
+            android:singleLine="true"
             android:textColor="@color/black"
             android:textSize="12sp" />
 
@@ -65,10 +75,10 @@
                 android:id="@+id/sPinner"
                 android:layout_width="85dp"
                 android:layout_height="24dp"
+                android:layout_marginLeft="1dp"
                 android:layout_marginTop="1dp"
-                android:layout_marginBottom="1dp"
                 android:layout_marginRight="1dp"
-                android:layout_marginLeft="1dp"
+                android:layout_marginBottom="1dp"
                 android:background="@null"
                 android:textColor="@color/black" />
 

BIN
app/src/main/res/mipmap-hdpi/selected_cb.png


BIN
app/src/main/res/mipmap-hdpi/unselected_cb.png