public TH60_MtrWhsCmdHst AddByMaterialCmd(TX34_MtrWhsCmd tx34) { var materialHouseHistory = new TH60_MtrWhsCmdHst() { F60_AbnormalCode = tx34.F34_AbnormalCode, F60_AddDate = tx34.F34_AddDate, F60_CmdSeqNo = tx34.F34_CmdSeqNo, F60_CommandEndDate = tx34.F34_CommandEndDate, F60_CommandNo = tx34.F34_CommandNo, F60_CommandSendDate = tx34.F34_CommandEndDate, F60_CommandType = tx34.F34_CommandType, F60_From = tx34.F34_From, F60_PalletNo = tx34.F34_PalletNo, F60_PictureNo = tx34.F34_PictureNo, F60_Priority = tx34.F34_Priority, F60_RetryCount = tx34.F34_RetryCount, F60_Status = tx34.F34_Status, F60_StrRtrType = tx34.F34_StrRtrType, F60_TerminalNo = tx34.F34_TerminalNo, F60_To = tx34.F34_To, F60_UpdateCount = tx34.F34_UpdateCount, F60_UpdateDate = tx34.F34_UpdateDate }; Add(materialHouseHistory); return(materialHouseHistory); }
/// <summary> /// Initiate message with material warehouse command. /// </summary> /// <param name="materialWarehouseCommand"></param> public TerminalMessage(TX34_MtrWhsCmd materialWarehouseCommand) : this() { CommandSequence = materialWarehouseCommand.F34_CmdSeqNo.PadRight(4); CommandIndex = materialWarehouseCommand.F34_CommandNo.PadRight(4); Command = materialWarehouseCommand.F34_CommandType.PadRight(4); From = materialWarehouseCommand.F34_From.PadRight(6); To = materialWarehouseCommand.F34_To.PadRight(6); if (string.IsNullOrEmpty(materialWarehouseCommand.F34_PalletNo)) { PalletNo = ""; } else { PalletNo = materialWarehouseCommand.F34_PalletNo; } PalletNo = PalletNo.PadRight(4); }
public TX34_MtrWhsCmd InsertTX34(Constants.F34_CommandNo commandNo, int f48_MtrWhsCmdNo, string cmdType, string lsStatus, string status, string palletNo, string from, string to, string terminalNo, string pictureNo) { var commandNo1 = commandNo.ToString("D"); var cmdSeqNo = f48_MtrWhsCmdNo.ToString("D4"); var materialWarehouse = _unitOfWork.MaterialWarehouseCommandRepository.GetMany( i => i.F34_CommandNo.Trim().Equals(commandNo1) && i.F34_CmdSeqNo.Trim().Equals(cmdSeqNo)); var tx34Mtrwhscmd = new TX34_MtrWhsCmd(); if (!materialWarehouse.Any()) { tx34Mtrwhscmd.F34_CommandNo = commandNo1; //tx34Mtrwhscmd.F34_CmdSeqNo = string.Format("{0}", f48_MtrWhsCmdNo + 1); tx34Mtrwhscmd.F34_CmdSeqNo = cmdSeqNo; tx34Mtrwhscmd.F34_CommandType = cmdType; tx34Mtrwhscmd.F34_StrRtrType = lsStatus; tx34Mtrwhscmd.F34_Status = status; tx34Mtrwhscmd.F34_Priority = 0; tx34Mtrwhscmd.F34_PalletNo = palletNo; tx34Mtrwhscmd.F34_From = from; tx34Mtrwhscmd.F34_To = to; tx34Mtrwhscmd.F34_CommandSendDate = null; tx34Mtrwhscmd.F34_CommandEndDate = null; tx34Mtrwhscmd.F34_TerminalNo = terminalNo; tx34Mtrwhscmd.F34_PictureNo = pictureNo; tx34Mtrwhscmd.F34_AbnormalCode = ""; tx34Mtrwhscmd.F34_RetryCount = 0; tx34Mtrwhscmd.F34_AddDate = DateTime.Now; tx34Mtrwhscmd.F34_UpdateDate = DateTime.Now; tx34Mtrwhscmd.F34_UpdateCount = 0; // Add record into database. _unitOfWork.MaterialWarehouseCommandRepository.AddOrUpdate(tx34Mtrwhscmd); //_unitOfWork.Commit(); } //_unitOfWork.Commit(); return(tx34Mtrwhscmd); }
/// <summary> /// process data when receive message for C1 /// </summary> /// <param name="terminalNo"></param> /// <param name="pictureNo"></param> public IList <FirstCommunicationResponse> PostStoreMaterial(string terminalNo, string pictureNo) { var materialWarehouseCommands = GetListMaterialWarehouseCommand().Where(i => i.F34_PictureNo.Trim().Equals(pictureNo.Trim())); var shelfRow = ""; var shelfBay = ""; var shelfLevel = ""; var proceededRecordsList = new List <FirstCommunicationResponse>(); foreach (var materialWarehouseCommand in materialWarehouseCommands) { var materialShelfStock = _unitOfWork.MaterialShelfStockRepository.Get( x => x.F33_PalletNo.Equals(materialWarehouseCommand.F34_PalletNo)); var instance = Mapper.Map <FirstCommunicationResponse>(materialWarehouseCommand); if (materialShelfStock == null) { instance.MaterialCode = ""; } else { instance.MaterialCode = materialShelfStock.F33_MaterialCode; } instance.OldStatus = materialWarehouseCommand.F34_Status; proceededRecordsList.Add(instance); if (materialWarehouseCommand.F34_Status.Equals(Constants.F34_Status.status6)) { materialWarehouseCommand.F34_Status = Constants.F34_Status.statusC; materialWarehouseCommand.F34_UpdateDate = DateTime.Now; //_unitOfWork.MaterialWarehouseCommandRepository.Update(materialWarehouseCommand); } else if (materialWarehouseCommand.F34_Status.Equals(Constants.F34_Status.status7)) { if (materialWarehouseCommand.F34_PictureNo.Trim().Equals(Constants.PictureNo.TCRM031F)) { //find shelfRow,shelfBay,shelfLevel shelfRow = materialWarehouseCommand.F34_To.Substring(0, 2); shelfBay = materialWarehouseCommand.F34_To.Substring(2, 2); shelfLevel = materialWarehouseCommand.F34_To.Substring(4, 2); //Find material shelf status record var tx31 = _unitOfWork.MaterialShelfStatusRepository.Get( i => i.F31_ShelfRow.Trim().Equals(shelfRow) && i.F31_ShelfBay.Trim().Equals(shelfBay) && i.F31_ShelfLevel.Trim().Equals(shelfLevel)); var tx32 = _unitOfWork.MaterialShelfRepository.Get( i => i.F32_PalletNo.Trim().Equals(materialWarehouseCommand.F34_PalletNo.Trim())); if (tx32 != null) { //Find material reception record whose [P. O. No.] is [f32_prcordno] var materialReception = _unitOfWork.ReceptionRepository.Get( i => i.F30_PrcOrdNo.Trim().Equals(tx32.F32_PrcOrdNo.Trim()) && i.F30_PrtDvrNo.Trim().Equals(tx32.F32_PrtDvrNo.Trim())); //update material reception record above if ((tx31 != null) && (materialReception != null)) { var ammount = tx31.F31_Amount ?? 0; materialReception.F30_StoragedAmount -= ammount; materialReception.F30_UpdateDate = DateTime.Now; _unitOfWork.ReceptionRepository.Update(materialReception); } } } //Update material warehouse command record above materialWarehouseCommand.F34_Status = Constants.F34_Status.statusD; materialWarehouseCommand.F34_UpdateDate = DateTime.Now; // _unitOfWork.MaterialWarehouseCommandRepository.Update(materialWarehouseCommand); } else if (materialWarehouseCommand.F34_Status.Equals(Constants.F34_Status.status8)) { shelfRow = materialWarehouseCommand.F34_To.Substring(0, 2); shelfBay = materialWarehouseCommand.F34_To.Substring(2, 2); shelfLevel = materialWarehouseCommand.F34_To.Substring(4, 2); if (materialWarehouseCommand.F34_PictureNo.Equals(Constants.PictureNo.TCRM031F)) { var materialShelfStatus = _unitOfWork.MaterialShelfStatusRepository.Get( i => i.F31_ShelfRow.Trim().Equals(shelfRow) && i.F31_ShelfBay.Trim().Equals(shelfBay) && i.F31_ShelfLevel.Trim().Equals(shelfLevel)); if (materialShelfStatus != null) { var liquiclass = materialShelfStatus.F31_LiquidClass; var shelfStatus = Constants.F31_ShelfStatus.EmptyShelf.ToString("D"); var materialShelfStatuses = _unitOfWork.MaterialShelfStatusRepository.GetAll(); if (liquiclass == Constants.F31_LiquidClass.NonLiquid.ToString("D")) { materialShelfStatuses = materialShelfStatuses.Where( i => i.F31_ShelfStatus.Equals(shelfStatus) && (i.F31_LiquidClass == "0") && i.F31_CmnShfAgnOrd.HasValue).OrderBy(i => i.F31_CmnShfAgnOrd); } else { materialShelfStatuses = materialShelfStatuses.Where( i => i.F31_ShelfStatus.Equals(shelfStatus) && (i.F31_LiquidClass == "1") && i.F31_LqdShfAgnOrd.HasValue).OrderBy(i => i.F31_LqdShfAgnOrd); } foreach (var materialShelfStatuse in materialShelfStatuses) { materialShelfStatuse.F31_ShelfStatus = Constants.TX31SheflStatus.TX31_MtrShfSts_RsvStg.ToString("D"); materialShelfStatuse.F31_TerminalNo = terminalNo; materialShelfStatuse.F31_PalletNo = materialWarehouseCommand.F34_PalletNo; materialShelfStatuse.F31_SupplierCode = null; materialShelfStatuse.F31_StockTakingFlag = Constants.TX31_StkTkgFlg.InvNotChk.ToString("d"); materialShelfStatuse.F31_LoadAmount = 0; materialShelfStatuse.F31_UpdateDate = DateTime.Now; _unitOfWork.MaterialShelfStatusRepository.AddOrUpdate(materialShelfStatuse); } } materialWarehouseCommand.F34_Status = Constants.F34_Status.statusD; materialWarehouseCommand.F34_UpdateDate = DateTime.Now; _unitOfWork.MaterialWarehouseCommandRepository.Update(materialWarehouseCommand); } //Update or insert TX48 var isNoManage = false; var asSer = _unitOfWork.NoManageRepository.CreateOrUpdateTX48(ref isNoManage, Constants.GetColumnInNoManager.MtrWhsCmdNo, 1, 0, 0, 0).ToString("D4"); //Insert data into tx34_mtrwhscmd var materialWarehouseCommandItem = new TX34_MtrWhsCmd(); materialWarehouseCommandItem.F34_CommandNo = Constants.F34_CommandNo.TwoTimesIn.ToString("D"); materialWarehouseCommandItem.F34_Status = Constants.F34_Status.statusE; materialWarehouseCommandItem.F34_CmdSeqNo = asSer; materialWarehouseCommandItem.F34_CommandType = Constants.CommandType.CmdType_0; materialWarehouseCommandItem.F34_Priority = 0; materialWarehouseCommandItem.F34_PalletNo = materialWarehouseCommand.F34_PalletNo; materialWarehouseCommandItem.F34_From = GetConveyorCode(terminalNo); materialWarehouseCommandItem.F34_To = shelfRow + shelfBay + shelfLevel; materialWarehouseCommandItem.F34_TerminalNo = terminalNo; materialWarehouseCommandItem.F34_StrRtrType = materialWarehouseCommand.F34_StrRtrType; materialWarehouseCommandItem.F34_PictureNo = pictureNo; materialWarehouseCommandItem.F34_UpdateDate = DateTime.Now; materialWarehouseCommandItem.F34_AddDate = DateTime.Now; materialWarehouseCommandItem.F34_UpdateCount = 0; _unitOfWork.MaterialWarehouseCommandRepository.AddOrUpdate(materialWarehouseCommandItem); //Update //If current screen is “TCRM031F”, the system will send message to server C1 var msgId = "0002"; var picNo = materialWarehouseCommandItem.F34_PictureNo; _notificationService.SendMessageToC1(new { msgId, terminalNo, picNo }); } } _unitOfWork.Commit(); return(proceededRecordsList); }
public int SendFromC1ToAw(TX34_MtrWhsCmd materialWhsCmd) { throw new NotImplementedException(); }