Commit a24451db by dong

fix20221127

parent 353e4091
......@@ -76,11 +76,11 @@ def search_project1():
ProjectManagement.project_name == project_name if project_name else text(''),
ProjectManagement.district == district if district else text(''),
ProjectManagement.development_area == development_area if development_area else text(''),
ProjectManagement.investor_name >= investor_name[0] if investor_name else text(''),
ProjectManagement.investor_name < investor_name[1] if investor_name else text(''),
ProjectManagement.investment_volume >= investment_volume[0] if investment_volume else text(''),
ProjectManagement.investment_volume < investment_volume[1] if investment_volume else text(''),
ProjectManagement.investor_district.like('%{}%'.format(investor_district)) if investor_district else text(''),
ProjectManagement.industry == industry if industry else text(''),
ProjectManagement.investment_volume == investment_volume if investment_volume else text(''),
ProjectManagement.investor_name == investor_name if investor_name else text(''),
ProjectManagement.project_progress == project_progress if project_progress else text(''),
ProjectManagement.project_year == project_year if project_year else text(''),
ProjectManagement.is_delete == 0
......@@ -201,6 +201,22 @@ def download_project_template():
return jsonify(code=RET.OK, data=project_template, msg="模板下载成功!")
def get_industry_level(industry1, industry2):
# 判断项目产业
industry_level = ''
if industry1 and industry1 == '现代农业':
industry_level = '第一产业'
if industry1 and industry1 == '文化旅游产业':
industry_level = '第三产业'
if industry2 and industry2 in ["商贸物流", "商务服务业", "房地产", "康养", "其他"]:
industry_level = '第三产业'
if industry2 and industry2 in ["煤炭先进产能和安全改造", "电力", "焦化", "冶金", "食品", "纺织",
"轻工", "其他工业技术改造", "节能环保产业", "煤层气产业", "煤化工产业", "新一代信息技术产业",
"高端装备制造业", "新材料产业", "新能源产业", "新能源汽车产业", "生物产业"]:
industry_level = '第二产业'
return industry_level
# 批量导入
@api_manage.route("/UploadProjectData2", methods=["POST"])
def upload_project_data2():
......@@ -282,7 +298,9 @@ def upload_project_data2():
if not project_name:
return jsonify(code=RET.PARAMERR, msg='项目名称不能为空!')
project_obj_list = ProjectManagement.query.all() # 项目编号
project_obj_list = ProjectManagement.query.all()
# 构造项目编号
time_strf = datetime.now().strftime("%Y%m%d")
max_project_num = ''
if project_obj_list:
......@@ -296,6 +314,12 @@ def upload_project_data2():
project_num = time_strf + num
else:
project_num = time_strf + '001'
if industry1 and industry2:
industry_level = get_industry_level(industry1, industry2)
if industry1 and not industry2:
industry_level = get_industry_level(industry1, '')
try:
# 写入数据库
file_time = datetime.now().strftime("%Y-%m-%d %H:%M")
......@@ -312,7 +336,8 @@ def upload_project_data2():
investor_district=provence + "/" + city,
industry=industry1,
industry2=industry2,
investment_volume=country + provence + city,
industry_level=industry_level,
investment_volume=investment_volume,
construction_content=construction_content,
construction_nature=construction_nature,
project_address=project_address,
......@@ -563,6 +588,16 @@ def project_edit():
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.SESSIONERR, msg="进行编辑项目信息操作时用户信息校验失败,请重新登陆后尝试!")
if '-' in industry:
industry = industry.spilt('-')
industry1 = industry[0]
industry2 = industry[1]
else:
industry1 = industry
industry2 = ''
industry_level = get_industry_level(industry1, industry2)
try:
project_obj = ProjectManagement.query.filter_by(id=project_id, is_delete=0).first()
if not project_obj:
......@@ -573,7 +608,9 @@ def project_edit():
project_obj.development_area = development_area
project_obj.attract_name = attract_name
project_obj.investor_name = investor_name
project_obj.industry = industry
project_obj.industry = industry1
project_obj.industry2 = industry2
project_obj.industry_level = industry_level
project_obj.investment_volume = investment_volume
project_obj.construction_content = construction_content
project_obj.project_address = project_address
......
......@@ -42,17 +42,17 @@ def statistic_shanxi_data():
if flag == 1:
data = [{
"district_name": target_obj.district_name,
"sign_money": str(target_obj.sign_money) + '亿',
"sign_target_money": str(target_obj.sign_target_money) + '亿',
"sign_finish_rate": str(target_obj.sign_finish_rate) + '%',
"sign_money": str(target_obj.sign_money / 10000) + '亿',
"sign_target_money": str(target_obj.sign_target_money / 10000) + '亿',
"sign_finish_rate": str(target_obj.sign_finish_rate / 10000) + '%',
} for target_obj in target_obj_li]
data1 = sorted(data, key=lambda x: x['sign_money'], reverse=True)
data2 = sorted(data1, key=lambda x: x['sign_finish_rate'], reverse=True)
if flag == 2:
data = [{
"district_name": target_obj.district_name,
"plan_invest_money": str(target_obj.plan_invest_money) + '亿',
"plan_target_money": str(target_obj.plan_target_money) + '亿',
"plan_invest_money": str(target_obj.plan_invest_money / 10000) + '亿',
"plan_target_money": str(target_obj.plan_target_money / 10000) + '亿',
"plan_finish_rate": str(target_obj.plan_finish_rate) + '%',
} for target_obj in target_obj_li]
data1 = sorted(data, key=lambda x: x['plan_invest_money'], reverse=True)
......@@ -60,8 +60,8 @@ def statistic_shanxi_data():
if flag == 3:
data = [{
"district_name": target_obj.district_name,
"arrive_money": str(target_obj.arrive_money) + '亿',
"arrive_target_money": str(target_obj.arrive_target_money) + '亿',
"arrive_money": str(target_obj.arrive_money / 10000) + '亿',
"arrive_target_money": str(target_obj.arrive_target_money / 10000) + '亿',
"arrive_finish_rate": str(target_obj.arrive_finish_rate) + '%',
} for target_obj in target_obj_li]
data1 = sorted(data, key=lambda x: x['arrive_money'], reverse=True)
......@@ -89,8 +89,6 @@ def statistic_jc_data():
data_li4 = []
data_li5 = []
data_li6 = []
try:
# 一。项目签约完成率(签约项目完成率:完成率(%):签约金额(亿元)/ 年度目标(亿元))
for district in district_li:
......@@ -256,14 +254,6 @@ def statistic_jc_data():
}
data_li5.append(data)
continue
# return jsonify(code=RET.OK, data=data_li, msg="固定资产投资项目到位资金完成率获取成功")
# 综合得分
# 项目签约情况得分
# 得分(满分15分):完成率( % )*赋分(15
# 上传后获取)如果小于赋分(15
# 上传后获取),则输出完成率( % )*赋分(15
# 上传后获取)的结果,否则输出赋分(15)
pass
# 非固定资产投资项目资金到位情况得分=如果完成率(%)小于1,
# 则输出完成率(%)*赋分(5 上传后获取)的结果,否则输出赋分(5);
grade_li5 = []
......@@ -312,9 +302,9 @@ def statistic_jc_data():
"""项目分析"""
# 项目来源区域分布饼状图
@api_manage.route("/ArealDistribution", methods=["POST"])
def areal_distribution():
# 项目分析四个图表
@api_manage.route("/ProjectGraph", methods=["POST"])
def project_graph():
req_dic = request.get_json()
district = req_dic['district']
flag = req_dic['flag']
......@@ -354,26 +344,26 @@ def areal_distribution():
if flag == 2:
project_count1 = project_obj.filter(
ProjectManagement.investment_volume > 0,
ProjectManagement.investment_volume <= 0.5
ProjectManagement.investment_volume <= 0.5 * 10000
).count()
project_count2 = project_obj.filter(
ProjectManagement.investment_volume > 0.5,
ProjectManagement.investment_volume <= 1
ProjectManagement.investment_volume > 0.5 * 10000,
ProjectManagement.investment_volume <= 1 * 10000
).count()
project_count3 = project_obj.filter(
ProjectManagement.investment_volume > 1,
ProjectManagement.investment_volume <= 5
ProjectManagement.investment_volume > 1 * 10000,
ProjectManagement.investment_volume <= 5 * 10000
).count()
project_count4 = project_obj.filter(
ProjectManagement.investment_volume > 5,
ProjectManagement.investment_volume <= 10
ProjectManagement.investment_volume > 5 * 10000,
ProjectManagement.investment_volume <= 10 * 10000
).count()
project_count5 = project_obj.filter(
ProjectManagement.investment_volume > 10,
ProjectManagement.investment_volume <= 20
ProjectManagement.investment_volume > 10 * 10000,
ProjectManagement.investment_volume <= 20 * 10000
).count()
project_count6 = project_obj.filter(
ProjectManagement.investment_volume > 20,
ProjectManagement.investment_volume > 20 * 10000,
).count()
data = {
"project_count1": project_count1,
......@@ -385,17 +375,13 @@ def areal_distribution():
}
if flag == 3: # 项目产业分布
# 第一产业
project_count1 = project_obj.filter(ProjectManagement.industry == '现代农业').count()
project_count1 = project_obj.filter(ProjectManagement.industry_level == '第一产业').count()
# 第二产业
project_count2 = project_obj.filter(
ProjectManagement.industry2.in_(["煤炭先进产能和安全改造", "电力", "焦化", "冶金", "食品", "纺织",
"轻工", "其他工业技术改造", "节能环保产业", "煤层气产业", "煤化工产业", "新一代信息技术产业",
"高端装备制造业", "新材料产业", "新能源产业", "新能源汽车产业", "生物产业"])).count()
ProjectManagement.industry_level == '第二产业').count()
# 第三产业
project_count3 = project_obj.filter(
ProjectManagement.industry2.in_(["商贸物流", "商务服务业", "房地产", "康养", "其他"]),
ProjectManagement.industry.in_(["文化旅游产业"])
).count()
ProjectManagement.industry_level == '第三产业').count()
total_num = project_count1 + project_count2 + project_count3
data = {
"project_count1": str(round(project_count1 / total_num, 2)) + '%',
......@@ -423,99 +409,123 @@ def areal_distribution():
return jsonify(code=RET.DBERR, msg="数据查询错误!")
# 项目来源区域分布项目列表
# 各类型项目列表
@api_manage.route("/ArealProject", methods=["POST"])
def areal_project():
req_dic = request.get_json()
district = req_dic['district']
project_source = req_dic['project_source']
investment_volume = req_dic['investment_volume']
industry_level = req_dic['industry_level']
industry_name = req_dic['industry_name']
flag = req_dic['flag']
page = req_dic['page']
per_page = req_dic['per_page']
current_year = datetime.now().year
try:
project_obj = ProjectManagement.query.filter(
ProjectManagement.district == district if district else text(''),
ProjectManagement.sign_time.like('%{}%'.format(str(current_year)))
)
if project_source == '京津冀':
project_obj = project_obj.filter(or_(
ProjectManagement.province.like('%北京%'),
ProjectManagement.province.like('%天津%'),
ProjectManagement.province.like('%河北%')
))
elif project_source == '长三角':
project_obj = project_obj.filter(or_(
ProjectManagement.province.like('%江苏%'),
ProjectManagement.province.like('%浙江%'),
ProjectManagement.province.like('%上海%')
))
elif project_source == '珠三角':
project_obj = project_obj.filter(or_(
ProjectManagement.province.like('%广东%'),
ProjectManagement.province.like('%香港%'),
ProjectManagement.province.like('%澳门%')
))
elif project_source == '中原经济区':
project_obj = project_obj.filter(or_(
ProjectManagement.province.like('%河南%'),
ProjectManagement.province.like('%天津%'),
ProjectManagement.province.like('%河北%'),
ProjectManagement.province.like('%长治%'),
ProjectManagement.province.like('%晋城%'),
ProjectManagement.province.like('%运城%'),
ProjectManagement.province.like('%聊城%'),
ProjectManagement.province.like('%菏泽%'),
ProjectManagement.province.like('%泰安%'),
ProjectManagement.province.like('%宿州%'),
ProjectManagement.province.like('%淮北%'),
ProjectManagement.province.like('%阜阳%'),
ProjectManagement.province.like('%亳州%'),
ProjectManagement.province.like('%蚌埠%'),
ProjectManagement.province.like('%淮南%'),
ProjectManagement.province.like('%邢台%'),
ProjectManagement.province.like('%邯郸%'),
))
elif project_source == '其他':
project_obj = project_obj.filter(and_(
ProjectManagement.province.notlike('%河南%'),
ProjectManagement.province.notlike('%天津%'),
ProjectManagement.province.notlike('%河北%'),
ProjectManagement.province.notlike('%长治%'),
ProjectManagement.province.notlike('%晋城%'),
ProjectManagement.province.notlike('%运城%'),
ProjectManagement.province.notlike('%聊城%'),
ProjectManagement.province.notlike('%菏泽%'),
ProjectManagement.province.notlike('%泰安%'),
ProjectManagement.province.notlike('%宿州%'),
ProjectManagement.province.notlike('%淮北%'),
ProjectManagement.province.notlike('%阜阳%'),
ProjectManagement.province.notlike('%亳州%'),
ProjectManagement.province.notlike('%蚌埠%'),
ProjectManagement.province.notlike('%淮南%'),
ProjectManagement.province.notlike('%邢台%'),
ProjectManagement.province.notlike('%邯郸%'),
ProjectManagement.province.notlike('%北京%'),
ProjectManagement.province.notlike('%天津%'),
ProjectManagement.province.notlike('%河北%'),
ProjectManagement.province.notlike('%江苏%'),
ProjectManagement.province.notlike('%浙江%'),
ProjectManagement.province.notlike('%上海%'),
ProjectManagement.province.notlike('%广东%'),
ProjectManagement.province.notlike('%香港%'),
ProjectManagement.province.notlike('%澳门%')
))
else:
return jsonify(code=RET.PARAMERR, msg="参数错误!")
if flag == 1: # 项目来源区域分布项目列表
if project_source == '京津冀':
project_obj = project_obj.filter(or_(
ProjectManagement.province.like('%北京%'),
ProjectManagement.province.like('%天津%'),
ProjectManagement.province.like('%河北%')
))
elif project_source == '长三角':
project_obj = project_obj.filter(or_(
ProjectManagement.province.like('%江苏%'),
ProjectManagement.province.like('%浙江%'),
ProjectManagement.province.like('%上海%')
))
elif project_source == '珠三角':
project_obj = project_obj.filter(or_(
ProjectManagement.province.like('%广东%'),
ProjectManagement.province.like('%香港%'),
ProjectManagement.province.like('%澳门%')
))
elif project_source == '中原经济区':
project_obj = project_obj.filter(or_(
ProjectManagement.province.like('%河南%'),
ProjectManagement.province.like('%天津%'),
ProjectManagement.province.like('%河北%'),
ProjectManagement.province.like('%长治%'),
ProjectManagement.province.like('%晋城%'),
ProjectManagement.province.like('%运城%'),
ProjectManagement.province.like('%聊城%'),
ProjectManagement.province.like('%菏泽%'),
ProjectManagement.province.like('%泰安%'),
ProjectManagement.province.like('%宿州%'),
ProjectManagement.province.like('%淮北%'),
ProjectManagement.province.like('%阜阳%'),
ProjectManagement.province.like('%亳州%'),
ProjectManagement.province.like('%蚌埠%'),
ProjectManagement.province.like('%淮南%'),
ProjectManagement.province.like('%邢台%'),
ProjectManagement.province.like('%邯郸%'),
))
elif project_source == '其他':
project_obj = project_obj.filter(and_(
ProjectManagement.province.notlike('%河南%'),
ProjectManagement.province.notlike('%天津%'),
ProjectManagement.province.notlike('%河北%'),
ProjectManagement.province.notlike('%长治%'),
ProjectManagement.province.notlike('%晋城%'),
ProjectManagement.province.notlike('%运城%'),
ProjectManagement.province.notlike('%聊城%'),
ProjectManagement.province.notlike('%菏泽%'),
ProjectManagement.province.notlike('%泰安%'),
ProjectManagement.province.notlike('%宿州%'),
ProjectManagement.province.notlike('%淮北%'),
ProjectManagement.province.notlike('%阜阳%'),
ProjectManagement.province.notlike('%亳州%'),
ProjectManagement.province.notlike('%蚌埠%'),
ProjectManagement.province.notlike('%淮南%'),
ProjectManagement.province.notlike('%邢台%'),
ProjectManagement.province.notlike('%邯郸%'),
ProjectManagement.province.notlike('%北京%'),
ProjectManagement.province.notlike('%天津%'),
ProjectManagement.province.notlike('%河北%'),
ProjectManagement.province.notlike('%江苏%'),
ProjectManagement.province.notlike('%浙江%'),
ProjectManagement.province.notlike('%上海%'),
ProjectManagement.province.notlike('%广东%'),
ProjectManagement.province.notlike('%香港%'),
ProjectManagement.province.notlike('%澳门%')
))
else:
return jsonify(code=RET.PARAMERR, msg="参数错误!")
if flag == 2: # 项目投资额区间分布项目列表
project_obj = project_obj.filter(
ProjectManagement.investment_volume > investment_volume[0] if investment_volume[0] else text(''),
ProjectManagement.investment_volume <= investment_volume[1] if investment_volume[1] else text(''))
if flag == 3: # 项目产业分布项目列表
project_obj = project_obj.filter(ProjectManagement.industry_level == industry_level)
if flag == 4: # 项目行业类型分布项目列表
project_obj = project_obj.filter(ProjectManagement.industry == industry_name)
if not project_obj.all():
return jsonify(code=RET.NODATA, msg='没有符合条件的数据!')
project_size = project_obj.count()
project_obj_list = project_obj.order_by(ProjectManagement.upload_time.desc()).paginate(page, per_page).items
data = [{
"project_name": project_obj.project_name, # 项目名称
"investor_district": project_obj.investor_district, # 投资方所在地
"project_type": "", # 项目类型
"industry": project_obj.industry, # 所属行业
"investment_volume": project_obj.investment_volume, # 总投资额(万元)
"id": project_obj.id,
"project_name": project_obj.project_name,
"investor_district": project_obj.investor_district,
"industry": project_obj.industry + '-' + project_obj.industry2,
"project_type": "",
"investment_volume": project_obj.investment_volume
} for project_obj in project_obj_list]
return jsonify(code=RET.OK,
data={"data": data,
......@@ -524,5 +534,3 @@ def areal_project():
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="数据查询错误!")
......@@ -24,35 +24,6 @@ from apps.inves_manage.siku_view import get_num, upload_daily_picture
"""项目总览"""
# @api_manage.route("/Overview", methods=["GET"])
# def overview():
# try:
# project_obj_count1 = 0
# project_obj_count2 = 0
# project_obj_count3 = 0
# project_obj_list = ProjectManagement.query.all()
# for project_obj in project_obj_list:
# if project_obj.sign_time:
# project_obj_count1 += 1
# if project_obj.start_time:
# project_obj_count2 += 1
# if project_obj.end_time:
# project_obj_count3 += 1
# data = {
# "project_obj_count1": project_obj_count1,
# "project_obj_count2": project_obj_count2,
# "project_obj_count3": project_obj_count3,
# }
# print('签约时间:{},开工时间:{},竣工时间:{},'.format(
# project_obj_count1,
# project_obj_count2,
# project_obj_count3))
# return jsonify(code=RET.OK, data=data, msg="查询成功!")
# except Exception as e:
# current_app.logger.error(e)
# return jsonify(code=RET.DBERR, msg="查询出错!")
@api_manage.route("/ProjectStalker", methods=["POST"]) # 项目跟踪
def project_stalker():
req_dic = request.get_json()
......@@ -138,56 +109,3 @@ def project_map():
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="操作失败!数据库查询错误")
# 获取项目列表
# @api_manage.route("/SearchProject2", methods=["POST"])
# def search_project2():
# req_dic = request.get_json()
# token = request.headers['token']
# project_stalker = req_dic['project_stalker']
# district = req_dic['district']
# page = req_dic['page']
# per_page = req_dic['per_page']
#
# try:
# user_obj = verify_token(token)
# except Exception as e:
# current_app.logger.error(e)
# return jsonify(code=RET.SESSIONERR, msg="进行操作时用户信息校验失败,请重新登陆后尝试!")
#
# try:
# project_obj = ProjectManagement.query.filter(
# and_(ProjectManagement.project_stalker == project_stalker if project_stalker else text(''),
# ProjectManagement.district == district if district else text(''),
# ))
#
# if not project_obj.all():
# return jsonify(code=RET.NODATA, msg='没有符合条件的数据!')
# project_size = project_obj.count()
#
# project_obj_list = project_obj.order_by(ProjectManagement.upload_time.desc()).paginate(page, per_page).items
# if project_obj_list:
# data = [{
# "id": project_obj.id,
# "project_stalker": project_obj.project_stalker,
# "project_name": project_obj.project_name,
# "district": project_obj.district,
# "development_area": project_obj.development_area,
# "attract_name": project_obj.attract_name,
# "investor_name": project_obj.investor_name,
# "investor_district": project_obj.investor_district,
# "industry": project_obj.industry,
# "investment_volume": project_obj.investment_volume,
# "construction_content": project_obj.construction_content,
# "project_address": project_obj.project_address,
# "project_progress": project_obj.project_progress,
# "project_problem": project_obj.project_problem,
# "project_year": project_obj.project_year
# } for project_obj in project_obj_list]
# return jsonify(code=RET.OK, data={"data": data, "size": project_size, "msg": "数据获取成功!"})
#
# except Exception as e:
# current_app.logger.error(e)
# return jsonify(code=RET.DBERR, msg="查询数据库错误!")
......@@ -1183,6 +1183,7 @@ class ProjectManagement(db.Model):
investor_district = db.Column(db.String(30), comment='投资方所在地')
industry = db.Column(db.String(20), comment='所属行业-一级产业')
industry2 = db.Column(db.String(20), comment='所属行业-二级产业')
industry_level = db.Column(db.String(20), comment='所属项目产业级别')
investment_volume = db.Column(db.Float, comment='总投资额(万元)')
construction_content = db.Column(db.String(30), comment='建设内容')
project_address = db.Column(db.String(20), comment='项目选址')
......
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