| | |
| | | using WIDESEA_Common.WareHouseEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_Model.Models; |
| | | |
| | |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.MES空æéåº.ObjToInt()) |
| | | { |
| | | //todo ææ¶æªå¯ç¨ |
| | | return WebResponseContent.Instance.Error($"ç©ºææªå¯ç¨"); |
| | | //newTask.TaskType = TaskTypeEnum.MesPalletReturn.ObjToInt(); |
| | | //todo å°æçææ¶æªå¯ç¨ |
| | | if (stockInfo.PalletType == PalletTypeEnum.MediumPallet.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesPalletLargeReturn.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesPalletSmallReturn.ObjToInt(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | return WebResponseContent.Instance.OK(data: task.TargetAddress); |
| | | } |
| | | |
| | | |
| | | Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId); |
| | | if (locationInfo == null) |
| | | { |
| | |
| | | |
| | | task.Roadway = roadwayNo; |
| | | task.TargetAddress = locationInfo.LocationCode; |
| | | task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | if (task.Roadway.Contains("AGV")) |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.AGV_Execute.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | } |
| | | |
| | | |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// æå使éåºå
¥ä» |
| | | /// </summary> |
| | | /// <param name="barCode"></param> |
| | | /// <param name="startPoint"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent BackProductTask(string barCode, string startPoint) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //夿å½åç¹ä½æ¯å¦éå¤ |
| | | Dt_Task taskOldPoint = BaseDal.QueryFirst(x=>x.SourceAddress==startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt()||x.TaskStatus==TaskStatusEnum.Line_Execute.ObjToInt()|| x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Takeing.ObjToInt())); |
| | | if (taskOldPoint != null) |
| | | { |
| | | return content.Error($"ç«ç¹{startPoint}å·²åå¨ä»»å¡"); |
| | | } |
| | | Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode); |
| | | if (taskOld != null) |
| | | { |
| | | return content.Error($"è¶æ¡{barCode}ä»»å¡å·²åå¨"); |
| | | } |
| | | //è·åè¶æ¡ä½æ |
| | | Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x=>x.PalletCode== barCode).Includes(x=>x.proStockInfoDetails).First(); |
| | | if (proStockInfo==null) |
| | | { |
| | | return content.Error($"æªæ¾å°{barCode}è¶æ¡ä¿¡æ¯"); |
| | | } |
| | | if (proStockInfo.proStockInfoDetails==null || proStockInfo.proStockInfoDetails.Count<=0) |
| | | { |
| | | return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ä¸ºç©º"); |
| | | } |
| | | if (proStockInfo.StockStatus!=StockStatusEmun.åºåºå®æ.ObjToInt()) |
| | | { |
| | | return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ç¶æå¼å¸¸"); |
| | | } |
| | | //è·åæåå¹³åº |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString()); |
| | | if (proStockInfo.WarehouseId != warehouse.WarehouseId && proStockInfo.LocationCode!= "æåå
è£
æ£è´§åº") |
| | | { |
| | | return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ä¸å¨æ£è´§åº"); |
| | | } |
| | | //è·åå½åçåºå屿§ |
| | | Dt_Warehouse? warePoint = null; |
| | | switch (proStockInfo.ProStockAttribute) |
| | | { |
| | | case (int)ProStockAttributeEnum.æå: |
| | | warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA71.ToString()); |
| | | break; |
| | | case (int)ProStockAttributeEnum.å°¾æ°: |
| | | warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA72.ToString()); |
| | | break; |
| | | case (int)ProStockAttributeEnum.ç å: |
| | | warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA73.ToString()); |
| | | break; |
| | | default: |
| | | throw new Exception($"æªæ¾å°{barCode}è¶æ¡ä¿¡æ¯åºå屿§"); |
| | | } |
| | | Dt_Warehouse warehouseLocation = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA71.ToString()); |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == warehouseLocation.WarehouseId); |
| | | if (locationInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°{warehouse.WarehouseCode}è´§ä½ä¿¡æ¯"); |
| | | } |
| | | proStockInfo.StockStatus = StockStatusEmun.æå使ååº.ObjToInt(); |
| | | proStockInfo.proStockInfoDetails.ForEach(x => |
| | | { |
| | | x.ProOutDetailStatus = StockStatusEmun.æå使ååº.ObjToInt(); |
| | | }); |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = startPoint, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = proStockInfo.PalletCode, |
| | | Roadway = locationInfo.RoadwayNo, |
| | | SourceAddress = startPoint, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.InProductBack.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warePoint.WarehouseId, |
| | | PalletType = proStockInfo.PalletType |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails); |
| | | _unitOfWorkManage.CommitTran(); |
| | | //æ¨éä»»å¡ |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | content.OK("åéæå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// 空æ¡ååº |
| | | /// </summary> |
| | | public WebResponseContent EmptyBackTask(string barCode, string startPoint) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //夿å½åç¹ä½æ¯å¦éå¤ |
| | | Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Execute.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt())); |
| | | //if (taskOldPoint != null) |
| | | //{ |
| | | // return content.Error($"ç«ç¹{startPoint}å·²åå¨ä»»å¡"); |
| | | //} |
| | | Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode); |
| | | if (taskOld != null) |
| | | { |
| | | return content.Error($"è¶æ¡{barCode}ä»»å¡å·²åå¨"); |
| | | } |
| | | |
| | | //è·åæåå¹³åº |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString()); |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = startPoint, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = barCode, |
| | | Roadway = "CL01_CP", |
| | | SourceAddress = startPoint, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId, |
| | | PalletType = 1 |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _unitOfWorkManage.CommitTran(); |
| | | //æ¨éä»»å¡ |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | content.OK("åéæå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |