| | |
| | | |
| | | using static HH.WCS.Mobox3.DSZSH.api.ApiModel; |
| | | using static HH.WCS.Mobox3.DSZSH.api.OtherModel; |
| | | using static HH.WCS.Mobox3.DSZSH.Config; |
| | | using static HH.WCS.Mobox3.DSZSH.core.Monitor; |
| | | |
| | | namespace HH.WCS.Mobox3.DSZSH.api { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 模拟Erp下发出库计划单 |
| | | /// DEBUG:模拟人工将料箱搬运到产线上线口(直接修改数据库) |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("GoodpackToProdLine")] |
| | | public string GoodpackToProdLine(GoodpackToProdLineInfo model) { |
| | | |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try { |
| | | // 查询起点货位:数量=0 |
| | | var startLoc = db.Queryable<TN_Location>().LeftJoin<TN_Loc_Container>((l, c) => l.S_CODE == c.S_LOC_CODE) |
| | | .Where((l,c) => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y" && l.S_CODE == model.StartLoc && l.N_CURRENT_NUM == 1 && c.S_CNTR_CODE == model.CntrCode).First(); |
| | | if (startLoc == null) { |
| | | return $"没有找到起点货位'{model.StartLoc}'!要求:锁状态='无',当前容器数量=1"; |
| | | } |
| | | |
| | | // 查询终点货位 |
| | | // Order:按货位层数,从小到大排列 |
| | | var endLoc = db.Queryable<TN_Location>().Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y" && l.N_CURRENT_NUM == 0).First(); |
| | | if (endLoc == null) { |
| | | return $"没有找到合适的终点货位!要求:锁状态='无',当前容器数量=0"; |
| | | } |
| | | |
| | | var locCntrRel = db.Queryable<TN_Loc_Container>().Where(c => c.S_CNTR_CODE == model.CntrCode).First() ; |
| | | if (locCntrRel == null) { |
| | | return $"该容器不存在绑定的货位!"; |
| | | } |
| | | |
| | | locCntrRel.S_LOC_CODE = model.StartLoc; |
| | | startLoc.N_CURRENT_NUM = 0; |
| | | endLoc.N_CURRENT_NUM = 1; |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_Location>(startLoc).ExecuteCommand() <= 0 && |
| | | db.Updateable<TN_Location>(endLoc).ExecuteCommand() <= 0 && |
| | | db.Updateable<TN_Loc_Container>(locCntrRel).ExecuteCommand() <= 0) { |
| | | |
| | | tran.RollbackTran(); |
| | | return "数据库操作失败!"; |
| | | } |
| | | |
| | | tran.CommitTran() ; |
| | | return "数据库操作成功"; |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | |
| | | return ex.Message; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// DEBUG:模拟Erp下发出库计划单 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | |
| | | } |
| | | } |
| | | |
| | | public class GoodpackToProdLineInfo { |
| | | public string CntrCode { get; set; } |
| | | public string StartLoc { get; set; } |
| | | public string EndLoc { get; set; } |
| | | } |
| | | |
| | | public class TestErpSendOutboundPlanInfo { |
| | | /// <summary> |
| | | /// 出库计划单号(计划单号 jhdh) |