Показать сообщение отдельно
Старый 02.09.2024, 11:05   #5  
Perc is offline
Perc
Участник
 
194 / 57 (2) ++++
Регистрация: 05.03.2005
Делаю в акс2012 тоже самое джобом. Результат смотрю в стандартной форме ссылок без группировки.
Ранже делаю разный для случая если хочется посмотреть пересечения с системными полями RecId и пр.. Для них нет объекта в xRefPaths.
X++:
   SysDictField    df;
    TreeNode        node;
    Map                     map = new Map(Types::Integer, Types::Class);
    TmpRecIdFilter          tmp;
    Args                    args = new Args();
    FormRun                 fr;
    FormDataSource          fds;
    QueryBuildDataSource    ds;
    Counter                 cnt;
    QueryRun                qr = new QueryRun(new Query());
    ;

    map.insert(1, new SysDictField(tableNum(AccountingDistributionTmpJournalize), FieldNum(AccountingDistributionTmpJournalize, ReferenceDistribution)));
    map.insert(2, new SysDictField(tableNum(SubledgerJournalAccountEntryDistribution), FieldNum(SubledgerJournalAccountEntryDistribution, SubledgerJournalAccountEntry)));
    //map.insert(3, new SysDictField(tableNum(SubledgerJournalAccountEntryDistribution), FieldNum(SubledgerJournalAccountEntryDistribution, AccountingDistribution)));
    //map.insert(4, new SysDictField(tableNum(SubledgerJournalAccountEntry), FieldNum(SubledgerJournalAccountEntry, ExchangeRate1)));
    //map.insert(5, new SysDictField(tableNum(SubledgerJournalAccountEntry), FieldNum(SubledgerJournalAccountEntry, REPORTINGEXCHANGERATE1)));
    // ...

    for(cnt = 1; cnt<=map.elements(); cnt++) {
        df = map.lookup(cnt);
        node = TreeNode::findNode(df.path());
        if (ds) {
            ds = SysQuery::addExistsJoin(ds, tableNum(xRefReferences), false);
            ds.addLink(fieldNum(xRefReferences, xRefPathRecId), fieldNum(xRefReferences, xRefPathRecId));
        }
        else
            ds = qr.query().addDataSource(tableNum(xRefReferences));

        if (node)
            ds.addRange(fieldNum(xRefReferences, referencePathRecId)).value(queryValue(xRefPaths::find(node.treeNodePath()).RecId));
        else
            ds.addRange(fieldNum(xRefReferences, xRefNameRecId)).value(queryValue(xRefNames::find(xRefKind::TableField, df.tableName(), df.name(), false, "").RecId));
    }
    
    cnt = 0;
    while (qr.next())
    {
        cnt++;
        tmp.RefRecId = qr.getNo(1).RecId;
        tmp.insert();
    }

    //Просмотрим операции в форме
    args = new Args();
    args.name(formstr(xRefReferencesUsedByTypedTree));

    fr = classfactory.formRunClass(args);
    fr.init();

    fds = fr.dataSource(1);
    ds = fds.queryBuildDataSource();

    ds = SysQuery::addExistsJoin(ds, tableNum(TmpRecIdFilter), false);
    ds.addLink(fieldNum(xRefReferences, RecId), fieldNum(TmpRecIdFilter, RefRecId));

    fr.run();
    fds.queryRun().setCursor(tmp);

    fds.research();
    fr.detach();

    info(strFmt("cnt - %1", cnt));

Последний раз редактировалось Perc; 02.09.2024 в 11:08.
За это сообщение автора поблагодарили: dech (10).