代码拉取完成,页面将自动刷新
在线预览:旅游网站TourismPro
账号:朱利尔,密码:123
管理员账号:admin,密码:123456
public List<Spots> findRecommendList(String id) {
//系统中我将景点抽象成了产品,这样便于扩展,如酒店、旅行团均可看作产品评分,统一记录在系统的分数表中
//如果是查询景点推荐列表,则根据入参景点id查询景点
List<Score> productScoreList = scoreDao.findByProductId(id);
//因为相似度比对需要两份数据,首先得到自己查询的景点的分数集合
double[] ownProductScoreList = new double[productScoreList.size()];
for (int i = 0; i < productScoreList.size(); i++) {
ownProductScoreList[i] = Double.parseDouble(productScoreList.get(i).getGrade());
}
//然后得到分数表中所有景点的分数集合
List<Score> productCountInScoreList = scoreDao.findAllGroupByProductId();
HashMap<String,double[]> ss = new HashMap<String,double[]>();
//循环所有景点
for (int i = 0; i < productCountInScoreList.size(); i++) {
//得到该产品的所有分数
List<Score> bb = scoreDao.findByProductId(productCountInScoreList.get(i).getProductId());
double[] otherProductScoreList = new double[bb.size()];
//循环该产品的所有分数
for (int j = 0; j < bb.size(); j++) {
otherProductScoreList[j] = Double.parseDouble(bb.get(j).getGrade());
}
//将产品作为key,分数集合作为value存入map
ss.put(productCountInScoreList.get(i).getProductId(),otherProductScoreList);
}
List<Spots> resSpotsList = new ArrayList<>();
//循环Map依次比对其线性相似度
ss.forEach((String k, double[] v)->{
//得到相似度值
double n = CFUtils.cosineSimilarity(ownProductScoreList,v);
log.info("id:{},线性相似度:{}",k,n);
//判断相似度值是否符合自己设定的阈值
if(n > pearsonCorrelation) {
//符合相似阈值,放入推荐列表
resSpotsList.add(spotsDao.findById(k));
}
});
return resSpotsList;
}
注:看不到图片可能需要梯子(maybe u need VPN)
前台登录&注册:
前台首页:
前台景点列表&详情:
前台景点推荐:
前台酒店列表&详情&预订:
前台旅线列表&详情:
前台订单列表:
后台首页:
后台景点列表&添加&更新&删除:
后台酒店列表&添加&更新:
后台线路列表&更新:
后台订单列表&订单审核:
后台旅行社列表:
后台用户列表:
1.启动Nginx
启动命令:nginx.exe
将两个前端页面【tour-front】和【tour】文件包拷贝到Nginx根目录下,修改./conf/nginx.conf配置文件,替换原有的server配置如下:
server {
listen 80;
server_name localhost;
location / {
root tour-front;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 8082;
server_name localhost;
location / {
root tour;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
关闭Nginx
nginx.exe -s stop
重启Nginx
nginx.exe -s reload
2.启动Mongodb
启动命令:net start mongoDB
3.启动Redis
启动命令:redis-server.exe --service-start --service-name redisserver
4.启动项目
#数据源
spring.datasource.url=jdbc:mysql://localhost:3306/tourismPro?useUnicode=true&zeroDateTimeBehavior=convertToNull&autoReconnect=true&characterEncoding=utf8
spring.datasource.username=你自己的MySQL账号
spring.datasource.password=你自己的MySQL密码
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
以下命令启动根目录下的mongodb-file-server.jar
java -jar mongodb-file-server.jar
5.view address访问地址
前台:http://localhost
后台:http://localhost:8082/index.html
注:使用我配置好的Nginx部署前端项目,通过我打包的jar直接启动后端项目
1.工具介绍:
2.前端部署:
3.后端部署:
java -jar tourismPro.jar
java -jar mongodb-file-server.jar
两个jar包启动都不报错则部署成功
4.验证:
打开浏览器访问地址
前台:http://localhost
后台:http://localhost:8082/index.html
在后台添加数据查看是否在前台正确展示
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。