From 1e45df12ddfc5c50a0ba52764a6ca5af946c740e Mon Sep 17 00:00:00 2001 From: wenjy Date: Mon, 30 Oct 2023 16:06:28 +0800 Subject: [PATCH] =?UTF-8?q?add=20-=20=E7=89=A9=E6=96=99=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Durkee.Mes.Api.Common.csproj | 7 + Durkee.Mes.Api.Common/ExpressionExtensions.cs | 150 +++++++++ .../domain/BaseMaterialInfo.cs | 284 ++++++++++++++++++ .../Durkee.Mes.Api.Repository.csproj | 1 + Durkee.Mes.Api.Repository/SqlsugarSetup.cs | 4 +- .../service/IBaseMaterialService.cs | 39 +++ .../service/IBaseUserService.cs | 7 + .../service/Impl/BaseMaterialServiceImpl.cs | 108 +++++++ .../service/Impl/BaseUserServiceImpl.cs | 18 ++ Durkee.Mes.Api.sln | 8 +- .../Controllers/BaseMaterialInfoController.cs | 87 ++++++ .../Controllers/BaseUserController.cs | 7 +- Durkee.Mes.Api/Controllers/JobController.cs | 12 + Durkee.Mes.Api/Startup.cs | 2 +- Durkee.Mes.Api/appsettings.json | 2 +- 15 files changed, 728 insertions(+), 8 deletions(-) create mode 100644 Durkee.Mes.Api.Common/Durkee.Mes.Api.Common.csproj create mode 100644 Durkee.Mes.Api.Common/ExpressionExtensions.cs create mode 100644 Durkee.Mes.Api.Model/domain/BaseMaterialInfo.cs create mode 100644 Durkee.Mes.Api.Repository/service/IBaseMaterialService.cs create mode 100644 Durkee.Mes.Api.Repository/service/Impl/BaseMaterialServiceImpl.cs create mode 100644 Durkee.Mes.Api/Controllers/BaseMaterialInfoController.cs diff --git a/Durkee.Mes.Api.Common/Durkee.Mes.Api.Common.csproj b/Durkee.Mes.Api.Common/Durkee.Mes.Api.Common.csproj new file mode 100644 index 0000000..cb63190 --- /dev/null +++ b/Durkee.Mes.Api.Common/Durkee.Mes.Api.Common.csproj @@ -0,0 +1,7 @@ + + + + netcoreapp3.1 + + + diff --git a/Durkee.Mes.Api.Common/ExpressionExtensions.cs b/Durkee.Mes.Api.Common/ExpressionExtensions.cs new file mode 100644 index 0000000..b9a6ab0 --- /dev/null +++ b/Durkee.Mes.Api.Common/ExpressionExtensions.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; + +namespace Durkee.Mes.Api.Common +{ + /// + /// 谓词表达式构建器 + /// + public static class ExpressionExtensions + { + /// + /// 创建一个值恒为 true 的表达式。 + /// + /// 表达式方法类型 + /// 一个值恒为 true 的表达式。 + public static Expression> True() { return p => true; } + + /// + /// 创建一个值恒为 false 的表达式。 + /// + /// 表达式方法类型 + /// 一个值恒为 false 的表达式。 + public static Expression> False() { return f => false; } + + /// + /// 使用 Expression.OrElse 的方式拼接两个 System.Linq.Expression。 + /// + /// 表达式方法类型 + /// 左边的 System.Linq.Expression 。 + /// 右边的 System.Linq.Expression。 + /// 拼接完成的 System.Linq.Expression。 + public static Expression Or(this Expression left, Expression right) + { + return MakeBinary(left, right, Expression.OrElse); + } + + /// + /// 使用 Expression.AndAlso 的方式拼接两个 System.Linq.Expression。 + /// + /// 表达式方法类型 + /// 左边的 System.Linq.Expression 。 + /// 右边的 System.Linq.Expression。 + /// 拼接完成的 System.Linq.Expression。 + public static Expression And(this Expression left, Expression right) + { + return MakeBinary(left, right, Expression.AndAlso); + } + + /// + /// 使用自定义的方式拼接两个 System.Linq.Expression。 + /// + /// 表达式方法类型 + /// 左边的 System.Linq.Expression 。 + /// 右边的 System.Linq.Expression。 + /// + /// 拼接完成的 System.Linq.Expression。 + private static Expression MakeBinary(this Expression left, Expression right, Func func) + { + return MakeBinary((LambdaExpression)left, right, func) as Expression; + } + + /// + /// 拼接两个 + /// System.Linq.Expression + /// ,两个 + /// System.Linq.Expression + /// 的参数必须完全相同。 + /// + /// 左边的 + /// System.Linq.Expression + /// + /// 右边的 + /// System.Linq.Expression + /// + /// 表达式拼接的具体逻辑 + /// 拼接完成的 + /// System.Linq.Expression + /// + private static LambdaExpression MakeBinary(this LambdaExpression left, LambdaExpression right, Func func) + { + var data = Combinate(right.Parameters, left.Parameters).ToArray(); + + right = ParameterReplace.Replace(right, data) as LambdaExpression; + + return Expression.Lambda(func(left.Body, right.Body), left.Parameters.ToArray()); + } + + /// + /// 合并参数 + /// + /// + /// + /// + /// + private static IEnumerable> Combinate(IEnumerable left, IEnumerable right) + { + var a = left.GetEnumerator(); + var b = right.GetEnumerator(); + while (a.MoveNext() && b.MoveNext()) + yield return new KeyValuePair(a.Current, b.Current); + } + } + + internal sealed class ParameterReplace : ExpressionVisitor + { + public static Expression Replace(Expression e, IEnumerable> paramList) + { + var item = new ParameterReplace(paramList); + return item.Visit(e); + } + + private readonly Dictionary _parameters; + + public ParameterReplace(IEnumerable> paramList) + { + _parameters = paramList.ToDictionary(p => p.Key, p => p.Value, new ParameterEquality()); + } + + protected override Expression VisitParameter(ParameterExpression p) + { + ParameterExpression result; + if (_parameters.TryGetValue(p, out result)) + return result; + return base.VisitParameter(p); + } + + #region class: ParameterEquality + private class ParameterEquality : IEqualityComparer + { + public bool Equals(ParameterExpression x, ParameterExpression y) + { + if (x == null || y == null) + return false; + + return x.Type == y.Type; + } + + public int GetHashCode(ParameterExpression obj) + { + if (obj == null) + return 0; + + return obj.Type.GetHashCode(); + } + } + #endregion + } +} \ No newline at end of file diff --git a/Durkee.Mes.Api.Model/domain/BaseMaterialInfo.cs b/Durkee.Mes.Api.Model/domain/BaseMaterialInfo.cs new file mode 100644 index 0000000..2c09844 --- /dev/null +++ b/Durkee.Mes.Api.Model/domain/BaseMaterialInfo.cs @@ -0,0 +1,284 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using System.Xml.Linq; + +namespace Durkee.Mes.Api.Model.domain +{ + [SugarTable("BasMaterial"), TenantAttribute("mes")] + [DataContract(Name = "BasMaterial 物料信息")] + public class BaseMaterialInfo + { + /// + /// + /// + [SugarColumn(ColumnName = "ObjID", IsPrimaryKey = true)] + public int ObjID { get; set; } + /// + /// 大类+小类+规格+胶代码或最后4顺序号 + /// + [SugarColumn(ColumnName = "MaterialCode")] + public string MaterialCode { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "MajorTypeID")] + public int? MajorTypeID { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "MinorTypeID")] + public string MinorTypeID { get; set; } + /// + /// + /// 默认值: ('') + /// + [SugarColumn(ColumnName = "RubCode")] + public string RubCode { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "MaterialName")] + public string MaterialName { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "MaterialOtherName")] + public string MaterialOtherName { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "MaterialSimpleName")] + public string MaterialSimpleName { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "ProductMaterialCode")] + public string ProductMaterialCode { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "MaterialLevel")] + public string MaterialLevel { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "MaterialGroup")] + public string MaterialGroup { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "UserCode")] + public string UserCode { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "PlanPrice")] + public decimal? PlanPrice { get; set; } + /// + /// 具体到县级市,长度为6,国外的只具体国家 + /// + [SugarColumn(ColumnName = "ProductArea")] + public string ProductArea { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "MinStock")] + public decimal? MinStock { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "MaxStock")] + public decimal? MaxStock { get; set; } + /// + /// 千克,克,块,桶,升 + /// + [SugarColumn(ColumnName = "UnitID")] + public int? UnitID { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "StaticUnitID")] + public int? StaticUnitID { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "StaticUnitCoefficient")] + public decimal? StaticUnitCoefficient { get; set; } + /// + /// 显为百分比 + /// + [SugarColumn(ColumnName = "CheckPermitError")] + public decimal? CheckPermitError { get; set; } + /// + /// 按小时计算 + /// + [SugarColumn(ColumnName = "MaxParkTime")] + public decimal? MaxParkTime { get; set; } + /// + /// 小时计算 + /// + [SugarColumn(ColumnName = "MinParkTime")] + public decimal? MinParkTime { get; set; } + /// + /// + /// 默认值: (getdate()) + /// + [SugarColumn(ColumnName = "DefineDate")] + public DateTime? DefineDate { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "StandardCode")] + public string StandardCode { get; set; } + /// + /// + /// 默认值: ((1)) + /// + [SugarColumn(ColumnName = "StaticClass")] + public int? StaticClass { get; set; } + /// + /// + /// 默认值: ((0)) + /// + [SugarColumn(ColumnName = "IsEqualMaterial")] + public string IsEqualMaterial { get; set; } + /// + /// + /// 默认值: ((0)) + /// + [SugarColumn(ColumnName = "IsPutJar")] + public string IsPutJar { get; set; } + /// + /// + /// 默认值: ((1)) + /// + [SugarColumn(ColumnName = "IsQualityRateCount")] + public string IsQualityRateCount { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "ERPCode")] + public string ERPCode { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "Remark")] + public string Remark { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "DeleteFlag")] + public string DeleteFlag { get; set; } + /// + /// + /// 默认值: ((0)) + /// + [SugarColumn(ColumnName = "ValidDate")] + public decimal ValidDate { get; set; } + /// + /// + /// 默认值: ((0)) + /// + [SugarColumn(ColumnName = "ValidDateB")] + public decimal ValidDateB { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "SAPMaterialCode")] + public string SAPMaterialCode { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "SAPMaterialShortCode")] + public string SAPMaterialShortCode { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "ERPCode_Bak")] + public string ErpcodeBak { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "OperSourceTemp")] + public string OperSourceTemp { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "IsQualityrateCountBak")] + public int? IsQualityrateCountBak { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "CMaterialLevel")] + public string CMaterialLevel { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "CMaterialGroup")] + public string CMaterialGroup { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "XBStock")] + public decimal? XBStock { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "HFCode")] + public string HFCode { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "HFCode2")] + public string HFCode2 { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "UNITName")] + public string UNITName { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "KFACSTATUS")] + public string Kfacstatus { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "Ordertype")] + public string Ordertype { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "CreateDate")] + public string CreateDate { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "UpdateDate")] + public string UpdateDate { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "UnAudit")] + public string UnAudit { get; set; } + /// + /// + /// + [SugarColumn(ColumnName = "ChkStand")] + public string ChkStand { get; set; } + /// + /// 1 KG 2 PC 3 标准KG + /// 默认值: ((1)) + /// + [SugarColumn(ColumnName = "SapUpUnit")] + public int? SapUpUnit { get; set; } + /// + /// 是否为轨道事业部物料:0:不是,1:是 + /// + [SugarColumn(ColumnName = "IsGDMaterial")] + public int? IsGDMaterial { get; set; } + } +} diff --git a/Durkee.Mes.Api.Repository/Durkee.Mes.Api.Repository.csproj b/Durkee.Mes.Api.Repository/Durkee.Mes.Api.Repository.csproj index a6d9e85..554efce 100644 --- a/Durkee.Mes.Api.Repository/Durkee.Mes.Api.Repository.csproj +++ b/Durkee.Mes.Api.Repository/Durkee.Mes.Api.Repository.csproj @@ -13,6 +13,7 @@ + diff --git a/Durkee.Mes.Api.Repository/SqlsugarSetup.cs b/Durkee.Mes.Api.Repository/SqlsugarSetup.cs index 59d9c29..ef99f4e 100644 --- a/Durkee.Mes.Api.Repository/SqlsugarSetup.cs +++ b/Durkee.Mes.Api.Repository/SqlsugarSetup.cs @@ -58,8 +58,10 @@ namespace Durkee.Mes.Api.Repository /// public static void AddServices(this IServiceCollection services) { - services.AddSingleton>(); + //services.AddSingleton>(); + services.AddSingleton(typeof(Repository<>)); services.AddSingleton(); + services.AddSingleton(); } } } diff --git a/Durkee.Mes.Api.Repository/service/IBaseMaterialService.cs b/Durkee.Mes.Api.Repository/service/IBaseMaterialService.cs new file mode 100644 index 0000000..4857fd1 --- /dev/null +++ b/Durkee.Mes.Api.Repository/service/IBaseMaterialService.cs @@ -0,0 +1,39 @@ +using Durkee.Mes.Api.Model.domain; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Durkee.Mes.Api.Repository.service +{ + public interface IBaseMaterialService + { + + /// + /// 获取所有的物料信息 + /// + /// + List GetMaterialInfos(); + + /// + /// 通过物料编码获取物料信息 + /// + /// + /// + BaseMaterialInfo GetMaterialInfoByMaterialCode(string materialCode); + + /// + /// 通过SAP物料编码获取物料信息 + /// + /// + /// + BaseMaterialInfo GetMaterialInfoBySapMaterialCode(string sapMaterialCode); + + /// + /// 通过物料类别获取物料信息 + /// + /// 物料大类 + /// 物料细类 + /// + List GetMaterialInfosByMaterialType(int majorTypeId,string minorTypeId); + } +} diff --git a/Durkee.Mes.Api.Repository/service/IBaseUserService.cs b/Durkee.Mes.Api.Repository/service/IBaseUserService.cs index 9a7b21f..81019a8 100644 --- a/Durkee.Mes.Api.Repository/service/IBaseUserService.cs +++ b/Durkee.Mes.Api.Repository/service/IBaseUserService.cs @@ -12,5 +12,12 @@ namespace Durkee.Mes.Api.Repository.service /// /// List GetUsers(); + + /// + /// 验证添加用户信息,有一个错误时进行回滚 + /// + /// + /// + bool InsertUsers(List users); } } diff --git a/Durkee.Mes.Api.Repository/service/Impl/BaseMaterialServiceImpl.cs b/Durkee.Mes.Api.Repository/service/Impl/BaseMaterialServiceImpl.cs new file mode 100644 index 0000000..63fd2bd --- /dev/null +++ b/Durkee.Mes.Api.Repository/service/Impl/BaseMaterialServiceImpl.cs @@ -0,0 +1,108 @@ +using Durkee.Mes.Api.Common; +using Durkee.Mes.Api.Model.domain; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text; + +namespace Durkee.Mes.Api.Repository.service.Impl +{ + public class BaseMaterialServiceImpl : IBaseMaterialService + { + private Repository _repository; + + private ILogger _logger; + + public BaseMaterialServiceImpl(Repository repository,ILogger logger) + { + _repository = repository; + _logger = logger; + } + + /// + /// 通过物料编码获取物料信息 + /// + /// + /// + public BaseMaterialInfo GetMaterialInfoByMaterialCode(string materialCode) + { + BaseMaterialInfo materialInfo = null; + try + { + materialInfo = _repository.GetFirst(x=>x.MaterialCode == materialCode); + }catch (Exception ex) + { + _logger.LogError($"根据物料编号获取物料信息异常:{ex.Message}"); + } + return materialInfo; + } + + /// + /// 通过SAP物料编码获取物料信息 + /// + /// + /// + public BaseMaterialInfo GetMaterialInfoBySapMaterialCode(string sapMaterialCode) + { + BaseMaterialInfo materialInfo = null; + try + { + materialInfo = _repository.GetFirst(x => x.SAPMaterialCode == sapMaterialCode); + } + catch (Exception ex) + { + _logger.LogError($"根据SAP物料编号获取物料信息异常:{ex.Message}"); + } + return materialInfo; + } + + /// + /// 获取所有的物料信息 + /// + /// + public List GetMaterialInfos() + { + List materialInfos = null; + try + { + materialInfos = _repository.GetList(); + } + catch (Exception ex) + { + _logger.LogError($"获取物料信息异常:{ex.Message}"); + } + return materialInfos; + } + + /// + /// 通过物料类别获取物料信息 + /// + /// 物料大类 + /// 物料细类 + /// + public List GetMaterialInfosByMaterialType(int majorTypeId, string minorTypeId) + { + List materialInfos = null; + try + { + Expression> exp = x => true; + + if(majorTypeId != 0) + { + exp = exp.And(x=>x.MajorTypeID == majorTypeId); + }else if (!string.IsNullOrEmpty(minorTypeId)) + { + exp = exp.And(x=>x.MinorTypeID == minorTypeId); + } + + materialInfos = _repository.GetList(exp); + } + catch (Exception ex) + { + _logger.LogError($"通过物料类型获取物料信息异常:{ex.Message}"); + } + return materialInfos; + } + } +} diff --git a/Durkee.Mes.Api.Repository/service/Impl/BaseUserServiceImpl.cs b/Durkee.Mes.Api.Repository/service/Impl/BaseUserServiceImpl.cs index 013f691..d89051e 100644 --- a/Durkee.Mes.Api.Repository/service/Impl/BaseUserServiceImpl.cs +++ b/Durkee.Mes.Api.Repository/service/Impl/BaseUserServiceImpl.cs @@ -31,5 +31,23 @@ namespace Durkee.Mes.Api.Repository.service.Impl } return users; } + + public bool InsertUsers(List users) + { + bool result = false; + try + { + _rep.AsTenant().BeginTran(); + + result = _rep.InsertRange(users); + + _rep.AsTenant().CommitTran(); + }catch(Exception ex) + { + _rep.AsTenant().RollbackTran(); + _logger.LogError($"用户信息添加异常:{ex.Message}"); + } + return result; + } } } diff --git a/Durkee.Mes.Api.sln b/Durkee.Mes.Api.sln index e5acf60..5f92b13 100644 --- a/Durkee.Mes.Api.sln +++ b/Durkee.Mes.Api.sln @@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Durkee.Mes.Api.Repository", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Durkee.Mes.Api.Model", "Durkee.Mes.Api.Model\Durkee.Mes.Api.Model.csproj", "{28400313-5B3D-412C-94F4-3DCCF5FDAEE3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Durkee.Mes.Api.Quartz", "Durkee.Mes.Api.Quartz\Durkee.Mes.Api.Quartz.csproj", "{0AC0188D-548A-428C-8FFC-164F53A5607F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Durkee.Mes.Api.Quartz", "Durkee.Mes.Api.Quartz\Durkee.Mes.Api.Quartz.csproj", "{0AC0188D-548A-428C-8FFC-164F53A5607F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Durkee.Mes.Api.Common", "Durkee.Mes.Api.Common\Durkee.Mes.Api.Common.csproj", "{0C072D94-3DA2-4E8F-896C-47537D1DFAA0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,6 +41,10 @@ Global {0AC0188D-548A-428C-8FFC-164F53A5607F}.Debug|Any CPU.Build.0 = Debug|Any CPU {0AC0188D-548A-428C-8FFC-164F53A5607F}.Release|Any CPU.ActiveCfg = Release|Any CPU {0AC0188D-548A-428C-8FFC-164F53A5607F}.Release|Any CPU.Build.0 = Release|Any CPU + {0C072D94-3DA2-4E8F-896C-47537D1DFAA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0C072D94-3DA2-4E8F-896C-47537D1DFAA0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0C072D94-3DA2-4E8F-896C-47537D1DFAA0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0C072D94-3DA2-4E8F-896C-47537D1DFAA0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Durkee.Mes.Api/Controllers/BaseMaterialInfoController.cs b/Durkee.Mes.Api/Controllers/BaseMaterialInfoController.cs new file mode 100644 index 0000000..6331b6b --- /dev/null +++ b/Durkee.Mes.Api/Controllers/BaseMaterialInfoController.cs @@ -0,0 +1,87 @@ +using Durkee.Mes.Api.Model.domain; +using Durkee.Mes.Api.Repository.service; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System.Collections.Generic; +using System; + +namespace Durkee.Mes.Api.Controllers +{ + /// + /// 物料信息 + /// + [Route("api/[controller]")] + [ApiController] + public class BaseMaterialInfoController + { + private ILogger _logger; + + private IBaseMaterialService _service; + + public BaseMaterialInfoController(ILogger logger, IBaseMaterialService service) + { + _logger = logger; + _service = service; + } + + /// + /// 获取物料信息 + /// + /// + [HttpGet] + public IEnumerable Get() + { + IEnumerable materialInfos = null; + try + { + materialInfos = _service.GetMaterialInfos(); + } + catch (Exception ex) + { + _logger.LogError($"获取物料信息接口调用异常:{ex.Message}"); + } + return materialInfos; + } + + /// + /// 根据物料编号获取物料信息 + /// + /// 物料编号 + /// + [HttpGet("Get/{materialCode}")] + public BaseMaterialInfo GetMaterialInfoByMaterialCode(string materialCode) + { + BaseMaterialInfo materialInfo = null; + try + { + materialInfo = _service.GetMaterialInfoByMaterialCode(materialCode); + } + catch (Exception ex) + { + _logger.LogError($"根据物料编号获取物料信息接口调用异常:{ex.Message}"); + } + return materialInfo; + } + + /// + /// 通过物料类别获取物料信息 + /// + /// 物料大类 + /// 物料细类 + /// + [HttpGet("Get/{majorTypeId}/{minorTypeId}")] + public IEnumerable GetMaterialInfosByMaterialType(int majorTypeId, string minorTypeId) + { + IEnumerable materialInfos = null; + try + { + materialInfos = _service.GetMaterialInfosByMaterialType(majorTypeId,minorTypeId); + } + catch (Exception ex) + { + _logger.LogError($"通过物料类别获取物料信息接口调用异常:{ex.Message}"); + } + return materialInfos; + } + } +} diff --git a/Durkee.Mes.Api/Controllers/BaseUserController.cs b/Durkee.Mes.Api/Controllers/BaseUserController.cs index f1cea39..7a11897 100644 --- a/Durkee.Mes.Api/Controllers/BaseUserController.cs +++ b/Durkee.Mes.Api/Controllers/BaseUserController.cs @@ -71,13 +71,12 @@ namespace Durkee.Mes.Api.Controllers /// /// 添加用户信息 /// - /// 用户信息 + /// 用户列表 /// [HttpPut] - public bool InsertUserInfo(BaseUser user) + public bool InsertUserInfo(List users) { - var info = user; - return true; + return _service.InsertUsers(users); } } } diff --git a/Durkee.Mes.Api/Controllers/JobController.cs b/Durkee.Mes.Api/Controllers/JobController.cs index 1cb2518..f86fef7 100644 --- a/Durkee.Mes.Api/Controllers/JobController.cs +++ b/Durkee.Mes.Api/Controllers/JobController.cs @@ -21,6 +21,12 @@ namespace Durkee.Mes.Api.Controllers _scheduler = scheduler; } + /// + /// 启动任务 + /// + /// 任务名称 + /// 任务分组 + /// [HttpPost("start")] public async Task StartJob(string jobName,string groupName) { @@ -36,6 +42,12 @@ namespace Durkee.Mes.Api.Controllers return "Job started successfully."; } + /// + /// 停止任务 + /// + /// 任务名称 + /// 任务分组 + /// [HttpPost("stop")] public async Task StopJob(string jobName, string groupName) { diff --git a/Durkee.Mes.Api/Startup.cs b/Durkee.Mes.Api/Startup.cs index 84d58bd..4ddff38 100644 --- a/Durkee.Mes.Api/Startup.cs +++ b/Durkee.Mes.Api/Startup.cs @@ -117,7 +117,7 @@ namespace Durkee.Mes.Api endpoints.MapControllers(); }); - Log.Information($"Ŀʼ,־·{logPath}"); + Log.Information($"Ŀʼ,־·{appConfig.logPath}"); } } diff --git a/Durkee.Mes.Api/appsettings.json b/Durkee.Mes.Api/appsettings.json index 8ba2674..990e4e3 100644 --- a/Durkee.Mes.Api/appsettings.json +++ b/Durkee.Mes.Api/appsettings.json @@ -8,7 +8,7 @@ }, "AllowedHosts": "*", "AppConfig": { - "logPath": "E:/代码生成/日志信息", + "logPath": "E:\\桌面\\杜肯密炼MES项目\\日志信息", "mesConnStr": "server=.;uid=sa;pwd=123456;database=JiangYinMENS", "mcsConnStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma" }