diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WmGp12QualityStatisticsController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WmGp12QualityStatisticsController.cs index 34491f74..2e08c99d 100644 --- a/ZR.Admin.WebApi/Controllers/mes/wms/WmGp12QualityStatisticsController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WmGp12QualityStatisticsController.cs @@ -3,6 +3,7 @@ using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Model.MES.wms; using ZR.Model.MES.wms.Dto; +using ZR.Service.mes.wms; using ZR.Service.mes.wms.IService; //创建时间:2024-08-08 @@ -11,8 +12,8 @@ namespace ZR.Admin.WebApi.Controllers /// /// GP12质检记录表 /// - [Verify] - [Route("business/WmGp12QualityStatistics")] + //[Verify] + [Route("/mes/wm/WmGp12QualityStatistics")] public class WmGp12QualityStatisticsController : BaseController { /// @@ -33,7 +34,6 @@ namespace ZR.Admin.WebApi.Controllers /// /// [HttpGet("list")] - [ActionPermissionFilter(Permission = "business:wmgp12qualitystatistics:list")] public IActionResult QueryWmGp12QualityStatistics( [FromQuery] WmGp12QualityStatisticsQueryDto parm ) @@ -48,7 +48,6 @@ namespace ZR.Admin.WebApi.Controllers /// /// [HttpGet("{Id}")] - [ActionPermissionFilter(Permission = "business:wmgp12qualitystatistics:query")] public IActionResult GetWmGp12QualityStatistics(string Id) { var response = _WmGp12QualityStatisticsService.GetInfo(Id); @@ -62,15 +61,21 @@ namespace ZR.Admin.WebApi.Controllers /// /// [HttpPost] - [ActionPermissionFilter(Permission = "business:wmgp12qualitystatistics:add")] [Log(Title = "GP12质检记录表", BusinessType = BusinessType.INSERT)] public IActionResult AddWmGp12QualityStatistics([FromBody] WmGp12QualityStatisticsDto parm) { - var modal = parm.Adapt().ToCreate(HttpContext); + try + { + var modal = parm.Adapt().ToCreate(HttpContext); - var response = _WmGp12QualityStatisticsService.AddWmGp12QualityStatistics(modal); + var response = _WmGp12QualityStatisticsService.AddWmGp12QualityStatistics(modal); - return SUCCESS(response); + return SUCCESS(response); + } + catch (Exception e) + { + return ToResponse(ApiResult.Error("添加记录失败:" + e.Message)); + } } /// @@ -78,16 +83,22 @@ namespace ZR.Admin.WebApi.Controllers /// /// [HttpPut] - [ActionPermissionFilter(Permission = "business:wmgp12qualitystatistics:edit")] [Log(Title = "GP12质检记录表", BusinessType = BusinessType.UPDATE)] public IActionResult UpdateWmGp12QualityStatistics( [FromBody] WmGp12QualityStatisticsDto parm ) { - var modal = parm.Adapt().ToUpdate(HttpContext); - var response = _WmGp12QualityStatisticsService.UpdateWmGp12QualityStatistics(modal); + try + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _WmGp12QualityStatisticsService.UpdateWmGp12QualityStatistics(modal); - return ToResponse(response); + return ToResponse(response); + } + catch (Exception e) + { + return ToResponse(ApiResult.Error("修改记录失败:" + e.Message)); + } } /// @@ -95,7 +106,6 @@ namespace ZR.Admin.WebApi.Controllers /// /// [HttpDelete("{ids}")] - [ActionPermissionFilter(Permission = "business:wmgp12qualitystatistics:delete")] [Log(Title = "GP12质检记录表", BusinessType = BusinessType.DELETE)] public IActionResult DeleteWmGp12QualityStatistics(string ids) { diff --git a/ZR.Model/MES/wms/Dto/WmGp12QualityStatisticsDto.cs b/ZR.Model/MES/wms/Dto/WmGp12QualityStatisticsDto.cs index 5f6b81df..ae9244a1 100644 --- a/ZR.Model/MES/wms/Dto/WmGp12QualityStatisticsDto.cs +++ b/ZR.Model/MES/wms/Dto/WmGp12QualityStatisticsDto.cs @@ -25,19 +25,26 @@ namespace ZR.Model.MES.wms.Dto /// public class WmGp12QualityStatisticsDto { - [Required(ErrorMessage = "id不能为空")] public string Id { get; set; } public string WorkorderId { get; set; } public string Partnumber { get; set; } + public string Color { get; set; } + + public string Specification { get; set; } + + public string Description { get; set; } + public int? RequireNumber { get; set; } public string Team { get; set; } public int? QualifiedNumber { get; set; } + public string QualifiedRateStr { get; set; } + public decimal QualifiedRate { get; set; } public int? PaoguangTotal { get; set; } diff --git a/ZR.Model/MES/wms/WmPolishInventory.cs b/ZR.Model/MES/wms/WmPolishInventory.cs index f94b10d1..fab4b64b 100644 --- a/ZR.Model/MES/wms/WmPolishInventory.cs +++ b/ZR.Model/MES/wms/WmPolishInventory.cs @@ -13,6 +13,12 @@ namespace ZR.Model.MES.wms [SugarColumn(IsPrimaryKey = true, IsIdentity = false)] public string Id { get; set; } + /// + /// 工单号 + /// + [SugarColumn(IsIgnore = true)] + public string WorkOrder { get; set; } + /// /// 毛坯号 /// diff --git a/ZR.Service/mes/qc/FirstFQCService.cs b/ZR.Service/mes/qc/FirstFQCService.cs index 35d85ba2..095783d5 100644 --- a/ZR.Service/mes/qc/FirstFQCService.cs +++ b/ZR.Service/mes/qc/FirstFQCService.cs @@ -1,8 +1,8 @@ -using Infrastructure.Attribute; -using SqlSugar; -using System; +using System; using System.Linq; using System.Threading.Tasks; +using Infrastructure.Attribute; +using SqlSugar; using ZR.Model.MES.pro; using ZR.Model.MES.qc; using ZR.Model.MES.qc.DTO; @@ -13,7 +13,6 @@ using ZR.Service.mes.wms; namespace ZR.Service.mes.qc { - [AppService(ServiceType = typeof(IFirstFQCService), ServiceLifetime = LifeTime.Transient)] public class FirstFQCService : BaseService, IFirstFQCService { @@ -27,13 +26,18 @@ namespace ZR.Service.mes.qc { CheckItemTableDTO checkItem = new CheckItemTableDTO(); - - checkItem.Paint = Queryable().Where(it => it.InspectionModule == "油漆").OrderBy(it => it.Id).ToList(); + checkItem.Paint = Queryable() + .Where(it => it.InspectionModule == "油漆") + .OrderBy(it => it.Id) + .ToList(); checkItem.Paint.ForEach(item => { - - QcFirstinspectionRecord record = Context.Queryable() - .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString()).First(); + QcFirstinspectionRecord record = Context + .Queryable() + .Where(it => + it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -42,15 +46,19 @@ namespace ZR.Service.mes.qc { item.Counter = 0; } - - - }); - checkItem.device = Queryable().Where(it => it.InspectionModule == "设备").OrderBy(it => it.Id).ToList(); + checkItem.device = Queryable() + .Where(it => it.InspectionModule == "设备") + .OrderBy(it => it.Id) + .ToList(); checkItem.device.ForEach(item => { - QcFirstinspectionRecord record = Context.Queryable() - .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString()).First(); + QcFirstinspectionRecord record = Context + .Queryable() + .Where(it => + it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -59,13 +67,19 @@ namespace ZR.Service.mes.qc { item.Counter = 0; } - }); - checkItem.Blank = Queryable().Where(it => it.InspectionModule == "毛坯").OrderBy(it => it.Id).ToList(); + checkItem.Blank = Queryable() + .Where(it => it.InspectionModule == "毛坯") + .OrderBy(it => it.Id) + .ToList(); checkItem.Blank.ForEach(item => { - QcFirstinspectionRecord record = Context.Queryable() - .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString()).First(); + QcFirstinspectionRecord record = Context + .Queryable() + .Where(it => + it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -74,13 +88,19 @@ namespace ZR.Service.mes.qc { item.Counter = 0; } - }); - checkItem.program = Queryable().Where(it => it.InspectionModule == "程序").OrderBy(it => it.Id).ToList(); + checkItem.program = Queryable() + .Where(it => it.InspectionModule == "程序") + .OrderBy(it => it.Id) + .ToList(); checkItem.program.ForEach(item => { - QcFirstinspectionRecord record = Context.Queryable() - .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString()).First(); + QcFirstinspectionRecord record = Context + .Queryable() + .Where(it => + it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -90,11 +110,18 @@ namespace ZR.Service.mes.qc item.Counter = 0; } }); - checkItem.Team = Queryable().Where(it => it.InspectionModule == "班组操作").OrderBy(it => it.Id).ToList(); + checkItem.Team = Queryable() + .Where(it => it.InspectionModule == "班组操作") + .OrderBy(it => it.Id) + .ToList(); checkItem.Team.ForEach(item => { - QcFirstinspectionRecord record = Context.Queryable() - .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString()).First(); + QcFirstinspectionRecord record = Context + .Queryable() + .Where(it => + it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -106,7 +133,6 @@ namespace ZR.Service.mes.qc }); return checkItem; - } /// @@ -124,10 +150,9 @@ namespace ZR.Service.mes.qc step.CreatedTime = DateTime.Now; step.WorkoderId = workorderID; - var x = Context.Storageable(step).WhereColumns(it => it.WorkoderId).ToStorage(); - x.AsInsertable.ExecuteCommand();//不存在插入 - x.AsUpdateable.ExecuteCommand();//存在更新 + x.AsInsertable.ExecuteCommand(); //不存在插入 + x.AsUpdateable.ExecuteCommand(); //存在更新 return 1; } @@ -142,13 +167,18 @@ namespace ZR.Service.mes.qc { CheckItemTableDTO checkItem = new CheckItemTableDTO(); - - checkItem.Paint = Queryable().Where(it => it.InspectionModule == "油漆").OrderBy(it => it.Id).ToList(); + checkItem.Paint = Queryable() + .Where(it => it.InspectionModule == "油漆") + .OrderBy(it => it.Id) + .ToList(); checkItem.Paint.ForEach(item => { - - QcAgaininspectionRecord record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First(); + QcAgaininspectionRecord record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -157,15 +187,19 @@ namespace ZR.Service.mes.qc { item.Counter = 0; } - - - }); - checkItem.device = Queryable().Where(it => it.InspectionModule == "设备").OrderBy(it => it.Id).ToList(); + checkItem.device = Queryable() + .Where(it => it.InspectionModule == "设备") + .OrderBy(it => it.Id) + .ToList(); checkItem.device.ForEach(item => { - QcAgaininspectionRecord record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First(); + QcAgaininspectionRecord record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -174,13 +208,19 @@ namespace ZR.Service.mes.qc { item.Counter = 0; } - }); - checkItem.Blank = Queryable().Where(it => it.InspectionModule == "毛坯").OrderBy(it => it.Id).ToList(); + checkItem.Blank = Queryable() + .Where(it => it.InspectionModule == "毛坯") + .OrderBy(it => it.Id) + .ToList(); checkItem.Blank.ForEach(item => { - QcAgaininspectionRecord record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First(); + QcAgaininspectionRecord record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -189,13 +229,19 @@ namespace ZR.Service.mes.qc { item.Counter = 0; } - }); - checkItem.program = Queryable().Where(it => it.InspectionModule == "程序").OrderBy(it => it.Id).ToList(); + checkItem.program = Queryable() + .Where(it => it.InspectionModule == "程序") + .OrderBy(it => it.Id) + .ToList(); checkItem.program.ForEach(item => { - QcAgaininspectionRecord record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First(); + QcAgaininspectionRecord record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -205,11 +251,18 @@ namespace ZR.Service.mes.qc item.Counter = 0; } }); - checkItem.Team = Queryable().Where(it => it.InspectionModule == "班组操作").OrderBy(it => it.Id).ToList(); + checkItem.Team = Queryable() + .Where(it => it.InspectionModule == "班组操作") + .OrderBy(it => it.Id) + .ToList(); checkItem.Team.ForEach(item => { - QcAgaininspectionRecord record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First(); + QcAgaininspectionRecord record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -221,11 +274,8 @@ namespace ZR.Service.mes.qc }); return checkItem; - } - - /// /// 获取检测项 (三检) /// @@ -236,13 +286,18 @@ namespace ZR.Service.mes.qc { CheckItemTableDTO checkItem = new CheckItemTableDTO(); - - checkItem.Paint = Queryable().Where(it => it.InspectionModule == "油漆").OrderBy(it => it.Id).ToList(); + checkItem.Paint = Queryable() + .Where(it => it.InspectionModule == "油漆") + .OrderBy(it => it.Id) + .ToList(); checkItem.Paint.ForEach(item => { - - QcFinalinspectionRecord record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First(); + QcFinalinspectionRecord record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -251,15 +306,19 @@ namespace ZR.Service.mes.qc { item.Counter = 0; } - - - }); - checkItem.device = Queryable().Where(it => it.InspectionModule == "设备").OrderBy(it => it.Id).ToList(); + checkItem.device = Queryable() + .Where(it => it.InspectionModule == "设备") + .OrderBy(it => it.Id) + .ToList(); checkItem.device.ForEach(item => { - QcFinalinspectionRecord record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First(); + QcFinalinspectionRecord record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -268,13 +327,19 @@ namespace ZR.Service.mes.qc { item.Counter = 0; } - }); - checkItem.Blank = Queryable().Where(it => it.InspectionModule == "毛坯").OrderBy(it => it.Id).ToList(); + checkItem.Blank = Queryable() + .Where(it => it.InspectionModule == "毛坯") + .OrderBy(it => it.Id) + .ToList(); checkItem.Blank.ForEach(item => { - QcFinalinspectionRecord record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First(); + QcFinalinspectionRecord record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -283,13 +348,19 @@ namespace ZR.Service.mes.qc { item.Counter = 0; } - }); - checkItem.program = Queryable().Where(it => it.InspectionModule == "程序").OrderBy(it => it.Id).ToList(); + checkItem.program = Queryable() + .Where(it => it.InspectionModule == "程序") + .OrderBy(it => it.Id) + .ToList(); checkItem.program.ForEach(item => { - QcFinalinspectionRecord record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First(); + QcFinalinspectionRecord record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -299,11 +370,18 @@ namespace ZR.Service.mes.qc item.Counter = 0; } }); - checkItem.Team = Queryable().Where(it => it.InspectionModule == "班组操作").OrderBy(it => it.Id).ToList(); + checkItem.Team = Queryable() + .Where(it => it.InspectionModule == "班组操作") + .OrderBy(it => it.Id) + .ToList(); checkItem.Team.ForEach(item => { - QcFinalinspectionRecord record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First(); + QcFinalinspectionRecord record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString() + ) + .First(); if (record != null) { item.Counter = record.Counter; @@ -315,10 +393,8 @@ namespace ZR.Service.mes.qc }); return checkItem; - } - /// /// 保存首次检测结果 /// @@ -327,9 +403,13 @@ namespace ZR.Service.mes.qc /// 检测项 /// 数量 /// - public async Task SaveinspectItem_v1(string workorder_id, string InspectionModule, string checkid, int counter) + public async Task SaveinspectItem_v1( + string workorder_id, + string InspectionModule, + string checkid, + int counter + ) { - //更新实时记录表 QcFirstinspectionRecord record = new QcFirstinspectionRecord(); record.Id = DateTime.Now.ToString("yyMMddHHmmss"); @@ -338,9 +418,15 @@ namespace ZR.Service.mes.qc record.FKInpectionId = checkid.Substring(0, 3); record.Counter = counter; record.UpdatedTime = DateTime.Now; - var x = Context.Storageable(record) - .WhereColumns(it => new { it.FKInpectionId, it.FKWorkorderId, it.InspectionModule }) - .ToStorage(); + var x = Context + .Storageable(record) + .WhereColumns(it => new + { + it.FKInpectionId, + it.FKWorkorderId, + it.InspectionModule + }) + .ToStorage(); x.AsInsertable.ExecuteCommandAsync(); //执行插入 x.AsUpdateable.ExecuteCommandAsync(); //执行更新 @@ -353,7 +439,7 @@ namespace ZR.Service.mes.qc // scrap.FkInspectionitemId = checkid; // scrap.FkFqcId = ""; // scrap.ProductName = ""; - // scrap.Number= 1; + // scrap.Number= 1; @@ -364,14 +450,8 @@ namespace ZR.Service.mes.qc //{ //} - - - - } - - /// /// 保存二次检测结果 /// @@ -380,7 +460,12 @@ namespace ZR.Service.mes.qc /// 检测项 /// 数量 /// - public async Task SaveinspectItem_v2(string workorder_id, string InspectionModule, string checkid, int counter) + public async Task SaveinspectItem_v2( + string workorder_id, + string InspectionModule, + string checkid, + int counter + ) { //更新实时记录表 QcAgaininspectionRecord record = new QcAgaininspectionRecord(); @@ -390,9 +475,15 @@ namespace ZR.Service.mes.qc record.FkInpectionId = checkid.Substring(0, 3); record.Counter = counter; record.UpdatedTime = DateTime.Now; - var x = Context.Storageable(record) - .WhereColumns(it => new { it.FkInpectionId, it.FkWorkorderId, it.InspectionModule }) - .ToStorage(); + var x = Context + .Storageable(record) + .WhereColumns(it => new + { + it.FkInpectionId, + it.FkWorkorderId, + it.InspectionModule + }) + .ToStorage(); x.AsInsertable.ExecuteCommandAsync(); //执行插入 x.AsUpdateable.ExecuteCommandAsync(); //执行更新 @@ -405,7 +496,7 @@ namespace ZR.Service.mes.qc // scrap.FkInspectionitemId = checkid; // scrap.FkFqcId = ""; // scrap.ProductName = ""; - // scrap.Number= 1; + // scrap.Number= 1; @@ -416,10 +507,6 @@ namespace ZR.Service.mes.qc //{ //} - - - - } /// @@ -430,7 +517,12 @@ namespace ZR.Service.mes.qc /// 检测项 /// 数量 /// - public async Task SaveinspectItem_v3(string workorder_id, string InspectionModule, string checkid, int counter) + public async Task SaveinspectItem_v3( + string workorder_id, + string InspectionModule, + string checkid, + int counter + ) { //更新实时记录表 QcFinalinspectionRecord record = new QcFinalinspectionRecord(); @@ -440,12 +532,24 @@ namespace ZR.Service.mes.qc record.FkInpectionId = checkid.Substring(0, 3); record.Counter = counter; record.UpdatedTime = DateTime.Now; - var x = Context.Storageable(record) - .WhereColumns(it => new { it.FkInpectionId, it.FkWorkorderId, it.InspectionModule }) - .ToStorage(); + var x = Context + .Storageable(record) + .WhereColumns(it => new + { + it.FkInpectionId, + it.FkWorkorderId, + it.InspectionModule + }) + .ToStorage(); x.AsInsertable.ExecuteCommandAsync(); //执行插入 - x.AsUpdateable.UpdateColumns(it => new { it.UpdatedBy, it.UpdatedTime, it.Counter }).ExecuteCommandAsync(); //执行更新 + x.AsUpdateable.UpdateColumns(it => new + { + it.UpdatedBy, + it.UpdatedTime, + it.Counter + }) + .ExecuteCommandAsync(); //执行更新 ////更新初检报废表 //if (Convert.ToInt32(checkid) / 10 % 10==3) @@ -455,7 +559,7 @@ namespace ZR.Service.mes.qc // scrap.FkInspectionitemId = checkid; // scrap.FkFqcId = ""; // scrap.ProductName = ""; - // scrap.Number= 1; + // scrap.Number= 1; @@ -466,10 +570,6 @@ namespace ZR.Service.mes.qc //{ //} - - - - } /// @@ -481,7 +581,14 @@ namespace ZR.Service.mes.qc /// 颜色 /// 班组 /// 投入数 - public void quailtyStatics(string workorderid, string productName, string leftRight, string color, string team, int inputNum) + public void quailtyStatics( + string workorderid, + string productName, + string leftRight, + string color, + string team, + int inputNum + ) { QcFqc record = new QcFqc(); record.Id = DateTime.Now.ToString("MMddHHmmss"); @@ -494,19 +601,24 @@ namespace ZR.Service.mes.qc //1.1 首检合格数=投入数-抛光数-打磨数-报废数 - List qcFirstinspections = Context.Queryable().Where(it => it.FKWorkorderId == workorderid).ToList(); + List qcFirstinspections = Context + .Queryable() + .Where(it => it.FKWorkorderId == workorderid) + .ToList(); int NoQualifiedNum01 = 0; qcFirstinspections.ForEach(it => { NoQualifiedNum01 += (int)it.Counter; - }); record.QualifiedNum01 = inputNum - NoQualifiedNum01; - //1.2 首检抛光数 - List defectNum01RecordList = Context.Queryable().Where(it => it.FKWorkorderId == workorderid).Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 1 + "_" }).ToList(); + List defectNum01RecordList = Context + .Queryable() + .Where(it => it.FKWorkorderId == workorderid) + .Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 1 + "_" }) + .ToList(); int defectNum01RecordSum = 0; defectNum01RecordList.ForEach(it => { @@ -515,7 +627,11 @@ namespace ZR.Service.mes.qc record.DefectNum01 = defectNum01RecordSum; //1.3 首检打磨数 - List polishNum01RecordList = Context.Queryable().Where(it => it.FKWorkorderId == workorderid).Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 2 + "_" }).ToList(); + List polishNum01RecordList = Context + .Queryable() + .Where(it => it.FKWorkorderId == workorderid) + .Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 2 + "_" }) + .ToList(); int polishNum01RecordSum = 0; polishNum01RecordList.ForEach(it => { @@ -524,7 +640,11 @@ namespace ZR.Service.mes.qc record.PolishNum01 = polishNum01RecordSum; //1.4 首检报废数 - List scrapNum01RecordList = Context.Queryable().Where(it => it.FKWorkorderId == workorderid).Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 3 + "_" }).ToList(); + List scrapNum01RecordList = Context + .Queryable() + .Where(it => it.FKWorkorderId == workorderid) + .Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 3 + "_" }) + .ToList(); int scrapNum01RecordSum = 0; scrapNum01RecordList.ForEach(it => { @@ -532,22 +652,27 @@ namespace ZR.Service.mes.qc }); record.PolishNum01 = scrapNum01RecordSum; - //TODO 2. 处理二检 //2.1 二检的合格数 = 首检的抛光数 - 二检打磨 - 二检报废 - List qcAgaininspections = Context.Queryable().Where(it => it.FkWorkorderId == workorderid).ToList(); + List qcAgaininspections = Context + .Queryable() + .Where(it => it.FkWorkorderId == workorderid) + .ToList(); int NoQualifiedNum02 = 0; qcAgaininspections.ForEach(it => - { - NoQualifiedNum02 += (int)it.Counter; - - }); + { + NoQualifiedNum02 += (int)it.Counter; + }); record.QualifiedNum02 = defectNum01RecordSum - NoQualifiedNum02; //2.2 二检打磨数 - List polishNum02RecordList = Context.Queryable().Where(it => it.FkWorkorderId == workorderid).Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 2 + "_" }).ToList(); + List polishNum02RecordList = Context + .Queryable() + .Where(it => it.FkWorkorderId == workorderid) + .Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 2 + "_" }) + .ToList(); int polishNum02RecordSum = 0; polishNum02RecordList.ForEach(it => @@ -556,9 +681,12 @@ namespace ZR.Service.mes.qc }); record.PolishNum02 = polishNum02RecordSum; - //2.3 二检报废 - List scrapNum02RecordList = Context.Queryable().Where(it => it.FkWorkorderId == workorderid).Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 3 + "_" }).ToList(); + List scrapNum02RecordList = Context + .Queryable() + .Where(it => it.FkWorkorderId == workorderid) + .Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 3 + "_" }) + .ToList(); int scrapNum02RecordSum = 0; scrapNum02RecordList.ForEach(it => { @@ -566,23 +694,29 @@ namespace ZR.Service.mes.qc }); record.ScrapNum02 = scrapNum02RecordSum; - //TODO 3. 处理三检 // 3.1 三检合格数=(一检合格数 + 二检合格数) - (三检打磨数+三检报废数) - List qcFinalinspections = Context.Queryable().Where(it => it.FkWorkorderId == workorderid).ToList(); + List qcFinalinspections = Context + .Queryable() + .Where(it => it.FkWorkorderId == workorderid) + .ToList(); int NoQualifiedNum03 = 0; qcAgaininspections.ForEach(it => { NoQualifiedNum03 += (int)it.Counter; - }); - record.QualifiedNum03 = (record.QualifiedNum01 + record.QualifiedNum02) - NoQualifiedNum03; + record.QualifiedNum03 = + (record.QualifiedNum01 + record.QualifiedNum02) - NoQualifiedNum03; //3.2 三检打磨数 - List polishNum03RecordList = Context.Queryable().Where(it => it.FkWorkorderId == workorderid).Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 2 + "_" }).ToList(); + List polishNum03RecordList = Context + .Queryable() + .Where(it => it.FkWorkorderId == workorderid) + .Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 2 + "_" }) + .ToList(); int polishNum03RecordSum = 0; polishNum03RecordList.ForEach(it => @@ -593,7 +727,11 @@ namespace ZR.Service.mes.qc //3.3 三检报废数 - List scrapNum03RecordList = Context.Queryable().Where(it => it.FkWorkorderId == workorderid).Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 3 + "_" }).ToList(); + List scrapNum03RecordList = Context + .Queryable() + .Where(it => it.FkWorkorderId == workorderid) + .Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 3 + "_" }) + .ToList(); int scrapNum03RecordSum = 0; scrapNum03RecordList.ForEach(it => { @@ -615,8 +753,8 @@ namespace ZR.Service.mes.qc record.CreatedTime = DateTime.Now; Context.Insertable(record).ExecuteCommand(); - } + /// /// 计算百分比 /// @@ -630,10 +768,9 @@ namespace ZR.Service.mes.qc return Math.Round(percentage, 2); } - public static QcCurrentWorkorderDto Now_producting_Workorder_first = null; //当前生产工单 首检 - public static QcCurrentWorkorderDto Now_producting_Workorder_again = null; //当前生产工单 二检 - public static QcCurrentWorkorderDto Now_producting_Workorder_thirty = null; //当前生产工单 三检 - + public static QcCurrentWorkorderDto Now_producting_Workorder_first = null; //当前生产工单 首检 + public static QcCurrentWorkorderDto Now_producting_Workorder_again = null; //当前生产工单 二检 + public static QcCurrentWorkorderDto Now_producting_Workorder_thirty = null; //当前生产工单 三检 /// /// 获取当前_生产中_工单列表 @@ -642,34 +779,39 @@ namespace ZR.Service.mes.qc /// public List GetNow_producting_WorkorderList() { - List workorders = Context.Queryable().Where(it => it.Remark3 == "是").Where(it => it.Status == 1).OrderBy(it => it.Sort).ToList(); + List workorders = Context + .Queryable() + .Where(it => it.Remark3 == "是") + .Where(it => it.Status == 1) + .OrderBy(it => it.Sort) + .ToList(); List qcCurrentList = new List(); foreach (ProWorkorder_v2 item in workorders) { - qcCurrentList.Add(new QcCurrentWorkorderDto() - { - ClientWorkorder = item.ClientWorkorder, - ProductDescription = item.ProductDescription, - FinishedPartNumber = item.FinishedPartNumber, - Specifications = item.Specifications, - Colour = item.Colour, - Team = "A", - PreviousNumber = item.PreviousNumber, - FirstPassNumber = 0, - FirstPassRate = 0.0, - PolisheNumber = 0, - ScrapNumber = 0, - DefectNumber = 0 - }); + qcCurrentList.Add( + new QcCurrentWorkorderDto() + { + ClientWorkorder = item.ClientWorkorder, + ProductDescription = item.ProductDescription, + FinishedPartNumber = item.FinishedPartNumber, + Specifications = item.Specifications, + Colour = item.Colour, + Team = "A", + PreviousNumber = item.PreviousNumber, + FirstPassNumber = 0, + FirstPassRate = 0.0, + PolisheNumber = 0, + ScrapNumber = 0, + DefectNumber = 0 + } + ); ; - } return qcCurrentList; } - /// /// 获取当前生产工单 一检 /// @@ -678,7 +820,8 @@ namespace ZR.Service.mes.qc public QcCurrentWorkorderDto GetcurrentWorkorder_first() { //获取状态为1的生产工单列表 - List Now_producting_WorkorderList = GetNow_producting_WorkorderList(); + List Now_producting_WorkorderList = + GetNow_producting_WorkorderList(); // 当前没有生产工单 if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0) { @@ -694,10 +837,8 @@ namespace ZR.Service.mes.qc { return Now_producting_Workorder_first; } - } - /// /// 获取当前生产工单 二检 /// @@ -706,7 +847,8 @@ namespace ZR.Service.mes.qc public QcCurrentWorkorderDto GetcurrentWorkorder_again() { //获取状态为1的生产工单列表 - List Now_producting_WorkorderList = GetNow_producting_WorkorderList(); + List Now_producting_WorkorderList = + GetNow_producting_WorkorderList(); // 当前没有生产工单 if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0) { @@ -722,11 +864,8 @@ namespace ZR.Service.mes.qc { return Now_producting_Workorder_again; } - } - - /// /// 获取当前生产工单 三检 /// @@ -735,7 +874,8 @@ namespace ZR.Service.mes.qc public QcCurrentWorkorderDto GetcurrentWorkorder_thirty() { //获取状态为1的生产工单列表 - List Now_producting_WorkorderList = GetNow_producting_WorkorderList(); + List Now_producting_WorkorderList = + GetNow_producting_WorkorderList(); // 当前没有生产工单 if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0) { @@ -751,24 +891,18 @@ namespace ZR.Service.mes.qc { return Now_producting_Workorder_thirty; } - } - - - /// + /// /// 获取下一个生产工单 一检 /// /// /// public QcCurrentWorkorderDto GetcurrentWorkorder_next_first() { - - - - //获取状态为1的生产工单列表 - List Now_producting_WorkorderList = GetNow_producting_WorkorderList(); + List Now_producting_WorkorderList = + GetNow_producting_WorkorderList(); // 当前没有生产工单 if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0) { @@ -777,14 +911,15 @@ namespace ZR.Service.mes.qc } else { - // 当前没有生产工单 if (Now_producting_Workorder_first == null) { return null; } //获取上一个工单号 游标 - int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_first.ClientWorkorder); + int index = Now_producting_WorkorderList.FindIndex(x => + x.ClientWorkorder == Now_producting_Workorder_first.ClientWorkorder + ); if (index < 0) { // 逻辑异常 @@ -797,16 +932,13 @@ namespace ZR.Service.mes.qc return null; - } else { Now_producting_Workorder_first = Now_producting_WorkorderList[index + 1]; return Now_producting_Workorder_first; } - } - } /// @@ -816,9 +948,9 @@ namespace ZR.Service.mes.qc /// public QcCurrentWorkorderDto GetcurrentWorkorder_next_again() { - //获取状态为1的生产工单列表 - List Now_producting_WorkorderList = GetNow_producting_WorkorderList(); + List Now_producting_WorkorderList = + GetNow_producting_WorkorderList(); // 当前没有生产工单 if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0) { @@ -827,14 +959,15 @@ namespace ZR.Service.mes.qc } else { - // 当前没有生产工单 if (Now_producting_Workorder_again == null) { return null; } //获取上一个工单号 游标 - int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_again.ClientWorkorder); + int index = Now_producting_WorkorderList.FindIndex(x => + x.ClientWorkorder == Now_producting_Workorder_again.ClientWorkorder + ); if (index < 0) { // 逻辑异常 @@ -847,16 +980,13 @@ namespace ZR.Service.mes.qc return null; - } else { Now_producting_Workorder_again = Now_producting_WorkorderList[index + 1]; return Now_producting_Workorder_again; } - } - } /// @@ -867,7 +997,8 @@ namespace ZR.Service.mes.qc public QcCurrentWorkorderDto GetcurrentWorkorder_next_thirty() { //获取状态为1的生产工单列表 - List Now_producting_WorkorderList = GetNow_producting_WorkorderList(); + List Now_producting_WorkorderList = + GetNow_producting_WorkorderList(); // 当前没有生产工单 if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0) { @@ -876,14 +1007,15 @@ namespace ZR.Service.mes.qc } else { - // 当前没有生产工单 if (Now_producting_Workorder_thirty == null) { return null; } //获取上一个工单号 游标 - int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_thirty.ClientWorkorder); + int index = Now_producting_WorkorderList.FindIndex(x => + x.ClientWorkorder == Now_producting_Workorder_thirty.ClientWorkorder + ); if (index < 0) { // 逻辑异常 @@ -896,52 +1028,44 @@ namespace ZR.Service.mes.qc return null; - } else { Now_producting_Workorder_thirty = Now_producting_WorkorderList[index + 1]; return Now_producting_Workorder_thirty; } - } - } - - - - /// /// 记录检测项结果 /// /// 工单 /// 检测结果 - private void Record_inspect_result(string workorder_id, List inspectionList, string createBy) + private void Record_inspect_result( + string workorder_id, + List inspectionList, + string createBy + ) { if (inspectionList != null && inspectionList.Count > 0) { foreach (var item in inspectionList) { - QcFirstinspectionRecord record = new QcFirstinspectionRecord(); - record.Id = DateTime.Now.ToString("yyMMddHHmmss") + inspectionList.IndexOf(item); + record.Id = + DateTime.Now.ToString("yyMMddHHmmss") + inspectionList.IndexOf(item); record.FKWorkorderId = workorder_id; record.FKInpectionId = item.Id.ToString(); record.InspectionModule = item.InspectionModule; record.Counter = item.Counter; record.CreatedBy = createBy; - //Context.Storageable() } - } - - } - /// /// 获取上一个工单 首检 /// @@ -951,7 +1075,8 @@ namespace ZR.Service.mes.qc public QcCurrentWorkorderDto GetcurrentWorkorder_previous_first() { //获取状态为1的生产工单列表 - List Now_producting_WorkorderList = GetNow_producting_WorkorderList(); + List Now_producting_WorkorderList = + GetNow_producting_WorkorderList(); // 当前没有生产工单 if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0) { @@ -960,14 +1085,15 @@ namespace ZR.Service.mes.qc } else { - // 当前没有生产工单 if (Now_producting_Workorder_first == null) { return null; } //获取上一个工单号 游标 - int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_first.ClientWorkorder); + int index = Now_producting_WorkorderList.FindIndex(x => + x.ClientWorkorder == Now_producting_Workorder_first.ClientWorkorder + ); if (index < 0) { // 逻辑异常 @@ -978,20 +1104,15 @@ namespace ZR.Service.mes.qc { // 已经是最后一个了没有 return null; - } else { Now_producting_Workorder_first = Now_producting_WorkorderList[index - 1]; return Now_producting_Workorder_first; } - } } - - - /// /// 获取上一个工单 二检 /// @@ -1001,7 +1122,8 @@ namespace ZR.Service.mes.qc public QcCurrentWorkorderDto GetcurrentWorkorder_previous_again() { //获取状态为1的生产工单列表 - List Now_producting_WorkorderList = GetNow_producting_WorkorderList(); + List Now_producting_WorkorderList = + GetNow_producting_WorkorderList(); // 当前没有生产工单 if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0) { @@ -1010,14 +1132,15 @@ namespace ZR.Service.mes.qc } else { - // 当前没有生产工单 if (Now_producting_Workorder_again == null) { return null; } //获取上一个工单号 游标 - int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_again.ClientWorkorder); + int index = Now_producting_WorkorderList.FindIndex(x => + x.ClientWorkorder == Now_producting_Workorder_again.ClientWorkorder + ); if (index < 0) { // 逻辑异常 @@ -1028,20 +1151,15 @@ namespace ZR.Service.mes.qc { // 已经是最后一个了没有 return null; - } else { Now_producting_Workorder_again = Now_producting_WorkorderList[index - 1]; return Now_producting_Workorder_again; } - } } - - - /// /// 获取上一个工单 三检 /// @@ -1051,7 +1169,8 @@ namespace ZR.Service.mes.qc public QcCurrentWorkorderDto GetcurrentWorkorder_previous_thirty() { //获取状态为1的生产工单列表 - List Now_producting_WorkorderList = GetNow_producting_WorkorderList(); + List Now_producting_WorkorderList = + GetNow_producting_WorkorderList(); // 当前没有生产工单 if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0) { @@ -1060,14 +1179,15 @@ namespace ZR.Service.mes.qc } else { - // 当前没有生产工单 if (Now_producting_Workorder_thirty == null) { return null; } //获取上一个工单号 游标 - int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_thirty.ClientWorkorder); + int index = Now_producting_WorkorderList.FindIndex(x => + x.ClientWorkorder == Now_producting_Workorder_thirty.ClientWorkorder + ); if (index < 0) { // 逻辑异常 @@ -1078,20 +1198,15 @@ namespace ZR.Service.mes.qc { // 已经是最后一个了没有 return null; - } else { Now_producting_Workorder_thirty = Now_producting_WorkorderList[index - 1]; return Now_producting_Workorder_thirty; } - } } - - - /// /// 缺陷项目 累加 (首检) /// @@ -1100,12 +1215,21 @@ namespace ZR.Service.mes.qc /// 要累加的值 /// 最终累加的值 /// - public int Accumulator_first(string workorder_id, int checkid, int number, string InspectionModule, string name) + public int Accumulator_first( + string workorder_id, + int checkid, + int number, + string InspectionModule, + string name + ) { int result = 0; //TODO 获取已知的的检测项 +1 - QcFirstinspectionRecord exist_record = Context.Queryable() - .Where(it => it.FKWorkorderId == workorder_id && it.FKInpectionId == checkid.ToString()) + QcFirstinspectionRecord exist_record = Context + .Queryable() + .Where(it => + it.FKWorkorderId == workorder_id && it.FKInpectionId == checkid.ToString() + ) .First(); if (exist_record == null) @@ -1125,29 +1249,25 @@ namespace ZR.Service.mes.qc Context.Insertable(record).ExecuteCommand(); result = 1; - } else { - result = Context.Updateable() + result = Context + .Updateable() .SetColumns(it => it.Counter == (exist_record.Counter + number)) .SetColumns(it => it.UpdatedTime == DateTime.Now) .SetColumns(it => it.UpdatedBy == name) - .Where(it => it.FKInpectionId == checkid.ToString() && it.FKWorkorderId == workorder_id) + .Where(it => + it.FKInpectionId == checkid.ToString() && it.FKWorkorderId == workorder_id + ) .ExecuteCommand(); result = (int)exist_record.Counter + number; - } - - - - - - return result; } + /// /// 缺陷项目 累加 (二检) /// @@ -1156,14 +1276,21 @@ namespace ZR.Service.mes.qc /// /// /// - public int Accumulator_again(string workorder_id, int checkid, int number, string InspectionModule, string name) + public int Accumulator_again( + string workorder_id, + int checkid, + int number, + string InspectionModule, + string name + ) { - - int result = 0; //TODO 获取已知的的检测项 +1 - QcAgaininspectionRecord exist_record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorder_id && it.FkInpectionId == checkid.ToString()) + QcAgaininspectionRecord exist_record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorder_id && it.FkInpectionId == checkid.ToString() + ) .First(); if (exist_record == null) @@ -1183,23 +1310,25 @@ namespace ZR.Service.mes.qc Context.Insertable(record).ExecuteCommand(); result = 1; - } else { - result = Context.Updateable() + result = Context + .Updateable() .SetColumns(it => it.Counter == (exist_record.Counter + number)) .SetColumns(it => it.UpdatedTime == DateTime.Now) .SetColumns(it => it.UpdatedBy == name) - .Where(it => it.FkInpectionId == checkid.ToString() && it.FkWorkorderId == workorder_id) - .ExecuteCommand(); + .Where(it => + it.FkInpectionId == checkid.ToString() && it.FkWorkorderId == workorder_id + ) + .ExecuteCommand(); result = (int)exist_record.Counter + number; - } return result; } + /// /// 缺陷项目 累加 (三检) /// @@ -1208,14 +1337,21 @@ namespace ZR.Service.mes.qc /// /// /// - public int Accumulator_thirty(string workorder_id, int checkid, int number, string InspectionModule, string name) + public int Accumulator_thirty( + string workorder_id, + int checkid, + int number, + string InspectionModule, + string name + ) { - - int result = 0; //TODO 获取已知的的检测项 +1 - QcFinalinspectionRecord exist_record = Context.Queryable() - .Where(it => it.FkWorkorderId == workorder_id && it.FkInpectionId == checkid.ToString()) + QcFinalinspectionRecord exist_record = Context + .Queryable() + .Where(it => + it.FkWorkorderId == workorder_id && it.FkInpectionId == checkid.ToString() + ) .First(); if (exist_record == null) @@ -1235,31 +1371,25 @@ namespace ZR.Service.mes.qc Context.Insertable(record).ExecuteCommand(); result = 1; - } else { - result = Context.Updateable() + result = Context + .Updateable() .SetColumns(it => it.Counter == (exist_record.Counter + number)) .SetColumns(it => it.UpdatedTime == DateTime.Now) .SetColumns(it => it.UpdatedBy == name) - .Where(it => it.FkInpectionId == checkid.ToString() && it.FkWorkorderId == workorder_id) - .ExecuteCommand(); + .Where(it => + it.FkInpectionId == checkid.ToString() && it.FkWorkorderId == workorder_id + ) + .ExecuteCommand(); result = (int)exist_record.Counter + number; - } - - - - - - return result; } - /// /// 计算当前工单下所有抛光总数 /// @@ -1267,19 +1397,22 @@ namespace ZR.Service.mes.qc /// public int CalculatePolishTotalNumber(string workorder_id) { - var list = Context.Queryable() - .Where(it => it.FKWorkorderId == workorder_id) - .Where("fk_inpection_id like @fk_inpection_id", new { fk_inpection_id = "_" + 1 + "_" }) - .GroupBy(it => it.FKWorkorderId) - .Select(it => new - { - sum = SqlFunc.AggregateSum(it.Counter ?? 0) - }).First(); + var list = Context + .Queryable() + .Where(it => it.FKWorkorderId == workorder_id) + .Where( + "fk_inpection_id like @fk_inpection_id", + new { fk_inpection_id = "_" + 1 + "_" } + ) + .GroupBy(it => it.FKWorkorderId) + .Select(it => new { sum = SqlFunc.AggregateSum(it.Counter ?? 0) }) + .First(); if (list != null) return list.sum; - else return 0; - + else + return 0; } + /// /// 计算当前工单下的包装投入数==一次合格+抛光合格 /// @@ -1289,26 +1422,25 @@ namespace ZR.Service.mes.qc public int CalculatePackagingInvestment(string workorder_id) { - - int OnePassNumber = 0; int polishPassNumber = 0; UseTran(() => { //TODO 一次合格数=计划数-所有缺陷数 - var workorder = Context.Queryable().Where(it => it.ClientWorkorder == workorder_id).First(); + var workorder = Context + .Queryable() + .Where(it => it.ClientWorkorder == workorder_id) + .First(); if (workorder != null) { - - var list = Context.Queryable() - .Where(it => it.FKWorkorderId.Equals(workorder_id)) - .GroupBy(it => it.FKWorkorderId) - .Select(it => new - { - sum = SqlFunc.AggregateSum(it.Counter ?? 0) - }).First(); + var list = Context + .Queryable() + .Where(it => it.FKWorkorderId.Equals(workorder_id)) + .GroupBy(it => it.FKWorkorderId) + .Select(it => new { sum = SqlFunc.AggregateSum(it.Counter ?? 0) }) + .First(); if (list != null) { OnePassNumber = workorder.PreviousNumber - list.sum; @@ -1318,16 +1450,14 @@ namespace ZR.Service.mes.qc OnePassNumber = workorder.PreviousNumber - 0; } - //TODO 计算抛光合格=首检的抛光-抛光缺陷项 int polishNumber = CalculatePolishTotalNumber(workorder_id); - var polish_defect_Number = Context.Queryable() - .Where(it => it.FkWorkorderId.Equals(workorder_id)) - .GroupBy(it => it.FkWorkorderId) - .Select(it => new - { - sum = SqlFunc.AggregateSum(it.Counter ?? 0) - }).First(); + var polish_defect_Number = Context + .Queryable() + .Where(it => it.FkWorkorderId.Equals(workorder_id)) + .GroupBy(it => it.FkWorkorderId) + .Select(it => new { sum = SqlFunc.AggregateSum(it.Counter ?? 0) }) + .First(); if (polish_defect_Number != null) { @@ -1338,23 +1468,18 @@ namespace ZR.Service.mes.qc polishPassNumber = polishNumber - 0; } -/* Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine($"打印工单{workorder_id} 一次合格数{OnePassNumber}=计划数{workorder.PreviousNumber}-----所有缺陷数{list?.sum} "); - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine($"打印工单{workorder_id} 计算抛光合格{polishPassNumber}=首检的抛光{polishNumber}-----抛光缺陷项{polish_defect_Number?.sum}"); - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine($"打印工单{workorder_id} 包装投入数{OnePassNumber + polishPassNumber}");*/ - - - - + /* Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine($"打印工单{workorder_id} 一次合格数{OnePassNumber}=计划数{workorder.PreviousNumber}-----所有缺陷数{list?.sum} "); + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine($"打印工单{workorder_id} 计算抛光合格{polishPassNumber}=首检的抛光{polishNumber}-----抛光缺陷项{polish_defect_Number?.sum}"); + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine($"打印工单{workorder_id} 包装投入数{OnePassNumber + polishPassNumber}");*/ } - }); return OnePassNumber + polishPassNumber; - } + /// /// 更改工单为完成态 /// @@ -1363,11 +1488,11 @@ namespace ZR.Service.mes.qc /// public int UpdateWorkorderStatus(string workorder_id) { - - return Context.Updateable() - .SetColumns(it => it.Status == 2) - .Where(it => it.ClientWorkorder == workorder_id) - .ExecuteCommand(); + return Context + .Updateable() + .SetColumns(it => it.Status == 2) + .Where(it => it.ClientWorkorder == workorder_id) + .ExecuteCommand(); } /// @@ -1376,19 +1501,28 @@ namespace ZR.Service.mes.qc /// /// /// - public int GenerateQualityStatisticsTable(string workorderID, string team, DateTime firstQuality_time) + public int GenerateQualityStatisticsTable( + string workorderID, + string team, + DateTime firstQuality_time + ) { if (!string.IsNullOrEmpty(workorderID)) { - ProWorkordertimeStep step = Context.Queryable().Where(it => it.WorkoderId == workorderID).First(); + ProWorkordertimeStep step = Context + .Queryable() + .Where(it => it.WorkoderId == workorderID) + .First(); #region 首检 #region 抛光 QcQualityStatisticsFirst first = new QcQualityStatisticsFirst(); first.Id = SnowFlakeSingle.Instance.NextId().ToString(); first.WorkorderId = workorderID; - - ProWorkorder_v2 workorder_item = Context.Queryable().Where(it => it.ClientWorkorder == workorderID).First(); + ProWorkorder_v2 workorder_item = Context + .Queryable() + .Where(it => it.ClientWorkorder == workorderID) + .First(); if (workorder_item != null) { first.Color = workorder_item?.Colour; @@ -1397,16 +1531,14 @@ namespace ZR.Service.mes.qc first.RequireNumber = workorder_item.PreviousNumber; if (step != null) { - first.StartTime = step.FirstInspectTime;//这地方是不妥的 + first.StartTime = step.FirstInspectTime; //这地方是不妥的 } else { first.StartTime = null; } - } - first.Team = team; first.EndTime = DateTime.Now; first.Remark = "抛光"; @@ -1414,12 +1546,15 @@ namespace ZR.Service.mes.qc int paoguang_total = 0; //抛光总数 //XXX20240223:记录首检后的抛光数 int paoguang_by_first = 0; - List firstrecordList = Context.Queryable().Where(it => it.FKWorkorderId == workorderID).Where(it => SqlFunc.Contains(it.FKInpectionId, "_1_")).ToList(); + List firstrecordList = Context + .Queryable() + .Where(it => it.FKWorkorderId == workorderID) + .Where(it => SqlFunc.Contains(it.FKInpectionId, "_1_")) + .ToList(); if (firstrecordList != null && firstrecordList.Count > 0) { for (int i = 0; i < firstrecordList.Count; i++) { - if (firstrecordList[i].FKInpectionId == "111") { first.PaintSuokong = firstrecordList[i].Counter; @@ -1438,21 +1573,18 @@ namespace ZR.Service.mes.qc paoguang_total = paoguang_total + (int)firstrecordList[i].Counter; } - if (firstrecordList[i].FKInpectionId == "114") { first.PaintSecha = firstrecordList[i].Counter; paoguang_total = paoguang_total + (int)firstrecordList[i].Counter; } - if (firstrecordList[i].FKInpectionId == "115") { first.PaintDianzi = firstrecordList[i].Counter; paoguang_total = paoguang_total + (int)firstrecordList[i].Counter; } - if (firstrecordList[i].FKInpectionId == "116") { first.PaintOther = firstrecordList[i].Counter; @@ -1584,7 +1716,6 @@ namespace ZR.Service.mes.qc paoguang_total = paoguang_total + (int)firstrecordList[i].Counter; } } - } // XXX20240223: 记录首检时抛光数 paoguang_by_first = paoguang_total; @@ -1599,8 +1730,10 @@ namespace ZR.Service.mes.qc first2.Id = SnowFlakeSingle.Instance.NextId().ToString(); first2.WorkorderId = workorderID; - - ProWorkorder_v2 workorder_item2 = Context.Queryable().Where(it => it.ClientWorkorder == workorderID).First(); + ProWorkorder_v2 workorder_item2 = Context + .Queryable() + .Where(it => it.ClientWorkorder == workorderID) + .First(); if (workorder_item2 != null) { first2.Color = workorder_item2?.Colour; @@ -1610,35 +1743,30 @@ namespace ZR.Service.mes.qc if (step != null) { - first2.StartTime = step.FirstInspectTime;//这地方是不妥的 + first2.StartTime = step.FirstInspectTime; //这地方是不妥的 } else { first2.StartTime = null; } - - - } - - - first2.Team = team; - first2.EndTime = DateTime.Now; first2.Remark = "打磨"; first2.Remark2 = 2; int damo_total = 0; - - List firstrecordList2 = Context.Queryable().Where(it => it.FKWorkorderId == workorderID).Where(it => SqlFunc.Contains(it.FKInpectionId, "_2_")).ToList(); + List firstrecordList2 = Context + .Queryable() + .Where(it => it.FKWorkorderId == workorderID) + .Where(it => SqlFunc.Contains(it.FKInpectionId, "_2_")) + .ToList(); if (firstrecordList2 != null && firstrecordList2.Count > 0) { for (int i = 0; i < firstrecordList2.Count; i++) { - if (firstrecordList2[i].FKInpectionId == "121") { first2.PaintSuokong = firstrecordList2[i].Counter; @@ -1657,21 +1785,18 @@ namespace ZR.Service.mes.qc damo_total = damo_total + (int)firstrecordList2[i].Counter; } - if (firstrecordList2[i].FKInpectionId == "124") { first2.PaintSecha = firstrecordList2[i].Counter; damo_total = damo_total + (int)firstrecordList2[i].Counter; } - if (firstrecordList2[i].FKInpectionId == "125") { first2.PaintDianzi = firstrecordList2[i].Counter; damo_total = damo_total + (int)firstrecordList2[i].Counter; } - if (firstrecordList2[i].FKInpectionId == "126") { first2.PaintOther = firstrecordList2[i].Counter; @@ -1803,7 +1928,6 @@ namespace ZR.Service.mes.qc damo_total = damo_total + (int)firstrecordList2[i].Counter; } } - } first2.CreatedTime = DateTime.Now; first2.UpdatedTime = DateTime.Now; @@ -1815,11 +1939,15 @@ namespace ZR.Service.mes.qc first3.Id = SnowFlakeSingle.Instance.NextId().ToString(); first3.WorkorderId = workorderID; - ProWorkorder_v2 workorder3 = Context.Queryable().Where(it => it.Id == first.WorkorderId).First(); + ProWorkorder_v2 workorder3 = Context + .Queryable() + .Where(it => it.Id == first.WorkorderId) + .First(); - - - ProWorkorder_v2 workorder_item3 = Context.Queryable().Where(it => it.ClientWorkorder == workorderID).First(); + ProWorkorder_v2 workorder_item3 = Context + .Queryable() + .Where(it => it.ClientWorkorder == workorderID) + .First(); if (workorder_item3 != null) { first3.Color = workorder_item3?.Colour; @@ -1828,25 +1956,27 @@ namespace ZR.Service.mes.qc first3.RequireNumber = workorder_item3.PreviousNumber; if (step != null) { - first3.StartTime = step.FirstInspectTime;//这地方是不妥的 + first3.StartTime = step.FirstInspectTime; //这地方是不妥的 } else { first3.StartTime = null; } - } first3.Team = team; first3.EndTime = DateTime.Now; first3.Remark = "报废"; first3.Remark2 = 3; int baofei_total = 0; - List firstrecordList3 = Context.Queryable().Where(it => it.FKWorkorderId == workorderID).Where(it => SqlFunc.Contains(it.FKInpectionId, "_3_")).ToList(); + List firstrecordList3 = Context + .Queryable() + .Where(it => it.FKWorkorderId == workorderID) + .Where(it => SqlFunc.Contains(it.FKInpectionId, "_3_")) + .ToList(); if (firstrecordList3 != null && firstrecordList3.Count > 0) { for (int i = 0; i < firstrecordList3.Count; i++) { - if (firstrecordList3[i].FKInpectionId == "131") { first3.PaintSuokong = firstrecordList3[i].Counter; @@ -1865,21 +1995,18 @@ namespace ZR.Service.mes.qc baofei_total = baofei_total + (int)firstrecordList3[i].Counter; } - if (firstrecordList3[i].FKInpectionId == "134") { first3.PaintSecha = firstrecordList3[i].Counter; baofei_total = baofei_total + (int)firstrecordList3[i].Counter; } - if (firstrecordList3[i].FKInpectionId == "135") { first3.PaintDianzi = firstrecordList3[i].Counter; baofei_total = baofei_total + (int)firstrecordList3[i].Counter; } - if (firstrecordList3[i].FKInpectionId == "136") { first3.PaintOther = firstrecordList3[i].Counter; @@ -2011,7 +2138,6 @@ namespace ZR.Service.mes.qc baofei_total = baofei_total + (int)firstrecordList3[i].Counter; } } - } first3.CreatedTime = DateTime.Now; @@ -2023,18 +2149,23 @@ namespace ZR.Service.mes.qc int qualifiedNumber_No_all = paoguang_total + damo_total + baofei_total; first.QualifiedNumber = first.RequireNumber - qualifiedNumber_No_all; - if (first.RequireNumber == 0) first.QualifiedRate = 0; + if (first.RequireNumber == 0) + first.QualifiedRate = 0; else - - first.QualifiedRate = Math.Round(((decimal)first.QualifiedNumber / (decimal)first.RequireNumber) * 100, 3); + first.QualifiedRate = Math.Round( + ((decimal)first.QualifiedNumber / (decimal)first.RequireNumber) * 100, + 3 + ); first.PaoguangTotal = paoguang_total; first.DamoTotal = damo_total; first.BaofeiTotal = baofei_total; - - var x = Context.Storageable(first).WhereColumns(it => new { it.WorkorderId, it.Remark2 }).ToStorage(); - x.AsInsertable.ExecuteCommand();//不存在插入 - x.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand();//存在更新 + var x = Context + .Storageable(first) + .WhereColumns(it => new { it.WorkorderId, it.Remark2 }) + .ToStorage(); + x.AsInsertable.ExecuteCommand(); //不存在插入 + x.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新 first2.QualifiedNumber = first2.RequireNumber - qualifiedNumber_No_all; if (first2.RequireNumber == 0) { @@ -2042,34 +2173,43 @@ namespace ZR.Service.mes.qc } else { - first2.QualifiedRate = Math.Round(((decimal)first2.QualifiedNumber / (decimal)first2.RequireNumber) * 100, 3); + first2.QualifiedRate = Math.Round( + ((decimal)first2.QualifiedNumber / (decimal)first2.RequireNumber) * 100, + 3 + ); } first2.PaoguangTotal = paoguang_total; first2.DamoTotal = damo_total; first2.BaofeiTotal = baofei_total; - var x2 = Context.Storageable(first2).WhereColumns(it => new { it.WorkorderId, it.Remark2 }).ToStorage(); - x2.AsInsertable.ExecuteCommand();//不存在插入 - x2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand();//存在更新 - - + var x2 = Context + .Storageable(first2) + .WhereColumns(it => new { it.WorkorderId, it.Remark2 }) + .ToStorage(); + x2.AsInsertable.ExecuteCommand(); //不存在插入 + x2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新 first3.QualifiedNumber = first3.RequireNumber - qualifiedNumber_No_all; if (first3.RequireNumber == 0) { first3.QualifiedRate = 0; - } else - first3.QualifiedRate = Math.Round(((decimal)first3.QualifiedNumber / (decimal)first3.RequireNumber) * 100, 3); + first3.QualifiedRate = Math.Round( + ((decimal)first3.QualifiedNumber / (decimal)first3.RequireNumber) * 100, + 3 + ); first3.PaoguangTotal = paoguang_total; first3.DamoTotal = damo_total; first3.BaofeiTotal = baofei_total; - var x3 = Context.Storageable(first3).WhereColumns(it => new { it.WorkorderId, it.Remark2 }).ToStorage(); - x3.AsInsertable.ExecuteCommand();//不存在插入 - x3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand();//存在更新 + var x3 = Context + .Storageable(first3) + .WhereColumns(it => new { it.WorkorderId, it.Remark2 }) + .ToStorage(); + x3.AsInsertable.ExecuteCommand(); //不存在插入 + x3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新 #endregion @@ -2082,10 +2222,10 @@ namespace ZR.Service.mes.qc again2.Id = SnowFlakeSingle.Instance.NextId().ToString(); again2.WorkorderId = workorderID; - - - - ProWorkorder_v2 workorder_again2 = Context.Queryable().Where(it => it.ClientWorkorder == workorderID).First(); + ProWorkorder_v2 workorder_again2 = Context + .Queryable() + .Where(it => it.ClientWorkorder == workorderID) + .First(); if (workorder_again2 != null) { again2.Color = workorder_again2?.Colour; @@ -2096,7 +2236,7 @@ namespace ZR.Service.mes.qc again2.RequireNumber = paoguang_total; if (step != null) { - again2.StartTime = step.FirstInspectTime;//这地方是不妥的 + again2.StartTime = step.FirstInspectTime; //这地方是不妥的 } else { @@ -2104,24 +2244,22 @@ namespace ZR.Service.mes.qc } } - - - again2.Team = team; - again2.EndTime = DateTime.Now; again2.Remark = "打磨"; again2.Remark2 = 2; int damo_total_again = 0; - - List againrecordList2 = Context.Queryable().Where(it => it.FkWorkorderId == workorderID).Where(it => SqlFunc.Contains(it.FkInpectionId, "_2_")).ToList(); + List againrecordList2 = Context + .Queryable() + .Where(it => it.FkWorkorderId == workorderID) + .Where(it => SqlFunc.Contains(it.FkInpectionId, "_2_")) + .ToList(); if (againrecordList2 != null && againrecordList2.Count > 0) { for (int i = 0; i < againrecordList2.Count; i++) { - if (againrecordList2[i].FkInpectionId == "121") { again2.PaintSuokong = againrecordList2[i].Counter; @@ -2140,21 +2278,18 @@ namespace ZR.Service.mes.qc damo_total_again = damo_total_again + (int)againrecordList2[i].Counter; } - if (againrecordList2[i].FkInpectionId == "124") { again2.PaintSecha = againrecordList2[i].Counter; damo_total_again = damo_total_again + (int)againrecordList2[i].Counter; } - if (againrecordList2[i].FkInpectionId == "125") { again2.PaintDianzi = againrecordList2[i].Counter; damo_total_again = damo_total_again + (int)againrecordList2[i].Counter; } - if (againrecordList2[i].FkInpectionId == "126") { again2.PaintOther = againrecordList2[i].Counter; @@ -2286,24 +2421,21 @@ namespace ZR.Service.mes.qc damo_total_again = damo_total_again + (int)againrecordList2[i].Counter; } } - } again2.CreatedTime = DateTime.Now; again2.UpdatedTime = DateTime.Now; - - - - - #endregion #region 报废 QcQualityStatisticsAgain again3 = new QcQualityStatisticsAgain(); again3.Id = SnowFlakeSingle.Instance.NextId().ToString(); again3.WorkorderId = workorderID; - ProWorkorder_v2 workorder_again3 = Context.Queryable().Where(it => it.ClientWorkorder == workorderID).First(); + ProWorkorder_v2 workorder_again3 = Context + .Queryable() + .Where(it => it.ClientWorkorder == workorderID) + .First(); if (workorder_again3 != null) { again3.Color = workorder_again3.Colour; @@ -2314,204 +2446,225 @@ namespace ZR.Service.mes.qc // again3.RequireNumber = workorder_again3.PreviousNumber; if (step != null) { - again3.StartTime = step.FirstInspectTime;//这地方是不妥的 + again3.StartTime = step.FirstInspectTime; //这地方是不妥的 } else { again3.StartTime = null; } - - } - again3.Team = team; again3.EndTime = DateTime.Now; again3.Remark = "报废"; again3.Remark2 = 3; int baofei_total_again3 = 0; - List againrecordList3 = Context.Queryable().Where(it => it.FkWorkorderId == workorderID).Where(it => SqlFunc.Contains(it.FkWorkorderId, "_3_")).ToList(); + List againrecordList3 = Context + .Queryable() + .Where(it => it.FkWorkorderId == workorderID) + .Where(it => SqlFunc.Contains(it.FkWorkorderId, "_3_")) + .ToList(); if (againrecordList3 != null && againrecordList3.Count > 0) { for (int i = 0; i < againrecordList3.Count; i++) { - if (againrecordList3[i].FkInpectionId == "131") { again3.PaintSuokong = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "132") { again3.PaintZhengkong = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "133") { again3.PaintShiguang = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } - if (againrecordList3[i].FkInpectionId == "134") { again3.PaintSecha = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } - if (againrecordList3[i].FkInpectionId == "135") { again3.PaintDianzi = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } - if (againrecordList3[i].FkInpectionId == "136") { again3.PaintOther = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "231") { again3.DeviceShuiban = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "232") { again3.DeviceZandian = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "233") { again3.DeviceBianxing = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "234") { again3.DeviceYouzhu = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "235") { again3.DeviceTuoluo = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "236") { again3.DeviceZhuangshang = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "237") { again3.DeviceOther = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "331") { again3.BlankMaoci = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "332") { again3.BlankSuoyin = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "333") { again3.BlankCanshuang = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "334") { again3.BlankShaying = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "335") { again3.BlankZangdian = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "336") { again3.BlankDamo = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "431") { again3.ProgramLiuguang = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "432") { again3.ProgramSeqiqueqi = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "433") { again3.ProgramQingqiqueqi = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "434") { again3.ProgramJupi = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "435") { again3.ProgramOther = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "531") { again3.TeamTuoluocanshuang = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "532") { again3.TeamQingqiqikuai = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "533") { again3.TeamSeqiqikuai = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "534") { again3.TeamFahua = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "535") { again3.TeamLiangbang = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } if (againrecordList3[i].FkInpectionId == "536") { again3.TeamPenglou = againrecordList3[i].Counter; - baofei_total_again3 = baofei_total_again3 + (int)againrecordList3[i].Counter; + baofei_total_again3 = + baofei_total_again3 + (int)againrecordList3[i].Counter; } } - } again3.CreatedTime = DateTime.Now; again3.UpdatedTime = DateTime.Now; - - - - - #endregion #region 计算汇总 int qualifiedNumber_No_all_again = damo_total_again + baofei_total_again3; @@ -2522,18 +2675,20 @@ namespace ZR.Service.mes.qc again2.QualifiedNumber = 0; } else - again2.QualifiedRate = Math.Round(((decimal)again2.QualifiedNumber / (decimal)again2.RequireNumber) * 100, 3); + again2.QualifiedRate = Math.Round( + ((decimal)again2.QualifiedNumber / (decimal)again2.RequireNumber) * 100, + 3 + ); again2.DamoTotal = damo_total_again; again2.BaofeiTotal = baofei_total_again3; - - var x_again_2 = Context.Storageable(again2).WhereColumns(it => new { it.WorkorderId, it.Remark2 }).ToStorage(); - x_again_2.AsInsertable.ExecuteCommand();//不存在插入 - x_again_2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand();//存在更新 - - - + var x_again_2 = Context + .Storageable(again2) + .WhereColumns(it => new { it.WorkorderId, it.Remark2 }) + .ToStorage(); + x_again_2.AsInsertable.ExecuteCommand(); //不存在插入 + x_again_2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新 again3.QualifiedNumber = again3.RequireNumber - qualifiedNumber_No_all_again; if (again3.RequireNumber == 0) @@ -2541,15 +2696,20 @@ namespace ZR.Service.mes.qc again3.QualifiedRate = 0; } else - again3.QualifiedRate = Math.Round(((decimal)again3.QualifiedNumber / (decimal)again3.RequireNumber) * 100, 3); + again3.QualifiedRate = Math.Round( + ((decimal)again3.QualifiedNumber / (decimal)again3.RequireNumber) * 100, + 3 + ); again3.DamoTotal = damo_total_again; again3.BaofeiTotal = baofei_total_again3; - - var x_again_3 = Context.Storageable(again3).WhereColumns(it => new { it.WorkorderId, it.Remark2 }).ToStorage(); - x_again_3.AsInsertable.ExecuteCommand();//不存在插入 - x_again_3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand();//存在更新 + var x_again_3 = Context + .Storageable(again3) + .WhereColumns(it => new { it.WorkorderId, it.Remark2 }) + .ToStorage(); + x_again_3.AsInsertable.ExecuteCommand(); //不存在插入 + x_again_3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新 #endregion @@ -2562,7 +2722,10 @@ namespace ZR.Service.mes.qc final2.Id = SnowFlakeSingle.Instance.NextId().ToString(); final2.WorkorderId = workorderID; - ProWorkorder_v2 workorder_final2 = Context.Queryable().Where(it => it.ClientWorkorder == workorderID).First(); + ProWorkorder_v2 workorder_final2 = Context + .Queryable() + .Where(it => it.ClientWorkorder == workorderID) + .First(); if (workorder_final2 != null) { final2.Color = workorder_final2.Colour; @@ -2573,34 +2736,30 @@ namespace ZR.Service.mes.qc final2.RequireNumber = first.QualifiedNumber + again2.QualifiedNumber; if (step != null) { - final2.StartTime = step.FirstInspectTime;//这地方是不妥的 + final2.StartTime = step.FirstInspectTime; //这地方是不妥的 } else { final2.StartTime = null; } - - } - - - final2.Team = team; - final2.EndTime = DateTime.Now; final2.Remark = "打磨"; final2.Remark2 = 2; int damo_total_final = 0; - - List finalrecordList2 = Context.Queryable().Where(it => it.FkWorkorderId == workorderID).Where(it => SqlFunc.Contains(it.FkInpectionId, "_2_")).ToList(); + List finalrecordList2 = Context + .Queryable() + .Where(it => it.FkWorkorderId == workorderID) + .Where(it => SqlFunc.Contains(it.FkInpectionId, "_2_")) + .ToList(); if (finalrecordList2 != null && finalrecordList2.Count > 0) { for (int i = 0; i < finalrecordList2.Count; i++) { - if (finalrecordList2[i].FkInpectionId == "121") { final2.PaintSuokong = finalrecordList2[i].Counter; @@ -2619,21 +2778,18 @@ namespace ZR.Service.mes.qc damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter; } - if (finalrecordList2[i].FkInpectionId == "124") { final2.PaintSecha = finalrecordList2[i].Counter; damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter; } - if (finalrecordList2[i].FkInpectionId == "125") { final2.PaintDianzi = finalrecordList2[i].Counter; damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter; } - if (finalrecordList2[i].FkInpectionId == "126") { final2.PaintOther = finalrecordList2[i].Counter; @@ -2765,24 +2921,21 @@ namespace ZR.Service.mes.qc damo_total_again = damo_total_again + (int)finalrecordList2[i].Counter; } } - } final2.CreatedTime = DateTime.Now; final2.UpdatedTime = DateTime.Now; - - - - - #endregion #region 报废 QcQualityStatisticsFinal final3 = new QcQualityStatisticsFinal(); final3.Id = SnowFlakeSingle.Instance.NextId().ToString(); final3.WorkorderId = workorderID; - ProWorkorder_v2 workorder_final3 = Context.Queryable().Where(it => it.ClientWorkorder == workorderID).First(); + ProWorkorder_v2 workorder_final3 = Context + .Queryable() + .Where(it => it.ClientWorkorder == workorderID) + .First(); if (workorder_again3 != null) { final3.Color = workorder_final3.Colour; @@ -2793,204 +2946,225 @@ namespace ZR.Service.mes.qc //final3.RequireNumber = workorder_final3.PreviousNumber; if (step != null) { - final3.StartTime = step.FirstInspectTime;//这地方是不妥的 + final3.StartTime = step.FirstInspectTime; //这地方是不妥的 } else { final3.StartTime = null; } - - } - final3.Team = team; final3.EndTime = DateTime.Now; final3.Remark = "报废"; final3.Remark2 = 3; int baofei_total_final = 0; - List finalrecordList3 = Context.Queryable().Where(it => it.FkWorkorderId == workorderID).Where(it => SqlFunc.Contains(it.FkWorkorderId, "_3_")).ToList(); + List finalrecordList3 = Context + .Queryable() + .Where(it => it.FkWorkorderId == workorderID) + .Where(it => SqlFunc.Contains(it.FkWorkorderId, "_3_")) + .ToList(); if (finalrecordList3 != null && finalrecordList3.Count > 0) { for (int i = 0; i < finalrecordList3.Count; i++) { - if (finalrecordList3[i].FkInpectionId == "131") { final3.PaintSuokong = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "132") { final3.PaintZhengkong = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "133") { final3.PaintShiguang = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } - if (finalrecordList3[i].FkInpectionId == "134") { final3.PaintSecha = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } - if (finalrecordList3[i].FkInpectionId == "135") { final3.PaintDianzi = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } - if (finalrecordList3[i].FkInpectionId == "136") { final3.PaintOther = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "231") { final3.DeviceShuiban = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "232") { final3.DeviceZandian = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "233") { final3.DeviceBianxing = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "234") { final3.DeviceYouzhu = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "235") { final3.DeviceTuoluo = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "236") { final3.DeviceZhuangshang = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "237") { final3.DeviceOther = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "331") { final3.BlankMaoci = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "332") { final3.BlankSuoyin = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "333") { final3.BlankCanshuang = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "334") { final3.BlankShaying = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "335") { final3.BlankZangdian = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "336") { final3.BlankDamo = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "431") { final3.ProgramLiuguang = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "432") { final3.ProgramSeqiqueqi = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "433") { final3.ProgramQingqiqueqi = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "434") { final3.ProgramJupi = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "435") { final3.ProgramOther = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "531") { final3.TeamTuoluocanshuang = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "532") { final3.TeamQingqiqikuai = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "533") { final3.TeamSeqiqikuai = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "534") { final3.TeamFahua = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "535") { final3.TeamLiangbang = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } if (finalrecordList3[i].FkInpectionId == "536") { final3.TeamPenglou = finalrecordList3[i].Counter; - baofei_total_final = baofei_total_final + (int)finalrecordList3[i].Counter; + baofei_total_final = + baofei_total_final + (int)finalrecordList3[i].Counter; } } - } final3.CreatedTime = DateTime.Now; final3.UpdatedTime = DateTime.Now; - - - - - #endregion #region 计算汇总 int qualifiedNumber_No_all_final = baofei_total_final + damo_total_final; @@ -3001,28 +3175,36 @@ namespace ZR.Service.mes.qc final2.QualifiedNumber = 0; } else - final2.QualifiedRate = Math.Round(((decimal)final2.QualifiedNumber / (decimal)final2.RequireNumber) * 100, 3); + final2.QualifiedRate = Math.Round( + ((decimal)final2.QualifiedNumber / (decimal)final2.RequireNumber) * 100, + 3 + ); final2.DamoTotal = damo_total_final; final2.BaofeiTotal = baofei_total_final; - - var x_final_2 = Context.Storageable(final2).WhereColumns(it => new { it.WorkorderId, it.Remark2 }).ToStorage(); - x_final_2.AsInsertable.ExecuteCommand();//不存在插入 - x_final_2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand();//存在更新 - - - + var x_final_2 = Context + .Storageable(final2) + .WhereColumns(it => new { it.WorkorderId, it.Remark2 }) + .ToStorage(); + x_final_2.AsInsertable.ExecuteCommand(); //不存在插入 + x_final_2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新 final3.QualifiedNumber = final3.RequireNumber - qualifiedNumber_No_all_final; - final3.QualifiedRate = Math.Round(((decimal)final3.QualifiedNumber / (decimal)final3.RequireNumber) * 100, 3); + final3.QualifiedRate = Math.Round( + ((decimal)final3.QualifiedNumber / (decimal)final3.RequireNumber) * 100, + 3 + ); final3.DamoTotal = damo_total_final; final3.BaofeiTotal = baofei_total_final; - var x_final_3 = Context.Storageable(final3).WhereColumns(it => new { it.WorkorderId, it.Remark2 }).ToStorage(); - x_final_3.AsInsertable.ExecuteCommand();//不存在插入 - x_final_3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand();//存在更新 + var x_final_3 = Context + .Storageable(final3) + .WhereColumns(it => new { it.WorkorderId, it.Remark2 }) + .ToStorage(); + x_final_3.AsInsertable.ExecuteCommand(); //不存在插入 + x_final_3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新 #endregion @@ -3033,7 +3215,6 @@ namespace ZR.Service.mes.qc total2.Id = SnowFlakeSingle.Instance.NextId().ToString(); total2.WorkorderId = workorderID; - total2.FinishedPartNumber = again2.FinishedPartNumber; total2.ProductDescription = again2.ProductDescription; //XXX:修改生产投入数为首检生产投入数 workorder_item @@ -3041,7 +3222,7 @@ namespace ZR.Service.mes.qc total2.RequireNumber = workorder_item.PreviousNumber; if (step != null) { - total2.StartTime = step.FirstInspectTime;//这地方是不妥的 + total2.StartTime = step.FirstInspectTime; //这地方是不妥的 } else { @@ -3050,44 +3231,117 @@ namespace ZR.Service.mes.qc total2.Team = team; - total2.EndTime = DateTime.Now; total2.Remark = "打磨"; total2.Remark2 = 2; - total2.PaintSuokong = (again2.PaintSuokong ?? 0) + (final2.PaintSuokong ?? 0) + (first2.PaintSuokong ?? 0); - total2.PaintZhengkong = (again2.PaintZhengkong ?? 0) + (final2.PaintZhengkong ?? 0) + (first2.PaintZhengkong ?? 0); - total2.PaintShiguang = (again2.PaintShiguang ?? 0) + (final2.PaintShiguang ?? 0) + (first2.PaintShiguang ?? 0); - total2.PaintSecha = (again2.PaintSecha ?? 0) + (final2.PaintSecha ?? 0) + (first2.PaintSecha ?? 0); - total2.PaintDianzi = (again2.PaintDianzi ?? 0) + (final2.PaintDianzi ?? 0) + (first2.PaintDianzi ?? 0); - total2.DeviceShuiban = (again2.DeviceShuiban ?? 0) + (final2.DeviceShuiban ?? 0) + (first2.DeviceShuiban ?? 0); - total2.PaintOther = (again2.PaintOther ?? 0) + (final2.PaintOther ?? 0) + (first2.PaintOther ?? 0); - total2.DeviceZandian = (again2.DeviceZandian ?? 0) + (final2.DeviceZandian ?? 0) + (first2.DeviceZandian ?? 0); - total2.DeviceBianxing = (again2.DeviceBianxing ?? 0) + (final2.DeviceBianxing ?? 0) + (first2.DeviceBianxing ?? 0); - total2.DeviceYouzhu = (again2.DeviceYouzhu ?? 0) + (final2.DeviceYouzhu ?? 0) + (first2.DeviceYouzhu ?? 0); - total2.DeviceTuoluo = (again2.DeviceTuoluo ?? 0) + (final2.DeviceTuoluo ?? 0) + (first2.DeviceTuoluo ?? 0); - total2.DeviceZhuangshang = (again2.DeviceZhuangshang ?? 0) + (final2.DeviceZhuangshang ?? 0) + (first2.DeviceZhuangshang ?? 0); - total2.DeviceOther = again2.DeviceOther ?? 0 + final2.DeviceOther ?? 0 + first2.DeviceOther ?? 0; - total2.BlankMaoci = (again2.BlankMaoci ?? 0) + (final2.BlankMaoci ?? 0) + (first2.BlankMaoci ?? 0); - total2.BlankSuoyin = (again2.BlankSuoyin ?? 0) + (final2.BlankSuoyin ?? 0) + (first2.BlankSuoyin ?? 0); - total2.BlankCanshuang = (again2.BlankCanshuang ?? 0) + (final2.BlankCanshuang ?? 0) + (first2.BlankCanshuang ?? 0); - total2.BlankShaying = (again2.BlankShaying ?? 0) + (final2.BlankShaying ?? 0) + (first2.BlankShaying ?? 0); - total2.BlankZangdian = (again2.BlankZangdian ?? 0) + (final2.BlankZangdian ?? 0) + (first2.BlankZangdian ?? 0); - total2.BlankDamo = (again2.BlankDamo ?? 0) + (final2.BlankDamo ?? 0) + (first2.BlankDamo ?? 0); - total2.ProgramLiuguang = (again2.ProgramLiuguang ?? 0) + (final2.ProgramLiuguang ?? 0) + (first2.ProgramLiuguang ?? 0); - total2.ProgramSeqiqueqi = (again2.ProgramSeqiqueqi ?? 0) + (final2.ProgramSeqiqueqi ?? 0) + (first2.ProgramSeqiqueqi ?? 0); - total2.ProgramQingqiqueqi = (again2.ProgramQingqiqueqi ?? 0) + (final2.ProgramQingqiqueqi ?? 0) + (first2.ProgramQingqiqueqi ?? 0); - total2.ProgramJupi = (again2.ProgramJupi ?? 0) + (final2.ProgramJupi ?? 0) + (first2.ProgramJupi ?? 0); - total2.TeamTuoluocanshuang = (again2.TeamTuoluocanshuang ?? 0) + (final2.TeamTuoluocanshuang ?? 0) + (first2.TeamTuoluocanshuang ?? 0); - total2.ProgramOther = (again2.ProgramOther ?? 0) + (final2.ProgramOther ?? 0) + (first2.ProgramOther ?? 0); - total2.TeamQingqiqikuai = (again2.TeamQingqiqikuai ?? 0) + (final2.TeamQingqiqikuai ?? 0) + (first2.TeamQingqiqikuai ?? 0); - total2.TeamSeqiqikuai = (again2.TeamSeqiqikuai ?? 0) + (final2.TeamSeqiqikuai ?? 0) + (first2.TeamSeqiqikuai ?? 0); - total2.TeamFahua = (again2.TeamFahua ?? 0) + (final2.TeamFahua ?? 0) + (first2.TeamFahua ?? 0); - total2.TeamLiangbang = (again2.TeamLiangbang ?? 0) + (final2.TeamLiangbang ?? 0) + (first2.TeamLiangbang ?? 0); - total2.TeamPenglou = (again2.TeamPenglou ?? 0) + (final2.TeamPenglou ?? 0) + (first2.TeamPenglou ?? 0); - - - - + total2.PaintSuokong = + (again2.PaintSuokong ?? 0) + + (final2.PaintSuokong ?? 0) + + (first2.PaintSuokong ?? 0); + total2.PaintZhengkong = + (again2.PaintZhengkong ?? 0) + + (final2.PaintZhengkong ?? 0) + + (first2.PaintZhengkong ?? 0); + total2.PaintShiguang = + (again2.PaintShiguang ?? 0) + + (final2.PaintShiguang ?? 0) + + (first2.PaintShiguang ?? 0); + total2.PaintSecha = + (again2.PaintSecha ?? 0) + (final2.PaintSecha ?? 0) + (first2.PaintSecha ?? 0); + total2.PaintDianzi = + (again2.PaintDianzi ?? 0) + + (final2.PaintDianzi ?? 0) + + (first2.PaintDianzi ?? 0); + total2.DeviceShuiban = + (again2.DeviceShuiban ?? 0) + + (final2.DeviceShuiban ?? 0) + + (first2.DeviceShuiban ?? 0); + total2.PaintOther = + (again2.PaintOther ?? 0) + (final2.PaintOther ?? 0) + (first2.PaintOther ?? 0); + total2.DeviceZandian = + (again2.DeviceZandian ?? 0) + + (final2.DeviceZandian ?? 0) + + (first2.DeviceZandian ?? 0); + total2.DeviceBianxing = + (again2.DeviceBianxing ?? 0) + + (final2.DeviceBianxing ?? 0) + + (first2.DeviceBianxing ?? 0); + total2.DeviceYouzhu = + (again2.DeviceYouzhu ?? 0) + + (final2.DeviceYouzhu ?? 0) + + (first2.DeviceYouzhu ?? 0); + total2.DeviceTuoluo = + (again2.DeviceTuoluo ?? 0) + + (final2.DeviceTuoluo ?? 0) + + (first2.DeviceTuoluo ?? 0); + total2.DeviceZhuangshang = + (again2.DeviceZhuangshang ?? 0) + + (final2.DeviceZhuangshang ?? 0) + + (first2.DeviceZhuangshang ?? 0); + total2.DeviceOther = + again2.DeviceOther ?? 0 + final2.DeviceOther ?? 0 + first2.DeviceOther ?? 0; + total2.BlankMaoci = + (again2.BlankMaoci ?? 0) + (final2.BlankMaoci ?? 0) + (first2.BlankMaoci ?? 0); + total2.BlankSuoyin = + (again2.BlankSuoyin ?? 0) + + (final2.BlankSuoyin ?? 0) + + (first2.BlankSuoyin ?? 0); + total2.BlankCanshuang = + (again2.BlankCanshuang ?? 0) + + (final2.BlankCanshuang ?? 0) + + (first2.BlankCanshuang ?? 0); + total2.BlankShaying = + (again2.BlankShaying ?? 0) + + (final2.BlankShaying ?? 0) + + (first2.BlankShaying ?? 0); + total2.BlankZangdian = + (again2.BlankZangdian ?? 0) + + (final2.BlankZangdian ?? 0) + + (first2.BlankZangdian ?? 0); + total2.BlankDamo = + (again2.BlankDamo ?? 0) + (final2.BlankDamo ?? 0) + (first2.BlankDamo ?? 0); + total2.ProgramLiuguang = + (again2.ProgramLiuguang ?? 0) + + (final2.ProgramLiuguang ?? 0) + + (first2.ProgramLiuguang ?? 0); + total2.ProgramSeqiqueqi = + (again2.ProgramSeqiqueqi ?? 0) + + (final2.ProgramSeqiqueqi ?? 0) + + (first2.ProgramSeqiqueqi ?? 0); + total2.ProgramQingqiqueqi = + (again2.ProgramQingqiqueqi ?? 0) + + (final2.ProgramQingqiqueqi ?? 0) + + (first2.ProgramQingqiqueqi ?? 0); + total2.ProgramJupi = + (again2.ProgramJupi ?? 0) + + (final2.ProgramJupi ?? 0) + + (first2.ProgramJupi ?? 0); + total2.TeamTuoluocanshuang = + (again2.TeamTuoluocanshuang ?? 0) + + (final2.TeamTuoluocanshuang ?? 0) + + (first2.TeamTuoluocanshuang ?? 0); + total2.ProgramOther = + (again2.ProgramOther ?? 0) + + (final2.ProgramOther ?? 0) + + (first2.ProgramOther ?? 0); + total2.TeamQingqiqikuai = + (again2.TeamQingqiqikuai ?? 0) + + (final2.TeamQingqiqikuai ?? 0) + + (first2.TeamQingqiqikuai ?? 0); + total2.TeamSeqiqikuai = + (again2.TeamSeqiqikuai ?? 0) + + (final2.TeamSeqiqikuai ?? 0) + + (first2.TeamSeqiqikuai ?? 0); + total2.TeamFahua = + (again2.TeamFahua ?? 0) + (final2.TeamFahua ?? 0) + (first2.TeamFahua ?? 0); + total2.TeamLiangbang = + (again2.TeamLiangbang ?? 0) + + (final2.TeamLiangbang ?? 0) + + (first2.TeamLiangbang ?? 0); + total2.TeamPenglou = + (again2.TeamPenglou ?? 0) + + (final2.TeamPenglou ?? 0) + + (first2.TeamPenglou ?? 0); total2.CreatedTime = DateTime.Now; total2.UpdatedTime = DateTime.Now; @@ -3099,7 +3353,6 @@ namespace ZR.Service.mes.qc total3.WorkorderId = workorderID; total3.Color = again3.Color; - total3.FinishedPartNumber = again3.FinishedPartNumber; total3.ProductDescription = again3.ProductDescription; // XXX:修改生产投入数 @@ -3107,62 +3360,138 @@ namespace ZR.Service.mes.qc total3.RequireNumber = workorder_item.PreviousNumber; if (step != null) { - total3.StartTime = step.FirstInspectTime;//这地方是不妥的 + total3.StartTime = step.FirstInspectTime; //这地方是不妥的 } else { total3.StartTime = null; - } - - - total3.Team = team; total3.EndTime = DateTime.Now; total3.Remark = "报废"; total3.Remark2 = 3; - total3.PaintSuokong = (again3.PaintSuokong ?? 0) + (final3.PaintSuokong ?? 0) + (first3.PaintSuokong ?? 0); - total3.PaintZhengkong = (again3.PaintZhengkong ?? 0) + (final3.PaintZhengkong ?? 0) + (first3.PaintZhengkong ?? 00); - total3.PaintShiguang = (again3.PaintShiguang ?? 0) + (final3.PaintShiguang ?? 0) + (first3.PaintShiguang ?? 0); - total3.PaintSecha = (again3.PaintSecha ?? 0) + (final3.PaintSecha ?? 0) + (first3.PaintSecha ?? 0); - total3.PaintDianzi = (again3.PaintDianzi ?? 0) + (final3.PaintDianzi ?? 0) + (first3.PaintDianzi ?? 0); - total3.DeviceShuiban = (again3.DeviceShuiban ?? 0) + (final3.DeviceShuiban ?? 0) + (first3.DeviceShuiban ?? 0); - total3.PaintOther = (again3.PaintOther ?? 0) + (final3.PaintOther ?? 0) + (first3.PaintOther ?? 0); - total3.DeviceZandian = again3.DeviceZandian ?? 0 + final3.DeviceZandian ?? 0 + first3.DeviceZandian ?? 0; - total3.DeviceBianxing = (again3.DeviceBianxing ?? 0) + (final3.DeviceBianxing ?? 0) + (first3.DeviceBianxing ?? 0); - total3.DeviceYouzhu = (again3.DeviceYouzhu ?? 0) + (final3.DeviceYouzhu ?? 0) + (first3.DeviceYouzhu ?? 0); - total3.DeviceTuoluo = (again3.DeviceTuoluo ?? 0) + (final3.DeviceTuoluo ?? 0) + (first3.DeviceTuoluo ?? 0); - total3.DeviceZhuangshang = (again3.DeviceZhuangshang ?? 0) + (final3.DeviceZhuangshang ?? 0) + (first3.DeviceZhuangshang ?? 0); - total3.DeviceOther = (again3.DeviceOther ?? 0) + (final3.DeviceOther ?? 0) + (first3.DeviceOther ?? 0); - total3.BlankMaoci = (again3.BlankMaoci ?? 0) + (final3.BlankMaoci ?? 0) + (first3.BlankMaoci ?? 0); - total3.BlankSuoyin = (again3.BlankSuoyin ?? 0) + (final3.BlankMaoci ?? 0) + (first3.BlankMaoci ?? 0); - total3.BlankCanshuang = (again3.BlankCanshuang ?? 0) + (final3.BlankCanshuang ?? 0) + (first3.BlankCanshuang ?? 0); - total3.BlankShaying = (again3.BlankShaying ?? 0) + (final3.BlankShaying ?? 0) + (first3.BlankShaying ?? 0); - total3.BlankZangdian = (again3.BlankZangdian ?? 0) + (final3.BlankZangdian ?? 0) + (first3.BlankZangdian ?? 0); - total3.BlankDamo = (again3.BlankDamo ?? 0) + (final3.BlankDamo ?? 0) + (first3.BlankDamo ?? 0); - total3.ProgramLiuguang = (again3.ProgramLiuguang ?? 0) + (final3.ProgramLiuguang ?? 0) + (first3.ProgramLiuguang ?? 0); - total3.ProgramSeqiqueqi = (again3.ProgramSeqiqueqi ?? 0) + (final3.ProgramSeqiqueqi ?? 0) + (first3.ProgramSeqiqueqi ?? 0); - total3.ProgramQingqiqueqi = (again3.ProgramQingqiqueqi ?? 0) + (final3.ProgramQingqiqueqi ?? 0) + (first3.ProgramQingqiqueqi ?? 0); - total3.ProgramJupi = (again3.ProgramJupi ?? 0) + (final3.ProgramJupi ?? 0) + (first3.ProgramJupi ?? 0); - total3.TeamTuoluocanshuang = (again3.TeamTuoluocanshuang ?? 0) + (final3.TeamTuoluocanshuang ?? 0) + (first3.TeamTuoluocanshuang ?? 0); - total3.ProgramOther = (again3.ProgramOther ?? 0) + (final3.ProgramOther ?? 0) + (first3.ProgramOther ?? 0); - total3.TeamQingqiqikuai = again3.TeamQingqiqikuai ?? 0 + final3.TeamQingqiqikuai ?? 0 + first3.TeamQingqiqikuai ?? 0; - total3.TeamSeqiqikuai = (again3.TeamSeqiqikuai ?? 0) + (final3.TeamSeqiqikuai ?? 0) + (first3.TeamSeqiqikuai ?? 0); - total3.TeamFahua = (again3.TeamFahua ?? 0) + (final3.TeamFahua ?? 0) + (first3.TeamFahua ?? 0); - total3.TeamLiangbang = (again3.TeamLiangbang ?? 0) + (final3.TeamLiangbang ?? 0) + (first3.TeamLiangbang ?? 0); - total3.TeamPenglou = (again3.TeamPenglou ?? 0) + (final3.TeamPenglou ?? 0) + (first3.TeamPenglou ?? 0); - - + total3.PaintSuokong = + (again3.PaintSuokong ?? 0) + + (final3.PaintSuokong ?? 0) + + (first3.PaintSuokong ?? 0); + total3.PaintZhengkong = + (again3.PaintZhengkong ?? 0) + + (final3.PaintZhengkong ?? 0) + + (first3.PaintZhengkong ?? 00); + total3.PaintShiguang = + (again3.PaintShiguang ?? 0) + + (final3.PaintShiguang ?? 0) + + (first3.PaintShiguang ?? 0); + total3.PaintSecha = + (again3.PaintSecha ?? 0) + (final3.PaintSecha ?? 0) + (first3.PaintSecha ?? 0); + total3.PaintDianzi = + (again3.PaintDianzi ?? 0) + + (final3.PaintDianzi ?? 0) + + (first3.PaintDianzi ?? 0); + total3.DeviceShuiban = + (again3.DeviceShuiban ?? 0) + + (final3.DeviceShuiban ?? 0) + + (first3.DeviceShuiban ?? 0); + total3.PaintOther = + (again3.PaintOther ?? 0) + (final3.PaintOther ?? 0) + (first3.PaintOther ?? 0); + total3.DeviceZandian = + again3.DeviceZandian + ?? 0 + final3.DeviceZandian + ?? 0 + first3.DeviceZandian + ?? 0; + total3.DeviceBianxing = + (again3.DeviceBianxing ?? 0) + + (final3.DeviceBianxing ?? 0) + + (first3.DeviceBianxing ?? 0); + total3.DeviceYouzhu = + (again3.DeviceYouzhu ?? 0) + + (final3.DeviceYouzhu ?? 0) + + (first3.DeviceYouzhu ?? 0); + total3.DeviceTuoluo = + (again3.DeviceTuoluo ?? 0) + + (final3.DeviceTuoluo ?? 0) + + (first3.DeviceTuoluo ?? 0); + total3.DeviceZhuangshang = + (again3.DeviceZhuangshang ?? 0) + + (final3.DeviceZhuangshang ?? 0) + + (first3.DeviceZhuangshang ?? 0); + total3.DeviceOther = + (again3.DeviceOther ?? 0) + + (final3.DeviceOther ?? 0) + + (first3.DeviceOther ?? 0); + total3.BlankMaoci = + (again3.BlankMaoci ?? 0) + (final3.BlankMaoci ?? 0) + (first3.BlankMaoci ?? 0); + total3.BlankSuoyin = + (again3.BlankSuoyin ?? 0) + (final3.BlankMaoci ?? 0) + (first3.BlankMaoci ?? 0); + total3.BlankCanshuang = + (again3.BlankCanshuang ?? 0) + + (final3.BlankCanshuang ?? 0) + + (first3.BlankCanshuang ?? 0); + total3.BlankShaying = + (again3.BlankShaying ?? 0) + + (final3.BlankShaying ?? 0) + + (first3.BlankShaying ?? 0); + total3.BlankZangdian = + (again3.BlankZangdian ?? 0) + + (final3.BlankZangdian ?? 0) + + (first3.BlankZangdian ?? 0); + total3.BlankDamo = + (again3.BlankDamo ?? 0) + (final3.BlankDamo ?? 0) + (first3.BlankDamo ?? 0); + total3.ProgramLiuguang = + (again3.ProgramLiuguang ?? 0) + + (final3.ProgramLiuguang ?? 0) + + (first3.ProgramLiuguang ?? 0); + total3.ProgramSeqiqueqi = + (again3.ProgramSeqiqueqi ?? 0) + + (final3.ProgramSeqiqueqi ?? 0) + + (first3.ProgramSeqiqueqi ?? 0); + total3.ProgramQingqiqueqi = + (again3.ProgramQingqiqueqi ?? 0) + + (final3.ProgramQingqiqueqi ?? 0) + + (first3.ProgramQingqiqueqi ?? 0); + total3.ProgramJupi = + (again3.ProgramJupi ?? 0) + + (final3.ProgramJupi ?? 0) + + (first3.ProgramJupi ?? 0); + total3.TeamTuoluocanshuang = + (again3.TeamTuoluocanshuang ?? 0) + + (final3.TeamTuoluocanshuang ?? 0) + + (first3.TeamTuoluocanshuang ?? 0); + total3.ProgramOther = + (again3.ProgramOther ?? 0) + + (final3.ProgramOther ?? 0) + + (first3.ProgramOther ?? 0); + total3.TeamQingqiqikuai = + again3.TeamQingqiqikuai + ?? 0 + final3.TeamQingqiqikuai + ?? 0 + first3.TeamQingqiqikuai + ?? 0; + total3.TeamSeqiqikuai = + (again3.TeamSeqiqikuai ?? 0) + + (final3.TeamSeqiqikuai ?? 0) + + (first3.TeamSeqiqikuai ?? 0); + total3.TeamFahua = + (again3.TeamFahua ?? 0) + (final3.TeamFahua ?? 0) + (first3.TeamFahua ?? 0); + total3.TeamLiangbang = + (again3.TeamLiangbang ?? 0) + + (final3.TeamLiangbang ?? 0) + + (first3.TeamLiangbang ?? 0); + total3.TeamPenglou = + (again3.TeamPenglou ?? 0) + + (final3.TeamPenglou ?? 0) + + (first3.TeamPenglou ?? 0); total3.CreatedTime = DateTime.Now; total3.UpdatedTime = DateTime.Now; - #endregion #region 计算汇总 - int qualifiedNumber_No_all_total = qualifiedNumber_No_all + qualifiedNumber_No_all_again + qualifiedNumber_No_all_final; + int qualifiedNumber_No_all_total = + qualifiedNumber_No_all + + qualifiedNumber_No_all_again + + qualifiedNumber_No_all_final; //XXX:修改合格数公式:包装数 // total2.QualifiedNumber = (again2.RequireNumber ?? 0) - qualifiedNumber_No_all_total; total2.QualifiedNumber = final2.QualifiedNumber; @@ -3171,7 +3500,10 @@ namespace ZR.Service.mes.qc total2.QualifiedRate = 0; } else - total2.QualifiedRate = Math.Round(((decimal)total2.QualifiedNumber / (decimal)total2.RequireNumber) * 100, 3); + total2.QualifiedRate = Math.Round( + ((decimal)total2.QualifiedNumber / (decimal)total2.RequireNumber) * 100, + 3 + ); // XXX:修改总报表打磨,报废数计算公式 total2.DamoTotal = damo_total + damo_total_again + damo_total_final; total2.BaofeiTotal = baofei_total + baofei_total_again3 + baofei_total_final; @@ -3179,9 +3511,12 @@ namespace ZR.Service.mes.qc // total2.BaofeiTotal = baofei_total_again3 + baofei_total_final; - var x_total_2 = Context.Storageable(total2).WhereColumns(it => new { it.WorkorderId, it.Remark2 }).ToStorage(); - x_total_2.AsInsertable.ExecuteCommand();//不存在插入 - x_total_2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand();//存在更新 + var x_total_2 = Context + .Storageable(total2) + .WhereColumns(it => new { it.WorkorderId, it.Remark2 }) + .ToStorage(); + x_total_2.AsInsertable.ExecuteCommand(); //不存在插入 + x_total_2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新 //XXX:修改合格数公式 // total3.QualifiedNumber = again3.RequireNumber ?? 0 - qualifiedNumber_No_all_total; total3.QualifiedNumber = final2.QualifiedNumber; @@ -3190,7 +3525,10 @@ namespace ZR.Service.mes.qc total3.QualifiedRate = 0; } else - total3.QualifiedRate = Math.Round(((decimal)total3.QualifiedNumber / (decimal)total3.RequireNumber) * 100, 3); + total3.QualifiedRate = Math.Round( + ((decimal)total3.QualifiedNumber / (decimal)total3.RequireNumber) * 100, + 3 + ); // XXX:修改总报表打磨,报废数计算公式 total3.DamoTotal = damo_total + damo_total_again + damo_total_final; total3.BaofeiTotal = baofei_total + baofei_total_again3 + baofei_total_final; @@ -3198,31 +3536,83 @@ namespace ZR.Service.mes.qc // total3.BaofeiTotal = baofei_total_again3 + baofei_total_final; - var x_total_3 = Context.Storageable(total3).WhereColumns(it => new { it.WorkorderId, it.Remark2 }).ToStorage(); - x_total_3.AsInsertable.ExecuteCommand();//不存在插入 - x_total_3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand();//存在更新 - - - + var x_total_3 = Context + .Storageable(total3) + .WhereColumns(it => new { it.WorkorderId, it.Remark2 }) + .ToStorage(); + x_total_3.AsInsertable.ExecuteCommand(); //不存在插入 + x_total_3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新 #endregion #endregion // 产线报表生成后自动化操作 - // 1.抛光品入库 + try { - WmPolishInventoryService wmPolishInventoryService = new WmPolishInventoryService(); - WmPolishInventory warehousingInfo = new() - { - Partnumber = workorder_item.FinishedPartNumber, - Type = workorder_item.Remark1.Contains("返工") ? 2 : 1, - Quantity = paoguang_by_first, - ActionTime = DateTime.Now.ToLocalTime(), - CreatedBy = "包装" + team + "组", - Remark = "首检抛光自动入库。来源工单号:[" + workorder_item.ClientWorkorder + "]" - }; + // 1.抛光品入库 + WmPolishInventoryService wmPolishInventoryService = new(); + WmPolishInventory warehousingInfo = + new() + { + Partnumber = workorder_item.FinishedPartNumber, + WorkOrder = workorder_item.ClientWorkorder, + Type = workorder_item.Remark1.Contains("返工") ? 2 : 1, + Quantity = paoguang_by_first, + ActionTime = DateTime.Now.ToLocalTime(), + CreatedBy = "包装" + team + "组", + Remark = "首检抛光自动入库。来源工单号:[" + workorder_item.ClientWorkorder + "]" + }; wmPolishInventoryService.DoWmPolishWarehousing(warehousingInfo); + // 2.成品入一次合格品库 + // 合格品检查是否是门把手,是进入成品库(仅出库),不是进入一次合格品库 + string[] checkStrArray = + { + "T22", + "T26", + "A58", + "A60", + "C01", + "B02", + "V71", + "T1EJ " + }; + var isDoorknobCheck = Expressionable.Create(); + foreach (string checkStr in checkStrArray) + { + isDoorknobCheck.Or(it => it.Description.Contains(checkStr)); + } + ; + isDoorknobCheck + .And(it => it.Partnumber == workorder_item.FinishedPartNumber) + .And(it => it.Type == 1) + .And(it => it.Status == 1) + .And(it => it.Description.Contains("门把手")); + bool isDoorknob = Context + .Queryable() + .Where(isDoorknobCheck.ToExpression()) + .Any(); + if (!isDoorknob) + { + WmOneTimeInventoryService oneTimeService = new(); + WmOneTimeInventory wmOneTimeInventoryWarehousing = + new() + { + Partnumber = workorder_item.FinishedPartNumber, + WorkOrder = workorder_item.ClientWorkorder, + Type = workorder_item.Remark1.Contains("返工") ? 2 : 1, + Quantity = total3.QualifiedNumber, + CreatedBy = "包装" + team + "组", + ActionTime = DateTime.Now.ToLocalTime(), + Remark = + "包装合格品入库,合格数:" + + total3.QualifiedNumber + + "、工单号:" + + workorder_item.ClientWorkorder + ?? "未填写工单号" + "。记录时间:" + DateTime.Now.ToLocalTime().ToString() + }; + oneTimeService.DoWmOneTimeWarehousing(wmOneTimeInventoryWarehousing); + } } catch (Exception) { @@ -3231,6 +3621,5 @@ namespace ZR.Service.mes.qc } return 1; } - } -} \ No newline at end of file +} diff --git a/ZR.Service/mes/wms/WmGp12QualityStatisticsService.cs b/ZR.Service/mes/wms/WmGp12QualityStatisticsService.cs index 01e54519..d138cefe 100644 --- a/ZR.Service/mes/wms/WmGp12QualityStatisticsService.cs +++ b/ZR.Service/mes/wms/WmGp12QualityStatisticsService.cs @@ -27,12 +27,56 @@ namespace ZR.Service.mes.wms /// public PagedInfo GetList(WmGp12QualityStatisticsQueryDto parm) { - var predicate = Expressionable.Create(); + var predicate = Expressionable + .Create() + .AndIF( + !string.IsNullOrEmpty(parm.WorkorderId), + it => it.WorkorderId.Contains(parm.WorkorderId) + ) + .AndIF(!string.IsNullOrEmpty(parm.Team), it => it.Team.Contains(parm.Team)) + .AndIF( + !string.IsNullOrEmpty(parm.Partnumber), + it => it.Partnumber.Contains(parm.Partnumber) + ) + .AndIF( + !string.IsNullOrEmpty(parm.CreatedBy), + it => it.CreatedBy.Contains(parm.CreatedBy) + ) + .AndIF( + parm.StartTime != null, + it => it.StartTime >= parm.StartTime.Value.ToLocalTime() + ) + .AndIF( + parm.EndTime != null, + it => it.StartTime <= parm.EndTime.Value.ToLocalTime() + ); var response = Queryable() .Where(predicate.ToExpression()) .ToPage(parm); - + if (response.Result.Count > 0) + { + foreach (WmGp12QualityStatisticsDto item in response.Result) + { + WmMaterial material = Context + .Queryable() + .Where(it => it.Partnumber == item.Partnumber) + .Where(it => it.Type == 1) + .Where(it => it.Status == 1) + .First(); + if (material == null) + { + item.Description = "此零件号不在物料清单内!"; + continue; + } + item.QualifiedRateStr = Math.Ceiling(item.QualifiedRate).ToString() + "%"; + item.Color = material.Color; + item.Specification = material.Specification; + item.Description = !string.IsNullOrEmpty(material.Description) + ? material.Description + : material.ProductName; + } + } return response; } @@ -55,7 +99,114 @@ namespace ZR.Service.mes.wms /// public WmGp12QualityStatistics AddWmGp12QualityStatistics(WmGp12QualityStatistics model) { - return Context.Insertable(model).ExecuteReturnEntity(); + try + { + Context.Ado.BeginTran(); + if ( + model.RequireNumber + != ( + model.QualifiedNumber + + model.PaoguangTotal + + model.DamoTotal + + model.BaofeiTotal + ) + ) + { + throw new Exception("投入数与合格数,抛光总数,打磨数,报废数不符合,请检查"); + } + model.Id = SnowFlakeSingle.instance.NextId().ToString(); + model.Type = 0; + decimal qualifiedRate = 0.0m; + if (model.QualifiedNumber != 0) + { + qualifiedRate = + (decimal)model.QualifiedNumber / model.RequireNumber * 100 ?? 0.0m; + } + model.QualifiedRate = qualifiedRate; + WmGp12QualityStatistics res0 = Context.Insertable(model).ExecuteReturnEntity(); + if (res0 == null) + { + Context.Ado.RollbackTran(); + throw new Exception("插入GP12检测结果记录失败"); + } + WmOneTimeInventoryService oneTimeService = new(); + WmPolishInventoryService inventoryService = new(); + //抛光品重新进入抛光仓库 + if (model.PaoguangTotal > 0) + { + WmPolishInventory wmPolishInventoryWarehousing = + new() + { + Partnumber = model.Partnumber, + WorkOrder = model.WorkorderId, + Type = model.IsReturnWorkpiece ? 2 : 1, + Quantity = model.PaoguangTotal, + CreatedBy = model.CreatedBy, + ActionTime = DateTime.Now.ToLocalTime(), + Remark = + "GP12检测抛光入库,抛光数:" + + model.PaoguangTotal + + "、工单号:" + + model.WorkorderId ?? "未填写工单号" + + "。记录时间:" + + model.CreatedTime.Value.ToLocalTime().ToString() + + "[来源记录识别编号:" + + res0.Id + + "]" + }; + int res1 = inventoryService.DoWmPolishWarehousing(wmPolishInventoryWarehousing); + if (res1 == 0) + { + Context.Ado.RollbackTran(); + throw new Exception("GP12检测结果抛光入库失败"); + } + } + //合格品,报废,打磨品,抛光品 扣除一次合格品仓库库存 + if ((model.BaofeiTotal + model.DamoTotal + model.QualifiedNumber + model.PaoguangTotal) > 0) + { + WmOneTimeInventory wmOneTimeInventoryRetrieval = + new() + { + Partnumber = model.Partnumber, + WorkOrder = model.WorkorderId, + Type = model.IsReturnWorkpiece ? 2 : 1, + Quantity = ( + model.BaofeiTotal + model.DamoTotal + model.QualifiedNumber + model.PaoguangTotal + ), + CreatedBy = model.CreatedBy, + ActionTime = DateTime.Now.ToLocalTime(), + Remark = + "GP12检测记录出库,合格数:" + + model.QualifiedNumber + + "、抛光数:" + + model.PaoguangTotal + + "、打磨数:" + + model.DamoTotal + + "、报废数:" + + model.BaofeiTotal + + "、工单号:" + + model.WorkorderId ?? "未填写工单号" + + "。记录时间:" + + model.CreatedTime.Value.ToLocalTime().ToString() + + "[来源记录识别编号:" + + res0.Id + + "]" + }; + int res2 = oneTimeService.DoWmOneTimeRetrieval(wmOneTimeInventoryRetrieval); + if (res2 == 0) + { + Context.Ado.RollbackTran(); + throw new Exception("GP12检测结果出库失败"); + } + } + Context.Ado.CommitTran(); + return res0; + } + catch (Exception e) + { + Context.Ado.RollbackTran(); + throw new Exception(e.Message); + } } /// @@ -65,7 +216,33 @@ namespace ZR.Service.mes.wms /// public int UpdateWmGp12QualityStatistics(WmGp12QualityStatistics model) { - return Update(model, true); + try + { + if ( + model.RequireNumber + != ( + model.QualifiedNumber + + model.PaoguangTotal + + model.DamoTotal + + model.BaofeiTotal + ) + ) + { + throw new Exception("投入数与合格数,抛光数,打磨数,报废数不符合,请检查"); + } + decimal qualifiedRate = 0.0m; + if (model.QualifiedNumber != 0) + { + qualifiedRate = + (decimal)model.QualifiedNumber / model.RequireNumber * 100 ?? 0.0m; + } + model.QualifiedRate = qualifiedRate; + return Update(model, true); + } + catch (Exception e) + { + throw new Exception(e.Message); + } } } } diff --git a/ZR.Service/mes/wms/WmPolishInventoryService.cs b/ZR.Service/mes/wms/WmPolishInventoryService.cs index c388dcc9..911feae4 100644 --- a/ZR.Service/mes/wms/WmPolishInventoryService.cs +++ b/ZR.Service/mes/wms/WmPolishInventoryService.cs @@ -251,7 +251,9 @@ namespace ZR.Service.mes.wms WmPolishInventory addWmPolishInventory = Context .Insertable(newWmPolishInventory) .ExecuteReturnEntity(); - string code = SnowFlakeSingle.Instance.NextId().ToString(); + string code = !string.IsNullOrEmpty(parm.WorkOrder) + ? parm.WorkOrder + : SnowFlakeSingle.Instance.NextId().ToString(); string remark = "初次创建仓库,新增入库数据 " + parm.Remark; int successNum = AddPolishRecord( addWmPolishInventory.Id, @@ -355,7 +357,9 @@ namespace ZR.Service.mes.wms WmPolishInventory addWmPolishInventory = Context .Insertable(newWmPolishInventory) .ExecuteReturnEntity(); - string code = SnowFlakeSingle.Instance.NextId().ToString(); + string code = !string.IsNullOrEmpty(parm.WorkOrder) + ? parm.WorkOrder + : SnowFlakeSingle.Instance.NextId().ToString(); string remark = "初次创建仓库,新增手动出库数据" + parm.Remark; int successNum = AddPolishRecord( addWmPolishInventory.Id, @@ -432,7 +436,9 @@ namespace ZR.Service.mes.wms } Context.Updateable(parm).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); // 已有则新增记录 - string code = SnowFlakeSingle.Instance.NextId().ToString(); + string code = !string.IsNullOrEmpty(parm.WorkOrder) + ? parm.WorkOrder + : SnowFlakeSingle.Instance.NextId().ToString(); int successNum = AddPolishRecord( parm.Id, code, @@ -457,7 +463,5 @@ namespace ZR.Service.mes.wms throw new Exception(e.Message); } } - - } } diff --git a/ZR.Service/mes/wms/WmPolishQualityStatisticsService.cs b/ZR.Service/mes/wms/WmPolishQualityStatisticsService.cs index 0d591777..b6a79396 100644 --- a/ZR.Service/mes/wms/WmPolishQualityStatisticsService.cs +++ b/ZR.Service/mes/wms/WmPolishQualityStatisticsService.cs @@ -50,7 +50,7 @@ namespace ZR.Service.mes.wms ) .AndIF( parm.EndTime != null, - it => it.StartTime <= parm.StartTime.Value.ToLocalTime() + it => it.StartTime <= parm.EndTime.Value.ToLocalTime() ); var response = Queryable() @@ -127,8 +127,67 @@ namespace ZR.Service.mes.wms (decimal)model.QualifiedNumber / model.RequireNumber * 100 ?? 0.0m; } model.QualifiedRate = qualifiedRate; + WmPolishQualityStatistics res0 = Context.Insertable(model).ExecuteReturnEntity(); + if (res0 == null) + { + Context.Ado.RollbackTran(); + throw new Exception("插入抛光质检记录失败"); + } WmPolishInventoryService inventoryService = new(); - //TODO 合格品检查是否是门把手,是进入成品库,不是进入一次合格品库 + WmOneTimeInventoryService oneTimeService = new(); + // 合格品检查是否是门把手,是进入成品库(仅出库),不是进入一次合格品库 + string[] checkStrArray = + { + "T22", + "T26", + "A58", + "A60", + "C01", + "B02", + "V71", + "T1EJ " + }; + var isDoorknobCheck = Expressionable + .Create(); + foreach (string checkStr in checkStrArray) + { + isDoorknobCheck.Or(it => it.Description.Contains(checkStr)); + } + ; + isDoorknobCheck.And(it => it.Partnumber == res0.Partnumber) + .And(it => it.Type == 1) + .And(it => it.Status == 1) + .And(it => it.Description.Contains("门把手")); + bool isDoorknob = Context + .Queryable() + .Where(isDoorknobCheck.ToExpression()) + .Any(); + if (!isDoorknob && model.QualifiedNumber > 0) + { + WmOneTimeInventory wmOneTimeInventoryWarehousing = + new() + { + Partnumber = model.Partnumber, + Type = model.IsReturnWorkpiece ? 2 : 1, + Quantity = model.PaoguangTotal, + CreatedBy = model.CreatedBy, + ActionTime = DateTime.Now.ToLocalTime(), + Remark = + "抛光合格品入库,合格数:" + + model.QualifiedNumber + + "。记录时间:" + + model.CreatedTime.Value.ToLocalTime().ToString() + + "[来源记录识别编号:" + + res0.Id + + "]" + }; + int res1 = oneTimeService.DoWmOneTimeWarehousing(wmOneTimeInventoryWarehousing); + if (res1 == 0) + { + Context.Ado.RollbackTran(); + throw new Exception("抛光合格品入库失败"); + } + } //抛光品重新进入抛光仓库 if (model.PaoguangTotal > 0) @@ -140,12 +199,15 @@ namespace ZR.Service.mes.wms Type = model.IsReturnWorkpiece ? 2 : 1, Quantity = model.PaoguangTotal, CreatedBy = model.CreatedBy, - ActionTime = DateTime.Now, + ActionTime = DateTime.Now.ToLocalTime(), Remark = - "抛光质检记录入库:抛光数" + "抛光质检记录入库,抛光数:" + model.PaoguangTotal - + "。记录时间" + + "。记录时间:" + model.CreatedTime.Value.ToLocalTime().ToString() + + "[来源记录识别编号:" + + res0.Id + + "]" }; int res1 = inventoryService.DoWmPolishWarehousing(wmPolishInventory); if (res1 == 0) @@ -168,31 +230,27 @@ namespace ZR.Service.mes.wms CreatedBy = model.CreatedBy, ActionTime = DateTime.Now, Remark = - "抛光质检记录出库:合格数" + "抛光质检记录出库,合格数:" + model.QualifiedNumber - + "、打磨数" + + "、打磨数:" + model.DamoTotal - + "、报废数" + + "、报废数:" + model.BaofeiTotal - + "。记录时间" + + "。记录时间:" + model.CreatedTime.Value.ToLocalTime().ToString() + + "[来源记录识别编号:" + + res0.Id + + "]" }; - int res1 = inventoryService.DoWmPolishRetrieval(wmPolishInventory); - if (res1 == 0) + int res2 = inventoryService.DoWmPolishRetrieval(wmPolishInventory); + if (res2 == 0) { Context.Ado.RollbackTran(); throw new Exception("抛光质检记录出库失败"); } } - - WmPolishQualityStatistics res3 = Context.Insertable(model).ExecuteReturnEntity(); - if (res3 == null) - { - Context.Ado.RollbackTran(); - throw new Exception("插入抛光质检记录失败"); - } Context.Ado.CommitTran(); - return res3; + return res0; } catch (Exception e) { @@ -220,7 +278,7 @@ namespace ZR.Service.mes.wms ) ) { - throw new Exception("投入数与合格数,抛光总数,打磨数,报废数不符合,请检查"); + throw new Exception("投入数与合格数,抛光数,打磨数,报废数不符合,请检查"); } decimal qualifiedRate = 0.0m; if (model.QualifiedNumber != 0) diff --git a/ZR.Service/mes/wms/WmPolishWorkQualityStatisticsService.cs b/ZR.Service/mes/wms/WmPolishWorkQualityStatisticsService.cs index aaca737e..884f5fea 100644 --- a/ZR.Service/mes/wms/WmPolishWorkQualityStatisticsService.cs +++ b/ZR.Service/mes/wms/WmPolishWorkQualityStatisticsService.cs @@ -50,7 +50,7 @@ namespace ZR.Service.mes.wms ) .AndIF( parm.EndTime != null, - it => it.StartTime <= parm.StartTime.Value.ToLocalTime() + it => it.StartTime <= parm.EndTime.Value.ToLocalTime() ); var response = Queryable() @@ -122,6 +122,14 @@ namespace ZR.Service.mes.wms (decimal)model.QualifiedNumber / model.RequireNumber * 100 ?? 0.0m; } model.QualifiedRate = qualifiedRate; + WmPolishWorkQualityStatistics res0 = Context + .Insertable(model) + .ExecuteReturnEntity(); + if (res0 == null) + { + Context.Ado.RollbackTran(); + throw new Exception("插入抛光操作记录失败"); + } WmPolishInventoryService inventoryService = new(); //合格品重新进入抛光仓库 if (model.QualifiedNumber > 0) @@ -133,12 +141,15 @@ namespace ZR.Service.mes.wms Type = model.IsReturnWorkpiece ? 2 : 1, Quantity = model.QualifiedNumber, CreatedBy = model.CreatedBy, - ActionTime = DateTime.Now, + ActionTime = DateTime.Now.ToLocalTime(), Remark = - "抛光操作记录入库:合格数" + "抛光操作记录入库,合格数:" + model.QualifiedNumber - + "。记录时间" + + "。记录时间:" + model.CreatedTime.Value.ToLocalTime().ToString() + + "[来源记录识别编号:" + + res0.Id + + "]" }; int res1 = inventoryService.DoWmPolishWarehousing(wmPolishInventory); if (res1 == 0) @@ -157,7 +168,7 @@ namespace ZR.Service.mes.wms Type = model.IsReturnWorkpiece ? 2 : 1, Quantity = (model.BaofeiTotal + model.DamoTotal), CreatedBy = model.CreatedBy, - ActionTime = DateTime.Now, + ActionTime = DateTime.Now.ToLocalTime(), Remark = "抛光操作记录出库:打磨数" + model.DamoTotal @@ -165,25 +176,19 @@ namespace ZR.Service.mes.wms + model.BaofeiTotal + "。记录时间" + model.CreatedTime.Value.ToLocalTime().ToString() + + "[来源记录识别编号:" + + res0.Id + + "]" }; - int res1 = inventoryService.DoWmPolishRetrieval(wmPolishInventory); - if (res1 == 0) + int res2 = inventoryService.DoWmPolishRetrieval(wmPolishInventory); + if (res2 == 0) { Context.Ado.RollbackTran(); throw new Exception("抛光操作记录出库失败"); } } - - WmPolishWorkQualityStatistics res3 = Context - .Insertable(model) - .ExecuteReturnEntity(); - if (res3 == null) - { - Context.Ado.RollbackTran(); - throw new Exception("插入抛光操作记录失败"); - } Context.Ado.CommitTran(); - return res3; + return res0; } catch (Exception e) {