1
huangxiaoqiang
2026-03-17 3fa25c0bcb790b64bc206211923099cc330c5086
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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涂装工单/总装工单/订单撤排
    /// 1- 工单/订单撤排支持部分撤排
    /// 2- 试制类型工单/订单撤排BDC库已过BDC03/BDC05工单不支持撤排
    /// 3-非试制类型工单/订单撤排一句绑定状态,已完成绑定的工单/订单不支持撤排
    /// 4-总装工单已拉动锁车的车身工单不支持撤排
    /// </summary>
    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<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)
            {
                LogFactory.GetLog("订单/工单排撤").Info(true, jsonData.ToJsonString());
                return content.Error($"排撤失败:{ex.Message}");
            }
 
        }
    }
}