|
|
@@ -6,7 +6,9 @@ import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
+import android.text.Editable;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.text.TextWatcher;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.View;
|
|
|
import android.widget.Button;
|
|
|
@@ -60,11 +62,12 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
private JLTPickMaterialBean mPickMaterialBean;
|
|
|
private JLTBoxBean mBoxBean;
|
|
|
private String mPiid, mPN, mLotno, mDatecode, mBarcode;
|
|
|
- private double mQty;
|
|
|
+ private double mQty = -1;
|
|
|
private OnCollectFinishListener mOnCollectFinishListener;
|
|
|
private String mDatecodebyparse;
|
|
|
private boolean mNeedPkg;
|
|
|
private List<WhcodeBean> mEnclosureList;
|
|
|
+ private String mPKG;
|
|
|
|
|
|
public void setOnCollectFinishListener(OnCollectFinishListener onCollectFinishListener) {
|
|
|
mOnCollectFinishListener = onCollectFinishListener;
|
|
|
@@ -93,14 +96,19 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
mScanImageView = root.findViewById(R.id.jlt_pick_material_out_scan_scan_iv);
|
|
|
mBarcodeEditText = root.findViewById(R.id.jlt_pick_material_out_scan_barcode_et);
|
|
|
mSaveButton = root.findViewById(R.id.jlt_pick_material_out_scan_save_btn);
|
|
|
+ mModelEditText = root.findViewById(R.id.jlt_pick_material_out_scan_model_et);
|
|
|
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);
|
|
|
- mModelEditText = root.findViewById(R.id.jlt_pick_material_out_scan_model_et);
|
|
|
|
|
|
- mBarcodeEditText.requestFocus();
|
|
|
+ mBarcodeEditText.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mBarcodeEditText.requestFocus();
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
|
|
|
mEnclosureList = new ArrayList<>();
|
|
|
}
|
|
|
@@ -135,6 +143,10 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ mLotEditText.addTextChangedListener(new MyTextWatcher(mLotEditText));
|
|
|
+ mQuantityEditText.addTextChangedListener(new MyTextWatcher(mQuantityEditText));
|
|
|
+ mCycleEditText.addTextChangedListener(new MyTextWatcher(mCycleEditText));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -259,22 +271,28 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
public void onSuccess(int flag, Object o) throws Exception {
|
|
|
progressDialog.dismiss();
|
|
|
try {
|
|
|
+ mBarcodeEditText.setText("");
|
|
|
+ mBarcodeEditText.requestFocus();
|
|
|
String result = o.toString();
|
|
|
JSONObject resultObject = JSON.parseObject(result);
|
|
|
JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
if (dataObject != null) {
|
|
|
- mPN = FastjsonUtil.getText(dataObject, "PN");
|
|
|
- mLotno = FastjsonUtil.getText(dataObject, "LOTNO");
|
|
|
- mDatecode = FastjsonUtil.getText(dataObject, "DATECODE");
|
|
|
- mQty = FastjsonUtil.getDouble(dataObject, "QTY");
|
|
|
- mDatecodebyparse = FastjsonUtil.getText(dataObject, "DATECODEBYPARSE");
|
|
|
- mNeedPkg = FastjsonUtil.getBoolean(dataObject, "NEEDPKG");
|
|
|
+ mPN = getValuableValue(FastjsonUtil.getText(dataObject, "PN"), mPN);
|
|
|
+ mLotno = getValuableValue(FastjsonUtil.getText(dataObject, "LOTNO"), mLotno);
|
|
|
+ mDatecode = getValuableValue(FastjsonUtil.getText(dataObject, "DATECODE"), mDatecode);
|
|
|
+ mQty = TextUtils.isEmpty(FastjsonUtil.getText(dataObject, "QTY")) ? mQty : FastjsonUtil.getDouble(dataObject, "QTY");
|
|
|
+ mDatecodebyparse = getValuableValue(FastjsonUtil.getText(dataObject, "DATECODEBYPARSE"), mDatecodebyparse);
|
|
|
+ mNeedPkg = TextUtils.isEmpty(FastjsonUtil.getText(dataObject, "NEEDPKG")) ?
|
|
|
+ mNeedPkg : FastjsonUtil.getBoolean(dataObject, "NEEDPKG");
|
|
|
+ mPKG = getValuableValue(FastjsonUtil.getText(dataObject, "PKG"), mPKG);
|
|
|
|
|
|
mModelEditText.setText(mPN);
|
|
|
mLotEditText.setText(mLotno);
|
|
|
- mQuantityEditText.setText(CommonUtil.doubleFormat(mQty));
|
|
|
+ if (mQty != -1) {
|
|
|
+ mQuantityEditText.setText(CommonUtil.doubleFormat(mQty));
|
|
|
+ }
|
|
|
mCycleEditText.setText(mDatecode);
|
|
|
- mEnclosureEditText.setText(FastjsonUtil.getText(dataObject, "PKG"));
|
|
|
+ mEnclosureEditText.setText(mPKG);
|
|
|
|
|
|
String Multiple = mMultipleEditText.getText().toString().trim();
|
|
|
int mulInt = 1;
|
|
|
@@ -284,9 +302,10 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
if (mNeedPkg) {
|
|
|
if ((mQty * mulInt) == mPickMaterialBean.getPD_RESTQTY() && !TextUtils.isEmpty(enclosure)) {
|
|
|
confirmOut(false);
|
|
|
- } else {
|
|
|
- mEnclosureEditText.requestFocus();
|
|
|
}
|
|
|
+// else {
|
|
|
+// mEnclosureEditText.requestFocus();
|
|
|
+// }
|
|
|
} else if ((mQty * mulInt) == mPickMaterialBean.getPD_RESTQTY()) {
|
|
|
confirmOut(false);
|
|
|
}
|
|
|
@@ -311,6 +330,10 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private String getValuableValue(String netValue, String oldValue) {
|
|
|
+ return TextUtils.isEmpty(netValue) ? oldValue : netValue;
|
|
|
+ }
|
|
|
+
|
|
|
private void analysisCache(String materialCache, int materialOrder) {
|
|
|
JSONObject resultObject = JSON.parseObject(materialCache);
|
|
|
JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
@@ -429,29 +452,33 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
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();
|
|
|
+ if (!TextUtils.isEmpty(mDatecodebyparse)) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
} else {
|
|
|
confirmRequest(exist, mulInt, zxbzs, enclosure);
|
|
|
}
|
|
|
@@ -595,4 +622,43 @@ public class JLTPickMaterialOutScanFragment extends BaseFragment implements View
|
|
|
public interface OnCollectFinishListener {
|
|
|
void onCollectFinish();
|
|
|
}
|
|
|
+
|
|
|
+ private class MyTextWatcher implements TextWatcher {
|
|
|
+ private TextView view;
|
|
|
+
|
|
|
+ public MyTextWatcher(TextView view) {
|
|
|
+ this.view = view;
|
|
|
+ }
|
|
|
+
|
|
|
+ @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) {
|
|
|
+ String text = s.toString().trim();
|
|
|
+ switch (view.getId()) {
|
|
|
+ case R.id.jlt_pick_material_out_scan_lot_et:
|
|
|
+ mLotno = text;
|
|
|
+ break;
|
|
|
+ case R.id.jlt_pick_material_out_scan_quantity_et:
|
|
|
+ try {
|
|
|
+ mQty = Double.parseDouble(text);
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case R.id.jlt_pick_material_out_scan_cycle_et:
|
|
|
+ mDatecode = text;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|