|
@@ -190,7 +190,7 @@ def inputMsg():
|
|
|
print(f"生成过程中出现错误: {e}")
|
|
|
|
|
|
json_res = res["response"]
|
|
|
- json_res = json.loads(json_res)
|
|
|
+
|
|
|
|
|
|
# 组织成选址需要的数据格式
|
|
|
json_res = jsonResToDict(json_res)
|
|
@@ -201,95 +201,100 @@ def inputMsg():
|
|
|
# 将大模型解析的结果转换为选址需要的数据格式
|
|
|
|
|
|
def jsonResToDict(json_res):
|
|
|
- # 1.查询选址范围信息
|
|
|
- districtName = json_res["districtName"]
|
|
|
- ewkt = getAiDistrict(districtName)
|
|
|
- # 2.保存选址范围信息
|
|
|
- geomId = saveGeom(ewkt)
|
|
|
- # 3.获取用地类型信息
|
|
|
- landType = json_res["landType"]
|
|
|
- landType = getLandType(landType, "YDYHFLDM")
|
|
|
- # 4.获取模板信息
|
|
|
- factorTemplates = getTemplateByCode(landType)
|
|
|
-
|
|
|
- # TODO 以哪个因子列表为准,模版和因子个数怎么匹配
|
|
|
-
|
|
|
- now = datetime.datetime.now()
|
|
|
- formatted_time = now.strftime("%Y%m%d%H%M%S")
|
|
|
- res = {
|
|
|
- "xzmj": 1500,
|
|
|
- "xmmc": "规划选址项目_"+formatted_time,
|
|
|
- "jsdw": "建设单位",
|
|
|
- "ydxz_bsm": landType,
|
|
|
- "ydmjbegin": json_res["area"]["min"],
|
|
|
- "ydmjend": json_res["area"]["max"],
|
|
|
- "geomId": geomId,
|
|
|
- "yxyz": [],
|
|
|
- # TODO: 循环遍历
|
|
|
- # "yxyz": [
|
|
|
- # {
|
|
|
- # "id": "259e5bbaab434dbfb9c679bd44d4bfa4",
|
|
|
- # "name": "幼儿园服务半径",
|
|
|
- # "bsm": "TB_YEY",
|
|
|
- # "conditionInfo": {
|
|
|
- # "spatial_type": "distance",
|
|
|
- # "default": "lt",
|
|
|
- # "hasValue": true,
|
|
|
- # "defaultValue": "300",
|
|
|
- # "unit": "米",
|
|
|
- # "clip": false
|
|
|
- # }
|
|
|
- # }
|
|
|
- # ],
|
|
|
- # "useMultiple": json_res["useMultiple"],
|
|
|
- # "useLandType": json_res["useLandType"],
|
|
|
- # "multipleDistance": json_res["multipleDistance"]
|
|
|
- }
|
|
|
- # 循环遍历输入因子
|
|
|
- factors = json_res["factors"]
|
|
|
- input_factors = {}
|
|
|
- for factor in factors:
|
|
|
- factorInfo = getFactorByName(factor["type"])
|
|
|
- if factorInfo == None:
|
|
|
- continue
|
|
|
- factorId = factorInfo["id"]
|
|
|
- factorBsm = factorInfo["bsm"]
|
|
|
- conditionInfo = factorInfo["condition_info"]
|
|
|
- conditionObj = json.loads(conditionInfo)
|
|
|
-
|
|
|
- defaultValue ='0'
|
|
|
- if "value" in factor:
|
|
|
- defaultValue=str(factor["value"])
|
|
|
- # if defaultValue == '':
|
|
|
- # defaultValue = '0'
|
|
|
-
|
|
|
- factor_info = {
|
|
|
- "id": factorId,
|
|
|
- "name": factor["type"],
|
|
|
- "bsm": factorBsm,
|
|
|
- "conditionInfo": {
|
|
|
- "spatial_type": conditionObj["spatial_type"],
|
|
|
- "default": factor["condition"],
|
|
|
- "hasValue": conditionObj["hasValue"],
|
|
|
- "defaultValue": defaultValue,
|
|
|
- "unit": conditionObj["unit"],
|
|
|
- "clip": conditionObj["clip"]
|
|
|
- }
|
|
|
+ if json_res != str("未找到相关数据"):
|
|
|
+ json_res = json.loads(json_res)
|
|
|
+ # 1.查询选址范围信息
|
|
|
+ districtName = json_res["districtName"]
|
|
|
+ ewkt = getAiDistrict(districtName)
|
|
|
+ # 2.保存选址范围信息
|
|
|
+ geomId = saveGeom(ewkt)
|
|
|
+ # 3.获取用地类型信息
|
|
|
+ landType = json_res["landType"]
|
|
|
+ landType = getLandType(landType, "YDYHFLDM")
|
|
|
+ # 4.获取模板信息
|
|
|
+ factorTemplates = getTemplateByCode(landType)
|
|
|
+
|
|
|
+ # TODO 以哪个因子列表为准,模版和因子个数怎么匹配
|
|
|
+
|
|
|
+ now = datetime.datetime.now()
|
|
|
+ formatted_time = now.strftime("%Y%m%d%H%M%S")
|
|
|
+ res = {
|
|
|
+ "xzmj": 1500,
|
|
|
+ "xmmc": "规划选址项目_"+formatted_time,
|
|
|
+ "jsdw": "建设单位",
|
|
|
+ "ydxz_bsm": landType,
|
|
|
+ "ydmjbegin": json_res["area"]["min"],
|
|
|
+ "ydmjend": json_res["area"]["max"],
|
|
|
+ "geomId": geomId,
|
|
|
+ "yxyz": [],
|
|
|
+ # TODO: 循环遍历
|
|
|
+ # "yxyz": [
|
|
|
+ # {
|
|
|
+ # "id": "259e5bbaab434dbfb9c679bd44d4bfa4",
|
|
|
+ # "name": "幼儿园服务半径",
|
|
|
+ # "bsm": "TB_YEY",
|
|
|
+ # "conditionInfo": {
|
|
|
+ # "spatial_type": "distance",
|
|
|
+ # "default": "lt",
|
|
|
+ # "hasValue": true,
|
|
|
+ # "defaultValue": "300",
|
|
|
+ # "unit": "米",
|
|
|
+ # "clip": false
|
|
|
+ # }
|
|
|
+ # }
|
|
|
+ # ],
|
|
|
+ # "useMultiple": json_res["useMultiple"],
|
|
|
+ # "useLandType": json_res["useLandType"],
|
|
|
+ # "multipleDistance": json_res["multipleDistance"]
|
|
|
}
|
|
|
- input_factors[factor_info["id"]] = factor_info
|
|
|
- # 循环遍历模板
|
|
|
- for factorTemplate in factorTemplates:
|
|
|
- factorId = factorTemplate["id"]
|
|
|
- if factorId in input_factors:
|
|
|
- res["yxyz"].append(input_factors[factorId])
|
|
|
- else:
|
|
|
- factorTemplate["conditionInfo"] = json.loads(
|
|
|
- factorTemplate["conditionInfo"])
|
|
|
- res["yxyz"].append(factorTemplate)
|
|
|
- resObj = {}
|
|
|
- resObj["data"] = res
|
|
|
- resObj["code"] = 200
|
|
|
- resObj["type"] = "selectLand"
|
|
|
+ # 循环遍历输入因子
|
|
|
+ factors = json_res["factors"]
|
|
|
+ input_factors = {}
|
|
|
+ for factor in factors:
|
|
|
+ factorInfo = getFactorByName(factor["type"])
|
|
|
+ if factorInfo == None:
|
|
|
+ continue
|
|
|
+ factorId = factorInfo["id"]
|
|
|
+ factorBsm = factorInfo["bsm"]
|
|
|
+ conditionInfo = factorInfo["condition_info"]
|
|
|
+ conditionObj = json.loads(conditionInfo)
|
|
|
+
|
|
|
+ defaultValue ='0'
|
|
|
+ if "value" in factor:
|
|
|
+ defaultValue=str(factor["value"])
|
|
|
+ # if defaultValue == '':
|
|
|
+ # defaultValue = '0'
|
|
|
+
|
|
|
+ factor_info = {
|
|
|
+ "id": factorId,
|
|
|
+ "name": factor["type"],
|
|
|
+ "bsm": factorBsm,
|
|
|
+ "conditionInfo": {
|
|
|
+ "spatial_type": conditionObj["spatial_type"],
|
|
|
+ "default": factor["condition"],
|
|
|
+ "hasValue": conditionObj["hasValue"],
|
|
|
+ "defaultValue": defaultValue,
|
|
|
+ "unit": conditionObj["unit"],
|
|
|
+ "clip": conditionObj["clip"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ input_factors[factor_info["id"]] = factor_info
|
|
|
+ # 循环遍历模板
|
|
|
+ for factorTemplate in factorTemplates:
|
|
|
+ factorId = factorTemplate["id"]
|
|
|
+ if factorId in input_factors:
|
|
|
+ res["yxyz"].append(input_factors[factorId])
|
|
|
+ else:
|
|
|
+ factorTemplate["conditionInfo"] = json.loads(
|
|
|
+ factorTemplate["conditionInfo"])
|
|
|
+ res["yxyz"].append(factorTemplate)
|
|
|
+ resObj = {}
|
|
|
+ resObj["data"] = res
|
|
|
+ resObj["code"] = 200
|
|
|
+ resObj["type"] = "selectLand"
|
|
|
+ else:
|
|
|
+ resObj = {"未找到相关数据"}
|
|
|
+
|
|
|
return resObj
|
|
|
|
|
|
# 获取因子信息
|