Tiandele
2026-03-20 daea1a90c2fa1b5cc2f52e62be15bd95cc4155f6
ÏîÄ¿´úÂë/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/removeWorkOrderInfo.cs
@@ -1,31 +1,64 @@
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
{
    /// <summary>
    /// BDC请求焊装特征下发
    /// æŽ¥å£æè¿°: è½¦èº«è¿›å…¥BDC时,BDC读取车身上的一维条码向MES请求焊装特征信息
    /// è®¢å•、工单撤排
    /// æŽ¥å£æè¿°:通知BDC涂装工单/总装工单/订单撤排
    /// 1- å·¥å•/订单撤排支持部分撤排
    /// 2- è¯•制类型工单/订单撤排BDC库已过BDC03/BDC05工单不支持撤排
    /// 3-非试制类型工单/订单撤排一句绑定状态,已完成绑定的工单/订单不支持撤排
    /// 4-总装工单已拉动锁车的车身工单不支持撤排
    /// </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}");
            }
        }