|
|
@@ -3,6 +3,10 @@ package com.uas.gdstorage.fragment;
|
|
|
import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
|
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.Editable;
|
|
|
import android.text.TextWatcher;
|
|
|
import android.view.KeyEvent;
|
|
|
@@ -10,13 +14,17 @@ import android.view.View;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.ArrayAdapter;
|
|
|
import android.widget.Button;
|
|
|
+import android.widget.LinearLayout;
|
|
|
import android.widget.Spinner;
|
|
|
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.uas.gdstorage.R;
|
|
|
import com.uas.gdstorage.activity.CommonSeclecActivity;
|
|
|
import com.uas.gdstorage.activity.FunctionActivity;
|
|
|
@@ -37,11 +45,10 @@ import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
|
import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickListener {
|
|
|
+ private TextView tv_gangwei;
|
|
|
private TextView mOlIdTv;
|
|
|
private TextView mOlNUmbersTv;
|
|
|
private TextView mOlNameTv;
|
|
|
@@ -58,12 +65,23 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
private ArrayAdapter<String> unitAdapter;
|
|
|
private String unitSelctStr = "PCS";
|
|
|
private String lastUnit = "PCS";
|
|
|
-
|
|
|
private double unitNumber = 1000;
|
|
|
private double lastunitNumber = 1000;
|
|
|
private double lastunreportqty = 0.00;
|
|
|
-
|
|
|
-
|
|
|
+ //
|
|
|
+ private ClearableEditText mSearch;
|
|
|
+ private RecyclerView fuzzyRv;
|
|
|
+ private List<FuzzyBean> fuzzyBeans;
|
|
|
+ private FuzzySearchAdapter fuzzyAdapter;
|
|
|
+ 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 Button startBtn;
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
return R.layout.fragment_gd_work_switch;
|
|
|
@@ -72,6 +90,14 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
@Override
|
|
|
protected void initViews() {
|
|
|
((FunctionActivity) getActivity()).setTitle("工单切换");
|
|
|
+ startBtn = root.findViewById(R.id.start_btn);
|
|
|
+ startLlS = root.findViewById(R.id.start_ll);
|
|
|
+ gongdanhaoTv = root.findViewById(R.id.gongdanhao_tv);
|
|
|
+ gongdanshuTv = root.findViewById(R.id.gongdanshu_tv);
|
|
|
+ yibaogongTv = root.findViewById(R.id.yibaogong_tv);
|
|
|
+ changpingTv = root.findViewById(R.id.changping_tv);
|
|
|
+ mingchenTv = root.findViewById(R.id.mingchen_tv);
|
|
|
+ guigeTv = root.findViewById(R.id.guige_tv);
|
|
|
|
|
|
mOlIdTv = root.findViewById(R.id.ol_id_tv);
|
|
|
mOlNUmbersTv = root.findViewById(R.id.olun_numbers_tv);
|
|
|
@@ -83,13 +109,54 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
mOlNextEt = root.findViewById(R.id.ol_next_et);
|
|
|
root.findViewById(R.id.scan_code_im).setOnClickListener(this);
|
|
|
root.findViewById(R.id.ol_next_im).setOnClickListener(this);
|
|
|
+ tv_gangwei=root.findViewById(R.id.tv_gangwei);
|
|
|
String name = SharedPreUtil.getString(mActivity, Constants.FLAG.CACHE_USER_EMNAME, null);
|
|
|
mOlNameTv.setText(name);
|
|
|
+ mSearch = root.findViewById(R.id.fl_search_actext);
|
|
|
+ startLlS = root.findViewById(R.id.start_ll);
|
|
|
+ //模糊查询展示的工单号列表
|
|
|
+ fuzzyRv = root.findViewById(R.id.fuzzy_rv);
|
|
|
+ fuzzyRv.addItemDecoration(new DividerItemDecoration(mActivity, LinearLayout.VERTICAL));
|
|
|
+ fuzzyRv.setLayoutManager(new LinearLayoutManager(mActivity));
|
|
|
+ fuzzyBeans = new ArrayList<>();
|
|
|
+ fuzzyAdapter = new FuzzySearchAdapter(fuzzyBeans);
|
|
|
+ fuzzyAdapter.setmList(fuzzyBeans);
|
|
|
+ fuzzyRv.setAdapter(fuzzyAdapter);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void initEvents() {
|
|
|
initUnitView();
|
|
|
+ mSearch.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.length() >= 3) {
|
|
|
+ String mSearchStr = s.toString().trim();
|
|
|
+ LogUtil.i("mSearchStr",mSearchStr);
|
|
|
+ fuzzySearchMa(mSearchStr);
|
|
|
+ } else {
|
|
|
+ fuzzyBeans.clear();
|
|
|
+ setfuzzyAdapter(fuzzyBeans);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ 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("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
mOlExChangeBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
@@ -104,7 +171,6 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
LogUtil.i("unitSelctStr", unitSelctStr);
|
|
|
upDateUnitNumber();
|
|
|
}
|
|
|
-
|
|
|
@Override
|
|
|
public void onNothingSelected(AdapterView<?> parent) {
|
|
|
}
|
|
|
@@ -135,6 +201,119 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ //启动按钮启动事件
|
|
|
+ startBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ doExChangeClick();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //工单细查询
|
|
|
+ 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");
|
|
|
+ if (dataObject == null){
|
|
|
+ CommonUtil.toastNoRepeat(mActivity,"暂无工单详细信息");
|
|
|
+ startLlS.setVisibility(View.GONE);
|
|
|
+ fuzzyRv.setVisibility(View.VISIBLE);
|
|
|
+ return;
|
|
|
+ }else {
|
|
|
+ startLlS.setVisibility(View.VISIBLE);
|
|
|
+ fuzzyRv.setVisibility(View.GONE);
|
|
|
+ fuzzyBeans.clear();
|
|
|
+ detailOne = dataObject;
|
|
|
+ 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")+"");
|
|
|
+ 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")+"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setfuzzyAdapter(List<FuzzyBean> mList) {
|
|
|
+ fuzzyRv.setVisibility(View.VISIBLE);
|
|
|
+ LogUtil.i("mList2", JSON.toJSONString(mList));
|
|
|
+ if (fuzzyAdapter == null){
|
|
|
+ fuzzyAdapter = new FuzzySearchAdapter(mList);
|
|
|
+ fuzzyRv.setAdapter(fuzzyAdapter);
|
|
|
+ }else {
|
|
|
+ fuzzyAdapter.setmList(mList);
|
|
|
+ fuzzyAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //模糊查询
|
|
|
+ private void fuzzySearchMa(String code){
|
|
|
+ progressDialog.show();
|
|
|
+ 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)
|
|
|
+ .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(mActivity,"未搜索到匹配数据");
|
|
|
+ fuzzyBeans.clear();
|
|
|
+ setfuzzyAdapter(fuzzyBeans);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ FuzzyBean bean = null;
|
|
|
+ if (fuzzyBeans.size() > 0) fuzzyBeans.clear();
|
|
|
+ for (Object index : dataArray){
|
|
|
+ JSONObject data = (JSONObject) index;
|
|
|
+ bean = new FuzzyBean(data.getString("MA_CODE"));
|
|
|
+ fuzzyBeans.add(bean);
|
|
|
+ }
|
|
|
+ setfuzzyAdapter(fuzzyBeans);
|
|
|
+ startLlS.setVisibility(View.GONE);
|
|
|
+ fuzzyRv.setVisibility(View.VISIBLE);
|
|
|
+
|
|
|
+ }else {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void upDateUnitNumber() {
|
|
|
@@ -155,58 +334,10 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
-// if(!StringUtil.isEmpty(mOlNumbersEt.getText().toString())){
|
|
|
-// mOlNumbersEt.setText(Double.valueOf(Double.valueOf(mOlNumbersEt.getText().toString())/unitNumber)+"");
|
|
|
-// }
|
|
|
-// if(!StringUtil.isEmpty(mOlUnuseEt.getText().toString())){
|
|
|
-// mOlUnuseEt.setText(Double.valueOf(Double.valueOf(mOlUnuseEt.getText().toString())/unitNumber)+"");
|
|
|
-// }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void doExChangeClick() {
|
|
|
- Map<Object, String> exchangeData = new HashMap<>();
|
|
|
-
|
|
|
- String madeqty = mOlNumbersEt.getText().toString();
|
|
|
- String scrapqty = mOlUnuseEt.getText().toString();
|
|
|
- String remark = mOlRemarkEt.getText().toString();
|
|
|
- String nextol = mOlNextEt.getText().toString();
|
|
|
-
|
|
|
- if (madeqty.length() == 0 || madeqty == "") {
|
|
|
- CommonUtil.toastNoRepeat(mActivity, "请输入报工数");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (madeqty.equals("0.0")) madeqty = "0";
|
|
|
- if (scrapqty.length() == 0 || scrapqty == "") {
|
|
|
- scrapqty = "0";
|
|
|
-// CommonUtil.toastNoRepeat(mActivity,"请输入报废数");
|
|
|
-// return;
|
|
|
- }
|
|
|
-// if(remark.length() == 0 || remark == ""){
|
|
|
-// CommonUtil.toastNoRepeat(mActivity,"请输入备注");
|
|
|
-// return;
|
|
|
-// }
|
|
|
- if (nextol.length() == 0 || nextol == "") {
|
|
|
- CommonUtil.toastNoRepeat(mActivity, "请输入下一工单");
|
|
|
- return;
|
|
|
- }
|
|
|
-/*
|
|
|
- Double thisNumber = (Double.valueOf(scrapqty) + Double.valueOf(madeqty))*unitNumber;
|
|
|
- Double lastUnNumber = lastunreportqty*lastunitNumber;
|
|
|
- if (thisNumber> lastUnNumber){
|
|
|
- CommonUtil.toastNoRepeat(mActivity,"报工数与报废数之和不可以大于上一工序报工数");
|
|
|
- return;
|
|
|
- }*/
|
|
|
- exchangeData.put("madeqty", madeqty);
|
|
|
- exchangeData.put("scrapqty", scrapqty);
|
|
|
- exchangeData.put("remark", remark);
|
|
|
- exchangeData.put("unit", unitSelctStr);
|
|
|
-// exchangeData.put("next_macode",nextol);
|
|
|
-
|
|
|
progressDialog.show();
|
|
|
-
|
|
|
-// next_macode = SharedPreUtil.getString(mActivity,"MA_CODE",null).equals("BZMB20181227007") ? "BZMB20181225001" : "BZMB20181227007";
|
|
|
-
|
|
|
VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
new HttpParams.Builder()
|
|
|
.url(GloableParams.ADDRESS_PDA_CHANGEMA)
|
|
|
@@ -215,32 +346,25 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
.flag(0)
|
|
|
.addParam("ma_code", mOlIdTv.getText().toString())
|
|
|
.addParam("sc_code", sc_code)
|
|
|
- .addParam("next_macode", nextol)
|
|
|
- .addParam("data", JSON.toJSONString(exchangeData))
|
|
|
+ .addParam("next_macode", gongdanhaoTv.getText().toString())
|
|
|
.build(), new HttpCallback() {
|
|
|
@Override
|
|
|
public void onSuccess(int flag, Object o) throws Exception {
|
|
|
Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
|
|
|
if (isSuccess) {
|
|
|
-// SharedPreUtil.saveString(mActivity,"MA_CODE",next_macode);
|
|
|
-// SharedPreUtil.saveString(mActivity,Constants.FLAG.REPORT_UNIT,unitSelctStr);
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "工单切换成功!");
|
|
|
Intent intent = new Intent(mActivity, IndexActivity.class);
|
|
|
intent.putExtra(Constants.FLAG.SC_CODE, sc_code);
|
|
|
startActivity(intent);
|
|
|
- } else {
|
|
|
-
|
|
|
}
|
|
|
progressDialog.dismiss();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onFail(int flag, String failStr) throws Exception {
|
|
|
progressDialog.dismiss();
|
|
|
CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
|
|
|
}
|
|
|
@@ -252,13 +376,13 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
sc_code = bundle.getString(Constants.FLAG.SC_CODE);
|
|
|
ma_code = bundle.getString(Constants.FLAG.MA_CODE);
|
|
|
mOlIdTv.setText(ma_code + "");
|
|
|
- getUnreportqty();
|
|
|
+ tv_gangwei.setText(sc_code);
|
|
|
+ // getUnreportqty();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void initUnitView() {
|
|
|
-// unitSelctStr = SharedPreUtil.getString(mActivity,Constants.FLAG.REPORT_UNIT,"空");
|
|
|
mUnitspinner = root.findViewById(R.id.unit_spinner);
|
|
|
unitList = new ArrayList<>();
|
|
|
unitList.add("KPCS");
|
|
|
@@ -271,7 +395,6 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
|
|
|
//获取当前线别在线工单、当前登录人员名称、工单未报工数
|
|
|
private void getUnreportqty() {
|
|
|
-
|
|
|
progressDialog.show();
|
|
|
VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
new HttpParams.Builder()
|
|
|
@@ -389,4 +512,40 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ 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) {
|
|
|
+ helper.setText(R.id.macode_Tv,item.getMA_CODE());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private class FuzzyBean{
|
|
|
+ String MA_CODE = null;
|
|
|
+
|
|
|
+ public FuzzyBean(String MA_CODE) {
|
|
|
+ this.MA_CODE = MA_CODE;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getMA_CODE() {
|
|
|
+ return MA_CODE;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|