|
|
@@ -1,27 +1,38 @@
|
|
|
package com.uas.huayunuasmes.fragment;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
import android.app.Activity;
|
|
|
+import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.os.Bundle;
|
|
|
import android.text.Editable;
|
|
|
import android.text.TextUtils;
|
|
|
import android.text.TextWatcher;
|
|
|
import android.util.Log;
|
|
|
+import android.view.Gravity;
|
|
|
import android.view.KeyEvent;
|
|
|
+import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.ArrayAdapter;
|
|
|
import android.widget.Button;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.ListView;
|
|
|
+import android.widget.PopupWindow;
|
|
|
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.uas.huayunuasmes.R;
|
|
|
import com.uas.huayunuasmes.activity.FunctionActivity;
|
|
|
+import com.uas.huayunuasmes.bean.CaiPiBlueBean;
|
|
|
import com.uas.huayunuasmes.global.GloableParams;
|
|
|
import com.uas.huayunuasmes.listener.MyEditorActionListener;
|
|
|
import com.uas.huayunuasmes.tools.SharedPreUtil;
|
|
|
@@ -29,9 +40,11 @@ import com.uas.huayunuasmes.util.CameraUtil;
|
|
|
import com.uas.huayunuasmes.util.CommonUtil;
|
|
|
import com.uas.huayunuasmes.util.Constants;
|
|
|
import com.uas.huayunuasmes.util.FastjsonUtil;
|
|
|
+import com.uas.huayunuasmes.util.FragmentUtils;
|
|
|
import com.uas.huayunuasmes.util.HttpCallback;
|
|
|
import com.uas.huayunuasmes.util.HttpParams;
|
|
|
import com.uas.huayunuasmes.util.LogUtil;
|
|
|
+import com.uas.huayunuasmes.util.PrintUtils;
|
|
|
import com.uas.huayunuasmes.util.StringUtil;
|
|
|
import com.uas.huayunuasmes.util.VollyRequest;
|
|
|
import com.uas.huayunuasmes.view.ClearableEditText;
|
|
|
@@ -72,7 +85,12 @@ public class GdTimeReportFragment extends BaseFragment {
|
|
|
private Integer integer;
|
|
|
private Integer charSequenceNumber;
|
|
|
private TextView material_in_collect_result_tv;
|
|
|
-
|
|
|
+ private boolean isPrinting = false;
|
|
|
+ private int mPrintDpi = 203;
|
|
|
+ private boolean isConnected = false;
|
|
|
+ private PopupWindow splitPop;
|
|
|
+ private Button printjson;
|
|
|
+ private JSONArray dataArrayjson;
|
|
|
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
@@ -92,11 +110,12 @@ public class GdTimeReportFragment extends BaseFragment {
|
|
|
mOlRemarkEt = root.findViewById(R.id.ol_remark_et);
|
|
|
mOlExChangeBtn = root.findViewById(R.id.ol_pause_btn);
|
|
|
ed_pichi=root.findViewById(R.id.ed_pichi);
|
|
|
+ printjson = root.findViewById(R.id.printjson);
|
|
|
tv_report_name=root.findViewById(R.id.tv_report_name);
|
|
|
material_in_collect_result_tv = root.findViewById(R.id.material_in_collect_result_tv);
|
|
|
String name = SharedPreUtil.getString(mActivity, Constants.FLAG.CACHE_USER_EMNAME,null);
|
|
|
mOlNameTv.setText(name);
|
|
|
- ed_pichi.requestFocus();
|
|
|
+ mOlNumbersEt.requestFocus();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -134,6 +153,19 @@ public class GdTimeReportFragment extends BaseFragment {
|
|
|
dosubmitClick();
|
|
|
}
|
|
|
});
|
|
|
+ printjson.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+// initBreakPopupWindow(dataArrayjson);
|
|
|
+ if (dataArrayjson==null){
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "条码数据为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+// dataArrayjson.remove(0);
|
|
|
+// printEvent(dataArrayjson);
|
|
|
+ initBreakPopupWindow(dataArrayjson);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
mUnitspinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
@Override
|
|
|
@@ -425,10 +457,10 @@ public class GdTimeReportFragment extends BaseFragment {
|
|
|
String madeqty = mOlNumbersEt.getText().toString().trim();//报工数
|
|
|
String scrapqty = mOlUnuseEt.getText().toString().trim();//报废数
|
|
|
String remark = mOlRemarkEt.getText().toString().trim();//备注
|
|
|
- if(TextUtils.isEmpty(pici)){
|
|
|
- CommonUtil.toastNoRepeat(mActivity,"生产批次不能为空");
|
|
|
- return;
|
|
|
- }
|
|
|
+// if(TextUtils.isEmpty(pici)){
|
|
|
+// CommonUtil.toastNoRepeat(mActivity,"生产批次不能为空");
|
|
|
+// return;
|
|
|
+// }
|
|
|
if(TextUtils.isEmpty(madeqty)){//madeqty.length() == 0 || madeqty == ""
|
|
|
CommonUtil.toastNoRepeat(mActivity,"报工数不能为空");
|
|
|
return;
|
|
|
@@ -457,6 +489,7 @@ public class GdTimeReportFragment extends BaseFragment {
|
|
|
public void onSuccess(int flag, Object o) throws Exception {
|
|
|
progressDialog.dismiss();
|
|
|
Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
|
|
|
+ dataArrayjson = FastjsonUtil.getJSONArray(o.toString(), "data");
|
|
|
if (isSuccess){
|
|
|
material_in_collect_result_tv.setVisibility(View.VISIBLE);
|
|
|
material_in_collect_result_tv.setTextColor(getResources().getColor(R.color.green));
|
|
|
@@ -465,7 +498,9 @@ public class GdTimeReportFragment extends BaseFragment {
|
|
|
mOlNumbersEt.setText("");//报工数
|
|
|
mOlUnuseEt.setText("");//报废数
|
|
|
mOlRemarkEt.setText("");//备注
|
|
|
- ed_pichi.requestFocus();
|
|
|
+ mOlNumbersEt.requestFocus();
|
|
|
+ initBreakPopupWindow(dataArrayjson);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -480,16 +515,157 @@ public class GdTimeReportFragment extends BaseFragment {
|
|
|
mOlNumbersEt.setText("");//报工数
|
|
|
mOlUnuseEt.setText("");//报废数
|
|
|
mOlRemarkEt.setText("");//备注
|
|
|
- ed_pichi.requestFocus();
|
|
|
+ mOlNumbersEt.requestFocus();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
+ private void printEvent(com.alibaba.fastjson.JSONArray printArray) {
|
|
|
+ if (isPrinting) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "正在打印中,请勿重复操作");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ isPrinting = true;
|
|
|
+ if (printArray != null && printArray.size() > 0) {
|
|
|
+ boolean isFail = false;
|
|
|
+ for (int i = 0; i < printArray.size(); i++) {
|
|
|
+ try {
|
|
|
+ int printResult = PrintUtils.printBar(mActivity, printArray.toString(), mPrintDpi, null);
|
|
|
+ if (printResult <= 0) {
|
|
|
+ isFail = true;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (isFail) {
|
|
|
+ isConnected = false;
|
|
|
+ SharedPreUtil.saveInt(mActivity, "printConnect", 0);
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印失败,请重新连接打印机");
|
|
|
+
|
|
|
+ BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, printArray.toString());
|
|
|
+ Log.e("listArraythree",printArray.toString());
|
|
|
+ blueToothPrintFragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(GdTimeReportFragment.this, blueToothPrintFragment);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印成功");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "打印失败,条码数据为空");
|
|
|
+ }
|
|
|
+ isPrinting = false;
|
|
|
+ }
|
|
|
|
|
|
+ private void closeSplitPopupWindow() {
|
|
|
+ if (splitPop != null) {
|
|
|
+ splitPop.dismiss();
|
|
|
+ splitPop = null;
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private List<CaiPiBlueBean.DataBean> messages = new ArrayList<>();
|
|
|
+ //org.json.
|
|
|
+ protected void initBreakPopupWindow(com.alibaba.fastjson.JSONArray listArray) {
|
|
|
+ for (int i = 0; i < listArray.size(); i++) {
|
|
|
+ messages.clear();
|
|
|
+ try {
|
|
|
+ com.alibaba.fastjson.JSONObject barcodeObject = listArray.getJSONObject(i);
|
|
|
+
|
|
|
+ if (barcodeObject != null) {
|
|
|
+ CaiPiBlueBean.DataBean dataBean=new CaiPiBlueBean.DataBean();
|
|
|
+// dataBean.setLotno(JsonUtils.optStringNotNull(barcodeObject, "LOTNO"));
|
|
|
+// dataBean.setQty(JsonUtils.optStringNotNull(barcodeObject, "QTY"));
|
|
|
+ Log.e("BAR_CODE",barcodeObject.getString("BAR_CODE"));//PR_CODE
|
|
|
+ dataBean.setLotno("新条码号:"+barcodeObject.getString("BAR_CODE"));
|
|
|
+ dataBean.setQty("数量:"+barcodeObject.getString("BAR_REMAIN")
|
|
|
+ +"\n产品名称:"+barcodeObject.getString("PR_DETAIL")
|
|
|
+ +"\n工单号:"+barcodeObject.getString("MA_CODE")
|
|
|
+ +"\n料号:"+barcodeObject.getString("PR_CODE")
|
|
|
+ +"\n打印时间:"+barcodeObject.getString("PRINTDATE"));
|
|
|
+ messages.add(dataBean);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ View popView = LayoutInflater.from(getActivity()).inflate(R.layout.popupwindow_whbreaking_batch, null);
|
|
|
+ ListView listView = (ListView) popView.findViewById(R.id.list_view);
|
|
|
+ Button btnPrintf = (Button) popView.findViewById(R.id.btn_print);
|
|
|
+ Button btnPrintfSet = (Button) popView.findViewById(R.id.btn_print_setting);
|
|
|
+ Button btnClose = (Button) popView.findViewById(R.id.btn_close);
|
|
|
+ Button btnBack = (Button) popView.findViewById(R.id.btn_back);
|
|
|
+
|
|
|
+ btnBack.setVisibility(View.GONE);
|
|
|
+ btnClose.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+// }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ btnPrintf.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (isConnected) {
|
|
|
+ progressDialog.show();
|
|
|
+// listArray.remove(0);
|
|
|
+ printEvent(listArray);
|
|
|
+ } else {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
|
|
|
+
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
|
|
|
+ Log.e("listArrayone",listArray.toString());
|
|
|
+ blueToothPrintFragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(GdTimeReportFragment.this, blueToothPrintFragment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
+ btnPrintfSet.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+ BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
|
|
|
+
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
|
|
|
+ Log.e("listArraytwo",listArray.toString());
|
|
|
+ blueToothPrintFragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(GdTimeReportFragment.this, blueToothPrintFragment);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ MyAdapter adapter = new MyAdapter(getActivity(), R.layout.item_list_whbreakingbatchfragment, messages);
|
|
|
+ listView.setAdapter(adapter);
|
|
|
+ //当只有一条数据的时候可以加上
|
|
|
+ /*
|
|
|
+ if (messages.size()>1){
|
|
|
+ btnBack.setVisibility(View.GONE);
|
|
|
+ }*/
|
|
|
+ // PopupWindow实例化,参数的意思是 view,长(不包括状态栏),高(不包括状态栏),是否聚焦
|
|
|
+ splitPop = new PopupWindow(popView, LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
|
+ LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ splitPop.setAnimationStyle(R.style.MenuAnimationFade);
|
|
|
+ splitPop.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ // 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
|
|
|
+ splitPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
|
+ splitPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeSplitPopupWindow();
|
|
|
+// specialOut();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -527,4 +703,24 @@ public class GdTimeReportFragment extends BaseFragment {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ private class MyAdapter extends ArrayAdapter<CaiPiBlueBean.DataBean> {
|
|
|
+ private int resourceId;
|
|
|
+
|
|
|
+ public MyAdapter(Context context, int resource, List<CaiPiBlueBean.DataBean> objects) {
|
|
|
+ super(context, resource, objects);
|
|
|
+ resourceId = resource;
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("ViewHolder")
|
|
|
+ @Override
|
|
|
+ public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
+ CaiPiBlueBean.DataBean person = getItem(position);
|
|
|
+ convertView = LayoutInflater.from(getContext()).inflate(resourceId, null);
|
|
|
+ TextView tv_gone1 = (TextView) convertView.findViewById(R.id.tv_bar_code);
|
|
|
+ TextView tv_gone2 = (TextView) convertView.findViewById(R.id.tv_bar_remain);
|
|
|
+ tv_gone1.setText(person.getLotno());
|
|
|
+ tv_gone2.setText(person.getQty());
|
|
|
+ return convertView;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|