|
|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.collection.fragment;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
|
import android.graphics.Color;
|
|
|
@@ -12,14 +13,19 @@ import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.Editable;
|
|
|
import android.text.TextWatcher;
|
|
|
import android.util.Base64;
|
|
|
+import android.util.Log;
|
|
|
+import android.util.SparseBooleanArray;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
import android.view.Window;
|
|
|
import android.view.WindowManager;
|
|
|
import android.view.inputmethod.EditorInfo;
|
|
|
import android.widget.AutoCompleteTextView;
|
|
|
+import android.widget.CheckBox;
|
|
|
+import android.widget.CompoundButton;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.PopupWindow;
|
|
|
@@ -45,6 +51,7 @@ import com.uas.collection.activity.FunctionActivity;
|
|
|
import com.uas.collection.bean.IpAndPortBean;
|
|
|
import com.uas.collection.bean.LinecodeBean;
|
|
|
import com.uas.collection.bean.ResourcesBean;
|
|
|
+import com.uas.collection.bean.StorageRechargeAloneBean;
|
|
|
import com.uas.collection.bean.TestcollectDataBean;
|
|
|
import com.uas.collection.camera.CaptureActivity;
|
|
|
import com.uas.collection.global.GloableParams;
|
|
|
@@ -57,15 +64,20 @@ import com.uas.collection.util.HttpCallback;
|
|
|
import com.uas.collection.util.HttpParams;
|
|
|
import com.uas.collection.util.LogUtil;
|
|
|
import com.uas.collection.util.MyArrayAdapter;
|
|
|
+import com.uas.collection.util.MyLayoutManager;
|
|
|
import com.uas.collection.util.StringUtil;
|
|
|
import com.uas.collection.util.VollyRequest;
|
|
|
import com.uas.collection.view.ClearableEditText;
|
|
|
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.json.JSONException;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import razerdp.basepopup.BasePopupWindow;
|
|
|
|
|
|
@@ -75,8 +87,6 @@ import razerdp.basepopup.BasePopupWindow;
|
|
|
* 数据采集
|
|
|
*/
|
|
|
public class DataCollectionFragment extends BaseFragment implements View.OnClickListener {
|
|
|
-
|
|
|
-
|
|
|
private TextView tv_save;
|
|
|
private AutoCompleteTextView et_linecode_smts;
|
|
|
private ImageView iv_popuwindow;
|
|
|
@@ -119,6 +129,11 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
private ImageView iv_dc_emcode;
|
|
|
private int mFocusId;
|
|
|
private static final int SCAN_BARCODE_CODESD = 925;
|
|
|
+ private RecyclerView rv_datachange;
|
|
|
+ private ArrayList<StorageRechargeAloneBean> mFeededList;
|
|
|
+ private SelectAdapter selectAdapter;
|
|
|
+ private String alonedata;
|
|
|
+
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
return R.layout.fragment_datacollection;
|
|
|
@@ -158,6 +173,7 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
tv_station = root.findViewById(R.id.tv_station);
|
|
|
tv_dc_emcode = root.findViewById(R.id.tv_dc_emcode);
|
|
|
iv_dc_emcode = root.findViewById(R.id.iv_dc_emcode);
|
|
|
+ rv_datachange = root.findViewById(R.id.rv_datachange);
|
|
|
|
|
|
mFilterStorageInBeans = Collections.synchronizedList(new ArrayList<>());
|
|
|
|
|
|
@@ -319,7 +335,15 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
//// initunhealthyPopupWindow();
|
|
|
// }
|
|
|
// });
|
|
|
-
|
|
|
+ mFeededList = new ArrayList<>();
|
|
|
+ selectAdapter = new SelectAdapter(mFeededList);
|
|
|
+ LinearLayoutManager layoutmanager = new LinearLayoutManager(mActivity);
|
|
|
+ MyLayoutManager layout = new MyLayoutManager();
|
|
|
+ layout.setAutoMeasureEnabled(true);//防止recyclerview高度为wrap时测量item高度0(一定要加这个属性,否则显示不出来)
|
|
|
+ layoutmanager.setOrientation(LinearLayoutManager.HORIZONTAL);//列表横向显示
|
|
|
+ rv_datachange.setLayoutManager(layout);
|
|
|
+ setAdapter(mFeededList);
|
|
|
+ rv_datachange.setAdapter(selectAdapter);
|
|
|
|
|
|
|
|
|
tv_save.setOnClickListener(new View.OnClickListener() {
|
|
|
@@ -363,11 +387,6 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void closeListPopupWindow() {
|
|
|
@@ -425,6 +444,24 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void handleFeededData(JSONArray dataArray) {
|
|
|
+ StorageRechargeAloneBean bean;
|
|
|
+ mFeededList.clear();
|
|
|
+ for (Object index : dataArray) {
|
|
|
+ JSONObject data = (JSONObject) index;
|
|
|
+ bean= new StorageRechargeAloneBean(
|
|
|
+ data.getString("alonedata"));
|
|
|
+ mFeededList.add(bean);
|
|
|
+ }
|
|
|
+ setAdapter(mFeededList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setAdapter(ArrayList<StorageRechargeAloneBean> mList) {
|
|
|
+ LogUtil.i("mList", JSON.toJSONString(mList));
|
|
|
+ selectAdapter = new SelectAdapter(mList);
|
|
|
+ rv_datachange.setAdapter(selectAdapter);
|
|
|
+ }
|
|
|
+
|
|
|
private class ComDataBean{
|
|
|
String PS_CODE = null;
|
|
|
String PS_PRODCODE = null;
|
|
|
@@ -749,7 +786,6 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
if (dataArrayone == null|| dataArrayone.size() == 0){
|
|
|
CommonUtil.toastNoRepeat(mActivity,"未搜索到匹配数据");
|
|
|
}
|
|
|
-
|
|
|
if (sourstring.equals("不良")){
|
|
|
for(Object index:dataArrayone){
|
|
|
JSONObject data = (JSONObject) index;
|
|
|
@@ -771,6 +807,7 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
JSONObject data = (JSONObject) index;
|
|
|
ResourcesBean bean = new ResourcesBean();
|
|
|
bean.setSC_CODE(data.getString("SC_CODE"));
|
|
|
+ bean.setST_REMARK(data.getString("ST_REMARK"));
|
|
|
resourcesBeanList.add(bean);
|
|
|
}
|
|
|
ipAndResourcesPortAdapter.setmList(resourcesBeanList);
|
|
|
@@ -877,6 +914,14 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
if (ec_passqtytrim.isEmpty()){
|
|
|
ec_passqtytrim="1";
|
|
|
}
|
|
|
+ ArrayList<StorageRechargeAloneBean> selectedItem = selectAdapter.getSelectedItem();
|
|
|
+ if (selectedItem.size()==0){
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请选择不良现象");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (int i=0;i<selectedItem.size();i++){
|
|
|
+ alonedata = selectedItem.get(i).getAlonedata();
|
|
|
+ }
|
|
|
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
JSONObject object_1 = new JSONObject();
|
|
|
@@ -885,7 +930,7 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
object_1.put("SR_SOURCECODE", at_stationtrim);//资源
|
|
|
object_1.put("SR_PASSQTY", "0");//通过数量
|
|
|
object_1.put("SR_NGQTY", ec_passqtytrim);//NG数量
|
|
|
- object_1.put("SR_BADNAME","ce_unhealthytrim");//不良现象
|
|
|
+ object_1.put("SR_BADNAME",alonedata);//不良现象
|
|
|
object_1.put("SR_TYPE", "数据采集");//种类(数据采集/、外观维修/性能维修)
|
|
|
object_1.put("SR_LOCATION", ce_bit_numbertrim);//位号
|
|
|
object_1.put("SR_REASON", "");//原因
|
|
|
@@ -1077,16 +1122,16 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
search_im.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- getfuzzySearchSourceData(ce_resources.getText().toString().trim(),"弹框");
|
|
|
+ getfuzzySearchSourceData(edit_et.getText().toString().trim(),"弹框");
|
|
|
}
|
|
|
});
|
|
|
|
|
|
ipAndResourcesPortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
-
|
|
|
@Override
|
|
|
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
List<ResourcesBean> ipAndPortBeans = ipAndResourcesPortAdapter.getmList();
|
|
|
sc_code = ipAndPortBeans.get(position).getSC_CODE();
|
|
|
+ st_remark = ipAndPortBeans.get(position).getST_REMARK();
|
|
|
for (int i = 0; i < ipAndPortBeans.size(); i++) {
|
|
|
ipAndPortBeans.get(i).setChecked(false);
|
|
|
}
|
|
|
@@ -1096,12 +1141,39 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
});
|
|
|
|
|
|
|
|
|
+ List<String> list=new ArrayList<>();
|
|
|
//确定
|
|
|
sure_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
+ list.clear();
|
|
|
ce_resources.setText(sc_code);
|
|
|
tv_station.setText("当前岗位:"+sc_code);
|
|
|
+ if (!StringUtil.isEmpty(st_remark)){
|
|
|
+ if (st_remark.contains("|")){
|
|
|
+ String[] split = st_remark.split("\\|");
|
|
|
+ list.addAll(Arrays.asList(split));
|
|
|
+ }else {
|
|
|
+ list.add(st_remark);
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ JSONObject object_1 = new JSONObject();
|
|
|
+ for (int i=0;i<list.size();i++){
|
|
|
+ StorageRechargeAloneBean bean=new StorageRechargeAloneBean(list.get(i));
|
|
|
+ object_1.put("alone", list.get(i));
|
|
|
+ jsonArray.add(bean);
|
|
|
+ }
|
|
|
+
|
|
|
+ jsonObject.put("formStore", jsonArray);
|
|
|
+ Log.e("alone===2",jsonObject.toString());
|
|
|
+
|
|
|
+ JSONArray dataArray = FastjsonUtil.getJSONArray(jsonObject.toString(), "formStore");
|
|
|
+ handleFeededData(dataArray);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
closeListPopupWindow();
|
|
|
}
|
|
|
});
|
|
|
@@ -1296,7 +1368,125 @@ public class DataCollectionFragment extends BaseFragment implements View.OnClick
|
|
|
|
|
|
|
|
|
|
|
|
+ public class SelectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
+ private int checkedPosition = -1;
|
|
|
+ private boolean onBind;
|
|
|
+ private ArrayList<StorageRechargeAloneBean> mList = new ArrayList<>();
|
|
|
+ private SparseBooleanArray mSelectedPositions = new SparseBooleanArray();
|
|
|
+ private boolean mIsSelectable = false;
|
|
|
+
|
|
|
+
|
|
|
+ public SelectAdapter(ArrayList<StorageRechargeAloneBean> list) {
|
|
|
+ if (list == null) {
|
|
|
+ throw new IllegalArgumentException("model Data must not be null");
|
|
|
+ }
|
|
|
+ mList = list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新adpter的数据和选择状态
|
|
|
+ public void updateDataSet(ArrayList<StorageRechargeAloneBean> list) {
|
|
|
+ this.mList = list;
|
|
|
+ mSelectedPositions = new SparseBooleanArray();
|
|
|
+// ab.setTitle("已选择" + 0 + "项");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ @Override
|
|
|
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
|
+ View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.recyclerview_item_data, viewGroup, false);
|
|
|
+ return new SelectAdapter.ListItemViewHolder(itemView);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<Integer, Boolean> map = new HashMap<>();
|
|
|
+ //绑定界面,设置监听
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
+ @Override
|
|
|
+ public void onBindViewHolder(final RecyclerView.@NotNull ViewHolder holder, @SuppressLint("RecyclerView") int i) {
|
|
|
+
|
|
|
+ //设置条目状态
|
|
|
+ (( SelectAdapter.ListItemViewHolder) holder).mainTitle.setText(mList.get(i).getAlonedata());
|
|
|
+// ((ListItemViewHolder) holder).checkBox.setChecked();
|
|
|
+ //checkBox的监听
|
|
|
+ (( SelectAdapter.ListItemViewHolder) holder).checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ if (isChecked == true) {
|
|
|
+ map.clear();
|
|
|
+ map.put(i, true);
|
|
|
+ checkedPosition = i;
|
|
|
+ } else {
|
|
|
+ map.remove(i);
|
|
|
+ if (map.size() == 0) {
|
|
|
+ checkedPosition = -1; //-1 代表一个都未选择
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!onBind) {
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ onBind = true;
|
|
|
+ if (map != null && map.containsKey(i)) {
|
|
|
+ (( SelectAdapter.ListItemViewHolder) holder).checkBox.setChecked(true);
|
|
|
+ } else {
|
|
|
+ (( SelectAdapter.ListItemViewHolder) holder).checkBox.setChecked(false);
|
|
|
+ }
|
|
|
+ onBind = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获得选中条目的结果
|
|
|
+ public ArrayList<StorageRechargeAloneBean> getSelectedItem() {
|
|
|
+ ArrayList<StorageRechargeAloneBean> selectList = new ArrayList<>();
|
|
|
+ int checkedPosition = getCheckedPosition();
|
|
|
+ if (checkedPosition==-1){
|
|
|
+ selectList.clear();
|
|
|
+ }else {
|
|
|
+ selectList.add(mList.get(checkedPosition));
|
|
|
+ }
|
|
|
+
|
|
|
+ return selectList;
|
|
|
+ }
|
|
|
+ //设置给定位置条目的选择状态
|
|
|
+ private void setItemChecked(int position, boolean isChecked) {
|
|
|
+ mSelectedPositions.put(position, isChecked);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //根据位置判断条目是否选中
|
|
|
+ private boolean isItemChecked(int position) {
|
|
|
+ return mSelectedPositions.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ //得到当前选中的位置
|
|
|
+ public int getCheckedPosition() {
|
|
|
+ return checkedPosition;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public int getItemCount() {
|
|
|
+ return mList == null ? 0 : mList.size();
|
|
|
+ }
|
|
|
+ //根据位置判断条目是否可选
|
|
|
+ private boolean isSelectable() {
|
|
|
+ return mIsSelectable;
|
|
|
+ }
|
|
|
+ //设置给定位置条目的可选与否的状态
|
|
|
+ private void setSelectable(boolean selectable) {
|
|
|
+ mIsSelectable = selectable;
|
|
|
+ }
|
|
|
+ public class ListItemViewHolder extends RecyclerView.ViewHolder{
|
|
|
+ //ViewHolder
|
|
|
+ CheckBox checkBox;
|
|
|
+ TextView mainTitle;
|
|
|
+ ClearableEditText ce_other;
|
|
|
+ ListItemViewHolder(View view) {
|
|
|
+ super(view);
|
|
|
+ this.mainTitle = (TextView) view.findViewById(R.id.text);
|
|
|
+ this.checkBox = (CheckBox) view.findViewById(R.id.select_checkbox);
|
|
|
+ this.ce_other = (ClearableEditText) view.findViewById(R.id.ce_other);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|