Commit 8b22b940 by dong

fix20230303

parent a18af756
......@@ -1206,10 +1206,9 @@ def upload_jc_data():
# 上传的文件
file = request.files['file']
year = request.form['year'] # 年份,如'2022年'
print(file.filename) # 打印文件名
if not year:
return jsonify(code=RET.PARAMERR, msg='数据年份不能为空!')
upload_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# current_year = str(datetime.now().year) + '年'
try:
f = file.read() # 文件内容
......
......@@ -26,13 +26,29 @@ from apps.inves_manage.siku_view import get_num, upload_daily_picture
"""指标分析"""
# 获取项目中的最大月份
def get_max_month():
try:
project_obj_list = ProjectManagement.query.all()
month_list = []
year = datetime.now().year
for project_obj in project_obj_list:
if project_obj.sign_time and str(year) in project_obj.sign_time:
month_list.append(project_obj.sign_time.split('-')[1])
max_month = max(set(month_list)) + 1
return max_month
except Exception as e:
return 'error'
# 项目签约完成率
def get_data1(data_time, district_li, current_year):
data_li1 = []
now_time3 = ''
now_time4 = ''
now_time = datetime.now().strftime('%Y-%m-01 00:00:00')
now_time1 = (datetime.now() - relativedelta(years=1)).strftime('%Y-%m-01 00:00:00')
max_month = get_max_month()
now_time = datetime.now().strftime('%Y-{}-01 00:00:00'.format(max_month))
now_time1 = (datetime.now() - relativedelta(years=1)).strftime('%Y-01-01 00:00:00')
if data_time:
if data_time[0] and data_time[1]:
......@@ -42,6 +58,20 @@ def get_data1(data_time, district_li, current_year):
try:
for district in district_li:
# 先查询最新的年度目标是哪一年的
jc_obj_list = JcTarget.query.filter(
JcTarget.district_name == district if district != '全市' else text(''),
JcTarget.is_delete == 0
).all()
# 获取最大年份
year_li = []
for jc_obj in jc_obj_list:
year = jc_obj.year.split('年')[0]
year_li.append(int(year))
max_year = max(set(year_li))
if not data_time:
project_obj_list = ProjectManagement.query.filter(
ProjectManagement.is_delete == 0,
......@@ -65,10 +95,12 @@ def get_data1(data_time, district_li, current_year):
investment_volume = 0
else:
investment_volume = sum([project_obj.investment_volume for project_obj in project_obj_list])
# 年度目标
jc_obj = JcTarget.query.filter(
JcTarget.district_name == district if district != '全市' else text(''),
JcTarget.year.like('%{}%'.format(str(data_time[0])) if data_time else str(current_year)),
# JcTarget.year.like('%{}%'.format(str(data_time[0])) if data_time else str(current_year)),
JcTarget.year.like('%{}%'.format(str(data_time[0]))) if data_time else text(''),
JcTarget.is_delete == 0
).first()
if not jc_obj:
......@@ -500,17 +532,14 @@ def statistic_jc_data():
data_time = req_dic['data_time'] # ["2022", "01", "12"]
current_year = datetime.now().year
# current_year = 2022
district_li = ["全市", "城区", "泽州县", "高平市", "阳城县", "陵川县",
"沁水县", "晋城经济技术开发区"]
try:
# data_li1, data_li2, data_li3, data_li4, data_li5 = get_data_li(district_li, current_year, data_time)
data_li1, data_li2, data_li3, data_li4, data_li5 = get_data_li(data_time, district_li, current_year)
# 六。综合得分
data_li6 = get_data6(district_li, data_li1, data_li2, data_li3, data_li4, data_li5)
if not data_time:
# now_time = datetime.now().strftime('%Y-%m-01 00:00:00')
now_time = (datetime.now() - relativedelta(years=1)).strftime('%Y-%m-%d')
now_time = now_time.split('-')
data_time1 = now_time[0] + '年' + now_time[1] + '月' + now_time[2] + '号-至今'
......
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