PDAService.cs
30.1 KB
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
using ApkInfo;
using Hh.Mes.Common;
using Hh.Mes.Common.config;
using Hh.Mes.Common.Json;
using Hh.Mes.Common.log;
using Hh.Mes.Common.Redis;
using Hh.Mes.Pojo.System;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Response;
using Hh.Mes.POJO.ViewModel;
using Hh.Mes.POJO.WebEntity;
using Hh.Mes.Service.Repository;
using Hh.Mes.Service.SystemAuth;
using MySqlX.XDevAPI.Common;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Hh.Mes.Service
{
public class PDAService : RepositorySqlSugar<sys_user>
{
AuthContextFactory authContextFactory;
public PDAService(AuthContextFactory authContextFactory)
{
this.authContextFactory = authContextFactory;
}
/// <summary>
/// PDA物料追溯查询
/// (扫码查询物料追溯码,查看物料的批次,物料名称,壁厚等物料信息)
/// </summary>
/// <param name="barCode"></param>
/// <returns></returns>
public dynamic GetMaterialInfoByBarCode(dynamic requestData)
{
return ExceptionsHelp.Instance.ExecuteT<dynamic>(() =>
{
var reqData = DynamicJson.Parse(requestData.ToString());
var response = new Response();
if (reqData == null || !reqData.IsDefined("barCode"))
{
return response.ResponseError($"barCode:参数字段不正确,请核对!");
}
string barCode = reqData.barCode;
if (string.IsNullOrEmpty(barCode)) return response.ResponseError($"barCode:值不能为空,请核对!");
//1:扫码 BarCode 查询bus_workOrder_detail 表确认BarCode是否存在。
var bwdInfo = Context.Queryable<bus_workOrder_detail>().First(x => x.barCode == barCode);
if (bwdInfo == null || string.IsNullOrEmpty(bwdInfo.barCode))
{
return response.ResponseError($"barCode:【{barCode}】不存在工序任务明细表中,请核对!");
}
if (string.IsNullOrEmpty(bwdInfo.cutMaterCode))
{
return response.ResponseError($"根据barCode:【{barCode}】未查询到工序任务明细表中的物料编码信息,请核对!");
}
//2:根据BarCode 查询到当前行的 materialCode,在去物料表查询 返回物料表的基础信息。
var materialInfo = Context.Queryable<base_material>().First(x => x.materialCode == bwdInfo.cutMaterCode);
if (materialInfo == null) return response.ResponseError($"未查询到{bwdInfo.cutMaterCode}的物料基础信息,请检查!");
//查询套料信息得到管材长度
var cutplandetail= Context.Queryable<bus_cutplan_detail>().First(x => x.barCode == barCode);
if (cutplandetail == null) return response.ResponseError($"{barCode}追踪码无效,请检查!");
materialInfo.barCode = barCode;
materialInfo.cuttingLength = cutplandetail.cuttingLength;
//查询套料头得到物料使用的批次
var buscutplanhead = Context.Queryable<bus_cutplan_head>().First(x => x.keys == cutplandetail.headKeys);
if (cutplandetail == null) return response.ResponseError($"{barCode}追踪码无效,请检查!");
materialInfo.lotNo = buscutplanhead.lotNo;
materialInfo.extend1 = bwdInfo.batchNo;//批次号
response.Result = materialInfo;
return response;
});
}
#region 组对、焊接
/// <summary>
/// 获取匹配的组对信息
/// </summary>
/// <param name="pipe">管段码</param>
/// <param name="batch">批次码</param>
/// <returns></returns>
public dynamic GetMatchTeamList(string pipe, string batch)
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var response = new Response();
if (string.IsNullOrWhiteSpace(pipe))
{
response.ResponseErr($"管段码【{pipe}】是空,请重新扫描管段码!");
return response;
}
if (string.IsNullOrWhiteSpace(batch))
{
response.ResponseErr($"批次码【{batch}】是空,请重新扫描批次码!");
return response;
}
var materialCode = batch;//todo:批次需要调用接口获取物料码
var resultDetail = Context.Queryable<bus_workOrder_detail>().Where(x =>
x.barCode.Equals(pipe) &&
x.state == (int)EnumOrderBodyStatus.运输中 &&
x.weldMaterCode.Equals(materialCode) &&
x.workCenterCode == EnumoprSequenceCode.组对).ToList();
bus_workOrder_head result = null;
if (resultDetail.Count > 0)
{
var material = Context.Queryable<base_material>().Where(x =>
x.materialCode.Equals(resultDetail[0].cutMaterCode)).First();
result = Context.Queryable<bus_workOrder_head>().Where(x => x.keys == resultDetail[0].headKeys).First();
if (material != null)
{
result.types = material.types;
result.diameter = material.diameter;
result.thickness = material.thickness;
}
result.teamList = resultDetail;
}
response.Result = result;
return response;
});
}
/// <summary>
/// 获取组对开始列表
/// </summary>
/// <returns></returns>
public dynamic GetTeamStartList()
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var response = new Response();
var resultDetail = Context.Queryable<bus_workOrder_detail>().Where(x =>
(x.state > (int)EnumOrderBodyStatus.运输中 && x.state < (int)EnumOrderBodyStatus.已完成) &&
x.workCenterCode == EnumoprSequenceCode.组对).ToList();
var headKeyList = Context.Queryable<bus_workOrder_detail>().Where(x =>
(x.state > (int)EnumOrderBodyStatus.运输中 && x.state < (int)EnumOrderBodyStatus.已完成) &&
x.workCenterCode == EnumoprSequenceCode.组对).GroupBy(x => x.headKeys).Select(x => x.headKeys).ToList();
List<bus_workOrder_head> result = new List<bus_workOrder_head>();
foreach (var key in headKeyList)
{
var item = Context.Queryable<bus_workOrder_head>().Where(x => x.keys == key).First();
item.teamList = new List<bus_workOrder_detail>();
foreach (var detail in resultDetail)
{
if (detail.headKeys == key)
{
item.teamList.Add(detail);
}
}
result.Add(item);
}
response.Result = result;
return response;
});
}
/// <summary>
/// 保存组对开始列表
/// </summary>
/// <returns></returns>
public dynamic SaveTeamStartList(List<bus_workOrder_detail> details)
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var response = new Response();
foreach (var item in details)
{
var resultItem = Context.Queryable<bus_workOrder_detail>().Where(x => x.bodyKeys == item.bodyKeys).First();
if (resultItem != null)
{
resultItem.stationCode = item.stationCode;
resultItem.actualEndTime= DateTime.Now;
resultItem.batchNo = item.batchNo;
resultItem.state = (int)EnumOrderBodyStatus.生产中;
resultItem.updateBy = sysWebUser?.Account;
resultItem.updateTime = DateTime.Now;
Context.Updateable(resultItem).AddQueue();
}
}
var resultCount = Context.SaveQueues();
return resultCount > 0 ? response.ResponseSuccess() : response.ResponseError();
});
}
/// <summary>
/// 保存组对结束列表
/// </summary>
/// <returns></returns>
public dynamic SaveTeamEndList(List<bus_workOrder_detail> details)
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var response = new Response();
CutWeldService cutWeldService = new CutWeldService();
foreach (var item in details)
{
var resultItem = Context.Queryable<bus_workOrder_detail>().Where(x => x.bodyKeys == item.bodyKeys).First();
if (resultItem != null)
{
resultItem.state = (int)EnumOrderBodyStatus.已完成;
resultItem.actualEndTime = DateTime.Now;
resultItem.updateBy = sysWebUser?.Account;
resultItem.updateTime = DateTime.Now;
Context.Updateable(resultItem).AddQueue();
var result = Context.Queryable<bus_workOrder_detail>().Where(x =>
x.barCode == resultItem.barCode &&
x.weldNo == resultItem.weldNo &&
x.workCenterCode == EnumoprSequenceCode.焊接).First();
if (result != null)
{
result.state= (int)EnumOrderBodyStatus.运输中;
result.batchNo = resultItem.batchNo;
result.updateBy = sysWebUser?.Account;
result.updateTime = DateTime.Now;
Context.Updateable(result).AddQueue();
}
}
//工序完工反馈
cutWeldService.SendIWPTechnologylineProcess(resultItem.barCode, (int)EnumCutHeadState.组对完成);
}
var resultCount = Context.SaveQueues();
return resultCount > 0 ? response.ResponseSuccess() : response.ResponseError();
});
}
/// <summary>
/// 获取匹配的焊接信息
/// </summary>
/// <param name="pipe">管段码</param>
/// <param name="batch">批次码</param>
/// <returns></returns>
public dynamic GetMatchWeldList(string pipe)
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var response = new Response();
if (string.IsNullOrWhiteSpace(pipe))
{
response.ResponseErr($"管段码【{pipe}】是空,请重新扫描管段码!");
return response;
}
var resultDetail = Context.Queryable<bus_workOrder_detail>().Where(x =>
x.barCode.Equals(pipe) &&
x.state == (int)EnumOrderBodyStatus.初始化 &&
x.workCenterCode == EnumoprSequenceCode.焊接 &&
!string.IsNullOrEmpty(x.batchNo)).ToList();
bus_workOrder_head result = null;
if (resultDetail.Count > 0)
{
var material = Context.Queryable<base_material>().Where(x =>
x.materialCode.Equals(resultDetail[0].cutMaterCode)).First();
result = Context.Queryable<bus_workOrder_head>().Where(x => x.keys == resultDetail[0].headKeys).First();
if (material != null)
{
result.types = material.types;
result.diameter = material.diameter;
result.thickness = material.thickness;
}
result.teamList = resultDetail;
}
response.Result = result;
return response;
});
}
/// <summary>
/// 获取焊接开始列表
/// </summary>
/// <returns></returns>
public dynamic GetWeldStartList()
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var response = new Response();
var resultDetail = Context.Queryable<bus_workOrder_detail>().Where(x =>
(x.state > (int)EnumOrderBodyStatus.初始化 && x.state < (int)EnumOrderBodyStatus.已完成) &&
x.workCenterCode == EnumoprSequenceCode.焊接).ToList();
var headKeyList = Context.Queryable<bus_workOrder_detail>().Where(x =>
(x.state > (int)EnumOrderBodyStatus.初始化 && x.state < (int)EnumOrderBodyStatus.已完成) &&
x.workCenterCode == EnumoprSequenceCode.焊接).GroupBy(x => x.headKeys).Select(x => x.headKeys).ToList();
List<bus_workOrder_head> result = new List<bus_workOrder_head>();
foreach (var key in headKeyList)
{
var item = Context.Queryable<bus_workOrder_head>().Where(x => x.keys == key).First();
item.teamList = new List<bus_workOrder_detail>();
foreach (var detail in resultDetail)
{
if (detail.headKeys == key)
{
item.teamList.Add(detail);
}
}
result.Add(item);
}
response.Result = result;
return response;
});
}
/// <summary>
/// 保存焊接开始列表
/// </summary>
/// <returns></returns>
public dynamic SaveWeldStartList(List<bus_workOrder_detail> details)
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var response = new Response();
foreach (var item in details)
{
var resultItem = Context.Queryable<bus_workOrder_detail>().Where(x => x.bodyKeys == item.bodyKeys).First();
if (resultItem != null)
{
resultItem.stationCode = item.stationCode;
resultItem.actualStartTime = DateTime.Now;
resultItem.state = (int)EnumOrderBodyStatus.生产中;
resultItem.updateBy = sysWebUser?.Account;
resultItem.updateTime = DateTime.Now;
Context.Updateable(resultItem).AddQueue();
}
}
var resultCount = Context.SaveQueues();
return resultCount > 0 ? response.ResponseSuccess() : response.ResponseError();
});
}
/// <summary>
/// 保存焊接结束列表
/// </summary>
/// <returns></returns>
public dynamic SaveWeldEndList(List<bus_workOrder_detail> details)
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var response = new Response();
CutWeldService cutWeldService = new CutWeldService();
foreach (var item in details)
{
var resultItem = Context.Queryable<bus_workOrder_detail>().Where(x => x.bodyKeys == item.bodyKeys).First();
if (resultItem != null)
{
resultItem.state = (int)EnumOrderBodyStatus.已完成;
resultItem.actualEndTime = DateTime.Now;
resultItem.updateBy = sysWebUser?.Account;
resultItem.updateTime = DateTime.Now;
Context.Updateable(resultItem).AddQueue();
}
//工序完工反馈
cutWeldService.SendIWPTechnologylineProcess(resultItem.barCode, (int)EnumCutHeadState.焊接完成);
}
var resultCount = Context.SaveQueues();
return resultCount > 0 ? response.ResponseSuccess() : response.ResponseError();
});
}
/// <summary>
/// 焊接工艺下发保存
/// </summary>
/// <param name="equipmentCode">设备编码</param>
/// <param name="barCode">管段码</param>
/// <returns></returns>
public dynamic SaveWeldTechnology(string equipmentCode, string barCode)
{
var response = new Response();
return ExceptionsHelp.Instance.ExecuteT(() =>
{
if (string.IsNullOrWhiteSpace(equipmentCode) || string.IsNullOrWhiteSpace(barCode))
{
return response.ResponseError($"设备编码或管段码为空,请重新扫描!");
}
//设备信息
var equipment = base.Context.Queryable<base_equipment>().Where(x => x.code == equipmentCode).First();
if (equipment == null)
{
return response.ResponseError($"设备编码{equipmentCode}在设备表中没有找到!");
}
//工序任务明细
var resultItem = base.Context.Queryable<bus_workOrder_detail>().Where(x => x.barCode == barCode).First();
if (equipment == null)
{
return response.ResponseError($"barCode:【{barCode}】不存在工序任务明细表中,请核对!");
}
//物料信息
var material = base.Context.Queryable<base_material>().Where(x => x.materialCode == resultItem.cutMaterCode).First();
if (equipment == null)
{
return response.ResponseError($"barCode:【{barCode}】对应物料没有信息,请核对!");
}
//焊接工艺参数
var Equipment = new base_weld_technology_equipment()
{
technologyHeadId = 0,
equipmentCode = equipmentCode,
createBy = sysWebUser?.Account,
createTime = DateTime.Now.ToString(),
sendStatus = 0,
minDiameter = material.diameter,
minThickness = material.thickness,
minWeldingSeam = "0",
material = material.types
};
switch (Equipment.material)
{
case "碳钢": Equipment.material = "1"; break;
case "不锈钢": Equipment.material = "2"; break;
case "合金钢": Equipment.material = "3"; break;
case "多重钢": Equipment.material = "4"; break;
default: Equipment.material = "0"; break;
}
response.Status = Add(Equipment);
response.Message = $"设备({equipment.name})焊接参数下发成功!";
return response;
});
}
/// <summary>
/// 批次码获取物料信息
/// </summary>
/// <param name="lotNo">批次码</param>
/// <returns></returns>
public dynamic GetMaterialBylotNo(string lotNo)
{
var response = new Response();
return ExceptionsHelp.Instance.ExecuteT(() =>
{
if (string.IsNullOrWhiteSpace(lotNo))
{
return response.ResponseError($"批次码为空,请重新扫描!");
}
//调用上游接口查询批次码对应的物料码
//物料信息
var material = base.Context.Queryable<base_material>().Where(x => x.materialCode == lotNo).First();
if (material == null)
{
return response.ResponseError($"批次码{lotNo}在系统表中没有找到对应的物料信息!");
}
response.Result = material;
return response;
});
}
/// <summary>
/// 设备编码获取设备信息
/// </summary>
/// <param name="equipmentCode">设备编码</param>
/// <returns></returns>
public dynamic GetEquipmentByCode(string equipmentCode)
{
var response = new Response();
return ExceptionsHelp.Instance.ExecuteT(() =>
{
if (string.IsNullOrWhiteSpace(equipmentCode))
{
return response.ResponseError($"设备编码为空,请重新扫描!");
}
//设备信息
var equipment = base.Context.Queryable<base_equipment>().Where(x => x.code == equipmentCode).First();
if (equipment == null)
{
return response.ResponseError($"设备编码{equipmentCode}没有找到对应的设备信息!");
}
//获取焊接类型ID
var equipmentType= base.Context.Queryable<base_equipment_type>().Where(x => x.code == EnumoprSequenceCode.焊接).First();
if (equipmentType == null)
{
return response.ResponseError($"焊接类型在系统中未配置!");
}
//判断设备是否为焊机,只有焊机可以呼叫AGV
if (equipment.equipmentTypeId != equipmentType.id)
{
return response.ResponseError($"只有焊机工位可以呼叫AGV!");
}
//AGV呼叫记录
var agvCalllog = base.Context.Queryable<bus_agvCall_log>().Where(x => x.callState == (int)EnumAgvCallState.接料中).First();
if (agvCalllog != null)
{
equipment.callState = (int)EnumAgvCallState.接料中;
equipment.equipmentNmae = agvCalllog.equipmentNmae;
}
else {
equipment.callState = (int)EnumAgvCallState.初始;
equipment.equipmentNmae = "无";
}
response.Result = equipment;
return response;
});
}
/// <summary>
/// Agv接料完成
/// </summary>
/// <param name="equipmentCode">设备编码</param>
/// <returns></returns>
public dynamic AgvCollectingEnd(string equipmentCode)
{
var response = new Response();
return ExceptionsHelp.Instance.ExecuteT(() =>
{
if (string.IsNullOrWhiteSpace(equipmentCode))
{
return response.ResponseError($"设备编码为空,请重新扫描!");
}
//设备信息
var equipment = base.Context.Queryable<base_equipment>().Where(x => x.code == equipmentCode).First();
if (equipment == null)
{
return response.ResponseError($"设备编码{equipmentCode}没有找到对应的设备信息!");
}
//获取焊接类型ID
var equipmentType = base.Context.Queryable<base_equipment_type>().Where(x => x.code == EnumoprSequenceCode.焊接).First();
if (equipmentType == null)
{
return response.ResponseError($"焊接类型在系统中未配置!");
}
//判断设备是否为焊机,只有焊机可以呼叫AGV
if (equipment.equipmentTypeId != equipmentType.id)
{
return response.ResponseError($"只有焊机工位可以呼叫AGV!");
}
//AGV呼叫记录
var agvCalllog = base.Context.Queryable<bus_agvCall_log>().Where(x => x.callState == (int)EnumAgvCallState.接料中).First();
if (agvCalllog == null)
{
return response.ResponseError($"AGV没有在接料,不能进行此操作!");
}
if (agvCalllog.equipmentCode != equipmentCode) {
return response.ResponseError($"确保误操作与安全,请扫描正在接料的工位,再操作接料完成!");
}
agvCalllog.callState = (int)EnumAgvCallState.接料完成;
agvCalllog.updateTime = DateTime.Now;
base.Context.Updateable(agvCalllog).ExecuteCommand();
response.Result = "";
response.Message= "AGV接料完成操作成功!";
return response;
});
}
/// <summary>
/// 呼叫Agv接料
/// </summary>
/// <param name="equipmentCode">设备编码</param>
/// <returns></returns>
public dynamic AgvCollectingStart(string equipmentCode)
{
var response = new Response();
return ExceptionsHelp.Instance.ExecuteT(() =>
{
if (string.IsNullOrWhiteSpace(equipmentCode))
{
return response.ResponseError($"设备编码为空,请重新扫描!");
}
//设备信息
var equipment = base.Context.Queryable<base_equipment>().Where(x => x.code == equipmentCode).First();
if (equipment == null)
{
return response.ResponseError($"设备编码{equipmentCode}没有找到对应的设备信息!");
}
//获取焊接类型ID
var equipmentType = base.Context.Queryable<base_equipment_type>().Where(x => x.code == EnumoprSequenceCode.焊接).First();
if (equipmentType == null)
{
return response.ResponseError($"焊接类型在系统中未配置!");
}
//判断设备是否为焊机,只有焊机可以呼叫AGV
if (equipment.equipmentTypeId != equipmentType.id)
{
return response.ResponseError($"只有焊机工位可以呼叫AGV!");
}
//AGV呼叫记录
var agvCalllog = base.Context.Queryable<bus_agvCall_log>().Where(x => x.callState == (int)EnumAgvCallState.接料中).First();
if (agvCalllog != null)
{
return response.ResponseError($"AGV正在{agvCalllog.equipmentNmae}接料,不能呼叫!");
}
var requestData = new
{
stationCode = equipmentCode,
userCode = ""
};
//发送WMS-AGV接料 url = "http://172.16.29.881:9100/api/WMS/CallEmptyContainer";
var url = GetDictionaryDictValue("UrlWCSCallEmptyContainer", "GetUrl");
var WCSresponse = HttpManWCS(url, requestData, EnumLog.WCS接口调用.ToString(), method: "post");
if (WCSresponse.Code == 200)
{
var busAgvCalllog = new bus_agvCall_log();
busAgvCalllog.equipmentNmae = equipment.name;
busAgvCalllog.equipmentCode = equipment.code;
busAgvCalllog.callState = (int)EnumAgvCallState.接料中;
busAgvCalllog.createTime = DateTime.Now;
base.Context.Insertable(busAgvCalllog).ExecuteCommand();
response.Result = "";
response.Message = "呼叫AGV接料成功!";
return response;
}
else
{
//var WcsResult = DynamicJson.Parse(WCSresponse.Result);
return response.ResponseError($"呼叫AGV接料失败!{WCSresponse.Result}");
}
});
}
/// <summary>
/// 托盘入库
/// </summary>
/// <param name="containerCode">托盘码</param>
/// <returns></returns>
public dynamic ContainerTransfer(string containerCode)
{
var response = new Response();
return ExceptionsHelp.Instance.ExecuteT(() =>
{
if (string.IsNullOrWhiteSpace(containerCode))
{
return response.ResponseError($"托盘码为空,请重新扫描!");
}
//AGV呼叫记录
var agvCalllog = base.Context.Queryable<bus_agvCall_log>().Where(x => x.callState == (int)EnumAgvCallState.接料中).First();
if (agvCalllog != null)
{
return response.ResponseError($"AGV正在{agvCalllog.equipmentNmae}接料,不能回库,需要先完成agv接料状态!");
}
var requestData = new
{
containerCode = containerCode,
inLocationCode = ""
};
//发送WMS-托盘入库 url = "http://10.193.244.156:8066/api/WMS/ContainerTransfer";
var url = GetDictionaryDictValue("UrlWCSContainerTransfer", "GetUrl");
var WCSresponse = HttpManWCS(url, requestData, EnumLog.WCS接口调用.ToString(), method: "post");
if (WCSresponse.Code == 200)
{
response.Result = "";
response.Message = "托盘入库成功!";
return response;
}
else
{
return response.ResponseError($"托盘入库失败!{WCSresponse.Result}");
}
});
}
#endregion
}
}