using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using HH.WCS.Mobox3.DSZSH.models; using Newtonsoft.Json; namespace HH.WCS.Mobox3.DSZSH.util { /// /// 打印日志内容构造器 /// public static class LogBuilder { /// /// 没有找到起点货位 /// /// /// lockState - 锁状态,默认为0,小于0时忽略
/// curNum - 当前数量,默认为-1,小于0时忽略
/// areas - 所在库区列表,默认为null,为null或为空时忽略
/// name - 货位名称,默认为null,为null或为空时忽略 ///
/// 锁状态,默认为0,小于0时忽略 /// 当前数量,默认为-1,小于0时忽略 /// 所在库区列表,默认为null,为null或为空时忽略 /// 货位名称,默认为null,为null或为空时忽略 /// /// public static string StartLocNotFound(int @lock = 0, int curNum = -1, List areas = null, string name = null, string pre = "") { var res = string.Empty; if (string.IsNullOrEmpty(name)) { res = $"没有找到合适的起点货位!"; } else { res = $"没有找到起点货位'{name}'!"; } var req = ""; if (@lock >= 0) { req += $"锁状态='{TN_Location.GetLockStateStr(@lock)}';"; } if (curNum >= 0) { req += $"当前容器数量={curNum};"; } if (areas != null && areas.Count != 0) { req += $"所在库区=['{string.Join("','", areas)}'];"; } if (req != "") { res += "要求:" + req; } return pre + res; } /// /// 没有找到终点货位 /// /// /// lockState - 锁状态,默认为0,小于0时忽略
/// curNum - 当前数量,默认为-1,小于0时忽略
/// areas - 所在库区列表,默认为null,为null或为空时忽略
/// name - 货位名称,默认为null,为null或为空时忽略 ///
/// 锁状态,默认为0,小于0时忽略 /// 当前数量,默认为-1,小于0时忽略 /// 所在库区列表,默认为null,为null或为空时忽略 /// 货位名称,默认为null,为null或为空时忽略 /// /// public static string EndLocNotFound(int @lock = 0, int curNum = -1, List areas = null, string name = null, string pre = "") { var res = string.Empty; if (string.IsNullOrEmpty(name)) { res = $"没有找到合适的终点货位!"; } else { res = $"没有找到终点货位'{name}'!"; } var req = ""; if (@lock >= 0) { req += $"锁状态='{TN_Location.GetLockStateStr(@lock)}';"; } if (curNum >= 0) { req += $"当前容器数量={curNum};"; } if (areas != null && areas.Count != 0) { req += $"所在库区=['{string.Join("','", areas)}'];"; } if (req != "") { res += "要求:" + req; } return pre + res; } public static string CreateTaskSuccess(TN_Task task, string pre = "") { var res = $"生成任务'{task.S_TYPE}'成功!" + $"任务号='{task.S_CODE}',容器号='{task.S_CNTR_CODE}',起点='{task.S_START_LOC}',终点='{task.S_END_LOC}'"; return pre + res; } public static string CreateTaskFail(TN_Task task, string pre = "") { var res = $"生成任务'{task.S_TYPE}'失败!" + $"任务号={task.S_CODE},容器号={task.S_CNTR_CODE},起点={task.S_START_LOC},终点={task.S_END_LOC}"; return pre + res; } public static string InsertLocCntrRelFail(TN_Loc_Container locCntrRel, string pre = "") { var res = $"插入[容器货位绑定表]失败!" + JsonConvert.SerializeObject(locCntrRel); return pre + res; } public static string InsertFail(string itemName, object item, string pre = "") { var res = $"插入[{itemName}]失败!" + JsonConvert.SerializeObject(item); return pre + res; } public static string DeleteFail(string itemName, object item, string pre = "") { var res = $"删除[{itemName}]失败!" + JsonConvert.SerializeObject(item); return pre + res; } public static string UpdateStartLocLockFail(TN_Location startLoc, string pre = "") { var res = $"更新[起点货位锁状态]失败!起点='{startLoc.S_CODE}',锁状态待修改为'{startLoc.S_LOCK_STATE}'"; return pre + res; } public static string UpdateEndLocLockFail(TN_Location endLoc, string pre = "") { var res = $"更新[终点货位锁状态]失败!终点='{endLoc.S_CODE}',锁状态待修改为'{endLoc.S_LOCK_STATE}'"; return pre + res; } public static string UpdateFail(string itemName, object item, string pre = "") { var res = $"更新[{itemName}]失败!" + JsonConvert.SerializeObject(item); return pre + res; } public static string LogEx(Exception ex, string pre = "") { var res = $"发生了异常:{ex.Message}"; return pre + res; } } }