| | |
| | | } |
| | | } |
| | | |
| | | // 统一更新最新首检备注 |
| | | // 最新首检单 |
| | | var latestFirst = Db.Queryable<MesQaItemsDetect02>() |
| | | .Where(s => s.Aufnr == womdaa.Daa001 && s.Ftype == "首检" && (s.Fcancel == null || s.Fcancel != "Y")) |
| | | .OrderBy(s => s.CreateDate, OrderByType.Desc) |
| | | .First(); |
| | | |
| | | if (latestFirst != null) |
| | | { |
| | | var ts = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | var remark = $"工控机于{ts}自动创建的首检单"; |
| | | Db.Updateable<MesQaItemsDetect02>() |
| | | .SetColumns(s => s.Remeke == remark) |
| | | .Where(s => s.Id == latestFirst.Id) |
| | | .ExecuteCommand(); |
| | | // 如果最新首检不合格:清空调机送检时间并重新生成首检单 |
| | | if (latestFirst.FcheckResu == "不合格") |
| | | { |
| | | // 清空数据库的送检时间 |
| | | InspectionIsUnqualified(new OrderMachineDto |
| | | { |
| | | OrderId = entity.OrderId |
| | | }); |
| | | // 避免后续更新时再写入旧送检时间 |
| | | entity.MaShoutTime = null; |
| | | |
| | | // 行级锁,确保重建过程串行 |
| | | Db.Ado.ExecuteCommand("SELECT ID FROM WOMDAA WHERE DAA001 = :BILL_NO FOR UPDATE", |
| | | new SugarParameter("BILL_NO", womdaa.Daa001)); |
| | | // 直接调用首检生成存储过程 |
| | | Db.Ado.ExecuteCommand( |
| | | "BEGIN AUTOMATIC_IPQC_FIRST_CHECK(:BILL_NO); END;", |
| | | new SugarParameter("BILL_NO", womdaa.Daa001, System.Data.DbType.String)); |
| | | |
| | | // 获取重建后的最新首检单并写备注 |
| | | var rebuiltFirst = Db.Queryable<MesQaItemsDetect02>() |
| | | .Where(s => s.Aufnr == womdaa.Daa001 && s.Ftype == "首检" && (s.Fcancel == null || s.Fcancel != "Y")) |
| | | .OrderBy(s => s.CreateDate, OrderByType.Desc) |
| | | .First(); |
| | | |
| | | if (rebuiltFirst != null) |
| | | { |
| | | var ts2 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | var remark2 = $"工控机于{ts2}重建的不合格后首检单"; |
| | | Db.Updateable<MesQaItemsDetect02>() |
| | | .SetColumns(s => s.Remeke == remark2) |
| | | .Where(s => s.Id == rebuiltFirst.Id) |
| | | .ExecuteCommand(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // 合格或其它结果时仅更新备注 |
| | | var ts = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | var remark = $"工控机于{ts}自动创建的首检单"; |
| | | Db.Updateable<MesQaItemsDetect02>() |
| | | .SetColumns(s => s.Remeke == remark) |
| | | .Where(s => s.Id == latestFirst.Id) |
| | | .ExecuteCommand(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | Db.Insertable<MesAnchors>(eAnchors) |
| | | .ExecuteCommand(); |
| | | |
| | | |
| | | |
| | | // 新增逻辑:送检时间有值时,判断最新首检单是否合格,合格则写入调机完成时间为当前时间 |
| | | // 若送检时间存在且首检合格则写入调机完成时间 |
| | | if (!string.IsNullOrEmpty(entity.MaShoutTime)) |
| | | { |
| | | //送检呼叫时间必须大于或等于调机开始时间,以此来筛选首检单 |
| | | if (DateTime.TryParse(entity.MaShoutTime, out var sjTime) && DateTime.TryParse(entity.MaStartTime, out var startTime)) |
| | | { |
| | | if (sjTime >= startTime) |