using Masuit.Tools; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Common; using WIDESEA_Core; namespace WIDESEA_StoragIntegrationServices { /// /// 订单、工单撤排 /// 接口描述:通知BDC涂装工单/总装工单/订单撤排 /// 1- 工单/订单撤排支持部分撤排 /// 2- 试制类型工单/订单撤排BDC库已过BDC03/BDC05工单不支持撤排 /// 3-非试制类型工单/订单撤排一句绑定状态,已完成绑定的工单/订单不支持撤排 /// 4-总装工单已拉动锁车的车身工单不支持撤排 /// public partial class MESService { public WebResponseContent removeWorkOrderInfo(object jsonData) { WebResponseContent content = new WebResponseContent(); try { if (string.IsNullOrEmpty(jsonData.ToString())) throw new Exception("请求参数为空"); Console.WriteLine(jsonData); var result = JsonConvert.DeserializeObject>(jsonData.ToString()); //if (result.plantCode != "1052") throw new Exception("非本工厂工单/订单,无法排撤,请重试"); List removeWorkOrderInfos = new List(); foreach (var item in result) { if (item.workshopCode == "TZ") { var orderinfo = _paintingOrderInfoRepository.QueryFirst(x => x.workOrderNo == item.workOrderNo && x.workOrderType == item.orderType); if (orderinfo == null) throw new Exception($"未找到工单号{item.workOrderNo}工单类型为{item.orderType}的涂装工单"); _paintingOrderInfoRepository.DeleteData(orderinfo); } else { var orderinfo = _assemblyOrderInfoRepository.QueryFirst(x => x.workOrderNo == item.workOrderNo && x.orderType == item.orderType); if (orderinfo == null) throw new Exception($"未找到工单号{item.workOrderNo}工单类型为{item.orderType}的总装工单"); //if (!string.IsNullOrEmpty(orderinfo.pvi)) throw new Exception($"总装工单号{item.workOrderNo}已拉动锁车的车身工单不支持撤排"); _assemblyOrderInfoRepository.DeleteData(orderinfo); } } LogFactory.GetLog("订单/工单排撤").Info(true, $"\r\r--------------------------------------"); LogFactory.GetLog("订单/工单排撤").Info(true, result.ToJsonString()); return content.OK(); } catch (Exception ex) { LogFactory.GetLog("订单/工单排撤").Info(true, jsonData.ToJsonString()); return content.Error($"排撤失败:{ex.Message}"); } } } }