fix: 判断列和评估结果改回固定值,周边站 MR 弱覆盖原样填平台占比
- 周边站表:小区行 P-R 填「/」、S-V 填 Y,汇总行 P-V 填 Y,评估结果填「通过」 - 低效拆除第 2 节:小区行判断列填「/」,扇区汇总行填 N、Y、Y、Y、Y,评估结果填「通过」 - 以上逐格照原模板工具,不再写阈值公式,也不再有「拆除后再评估」 - MR 弱覆盖原样填「大于等于 -110 占比」;以后要填 100 减占比时改 sources.py 的 WEAK_AS_SHARE - 文档补充同一扇区的识别方法(平台的 sectors_name)
This commit is contained in:
@@ -12,7 +12,8 @@ from app.evaluate.compute import EvalFailure, equiv_carriers, evaluate_site, nor
|
||||
from app.evaluate.demand import DemandError, DemandRow, SiteGroup, group_rows, parse_demand, template_workbook
|
||||
from app.evaluate.report import Item1, NeighborGroup, write_dixiao, write_pinduan
|
||||
from app.evaluate.compute import month_ready, mr_months
|
||||
from app.evaluate.sources import LTE_MR, LTE_WEEK, NR_KPI, NR_MR, NR_WEEK, MockGongcan, MockMetrics, Period, PlatformMetrics, PlatformTables, weak_share
|
||||
from app.evaluate import sources
|
||||
from app.evaluate.sources import LTE_MR, LTE_WEEK, NR_KPI, NR_MR, NR_WEEK, MockGongcan, MockMetrics, Period, PlatformMetrics, PlatformTables, mr_weak
|
||||
|
||||
TODAY = date(2026, 11, 11)
|
||||
|
||||
@@ -145,12 +146,13 @@ def test_platform_metrics_read_every_value_from_adhoc_tables():
|
||||
period = Period(date(2026, 10, 5), date(2026, 10, 11), date(2026, 9, 1))
|
||||
window = metrics.window(cells, period)
|
||||
assert set(window) == {"460-00-1-1", "460-00-9-1"}
|
||||
# 「MR 弱覆盖」原样填平台的「大于等于 -110 占比」,和原模板工具一样。
|
||||
assert window["460-00-1-1"] == {
|
||||
"traffic_gb": 21.1019, "rrc_max": 25.28571, "high_load": 0, "mr_weak_pct": pytest.approx(2.78951),
|
||||
"traffic_gb": 21.1019, "rrc_max": 25.28571, "high_load": 0, "mr_weak_pct": 97.21049,
|
||||
"access_rate": 99.92656, "drop_rate": 0.02945, "util_peak": 31.7206,
|
||||
}
|
||||
assert window["460-00-9-1"] == {
|
||||
"traffic_gb": 306.66953, "rrc_max": 53.49278, "high_load": 1, "mr_weak_pct": pytest.approx(0.23544),
|
||||
"traffic_gb": 306.66953, "rrc_max": 53.49278, "high_load": 1, "mr_weak_pct": 99.76456,
|
||||
"access_rate": 99.9765, "drop_rate": 0.00113, "util_peak": 18.4876,
|
||||
}
|
||||
assert [(title, field, start, end) for title, field, _values, start, end in tables.queries] == [
|
||||
@@ -185,7 +187,14 @@ def test_platform_metrics_read_every_value_from_adhoc_tables():
|
||||
no_month = early.window(cells[:1], Period(date(2026, 10, 5), date(2026, 10, 11)))
|
||||
assert no_month["460-00-1-1"]["mr_weak_pct"] is None and no_month["460-00-1-1"]["traffic_gb"] == 21.1019
|
||||
assert [query[0] for query in early.tables.queries] == ["4G 小区周表"]
|
||||
assert weak_share(None) is None and weak_share("83.9838") == pytest.approx(16.0162)
|
||||
|
||||
|
||||
def test_mr_weak_column_keeps_platform_ratio_unless_switched(monkeypatch):
|
||||
assert mr_weak(None) is None and mr_weak("83.9838") == 83.9838
|
||||
# 以后要改成「弱于 -110 的比例」时只改这一个开关。
|
||||
monkeypatch.setattr(sources, "WEAK_AS_SHARE", True)
|
||||
assert mr_weak(None) is None and mr_weak("83.9838") == pytest.approx(16.0162)
|
||||
assert PlatformMetrics(FakeTables()).window([{"cgi": "460-00-1-1", "tech": "4G"}], Period(date(2026, 10, 5), date(2026, 10, 11), date(2026, 9, 1)))["460-00-1-1"]["mr_weak_pct"] == pytest.approx(2.78951)
|
||||
|
||||
|
||||
def demand(cgi: str, name: str, order: str = "频段清退", when: date = date(2026, 10, 15)) -> DemandRow:
|
||||
@@ -235,7 +244,6 @@ def test_evaluate_site_waits_for_weeks_the_platform_has_not_synced():
|
||||
assert last_week["afterDay"] is None and "拆除后工参用 2026-11-09 的,要到 2026-11-12 才取,周边站先按拆除前工参算" in last_week["notes"]
|
||||
assert not any("拆除后工参用" in note for note in done["notes"] + this_week["notes"])
|
||||
lte_rows = [item for item in last_week["item2"] if item["tech"] == "4G"]
|
||||
assert last_week["mrPending"] is True and not done["mrPending"]
|
||||
assert all(item["before"]["mr_weak_pct"] is not None and item["after"]["mr_weak_pct"] is None and item["after"]["traffic_gb"] is not None for item in lte_rows)
|
||||
assert all(item["after"]["mr_weak_pct"] is not None for item in last_week["item2"] if item["tech"] == "5G")
|
||||
assert all(sector["cover_b"] is not None and sector["cover_a"] is None for sector in last_week["sectors"])
|
||||
@@ -275,7 +283,7 @@ def item(cgi: str, site: str, locatable: bool = True) -> Item1:
|
||||
def test_write_pinduan_groups_neighbors_per_site():
|
||||
content = write_pinduan(
|
||||
[item("460-00-1-1", "站A"), item("460-00-2-1", "站B", locatable=False)],
|
||||
[NeighborGroup("站A", neighbor_cells("周边一", 3)), NeighborGroup("站B", neighbor_cells("周边二", 2, with_after=False), mr_pending=True)],
|
||||
[NeighborGroup("站A", neighbor_cells("周边一", 3)), NeighborGroup("站B", neighbor_cells("周边二", 2, with_after=False))],
|
||||
)
|
||||
sheet = load_workbook(io.BytesIO(content)).worksheets[0]
|
||||
assert sheet["E3"].value == "460-00-1-1" and sheet["D3"].value == "460-00-1" and sheet["J3"].number_format == "yyyy-mm-dd"
|
||||
@@ -291,19 +299,17 @@ def test_write_pinduan_groups_neighbors_per_site():
|
||||
merges = {str(item) for item in sheet.merged_cells.ranges}
|
||||
assert f"W{first}:W{summary_a}" in merges and f"X{first}:X{summary_a}" in merges
|
||||
assert sheet.cell(first, 24).value == "站A"
|
||||
assert "不通过" in sheet.cell(first, 23).value and "拆除后再评估" in sheet.cell(first, 23).value
|
||||
# 每一项只在自己的停闭后数值存在时才比阈值,缺了显示「/」。
|
||||
assert sheet.cell(first, 19).value == f'=IF(ISNUMBER(L{first}),IF(L{first}>10,"N",IF(IF(ISNUMBER(E{first}),(L{first}-E{first})>5,FALSE),"N","Y")),"/")'
|
||||
assert sheet.cell(first, 20).value == f'=IF(ISNUMBER(M{first}),IF(M{first}<97,"N",IF(IF(ISNUMBER(F{first}),(F{first}-M{first})>1,FALSE),"N","Y")),"/")'
|
||||
assert sheet.cell(first, 21).value == f'=IF(ISNUMBER(N{first}),IF(N{first}<0.3,"Y","N"),"/")'
|
||||
assert sheet.cell(summary_a, 22).value == f'=IF(ISNUMBER(O{summary_a}),IF(O{summary_a}<0.3,"Y","N"),"/")'
|
||||
# 判断列和评估结果是固定值,和原模板工具一样:小区行前三项「/」、后四项「Y」,汇总行全「Y」,评估结果「通过」。
|
||||
assert [sheet.cell(first, col).value for col in range(16, 23)] == ["/", "/", "/", "Y", "Y", "Y", "Y"]
|
||||
assert [sheet.cell(summary_a, col).value for col in range(16, 23)] == ["Y"] * 7
|
||||
assert sheet.cell(first, 23).value == "通过"
|
||||
second = summary_a + 1
|
||||
assert sheet.cell(second, 1).value == "周边二-1" and sheet.cell(second, 9).value is None
|
||||
assert sheet.cell(second, 2).fill.start_color.rgb.endswith("F2F6FC")
|
||||
assert sheet.cell(second + 2, 1).value == "汇总"
|
||||
# 4G 停闭后的 MR 月数据没出时,汇总行的 MR 弱覆盖直接写「/」,别的项照常用公式。
|
||||
assert sheet.cell(second + 2, 19).value == "/" and sheet.cell(summary_a, 19).value.startswith("=IF(ISNUMBER(L")
|
||||
assert sheet.cell(second + 2, 20).value.startswith("=IF(ISNUMBER(M")
|
||||
# 停闭后的数据还没有时也一样写固定值,缺什么只写在结果说明里。
|
||||
assert [sheet.cell(second, col).value for col in range(16, 23)] == ["/", "/", "/", "Y", "Y", "Y", "Y"]
|
||||
assert [sheet.cell(second + 2, col).value for col in range(16, 23)] == ["Y"] * 7 and sheet.cell(second, 23).value == "通过"
|
||||
assert sheet.cell(second + 3, 1).value.startswith("CGI评估对象")
|
||||
|
||||
|
||||
@@ -327,7 +333,10 @@ def test_write_dixiao_fills_three_sections():
|
||||
assert sheet.cell(first, 1).value == "扇区甲" and sheet.cell(first + 1, 9).value == "/"
|
||||
summary = first + 2
|
||||
assert sheet.cell(summary, 2).value == "扇区汇总评估" and sheet.cell(summary, 7).value == 20.0
|
||||
assert sheet.cell(summary, 19).value == f'=IF(N(E{summary})>=3,"Y","N")'
|
||||
# 判断列和评估结果是固定值,和原模板工具一样:小区行全「/」,汇总行 N、Y、Y、Y、Y,评估结果「通过」。
|
||||
assert [sheet.cell(first, col).value for col in range(19, 24)] == ["/"] * 5
|
||||
assert [sheet.cell(summary, col).value for col in range(19, 24)] == ["N", "Y", "Y", "Y", "Y"]
|
||||
assert sheet.cell(first, 24).value == "通过"
|
||||
merges = {str(item) for item in sheet.merged_cells.ranges}
|
||||
assert {f"A{first}:A{summary}", f"X{first}:X{summary}", f"Y{first}:Y{summary}"} <= merges
|
||||
leaf3 = next(row for row in range(summary, 80) if sheet.cell(row, 2).value == "日均流量(GB)" and sheet.cell(row, 3).value == "日均有效RRC连接最大数")
|
||||
|
||||
Reference in New Issue
Block a user