|
@@ -0,0 +1,1086 @@
|
|
|
|
|
+package com.jiaju.activity;
|
|
|
|
|
+
|
|
|
|
|
+import java.lang.reflect.InvocationTargetException;
|
|
|
|
|
+import java.lang.reflect.Method;
|
|
|
|
|
+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.adapter.FactoryTransferInListMessageAdapter;
|
|
|
|
|
+import com.jiaju.adapter.SendOutSpinnerAdapter;
|
|
|
|
|
+import com.jiaju.model.BarcodeInfo;
|
|
|
|
|
+import com.jiaju.model.CarBrandModel;
|
|
|
|
|
+import com.jiaju.model.Procedure;
|
|
|
|
|
+import com.jiaju.model.ReceiveModel;
|
|
|
|
|
+import com.jiaju.model.SendOutModel;
|
|
|
|
|
+import com.jiaju.net.WebClient;
|
|
|
|
|
+import com.jiaju.utils.CommonUtil;
|
|
|
|
|
+import com.jiaju.utils.Constants;
|
|
|
|
|
+import com.jiaju.utils.CustomToast;
|
|
|
|
|
+import com.jiaju.utils.MultiChoiceProcedurePopWindow;
|
|
|
|
|
+import com.jiaju.utils.ProcessDialogUtils;
|
|
|
|
|
+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.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.widget.AdapterView;
|
|
|
|
|
+import android.widget.Button;
|
|
|
|
|
+import android.widget.EditText;
|
|
|
|
|
+import android.widget.ImageButton;
|
|
|
|
|
+import android.widget.ListView;
|
|
|
|
|
+import android.widget.Spinner;
|
|
|
|
|
+import android.widget.TextView;
|
|
|
|
|
+import android.widget.Toast;
|
|
|
|
|
+
|
|
|
|
|
+//
|
|
|
|
|
+public class FactoryTransferInActivity 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 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 Spinner sendOutSpinner;
|
|
|
|
|
+ private SendOutModel sendOutModel;
|
|
|
|
|
+ private SendOutModel lastSendOutModel;
|
|
|
|
|
+ private String desc;
|
|
|
|
|
+ private SendOutSpinnerAdapter sendOutAdapter;
|
|
|
|
|
+ private Handler barcodeUpperH = new Handler();
|
|
|
|
|
+ private FactoryTransferInListMessageAdapter adapter;
|
|
|
|
|
+ private boolean isCancel = false;
|
|
|
|
|
+ private boolean isFirst = true;
|
|
|
|
|
+ private String IsSYNCSTATUS = "0";
|
|
|
|
|
+ private int Height = 188;
|
|
|
|
|
+ private String DATAKEY = "";
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
|
|
+ setContentView(R.layout.activity_factory_transfer_in);
|
|
|
|
|
+ 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>();
|
|
|
|
|
+ initView();
|
|
|
|
|
+ IsSYNCSTATUS = this.getIntent().getStringExtra("SYNCSTATUS");
|
|
|
|
|
+ if (IsSYNCSTATUS == null || IsSYNCSTATUS.equals("")) {
|
|
|
|
|
+ IsSYNCSTATUS = "0";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ procedureTv.setText(send_userCode);
|
|
|
|
|
+ allListeners();
|
|
|
|
|
+
|
|
|
|
|
+ thread = new HandlerThread("sendOutThread3", 5);
|
|
|
|
|
+ thread.start();
|
|
|
|
|
+ mHandler = new Handler(thread.getLooper());
|
|
|
|
|
+ SendOutRunnable glazeRunnable = new SendOutRunnable(obj);
|
|
|
|
|
+ mHandler.post(glazeRunnable);
|
|
|
|
|
+ updateDataKey();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** 更新唯一标识 */
|
|
|
|
|
+ private void updateDataKey() {
|
|
|
|
|
+ // 获取当前时间戳
|
|
|
|
|
+ long timestamp = new Date().getTime();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取TextView文本内容
|
|
|
|
|
+ String text = procedureTv.getText().toString();
|
|
|
|
|
+
|
|
|
|
|
+ // 拼接字符串
|
|
|
|
|
+ DATAKEY = timestamp + "-" + text;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private class SendOutRunnable implements Runnable {
|
|
|
|
|
+ private Object object;
|
|
|
|
|
+
|
|
|
|
|
+ public SendOutRunnable(Object object) {
|
|
|
|
|
+ this.object = object;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ synchronized (object) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ ProcessDialogUtils.showProcessDialog(FactoryTransferInActivity.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", "TPC033");
|
|
|
|
|
+ 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() {
|
|
|
|
|
+
|
|
|
|
|
+ backbtn.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ finish();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ backtext.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ finish();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ 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(FactoryTransferInActivity.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(FactoryTransferInActivity.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(FactoryTransferInActivity.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, FactoryTransferInActivity.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.fatory_transfer_in);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private class SaveRunnable implements Runnable {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ client = new WebClient();
|
|
|
|
|
+ try {
|
|
|
|
|
+ JSONObject js = new JSONObject();
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject js6 = new JSONObject();
|
|
|
|
|
+ js6.put("USERCODE", send_userCode);
|
|
|
|
|
+ js6.put("DATAKEY", DATAKEY);
|
|
|
|
|
+
|
|
|
|
|
+ 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());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ 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", "DockingLuoci");
|
|
|
|
|
+ js5.put("action", "SaveDockingLuoci");
|
|
|
|
|
+ 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", "DockingLuoci");
|
|
|
|
|
+ js.put("action", "CheckDockingLuoci");
|
|
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
|
|
+ data.put("barcode", barcode);
|
|
|
|
|
+ SendOutModel model = (SendOutModel) sendOutSpinner.getSelectedItem();
|
|
|
|
|
+ data.put("workshop", model.getSendOutId());
|
|
|
|
|
+ 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, FactoryTransferInActivity.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().equals(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库存
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean a = false;
|
|
|
|
|
+ if ((Double.parseDouble(Count)) > (double) (storageConout - mcount)) {
|
|
|
|
|
+ a = !a;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (status == 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;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!a) {
|
|
|
|
|
+ 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 (a) {
|
|
|
|
|
+ // CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
|
|
|
|
|
+ CommonUtil.showBarCodeAlertDialog(0, "库存不足", FactoryTransferInActivity.this, barcodeEdt,
|
|
|
|
|
+ null, null);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (adapter == null) {
|
|
|
|
|
+ adapter = new FactoryTransferInListMessageAdapter(FactoryTransferInActivity.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 = message;
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
|
|
|
|
|
+ CommonUtil.showBarCodeAlertDialog(0, message, FactoryTransferInActivity.this, barcodeEdt, null,
|
|
|
|
|
+ null);
|
|
|
|
|
+ return;
|
|
|
|
|
+ } else if (status == -102) {
|
|
|
|
|
+ message = "此产品未交接,不能进行该操作";
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
|
|
|
|
|
+ CommonUtil.showBarCodeAlertDialog(0, message, FactoryTransferInActivity.this, barcodeEdt, null,
|
|
|
|
|
+ null);
|
|
|
|
|
+ return;
|
|
|
|
|
+ } else if (status == -100) {
|
|
|
|
|
+ message = "此产品已被废弃,不能进行该操作";
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
|
|
|
|
|
+ CommonUtil.showBarCodeAlertDialog(0, message, FactoryTransferInActivity.this, barcodeEdt, null,
|
|
|
|
|
+ null);
|
|
|
|
|
+ return;
|
|
|
|
|
+ } else if (status == -999) {
|
|
|
|
|
+ message = "此产品无效条码,不能进行该操作";
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
|
|
|
|
|
+ CommonUtil.showBarCodeAlertDialog(0, message, FactoryTransferInActivity.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 , FactoryTransferInActivity.this, null, barcodeEdt, 2);
|
|
|
|
|
+// CustomToast.showToast(getApplicationContext(), "成功", 2000);
|
|
|
|
|
+// CommonUtil.playSound(getApplicationContext());
|
|
|
|
|
+ // checkedProcedureList.clear();
|
|
|
|
|
+ // procedureTv.setText("");
|
|
|
|
|
+ // descEdt.setText("");
|
|
|
|
|
+ // desc = "";
|
|
|
|
|
+ // booleans = new boolean[procedureList.size()];
|
|
|
|
|
+ Dialog alertDialog = new AlertDialog.Builder(FactoryTransferInActivity.this).setMessage(message)
|
|
|
|
|
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
+
|
|
|
|
|
+ finish();
|
|
|
|
|
+ }
|
|
|
|
|
+ }).create();
|
|
|
|
|
+ alertDialog.setCanceledOnTouchOutside(false);
|
|
|
|
|
+ alertDialog.show();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
|
|
|
|
|
+ CommonUtil.showSaveAlertDialog(0, message, FactoryTransferInActivity.this, null, barcodeEdt, 2);
|
|
|
|
|
+ updateDataKey();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ } 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(FactoryTransferInActivity.this, sendOutList);
|
|
|
|
|
+ sendOutSpinner.setAdapter(sendOutAdapter);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } 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 FactoryTransferInListMessageAdapter(FactoryTransferInActivity.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,
|
|
|
|
|
+ // FactoryTransferInActivity.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);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|