AGVIOCOutMakeMaterialOper.java 150 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921
  1. package com.uas.bgdq.fragment;
  2. import android.app.Activity;
  3. import android.content.ComponentName;
  4. import android.content.Context;
  5. import android.content.DialogInterface;
  6. import android.content.Intent;
  7. import android.graphics.drawable.BitmapDrawable;
  8. import android.net.Uri;
  9. import android.os.Bundle;
  10. import android.os.Handler;
  11. import android.os.Message;
  12. import android.support.v4.app.Fragment;
  13. import android.support.v7.app.AlertDialog;
  14. import android.text.Editable;
  15. import android.text.TextUtils;
  16. import android.text.TextWatcher;
  17. import android.util.Log;
  18. import android.view.Gravity;
  19. import android.view.KeyEvent;
  20. import android.view.LayoutInflater;
  21. import android.view.View;
  22. import android.view.ViewGroup;
  23. import android.view.inputmethod.EditorInfo;
  24. import android.widget.AdapterView;
  25. import android.widget.ArrayAdapter;
  26. import android.widget.BaseAdapter;
  27. import android.widget.Button;
  28. import android.widget.CheckBox;
  29. import android.widget.CompoundButton;
  30. import android.widget.EditText;
  31. import android.widget.ImageView;
  32. import android.widget.LinearLayout;
  33. import android.widget.ListView;
  34. import android.widget.PopupWindow;
  35. import android.widget.RadioButton;
  36. import android.widget.RadioGroup;
  37. import android.widget.Spinner;
  38. import android.widget.TableLayout;
  39. import android.widget.TextView;
  40. import android.widget.Toast;
  41. import com.alibaba.fastjson.JSON;
  42. import com.android.volley.AuthFailureError;
  43. import com.android.volley.DefaultRetryPolicy;
  44. import com.android.volley.NetworkResponse;
  45. import com.android.volley.Request;
  46. import com.android.volley.Response;
  47. import com.android.volley.VolleyError;
  48. import com.android.volley.toolbox.HttpHeaderParser;
  49. import com.android.volley.toolbox.JsonObjectRequest;
  50. import com.android.volley.toolbox.StringRequest;
  51. import com.uas.bgdq.R;
  52. import com.uas.bgdq.activity.FunctionActivity;
  53. import com.uas.bgdq.application.PdaApplication;
  54. import com.uas.bgdq.bean.ErrorMsg;
  55. import com.uas.bgdq.bean.IOCOutMakeMaterialOperMsd;
  56. import com.uas.bgdq.bean.IOCOutmakeMaterialSplitBean;
  57. import com.uas.bgdq.bean.MaterialInformationBean;
  58. import com.uas.bgdq.bean.SubmitNotParam;
  59. import com.uas.bgdq.bean.WHBreakingBatchBreakingBtnClickEvent;
  60. import com.uas.bgdq.database.DBManager;
  61. import com.uas.bgdq.global.GloableParams;
  62. import com.uas.bgdq.table.TableLBARCODEIO;
  63. import com.uas.bgdq.table.TableLPRODIONEEDGET;
  64. import com.uas.bgdq.tools.SharedPreUtil;
  65. import com.uas.bgdq.tools.VolleyUtil;
  66. import com.uas.bgdq.util.CameraUtil;
  67. import com.uas.bgdq.util.CommonUtil;
  68. import com.uas.bgdq.util.Constants;
  69. import com.uas.bgdq.util.FastjsonUtil;
  70. import com.uas.bgdq.util.FileUtils;
  71. import com.uas.bgdq.util.FragmentUtils;
  72. import com.uas.bgdq.util.HttpCallback;
  73. import com.uas.bgdq.util.HttpParams;
  74. import com.uas.bgdq.util.JsonTools;
  75. import com.uas.bgdq.util.JsonUtils;
  76. import com.uas.bgdq.util.LogUtil;
  77. import com.uas.bgdq.util.PrintUtils;
  78. import com.uas.bgdq.util.VolleyRequest;
  79. import com.uas.bgdq.view.ClearableEditText;
  80. import com.uuzuche.lib_zxing.activity.CaptureActivity;
  81. import com.uuzuche.lib_zxing.activity.CodeUtils;
  82. import org.json.JSONArray;
  83. import org.json.JSONException;
  84. import org.json.JSONObject;
  85. import java.io.File;
  86. import java.io.UnsupportedEncodingException;
  87. import java.net.URLEncoder;
  88. import java.util.ArrayList;
  89. import java.util.HashMap;
  90. import java.util.Iterator;
  91. import java.util.List;
  92. import java.util.Map;
  93. import java.util.concurrent.TimeUnit;
  94. import butterknife.ButterKnife;
  95. import okhttp3.OkHttpClient;
  96. /**
  97. * Created by RaoMeng on 2016/7/27.
  98. * AVG出库采集页面
  99. */
  100. public class AGVIOCOutMakeMaterialOper extends BaseFragment implements View.OnClickListener, RadioGroup.OnCheckedChangeListener, HttpCallback ,AdapterView.OnItemSelectedListener{
  101. private static final int SCAN_BARCODE_CODE = 103;
  102. private static final int SPLIT_BARCODE_SUCCESS = 104;
  103. private static final int SPLIT_BARCODE_FAIL = 105;
  104. private static final int FLAG_CONFIRM_POST = 0x05;
  105. private String maFunName = null;
  106. private List<String> masterFuncList;
  107. private ImageView mScanImageView;
  108. static ArrayAdapter adapter;
  109. private JsonObjectRequest jsonRequest;
  110. private static final String TAG = "IOCOutMakeMaterialOper";
  111. private Button btnActionbarWithback, btnActionbarRight;
  112. private String pi_inoutno;
  113. private String pd_whcode;
  114. private String pi_id;
  115. private boolean isMultiple;
  116. private Fragment mFragment;
  117. private String mCollectType;
  118. private PopupWindow listPopupWindow;
  119. private StringRequest stringRequestPost;
  120. private String mProdOutType;
  121. private List<WHBreakingBatchBreakingBtnClickEvent.DataBean> messages = new ArrayList<>();
  122. private int mCollectModel = 1;//采集模式:1代表在线,0代表离线
  123. private String mBarRemain, mRestqty;
  124. private String mResult1, mResult2, mResult3, mResult4;
  125. private List<String> mResults;
  126. private TextWatcher watcher = new TextWatcher() {
  127. @Override
  128. public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  129. }
  130. @Override
  131. public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  132. }
  133. @Override
  134. public void afterTextChanged(Editable editable) {
  135. if (editable.length() == 0) {
  136. btnConfirm.setEnabled(false);
  137. } else {
  138. btnConfirm.setEnabled(true);
  139. }
  140. }
  141. };
  142. private StringRequest stringRequest;
  143. private PopupWindow splitPop;
  144. private String strPrintDataList;
  145. private StringRequest stringRequestSplit;
  146. private DBManager mDbManager;
  147. private StringRequest mStringRequest;
  148. private ArrayAdapter mTypeSpAdapter;
  149. private ArrayList<String> mCollectTypes;
  150. private String mPrintUrl = "";
  151. private Handler mHandler = new Handler() {
  152. @Override
  153. public void handleMessage(Message msg) {
  154. super.handleMessage(msg);
  155. switch (msg.what) {
  156. case Constants.CONSTANT.PRINT_SUCCESS:
  157. if (progressDialog.isShowing())
  158. progressDialog.dismiss();
  159. closeSplitPopupWindow();
  160. Toast.makeText(mActivity, R.string.obtain_print_file_success, Toast.LENGTH_LONG).show();
  161. try {
  162. Intent intent = new Intent();
  163. ComponentName comp = new ComponentName("com.dynamixsoftware.printershare", "com.dynamixsoftware.printershare.ActivityPrintPDF");
  164. intent = new Intent();
  165. intent.setComponent(comp);
  166. intent.setAction("android.intent.action.VIEW");
  167. intent.setType("application/pdf");
  168. intent.setData(Uri.fromFile(new File(Constants.CONSTANT.PRINT_FILE_PATH, Constants.CONSTANT.PRINT_FILE_NAME)));
  169. startActivity(intent);
  170. } catch (Exception e) {
  171. Toast.makeText(mActivity, "打印失败", Toast.LENGTH_LONG).show();
  172. e.printStackTrace();
  173. }
  174. break;
  175. case Constants.CONSTANT.PRINT_FAILED:
  176. if (progressDialog.isShowing())
  177. progressDialog.dismiss();
  178. Toast.makeText(mActivity, R.string.obtain_print_file_failed, Toast.LENGTH_LONG).show();
  179. break;
  180. case Constants.CONSTANT.PRINT_OVERLOAD:
  181. if (progressDialog.isShowing())
  182. progressDialog.dismiss();
  183. Toast.makeText(mActivity, R.string.obtain_print_file_overload, Toast.LENGTH_LONG).show();
  184. break;
  185. case SPLIT_BARCODE_SUCCESS:
  186. String s = (String) msg.obj;
  187. if (popupWindow != null && popupWindow.isShowing())
  188. closePopupWindow();
  189. mResults = new ArrayList<>();
  190. mCollectTypeRadioGroup.setEnabled(true);
  191. LogUtil.e("breaking", s);
  192. try {
  193. JSONObject jsonObject = new JSONObject(s);
  194. JSONObject dataObject = jsonObject.optJSONObject("data");
  195. if (dataObject == null) {
  196. return;
  197. }
  198. JSONObject messageObject = dataObject.optJSONObject("barcode");
  199. if (messageObject == null) {
  200. return;
  201. }
  202. if (messageObject.has("ISMSD")) {
  203. if (messageObject.optBoolean("ISMSD")) {
  204. //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
  205. iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
  206. // Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
  207. mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
  208. mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
  209. showDewPopupWindow();
  210. } else {
  211. mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
  212. mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
  213. mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
  214. if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
  215. spliteBarcode(currentBarcode, mBarRemain, mRestqty);
  216. }
  217. }
  218. } else {
  219. mCollectResultTextView.setVisibility(View.VISIBLE);
  220. mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
  221. mCollectResultTextView.setText(null);
  222. JSONArray listArray = dataObject.optJSONArray("nolist");
  223. if (mCollectType.equals("byBarcode") || mCollectType.equals("byBatchcode")) {
  224. String barcodeResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
  225. + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
  226. + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
  227. + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
  228. + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
  229. + ";名称规格:" + messageObject. optString("PR_DETAIL")
  230. + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC")
  231. + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
  232. if (listArray != null && listArray.length() > 0) {
  233. for (int i = 0; i < listArray.length(); i++) {
  234. JSONObject listObject = listArray.optJSONObject(i);
  235. barcodeResult = barcodeResult
  236. + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
  237. + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
  238. + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
  239. }
  240. //弹出拆分结果弹框
  241. initBreakPopupWindow(listArray,"1");
  242. }
  243. mCollectResultTextView.setText(barcodeResult);
  244. mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
  245. mBarcodeTableLayout.setVisibility(View.GONE);
  246. mBoxTableLayout.setVisibility(View.GONE);
  247. tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
  248. tvBarcodeCollectionSuccess.setText("采集成功");
  249. mResult1 = messageObject.optString("BAR_CODE");
  250. mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
  251. mResult3 = messageObject.optString("BAR_PRODCODE");
  252. mResults.add(mResult1);
  253. mResults.add(mResult2);
  254. mResults.add(mResult3);
  255. mCollectBarcodeTv.setText(mResult1);
  256. mCollectBarRemainTv.setText(mResult2);
  257. mCollectBarProdcodeTv.setText(mResult3);
  258. PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
  259. } else if (false) {
  260. String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
  261. + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
  262. + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
  263. + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
  264. + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
  265. + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
  266. + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
  267. if (listArray != null && listArray.length() > 0) {
  268. for (int i = 0; i < listArray.length(); i++) {
  269. JSONObject listObject = listArray.optJSONObject(i);
  270. boxResult = boxResult
  271. + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
  272. + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
  273. + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
  274. }
  275. }
  276. mCollectResultTextView.setText(boxResult);
  277. mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
  278. mBarcodeTableLayout.setVisibility(View.GONE);
  279. mBoxTableLayout.setVisibility(View.GONE);
  280. tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
  281. tvBoxCollectionSuccess.setText("采集成功");
  282. mResult1 = messageObject.optString("PA_OUTBOXCODE");
  283. mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
  284. mResult3 = messageObject.optString("PA_PRODCODE");
  285. mResult4 = messageObject.optString("PA_WHCODE");
  286. mResults.add(mResult1);
  287. mResults.add(mResult2);
  288. mResults.add(mResult3);
  289. mResults.add(mResult4);
  290. mCollectBoxTv.setText(mResult1);
  291. mCollectBoxNumTv.setText(mResult2);
  292. mCollectBoxrProdcodeTv.setText(mResult3);
  293. mCollectBoxWhcodeTv.setText(mResult4);
  294. PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
  295. }
  296. CommonUtil.toastNoRepeat(getActivity(), "采集成功");
  297. Object next = jsonObject.getJSONObject("data").get("next");
  298. if (next != null && !"null".equals(next.toString())) {
  299. JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
  300. MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
  301. if (materialInformationBean != null) {
  302. String materialInfo =
  303. "型号:" + (materialInformationBean.getPR_ORISPECCODE() == null ? "" : materialInformationBean.getPR_ORISPECCODE())
  304. + "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
  305. + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
  306. + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
  307. + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
  308. + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
  309. + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
  310. if (materialInformationBean.getPD_BATCHCODE() != null) {
  311. materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
  312. }
  313. mMaterialInforTextView.setText(materialInfo);
  314. }
  315. } else {
  316. mMaterialInforTextView.setText("该出库单已经完成备料");
  317. }
  318. }
  319. } catch (JSONException e) {
  320. e.printStackTrace();
  321. }
  322. break;
  323. case SPLIT_BARCODE_FAIL:
  324. s = (String) msg.obj;
  325. String errorStr = "请求失败";
  326. if (JsonUtils.validate(s)) {
  327. try {
  328. JSONObject errorObject = new JSONObject(s);
  329. String exceptionInfo = JsonUtils.optStringNotNull(errorObject, "exceptionInfo");
  330. if (TextUtils.isEmpty(exceptionInfo)) {
  331. errorStr = "系统错误";
  332. } else {
  333. errorStr = exceptionInfo;
  334. }
  335. } catch (JSONException e) {
  336. e.printStackTrace();
  337. }
  338. }
  339. if (getActivity() != null) {
  340. try {
  341. etBarCode.setText(null);
  342. CommonUtil.editTextGetFocus(etBarCode);
  343. CommonUtil.makeNotice();
  344. CommonUtil.toastNoRepeat(getActivity(), errorStr);
  345. } catch (Exception e) {
  346. e.printStackTrace();
  347. }
  348. }
  349. break;
  350. default:
  351. break;
  352. }
  353. }
  354. };
  355. private okhttp3.Request mRequest;
  356. private OkHttpClient mOkHttpClient;
  357. private int mFocusId;
  358. private String currentBarcode;
  359. private boolean isConnected = false;
  360. private String mOldAddress = "";
  361. private int mPrintDpi = 203;
  362. private boolean isPrinting = false;
  363. private TextView tvPiInoutno;
  364. private TextView tvPdWhcode;
  365. private ClearableEditText etBarCode;
  366. private Button btnConfirm;
  367. private RadioGroup mCollectTypeRadioGroup;
  368. private RadioButton mBarcodeRadioButton;
  369. private RadioButton mBoxRadioButton;
  370. private TableLayout mBarcodeTableLayout;
  371. private TableLayout mBoxTableLayout;
  372. private TextView tvBarcodeCollectionSuccess;
  373. private TextView mCollectBarcodeTv;
  374. private TextView mCollectBarRemainTv;
  375. private TextView tvBoxCollectionSuccess;
  376. private TextView mCollectBoxTv;
  377. private TextView mCollectBoxNumTv;
  378. private TextView mCollectBoxrProdcodeTv;
  379. private TextView mCollectBoxWhcodeTv;
  380. private Button mCollectModelBtn;
  381. private TextView mtypeNameTv;
  382. private Spinner mTypeSpinner;
  383. private TextView mMaterialInforTextView;
  384. private TextView mCollectResultTextView;
  385. private TextView mCollectBarProdcodeTv;
  386. private CheckBox special_check;
  387. private TextView text_finishno;
  388. private Button btn_startoutku;
  389. private Button btn_deleteoutku;
  390. private Spinner masterSpinner;
  391. @Override
  392. protected int getLayout() {
  393. return R.layout.fragment_agviocout_make_material_oper;
  394. }
  395. @Override
  396. protected void initViews() {
  397. tvPiInoutno = root.findViewById(R.id.tv_pi_inoutno);
  398. tvPdWhcode = root.findViewById(R.id.tv_pd_whcode);
  399. etBarCode = root.findViewById(R.id.et_bar_code);
  400. btnConfirm = root.findViewById(R.id.btn_confirm);
  401. mCollectBarProdcodeTv = root.findViewById(R.id.iocout_bar_prodcode_tv);
  402. mCollectTypeRadioGroup = root.findViewById(R.id.iocout_collect_rg);
  403. mBarcodeRadioButton = root.findViewById(R.id.iocout_collect_barcode_rb);
  404. mBoxRadioButton = root.findViewById(R.id.iocout_collect_box_rb);
  405. mBarcodeTableLayout = root.findViewById(R.id.iocout_collect_barcode_tl);
  406. mBoxTableLayout = root.findViewById(R.id.iocout_collect_box_tl);
  407. tvBarcodeCollectionSuccess = root.findViewById(R.id.tv_barcode_collection_success);
  408. mCollectBarcodeTv = root.findViewById(R.id.iocout_bar_code_tv);
  409. mCollectBarRemainTv = root.findViewById(R.id.iocout_bar_remain_tv);
  410. tvBoxCollectionSuccess = root.findViewById(R.id.tv_box_collection_success);
  411. mCollectBoxTv = root.findViewById(R.id.iocout_box_tv);
  412. mCollectBoxNumTv = root.findViewById(R.id.iocout_box_num_tv);
  413. mCollectBoxrProdcodeTv = root.findViewById(R.id.iocout_box_prodcode_tv);
  414. mCollectBoxWhcodeTv = root.findViewById(R.id.iocout_box_whcode_tv);
  415. mCollectModelBtn = root.findViewById(R.id.iocout_collect_model_btn);
  416. mtypeNameTv = root.findViewById(R.id.iocout_material_type_tv);
  417. mTypeSpinner = root.findViewById(R.id.iocout_material_type_sp);
  418. mMaterialInforTextView = root.findViewById(R.id.iocout_next_material_information);
  419. mCollectResultTextView = root.findViewById(R.id.iocout_collect_result);
  420. special_check = root.findViewById(R.id.special_check);
  421. btn_startoutku = root.findViewById(R.id.btn_startoutku);
  422. btn_deleteoutku = root.findViewById(R.id.btn_deleteoutku);
  423. masterSpinner = (Spinner) root.findViewById(R.id.sp_login);
  424. text_finishno = root.findViewById(R.id.text_finishno);
  425. ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(getString(R.string.avgout_material_collect));
  426. // ((FunctionActivity) getActivity()).fragment = new IOCOutMakeMaterialOper();
  427. ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
  428. ((FunctionActivity) getActivity()).setScanIvVisible(true);
  429. mScanImageView = (ImageView) mActivity.findViewById(R.id.btn_actionbar_scan_iv);
  430. mDbManager = new DBManager(getActivity().getApplicationContext());
  431. mOkHttpClient = new OkHttpClient.Builder()
  432. .sslSocketFactory(FileUtils.createSSLSocketFactory(), new FileUtils.TrustAllCerts())
  433. .hostnameVerifier(new FileUtils.TrustAllHostnameVerifier())
  434. .connectTimeout(30, TimeUnit.SECONDS)
  435. .readTimeout(30, TimeUnit.SECONDS).build();
  436. mProdOutType = SharedPreUtil.getString(getActivity().getApplicationContext(), Constants.FLAG.PRODOUT_TYPE_CACHE, "byBatch");
  437. //获取上一个Fragment(即IOCOutMakeMaterial里面的数据)
  438. Bundle bundle = getArguments();
  439. if (bundle != null) {
  440. pi_inoutno = bundle.getString("pi_inoutno");
  441. pd_whcode = bundle.getString("pd_whcode") == null ? "" : bundle.getString("pd_whcode");
  442. pi_id = bundle.getString("pi_id");
  443. isMultiple = bundle.getBoolean("isMultiple");
  444. }
  445. ButterKnife.bind(this, root);
  446. mResults = new ArrayList<>();
  447. if (mCollectModel == 1) {
  448. mCollectModelBtn.setText("在线");
  449. } else if (mCollectModel == 0) {
  450. mCollectModelBtn.setText("离线");
  451. }
  452. //条码输入框获取焦点
  453. etBarCode.requestFocus();
  454. tvPiInoutno.setText(pi_inoutno);
  455. tvPdWhcode.setText(pd_whcode);
  456. mCollectTypes = new ArrayList<>();
  457. mCollectTypes.add("条码号");
  458. mCollectTypes.add("外箱号");
  459. mTypeSpAdapter = new ArrayAdapter<>(getActivity(), R.layout.layout_myspinner, mCollectTypes);
  460. mTypeSpAdapter.setDropDownViewResource(R.layout.layout_myspinner_dropdown);
  461. mTypeSpinner.setAdapter(mTypeSpAdapter);
  462. mBarcodeTableLayout.setVisibility(View.GONE);
  463. mBoxTableLayout.setVisibility(View.GONE);
  464. mCollectType = SharedPreUtil.getString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBarcode");
  465. if (mCollectType != null) {
  466. //取消箱号采集
  467. if (mCollectType.equals("byBarcode")) {
  468. mCollectType = "byBarcode";
  469. CommonUtil.setSpinnerItemSelectedByValue(mTypeSpinner, "条码号");
  470. etBarCode.setHint(R.string.please_collect_barcode);
  471. mtypeNameTv.setText("条码");
  472. } else if (mCollectType.equals("byBatchcode")) {
  473. CommonUtil.setSpinnerItemSelectedByValue(mTypeSpinner, "箱号");
  474. etBarCode.setHint("请采集箱号");
  475. mtypeNameTv.setText("箱号");
  476. }
  477. }
  478. btnActionbarRight = (Button) getActivity().findViewById(R.id.btn_actionbar_more);
  479. isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
  480. mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
  481. mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
  482. special_check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  483. @Override
  484. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  485. boolean checked = special_check.isChecked();
  486. Log.e("checked",checked+"");
  487. }
  488. });
  489. btn_startoutku.setOnClickListener(new View.OnClickListener() {
  490. @Override
  491. public void onClick(View v) {
  492. startchuku();
  493. }
  494. });
  495. btn_deleteoutku.setOnClickListener(new View.OnClickListener() {
  496. @Override
  497. public void onClick(View v) {
  498. new AlertDialog.Builder(getActivity()).setTitle("提示")
  499. .setMessage("确认结束出库?")
  500. .setPositiveButton("确定", new DialogInterface.OnClickListener() {
  501. @Override
  502. public void onClick(DialogInterface dialog, int which) {
  503. dialog.dismiss();
  504. stopchuku();
  505. }
  506. })
  507. .setNegativeButton("取消", new DialogInterface.OnClickListener() {
  508. @Override
  509. public void onClick(DialogInterface dialog, int which) {
  510. dialog.dismiss();
  511. }
  512. })
  513. .show();
  514. }
  515. });
  516. masterFuncList = new ArrayList<String>();
  517. getSpinnerData();
  518. }
  519. private void getSpinnerData(){
  520. masterFuncList.clear();
  521. // com.alibaba.fastjson.JSONArray dataArrayone = FastjsonUtil.getJSONArray(o.toString(),"items");
  522. // if (dataArrayone == null|| dataArrayone.size() == 0){
  523. // CommonUtil.toastNoRepeat(mActivity,"未搜索到匹配数据");
  524. // }
  525. // for(Object index:dataArrayone){
  526. // com.alibaba.fastjson.JSONObject data = (com.alibaba.fastjson.JSONObject) index;
  527. // masterFuncList.add(data.getString("WC_NAME"));
  528. // }
  529. masterFuncList.add("无");
  530. masterFuncList.add("五虎上将");
  531. masterFuncList.add("2");
  532. masterFuncList.add("3");
  533. masterFuncList.add("4");
  534. masterFuncList.add("5");
  535. masterFuncList.add("6");
  536. adapter = new ArrayAdapter(mActivity, R.layout.item_spinner, R.id.text_spinner, masterFuncList);
  537. masterSpinner.setAdapter(adapter);
  538. }
  539. @Override
  540. protected void initEvents() {
  541. masterSpinner.setOnItemSelectedListener(this);
  542. btnActionbarRight.setOnClickListener(this);
  543. etBarCode.addTextChangedListener(watcher);
  544. mCollectTypeRadioGroup.setOnCheckedChangeListener(this);
  545. mCollectModelBtn.setOnClickListener(this);
  546. mScanImageView.setOnClickListener(this);
  547. etBarCode.setOnEditorActionListener(new TextView.OnEditorActionListener() {
  548. @Override
  549. public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
  550. if (actionId == EditorInfo.IME_ACTION_SEND
  551. || actionId == EditorInfo.IME_ACTION_DONE
  552. || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
  553. confirmEvent();
  554. return true;
  555. }
  556. return false;
  557. }
  558. });
  559. mtypeNameTv.setOnClickListener(new View.OnClickListener() {
  560. @Override
  561. public void onClick(View v) {
  562. String typeName = mtypeNameTv.getText().toString().trim();
  563. if ("条码".equals(typeName)) {
  564. changeToTypeBatch();
  565. } else if ("箱号".equals(typeName)) {
  566. changeToTypeBarcode();
  567. }
  568. }
  569. });
  570. mTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  571. @Override
  572. public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
  573. if (mCollectTypes != null) {
  574. if (mCollectTypes.get(position).equals("条码号")) {
  575. changeToTypeBarcode();
  576. } else if (mCollectTypes.get(position).equals("外箱号")) {
  577. changeToTypeBatch();
  578. }
  579. }
  580. }
  581. @Override
  582. public void onNothingSelected(AdapterView<?> parent) {
  583. }
  584. });
  585. }
  586. /**
  587. * 开始出库
  588. */
  589. private void startchuku(){
  590. progressDialog.show();
  591. String url = GloableParams.ADDRESS_PAD_STARTPRODOUT+ "?id="+pi_id;
  592. PdaApplication.mRequestQueue.cancelAll(TAG);
  593. mCollectTypeRadioGroup.setEnabled(false);
  594. jsonRequest = new JsonObjectRequest(Request.Method.POST, url, null, new Response.Listener<JSONObject>() {
  595. @Override
  596. public void onResponse(JSONObject jsonObject) {
  597. progressDialog.dismiss();
  598. try {
  599. Log.e("jsonObject",jsonObject.toString());
  600. JSONObject dataObject = jsonObject.optJSONObject("data");
  601. JSONObject dataData = dataObject.optJSONObject("next");
  602. Object log = dataObject.get("log");
  603. String bar_prodcode = dataData.getString("PD_PRODCODE");//编号
  604. String pr_detail = dataData.getString("PR_DETAIL");//名称
  605. String pr_spec = dataData.getString("PR_SPEC");//规格
  606. String pd_outqty = dataData.getString("PD_OUTQTY");//出库数量
  607. String pd_restqty = dataData.getString("PD_RESTQTY");
  608. String pr_zxbzs = dataData.getString("PR_ZXBZS");
  609. String bar_remain = dataData.getString("BAR_REMAIN");
  610. String dc = dataData.getString("DC");
  611. mCollectResultTextView.setVisibility(View.VISIBLE);
  612. mCollectResultTextView.setText(log.toString());
  613. mMaterialInforTextView.setText("物料:"+bar_prodcode
  614. +"名称:"+pr_detail
  615. +"规格:"+pr_spec
  616. +"未备料数:"+pd_restqty
  617. +"批数量:"+bar_remain
  618. +"DC:"+dc
  619. );
  620. getNextMaterialInfo();
  621. // JSONObject messageObject = dataObject.getJSONObject("barcode");
  622. CommonUtil.toastNoRepeat(mActivity, "货架点亮成功");
  623. } catch (Exception e) {
  624. e.printStackTrace();
  625. }
  626. }
  627. }, new Response.ErrorListener() {
  628. @Override
  629. public void onErrorResponse(VolleyError volleyError) {
  630. progressDialog.dismiss();
  631. if (getActivity() != null) {
  632. mCollectTypeRadioGroup.setEnabled(true);
  633. CommonUtil.editTextGetFocus(etBarCode);
  634. String errorToast = CommonUtil.showErrorToast(volleyError, true);
  635. mCollectResultTextView.setVisibility(View.VISIBLE);
  636. mCollectResultTextView.setTextColor(getResources().getColor(R.color.red));
  637. mCollectResultTextView.setText(errorToast);
  638. }
  639. }
  640. }) {
  641. @Override
  642. public Map<String, String> getHeaders() throws AuthFailureError {
  643. return VolleyUtil.getVolleyUtil().setCookies();
  644. }
  645. };
  646. jsonRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
  647. jsonRequest.setTag(TAG);
  648. PdaApplication.mRequestQueue.add(jsonRequest);
  649. }
  650. /**
  651. * 结束出库
  652. */
  653. private void stopchuku(){
  654. progressDialog.show();
  655. String url = GloableParams.ADDRESS_COMMON_ENDPRODOUT+ "?id="+pi_id;
  656. PdaApplication.mRequestQueue.cancelAll(TAG);
  657. mCollectTypeRadioGroup.setEnabled(false);
  658. jsonRequest = new JsonObjectRequest(Request.Method.POST, url, null, new Response.Listener<JSONObject>() {
  659. @Override
  660. public void onResponse(JSONObject jsonObject) {
  661. progressDialog.dismiss();
  662. try {
  663. Log.e("jsonObject",jsonObject.toString());
  664. // JSONObject dataObject = jsonObject.optJSONObject("data");
  665. String data = FastjsonUtil.getText(jsonObject.toString(), "data");
  666. mCollectResultTextView.setVisibility(View.VISIBLE);
  667. mCollectResultTextView.setTextColor(getResources().getColor(R.color.blue));
  668. mCollectResultTextView.setText(data.toString());
  669. // JSONObject messageObject = dataObject.getJSONObject("barcode");
  670. CommonUtil.toastNoRepeat(mActivity, data.toString());
  671. } catch (Exception e) {
  672. e.printStackTrace();
  673. }
  674. }
  675. }, new Response.ErrorListener() {
  676. @Override
  677. public void onErrorResponse(VolleyError volleyError) {
  678. progressDialog.dismiss();
  679. if (getActivity() != null) {
  680. mCollectTypeRadioGroup.setEnabled(true);
  681. CommonUtil.editTextGetFocus(etBarCode);
  682. String errorToast = CommonUtil.showErrorToast(volleyError, true);
  683. mCollectResultTextView.setVisibility(View.VISIBLE);
  684. mCollectResultTextView.setTextColor(getResources().getColor(R.color.red));
  685. mCollectResultTextView.setText(errorToast);
  686. }
  687. }
  688. }) {
  689. @Override
  690. public Map<String, String> getHeaders() throws AuthFailureError {
  691. return VolleyUtil.getVolleyUtil().setCookies();
  692. }
  693. };
  694. jsonRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
  695. jsonRequest.setTag(TAG);
  696. PdaApplication.mRequestQueue.add(jsonRequest);
  697. }
  698. /**
  699. * 采集方式切换成箱号
  700. */
  701. private void changeToTypeBatch() {
  702. etBarCode.setHint("请采集箱号");
  703. mtypeNameTv.setText("箱号");
  704. SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBatchcode");
  705. mCollectType = "byBatchcode";
  706. mBarcodeTableLayout.setVisibility(View.GONE);
  707. mBoxTableLayout.setVisibility(View.GONE);
  708. mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno);
  709. if (mResults != null && mResults.size() == 4) {
  710. tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
  711. tvBoxCollectionSuccess.setText("采集成功");
  712. mCollectBoxTv.setText(mResults.get(0));
  713. mCollectBoxNumTv.setText(mResults.get(1));
  714. mCollectBoxrProdcodeTv.setText(mResults.get(2));
  715. mCollectBoxWhcodeTv.setText(mResults.get(3));
  716. } else {
  717. tvBoxCollectionSuccess.setVisibility(View.GONE);
  718. mCollectBoxTv.setText(null);
  719. mCollectBoxNumTv.setText(null);
  720. mCollectBoxrProdcodeTv.setText(null);
  721. mCollectBoxWhcodeTv.setText(null);
  722. }
  723. }
  724. /**
  725. * 采集方式切换成条码号
  726. */
  727. private void changeToTypeBarcode() {
  728. etBarCode.setHint(R.string.please_collect_barcode);
  729. mtypeNameTv.setText("条码");
  730. SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBarcode");
  731. mCollectType = "byBarcode";
  732. // mBarcodeTableLayout.setVisibility(View.VISIBLE);
  733. mBarcodeTableLayout.setVisibility(View.GONE);
  734. mBoxTableLayout.setVisibility(View.GONE);
  735. mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno);
  736. if (mResults != null && mResults.size() == 3) {
  737. tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
  738. tvBarcodeCollectionSuccess.setText("采集成功");
  739. mCollectBarcodeTv.setText(mResults.get(0));
  740. mCollectBarRemainTv.setText(mResults.get(1));
  741. mCollectBarProdcodeTv.setText(mResults.get(2));
  742. } else {
  743. tvBarcodeCollectionSuccess.setVisibility(View.GONE);
  744. mCollectBarcodeTv.setText(null);
  745. mCollectBarRemainTv.setText(null);
  746. mCollectBarProdcodeTv.setText(null);
  747. }
  748. }
  749. @Override
  750. protected void initDatas() {
  751. if (CommonUtil.isNetWorkConnected(mActivity)) {
  752. getNextMaterialInfo();
  753. } else {
  754. CommonUtil.toastNoRepeat(mActivity, getString(R.string.net_not_connect));
  755. mMaterialInforTextView.setText(getString(R.string.net_not_connect));
  756. }
  757. }
  758. /**
  759. * 获取下一采集货品信息
  760. */
  761. private void getNextMaterialInfo() {
  762. progressDialog.show();
  763. String url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH + "?pi_id=" + pi_id + "&pd_whcode=" + pd_whcode;
  764. // if (!isMultiple) {
  765. if (false) {
  766. if (mProdOutType.equals("byProdcode")) {
  767. url = GloableParams.ADDRESS_OUT_GET_NEXT_PRODCODE + "?pi_id=" + pi_id + "&pd_whcode=" + pd_whcode;
  768. } else if (mProdOutType.equals("byBatch")) {
  769. url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH + "?pi_id=" + pi_id + "&pd_whcode=" + pd_whcode;
  770. }
  771. } else {
  772. url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH_DEAL + "?ids=" + pi_id;
  773. if (mProdOutType.equals("byProdcode")) {
  774. url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH_DEAL + "?ids=" + pi_id;
  775. } else if (mProdOutType.equals("byBatch")) {
  776. url = GloableParams.ADDRESS_OUT_GET_NEXT_BATCH_DEAL + "?ids=" + pi_id;
  777. }
  778. }
  779. PdaApplication.mRequestQueue.cancelAll(TAG + "getnext");
  780. mStringRequest = new StringRequest(Request.Method.GET, url,
  781. new Response.Listener<String>() {
  782. @Override
  783. public void onResponse(String s) {
  784. progressDialog.dismiss();
  785. Log.i("materialinfo", s);
  786. MaterialInformationBean materialInformationBean = JsonTools.parseJsonToBean(s, MaterialInformationBean.class);
  787. if (materialInformationBean != null && materialInformationBean.getData() != null) {
  788. String materialInfo =
  789. "型号:" + (materialInformationBean.getData().getPR_ORISPECCODE() == null ? "" : materialInformationBean.getData().getPR_ORISPECCODE())
  790. + "物料:" + (materialInformationBean.getData().getPD_PRODCODE() == null ? "" : materialInformationBean.getData().getPD_PRODCODE())
  791. + "; 名称规格:" + (materialInformationBean.getData().getPR_DETAIL() == null ? "" : materialInformationBean.getData().getPR_DETAIL())
  792. + " " + (materialInformationBean.getData().getPR_SPEC() == null ? "" : materialInformationBean.getData().getPR_SPEC())
  793. + "; 未备料数:" + (materialInformationBean.getData().getPD_RESTQTY() == null ? "" : materialInformationBean.getData().getPD_RESTQTY())
  794. + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getData().getBAR_REMAIN()))
  795. + "; 仓位:" + (materialInformationBean.getData().getBAR_LOCATION() == null ? "" : materialInformationBean.getData().getBAR_LOCATION())
  796. + "; DC:" + (materialInformationBean.getData().getDC() == null ? "" : materialInformationBean.getData().getDC());
  797. if (materialInformationBean.getData().getPD_BATCHCODE() != null) {
  798. materialInfo = materialInfo + "; 批号:" + materialInformationBean.getData().getPD_BATCHCODE();
  799. }
  800. if (mMaterialInforTextView != null)
  801. mMaterialInforTextView.setText(materialInfo);
  802. } else {
  803. if (mMaterialInforTextView != null)
  804. mMaterialInforTextView.setText("该出库单当前的仓库已经完成备料");
  805. }
  806. }
  807. },
  808. new Response.ErrorListener() {
  809. @Override
  810. public void onErrorResponse(VolleyError volleyError) {
  811. progressDialog.dismiss();
  812. String errorMsg = CommonUtil.showErrorToast(volleyError);
  813. if (mMaterialInforTextView != null)
  814. mMaterialInforTextView.setText(errorMsg);
  815. }
  816. }) {
  817. @Override
  818. public Map<String, String> getHeaders() throws AuthFailureError {
  819. return VolleyUtil.getVolleyUtil().setCookies();
  820. }
  821. };
  822. mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
  823. mStringRequest.setTag(TAG + "getnext");
  824. PdaApplication.mRequestQueue.add(mStringRequest);
  825. }
  826. @Override
  827. public boolean onKeyDown(int keyCode, KeyEvent event) {
  828. return false;
  829. }
  830. // 材料出库确认
  831. private IOCOutMakeMaterialOperMsd iocOutMakeMaterialOperMsd;
  832. // 需要拆分材料
  833. private IOCOutmakeMaterialSplitBean mIocoutMaterialSplitBean;
  834. /**
  835. * 在线模式确认按钮提交事件
  836. */
  837. private void barcodeEnterEvent(boolean msdcheck, boolean datecheck) {
  838. progressDialog.show();
  839. boolean checkeds = special_check.isChecked();
  840. // currentBarcode = etBarCode.getText().toString().trim();
  841. String url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
  842. + "?barcode=" + currentBarcode
  843. + (isMultiple ? "&ids=" : "&ids=")
  844. + pi_id + "&whcode=" + pd_whcode
  845. + "&type=barcode&msdcheck=" + msdcheck
  846. + "&datecheck=" + datecheck
  847. +"&ifspecial="+checkeds;
  848. try {
  849. if (mProdOutType != null && mCollectType != null) {
  850. if (mProdOutType.equals("byProdcode")) {
  851. if (mCollectType.equals("byBarcode")) {
  852. url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
  853. + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
  854. + (isMultiple ? "&ids=" : "&ids=")
  855. + pi_id + "&whcode=" + pd_whcode
  856. + "&type=barcode&msdcheck=" + msdcheck
  857. + "&datecheck=" + datecheck
  858. +"&ifspecial="+checkeds;
  859. } else if (mCollectType.equals("byBatchcode")) {
  860. url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
  861. + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
  862. + (isMultiple ? "&ids=" : "&ids=")
  863. + pi_id + "&whcode=" + pd_whcode
  864. + "&type=boxcode&msdcheck=" + msdcheck
  865. + "&datecheck=" + datecheck
  866. +"&ifspecial="+checkeds;
  867. }
  868. } else if (mProdOutType.equals("byBatch")) {
  869. if (mCollectType.equals("byBarcode")) {
  870. url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
  871. + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
  872. + (isMultiple ? "&ids=" : "&ids=")
  873. + pi_id + "&whcode=" + pd_whcode
  874. + "&type=barcode&msdcheck=" + msdcheck
  875. + "&datecheck=" + datecheck
  876. +"&ifspecial="+checkeds;
  877. } else if (mCollectType.equals("byBatchcode")) {
  878. url = (isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_DEAL)
  879. + "?barcode=" + URLEncoder.encode(currentBarcode, "utf-8")
  880. + (isMultiple ? "&ids=" : "&ids=")
  881. + pi_id + "&whcode=" + pd_whcode
  882. + "&type=boxcode&msdcheck=" + msdcheck
  883. + "&datecheck=" + datecheck
  884. +"&ifspecial="+checkeds;
  885. }
  886. }
  887. }
  888. } catch (UnsupportedEncodingException e) {
  889. e.printStackTrace();
  890. }
  891. LogUtil.i("iocouturl", url);
  892. etBarCode.setText(null);
  893. PdaApplication.mRequestQueue.cancelAll(TAG);
  894. mCollectTypeRadioGroup.setEnabled(false);
  895. jsonRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
  896. @Override
  897. public void onResponse(JSONObject jsonObject) {
  898. progressDialog.dismiss();
  899. mResults = new ArrayList<>();
  900. mCollectTypeRadioGroup.setEnabled(true);
  901. LogUtil.e("!!!ok", jsonObject.toString());
  902. try {
  903. JSONObject dataObject = jsonObject.optJSONObject("data");
  904. if (dataObject == null) {
  905. CommonUtil.toastNoRepeat(mActivity, "采集结果获取失败!");
  906. return;
  907. }
  908. etBarCode.setText(null);
  909. JSONObject messageObject = dataObject.getJSONObject("barcode");
  910. if (messageObject.has("IFOVER") && messageObject.optBoolean("IFOVER")) {
  911. new AlertDialog.Builder(mActivity)
  912. .setMessage("采集条码[" + messageObject.optString("BAR_CODE") + "]有效期已过,是否继续采集?")
  913. .setNegativeButton(R.string.cancel, null)
  914. .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
  915. @Override
  916. public void onClick(DialogInterface dialogInterface, int i) {
  917. dialogInterface.dismiss();
  918. barcodeEnterEvent(false, false);
  919. }
  920. }).create().show();
  921. } else if (messageObject.has("ISMSD")) {
  922. if (messageObject.optBoolean("ISMSD")) {
  923. //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
  924. iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
  925. if (iocOutMakeMaterialOperMsd != null) {
  926. Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
  927. mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
  928. mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
  929. showDewPopupWindow();
  930. }
  931. } else {
  932. mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
  933. mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
  934. mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
  935. if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
  936. spliteBarcode(currentBarcode, mBarRemain, mRestqty);
  937. }
  938. }
  939. } else {
  940. mCollectResultTextView.setVisibility(View.VISIBLE);
  941. mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
  942. mCollectResultTextView.setText(null);
  943. // JSONArray listArray = dataObject.optJSONArray("nolist");
  944. if (mCollectType.equals("byBarcode") || mCollectType.equals("byBatchcode")) {
  945. String barcodeResult = "采集成功!\n"
  946. // + JsonUtils.optStringNotNull(dataObject, "finishno")
  947. + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
  948. + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
  949. // + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
  950. + ";\n料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
  951. + ";\n名称规格:" + messageObject.optString("PR_DETAIL")+";";
  952. // + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
  953. // + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
  954. // if (listArray != null && listArray.length() > 0) {
  955. // for (int i = 0; i < listArray.length(); i++) {
  956. // JSONObject listObject = listArray.optJSONObject(i);
  957. // barcodeResult = barcodeResult
  958. // + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
  959. // + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
  960. // + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
  961. // }
  962. // }
  963. String finishno = JsonUtils.optStringNotNull(dataObject, "finishno");
  964. if (!finishno.isEmpty()){
  965. text_finishno.setVisibility(View.VISIBLE);
  966. text_finishno.setText(finishno);
  967. }else {
  968. text_finishno.setVisibility(View.GONE);
  969. }
  970. mCollectResultTextView.setText(barcodeResult);
  971. mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
  972. mBarcodeTableLayout.setVisibility(View.GONE);
  973. mBoxTableLayout.setVisibility(View.GONE);
  974. tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
  975. tvBarcodeCollectionSuccess.setText("采集成功");
  976. mResult1 = messageObject.optString("BAR_CODE");
  977. mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
  978. mResult3 = messageObject.optString("BAR_PRODCODE");
  979. mResults.add(mResult1);
  980. mResults.add(mResult2);
  981. mResults.add(mResult3);
  982. mCollectBarcodeTv.setText(mResult1);
  983. mCollectBarRemainTv.setText(mResult2);
  984. mCollectBarProdcodeTv.setText(mResult3);
  985. PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
  986. } else if (false) {
  987. String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
  988. + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
  989. + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
  990. + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
  991. + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
  992. + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
  993. + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
  994. // if (listArray != null && listArray.length() > 0) {
  995. // for (int i = 0; i < listArray.length(); i++) {
  996. // JSONObject listObject = listArray.optJSONObject(i);
  997. // boxResult = boxResult
  998. // + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
  999. // + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
  1000. // + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
  1001. // }
  1002. // }
  1003. mCollectResultTextView.setText(boxResult);
  1004. mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
  1005. mBarcodeTableLayout.setVisibility(View.GONE);
  1006. mBoxTableLayout.setVisibility(View.GONE);
  1007. tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
  1008. tvBoxCollectionSuccess.setText("采集成功");
  1009. mResult1 = messageObject.optString("PA_OUTBOXCODE");
  1010. mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
  1011. mResult3 = messageObject.optString("PA_PRODCODE");
  1012. mResult4 = messageObject.optString("PA_WHCODE");
  1013. mResults.add(mResult1);
  1014. mResults.add(mResult2);
  1015. mResults.add(mResult3);
  1016. mResults.add(mResult4);
  1017. mCollectBoxTv.setText(mResult1);
  1018. mCollectBoxNumTv.setText(mResult2);
  1019. mCollectBoxrProdcodeTv.setText(mResult3);
  1020. mCollectBoxWhcodeTv.setText(mResult4);
  1021. PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
  1022. }
  1023. CommonUtil.toastNoRepeat(getActivity(), "采集成功");
  1024. Object next = jsonObject.getJSONObject("data").get("next");
  1025. if (next != null && !"null".equals(next.toString())) {
  1026. JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
  1027. MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
  1028. if (materialInformationBean != null) {
  1029. String materialInfo =
  1030. "型号:" + (materialInformationBean.getPR_ORISPECCODE() == null ? "" : materialInformationBean.getPR_ORISPECCODE())
  1031. + "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
  1032. + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
  1033. + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
  1034. + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
  1035. + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
  1036. + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
  1037. if (materialInformationBean.getPD_BATCHCODE() != null) {
  1038. materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
  1039. }
  1040. mMaterialInforTextView.setText(materialInfo);
  1041. }
  1042. } else {
  1043. mMaterialInforTextView.setText("该出库单已经完成备料");
  1044. }
  1045. }
  1046. } catch (JSONException e) {
  1047. e.printStackTrace();
  1048. }
  1049. }
  1050. }, new Response.ErrorListener() {
  1051. @Override
  1052. public void onErrorResponse(VolleyError volleyError) {
  1053. progressDialog.dismiss();
  1054. if (getActivity() != null) {
  1055. mCollectTypeRadioGroup.setEnabled(true);
  1056. CommonUtil.editTextGetFocus(etBarCode);
  1057. String errorToast = CommonUtil.showErrorToast(volleyError, true);
  1058. mCollectResultTextView.setVisibility(View.VISIBLE);
  1059. mCollectResultTextView.setTextColor(getResources().getColor(R.color.red));
  1060. mCollectResultTextView.setText(errorToast);
  1061. }
  1062. }
  1063. }) {
  1064. @Override
  1065. public Map<String, String> getHeaders() throws AuthFailureError {
  1066. return VolleyUtil.getVolleyUtil().setCookies();
  1067. }
  1068. };
  1069. jsonRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
  1070. jsonRequest.setTag(TAG);
  1071. PdaApplication.mRequestQueue.add(jsonRequest);
  1072. }
  1073. /**
  1074. * 创建PopupWindow
  1075. */
  1076. private PopupWindow popupWindow;
  1077. private AdapterPopupWindow adapterPopupWindow;
  1078. private Button dewOperConfirmBtn, btnDewCancel;
  1079. protected void showDewPopupWindow() {
  1080. try {
  1081. LayoutInflater inflater = LayoutInflater.from(getActivity());
  1082. View contentView = inflater.inflate(R.layout.popupwindow_ioc_out_make_material_oper, null);
  1083. ListView dewOperLv = (ListView) contentView.findViewById(R.id.dew_oper_lv);
  1084. ((TextView) contentView.findViewById(R.id.tv_ms_level)).setText(iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getMS_LEVEL());
  1085. ((TextView) contentView.findViewById(R.id.tv_status)).setText(iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getSTATUS());
  1086. if (iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getMS_RESTTIME() == -1) {
  1087. ((TextView) contentView.findViewById(R.id.tv_ms_resttime)).setText("999");
  1088. } else {
  1089. ((TextView) contentView.findViewById(R.id.tv_ms_resttime)).setText(iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getMS_RESTTIME() + "");
  1090. }
  1091. dewOperConfirmBtn = (Button) contentView.findViewById(R.id.dew_oper_confirm_btn);
  1092. btnDewCancel = (Button) contentView.findViewById(R.id.btn_dew_cancel);
  1093. dewOperConfirmBtn.setOnClickListener(this);
  1094. btnDewCancel.setOnClickListener(this);
  1095. adapterPopupWindow = new AdapterPopupWindow(getActivity(), R.layout.item_list_ioc_out_make_material_oper, iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getLog());
  1096. dewOperLv.setAdapter(adapterPopupWindow);
  1097. //item 的点击事件
  1098. dewOperLv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  1099. @Override
  1100. public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
  1101. /* IOCOutMakeMaterialSubmit.Data data = dataListPopupWindow.get(i);
  1102. dataList.add(data);
  1103. adapterListView.notifyDataSetChanged();
  1104. closePopupWindow();
  1105. reset();*/
  1106. }
  1107. });
  1108. // PopupWindow实例化
  1109. popupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.WRAP_CONTENT,
  1110. LinearLayout.LayoutParams.WRAP_CONTENT, true);
  1111. popupWindow.setAnimationStyle(R.style.MenuAnimationFade);
  1112. // 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
  1113. popupWindow.showAtLocation(btnConfirm, Gravity.CENTER, 0, 0);
  1114. popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
  1115. @Override
  1116. public void onDismiss() {
  1117. closePopupWindow();
  1118. }
  1119. });
  1120. //获取最底层窗口的参数,背景变灰色效果
  1121. CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
  1122. } catch (Exception e) {
  1123. }
  1124. }
  1125. @Override
  1126. public void onCheckedChanged(RadioGroup group, int checkedId) {
  1127. switch (checkedId) {
  1128. case R.id.iocout_collect_barcode_rb:
  1129. etBarCode.setHint(R.string.please_collect_barcode);
  1130. mtypeNameTv.setText("条码号");
  1131. SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBarcode");
  1132. mCollectType = "byBarcode";
  1133. mBarcodeTableLayout.setVisibility(View.VISIBLE);
  1134. mBoxTableLayout.setVisibility(View.GONE);
  1135. mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno);
  1136. if (mResults != null && mResults.size() == 3) {
  1137. tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
  1138. tvBarcodeCollectionSuccess.setText("采集成功");
  1139. mCollectBarcodeTv.setText(mResults.get(0));
  1140. mCollectBarRemainTv.setText(mResults.get(1));
  1141. mCollectBarProdcodeTv.setText(mResults.get(2));
  1142. } else {
  1143. tvBarcodeCollectionSuccess.setVisibility(View.GONE);
  1144. mCollectBarcodeTv.setText(null);
  1145. mCollectBarRemainTv.setText(null);
  1146. mCollectBarProdcodeTv.setText(null);
  1147. }
  1148. break;
  1149. case R.id.iocout_collect_box_rb:
  1150. etBarCode.setHint(R.string.please_collect_box);
  1151. mtypeNameTv.setText("外箱号");
  1152. SharedPreUtil.saveString(getActivity().getApplicationContext(), Constants.FLAG.MATERIAL_OUT_COLLECT_TYPE, "byBatchcode");
  1153. mCollectType = "byBatchcode";
  1154. mBarcodeTableLayout.setVisibility(View.GONE);
  1155. mBoxTableLayout.setVisibility(View.VISIBLE);
  1156. mResults = (List<String>) PdaApplication.getDataCacheFromMap(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno);
  1157. if (mResults != null && mResults.size() == 4) {
  1158. tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
  1159. tvBoxCollectionSuccess.setText("采集成功");
  1160. mCollectBoxTv.setText(mResults.get(0));
  1161. mCollectBoxNumTv.setText(mResults.get(1));
  1162. mCollectBoxrProdcodeTv.setText(mResults.get(2));
  1163. mCollectBoxWhcodeTv.setText(mResults.get(3));
  1164. } else {
  1165. mCollectBoxTv.setText(null);
  1166. mCollectBoxNumTv.setText(null);
  1167. mCollectBoxrProdcodeTv.setText(null);
  1168. mCollectBoxWhcodeTv.setText(null);
  1169. }
  1170. break;
  1171. }
  1172. }
  1173. @Override
  1174. public void onSuccess(int flag, Object o) throws Exception {
  1175. if (flag == FLAG_CONFIRM_POST) {
  1176. progressDialog.dismiss();
  1177. CommonUtil.toastNoRepeat(mActivity, "过账成功");
  1178. }
  1179. }
  1180. @Override
  1181. public void onFail(int flag, String failStr) throws Exception {
  1182. if (flag == FLAG_CONFIRM_POST) {
  1183. progressDialog.dismiss();
  1184. CommonUtil.toastNoRepeat(mActivity, failStr);
  1185. }
  1186. }
  1187. @Override
  1188. public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
  1189. //获得master的name
  1190. maFunName = masterFuncList.get(position);
  1191. LogUtil.i("maname",maFunName);
  1192. }
  1193. @Override
  1194. public void onNothingSelected(AdapterView<?> parent) {
  1195. }
  1196. /**
  1197. * popupWindow 设置适配器
  1198. */
  1199. private class AdapterPopupWindow extends BaseAdapter {
  1200. private int resourceId;
  1201. private List<IOCOutMakeMaterialOperMsd.DataBean.BarcodeBean.MsdBean.LogBean> objects;
  1202. private Context mContext;
  1203. public AdapterPopupWindow(Context context, int resource, List<IOCOutMakeMaterialOperMsd.DataBean.BarcodeBean.MsdBean.LogBean> objects) {
  1204. resourceId = resource;
  1205. this.objects = objects;
  1206. mContext = context;
  1207. }
  1208. @Override
  1209. public int getCount() {
  1210. return objects == null ? 0 : objects.size();
  1211. }
  1212. @Override
  1213. public Object getItem(int position) {
  1214. return objects == null ? null : objects.get(position);
  1215. }
  1216. @Override
  1217. public long getItemId(int position) {
  1218. return position;
  1219. }
  1220. @Override
  1221. public View getView(int position, View convertView, ViewGroup parent) {
  1222. ViewHolder viewHolder = null;
  1223. if (convertView == null) {
  1224. convertView = View.inflate(mContext, resourceId, null);
  1225. viewHolder = new ViewHolder();
  1226. viewHolder.dateTextView = (TextView) convertView.findViewById(R.id.tv_date);
  1227. viewHolder.lifeTimeTextView = (TextView) convertView.findViewById(R.id.tv_lifetime);
  1228. viewHolder.actionTextView = (TextView) convertView.findViewById(R.id.tv_action);
  1229. viewHolder.manTextView = (TextView) convertView.findViewById(R.id.tv_man);
  1230. convertView.setTag(viewHolder);
  1231. } else {
  1232. viewHolder = (ViewHolder) convertView.getTag();
  1233. }
  1234. viewHolder.actionTextView.setText(objects.get(position).getMS_ACTION());
  1235. viewHolder.dateTextView.setText(objects.get(position).getMS_DATE() + "");
  1236. viewHolder.lifeTimeTextView.setText(objects.get(position).getMS_LIFETIME() + "");
  1237. viewHolder.manTextView.setText(objects.get(position).getMS_MAN());
  1238. return convertView;
  1239. }
  1240. }
  1241. class ViewHolder {
  1242. TextView dateTextView;
  1243. TextView lifeTimeTextView;
  1244. TextView actionTextView;
  1245. TextView manTextView;
  1246. }
  1247. @Override
  1248. public void onClick(View view) {
  1249. switch (view.getId()) {
  1250. case R.id.btn_actionbar_more:
  1251. View materialOutMoreView = View.inflate(getActivity(), R.layout.pop_material_out_menu, null);
  1252. Button stockTaskBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_1);
  1253. Button stockAlreadyBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_2);
  1254. Button stockRevokeBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_3);
  1255. Button stockModifyBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_4);
  1256. Button stockSpecialBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_5);
  1257. Button passBillBtn = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_6);
  1258. Button stockDataSummary = (Button) materialOutMoreView.findViewById(R.id.pop_material_out_menu_7);
  1259. stockTaskBtn.setOnClickListener(new View.OnClickListener() {
  1260. @Override
  1261. public void onClick(View v) {
  1262. closeListPopupWindow();
  1263. ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
  1264. ((FunctionActivity) getActivity()).setScanIvVisible(false);
  1265. if (isMultiple) {
  1266. clickToFragment(new MaterialOutStockTaskMultipleFragment());
  1267. } else {
  1268. clickToFragment(new MaterialOutStockTaskMultipleFragment());
  1269. // clickToFragment(new MaterialOutStockTaskFragment());
  1270. }
  1271. }
  1272. });
  1273. stockDataSummary.setOnClickListener(new View.OnClickListener() {
  1274. @Override
  1275. public void onClick(View v) {
  1276. closeListPopupWindow();
  1277. ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
  1278. ((FunctionActivity) getActivity()).setScanIvVisible(false);
  1279. clickToFragment(new StockDataSummaryFragment());
  1280. }
  1281. });
  1282. stockAlreadyBtn.setOnClickListener(new View.OnClickListener() {
  1283. @Override
  1284. public void onClick(View v) {
  1285. closeListPopupWindow();
  1286. ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
  1287. ((FunctionActivity) getActivity()).setScanIvVisible(false);
  1288. clickToFragment(new MaterialOutStockAlreadyFragment());
  1289. }
  1290. });
  1291. stockRevokeBtn.setOnClickListener(new View.OnClickListener() {
  1292. @Override
  1293. public void onClick(View v) {
  1294. closeListPopupWindow();
  1295. ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
  1296. // ((FunctionActivity) getActivity()).setScanIvVisible(false);
  1297. clickToFragment(new MaterialOutRevocationStockFragment());
  1298. }
  1299. });
  1300. stockModifyBtn.setOnClickListener(new View.OnClickListener() {
  1301. @Override
  1302. public void onClick(View v) {
  1303. closeListPopupWindow();
  1304. ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
  1305. // ((FunctionActivity) getActivity()).setScanIvVisible(false);
  1306. clickToFragment(new ModifyQuantityOutFragment());
  1307. }
  1308. });
  1309. stockSpecialBtn.setOnClickListener(new View.OnClickListener() {
  1310. @Override
  1311. public void onClick(View v) {
  1312. closeListPopupWindow();
  1313. ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
  1314. // ((FunctionActivity) getActivity()).setScanIvVisible(false);
  1315. clickToFragment(new SpecialMaterialOutFragment());
  1316. }
  1317. });
  1318. passBillBtn.setOnClickListener(new View.OnClickListener() {
  1319. @Override
  1320. public void onClick(View view) {
  1321. closeListPopupWindow();
  1322. new AlertDialog.Builder(mActivity)
  1323. .setMessage("确认将单据过账?")
  1324. .setNegativeButton(R.string.cancel, null)
  1325. .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
  1326. @Override
  1327. public void onClick(DialogInterface dialogInterface, int i) {
  1328. dialogInterface.dismiss();
  1329. progressDialog.show();
  1330. VolleyRequest.getInstance().stringRequest(mStringRequest,
  1331. new HttpParams.Builder()
  1332. .url(GloableParams.ADDRESS_INMATERIAL_CONFIRMPOST)
  1333. .method(Request.Method.POST)
  1334. .addParam("piid", pi_id)
  1335. .tag(TAG + "confirmpost")
  1336. .flag(FLAG_CONFIRM_POST).build(),
  1337. 30 * 1000, AGVIOCOutMakeMaterialOper.this);
  1338. }
  1339. }).create().show();
  1340. }
  1341. });
  1342. listPopupWindow = new PopupWindow(materialOutMoreView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
  1343. listPopupWindow.setBackgroundDrawable(new BitmapDrawable());
  1344. listPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
  1345. @Override
  1346. public void onDismiss() {
  1347. closeListPopupWindow();
  1348. }
  1349. });
  1350. CommonUtil.setBackgroundAlpha(getActivity(), 0.5f);
  1351. listPopupWindow.showAsDropDown(btnActionbarRight);
  1352. /*View materialOutMoreView = View.inflate(getActivity(), R.layout.popupwindow_material_out_listview, null);
  1353. Button hadCollectBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_1);
  1354. Button noCollectBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_2);
  1355. Button reCollectBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_3);
  1356. Button noSubmitBtn = (Button) materialOutMoreView.findViewById(R.id.material_out_menu_4);
  1357. if (mCollectModel == 1) {
  1358. noSubmitBtn.setVisibility(View.GONE);
  1359. } else {
  1360. noSubmitBtn.setVisibility(View.VISIBLE);
  1361. }
  1362. hadCollectBtn.setOnClickListener(new View.OnClickListener() {
  1363. @Override
  1364. public void onClick(View v) {
  1365. closeListPopupWindow();
  1366. ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
  1367. clickToFragment(new CollectAlreadyFragment());
  1368. }
  1369. });
  1370. noCollectBtn.setOnClickListener(new View.OnClickListener() {
  1371. @Override
  1372. public void onClick(View v) {
  1373. closeListPopupWindow();
  1374. ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
  1375. clickToFragment(new CollectNotFragment());
  1376. }
  1377. });
  1378. reCollectBtn.setOnClickListener(new View.OnClickListener() {
  1379. @Override
  1380. public void onClick(View v) {
  1381. closeListPopupWindow();
  1382. progressDialog.show();
  1383. mDbManager.deleteFromBarcodeIo(new String[]{pi_id, pd_whcode}, "LBI_PIID=? and LBI_WHCODE=?");
  1384. getAgainEvent();
  1385. }
  1386. });
  1387. noSubmitBtn.setOnClickListener(new View.OnClickListener() {
  1388. @Override
  1389. public void onClick(View v) {
  1390. closeListPopupWindow();
  1391. ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
  1392. clickToFragment(new SubmitNotFragment());
  1393. }
  1394. });
  1395. listPopupWindow = new PopupWindow(materialOutMoreView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
  1396. // popupWindow.setAnimationStyle(R.style.MenuAnimationFade);
  1397. listPopupWindow.setBackgroundDrawable(new BitmapDrawable());
  1398. listPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
  1399. @Override
  1400. public void onDismiss() {
  1401. closeListPopupWindow();
  1402. }
  1403. });
  1404. CommonUtil.setBackgroundAlpha(getActivity(), 0.5f);
  1405. listPopupWindow.showAsDropDown(btnActionbarRight);*/
  1406. break;
  1407. case R.id.dew_oper_confirm_btn:
  1408. if (iocOutMakeMaterialOperMsd.getData().getBarcode().getMsd().getSTATUS().equals("在烘烤")) {
  1409. new AlertDialog.Builder(getActivity()).setTitle("提示")
  1410. .setMessage("是否出烤箱?")
  1411. .setPositiveButton("确定", new DialogInterface.OnClickListener() {
  1412. @Override
  1413. public void onClick(DialogInterface dialog, int which) {
  1414. dialog.dismiss();
  1415. popupWindow.dismiss();
  1416. progressDialog.show();
  1417. outOvenEvent();
  1418. }
  1419. })
  1420. .setNegativeButton("取消", new DialogInterface.OnClickListener() {
  1421. @Override
  1422. public void onClick(DialogInterface dialog, int which) {
  1423. dialog.dismiss();
  1424. }
  1425. })
  1426. .show();
  1427. } else {
  1428. double bar_remain = iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN();
  1429. double restqty = iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY();
  1430. if (CommonUtil.doubleCompare(bar_remain, restqty) == 1) {
  1431. spliteBarcode(currentBarcode, bar_remain + "", restqty + "");
  1432. } else {
  1433. closePopupWindow();
  1434. barcodeEnterEvent(true, false);
  1435. }
  1436. }
  1437. break;
  1438. case R.id.btn_dew_cancel:
  1439. //点击取消按钮,关闭窗口
  1440. closePopupWindow();
  1441. // clearAll();
  1442. break;
  1443. case R.id.iocout_collect_model_btn:
  1444. if (mCollectModelBtn.getText().toString().trim().equals("在线")) {
  1445. mCollectModelBtn.setText("离线");
  1446. mCollectModel = 0;
  1447. } else if (mCollectModelBtn.getText().toString().trim().equals("离线")) {
  1448. List<TableLBARCODEIO> allBarcodeIo = new ArrayList<>();
  1449. if (mDbManager.getDb().isOpen()) {
  1450. allBarcodeIo = mDbManager.queryFromBarcodeIo(new String[]{"out", pi_id, pd_whcode}, "inOrOut=? and LBI_PIID=? and LBI_WHCODE=?");
  1451. }
  1452. if (CommonUtil.isNetWorkConnected(getActivity())) {
  1453. if (allBarcodeIo.size() != 0) {
  1454. CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.auto_upload_offline_data));
  1455. submitOfflineData(allBarcodeIo, false);
  1456. } else {
  1457. mCollectModelBtn.setText("在线");
  1458. mCollectModel = 1;
  1459. }
  1460. } else {
  1461. mCollectModelBtn.setText("离线");
  1462. mCollectModel = 0;
  1463. CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
  1464. }
  1465. }
  1466. break;
  1467. case R.id.btn_actionbar_scan_iv:
  1468. if (CameraUtil.hasCamera()) {
  1469. if (root.findFocus() != null) {
  1470. mFocusId = root.findFocus().getId();
  1471. Intent intent = new Intent();
  1472. intent.setClass(mActivity, CaptureActivity.class);
  1473. startActivityForResult(intent, SCAN_BARCODE_CODE);
  1474. }
  1475. } else {
  1476. CommonUtil.toastNoRepeat(mActivity, getString(R.string.no_camera_detected));
  1477. }
  1478. break;
  1479. default:
  1480. break;
  1481. }
  1482. }
  1483. @Override
  1484. public void onActivityResult(int requestCode, int resultCode, Intent data) {
  1485. super.onActivityResult(requestCode, resultCode, data);
  1486. if (resultCode != Activity.RESULT_OK) {
  1487. return;
  1488. }
  1489. if (requestCode == SCAN_BARCODE_CODE && data != null) {
  1490. if (data.getExtras() != null) {
  1491. String result = data.getExtras().getString(CodeUtils.RESULT_STRING);
  1492. if (mFocusId == R.id.et_bar_code) {
  1493. etBarCode.setText(result);
  1494. etBarCode.setSelection(result.length());
  1495. }
  1496. }
  1497. }
  1498. }
  1499. @Override
  1500. public void onHiddenChanged(boolean hidden) {
  1501. super.onHiddenChanged(hidden);
  1502. if (!hidden) {
  1503. FunctionActivity.setTitle(getResources().getString(R.string.avgout_material_collect));
  1504. ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
  1505. ((FunctionActivity) getActivity()).setScanIvVisible(true);
  1506. mScanImageView.setOnClickListener(this);
  1507. etBarCode.requestFocus();
  1508. isConnected = (SharedPreUtil.getInt(mActivity, "printConnect", 0) == 1);
  1509. mOldAddress = SharedPreUtil.getString(mActivity, "printAddress", "");
  1510. mPrintDpi = SharedPreUtil.getInt(mActivity, "printDpi", 203);
  1511. } else {
  1512. ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
  1513. ((FunctionActivity) getActivity()).setScanIvVisible(false);
  1514. }
  1515. }
  1516. /**
  1517. * 出烘烤
  1518. */
  1519. private void outOvenEvent() {
  1520. String url = GloableParams.ADDRESS_MSDOUTOVEN + "?code=" + currentBarcode;
  1521. stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
  1522. @Override
  1523. public void onResponse(String s) {
  1524. progressDialog.dismiss();
  1525. Toast.makeText(getActivity().getApplicationContext(), "出烘烤成功", Toast.LENGTH_SHORT).show();
  1526. double bar_remain = iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN();
  1527. double restqty = iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY();
  1528. if (CommonUtil.doubleCompare(bar_remain, restqty) == 1) {
  1529. spliteBarcode(currentBarcode, bar_remain + "", restqty + "");
  1530. } else {
  1531. closePopupWindow();
  1532. }
  1533. }
  1534. }, new Response.ErrorListener() {
  1535. @Override
  1536. public void onErrorResponse(VolleyError volleyError) {
  1537. //显示处理后的错误信息
  1538. progressDialog.dismiss();
  1539. if (volleyError != null && volleyError.networkResponse != null && volleyError.networkResponse.data != null) {
  1540. ErrorMsg errorMsg = JsonTools.parseJsonToBean(new String(volleyError.networkResponse.data), ErrorMsg.class);
  1541. if (errorMsg == null) {
  1542. Toast.makeText(mActivity, "系统错误", Toast.LENGTH_LONG).show();
  1543. } else {
  1544. String exceptionInfo = errorMsg.exceptionInfo;
  1545. if (exceptionInfo.contains("无需出")) {
  1546. Toast.makeText(mActivity, "已出烘烤", Toast.LENGTH_LONG).show();
  1547. } else {
  1548. Toast.makeText(mActivity, "出烘烤失败", Toast.LENGTH_LONG).show();
  1549. // etBarCode.setText("");
  1550. // CommonUtil.editTextGetFocus(etBarCode);
  1551. }
  1552. }
  1553. }
  1554. }
  1555. }) {
  1556. @Override
  1557. public Map<String, String> getHeaders() throws AuthFailureError {
  1558. String cookie = SharedPreUtil.getString(getActivity().getApplicationContext(), "cookie", null);
  1559. Map<String, String> headers = new HashMap<>();
  1560. headers.put("Cookie", cookie);
  1561. return headers;
  1562. }
  1563. };
  1564. stringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
  1565. stringRequest.setTag(TAG);
  1566. PdaApplication.mRequestQueue.add(stringRequest);
  1567. }
  1568. private void spliteBarcode(final String currentBarcode, String barRemain, String restqty) {
  1569. new AlertDialog.Builder(getActivity()).setTitle("提示")
  1570. .setMessage("条码数量(" + barRemain + ")大于剩余需要采集数量(" + restqty + "),确认拆分?")
  1571. .setPositiveButton("确认", new DialogInterface.OnClickListener() {
  1572. @Override
  1573. public void onClick(DialogInterface dialog, int which) {
  1574. if (!CommonUtil.isRepeatClick())
  1575. breakingBtnClickEvent(currentBarcode);
  1576. }
  1577. })
  1578. .setNegativeButton("取消", new DialogInterface.OnClickListener() {
  1579. @Override
  1580. public void onClick(DialogInterface dialog, int which) {
  1581. dialog.dismiss();
  1582. }
  1583. })
  1584. .show();
  1585. }
  1586. /**
  1587. * 分拆批次
  1588. *
  1589. * @param currentBarcode
  1590. */
  1591. private void breakingBtnClickEvent(final String currentBarcode) {
  1592. progressDialog.show();
  1593. String url = isMultiple ? GloableParams.ADDRESS_OUT_BYBATCH_BREAK_DEAL : GloableParams.ADDRESS_OUT_BYBATCH_BREAK_DEAL;
  1594. Log.d("breakDeal", url);
  1595. VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
  1596. .url(url)
  1597. .method(Request.Method.POST)
  1598. .addParam("ids", pi_id)
  1599. .addParam("barcode", currentBarcode)
  1600. .addParam("or_remain", mBarRemain)
  1601. .addParam("bar_remain", mRestqty)
  1602. .build(), new HttpCallback() {
  1603. @Override
  1604. public void onSuccess(int flag, Object o) throws Exception {
  1605. progressDialog.dismiss();
  1606. String s = o.toString();
  1607. if (popupWindow != null && popupWindow.isShowing())
  1608. closePopupWindow();
  1609. mResults = new ArrayList<>();
  1610. mCollectTypeRadioGroup.setEnabled(true);
  1611. LogUtil.e("breaking", s);
  1612. try {
  1613. JSONObject jsonObject = new JSONObject(s);
  1614. JSONObject dataObject = jsonObject.optJSONObject("data");
  1615. if (dataObject == null) {
  1616. return;
  1617. }
  1618. JSONObject messageObject = dataObject.optJSONObject("barcode");
  1619. if (messageObject == null) {
  1620. return;
  1621. }
  1622. if (messageObject.has("ISMSD")) {
  1623. if (messageObject.optBoolean("ISMSD")) {
  1624. //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
  1625. iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
  1626. // Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
  1627. mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
  1628. mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
  1629. showDewPopupWindow();
  1630. } else {
  1631. mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
  1632. mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
  1633. mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
  1634. if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
  1635. spliteBarcode(currentBarcode, mBarRemain, mRestqty);
  1636. }
  1637. }
  1638. } else {
  1639. mCollectResultTextView.setVisibility(View.VISIBLE);
  1640. mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
  1641. mCollectResultTextView.setText(null);
  1642. JSONArray listArray = dataObject.optJSONArray("nolist");
  1643. if (mCollectType.equals("byBarcode") || mCollectType.equals("byBatchcode")) {
  1644. String barcodeResult = "采集成功!"
  1645. // + JsonUtils.optStringNotNull(dataObject, "finishno")
  1646. + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
  1647. + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
  1648. // + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
  1649. + ";\n料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
  1650. + ";\n名称规格:" + messageObject.optString("PR_DETAIL");
  1651. // + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC")
  1652. // + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
  1653. if (listArray != null && listArray.length() > 0) {
  1654. // for (int i = 0; i < listArray.length(); i++) {
  1655. // JSONObject listObject = listArray.optJSONObject(i);
  1656. // barcodeResult = barcodeResult
  1657. // + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
  1658. // + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
  1659. // + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
  1660. // }
  1661. //弹出拆分结果弹框
  1662. initBreakPopupWindow(listArray,"1");
  1663. }
  1664. String finishno = JsonUtils.optStringNotNull(dataObject, "finishno");
  1665. if (!finishno.isEmpty()){
  1666. text_finishno.setVisibility(View.VISIBLE);
  1667. text_finishno.setText(finishno);
  1668. }else {
  1669. text_finishno.setVisibility(View.GONE);
  1670. }
  1671. mCollectResultTextView.setText(barcodeResult);
  1672. mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
  1673. mBarcodeTableLayout.setVisibility(View.GONE);
  1674. mBoxTableLayout.setVisibility(View.GONE);
  1675. tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
  1676. tvBarcodeCollectionSuccess.setText("采集成功");
  1677. mResult1 = messageObject.optString("BAR_CODE");
  1678. mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
  1679. mResult3 = messageObject.optString("BAR_PRODCODE");
  1680. mResults.add(mResult1);
  1681. mResults.add(mResult2);
  1682. mResults.add(mResult3);
  1683. mCollectBarcodeTv.setText(mResult1);
  1684. mCollectBarRemainTv.setText(mResult2);
  1685. mCollectBarProdcodeTv.setText(mResult3);
  1686. PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
  1687. } else if (false) {
  1688. String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
  1689. + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
  1690. + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
  1691. + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
  1692. + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
  1693. + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
  1694. + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
  1695. if (listArray != null && listArray.length() > 0) {
  1696. for (int i = 0; i < listArray.length(); i++) {
  1697. JSONObject listObject = listArray.optJSONObject(i);
  1698. boxResult = boxResult
  1699. + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
  1700. + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
  1701. + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
  1702. }
  1703. }
  1704. mCollectResultTextView.setText(boxResult);
  1705. mCollectResultTextView.setTextColor(getResources().getColor(R.color.green));
  1706. mBarcodeTableLayout.setVisibility(View.GONE);
  1707. mBoxTableLayout.setVisibility(View.GONE);
  1708. tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
  1709. tvBoxCollectionSuccess.setText("采集成功");
  1710. mResult1 = messageObject.optString("PA_OUTBOXCODE");
  1711. mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
  1712. mResult3 = messageObject.optString("PA_PRODCODE");
  1713. mResult4 = messageObject.optString("PA_WHCODE");
  1714. mResults.add(mResult1);
  1715. mResults.add(mResult2);
  1716. mResults.add(mResult3);
  1717. mResults.add(mResult4);
  1718. mCollectBoxTv.setText(mResult1);
  1719. mCollectBoxNumTv.setText(mResult2);
  1720. mCollectBoxrProdcodeTv.setText(mResult3);
  1721. mCollectBoxWhcodeTv.setText(mResult4);
  1722. PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
  1723. }
  1724. CommonUtil.toastNoRepeat(getActivity(), "采集成功");
  1725. Object next = jsonObject.getJSONObject("data").get("next");
  1726. if (next != null && !"null".equals(next.toString())) {
  1727. JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
  1728. MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
  1729. if (materialInformationBean != null) {
  1730. String materialInfo =
  1731. "型号:" + (materialInformationBean.getPR_ORISPECCODE() == null ? "" : materialInformationBean.getPR_ORISPECCODE())
  1732. + "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
  1733. + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
  1734. + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
  1735. + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
  1736. + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
  1737. + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
  1738. if (materialInformationBean.getPD_BATCHCODE() != null) {
  1739. materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
  1740. }
  1741. mMaterialInforTextView.setText(materialInfo);
  1742. }
  1743. } else {
  1744. mMaterialInforTextView.setText("该出库单已经完成备料");
  1745. }
  1746. }
  1747. } catch (JSONException e) {
  1748. e.printStackTrace();
  1749. }
  1750. }
  1751. @Override
  1752. public void onFail(int flag, String failStr) throws Exception {
  1753. progressDialog.dismiss();
  1754. if (getActivity() != null) {
  1755. try {
  1756. etBarCode.setText(null);
  1757. CommonUtil.editTextGetFocus(etBarCode);
  1758. CommonUtil.makeNotice();
  1759. CommonUtil.toastNoRepeat(getActivity(), failStr);
  1760. } catch (Exception e) {
  1761. e.printStackTrace();
  1762. }
  1763. }
  1764. }
  1765. });
  1766. /*RequestBody requestBody = new FormBody.Builder()
  1767. .add("ids", pi_id)
  1768. .add("barcode", currentBarcode)
  1769. .add("or_remain", mBarRemain)
  1770. .add("bar_remain", mRestqty)
  1771. .build();
  1772. okhttp3.Request.Builder builder = new okhttp3.Request.Builder().url(url).post(requestBody);
  1773. Map<String, String> cookiesMap = VolleyUtil.getVolleyUtil().setCookies();
  1774. if (cookiesMap != null) {
  1775. Set<String> keys = cookiesMap.keySet();
  1776. Iterator<String> iterator = keys.iterator();
  1777. while (iterator.hasNext()) {
  1778. String key = iterator.next();
  1779. String value = cookiesMap.get(key);
  1780. builder.addHeader(key, value);
  1781. }
  1782. }
  1783. mRequest = builder.build();
  1784. mOkHttpClient.newCall(mRequest).enqueue(new Callback() {
  1785. @Override
  1786. public void onFailure(Call call, IOException e) {
  1787. progressDialog.dismiss();
  1788. Message message = Message.obtain();
  1789. message.what = SPLIT_BARCODE_FAIL;
  1790. message.obj = "{\"exceptionInfo\":\"条码拆分异常\"}";
  1791. mHandler.sendMessage(message);
  1792. }
  1793. @Override
  1794. public void onResponse(Call call, okhttp3.Response response) throws IOException {
  1795. progressDialog.dismiss();
  1796. String s = response.body().string();
  1797. if (response.code() == 200) {
  1798. Message message = Message.obtain();
  1799. message.what = SPLIT_BARCODE_SUCCESS;
  1800. message.obj = s;
  1801. mHandler.sendMessage(message);
  1802. } else {
  1803. Message message = Message.obtain();
  1804. message.what = SPLIT_BARCODE_FAIL;
  1805. message.obj = s;
  1806. mHandler.sendMessage(message);
  1807. }
  1808. }
  1809. });
  1810. */
  1811. /*stringRequest = new StringRequest(Request.Method.POST, url,
  1812. new Response.Listener<String>() {
  1813. @Override
  1814. public void onResponse(String s) {
  1815. progressDialog.dismiss();
  1816. if (popupWindow != null && popupWindow.isShowing())
  1817. closePopupWindow();
  1818. mResults = new ArrayList<>();
  1819. mCollectTypeRadioGroup.setEnabled(true);
  1820. LogUtil.e("breaking", s);
  1821. try {
  1822. JSONObject jsonObject = new JSONObject(s);
  1823. JSONObject dataObject = jsonObject.optJSONObject("data");
  1824. if (dataObject == null) {
  1825. return;
  1826. }
  1827. JSONObject messageObject = dataObject.optJSONObject("barcode");
  1828. if (messageObject == null) {
  1829. return;
  1830. }
  1831. if (messageObject.has("ISMSD")) {
  1832. if (messageObject.optBoolean("ISMSD")) {
  1833. //成功,有返回值,判断返回值message中isMsd是否存在,存在判断if(isMsd)true,弹出显示框
  1834. iocOutMakeMaterialOperMsd = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialOperMsd.class);
  1835. // Log.i("msdresult", iocOutMakeMaterialOperMsd.toString());
  1836. mBarRemain = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getBAR_REMAIN());
  1837. mRestqty = CommonUtil.doubleFormat(iocOutMakeMaterialOperMsd.getData().getBarcode().getRESTQTY());
  1838. showDewPopupWindow();
  1839. } else {
  1840. mIocoutMaterialSplitBean = JsonTools.parseJsonToBean(messageObject.toString(), IOCOutmakeMaterialSplitBean.class);
  1841. mBarRemain = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getBAR_REMAIN());
  1842. mRestqty = CommonUtil.doubleFormat(mIocoutMaterialSplitBean.getRESTQTY());
  1843. if (CommonUtil.doubleCompare(mIocoutMaterialSplitBean.getBAR_REMAIN(), mIocoutMaterialSplitBean.getRESTQTY()) == 1) {
  1844. spliteBarcode(currentBarcode);
  1845. }
  1846. }
  1847. } else {
  1848. mCollectResultTextView.setVisibility(View.VISIBLE);
  1849. mCollectResultTextView.setText(null);
  1850. JSONArray listArray = dataObject.optJSONArray("nolist");
  1851. if (mCollectType.equals("byBarcode")) {
  1852. String barcodeResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
  1853. + "\n条码:" + JsonUtils.optStringNotNull(messageObject, "BAR_CODE")
  1854. + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
  1855. + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
  1856. + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
  1857. + ";名称规格:" + messageObject.optString("PR_DETAIL")
  1858. + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC")
  1859. + ";仓位:" + JsonUtils.optStringNotNull(messageObject, "BAR_LOCATION");
  1860. if (listArray != null && listArray.length() > 0) {
  1861. for (int i = 0; i < listArray.length(); i++) {
  1862. JSONObject listObject = listArray.optJSONObject(i);
  1863. barcodeResult = barcodeResult
  1864. + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
  1865. + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
  1866. + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
  1867. }
  1868. }
  1869. mCollectResultTextView.setText(barcodeResult);
  1870. mBarcodeTableLayout.setVisibility(View.GONE);
  1871. mBoxTableLayout.setVisibility(View.GONE);
  1872. tvBarcodeCollectionSuccess.setVisibility(View.VISIBLE);
  1873. tvBarcodeCollectionSuccess.setText("采集成功");
  1874. mResult1 = messageObject.optString("BAR_CODE");
  1875. mResult2 = messageObject.optDouble("BAR_REMAIN") + "";
  1876. mResult3 = messageObject.optString("BAR_PRODCODE");
  1877. mResults.add(mResult1);
  1878. mResults.add(mResult2);
  1879. mResults.add(mResult3);
  1880. mCollectBarcodeTv.setText(mResult1);
  1881. mCollectBarRemainTv.setText(mResult2);
  1882. mCollectBarProdcodeTv.setText(mResult3);
  1883. PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BARCODE_RESULT + pi_inoutno, mResults);
  1884. } else if (mCollectType.equals("byBatchcode")) {
  1885. String boxResult = "采集成功;" + JsonUtils.optStringNotNull(dataObject, "finishno")
  1886. + "\n箱号:" + JsonUtils.optStringNotNull(messageObject, "BAR_OUTBOXCODE1")
  1887. + ";数量:" + CommonUtil.doubleFormat(messageObject.optDouble("BAR_REMAIN"))
  1888. + ";批号:" + JsonUtils.optStringNotNull(messageObject, "BAR_BATCHCODE")
  1889. + ";料号:" + JsonUtils.optStringNotNull(messageObject, "BAR_PRODCODE")
  1890. + ";名称规格:" + JsonUtils.optStringNotNull(messageObject, "PR_DETAIL")
  1891. + " " + JsonUtils.optStringNotNull(messageObject, "PR_SPEC");
  1892. if (listArray != null && listArray.length() > 0) {
  1893. for (int i = 0; i < listArray.length(); i++) {
  1894. JSONObject listObject = listArray.optJSONObject(i);
  1895. boxResult = boxResult
  1896. + "\n单号:" + JsonUtils.optStringNotNull(listObject, "PI_INOUTNO")
  1897. + ";条码号:" + JsonUtils.optStringNotNull(listObject, "BAR_CODE")
  1898. + ";数量:" + CommonUtil.doubleFormat(JsonUtils.optDoubleNotNull(listObject, "BAR_REMAIN"));
  1899. }
  1900. }
  1901. mCollectResultTextView.setText(boxResult);
  1902. mBarcodeTableLayout.setVisibility(View.GONE);
  1903. mBoxTableLayout.setVisibility(View.GONE);
  1904. tvBoxCollectionSuccess.setVisibility(View.VISIBLE);
  1905. tvBoxCollectionSuccess.setText("采集成功");
  1906. mResult1 = messageObject.optString("PA_OUTBOXCODE");
  1907. mResult2 = messageObject.optInt("PA_TOTALQTY") + "";
  1908. mResult3 = messageObject.optString("PA_PRODCODE");
  1909. mResult4 = messageObject.optString("PA_WHCODE");
  1910. mResults.add(mResult1);
  1911. mResults.add(mResult2);
  1912. mResults.add(mResult3);
  1913. mResults.add(mResult4);
  1914. mCollectBoxTv.setText(mResult1);
  1915. mCollectBoxNumTv.setText(mResult2);
  1916. mCollectBoxrProdcodeTv.setText(mResult3);
  1917. mCollectBoxWhcodeTv.setText(mResult4);
  1918. PdaApplication.putDataCache2Map(Constants.FLAG.MATERIAL_COLLECT_BOX_RESULT + pi_inoutno, mResults);
  1919. }
  1920. CommonUtil.toastNoRepeat(getActivity(), "采集成功");
  1921. Object next = jsonObject.getJSONObject("data").get("next");
  1922. if (next != null && !"null".equals(next.toString())) {
  1923. JSONObject nextObject = jsonObject.getJSONObject("data").getJSONObject("next");
  1924. MaterialInformationBean.DataBean materialInformationBean = JsonTools.parseJsonToBean(nextObject.toString(), MaterialInformationBean.DataBean.class);
  1925. if (materialInformationBean != null) {
  1926. String materialInfo =
  1927. "物料:" + (materialInformationBean.getPD_PRODCODE() == null ? "" : materialInformationBean.getPD_PRODCODE())
  1928. + "; 名称规格:" + (materialInformationBean.getPR_DETAIL() == null ? "" : materialInformationBean.getPR_DETAIL())
  1929. + " " + (materialInformationBean.getPR_SPEC() == null ? "" : materialInformationBean.getPR_SPEC())
  1930. + "; 未备料数:" + (materialInformationBean.getPD_RESTQTY() == null ? "" : materialInformationBean.getPD_RESTQTY())
  1931. + "; 批数量:" + (CommonUtil.doubleFormat(materialInformationBean.getBAR_REMAIN()))
  1932. + "; 仓位:" + (materialInformationBean.getBAR_LOCATION() == null ? "" : materialInformationBean.getBAR_LOCATION());
  1933. if (materialInformationBean.getPD_BATCHCODE() != null) {
  1934. materialInfo = materialInfo + "; 批号:" + materialInformationBean.getPD_BATCHCODE();
  1935. }
  1936. mMaterialInforTextView.setText(materialInfo);
  1937. }
  1938. } else {
  1939. mMaterialInforTextView.setText("该出库单已经完成备料");
  1940. }
  1941. }
  1942. } catch (JSONException e) {
  1943. e.printStackTrace();
  1944. }
  1945. }
  1946. },
  1947. new Response.ErrorListener() {
  1948. @Override
  1949. public void onErrorResponse(VolleyError volleyError) {
  1950. progressDialog.dismiss();
  1951. // Toast.makeText(getActivity().getApplicationContext(), "拆分失败", Toast.LENGTH_LONG).show();
  1952. if (getActivity() != null) {
  1953. etBarCode.setText(null);
  1954. CommonUtil.editTextGetFocus(etBarCode);
  1955. CommonUtil.showErrorToast(volleyError);
  1956. }
  1957. }
  1958. }) {
  1959. @Override
  1960. public Map<String, String> getHeaders() throws AuthFailureError {
  1961. return VolleyUtil.getVolleyUtil().setCookies();
  1962. }
  1963. @Override
  1964. protected Map<String, String> getParams() throws AuthFailureError {
  1965. Map<String, String> params = new HashMap<>();
  1966. // if (isMultiple) {
  1967. params.put("ids", pi_id);
  1968. // } else {
  1969. // params.put("id", pi_id);
  1970. // params.put("whcode", pd_whcode);
  1971. // }
  1972. params.put("barcode", currentBarcode);
  1973. params.put("or_remain", mBarRemain);
  1974. params.put("bar_remain", mRestqty);
  1975. Log.e(TAG, params.toString());
  1976. return params;
  1977. }
  1978. };
  1979. stringRequest.setRetryPolicy(new DefaultRetryPolicy(20 * 1000, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
  1980. int timeoutMs = stringRequest.getTimeoutMs();
  1981. stringRequest.setTag(TAG);
  1982. PdaApplication.mRequestQueue.add(stringRequest);*/
  1983. }
  1984. protected void initBreakPopupWindow(JSONArray listArray,String bolle) {
  1985. messages.clear();
  1986. for (int i = 0; i < listArray.length(); i++) {
  1987. try {
  1988. JSONObject barcodeObject = listArray.getJSONObject(i);
  1989. if (barcodeObject != null) {
  1990. WHBreakingBatchBreakingBtnClickEvent.DataBean dataBean = new WHBreakingBatchBreakingBtnClickEvent.DataBean();
  1991. if (bolle.equals("true")){
  1992. dataBean.setBAR_CODE(JsonUtils.optStringNotNull(barcodeObject, "BAR_CODE"));
  1993. dataBean.setBAR_REMAIN(JsonUtils.optStringNotNull(barcodeObject, "BAR_REMAIN"));
  1994. dataBean.setPR_CODE(JsonUtils.optStringNotNull(barcodeObject, "PR_CODE"));
  1995. dataBean.setPR_SPEC(JsonUtils.optStringNotNull(barcodeObject, "PR_SPEC"));
  1996. }else {
  1997. dataBean.setBAR_CODE(JsonUtils.optStringNotNull(barcodeObject, "BAR_CODE"));
  1998. dataBean.setBAR_REMAIN(JsonUtils.optStringNotNull(barcodeObject, "BAR_REMAIN"));
  1999. }
  2000. messages.add(dataBean);
  2001. }
  2002. } catch (JSONException e) {
  2003. e.printStackTrace();
  2004. }
  2005. }
  2006. View popView = LayoutInflater.from(getActivity()).inflate(R.layout.popupwindow_whbreaking_batch, null);
  2007. ListView listView = (ListView) popView.findViewById(R.id.list_view);
  2008. Button btnPrintf = (Button) popView.findViewById(R.id.btn_print);
  2009. Button btnPrintfSet = (Button) popView.findViewById(R.id.btn_print_setting);
  2010. Button btnClose = (Button) popView.findViewById(R.id.btn_close);
  2011. Button btnBack = (Button) popView.findViewById(R.id.btn_back);
  2012. btnBack.setVisibility(View.GONE);
  2013. btnClose.setOnClickListener(new View.OnClickListener() {
  2014. @Override
  2015. public void onClick(View v) {
  2016. closeSplitPopupWindow();
  2017. }
  2018. });
  2019. btnPrintf.setOnClickListener(new View.OnClickListener() {
  2020. @Override
  2021. public void onClick(View v) {
  2022. if (isConnected) {
  2023. progressDialog.show();
  2024. printEvent(listArray);
  2025. } else {
  2026. closeSplitPopupWindow();
  2027. BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
  2028. Bundle bundle = new Bundle();
  2029. bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
  2030. blueToothPrintFragment.setArguments(bundle);
  2031. FragmentUtils.switchFragment(AGVIOCOutMakeMaterialOper.this, blueToothPrintFragment);
  2032. }
  2033. }
  2034. });
  2035. btnPrintfSet.setOnClickListener(new View.OnClickListener() {
  2036. @Override
  2037. public void onClick(View v) {
  2038. closeSplitPopupWindow();
  2039. BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
  2040. Bundle bundle = new Bundle();
  2041. bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
  2042. blueToothPrintFragment.setArguments(bundle);
  2043. FragmentUtils.switchFragment(AGVIOCOutMakeMaterialOper.this, blueToothPrintFragment);
  2044. }
  2045. });
  2046. MyAdapter adapter = new MyAdapter(getActivity(), R.layout.item_list_whbreakingbatchfragment, messages);
  2047. listView.setAdapter(adapter);
  2048. //当只有一条数据的时候可以加上
  2049. /*
  2050. if (messages.size()>1){
  2051. btnBack.setVisibility(View.GONE);
  2052. }*/
  2053. // PopupWindow实例化,参数的意思是 view,长(不包括状态栏),高(不包括状态栏),是否聚焦
  2054. splitPop = new PopupWindow(popView, LinearLayout.LayoutParams.WRAP_CONTENT,
  2055. LinearLayout.LayoutParams.WRAP_CONTENT, true);
  2056. splitPop.setAnimationStyle(R.style.MenuAnimationFade);
  2057. splitPop.setBackgroundDrawable(new BitmapDrawable());
  2058. // 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
  2059. splitPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
  2060. splitPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
  2061. @Override
  2062. public void onDismiss() {
  2063. closeSplitPopupWindow();
  2064. // confirmEvent();
  2065. }
  2066. });
  2067. CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
  2068. }
  2069. private void printEvent(JSONArray printArray) {
  2070. if (isPrinting) {
  2071. CommonUtil.toastNoRepeat(mActivity, "正在打印中,请勿重复操作");
  2072. return;
  2073. }
  2074. isPrinting = true;
  2075. if (printArray != null && printArray.length() > 0) {
  2076. boolean isFail = false;
  2077. for (int i = 0; i < printArray.length(); i++) {
  2078. try {
  2079. JSONObject printObject = printArray.getJSONObject(i);
  2080. int printResult = PrintUtils.printBar(mActivity, printObject.toString(), mPrintDpi, null);
  2081. if (printResult <= 0) {
  2082. isFail = true;
  2083. }
  2084. } catch (Exception e) {
  2085. e.printStackTrace();
  2086. }
  2087. }
  2088. closeSplitPopupWindow();
  2089. progressDialog.dismiss();
  2090. if (isFail) {
  2091. isConnected = false;
  2092. SharedPreUtil.saveInt(mActivity, "printConnect", 0);
  2093. CommonUtil.toastNoRepeat(mActivity, "打印失败,请重新连接打印机");
  2094. BlueToothPrintFragment blueToothPrintFragment = new BlueToothPrintFragment();
  2095. Bundle bundle = new Bundle();
  2096. bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, printArray.toString());
  2097. blueToothPrintFragment.setArguments(bundle);
  2098. FragmentUtils.switchFragment(AGVIOCOutMakeMaterialOper.this, blueToothPrintFragment);
  2099. } else {
  2100. CommonUtil.toastNoRepeat(mActivity, "打印成功");
  2101. }
  2102. } else {
  2103. CommonUtil.toastNoRepeat(mActivity, "打印失败,条码数据为空");
  2104. }
  2105. isPrinting = false;
  2106. }
  2107. public static final String GETPRINTDATA = "getPrintData";
  2108. /**
  2109. * 获取打印文件
  2110. */
  2111. private void getPrintData() {
  2112. progressDialog.show();
  2113. String url = GloableParams.ADDRESS_LABELPRINT + "?data=" + strPrintDataList;
  2114. stringRequestSplit = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
  2115. @Override
  2116. public void onResponse(String s) {
  2117. try {
  2118. JSONObject resultObject = new JSONObject(s);
  2119. if (resultObject.optBoolean("success")) {
  2120. mPrintUrl = resultObject.optString("data");
  2121. FileUtils.printBarcode(mPrintUrl, mHandler);
  2122. }
  2123. } catch (JSONException e) {
  2124. if (progressDialog.isShowing())
  2125. progressDialog.dismiss();
  2126. e.printStackTrace();
  2127. }
  2128. }
  2129. }, new Response.ErrorListener() {
  2130. @Override
  2131. public void onErrorResponse(VolleyError volleyError) {
  2132. if (progressDialog.isShowing())
  2133. progressDialog.dismiss();
  2134. CommonUtil.showErrorToast(volleyError);
  2135. }
  2136. }) {
  2137. @Override
  2138. public Map<String, String> getHeaders() throws AuthFailureError {
  2139. Map map = VolleyUtil.getVolleyUtil().setCookies();
  2140. //不用改动
  2141. map.put("Content-Type", "text/html; charset=UTF-8");
  2142. return map;
  2143. }
  2144. };
  2145. stringRequestSplit.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
  2146. stringRequestSplit.setTag(GETPRINTDATA);
  2147. PdaApplication.mRequestQueue.add(stringRequestSplit);
  2148. }
  2149. private class MyAdapter extends ArrayAdapter<WHBreakingBatchBreakingBtnClickEvent.DataBean> {
  2150. private int resourceId;
  2151. public MyAdapter(Context context, int resource, List<WHBreakingBatchBreakingBtnClickEvent.DataBean> objects) {
  2152. super(context, resource, objects);
  2153. resourceId = resource;
  2154. }
  2155. @Override
  2156. public View getView(int position, View convertView, ViewGroup parent) {
  2157. //WHBreakingBatchBreakingBtnClickEvent.Message target = getItem(position);
  2158. WHBreakingBatchBreakingBtnClickEvent.DataBean person = getItem(position);
  2159. convertView = LayoutInflater.from(getContext()).inflate(resourceId,
  2160. null);
  2161. TextView tv_bar_code = (TextView) convertView.findViewById(R.id.tv_bar_code);
  2162. TextView tv_bar_remain = (TextView) convertView.findViewById(R.id.tv_bar_remain);
  2163. // tv_bar_code.setText(target.bar_code);
  2164. // tv_bar_remain.setText(target.bar_remain);
  2165. tv_bar_code.setText(person.getBAR_CODE());
  2166. tv_bar_remain.setText(person.getBAR_REMAIN());
  2167. return convertView;
  2168. }
  2169. }
  2170. /**
  2171. * 条码输入框的enter事件以及确认按钮点击事件
  2172. */
  2173. private void confirmEvent() {
  2174. currentBarcode = etBarCode.getText().toString().trim();
  2175. if (TextUtils.isEmpty(currentBarcode)) {
  2176. CommonUtil.toastNoRepeat(getActivity(), "请输入号码");
  2177. }
  2178. // else if (!currentBarcode.matches(Constants.REGEX.NO_CN_SYMBOL)) {
  2179. // CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.barcode_cannot_contain_special));
  2180. // }
  2181. else {
  2182. if (mCollectModel == 1) {
  2183. if (CommonUtil.isNetWorkConnected(getActivity())) {
  2184. barcodeEnterEvent(false, true);
  2185. } else {
  2186. CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
  2187. }
  2188. } else if (mCollectModel == 0) {
  2189. //离线模式
  2190. saveToDatabase(currentBarcode);
  2191. }
  2192. }
  2193. }
  2194. private void saveToDatabase(String currentText) {
  2195. progressDialog.show();
  2196. List<TableLBARCODEIO> allBarcodeIo = new ArrayList<>();
  2197. if (mDbManager.getDb().isOpen()) {
  2198. allBarcodeIo = mDbManager.queryFromBarcodeIo(new String[]{"out", pi_id, pd_whcode}, "inOrOut=? and LBI_PIID=? and LBI_WHCODE=? ");
  2199. }
  2200. //如果用户采集的离线数据超过30条,提示用户请先将采集的数据上传,限制用户必须先将数据上传
  2201. if (allBarcodeIo.size() >= 30) {
  2202. progressDialog.dismiss();
  2203. final List<TableLBARCODEIO> finalAllBarcodeIo = allBarcodeIo;
  2204. new android.app.AlertDialog.Builder(getActivity())
  2205. .setTitle("提示")
  2206. .setMessage("您采集的离线数据已经达到30条,请先将离线数据上传再继续采集。是否上传数据?")
  2207. .setPositiveButton("上传", new DialogInterface.OnClickListener() {
  2208. @Override
  2209. public void onClick(DialogInterface dialog, int which) {
  2210. if (CommonUtil.isNetWorkConnected(getActivity())) {
  2211. submitOfflineData(finalAllBarcodeIo, false);
  2212. } else {
  2213. CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
  2214. }
  2215. }
  2216. })
  2217. .setNegativeButton("取消", new DialogInterface.OnClickListener() {
  2218. @Override
  2219. public void onClick(DialogInterface dialog, int which) {
  2220. dialog.dismiss();
  2221. }
  2222. }).show();
  2223. return;
  2224. }
  2225. boolean isExist = false;
  2226. for (int i = 0; i < allBarcodeIo.size(); i++) {
  2227. if (pi_id.equals(allBarcodeIo.get(i).getLBI_PIID() + "") && pd_whcode.equals(allBarcodeIo.get(i).getLBI_WHCODE())
  2228. && "out".equals(allBarcodeIo.get(i).getInOrOut())
  2229. && ((currentText.equals(allBarcodeIo.get(i).getLBI_BARCODE()) && mCollectType.equals("byBarcode"))
  2230. || (currentText.equals(allBarcodeIo.get(i).getLBI_OUTBOXCODE()) && mCollectType.equals("byBatchcode")))) {
  2231. isExist = true;
  2232. break;
  2233. }
  2234. }
  2235. if (isExist) {
  2236. progressDialog.dismiss();
  2237. if (mCollectType.equals("byBarcode"))
  2238. Toast.makeText(getActivity(), "条码 " + currentText + " 已经在已采集待提交数据中", Toast.LENGTH_SHORT).show();
  2239. else if (mCollectType.equals("byBatchcode"))
  2240. Toast.makeText(getActivity(), "外箱 " + currentText + " 已经在已采集待提交数据中", Toast.LENGTH_SHORT).show();
  2241. etBarCode.setText(null);
  2242. etBarCode.requestFocus();
  2243. } else {
  2244. TableLBARCODEIO newBarcodeIo = new TableLBARCODEIO();
  2245. newBarcodeIo.setLBI_PIID(Long.parseLong(pi_id));
  2246. if (mCollectType.equals("byBarcode")) {
  2247. newBarcodeIo.setLBI_BARCODE(etBarCode.getText().toString().trim());
  2248. newBarcodeIo.setLBI_OUTBOXCODE("");
  2249. newBarcodeIo.setLBI_BOXTYPE("byBarcode");
  2250. } else if (mCollectType.equals("byBatchcode")) {
  2251. newBarcodeIo.setLBI_BARCODE("");
  2252. newBarcodeIo.setLBI_OUTBOXCODE(etBarCode.getText().toString().trim());
  2253. newBarcodeIo.setLBI_BOXTYPE("byBatchcode");
  2254. }
  2255. newBarcodeIo.setLBI_WHCODE(pd_whcode);
  2256. newBarcodeIo.setLBI_INOUTNO(pi_inoutno);
  2257. newBarcodeIo.setLBI_PRODCODE("");
  2258. newBarcodeIo.setLBI_INQTY(0);
  2259. newBarcodeIo.setLBI_LOCATION("");
  2260. newBarcodeIo.setLBI_PRDETAIL("");
  2261. newBarcodeIo.setLBI_OUTQTY(0);
  2262. newBarcodeIo.setLBI_PRID(0);
  2263. newBarcodeIo.setInOrOut("out");
  2264. try {
  2265. mDbManager.saveToBarcodeIo(newBarcodeIo);
  2266. new Handler().postDelayed(new Runnable() {
  2267. @Override
  2268. public void run() {
  2269. progressDialog.dismiss();
  2270. Toast.makeText(getActivity(), "成功保存至未提交列表", Toast.LENGTH_SHORT).show();
  2271. }
  2272. }, 400);
  2273. etBarCode.setText(null);
  2274. } catch (Exception e) {
  2275. progressDialog.dismiss();
  2276. Toast.makeText(getActivity(), "数据保存失败", Toast.LENGTH_SHORT).show();
  2277. etBarCode.setText(null);
  2278. }
  2279. }
  2280. }
  2281. private void submitOfflineData(final List<TableLBARCODEIO> mNotSubmitList, final boolean isPop) {
  2282. progressDialog.show();
  2283. final List<SubmitNotParam> submitNotParams = new ArrayList<SubmitNotParam>();
  2284. for (int i = 0; i < mNotSubmitList.size(); i++) {
  2285. SubmitNotParam submitNotParam = new SubmitNotParam();
  2286. TableLBARCODEIO lbarcodeio = mNotSubmitList.get(i);
  2287. submitNotParam.setBi_barcode(lbarcodeio.getLBI_BARCODE());
  2288. submitNotParam.setBi_inoutno(lbarcodeio.getLBI_INOUTNO());
  2289. submitNotParam.setBi_inqty(lbarcodeio.getLBI_INQTY() + "");
  2290. submitNotParam.setBi_location(lbarcodeio.getLBI_LOCATION());
  2291. submitNotParam.setBi_piid(lbarcodeio.getLBI_PIID() + "");
  2292. submitNotParam.setBi_prodcode(lbarcodeio.getLBI_PRODCODE());
  2293. submitNotParam.setBi_prodid(lbarcodeio.getLBI_PRID() + "");
  2294. submitNotParam.setBi_whcode(lbarcodeio.getLBI_WHCODE());
  2295. submitNotParam.setBi_outboxcode(lbarcodeio.getLBI_OUTBOXCODE());
  2296. submitNotParam.setBi_boxtype(lbarcodeio.getLBI_BOXTYPE());
  2297. submitNotParams.add(submitNotParam);
  2298. }
  2299. try {
  2300. String url = GloableParams.ADDRESS_OUT_SAVE_BARCODE;
  2301. PdaApplication.mRequestQueue.cancelAll(TAG + "submit");
  2302. mStringRequest = new StringRequest(Request.Method.POST, url,
  2303. new Response.Listener<String>() {
  2304. @Override
  2305. public void onResponse(String s) {
  2306. progressDialog.dismiss();
  2307. try {
  2308. JSONObject resultJsonObject = new JSONObject(s);
  2309. JSONObject dataJsonObject = resultJsonObject.getJSONObject("data");
  2310. Iterator<String> resultKeys = dataJsonObject.keys();
  2311. if (resultKeys.hasNext()) {
  2312. int successCount = 0;
  2313. int failCount = 0;
  2314. while (resultKeys.hasNext()) {
  2315. String barcodeKey = resultKeys.next().toString();
  2316. String barcodeResult = JsonUtils.optStringNotNull(dataJsonObject, barcodeKey);
  2317. if (barcodeKey.contains("byBarcode:")) {
  2318. barcodeKey = barcodeKey.substring(10);
  2319. } else if (barcodeKey.contains("byBatchcode:")) {
  2320. barcodeKey = barcodeKey.substring(6);
  2321. }
  2322. if ("success".equals(barcodeResult)) {
  2323. successCount++;
  2324. for (int i = 0; i < mNotSubmitList.size(); i++) {
  2325. TableLBARCODEIO lbarcodeio = mNotSubmitList.get(i);
  2326. if (barcodeKey.equals(lbarcodeio.getLBI_BARCODE())) {
  2327. mDbManager.deleteFromBarcodeIo(lbarcodeio);
  2328. }
  2329. }
  2330. } else {
  2331. failCount++;
  2332. }
  2333. }
  2334. if (failCount == 0) {
  2335. mCollectModelBtn.setText("在线");
  2336. mCollectModel = 1;
  2337. Toast.makeText(getActivity(), getResources().getString(R.string.submit_success), Toast.LENGTH_SHORT).show();
  2338. if (isPop)
  2339. getActivity().getSupportFragmentManager().popBackStack();
  2340. } else {
  2341. mCollectModelBtn.setText("离线");
  2342. mCollectModel = 0;
  2343. CommonUtil.toastNoRepeat(getActivity(), successCount + "条数据提交成功\n" + failCount + "条数据提交失败");
  2344. }
  2345. }
  2346. } catch (Exception e) {
  2347. e.printStackTrace();
  2348. }
  2349. }
  2350. },
  2351. new Response.ErrorListener() {
  2352. @Override
  2353. public void onErrorResponse(VolleyError volleyError) {
  2354. progressDialog.dismiss();
  2355. if (getActivity() != null) {
  2356. mCollectModelBtn.setText("离线");
  2357. mCollectModel = 0;
  2358. CommonUtil.showErrorToast(volleyError);
  2359. }
  2360. }
  2361. }) {
  2362. @Override
  2363. public Map<String, String> getHeaders() throws AuthFailureError {
  2364. return VolleyUtil.getVolleyUtil().setCookies();
  2365. }
  2366. @Override
  2367. protected Map<String, String> getParams() throws AuthFailureError {
  2368. Map<String, String> param = new HashMap<>();
  2369. param.put("data", JSON.toJSONString(submitNotParams));
  2370. param.put("type", mProdOutType);
  2371. return param;
  2372. }
  2373. };
  2374. mStringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
  2375. mStringRequest.setTag(TAG + "submit");
  2376. PdaApplication.mRequestQueue.add(mStringRequest);
  2377. } catch (Exception e) {
  2378. progressDialog.dismiss();
  2379. e.printStackTrace();
  2380. }
  2381. }
  2382. private void getAgainEvent() {
  2383. String url = GloableParams.ADDRESS_CLEARGET;
  2384. PdaApplication.mRequestQueue.cancelAll(TAG);
  2385. stringRequestPost = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
  2386. @Override
  2387. public void onResponse(String s) {
  2388. LogUtil.e("已空", s + "");
  2389. // progressDialog.dismiss();
  2390. CommonUtil.toastNoRepeat(getActivity(), "已清空采集数据");
  2391. getCollectNotListOnline(pi_id, pd_whcode);
  2392. }
  2393. }, new Response.ErrorListener() {
  2394. @Override
  2395. public void onErrorResponse(VolleyError volleyError) {
  2396. progressDialog.dismiss();
  2397. if (getActivity() != null) {
  2398. closeListPopupWindow();
  2399. // getCollectNotListOnline(pi_id, pd_whcode);
  2400. CommonUtil.showErrorToast(volleyError);
  2401. }
  2402. }
  2403. }) {
  2404. @Override
  2405. public Map<String, String> getHeaders() throws AuthFailureError {
  2406. return VolleyUtil.getVolleyUtil().setCookies();
  2407. }
  2408. @Override
  2409. protected Map<String, String> getParams() throws AuthFailureError {
  2410. Map<String, String> params = new HashMap<>();
  2411. params.put("id", pi_id);
  2412. params.put("whcode", pd_whcode);
  2413. return params;
  2414. }
  2415. };
  2416. stringRequestPost.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
  2417. stringRequestPost.setTag(TAG);
  2418. PdaApplication.mRequestQueue.add(stringRequestPost);
  2419. }
  2420. /**
  2421. * 获取材料未采集列表
  2422. *
  2423. * @param pi_id
  2424. * @param pd_whcode
  2425. */
  2426. private void getCollectNotListOnline(String pi_id, String pd_whcode) {
  2427. progressDialog.show();
  2428. String url = GloableParams.ADDRESS_OUT_NEED_GET_LIST + "?id=" + pi_id + "&whcode=" + pd_whcode + "&type=" + mProdOutType;
  2429. PdaApplication.mRequestQueue.cancelAll(TAG + "online");
  2430. jsonRequest = new JsonObjectRequest(Request.Method.GET, url, null,
  2431. new Response.Listener<JSONObject>() {
  2432. @Override
  2433. public void onResponse(JSONObject jsonObject) {
  2434. progressDialog.dismiss();
  2435. try {
  2436. if (!"success".equals(jsonObject.getJSONObject("data").optString("message"))) {
  2437. CommonUtil.toastNoRepeat(getActivity(), jsonObject.getJSONObject("data").optString("message"));
  2438. }
  2439. JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("data");
  2440. LogUtil.i("jsonArray", jsonArray.toString());
  2441. if (jsonArray != null) {
  2442. List<TableLPRODIONEEDGET> lprodioneedgetList = new ArrayList<>();
  2443. for (int i = 0; i < jsonArray.length(); i++) {
  2444. LogUtil.i("jsonObject", jsonArray.get(i).toString());
  2445. JSONObject notCollectObject = jsonArray.getJSONObject(i);
  2446. TableLPRODIONEEDGET lprodioneedget = new TableLPRODIONEEDGET();
  2447. lprodioneedget.setLPN_PRODCODE(notCollectObject.optString("PD_PRODCODE"));
  2448. lprodioneedget.setLPN_RESTQTY(notCollectObject.optDouble("PD_RESTQTY"));
  2449. lprodioneedget.setLPN_PRDETAIL(notCollectObject.optString("PR_DETAIL"));
  2450. lprodioneedget.setLPN_PRSPEC(JsonUtils.optStringNotNull(notCollectObject, "PR_SPEC"));
  2451. lprodioneedget.setLPN_ZXBZS(notCollectObject.optDouble("PR_ZXBZS"));
  2452. lprodioneedget.setLPN_IFBARCODECHECK("");
  2453. lprodioneedget.setLPN_PIID(notCollectObject.optInt("PD_PIID"));
  2454. lprodioneedget.setLPN_INOUTNO(notCollectObject.optString("PD_INOUTNO"));
  2455. lprodioneedget.setLPN_WHCODE(notCollectObject.optString("PD_WHCODE"));
  2456. lprodioneedget.setLPN_PRID(notCollectObject.optInt("PR_ID"));
  2457. lprodioneedget.setLPN_BATCHCODE(notCollectObject.optString("PD_BATCHCODE"));
  2458. lprodioneedget.setInOrOut("out");
  2459. lprodioneedget.setLPN_ORDERCODE("");
  2460. lprodioneedget.setLPN_TRACEKIND(-1);
  2461. lprodioneedgetList.add(lprodioneedget);
  2462. }
  2463. try {
  2464. if (mDbManager.getDb().isOpen()) {
  2465. mDbManager.deleteInOrOutProductWaitCollect("out");
  2466. mDbManager.saveListToProductWaitCollect(lprodioneedgetList);
  2467. }
  2468. } catch (Exception e) {
  2469. e.printStackTrace();
  2470. }
  2471. }
  2472. } catch (JSONException e) {
  2473. e.printStackTrace();
  2474. }
  2475. }
  2476. },
  2477. new Response.ErrorListener() {
  2478. @Override
  2479. public void onErrorResponse(VolleyError volleyError) {
  2480. progressDialog.dismiss();
  2481. CommonUtil.showErrorToast(volleyError);
  2482. }
  2483. }) {
  2484. @Override
  2485. public Map<String, String> getHeaders() throws AuthFailureError {
  2486. return VolleyUtil.getVolleyUtil().setCookies();
  2487. }
  2488. @Override
  2489. protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
  2490. if (response.data == null || response.data.length == 0) {
  2491. JSONObject jsonObject = new JSONObject();
  2492. try {
  2493. jsonObject.put("msg", "成功:服务器无返回");
  2494. } catch (JSONException e) {
  2495. e.printStackTrace();
  2496. }
  2497. return Response.success(jsonObject, HttpHeaderParser.parseCacheHeaders(response));
  2498. } else {
  2499. return super.parseNetworkResponse(response);
  2500. }
  2501. }
  2502. };
  2503. jsonRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1f));
  2504. jsonRequest.setTag(TAG + "online");
  2505. PdaApplication.mRequestQueue.add(jsonRequest);
  2506. }
  2507. private void clickToFragment(BaseFragment baseFragment) {
  2508. Bundle bundle = new Bundle();
  2509. bundle.putString("pi_id", pi_id);
  2510. bundle.putString("pi_inoutno", pi_inoutno);
  2511. bundle.putString("pd_whcode", pd_whcode);
  2512. bundle.putString("whichpage", "materialout");
  2513. bundle.putBoolean("isMultiple", isMultiple);
  2514. if (mCollectModel == 1) {
  2515. bundle.putInt("modeType", 3);
  2516. } else if (mCollectModel == 0) {
  2517. bundle.putInt("modeType", 2);
  2518. }
  2519. mFragment = baseFragment;
  2520. mFragment.setArguments(bundle);
  2521. FragmentUtils.switchFragment(this, mFragment);
  2522. }
  2523. private void closeListPopupWindow() {
  2524. if (listPopupWindow != null) {
  2525. listPopupWindow.dismiss();
  2526. listPopupWindow = null;
  2527. CommonUtil.setBackgroundAlpha(mActivity, 1f);
  2528. }
  2529. }
  2530. private void closeSplitPopupWindow() {
  2531. if (splitPop != null) {
  2532. splitPop.dismiss();
  2533. splitPop = null;
  2534. CommonUtil.setBackgroundAlpha(mActivity, 1f);
  2535. }
  2536. }
  2537. private void closePopupWindow() {
  2538. if (popupWindow != null) {
  2539. popupWindow.dismiss();
  2540. popupWindow = null;
  2541. CommonUtil.setBackgroundAlpha(mActivity, 1f);
  2542. }
  2543. }
  2544. /**
  2545. * 清除所有信息
  2546. */
  2547. private void clearAll() {
  2548. //清空输入框
  2549. etBarCode.setText("");
  2550. }
  2551. @Override
  2552. public void onDestroyView() {
  2553. super.onDestroyView();
  2554. ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
  2555. ((FunctionActivity) getActivity()).setScanIvVisible(false);
  2556. ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(getString(R.string.out_management));
  2557. mDbManager.closeDB();
  2558. CommonUtil.closeKeybord(((EditText) etBarCode), mActivity);
  2559. ButterKnife.unbind(this);
  2560. ((FunctionActivity) getActivity()).fragment = new IOCOutMakeMaterial();
  2561. }
  2562. /**
  2563. * 其返回一个布尔值;意思是,如果对返回事件进行了处理就返回TRUE,如果不做处理就返回FALSE,让上层进行处理。
  2564. *
  2565. * @return 是否交与activity处理返回事件
  2566. */
  2567. public boolean onFragmentBackPressed() {
  2568. List<TableLBARCODEIO> allBarcodeIo = new ArrayList<>();
  2569. if (mDbManager == null || !mDbManager.getDb().isOpen()) {
  2570. mDbManager = new DBManager(PdaApplication.getmContext());
  2571. }
  2572. allBarcodeIo = mDbManager.queryFromBarcodeIo(new String[]{"out", pi_inoutno, pd_whcode}, "inOrOut=? and LBI_INOUTNO=? and LBI_WHCODE=?");
  2573. if (allBarcodeIo != null && allBarcodeIo.size() != 0) {
  2574. final List<TableLBARCODEIO> finalAllBarcodeIo = allBarcodeIo;
  2575. new android.app.AlertDialog.Builder(getActivity())
  2576. .setTitle("提示")
  2577. .setMessage("存在未提交的离线采集数据,点击上传将把未提交数据上传,点击取消将清空未采集数据")
  2578. .setPositiveButton("上传", new DialogInterface.OnClickListener() {
  2579. @Override
  2580. public void onClick(DialogInterface dialog, int which) {
  2581. if (CommonUtil.isNetWorkConnected(getActivity())) {
  2582. submitOfflineData(finalAllBarcodeIo, true);
  2583. } else {
  2584. CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.str_net_not_connect));
  2585. }
  2586. }
  2587. })
  2588. .setNegativeButton("取消", new DialogInterface.OnClickListener() {
  2589. @Override
  2590. public void onClick(DialogInterface dialog, int which) {
  2591. dialog.dismiss();
  2592. try {
  2593. mDbManager.deleteListFromBarcodeIo(finalAllBarcodeIo);
  2594. List<TableLPRODIONEEDGET> allLprodioneedgets = mDbManager.queryFromProductWaitCollect(new String[]{"out"}, "inOrOut=? ");
  2595. if (allLprodioneedgets != null) {
  2596. for (int j = 0; j < finalAllBarcodeIo.size(); j++) {
  2597. TableLBARCODEIO deleteLbarcodeio = finalAllBarcodeIo.get(j);
  2598. for (int i = 0; i < allLprodioneedgets.size(); i++) {
  2599. TableLPRODIONEEDGET tableLPRODIONEEDGET = allLprodioneedgets.get(i);
  2600. if (tableLPRODIONEEDGET.getLPN_PIID() == deleteLbarcodeio.getLBI_PIID()
  2601. && tableLPRODIONEEDGET.getLPN_WHCODE().equals(deleteLbarcodeio.getLBI_WHCODE())
  2602. // && tableLPRODIONEEDGET.getLPN_PRODCODE().equals(deleteLbarcodeio.getLBI_PRODCODE())
  2603. ) {
  2604. tableLPRODIONEEDGET.setLPN_RESTQTY(CommonUtil.doubleAddition(tableLPRODIONEEDGET.getLPN_RESTQTY(), deleteLbarcodeio.getLBI_INQTY()));
  2605. mDbManager.updateProductWaitCollect(tableLPRODIONEEDGET);
  2606. }
  2607. }
  2608. }
  2609. }
  2610. CommonUtil.toastNoRepeat(getActivity(), "清除数据成功");
  2611. getActivity().getSupportFragmentManager().popBackStack();
  2612. } catch (Exception e) {
  2613. CommonUtil.toastNoRepeat(getActivity(), "清除失败");
  2614. getActivity().getSupportFragmentManager().popBackStack();
  2615. }
  2616. }
  2617. }).show();
  2618. // ((FunctionActivity) getActivity()).fragment = new MaterialStorageFragment();
  2619. return true;
  2620. } else {
  2621. return false;
  2622. }
  2623. }
  2624. }