轮胎外观检测添加思谋语义分割模型检测工具
C3204
2026-03-30 7ceaa09e4baefe84bad268b56bbf8b8f3f1d0f99
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
using ClassLibrary1;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
 
namespace DeviceITisation
{
    public class DeviceOnline
    {
        public bool AddDevice(out string msg, string test_date, string device_type, string device_name, string device_sn,
                string device_fw, string location, string user_name, string assets_no, string device_status, string remark = "",
                string pc_name = "", string pc_ip = "", string pc_mac = "", string bom = "", string odf = "")
        {
            try
            {
                if (string.IsNullOrEmpty(pc_name))
                    pc_name = SystemInfoHelper.GetComputerName();
 
                if (string.IsNullOrEmpty(pc_ip))
                    pc_ip = SystemInfoHelper.GetLocalIPAddress();
 
                if (string.IsNullOrEmpty(pc_mac))
                    pc_mac = SystemInfoHelper.GetFirstMacAddress();
 
                string[] colsName = new string[]
                {
                    "bom","odf","test_date","device_type","device_name","device_sn",
                    "device_fw","location","pc_name","pc_ip","pc_mac","user_name",
                    "assets_no","device_status","remark"
                };
 
                if (MySqlCommand.CheckRecordExists("device_ol_log", new string[] { "device_sn" }, colsName,
                        bom, odf, test_date, device_type, device_name, device_sn,
                        device_fw, location, pc_name, pc_ip, pc_mac, user_name,
                        assets_no, device_status, remark))
                {
                    string last_location = MySqlCommand.FindValueFromIndexName("device_ol_log", "device_sn", device_sn, "location");
                    string last_remark = MySqlCommand.FindValueFromIndexName("device_ol_log", "device_sn", device_sn, "remark");
                    string last_date = MySqlCommand.FindValueFromIndexName("device_ol_log", "device_sn", device_sn, "date");
 
                    //if (!string.IsNullOrEmpty(last_remark))
                    //{
                    //    if (!string.IsNullOrEmpty(remark))
                    //        remark += $"[{last_remark}]";
                    //    else
                    //        remark += $"{last_remark}";
                    //}
 
                    if (last_location != location)
                        remark += $"[{last_date}位置为{last_location}]";
 
                    if (MySqlCommand.AddRow("device_ol_log", colsName, new string[] { "device_sn" },
                                            bom, odf, test_date, device_type, device_name, device_sn,
                                            device_fw, location, pc_name, pc_ip, pc_mac, user_name,
                                            assets_no, device_status, remark))
                    {
                        Debug.WriteLine($"{device_sn}更新成功");
                        msg = $"{device_sn}更新成功";
                        return true;
                    }
                    else
                    {
                        Debug.WriteLine($"{device_sn}更新失败");
                        msg = $"{device_sn}更新失败";
                        return false;
                    }
                }
                else
                {
                    if (MySqlCommand.AddRow("device_ol_log", colsName, new string[] { "device_sn" },
                        bom, odf, test_date, device_type, device_name, device_sn,
                        device_fw, location, pc_name, pc_ip, pc_mac, user_name,
                        assets_no, device_status, remark))
                    {
                        Debug.WriteLine($"{device_sn}添加成功");
                        msg = $"{device_sn}添加成功";
                        return true;
                    }
                    else
                    {
                        Debug.WriteLine($"{device_sn}添加失败");
                        msg = $"{device_sn}添加失败";
                        return false;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"添加{device_sn}时发生异常:{e.Message}【{e.StackTrace}】");
                msg = $"添加{device_sn}时发生异常:{e.Message}【{e.StackTrace}】";
                return false;
            }
        }
 
        public bool AddDeviceBySN(out string msg, string test_date, string device_type, string device_name, string device_sn,
                string device_fw, string location, string user_name, string assets_no, string device_status, string sn, string remark = "",
                string pc_name = "", string pc_ip = "", string pc_mac = "")
        {
            try
            {
                if (string.IsNullOrEmpty(pc_name))
                    pc_name = SystemInfoHelper.GetComputerName();
 
                if (string.IsNullOrEmpty(pc_ip))
                    pc_ip = SystemInfoHelper.GetLocalIPAddress();
 
                if (string.IsNullOrEmpty(pc_mac))
                    pc_mac = SystemInfoHelper.GetFirstMacAddress();
 
                string[] colsName = new string[]
                {
                    "bom","odf","test_date","device_type","device_name","device_sn",
                    "device_fw","location","pc_name","pc_ip","pc_mac","user_name",
                    "assets_no","device_status","remark"
                };
 
                GetBomAndOdf(sn, out string bom, out string odf);
 
                if (MySqlCommand.CheckRecordExists("device_ol_log", new string[] { "device_sn" }, colsName,
                        bom, odf, test_date, device_type, device_name, device_sn,
                        device_fw, location, pc_name, pc_ip, pc_mac, user_name,
                        assets_no, device_status, remark))
                {
                    string last_location = MySqlCommand.FindValueFromIndexName("device_ol_log", "device_sn", device_sn, "location");
                    string last_remark = MySqlCommand.FindValueFromIndexName("device_ol_log", "device_sn", device_sn, "remark");
                    string last_date = MySqlCommand.FindValueFromIndexName("device_ol_log", "device_sn", device_sn, "date");
 
                    //if (!string.IsNullOrEmpty(last_remark))
                    //{
                    //    if (!string.IsNullOrEmpty(remark))
                    //        remark += $"[{last_remark}]";
                    //    else
                    //        remark += $"{last_remark}";
                    //}
 
                    if (last_location != location)
                        remark += $"[{last_date}位置为{last_location}]";
 
                    if (MySqlCommand.AddRow("device_ol_log", colsName, new string[] { "device_sn" },
                                            bom, odf, test_date, device_type, device_name, device_sn,
                                            device_fw, location, pc_name, pc_ip, pc_mac, user_name,
                                            assets_no, device_status, remark))
                    {
                        Debug.WriteLine($"{device_sn}更新成功");
                        msg = $"{device_sn}更新成功";
                        return true;
                    }
                    else
                    {
                        Debug.WriteLine($"{device_sn}更新失败");
                        msg = $"{device_sn}更新失败";
                        return false;
                    }
                }
                else
                {
                    if (MySqlCommand.AddRow("device_ol_log", colsName, new string[] { "device_sn" },
                        bom, odf, test_date, device_type, device_name, device_sn,
                        device_fw, location, pc_name, pc_ip, pc_mac, user_name,
                        assets_no, device_status, remark))
                    {
                        Debug.WriteLine($"{device_sn}添加成功");
                        msg = $"{device_sn}添加成功";
                        return true;
                    }
                    else
                    {
                        Debug.WriteLine($"{device_sn}添加失败");
                        msg = $"{device_sn}添加失败";
                        return false;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"添加{device_sn}时发生异常:{e.Message}【{e.StackTrace}】");
                msg = $"添加{device_sn}时发生异常:{e.Message}【{e.StackTrace}】";
                return false;
            }
        }
 
        public bool GetBomAndOdf(string sn, out string bom, out string odf)
        {
            try
            {
                bom = string.Empty;
                odf = string.Empty;
                string GetTVInfoMessage = ClassLibrary1.Class1.GetTVinfo(sn);
                if (GetTVInfoMessage != "null")
                {
                    try
                    {
                        List<GetTVInfo> GetTVInfo1 = JsonConvert.DeserializeObject<List<GetTVInfo>>("[" + GetTVInfoMessage + "]");
                        foreach (GetTVInfo l in GetTVInfo1)
                        {
                            bom = l.ProductCode;
                            odf = l.ODF;
                        }
                        return true;
                    }
                    catch
                    {
                        bom = string.Empty;
                        odf = string.Empty;
                        return false;
                    }
                }
                else
                {
                    try
                    {
                        string sHtml = ClassLibrary1.Class1.PostXml(" http://10.222.16.22:9002/SAPService.asmx?op=GetMaInfo", sn);
                        RootObject5 rb = JsonConvert.DeserializeObject<RootObject5>(sHtml);
 
                        bom = rb.BOM;
                        odf = rb.ODF;
                        return true;
                    }
                    catch
                    {
                        bom = string.Empty;
                        odf = string.Empty;
                        return false;
                    }
                }
 
            }
            catch
            {
                bom = string.Empty;
                odf = string.Empty;
                return false;
            }
        }
    }
}