| | |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System.DirectoryServices.Protocols; |
| | | using System.Net; |
| | | using System.Reflection.Emit; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OtherEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_DTO.ToMes; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IOutboundService; |
| | |
| | | private readonly IRepository<Dt_LocationInfo> _locationInfoRepository; |
| | | private readonly IRepository<Dt_RoadwayInfo> _roadwayInforepository; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IDt_ApiInfoService _dt_ApiInfoService; |
| | | private readonly ILocationStatusChangeRecordService _locationStatusChangeRecordService; |
| | | private readonly IStationMangerService _stationMangerService; |
| | | |
| | | public IRepository<Dt_Task> Repository => BaseDal; |
| | | |
| | |
| | | {nameof(Dt_Task.CreateDate),OrderByType.Asc}, |
| | | }; |
| | | |
| | | public List<int> TaskTypes => typeof(TaskTypeEnum).GetEnumIndexList(); |
| | | |
| | | public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList(); |
| | | |
| | | public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, IBasicService basicService, IRepository<Dt_Warehouse> warehouseRepository, IRepository<Dt_LocationInfo> locationInfoRepository, IRepository<Dt_RoadwayInfo> roadwayInforepository) : base(BaseDal) |
| | | public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, IBasicService basicService, IRepository<Dt_Warehouse> warehouseRepository, IRepository<Dt_LocationInfo> locationInfoRepository, IRepository<Dt_RoadwayInfo> roadwayInforepository, IDt_ApiInfoService dt_ApiInfoService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IStationMangerService stationMangerService) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _warehouseRepository = warehouseRepository; |
| | | _locationInfoRepository = locationInfoRepository; |
| | | _roadwayInforepository = roadwayInforepository; |
| | | _dt_ApiInfoService = dt_ApiInfoService; |
| | | _locationStatusChangeRecordService = locationStatusChangeRecordService; |
| | | _stationMangerService=stationMangerService; |
| | | } |
| | | public int GetTaskNum(string sequenceName) |
| | | { |
| | | return Db.Ado.GetScalar($"SELECT NEXT VALUE FOR {sequenceName}").ObjToInt(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡ä¿¡æ¯æ¨éè³WCS |
| | | /// </summary> |
| | |
| | | { |
| | | x.AGVArea = agvDescription; |
| | | }); |
| | | string url = AppSettings.Get("WCSApiAddress"); |
| | | if (string.IsNullOrEmpty(url)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°WCSApiå°å,è¯·æ£æ¥é
ç½®æä»¶"); |
| | | } |
| | | string response = HttpHelper.Post($"{url}/api/Task/ReceiveTask", taskDTOs.Serialize()); |
| | | |
| | | return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("è¿åé误"); |
| | | var ConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_WCS_IPAddress, SysConfigConst.WCSReceiveTask); //è·åå°wcså
¨é¨ç±»åçæ¥å£ |
| | | string WCSReceiveTaskAPI = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName; |
| | | |
| | | var respon = HttpHelper.Post(WCSReceiveTaskAPI, JsonConvert.SerializeObject(taskDTOs)); |
| | | if (respon != null) |
| | | { |
| | | WebResponseContent respone = JsonConvert.DeserializeObject<WebResponseContent>(respon.ToString()); |
| | | if (respone.Status) |
| | | { |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error($"ä¸ååºåºå¤±è´¥ï¼åå ï¼{respone.Message}ï¼"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error("ä»»å¡ä¸å失败ï¼"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 夿巷éå
ç§»åº |
| | | /// </summary> |
| | | /// <param name="TaskNum"></param> |
| | | /// <param name="SourceAddress"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent IsRelocations(int TaskNum) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_LocationInfo> loca = new List<Dt_LocationInfo>(); |
| | | |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == TaskNum); |
| | | if (task == null) return content.Error($"æªæ¾å°è¯¥ä»»å¡ä¿¡æ¯ï¼ä»»å¡å·ï¼{TaskNum}"); |
| | | string Locatask = task.SourceAddress; |
| | | |
| | | //è·åå°æ·±åºä½ç¼å· |
| | | Dt_LocationInfo DeepLocation = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == Locatask); |
| | | if(DeepLocation == null) return content.Error($"æªæ¾å°è¯¥è´§ä½ä¿¡æ¯,è´§ä½ç¼å·:{Locatask}"); |
| | | |
| | | //è¿è¡è·åæµ
åºä½ç¼å· |
| | | int locrow = DeepLocation.Row == 1 ? 2 : 3; |
| | | Dt_LocationInfo ShallowLocation = _basicService.LocationInfoService.Repository.QueryFirst(x =>x.Row== locrow && x.Layer== DeepLocation.Layer && x.Column== DeepLocation.Column && x.RoadwayNo== DeepLocation.RoadwayNo); |
| | | if (ShallowLocation == null) return content.Error($"æªæ¾å°è´§ä½ç¼å·:{Locatask}çæµ
è´§ä½"); |
| | | |
| | | if (ShallowLocation.LocationStatus == (int)LocationStatusEnum.Free) |
| | | { |
| | | return content.OK(data: task); //ç´æ¥è¿åå½åæ¥è¯¢çä»»å¡ |
| | | } |
| | | |
| | | |
| | | //妿æè´§ï¼åçæç§»åºä»»å¡ |
| | | if (ShallowLocation.LocationStatus == (int)LocationStatusEnum.InStock) |
| | | { |
| | | Dt_StockInfo dt_Stock = _stockRepository.QueryFirst(x => x.LocationCode == ShallowLocation.LocationCode); |
| | | if (dt_Stock == null) return content.Error($"è´§ä½ç¼å·:{Locatask}çæµ
è´§ä½åºåå¼å¸¸ï¼è¯·æ£æ¥ï¼ï¼ï¼"); |
| | | |
| | | //è¿è¡è·åæ°çåºä½ |
| | | Dt_LocationInfo? Nextlocation = _basicService.LocationInfoService.GetLocation(DeepLocation.RoadwayNo);//è·åå°æ°åºä½ |
| | | if (Nextlocation == null) |
| | | { |
| | | return content.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | ShallowLocation.LocationStatus = (int)LocationStatusEnum.Lock; |
| | | Nextlocation.LocationStatus = (int)LocationStatusEnum.Lock; |
| | | loca.Add(ShallowLocation); |
| | | loca.Add(Nextlocation); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | //çæç§»å¨ä»»å¡ |
| | | Dt_Task dt_Task = new() |
| | | { |
| | | PalletCode = dt_Stock.PalletCode, |
| | | TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | Roadway = Nextlocation.RoadwayNo, |
| | | TaskType = TaskRelocationTypeEnum.Relocation.ObjToInt(), |
| | | TaskStatus = TaskRelocationStatusEnum.RelocationNew.ObjToInt(), |
| | | SourceAddress = ShallowLocation.LocationCode, |
| | | TargetAddress = Nextlocation.LocationCode, |
| | | CurrentAddress = ShallowLocation.LocationCode, |
| | | NextAddress = Nextlocation.LocationCode, |
| | | Grade = 1, |
| | | Creater = "WMS", |
| | | Depth = ShallowLocation.Depth, |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | |
| | | _locationInfoRepository.AddData(loca); |
| | | BaseDal.AddData(dt_Task); //æ°å¢ä»»å¡ |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | return content.OK(data: dt_Task); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"è´§ä½ç¼å·:{Locatask}çæµ
è´§ä½ç¶æå¼å¸¸ï¼æµ
è´§ä½ç¼å·ï¼{ShallowLocation.LocationCode}"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡ç¼å·</param> |
| | | /// <param name="HowWorks">模å¼ï¼1ï¼èªå¨ï¼2ï¼æå¨ï¼</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent TaskCompleted(int taskNum) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) return WebResponseContent.Instance.Error("æªæ¾å°ä»»å¡ä¿¡æ¯"); |
| | | switch (task.TaskType) |
| | | { |
| | | case (int)TaskRelocationTypeEnum.Relocation: |
| | | return RelocationInTaskCompleted(task); |
| | | case (int)TaskInboundTypeEnum.Inbound: |
| | | return InboundTaskCompleted(task); |
| | | case (int)TaskOutboundTypeEnum.Outbound: |
| | | return OutboundTaskCompleted(task); |
| | | default: return content.Error($"ä»»å¡ç±»åé误ï¼ä»»å¡å·ï¼{task.TaskNum}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ç§»åºå®ææ¹æ³ |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RelocationInTaskCompleted(Dt_Task task) |
| | | { |
| | | WebResponseContent webResponse = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_StockInfo stockInfo = _stockRepository.QueryFirst(x => x.PalletCode == task.PalletCode); |
| | | Dt_LocationInfo locationpoint = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | | Dt_LocationInfo locationEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | List<Dt_LocationInfo> loca = new List<Dt_LocationInfo>(); |
| | | stockInfo.LocationCode = locationEnd.LocationCode; |
| | | stockInfo.StockStatus = StockStatusEmun.å·²å
¥åº.ObjToInt(); |
| | | locationpoint.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | locationEnd.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | loca.Add(locationpoint); |
| | | loca.Add(locationEnd); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | _stockRepository.UpdateData(stockInfo); |
| | | _basicService.LocationInfoService.Repository.UpdateData(loca); |
| | | BaseDal.DeleteData(task); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | |
| | | WebResponseContent content=MES_TransferCompletionFeedback(task); |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content; |
| | | } |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | return webResponse.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return webResponse.Error($"ç§»åºä»»å¡å®æå¤±è´¥ï¼ä»»å¡idï¼{task.TaskNum}"); |
| | | throw; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="tasknum"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent InboundTaskCompleted(int taskNum) |
| | | public WebResponseContent InboundTaskCompleted(Dt_Task task) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ä»»å¡ä¿¡æ¯"); |
| | | } |
| | | Dt_Warehouse warehouse = _warehouseRepository.QueryFirst(x => x.WarehouseId == task.WarehouseId); |
| | | Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode && x.WarehouseId == task.WarehouseId).First(); |
| | | if (stockInfo == null) |
| | |
| | | } |
| | | dt_LocationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | //ä¿®æ¹è´§ä½ç¶æä¸ºæè´§ |
| | | _locationInfoRepository.UpdateData(dt_LocationInfo); |
| | |
| | | _stockRepository.UpdateData(stockInfo); |
| | | //å é¤ä»»å¡æ·»å åå² |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | |
| | | |
| | | /*WebResponseContent content = TaskCompletionFeedback(task); |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content; |
| | | }*/ |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | catch (Exception) |
| | |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºåºä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent OutboundTaskCompleted(Dt_Task task) |
| | | { |
| | | WebResponseContent webResponse = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_StockInfo stockInfo = _stockRepository.QueryFirst(x => x.PalletCode == task.PalletCode); |
| | | if (stockInfo == null) return webResponse.Error($"ä»»å¡ç¼å·ï¼{task.TaskNum},æªæ¾å°æçï¼{stockInfo.PalletCode}çåºåä¿¡æ¯"); |
| | | Dt_LocationInfo locationInfo = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | | if (locationInfo == null) return webResponse.Error($"ä»»å¡ç¼å·ï¼{task.TaskNum},æªæ¾å°æçï¼{stockInfo.PalletCode}çè´§ä½ä¿¡æ¯"); |
| | | |
| | | |
| | | stockInfo.StockStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | |
| | | int beforeStatus = locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus =(int)LocationStatusEnum.Free; |
| | | task.TaskStatus = TaskOutStatusEnum.OutFinish.ObjToInt(); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | _stockRepository.DeleteData(stockInfo); |
| | | _locationInfoRepository.UpdateData(locationInfo); //ä¿®æ¹æç©ºè´§ä½ |
| | | |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.èªå¨å®æ : OperateTypeEnum.äººå·¥å®æ); |
| | | _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockStatusEmun.åºåºå®æ.ObjToInt(), "1", task.TaskNum); |
| | | /*WebResponseContent content = TaskCompletionFeedback(task); |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content; |
| | | }*/ |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | return webResponse.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return webResponse.Error($"åºåºä»»å¡å®æå¤±è´¥ï¼ä»»å¡idï¼{task.TaskNum},é误åå ï¼{ex.Message}"); |
| | | throw; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //==============================================ç§»åºå®æå馿¥å£==================================================== |
| | | /// <summary> |
| | | /// ä¸ä¼ ç§»åºä»»å¡å®æç»MES |
| | | /// </summary> |
| | | /// <param name="dt_Task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent MES_TransferCompletionFeedback(Dt_Task dt_Task) |
| | | { |
| | | WebResponseContent webResponse = new WebResponseContent(); |
| | | |
| | | try |
| | | { |
| | | TransferRequest transferRequest = new TransferRequest() |
| | | { |
| | | //ä¸å¡idï¼ä»»å¡idåç»è¿è¡æ´æ¹ |
| | | businessId = "1", |
| | | TaskId = "1", |
| | | SourceLocationCode = dt_Task.SourceAddress, |
| | | LocationCode = dt_Task.TargetAddress, |
| | | PalletCode = dt_Task.PalletCode, |
| | | Status = "FINISH", |
| | | ErrorStatus = "NORMAL", |
| | | ErrorInfo = "", |
| | | }; |
| | | |
| | | //è·åæ¥å£è¿è¡è°å |
| | | var ConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.MESTransferCompletionFeedback); //è·åå°wcså
¨é¨ç±»åçæ¥å£ |
| | | string WCSReceiveTaskAPI = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName; |
| | | if (WCSReceiveTaskAPI == null) |
| | | { |
| | | return webResponse.Error($"åºåºå¤±è´¥ï¼æªé
ç½®MESç§»åºå®æå馿¥å£"); |
| | | } |
| | | var respon = HttpHelper.Post(WCSReceiveTaskAPI, JsonConvert.SerializeObject(transferRequest)); |
| | | if (respon != null) |
| | | { |
| | | var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon); |
| | | if (response.Success) |
| | | { |
| | | return webResponse.OK(); |
| | | } |
| | | else |
| | | { |
| | | return webResponse.Error($"è°åæ¥å£å¤±è´¥ï¼åé¦åæ°åå ï¼{response.Message}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return webResponse.Error($"è°åæ¥å£å¤±è´¥ï¼åé¦åæ°ä¸ºç©º"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return webResponse.Error($"ç§»åºä»»å¡ä¸ä¼ 失败ï¼åå ï¼{ex.Message}"); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// ä¸ä¼ åºå
¥åºä»»å¡å®æç»MES |
| | | /// </summary> |
| | | /// <param name="dt_Task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent TaskCompletionFeedback(Dt_Task dt_Task) |
| | | { |
| | | WebResponseContent webResponse = new WebResponseContent(); |
| | | |
| | | try |
| | | { |
| | | TaskNotification transferRequest = new TaskNotification() |
| | | { |
| | | //ä¸å¡idï¼ä»»å¡idåç»è¿è¡æ´æ¹ |
| | | TaskId = "1", //ä»»å¡id |
| | | BusinessId = "1", //ä¸å¡id |
| | | PalletCode = dt_Task.PalletCode, |
| | | SubPalletCode = "",//åæçç¼ç |
| | | LocationCode = dt_Task.SourceAddress, |
| | | ErrorStatus = "NORMAL", |
| | | ErrorInfo = "", |
| | | }; |
| | | |
| | | //è·åæ¥å£è¿è¡è°å |
| | | var ConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.MESTaskFeedback); //è·åå°wcså
¨é¨ç±»åçæ¥å£ |
| | | string WCSReceiveTaskAPI = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName; |
| | | if (WCSReceiveTaskAPI == null) |
| | | { |
| | | return webResponse.Error($"ä»»å¡åé¦MESå¤±è´¥ï¼æªé
ç½®MESä»»å¡å®æå馿¥å£"); |
| | | } |
| | | var respon = HttpHelper.Post(WCSReceiveTaskAPI, JsonConvert.SerializeObject(transferRequest)); |
| | | if (respon != null) |
| | | { |
| | | var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon); |
| | | if (response.Success) |
| | | { |
| | | return webResponse.OK(); |
| | | } |
| | | else |
| | | { |
| | | return webResponse.Error($"è°åæ¥å£å¤±è´¥ï¼åé¦åæ°åå ï¼{response.Message}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return webResponse.Error($"è°åæ¥å£å¤±è´¥ï¼åé¦åæ°ä¸ºç©º"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return webResponse.Error($"ä»»å¡ä»»å¡ä¸ä¼ 失败ï¼åå ï¼{ex.Message}"); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | public ApiResponse<object> MESresponse(string Message, bool Success) |
| | | { |
| | | ApiResponse<object> apiResponse = new ApiResponse<object>(); |
| | | apiResponse.Message = Message; |
| | | apiResponse.Success = Success; |
| | | apiResponse.Code = 1; |
| | | return apiResponse; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// åå»ºè´§ä½ |
| | | /// </summary> |
| | | /// <param name="locationInfo"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | public ApiResponse<object> createLocation(List<LocationInfoDto> locationInfo) |
| | | { |
| | | List<Dt_LocationInfo> dt_LocationInfoList = new List<Dt_LocationInfo>(); |
| | | foreach (var item in locationInfo) |
| | | { |
| | | Dt_LocationInfo dt_LocationInfo = new Dt_LocationInfo() |
| | | { |
| | | LocationCode = item.locationCode, |
| | | LocationName = item.locationName, |
| | | RoadwayNo = item.roadwayNo, |
| | | Row = item.row, |
| | | Column = item.column, |
| | | Layer = item.layer, |
| | | Depth = (int)item.depth, |
| | | LocationType = item.locationType, |
| | | LocationStatus = item.locationStatus, |
| | | EnableStatus = item.enableStatus == true ? 1 : 0, |
| | | Remark = item.remark, |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | }; |
| | | dt_LocationInfoList.Add(dt_LocationInfo); |
| | | } |
| | | int res = _locationInfoRepository.AddData(dt_LocationInfoList); |
| | | if (res <= 0) |
| | | { |
| | | return MESresponse($"å建货ä½å¤±è´¥",false); |
| | | } |
| | | return MESresponse($"", true); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä¿®æ¹è´§ä½ |
| | | /// </summary> |
| | | /// <param name="locationInfo"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | public ApiResponse<object> updateLocation(LocationInfoDto locationInfo) |
| | | { |
| | | Dt_LocationInfo dt_LocationInfo = new Dt_LocationInfo() |
| | | { |
| | | LocationCode = locationInfo.locationCode, |
| | | LocationName = locationInfo.locationName, |
| | | RoadwayNo = locationInfo.roadwayNo, |
| | | Row = locationInfo.row, |
| | | Column = locationInfo.column, |
| | | Layer = locationInfo.layer, |
| | | Depth = (int)locationInfo.depth, |
| | | LocationType = locationInfo.locationType, |
| | | LocationStatus = locationInfo.locationStatus, |
| | | EnableStatus = locationInfo.enableStatus == true ? 1 : 0, |
| | | Remark = locationInfo.remark, |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | bool res = _locationInfoRepository.Db.Updateable(dt_LocationInfo) |
| | | .Where(x => x.LocationCode == dt_LocationInfo.LocationCode) |
| | | .ExecuteCommand() > 0; |
| | | if (!res) |
| | | { |
| | | return MESresponse($"ä¿®æ¹è´§ä½å¤±è´¥",false); |
| | | } |
| | | return MESresponse($"", true); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å é¤è´§ä½ |
| | | /// </summary> |
| | | /// <param name="locationCode"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | public ApiResponse<object> deleteLocation(List<string> locationCode) |
| | | { |
| | | WebResponseContent webResponseContent = new WebResponseContent(); |
| | | int res = _locationInfoRepository.Db.Deleteable<Dt_LocationInfo>().Where(x => locationCode.Contains(x.LocationCode)).ExecuteCommand(); |
| | | if (res <= 0) |
| | | { |
| | | return MESresponse($"å é¤è´§ä½å¤±è´¥",false); |
| | | } |
| | | return MESresponse($"", true); |
| | | } |
| | | } |
| | | } |