|
|
@@ -42,6 +42,7 @@ import com.uas.pda_smart_com.R;
|
|
|
import com.uas.pda_smart_com.application.PdaApplication;
|
|
|
import com.uas.pda_smart_com.bean.IOCOutMakeMaterialFuzzySearch;
|
|
|
import com.uas.pda_smart_com.bean.MaterialOutMessageBean;
|
|
|
+import com.uas.pda_smart_com.bean.OutboundOrderBean;
|
|
|
import com.uas.pda_smart_com.bean.SubmitNotParam;
|
|
|
import com.uas.pda_smart_com.database.DBManager;
|
|
|
import com.uas.pda_smart_com.global.GloableParams;
|
|
|
@@ -51,10 +52,14 @@ import com.uas.pda_smart_com.tools.SharedPreUtil;
|
|
|
import com.uas.pda_smart_com.tools.VolleyUtil;
|
|
|
import com.uas.pda_smart_com.util.CommonUtil;
|
|
|
import com.uas.pda_smart_com.util.Constants;
|
|
|
+import com.uas.pda_smart_com.util.FastjsonUtil;
|
|
|
+import com.uas.pda_smart_com.util.HttpCallback;
|
|
|
+import com.uas.pda_smart_com.util.HttpParams;
|
|
|
import com.uas.pda_smart_com.util.JsonTools;
|
|
|
import com.uas.pda_smart_com.util.JsonUtils;
|
|
|
import com.uas.pda_smart_com.util.LogUtil;
|
|
|
import com.uas.pda_smart_com.util.MyArrayAdapter;
|
|
|
+import com.uas.pda_smart_com.util.VollyRequest;
|
|
|
import com.uas.pda_smart_com.view.ClearableEditText;
|
|
|
|
|
|
import org.json.JSONArray;
|
|
|
@@ -79,8 +84,6 @@ public class IOCOutMakeMaterial extends BaseFragment {
|
|
|
|
|
|
private static String TAG = "IOCOutMakeMaterial";
|
|
|
|
|
|
-
|
|
|
-
|
|
|
private IOCOutMakeMaterialFuzzySearch fuzzySearchData;
|
|
|
private MyArrayAdapter<String> autoStringAdapter;
|
|
|
private StringRequest stringRequest, stringRequestPost;
|
|
|
@@ -133,23 +136,24 @@ public class IOCOutMakeMaterial extends BaseFragment {
|
|
|
mProdOutType = SharedPreUtil.getString(getActivity().getApplicationContext(), Constants.FLAG.PRODOUT_TYPE_CACHE, "byBatch");
|
|
|
|
|
|
dataList = (List<MaterialOutMessageBean.DataBean>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_OUT_CACHE);
|
|
|
- if (dataList == null || dataList.size() == 0) {
|
|
|
+ if (dataList == null) {
|
|
|
dataList = new ArrayList<>();
|
|
|
- adapterListView = new AdapterListView(getActivity(), R.layout.item_list_ioc_out_make_material, dataList);
|
|
|
- listInOut.setAdapter(adapterListView);
|
|
|
- } else {
|
|
|
- adapterListView = new AdapterListView(getActivity(), R.layout.item_list_ioc_out_make_material, dataList);
|
|
|
- listInOut.setAdapter(adapterListView);
|
|
|
- if (CommonUtil.isNetWorkConnected(mActivity))
|
|
|
- refreshMaterialStatus();
|
|
|
}
|
|
|
-
|
|
|
+// if (dataList == null || dataList.size() == 0) {
|
|
|
+// dataList = new ArrayList<>();
|
|
|
+// adapterListView = new AdapterListView(getActivity(), R.layout.item_list_ioc_out_make_material, dataList);
|
|
|
+// listInOut.setAdapter(adapterListView);
|
|
|
+// } else {
|
|
|
+// adapterListView = new AdapterListView(getActivity(), R.layout.item_list_ioc_out_make_material, dataList);
|
|
|
+// listInOut.setAdapter(adapterListView);
|
|
|
+// if (CommonUtil.isNetWorkConnected(mActivity))
|
|
|
+// refreshMaterialStatus();
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void initEvents() {
|
|
|
-
|
|
|
listInOut.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
@@ -170,38 +174,7 @@ public class IOCOutMakeMaterial extends BaseFragment {
|
|
|
inOutNo.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- if (TextUtils.isEmpty(inOutNo.getText().toString().trim())) {
|
|
|
- CommonUtil.toastNoRepeat(getActivity(), "请输入出库单号");
|
|
|
- } else if (CommonUtil.isStringContainsSpecialChar(inOutNo.getText().toString().trim())) {
|
|
|
- CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.barcode_cannot_contain_special));
|
|
|
- } else if (CommonUtil.isStringContainsSpecialChar(whCode.getText().toString().trim())) {
|
|
|
- CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.whcode_cannot_contain_special));
|
|
|
- } else {
|
|
|
- //判断单号和仓库组合是否已经存在于变量orders中
|
|
|
- boolean isExist = false;
|
|
|
- for (int i = 0; i < dataList.size(); i++) {
|
|
|
- if ((dataList.get(i).getPI_INOUTNO()).equals(inOutNo.getText().toString().trim()) && (dataList.get(i).getPD_WHCODE()).equals(whCode.getText().toString().trim())) {
|
|
|
- isExist = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (isExist) {
|
|
|
- Toast.makeText(getActivity(), "单号重复", Toast.LENGTH_SHORT).show();
|
|
|
- reset();
|
|
|
- } else {
|
|
|
- submitBtnClick();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- inOutNo.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
- @Override
|
|
|
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
- if (actionId == EditorInfo.IME_ACTION_SEND
|
|
|
- || actionId == EditorInfo.IME_ACTION_SEARCH
|
|
|
- || actionId == EditorInfo.IME_ACTION_DONE
|
|
|
- || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
+ try {
|
|
|
if (TextUtils.isEmpty(inOutNo.getText().toString().trim())) {
|
|
|
CommonUtil.toastNoRepeat(getActivity(), "请输入出库单号");
|
|
|
} else if (CommonUtil.isStringContainsSpecialChar(inOutNo.getText().toString().trim())) {
|
|
|
@@ -224,8 +197,53 @@ public class IOCOutMakeMaterial extends BaseFragment {
|
|
|
submitBtnClick();
|
|
|
}
|
|
|
}
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- return true;
|
|
|
+ inOutNo.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ try {
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_SEND
|
|
|
+ || actionId == EditorInfo.IME_ACTION_SEARCH
|
|
|
+ || actionId == EditorInfo.IME_ACTION_DONE
|
|
|
+ || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
+ if (TextUtils.isEmpty(inOutNo.getText().toString().trim())) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), "请输入出库单号");
|
|
|
+ } else if (CommonUtil.isStringContainsSpecialChar(inOutNo.getText().toString().trim())) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.barcode_cannot_contain_special));
|
|
|
+ } else if (CommonUtil.isStringContainsSpecialChar(whCode.getText().toString().trim())) {
|
|
|
+ CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.whcode_cannot_contain_special));
|
|
|
+ } else {
|
|
|
+ //判断单号和仓库组合是否已经存在于变量orders中
|
|
|
+ boolean isExist = false;
|
|
|
+
|
|
|
+ for (int i = 0; i < dataList.size(); i++) {
|
|
|
+ try {
|
|
|
+ if ((dataList.get(i).getPI_INOUTNO()).equals(inOutNo.getText().toString().trim())
|
|
|
+ && (dataList.get(i).getPD_WHCODE()).equals(whCode.getText().toString().trim())) {
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }catch (Exception e) {
|
|
|
+ isExist = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isExist) {
|
|
|
+ Toast.makeText(getActivity(), "单号重复", Toast.LENGTH_SHORT).show();
|
|
|
+ reset();
|
|
|
+ } else {
|
|
|
+ submitBtnClick();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
@@ -266,7 +284,97 @@ public class IOCOutMakeMaterial extends BaseFragment {
|
|
|
|
|
|
@Override
|
|
|
protected void initDatas() {
|
|
|
+ getlistData();
|
|
|
+ }
|
|
|
|
|
|
+ private void getlistData() {
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_GET_OUT_PRODIO_LIST)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "getlistData")
|
|
|
+ .flag(0)
|
|
|
+// .addParam("sc_code", sc_code)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
|
|
|
+ if (isSuccess){
|
|
|
+ com.alibaba.fastjson.JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(),"data");
|
|
|
+// if (dataArray == null || dataArray.size() == 0 && dataList.size() <= 0){
|
|
|
+// CommonUtil.toastNoRepeat(mActivity,"未搜索到匹配数据");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+ List<OutboundOrderBean> outboundOrderBeans = new ArrayList<>();
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ com.alibaba.fastjson.JSONObject jsonObject = dataArray.getJSONObject(i);
|
|
|
+ OutboundOrderBean workOrderListBean = new OutboundOrderBean();
|
|
|
+ workOrderListBean.setPI_ID(jsonObject.getLongValue("PI_ID")==-1?-1:jsonObject.getLongValue("PI_ID"));
|
|
|
+ workOrderListBean.setPI_CLASS(jsonObject.getString("PI_CLASS")==null?"":jsonObject.getString("PI_CLASS"));
|
|
|
+ workOrderListBean.setPD_WHCODE(jsonObject.getString("PD_WHCODE")==null?"":jsonObject.getString("PD_WHCODE"));
|
|
|
+ workOrderListBean.setPI_INOUTNO(jsonObject.getString("PI_INOUTNO")==null?"":jsonObject.getString("PI_INOUTNO"));
|
|
|
+ workOrderListBean.setPI_PDASTATUS(jsonObject.getString("PI_PDASTATUS")==null?"":jsonObject.getString("PI_PDASTATUS"));
|
|
|
+ outboundOrderBeans.add(workOrderListBean);
|
|
|
+ }
|
|
|
+
|
|
|
+ dataList = (List<MaterialOutMessageBean.DataBean>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_OUT_CACHE);
|
|
|
+ if (dataList == null) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ for (int i = 0; i < outboundOrderBeans.size(); i++) {
|
|
|
+ OutboundOrderBean outboundOrderBean = outboundOrderBeans.get(i);
|
|
|
+ MaterialOutMessageBean.DataBean dataBean = new MaterialOutMessageBean.DataBean();
|
|
|
+ dataBean.setPI_ID(outboundOrderBean.getPI_ID());
|
|
|
+ dataBean.setPI_CLASS(outboundOrderBean.getPI_CLASS());
|
|
|
+ dataBean.setPD_WHCODE(outboundOrderBean.getPD_WHCODE());
|
|
|
+ dataBean.setPI_INOUTNO(outboundOrderBean.getPI_INOUTNO());
|
|
|
+ dataBean.setPI_PDASTATUS(outboundOrderBean.getPI_PDASTATUS());
|
|
|
+ dataList.add(dataBean);
|
|
|
+ }
|
|
|
+ if (dataList.size() <= 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ adapterListView = new AdapterListView(getActivity(), R.layout.item_list_ioc_out_make_material, dataList);
|
|
|
+ listInOut.setAdapter(adapterListView);
|
|
|
+ } else {
|
|
|
+ //清除pi_id的项
|
|
|
+ dataList = removeDuplicate1(dataList);
|
|
|
+
|
|
|
+ adapterListView = new AdapterListView(getActivity(), R.layout.item_list_ioc_out_make_material, dataList);
|
|
|
+ listInOut.setAdapter(adapterListView);
|
|
|
+ if (CommonUtil.isNetWorkConnected(mActivity)) {
|
|
|
+ refreshMaterialStatus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 使用for循环删除list中的PI_ID重复的元素
|
|
|
+ */
|
|
|
+ public List<MaterialOutMessageBean.DataBean> removeDuplicate1(List<MaterialOutMessageBean.DataBean> list) {
|
|
|
+ for (int i = 0; i < list.size() - 1; i++) {
|
|
|
+ for (int j = list.size() - 1; j > i; j--) {
|
|
|
+ if (list.get(j).getPI_ID() == list.get(i).getPI_ID()) {
|
|
|
+ list.remove(j);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -320,13 +428,17 @@ public class IOCOutMakeMaterial extends BaseFragment {
|
|
|
}
|
|
|
adapterListView.notifyDataSetChanged();
|
|
|
} catch (Exception e) {
|
|
|
-
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}, new Response.ErrorListener() {
|
|
|
@Override
|
|
|
public void onErrorResponse(VolleyError error) {
|
|
|
-
|
|
|
+ try {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, error.getMessage());
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}) {
|
|
|
@Override
|
|
|
@@ -463,7 +575,7 @@ public class IOCOutMakeMaterial extends BaseFragment {
|
|
|
public void onClick(View view) {
|
|
|
switch (view.getId()) {
|
|
|
case R.id.clean_iv:
|
|
|
- inOutNo.getText().clear();
|
|
|
+ inOutNo.setText("");
|
|
|
break;
|
|
|
case R.id.submit_btn:
|
|
|
if (TextUtils.isEmpty(inOutNo.getText().toString().trim())) {
|
|
|
@@ -576,7 +688,7 @@ public class IOCOutMakeMaterial extends BaseFragment {
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
-
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
}
|