|
@@ -0,0 +1,584 @@
|
|
|
+package com.uas.ruiziuasmes;
|
|
|
+
|
|
|
+import android.app.Activity;
|
|
|
+import android.content.Intent;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+import android.text.Editable;
|
|
|
+import android.text.TextWatcher;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.view.inputmethod.EditorInfo;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.AutoCompleteTextView;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.android.volley.toolbox.StringRequest;
|
|
|
+import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
+import com.chad.library.adapter.base.BaseViewHolder;
|
|
|
+import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
|
|
+import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
|
|
+import com.uas.ruiziuasmes.activity.BaseActivity;
|
|
|
+import com.uas.ruiziuasmes.adapter.MyaddAdapter;
|
|
|
+import com.uas.ruiziuasmes.bean.AddworkorderBean;
|
|
|
+import com.uas.ruiziuasmes.global.GloableParams;
|
|
|
+import com.uas.ruiziuasmes.tools.SharedPreUtil;
|
|
|
+import com.uas.ruiziuasmes.util.CommonUtil;
|
|
|
+import com.uas.ruiziuasmes.util.Constants;
|
|
|
+import com.uas.ruiziuasmes.util.FastjsonUtil;
|
|
|
+import com.uas.ruiziuasmes.util.HttpCallback;
|
|
|
+import com.uas.ruiziuasmes.util.HttpParams;
|
|
|
+import com.uas.ruiziuasmes.util.LogUtil;
|
|
|
+import com.uas.ruiziuasmes.util.MyArrayAdapter;
|
|
|
+import com.uas.ruiziuasmes.util.StringUtil;
|
|
|
+import com.uas.ruiziuasmes.util.VollyRequest;
|
|
|
+import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+public class WorkOrderSearchActivity extends BaseActivity {
|
|
|
+ private static String TAG ="WorkOrderSearchActivity";
|
|
|
+ private AutoCompleteTextView mSearch;
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+ private RefreshLayout mRefreshLayout;
|
|
|
+ private List<FuzzyBean> fuzzyBeans;
|
|
|
+ private FuzzySearchAdapter fuzzyAdapter;
|
|
|
+ private Button startBtn;
|
|
|
+ private LinearLayout startLlS;
|
|
|
+ private TextView gongdanhaoTv;
|
|
|
+ private TextView gongdanshuTv;
|
|
|
+ private TextView yibaogongTv;
|
|
|
+ private TextView changpingTv;
|
|
|
+ private TextView mingchenTv;
|
|
|
+ private TextView guigeTv;
|
|
|
+ private JSONObject detailOne;
|
|
|
+ private String sc_code;
|
|
|
+ private int mFocusId;
|
|
|
+ private static final int SCAN_BARCODE_CODE = 201;
|
|
|
+ private String ifneedmj;
|
|
|
+ private AutoCompleteTextView ce_moju;
|
|
|
+ private TextView tv_mju;
|
|
|
+ private LinearLayout line_mju;
|
|
|
+ private boolean chentrueorflase = true;
|
|
|
+ private ArrayList<AddworkorderBean> mFilterStorageInBeans;
|
|
|
+ private RecyclerView recyclerView;
|
|
|
+ private MyArrayAdapter autoStringAdapter;
|
|
|
+ private ImageView clean_iv;
|
|
|
+ private ImageView sear_iv;
|
|
|
+ private MyArrayAdapter searStringAdapter;
|
|
|
+ private String boolea;
|
|
|
+ private TextView tv_actionbar_withback;
|
|
|
+ private Button btn_actionbar_withback;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setContentView(R.layout.activity_work_order_search);
|
|
|
+ initStartView();
|
|
|
+ mSearch = findViewById(R.id.fl_search_actext);
|
|
|
+ tv_actionbar_withback = findViewById(R.id.tv_actionbar_withback);
|
|
|
+ btn_actionbar_withback = findViewById(R.id.btn_actionbar_withback);
|
|
|
+ mRefreshLayout = findViewById(R.id.SmartRefreshLayout_id);
|
|
|
+ ce_moju = findViewById(R.id.ce_moju);
|
|
|
+ tv_mju = findViewById(R.id.tv_mju);
|
|
|
+ line_mju = findViewById(R.id.line_mju);
|
|
|
+ clean_iv = findViewById(R.id.clean_iv);
|
|
|
+ sear_iv = findViewById(R.id.sear_iv);
|
|
|
+
|
|
|
+ fuzzyBeans = new ArrayList<>();
|
|
|
+ fuzzyAdapter = new FuzzySearchAdapter(fuzzyBeans);
|
|
|
+ fuzzyAdapter.setmList(fuzzyBeans);
|
|
|
+
|
|
|
+ recyclerView = findViewById(R.id.id_item_remove_recyclerview);
|
|
|
+ tv_actionbar_withback.setText("工单绑定");
|
|
|
+
|
|
|
+ mRefreshLayout.setEnableRefresh(false);
|
|
|
+ mRefreshLayout.setEnableLoadMore(false);
|
|
|
+ Intent intent = getIntent();
|
|
|
+ if(intent!=null){
|
|
|
+ sc_code = intent.getStringExtra(Constants.FLAG.SC_CODE);
|
|
|
+ }
|
|
|
+ btn_actionbar_withback.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ clean_iv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ ce_moju.setText("");
|
|
|
+ ce_moju.requestFocus();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ sear_iv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ mSearch.setText("");
|
|
|
+ mSearch.requestFocus();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
|
|
+ @Override
|
|
|
+ public void onRefresh(RefreshLayout refreshLayout) {
|
|
|
+ mRefreshLayout.finishRefresh();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onFocusChange(View v, boolean hasFocus) {
|
|
|
+ if (hasFocus) {
|
|
|
+ // 输入框获取到焦点时的处理逻辑
|
|
|
+ fuzzySearchMa(mSearch.getText().toString().trim());
|
|
|
+ } else {
|
|
|
+ // 输入框失去焦点时的处理逻辑
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mSearch.addTextChangedListener(searchNoTextWatcher);
|
|
|
+
|
|
|
+ mSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ String code = mSearch.getText().toString().trim();
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED && !StringUtil.isEmpty(code)){
|
|
|
+ getLastBean(code);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mSearch.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ getLastBean(mSearch.getText().toString().trim());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //----------模具模糊搜索------------------------
|
|
|
+ ce_moju.addTextChangedListener(inOutNoTextWatcher);
|
|
|
+
|
|
|
+ ce_moju.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ mSearch.requestFocus();
|
|
|
+ mSearch.setSelection(mSearch.getText().length());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ fuzzyAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ FuzzyBean bean = fuzzyAdapter.getBeanByPositon(position);
|
|
|
+ String macode = bean.getMA_CODE();
|
|
|
+ if (macode.length() > 0){
|
|
|
+ getLastBean(macode);
|
|
|
+ mSearch.setText("");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ mFilterStorageInBeans = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //启动按钮启动事件
|
|
|
+ startBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (mFilterStorageInBeans==null||mFilterStorageInBeans.size()==0){
|
|
|
+ CommonUtil.toastNoRepeat(WorkOrderSearchActivity.this, "请采集工单号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ StringBuilder stringtext = new StringBuilder();
|
|
|
+ for (int i=0;i<mFilterStorageInBeans.size();i++) {
|
|
|
+ stringtext.append(mFilterStorageInBeans.get(i).getLOTNO()).append(",");
|
|
|
+ }
|
|
|
+ Intent resultIntent = new Intent();
|
|
|
+ resultIntent.putExtra("ITEM_DATA",stringtext.toString());
|
|
|
+ setResult(1847,resultIntent);
|
|
|
+ finish();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ifneedmj = SharedPreUtil.getString(this, Constants.FLAG.GANG_WEI_SOURCE_ifneedmj, null);
|
|
|
+ mSearch.setThreshold(0);
|
|
|
+ if (!StringUtil.isEmpty(ifneedmj)){
|
|
|
+ if (!ifneedmj.equals("0")){
|
|
|
+ line_mju.setVisibility(View.VISIBLE);
|
|
|
+ tv_mju.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ ce_moju.requestFocus();
|
|
|
+ ce_moju.setThreshold(0);
|
|
|
+ }else {
|
|
|
+ line_mju.setVisibility(View.GONE);
|
|
|
+ tv_mju.setTextColor(getResources().getColor(R.color.blue));
|
|
|
+ mSearch.requestFocus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ private void initStartView() {
|
|
|
+ startBtn = findViewById(R.id.start_btn);
|
|
|
+ startLlS = findViewById(R.id.start_ll);
|
|
|
+ gongdanhaoTv = findViewById(R.id.gongdanhao_tv);
|
|
|
+ gongdanshuTv = findViewById(R.id.gongdanshu_tv);
|
|
|
+ yibaogongTv = findViewById(R.id.yibaogong_tv);
|
|
|
+ changpingTv = findViewById(R.id.changping_tv);
|
|
|
+ mingchenTv = findViewById(R.id.mingchen_tv);
|
|
|
+ guigeTv = findViewById(R.id.guige_tv);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //工单细查询
|
|
|
+ private void getLastBean(String clickCode) {
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_PDA_GETMACODE)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "getMaCode")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("code", clickCode)
|
|
|
+ .addParam("sc_code",sc_code)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (isSuccess){
|
|
|
+ JSONObject dataObject = FastjsonUtil.getJSONObject(o.toString(),"data");
|
|
|
+// JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(),"data");
|
|
|
+ showDetailOneOrder(dataObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(WorkOrderSearchActivity.this, failStr);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showDetailOneOrder(JSONObject dataObject) {
|
|
|
+ if (dataObject == null){
|
|
|
+ CommonUtil.toastNoRepeat(this,"暂无工单详细信息");
|
|
|
+ startLlS.setVisibility(View.GONE);
|
|
|
+ return;
|
|
|
+ }else {
|
|
|
+// startLlS.setVisibility(View.VISIBLE);
|
|
|
+ fuzzyBeans.clear();
|
|
|
+ detailOne = dataObject;
|
|
|
+ if (StringUtil.isEmpty(detailOne.getString("MA_CODE"))){
|
|
|
+ CommonUtil.toastNoRepeat(this,"暂无工单详细信息");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ gongdanhaoTv.setText(dataObject.getString("MA_CODE") == null ? "-" :dataObject.getString("MA_CODE"));
|
|
|
+ gongdanshuTv.setText(dataObject.getInteger("MA_QTY") == null ? "-":dataObject.getInteger("MA_QTY")+"");
|
|
|
+// yibaogongTv.setText(dataObject.getInteger("MA_REPORTYQTY") == null ? "-": dataObject.getInteger("MA_REPORTYQTY")+"");
|
|
|
+ yibaogongTv.setText(dataObject.getInteger("MA_MADEQTY") == null ? "-": dataObject.getInteger("MA_MADEQTY")+"");
|
|
|
+
|
|
|
+ changpingTv.setText(dataObject.getString("MA_PRODCODE") == null ? "-" :dataObject.getString("MA_PRODCODE"));
|
|
|
+ mingchenTv.setText(dataObject.getString("PR_DETAIL") == null ? "-" : dataObject.getString("PR_DETAIL"));
|
|
|
+ guigeTv.setText(dataObject.getString("PR_SPEC") == null ? "-" :dataObject.getString("PR_SPEC")+"");
|
|
|
+
|
|
|
+ for (int i=0;i<mFilterStorageInBeans.size();i++){
|
|
|
+ if (mFilterStorageInBeans.get(i).getLOTNO().equals(detailOne.getString("MA_CODE"))){
|
|
|
+ CommonUtil.toastNoRepeat(this, "工单重复");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ AddworkorderBean jltStorageInBean = new AddworkorderBean();
|
|
|
+ jltStorageInBean.setLOTNO(detailOne.getString("MA_CODE"));
|
|
|
+ jltStorageInBean.setQTY(detailOne.getString("MA_QTY"));
|
|
|
+ jltStorageInBean.setMA_PRODCODE(dataObject.getString("MA_PRODCODE"));
|
|
|
+ jltStorageInBean.setPR_DETAIL(dataObject.getString("PR_DETAIL"));
|
|
|
+ jltStorageInBean.setPR_SPEC(dataObject.getString("PR_SPEC"));
|
|
|
+ jltStorageInBean.setMA_KIND(dataObject.getString("MA_KIND"));
|
|
|
+ mFilterStorageInBeans.add(jltStorageInBean);
|
|
|
+ MyaddAdapter addadapter = new MyaddAdapter(this, mFilterStorageInBeans);
|
|
|
+ recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
|
|
+ recyclerView.setAdapter(addadapter);
|
|
|
+ mSearch.requestFocus();
|
|
|
+ mSearch.setText("");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+
|
|
|
+ }
|
|
|
+ private TextWatcher inOutNoTextWatcher = new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
|
|
+ //当字数超过3个,自动弹出输入提示框
|
|
|
+ if (charSequence.length() >= 1) {
|
|
|
+ LogUtil.i("mSearchStr",ce_moju.getText().toString().trim());
|
|
|
+ fuzzySearchMould(ce_moju.getText().toString().trim());
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable editable) {
|
|
|
+ if (editable.length() == 0) {
|
|
|
+ clean_iv.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ clean_iv.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ public static String removeTrailingDash(String str) {
|
|
|
+ return str.replaceFirst("\n[^\n]*$", "");
|
|
|
+ }
|
|
|
+
|
|
|
+ private TextWatcher searchNoTextWatcher = new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
|
|
+// 当字数超过3个,自动弹出输入提示框
|
|
|
+// if (charSequence.length() >= 3) {
|
|
|
+ if (mSearch.getText().toString().trim().contains("\n")){
|
|
|
+ String s = removeTrailingDash(mSearch.getText().toString().trim());
|
|
|
+ mSearch.setText(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ LogUtil.i("mSearchStr",mSearch.getText().toString().trim());
|
|
|
+
|
|
|
+ fuzzySearchMa(mSearch.getText().toString().trim());
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable editable) {
|
|
|
+ if (editable.length() == 0) {
|
|
|
+ sear_iv.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ sear_iv.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ //模糊查询工单号
|
|
|
+ private void fuzzySearchMa(String code){
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_PDA_FUZZYSEARCHMA)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "fuzzySearchMa")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("ma_code", code)
|
|
|
+ .addParam("sc_code", sc_code)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
|
|
|
+ if (isSuccess){
|
|
|
+ JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(),"data");
|
|
|
+ if (dataArray == null || dataArray.size() == 0){
|
|
|
+ CommonUtil.toastNoRepeat(WorkOrderSearchActivity.this,"未搜索到匹配数据");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> autoStrings = new ArrayList<>();
|
|
|
+ autoStrings.clear();
|
|
|
+ searStringAdapter = new MyArrayAdapter<String>(WorkOrderSearchActivity.this, R.layout.myarry_item, autoStrings);
|
|
|
+ if (mSearch != null) {
|
|
|
+ mSearch.setAdapter(searStringAdapter);
|
|
|
+ }
|
|
|
+ for (Object index : dataArray){
|
|
|
+ JSONObject data = (JSONObject) index;
|
|
|
+// String newString = data.getString("MA_CODE").replaceFirst("^-*", "");
|
|
|
+ searStringAdapter.add(data.getString("MA_CODE")+"\n"+data.getString("PR_DETAIL")+"\n"+data.getString("MA_KIND"));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(WorkOrderSearchActivity.this, failStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ //查询模具
|
|
|
+ private void fuzzySearchMould(String code){
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_FUZZYSEARCHMOULD)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "fuzzySearchMa")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("mouldcode", code)
|
|
|
+ .addParam("sc_code", sc_code)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
|
|
|
+ if (isSuccess){
|
|
|
+ JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(),"data");
|
|
|
+ if (dataArray == null || dataArray.size() == 0){
|
|
|
+ CommonUtil.toastNoRepeat(WorkOrderSearchActivity.this,"未搜索到匹配数据");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> autoStrings = new ArrayList<>();
|
|
|
+ autoStrings.clear();
|
|
|
+ autoStringAdapter = new MyArrayAdapter<String>(WorkOrderSearchActivity.this, android.R.layout.simple_dropdown_item_1line, autoStrings);
|
|
|
+
|
|
|
+ if (ce_moju != null) {
|
|
|
+ ce_moju.setAdapter(autoStringAdapter);
|
|
|
+ }
|
|
|
+ for (Object index : dataArray){
|
|
|
+
|
|
|
+ JSONObject data = (JSONObject) index;
|
|
|
+// bean = new FuzzyBean(,data.getString("DE_NAME"));
|
|
|
+ autoStringAdapter.add(data.getString("DE_CODE"));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(WorkOrderSearchActivity.this, failStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private class FuzzySearchAdapter extends BaseQuickAdapter<FuzzyBean, BaseViewHolder>{
|
|
|
+ private List<FuzzyBean> mList;
|
|
|
+
|
|
|
+ public List<FuzzyBean> getmList() {
|
|
|
+ return mList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setmList(List<FuzzyBean> mList) {
|
|
|
+ this.mList = mList;
|
|
|
+ }
|
|
|
+ public FuzzyBean getBeanByPositon(int position){
|
|
|
+ return mList.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ private FuzzySearchAdapter(@Nullable List<FuzzyBean> data) {
|
|
|
+ super(R.layout.fuzzy_search_item, data);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ protected void convert(BaseViewHolder helper, FuzzyBean item) {
|
|
|
+ if (StringUtil.isEmpty(item.getDE_NAME())){
|
|
|
+ helper.setText(R.id.macode_Tv,item.getMA_CODE());
|
|
|
+ }else {
|
|
|
+ helper.setText(R.id.macode_Tv,item.getMA_CODE()+"-"+item.getDE_NAME());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private class FuzzyBean{
|
|
|
+ String MA_CODE = null;
|
|
|
+ String DE_NAME = null;
|
|
|
+
|
|
|
+ public FuzzyBean(String MA_CODE) {
|
|
|
+ this.MA_CODE = MA_CODE;
|
|
|
+ }
|
|
|
+
|
|
|
+ public FuzzyBean(String MA_CODE, String DE_NAME) {
|
|
|
+ this.MA_CODE = MA_CODE;
|
|
|
+ this.DE_NAME = DE_NAME;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getDE_NAME() {
|
|
|
+ return DE_NAME;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getMA_CODE() {
|
|
|
+ return MA_CODE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ if (resultCode != Activity.RESULT_OK) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (requestCode == SCAN_BARCODE_CODE && data != null) {
|
|
|
+ if (data.getExtras() != null) {
|
|
|
+ String result = data.getExtras().getString(CodeUtils.RESULT_STRING);
|
|
|
+ if (mFocusId == R.id.fl_search_actext) {
|
|
|
+ mSearch.setText(result);
|
|
|
+ mSearch.setSelection(result.length());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onPointerCaptureChanged(boolean hasCapture) {
|
|
|
+
|
|
|
+ }
|
|
|
+}
|