private NomenclatureSimple getEmptyNomenclature(IList <NomenclatureSimple> nomenclatures, int groupId) { NomenclatureSimple ret = null; foreach (var item in nomenclatures) { if ((item.GroupId == groupId) && (item.NameId == 0)) { return(item); } } return(ret); }
private IList <NomenclatureSimple> getNomenclaturesByParam(string Ids) { IList <NomenclatureSimple> nomenclatures = new List <NomenclatureSimple>(); string[] listId = Ids.Split(';'); foreach (var id in listId) { Dictionary <string, object> query = new Dictionary <string, object>(); Dictionary <string, object> order = new Dictionary <string, object>(); query.Add("[in]Id", Ids); query.Add("[>]Quantity", 0); order.Add("Storage.StorageName.Id", ASC); IList <WorkerCardContent> workerCardContents = workerCardContentRepository.GetByLikeCriteria(query); foreach (var itemContens in workerCardContents) { NomenclatureSimple nomenclature = new NomenclatureSimple(itemContens.Id); nomenclature.NameId = itemContens.Storage.Nomenclature.Id; nomenclature.Name = itemContens.Storage.NomenclatureInfo; // nomenclature.GroupId = itemContens.NormaContent.NomGroup.Id; // nomenclature.GroupName = itemContens.NormaContent.NomGroup.Name; nomenclature.GroupId = itemContens.Storage.Nomenclature.NomGroup.Id; nomenclature.GroupName = itemContens.Storage.Nomenclature.NomGroup.Name; nomenclature.StartDate = itemContens.StartDate; nomenclature.StartDateStr = itemContens.StartDate.ToString(DataGlobals.DATE_FORMAT_FULL_YEAR); nomenclature.Quantity = itemContens.Quantity; nomenclature.StorageNameId = itemContens.Storage.StorageName.Id; nomenclature.StorageNumber = itemContens.Storage.StorageName.StorageNumber; nomenclature.OperType = itemContens.Operation.OperType.Id; if (nomenclature.OperType == DataGlobals.OPERATION_STORAGE_TRANSFER_IN) { nomenclature.DocNumber = itemContens.Operation.DocNumber; nomenclature.OperDate = itemContens.Operation.OperDate; nomenclature.OperDateStr = itemContens.Operation.OperDate.ToString(DataGlobals.DATE_FORMAT_FULL_YEAR); } // nomenclature.WorkerWorkPlaceId = nomenclatures.Add(nomenclature); } } return(nomenclatures); }
private IList <NomenclatureSimple> getNomenclaturesForWorkplace(int workerWorkplaceId, bool isActive) { IList <NomenclatureSimple> nomenclatures = new List <NomenclatureSimple>(); IList <WorkerWorkplace> workerWorkplaces = new List <WorkerWorkplace>(); Dictionary <string, object> query = new Dictionary <string, object>(); Dictionary <string, object> order = new Dictionary <string, object>(); query.Add("Worker.Id", workerWorkplaceId); query.Add("IsActive", isActive); //Выбираем рабочие места workerWorkplaces = workerWorkplaceRepository.GetByLikeCriteria(query); //Если активное рабочее место, то сначала выбираем все, что положено по норме if (isActive) { if (workerWorkplaces.Count > 0) { query.Clear(); query.Add("Organization", workerWorkplaces[0].Organization); query.Add("Norma.Organization.Id", int.Parse(getCurrentEnterpriseId())); query.Add("Norma.IsActive", true); IList <NormaOrganization> normaOrganizations = normaOrganizationRepository.GetByCriteria(query); if (normaOrganizations != null && normaOrganizations.Count > 0) { IList <NormaContent> normas = normaOrganizations[0].Norma.NormaContents; //normas = reorderNormaContents(normas, false); foreach (var item in normas) { if (item.IsActive == true) { if (item.InShop == false) { NomenclatureSimple nomenclature = new NomenclatureSimple(); nomenclature.GroupId = item.NomGroup.Id; nomenclature.GroupName = item.NomGroup.Name; nomenclature.NormaContentId = item.Id; nomenclatures.Add(nomenclature); } } } } } } foreach (var item in workerWorkplaces) { //Для всех неактивных рабочих мест //Ищем номенклатуры, которые на руках query.Clear(); query.Add("WorkerWorkplace", item); WorkerCardHead workerCardHead = workerCardRepository.FindOne(query); //Если карточка найдена if (workerCardHead != null) { IList <WorkerCardContent> workerCardContents = new List <WorkerCardContent>(); query.Clear(); query.Add("WorkerCardHead", workerCardHead); query.Add("[>]Quantity", 0); workerCardContents = workerCardContentRepository.GetByLikeCriteria(query); bool addNomenclature = false; foreach (var itemContens in workerCardContents) { // NomenclatureSimple nomenclature = getEmptyNomenclature(nomenclatures, itemContens.NormaContent.NomGroup.Id); NomenclatureSimple nomenclature = getEmptyNomenclature(nomenclatures, itemContens.Storage.Nomenclature.NomGroup.Id); if (nomenclature == null) { nomenclature = new NomenclatureSimple(); if (itemContens.NormaContent != null) { nomenclature.NormaContentId = itemContens.NormaContent.Id; } addNomenclature = true; } else { addNomenclature = false; } nomenclature.setId(itemContens.Id); nomenclature.NameId = itemContens.Storage.Nomenclature.Id; nomenclature.Name = itemContens.Storage.NomenclatureInfo; if (!isActive) //{ // nomenclature.GroupId = itemContens.NormaContent.NomGroup.Id; // nomenclature.GroupName = itemContens.NormaContent.NomGroup.Name; //} //else { nomenclature.GroupId = itemContens.Storage.Nomenclature.NomGroup.Id; nomenclature.GroupName = itemContens.Storage.Nomenclature.NomGroup.Name; } nomenclature.Quantity = itemContens.Quantity; nomenclature.OperType = itemContens.Operation.OperType.Id; nomenclature.StartDate = itemContens.StartDate; nomenclature.StartDateStr = itemContens.StartDate.ToString(DataGlobals.DATE_FORMAT_FULL_YEAR); if (nomenclature.OperType == DataGlobals.OPERATION_STORAGE_TRANSFER_IN) { nomenclature.DocNumber = itemContens.Operation.DocNumber; nomenclature.OperDate = itemContens.Operation.OperDate; nomenclature.OperDateStr = itemContens.Operation.OperDate.ToString(DataGlobals.DATE_FORMAT_FULL_YEAR); } nomenclature.StorageNameId = itemContens.Storage.StorageName.Id; nomenclature.StorageNumber = itemContens.Storage.StorageName.StorageNumber; if (addNomenclature) { nomenclatures.Add(nomenclature); } } } } return(nomenclatures); }