| | |
| | | using WIDESEA_ITaskInfoRepository; |
| | | using WIDESEA_ITaskInfoService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Common.OrderEnum; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | try |
| | | { |
| | | Dt_Task exsit = Repository.QueryFirst(x => x.TargetAddress == model.TargetAddressCode); |
| | | if(exsit != null) |
| | | if (exsit != null) |
| | | { |
| | | return responseContent.Error($"ç®æ å°åéå¤"); |
| | | } |
| | |
| | | //æ´æ°åºåç¶æ |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | //æ´æ°è´§ä½ç¶æ |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, (PalletTypeEnum)stockInfo.PalletType, LocationStatusEnum.Lock, stockInfo.WarehouseId); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.Lock, stockInfo.WarehouseId); |
| | | //æ°å»ºä»»å¡ |
| | | BaseDal.AddData(taskOut); |
| | | //å å
¥è´§ä½åå¨è®°å½ |
| | |
| | | //æ¸
é¤åºåä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | | _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfoUpdates, OperateTypeEnum.èªå¨å é¤); |
| | | _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfoDetails,OperateTypeEnum.èªå¨å é¤); |
| | | _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfoDetails, OperateTypeEnum.èªå¨å é¤); |
| | | _unitOfWorkManage.CommitTran(); |
| | | responseContent.OK($"æ¥åºæå"); |
| | | } |
| | |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ç©æåºåºï¼WMS忥åºåºç©ææ¹æ¬¡è³MES |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent UploadMesMaterialLotaAcept(MesMaterialLotaAceptModel model) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMS_MES_TestToolSync.ToString()); |
| | | MESRoot<MesMaterialLotaAceptModel> root = new MESRoot<MesMaterialLotaAceptModel>() |
| | | { |
| | | From = "WMS", |
| | | DateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | Content = model |
| | | }; |
| | | 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); |
| | | } |
| | | else |
| | | { |
| | | content.Error(mesResponseContent.StrMsg); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="stockInfo"></param> |
| | | /// <param name="stockInfoDetail"></param> |
| | | /// <param name="taskNo"></param> |
| | | /// <param name="warehouseCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <param name="cutedType"></param> |
| | | /// <param name="ppWidth"></param> |
| | | /// <returns></returns> |
| | | public MesMaterialLotaAceptModel GetMesMaterialLotaAceptModel(Dt_StockInfo stockInfo, Dt_StockInfoDetail stockInfoDetail, string taskNo, string warehouseCode, float quantity, string cutedType = "", float ppWidth = 0) |
| | | { |
| | | MesMaterialLotaAceptModel model = new MesMaterialLotaAceptModel() |
| | | { |
| | | CarrierCode = stockInfo.PalletCode, |
| | | CutedType = cutedType, |
| | | ExpirationDate = stockInfoDetail.EffectiveDate, |
| | | MaterialBarCode = stockInfoDetail.SerialNumber, |
| | | MaterialCode = stockInfoDetail.MaterielCode, |
| | | MaterialLot = stockInfoDetail.MaterielCode + "," + stockInfoDetail.BatchNo, |
| | | MaterialName = stockInfoDetail.MaterielName, |
| | | PPWidth = ppWidth, |
| | | ProductionDate = stockInfoDetail.ProductionDate, |
| | | Quantity = quantity, |
| | | Supplier = "", |
| | | TaskNo = taskNo, |
| | | Type = 1, |
| | | WarehouseArea = warehouseCode, |
| | | WarehouseLocation = warehouseCode |
| | | }; |
| | | |
| | | return model; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºæ¿åºåº |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public MesResponseContent SubstrateOut(SubstrateOutModel model) |
| | | { |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA57.ToString()); |
| | | if (warehouse == null) |
| | | { |
| | | return MesResponseContent.Instance.Error($"ä»åºåºç¡ä¿¡æ¯æªé
ç½®"); |
| | | } |
| | | |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == model.MaterialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | return MesResponseContent.Instance.Error($"æªæ¾å°è¯¥ç©æä¿¡æ¯"); |
| | | } |
| | | |
| | | Dt_MesOutboundOrder mesOutboundOrder = new Dt_MesOutboundOrder() |
| | | { |
| | | CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(), |
| | | Line = model.Line, |
| | | MaterialCode = model.MaterialCode, |
| | | MaterialName = model.MaterialName, |
| | | OrderQuantity = model.RequiredQuantity, |
| | | TaskNo = model.TaskNo, |
| | | Unit = model.Unit, |
| | | OrderType = MesOutboundOrderTypeEnum.SubstrateOut.ObjToInt(), |
| | | OrderStatus = OutOrderStatusEnum.æªå¼å§.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId |
| | | }; |
| | | |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | { |
| | | (List<Dt_StockInfo>, Dt_MesOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesOutboundOrderService.AssignStockOutbound(mesOutboundOrder); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound); |
| | | result.Item2.OrderStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | mesOutboundOrder = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | int id = BaseDal.AddData(tasks); |
| | | outStockLockInfos.ForEach(x => |
| | | { |
| | | x.OrderNo = mesOutboundOrder.TaskNo; |
| | | x.OrderDetailId = id; |
| | | }); |
| | | _outboundService.MesOutboundOrderService.Repository.AddData(mesOutboundOrder); |
| | | if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | WebResponseContent content = _outboundService.MesOutboundOrderService.LockOutboundStockDataUpdate(stockInfos, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return MesResponseContent.Instance.Error(content.Message); |
| | | } |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | |
| | | |
| | | return MesResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return MesResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åºæ¿ä½æéåº |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public MesResponseContent SubstrateBack(SubstrateBackModel model) |
| | | { |
| | | try |
| | | { |
| | | Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => model.CarrierCode.Contains(x.CodeStartStr)); |
| | | if (palletTypeInfo == null) |
| | | { |
| | | return MesResponseContent.Instance.Error($"æªè¯å«è¯¥æçç±»åï¼è¯·ç¡®è®¤æçå·"); |
| | | } |
| | | |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseCode == WarehouseEnum.HA57.ToString()); |
| | | |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletCode = model.CarrierCode, |
| | | PalletType = palletTypeInfo.PalletType, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt() |
| | | }; |
| | | |
| | | Dt_StockInfoDetail_Hty stockInfoDetail_Hty = _stockRepository.StockInfoDetail_HtyRepository.QueryFirst(x => x.BatchNo == model.MaterialLot && x.MaterielCode == model.MaterialCode); |
| | | |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | BatchNo = stockInfoDetail_Hty?.BatchNo ?? "", |
| | | EffectiveDate = model.ExpirationDate, |
| | | MaterielCode = model.MaterialCode, |
| | | InboundOrderRowNo = stockInfoDetail_Hty?.InboundOrderRowNo ?? 0, |
| | | MaterielName = model.MaterialCode, |
| | | ProductionDate = model.ProductionDate, |
| | | OrderNo = stockInfoDetail_Hty?.OrderNo ?? "", |
| | | OutboundQuantity = 0, |
| | | SerialNumber = stockInfoDetail_Hty?.SerialNumber ?? "0", |
| | | StockQuantity = model.Quantity, |
| | | Status = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | Unit = model.Unit |
| | | }; |
| | | |
| | | Dt_Task task = new Dt_Task() |
| | | { |
| | | PalletCode = stockInfo.PalletCode, |
| | | CurrentAddress = "", |
| | | NextAddress = "", |
| | | PalletType = stockInfo.PalletType, |
| | | Roadway = "", |
| | | SourceAddress = "", |
| | | TargetAddress = "", |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId |
| | | }; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand(); |
| | | BaseDal.AddData(task); |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | return MesResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return MesResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |