|
|
|
|
@ -80,6 +80,29 @@ const nmFlowGaugeRecord* findFlowRecord(
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保留配置只要求 Code 唯一且记录可解析,不要求记录中存在非零产量。
|
|
|
|
|
const nmFlowGaugeRecord* findUniqueUsableFlowRecord(
|
|
|
|
|
const QVector<nmFlowGaugeRecord>& vecRecords,
|
|
|
|
|
const QString& sGaugeCode)
|
|
|
|
|
{
|
|
|
|
|
if(sGaugeCode.isEmpty()) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
const nmFlowGaugeRecord* pMatchedRecord = nullptr;
|
|
|
|
|
for(int nIndex = 0; nIndex < vecRecords.size(); ++nIndex) {
|
|
|
|
|
if(vecRecords[nIndex].sGaugeCode != sGaugeCode) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if(pMatchedRecord != nullptr) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
pMatchedRecord = &vecRecords[nIndex];
|
|
|
|
|
}
|
|
|
|
|
return pMatchedRecord != nullptr &&
|
|
|
|
|
pMatchedRecord->eStatus == NM_GaugeRecord_Usable
|
|
|
|
|
? pMatchedRecord : nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmFlowGaugeRecord* findMutableFlowRecord(
|
|
|
|
|
QVector<nmFlowGaugeRecord>& vecRecords,
|
|
|
|
|
const QString& sGaugeCode)
|
|
|
|
|
@ -398,10 +421,13 @@ void nmWxIncludeOtherWells::setupTable()
|
|
|
|
|
|
|
|
|
|
const bool bHadRequestedPhase = oWellRow.m_bUseOilRate ||
|
|
|
|
|
oWellRow.m_bUseGasRate || oWellRow.m_bUseWaterRate;
|
|
|
|
|
const bool bHadValidFlowSelection = findUniqueUsableFlowRecord(
|
|
|
|
|
oWellRow.m_vecFlowRecords,
|
|
|
|
|
oWellRow.m_sFlowGaugeCode) != nullptr;
|
|
|
|
|
normalizeFlowSelection(oWellRow);
|
|
|
|
|
// 新井默认启用三相;若框架当前选择失效,回退到第一条有产量记录。
|
|
|
|
|
// 用户已明确把三相都设为“无”时不自动恢复。
|
|
|
|
|
if(!oWellRow.canCalculate() && bHadRequestedPhase) {
|
|
|
|
|
if(!bHadValidFlowSelection && bHadRequestedPhase) {
|
|
|
|
|
for(int nRecordIndex = 0;
|
|
|
|
|
nRecordIndex < oWellRow.m_vecFlowRecords.size();
|
|
|
|
|
++nRecordIndex) {
|
|
|
|
|
@ -574,9 +600,9 @@ void nmWxIncludeOtherWells::addWellDataToTable(
|
|
|
|
|
|
|
|
|
|
void nmWxIncludeOtherWells::normalizeFlowSelection(WellDataRow& data) const
|
|
|
|
|
{
|
|
|
|
|
const nmFlowGaugeRecord* pRecord = findFlowRecord(
|
|
|
|
|
const nmFlowGaugeRecord* pRecord = findUniqueUsableFlowRecord(
|
|
|
|
|
data.m_vecFlowRecords, data.m_sFlowGaugeCode);
|
|
|
|
|
if(pRecord == nullptr || !nmIsSelectableFlowRecord(*pRecord)) {
|
|
|
|
|
if(pRecord == nullptr) {
|
|
|
|
|
data.m_sFlowGaugeCode.clear();
|
|
|
|
|
data.m_bUseOilRate = false;
|
|
|
|
|
data.m_bUseGasRate = false;
|
|
|
|
|
@ -594,11 +620,12 @@ void nmWxIncludeOtherWells::normalizeFlowSelection(WellDataRow& data) const
|
|
|
|
|
|
|
|
|
|
const int nSegmentCount = flowRecordSegmentCount(*pRecord);
|
|
|
|
|
if(nSegmentCount <= 0) {
|
|
|
|
|
data.m_sFlowGaugeCode.clear();
|
|
|
|
|
data.m_bUseOilRate = false;
|
|
|
|
|
data.m_bUseGasRate = false;
|
|
|
|
|
data.m_bUseWaterRate = false;
|
|
|
|
|
data.m_nFlowSegmentIndex = 0;
|
|
|
|
|
nmFlowGaugeRecord* pMutableRecord = findMutableFlowRecord(
|
|
|
|
|
data.m_vecFlowRecords, data.m_sFlowGaugeCode);
|
|
|
|
|
if(pMutableRecord != nullptr) {
|
|
|
|
|
pMutableRecord->nIndexF = 0;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(data.m_nFlowSegmentIndex < 1 ||
|
|
|
|
|
@ -711,7 +738,7 @@ void nmWxIncludeOtherWells::populateFlowSegmentCombo(
|
|
|
|
|
}
|
|
|
|
|
const bool bSignalsWereBlocked = pComboBox->blockSignals(true);
|
|
|
|
|
pComboBox->clear();
|
|
|
|
|
const nmFlowGaugeRecord* pRecord = findFlowRecord(
|
|
|
|
|
const nmFlowGaugeRecord* pRecord = findUniqueUsableFlowRecord(
|
|
|
|
|
data.m_vecFlowRecords, data.m_sFlowGaugeCode);
|
|
|
|
|
const int nSegmentCount = pRecord == nullptr
|
|
|
|
|
? 0 : flowRecordSegmentCount(*pRecord);
|
|
|
|
|
|