diff --git a/FactorySystemApi/Controllers/HalfMaterialTeamworkController.cs b/FactorySystemApi/Controllers/HalfMaterialTeamworkController.cs index f31ce17..45250ba 100644 --- a/FactorySystemApi/Controllers/HalfMaterialTeamworkController.cs +++ b/FactorySystemApi/Controllers/HalfMaterialTeamworkController.cs @@ -252,7 +252,7 @@ namespace FactorySystemApi.Controllers //创建 TFS_FTeamwork int teamId = BaseBll.InsertDataModel(inParam, "TFS_HalfMaterialFTeamwork"); - List editMaterialList = MaterialTeamworkBll.UpdateFormula(inParam["FTestCode"].ToString(), inParam["FNewTestCode"].ToString(), teamId, factory.FID); + List editMaterialList = MaterialTeamworkBll.UpdateFormula(inParam["FTestCode"].ToString(), inParam["FNewTestCode"].ToString(), teamId, factory); ids = editMaterialList.Select(m => m.FID).Distinct().ToList(); apiResult.Data = teamId; @@ -320,7 +320,7 @@ namespace FactorySystemApi.Controllers catch (Exception ex) { //失败则把修改的更新回去 - MaterialTeamworkBll.UpdateFormula(inParam["FTestCode"].ToString(), inParam["FNewTestCode"].ToString(), 0, 0, string.Join(",", ids)); + MaterialTeamworkBll.UpdateFormula(inParam["FTestCode"].ToString(), inParam["FNewTestCode"].ToString(), 0, null, string.Join(",", ids)); throw; } }, apiResult, Request, inParam); @@ -776,12 +776,12 @@ namespace FactorySystemApi.Controllers TFS_Material material = new TFS_Material() { FID = DateTime.Now.DayOfYear * 10 + dataId, - FPlmCode = item.Code, + FPlmCode = item.SP, FName = item.Name, //FCode = item.Code, FType = item.Type.ToLower(), - FTestCode = item.TestNO, - FVersionCode = item.Version, + FTestCode = item.SP_VALUE, + FVersionCode = item.SP_Version, FParentID = parentId }; diff --git a/FactorySystemApi/Controllers/MaterialController.cs b/FactorySystemApi/Controllers/MaterialController.cs index 6a667fa..f793cab 100644 --- a/FactorySystemApi/Controllers/MaterialController.cs +++ b/FactorySystemApi/Controllers/MaterialController.cs @@ -156,6 +156,30 @@ namespace FactorySystemApi.Controllers } }, apiResult, Request, inParam); } + /// + /// 根据试验号获取物料 + /// + /// + /// + [HttpPost] + public ApiResult GetMaterialListByFTestCode(Dictionary inParam) + { + ApiResult apiResult = new ApiResult(); + return ExceptionHelper.TryReturnException(() => + { + if (inParam == null) + { + apiResult.Error("未接收到参数"); + } + else + { + if (inParam.ContainsKey("FTestCode")) + { + apiResult.Data = MaterialBll.GetMaterialListByFTestCode(inParam["FTestCode"].ToString()); + } + } + }, apiResult, Request, inParam); + } /// /// (对接)MDM获取物料PLM码 @@ -223,7 +247,7 @@ namespace FactorySystemApi.Controllers /// 导出视图 /// /// - public ApiResult DownMateialView(Dictionary inParam) + public ApiResult DownMateialView(Dictionary inParam) { ApiResult apiResult = new ApiResult(); return ExceptionHelper.TryReturnException(() => @@ -279,7 +303,7 @@ namespace FactorySystemApi.Controllers } - + /// @@ -331,7 +355,7 @@ namespace FactorySystemApi.Controllers /// /// /// - public ApiResult DownViewAll(Dictionary inParam) + public ApiResult DownViewAll(Dictionary inParam) { ApiResult apiResult = new ApiResult(); return ExceptionHelper.TryReturnException(() => @@ -358,8 +382,8 @@ namespace FactorySystemApi.Controllers File.Delete(basePath + string.Format("\\File\\Temp\\{0}\\", "", str)); MaterialBll.CreateExeclFileALL(inParam["FType"].ToString(), savePath); } - - string url = Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.AbsolutePath, "") + savePath.Replace(basePath, "").Replace("\\", "/").Replace(".xlsx", str+".xlsx"); + + string url = Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.AbsolutePath, "") + savePath.Replace(basePath, "").Replace("\\", "/").Replace(".xlsx", str + ".xlsx"); apiResult.Data = url; }, apiResult, Request, inParam); } @@ -373,7 +397,7 @@ namespace FactorySystemApi.Controllers public ApiResult UpdateDataModel2(Dictionary inParam) { ApiResult apiResult = new ApiResult(); - + //BaseBll.UpdateDataModel(inParam, "TFS_FTeamwork"); return ExceptionHelper.TryReturnException(() => @@ -382,14 +406,14 @@ namespace FactorySystemApi.Controllers { apiResult.Error("未接收到参数"); } - else if (!inParam.ContainsKey("tempId")) + else if (!inParam.ContainsKey("tempId")) { apiResult.Error("未找到协同ID"); } else { int tempId = int.Parse(inParam["tempId"].ToString()); - int taskId= int.Parse(inParam["taskId"].ToString()); + int taskId = int.Parse(inParam["taskId"].ToString()); inParam.Remove("tempId"); inParam.Remove("taskId"); @@ -401,11 +425,11 @@ namespace FactorySystemApi.Controllers if (result.Where(m => m.FSuccedaneumID == 0).Count() == 0) { BaseBll.UpdateTeamProcess(tempId, (int)Constant.ProcessType.替代品确认, 2, 2); - int count=MaterialBll.ExecSql(BaseBll.GetTaskSql(taskId, 2, tempId, (int)Constant.TaskType.替代料确认)); + int count = MaterialBll.ExecSql(BaseBll.GetTaskSql(taskId, 2, tempId, (int)Constant.TaskType.替代料确认)); } } - + }, apiResult, Request, inParam); } diff --git a/FactorySystemBll/HalfMaterialTeamworkBll.cs b/FactorySystemBll/HalfMaterialTeamworkBll.cs index 8b92476..4dd99e2 100644 --- a/FactorySystemBll/HalfMaterialTeamworkBll.cs +++ b/FactorySystemBll/HalfMaterialTeamworkBll.cs @@ -408,8 +408,8 @@ namespace FactorySystemBll int oldId = mItem.FID, oldParent = mItem.FParentID; Expression> expression; - if (string.IsNullOrEmpty(mItem.FCode)) expression = s => s.FPlmCode == mItem.FPlmCode && s.FVersionCode == mItem.FVersionCode&&s.FID==mItem.FID; - else expression = s => s.FCode == mItem.FCode && s.FVersionCode == mItem.FVersionCode && s.FID == mItem.FID; + if (string.IsNullOrEmpty(mItem.FCode)) expression = s => s.FPlmCode == mItem.FPlmCode && s.FVersionCode == mItem.FVersionCode; + else expression = s => s.FCode == mItem.FCode && s.FVersionCode == mItem.FVersionCode ; TFS_Material mData = db.Queryable().Where(expression).First(); if (mData == null)//没物料新增物料 @@ -778,28 +778,47 @@ namespace FactorySystemBll /// 原配方 /// 新配方 /// - public List UpdateFormula(string testCode, string testCode2,int temId,int factoryID, string idList="") + public List UpdateFormula(string testCode, string testCode2,int temId, TFS_Factory factory, string idList="") { SqlSugarClient db = AppSettingsHelper.GetSqlSugar(); + List materialList = null; + List factoryList = new List(); + if (factory != null) + { + if (factory.FType != (int)Constant.FactoryType.单工厂) + { + factoryList.Add(factory.FID); + factoryList.Add(factory.FFactoryID); + } + else + { + factoryList.Add(factory.FID); + } - List materialList = db.Queryable().Where(m => m.FTestCode == testCode).ToList(); - List ids = materialList.Select(m => m.FID).ToList(); - //更新配方 - string sql = ""; + materialList = db.Queryable().Where(m => m.FTestCode == testCode&&string.Join(",", factoryList).Contains(m.FFactoryID.ToString())).ToList(); + List ids = materialList.Select(m => m.FID).ToList(); + //更新配方 + string sql = ""; + + + if (string.IsNullOrWhiteSpace(idList)) + { + sql = string.Format("update TFS_Material set FTestCode='{0}' WHERE FID in ({1});update TFS_ViewMaterial set FHalfMaterialTeamID={2} WHERE FMaterialID in ({1})", testCode2, string.Join(",", ids), temId); + } + else + { + sql = string.Format("update TFS_Material set FTestCode='{0}' WHERE FID in ({1})", testCode, idList); + } + if (materialList.Count() > 0) + { + db.Ado.ExecuteCommand(sql); + } - if (string.IsNullOrWhiteSpace(idList)) - { - sql = string.Format("update TFS_Material set FTestCode='{0}' WHERE FID in ({1});update TFS_ViewMaterial set FHalfMaterialTeamID={2} WHERE FMaterialID in ({1})", testCode2, string.Join(",", ids),temId); - } - else - { - sql = string.Format("update TFS_Material set FTestCode='{0}' WHERE FID in ({1})", testCode, idList); - } - if (materialList.Count() > 0) - { - db.Ado.ExecuteCommand(sql); } + + + return materialList; } diff --git a/FactorySystemBll/MaterialBll.cs b/FactorySystemBll/MaterialBll.cs index a0db5d8..c9f114c 100644 --- a/FactorySystemBll/MaterialBll.cs +++ b/FactorySystemBll/MaterialBll.cs @@ -105,6 +105,16 @@ namespace FactorySystemBll .Queryable((a, b) => new JoinQueryInfos(JoinType.Left, a.FID == b.FMaterialID)) .Where((a, b) => b.FTeamID == tempId).Select((a, b) => a).ToList(); } + /// + /// 更具试验号获取物料 + /// + /// + /// + public List GetMaterialListByFTestCode(string fTestCode) + { + return AppSettingsHelper.GetSqlSugar().Queryable().Where(m => m.FTestCode == fTestCode).ToList(); + } + public TFS_Material GetMaterialById(int id) {