public ActionResult Save(LotReworkViewModel model) { MethodReturnResult result = new MethodReturnResult(); try { ReworkParameter p = new ReworkParameter() { Creator = User.Identity.Name, OperateComputer = Request.UserHostAddress, Operator = User.Identity.Name, RouteEnterpriseName = model.RouteEnterpriseName, RouteName = model.RouteName, RouteStepName = model.RouteStepName, Remark = model.Description, LotNumbers = new List <string>(), MaterialCode = model.NewMaterialCode, OrderNumber = model.NewOrderNumber }; //按批次返工。 if (model.IsPackageNo == false) { string lotNumber = model.LotNumber.ToUpper(); p.LotNumbers.Add(lotNumber); } else //按包装返工。 { using (PackageQueryServiceClient client = new PackageQueryServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format("Key.PackageNo='{0}'", model.LotNumber) }; MethodReturnResult <IList <PackageDetail> > rst1 = client.GetDetail(ref cfg); if (rst1.Code > 0) { return(Json(rst1)); } foreach (PackageDetail item in rst1.Data) { p.LotNumbers.Add(item.Key.ObjectNumber); } } if (p.LotNumbers.Count <= 0) { result.Code = 5; result.Message = string.Format("包装 {0} 不存在。", model.LotNumber); return(Json(result)); } } //foreach (string lotNumber in p.LotNumbers) //{ // //获取批值。 // result = GetLot(lotNumber); // if (result.Code > 0) // { // return Json(result); // } //} //批次返工操作。 using (LotReworkServiceClient client = new LotReworkServiceClient()) { result = client.Rework(p); } if (result.Code == 0) { result.Message = string.Format(" {0} 返工操作成功。", model.LotNumber); } } catch (Exception ex) { result.Code = 1000; result.Message = ex.Message; result.Detail = ex.ToString(); } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(Json(result)); }
public ActionResult Save(LotReworkViewModel model) { MethodReturnResult result = new MethodReturnResult(); string error_mes = string.Empty; try { ReworkParameter p = new ReworkParameter() { Creator = User.Identity.Name, OperateComputer = Request.UserHostAddress, Operator = User.Identity.Name, RouteEnterpriseName = model.RouteEnterpriseName, RouteName = model.RouteName, RouteStepName = model.RouteStepName, Remark = model.Description, LotNumbers = new List <string>(), MaterialCode = model.NewMaterialCode, OrderNumber = model.NewOrderNumber, IsPackageRework = true }; //按包装返工。 //string lotNumber = model.LotNumber.ToUpper(); //string[] arrlotNumber = model.LotNumber.Split(','); //foreach (var data in arrlotNumber) //{ // using (PackageQueryServiceClient client = new PackageQueryServiceClient()) // { // PagingConfig cfg = new PagingConfig() // { // IsPaging = false, // Where = string.Format("Key.PackageNo='{0}'", data.Trim()) // }; // MethodReturnResult<IList<PackageDetail>> rst1 = client.GetDetail(ref cfg); // if (rst1.Code > 0) // { // return Json(rst1); // } // foreach (PackageDetail item in rst1.Data) // { // p.LotNumbers.Add(item.Key.ObjectNumber); // } // } //} using (PackageQueryServiceClient client = new PackageQueryServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format("Key.PackageNo='{0}'", model.LotNumber) }; MethodReturnResult <IList <PackageDetail> > rst1 = client.GetDetail(ref cfg); if (rst1.Code > 0) { return(Json(rst1)); } foreach (PackageDetail item in rst1.Data) { p.LotNumbers.Add(item.Key.ObjectNumber); } } if (p.LotNumbers.Count <= 0) { //result.Code = 5; //result.Message = string.Format("包装 {0} 不存在。", model.LotNumber); //return Json(result); error_mes = REback(model.LotNumber); if (!string.IsNullOrEmpty(error_mes)) { result.Code = 5; result.Message = string.Format(error_mes); return(Json(result)); } } //string error_mes = string.Empty; //error_mes = REback(p.LotNumbers[0]); //if (!string.IsNullOrEmpty(error_mes)) //{ // result.Code = 5; // result.Message = string.Format(error_mes); // return Json(result); //} using (LotReworkServiceClient client = new LotReworkServiceClient()) { result = client.Rework(p); } if (result.Code == 0) { result.Message = string.Format(" {0} 投料操作成功。", model.LotNumber); //using (LotReworkServiceClient client = new LotReworkServiceClient()) //{ // result = client.LotUpdate(); // if (result.Code == 0) // { // result.Message =result.Message + string.Format(" 更新批次操作成功。"); // } //} } } catch (Exception ex) { result.Code = 1000; result.Message = ex.Message; result.Detail = ex.ToString(); } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(Json(result)); }