فهرست منبع

合并冲突解决

Murphy 2 سال پیش
والد
کامیت
899ccffb46

+ 3 - 0
.gitignore

@@ -2143,3 +2143,6 @@ MicroServices/Business/Bussiness.MongoModel/bin/Debug/net6.0/Business.MongoModel
 /MicroServices/Business/Bussiness.EntityFrameworkCore.Test/bin/Release/net6.0
 /MicroServices/Procurement/Procurement.Core/obj/Debug/net6.0
 /MicroServices/Procurement/Procurement.Application.Contracts/obj/Debug/net6.0
+/MicroServices/Procurement/Procurement.Core/obj/Debug/net6.0
+/MicroServices/Procurement/Procurement.Application.Contracts/obj/Debug/net6.0
+/MicroServices/Procurement/Procurement.Host/obj

+ 4 - 4
MicroServices/Business/Business.Application/PriorityManagement/PriorityAppService.cs

@@ -31,13 +31,13 @@ namespace Business.PriorityManagement
                 level = p.custom_level.GetValueOrDefault()
             }).AsQueryable<PriorityDto>().ToList(); 
             
-            //子表数据处理:根据订单id分组取出客户要求交期交期最的数据
+            //子表数据处理:根据订单id分组取出客户要求交期交期最的数据
             var entrys = from t in sentrys
                          group t by t.seorder_id into temp
                          select new
                          {
                              id = temp.Key,
-                             plan_date = temp.Max(x => x.plan_date.GetValueOrDefault())
+                             plan_date = temp.Min(x => x.plan_date.GetValueOrDefault())
                          };
             foreach (var item in dtos)
             {
@@ -75,13 +75,13 @@ namespace Business.PriorityManagement
                 level = p.custom_level.GetValueOrDefault()
             }).AsQueryable<PriorityDto>().ToList();
 
-            //子表数据处理:根据订单id分组取出客户要求交期交期最的数据
+            //子表数据处理:根据订单id分组取出客户要求交期交期最的数据
             var entrys = from t in sentrys
                          group t by t.seorder_id into temp
                          select new
                          {
                              id = temp.Key,
-                             plan_date = temp.Max(x => x.plan_date.GetValueOrDefault())
+                             plan_date = temp.Min(x => x.plan_date.GetValueOrDefault())
                          };
             foreach (var item in dtos)
             {

+ 4 - 0
MicroServices/Business/Business.Application/ResourceExamineManagement/CalcBomViewAppService.cs

@@ -379,6 +379,10 @@ namespace Business.ResourceExamineManagement
                         mes_Morders.morder_need_time = ProductiveDate;
                         //满足资源检查的时间需加上提前期
                         level1Dto.satisfy_time = mes_Morders.moentry_sys_stime.Value.AddDays((double)LeadTime);
+                        if (sentrys != null)
+                        {
+                            sentrys.sys_capacity_date = level1Dto.satisfy_time;
+                        }
                     }
                     level1Dto.make_list = new List<moorder>();
                     mes_MorderDto.mes_Morders.ForEach(me =>

+ 10 - 4
MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs

@@ -479,6 +479,9 @@ namespace Business.ResourceExamineManagement
             //获取订单行数据
             List<crm_seorderentry> sentrys = await _mysql_crm_seorderentry.GetListAsync(p => p.tenant_id == input.tenantId && p.factory_id == input.factoryId && input.sorderId.Contains(p.seorder_id.GetValueOrDefault()) && !p.IsDeleted);
 
+            //处理订单行优先级
+            sentrys = _priorityAppService.CalcOrderEntryPriority(sorders, sentrys);
+
             //删除同步Mysql后旧数据
             await DeleteMySqlOldData(sentrys);
 
@@ -521,7 +524,8 @@ namespace Business.ResourceExamineManagement
                 _purchaseOrderAppService.param = param;
                 _CalcBomViewAppService.param = param;
                 _CalcBomViewAppService.seorder = sorder;//销售订单
-                foreach (var item in sentrys)
+                var orderSentrys = sentrys.Where(s => s.seorder_id == sorder.Id).ToList();
+                foreach (var item in orderSentrys)
                 {
                     //获取销售订单“是否加急”字段
                     int urgent = sorder.urgent;
@@ -560,14 +564,16 @@ namespace Business.ResourceExamineManagement
                     dtl.kitting_times = getBomList.Where(p => p.is_use).OrderByDescending(m => m.kitting_time).First().kitting_time.GetValueOrDefault();
                     //TODO:最早开始时间默认3天后(后期调整,因为要计算排产,计算产能这一类,才能得到开工时间)
                     dtl.earliest_times = dtl.kitting_times.AddDays(1);
-
+                    item.progress = "2";
                     //替代关系展开list
                     dtl.BomChildExamineList = getBomList;
                     //添加订单行开工信息
                     examines.Add(dtl);
                 }
             }
-            
+
+            await _mysql_crm_seorderentry.UpdateManyAsync(sentrys);
+
             //批量保存 后期考虑子工单
             if (_CalcBomViewAppService.mordersInsertList.Any())
             {
@@ -2047,7 +2053,7 @@ namespace Business.ResourceExamineManagement
                 workOrd.Status = "r";
                 workOrd.IsActive = true;
                 workOrd.ProdLine = "组装线";
-
+                workOrd.IsConfirm = true;
                 workOrds.Add(workOrd);
 
                 //添加工单工艺路线数据

+ 6 - 0
MicroServices/Business/Bussiness.Model/Production/WorkOrdMaster.cs

@@ -93,5 +93,11 @@ namespace Business.Model.Production
         /// </summary>
         [Comment("状态")]
         public string? ProdLine { get; set; }
+
+        /// <summary>
+        /// 确认
+        /// </summary>
+        [Comment("确认")]
+        public Boolean IsConfirm { get; set; }
     }
 }

+ 2 - 2
MicroServices/Procurement/Procurement.Application/ProcurementManagement/ProcurementAppService.cs

@@ -56,8 +56,8 @@ namespace Procurement.FileManagement
             //限制100M
             if (file.Length > 104857600)
             {
-                new NLogHelper("ProcurementAppService").WriteLog("Upload", "上传文件过大",NLog.LogLevel.Error,_currentTenant.Id.ToString());
-                NLogHelper.Default.WriteLog("Upload", "上传文件过大", _currentTenant.Id.ToString());
+                //new NLogHelper("ProcurementAppService").WriteLog("Upload", "上传文件过大",NLog.LogLevel.Error,_currentTenant.Id.ToString());
+                //NLogHelper.Default.WriteLog("Upload", "上传文件过大", _currentTenant.Id.ToString());
                 throw new BusinessException("上传文件过大");
             }
             //文件格式

+ 20 - 46
MicroServices/Procurement/Procurement.Core/NLogHelper.cs

@@ -7,64 +7,38 @@ namespace Procurement.Core
     /// </summary>
     public class NLogHelper
     {
-        #region 初始化
-        readonly Logger _logger;
-
-        private NLogHelper(Logger logger)
-        {
-            this._logger = logger;
-        }
-
-        /// <summary>
-        /// 自定义Logger,否则用默认的GetCurrentClassLogger
-        /// </summary>
-        /// <param name="name"></param>
-        public NLogHelper(string name) : this(LogManager.GetLogger(name))
-        {
-        }
+        static Logger logger = LogManager.GetCurrentClassLogger();
 
         /// <summary>
-        /// 默认 ${logger} (Default 文件夹下)
+        /// 写日志
         /// </summary>
-        public static NLogHelper Default { get; private set; }
-        static NLogHelper()
+        /// <param name="type">类别</param>
+        /// <param name="action">动作</param>
+        /// <param name="message">消息</param>
+        public static void Info(string type, string action, string message)
         {
-            Default = new NLogHelper(LogManager.GetCurrentClassLogger());
+            Log(LogLevel.Info, type, action, message);
         }
-        #endregion
 
         /// <summary>
-        /// 日志写入,默认info等级
+        /// 写错误日志
         /// </summary>
-        /// <param name="ModuleName">模块名称</param>
-        /// <param name="Msg">日志内容</param>
-        /// <param name="TenantId">租户Id</param>
-        public void WriteLog(string ModuleName,string Msg,string TenantId="")
+        /// <param name="type">类别</param>
+        /// <param name="action">动作</param>
+        /// <param name="message">消息</param>
+        public static void Error(string type, string action, string message)
         {
-            LogEventInfo logEventInfo=new LogEventInfo();
-            logEventInfo.Properties["ModuleName"] = ModuleName;
-            logEventInfo.Properties["Msg"] = Msg;
-            logEventInfo.Properties["TenantId"] = TenantId;
-            logEventInfo.Level = LogLevel.Info;
-            _logger.Log(logEventInfo);
+            Log(LogLevel.Error, type, action, message);
         }
 
-        /// <summary>
-        /// 日志写入,自己传日志类别
-        /// </summary>
-        /// <param name="ModuleName">模块名称</param>
-        /// <param name="Msg">日志内容</param>
-        /// <param name="Level">日志级别</param>
-        /// <param name="TenantId">租户Id</param>
-        public void WriteLog(string ModuleName, string Msg,LogLevel Level, string TenantId = "")
+        private static void Log(LogLevel level, string type, string action, string message)
         {
-            
-            LogEventInfo logEventInfo = new LogEventInfo();
-            logEventInfo.Properties["ModuleName"] = ModuleName;
-            logEventInfo.Properties["Msg"] = Msg;
-            logEventInfo.Properties["TenantId"] = TenantId;
-            logEventInfo.Level = Level;
-            _logger.Log(logEventInfo);
+            LogEventInfo lei = new LogEventInfo();
+            lei.Properties["Type"] = type;
+            lei.Properties["Action"] = action;
+            lei.Message = message;
+            lei.Level = level;
+            logger.Log(lei);
         }
     }
 }

+ 72 - 0
MicroServices/Procurement/Procurement.Host/Controllers/Sync/ModuleCallbackController.cs

@@ -0,0 +1,72 @@
+using Procurement.Enums;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Threading.Tasks;
+using Volo.Abp.AspNetCore.Mvc;
+using Procurement.EntityFrameworkCore.SqlRepositories;
+using Procurement.ViewModel;
+using Procurement.Helpers;
+using System.Text.Json;
+using System.Data.SqlClient;
+using Procurement.Core;
+using Newtonsoft.Json.Linq;
+
+namespace Procurement.Controllers
+{
+    [Produces("application/json")]
+    [Route("api/[controller]")]
+    public class ModuleCallbackController : AbpController
+    {
+        private readonly ISqlRepository _repository;
+        private string logType = "ModuleCallback";
+
+        public ModuleCallbackController(ISqlRepository sqlRepository)
+        {
+            _repository = sqlRepository;
+        }
+
+        /// <summary>
+        /// 接收IQC检验结果
+        /// </summary>
+        /// <returns></returns>
+        [Route("iqcresult")]
+        [HttpPost]
+        public async Task<IActionResult> SaveIQCResult([FromBody] JsonElement jsonElement)
+        {
+            if (jsonElement.ValueKind == JsonValueKind.Undefined || jsonElement.ValueKind == JsonValueKind.Null)
+            {
+                return BadRequest();
+            }
+
+            string reqMethod = HttpContext.Request.Method.ToString().ToUpper();
+            string traceId = DateTime.Now.ToString("yyyyMMddHHmmssfff");
+            string logAction = "IQCResult";
+            NLogHelper.Info(logType, logAction, $"收到{reqMethod}请求:RecID_{traceId}|{jsonElement.ToString()}");
+
+            ResultCode code = ResultCode.Fail, subCode = ResultCode.Fail;
+            string subMsg = "";
+            try
+            {
+                string proc = "pr_WMS_SaveIQCResult";
+                SqlParameter[] sqlParams = SqlHelper.CreateSqlParameters(jsonElement);
+                var resultData = await _repository.GetResultByProcAsync(proc, sqlParams);
+                subMsg = resultData.msg;
+                if (resultData.isSuccess)
+                {
+                    code = ResultCode.Success;
+                    subCode = ResultCode.Success;
+                }
+            }
+            catch (Exception ex)
+            {
+                subMsg = ex.Message;
+                code = ResultCode.Fail;
+                subCode = ResultCode.Fail;
+            }
+            ResultViewModel result = ResultHelper.CreateResult(code, null, subCode, subMsg);
+            NLogHelper.Info(logType, logAction, $"处理结果:RecID_{traceId}|{subMsg}");
+            return Ok(result);
+        }
+
+    }
+}

+ 7 - 0
MicroServices/Procurement/Procurement.Host/Procurement.Host.csproj

@@ -32,7 +32,14 @@
   </ItemGroup>
 
   <ItemGroup>
+    <Folder Include="Controllers\Sync\" />
     <Folder Include="wwwroot\Images\" />
   </ItemGroup>
 
+  <ItemGroup>
+    <Content Update="nlog.config">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+
 </Project>

+ 1 - 1
MicroServices/Procurement/Procurement.Host/Procurement.Host.csproj.user

@@ -5,7 +5,7 @@
   </PropertyGroup>
   <PropertyGroup>
     <ActiveDebugProfile>Procurement.Host</ActiveDebugProfile>
-    <NameOfLastUsedPublishProfile>FolderProfile</NameOfLastUsedPublishProfile>
+    <NameOfLastUsedPublishProfile>E:\ProjectZZY\DOPCore\MicroServices\Procurement\Procurement.Host\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
     <ShowAllFiles>false</ShowAllFiles>
   </PropertyGroup>
 </Project>

+ 25 - 22
MicroServices/Procurement/Procurement.Host/Program.cs

@@ -3,6 +3,7 @@ using System.IO;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Hosting;
+using NLog.Web;
 using Serilog;
 using Serilog.Events;
 
@@ -12,39 +13,40 @@ namespace Procurement
     {
         public static int Main(string[] args)
         {
-            var configuration = new ConfigurationBuilder()
-                .SetBasePath(Directory.GetCurrentDirectory())
-                .AddJsonFile("appsettings.json")
-                .AddEnvironmentVariables()
-                .Build();
-            NLog.Extensions.Logging.ConfigSettingLayoutRenderer.DefaultConfiguration = configuration;
-            Log.Logger = new LoggerConfiguration()
-#if DEBUG
-                .MinimumLevel.Debug()
-#else
-                .MinimumLevel.Information()
-#endif
-                .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
-                .Enrich.FromLogContext()
-                .WriteTo.Async(c => c.File("Logs/logs.txt"))
-                .WriteTo.Console()
-                .CreateLogger();
+            //var configuration = new ConfigurationBuilder()
+            //    .SetBasePath(Directory.GetCurrentDirectory())
+            //    .AddJsonFile("appsettings.json")
+            //    .AddEnvironmentVariables()
+            //    .Build();
+            //NLog.Extensions.Logging.ConfigSettingLayoutRenderer.DefaultConfiguration = configuration;
+//            Log.Logger = new LoggerConfiguration()
+//#if DEBUG
+//                .MinimumLevel.Debug()
+//#else
+//                            .MinimumLevel.Information()
+//#endif
+//                .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
+//                .Enrich.FromLogContext()
+//                //.WriteTo.Async(c => c.File($"Logs/{DateTime.Now.ToString("yyyy-MM-dd")}.txt"))
+//                .WriteTo.Async(c => c.File($"Logs/logs.txt"))
+//                .WriteTo.Console()
+//                .CreateLogger();
 
             try
             {
-                Log.Information("Starting Procurement.Host");
+                //Log.Information("Starting Procurement.Host");
                 CreateHostBuilder(args).Build().Run();
                 return 0;
             }
             catch (Exception ex)
             {
-                Log.Fatal(ex, "Host terminated unexpectedly!");
+                //Log.Fatal(ex, "Host terminated unexpectedly!");
                 return 1;
             }
             finally
             {
-                Log.CloseAndFlush();
-                NLog.LogManager.Shutdown();
+                //Log.CloseAndFlush();
+                //NLog.LogManager.Shutdown();
             }
         }
 
@@ -55,6 +57,7 @@ namespace Procurement
                     webBuilder.UseStartup<Startup>();
                 })
                 .UseAutofac()
-                .UseSerilog();
+                //.UseSerilog()
+                .UseNLog();
     }
 }

+ 5 - 5
MicroServices/Procurement/Procurement.Host/Properties/PublishProfiles/FolderProfile.pubxml

@@ -10,12 +10,12 @@
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>Any CPU</LastUsedPlatform>
     <SiteUrlToLaunchAfterPublish />
-    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
-    <ExcludeApp_Data>False</ExcludeApp_Data>
-    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
+    <ExcludeApp_Data>false</ExcludeApp_Data>
+    <TargetFramework>net6.0</TargetFramework>
     <ProjectGuid>266c12a1-4903-4282-bb37-14a4d0dae706</ProjectGuid>
     <SelfContained>false</SelfContained>
-    <publishUrl>bin\Release\netcoreapp3.1\publish\</publishUrl>
-    <DeleteExistingFiles>True</DeleteExistingFiles>
+    <publishUrl>C:\Procurement.Host</publishUrl>
+    <DeleteExistingFiles>true</DeleteExistingFiles>
   </PropertyGroup>
 </Project>

+ 3 - 1
MicroServices/Procurement/Procurement.Host/Properties/PublishProfiles/FolderProfile.pubxml.user

@@ -6,6 +6,8 @@
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <TimeStampOfAssociatedLegacyPublishXmlFile />
-    <_PublishTargetUrl>D:\Code\ABP-MicroService\MicroServices\FileSystem\FileSystem.Host\bin\Release\netcoreapp3.1\publish\</_PublishTargetUrl>
+    <_PublishTargetUrl>C:\Procurement.Host</_PublishTargetUrl>
+    <History>True|2023-05-16T11:55:13.5002893Z;True|2023-05-16T19:51:15.7648660+08:00;True|2023-05-16T19:47:23.6864540+08:00;False|2023-05-16T19:45:18.8509443+08:00;</History>
+    <LastFailureDetails />
   </PropertyGroup>
 </Project>

+ 13 - 0
MicroServices/Procurement/Procurement.Host/Startup.cs

@@ -1,14 +1,27 @@
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Logging;
+using NLog.Targets;
 
 namespace Procurement
 {
     public class Startup
     {
+        public static IConfiguration Configuration { get; private set; }
+
+        public Startup(IConfiguration configuration)
+        {
+            Configuration = configuration;
+        }
+
         public void ConfigureServices(IServiceCollection services)
         {
+            string connectionStringDefault = "";
+            connectionStringDefault = Configuration["connectionStrings:Default"];
+            NLog.LogManager.Configuration.FindTargetByName<DatabaseTarget>("db").ConnectionString = connectionStringDefault;
+
             services.AddApplication<ProcurementHostModule>();
             services.AddMvc(options =>
             {

+ 28 - 105
MicroServices/Procurement/Procurement.Host/nlog.config

@@ -1,110 +1,33 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-      autoReload="true"
-	  throwExceptions="true"
-      internalLogLevel="Info"
-      internalLogFile="${basedir}/NLog/${date:format=yyyyMM}/Procurement.txt">
-	<extensions>
-		<add assembly="NLog.Web.AspNetCore"/>
-	</extensions>
-	<!-- 定义变量当前应用程序名称 -->
-	<variable name="AppName" value="Procurement" />
-	<!-- 日志输出目标 -->
-	<targets>
-		<!--把日志输出到控制台 -->
-		<target xsi:type="Console" name="lifetimeConsole" layout="${level:truncate=4:tolower=true}: ${logger}[0]${newline}      ${message}${exception:format=tostring}" />
-		<!-- 把日志记录到文件(通用) -->
-		<target xsi:type="File" name="allfile" fileName="${gdc:item=appbasepath}\logs\nlog-${shortdate}.log" encoding="UTF-8"
-            archiveFileName="${gdc:item=appbasepath}\logs\nlog-${shortdate}.{#}.log" archiveAboveSize="10485760"
-            layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
-		<!--把日志输出到数据库 -->
-		<!--<target xsi:type="Database" name="database" dbProvider="MySqlConnector.MySqlConnection, MySqlConnector" connectionString="${configsetting:item=ConnectionStrings.DOPLog}">
-			<install-command ignoreFailures="true">
-				<text>
-					--><!-- NOTE: call LogManager.Configuration.Install(new InstallationContext()); to execute this query. --><!--
-					CREATE TABLE IF NOT EXISTS `Sys_Log${date:format=yyyyMM}`  (
-					`id` bigint NOT NULL AUTO_INCREMENT,
-					`createtime` datetime NOT NULL,
-					`appname` varchar(50) NOT NULL,
-					`modulename` varchar(50)  NULL,
-					`level` varchar(50) NOT NULL,
-					`logger` varchar(1024) NULL DEFAULT NULL,
-					`msg` text NULL,
-					`userid` varchar(50) NULL DEFAULT NULL,
-					`url` varchar(1024) NULL DEFAULT NULL,
-					`ip` varchar(255) NULL DEFAULT NULL,
-					`tenantId` varchar(50) NULL,
-					PRIMARY KEY (`id`) USING BTREE
-					);
-				</text>
-			</install-command>
-			<commandText>
-				INSERT INTO `Sys_Log${date:format=yyyyMM}`(`createtime`, `appname`, `modulename`, `level`, `logger`, `msg`,`userid`, `url`, `ip`,`tenantId`) VALUES (@CreateTime, @AppName,@ModuleName, @Level, @Logger, @Msg, @UserId, @Url, @IP,@TenantId);
-			</commandText>
-			<parameter name="@CreateTime" layout="${longdate}" />
-			<parameter name="@AppName" layout="${var:AppName}" />
-			<parameter name="@ModuleName" layout="${event-context:item=ModuleName}" allowDbNull="true"/>
-			<parameter name="@Level" layout="${level}" />
-			<parameter name="@Logger" layout="${logger}" allowDbNull="true" />
-			<parameter name="@Msg" layout="${event-context:item=Msg}" allowDbNull="true" />
-			<parameter name="@UserId" layout="${aspnet-user-claim:userId}" allowDbNull="true" />
-			<parameter name="@Url" layout="${aspnet-request-url}" allowDbNull="true" />
-			<parameter name="@IP" layout="${aspnet-request-ip}" allowDbNull="true" />
-            <parameter name="@TenantId" layout="${event-context:item=TenantId}" allowDbNull="true" />
-		</target>-->
-		<target xsi:type="Database" name="database" dbProvider="Microsoft.Data.SqlClient.SqlConnection, Microsoft.Data.SqlClient" connectionString="${configsetting:item=ConnectionStrings.DOPLog}">
-			<install-command ignoreFailures="true">
-				<text>
-					<!-- NOTE: call LogManager.Configuration.Install(new InstallationContext()); to execute this query. -->
-					if not exists (select * from sysobjects where id = object_id('dbo.Sys_Log${date:format=yyyyMM}')
-					and OBJECTPROPERTY(id, 'IsUserTable') = 1)
-					create table dbo.Sys_Log${date:format=yyyyMM}
-					(
-					id bigint identity(1,1) not null,
-					createtime datetime NOT NULL,
-					appname varchar(50) NOT NULL,
-					modulename varchar(50)  NULL,
-					level varchar(50) NOT NULL,
-					logger varchar(1024) NULL DEFAULT NULL,
-					msg text NULL,
-					userid varchar(50) NULL DEFAULT NULL,
-					url varchar(1024) NULL DEFAULT NULL,
-					ip varchar(255) NULL DEFAULT NULL,
-					tenantId varchar(50) NULL,
-					CONSTRAINT [PK_dbo.Sys_Log${date:format=yyyyMM}] PRIMARY KEY CLUSTERED ([id] ASC) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
-					)
-				</text>
-			</install-command>
-			<commandText>
-				INSERT INTO dbo.Sys_Log${date:format=yyyyMM}(createtime, appname, modulename, level, logger, msg,userid, url, ip,tenantId) VALUES (@CreateTime, @AppName,@ModuleName, @Level, @Logger, @Msg, @UserId, @Url, @IP,@TenantId);
-			</commandText>
-			<parameter name="@CreateTime" layout="${date}" />
-			<parameter name="@AppName" layout="${var:AppName}" />
-			<parameter name="@ModuleName" layout="${event-context:item=ModuleName}" allowDbNull="true"/>
-			<parameter name="@Level" layout="${level}" />
-			<parameter name="@Logger" layout="${logger}" allowDbNull="true" />
-			<parameter name="@Msg" layout="${event-context:item=Msg}" allowDbNull="true" />
-			<parameter name="@UserId" layout="${aspnet-user-claim:userId}" allowDbNull="true" />
-			<parameter name="@Url" layout="${aspnet-request-url}" allowDbNull="true" />
-			<parameter name="@IP" layout="${aspnet-request-ip}" allowDbNull="true" />
-			<parameter name="@TenantId" layout="${event-context:item=TenantId}" allowDbNull="true" />
-		</target>
-	</targets>
+      autoReload="true">
+  <targets>
+    <target xsi:type="Null" name="blackhole" />
+    <target name="loginfo" xsi:type="File" fileName="logs/${shortdate}.log" />
+    
+    <target name="db"
+                  xsi:type="Database"
+                  connectionString="${var:NLOG_CONNECTION_STRING}"
+                  commandType="StoredProcedure"
+                  commandText="[dbo].[pr_SFM_SaveWebApiLog]">
+      <parameter name="@traceId" layout="${aspnet-TraceIdentifier}" />
+      <parameter name="@eventId" layout="${event-properties:EventId}" />
+      <parameter name="@type" layout="${event-context:item=Type}" />
+      <parameter name="@action" layout="${event-context:item=Action}" />
+      <parameter name="@application" layout="Procurement" />
+      <parameter name="@level" layout="${level}" />
+      <parameter name="@category" layout="${logger}" />
+      <parameter name="@message" layout="${message}" />
+      <parameter name="@properties" layout="${all-event-properties:separator=|}" />
+      <parameter name="@exception" layout="${exception:tostring}" />
+      <parameter name="@clientIP" layout="${aspnet-request-ip}" />
+    </target>
+  </targets>
 
-	<!-- 日志输出规则 -->
-	<rules>
-		<!--All logs, including from Microsoft-->
-		<!--<logger name="*" minlevel="Trace" writeTo="allfile" />-->
-
-		<!--Output hosting lifetime messages to console target for faster startup detection -->
-		<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="lifetimeConsole,database" final="true" />
-		<logger name="Microsoft.EntityFrameworkCore.Model.Validation" maxlevel="Error" final="true" />
-
-		<!--Skip non-critical Microsoft logs and so log only own logs (BlackHole) -->
-		<logger name="Microsoft.*" maxlevel="Info" final="true" />
-		<logger name="System.Net.Http.*" maxlevel="Info" final="true" />
-
-		<logger name="*" minlevel="Trace" writeTo="lifetimeConsole,database" />
-	</rules>
+  <rules>
+    <logger name="Microsoft.EntityFrameworkCore.Infrastructure" minlevel="Info" writeTo="blackhole" final="true" />
+    <logger name="Procurement.Core.NLogHelper" minlevel="Info" writeTo="db"/>
+    <logger name="*" minlevel="Info" writeTo="loginfo" />
+  </rules>
 </nlog>