|
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
|
{
|
/// <summary>
|
/// 第三方调用的接口
|
/// </summary>
|
/*[RoutePrefix("api")]*/
|
public class WmsController : System.Web.Http.ApiController
|
{
|
/// <summary>
|
/// 1.空工装出库
|
/// 业务场景:
|
/// 1.直连流程初始化,补充空工装
|
/// 2.非直连流程,固定站台自动补充空工装
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[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 = 501;
|
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;
|
}
|
|
|
/// <summary>
|
/// 2.设备信号反馈
|
/// 业务场景:
|
/// 1.下线请求,机台生产完成后,满料工装退出机台时,WCS下发下线请求满料入库
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[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 };
|
responseResult = ApiHelper.offLineProcess(request);
|
}
|
else if (model.signalType == 3) // 读码入库请求
|
{
|
ReadCodeRequest request = new ReadCodeRequest() { loc = model.loc, cntrNo = model.cntrNo };
|
responseResult = ApiHelper.readCodeProcess(request);
|
}
|
else if (model.signalType == 5) // 异常工装入库请求
|
{
|
var container = ContainerHelper.GetCntr(model.cntrNo);
|
if (container != null)
|
{
|
ContainerHelper.UpdateCntrState(model.cntrNo, 1);
|
WMSHelper.addAlarmRecord("流程异常", "低", $"下线位:{model.cntrNo},WCS读码异常");
|
}
|
else
|
{
|
|
}
|
OffLineRequest request = new OffLineRequest() { loc = model.loc, cntrNo = model.cntrNo, jtNo = model.deviceNo };
|
responseResult = ApiHelper.offLineProcess(request);
|
}
|
}
|
catch (BusinessException be)
|
{
|
responseResult.code = 501;
|
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;
|
}
|
|
/// <summary>
|
/// 3.任务状态反馈
|
/// 业务场景:WCS在执行任务时,回报任务状态
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[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;
|
}
|
|
/// <summary>
|
/// 3.申请终点
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[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;
|
}
|
|
/// <summary>
|
/// 4.获取托盘物料信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[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;
|
}
|
|
/// <summary>
|
/// 5.设备报警上报
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[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;
|
}
|
|
/// <summary>
|
/// 5.解绑货位
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[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;
|
}
|
|
/// <summary>
|
/// 6.绑定货位
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[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<string>() { model.cntrCode });
|
LogHelper.Info("BindingLoc 出参:" + JsonConvert.SerializeObject(result), "WMS");
|
return result;
|
}
|
|
/// <summary>
|
/// 7.切换站台属性
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
/* [Route("notifyAlarm")]*/
|
public ResponseResult switchStationAttribute(SwitchStationAttributeModel model)
|
{
|
LogHelper.Info("switchStationAttribute 入参:" + JsonConvert.SerializeObject(model), "WMS");
|
ResponseResult result = new ResponseResult();
|
var bo = ApiHelper.switchStationAttribute(model);
|
if (!bo)
|
{
|
result.code = 201;
|
}
|
LogHelper.Info("switchStationAttribute 出参:" + JsonConvert.SerializeObject(result), "WMS");
|
return result;
|
}
|
|
/// <summary>
|
/// 8.WCS反馈货位状态
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[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;
|
}
|
|
public class LocStateFeedBackModel
|
{
|
public string loc_code { get; set; } // 站台编码
|
public string type { get; set; } // 请求类型 1 允许取货 2 允许放货
|
public string req_no { get; set; } // 站台编码
|
}
|
|
public class SwitchStationAttributeModel
|
{
|
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 endLocCode { get; set; }
|
}
|
}
|
}
|