|
|
@@ -1,9 +1,13 @@
|
|
|
package com.uas.jlt_storage.fragment;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
+import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.support.v7.app.AlertDialog;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.text.format.DateUtils;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.View;
|
|
|
import android.widget.Button;
|
|
|
@@ -18,12 +22,14 @@ import com.uas.jlt_storage.R;
|
|
|
import com.uas.jlt_storage.activity.FunctionActivity;
|
|
|
import com.uas.jlt_storage.bean.JLTBoxBean;
|
|
|
import com.uas.jlt_storage.bean.JLTPickMaterialBean;
|
|
|
+import com.uas.jlt_storage.bean.WhcodeBean;
|
|
|
import com.uas.jlt_storage.global.GloableParams;
|
|
|
import com.uas.jlt_storage.listener.MyEditorActionListener;
|
|
|
import com.uas.jlt_storage.tools.SharedPreUtil;
|
|
|
import com.uas.jlt_storage.util.CameraUtil;
|
|
|
import com.uas.jlt_storage.util.CommonUtil;
|
|
|
import com.uas.jlt_storage.util.Constants;
|
|
|
+import com.uas.jlt_storage.util.DateFormatUtil;
|
|
|
import com.uas.jlt_storage.util.FastjsonUtil;
|
|
|
import com.uas.jlt_storage.util.HttpCallback;
|
|
|
import com.uas.jlt_storage.util.HttpParams;
|
|
|
@@ -32,6 +38,9 @@ import com.uas.jlt_storage.view.ClearableEditText;
|
|
|
import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
|
import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Created by RaoMeng on 2019/2/25
|
|
|
@@ -39,9 +48,10 @@ import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
*/
|
|
|
public class JLTPickMaterialOutScanFragment extends BaseFragment implements View.OnClickListener {
|
|
|
private static final int SCAN_BARCODE_CODE = 101;
|
|
|
- private ClearableEditText mLotEditText, mQuantityEditText, mCycleEditText, mMultipleEditText;
|
|
|
- private TextView mModelTextView, mOrderTextView, mRemainTextView, mMpqTextView, mTotalTextView, mBoxTextView, mHbTextView;
|
|
|
- private ImageView mEditImageView, mScanImageView;
|
|
|
+ private static final int SCAN_ENCLOSURE_CODE = 102;
|
|
|
+ private ClearableEditText mLotEditText, mQuantityEditText, mCycleEditText, mMultipleEditText, mEnclosureEditText;
|
|
|
+ private TextView mModelTextView, mOrderTextView, mRemainTextView, mMpqTextView, mTotalTextView, mBoxTextView, mHbTextView, mEnclosureTextView;
|
|
|
+ private ImageView mEditImageView, mScanImageView, mEnclosureImageView;
|
|
|
private ClearableEditText mBarcodeEditText;
|
|
|
private Button mSaveButton, mNextButton;
|
|
|
private JLTPickMaterialBean mPickMaterialBean;
|
|
|
@@ -49,6 +59,8 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
private String mPiid, mLotno, mDatecode, mBarcode;
|
|
|
private double mQty;
|
|
|
private OnCollectFinishListener mOnCollectFinishListener;
|
|
|
+ private String mDatecodebyparse;
|
|
|
+ private List<WhcodeBean> mEnclosureList;
|
|
|
|
|
|
public void setOnCollectFinishListener(OnCollectFinishListener onCollectFinishListener) {
|
|
|
mOnCollectFinishListener = onCollectFinishListener;
|
|
|
@@ -79,8 +91,13 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
mSaveButton = root.findViewById(R.id.jlt_pick_material_out_scan_save_btn);
|
|
|
mNextButton = root.findViewById(R.id.jlt_pick_material_out_scan_next_btn);
|
|
|
mHbTextView = root.findViewById(R.id.jlt_pick_material_out_scan_hb_tv);
|
|
|
+ mEnclosureEditText = root.findViewById(R.id.jlt_pick_material_out_scan_enclosure_et);
|
|
|
+ mEnclosureImageView = root.findViewById(R.id.jlt_pick_material_out_scan_enclosure_iv);
|
|
|
+ mEnclosureTextView = root.findViewById(R.id.jlt_pick_material_out_scan_enclosure_tv);
|
|
|
|
|
|
mBarcodeEditText.requestFocus();
|
|
|
+
|
|
|
+ mEnclosureList = new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -89,6 +106,7 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
mSaveButton.setOnClickListener(this);
|
|
|
mEditImageView.setOnClickListener(this);
|
|
|
mScanImageView.setOnClickListener(this);
|
|
|
+ mEnclosureImageView.setOnClickListener(this);
|
|
|
|
|
|
CommonUtil.setEditorActionListener(mBarcodeEditText, new MyEditorActionListener() {
|
|
|
@Override
|
|
|
@@ -96,6 +114,13 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
barcodeParse(text);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ CommonUtil.setEditorActionListener(mEnclosureEditText, new MyEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public void MyEditorAction(String text, int actionId, KeyEvent event) {
|
|
|
+ enclosureParse();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -121,6 +146,7 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
|
|
|
mModelTextView.setText(mPickMaterialBean.getPR_ORISPECCODE());
|
|
|
mOrderTextView.setText(mPickMaterialBean.getDETNO() + "");
|
|
|
+ mEnclosureTextView.setText(mPickMaterialBean.getPR_PKG());
|
|
|
double pd_restqty = mPickMaterialBean.getPD_RESTQTY();
|
|
|
double pd_zxbzs = mPickMaterialBean.getPD_ZXBZS();
|
|
|
mRemainTextView.setText(CommonUtil.doubleFormat(pd_restqty));
|
|
|
@@ -134,6 +160,66 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void enclosureParse() {
|
|
|
+ String enclosure = mEnclosureEditText.getText().toString().trim();
|
|
|
+
|
|
|
+ if (TextUtils.isEmpty(enclosure)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ progressDialog.show();
|
|
|
+
|
|
|
+ VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_JLT_OUTSTOCK_PKGPARSE)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .flag(0)
|
|
|
+ .tag(TAG + "enclosureparse")
|
|
|
+ .addParam("pkgStr", enclosure)
|
|
|
+ .addParam("brand", mPickMaterialBean.getPR_BRAND())
|
|
|
+ .addParam("prodcode", mPickMaterialBean.getPR_CODE())
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ if (resultObject != null) {
|
|
|
+ String enclosure = FastjsonUtil.getText(resultObject, "data");
|
|
|
+ mEnclosureEditText.setText(enclosure);
|
|
|
+
|
|
|
+ String Multiple = mMultipleEditText.getText().toString().trim();
|
|
|
+ int mulInt = 1;
|
|
|
+ try {
|
|
|
+ mulInt = Integer.parseInt(Multiple);
|
|
|
+ if ((mQty * mulInt) == mPickMaterialBean.getPD_RESTQTY() && !TextUtils.isEmpty(enclosure)) {
|
|
|
+ confirmOut(false);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ mEnclosureEditText.setText("");
|
|
|
+ new Handler().post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mEnclosureEditText.requestFocus();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
private void barcodeParse(String text) {
|
|
|
if (TextUtils.isEmpty(text)) {
|
|
|
return;
|
|
|
@@ -142,6 +228,7 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
if (mPickMaterialBean == null) {
|
|
|
return;
|
|
|
}
|
|
|
+ mEnclosureList.clear();
|
|
|
|
|
|
progressDialog.show();
|
|
|
mBarcode = text;
|
|
|
@@ -165,6 +252,7 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
mLotno = FastjsonUtil.getText(dataObject, "LOTNO");
|
|
|
mDatecode = FastjsonUtil.getText(dataObject, "DATECODE");
|
|
|
mQty = FastjsonUtil.getDouble(dataObject, "QTY");
|
|
|
+ mDatecodebyparse = FastjsonUtil.getText(dataObject, "DATECODEBYPARSE");
|
|
|
|
|
|
mLotEditText.setText(mLotno);
|
|
|
mQuantityEditText.setText(CommonUtil.doubleFormat(mQty));
|
|
|
@@ -174,9 +262,11 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
int mulInt = 1;
|
|
|
try {
|
|
|
mulInt = Integer.parseInt(Multiple);
|
|
|
-
|
|
|
- if ((mQty * mulInt) == mPickMaterialBean.getPD_RESTQTY()) {
|
|
|
+ String enclosure = mEnclosureEditText.getText().toString().trim();
|
|
|
+ if ((mQty * mulInt) == mPickMaterialBean.getPD_RESTQTY() && !TextUtils.isEmpty(enclosure)) {
|
|
|
confirmOut(false);
|
|
|
+ } else {
|
|
|
+ mEnclosureEditText.requestFocus();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return;
|
|
|
@@ -225,6 +315,8 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
mPickMaterialBean.setPR_CODE(FastjsonUtil.getText(listObject, "PR_CODE"));
|
|
|
mPickMaterialBean.setPD_WHCODE(FastjsonUtil.getText(listObject, "PD_WHCODE"));
|
|
|
mPickMaterialBean.setNOHBZ(FastjsonUtil.getInt(listObject, "NOHBZ"));
|
|
|
+ mPickMaterialBean.setCU_PRINT_LIMITEDDATE(FastjsonUtil.getLong(listObject, "CU_PRINT_LIMITEDDATE"));
|
|
|
+ mPickMaterialBean.setPR_PKG(FastjsonUtil.getText(listObject, "PR_PKG"));
|
|
|
|
|
|
float restqtyCache = SharedPreUtil.getFloat(mActivity, Constants.FLAG.JLT_PICK_MATERIAL_QUANTITY, -1);
|
|
|
if (restqtyCache > 0) {
|
|
|
@@ -257,6 +349,17 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
CommonUtil.toastNoRepeat(mActivity, getString(R.string.no_camera_detected));
|
|
|
}
|
|
|
break;
|
|
|
+ case R.id.jlt_pick_material_out_scan_enclosure_iv:
|
|
|
+ if (CameraUtil.hasCamera()) {
|
|
|
+ if (root.findFocus() != null) {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(mActivity, CaptureActivity.class);
|
|
|
+ startActivityForResult(intent, SCAN_ENCLOSURE_CODE);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, getString(R.string.no_camera_detected));
|
|
|
+ }
|
|
|
+ break;
|
|
|
case R.id.jlt_pick_material_out_scan_save_btn:
|
|
|
confirmOut(false);
|
|
|
break;
|
|
|
@@ -294,6 +397,57 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ String enclosure = mEnclosureEditText.getText().toString().trim();
|
|
|
+ if (TextUtils.isEmpty(enclosure)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请采集封装形式");
|
|
|
+ mEnclosureEditText.requestFocus();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ long limitDays = mBoxBean.getCU_PRINT_LIMITEDDATE();
|
|
|
+ int daysInterval = DateFormatUtil.getDaysInterval(mDatecodebyparse, DateFormatUtil.long2Str("yyyyMMdd")
|
|
|
+ , DateFormatUtil.getFormat("yyyyMMdd"));
|
|
|
+
|
|
|
+ if (daysInterval > limitDays) {
|
|
|
+ int finalMulInt = mulInt;
|
|
|
+ new AlertDialog.Builder(mActivity)
|
|
|
+ .setTitle("提示")
|
|
|
+ .setMessage("捡料条码 生产日期(" + mDatecodebyparse
|
|
|
+ + ")+ 有效天数(" + limitDays
|
|
|
+ + ")>当天,是否确认捡料?")
|
|
|
+ .setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ confirmRequest(exist, finalMulInt, zxbzs, enclosure);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ resetState();
|
|
|
+ }
|
|
|
+ }).create().show();
|
|
|
+ } else {
|
|
|
+ confirmRequest(exist, mulInt, zxbzs, enclosure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void resetState() {
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ mLotEditText.setText("");
|
|
|
+ mQuantityEditText.setText("");
|
|
|
+ mCycleEditText.setText("");
|
|
|
+ mEnclosureEditText.setText("");
|
|
|
+
|
|
|
+ new Handler().post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mBarcodeEditText.requestFocus();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void confirmRequest(boolean exist, int mulInt, double zxbzs, String enclosure) {
|
|
|
progressDialog.show();
|
|
|
VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
.url(GloableParams.ADDRESS_JLT_OUTSTOCK_CONFIRMOUT)
|
|
|
@@ -307,44 +461,54 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
.addParam("data", mBarcode)
|
|
|
.addParam("PD_ZXBZS", CommonUtil.doubleFormat(zxbzs))
|
|
|
.addParam("nohbz", mPickMaterialBean.getNOHBZ() + "")
|
|
|
+ .addParam("pkg", enclosure)
|
|
|
.build(), new HttpCallback() {
|
|
|
@Override
|
|
|
public void onSuccess(int flag, Object o) throws Exception {
|
|
|
progressDialog.dismiss();
|
|
|
try {
|
|
|
- CommonUtil.toastNoRepeat(mActivity, "采集成功");
|
|
|
-
|
|
|
String result = o.toString();
|
|
|
JSONObject resultObject = JSON.parseObject(result);
|
|
|
JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
if (dataObject != null) {
|
|
|
- double restqty = FastjsonUtil.getDouble(dataObject, "RESTQTY");
|
|
|
- mPickMaterialBean.setPD_RESTQTY(restqty);
|
|
|
- SharedPreUtil.saveFloat(mActivity, Constants.FLAG.JLT_PICK_MATERIAL_QUANTITY, (float) restqty);
|
|
|
- mRemainTextView.setText(CommonUtil.doubleFormat(restqty));
|
|
|
- double pd_zxbzs = zxbzs;
|
|
|
- try {
|
|
|
- double pan = Math.ceil(restqty / pd_zxbzs);
|
|
|
- mTotalTextView.setText(CommonUtil.doubleFormat(pan));
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- if (restqty <= 0) {
|
|
|
- int materialOrder = SharedPreUtil.getInt(mActivity, Constants.FLAG.JLT_PICK_MATERIAL_ORDER, 0);
|
|
|
- materialOrder++;
|
|
|
- SharedPreUtil.saveInt(mActivity, Constants.FLAG.JLT_PICK_MATERIAL_ORDER, materialOrder);
|
|
|
-
|
|
|
- getActivity().getSupportFragmentManager().popBackStackImmediate();
|
|
|
+ boolean checkpkg = FastjsonUtil.getBoolean(dataObject, "CHECKPKG");
|
|
|
+ if (!checkpkg) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "封装形式校验不通过,请重新采集");
|
|
|
+ mEnclosureEditText.setText("");
|
|
|
+ new Handler().post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mEnclosureEditText.requestFocus();
|
|
|
+ }
|
|
|
+ });
|
|
|
} else {
|
|
|
- if (exist) {
|
|
|
- getActivity().getSupportFragmentManager().popBackStack();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "采集成功");
|
|
|
+ double restqty = FastjsonUtil.getDouble(dataObject, "RESTQTY");
|
|
|
+ mPickMaterialBean.setPD_RESTQTY(restqty);
|
|
|
+ SharedPreUtil.saveFloat(mActivity, Constants.FLAG.JLT_PICK_MATERIAL_QUANTITY, (float) restqty);
|
|
|
+ mRemainTextView.setText(CommonUtil.doubleFormat(restqty));
|
|
|
+ double pd_zxbzs = zxbzs;
|
|
|
+ try {
|
|
|
+ double pan = Math.ceil(restqty / pd_zxbzs);
|
|
|
+ mTotalTextView.setText(CommonUtil.doubleFormat(pan));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (restqty <= 0) {
|
|
|
+ int materialOrder = SharedPreUtil.getInt(mActivity, Constants.FLAG.JLT_PICK_MATERIAL_ORDER, 0);
|
|
|
+ materialOrder++;
|
|
|
+ SharedPreUtil.saveInt(mActivity, Constants.FLAG.JLT_PICK_MATERIAL_ORDER, materialOrder);
|
|
|
+
|
|
|
+ getActivity().getSupportFragmentManager().popBackStackImmediate();
|
|
|
} else {
|
|
|
- mBarcodeEditText.setText("");
|
|
|
- mLotEditText.setText("");
|
|
|
- mQuantityEditText.setText("");
|
|
|
- mCycleEditText.setText("");
|
|
|
+ if (exist) {
|
|
|
+ getActivity().getSupportFragmentManager().popBackStack();
|
|
|
+ } else {
|
|
|
+ resetState();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -373,6 +537,14 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
mBarcodeEditText.setSelection(result.length());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (requestCode == SCAN_ENCLOSURE_CODE && data != null) {
|
|
|
+ if (data.getExtras() != null) {
|
|
|
+ String result = data.getExtras().getString(CodeUtils.RESULT_STRING);
|
|
|
+ mEnclosureEditText.setText(result);
|
|
|
+ mEnclosureEditText.setSelection(result.length());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|