2024年基于大数据的房价分析--4(1),2024年最新大数据开发进阶

img
img

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

public void executeRemove(Map<String,Object> condition,String dbname,String collname) {

}

}

2.service

//service接口

package Service;

import Dao.BaseDao;

import java.util.Map;

public interface BaseService {

public Object service(Map<String,Object> map, String dbName,String colName,int Number,int isDataLimit);

}

//service实现

package Service;

import Dao.BaseDao;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.stereotype.Component;

import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

import java.util.Map;

@Component(“cityService”)

public class CityService implements BaseService {

@Resource(name = “cityMapDao”)

private BaseDao dao;

public Object service(Map<String,Object> map, String dbName,String colName,int number,int isDataLimit) {

return dao.executeQuery(map,dbName,colName,number,isDataLimit);

}

}

3.bean类

package Beans;

import java.util.Date;

public class Location {

private String detailUrl;

private String address;

private Float size;

private String orient;

private String roomNum;

public void setDetailUrl(String detailUrl) {

this.detailUrl = detailUrl;

}

public void setAddress(String address) {

this.address = address;

}

public void setSize(Float size) {

this.size = size;

}

public void setOrient(String orient) {

this.orient = orient;

}

public void setRoomNum(String rooomNum) {

this.roomNum = rooomNum;

}

public void setUnitPrice(Float unitPrice) {

this.unitPrice = unitPrice;

}

public void setSumPrice(Float sumPrice) {

this.sumPrice = sumPrice;

}

public void setLn(Double ln) {

this.ln = ln;

}

public void setLat(Double lat) {

this.lat = lat;

}

public void setTime(Date time) {

this.time = time;

}

public void setCity(String city) {

this.city = city;

}

public String getDetailUrl() {

return detailUrl;

}

public String getAddress() {

return address;

}

public Float getSize() {

return size;

}

public String getOrient() {

return orient;

}

public String getRoomNum() {

return roomNum;

}

public Float getUnitPrice() {

return unitPrice;

}

public Float getSumPrice() {

return sumPrice;

}

public Double getLn() {

return ln;

}

public Double getLat() {

return lat;

}

public Date getTime() {

return time;

}

public String getCity() {

return city;

}

public String print(){

return “address:”+this.getAddress()+

“Size:”+this.getSize()+

“orient:”+this.getOrient()+

“detailUrl:”+this.getDetailUrl()+

“unitPrice:”+this.getUnitPrice()+

“sumPrice:”+this.getSumPrice()+

“RooomNum:”+this.getRoomNum()+

“Ln:”+this.getLn()+

“Lat:”+this.getLat()+

“Time:”+this.getTime();

}

private Float unitPrice;

private Float sumPrice;

private Double ln;

private Double lat;

private Date time;

private String city;

}

4.用于封装bean的util类

package Utils;

import org.bson.Document;

import Beans.Location;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

public class DumpClassUtil {

public static Location dumpLocation(Document doc){

Location location = new Location();

if(doc.containsKey(“address”)){

location.setAddress(doc.getString(“address”));

}

if(doc.containsKey(“city”)){

location.setCity(doc.getString(“city”));

}

if(doc.containsKey(“roomNum”)){

location.setRoomNum(doc.getString(“roomNum”));

}

if(doc.containsKey(“orient”)){

location.setOrient(doc.getString(“orient”));

}

if(doc.containsKey(“size”)){

try {

Float size = Float.parseFloat(doc.getString(“size”));

location.setSize(size);

}catch (Exception e){

return null;

}

}

if(doc.containsKey(“unitPrice”)){

try {

Float unitPrice = Float.parseFloat(doc.getString(“unitPrice”));

location.setUnitPrice(unitPrice);

}catch(Exception e){

return null;

}

}

if(doc.containsKey(“sumPrice”)){

try {

Float sumPrice = Float.parseFloat(doc.getString(“sumPrice”));

location.setSumPrice(sumPrice);

}catch(Exception e){

return null;

}

}

if(doc.containsKey(“ln”)){

Double ln = doc.getDouble(“ln”);

location.setLn(ln);

}

if(doc.containsKey(“lat”)){

Double lat = doc.getDouble(“lat”);

location.setLat(lat);

}

if(doc.containsKey(“time”)){

Double dateDouble = doc.getDouble(“time”);

SimpleDateFormat format = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);

try{

String dateString=format.format(dateDouble);

Date date = format.parse(dateString);

location.setTime(date);

}catch (ParseException e){

e.printStackTrace();

location.setTime(null);

}

}

return location;

}

}

5.用于获得数据库连接的util类

package Utils;

import com.mongodb.MongoClient;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.stereotype.Component;

@Component(“mongoUtil”)

public class MongoUtil {

private static MongoClient client;

@Value(“${ip}”)

private String IP;

@Value(“${port}”)

private String PORT;

public MongoClient getClient(){

if (this.client == null) {

this.client = new MongoClient(this.IP, Integer.parseInt(this.PORT));

}

return client;

}

public void closeClient(){

this.client.close();

this.client = null;

}

}

action

//action最初的父类

package Action;

import Service.BaseService;

import com.alibaba.fastjson.JSON;

import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import java.util.List;

import java.util.Map;

import java.util.TreeMap;

public class BaseAction {

protected BaseService service;

protected String dbName;

protected String colName;

@ResponseBody

public String datas(HttpServletRequest request, HttpServletResponse response){

String city = (String)request.getParameter(“city”);

Integer number = Integer.parseInt((String)request.getParameter(“number”));

int isdatalimit = Integer.parseInt((String)request.getParameter(“isDataLimit”));

Map<String,Object> query = new TreeMap<String,Object>();

if(city != null) {

query.put(“city”, city);

}else{

query = null;

}

List list = (List)this.service.service(query,this.dbName,this.colName,number,isdatalimit);

return JSON.toJSONString(list);

}

}

//地图action

package Action.house;

import Action.BaseAction;

import Service.BaseService;

import com.alibaba.fastjson.JSON;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import java.util.List;

import java.util.Map;

import java.util.TreeMap;

/**

  • Created by JACK on 2017/12/8.

*/

@Controller

@RequestMapping(value = “/house”)

public class CityMapAction extends BaseAction {

@Resource(name = “cityService”)

private void setService(BaseService service){

this.service = service;

}

img
img

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

vlet.http.HttpServletResponse;

import java.util.List;

import java.util.Map;

import java.util.TreeMap;

/**

  • Created by JACK on 2017/12/8.

*/

@Controller

@RequestMapping(value = “/house”)

public class CityMapAction extends BaseAction {

@Resource(name = “cityService”)

private void setService(BaseService service){

this.service = service;

}

[外链图片转存中…(img-J4i6Pxmk-1715582853544)]
[外链图片转存中…(img-iCAJjlyn-1715582853544)]

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 18
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值