1
pulg
2025-06-30 f8e049e2a30f711a56b735361a230216d8808f0b
HH.WCS.QingXiNongfu/dispatch/NDC.cs
@@ -70,11 +70,71 @@
                return new AGVResult { Res = new Res { ErrCode = -1, ErrInfo = e.Message } };
            }
        }
        public static bool AddTaskNew(int ts, int pri, string taskNo, Dictionary<string, string> dic)
        {
            var res = NDC.AddNewOrderNew(ts, pri, taskNo, dic);
            if (res != null && (res.Res.ErrCode == 0 || res.Res.ErrCode == 50009))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public static AGVResult AddNewOrderNew(int ts, int pri, string taskNo, Dictionary<string, string> param)
        {
            //< Req >< Order TS = '1' Pri = '1' No = 'TN2302020001' Ext1 = '' Ext2 = '' N_CNTR_COUNT = '' >< Param Name = 'From' Value = '2' />< Param Name = 'To' Value = '1' /></ Order ></ Req >
            var bufin = GetReqStrNew(ts, pri, taskNo, param);
            try
            {
                LogHelper.Info($"任务下发结果 OrderAdd req={bufin}", "NDC");
                var result = callClient.OrderAdd(bufin);
                LogHelper.Info($"任务下发结果 OrderAdd req={bufin} res={result}", "NDC");
                // Console.WriteLine($"任务下发结果 OrderAdd req={bufin} res={result}");
                //LogHelper.Info(result.bufout, "ts");
                return GetResult(result);
            }
            catch (Exception e)
            {
                LogHelper.Info($"任务下发失败 OrderAdd req={bufin} res={e.Message}", "NDC");
                //Console.WriteLine($"任务下发失败 AddNewOrder req={bufin} res={e.Message}");
                return new AGVResult { Res = new Res { ErrCode = -1, ErrInfo = e.Message } };
            }
        }
        private static string GetReqStrNew(int ts, int pri, string taskNo, Dictionary<string, string> param)
        {
            /*<Req>
              <Order TS='5' Pri='80' No='666' NoCallback='0' Ext1='' Ext2='' Ext3=''>
                <Param Name='From' Value='10' />
                <Param Name='To' Value='20' />
                <Param Name='FRow' Value='1' />
                <Param Name='TRow' Value='7' />
                <Param Name='DispInfo' Value='1' />
                <Param Name='CtrlVal' Value='12' />
                <Param Name='ChgTo' Value='2' />
                <Param Name='Flow' Value='111' />
                <Param Name='Tlow' Value='222' />
              </Order>
            </Req>*/
            var sb = new StringBuilder();
            sb.Append($"<Req><Order TS='{ts}' Pri='{pri}' No='{taskNo}'>");
            foreach (var kv in param)
            {
                sb.Append($"<Param Name='{kv.Key}' Value='{kv.Value}'/>");
            }
            sb.Append("</Order></Req>");
            return sb.ToString();
        }
        public static AGVResult CancelOrder(int ts, Dictionary<string, string> param, string RORDERs = "")
        {
            //< Req >< Order No = 'TN2302020001' >< Param Name = 'IsForce' Value = '1' /></ Order ></ Req >
            var bufin =GetReqStr(ts, param);
            var bufin = GetReqStr(ts, param);
            if (!string.IsNullOrEmpty(RORDERs))
                bufin = RORDERs;// GetReqStr(ts, param);
            try