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(PackageReworkViewModel model) { MethodReturnResult result = new MethodReturnResult(); string error_mes = string.Empty; try { //创建参数 PackageReworkParameter p = new PackageReworkParameter() { Creator = User.Identity.Name, OperateComputer = Request.UserHostAddress, Operator = User.Identity.Name, PackageNo = model.PackageNo, //托号 LotNumber = model.LotNumber, //批次号 LocationName = model.LocationName, //车间 LineCode = model.LineCode, //线别 RetainPackageNo = model.RetainPackageNo, //是否保留托号 IsLot = model.IsLot //是否按批次号投料 }; if (model.LotNumber != "" && model.LotNumber != null) { p.LotNumber = p.LotNumber.Trim(); char splitChar = ','; //获取批次号值。 string[] lotNumbers = p.LotNumber.ToUpper().Split(splitChar); p.LotNumbers = lotNumbers.ToList(); } if (model.PackageNo != "" && model.PackageNo != null && p.IsLot == false) { p.PackageNo = p.PackageNo.Trim(); char splitChar = ','; //获取托号值。 string[] packageNos = p.PackageNo.ToUpper().Split(splitChar); p.PackageNos = packageNos.ToList(); } //整托投料不得输入批次号 if (p.IsLot == false && (p.LotNumber != "" && p.LotNumber != null)) { result.Code = 1000; result.Message = string.Format(" 未勾选按批次号投料,请勿输入批次号!"); } //按批次号投料必须输批次号 else if (p.IsLot == true && (p.LotNumber == "" || p.LotNumber == null)) { result.Code = 1000; result.Message = string.Format(" 已勾选按批次号投料,请输入批次号!"); } else { using (LotReworkServiceClient client = new LotReworkServiceClient()) { string message = ""; if (p.IsLot) { for (int i = 0; i < p.LotNumbers.Count; i++) { p.LotNumber = p.LotNumbers[i]; result = client.Rework(p); message = result.Message; if (result.Code == 0) { if (p.LotNumbers.Count == 1) { result.Message = string.Format(" 托号 {0} 中批次 {1} 投料操作成功!", model.PackageNo, p.LotNumber); } if (p.LotNumbers.Count > 1) { result.Message = string.Format(" 投料操作成功!"); } } } } else { for (int i = 0; i < p.PackageNos.Count; i++) { p.PackageNo = p.PackageNos[i]; result = client.Rework(p); message = result.Message; if (result.Code == 0) { if (p.PackageNos.Count == 1) { result.Message = string.Format(" {0} 投料操作成功!", model.PackageNo); } if (p.PackageNos.Count > 1) { result.Message = string.Format("投料操作成功!"); } } } } if (result.Code == 0) { result.Message += message; } } } } 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)); }