| | |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.AspNetCore.Http; |
| | | using WIDESEA_WMS.IRepositories; |
| | | using WIDESEA_WMS.Repositories; |
| | | using WIDESEA_Core.EFDbContext; |
| | | using static System.Collections.Specialized.BitVector32; |
| | | using WIDESEA_Comm.TaskNo; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core.ManageUser; |
| | | using WIDESEA_Comm.LogInfo; |
| | | |
| | | namespace WIDESEA_WMS.Services |
| | | { |
| | |
| | | //å¤ç§æ·ä¼ç¨å°è¿init代ç ï¼å
¶ä»æ
åµå¯ä»¥ä¸ç¨ |
| | | //base.Init(dbRepository); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// æ·»å ä»»å¡ |
| | | /// </summary> |
| | | /// <param name="saveDataModel"></param> |
| | | /// <returns></returns> |
| | | public override WebResponseContent Add(SaveModel saveDataModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | VOLContext context = new VOLContext(); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context); |
| | | var fromaddress = saveDataModel.MainData["agv_fromaddress"].ToString(); |
| | | var toaddress = saveDataModel.MainData["agv_toaddress"].ToString(); |
| | | var tasktype = saveDataModel.MainData["agv_tasktype"].ToString(); |
| | | var grade = saveDataModel.MainData["agv_grade"].ToInt(); |
| | | var station1 = stationinfoRepository.FindFirst(x => x.stationCode == fromaddress); |
| | | var station2 = stationinfoRepository.FindFirst(x => x.stationCode == toaddress); |
| | | if (station1 == null || station2 == null) |
| | | throw new Exception($"èµ·ç¹å°å{fromaddress}æç»ç¹å°å{toaddress}ä¸åå¨ï¼"); |
| | | if (string.IsNullOrEmpty(station1.stationType)) |
| | | throw new Exception($"èµ·ç¹{fromaddress}æªç»å®ç©æç±»åï¼"); |
| | | var task = _repository.Find(t => t.agv_fromaddress == fromaddress |
| | | || t.agv_fromaddress == toaddress |
| | | || t.agv_toaddress == fromaddress |
| | | || t.agv_toaddress == toaddress |
| | | ).Any(); |
| | | if (task) |
| | | throw new Exception("èµ·å§æç®çå°åï¼å·²åå¨ä»»å¡ä¸ï¼"); |
| | | dt_agvtask agvtask = new dt_agvtask(); |
| | | agvtask.agv_id = Guid.NewGuid(); |
| | | agvtask.agv_fromaddress = fromaddress; |
| | | agvtask.agv_toaddress = toaddress; |
| | | agvtask.agv_tasknum = IdenxManager.GetTaskNo("KH-"); |
| | | agvtask.agv_code = "AGV"; |
| | | agvtask.agv_taskstate = AGVTaskStateEnum.Create.ToString(); |
| | | agvtask.agv_tasktype = tasktype; |
| | | agvtask.agv_worktype = 1;//å·¥ä½ç±»å |
| | | agvtask.agv_materielid = station1.stationType;//ç©æç±»å |
| | | agvtask.agv_qty = station1.quantity; |
| | | agvtask.agv_createtime = DateTime.Now; |
| | | agvtask.agv_grade = grade;//ä»»å¡ä¼å
级 |
| | | agvtask.agv_userid = UserContext.Current.UserName; |
| | | _repository.Add(agvtask, true); |
| | | content.OK(); |
| | | WriteDBLog.Success($"æå¨æ·»å ä»»å¡", new { æ°æ® = saveDataModel }, "WMS", UserContext.Current.UserName); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteDBLog.Error($"æå¨æ·»å ä»»å¡", new { æ°æ® = saveDataModel, å¼å¸¸ä¿¡æ¯ = ex.Message }, "WMS", UserContext.Current.UserName); |
| | | content.Error(ex.Message); |
| | | } |
| | | |
| | | return content; |
| | | } |
| | | } |
| | | } |