| | |
| | | using WIDESEA_Comm.LogInfo; |
| | | using StackExchange.Redis; |
| | | using WIDESEA_Comm; |
| | | using WIDESEA_Entity.DomainModels.Mes; |
| | | using WIDESEA_WMS.Common; |
| | | using System.Reflection.Emit; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEA_WMS.Services |
| | | { |
| | |
| | | //å¤ç§æ·ä¼ç¨å°è¿init代ç ï¼å
¶ä»æ
åµå¯ä»¥ä¸ç¨ |
| | | //base.Init(dbRepository); |
| | | } |
| | | |
| | | public override WebResponseContent Del(object[] keys, bool delList = true) |
| | | { |
| | | #region æ¹éä¿®æ¹è´§ä½ç¶æ |
| | | //VOLContext context = new VOLContext(); |
| | | //Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context); |
| | | //var fromaddress = repository.Find(x => keys.Contains(x.agv_id)).Select(x => x.agv_fromaddress).ToList(); |
| | | //var stations = stationinfoRepository.Find(x => fromaddress.Contains(x.stationCode)).ToList(); |
| | | //foreach (var station in stations) |
| | | //{ |
| | | // station.location_state = LocationStateEnum.Stroge.ToString(); |
| | | // //station.tray_type= TrayTypeEnum.SmallTray.ToString(); |
| | | // //station.tray_status= TrayStateEnum.StrogeTray.ToString(); |
| | | //} |
| | | //stationinfoRepository.UpdateRange(stations, x => new { x.location_state }, true); |
| | | #endregion |
| | | VOLContext volContext = new VOLContext(); |
| | | Idt_agvtask_htyRepository agvtask_HtyRepository=new dt_agvtask_htyRepository(volContext); |
| | | var agvtasks = repository.Find(x => keys.Contains(x.agv_id)).ToList(); |
| | | List<dt_agvtask_hty> dt_Agvtask_Hties = new List<dt_agvtask_hty>(); |
| | | foreach (var task in agvtasks) |
| | | { |
| | | dt_agvtask_hty agvtask_Hty = new dt_agvtask_hty() |
| | | { |
| | | hty_pkid = Guid.NewGuid(), |
| | | agv_id = task.agv_id, |
| | | agv_tasknum = task.agv_tasknum, |
| | | agv_materielid = task.agv_materielid, |
| | | agv_qty = task.agv_qty, |
| | | agv_createtime = task.agv_createtime, |
| | | agv_realesstime = task.agv_realesstime, |
| | | agv_executingBeginTime = task.agv_executingBeginTime, |
| | | agv_executingEndTime = task.agv_executingEndTime, |
| | | agv_completeBeginTime = task.agv_completeBeginTime, |
| | | agv_finishedtime = task.agv_finishedtime, |
| | | agv_taskstate = task.agv_taskstate, |
| | | agv_tasktype = task.agv_tasktype, |
| | | agv_fromaddress = task.agv_fromaddress, |
| | | agv_toaddress = task.agv_toaddress, |
| | | agv_operatetype = "Del", |
| | | agv_compeletor = UserContext.Current.UserName, |
| | | agv_completedate = DateTime.Now, |
| | | agv_grade = task.agv_grade, |
| | | agv_userid = task.agv_userid, |
| | | agv_Traytype = task.agv_Traytype, |
| | | agv_TrayStatus = task.agv_TrayStatus, |
| | | agv_worktype = task.agv_worktype, |
| | | agv_remark = task.agv_remark, |
| | | bindSN = task.bindSN, |
| | | jobID = task.jobID, |
| | | agv_materbarcode = task.agv_materbarcode, |
| | | }; |
| | | dt_Agvtask_Hties.Add(agvtask_Hty); |
| | | } |
| | | agvtask_HtyRepository.AddRange(dt_Agvtask_Hties,true); |
| | | return base.Del(keys, delList); |
| | | } |
| | | public WebResponseContent addNgTask(MesRequestTemp requestTemp) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var fromaddress = requestTemp.from_address; |
| | | VOLContext context = new VOLContext(); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context); |
| | | IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context); |
| | | var station = stationinfoRepository.Find(x => x.stationCode == fromaddress).FirstOrDefault(); |
| | | if (_repository.Find(x => x.agv_fromaddress == fromaddress || x.agv_toaddress == fromaddress).Any()) |
| | | throw new Exception($"è´§ä½{fromaddress}å·²åå¨ä»»å¡ï¼"); |
| | | if (station == null) throw new Exception($"æªæ¾å°è´§ä½{fromaddress}ï¼"); |
| | | if (!station.enable) throw new Exception($"è´§ä½{fromaddress}æªå¯ç¨ï¼"); |
| | | if (station.quantity < 1) throw new Exception($"è´§ä½{fromaddress}æ 车轮ï¼"); |
| | | var Work = workinfoRepository.Find(x => x.workOrder == station.Number && x.processCode == "17").FirstOrDefault(); |
| | | if (Work == null) throw new Exception($"æªæ¾å°è´§ä½{fromaddress}çæºå 工工åä¿¡æ¯"); |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = station.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = 2, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Queue", |
| | | agv_materielid = station.stationType, |
| | | agv_qty = station.quantity, |
| | | agv_tasktype = "TaskType_OutsourceInbound", |
| | | agv_toaddress = "", |
| | | agv_userid = UserContext.Current.UserName, |
| | | bindSN = station.bindSN, |
| | | agv_worktype = Convert.ToInt32(Work.processCode), |
| | | agv_materbarcode = Work.materialCode, |
| | | agv_Traytype = station.tray_type, |
| | | jobID = station.Number, |
| | | agv_TrayStatus = station.tray_status |
| | | }; |
| | | _repository.Add(agvtask, true); |
| | | station.location_state = LocationStateEnum.InBusy.ToString(); |
| | | stationinfoRepository.Update(station, true); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Message = ex.Message; |
| | | } |
| | | return content; |
| | | } |
| | | public override WebResponseContent Update(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | var agv_id = saveModel.MainData["agv_id"].ToString(); |
| | | var task = _repository.Find(x => x.agv_id.ToString() == agv_id).FirstOrDefault(); |
| | | if (task.agv_taskstate != AGVTaskStateEnum.Queue.ToString()) return content.Error("å½åä»»å¡ä¸å¯æ´æ¹ï¼"); |
| | | WriteDBLog.Success($"æå¨ä¿®æ¹ä»»å¡", new { æ°æ® = saveModel }, "WMS", UserContext.Current.UserName); |
| | | return base.Update(saveModel); |
| | | } |
| | | #region æ·»å NGä»»å¡ |
| | | public override WebResponseContent Add(SaveModel saveDataModel) |
| | | { |