|
|
@@ -672,16 +672,19 @@ def pest_statistics_char_new(request):
|
|
|
else:
|
|
|
for result in indentify_result.split("#"):
|
|
|
tuple_result = result.split(",")
|
|
|
- pest_name = insect_dict.get(tuple_result[0],"未命名")
|
|
|
- pest_num = int(tuple_result[1])
|
|
|
- if pest_name in pest_day_info:
|
|
|
- pest_day_info[pest_name]["sum"] += pest_num
|
|
|
- else:
|
|
|
- pest_day_info[pest_name] = {"addtime":date_stamp,"sum":pest_num}
|
|
|
- if pest_name in pest_info_total:
|
|
|
- pest_info_total[pest_name] += pest_num
|
|
|
- else:
|
|
|
- pest_info_total[pest_name] = pest_num
|
|
|
+ try:
|
|
|
+ pest_name = insect_dict.get(tuple_result[0],"未命名")
|
|
|
+ pest_num = int(tuple_result[1])
|
|
|
+ if pest_name in pest_day_info:
|
|
|
+ pest_day_info[pest_name]["sum"] += pest_num
|
|
|
+ else:
|
|
|
+ pest_day_info[pest_name] = {"addtime":date_stamp,"sum":pest_num}
|
|
|
+ if pest_name in pest_info_total:
|
|
|
+ pest_info_total[pest_name] += pest_num
|
|
|
+ else:
|
|
|
+ pest_info_total[pest_name] = pest_num
|
|
|
+ except Exception as e:
|
|
|
+ logger.error(f'虫情分析error {e}')
|
|
|
# 最后一天的数据统计,循环内加不了
|
|
|
for pest_day_key,pest_day_value in pest_day_info.items():
|
|
|
if pest_day_key in chart_info:
|
|
|
@@ -797,12 +800,15 @@ def pest_image_source(request):
|
|
|
pest_dict[pest_name] = 1
|
|
|
else:
|
|
|
for index,result in enumerate(indentify_result.split("#")) :
|
|
|
- if index != 0:
|
|
|
- pest_string += "、"
|
|
|
- tuple_result = result.split(",")
|
|
|
- pest_name = insect_dict.get(tuple_result[0],"未命名")
|
|
|
- pest_string+=pest_name
|
|
|
- pest_dict[pest_name] = int(tuple_result[1])
|
|
|
+ try:
|
|
|
+ if index != 0:
|
|
|
+ pest_string += "、"
|
|
|
+ tuple_result = result.split(",")
|
|
|
+ pest_name = insect_dict.get(tuple_result[0],"未命名")
|
|
|
+ pest_string+=pest_name
|
|
|
+ pest_dict[pest_name] = int(tuple_result[1])
|
|
|
+ except Exception as e:
|
|
|
+ logger.error(e)
|
|
|
if select_name and select_name not in pest_string:
|
|
|
continue
|
|
|
addtime = photo_object.addtime
|