| | |
| | | var mes_heads = freeDB.Select<dt_mes_head>().Where(x => x.processCode == "28").OrderBy(x => x.expectedStartTime).ToList(); |
| | | foreach (var mes_head in mes_heads) |
| | | { |
| | | //var inventorys = freeDB.Select<dt_inventory>().Where(x => x.FigureNumber == mes_head.drawingNo).OrderBy.ToList(); |
| | | var station = stationinfoRepository.Find(x => x.stationType == mes_head.drawingNo && x.line != x.line).OrderBy(x => x.line).ThenByDescending(x => x.column).FirstOrDefault(); |
| | | bool ok = false; |
| | | List<string> list = new List<string>(); |
| | | if (station != null && station.location_state == LocationStateEnum.Stroge.ToString() && station.enable) |
| | | #region æ ¹æ®åºåå
¥åºæ¶é´æææ¥è¯¢ |
| | | var inventory = freeDB.Select<dt_inventory>().Where(x => x.FigureNumber == mes_head.drawingNo).OrderByDescending(x => x.OnlineTime).First(); |
| | | if (inventory != null) |
| | | { |
| | | var SNS = station.bindSN.Split(","); |
| | | var Station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault(); |
| | | if (Station != null) |
| | | { |
| | | var stationinfo = stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); |
| | | if (stationinfo != null) |
| | | { |
| | | if (stationinfo.bindSN == null) |
| | | throw new Exception(stationinfo.stationCode + "车轮SNå·ä¿¡æ¯å¼å¸¸!"); |
| | | List<string> lists = new List<string>(); |
| | | var SNS = stationinfo.bindSN.Split(","); |
| | | foreach (var SN in SNS) |
| | | { |
| | | if (!string.IsNullOrEmpty(SN)) |
| | | list.Add(SN); |
| | | lists.Add(SN); |
| | | } |
| | | } |
| | | foreach (var SN in list) |
| | | foreach (var item in lists) |
| | | { |
| | | if (ok = freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mes_head.jobID && x.SN == SN).Any()) continue; |
| | | } |
| | | if (ok) |
| | | if (freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mes_head.jobID && x.SN == item).Any()) |
| | | { |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = station.stationCode, |
| | | agv_fromaddress = stationinfo.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Queue", |
| | | agv_materielid = station.stationType, |
| | | agv_qty = station.quantity, |
| | | agv_materielid = stationinfo.stationType, |
| | | agv_qty = stationinfo.quantity, |
| | | agv_tasktype = "TaskType_Outbound", |
| | | agv_toaddress = "", |
| | | agv_userid = "ç³»ç»", |
| | | bindSN = station.bindSN, |
| | | bindSN = stationinfo.bindSN, |
| | | agv_worktype = Convert.ToInt32(mes_head.processCode), |
| | | agv_materbarcode = mes_head.materialCode, |
| | | agv_barcode = station.tray_type |
| | | agv_Traytype = stationinfo.tray_type, |
| | | agv_TrayStatus = stationinfo.tray_status |
| | | }; |
| | | dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository); |
| | | if (TargetLocation != null) |
| | |
| | | freeDB.Update(TargetLocation); |
| | | } |
| | | freeDB.Add(agvtask); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | stationinfo = stationinfoRepository.Find(x => x.stationType == mes_head.drawingNo && x.line != Station.line).OrderBy(x => x.line).ThenByDescending(x => x.column).FirstOrDefault(); |
| | | if (stationinfo != null && stationinfo.enable) |
| | | { |
| | | if (stationinfo.bindSN == null) |
| | | throw new Exception(stationinfo.stationCode + "车轮SNå·ä¿¡æ¯å¼å¸¸!"); |
| | | List<string> lists = new List<string>(); |
| | | var SNS = stationinfo.bindSN.Split(","); |
| | | foreach (var SN in SNS) |
| | | { |
| | | if (!string.IsNullOrEmpty(SN)) |
| | | lists.Add(SN); |
| | | } |
| | | foreach (var item in lists) |
| | | { |
| | | if (freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mes_head.jobID && x.SN == item).Any()) |
| | | { |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = stationinfo.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Queue", |
| | | agv_materielid = stationinfo.stationType, |
| | | agv_qty = stationinfo.quantity, |
| | | agv_tasktype = "TaskType_Outbound", |
| | | agv_toaddress = "", |
| | | agv_userid = "ç³»ç»", |
| | | bindSN = stationinfo.bindSN, |
| | | agv_worktype = Convert.ToInt32(mes_head.processCode), |
| | | agv_materbarcode = mes_head.materialCode, |
| | | agv_Traytype = stationinfo.tray_type, |
| | | agv_TrayStatus = stationinfo.tray_status |
| | | }; |
| | | dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository); |
| | | if (TargetLocation != null) |
| | | { |
| | | agvtask.agv_taskstate = "Create"; |
| | | agvtask.agv_toaddress = TargetLocation.stationCode; |
| | | TargetLocation.location_state = LocationStateEnum.Busy.ToString(); |
| | | freeDB.Update(TargetLocation); |
| | | } |
| | | freeDB.Add(agvtask); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region MyRegion |
| | | //var station = stationinfoRepository.Find(x => x.stationType == mes_head.drawingNo && x.line != x.line).OrderBy(x => x.line).ThenByDescending(x => x.column).FirstOrDefault(); |
| | | //bool ok = false; |
| | | //List<string> list = new List<string>(); |
| | | //if (station != null && station.location_state == LocationStateEnum.Stroge.ToString() && station.enable) |
| | | //{ |
| | | // var SNS = station.bindSN.Split(","); |
| | | // foreach (var SN in SNS) |
| | | // { |
| | | // if (!string.IsNullOrEmpty(SN)) |
| | | // list.Add(SN); |
| | | // } |
| | | //} |
| | | //foreach (var SN in list) |
| | | //{ |
| | | // if (ok = freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mes_head.jobID && x.SN == SN).Any()) continue; |
| | | //} |
| | | //if (ok) |
| | | //{ |
| | | // dt_agvtask agvtask = new dt_agvtask() |
| | | // { |
| | | // agv_fromaddress = station.stationCode, |
| | | // agv_id = Guid.NewGuid(), |
| | | // agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | // agv_grade = 1, |
| | | // agv_createtime = DateTime.Now, |
| | | // agv_taskstate = "Queue", |
| | | // agv_materielid = station.stationType, |
| | | // agv_qty = station.quantity, |
| | | // agv_tasktype = "TaskType_Outbound", |
| | | // agv_toaddress = "", |
| | | // agv_userid = "ç³»ç»", |
| | | // bindSN = station.bindSN, |
| | | // agv_worktype = Convert.ToInt32(mes_head.processCode), |
| | | // agv_materbarcode = mes_head.materialCode, |
| | | // agv_barcode = station.tray_type |
| | | // }; |
| | | // dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository); |
| | | // if (TargetLocation != null) |
| | | // { |
| | | // agvtask.agv_taskstate = "Create"; |
| | | // agvtask.agv_toaddress = TargetLocation.stationCode; |
| | | // TargetLocation.location_state = LocationStateEnum.Busy.ToString(); |
| | | // freeDB.Update(TargetLocation); |
| | | // } |
| | | // freeDB.Add(agvtask); |
| | | //} |
| | | #endregion |
| | | |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |