| | |
| | | using HH.WCS.HangYang.api; |
| | | using HH.WCS.HangYang.LISTA.models; |
| | | using HH.WCS.HangYang.LISTA.models.wms; |
| | | using HH.WCS.HangYang.models.other; |
| | | using HH.WCS.HangYang.util; |
| | | using Newtonsoft.Json; |
| | |
| | | using System.Linq.Expressions; |
| | | using System.Reflection; |
| | | using System.Runtime.Remoting.Messaging; |
| | | using System.Security.Cryptography; |
| | | using System.Security.Cryptography.X509Certificates; |
| | | using System.Text; |
| | | using System.Threading; |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | #region 杭氧WMS帮助方法 |
| | | /// <summary> |
| | | /// 新增入库单 |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 杭氧升降量表帮助方法 |
| | | /// <summary> |
| | | /// MD5加密 |
| | | /// </summary> |
| | | /// <param name="sInput"></param> |
| | | /// <returns></returns> |
| | | public static string GetMd5FromString(string sInput) |
| | | { |
| | | var lstData = Encoding.GetEncoding("utf-8").GetBytes(sInput); |
| | | var lstHash = new MD5CryptoServiceProvider().ComputeHash(lstData); |
| | | var result = new StringBuilder(32); |
| | | for (int i = 0; i < lstHash.Length; i++) |
| | | { |
| | | result.Append(lstHash[i].ToString("x2").ToUpper()); |
| | | } |
| | | return result.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据任务升量 |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | internal static void AddChange(WCSTask task) |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var result = true; |
| | | try |
| | | { |
| | | var itemlist = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE == task.S_CNTR_CODE).ToList(); |
| | | if (itemlist.Count > 0) |
| | | { |
| | | var url = Settings.MoboxSeverUrl + "inventory/AddChange"; |
| | | //仓库量表升量 |
| | | var req = new AddChangeModel { op_type = 5 }; |
| | | //库区量表升量 |
| | | var req2 = new AddChangeModel { op_type = 6 }; |
| | | itemlist.ForEach(a => |
| | | { |
| | | LogHelper.Info($"填充数据"); |
| | | LogHelper.Info($"添加仓库量表数据 仓库{task.S_END_WH} 物料编码{a.S_ITEM_CODE} 物料名称{a.S_ITEM_NAME} 数量{a.F_QTY}"); |
| | | req.item_info.Add(new AddChangeModel.itemModel |
| | | { |
| | | wh_code = task.S_END_WH, |
| | | item_code = a.S_ITEM_CODE, |
| | | item_name = a.S_ITEM_NAME, |
| | | qty = a.F_QTY |
| | | }); |
| | | LogHelper.Info($"添加库区量表数据 库区{task.S_END_AREA} 物料编码{a.S_ITEM_CODE} 物料名称{a.S_ITEM_NAME} 数量{a.F_QTY}"); |
| | | req2.item_info.Add(new AddChangeModel.itemModel |
| | | { |
| | | wh_code = task.S_END_WH, |
| | | area_code = task.S_END_AREA, |
| | | item_code = a.S_ITEM_CODE, |
| | | item_name = a.S_ITEM_NAME, |
| | | qty = a.F_QTY |
| | | }); |
| | | }); |
| | | var reqData = JsonConvert.SerializeObject(req); |
| | | var AppKey = Settings.AppKey; |
| | | var AppSecret = Settings.AppSecret; |
| | | var ReqTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); |
| | | //var ReqTime = GetTimeStamp(DateTime.Now.AddHours(-8), 1, 2); |
| | | LogHelper.Info($"加密前 AppKey={AppKey} AppSecret={AppSecret} ReqTime={ReqTime}"); |
| | | var ReqVerify = GetMd5FromString(AppKey + AppSecret + ReqTime); |
| | | LogHelper.Info($"加密后 AppKey={AppKey} AppSecret={AppSecret} ReqTime={ReqTime} ReqVerify={ReqVerify} url={url} req={reqData}"); |
| | | var res = new HttpHelper().WebPost(url, reqData, "application/json", AppKey, ReqTime, ReqVerify); |
| | | if (!string.IsNullOrEmpty(res)) |
| | | { |
| | | LogHelper.Info($"mobox 仓库升量接口返回 {res}"); |
| | | var moboxres = JsonConvert.DeserializeObject<moboxres>(res); |
| | | if (moboxres.err_code != 0) |
| | | { |
| | | result = false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"mobox 仓库升量接口返回为空"); |
| | | result = false; |
| | | } |
| | | var reqData2 = JsonConvert.SerializeObject(req2); |
| | | var ReqTime2 = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); |
| | | //var ReqTime2 = GetTimeStamp(DateTime.Now.AddHours(-8), 1, 2); |
| | | LogHelper.Info($"加密前 AppKey={AppKey} AppSecret={AppSecret} ReqTime={ReqTime2}"); |
| | | var ReqVerify2 = GetMd5FromString(AppKey + AppSecret + ReqTime2); |
| | | LogHelper.Info($"加密后 AppKey={AppKey} AppSecret={AppSecret} ReqTime={ReqTime2} ReqVerify={ReqVerify2} url={url} req={reqData2}"); |
| | | var res2 = new HttpHelper().WebPost(url, reqData2, "application/json", AppKey, ReqTime2, ReqVerify2); |
| | | if (!string.IsNullOrEmpty(res2)) |
| | | { |
| | | LogHelper.Info($"mobox 库区升量接口返回 {res2}"); |
| | | var moboxres = JsonConvert.DeserializeObject<moboxres>(res); |
| | | if (moboxres.err_code != 0) |
| | | { |
| | | result = false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"mobox 库区升量接口返回为空"); |
| | | result = false; |
| | | } |
| | | |
| | | } |
| | | else LogHelper.Info($"托盘{task.S_CNTR_CODE} 在容器货品明细中找不到数据"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Error($"仓库升量异常 异常信息={ex.Message}", ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据任务降量 |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | internal static void DeleteChange(WCSTask task) |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var result = true; |
| | | try |
| | | { |
| | | var wmstask = db.Queryable<WMSTask>().Where(a => a.S_CODE == task.S_OP_CODE).First(); |
| | | if (wmstask != null) |
| | | { |
| | | var itemlist = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE == task.S_CNTR_CODE).ToList(); |
| | | if (itemlist.Count > 0) |
| | | { |
| | | var url = Settings.MoboxSeverUrl + "inventory/AddChange"; |
| | | //仓库量表升量 |
| | | var req = new AddChangeModel { op_type = 4 }; |
| | | //库区量表升量 |
| | | var req2 = new AddChangeModel { op_type = 7 }; |
| | | itemlist.ForEach(a => |
| | | { |
| | | LogHelper.Info($"填充数据"); |
| | | LogHelper.Info($"减仓库量表数据 仓库{task.S_END_WH} 物料编码{a.S_ITEM_CODE} 物料名称{a.S_ITEM_NAME} 数量{a.F_QTY}"); |
| | | req.item_info.Add(new AddChangeModel.itemModel |
| | | { |
| | | wh_code = wmstask.S_START_WH, |
| | | item_code = a.S_ITEM_CODE, |
| | | item_name = a.S_ITEM_NAME, |
| | | qty = a.F_QTY |
| | | }); |
| | | LogHelper.Info($"减库区量表数据 库区{task.S_END_AREA} 物料编码{a.S_ITEM_CODE} 物料名称{a.S_ITEM_NAME} 数量{a.F_QTY}"); |
| | | req2.item_info.Add(new AddChangeModel.itemModel |
| | | { |
| | | wh_code = wmstask.S_START_WH, |
| | | area_code = wmstask.S_START_AREA, |
| | | item_code = a.S_ITEM_CODE, |
| | | item_name = a.S_ITEM_NAME, |
| | | qty = a.F_QTY |
| | | }); |
| | | }); |
| | | var reqData = JsonConvert.SerializeObject(req); |
| | | var AppKey = Settings.AppKey; |
| | | var AppSecret = Settings.AppSecret; |
| | | var ReqTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); |
| | | //var ReqTime = GetTimeStamp(DateTime.Now.AddHours(-8), 1, 2); |
| | | LogHelper.Info($"加密前 AppKey={AppKey} AppSecret={AppSecret} ReqTime={ReqTime}"); |
| | | var ReqVerify = GetMd5FromString(AppKey + AppSecret + ReqTime); |
| | | LogHelper.Info($"加密后 AppKey={AppKey} AppSecret={AppSecret} ReqTime={ReqTime} ReqVerify={ReqVerify} url={url} req={reqData}"); |
| | | var res = new HttpHelper().WebPost(url, reqData, "application/json", AppKey, ReqTime, ReqVerify); |
| | | if (!string.IsNullOrEmpty(res)) |
| | | { |
| | | LogHelper.Info($"mobox 仓库降量接口返回 {res}"); |
| | | var moboxres = JsonConvert.DeserializeObject<moboxres>(res); |
| | | if (moboxres.err_code != 0) |
| | | { |
| | | result = false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"mobox 仓库降量接口返回为空"); |
| | | result = false; |
| | | } |
| | | var reqData2 = JsonConvert.SerializeObject(req2); |
| | | var ReqTime2 = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); |
| | | //var ReqTime2 = GetTimeStamp(DateTime.Now.AddHours(-8), 1, 2); |
| | | LogHelper.Info($"加密前 AppKey={AppKey} AppSecret={AppSecret} ReqTime={ReqTime2}"); |
| | | var ReqVerify2 = GetMd5FromString(AppKey + AppSecret + ReqTime2); |
| | | LogHelper.Info($"加密后 AppKey={AppKey} AppSecret={AppSecret} ReqTime={ReqTime2} ReqVerify={ReqVerify2} url={url} req={reqData2}"); |
| | | var res2 = new HttpHelper().WebPost(url, reqData2, "application/json", AppKey, ReqTime2, ReqVerify2); |
| | | if (!string.IsNullOrEmpty(res2)) |
| | | { |
| | | LogHelper.Info($"mobox 库区降量接口返回 {res2}"); |
| | | var moboxres = JsonConvert.DeserializeObject<moboxres>(res); |
| | | if (moboxres.err_code != 0) |
| | | { |
| | | result = false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"mobox 库区降量接口返回为空"); |
| | | result = false; |
| | | } |
| | | |
| | | } |
| | | else LogHelper.Info($"托盘{task.S_CNTR_CODE} 在容器货品明细中找不到数据"); |
| | | } |
| | | else LogHelper.Info($"未找到任务{task.S_CODE} 对应的作业"); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Error($"仓库降量异常 异常信息={ex.Message}", ex); |
| | | } |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | } |
| | | } |