| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection.Emit; |
| | | using System.ServiceModel; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | using System.Web.UI.WebControls; |
| | | using static HH.WCS.JiaTong.api.ApiModel; |
| | | using static HH.WCS.JiaTong.api.OtherModel; |
| | | using static HH.WCS.JiaTong.LISTA.process.HttpModel; |
| | |
| | | // AddErrorInfo("寻找出库区失败", result.msg); |
| | | // return result; |
| | | //} |
| | | |
| | | |
| | | int n_type = 0; //任务来源 1.密炼立库 3.预备库 ,4.原材料库 |
| | | string Source = ""; |
| | | switch (taskData.source) |
| | |
| | | } |
| | | else if (taskData.taskType == 2)//入库流程,直接使用起点货位和终点货位生成任务,起点需要有托盘 |
| | | { |
| | | note = "入库"; |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | |
| | | } |
| | | |
| | | } |
| | | //判断是否是空托回库 |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == CntrCode).First(); |
| | | if (CntrItem == null) |
| | | { |
| | | note = "空托回库";//井松空托回库,需要与叠盘机安全交互 |
| | | } |
| | | |
| | | endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); |
| | | if (endloc != null) |
| | | { |
| | |
| | | } |
| | | else if (taskData.taskType == 3)//移库流程,直接使用起点货位和终点货位生成任务, |
| | | { |
| | | note = "出库"; |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | Z_TYPE = n_type |
| | | Z_TYPE = n_type, |
| | | |
| | | |
| | | }; |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | Z_TYPE = n_type |
| | | Z_TYPE = n_type, |
| | | S_MES_NO = taskData.mesTaskNo |
| | | }; |
| | | var wcsTask1 = new WCSTask |
| | | { |
| | |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | Z_TYPE = n_type |
| | | |
| | | Z_TYPE = n_type, |
| | | S_MES_NO = taskData.mesTaskNo |
| | | |
| | | }; |
| | | |
| | |
| | | //暂存位回库 |
| | | else if (taskData.taskType == 6)//入库流程,直接使用起点货位和终点货位生成任务 |
| | | { |
| | | note = "入库"; |
| | | //根据托盘号找货位 |
| | | var CntrRel = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == partData.rfid).First(); |
| | | if (CntrRel != null) |
| | |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | S_NOTE = note |
| | | S_NOTE = note, |
| | | S_MES_NO = taskData.mesTaskNo |
| | | |
| | | }; |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | |
| | | try |
| | | { |
| | | //创建托盘数据绑定关系 |
| | | if (ContainerHelper.CreateCntrItem(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight, model.Qty)) |
| | | if (ContainerHelper.CreateCntrItem(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight, model.Qty, model.ProductionTime, model.MaturityTime)) |
| | | { |
| | | //创建成功流程 |
| | | } |
| | |
| | | if (startloc != null) |
| | | { |
| | | //根据仓库 计算库区 |
| | | if (startloc.S_WH_CODE == "101") |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | areacode = "PMGQ"; |
| | | areacode = whcode.PMK; |
| | | } |
| | | else |
| | | { |
| | | areacode = "PK2"; |
| | | result.code = "1"; |
| | | result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | areacode = "FLPK"; |
| | | |
| | | //判断有无相同物料排 |
| | | loc = StorageCompute(itemcode, areacode); |
| | | if (loc == null) |
| | | { |
| | | //无相同物料排找空排 |
| | | loc = emptyRow(areacode); |
| | | } |
| | | //if (loc == null) |
| | | //{ |
| | | // //无相同物料排找空排 |
| | | // loc = emptyRow(areacode); |
| | | //} |
| | | if (loc != null) |
| | | { |
| | | End = loc.S_CODE; |
| | |
| | | result.msg = $"库区:{areacode}无可用货位"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | result.msg = $"任务起点:{Start}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | LogHelper.Error("Putin Error:" + ex.ToString(), ex); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | #region 根据物料编码规则 计算出库库区 |
| | | //粉料从平库出库,其他物料需要从暂存区出库 |
| | | if (model.PartNumber.StartsWith("4X")) |
| | | var locJt = db.Queryable<Location>().Where(a => a.S_AREA_CODE == model.WorkCenter).First(); |
| | | if (locJt == null) |
| | | { |
| | | areacode = "FLPK"; |
| | | cntrType = "PM"; |
| | | result.code = "1"; |
| | | result.msg = $"根据机台编码:{model.WorkCenter}未找到对应货位"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | else |
| | | //根据仓库 计算库区 |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == locJt.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | |
| | | if (model.PartNumber.StartsWith("3")) |
| | | if (model.PartNumber.StartsWith("4X")) |
| | | { |
| | | cntrType = "RC"; |
| | | areacode = "KJZCW"; |
| | | areacode = whcode.PMK; |
| | | cntrType = "PM"; |
| | | } |
| | | else |
| | | { |
| | | if (model.PartNumber.StartsWith("3")) |
| | | { |
| | | cntrType = "RC"; |
| | | areacode = whcode.ZCW; |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,物料号{model.PartNumber}不属于规定物料"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("物料编码格式错误", result.msg, Source); |
| | | return result; |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,物料号{model.PartNumber}不属于规定物料"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("物料编码格式错误", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | } |
| | | //根据物料获取对应库区 |
| | | // var iteminfo = db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE.Trim() == itemcode).First(); |
| | | //if (iteminfo != null) |
| | | //{ |
| | | // areacode = iteminfo.S_WH_CODE; |
| | | //} |
| | | //areacode = computeArea(itemcode); |
| | | //if (string.IsNullOrEmpty(areacode)) |
| | | //{ |
| | | // LogHelper.Info($"PutOut==> 根据物料编码:{itemcode}找不到对应库区,请检查配置文件"); |
| | | // result.code = "1"; |
| | | // result.msg = $"根据物料编码:{itemcode}找不到对应库区,物料表配置"; |
| | | // AddErrorInfo("查找库区失败", result.msg); |
| | | //} |
| | | //if (itemcode == "测试1") |
| | | //{ |
| | | // areacode = "PMJP"; |
| | | //} |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据终点库区仓库编码:{locJt.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 根据物料编码计算出库货位,送往线边位置 |
| | |
| | | { |
| | | End = Endloc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"Computeloc==》根据机台编码:{model.WorkCenter},工装类型:{cntrType} 未找到空货位数据,请检查货位表"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | result.msg = $"任务物料:{itemcode}找不到对应库存"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | try |
| | | { |
| | | #region 判断托盘绑定货位是否和下发绑定起点相同 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrLoc != null) |
| | | { |
| | | if (CntrLoc.S_LOC_CODE != Start) |
| | | { |
| | | LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}"); |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}"; |
| | | AddErrorInfo("托盘绑定位置不同", result.msg); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}未找到绑定货位"); |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}未找到绑定货位"; |
| | | AddErrorInfo("查找托盘货位失败", result.msg); |
| | | return result; |
| | | } |
| | | //var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | //if (CntrLoc != null) |
| | | //{ |
| | | // if (CntrLoc.S_LOC_CODE != Start) |
| | | // { |
| | | // LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}"); |
| | | // result.code = "1"; |
| | | // result.msg = $"创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}"; |
| | | // AddErrorInfo("托盘绑定位置不同", result.msg); |
| | | // return result; |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | // LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}未找到绑定货位"); |
| | | // result.code = "1"; |
| | | // result.msg = $"创建任务失败,托盘:{model.Rfid}未找到绑定货位"; |
| | | // AddErrorInfo("查找托盘货位失败", result.msg); |
| | | // return result; |
| | | //} |
| | | #endregion |
| | | |
| | | #region 根据货位楼层判断,3楼去往叠盘位 其他的回库 |
| | |
| | | return result; |
| | | } |
| | | } |
| | | else if (startloc.S_NOTE == "PM") |
| | | else if (startloc.S_NOTE == "PB") |
| | | { |
| | | //找块胶堆叠区 |
| | | var KjDploc = db.Queryable<Location>().Where(a => a.S_NOTE.Trim() == "片胶堆叠位" && a.S_WH_CODE.Trim() == startloc.S_WH_CODE).ToList(); |
| | |
| | | } |
| | | else |
| | | { |
| | | #region 根据托盘找呼叫空托任务,并获得出库库区 |
| | | msts = WCSHelper.GetTaskBycntrcode(model.Rfid.Trim()); |
| | | if (msts.Count() > 0) |
| | | #region 根据起点货位类型,获得回库库区 |
| | | //根据仓库 计算库区 |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | msts.RemoveAll(a => string.IsNullOrEmpty(a.S_CNTR_CODE)); |
| | | mst = msts.OrderByDescending(a => a.T_CREATE).FirstOrDefault(); |
| | | } |
| | | if (mst != null) |
| | | { |
| | | LogHelper.Info($"找到出库任务:{JsonConvert.SerializeObject(mst)}"); |
| | | areacode = mst.S_START_AREA; |
| | | if (startloc.S_NOTE == "PM" || string.IsNullOrEmpty(startloc.S_NOTE)) |
| | | { |
| | | areacode = whcode.PMK; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,根据托盘编码{model.Rfid}未找到托盘出库任务"; |
| | | LogHelper.Info($"{result.msg}"); |
| | | AddErrorInfo("查找任务失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | if (string.IsNullOrEmpty(areacode)) |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,根据托盘编码{model.Rfid}找到出库任务{mst.S_CODE}的起点库区为空"; |
| | | LogHelper.Info($"{result.msg}"); |
| | | result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | |
| | | |
| | | //回库货位计算库区货位 |
| | | loc = StorageCompute(itemcode, areacode); |
| | | if (loc == null) |
| | | { |
| | | loc = emptyRow(areacode); |
| | | if (loc == null) |
| | | { |
| | | LogHelper.Info($"库区:{areacode}没有空排"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //if (loc == null) |
| | | //{ |
| | | // loc = emptyRow(areacode); |
| | | // if (loc == null) |
| | | // { |
| | | // LogHelper.Info($"库区:{areacode}没有空排"); |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"库区:{areacode}无可用货位"; |
| | | LogHelper.Info($"{result.msg}"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | // result.code = "1"; |
| | | // result.msg = $"库区:{areacode}无可用货位"; |
| | | // LogHelper.Info($"{result.msg}"); |
| | | // AddErrorInfo("查找货位失败", result.msg, Source); |
| | | // return result; |
| | | //} |
| | | } |
| | | |
| | | } |
| | |
| | | #endregion |
| | | |
| | | #region 创建任务 |
| | | if (!string.IsNullOrEmpty(Start) && loc != null) |
| | | if (startloc != null && loc != null) |
| | | { |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | if (startloc.N_LOCK_STATE != 0 && loc.N_LOCK_STATE != 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,起点{Start}有锁"; |
| | | result.msg = $"创建任务失败,起点货位状态{startloc.N_LOCK_STATE},起点货位状态:{loc.N_LOCK_STATE}"; |
| | | AddErrorInfo("货位有锁", result.msg); |
| | | return result; |
| | | } |
| | |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "空工装回库", |
| | | S_EQ_NO = model.TaskNumber, |
| | | S_START_LOC = Start, |
| | | S_START_LOC = startloc.S_CODE, |
| | | S_END_LOC = loc.S_CODE, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | LocationHelper.LockLoc(loc.S_CODE, 1); |
| | | // 空托回库判断托盘有无绑定物料信息 如果有则删除 |
| | | var itemcntr = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | |
| | | { |
| | | #region 根据仓库编码判断库区 并计算出库货位 |
| | | var endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == End).First(); |
| | | //根据仓库 计算库区 |
| | | |
| | | if (endloc != null) |
| | | { |
| | | if (endloc.S_WH_CODE == "101") |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == endloc.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | // itemcode = "TP"; |
| | | areacode = "PMGQ"; |
| | | areacode = whcode.PMK; |
| | | } |
| | | else |
| | | { |
| | | //itemcode = "TP"; |
| | | areacode = "PK2"; |
| | | result.code = "1"; |
| | | result.msg = $"根据起点仓库编码:{endloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | areacode = "FLPK"; |
| | | |
| | | |
| | | //计算出库托盘 |
| | | startloc = airlift(areacode, itemcode); |
| | | startloc = LocationHelper.GetLocByAreacode(areacode); |
| | | if (startloc != null) |
| | | { |
| | | var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == startloc.S_CODE).First(); |
| | |
| | | result.msg = $"任务起点:{End}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"callfixture:{result.msg}"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | |
| | | try |
| | | { |
| | | #region 判断托盘绑定货位是否和下发绑定起点相同 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrLoc != null) |
| | | { |
| | | if (CntrLoc.S_LOC_CODE != Start) |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("托盘绑定位置不同", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}未找到绑定货位"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("查找托盘货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 余料返回根据托盘找出库任务 |
| | | //余料返回根据托盘找出库任务 |
| | |
| | | var startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == Start).First(); |
| | | if (startloc != null) |
| | | { |
| | | //粉料直接回库,其他物料需要去对应的暂存区 |
| | | if (model.PartNumber.StartsWith("4X")) |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | areacode = "FLPK"; |
| | | loc = StorageCompute(itemcode, areacode); |
| | | if (loc == null) |
| | | //粉料直接回库,其他物料需要去对应的暂存区 |
| | | if (model.PartNumber.StartsWith("4X")) |
| | | { |
| | | loc = emptyRow(areacode); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (model.PartNumber.StartsWith("3")) |
| | | { |
| | | areacode = "KJYLZCW"; |
| | | areacode = whcode.PMK; |
| | | loc = StorageCompute(itemcode, areacode); |
| | | //if (loc == null) |
| | | //{ |
| | | // loc = emptyRow(areacode); |
| | | //} |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,物料号{model.PartNumber}不属于规定物料"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("物料编码格式错误", result.msg, Source); |
| | | return result; |
| | | } |
| | | var EndLocs = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == areacode).ToList(); |
| | | if (EndLocs.Count > 0) |
| | | { |
| | | loc = EndLocs.Find(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0); |
| | | if (loc != null) |
| | | #region 判断托盘绑定货位是否和下发绑定起点相同 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrLoc != null) |
| | | { |
| | | End = loc.S_CODE; |
| | | if (CntrLoc.S_LOC_CODE != Start) |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("托盘绑定位置不同", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}未找到绑定货位"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("查找托盘货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | if (model.PartNumber.StartsWith("3")) |
| | | { |
| | | areacode = whcode.ZCW; |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,物料号{model.PartNumber}不属于规定物料"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("物料编码格式错误", result.msg, Source); |
| | | return result; |
| | | } |
| | | var EndLocs = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == areacode).ToList(); |
| | | if (EndLocs.Count > 0) |
| | | { |
| | | //loc = EndLocs.Find(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0); |
| | | loc = FindEndcolByLocList(EndLocs); |
| | | if (loc != null) |
| | | { |
| | | End = loc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"终点库区:{areacode}无可用货位"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"终点库区:{areacode}无可用货位"; |
| | | result.msg = $"根据终点库区:{areacode},未找到对应货位"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | //loc = StorageCompute(itemcode, areacode); |
| | | //if (loc == null) |
| | | //{ |
| | | // loc = emptyRow(areacode); |
| | | //} |
| | | } |
| | | if (loc != null) |
| | | { |
| | | End = loc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"根据终点库区:{areacode},未找到对应货位"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | result.msg = $"库区:{areacode}无可用货位"; |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | //loc = StorageCompute(itemcode, areacode); |
| | | //if (loc == null) |
| | | //{ |
| | | // loc = emptyRow(areacode); |
| | | //} |
| | | } |
| | | if (loc != null) |
| | | { |
| | | End = loc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"库区:{areacode}无可用货位"; |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | itemInfo.REMARK1 = model.StewingTime; |
| | | itemInfo.REMARK2 = model.OverdueTime; |
| | | itemInfo.S_MP_TYPE = model.Unit; |
| | | if (db.Insertable<TN_Material>(itemInfo).ExecuteCommand()>0) |
| | | if (db.Insertable<TN_Material>(itemInfo).ExecuteCommand() > 0) |
| | | { |
| | | LogHelper.Info($"add:物料编码:{model.PartNumber}的物料主数据已同步"); |
| | | } ; |
| | | } |
| | | ; |
| | | return result; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | return result; |
| | | } |
| | | internal static DeviceInfoModel Device() |
| | | { |
| | | |
| | | DeviceInfoModel device = new DeviceInfoModel(); |
| | | |
| | | List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//叠盘机报错信息 |
| | | AgvInfos gvInfos = new AgvInfos();//agv报错信息 |
| | | //获取内存中叠盘机的报错信息 |
| | | foreach (var dpjInfo in DeviceProcess.DpjInfoDirectory) |
| | | { |
| | | deviceInfos.Add(new DeviceInfos() { Device = dpjInfo.Value.DeviceName, DeviceInfo = dpjInfo.Value.ErrorInfo }); |
| | | } |
| | | device.DeviceInfos = deviceInfos; |
| | | |
| | | |
| | | return device; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 库位清空 |
| | |
| | | if (CntrItem != null) |
| | | { |
| | | |
| | | LocationHelper.UnBindingLoc(loc, new List<string>() { "cntrcode" }); |
| | | // db.Deleteable<LocCntrRel>().Where(it => it.S_LOC_CODE.Trim() == loc).ExecuteCommand(); |
| | | LocationHelper.UnBindingLoc(loc, new List<string>() { cntrcode }); |
| | | // db.Deleteable<LocCntrRel>().Where(it => it.S_LOC_CODE.Trim() == loc).ExecuteCommand(); |
| | | db.Deleteable<CntrItemDetail>().Where(it => it.S_CNTR_CODE.Trim() == cntrcode).ExecuteCommand(); |
| | | |
| | | } |
| | |
| | | internal static Location StorageCompute(string itemcode, string areacode) |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | Location result = null; |
| | | //查询所有有托盘的排 |
| | | var list = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM > 0 && a.S_AREA_CODE.Trim() == areacode).OrderByDescending(a => a.N_COL).Take(1).PartitionBy(a => a.N_ROW).ToList(); |
| | | if (list.Count > 0) |
| | | { |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | LogHelper.Info($"有托盘排号{list[i].N_ROW},物料编码{itemcode},库区{areacode}"); |
| | | //判断托盘物料是否相同物料信息相同 |
| | | var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == list[i].S_CODE).First(); |
| | | if (cntr != null) |
| | | { |
| | | if (string.IsNullOrEmpty(itemcode))//空托入库 |
| | | { |
| | | var iteminfo = ContainerHelper.GetCntrItemRel(cntr.S_CNTR_CODE).FirstOrDefault(); |
| | | if (iteminfo == null) |
| | | { |
| | | //物料相同入货位后一位货位 |
| | | result = db.Queryable<Location>().OrderBy(a => a.N_COL).Where(a => a.S_AREA_CODE.Trim() == areacode && a.N_ROW == list[i].N_ROW && a.N_COL > list[i].N_COL).First(); |
| | | } |
| | | } |
| | | else//满拖入库 |
| | | { |
| | | var iteminfo = ContainerHelper.GetCntrItemRel(cntr.S_CNTR_CODE).FirstOrDefault(); |
| | | if (iteminfo != null) |
| | | { |
| | | if (iteminfo.S_ITEM_CODE == itemcode) |
| | | { |
| | | //物料相同入货位后一位货位 |
| | | result = db.Queryable<Location>().OrderBy(a => a.N_COL).Where(a => a.S_AREA_CODE.Trim() == areacode && a.N_ROW == list[i].N_ROW && a.N_COL > list[i].N_COL).First(); |
| | | Location result = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM == 0 && a.S_AREA_CODE.Trim() == areacode && a.N_LOCK_STATE == 0).First(); |
| | | //查询所有有托盘的排没锁的排 |
| | | // var list = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM > 0 && a.S_AREA_CODE.Trim() == areacode && a.N_LOCK_STATE == 0).OrderByDescending(a => a.N_COL).Take(1).PartitionBy(a => a.N_ROW).ToList(); |
| | | // if (list.Count > 0) |
| | | //{ |
| | | // for (int i = 0; i < list.Count; i++) |
| | | // { |
| | | // LogHelper.Info($"有托盘排号{list[i].N_ROW},物料编码{itemcode},库区{areacode}"); |
| | | // //查询货位绑定托盘 |
| | | // var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == list[i].S_CODE).First(); |
| | | // if (cntr != null) |
| | | // { |
| | | // //查询托盘物料信息 |
| | | // var iteminfo = ContainerHelper.GetCntrItemRel(cntr.S_CNTR_CODE).FirstOrDefault(); |
| | | |
| | | } |
| | | } |
| | | } |
| | | if (result != null) |
| | | { |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"根据货物编码{list[i].S_CODE}未找到托盘货位绑定关系"); |
| | | } |
| | | } |
| | | } |
| | | // if (string.IsNullOrEmpty(itemcode))//空托入库 |
| | | // { |
| | | // if (iteminfo == null) |
| | | // { |
| | | // //物料相同入货位后一位货位 |
| | | // result = db.Queryable<Location>().OrderBy(a => a.N_COL).Where(a => a.S_AREA_CODE.Trim() == areacode && a.N_ROW == list[i].N_ROW && a.N_COL > list[i].N_COL && a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM == 0).First(); |
| | | // } |
| | | // } |
| | | // else//满拖入库 |
| | | // { |
| | | // if (iteminfo != null) |
| | | // { |
| | | // if (iteminfo.S_ITEM_CODE == itemcode) |
| | | // { |
| | | // //物料相同入货位后一位货位 |
| | | // result = db.Queryable<Location>().OrderBy(a => a.N_COL).Where(a => a.S_AREA_CODE.Trim() == areacode && a.N_ROW == list[i].N_ROW && a.N_COL > list[i].N_COL && a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM == 0).First(); |
| | | |
| | | // } |
| | | // } |
| | | // } |
| | | // if (result != null) |
| | | // { |
| | | // return result; |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // LogHelper.Info($"根据货物编码{list[i].S_CODE}未找到托盘货位绑定关系"); |
| | | // } |
| | | // } |
| | | //} |
| | | return result; |
| | | } |
| | | |
| | |
| | | #endregion |
| | | var loc = LocationHelper.GetLocByItemCode(areacode, itemcode, level); |
| | | LogHelper.Info($"airlift=>根据库区编码:{areacode},物料编码:{itemcode},物料等级计算出有托盘货位{JsonConvert.SerializeObject(loc)}"); |
| | | result = FindStartcolByLoclist(loc); |
| | | // result = FindStartcolByLoclist(loc); |
| | | if (loc.Count > 0) |
| | | { |
| | | result = loc.OrderByDescending(a => a.N_COL).First(); |
| | | } |
| | | |
| | | LogHelper.Info($"airlift=>可用货位为:{JsonConvert.SerializeObject(result)}"); |
| | | return result; |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="locations"></param> |
| | | /// <returns></returns> |
| | | internal static Location FindEndcolByLocList(List<Location> locations, string itemcode) |
| | | internal static Location FindEndcolByLocList(List<Location> locations) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取对应错误编码的小车数量 |
| | | /// </summary> |
| | | /// <param name="Error1">错误码1</param> |
| | | /// <param name="Error2">错误码2</param> |
| | | /// <param name="faildCode"></param> |
| | | /// <returns></returns> |
| | | internal static int GetAgvQty(string Error1, string Error2 = "0", string faildCode = "0") |
| | | { |
| | | try |
| | | { |
| | | var db = new SqlHelper<HangChaAGV>().GetInstance(); |
| | | return db.Queryable<HangChaAGV>().Where(a => a.faildCode == faildCode && a.errCode2 == Error2 && a.agvErrCode == Error1).Count(); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | |