| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557 |
- package com.jiaju.activity;
- import java.io.IOException;
- import java.lang.reflect.InvocationTargetException;
- import java.lang.reflect.Method;
- import java.security.KeyStore.PrivateKeyEntry;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- import com.jiaju.activity.ComponentsBreakageQuantityOkActivity.SaveRunnableScanOk;
- import com.jiaju.activity.MakeBilletActivity.BarcodeRunnable;
- import com.jiaju.adapter.CarBrandSpinnerAdapter;
- import com.jiaju.adapter.GlazeSpinnerAdapter;
- import com.jiaju.adapter.ReceiveSpinnerAdapter;
- import com.jiaju.adapter.SendOutGoodsListMessageAdapter;
- import com.jiaju.adapter.SendOutSpinnerAdapter;
- import com.jiaju.model.BarcodeInfo;
- import com.jiaju.model.Billet;
- import com.jiaju.model.CarBrandModel;
- import com.jiaju.model.DutyPerson;
- import com.jiaju.model.GlazeModel;
- import com.jiaju.model.Procedure;
- import com.jiaju.model.ReceiveModel;
- import com.jiaju.model.ResponsibilityProcedure;
- import com.jiaju.model.ScrapReason;
- import com.jiaju.model.SendOutModel;
- import com.jiaju.model.WorkNo;
- import com.jiaju.net.WebClient;
- import com.jiaju.utils.CommonUtil;
- import com.jiaju.utils.Constants;
- import com.jiaju.utils.CustomToast;
- import com.jiaju.utils.MultiChoicDialog;
- import com.jiaju.utils.MultiChoicePopWindow;
- import com.jiaju.utils.MultiChoiceProcedureDialog;
- import com.jiaju.utils.MultiChoiceProcedurePopWindow;
- import com.jiaju.utils.ProcessDialogUtils;
- import com.jiaju.utils.Removeduplicate;
- import com.jiaju.utils.TimePickerInfo;
- import android.annotation.SuppressLint;
- import android.app.Activity;
- import android.app.AlertDialog;
- import android.app.Dialog;
- import android.app.Notification;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.content.SharedPreferences;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.HandlerThread;
- import android.os.Message;
- import android.text.Editable;
- import android.text.InputFilter;
- import android.text.InputType;
- import android.text.Spanned;
- import android.text.TextUtils;
- import android.text.TextWatcher;
- import android.text.method.ScrollingMovementMethod;
- import android.view.KeyEvent;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.inputmethod.EditorInfo;
- import android.view.inputmethod.InputMethodManager;
- import android.widget.AdapterView;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.ImageButton;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.ListView;
- import android.widget.Spinner;
- import android.widget.TextView;
- import android.widget.Toast;
- import android.widget.AdapterView.OnItemSelectedListener;
- public class SendOutGoods extends Activity {
- private String serverAddress_ip;
- private String serverAddress_port;
- private String accountCode;
- private String password;
- private String sessionkey;
- private WebClient client;
- private String send_userCode;
- private SharedPreferences preferences;
- private HandlerThread thread;
- private Handler mHandler;
- private List<Procedure> procedureList;
- private List<Procedure> checkedProcedureList;
- private TextView title;
- private TextView backtext;
- private TextView sGoodsLogcode;
- private ImageButton backbtn;
- private Object obj = new Object();
- boolean booleans[];
- boolean booleansTemp[];
- boolean[] selItems;
- private View mRootView;
- private MultiChoiceProcedurePopWindow mMultiChoicePopWindow;
- private EditText barcodeEdt;
- private EditText descEdt;
- private String barcodeUpper;
- private String Lgort;// 发出仓
- private TextView procedureTv;
- private List<BarcodeInfo> barcodeList;
- private List<SendOutModel> sendOutList;
- private List<ReceiveModel> receiveList;
- private List<CarBrandModel> carBrandList;
- private JSONArray storageJArray;// 库存
- private ListView messageLst;
- public Button saveBtn;
- private TimePickerInfo mTimePickerInfo;
- private TimePickerInfo mTimePickerInfo1;
- private long timeMillis;
- private Date mSelectedDate;
- private Date mSelectedDate1;
- private Spinner sendOutSpinner;
- private Spinner receiveSpinner;
- private Spinner carBrandSpinner;
- private TextView TextView04;
- private TextView TextView01;
- protected String selectedDate;
- protected String selectedDate1;
- protected String sendOutGoodLogId;
- private SendOutModel sendOutModel;
- private SendOutModel lastSendOutModel;
- private String desc;
- private ImageView dateSelector;
- private ImageView dateSelector1;
- private SendOutSpinnerAdapter sendOutAdapter;
- private ReceiveSpinnerAdapter receiveAdapter;
- private CarBrandSpinnerAdapter carBrandAdapter;
- private Handler barcodeUpperH = new Handler();
- private SendOutGoodsListMessageAdapter adapter;
- private boolean isCancel=false;
- private boolean isFirst=true;
- private String IsSYNCSTATUS="0";
- private int Height=188;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_send_out_goods);
- preferences = getSharedPreferences("user", Context.MODE_PRIVATE);
- serverAddress_ip = preferences.getString("ServerAddress_ip", "");
- serverAddress_port = preferences.getString("ServerAddress_duankou", "");
- accountCode = preferences.getString("AccountCode", "");
- send_userCode = preferences.getString("UserCode", "");
- password = preferences.getString("UserPassword", "");
- sessionkey = preferences.getString("SessionKey", "");
- barcodeList = new ArrayList<BarcodeInfo>();
- loadProcedureDataSource();
- initView();
- sendOutGoodLogId="";
- sendOutGoodLogId = this.getIntent().getStringExtra("sendoutCode");
- IsSYNCSTATUS = this.getIntent().getStringExtra("SYNCSTATUS");
- if(IsSYNCSTATUS==null||IsSYNCSTATUS.equals("")) {
- IsSYNCSTATUS="0";
- }
- if(sendOutGoodLogId==null||sendOutGoodLogId=="")
- {
- ((LinearLayout) findViewById(R.id.LinearLayout06)).setVisibility(View.GONE);
- }else
- {
- sGoodsLogcode.setText(sendOutGoodLogId);
- }
- procedureTv.setText(send_userCode);
- selectedDate = CommonUtil.getCurrentDate();
- TextView04.setText(selectedDate);
- timeMillis = System.currentTimeMillis();
- mTimePickerInfo = new TimePickerInfo(SendOutGoods.this, TimePickerInfo.Type.YEAR_MONTH_DAY);
- mTimePickerInfo.setCyclic(true);
- mTimePickerInfo.setCancelable(true);
- mTimePickerInfo.setOnTimeSelectListener(new TimePickerInfo.OnTimeSelectListener() {
- @SuppressLint("SimpleDateFormat")
- @Override
- public void onTimeSelect(Date date) {
- // 存储当前选中的date
- SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd");
- mSelectedDate = date;
- selectedDate = dateFormater.format(mSelectedDate);
- TextView04.setText(selectedDate);
- }
- });
-
- selectedDate1 = CommonUtil.getCurrentDate();
- TextView01.setText(selectedDate1);
- timeMillis = System.currentTimeMillis();
- mTimePickerInfo1 = new TimePickerInfo(SendOutGoods.this, TimePickerInfo.Type.YEAR_MONTH_DAY);
- mTimePickerInfo1.setCyclic(true);
- mTimePickerInfo1.setCancelable(true);
- mTimePickerInfo1.setOnTimeSelectListener(new TimePickerInfo.OnTimeSelectListener() {
- @SuppressLint("SimpleDateFormat")
- @Override
- public void onTimeSelect(Date date) {
- // 存储当前选中的date
- SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd");
- mSelectedDate1 = date;
- selectedDate1 = dateFormater.format(mSelectedDate1);
- TextView01.setText(selectedDate1);
- }
- });
-
- allListeners();
- thread = new HandlerThread("sendOutThread3", 5);
- thread.start();
- mHandler = new Handler(thread.getLooper());
- SendOutRunnable glazeRunnable = new SendOutRunnable(obj);
- mHandler.post(glazeRunnable);
-
- thread = new HandlerThread("sendOutThread1", 5);
- thread.start();
- mHandler = new Handler(thread.getLooper());
- CarBrandRunnable CarBrandRunnable = new CarBrandRunnable(obj);
- mHandler.post(CarBrandRunnable);
- thread = new HandlerThread("sendOutThread2", 5);
- thread.start();
- mHandler = new Handler(thread.getLooper());
- ReceiveRunnable ReceiveRunnable = new ReceiveRunnable(obj);
- mHandler.post(ReceiveRunnable);
- }
- //protected void onResume() {
- // super.onResume();
- // 如果值已经在onCreate()中加载完成,可以在这里直接调用方法
-
- //HandlerThread thread = new HandlerThread("worThread", 5);
- //thread.start();
- //mHandler = new Handler(thread.getLooper());
- // mHandler.post(responsibilityWorkNoRunnable);
- //isFirst=false;
- // }
- private class CarBrandRunnable implements Runnable {
- private Object object;
- public CarBrandRunnable(Object object) {
- this.object = object;
- }
- @Override
- public void run() {
- synchronized (object) {
- try {
- client = null;
- client = new WebClient();
- JSONObject js = new JSONObject();
- js.put("accountCode", accountCode);
- js.put("userCode", send_userCode);
- js.put("userPassword", password);
- js.put("sessionKey", sessionkey);
- js.put("dicType", "TPC029");
- String result = client.doPost("http://" + serverAddress_ip + ":" + serverAddress_port
- + Constants.serverAction + "/GetDataDictionaryByType", js.toString(), "application/json");
- Message m = new Message();
- m.what = 5;
- Bundle b = new Bundle();
- b.putString("carBrandResult", result);
- m.setData(b);
- handler.sendMessage(m);
- } catch (Exception e) {
- e.printStackTrace();
- Message m = new Message();
- Bundle b = new Bundle();
- b.putString("message", "网络连接异常");
- m.setData(b);
- m.what = 0;
- exceptionHandler.sendMessage(m);
- }
- }
- }
- };
- private class ReceiveRunnable implements Runnable {
- private Object object;
- public ReceiveRunnable(Object object) {
- this.object = object;
- }
- @Override
- public void run() {
- synchronized (object) {
- try {
- client = null;
- client = new WebClient();
- JSONObject js = new JSONObject();
- js.put("accountCode", accountCode);
- js.put("userCode", send_userCode);
- js.put("userPassword", password);
- js.put("sessionKey", sessionkey);
- js.put("dicType", "TPC028");
- String result = client.doPost("http://" + serverAddress_ip + ":" + serverAddress_port
- + Constants.serverAction + "/GetDataDictionaryByType", js.toString(), "application/json");
- Message m = new Message();
- m.what = 4;
- Bundle b = new Bundle();
- b.putString("receiveResult", result);
- m.setData(b);
- handler.sendMessage(m);
- } catch (Exception e) {
- e.printStackTrace();
- Message m = new Message();
- Bundle b = new Bundle();
- b.putString("message", "网络连接异常");
- m.setData(b);
- m.what = 0;
- exceptionHandler.sendMessage(m);
- }
- }
- }
- };
- private class SendOutRunnable implements Runnable {
- private Object object;
- public SendOutRunnable(Object object) {
- this.object = object;
- }
- @Override
- public void run() {
- synchronized (object) {
- try {
- ProcessDialogUtils
- .showProcessDialog(SendOutGoods.this);
- client = null;
- client = new WebClient();
- JSONObject js = new JSONObject();
- js.put("accountCode", accountCode);
- js.put("userCode", send_userCode);
- js.put("userPassword", password);
- js.put("sessionKey", sessionkey);
- js.put("dicType", "TPC027");
- String result = client.doPost("http://" + serverAddress_ip + ":" + serverAddress_port
- + Constants.serverAction + "/GetDataDictionaryByType", js.toString(), "application/json");
- Message m = new Message();
- m.what = 3;
- Bundle b = new Bundle();
- b.putString("glazeResult", result);
- m.setData(b);
- handler.sendMessage(m);
- } catch (Exception e) {
- e.printStackTrace();
- Message m = new Message();
- Bundle b = new Bundle();
- b.putString("message", "网络连接异常");
- m.setData(b);
- m.what = 0;
- exceptionHandler.sendMessage(m);
- }
- }
- }
- };
- private void allListeners() {
- dateSelector.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mSelectedDate == null) {
- mTimePickerInfo.show(new Date(timeMillis));
- } else {
- mTimePickerInfo.show(mSelectedDate);
- }
- }
- });
- dateSelector1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mSelectedDate1 == null) {
- mTimePickerInfo1.show(new Date(timeMillis));
- } else {
- mTimePickerInfo1.show(mSelectedDate1);
- }
- }
- });
- backbtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
- }
- });
- backtext.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
- }
- });
- sendOutSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
- if (arg0 != null) {
- lastSendOutModel=sendOutModel;
- sendOutModel = (SendOutModel) arg0.getItemAtPosition(arg2);
- Lgort = sendOutModel.getSendOutId();
- if(isCancel) {
- return;
- }
- ProcessDialogUtils.showProcessDialog(
- SendOutGoods.this);
- if(!isFirst)
- {
-
- Dialog alertDialog = new AlertDialog.Builder(
- SendOutGoods.this).setMessage("确定是否切换发出仓库,需要重新扫码校验出库数量是否充足")
- .setPositiveButton("确定", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- HandlerThread thread = new HandlerThread("worknoThread", 5);
- thread.start();
- mHandler = new Handler(thread.getLooper());
- mHandler.post(responsibilityWorkNoRunnable);
- }
- }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- isCancel=true;
- int index = sendOutList.indexOf(lastSendOutModel);
- if (index >= 0) {
- sendOutSpinner.setSelection(index); // 这将更新 Spinner 的选中项,但不会触发任何监听器
- }
- ProcessDialogUtils.closeProgressDilog();
- // 添加一秒延时
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- isCancel=false;
- }
- }, 1500); // 1000 毫秒即一秒延时
-
- }
- }).create();
- alertDialog.setCanceledOnTouchOutside(false);
- alertDialog.show();
- return;
-
- }
- else
- {
- sendOutModel = (SendOutModel) arg0.getItemAtPosition(arg2);
- Lgort = sendOutModel.getSendOutId();
- HandlerThread thread = new HandlerThread("worknoThread", 5);
- thread.start();
- mHandler = new Handler(thread.getLooper());
- mHandler.post(responsibilityWorkNoRunnable);
- }
- if (!sendOutModel.getSendOutName().equals("请选择发出仓库")) {
-
- }
- }
-
- // flag = true;
- }
- @Override
- public void onNothingSelected(AdapterView<?> arg0) {
- }
- });
- saveBtn.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- String procedure = procedureTv.getText().toString().trim();
- if (TextUtils.isEmpty(procedure)) {
- Toast.makeText(getApplicationContext(), "请选择工序", Toast.LENGTH_SHORT).show();
- return;
- }
- if (sendOutList == null || sendOutList.size() == 0) {
- Toast.makeText(getApplicationContext(), "请选择发货仓库", Toast.LENGTH_SHORT).show();
- return;
- }
- //if (barcodeList == null || barcodeList.size() == 0) {
- // Toast.makeText(getApplicationContext(), "请添加发货单信息", Toast.LENGTH_SHORT).show();
- // return;
- //}
- ProcessDialogUtils.showProcessDialog(SendOutGoods.this);
- SendOutModel sendOut = (SendOutModel) sendOutSpinner.getSelectedItem();
- if (sendOut == null) {
- CustomToast.showToast(getApplicationContext(), "不能为空", 2000);
- return;
- }
- //desc = descEdt.getText().toString();
- thread = new HandlerThread("SaveThread", 5);
- thread.start();
- mHandler = new Handler(thread.getLooper());
- SaveRunnable saveRunnable = new SaveRunnable();
- mHandler.post(saveRunnable);
- }
- });
- barcodeEdt.addTextChangedListener(new TextWatcher() {
- @Override
- public void afterTextChanged(Editable arg0) {
- if (barcodeEdt.getText().toString().contains("\n")) {
- String barcode = barcodeEdt.getText().toString().trim().replaceAll("\\n", "");
- barcodeEdt.setEnabled(false);
- barcodeEdt.setFocusable(false);
- barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
- @Override
- public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
- int dend) {
- return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
- }
- } });
- ProcessDialogUtils.showProcessDialog(SendOutGoods.this);
- if (TextUtils.isEmpty(barcode)) {
- ProcessDialogUtils.closeProgressDilog();
- barcodeEdt.setEnabled(true);
- barcodeEdt.setText("");
- barcodeEdt.setFocusable(true);
- barcodeEdt.setFocusableInTouchMode(true);
- barcodeEdt.requestFocus();
- barcodeEdt.findFocus();
- barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
- @Override
- public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
- int dstart, int dend) {
- return null;
- }
- } });
- CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
- CustomToast.showToast(getApplicationContext(), "条码不能为空", 2000);
- return;
- }
- else {
- thread = new HandlerThread("BarCodeThread", 5);
- thread.start();
- mHandler = new Handler(thread.getLooper());
- BarcodeRunnable barcodeRunnable = new BarcodeRunnable(barcode);
- mHandler.post(barcodeRunnable);
- }
- }
- }
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- barcodeUpper = barcodeEdt.getText().toString();
- // 判断输入的文字是否是小写
- for (int i = 0; i < barcodeUpper.length(); i++) {
- if (barcodeUpper.charAt(i) - 0 >= 97 && barcodeUpper.charAt(i) - 0 <= 122) {
- barcodeUpperH.postDelayed(BarcodeUpperCase, 300);
- }
- }
- }
- });
- barcodeEdt.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- if (actionId == EditorInfo.IME_ACTION_GO) {
- String barcode = barcodeEdt.getText().toString().trim();
- barcodeEdt.setEnabled(false);
- barcodeEdt.setFocusable(false);
- barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
- @Override
- public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
- int dend) {
- return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
- }
- } });
- ProcessDialogUtils.showProcessDialog(SendOutGoods.this);
- if (TextUtils.isEmpty(barcode)) {
- ProcessDialogUtils.closeProgressDilog();
- barcodeEdt.setEnabled(true);
- barcodeEdt.setText("");
- barcodeEdt.setFocusable(true);
- barcodeEdt.setFocusableInTouchMode(true);
- barcodeEdt.requestFocus();
- barcodeEdt.findFocus();
- barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
- @Override
- public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
- int dstart, int dend) {
- return null;
- }
- } });
- CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
- CustomToast.showToast(getApplicationContext(), "条码不能为空", 2000);
- return true;
- }
- else {
- thread = new HandlerThread("BarCodeThread", 5);
- thread.start();
- mHandler = new Handler(thread.getLooper());
- BarcodeRunnable barcodeRunnable = new BarcodeRunnable(barcode);
- mHandler.post(barcodeRunnable);
- }
- }
- return true;
- }
- });
- }
- Runnable BarcodeUpperCase = new Runnable() {
- @Override
- public void run() {
- // 小写转大写
- barcodeEdt.setText(barcodeUpper.toUpperCase());
- // 设置EditText光标位置
- barcodeEdt.setSelection(barcodeUpper.length());
- }
- };
- public void showMultiChoiceWindow() {
- initProcedurePopWindow(booleans);
- mMultiChoicePopWindow.show(true);
- }
- public boolean removeFinishedBarCode(String code, List<BarcodeInfo> data) {
- boolean rem = false;
- for (int i = 0; i < data.size(); i++) {
- Object S = data.get(i);
- Class<?> clss = S.getClass();
- String clssName = clss.getName();
- Method m = null;
- Method mouldId = null;
- try {
- m = clss.getMethod("getFinishedBarCode");
- } catch (NoSuchMethodException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- String bar;
- try {
- bar = (String) m.invoke(S);
- if (bar.equals(code)) {
- rem = true;
- return rem;
- }
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- return rem;
- }
- private Handler exceptionHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- super.handleMessage(msg);
- switch (msg.what) {
- case 0:
- ProcessDialogUtils.closeProgressDilog();
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- mHandler.getLooper().quit();
- }
- Bundle b = msg.getData();
- String message = b.getString("message");
- CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
- Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
- barcodeEdt.setEnabled(true);
- barcodeEdt.setText("");
- barcodeEdt.setFocusable(true);
- barcodeEdt.setFocusableInTouchMode(true);
- barcodeEdt.requestFocus();
- barcodeEdt.findFocus();
- barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
- @Override
- public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
- int dend) {
- return null;
- }
- } });
- CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
- break;
- case 1://关闭转圈
- ProcessDialogUtils.closeProgressDilog();
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- mHandler.getLooper().quit();
- }
- Bundle b1 = msg.getData();
- String message1 = b1.getString("message");
- CommonUtil.showRepeatDialog(message1, SendOutGoods.this);
- break;
- }
- }
- };
- private void initView() {
- title = (TextView) findViewById(R.id.title);
- backbtn = (ImageButton) findViewById(R.id.left_img);
- backtext = (TextView) findViewById(R.id.back);
- title.setText("发货单");
- procedureTv = (TextView) findViewById(R.id.procedureTv);
- procedureTv.setMovementMethod(ScrollingMovementMethod.getInstance());
-
- procedureTv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
- procedureTv.setMarqueeRepeatLimit(6);
- mRootView = findViewById(R.id.parentRel);
- barcodeEdt = (EditText) findViewById(R.id.barcodeEdt);
- barcodeEdt.setRawInputType(InputType.TYPE_CLASS_NUMBER);
- CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
- descEdt = (EditText) findViewById(R.id.descEdt);
- messageLst = (ListView) findViewById(R.id.message_listview);
- saveBtn = (Button) findViewById(R.id.btnSave);
- sendOutSpinner = (Spinner) findViewById(R.id.trademarksource);
- receiveSpinner = (Spinner) findViewById(R.id.Spinner02);
- carBrandSpinner = (Spinner) findViewById(R.id.Spinner01);
- TextView04 = (TextView) findViewById(R.id.TextView04);
- TextView01 = (TextView) findViewById(R.id.TextView01);
- dateSelector = (ImageView) findViewById(R.id.ImageView02);
- dateSelector1 = (ImageView) findViewById(R.id.ImageView01);
- sGoodsLogcode = (TextView) findViewById(R.id.sendOutGoodsLogidTxt);
-
- }
- public void loadProcedureDataSource() {
- }
- private Runnable responsibilityWorkNoRunnable = new Runnable() {
- @Override
- public void run() {
- try {
- client = null;
- client = new WebClient();
- JSONObject js = new JSONObject();
- js.put("accountCode", accountCode);
- js.put("userCode", send_userCode);
- js.put("userPassword", password);
- js.put("sessionKey", sessionkey);
- js.put("module", "SendOutGoods");
- js.put("action", "GetSendOutGoodsLogs");
- JSONObject data = new JSONObject();
- data.put("Lgort", Lgort);// 发出仓
- data.put("sendoutgoodslogid", sendOutGoodLogId);// 日志id
- js.put("jsonData", data.toString());
- if(Lgort!=null) {
- String result = client.doPost(
- "http://" + serverAddress_ip + ":" + serverAddress_port + Constants.serverAction + "/DoAction",
- js.toString(), "application/json");
- JSONObject j = new JSONObject(result);
- JSONObject jo = (JSONObject) j.opt("d");
- int status = jo.optInt("Status");
- String message = jo.optString("Message");
- if (status == 0) {
- Message m = new Message();
- m.what = 10;
- Bundle b = new Bundle();
- b.putString("result", result);
- m.setData(b);
- handler.sendMessage(m);
- // String result1 = jo.optString("Result");
- // JSONArray jarray = new JSONArray(result1);
- // for (int i = 0; i < jarray.length(); i++) {
- // JSONObject jobj = (JSONObject) jarray.opt(i);
- // WorkNo w = new WorkNo();
- // double userId = jobj.optDouble("USERID");
- // w.setUserId(userId);
- // String userCode = jobj.optString("USERCODE");
- // w.setUserCode(userCode);
- // String userName1 = jobj.optString("USERNAME");
- // w.setUserName(userName1);
- // worknolist.add(w);
- // }
- }}
- }
- catch (Exception e) {
- Message m = new Message();
- m.what = 0;
- Bundle b = new Bundle();
- b.putString("message", "网络连接异常");
- m.setData(b);
- exceptionHandler.sendMessage(m);
- e.printStackTrace();
- }
- }
- };
- private class SaveRunnable implements Runnable {
- @Override
- public void run() {
- client = new WebClient();
- try {
- JSONObject js = new JSONObject();
-
- JSONObject js6 = new JSONObject();
- js6.put("SENDOUTCODE", sendOutGoodLogId);
- js6.put("USERCODE", send_userCode);
-
- if(TextView04.getText()== null|| TextView04.getText().toString()== "")
- {
- CustomToast.showToast(getApplicationContext(), "记账日期不能为空",
- 2000);
- ProcessDialogUtils.closeProgressDilog();
- return;
- }else
- {
- js6.put("ACCOUNTDATE", TextView04.getText().toString());
- }
- if(TextView01.getText()== null|| TextView01.getText().toString()== "")
- {
- CustomToast.showToast(getApplicationContext(), "送货日期不能为空",
- 2000);
- ProcessDialogUtils.closeProgressDilog();
- return;
- }else
- {
- js6.put("DELIVERDATE", TextView01.getText().toString());
- }
-
- if (sendOutSpinner.getSelectedItem() == null) {
- CustomToast.showToast(getApplicationContext(), "损坯原因不能为空",
- 2000);
- ProcessDialogUtils.closeProgressDilog();
- return;
- } else if (sendOutSpinner.getSelectedItem() != null) {
- SendOutModel model = (SendOutModel) sendOutSpinner.getSelectedItem();
- if (model != null && model.getSendOutId() == "") {
- CustomToast.showToast(getApplicationContext(),
- "发货仓库不能为空", 2000);
- ProcessDialogUtils.closeProgressDilog();
- return;
- }else
- {
- js6.put("WAREHOUSINGID", model.getSendOutId());
- }
- }
- if (receiveSpinner.getSelectedItem() == null) {
- CustomToast.showToast(getApplicationContext(), "损坯原因不能为空",
- 2000);
- ProcessDialogUtils.closeProgressDilog();
- return;
- } else if (receiveSpinner.getSelectedItem() != null) {
- ReceiveModel rm = (ReceiveModel) receiveSpinner.getSelectedItem();
- if (rm != null && rm.getReceiveId() == "") {
- CustomToast.showToast(getApplicationContext(),
- "接收仓库不能为空", 2000);
- ProcessDialogUtils.closeProgressDilog();
- return;
- }else
- {
- js6.put("RECEIVEID", rm.getReceiveId());
- }
- }
- if (carBrandSpinner.getSelectedItem() == null) {
- CustomToast.showToast(getApplicationContext(), "损坯原因不能为空",
- 2000);
- ProcessDialogUtils.closeProgressDilog();
- return;
- } else if (carBrandSpinner.getSelectedItem() != null) {
- CarBrandModel model = (CarBrandModel) carBrandSpinner.getSelectedItem();
- if (model != null && model.getCarBrandId() == "") {
- CustomToast.showToast(getApplicationContext(),
- "车牌号不能为空", 2000);
- ProcessDialogUtils.closeProgressDilog();
- return;
- }else
- {
- js6.put("CARPLATEID", model.getCarBrandId());
- }
- }
-
- js.put("setEntity", js6);
- if (barcodeList != null && barcodeList.size() > 0) {
- JSONArray jarray6 = new JSONArray();
- for (BarcodeInfo bd : barcodeList) {
- JSONObject jo6 = new JSONObject();
- jo6.put("Banma", bd.getBanMa());
- jo6.put("GOODSCODE", bd.getGoodsCode());
- jo6.put("MATERIALCODE", bd.getLogoCode());
- jo6.put("MATERIALREMARK", bd.getLogoName());
- jo6.put("BINDINGCount", bd.getOrderNo());
- jo6.put("FINISHEDLOADBATCHNO", bd.getFinishedBarCode());
- jarray6.put(jo6);
- }
- js.put("setDetailEntity", jarray6);
- }else
- {
- CustomToast.showToast(getApplicationContext(),
- "发货单信息不能为空", 2000);
- ProcessDialogUtils.closeProgressDilog();
- return;
- }
- JSONObject js5 = new JSONObject();
- js5.put("accountCode", accountCode);
- js5.put("userCode", send_userCode);
- js5.put("userPassword", password);
- js5.put("sessionKey", sessionkey);
- js5.put("module", "SendOutGoods");
- js5.put("action", "SaveSendOutGoods");
- js5.put("jsonData",js.toString());
- String result = client.doPost(
- "http://" + serverAddress_ip + ":" + serverAddress_port + Constants.serverAction + "/DoAction",
- js5.toString(), "application/json");
- Message m = new Message();
- m.what = 2;
- Bundle b = new Bundle();
- b.putString("result", result);
- m.setData(b);
- handler.sendMessage(m);
- } catch (Exception e) {
- Message m = new Message();
- m.what = 0;
- Bundle b = new Bundle();
- b.putString("message", "网络连接异常");
- m.setData(b);
- exceptionHandler.sendMessage(m);
- e.printStackTrace();
- }
- }
- }
- //扫码
- private class BarcodeRunnable implements Runnable {
- String barcode;
- public BarcodeRunnable(String barcode) {
- super();
- this.barcode = barcode;
- }
- @Override
- public void run() {
- client = new WebClient();
- try {
- JSONObject js = new JSONObject();
- js.put("accountCode", accountCode);
- js.put("userCode", send_userCode);
- js.put("userPassword", password);
- js.put("sessionKey", sessionkey);
- js.put("module", "SendOutGoods");
- js.put("action", "CheckSendOutBarcode");
- JSONObject data = new JSONObject();
- data.put("banma", barcode);
- js.put("jsonData", data.toString());
- String result = client.doPost(
- "http://" + serverAddress_ip + ":" + serverAddress_port + Constants.serverAction + "/DoAction",
- js.toString(), "application/json");
- Message m = new Message();
- m.what = 1;
- Bundle b = new Bundle();
- b.putString("result", result);
- m.setData(b);
- handler.sendMessage(m);
- } catch (Exception e) {
- Message m = new Message();
- m.what = 0;
- Bundle b = new Bundle();
- b.putString("message", "网络连接异常");
- m.setData(b);
- exceptionHandler.sendMessage(m);
- e.printStackTrace();
- }
- }
- }
-
- Handler handler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case 0:
- Bundle b = msg.getData();
- String json = b.getString("result");
- ProcessDialogUtils.closeProgressDilog();
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- mHandler.getLooper().quit();
- }
- try {
- JSONObject jObject = new JSONObject(json);
- JSONObject object = (JSONObject) jObject.opt("d");
- int status = object.optInt("Status");
- String message = object.optString("Message");
- if (status == 0) {
- String result = object.optString("Result");
- JSONArray jArray = new JSONArray(result);
- if (jArray != null && jArray.length() > 0) {
- procedureList = new ArrayList<Procedure>();
- for (int i = 0; i < jArray.length(); i++) {
- JSONObject jObject1 = (JSONObject) jArray.opt(i);
- int procedureId = jObject1.optInt("PROCEDUREID");
- String procedureName = jObject1.optString("PROCEDURENAME");
- Procedure procedure = new Procedure();
- procedure.setProcedureId(String.valueOf(procedureId));
- procedure.setProcedureName(procedureName);
- procedureList.add(procedure);
- }
- booleans = new boolean[procedureList.size()];
- initProcedurePopWindow(booleans);
- }
- } else {
- CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
- CommonUtil.showBarCodeAlertDialog(status, message, SendOutGoods.this, null, null, null);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- break;
- case 1:
- ProcessDialogUtils.closeProgressDilog();
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- mHandler.getLooper().quit();
- }
- Bundle bundle = msg.getData();
- String json1 = bundle.getString("result");
- try {
- JSONObject jObject = new JSONObject(json1);
- JSONObject object = (JSONObject) jObject.opt("d");
- int status = object.optInt("Status");
- String message = object.optString("Message");
- if (status == 0) {
- String result = object.optString("Result");
- JSONArray jArray = new JSONArray(result);
- String mCODE = ((JSONObject) jArray.opt(0)).optString("MATERIALCODE");
- String Count = ((JSONObject) jArray.opt(0)).optString("COUNT");
- int mcount = 0;
- for (BarcodeInfo bd : barcodeList) {
- if (bd.getLogoCode() == mCODE) {
- mcount = mcount + Integer.parseInt(bd.getOrderNo());
- }
- }
- int storageConout = 0;
- if (storageJArray != null && storageJArray.length() > 0) {
- for (int i = 0; i < storageJArray.length(); i++) {
- JSONObject sobject = (JSONObject) storageJArray.opt(i);
- String MATERIALCODE = sobject.optString("MATNR");
- if (MATERIALCODE.equals(mCODE)) {
- storageConout = storageConout + (int)Double.parseDouble(sobject.optString("LABST"));// sap库存
- }
- }
- }
- if ((Double.parseDouble(Count)) >(double)(storageConout-mcount)) {
- //CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
- CommonUtil.showBarCodeAlertDialog(0, "库存不足", SendOutGoods.this, barcodeEdt, null,
- null);
- return;
- } else {
- if (jArray != null && jArray.length() > 0) {
- for (int i = 0; i < jArray.length(); i++) {
- JSONObject object2 = (JSONObject) jArray.opt(i);
- String barcode = object2.optString("BANMA");
- String goodsCode = object2.optString("GOODSCODE");
- String LogoCode = object2.optString("MATERIALCODE");
- String LogoName = object2.optString("MATERIALREMARK");
- int orderNo = object2.optInt("COUNT");
- boolean isHas =removeFinishedBarCode(object2.optString("FINISHEDLOADBATCHNO"), barcodeList);
- if(isHas)
- {
- CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
- CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
- CustomToast.showToast(getApplicationContext(), "条码重复", 2000);
- break;
- }
- BarcodeInfo barcodeInfo = new BarcodeInfo();
- barcodeInfo.setBanMa(barcode=="null"?"":barcode);
- barcodeInfo.setGoodsCode(goodsCode);
- barcodeInfo.setLogoCode(LogoCode);
- barcodeInfo.setLogoName(LogoName);
- barcodeInfo.setOrderNo(String.valueOf(orderNo));
- barcodeInfo.setFinishedBarCode(object2.optString("FINISHEDLOADBATCHNO"));//判断是否重复
- barcodeList.add(barcodeInfo);
- }
- if (adapter == null) {
- adapter = new SendOutGoodsListMessageAdapter(SendOutGoods.this, barcodeList);
- messageLst.setAdapter(adapter);
- } else {
- adapter.notifyDataSetChanged();
- //messageLst.getLayoutParams().height=(messageLst.getHeight()+Height);
- messageLst.getLayoutParams().height=(barcodeList.size()*Height);
- }
- saveBtn.setText("保存(" + barcodeList.size() + ")");
- barcodeEdt.setEnabled(true);
- barcodeEdt.setText("");
- barcodeEdt.setFocusable(true);
- barcodeEdt.setFocusableInTouchMode(true);
- barcodeEdt.requestFocus();
- barcodeEdt.findFocus();
- barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
- @Override
- public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
- int dstart, int dend) {
- return null;
- }
- } });
- CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
- // InputMethodManager im = (InputMethodManager) barcodeEdt
- // .getContext().getSystemService(
- // Context.INPUT_METHOD_SERVICE);
- // im.hideSoftInputFromWindow(ProductSuspendActivity.this
- // .getCurrentFocus().getWindowToken(),
- // InputMethodManager.HIDE_NOT_ALWAYS);
- ProcessDialogUtils.closeProgressDilog();
- }
- }
- } else if (status==-1)
- {
- message="此产品已发货,不能进行该操作";
- CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
- CommonUtil.showBarCodeAlertDialog(0, message, SendOutGoods.this, barcodeEdt, null, null);
- return;
- }else if (status==-102)
- {
- message="此产品未交接,不能进行该操作";
- CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
- CommonUtil.showBarCodeAlertDialog(0, message, SendOutGoods.this, barcodeEdt, null, null);
- return;
- }else if (status==-100)
- {
- message="此产品已被废弃,不能进行该操作";
- CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
- CommonUtil.showBarCodeAlertDialog(0, message, SendOutGoods.this, barcodeEdt, null, null);
- return;
- }else if (status==-999)
- {
- message="此产品无效条码,不能进行该操作";
- CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
- CommonUtil.showBarCodeAlertDialog(0, message, SendOutGoods.this, barcodeEdt, null, null);
- return;
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- break;
- case 2:
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- mHandler.getLooper().quit();
- }
- ProcessDialogUtils.closeProgressDilog();
- Bundle bundle2 = msg.getData();
- String json2 = bundle2.getString("result");
- JSONObject jObject;
- try {
- jObject = new JSONObject(json2);
- JSONObject object = (JSONObject) jObject.opt("d");
- int status = object.optInt("Status");
- String message = object.optString("Message");
- //JSONObject result3 =(JSONObject) object.opt("Result");
- //JSONArray resArray = (JSONArray)result3.opt("Result");
- if (status == 0) {
- barcodeList.removeAll(barcodeList);
- adapter.notifyDataSetChanged();
- messageLst.getLayoutParams().height=(barcodeList.size()*Height);
- saveBtn.setText("保存(" + barcodeList.size() + ")");
- CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
- CommonUtil.showSaveAlertDialog(0,message , SendOutGoods.this, null, barcodeEdt, 2);
- // CustomToast.showToast(getApplicationContext(), "成功", 2000);
- // CommonUtil.playSound(getApplicationContext());
- //checkedProcedureList.clear();
- //procedureTv.setText("");
- //descEdt.setText("");
- //desc = "";
- //booleans = new boolean[procedureList.size()];
- sendOutGoodLogId="";
- ((LinearLayout) findViewById(R.id.LinearLayout06)).setVisibility(View.GONE);
- HandlerThread thread = new HandlerThread("worknoThreads", 5);
- thread.start();
- mHandler = new Handler(thread.getLooper());
- mHandler.post(responsibilityWorkNoRunnable);
- } else{
- CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
- CommonUtil.showSaveAlertDialog(0,message , SendOutGoods.this, null, barcodeEdt, 2);
-
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- break;
- case 3:
- Bundle b3 = msg.getData();
- String json3 = b3.getString("glazeResult");
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- mHandler.getLooper().quit();
- }
- ProcessDialogUtils.closeProgressDilog();
- JSONObject j2;
- try {
- j2 = new JSONObject(json3);
- JSONObject j3 = j2.optJSONObject("d");
- int status3 = j3.optInt("Status");
- if (status3 == 0) {
- String result3 = j3.optString("Result");
- JSONArray resultArray = new JSONArray(result3);
- if (resultArray != null && resultArray.length() > 0) {
- sendOutList = new ArrayList<SendOutModel>();
- for (int i = 0; i < resultArray.length(); i++) {
- JSONObject resultObj = (JSONObject) resultArray.opt(i);
- int dictionaryId = resultObj.optInt("DICTIONARYID");
- String dictionaryValue = resultObj.optString("DICTIONARYVALUE");
- SendOutModel sendOutModel = new SendOutModel();
- sendOutModel.setSendOutId(String.valueOf(dictionaryId));
- sendOutModel.setSendOutName(dictionaryValue);
- sendOutList.add(sendOutModel);
- }
- sendOutAdapter = new SendOutSpinnerAdapter(SendOutGoods.this, sendOutList);
- sendOutSpinner.setAdapter(sendOutAdapter);
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- break;
- case 4:
- Bundle b3r = msg.getData();
- String json3r = b3r.getString("receiveResult");
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- mHandler.getLooper().quit();
- }
- JSONObject j2r;
- try {
- j2r = new JSONObject(json3r);
- JSONObject j3 = j2r.optJSONObject("d");
- int status3 = j3.optInt("Status");
- if (status3 == 0) {
- String result3 = j3.optString("Result");
- JSONArray resultArray = new JSONArray(result3);
- if (resultArray != null && resultArray.length() > 0) {
- receiveList = new ArrayList<ReceiveModel>();
- for (int i = 0; i < resultArray.length(); i++) {
- JSONObject resultObj = (JSONObject) resultArray.opt(i);
- int dictionaryId = resultObj.optInt("DICTIONARYID");
- String dictionaryValue = resultObj.optString("DICTIONARYVALUE");
- ReceiveModel receiveModel = new ReceiveModel();
- receiveModel.setReceiveId(String.valueOf(dictionaryId));
- receiveModel.setReceiveName(dictionaryValue);
- receiveList.add(receiveModel);
- }
- receiveAdapter = new ReceiveSpinnerAdapter(SendOutGoods.this, receiveList);
- receiveSpinner.setAdapter(receiveAdapter);
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- break;
- case 5:
- Bundle b3c = msg.getData();
- String json3c = b3c.getString("carBrandResult");
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- mHandler.getLooper().quit();
- }
- JSONObject j2c;
- try {
- j2c = new JSONObject(json3c);
- JSONObject j3 = j2c.optJSONObject("d");
- int status3 = j3.optInt("Status");
- if (status3 == 0) {
- String result3 = j3.optString("Result");
- JSONArray resultArray = new JSONArray(result3);
- if (resultArray != null && resultArray.length() > 0) {
- carBrandList = new ArrayList<CarBrandModel>();
- for (int i = 0; i < resultArray.length(); i++) {
- JSONObject resultObj = (JSONObject) resultArray.opt(i);
- int dictionaryId = resultObj.optInt("DICTIONARYID");
- String dictionaryValue = resultObj.optString("DICTIONARYVALUE");
- CarBrandModel carBrandModel = new CarBrandModel();
- carBrandModel.setCarBrandId(String.valueOf(dictionaryId));
- carBrandModel.setCarBrandName(dictionaryValue);
- carBrandList.add(carBrandModel);
- }
- carBrandAdapter = new CarBrandSpinnerAdapter(SendOutGoods.this, carBrandList);
- carBrandSpinner.setAdapter(carBrandAdapter);
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- break;
- case 10:
- ProcessDialogUtils.closeProgressDilog();
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- mHandler.getLooper().quit();
- }
- Bundle bundle10 = msg.getData();
- String json10 = bundle10.getString("result");
- try {
- JSONObject jObject10 = new JSONObject(json10);
- JSONObject object = (JSONObject) jObject10.opt("d");
- int status = object.optInt("Status");
- String message = object.optString("Message");
- if (status == 0) {
- String result = object.optString("Result");
- JSONArray jArr = new JSONArray(result);
- storageJArray=(JSONArray)jArr.opt(0);
- JSONArray jArray = (JSONArray)jArr.opt(1);
- barcodeList.removeAll(barcodeList);
- if (jArray != null && jArray.length() > 0) {
- for (int i = 0; i < jArray.length(); i++) {
- JSONObject object2 = (JSONObject) jArray.opt(i);
- String barcode = object2.optString("BANMA");
- String goodsCode = object2.optString("GOODSCODE");
- String LogoCode = object2.optString("MATERIALCODE");
- // groutingDate = CommonUtil.commonDateConverter(groutingDate);
- String LogoName = object2.optString("MATERIALREMARK");
- // String userCode = object2.optString("USERCODE");
- String orderNo =String.valueOf((int) Double.parseDouble(object2.optString("COUNT")));
- BarcodeInfo barcodeInfo = new BarcodeInfo();
- barcodeInfo.setBanMa(barcode==null||barcode.equals("null")?"":barcode);
- barcodeInfo.setGoodsCode(goodsCode);
- barcodeInfo.setLogoCode(LogoCode);
- barcodeInfo.setLogoName(LogoName);
- // barcodeInfo.setUserCode(userCode);
- barcodeInfo.setOrderNo(orderNo);
- barcodeInfo.setFinishedBarCode(object2.optString("FINISHEDLOADBATCHNO"));
- barcodeList.add(barcodeInfo);
- }
- }
- if (adapter == null) {
- adapter = new SendOutGoodsListMessageAdapter(SendOutGoods.this, barcodeList);
- messageLst.setAdapter(adapter);
- } else {
- adapter.notifyDataSetChanged();
- }
- messageLst.getLayoutParams().height=(barcodeList.size()*Height);
- saveBtn.setText("保存(" + barcodeList.size() + ")");
- barcodeEdt.setEnabled(true);
- barcodeEdt.setText("");
- barcodeEdt.setFocusable(true);
- barcodeEdt.setFocusableInTouchMode(true);
- barcodeEdt.requestFocus();
- barcodeEdt.findFocus();
- isFirst=false;
- barcodeEdt.setFilters(new InputFilter[] { new InputFilter() {
- @Override
- public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
- int dstart, int dend) {
- return null;
- }
- } });
- if(IsSYNCSTATUS.equals("1"))
- {
- barcodeEdt.setEnabled(false);
- saveBtn.setEnabled(false);
- //sendOutSpinner.setSpinnerMode(DialogFragment.MODE_DIALOG);
- }
- CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
- // InputMethodManager im = (InputMethodManager) barcodeEdt
- // .getContext().getSystemService(
- // Context.INPUT_METHOD_SERVICE);
- // im.hideSoftInputFromWindow(ProductSuspendActivity.this
- // .getCurrentFocus().getWindowToken(),
- // InputMethodManager.HIDE_NOT_ALWAYS);
- ProcessDialogUtils.closeProgressDilog();
- }
- //else {
- // CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
- // CommonUtil.showBarCodeAlertDialog(status, message, SendOutGoods.this, barcodeEdt, null, null);
- // return;
- //}
- } catch (JSONException e) {
- e.printStackTrace();
- }
- break;
- }
- }
- };
- public void initProcedurePopWindow(boolean[] bool) {
- mMultiChoicePopWindow = new MultiChoiceProcedurePopWindow(this, mRootView, procedureList, bool);
- mMultiChoicePopWindow.setTitle("工序列表");
- mMultiChoicePopWindow.setOnOKButtonListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- selItems = mMultiChoicePopWindow.getSelectItem();
- booleansTemp = selItems.clone();
- checkedProcedureList = new ArrayList<Procedure>();
- StringBuffer stringBuffer = new StringBuffer();
- if (selItems != null && selItems.length > 0) {
- int size = selItems.length;
- stringBuffer.append("【");
- for (int i = 0; i < size; i++) {
- if (selItems[i]) {
- stringBuffer.append(procedureList.get(i).getProcedureName());
- stringBuffer.append("、");
- checkedProcedureList.add(procedureList.get(i));
- }
- }
- if (checkedProcedureList != null && checkedProcedureList.size() > 0) {
- String procedure = stringBuffer.toString();
- if (procedure.length() > 0) {
- procedure = procedure.substring(0, procedure.length() - 1);
- StringBuffer procedureStringBuffer = new StringBuffer();
- procedureStringBuffer.append(procedure);
- procedureStringBuffer.append("】");
- procedure = procedureStringBuffer.toString();
- procedureTv.setText(procedure);
- }
- } else {
- checkedProcedureList = null;
- procedureTv.setText("");
- }
- }
- }
- });
- mMultiChoicePopWindow.setOnCancelButtonListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (booleansTemp != null && booleansTemp.length > 0) {
- booleans = booleansTemp.clone();
- }
- }
- });
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.product_suspend, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- }
|