123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- using ServiceCenter.Extensions;
- using ServiceCenter.Logs;
- using ServiceCenter.Redis;
- using ServiceCenter.WebApi;
- using WCS.WorkEngineering.WebApi.Models.AGV;
- using WCS.WorkEngineering.WebApi.Models.AGV.Request;
- using WCS.WorkEngineering.WebApi.Models.AGV.Response;
- using WCS.WorkEngineering.WebApi.Models.WCS.Response;
- using WCS.WorkEngineering.WebApi.Models.WMS.Request;
- using WCS.WorkEngineering.WebApi.Models.WMS.Response;
- namespace WCS.WorkEngineering.WebApi.Controllers
- {
- /// <summary>
- /// AGV接口
- /// </summary>
- public static class AgvApi
- {
- private static string _AgvUrl = null!;
- /// <summary>
- /// AGV地址
- /// </summary>
- public static string AgvUrl
- {
- get
- {
- _AgvUrl ??= RedisHub.Default.Check("AgvUrl");
- if (string.IsNullOrEmpty(_AgvUrl))
- {
- throw new KnownException($"请在Redis配置AgvUrl", LogLevelEnum.High);
- }
- return _AgvUrl;
- }
- }
- #region 任务单生成
- ///// <summary>
- ///// 盘条入库
- ///// </summary>
- ///// <param name="position">取货机台</param>
- ///// <param name="ctnrCode">容器编码</param>
- ///// <param name="taskCode">WMS任务号</param>
- ///// <param name="priority">优先级</param>
- ///// <returns></returns>
- //public static GenAgvSchedulingTaskResponse 盘条入库( string position, string ctnrCode, string taskCode, string priority)
- //{
- // return GenAgvSchedulingTask("iwms_third", ctnrCode,"4", new List<positionCodeClass>()
- // {
- // new positionCodeClass(){ //取货机台
- // positionCode=position,
- // type="00"
- // },
- // new positionCodeClass(){ //巷道分配点
- // positionCode="DD3",
- // type="00"
- // },
- // new positionCodeClass(){ //预分配终点
- // positionCode="JT1",
- // type="00"
- // }
- // }, priority, taskCode, "PT05", "1");
- //}
- //public static GenAgvSchedulingTaskResponse 叫料出库(string ctnrCode, string position, string taskCode, string priority)
- //{
- // return GenAgvSchedulingTask("iwms_third", ctnrCode, "4", new List<positionCodeClass>()
- // {
- // new positionCodeClass(){ //取货机台
- // positionCode=position,
- // type="00"
- // },
- // new positionCodeClass(){ //巷道分配点
- // positionCode="DD3",
- // type="00"
- // }
- // }, priority, taskCode, "PT04", "1");
- //}
- //public static GenAgvSchedulingTaskResponse 搬运(string ctnrCode, string position, string taskCode, string priority)
- //{
- // return GenAgvSchedulingTask("iwms_third", ctnrCode, "4", new List<positionCodeClass>()
- // {
- // new positionCodeClass(){ //取货机台
- // positionCode=position,
- // type="00"
- // },
- // new positionCodeClass(){ //放货站点
- // positionCode="JT4",
- // type="00"
- // }
- // }, priority, taskCode, "PT04", "1");
- //}
- //public static GenAgvSchedulingTaskResponse 搬运_wms(string ctnrCode, string position, string taskCode, string priority)
- //{
- // return GenAgvSchedulingTask("iwms_third", ctnrCode, "4", new List<positionCodeClass>()
- // {
- // new positionCodeClass(){ //取货机台
- // positionCode="JT1",
- // type="00"
- // },
- // new positionCodeClass(){ //放货站点
- // positionCode=position,
- // type="00"
- // }
- // }, priority, taskCode, "PT03", "1");
- //}
- ///// <summary>
- ///// Agv任务单生成接口
- ///// </summary>
- ///// <param name="clienCode">客户端编号</param>
- ///// <param name="ctnrCode">容器编号</param>
- ///// <param name="ctnrTyp">容器类型</param>
- ///// <param name="positionCodePath">路径</param>
- ///// <param name="priority">优先级</param>
- ///// <param name="taskCode">任务单号</param>
- ///// <param name="taskType">任务类型</param>
- ///// <param name="hjTaskTy">合金任务模板</param>
- ///// <returns></returns>
- ///// <exception cref="KnownException"></exception>
- //public static GenAgvSchedulingTaskResponse GenAgvSchedulingTask(string clienCode,string ctnrCode,string ctnrTyp, List<positionCodeClass> positionCodePath, string priority, string taskCode, string taskType, string hjTaskTy)
- //{
- // var res = APICaller.CallApi2<GenAgvSchedulingTaskResponse>("http://10.16.237.230:8181/rcms/services/rest/hikRpcService/genAgvSchedulingTask", new GenAgvSchedulingTaskRequest
- // {
- // clientCode = clienCode,
- // ctnrCode = ctnrCode,
- // ctnrTyp = ctnrTyp,
- // interfaceName = "genAgvSchedulingTask",
- // positionCodePath = positionCodePath,
- // priority = priority,
- // reqCode = Guid.NewGuid().ToString().Replace("-", ""),
- // taskCode = taskCode,
- // taskTyp = taskType,
- // hjTaskTy = hjTaskTy,
- // tokenCode = "56898661ea976b748f328cefa6960434",
- // });
- // if (res.code != AgvResponseCode.Success)
- // {
- // throw new KnownException(res.message, LogLevelEnum.High);
- // }
- // return res;
- //}
- #endregion 任务单生成
- #region 任务单生成测试
- /// <summary>
- /// 盘条入库
- /// </summary>
- /// <param name="position1">取货位置</param>
- /// <param name="position2">下个位置</param>
- /// <param name="position3">终点位置</param>
- /// <param name="ctnrCode">容器编码</param>
- /// <param name="taskCode">agv任务号</param>
- /// <param name="priority">优先级</param>
- /// <returns></returns>
- public static GenAgvSchedulingTaskResponse 盘条入库(string position1,string position2,string position3, string ctnrCode, string taskCode, string priority)
- {
- return GenAgvSchedulingTask("iwms_third", ctnrCode, "4", new List<positionCodeClass>()
- {
- new positionCodeClass(){ //取货机台
- positionCode=position1,
- type="00"
- },
- new positionCodeClass(){ //巷道分配点
- positionCode=position2,
- type="00"
- },
- new positionCodeClass(){ //预分配终点
- positionCode=position3,
- type="00"
- }
- }, priority, taskCode, "ZTGT30", "1");
- }
- /// <summary>
- /// 缓存区到出库口
- /// </summary>
- /// <param name="ctnrCode">容器编码</param>
- /// <param name="position1">取货位置</param>
- /// <param name="position2">放货位置</param>
- /// <param name="taskCode">任务号</param>
- /// <param name="priority">优先级</param>
- /// <returns></returns>
- public static GenAgvSchedulingTaskResponse 搬运_wmsEnd(string ctnrCode, string position1, string position2, string taskCode, string priority)
- {
- return GenAgvSchedulingTask("iwms_third", ctnrCode, "4", new List<positionCodeClass>()
- {
- new positionCodeClass(){ //取货机台
- positionCode=position1,
- type="00"
- },
- new positionCodeClass(){ //放货站点
- positionCode=position2,
- type="00"
- }
- }, priority, taskCode, "PT02", "1");
- }
- public static GenAgvSchedulingTaskResponse 搬运_wmsStart(string ctnrCode, string position1, string position2, string taskCode, string priority)
- {
- return GenAgvSchedulingTask("iwms_third", ctnrCode, "4", new List<positionCodeClass>()
- {
- new positionCodeClass(){ //取货机台
- positionCode=position1,
- type="00"
- },
- new positionCodeClass(){ //放货站点
- positionCode=position2,
- type="00"
- }
- }, priority, taskCode, "PT03", "1");
- }
- //取放都校验
- public static GenAgvSchedulingTaskResponse 搬运(string ctnrCode, string position1, string position2, string taskCode, string priority)
- {
- return GenAgvSchedulingTask("iwms_third", ctnrCode, "4", new List<positionCodeClass>()
- {
- new positionCodeClass(){ //取货机台
- positionCode=position1,
- type="00"
- },
- new positionCodeClass(){ //放货站点
- positionCode=position2,
- type="00"
- }
- }, priority, taskCode, "PT04", "1");
- }
- public static GenAgvSchedulingTaskResponse 出库搬运_wms(string ctnrCode, string position1, string position2, string taskCode, string priority)
- {
- return GenAgvSchedulingTask("iwms_third", ctnrCode, "4", new List<positionCodeClass>()
- {
- new positionCodeClass(){ //取货机台
- positionCode=position1,
- type="00"
- },
- new positionCodeClass(){ //放货站点
- positionCode=position2,
- type="00"
- }
- }, priority, taskCode, "PT05", "1");
- }
- /// <summary>
- /// 叫料出库
- /// </summary>
- /// <param name="ctnrCode">容器编码</param>
- /// <param name="position1">取货位置</param>
- /// <param name="position2">放货位置</param>
- /// <param name="taskCode">任务号</param>
- /// <param name="priority">优先级</param>
- /// <returns></returns>
- public static GenAgvSchedulingTaskResponse 叫料出库(string ctnrCode, string position1, string position2, string taskCode, string priority)
- {
- return GenAgvSchedulingTask("iwms_third", ctnrCode, "4", new List<positionCodeClass>()
- {
- new positionCodeClass(){ //取货机台
- positionCode=position1,
- type="00"
- },
- new positionCodeClass(){ //取货机台
- positionCode="DD4",
- type="00"
- },
- new positionCodeClass(){ //放货站台
- positionCode=position2,
- type="00"
- }
- }, priority, taskCode, "PT05", "1");
- }
- /// <summary>
- /// Agv任务单生成接口
- /// </summary>
- /// <param name="clienCode">客户端编号</param>
- /// <param name="ctnrCode">容器编号</param>
- /// <param name="ctnrTyp">容器类型</param>
- /// <param name="positionCodePath">路径</param>
- /// <param name="priority">优先级</param>
- /// <param name="taskCode">任务单号</param>
- /// <param name="taskType">任务类型</param>
- /// <param name="hjTaskTy">合金任务模板</param>
- /// <returns></returns>
- /// <exception cref="KnownException"></exception>
- public static GenAgvSchedulingTaskResponse GenAgvSchedulingTask(string clienCode, string ctnrCode, string ctnrTyp, List<positionCodeClass> positionCodePath, string priority, string taskCode, string taskType, string hjTaskTy)
- {
- var res = APICaller.CallApi2<GenAgvSchedulingTaskResponse>("http://10.16.237.230:8181/rcms/services/rest/hikRpcService/genAgvSchedulingTask", new GenAgvSchedulingTaskRequest
- {
- clientCode = clienCode,
- ctnrCode = ctnrCode,
- ctnrTyp = ctnrTyp,
- interfaceName = "genAgvSchedulingTask",
- positionCodePath = positionCodePath,
- priority = priority,
- reqCode = Guid.NewGuid().ToString().Replace("-", ""),
- taskCode = taskCode,
- taskTyp = taskType,
- hjTaskTy = hjTaskTy,
- tokenCode = "56898661ea976b748f328cefa6960434",
- });
- if (res.code != AgvResponseCode.Success)
- {
- throw new KnownException(res.message, LogLevelEnum.High);
- }
- return res;
- }
- #endregion
- #region 继续执行任务
- /// <summary>
- /// 继续执行任务
- /// </summary>
- /// <param name="taskCode">AGV任务号</param>
- /// <param name="nextPositionCode">下一个地址</param>
- /// <returns>接口返回结果</returns>
- /// <exception cref="KnownException"></exception>
- public static ContinueTaskResponse ContinueTask(string taskCode, string nextPositionCode)
- {
- var res = APICaller.CallApi2<ContinueTaskResponse>("http://10.16.237.230:8181/rcms/services/rest/hikRpcService/continueTask", new ContinueTaskRequest
- {
- reqCode = Guid.NewGuid().ToString().Replace("-", ""),
- taskCode = taskCode,
- nextPositionCode = new positionCodeClass()
- {
- positionCode = nextPositionCode,
- type = "00"
- }
- });
- if (res.code != AgvResponseCode.Success)
- {
- throw new KnownException(res.message, LogLevelEnum.High);
- }
- return res;
- }
- #endregion
- /// <summary>
- /// 取消任务
- /// </summary>
- /// <param name="AGVtaskCode">AGV任务号</param>
- /// <returns></returns>
- /// <exception cref="KnownException"></exception>
- public static CancelTaskResponse CancelAgvTask(string AGVtaskCode)
- {
- var res = APICaller.CallApi2<CancelTaskResponse>(AgvUrl + "/rcms/services/rest/hikRpcService/cancelTask", new CancelTaskRequest
- {
- reqCode = Guid.NewGuid().ToString().Replace("-", ""),
- taskCode = AGVtaskCode,
- forceCancel = "0",
- });
- if (res.code != AgvResponseCode.Success)
- {
- throw new KnownException(res.message, LogLevelEnum.High);
- }
- return res;
- }
- /// <summary>
- /// AGV取消任务验证
- /// </summary>
- /// <param name="sRes"></param>
- /// <param name="id"></param>
- /// <param name="agvTask">需要取消任务的AGV任务号</param>
- /// <returns></returns>
- public static CancelTaskResponse? CancelAgvTask(SRes<HandleTaskResponse> sRes, int id, string agvTask)
- {
- try
- {
- var res = AgvApi.CancelAgvTask(agvTask);
- return res;
- }
- catch (Exception ex)
- {
- sRes.ResDataList.Add(new HandleTaskResponse()
- {
- IsSuccess = false,
- TaskNo = id,
- Message = $"AGV错误:{ex.Message}",
- });
- return null;
- }
- }
- }
- }
|