chenyong
2024-11-18 10797a680feaa24bdc17d10ac085e323be807819
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using LogLibrary.Log;
using Masuit.Tools;
using Newtonsoft.Json;
using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_DTO;
using WIDESEA_IStorageBasicService;
using WIDESEA_IStoragIntegrationServices;
 
namespace WIDESEA_StoragIntegrationServices;
 
public class CellStateService : ICellStateService
{
    private readonly LogFactory LogFactory = new LogFactory();
 
    private readonly IBoxingInfoService _boxingInfoService;
 
    public CellStateService(IBoxingInfoService boxingInfoService)
    {
        _boxingInfoService = boxingInfoService;
    }
 
    /// <summary>
    /// 单电芯属性获取
    /// </summary>
    /// <param name="input">电芯数据</param>
    /// <returns></returns>
    public async Task<dynamic> GetCellStateAsync(CellStateDto input)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            input.SessionId = Guid.NewGuid().ToString();
            input.EmployeeNo = "MITest";
            input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
            var inputJson = input.ToDictionary();
            var x = await HttpsClient.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/CellState", inputJson);
            #region
            //if (x != null)
            //{
            //    ResultCellState result = JsonConvert.DeserializeObject<ResultCellState>(x);
            //    DtBoxingInfo boxingInfo = new DtBoxingInfo()
            //    {
            //        IsFull = true,
            //        PalletCode = "",
            //    };
            //    var details = new List<DtBoxingInfoDetail>();
            //    foreach (var item in result.SerialNos)
            //    {
            //        DtBoxingInfoDetail detail = new DtBoxingInfoDetail()
            //        {
            //            SerialNumber = item.SerialNo,
            //            OrderNo = item.BindCode,
            //            Status = item.SerialNoStatus,
            //        };
            //        details.Add(detail);
            //    }
            //    boxingInfo.BoxingInfoDetails = details;
            //    var abc = await _boxingInfoService.AddBoxingInfoAsync(boxingInfo);
            //    if (abc.Status)
            //        return content.OK("组盘成功");
            //    else
            //        return content.Error("组盘失败");
            //}
            #endregion
 
            LogFactory.GetLog("单电芯属性获取").Info(true, $"\r\r--------------------------------------");
            LogFactory.GetLog("单电芯属性获取").Info(true, x);
            return x;
        }
        catch (Exception err)
        {
            Console.WriteLine(err.Message.ToString());
            LogFactory.GetLog("单电芯属性获取").Error(true, $"\r\r--------------------------------------");
            LogFactory.GetLog("单电芯属性获取").Error(true, $"请求参数: {JsonConvert.SerializeObject(input)}");
            LogFactory.GetLog("单电芯属性获取").Error(true, err.Message);
            LogFactory.GetLog("单电芯属性获取").Error(true, err.StackTrace);
        }
        return Task.FromResult<dynamic>(null);
    }
 
    /// <summary>
    /// 整盘电芯属性获取
    /// </summary>
    /// <param name="input">电芯数据</param>
    /// <returns></returns>
    public async Task<WebResponseContent> GetTrayCellStatusAsync(TrayCellsStatusDto input)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            input.SessionId = Guid.NewGuid().ToString();
            input.EmployeeNo = "MITest";
            input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
            var inputJson = input.ToDictionary();
            var x = await HttpsClient.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/TrayCellsStatus", inputJson);
            if (x != null)
            {
                // 反序列化ResultTrayCellsStatus对象
                //ResultTrayCellsStatus result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(x);
 
                //// 创建DtBoxingInfo对象
                //DtBoxingInfo boxingInfo = new DtBoxingInfo
                //{
                //    IsFull = true,
                //    PalletCode = result.TrayBarcode,
                //};
 
                //// 使用LINQ创建DtBoxingInfoDetail对象列表
                //var details = result.SerialNos.Select(item => new DtBoxingInfoDetail
                //{
                //    SerialNumber = item.SerialNo,
                //    OrderNo = item.PositionNo.ToString(),
                //    Status = item.SerialNoStatus,
                //    Remark = result.TrayBarcodePropertys.ToJsonString(),
                //    MaterielCode = result.BindCode,
                //}).ToList();
 
                //// 赋值DtBoxingInfoDetails
                //boxingInfo.BoxingInfoDetails = details;
                //var abc = await _boxingInfoService.AddBoxingInfoAsync(boxingInfo);
                    content.OK("组盘成功", x);
            }
            LogFactory.GetLog("整盘电芯属性获取").Info(true, $"\r\r--------------------------------------");
            LogFactory.GetLog("整盘电芯属性获取").Info(true, x);
        }
        catch (Exception err)
        {
            Console.WriteLine(err.Message.ToString());
            LogFactory.GetLog("整盘电芯属性获取").Error(true, $"\r\r--------------------------------------");
            LogFactory.GetLog("整盘电芯属性获取").Error(true, $"请求参数: {JsonConvert.SerializeObject(input)}");
            LogFactory.GetLog("整盘电芯属性获取").Error(true, err.Message);
            LogFactory.GetLog("整盘电芯属性获取").Error(true, err.StackTrace);
        }
        return content;
    }
}