|
@@ -43,20 +43,20 @@ class CdFluxRemovalService:
|
|
|
"""
|
|
|
根据地区计算籽粒移除Cd通量
|
|
|
|
|
|
- @param area: 地区名称
|
|
|
+ @param area: 地区名称(仅用于地图边界,参数固定使用"韶关")
|
|
|
@returns: 计算结果字典
|
|
|
|
|
|
计算公式:籽粒移除(g/ha/a) = EXP(LnCropCd) * F11 * 0.5 * 15 / 1000
|
|
|
"""
|
|
|
try:
|
|
|
with SessionLocal() as db:
|
|
|
- # 查询指定地区的参数(严格等号匹配,不做任何映射)
|
|
|
- parameter = db.query(Parameters).filter(Parameters.area == area).first()
|
|
|
+ # 参数固定使用"韶关",area参数仅用于地图边界
|
|
|
+ parameter = db.query(Parameters).filter(Parameters.area == "韶关").first()
|
|
|
|
|
|
if not parameter:
|
|
|
return {
|
|
|
"success": False,
|
|
|
- "message": f"未找到地区 '{area}' 的参数数据",
|
|
|
+ "message": f"未找到韶关地区的参数数据",
|
|
|
"data": None
|
|
|
}
|
|
|
|
|
@@ -119,20 +119,20 @@ class CdFluxRemovalService:
|
|
|
"""
|
|
|
根据地区计算秸秆移除Cd通量
|
|
|
|
|
|
- @param area: 地区名称
|
|
|
+ @param area: 地区名称(仅用于地图边界,参数固定使用"韶关")
|
|
|
@returns: 计算结果字典
|
|
|
|
|
|
计算公式:秸秆移除(g/ha/a) = [EXP(LnCropCd)/(EXP(LnCropCd)*0.76-0.0034)] * F11 * 0.5 * 15 / 1000
|
|
|
"""
|
|
|
try:
|
|
|
with SessionLocal() as db:
|
|
|
- # 查询指定地区的参数(严格等号匹配,不做任何映射)
|
|
|
- parameter = db.query(Parameters).filter(Parameters.area == area).first()
|
|
|
+ # 参数固定使用"韶关",area参数仅用于地图边界
|
|
|
+ parameter = db.query(Parameters).filter(Parameters.area == "韶关").first()
|
|
|
|
|
|
if not parameter:
|
|
|
return {
|
|
|
"success": False,
|
|
|
- "message": f"未找到地区 '{area}' 的参数数据",
|
|
|
+ "message": f"未找到韶关地区的参数数据",
|
|
|
"data": None
|
|
|
}
|
|
|
|
|
@@ -408,24 +408,15 @@ class CdFluxRemovalService:
|
|
|
self.logger.warning(
|
|
|
f"存在 {outside_count} 个样点位于边界之外,绘图时将被掩膜隐藏。示例(最多10条): {sample_preview}")
|
|
|
|
|
|
- report = {
|
|
|
- "area": area,
|
|
|
- "level": level,
|
|
|
- "calculation_type": calculation_type,
|
|
|
- "total_points": total_points,
|
|
|
- "inside_points": inside_count,
|
|
|
- "outside_points": outside_count,
|
|
|
- "inside_percentage": round(inside_pct, 2),
|
|
|
- "outside_samples": outside_points
|
|
|
- }
|
|
|
- os.makedirs(output_dir, exist_ok=True)
|
|
|
- report_path = os.path.join(
|
|
|
- output_dir,
|
|
|
- f"{calculation_type}_{area}_points_boundary_check_{timestamp}.json"
|
|
|
+ # 在日志中打印边界检查统计结果
|
|
|
+ self.logger.info(
|
|
|
+ f"边界检查统计 - 地区: {area}, 层级: {level}, 计算类型: {calculation_type}, "
|
|
|
+ f"总样点: {total_points}, 边界内: {inside_count} ({inside_pct:.2f}%), "
|
|
|
+ f"边界外: {outside_count}"
|
|
|
)
|
|
|
- with open(report_path, "w", encoding="utf-8") as f:
|
|
|
- json.dump(report, f, ensure_ascii=False, indent=2)
|
|
|
- generated_files["point_boundary_report"] = report_path
|
|
|
+ if outside_count > 0 and len(outside_points) > 0:
|
|
|
+ sample_preview = outside_points[:5] # 只显示前5个样本
|
|
|
+ self.logger.info(f"边界外样点示例(前5个): {sample_preview}")
|
|
|
else:
|
|
|
generated_files = {}
|
|
|
except Exception as check_err:
|