Tiandele
2026-03-20 daea1a90c2fa1b5cc2f52e62be15bd95cc4155f6
ÏîÄ¿´úÂë/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/removeWorkOrderInfo.cs
@@ -1,8 +1,11 @@
using System;
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
@@ -17,19 +20,45 @@
    /// </summary>
    public partial class MESService
    {
        public WebResponseContent removeWorkOrderInfo(string jsonData)
        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<List<removeWorkOrderInfo>>(jsonData.ToString());
                //if (result.plantCode != "1052") throw new Exception("非本工厂工单/订单,无法排撤,请重试");
                List<removeWorkOrderInfoRespon> removeWorkOrderInfos = new List<removeWorkOrderInfoRespon>();
                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)
            {
                return content.OK(ex.Message);
                LogFactory.GetLog("订单/工单排撤").Info(true, jsonData.ToJsonString());
                return content.Error($"排撤失败:{ex.Message}");
            }
        }