| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921 |
- package com.uas.bgdq.fragment;
- import android.app.Activity;
- import android.content.ComponentName;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.graphics.drawable.BitmapDrawable;
- import android.net.Uri;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.Message;
- import android.support.v4.app.Fragment;
- import android.support.v7.app.AlertDialog;
- 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.view.inputmethod.EditorInfo;
- import android.widget.AdapterView;
- import android.widget.ArrayAdapter;
- import android.widget.BaseAdapter;
- import android.widget.Button;
- import android.widget.CheckBox;
- import android.widget.CompoundButton;
- import android.widget.EditText;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.ListView;
- import android.widget.PopupWindow;
- import android.widget.RadioButton;
- import android.widget.RadioGroup;
- import android.widget.Spinner;
- import android.widget.TableLayout;
- import android.widget.TextView;
- import android.widget.Toast;
- import com.alibaba.fastjson.JSON;
- import com.android.volley.AuthFailureError;
- import com.android.volley.DefaultRetryPolicy;
- import com.android.volley.NetworkResponse;
- import com.android.volley.Request;
- import com.android.volley.Response;
- import com.android.volley.VolleyError;
- import com.android.volley.toolbox.HttpHeaderParser;
- import com.android.volley.toolbox.JsonObjectRequest;
- import com.android.volley.toolbox.StringRequest;
- import com.uas.bgdq.R;
- import com.uas.bgdq.activity.FunctionActivity;
- import com.uas.bgdq.application.PdaApplication;
- import com.uas.bgdq.bean.ErrorMsg;
- import com.uas.bgdq.bean.IOCOutMakeMaterialOperMsd;
- import com.uas.bgdq.bean.IOCOutmakeMaterialSplitBean;
- import com.uas.bgdq.bean.MaterialInformationBean;
- import com.uas.bgdq.bean.SubmitNotParam;
- import com.uas.bgdq.bean.WHBreakingBatchBreakingBtnClickEvent;
- import com.uas.bgdq.database.DBManager;
- import com.uas.bgdq.global.GloableParams;
- import com.uas.bgdq.table.TableLBARCODEIO;
- import com.uas.bgdq.table.TableLPRODIONEEDGET;
- import com.uas.bgdq.tools.SharedPreUtil;
- import com.uas.bgdq.tools.VolleyUtil;
- import com.uas.bgdq.util.CameraUtil;
- import com.uas.bgdq.util.CommonUtil;
- import com.uas.bgdq.util.Constants;
- import com.uas.bgdq.util.FastjsonUtil;
- import com.uas.bgdq.util.FileUtils;
- import com.uas.bgdq.util.FragmentUtils;
- import com.uas.bgdq.util.HttpCallback;
- import com.uas.bgdq.util.HttpParams;
- import com.uas.bgdq.util.JsonTools;
- import com.uas.bgdq.util.JsonUtils;
- import com.uas.bgdq.util.LogUtil;
- import com.uas.bgdq.util.PrintUtils;
- import com.uas.bgdq.util.VolleyRequest;
- import com.uas.bgdq.view.ClearableEditText;
- import com.uuzuche.lib_zxing.activity.CaptureActivity;
- import com.uuzuche.lib_zxing.activity.CodeUtils;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- import java.io.File;
- import java.io.UnsupportedEncodingException;
- import java.net.URLEncoder;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import java.util.concurrent.TimeUnit;
- import butterknife.ButterKnife;
- import okhttp3.OkHttpClient;
- /**
- * Created by RaoMeng on 2016/7/27.
- * AVG出库采集页面
- */
- public class AGVIOCOutMakeMaterialOper extends BaseFragment implements View.OnClickListener, RadioGroup.OnCheckedChangeListener, HttpCallback ,AdapterView.OnItemSelectedListener{
- private static final int SCAN_BARCODE_CODE = 103;
- private static final int SPLIT_BARCODE_SUCCESS = 104;
- private static final int SPLIT_BARCODE_FAIL = 105;
- private static final int FLAG_CONFIRM_POST = 0x05;
- private String maFunName = null;
- private List<String> masterFuncList;
- private ImageView mScanImageView;
- static ArrayAdapter adapter;
- private JsonObjectRequest jsonRequest;
- private static final String TAG = "IOCOutMakeMaterialOper";
- private Button btnActionbarWithback, btnActionbarRight;
- private String pi_inoutno;
- private String pd_whcode;
- private String pi_id;
- private boolean isMultiple;
- private Fragment mFragment;
- private String mCollectType;
- private PopupWindow listPopupWindow;
- private StringRequest stringRequestPost;
- private String mProdOutType;
- private List<WHBreakingBatchBreakingBtnClickEvent.DataBean> messages = new ArrayList<>();
- private int mCollectModel = 1;//采集模式:1代表在线,0代表离线
- private String mBarRemain, mRestqty;
- private String mResult1, mResult2, mResult3, mResult4;
- private List<String> mResults;
- private TextWatcher watcher = new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- }
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- }
- @Override
- public void afterTextChanged(Editable editable) {
- if (editable.length() == 0) {
- btnConfirm.setEnabled(false);
- } else {
- btnConfirm.setEnabled(true);
- }
- }
- };
- private StringRequest stringRequest;
- private PopupWindow splitPop;
- private String strPrintDataList;
- private StringRequest stringRequestSplit;
- private DBManager mDbManager;
- private StringRequest mStringRequest;
- private ArrayAdapter mTypeSpAdapter;
- private ArrayList<String> mCollectTypes;
- private String mPrintUrl = "";
- private Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- super.handleMessage(msg);
- switch (msg.what) {
- case Constants.CONSTANT.PRINT_SUCCESS:
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- closeSplitPopupWindow();
- Toast.makeText(mActivity, R.string.obtain_print_file_success, Toast.LENGTH_LONG).show();
- try {
- Intent intent = new Intent();
- ComponentName comp = new ComponentName("com.dynamixsoftware.printershare", "com.dynamixsoftware.printershare.ActivityPrintPDF");
- intent = new Intent();
- intent.setComponent(comp);
- intent.setAction("android.intent.action.VIEW");
- intent.setType("application/pdf");
- intent.setData(Uri.fromFile(new File(Constants.CONSTANT.PRINT_FILE_PATH, Constants.CONSTANT.PRINT_FILE_NAME)));
- startActivity(intent);
- } catch (Exception e) {
- Toast.makeText(mActivity, "打印失败", Toast.LENGTH_LONG).show();
- e.printStackTrace();
- }
- break;
- case Constants.CONSTANT.PRINT_FAILED:
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- Toast.makeText(mActivity, R.string.obtain_print_file_failed, Toast.LENGTH_LONG).show();
- break;
- case Constants.CONSTANT.PRINT_OVERLOAD:
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- Toast.makeText(mActivity, R.string.obtain_print_file_overload, Toast.LENGTH_LONG).show();
- break;
- case SPLIT_BARCODE_SUCCESS:
- String s = (String) msg.obj;
- if (popupWindow != null && popupWindow.isShowing())
- closePopupWindow();
- mResults = new ArrayList<>();
- mCollectTypeRadioGroup.setEnabled(true);
- LogUtil.e("breaking", s);
- try {
- JSONObject jsonObject = new JSONObject(s);
- JSONObject dataObject = jsonObject.optJSONObject("data");
- if (dataObject == null) {
- return;
- }
- JSONObject messageObject = dataObject.optJSONObject("barcode");
- if (messageObject == null) {
- return;
- }
- if (messageObject.has("ISMSD")) {
- if (messageObject.optBoolean("ISMSD")) {
- //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
- iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
- // Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
- mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
- mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
- showDewPopupWindow();
- } else {
- mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
- mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
- mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
- if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
- spliteBarcode(currentBarcode, mBarRemain, mRestqty);
- }
- }
- } else {
- mCollectResultTextView.setVisibility(View.VISIBLE);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
- mCollectResultTextView.setText(null);
- JSONArray listArray = dataObject.optJSONArray("nolist");
- if (mCollectType.equals("byBarcode") || mCollectType.equals("byBatchcode")) {
- String barcodeResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
- + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
- + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
- + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
- + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
- + ";名称规格:" + messageObject. optString("PR_DETAIL")
- + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC")
- + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
- if (listArray != null && listArray.length() > 0) {
- for (int i = 0; i < listArray.length(); i++) {
- JSONObject listObject = listArray.optJSONObject(i);
- barcodeResult = barcodeResult
- + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
- + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
- + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
- }
- //弹出拆分结果弹框
- initBreakPopupWindow(listArray,"1");
- }
- mCollectResultTextView.setText(barcodeResult);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.GONE);
- tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
- tvBarcodeCollectionSuccess.setText("采集成功");
- mResult1 = messageObject.optString("BAR_CODE");
- mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
- mResult3 = messageObject.optString("BAR_PRODCODE");
- mResults.add(mResult1);
- mResults.add(mResult2);
- mResults.add(mResult3);
- mCollectBarcodeTv.setText(mResult1);
- mCollectBarRemainTv.setText(mResult2);
- mCollectBarProdcodeTv.setText(mResult3);
- PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
- } else if (false) {
- String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
- + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
- + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
- + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
- + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
- + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
- + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
- if (listArray != null && listArray.length() > 0) {
- for (int i = 0; i < listArray.length(); i++) {
- JSONObject listObject = listArray.optJSONObject(i);
- boxResult = boxResult
- + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
- + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
- + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
- }
- }
- mCollectResultTextView.setText(boxResult);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.GONE);
- tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
- tvBoxCollectionSuccess.setText("采集成功");
- mResult1 = messageObject.optString("PA_OUTBOXCODE");
- mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
- mResult3 = messageObject.optString("PA_PRODCODE");
- mResult4 = messageObject.optString("PA_WHCODE");
- mResults.add(mResult1);
- mResults.add(mResult2);
- mResults.add(mResult3);
- mResults.add(mResult4);
- mCollectBoxTv.setText(mResult1);
- mCollectBoxNumTv.setText(mResult2);
- mCollectBoxrProdcodeTv.setText(mResult3);
- mCollectBoxWhcodeTv.setText(mResult4);
- PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
- }
- CommonUtil.toastNoRepeat(getActivity(), "采集成功");
- Object next = jsonObject.getJSONObject("data").get("next");
- if (next != null && !"null".equals(next.toString())) {
- JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
- MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
- if (materialInformationBean != null) {
- String materialInfo =
- "型号:" + (materialInformationBean.getPR_ORISPECCODE() == null ? "" : materialInformationBean.getPR_ORISPECCODE())
- + "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
- + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
- + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
- + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
- + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
- + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
- if (materialInformationBean.getPD_BATCHCODE() != null) {
- materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
- }
- mMaterialInforTextView.setText(materialInfo);
- }
- } else {
- mMaterialInforTextView.setText("该出库单已经完成备料");
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- break;
- case SPLIT_BARCODE_FAIL:
- s = (String) msg.obj;
- String errorStr = "请求失败";
- if (JsonUtils.validate(s)) {
- try {
- JSONObject errorObject = new JSONObject(s);
- String exceptionInfo = JsonUtils.optStringNotNull(errorObject, "exceptionInfo");
- if (TextUtils.isEmpty(exceptionInfo)) {
- errorStr = "系统错误";
- } else {
- errorStr = exceptionInfo;
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- if (getActivity() != null) {
- try {
- etBarCode.setText(null);
- CommonUtil.editTextGetFocus(etBarCode);
- CommonUtil.makeNotice();
- CommonUtil.toastNoRepeat(getActivity(), errorStr);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- break;
- default:
- break;
- }
- }
- };
- private okhttp3.Request mRequest;
- private OkHttpClient mOkHttpClient;
- private int mFocusId;
- private String currentBarcode;
- private boolean isConnected = false;
- private String mOldAddress = "";
- private int mPrintDpi = 203;
- private boolean isPrinting = false;
- private TextView tvPiInoutno;
- private TextView tvPdWhcode;
- private ClearableEditText etBarCode;
- private Button btnConfirm;
- private RadioGroup mCollectTypeRadioGroup;
- private RadioButton mBarcodeRadioButton;
- private RadioButton mBoxRadioButton;
- private TableLayout mBarcodeTableLayout;
- private TableLayout mBoxTableLayout;
- private TextView tvBarcodeCollectionSuccess;
- private TextView mCollectBarcodeTv;
- private TextView mCollectBarRemainTv;
- private TextView tvBoxCollectionSuccess;
- private TextView mCollectBoxTv;
- private TextView mCollectBoxNumTv;
- private TextView mCollectBoxrProdcodeTv;
- private TextView mCollectBoxWhcodeTv;
- private Button mCollectModelBtn;
- private TextView mtypeNameTv;
- private Spinner mTypeSpinner;
- private TextView mMaterialInforTextView;
- private TextView mCollectResultTextView;
- private TextView mCollectBarProdcodeTv;
- private CheckBox special_check;
- private TextView text_finishno;
- private Button btn_startoutku;
- private Button btn_deleteoutku;
- private Spinner masterSpinner;
- @Override
- protected int getLayout() {
- return R.layout.fragment_agviocout_make_material_oper;
- }
- @Override
- protected void initViews() {
- tvPiInoutno = root.findViewById(R.id.tv_pi_inoutno);
- tvPdWhcode = root.findViewById(R.id.tv_pd_whcode);
- etBarCode = root.findViewById(R.id.et_bar_code);
- btnConfirm = root.findViewById(R.id.btn_confirm);
- mCollectBarProdcodeTv = root.findViewById(R.id.iocout_bar_prodcode_tv);
- mCollectTypeRadioGroup = root.findViewById(R.id.iocout_collect_rg);
- mBarcodeRadioButton = root.findViewById(R.id.iocout_collect_barcode_rb);
- mBoxRadioButton = root.findViewById(R.id.iocout_collect_box_rb);
- mBarcodeTableLayout = root.findViewById(R.id.iocout_collect_barcode_tl);
- mBoxTableLayout = root.findViewById(R.id.iocout_collect_box_tl);
- tvBarcodeCollectionSuccess = root.findViewById(R.id.tv_barcode_collection_success);
- mCollectBarcodeTv = root.findViewById(R.id.iocout_bar_code_tv);
- mCollectBarRemainTv = root.findViewById(R.id.iocout_bar_remain_tv);
- tvBoxCollectionSuccess = root.findViewById(R.id.tv_box_collection_success);
- mCollectBoxTv = root.findViewById(R.id.iocout_box_tv);
- mCollectBoxNumTv = root.findViewById(R.id.iocout_box_num_tv);
- mCollectBoxrProdcodeTv = root.findViewById(R.id.iocout_box_prodcode_tv);
- mCollectBoxWhcodeTv = root.findViewById(R.id.iocout_box_whcode_tv);
- mCollectModelBtn = root.findViewById(R.id.iocout_collect_model_btn);
- mtypeNameTv = root.findViewById(R.id.iocout_material_type_tv);
- mTypeSpinner = root.findViewById(R.id.iocout_material_type_sp);
- mMaterialInforTextView = root.findViewById(R.id.iocout_next_material_information);
- mCollectResultTextView = root.findViewById(R.id.iocout_collect_result);
- special_check = root.findViewById(R.id.special_check);
- btn_startoutku = root.findViewById(R.id.btn_startoutku);
- btn_deleteoutku = root.findViewById(R.id.btn_deleteoutku);
- masterSpinner = (Spinner) root.findViewById(R.id.sp_login);
- text_finishno = root.findViewById(R.id.text_finishno);
- ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(getString(R.string.avgout_material_collect));
- // ((FunctionActivity) getActivity()).fragment = new IOCOutMakeMaterialOper();
- ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
- ((FunctionActivity) getActivity()).setScanIvVisible(true);
- mScanImageView = (ImageView) mActivity.findViewById(R.id.btn_actionbar_scan_iv);
- mDbManager = new DBManager(getActivity().getApplicationContext());
- mOkHttpClient = new OkHttpClient.Builder()
- .sslSocketFactory(FileUtils.createSSLSocketFactory(), new FileUtils.TrustAllCerts())
- .hostnameVerifier(new FileUtils.TrustAllHostnameVerifier())
- .connectTimeout(30, TimeUnit.SECONDS)
- .readTimeout(30, TimeUnit.SECONDS).build();
- mProdOutType = SharedPreUtil.getString(getActivity().getApplicationContext(), Constants.FLAG.PRODOUT_TYPE_CACHE, "byBatch");
- //获取上一个Fragment(即IOCOutMakeMaterial里面的数据)
- Bundle bundle = getArguments();
- if (bundle != null) {
- pi_inoutno = bundle.getString("pi_inoutno");
- pd_whcode = bundle.getString("pd_whcode") == null ? "" : bundle.getString("pd_whcode");
- pi_id = bundle.getString("pi_id");
- isMultiple = bundle.getBoolean("isMultiple");
- }
- ButterKnife.bind(this, root);
- mResults = new ArrayList<>();
- if (mCollectModel == 1) {
- mCollectModelBtn.setText("在线");
- } else if (mCollectModel == 0) {
- mCollectModelBtn.setText("离线");
- }
- //条码输入框获取焦点
- etBarCode.requestFocus();
- tvPiInoutno.setText(pi_inoutno);
- tvPdWhcode.setText(pd_whcode);
- mCollectTypes = new ArrayList<>();
- mCollectTypes.add("条码号");
- mCollectTypes.add("外箱号");
- mTypeSpAdapter = new ArrayAdapter<>(getActivity(), R.layout.layout_myspinner, mCollectTypes);
- mTypeSpAdapter.setDropDownViewResource(R.layout.layout_myspinner_dropdown);
- mTypeSpinner.setAdapter(mTypeSpAdapter);
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.GONE);
- mCollectType = SharedPreUtil.getString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBarcode");
- if (mCollectType != null) {
- //取消箱号采集
- if (mCollectType.equals("byBarcode")) {
- mCollectType = "byBarcode";
- CommonUtil.setSpinnerItemSelectedByValue(mTypeSpinner, "条码号");
- etBarCode.setHint(R.string.please_collect_barcode);
- mtypeNameTv.setText("条码");
- } else if (mCollectType.equals("byBatchcode")) {
- CommonUtil.setSpinnerItemSelectedByValue(mTypeSpinner, "箱号");
- etBarCode.setHint("请采集箱号");
- mtypeNameTv.setText("箱号");
- }
- }
- btnActionbarRight = (Button) getActivity().findViewById(R.id.btn_actionbar_more);
- isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
- mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
- mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
- special_check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- boolean checked = special_check.isChecked();
- Log.e("checked",checked+"");
- }
- });
- btn_startoutku.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- startchuku();
- }
- });
- btn_deleteoutku.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- new AlertDialog.Builder(getActivity()).setTitle("提示")
- .setMessage("确认结束出库?")
- .setPositiveButton("确定", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- stopchuku();
- }
- })
- .setNegativeButton("取消", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- })
- .show();
- }
- });
- masterFuncList = new ArrayList<String>();
- getSpinnerData();
- }
- private void getSpinnerData(){
- masterFuncList.clear();
- // com.alibaba.fastjson.JSONArray dataArrayone = FastjsonUtil.getJSONArray(o.toString(),"items");
- // if (dataArrayone == null|| dataArrayone.size() == 0){
- // CommonUtil.toastNoRepeat(mActivity,"未搜索到匹配数据");
- // }
- // for(Object index:dataArrayone){
- // com.alibaba.fastjson.JSONObject data = (com.alibaba.fastjson.JSONObject) index;
- // masterFuncList.add(data.getString("WC_NAME"));
- // }
- masterFuncList.add("无");
- masterFuncList.add("五虎上将");
- masterFuncList.add("2");
- masterFuncList.add("3");
- masterFuncList.add("4");
- masterFuncList.add("5");
- masterFuncList.add("6");
- adapter = new ArrayAdapter(mActivity, R.layout.item_spinner, R.id.text_spinner, masterFuncList);
- masterSpinner.setAdapter(adapter);
- }
- @Override
- protected void initEvents() {
- masterSpinner.setOnItemSelectedListener(this);
- btnActionbarRight.setOnClickListener(this);
- etBarCode.addTextChangedListener(watcher);
- mCollectTypeRadioGroup.setOnCheckedChangeListener(this);
- mCollectModelBtn.setOnClickListener(this);
- mScanImageView.setOnClickListener(this);
- etBarCode.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- if (actionId == EditorInfo.IME_ACTION_SEND
- || actionId == EditorInfo.IME_ACTION_DONE
- || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
- confirmEvent();
- return true;
- }
- return false;
- }
- });
- mtypeNameTv.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String typeName = mtypeNameTv.getText().toString().trim();
- if ("条码".equals(typeName)) {
- changeToTypeBatch();
- } else if ("箱号".equals(typeName)) {
- changeToTypeBarcode();
- }
- }
- });
- mTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- if (mCollectTypes != null) {
- if (mCollectTypes.get(position).equals("条码号")) {
- changeToTypeBarcode();
- } else if (mCollectTypes.get(position).equals("外箱号")) {
- changeToTypeBatch();
- }
- }
- }
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- }
- });
- }
- /**
- * 开始出库
- */
- private void startchuku(){
- progressDialog.show();
- String url = GloableParams.ADDRESS_PAD_STARTPRODOUT+ "?id="+pi_id;
- PdaApplication.mRequestQueue.cancelAll(TAG);
- mCollectTypeRadioGroup.setEnabled(false);
- jsonRequest = new JsonObjectRequest(Request.Method.POST, url, null, new Response.Listener<JSONObject>() {
- @Override
- public void onResponse(JSONObject jsonObject) {
- progressDialog.dismiss();
- try {
- Log.e("jsonObject",jsonObject.toString());
- JSONObject dataObject = jsonObject.optJSONObject("data");
- JSONObject dataData = dataObject.optJSONObject("next");
- Object log = dataObject.get("log");
- String bar_prodcode = dataData.getString("PD_PRODCODE");//编号
- String pr_detail = dataData.getString("PR_DETAIL");//名称
- String pr_spec = dataData.getString("PR_SPEC");//规格
- String pd_outqty = dataData.getString("PD_OUTQTY");//出库数量
- String pd_restqty = dataData.getString("PD_RESTQTY");
- String pr_zxbzs = dataData.getString("PR_ZXBZS");
- String bar_remain = dataData.getString("BAR_REMAIN");
- String dc = dataData.getString("DC");
- mCollectResultTextView.setVisibility(View.VISIBLE);
- mCollectResultTextView.setText(log.toString());
- mMaterialInforTextView.setText("物料:"+bar_prodcode
- +"名称:"+pr_detail
- +"规格:"+pr_spec
- +"未备料数:"+pd_restqty
- +"批数量:"+bar_remain
- +"DC:"+dc
- );
- getNextMaterialInfo();
- // JSONObject messageObject = dataObject.getJSONObject("barcode");
- CommonUtil.toastNoRepeat(mActivity, "货架点亮成功");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- progressDialog.dismiss();
- if (getActivity() != null) {
- mCollectTypeRadioGroup.setEnabled(true);
- CommonUtil.editTextGetFocus(etBarCode);
- String errorToast = CommonUtil.showErrorToast(volleyError, true);
- mCollectResultTextView.setVisibility(View.VISIBLE);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.red));
- mCollectResultTextView.setText(errorToast);
- }
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- };
- jsonRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- jsonRequest.setTag(TAG);
- PdaApplication.mRequestQueue.add(jsonRequest);
- }
- /**
- * 结束出库
- */
- private void stopchuku(){
- progressDialog.show();
- String url = GloableParams.ADDRESS_COMMON_ENDPRODOUT+ "?id="+pi_id;
- PdaApplication.mRequestQueue.cancelAll(TAG);
- mCollectTypeRadioGroup.setEnabled(false);
- jsonRequest = new JsonObjectRequest(Request.Method.POST, url, null, new Response.Listener<JSONObject>() {
- @Override
- public void onResponse(JSONObject jsonObject) {
- progressDialog.dismiss();
- try {
- Log.e("jsonObject",jsonObject.toString());
- // JSONObject dataObject = jsonObject.optJSONObject("data");
- String data = FastjsonUtil.getText(jsonObject.toString(), "data");
- mCollectResultTextView.setVisibility(View.VISIBLE);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.blue));
- mCollectResultTextView.setText(data.toString());
- // JSONObject messageObject = dataObject.getJSONObject("barcode");
- CommonUtil.toastNoRepeat(mActivity, data.toString());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- progressDialog.dismiss();
- if (getActivity() != null) {
- mCollectTypeRadioGroup.setEnabled(true);
- CommonUtil.editTextGetFocus(etBarCode);
- String errorToast = CommonUtil.showErrorToast(volleyError, true);
- mCollectResultTextView.setVisibility(View.VISIBLE);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.red));
- mCollectResultTextView.setText(errorToast);
- }
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- };
- jsonRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- jsonRequest.setTag(TAG);
- PdaApplication.mRequestQueue.add(jsonRequest);
- }
- /**
- * 采集方式切换成箱号
- */
- private void changeToTypeBatch() {
- etBarCode.setHint("请采集箱号");
- mtypeNameTv.setText("箱号");
- SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBatchcode");
- mCollectType = "byBatchcode";
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.GONE);
- mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno);
- if (mResults != null && mResults.size() == 4) {
- tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
- tvBoxCollectionSuccess.setText("采集成功");
- mCollectBoxTv.setText(mResults.get(0));
- mCollectBoxNumTv.setText(mResults.get(1));
- mCollectBoxrProdcodeTv.setText(mResults.get(2));
- mCollectBoxWhcodeTv.setText(mResults.get(3));
- } else {
- tvBoxCollectionSuccess.setVisibility(View.GONE);
- mCollectBoxTv.setText(null);
- mCollectBoxNumTv.setText(null);
- mCollectBoxrProdcodeTv.setText(null);
- mCollectBoxWhcodeTv.setText(null);
- }
- }
- /**
- * 采集方式切换成条码号
- */
- private void changeToTypeBarcode() {
- etBarCode.setHint(R.string.please_collect_barcode);
- mtypeNameTv.setText("条码");
- SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBarcode");
- mCollectType = "byBarcode";
- // mBarcodeTableLayout.setVisibility(View.VISIBLE);
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.GONE);
- mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno);
- if (mResults != null && mResults.size() == 3) {
- tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
- tvBarcodeCollectionSuccess.setText("采集成功");
- mCollectBarcodeTv.setText(mResults.get(0));
- mCollectBarRemainTv.setText(mResults.get(1));
- mCollectBarProdcodeTv.setText(mResults.get(2));
- } else {
- tvBarcodeCollectionSuccess.setVisibility(View.GONE);
- mCollectBarcodeTv.setText(null);
- mCollectBarRemainTv.setText(null);
- mCollectBarProdcodeTv.setText(null);
- }
- }
- @Override
- protected void initDatas() {
- if (CommonUtil.isNetWorkConnected(mActivity)) {
- getNextMaterialInfo();
- } else {
- CommonUtil.toastNoRepeat(mActivity, getString(R.string.net_not_connect));
- mMaterialInforTextView.setText(getString(R.string.net_not_connect));
- }
- }
- /**
- * 获取下一采集货品信息
- */
- private void getNextMaterialInfo() {
- progressDialog.show();
- String url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH + "?pi_id=" + pi_id + "&pd_whcode=" + pd_whcode;
- // if (!isMultiple) {
- if (false) {
- if (mProdOutType.equals("byProdcode")) {
- url = GloableParams.ADDRESS_OUT_GET_NEXT_PRODCODE + "?pi_id=" + pi_id + "&pd_whcode=" + pd_whcode;
- } else if (mProdOutType.equals("byBatch")) {
- url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH + "?pi_id=" + pi_id + "&pd_whcode=" + pd_whcode;
- }
- } else {
- url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH_DEAL + "?ids=" + pi_id;
- if (mProdOutType.equals("byProdcode")) {
- url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH_DEAL + "?ids=" + pi_id;
- } else if (mProdOutType.equals("byBatch")) {
- url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH_DEAL + "?ids=" + pi_id;
- }
- }
- PdaApplication.mRequestQueue.cancelAll(TAG + "getnext");
- mStringRequest = new StringRequest(Request.Method.GET, url,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- progressDialog.dismiss();
- Log.i("materialinfo", s);
- MaterialInformationBean materialInformationBean = JsonTools.parseJsonToBean(s, MaterialInformationBean.class);
- if (materialInformationBean != null && materialInformationBean.getData() != null) {
- String materialInfo =
- "型号:" + (materialInformationBean.getData().getPR_ORISPECCODE() == null ? "" : materialInformationBean.getData().getPR_ORISPECCODE())
- + "物料:" + (materialInformationBean.getData().getPD_PRODCODE() == null ? "" : materialInformationBean.getData().getPD_PRODCODE())
- + "; 名称规格:" + (materialInformationBean.getData().getPR_DETAIL() == null ? "" : materialInformationBean.getData().getPR_DETAIL())
- + " " + (materialInformationBean.getData().getPR_SPEC() == null ? "" : materialInformationBean.getData().getPR_SPEC())
- + "; 未备料数:" + (materialInformationBean.getData().getPD_RESTQTY() == null ? "" : materialInformationBean.getData().getPD_RESTQTY())
- + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getData().getBAR_REMAIN()))
- + "; 仓位:" + (materialInformationBean.getData().getBAR_LOCATION() == null ? "" : materialInformationBean.getData().getBAR_LOCATION())
- + "; DC:" + (materialInformationBean.getData().getDC() == null ? "" : materialInformationBean.getData().getDC());
- if (materialInformationBean.getData().getPD_BATCHCODE() != null) {
- materialInfo = materialInfo + "; 批号:" + materialInformationBean.getData().getPD_BATCHCODE();
- }
- if (mMaterialInforTextView != null)
- mMaterialInforTextView.setText(materialInfo);
- } else {
- if (mMaterialInforTextView != null)
- mMaterialInforTextView.setText("该出库单当前的仓库已经完成备料");
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- progressDialog.dismiss();
- String errorMsg = CommonUtil.showErrorToast(volleyError);
- if (mMaterialInforTextView != null)
- mMaterialInforTextView.setText(errorMsg);
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- };
- mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- mStringRequest.setTag(TAG + "getnext");
- PdaApplication.mRequestQueue.add(mStringRequest);
- }
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- return false;
- }
- // 材料出库确认
- private IOCOutMakeMaterialOperMsd iocOutMakeMaterialOperMsd;
- // 需要拆分材料
- private IOCOutmakeMaterialSplitBean mIocoutMaterialSplitBean;
- /**
- * 在线模式确认按钮提交事件
- */
- private void barcodeEnterEvent(boolean msdcheck, boolean datecheck) {
- progressDialog.show();
- boolean checkeds = special_check.isChecked();
- // currentBarcode = etBarCode.getText().toString().trim();
- String url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
- + "?barcode=" + currentBarcode
- + (isMultiple ? "&ids=" : "&ids=")
- + pi_id + "&whcode=" + pd_whcode
- + "&type=barcode&msdcheck=" + msdcheck
- + "&datecheck=" + datecheck
- +"&ifspecial="+checkeds;
- try {
- if (mProdOutType != null && mCollectType != null) {
- if (mProdOutType.equals("byProdcode")) {
- if (mCollectType.equals("byBarcode")) {
- url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
- + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
- + (isMultiple ? "&ids=" : "&ids=")
- + pi_id + "&whcode=" + pd_whcode
- + "&type=barcode&msdcheck=" + msdcheck
- + "&datecheck=" + datecheck
- +"&ifspecial="+checkeds;
- } else if (mCollectType.equals("byBatchcode")) {
- url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
- + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
- + (isMultiple ? "&ids=" : "&ids=")
- + pi_id + "&whcode=" + pd_whcode
- + "&type=boxcode&msdcheck=" + msdcheck
- + "&datecheck=" + datecheck
- +"&ifspecial="+checkeds;
- }
- } else if (mProdOutType.equals("byBatch")) {
- if (mCollectType.equals("byBarcode")) {
- url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
- + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
- + (isMultiple ? "&ids=" : "&ids=")
- + pi_id + "&whcode=" + pd_whcode
- + "&type=barcode&msdcheck=" + msdcheck
- + "&datecheck=" + datecheck
- +"&ifspecial="+checkeds;
- } else if (mCollectType.equals("byBatchcode")) {
- url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
- + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
- + (isMultiple ? "&ids=" : "&ids=")
- + pi_id + "&whcode=" + pd_whcode
- + "&type=boxcode&msdcheck=" + msdcheck
- + "&datecheck=" + datecheck
- +"&ifspecial="+checkeds;
- }
- }
- }
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- LogUtil.i("iocouturl", url);
- etBarCode.setText(null);
- PdaApplication.mRequestQueue.cancelAll(TAG);
- mCollectTypeRadioGroup.setEnabled(false);
- jsonRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
- @Override
- public void onResponse(JSONObject jsonObject) {
- progressDialog.dismiss();
- mResults = new ArrayList<>();
- mCollectTypeRadioGroup.setEnabled(true);
- LogUtil.e("!!!ok", jsonObject.toString());
- try {
- JSONObject dataObject = jsonObject.optJSONObject("data");
- if (dataObject == null) {
- CommonUtil.toastNoRepeat(mActivity, "采集结果获取失败!");
- return;
- }
- etBarCode.setText(null);
- JSONObject messageObject = dataObject.getJSONObject("barcode");
- if (messageObject.has("IFOVER") && messageObject.optBoolean("IFOVER")) {
- new AlertDialog.Builder(mActivity)
- .setMessage("采集条码[" + messageObject.optString("BAR_CODE") + "]有效期已过,是否继续采集?")
- .setNegativeButton(R.string.cancel, null)
- .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- dialogInterface.dismiss();
- barcodeEnterEvent(false, false);
- }
- }).create().show();
- } else if (messageObject.has("ISMSD")) {
- if (messageObject.optBoolean("ISMSD")) {
- //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
- iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
- if (iocOutMakeMaterialOperMsd != null) {
- Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
- mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
- mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
- showDewPopupWindow();
- }
- } else {
- mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
- mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
- mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
- if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
- spliteBarcode(currentBarcode, mBarRemain, mRestqty);
- }
- }
- } else {
- mCollectResultTextView.setVisibility(View.VISIBLE);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
- mCollectResultTextView.setText(null);
- // JSONArray listArray = dataObject.optJSONArray("nolist");
- if (mCollectType.equals("byBarcode") || mCollectType.equals("byBatchcode")) {
- String barcodeResult = "采集成功!\n"
- // + JsonUtils.optStringNotNull(dataObject, "finishno")
- + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
- + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
- // + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
- + ";\n料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
- + ";\n名称规格:" + messageObject.optString("PR_DETAIL")+";";
- // + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
- // + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
- // if (listArray != null && listArray.length() > 0) {
- // for (int i = 0; i < listArray.length(); i++) {
- // JSONObject listObject = listArray.optJSONObject(i);
- // barcodeResult = barcodeResult
- // + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
- // + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
- // + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
- // }
- // }
- String finishno = JsonUtils.optStringNotNull(dataObject, "finishno");
- if (!finishno.isEmpty()){
- text_finishno.setVisibility(View.VISIBLE);
- text_finishno.setText(finishno);
- }else {
- text_finishno.setVisibility(View.GONE);
- }
- mCollectResultTextView.setText(barcodeResult);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.GONE);
- tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
- tvBarcodeCollectionSuccess.setText("采集成功");
- mResult1 = messageObject.optString("BAR_CODE");
- mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
- mResult3 = messageObject.optString("BAR_PRODCODE");
- mResults.add(mResult1);
- mResults.add(mResult2);
- mResults.add(mResult3);
- mCollectBarcodeTv.setText(mResult1);
- mCollectBarRemainTv.setText(mResult2);
- mCollectBarProdcodeTv.setText(mResult3);
- PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
- } else if (false) {
- String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
- + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
- + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
- + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
- + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
- + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
- + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
- // if (listArray != null && listArray.length() > 0) {
- // for (int i = 0; i < listArray.length(); i++) {
- // JSONObject listObject = listArray.optJSONObject(i);
- // boxResult = boxResult
- // + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
- // + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
- // + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
- // }
- // }
- mCollectResultTextView.setText(boxResult);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.GONE);
- tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
- tvBoxCollectionSuccess.setText("采集成功");
- mResult1 = messageObject.optString("PA_OUTBOXCODE");
- mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
- mResult3 = messageObject.optString("PA_PRODCODE");
- mResult4 = messageObject.optString("PA_WHCODE");
- mResults.add(mResult1);
- mResults.add(mResult2);
- mResults.add(mResult3);
- mResults.add(mResult4);
- mCollectBoxTv.setText(mResult1);
- mCollectBoxNumTv.setText(mResult2);
- mCollectBoxrProdcodeTv.setText(mResult3);
- mCollectBoxWhcodeTv.setText(mResult4);
- PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
- }
- CommonUtil.toastNoRepeat(getActivity(), "采集成功");
- Object next = jsonObject.getJSONObject("data").get("next");
- if (next != null && !"null".equals(next.toString())) {
- JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
- MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
- if (materialInformationBean != null) {
- String materialInfo =
- "型号:" + (materialInformationBean.getPR_ORISPECCODE() == null ? "" : materialInformationBean.getPR_ORISPECCODE())
- + "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
- + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
- + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
- + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
- + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
- + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
- if (materialInformationBean.getPD_BATCHCODE() != null) {
- materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
- }
- mMaterialInforTextView.setText(materialInfo);
- }
- } else {
- mMaterialInforTextView.setText("该出库单已经完成备料");
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- progressDialog.dismiss();
- if (getActivity() != null) {
- mCollectTypeRadioGroup.setEnabled(true);
- CommonUtil.editTextGetFocus(etBarCode);
- String errorToast = CommonUtil.showErrorToast(volleyError, true);
- mCollectResultTextView.setVisibility(View.VISIBLE);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.red));
- mCollectResultTextView.setText(errorToast);
- }
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- };
- jsonRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- jsonRequest.setTag(TAG);
- PdaApplication.mRequestQueue.add(jsonRequest);
- }
- /**
- * 创建PopupWindow
- */
- private PopupWindow popupWindow;
- private AdapterPopupWindow adapterPopupWindow;
- private Button dewOperConfirmBtn, btnDewCancel;
- protected void showDewPopupWindow() {
- try {
- LayoutInflater inflater = LayoutInflater.from(getActivity());
- View contentView = inflater.inflate(R.layout.popupwindow_ioc_out_make_material_oper, null);
- ListView dewOperLv = (ListView) contentView.findViewById(R.id.dew_oper_lv);
- ((TextView) contentView.findViewById(R.id.tv_ms_level)).setText(iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getMS_LEVEL());
- ((TextView) contentView.findViewById(R.id.tv_status)).setText(iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getSTATUS());
- if (iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getMS_RESTTIME() == -1) {
- ((TextView) contentView.findViewById(R.id.tv_ms_resttime)).setText("999");
- } else {
- ((TextView) contentView.findViewById(R.id.tv_ms_resttime)).setText(iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getMS_RESTTIME() + "");
- }
- dewOperConfirmBtn = (Button) contentView.findViewById(R.id.dew_oper_confirm_btn);
- btnDewCancel = (Button) contentView.findViewById(R.id.btn_dew_cancel);
- dewOperConfirmBtn.setOnClickListener(this);
- btnDewCancel.setOnClickListener(this);
- adapterPopupWindow = new AdapterPopupWindow(getActivity(), R.layout.item_list_ioc_out_make_material_oper, iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getLog());
- dewOperLv.setAdapter(adapterPopupWindow);
- //item 的点击事件
- dewOperLv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
- /* IOCOutMakeMaterialSubmit.Data data = dataListPopupWindow.get(i);
- dataList.add(data);
- adapterListView.notifyDataSetChanged();
- closePopupWindow();
- reset();*/
- }
- });
- // PopupWindow实例化
- popupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT, true);
- popupWindow.setAnimationStyle(R.style.MenuAnimationFade);
- // 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
- popupWindow.showAtLocation(btnConfirm, Gravity.CENTER, 0, 0);
- popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
- @Override
- public void onDismiss() {
- closePopupWindow();
- }
- });
- //获取最底层窗口的参数,背景变灰色效果
- CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
- } catch (Exception e) {
- }
- }
- @Override
- public void onCheckedChanged(RadioGroup group, int checkedId) {
- switch (checkedId) {
- case R.id.iocout_collect_barcode_rb:
- etBarCode.setHint(R.string.please_collect_barcode);
- mtypeNameTv.setText("条码号");
- SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBarcode");
- mCollectType = "byBarcode";
- mBarcodeTableLayout.setVisibility(View.VISIBLE);
- mBoxTableLayout.setVisibility(View.GONE);
- mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno);
- if (mResults != null && mResults.size() == 3) {
- tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
- tvBarcodeCollectionSuccess.setText("采集成功");
- mCollectBarcodeTv.setText(mResults.get(0));
- mCollectBarRemainTv.setText(mResults.get(1));
- mCollectBarProdcodeTv.setText(mResults.get(2));
- } else {
- tvBarcodeCollectionSuccess.setVisibility(View.GONE);
- mCollectBarcodeTv.setText(null);
- mCollectBarRemainTv.setText(null);
- mCollectBarProdcodeTv.setText(null);
- }
- break;
- case R.id.iocout_collect_box_rb:
- etBarCode.setHint(R.string.please_collect_box);
- mtypeNameTv.setText("外箱号");
- SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBatchcode");
- mCollectType = "byBatchcode";
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.VISIBLE);
- mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno);
- if (mResults != null && mResults.size() == 4) {
- tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
- tvBoxCollectionSuccess.setText("采集成功");
- mCollectBoxTv.setText(mResults.get(0));
- mCollectBoxNumTv.setText(mResults.get(1));
- mCollectBoxrProdcodeTv.setText(mResults.get(2));
- mCollectBoxWhcodeTv.setText(mResults.get(3));
- } else {
- mCollectBoxTv.setText(null);
- mCollectBoxNumTv.setText(null);
- mCollectBoxrProdcodeTv.setText(null);
- mCollectBoxWhcodeTv.setText(null);
- }
- break;
- }
- }
- @Override
- public void onSuccess(int flag, Object o) throws Exception {
- if (flag == FLAG_CONFIRM_POST) {
- progressDialog.dismiss();
- CommonUtil.toastNoRepeat(mActivity, "过账成功");
- }
- }
- @Override
- public void onFail(int flag, String failStr) throws Exception {
- if (flag == FLAG_CONFIRM_POST) {
- progressDialog.dismiss();
- CommonUtil.toastNoRepeat(mActivity, failStr);
- }
- }
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- //获得master的name
- maFunName = masterFuncList.get(position);
- LogUtil.i("maname",maFunName);
- }
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- }
- /**
- * popupWindow 设置适配器
- */
- private class AdapterPopupWindow extends BaseAdapter {
- private int resourceId;
- private List<IOCOutMakeMaterialOperMsd.DataBean.BarcodeBean.MsdBean.LogBean> objects;
- private Context mContext;
- public AdapterPopupWindow(Context context, int resource, List<IOCOutMakeMaterialOperMsd.DataBean.BarcodeBean.MsdBean.LogBean> objects) {
- resourceId = resource;
- this.objects = objects;
- mContext = context;
- }
- @Override
- public int getCount() {
- return objects == null ? 0 : objects.size();
- }
- @Override
- public Object getItem(int position) {
- return objects == null ? null : objects.get(position);
- }
- @Override
- public long getItemId(int position) {
- return position;
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder viewHolder = null;
- if (convertView == null) {
- convertView = View.inflate(mContext, resourceId, null);
- viewHolder = new ViewHolder();
- viewHolder.dateTextView = (TextView) convertView.findViewById(R.id.tv_date);
- viewHolder.lifeTimeTextView = (TextView) convertView.findViewById(R.id.tv_lifetime);
- viewHolder.actionTextView = (TextView) convertView.findViewById(R.id.tv_action);
- viewHolder.manTextView = (TextView) convertView.findViewById(R.id.tv_man);
- convertView.setTag(viewHolder);
- } else {
- viewHolder = (ViewHolder) convertView.getTag();
- }
- viewHolder.actionTextView.setText(objects.get(position).getMS_ACTION());
- viewHolder.dateTextView.setText(objects.get(position).getMS_DATE() + "");
- viewHolder.lifeTimeTextView.setText(objects.get(position).getMS_LIFETIME() + "");
- viewHolder.manTextView.setText(objects.get(position).getMS_MAN());
- return convertView;
- }
- }
- class ViewHolder {
- TextView dateTextView;
- TextView lifeTimeTextView;
- TextView actionTextView;
- TextView manTextView;
- }
- @Override
- public void onClick(View view) {
- switch (view.getId()) {
- case R.id.btn_actionbar_more:
- View materialOutMoreView = View.inflate(getActivity(), R.layout.pop_material_out_menu, null);
- Button stockTaskBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_1);
- Button stockAlreadyBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_2);
- Button stockRevokeBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_3);
- Button stockModifyBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_4);
- Button stockSpecialBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_5);
- Button passBillBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_6);
- Button stockDataSummary = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_7);
- stockTaskBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closeListPopupWindow();
- ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
- ((FunctionActivity) getActivity()).setScanIvVisible(false);
- if (isMultiple) {
- clickToFragment(new MaterialOutStockTaskMultipleFragment());
- } else {
- clickToFragment(new MaterialOutStockTaskMultipleFragment());
- // clickToFragment(new MaterialOutStockTaskFragment());
- }
- }
- });
- stockDataSummary.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closeListPopupWindow();
- ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
- ((FunctionActivity) getActivity()).setScanIvVisible(false);
- clickToFragment(new StockDataSummaryFragment());
- }
- });
- stockAlreadyBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closeListPopupWindow();
- ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
- ((FunctionActivity) getActivity()).setScanIvVisible(false);
- clickToFragment(new MaterialOutStockAlreadyFragment());
- }
- });
- stockRevokeBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closeListPopupWindow();
- ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
- // ((FunctionActivity) getActivity()).setScanIvVisible(false);
- clickToFragment(new MaterialOutRevocationStockFragment());
- }
- });
- stockModifyBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closeListPopupWindow();
- ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
- // ((FunctionActivity) getActivity()).setScanIvVisible(false);
- clickToFragment(new ModifyQuantityOutFragment());
- }
- });
- stockSpecialBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closeListPopupWindow();
- ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
- // ((FunctionActivity) getActivity()).setScanIvVisible(false);
- clickToFragment(new SpecialMaterialOutFragment());
- }
- });
- passBillBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- closeListPopupWindow();
- new AlertDialog.Builder(mActivity)
- .setMessage("确认将单据过账?")
- .setNegativeButton(R.string.cancel, null)
- .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- dialogInterface.dismiss();
- progressDialog.show();
- VolleyRequest.getInstance().stringRequest(mStringRequest,
- new HttpParams.Builder()
- .url(GloableParams.ADDRESS_INMATERIAL_CONFIRMPOST)
- .method(Request.Method.POST)
- .addParam("piid", pi_id)
- .tag(TAG + "confirmpost")
- .flag(FLAG_CONFIRM_POST).build(),
- 30 * 1000, AGVIOCOutMakeMaterialOper.this);
- }
- }).create().show();
- }
- });
- listPopupWindow = new PopupWindow(materialOutMoreView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
- listPopupWindow.setBackgroundDrawable(new BitmapDrawable());
- listPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
- @Override
- public void onDismiss() {
- closeListPopupWindow();
- }
- });
- CommonUtil.setBackgroundAlpha(getActivity(), 0.5f);
- listPopupWindow.showAsDropDown(btnActionbarRight);
- /*View materialOutMoreView = View.inflate(getActivity(), R.layout.popupwindow_material_out_listview, null);
- Button hadCollectBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_1);
- Button noCollectBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_2);
- Button reCollectBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_3);
- Button noSubmitBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_4);
- if (mCollectModel == 1) {
- noSubmitBtn.setVisibility(View.GONE);
- } else {
- noSubmitBtn.setVisibility(View.VISIBLE);
- }
- hadCollectBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closeListPopupWindow();
- ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
- clickToFragment(new CollectAlreadyFragment());
- }
- });
- noCollectBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closeListPopupWindow();
- ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
- clickToFragment(new CollectNotFragment());
- }
- });
- reCollectBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closeListPopupWindow();
- progressDialog.show();
- mDbManager.deleteFromBarcodeIo(new String[]{pi_id, pd_whcode}, "LBI_PIID=? and LBI_WHCODE=?");
- getAgainEvent();
- }
- });
- noSubmitBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- closeListPopupWindow();
- ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
- clickToFragment(new SubmitNotFragment());
- }
- });
- listPopupWindow = new PopupWindow(materialOutMoreView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
- // popupWindow.setAnimationStyle(R.style.MenuAnimationFade);
- listPopupWindow.setBackgroundDrawable(new BitmapDrawable());
- listPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
- @Override
- public void onDismiss() {
- closeListPopupWindow();
- }
- });
- CommonUtil.setBackgroundAlpha(getActivity(), 0.5f);
- listPopupWindow.showAsDropDown(btnActionbarRight);*/
- break;
- case R.id.dew_oper_confirm_btn:
- if (iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getSTATUS().equals("在烘烤")) {
- new AlertDialog.Builder(getActivity()).setTitle("提示")
- .setMessage("是否出烤箱?")
- .setPositiveButton("确定", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- popupWindow.dismiss();
- progressDialog.show();
- outOvenEvent();
- }
- })
- .setNegativeButton("取消", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- })
- .show();
- } else {
- double bar_remain = iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN();
- double restqty = iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY();
- if (CommonUtil.doubleCompare(bar_remain, restqty) == 1) {
- spliteBarcode(currentBarcode, bar_remain + "", restqty + "");
- } else {
- closePopupWindow();
- barcodeEnterEvent(true, false);
- }
- }
- break;
- case R.id.btn_dew_cancel:
- //点击取消按钮,关闭窗口
- closePopupWindow();
- // clearAll();
- break;
- case R.id.iocout_collect_model_btn:
- if (mCollectModelBtn.getText().toString().trim().equals("在线")) {
- mCollectModelBtn.setText("离线");
- mCollectModel = 0;
- } else if (mCollectModelBtn.getText().toString().trim().equals("离线")) {
- List<TableLBARCODEIO> allBarcodeIo = new ArrayList<>();
- if (mDbManager.getDb().isOpen()) {
- allBarcodeIo = mDbManager.queryFromBarcodeIo(new String[]{"out", pi_id, pd_whcode}, "inOrOut=? and LBI_PIID=? and LBI_WHCODE=?");
- }
- if (CommonUtil.isNetWorkConnected(getActivity())) {
- if (allBarcodeIo.size() != 0) {
- CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.auto_upload_offline_data));
- submitOfflineData(allBarcodeIo, false);
- } else {
- mCollectModelBtn.setText("在线");
- mCollectModel = 1;
- }
- } else {
- mCollectModelBtn.setText("离线");
- mCollectModel = 0;
- CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
- }
- }
- break;
- case R.id.btn_actionbar_scan_iv:
- if (CameraUtil.hasCamera()) {
- if (root.findFocus() != null) {
- mFocusId = root.findFocus().getId();
- Intent intent = new Intent();
- intent.setClass(mActivity, CaptureActivity.class);
- startActivityForResult(intent, SCAN_BARCODE_CODE);
- }
- } else {
- CommonUtil.toastNoRepeat(mActivity, getString(R.string.no_camera_detected));
- }
- break;
- default:
- break;
- }
- }
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode != Activity.RESULT_OK) {
- return;
- }
- if (requestCode == SCAN_BARCODE_CODE && data != null) {
- if (data.getExtras() != null) {
- String result = data.getExtras().getString(CodeUtils.RESULT_STRING);
- if (mFocusId == R.id.et_bar_code) {
- etBarCode.setText(result);
- etBarCode.setSelection(result.length());
- }
- }
- }
- }
- @Override
- public void onHiddenChanged(boolean hidden) {
- super.onHiddenChanged(hidden);
- if (!hidden) {
- FunctionActivity.setTitle(getResources().getString(R.string.avgout_material_collect));
- ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
- ((FunctionActivity) getActivity()).setScanIvVisible(true);
- mScanImageView.setOnClickListener(this);
- etBarCode.requestFocus();
- isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
- mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
- mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
- } else {
- ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
- ((FunctionActivity) getActivity()).setScanIvVisible(false);
- }
- }
- /**
- * 出烘烤
- */
- private void outOvenEvent() {
- String url = GloableParams.ADDRESS_MSDOUTOVEN + "?code=" + currentBarcode;
- stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- progressDialog.dismiss();
- Toast.makeText(getActivity().getApplicationContext(), "出烘烤成功", Toast.LENGTH_SHORT).show();
- double bar_remain = iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN();
- double restqty = iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY();
- if (CommonUtil.doubleCompare(bar_remain, restqty) == 1) {
- spliteBarcode(currentBarcode, bar_remain + "", restqty + "");
- } else {
- closePopupWindow();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- //显示处理后的错误信息
- progressDialog.dismiss();
- if (volleyError != null && volleyError.networkResponse != null && volleyError.networkResponse.data != null) {
- ErrorMsg errorMsg = JsonTools.parseJsonToBean(new String(volleyError.networkResponse.data), ErrorMsg.class);
- if (errorMsg == null) {
- Toast.makeText(mActivity, "系统错误", Toast.LENGTH_LONG).show();
- } else {
- String exceptionInfo = errorMsg.exceptionInfo;
- if (exceptionInfo.contains("无需出")) {
- Toast.makeText(mActivity, "已出烘烤", Toast.LENGTH_LONG).show();
- } else {
- Toast.makeText(mActivity, "出烘烤失败", Toast.LENGTH_LONG).show();
- // etBarCode.setText("");
- // CommonUtil.editTextGetFocus(etBarCode);
- }
- }
- }
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- String cookie = SharedPreUtil.getString(getActivity().getApplicationContext(), "cookie", null);
- Map<String, String> headers = new HashMap<>();
- headers.put("Cookie", cookie);
- return headers;
- }
- };
- stringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- stringRequest.setTag(TAG);
- PdaApplication.mRequestQueue.add(stringRequest);
- }
- private void spliteBarcode(final String currentBarcode, String barRemain, String restqty) {
- new AlertDialog.Builder(getActivity()).setTitle("提示")
- .setMessage("条码数量(" + barRemain + ")大于剩余需要采集数量(" + restqty + "),确认拆分?")
- .setPositiveButton("确认", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (!CommonUtil.isRepeatClick())
- breakingBtnClickEvent(currentBarcode);
- }
- })
- .setNegativeButton("取消", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- })
- .show();
- }
- /**
- * 分拆批次
- *
- * @param currentBarcode
- */
- private void breakingBtnClickEvent(final String currentBarcode) {
- progressDialog.show();
- String url = isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_BREAK_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_BREAK_DEAL;
- Log.d("breakDeal", url);
- VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
- .url(url)
- .method(Request.Method.POST)
- .addParam("ids", pi_id)
- .addParam("barcode", currentBarcode)
- .addParam("or_remain", mBarRemain)
- .addParam("bar_remain", mRestqty)
- .build(), new HttpCallback() {
- @Override
- public void onSuccess(int flag, Object o) throws Exception {
- progressDialog.dismiss();
- String s = o.toString();
- if (popupWindow != null && popupWindow.isShowing())
- closePopupWindow();
- mResults = new ArrayList<>();
- mCollectTypeRadioGroup.setEnabled(true);
- LogUtil.e("breaking", s);
- try {
- JSONObject jsonObject = new JSONObject(s);
- JSONObject dataObject = jsonObject.optJSONObject("data");
- if (dataObject == null) {
- return;
- }
- JSONObject messageObject = dataObject.optJSONObject("barcode");
- if (messageObject == null) {
- return;
- }
- if (messageObject.has("ISMSD")) {
- if (messageObject.optBoolean("ISMSD")) {
- //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
- iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
- // Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
- mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
- mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
- showDewPopupWindow();
- } else {
- mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
- mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
- mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
- if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
- spliteBarcode(currentBarcode, mBarRemain, mRestqty);
- }
- }
- } else {
- mCollectResultTextView.setVisibility(View.VISIBLE);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
- mCollectResultTextView.setText(null);
- JSONArray listArray = dataObject.optJSONArray("nolist");
- if (mCollectType.equals("byBarcode") || mCollectType.equals("byBatchcode")) {
- String barcodeResult = "采集成功!"
- // + JsonUtils.optStringNotNull(dataObject, "finishno")
- + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
- + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
- // + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
- + ";\n料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
- + ";\n名称规格:" + messageObject.optString("PR_DETAIL");
- // + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC")
- // + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
- if (listArray != null && listArray.length() > 0) {
- // for (int i = 0; i < listArray.length(); i++) {
- // JSONObject listObject = listArray.optJSONObject(i);
- // barcodeResult = barcodeResult
- // + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
- // + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
- // + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
- // }
- //弹出拆分结果弹框
- initBreakPopupWindow(listArray,"1");
- }
- String finishno = JsonUtils.optStringNotNull(dataObject, "finishno");
- if (!finishno.isEmpty()){
- text_finishno.setVisibility(View.VISIBLE);
- text_finishno.setText(finishno);
- }else {
- text_finishno.setVisibility(View.GONE);
- }
- mCollectResultTextView.setText(barcodeResult);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.GONE);
- tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
- tvBarcodeCollectionSuccess.setText("采集成功");
- mResult1 = messageObject.optString("BAR_CODE");
- mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
- mResult3 = messageObject.optString("BAR_PRODCODE");
- mResults.add(mResult1);
- mResults.add(mResult2);
- mResults.add(mResult3);
- mCollectBarcodeTv.setText(mResult1);
- mCollectBarRemainTv.setText(mResult2);
- mCollectBarProdcodeTv.setText(mResult3);
- PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
- } else if (false) {
- String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
- + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
- + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
- + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
- + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
- + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
- + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
- if (listArray != null && listArray.length() > 0) {
- for (int i = 0; i < listArray.length(); i++) {
- JSONObject listObject = listArray.optJSONObject(i);
- boxResult = boxResult
- + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
- + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
- + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
- }
- }
- mCollectResultTextView.setText(boxResult);
- mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.GONE);
- tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
- tvBoxCollectionSuccess.setText("采集成功");
- mResult1 = messageObject.optString("PA_OUTBOXCODE");
- mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
- mResult3 = messageObject.optString("PA_PRODCODE");
- mResult4 = messageObject.optString("PA_WHCODE");
- mResults.add(mResult1);
- mResults.add(mResult2);
- mResults.add(mResult3);
- mResults.add(mResult4);
- mCollectBoxTv.setText(mResult1);
- mCollectBoxNumTv.setText(mResult2);
- mCollectBoxrProdcodeTv.setText(mResult3);
- mCollectBoxWhcodeTv.setText(mResult4);
- PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
- }
- CommonUtil.toastNoRepeat(getActivity(), "采集成功");
- Object next = jsonObject.getJSONObject("data").get("next");
- if (next != null && !"null".equals(next.toString())) {
- JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
- MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
- if (materialInformationBean != null) {
- String materialInfo =
- "型号:" + (materialInformationBean.getPR_ORISPECCODE() == null ? "" : materialInformationBean.getPR_ORISPECCODE())
- + "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
- + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
- + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
- + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
- + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
- + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
- if (materialInformationBean.getPD_BATCHCODE() != null) {
- materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
- }
- mMaterialInforTextView.setText(materialInfo);
- }
- } else {
- mMaterialInforTextView.setText("该出库单已经完成备料");
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- @Override
- public void onFail(int flag, String failStr) throws Exception {
- progressDialog.dismiss();
- if (getActivity() != null) {
- try {
- etBarCode.setText(null);
- CommonUtil.editTextGetFocus(etBarCode);
- CommonUtil.makeNotice();
- CommonUtil.toastNoRepeat(getActivity(), failStr);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- });
- /*RequestBody requestBody = new FormBody.Builder()
- .add("ids", pi_id)
- .add("barcode", currentBarcode)
- .add("or_remain", mBarRemain)
- .add("bar_remain", mRestqty)
- .build();
- okhttp3.Request.Builder builder = new okhttp3.Request.Builder().url(url).post(requestBody);
- Map<String, String> cookiesMap = VolleyUtil.getVolleyUtil().setCookies();
- if (cookiesMap != null) {
- Set<String> keys = cookiesMap.keySet();
- Iterator<String> iterator = keys.iterator();
- while (iterator.hasNext()) {
- String key = iterator.next();
- String value = cookiesMap.get(key);
- builder.addHeader(key, value);
- }
- }
- mRequest = builder.build();
- mOkHttpClient.newCall(mRequest).enqueue(new Callback() {
- @Override
- public void onFailure(Call call, IOException e) {
- progressDialog.dismiss();
- Message message = Message.obtain();
- message.what = SPLIT_BARCODE_FAIL;
- message.obj = "{\"exceptionInfo\":\"条码拆分异常\"}";
- mHandler.sendMessage(message);
- }
- @Override
- public void onResponse(Call call, okhttp3.Response response) throws IOException {
- progressDialog.dismiss();
- String s = response.body().string();
- if (response.code() == 200) {
- Message message = Message.obtain();
- message.what = SPLIT_BARCODE_SUCCESS;
- message.obj = s;
- mHandler.sendMessage(message);
- } else {
- Message message = Message.obtain();
- message.what = SPLIT_BARCODE_FAIL;
- message.obj = s;
- mHandler.sendMessage(message);
- }
- }
- });
- */
- /*stringRequest = new StringRequest(Request.Method.POST, url,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- progressDialog.dismiss();
- if (popupWindow != null && popupWindow.isShowing())
- closePopupWindow();
- mResults = new ArrayList<>();
- mCollectTypeRadioGroup.setEnabled(true);
- LogUtil.e("breaking", s);
- try {
- JSONObject jsonObject = new JSONObject(s);
- JSONObject dataObject = jsonObject.optJSONObject("data");
- if (dataObject == null) {
- return;
- }
- JSONObject messageObject = dataObject.optJSONObject("barcode");
- if (messageObject == null) {
- return;
- }
- if (messageObject.has("ISMSD")) {
- if (messageObject.optBoolean("ISMSD")) {
- //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
- iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
- // Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
- mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
- mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
- showDewPopupWindow();
- } else {
- mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
- mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
- mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
- if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
- spliteBarcode(currentBarcode);
- }
- }
- } else {
- mCollectResultTextView.setVisibility(View.VISIBLE);
- mCollectResultTextView.setText(null);
- JSONArray listArray = dataObject.optJSONArray("nolist");
- if (mCollectType.equals("byBarcode")) {
- String barcodeResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
- + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
- + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
- + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
- + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
- + ";名称规格:" + messageObject.optString("PR_DETAIL")
- + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC")
- + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
- if (listArray != null && listArray.length() > 0) {
- for (int i = 0; i < listArray.length(); i++) {
- JSONObject listObject = listArray.optJSONObject(i);
- barcodeResult = barcodeResult
- + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
- + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
- + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
- }
- }
- mCollectResultTextView.setText(barcodeResult);
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.GONE);
- tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
- tvBarcodeCollectionSuccess.setText("采集成功");
- mResult1 = messageObject.optString("BAR_CODE");
- mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
- mResult3 = messageObject.optString("BAR_PRODCODE");
- mResults.add(mResult1);
- mResults.add(mResult2);
- mResults.add(mResult3);
- mCollectBarcodeTv.setText(mResult1);
- mCollectBarRemainTv.setText(mResult2);
- mCollectBarProdcodeTv.setText(mResult3);
- PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
- } else if (mCollectType.equals("byBatchcode")) {
- String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
- + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
- + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
- + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
- + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
- + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
- + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
- if (listArray != null && listArray.length() > 0) {
- for (int i = 0; i < listArray.length(); i++) {
- JSONObject listObject = listArray.optJSONObject(i);
- boxResult = boxResult
- + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
- + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
- + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
- }
- }
- mCollectResultTextView.setText(boxResult);
- mBarcodeTableLayout.setVisibility(View.GONE);
- mBoxTableLayout.setVisibility(View.GONE);
- tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
- tvBoxCollectionSuccess.setText("采集成功");
- mResult1 = messageObject.optString("PA_OUTBOXCODE");
- mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
- mResult3 = messageObject.optString("PA_PRODCODE");
- mResult4 = messageObject.optString("PA_WHCODE");
- mResults.add(mResult1);
- mResults.add(mResult2);
- mResults.add(mResult3);
- mResults.add(mResult4);
- mCollectBoxTv.setText(mResult1);
- mCollectBoxNumTv.setText(mResult2);
- mCollectBoxrProdcodeTv.setText(mResult3);
- mCollectBoxWhcodeTv.setText(mResult4);
- PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
- }
- CommonUtil.toastNoRepeat(getActivity(), "采集成功");
- Object next = jsonObject.getJSONObject("data").get("next");
- if (next != null && !"null".equals(next.toString())) {
- JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
- MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
- if (materialInformationBean != null) {
- String materialInfo =
- "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
- + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
- + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
- + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
- + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
- + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
- if (materialInformationBean.getPD_BATCHCODE() != null) {
- materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
- }
- mMaterialInforTextView.setText(materialInfo);
- }
- } else {
- mMaterialInforTextView.setText("该出库单已经完成备料");
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- progressDialog.dismiss();
- // Toast.makeText(getActivity().getApplicationContext(), "拆分失败", Toast.LENGTH_LONG).show();
- if (getActivity() != null) {
- etBarCode.setText(null);
- CommonUtil.editTextGetFocus(etBarCode);
- CommonUtil.showErrorToast(volleyError);
- }
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- @Override
- protected Map<String, String> getParams() throws AuthFailureError {
- Map<String, String> params = new HashMap<>();
- // if (isMultiple) {
- params.put("ids", pi_id);
- // } else {
- // params.put("id", pi_id);
- // params.put("whcode", pd_whcode);
- // }
- params.put("barcode", currentBarcode);
- params.put("or_remain", mBarRemain);
- params.put("bar_remain", mRestqty);
- Log.e(TAG, params.toString());
- return params;
- }
- };
- stringRequest.setRetryPolicy(new DefaultRetryPolicy(20 * 1000, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
- int timeoutMs = stringRequest.getTimeoutMs();
- stringRequest.setTag(TAG);
- PdaApplication.mRequestQueue.add(stringRequest);*/
- }
- protected void initBreakPopupWindow(JSONArray listArray,String bolle) {
- messages.clear();
- for (int i = 0; i < listArray.length(); i++) {
- try {
- JSONObject barcodeObject = listArray.getJSONObject(i);
- if (barcodeObject != null) {
- WHBreakingBatchBreakingBtnClickEvent.DataBean dataBean = new WHBreakingBatchBreakingBtnClickEvent.DataBean();
- if (bolle.equals("true")){
- dataBean.setBAR_CODE(JsonUtils.optStringNotNull(barcodeObject, "BAR_CODE"));
- dataBean.setBAR_REMAIN(JsonUtils.optStringNotNull(barcodeObject, "BAR_REMAIN"));
- dataBean.setPR_CODE(JsonUtils.optStringNotNull(barcodeObject, "PR_CODE"));
- dataBean.setPR_SPEC(JsonUtils.optStringNotNull(barcodeObject, "PR_SPEC"));
- }else {
- dataBean.setBAR_CODE(JsonUtils.optStringNotNull(barcodeObject, "BAR_CODE"));
- dataBean.setBAR_REMAIN(JsonUtils.optStringNotNull(barcodeObject, "BAR_REMAIN"));
- }
- messages.add(dataBean);
- }
- } catch (JSONException 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();
- printEvent(listArray);
- } else {
- closeSplitPopupWindow();
- BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
- Bundle bundle = new Bundle();
- bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
- blueToothPrintFragment.setArguments(bundle);
- FragmentUtils.switchFragment(AGVIOCOutMakeMaterialOper.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());
- blueToothPrintFragment.setArguments(bundle);
- FragmentUtils.switchFragment(AGVIOCOutMakeMaterialOper.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();
- // confirmEvent();
- }
- });
- CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
- }
- private void printEvent(JSONArray printArray) {
- if (isPrinting) {
- CommonUtil.toastNoRepeat(mActivity, "正在打印中,请勿重复操作");
- return;
- }
- isPrinting = true;
- if (printArray != null && printArray.length() > 0) {
- boolean isFail = false;
- for (int i = 0; i < printArray.length(); i++) {
- try {
- JSONObject printObject = printArray.getJSONObject(i);
- int printResult = PrintUtils.printBar(mActivity, printObject.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());
- blueToothPrintFragment.setArguments(bundle);
- FragmentUtils.switchFragment(AGVIOCOutMakeMaterialOper.this, blueToothPrintFragment);
- } else {
- CommonUtil.toastNoRepeat(mActivity, "打印成功");
- }
- } else {
- CommonUtil.toastNoRepeat(mActivity, "打印失败,条码数据为空");
- }
- isPrinting = false;
- }
- public static final String GETPRINTDATA = "getPrintData";
- /**
- * 获取打印文件
- */
- private void getPrintData() {
- progressDialog.show();
- String url = GloableParams.ADDRESS_LABELPRINT + "?data=" + strPrintDataList;
- stringRequestSplit = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- try {
- JSONObject resultObject = new JSONObject(s);
- if (resultObject.optBoolean("success")) {
- mPrintUrl = resultObject.optString("data");
- FileUtils.printBarcode(mPrintUrl, mHandler);
- }
- } catch (JSONException e) {
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- if (progressDialog.isShowing())
- progressDialog.dismiss();
- CommonUtil.showErrorToast(volleyError);
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- Map map = VolleyUtil.getVolleyUtil().setCookies();
- //不用改动
- map.put("Content-Type", "text/html; charset=UTF-8");
- return map;
- }
- };
- stringRequestSplit.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- stringRequestSplit.setTag(GETPRINTDATA);
- PdaApplication.mRequestQueue.add(stringRequestSplit);
- }
- private class MyAdapter extends ArrayAdapter<WHBreakingBatchBreakingBtnClickEvent.DataBean> {
- private int resourceId;
- public MyAdapter(Context context, int resource, List<WHBreakingBatchBreakingBtnClickEvent.DataBean> objects) {
- super(context, resource, objects);
- resourceId = resource;
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- //WHBreakingBatchBreakingBtnClickEvent.Message target = getItem(position);
- WHBreakingBatchBreakingBtnClickEvent.DataBean person = getItem(position);
- convertView = LayoutInflater.from(getContext()).inflate(resourceId,
- null);
- TextView tv_bar_code = (TextView) convertView.findViewById(R.id.tv_bar_code);
- TextView tv_bar_remain = (TextView) convertView.findViewById(R.id.tv_bar_remain);
- // tv_bar_code.setText(target.bar_code);
- // tv_bar_remain.setText(target.bar_remain);
- tv_bar_code.setText(person.getBAR_CODE());
- tv_bar_remain.setText(person.getBAR_REMAIN());
- return convertView;
- }
- }
- /**
- * 条码输入框的enter事件以及确认按钮点击事件
- */
- private void confirmEvent() {
- currentBarcode = etBarCode.getText().toString().trim();
- if (TextUtils.isEmpty(currentBarcode)) {
- CommonUtil.toastNoRepeat(getActivity(), "请输入号码");
- }
- // else if (!currentBarcode.matches(Constants.REGEX.NO_CN_SYMBOL)) {
- // CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.barcode_cannot_contain_special));
- // }
- else {
- if (mCollectModel == 1) {
- if (CommonUtil.isNetWorkConnected(getActivity())) {
- barcodeEnterEvent(false, true);
- } else {
- CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
- }
- } else if (mCollectModel == 0) {
- //离线模式
- saveToDatabase(currentBarcode);
- }
- }
- }
- private void saveToDatabase(String currentText) {
- progressDialog.show();
- List<TableLBARCODEIO> allBarcodeIo = new ArrayList<>();
- if (mDbManager.getDb().isOpen()) {
- allBarcodeIo = mDbManager.queryFromBarcodeIo(new String[]{"out", pi_id, pd_whcode}, "inOrOut=? and LBI_PIID=? and LBI_WHCODE=? ");
- }
- //如果用户采集的离线数据超过30条,提示用户请先将采集的数据上传,限制用户必须先将数据上传
- if (allBarcodeIo.size() >= 30) {
- progressDialog.dismiss();
- final List<TableLBARCODEIO> finalAllBarcodeIo = allBarcodeIo;
- new android.app.AlertDialog.Builder(getActivity())
- .setTitle("提示")
- .setMessage("您采集的离线数据已经达到30条,请先将离线数据上传再继续采集。是否上传数据?")
- .setPositiveButton("上传", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (CommonUtil.isNetWorkConnected(getActivity())) {
- submitOfflineData(finalAllBarcodeIo, false);
- } else {
- CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
- }
- }
- })
- .setNegativeButton("取消", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- }).show();
- return;
- }
- boolean isExist = false;
- for (int i = 0; i < allBarcodeIo.size(); i++) {
- if (pi_id.equals(allBarcodeIo.get(i).getLBI_PIID() + "") && pd_whcode.equals(allBarcodeIo.get(i).getLBI_WHCODE())
- && "out".equals(allBarcodeIo.get(i).getInOrOut())
- && ((currentText.equals(allBarcodeIo.get(i).getLBI_BARCODE()) && mCollectType.equals("byBarcode"))
- || (currentText.equals(allBarcodeIo.get(i).getLBI_OUTBOXCODE()) && mCollectType.equals("byBatchcode")))) {
- isExist = true;
- break;
- }
- }
- if (isExist) {
- progressDialog.dismiss();
- if (mCollectType.equals("byBarcode"))
- Toast.makeText(getActivity(), "条码 " + currentText + " 已经在已采集待提交数据中", Toast.LENGTH_SHORT).show();
- else if (mCollectType.equals("byBatchcode"))
- Toast.makeText(getActivity(), "外箱 " + currentText + " 已经在已采集待提交数据中", Toast.LENGTH_SHORT).show();
- etBarCode.setText(null);
- etBarCode.requestFocus();
- } else {
- TableLBARCODEIO newBarcodeIo = new TableLBARCODEIO();
- newBarcodeIo.setLBI_PIID(Long.parseLong(pi_id));
- if (mCollectType.equals("byBarcode")) {
- newBarcodeIo.setLBI_BARCODE(etBarCode.getText().toString().trim());
- newBarcodeIo.setLBI_OUTBOXCODE("");
- newBarcodeIo.setLBI_BOXTYPE("byBarcode");
- } else if (mCollectType.equals("byBatchcode")) {
- newBarcodeIo.setLBI_BARCODE("");
- newBarcodeIo.setLBI_OUTBOXCODE(etBarCode.getText().toString().trim());
- newBarcodeIo.setLBI_BOXTYPE("byBatchcode");
- }
- newBarcodeIo.setLBI_WHCODE(pd_whcode);
- newBarcodeIo.setLBI_INOUTNO(pi_inoutno);
- newBarcodeIo.setLBI_PRODCODE("");
- newBarcodeIo.setLBI_INQTY(0);
- newBarcodeIo.setLBI_LOCATION("");
- newBarcodeIo.setLBI_PRDETAIL("");
- newBarcodeIo.setLBI_OUTQTY(0);
- newBarcodeIo.setLBI_PRID(0);
- newBarcodeIo.setInOrOut("out");
- try {
- mDbManager.saveToBarcodeIo(newBarcodeIo);
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- progressDialog.dismiss();
- Toast.makeText(getActivity(), "成功保存至未提交列表", Toast.LENGTH_SHORT).show();
- }
- }, 400);
- etBarCode.setText(null);
- } catch (Exception e) {
- progressDialog.dismiss();
- Toast.makeText(getActivity(), "数据保存失败", Toast.LENGTH_SHORT).show();
- etBarCode.setText(null);
- }
- }
- }
- private void submitOfflineData(final List<TableLBARCODEIO> mNotSubmitList, final boolean isPop) {
- progressDialog.show();
- final List<SubmitNotParam> submitNotParams = new ArrayList<SubmitNotParam>();
- for (int i = 0; i < mNotSubmitList.size(); i++) {
- SubmitNotParam submitNotParam = new SubmitNotParam();
- TableLBARCODEIO lbarcodeio = mNotSubmitList.get(i);
- submitNotParam.setBi_barcode(lbarcodeio.getLBI_BARCODE());
- submitNotParam.setBi_inoutno(lbarcodeio.getLBI_INOUTNO());
- submitNotParam.setBi_inqty(lbarcodeio.getLBI_INQTY() + "");
- submitNotParam.setBi_location(lbarcodeio.getLBI_LOCATION());
- submitNotParam.setBi_piid(lbarcodeio.getLBI_PIID() + "");
- submitNotParam.setBi_prodcode(lbarcodeio.getLBI_PRODCODE());
- submitNotParam.setBi_prodid(lbarcodeio.getLBI_PRID() + "");
- submitNotParam.setBi_whcode(lbarcodeio.getLBI_WHCODE());
- submitNotParam.setBi_outboxcode(lbarcodeio.getLBI_OUTBOXCODE());
- submitNotParam.setBi_boxtype(lbarcodeio.getLBI_BOXTYPE());
- submitNotParams.add(submitNotParam);
- }
- try {
- String url = GloableParams.ADDRESS_OUT_SAVE_BARCODE;
- PdaApplication.mRequestQueue.cancelAll(TAG + "submit");
- mStringRequest = new StringRequest(Request.Method.POST, url,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- progressDialog.dismiss();
- try {
- JSONObject resultJsonObject = new JSONObject(s);
- JSONObject dataJsonObject = resultJsonObject.getJSONObject("data");
- Iterator<String> resultKeys = dataJsonObject.keys();
- if (resultKeys.hasNext()) {
- int successCount = 0;
- int failCount = 0;
- while (resultKeys.hasNext()) {
- String barcodeKey = resultKeys.next().toString();
- String barcodeResult = JsonUtils.optStringNotNull(dataJsonObject, barcodeKey);
- if (barcodeKey.contains("byBarcode:")) {
- barcodeKey = barcodeKey.substring(10);
- } else if (barcodeKey.contains("byBatchcode:")) {
- barcodeKey = barcodeKey.substring(6);
- }
- if ("success".equals(barcodeResult)) {
- successCount++;
- for (int i = 0; i < mNotSubmitList.size(); i++) {
- TableLBARCODEIO lbarcodeio = mNotSubmitList.get(i);
- if (barcodeKey.equals(lbarcodeio.getLBI_BARCODE())) {
- mDbManager.deleteFromBarcodeIo(lbarcodeio);
- }
- }
- } else {
- failCount++;
- }
- }
- if (failCount == 0) {
- mCollectModelBtn.setText("在线");
- mCollectModel = 1;
- Toast.makeText(getActivity(), getResources().getString(R.string.submit_success), Toast.LENGTH_SHORT).show();
- if (isPop)
- getActivity().getSupportFragmentManager().popBackStack();
- } else {
- mCollectModelBtn.setText("离线");
- mCollectModel = 0;
- CommonUtil.toastNoRepeat(getActivity(), successCount + "条数据提交成功\n" + failCount + "条数据提交失败");
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- progressDialog.dismiss();
- if (getActivity() != null) {
- mCollectModelBtn.setText("离线");
- mCollectModel = 0;
- CommonUtil.showErrorToast(volleyError);
- }
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- @Override
- protected Map<String, String> getParams() throws AuthFailureError {
- Map<String, String> param = new HashMap<>();
- param.put("data", JSON.toJSONString(submitNotParams));
- param.put("type", mProdOutType);
- return param;
- }
- };
- mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- mStringRequest.setTag(TAG + "submit");
- PdaApplication.mRequestQueue.add(mStringRequest);
- } catch (Exception e) {
- progressDialog.dismiss();
- e.printStackTrace();
- }
- }
- private void getAgainEvent() {
- String url = GloableParams.ADDRESS_CLEARGET;
- PdaApplication.mRequestQueue.cancelAll(TAG);
- stringRequestPost = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- LogUtil.e("已空", s + "");
- // progressDialog.dismiss();
- CommonUtil.toastNoRepeat(getActivity(), "已清空采集数据");
- getCollectNotListOnline(pi_id, pd_whcode);
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- progressDialog.dismiss();
- if (getActivity() != null) {
- closeListPopupWindow();
- // getCollectNotListOnline(pi_id, pd_whcode);
- CommonUtil.showErrorToast(volleyError);
- }
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- @Override
- protected Map<String, String> getParams() throws AuthFailureError {
- Map<String, String> params = new HashMap<>();
- params.put("id", pi_id);
- params.put("whcode", pd_whcode);
- return params;
- }
- };
- stringRequestPost.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- stringRequestPost.setTag(TAG);
- PdaApplication.mRequestQueue.add(stringRequestPost);
- }
- /**
- * 获取材料未采集列表
- *
- * @param pi_id
- * @param pd_whcode
- */
- private void getCollectNotListOnline(String pi_id, String pd_whcode) {
- progressDialog.show();
- String url = GloableParams.ADDRESS_OUT_NEED_GET_LIST + "?id=" + pi_id + "&whcode=" + pd_whcode + "&type=" + mProdOutType;
- PdaApplication.mRequestQueue.cancelAll(TAG + "online");
- jsonRequest = new JsonObjectRequest(Request.Method.GET, url, null,
- new Response.Listener<JSONObject>() {
- @Override
- public void onResponse(JSONObject jsonObject) {
- progressDialog.dismiss();
- try {
- if (!"success".equals(jsonObject.getJSONObject("data").optString("message"))) {
- CommonUtil.toastNoRepeat(getActivity(), jsonObject.getJSONObject("data").optString("message"));
- }
- JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("data");
- LogUtil.i("jsonArray", jsonArray.toString());
- if (jsonArray != null) {
- List<TableLPRODIONEEDGET> lprodioneedgetList = new ArrayList<>();
- for (int i = 0; i < jsonArray.length(); i++) {
- LogUtil.i("jsonObject", jsonArray.get(i).toString());
- JSONObject notCollectObject = jsonArray.getJSONObject(i);
- TableLPRODIONEEDGET lprodioneedget = new TableLPRODIONEEDGET();
- lprodioneedget.setLPN_PRODCODE(notCollectObject.optString("PD_PRODCODE"));
- lprodioneedget.setLPN_RESTQTY(notCollectObject.optDouble("PD_RESTQTY"));
- lprodioneedget.setLPN_PRDETAIL(notCollectObject.optString("PR_DETAIL"));
- lprodioneedget.setLPN_PRSPEC(JsonUtils.optStringNotNull(notCollectObject, "PR_SPEC"));
- lprodioneedget.setLPN_ZXBZS(notCollectObject.optDouble("PR_ZXBZS"));
- lprodioneedget.setLPN_IFBARCODECHECK("");
- lprodioneedget.setLPN_PIID(notCollectObject.optInt("PD_PIID"));
- lprodioneedget.setLPN_INOUTNO(notCollectObject.optString("PD_INOUTNO"));
- lprodioneedget.setLPN_WHCODE(notCollectObject.optString("PD_WHCODE"));
- lprodioneedget.setLPN_PRID(notCollectObject.optInt("PR_ID"));
- lprodioneedget.setLPN_BATCHCODE(notCollectObject.optString("PD_BATCHCODE"));
- lprodioneedget.setInOrOut("out");
- lprodioneedget.setLPN_ORDERCODE("");
- lprodioneedget.setLPN_TRACEKIND(-1);
- lprodioneedgetList.add(lprodioneedget);
- }
- try {
- if (mDbManager.getDb().isOpen()) {
- mDbManager.deleteInOrOutProductWaitCollect("out");
- mDbManager.saveListToProductWaitCollect(lprodioneedgetList);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError volleyError) {
- progressDialog.dismiss();
- CommonUtil.showErrorToast(volleyError);
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- return VolleyUtil.getVolleyUtil().setCookies();
- }
- @Override
- protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
- if (response.data == null || response.data.length == 0) {
- JSONObject jsonObject = new JSONObject();
- try {
- jsonObject.put("msg", "成功:服务器无返回");
- } catch (JSONException e) {
- e.printStackTrace();
- }
- return Response.success(jsonObject, HttpHeaderParser.parseCacheHeaders(response));
- } else {
- return super.parseNetworkResponse(response);
- }
- }
- };
- jsonRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
- jsonRequest.setTag(TAG + "online");
- PdaApplication.mRequestQueue.add(jsonRequest);
- }
- private void clickToFragment(BaseFragment baseFragment) {
- Bundle bundle = new Bundle();
- bundle.putString("pi_id", pi_id);
- bundle.putString("pi_inoutno", pi_inoutno);
- bundle.putString("pd_whcode", pd_whcode);
- bundle.putString("whichpage", "materialout");
- bundle.putBoolean("isMultiple", isMultiple);
- if (mCollectModel == 1) {
- bundle.putInt("modeType", 3);
- } else if (mCollectModel == 0) {
- bundle.putInt("modeType", 2);
- }
- mFragment = baseFragment;
- mFragment.setArguments(bundle);
- FragmentUtils.switchFragment(this, mFragment);
- }
- private void closeListPopupWindow() {
- if (listPopupWindow != null) {
- listPopupWindow.dismiss();
- listPopupWindow = null;
- CommonUtil.setBackgroundAlpha(mActivity, 1f);
- }
- }
- private void closeSplitPopupWindow() {
- if (splitPop != null) {
- splitPop.dismiss();
- splitPop = null;
- CommonUtil.setBackgroundAlpha(mActivity, 1f);
- }
- }
- private void closePopupWindow() {
- if (popupWindow != null) {
- popupWindow.dismiss();
- popupWindow = null;
- CommonUtil.setBackgroundAlpha(mActivity, 1f);
- }
- }
- /**
- * 清除所有信息
- */
- private void clearAll() {
- //清空输入框
- etBarCode.setText("");
- }
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
- ((FunctionActivity) getActivity()).setScanIvVisible(false);
- ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(getString(R.string.out_management));
- mDbManager.closeDB();
- CommonUtil.closeKeybord(((EditText) etBarCode), mActivity);
- ButterKnife.unbind(this);
- ((FunctionActivity) getActivity()).fragment = new IOCOutMakeMaterial();
- }
- /**
- * 其返回一个布尔值;意思是,如果对返回事件进行了处理就返回TRUE,如果不做处理就返回FALSE,让上层进行处理。
- *
- * @return 是否交与activity处理返回事件
- */
- public boolean onFragmentBackPressed() {
- List<TableLBARCODEIO> allBarcodeIo = new ArrayList<>();
- if (mDbManager == null || !mDbManager.getDb().isOpen()) {
- mDbManager = new DBManager(PdaApplication.getmContext());
- }
- allBarcodeIo = mDbManager.queryFromBarcodeIo(new String[]{"out", pi_inoutno, pd_whcode}, "inOrOut=? and LBI_INOUTNO=? and LBI_WHCODE=?");
- if (allBarcodeIo != null && allBarcodeIo.size() != 0) {
- final List<TableLBARCODEIO> finalAllBarcodeIo = allBarcodeIo;
- new android.app.AlertDialog.Builder(getActivity())
- .setTitle("提示")
- .setMessage("存在未提交的离线采集数据,点击上传将把未提交数据上传,点击取消将清空未采集数据")
- .setPositiveButton("上传", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (CommonUtil.isNetWorkConnected(getActivity())) {
- submitOfflineData(finalAllBarcodeIo, true);
- } else {
- CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
- }
- }
- })
- .setNegativeButton("取消", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- try {
- mDbManager.deleteListFromBarcodeIo(finalAllBarcodeIo);
- List<TableLPRODIONEEDGET> allLprodioneedgets = mDbManager.queryFromProductWaitCollect(new String[]{"out"}, "inOrOut=? ");
- if (allLprodioneedgets != null) {
- for (int j = 0; j < finalAllBarcodeIo.size(); j++) {
- TableLBARCODEIO deleteLbarcodeio = finalAllBarcodeIo.get(j);
- for (int i = 0; i < allLprodioneedgets.size(); i++) {
- TableLPRODIONEEDGET tableLPRODIONEEDGET = allLprodioneedgets.get(i);
- if (tableLPRODIONEEDGET.getLPN_PIID() == deleteLbarcodeio.getLBI_PIID()
- && tableLPRODIONEEDGET.getLPN_WHCODE().equals(deleteLbarcodeio.getLBI_WHCODE())
- // && tableLPRODIONEEDGET.getLPN_PRODCODE().equals(deleteLbarcodeio.getLBI_PRODCODE())
- ) {
- tableLPRODIONEEDGET.setLPN_RESTQTY(CommonUtil.doubleAddition(tableLPRODIONEEDGET.getLPN_RESTQTY(), deleteLbarcodeio.getLBI_INQTY()));
- mDbManager.updateProductWaitCollect(tableLPRODIONEEDGET);
- }
- }
- }
- }
- CommonUtil.toastNoRepeat(getActivity(), "清除数据成功");
- getActivity().getSupportFragmentManager().popBackStack();
- } catch (Exception e) {
- CommonUtil.toastNoRepeat(getActivity(), "清除失败");
- getActivity().getSupportFragmentManager().popBackStack();
- }
- }
- }).show();
- // ((FunctionActivity) getActivity()).fragment = new MaterialStorageFragment();
- return true;
- } else {
- return false;
- }
- }
- }
|