Преглед изворни кода

包装工序,扫托盘时候检验下,该托盘下有没有产品未交接的
发货单 新增工号+时间戳作为唯一标识

李士越 пре 10 месеци
родитељ
комит
c57e65c4d0
2 измењених фајлова са 99 додато и 16 уклоњено
  1. 69 4
      src/com/jiaju/activity/PieceActivity.java
  2. 30 12
      src/com/jiaju/activity/SendOutGoods.java

+ 69 - 4
src/com/jiaju/activity/PieceActivity.java

@@ -134,8 +134,7 @@ public class PieceActivity extends Activity {
 	private EditText edtBoardCode; // 板码输入框控件
 	private String[] packagProId = { "13", "79", "107" }; // 包装的 页面id
 	private boolean ispackagpage = false;
-	public Button btndelete;
-
+	public Button btndelete; 
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
@@ -665,10 +664,11 @@ public class PieceActivity extends Activity {
 					LogToFile.v("barcode", "addTextChangedListener");
 					if (ispackagpage && (etcode.length() == 8) && !barcode.getText().toString().trim().substring(0, 4).equals("http")) { // 在包装页 等于8的是板码
 						edtBoardCode.setText(etcode);
+						checkbanma(etcode);
 						barcode.setText("");
 					} else {
 						getBindOrChearkCode(etcode);
-
+						
 					}
 
 				}
@@ -712,10 +712,12 @@ public class PieceActivity extends Activity {
 					LogToFile.v("barcode", "setOnEditorActionListener");
 					if (ispackagpage && (etcode.length() == 8)&& !barcode.getText().toString().trim().substring(0, 4).equals("http")) { // 在包装页 等于8的是板码
 						edtBoardCode.setText(etcode);
+						checkbanma(etcode);
 						barcode.setText("");
 					} else {
 						getBindOrChearkCode(etcode);
-
+						
+						
 					}
 				}
 				return false;
@@ -983,6 +985,22 @@ public class PieceActivity extends Activity {
 				}
 				break;
 			// 王英杰 2021年11月22日end。。。。。。。。
+			case 2:
+				try {
+				Bundle b5 = msg.getData();
+				String result5 = b5.getString("worknoResult");
+				JSONObject jo = new JSONObject(result5);
+					JSONObject jobj = jo.optJSONObject("d");
+					int status = jobj.optInt("Status");
+					String message = jobj.optString("Message"); 
+					if(message != null && !message.equals("")) {
+						CommonUtil.showAlertDialog(status, message, PieceActivity.this);
+					}
+				}catch (Exception e) {
+					e.printStackTrace();
+				}
+			break;
+				
 			}
 		}
 	};
@@ -3043,4 +3061,51 @@ public class PieceActivity extends Activity {
 		res.updateConfiguration(config, res.getDisplayMetrics());
 		return res;
 	}
+	/**校验托盘下有没有产品未交接的*/
+	private void checkbanma(String str) {
+		thread = null;
+		thread = new HandlerThread("SavePieceThread", 5);
+		thread.start();
+		mHandler = new Handler(thread.getLooper());
+		ToCheckbanma bindOrChearkCode = new ToCheckbanma(str);
+		mHandler.post(bindOrChearkCode); 
+	}
+	private class ToCheckbanma implements Runnable {
+		String banma;
+
+		public ToCheckbanma(String banma) {
+			this.banma = banma;
+		}
+
+		public ToCheckbanma() {
+		}
+
+		@Override
+		public void run() {
+			try {
+				JSONObject js = new JSONObject();
+				js.put("accountCode", accountCode);
+				js.put("userCode", piece_userCode);
+				js.put("userPassword", userPassword);
+				js.put("sessionKey", sessionKey);
+				js.put("banma", banma);
+				String result = client.doPost("http://" + ServerAddress_ip + ":" + ServerAddress_duankou + Constants.serverAction
+						+ "/CheckBanma",js.toString(), "application/json");
+				Message m = new Message();
+				m.what = 2; 
+				Bundle b = new Bundle();
+				b.putString("worknoResult", result);
+				m.setData(b);
+				handler1.sendMessage(m);
+			} catch (Exception e) {
+				e.printStackTrace();
+				Message m = new Message();
+				Bundle b = new Bundle();
+				b.putString("message", "网络连接异常");
+				m.setData(b);
+				m.what = 1;
+				exceptionHandler.sendMessage(m);
+			}
+		}
+	};
 }

+ 30 - 12
src/com/jiaju/activity/SendOutGoods.java

@@ -146,6 +146,7 @@ public class SendOutGoods extends Activity {
 	private boolean isFirst=true;
 	private String IsSYNCSTATUS="0";
 	private int Height=188;
+	private String DATAKEY="";
 
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
@@ -234,8 +235,19 @@ public class SendOutGoods extends Activity {
 		mHandler = new Handler(thread.getLooper());
 		ReceiveRunnable ReceiveRunnable = new ReceiveRunnable(obj);
 		mHandler.post(ReceiveRunnable);
+		updateDataKey();
 	}
-
+	/**更新唯一标识*/
+	private void updateDataKey() {
+        // 获取当前时间戳
+        long timestamp = new Date().getTime();
+        
+        // 获取TextView文本内容
+        String text = procedureTv.getText().toString();
+        
+        // 拼接字符串
+        DATAKEY = timestamp + "-" + text;
+    }
 	 //protected void onResume() {
 	   //     super.onResume();
 	        // 如果值已经在onCreate()中加载完成,可以在这里直接调用方法
@@ -862,7 +874,7 @@ public class SendOutGoods extends Activity {
 				JSONObject js6 = new JSONObject();
 				js6.put("SENDOUTCODE", sendOutGoodLogId);
 				js6.put("USERCODE", send_userCode);			
-				
+				js6.put("DATAKEY", DATAKEY);		
 				if(TextView04.getText()== null|| TextView04.getText().toString()== "")
 				{
 					CustomToast.showToast(getApplicationContext(), "记账日期不能为空",
@@ -1126,13 +1138,11 @@ public class SendOutGoods extends Activity {
 
 							}
 						} 
+						boolean a=false;
 						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) {
+							a=!a;
+						} 
+							if (status==0) { 
 								for (int i = 0; i < jArray.length(); i++) {
 									JSONObject object2 = (JSONObject) jArray.opt(i);
 									String barcode = object2.optString("BANMA");
@@ -1150,7 +1160,8 @@ public class SendOutGoods extends Activity {
 										CustomToast.showToast(getApplicationContext(), "条码重复", 2000);
 
 										break; 
-									}
+									} 
+									if (!a) {
 									BarcodeInfo barcodeInfo = new BarcodeInfo();
 									barcodeInfo.setBanMa(barcode=="null"?"":barcode);
 									barcodeInfo.setGoodsCode(goodsCode);
@@ -1159,7 +1170,13 @@ public class SendOutGoods extends Activity {
 									barcodeInfo.setOrderNo(String.valueOf(orderNo));
 									barcodeInfo.setFinishedBarCode(object2.optString("FINISHEDLOADBATCHNO"));//判断是否重复
 									barcodeList.add(barcodeInfo);
-								}
+								}}
+								if (a) {
+									//CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
+									CommonUtil.showBarCodeAlertDialog(0, "库存不足", SendOutGoods.this, barcodeEdt, null,
+											null);
+									return;
+								} 
 								if (adapter == null) {
 									adapter = new SendOutGoodsListMessageAdapter(SendOutGoods.this, barcodeList);
 									messageLst.setAdapter(adapter);
@@ -1193,7 +1210,7 @@ public class SendOutGoods extends Activity {
 								// InputMethodManager.HIDE_NOT_ALWAYS);
 								ProcessDialogUtils.closeProgressDilog();
 
-							}
+							 
 						}
 					} else if (status==-1)					
 					{
@@ -1281,7 +1298,8 @@ public class SendOutGoods extends Activity {
 
 					} else{	
 						CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
-						CommonUtil.showSaveAlertDialog(0,message , SendOutGoods.this, null, barcodeEdt, 2);					
+						CommonUtil.showSaveAlertDialog(0,message , SendOutGoods.this, null, barcodeEdt, 2);	
+						updateDataKey();
 						
 					} 
 				} catch (JSONException e) {