| | |
| | | using WIDESEA_DTO.Stock; |
| | | using SqlSugar; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | | public partial class TaskService |
| | | { |
| | | static object lock_out = new object(); |
| | | |
| | | static object solderMask_out = new object(); |
| | | |
| | | /// <summary> |
| | | /// æµè¯æ¶åºä» |
| | |
| | | (x.EnableStatus == (int)EnableStatusEnum.Normal || x.EnableStatus == (int)EnableStatusEnum.OnlyOut)); |
| | | if (locationInfo == null) |
| | | { |
| | | return responseContent.Error($"æµè¯æ¶è´§ä½ããããããããã:{stockInfo.LocationCode}åºåºæ¡ä»¶ä¸æ»¡è¶³"); |
| | | return responseContent.Error($"æµè¯æ¶è´§ä½:{stockInfo.LocationCode}åºåºæ¡ä»¶ä¸æ»¡è¶³"); |
| | | } |
| | | //çææµè¯æ¶åºåºä»»å¡ éå®åºå æ´æ¹è´§ä½ç¶æ |
| | | Dt_Task taskOut = new() |
| | |
| | | PalletType = stockInfo.PalletType, |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | }; |
| | | string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode; |
| | | float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity); |
| | | if (MaterielCode != null && Quantity != null) |
| | | { |
| | | taskOut.MaterielCode = MaterielCode; |
| | | taskOut.Quantity = Quantity; |
| | | } |
| | | stockInfo.StockStatus = (int)StockStatusEmun.åºåºéå®; |
| | | LocationStatusEnum locationStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = (int)LocationStatusEnum.Lock; |
| | |
| | | _unitOfWorkManage.CommitTran(); |
| | | //å°ä»»å¡æ¨éå°WCS |
| | | PushTasksToWCS(new List<Dt_Task>() { taskOut }, "AGV_CSJ"); |
| | | responseContent.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | responseContent.Error(ex.Message); |
| | | } |
| | | return responseContent; |
| | | } |
| | | } |
| | | public MesResponseContent SolderMaskOutNotice(SolderMaskOutNotice model) |
| | | { |
| | | lock (solderMask_out) |
| | | { |
| | | MesResponseContent responseContent = new MesResponseContent(); |
| | | try |
| | | { |
| | | |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA154.ToString()); |
| | | //è·ååºåè®°å½ |
| | | List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => |
| | | x.WarehouseId == warehouse.WarehouseId && |
| | | x.StockStatus == (int)StockStatusEmun.å
¥åºå®æ).Includes(x => x.Details).ToList(); |
| | | Dt_StockInfo? stockInfo = stockInfos.FirstOrDefault(x => x.Details.Any(x => x.BatchNo == model.LotNo)); |
| | | if (stockInfo == null) |
| | | { |
| | | return responseContent.Error($"é²çåº:æ {model.LotNo}å¯ç¨åºå"); |
| | | } |
| | | Dt_Task exsit2 = Repository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode); |
| | | if (exsit2 != null) |
| | | { |
| | | return responseContent.Error($"é²çä»»å¡{stockInfo.PalletCode}å·²åå¨"); |
| | | } |
| | | |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode && |
| | | x.WarehouseId == stockInfo.WarehouseId && |
| | | x.LocationStatus == (int)LocationStatusEnum.InStock && |
| | | (x.EnableStatus == (int)EnableStatusEnum.Normal || x.EnableStatus == (int)EnableStatusEnum.OnlyOut)); |
| | | if (locationInfo == null) |
| | | { |
| | | return responseContent.Error($"é²çè´§ä½:{stockInfo.LocationCode}åºåºæ¡ä»¶ä¸æ»¡è¶³"); |
| | | } |
| | | //çæé²çåºåºä»»å¡ éå®åºå æ´æ¹è´§ä½ç¶æ |
| | | Dt_Task taskOut = new() |
| | | { |
| | | CurrentAddress = stockInfo.LocationCode, |
| | | Grade = 0, |
| | | PalletCode = stockInfo.PalletCode, |
| | | NextAddress = "", |
| | | Roadway = locationInfo.RoadwayNo, |
| | | SourceAddress = stockInfo.LocationCode, |
| | | TargetAddress = model.TargetAddressCode, |
| | | TaskStatus = (int)TaskStatusEnum.New, |
| | | TaskType = stockInfo.PalletType<2 ? (int)TaskTypeEnum.MaskOutNoticeSmall : (int)TaskTypeEnum.MaskOutNoticeLarge, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | PalletType = stockInfo.PalletType, |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | }; |
| | | string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode; |
| | | float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity); |
| | | if (MaterielCode != null && Quantity != null) |
| | | { |
| | | taskOut.MaterielCode = MaterielCode; |
| | | taskOut.Quantity = Quantity; |
| | | } |
| | | stockInfo.StockStatus = (int)StockStatusEmun.åºåºéå®; |
| | | LocationStatusEnum locationStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = (int)LocationStatusEnum.Lock; |
| | | //夿æ¯å¦æåºåºåä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | | //æ´æ°åºåç¶æ |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | //æ´æ°è´§ä½ç¶æ |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.Lock, stockInfo.WarehouseId); |
| | | //æ°å»ºä»»å¡ |
| | | BaseDal.AddData(taskOut); |
| | | //å å
¥è´§ä½åå¨è®°å½ |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, locationStatus, LocationStatusEnum.Lock, LocationChangeType.OutboundAssignLocation, stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", taskOut.TaskNum); |
| | | _unitOfWorkManage.CommitTran(); |
| | | //å°ä»»å¡æ¨éå°WCS |
| | | PushTasksToWCS(new List<Dt_Task>() { taskOut }, "AGV_ZH"); |
| | | responseContent.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | responseContent.Error(ex.Message); |
| | | } |
| | | return responseContent; |
| | | } |
| | | } |
| | | |
| | | public MesResponseContent SolderMaskOut(SolderMaskOut model) |
| | | { |
| | | lock (solderMask_out) |
| | | { |
| | | MesResponseContent responseContent = new MesResponseContent(); |
| | | try |
| | | { |
| | | |
| | | |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA154.ToString()); |
| | | //è·ååºåè®°å½ |
| | | List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => |
| | | x.WarehouseId == warehouse.WarehouseId && |
| | | x.StockStatus == (int)StockStatusEmun.å
¥åºå®æ).Includes(x => x.Details).ToList(); |
| | | Dt_StockInfo? stockInfo = stockInfos.FirstOrDefault(x => x.Details.Any(x => x.BatchNo == model.LotNo)); |
| | | if (stockInfo == null) |
| | | { |
| | | return responseContent.Error($"é²çåº:æ {model.LotNo}å¯ç¨åºå"); |
| | | } |
| | | Dt_Task exsit2 = Repository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode); |
| | | if (exsit2 != null) |
| | | { |
| | | return responseContent.Error($"é²çä»»å¡{stockInfo.PalletCode}å·²åå¨"); |
| | | } |
| | | |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode && |
| | | x.WarehouseId == stockInfo.WarehouseId && |
| | | x.LocationStatus == (int)LocationStatusEnum.InStock && |
| | | (x.EnableStatus == (int)EnableStatusEnum.Normal || x.EnableStatus == (int)EnableStatusEnum.OnlyOut)); |
| | | if (locationInfo == null) |
| | | { |
| | | return responseContent.Error($"é²çè´§ä½:{stockInfo.LocationCode}åºåºæ¡ä»¶ä¸æ»¡è¶³"); |
| | | } |
| | | //çæé²çåºåºä»»å¡ éå®åºå æ´æ¹è´§ä½ç¶æ |
| | | Dt_Task taskOut = new() |
| | | { |
| | | CurrentAddress = stockInfo.LocationCode, |
| | | Grade = 0, |
| | | PalletCode = stockInfo.PalletCode, |
| | | NextAddress = "", |
| | | Roadway = locationInfo.RoadwayNo, |
| | | SourceAddress = stockInfo.LocationCode, |
| | | TargetAddress = model.TargetAddressCode, |
| | | TaskStatus = (int)TaskStatusEnum.New, |
| | | TaskType = stockInfo.PalletType < 2 ? (int)TaskTypeEnum.MaskOutSmall : (int)TaskTypeEnum.MaskOutLarge, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | PalletType = stockInfo.PalletType, |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | }; |
| | | string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode; |
| | | float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity); |
| | | if (MaterielCode != null && Quantity != null) |
| | | { |
| | | taskOut.MaterielCode = MaterielCode; |
| | | taskOut.Quantity = Quantity; |
| | | } |
| | | stockInfo.StockStatus = (int)StockStatusEmun.åºåºéå®; |
| | | LocationStatusEnum locationStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = (int)LocationStatusEnum.Lock; |
| | | //夿æ¯å¦æåºåºåä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | | //æ´æ°åºåç¶æ |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | //æ´æ°è´§ä½ç¶æ |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.Lock, stockInfo.WarehouseId); |
| | | //æ°å»ºä»»å¡ |
| | | BaseDal.AddData(taskOut); |
| | | //å å
¥è´§ä½åå¨è®°å½ |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, locationStatus, LocationStatusEnum.Lock, LocationChangeType.OutboundAssignLocation, stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", taskOut.TaskNum); |
| | | _unitOfWorkManage.CommitTran(); |
| | | //å°ä»»å¡æ¨éå°WCS |
| | | PushTasksToWCS(new List<Dt_Task>() { taskOut }, "AGV_ZH"); |
| | | responseContent.OK(); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | PalletType = stockInfo.PalletType, |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | }; |
| | | string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode; |
| | | float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity); |
| | | if (MaterielCode != null && Quantity != null) |
| | | { |
| | | taskIn.MaterielCode = MaterielCode; |
| | | taskIn.Quantity = Quantity; |
| | | } |
| | | //æ´æ¹åºåç¶æ |
| | | stockInfo.StockStatus = StockStatusEmun.éåº.ObjToInt(); |
| | | BaseDal.AddData(taskIn); |
| | |
| | | } |
| | | |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == palletTypeInfo.WarehouseId); |
| | | |
| | | //夿æ¯å¦æçåºåæ¯å¦å·²åå¨ |
| | | Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == model.CarrierCode); |
| | | if (stockInfoOld != null) |
| | | { |
| | | return MesResponseContent.Instance.Error($"æçå·åºå{model.CarrierCode}å·²åå¨"); |
| | | } |
| | | |
| | | Dt_StockInfo_Hty stockInfo_Hty = _stockRepository.StockInfo_HtyRepository.QueryData(x => x.PalletCode == model.CarrierCode).OrderByDescending(x => x.SourceId).First(); |
| | | Dt_StockInfoDetail_Hty stockInfoDetail_Hty = _stockRepository.StockInfoDetail_HtyRepository.QueryFirst(x => x.StockId == stockInfo_Hty.SourceId); |
| | | |
| | | |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode, |
| | | Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.StockQuantity, |
| | | }; |
| | | string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode; |
| | | float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity); |
| | | if (MaterielCode != null && Quantity != null) |
| | | { |
| | | newTask.MaterielCode = MaterielCode; |
| | | newTask.Quantity = Quantity; |
| | | } |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | _unitOfWorkManage.BeginTran(); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åMESé»çæ¹æ¬¡ä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent GetZHMesMaterialLot(string materialLot) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMS_MES_GetProductByLot.ToString()); |
| | | object obj = new { LotNo = materialLot }; |
| | | MESRoot<object> root = new MESRoot<object>() |
| | | { |
| | | From = "WMS", |
| | | DateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | Content = obj |
| | | }; |
| | | JsonSerializerSettings settings = new JsonSerializerSettings |
| | | { |
| | | ContractResolver = new CamelCasePropertyNamesContractResolver() |
| | | }; |
| | | string request = JsonConvert.SerializeObject(root, settings); |
| | | string response = HttpMesHelper.Post(apiInfo.ApiAddress, request); |
| | | MesResponseContent mesResponseContent = response.DeserializeObject<MesResponseContent>(); |
| | | //è°ç¨æ¥å£ |
| | | if (mesResponseContent.BSucc == true) |
| | | { |
| | | content.OK(mesResponseContent.StrMsg, mesResponseContent.Content); |
| | | } |
| | | else |
| | | { |
| | | content.Error(mesResponseContent.StrMsg); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |