public HttpResponseBase GETMarkTallyWD() { StringBuilder sb = new StringBuilder(); string json = String.Empty; AseldQuery m = new AseldQuery(); List<AseldQuery> list = new List<AseldQuery>(); _iasdMgr = new AseldMgr(mySqlConnectionString); int flag = 2; int try1 = 0; try { m.seld_id = Int32.Parse(Request.Params["seld_id"]);//aseld的流水號 m.commodity_type = Request.Params["commodity_type"];//獲取寄倉2和調度3 m.ord_qty = Int32.Parse(Request.Params["ord_qty"]);//需要訂貨數量 if (Int32.TryParse(Request.Params["act_pick_qty"], out try1)) { m.act_pick_qty = Int32.Parse(Request.Params["act_pick_qty"]); } else { m.act_pick_qty = 0; } m.item_id = uint.Parse(Request.Params["item_id"]); m.out_qty = Int32.Parse(Request.Params["out_qty"]) - m.act_pick_qty;//缺貨數量 m.act_pick_qty = m.ord_qty - m.out_qty; m.complete_dtim = DateTime.Now; m.assg_id = Request.Params["assg_id"]; m.ord_id = Int32.Parse(Request.Params["ord_id"]); m.ordd_id = int.Parse(Request.Params["ordd_id"]);//商品細項編號。操作iwms_record需要 m.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; m.deliver_code = Request.Params["deliver_id"]; m.deliver_id = int.Parse(m.deliver_code.Substring(1, m.deliver_code.Length - 1).ToString()); if (m.out_qty == 0) {//揀完了,判斷缺貨數量是否為0 m.wust_id = "COM"; } else {//沒拿夠貨物 m.wust_id = "SKP"; } sb.Append(_iasdMgr.UpdAseld(m)); if (m.commodity_type == "2") { #region 寄倉--對庫存進行操作 Dictionary<string, string> dickuCun = new Dictionary<string, string>(); if (Int32.TryParse(Request.Params["act_pick_qty"], out try1)) { if (!string.IsNullOrEmpty(Request.Params["pickRowId"])) { string[] iinvd = Request.Params["pickRowId"].Split(','); string[] pick = Request.Params["pickInfo"].Split(','); for (int i = 0; i < iinvd.Length; i++) { if (!dickuCun.Keys.Contains(iinvd[i])) { dickuCun.Add(iinvd[i], pick[i]); } else { dickuCun[iinvd[i]] = pick[i]; } } } } if (!string.IsNullOrEmpty(_iasdMgr.updgry(m, dickuCun))) { sb.Append(_iasdMgr.updgry(m, dickuCun)); } if (!string.IsNullOrEmpty(sb.ToString())) { _iasdMgr.InsertSql(sb.ToString());//執行SQL語句裡面有事物處理 } int ord = 1; int cancel = 0; int ord_id = 0; #region 判斷項目狀態 if (_iasdMgr.SelCom(m) == 0) { ord = 0; ord_id = m.ord_id; //訂單揀貨完成,可以封箱 } if (_iasdMgr.SelComA(m) == 0) { flag = 0;//項目訂單揀貨完成 } if (ord == 0) {//有沒有臨時取消的商品 if (_iasdMgr.SelComC(m) > 0) { cancel = 1; ord_id = m.ord_id; } } #endregion json = "{success:true,qty:'" + m.out_qty + "',flag:'" + flag + "',ord:'" + ord + "',cancel:'" + cancel + "',ord_id:'" + ord_id + "'}";//返回json數據 //qty 該物品是否缺貨,如果為零揀貨完成,否則彈框提示缺貨數量。 //over:0表示該訂單已經揀貨完畢,如果qty為零則提示該訂單可以封箱,qty不為零則提示該訂單還缺物品的數量。不為零則不提示任何信息。 #endregion } else if (m.commodity_type == "3") { #region 調度--對庫存進行操作 m.change_user = int.Parse((Session["caller"] as Caller).user_id.ToString());//操作iwms_record 需要插入create_uaer_id。对aseld中的change_user未做任何改变 m.act_pick_qty = Int32.Parse(Request.Params["act_pick_qty"]);//下一步插入檢貨記錄表,每檢一次記錄一次,實際撿貨量以傳過來的值為標準 if (_iasdMgr.getTime(m).Rows.Count > 0) {//獲取到有效期控管商品的保質期 m.cde_dt_incr = int.Parse(_iasdMgr.getTime(m).Rows[0]["cde_dt_incr"].ToString()); m.cde_dt_shp = int.Parse(_iasdMgr.getTime(m).Rows[0]["cde_dt_shp"].ToString()); } if (!string.IsNullOrEmpty(Request.Params["cde_dt"])) {//獲取有效日期算出製造日期 m.cde_dt = DateTime.Parse(Request.Params["cde_dt"]); if (m.cde_dt_incr > 0) { m.made_dt = m.cde_dt.AddDays(-m.cde_dt_incr); } else { m.made_dt = DateTime.Now; } } else if (!string.IsNullOrEmpty(Request.Params["made_dt"])) {//獲取製造日期獲取有效日期 m.made_dt = DateTime.Parse(Request.Params["made_dt"]); if (m.cde_dt_incr > 0) { m.cde_dt = m.made_dt.AddDays(m.cde_dt_incr); } else { m.cde_dt = DateTime.Now; } } else {//不是有效期控管 m.made_dt = DateTime.Now; m.cde_dt = DateTime.Now; } if (m.act_pick_qty > 0) { sb.Append(_iasdMgr.AddIwsRecord(m)); } //m.act_pick_qty = m.ord_qty - m.out_qty; _iasdMgr.InsertSql(sb.ToString());//執行SQL語句裡面有事物處理 int result = _iasdMgr.DecisionBulkPicking(m, 3);//判斷調度是否檢完,是否檢夠,是否可以裝箱 json = "{success:true,msg:'" + result + "'" + "}";//返回json數據 #endregion } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:0}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }