Commit e48c51a1 by dong

fix20230317

parent fd45fd1b
...@@ -296,6 +296,8 @@ def upload_project_data2(): ...@@ -296,6 +296,8 @@ def upload_project_data2():
return jsonify(code=RET.NODATA, return jsonify(code=RET.NODATA,
msg="表格内无有效数据!请尝试 <清空浏览器缓存> 后下载最新模板,根据模板提示信息编辑数据后再次上传。(注:第三行为首行有效数据不能为空、第一行和第二行无法读取。)") msg="表格内无有效数据!请尝试 <清空浏览器缓存> 后下载最新模板,根据模板提示信息编辑数据后再次上传。(注:第三行为首行有效数据不能为空、第一行和第二行无法读取。)")
project_name = row_content[1] # 项目名称 project_name = row_content[1] # 项目名称
if project_name == '年产100万立方商砼项目':
print(project_name)
# 判断该项目是否已经存在 # 判断该项目是否已经存在
project_obj = ProjectManagement.query.filter_by(project_name=project_name, is_delete=0).first() project_obj = ProjectManagement.query.filter_by(project_name=project_name, is_delete=0).first()
if project_obj: if project_obj:
...@@ -325,19 +327,22 @@ def upload_project_data2(): ...@@ -325,19 +327,22 @@ def upload_project_data2():
set_project_status = row_content[17] # 项目立项状态 set_project_status = row_content[17] # 项目立项状态
project_progress = row_content[18] # 项目进展 project_progress = row_content[18] # 项目进展
sign_time = row_content[19] # 签约时间 sign_time = row_content[19] # 签约时间
y, m, d, h, i, s = xlrd.xldate_as_tuple(sign_time, data.datemode)
sign_time = "{0}-{1}-{2}".format(y, m, d)
project_year = '' project_year = ''
if sign_time: if sign_time:
y, m, d, h, i, s = xlrd.xldate_as_tuple(sign_time, data.datemode)
sign_time = "{0}-{1}-{2}".format(y, m, d)
# if sign_time:
project_year = int(sign_time.split('-')[0]) project_year = int(sign_time.split('-')[0])
start_time = row_content[20] # 开工时间 start_time = row_content[20] # 开工时间
y, m, d, h, i, s = xlrd.xldate_as_tuple(start_time, data.datemode) if start_time:
start_time = "{0}-{1}-{2}".format(y, m, d) y, m, d, h, i, s = xlrd.xldate_as_tuple(start_time, data.datemode)
start_time = "{0}-{1}-{2}".format(y, m, d)
end_time = row_content[21] # 竣工时间 end_time = row_content[21] # 竣工时间
y, m, d, h, i, s = xlrd.xldate_as_tuple(end_time, data.datemode) if end_time:
end_time = "{0}-{1}-{2}".format(y, m, d) y, m, d, h, i, s = xlrd.xldate_as_tuple(end_time, data.datemode)
end_time = "{0}-{1}-{2}".format(y, m, d)
is_fixed_investment = row_content[22] # 固定资产投资项目 is_fixed_investment = row_content[22] # 固定资产投资项目
investment_year = row_content[23] # 资金到位本年累计(万元) investment_year = row_content[23] # 资金到位本年累计(万元)
...@@ -353,8 +358,9 @@ def upload_project_data2(): ...@@ -353,8 +358,9 @@ def upload_project_data2():
investor_district = city investor_district = city
except Exception as e: except Exception as e:
# 表示操作失败,回滚数据库操作 # 表示操作失败,回滚数据库操作
data = '第{}行'.format(i) + project_name
current_app.logger.error(e) current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="数据异常!请尝试 <清空浏览器缓存> 后下载最新模板,根据模板提示信息编辑数据后再次上传。") return jsonify(code=RET.DBERR, msg=data)
if not project_name: if not project_name:
return jsonify(code=RET.PARAMERR, msg='项目名称不能为空!') return jsonify(code=RET.PARAMERR, msg='项目名称不能为空!')
......
...@@ -263,7 +263,6 @@ def find_zero(): ...@@ -263,7 +263,6 @@ def find_zero():
get_data = request.get_json() get_data = request.get_json()
name = get_data.get('company_name') name = get_data.get('company_name')
result = { result = {
"nodes": [ "nodes": [
{"data": {"category": "1", "real_name": name}, "id": "a", "name": "{}↓".format(name), "category": "1"}], {"data": {"category": "1", "real_name": name}, "id": "a", "name": "{}↓".format(name), "category": "1"}],
"links": [], "links": [],
......
...@@ -402,7 +402,8 @@ def attract_enterprise(): ...@@ -402,7 +402,8 @@ def attract_enterprise():
page = req_dict.get("page") # 分页页码 page = req_dict.get("page") # 分页页码
perpage = req_dict.get("perpage") # 分页大小 perpage = req_dict.get("perpage") # 分页大小
name_query = "AttractEnterprise" + str(inid) + str(page) + province + city + district + product name_query = "AttractEnterprise" + str(inid) + str(page) + province + city + district + \
product + company_name + entype + qualificat + quoted + product + area
if redis_store.get(name_query) is not None: if redis_store.get(name_query) is not None:
data = json.loads(redis_store.get(name_query)) data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
......
...@@ -427,7 +427,7 @@ def recommond(): ...@@ -427,7 +427,7 @@ def recommond():
page = req_dict.get("page") page = req_dict.get("page")
perpage = req_dict.get("perpage") perpage = req_dict.get("perpage")
name_query = "GetLinkEnterprise" + name name_query = "GetLinkEnterprise" + name + str(page)
if redis_store.get(name_query) is not None: if redis_store.get(name_query) is not None:
data = json.loads(redis_store.get(name_query)) data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
...@@ -477,6 +477,7 @@ def recommond(): ...@@ -477,6 +477,7 @@ def recommond():
# redis缓存 # redis缓存
redis_store.setex(name_query, 30 * 24 * 3600, json.dumps(data)) redis_store.setex(name_query, 30 * 24 * 3600, json.dumps(data))
# redis_store.hset('GetLinkEnterprise:{}'.format(name_query), 'GetLinkEnterprise', {'data':data})
return jsonify(code=RET.OK, msg="查询成功", data=data) return jsonify(code=RET.OK, msg="查询成功", data=data)
except Exception as e: except Exception as e:
...@@ -484,6 +485,20 @@ def recommond(): ...@@ -484,6 +485,20 @@ def recommond():
return jsonify(code=RET.DBERR, msg="数据库查询错误") return jsonify(code=RET.DBERR, msg="数据库查询错误")
@api_radar.route('/SaveRedis', methods=['GET'])
# @login_required
def save_redis():
'''雷达监测页企业数量统计'''
name_query = 'value_name_aaa'
if redis_store.hget('GetLinkEnterprise:{}'.format(name_query), name_query) is not None:
data = json.loads(redis_store.hget('GetLinkEnterprise:{}'.format(name_query), name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data)
data = 'aaa'
# redis缓存
redis_store.hset('GetLinkEnterprise:{}'.format(name_query), name_query, data)
return jsonify(code=RET.OK, msg="查询成功", data=data)
# 优质企业-各资质企业数量 # 优质企业-各资质企业数量
@api_radar.route('/GoodEnterpriseNum', methods=['POST']) @api_radar.route('/GoodEnterpriseNum', methods=['POST'])
# @login_required # @login_required
......
...@@ -18,6 +18,7 @@ def handle(): ...@@ -18,6 +18,7 @@ def handle():
# 读取industry_chain数据表的产业名称 # 读取industry_chain数据表的产业名称
for industry_obj in industry_obj_list: for industry_obj in industry_obj_list:
industry_name = industry_obj.industry_name industry_name = industry_obj.industry_name
indu_id = industry_obj.id
chain_id = industry_obj.chain_id chain_id = industry_obj.chain_id
# 读取全国企业表,模糊匹配product_all字段 # 读取全国企业表,模糊匹配product_all字段
if industry_name in ["钢铁", "光机电", "煤层气", "装备制造", "铸造", if industry_name in ["钢铁", "光机电", "煤层气", "装备制造", "铸造",
...@@ -26,25 +27,28 @@ def handle(): ...@@ -26,25 +27,28 @@ def handle():
continue continue
else: else:
print("正在查询【{}】的相关企业......".format(industry_name)) indu_obj_li = IndustryChain.query.filter(relate_id=indu_id).all()
enterprise_num1 = Enterprise.query.filter( for indu_obj in indu_obj_li:
Enterprise.c_type == chain_id, indu_name = indu_obj.industry_name
Enterprise.product_all.like("%{}%".format(industry_name)) print("正在查询【{}】的相关企业......".format(indu_name))
).count() enterprise_num1 = Enterprise.query.filter(
Enterprise.c_type == chain_id,
enterprise_num2 = Enterprise.query.filter( Enterprise.product_all.like("%{}%".format(industry_name))
Enterprise.c_type1 == chain_id, ).count()
Enterprise.product_all1.like("%{}%".format(industry_name))
).count() enterprise_num2 = Enterprise.query.filter(
Enterprise.c_type1 == chain_id,
enterprise_num3 = Enterprise.query.filter( Enterprise.product_all1.like("%{}%".format(industry_name))
Enterprise.c_type2 == chain_id, ).count()
Enterprise.product_all2.like("%{}%".format(industry_name))
).count() enterprise_num3 = Enterprise.query.filter(
enterprise_num = enterprise_num1 + enterprise_num2 + enterprise_num3 Enterprise.c_type2 == chain_id,
industry_obj.enterprise_num = enterprise_num Enterprise.product_all2.like("%{}%".format(industry_name))
db.session.commit() ).count()
print("产品【{}】已完成, 共有{}家相关企业。".format(industry_name, enterprise_num)) enterprise_num = enterprise_num1 + enterprise_num2 + enterprise_num3
industry_obj.enterprise_num = enterprise_num
db.session.commit()
print("产品【{}】已完成, 共有{}家相关企业。".format(industry_name, enterprise_num))
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment