SServerManager.cs 55.9 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 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 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356
using HalconDotNet;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;

namespace OnlineStore.DeviceLibrary
{
    public class SServerManager
    {
        #region 立臻料仓接口
        static string Addr_getOutStateInfo = "/service/store/innerBox/getOutStateInfo";
        /// <summary>
        /// 根据料仓编号获取料仓两个出料口料箱信息
        /// </summary>
        /// <param name="cid">料仓cid</param>
        /// <returns></returns>
        public static List<BoxTaskInfo> GetOutStateInfo()
        {
            try
            {
                string msg = "";
                Dictionary<string, string> map = new Dictionary<string, string>();
                map.Add("cid", StoreManager.XLRStore.Config.CID);
                string server = GetAddr(Addr_getOutStateInfo, map);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Get(server);
                ServerData4 serverResult = JsonHelper.DeserializeJsonToObject<ServerData4>(resultStr);
                if (serverResult == null)
                {
                    msg = $"GetOutStateInfo" + "没有收到服务器反馈";
                }
                else if (serverResult.code.Equals(0).Equals(false))
                {
                    // code: 0为正常,其他为异常, msg: 消息, data: 为空
                    msg = $" GetOutStateInfo【{JsonHelper.SerializeObject(serverResult)}】";
                    if (!msg.Equals(""))
                    {
                        LogUtil.error(msg);
                        return null;
                    }
                }
                else
                {
                    msg = $" GetOutStateInfo【{JsonHelper.SerializeObject(serverResult)}】";
                    LogUtil.debug(msg);
                    return serverResult.data;
                }

            }
            catch (Exception ex)
            {
                LogUtil.error("GetOutStateInfo", ex);
            }
            return null;
        }
        static string Addr_UploadLocInfo = "/service/store/innerBox/updateLocInfo";
        /// <summary>
        /// A 出库更新任务状态 -OK
        /// </summary>
        /// <param name="barcode">料盘条码</param>
        /// <param name="status"></param>
        /// <returns></returns>
        public static BoxTaskInfo UploadLocInfo(string barcode, string status, string loc = "",string hSerial="",string outlet="",string boxSide="")
        {
            try
            {
                string msg = "";
                Dictionary<string, string> map = new Dictionary<string, string>();
                map.Add("cid", StoreManager.XLRStore.Config.CID);
                map.Add("barcode", barcode);
                map.Add("status", status);
                map.Add("loc", loc);
                map.Add("hSerial", hSerial);
                map.Add("outlet", outlet);
                map.Add("boxSide", boxSide);
                string server = GetAddr(Addr_UploadLocInfo, map);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Get(server);
                ServerData1 serverResult = JsonHelper.DeserializeJsonToObject<ServerData1>(resultStr);
                if (serverResult == null)
                {
                    msg = $"UploadLocInfo【{barcode}】【{status}】" + "没有收到服务器反馈";
                }
                else if (serverResult.code.Equals(0).Equals(false))
                {
                    // code: 0为正常,其他为异常, msg: 消息, data: 为空
                    msg = $"UploadLocInfo 【{barcode}】【{status}】【{JsonHelper.SerializeObject(serverResult)}】";
                    LogUtil.error(msg);
                    return null;

                }
                else
                {
                    msg = $"UploadLocInfo 【{barcode}】【{status}】【{JsonHelper.SerializeObject(serverResult)}】";
                    LogUtil.info(msg);
                    return serverResult.data;
                }

            }
            catch (Exception ex)
            {
                LogUtil.error("UploadLocInfo", ex);
            }
            return null;
        }

        static string Addr_GetBoxStatusInfo = "/service/store/innerBox/getBoxStatusInfo";
        /// <summary>
        /// 获取料箱状态信息
        /// </summary>
        /// <param name="cid"></param>
        /// <param name="status"></param>
        /// <param name="rfid"></param>
        /// <returns></returns>
        public static BoxTaskInfo GetBoxStatusInfo(string cid, string rfid)
        {
            try
            {
                string msg = "";
                Dictionary<string, string> map = new Dictionary<string, string>();
                map.Add("cid", cid);
                map.Add("rfid", rfid);
                string server = GetAddr(Addr_GetBoxStatusInfo, map);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Get(server);
                ServerData1 serverResult = JsonHelper.DeserializeJsonToObject<ServerData1>(resultStr);
                if (serverResult == null)
                {
                    msg = $"GetBoxStatusInfo【{cid}】【{rfid}】" + "没有收到服务器反馈";
                }
                else if (serverResult.code.Equals(0).Equals(false))
                {
                    // code: 0为正常,其他为异常, msg: 消息, data: 为空
                    msg = $" GetBoxStatusInfo 【{cid}】【{rfid}】【{JsonHelper.SerializeObject(serverResult)}】";
                    if (!msg.Equals(""))
                    {
                        LogUtil.error(msg);
                        return null;
                    }
                }
                else
                {
                    msg = $" GetBoxStatusInfo 【{cid}】【{rfid}】【{JsonHelper.SerializeObject(serverResult)}】";
                    LogUtil.debug(msg);
                    return serverResult.data;
                }

            }
            catch (Exception ex)
            {
                LogUtil.error("GetBoxStatusInfo", ex);
            }
            return null;
        }
        static string Addr_boxTakeAway = "/service/store/innerBox/boxTakeAway";
        /// <summary>
        /// 清除料箱与工单的绑定
        /// </summary>
        /// <param name="rfid"></param>
        /// <returns></returns>
        public static bool BoxTakeAway(string rfid)
        {
            try
            {
                string msg = "";
                Dictionary<string, string> map = new Dictionary<string, string>();
                map.Add("rfid", rfid);
                string server = GetAddr(Addr_boxTakeAway, map);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Get(server);
                RfidData serverResult = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);
                if (serverResult == null)
                {
                    msg = $"BoxTakeAway【{rfid}】" + "没有收到服务器反馈";
                    LogUtil.error(msg);
                }
                else if (serverResult.code.Equals(0))
                {
                    // code: 0为正常,其他为异常, msg: 消息, data: 为空
                    msg = $" BoxTakeAway【{rfid}】【{JsonHelper.SerializeObject(serverResult)}】";
                    LogUtil.info(msg);
                    return true;
                }

            }
            catch (Exception ex)
            {
                LogUtil.error("BoxTakeAway", ex);
            }
            return false;
        }

        static string Addr_GetFeederInfo = "/service/store/innerBox/getFeederInfo";
        /// <summary>
        /// 贴标前获取站位信息
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static Label_LZ GetFeederInfo(string barcode)
        {
            try
            {
                string msg = "";
                Dictionary<string, string> map = new Dictionary<string, string>();
                map.Add("barcode", barcode);
                string server = GetAddr(Addr_GetFeederInfo, map);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Get(server);
                ServerData2 serverResult = JsonHelper.DeserializeJsonToObject<ServerData2>(resultStr);
                if (serverResult == null)
                {
                    msg = $"GetFeederInfo【{barcode}】" + "没有收到服务器反馈";
                }
                else if (!serverResult.code.Equals(0))
                {
                    // code: 0为正常,其他为异常, msg: 消息, data: 为空
                    msg = $" GetFeederInfo 【{barcode}】【{resultStr}】";
                    LogUtil.error(msg);
                    return null;
                }
                else
                {
                    msg = $" GetFeederInfo 【{barcode}】【{resultStr}】";
                    LogUtil.debug(msg);
                    return serverResult.data;
                }
            }
            catch (Exception ex)
            {
                LogUtil.error("GetFeederInfo", ex);
            }
            return null;
        }
        #region 料架打印机接口
        static string Addr_GetPrintInfo = "/service/store/innerBox/rack/getPrintInfo";
        public static List<Label_LZ> GetPrintInfo()
        {
            try
            {
                string msg = "";
                Dictionary<string, string> map = new Dictionary<string, string>();
                string server = GetAddr(Addr_GetPrintInfo, map);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Get(server);
                ServerData3 serverResult = JsonHelper.DeserializeJsonToObject<ServerData3>(resultStr);
                if (serverResult == null)
                {
                    msg = $"GetPrintInfo " + "没有收到服务器反馈";
                }
                else if (!serverResult.code.Equals(0))
                {
                    // code: 0为正常,其他为异常, msg: 消息, data: 为空
                    msg = $" GetPrintInfo 【{resultStr}】";
                    LogUtil.error(msg);
                    return null;
                }
                else
                {
                    msg = $" GetPrintInfo【{resultStr}】";
                    LogUtil.debug(msg);
                    return serverResult.data;
                }
            }
            catch (Exception ex)
            {
                LogUtil.error("GetPrintInfo", ex);
            }
            return null;
        }

        static string Addr_FinishPrint = "/service/store/innerBox/rack/finishPrint";
        public static bool FinishPrint(string barcode)
        {
            try
            {
                string msg = "";
                Dictionary<string, string> map = new Dictionary<string, string>();
                map.Add("barcode", barcode);
                string server = GetAddr(Addr_FinishPrint, map);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Get(server);
                ServerData serverResult = JsonHelper.DeserializeJsonToObject<ServerData>(resultStr);
                if (serverResult == null)
                {
                    msg = $"FinishPrint【{barcode}】" + "没有收到服务器反馈";
                }
                else if (serverResult.code.Equals(0))
                {
                    // code: 0为正常,其他为异常, msg: 消息, data: 为空
                    msg = $" FinishPrint 【{barcode}】【{resultStr}】";
                    LogUtil.info(msg);
                    return true;
                }
                else
                {
                    msg = $" GetFeederInfo 【{barcode}】【{resultStr}】";
                    LogUtil.debug(msg);
                    return false;
                }
            }
            catch (Exception ex)
            {
                LogUtil.error("FinishPrint", ex);
            }
            return false;
        }

        #endregion

        #endregion



        #region 存储机构使用的API
        private static string api_communication = "service/store/communication";    //流水线状态通信接口 
        public static string GetPostApi(string host)
        {
            if (host == "")
            {
                host = ConfigAppSettings.GetValue(Setting_Init.http_server);
            }
            if (!host.StartsWith("http://"))
            {
                host = "http://" + host;
            }
            if (!host.EndsWith("/"))
            {
                host = host + "/";
            }
            return host + api_communication;
        }

        internal static string GetShelfIDByLoc(int rfidLoc, List<string> shelfPosList)
        {
            string shelfId = "";
            if (rfidLoc.Equals(-1))
            {
                shelfId = shelfPosList[0];
            }
            if (rfidLoc >= 1 && rfidLoc <= 8 && rfidLoc <= shelfPosList.Count)
            {
                shelfId = shelfPosList[rfidLoc - 1];
            }
            return shelfId;
        }
        #endregion
        //http://localhost/myproject/service/store/emptyPosForPutin
        private static string Addr_PosForPutin = "/service/store/emptyPosForPutin";
        /// <summary>
        /// 屏蔽库位接口
        /// </summary>
        private static string Addr_disabledPos = "/service/store/disabledPos";

        /// <summary>
        /// 屏蔽库位
        /// </summary>
        /// <param name="deviceName"></param>
        /// <param name="barcode"></param>
        /// <param name="poid"></param>
        /// <returns></returns>
        public static string DisablePos(string deviceName, string barcode, string poid,string reason="")
        {
            string msg = "";
            try
            {
                if (String.IsNullOrEmpty(barcode))
                {
                    return msg;
                }
                if (string.IsNullOrEmpty(serverAddr))
                {
                    LogUtil.error(deviceName + "DisablePos   [" + barcode + "]  [" + poid + "]  :未找到服务器地址");
                    return msg;
                }

                Dictionary<string, string> paramMap = new Dictionary<string, string>();
                paramMap.Add("posId", poid);//posId:库位号
                paramMap.Add("barcode", barcode);   // barcode = 料盘的条码
                paramMap.Add("msg", reason);
                string server = GetAddr(Addr_disabledPos, paramMap);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Post(server, "");
                LogUtil.info("DisablePos   " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
                // 返回: { "code": 0, "msg":"ok", "data":""}
                ServerData serverResult = JsonHelper.DeserializeJsonToObject<ServerData>(resultStr);
                if (serverResult == null)
                {
                    msg = deviceName + "DisablePos【 " + barcode + "】【" + poid + "】没有收到服务器反馈";
                }
                else if (serverResult.code.Equals(0).Equals(false))
                {
                    // code: 0为正常,其他为异常, msg: 消息, data: 为空
                    msg = deviceName + " DisablePos【 " + barcode + "】【" + poid + "】:" + "[" + serverResult.code + "]" + serverResult.msg;
                }
                if (!msg.Equals(""))
                {
                    LogUtil.error(msg);
                }
            }
            catch (Exception ex)
            {
                LogUtil.error(deviceName + " ", ex);
            }
            return msg;
        }


        /// <summary>
        /// 1  皮带线扫码后调用,用于获取尺寸后升起气缸
        ///  地址: /rest/api/qisda/device/getSize
        /// </summary>
       // private static string Addr_getSize = "/rest/api/qisda/device/getSize";

        /// <summary>
        /// 2  料盘流转位置信息更新
        ///     地址: /rest/api/qisda/device/updateLocInfo
        /// </summary>
        private static string Addr_updateLocInfo = "/rest/api/qisda/device/updateLocInfo";
        ///// <summary>
        ///// 3  放入料架(A,B,C,D)后调用,根据返回值决定当前料架是否放满,以及后续是否还有任务
        ////        地址: /rest/api/qisda/device/putShelfFinished
        ///// </summary>
        //private static string Addr_putShelfFinished = "/rest/api/qisda/device/putShelfFinished";

        private static string serverAddr = ConfigAppSettings.GetValue(Setting_Init.http_server);
        private static string GetAddr(string addr, Dictionary<string, string> paramsMap)
        {

            if (serverAddr.EndsWith("/"))
            {
                serverAddr = serverAddr.Substring(0, serverAddr.Length - 1);
            }
            string path = serverAddr + addr.Trim() + "?";
            foreach (string paramName in paramsMap.Keys)
            {
                string par = System.Web.HttpUtility.UrlEncode(paramsMap[paramName], System.Text.Encoding.UTF8);
                path += paramName + "=" + par + "&";
            }
            path = path.Substring(0, path.Length - 1);
            return path;
        }
        //## 100 循环获取库位。服务器超时:循环获取库位
        private static string spiltStr = "##";

        public static string ProcessCodeList(List<string> codeList)
        {
            string codeStr = "";
            List<string> list = new List<string>();
            foreach (string str in codeList)
            {
                if (list.Contains(str.Trim()) || String.IsNullOrEmpty(str.Trim()))
                {
                    continue;
                }
                codeStr = codeStr + str.Trim() + spiltStr;
            }
            return codeStr;
        }
        //public static string GetTraySize(string deviceName, int robotIndex, string codeStr, out int outSize, out bool isNg)
        //{
        //    outSize = 0;
        //    isNg = false;
        //    string msg = "";
        //    try
        //    {
        //        if (String.IsNullOrEmpty(codeStr))
        //        {
        //            return msg = deviceName + "未扫到条码";
        //        }
        //        string logName = $"GetTraySize   [{robotIndex }]  [{codeStr}]  :";
        //        if (string.IsNullOrEmpty(serverAddr))
        //        {
        //            LogUtil.error(deviceName + $"{logName}未找到服务器地址");
        //            return msg;
        //        }
        //        Dictionary<string, string> paramMap = new Dictionary<string, string>();
        //        paramMap.Add("robotIndex", robotIndex.ToString());// 参数: robotIndex = 机器人编号,IP为51的机器人为1, 52的机器人为2, 53的机器人为3
        //        paramMap.Add("barcode", codeStr);//  barcode = 扫到的条码

        //        string server = GetAddr(Addr_getSize, paramMap);
        //        DateTime startTime = DateTime.Now;
        //        bool isTimeOut = false;
        //        string resultStr = HttpHelper.Post(server, "", Encoding.UTF8, 5000, out isTimeOut);

        //        LogUtil.info("GetTraySize   " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
        //        if (isTimeOut)
        //        {
        //            return msg = "获取尺寸超时";
        //        }
        //        //返回: { "code": 0, "msg":"ok", data: 7} 
        //        ServerData serverResult = JsonHelper.DeserializeJsonToObject<ServerData>(resultStr);
        //        if (serverResult == null)
        //        {
        //            return msg = "没有收到服务器反馈";
        //        }
        //        else if (serverResult.code.Equals(0).Equals(false))
        //        {
        //            //   code: 0为正常,其他为异常, 
        //            //code不是0,直接NG
        //            isNg = true;
        //            return msg = $" [{ serverResult.code}]:" + serverResult.msg;
        //        }

        //        if (!serverResult.data.Equals(""))
        //        {
        //            //   data:料盘直径,= 7时升起气缸
        //            outSize = Convert.ToInt32(serverResult.data);
        //            LogUtil.info(deviceName + $"{ logName} 获得尺寸:" + outSize);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        LogUtil.error(deviceName + " ", ex);
        //    }
        //    return "";
        //}


        public static string UpdateTrayLoc(string deviceName, string barcode, string status, string locInfo)
        {
            string msg = "";
            try
            {
                if (String.IsNullOrEmpty(barcode))
                {
                    return msg;
                }
                if (string.IsNullOrEmpty(serverAddr))
                {
                    LogUtil.error(deviceName + "UpdateTrayLoc   [" + barcode + "]  [" + status + "]  :未找到服务器地址");
                    return msg;
                }

                Dictionary<string, string> paramMap = new Dictionary<string, string>();
                paramMap.Add("barcode", barcode);//barcode = 料盘的条码
                paramMap.Add("status", status);   // status = 状态信息, 移栽 = MOVING, 流水线 = INLINE, 皮带线 = INBELT
                paramMap.Add("locInfo", locInfo);  // locInfo = 位置信息,移栽时为移栽编号,流水线时为托盘号,皮带线时为皮带线编号,机器人时为机器人编号
                string server = GetAddr(Addr_updateLocInfo, paramMap);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Post(server, "");
                LogUtil.info("UpdateTrayLoc   " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
                // 返回: { "code": 0, "msg":"ok", "data":""}
                ServerData serverResult = JsonHelper.DeserializeJsonToObject<ServerData>(resultStr);
                if (serverResult == null)
                {
                    msg = deviceName + "UpdateTrayLoc【 " + barcode + "】【" + status + "】【" + locInfo + "】没有收到服务器反馈";
                }
                else if (serverResult.code.Equals(0).Equals(false))
                {
                    // code: 0为正常,其他为异常, msg: 消息, data: 为空
                    msg = deviceName + " UpdateTrayLoc【 " + barcode + "】【" + status + "】【" + locInfo + "】  :" + "[" + serverResult.code + "]" + serverResult.msg;
                }
                if (!msg.Equals(""))
                {
                    LogUtil.error(msg);
                }
            }
            catch (Exception ex)
            {
                LogUtil.error(deviceName + " ", ex);
            }
            return msg;
        }

        private static string Addr_clearPutInRfid = "/service/store/qisda/clearPutInRfid";
        public static string clearPutInRfid(string deviceName, string rfid)
        {
            string msg = "";
            try
            {
                if (String.IsNullOrEmpty(rfid))
                {
                    return msg;
                }
                if (string.IsNullOrEmpty(serverAddr))
                {
                    LogUtil.error(deviceName + "clearPutInRfid   [" + rfid + "]  :未找到服务器地址");
                    return msg;
                }

                Dictionary<string, string> paramMap = new Dictionary<string, string>();
                paramMap.Add("rfid", rfid);//rfid   
                string server = GetAddr(Addr_clearPutInRfid, paramMap);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Post(server, "");
                LogUtil.info(deviceName + "clearPutInRfid    " + FormUtil.GetSpanStr(DateTime.Now - startTime) + "  【" + server + "】【" + resultStr + "】");

            }
            catch (Exception ex)
            {
                LogUtil.error(deviceName + " " + ex.ToString());
            }
            return msg;
        }


        //皮带线获取尺寸后,料盘到达机器人取料位置进调用,如果未扫到码,或者没等到取料位置信号亮,可以不用调用

        //> 地址:
        //>>/rest/api/qisda/device/arrive3fRobotLocation
        //>
        //> 参数: 
        //>> - robotIndex=机器人编号,IP为51的机器人为1, 52的机器人为2, 53的机器人为3
        //>
        //> 返回: 
        //>>``
        private static string Addr_arrive3fRobotLocation = "/rest/api/qisda/device/arrive3fRobotLocation";
        public static string arrive3fRobotLocation(string deviceName, int robotIndex, string barcode)
        {
            string msg = "";
            if (string.IsNullOrEmpty(serverAddr))
            {
                LogUtil.error(deviceName + "arrive3fRobotLocation   [" + robotIndex + "][" + barcode + "]  :未找到服务器地址");
                return msg;
            }
            try
            {
                if (robotIndex <= 0)
                {
                    return "robotIndex=" + robotIndex;
                }
                DateTime startTime = DateTime.Now;
                Dictionary<string, string> paramMap = new Dictionary<string, string>();
                paramMap.Add("robotIndex", robotIndex.ToString());//rfid   
                paramMap.Add("barcode", barcode);
                string server = GetAddr(Addr_arrive3fRobotLocation, paramMap);
                string resultStr = HttpHelper.Post(server, "");
                LogUtil.info(deviceName + "arrive3fRobotLocation      " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
            }
            catch (Exception ex)
            {
                msg = deviceName + " " + ex.ToString();
                LogUtil.error(deviceName + " " + ex.ToString());
            }
            return msg;
        }


        //        分盘料/紧急料放上料串或料架时调用 /rest/api/qisda/device/afterPutCut
        private static string Addr_afterPutCut = "/rest/api/qisda/device/afterPutCut";
        public static string afterPutCut(string deviceName, string rfid, string barcode, string cid, int rfidLoc, out TaskData afterData)
        {
            afterData = null;
            string msg = "";
            if (string.IsNullOrEmpty(serverAddr))
            {
                LogUtil.error(deviceName + "afterPutCut   [" + rfid + "][" + barcode + "][" + cid + "][" + rfidLoc + "] :未找到服务器地址");
                return msg;
            }
            try
            {
                //参数:
                //cid:  料仓cid,流水线可传入空
                //barcode : 条码
                //rfid :  RFID
                //rfidLoc: 料架位置,流水线可传-1

                Dictionary<string, string> paramMap = new Dictionary<string, string>();
                paramMap.Add("barcode", barcode);      // 参数: barcode=料盘的条码
                paramMap.Add("rfid", rfid);                     // rfid = 料架的RFID信息
                paramMap.Add("rfidLoc", rfidLoc.ToString());     // rfidLoc=料架的架位信息 
                paramMap.Add("cid", cid);     // 料仓cid,流水线可传入空
                string server = GetAddr(Addr_afterPutCut, paramMap);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Post(server, "");
                if (barcode != "")
                {
                    LogUtil.info(deviceName + "afterPutCut    " + FormUtil.GetSpanStr(DateTime.Now - startTime) + "  【" + server + "】【" + resultStr + "】");
                }
                else
                {
                    LogUtil.debug(deviceName + "afterPutCut    " + FormUtil.GetSpanStr(DateTime.Now - startTime) + "  【" + server + "】【" + resultStr + "】");
                }
                //>   返回: 
                //>>` {"code": 0, "msg":"ok", "data":{"cutPackageTask":"0","urgentPackageTask":"20","cutTask":"21","urgentTask":"22"}} `
                //>>
                //>> - code: 0为正常,其他为异常, 
                //>> - msg:消息, 
                //>> - data:为包装料仓的空闲仓位数(key为与客户端一致的料仓标识, value为空闲仓位)
                //>> - cutPackageTask: 表示当前包装仓的分盘任务数
                //>> - urgentPackageTask: 表示当前包装仓的紧急料任务数
                //>> - cutTask: 表示流水线分盘任务数
                //>> - urgentTask: 表示流水线紧急料任务数
                AfterPutData serverResult = JsonHelper.DeserializeJsonToObject<AfterPutData>(resultStr);

                if (serverResult == null)
                {
                    return msg = deviceName + "afterPutCut【 " + barcode + "】【" + rfid + "】【" + rfidLoc + "】没有收到服务器反馈";
                }
                else if (serverResult.code.Equals(0).Equals(false))
                {
                    return msg = deviceName + " afterPutCut【 " + barcode + "】【" + rfid + "】【" + rfidLoc + "】  :" + serverResult.msg;
                }
                afterData = serverResult.data;
                return "";
            }
            catch (Exception ex)
            {
                LogUtil.error(deviceName + " " + ex.ToString());
            }
            return msg;
        }


        //        分盘料/紧急料启动时获取料架的虚拟RFID调用  地址:   /rest/api/qisda/device/findTempRfid
        private static string Addr_findTempRfid = "/rest/api/qisda/device/findTempRfid";
        public static string findTempRfid(string deviceName, string rfid, out string tempRfid)
        {
            tempRfid = "";
            string msg = "";
            if (string.IsNullOrEmpty(serverAddr))
            {
                LogUtil.error(deviceName + "findTempRfid   [" + rfid + "] :未找到服务器地址");
                return msg;
            }
            try
            {
                //            参数:         rfid: RFID
                //           返回:       "code": 0, "msg":"ok", "data":{ "tempRfid":""}
                //                 code: 0为正常,其他为异常,
                //msg: 消息,
                //data:  tempRfid: 表示当前料架(料串)对应的虚拟RFID

                Dictionary<string, string> paramMap = new Dictionary<string, string>();
                paramMap.Add("rfid", rfid);      // rfid: RFID

                string server = GetAddr(Addr_findTempRfid, paramMap);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Post(server, "");
                LogUtil.info(deviceName + "findTempRfid    " + FormUtil.GetSpanStr(DateTime.Now - startTime) + "  【" + server + "】【" + resultStr + "】");

                RfidData data = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);

                if (data == null)
                {
                    return msg = deviceName + " findTempRfid【 " + rfid + "】 没有收到服务器反馈";
                }
                else if (data.code.Equals(0).Equals(false))
                {
                    return msg = deviceName + " findTempRfid【 " + rfid + "】   :" + data.msg;
                }
                if (data.data != null && data.data.ContainsKey("tempRfid"))
                {
                    tempRfid = data.data["tempRfid"];
                }
                return "";
            }
            catch (Exception ex)
            {
                LogUtil.error(deviceName + " " + ex.ToString());
            }
            return msg;
        }


        //        取消任务地址:   /cancelPutInTask      //参数: barcode
        private static string Addr_cancelPutInTask = "/rest/api/qisda/device/cancelPutInTask";
        public static string cancelPutInTask(string deviceName, string barcode)
        {
            string msg = "";
            try
            {
                if (string.IsNullOrEmpty(serverAddr))
                {
                    LogUtil.error(deviceName + "cancelPutInTask   [" + barcode + "] :未找到服务器地址");
                    return msg;
                }

                Dictionary<string, string> paramMap = new Dictionary<string, string>();
                paramMap.Add("barcode", barcode);

                string server = GetAddr(Addr_cancelPutInTask, paramMap);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Post(server, "");
                LogUtil.info(deviceName + "cancelPutInTask    " + FormUtil.GetSpanStr(DateTime.Now - startTime) + "  【" + server + "】【" + resultStr + "】");

                CancelData data = JsonHelper.DeserializeJsonToObject<CancelData>(resultStr);

                if (data == null)
                {
                    return msg = deviceName + " cancelPutInTask【 " + barcode + "】 没有收到服务器反馈";
                }
                else if (data.code.Equals(0).Equals(false))
                {
                    return msg = deviceName + " cancelPutInTask【 " + barcode + "】   :" + data.msg;
                }

                return "";
            }
            catch (Exception ex)
            {
                LogUtil.error(deviceName + " " + ex.ToString());
            }
            return msg;
        }

        public static GetPosResult GetPosId(string deviceName, List<string> codeList, int height, int width, string rfid, string lastPosId)
        {
            GetPosResult result = new GetPosResult();
            try
            {
                string codeStr = "";
                List<string> list = new List<string>();
                foreach (string str in codeList)
                {
                    if (list.Contains(str.Trim()) || String.IsNullOrEmpty(str.Trim()))
                    {
                        continue;
                    }
                    list.Add(str.Trim());
                    string code = "=" + width + "x" + height + "=" + str.Trim();
                    codeStr = codeStr + code + spiltStr;
                }
                codeStr = CodeManager.ReplaceCode(codeStr);

                //判断是否不连接服务器
                if (string.IsNullOrEmpty(serverAddr))
                {
                    LogUtil.error(deviceName + "GetPosId[" + codeStr + "][" + width + "][" + height + "]:未找到服务器地址 ");
                    result.Msg = "未找到服务器地址";
                    result.Param = InOutPosInfo.NewNgPos(codeStr, "", width, height, "");
                    return result;
                }

                //http://localhost/myproject/service/store/emptyPosForPutin
                // 参数:cids: 多个 cid
                //code: 条码内容
                Dictionary<string, string> paramMap = new Dictionary<string, string>();
                paramMap.Add("cids", StoreManager.Config.CID);
                paramMap.Add("code", codeStr);
                paramMap.Add(ParamDefine.rfid, rfid);
                paramMap.Add(ParamDefine.lastPosId, lastPosId);

                string server = GetAddr(Addr_PosForPutin, paramMap);
                DateTime startTime = DateTime.Now;
                LogUtil.info(deviceName + "【" + rfid + "】【 " + codeStr + "】【" + lastPosId + "】 ,获取入库库位:");

                string resultStr = HttpHelper.Post(server, "", Encoding.UTF8, 10000, out result.IsTimeOut);

                LogUtil.info(deviceName + "CodeReceived " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
                if (result.IsTimeOut)
                {
                    return result;
                }
                //{"result":"0","msg":"","pos":"11#AC1_18_4_28","barcode":"R506072019102200414","cid":"line-ac-11"}
                ForPutinData serverResult = JsonHelper.DeserializeJsonToObject<ForPutinData>(resultStr);

                if (serverResult == null)
                {
                    result.Msg = deviceName + "  【" + codeStr + "】结果:没有收到服务器反馈,等待下一次请求";
                    result.Result = 100;
                    //cancelPutInTask(deviceName, codeStr);
                    //result.Param = InOutPosInfo.NewNgPos(codeStr, "", width, height, "没有收到服务器反馈");
                   // result.Param.rfid = rfid;
                   // result.Param.IsNG = true;
                    return result;
                }
                else if ((!string.IsNullOrEmpty(serverResult.msg)) && serverResult.result.Equals(98))
                {
                    result.Result = serverResult.result;
                    result.Msg = "";
                    bool cutReel = serverResult.cutReel.ToLower().Equals("true");
                    bool urgentReel = serverResult.urgentReel.ToLower().Equals("true");
                    bool smallReel = serverResult.smallReel.ToLower().Equals("true");
                    int rfidloc = FormUtil.GetIntValue(serverResult.rfidLoc);
                    int pH = FormUtil.GetIntValue(serverResult.plateH);
                    int pW = FormUtil.GetIntValue(serverResult.plateW);
                    result.Param = new InOutPosInfo(serverResult.barcode, serverResult.posId, pW, pH, urgentReel, cutReel, smallReel, serverResult.rfid, rfidloc);

                    LogUtil.error(deviceName + "  【" + codeStr + "】结果入库NG:收到出库信息: " + result.Param.ToStr() + "  ");

                    result.Msg = "收到出库信息[" + serverResult.barcode + "][" + serverResult.posId + "] ";
                    cancelPutInTask(deviceName, codeStr);
                    result.Param = InOutPosInfo.NewNgPos(codeStr, "", width, height, "收到出库信息[" + serverResult.barcode + "][" + serverResult.posId + "]");
                    result.Param.rfid = rfid;
                    result.Param.IsNG = true;
                    return result;
                }
                else if ((!string.IsNullOrEmpty(serverResult.msg)) || serverResult.result.Equals(0).Equals(false))
                {
                    result.Result = serverResult.result;
                    //result.Msg = deviceName + "  【" + codeStr + "】结果:" + serverResult.msg;
                    result.Msg = serverResult.msg;
                    result.Param = InOutPosInfo.NewNgPos(codeStr, "", width, height, serverResult.msg);
                    result.Param.rfid = rfid;
                    return result;
                }
                result.Result = serverResult.result;
                if (!serverResult.pos.Equals(""))
                {
                    //                    库位号格式:
                    //例:05AA03040102
                    //05:第1和第2位表示料仓编号,01 - 08
                    //AA:第3和第4位存储机构A面或B面,AA或者BB
                    //03:第5和第6位表示抽屉在第几行
                    //04:第7和第8位表示抽屉在第几列
                    //01:第9和第10位表示在抽屉中的第几行
                    //02:第11和第12位表示在抽屉中的第几列 
                    string posId = serverResult.pos;

                    //根据库位号查找移栽
                    //  判断PosID是否已经在入库或者在排队列表中,如果已经存在,加入列表失败     
                    result.Param = new InOutPosInfo(serverResult.barcode, posId, width, height);
                    result.Param.rfid = rfid;
                    BoxPosition position = CSVPositionReader<BoxPosition>.GetPositon(posId);
                    if (position == null)
                    {
                        result.Param.IsNG = true;
                        result.Param.NgMsg = "未找到库位[" + position + "]";
                        result.Msg = "未找到库位: " + result.Param.ToStr() + " ,入库失败";
                        LogUtil.error(deviceName + ("收到服务器入库命令  " + ",未找到库位: " + result.Param.ToStr() + " ,入库失败!"));
                        return result;
                    }
                    else
                    {
                        LogUtil.info(deviceName + "收到入库命令: " + result.Param.ToStr() + "  ");
                        return result;
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtil.error(deviceName + " ", ex);
            }
            return result;
        }
        public static void SendPosToStoreCheck(string deviceName, InOutParam param)
        {
            //if (param == null || param.IsNG)
            //{
            //    return;
            //}
            //int storeId = param.GetStoreId();
            //MoveEquip moveEquip = StoreManager.XLRStore.MoveEquipMap[storeId];
            //if (LineServer.BoxCanInStore(moveEquip.DeviceID))
            //{
            //    LineServer.CheckInStorePos(storeId, param);
            //}
            //else
            //{
            //    //等待3秒后重发验证
            //    Task.Factory.StartNew(delegate
            //    {
            //        LogUtil.error(deviceName + "[" + moveEquip.Name + " ]入库命令: " + param.ToStr() + " 给料仓发送验证失败,等待3秒后重发 ");
            //        Thread.Sleep(3000);
            //        LineServer.CheckInStorePos(storeId, param);
            //    });
            //}
            //lock (moveEquip.waitInListLock)
            //{
            //    //如果当前正在出入库中,需要记录下来,等待空闲时执行
            //    LogUtil.info(deviceName + "[" + moveEquip.Name + " ]入库命令: " + param.ToStr() + "加入等待列表中!");
            //    moveEquip.waitInStoreList.Add(param);
            //}
        }

        //14.异常看板

        //   > 地址: 
        //>>/ rest / api / qisda / device / updateDeviceAlarmMsg


        //    >
        //    > 参数:
        //>> deviceAlarmList : 异常列表Json字符串  `[{"name":"移栽5", "msgKey":"line.move5.timeOut", "msgValue":"运动超时"},{"name":"移栽4", "msgKey":"line.move4.timeOut", "msgValue":"误差过大"}]`
        //>>>name :  异常位置名称
        //>>>msgKey :  异常信息唯一标识
        //>>>msgValue :  异常信息
        //>
        //>   返回: 
        //>>` {"code":0,"msg":"ok","data":""}`
        //>>
        //>> - code: 0为正常,其他为异常, 
        //          >> - msg:消息, 
        //          >> - data:
        private static string Addr_updateDeviceAlarmMsg = "/rest/api/qisda/device/updateDeviceAlarmMsg";
        public static string updateDeviceAlarmMsg(List<AlarmMsg> msgList)
        {
            string msg = "";
            try
            {
                if (string.IsNullOrEmpty(serverAddr))
                {
                    return msg;
                }
                Dictionary<string, string> paramMap = new Dictionary<string, string>();
                string msgListStr = JsonHelper.SerializeObject(msgList);
                paramMap.Add("deviceAlarmList", msgListStr);
                string server = GetAddr(Addr_updateDeviceAlarmMsg, paramMap);
                DateTime startTime = DateTime.Now;
                string resultStr = HttpHelper.Post(server, "", 5000);
                LogUtil.debug("updateDeviceAlarmMsg    " + FormUtil.GetSpanStr(DateTime.Now - startTime) + "  【" + server + "】【" + resultStr + "】");

                RfidData data = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);

                if (data == null)
                {
                    return msg = " updateDeviceAlarmMsg 没有收到服务器反馈";
                }
                else if (data.code.Equals(0).Equals(false))
                {
                    return msg = " updateDeviceAlarmMsg   【" + server + "】【" + resultStr + "】" + data.msg;
                }
                return "";
            }
            catch (Exception ex)
            {
                LogUtil.error("  updateDeviceAlarmMsg Error:  " + ex.ToString());
            }
            return msg;
        }

        //private static string Addr_ShelfFinish = "/rest/api/qisda/device/putShelfFinished";

        public static BoxTaskInfo ShelfFinish(string rfid, string barcode = "", Label_LZ label_LZ = null,string outlet="",string boxside="",int remainTaskCount=-1)
        {
            LogUtil.info($"BoxFinish rifd【{rfid}】barcode【{barcode}】outlet【{outlet}】boxside【{boxside}】 hSerial【{label_LZ?.hSerial ?? ""}】remainTaskCount【{remainTaskCount}】");

            BoxTaskInfo task = new BoxTaskInfo();
            //task.boxLoc = rfid;
            return task;
            //    DateTime startTime = DateTime.Now;
            //    try
            //    {
            //        string api = Addr_ShelfFinish;
            //        Dictionary<string, string> paramMap = new Dictionary<string, string>();
            //        paramMap.Add("barcode", barcode);
            //        paramMap.Add("rfid", rfid);
            //        paramMap.Add("rfidLoc", rfidLoc);
            //        paramMap.Add("robotIndex", robotIndex);
            //        //string url = httpAddr + api + "?barcode=" + barcode + "&rfid=" + rfid + "&rfidLoc=" + rfidLoc + "&robotIndex=" + robotIndex;
            //        string url = GetAddr(api, paramMap);
            //        LogUtil.debug("http :URL:" + url);

            //        string json = HttpHelper.Post(url, "", 10000);
            //        if (barcode != "")
            //        {
            //            LogUtil.info("http :URL:" + url + " :Response:" + json + " 耗时[" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "]");
            //        }
            //        else
            //        {
            //            LogUtil.debug("http :URL:" + url + " :Response:" + json);
            //        }
            //        if (string.IsNullOrWhiteSpace(json)) return task;
            //        //行 2234: [2021 - 04 - 07 15:09:31,412][9]INFO - http :URL: 
            //        //http://192.168.100.14/myproject/rest/api/qisda/device/putShelfFinished?barcode=640253A*34005600000309*QG00006*5000*23C4&rfid=F103&rfidLoc=8&robotIndex=1 :
            //        //Response:{"code":0,"msg":"ok","data":{"smallTask":"0","cutPackageTask":"0","packageTask":"0","bigTask":"0","smallEmpty":"0","bigEmpty":"5","packageEmpty":"0","rfid":"F103","usedRfidList":"F106,F105,F103","barcode":"640253A*34005600000309*QG00006*5000*23C4","cutTask":"0"}} 耗时[00:00:00.1]

            //        JavaScriptSerializer serializer = new JavaScriptSerializer();
            //        Dictionary<string, object> obj = (Dictionary<string, object>)serializer.DeserializeObject(json);
            //        if (!obj.TryGetValue("code", out object value)) return task;
            //        if (value.ToString() != "0")
            //        {
            //            if (obj.TryGetValue("msg", out value))
            //                LogUtil.error("http" + api + ": " + value.ToString());
            //            return task;
            //        }
            //        if (!obj.TryGetValue("data", out value)) return task;
            //        Dictionary<string, object> dict = (Dictionary<string, object>)value;
            //        if (dict == null)
            //        {
            //            LogUtil.info("http" + api + ": data=null");
            //            return task;
            //        }

            //        if (dict.TryGetValue("bigEmpty", out value))
            //            int.TryParse(value.ToString(), out task.bigEmpty);
            //        if (dict.TryGetValue("smallEmpty", out value))
            //            int.TryParse(value.ToString(), out task.smallEmpty);

            //        if (dict.TryGetValue("usedRfidList", out value))
            //            task.usedRfidList = value.ToString();
            //    }
            //    catch (Exception ex)
            //    {
            //        LogUtil.error("http error  : " + ex.ToString());
            //    }
            //    return task;
        }
    }
    /// <summary>
    /// 出库任务状态
    /// </summary>
    public class LocStatus
    {
        /// <summary>
        /// 任务出错
        /// </summary>
        public static string ERROR = "ERROR";
        /// <summary>
        /// 已放上仓内皮带线
        /// </summary>
        public static string ON_INNER_LINE = "ON_INNER_LINE";
        /// <summary>
        /// 已送入仓外皮带线
        /// </summary>
        public static string ON_OUT_LINE = "ON_OUT_LINE";
        /// <summary>
        /// 料盘放贴标平台,机器人取好标签
        /// </summary>
        public static string GET_LABEL = "GET_LABEL";
        /// <summary>
        /// 贴标完成,等待放入周转箱
        /// </summary>
        public static string LABELED = "LABELED";
        /// <summary>
        /// 料盘在机器人上,准备放入周转箱
        /// </summary>
        public static string TO_BOX = "TO_BOX";
        /// <summary>
        /// 任务完成(已放入周转箱)
        /// </summary>
        public static string FINISHED = "FINISHED";
    }

    /// <summary>
    /// 箱子剩余数量
    /// </summary>
    public class BoxTaskInfo
    {
        /// <summary>
        /// 所属需求单剩余当前料仓未完成任务数
        /// </summary>
        public int remainTaskCount { get; set; } = -1;
        /// <summary>
        /// 所属需求单剩余料架任务数
        /// </summary>
        public int rackTaskCount { get; set; } = -1;
        /// <summary>
        /// 需求单号
        /// </summary>
        public string hSerial { get; set; } = "";
        /// <summary>
        /// 目的地
        /// </summary>
        public string line { get; set; } = "";
        public string cid { get; set; }
        /// <summary>
        /// 出口位置,A或者B
        /// </summary>
        public string outlet { get; set; }
        /// <summary>
        /// 当前料箱隔口内侧T
        /// </summary>
        public int boxTCount { get; set; } = -1;
        /// <summary>
        /// 当前料箱隔口外侧B
        /// </summary>
        public int boxBCount { get; set; } = -1;
        /// <summary>
        /// 料箱rfid
        /// </summary>
        public string rfid { get; set; }
        public string ToStr()
        {
            return $"内侧T已有数量:{boxTCount},外侧B已有数量;{boxBCount}; 需求单:{hSerial},剩余任务数={remainTaskCount}," +
                $"剩余料架数:{rackTaskCount},目的地:{line}";
        }
    }
    /// <summary>
    /// 出口料箱信息
    /// </summary>
    public class BoxInfo
    {
        /// <summary>
        /// 出口位置,A或者B
        /// </summary>
        public string outlet { get; set; }
        /// <summary>
        /// 料仓cid
        /// </summary>
        public string cid { get; set; }
        /// <summary>
        /// 料箱rfid
        /// </summary>
        public string rfid { get; set; }
        /// <summary>
        /// 需求单号
        /// </summary>
        public string hSerial { get; set; } = "";
        /// <summary>
        /// 目的线体
        /// </summary>
        public string line { get; set; } = "";
        /// <summary>
        /// 当前料箱隔口内侧T
        /// </summary>
        public int boxTCount { get; set; } = -1;
        /// <summary>
        /// 当前料箱隔口外侧B
        /// </summary>
        public int boxBCount { get; set; } = -1;

        public string ToStr()
        {
            return $"出口位置:{outlet},箱号:{rfid},需求单:{hSerial},内侧T已有数量:{boxTCount},外侧B已有数量;{boxBCount}," +
                $"目的地:{line}";
        }
    }
    public class AlarmMsg
    {

        //>>>name :  异常位置名称
        public string name = "";
        //>>>msgKey :  异常信息唯一标识
        public string msgKey = "";
        //>>>msgValue :  异常信息
        public string msgValue = "";

        public AlarmMsg(string n, string key, string value)
        {
            this.name = n;
            this.msgKey = key;
            this.msgValue = value;
        }
    }
    public class GetPosResult
    {
        public string Msg = "";
        /// <summary>
        /// 0=成功,98=此盘为出库盘。99:暂时不能入库,需要重新获取库位。100:服务器需要更新,需要重新获取库位
        /// </summary>
        public int Result = 0;
        /// <summary>
        /// 获取超时,需要重新获取库位
        /// </summary>
        public bool IsTimeOut = false;
        public InOutPosInfo Param = null;
    }
    public class RfidData
    {
        //{"code":0,"msg":"ok","data":"7"} 
        public int code { get; set; }

        public string msg { get; set; }

        public Dictionary<string, string> data { get; set; }
    }
    public class CancelData
    {
        //{"code":0,"msg":"ok","data":"7"} 
        public int code { get; set; }

        public string msg { get; set; }

        public object data { get; set; }
    }
    //public class LocStatus
    //{
    //    /// <summary>
    //    /// 料盘位置:移栽 = MOVING
    //    /// </summary>
    //    public static string MOVING = "MOVING";
    //    /// <summary>
    //    /// 料盘位置:流水线 = INLINE
    //    /// </summary>
    //    public static string INLINE = "INLINE";
    //    /// <summary>
    //    /// 料盘位置:皮带线 = INBELT
    //    /// </summary>
    //    public static string INBELT = "INBELT";
    //}
    public class ServerData
    {
        //{"code":0,"msg":"ok","data":"7"} 
        public int code { get; set; }

        public string msg { get; set; }

        public string data { get; set; }
    }
    public class ServerData1
    {
        public int code { get; set; }

        public string msg { get; set; }

        public BoxTaskInfo data { get; set; }
    }
    public class ServerData2
    {
        public int code { get; set; }

        public string msg { get; set; }

        public Label_LZ data { get; set; }
    }
    public class ServerData3
    {
        public int code { get; set; }

        public string msg { get; set; }

        public List<Label_LZ> data { get; set; }
    }
    public class ServerData4
    {
        public int code { get; set; }

        public string msg { get; set; }

        public List<BoxTaskInfo> data { get; set; }
    }
    public class AfterPutData
    {
        //>>` {"code": 0, "msg":"ok", "data":{"cutPackageTask":"0","urgentPackageTask":"20","cutTask":"21","urgentTask":"22"}} `
        //>>
        //>> - code: 0为正常,其他为异常, 
        //>> - msg:消息, 
        //>> - data:为包装料仓的空闲仓位数(key为与客户端一致的料仓标识, value为空闲仓位)
        //>> - cutPackageTask: 表示当前包装仓的分盘任务数
        //>> - urgentPackageTask: 表示当前包装仓的紧急料任务数
        //>> - cutTask: 表示流水线分盘任务数
        //>> - urgentTask: 表示流水线紧急料任务数
        public int code { get; set; }

        public string msg { get; set; }

        public TaskData data { get; set; }
    }
    public class TaskData
    {
        /// <summary>
        /// urgentPackageTask: 表示当前包装仓的紧急料任务数
        /// </summary>
        public int urgentPackageTask { get; set; }
        /// <summary>
        /// cutPackageTask: 表示当前包装仓的分盘任务数
        /// </summary>
        public int cutPackageTask { get; set; }
        /// <summary>
        /// cutTask: 表示流水线分盘任务数
        /// </summary>
        public int cutTask { get; set; }
        /// <summary>
        /// urgentTask: 表示流水线紧急料任务数
        /// </summary>
        public int urgentTask { get; set; }

        public string ToStr()
        {
            return "[分盘料=" + cutTask + "][紧急料=" + urgentTask + "]";
        }

    }
}