| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Reflection.Emit; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using static HH.WCS.JuShi.device.S7Helper; |
| | |
| | | var reservoirs2 = Settings.ReservoirAreas.Where(s => s.areaName == "6min空托区").FirstOrDefault(); |
| | | var linePlcInfo1 = Settings.linePlcInfos.Where(s => s.deviceNo == "1").FirstOrDefault(); |
| | | var linePlcInfo2 = Settings.linePlcInfos.Where(s => s.deviceNo == "2").FirstOrDefault(); |
| | | //找到空托缓存区的所有货位编号 |
| | | var locList = db.Queryable<Location>() |
| | | .Where(s => s.S_AREA_CODE == reservoirs1.areaCode || s.S_AREA_CODE == reservoirs2.areaCode) |
| | | .Where(s => s.N_LOCK_STATE == 0) |
| | | .OrderByDescending(s => s.N_ROW).OrderByDescending(s => s.N_COL).OrderBy(s => s.N_LAYER) |
| | | .Select(s => s.S_CODE) |
| | | .ToList(); |
| | | ////找到空托缓存区的所有货位编号 |
| | | //var locList = db.Queryable<Location>() |
| | | // .Where(s => s.S_AREA_CODE == reservoirs1.areaCode || s.S_AREA_CODE == reservoirs2.areaCode) |
| | | // .Where(s => s.N_LOCK_STATE == 0) |
| | | // .OrderByDescending(s => s.N_ROW).OrderByDescending(s => s.N_COL).OrderBy(s => s.N_LAYER) |
| | | // .Select(s => s.S_CODE) |
| | | // .ToList(); |
| | | |
| | | //找到绑了托盘的货位号 |
| | | var locCntrs = db.Queryable<LocCntrRel>() |
| | | .Where(s => locList.Contains(s.S_LOC_CODE.Trim())) |
| | | .Select(s => s.S_LOC_CODE) |
| | | .ToList(); |
| | | if (locCntrs.Any()) |
| | | |
| | | //查询每排最后一列有托盘的货位 根据行分区 再找每一行的最后一列有货的货位 |
| | | var list = db.Queryable<Location>(). |
| | | Where(a => a.N_CURRENT_NUM > 0 ).Where(a=> a.S_AREA_CODE.Trim() == reservoirs1.areaCode|| a.S_AREA_CODE.Trim() == reservoirs2.areaCode) |
| | | .PartitionBy(a => a.N_ROW) |
| | | .OrderByDescending(a => a.N_COL).Take(1).ToList(); |
| | | if (list.Count > 0) |
| | | { |
| | | //LogHelper.Info($"空托缓存区有绑定货位:{JsonConvert.SerializeObject(locCntrs)}"); |
| | | //var loccode = locCntrs.First(); |
| | | foreach (var loccode in locCntrs) |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | var loc = db.Queryable<Location>().Where(s => s.S_CODE == loccode).First(); |
| | | //var loc = list[i]; |
| | | //判断送往3寸还是6寸拆托机 |
| | | string endLoc = null; |
| | | string dev = null; |
| | | if (loc.S_AREA_CODE == reservoirs1.areaCode) |
| | | if (list[i].S_AREA_CODE == reservoirs1.areaCode) |
| | | { |
| | | endLoc = linePlcInfo1.inLoca; |
| | | dev = "1"; |
| | | } |
| | | else if (loc.S_AREA_CODE == reservoirs2.areaCode) |
| | | else if (list[i].S_AREA_CODE == reservoirs2.areaCode) |
| | | { |
| | | endLoc = linePlcInfo2.inLoca; |
| | | dev = "2"; |
| | |
| | | if ((plcDeviceTable.requestPut1 && dev == "1") || |
| | | (plcDeviceTable.requestPut2 && dev == "2")) |
| | | { |
| | | var locCntrRel = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE == loccode).First(); |
| | | var locCntrRel = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE == list[i].S_CODE).First(); |
| | | |
| | | LogHelper.Info($"创建任务 起点:{loccode}终点:{endLoc}"); |
| | | var res = TaskProcess.CreateTransport(loccode, endLoc, "送托", locCntrRel.S_CNTR_CODE, 1, 1); |
| | | LogHelper.Info($"创建任务 起点:{list[i].S_CODE}终点:{endLoc}"); |
| | | var res = TaskProcess.CreateTransport(list[i].S_CODE, endLoc, "送托", locCntrRel.S_CNTR_CODE, 1, 1); |
| | | if (res) |
| | | { |
| | | LogHelper.Info($"起点:{loccode}终点:{endLoc}任务创建成功"); |
| | | LogHelper.Info($"起点:{list[i].S_CODE}终点:{endLoc}任务创建成功"); |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"起点:{loccode}终点:{endLoc}任务创建失败"); |
| | | LogHelper.Info($"起点:{list[i].S_CODE}终点:{endLoc}任务创建失败"); |
| | | } |
| | | } |
| | | else |
| | |
| | | LogHelper.Info($"拆托机{endLoc}不允许放框"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | ////找到绑了托盘的货位号 |
| | | //var locCntrs = db.Queryable<LocCntrRel>() |
| | | // .Where(s => locList.Contains(s.S_LOC_CODE.Trim())) |
| | | // .Select(s => s.S_LOC_CODE) |
| | | // .ToList(); |
| | | //if (locCntrs.Any()) |
| | | //{ |
| | | // //LogHelper.Info($"空托缓存区有绑定货位:{JsonConvert.SerializeObject(locCntrs)}"); |
| | | // //var loccode = locCntrs.First(); |
| | | // foreach (var loccode in locCntrs) |
| | | // { |
| | | // var loc = db.Queryable<Location>().Where(s => s.S_CODE == loccode).First(); |
| | | // //判断送往3寸还是6寸拆托机 |
| | | // string endLoc = null; |
| | | // string dev = null; |
| | | // if (loc.S_AREA_CODE == reservoirs1.areaCode) |
| | | // { |
| | | // endLoc = linePlcInfo1.inLoca; |
| | | // dev = "1"; |
| | | // } |
| | | // else if (loc.S_AREA_CODE == reservoirs2.areaCode) |
| | | // { |
| | | // endLoc = linePlcInfo2.inLoca; |
| | | // dev = "2"; |
| | | // } |
| | | // var endLocation = db.Queryable<Location>().Where(s => s.S_CODE == endLoc).First(); |
| | | // if (endLocation == null || endLocation.N_LOCK_STATE != 0) |
| | | // { |
| | | // //LogHelper.Info($"拆托机货位{endLoc}不存在或已被锁"); |
| | | // return; |
| | | // } |
| | | // //校验是否允许放货 |
| | | // var plcDeviceTable = S7Helper.plcDeviceTables; |
| | | // LogHelper.Info($"自动送托 拆托机{dev}:{plcDeviceTable.requestPut1}"); |
| | | // if ((plcDeviceTable.requestPut1 && dev == "1") || |
| | | // (plcDeviceTable.requestPut2 && dev == "2")) |
| | | // { |
| | | // var locCntrRel = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE == loccode).First(); |
| | | |
| | | // LogHelper.Info($"创建任务 起点:{loccode}终点:{endLoc}"); |
| | | // var res = TaskProcess.CreateTransport(loccode, endLoc, "送托", locCntrRel.S_CNTR_CODE, 1, 1); |
| | | // if (res) |
| | | // { |
| | | // LogHelper.Info($"起点:{loccode}终点:{endLoc}任务创建成功"); |
| | | // } |
| | | // else |
| | | // { |
| | | // LogHelper.Info($"起点:{loccode}终点:{endLoc}任务创建失败"); |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // LogHelper.Info($"拆托机{endLoc}不允许放框"); |
| | | // } |
| | | // } |
| | | |
| | | //} |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |