Răsfoiți Sursa

SAP交接(暂存成品)

姜永辉 5 luni în urmă
părinte
comite
0b89bc6b7a

+ 4 - 0
AndroidManifest.xml

@@ -802,6 +802,10 @@
             android:name=".FactoryTransferInActivity"
             android:label="@string/title_activity_factory_transfer_in" >
         </activity>
+        <activity
+            android:name=".SapFinishedProductHandOverActivity"
+            android:label="@string/title_activity_sap_finished_product_hand_over" >
+        </activity>
     </application>
 
 </manifest>

+ 44 - 0
res/layout/activity_sap_finished_product_hand_over.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/parentRel"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/background" >
+
+    <include
+        android:id="@+id/titleset"
+        layout="@layout/fragment_title" />
+      <RelativeLayout
+        android:id="@+id/bottomLay"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true" >
+
+        <Button
+            android:id="@+id/saveBtn"
+            android:layout_width="fill_parent"
+            android:layout_height="45dp"
+            android:background="@drawable/login_btn_selector"
+            android:text="保存 "
+            android:textColor="@color/white"
+            android:textSize="@dimen/textsize_24" />
+    </RelativeLayout>
+
+            <LinearLayout
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/titleset"
+                android:layout_above="@id/bottomLay"
+                android:orientation="vertical" >
+
+                  <ListView
+                    android:id="@+id/handoverlst"
+                    android:layout_width="fill_parent"
+                    android:listSelector="#00000000"
+                     android:cacheColorHint="#00000000"
+                    android:layout_height="fill_parent"
+                    android:divider="@null" />
+            </LinearLayout>
+
+
+</RelativeLayout>

+ 151 - 0
res/layout/sap_finished_product_handover_head_view.xml

@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+
+     
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal" >
+
+        <com.jiaju.widget.JustifyTextView
+            android:id="@+id/orderTitle"
+            android:layout_width="80dp"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="10dp"
+            android:layout_marginTop="10dp"
+            android:text="生产订单"
+            android:textColor="@color/white"
+            android:textSize="@dimen/textsize_16" />
+
+        <TextView
+            android:id="@+id/symbol3"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerVertical="true"
+            android:layout_marginTop="10dp"
+            android:text=":"
+            android:textColor="@color/white"
+            android:textSize="@dimen/textsize_16" />
+
+        <LinearLayout
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="5dp"
+            android:orientation="vertical" >
+
+            <EditText
+                android:id="@+id/orderEdt"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="10dp"
+                android:background="@null"
+                android:imeOptions="actionGo"
+                android:singleLine="true"
+                android:text=""
+                android:textColor="@color/white"
+                android:textSize="@dimen/textsize_24" />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="1dp"
+                android:background="@color/text_gray" />
+
+            <LinearLayout
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="15dp"
+                android:orientation="vertical" >
+
+                <Spinner
+                    android:id="@+id/orderSpinner"
+                    android:layout_width="fill_parent"
+                    android:layout_height="40dp"
+                    android:layout_marginRight="10dp"
+                    android:background="@drawable/spinner_drop_down" >
+                </Spinner>
+            </LinearLayout>
+        </LinearLayout>
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/barcodelay"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal" >
+
+        <com.jiaju.widget.JustifyTextView
+            android:id="@+id/barcodeTitle"
+            android:layout_width="80dp"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="10dp"
+            android:layout_marginTop="5dp"
+            android:text="包装条码"
+            android:textColor="@color/white"
+            android:textSize="@dimen/textsize_16" />
+
+        <TextView
+            android:id="@+id/symbol1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerVertical="true"
+            android:layout_marginTop="5dp"
+            android:text=":"
+            android:textColor="@color/white"
+            android:textSize="@dimen/textsize_16" />
+
+        <LinearLayout
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical" >
+
+            <EditText
+                android:id="@+id/barcodeEdt"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="10dp"
+                android:background="@null"
+                android:imeOptions="actionGo"
+                android:singleLine="true"
+                android:text=""
+                android:textColor="@color/white"
+                android:textSize="@dimen/textsize_24" />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="1dp"
+                android:background="@color/text_gray" />
+        </LinearLayout>
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/lin3"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="12dp"
+        android:orientation="vertical" >
+
+        <View
+            android:layout_width="fill_parent"
+            android:layout_height="1dp"
+            android:background="@color/text_gray" />
+
+        <TextView
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="10dp"
+            android:layout_marginRight="10dp"
+            android:text="产品信息:"
+            android:textColor="@color/white"
+            android:textSize="@dimen/textsize_16" />
+
+        <View
+            android:layout_width="fill_parent"
+            android:layout_height="1dp"
+            android:background="@color/text_gray" />
+    </LinearLayout>
+
+</LinearLayout>

+ 11 - 0
res/menu/sap_finished_product_hand_over.xml

@@ -0,0 +1,11 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:context="com.jiaju.activity.SapFinishedProductHandOverActivity" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/action_settings"/>
+
+</menu>

+ 1 - 0
res/values/strings.xml

@@ -122,5 +122,6 @@
     <string name="title_activity_naked_porcelain">NakedPorcelainActivity</string>
     <string name="title_activity_send_out_goods">SendOutGoods</string>
     <string name="title_activity_factory_transfer_in">FactoryTransferInActivity</string>
+    <string name="title_activity_sap_finished_product_hand_over">SapFinishedProductHandOverActivity</string>
 
 </resources>

+ 10 - 0
src/com/jiaju/activity/HomeActivity.java

@@ -514,6 +514,16 @@ public class HomeActivity extends Activity {
 								pm1.setProcedureId(i);
 								handoverlist.add(pm1);
 							}
+							// SAP交接(暂存成品)
+							else if (functionCode.equals("062204")) {
+								ProcedureModel pm1 = new ProcedureModel();
+								pm1.setProcedureMenuCode(functionCode);
+								pm1.setProcedureMenuName("SAP交接(暂存成品)");
+								pm1.setProcedureModel("00" + i);
+								pm1.setModelType(i);
+								pm1.setProcedureId(i);
+								handoverlist.add(pm1);
+							}
 
 							else if (functionCode.equals("062203")) {
 

+ 1029 - 0
src/com/jiaju/activity/SapFinishedProductHandOverActivity.java

@@ -0,0 +1,1029 @@
+package com.jiaju.activity;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.jiaju.adapter.HandOverAdapter;
+import com.jiaju.adapter.OrderSpinnerAdapter; 
+import com.jiaju.model.BarcodeInfo;
+import com.jiaju.model.Order;
+import com.jiaju.net.WebClient;
+import com.jiaju.utils.CommonUtil;
+import com.jiaju.utils.Constants;
+import com.jiaju.utils.CustomToast;
+import com.jiaju.utils.ProcessDialogUtils;
+import com.jiaju.utils.Removeduplicate;
+
+import android.app.Activity;
+import android.app.Notification;
+import android.content.Context;
+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.view.KeyEvent;
+import android.view.Menu;
+import android.view.MotionEvent;
+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.ImageView;
+import android.widget.ListView; 
+import android.widget.Spinner;
+import android.widget.TextView;
+//SAP交接(暂存成品)
+public class SapFinishedProductHandOverActivity extends Activity {
+	private TextView tvTitle;
+	private String password;
+	private String sessionkey;
+	private SharedPreferences preferences;
+	private String ServerAddress_ip;
+	private String ServerAddress_port;
+	private String accountCode;
+	private String handover_usercode;
+	private HandlerThread thread;
+	private Handler mHandler;
+	private WebClient client;
+	private List<Order> orderList;
+	private Spinner orderSpinner; 
+	private EditText barcodeEdt;
+	private String barcode;
+	private TextView tvBack;
+	private ImageView ivBack;
+	private Object obj = new Object();
+	private List<BarcodeInfo> barcodeInfoList = new ArrayList<BarcodeInfo>();
+	private ListView barcodeLst;
+	private HandOverAdapter handoverAdapter;
+	private Button saveBtn;
+	private EditText orderEdt; 
+	private Handler barcodeUpperH = new Handler();
+	private String barcodeUpper;  
+	private OrderSpinnerAdapter adapter;  
+	private static final String[] m = {"APP1", "APP2", "APP3"}; 
+	private String spinnerName = "APP2";  
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_sap_finished_product_hand_over);
+		initView(); 
+		preferences = getSharedPreferences("user", Context.MODE_PRIVATE);
+		ServerAddress_ip = preferences.getString("ServerAddress_ip", "");
+		ServerAddress_port = preferences.getString("ServerAddress_duankou", "");
+		accountCode = preferences.getString("AccountCode", "");
+		handover_usercode = preferences.getString("UserCode", "");
+		password = preferences.getString("UserPassword", "");
+		sessionkey = preferences.getString("SessionKey", ""); 
+		 
+		Bundle b = getIntent().getExtras();
+		String title = b.getString("title");
+		tvTitle.setText(title);
+		orderEdt.setFocusable(true);
+		orderEdt.requestFocus();
+		orderEdt.findFocus(); 
+		allListeners();
+		thread = new HandlerThread("trademarkThread", 5);
+		thread.start();
+		mHandler = new Handler(thread.getLooper());
+		OrderListRunnable orderListRunnable = new OrderListRunnable(obj);
+		mHandler.post(orderListRunnable);
+	}
+	 
+	private void initView() {
+		tvTitle = (TextView) findViewById(R.id.title);
+		ivBack = (ImageButton) findViewById(R.id.left_img);
+		tvBack = (TextView) findViewById(R.id.back);
+		View head = View.inflate(this,
+				R.layout.sap_finished_product_handover_head_view, null);
+		orderSpinner = (Spinner) head.findViewById(R.id.orderSpinner); 
+		barcodeEdt = (EditText) head.findViewById(R.id.barcodeEdt);
+		barcodeEdt.setRawInputType(InputType.TYPE_CLASS_NUMBER);
+		barcodeLst = (ListView) findViewById(R.id.handoverlst);
+		barcodeLst.addHeaderView(head, null, false);
+		handoverAdapter = new HandOverAdapter(
+				SapFinishedProductHandOverActivity.this, barcodeInfoList);
+		barcodeLst.setAdapter(handoverAdapter);
+		saveBtn = (Button) findViewById(R.id.saveBtn);
+		orderEdt = (EditText) head.findViewById(R.id.orderEdt); 
+		 
+	}
+	private void allListeners() {
+		ivBack.setOnClickListener(new OnClickListener() {
+			@Override
+			public void onClick(View v) {
+				finish();
+			}
+		});
+		tvBack.setOnClickListener(new OnClickListener() {
+			@Override
+			public void onClick(View v) {
+				finish();
+			}
+		});
+		 
+		orderSpinner.setOnItemSelectedListener(
+				new Spinner.OnItemSelectedListener() {
+					@Override
+					public void onItemSelected(AdapterView<?> arg0, View arg1,
+							int arg2, long arg3) {
+						Order order = (Order) arg0.getItemAtPosition(arg2);
+						String orderNo = order.getOrderNo();
+						int orderId = order.getOrderId();
+						if (orderId == -1) {
+							orderEdt.setText("");
+							orderEdt.setFocusable(true);
+							orderEdt.requestFocus();
+							orderEdt.findFocus();
+						} else {
+							orderEdt.setText(orderNo);
+							barcodeEdt.setFocusable(true);
+							barcodeEdt.requestFocus();
+							barcodeEdt.findFocus();
+						}
+					}
+					@Override
+					public void onNothingSelected(AdapterView<?> arg0) {
+					}
+				});
+		saveBtn.setOnClickListener(new View.OnClickListener() {
+			@Override
+			public void onClick(View v) {
+				Order order = (Order) orderSpinner.getSelectedItem();
+				int orderId;
+				if (order == null) {
+					CustomToast.showToast(getApplicationContext(), "订单不能为空",
+							2000);
+					return;
+				} else {
+					orderId = order.getOrderId();
+					if (orderId == -1) {
+						CustomToast.showToast(getApplicationContext(), "请选择订单",
+								2000);
+						return;
+					}
+				}
+				if (barcodeInfoList == null || barcodeInfoList.size() == 0) {
+					CustomToast.showToast(getApplicationContext(), "条码信息不能为空",
+							2000);
+					return;
+				}
+				ProcessDialogUtils.showProcessDialog(
+						SapFinishedProductHandOverActivity.this);
+				thread = null;
+				thread = new HandlerThread("saveThread", 5);
+				thread.start();
+				mHandler = new Handler(thread.getLooper());
+				SaveRunnable saveRunnable = new SaveRunnable(obj,
+						String.valueOf(orderId));
+				mHandler.post(saveRunnable);
+			}
+		});
+		// orderEdt.setOnFocusChangeListener(new OnFocusChangeListener() {
+		//
+		// @Override
+		// public void onFocusChange(View v, boolean hasFocus) {
+		// if (!hasFocus) {
+		// String order = orderEdt.getText().toString();
+		// if (isOrderTextChange) {
+		// isOrderTextChange = false;
+		// return;
+		// }
+		// if (TextUtils.isEmpty(order)) {
+		// return;
+		// }
+		// if (orderList != null && orderList.size() > 0) {
+		// int orderIndex = getOrderIndex(order, orderList);
+		// if (orderSpinner != null) {
+		// if (orderIndex == -1) {
+		// orderSpinner.setSelection(0);
+		// orderEdt.setText("");
+		//
+		// }
+		//
+		// else {
+		// orderSpinner.setSelection(orderIndex);
+		// Order orderModel = (Order) orderSpinner.getSelectedItem();
+		// orderEdt.setText(orderModel.getOrderNo());
+		//
+		// }
+		//
+		// }
+		// }
+		// }
+		//
+		// }
+		// });
+		orderEdt.setOnEditorActionListener(
+				new TextView.OnEditorActionListener() {
+					@Override
+					public boolean onEditorAction(TextView v, int actionId,
+							KeyEvent event) {
+						if (actionId == EditorInfo.IME_ACTION_GO) {
+							String order = orderEdt.getText().toString();
+							if (!TextUtils.isEmpty(order)) {
+								if (orderList != null && orderList.size() > 0) {
+									int orderIndex = getOrderIndex(order,
+											orderList);
+									if (orderSpinner != null) {
+										if (orderIndex == -1) {
+											orderSpinner.setSelection(0);
+											orderEdt.setText("");
+											orderEdt.setFocusable(true);
+											orderEdt.requestFocus();
+											orderEdt.findFocus();
+											return true;
+										} else {
+											barcodeEdt.requestFocus();
+											barcodeEdt.findFocus();
+											orderSpinner
+													.setSelection(orderIndex);
+											Order orderModel = (Order) orderSpinner
+													.getSelectedItem();
+											orderEdt.setText(
+													orderModel.getOrderNo());
+											return true;
+										}
+									}
+								}
+							}
+						}
+						return false;
+					}
+				});
+		orderEdt.addTextChangedListener(new TextWatcher() {
+			@Override
+			public void afterTextChanged(Editable arg0) {
+			}
+			@Override
+			public void beforeTextChanged(CharSequence s, int start, int count,
+					int after) {
+			}
+			@Override
+			public void onTextChanged(CharSequence s, int start, int before,
+					int count) {
+				if (start == 0 && before == 0 && count > 1) {
+					String order = orderEdt.getText().toString().trim();
+					if (!TextUtils.isEmpty(order)) {
+						if (orderList != null && orderList.size() > 0) {
+							int orderIndex = getOrderIndex(order, orderList);
+							if (orderSpinner != null) {
+								if (orderIndex == -1) {
+									orderSpinner.setSelection(0);
+									orderEdt.setText("");
+									orderEdt.setFocusable(true);
+									orderEdt.requestFocus();
+								} else {
+									barcodeEdt.requestFocus();
+									barcodeEdt.findFocus();
+									orderSpinner.setSelection(orderIndex);
+								}
+							}
+						}
+					}
+				}
+			}
+		});
+		barcodeEdt.addTextChangedListener(new TextWatcher() {
+			@Override
+			public void afterTextChanged(Editable arg0) { 
+				
+				
+			}
+			@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().trim();
+				if(barcodeUpper.length() >= 73)
+				{
+					String[] parts = barcodeUpper.split("-", 2); // 第二个参数限制分割后的数组长度,这里为2  
+					  
+			        if (parts.length == 2) {  
+			            //System.out.println("第一部分: " + parts[0]);  
+			            //System.out.println("第二部分: " + parts[1]);  
+			        	barcodeUpper = parts[1];
+			        }  
+				} 
+				// 判断输入的文字是否是小写
+				for (int i = 0; i < barcodeUpper.length(); i++) {
+					if (barcodeUpper.charAt(i) - 0 >= 97
+							&& barcodeUpper.charAt(i) - 0 <= 122) {
+						barcodeUpperH.postDelayed(UpperCase, 300);
+					}
+				}
+				if (start == 0 && before == 0 && count > 1) {
+					String barcode = barcodeEdt.getText().toString();
+					
+					
+					
+					barcode = barcode.trim();
+					if (!TextUtils.isEmpty(barcode)) {
+					 
+						if(barcode.length() >= 73)
+						{
+							String[] parts = barcode.split("-", 2); // 第二个参数限制分割后的数组长度,这里为2  
+							  
+					        if (parts.length == 2) {  
+					            //System.out.println("第一部分: " + parts[0]);  
+					            //System.out.println("第二部分: " + parts[1]);  
+					            barcode = parts[1];
+					        }  
+						} 
+						ProcessDialogUtils.showProcessDialog(
+								SapFinishedProductHandOverActivity.this);
+						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)
+												: "";
+									}
+								}});
+					
+						thread = new HandlerThread("barcodeThread", 5);
+						thread.start();
+						mHandler = new Handler(thread.getLooper());
+						BarcodeRunnable barcodeRunnable = new BarcodeRunnable(
+								obj, barcode);
+						mHandler.post(barcodeRunnable);
+					}
+				}
+			}
+		});
+		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(); 
+							if (!TextUtils.isEmpty(barcode)) {
+								if(barcode.length() >= 73)
+								{
+									String[] parts = barcode.split("-", 2); // 第二个参数限制分割后的数组长度,这里为2  
+									  
+							        if (parts.length == 2) {  
+							            //System.out.println("第一部分: " + parts[0]);  
+							            //System.out.println("第二部分: " + parts[1]);  
+							            barcode = parts[1];
+							        }  
+								} 
+								ProcessDialogUtils.showProcessDialog(
+										SapFinishedProductHandOverActivity.this);
+								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)
+														: "";
+											}
+										}});
+								thread = new HandlerThread("barcodeThread", 5);
+								thread.start();
+								mHandler = new Handler(thread.getLooper());
+								BarcodeRunnable barcodeRunnable = new BarcodeRunnable(
+										obj, barcode);
+								mHandler.post(barcodeRunnable);
+								return true;
+							}
+						}
+						return false;
+					}
+				});
+	}
+	Runnable UpperCase = new Runnable() {
+		@Override
+		public void run() {
+			// 小写转大写
+			barcodeEdt.setText(barcodeUpper.toUpperCase());
+			// 设置EditText光标位置
+			barcodeEdt.setSelection(barcodeUpper.length());
+		}
+	};
+	public static int getOrderIndex(String order, List<Order> orderList) {
+		int newposition = -1;
+		for (int position = 0; position < orderList.size(); position++) {
+			if (order
+					.equalsIgnoreCase((orderList.get(position).getOrderNo()))) {
+				newposition = position;
+				break;
+			}
+		}
+		return newposition;
+	}
+	private class SaveRunnable implements Runnable {
+		private Object object;
+		private String orderId;
+		public SaveRunnable(Object object, String orderId) {
+			this.object = object;
+			this.orderId = orderId;
+		}
+		@Override
+		public void run() {
+			synchronized (object) {
+				try {
+					client = null;
+					client = new WebClient();
+					JSONObject js = new JSONObject();
+					js.put("accountCode", accountCode);
+					js.put("userCode", handover_usercode);
+					js.put("userPassword", password);
+					js.put("sessionKey", sessionkey);
+					js.put("module", "FinishedProduct");
+					js.put("SPANAME", spinnerName);
+					js.put("action", "SaveFinishedHandoverAgain");
+					JSONArray orderEntity = new JSONArray();
+					for (BarcodeInfo info : barcodeInfoList) {
+						JSONObject obj = new JSONObject();
+						obj.put("BarCode", info.getBarcode());
+						obj.put("GoodsModel", info.getGoodsCode());
+						obj.put("SPANAME", spinnerName);
+						obj.put("logoID", info.getLogoId());
+						obj.put("LogoName", info.getLogoName());
+						orderEntity.put(obj);
+					}
+					JSONObject data = new JSONObject();
+					data.put("OrderID", orderId);
+					data.put("Table", orderEntity);
+					data.put("SPANAME", spinnerName);
+					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 = 3;
+					Bundle b = new Bundle();
+					b.putString("saveResult", 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 BarcodeRunnable implements Runnable {
+		private Object object;
+		private String barcode;
+		public BarcodeRunnable(Object object, String barcode) {
+			this.object = object;
+			this.barcode = barcode;
+		}
+		@Override
+		public void run() {
+			synchronized (object) {
+				try {
+					client = null;
+					client = new WebClient();
+					JSONObject js1 = new JSONObject();
+					js1.put("accountCode", accountCode);
+					js1.put("userCode", handover_usercode);
+					js1.put("userPassword", password);
+					js1.put("sessionKey", sessionkey);
+					JSONObject data = new JSONObject();
+					data.put("Barcode", barcode);
+					js1.put("jsonData", data.toString());
+					js1.put("module", "FinishedProduct");
+					js1.put("action", "FinishedHandoverBarcodeAgain");
+					String result2 = client.doPost(
+							"http://" + ServerAddress_ip + ":"
+									+ ServerAddress_port
+									+ Constants.serverAction + "/DoAction",
+							js1.toString(), "application/json");
+					Bundle b = new Bundle();
+					Message message = new Message();
+					message.what = 1;
+					b.putString("barcode", barcode);
+					b.putString("result", result2);
+					message.setData(b);
+					handler.sendMessage(message);
+				} 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 OrderListRunnable implements Runnable {
+		private Object object;
+		public OrderListRunnable(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", handover_usercode);
+					js.put("userPassword", password);
+					js.put("sessionKey", sessionkey);
+					JSONObject orderEntity = new JSONObject();
+					js.put("order", orderEntity);
+					String result = client.doPost(
+							"http://" + ServerAddress_ip + ":"
+									+ ServerAddress_port
+									+ Constants.serverAction + "/GetOrderList",
+							js.toString(), "application/json");
+					JSONObject j = new JSONObject(result);
+					JSONObject j1 = j.optJSONObject("d");
+					int status = j1.optInt("Status");
+					String message = j1.optString("Message");
+					if (status == 0) {
+						String result1 = j1.optString("Result");
+						JSONArray jarray = new JSONArray(result1);
+						if (jarray != null && jarray.length() > 0) {
+							orderList = new ArrayList<Order>();
+							Order order = new Order();
+							order.setOrderId(-1);
+							order.setOrderNo("请选择订单");
+							orderList.add(order);
+							for (int i = 0; i < jarray.length(); i++) {
+								JSONObject obj = jarray.optJSONObject(i);
+								int orderId = obj.optInt("ORDERID");
+								String orderNo = obj.optString("ORDERNO");
+								String valueFlag = obj.optString("VALUEFLAG");
+								if (valueFlag.equals("1")) {
+									Order order1 = new Order();
+									order1.setOrderId(orderId);
+									order1.setOrderNo(orderNo);
+									orderList.add(order1);
+								}
+							}
+						}
+						// client = null;
+						// client = new WebClient();
+						// JSONObject js1 = new JSONObject();
+						// js1.put("accountCode", accountCode);
+						// js1.put("userCode", handover_usercode);
+						// js1.put("userPassword", password);
+						// js1.put("sessionKey", sessionkey);
+						// js1.put("barcode", barcode);
+						// String result2 = client.doPost("http://" +
+						// ServerAddress_ip + ":" + ServerAddress_port
+						// + Constants.serverAction + "/GetSystemData",
+						// js1.toString(), "application/json");
+						// JSONObject jobj = new JSONObject(result2);
+						// JSONObject obj1 = jobj.optJSONObject("d");
+						//
+						// int status1 = obj1.optInt("Status");
+						// String message1 = obj1.optString("Message");
+						// if (status1 == 0) {
+						// String result3 = obj1.optString("Result");
+						// JSONArray jarray1 = new JSONArray(result3);
+						// if (jarray1 != null && jarray1.length() > 0) {
+						// for (int i = 0; i < jarray1.length(); i++) {
+						// JSONObject obj2 = jarray1.optJSONObject(i);
+						// String settingCode = obj2.optString("SETTINGCODE");
+						// String settingValue = obj2.optString("SETTINGVALUE");
+						// if (settingCode.equals("S_PM_011")) {
+						// trademarkSettingValue = settingValue;
+						// }
+						// if (settingCode.equals("S_PM_012")) {
+						// modelSettingValue = settingValue;
+						// }
+						// if (settingCode.equals("S_PM_013")) {
+						// quantitySettingValue = settingValue;
+						// }
+						// }
+						// }
+						Message m = new Message();
+						m.what = 0;
+						Bundle b = new Bundle();
+						b.putSerializable("orderList",
+								(Serializable) orderList);
+						m.setData(b);
+						handler.sendMessage(m);
+						// } else {
+						// Bundle b = new Bundle();
+						// b.putInt("status", status1);
+						// b.putString("message", message1);
+						// Message m = new Message();
+						// m.what = 1;
+						// m.setData(b);
+						// exceptionHandler.sendMessage(m);
+						// return;
+						// }
+					} else {
+						Bundle b = new Bundle();
+						b.putInt("status", status);
+						b.putString("message", message);
+						Message m = new Message();
+						m.what = 1;
+						m.setData(b);
+						exceptionHandler.sendMessage(m);
+						return;
+					}
+				} 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);
+				}
+			}
+		}
+	};
+	Handler exceptionHandler = new Handler() {
+		@Override
+		public void handleMessage(Message msg) {
+			switch (msg.what) {
+				case 0 :
+					Bundle b = msg.getData();
+					String message = b.getString("message");
+					ProcessDialogUtils.closeProgressDilog();
+					if (mHandler != null) {
+						mHandler.removeCallbacksAndMessages(null);
+						mHandler.getLooper().quit();
+					}
+					CustomToast.showToast(getApplicationContext(), message,
+							2000);
+					CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
+							getApplicationContext());
+					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;
+						}
+					}}); 
+					break;
+				case 1 :
+					Bundle b1 = msg.getData();
+					int status1 = b1.getInt("status");
+					String message1 = b1.getString("message");
+					ProcessDialogUtils.closeProgressDilog();
+					if (mHandler != null) {
+						mHandler.removeCallbacksAndMessages(null);
+						mHandler.getLooper().quit();
+					}
+					CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
+							getApplicationContext());
+					CommonUtil.showBarCodeAlertDialog(status1, message1,
+							SapFinishedProductHandOverActivity.this, barcodeEdt,
+							null, null);
+					break;
+			}
+		}
+	};
+	Handler handler = new Handler() {
+		@SuppressWarnings("unchecked")
+		@Override
+		public void handleMessage(Message msg) {
+			switch (msg.what) {
+				case 0 :
+					Bundle b = msg.getData();
+					orderList = (List<Order>) b.getSerializable("orderList");
+					if (mHandler != null) {
+						mHandler.removeCallbacksAndMessages(null);
+						mHandler.getLooper().quit();
+					}
+					ProcessDialogUtils.closeProgressDilog();
+					orderEdt.setEnabled(true);
+					orderEdt.setFocusable(true);
+					orderEdt.setFocusableInTouchMode(true);
+					orderEdt.setFilters(new InputFilter[]{new InputFilter() {
+						@Override
+						public CharSequence filter(CharSequence source,
+								int start, int end, Spanned dest, int dstart,
+								int dend) {
+							return null;
+						}
+					}});
+					if (orderList != null && orderList.size() > 0) {
+						adapter = new OrderSpinnerAdapter(
+								SapFinishedProductHandOverActivity.this,
+								orderList);
+						orderSpinner.setAdapter(adapter);
+					}
+					// if (quantitySettingValue.equals("0")) {
+					// saveBtn.setEnabled(true);
+					// }
+					break;
+				case 1 :
+					ProcessDialogUtils.closeProgressDilog();
+					if (mHandler != null) {
+						mHandler.removeCallbacksAndMessages(null);
+						mHandler.getLooper().quit();
+					}
+					Bundle b1 = msg.getData();
+					String result1 = b1.getString("result");
+					barcode = b1.getString("barcode");
+					JSONObject jobj2;
+					try {
+						jobj2 = new JSONObject(result1);
+						JSONObject jobj3 = jobj2.optJSONObject("d");
+						int status3 = jobj3.optInt("Status");
+						if (status3 == 0) {
+							String result4 = jobj3.optString("Result");
+							JSONObject jobj4 = new JSONObject(result4);
+							JSONArray arry4 = jobj4.optJSONArray("Table");
+							if (arry4 != null && arry4.length() > 0) {
+								JSONObject jobj6 = arry4.optJSONObject(0);
+								String outbarcode = jobj6.optString("BARCODE");
+								if (barcodeInfoList.size() > 0) {
+									boolean b2 = Removeduplicate.removeBarCode(
+											outbarcode, barcodeInfoList);
+									if (b2) {
+										String message = "条码" + outbarcode
+												+ "重复";
+										CustomToast.showToast(
+												getApplicationContext(),
+												message, 2000);
+										CommonUtil.setDefault(
+												Notification.DEFAULT_VIBRATE,
+												getApplicationContext());
+										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;
+													}
+												}}); 
+										return;
+									}
+								}
+								for (int i = 0; i < arry4.length(); i++) {
+									JSONObject jobj5 = arry4.optJSONObject(i);
+									int logoId = jobj5.optInt("LOGOID");
+									String logoCode = jobj5
+											.optString("LOGOCODE");
+									String logoName = jobj5
+											.optString("LOGONAME");
+									String goodsCode = jobj5
+											.optString("GOODSCODE");
+									String finishedBarCode = jobj5
+											.optString("FINISHEDBARCODE");
+									String outbarcode1 = jobj5
+											.optString("BARCODE");
+									int userId = jobj5.optInt("USERID");
+									String groutingUserCode = jobj5
+											.optString("GROUTINGUSERCODE");
+									String mouldCode = jobj5
+											.optString("MOULDCODE");
+									String groutingDate = jobj5
+											.optString("GROUTINGDATE");
+									groutingDate = CommonUtil
+											.commonDateConverter(groutingDate);
+									String diliverTime = jobj5
+											.optString("DELIVERTIME");
+									String goodsModel = jobj5
+											.optString("GOODSMODEL");
+									diliverTime = CommonUtil
+											.commonDateConverter(diliverTime);
+									// limitNum = jobj5.optInt("PLATELIMITNUM");
+									BarcodeInfo info = new BarcodeInfo();
+									info.setBarcode(outbarcode1);
+									info.setLogoId(logoId);
+									info.setLogoCode(logoCode);
+									info.setFinishedBarCode(finishedBarCode);
+									info.setLogoName(logoName);
+									info.setGoodsCode(goodsCode);
+									info.setGoodsModel(goodsModel);
+									info.setUserId(userId);
+									info.setUserCode(groutingUserCode);
+									info.setMouldCode(mouldCode);
+									info.setGroutingDate(groutingDate);
+									info.setDeliverTime(diliverTime);
+									info.setBanMa(
+											(jobj5.optString("BANMA") == "null")
+													? ""
+													: jobj5.optString("BANMA"));
+								 
+									barcodeInfoList.add(info);
+								}
+								if (handoverAdapter == null) {
+									handoverAdapter = new HandOverAdapter(
+											SapFinishedProductHandOverActivity.this,
+											barcodeInfoList);
+									barcodeLst.setAdapter(handoverAdapter);
+								 
+								} else {
+									handoverAdapter.notifyDataSetChanged();
+								}
+							 
+								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;
+											}
+										}}); 
+							}
+						} else {
+							String message = jobj3.optString("Message");
+							CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
+									getApplicationContext());
+							CommonUtil.showBarCodeAlertDialog(status3, message,
+									SapFinishedProductHandOverActivity.this,
+									barcodeEdt, null, null);
+							return;
+						}
+						saveBtn.setText("保存(" + barcodeInfoList.size() + ")");
+					} catch (JSONException e1) {
+						e1.printStackTrace();
+					}
+					break;
+				case 2 :
+					ProcessDialogUtils.closeProgressDilog();
+					if (mHandler != null) {
+						mHandler.removeCallbacksAndMessages(null);
+						mHandler.getLooper().quit();
+					}
+					Bundle b2 = msg.getData();
+					String errmsg = b2.getString("msg");
+					String missFlag = b2.getString("missingFlag");
+					Intent intent = new Intent();
+					Bundle b3 = new Bundle();
+					b3.putString("msg", errmsg);
+					b3.putString("missingFlag", missFlag);
+					intent.putExtras(b3);
+					intent.setClass(SapFinishedProductHandOverActivity.this,
+							MissingScanActivity.class);
+					startActivityForResult(intent, 101);
+					break;
+				case 3 :
+					Bundle b4 = msg.getData();
+					String result3 = b4.getString("saveResult");
+					if (mHandler != null) {
+						mHandler.removeCallbacksAndMessages(null);
+						mHandler.getLooper().quit();
+					}
+					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;
+						}
+					}});
+					try {
+						JSONObject jo = new JSONObject(result3);
+						JSONObject jo1 = jo.optJSONObject("d");
+						int status = jo1.optInt("Status");
+						String message = jo1.optString("Message");
+						if (status == 0) {
+							CustomToast.showToast(getApplicationContext(),
+									"保存成功", 2000);
+							// if (quantitySettingValue.equals("0")) {
+							// saveBtn.setEnabled(true);
+							//
+							// } else {
+							// saveBtn.setEnabled(false);
+							//
+							// }
+							orderEdt.setText("");
+							if (handoverAdapter != null) {
+								barcodeInfoList.removeAll(barcodeInfoList);
+								handoverAdapter.notifyDataSetChanged();
+								saveBtn.setText(
+										"保存(" + barcodeInfoList.size() + ")");
+							}
+							CommonUtil.playSound(getApplicationContext());
+						} else {
+							CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
+									getApplicationContext());
+							CommonUtil.showBarCodeAlertDialog(status, message,
+									SapFinishedProductHandOverActivity.this,
+									barcodeEdt, null, null);
+						}
+					} catch (JSONException e) {
+						e.printStackTrace();
+					}
+					break;
+			}
+		}
+	};
+	@Override
+	public boolean dispatchTouchEvent(MotionEvent ev) {
+		switch (ev.getAction()) {
+			case MotionEvent.ACTION_DOWN :
+				View view = getCurrentFocus();
+				CommonUtil.hideKeyboard(ev, view,
+						SapFinishedProductHandOverActivity.this);// 调用方法判断是否需要隐藏键盘
+				break;
+			default :
+				break;
+		}
+		return super.dispatchTouchEvent(ev);
+	}
+	@Override
+	protected void onActivityResult(int requestCode, int resultCode,
+			Intent intent) {
+		if (requestCode == 101 && resultCode == 103) {
+			orderEdt.setEnabled(true);
+			orderEdt.setFocusable(true);
+			orderEdt.setFocusableInTouchMode(true);
+			orderEdt.setFilters(new InputFilter[]{new InputFilter() {
+				@Override
+				public CharSequence filter(CharSequence source, int start,
+						int end, Spanned dest, int dstart, int dend) {
+					return null;
+				}
+			}});
+			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;
+				}
+			}}); 
+		}
+	}
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		getMenuInflater().inflate(R.menu.finished_product_handover, menu);
+		return true;
+	}
+}

+ 10 - 0
src/com/jiaju/adapter/ProductLineExpandableListView.java

@@ -77,6 +77,7 @@ import com.jiaju.activity.R;
 import com.jiaju.activity.RecheckRegisterActivity;
 import com.jiaju.activity.RecoveryBarcodeActivity;
 import com.jiaju.activity.RecycleActivity;
+import com.jiaju.activity.SapFinishedProductHandOverActivity;
 import com.jiaju.activity.SecurityCodeChangeActivity;
 import com.jiaju.activity.SemiCheckDataStatisticsActivity;
 import com.jiaju.activity.SemiCheckModifyActivity;
@@ -1270,6 +1271,15 @@ public class ProductLineExpandableListView extends ExpandableListView
 			i.setClass(mContext, CancelFinishedProductHandOverActivity.class);
 			mContext.startActivity(i);
 
+		} 
+		else if (procedureMenuCode.equals("062204")) {
+			Intent i = new Intent();
+			Bundle b = new Bundle();
+			b.putString("title", "SAP交接(暂存成品)");
+			i.putExtras(b);
+			i.setClass(mContext, SapFinishedProductHandOverActivity.class);
+			mContext.startActivity(i);
+
 		} else if (procedureMenuCode.equals("06200301")) {// 成检登记
 			Intent i = new Intent();
 			Bundle b = new Bundle();