SendOutGoods.java 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557
  1. package com.jiaju.activity;
  2. import java.io.IOException;
  3. import java.lang.reflect.InvocationTargetException;
  4. import java.lang.reflect.Method;
  5. import java.security.KeyStore.PrivateKeyEntry;
  6. import java.text.SimpleDateFormat;
  7. import java.util.ArrayList;
  8. import java.util.Date;
  9. import java.util.List;
  10. import org.json.JSONArray;
  11. import org.json.JSONException;
  12. import org.json.JSONObject;
  13. import com.jiaju.activity.ComponentsBreakageQuantityOkActivity.SaveRunnableScanOk;
  14. import com.jiaju.activity.MakeBilletActivity.BarcodeRunnable;
  15. import com.jiaju.adapter.CarBrandSpinnerAdapter;
  16. import com.jiaju.adapter.GlazeSpinnerAdapter;
  17. import com.jiaju.adapter.ReceiveSpinnerAdapter;
  18. import com.jiaju.adapter.SendOutGoodsListMessageAdapter;
  19. import com.jiaju.adapter.SendOutSpinnerAdapter;
  20. import com.jiaju.model.BarcodeInfo;
  21. import com.jiaju.model.Billet;
  22. import com.jiaju.model.CarBrandModel;
  23. import com.jiaju.model.DutyPerson;
  24. import com.jiaju.model.GlazeModel;
  25. import com.jiaju.model.Procedure;
  26. import com.jiaju.model.ReceiveModel;
  27. import com.jiaju.model.ResponsibilityProcedure;
  28. import com.jiaju.model.ScrapReason;
  29. import com.jiaju.model.SendOutModel;
  30. import com.jiaju.model.WorkNo;
  31. import com.jiaju.net.WebClient;
  32. import com.jiaju.utils.CommonUtil;
  33. import com.jiaju.utils.Constants;
  34. import com.jiaju.utils.CustomToast;
  35. import com.jiaju.utils.MultiChoicDialog;
  36. import com.jiaju.utils.MultiChoicePopWindow;
  37. import com.jiaju.utils.MultiChoiceProcedureDialog;
  38. import com.jiaju.utils.MultiChoiceProcedurePopWindow;
  39. import com.jiaju.utils.ProcessDialogUtils;
  40. import com.jiaju.utils.Removeduplicate;
  41. import com.jiaju.utils.TimePickerInfo;
  42. import android.annotation.SuppressLint;
  43. import android.app.Activity;
  44. import android.app.AlertDialog;
  45. import android.app.Dialog;
  46. import android.app.Notification;
  47. import android.content.Context;
  48. import android.content.DialogInterface;
  49. import android.content.Intent;
  50. import android.content.SharedPreferences;
  51. import android.os.Bundle;
  52. import android.os.Handler;
  53. import android.os.HandlerThread;
  54. import android.os.Message;
  55. import android.text.Editable;
  56. import android.text.InputFilter;
  57. import android.text.InputType;
  58. import android.text.Spanned;
  59. import android.text.TextUtils;
  60. import android.text.TextWatcher;
  61. import android.text.method.ScrollingMovementMethod;
  62. import android.view.KeyEvent;
  63. import android.view.Menu;
  64. import android.view.MenuItem;
  65. import android.view.View;
  66. import android.view.View.OnClickListener;
  67. import android.view.inputmethod.EditorInfo;
  68. import android.view.inputmethod.InputMethodManager;
  69. import android.widget.AdapterView;
  70. import android.widget.Button;
  71. import android.widget.EditText;
  72. import android.widget.ImageButton;
  73. import android.widget.ImageView;
  74. import android.widget.LinearLayout;
  75. import android.widget.ListView;
  76. import android.widget.Spinner;
  77. import android.widget.TextView;
  78. import android.widget.Toast;
  79. import android.widget.AdapterView.OnItemSelectedListener;
  80. public class SendOutGoods extends Activity {
  81. private String serverAddress_ip;
  82. private String serverAddress_port;
  83. private String accountCode;
  84. private String password;
  85. private String sessionkey;
  86. private WebClient client;
  87. private String send_userCode;
  88. private SharedPreferences preferences;
  89. private HandlerThread thread;
  90. private Handler mHandler;
  91. private List<Procedure> procedureList;
  92. private List<Procedure> checkedProcedureList;
  93. private TextView title;
  94. private TextView backtext;
  95. private TextView sGoodsLogcode;
  96. private ImageButton backbtn;
  97. private Object obj = new Object();
  98. boolean booleans[];
  99. boolean booleansTemp[];
  100. boolean[] selItems;
  101. private View mRootView;
  102. private MultiChoiceProcedurePopWindow mMultiChoicePopWindow;
  103. private EditText barcodeEdt;
  104. private EditText descEdt;
  105. private String barcodeUpper;
  106. private String Lgort;// 发出仓
  107. private TextView procedureTv;
  108. private List<BarcodeInfo> barcodeList;
  109. private List<SendOutModel> sendOutList;
  110. private List<ReceiveModel> receiveList;
  111. private List<CarBrandModel> carBrandList;
  112. private JSONArray storageJArray;// 库存
  113. private ListView messageLst;
  114. public Button saveBtn;
  115. private TimePickerInfo mTimePickerInfo;
  116. private TimePickerInfo mTimePickerInfo1;
  117. private long timeMillis;
  118. private Date mSelectedDate;
  119. private Date mSelectedDate1;
  120. private Spinner sendOutSpinner;
  121. private Spinner receiveSpinner;
  122. private Spinner carBrandSpinner;
  123. private TextView TextView04;
  124. private TextView TextView01;
  125. protected String selectedDate;
  126. protected String selectedDate1;
  127. protected String sendOutGoodLogId;
  128. private SendOutModel sendOutModel;
  129. private SendOutModel lastSendOutModel;
  130. private String desc;
  131. private ImageView dateSelector;
  132. private ImageView dateSelector1;
  133. private SendOutSpinnerAdapter sendOutAdapter;
  134. private ReceiveSpinnerAdapter receiveAdapter;
  135. private CarBrandSpinnerAdapter carBrandAdapter;
  136. private Handler barcodeUpperH = new Handler();
  137. private SendOutGoodsListMessageAdapter adapter;
  138. private boolean isCancel=false;
  139. private boolean isFirst=true;
  140. private String IsSYNCSTATUS="0";
  141. private int Height=188;
  142. @Override
  143. protected void onCreate(Bundle savedInstanceState) {
  144. super.onCreate(savedInstanceState);
  145. setContentView(R.layout.activity_send_out_goods);
  146. preferences = getSharedPreferences("user", Context.MODE_PRIVATE);
  147. serverAddress_ip = preferences.getString("ServerAddress_ip", "");
  148. serverAddress_port = preferences.getString("ServerAddress_duankou", "");
  149. accountCode = preferences.getString("AccountCode", "");
  150. send_userCode = preferences.getString("UserCode", "");
  151. password = preferences.getString("UserPassword", "");
  152. sessionkey = preferences.getString("SessionKey", "");
  153. barcodeList = new ArrayList<BarcodeInfo>();
  154. loadProcedureDataSource();
  155. initView();
  156. sendOutGoodLogId="";
  157. sendOutGoodLogId = this.getIntent().getStringExtra("sendoutCode");
  158. IsSYNCSTATUS = this.getIntent().getStringExtra("SYNCSTATUS");
  159. if(IsSYNCSTATUS==null||IsSYNCSTATUS.equals("")) {
  160. IsSYNCSTATUS="0";
  161. }
  162. if(sendOutGoodLogId==null||sendOutGoodLogId=="")
  163. {
  164. ((LinearLayout) findViewById(R.id.LinearLayout06)).setVisibility(View.GONE);
  165. }else
  166. {
  167. sGoodsLogcode.setText(sendOutGoodLogId);
  168. }
  169. procedureTv.setText(send_userCode);
  170. selectedDate = CommonUtil.getCurrentDate();
  171. TextView04.setText(selectedDate);
  172. timeMillis = System.currentTimeMillis();
  173. mTimePickerInfo = new TimePickerInfo(SendOutGoods.this, TimePickerInfo.Type.YEAR_MONTH_DAY);
  174. mTimePickerInfo.setCyclic(true);
  175. mTimePickerInfo.setCancelable(true);
  176. mTimePickerInfo.setOnTimeSelectListener(new TimePickerInfo.OnTimeSelectListener() {
  177. @SuppressLint("SimpleDateFormat")
  178. @Override
  179. public void onTimeSelect(Date date) {
  180. // 存储当前选中的date
  181. SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd");
  182. mSelectedDate = date;
  183. selectedDate = dateFormater.format(mSelectedDate);
  184. TextView04.setText(selectedDate);
  185. }
  186. });
  187. selectedDate1 = CommonUtil.getCurrentDate();
  188. TextView01.setText(selectedDate1);
  189. timeMillis = System.currentTimeMillis();
  190. mTimePickerInfo1 = new TimePickerInfo(SendOutGoods.this, TimePickerInfo.Type.YEAR_MONTH_DAY);
  191. mTimePickerInfo1.setCyclic(true);
  192. mTimePickerInfo1.setCancelable(true);
  193. mTimePickerInfo1.setOnTimeSelectListener(new TimePickerInfo.OnTimeSelectListener() {
  194. @SuppressLint("SimpleDateFormat")
  195. @Override
  196. public void onTimeSelect(Date date) {
  197. // 存储当前选中的date
  198. SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd");
  199. mSelectedDate1 = date;
  200. selectedDate1 = dateFormater.format(mSelectedDate1);
  201. TextView01.setText(selectedDate1);
  202. }
  203. });
  204. allListeners();
  205. thread = new HandlerThread("sendOutThread3", 5);
  206. thread.start();
  207. mHandler = new Handler(thread.getLooper());
  208. SendOutRunnable glazeRunnable = new SendOutRunnable(obj);
  209. mHandler.post(glazeRunnable);
  210. thread = new HandlerThread("sendOutThread1", 5);
  211. thread.start();
  212. mHandler = new Handler(thread.getLooper());
  213. CarBrandRunnable CarBrandRunnable = new CarBrandRunnable(obj);
  214. mHandler.post(CarBrandRunnable);
  215. thread = new HandlerThread("sendOutThread2", 5);
  216. thread.start();
  217. mHandler = new Handler(thread.getLooper());
  218. ReceiveRunnable ReceiveRunnable = new ReceiveRunnable(obj);
  219. mHandler.post(ReceiveRunnable);
  220. }
  221. //protected void onResume() {
  222. // super.onResume();
  223. // 如果值已经在onCreate()中加载完成,可以在这里直接调用方法
  224. //HandlerThread thread = new HandlerThread("worThread", 5);
  225. //thread.start();
  226. //mHandler = new Handler(thread.getLooper());
  227. // mHandler.post(responsibilityWorkNoRunnable);
  228. //isFirst=false;
  229. // }
  230. private class CarBrandRunnable implements Runnable {
  231. private Object object;
  232. public CarBrandRunnable(Object object) {
  233. this.object = object;
  234. }
  235. @Override
  236. public void run() {
  237. synchronized (object) {
  238. try {
  239. client = null;
  240. client = new WebClient();
  241. JSONObject js = new JSONObject();
  242. js.put("accountCode", accountCode);
  243. js.put("userCode", send_userCode);
  244. js.put("userPassword", password);
  245. js.put("sessionKey", sessionkey);
  246. js.put("dicType", "TPC029");
  247. String result = client.doPost("http://" + serverAddress_ip + ":" + serverAddress_port
  248. + Constants.serverAction + "/GetDataDictionaryByType", js.toString(), "application/json");
  249. Message m = new Message();
  250. m.what = 5;
  251. Bundle b = new Bundle();
  252. b.putString("carBrandResult", result);
  253. m.setData(b);
  254. handler.sendMessage(m);
  255. } catch (Exception e) {
  256. e.printStackTrace();
  257. Message m = new Message();
  258. Bundle b = new Bundle();
  259. b.putString("message", "网络连接异常");
  260. m.setData(b);
  261. m.what = 0;
  262. exceptionHandler.sendMessage(m);
  263. }
  264. }
  265. }
  266. };
  267. private class ReceiveRunnable implements Runnable {
  268. private Object object;
  269. public ReceiveRunnable(Object object) {
  270. this.object = object;
  271. }
  272. @Override
  273. public void run() {
  274. synchronized (object) {
  275. try {
  276. client = null;
  277. client = new WebClient();
  278. JSONObject js = new JSONObject();
  279. js.put("accountCode", accountCode);
  280. js.put("userCode", send_userCode);
  281. js.put("userPassword", password);
  282. js.put("sessionKey", sessionkey);
  283. js.put("dicType", "TPC028");
  284. String result = client.doPost("http://" + serverAddress_ip + ":" + serverAddress_port
  285. + Constants.serverAction + "/GetDataDictionaryByType", js.toString(), "application/json");
  286. Message m = new Message();
  287. m.what = 4;
  288. Bundle b = new Bundle();
  289. b.putString("receiveResult", result);
  290. m.setData(b);
  291. handler.sendMessage(m);
  292. } catch (Exception e) {
  293. e.printStackTrace();
  294. Message m = new Message();
  295. Bundle b = new Bundle();
  296. b.putString("message", "网络连接异常");
  297. m.setData(b);
  298. m.what = 0;
  299. exceptionHandler.sendMessage(m);
  300. }
  301. }
  302. }
  303. };
  304. private class SendOutRunnable implements Runnable {
  305. private Object object;
  306. public SendOutRunnable(Object object) {
  307. this.object = object;
  308. }
  309. @Override
  310. public void run() {
  311. synchronized (object) {
  312. try {
  313. ProcessDialogUtils
  314. .showProcessDialog(SendOutGoods.this);
  315. client = null;
  316. client = new WebClient();
  317. JSONObject js = new JSONObject();
  318. js.put("accountCode", accountCode);
  319. js.put("userCode", send_userCode);
  320. js.put("userPassword", password);
  321. js.put("sessionKey", sessionkey);
  322. js.put("dicType", "TPC027");
  323. String result = client.doPost("http://" + serverAddress_ip + ":" + serverAddress_port
  324. + Constants.serverAction + "/GetDataDictionaryByType", js.toString(), "application/json");
  325. Message m = new Message();
  326. m.what = 3;
  327. Bundle b = new Bundle();
  328. b.putString("glazeResult", result);
  329. m.setData(b);
  330. handler.sendMessage(m);
  331. } catch (Exception e) {
  332. e.printStackTrace();
  333. Message m = new Message();
  334. Bundle b = new Bundle();
  335. b.putString("message", "网络连接异常");
  336. m.setData(b);
  337. m.what = 0;
  338. exceptionHandler.sendMessage(m);
  339. }
  340. }
  341. }
  342. };
  343. private void allListeners() {
  344. dateSelector.setOnClickListener(new View.OnClickListener() {
  345. @Override
  346. public void onClick(View v) {
  347. if (mSelectedDate == null) {
  348. mTimePickerInfo.show(new Date(timeMillis));
  349. } else {
  350. mTimePickerInfo.show(mSelectedDate);
  351. }
  352. }
  353. });
  354. dateSelector1.setOnClickListener(new View.OnClickListener() {
  355. @Override
  356. public void onClick(View v) {
  357. if (mSelectedDate1 == null) {
  358. mTimePickerInfo1.show(new Date(timeMillis));
  359. } else {
  360. mTimePickerInfo1.show(mSelectedDate1);
  361. }
  362. }
  363. });
  364. backbtn.setOnClickListener(new View.OnClickListener() {
  365. @Override
  366. public void onClick(View v) {
  367. finish();
  368. }
  369. });
  370. backtext.setOnClickListener(new View.OnClickListener() {
  371. @Override
  372. public void onClick(View v) {
  373. finish();
  374. }
  375. });
  376. sendOutSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
  377. @Override
  378. public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
  379. if (arg0 != null) {
  380. lastSendOutModel=sendOutModel;
  381. sendOutModel = (SendOutModel) arg0.getItemAtPosition(arg2);
  382. Lgort = sendOutModel.getSendOutId();
  383. if(isCancel) {
  384. return;
  385. }
  386. ProcessDialogUtils.showProcessDialog(
  387. SendOutGoods.this);
  388. if(!isFirst)
  389. {
  390. Dialog alertDialog = new AlertDialog.Builder(
  391. SendOutGoods.this).setMessage("确定是否切换发出仓库,需要重新扫码校验出库数量是否充足")
  392. .setPositiveButton("确定", new DialogInterface.OnClickListener() {
  393. @Override
  394. public void onClick(DialogInterface dialog, int which) {
  395. HandlerThread thread = new HandlerThread("worknoThread", 5);
  396. thread.start();
  397. mHandler = new Handler(thread.getLooper());
  398. mHandler.post(responsibilityWorkNoRunnable);
  399. }
  400. }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
  401. @Override
  402. public void onClick(DialogInterface dialog, int which) {
  403. isCancel=true;
  404. int index = sendOutList.indexOf(lastSendOutModel);
  405. if (index >= 0) {
  406. sendOutSpinner.setSelection(index); // 这将更新 Spinner 的选中项,但不会触发任何监听器
  407. }
  408. ProcessDialogUtils.closeProgressDilog();
  409. // 添加一秒延时
  410. new Handler().postDelayed(new Runnable() {
  411. @Override
  412. public void run() {
  413. isCancel=false;
  414. }
  415. }, 1500); // 1000 毫秒即一秒延时
  416. }
  417. }).create();
  418. alertDialog.setCanceledOnTouchOutside(false);
  419. alertDialog.show();
  420. return;
  421. }
  422. else
  423. {
  424. sendOutModel = (SendOutModel) arg0.getItemAtPosition(arg2);
  425. Lgort = sendOutModel.getSendOutId();
  426. HandlerThread thread = new HandlerThread("worknoThread", 5);
  427. thread.start();
  428. mHandler = new Handler(thread.getLooper());
  429. mHandler.post(responsibilityWorkNoRunnable);
  430. }
  431. if (!sendOutModel.getSendOutName().equals("请选择发出仓库")) {
  432. }
  433. }
  434. // flag = true;
  435. }
  436. @Override
  437. public void onNothingSelected(AdapterView<?> arg0) {
  438. }
  439. });
  440. saveBtn.setOnClickListener(new OnClickListener() {
  441. @Override
  442. public void onClick(View v) {
  443. String procedure = procedureTv.getText().toString().trim();
  444. if (TextUtils.isEmpty(procedure)) {
  445. Toast.makeText(getApplicationContext(), "请选择工序", Toast.LENGTH_SHORT).show();
  446. return;
  447. }
  448. if (sendOutList == null || sendOutList.size() == 0) {
  449. Toast.makeText(getApplicationContext(), "请选择发货仓库", Toast.LENGTH_SHORT).show();
  450. return;
  451. }
  452. //if (barcodeList == null || barcodeList.size() == 0) {
  453. // Toast.makeText(getApplicationContext(), "请添加发货单信息", Toast.LENGTH_SHORT).show();
  454. // return;
  455. //}
  456. ProcessDialogUtils.showProcessDialog(SendOutGoods.this);
  457. SendOutModel sendOut = (SendOutModel) sendOutSpinner.getSelectedItem();
  458. if (sendOut == null) {
  459. CustomToast.showToast(getApplicationContext(), "不能为空", 2000);
  460. return;
  461. }
  462. //desc = descEdt.getText().toString();
  463. thread = new HandlerThread("SaveThread", 5);
  464. thread.start();
  465. mHandler = new Handler(thread.getLooper());
  466. SaveRunnable saveRunnable = new SaveRunnable();
  467. mHandler.post(saveRunnable);
  468. }
  469. });
  470. barcodeEdt.addTextChangedListener(new TextWatcher() {
  471. @Override
  472. public void afterTextChanged(Editable arg0) {
  473. if (barcodeEdt.getText().toString().contains("\n")) {
  474. String barcode = barcodeEdt.getText().toString().trim().replaceAll("\\n", "");
  475. barcodeEdt.setEnabled(false);
  476. barcodeEdt.setFocusable(false);
  477. barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
  478. @Override
  479. public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
  480. int dend) {
  481. return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
  482. }
  483. } });
  484. ProcessDialogUtils.showProcessDialog(SendOutGoods.this);
  485. if (TextUtils.isEmpty(barcode)) {
  486. ProcessDialogUtils.closeProgressDilog();
  487. barcodeEdt.setEnabled(true);
  488. barcodeEdt.setText("");
  489. barcodeEdt.setFocusable(true);
  490. barcodeEdt.setFocusableInTouchMode(true);
  491. barcodeEdt.requestFocus();
  492. barcodeEdt.findFocus();
  493. barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
  494. @Override
  495. public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
  496. int dstart, int dend) {
  497. return null;
  498. }
  499. } });
  500. CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
  501. CustomToast.showToast(getApplicationContext(), "条码不能为空", 2000);
  502. return;
  503. }
  504. else {
  505. thread = new HandlerThread("BarCodeThread", 5);
  506. thread.start();
  507. mHandler = new Handler(thread.getLooper());
  508. BarcodeRunnable barcodeRunnable = new BarcodeRunnable(barcode);
  509. mHandler.post(barcodeRunnable);
  510. }
  511. }
  512. }
  513. @Override
  514. public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  515. }
  516. @Override
  517. public void onTextChanged(CharSequence s, int start, int before, int count) {
  518. barcodeUpper = barcodeEdt.getText().toString();
  519. // 判断输入的文字是否是小写
  520. for (int i = 0; i < barcodeUpper.length(); i++) {
  521. if (barcodeUpper.charAt(i) - 0 >= 97 && barcodeUpper.charAt(i) - 0 <= 122) {
  522. barcodeUpperH.postDelayed(BarcodeUpperCase, 300);
  523. }
  524. }
  525. }
  526. });
  527. barcodeEdt.setOnEditorActionListener(new TextView.OnEditorActionListener() {
  528. @Override
  529. public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
  530. if (actionId == EditorInfo.IME_ACTION_GO) {
  531. String barcode = barcodeEdt.getText().toString().trim();
  532. barcodeEdt.setEnabled(false);
  533. barcodeEdt.setFocusable(false);
  534. barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
  535. @Override
  536. public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
  537. int dend) {
  538. return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
  539. }
  540. } });
  541. ProcessDialogUtils.showProcessDialog(SendOutGoods.this);
  542. if (TextUtils.isEmpty(barcode)) {
  543. ProcessDialogUtils.closeProgressDilog();
  544. barcodeEdt.setEnabled(true);
  545. barcodeEdt.setText("");
  546. barcodeEdt.setFocusable(true);
  547. barcodeEdt.setFocusableInTouchMode(true);
  548. barcodeEdt.requestFocus();
  549. barcodeEdt.findFocus();
  550. barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
  551. @Override
  552. public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
  553. int dstart, int dend) {
  554. return null;
  555. }
  556. } });
  557. CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
  558. CustomToast.showToast(getApplicationContext(), "条码不能为空", 2000);
  559. return true;
  560. }
  561. else {
  562. thread = new HandlerThread("BarCodeThread", 5);
  563. thread.start();
  564. mHandler = new Handler(thread.getLooper());
  565. BarcodeRunnable barcodeRunnable = new BarcodeRunnable(barcode);
  566. mHandler.post(barcodeRunnable);
  567. }
  568. }
  569. return true;
  570. }
  571. });
  572. }
  573. Runnable BarcodeUpperCase = new Runnable() {
  574. @Override
  575. public void run() {
  576. // 小写转大写
  577. barcodeEdt.setText(barcodeUpper.toUpperCase());
  578. // 设置EditText光标位置
  579. barcodeEdt.setSelection(barcodeUpper.length());
  580. }
  581. };
  582. public void showMultiChoiceWindow() {
  583. initProcedurePopWindow(booleans);
  584. mMultiChoicePopWindow.show(true);
  585. }
  586. public boolean removeFinishedBarCode(String code, List<BarcodeInfo> data) {
  587. boolean rem = false;
  588. for (int i = 0; i < data.size(); i++) {
  589. Object S = data.get(i);
  590. Class<?> clss = S.getClass();
  591. String clssName = clss.getName();
  592. Method m = null;
  593. Method mouldId = null;
  594. try {
  595. m = clss.getMethod("getFinishedBarCode");
  596. } catch (NoSuchMethodException e) {
  597. // TODO Auto-generated catch block
  598. e.printStackTrace();
  599. }
  600. String bar;
  601. try {
  602. bar = (String) m.invoke(S);
  603. if (bar.equals(code)) {
  604. rem = true;
  605. return rem;
  606. }
  607. } catch (IllegalArgumentException e) {
  608. e.printStackTrace();
  609. } catch (IllegalAccessException e) {
  610. e.printStackTrace();
  611. } catch (InvocationTargetException e) {
  612. // TODO Auto-generated catch block
  613. e.printStackTrace();
  614. }
  615. }
  616. return rem;
  617. }
  618. private Handler exceptionHandler = new Handler() {
  619. @Override
  620. public void handleMessage(Message msg) {
  621. super.handleMessage(msg);
  622. switch (msg.what) {
  623. case 0:
  624. ProcessDialogUtils.closeProgressDilog();
  625. if (mHandler != null) {
  626. mHandler.removeCallbacksAndMessages(null);
  627. mHandler.getLooper().quit();
  628. }
  629. Bundle b = msg.getData();
  630. String message = b.getString("message");
  631. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
  632. Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
  633. barcodeEdt.setEnabled(true);
  634. barcodeEdt.setText("");
  635. barcodeEdt.setFocusable(true);
  636. barcodeEdt.setFocusableInTouchMode(true);
  637. barcodeEdt.requestFocus();
  638. barcodeEdt.findFocus();
  639. barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
  640. @Override
  641. public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
  642. int dend) {
  643. return null;
  644. }
  645. } });
  646. CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
  647. break;
  648. case 1://关闭转圈
  649. ProcessDialogUtils.closeProgressDilog();
  650. if (mHandler != null) {
  651. mHandler.removeCallbacksAndMessages(null);
  652. mHandler.getLooper().quit();
  653. }
  654. Bundle b1 = msg.getData();
  655. String message1 = b1.getString("message");
  656. CommonUtil.showRepeatDialog(message1, SendOutGoods.this);
  657. break;
  658. }
  659. }
  660. };
  661. private void initView() {
  662. title = (TextView) findViewById(R.id.title);
  663. backbtn = (ImageButton) findViewById(R.id.left_img);
  664. backtext = (TextView) findViewById(R.id.back);
  665. title.setText("发货单");
  666. procedureTv = (TextView) findViewById(R.id.procedureTv);
  667. procedureTv.setMovementMethod(ScrollingMovementMethod.getInstance());
  668. procedureTv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
  669. procedureTv.setMarqueeRepeatLimit(6);
  670. mRootView = findViewById(R.id.parentRel);
  671. barcodeEdt = (EditText) findViewById(R.id.barcodeEdt);
  672. barcodeEdt.setRawInputType(InputType.TYPE_CLASS_NUMBER);
  673. CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
  674. descEdt = (EditText) findViewById(R.id.descEdt);
  675. messageLst = (ListView) findViewById(R.id.message_listview);
  676. saveBtn = (Button) findViewById(R.id.btnSave);
  677. sendOutSpinner = (Spinner) findViewById(R.id.trademarksource);
  678. receiveSpinner = (Spinner) findViewById(R.id.Spinner02);
  679. carBrandSpinner = (Spinner) findViewById(R.id.Spinner01);
  680. TextView04 = (TextView) findViewById(R.id.TextView04);
  681. TextView01 = (TextView) findViewById(R.id.TextView01);
  682. dateSelector = (ImageView) findViewById(R.id.ImageView02);
  683. dateSelector1 = (ImageView) findViewById(R.id.ImageView01);
  684. sGoodsLogcode = (TextView) findViewById(R.id.sendOutGoodsLogidTxt);
  685. }
  686. public void loadProcedureDataSource() {
  687. }
  688. private Runnable responsibilityWorkNoRunnable = new Runnable() {
  689. @Override
  690. public void run() {
  691. try {
  692. client = null;
  693. client = new WebClient();
  694. JSONObject js = new JSONObject();
  695. js.put("accountCode", accountCode);
  696. js.put("userCode", send_userCode);
  697. js.put("userPassword", password);
  698. js.put("sessionKey", sessionkey);
  699. js.put("module", "SendOutGoods");
  700. js.put("action", "GetSendOutGoodsLogs");
  701. JSONObject data = new JSONObject();
  702. data.put("Lgort", Lgort);// 发出仓
  703. data.put("sendoutgoodslogid", sendOutGoodLogId);// 日志id
  704. js.put("jsonData", data.toString());
  705. if(Lgort!=null) {
  706. String result = client.doPost(
  707. "http://" + serverAddress_ip + ":" + serverAddress_port + Constants.serverAction + "/DoAction",
  708. js.toString(), "application/json");
  709. JSONObject j = new JSONObject(result);
  710. JSONObject jo = (JSONObject) j.opt("d");
  711. int status = jo.optInt("Status");
  712. String message = jo.optString("Message");
  713. if (status == 0) {
  714. Message m = new Message();
  715. m.what = 10;
  716. Bundle b = new Bundle();
  717. b.putString("result", result);
  718. m.setData(b);
  719. handler.sendMessage(m);
  720. // String result1 = jo.optString("Result");
  721. // JSONArray jarray = new JSONArray(result1);
  722. // for (int i = 0; i < jarray.length(); i++) {
  723. // JSONObject jobj = (JSONObject) jarray.opt(i);
  724. // WorkNo w = new WorkNo();
  725. // double userId = jobj.optDouble("USERID");
  726. // w.setUserId(userId);
  727. // String userCode = jobj.optString("USERCODE");
  728. // w.setUserCode(userCode);
  729. // String userName1 = jobj.optString("USERNAME");
  730. // w.setUserName(userName1);
  731. // worknolist.add(w);
  732. // }
  733. }}
  734. }
  735. catch (Exception e) {
  736. Message m = new Message();
  737. m.what = 0;
  738. Bundle b = new Bundle();
  739. b.putString("message", "网络连接异常");
  740. m.setData(b);
  741. exceptionHandler.sendMessage(m);
  742. e.printStackTrace();
  743. }
  744. }
  745. };
  746. private class SaveRunnable implements Runnable {
  747. @Override
  748. public void run() {
  749. client = new WebClient();
  750. try {
  751. JSONObject js = new JSONObject();
  752. JSONObject js6 = new JSONObject();
  753. js6.put("SENDOUTCODE", sendOutGoodLogId);
  754. js6.put("USERCODE", send_userCode);
  755. if(TextView04.getText()== null|| TextView04.getText().toString()== "")
  756. {
  757. CustomToast.showToast(getApplicationContext(), "记账日期不能为空",
  758. 2000);
  759. ProcessDialogUtils.closeProgressDilog();
  760. return;
  761. }else
  762. {
  763. js6.put("ACCOUNTDATE", TextView04.getText().toString());
  764. }
  765. if(TextView01.getText()== null|| TextView01.getText().toString()== "")
  766. {
  767. CustomToast.showToast(getApplicationContext(), "送货日期不能为空",
  768. 2000);
  769. ProcessDialogUtils.closeProgressDilog();
  770. return;
  771. }else
  772. {
  773. js6.put("DELIVERDATE", TextView01.getText().toString());
  774. }
  775. if (sendOutSpinner.getSelectedItem() == null) {
  776. CustomToast.showToast(getApplicationContext(), "损坯原因不能为空",
  777. 2000);
  778. ProcessDialogUtils.closeProgressDilog();
  779. return;
  780. } else if (sendOutSpinner.getSelectedItem() != null) {
  781. SendOutModel model = (SendOutModel) sendOutSpinner.getSelectedItem();
  782. if (model != null && model.getSendOutId() == "") {
  783. CustomToast.showToast(getApplicationContext(),
  784. "发货仓库不能为空", 2000);
  785. ProcessDialogUtils.closeProgressDilog();
  786. return;
  787. }else
  788. {
  789. js6.put("WAREHOUSINGID", model.getSendOutId());
  790. }
  791. }
  792. if (receiveSpinner.getSelectedItem() == null) {
  793. CustomToast.showToast(getApplicationContext(), "损坯原因不能为空",
  794. 2000);
  795. ProcessDialogUtils.closeProgressDilog();
  796. return;
  797. } else if (receiveSpinner.getSelectedItem() != null) {
  798. ReceiveModel rm = (ReceiveModel) receiveSpinner.getSelectedItem();
  799. if (rm != null && rm.getReceiveId() == "") {
  800. CustomToast.showToast(getApplicationContext(),
  801. "接收仓库不能为空", 2000);
  802. ProcessDialogUtils.closeProgressDilog();
  803. return;
  804. }else
  805. {
  806. js6.put("RECEIVEID", rm.getReceiveId());
  807. }
  808. }
  809. if (carBrandSpinner.getSelectedItem() == null) {
  810. CustomToast.showToast(getApplicationContext(), "损坯原因不能为空",
  811. 2000);
  812. ProcessDialogUtils.closeProgressDilog();
  813. return;
  814. } else if (carBrandSpinner.getSelectedItem() != null) {
  815. CarBrandModel model = (CarBrandModel) carBrandSpinner.getSelectedItem();
  816. if (model != null && model.getCarBrandId() == "") {
  817. CustomToast.showToast(getApplicationContext(),
  818. "车牌号不能为空", 2000);
  819. ProcessDialogUtils.closeProgressDilog();
  820. return;
  821. }else
  822. {
  823. js6.put("CARPLATEID", model.getCarBrandId());
  824. }
  825. }
  826. js.put("setEntity", js6);
  827. if (barcodeList != null && barcodeList.size() > 0) {
  828. JSONArray jarray6 = new JSONArray();
  829. for (BarcodeInfo bd : barcodeList) {
  830. JSONObject jo6 = new JSONObject();
  831. jo6.put("Banma", bd.getBanMa());
  832. jo6.put("GOODSCODE", bd.getGoodsCode());
  833. jo6.put("MATERIALCODE", bd.getLogoCode());
  834. jo6.put("MATERIALREMARK", bd.getLogoName());
  835. jo6.put("BINDINGCount", bd.getOrderNo());
  836. jo6.put("FINISHEDLOADBATCHNO", bd.getFinishedBarCode());
  837. jarray6.put(jo6);
  838. }
  839. js.put("setDetailEntity", jarray6);
  840. }else
  841. {
  842. CustomToast.showToast(getApplicationContext(),
  843. "发货单信息不能为空", 2000);
  844. ProcessDialogUtils.closeProgressDilog();
  845. return;
  846. }
  847. JSONObject js5 = new JSONObject();
  848. js5.put("accountCode", accountCode);
  849. js5.put("userCode", send_userCode);
  850. js5.put("userPassword", password);
  851. js5.put("sessionKey", sessionkey);
  852. js5.put("module", "SendOutGoods");
  853. js5.put("action", "SaveSendOutGoods");
  854. js5.put("jsonData",js.toString());
  855. String result = client.doPost(
  856. "http://" + serverAddress_ip + ":" + serverAddress_port + Constants.serverAction + "/DoAction",
  857. js5.toString(), "application/json");
  858. Message m = new Message();
  859. m.what = 2;
  860. Bundle b = new Bundle();
  861. b.putString("result", result);
  862. m.setData(b);
  863. handler.sendMessage(m);
  864. } catch (Exception e) {
  865. Message m = new Message();
  866. m.what = 0;
  867. Bundle b = new Bundle();
  868. b.putString("message", "网络连接异常");
  869. m.setData(b);
  870. exceptionHandler.sendMessage(m);
  871. e.printStackTrace();
  872. }
  873. }
  874. }
  875. //扫码
  876. private class BarcodeRunnable implements Runnable {
  877. String barcode;
  878. public BarcodeRunnable(String barcode) {
  879. super();
  880. this.barcode = barcode;
  881. }
  882. @Override
  883. public void run() {
  884. client = new WebClient();
  885. try {
  886. JSONObject js = new JSONObject();
  887. js.put("accountCode", accountCode);
  888. js.put("userCode", send_userCode);
  889. js.put("userPassword", password);
  890. js.put("sessionKey", sessionkey);
  891. js.put("module", "SendOutGoods");
  892. js.put("action", "CheckSendOutBarcode");
  893. JSONObject data = new JSONObject();
  894. data.put("banma", barcode);
  895. js.put("jsonData", data.toString());
  896. String result = client.doPost(
  897. "http://" + serverAddress_ip + ":" + serverAddress_port + Constants.serverAction + "/DoAction",
  898. js.toString(), "application/json");
  899. Message m = new Message();
  900. m.what = 1;
  901. Bundle b = new Bundle();
  902. b.putString("result", result);
  903. m.setData(b);
  904. handler.sendMessage(m);
  905. } catch (Exception e) {
  906. Message m = new Message();
  907. m.what = 0;
  908. Bundle b = new Bundle();
  909. b.putString("message", "网络连接异常");
  910. m.setData(b);
  911. exceptionHandler.sendMessage(m);
  912. e.printStackTrace();
  913. }
  914. }
  915. }
  916. Handler handler = new Handler() {
  917. @Override
  918. public void handleMessage(Message msg) {
  919. switch (msg.what) {
  920. case 0:
  921. Bundle b = msg.getData();
  922. String json = b.getString("result");
  923. ProcessDialogUtils.closeProgressDilog();
  924. if (mHandler != null) {
  925. mHandler.removeCallbacksAndMessages(null);
  926. mHandler.getLooper().quit();
  927. }
  928. try {
  929. JSONObject jObject = new JSONObject(json);
  930. JSONObject object = (JSONObject) jObject.opt("d");
  931. int status = object.optInt("Status");
  932. String message = object.optString("Message");
  933. if (status == 0) {
  934. String result = object.optString("Result");
  935. JSONArray jArray = new JSONArray(result);
  936. if (jArray != null && jArray.length() > 0) {
  937. procedureList = new ArrayList<Procedure>();
  938. for (int i = 0; i < jArray.length(); i++) {
  939. JSONObject jObject1 = (JSONObject) jArray.opt(i);
  940. int procedureId = jObject1.optInt("PROCEDUREID");
  941. String procedureName = jObject1.optString("PROCEDURENAME");
  942. Procedure procedure = new Procedure();
  943. procedure.setProcedureId(String.valueOf(procedureId));
  944. procedure.setProcedureName(procedureName);
  945. procedureList.add(procedure);
  946. }
  947. booleans = new boolean[procedureList.size()];
  948. initProcedurePopWindow(booleans);
  949. }
  950. } else {
  951. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
  952. CommonUtil.showBarCodeAlertDialog(status, message, SendOutGoods.this, null, null, null);
  953. }
  954. } catch (Exception e) {
  955. e.printStackTrace();
  956. }
  957. break;
  958. case 1:
  959. ProcessDialogUtils.closeProgressDilog();
  960. if (mHandler != null) {
  961. mHandler.removeCallbacksAndMessages(null);
  962. mHandler.getLooper().quit();
  963. }
  964. Bundle bundle = msg.getData();
  965. String json1 = bundle.getString("result");
  966. try {
  967. JSONObject jObject = new JSONObject(json1);
  968. JSONObject object = (JSONObject) jObject.opt("d");
  969. int status = object.optInt("Status");
  970. String message = object.optString("Message");
  971. if (status == 0) {
  972. String result = object.optString("Result");
  973. JSONArray jArray = new JSONArray(result);
  974. String mCODE = ((JSONObject) jArray.opt(0)).optString("MATERIALCODE");
  975. String Count = ((JSONObject) jArray.opt(0)).optString("COUNT");
  976. int mcount = 0;
  977. for (BarcodeInfo bd : barcodeList) {
  978. if (bd.getLogoCode() == mCODE) {
  979. mcount = mcount + Integer.parseInt(bd.getOrderNo());
  980. }
  981. }
  982. int storageConout = 0;
  983. if (storageJArray != null && storageJArray.length() > 0) {
  984. for (int i = 0; i < storageJArray.length(); i++) {
  985. JSONObject sobject = (JSONObject) storageJArray.opt(i);
  986. String MATERIALCODE = sobject.optString("MATNR");
  987. if (MATERIALCODE.equals(mCODE)) {
  988. storageConout = storageConout + (int)Double.parseDouble(sobject.optString("LABST"));// sap库存
  989. }
  990. }
  991. }
  992. if ((Double.parseDouble(Count)) >(double)(storageConout-mcount)) {
  993. //CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
  994. CommonUtil.showBarCodeAlertDialog(0, "库存不足", SendOutGoods.this, barcodeEdt, null,
  995. null);
  996. return;
  997. } else {
  998. if (jArray != null && jArray.length() > 0) {
  999. for (int i = 0; i < jArray.length(); i++) {
  1000. JSONObject object2 = (JSONObject) jArray.opt(i);
  1001. String barcode = object2.optString("BANMA");
  1002. String goodsCode = object2.optString("GOODSCODE");
  1003. String LogoCode = object2.optString("MATERIALCODE");
  1004. String LogoName = object2.optString("MATERIALREMARK");
  1005. int orderNo = object2.optInt("COUNT");
  1006. boolean isHas =removeFinishedBarCode(object2.optString("FINISHEDLOADBATCHNO"), barcodeList);
  1007. if(isHas)
  1008. {
  1009. CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
  1010. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
  1011. CustomToast.showToast(getApplicationContext(), "条码重复", 2000);
  1012. break;
  1013. }
  1014. BarcodeInfo barcodeInfo = new BarcodeInfo();
  1015. barcodeInfo.setBanMa(barcode=="null"?"":barcode);
  1016. barcodeInfo.setGoodsCode(goodsCode);
  1017. barcodeInfo.setLogoCode(LogoCode);
  1018. barcodeInfo.setLogoName(LogoName);
  1019. barcodeInfo.setOrderNo(String.valueOf(orderNo));
  1020. barcodeInfo.setFinishedBarCode(object2.optString("FINISHEDLOADBATCHNO"));//判断是否重复
  1021. barcodeList.add(barcodeInfo);
  1022. }
  1023. if (adapter == null) {
  1024. adapter = new SendOutGoodsListMessageAdapter(SendOutGoods.this, barcodeList);
  1025. messageLst.setAdapter(adapter);
  1026. } else {
  1027. adapter.notifyDataSetChanged();
  1028. //messageLst.getLayoutParams().height=(messageLst.getHeight()+Height);
  1029. messageLst.getLayoutParams().height=(barcodeList.size()*Height);
  1030. }
  1031. saveBtn.setText("保存(" + barcodeList.size() + ")");
  1032. barcodeEdt.setEnabled(true);
  1033. barcodeEdt.setText("");
  1034. barcodeEdt.setFocusable(true);
  1035. barcodeEdt.setFocusableInTouchMode(true);
  1036. barcodeEdt.requestFocus();
  1037. barcodeEdt.findFocus();
  1038. barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
  1039. @Override
  1040. public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
  1041. int dstart, int dend) {
  1042. return null;
  1043. }
  1044. } });
  1045. CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
  1046. // InputMethodManager im = (InputMethodManager) barcodeEdt
  1047. // .getContext().getSystemService(
  1048. // Context.INPUT_METHOD_SERVICE);
  1049. // im.hideSoftInputFromWindow(ProductSuspendActivity.this
  1050. // .getCurrentFocus().getWindowToken(),
  1051. // InputMethodManager.HIDE_NOT_ALWAYS);
  1052. ProcessDialogUtils.closeProgressDilog();
  1053. }
  1054. }
  1055. } else if (status==-1)
  1056. {
  1057. message="此产品已发货,不能进行该操作";
  1058. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
  1059. CommonUtil.showBarCodeAlertDialog(0, message, SendOutGoods.this, barcodeEdt, null, null);
  1060. return;
  1061. }else if (status==-102)
  1062. {
  1063. message="此产品未交接,不能进行该操作";
  1064. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
  1065. CommonUtil.showBarCodeAlertDialog(0, message, SendOutGoods.this, barcodeEdt, null, null);
  1066. return;
  1067. }else if (status==-100)
  1068. {
  1069. message="此产品已被废弃,不能进行该操作";
  1070. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
  1071. CommonUtil.showBarCodeAlertDialog(0, message, SendOutGoods.this, barcodeEdt, null, null);
  1072. return;
  1073. }else if (status==-999)
  1074. {
  1075. message="此产品无效条码,不能进行该操作";
  1076. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
  1077. CommonUtil.showBarCodeAlertDialog(0, message, SendOutGoods.this, barcodeEdt, null, null);
  1078. return;
  1079. }
  1080. } catch (JSONException e) {
  1081. e.printStackTrace();
  1082. }
  1083. break;
  1084. case 2:
  1085. if (mHandler != null) {
  1086. mHandler.removeCallbacksAndMessages(null);
  1087. mHandler.getLooper().quit();
  1088. }
  1089. ProcessDialogUtils.closeProgressDilog();
  1090. Bundle bundle2 = msg.getData();
  1091. String json2 = bundle2.getString("result");
  1092. JSONObject jObject;
  1093. try {
  1094. jObject = new JSONObject(json2);
  1095. JSONObject object = (JSONObject) jObject.opt("d");
  1096. int status = object.optInt("Status");
  1097. String message = object.optString("Message");
  1098. //JSONObject result3 =(JSONObject) object.opt("Result");
  1099. //JSONArray resArray = (JSONArray)result3.opt("Result");
  1100. if (status == 0) {
  1101. barcodeList.removeAll(barcodeList);
  1102. adapter.notifyDataSetChanged();
  1103. messageLst.getLayoutParams().height=(barcodeList.size()*Height);
  1104. saveBtn.setText("保存(" + barcodeList.size() + ")");
  1105. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
  1106. CommonUtil.showSaveAlertDialog(0,message , SendOutGoods.this, null, barcodeEdt, 2);
  1107. // CustomToast.showToast(getApplicationContext(), "成功", 2000);
  1108. // CommonUtil.playSound(getApplicationContext());
  1109. //checkedProcedureList.clear();
  1110. //procedureTv.setText("");
  1111. //descEdt.setText("");
  1112. //desc = "";
  1113. //booleans = new boolean[procedureList.size()];
  1114. sendOutGoodLogId="";
  1115. ((LinearLayout) findViewById(R.id.LinearLayout06)).setVisibility(View.GONE);
  1116. HandlerThread thread = new HandlerThread("worknoThreads", 5);
  1117. thread.start();
  1118. mHandler = new Handler(thread.getLooper());
  1119. mHandler.post(responsibilityWorkNoRunnable);
  1120. } else{
  1121. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
  1122. CommonUtil.showSaveAlertDialog(0,message , SendOutGoods.this, null, barcodeEdt, 2);
  1123. }
  1124. } catch (JSONException e) {
  1125. e.printStackTrace();
  1126. }
  1127. break;
  1128. case 3:
  1129. Bundle b3 = msg.getData();
  1130. String json3 = b3.getString("glazeResult");
  1131. if (mHandler != null) {
  1132. mHandler.removeCallbacksAndMessages(null);
  1133. mHandler.getLooper().quit();
  1134. }
  1135. ProcessDialogUtils.closeProgressDilog();
  1136. JSONObject j2;
  1137. try {
  1138. j2 = new JSONObject(json3);
  1139. JSONObject j3 = j2.optJSONObject("d");
  1140. int status3 = j3.optInt("Status");
  1141. if (status3 == 0) {
  1142. String result3 = j3.optString("Result");
  1143. JSONArray resultArray = new JSONArray(result3);
  1144. if (resultArray != null && resultArray.length() > 0) {
  1145. sendOutList = new ArrayList<SendOutModel>();
  1146. for (int i = 0; i < resultArray.length(); i++) {
  1147. JSONObject resultObj = (JSONObject) resultArray.opt(i);
  1148. int dictionaryId = resultObj.optInt("DICTIONARYID");
  1149. String dictionaryValue = resultObj.optString("DICTIONARYVALUE");
  1150. SendOutModel sendOutModel = new SendOutModel();
  1151. sendOutModel.setSendOutId(String.valueOf(dictionaryId));
  1152. sendOutModel.setSendOutName(dictionaryValue);
  1153. sendOutList.add(sendOutModel);
  1154. }
  1155. sendOutAdapter = new SendOutSpinnerAdapter(SendOutGoods.this, sendOutList);
  1156. sendOutSpinner.setAdapter(sendOutAdapter);
  1157. }
  1158. }
  1159. } catch (JSONException e) {
  1160. e.printStackTrace();
  1161. }
  1162. break;
  1163. case 4:
  1164. Bundle b3r = msg.getData();
  1165. String json3r = b3r.getString("receiveResult");
  1166. if (mHandler != null) {
  1167. mHandler.removeCallbacksAndMessages(null);
  1168. mHandler.getLooper().quit();
  1169. }
  1170. JSONObject j2r;
  1171. try {
  1172. j2r = new JSONObject(json3r);
  1173. JSONObject j3 = j2r.optJSONObject("d");
  1174. int status3 = j3.optInt("Status");
  1175. if (status3 == 0) {
  1176. String result3 = j3.optString("Result");
  1177. JSONArray resultArray = new JSONArray(result3);
  1178. if (resultArray != null && resultArray.length() > 0) {
  1179. receiveList = new ArrayList<ReceiveModel>();
  1180. for (int i = 0; i < resultArray.length(); i++) {
  1181. JSONObject resultObj = (JSONObject) resultArray.opt(i);
  1182. int dictionaryId = resultObj.optInt("DICTIONARYID");
  1183. String dictionaryValue = resultObj.optString("DICTIONARYVALUE");
  1184. ReceiveModel receiveModel = new ReceiveModel();
  1185. receiveModel.setReceiveId(String.valueOf(dictionaryId));
  1186. receiveModel.setReceiveName(dictionaryValue);
  1187. receiveList.add(receiveModel);
  1188. }
  1189. receiveAdapter = new ReceiveSpinnerAdapter(SendOutGoods.this, receiveList);
  1190. receiveSpinner.setAdapter(receiveAdapter);
  1191. }
  1192. }
  1193. } catch (JSONException e) {
  1194. e.printStackTrace();
  1195. }
  1196. break;
  1197. case 5:
  1198. Bundle b3c = msg.getData();
  1199. String json3c = b3c.getString("carBrandResult");
  1200. if (mHandler != null) {
  1201. mHandler.removeCallbacksAndMessages(null);
  1202. mHandler.getLooper().quit();
  1203. }
  1204. JSONObject j2c;
  1205. try {
  1206. j2c = new JSONObject(json3c);
  1207. JSONObject j3 = j2c.optJSONObject("d");
  1208. int status3 = j3.optInt("Status");
  1209. if (status3 == 0) {
  1210. String result3 = j3.optString("Result");
  1211. JSONArray resultArray = new JSONArray(result3);
  1212. if (resultArray != null && resultArray.length() > 0) {
  1213. carBrandList = new ArrayList<CarBrandModel>();
  1214. for (int i = 0; i < resultArray.length(); i++) {
  1215. JSONObject resultObj = (JSONObject) resultArray.opt(i);
  1216. int dictionaryId = resultObj.optInt("DICTIONARYID");
  1217. String dictionaryValue = resultObj.optString("DICTIONARYVALUE");
  1218. CarBrandModel carBrandModel = new CarBrandModel();
  1219. carBrandModel.setCarBrandId(String.valueOf(dictionaryId));
  1220. carBrandModel.setCarBrandName(dictionaryValue);
  1221. carBrandList.add(carBrandModel);
  1222. }
  1223. carBrandAdapter = new CarBrandSpinnerAdapter(SendOutGoods.this, carBrandList);
  1224. carBrandSpinner.setAdapter(carBrandAdapter);
  1225. }
  1226. }
  1227. } catch (JSONException e) {
  1228. e.printStackTrace();
  1229. }
  1230. break;
  1231. case 10:
  1232. ProcessDialogUtils.closeProgressDilog();
  1233. if (mHandler != null) {
  1234. mHandler.removeCallbacksAndMessages(null);
  1235. mHandler.getLooper().quit();
  1236. }
  1237. Bundle bundle10 = msg.getData();
  1238. String json10 = bundle10.getString("result");
  1239. try {
  1240. JSONObject jObject10 = new JSONObject(json10);
  1241. JSONObject object = (JSONObject) jObject10.opt("d");
  1242. int status = object.optInt("Status");
  1243. String message = object.optString("Message");
  1244. if (status == 0) {
  1245. String result = object.optString("Result");
  1246. JSONArray jArr = new JSONArray(result);
  1247. storageJArray=(JSONArray)jArr.opt(0);
  1248. JSONArray jArray = (JSONArray)jArr.opt(1);
  1249. barcodeList.removeAll(barcodeList);
  1250. if (jArray != null && jArray.length() > 0) {
  1251. for (int i = 0; i < jArray.length(); i++) {
  1252. JSONObject object2 = (JSONObject) jArray.opt(i);
  1253. String barcode = object2.optString("BANMA");
  1254. String goodsCode = object2.optString("GOODSCODE");
  1255. String LogoCode = object2.optString("MATERIALCODE");
  1256. // groutingDate = CommonUtil.commonDateConverter(groutingDate);
  1257. String LogoName = object2.optString("MATERIALREMARK");
  1258. // String userCode = object2.optString("USERCODE");
  1259. String orderNo =String.valueOf((int) Double.parseDouble(object2.optString("COUNT")));
  1260. BarcodeInfo barcodeInfo = new BarcodeInfo();
  1261. barcodeInfo.setBanMa(barcode==null||barcode.equals("null")?"":barcode);
  1262. barcodeInfo.setGoodsCode(goodsCode);
  1263. barcodeInfo.setLogoCode(LogoCode);
  1264. barcodeInfo.setLogoName(LogoName);
  1265. // barcodeInfo.setUserCode(userCode);
  1266. barcodeInfo.setOrderNo(orderNo);
  1267. barcodeInfo.setFinishedBarCode(object2.optString("FINISHEDLOADBATCHNO"));
  1268. barcodeList.add(barcodeInfo);
  1269. }
  1270. }
  1271. if (adapter == null) {
  1272. adapter = new SendOutGoodsListMessageAdapter(SendOutGoods.this, barcodeList);
  1273. messageLst.setAdapter(adapter);
  1274. } else {
  1275. adapter.notifyDataSetChanged();
  1276. }
  1277. messageLst.getLayoutParams().height=(barcodeList.size()*Height);
  1278. saveBtn.setText("保存(" + barcodeList.size() + ")");
  1279. barcodeEdt.setEnabled(true);
  1280. barcodeEdt.setText("");
  1281. barcodeEdt.setFocusable(true);
  1282. barcodeEdt.setFocusableInTouchMode(true);
  1283. barcodeEdt.requestFocus();
  1284. barcodeEdt.findFocus();
  1285. isFirst=false;
  1286. barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
  1287. @Override
  1288. public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
  1289. int dstart, int dend) {
  1290. return null;
  1291. }
  1292. } });
  1293. if(IsSYNCSTATUS.equals("1"))
  1294. {
  1295. barcodeEdt.setEnabled(false);
  1296. saveBtn.setEnabled(false);
  1297. //sendOutSpinner.setSpinnerMode(DialogFragment.MODE_DIALOG);
  1298. }
  1299. CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
  1300. // InputMethodManager im = (InputMethodManager) barcodeEdt
  1301. // .getContext().getSystemService(
  1302. // Context.INPUT_METHOD_SERVICE);
  1303. // im.hideSoftInputFromWindow(ProductSuspendActivity.this
  1304. // .getCurrentFocus().getWindowToken(),
  1305. // InputMethodManager.HIDE_NOT_ALWAYS);
  1306. ProcessDialogUtils.closeProgressDilog();
  1307. }
  1308. //else {
  1309. // CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
  1310. // CommonUtil.showBarCodeAlertDialog(status, message, SendOutGoods.this, barcodeEdt, null, null);
  1311. // return;
  1312. //}
  1313. } catch (JSONException e) {
  1314. e.printStackTrace();
  1315. }
  1316. break;
  1317. }
  1318. }
  1319. };
  1320. public void initProcedurePopWindow(boolean[] bool) {
  1321. mMultiChoicePopWindow = new MultiChoiceProcedurePopWindow(this, mRootView, procedureList, bool);
  1322. mMultiChoicePopWindow.setTitle("工序列表");
  1323. mMultiChoicePopWindow.setOnOKButtonListener(new OnClickListener() {
  1324. @Override
  1325. public void onClick(View v) {
  1326. selItems = mMultiChoicePopWindow.getSelectItem();
  1327. booleansTemp = selItems.clone();
  1328. checkedProcedureList = new ArrayList<Procedure>();
  1329. StringBuffer stringBuffer = new StringBuffer();
  1330. if (selItems != null && selItems.length > 0) {
  1331. int size = selItems.length;
  1332. stringBuffer.append("【");
  1333. for (int i = 0; i < size; i++) {
  1334. if (selItems[i]) {
  1335. stringBuffer.append(procedureList.get(i).getProcedureName());
  1336. stringBuffer.append("、");
  1337. checkedProcedureList.add(procedureList.get(i));
  1338. }
  1339. }
  1340. if (checkedProcedureList != null && checkedProcedureList.size() > 0) {
  1341. String procedure = stringBuffer.toString();
  1342. if (procedure.length() > 0) {
  1343. procedure = procedure.substring(0, procedure.length() - 1);
  1344. StringBuffer procedureStringBuffer = new StringBuffer();
  1345. procedureStringBuffer.append(procedure);
  1346. procedureStringBuffer.append("】");
  1347. procedure = procedureStringBuffer.toString();
  1348. procedureTv.setText(procedure);
  1349. }
  1350. } else {
  1351. checkedProcedureList = null;
  1352. procedureTv.setText("");
  1353. }
  1354. }
  1355. }
  1356. });
  1357. mMultiChoicePopWindow.setOnCancelButtonListener(new OnClickListener() {
  1358. @Override
  1359. public void onClick(View v) {
  1360. if (booleansTemp != null && booleansTemp.length > 0) {
  1361. booleans = booleansTemp.clone();
  1362. }
  1363. }
  1364. });
  1365. }
  1366. @Override
  1367. public boolean onCreateOptionsMenu(Menu menu) {
  1368. getMenuInflater().inflate(R.menu.product_suspend, menu);
  1369. return true;
  1370. }
  1371. @Override
  1372. public boolean onOptionsItemSelected(MenuItem item) {
  1373. int id = item.getItemId();
  1374. if (id == R.id.action_settings) {
  1375. return true;
  1376. }
  1377. return super.onOptionsItemSelected(item);
  1378. }
  1379. }