快乐的昕的电脑
2025-10-22 7e0aad095dc9ed744f1f7ecd8a0ca56b674a8f26
Services/MesOrderStaManager.cs
@@ -152,7 +152,7 @@
                    "application/json");
                var response = httpClient
                    .PostAsync("http://192.168.0.94:9095/Numerical/RefreshDev",
                    .PostAsync("http://192.168.0.94:9095/Numerical/RefreshDevBycl",
                        content).GetAwaiter().GetResult();
                if (response.IsSuccessStatusCode)
@@ -192,24 +192,42 @@
            OrderId = womdaa.Id,
            OrderNo = womdaa.Daa001,
            EditDate = editDate,
            Qty = mesReporting == null ? 0 : Int64.Parse(mesReporting.DyQty),
            Qty = mesReporting == null ? 0 : (long?)(mesReporting.DyQty ?? 0),
            InitialValue = mesNumerical == null ? 0 : mesNumerical.CjNum
        };
        Db.Insertable<MesAnchors>(eAnchors)
            .ExecuteCommand();
        // 新增逻辑:送检时间有值时,判断最新首检单是否合格,合格则写入调机完成时间为当前时间
        if (!string.IsNullOrEmpty(entity.MaShoutTime))
        {
            // 查找该工单号下最新的首检单
            var sjRecord = Db.Queryable<MesQaItemsDetect02>()
                .Where(x => x.Aufnr == womdaa.Daa001 && x.Ftype == "首检")
                .OrderBy(x => x.CreateDate, OrderByType.Desc)
                .First();
            if (sjRecord != null && sjRecord.FcheckResu == "合格")
            //送检呼叫时间必须大于或等于调机开始时间,以此来筛选首检单
            if (DateTime.TryParse(entity.MaShoutTime, out var sjTime) && DateTime.TryParse(entity.MaStartTime, out var startTime))
            {
                entity.MaEndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (sjTime >= startTime)
                {
                    // 查找该工单号下最新的首检单
                    var sjRecord = Db.Queryable<MesQaItemsDetect02>()
                        .Where(x => x.Aufnr == womdaa.Daa001 && x.Ftype == "首检")
                        .OrderBy(x => x.CreateDate, OrderByType.Desc)
                        .First();
                    if (sjRecord != null && sjRecord.FcheckResu == "合格")
                    {
                        // 使用QualifiedInspection方法更新工单状态
                        QualifiedInspection(new OrderMachineDto
                        {
                            OrderId = entity.OrderId,
                            orderNo = entity.OrderNo,
                            machineNo = entity.MachineNo
                        });
                        //将送检时间写入开工时间
                        entity.StartTime = entity.MaShoutTime;
                        entity.MaEndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    }
                }
            }
        }
@@ -224,6 +242,9 @@
            // 如果有调机完成时间则更新
            .SetColumnsIF(entity.MaEndTime != null,
                s => s.MaEndTime == entity.MaEndTime)
            // 如果有开工时间则更新
            .SetColumnsIF(entity.StartTime != null,
                s => s.StartTime == entity.StartTime)
            // 如果标记为1则更新备注信息
            .SetColumnsIF(entity.Flag == 1,
                s => s.remark == "于" + entity.MaShoutTime + "时间有一次送检")
@@ -487,12 +508,12 @@
                            MachineNo = womdaa.MachineNo,
                            // BfQty = reportingOkQty,
                            BfQty = 0,
                            BlQty = reportingOkQty.ToString(),
                            BlQty = reportingOkQty,
                            OkQty = 0,
                            ItemNo = womdaa.Daa002,
                            BillNo = womdaa.Daa001,
                            CjQty = CjQty.ToString(),
                            DyQty = reporting.OkQty.ToString()
                            CjQty = CjQty,
                            DyQty = reporting.OkQty
                        };
                        
                        // 插入报工记录