LuociPriceActivity.java 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. package com.jiaju.activity;
  2. import java.io.Serializable;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import org.json.JSONArray;
  6. import org.json.JSONException;
  7. import org.json.JSONObject;
  8. import com.jiaju.adapter.HandOverAdapter;
  9. import com.jiaju.adapter.OrderSpinnerAdapter;
  10. import com.jiaju.adapter.SapSpinnerAdapter;
  11. import com.jiaju.model.BarcodeInfo;
  12. import com.jiaju.model.Order;
  13. import com.jiaju.net.WebClient;
  14. import com.jiaju.utils.CommonUtil;
  15. import com.jiaju.utils.Constants;
  16. import com.jiaju.utils.CustomToast;
  17. import com.jiaju.utils.ProcessDialogUtils;
  18. import com.jiaju.utils.Removeduplicate;
  19. import android.app.Activity;
  20. import android.app.Notification;
  21. import android.content.Context;
  22. import android.content.Intent;
  23. import android.content.SharedPreferences;
  24. import android.content.SharedPreferences.Editor;
  25. import android.os.Bundle;
  26. import android.os.Handler;
  27. import android.os.HandlerThread;
  28. import android.os.Message;
  29. import android.text.Editable;
  30. import android.text.InputFilter;
  31. import android.text.InputType;
  32. import android.text.Spanned;
  33. import android.text.TextUtils;
  34. import android.text.TextWatcher;
  35. import android.view.KeyEvent;
  36. import android.view.Menu;
  37. import android.view.MotionEvent;
  38. import android.view.View;
  39. import android.view.View.OnClickListener;
  40. import android.view.inputmethod.EditorInfo;
  41. import android.widget.AdapterView;
  42. import android.widget.AdapterView.OnItemSelectedListener;
  43. import android.widget.Button;
  44. import android.widget.EditText;
  45. import android.widget.ImageButton;
  46. import android.widget.ImageView;
  47. import android.widget.ListView;
  48. import android.widget.RelativeLayout;
  49. import android.widget.Spinner;
  50. import android.widget.TextView;
  51. //裸辞交接
  52. public class LuociPriceActivity extends Activity {
  53. private TextView tvTitle;
  54. private String password;
  55. private String sessionkey;
  56. private SharedPreferences preferences;
  57. private String ServerAddress_ip;
  58. private String ServerAddress_port;
  59. private String accountCode;
  60. private String handover_usercode;
  61. private HandlerThread thread;
  62. private Handler mHandler;
  63. private WebClient client;
  64. private List<Order> orderList;
  65. private Spinner orderSpinner;
  66. private SapSpinnerAdapter adapter1;
  67. private EditText barcodeEdt;
  68. private String barcode;
  69. private TextView tvBack;
  70. private ImageView ivBack;
  71. private Object obj = new Object();
  72. private List<BarcodeInfo> barcodeInfoList = new ArrayList<BarcodeInfo>();
  73. private ListView barcodeLst;
  74. private HandOverAdapter handoverAdapter;
  75. private Button saveBtn;
  76. // private EditText orderEdt;
  77. private boolean orderFlag;
  78. private Handler barcodeUpperH = new Handler();
  79. private String barcodeUpper;
  80. private boolean checkedFlag = false;
  81. private boolean isOrderTextChange;
  82. private OrderSpinnerAdapter adapter;
  83. private boolean isBarcodeTextChange;
  84. private RelativeLayout parent;
  85. private static final String[] m = {"APP1", "APP2", "APP3"};
  86. private Spinner spinner;
  87. private String spinnerName = "APP2";
  88. private String spinner_ = "";
  89. private boolean first = true;
  90. @Override
  91. protected void onCreate(Bundle savedInstanceState) {
  92. super.onCreate(savedInstanceState);
  93. setContentView(R.layout.activity_finished_product_handover);
  94. initView();
  95. preferences = getSharedPreferences("user", Context.MODE_PRIVATE);
  96. ServerAddress_ip = preferences.getString("ServerAddress_ip", "");
  97. ServerAddress_port = preferences.getString("ServerAddress_duankou", "");
  98. accountCode = preferences.getString("AccountCode", "");
  99. handover_usercode = preferences.getString("UserCode", "");
  100. password = preferences.getString("UserPassword", "");
  101. sessionkey = preferences.getString("SessionKey", "");
  102. Bundle b = getIntent().getExtras();
  103. String title = b.getString("title");
  104. tvTitle.setText(title);
  105. allListeners();
  106. thread = new HandlerThread("trademarkThread", 5);
  107. thread.start();
  108. mHandler = new Handler(thread.getLooper());
  109. OrderListRunnable orderListRunnable = new OrderListRunnable(obj);
  110. mHandler.post(orderListRunnable);
  111. }
  112. private void initView() {
  113. tvTitle = (TextView) findViewById(R.id.title);
  114. ivBack = (ImageButton) findViewById(R.id.left_img);
  115. tvBack = (TextView) findViewById(R.id.back);
  116. View head = View.inflate(this,
  117. R.layout.finished_product_handover_head_viewluoci, null);
  118. barcodeEdt = (EditText) head.findViewById(R.id.barcodeEdt);
  119. barcodeEdt.setRawInputType(InputType.TYPE_CLASS_NUMBER);
  120. barcodeLst = (ListView) findViewById(R.id.handoverlst);
  121. barcodeLst.addHeaderView(head, null, false);
  122. handoverAdapter = new HandOverAdapter(
  123. LuociPriceActivity.this, barcodeInfoList);
  124. barcodeLst.setAdapter(handoverAdapter);
  125. saveBtn = (Button) findViewById(R.id.saveBtn);
  126. parent = (RelativeLayout) findViewById(R.id.parentRel);
  127. }
  128. private void allListeners() {
  129. ivBack.setOnClickListener(new OnClickListener() {
  130. @Override
  131. public void onClick(View v) {
  132. finish();
  133. }
  134. });
  135. tvBack.setOnClickListener(new OnClickListener() {
  136. @Override
  137. public void onClick(View v) {
  138. finish();
  139. }
  140. });
  141. saveBtn.setOnClickListener(new View.OnClickListener() {
  142. @Override
  143. public void onClick(View v) {
  144. int orderId;
  145. if (barcodeInfoList == null || barcodeInfoList.size() == 0) {
  146. CustomToast.showToast(getApplicationContext(), "条码信息不能为空",
  147. 2000);
  148. return;
  149. }
  150. ProcessDialogUtils.showProcessDialog(
  151. LuociPriceActivity.this);
  152. thread = null;
  153. thread = new HandlerThread("saveThread", 5);
  154. thread.start();
  155. mHandler = new Handler(thread.getLooper());
  156. SaveRunnable saveRunnable = new SaveRunnable(obj);
  157. mHandler.post(saveRunnable);
  158. }
  159. });
  160. barcodeEdt.addTextChangedListener(new TextWatcher() {
  161. @Override
  162. public void afterTextChanged(Editable arg0) {
  163. }
  164. @Override
  165. public void beforeTextChanged(CharSequence s, int start, int count,
  166. int after) {
  167. }
  168. @Override
  169. public void onTextChanged(CharSequence s, int start, int before,
  170. int count) {
  171. barcodeUpper = barcodeEdt.getText().toString().trim();
  172. if(barcodeUpper.length() >= 73)
  173. {
  174. String[] parts = barcodeUpper.split("-", 2); // 第二个参数限制分割后的数组长度,这里为2
  175. if (parts.length == 2) {
  176. //System.out.println("第一部分: " + parts[0]);
  177. //System.out.println("第二部分: " + parts[1]);
  178. barcodeUpper = parts[1];
  179. }
  180. }
  181. // 判断输入的文字是否是小写
  182. for (int i = 0; i < barcodeUpper.length(); i++) {
  183. if (barcodeUpper.charAt(i) - 0 >= 97
  184. && barcodeUpper.charAt(i) - 0 <= 122) {
  185. barcodeUpperH.postDelayed(UpperCase, 300);
  186. }
  187. }
  188. if (start == 0 && before == 0 && count > 1) {
  189. String barcode = barcodeEdt.getText().toString();
  190. barcode = barcode.trim();
  191. if (!TextUtils.isEmpty(barcode)) {
  192. if(barcode.length() >= 73)
  193. {
  194. String[] parts = barcode.split("-", 2); // 第二个参数限制分割后的数组长度,这里为2
  195. if (parts.length == 2) {
  196. //System.out.println("第一部分: " + parts[0]);
  197. //System.out.println("第二部分: " + parts[1]);
  198. barcode = parts[1];
  199. }
  200. }
  201. ProcessDialogUtils.showProcessDialog(
  202. LuociPriceActivity.this);
  203. barcodeEdt.setEnabled(false);
  204. barcodeEdt.setFocusable(false);
  205. barcodeEdt.setFilters(
  206. new InputFilter[]{new InputFilter() {
  207. @Override
  208. public CharSequence filter(
  209. CharSequence source, int start,
  210. int end, Spanned dest, int dstart,
  211. int dend) {
  212. return source.length() < 1
  213. ? dest.subSequence(dstart, dend)
  214. : "";
  215. }
  216. }});
  217. thread = new HandlerThread("barcodeThread", 5);
  218. thread.start();
  219. mHandler = new Handler(thread.getLooper());
  220. BarcodeRunnable barcodeRunnable = new BarcodeRunnable(
  221. obj, barcode);
  222. mHandler.post(barcodeRunnable);
  223. }
  224. }
  225. }
  226. });
  227. barcodeEdt.setOnEditorActionListener(
  228. new TextView.OnEditorActionListener() {
  229. @Override
  230. public boolean onEditorAction(TextView v, int actionId,
  231. KeyEvent event) {
  232. if (actionId == EditorInfo.IME_ACTION_GO) {
  233. String barcode = barcodeEdt.getText().toString();
  234. if (!TextUtils.isEmpty(barcode)) {
  235. if(barcode.length() >= 73)
  236. {
  237. String[] parts = barcode.split("-", 2); // 第二个参数限制分割后的数组长度,这里为2
  238. if (parts.length == 2) {
  239. //System.out.println("第一部分: " + parts[0]);
  240. //System.out.println("第二部分: " + parts[1]);
  241. barcode = parts[1];
  242. }
  243. }
  244. ProcessDialogUtils.showProcessDialog(
  245. LuociPriceActivity.this);
  246. barcodeEdt.setEnabled(false);
  247. barcodeEdt.setFocusable(false);
  248. barcodeEdt.setFilters(
  249. new InputFilter[]{new InputFilter() {
  250. @Override
  251. public CharSequence filter(
  252. CharSequence source,
  253. int start, int end,
  254. Spanned dest, int dstart,
  255. int dend) {
  256. return source.length() < 1
  257. ? dest.subSequence(
  258. dstart, dend)
  259. : "";
  260. }
  261. }});
  262. thread = new HandlerThread("barcodeThread", 5);
  263. thread.start();
  264. mHandler = new Handler(thread.getLooper());
  265. BarcodeRunnable barcodeRunnable = new BarcodeRunnable(
  266. obj, barcode);
  267. mHandler.post(barcodeRunnable);
  268. return true;
  269. }
  270. }
  271. return false;
  272. }
  273. });
  274. }
  275. Runnable UpperCase = new Runnable() {
  276. @Override
  277. public void run() {
  278. // 小写转大写
  279. barcodeEdt.setText(barcodeUpper.toUpperCase());
  280. // 设置EditText光标位置
  281. barcodeEdt.setSelection(barcodeUpper.length());
  282. }
  283. };
  284. public static int getOrderIndex(String order, List<Order> orderList) {
  285. int newposition = -1;
  286. for (int position = 0; position < orderList.size(); position++) {
  287. if (order
  288. .equalsIgnoreCase((orderList.get(position).getOrderNo()))) {
  289. newposition = position;
  290. break;
  291. }
  292. }
  293. return newposition;
  294. }
  295. private class SaveRunnable implements Runnable {
  296. private Object object;
  297. public SaveRunnable(Object object) {
  298. this.object = object;
  299. }
  300. @Override
  301. public void run() {
  302. synchronized (object) {
  303. try {
  304. client = null;
  305. client = new WebClient();
  306. JSONObject js = new JSONObject();
  307. js.put("accountCode", accountCode);
  308. js.put("userCode", handover_usercode);
  309. js.put("userPassword", password);
  310. js.put("sessionKey", sessionkey);
  311. js.put("module", "LCFinishedProduct");
  312. js.put("SPANAME", spinnerName);
  313. js.put("action", "LCSaveFinishedHandover");
  314. JSONArray orderEntity = new JSONArray();
  315. for (BarcodeInfo info : barcodeInfoList) {
  316. JSONObject obj = new JSONObject();
  317. obj.put("BarCode", info.getBarcode());
  318. obj.put("GoodsModel", info.getGoodsCode());
  319. obj.put("SPANAME", spinnerName);
  320. obj.put("logoID", info.getLogoId());
  321. obj.put("LogoName", info.getLogoName());
  322. orderEntity.put(obj);
  323. }
  324. JSONObject data = new JSONObject();
  325. // data.put("OrderID", orderId);
  326. data.put("Table", orderEntity);
  327. data.put("SPANAME", spinnerName);
  328. js.put("jsonData", data.toString());
  329. String result = client.doPost(
  330. "http://" + ServerAddress_ip + ":"
  331. + ServerAddress_port
  332. + Constants.serverAction + "/DoAction",
  333. js.toString(), "application/json");
  334. Message m = new Message();
  335. m.what = 3;
  336. Bundle b = new Bundle();
  337. b.putString("saveResult", result);
  338. m.setData(b);
  339. handler.sendMessage(m);
  340. } catch (Exception e) {
  341. e.printStackTrace();
  342. Message m = new Message();
  343. Bundle b = new Bundle();
  344. b.putString("message", "网络连接异常");
  345. m.setData(b);
  346. m.what = 0;
  347. exceptionHandler.sendMessage(m);
  348. }
  349. }
  350. }
  351. };
  352. private class BarcodeRunnable implements Runnable {
  353. private Object object;
  354. private String barcode;
  355. public BarcodeRunnable(Object object, String barcode) {
  356. this.object = object;
  357. this.barcode = barcode;
  358. }
  359. @Override
  360. public void run() {
  361. synchronized (object) {
  362. try {
  363. client = null;
  364. client = new WebClient();
  365. JSONObject js1 = new JSONObject();
  366. js1.put("accountCode", accountCode);
  367. js1.put("userCode", handover_usercode);
  368. js1.put("userPassword", password);
  369. js1.put("sessionKey", sessionkey);
  370. JSONObject data = new JSONObject();
  371. data.put("Barcode", barcode);
  372. js1.put("jsonData", data.toString());
  373. js1.put("module", "LCFinishedProduct");
  374. js1.put("action", "LCFinishedHandoverBarcode");
  375. String result2 = client.doPost(
  376. "http://" + ServerAddress_ip + ":"
  377. + ServerAddress_port
  378. + Constants.serverAction + "/DoAction",
  379. js1.toString(), "application/json");
  380. Bundle b = new Bundle();
  381. Message message = new Message();
  382. message.what = 1;
  383. b.putString("barcode", barcode);
  384. b.putString("result", result2);
  385. message.setData(b);
  386. handler.sendMessage(message);
  387. } catch (Exception e) {
  388. e.printStackTrace();
  389. Message m = new Message();
  390. Bundle b = new Bundle();
  391. b.putString("message", "网络连接异常");
  392. m.setData(b);
  393. m.what = 0;
  394. exceptionHandler.sendMessage(m);
  395. }
  396. }
  397. }
  398. };
  399. private class OrderListRunnable implements Runnable {
  400. private Object object;
  401. public OrderListRunnable(Object object) {
  402. this.object = object;
  403. }
  404. @Override
  405. public void run() {
  406. synchronized (object) {
  407. try {
  408. client = null;
  409. client = new WebClient();
  410. JSONObject js = new JSONObject();
  411. js.put("accountCode", accountCode);
  412. js.put("userCode", handover_usercode);
  413. js.put("userPassword", password);
  414. js.put("sessionKey", sessionkey);
  415. JSONObject orderEntity = new JSONObject();
  416. js.put("order", orderEntity);
  417. String result = client.doPost(
  418. "http://" + ServerAddress_ip + ":"
  419. + ServerAddress_port
  420. + Constants.serverAction + "/GetOrderList",
  421. js.toString(), "application/json");
  422. JSONObject j = new JSONObject(result);
  423. JSONObject j1 = j.optJSONObject("d");
  424. int status = j1.optInt("Status");
  425. String message = j1.optString("Message");
  426. if (status == 0) {
  427. String result1 = j1.optString("Result");
  428. JSONArray jarray = new JSONArray(result1);
  429. if (jarray != null && jarray.length() > 0) {
  430. orderList = new ArrayList<Order>();
  431. Order order = new Order();
  432. order.setOrderId(-1);
  433. order.setOrderNo("请选择订单");
  434. orderList.add(order);
  435. for (int i = 0; i < jarray.length(); i++) {
  436. JSONObject obj = jarray.optJSONObject(i);
  437. int orderId = obj.optInt("ORDERID");
  438. String orderNo = obj.optString("ORDERNO");
  439. String valueFlag = obj.optString("VALUEFLAG");
  440. if (valueFlag.equals("1")) {
  441. Order order1 = new Order();
  442. order1.setOrderId(orderId);
  443. order1.setOrderNo(orderNo);
  444. orderList.add(order1);
  445. }
  446. }
  447. }
  448. Message m = new Message();
  449. m.what = 0;
  450. Bundle b = new Bundle();
  451. b.putSerializable("orderList",
  452. (Serializable) orderList);
  453. m.setData(b);
  454. handler.sendMessage(m);
  455. } else {
  456. Bundle b = new Bundle();
  457. b.putInt("status", status);
  458. b.putString("message", message);
  459. Message m = new Message();
  460. m.what = 1;
  461. m.setData(b);
  462. exceptionHandler.sendMessage(m);
  463. return;
  464. }
  465. } catch (Exception e) {
  466. e.printStackTrace();
  467. Message m = new Message();
  468. Bundle b = new Bundle();
  469. b.putString("message", "网络连接异常");
  470. m.setData(b);
  471. m.what = 0;
  472. exceptionHandler.sendMessage(m);
  473. }
  474. }
  475. }
  476. };
  477. Handler exceptionHandler = new Handler() {
  478. @Override
  479. public void handleMessage(Message msg) {
  480. switch (msg.what) {
  481. case 0 :
  482. Bundle b = msg.getData();
  483. String message = b.getString("message");
  484. ProcessDialogUtils.closeProgressDilog();
  485. if (mHandler != null) {
  486. mHandler.removeCallbacksAndMessages(null);
  487. mHandler.getLooper().quit();
  488. }
  489. CustomToast.showToast(getApplicationContext(), message,
  490. 2000);
  491. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
  492. getApplicationContext());
  493. barcodeEdt.setEnabled(true);
  494. barcodeEdt.setText("");
  495. barcodeEdt.setFocusable(true);
  496. barcodeEdt.setFocusableInTouchMode(true);
  497. barcodeEdt.requestFocus();
  498. barcodeEdt.findFocus();
  499. barcodeEdt.setFilters(new InputFilter[]{new InputFilter() {
  500. @Override
  501. public CharSequence filter(CharSequence source,
  502. int start, int end, Spanned dest, int dstart,
  503. int dend) {
  504. return null;
  505. }
  506. }});
  507. break;
  508. case 1 :
  509. Bundle b1 = msg.getData();
  510. int status1 = b1.getInt("status");
  511. String message1 = b1.getString("message");
  512. ProcessDialogUtils.closeProgressDilog();
  513. if (mHandler != null) {
  514. mHandler.removeCallbacksAndMessages(null);
  515. mHandler.getLooper().quit();
  516. }
  517. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
  518. getApplicationContext());
  519. CommonUtil.showBarCodeAlertDialog(status1, message1,
  520. LuociPriceActivity.this, barcodeEdt,
  521. null, null);
  522. break;
  523. }
  524. }
  525. };
  526. Handler handler = new Handler() {
  527. @SuppressWarnings("unchecked")
  528. @Override
  529. public void handleMessage(Message msg) {
  530. switch (msg.what) {
  531. case 0 :
  532. Bundle b = msg.getData();
  533. orderList = (List<Order>) b.getSerializable("orderList");
  534. if (mHandler != null) {
  535. mHandler.removeCallbacksAndMessages(null);
  536. mHandler.getLooper().quit();
  537. }
  538. ProcessDialogUtils.closeProgressDilog();
  539. break;
  540. case 1 :
  541. ProcessDialogUtils.closeProgressDilog();
  542. if (mHandler != null) {
  543. mHandler.removeCallbacksAndMessages(null);
  544. mHandler.getLooper().quit();
  545. }
  546. Bundle b1 = msg.getData();
  547. String result1 = b1.getString("result");
  548. barcode = b1.getString("barcode");
  549. JSONObject jobj2;
  550. try {
  551. jobj2 = new JSONObject(result1);
  552. JSONObject jobj3 = jobj2.optJSONObject("d");
  553. int status3 = jobj3.optInt("Status");
  554. if (status3 == 0) {
  555. String result4 = jobj3.optString("Result");
  556. JSONObject jobj4 = new JSONObject(result4);
  557. JSONArray arry4 = jobj4.optJSONArray("Table");
  558. if (arry4 != null && arry4.length() > 0) {
  559. JSONObject jobj6 = arry4.optJSONObject(0);
  560. String outbarcode = jobj6.optString("BARCODE");
  561. if (barcodeInfoList.size() > 0) {
  562. boolean b2 = Removeduplicate.removeBarCode(
  563. outbarcode, barcodeInfoList);
  564. if (b2) {
  565. String message = "条码" + outbarcode
  566. + "重复";
  567. CustomToast.showToast(
  568. getApplicationContext(),
  569. message, 2000);
  570. CommonUtil.setDefault(
  571. Notification.DEFAULT_VIBRATE,
  572. getApplicationContext());
  573. barcodeEdt.setEnabled(true);
  574. barcodeEdt.setText("");
  575. barcodeEdt.setFocusable(true);
  576. barcodeEdt
  577. .setFocusableInTouchMode(true);
  578. barcodeEdt.requestFocus();
  579. barcodeEdt.findFocus();
  580. barcodeEdt.setFilters(new InputFilter[]{
  581. new InputFilter() {
  582. @Override
  583. public CharSequence filter(
  584. CharSequence source,
  585. int start, int end,
  586. Spanned dest,
  587. int dstart,
  588. int dend) {
  589. return null;
  590. }
  591. }});
  592. return;
  593. }
  594. }
  595. for (int i = 0; i < arry4.length(); i++) {
  596. JSONObject jobj5 = arry4.optJSONObject(i);
  597. int logoId = jobj5.optInt("LOGOID");
  598. String logoCode = jobj5
  599. .optString("LOGOCODE");
  600. String logoName = jobj5
  601. .optString("LOGONAME");
  602. String goodsCode = jobj5
  603. .optString("GOODSCODE");
  604. String finishedBarCode = jobj5
  605. .optString("FINISHEDBARCODE");
  606. String outbarcode1 = jobj5
  607. .optString("BARCODE");
  608. int userId = jobj5.optInt("USERID");
  609. String groutingUserCode = jobj5
  610. .optString("GROUTINGUSERCODE");
  611. String mouldCode = jobj5
  612. .optString("MOULDCODE");
  613. String groutingDate = jobj5
  614. .optString("GROUTINGDATE");
  615. groutingDate = CommonUtil
  616. .commonDateConverter(groutingDate);
  617. String diliverTime = jobj5
  618. .optString("DELIVERTIME");
  619. String goodsModel = jobj5
  620. .optString("GOODSMODEL");
  621. diliverTime = CommonUtil
  622. .commonDateConverter(diliverTime);
  623. // limitNum = jobj5.optInt("PLATELIMITNUM");
  624. BarcodeInfo info = new BarcodeInfo();
  625. info.setBarcode(outbarcode1);
  626. info.setLogoId(logoId);
  627. info.setLogoCode(logoCode);
  628. info.setFinishedBarCode(finishedBarCode);
  629. info.setLogoName(logoName);
  630. info.setGoodsCode(goodsCode);
  631. info.setGoodsModel(goodsModel);
  632. info.setUserId(userId);
  633. info.setUserCode(groutingUserCode);
  634. info.setMouldCode(mouldCode);
  635. info.setGroutingDate(groutingDate);
  636. info.setDeliverTime(diliverTime);
  637. info.setBanMa(
  638. (jobj5.optString("BANMA") == "null")
  639. ? ""
  640. : jobj5.optString("BANMA"));
  641. barcodeInfoList.add(info);
  642. }
  643. if (handoverAdapter == null) {
  644. handoverAdapter = new HandOverAdapter(
  645. LuociPriceActivity.this,
  646. barcodeInfoList);
  647. barcodeLst.setAdapter(handoverAdapter);
  648. } else {
  649. handoverAdapter.notifyDataSetChanged();
  650. }
  651. barcodeEdt.setEnabled(true);
  652. barcodeEdt.setText("");
  653. barcodeEdt.setFocusable(true);
  654. barcodeEdt.setFocusableInTouchMode(true);
  655. barcodeEdt.requestFocus();
  656. barcodeEdt.findFocus();
  657. barcodeEdt.setFilters(
  658. new InputFilter[]{new InputFilter() {
  659. @Override
  660. public CharSequence filter(
  661. CharSequence source,
  662. int start, int end,
  663. Spanned dest, int dstart,
  664. int dend) {
  665. return null;
  666. }
  667. }});
  668. }
  669. } else {
  670. String message = jobj3.optString("Message");
  671. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
  672. getApplicationContext());
  673. CommonUtil.showBarCodeAlertDialog(status3, message,
  674. LuociPriceActivity.this,
  675. barcodeEdt, null, null);
  676. return;
  677. }
  678. saveBtn.setText("保存(" + barcodeInfoList.size() + ")");
  679. } catch (JSONException e1) {
  680. e1.printStackTrace();
  681. }
  682. break;
  683. case 2 :
  684. ProcessDialogUtils.closeProgressDilog();
  685. if (mHandler != null) {
  686. mHandler.removeCallbacksAndMessages(null);
  687. mHandler.getLooper().quit();
  688. }
  689. Bundle b2 = msg.getData();
  690. String errmsg = b2.getString("msg");
  691. String missFlag = b2.getString("missingFlag");
  692. Intent intent = new Intent();
  693. Bundle b3 = new Bundle();
  694. b3.putString("msg", errmsg);
  695. b3.putString("missingFlag", missFlag);
  696. intent.putExtras(b3);
  697. intent.setClass(LuociPriceActivity.this,
  698. MissingScanActivity.class);
  699. startActivityForResult(intent, 101);
  700. break;
  701. case 3 :
  702. Bundle b4 = msg.getData();
  703. String result3 = b4.getString("saveResult");
  704. if (mHandler != null) {
  705. mHandler.removeCallbacksAndMessages(null);
  706. mHandler.getLooper().quit();
  707. }
  708. ProcessDialogUtils.closeProgressDilog();
  709. barcodeEdt.setEnabled(true);
  710. barcodeEdt.setText("");
  711. barcodeEdt.setFocusable(true);
  712. barcodeEdt.setFocusableInTouchMode(true);
  713. barcodeEdt.requestFocus();
  714. barcodeEdt.findFocus();
  715. barcodeEdt.setFilters(new InputFilter[]{new InputFilter() {
  716. @Override
  717. public CharSequence filter(CharSequence source,
  718. int start, int end, Spanned dest, int dstart,
  719. int dend) {
  720. return null;
  721. }
  722. }});
  723. try {
  724. JSONObject jo = new JSONObject(result3);
  725. JSONObject jo1 = jo.optJSONObject("d");
  726. int status = jo1.optInt("Status");
  727. String message = jo1.optString("Message");
  728. if (status == 0) {
  729. CustomToast.showToast(getApplicationContext(),
  730. "保存成功", 2000);
  731. // if (quantitySettingValue.equals("0")) {
  732. // saveBtn.setEnabled(true);
  733. //
  734. // } else {
  735. // saveBtn.setEnabled(false);
  736. //
  737. // }
  738. // orderEdt.setText("");
  739. if (handoverAdapter != null) {
  740. barcodeInfoList.removeAll(barcodeInfoList);
  741. handoverAdapter.notifyDataSetChanged();
  742. saveBtn.setText(
  743. "保存(" + barcodeInfoList.size() + ")");
  744. }
  745. CommonUtil.playSound(getApplicationContext());
  746. } else {
  747. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
  748. getApplicationContext());
  749. CommonUtil.showBarCodeAlertDialog(status, message,
  750. LuociPriceActivity.this,
  751. barcodeEdt, null, null);
  752. }
  753. } catch (JSONException e) {
  754. e.printStackTrace();
  755. }
  756. break;
  757. }
  758. }
  759. };
  760. @Override
  761. public boolean dispatchTouchEvent(MotionEvent ev) {
  762. switch (ev.getAction()) {
  763. case MotionEvent.ACTION_DOWN :
  764. View view = getCurrentFocus();
  765. CommonUtil.hideKeyboard(ev, view,
  766. LuociPriceActivity.this);// 调用方法判断是否需要隐藏键盘
  767. break;
  768. default :
  769. break;
  770. }
  771. return super.dispatchTouchEvent(ev);
  772. }
  773. @Override
  774. protected void onActivityResult(int requestCode, int resultCode,
  775. Intent intent) {
  776. if (requestCode == 101 && resultCode == 103) {
  777. // orderEdt.setEnabled(true);
  778. // orderEdt.setFocusable(true);
  779. // orderEdt.setFocusableInTouchMode(true);
  780. // orderEdt.setFilters(new InputFilter[]{new InputFilter() {
  781. // @Override
  782. // public CharSequence filter(CharSequence source, int start,
  783. // int end, Spanned dest, int dstart, int dend) {
  784. // return null;
  785. // }
  786. // }});
  787. barcodeEdt.setEnabled(true);
  788. barcodeEdt.setText("");
  789. barcodeEdt.setFocusable(true);
  790. barcodeEdt.setFocusableInTouchMode(true);
  791. barcodeEdt.requestFocus();
  792. barcodeEdt.findFocus();
  793. barcodeEdt.setFilters(new InputFilter[]{new InputFilter() {
  794. @Override
  795. public CharSequence filter(CharSequence source, int start,
  796. int end, Spanned dest, int dstart, int dend) {
  797. return null;
  798. }
  799. }});
  800. }
  801. }
  802. @Override
  803. public boolean onCreateOptionsMenu(Menu menu) {
  804. getMenuInflater().inflate(R.menu.finished_product_handover, menu);
  805. return true;
  806. }
  807. }