public string GetProductType(string materialCode, string orderNumber, string powersetCode, int itemNo, Lot lot) { string productType = string.Empty; Material material = null; string wop = ""; wop = GetPowersetName(lot.Key, powersetCode, itemNo); using (MaterialServiceClient client = new MaterialServiceClient()) { MethodReturnResult <Material> result = client.Get(materialCode); MethodReturnResult <MaterialAttribute> resultOfMaterialAttr = new MethodReturnResult <MaterialAttribute>(); MaterialAttributeServiceClient clientOfMattr = new MaterialAttributeServiceClient(); if (result.Code == 0) { material = result.Data; if (wop != "") { int indexOfType = material.Name.IndexOf('-'); if (indexOfType >= 0) { productType = material.Name.Substring(0, indexOfType) + "-" + wop.Substring(0, 3); } else { productType = material.Name.Substring(0, 6) + "-" + wop.Substring(0, 3); } if (material.Name.Contains("PV")) { MaterialAttributeKey materialAttributeKey = new MaterialAttributeKey() { MaterialCode = material.Key, AttributeName = "ProductType" }; resultOfMaterialAttr = clientOfMattr.Get(materialAttributeKey); if (resultOfMaterialAttr.Data != null) { string valueOf = resultOfMaterialAttr.Data.Value.Trim(); int indexOfType1 = valueOf.IndexOf('*'); productType = string.Format("{0}{1}-{2}{3}" , valueOf.Substring(0, indexOfType1) , wop.Substring(0, 3) , material.MainRawQtyPerLot , valueOf.Substring(valueOf.Length - 3)); } else { productType = ""; } } } } } return(productType); }
public ActionResult Save(LotMateSeModel model) { MethodReturnResult result = new MethodReturnResult(); int count = 0; try { string lotNumber = model.LotNumber.ToUpper(); result = GetLot(lotNumber); if (result.Code > 0) { return(Json(result)); } //取得批次信息 MethodReturnResult <Lot> rst = result as MethodReturnResult <Lot>; Lot obj = rst.Data; MaterialAttributeServiceClient clientOfMattr = new MaterialAttributeServiceClient(); MaterialAttributeKey materialAttributeKey = new MaterialAttributeKey() { MaterialCode = obj.MaterialCode, AttributeName = "MapBitCount" }; MethodReturnResult <MaterialAttribute> materialAttributeOfMap = clientOfMattr.Get(materialAttributeKey); if (materialAttributeOfMap.Code == 0 && materialAttributeOfMap.Data != null) { count = Convert.ToInt32(materialAttributeOfMap.Data.Value); } if (count != 0 && model.SEModulesNo.Length != count) { result.Code = 1000; result.Message = string.Format("组件批次{0}优化器序列号{1}长度不符合长度限制{2}", model.LotNumber, model.SEModulesNo, count); return(Json(result)); } else if (count != 0 && model.SEModulesNo.Length == count) { if (model.SEModulesNo.Length == 8) { int seModulesNo = 0; bool isNum = int.TryParse(model.SEModulesNo, out seModulesNo); if (isNum) { obj.Attr3 = model.SEModulesNo; } else { result.Code = 1000; result.Message = string.Format("组件批次{0}优化器序列号{1}不合法", model.LotNumber, model.SEModulesNo); return(Json(result)); } } else { obj.Attr3 = model.SEModulesNo; } } else { obj.Attr3 = model.SEModulesNo; } using (LotCreateServiceClient client = new LotCreateServiceClient()) { result = client.UpdateLotSEModules(obj); if (result.Code == 0) { result.Message = string.Format("组件批次{0}优化器序列号{1}匹配成功", model.LotNumber, model.SEModulesNo); } } } catch (Exception ex) { result.Code = 1000; result.Message = ex.Message; result.Detail = ex.ToString(); } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(Json(result)); }