| | |
| | | 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; |
| | |
| | | } |
| | | else if (taskData.taskType == 2)//入库流程,直接使用起点货位和终点货位生成任务,起点需要有托盘 |
| | | { |
| | | note = "入库"; |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | Start = startloc.S_CODE; |
| | | var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).FirstOrDefault(); |
| | | if (CntrRel != null) |
| | | { |
| | | Start = startloc.S_CODE; |
| | | CntrCode = CntrRel.S_CNTR_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据起点{Start},未找到托盘货位绑定关系"; |
| | | AddErrorInfo("托盘查找失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | //else |
| | | //{ |
| | | // result.code = "1"; |
| | | // result.msg = $"根据起点{Start},未找到托盘货位绑定关系"; |
| | | // AddErrorInfo("托盘查找失败", result.msg, Source); |
| | | // return result; |
| | | //} |
| | | |
| | | } |
| | | //判断是否是空托回库 |
| | | 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) |
| | | { |
| | |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | // LocationHelper.LockLoc(End, 2); |
| | | |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else if (startArea.N_FLOOR != endArea.N_FLOOR) |
| | | { |
| | | //楼层电梯分配 |
| | | var endloc1 = Settings.elevatorLoc.Find(a => a.Floor == startArea.N_FLOOR); |
| | | var startloc1 = Settings.elevatorLoc.Find(a => a.Floor == endArea.N_FLOOR); |
| | | var elevatorLoc = LocationHelper.GetElevatorLoc(); |
| | | |
| | | //创建wcs分段任务 |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "电梯1", |
| | | S_EQ_NO = taskData.taskNum, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = endloc1.Location[0], |
| | | N_CNTR_COUNT = 1, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_END_WH = endloc.S_WH_CODE, |
| | | S_END_AREA = endloc.S_AREA_CODE, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = CntrCode, |
| | | N_PRIORITY = taskData.priority, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | Z_TYPE = n_type, |
| | | S_MES_NO = taskData.mesTaskNo |
| | | }; |
| | | var wcsTask1 = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "电梯2", |
| | | S_EQ_NO = taskData.taskNum, |
| | | S_START_LOC = startloc1.Location[0], |
| | | S_END_LOC = End, |
| | | N_CNTR_COUNT = 1, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_END_WH = endloc.S_WH_CODE, |
| | | S_END_AREA = endloc.S_AREA_CODE, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = CntrCode, |
| | | N_PRIORITY = taskData.priority, |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | Z_TYPE = n_type, |
| | | S_MES_NO = taskData.mesTaskNo |
| | | if (elevatorLoc != null) |
| | | { //创建wcs分段任务 |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "电梯1", |
| | | S_EQ_NO = taskData.taskNum, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = elevatorLoc.S_CODE, |
| | | N_CNTR_COUNT = 1, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_END_WH = elevatorLoc.S_WH_CODE, |
| | | S_END_AREA = elevatorLoc.S_AREA_CODE, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = CntrCode, |
| | | N_PRIORITY = taskData.priority, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | Z_TYPE = n_type, |
| | | S_MES_NO = taskData.mesTaskNo |
| | | }; |
| | | var wcsTask1 = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "电梯2", |
| | | S_EQ_NO = taskData.taskNum, |
| | | S_START_LOC = elevatorLoc.S_CODE, |
| | | S_END_LOC = End, |
| | | N_CNTR_COUNT = 1, |
| | | S_START_WH = elevatorLoc.S_WH_CODE, |
| | | S_START_AREA = elevatorLoc.S_AREA_CODE, |
| | | S_END_WH = endloc.S_WH_CODE, |
| | | S_END_AREA = endloc.S_AREA_CODE, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = CntrCode, |
| | | N_PRIORITY = taskData.priority, |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | Z_TYPE = n_type, |
| | | S_MES_NO = taskData.mesTaskNo |
| | | |
| | | }; |
| | | }; |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask) && WCSHelper.CreateTask(wcsTask1)) |
| | | { |
| | | |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask) && WCSHelper.CreateTask(wcsTask1)) |
| | | { |
| | | |
| | | LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | // LocationHelper.LockLoc(Start, 1); |
| | | //LocationHelper.LockLoc(End, 2); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | else if (taskData.taskType == 5)//移库流程,直接使用起点货位和终点货位生成任务,并绑定托盘 |
| | | { |
| | | note = "出库"; |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | if (CreateCntrIteminfo(partData, taskData)) |
| | | { |
| | |
| | | //暂存位回库 |
| | | else if (taskData.taskType == 6)//入库流程,直接使用起点货位和终点货位生成任务 |
| | | { |
| | | note = "入库"; |
| | | //根据托盘号找货位 |
| | | var CntrRel = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == partData.rfid).First(); |
| | | if (CntrRel != null) |
| | |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | // LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | try |
| | | { |
| | | |
| | | #region 入库检查托盘物料表有无数据 |
| | | var cntritem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (cntritem == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}无绑定物料数据"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("托盘绑定物料数据为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 判断托盘绑定货位是否和下发绑定起点相同,如果没绑定托盘则绑定托盘 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrLoc != null) |
| | |
| | | result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | //判断有无相同物料排 |
| | |
| | | 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.Info("创建入平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | result.msg = $"根据机台编码:{model.WorkCenter}未找到对应货位"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | //根据仓库 计算库区 |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == locJt.S_WH_CODE).FirstOrDefault(); |
| | |
| | | result.msg = $"根据终点库区仓库编码:{locJt.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | { |
| | | 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 |
| | | |
| | |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LogHelper.Info("创建任务成功"); |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | if (startloc.S_NOTE == "PM" || string.IsNullOrEmpty(startloc.S_NOTE)) |
| | | if ( string.IsNullOrEmpty(startloc.S_NOTE)) |
| | | { |
| | | areacode = whcode.PMK; |
| | | } |
| | |
| | | result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | N_END_LAYER = endlayer, |
| | | Z_TYPE = 5 |
| | | }; |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | LogHelper.Info("创建空托回库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | LocationHelper.LockLoc(loc.S_CODE, 1); |
| | | //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(); |
| | | if (itemcntr != null) { db.Deleteable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).ExecuteCommand(); } |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | result.msg = $"根据起点仓库编码:{endloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | //计算出库托盘 |
| | | 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 |
| | | |
| | |
| | | Z_TYPE = 5 |
| | | |
| | | }; |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | LogHelper.Info("创建呼叫空托任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | |
| | | try |
| | | { |
| | | |
| | | |
| | | #region 余料返回根据托盘找出库任务 |
| | | //余料返回根据托盘找出库任务 |
| | | //msts = WCSHelper.GetTaskBycntrcode(model.Rfid); |
| | |
| | | if (whcode != null) |
| | | { |
| | | //粉料直接回库,其他物料需要去对应的暂存区 |
| | | #region 根据物料判断回库库区 |
| | | if (model.PartNumber.StartsWith("4X")) |
| | | { |
| | | areacode = whcode.PMK; |
| | | loc = StorageCompute(itemcode, areacode); |
| | | //loc = StorageCompute(itemcode, areacode); |
| | | //if (loc == null) |
| | | //{ |
| | | // loc = emptyRow(areacode); |
| | |
| | | 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) |
| | | { |
| | | End = loc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"终点库区:{areacode}无可用货位"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据终点库区:{areacode},未找到对应货位"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | //loc = StorageCompute(itemcode, areacode); |
| | | //if (loc == null) |
| | | //{ |
| | | // loc = emptyRow(areacode); |
| | | //} |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | 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); |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据终点库区:{areacode},未找到对应货位"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | if (loc != null) |
| | | { |
| | | End = loc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"库区:{areacode}无可用货位"; |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | //创建任务成功 更新余料信息 |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrItem != null) |
| | |
| | | db.Updateable(CntrItem).UpdateColumns(a => new { a.F_WEIGHT, a.S_BS_TYPE }).ExecuteCommand(); |
| | | } |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | // var startArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == startloc.S_AREA_CODE).First(); |
| | | //var endArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == endloc.S_AREA_CODE).First(); |
| | | |
| | | string dtcode = "DT-01"; |
| | | //楼层电梯分配 |
| | | var Diantiloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == dtcode).First(); |
| | | if (Diantiloc == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,根据货位编码:{dtcode}未找到电梯货位"; |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | //string dtcode = "DT-01"; |
| | | ////楼层电梯分配 |
| | | //var Diantiloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == dtcode).First(); |
| | | //if (Diantiloc == null) |
| | | //{ |
| | | // result.code = "1"; |
| | | // result.msg = $"创建任务失败,根据货位编码:{dtcode}未找到电梯货位"; |
| | | // AddErrorInfo("查找货位失败", result.msg, Source); |
| | | // return result; |
| | | //} |
| | | |
| | | //根据电梯数量判断送往哪个电梯 (具体电梯流程根据现场电梯数量) |
| | | //根据任务数量判断送往哪个电梯 (具体电梯流程根据现场电梯数量) |
| | | var elevatorLoc = LocationHelper.GetElevatorLoc(); |
| | | |
| | | //创建wcs分段任务 |
| | | var wcsTask = new WCSTask |
| | |
| | | S_TYPE = "电梯1", |
| | | S_EQ_NO = model.Data.task_no, |
| | | S_START_LOC = startloc.S_CODE, |
| | | S_END_LOC = Diantiloc.S_CODE, |
| | | S_END_LOC = elevatorLoc.S_CODE, |
| | | N_CNTR_COUNT = 1, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_END_WH = endloc.S_WH_CODE, |
| | | S_END_AREA = endloc.S_AREA_CODE, |
| | | S_END_WH = elevatorLoc.S_WH_CODE, |
| | | S_END_AREA = elevatorLoc.S_AREA_CODE, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = cntr.S_CNTR_CODE, |
| | | N_END_LAYER = 1, |
| | |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "电梯2", |
| | | S_EQ_NO = model.Data.task_no, |
| | | S_START_LOC = Diantiloc.S_CODE, |
| | | S_START_LOC = elevatorLoc.S_CODE, |
| | | S_END_LOC = endloc.S_CODE, |
| | | N_CNTR_COUNT = 1, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_START_WH = elevatorLoc.S_WH_CODE, |
| | | S_START_AREA = elevatorLoc.S_AREA_CODE, |
| | | S_END_WH = endloc.S_WH_CODE, |
| | | S_END_AREA = endloc.S_AREA_CODE, |
| | | N_SCHEDULE_TYPE = 1, |
| | |
| | | if (WCSHelper.CreateTask(wcsTask) && WCSHelper.CreateTask(wcsTask1)) |
| | | { |
| | | |
| | | LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | //LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | //LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 库位清空 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result ClearLocCntr(ClearTask model) |
| | | { |
| | | Result result = new Result() { code = "200", msg = "库位清除成功" }; |
| | | string Source = "MES"; |
| | | if (model == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "参数为null"; |
| | | AddErrorInfo("参数为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | string loc = model.LocationNum; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try |
| | | { |
| | | var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First(); |
| | | if (location != null) |
| | | { |
| | | var loccntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc).First(); |
| | | |
| | | if (loccntr != null) |
| | | { |
| | | |
| | | string cntrcode = loccntr.S_CNTR_CODE; |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == cntrcode).First(); |
| | | if (CntrItem != null) |
| | | { |
| | | if (LocationHelper.UnBindingLoc(loc, new List<string>() { cntrcode })) |
| | | { |
| | | LogHelper.Info($"清除托盘货位关系成功"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLocCntr 托盘{cntrcode}无物料绑定关系"); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLocCntr 货位{loc}无托盘货位绑定关系"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据货位:{loc}找不到货位关系"; |
| | | AddErrorInfo("货位为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"ClearLocCntr Error:{ex}"); |
| | | db.Ado.CommitTran(); |
| | | result.code = "1"; |
| | | result.msg = $"Error:{ex}"; |
| | | return result; |
| | | |
| | | } |
| | | |
| | | return result; |
| | | } /// <summary> |
| | | /// 库位清空 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | |
| | | if (CntrItem != null) |
| | | { |
| | | |
| | | 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(); |
| | | LocationHelper.UnBindingLoc(loc, new List<string>() { cntrcode }); |
| | | // db.Deleteable<LocCntrRel>().Where(it => it.S_LOC_CODE.Trim() == loc).ExecuteCommand(); |
| | | if (db.Deleteable<CntrItemDetail>().Where(it => it.S_CNTR_CODE == cntrcode).ExecuteCommand() > 0) |
| | | { |
| | | LogHelper.Info($"ClearLoc 库位清除成功"); |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLoc 库位清除失败"); |
| | | result.code = "1"; |
| | | result.msg = "库位清除失败"; |
| | | AddErrorInfo("库位清除失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | else |
| | |
| | | |
| | | return result; |
| | | } |
| | | /// <summary> |
| | | /// 设备状态上报 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | internal static DeviceInfoModel Device() |
| | | { |
| | | var db = new SqlHelper<HangChaAGV>().GetInstance(); |
| | | DeviceInfoModel device = new DeviceInfoModel(); |
| | | |
| | | List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//叠盘机报错信息 |
| | | List<AgvInfos> agvInfos = new List<AgvInfos>();//agv报错信息 |
| | | |
| | | //获取内存中叠盘机的报错信息 |
| | | foreach (var dpjInfo in DeviceProcess.DpjInfoDirectory) |
| | | { |
| | | deviceInfos.Add(new DeviceInfos() { Device = dpjInfo.Value.DeviceName, DeviceInfo = dpjInfo.Value.ErrorInfo }); |
| | | } |
| | | device.DeviceInfos = deviceInfos; |
| | | //获取车辆报警信息 |
| | | var agvDeviceInfo = db.Queryable<HangChaAGV>().ToList(); |
| | | if (agvDeviceInfo.Count > 0) |
| | | { |
| | | device.AgvQty = agvDeviceInfo.Count; |
| | | device.AgvErrorQty = agvDeviceInfo.FindAll(a => a.agvErrCode != "0" || a.agvErrCode != "0" || a.faildCode != "0").Count; |
| | | device.AgvChargeQty = agvDeviceInfo.FindAll(a => a.agvErrCode == "1").Count; |
| | | device.AgvRunQty = agvDeviceInfo.FindAll(a => a.agvErrCode == "1").Count; |
| | | foreach (var agv in agvDeviceInfo) |
| | | { |
| | | string agvErrorInfo = GetAgvAlarmSendCodeTwo(agv.agvErrCode, agv.errCode2, agv.faildCode); |
| | | agvInfos.Add(new AgvInfos() { AgvNo = agv.agvNo, AgvInfo = agvErrorInfo }); |
| | | } |
| | | } |
| | | device.AgvInfos = agvInfos; |
| | | |
| | | return device; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// agv小车故障码处理 |
| | | /// </summary> |
| | | /// <param name="errCode1">错误码1</param> |
| | | /// <param name="errCode2">错误码2</param> |
| | | /// <param name="faildCode">错误码3</param> |
| | | /// <returns></returns> |
| | | private static string GetAgvAlarmSendCodeTwo(string errCode1, string errCode2, string faildCode) |
| | | { |
| | | string result = ""; |
| | | //将报警信息整合 |
| | | string binSW1 = Convert.ToString(int.Parse(errCode1), 2).PadLeft(22, '0'); |
| | | string binSW2 = Convert.ToString(int.Parse(errCode1), 2).PadLeft(20, '0'); |
| | | string binFc = Convert.ToString(int.Parse(errCode1), 2).PadLeft(16, '0'); |
| | | var arr1 = binSW1.ToArray(); |
| | | var arr2 = binSW2.ToArray(); |
| | | var arr3 = binFc.ToArray(); |
| | | |
| | | for (int i = 0; i <= arr1.Length; i++) |
| | | { |
| | | if (arr1[i] == '1') |
| | | { |
| | | var ErrorInfo = Settings.agvErrorCode1.Where(a => a.ErrorCode == i).FirstOrDefault(); |
| | | if (ErrorInfo != null) |
| | | { |
| | | result = result + "," + $"{ErrorInfo.ErrorInfo}"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | for (int i = 0; i <= arr2.Length; i++) |
| | | { |
| | | if (arr1[i] == '1') |
| | | { |
| | | var ErrorInfo = Settings.agvErrorCode2.Where(a => a.ErrorCode == i).FirstOrDefault(); |
| | | if (ErrorInfo != null) |
| | | { |
| | | result = result + "," + $"{ErrorInfo.ErrorInfo}"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | for (int i = 0; i <= arr3.Length; i++) |
| | | { |
| | | if (arr1[i] == '1') |
| | | { |
| | | var ErrorInfo = Settings.agvFaildCode.Where(a => a.ErrorCode == i).FirstOrDefault(); |
| | | if (ErrorInfo != null) |
| | | { |
| | | result = result + "," + $"{ErrorInfo.ErrorInfo}"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 合肥佳通业务方法 |
| | |
| | | #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; |
| | | } |
| | |
| | | |
| | | lock (_lockLocation) |
| | | { |
| | | var loc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).First(); |
| | | var loc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0&&a.S_LOCK_STATE=="无").First(); |
| | | if (loc != null) |
| | | { |
| | | End = loc; |
| | |
| | | /// </summary> |
| | | /// <param name="locations"></param> |
| | | /// <returns></returns> |
| | | internal static Location FindEndcolByLocList(List<Location> locations, string itemcode) |
| | | internal static Location FindEndcolByLocList(List<Location> locations) |
| | | { |
| | | try |
| | | { |
| | |
| | | Location other = null; |
| | | //当前排没有锁并且有空位置 |
| | | //先找满位,然后后面一层要么是空,要么不存在 |
| | | other = rowList.OrderByDescending(a => a.N_COL).Where(a => a.N_CURRENT_NUM == 0).FirstOrDefault(); |
| | | other = rowList.OrderBy(a => a.N_COL).Where(a => a.N_CURRENT_NUM == 0).FirstOrDefault(); |
| | | //if (full == null) |
| | | //{ |
| | | // //没有满位,那就找最小的空位 |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | internal static CodeInfo GetCodeInfo(string code, string org) |
| | | { |