using HH.WCS.Mobox3.AnGang.util;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Web.Services.Description;
namespace HH.WCS.Mobox3.AnGang.dispatch {
///
/// 国自调度辅助类
///
public class HanAo {
private static readonly HttpHelper apiHelper = new HttpHelper();
private static readonly string baseUrl ="";//配置文件里获取国自调度地址
//private static readonly string logName = "hanao";
public static bool CreateOrder(TaskInfoModel model) {
var msg = "";
var result = true;
var request = JsonConvert.SerializeObject(model);
var response = apiHelper.Post(baseUrl + ":9001/wcs-admin/api/receive", request);
msg = $"[hanao-CreateOrder] request={request} response={response}";
Console.WriteLine(msg);
if (response != "") {
try {
var dataResult = JsonConvert.DeserializeObject(response);
if (dataResult.code == "0") {
result = true;
}
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
}
}
else {
msg = "[hanao-CreateOrder]创建订单失败";
Console.WriteLine(msg);
}
LogHelper.Info(msg,"杭奥");
return result;
}
public static bool CancelOrder(CancelModel model) {
bool result = false;
string msg = "";
var request = JsonConvert.SerializeObject(model);
var response = apiHelper.Post(baseUrl + ":9002/wcs-admin/api/cancel", request);
msg = $"[hanao-CancelOrder] request={request};response={response}";
Console.WriteLine(msg);
if (response != "") {
var dataResult = JsonConvert.DeserializeObject(response);
if (dataResult.code == "0") {
result = true;
}
}
else {
msg = "[hanao-CancelOrder]取消订单失败";
Console.WriteLine(msg);
}
LogHelper.Info(msg, "杭奥");
return result;
}
public static bool QueryDevice(DeviceInfoModel model) {
bool result = false;
string msg = "";
var request = JsonConvert.SerializeObject(model);
var response = apiHelper.Get(baseUrl + ":9003//wcs-admin/api/dvc-state/", request);
msg = $"[hanao-QueryDeviceResult] request={request};response={response}";
Console.WriteLine(msg);
if (response != "") {
var dataResult = JsonConvert.DeserializeObject(response);
if (dataResult.code == "0") {
result = true;
}
}
else {
msg = "[hanao-QueryOrderResult]查询订单信息失败";
Console.WriteLine(msg);
}
LogHelper.Info(msg, "杭奥");
return result;
}
public class TaskInfoModel {
///
/// 请求pk
///
public string requestPk { get; set; }
///
/// 托盘条码
///
public string contNo { get; set; }
///
/// 托盘类型
///
public string contType { get; set; } = "";
///
/// 任务类型 1-入库 2-出库 3-移库
///
public string trkType { get; set; }
///
/// 1-999(值越大优先级越高)
///
public string trkPrty { get; set; } = "1";
public string frmPos { get; set; }
public string toPos { get; set; }
public string noticeInfo { get; set; } = "";
///
/// 0-空托盘 1-实物
///
public string isFull { get; set; } = "0";
public string groupNo { get; set; } = "";
public string clientCode { get; set; } = "WMS";
///
/// 格式:2022-11-11 11:32:08
///
public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
public class HAResult {
public string code { get; set; }
public string msg { get; set; }
///
///
///
public string requestPk { get; set; }
}
public class CancelModel {
public string requestPk { get; set; }
public string contNo { get; set; }
public string clientCode { get; set; }
public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
public class DeviceInfoModel {
public string requestPk { get; set; }
public string dvcNo { get; set; }
public string clientCode { get; set; }
public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
public class TaskStateInfoModel {
public string requestPk { get; set; }
public string contNo { get; set; }
///
/// 双方系统共同定义 1-入库 2-出库 3-移库 (后续如有增加再协定)
///
public string noticeType { get; set; }
public string curPos { get; set; }
public string noticeInfo { get; set; }
///
/// 0-成功 (入库上架完成/出库下架完成/库内移库完成:移库只上报最终移库上架) 或 其他-异常码(反馈相关结果原因,WMS根据情况处理
/// 1-入库有货 2-入远近有货 3-出库无货 4-出远近有货)
///
public string code { get; set; }
public string result { get; set; }
public string clientCode { get; set; }
public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
}
}