Skip to content

Instantly share code, notes, and snippets.

@stdray
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save stdray/86928de3c765397294e5 to your computer and use it in GitHub Desktop.

Select an option

Save stdray/86928de3c765397294e5 to your computer and use it in GitHub Desktop.
using Interfax.SM.ETL.Mapping.Functions;
using Interfax.SM.ETL.Mapping.Macros.DSL;
using Interfax.SM.ETL.Mapping.Types;
using Interfax.SM.ETL.Mapping.Goszakupki.Goszakupki44.Actual.Common;
using Nemerle.Collections;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Xml.Linq;
using Internal.Spark.Marketing.Ru.XMLSchema.Lots;
using Internal.Spark.Marketing.Ru.XMLSchema.Tenders;
using Internal.Spark.Marketing.Ru.XMLSchema.SharedCore;
using Internal.Spark.Marketing.Ru.XMLSchema.SharedSystem;
using Goszakupki44.Actual.Zakupki.Gov.Ru.Oos.Types.V1;
using Deserializer = Goszakupki44.Actual.Deserializer;
namespace Interfax.SM.ETL.Mapping.Goszakupki.Goszakupki44.Actual.Mappers
{
[Mapping, Record]
public class NotificationMapper : Goszakupki44MapperBase
{
#region Text
static responsibleDecisionStr = "По решению заказчика (организации, осуществляющей определение поставщика для заказчика)";
static authorityPrescriptionStr = "Предписание органа, уполномоченного на осуществление контроля";
static courtDecisionStr = "Решение судебного органа";
static discussionResultStr = "Общественное обсуждение";
static externalPrescriptionStr = "Предписание отсутствует в реестре результатов контроля";
static reestrPrescriptionStr = "Данные о предписании, выданном КО";
static purchaseProlongationZKStr = "Извещение о продлении срока подачи котировочных заявок";
static purchaseProlongationOKStr = "Уведомление о продлении срока рассмотрения и оценки заявок";
#endregion
#region Helper classes
public class CustomerProductsRequirementsInfo
{
public mutable CustomerLocalIdentity : string;
public mutable CustomerName : string;
public mutable ProductLocalIdentity : string;
public mutable Quantity : decimal?;
}
type CustomersBag = Dictionary[string, CustomerProductsRequirementsInfo];
#endregion
#region Helpers
person(org : KeyValuePair[string, CustomerProductsRequirementsInfo]) : ParticipantType
{
entity() <-
{
IdentityInfo <-
{
LocalIdentity = org.Value.CustomerLocalIdentity;
OOS_Identity = org.Key;
}
Person <-
{
MainInfo <-
{
RussianFullName = org.Value.CustomerName;
}
}
}
}
paymentInfo([Null] info : zfcs_paymentInfoType) : lotGuaranteeType
{
entity() <-
{
Amount = decimal'(info.amount);
Part = decimal'(info.part);
ProcedureInfo = info.procedureInfo;
}
}
bidding([Null] src : zfcs_purchaseProcedureBiddingType) : lotProcedureSimpleType
{
entity() <-
{
AdditionInfo = src.addInfo;
Date = date(src.date);
Place = src.place;
}
}
bidding([Null] src : zfcs_notificationEFTypeProcedureInfoBidding) : lotProcedureSimpleType
{
entity() <-
{
AdditionInfo = src.addInfo;
Date = date(src.date);
}
}
[Overloads(src, zfcs_purchaseProcedureCollectingWithFormType
, zfcs_purchaseProcedureCollectingType)]
collecting([Null] src : zfcs_purchaseProcedureCollectingType) : lotProcedureAdvancedType
{
entity() <-
{
EndDate = date(src.endDate);
Order = src.order;
Place = src.place;
StartDate = date(src.startDate);
}
}
contracting([Null] src : zfcs_purchaseProcedureContractingType) : lotProcedureContractingType
{
entity() <-
{
EvadeConditions = src.evadeConditions;
Term = src.contractingTerm;
}
}
openig([Null] src : zfcs_purchaseProcedureOpeningType) : lotProcedureSimpleType
{
entity() <-
{
AdditionInfo = src.addInfo;
Date = date(src.date);
Place = src.place;
}
}
prequalification([Null] src : zfcs_purchaseProcedurePrequalificationType) : lotProcedureSimpleType
{
entity() <-
{
Date = date(src.date);
Place = src.place;
}
}
[Overloads(src, zfcs_purchaseProcedureScoringType
, zfcs_purchaseProcedureScoringPlaceType)]
scoring([Null] src : zfcs_purchaseProcedureScoringPlaceType) : lotProcedureSimpleType
{
entity() <-
{
AdditionInfo = src.addInfo;
Date = date(src.date);
Place = src.place;
}
}
scoring([Null] src : zfcs_notificationEFTypeProcedureInfoScoring) : lotProcedureSimpleType
{
entity() <-
{
Date = date(src.date);
}
}
procedures(src : zfcs_purchaseProcedureOKType) : LotTypeProcedures
{
entity() <-
{
Collecting = collecting(src.collecting);
Opening = openig(src.opening);
Scoring = scoring(src.scoring);
}
}
procedures(src : zfcs_notificationEFTypeProcedureInfo) : LotTypeProcedures
{
entity() <-
{
Bidding = bidding(src.bidding);
Collecting = collecting(src.collecting);
Scoring = scoring(src.scoring);
}
}
procedures(src : zfcs_purchaseProcedureOKDType) : LotTypeProcedures
{
entity() <-
{
Collecting = collecting(src.stageOne.collecting);
Collecting2 = collecting(src.stageTwo.collecting);
Opening = openig(src.stageOne.opening);
Opening2 = openig(src.stageTwo.opening);
Prequalification = prequalification(src.stageOne.prequalification);
Scoring = scoring(src.stageOne.scoring);
Scoring2 = scoring(src.stageTwo.scoring);
}
}
procedures(src : zfcs_notificationPOTypeProcedureInfo) : LotTypeProcedures
{
//todo:
_ = src.selecting;
entity() <-
{
Collecting = collecting(src.collecting);
Contracting = contracting(src.contracting);
}
}
[Overloads(src, zfcs_notificationISMTypeProcedureInfo
, zfcs_notificationISOTypeProcedureInfo)]
procedures(src : zfcs_notificationISMTypeProcedureInfo) : LotTypeProcedures
{
entity() <-
{
Collecting <-
{
EndDate = date(src.collectingEndDate);
}
}
}
procedures(src : zfcs_purchaseProcedureOKOUType) : LotTypeProcedures
{
entity() <-
{
Collecting = collecting(src.collecting);
Opening = openig(src.opening);
Prequalification = prequalification(src.prequalification);
Scoring = scoring(src.scoring);
}
}
procedures(src : zfcs_purchaseProcedureZakAType) : LotTypeProcedures
{
entity() <-
{
Bidding = bidding(src.bidding);
Collecting = collecting(src.collecting);
Opening = openig(src.opening);
Scoring = scoring(src.scoring);
}
}
procedures(src : zfcs_notificationZKTypeProcedureInfo) : LotTypeProcedures
{
entity() <-
{
Collecting = collecting(src.collecting);
Opening = openig(src.opening);
Contracting = contracting(src.contracting);
}
}
cancelReason([Null] reason : zfcs_purchaseCancelReasonType) : string
{
def item = reason.ItemChoice;
choice(item)
{
when(item.authorityPrescription(x))
{
def xItem = x.ItemChoice;
choice(xItem)
{
when(xItem.externalPrescription(y))
externalPrescriptionStr + Environment.NewLine + $"$(y.authorityName): [$(y.docNumber)] $(y.docName)";
when(xItem.reestrPrescription(y))
reestrPrescriptionStr + Environment.NewLine + $"$(y.authorityName): [$(y.checkResultNumber)] $(y.foundation)";
}
}
when(item.discussionResult(x))
discussionResultStr + Environment.NewLine + $"[$(x.docNumber)] $(x.docName)";
when(item.courtDecision(x))
courtDecisionStr + Environment.NewLine + $"$(x.courtName): [$(x.docNumber)] $(x.docName)";
when(item.responsibleDecision(_))
responsibleDecisionStr
}
}
cancelReason([Null] reason : zfcs_protocolModificationReasonType) : string
{
def item = reason.ItemChoice;
choice(item)
{
when(item.authorityPrescription(x))
{
def xItem = x.ItemChoice;
choice(xItem)
{
when(xItem.externalPrescription(y))
externalPrescriptionStr + Environment.NewLine + $"$(y.authorityName): [$(y.docNumber)] $(y.docName)";
when(xItem.reestrPrescription(y))
reestrPrescriptionStr + Environment.NewLine + $"$(y.authorityName): [$(y.checkResultNumber)] $(y.foundation)";
}
}
when(item.courtDecision(x))
courtDecisionStr + Environment.NewLine + $"$(x.courtName): [$(x.docNumber)] $(x.docName)";
when(item.responsibleDecision(_))
responsibleDecisionStr
}
}
extendedRole([Null] org : ParticipantType, role : zfcs_responsibleRoleType?) : TenderTypeOrganizersExtendedRole
{
def extenderRole =
if(!role.HasValue)
TenderTypeOrganizersExtendedRoleOrganizerExtendedRole.SpecializedOrganization;
else match(role.Value)
{
| zfcs_responsibleRoleType.RA //Уполномоченный орган;
| zfcs_responsibleRoleType.AI //Уполномоченное учреждение;
| zfcs_responsibleRoleType.OA //Организация, осуществляющая полномочия заказчика на осуществление закупок на основании договора (соглашения);
| zfcs_responsibleRoleType.CU //Заказчик;
=> TenderTypeOrganizersExtendedRoleOrganizerExtendedRole.AuthorizedAgency;
| zfcs_responsibleRoleType.ORA //Уполномоченный орган в качестве организатора совместного конкурса (аукциона) согласно ст. 25 Закона №44ФЗ;
| zfcs_responsibleRoleType.OCU //Заказчик в качестве организатора совместного конкурса (аукциона) согласно ст. 25 Закона №44ФЗ;
| zfcs_responsibleRoleType.OAI //Уполномоченное учреждение в качестве организатора совместного конкурса (аукциона) согласно ст. 25 Закона №44ФЗ;
| zfcs_responsibleRoleType.OOA //Организация, осуществляющая полномочия заказчика на осуществление закупок на основании договора (соглашения) в качестве организатора совместного конкурса (аукциона) согласно ст. 25 Закона №44ФЗ;
=> TenderTypeOrganizersExtendedRoleOrganizerExtendedRole.JointOrganizer;
}
entity() <-
{
OrganizerLocalIdentity = org.IdentityInfo.LocalIdentity;
OrganizerExtendedRole = extenderRole
}
}
[Overloads(org, organizationRef, zfcs_organizationRef)]
getCustomerByReq(customers : CustomersBag, org : organizationRef, _reqQuantity : decimal?) : CustomerProductsRequirementsInfo
{
mutable val;
unless(customers.TryGetValue(org.regNum, out val))
{
val = entity() <-
{
CustomerLocalIdentity = str(Guid.NewGuid());
CustomerName = org.fullName;
}
customers.Add(org.regNum, val);
}
val
}
[Overloads(org, organizationRef, zfcs_organizationRef)]
getCustomerByProd(customers : CustomersBag, org : organizationRef, productLocalIdentity : string, quantity : decimal?) : CustomerProductsRequirementsInfo
{
mutable val;
if(customers.TryGetValue(org.regNum, out val))
{
_ = val<<-
{
ProductLocalIdentity = productLocalIdentity;
Quantity = quantity;
}
}
else
{
val = entity() <-
{
CustomerLocalIdentity = str(Guid.NewGuid());
CustomerName = org.fullName;
ProductLocalIdentity = productLocalIdentity;
Quantity = quantity;
}
customers.Add(org.regNum, val);
}
val
}
[Overloads(src, zfcs_notificationEFTypeLotCustomerRequirement
, zfcs_notificationZPTypeLotCustomerRequirement
, zfcs_notificationPOTypeLotCustomerRequirement
, zfcs_notificationEPTypeLotCustomerRequirement
, zfcs_notificationZKBITypeLotCustomerRequirement
, zfcs_protocolZKBITypeLotCustomerRequirement
, zfcs_lotOKTypeCustomerRequirement
, zfcs_lotZKTypeCustomerRequirement)]
customerRequirementBase(customers : CustomersBag, src : zfcs_protocolZKBITypeLotCustomerRequirement) : LotTypeCustomerRequirement
{
def customer = getCustomerByReq(customers, src.customer, null);
entity() <-
{
CustomerLocalIdentity = customer.CustomerLocalIdentity;
ExecutionDeliveryTerm = src.deliveryTerm;
StartPrice = decimal'(src.maxPrice);
}
}
[Overloads(src, zfcs_notificationEFTypeLotCustomerRequirement
, zfcs_notificationZPTypeLotCustomerRequirement
, zfcs_notificationPOTypeLotCustomerRequirement)]
customerRequirementWithGuaranties(customers : CustomersBag, src : zfcs_notificationEFTypeLotCustomerRequirement) : LotTypeCustomerRequirement
{
customerRequirementBase(customers, src) <<-
{
ApplicationGuarantee = paymentInfo(src.applicationGuarantee);
ContractGuarantee = paymentInfo(src.contractGuarantee);
}
}
customerRequirement(customers : CustomersBag, src : zfcs_notificationEFTypeLotCustomerRequirement) : LotTypeCustomerRequirement
{
customerRequirementWithGuaranties(customers, src)
}
customerRequirement(customers : CustomersBag, src : zfcs_notificationZPTypeLotCustomerRequirement) : LotTypeCustomerRequirement
{
//todo:
_ = src.tenderPlanInfo;
_ = src.budgetFinancings;
_ = src.nonbudgetFinancings;
customerRequirementWithGuaranties(customers, src)
}
customerRequirement(customers : CustomersBag, src : zfcs_notificationPOTypeLotCustomerRequirement) : LotTypeCustomerRequirement
{
//todo:
_ = src.budgetFinancings;
_ = src.nonbudgetFinancings;
customerRequirementWithGuaranties(customers, src)
}
customerRequirement(customers : CustomersBag, src : zfcs_notificationEPTypeLotCustomerRequirement) : LotTypeCustomerRequirement
{
//todo:
_ = src.tenderPlanInfo;
_ = src.budgetFinancings;
_ = src.nonbudgetFinancings;
customerRequirementBase(customers, src) <<-
{
ContractGuarantee = paymentInfo(src.contractGuarantee);
}
}
customerRequirement(customers : CustomersBag, src : zfcs_notificationZKBITypeLotCustomerRequirement) : LotTypeCustomerRequirement
{
//todo:
_ = src.tenderPlanInfo;
_ = src.budgetFinancings;
_ = src.nonbudgetFinancings;
customerRequirementBase(customers, src) <<-
{
OneSideRejectionInfo = src.onesideRejection;
}
}
customerRequirement(customers : CustomersBag, src : zfcs_protocolZKBITypeLotCustomerRequirement) : LotTypeCustomerRequirement
{
//todo:
_ = src.tenderPlanInfo;
customerRequirementBase(customers, src)
}
customerRequirement(customers : CustomersBag, src : zfcs_lotZKTypeCustomerRequirement) : LotTypeCustomerRequirement
{
//todo:
_ = src.tenderPlanInfo;
customerRequirementBase(customers, src) <<-
{
ContractGuarantee = if(src.contractGuarantee != null) paymentInfo(src.contractGuarantee) else null;
}
}
customerRequirement(customers : CustomersBag, src : zfcs_lotOKTypeCustomerRequirement) : LotTypeCustomerRequirement
{
//todo:
_ = src.tenderPlanInfo;
_ = src.budgetFinancings;
customerRequirementBase(customers, src) <<-
{
ContractGuarantee = paymentInfo(src.contractGuarantee);
}
}
[Overloads(src, zfcs_notificationEFTypeLotPurchaseObjectsPurchaseObject
, zfcs_notificationZPTypeLotPurchaseObjectsPurchaseObject
, zfcs_lotZKTypePurchaseObjectsPurchaseObject
, zfcs_lotOKTypePurchaseObjectsPurchaseObject
, zfcs_notificationEPTypeLotPurchaseObjectsPurchaseObject
, zfcs_notificationZKBITypeLotPurchaseObjectsPurchaseObject
, zfcs_notificationPOTypeLotPurchaseObjectsPurchaseObject)]
buildCustomerProductRequirement(customers : CustomersBag, productLocalId : string, src : zfcs_notificationEFTypeLotPurchaseObjectsPurchaseObject) : void
{
when(src.customerQuantities != null)
foreach(x in src.customerQuantities)
_ = getCustomerByProd(customers, x.customer, productLocalId, x.quantity)
}
#endregion
#region Notifications
[Overloads(src, zfcs_notificationEFType
, zfcs_notificationEPType
, zfcs_notificationISMType
, zfcs_notificationISOType
, zfcs_notificationOKDType
, zfcs_notificationOKOUType
, zfcs_notificationOKType
, zfcs_notificationPOType
, zfcs_notificationZakAType
, zfcs_notificationZakKDType
, zfcs_notificationZakKOUType
, zfcs_notificationZakKType
, zfcs_notificationZKBIType
, zfcs_notificationZKType
, zfcs_notificationZPType
, zfcs_notificationLotChangeType)]
public notificationBase(tender : TenderType, src: zfcs_notificationLotChangeType) : TenderType
{
tender <<-
{
Attachments =
from attach in src.attachments
select attachment(attach);
IdentityInfo <-
{
TenderIdentity = src.purchaseNumber;
}
MainInfo <-
{
DirectDeal = nullable(TenderTypeMainInfoDirectDeal.Demand);
Name = src.purchaseObjectInfo;
PlacingWay <-
{
Code = src.placingWay.code;
Name = src.placingWay.name;
}
PurchaseType = nullable(TenderTypeMainInfoPurchaseType.OOS_44);
}
PublishInfo <-
{
Date = date(src.docPublishDate);
ModificationInfo = src.modification?.info; //todo: нужен ли какой-то более сложный тип для ModificationInfo?
Url = src.href;
}
StateInfo <-
{
State = TenderTypeStateInfoState.Published;
StatePublishDate = date(src.docPublishDate);
}
}
}
[Overloads(src, zfcs_notificationEFType
, zfcs_notificationEPType
, zfcs_notificationOKDType
, zfcs_notificationOKOUType
, zfcs_notificationOKType
, zfcs_notificationPOType
, zfcs_notificationZakAType
, zfcs_notificationZakKDType
, zfcs_notificationZakKOUType
, zfcs_notificationZakKType
, zfcs_notificationZKType
, zfcs_notificationZPType)]
public notificationBaseWithTwoOrgs(src : zfcs_notificationEFType) : TenderType
{
notificationBase(entity(), src) <-
{
def resp = src.purchaseResponsible;
def respOrg = person(resp.responsibleOrg, collection contact(resp.responsibleInfo));
def specOrg = person(resp.specializedOrg, null);
Organizers = collection { respOrg; specOrg }
OrganizersExtendedRoles = collection { extendedRole(respOrg, resp.responsibleRole); extendedRole(specOrg, null) }
}
}
[Overloads(src, zfcs_notificationISMType
, zfcs_notificationISOType
, zfcs_notificationZKBIType)]
public notificationBaseWithOneOrg(src : zfcs_notificationISOType) : TenderType
{
notificationBase(entity(), src) <-
{
def resp = src.purchaseResponsible;
def respOrg = person(resp.responsibleOrg, null);
Organizers = collection respOrg;
OrganizersExtendedRoles = collection extendedRole(respOrg, resp.responsibleRole);
}
}
public notificationEF(src : zfcs_notificationEFType) : TenderType
{
notificationBaseWithTwoOrgs(src) <<-
{
MainInfo <-
{
ElectronicTradePlace <-
{
Code = src.ETP?.code;
Name = src.ETP?.name;
Url = src.ETP?.url;
}
}
}
}
public notificationEP(src : zfcs_notificationEPType) : TenderType
{
notificationBaseWithTwoOrgs(src)
}
public notificationISM(src : zfcs_notificationISMType) : TenderType
{
notificationBaseWithOneOrg(src)
}
public notificationISO(src : zfcs_notificationISOType) : TenderType
{
notificationBaseWithOneOrg(src)
}
public notificationOKD(src : zfcs_notificationOKDType) : TenderType
{
notificationBaseWithTwoOrgs(src);
}
public notificationOKOU(src : zfcs_notificationOKOUType) : TenderType
{
notificationBaseWithTwoOrgs(src)
}
public notificationOK(src : zfcs_notificationOKType) : TenderType
{
notificationBaseWithTwoOrgs(src)
}
public notificationPO(src : zfcs_notificationPOType) : TenderType
{
notificationBaseWithTwoOrgs(src)
}
public notificationZakA(src : zfcs_notificationZakAType) : TenderType
{
notificationBaseWithTwoOrgs(src)
}
public notificationZakKD(src : zfcs_notificationZakKDType) : TenderType
{
notificationBaseWithTwoOrgs(src)
}
public notificationZakKOU(src : zfcs_notificationZakKOUType) : TenderType
{
notificationBaseWithTwoOrgs(src)
}
public notificationZakK(src : zfcs_notificationZakKType) : TenderType
{
notificationBaseWithTwoOrgs(src)
}
public notificationZKBI(src : zfcs_notificationZKBIType) : TenderType
{
notificationBaseWithOneOrg(src)
}
public notificationZK(src : zfcs_notificationZKType) : TenderType
{
notificationBaseWithTwoOrgs(src)
}
//zfcs_notificationZPType
public notificationZP(src : zfcs_notificationZPType) : TenderType
{
notificationBaseWithTwoOrgs(src)
}
#endregion
#region Lots
[Overloads(src, zfcs_lotISType
, zfcs_notificationEFTypeLot
, zfcs_notificationZPTypeLot
, zfcs_notificationZKTypeLot
, zfcs_notificationOKTypeLot
, zfcs_notificationOKOUTypeLot
, zfcs_notificationOKDTypeLot
, zfcs_notificationLotChangeTypeLot
, zfcs_notificationEPTypeLot
, zfcs_notificationZKBITypeLot
, zfcs_notificationPOTypeLot
, zfcs_lotOKType)]
public lotBase1(lot : LotType,
src : zfcs_lotISType,
purchaseNumber : string,
lotNumber : string,
procedures : LotTypeProcedures,
statePublishDate : DateTime?,
lotName : string) : LotType
{
lot <<-
{
IdentityInfo <-
{
LotNumber = lotNumber;
TenderIdentity = purchaseNumber;
}
MainInfo <-
{
Currency = src.currency.code;
Name = lotName;
StartPrice = decimal'(src.maxPrice);
}
Preferences =
from pref in src.preferenses
select entity() <-
{
Preference <-
{
Code = str(pref.code);
Name = pref.name;
}
Value = decimal'(pref.prefValue);
}
Requirements =
from req in src.requirements
select entity() <-
{
Content = req.content;
Requirement <-
{
Code = str(req.code);
Name = req.name;
}
}
Procedures = procedures;
StateInfo <-
{
State = LotTypeStateInfoState.Published;
StatePublishDate = date(statePublishDate);
}
}
}
[Overloads(src, zfcs_notificationEFTypeLot
, zfcs_notificationZPTypeLot
, zfcs_notificationZKTypeLot
, zfcs_notificationOKTypeLot
, zfcs_notificationOKOUTypeLot
, zfcs_notificationOKDTypeLot
, zfcs_notificationLotChangeTypeLot
, zfcs_notificationEPTypeLot
, zfcs_notificationZKBITypeLot
, zfcs_notificationPOTypeLot
, zfcs_lotOKType)]
public lotBase2(lot : LotType,
src : zfcs_notificationPOTypeLot,
purchaseNumber : string,
lotNumber : string,
procedures : LotTypeProcedures,
statePublishDate : DateTime?,
lotName : string) : LotType
{
def customers = CustomersBag();
def products = from purc in src.purchaseObjects.purchaseObject select (str(Guid.NewGuid()), purc);
def requirements = from req in src.customerRequirements select customerRequirement(customers, req);
foreach((localId, prod) in products)
buildCustomerProductRequirement(customers, localId, prod);
lotBase1(lot, src, purchaseNumber, lotNumber, procedures, statePublishDate, lotName) <-
{
CustomerProductsRequirements =
from customerInfo in customers
select
if(customerInfo.Value.ProductLocalIdentity == null) null
else entity() <-
{
def v = customerInfo.Value;
CustomerLocalIdentity = v.CustomerLocalIdentity;
ProductLocalIdentity = v.ProductLocalIdentity;
Quantity = v.Quantity;
}
CustomerRequirements = requirements;
Products =
from (localId, purc) in products
select entity() <-
{
AmountUnit = purc.OKEI?.code;
Classifiers = collection entity() <-
{
Code = purc.OKPD.code;
Name = purc.OKPD.name;
Type = ClassifierItemTypeType.OKPD;
}
LocalIdentity = localId;
Name = purc.name;
def item = purc.quantity.ItemChoice;
Quantity = choice(item)
{
when(item.undefined(_))
null;
when(item.value(x))
nullable(x);
}
SumPrice = decimal'(purc.sum);
UnitPrice = decimal'(purc.price);
}
Traders =
from customerInfo in customers
select person(customerInfo);
}
}
[Overloads(src, zfcs_notificationEFTypeLot
, zfcs_notificationZPTypeLot
, zfcs_notificationZKTypeLot
, zfcs_notificationOKTypeLot
, zfcs_notificationOKOUTypeLot
, zfcs_notificationOKDTypeLot
, zfcs_notificationLotChangeTypeLot
, zfcs_notificationEPTypeLot
, zfcs_notificationZKBITypeLot
, zfcs_lotOKType)]
public lotBase3(lot : LotType,
src : zfcs_lotOKType,
purchaseNumber : string,
lotNumber : string,
procedures : LotTypeProcedures,
statePublishDate : DateTime?,
lotName : string) : LotType
{
lotBase2(lot, src, purchaseNumber, lotNumber, procedures, statePublishDate, lotName) <<-
{
ExternalLinks <-
{
PlanGraphPositionsIdentities =
from req in src.customerRequirements
select req.tenderPlanInfo?.positionNumber;
}
}
}
public lotChange(lot : LotType, src : zfcs_notificationLotChangeType) : LotType
{
def item = src.ItemChoice;
def procedures = choice(item)
{
when(item.procedureOKDInfo(x))
procedures(x);
when(item.procedureOKInfo(x))
procedures(x);
when(item.procedureOKInfo(x))
procedures(x);
when(item.procedureOKOUInfo(x))
procedures(x);
when(item.procedureZakAInfo(x))
procedures(x);
when(item.procedureZakKDInfo(x))
procedures(x);
when(item.procedureZakKInfo(x))
procedures(x);
when(item.procedureZakKOUInfo(x))
procedures(x);
}
lotBase3(lot, src.lot, src.purchaseNumber, src.lot.lotNumber, procedures, src.docPublishDate, null)
}
public lotChange(src : zfcs_notificationLotChangeType) : LotType
{
lotChange(entity(), src);
}
public lotEF(src : zfcs_notificationEFType, lot : zfcs_notificationEFTypeLot) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, str(1), procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotEP(src : zfcs_notificationEPType, lot : zfcs_notificationEPTypeLot) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, str(1), null, src.docPublishDate, src.purchaseObjectInfo);
}
public lotISM(src : zfcs_notificationISMType, lot : zfcs_lotISType) : LotType
{
lotBase1(entity(), lot, src.purchaseNumber, lot.lotNumber, procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotISO(src : zfcs_notificationISOType, lot : zfcs_lotISType) : LotType
{
lotBase1(entity(), lot, src.purchaseNumber, lot.lotNumber, procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotOK(src : zfcs_notificationOKType, lot : zfcs_notificationOKTypeLot) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, lot.lotNumber, procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotOKD(src : zfcs_notificationOKDType, lot : zfcs_notificationOKDTypeLot) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, lot.lotNumber, procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotOKOU(src : zfcs_notificationOKOUType, lot : zfcs_notificationOKOUTypeLot) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, lot.lotNumber, procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotPO(src : zfcs_notificationPOType, lot : zfcs_notificationPOTypeLot) : LotType
{
lotBase2(entity(), lot, src.purchaseNumber, str(1), procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotZakA(src : zfcs_notificationZakAType, lot : zfcs_lotOKType) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, lot.lotNumber, procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotZakK(src : zfcs_notificationZakKType, lot : zfcs_lotOKType) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, lot.lotNumber, procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotZakKD(src : zfcs_notificationZakKDType, lot : zfcs_lotOKType) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, lot.lotNumber, procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotZakKOU(src : zfcs_notificationZakKOUType, lot : zfcs_lotOKType) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, lot.lotNumber, procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotZK(src : zfcs_notificationZKType, lot : zfcs_notificationZKTypeLot) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, str(1), procedures(src.procedureInfo), src.docPublishDate, src.purchaseObjectInfo);
}
public lotZKBI(src : zfcs_notificationZKBIType, lot : zfcs_notificationZKBITypeLot) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, str(1), null, src.docPublishDate, src.purchaseObjectInfo);
}
public lotZP(src : zfcs_notificationZPType, lot : zfcs_notificationZPTypeLot) : LotType
{
lotBase3(entity(), lot, src.purchaseNumber, str(1), null, src.docPublishDate, src.purchaseObjectInfo);
}
#endregion
#region Changes
public notificationChange(tender : TenderType, src : zfcs_notificationLotChangeType) : TenderType
{
notificationBase(tender, src);
}
public zfcs_notificationOrgChangeType(tender : TenderType, _ : zfcs_notificationOrgChangeType) : TenderType
{
//todo: ZFCS_NOTIFICATIONORGCHANGETYPE
//разобраться с тем как мапить организации (их тут три штуки)
tender
}
public notificationLotCancel(lot : LotType , src : zfcs_notificationLotCancelType) : LotType
{
lot <<-
{
StateInfo <-
{
CancelledReason = cancelReason(src.cancelReason) ?? src.addInfo;
State = LotTypeStateInfoState.Cancelled;
StatePublishDate = date(src.docPublishDate);
}
}
}
public placementResult(tender : TenderType, src : zfcs_placementResultType) : TenderType
{
tender <<-
{
IdentityInfo <-
{
}
ExternalLinks <-
{
FoundationTenderIdentity = src.foundationProtocolNumber;
}
StateInfo <-
{
State =
if(src.result.HasValue)
match(src.zzz_result)
{
| zfcs_placementResultEnum.CC => TenderTypeStateInfoState.Published;
| zfcs_placementResultEnum.RC => TenderTypeStateInfoState.Cancelled;
}
else
tender.StateInfo.State;
StatePublishDate = date(src.createDate);
}
PublishInfo <-
{
Date = date(src.createDate);
Version = str(src.versionNumber);
}
}
}
public placementResult(lot : LotType, src : zfcs_placementResultType) : LotType
{
//todo: src.applications; src.abandonedReason.code; src.abandonedReason.type;
lot <<-
{
StateInfo <-
{
State =
if(src.result.HasValue)
match(src.zzz_result)
{
| zfcs_placementResultEnum.CC => LotTypeStateInfoState.Abandoned;
| zfcs_placementResultEnum.RC => LotTypeStateInfoState.Cancelled;
}
else
lot.StateInfo.State;
StatePublishDate = date(src.createDate);
AbandonedReason = src.abandonedReason?.name;
}
}
}
public notificationCancelFailure(tender : TenderType, src : zfcs_notificationCancelFailureType) : TenderType
{
//todo: Узнать, как заполнить причину отмены
def attachments =
from attach in src.attachments
select attachment(attach);
tender <<-
{
Attachments = mergeAttachments(tender.Attachments, attachments);
MainInfo <-
{
PlacingWay <-
{
Code = src.placingWay.code;
Name = src.placingWay.name;
}
}
StateInfo <-
{
CancelledReason = cancelReason(src.cancelReason) ?? src.addInfo;
StatePublishDate = date(src.docPublishDate);
State = TenderTypeStateInfoState.Published;
}
}
}
public notificationCancelFailure(lot : LotType, src : zfcs_notificationCancelFailureType) : LotType
{
lot<<-
{
StateInfo <-
{
State = LotTypeStateInfoState.Published;
StatePublishDate = date(src.docPublishDate);
}
}
}
public notificationCancel(tender : TenderType, src : zfcs_notificationCancelType) : TenderType
{
//todo: Узнать, как заполнить причину отмены
tender <<-
{
StateInfo <-
{
CancelledReason = cancelReason(src.cancelReason) ?? src.addInfo;
StatePublishDate = date(src.docPublishDate);
State = TenderTypeStateInfoState.Cancelled;
}
}
}
public notificationCancel(lot : LotType, src : zfcs_notificationCancelType) : LotType
{
//todo: Узнать, как заполнить причину отмены
lot <<-
{
StateInfo <-
{
CancelledReason = cancelReason(src.cancelReason) ?? src.addInfo;
StatePublishDate = date(src.docPublishDate);
State = LotTypeStateInfoState.Cancelled;
}
}
}
public notificationEFDateChange(tender : TenderType, src : zfcs_notificationEFDateChangeType) : TenderType
{
//todo:
_ = src.auctionTime;
tender <<-
{
StateInfo <-
{
State = TenderTypeStateInfoState.Published;
StatePublishDate = date(src.docPublishDate);
}
}
}
public notificationEFDateChange(lot : LotType, src : zfcs_notificationEFDateChangeType) : LotType
{
lot <<-
{
StateInfo <-
{
State = LotTypeStateInfoState.Published;
StatePublishDate = date(src.docPublishDate);
}
}
}
public purchaseProlongationOK(tender : TenderType, src : zfcs_purchaseProlongationOKType) : TenderType
{
tender <<-
{
StateInfo <-
{
StatePublishDate = date(src.docPublishDate);
State = TenderTypeStateInfoState.Published;
}
}
}
public purchaseProlongationOK(lot : LotType, src : zfcs_purchaseProlongationOKType) : LotType
{
lot <<-
{
Procedures <-
{
Scoring <-
{
Date = date(src.scoringProlongationDate);
}
}
StateInfo <-
{
StatePublishDate = date(src.docPublishDate);
State = LotTypeStateInfoState.Prolongated;
ProlongatedReason = purchaseProlongationOKStr;
}
}
}
public purchaseProlongationZK(tender : TenderType, src : zfcs_purchaseProlongationZKType) : TenderType
{
tender <<-
{
StateInfo <-
{
StatePublishDate = date(src.docPublishDate);
State = TenderTypeStateInfoState.Published;
}
}
}
public purchaseProlongationZK(lot : LotType, src : zfcs_purchaseProlongationZKType) : LotType
{
lot <<-
{
Procedures <-
{
Collecting <-
{
EndDate = date(src.collectingProlongationDate);
}
}
StateInfo <-
{
StatePublishDate = date(src.docPublishDate);
State = LotTypeStateInfoState.Prolongated;
ProlongatedReason = purchaseProlongationZKStr;
}
}
}
#endregion
public override Transform() : Seq[IntDoc]
{
yield EntityBuilder(this)
.Create(notificationEF, null, x => x.docPublishDate)
.Create(notificationEP, null, x => x.docPublishDate)
.Create(notificationISM, null, x => x.docPublishDate)
.Create(notificationISO, null, x => x.docPublishDate)
.Create(notificationOK, null, x => x.docPublishDate)
.Create(notificationOKD, null, x => x.docPublishDate)
.Create(notificationOKOU, null, x => x.docPublishDate)
.Create(notificationPO, null, x => x.docPublishDate)
.Create(notificationZakA, null, x => x.docPublishDate)
.Create(notificationZakK, null, x => x.docPublishDate)
.Create(notificationZakKD, null, x => x.docPublishDate)
.Create(notificationZakKOU, null, x => x.docPublishDate)
.Create(notificationZK, null, x => x.docPublishDate)
.Create(notificationZKBI, null, x => x.docPublishDate)
.Create(notificationZP, null, x => x.docPublishDate)
.Change(notificationChange, null, x => x.docPublishDate)
.Change(placementResult, null, x => x.createDate)
.Change(notificationCancelFailure, null, x => x.docPublishDate)
.Change(notificationCancel, null, x => x.docPublishDate)
.Change(notificationEFDateChange, null, x => x.docPublishDate)
.Change(purchaseProlongationOK, null, x => x.docPublishDate)
.Change(purchaseProlongationZK, null, x => x.docPublishDate)
.Build(x => x.IdentityInfo.TenderIdentity);
yields EntitiesBuilder(this)
.Create(lotEF, x => array[ x.lot ], null, (n, _) => n.docPublishDate)
.Create(lotEP, x => array[ x.lot ], null, (n, _) => n.docPublishDate)
.Create(lotISM, x => x.lots, null, (n, _) => n.docPublishDate)
.Create(lotISO, x => array[ x.lot ], null, (n, _) => n.docPublishDate)
.Create(lotOK, x => x.lots, null, (n, _) => n.docPublishDate)
.Create(lotOKD, x => x.lots, null, (n, _) => n.docPublishDate)
.Create(lotOKOU,x => x.lots, null, (n, _) => n.docPublishDate)
.Create(lotPO, x => array [ x.lot ], null, (n, _) => n.docPublishDate)
.Create(lotZakA, x => x.lots, null, (n, _) => n.docPublishDate)
.Create(lotZakK, x => x.lots, null, (n, _) => n.docPublishDate)
.Create(lotZakKD, x => x.lots, null, (n, _) => n.docPublishDate)
.Create(lotZakKOU, x => x.lots, null, (n, _) => n.docPublishDate)
.Create(lotZK, x => array [ x.lot ] , null, (n, _) => n.docPublishDate)
.Create(lotZKBI, x => array [ x.lot ], null, (n, _) => n.docPublishDate)
.Create(lotZP, x => array [ x.lot ], null, (n, _) => n.docPublishDate)
.Change(lotChange, (l, c) => l.IdentityInfo.LotNumber == c.lot.lotNumber, null, x => x.docPublishDate, lotChange)
.Change(notificationLotCancel, (l, c) => c.lot == null || l.IdentityInfo.LotNumber == c.lot.lotNumber, null, x => x.docPublishDate)
.Change(placementResult, (l, r) => l.IdentityInfo.LotNumber == r.lotNumber, null, x => x.createDate)
.Change(notificationCancelFailure, (l, c) => c.lot == null || l.IdentityInfo.LotNumber == c.lot.lotNumber, null, x => x.docPublishDate)
//.Change(notificationCancel, _ => true, null, x => x.docPublishDate)
.Change(notificationEFDateChange, _ => true, null, x => x.docPublishDate)
.Change(purchaseProlongationOK, (l, c) => l.IdentityInfo.LotNumber == c.lot.lotNumber, null, x => x.docPublishDate)
.Change(purchaseProlongationZK, _ => true, null, x => x.docDate)
.Build(x => string.Format("{0}/{1}", x.IdentityInfo.TenderIdentity, x.IdentityInfo.LotNumber));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment