diff --git a/Infrastructure/Infrastructure.csproj b/Infrastructure/Infrastructure.csproj index c305efef..a17c51c5 100644 --- a/Infrastructure/Infrastructure.csproj +++ b/Infrastructure/Infrastructure.csproj @@ -1,4 +1,4 @@ - + net7.0 diff --git a/ZR.Admin.WebApi/Controllers/mes/op/quality/QualityStatisticsController.cs b/ZR.Admin.WebApi/Controllers/mes/op/quality/QualityStatisticsController.cs new file mode 100644 index 00000000..b2c53051 --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/mes/op/quality/QualityStatisticsController.cs @@ -0,0 +1,41 @@ +using Microsoft.AspNetCore.Mvc; +using ZR.Model.mes.pro; +using ZR.Model.MES.op.DTO; +using ZR.Service.mes.pro; +using ZR.Service.MES.op.IService; + +namespace ZR.Admin.WebApi.Controllers.mes.op.quality +{ + [Route("mes/op/operation/quality")] + public class QualityStatisticsController : BaseController + { + private readonly IOperationService operationService; + + public QualityStatisticsController(IOperationService operationService) + { + this.operationService = operationService; + + } + + + /// + /// 获取质量统计表 + /// + /// + /// + /// + /// + /// + /// + /// + [HttpGet("gueryQualityStatisticsTable")] + public IActionResult GueryQualityStatisticsTable(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1, string workorderid = "") + { + (List, int) data = operationService.GueryQualityStatistics(workorderid,pageNum, pageSize, year, week, date); + + return ToResponse(new ApiResult(200, "success", data)); + } + + + } +} diff --git a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs index 219c397b..84221afd 100644 --- a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs @@ -41,17 +41,17 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.IQC { CheckItemTableDTO itemTableDTO= fQCService.GetCheckItemTable(); - hubContext.Clients.All.SendAsync(HubsConstant.mymy, "123456"); + return SUCCESS(itemTableDTO); } + [HttpGet("getcheckitemRecord")] + public IActionResult GetcheckitemRecord() + { - + + return null; + } } - - - - - } diff --git a/ZR.Admin.WebApi/Hubs/MessageHub.cs b/ZR.Admin.WebApi/Hubs/MessageHub.cs index e74c87a7..40ab34b5 100644 --- a/ZR.Admin.WebApi/Hubs/MessageHub.cs +++ b/ZR.Admin.WebApi/Hubs/MessageHub.cs @@ -3,8 +3,12 @@ using Infrastructure.Constant; using Infrastructure.Model; using IPTools.Core; using Microsoft.AspNetCore.SignalR; +using System.ComponentModel; +using System.Diagnostics.Metrics; using UAParser; using ZR.Admin.WebApi.Extensions; +using ZR.Service.mes.qc; +using ZR.Service.mes.qc.IService; using ZR.Service.System.IService; namespace ZR.Admin.WebApi.Hubs @@ -18,10 +22,12 @@ namespace ZR.Admin.WebApi.Hubs public static readonly List clientUsers = new(); private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); private readonly ISysNoticeService SysNoticeService; + private readonly IFirstFQCService firstFQCService; - public MessageHub(ISysNoticeService noticeService) + public MessageHub(ISysNoticeService noticeService, IFirstFQCService firstFQCService) { SysNoticeService = noticeService; + this.firstFQCService = firstFQCService; } private ApiResult SendNotice() @@ -102,5 +108,32 @@ namespace ZR.Admin.WebApi.Hubs Console.WriteLine($"{connectId},message={message}"); await Clients.Client(connectId).SendAsync("receiveChat", new { userName, message }); } + + /// + /// 保存油漆缺陷采集累加信息 + /// + /// 工单id + /// 检测项 + /// + public async Task SaveCacheInformation(string workorderid, string Moudle, string checkid) + { + + if (CacheHelper.Exists(checkid)) + { + int sum = Convert.ToInt32(CacheHelper.GetCache(checkid)) + 1; + logger.Info($"当前保存工单号{workorderid},检测项{checkid},累加的数为{sum}"); + CacheHelper.SetCache(checkid, sum); + //SaveinspectItem + await firstFQCService.SaveinspectItem(workorderid,Moudle, checkid,sum); + await Clients.All.SendAsync("GetCache", Moudle,checkid, sum); + } + else + { + CacheHelper.SetCache(checkid, 1); + logger.Info($"当前保存工单号{workorderid},检测项{checkid},累加的数为1"); + await firstFQCService.SaveinspectItem(workorderid, Moudle, checkid, 1); + await Clients.All.SendAsync("GetCache", Moudle, checkid, 1); + } + } } } diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json index c5ba77f2..0663f920 100644 --- a/ZR.Admin.WebApi/appsettings.json +++ b/ZR.Admin.WebApi/appsettings.json @@ -9,8 +9,9 @@ "urls": "http://localhost:8888", //(app会默认去读)项目启动url,如果改动端口前端对应devServer也需要进行修改 "dbConfigs": [ { - "Conn": "Data Source=192.168.0.36;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", - // "Conn": "Data Source=127.0.0.1;User ID=sa;Password=123456;Initial Catalog=ZrAdmin;", + //"Conn": "Data Source=192.168.0.36;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", + + "Conn": "Data Source=47.116.122.230;Port=3307;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 "ConfigId": "0", //多租户唯一标识 "IsAutoCloseConnection": true diff --git a/ZR.Model/MES/op/DTO/QcFqcDTO.cs b/ZR.Model/MES/op/DTO/QcFqcDTO.cs new file mode 100644 index 00000000..f2893d81 --- /dev/null +++ b/ZR.Model/MES/op/DTO/QcFqcDTO.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model.MES.op.DTO +{ + public class QcFqcDTO + { + + public int? Year { get; set; } + public int? Week { get; set; } + public int? Date { get; set; } + + /// + /// 流水号 + /// + public string Id { get; set; } + /// + /// kf工单id + /// + public string FkWorkorderId { get; set; } + /// + /// 产品名称 + /// + public string ProductName { get; set; } + /// + /// 颜色 + /// + public string Color { get; set; } + /// + /// 需要检测数量/投入数 + /// + public int? Require { get; set; } + /// + /// 左右 + /// + public string LeftRight { get; set; } + /// + /// 班组 + /// + public string Team { get; set; } + /// + /// 首检合格数量 + /// + public int? QualifiedNum01 { get; set; } + /// + /// 首检抛光数量 + /// + public int? DefectNum01 { get; set; } + /// + /// 首检打磨数量 + /// + public string PolishNum01 { get; set; } + /// + /// 首检报废数量 + /// + public string ScrapNum01 { get; set; } + /// + /// 二检合格数量 + /// + public string QualifiedNum02 { get; set; } + /// + /// 二检打磨数量 + /// + public int? PolishNum02 { get; set; } + /// + /// 二检报废数量 + /// + public int? ScrapNum02 { get; set; } + /// + /// 三检合格数量 + /// + public string QualifiedNum03 { get; set; } + /// + /// 三检打磨数量 + /// + public string PolishNum03 { get; set; } + /// + /// 三检报废数量 + /// + public string ScrapNum03 { get; set; } + } +} diff --git a/ZR.Model/MES/qc/DTO/QcInspectionitem_Record.cs b/ZR.Model/MES/qc/DTO/QcInspectionitem_Record.cs new file mode 100644 index 00000000..095ec4eb --- /dev/null +++ b/ZR.Model/MES/qc/DTO/QcInspectionitem_Record.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model.MES.qc.DTO +{ + public class QcInspectionitem_Record + { + + /// + /// 工单id + /// + public string FKWorkorderId { get; set; } + /// + /// 检测项id + /// + public string FKInpectionId { get; set; } + /// + /// 模块 + /// + public string InspectionModule { get; set; } + + + /// + /// 数值 + /// + public int? Counter { get; set; } + } +} diff --git a/ZR.Model/MES/qc/QcFirstinspectionRecord.cs b/ZR.Model/MES/qc/QcFirstinspectionRecord.cs new file mode 100644 index 00000000..5871b0d5 --- /dev/null +++ b/ZR.Model/MES/qc/QcFirstinspectionRecord.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using SqlSugar; +namespace ZR.Model.MES.qc +{ + /// + /// 初检实时记录表 + /// + [SugarTable("qc_firstinspection_record")] + public class QcFirstinspectionRecord + { + /// + /// 流水号 + /// + [SugarColumn(ColumnName = "id", IsPrimaryKey = true)] + public string Id { get; set; } + /// + /// 工单id + /// + [SugarColumn(ColumnName = "fk_workorder_id")] + public string FKWorkorderId { get; set; } + /// + /// 检测项id + /// + [SugarColumn(ColumnName = "fk_inpection_id")] + public string FKInpectionId { get; set; } + /// + /// 模块 + /// + [SugarColumn(ColumnName = "InspectionModule")] + public string InspectionModule { get; set; } + /// + /// 数值 + /// + [SugarColumn(ColumnName = "counter")] + public int? Counter { get; set; } + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "CREATED_BY")] + public string CreatedBy { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "CREATED_TIME")] + public DateTime? CreatedTime { get; set; } + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "UPDATED_BY")] + public string UpdatedBy { get; set; } + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "UPDATED_TIME")] + public DateTime? UpdatedTime { get; set; } + } +} diff --git a/ZR.Model/MES/qc/QcFqc.cs b/ZR.Model/MES/qc/QcFqc.cs new file mode 100644 index 00000000..618e6bee --- /dev/null +++ b/ZR.Model/MES/qc/QcFqc.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model.MES.qc +{ + /// + /// 终检收集表 + /// + [SugarTable("qc_fqc")] + public class QcFqc + { + + + /// + /// 流水号 + /// + [SugarColumn(ColumnName = "id", IsPrimaryKey = true)] + public string Id { get; set; } + /// + /// kf工单id + /// + [SugarColumn(ColumnName = "fk_workorder_id")] + public string FkWorkorderId { get; set; } + /// + /// 产品名称 + /// + [SugarColumn(ColumnName = "productName")] + public string ProductName { get; set; } + /// + /// 颜色 + /// + [SugarColumn(ColumnName = "color")] + public string Color { get; set; } + /// + /// 需要检测数量/投入数 + /// + [SugarColumn(ColumnName = "require")] + public int? Require { get; set; } + /// + /// 左右 + /// + [SugarColumn(ColumnName = "left_right")] + public string LeftRight { get; set; } + /// + /// 班组 + /// + [SugarColumn(ColumnName = "team")] + public string Team { get; set; } + /// + /// 首检合格数量 + /// + [SugarColumn(ColumnName = "qualifiedNum01")] + public int? QualifiedNum01 { get; set; } + /// + /// 首检抛光数量 + /// + [SugarColumn(ColumnName = "defectNum01")] + public int? DefectNum01 { get; set; } + /// + /// 首检打磨数量 + /// + [SugarColumn(ColumnName = "polishNum01")] + public string PolishNum01 { get; set; } + /// + /// 首检报废数量 + /// + [SugarColumn(ColumnName = "scrapNum01")] + public string ScrapNum01 { get; set; } + /// + /// 二检合格数量 + /// + [SugarColumn(ColumnName = "qualifiedNum02")] + public string QualifiedNum02 { get; set; } + /// + /// 二检打磨数量 + /// + [SugarColumn(ColumnName = "polishNum02")] + public int? PolishNum02 { get; set; } + /// + /// 二检报废数量 + /// + [SugarColumn(ColumnName = "scrapNum02")] + public int? ScrapNum02 { get; set; } + /// + /// 三检合格数量 + /// + [SugarColumn(ColumnName = "qualifiedNum03")] + public string QualifiedNum03 { get; set; } + /// + /// 三检打磨数量 + /// + [SugarColumn(ColumnName = "polishNum03")] + public string PolishNum03 { get; set; } + /// + /// 三检报废数量 + /// + [SugarColumn(ColumnName = "scrapNum03")] + public string ScrapNum03 { get; set; } + /// + /// 乐观锁 + /// + [SugarColumn(ColumnName = "REVISION")] + public int? Revision { get; set; } + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "CREATED_BY")] + public string CreatedBy { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "CREATED_TIME")] + public DateTime? CreatedTime { get; set; } + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "UPDATED_BY")] + public string UpdatedBy { get; set; } + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "UPDATED_TIME")] + public DateTime? UpdatedTime { get; set; } + } +} + + diff --git a/ZR.Model/MES/qc/QcInspectionitem.cs b/ZR.Model/MES/qc/QcInspectionitem.cs index 9826a2c8..a2a94cc0 100644 --- a/ZR.Model/MES/qc/QcInspectionitem.cs +++ b/ZR.Model/MES/qc/QcInspectionitem.cs @@ -32,7 +32,7 @@ namespace ZR.Model.MES.qu public string InspectionType { get; set; } /// - /// 检测类别 + /// 检测类模块 /// [SugarColumn(ColumnName = "inspectionModule")] public string InspectionModule { get; set; } @@ -71,5 +71,8 @@ namespace ZR.Model.MES.qu /// [SugarColumn(ColumnName = "UPDATED_TIME")] public DateTime? UpdatedTime { get; set; } + + [SugarColumn(IsIgnore =true)] + public int? Counter { get; set; } } } diff --git a/ZR.Service/mes/op/IService/IOperationService.cs b/ZR.Service/mes/op/IService/IOperationService.cs index 4a1a8524..a1f4f0e6 100644 --- a/ZR.Service/mes/op/IService/IOperationService.cs +++ b/ZR.Service/mes/op/IService/IOperationService.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using ZR.Model.MES.op.DTO; using ZR.Model.MES.op.ZR.Model.mes.md; +using ZR.Model.MES.qc; namespace ZR.Service.MES.op.IService { @@ -12,5 +13,7 @@ namespace ZR.Service.MES.op.IService { public List GetAllData(string workshopID); + + public (List,int) GueryQualityStatistics(string workorderid, int pageNum, int pageSize, int year = -1, int week = -1, int date = -1); } } diff --git a/ZR.Service/mes/op/OperationService.cs b/ZR.Service/mes/op/OperationService.cs index a81a4b67..a2c71913 100644 --- a/ZR.Service/mes/op/OperationService.cs +++ b/ZR.Service/mes/op/OperationService.cs @@ -13,6 +13,12 @@ using ZR.Service.MES.op.IService; using ZR.Model.MES.op.DTO; using Microsoft.AspNetCore.Http.HttpResults; using Org.BouncyCastle.Asn1.Esf; +using ZR.Model.MES.qc; +using SqlSugar; +using ZR.Model.mes.pro; +using static System.Runtime.InteropServices.JavaScript.JSType; +using System.Drawing; +using Newtonsoft.Json; namespace ZR.Service.MES.op { @@ -65,6 +71,50 @@ namespace ZR.Service.MES.op return OpStatisticsDTOList; } + + public (List,int) GueryQualityStatistics(string workorderid ,int pageNum, int pageSize, int year = -1, int week = -1, int date = -1) + { + var predicate = Expressionable.Create() + .AndIF(year > 0, p => p.Year == year) + .AndIF(week > 0, p => p.Week == week) + .AndIF(date > 0, p => p.Date == date) + .ToExpression(); + var predicate2 = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(workorderid),q=>q.FkWorkorderId== workorderid) + .ToExpression(); + + int totalCount = 0; + + var query5 = Context.Queryable() + .LeftJoin((q, p) => q.FkWorkorderId == p.Id) + .Where(predicate2) + .Select((q, p) => new QcFqcDTO { + Year = p.Year, + Week = p.Week, + Date = p.Date, + Id = q.Id, + FkWorkorderId = q.FkWorkorderId, + ProductName = q.ProductName, + Color = q.Color, + Require = q.Require, + LeftRight = q.LeftRight, + Team = q.Team, + QualifiedNum01 = q.QualifiedNum01, + DefectNum01 = q.DefectNum01, + PolishNum01 = q.PolishNum01, + ScrapNum01 = q.ScrapNum01, + QualifiedNum02 = q.QualifiedNum02, + PolishNum02 = q.PolishNum02, + ScrapNum02 = q.ScrapNum02, + QualifiedNum03 = q.QualifiedNum03, + PolishNum03 = q.PolishNum03, + ScrapNum03 = q.ScrapNum03, + }).MergeTable(); + + List QcFqcDTOList = query5.Where(predicate).ToPageList(pageNum, pageSize,ref totalCount); + return (QcFqcDTOList, totalCount); + + } } } diff --git a/ZR.Service/mes/qc/FirstFQCService.cs b/ZR.Service/mes/qc/FirstFQCService.cs index 6b4963c6..cf457ec7 100644 --- a/ZR.Service/mes/qc/FirstFQCService.cs +++ b/ZR.Service/mes/qc/FirstFQCService.cs @@ -1,11 +1,13 @@ using Infrastructure.Attribute; using Microsoft.Extensions.DependencyInjection; using System; +using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using ZR.Model.MES.qc; using ZR.Model.MES.qc.DTO; using ZR.Model.MES.qu; using ZR.Service.mes.qc.IService; @@ -19,8 +21,11 @@ namespace ZR.Service.mes.qc { public CheckItemTableDTO GetCheckItemTable() { - CheckItemTableDTO checkItem=new CheckItemTableDTO(); - checkItem.Paint = Queryable().Where(it => it.InspectionModule == "油漆").OrderBy(it=>it.Id).ToList(); + CheckItemTableDTO checkItem = new CheckItemTableDTO(); + + + checkItem.Paint = Queryable().Where(it => it.InspectionModule == "油漆").OrderBy(it => it.Id).ToList(); + checkItem.device = Queryable().Where(it => it.InspectionModule == "设备").OrderBy(it => it.Id).ToList(); checkItem.Blank = Queryable().Where(it => it.InspectionModule == "毛坯").OrderBy(it => it.Id).ToList(); checkItem.program = Queryable().Where(it => it.InspectionModule == "程序").OrderBy(it => it.Id).ToList(); @@ -29,5 +34,59 @@ namespace ZR.Service.mes.qc return checkItem; } + + /// + /// 保存检测结果 + /// + /// + /// + /// + /// + /// + public async Task SaveinspectItem(string workorder_id, string InspectionModule, string checkid, int counter) + { + //更新实时记录表 + QcFirstinspectionRecord record = new QcFirstinspectionRecord(); + record.Id = DateTime.Now.ToString("MMddHHmmss"); + record.InspectionModule = InspectionModule; + record.FKWorkorderId = workorder_id; + record.FKInpectionId = checkid; + record.Counter = counter; + var x = Context.Storageable(record) + .WhereColumns(it => new {it.FKInpectionId,it.FKWorkorderId,it.InspectionModule }) + .ToStorage(); + + x.AsInsertable.ExecuteCommandAsync(); //执行插入 + x.AsUpdateable.ExecuteCommandAsync(); //执行更新 + + ////更新初检报废表 + //if (Convert.ToInt32(checkid) / 10 % 10==3) + //{ + // QcAgaininspectionUselessnum scrap =new QcAgaininspectionUselessnum(); + // scrap.Id = "scrap" + DateTime.Now.ToString("MMddHHmmss"); + // scrap.FkInspectionitemId = checkid; + // scrap.FkFqcId = ""; + // scrap.ProductName = ""; + // scrap.Number= 1; + + + + //} + + ////更新初检xiazi表 + //if (Convert.ToInt32(checkid) / 10 % 10 == 1) + //{ + + //} + + + + + } + + + + + } } diff --git a/ZR.Service/mes/qc/IService/IFirstFQCService.cs b/ZR.Service/mes/qc/IService/IFirstFQCService.cs index 5c7aecb0..71fd70e9 100644 --- a/ZR.Service/mes/qc/IService/IFirstFQCService.cs +++ b/ZR.Service/mes/qc/IService/IFirstFQCService.cs @@ -10,5 +10,6 @@ namespace ZR.Service.mes.qc.IService public interface IFirstFQCService { public CheckItemTableDTO GetCheckItemTable(); + public Task SaveinspectItem(string workorder_id, string InspectionModule, string checkid, int counter); } }