wxw
2025-04-24 3e19792c0061879ebe17ea04264c4c1f86bb3504
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
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Model.InterFaceModel;
using Newtonsoft.Json;
using System;
using System.IO;
using System.Security.Claims;
using Utility.Tools;
using WMS.BLL.LogServer;
using WMS.IBLL.IBllAsnServer;
using WMS.IBLL.IBllCheckServer;
using WMS.IBLL.IBllSoServer;
using WMS.IBLL.ILogServer;
using Wms.Tools;
using WMS.Entity.BllTaskEntity;
using WMS.IBLL.IBllTaskServer;
using Model.ModelVm.BllTaskVm;
using static Model.InterFaceModel.RCSModel;
using WMS.IBLL.IBllTransServer;
using Microsoft.Extensions.Logging;
using ZXing.QrCode.Internal;
using Model.ModelVm.BllCheckVm;
using Model.ModelVm.SysVm;
 
namespace Wms.Controllers
{
    /// <summary>
    /// 下游系统交互
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DownApiController : ControllerBase
    {
        private readonly ApiUrlConfig _config; //接口交互路径
        private readonly IExportNoticeServer _exNoticeSvc;//出库单Svc 
        private readonly IPalletBindServer _asnPalletBindSvc;//托盘绑定Svc 
        private readonly IStockCheckServer _crCheckSvc;//托盘绑定Svc 
        private readonly ITaskServer _taskSvc;//任务Svc
        private readonly IBllTaskSyncServer _taskSyncSvc;//任务同步Svc
        private readonly IWaveMageServer _waveSvc;//任务同步Svc
        private readonly IRcsServer _rcsserver;//RCS相关任务
        private readonly INoticeServer _noticeSvc;//二楼单据相关
        private readonly IHopperTransportServer _hopper;//二楼单据相关
        public DownApiController(IOptions<ApiUrlConfig> setting, IExportNoticeServer exNoticeSvc, IPalletBindServer asnPalletBindSvc, IStockCheckServer crCheckSvc, ITaskServer taskSvc, IBllTaskSyncServer taskSyncSvc, IWaveMageServer waveSvc, IRcsServer rcsserver, INoticeServer noticeSvc, IHopperTransportServer hopper)
        {
            _config = setting.Value;
            _exNoticeSvc = exNoticeSvc;
            _asnPalletBindSvc = asnPalletBindSvc;
            _crCheckSvc = crCheckSvc;
            _taskSvc = taskSvc;
            _taskSyncSvc = taskSyncSvc;
            _waveSvc = waveSvc;
            _rcsserver = rcsserver;
            _noticeSvc = noticeSvc;
            _hopper = hopper;
        }
 
        #region WMS接口 调用下游系统接口 
 
        /// <summary>
        /// 指令下发(波次出库)
        /// </summary>
        /// <param name="unstackingMode">拆垛方式</param>
        /// <param name="waveNo">出库单号</param>
        /// <param name="outMode">出库口</param>
        /// <param name="loadingAddre">装车口</param>
        /// <returns></returns>
        [Authorize]
        [HttpGet]
        public IActionResult WaveIssueOutHouse(string waveNo, string unstackingMode, string outMode, string loadingAddre)
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                //验证出库口
                //if (string.IsNullOrWhiteSpace(outMode))
                //{
                //    return Ok(new { code = 1, msg = "请选择出库口" });
                //}
 
                var list = _waveSvc.WaveIssueOutHouse(waveNo, unstackingMode, outMode, loadingAddre, int.Parse(userId), _config.WcsHost + _config.IssueComApiUrl, out string str);
 
                return Ok(new { code = 0, msg = str, data = list });
 
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
 
        /// <summary>
        /// 指令下发(出库)
        /// </summary>
        /// <param name="unstackingMode">拆垛方式</param>
        /// <param name="soNo">出库单号</param>
        /// <param name="outMode">出库口</param>
        /// <param name="loadingAddre">装车口</param>
        /// <returns></returns>
        [Authorize]
        [HttpGet]
        public IActionResult IssueOutHouse(string soNo,string unstackingMode, string outMode,string loadingAddre)
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                //验证出库口
                //if (string.IsNullOrWhiteSpace(outMode))
                //{
                //    return Ok(new { code = 1, msg = "请选择出库口" });
                //}
 
                var list = _exNoticeSvc.IssueOutHouse(soNo,unstackingMode, outMode,loadingAddre, int.Parse(userId), _config.WcsHost + _config.IssueComApiUrl,out string str);
                
                return Ok(new { code = 0, msg = str , data = list }); 
                
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
 
 
        /// <summary>
        /// 重新下发出库任务
        /// </summary>
        /// <param name="taskNo"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult AgainSendSoTask(string taskNo)
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var list = _exNoticeSvc.AgainSendSoTask(taskNo, int.Parse(userId),_config.WcsHost + _config.IssueComApiUrl2);
               
                return Ok(new { code = 0, msg = "重新下发已完成", data = list });
 
 
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
 
        /// <summary>
        /// 指令下发(盘点出库)
        /// </summary>
        /// <param name="crNo"></param>
        /// <param name="outMode"></param>
        /// <returns></returns>
        [Authorize]
        [HttpGet]
        public IActionResult CheckOutHouse(string crNo,string outMode)
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
 
                var list = _crCheckSvc.CheckOutHouse(crNo, outMode,int.Parse(userId), _config.WcsHost + _config.IssueComApiUrl, out string str);
 
                return Ok(new { code = 0, msg = str, data = list });
 
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
 
        /// <summary>
        /// 重新下发盘点任务
        /// </summary>
        /// <param name="taskNo"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult AgainSendCheckTask(string taskNo)
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                _crCheckSvc.AgainSendCheckTask(taskNo, int.Parse(userId), _config.WcsHost + _config.IssueComApiUrl2);
 
                return Ok(new { code = 0, msg = "重新下发已完成", data = "" });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
 
        #endregion
 
        #region WMS接口 被下游系统接口调用
 
        /// <summary>
        /// 绑定信息返回巷道口
        /// </summary>
        /// <param name="model">入库单信息</param>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpPost]
        public IActionResult BindRequestRoadWay(BoxPalletBindVm model)
        {
            var logStr = $@".\log\WCS\WCS托盘绑定-申请巷道" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
 
            try
            {
 
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"WCS托盘绑定-申请巷道:( {jsonData} ),", logStr);
 
                 _asnPalletBindSvc.BindPalletStock(model, 0);
                //申请巷道
                var list = _asnPalletBindSvc.RequestRoadWay(model.PalletNo, "W01");
                LogFile.SaveLogToFile($"WCS托盘绑定-申请巷道返回:( {JsonConvert.SerializeObject(list)} ),", logStr);
                
                return Ok(new { Success = 0, Message = "托盘绑定-申请巷道成功", TaskList = list });
            }
            catch (Exception e)
            {
                LogFile.SaveLogToFile($"WCS托盘绑定-申请巷道返回:( {e.Message} ),", logStr);
                
                return Ok(new ErpModel { Success = -1, Message = e.Message });
            }
        }
 
 
        /// <summary>
        /// 申请巷道
        /// </summary>
        /// <param name="model">入库单信息</param>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpPost]
        public IActionResult RequestRoadWay(RequestLocate model)
        {
            var logStr = "";
            
            logStr = $@".\log\WCS\WCS申请巷道" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            
            try
            {
                 
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"WCS申请巷道:( {jsonData} ),", logStr);
                
                var list = _asnPalletBindSvc.RequestRoadWay(model.PalletNo, model.HouseNo );
 
                LogFile.SaveLogToFile($"WCS申请巷道返回:( {JsonConvert.SerializeObject(list)} ),", logStr);
                //new OperationASNServer().AddLogOperationAsn("入库作业", "入库日志", model.PalletNo.Substring(0, 8), 
                //    "申请巷道", $"申请巷道托盘号:{model.PalletNo.Substring(0, 8)}的成功信息", 2);
 
                return Ok(new { Success = 0, Message = "申请巷道成功", TaskList = list });
            }
            catch (Exception e)
            {
                LogFile.SaveLogToFile($"WCS申请巷道返回:( {e.Message} ),", logStr);
                //new OperationASNServer().AddLogOperationAsn("入库作业", "入库日志", model.PalletNo.Substring(0, 8),
                //"申请巷道", $"申请巷道托盘号:{model.PalletNo.Substring(0, 8)}的失败信息", 2);
 
                return Ok(new ErpModel { Success = -1, Message = e.Message });
            }
        }
 
        /// <summary>
        /// 申请储位
        /// </summary>
        /// <param name="model">入库单信息</param>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpPost]
        public IActionResult RequestLocation(RequestLocate model)
        {
 
            //获取当前登录的用户ID
            //var claimsIdentity = this.User.Identity as ClaimsIdentity;
            //if (claimsIdentity == null)
            //{
            //    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
            //}
            //var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
            //if (string.IsNullOrWhiteSpace(userId))
            //{
            //    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
            //}
 
            //string palletno = model.PalletNo;
            var logStr = "";
            if (model.PalletNo.Length == 9)
            {
                logStr = $@".\log\WCS\WMS申请储位" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            }
            else if (model.PalletNo.Length == 8)
            {
                logStr = $@".\log\WCS\WCS申请储位" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            }
            
            try
            {
                if (model.PalletNo.Length == 9)
                {
                    var jsonData = JsonConvert.SerializeObject(model);
                    LogFile.SaveLogToFile($"WMS申请储位:( {jsonData} ),", logStr);
                }
                else if (model.PalletNo.Length == 8)
                {
                    var jsonData = JsonConvert.SerializeObject(model);
                    LogFile.SaveLogToFile($"WCS申请储位:( {jsonData} ),", logStr);
                }
 
                string pallet = model.PalletNo.Substring(0, 8);
                var list = _asnPalletBindSvc.RequestLocation(pallet, model.HouseNo,model.RoadwayNo);
 
                if (model.PalletNo.Length == 9)
                {
                    new OperationASNServer().AddLogOperationAsn("入库作业", "入库日志", model.PalletNo.Substring(0, 8), "申请储位", $"申请储位托盘号:{model.PalletNo.Substring(0, 8)}的成功信息",2);// int.Parse(userId)
                    LogFile.SaveLogToFile($"WMS申请储位成功:( {JsonConvert.SerializeObject(list)} ),", logStr);
                }
                else if (model.PalletNo.Length == 8)
                {
                    LogFile.SaveLogToFile($"WCS申请储位返回:( {JsonConvert.SerializeObject(list)} ),", logStr);
                }
                if (model.PalletNo.Length == 9)
                {
                   
                }
 
                return Ok(new { Success = 0, Message = "申请储位成功", TaskList = list });
            }
            catch (Exception e)
            {
                if (model.PalletNo.Length == 9)
                {
                    new OperationASNServer().AddLogOperationAsn("入库作业", "入库日志", model.PalletNo.Substring(0, 8), "申请储位", $"申请储位托盘号:{model.PalletNo.Substring(0,8)}的失败信息", 2);//int.Parse(userId)
                    LogFile.SaveLogToFile($"WMS申请储位失败返回:( {e.Message} ),", logStr);
                }
                else if(model.PalletNo.Length == 8)
                {
                    LogFile.SaveLogToFile($"WCS申请储位返回:( {e.Message} ),", logStr);
                }
                
                return Ok(new ErpModel { Success = -1, Message = e.Message });
            }
        }
 
        /// <summary>
        /// 接受wcs返回的信号 //指令反馈(是否完成)
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ReceiveWcsSignal(ReceiveWcsSignal model)
        {
            try
            {
                //记录log
                var logStr = $@".\log\WCS\任务反馈" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"任务反馈:( {jsonData} ),", logStr);
 
                if (string.IsNullOrEmpty(model.TaskNo) || string.IsNullOrEmpty(model.TaskStatus) || string.IsNullOrEmpty(model.TaskType))
                {
                    return Ok(new WcsModel { StatusCode = -1, Msg = "接口数据不正确" });
                }
                //接收时间
                var time1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                var orderType = _taskSvc.GetTaskOrderType(model.TaskNo);// 判断单据类型入出移
                switch (orderType)
                {
                    case "0"://入库完成任务
                        if (model.TaskType == "0")//0:入库 1:出库 2:移库
                        {
                            _asnPalletBindSvc.ArrivalSuccess(model.TaskNo,0);
                            return Ok(new WcsModel { StatusCode = 0, Msg = "入库完成" });
                        }
                        break;
                    case "1"://出库完成任务
                        if (model.TaskType == "1")//0:入库 1:出库 2:移库
                        {
                            _exNoticeSvc.ExportSuccess(model.TaskNo,0);
                            return Ok(new WcsModel { StatusCode = 0, Msg = "出库完成" });
                        }
                        else if (model.TaskType == "2")
                        {
                            _exNoticeSvc.RelocationSuccess(model.TaskNo, 0);
                            return Ok(new WcsModel { StatusCode = 0, Msg = "移库完成" });
                        }
                        break;
                    case "2"://盘库完成任务
                        if (model.TaskType == "1")//0:入库 1:出库 3:移库
                        {
                            _crCheckSvc.CheckSuccess(model.TaskNo, 0);
                            return Ok(new WcsModel { StatusCode = 0, Msg = "盘点出库完成" });
                        }
                        else if (model.TaskType == "0")// 盘点出库托盘回库完成
                        {
                            _asnPalletBindSvc.ArrivalSuccess(model.TaskNo, 0);
                            return Ok(new WcsModel { StatusCode = 0, Msg = "入库完成" });
                        }
                        break;
                    case "3"://移库完成任务、优化储位
                        if (model.TaskType == "3") //0:入库 1:出库 3:移库
                        {
                            //填写移库完成代码
                        }
                        break;
                    default :
                        return Ok(new WcsModel { StatusCode = -1, Msg = "传递的任务状态为失败状态" });  
                }
                return Ok(new WcsModel { StatusCode = -1, Msg = "传递的任务状态为失败状态" });
            }
            catch (Exception ex)
            {
                return Ok(new WcsModel { StatusCode = -1, Msg = ex.Message });
            }
        }
 
 
        /// <summary>
        /// 空取异常
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult EmptyException(ReceiveWcsSignal model) 
        {
            var logStr = $@".\log\WCS\异常反馈" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            try
            {
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"空取异常:( {jsonData} ),", logStr);
 
                var bl = _exNoticeSvc.EmptyException(model);
 
                LogFile.SaveLogToFile($"空取异常:(执行结果成功),", logStr);
                return Ok(new { Success = 0, Message = ""});
            }
            catch (Exception e)
            {
                LogFile.SaveLogToFile($"空取异常:( {e.Message} ),", logStr);
                return Ok(new ErpModel { Success = -1, Message = e.Message });
            }
        }
 
        /// <summary>
        /// 满入异常
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult FullException(ReceiveWcsSignal model) 
        {
            var logStr = $@".\log\WCS\异常反馈" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            try
            {
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"满入异常:( {jsonData} ),", logStr);
 
                var list = _asnPalletBindSvc.FullException(model);
 
                LogFile.SaveLogToFile($"满入异常:( {JsonConvert.SerializeObject(list)} ),", logStr);
                return Ok(new { Success = 0, Message = "", TaskList = list });
            }
            catch (Exception e)
            {
                LogFile.SaveLogToFile($"满入异常:( {e.Message} ),", logStr);
                return Ok(new ErpModel { Success = -1, Message = e.Message });
            }
        }
 
        //每日清空日志
        [HttpPost]
        public IActionResult DeleteNlogFile()
        {
            try
            {
                string[] files = null;
                try
                {
                    files = Directory.GetFiles(_config.GetLog1);
                }
                catch
                {
                    try
                    {
                        files = Directory.GetFiles(_config.GetLog2);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
                finally
                {
                    foreach (string file in files)
                    {
                        FileInfo fi = new FileInfo(file);
                        if (fi.LastWriteTime < DateTime.Now.AddMonths(-1))
                        {
                            fi.Delete();
                        }
                    }
                }
 
                return Ok(new
                {
                    msg = "成功清除"
                });
            }
            catch (Exception ex)
            {
 
                throw new Exception(ex.Message);
            }
        }
 
        //托盘箱码信息 自动码垛 (wcs提供)
 
        //申请空托(自动码空托时用)
 
        //agv返回信息(任务是否完成)
        /// <summary>
        /// 接受agv返回的信号 //指令反馈(是否完成)
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ReceiveAgvSignal(ReceiveWcsSignal model)
        {
            try
            {
                //记录log
                var logStr = $@".\log\AGV\任务反馈" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"任务反馈:( {jsonData} ),", logStr);
 
                if (string.IsNullOrEmpty(model.TaskNo) || string.IsNullOrEmpty(model.TaskStatus) || string.IsNullOrEmpty(model.TaskType))
                {
                    return Ok(new WcsModel { StatusCode = -1, Msg = "接口数据不正确" });
                }
                //接收时间
                var time1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                var orderType = _taskSvc.GetTaskOrderType(model.TaskNo);// 判断单据类型入出移
                switch (orderType)
                {
                   
                    case "1"://出库完成任务
                        if (model.TaskType == "1")//0:入库 1:出库 2:移库
                        {
                            _exNoticeSvc.ExportSuccessAGV(model.TaskNo, 0);
                            return Ok(new WcsModel { StatusCode = 0, Msg = "出库完成" });
                        }
                        else
                        {
                            return Ok(new WcsModel { StatusCode = -1, Msg = "传递的任务类型不是出库类型" });
                        }
                    default:
                        return Ok(new WcsModel { StatusCode = -1, Msg = "传递的任务状态为失败状态" });
                }
            }
            catch (Exception ex)
            {
                return Ok(new WcsModel { StatusCode = -1, Msg = ex.Message });
            }
        }
 
 
 
        /// <summary>
        /// 接收同步任务信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ReceiveWCSTaskSync(TaskSyncInfoVm model)
        {
            try
            {
                //记录log
                var logStr = $@".\log\WCS\任务同步" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"任务同步:( {jsonData} ),", logStr);
 
                if (string.IsNullOrEmpty(model.TaskNo) || string.IsNullOrEmpty(model.StartLocat) || string.IsNullOrEmpty(model.EndLocat) || string.IsNullOrEmpty(model.PalletNo))
                {
                    return Ok(new WcsModel { StatusCode = -1, Msg = "接口数据不正确" });
                }
                _taskSyncSvc.ReceiveWCSTaskSync(model);
                return Ok(new WcsModel { StatusCode = 0, Msg = "同步完成" });
            }
            catch (Exception ex)
            {
                return Ok(new WcsModel { StatusCode = -1, Msg = ex.Message });
            }
        }
        #endregion
 
        #region 二楼业务
        /// <summary>
        /// RCS叫桶
        /// </summary>
        /// <param name="pallmsg"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetPalletNo(Pallnetmsg pallmsg)
        {
            var logStr = $@".\log\AGV\AGV申请叫桶" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            AgvResultModel resultModel = null;//返回信息
            try
            {
                var jsonData = JsonConvert.SerializeObject(pallmsg);
                LogFile.SaveLogToFile($"AGV申请叫桶-请求报文:( {jsonData} ),", logStr);
 
                if (string.IsNullOrWhiteSpace(pallmsg.Location))
                {
                    resultModel = new AgvResultModel { code = "1", message = "叫料位置为空!", data = "", reqCode = "" };
                    var jsonData3 = JsonConvert.SerializeObject(resultModel);
                    LogFile.SaveLogToFile($"AGV申请叫桶-返回报文:( {jsonData3} ),", logStr);
                    return Ok(resultModel);
                }
                if (string.IsNullOrWhiteSpace(pallmsg.Type))
                {
                    resultModel = new AgvResultModel { code = "1", message = "任务类型为空!", data = "", reqCode = "" };
                    var jsonData4 = JsonConvert.SerializeObject(resultModel);
                    LogFile.SaveLogToFile($"AGV申请叫桶-返回报文:( {jsonData4} ),", logStr);
                    return Ok(resultModel);
                }
                string taskNo = "";
                //具体处理方法
                _rcsserver.GetPalletNo(pallmsg, _config.AgvHost + _config.GenAgvSchedulingTask, out taskNo);
 
                resultModel = new AgvResultModel { code = "0", message = "叫桶成功!", data = taskNo, reqCode = "" };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV申请叫桶-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
            catch (Exception e)
            {
                LogFile.SaveLogToFile($"AGV申请叫桶异常:( {e.Message} ),", logStr);
 
                resultModel = new AgvResultModel { code = "1", message = e.Message, data = "", reqCode = "" };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV申请叫桶-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
        }
 
        /// <summary>
        /// RCS申请储位
        /// </summary>
        /// <param name="pallmsg"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ApplyLocatNo(Pallnetmsg pallmsg)
        {
            var logStr = $@".\log\AGV\AGV申请储位" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            AgvResultModel resultModel = null;//返回信息
            try
            {
                var jsonData = JsonConvert.SerializeObject(pallmsg);
                LogFile.SaveLogToFile($"AGV申请储位-请求报文:( {jsonData} ),", logStr);
 
                if (string.IsNullOrWhiteSpace(pallmsg.Location))
                {
                    resultModel = new AgvResultModel { code = "1", message = "申请位置为空!", data = "", reqCode = "" };
                    var jsonData3 = JsonConvert.SerializeObject(resultModel);
                    LogFile.SaveLogToFile($"AGV申请储位-返回报文:( {jsonData3} ),", logStr);
                    return Ok(resultModel);
                }
                if (string.IsNullOrWhiteSpace(pallmsg.Type))
                {
                    resultModel = new AgvResultModel { code = "1", message = "任务类型为空!", data = "", reqCode = "" };
                    var jsonData3 = JsonConvert.SerializeObject(resultModel);
                    LogFile.SaveLogToFile($"AGV申请储位-返回报文:( {jsonData3} ),", logStr);
                    return Ok(resultModel);
                }
                //if (string.IsNullOrWhiteSpace(pallmsg.PalletNo))
                //{
                //    resultModel = new AgvResultModel { code = "1", message = "申请桶号为空!", data = "", reqCode = "" };
                //    var jsonData3 = JsonConvert.SerializeObject(resultModel);
                //    LogFile.SaveLogToFile($"AGV申请储位-返回报文:( {jsonData3} ),", logStr);
                //    return Ok(resultModel);
                //}
                string taskNo = "";
                //具体处理方法
                _rcsserver.ApplyLocatNo(pallmsg, _config.AgvHost + _config.GenAgvSchedulingTask, out taskNo);
 
                resultModel = new AgvResultModel { code = "0", message = "申请储位成功!", data = taskNo, reqCode = "" };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV申请储位-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
            catch (Exception e)
            {
                LogFile.SaveLogToFile($"AGV申请储位异常:( {e.Message} ),", logStr);
 
                resultModel = new AgvResultModel { code = "1", message = e.Message, data = "", reqCode = "" };
                var jsonData3 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV申请储位-返回报文:( {jsonData3} ),", logStr);
                return Ok(resultModel);
            }
        }
        /// <summary>
        /// 将净桶改为脏桶并拉到脏桶区
        /// </summary>
        /// <param name="pallmsg"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ChangePalletStatus(Pallnetmsg pallmsg)
        {
            var result = new ErpModel { Success = -1, Message = "", };
            try
            {
                if (string.IsNullOrWhiteSpace(pallmsg.PalletNo))
                {
                    result.Message = "桶编号不能为空!";
                    return Ok(result);
                }
                _rcsserver.ChangePalletStatus(pallmsg.PalletNo, _config.AgvHost + _config.GenAgvSchedulingTask);
                result.Success = 0;
                result.Message = "操作成功!";
                return Ok(result);
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                return Ok(result);
            }
        }
 
        /// <summary>
        /// MES下发清洗锁定脏桶
        /// </summary>
        /// <param name="pallmsg"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult CleanPallet(Pallnetmsg pallmsg)
        {
            var result = new ErpModel { Success = -1, Message = "", };
            try
            {
                if (string.IsNullOrWhiteSpace(pallmsg.Location))
                {
                    result.Message = "叫料位置为空!";
                    return Ok(result);
                }
                if (string.IsNullOrWhiteSpace(pallmsg.PalletNo))
                {
                    result.Message = "桶号为空!";
                    return Ok(result);
                }
                _rcsserver.CleanPallet(pallmsg, _config.AgvHost + _config.GenAgvSchedulingTask);
                result.Success = 0;
                result.Message = "叫桶成功!";
                return Ok(result);
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                return Ok(result);
            }
        }
 
        /// <summary>
        /// 入库单据下发
        /// </summary>
        /// <param name="model">入库单信息</param>
        /// <returns></returns>
        //[Authorize]
        [HttpPost]
        public IActionResult CreateAsnWork(AsnInfo model)
        {
            var result = new ErpModel { Success = -1, Message = "" };
            try
            {
                /*var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    throw new Exception("未获取到用户信息");
                }
                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(UserId))
                {
                    throw new Exception("未获取到用户信息");
                }*/
 
                result = _noticeSvc.CreateAsnWork(model);
 
                return Ok(result);
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                return Ok(result);
            }
        }
 
 
        #region Agv任务完成反馈
        /// <summary>
        /// 任务开始
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult start(AgvTaskDto model)
        {
            //记录log
            var logStr = $@".\log\AGV\任务执行通知" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            AgvResultModel resultModel = null;//返回信息
            try
            {
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"AGV任务执行通知-任务开始-请求报文:( {jsonData} ),", logStr);
 
                //具体处理方法
 
 
 
                resultModel = new AgvResultModel { code = "0", message = "成功", reqCode = model.reqCode };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-任务开始-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
            catch (Exception ex)
            {
                LogFile.SaveLogToFile($"AGV任务执行通知-任务开始-异常:( {ex.Message} ),", logStr);
 
                resultModel = new AgvResultModel { code = "1", message = ex.Message, reqCode = model.reqCode };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-任务开始-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
        }
        /// <summary>
        /// 走出储位
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult outbin(AgvTaskDto model)
        {
            //记录log
            var logStr = $@".\log\AGV\任务执行通知" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            AgvResultModel resultModel = null;//返回信息
            try
            {
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"AGV任务执行通知-走出储位-请求报文:( {jsonData} ),", logStr);
 
                //具体处理方法
 
 
 
                resultModel = new AgvResultModel { code = "0", message = "成功", reqCode = model.reqCode };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-走出储位-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
            catch (Exception ex)
            {
                LogFile.SaveLogToFile($"AGV任务执行通知-走出储位-异常:( {ex.Message} ),", logStr);
 
                resultModel = new AgvResultModel { code = "1", message = ex.Message, reqCode = model.reqCode };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-走出储位-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
        }
        /// <summary>
        /// 任务结束
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult end(AgvTaskDto model)
        {
            //记录log
            var logStr = $@".\log\AGV\任务执行通知" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            AgvResultModel resultModel = null;//返回信息
            try
            {
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"AGV任务执行通知-任务结束-请求报文:( {jsonData} ),", logStr);
 
                //具体处理方法
                _rcsserver.RCSFinishTask(model.taskCode, "1", "AGV");
 
 
                resultModel = new AgvResultModel { code = "0", message = "成功", reqCode = model.reqCode };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-任务结束-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
            catch (Exception ex)
            {
                LogFile.SaveLogToFile($"AGV任务执行通知-任务结束-异常:( {ex.Message} ),", logStr);
 
                resultModel = new AgvResultModel { code = "1", message = ex.Message, reqCode = model.reqCode };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-任务结束-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
        }
        /// <summary>
        /// 任务单取消
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult cancel(AgvTaskDto model)
        {
            //记录log
            var logStr = $@".\log\AGV\任务执行通知" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            AgvResultModel resultModel = null;//返回信息
            try
            {
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"AGV任务执行通知-任务单取消-请求报文:( {jsonData} ),", logStr);
 
                //具体处理方法
 
 
 
                resultModel = new AgvResultModel { code = "0", message = "成功", reqCode = model.reqCode };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-任务单取消-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
            catch (Exception ex)
            {
                LogFile.SaveLogToFile($"AGV任务执行通知-任务单取消-异常:( {ex.Message} ),", logStr);
 
                resultModel = new AgvResultModel { code = "1", message = ex.Message, reqCode = model.reqCode };
                var jsonData2 = JsonConvert.SerializeObject(resultModel);
                LogFile.SaveLogToFile($"AGV任务执行通知-任务单取消-返回报文:( {jsonData2} ),", logStr);
                return Ok(resultModel);
            }
        }        
 
        #endregion
 
        /// <summary>
        /// 出库单据下发
        /// </summary>
        /// <param name="model">出库单信息</param>
        /// <returns></returns>
        //[Authorize]
        [HttpPost]
        public IActionResult CreateSoWork(SoInfo model)
        {
            try
            {
                /*var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    throw new Exception("未获取到用户信息");
                }
                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(UserId))
                {
                    throw new Exception("未获取到用户信息");
                }*/
 
                SoResInfo result = _noticeSvc.CreateSoWork(model);
                return Ok(result);
 
            }
            catch (Exception e)
            {
                return Ok(new ErpModel { Success = -1, Message = e.Message });
            }
        }
 
        /// <summary>
        /// 手动下发小车任务
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult SendAgvTaskWms(CheckTaskVm model)
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                _rcsserver.DownTask(model.taskNo, int.Parse(userId), _config.AgvHost + _config.GenAgvSchedulingTask);
 
                return Ok(new { code = 0, msg = "重新下发已完成", data = "" });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
 
        /// <summary>
        /// 手动完成小车任务
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult FinshAgvTaskWms(CheckTaskVm model)
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                //具体处理方法
                _rcsserver.RCSFinishTask(model.taskNo, "1", "WMS");
 
                return Ok(new { code = 0, msg = "重新下发已完成", data = "" });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
 
        /// <summary>
        /// 手动取消AGV移库任务
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult CancelAgvTaskWms(CheckTaskVm model)
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                _rcsserver.CancelTask(model.taskNo, int.Parse(userId));
 
                return Ok(new { code = 0, msg = "成功取消任务", data = "" });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        #endregion
 
        #region JC37 料斗转运3、4楼业务
 
        /// <summary>
        /// 获取区域根据角色
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetAreaListByUser()
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var model = _hopper.GetAreaListByUser(int.Parse(userId));
 
                return Ok(new { data = model, code = 0, msg = "" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = e.Message });
            }
        } 
 
        /// <summary>
        /// 获取储位根据区域
        /// </summary>
        /// <param name="areaNo"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetLocatByArea(string areaNo)
        {
            try
            {
                var model = _hopper.GetLocatByArea(areaNo);
 
                return Ok(new { data = model, code = 0, msg = "" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = e.Message });
            }
        }
 
        /// <summary>
        /// 获取罐类型根据区域
        /// </summary>
        /// <param name="areaNo"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetPlnStatusByArea(string areaNo)
        {
            try
            { 
                var model = _hopper.GetPlnStatusByArea(areaNo);
 
                return Ok(new { data = model, code = 0, msg = "" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = e.Message });
            }
        }
 
        /// <summary>
        /// 获取物料根据罐类型
        /// </summary>
        /// <param name="palletStatus"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetSkuByStatus(string palletStatus)
        {
            try
            {
                var model = _hopper.GetSkuByStatus(palletStatus);
 
                return Ok(new { data = model, code = 0, msg = "" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = e.Message });
            }
        }
 
        /// <summary>
        /// 获取批次根据物料
        /// </summary>
        /// <param name="skuNo"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetLotNoBySku(string skuNo)
        {
            try
            {
                var model = _hopper.GetLotNoBySku(skuNo);
 
                return Ok(new { data = model, code = 0, msg = "" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = e.Message });
            }
        }
 
        /// <summary>
        /// 获取物料
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetSku()
        {
            try
            {
                var model = _hopper.GetSku();
 
                return Ok(new { data = model, code = 0, msg = "" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = e.Message });
            }
        }
 
 
        /// <summary>
        ///  
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult jiaoLiaoHopper(HopperModel model)
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                _hopper.jiaoLiaoHopper(model.AreaNo,model.LocateNo,model.PlnStatus,model.Standard,model.SkuNo,model.LotNo,"", int.Parse(userId));
 
                return Ok(new { data = model, code = 0, msg = "" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = e.Message });
            }
        }
 
        /// <summary>
        ///  
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult jiaoCheHopper(HopperModel model)
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
                }
                _hopper.jiaoCheHopper(model.AreaNo, model.LocateNo,model.PlnNo, model.PlnStatus, model.Weight , model.SkuNo, model.LotNo, int.Parse(userId));
 
                return Ok(new { data = model, code = 0, msg = "" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = e.Message });
            }
        }
 
 
        #endregion
 
    }
}