啊鑫
2024-08-16 21d72e7e8765511977efc0b034d474148e385efa
格式化代码
已修改24个文件
246 ■■■■ 文件已修改
MES.Service/Dto/service/MovesDto.cs 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Dto/service/OutItemDto.cs 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Dto/service/SJPageResult.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Modes/MesInvBusiness2.cs 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Modes/MesInvItemArn.cs 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Modes/MesInvItemBarcodes.cs 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Modes/MesInvItemInCItems.cs 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Modes/MesInvItemMoves.cs 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Modes/MesLine.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Modes/MesQaItemsDetect01.cs 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Modes/MesQaItemsDetectDetail5.cs 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Modes/Purdhb.cs 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Modes/Purdka.cs 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Modes/Womdaa.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/service/QC/SuspendService.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/service/QC/XJService.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/service/Warehouse/MesInvItemMovesManager.cs 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/Controllers/Base/DemoController.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/Controllers/Base/LoginController.cs 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/Controllers/Warehouse/MesInvItemMovesController.cs 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/Filter/ActionFilter.cs 139 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/Filter/ErrorLog.cs 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/MESApplication.csproj 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/Startup.cs 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Dto/service/MovesDto.cs
MES.Service/Dto/service/OutItemDto.cs
MES.Service/Dto/service/SJPageResult.cs
@@ -1,4 +1,4 @@
using MES.Service.Dto.@base;
using MES.Service.Dto.@base;
using SqlSugar;
namespace MES.Service.Dto.service;
@@ -82,5 +82,4 @@
    ///</summary>
    [SugarColumn(ColumnName = "DAA008")]
    public decimal? Daa008 { get; set; }
}
MES.Service/Modes/MesInvBusiness2.cs
MES.Service/Modes/MesInvItemArn.cs
MES.Service/Modes/MesInvItemBarcodes.cs
MES.Service/Modes/MesInvItemInCItems.cs
MES.Service/Modes/MesInvItemMoves.cs
MES.Service/Modes/MesLine.cs
@@ -1,7 +1,7 @@
using SqlSugar;
namespace MES.Service.Modes
{
namespace MES.Service.Modes;
    /// <summary>
    /// 线体
    ///</summary>
@@ -105,25 +105,21 @@
        public string Workcentertype { get; set; }
        /// <summary>
        ///
        ///</summary>
        [SugarColumn(ColumnName = "SIMPLENAME")]
        public string Simplename { get; set; }
        /// <summary>
        ///
        ///</summary>
        [SugarColumn(ColumnName = "SHOW_INDEX")]
        public decimal? ShowIndex { get; set; }
        /// <summary>
        ///
        ///</summary>
        [SugarColumn(ColumnName = "COMPANY")]
        public string Company { get; set; }
        /// <summary>
        ///
        ///</summary>
        [SugarColumn(ColumnName = "FACTORY")]
        public string Factory { get; set; }
@@ -159,7 +155,6 @@
        public string ProcNo { get; set; }
        /// <summary>
        ///
        ///</summary>
        [SugarColumn(ColumnName = "LINE_STYLE")]
        public string LineStyle { get; set; }
@@ -169,5 +164,4 @@
        ///</summary>
        [SugarColumn(ColumnName = "L_CODE")]
        public string LCode { get; set; }
    }
}
MES.Service/Modes/MesQaItemsDetect01.cs
MES.Service/Modes/MesQaItemsDetectDetail5.cs
MES.Service/Modes/Purdhb.cs
MES.Service/Modes/Purdka.cs
MES.Service/Modes/Womdaa.cs
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using SqlSugar;
using SqlSugar;
namespace MES.Service.Modes
{
namespace MES.Service.Modes;
    /// <summary>
    /// 工单指令表
    ///</summary>
@@ -316,5 +313,4 @@
        ///</summary>
        [SugarColumn(ColumnName = "MES_END_PROD")]
        public DateTime? MesEndProd { get; set; }
    }
}
MES.Service/service/QC/SuspendService.cs
@@ -15,7 +15,8 @@
        return db
            .Queryable<Womdaa, MesLine, QsQaItemXj, SysDepartment>(
                (a, b, c, d) =>
                    new JoinQueryInfos(JoinType.Left, a.Daa002 == b.Id.ToString(),
                    new JoinQueryInfos(JoinType.Left,
                        a.Daa002 == b.Id.ToString(),
                        JoinType.Inner, a.Daa001 == c.BillNo,
                        JoinType.Left, b.Departmentcode == d.Departmentcode))
            .Where((a, b, c, d) => b.LineName != null &&
@@ -36,7 +37,8 @@
        var db = SqlSugarHelper.GetInstance();
        var mesLines = db.Queryable<Womdaa, MesLine, QsQaItemXj>(
                (a, b, c) =>
                    new JoinQueryInfos(JoinType.Left, a.Daa002 == b.Id.ToString(),
                    new JoinQueryInfos(JoinType.Left,
                        a.Daa002 == b.Id.ToString(),
                        JoinType.Inner, a.Daa001 == c.BillNo))
            .Where((a, b, c) => b.LineName != null &&
                                statusArray.Contains(a.Daa018)
MES.Service/service/QC/XJService.cs
@@ -147,7 +147,7 @@
                BillNo = s.BillNo,
                FcheckBy = s.FcheckBy,
                FcheckResu = s.FcheckResu,
                Remarks = s.Remarks,
                Remarks = s.Remarks
            }).OrderBy(s => s.CreateDate, OrderByType.Desc)
            .ToPageList(queryObj.PageIndex, queryObj.Limit);
    }
MES.Service/service/Warehouse/MesInvItemMovesManager.cs
@@ -15,12 +15,10 @@
    public MovesDto ScanInBarcode(WarehouseQuery query)
    {
        if (string.IsNullOrEmpty(query.sectionCode))
        {
            throw new Exception("请扫库位条码!");
        }
        int pBillTypeId = 300;
        int pTransctionNo = 301;
        var pBillTypeId = 300;
        var pTransctionNo = 301;
        var depotQuery = Db.Queryable<MesDepotSections, MesDepots>((a, b) =>
                new JoinQueryInfos(
@@ -30,9 +28,7 @@
            .First();
        if (depotQuery == null)
        {
            throw new Exception($"002[库位编码 {query.sectionCode} 不存在,请确认!");
        }
        var cDepotCode = depotQuery.DepotCode;
@@ -48,10 +44,7 @@
            .Select((a, b) => new { a.Id, a.BillNo, a.InvDepotsCode })
            .First();
        if (itemMoveQuery == null)
        {
            throw new Exception("条码未做调拔出库扫码,请核对!");
        }
        if (itemMoveQuery == null) throw new Exception("条码未做调拔出库扫码,请核对!");
        var cBillNo = itemMoveQuery.BillNo;
        var iDepotCode = itemMoveQuery.InvDepotsCode;
@@ -66,14 +59,10 @@
            .First();
        if (depotValidationQuery == null)
        {
            throw new Exception($"002[库位编码 {query.sectionCode} 不存在,请确认!");
        }
        if (iDepotCode != depotValidationQuery.DepotCode)
        {
            throw new Exception("实际仓库与申请调入仓库不符,请核对!");
        }
        var barcodeCount = Db.Queryable<MesInvItemMovesCDetails>()
            .Where(b =>
@@ -81,19 +70,13 @@
                b.ItemMoveId == itemMoveQuery.Id && b.MoveOk == 1)
            .Count();
        if (barcodeCount > 0)
        {
            throw new Exception("条码调拔已完成,请核对!");
        }
        if (barcodeCount > 0) throw new Exception("条码调拔已完成,请核对!");
        var barcodeInfo = Db.Queryable<MesInvItemBarcodes>()
            .Where(t => t.ItemBarcode == query.barcode)
            .First();
        if (barcodeInfo == null)
        {
            throw new Exception("条码不存在,请核对!");
        }
        if (barcodeInfo == null) throw new Exception("条码不存在,请核对!");
        var isAudit = UseTransaction(db =>
        {
@@ -140,15 +123,12 @@
                .Where(a => a.ItemMoveId == itemMoveQuery.Id && a.MoveOk == 1)
                .Sum(a => SqlFunc.IsNull(a.Quantity, 0));
            if (totalQuantity == scannedQuantity)
            {
                return 1;
            }
            if (totalQuantity == scannedQuantity) return 1;
            return 0;
        });
        MovesDto dto = new MovesDto();
        var dto = new MovesDto();
        dto.InAudit = isAudit == 1;
        dto.BarcodesInfo = barcodeInfo;
        return dto;
@@ -180,7 +160,7 @@
    public MovesDto GetItems(WarehouseQuery query)
    {
        MovesDto dto = new MovesDto();
        var dto = new MovesDto();
        dto.BarcodeList = GetItemMovesCDetails(query);
        dto.OutItems = GetItemOutItems(query);
MESApplication/Controllers/Base/DemoController.cs
@@ -3,6 +3,7 @@
using MES.Service.util;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
namespace MESApplication.Controllers.Base;
[Route("api/[controller]")]
MESApplication/Controllers/Base/LoginController.cs
MESApplication/Controllers/Warehouse/MesInvItemMovesController.cs
MESApplication/Filter/ActionFilter.cs
@@ -1,17 +1,19 @@
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using System.Text;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Newtonsoft.Json;
using System.Diagnostics;
using System.Text;
namespace MESApplication
{
namespace MESApplication;
    /// <summary>
    /// 方法过滤器
    /// </summary>
    public class ActionFilter : IActionFilter
    {
    private Stopwatch _stopwatch;
        /// <summary>
        /// 监控日志
        /// </summary>
@@ -21,47 +23,6 @@
        /// 错误日志
        /// </summary>
        public static ILogger LoggerError { get; set; }
        private Stopwatch _stopwatch;
        /// <summary>
        /// 创建请求日志文本
        /// </summary>
        /// <param name="method"></param>
        /// <param name="controllerName"></param>
        /// <param name="actionName"></param>
        /// <param name="actionArgs"></param>
        /// <returns></returns>
        private static string CreateRequestLogText(string method, string controllerName, string actionName, string requestHead, string requestBody)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")} 请求{method}/{controllerName}/{actionName}接口,请求Head:{requestHead}\n");
            sb.Append($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")} 请求{method}/{controllerName}/{actionName}接口,请求Body:{requestBody}\n");
            return sb.ToString();
        }
        /// <summary>
        /// 创建响应日志文本
        /// </summary>
        /// <param name="method"></param>
        /// <param name="controllerName"></param>
        /// <param name="actionName"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        private static string CreateResponseLogText(string method, string controllerName, string actionName, object result)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")} 完成请求{method}/{controllerName}/{actionName}接口,返回结果:");
            if (result != null)
            {
                sb.Append($"{JsonConvert.SerializeObject(result)}");
            }
            else
            {
                sb.Append($"无");
            }
            return sb.ToString();
        }
        /// <summary>
@@ -78,72 +39,74 @@
            if (LoggerMonitor != null)
            {
                //记录请求参数日志
                ControllerActionDescriptor desc = context.ActionDescriptor as ControllerActionDescriptor;
            var desc = context.ActionDescriptor as ControllerActionDescriptor;
                if (desc != null)
                {
                    Dictionary<string, object> headers = new Dictionary<string, object>();
                var headers = new Dictionary<string, object>();
                    var requestHeaders = context.HttpContext.Request.Headers;
                    // 访问请求中的 header 信息
                    foreach (var header in requestHeaders)
                    {
                        headers.Add(header.Key, header.Value);
                    }
                    var requestHead = JsonConvert.SerializeObject(headers);
                    Dictionary<string, object> bodys = new Dictionary<string, object>();
                var bodys = new Dictionary<string, object>();
                    var actionArguments = context.ActionArguments;
                    // 访问请求中的参数
                    foreach (var argument in actionArguments)
                    {
                        //dic.Add(argument.Key, argument.Value);
                        var parameter = JsonConvert.DeserializeObject<Dictionary<string, object>>(argument.Value.ToString());
                    var parameter =
                        JsonConvert
                            .DeserializeObject<Dictionary<string, object>>(
                                argument.Value.ToString());
                        foreach (var item in parameter)
                        {
                            bodys.Add(item.Key, item.Value);
                        }
                    }
                    var requestBody = JsonConvert.SerializeObject(bodys);
                    var logText = CreateRequestLogText(context.HttpContext.Request.Method, desc.ControllerName, desc.ActionName, requestHead, requestBody);
                var logText = CreateRequestLogText(
                    context.HttpContext.Request.Method, desc.ControllerName,
                    desc.ActionName, requestHead, requestBody);
                    //LoggerMonitor.LogDebug(logText);
                    //ErrorLog.Write(logText);
                }
            }
        }
        public void OnActionExecuted(ActionExecutedContext context)
        {
            //throw new NotImplementedException();
            _stopwatch.Stop();
            long elaspsedMillisedconds = _stopwatch.ElapsedMilliseconds;
            string msg = "";
        var elaspsedMillisedconds = _stopwatch.ElapsedMilliseconds;
        var msg = "";
            //string msg = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")} 接口执行时间:{elaspsedMillisedconds}毫秒";
            //ErrorLog.Write(msg);
            if (context.Exception != null)
            {
                // 记录异常日志
                if (LoggerError != null)
                {
                    LoggerError.LogError(context.Exception, context.Exception.Message);
                LoggerError.LogError(context.Exception,
                    context.Exception.Message);
                    ErrorLog.Write($@"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")} 接口异常:{JsonConvert.SerializeObject(context.Exception)}");
                    ErrorLog.Write($@"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")} 异常提示信息:{JsonConvert.SerializeObject(context.Exception.Message)}");
                    ErrorLog.Write("==================================================================================================================================");
                }
                ErrorLog.Write(
                    $@"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")} 接口异常:{JsonConvert.SerializeObject(context.Exception)}");
                ErrorLog.Write(
                    $@"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")} 异常提示信息:{JsonConvert.SerializeObject(context.Exception.Message)}");
                ErrorLog.Write(
                    "==================================================================================================================================");
            }
            if (LoggerMonitor != null)
            {
                // 记录请求结果日志
                ControllerActionDescriptor desc = context.ActionDescriptor as ControllerActionDescriptor;
            var desc = context.ActionDescriptor as ControllerActionDescriptor;
                if (desc != null)
                {
                    ObjectResult rst = context.Result as ObjectResult;
                    object rstValue = rst != null ? rst.Value : null;
                var rst = context.Result as ObjectResult;
                var rstValue = rst != null ? rst.Value : null;
                    var logText = CreateResponseLogText(
                        context.HttpContext.Request.Method,
                        desc.ControllerName,
@@ -156,5 +119,45 @@
            //  ErrorLog.Write(msg);
            //  ErrorLog.Write("==================================================================================================================================");
        }
    /// <summary>
    ///     创建请求日志文本
    /// </summary>
    /// <param name="method"></param>
    /// <param name="controllerName"></param>
    /// <param name="actionName"></param>
    /// <param name="actionArgs"></param>
    /// <returns></returns>
    private static string CreateRequestLogText(string method,
        string controllerName, string actionName, string requestHead,
        string requestBody)
    {
        var sb = new StringBuilder();
        sb.Append(
            $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")} 请求{method}/{controllerName}/{actionName}接口,请求Head:{requestHead}\n");
        sb.Append(
            $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")} 请求{method}/{controllerName}/{actionName}接口,请求Body:{requestBody}\n");
        return sb.ToString();
    }
    /// <summary>
    ///     创建响应日志文本
    /// </summary>
    /// <param name="method"></param>
    /// <param name="controllerName"></param>
    /// <param name="actionName"></param>
    /// <param name="result"></param>
    /// <returns></returns>
    private static string CreateResponseLogText(string method,
        string controllerName, string actionName, object result)
    {
        var sb = new StringBuilder();
        sb.Append(
            $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")} 完成请求{method}/{controllerName}/{actionName}接口,返回结果:");
        if (result != null)
            sb.Append($"{JsonConvert.SerializeObject(result)}");
        else
            sb.Append("无");
        return sb.ToString();
    }
}
MESApplication/Filter/ErrorLog.cs
@@ -1,9 +1,9 @@
namespace MESApplication
{
namespace MESApplication;
    public class ErrorLog
    {
        private static string DirectoryPath = AppDomain.CurrentDomain.BaseDirectory;
    private static readonly string DirectoryPath =
        AppDomain.CurrentDomain.BaseDirectory;
        /// <summary>
        /// 写入操作日志到文件中
@@ -14,24 +14,22 @@
        public static void Write(string moduleName, string message, Exception ex)
        {
            //string directoryPath = $@"C:\至简科技\MyDemoData\.NetCore接口过滤器项目\FilterText\FilterText\Logger\{DateTime.Now.ToString("yyyyMMdd")}"; // 目标目录路径
            string directoryPath = $@"{DirectoryPath}{"log"}"; // 目标目录路径
        var directoryPath = $@"{DirectoryPath}{"log"}"; // 目标目录路径
            if (!Directory.Exists(directoryPath))
            {
                // 如果目录不存在,则新建文件夹
                Directory.CreateDirectory(directoryPath);
            }
            string filePath = directoryPath + $@"\{DateTime.Now.ToString("yyyyMMddHH")}.log"; // 目标文件路径
        var filePath = directoryPath +
                       $@"\{DateTime.Now.ToString("yyyyMMddHH")}.log"; // 目标文件路径
            if (!File.Exists(filePath))
            {
                // 如果文件不存在,则创建文件
                using (File.Create(filePath))
                {
                    //Console.WriteLine("文件已创建");
                }
            }
            LogToFile(filePath, message);
        }
@@ -52,7 +50,7 @@
        /// <param name="ex">异常</param>
        public static void Write(string message)
        {
            Write(String.Empty, message, null);
        Write(string.Empty, message, null);
        }
        /// <summary>
@@ -61,10 +59,9 @@
        /// <param name="logMessage"></param>
        private static void LogToFile(string logFilePath, string logMessage)
        {
            using (StreamWriter sw = File.AppendText(logFilePath))
        using (var sw = File.AppendText(logFilePath))
            {
                sw.WriteLine($"{logMessage}");
            }
        }
    }
}
MESApplication/MESApplication.csproj
MESApplication/Startup.cs
@@ -1,10 +1,10 @@
using MES.Service.Dto.@base;
using System.Reflection;
using MES.Service.Dto.@base;
using MES.Service.util;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Swashbuckle.AspNetCore.SwaggerUI;
using System.Reflection;
namespace MESApplication;
@@ -36,7 +36,8 @@
            c.SwaggerDoc("v1",
                new OpenApiInfo
                    { Title = "MESApplication.Api", Version = "v1" });
            var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
            var xmlFile =
                $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
            var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
            c.IncludeXmlComments(xmlPath, true);
        });
@@ -72,11 +73,15 @@
        });
        #region 接口行动过滤器
        services.AddControllers(options => {
        services.AddControllers(options =>
        {
            options.Filters.Add(new ActionFilter());
        });
        var serviceProvider = services.BuildServiceProvider();
        ActionFilter.LoggerError = serviceProvider.GetRequiredService<ILogger<ActionFilter>>();
        ActionFilter.LoggerError =
            serviceProvider.GetRequiredService<ILogger<ActionFilter>>();
        #endregion
    }
@@ -108,6 +113,5 @@
        //////////////////////////
        
        ///////////////////////////
    }
}