feat(data): DsRow 加 dsTypeCode/properties + parseDsRows 解析

This commit is contained in:
gaozheng 2026-06-24 17:40:49 +08:00
parent a7d558bbfa
commit 5a719ca16d
3 changed files with 40 additions and 0 deletions

View File

@ -127,6 +127,18 @@ std::vector<DsRow> parseDsRows(const QJsonArray& arr) {
// 数据集树父节点sourceShowParentId 是“显示树”父(=派生数据挂源数据下),回退 parentId。 // 数据集树父节点sourceShowParentId 是“显示树”父(=派生数据挂源数据下),回退 parentId。
d.parentId = str(o, "sourceShowParentId"); d.parentId = str(o, "sourceShowParentId");
if (d.parentId.empty()) d.parentId = str(o, "parentId"); if (d.parentId.empty()) d.parentId = str(o, "parentId");
d.dsTypeCode = str(o, "dsTypeCode");
d.structParentId = str(o, "structParentId");
d.structParentConfType = o.value(QStringLiteral("structParentConfType")).toInt();
// properties[] = [{confFieldId,value}]value 用 toVariant().toString() 兼容字符串/数值/时间,
// 与 parseDynamicForm 同口径);非数组形态(文件型 ds安全返回空。
const QJsonArray props = o.value(QStringLiteral("properties")).toArray();
d.properties.reserve(static_cast<size_t>(props.size()));
for (const QJsonValue& pv : props) {
const QJsonObject po = pv.toObject();
d.properties.push_back(
{str(po, "confFieldId"), po.value(QStringLiteral("value")).toVariant().toString().toStdString()});
}
const QJsonObject f = o.value(QStringLiteral("file")).toObject(); const QJsonObject f = o.value(QStringLiteral("file")).toObject();
d.fileName = str(f, "name"); d.fileName = str(f, "name");
d.fileUrl = str(f, "url"); d.fileUrl = str(f, "url");

View File

@ -7,11 +7,18 @@ struct DsNode { std::string id, name, ddType; };
// data/page 或 file/page 的一条 ds。数据行只用 dsName/typeName/ddCode文件行另含 file*。 // data/page 或 file/page 的一条 ds。数据行只用 dsName/typeName/ddCode文件行另含 file*。
// parentId = 数据集树的父节点 id取 sourceShowParentId回退 parentId空或不在本批=树根。 // parentId = 数据集树的父节点 id取 sourceShowParentId回退 parentId空或不在本批=树根。
// 原版数据列表是树:源「原始数据」为根,派生「反演/接地电阻」挂其下。 // 原版数据列表是树:源「原始数据」为根,派生「反演/接地电阻」挂其下。
// ds 属性键值data/page 的 properties[] 项confFieldId→value 原始对)。
struct DsPropKV { std::string confFieldId, value; };
struct DsRow { struct DsRow {
std::string id, dsName, typeName, ddCode, createTime; std::string id, dsName, typeName, ddCode, createTime;
std::string parentId; std::string parentId;
std::string fileName, fileUrl; std::string fileName, fileUrl;
long long fileSize = 0; long long fileSize = 0;
std::string dsTypeCode; // 大类分类主键spec §5ddCode 粒度不足以区分电阻率/视电阻率)
std::vector<DsPropKV> properties; // 原始 confFieldId→value装置类型/采集时间经 DatasetFieldDictionary 解析
std::string structParentId; // 上级节点 id段体容器分组 + 生成三维体归属用)
int structParentConfType = 0; // 1=GS/项目根 2=TM
}; };
struct DsPage { std::vector<DsRow> rows; int total = 0; }; struct DsPage { std::vector<DsRow> rows; int total = 0; };
struct TmNode { std::string id, name, confCode; std::vector<DsNode> dss; }; struct TmNode { std::string id, name, confCode; std::vector<DsNode> dss; };

View File

@ -195,6 +195,27 @@ TEST(NavDto, ParseDsRowsParentIdForTree) {
EXPECT_TRUE(d[3].parentId.empty()); // 二者皆无 → 空(树根) EXPECT_TRUE(d[3].parentId.empty()); // 二者皆无 → 空(树根)
} }
// 大类分类主键 dsTypeCode、层级 structParent*、原始属性 properties[] 的解析。
TEST(NavDto, ParseDsRowsExtractsTypeCodeAndProperties) {
const auto d = dto::parseDsRows(arrOf(R"([
{"id":"d1","dsName":"ERT1-WS","name":"电阻率数据",
"ddCode":"dd_inversion_data","dsTypeCode":"ERT platform inversion data",
"createTime":"2026-03-25 16:48:57","structParentId":"tm1","structParentConfType":2,
"properties":[
{"confFieldId":"1450495001706500","value":"1429468249448449"},
{"confFieldId":"1455083478786048","value":"2026-03-25 16:48:57"}
]}
])"));
ASSERT_EQ(d.size(), 1u);
EXPECT_EQ(d[0].dsTypeCode, "ERT platform inversion data");
EXPECT_EQ(d[0].structParentId, "tm1");
EXPECT_EQ(d[0].structParentConfType, 2);
EXPECT_EQ(d[0].ddCode, "dd_inversion_data");
ASSERT_EQ(d[0].properties.size(), 2u);
EXPECT_EQ(d[0].properties[0].confFieldId, "1450495001706500");
EXPECT_EQ(d[0].properties[0].value, "1429468249448449");
}
TEST(NavDto, ParseProjectItemFullFields) { TEST(NavDto, ParseProjectItemFullFields) {
const auto v = dto::parseProjectList(arrOf(R"([ const auto v = dto::parseProjectList(arrOf(R"([
{"id":"p1","projectName":"演示","projectCode":"001","status":2, {"id":"p1","projectName":"演示","projectCode":"001","status":2,