/// <summary> /// 获取包装信息。 /// </summary> /// <param name="packageNo"></param> /// <returns></returns> public ActionResult GetPackageInfo(string packageNo) { double currentQuantity = 0; double fullPackageQty = 0; string orderNumber = string.Empty; string materialCode = string.Empty; bool isLatestPackage = false; int nPackageState = 0; if (!string.IsNullOrEmpty(packageNo)) { //获取当前数量 using (PackageQueryServiceClient client = new PackageQueryServiceClient()) { MethodReturnResult <Package> rst2 = client.Get(packageNo); if (rst2.Code == 1000) { return(Json(rst2)); } if (rst2.Code <= 0 && rst2.Data != null && rst2.Data.PackageState == EnumPackageState.Packaging) { currentQuantity = rst2.Data.Quantity; orderNumber = rst2.Data.OrderNumber; materialCode = rst2.Data.MaterialCode; isLatestPackage = rst2.Data.IsLastPackage; nPackageState = Convert.ToInt32(rst2.Data.PackageState); } } if (!string.IsNullOrEmpty(orderNumber)) { //获取满包数量 using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient()) { MethodReturnResult <WorkOrderRule> rst1 = client.Get(new WorkOrderRuleKey() { OrderNumber = orderNumber, MaterialCode = materialCode }); if (rst1.Code == 0 && rst1.Data != null) { fullPackageQty = rst1.Data.FullPackageQty; } } } } return(Json(new{ CurrentQuantity = currentQuantity, FullPackageQty = fullPackageQty, IsLastestPackage = isLatestPackage, PackageState = nPackageState }, JsonRequestBehavior.AllowGet)); }
public WorkOrderRule GetWorkOrderRule(string orderNumber, string materialCode) { using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient()) { MethodReturnResult <WorkOrderRule> result = client.Get(new WorkOrderRuleKey() { MaterialCode = materialCode, OrderNumber = orderNumber }); if (result.Code <= 0) { return(result.Data); } } return(null); }
// // GET: /ZPVM/WorkOrderControlObject/ public async Task <ActionResult> Index(string OrderNumber, string MaterialCode) { if (string.IsNullOrEmpty(OrderNumber) || string.IsNullOrEmpty(MaterialCode)) { return(RedirectToAction("Index", "WorkOrderRule")); } using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient()) { MethodReturnResult <WorkOrderRule> result = await client.GetAsync(new WorkOrderRuleKey() { OrderNumber = OrderNumber, MaterialCode = MaterialCode }); if (result.Code > 0 || result.Data == null) { return(RedirectToAction("Index", "WorkOrderRule")); } ViewBag.Rule = result.Data; } using (WorkOrderControlObjectServiceClient client = new WorkOrderControlObjectServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { Where = string.Format(" Key.OrderNumber = '{0}' AND Key.MaterialCode='{1}'" , OrderNumber , MaterialCode), OrderBy = "Key" }; MethodReturnResult <IList <WorkOrderControlObject> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } return(View(new WorkOrderControlObjectQueryViewModel() { OrderNumber = OrderNumber, MaterialCode = MaterialCode })); }
// // GET: /ZPVM/WorkOrderRule/Detail public async Task <ActionResult> Detail(string orderNumber, string materialCode) { using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient()) { MethodReturnResult <WorkOrderRule> result = await client.GetAsync(new WorkOrderRuleKey() { OrderNumber = orderNumber, MaterialCode = materialCode }); if (result.Code == 0) { WorkOrderRuleViewModel viewModel = new WorkOrderRuleViewModel() { OrderNumber = result.Data.Key.OrderNumber, MaterialCode = result.Data.Key.MaterialCode, CalibrationType = result.Data.CalibrationType, CalibrationCycle = result.Data.CalibrationCycle, PowerDegree = result.Data.PowerDegree, MinPower = result.Data.MinPower, MaxPower = result.Data.MaxPower, FixCycle = result.Data.FixCycle, FullPackageQty = result.Data.FullPackageQty, Description = result.Data.Description, RuleCode = result.Data.RuleCode, RuleName = result.Data.RuleName, CreateTime = result.Data.CreateTime, Creator = result.Data.Creator, Editor = result.Data.Editor, EditTime = result.Data.EditTime }; return(PartialView("_InfoPartial", viewModel)); } else { ModelState.AddModelError("", result.Message); } } return(PartialView("_InfoPartial", new WorkOrderRuleViewModel() { OrderNumber = orderNumber, MaterialCode = materialCode })); }
public async Task <ActionResult> Delete(string orderNumber, string materialCode) { MethodReturnResult result = new MethodReturnResult(); using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient()) { result = await client.DeleteAsync(new WorkOrderRuleKey() { OrderNumber = orderNumber, MaterialCode = materialCode }); if (result.Code == 0) { result.Message = string.Format(ZPVMResources.StringResource.WorkOrderRule_Delete_Success , materialCode); } return(Json(result)); } }
public async Task <ActionResult> SaveModify(WorkOrderRuleViewModel model) { using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient()) { MethodReturnResult <WorkOrderRule> result = await client.GetAsync(new WorkOrderRuleKey() { OrderNumber = model.OrderNumber, MaterialCode = model.MaterialCode }); if (result.Code == 0) { result.Data.RuleName = model.RuleName; result.Data.RuleCode = model.RuleCode; result.Data.PowerDegree = model.PowerDegree; result.Data.MinPower = model.MinPower; result.Data.MaxPower = model.MaxPower; result.Data.FixCycle = model.FixCycle; result.Data.FullPackageQty = model.FullPackageQty.Value; result.Data.CalibrationCycle = model.CalibrationCycle; result.Data.CalibrationType = model.CalibrationType; result.Data.Editor = User.Identity.Name; result.Data.EditTime = DateTime.Now; MethodReturnResult rst = await client.ModifyAsync(result.Data); if (rst.Code == 0) { rst.Message = string.Format(ZPVMResources.StringResource.WorkOrderRule_SaveModify_Success , result.Data.Key); } return(Json(rst)); } else { return(await Save(model)); } } }
public async Task <ActionResult> Save(WorkOrderRuleViewModel model) { using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient()) { WorkOrderRule obj = new WorkOrderRule() { Key = new WorkOrderRuleKey() { OrderNumber = model.OrderNumber.ToUpper(), MaterialCode = model.MaterialCode.ToUpper() }, CalibrationCycle = model.CalibrationCycle, CalibrationType = model.CalibrationType, FullPackageQty = model.FullPackageQty.Value, Description = model.Description, FixCycle = model.FixCycle, MaxPower = model.MaxPower, MinPower = model.MinPower, PowerDegree = model.PowerDegree, RuleCode = model.RuleCode, RuleName = model.RuleName, CreateTime = DateTime.Now, Creator = User.Identity.Name, Editor = User.Identity.Name, EditTime = DateTime.Now, }; MethodReturnResult rst = await client.AddAsync(obj); if (rst.Code == 0) { rst.Message = string.Format(ZPVMResources.StringResource.WorkOrderRule_Save_Success , obj.Key); } return(Json(rst)); } }
public ActionResult Finish(ZPVMLotPackageViewModel model) { MethodReturnResult result = new MethodReturnResult(); try { //如果包装号为空。 if (string.IsNullOrEmpty(model.PackageNo)) { result.Code = 1001; result.Message = string.Format("包装号不能为空。"); return(Json(result)); } else { model.PackageNo = model.PackageNo.ToUpper().Trim(); } Package obj = null; //如果当前数量为空,获取当前数量 using (PackageQueryServiceClient client = new PackageQueryServiceClient()) { MethodReturnResult <Package> rst2 = client.Get(model.PackageNo.ToUpper().Trim()); if (rst2.Code > 0) { return(Json(rst2)); } //检查包装状态 if (rst2.Data.PackageState != EnumPackageState.Packaging) { result.Code = 1001; result.Message = string.Format("包 {0} 非{1}状态,不能操作。" , model.PackageNo.ToUpper().Trim() , EnumPackageState.Packaging.GetDisplayName()); return(Json(result)); } //设置当前数量。 if (rst2.Code <= 0 && rst2.Data != null) { obj = rst2.Data; model.CurrentQuantity = rst2.Data.Quantity; } } //如果满包数量为空,获取满包数量 if (model.FullQuantity == 0) { using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient()) { MethodReturnResult <WorkOrderRule> rst1 = client.Get(new WorkOrderRuleKey() { OrderNumber = obj.OrderNumber, MaterialCode = obj.MaterialCode }); if (rst1.Code == 0 && rst1.Data != null) { model.FullQuantity = rst1.Data.FullPackageQty; } } } //非尾包,不能完成包装并过站 if (model.IsFinishPackage == true && (model.IsLastestPackage == false && obj.IsLastPackage == false) && model.CurrentQuantity != model.FullQuantity) { result.Code = 1; result.Message = string.Format("包({0})非尾包,包装数量未达到满包数量,不能完成包装。" , model.PackageNo); return(Json(result)); } //判断批次所在车间和当前线所在车间是否匹配。 //获取线别车间。 string locationName = string.Empty; using (ProductionLineServiceClient client = new ProductionLineServiceClient()) { MethodReturnResult <ProductionLine> r = client.Get(model.LineCode); if (r.Code <= 0) { locationName = r.Data.LocationName; } } if (!string.IsNullOrEmpty(locationName)) { using (LocationServiceClient client = new LocationServiceClient()) { MethodReturnResult <Location> r = client.Get(locationName); if (r.Code <= 0) { locationName = r.Data.ParentLocationName; } } } //获取包装号所在车间。 string currentLocationName = string.Empty; using (WorkOrderServiceClient client = new WorkOrderServiceClient()) { MethodReturnResult <WorkOrder> rst1 = client.Get(obj.OrderNumber); if (rst1.Code <= 0 && rst1.Data != null) { currentLocationName = rst1.Data.LocationName; } } //检查包所在车间和线别车间是否匹配。 if (currentLocationName != locationName) { result.Code = 3; result.Message = string.Format("包({0})属于({1})车间,不能在({2})车间线别上操作。" , obj.Key , currentLocationName , locationName); return(Json(result)); } result = FinishPackage(model); //result = Package(model); //返回包装结果。 if (result.Code <= 0) { MethodReturnResult <ZPVMLotPackageViewModel> rstFinal = new MethodReturnResult <ZPVMLotPackageViewModel>() { Code = result.Code, Data = model, Detail = result.Detail, HelpLink = result.HelpLink, Message = result.Message }; return(Json(rstFinal)); } } catch (Exception ex) { result.Code = 1000; result.Message = ex.Message; result.Detail = ex.ToString(); } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(Json(result)); }