| | |
| | | var startLoc = db.Queryable<TN_Location>() |
| | | .Where(a => a.S_CODE == model.StartLoc) |
| | | .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无" && a.C_ENABLE == "Y") |
| | | .Where(a => a.N_CURRENT_NUM == 0) |
| | | //.Where(a => a.N_CURRENT_NUM == 0) |
| | | .Where(a => Settings.Areas[0].Contains(a.S_AREA_CODE)) // 收发区 |
| | | .First(); |
| | | |
| | | if (startLoc == null) { |
| | | return BuildSimpleResult(1, $"起点位置{model.StartLoc}不存在或不满足要求:需要(1)没有锁状态(2)当前无容器(3)属于取放货区"); |
| | | return BuildSimpleResult(1, $"起点位置{model.StartLoc}不存在或不满足要求:(1)没有锁状态 (2)属于取放货区"); |
| | | } |
| | | |
| | | var locCntrRelOld = db.Queryable<TN_Loc_Container>() |
| | | .Where(c => c.S_LOC_CODE == model.StartLoc).First(); |
| | | |
| | | // 产品入库:假定用户不会将新入库物料,放到已有物料的收发货区入库 |
| | | // 新产品入库时,如果存在旧的货位绑定数据(出库遗留项目)直接删除 |
| | | TN_CG_Detail cgDetailOld = null; |
| | | if (locCntrRelOld != null) { |
| | | cgDetailOld = db.Queryable<TN_CG_Detail>() |
| | | .Where(d => d.S_CNTR_CODE == locCntrRelOld.S_CNTR_CODE).First(); |
| | | } |
| | | |
| | | // 容器 ID 和 物料 ID 未指定,由系统直接生成 |
| | |
| | | var cntId = GenerateNo("容器号", "CN"); |
| | | var cgId = GenerateNo("物料号", "CG"); |
| | | |
| | | // 初始是没有绑定信息的,先将起点位置与容器绑定,容器与物料绑定 |
| | | // 首次入库:没有绑定信息,先将起点位置与容器绑定,容器与物料绑定 |
| | | var locCntrRel = new TN_Loc_Container() { |
| | | S_LOC_CODE = startLoc.S_CODE, |
| | | S_CNTR_CODE = cntId, |
| | |
| | | S_ITEM_CODE = cgId, |
| | | S_CNTR_CODE = cntId, |
| | | }; |
| | | |
| | | startLoc.N_CURRENT_NUM = 1; |
| | | |
| | | var endLocCode = "0"; // 假的默认终点地址 |
| | | |
| | |
| | | |
| | | // 无论是否选择终点货架,都等到称重之后再计算终点货位 |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (locCntrRelOld != null) { |
| | | if (db.Deleteable<TN_Loc_Container>(locCntrRelOld).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return BuildSimpleResult(500, |
| | | $"删除货位容器关系表失败:货位{locCntrRelOld.S_LOC_CODE},容器{locCntrRelOld.S_CNTR_CODE}"); |
| | | } |
| | | } |
| | | if (cgDetailOld != null) { |
| | | if (db.Deleteable<TN_CG_Detail>(cgDetailOld).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return BuildSimpleResult(500, |
| | | $"删除旧容器货品明细表失败:容器{cgDetailOld.S_CNTR_CODE},物料{cgDetailOld.S_ITEM_CODE}"); |
| | | } |
| | | } |
| | | |
| | | if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return BuildSimpleResult(500, |
| | |
| | | } |
| | | |
| | | if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { |
| | | it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY, it.N_CURRENT_NUM }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return BuildSimpleResult(500, |
| | | $"更新起点货位锁状态失败:起点货位{startLoc.S_CODE}"); |
| | |
| | | var date = DateTime.Now.ToString("yyMMdd"); |
| | | return $"{prefix}{date}-{id.ToString().PadLeft(5, '0')}"; // 形如:CN250525-00011 |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 兼容Inbound和PartInbound的功能,备用(问题:出库后无法自动清数据,导致入库后回库) |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public static SimpleResult InboundTwoWays(InboundInfo model) { |
| | | var taskName = TaskName.产品入库; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | try { |
| | | // 起点位置必须:为空、无锁、启用、属于收发区域 |
| | | var startLoc = db.Queryable<TN_Location>() |
| | | .Where(a => a.S_CODE == model.StartLoc) |
| | | .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无" && a.C_ENABLE == "Y") |
| | | //.Where(a => a.N_CURRENT_NUM == 0) |
| | | .Where(a => Settings.Areas[0].Contains(a.S_AREA_CODE)) // 收发区 |
| | | .First(); |
| | | |
| | | if (startLoc == null) { |
| | | return BuildSimpleResult(1, $"起点位置{model.StartLoc}不存在或不满足要求:(1)没有锁状态 (2)属于取放货区"); |
| | | } |
| | | |
| | | // 容器 ID 和 物料 ID 未指定,由系统直接生成 |
| | | //var cntId = Guid.NewGuid().ToString("D"); |
| | | //var CgId = Guid.NewGuid().ToString("D"); |
| | | var cntId = GenerateNo("容器号", "CN"); |
| | | var cgId = GenerateNo("物料号", "CG"); |
| | | |
| | | var locCntrRel = db.Queryable<TN_Loc_Container>() |
| | | .Where(c => c.S_LOC_CODE == model.StartLoc).First(); |
| | | |
| | | // 只有首次入库(当前托盘未绑定在起点货位)时cgDetail设置值,并插入 |
| | | // 否则,cgDetail为空,代表是回库作业(此前有绑定过起点) |
| | | TN_CG_Detail cgDetail = null; |
| | | if (locCntrRel == null) { |
| | | // 首次入库:没有绑定信息,先将起点位置与容器绑定,容器与物料绑定 |
| | | locCntrRel = new TN_Loc_Container() { |
| | | S_LOC_CODE = startLoc.S_CODE, |
| | | S_CNTR_CODE = cntId, |
| | | }; |
| | | |
| | | cgDetail = new TN_CG_Detail() { |
| | | S_ITEM_CODE = cgId, |
| | | S_CNTR_CODE = cntId, |
| | | }; |
| | | } |
| | | |
| | | startLoc.N_CURRENT_NUM = 1; |
| | | |
| | | var endLocCode = "0"; // 假的默认终点地址 |
| | | |
| | | // 指定货位排号(不能为空、空字符串或空格) |
| | | if (model.Row != null && model.Row.Trim() != "") { |
| | | endLocCode = model.Row; // 用排号字符串当做假地址 |
| | | if (!int.TryParse(model.Row.Trim(), out int row)) { |
| | | return BuildSimpleResult(2, $"{model.Row} 不合法:无法转成整数类型"); |
| | | } |
| | | // 货架排号只能是 0 - 8 |
| | | if (row <= 0 || row > 8) { |
| | | return BuildSimpleResult(2, $"货架号 {model.Row} 必须是1-8之间的整数"); |
| | | } |
| | | } |
| | | |
| | | var task = WCSHelper.BuildInboundTask(startLoc, endLocCode, cntId); |
| | | LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | |
| | | // 无论是否选择终点货架,都等到称重之后再计算终点货位 |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (cgDetail != null) { |
| | | if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return BuildSimpleResult(500, |
| | | $"插入货位容器关系表失败:货位{locCntrRel.S_LOC_CODE},容器{locCntrRel.S_CNTR_CODE}"); |
| | | } |
| | | |
| | | if (db.Insertable<TN_CG_Detail>(cgDetail).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return BuildSimpleResult(500, |
| | | $"插入容器货品明细表失败:容器{cgDetail.S_CNTR_CODE},物料{cgDetail.S_ITEM_CODE}"); |
| | | } |
| | | } |
| | | |
| | | if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { |
| | | it.N_LOCK_STATE, |
| | | it.S_LOCK_STATE, |
| | | it.S_LOCK_OP, |
| | | it.T_MODIFY, |
| | | it.N_CURRENT_NUM |
| | | }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return BuildSimpleResult(500, |
| | | $"更新起点货位锁状态失败:起点货位{startLoc.S_CODE}"); |
| | | } |
| | | |
| | | if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return BuildSimpleResult(500, |
| | | $"生成任务 {taskName} 失败:容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLocCode} ,终点货位未指定"); |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | return BuildSimpleResult(0, |
| | | $"生成任务 {taskName} 成功:容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLocCode} ,终点货位未指定"); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | return BuildSimpleResult(1, $"发生了异常:{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// PDA选择终点货位 |
| | |
| | | var endLoc = new TN_Location(); |
| | | if (cgDetail.F_QTY > 2000) { |
| | | // 重量超过2t,报错 |
| | | if (GZRobot.UpdateInteractInfo(new UpdateInteractInfo { |
| | | type_name = "GET_DST", |
| | | interaction_info_id = int.Parse(task.S_EQ_TASK_CODE), |
| | | info_status = "error", |
| | | })) { |
| | | LogHelper.Info($"国自AGV接受超重取消信息成功", "HosttoagvTask"); |
| | | } |
| | | else { |
| | | LogHelper.Info($"国自AGV接受超重取消信息失败", "HosttoagvTask"); |
| | | } |
| | | |
| | | return BuildSimpleResult(8, $"物料重量{cgDetail.F_QTY}超过2t"); |
| | | } |
| | | else if (cgDetail.F_QTY > 1500) { |
| | |
| | | task.S_END_LOC = endLoc.S_CODE; |
| | | LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | if (GZRobot.UpdateInteractInfo(new UpdateInteractInfo { |
| | | type_name = "GET_DST", |
| | | interaction_info_id = int.Parse(task.S_EQ_TASK_CODE), |
| | | info_status = "invalid", |
| | | return_value = LocationHelper.GetAgvSite(task.S_END_LOC), // 目前使用agvsite |
| | | })) { |
| | | LogHelper.Info($"国自AGV接受终点信息成功", "HosttoagvTask"); |
| | | } |
| | | else { |
| | | LogHelper.Info($"国自AGV接受终点信息失败", "HosttoagvTask"); |
| | | } |
| | | |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_Task>(task).UpdateColumns(a => a.S_END_LOC).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 产品部分出库(WMS) |
| | | /// 产品部分出库 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | |
| | | LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | var res = GZRobot.QueryInteractInfo(3); |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { |
| | | it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 产品部分回库(WMS) |
| | | /// 产品部分回库 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | |
| | | if (startLoc == null) { |
| | | return BuildSimpleResult(2, $"起点位置 {model.startLoc} 不符合回库条件"); |
| | | } |
| | | |
| | | |
| | | var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc); |
| | | if (locCntrRel == null) { |
| | | return BuildSimpleResult(3, $"起点位置 {model.startLoc} 没有绑定容器,无可回库的物料"); |
| | |
| | | return BuildSimpleResult(2, $"任务号{model.TaskNo}不存在"); |
| | | } |
| | | |
| | | if (task.N_B_STATE == 0 && task.S_B_STATE == TN_Task.GetStateStr(0) |
| | | || task.N_B_STATE == 1 && task.S_B_STATE == TN_Task.GetStateStr(1)) { |
| | | |
| | | task.N_B_STATE = 4; |
| | | task.S_B_STATE = "取消"; |
| | | // 等待 或 已推送 时,可以取消任务 |
| | | //if (task.N_B_STATE == 0 && task.S_B_STATE == TN_Task.GetStateStr(0) |
| | | // || task.N_B_STATE == 1 && task.S_B_STATE == TN_Task.GetStateStr(1)) { |
| | | if (task.N_B_STATE == 0 || task.N_B_STATE == 1) { |
| | | |
| | | var startloc = db.Queryable<TN_Location>().First(a => a.S_CODE == task.S_START_LOC); |
| | | var endloc = db.Queryable<TN_Location>().First(a => a.S_CODE == task.S_END_LOC); |
| | |
| | | endloc.T_MODIFY = System.DateTime.Now; |
| | | } |
| | | |
| | | if (!int.TryParse(task.S_EQ_TASK_CODE, out var code)) { |
| | | return BuildSimpleResult(1, $"当前任务{task.S_CODE}没有找到对应的国自AGV orderId!"); |
| | | if (task.N_B_STATE == 1) { |
| | | if (!int.TryParse(task.S_EQ_TASK_CODE, out var code)) { |
| | | LogHelper.Info($"当前任务{task.S_CODE}没有找到对应的国自AGV orderId!"); |
| | | } |
| | | else { |
| | | var res = GZRobot.CancelGZOrder(code); |
| | | if (!res) { |
| | | LogHelper.Info($"国自AGV取消任务失败!", "HosttoagvTask"); |
| | | } |
| | | else { |
| | | LogHelper.Info($"国自AGV取消任务成功!", "HosttoagvTask"); |
| | | } |
| | | } |
| | | } |
| | | var res = GZRobot.CancelGZOrder(code); |
| | | if (!res) { |
| | | return BuildSimpleResult(2, $"国自AGV取消任务失败!"); |
| | | } |
| | | |
| | | task.N_B_STATE = 4; |
| | | task.S_B_STATE = "取消"; |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_Location>(startloc).ExecuteCommand() <= 0) { |
| | |
| | | return BuildSimpleResult(3, $"只有任务号状态为 等待 或 已推送 的任务才能取消"); |
| | | } |
| | | |
| | | //public static SimpleResult CreateCountPlan(CreateCountPlanInfo model) { |
| | | // var db = new SqlHelper<object>().GetInstance(); |
| | | // try { |
| | | |
| | | // var countPlan = new TN_Count_Plan() { |
| | | // S_CP_NO = GenerateNo("盘点计划", "CP"), |
| | | // S_TYPE = model.countType, |
| | | // }; |
| | | |
| | | // if (model.countType == "货位") { |
| | | // countPlan.S_LOC_CODE = model.targetId; |
| | | // } |
| | | // else if (model.countType == "物料") { |
| | | // countPlan.S_ITEM_CODE = model.targetId; |
| | | // } |
| | | // else { |
| | | // return BuildSimpleResult(2, $"创建盘点计划失败:不合法的盘点类型 '{model.countType}'"); |
| | | // } |
| | | |
| | | // if (db.Insertable<TN_Count_Plan>(countPlan).ExecuteCommand() <= 0) { |
| | | // return BuildSimpleResult(2, "创建盘点计划失败"); |
| | | // } |
| | | |
| | | // return BuildSimpleResult(0, "创建盘点计划成功"); |
| | | |
| | | // } |
| | | // catch (Exception ex) { |
| | | |
| | | // return BuildSimpleResult(1, ex.Message); |
| | | // } |
| | | //} |
| | | |
| | | //public static SimpleResult CreateCountOrder(CreateCountOrderInfo model) { |
| | | // var db = new SqlHelper<object>().GetInstance(); |
| | | // var info = ""; |
| | | // try { |
| | | // var countPlan = db.Queryable<TN_Count_Plan>() |
| | | // .Where(a => a.S_CP_NO == model.planId).First(); |
| | | |
| | | // if (countPlan == null) { |
| | | // return BuildSimpleResult(2, $"盘点计划单号 '{model.planId}' 不存在"); |
| | | // } |
| | | |
| | | // var countOrder = new TN_Count_Order() { |
| | | // S_CP_NO = model.planId, |
| | | // S_COUNT_NO = GenerateNo("盘点单", "CN"), |
| | | // }; |
| | | |
| | | // var countDetailList = new List<TN_Count_CG_Detail>(); |
| | | // if (countPlan.S_TYPE == "货位") { |
| | | // var cgDetail = db.Queryable<TN_Location, TN_Loc_Container, TN_CG_Detail> |
| | | // ((l, c, d) => l.S_CODE == c.S_LOC_CODE && c.S_CNTR_CODE == d.S_CNTR_CODE) |
| | | // .Where(l => l.S_CODE == countPlan.S_LOC_CODE) |
| | | // .Select((l, c, d) => d).First(); |
| | | |
| | | // var countDetail = new TN_Count_CG_Detail { |
| | | // S_COUNT_NO = countOrder.S_COUNT_NO, |
| | | // S_CNTR_CODE = cgDetail.S_CNTR_CODE, |
| | | // S_ITEM_CODE = cgDetail.S_ITEM_CODE, |
| | | // }; |
| | | |
| | | // countDetailList.Add(countDetail); |
| | | // } |
| | | // else if (countPlan.S_TYPE == "物料") { |
| | | // var cgDetailList = db.Queryable<TN_CG_Detail>() |
| | | // .Where(d => d.S_ITEM_CODE == countPlan.S_ITEM_CODE).ToList(); |
| | | |
| | | // foreach (var cgDetail in cgDetailList) { |
| | | // var countDetail = new TN_Count_CG_Detail { |
| | | // S_COUNT_NO = countOrder.S_COUNT_NO, |
| | | // S_CNTR_CODE = cgDetail.S_CNTR_CODE, |
| | | // S_ITEM_CODE = cgDetail.S_ITEM_CODE, |
| | | // }; |
| | | |
| | | // countDetailList.Add(countDetail); |
| | | // } |
| | | // } |
| | | // else { |
| | | // return BuildSimpleResult(3, $"计划单'{model.planId}'的类型{countPlan.S_TYPE}不合法"); |
| | | // } |
| | | |
| | | // using (var tran = db.Ado.UseTran()) { |
| | | // if (db.Insertable<TN_Count_Order>(countOrder).ExecuteCommand() <= 0) { |
| | | // tran.RollbackTran(); |
| | | // info = "创建盘点单失败"; |
| | | // return BuildSimpleResult(2, info); |
| | | // } |
| | | |
| | | // if (db.Insertable<TN_Count_CG_Detail>(countDetailList).ExecuteCommand() <= 0) { |
| | | // tran.RollbackTran(); |
| | | // info = "创建盘点单明细失败"; |
| | | // return BuildSimpleResult(3, info); |
| | | // } |
| | | |
| | | // tran.CommitTran(); |
| | | // } |
| | | |
| | | // return BuildSimpleResult(0, "创建盘点单成功"); |
| | | // } |
| | | // catch (Exception ex) { |
| | | |
| | | // return BuildSimpleResult(1, $"发生了异常:{ex.Message}"); |
| | | // } |
| | | //} |
| | | |
| | | //public static SimpleResult CountProduct(CountProductInfo model) { |
| | | // var db = new SqlHelper<object>().GetInstance(); |
| | | // try { |
| | | // var cgDetail = db.Queryable<TN_CG_Detail>() |
| | | // .Where(d => d.S_CNTR_CODE == model.cntrCode).First(); |
| | | |
| | | // if (cgDetail == null) { |
| | | // return BuildSimpleResult(2, $"找不到容器号'{model.cntrCode}'对应的物料"); |
| | | // } |
| | | |
| | | // var countDiff = new TN_Count_Diff { |
| | | // S_CNTR_CODE = cgDetail.S_CNTR_CODE, |
| | | // F_QTY = cgDetail.F_QTY, |
| | | // F_ACTUAL_QTY = model.qty |
| | | // }; |
| | | |
| | | // if (db.Insertable<TN_Count_Diff>(countDiff).ExecuteCommand() <= 0) { |
| | | // return BuildSimpleResult(3, $"插入盘点差异表失败"); |
| | | // } |
| | | |
| | | // return BuildSimpleResult(0, "盘点差异完成"); |
| | | |
| | | // } |
| | | // catch (Exception ex) { |
| | | // return BuildSimpleResult(1, $"发生了异常:{ex.Message}"); |
| | | // } |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 盘点理货出库(WMS) |
| | | ///// </summary> |
| | | ///// <param name="model"></param> |
| | | ///// <returns></returns> |
| | | //internal static SimpleResult CheckOutbound(CheckOutboundInfo model) { |
| | | // var taskName = TaskName.盘点理货出库; |
| | | // var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | // try { |
| | | // // 起点位置:取放货区(有货物、没有锁、已启用) |
| | | // var startLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.startLoc && a.N_CURRENT_NUM == 1 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无" && a.C_ENABLE == "Y" && Settings.Areas[0].Contains(a.S_AREA_CODE)); |
| | | // if (startLoc == null) { |
| | | // return BuildSimpleResult(2, $"起点位置 {model.startLoc} 不符合出库条件"); |
| | | // } |
| | | |
| | | // var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc); |
| | | // if (locCntrRel == null) { |
| | | // return BuildSimpleResult(3, $"起点位置 {model.startLoc} 没有绑定容器,无可回库的物料"); |
| | | // } |
| | | |
| | | // // 终点位置:货架(没有货物,没有锁) |
| | | // var endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.endLoc && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无" && a.C_ENABLE == "Y"); |
| | | // if (endLoc == null) { |
| | | // return BuildSimpleResult(4, $"终点位置 {model.endLoc} 不具备放货条件"); |
| | | // } |
| | | |
| | | // var cntID = locCntrRel.S_CNTR_CODE; |
| | | // var task = WCSHelper.BuildTask(startLoc, endLoc, cntID, taskName); |
| | | // LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | // LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | // using (var tran = db.Ado.UseTran()) { |
| | | // if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { |
| | | // it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | // tran.RollbackTran(); |
| | | // return BuildSimpleResult(500, |
| | | // $"生成 {taskName} 失败,容器号 {cntID} ,起点 {startLoc.S_CODE} ,终点货位 {endLoc.S_CODE}"); |
| | | // } |
| | | |
| | | // if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new { |
| | | // it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | // tran.RollbackTran(); |
| | | // return BuildSimpleResult(500, |
| | | // $"生成 {taskName} 失败,容器号 {cntID} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | // } |
| | | |
| | | // if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) { |
| | | // tran.RollbackTran(); |
| | | // return BuildSimpleResult(500, |
| | | // $"生成 {taskName} 失败,容器号 {cntID} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | // } |
| | | |
| | | // tran.CommitTran(); |
| | | // return BuildSimpleResult(0, |
| | | // $"生成 {taskName} 成功,容器号 {cntID} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | // } |
| | | // } |
| | | // catch (Exception ex) { |
| | | // return BuildSimpleResult(1, $"发生了异常:{ex.Message}"); |
| | | // } |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 盘点理货回库(WMS) |
| | | ///// </summary> |
| | | ///// <param name="model"></param> |
| | | ///// <returns></returns> |
| | | //internal static SimpleResult CheckInbound(CheckInboundInfo model) { |
| | | // var taskName = TaskName.盘点理货回库; |
| | | // var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | // try { |
| | | // // 起点位置:取放货区(有货物、没有锁、已启用) |
| | | // var startLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.startLoc && a.N_CURRENT_NUM == 1 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无" && a.C_ENABLE == "Y" && Settings.Areas[0].Contains(a.S_AREA_CODE)); |
| | | // if (startLoc == null) { |
| | | // return BuildSimpleResult(2, $"起点位置 {model.startLoc} 不符合回库条件"); |
| | | // } |
| | | |
| | | // var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc); |
| | | // if (locCntrRel == null) { |
| | | // return BuildSimpleResult(3, $"起点位置 {model.startLoc} 没有绑定容器,无可回库的物料"); |
| | | // } |
| | | |
| | | // // 终点位置:货架(没有货物,没有锁) |
| | | // var endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.endLoc && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无" && a.C_ENABLE == "Y"); |
| | | // if (endLoc == null) { |
| | | // return BuildSimpleResult(4, $"终点位置 {model.endLoc} 不具备放货条件"); |
| | | // } |
| | | |
| | | // var cntID = locCntrRel.S_CNTR_CODE; |
| | | // var task = WCSHelper.BuildTask(startLoc, endLoc, cntID, taskName); |
| | | // LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | // LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | // using (var tran = db.Ado.UseTran()) { |
| | | // if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { |
| | | // it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | // tran.RollbackTran(); |
| | | // return BuildSimpleResult(500, |
| | | // $"生成 {taskName} 失败,容器号 {cntID} ,起点 {startLoc.S_CODE} ,终点货位 {endLoc.S_CODE}"); |
| | | // } |
| | | |
| | | // if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new { |
| | | // it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | // tran.RollbackTran(); |
| | | // return BuildSimpleResult(500, |
| | | // $"生成 {taskName} 失败,容器号 {cntID} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | // } |
| | | |
| | | // if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) { |
| | | // tran.RollbackTran(); |
| | | // return BuildSimpleResult(500, |
| | | // $"生成 {taskName} 失败,容器号 {cntID} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | // } |
| | | |
| | | // tran.CommitTran(); |
| | | // return BuildSimpleResult(0, |
| | | // $"生成 {taskName} 成功,容器号 {cntID} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | // } |
| | | // } |
| | | // catch (Exception ex) { |
| | | // return BuildSimpleResult(1, $"发生了异常:{ex.Message}"); |
| | | // } |
| | | //} |
| | | |
| | | |
| | | public static ErpResult InboundDataSync(InboundDataSyncInfo model) { |
| | | //return BuildErpResult(1, "测试"); |
| | |
| | | S_ITEM_CODE = transaction.itemCode, |
| | | S_ITEM_NAME = transaction.itemName, |
| | | S_ITEM_SHORT_DESC = transaction.itemShortDesc, |
| | | S_STOCK_QUANTITY = transaction.stockQuantity, |
| | | S_IN_QUANTITY = transaction.inQuantity, |
| | | S_STOCK_QUANTITY = transaction.stockQuantity, // 库存数量 |
| | | S_IN_QUANTITY = transaction.inQuantity, // 入库数量 |
| | | S_TOTAL_PRICE = transaction.totalPrice, |
| | | S_STOCK_IN_TIME = transaction.stockInTime, |
| | | S_STORE_KEEPER = transaction.storeKeeper, |
| | |
| | | |
| | | cgDetailList.Add(cgDetail); |
| | | } |
| | | |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Insertable<TN_Inbound_DataRecord>(recordList).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | |
| | | S_ITEM_CODE = issue.itemCode, |
| | | S_ITEM_NAME = issue.itemName, |
| | | S_SHORT_DESC = issue.itemShortDesc, |
| | | S_ACTUAL_QTY = issue.actualIssuedQty, |
| | | S_ACTUAL_QTY = issue.actualIssuedQty, // 实发数量 |
| | | S_ISSUED_AMOUNT = issue.issuedAmount, |
| | | S_SUPPLIER_NAME = issue.supplierName, |
| | | S_ISSUER = issue.issuer, |