/// <summary> /// 质量返馈新增 /// </summary> /// <param name="jData"></param> /// <returns></returns> public AjaxResult QualityInsert(JObject jData) { AjaxResult result = new AjaxResult(); try { var cQuality = jData.ToObject <AppQuality>(); var ef = AutoMapper.Mapper.Map <TMQ_QUALITY_MAIN>(cQuality); ef.C_ID = Guid.NewGuid().ToString(); ef.C_EMP_ID = BaseUser.Id; ef.C_EMP_NAME = BaseUser.Name; ef.D_MOD_DT = DateTime.Now; ef = qualityService.QualitysInser(ef); List <TRC_ROLL_PRODCUT> products = new List <TRC_ROLL_PRODCUT>(); List <TSC_SLAB_MAIN> slabs = new List <TSC_SLAB_MAIN>(); List <TMQ_QUALITY_STL_GRDDTO> stlGrds = new List <TMQ_QUALITY_STL_GRDDTO>(); if (cQuality.N_ORDERTYPE == "8") { if (cQuality.Details != null && cQuality.Details.Count > 0) { foreach (var item in cQuality.Details) { products = qualityService.GetRollProdcut(item.BatchNO, ""); if (products != null && products.Count > 0) { foreach (var p in products) { TMQ_QUALITY_STL_GRDDTO newStl = new TMQ_QUALITY_STL_GRDDTO(); newStl.C_QUALITY_ID = ef.C_ID; newStl.C_BATCH_NO = item.BatchNO; newStl.C_STL_GRD = p.C_STL_GRD; newStl.C_STD_CODE = p.C_STD_CODE; newStl.C_SPEC = p.C_SPEC; newStl.N_SHIP_WGT = item.N_SHIP_WGT; newStl.N_OBJEC_WGT = item.N_OBJEC_WGT; stlGrds.Add(newStl); } } } } } else { if (cQuality.Details != null && cQuality.Details.Count > 0) { foreach (var item in cQuality.Details) { slabs = qualityService.GetSlabMain(item.BatchNO, ""); if (slabs != null && slabs.Count > 0) { foreach (var p in products) { TMQ_QUALITY_STL_GRDDTO newStl = new TMQ_QUALITY_STL_GRDDTO(); newStl.C_QUALITY_ID = ef.C_ID; newStl.C_BATCH_NO = item.BatchNO; newStl.C_STL_GRD = p.C_STL_GRD; newStl.C_STD_CODE = p.C_STD_CODE; newStl.C_SPEC = p.C_SPEC; newStl.N_SHIP_WGT = item.N_WGT; stlGrds.Add(newStl); } } } } } qualityService.QualitysDetailInser(stlGrds); result.Code = DoResult.Success; result.Result = "添加成功!"; } catch (Exception e) { result.Code = DoResult.Failed; result.Result = e.Message; } return(result); }