毕业设计:python农业数据分析可视化系统 农作物产量数据分析 (包含文档+源码+部署教程)建议收藏!
毕业设计:python农业数据分析可视化系统 农作物产量数据分析 (包含文档+源码+部署教程)建议收藏!
[毕业设计]2023-2024年最新最全计算机专业毕设选题推荐汇总
2023年 - 2024年 最新计算机毕业设计 本科 选题大全 汇总
1、项目介绍
农业数据 农业数据分析可视化大屏 农业产量数据分析
Python语言、Flask框架、MySQL数据库 机器学习预测算法
后端:Python、Flask框架、数据库连接-pymysql、数据库是mysql
前端:html+css+js echarts、layui后台页面框架
2、项目界面
(1)数据可视化大屏
(2)产量预测分析
(3)气象数据管理
(4)产量数据管理
(5)后台管理首页
(6)注册登录界面
3、项目说明
本文描述了一种基于 Flask 的农业数据分析与可视化系统,旨在帮助农民和相关从业者更好地预测农作物产量,以优化农业生产。该系统主要包括四个功能模块。首先,农作物数据可视化模块利用 Python语言、Echarts、Ajax、Flask、PyMysql技术实现了可视化展示农作物产量相关数据的功能。其次,产量预测模块使用 pandas、numpy 等技术,通过对气象和农作物产量关系数据集的分析和训练,实现了对农作物产量的预测功能。该模块可以对当前或未来某一时间段的农作物产量进行预测,并提供预测结果的可视化展示。 用户登录与用户注册模块使用 layui、Flask、PyMysql 技术实现了用户登录和注册功能。用户可以通过登录系统后,利用该系统提供的预测和可视化功能,更好地规划和管理自己的农业生产。最后,数据管理模块使用 layui、Flask、PyMysql 技术,实现了用户管理、公告管理和农作物数据管理等功能。系统管理员可以通过后台界面对用户信息、公告信息和农作物数据进行管理和维护,保证系统的正常运行和信息安全。本系统的实现对农业生产的优化具有积极的意义。 通过对气象和农作物产量关系数据的分析和训练,该系统可以帮助用户更好地了解不同作物产量随时间变化的趋势和规律,提高农作物的产量和品质,促进农业生产的可持续发展。
4、核心代码
import datetime
from flask import Flask as _Flask, flash, redirect
from flask import request, session
from flask import render_template
from flask.json import JSONEncoder as _JSONEncoder, jsonify
import decimal
import os
from service import user_service, notice_service, data_service, output_service, weather_service, predict_service
from utils.JsonUtils import read_json
from utils.Result import Result
base = os.path.dirname(__file__)
directory_path = os.path.dirname(__file__)
json_path = directory_path + '/static/api/'
class JSONEncoder(_JSONEncoder):
def default(self, o):
if isinstance(o, decimal.Decimal):
return float(o)
if isinstance(o, datetime.datetime):
return o.strftime("%Y-%m-%d %H:%M:%S")
if isinstance(o, datetime.date):
return o.strftime("%Y-%m-%d")
super(_JSONEncoder, self).default(o)
class Flask(_Flask):
json_encoder = JSONEncoder
import os
app = Flask(__name__)
app.config['SESSION_TYPE'] = 'filesystem'
app.config['SECRET_KEY'] = os.urandom(24)
# ----------------------------------------------页面加载模块开始----------------------------------------------
# 加载系统json文件
@app.route('/api/<string:path>/')
def api_json(path):
if path == 'init.json' and session.get('user') and session.get('user')['type'] == 1:
path = 'custom_init.json'
return read_json(json_path + path)
# 加载page下的静态页面
@app.route('/page/<string:path>')
def api_path(path):
return render_template("page/" + path)
# 系统默认路径后台跳转
@app.route('/admin')
def admin_page():
if session.get('user') and session.get('user')['id'] > 0:
return render_template("index.html")
else:
return redirect("/login")
# 系统可视化数据请求接口
@app.route('/')
def main_page():
month_rain = data_service.get_month_rain_volume()
ave_wind = data_service.get_ave_wind()
count, output, weather = data_service.get_total()
yearly_outputs = data_service.get_yearly_output()
months_temp = data_service.get_months_temp()
times_selling = data_service.get_times_selling()
months_sun = data_service.get_months_sun()
table_list = data_service.get_table_list()
return render_template("main.html", month_rain=month_rain,
ave_wind=ave_wind,
table_list=table_list,
count=count, output=output, weather=weather,
yearly_outputs=yearly_outputs, months_temp=months_temp,
times_selling=times_selling, months_sun=months_sun)
# 系统登录路径
@app.route('/login')
def login_page():
return render_template("page/login.html")
# 系统退出登录路径
@app.route('/logout')
def logout_page():
session.clear()
return redirect("/login")
# 系统注册用户
@app.route('/register', methods=['get'])
def register_page():
return render_template("page/register.html")
# ----------------------------------------------页面加载模块结束----------------------------------------------
# ----------------------------------------------用户相关模块开始----------------------------------------------
# 用户注册
@app.route('/register', methods=['post'])
def register_user():
form = request.form.to_dict() # 获取值
result = user_service.insert_user(form)
return result.get()
# 用户登录
@app.route('/login', methods=['post'])
def login_user():
form = request.form.to_dict() # 获取值
result = user_service.select_user_by_account_password(form)
session['user'] = result.data
return result.get()
# 用户数据分页
@app.route('/page/user/add', methods=['get'])
def page_user_add():
return render_template("page/user/add.html")
# 用户修改密码
@app.route('/user/reset/password', methods=['post'])
def reset_password_user():
form = request.form.to_dict() # 获取值
result = user_service.reset_password(form['old_password'], form['new_password'], form['again_password'])
return result.get()
@app.route('/add/user', methods=['post'])
def add_user():
form = request.form.to_dict()
result = user_service.insert_user(form)
return result.get()
# 用户编辑页面
@app.route('/page/user/edit', methods=['get'])
def page_user_edit():
id = request.args.get('id')
user = user_service.get_user(id)
return render_template("page/user/edit.html", user=user)
# 编辑用户接口
@app.route('/edit/user', methods=['post'])
def edit_user():
form = request.form.to_dict()
result = user_service.edit_user(form)
return result.get()
# 单个删除用户接口
@app.route('/del/user/<int:id>', methods=['post'])
def del_user(id):
result = user_service.del_user(id)
return result.get()
# 批量删除用户接口
@app.route('/del/user', methods=['post'])
def del_user_list():
ids = request.args.get('ids')
result = user_service.del_user_list(ids)
return result.get()
# 用户数据分页
@app.route('/list/user', methods=['get'])
def user_list():
page = request.args.get('page')
limit = request.args.get('limit')
where = request.args.get('searchParams')
result = user_service.select_user_list(page, limit, where)
return result.get()
# ----------------------------------------------用户相关模块结束----------------------------------------------
# ----------------------------------------------公告相关模块开始----------------------------------------------
# 公告添加页面
@app.route('/page/notice/add', methods=['get'])
def page_notice_add():
return render_template("page/notice/add.html")
@app.route('/add/notice', methods=['post'])
def add_notice():
form = request.form.to_dict()
result = notice_service.insert_notice(form)
return result.get()
# 数据公告编辑页面
@app.route('/page/notice/edit', methods=['get'])
def page_notice_edit():
id = request.args.get('id')
notice = notice_service.get_notice(id)
return render_template("page/notice/edit.html", notice=notice)
# 编辑公告接口
@app.route('/edit/notice', methods=['post'])
def edit_notice():
form = request.form.to_dict()
result = notice_service.edit_notice(form)
return result.get()
# 单个删除公告接口
@app.route('/del/notice/<int:id>', methods=['post'])
def del_notice(id):
result = notice_service.del_notice(id)
return result.get()
# 批量删除公告接口
@app.route('/del/notice', methods=['post'])
def del_notice_list():
ids = request.args.get('ids')
result = notice_service.del_notice_list(ids)
return result.get()
# 公告数据分页
@app.route('/list/notice', methods=['get'])
def notice_list():
page = request.args.get('page')
limit = request.args.get('limit')
where = request.args.get('searchParams')
result = notice_service.select_notice_list(page, limit, where)
return result.get()
# 公告数据最新获取
@app.route('/get/notice/new', methods=['get'])
def get_new_notice():
result = notice_service.get_notice_by_new()
return result.get()
# ----------------------------------------------公告相关模块结束----------------------------------------------
# ----------------------------------------------产量相关模块开始----------------------------------------------
# 产量添加页面跳转
@app.route('/page/output/add', methods=['get'])
def page_output_add():
return render_template("page/output/add.html")
# 产量新增接口
@app.route('/add/output', methods=['post'])
def add_output():
form = request.form.to_dict()
result = output_service.insert_output(form)
return result.get()
# 产量编辑页面跳转
@app.route('/page/output/edit', methods=['get'])
def page_output_edit():
id = request.args.get('id')
output = output_service.get_output(id)
return render_template("page/output/edit.html", output=output)
# 产量编辑接口
@app.route('/edit/output', methods=['post'])
def edit_output():
form = request.form.to_dict()
result = output_service.edit_output(form)
return result.get()
# 删除单个产量接口
@app.route('/del/output/<int:id>', methods=['post'])
def del_output(id):
result = output_service.del_output(id)
return result.get()
# 批量删除产量接口
@app.route('/del/output', methods=['post'])
def del_output_list():
ids = request.args.get('ids')
result = output_service.del_output_list(ids)
return result.get()
# 产量数据分页接口
@app.route('/list/output', methods=['get'])
def output_list():
page = request.args.get('page')
limit = request.args.get('limit')
where = request.args.get('searchParams')
result = output_service.select_output_list(page, limit, where)
return result.get()
# ----------------------------------------------产量相关模块结束----------------------------------------------
# ----------------------------------------------气象相关模块开始----------------------------------------------
# 气象添加页面跳转
@app.route('/page/weather/add', methods=['get'])
def page_weather_add():
return render_template("page/weather/add.html")
# 气象新增接口
@app.route('/add/weather', methods=['post'])
def add_weather():
form = request.form.to_dict()
result = weather_service.insert_weather(form)
return result.get()
# 气象编辑页面跳转
@app.route('/page/weather/edit', methods=['get'])
def page_weather_edit():
id = request.args.get('id')
weather = weather_service.get_weather(id)
return render_template("page/weather/edit.html", weather=weather)
# 气象编辑接口
@app.route('/edit/weather', methods=['post'])
def edit_weather():
form = request.form.to_dict()
result = weather_service.edit_weather(form)
return result.get()
# 删除单个气象接口
@app.route('/del/weather/<int:id>', methods=['post'])
def del_weather(id):
result = weather_service.del_weather(id)
return result.get()
# 批量删除气象接口
@app.route('/del/weather', methods=['post'])
def del_weather_list():
ids = request.args.get('ids')
result = weather_service.del_weather_list(ids)
return result.get()
# 气象数据分页接口
@app.route('/list/weather', methods=['get'])
def weather_list():
page = request.args.get('page')
limit = request.args.get('limit')
where = request.args.get('searchParams')
result = weather_service.select_weather_list(page, limit, where)
return result.get()
# ----------------------------------------------气象相关模块结束----------------------------------------------
# ----------------------------------------------预测相关模块开始----------------------------------------------
# 预测数据接口
@app.route('/predict/data', methods=['get'])
def predict_data():
result = predict_service.get_predict_data()
return result.get()
# ----------------------------------------------预测相关模块结束----------------------------------------------
if __name__ == '__main__':
# 端口号设置
app.run(host="127.0.0.1", port=5000)
源码获取:
🍅由于篇幅限制,获取完整文章或源码、代做项目的,查看主页【专栏名称】或者【用户名】或者顶部的【选题链接】就可以找到我获取项目源码学习啦~🍅
大家点赞、收藏、关注、评论啦 !
更多推荐
所有评论(0)