using HH.WCS.Mobox3.FJJT.wms; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Web.Http; using static HH.WCS.Mobox3.FJJT.api.ApiHelper; using static HH.WCS.Mobox3.FJJT.api.ApiModel; using static HH.WCS.Mobox3.FJJT.util.ExcetionHelper; namespace HH.WCS.Mobox3.FJJT.api { /// /// 第三方调用的接口 /// /*[RoutePrefix("api")]*/ public class WmsController : System.Web.Http.ApiController { /// /// 1.空工装出库 /// 业务场景:直连流程初始化,补充缓存位的空工装 /// /// /// [HttpPost] /* [Route("emptyPalletOutStock")]*/ public ResponseResult emptyPalletOutStock(OutStockModel model) { LogHelper.Info("emptyPalletOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS"); ResponseResult responseResult = new ResponseResult(); try { responseResult = ApiHelper.emptyPalletOutStock(model); } catch (BusinessException be) { responseResult.code = 201; responseResult.msg = be.Message; } catch (Exception ex) { responseResult.code = 500; responseResult.msg = $"WMS内部错误,请联系开发人员处理"; WMSHelper.addAlarmRecord("系统错误", "高", $"WMS内部错误: 空工装出库错误,错误原因:{ex.Message}"); } LogHelper.Info("emptyPalletOutStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS"); return responseResult; } /// /// 2.设备信号反馈 /// 业务场景: /// 1.下线请求,机台生产完成后,满料工装退出机台时,WCS下发下线请求满料入库 /// /// /// [HttpPost] /*[Route("notifyDeviceSignal")]*/ public ResponseResult notifyDeviceSignal(DeviceSignalFeedbackModel model) { LogHelper.Info("notifyDeviceSignal 入参:" + JsonConvert.SerializeObject(model), "WMS"); ResponseResult responseResult = new ResponseResult(); try { if (model.signalType == 1) // 正常物料下线入库请求 { OffLineRequest request = new OffLineRequest() { loc = model.loc, cntrNo = model.cntrNo, jtNo = model.deviceNo, isNormal = true}; responseResult = ApiHelper.offLineProcess(request); } else if (model.signalType == 3) // 读码入库请求 { ReadCodeRequest request = new ReadCodeRequest() { loc = model.loc, cntrNo = model.cntrNo ,taskNo = model.taskNo }; responseResult = ApiHelper.readCodeProcess(request); } else if (model.signalType == 5) // 异常工装入库请求 { OffLineRequest request = new OffLineRequest() { loc = model.loc, cntrNo = model.cntrNo, jtNo = model.deviceNo , isNormal = false}; responseResult = ApiHelper.offLineProcess(request); } } catch (BusinessException be) { responseResult.code = 201; responseResult.msg = be.Message; } catch (Exception ex) { responseResult.code = 500; responseResult.msg = $"WMS内部错误,请联系开发人员处理"; WMSHelper.addAlarmRecord("系统错误", "高", $"WMS内部错误: 设备信号反馈错误,错误原因:{ex.Message}"); } LogHelper.Info("notifyDeviceSignal 出参:" + JsonConvert.SerializeObject(responseResult), "WMS"); return responseResult; } /// /// 3.任务状态反馈 /// 业务场景:WCS在执行任务时,回报任务状态 /// /// /// [HttpPost] /*[Route("notifyTaskStatus")]*/ public ResponseResult notifyTaskStatus(TaskStatusFeedbackModel model) { LogHelper.Info("notifyTaskStatus 入参:" + JsonConvert.SerializeObject(model), "WMS"); var result = ApiHelper.taskStatusFeedback(model); LogHelper.Info("notifyTaskStatus 出参:" + JsonConvert.SerializeObject(result), "WMS"); return result; } /// /// 3.申请终点 /// /// /// [HttpPost] /* [Route("applyDest")]*/ public ResponseResult applyDest(ApplyDestinationModel model) { LogHelper.Info("applyDest 入参:" + JsonConvert.SerializeObject(model), "WMS"); var result = ApiHelper.applyDest(model); LogHelper.Info("applyDest 出参:" + JsonConvert.SerializeObject(result), "WMS"); return result; } /// /// 4.获取托盘物料信息 /// /// /// [HttpPost] /* [Route("findTrayItemInfo")]*/ public ResponseResult findTrayItemInfo(FindTrayItemInfoModel model) { LogHelper.Info("findTrayItemInfo 入参:" + JsonConvert.SerializeObject(model), "WMS"); var result = ApiHelper.findTrayItemInfo(model); LogHelper.Info("findTrayItemInfo 出参:" + JsonConvert.SerializeObject(result), "WMS"); return result; } /// /// 5.设备报警上报 /// /// /// [HttpPost] /* [Route("notifyAlarm")]*/ public ResponseResult notifyAlarm(DeviceAlertorFeedbackModel model) { LogHelper.Info("notifyAlarm 入参:" + JsonConvert.SerializeObject(model), "WMS"); var result = ApiHelper.notifyAlarm(model); LogHelper.Info("notifyAlarm 出参:" + JsonConvert.SerializeObject(result), "WMS"); return result; } /// /// 5.解绑货位 /// /// /// [HttpPost] /* [Route("notifyAlarm")] */ public ResponseResult unBindingLoc(LocModel model) { LogHelper.Info("UnBindingLoc 入参:" + JsonConvert.SerializeObject(model), "WMS"); ResponseResult result = new ResponseResult(); LocationHelper.UnBindingLoc(model.locCode); LogHelper.Info("UnBindingLoc 出参:" + JsonConvert.SerializeObject(result), "WMS"); return result; } /// /// 6.绑定货位 /// /// /// [HttpPost] /*[Route("notifyAlarm")]*/ public ResponseResult bindingLoc(LocCntrModel model) { LogHelper.Info("BindingLoc 入参:" + JsonConvert.SerializeObject(model), "WMS"); ResponseResult result = new ResponseResult(); LocationHelper.BindingLoc(model.locCode, new List() { model.cntrCode }); LogHelper.Info("BindingLoc 出参:" + JsonConvert.SerializeObject(result), "WMS"); return result; } /// /// 7.切换站台属性 /// /// /// [HttpPost] /* [Route("notifyAlarm")]*/ public ResponseResult switchStationAttribute(SwitchStationAttributeModel model) { LogHelper.Info("switchStationAttribute 入参:" + JsonConvert.SerializeObject(model), "WMS"); ResponseResult result = new ResponseResult(); result = ApiHelper.switchStationAttribute(model); LogHelper.Info("switchStationAttribute 出参:" + JsonConvert.SerializeObject(result), "WMS"); return result; } /// /// 8.WCS反馈货位状态 /// /// /// [HttpPost] /* [Route("notifyAlarm")]*/ public ResponseResult locStateFeedBack(LocStateFeedBackModel model) { LogHelper.Info("locStateFeedBack 入参:" + JsonConvert.SerializeObject(model), "WMS"); ResponseResult result = new ResponseResult(); bool bo = ApiHelper.locStateFeedBack(model); if (!bo) { result.code = 201; } LogHelper.Info("locStateFeedBack 出参:" + JsonConvert.SerializeObject(result), "WMS"); return result; } //--------------------------------- 提供给斜裁的接口 -------------------------------- /// /// 9.斜裁出库任务 /// /// /// [HttpPost] /* [Route("notifyAlarm")]*/ public ResponseResult createXcItemOutStockTask(XcItemOutStockModel model) { LogHelper.Info("XcItemOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS"); ResponseResult result = new ResponseResult(); result = ApiHelper.createXcItemOutStockTask(model); LogHelper.Info("XcItemOutStock 出参:" + JsonConvert.SerializeObject(result), "WMS"); return result; } public class XcItemOutStockModel { public string reqId { get; set; } public string reqTime { get; set; } public string startLoc { get; set; } public string eqNo { get; set; } // 设备号 public string palletId { get; set; } // 托盘号 /*public string lotName { get; set; } // 批次条码 public string yclBatch { get; set; } // 原材料批次号 public string materialCode { get; set; } // 物料编码 public float qty { get; set; } // 物料数量 public string productionDate { get; set; } // 生产日期(yyyy-MM-dd HH:mm:ss) public string qcStatus { get; set; } // 检验状态 0:未检验 1:合格,2:不合格 public string shelfLifeDate { get; set; } // 最长停放日期 public string minShelfLife_Date { get; set; } // 最小停放日期*/ } public class LocStateFeedBackModel { public string reqId { get; set; } public string reqTime { get; set; } public string loc_code { get; set; } // 站台编码 public string type { get; set; } // 请求类型 1 允许取货 2 允许放货 public string req_no { get; set; } // 站台编码 } public class SwitchStationAttributeModel { public string reqId { get; set; } public string reqTime { get; set; } public string locCode { get; set; } // 站台编码 public string signalType { get; set; } // 1.agv上料模式 2.人工模式 } public class LocCntrModel { public string locCode { get; set; } public string cntrCode { get; set; } } public class OutStockModel { public string reqId { get; set; } public string reqTime { get; set; } public string endLocCode { get; set; } } } }