diff --git a/FactorySystemApi/Controllers/FormulaController.cs b/FactorySystemApi/Controllers/FormulaController.cs index c419b7e..08ec4c2 100644 --- a/FactorySystemApi/Controllers/FormulaController.cs +++ b/FactorySystemApi/Controllers/FormulaController.cs @@ -14,6 +14,7 @@ using FactorySystemModel.RequestModel; using FactorySystemApi.Plm_Formula; using System.Web.UI.WebControls; using Newtonsoft.Json; +using Aspose.Cells; namespace FactorySystemApi.Controllers { @@ -62,7 +63,19 @@ namespace FactorySystemApi.Controllers apiResult.Data = FormulaBll.GetFormulaList(); }, apiResult, Request); } - + /// + /// 获取修改配方集合 + /// + /// + [HttpPost] + public ApiResult GetUpdateFormulaList() + { + ApiResult apiResult = new ApiResult(); + return ExceptionHelper.TryReturnException(() => + { + apiResult.Data = FormulaBll.GetUpdateFormulaList(); + }, apiResult, Request); + } /// /// 分业请求 @@ -80,6 +93,65 @@ namespace FactorySystemApi.Controllers }; }, apiResult, Request); } + /// + /// 获取配方变更列表 + /// + /// + /// + [HttpPost] + + public ApiResult GetUpdateFormulaPageList(FormulaQuery fq) + { + ApiResult apiResult = new ApiResult(); + return ExceptionHelper.TryReturnException(() => + { + apiResult.Data = new + { + List = FormulaBll.GetUpdateFormulaList(fq, out var totalNumber), + Total = totalNumber + }; + }, apiResult, Request); + } + + /// + /// 更新修改配方的描述及状态 + /// + /// + /// + [HttpPost] + public ApiResult EditUpdateFormula(Dictionary inParam) + { + ApiResult apiResult = new ApiResult(); + apiResult.Data = 0; + return ExceptionHelper.TryReturnException(() => + { + if (inParam == null) + { + apiResult.Error("未接收到参数"); + } + if (!inParam.ContainsKey("FID")) + { + apiResult.Error("未接收到参数FID"); + } + if (!inParam.ContainsKey("Remark")) + { + apiResult.Error("未填写备注说明"); + } + else + { + int userId = -1; + userId = Request.Properties["token"] is ApiAuthInfo user ? user.FID : userId; + int fid = int.Parse(inParam["FID"].ToString()); + TFS_UpdateFormula model = FormulaBll.GetUpdateFormulaByFID(fid); + model.Update_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm"); + model.Remark = inParam["Remark"].ToString(); + model.Status = "已处理"; + model.Update_User = userId.ToString(); + + apiResult.Data= FormulaBll.EditUpdateFormula(model); + } + }, apiResult, Request, inParam); + } /// /// 对接配方数据(对方写入) @@ -171,6 +243,8 @@ namespace FactorySystemApi.Controllers int userId = -1; if (Request.Properties.ContainsKey("token")) { + + userId = Request.Properties["token"] is ApiAuthInfo user ? user.FID : userId; apiResult.Data = FormulaBll.DockingRecipeData(new List() { formula }, userId); } @@ -183,6 +257,83 @@ namespace FactorySystemApi.Controllers }, apiResult, Request, inParam); } + [HttpPost] + public ApiResult DockingChangeData(Dictionary inParam) + { + ApiResult apiResult = new ApiResult(); + apiResult.Data = 0; + + return ExceptionHelper.TryReturnException(() => + { + if (inParam == null) + { + apiResult.Error("未接收到参数"); + } + else + { + + + + if (!inParam.ContainsKey("SP")) + { + apiResult.Error("PLM规格内码不能为空"); + } + else if (!inParam.ContainsKey("SP_VERSION")) + { + apiResult.Error("版本号不能为空"); + } + else if (!inParam.ContainsKey("Name")) + { + apiResult.Error("配方中文名称不能为空"); + } + else if (!inParam.ContainsKey("Type")) + { + apiResult.Error("配方类型不能为空"); + } + else if (!inParam.ContainsKey("SP_AUTHOR")) + { + apiResult.Error("修改人不能为空"); + } + else + { + //int userId = -1; + if (Request.Properties.ContainsKey("token")) + { + string sVersion = inParam["SP_VERSION"].ToString(); + double dVersion; + + bool isVersionNum = double.TryParse(sVersion, out dVersion); + + if (isVersionNum) + { + sVersion = string.Format("{0:F4}", dVersion); + } + TFS_UpdateFormula tFS_UpdateFormula = new TFS_UpdateFormula() + { + SP = inParam["SP"].ToString(), + SP_VERSION = sVersion, + SP_VALUE = inParam["SP_VALUE"].ToString(), + Name = inParam["Name"].ToString(), + Type = inParam["Type"].ToString(), + SP_AUTHOR = inParam["SP_AUTHOR"].ToString(), + //Change_Content = inParam["Change_Content"].ToString(), + Change_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm"), + Change_Content = inParam.ContainsKey("Change_List")?inParam["Change_List"].ToString():"", + }; + apiResult.Data = FormulaBll.SevaTFS_UpdateFormula(tFS_UpdateFormula); + + //userId = Request.Properties["token"] is ApiAuthInfo user ? user.FID : userId; + //apiResult.Data = FormulaBll.DockingRecipeData(new List() { formula }, userId); + } + else + { + apiResult.Error("token信息不存在"); + } + } + } + }, apiResult, Request, inParam); + } + /// /// (对接)SAP配方同步 /// @@ -523,7 +674,7 @@ namespace FactorySystemApi.Controllers FPlmCode = item.Code, FName = item.Name, //FCode = item.Code, - FType = item.Type.ToLower(), + FType = item.Type!=null? item.Type.ToLower():"", //FTestCode = item.TestNO, FVersionCode = item.Version, FParentID = parentId @@ -539,6 +690,8 @@ namespace FactorySystemApi.Controllers FLevel = materLevel, FBomMaterialID = material.FID }; + + if (material.FType == "a" || material.FType == "f") { material.FType = "20"; @@ -603,13 +756,17 @@ namespace FactorySystemApi.Controllers } } } + if (string.IsNullOrWhiteSpace(item.AMaterialCode)) + { + item.AMaterialCode = "空"; + } item.ABomType = "kg"; - if (item.Name.Contains("@")) + if (item.Name!=null&&item.Name.Contains("@")) { item.EnName = "甜味"; } - else if (item.Name.Contains("□")) + else if (item.Name != null && item.Name.Contains("□")) { item.EnName = "咸味"; } diff --git a/FactorySystemBll/FormulaBll.cs b/FactorySystemBll/FormulaBll.cs index 7933097..3301e55 100644 --- a/FactorySystemBll/FormulaBll.cs +++ b/FactorySystemBll/FormulaBll.cs @@ -29,6 +29,25 @@ namespace FactorySystemBll return AppSettingsHelper.GetSqlSugar().Queryable().Where(s => s.FDeleted != isDelete).Distinct().ToList(); } + + + /// + /// 获取修改配方信息 + /// + public static List GetUpdateFormulaList() + { + return AppSettingsHelper.GetSqlSugar().Queryable().Distinct().OrderByDescending(m=>m.Change_Time).ToList(); + } + + /// + /// 获取修改配方信息更具ID获取 + /// + public static TFS_UpdateFormula GetUpdateFormulaByFID(int fid) + { + return AppSettingsHelper.GetSqlSugar().Queryable().Where(m=>m.FID==fid).Distinct().OrderByDescending(m => m.Change_Time).ToList().LastOrDefault(); + } + + public List GetFormulaListById(int id) { int isDelete = (int)Constant.DeleteCode.已删除; @@ -50,6 +69,23 @@ namespace FactorySystemBll .WhereIF(tr.FName != null, s => s.FName.Contains(tr.FName) || s.FPlmCode.Contains(tr.FPlmCode) || s.FTestCode.Contains(tr.FTestCode) || s.FVersionCode.Contains(tr.FVersionCode)) .Select("*").ToPageList(tr.FPageIndex, tr.FPageSize, ref totalNumber); } + /// + /// 获取配方变更列表 + /// + /// + /// + /// + public List GetUpdateFormulaList(FormulaQuery tr, out int totalNumber) + { + totalNumber = 0; + var db = AppSettingsHelper.GetSqlSugar(); + List list = db.Queryable() + .WhereIF(tr.FPlmCode != null, s => s.SP.Contains(tr.FPlmCode)) + .WhereIF(tr.FTestCode != null, s => s.SP_VALUE.Contains(tr.FTestCode)) + .WhereIF(tr.FStatus != null, s => s.Status.Contains(tr.FStatus)) + .Select("*").ToPageList(tr.FPageIndex, tr.FPageSize, ref totalNumber); + return list; + } /// /// 配方数据比对 @@ -469,5 +505,43 @@ namespace FactorySystemBll return views; } + + /// + /// 新增修改配方表 + /// + /// + /// + public int SevaTFS_UpdateFormula(TFS_UpdateFormula model) + { + SqlSugarClient db = AppSettingsHelper.GetSqlSugar(); + int taskId = -1; + try + { + taskId = db.Insertable(model).IgnoreColumns(true).ExecuteReturnIdentity(); + } + catch (Exception) + { + + taskId = -1; ; + } + return taskId; + } + + public int EditUpdateFormula(TFS_UpdateFormula model) + { + SqlSugarClient db = AppSettingsHelper.GetSqlSugar(); + int taskId = -1; + try + { + //taskId = db.Insertable(model).IgnoreColumns(true).ExecuteReturnIdentity(); + taskId = db.Updateable(model).IgnoreColumns(true).ExecuteCommand(); + } + catch (Exception) + { + + taskId = -1; ; + } + return taskId; + } } } diff --git a/FactorySystemModel/FactorySystemModel.csproj b/FactorySystemModel/FactorySystemModel.csproj index a36b92d..735a36b 100644 --- a/FactorySystemModel/FactorySystemModel.csproj +++ b/FactorySystemModel/FactorySystemModel.csproj @@ -73,6 +73,7 @@ + diff --git a/FactorySystemModel/ResponseModel/FormulaRow.cs b/FactorySystemModel/ResponseModel/FormulaRow.cs index a333c97..ec3d7bf 100644 --- a/FactorySystemModel/ResponseModel/FormulaRow.cs +++ b/FactorySystemModel/ResponseModel/FormulaRow.cs @@ -101,5 +101,10 @@ namespace FactorySystemModel.ResponseModel /// Nullable:False /// public DateTime? FEditDate { get; set; } + + /// + /// 状态 + /// + public string FStatus { get; set; } } } diff --git a/FactorySystemModel/SqlSugarModel/TFS_UpdateFormula.cs b/FactorySystemModel/SqlSugarModel/TFS_UpdateFormula.cs new file mode 100644 index 0000000..64b062f --- /dev/null +++ b/FactorySystemModel/SqlSugarModel/TFS_UpdateFormula.cs @@ -0,0 +1,87 @@ +using System; +using SqlSugar; + +namespace FactorySystemModel.SqlSugarModel +{ + /// + ///配方表 + /// + [SugarTable("TFS_UpdateFormula")] + public partial class TFS_UpdateFormula + { + public TFS_UpdateFormula() + { + + } + /// + /// Desc:唯一标识 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int FID { get; set; } + + /// + /// PLM规格内码 + /// + public string SP { get; set; } + + /// + /// 版本号 + /// + public string SP_VERSION { get; set; } + /// + /// 试验号 + /// + public string SP_VALUE { get; set; } + + /// + /// 配方中文名称 + /// + public string Name { get; set; } + + /// + /// 配方类型 + /// + public string Type { get; set; } + /// + /// 转规格人员 + /// + public string SP_AUTHOR { get; set; } + + /// + /// 变化内容 + /// + public string Change_Content { get; set; } + + /// + /// 变化日期 + /// + public string Change_Time { get; set; } + + /// + /// 受影响其他配方 + /// + public string Change_Other { get; set; } + + /// + /// 描述 + /// + public string Remark { get; set; } + + /// + /// 状态 + /// + public string Status { get; set; } + + /// + /// 修改日期 + /// + public string Update_Time { get; set; } + + /// + /// 修改人 + /// + public string Update_User { get; set; } + } +}