|
|
@@ -0,0 +1,687 @@
|
|
|
+package com.uas.hystorage.activity;
|
|
|
+
|
|
|
+import android.content.Intent;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
+import android.support.v7.widget.DividerItemDecoration;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.Gravity;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.Window;
|
|
|
+import android.view.inputmethod.EditorInfo;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.FrameLayout;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.PopupWindow;
|
|
|
+import android.widget.RadioGroup;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+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.google.gson.Gson;
|
|
|
+import com.uas.hystorage.R;
|
|
|
+import com.uas.hystorage.bean.InspectionPaintBean;
|
|
|
+import com.uas.hystorage.fragment.BlueToothPrintFragment;
|
|
|
+import com.uas.hystorage.fragment.HePiFragment;
|
|
|
+import com.uas.hystorage.global.GloableParams;
|
|
|
+import com.uas.hystorage.listener.MyEditorActionListener;
|
|
|
+import com.uas.hystorage.tools.SharedPreUtil;
|
|
|
+import com.uas.hystorage.util.CommonUtil;
|
|
|
+import com.uas.hystorage.util.Constants;
|
|
|
+import com.uas.hystorage.util.FastjsonUtil;
|
|
|
+import com.uas.hystorage.util.FragmentUtils;
|
|
|
+import com.uas.hystorage.util.HttpCallback;
|
|
|
+import com.uas.hystorage.util.HttpParams;
|
|
|
+import com.uas.hystorage.util.LogUtil;
|
|
|
+import com.uas.hystorage.util.PrintUtils;
|
|
|
+import com.uas.hystorage.util.StringUtil;
|
|
|
+import com.uas.hystorage.util.VolleyRequest;
|
|
|
+import com.uas.hystorage.util.VollyRequest;
|
|
|
+import com.uas.hystorage.view.ClearableEditText;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import razerdp.basepopup.BasePopupWindow;
|
|
|
+
|
|
|
+public class InspectionSendSamplesAct extends BaseActivity {
|
|
|
+
|
|
|
+ protected String TAG = getClass().getName();
|
|
|
+ private Button bt_return;
|
|
|
+ private TextView tv_title, tv_gangweiname;
|
|
|
+ private ImageView iv_icon, iv_search;
|
|
|
+ private RadioGroup rg_jianyanleixin;
|
|
|
+ private ClearableEditText cet_gangweiziyuan;
|
|
|
+ private TextView cet_jitai, cet_gondanhao, cet_xiangmuhao;
|
|
|
+ private TextView tv_isok, tv_details;
|
|
|
+ private Button bt_dayinbiaoqian;
|
|
|
+ private LinearLayout ll_inspection;
|
|
|
+ private FrameLayout fl_dayin;
|
|
|
+
|
|
|
+ private String rb_changetext = "首件";
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+ private ClearableEditText edit_et;
|
|
|
+ private RecyclerView rv_line_ip_port_data;
|
|
|
+ private PopupWindow editPW;
|
|
|
+ private IpAndResourcesPortAdapter ipAndResourcesPortAdapter;
|
|
|
+ private ArrayList<ComDataBean> ComDataBeanList;
|
|
|
+ private String sc_name;
|
|
|
+ private String sc_code;
|
|
|
+ private boolean isPrinting = false;
|
|
|
+ private boolean isConnected = false;
|
|
|
+ private int mPrintDpi = 203;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ setContentView(R.layout.act_inspection_send_samples);
|
|
|
+ bt_return = findViewById(R.id.bt_return);
|
|
|
+ tv_title = findViewById(R.id.tv_title);
|
|
|
+ iv_icon = findViewById(R.id.iv_icon);
|
|
|
+
|
|
|
+ ll_inspection = findViewById(R.id.ll_inspection);
|
|
|
+ fl_dayin = findViewById(R.id.fl_dayin);
|
|
|
+
|
|
|
+ rg_jianyanleixin = findViewById(R.id.rg_jianyanleixin);
|
|
|
+ cet_gangweiziyuan = findViewById(R.id.cet_gangweiziyuan);
|
|
|
+ iv_search = findViewById(R.id.iv_search);
|
|
|
+ tv_gangweiname = findViewById(R.id.tv_gangweiname);
|
|
|
+
|
|
|
+ cet_jitai = findViewById(R.id.cet_jitai);
|
|
|
+ cet_gondanhao = findViewById(R.id.cet_gondanhao);
|
|
|
+ cet_xiangmuhao = findViewById(R.id.cet_xiangmuhao);
|
|
|
+
|
|
|
+ bt_dayinbiaoqian = findViewById(R.id.bt_dayinbiaoqian);
|
|
|
+ tv_isok = findViewById(R.id.tv_isok);
|
|
|
+ tv_details = findViewById(R.id.tv_details);
|
|
|
+
|
|
|
+ ComDataBeanList = new ArrayList<>();
|
|
|
+ isConnected = (SharedPreUtil.getInt(InspectionSendSamplesAct.this, "printConnect", 0) == 1);
|
|
|
+ mPrintDpi = SharedPreUtil.getInt(InspectionSendSamplesAct.this, "printDpi", 203);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ bt_return.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ iv_icon.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ //送样清单列表
|
|
|
+ startActivity(new Intent(InspectionSendSamplesAct.this,SampleDeliveryListAct.class));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ rg_jianyanleixin.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
|
|
|
+ switch (checkedId) {
|
|
|
+ case R.id.rb_shoujian:
|
|
|
+ rb_changetext = "首件";
|
|
|
+ break;
|
|
|
+ case R.id.rb_xunjian:
|
|
|
+ rb_changetext = "巡检";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ CommonUtil.setEditorActionListener(cet_gangweiziyuan, new MyEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public void MyEditorAction(String text, int actionId, KeyEvent event) {
|
|
|
+ getSourcePunchInfo(text);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ iv_search.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ getRepairStep();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ bt_dayinbiaoqian.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ getPrintLabel();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 打印标签按钮
|
|
|
+ * */
|
|
|
+ private void getPrintLabel() {
|
|
|
+ //String data --json 串
|
|
|
+ //{sr_sccode:岗位资源编号,sr_devcode:机台号,sr_makecode:工单号,sr_itemcode:项目号,sr_sendtype:送样类型(首件或者巡检)}
|
|
|
+ //测试数据:
|
|
|
+ //{"sr_sccode":"ZX0000-104","sr_devcode":"DEV001","sr_makecode":"5106-24090610269-5","sr_itemcode":"2323342","sr_sendtype":"首件"}
|
|
|
+ if (TextUtils.isEmpty(cet_gangweiziyuan.getText().toString().trim())) {
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, "岗位资源不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (TextUtils.isEmpty(cet_jitai.getText().toString().trim())) {
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, "机台号不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (TextUtils.isEmpty(cet_gondanhao.getText().toString().trim())) {
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, "工单号不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (TextUtils.isEmpty(cet_xiangmuhao.getText().toString().trim())) {
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, "项目号不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("sr_sccode",cet_gangweiziyuan.getText().toString().trim());
|
|
|
+ params.put("sr_devcode",cet_jitai.getText().toString().trim());
|
|
|
+ params.put("sr_makecode",cet_gondanhao.getText().toString().trim());
|
|
|
+ params.put("sr_itemcode",cet_xiangmuhao.getText().toString().trim());
|
|
|
+ params.put("sr_sendtype",rb_changetext);
|
|
|
+ String data = JSON.toJSONString(params);
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_SAVESAMPLEREPORT)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("data",data)
|
|
|
+ .tag("getMaCode")
|
|
|
+ .flag(0)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try{
|
|
|
+ InspectionPaintBean inspectionPaintBean = new Gson().fromJson(o.toString(), InspectionPaintBean.class);
|
|
|
+ if (inspectionPaintBean != null && inspectionPaintBean.isSuccess()) {
|
|
|
+ InspectionPaintBean.DataBean data1 = inspectionPaintBean.getData().get(0);
|
|
|
+ tv_isok.setTextColor(getResources().getColor(R.color.blue));
|
|
|
+ tv_isok.setText("生成送样单成功");
|
|
|
+ tv_details.setText("单号: " + data1.getSR_CODE() + "\n" +
|
|
|
+ "检验类型: " + data1.getSR_SENDTYPE() + "\n" +
|
|
|
+ "岗位资源: " + data1.getSR_SCCODE() + "(" + data1.getSR_SCNAME() + ")" + "\n" +
|
|
|
+ "机台: " + data1.getSR_DEVCODE() + "\n" +
|
|
|
+ "工单号: " + data1.getSR_MAKECODE() + "\n" +
|
|
|
+ "项目号: " + data1.getSR_ITEMCODE()
|
|
|
+ );
|
|
|
+ //调用打印接口
|
|
|
+ JSONObject resultObject = JSON.parseObject(o.toString());
|
|
|
+ JSONArray savedataArrays = resultObject.getJSONArray("data");
|
|
|
+ if (savedataArrays != null && savedataArrays.size() > 0) {
|
|
|
+ getPrintTemplate(savedataArrays);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ tv_isok.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ tv_isok.setText(failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 打印
|
|
|
+ * */
|
|
|
+ private void getPrintTemplate(JSONArray savedataArrays) {
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_BARINFO_PRINTMODEL)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .flag(0)
|
|
|
+ .tag("barinfoPrint")
|
|
|
+ .addParam("caller", "SampleReportBarPrint")//Barcode!PDAPrint仓库
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ Log.e("aaa", "打印接口数据" + result);
|
|
|
+ if (FastjsonUtil.validate(result)) {
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONArray dataArray = resultObject.getJSONArray("data");
|
|
|
+ if (dataArray != null && dataArray.size() > 0) {
|
|
|
+ SharedPreUtil.saveString(InspectionSendSamplesAct.this, Constants.FLAG.PRINT_TEMPLATE_CACHE, dataArray.toJSONString());
|
|
|
+ }
|
|
|
+ //打印时传递保存的数据,非打印模板的数据
|
|
|
+ printEvent(savedataArrays);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 搜索
|
|
|
+ * */
|
|
|
+ private void getRepairStep() {
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_PAD_GETSOURCEBYEMP)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag("getMaCode")
|
|
|
+ .flag(0)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
|
|
|
+ JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(), "data");
|
|
|
+ if (isSuccess){
|
|
|
+ if (dataArray == null){
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this,"未搜索到匹配数据");
|
|
|
+ }else {
|
|
|
+ handleFeededlineData(dataArray);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ tv_isok.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ tv_isok.setText(failStr);
|
|
|
+ //CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void printEvent(com.alibaba.fastjson.JSONArray printArray) {
|
|
|
+ if (isPrinting) {
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, "正在打印中,请勿重复操作");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ isPrinting = true;
|
|
|
+ if (printArray != null && printArray.size() > 0) {
|
|
|
+ boolean isFail = false;
|
|
|
+ for (int i = 0; i < printArray.size(); i++) {
|
|
|
+ try {
|
|
|
+ JSONObject printObject = printArray.getJSONObject(i);
|
|
|
+ int printResult = PrintUtils.printBar(InspectionSendSamplesAct.this, printObject.toString(), mPrintDpi, null);
|
|
|
+ if (printResult <= 0) {
|
|
|
+ isFail = true;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (isFail) {
|
|
|
+ isConnected = false;
|
|
|
+ SharedPreUtil.saveInt(InspectionSendSamplesAct.this, "printConnect", 0);
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, "打印失败,请重新连接打印机");
|
|
|
+
|
|
|
+ Intent intent = new Intent(InspectionSendSamplesAct.this, BlueToothPrintAct.class);
|
|
|
+ intent.putExtra(Constants.KEY.BARCODE_PRINT_ARRAY, printArray.toString());
|
|
|
+ startActivity(intent);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, "打印成功");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, "打印失败,条码数据为空");
|
|
|
+ }
|
|
|
+ isPrinting = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ tv_title.setText("检验送样");
|
|
|
+ iv_icon.setBackground(getResources().getDrawable(R.drawable.ic_jump_smt_query));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleFeededlineData(JSONArray dataArray) {
|
|
|
+ ComDataBean bean;
|
|
|
+ ComDataBeanList.clear();
|
|
|
+ for (Object index : dataArray) {
|
|
|
+ JSONObject data = (JSONObject) index;
|
|
|
+ bean= new ComDataBean();
|
|
|
+ bean.setItemName(data.getString("SC_NAME"));
|
|
|
+ bean.setItemremark(data.getString("SC_CODE"));
|
|
|
+ ComDataBeanList.add(bean);
|
|
|
+ }
|
|
|
+ initresourcesPopupWindow();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initresourcesPopupWindow() {
|
|
|
+ View contView = LayoutInflater.from(InspectionSendSamplesAct.this).inflate(R.layout.index_recycle_item, null);
|
|
|
+ edit_et = (ClearableEditText) contView.findViewById(R.id.edit_et);
|
|
|
+ TextView sure_tv = (TextView) contView.findViewById(R.id.sure_tv);
|
|
|
+ TextView cancle_tv = (TextView) contView.findViewById(R.id.cancle_tv);
|
|
|
+ ImageView search_im = contView.findViewById(R.id.search_im);
|
|
|
+ LinearLayout line_top = contView.findViewById(R.id.line_top);
|
|
|
+ rv_line_ip_port_data = contView.findViewById(R.id.rv_ip_port_data);
|
|
|
+ rv_line_ip_port_data.addItemDecoration(new DividerItemDecoration(InspectionSendSamplesAct.this, LinearLayout.VERTICAL));
|
|
|
+ rv_line_ip_port_data.setLayoutManager(new LinearLayoutManager(InspectionSendSamplesAct.this));
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(ComDataBeanList);
|
|
|
+ ipAndResourcesPortAdapter.setmList(ComDataBeanList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ setlineAdapter(ComDataBeanList);
|
|
|
+ // edit_et.setText(ct_qty.getText().toString().trim());
|
|
|
+
|
|
|
+ edit_et.requestFocus();
|
|
|
+ editPW = new PopupWindow(contView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ editPW.setTouchable(true);
|
|
|
+ editPW.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ editPW.setOnDismissListener(new BasePopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ View parentView = InspectionSendSamplesAct.this.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
|
|
|
+ editPW.showAtLocation(parentView, Gravity.CENTER, 0, 0);
|
|
|
+ CommonUtil.setBackgroundAlpha(InspectionSendSamplesAct.this, 0.5f);
|
|
|
+ edit_et.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_DONE
|
|
|
+ || actionId == EditorInfo.IME_ACTION_SEND
|
|
|
+ || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
+ String mSearchStr = edit_et.getText().toString().trim();
|
|
|
+ if (!mSearchStr.isEmpty()) {
|
|
|
+ List<ComDataBean> thisList = new ArrayList<>();
|
|
|
+ for(int i=0;i<ComDataBeanList.size();i++){
|
|
|
+ if(ComDataBeanList.get(i).getItemremark().contains(mSearchStr)||ComDataBeanList.get(i).getItemName().contains(mSearchStr)){
|
|
|
+ thisList.add(ComDataBeanList.get(i));
|
|
|
+ }
|
|
|
+ if(i == ComDataBeanList.size() -1){
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(thisList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ LogUtil.i("mSearchStr", JSON.toJSONString(thisList));
|
|
|
+
|
|
|
+ }
|
|
|
+ List<ComDataBean> lineCodeEntities = ipAndResourcesPortAdapter.getmList();
|
|
|
+ for (int j = 0; j < lineCodeEntities.size(); j++) {
|
|
|
+ lineCodeEntities.get(j).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(ComDataBeanList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ List<ComDataBean> lineCodeEntities = ipAndResourcesPortAdapter.getmList();
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ lineCodeEntities.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ List<ComDataBean> ipAndPortBeans = ipAndResourcesPortAdapter.getmList();
|
|
|
+ sc_name = ipAndPortBeans.get(position).getItemName();
|
|
|
+ sc_code = ipAndPortBeans.get(position).getItemremark();
|
|
|
+ for (int i = 0; i < ipAndPortBeans.size(); i++) {
|
|
|
+ ipAndPortBeans.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndPortBeans.get(position).setChecked(true);
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ search_im.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ String mSearchStr = edit_et.getText().toString().trim();
|
|
|
+ if (!mSearchStr.isEmpty()) {
|
|
|
+ List<ComDataBean> thisList = new ArrayList<>();
|
|
|
+ for(int i=0;i<ComDataBeanList.size();i++){
|
|
|
+ if(ComDataBeanList.get(i).getItemremark().contains(mSearchStr)||ComDataBeanList.get(i).getItemName().contains(mSearchStr)){
|
|
|
+ thisList.add(ComDataBeanList.get(i));
|
|
|
+ }
|
|
|
+ if(i == ComDataBeanList.size() -1){
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(thisList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ LogUtil.i("mSearchStr", JSON.toJSONString(thisList));
|
|
|
+
|
|
|
+ }
|
|
|
+ List<ComDataBean> lineCodeEntities = ipAndResourcesPortAdapter.getmList();
|
|
|
+ for (int j = 0; j < lineCodeEntities.size(); j++) {
|
|
|
+ lineCodeEntities.get(j).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(ComDataBeanList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ List<ComDataBean> lineCodeEntities = ipAndResourcesPortAdapter.getmList();
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ lineCodeEntities.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ List<ComDataBean> ipAndPortBeans = ipAndResourcesPortAdapter.getmList();
|
|
|
+ sc_name = ipAndPortBeans.get(position).getItemName();
|
|
|
+ sc_code = ipAndPortBeans.get(position).getItemremark();
|
|
|
+ for (int i = 0; i < ipAndPortBeans.size(); i++) {
|
|
|
+ ipAndPortBeans.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndPortBeans.get(position).setChecked(true);
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ List<String> list=new ArrayList<>();
|
|
|
+ //确定
|
|
|
+ sure_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ list.clear();
|
|
|
+
|
|
|
+ if (StringUtil.isEmpty(sc_code)){
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this,"请选择工序");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ cet_gangweiziyuan.setText(sc_code);
|
|
|
+ cet_gangweiziyuan.requestFocus();
|
|
|
+ cet_gangweiziyuan.setSelection(cet_gangweiziyuan.getText().length());
|
|
|
+ getSourcePunchInfo(cet_gangweiziyuan.getText().toString().trim());
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //取消
|
|
|
+ cancle_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ String mSearchStr = edit_et.getText().toString().trim();
|
|
|
+ if (mSearchStr.isEmpty()) {
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(ComDataBeanList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ List<ComDataBean> lineCodeEntities = ipAndResourcesPortAdapter.getmList();
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ lineCodeEntities.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ ipAndResourcesPortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ List<ComDataBean> ipAndPortBeans = ipAndResourcesPortAdapter.getmList();
|
|
|
+ sc_name = ipAndPortBeans.get(position).getItemName();
|
|
|
+ sc_code = ipAndPortBeans.get(position).getItemremark();
|
|
|
+ for (int i = 0; i < ipAndPortBeans.size(); i++) {
|
|
|
+ ipAndPortBeans.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndPortBeans.get(position).setChecked(true);
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 岗位资源enter事件
|
|
|
+ */
|
|
|
+ private void getSourcePunchInfo(String sccode) {
|
|
|
+ if (sccode.isEmpty()){
|
|
|
+ CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, "请输入岗位编号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_GETSOURCEDATA)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "getMaCode")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("sc_code",sccode)//岗位资源编号
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
|
|
|
+ if (isSuccess){
|
|
|
+ JSONObject dataObject = FastjsonUtil.getJSONObject(o.toString(),"data");
|
|
|
+ if (dataObject == null){
|
|
|
+
|
|
|
+ }else {
|
|
|
+ String SC_CODE = dataObject.getString("SC_CODE") == null ? "" : dataObject.getString("SC_CODE");
|
|
|
+ String SC_NAME = dataObject.getString("SC_NAME") == null ? "" : dataObject.getString("SC_NAME");
|
|
|
+ tv_gangweiname.setText(SC_NAME);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ tv_isok.setText(failStr);
|
|
|
+ tv_isok.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ cet_gangweiziyuan.requestFocus();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setlineAdapter(ArrayList<ComDataBean> mList) {
|
|
|
+ LogUtil.i("mList", JSON.toJSONString(mList));
|
|
|
+ ipAndResourcesPortAdapter = new IpAndResourcesPortAdapter(mList);
|
|
|
+ ipAndResourcesPortAdapter.setmList(ComDataBeanList);
|
|
|
+ ipAndResourcesPortAdapter.notifyDataSetChanged();
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndResourcesPortAdapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closeListPopupWindow() {
|
|
|
+ if (editPW != null) {
|
|
|
+ editPW.dismiss();
|
|
|
+ editPW = null;
|
|
|
+ CommonUtil.setBackgroundAlpha(InspectionSendSamplesAct.this, 1f);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private class IpAndResourcesPortAdapter extends BaseQuickAdapter<ComDataBean, BaseViewHolder> {
|
|
|
+ private List<ComDataBean> mmmmList;
|
|
|
+
|
|
|
+ public List<ComDataBean> getmList() {
|
|
|
+ return mmmmList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setmList(List<ComDataBean> mList) {
|
|
|
+ this.mmmmList = mList;
|
|
|
+ }
|
|
|
+ public ComDataBean getBeanByPositon(int position){
|
|
|
+ return mmmmList.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ private IpAndResourcesPortAdapter(@Nullable List<ComDataBean> data) {
|
|
|
+ super(R.layout.fuzzy_ipandport_item, data);
|
|
|
+ this.mmmmList = data;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ protected void convert(BaseViewHolder helper, ComDataBean item) {
|
|
|
+ helper.setText(R.id.macode_ip__Tv,item.getItemremark()+"-("+item.getItemName()+")");
|
|
|
+ LinearLayout line_true = helper.itemView.findViewById(R.id.line_true);
|
|
|
+ if (item.getChecked()) {
|
|
|
+ line_true.setSelected(true);
|
|
|
+ } else {
|
|
|
+ line_true.setSelected(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private class ComDataBean{
|
|
|
+ String itemName = null;
|
|
|
+ String itemremark = null;
|
|
|
+ boolean Checked;
|
|
|
+
|
|
|
+ public boolean getChecked() {
|
|
|
+ return Checked;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setChecked(boolean checked) {
|
|
|
+ Checked = checked;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getItemName() {
|
|
|
+ return itemName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setItemName(String itemName) {
|
|
|
+ this.itemName = itemName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getItemremark() {
|
|
|
+ return itemremark;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setItemremark(String itemremark) {
|
|
|
+ this.itemremark = itemremark;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|