| | |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | using Autofac.Core; |
| | | using Microsoft.IdentityModel.Tokens; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.MaterielEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.Basic; |
| | | using WIDESEA_DTO.ERP; |
| | | using WIDESEA_DTO.MES; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_External.Model; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_TaskInfoRepository; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.éåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MESéåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES空æéåº.ObjToInt()) |
| | | if (stockInfo.StockStatus != StockStatusEmun.MES使éåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES空æéåº.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); |
| | | } |
| | |
| | | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.MESéåº.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.MES空æéåº.ObjToInt()) |
| | | { |
| | | //todo å°æçææ¶æªå¯ç¨ |
| | | if (stockInfo.PalletType == PalletTypeEnum.MediumPallet.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesPalletLargeReturn.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesPalletSmallReturn.ObjToInt(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestYLWMSTaskSimple(string stationCode, string palletCode) |
| | | { |
| | | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (task != null) |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | PushTasksToWCS(new List<Dt_Task> { task }); |
| | | return WebResponseContent.Instance.OK($"该æçå·²çæä»»å¡", _mapper.Map<WMSTaskDTO>(task)); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.RfidCode == palletCode); |
| | | if (stockInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°ç»çä¿¡æ¯"); |
| | | } |
| | | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode); |
| | | if (task != null) |
| | | { |
| | | PushTasksToWCS(new List<Dt_Task> { task }); |
| | | return content.OK($"该æçå·²çæä»»å¡", _mapper.Map<WMSTaskDTO>(task)); |
| | | } |
| | | |
| | | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); |
| | | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null) |
| | | { |
| | | return content.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.èåéåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.åæéç»çæå.ObjToInt()) |
| | | { |
| | | return content.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); |
| | | } |
| | | //åé
å··é |
| | | string rowWay = AssignYLRoadwayNo(stockInfo.PalletCode); |
| | | if (string.IsNullOrEmpty(rowWay)) |
| | | { |
| | | return content.Error($"æªæ¾å°å¯åé
å··é"); |
| | | } |
| | | //çæä»»å¡ |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = stockInfo.PalletCode, |
| | | RfidCode=stockInfo.RfidCode, |
| | | Roadway = rowWay, |
| | | SourceAddress = stationCode, |
| | | TargetAddress = "", |
| | | TaskType = stationCode=="307" ? TaskTypeEnum.PaperOldYLBackInbound.ObjToInt() : TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | TaskLength = (int)stockInfo.MaterielWide |
| | | }; |
| | | //æ´æ°ç¶æ |
| | | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | //æ°æ®æ´æ° |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); |
| | | return content.OK(data: wMSTaskDTO); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (stockInfo == null) |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); |
| | | } |
| | | string rowWay = AssignYLRoadwayNo(stockInfo.PalletCode); |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = palletCode, |
| | | Roadway = rowWay, |
| | | SourceAddress = stationCode, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | }; |
| | | |
| | | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); |
| | | return WebResponseContent.Instance.OK(data: wMSTaskDTO); |
| | | return content; |
| | | } |
| | | private readonly static object lockerYLBoxing = new object(); |
| | | /// <summary> |
| | | /// åæè¯·æ± |
| | | /// </summary> |
| | | /// <param name="palletCode">RFIDä¿¡æ¯</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent YLPurchaseBoxing(string palletCode, decimal weight = 0, decimal thickness = 0, decimal wide = 0) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | lock (lockerYLBoxing) |
| | | { |
| | | Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.RfidCode == palletCode); |
| | | if (stockInfoOld != null && stockInfoOld.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | | { |
| | | UpdateStock(stockInfoOld, weight, thickness, wide); |
| | | return content.OK($"临æ¶å
¥åº{stockInfoOld.RfidCode}"); |
| | | } |
| | | else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.èå.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.èåéåº.ObjToInt()) |
| | | { |
| | | UpdateStock(stockInfoOld, weight, thickness, wide); |
| | | return content.OK($"èåéåº{stockInfoOld.RfidCode}"); |
| | | } |
| | | else if (stockInfoOld != null) |
| | | { |
| | | return content.Error("RFIDä¿¡æ¯å·²åå¨"); |
| | | } |
| | | #region å¤çéè´ç»å®RFIDé»è¾ |
| | | Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.èå.ToString()).FirstOrDefault(); |
| | | if (yLInboundCache == null) |
| | | { |
| | | return content.Error("æªæ¾å°åæç¼åæ¡ç ä¿¡æ¯"); |
| | | } |
| | | if (yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt()) |
| | | { |
| | | return content.Error($"åæç¼åæ¡ç {yLInboundCache.BarCode}å·²ç»å®RFID{yLInboundCache.RfidCode}"); |
| | | } |
| | | else |
| | | { |
| | | Dt_StockInfo ExistStockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == yLInboundCache.BarCode); |
| | | if (ExistStockInfo != null && ExistStockInfo.MaterielInvOrgId == MaterielInvOrgEnum.èå.ObjToInt() && ExistStockInfo.StockStatus == StockStatusEmun.åæéç»çæå.ObjToInt()) |
| | | { |
| | | yLInboundCache.RfidCode = palletCode; |
| | | yLInboundCache.BindStatus = WhetherEnum.True.ObjToInt(); |
| | | ExistStockInfo.RfidCode = palletCode; |
| | | _unitOfWorkManage.BeginTran(); |
| | | //æ´æ°ç»çä¿¡æ¯ |
| | | UpdateStock(ExistStockInfo, weight, thickness, wide); |
| | | _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return content.OK($"åæéåºå转å{ExistStockInfo.RfidCode}"); |
| | | } |
| | | else |
| | | { |
| | | //è·åéè´ä¿¡æ¯ |
| | | Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _purchaseBSTOrderDetailRepository.QueryFirst(x => x.Barcode == yLInboundCache.BarCode); |
| | | if (purchaseBSTOrderDetail == null) |
| | | { |
| | | return content.Error($"æªæ¾å°æ¡ç {yLInboundCache.BarCode}éè´ä¿¡æ¯"); |
| | | } |
| | | if (purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus != InOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | return content.Error($"éè´{purchaseBSTOrderDetail.Barcode}ä¿¡æ¯å·²å
¥åºæå
¥åºä¸"); |
| | | } |
| | | else |
| | | { |
| | | purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | purchaseBSTOrderDetail.RfidCode = palletCode; |
| | | } |
| | | //è·åéè´ä¸»å |
| | | Dt_PurchaseBSTOrder purchaseBSTOrder = _purchaseBSTOrderRepository.QueryFirst(x => x.Id == purchaseBSTOrderDetail.PurchaseBSTOrderId); |
| | | //è·åç©æ |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterialSourceId == purchaseBSTOrderDetail.MaterialId); |
| | | //çæåºåç»çä¿¡æ¯ |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | MaterielInvOrgId = materielInfo.MaterielInvOrgId, |
| | | PalletCode = purchaseBSTOrderDetail.Barcode, |
| | | RfidCode = palletCode, |
| | | LocationCode = "", |
| | | PalletType = 1, |
| | | WarehouseId = materielInfo.WarehouseId, |
| | | StockAttribute = materielInfo.MaterielSourceType, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | MaterielSpec = materielInfo.MaterielSpec, |
| | | Unit = materielInfo.MaterielUnit, |
| | | MaterielThickness = purchaseBSTOrderDetail.MaterialThick, |
| | | MaterielWide = purchaseBSTOrderDetail.MaterialWide, |
| | | MaterielWeight = purchaseBSTOrderDetail.DeliveryQty, |
| | | CheckWeight=weight, |
| | | CheckThickness=thickness, |
| | | CheckWide=wide, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | StockLength = purchaseBSTOrderDetail.ProcurementLength, |
| | | MaterielId = purchaseBSTOrderDetail.MaterialId |
| | | }; |
| | | if (purchaseBSTOrderDetail.MaterialWide > 1200) |
| | | { |
| | | stockInfo.PalletType = 2; |
| | | } |
| | | yLInboundCache.RfidCode = palletCode; |
| | | yLInboundCache.BindStatus = WhetherEnum.True.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | //æ°å¢ç»çä¿¡æ¯ |
| | | _stockRepository.StockInfoRepository.AddData(stockInfo); |
| | | if (purchaseBSTOrder.PurchaseOrderStatus == InOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | purchaseBSTOrder.PurchaseOrderStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | _purchaseBSTOrderRepository.UpdateData(purchaseBSTOrder); |
| | | } |
| | | _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache); |
| | | _purchaseBSTOrderDetailRepository.UpdateData(purchaseBSTOrderDetail); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | } |
| | | #endregion |
| | | content.OK("ç»å®æå"); |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | public void UpdateStock(Dt_StockInfo stockInfo, decimal weight = 0, decimal thickness = 0, decimal wide = 0) |
| | | { |
| | | stockInfo.CheckWeight = weight; |
| | | stockInfo.CheckThickness = thickness; |
| | | stockInfo.CheckWide = wide; |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | } |
| | | /// <summary> |
| | | /// åæéè´ç»å®RFID |
| | | /// </summary> |
| | | /// <param name="palletCode">çº¸å·æ¡ç </param> |
| | | /// <param name="rfidCode">纸å·RIFD</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent PurchaseBoxing(string palletCode) |
| | | { |
| | | WebResponseContent content=new WebResponseContent(); |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(palletCode)) |
| | | { |
| | | return content.Error("æ¡ç ä¸è½ä¸ºç©º"); |
| | | } |
| | | Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (stockInfoOld != null) |
| | | { |
| | | return content.Error("æ¡ç ä¿¡æ¯åºåä¸å·²åå¨"); |
| | | } |
| | | //è·åéè´ä¿¡æ¯ |
| | | Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _purchaseBSTOrderDetailRepository.QueryFirst(x => x.Barcode == palletCode); |
| | | if (purchaseBSTOrderDetail == null) |
| | | { |
| | | BSTResponse<BSTStockInfoDTO> bSTResponse = _invokeERPService.BSTStockAsync(palletCode).DeserializeObject<BSTResponse<BSTStockInfoDTO>>(); |
| | | if (bSTResponse.Code == 500) |
| | | { |
| | | return content.Error($"æªæ¾å°æ¡ç {palletCode}éè´ä¿¡æ¯å¹¶ä¸æERPåºåä¹ä¸åå¨"); |
| | | } |
| | | BSTStockInfoDTO bSTStockInfoDTO=bSTResponse.Data; |
| | | if (bSTStockInfoDTO==null) |
| | | { |
| | | return content.Error($"䏿ERPæªè¿å{palletCode}çåºåä¿¡æ¯"); |
| | | } |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterialSourceId == bSTStockInfoDTO.MaterialId); |
| | | if (materielInfo==null) |
| | | { |
| | | return content.Error($"æªæ¾å°æ¡ç {palletCode}ç©æä¿¡æ¯{bSTStockInfoDTO.MaterialNo}"); |
| | | } |
| | | //çæåºåç»çä¿¡æ¯ |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | MaterielInvOrgId = materielInfo.MaterielInvOrgId, |
| | | PalletCode = palletCode, |
| | | RfidCode = "", |
| | | LocationCode = "", |
| | | PalletType = 1, |
| | | WarehouseId = materielInfo.WarehouseId, |
| | | StockAttribute = materielInfo.MaterielSourceType, |
| | | StockStatus = StockStatusEmun.åæéç»çæå.ObjToInt(), |
| | | MaterielSpec = materielInfo.MaterielSpec, |
| | | Unit = materielInfo.MaterielUnit, |
| | | MaterielThickness = bSTStockInfoDTO.Thick, |
| | | MaterielWide = bSTStockInfoDTO.W, |
| | | MaterielWeight = bSTStockInfoDTO.Qty, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | StockLength = bSTStockInfoDTO.StockMeter, |
| | | MaterielId = materielInfo.MaterialSourceId |
| | | }; |
| | | if (bSTStockInfoDTO.W > 1200) |
| | | { |
| | | stockInfo.PalletType = 2; |
| | | } |
| | | Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.èå.ToString()).FirstOrDefault(); |
| | | if (yLInboundCache == null) |
| | | { |
| | | return content.Error("æªæ¾å°åææ¡ç ç¼åä¿¡æ¯"); |
| | | } |
| | | int Id = yLInboundCache.Id; |
| | | if (yLInboundCache.BarCode == palletCode) |
| | | { |
| | | return content.Error($"æ¡ç {palletCode}å·²æ«ç "); |
| | | } |
| | | else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt()) |
| | | { |
| | | yLInboundCache = _mapper.Map<Dt_YLInboundCache>(stockInfo); |
| | | yLInboundCache.Id = Id; |
| | | _unitOfWorkManage.BeginTran(); |
| | | //æ°å¢ç»çä¿¡æ¯ |
| | | _stockRepository.StockInfoRepository.AddData(stockInfo); |
| | | _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache); |
| | | WebResponseContent webResponse = YLPurchasePush(); |
| | | if (!webResponse.Status) |
| | | { |
| | | throw new Exception(webResponse.Message); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | return content.OK("æå", yLInboundCache); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"ä¸å·æ¡ç {yLInboundCache.BarCode}è¿æªè¿è¡ç»å®"); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus != InOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | return content.Error($"æ¡ç {palletCode}éè´ä¿¡æ¯å·²å
¥åºæå
¥åºä¸"); |
| | | } |
| | | Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.èå.ToString()).FirstOrDefault(); |
| | | if (yLInboundCache == null) |
| | | { |
| | | return content.Error("æªæ¾å°åææ¡ç ç¼åä¿¡æ¯"); |
| | | } |
| | | int Id = yLInboundCache.Id; |
| | | if (yLInboundCache.BarCode == palletCode) |
| | | { |
| | | return content.Error($"æ¡ç {palletCode}å·²æ«ç "); |
| | | } |
| | | else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt()) |
| | | { |
| | | yLInboundCache = _mapper.Map<Dt_YLInboundCache>(purchaseBSTOrderDetail); |
| | | yLInboundCache.Id = Id; |
| | | _unitOfWorkManage.BeginTran(); |
| | | _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache); |
| | | WebResponseContent webResponse = YLPurchasePush(); |
| | | if (!webResponse.Status) |
| | | { |
| | | throw new Exception(webResponse.Message); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | return content.OK("æå", yLInboundCache); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"ä¸å·æ¡ç {yLInboundCache.BarCode}è¿æªè¿è¡ç»å®"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// æ¨éè³WCSåæçº¿ä½å¯å¨ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent YLPurchasePush() |
| | | { |
| | | try |
| | | { |
| | | string url = AppSettings.Get("WCS"); |
| | | if (string.IsNullOrEmpty(url)) |
| | | { |
| | | throw new Exception($"æªæ¾å°WCSAApiå°å,è¯·æ£æ¥é
ç½®æä»¶"); |
| | | } |
| | | string response = HttpHelper.Post($"{url}/api/Task/YLPurchasePush?code=406"); |
| | | |
| | | return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("è¿åé误"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// åæåé
å··é |
| | | /// </summary> |
| | | /// <param name="palletCode">æ¡ç å·</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public string AssignYLRoadwayNo(string palletCode) |
| | | { |
| | | try |
| | | { |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | |
| | | if (stockInfo==null) |
| | | { |
| | | throw new Exception($"ç»çåºåä¸åå¨"); |
| | | } |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == stockInfo.WarehouseId); |
| | | |
| | | if (warehouse == null) |
| | |
| | | } |
| | | |
| | | string roadwayNo = ""; |
| | | if (stockInfo.MaterielWide < 2200 && stockInfo.MaterielThickness > 800) |
| | | |
| | | if (stockInfo.MaterielInvOrgId==MaterielInvOrgEnum.æ°å.ObjToInt()) |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationType == LocationTypeEnum.Undefined.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("SC01_YL")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | //éå¶ç´å¾ |
| | | if (stockInfo.MaterielThickness >= 300 && stockInfo.MaterielThickness <= 1300 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2700) |
| | | { |
| | | //è·ååé
|
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("YLDual") && (stockInfo.PalletType == LocationTypeEnum.MediumPallet.ObjToInt() ? x.LocationType == LocationTypeEnum.MediumPallet.ObjToInt(): x.LocationType == LocationTypeEnum.SmallPallet.ObjToInt())).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | |
| | | roadwayNo = HandleRoadway(locationCounts, warehouse); |
| | | } |
| | | } |
| | | else if (stockInfo.MaterielWide>2200 && stockInfo.MaterielThickness>800) |
| | | else |
| | | { |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationType == LocationTypeEnum.Undefined.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && !x.RoadwayNo.Contains("SC01_YL")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | //éå¶ |
| | | if (stockInfo.MaterielThickness >= 800 && stockInfo.MaterielThickness <= 1500 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500) |
| | | { |
| | | bool LayerLimit = false; |
| | | if (stockInfo.MaterielThickness>1300) |
| | | { |
| | | LayerLimit = true; |
| | | } |
| | | //è·ååé
|
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("YL") && !x.RoadwayNo.Contains("YLDual") && (LayerLimit ? x.Columns>=56 : x.Columns<=55)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | if (stockInfo.MaterielWide > 2200) |
| | | { |
| | | locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo == "SC02_YL" && (LayerLimit ? x.Columns >= 56 : x.Columns <= 55)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | } |
| | | |
| | | roadwayNo = HandleRoadway(locationCounts, warehouse); |
| | | } |
| | | } |
| | | |
| | | return !string.IsNullOrEmpty(roadwayNo) ? (roadwayNo) : throw new Exception("æªæ¾å°å¯åé
å··é"); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | //å¤çåé
å··é 任塿°é |
| | | public string HandleRoadway(List<LocationCount> locationCounts, Dt_Warehouse warehouse) |
| | | { |
| | | //å··éä»»å¡åé
æ°é |
| | | List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => x.WarehouseId == warehouse.WarehouseId |
| | | && locationCounts.Select(j => j.RoadwayNo).Distinct().Contains(x.Roadway) |
| | | && TaskInboundTypes.Contains(x.TaskType)).GroupBy(x => x.Roadway).Select(x => new LocationCount { RoadwayNo = x.Roadway, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | foreach (var item in locationCounts) |
| | | { |
| | | LocationCount? count = useLocationCounts.FirstOrDefault(x => x.RoadwayNo == item.RoadwayNo); |
| | | if (count != null) |
| | | { |
| | | item.Count -= count.Count; |
| | | } |
| | | } |
| | | return locationCounts.Where(x => x.Count > 0).OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | /// <summary> |
| | | /// å
¥åºå®æ |
| | | /// </summary> |
| | | public WebResponseContent InboundTaskCompleted(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == task.WarehouseId); |
| | | if (warehouse.WarehouseCode == WarehouseEnum.LLDCP.ToString() || warehouse.WarehouseCode == WarehouseEnum.LLDFL.ToString()) //æå/è¾
æå®æ |
| | | { |
| | | Dt_LocationInfo locationInfoEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | if (locationInfoEnd == null) |
| | | { |
| | | return content.Error($"æªæ¾å°å¯¹åºçç»ç¹è´§ä½ä¿¡æ¯"); |
| | | } |
| | | Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.SourceAddress && ( x.StationArea == nameof(AGVStationAreaEnum.䏿¥¼æå°ç 头) || x.StationArea == nameof(AGVStationAreaEnum.䏿¥¼æ 纺ç»å¸) || x.StationArea == nameof(AGVStationAreaEnum.䏿¥¼æ 纺æ·è) || x.StationArea == nameof(AGVStationAreaEnum.䏿¥¼æ 纺æ·è))); |
| | | if (agvstation != null) |
| | | { |
| | | agvstation.IsOccupied = WhetherEnum.False.ObjToInt(); |
| | | } |
| | | Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x=>x.proStockInfoDetails).First(); |
| | | if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.MES空æéåº.ObjToInt()) |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (agvstation != null) |
| | | { |
| | | _agvStationInfoRepository.UpdateData(agvstation); |
| | | } |
| | | proStockInfo.LocationCode = locationInfoEnd.LocationCode; |
| | | proStockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, proStockInfo.PalletType, LocationStatusEnum.InStock, proStockInfo.WarehouseId); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.äººå·¥å®æ : WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | else if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt()) |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | proStockInfo.proStockInfoDetails.ForEach(x => |
| | | { |
| | | x.ProStockDetailStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (agvstation != null) |
| | | { |
| | | _agvStationInfoRepository.UpdateData(agvstation); |
| | | } |
| | | proStockInfo.LocationCode = locationInfoEnd.LocationCode; |
| | | proStockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, proStockInfo.PalletType, LocationStatusEnum.InStock, proStockInfo.WarehouseId); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.äººå·¥å®æ : WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"æªæ¾å°å¯¹åºåºåä¿¡æ¯"); |
| | | } |
| | | } |
| | | else//åæåºå®æ |
| | | { |
| | | //è·ååºå |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == task.PalletCode); |
| | | if (stockInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°å¯¹åºåºåä¿¡æ¯"); |
| | | } |
| | | //è·åè´§ä½ä¿¡æ¯ |
| | | Dt_LocationInfo locationInfoEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | if (locationInfoEnd == null) |
| | | { |
| | | return content.Error($"æªæ¾å°å¯¹åºçç»ç¹è´§ä½ä¿¡æ¯"); |
| | | } |
| | | //æ´æ°ç¶æ |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (task.TaskType == TaskTypeEnum.InPick.ObjToInt()) |
| | | { |
| | | Dt_LocationInfo locationInfoStart = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId); |
| | | } |
| | | stockInfo.LocationCode = locationInfoEnd.LocationCode; |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | if (task.TaskType!=TaskTypeEnum.Inbound.ObjToInt()) |
| | | { |
| | | stockInfo.IsFull = WhetherEnum.True.ObjToInt(); |
| | | } |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.äººå·¥å®æ : WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | //䏿¥èåERP |
| | | if (stockInfo.MaterielInvOrgId == MaterielInvOrgEnum.èå.ObjToInt()) |
| | | { |
| | | int Qty = Convert.ToInt32(stockInfo.MaterielWeight); |
| | | BSTPurchaseUpModel bSTPurchaseUpModel = new BSTPurchaseUpModel() |
| | | { |
| | | Barcode = stockInfo.PalletCode, |
| | | BarcodeQty = Qty, |
| | | Rfid = stockInfo.RfidCode, |
| | | RfidUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") |
| | | }; |
| | | BSTResponse<object> bSTResponse = _invokeERPService.BSTPurchaseUp(bSTPurchaseUpModel).DeserializeObject<BSTResponse<object>>(); |
| | | if (bSTResponse.Code == 500) |
| | | { |
| | | throw new Exception($"BST䏿ERP忥å
¥åºä¿¡æ¯å¤±è´¥,é误信æ¯ï¼{bSTResponse.Msg}"); |
| | | } |
| | | content.Message = bSTResponse.Msg; |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// åé
æåå··é |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public string AssignCPRoadwayNo() |
| | | { |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == 2); |
| | | if (warehouse == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°å··é对åºä»åºä¿¡æ¯"); |
| | | } |
| | | |
| | | string roadwayNo = ""; |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationType == LocationTypeEnum.Undefined.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("CP")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | //è·åå··éå¯åé
çè´§ä½æ°é |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == WarehouseEnum.LLDCP.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("CP")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | //çéå½åå
¥åºä»»å¡ä¸å·²åé
å··é任塿°é |
| | | List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => (x.WarehouseId == WarehouseEnum.LLDCP.ObjToInt()|| x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt()) |
| | | && locationCounts.Select(j=>j.RoadwayNo).Distinct().Contains(x.Roadway) |
| | | && TaskInboundTypes.Contains(x.TaskType)).GroupBy(x => x.Roadway).Select(x => new LocationCount { RoadwayNo = x.Roadway, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | foreach (var item in locationCounts) |
| | | { |
| | | LocationCount? count = useLocationCounts.FirstOrDefault(x => x.RoadwayNo == item.RoadwayNo); |
| | | if (count!=null) |
| | | { |
| | | item.Count -= count.Count; |
| | | } |
| | | } |
| | | //éè¿å¯ç¨è´§ä½æ°éæåºï¼æå¤çä¼å
åé
|
| | | roadwayNo = locationCounts.Where(x=>x.Count>0).OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | return !string.IsNullOrEmpty(roadwayNo) ? (roadwayNo) : throw new Exception("æªæ¾å°å¯åé
å··é"); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡ç³è¯·åé
è´§ä½ |
| | | /// </summary> |
| | |
| | | { |
| | | return WebResponseContent.Instance.OK(data: task.TargetAddress); |
| | | } |
| | | |
| | | Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId); |
| | | Dt_StockInfo? stockInfo = null; |
| | | if (roadwayNo.Contains("YL")) |
| | | { |
| | | stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x=>x.PalletCode==task.PalletCode); |
| | | } |
| | | //åé
è´§ä½ |
| | | Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId, stockInfo); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | } |
| | | |
| | | |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | |
| | | //æ´æ°éå®è´§ä½ |
| | | _unitOfWorkManage.BeginTran(); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, task.PalletType, LocationStatusEnum.Lock, task.WarehouseId); |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AssignInboundTaskLocationByHeight(int taskNum, string roadwayNo, int heightType) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å
¥åºä»»å¡"); |
| | | } |
| | | |
| | | if (_basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress) != null) |
| | | { |
| | | return WebResponseContent.Instance.OK(data: task.TargetAddress); |
| | | } |
| | | |
| | | Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId, heightType: heightType); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | |
| | | task.Roadway = roadwayNo; |
| | | task.TargetAddress = locationInfo.LocationCode; |
| | | task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, task.PalletType, LocationStatusEnum.Lock, task.WarehouseId); |
| | | BaseDal.UpdateData(task); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(data: locationInfo.LocationCode); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | public readonly string[] OutStartPonits = { "5230", "5237", "5244" }; |
| | | /// <summary> |
| | | /// æå使éåºå
¥ä» |
| | | /// </summary> |
| | | /// <param name="barCode"></param> |
| | | /// <param name="startPoint"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent BackProductTask(string barCode, string startPoint) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string palletCode = @"^C\d{5}$"; // æ£åè¡¨è¾¾å¼ |
| | | bool isValid = Regex.IsMatch(barCode, palletCode); |
| | | if (!isValid) |
| | | { |
| | | return content.Error($"æ¡ç æ ¼å¼é误{barCode}"); |
| | | } |
| | | if (!OutStartPonits.Contains(startPoint)) |
| | | { |
| | | return content.Error($"èµ·ç¹é误{startPoint}"); |
| | | } |
| | | //夿å½åç¹ä½æ¯å¦éå¤ |
| | | 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, |
| | | MaterielCode = proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).FirstOrDefault()?.ProductCode, |
| | | Quantity = (float)proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).Sum(x => x.StockPcsQty) |
| | | }; |
| | | _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> |
| | |
| | | return content.Error($"èµ·ç¹é误{startPoint}"); |
| | | } |
| | | //夿å½åç¹ä½æ¯å¦éå¤ |
| | | Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && x.TaskStatus == TaskStatusEnum.New.ObjToInt()); |
| | | Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint &&( x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus==TaskStatusEnum.AGV_Executing.ObjToInt())); |
| | | if (taskOldPoint != null) |
| | | { |
| | | return content.Error($"ç«ç¹{startPoint}å·²åå¨ä»»å¡"); |
| | |
| | | //åé
å··é |
| | | string roadWay=AssignCPRoadwayNo(); |
| | | |
| | | //è·åæååº |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.LLDCP.ToString()); |
| | | Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo() |
| | | { |
| | | PalletCode=barCode, |
| | | ProStockAttribute=ProStockAttributeEnum.空æ.ObjToInt(), |
| | | PalletType=1, |
| | | LocationCode="", |
| | | WarehouseId=warehouse.WarehouseId, |
| | | WarehouseId= WarehouseEnum.LLDFL.ObjToInt(), |
| | | StockStatus=StockStatusEmun.MES空æéåº.ObjToInt() |
| | | }; |
| | | |
| | |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId, |
| | | WarehouseId = WarehouseEnum.LLDFL.ObjToInt(), |
| | | PalletType = 1 |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | private readonly static object _lockerFLorCP = new object(); |
| | | /// <summary> |
| | | /// è¾
æ/æå临æ¶å
¥åº |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent InboundFLOrCPTask(string barCode, string startPoint,string matCode,int matCount, int oneCount) |
| | | { |
| | | lock (_lockerFLorCP) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (matCount<1 || oneCount < 1) |
| | | { |
| | | return content.Error("ç©ææ»æ°æå个æ°éä¸è½å°äº1"); |
| | | } |
| | | //string palletCode = @"^C\d{5}$"; // æ£åè¡¨è¾¾å¼ |
| | | //bool isValid = Regex.IsMatch(barCode, palletCode); |
| | | //if (!isValid) |
| | | //{ |
| | | // return content.Error($"æ¡ç æ ¼å¼é误{barCode}"); |
| | | //} |
| | | //è·åç©æ |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == matCode && x.MaterielInvOrgId == MaterielInvOrgEnum.æ°å.ObjToInt() && (x.WarehouseId==WarehouseEnum.LLDCP.ObjToInt() || x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt())); |
| | | if (materielInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°ç©æä¿¡æ¯{matCode}"); |
| | | } |
| | | Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint); |
| | | if (agvstation == null) |
| | | { |
| | | return content.Error($"èµ·ç¹é误{startPoint}"); |
| | | } |
| | | //夿å½åç¹ä½æ¯å¦éå¤ |
| | | Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_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_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode); |
| | | if (proStockInfoOld != null) |
| | | { |
| | | return content.Error($"æç{barCode}å·²åå¨"); |
| | | } |
| | | //åé
å··é |
| | | string roadWay = AssignCPRoadwayNo(); |
| | | |
| | | //è·åæååº |
| | | WarehouseEnum warehouseEnum = materielInfo.MaterielSourceType == MaterielTypeEnum.æå.ObjToInt() ? WarehouseEnum.LLDCP : WarehouseEnum.LLDFL; |
| | | List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>(); |
| | | for (int i = 0; i < matCount; i++) |
| | | { |
| | | Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail() |
| | | { |
| | | ProductCode = materielInfo.MaterielCode, |
| | | ProductName = materielInfo.MaterielName, |
| | | ProductSpec = materielInfo.MaterielSpec, |
| | | ProductUnit = materielInfo.MaterielUnit, |
| | | StockQty = oneCount, |
| | | ProStockDetailStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt() |
| | | }; |
| | | proStockInfoDetails.Add(proStockInfoDetail); |
| | | } |
| | | |
| | | Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo() |
| | | { |
| | | PalletCode = barCode, |
| | | ProStockAttribute = materielInfo.MaterielSourceType, |
| | | PalletType = 1, |
| | | LocationCode = "", |
| | | WarehouseId = warehouseEnum.ObjToInt(), |
| | | StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(), |
| | | proStockInfoDetails = proStockInfoDetails |
| | | }; |
| | | |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = startPoint, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = barCode, |
| | | Roadway = roadWay, |
| | | SourceAddress = startPoint, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warehouseEnum.ObjToInt(), |
| | | PalletType = 1 |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | BaseDal.Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand(); |
| | | newTask.TaskId = taskId; |
| | | _unitOfWorkManage.CommitTran(); |
| | | //æ¨éä»»å¡ |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }, "AGV"); |
| | | content.OK("åéæå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// å°å·ä½æéæä»»å¡ |
| | | /// </summary> |
| | | public WebResponseContent PrintBackInbound(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var barcode = saveModel.MainData["palletCode"].ToString(); |
| | | var warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); |
| | | var materSn = saveModel.MainData["materSn"]; |
| | | //ç´å¾ |
| | | var thickness = saveModel.MainData["thickness"].ObjToInt(); |
| | | var weight = saveModel.MainData["weight"].ObjToInt(); |
| | | var address = saveModel.MainData["address"].ToString(); |
| | | //å¹
宽 |
| | | var wide = saveModel.MainData["wide"].ObjToInt(); |
| | | Dt_MaterielInfo? materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materSn); |
| | | if (materielInfo == null) |
| | | { |
| | | return content.Error("æªæ¾å°ç©æä¿¡æ¯"); |
| | | } |
| | | if (materielInfo.MaterielSourceType != MaterielTypeEnum.åææ.ObjToInt()) |
| | | { |
| | | return content.Error($"ç©æä¿¡æ¯ä¸ç¬¦å{MaterielTypeEnum.åææ}"); |
| | | } |
| | | Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == barcode); |
| | | if (stockInfoOld != null) |
| | | { |
| | | return content.Error("æçä¿¡æ¯å·²åå¨"); |
| | | } |
| | | //çæåºåç»çä¿¡æ¯ |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | MaterielInvOrgId = materielInfo.MaterielInvOrgId, |
| | | PalletCode = barcode, |
| | | LocationCode = "", |
| | | PalletType = 1, |
| | | WarehouseId = warehouseId, |
| | | StockAttribute = materielInfo.MaterielSourceType, |
| | | StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(), |
| | | MaterielSpec = materielInfo.MaterielSpec, |
| | | Unit = materielInfo.MaterielUnit, |
| | | MaterielThickness = thickness, |
| | | MaterielWide = wide, |
| | | MaterielWeight = weight, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | }; |
| | | if (wide > 1200) |
| | | { |
| | | stockInfo.PalletType = 2; |
| | | } |
| | | |
| | | //çæå°å·ä½æéæä»»å¡ |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = address, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = barcode, |
| | | Roadway = "", |
| | | SourceAddress = address, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.PrintYLBackInbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | TaskLength= wide |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | _stockRepository.StockInfoRepository.AddData(stockInfo); |
| | | newTask.TaskId = taskId; |
| | | _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 PrintInbound(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var barcode = saveModel.MainData["palletCode"].ToString(); |
| | | var warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); |
| | | var materSn = saveModel.MainData["materSn"]; |
| | | //ç´å¾ |
| | | var thickness = saveModel.MainData["thickness"].ObjToInt(); |
| | | var weight = saveModel.MainData["weight"].ObjToInt(); |
| | | var address = saveModel.MainData["address"].ToString(); |
| | | //å¹
宽 |
| | | var wide = saveModel.MainData["wide"].ObjToInt(); |
| | | Dt_MaterielInfo? materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materSn); |
| | | if (materielInfo == null) |
| | | { |
| | | return content.Error("æªæ¾å°ç©æä¿¡æ¯"); |
| | | } |
| | | if (materielInfo.MaterielSourceType!=MaterielTypeEnum.åæå.ObjToInt()) |
| | | { |
| | | return content.Error($"æªæ¾å°ç©æ{materielInfo.MaterielCode}åæåä¿¡æ¯"); |
| | | } |
| | | Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == barcode); |
| | | if (stockInfoOld != null) |
| | | { |
| | | return content.Error("æçä¿¡æ¯å·²åå¨"); |
| | | } |
| | | //çæåºåç»çä¿¡æ¯ |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | MaterielInvOrgId = materielInfo.MaterielInvOrgId, |
| | | PalletCode = barcode, |
| | | LocationCode = "", |
| | | PalletType = 1, |
| | | WarehouseId = warehouseId, |
| | | StockAttribute = materielInfo.MaterielSourceType, |
| | | StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(), |
| | | MaterielSpec = materielInfo.MaterielSpec, |
| | | Unit = materielInfo.MaterielUnit, |
| | | MaterielThickness = thickness, |
| | | MaterielWide = wide, |
| | | MaterielWeight = weight, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | }; |
| | | if (wide > 1200) |
| | | { |
| | | stockInfo.PalletType = 2; |
| | | } |
| | | |
| | | //çæå°å·åæåå
¥åºä»»å¡ |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = address, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = barcode, |
| | | Roadway = "", |
| | | SourceAddress = address, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.PrintYLInbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | TaskLength = wide |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | _stockRepository.StockInfoRepository.AddData(stockInfo); |
| | | newTask.TaskId = taskId; |
| | | _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 ReceiveProCodeInfo(List<MESProInDTO> proInDTOs) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (proInDTOs == null || proInDTOs.Count <= 0) |
| | | { |
| | | return content.Error("ä¼ å
¥ä¿¡æ¯ä¸ºç©º"); |
| | | } |
| | | //è·åæææåï¼åæåä¿¡æ¯ |
| | | List<Dt_MESProInOrderInfo> proInOrderInfos = _inboundRepository.MESProInOrderInfoRepository.QueryData(); |
| | | //è·åææç©æä¿¡æ¯ |
| | | List<Dt_MaterielInfo> materielInfos = _basicRepository.MaterielInfoRepository.QueryData(x => x.MaterielInvOrgId == MaterielInvOrgEnum.æ°å.ObjToInt()); |
| | | |
| | | MESProInDTO? CheckMaterialCode = proInDTOs.FirstOrDefault(x => !materielInfos.Select(x => x.MaterielCode).Contains(x.MaterialCode)); |
| | | if (CheckMaterialCode != null) |
| | | { |
| | | return content.Error($"ç©æç¼ç {nameof(MESProInDTO.MaterialCode)}:{CheckMaterialCode.MaterialCode}ä¿¡æ¯ä¸åå¨"); |
| | | } |
| | | //è·åææAGVç¹ä½ |
| | | List<Dt_AGVStationInfo> aGVStationInfos = _agvStationInfoRepository.QueryData(x => !string.IsNullOrEmpty(x.MESPointCode)); |
| | | |
| | | //夿æ¯å¦åå¨éå¤ |
| | | MESProInDTO? proInDTO = proInDTOs.FirstOrDefault(x => x.IsMantissa == false && proInOrderInfos.Select(x => x.BarCode).Contains(x.BarCode)); |
| | | if (proInDTO != null) |
| | | { |
| | | return content.Error($"{proInDTO.ProductOrderNo}ç产工å{proInDTO.BarCode}æ¡ç å·²åå¨"); |
| | | } |
| | | Dt_MESProInOrderInfo? proInOrderInfo = proInOrderInfos.FirstOrDefault(x => x.MESProInStatus == InOrderStatusEnum.å
³é.ObjToInt() && proInDTOs.Select(x => x.ProductOrderNo).Distinct().Contains(x.ProductOrderNo)); |
| | | if (proInOrderInfo != null) |
| | | { |
| | | return content.Error($"{proInOrderInfo.ProductOrderNo}ç产工åå·²å
³é"); |
| | | } |
| | | List<Dt_MESProInOrderInfo> AddMESProInOrders = new List<Dt_MESProInOrderInfo>(); |
| | | foreach (var item in proInDTOs) |
| | | { |
| | | Dt_MaterielInfo materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterialCode); |
| | | if (materielInfo.MaterielSourceType != MaterielTypeEnum.æå.ObjToInt()) |
| | | { |
| | | Dt_AGVStationInfo? CheckPointCode = aGVStationInfos.FirstOrDefault(x => x.MESPointCode == item?.PointCode); |
| | | if (CheckPointCode == null) |
| | | { |
| | | return content.Error($"å¨è½¬ä½{nameof(MESReturnIssueDTO.PointCode)}{item?.PointCode}ä¸åå¨,ä»
æåç©æå¯ä¸ä¼ "); |
| | | } |
| | | } |
| | | Dt_MESProInOrderInfo AddproInOrderInfo = _mapper.Map<Dt_MESProInOrderInfo>(item); |
| | | AddproInOrderInfo.WarehouseId = materielInfo.WarehouseId; |
| | | AddproInOrderInfo.MESProOrderType = materielInfo.MaterielSourceType; |
| | | AddMESProInOrders.Add(AddproInOrderInfo); |
| | | } |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | _inboundRepository.MESProInOrderInfoRepository.AddData(AddMESProInOrders); |
| | | if (AddMESProInOrders.Where(x => x.MESProOrderType == MaterielTypeEnum.åæå.ObjToInt()).Count() > 0) |
| | | { |
| | | //çæåæåå
¥åº |
| | | WebResponseContent webResponse = PrintInbound(AddMESProInOrders.Where(x => x.MESProOrderType == MaterielTypeEnum.åæå.ObjToInt()).ToList()); |
| | | if (!webResponse.Status) |
| | | { |
| | | throw new Exception(webResponse.Message); |
| | | } |
| | | tasks = webResponse.Data as List<Dt_Task>; |
| | | WebResponseContent taskResponse = PushTasksToWCS(tasks); |
| | | if (taskResponse.Status) |
| | | { |
| | | throw new Exception(taskResponse.Message); |
| | | } |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK("æ¥æ¶æå"); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// å°å·ä¸æMESä»»å¡ |
| | | /// </summary> |
| | | public WebResponseContent PrintInbound(List<Dt_MESProInOrderInfo> mESProInOrderInfos) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (mESProInOrderInfos.Count <= 0) |
| | | { |
| | | return content.Error("ä¼ å
¥ä¿¡æ¯ä¸ºç©º"); |
| | | } |
| | | |
| | | List<Dt_MaterielInfo> materielInfos = _basicRepository.MaterielInfoRepository.QueryData(); |
| | | List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>(); |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | //è·åææAGVç¹ä½ |
| | | List<Dt_AGVStationInfo> aGVStationInfos = _agvStationInfoRepository.QueryData(x => !string.IsNullOrEmpty(x.MESPointCode)); |
| | | //æ ¹æ®åæåä¿¡æ¯å¼å«å¯¹åºä»»å¡ |
| | | foreach (var item in mESProInOrderInfos) |
| | | { |
| | | Dt_AGVStationInfo? CheckPointCode = aGVStationInfos.FirstOrDefault(x => x.MESPointCode == item?.PointCode); |
| | | Dt_MaterielInfo? materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | return content.Error("æªæ¾å°ç©æä¿¡æ¯"); |
| | | } |
| | | if (materielInfo.MaterielSourceType != MaterielTypeEnum.åæå.ObjToInt()) |
| | | { |
| | | return content.Error($"æªæ¾å°ç©æ{materielInfo.MaterielCode}åæåä¿¡æ¯"); |
| | | } |
| | | Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == item.BarCode); |
| | | if (stockInfoOld != null) |
| | | { |
| | | return content.Error("æçä¿¡æ¯å·²åå¨"); |
| | | } |
| | | //çæåºåç»çä¿¡æ¯ |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | MaterielInvOrgId = materielInfo.MaterielInvOrgId, |
| | | PalletCode = item.BarCode, |
| | | LocationCode = "", |
| | | PalletType = 1, |
| | | WarehouseId = materielInfo.WarehouseId, |
| | | StockAttribute = materielInfo.MaterielSourceType, |
| | | StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(), |
| | | MaterielSpec = materielInfo.MaterielSpec, |
| | | Unit = materielInfo.MaterielUnit, |
| | | MaterielThickness = item.Thickness, |
| | | MaterielWide = item.Wide, |
| | | MaterielWeight = item.Weight, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | StockLength=item.ProQuantity |
| | | }; |
| | | if (item.Wide > 1200) |
| | | { |
| | | stockInfo.PalletType = 2; |
| | | } |
| | | |
| | | //åæåå
¥åºä»»å¡ |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = CheckPointCode.AGVStationCode, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = item.BarCode, |
| | | Roadway = "", |
| | | SourceAddress = CheckPointCode.AGVStationCode, |
| | | TargetAddress = "", |
| | | TaskType = 0, |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = materielInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | TaskLength = (int)item.Wide |
| | | }; |
| | | TaskTypeEnum taskTypeEnum = CheckPointCode.StationArea switch |
| | | { |
| | | nameof(AGVStationAreaEnum.䏿¥¼å°å·) => TaskTypeEnum.PrintYLInbound, |
| | | _ => throw new Exception("æªæ¾å°å¯¹åºä»»å¡") |
| | | }; |
| | | newTask.TaskType = taskTypeEnum.ObjToInt(); |
| | | stockInfos.Add(stockInfo); |
| | | tasks.Add(newTask); |
| | | } |
| | | //æä½å
¥åºæ°æ® |
| | | BaseDal.AddData(tasks); |
| | | _stockRepository.StockInfoRepository.AddData(stockInfos); |
| | | //æ¨éä»»å¡ |
| | | content.OK("åéæå",data:tasks); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |