
博主介绍:
✌我是阿龙,一名专注于Java技术领域的程序员,全网拥有10W+粉丝。作为CSDN特邀作者、博客专家、新星计划导师,我在计算机毕业设计开发方面积累了丰富的经验。同时,我也是掘金、华为云、阿里云、InfoQ等平台的优质作者。通过长期分享和实战指导,我致力于帮助更多学生完成毕业项目和技术提升。
技术范围:
我熟悉的技术领域涵盖SpringBoot、Vue、SSM、HLMT、Jsp、PHP、Nodejs、Python、爬虫、数据可视化、小程序、安卓app、大数据、物联网、机器学习等方面的设计与开发。如果你有任何技术难题,我都乐意与你分享解决方案。
主要内容:
我的服务内容包括:免费功能设计、开题报告、任务书、中期检查PPT、系统功能实现、代码编写、论文撰写与辅导、论文降重、长期答辩答疑辅导。我还提供腾讯会议一对一的专业讲解和模拟答辩演练,帮助你全面掌握答辩技巧与代码逻辑。
🍅获取源码请在文末联系我🍅
温馨提示:文末有 CSDN 平台官方提供的阿龙联系方式的名片!
温馨提示:文末有 CSDN 平台官方提供的阿龙联系方式的名片!

2.1 Mysql技术介绍
随着技术的不断发展,数据库从只能处理数据表格,到现在能够处理大量数据,MySQL数据库属于关系类型数据库,在安装的时候很方便,可以为其添加索引从而更快的查询出数据。数据库还有多种版本,能够在不同的操作系统中使用数据库。能够在不同的平台部署[9]。Microsoft MySQL工具可以为数据库进行一个可视化的管理。用户可以在软件上进行测试连接数据库是否成功,可以轻松对数据库的字段进行操作。数据库中的数据是存储在数据库表和索引当中,MySQL数据库架构属于c/s模型,客户端需要有账号和密码从而进行连接服务器。
2.2 Python语言介绍
Python作为一种高级编程语言,在全球范围内因其清晰的语法和高代码可读性获得了广泛的应用。特别是在基于大数据技术的购房推荐系统的设计与实现项目中,Python起到了核心作用。在该系统中,Python用于开发爬虫程序来从南京地区的安居客网站抓取房产数据[10]。这些数据包括楼盘名称、价格、位置等关键信息,是购房推荐系统能够提供精准推荐的基础。
Python支持面向对象、命令式、函数式和过程式编程范式,非常适合执行复杂的数据操作任务,如数据采集、清洗以及分析。在该购房推荐系统中,不仅利用Python进行数据处理,还应用了Python生态系统中的丰富库和框架来增强系统功能性。使用Pandas库进行数据整理和分析,NumPy库处理数学运算,这些都是实现数据处理和分析的关键工具。Python的跨平台特性确保购房推荐系统能在不同的操作系统上稳定运行[11]。其解释性特点帮助缩短了开发周期,便于系统的快速测试和部署。Python的强大开源社区为系统开发提供了丰富的资源和支持,这不仅增强了购房推荐系统的可靠性,也促进了持续的技术升级和功能优化。通过这种方式,学生开发的系统利用Python语言的强大功能[12],提供了一个高效、准确的购房推荐平台,以满足用户的多样化购房需求。
2.3 Flask框架简介
Flask是一个由Python编写的轻量级Web应用框架,因其简单易用和高度灵活而广受欢迎。在基于大数据技术的购房推荐系统的设计与实现项目中,Flask起到了核心的作用,主要用于开发系统的前端用户界面和后端API服务。该框架的简洁性和可扩展性使得学生能够快速构建并迭代开发Web应用,从而有效支持复杂的购房推荐逻辑和用户交互[13]。利用Flask,学生设计的购房推荐系统提供了用户友好的Web界面,使购房者可以轻松地注册、登录、浏览房产信息、进行房产搜索和管理关注列表。系统后端利用Flask处理用户请求,与Hadoop和MySQL等技术结合,实现数据的高效处理和存储。这种结构不仅保证了系统的响应速度和稳定性,也便于未来的功能拓展和维护。
2.4 Scrapy简介
Scrapy是由Python语言开发的一个快速、高层次的网页爬虫框架,广泛应用于数据挖掘和网页内容抓取。在基于大数据技术的购房推荐系统的设计与实现项目中,Scrapy扮演着至关重要的角色,主要负责从安居客等房地产网站抓取南京地区的房产数据。这些数据包括楼盘的名称、价格、位置、配套设施等关键信息,为购房推荐系统提供了丰富和实时的数据源[14]。Scrapy框架的优势体现在其强大的数据抓取能力、灵活的配置选项以及易于扩展的架构上。该框架允许开发者编写定制的抓取规则,确保能从目标网站高效且准确地提取所需数据。Scrapy的异步处理机制通过并行处理多个网页抓取请求,显著提高了数据采集的速度和效率。
在购房推荐系统中,通过Scrapy抓取的房产数据在清洗和格式化后存入MySQL数据库,供后续的数据分析和用户查询使用。Scrapy的可扩展性使得学生开发的系统可以根据市场变化或新的数据需求灵活调整抓取任务[15],增加新的数据源或修改数据抓取策略。这种方式有效地支持了购房推荐系统的需求,提高了房产数据的实时性和准确性,从而帮助购房者做出更为明智的购房决策。
2.5 VUE技术简介
Vue.js是渐进式框架,没有关注后端逻辑,只关注前端页面,采用的是向上增量开发设计,Vue是由Api实现视图组件。Vue.js是一种动态页面的技术,和静态页面有着很大的区别,程序员使用Vue.js和后端编程语言能够实现前后端分离,使得程序员在前后端交互更加容易,能够使得数据在交互的时候更加简便,前端程序员只需要负责前端页面逻辑代码的编写,调用后端程序员编写的服务接口就能够实现数据的处理。Vue.js还能够和静态页面混合编写,提供给程序员多种选择,能够把静态页面变成动态页面,使得程序更容易扩展。
2.6 Hadoop介绍
Hadoop实现了一个分布式文件系统(Hadoop Distributed File System),简称HDFS。HDFS有高容错性的特点,并且设计用来部署在低廉的(low-cost)硬件上;而且它提供高吞吐量(high throughput)来访问应用程序的数据,适合那些有着超大数据集(large data set)的应用程序。HDFS放宽了(relax)POSIX的要求,可以以流的形式访问(streaming access)文件系统中的数据。
Hadoop的框架最核心的设计就是:HDFS和MapReduce。HDFS为海量的数据提供了存储,而MapReduce则为海量的数据提供了计算。主要有以下优点:
(1)高可靠性。Hadoop按位存储和处理数据的能力值得人们信赖。
(2)高扩展性。Hadoop是在可用的计算机集簇间分配数据并完成计算任务的,这些集簇可以方便地扩展到数以千计的节点中。
(3)高效性。Hadoop能够在节点之间动态地移动数据,并保证各个节点的动态平衡,因此处理速度非常快。高容错性。Hadoop能够自动保存数据的多个副本,并且能够自动将失败的任务重新分配。
(4)低成本。与一体机、商用数据仓库以及QlikView、Yonghong Z-Suite等数据集市相比,hadoop是开源的,项目的软件成本因此会大大降低

4.1 系统总体架构设计
本系统使用的数据库为MySQL数据库,选择该数据库的原因是因为该数据库开源、免费,且相对简便,且由于使用人数众多,在处理问题上会得到更多已知的帮助。系统,其体量并不会很大,也很适合MySQL数据库的特点,本项目采用MySQL作为本项目的数据库和进行数据表的设计。
如图4-1是该系统软件的总体功能结构图:
图4-1 总体功能结构图
4.2 建立概念性数据模型
利用数据模型可以表示不同的类,概念性模型没有固定的模型,因此用户可以按照自己的想法进行建立概念性数据模型。概念模型可以用E-R图表示,E-R图又称为数据模型。系统有着大量的数据,因此需要建立数据模型,根据前面对系统的分析可以得出系统的E-R图如下:



用户管理:管理系统用户的账户信息。
核心代码:
// 获取用户信息
this .$http({
url: `{*this* .storage.get('sessionTable')}/session`,
method: "get"
}).then(({ data }) => {
if (data && data.code === 0) {
var json = data.data;
} else {
this .$message.error(data.msg);
}
});
this .xingbieOptions = "男,女".split(',')
},

小区信息管理,提供管理员对于小区信息的序号、小区名称、小区类型、小区类型、建筑面积、绿化面积、总户数、物业名称、小区图片、点击次数、评论数、收藏数,进行查看、修改、查看评论,删除等操作。
核心代码:
</el-form-item>
<el-form-item :style='{"width":"100%","padding":"10px","margin":"0 0 10px","background":"none","display":"inline-block"}' label=" 小区地址" prop="xiaoqudizhi">
<el-input v-model="ruleForm.xiaoqudizhi"
placeholder="小区地址" clearable :disabled=" false ||ro.xiaoqudizhi"></el-input>
</el-form-item>
<el-form-item :style='{"width":"100%","padding":"10px","margin":"0 0 10px","background":"none","display":"inline-block"}' label="建筑面积" prop="jianzhumianji">
<el-input v-model="ruleForm.jianzhumianji"
placeholder="建筑面积" clearable :disabled=" false ||ro.jianzhumianji"></el-input>
</el-form-item>
核心代码:
python
# coding:utf-8
__author__ = "ila"
import logging, os, json, configparser
import time
from datetime import datetime
from flask import request, jsonify,session
from sqlalchemy.sql import func,and_,or_,case
from sqlalchemy import cast, Integer,Float
from api.models.brush_model import *
from . import main_bp
from utils.codes import *
from utils.jwt_auth import Auth
from configs import configs
from utils.helper import *
import random
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
from email.header import Header
from utils.baidubce_api import BaiDuBce
from api.models.config_model import config
from flask import current_app as app
from utils.spark_func import spark_read_mysql
from utils.hdfs_func import upload_to_hdfs
from utils.mapreduce1 import MRMySQLAvg
# 注册接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/register", methods=['POST'])
def pythonb9t35583_fangyuanxinxi_register():
if request.method == 'POST':
msg = {'code': normal_code, 'message': 'success', 'data': [{}]}
req_dict = session.get("req_dict")
error = fangyuanxinxi.createbyreq(fangyuanxinxi, fangyuanxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = "注册用户已存在"
return jsonify(msg)
# 登录接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/login", methods=['GET','POST'])
def pythonb9t35583_fangyuanxinxi_login():
if request.method == 'GET' or request.method == 'POST':
msg = {"code": normal_code, "msg": "success", "data": {}}
req_dict = session.get("req_dict")
req_model = session.get("req_dict")
try:
del req_model['role']
except:
pass
datas = fangyuanxinxi.getbyparams(fangyuanxinxi, fangyuanxinxi, req_model)
if not datas:
msg['code'] = password_error_code
msg['msg']='密码错误或用户不存在'
return jsonify(msg)
req_dict['id'] = datas[0].get('id')
try:
del req_dict['mima']
except:
pass
return Auth.authenticate(Auth, fangyuanxinxi, req_dict)
# 登出接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/logout", methods=['POST'])
def pythonb9t35583_fangyuanxinxi_logout():
if request.method == 'POST':
msg = {
"msg": "退出成功",
"code": 0
}
req_dict = session.get("req_dict")
return jsonify(msg)
# 重置密码接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/resetPass", methods=['POST'])
def pythonb9t35583_fangyuanxinxi_resetpass():
'''
'''
if request.method == 'POST':
msg = {"code": normal_code, "msg": "success"}
req_dict = session.get("req_dict")
if req_dict.get('mima') != None:
req_dict['mima'] = '123456'
error = fangyuanxinxi.updatebyparams(fangyuanxinxi, fangyuanxinxi, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
else:
msg['msg'] = '密码已重置为:123456'
return jsonify(msg)
# 获取会话信息接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/session", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_session():
'''
'''
if request.method == 'GET':
msg = {"code": normal_code, "data": {}}
req_dict={"id":session.get('params').get("id")}
msg['data'] = fangyuanxinxi.getbyparams(fangyuanxinxi, fangyuanxinxi, req_dict)[0]
return jsonify(msg)
# 分类接口(后端)
@main_bp.route("/pythonb9t35583/fangyuanxinxi/page", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_page():
'''
'''
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = session.get("req_dict")
userinfo = session.get("params")
try:
__hasMessage__=fangyuanxinxi.__hasMessage__
except:
__hasMessage__=None
if __hasMessage__ and __hasMessage__!="否":
tablename=session.get("tablename")
if tablename!="users" and session.get("params")!=None and fangyuanxinxi!='chat':
req_dict["userid"]=session.get("params").get("id")
tablename=session.get("tablename")
if tablename=="users" :
try:
pass
except:
pass
else:
mapping_str_to_object = {}
for model in Base_model._decl_class_registry.values():
if hasattr(model, '__tablename__'):
mapping_str_to_object[model.__tablename__] = model
try:
__isAdmin__=mapping_str_to_object[tablename].__isAdmin__
except:
__isAdmin__=None
try:
__authSeparate__ =mapping_str_to_object[tablename].__authSeparate__
except:
__authSeparate__ = None
if __isAdmin__!="是" and __authSeparate__ == "是" and session.get("params")!=None:
req_dict["userid"]=session.get("params").get("id")
else:
try:
del req_dict["userid"]
except:
pass
# 当前表也是有管理员权限的表
if __isAdmin__ == "是" and 'fangyuanxinxi' != 'forum':
if req_dict.get("userid") and 'fangyuanxinxi' != 'chat':
del req_dict["userid"]
else:
#非管理员权限的表,判断当前表字段名是否有userid
if tablename!="users" and 'fangyuanxinxi'[:7]!='discuss'and "userid" in fangyuanxinxi.getallcolumn(fangyuanxinxi,fangyuanxinxi):
req_dict["userid"] = session.get("params").get("id")
clause_args = []
or_clauses = or_(*clause_args)
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = fangyuanxinxi.page(fangyuanxinxi, fangyuanxinxi, req_dict, or_clauses)
return jsonify(msg)
# 排序接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/autoSort", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_autosort():
'''
'''
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = session.get("req_dict")
req_dict['sort']='clicktime'
req_dict['order']='desc'
try:
__browseClick__= fangyuanxinxi.__browseClick__
except:
__browseClick__=None
if __browseClick__ =='是':
req_dict['sort']='clicknum'
elif __browseClick__ =='时长':
req_dict['sort']='browseduration'
else:
req_dict['sort']='clicktime'
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = fangyuanxinxi.page(fangyuanxinxi, fangyuanxinxi, req_dict)
return jsonify(msg)
#查询单条数据
@main_bp.route("/pythonb9t35583/fangyuanxinxi/query", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_query():
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data":{}}
req_dict = session.get("req_dict")
query = db.session.query(fangyuanxinxi)
for key, value in req_dict.items():
query = query.filter(getattr(fangyuanxinxi, key) == value)
query_result = query.first()
query_result.__dict__.pop('_sa_instance_state', None)
msg['data'] = query_result.__dict__
return jsonify(msg)
# 分页接口(前端)
@main_bp.route("/pythonb9t35583/fangyuanxinxi/list", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_list():
'''
'''
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = session.get("req_dict")
if req_dict.__contains__('vipread'):
del req_dict['vipread']
userinfo = session.get("params")
try:
__foreEndList__=fangyuanxinxi.__foreEndList__
except:
__foreEndList__=None
if __foreEndList__ and __foreEndList__!="否":
tablename=session.get("tablename")
if tablename!="users" and session.get("params")!=None:
req_dict['userid']=session.get("params").get("id")
try:
__foreEndListAuth__=fangyuanxinxi.__foreEndListAuth__
except:
__foreEndListAuth__=None
if __foreEndListAuth__ and __foreEndListAuth__!="否":
tablename=session.get("tablename")
if tablename!="users" and session.get("params")!=None:
req_dict['userid']=session.get("params").get("id")
tablename=session.get("tablename")
if tablename=="users" :
try:
del req_dict["userid"]
except:
pass
else:
mapping_str_to_object = {}
for model in Base_model._decl_class_registry.values():
if hasattr(model, '__tablename__'):
mapping_str_to_object[model.__tablename__] = model
try:
__isAdmin__=mapping_str_to_object[tablename].__isAdmin__
except:
__isAdmin__=None
if __isAdmin__!="是" and session.get("params")!=None:
req_dict["userid"]=session.get("params").get("id")
if 'luntan' in 'fangyuanxinxi':
if 'userid' in req_dict.keys():
del req_dict["userid"]
if 'discuss' in 'fangyuanxinxi':
if 'userid' in req_dict.keys():
del req_dict["userid"]
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = fangyuanxinxi.page(fangyuanxinxi, fangyuanxinxi, req_dict)
return jsonify(msg)
# 保存接口(后端)
@main_bp.route("/pythonb9t35583/fangyuanxinxi/save", methods=['POST'])
def pythonb9t35583_fangyuanxinxi_save():
'''
'''
if request.method == 'POST':
msg = {"code": normal_code, "msg": "success", "data": {}}
req_dict = session.get("req_dict")
for key in req_dict:
if req_dict[key] == '':
req_dict[key] = None
error= fangyuanxinxi.createbyreq(fangyuanxinxi, fangyuanxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return jsonify(msg)
# 添加接口(前端)
@main_bp.route("/pythonb9t35583/fangyuanxinxi/add", methods=['POST'])
def pythonb9t35583_fangyuanxinxi_add():
'''
'''
if request.method == 'POST':
msg = {"code": normal_code, "msg": "success", "data": {}}
req_dict = session.get("req_dict")
try:
__foreEndListAuth__=fangyuanxinxi.__foreEndListAuth__
except:
__foreEndListAuth__=None
if __foreEndListAuth__ and __foreEndListAuth__!="否":
tablename=session.get("tablename")
if tablename!="users":
req_dict['userid']=session.get("params").get("id")
error= fangyuanxinxi.createbyreq(fangyuanxinxi, fangyuanxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return jsonify(msg)
# 踩、赞接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/thumbsup/<id_>", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_thumbsup(id_):
'''
'''
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data": {}}
req_dict = session.get("req_dict")
id_=int(id_)
type_=int(req_dict.get("type",0))
rets=fangyuanxinxi.getbyid(fangyuanxinxi, fangyuanxinxi,id_)
update_dict={
"id":id_,
}
if type_==1:#赞
update_dict["thumbsupnum"]=int(rets[0].get('thumbsupnum'))+1
elif type_==2:#踩
update_dict["crazilynum"]=int(rets[0].get('crazilynum'))+1
error = fangyuanxinxi.updatebyparams(fangyuanxinxi, fangyuanxinxi, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return jsonify(msg)
# 获取详情信息(后端)
@main_bp.route("/pythonb9t35583/fangyuanxinxi/info/<id_>", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_info(id_):
'''
'''
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data": {}}
data = fangyuanxinxi.getbyid(fangyuanxinxi, fangyuanxinxi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= fangyuanxinxi.__browseClick__
except:
__browseClick__=None
if __browseClick__ and "clicknum" in fangyuanxinxi.__table__.columns:
click_dict={"id":int(id_),"clicknum":str(int(data[0].get("clicknum") or 0)+1)}
ret=fangyuanxinxi.updatebyparams(fangyuanxinxi,fangyuanxinxi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return jsonify(msg)
# 获取详情信息(前端)
@main_bp.route("/pythonb9t35583/fangyuanxinxi/detail/<id_>", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_detail(id_):
'''
'''
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data": {}}
data = fangyuanxinxi.getbyid(fangyuanxinxi, fangyuanxinxi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= fangyuanxinxi.__browseClick__
except:
__browseClick__=None
if __browseClick__ and "clicknum" in fangyuanxinxi.__table__.columns:
click_dict={"id":int(id_),"clicknum":str(int(data[0].get("clicknum") or 0)+1)}
ret=fangyuanxinxi.updatebyparams(fangyuanxinxi,fangyuanxinxi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return jsonify(msg)
# 更新接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/update", methods=['POST'])
def pythonb9t35583_fangyuanxinxi_update():
'''
'''
if request.method == 'POST':
msg = {"code": normal_code, "msg": "success", "data": {}}
req_dict = session.get("req_dict")
if req_dict.get("mima") and "mima" not in fangyuanxinxi.__table__.columns :
del req_dict["mima"]
if req_dict.get("password") and "password" not in fangyuanxinxi.__table__.columns :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = fangyuanxinxi.updatebyparams(fangyuanxinxi, fangyuanxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return jsonify(msg)
# 删除接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/delete", methods=['POST'])
def pythonb9t35583_fangyuanxinxi_delete():
'''
'''
if request.method == 'POST':
msg = {"code": normal_code, "msg": "success", "data": {}}
req_dict = session.get("req_dict")
error=fangyuanxinxi.delete(
fangyuanxinxi,
req_dict
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return jsonify(msg)
# 投票接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/vote/<int:id_>", methods=['POST'])
def pythonb9t35583_fangyuanxinxi_vote(id_):
'''
'''
if request.method == 'POST':
msg = {"code": normal_code, "msg": "success"}
data= fangyuanxinxi.getbyid(fangyuanxinxi, fangyuanxinxi, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=fangyuanxinxi.updatebyparams(fangyuanxinxi,fangyuanxinxi,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return jsonify(msg)
# 分组统计接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/group/<columnName>", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_group(columnName):
'''
分组统计接口
'''
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data": {}}
req_dict = session.get("req_dict")
userinfo = session.get("params")
msg['data'] = fangyuanxinxi.groupbycolumnname(fangyuanxinxi,fangyuanxinxi,columnName,req_dict)
msg['data'] = msg['data'][:10]
msg['data'] = [ {**i,columnName:str(i[columnName])} if columnName in i else i for i in msg['data']]
json_filename='fangyuanxinxi'+f'_group_{columnName}.json'
where = ' where 1 = 1 '
sql = "SELECT COUNT(*) AS total, " + columnName + " FROM fangyuanxinxi " + where + " GROUP BY " + columnName
with open(json_filename, 'w', encoding='utf-8') as f:
f.write(json.dumps(msg['data'], indent=4, ensure_ascii=False))
app.executor.submit(upload_to_hdfs, json_filename)
app.executor.submit(MRMySQLAvg.run)
return jsonify(msg)
# 按值统计接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/value/<xColumnName>/<yColumnName>", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_value(xColumnName, yColumnName):
'''
按值统计接口,
{
"code": 0,
"data": [
{
"total": 10.0,
"shangpinleibie": "aa"
},
{
"total": 20.0,
"shangpinleibie": "bb"
},
{
"total": 15.0,
"shangpinleibie": "cc"
}
]
}
'''
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data": {}}
req_dict = session.get("req_dict")
userinfo = session.get("params")
msg['data'] = fangyuanxinxi.getvaluebyxycolumnname(fangyuanxinxi,fangyuanxinxi,xColumnName,yColumnName,req_dict)
msg['data'] = msg['data'][:10]
return jsonify(msg)
# 按日期统计接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/value/<xColumnName>/<yColumnName>/<timeStatType>", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_value_riqi(xColumnName, yColumnName, timeStatType):
'''
按日期统计接口
'''
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data": {}}
userinfo = session.get("params")
where = ' where 1 = 1 '
sql = ''
if timeStatType == '日':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM fangyuanxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '月':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM fangyuanxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '年':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM fangyuanxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
data = db.session.execute(sql)
data = data.fetchall()
results = []
for i in range(len(data)):
result = {
xColumnName: decimalEncoder(data[i][0]),
'total': decimalEncoder(data[i][1])
}
results.append(result)
msg['data'] = results
json_filename='fangyuanxinxi'+f'_value_{xColumnName}_{yColumnName}.json'
with open(json_filename, 'w', encoding='utf-8') as f:
f.write(json.dumps(results, indent=4, ensure_ascii=False))
app.executor.submit(upload_to_hdfs, json_filename)
app.executor.submit(MRMySQLAvg.run)
return jsonify(msg)
# 按值统计(多)
@main_bp.route("/pythonb9t35583/fangyuanxinxi/valueMul/<xColumnName>", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_valueMul(xColumnName):
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data": []}
req_dict = session.get("req_dict")
userinfo = session.get("params")
where = ' where 1 = 1 '
for item in req_dict['yColumnNameMul'].split(','):
sql = "SELECT {0}, sum({1}) AS total FROM fangyuanxinxi {2} GROUP BY {0} LIMIT 10".format(xColumnName, item, where)
L = []
data = db.session.execute(sql)
data = data.fetchall()
for i in range(len(data)):
result = {
xColumnName: decimalEncoder(data[i][0]),
'total': decimalEncoder(data[i][1])
}
L.append(result)
msg['data'].append(L)
return jsonify(msg)
# 按值统计(多)
@main_bp.route("/pythonb9t35583/fangyuanxinxi/valueMul/<xColumnName>/<timeStatType>", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_valueMul_time(xColumnName,timeStatType):
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data": []}
req_dict = session.get("req_dict")
userinfo = session.get("params")
where = ' where 1 = 1 '
for item in req_dict['yColumnNameMul'].split(','):
sql = ''
if timeStatType == '日':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM fangyuanxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d') LIMIT 10".format(xColumnName, item, where, '%Y-%m-%d')
if timeStatType == '月':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM fangyuanxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m') LIMIT 10".format(xColumnName, item, where, '%Y-%m')
if timeStatType == '年':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM fangyuanxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y') LIMIT 10".format(xColumnName, item, where, '%Y')
L = []
data = db.session.execute(sql)
data = data.fetchall()
for i in range(len(data)):
result = {
xColumnName: decimalEncoder(data[i][0]),
'total': decimalEncoder(data[i][1])
}
L.append(result)
msg['data'].append(L)
return jsonify(msg)
# 总数量
@main_bp.route("/pythonb9t35583/fangyuanxinxi/count", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_count():
'''
'''
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data": 0}
req_dict = session.get("req_dict")
userinfo = session.get("params")
msg['data'] = fangyuanxinxi.count(fangyuanxinxi, fangyuanxinxi, req_dict)
return jsonify(msg)
# 统计接口
@main_bp.route("/pythonb9t35583/fangyuanxinxi/remind/<columnName>/<type>", methods=['GET']) #
def pythonb9t35583_fangyuanxinxi_remind(columnName,type):
'''
'''
if request.method == 'GET':
msg = {"code": normal_code, 'count': 0}
# 组合查询参数
params = session.get("req_dict")
remindstart = 0
remindend =9999990
if int(type)==1:#数字
if params.get('remindstart') == None and params.get('remindend') != None:
remindstart = 0
remindend = int(params['remindend'])
elif params.get('remindstart') != None and params.get('remindend') == None:
remindstart = int(params['remindstart'])
remindend = 999999
elif params.get('remindstart') == None and params.get('remindend') == None:
remindstart = 0
remindend = 999999
else:
remindstart = params.get('remindstart')
remindend = params.get('remindend')
elif int(type)==2:#日期
current_time=int(time.time())
if params.get('remindstart') == None and params.get('remindend') != None:
starttime=current_time-60*60*24*365*2
params['remindstart'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(starttime))
endtime=current_time+60*60*24*params.get('remindend')
params['remindend'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(endtime))
elif params.get('remindstart') != None and params.get('remindend') == None:
starttime= current_time - 60 * 60 * 24 * params.get('remindstart')
params['remindstart']=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(starttime))
endtime=current_time+60*60*24*365*2
params['remindend'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(endtime))
elif params.get('remindstart') == None and params.get('remindend') == None:
starttime = current_time - 60 * 60 * 24 * 365 * 2
params['remindstart'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(starttime))
endtime = current_time + 60 * 60 * 24 * 365 * 2
params['remindend'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(endtime))
data = fangyuanxinxi.getbetweenparams(
fangyuanxinxi,
fangyuanxinxi,
columnName,
{
"remindStart": remindstart,
"remindEnd": remindend
}
)
msg['count'] = len(data)
return jsonify(msg)
#分类列表
@main_bp.route("/pythonb9t35583/fangyuanxinxi/lists", methods=['GET'])
def pythonb9t35583_fangyuanxinxi_lists():
if request.method == 'GET':
msg = {"code": normal_code, "msg": "success", "data": []}
list,_,_,_,_ = fangyuanxinxi.page(fangyuanxinxi,fangyuanxinxi,{})
msg['data'] = list
return jsonify(msg)

为什么选择我(我可以给你的定制项目推荐核心功能,一对一推荐)实现定制!!!
博主提供的项目均为博主自己收集和开发的!所有的源码都经由博主检验过,能过正常启动并且功能都没有问题!同学们拿到后就能使用!且博主自身就是高级开发,可以将所有的代码都清晰讲解出来。
源码获取
文章下方名片联系我即可~
大家点赞、收藏、关注、评论啦 、查看👇🏻获取联系方式👇🏻
精彩专栏推荐订阅:在下方专栏