public ActionResult Undo(string lotNumber, string transactionKey, string description) { MethodReturnResult result = new MethodReturnResult(); try { if (string.IsNullOrEmpty(lotNumber) || string.IsNullOrEmpty(transactionKey)) { result.Code = 1; result.Message = "参数为空。"; return(Json(result)); } //获取批次值。 lotNumber = lotNumber.ToUpper(); result = GetLot(lotNumber); if (result.Code > 0) { return(Json(result)); } //获取批次操作数据 result = GetLotTransaction(transactionKey); if (result.Code > 0) { return(Json(result)); } UndoParameter p = new UndoParameter() { Creator = User.Identity.Name, OperateComputer = Request.UserHostAddress, Operator = User.Identity.Name, UndoTransactionKeys = new Dictionary <string, IList <string> >(), Remark = description, LotNumbers = new List <string>() }; p.LotNumbers.Add(lotNumber); p.UndoTransactionKeys.Add(lotNumber, new List <string>()); p.UndoTransactionKeys[lotNumber].Add(transactionKey); //批次撤销操作。 using (LotUndoServiceClient client = new LotUndoServiceClient()) { result = client.Undo(p); } if (result.Code == 0) { return(Query(lotNumber)); } } catch (Exception ex) { result.Code = 1000; result.Message = ex.Message; result.Detail = ex.ToString(); } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(Json(result)); }
/// <summary>批次进行批量查询 </summary> /// <param name="lotNumber"></param> /// <returns></returns> public ActionResult QueryBatchRevocation(string lotNumber) { string strErrorMessage = string.Empty; MethodReturnResult <DataSet> result = new MethodReturnResult <DataSet>(); try { LotProcessingParameter param = new LotProcessingParameter(); param.Lotlist = lotNumber; param.PageSize = 20; param.PageNo = -1; using (LotUndoServiceClient client = new LotUndoServiceClient()) { MethodReturnResult <DataSet> ds = client.GetLotProcessing(ref param); if (ds.Code > 0) { result.Code = ds.Code; result.Message = ds.Message; result.Detail = ds.Detail; return(Json(result)); } ViewBag.ListData = ds.Data.Tables[0]; ViewBag.PagingConfig = new PagingConfig() { PageNo = -1, PageSize = 20, }; } } catch (Exception ex) { result.Code = 1000; result.Message = ex.Message; result.Detail = ex.ToString(); } if (Request.IsAjaxRequest()) { return(PartialView("_BatchRevocationListPartial", new LotViewModel())); } else { return(View("BatchRevocationIndex", new LotViewModel())); } }
public ActionResult Delete(string packageNo, int itemNo, string lotNumber) { MethodReturnResult result = new MethodReturnResult(); try { //获取包装记录 using (PackageQueryServiceClient client = new PackageQueryServiceClient()) { MethodReturnResult <Package> rst1 = client.Get(packageNo); if (rst1.Code > 0 || rst1.Data == null) { return(Json(rst1)); } //判断包装记录目前是否处于包装中状态。 if (rst1.Data.PackageState != EnumPackageState.Packaging) { result.Code = 1001; result.Message = string.Format("包装{0}为非{1}状态,不能删除。" , packageNo , EnumPackageState.Packaging.GetDisplayName()); return(Json(result)); } } //获取最后一笔包装记录。 IList <string> lstTransactionKey = new List <string>(); using (LotQueryServiceClient client = new LotQueryServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format("LotNumber='{0}' AND UndoFlag=0" , lotNumber) }; MethodReturnResult <IList <LotTransaction> > rst1 = client.GetTransaction(ref cfg); if (rst1.Code <= 0 && rst1.Data != null) { var lnq = from item in rst1.Data orderby item.CreateTime descending select item; foreach (LotTransaction item in lnq) { lstTransactionKey.Add(item.Key); if (item.Activity == EnumLotActivity.Package) { break; } } } else { return(Json(rst1)); } } //可撤销操作主键不为空。 if (lstTransactionKey.Count > 0) { UndoParameter p = new UndoParameter() { Creator = User.Identity.Name, LotNumbers = new List <string>(), OperateComputer = Request.UserHostAddress, Operator = User.Identity.Name, UndoTransactionKeys = new Dictionary <string, IList <string> >() }; p.LotNumbers.Add(lotNumber); p.UndoTransactionKeys.Add(lotNumber, lstTransactionKey); using (LotUndoServiceClient client = new LotUndoServiceClient()) { result = client.Undo(p); if (result.Code == 0) { result.Message = string.Format("删除 ({0}:{1}:{2}) 成功。" , packageNo, itemNo, lotNumber); } } } } catch (Exception ex) { result.Code = 1000; result.Message = ex.Message; result.Detail = ex.ToString(); } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(Json(result)); }
public ActionResult SaveBatchRevocation(string LotNumber) { MethodReturnResult result = new MethodReturnResult(); LotTransaction LotTransaction = null; LotTransaction LotTransaction1 = null; LotTransaction LotTransaction2 = null; try { UndoParameter p = new UndoParameter() { Creator = User.Identity.Name, OperateComputer = Request.UserHostAddress, Operator = User.Identity.Name, UndoTransactionKeys = new Dictionary <string, IList <string> >(), LotNumbers = new List <string>() }; char splitChar = ','; //获取批次号值 string[] lotNumbers = Request["LotNumber"].ToUpper().Split(splitChar); p.LotNumbers = lotNumbers.ToList(); for (int i = 0; i < p.LotNumbers.Count; i++) { string lotNumber = p.LotNumbers[i]; if (i == 0) { //获取第一个批次的最新一条加工历史数据 LotTransaction = GetLotLastTransaction(p.LotNumbers[0]); LotTransaction2 = LotTransaction; } else { //获取除第一个批次的最新一条加工历史数据 LotTransaction1 = GetLotLastTransaction(lotNumber); LotTransaction2 = LotTransaction1; } if (LotTransaction != null && LotTransaction1 != null) { //判定批次是否为同一个工艺流程组。 if (LotTransaction.RouteEnterpriseName != LotTransaction1.RouteEnterpriseName) { result.Code = 1001; result.Message = string.Format("批次({0})与批次({1})工艺流程组不相同。", p.LotNumbers[0], lotNumber); return(Json(result)); } //判定批次是否为同一个工艺流程。 if (LotTransaction.RouteName != LotTransaction1.RouteName) { result.Code = 1002; result.Message = string.Format("批次({0})与批次({1})工艺流程不相同。", p.LotNumbers[0], lotNumber); return(Json(result)); } //判定批次是否为同一个工序。 if (LotTransaction.RouteStepName != LotTransaction1.RouteStepName) { result.Code = 1003; result.Message = string.Format("批次({0})与批次({1})工序不相同。", p.LotNumbers[0], lotNumber); return(Json(result)); } //判定批次是否为同一个操作流程。 if (LotTransaction.Activity != LotTransaction1.Activity) { result.Code = 1004; result.Message = string.Format("批次({0})与批次({1})操作名称不相同。", p.LotNumbers[0], lotNumber); return(Json(result)); } } //p.LotNumbers.Add(lotNumber); p.UndoTransactionKeys.Add(lotNumber, new List <string>()); p.UndoTransactionKeys[lotNumber].Add(LotTransaction2.Key); } if (result.Code == 0) { using (LotUndoServiceClient client = new LotUndoServiceClient()) { result = client.Undo(p); } } if (result.Code == 0) { return(Query(LotNumber)); } if (result.Code > 0) { return(Json(result)); } } catch (Exception ex) { result.Code = 1000; result.Message = ex.Message; result.Detail = ex.ToString(); } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(Json(result)); }