Browse Source

优化生产信息绑定界面人员编号输入逻辑

ChengJH 2 years ago
parent
commit
49dce49f34

+ 30 - 0
app/src/main/java/com/uas/rd_equipment/bean/User.java

@@ -0,0 +1,30 @@
+package com.uas.rd_equipment.bean;
+
+/**
+ * Created by cjh-sail on 2023-07-03
+ */
+public class User {
+    private String name;
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        User user = (User) o;
+        return name != null ? name.equals(user.name) : user.name == null;
+    }
+
+    @Override
+    public int hashCode() {
+        return name != null ? name.hashCode() : 0;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+}

+ 108 - 32
app/src/main/java/com/uas/rd_equipment/fragment/ProduceMassageBindingFragment.java

@@ -53,6 +53,7 @@ import com.uas.rd_equipment.activity.FunctionActivity;
 import com.uas.rd_equipment.bean.LinecodeBean;
 import com.uas.rd_equipment.bean.LinecodeBean;
 import com.uas.rd_equipment.bean.MakerecordBean;
 import com.uas.rd_equipment.bean.MakerecordBean;
 import com.uas.rd_equipment.bean.ResourcesBean;
 import com.uas.rd_equipment.bean.ResourcesBean;
+import com.uas.rd_equipment.bean.User;
 import com.uas.rd_equipment.camera.CaptureActivity;
 import com.uas.rd_equipment.camera.CaptureActivity;
 import com.uas.rd_equipment.global.GloableParams;
 import com.uas.rd_equipment.global.GloableParams;
 import com.uas.rd_equipment.tools.SharedPreUtil;
 import com.uas.rd_equipment.tools.SharedPreUtil;
@@ -78,7 +79,10 @@ import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.List;
+import java.util.Set;
 
 
 import razerdp.basepopup.BasePopupWindow;
 import razerdp.basepopup.BasePopupWindow;
 
 
@@ -126,7 +130,7 @@ public class ProduceMassageBindingFragment extends BaseFragment implements OnCol
     private IpAndResourcesPortAdapter ipAndResourcesPortAdapter;
     private IpAndResourcesPortAdapter ipAndResourcesPortAdapter;
     private String sc_code;
     private String sc_code;
     private List<ResourcesBean> resourcesBeanList;
     private List<ResourcesBean> resourcesBeanList;
-    private ClearableEditText tv_dc_emcode;
+    private AutoCompleteTextView tv_dc_emcode;
     private ImageView iv_dc_emcode;
     private ImageView iv_dc_emcode;
     private TextView tv_dc_emname;
     private TextView tv_dc_emname;
     private String substring;
     private String substring;
@@ -137,7 +141,9 @@ public class ProduceMassageBindingFragment extends BaseFragment implements OnCol
     private String maFunName = null;
     private String maFunName = null;
     private ImageView shaopwork_id;
     private ImageView shaopwork_id;
     private List<String> stringList;
     private List<String> stringList;
-    private HashSet<String> setstring;
+    private Set<String> setstring;
+    private ImageView tv_dc_emcode_delete;
+    private List<User> list;
 
 
     @Override
     @Override
     protected int getLayout() {
     protected int getLayout() {
@@ -175,13 +181,14 @@ public class ProduceMassageBindingFragment extends BaseFragment implements OnCol
         work_code_code = root.findViewById(R.id.work_code_code);
         work_code_code = root.findViewById(R.id.work_code_code);
         masterSpinner = (Spinner) root.findViewById(R.id.sp_login);
         masterSpinner = (Spinner) root.findViewById(R.id.sp_login);
         shaopwork_id = root.findViewById(R.id.shaopwork_id);
         shaopwork_id = root.findViewById(R.id.shaopwork_id);
+        tv_dc_emcode_delete = root.findViewById(R.id.tv_dc_emcode_delete);
 
 
 
 
     }
     }
 
 
     @Override
     @Override
     protected void initEvents() {
     protected void initEvents() {
-        storage_recharge_collect_et.requestFocus();
+        et_linecode_smts.requestFocus();
         mFilterStorageInBeans = Collections.synchronizedList(new ArrayList<>());
         mFilterStorageInBeans = Collections.synchronizedList(new ArrayList<>());
     }
     }
 
 
@@ -391,6 +398,36 @@ public class ProduceMassageBindingFragment extends BaseFragment implements OnCol
             }
             }
         });
         });
 
 
+        tv_dc_emcode.addTextChangedListener(new TextWatcher() {
+            @Override
+            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+            }
+
+            @Override
+            public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+            }
+
+            @Override
+            public void afterTextChanged(Editable s) {
+                if (s == null || s.length() == 0) {
+                    tv_dc_emcode_delete.setVisibility(View.GONE);
+                } else {
+                    tv_dc_emcode_delete.setVisibility(View.VISIBLE);
+                }
+            }
+        });
+
+        tv_dc_emcode_delete.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                tv_dc_emcode.setText("");
+                tv_dc_emcode.requestFocus();
+
+            }
+        });
+
         iv_dc_emcode.setOnClickListener(new View.OnClickListener() {
         iv_dc_emcode.setOnClickListener(new View.OnClickListener() {
             @Override
             @Override
             public void onClick(View v) {
             public void onClick(View v) {
@@ -416,18 +453,46 @@ public class ProduceMassageBindingFragment extends BaseFragment implements OnCol
 //        ceshiData();
 //        ceshiData();
     }
     }
 
 
-
     String inputString ="" ;
     String inputString ="" ;
     public void getNewdc_emcodeData(String input){
     public void getNewdc_emcodeData(String input){
+
         if (input.isEmpty()){
         if (input.isEmpty()){
             CommonUtil.toastNoRepeat(mActivity, "请输入人员编号");
             CommonUtil.toastNoRepeat(mActivity, "请输入人员编号");
             return;
             return;
         }
         }
+        list = new ArrayList<>();
+        list.clear();
+        String[] split = input.split(",");
+
+        for (String value : split) {
+            User user=new User();
+            if (!value.isEmpty()) {
+                user.setName(value + ",");
+                list.add(user);
+            }
+
+        }
+
+        for (int i = 0; i < list.size(); i++)  //外循环是循环的次数
+        {
+            for (int j = list.size() - 1; j > i; j--)  //内循环是 外循环一次比较的次数
+            {
+                if (list.get(i).getName().equals(list.get(j).getName()))
+                {
+                    list.remove(j);
+                }
+
+            }
+        }
+
+        for (int s = 0; s < list.size(); s++) {
+            inputString+= list.get(s).getName();
+        }
         progressDialog.show();
         progressDialog.show();
         VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
         VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
                 .url(GloableParams.ASTATIONTHE_SELECT_GETEMNAME)
                 .url(GloableParams.ASTATIONTHE_SELECT_GETEMNAME)
                 .method(Request.Method.GET)
                 .method(Request.Method.GET)
-                .addParam("em_code",tv_dc_emcode.getText().toString().trim()+",")
+                .addParam("em_code",inputString)
                 .build(), new HttpCallback() {
                 .build(), new HttpCallback() {
             @Override
             @Override
             public void onSuccess(int flag, Object o) throws Exception {//DeviceChange!Use
             public void onSuccess(int flag, Object o) throws Exception {//DeviceChange!Use
@@ -437,46 +502,57 @@ public class ProduceMassageBindingFragment extends BaseFragment implements OnCol
                 JSONObject dataObject = resultObject.getJSONObject("items");
                 JSONObject dataObject = resultObject.getJSONObject("items");
                 String de_name = FastjsonUtil.getText(dataObject, "em_name");
                 String de_name = FastjsonUtil.getText(dataObject, "em_name");
                 tv_dc_emname.setText(de_name);
                 tv_dc_emname.setText(de_name);
-                stringList.clear();
-                String[] split = input.split(",");
-                for (int i=0;i<split.length;i++){
-                    if (!split[i].isEmpty()){
-                        stringList.add(split[i]);
-                    }
-
-                }
-//                stringList.addAll(Arrays.asList(split));
-//                stringList.add(input+",");
-//                for (int i=0;i<stringList.size();i++){
-//                    inputString=stringList.get(i)+",";
-//                }
-                Log.e("stringList1===",inputString+"");
-                setstring.clear();
-                setstring.addAll(stringList);
-                for (int item = 0;item<setstring.size();item++){
-                    inputString = setstring+",";
-                }
-                Log.e("stringList2===",inputString+"");
-//                String substring = inputString.toString().substring(0, inputString.toString().length() - 1);//去除尾部
-//                String substring1 = substring.substring(1, substring.length());//去除首部
-
-                String replace = inputString.replace("[", "");
-                String replace1 = replace.replace("]", "");
-                inputString=replace1;
-
                 tv_dc_emcode.setText(inputString+"");
                 tv_dc_emcode.setText(inputString+"");
                 tv_dc_emcode.setSelection(tv_dc_emcode.getText().toString().length());
                 tv_dc_emcode.setSelection(tv_dc_emcode.getText().toString().length());
+                inputString="";
             }
             }
 
 
             @Override
             @Override
             public void onFail(int flag, String failStr) throws Exception {
             public void onFail(int flag, String failStr) throws Exception {
                 progressDialog.dismiss();
                 progressDialog.dismiss();
+                inputString="";
                 CommonUtil.toastNoRepeat(mActivity, failStr);
                 CommonUtil.toastNoRepeat(mActivity, failStr);
+                for (int s = 0; s < list.size(); s++) {
+                    if (failStr.contains(list.get(s).getName().replace(",",""))){
+                        list.remove(s);
+                    }
+                }
+                for (int s = 0; s < list.size(); s++) {
+                    inputString+= list.get(s).getName();
+                }
                 tv_dc_emcode.setText(inputString+"");
                 tv_dc_emcode.setText(inputString+"");
                 tv_dc_emcode.setSelection(tv_dc_emcode.getText().toString().length());
                 tv_dc_emcode.setSelection(tv_dc_emcode.getText().toString().length());
+                inputString="";
             }
             }
         });
         });
     }
     }
+
+
+    public static List<String> removeDuplicate(List<String> list)
+
+    {
+        Set set = new LinkedHashSet<String>();
+        set.addAll(list);
+        list.clear();
+        list.addAll(set);
+        return list;
+    }
+
+    /**
+     * 得到去除重复后的集合
+     * @param list
+     * @return
+     */
+    private static List<User> getRemoveList(List<User> list){
+        Set set = new HashSet();
+        List<User> newList = new ArrayList<>();
+        for (Iterator iter = list.iterator(); iter.hasNext();){
+            User object = (User) iter.next();
+            if(set.add(object))
+                newList.add(object);
+        }
+        return newList;
+    }
     //工单ID
     //工单ID
     public void getfuzzySearchData(String inoutNo){
     public void getfuzzySearchData(String inoutNo){
         progressDialog.show();
         progressDialog.show();

+ 4 - 2
app/src/main/res/layout/popwin_whbatch_breakpackage.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-   android:layout_width="match_parent"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
     android:layout_height="match_parent">
     android:layout_height="match_parent">
 
 
     <RelativeLayout
     <RelativeLayout
@@ -60,7 +61,8 @@
                 android:id="@+id/btn_print"
                 android:id="@+id/btn_print"
                 android:layout_toLeftOf="@id/btn_dialog_confirm_ok"
                 android:layout_toLeftOf="@id/btn_dialog_confirm_ok"
                 style="@style/PopwinCancleButtonStyle"
                 style="@style/PopwinCancleButtonStyle"
-                android:text="@string/text_btn_print"/>
+                android:text="@string/text_btn_print"
+                tools:ignore="NotSibling" />
         </RelativeLayout>
         </RelativeLayout>
     </RelativeLayout>
     </RelativeLayout>
 </RelativeLayout>
 </RelativeLayout>

+ 26 - 18
app/src/main/res/layout/producemassagebinding_fragment.xml

@@ -254,33 +254,41 @@
             <LinearLayout
             <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginLeft="@dimen/textsize_16"
-                android:layout_marginRight="@dimen/textsize_16">
-                <com.uas.rd_equipment.view.ClearableEditText
-                    android:id="@+id/tv_dc_emcode"
-                    style="@style/EditTextLineStyle"
-                    android:text=""
-                    android:hint="请输入人员编号"
-                    android:layout_width="match_parent"
-                    android:layout_height="30dp"
-                    android:layout_weight="1"
-                    android:textColor="@color/black"
-                    />
+                android:layout_marginRight="16dp"
+                android:layout_marginLeft="16dp">
+                <FrameLayout
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1">
+
+                    <AutoCompleteTextView
+                        android:id="@+id/tv_dc_emcode"
+                        style="@style/EditTextLineStyle"
+                        android:layout_height="30dp"
+                        android:hint="请输入人员编号" />
+
+                    <ImageView
+                        android:id="@+id/tv_dc_emcode_delete"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_gravity="center|right"
+                        android:layout_marginRight="13dp"
+                        android:src="@drawable/wrong"
+                        android:visibility="gone" />
+                </FrameLayout>
 
 
                 <ImageView
                 <ImageView
                     android:id="@+id/iv_dc_emcode"
                     android:id="@+id/iv_dc_emcode"
-                    android:layout_width="30dp"
-                    android:layout_height="wrap_content"
                     android:layout_gravity="center"
                     android:layout_gravity="center"
+                    android:layout_width="30dp"
+                    android:layout_height="match_parent"
                     android:layout_marginRight="10dp"
                     android:layout_marginRight="10dp"
                     android:layout_marginLeft="5dp"
                     android:layout_marginLeft="5dp"
-                    android:clickable="false"
-                    android:src="@drawable/ic_edittext_scan" />
+                    android:background="@drawable/ic_edittext_scan"
+                    android:src="@drawable/search_48" />
             </LinearLayout>
             </LinearLayout>
 
 
 
 
-
-
         </TableRow>
         </TableRow>
         <TableRow
         <TableRow
             android:layout_marginTop="5dp">
             android:layout_marginTop="5dp">

+ 1 - 1
pda_libs/pulltoreflashlibrary/build/intermediates/incremental/packageDebugResources/compile-file-map.properties

@@ -1,4 +1,4 @@
-#Tue Jun 27 10:30:29 CST 2023
+#Mon Jul 03 15:49:59 CST 2023
 D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\src\\main\\res\\anim\\slide_out_to_top.xml=D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\build\\intermediates\\packaged_res\\debug\\anim\\slide_out_to_top.xml
 D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\src\\main\\res\\anim\\slide_out_to_top.xml=D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\build\\intermediates\\packaged_res\\debug\\anim\\slide_out_to_top.xml
 D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\src\\main\\res\\anim\\slide_in_from_top.xml=D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\build\\intermediates\\packaged_res\\debug\\anim\\slide_in_from_top.xml
 D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\src\\main\\res\\anim\\slide_in_from_top.xml=D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\build\\intermediates\\packaged_res\\debug\\anim\\slide_in_from_top.xml
 D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\src\\main\\res\\drawable-xhdpi\\default_ptr_rotate.png=D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\build\\intermediates\\packaged_res\\debug\\drawable-xhdpi-v4\\default_ptr_rotate.png
 D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\src\\main\\res\\drawable-xhdpi\\default_ptr_rotate.png=D\:\\AndroidData\\RD-NewEquipmentManagement\\pda_libs\\pulltoreflashlibrary\\build\\intermediates\\packaged_res\\debug\\drawable-xhdpi-v4\\default_ptr_rotate.png