| | |
| | | using HH.WCS.DaYang.dispatch; |
| | | using HH.WCS.DaYang.process; |
| | | using HH.WCS.DaYang.util; |
| | | using HH.WCS.DaYang.wms; |
| | | using Newtonsoft.Json; |
| | | using System.Collections.Generic; |
| | | using System.Threading.Tasks; |
| | | using System.Web.Http; |
| | | using static HH.WCS.DaYang.api.ApiModel; |
| | | using static HH.WCS.DaYang.api.OtherModel; |
| | | using static System.Net.WebRequestMethods; |
| | | |
| | | namespace HH.WCS.DaYang.api { |
| | | namespace HH.WCS.DaYang.api |
| | | { |
| | | /// <summary> |
| | | /// mobox3调用,脚本中调用 |
| | | /// </summary> |
| | | public class MoboxController : System.Web.Http.ApiController { |
| | | public class MoboxController : System.Web.Http.ApiController |
| | | { |
| | | |
| | | /// <summary> |
| | | /// 任务暂停的请求 |
| | |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public SimpleResult PauseTask() { |
| | | public SimpleResult PauseTask() |
| | | { |
| | | var result = new SimpleResult(); |
| | | //ManualTaskSwitch [{"Area":"AAA","State":0}] |
| | | //准备一个数据模型,作为开关,收到暂停请求后,打开,后续相关流程的任务不再推送 |
| | |
| | | //收到暂停请求后, |
| | | return result; |
| | | } |
| | | public SimpleResult RecoverTask() { |
| | | public SimpleResult RecoverTask() |
| | | { |
| | | var result = new SimpleResult(); |
| | | //ManualTaskSwitch [{"Area":"AAA","State":0}] |
| | | |
| | | |
| | | return result; |
| | | } |
| | | |
| | |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public SimpleResult CancelTask(MoboxTaskBase model) { |
| | | public SimpleResult CancelTask(MoboxTaskBase model) |
| | | { |
| | | var result = new SimpleResult(); |
| | | var task = WCSHelper.GetTask(model.TaskNo); |
| | | if (task != null) { |
| | | if (task.N_B_STATE == 0) { |
| | | if (task != null) |
| | | { |
| | | if (task.N_B_STATE == 0) |
| | | { |
| | | //等待直接修改状态为取消 |
| | | WCSHelper.UpdateStatus(model.TaskNo, 4); |
| | | result.resultMsg = "任务等待,直接取消"; |
| | | } |
| | | else if (task.N_B_STATE != 3 && task.N_B_STATE != 4) { |
| | | //已推送但是没有完成或者取消,通知hosttoagv |
| | | NDCHelper.Cancel(task.S_CODE.Trim()); |
| | | result.resultMsg = "任务取消已经发送给小车"; |
| | | else if (task.N_B_STATE != 3 && task.N_B_STATE != 4) |
| | | { |
| | | var url = Settings.tableUrls.Find(a => a.id == 2); |
| | | if (url != null) |
| | | { |
| | | HttpHelper http = new HttpHelper(); |
| | | var CancelResult = http.CancelTask(task, url.url); |
| | | if (CancelResult != null && CancelResult.Code == 200) |
| | | { |
| | | WCSHelper.UpdateStatus(model.TaskNo, 4); |
| | | result.resultMsg = "任务取消已下发"; |
| | | } |
| | | else |
| | | { |
| | | result.resultMsg = "任务取消失败"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"任务取消,未找到对应取消任务接口,请检查配置文件"); |
| | | } |
| | | |
| | | } |
| | | else { |
| | | else |
| | | { |
| | | result.resultCode = 1; |
| | | result.resultMsg = "任务已结束"; |
| | | } |
| | | } |
| | | else { |
| | | else |
| | | { |
| | | result.resultCode = 1; |
| | | result.resultMsg = "任务不存在"; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 任务强制完成(目前支持ndc) |
| | | /// 叠盘机状态切换 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public SimpleResult CompleteTask(MoboxTaskBase model) { |
| | | public SimpleResult MoboxChangeStatus(MoboxChangeStatus model) |
| | | { |
| | | var result = new SimpleResult(); |
| | | //切换叠盘机状态,去调用wcs接口 |
| | | HttpHelper http = new HttpHelper(); |
| | | var url = Settings.tableUrls.Find(a => a.id == 5); |
| | | if (url != null) |
| | | { |
| | | var changeResult = http.ChangeStatus(model.Type, url.url); |
| | | if (changeResult.Code == 200) |
| | | { |
| | | result.resultCode = 0; |
| | | result.resultMsg = "切换成功"; |
| | | } |
| | | else |
| | | { |
| | | result.resultCode = changeResult.Code; |
| | | result.resultMsg = "切换失败:" + result.resultMsg; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.resultCode = 1; |
| | | result.resultMsg = "根据配置文件未获取到叠盘机状态切换接口,请检查配置文件"; |
| | | } |
| | | return result; |
| | | } |
| | | /// <summary> |
| | | /// 任务强制完成 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public SimpleResult CompleteTask(MoboxTaskBase model) |
| | | { |
| | | var result = new SimpleResult(); |
| | | var mst = WCSHelper.GetTask(model.TaskNo); |
| | | if (mst != null) { |
| | | if (!WCSHelper.CheckActionRecordExist(mst.S_CODE, 4)) |
| | | { |
| | | //CacheBitCancelUpdate(mst); |
| | | |
| | | //等待直接修改状态为取消 |
| | | WCSHelper.UpdateStatus(model.TaskNo, 4); |
| | | |
| | | //起点终点解绑 删除托盘表托盘 |
| | | TaskProcess.CacheBitUpdate(mst, true); |
| | | TaskProcess.CacheBitCancelUpdate(mst); |
| | | } |
| | | else |
| | | { |
| | | //如果取货完成,开始卸货,卸货完成取消任务,则让任务直接强制完成 |
| | | //CacheBitUpdate(mst, false); |
| | | //等待直接修改状态为取消 |
| | | WCSHelper.UpdateStatus(model.TaskNo,3); |
| | | TaskProcess.CacheBitUpdate(mst, false); |
| | | |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.resultCode = 1; |
| | | result.resultMsg = $"根据任务号{model.TaskNo}未找到对应任务"; |
| | | } |
| | | //非成品取消工单,任务为取货完成直接失败 删除托盘 |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 修改任务优先级 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public SimpleResult changePriority(ChangePriorityModel model) |
| | | { |
| | | |
| | | LogHelper.Info("changePriority 接收:" + JsonConvert.SerializeObject(model), "API"); |
| | | var result = new SimpleResult(); |
| | | //切换叠盘机状态,去调用wcs接口 |
| | | HttpHelper http = new HttpHelper(); |
| | | var url = Settings.tableUrls.Find(a => a.id == 6); |
| | | if (url != null) |
| | | { |
| | | var changeResult = http.ChangePriority(model.TaskNo,model.Priority, url.url); |
| | | if (changeResult.Code == 200) |
| | | { |
| | | result.resultCode = 0; |
| | | result.resultMsg = "修改成功"; |
| | | } |
| | | else |
| | | { |
| | | result.resultCode = changeResult.Code; |
| | | result.resultMsg = "修改失败:" + result.resultMsg; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.resultCode = 1; |
| | | result.resultMsg = "根据配置文件未获取到修改任务优先级接口,请检查配置文件"; |
| | | } |
| | | |
| | | LogHelper.Info("changePriority 返回:" + JsonConvert.SerializeObject(result), "API"); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 码盘校验 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public SimpleResult PalletSorting(PalletSorting model) { |
| | | return ApiHelper.PalletSorting(model); |
| | | } |
| | | /// <summary> |
| | | /// 码盘校验不带上架(入库)单号 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public SimpleResult PalletSorting1(PalletSorting1 model) { |
| | | return ApiHelper.PalletSorting1(model); |
| | | } |
| | | /// <summary> |
| | | /// pda入库申请 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public SimpleResult Instock(InstockInfo model) { |
| | | return ApiHelper.Instock(model); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 发货单执行 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public SimpleResult ShippingOrderExecute(ShippingOrderCheck model) { |
| | | return ApiHelper.ShippingOrderExecute(model); |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 分拣单执行 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public SimpleResult SortingOrderExecute(SortingOrderCheck model) { |
| | | return ApiHelper.SortingOrderExecute(model); |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 分拣结果确认(前端拦截数量不可以超过分拣明细中 F_QTY-F_ACC_SR_QTY的数量) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public SimpleResult SortingResultCheck(List<SortingResultCheck> models) { |
| | | return ApiHelper.SortingResultCheck(models); |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 判断是否是整托分拣 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public SimpleResult CheckSortingWholeCntr(CheckSortingWholeCntr model) { |
| | | return ApiHelper.CheckSortingWholeCntr(model); |
| | | |
| | | } |
| | | } |
| | | } |