| | |
| | | using System.Reflection; |
| | | using System.Reflection.Metadata; |
| | | using System.Security.Policy; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Cache; |
| | |
| | | _wareAreaInfoRepository = wareAreaInfoRepository; |
| | | _inventoryRecordRepository = inventoryRecordRepository; |
| | | } |
| | | #region åå§åæåæº |
| | | public async Task<WebResponseContent> InitializationElevator() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var address = GetWCSIPAddress("WCSIPAddress","InitializationElevator"); |
| | | if (address != null) |
| | | { |
| | | await HttpHelper.PostAsync(address, ""); |
| | | return content.OK("æå"); |
| | | } |
| | | return content.Error("失败"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region å¤é¨æ¥å£æ¹æ³ |
| | | |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.CarryGroup) |
| | | { |
| | | var result1 = UpdateLocationStatus(task.SourceAddress, LocationEnum.Free, task.TaskNum.Value, StatusChangeTypeEnum.AutomaticOutbound); |
| | | await _locationStatusChangeRecordRepository.AddDataAsync(result1.Item1); |
| | | await _locationRepository.UpdateDataAsync(result1.Item2); |
| | | } |
| | | |
| | | task.TaskState = (int)TaskOutStatusEnum.OutFinish; |
| | | var taskHty = task.Adapt<Dt_Task_Hty>(); |
| | | taskHty.FinishTime = DateTime.Now; |
| | |
| | | stock.ModifyDate = DateTime.Now; |
| | | stock.LocationCode = task.TargetAddress; |
| | | var result2 = UpdateLocationStatus(task.TargetAddress, LocationEnum.InStock, task.TaskNum.Value, StatusChangeTypeEnum.AutomaticOutbound); |
| | | |
| | | DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>(); |
| | | var orderDetails = _orderOutDetailsRepository.QueryData(x => x.PalletCode == task.PalletCode); |
| | | List<Dt_OrderOutDetails_Hty> orderdetailshtys = new List<Dt_OrderOutDetails_Hty>(); |
| | | |
| | | orderDetails.ForEach(item => |
| | | { |
| | | orderdetailshtys.Add(item.Adapt<Dt_OrderOutDetails_Hty>()); |
| | | }); |
| | | { |
| | | orderdetailshtys.Add(item.Adapt<Dt_OrderOutDetails_Hty>()); |
| | | }); |
| | | |
| | | await ERPAllocateOut(stock); |
| | | |
| | |
| | | boxingInfo.BoxingInfoDetails = mergedDetails; |
| | | } |
| | | |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | | { |
| | | //await _unitOfWorkManage.UseTranAsync(async () => |
| | | //{ |
| | | _unitOfWorkManage.BeginTran(); |
| | | await DeleteStockInfoAsync(stock.Id); |
| | | _boxingInfoRepository.UpdateDataNav(boxingInfo); |
| | | await DeleteStockInfoDetailsAsync(stock.StockInfoDetails); |
| | |
| | | |
| | | await DeleteTaskAsync(task.TaskId); |
| | | await AddTaskHtyAsync(taskHty); |
| | | }); |
| | | _unitOfWorkManage.CommitTran(); |
| | | //}); |
| | | content.OK("åºåºå®æ"); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | task.ErrorMessage = ex.Message; |
| | | await BaseDal.UpdateDataAsync(task); |
| | | return content.Error(ex.Message); |
| | |
| | | { |
| | | return content.Error("æªæ¾å°ç»çæ°æ®"); |
| | | } |
| | | await ERPAllocate(boxinfo); |
| | | |
| | | if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.CarryGroup) |
| | | { |
| | | var result1 = UpdateLocationStatus(task.SourceAddress, LocationEnum.Free, task.TaskNum.Value, StatusChangeTypeEnum.AutomaticInbound); |
| | | await _locationStatusChangeRecordRepository.AddDataAsync(result1.Item1); |
| | | await _locationRepository.UpdateDataAsync(result1.Item2); |
| | | } |
| | | |
| | | |
| | | |
| | | var stock = CreateStock(boxinfo, task); |
| | | |
| | |
| | | |
| | | var result2 = UpdateLocationStatus(task.TargetAddress, LocationEnum.InStock, task.TaskNum.Value, StatusChangeTypeEnum.AutomaticInbound); |
| | | |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | | { |
| | | await _stockInfoRepository.AddDataNavAsync(stock); |
| | | //await _unitOfWorkManage.UseTranAsync(async () => |
| | | //{ |
| | | _unitOfWorkManage.BeginTran(); |
| | | await _stockInfoRepository.AddDataNavAsync(stock); |
| | | await DeleteTaskAsync(task.TaskId); |
| | | await AddTaskHtyAsync(taskHty); |
| | | await _locationStatusChangeRecordRepository.AddDataAsync(result2.Item1); |
| | | await _locationRepository.UpdateDataAsync(result2.Item2); |
| | | }); |
| | | _unitOfWorkManage.CommitTran(); |
| | | //}); |
| | | await ERPAllocate(boxinfo); |
| | | content.OK("å
¥åºå®æ"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | task.ErrorMessage = ex.Message; |
| | | await BaseDal.UpdateDataAsync(task); |
| | | return content.Error(ex.Message); |
| | |
| | | }; |
| | | } |
| | | #endregion å
¥åºä»»å¡å®æ |
| | | |
| | | #region AGVæ¬è¿ä»»å¡å®æ |
| | | public async Task<WebResponseContent> CompleteCarryTaskAsync(Dt_Task task,DtStockInfo stockInfo) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var Sourcelocation = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.SourceAddress); |
| | | var Targetlocation = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.TargetAddress); |
| | | |
| | | //UpdateLocationStatus(Sourcelocation, LocationEnum.Free); |
| | | //UpdateLocationStatus(Targetlocation, LocationEnum.InStock); |
| | | |
| | | task.TaskState = (int)TaskAGVCarryStatusEnum.CarryFinish; |
| | | var taskHty = task.Adapt<Dt_Task_Hty>(); |
| | | taskHty.FinishTime = DateTime.Now; |
| | | taskHty.OperateType = App.User.UserName != null ? (int)OperateTypeEnum.äººå·¥å®æ : (int)OperateTypeEnum.èªå¨å®æ; |
| | | taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System"; |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | | { |
| | | await DeleteTaskAsync(task.TaskId); |
| | | await AddTaskHtyAsync(taskHty); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region AGV跨楼å±ä»»å¡å®æ |
| | | public async Task<WebResponseContent> CompleteAcrossFloorTaskAsync(Dt_Task task, DtStockInfo stockInfo) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryFinish; |
| | | var taskHty = task.Adapt<Dt_Task_Hty>(); |
| | | taskHty.FinishTime = DateTime.Now; |
| | | taskHty.OperateType = App.User.UserName != null ? (int)OperateTypeEnum.äººå·¥å®æ : (int)OperateTypeEnum.èªå¨å®æ; |
| | | taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System"; |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | | { |
| | | await DeleteTaskAsync(task.TaskId); |
| | | await AddTaskHtyAsync(taskHty); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ä»»å¡å®æ |
| | | |
| | |
| | | return content.Error("æçä¿¡æ¯ä¸åå¨ï¼è¯·ç¡®è®¤æçå·²ç»çæå"); |
| | | } |
| | | |
| | | foreach (var item in boxingInfo.BoxingInfoDetails) |
| | | { |
| | | var ERPStock = SqlSugarHelper.DBERPtext.Queryable<ç¨å峿¶åºå_ST>().Where(x => x.åå¨å°ç¹åç§° == item.Warehouse && x.æå· == item.MaterielCode && x.åå == item.MaterielName && x.åºåæ°é >= item.Quantity).ToList().FirstOrDefault(); |
| | | if (ERPStock == null) |
| | | { |
| | | return content.Error($"ç»çæ°æ®æªå¨ERPåºåæ°æ®ä¸ï¼è¯·äººå·¥ç¡®è®¤æ°æ®æ¯å¦æ£ç¡®"); |
| | | } |
| | | } |
| | | //foreach (var item in boxingInfo.BoxingInfoDetails) |
| | | //{ |
| | | // var ERPStock = SqlSugarHelper.DBERP.Queryable<ç¨å峿¶åºå_ST>().Where(x => x.åå¨å°ç¹åç§° == item.Warehouse && x.æå· == item.MaterielCode && x.åå == item.MaterielName && x.åºåæ°é >= item.Quantity).ToList().FirstOrDefault(); |
| | | // if (ERPStock == null) |
| | | // { |
| | | // return content.Error($"ç»çæ°æ®æªå¨ERPåºåæ°æ®ä¸ï¼è¯·äººå·¥ç¡®è®¤æ°æ®æ¯å¦æ£ç¡®"); |
| | | // } |
| | | //} |
| | | |
| | | var StartAddress = await _locationRepository.QueryFirstAsync(x => x.LocationCode == taskDto.Position); |
| | | if (StartAddress == null) |
| | |
| | | case 4: |
| | | case 5: |
| | | case 6: |
| | | case 7: |
| | | taskNew = InboundAGVCacheArea(taskDto, StartAddress, area); |
| | | break; |
| | | default: |
| | |
| | | |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | | { |
| | | if (taskDto.AreaId == 3 || taskDto.AreaId == 7) |
| | | { |
| | | var result2 = UpdateLocationStatus(taskNew.TargetAddress, LocationEnum.Lock, taskNew.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticInbound); |
| | | await _locationStatusChangeRecordRepository.AddDataAsync(result2.Item1); |
| | | await _locationRepository.UpdateDataAsync(result2.Item2); |
| | | } |
| | | await _locationStatusChangeRecordRepository.AddDataAsync(result.Item1); |
| | | await _locationRepository.UpdateDataAsync(result.Item2); |
| | | BaseDal.AddData(taskNew); |
| | |
| | | /// </summary> |
| | | /// <param name="palletCode"></param> |
| | | /// <returns></returns> |
| | | public async Task<WebResponseContent> OutBoundTaskAsync(string palletCode,string remark) |
| | | public async Task<WebResponseContent> OutBoundTaskAsync(string palletCode,string remark,int doubleTray) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | |
| | | return content.Error("该æçåºåå·²å¨åºåºç¼ååº"); |
| | | } |
| | | |
| | | Dt_Task taskNew = await RequestOutboundTaskAsync(new RequestTaskDto { PalletCode = palletCode, AreaId = 2, Position = stcok.LocationCode, TaskType = (int)TaskOutboundTypeEnum.Outbound }); |
| | | Dt_Task taskNew = await RequestOutboundTaskAsync(new RequestTaskDto { PalletCode = palletCode, AreaId = 2, Position = stcok.LocationCode, TaskType = (int)TaskOutboundTypeEnum.Outbound, DoubleTray= doubleTray }); |
| | | List<Dt_InventoryRecord> records = new List<Dt_InventoryRecord>(); |
| | | stcok.StockInfoDetails.ForEach(x => |
| | | { |
| | |
| | | }); |
| | | |
| | | var taskDto = CreateListTaskDTO(taskNew); |
| | | var result = GetlcoationState(taskNew, StatusChangeTypeEnum.AutomaticOutbound); |
| | | var result = GetlcoationState(taskNew, StatusChangeTypeEnum.AutomaticOutbound, location); |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | | { |
| | | await BaseDal.AddDataAsync(taskNew); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// å
¶ä»åºåº |
| | | /// </summary> |
| | | /// <param name="details"></param> |
| | | /// <returns></returns> |
| | | |
| | | public async Task<WebResponseContent> OtherOutBoundTaskAsync(List<DtStockInfoDetail> details) |
| | | { |
| | |
| | | stock.StockInfoDetails = details; |
| | | |
| | | var taskDto = CreateListTaskDTO(taskNew); |
| | | var result = GetlcoationState(taskNew, StatusChangeTypeEnum.AutomaticOutbound); |
| | | var result = GetlcoationState(taskNew, StatusChangeTypeEnum.AutomaticOutbound, stock.LocationInfo); |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | | { |
| | | await BaseDal.AddDataAsync(taskNew); |
| | |
| | | stock.StockInfoDetails = details; |
| | | |
| | | var taskDto = CreateListTaskDTO(taskNew); |
| | | var result = GetlcoationState(taskNew, StatusChangeTypeEnum.AutomaticOutbound); |
| | | var result = GetlcoationState(taskNew, StatusChangeTypeEnum.AutomaticOutbound, stock.LocationInfo); |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | | { |
| | | await BaseDal.AddDataAsync(taskNew); |
| | |
| | | } |
| | | } |
| | | |
| | | public (List<DtLocationStatusChangeRecord>,List<DtLocationInfo>) GetlcoationState(Dt_Task task, StatusChangeTypeEnum StatusChangeTypeEnum) |
| | | public (List<DtLocationStatusChangeRecord>,List<DtLocationInfo>) GetlcoationState(Dt_Task task, StatusChangeTypeEnum StatusChangeTypeEnum, DtLocationInfo location) |
| | | { |
| | | List<DtLocationStatusChangeRecord> locationStatusChangeRecords = new List<DtLocationStatusChangeRecord>(); |
| | | List<DtLocationInfo> locations = new List<DtLocationInfo>(); |
| | | var result = UpdateLocationStatus(task.SourceAddress, LocationEnum.InStockDisable, task.TaskNum.Value, (int)StatusChangeTypeEnum); |
| | | locationStatusChangeRecords.AddRange(result.Item1); |
| | | locations.AddRange(result.Item2); |
| | | |
| | | if(location.AreaId ==3|| location.AreaId == 7) |
| | | { |
| | | var result2 = UpdateLocationStatus(task.TargetAddress, LocationEnum.Lock, task.TaskNum.Value, (int)StatusChangeTypeEnum); |
| | | locationStatusChangeRecords.AddRange(result2.Item1); |
| | | locations.AddRange(result2.Item2); |
| | | } |
| | | |
| | | return (locationStatusChangeRecords,locations); |
| | | } |
| | |
| | | case 4: |
| | | case 5: |
| | | case 6: |
| | | case 7: |
| | | return OutboundAGVCacheArea(taskDto, StartAddress, area); |
| | | default: |
| | | throw new Exception("è¯·éæ©æ£ç¡®çåºåä¿¡æ¯"); |
| | |
| | | await BaseDal.AddDataAsync(taskNew); |
| | | }); |
| | | await SendWCSTask(CreateListTaskDTO(taskNew)); |
| | | return content.OK(); |
| | | return content.OK("æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | Remark = StartAddress.AreaId.ToString(), |
| | | AGVTaskNum = GenerateUniqueId(), |
| | | Floor = StartAddress.Floor, |
| | | DoubleTray = taskDto.DoubleTray, |
| | | }; |
| | | |
| | | } |
| | |
| | | switch (location.AreaId) |
| | | { |
| | | case 2: |
| | | case 7: |
| | | locationInfos = _locationRepository.QueryData(x => x.Row == location.Row && x.Column > location.Column && x.Remark == location.Remark && x.AreaId == location.AreaId); |
| | | break; |
| | | case 5: |
| | |
| | | case 4: |
| | | case 5: |
| | | case 6: |
| | | case 7: |
| | | locationInfo = await GetAGVEmptyCacheLocation(areaInfo.AreaID, location); |
| | | break; |
| | | default: |
| | |
| | | return (changeRecordDto, locations); |
| | | } |
| | | |
| | | public (DtLocationStatusChangeRecord, DtLocationInfo) UpdateEndLocationStatus(string locationCode, LocationEnum locationStatus, int taskNum, StatusChangeTypeEnum StatusChangeType) |
| | | { |
| | | var location = _locationRepository.QueryFirst(x => x.LocationCode == locationCode); |
| | | |
| | | if (location != null && (location.AreaId == 3 || location.AreaId == 7)) |
| | | { |
| | | int Beforelocation = location.LocationStatus; |
| | | |
| | | location.LocationStatus = (int)locationStatus; |
| | | |
| | | DtLocationStatusChangeRecord dtLocationStatusChangeRecord = new DtLocationStatusChangeRecord() |
| | | { |
| | | ChangeType = (int)StatusChangeType, |
| | | LocationCode = locationCode, |
| | | LocationId = location.Id, |
| | | Creater = "System", |
| | | TaskNum = taskNum, |
| | | AfterStatus = location.LocationStatus, |
| | | BeforeStatus = Beforelocation, |
| | | }; |
| | | |
| | | return (dtLocationStatusChangeRecord, location); |
| | | } |
| | | return (null, null); |
| | | } |
| | | |
| | | public (DtLocationStatusChangeRecord, DtLocationInfo) UpdateLocationStatus(string locationCode, LocationEnum locationStatus, int taskNum, StatusChangeTypeEnum StatusChangeType) |
| | | { |
| | | var location = _locationRepository.QueryFirst(x => x.LocationCode == locationCode); |
| | |
| | | } |
| | | } |
| | | } |
| | | else if (location.AreaId == 2) |
| | | else if (location.AreaId == 2 || location.AreaId == 7) |
| | | { |
| | | var locationLateral = _locationRepository.QueryData(x => x.Row == location.Row && x.Column > location.Column && x.Remark == location.Remark); |
| | | if (locationLateral.Count > 0) |
| | |
| | | TaskType = task.TaskType, |
| | | Floor =task.Floor, |
| | | AGVTaskNum = task.AGVTaskNum, |
| | | DoubleTray = task.DoubleTray, |
| | | } }; |
| | | } |
| | | |
| | |
| | | AGVTaskNum = task.AGVTaskNum, |
| | | Remark = task.Remark, |
| | | Floor = task.Floor, |
| | | DoubleTray = task.DoubleTray, |
| | | }; |
| | | } |
| | | private List<WMSTaskDTO> CreateTaskDTO(List<Dt_Task> task) |
| | |
| | | AGVTaskNum = item.AGVTaskNum, |
| | | Remark = item.Remark, |
| | | Floor = item.Floor, |
| | | DoubleTray = item.DoubleTray, |
| | | }); |
| | | } |
| | | |
| | |
| | | switch (AreaId) |
| | | { |
| | | case 2: |
| | | case 7: |
| | | return await FromShallowToDeep(AreaId, loc); |
| | | case 3: |
| | | return await AGVLIKU(AreaId); |
| | |
| | | } |
| | | } |
| | | |
| | | else if (location.AreaId == 2) |
| | | else if (location.AreaId == 2 || location.AreaId == 7) |
| | | { |
| | | var locationLateral = _locationRepository.QueryData(x => x.Row == location.Row && x.Column > location.Column && x.Remark == location.Remark); |
| | | |