| | |
| | | S_CNTR_CODE = cntrCode, |
| | | }; |
| | | |
| | | // BEG 每次轮询都检查对应容器是否已登记,登记则更新,未登记则插入 |
| | | var cntrItemRel = db.Queryable<TN_Container_ItemType>() |
| | | .Where(i => i.S_CNTR_CODE == cntrCode).First(); |
| | | var needInsertContainer = false; |
| | | var needUpdateContainer = false; |
| | | // 查容器信息表是否已经有这个容器 |
| | | var cntr = db.Queryable<TN_Container>() |
| | | .Where(c => c.S_CODE == cntrCode).First(); |
| | | // 如果找不到该容器,需要添加,并且将容器来源设置为任务名称 |
| | | if (cntr == null) { |
| | | needInsertContainer = true; |
| | | LogHelper.Info($"轮询:{taskName}:容器:{cntrCode},在容器表中没有登记,登记并设置容器来源为:{taskName}"); |
| | | |
| | | var insertTable = cntrItemRel == null; |
| | | |
| | | if (insertTable) { |
| | | // 暂定在满托下线入库的时候,登记托盘容器-物料号关系(后面可能会改成系统维护) |
| | | cntrItemRel = new TN_Container_ItemType { |
| | | S_ITEM_CODE = itemCode, |
| | | S_CNTR_CODE = cntrCode, |
| | | S_CNTR_TYPE = "托盘", |
| | | cntr = new TN_Container { |
| | | S_CODE = cntrCode, |
| | | S_TYPE = "托盘", |
| | | S_SPEC = itemCode, |
| | | S_SOURCE = taskName, |
| | | }; |
| | | } |
| | | // END |
| | | else { |
| | | // 如果找到该容器,但容器物料类型与下线物料不符,记录并直接覆盖(待定) |
| | | if (!string.IsNullOrEmpty(cntr.S_SPEC) && cntr.S_SPEC != itemCode) { |
| | | needUpdateContainer = true; |
| | | LogHelper.Info($"轮询:{taskName}:容器表中容器{cntrCode}对应的物料信息:{cntr.S_SPEC}," + |
| | | $"与所需要的物料信息{itemCode}不符,直接覆盖结果"); |
| | | |
| | | cntr.S_SPEC = itemCode; |
| | | cntr.S_SOURCE = taskName; |
| | | } |
| | | } |
| | | |
| | | var startLoc = db.Queryable<TN_Location>() |
| | | .Where(l => l.S_CODE == startLocCode) // 指定:起点货位号 |
| | |
| | | S_CNTR_TYPE = "托盘", |
| | | }; |
| | | |
| | | //if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() <= 0) { |
| | | // info = $"插入货位容器关系失败:" + JsonConvert.SerializeObject(locCntrRel); |
| | | // LogHelper.Info(info); |
| | | // continue; |
| | | // //return; |
| | | //} |
| | | |
| | | var endLoc = db.Queryable<TN_Location>() |
| | | .Where(a => Settings.AreaMap[AreaName.K空托存放区].Contains(a.S_AREA_CODE)) |
| | | .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无" && a.C_ENABLE == "Y") // 筛选:未上锁 |
| | |
| | | LocationHelper.LockEndLoc(ref endLoc); // 终点入库锁 |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (needInsertContainer) { |
| | | if (db.Insertable<TN_Container>(cntr).ExecuteCommand() <= 0) { |
| | | info = $"插入容器表失败:" + JsonConvert.SerializeObject(cntr); |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(info); |
| | | continue; |
| | | } |
| | | } |
| | | else if (needUpdateContainer) { |
| | | if (db.Updateable<TN_Container>(cntr).ExecuteCommand() <= 0) { |
| | | info = $"更新容器表失败:" + JsonConvert.SerializeObject(cntr); |
| | | tran.RollbackTran(); |
| | | LogHelper.Info(info); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (db.Insertable<TN_CG_Detail>(cgDetail).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | info = $"插入容器货品信息表失败:物料编码{cgDetail.S_ITEM_CODE},容器编码{cgDetail.S_CNTR_CODE}"; |
| | | LogHelper.Info(info); |
| | | continue; |
| | | } |
| | | |
| | | // BEG 插入或更新容器与物料类型的绑定表 |
| | | if (insertTable) { |
| | | if (db.Insertable<TN_Container_ItemType>(cntrItemRel).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | info = $"登记容器物料类型绑定表失败:物料编码{cntrItemRel.S_ITEM_CODE},容器编码{cntrItemRel.S_CNTR_CODE}"; |
| | | LogHelper.Info(info); |
| | | continue; |
| | | } |
| | | } |
| | | else { |
| | | if (db.Updateable<TN_Container_ItemType>(cntrItemRel).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | info = $"登记容器物料类型绑定表失败:物料编码{cntrItemRel.S_ITEM_CODE},容器编码{cntrItemRel.S_CNTR_CODE}"; |
| | | LogHelper.Info(info); |
| | | continue; |
| | | } |
| | | } |
| | | // END |
| | | |
| | | if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |