Merge branch 'master' of http://gitlab.fangjia.com/dev0/main into script_gj
This commit is contained in:
@@ -21,6 +21,10 @@ spec:
|
||||
project: fangjia-bkoff
|
||||
app: fangjia
|
||||
spec:
|
||||
hostAliases:
|
||||
- ip: "192.168.0.38"
|
||||
hostnames:
|
||||
- "seaweed.db.fangjia.com"
|
||||
imagePullSecrets:
|
||||
- name: nexus-registry-secret
|
||||
nodeSelector:
|
||||
|
||||
+16
-4
@@ -106,7 +106,13 @@ public class EvaluationAuditController {
|
||||
if(eval!=null){
|
||||
bo.setHouseArea(eval.getHouseArea());
|
||||
bo.setDistrictName(eval.getDistrictName());
|
||||
bo.setAddress(eval.getAddress());
|
||||
String address = "";
|
||||
if(StringUtils.isNotBlank(eval.getCertificateAddress())){
|
||||
address = eval.getCertificateAddress();
|
||||
}else{
|
||||
address = eval.getAddress();
|
||||
}
|
||||
bo.setAddress(address);
|
||||
bo.setHouseNum(eval.getHouseNum());
|
||||
bo.setRoomNum(eval.getRoomNum());
|
||||
bo.setEvaluationDate(eval.getLastUpdated());
|
||||
@@ -115,7 +121,7 @@ public class EvaluationAuditController {
|
||||
bo.setFloorDesc(eval.getFloorDesc());
|
||||
bos.add(bo);
|
||||
|
||||
List<FjtEvaluation> evaluations = fjtEvaluationService.findAllFjtEvaluationByConditions(eval.getCity(), eval.getRegion(), eval.getAddress(), eval.getHouseNum(), eval.getRoomNum());
|
||||
List<FjtEvaluation> evaluations = fjtEvaluationService.findAllFjtEvaluationByConditions(eval.getCity(), eval.getRegion(), bo.getAddress(), eval.getHouseNum(), eval.getRoomNum());
|
||||
if(evaluations!=null && evaluations.size()>=2){
|
||||
List<String> ids = new ArrayList<String>();
|
||||
for(FjtEvaluation fjtEval : evaluations){
|
||||
@@ -148,7 +154,13 @@ public class EvaluationAuditController {
|
||||
BeanUtils.copyProperties(audit, bo);
|
||||
bo.setHouseArea(eval.getHouseArea());
|
||||
bo.setDistrictName(eval.getDistrictName());
|
||||
bo.setAddress(eval.getAddress());
|
||||
String address = "";
|
||||
if(StringUtils.isNotBlank(eval.getCertificateAddress())){
|
||||
address = eval.getCertificateAddress();
|
||||
}else{
|
||||
address = eval.getAddress();
|
||||
}
|
||||
bo.setAddress(address);
|
||||
bo.setHouseNum(eval.getHouseNum());
|
||||
bo.setRoomNum(eval.getRoomNum());
|
||||
bo.setEvaluationDate(eval.getLastUpdated());
|
||||
@@ -157,7 +169,7 @@ public class EvaluationAuditController {
|
||||
bo.setFloorDesc(eval.getFloorDesc());
|
||||
bos.add(bo);
|
||||
//根据地址,楼栋号判断是否是同一套房
|
||||
List<FjtEvaluation> evaluations = fjtEvaluationService.findAllFjtEvaluationByConditions(eval.getCity(), eval.getRegion(), eval.getAddress(), eval.getHouseNum(), eval.getRoomNum());
|
||||
List<FjtEvaluation> evaluations = fjtEvaluationService.findAllFjtEvaluationByConditions(eval.getCity(), eval.getRegion(), bo.getAddress(), eval.getHouseNum(), eval.getRoomNum());
|
||||
if(evaluations!=null && evaluations.size()>=2){
|
||||
List<String> ids = new ArrayList<String>();
|
||||
for(FjtEvaluation fjtEval : evaluations){
|
||||
|
||||
-5
@@ -6,8 +6,6 @@ import com.fangjia.core.util.DateUtil;
|
||||
import com.fangjia.dal.mongo.model.OperationLog;
|
||||
import com.fangjia.service.mongo.bkoff.OperationLogService;
|
||||
import org.sothis.core.util.Pager;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -28,7 +26,6 @@ public class OperationLogController{
|
||||
put( "block" , "板块" );
|
||||
put( "address" , "地址" );
|
||||
put( "loop_line_info" , "环线" );
|
||||
put( "loop_line_info" , "环线" );
|
||||
put( "estate_type2" , "物业类型" );
|
||||
put( "street_community" , "街道社区" );
|
||||
put( "household_count" , "户数" );
|
||||
@@ -58,7 +55,6 @@ public class OperationLogController{
|
||||
put( "house_height" , "楼高" );
|
||||
put( "lease_term","租赁年限");
|
||||
put( "payment_pattern","付款方式");
|
||||
put( "rent_price","出租价格");
|
||||
put( "sell_price","出售价格");
|
||||
put( "floor","建筑楼层");
|
||||
put( "floor_info","楼层状况");
|
||||
@@ -66,7 +62,6 @@ public class OperationLogController{
|
||||
put( "characteristic","项目特色");
|
||||
put( "bay_area","开间面积");
|
||||
put( "finish_building_date","竣工时间");
|
||||
put( "live_date","开业时间");
|
||||
put( "divisible","是否可分割");
|
||||
put( "unified_manage","是否统一管理");
|
||||
put( "metro_info","地铁沿线");
|
||||
|
||||
+1166
File diff suppressed because it is too large
Load Diff
+66
-2
@@ -3,6 +3,7 @@ package com.fangjia.bkoff.controllers;
|
||||
import com.fangjia.bkoff.model.JsonModel;
|
||||
import com.fangjia.bkoff.model.SeawaterModel;
|
||||
import com.fangjia.core.RegionData;
|
||||
import com.fangjia.dal.SeawaterQuery;
|
||||
import com.fangjia.dal.common.DistrictKey;
|
||||
import com.fangjia.dal.seawater.model.Seawater;
|
||||
import com.fangjia.dal.seaweed.dao.DistrictDao;
|
||||
@@ -13,6 +14,7 @@ import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.sothis.core.util.Pager;
|
||||
import org.sothis.web.mvc.annotation.Param;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
@@ -49,6 +51,8 @@ public class SeawaterController {
|
||||
pager.setTotalRows(0);
|
||||
}
|
||||
}else {
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
BeanUtils.copyProperties(model, query, new String[] {"sortField", "regionAlias", "districtAlias", "keys", "table"});
|
||||
String sort = model.getSort();
|
||||
String sortField = null;
|
||||
boolean order = false;
|
||||
@@ -62,6 +66,8 @@ public class SeawaterController {
|
||||
if (sortField == null) {
|
||||
sortField = "p_date";
|
||||
}
|
||||
query.setOrder(order);
|
||||
query.setSortField(sortField);
|
||||
|
||||
List<String> regionAlias = null;
|
||||
List<String> districtAlias = null;
|
||||
@@ -80,9 +86,15 @@ public class SeawaterController {
|
||||
regionAlias = RegionData.getRegionAlias(city, model.getRegion());
|
||||
}
|
||||
|
||||
query.setDistrictAlias(districtAlias);
|
||||
query.setRegionAlias(regionAlias);
|
||||
query.setTable("seawater");
|
||||
|
||||
// pager.setTotalRows((int) seawaterService.findSeawatersCountFromEs(model.getCat(), city, model.getRegion(),model.getDistrictName(), districtAlias, regionAlias, model.getStartDate(), model.getEndDate(), model.getRoom(), model.getRootName(),"seawater"));
|
||||
// List<Seawater> seawaterList = seawaterService.findSeawatersFromEs(model.getCat(), city, model.getRegion(),model.getDistrictName(), districtAlias, regionAlias, model.getStartDate(), model.getEndDate(), model.getRoom(), model.getRootName(), sortField, order, pager.getStartRow(), pager.getPageSize(), null,"seawater");
|
||||
pager.setTotalRows((int)seawaterService.findSeawatersCountByQuery(query));
|
||||
List<Seawater> seawaterList = seawaterService.findSeawatersByQuery(query);
|
||||
|
||||
pager.setTotalRows((int) seawaterService.findSeawatersCountFromEs(model.getCat(), city, model.getRegion(),model.getDistrictName(), districtAlias, regionAlias, model.getStartDate(), model.getEndDate(), model.getRoom(), model.getRootName(),"seawater"));
|
||||
List<Seawater> seawaterList = seawaterService.findSeawatersFromEs(model.getCat(), city, model.getRegion(),model.getDistrictName(), districtAlias, regionAlias, model.getStartDate(), model.getEndDate(), model.getRoom(), model.getRootName(), sortField, order, pager.getStartRow(), pager.getPageSize(), null,"seawater");
|
||||
Map<String, String> tagsMap = new HashMap<String, String>();
|
||||
for(Seawater seawater : seawaterList) {
|
||||
if(StringUtils.isBlank(seawater.getName())){
|
||||
@@ -125,6 +137,58 @@ public class SeawaterController {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按条件批量删除数据(小区名称只匹配主名不匹配别名,查询时匹配别名)
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
public Object batchDeleteByParamsAction(SeawaterModel model) {
|
||||
JsonModel ret = new JsonModel();
|
||||
|
||||
String city = model.getCityDisplay();
|
||||
if(StringUtils.isBlank(model.getCat())) {
|
||||
model.setCat("sell");
|
||||
}
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
BeanUtils.copyProperties(model, query, new String[] {"sortField", "regionAlias", "districtAlias", "keys", "table"});
|
||||
List<String> regionAlias = null;
|
||||
model.setDistrictName(model.getDistrictName().trim());
|
||||
if(StringUtils.isNotBlank(model.getRegion())) {
|
||||
regionAlias = RegionData.getRegionAlias(city, model.getRegion());
|
||||
}
|
||||
query.setRegionAlias(regionAlias);
|
||||
query.setTable("seawater");
|
||||
seawaterService.batchDeleteByParams(query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按条件批量修改物业类型(小区名称只匹配主名不匹配别名,查询时匹配别名)
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
public Object batchUpdateEstateTypeAction(SeawaterModel model) {
|
||||
JsonModel ret = new JsonModel();
|
||||
|
||||
String city = model.getCityDisplay();
|
||||
if(StringUtils.isBlank(model.getCat())) {
|
||||
model.setCat("sell");
|
||||
}
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
BeanUtils.copyProperties(model, query, new String[] {"sortField", "regionAlias", "districtAlias", "keys", "table"});
|
||||
List<String> regionAlias = null;
|
||||
model.setDistrictName(model.getDistrictName().trim());
|
||||
if(StringUtils.isNotBlank(model.getRegion())) {
|
||||
regionAlias = RegionData.getRegionAlias(city, model.getRegion());
|
||||
}
|
||||
query.setRegionAlias(regionAlias);
|
||||
query.setTable("seawater");
|
||||
seawaterService.batchUpdateEstateType(query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setSeawaterService(SeawaterService seawaterService) {
|
||||
this.seawaterService = seawaterService;
|
||||
}
|
||||
|
||||
+3
-3
@@ -102,7 +102,7 @@ public class SqMetreRentController {
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("x",DateUtil.add(rent.getWeekend(), 1).getTime());
|
||||
row.put("y",rent.getAvgPrice());
|
||||
row.put("sampleEnum",rent.getSampleEnum());
|
||||
row.put("sampleEnum",rent.getValueType());
|
||||
datas.add(row);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public class SqMetreRentController {
|
||||
Date statDate = DateUtil.parseFormatDate(model.getStatDate());
|
||||
SqmetreRent stat = sqmetreRentService.findSqmetreRent(model.getCityDisplay(), model.getRegion(), model.getDistrictName(), model.getCat(), statDate);
|
||||
if(null != stat){
|
||||
stat.setAvgPrice(model.getValue());
|
||||
stat.setAvgPrice(model.getValue().intValue());
|
||||
stat.setModificationDate(new Date());
|
||||
sqmetreRentService.updateSqmetreRent(stat);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class SqMetreRentController {
|
||||
rent.setDistrictName(model.getDistrictName());
|
||||
rent.setWeekend(statDate);
|
||||
rent.setCat(model.getCat());
|
||||
rent.setAvgPrice(model.getValue());
|
||||
rent.setAvgPrice(model.getValue().intValue());
|
||||
rent.setCreationDate(new Date());
|
||||
rent.setModificationDate(new Date());
|
||||
sqmetreRentService.save(rent);
|
||||
|
||||
+2
-2
@@ -362,8 +362,8 @@ public class YugudanController {
|
||||
if (model.getId()>0) {
|
||||
//FjtEvaluation evaluation = fjtEvaluationService.findEvaluationById(model.getId());
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
if(StringUtils.isNotBlank(model.getAddress())){
|
||||
data.put("address", model.getAddress());
|
||||
if(StringUtils.isNotBlank(model.getCertificateAddress())){
|
||||
data.put("certificateAddress", model.getCertificateAddress());
|
||||
}
|
||||
// if(model.getPeopleEditDate()!=null || model.getPeopleEditPrice()!=null){
|
||||
// data.put("peopleEdit", 1);
|
||||
|
||||
+3
-1
@@ -113,7 +113,9 @@ public class fjtEvaluationController {
|
||||
FjtEvaluation evaluation = fjtEvaluationService.findEvaluationById(Integer.parseInt(bo.getEvaluationId()));
|
||||
if(evaluation != null){
|
||||
String addr = "";
|
||||
if(evaluation.getAddress() != null){
|
||||
if(StringUtils.isNotBlank(evaluation.getCertificateAddress())){
|
||||
addr += evaluation.getCertificateAddress();
|
||||
}else if(evaluation.getAddress() != null){
|
||||
addr += evaluation.getAddress();
|
||||
}
|
||||
if(StringUtils.isNotBlank(evaluation.getHouseNum())){
|
||||
|
||||
+341
@@ -0,0 +1,341 @@
|
||||
package com.fangjia.bkoff.model;
|
||||
|
||||
import com.fangjia.dal.mongo.model.*;
|
||||
import com.fangjia.dal.mongo.model.bkoff.CalcCommand;
|
||||
import com.fangjia.dal.mongo.model.bkoff.CalcConfig;
|
||||
import com.fangjia.dal.mongo.model.bkoff.GuidingPrice;
|
||||
import com.fangjia.dal.seaweed.model.District;
|
||||
import com.fangjia.service.bo.AvgUpdateBo;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RentPriceUpdateModel extends BaseModel {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<AvgUpdateBo> avgUpdateBos;
|
||||
private Map<String, List<AvgUpdateBo>> avgUpdateBoMap;
|
||||
private String region;
|
||||
private String block;
|
||||
private String cityDisplay;
|
||||
private String id;
|
||||
private int avgPrice;
|
||||
private Double minCredit;
|
||||
private Double maxCredit;
|
||||
private Integer valueType;
|
||||
private String name;
|
||||
private District district;
|
||||
private List<AverageStatistics> averageStatistics;
|
||||
private List<AvgBase> avgBases;
|
||||
private CalcDistrictStat calcDistrictStat;
|
||||
private DistrictStat districtStat;
|
||||
private SqmetreRent sqmetreRent;
|
||||
private long dealPriceCount;
|
||||
private List<GuidingPrice> guidingPrices;
|
||||
private Map<String, Long> distribution;
|
||||
private CalcConfig calcConfig;
|
||||
private String stype;
|
||||
private String keyword;
|
||||
private Integer status;
|
||||
private List<CalcCommand> calcCommands;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date startDate;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date endDate;
|
||||
private String estateType;
|
||||
private String sort;
|
||||
private Date weekend;
|
||||
private int sdateStart;
|
||||
private int sdateEnd;
|
||||
private String series;
|
||||
private String vts;
|
||||
private String category;
|
||||
|
||||
public List<AvgUpdateBo> getAvgUpdateBos() {
|
||||
return avgUpdateBos;
|
||||
}
|
||||
|
||||
public void setAvgUpdateBos(List<AvgUpdateBo> avgUpdateBos) {
|
||||
this.avgUpdateBos = avgUpdateBos;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public String getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(String block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public String getCityDisplay() {
|
||||
return cityDisplay;
|
||||
}
|
||||
|
||||
public void setCityDisplay(String cityDisplay) {
|
||||
this.cityDisplay = cityDisplay;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getAvgPrice() {
|
||||
return avgPrice;
|
||||
}
|
||||
|
||||
public void setAvgPrice(int avgPrice) {
|
||||
this.avgPrice = avgPrice;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public District getDistrict() {
|
||||
return district;
|
||||
}
|
||||
|
||||
public void setDistrict(District district) {
|
||||
this.district = district;
|
||||
}
|
||||
|
||||
public List<AverageStatistics> getAverageStatistics() {
|
||||
return averageStatistics;
|
||||
}
|
||||
|
||||
public void setAverageStatistics(List<AverageStatistics> averageStatistics) {
|
||||
this.averageStatistics = averageStatistics;
|
||||
}
|
||||
|
||||
public long getDealPriceCount() {
|
||||
return dealPriceCount;
|
||||
}
|
||||
|
||||
public void setDealPriceCount(long dealPriceCount) {
|
||||
this.dealPriceCount = dealPriceCount;
|
||||
}
|
||||
|
||||
public List<GuidingPrice> getGuidingPrices() {
|
||||
return guidingPrices;
|
||||
}
|
||||
|
||||
public void setGuidingPrices(List<GuidingPrice> guidingPrices) {
|
||||
this.guidingPrices = guidingPrices;
|
||||
}
|
||||
|
||||
public Map<String, Long> getDistribution() {
|
||||
return distribution;
|
||||
}
|
||||
|
||||
public void setDistribution(Map<String, Long> distribution) {
|
||||
this.distribution = distribution;
|
||||
}
|
||||
|
||||
public CalcConfig getCalcConfig() {
|
||||
return calcConfig;
|
||||
}
|
||||
|
||||
public void setCalcConfig(CalcConfig calcConfig) {
|
||||
this.calcConfig = calcConfig;
|
||||
}
|
||||
|
||||
public String getStype() {
|
||||
return stype;
|
||||
}
|
||||
|
||||
public void setStype(String stype) {
|
||||
this.stype = stype;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public List<CalcCommand> getCalcCommands() {
|
||||
return calcCommands;
|
||||
}
|
||||
|
||||
public void setCalcCommands(List<CalcCommand> calcCommands) {
|
||||
this.calcCommands = calcCommands;
|
||||
}
|
||||
|
||||
public String getEstateType() {
|
||||
return estateType;
|
||||
}
|
||||
|
||||
public void setEstateType(String estateType) {
|
||||
this.estateType = estateType;
|
||||
}
|
||||
|
||||
public Map<String, List<AvgUpdateBo>> getAvgUpdateBoMap() {
|
||||
return avgUpdateBoMap;
|
||||
}
|
||||
|
||||
public void setAvgUpdateBoMap(Map<String, List<AvgUpdateBo>> avgUpdateBoMap) {
|
||||
this.avgUpdateBoMap = avgUpdateBoMap;
|
||||
}
|
||||
|
||||
public String getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(String sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public Double getMinCredit() {
|
||||
return minCredit;
|
||||
}
|
||||
|
||||
public void setMinCredit(Double minCredit) {
|
||||
this.minCredit = minCredit;
|
||||
}
|
||||
|
||||
public Double getMaxCredit() {
|
||||
return maxCredit;
|
||||
}
|
||||
|
||||
public void setMaxCredit(Double maxCredit) {
|
||||
this.maxCredit = maxCredit;
|
||||
}
|
||||
|
||||
public Integer getValueType() {
|
||||
return valueType;
|
||||
}
|
||||
|
||||
public void setValueType(Integer valueType) {
|
||||
this.valueType = valueType;
|
||||
}
|
||||
|
||||
public CalcDistrictStat getCalcDistrictStat() {
|
||||
return calcDistrictStat;
|
||||
}
|
||||
|
||||
public void setCalcDistrictStat(CalcDistrictStat calcDistrictStat) {
|
||||
this.calcDistrictStat = calcDistrictStat;
|
||||
}
|
||||
|
||||
public DistrictStat getDistrictStat() {
|
||||
return districtStat;
|
||||
}
|
||||
|
||||
public void setDistrictStat(DistrictStat districtStat) {
|
||||
this.districtStat = districtStat;
|
||||
}
|
||||
|
||||
public Date getWeekend() {
|
||||
return weekend;
|
||||
}
|
||||
|
||||
public void setWeekend(Date weekend) {
|
||||
this.weekend = weekend;
|
||||
}
|
||||
|
||||
|
||||
public int getSdateStart() {
|
||||
return sdateStart;
|
||||
}
|
||||
|
||||
public void setSdateStart(int sdateStart) {
|
||||
this.sdateStart = sdateStart;
|
||||
}
|
||||
|
||||
public int getSdateEnd() {
|
||||
return sdateEnd;
|
||||
}
|
||||
|
||||
public void setSdateEnd(int sdateEnd) {
|
||||
this.sdateEnd = sdateEnd;
|
||||
}
|
||||
|
||||
public String getSeries() {
|
||||
return series;
|
||||
}
|
||||
|
||||
public void setSeries(String series) {
|
||||
this.series = series;
|
||||
}
|
||||
|
||||
public String getVts() {
|
||||
return vts;
|
||||
}
|
||||
|
||||
public void setVts(String vts) {
|
||||
this.vts = vts;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public List<AvgBase> getAvgBases() {
|
||||
return avgBases;
|
||||
}
|
||||
|
||||
public void setAvgBases(List<AvgBase> avgBases) {
|
||||
this.avgBases = avgBases;
|
||||
}
|
||||
|
||||
|
||||
public SqmetreRent getSqmetreRent() {
|
||||
return sqmetreRent;
|
||||
}
|
||||
|
||||
public void setSqmetreRent(SqmetreRent sqmetreRent) {
|
||||
this.sqmetreRent = sqmetreRent;
|
||||
}
|
||||
}
|
||||
@@ -35,12 +35,19 @@ public class SeawaterModel extends BaseModel {
|
||||
private Seawater seawater;
|
||||
private List<Seawater> seawaterList;
|
||||
private Map<String, String> tagsMap;
|
||||
private Integer order;
|
||||
private Boolean order;
|
||||
private Integer StartDate;
|
||||
private Integer endDate;
|
||||
private String sort;
|
||||
private String url;
|
||||
private String rootName;
|
||||
private String estateType;
|
||||
private Double startArea;
|
||||
private Double endArea;
|
||||
private Integer startPrice;
|
||||
private Integer endPrice;
|
||||
private Integer status;
|
||||
private String editEstateType;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -156,10 +163,10 @@ public class SeawaterModel extends BaseModel {
|
||||
public void setCityDisplay(String cityDisplay) {
|
||||
this.cityDisplay = cityDisplay;
|
||||
}
|
||||
public Integer getOrder() {
|
||||
public Boolean getOrder() {
|
||||
return order;
|
||||
}
|
||||
public void setOrder(Integer order) {
|
||||
public void setOrder(Boolean order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
@@ -220,4 +227,60 @@ public class SeawaterModel extends BaseModel {
|
||||
public void setTagsMap(Map<String, String> tagsMap) {
|
||||
this.tagsMap = tagsMap;
|
||||
}
|
||||
|
||||
public String getEstateType() {
|
||||
return estateType;
|
||||
}
|
||||
|
||||
public void setEstateType(String estateType) {
|
||||
this.estateType = estateType;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getStartPrice() {
|
||||
return startPrice;
|
||||
}
|
||||
|
||||
public void setStartPrice(Integer startPrice) {
|
||||
this.startPrice = startPrice;
|
||||
}
|
||||
|
||||
public Integer getEndPrice() {
|
||||
return endPrice;
|
||||
}
|
||||
|
||||
public void setEndPrice(Integer endPrice) {
|
||||
this.endPrice = endPrice;
|
||||
}
|
||||
|
||||
public Double getStartArea() {
|
||||
return startArea;
|
||||
}
|
||||
|
||||
public void setStartArea(Double startArea) {
|
||||
this.startArea = startArea;
|
||||
}
|
||||
|
||||
public Double getEndArea() {
|
||||
return endArea;
|
||||
}
|
||||
|
||||
public void setEndArea(Double endArea) {
|
||||
this.endArea = endArea;
|
||||
}
|
||||
|
||||
public String getEditEstateType() {
|
||||
return editEstateType;
|
||||
}
|
||||
|
||||
public void setEditEstateType(String editEstateType) {
|
||||
this.editEstateType = editEstateType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,8 +150,10 @@ public class YugudanModel extends BaseModel{
|
||||
private String reportNum;
|
||||
|
||||
private Integer askPriceId;//人工询价id
|
||||
|
||||
|
||||
|
||||
private String certificateAddress;
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -861,7 +863,12 @@ public class YugudanModel extends BaseModel{
|
||||
public void setUnitNum(String unitNum) {
|
||||
this.unitNum = unitNum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getCertificateAddress() {
|
||||
return certificateAddress;
|
||||
}
|
||||
|
||||
public void setCertificateAddress(String certificateAddress) {
|
||||
this.certificateAddress = certificateAddress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,12 +90,12 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>价格类型</td>
|
||||
<td>估价类型</td>
|
||||
<td>
|
||||
<select id="slt_priceType" name="priceType" style="width: 100px">
|
||||
<option value=""></option>
|
||||
<option value="2B" <#if apiUserBo.priceType?? && apiUserBo.priceType?index_of("2B")!=-1>selected</#if>>2B</option>
|
||||
<option value="2C" <#if apiUserBo.priceType?? && apiUserBo.priceType?index_of("2C")!=-1>selected</#if>>2C</option>
|
||||
<option value="sell" <#if apiUserBo.priceType?? && apiUserBo.priceType?index_of("sell")!=-1>selected</#if>>挂牌价</option>
|
||||
<option value="evaluate" <#if apiUserBo.priceType?? && apiUserBo.priceType?index_of("evaluate")!=-1>selected</#if>>评估价</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -227,7 +227,7 @@
|
||||
<td colspan="2"><b>兔博士</b></td>
|
||||
</#if>
|
||||
|
||||
<#if (it.centanetNewPrice)?? || (it.centanetEsfPrice)??>
|
||||
<#if (it.zhongyuanNewPrice)?? || (it.zhongyuanEsfPrice)??>
|
||||
<td colspan="2"><b>中原地产</b></td>
|
||||
</#if>
|
||||
<#if (it.leyoujiaNewPrice)?? || (it.leyoujiaEsfPrice)??>
|
||||
@@ -247,7 +247,13 @@
|
||||
</#if>
|
||||
<#if (it.yungujiaNewPrice)?? || (it.yungujiaEsfPrice)??>
|
||||
<td colspan="2"><b>云估价</b></td>
|
||||
</#if>
|
||||
</#if>
|
||||
<#if (it.jiwuNewPrice)?? || (it.jiwuEsfPrice)??>
|
||||
<td colspan="2"><b>吉屋</b></td>
|
||||
</#if>
|
||||
<#if (it.tsfhouseNewPrice)?? || (it.tsfhouseEsfPrice)??>
|
||||
<td colspan="2"><b>365房产</b></td>
|
||||
</#if>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -300,7 +306,7 @@
|
||||
<td style="width:70px;color:#D3750A">二手房</td>
|
||||
</#if>
|
||||
|
||||
<#if (it.centanetNewPrice)?? || (it.centanetEsfPrice)??>
|
||||
<#if (it.zhongyuanNewPrice)?? || (it.zhongyuanEsfPrice)??>
|
||||
<td style="width:70px;color:#0C88C7">新房</td>
|
||||
<td style="width:70px;color:#D3750A">二手房</td>
|
||||
</#if>
|
||||
@@ -329,10 +335,17 @@
|
||||
</#if>
|
||||
<#if (it.yungujiaNewPrice)?? || (it.yungujiaEsfPrice)??>
|
||||
<td style="width:70px;color:#0C88C7">新房</td>
|
||||
<td style="width:70px;color:#D3750A">二手房</td>
|
||||
|
||||
<td style="width:70px;color:#D3750A">二手房</td>
|
||||
</#if>
|
||||
|
||||
<#if (it.jiwuNewPrice)?? || (it.jiwuEsfPrice)??>
|
||||
<td style="width:70px;color:#0C88C7">新房</td>
|
||||
<td style="width:70px;color:#D3750A">二手房</td>
|
||||
</#if>
|
||||
<#if (it.tsfhouseNewPrice)?? || (it.tsfhouseEsfPrice)??>
|
||||
<td style="width:70px;color:#0C88C7">新房</td>
|
||||
<td style="width:70px;color:#D3750A">二手房</td>
|
||||
</#if>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -392,9 +405,9 @@
|
||||
<td style ="color:#D3750A">${it.tuboshiEsfPrice!}</td>
|
||||
</#if>
|
||||
|
||||
<#if (it.centanetNewPrice)?? || (it.centanetEsfPrice)??>
|
||||
<td style ="color:#0C88C7">${it.centanetNewPrice!}</td>
|
||||
<td style ="color:#D3750A">${it.centanetEsfPrice!}</td>
|
||||
<#if (it.zhongyuanNewPrice)?? || (it.zhongyuanEsfPrice)??>
|
||||
<td style ="color:#0C88C7">${it.zhongyuanNewPrice!}</td>
|
||||
<td style ="color:#D3750A">${it.zhongyuanEsfPrice!}</td>
|
||||
</#if>
|
||||
|
||||
<#if (it.leyoujiaNewPrice)?? || (it.leyoujiaEsfPrice)??>
|
||||
@@ -422,7 +435,15 @@
|
||||
<td style ="color:#0C88C7">${it.yungujiaNewPrice!}</td>
|
||||
<td style ="color:#D3750A">${it.yungujiaEsfPrice!}</td>
|
||||
</#if>
|
||||
|
||||
<#if (it.jiwuNewPrice)?? || (it.jiwuEsfPrice)??>
|
||||
<td style ="color:#0C88C7">${it.jiwuNewPrice!}</td>
|
||||
<td style ="color:#D3750A">${it.jiwuEsfPrice!}</td>
|
||||
</#if>
|
||||
<#if (it.tsfhouseNewPrice)?? || (it.tsfhouseEsfPrice)??>
|
||||
<td style ="color:#0C88C7">${it.tsfhouseNewPrice!}</td>
|
||||
<td style ="color:#D3750A">${it.tsfhouseEsfPrice!}</td>
|
||||
</#if>
|
||||
|
||||
</tr>
|
||||
</#list>
|
||||
<#if averageStatistics?size == 0>
|
||||
@@ -724,19 +745,59 @@
|
||||
});
|
||||
var series = new Array();
|
||||
series[0] = {
|
||||
name:"房源散列图",
|
||||
name:"房源散列图-普通住宅",
|
||||
data:new Array()
|
||||
//color:"#660099"
|
||||
}
|
||||
series[1] = {
|
||||
name:"房源散列图-商住",
|
||||
data:new Array(),
|
||||
color:"#12990f"
|
||||
}
|
||||
series[2] = {
|
||||
name:"房源散列图-别墅",
|
||||
data:new Array(),
|
||||
color:"#992632"
|
||||
}
|
||||
var series_arry_0 = []
|
||||
var series_arry_1 = []
|
||||
var series_arry_2 = []
|
||||
$(data).each(function(i,item){
|
||||
var pdate = item.pDate + "";
|
||||
var ds = pdate.substring(0, 4) + '-' + pdate.substring(4, 6) + '-' + pdate.substring(6)
|
||||
series[0].data.push({
|
||||
x:new Date(ds),
|
||||
y:Math.round(item.totalPrice/item.area),
|
||||
data:item
|
||||
})
|
||||
if ((item.estateType!=null) && (item.estateType.indexOf('别墅') > -1)){
|
||||
series_arry_2.push({
|
||||
x:new Date(ds),
|
||||
y:Math.round(item.totalPrice/item.area),
|
||||
data:item
|
||||
})
|
||||
}else if((item.estateType!=null) && ((item.estateType.indexOf('商住') > -1) || (item.estateType.indexOf('商业') > -1) || (item.estateType.indexOf('商务') > -1) || (item.estateType.indexOf('公寓酒店') > -1))){
|
||||
series_arry_1.push({
|
||||
x:new Date(ds),
|
||||
y:Math.round(item.totalPrice/item.area),
|
||||
data:item
|
||||
})
|
||||
}else{
|
||||
series_arry_0.push({
|
||||
x:new Date(ds),
|
||||
y:Math.round(item.totalPrice/item.area),
|
||||
data:item
|
||||
})
|
||||
}
|
||||
// series[0].data.push({
|
||||
// x:new Date(ds),
|
||||
// y:Math.round(item.totalPrice/item.area),
|
||||
// data:item
|
||||
// })
|
||||
// series[1].data.push({
|
||||
// x:new Date(ds),
|
||||
// y:Math.round(item.totalPrice/item.area),
|
||||
// data:item
|
||||
// })
|
||||
});
|
||||
series[0].data = series_arry_0
|
||||
series[1].data = series_arry_1
|
||||
series[2].data = series_arry_2
|
||||
$('#houseChart').highcharts({
|
||||
chart: {
|
||||
type: 'scatter',
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<label class="checkbox"><input type="checkbox" id="col13" temp="13" rank="1" name="chkCol">Mapabc经纬度覆盖率</label>
|
||||
<label class="checkbox"><input type="checkbox" id="col14" temp="14" rank="1" name="chkCol" checked>百度经纬度覆盖率</label>
|
||||
<label class="checkbox"><input type="checkbox" id="col15" temp="15" rank="1" name="chkCol" checked>统计周</label>
|
||||
<label class="checkbox"><input type="checkbox" id="col16" temp="16" rank="1" name="chkCol" checked>租金覆盖率</label>
|
||||
<#-- <label class="checkbox"><input type="checkbox" id="col16" temp="16" rank="1" name="chkCol" checked>租金覆盖率</label>-->
|
||||
<label class="checkbox"><input type="checkbox" id="col17" temp="17" rank="1" name="chkCol" checked>等级</label>
|
||||
|
||||
<div style="float: right;">
|
||||
@@ -234,7 +234,7 @@
|
||||
</th>
|
||||
<th width="6.25%" name="col13" class="dn">Mapabc经纬度<br/>覆盖率</th>
|
||||
<th width="6.25%" name="col14" >百度经纬度<br/>覆盖率</th>
|
||||
<th width="6.25%" name="col16">租金覆盖率</th>
|
||||
<#-- <th width="6.25%" name="col16">租金覆盖率</th>-->
|
||||
<th width="6.25%" name="col15">统计周</th>
|
||||
|
||||
</tr>
|
||||
@@ -269,7 +269,7 @@
|
||||
<td width="6.25%" name="col12" class="dn"><#if info.priceToEva??>${info.priceToEva * 100}%<#else>未知</#if></td>
|
||||
<td width="6.25%" name="col13" class="dn"><#if info.districtDetail.latLng??>${info.districtDetail.latLng * 100}%<#else>未知</#if></td>
|
||||
<td width="6.25%" name="col14"><#if info.districtDetail.latLng2??>${info.districtDetail.latLng2 * 100}%<#else>未知</#if></td>
|
||||
<td width="6.25%" name="col16"><#if info.districtDetail.rentPrice??>${info.districtDetail.rentPrice * 100}%<#else>未知</#if></td>
|
||||
<#-- <td width="6.25%" name="col16"><#if info.districtDetail.rentPrice??>${info.districtDetail.rentPrice * 100}%<#else>未知</#if></td>-->
|
||||
<td width="6.25%" name="col15">${info.weekend?string('yyyy-MM-dd')} <a href="../data/cityShow?infoId=${info.id!}" target="_blank">详细</a></td>
|
||||
</tr>
|
||||
</#list>
|
||||
@@ -306,7 +306,7 @@
|
||||
<label class="checkbox"><input type="checkbox" id="col13" temp="13" rank="1" name="chkCol">Mapabc经纬度覆盖率</label>
|
||||
<label class="checkbox"><input type="checkbox" id="col14" temp="14" rank="1" name="chkCol" checked>百度经纬度覆盖率</label>
|
||||
<label class="checkbox"><input type="checkbox" id="col15" temp="15" rank="1" name="chkCol" checked>统计周</label>
|
||||
<label class="checkbox"><input type="checkbox" id="col16" temp="16" rank="1" name="chkCol" checked>租金覆盖率</label>
|
||||
<#-- <label class="checkbox"><input type="checkbox" id="col16" temp="16" rank="1" name="chkCol" checked>租金覆盖率</label>-->
|
||||
<label class="checkbox"><input type="checkbox" id="col17" temp="17" rank="1" name="chkCol" checked>等级</label>
|
||||
|
||||
<span style="float: right; margin-right: 50px;"><img src="../images/script-excel.png"><a id="export" style="cursor:pointer;">导出</a>
|
||||
@@ -444,7 +444,7 @@
|
||||
</th>
|
||||
<th width="6.25%" name="col13" class="dn">Mapabc经纬度<br/>覆盖率</th>
|
||||
<th width="6.25%" name="col14" >百度经纬度<br/>覆盖率</th>
|
||||
<th width="6.25%" name="col16">租金覆盖率</th>
|
||||
<#-- <th width="6.25%" name="col16">租金覆盖率</th>-->
|
||||
<th width="6.25%" name="col15">统计周</th>
|
||||
|
||||
</tr>
|
||||
@@ -478,7 +478,7 @@
|
||||
<td width="6.25%" name="col12" class="dn"><#if info.priceToEva??>${info.priceToEva * 100}%<#else>未知</#if></td>
|
||||
<td width="6.25%" name="col13" class="dn"><#if info.shopDetail.latLng??>${info.shopDetail.latLng * 100}%<#else>未知</#if></td>
|
||||
<td width="6.25%" name="col14"><#if info.shopDetail.latLng2??>${info.shopDetail.latLng2 * 100}%<#else>未知</#if></td>
|
||||
<td width="6.25%" name="col16"><#if info.shopDetail.rentPrice??>${info.shopDetail.rentPrice * 100}%<#else>0</#if></td>
|
||||
<#-- <td width="6.25%" name="col16"><#if info.shopDetail.rentPrice??>${info.shopDetail.rentPrice * 100}%<#else>0</#if></td>-->
|
||||
<td width="6.25%" name="col15">${info.weekend?string('yyyy-MM-dd')} <a href="../data/cityShow?infoId=${info.id!}#lB" target="_blank">详细</a></td>
|
||||
</tr>
|
||||
</#list>
|
||||
@@ -515,7 +515,7 @@
|
||||
<label class="checkbox"><input type="checkbox" id="col13" temp="13" rank="1" name="chkCol">Mapabc经纬度覆盖率</label>
|
||||
<label class="checkbox"><input type="checkbox" id="col14" temp="14" rank="1" name="chkCol" checked>百度经纬度覆盖率</label>
|
||||
<label class="checkbox"><input type="checkbox" id="col15" temp="15" rank="1" name="chkCol" checked>统计周</label>
|
||||
<label class="checkbox"><input type="checkbox" id="col16" temp="16" rank="1" name="chkCol" checked>租金覆盖率</label>
|
||||
<#-- <label class="checkbox"><input type="checkbox" id="col16" temp="16" rank="1" name="chkCol" checked>租金覆盖率</label>-->
|
||||
<label class="checkbox"><input type="checkbox" id="col17" temp="17" rank="1" name="chkCol" checked>等级</label>
|
||||
|
||||
<span style="float: right; margin-right: 50px;"><img src="../images/script-excel.png"><a id="export" style="cursor:pointer;">导出</a>
|
||||
@@ -653,7 +653,7 @@
|
||||
</th>
|
||||
<th width="6.25%" name="col13" class="dn">Mapabc经纬度<br/>覆盖率</th>
|
||||
<th width="6.25%" name="col14" >百度经纬度<br/>覆盖率</th>
|
||||
<th width="6.25%" name="col16">租金覆盖率</th>
|
||||
<#-- <th width="6.25%" name="col16">租金覆盖率</th>-->
|
||||
<th width="6.25%" name="col15">统计周</th>
|
||||
|
||||
</tr>
|
||||
@@ -687,7 +687,7 @@
|
||||
<td width="6.25%" name="col12" class="dn"><#if info.priceToEva??>${info.priceToEva * 100}%<#else>未知</#if></td>
|
||||
<td width="6.25%" name="col13" class="dn"><#if info.officeDetail.latLng??>${info.officeDetail.latLng * 100}%<#else>未知</#if></td>
|
||||
<td width="6.25%" name="col14"><#if info.officeDetail.latLng2??>${info.officeDetail.latLng2 * 100}%<#else>未知</#if></td>
|
||||
<td width="6.25%" name="col16"><#if info.officeDetail.rentPrice??>${info.officeDetail.rentPrice * 100}%<#else>0</#if></td>
|
||||
<#-- <td width="6.25%" name="col16"><#if info.officeDetail.rentPrice??>${info.officeDetail.rentPrice * 100}%<#else>0</#if></td>-->
|
||||
<td width="6.25%" name="col15">${info.weekend?string('yyyy-MM-dd')} <a href="../data/cityShow?infoId=${info.id!}#lC" target="_blank">详细</a></td>
|
||||
</tr>
|
||||
</#list>
|
||||
|
||||
@@ -686,6 +686,7 @@
|
||||
<a target="_blank" href="../district/districtNearby?id=${district.id}&cityDisplay=${cityDisplay!}">配套</a>
|
||||
</#if>
|
||||
<a target="_blank" href="../avgPriceUpdate/districtDetail?id=${district.id}">均价</a>
|
||||
<a target="_blank" href="../rentPriceUpdate/districtDetail?id=${district.id}">租金</a>
|
||||
<a target="_blank" href="../seawater/houseList?cityDisplay=${district.city!}®ion=${district.region!}&districtName=${district.name!}">样本</a>
|
||||
<a target="_blank" href="http://192.168.0.65/fangjia-coredata-bkoff/analy/analyDistrictDetailList?city=${district.city!}®ion=${district.region!}&districtName=${district.name!}">数据对比</a>
|
||||
<a target="_blank" href="../district/add?id=${district.id}">复制</a>
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
<tbody>
|
||||
<#list loudongList! as loudong>
|
||||
<tr>
|
||||
<td width="4%">
|
||||
<td width="9%">
|
||||
${loudong.districtNo!''}
|
||||
</td>
|
||||
<td width="4%">
|
||||
|
||||
@@ -0,0 +1,470 @@
|
||||
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
|
||||
<#compress>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>${cityDisplay}<#if region?? && region!=''>-${region}<#if block?? && block!=''>-${block}</#if></#if> 城市租金详细信息</title>
|
||||
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/main_simple.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/pagination.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/jnotify/jNotify.jquery.css?v=${version}" />
|
||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||
<#include "/common_js.ftl" />
|
||||
<script type="text/javascript" src="../js/jquery-1.9.1.js"></script>
|
||||
<script type="text/javascript" src="../js/jquery.pagination.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/highcharts-3.0.7.js"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/exporting-3.0.7.js"></script>
|
||||
<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="../js/jNotify.jquery.min.js?v=${version}"></script>
|
||||
<style>
|
||||
.con {
|
||||
border-radius:0px;
|
||||
}
|
||||
label{display:inline-block}
|
||||
.input-small{
|
||||
margin:0px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<#include "/layout/header.ftl" />
|
||||
<div class="main-content" style="padding:0px 10px;">
|
||||
<form action="detail">
|
||||
<table class="table table-bordered table-condensed con" style="margin-top: 4px">
|
||||
<tr>
|
||||
<th colspan="2">查询条件</th><th colspan="2">租金更新</th><th colspan="2">租金新增</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="region">城市:</label>
|
||||
</td>
|
||||
<td>
|
||||
<@d_city defaultValue="${cityDisplay!}" callback="changeCity" callbackField="display" name="cityDisplay"/>
|
||||
</td>
|
||||
<td>
|
||||
日期:
|
||||
</td>
|
||||
<td>
|
||||
<label id="dateLabel"></label>
|
||||
</td>
|
||||
<td>
|
||||
新增日期:
|
||||
</td>
|
||||
<td>
|
||||
<input id="shortDate" style="width:80px;" name="shortDate" value="${shortDate!}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="region">区域:</label>
|
||||
</td>
|
||||
<td>
|
||||
<select id="region" name="region" class="form-control" onchange="changeRegion()">
|
||||
<option value="">不限</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
覆盖率:
|
||||
</td>
|
||||
<td>
|
||||
<label id="coverageLabel"></label>
|
||||
</td>
|
||||
<td>
|
||||
覆盖率:
|
||||
</td>
|
||||
<td>
|
||||
<label>0</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="region">板块:</label>
|
||||
</td>
|
||||
<td>
|
||||
<select id="block" name="block" class="form-control">
|
||||
<option value="">不限</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
可信度:
|
||||
</td>
|
||||
<td>
|
||||
<label id="creditLabel"></label>
|
||||
</td>
|
||||
<td>
|
||||
可信度:
|
||||
</td>
|
||||
<td>
|
||||
<label id="creditLabel2"></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td><label for="avgPrice">租金/计算租金:</label></td>
|
||||
<td>
|
||||
<input type="hidden" id="_id">
|
||||
<input type="text" id="avgPrice" class=".span1" style="margin-bottom: 0px;"> /
|
||||
<span id="calcValueLabel" style="width:100px;display:inline-block;"></span>
|
||||
</td>
|
||||
<td><label for="avgPrice">租金:</label></td>
|
||||
<td>
|
||||
<input type="hidden" id="_region" value="${region!}">
|
||||
<input type="hidden" id="_city" value="${cityDisplay!}">
|
||||
<input type="hidden" id="_block" value="${block!}">
|
||||
<input type="text" id="avgPrice2" class=".span1" style="margin-bottom: 0px;">
|
||||
<span id="calcValueLabel2" style="width:100px;display:inline-block;"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input id="queryBtn" class ="btn btn-primary" type="submit" value="查询" /></td>
|
||||
<td colspan="2">
|
||||
<a href="#myModal" role="button" class="btn btn-primary" onclick="updateAvgPriveOpener()" >更新租金</a>
|
||||
<a href="javascript:;" role="button" class="btn btn-primary" onclick="javascript:if(confirm('确认删除?')){$.get('../rentPriceUpdate/delete?id=' + $('#_id').val(), function(){location.reload();})}" >删除</a>
|
||||
</td>
|
||||
<td colspan="2">
|
||||
<a href="#myModal2" role="button" class="btn btn-primary" onclick="confirmAddAvgPrice()" >新增价格</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<div id="myModal" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>提示</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>确定要更新租金?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal">关闭</a>
|
||||
<a href="#" class="btn btn-warning" onclick="updateAvgPrice()">更新</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="myModal2" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>提示</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>确定要新增租金?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal">关闭</a>
|
||||
<a href="#" class="btn btn-warning" onclick="addAvgPrice()">确定</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<ul class="nav nav-tabs" id="myTab" style="height: 30px;">
|
||||
<li class="active" data-toggle="tab"><a href="#container">走势图</a></li>
|
||||
<li data-toggle="tab"><a href="#DataTab">数据表</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div id="container" class="tab-pane active"></div>
|
||||
<div id="DataTab" class="tab-pane">
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>日期</td><td>租金</td><td>计算租金</td><td>周同比</td><td>可信度</td><td>覆盖率</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="Searchresult">
|
||||
</tbody>
|
||||
<tfoot >
|
||||
<tr>
|
||||
<td colspan="6"><div id="Pagination" class="pagination"></div></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<script type="text/javascript">
|
||||
var selectCity = '${cityDisplay!}';
|
||||
var selectRegion = '${region!}'
|
||||
var selectBlock = '${block!}'
|
||||
function changeCity(display){
|
||||
selectCity = display;
|
||||
if (display) {
|
||||
$("#display").val(display);
|
||||
}
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '../district/getRegions',
|
||||
data: encodeURI("cityDisplay=" + display),
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
$("#region").empty();
|
||||
if (model.regionList.length > 0) {
|
||||
$("<option value=''>不限</option>").appendTo($("#region"));
|
||||
$.each(model.regionList, function(i, region){
|
||||
if(selectRegion == region){
|
||||
$("<option value='" + region + "' selected>" + region + "</option>").appendTo($("#region"));
|
||||
}else{
|
||||
$("<option value='" + region + "' >" + region + "</option>").appendTo($("#region"));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error : function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
function changeRegion(r){
|
||||
var selectRegion = $("#region option:selected").text();
|
||||
if(r!=undefined){
|
||||
selectRegion = r;
|
||||
}
|
||||
$("#block").empty();
|
||||
if(region==="不限"){
|
||||
$("<option value=''>不限</option>").appendTo($("#block"));
|
||||
}
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '../district/getBlocks',
|
||||
data: {cityDisplay:selectCity,region:selectRegion},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
$("#block").empty();
|
||||
if (model.blockList.length > 0) {
|
||||
$("<option value=''>不限</option>").appendTo($("#block"));
|
||||
$.each(model.blockList, function(i, block){
|
||||
if(selectBlock == block){
|
||||
$("<option value='" + block + "' selected>" + block + "</option>").appendTo($("#block"));
|
||||
}else{
|
||||
$("<option value='" + block + "' >" + block + "</option>").appendTo($("#block"));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error : function() {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
changeCity('${cityDisplay!}');
|
||||
if(selectRegion !==''){
|
||||
changeRegion(selectRegion);
|
||||
}
|
||||
|
||||
|
||||
function pageselectCallback(page_index, opts){
|
||||
var pageNum = page_index + 1;
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../rentPriceUpdate/loadAllAvgPrice',
|
||||
data: {"cityName":selectCity,region:selectRegion,block:selectBlock,"pager.currentPage":pageNum,"pager.pageSize":10,"pager.totalRows":opts.items_total},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
async:false,
|
||||
success: function(model) {
|
||||
var newcontent = ''
|
||||
opts.items_total = model.pager.totalRows;
|
||||
$(model.data).each(function(i,item){
|
||||
newcontent += '<tr data-id=='+item.id+'><td>'+item.weekend+'</td>'
|
||||
+ '<td>'+item.avgPrice+'</td>'
|
||||
+ '<td>'+item.calcValue+'</td>'
|
||||
+ '<td>' + item.weekendMarkup + '</td>'
|
||||
+ '<td>' + item.credit + '</td>'
|
||||
+ '<td>'+item.coverage+'</td></tr>'
|
||||
});
|
||||
$('#Searchresult').html(newcontent);
|
||||
$('#Searchresult tr').click(function(){
|
||||
var tds = $(this).children()
|
||||
$("#dateLabel").text(tds[0].innerText);
|
||||
$("#coverageLabel").text(tds[5].innerText);
|
||||
$("#creditLabel").text(tds[4].innerText);
|
||||
$("#calcValueLabel").text(tds[2].innerText);
|
||||
$("#avgPrice").val(tds[1].innerText);
|
||||
$("#_id").val($(this).attr("data-id"));
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function updateAvgPriveOpener(){
|
||||
if($("#_id").val()==undefined||$("#_id").val()===""){
|
||||
alert("请选择要更新的时间点");
|
||||
return;
|
||||
}
|
||||
$('#myModal').modal('show')
|
||||
}
|
||||
|
||||
function confirmAddAvgPrice(){
|
||||
$('#myModal2').modal('show')
|
||||
}
|
||||
|
||||
function updateAvgPrice(){
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../rentPriceUpdate/updateAvgPrice',
|
||||
data: {"id":$("#_id").val(),avgPrice:$("#avgPrice").val()},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
$('#myModal').modal('hide')
|
||||
showSuccessMsg("更新成功");
|
||||
initChart();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addAvgPrice(){
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../rentPriceUpdate/addAvgPrice',
|
||||
data: {"cityDisplay":$("#_city").val(), "region" : $("#_region").val(), "block" : $("#_block").val(), "weekend" : $("#shortDate").val(), avgPrice:$("#avgPrice2").val()},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
alert(model.msg);
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initChart(){
|
||||
var data
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../rentPriceUpdate/loadAllAvgPriceForChart',
|
||||
data: {"cityName":selectCity,region:selectRegion,block:selectBlock},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
async:false,
|
||||
success: function(model) {
|
||||
data = model.data;
|
||||
}
|
||||
});
|
||||
var series = new Array();
|
||||
series[0] = {
|
||||
name:"租金",
|
||||
data:new Array(),
|
||||
//color:"#660099",
|
||||
events:{
|
||||
click:function(event){
|
||||
var item = event.point.data;
|
||||
$("#dateLabel").text(item.weekend);
|
||||
$("#coverageLabel").text(item.coverage);
|
||||
$("#creditLabel").text(item.credit);
|
||||
$("#calcValueLabel").text(item.calcValue);
|
||||
$("#avgPrice").val(item.avgPrice);
|
||||
$("#_id").val(item.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
series[1] = {
|
||||
name:"计算租金",
|
||||
data:new Array(),
|
||||
color:"#55AC8C",
|
||||
visible: false,
|
||||
events:{
|
||||
click:function(event){
|
||||
var item = event.point.data;
|
||||
$("#dateLabel").text(item.weekend);
|
||||
$("#coverageLabel").text(item.coverage);
|
||||
$("#creditLabel").text(item.credit);
|
||||
$("#calcValueLabel").text(item.calcValue);
|
||||
$("#avgPrice").val(item.avgPrice);
|
||||
$("#_id").val(item.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
$(data).each(function(i,item){
|
||||
var y = item.weekend.split("-")[0]
|
||||
var m = item.weekend.split("-")[1] -1
|
||||
var d = item.weekend.split("-")[2]
|
||||
series[0].data.push({
|
||||
x:Date.UTC(y, m, d),
|
||||
y:item.avgPrice,
|
||||
data:item
|
||||
})
|
||||
if(item.calcValue!=0){
|
||||
series[1].data.push({
|
||||
x:Date.UTC(y, m, d),
|
||||
y:item.calcValue,
|
||||
data:item
|
||||
})
|
||||
}
|
||||
});
|
||||
$('#container').highcharts({
|
||||
chart: {
|
||||
zoomType:"xy",
|
||||
height: 700,
|
||||
},
|
||||
title: {
|
||||
text: '${cityDisplay!}<#if region??>-${region!}</#if><#if block??>-${block!}</#if> 租金走势图'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'datetime',
|
||||
dateTimeLabelFormats: { // don't display the dummy year
|
||||
month: '%y-%m-%e',
|
||||
year: '%b'
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
title: {
|
||||
text: '租金(元/平米)'
|
||||
},
|
||||
min: 0
|
||||
},
|
||||
tooltip: {
|
||||
crosshairs: true,
|
||||
formatter: function() {
|
||||
return '<b>'+ this.series.name +'</b><br/>'+
|
||||
Highcharts.dateFormat('%y-%m-%e', this.x) +': '+ this.y +' 元/平米';
|
||||
}
|
||||
},
|
||||
series:series
|
||||
});
|
||||
|
||||
}
|
||||
function showSuccessMsg(msg){
|
||||
jNotify(
|
||||
msg,
|
||||
{
|
||||
autoHide : true,
|
||||
clickOverlay : false,
|
||||
MinWidth : 250,
|
||||
TimeShown : 2000,
|
||||
ShowTimeEffect : 1000,
|
||||
HideTimeEffect : 1000,
|
||||
LongTrip :20,
|
||||
HorizontalPosition : 'right',
|
||||
VerticalPosition : 'top',
|
||||
ShowOverlay : true,
|
||||
ColorOverlay : '#000',
|
||||
OpacityOverlay : 0.3,
|
||||
onClosed : function(){
|
||||
|
||||
},
|
||||
onCompleted : function(){
|
||||
}
|
||||
});
|
||||
}
|
||||
$(function(){
|
||||
$("#Pagination").pagination({
|
||||
callback:pageselectCallback,
|
||||
prev_text:"上一页",
|
||||
next_text:"下一页",
|
||||
items_per_page:10,
|
||||
num_display_entries:5,
|
||||
num_edge_entries:5,
|
||||
items_total:-1
|
||||
});
|
||||
initChart();
|
||||
$('#myTab a').click(function (e) {
|
||||
e.preventDefault();
|
||||
$(this).tab('show');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</#compress>
|
||||
@@ -0,0 +1,946 @@
|
||||
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
|
||||
<#compress>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title><#if district??>${district.name!}</#if> 租金详细信息</title>
|
||||
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/main_simple.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/pagination.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/jnotify/jNotify.jquery.css?v=${version}" />
|
||||
<#include "/common_js.ftl" />
|
||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||
<script type="text/javascript" src="../js/jquery-1.9.1.js"></script>
|
||||
<script type="text/javascript" src="../js/jquery.pagination.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/highcharts-3.0.7.js"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/exporting-3.0.7.js"></script>
|
||||
<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="../js/jNotify.jquery.min.js?v=${version}"></script>
|
||||
<style>
|
||||
.con {
|
||||
border-radius:0px;
|
||||
}
|
||||
label{display:inline-block}
|
||||
.input-small{
|
||||
margin:0px;
|
||||
}
|
||||
.prettyprint {
|
||||
padding: 8px;
|
||||
background-color: #f7f7f9;
|
||||
border: 1px solid #e1e1e8;
|
||||
}
|
||||
i:hover{
|
||||
cursor:pointer;
|
||||
}
|
||||
.ac td{
|
||||
text-align:center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.ac th{
|
||||
text-align:center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<#include "/layout/header.ftl" />
|
||||
<div class="main-content" style="padding:10px 10px;">
|
||||
<p class="prettyprint" style="text-align: center;">
|
||||
<strong style="font-size:18px;">
|
||||
<a href="../rentPriceUpdate/districtList?cityDisplay=${district.city!}">${district.city!}</a>-
|
||||
<a href="../rentPriceUpdate/districtList?cityDisplay=${district.city!}®ion=${district.region!}">${district.region!}</a>-
|
||||
${district.name!}(${district.estateType2!})
|
||||
</strong>租金详细信息
|
||||
<span style="float:right;font-size: 12px;"><a onclick="javascript:$('#myReCompModal').modal('show')" href="javascript:;">重算租金</a></span>
|
||||
</p>
|
||||
<br>
|
||||
<p class="prettyprint" style="text-align: left;">
|
||||
<#if sqmetreRent??>
|
||||
最新(<b>${t_util.formatDate(sqmetreRent.weekend!)}</b>)
|
||||
租金:<b style="color:red;">${sqmetreRent.avgPrice!}</b>元/平米
|
||||
<#-- 2B租金:<b style="color:red;">${districtStat.avg_price_2b!}</b>元/平米 -->
|
||||
计算方式:
|
||||
<#if (sqmetreRent.valueType)??>
|
||||
<#if sqmetreRent.valueType=='own'>
|
||||
自身样本
|
||||
</#if>
|
||||
<#if sqmetreRent.valueType=='around'>
|
||||
周边
|
||||
</#if>
|
||||
</#if>
|
||||
可信度:${(sqmetreRent.credit!)?string("#.#######")}
|
||||
<#if sqmetreRent.markup??>
|
||||
环比上月:<#if sqmetreRent.markup gt 0><b style="color:red">↑</b><#elseif sqmetreRent.markup lt 0><b style="color:green">↓</b></#if><b>${(sqmetreRent.markup!/100.0)?string("#.##")}%</b>
|
||||
</#if>
|
||||
<#else>
|
||||
本月租金暂无
|
||||
</#if>
|
||||
</p>
|
||||
<br>
|
||||
<p class="prettyprint"><strong>${district.name!}-价格走势图</strong></p>
|
||||
<div id="myModal" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>提示</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>确定要更新租金?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal">关闭</a>
|
||||
<a href="#" class="btn btn-warning" onclick="updateAvgPrice()">更新</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="container"></div>
|
||||
|
||||
<#-- <div style="width:19%;float:left;">-->
|
||||
<#-- <p class="prettyprint"><strong><a name="guiding"></a>${district.name!}-指导价</strong></p>-->
|
||||
<#-- <div style="border: 1px solid #e1e1e8;margin-bottom: 3px;margin-top: 2px;padding-left:1px;padding-top: 3px;">-->
|
||||
<#-- <table class="table table-bordered" style="width:<#if 120 * (guidingPrices?size+1) lt 300>300<#else>>${120 * (guidingPrices?size+1)}</#if>px">-->
|
||||
<#-- <tr>-->
|
||||
<#-- <td colspan="${(guidingPrices?size+1)}">-->
|
||||
<#-- <form class="form-inline" style="padding:4px;">-->
|
||||
<#-- <input placeholder="指导日期" id="guidingDate" name="guidingDate" readonly="true" type="text" class="input-small" onfocus="WdatePicker({dateFmt:'yyyyMMdd',maxDate:'%y-%M-%d'})">-->
|
||||
<#-- <input placeholder="指导价格" id="guidingPrice" name="value" type="number" class="input-small">-->
|
||||
<#-- <button type="button" id="saveGuidPrice" class="btn btn-primary" >添加</button>-->
|
||||
<#-- </form>-->
|
||||
<#-- </td>-->
|
||||
<#-- </tr>-->
|
||||
<#-- <tr>-->
|
||||
<#-- <td style="width:120px;">日期 </td>-->
|
||||
|
||||
<#-- <#list guidingPrices as it>-->
|
||||
<#-- <td style="width:120px;">${it.guidingDate?string("yyyy-MM-dd")} <i class="icon-trash" data-id="${it.id}" title="删除"></i>-->
|
||||
<#-- </td>-->
|
||||
<#-- </#list>-->
|
||||
<#-- </tr>-->
|
||||
<#-- <tr>-->
|
||||
<#-- <td style="width:120px;">价格</td>-->
|
||||
<#-- <#list guidingPrices as it><td style="width:100px;">${it.guidingValue!}</td></#list>-->
|
||||
<#-- </tr>-->
|
||||
<#-- <tr>-->
|
||||
<#-- <td style="width:120px;">添加人</td>-->
|
||||
<#-- <#list guidingPrices as it><td style="width:100px;">${it.guidingPerson!}</td></#list>-->
|
||||
<#-- </tr>-->
|
||||
<#-- </table>-->
|
||||
<#-- </div>-->
|
||||
<#-- </div>-->
|
||||
<#-- <div style="width: 80%;float:left;padding-left: 10px;">-->
|
||||
<#-- <p class="prettyprint"><strong><a name="guiding"></a>${district.name!}-参考价</strong></p>-->
|
||||
<#-- <table class="table table-bordered table-condensed ac">-->
|
||||
<#-- <thead>-->
|
||||
<#-- <tr>-->
|
||||
<#-- <th style="width:10%;">价格</th>-->
|
||||
<#-- -->
|
||||
<#-- <th style="width:10%;">调查时间</th>-->
|
||||
<#-- <th style="width:10%;">调查人</th>-->
|
||||
<#-- </tr>-->
|
||||
<#-- </thead>-->
|
||||
<#-- <tbody>-->
|
||||
<#-- <#if (avgBases??&&avgBases?size>0)>-->
|
||||
<#-- <#list avgBases as it>-->
|
||||
<#-- <tr>-->
|
||||
<#-- <td align="center">-->
|
||||
<#-- ${it.price}-->
|
||||
<#-- </td>-->
|
||||
<#-- -->
|
||||
<#-- <td align="center">-->
|
||||
<#-- ${it.creationDate?string("yyyy-MM-dd")}-->
|
||||
<#-- </td>-->
|
||||
<#-- <td align="center">-->
|
||||
<#-- <#if it.userName??>-->
|
||||
<#-- ${it.userName}-->
|
||||
<#-- </#if>-->
|
||||
<#-- </td> -->
|
||||
<#-- </tr>-->
|
||||
<#-- </#list>-->
|
||||
<#-- </#if>-->
|
||||
<#-- </tbody>-->
|
||||
<#-- <#if avgBases?size == 0>-->
|
||||
<#-- <tr><td colspan="3" style="text-align:center;">暂无数据</td></tr>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- </table>-->
|
||||
<#-- </div>-->
|
||||
<#-- <div style="clear:both;"></div>-->
|
||||
<#-- -->
|
||||
<#-- <p class="prettyprint"><strong>${district.name!}-第三方价格对比</strong></p>-->
|
||||
<#-- <table class="table table-condensed ac" id="dsfjj">-->
|
||||
<#-- <#list averageStatistics as it>-->
|
||||
<#-- <tr>-->
|
||||
<#-- <td style="vertical-align: middle;width:100px;" rowspan="2"><b>日期</b></td>-->
|
||||
<#-- <td style="vertical-align: middle;" rowspan="2"><b>房价网</b></td>-->
|
||||
<#-- <#if (it.xiaozijiaNewPrice)?? || (it.xiaozijiaEsfPrice)??> -->
|
||||
<#-- <td colspan="2"><b>小资家</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.lianjiaNewPrice)?? || (it.lianjiaEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>链家</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.anjukeNewPrice)?? || (it.anjukeEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>安居客</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.zhugezhaofangNewPrice)?? || (it.zhugezhaofangEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>诸葛</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.beikeNewPrice)?? || (it.beikeEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>贝壳</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.fangguguNewPrice)?? || (it.fangguguEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>房估估</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.fangdoudouNewPrice)?? || (it.fangdoudouEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>房兜兜</b></td> -->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.soufangNewPrice)?? || (it.soufangEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>搜房</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.cityhouseNewPrice)?? || (it.cityhouseEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>cityhouse</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.fangtanNewPrice)?? || (it.fangtanEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>房探</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.tuboshiNewPrice)?? || (it.tuboshiEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>兔博士</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.centanetNewPrice)?? || (it.centanetEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>中原地产</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.leyoujiaNewPrice)?? || (it.leyoujiaEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>乐有家</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.qfangNewPrice)?? || (it.qfangEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>Q房</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.sinaNewPrice)?? || (it.sinaEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>新浪</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.cricNewPrice)?? || (it.cricEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>克尔瑞</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.ganjiNewPrice)?? || (it.ganjiEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>赶集网</b></td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.yungujiaNewPrice)?? || (it.yungujiaEsfPrice)??>-->
|
||||
<#-- <td colspan="2"><b>云估价</b></td>-->
|
||||
<#-- </#if> -->
|
||||
<#-- </tr>-->
|
||||
<#-- -->
|
||||
<#-- <tr>-->
|
||||
<#-- <#if (it.xiaozijiaNewPrice)?? || (it.xiaozijiaEsfPrice)??>-->
|
||||
<#-- <td style="width:80px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:80px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.lianjiaNewPrice)?? || (it.lianjiaEsfPrice)??>-->
|
||||
<#-- <td style="width:80px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:80px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.anjukeNewPrice)?? || (it.anjukeEsfPrice)??>-->
|
||||
<#-- <td style="width:80px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:80px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.zhugezhaofangNewPrice)?? || (it.zhugezhaofangEsfPrice)??>-->
|
||||
<#-- <td style="width:80px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:80px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.beikeNewPrice)?? || (it.beikeEsfPrice)??>-->
|
||||
<#-- <td style="width:80px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:80px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.fangguguNewPrice)?? || (it.fangguguEsfPrice)??>-->
|
||||
<#-- <td style="width:80px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:80px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.fangdoudouNewPrice)?? || (it.fangdoudouEsfPrice)??>-->
|
||||
<#-- <td style="width:80px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:80px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.soufangNewPrice)?? || (it.soufangEsfPrice)??>-->
|
||||
<#-- <td style="width:80px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:80px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.cityhouseNewPrice)?? || (it.cityhouseEsfPrice)??>-->
|
||||
<#-- <td style="width:70px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:70px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.fangtanNewPrice)?? || (it.fangtanEsfPrice)??>-->
|
||||
<#-- <td style="width:70px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:70px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.tuboshiNewPrice)?? || (it.tuboshiEsfPrice)??>-->
|
||||
<#-- <td style="width:70px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:70px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.centanetNewPrice)?? || (it.centanetEsfPrice)??> -->
|
||||
<#-- <td style="width:70px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:70px;color:#D3750A">二手房</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.leyoujiaNewPrice)?? || (it.leyoujiaEsfPrice)??>-->
|
||||
<#-- <td style="width:70px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:70px;color:#D3750A">二手房</td> -->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.qfangNewPrice)?? || (it.qfangEsfPrice)??>-->
|
||||
<#-- <td style="width:70px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:70px;color:#D3750A">二手房</td> -->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.sinaNewPrice)?? || (it.sinaEsfPrice)??>-->
|
||||
<#-- <td style="width:70px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:70px;color:#D3750A">二手房</td> -->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.cricNewPrice)?? || (it.cricEsfPrice)??>-->
|
||||
<#-- <td style="width:70px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:70px;color:#D3750A">二手房</td> -->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.ganjiNewPrice)?? || (it.ganjiEsfPrice)??>-->
|
||||
<#-- <td style="width:70px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:70px;color:#D3750A">二手房</td> -->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.yungujiaNewPrice)?? || (it.yungujiaEsfPrice)??>-->
|
||||
<#-- <td style="width:70px;color:#0C88C7">新房</td>-->
|
||||
<#-- <td style="width:70px;color:#D3750A">二手房</td> -->
|
||||
<#-- -->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- </tr>-->
|
||||
<#-- -->
|
||||
<#-- <tr>-->
|
||||
<#-- <td>${(t_util.parseDate(it.shortDate?string, 'yyyyMM'))?string("yyyy年MM月")}</td>-->
|
||||
<#-- <td>${it.fangjiaPrice!}</td>-->
|
||||
<#-- <#if (it.xiaozijiaNewPrice)?? || (it.xiaozijiaEsfPrice)??>-->
|
||||
<#-- <td style="color:#0C88C7;">${it.xiaozijiaNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.xiaozijiaEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.lianjiaNewPrice)?? || (it.lianjiaEsfPrice)??>-->
|
||||
<#-- <td style="color:#0C88C7;">${it.lianjiaNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.lianjiaEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.anjukeNewPrice)?? || (it.anjukeEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.anjukeNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.anjukeEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.zhugezhaofangNewPrice)?? || (it.zhugezhaofangEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.zhugezhaofangNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.zhugezhaofangEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.beikeNewPrice)?? || (it.beikeEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.beikeNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.beikeEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.fangguguNewPrice)?? || (it.fangguguEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.fangguguNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.fangguguEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.fangdoudouNewPrice)?? || (it.fangdoudouEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.fangdoudouNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.fangdoudouEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.soufangNewPrice)?? || (it.soufangEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.soufangNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.soufangEsfPrice!}</td> -->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- -->
|
||||
<#-- <#if (it.cityhouseNewPrice)?? || (it.cityhouseEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.cityhouseNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.cityhouseEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.fangtanNewPrice)?? || (it.fangtanEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.fangtanNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.fangtanEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.tuboshiNewPrice)?? || (it.tuboshiEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.tuboshiNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.tuboshiEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.centanetNewPrice)?? || (it.centanetEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.centanetNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.centanetEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.leyoujiaNewPrice)?? || (it.leyoujiaEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.leyoujiaNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.leyoujiaEsfPrice!}</td> -->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.qfangNewPrice)?? || (it.qfangEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.qfangNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.qfangEsfPrice!}</td> -->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- <#if (it.sinaNewPrice)?? || (it.sinaEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.sinaNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.sinaEsfPrice!}</td> -->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.cricNewPrice)?? || (it.cricEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.cricNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.cricEsfPrice!}</td> -->
|
||||
<#-- </#if> -->
|
||||
<#-- <#if (it.ganjiNewPrice)?? || (it.ganjiEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.ganjiNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.ganjiEsfPrice!}</td> -->
|
||||
<#-- </#if>-->
|
||||
<#-- <#if (it.yungujiaNewPrice)?? || (it.yungujiaEsfPrice)??>-->
|
||||
<#-- <td style ="color:#0C88C7">${it.yungujiaNewPrice!}</td>-->
|
||||
<#-- <td style ="color:#D3750A">${it.yungujiaEsfPrice!}</td>-->
|
||||
<#-- </#if>-->
|
||||
<#-- -->
|
||||
<#-- </tr>-->
|
||||
<#-- </#list>-->
|
||||
<#-- <#if averageStatistics?size == 0>-->
|
||||
<#-- <tr><td colspan="7" style="text-align:center;">暂无数据</td></tr>-->
|
||||
<#-- </#if>-->
|
||||
<#-- </table>-->
|
||||
<#-- -->
|
||||
<#-- <div id="comparisonChartContainer">-->
|
||||
<#-- <#if !(calcDistrictStat??)><div style="width: 100%;height: 150px;border: 1px solid #d2c298;text-align: center;">本月没有利用第三方的详细数据!</div></#if>-->
|
||||
<#-- </div>-->
|
||||
<#-- <#if calcDistrictStat?? && calcDistrictStat.thirdpartDetails??>-->
|
||||
<#-- <#macro greet pt> -->
|
||||
<#-- <#assign ret=0>-->
|
||||
<#-- <#list calcDistrictStat.thirdpartDetails as detail>-->
|
||||
<#-- <#if detail['name'] == pt && detail['val']??>-->
|
||||
<#-- <#assign ret>${detail['val']!}</#assign>-->
|
||||
<#-- </#if>-->
|
||||
<#-- </#list>-->
|
||||
<#-- ${ret}-->
|
||||
<#-- </#macro> -->
|
||||
<#-- </#if>-->
|
||||
|
||||
<p class="prettyprint">
|
||||
<strong>${district.name!}-样本散列图</strong>
|
||||
<a style="font-size:8px;float:right;" target="_blank" href="../seawater/houseList?cityDisplay=${district.city!}®ion=${district.region!}&districtName=${district.name!}&cat=rent">房源样本列表</a>
|
||||
<#-- <a style="font-size:8px;float:right;padding-right: 10px;" target="_blank" href="../data/dealPrice?cityDisplay=${district.city}®ion=${district.region}&districtName=${district.name}" >交易数据列表(${dealPriceCount!})</a>-->
|
||||
</p>
|
||||
<#-- <table class="table table-bordered">
|
||||
<tr><th>七天</th><th>一个月</th><th>三个月</th><th>半年</th><th>一年</th><th>全部</th><tr>
|
||||
<tr><td>${distribution['QiTian']}</td><td>${distribution['YiYue']}</td><td>${distribution['SanYue']}</td><td>${distribution['BanNian']}</td><td>${distribution['YiNian']}</td><td>${distribution['All']}</td><tr>
|
||||
</table> -->
|
||||
<p class="prettyprint"><strong>${district.name!}-房源散列图</strong></p>
|
||||
<div id="houseChart"></div>
|
||||
<#-- <p class="prettyprint"><strong>${district.name!}-样本过滤规则</strong></p>-->
|
||||
<#-- <form class="form-inline" style="padding:10px;">-->
|
||||
<#-- <#if calcConfig??>-->
|
||||
<#-- <input id="configId" value="${calcConfig.id!}" type="hidden"/>-->
|
||||
<#-- <#else>-->
|
||||
<#-- <input id="configId" value="" type="hidden"/>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <label for="minPrice">最低房价:</label>-->
|
||||
<#-- <#if calcConfig??>-->
|
||||
<#-- <input id="minPrice" type="number" class="input-small" value='${calcConfig.logicalMinValue!}'>-->
|
||||
<#-- <#else>-->
|
||||
<#-- <input id="configId" value="" type="hidden"/>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <label for="maxPrice">最高房价:</label>-->
|
||||
<#-- <#if calcConfig??>-->
|
||||
<#-- <input id="maxPrice" type="number" class="input-small" value='${calcConfig.logicalMaxValue!}'>-->
|
||||
<#-- <#else>-->
|
||||
<#-- <input id="configId" value="" type="hidden"/>-->
|
||||
<#-- </#if>-->
|
||||
<#-- <button type="button" id="sampleFilterBtn" class="btn">设置</button>(<span class="code" style="color: #D14;">请设置较大区间</span>)-->
|
||||
<#-- </form>-->
|
||||
<#-- <hr><br>-->
|
||||
<#-- <div style="text-align:center;">-->
|
||||
<#-- <button type="button" onclick="javascript:$('#myReCompModal').modal('show')" class="btn btn-danger" >重算租金</button>-->
|
||||
<#-- </div>-->
|
||||
<#-- <hr><br><br>-->
|
||||
</div>
|
||||
<div id="myReCompModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">是否确定?</h3>
|
||||
</div>
|
||||
<div class="modal-body error">
|
||||
<p>1.耗时较长,请谨慎操作!</p>
|
||||
<p>2.计算<b>${district.name!}</b>的历史价格!</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true" aria-hidden="true">关闭</button>
|
||||
<button class="btn btn-primary" name="reComputeBtn" type="all">重算历史</button>
|
||||
<button class="btn btn-primary" name="reComputeBtn" type="month">最近一期</button>
|
||||
<#-- <button class="btn btn-primary" name="reComputeBtn" type="month">最近一月</button>-->
|
||||
<#-- <button class="btn btn-primary" name="reComputeBtn" type="quarter">最近季度</button>-->
|
||||
<button class="btn btn-primary" name="reComputeBtn" type="year">最近一年</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<script type="text/javascript">
|
||||
var selectCity = '${district.city!}';
|
||||
var selectRegion = '${district.region!}'
|
||||
var selectBlock = '${district.block!}'
|
||||
var name = '${district.name!}'
|
||||
function updateAvgPriveOpener(){
|
||||
if($("#_id").val()==undefined||$("#_id").val()===""){
|
||||
alert("请选择要更新的时间点");
|
||||
return;
|
||||
}
|
||||
$('#myModal').modal('show')
|
||||
}
|
||||
|
||||
function updateAvgPrice(){
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../rentPriceUpdate/updateAvgPrice',
|
||||
data: {"id":$("#_id").val(),avgPrice:$("#avgPrice").val()},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
$('#myModal').modal('hide')
|
||||
showSuccessMsg("更新成功");
|
||||
initChart();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initChart(){
|
||||
var data
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../rentPriceUpdate/loadAllDistrictRentPrice',
|
||||
data: {"cityName":selectCity,region:selectRegion,name:name,estateType:'${district.estateType2!}'},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
async:false,
|
||||
success: function(model) {
|
||||
data = model.data;
|
||||
}
|
||||
});
|
||||
var series = new Array();
|
||||
series[0] = {
|
||||
name:"租金",
|
||||
data:new Array(),
|
||||
color:"#0066FF",
|
||||
events:{
|
||||
click:function(event){
|
||||
var item = event.point.data;
|
||||
$("#dateLabel").text(item.weekend.substring(0,10));
|
||||
$("#sampleSizeLabel").text(item.sampleSize);
|
||||
$("#creditLabel").text(item.credit);
|
||||
$("#calcValueLabel").text(item.calcAvgPrice);
|
||||
$("#avgPrice").val(item.avgPrice);
|
||||
$("#_id").val(item.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
series[1] = {
|
||||
name:"计算租金",
|
||||
data:new Array(),
|
||||
color:"#55AC8C",
|
||||
visible: false,
|
||||
events:{
|
||||
click:function(event){
|
||||
var item = event.point.data;
|
||||
$("#dateLabel").text(item.weekend.substring(0,10));
|
||||
$("#sampleSizeLabel").text(item.sampleSize);
|
||||
$("#creditLabel").text(item.credit);
|
||||
$("#calcValueLabel").text(item.calcAvgPrice);
|
||||
$("#avgPrice").val(item.avgPrice);
|
||||
$("#_id").val(item.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// series[2] = {
|
||||
// name:"2B价格",
|
||||
// data:new Array(),
|
||||
// color:"#5bce60",
|
||||
// visible: false,
|
||||
// events:{
|
||||
// click:function(event){
|
||||
// var item = event.point.data;
|
||||
// $("#dateLabel").text(item.weekend.substring(0,10));
|
||||
// $("#sampleSizeLabel").text(item.sampleSize);
|
||||
// $("#creditLabel").text(item.credit);
|
||||
// $("#calcValueLabel").text(item.calcAvgPrice);
|
||||
// $("#avgPrice").val(item.avgPrice);
|
||||
// $("#_id").val(item.id);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// series[3] = {
|
||||
// name:"2B计算价格",
|
||||
// data:new Array(),
|
||||
// color:"#a9864f",
|
||||
// visible: false,
|
||||
// events:{
|
||||
// click:function(event){
|
||||
// var item = event.point.data;
|
||||
// $("#dateLabel").text(item.weekend.substring(0,10));
|
||||
// $("#sampleSizeLabel").text(item.sampleSize);
|
||||
// $("#creditLabel").text(item.credit);
|
||||
// $("#calcValueLabel").text(item.calcAvgPrice);
|
||||
// $("#avgPrice").val(item.avgPrice);
|
||||
// $("#_id").val(item.id);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// series[4] = {
|
||||
// name:"预期价格",
|
||||
// data:new Array(),
|
||||
// color:"red",
|
||||
// visible: true,
|
||||
// events:{
|
||||
// click:function(event){
|
||||
// var item = event.point.data;
|
||||
// $("#dateLabel").text(item.weekend.substring(0,10));
|
||||
// $("#sampleSizeLabel").text(item.sampleSize);
|
||||
// $("#creditLabel").text(item.credit);
|
||||
// $("#calcValueLabel").text(item.calcAvgPrice);
|
||||
// $("#avgPrice").val(item.avgPrice);
|
||||
// $("#_id").val(item.id);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
$(data).each(function(i,item){
|
||||
series[0].data.push({
|
||||
x:new Date(item.weekend),
|
||||
y:item.avgPrice,
|
||||
data:item
|
||||
})
|
||||
if(item.calcAvgPrice!=0){
|
||||
series[1].data.push({
|
||||
x:new Date(item.weekend),
|
||||
y:item.calcAvgPrice,
|
||||
data:item
|
||||
})
|
||||
}
|
||||
|
||||
// if (typeof(item.avg_price_2b) != "undefined"){
|
||||
// series[2].data.push({
|
||||
// x:new Date(item.weekend),
|
||||
// y:item.avg_price_2b,
|
||||
// data:item
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// if (typeof(item.calc_avg_price_2b) != "undefined"){
|
||||
// series[3].data.push({
|
||||
// x:new Date(item.weekend),
|
||||
// y:item.calc_avg_price_2b,
|
||||
// data:item
|
||||
// })
|
||||
// }
|
||||
// if (typeof(item.futureValue) != "undefined"){
|
||||
// series[4].data.push({
|
||||
// x:new Date(item.weekend),
|
||||
// y:item.futureValue,
|
||||
// data:item
|
||||
// })
|
||||
// }
|
||||
});
|
||||
$('#container').highcharts({
|
||||
chart: {
|
||||
type: 'spline',
|
||||
zoomType:"xy",
|
||||
height:700
|
||||
},
|
||||
title: {
|
||||
text:'租金走势图('+name+')'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'datetime',
|
||||
dateTimeLabelFormats: { // don't display the dummy year
|
||||
month: '%y-%m-%e',
|
||||
year: '%b'
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
title: {
|
||||
text: '租金(元/平米)'
|
||||
},
|
||||
min: 0
|
||||
},
|
||||
tooltip: {
|
||||
crosshairs: true,
|
||||
formatter: function() {
|
||||
var item = this.point.data;
|
||||
var credit = item.credit;
|
||||
var title = (Highcharts.dateFormat('%y-%m-%e', this.x)+'<br/>')
|
||||
title +=('<b>'+ this.series.name +'</b>:'+this.y+'元/平米<br/>');
|
||||
title +=('<b>可信度:</b>'+credit+'</br>')
|
||||
if(credit>=0.8){
|
||||
title +=('<b>样本量:</b>'+item.sampleSize+'</br>')
|
||||
}else if(credit>=0.6){
|
||||
|
||||
}
|
||||
return title;
|
||||
}
|
||||
},
|
||||
series:series
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function initHouseChart(){
|
||||
var data
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../rentPriceUpdate/loadHouseInfo',
|
||||
data: {"cityName":selectCity,region:selectRegion,name:name},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
async:false,
|
||||
success: function(model) {
|
||||
data = model.data;
|
||||
}
|
||||
});
|
||||
var series = new Array();
|
||||
series[0] = {
|
||||
name:"房源散列图",
|
||||
data:new Array()
|
||||
//color:"#660099"
|
||||
}
|
||||
$(data).each(function(i,item){
|
||||
var pdate = item.pDate + "";
|
||||
var ds = pdate.substring(0, 4) + '-' + pdate.substring(4, 6) + '-' + pdate.substring(6)
|
||||
series[0].data.push({
|
||||
x:new Date(ds),
|
||||
y:Math.round(item.totalPrice/item.area),
|
||||
data:item
|
||||
})
|
||||
});
|
||||
$('#houseChart').highcharts({
|
||||
chart: {
|
||||
type: 'scatter',
|
||||
zoomType:"xy",
|
||||
height:500
|
||||
},
|
||||
title: {
|
||||
text:name + ' 样本散列图'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'datetime',
|
||||
dateTimeLabelFormats: { // don't display the dummy year
|
||||
month: '%y-%m-%e',
|
||||
year: '%b'
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
title: {
|
||||
text: '租金(元/平米)'
|
||||
},
|
||||
min: 0
|
||||
},
|
||||
tooltip: {
|
||||
crosshairs: true,
|
||||
formatter: function() {
|
||||
return '<b>'+ this.series.name +'</b><br/>'+
|
||||
Highcharts.dateFormat('%y-%m-%e', this.x) +': '+ this.y +' 元/平米';
|
||||
}
|
||||
},
|
||||
series:series
|
||||
});
|
||||
}
|
||||
function showSuccessMsg(msg){
|
||||
jNotify(
|
||||
msg,
|
||||
{
|
||||
autoHide : true,
|
||||
clickOverlay : false,
|
||||
MinWidth : 250,
|
||||
TimeShown : 2000,
|
||||
ShowTimeEffect : 1000,
|
||||
HideTimeEffect : 1000,
|
||||
LongTrip :20,
|
||||
HorizontalPosition : 'right',
|
||||
VerticalPosition : 'top',
|
||||
ShowOverlay : true,
|
||||
ColorOverlay : '#000',
|
||||
OpacityOverlay : 0.3,
|
||||
onClosed : function(){
|
||||
|
||||
},
|
||||
onCompleted : function(){
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
<#--第三方对比图 start-->
|
||||
<#if calcDistrictStat?? && calcDistrictStat.thirdpartDetails??>
|
||||
$('#comparisonChartContainer').highcharts({
|
||||
chart: {
|
||||
type: 'column'
|
||||
},
|
||||
title: {
|
||||
text: '第三方价格详细利用情况'
|
||||
},
|
||||
subtitle: {
|
||||
text: '(利用最近2个月的数据)'
|
||||
},
|
||||
xAxis: {
|
||||
categories: [
|
||||
'搜房','安居客','新浪','克尔瑞','赶集'
|
||||
]
|
||||
},
|
||||
yAxis: {
|
||||
min: 0,
|
||||
title: {
|
||||
text: 'Rainfall (mm)'
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
headerFormat: '<b>{point.key}</b><table>',
|
||||
pointFormat: '<tr><td style="color:{series.color};padding:0"><b>{series.name}</b>:</td>' +
|
||||
'<td style="padding:0">{point.y}</td></tr>',
|
||||
footerFormat: '</table>',
|
||||
shared: true,
|
||||
useHTML: true
|
||||
},
|
||||
plotOptions: {
|
||||
column: {
|
||||
pointPadding: 0.2,
|
||||
borderWidth: 0
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
color:'#0C88C7',
|
||||
name: '新房',
|
||||
data: [<@greet pt='soufun_new' />, <@greet pt='anjuke_new' />,<@greet pt='sina_new' />,<@greet pt='cric_new' />,<@greet pt='ganji_new' />]
|
||||
},
|
||||
{
|
||||
color:'#D3750A',
|
||||
name: '二手房',
|
||||
data: [<@greet pt='soufun_esf' />, <@greet pt='anjuke_esf' />,<@greet pt='sina_esf' />,<@greet pt='cric_esf' />,<@greet pt='ganji_esf' />]
|
||||
},
|
||||
]
|
||||
});
|
||||
</#if>
|
||||
|
||||
$(function(){
|
||||
initChart();
|
||||
initHouseChart();
|
||||
|
||||
$("#saveGuidPrice").click(function(){
|
||||
if($("#guidingPrice").val()===""){
|
||||
alert("指导价不能为空");
|
||||
return;
|
||||
}
|
||||
if(!$.isNumeric($("#guidingPrice").val())){
|
||||
alert("指导价必须是数字");
|
||||
return;
|
||||
}
|
||||
if($("#guidingDate").val()===""){
|
||||
alert("指导日期不能为空");
|
||||
return;
|
||||
}
|
||||
if(${(guidingPrices?size+1)}>=2){
|
||||
alert("指导价已添加!");
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../rentPriceUpdate/addGuidingPrice',
|
||||
data: {"guidingPrice":$("#guidingPrice").val(),guidingDate:$("#guidingDate").val(),id:'${id}'},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
showSuccessMsg('保存成功!!建议你重算租金');
|
||||
window.location.hash= 'guiding';
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
$("#sampleFilterBtn").click(function(){
|
||||
var minPrice = $.trim($("#minPrice").val())
|
||||
var maxPrice = $.trim($("#maxPrice").val())
|
||||
if(maxPrice===""||maxPrice===""){
|
||||
alert("请填写价格区间");
|
||||
return;
|
||||
}
|
||||
if($.trim($("#minPrice").val())!==""&&!$.isNumeric($.trim($("#minPrice").val()))){
|
||||
alert("价格必须是数字");
|
||||
return;
|
||||
}
|
||||
if($.trim($("#maxPrice").val())!==""&&!$.isNumeric($.trim($("#maxPrice").val()))){
|
||||
alert("价格必须是数字");
|
||||
return;
|
||||
}
|
||||
if(minPrice!=""&&maxPrice!=""){
|
||||
if(new Number(maxPrice) - new Number(minPrice)<2000){
|
||||
alert("最大价格和最小价格至少要相差2000元")
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../rentPriceUpdate/updateCalcConfig',
|
||||
data: {"minPrice":minPrice,maxPrice:maxPrice,id:'${id}',configId:$("#configId").val()},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
showSuccessMsg('保存成功');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
$(".icon-trash").click(function(){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../rentPriceUpdate/deleteGuidingPrice',
|
||||
data: {id:$(this).attr("data-id")},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
showSuccessMsg("指导价删除成功!!建议你重算租金");
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
function getBeforeDay(day) {
|
||||
var rdate = new Date();
|
||||
var cmills = new Date().getTime()
|
||||
if(day > 0) {
|
||||
cmills = cmills - day * 24 * 3600 * 1000;
|
||||
}
|
||||
rdate.setTime(cmills)
|
||||
var month = rdate.getMonth() < 10 ? "0" + rdate.getMonth() : rdate.getMonth();
|
||||
var date = rdate.getDate() < 10 ? "0" + rdate.getDate() : rdate.getDate();
|
||||
return rdate.getFullYear() + month + "" + date
|
||||
}
|
||||
|
||||
$("button[name='reComputeBtn']").click(function(){
|
||||
var type = $(this).attr('type');
|
||||
var data ={};
|
||||
var commands = Array();
|
||||
commands.push({city:'${district.city!}',region:'${district.region!}',name:'${district.name!}',estateType:'${district.estateType2!}'})
|
||||
data.commands = commands ;
|
||||
data.calcRange = type;
|
||||
$.ajax({
|
||||
url:"../rentPriceUpdate/reCompute",
|
||||
dataType:"json",
|
||||
type:'POST',
|
||||
data:{data:JSON.stringify(data)},
|
||||
success:function(data){
|
||||
showSuccessMsg(data.msg)
|
||||
$('#myReCompModal').modal('hide')
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</#compress>
|
||||
@@ -0,0 +1,344 @@
|
||||
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
|
||||
<#compress>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>${cityDisplay}<#if region?? && region!=''>-${region}<#if block?? && block!=''>-${block}</#if></#if> 小区均价操作列表</title>
|
||||
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/main_simple.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/pagination.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/jnotify/jNotify.jquery.css?v=${version}" />
|
||||
<#include "/common_js.ftl" />
|
||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||
<script type="text/javascript" src="../js/jquery-1.9.1.js"></script>
|
||||
<script type="text/javascript" src="../js/jquery.pagination.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/highcharts-3.0.7.js"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/exporting-3.0.7.js"></script>
|
||||
<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="../js/jNotify.jquery.min.js?v=${version}"></script>
|
||||
<style>
|
||||
.con {
|
||||
border-radius:0px;
|
||||
}
|
||||
label{display:inline-block}
|
||||
.input-small{
|
||||
margin:0px;
|
||||
}
|
||||
#city-border-mid{
|
||||
margin-top:6px;
|
||||
}
|
||||
|
||||
.pagination-page {
|
||||
padding-top:8px;
|
||||
padding-right:20px;
|
||||
}
|
||||
|
||||
.pagination-page a{
|
||||
border-color: #ccc #aaa #aaa #ccc;
|
||||
border-image: none;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
color: #666;
|
||||
margin: 0 3px;
|
||||
padding: 2px 6px;
|
||||
}
|
||||
.current-page {
|
||||
padding: 2px 3px;
|
||||
color: #666;
|
||||
background: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<#include "/layout/header.ftl" />
|
||||
<#setting number_format="0.###########"/>
|
||||
<div class="main-content" style="padding:10px 10px;">
|
||||
<table class="table table-bordered table-condensed">
|
||||
<tr>
|
||||
<th>查询条件</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<form action="districtList">
|
||||
<@d_city defaultValue="${cityDisplay!}" callback="changeCity" callbackField="display" name="cityDisplay"/>
|
||||
<label for="region">区域:</label>
|
||||
<select id="region" name="region" class="form-control" onchange="changeRegion()" style="width: 120px;">
|
||||
<option value="">不限</option>
|
||||
</select>
|
||||
<label for="region">板块:</label>
|
||||
<select id="block" name="block" class="form-control" style="width: 120px;">
|
||||
<option value="">不限</option>
|
||||
</select>
|
||||
<label for="name">可信度:</label>
|
||||
<select id="minCredit" name="minCredit" class="form-control" style="width: 70px;">
|
||||
<option value="">--</option>
|
||||
<#list 0..100 as a>
|
||||
<option <#if minCredit?? && a/100?number == minCredit>selected</#if> value="${a/100?number}">${a/100?number}</option>
|
||||
</#list>
|
||||
</select>
|
||||
-
|
||||
<select id="maxCredit" name="maxCredit" class="form-control" style="width: 70px;">
|
||||
<option value="">--</option>
|
||||
<#list 0..100 as a>
|
||||
<option <#if maxCredit?? && a/100?number == maxCredit>selected</#if> value="${a/100?number}">${a/100?number}</option>
|
||||
</#list>
|
||||
</select>
|
||||
|
||||
<label for="name">计算方式:</label>
|
||||
<select id="valueType" name="valueType" class="form-control" style="width: 120px;">
|
||||
<option value="">不限</option>
|
||||
<option value="1" <#if valueType?? && valueType == 1>selected</#if> >指导价</option>
|
||||
<option value="2" <#if valueType?? && valueType == 2>selected</#if> >自身样本</option>
|
||||
<option value="3" <#if valueType?? && valueType == 3>selected</#if> >第三方</option>
|
||||
<option value="4" <#if valueType?? && valueType == 4>selected</#if> >交易数据</option>
|
||||
<option value="5" <#if valueType?? && valueType == 5>selected</#if> >周边楼盘</option>
|
||||
<option value="6" <#if valueType?? && valueType == 6>selected</#if> >推算</option>
|
||||
<option value="-1" <#if valueType?? && valueType == -1>selected</#if> >无方式</option>
|
||||
</select>
|
||||
|
||||
<label for="name">小区:</label>
|
||||
<input type="text" name="name" id="name" class="input-medium" style="margin-top:4px;" value="${name!}" >
|
||||
|
||||
<input id="queryBtn" class ="btn btn-primary" type="submit" value="查询" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<span style="font-size:12px;">查询到<b style="color:red;">${pager.totalRows!}</b>条记录</span>
|
||||
<table id="dataSheet" class="table table-hover table-condensed">
|
||||
<tr>
|
||||
<th style="width:20px;"></th>
|
||||
<th style="width:60px;">区域</th>
|
||||
<th style="width:150px;">小区名</th>
|
||||
<th style="width:150px;">别名</th>
|
||||
<th style="width:60px;">物业类型</th>
|
||||
<th style="width:50px;">
|
||||
<#if sort?? && sort == 'price_desc'>
|
||||
<a href="../rentPriceUpdate/districtList?cityDisplay=${cityDisplay!}®ion=${region!}&block=${block!}&name=${name!}&valueType=${valueType!}&minCredit=${minCredit!}&maxCredit=${maxCredit!}&sort=price_asc">均价</a>↓
|
||||
<#elseif sort?? && sort == 'price_asc'>
|
||||
<a href="../rentPriceUpdate/districtList?cityDisplay=${cityDisplay!}®ion=${region!}&block=${block!}&name=${name!}&valueType=${valueType!}&minCredit=${minCredit!}&maxCredit=${maxCredit!}&sort=price_desc">均价</a>↑
|
||||
<#else>
|
||||
<a href="../rentPriceUpdate/districtList?cityDisplay=${cityDisplay!}®ion=${region!}&block=${block!}&name=${name!}&valueType=${valueType!}&minCredit=${minCredit!}&maxCredit=${maxCredit!}&sort=price_desc">均价</a>
|
||||
</#if>
|
||||
</th>
|
||||
<th style="width:86px;">时间</th>
|
||||
<th style="width:60px;">
|
||||
<#if sort?? && sort == 'credit_desc'><a href="../rentPriceUpdate/districtList?cityDisplay=${cityDisplay!}®ion=${region!}&block=${block!}&name=${name!}&minCredit=${minCredit!}&maxCredit=${maxCredit!}&valueType=${valueType!}&sort=credit_asc">可信度</a>↓
|
||||
<#elseif sort?? && sort == 'credit_asc'><a href="../rentPriceUpdate/districtList?cityDisplay=${cityDisplay!}®ion=${region!}&block=${block!}&name=${name!}&minCredit=${minCredit!}&maxCredit=${maxCredit!}&valueType=${valueType!}&sort=credit_desc">可信度</a>↑
|
||||
<#else><a href="../rentPriceUpdate/districtList?cityDisplay=${cityDisplay!}®ion=${region!}&block=${block!}&name=${name!}&minCredit=${minCredit!}&maxCredit=${maxCredit!}&valueType=${valueType!}&sort=credit_desc">可信度</a>
|
||||
</#if>
|
||||
</th>
|
||||
<th style="width:60px;">计算类型</th>
|
||||
<th style="width:50px;">操作</th>
|
||||
</tr>
|
||||
<#if avgUpdateBos??>
|
||||
<#list avgUpdateBos as it>
|
||||
<tr>
|
||||
<td><input type="checkbox" data-city="${it.city!}" data-region="${it.region!}" data-block="${it.block!}" data-name="${it.districtName!}" data-estateType="${it.estateType!}" data-startDate="${it.calcStartDate!}" data-id="${it.id!}"/></td>
|
||||
<td>${it.region!}</td>
|
||||
<td><a href="../rentPriceUpdate/districtDetail?id=${it.id}" target="_blank">${it.districtName!}</a></td>
|
||||
<td style="width: 120px;">
|
||||
<span>${t_util.join(it.alias!, ',')}</span>
|
||||
</td>
|
||||
<td>${it.estateType!}</td>
|
||||
<td>${it.avgPrice!}</td>
|
||||
<td>${it.weekend!}</td>
|
||||
<td>${it.credit}</td>
|
||||
<td>
|
||||
<#if it.valueType?? && it.valueType == 1>
|
||||
指导价
|
||||
<#elseif it.valueType?? && it.valueType == 2>
|
||||
自身样本
|
||||
<#elseif it.valueType?? && it.valueType == 3>
|
||||
第三方
|
||||
<#elseif it.valueType?? && it.valueType == 4>
|
||||
交易数据
|
||||
<#elseif it.valueType?? && it.valueType == 5>
|
||||
周边楼盘
|
||||
</#if>
|
||||
</td>
|
||||
<td>
|
||||
<a href="../priceSurvey/create?cityDisplay=${it.city!}®ion=${it.region!}&districtName=${it.districtName!}" target="_blank">调查</a>
|
||||
<a href="../seawater/houseList?cityDisplay=${it.city!}®ion=${it.region!}&districtName=${it.districtName!}" target="_blank">样本</a>
|
||||
<a href="../averagerConfig/show?display=${it.city!}®ion=${it.region!}&name=${it.districtName!}" target="_blank">设置</a>
|
||||
</td>
|
||||
</tr>
|
||||
</#list>
|
||||
</#if>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="14" style="text-align: right;">
|
||||
<@d_pager action = "districtList" currentPage = pager.currentPage controller = "rentPriceUpdate" totalPages = pager.totalPages pagerCount=12 theme="full"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">警告</h3>
|
||||
</div>
|
||||
<div class="modal-body error">
|
||||
<p>耗时操作,请谨慎操作!</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true" aria-hidden="true">关闭</button>
|
||||
<button class="btn btn-primary" id="reComputeBtn">计算</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<script type="text/javascript">
|
||||
|
||||
var selectCity = '${cityDisplay!}';
|
||||
var selectRegion = '${region!}'
|
||||
var selectBlock = '${block!}'
|
||||
function changeCity(display){
|
||||
selectCity = display;
|
||||
if (display) {
|
||||
$("#display").val(display);
|
||||
}
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '../district/getRegions',
|
||||
data: encodeURI("cityDisplay=" + display),
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
$("#region").empty();
|
||||
if (model.regionList.length > 0) {
|
||||
$("<option value=''>不限</option>").appendTo($("#region"));
|
||||
$.each(model.regionList, function(i, region){
|
||||
if(selectRegion == region){
|
||||
$("<option value='" + region + "' selected>" + region + "</option>").appendTo($("#region"));
|
||||
}else{
|
||||
$("<option value='" + region + "' >" + region + "</option>").appendTo($("#region"));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error : function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
function changeRegion(r){
|
||||
var selectRegion = $("#region option:selected").text();
|
||||
if(r!=undefined){
|
||||
selectRegion = r;
|
||||
}
|
||||
$("#block").empty();
|
||||
if(region==="不限"){
|
||||
$("<option value=''>不限</option>").appendTo($("#block"));
|
||||
}
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '../district/getBlocks',
|
||||
data: {cityDisplay:selectCity,region:selectRegion},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
$("#block").empty();
|
||||
if (model.blockList.length > 0) {
|
||||
$("<option value=''>不限</option>").appendTo($("#block"));
|
||||
$.each(model.blockList, function(i, block){
|
||||
if(selectBlock == block){
|
||||
$("<option value='" + block + "' selected>" + block + "</option>").appendTo($("#block"));
|
||||
}else{
|
||||
$("<option value='" + block + "' >" + block + "</option>").appendTo($("#block"));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error : function() {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
changeCity('${cityDisplay!}');
|
||||
if(selectRegion !==''){
|
||||
changeRegion(selectRegion);
|
||||
}
|
||||
|
||||
function openWarnDailog(){
|
||||
var checkedInputs = $("#dataSheet input:checked")
|
||||
if(checkedInputs.length==0){
|
||||
alert("请选择要更新的小区");
|
||||
return;
|
||||
}
|
||||
$('#myModal').modal('show')
|
||||
|
||||
}
|
||||
function showSuccessMsg(msg){
|
||||
jNotify(
|
||||
msg,
|
||||
{
|
||||
autoHide : true,
|
||||
clickOverlay : false,
|
||||
MinWidth : 250,
|
||||
TimeShown : 2000,
|
||||
ShowTimeEffect : 1000,
|
||||
HideTimeEffect : 1000,
|
||||
LongTrip :20,
|
||||
HorizontalPosition : 'right',
|
||||
VerticalPosition : 'top',
|
||||
ShowOverlay : true,
|
||||
ColorOverlay : '#000',
|
||||
OpacityOverlay : 0.3,
|
||||
onClosed : function(){
|
||||
|
||||
},
|
||||
onCompleted : function(){
|
||||
}
|
||||
});
|
||||
}
|
||||
$(function(){
|
||||
$("#reComputeBtn").click(function(){
|
||||
var data ={};
|
||||
var commands = Array();
|
||||
$("#dataSheet input:checked").each(function(){
|
||||
var command = {};
|
||||
if($(this).attr("data-city")!==""){
|
||||
command.city = $(this).attr("data-city")
|
||||
}
|
||||
|
||||
if($(this).attr("data-region")!==""){
|
||||
command.region = $(this).attr("data-region")
|
||||
}
|
||||
|
||||
if($(this).attr("data-block")!==""){
|
||||
command.block = $(this).attr("data-block")
|
||||
}
|
||||
|
||||
if($(this).attr("data-name")!==""){
|
||||
command.name = $(this).attr("data-name")
|
||||
}
|
||||
if($(this).attr("data-estateType")!==""){
|
||||
command.estateType = $(this).attr("data-estateType")
|
||||
}
|
||||
if($(this).attr("data-startdate")!==""){
|
||||
command.startDate = $(this).attr("data-startDate")
|
||||
}
|
||||
commands.push(command)
|
||||
|
||||
})
|
||||
data.commands = commands ;
|
||||
data.startDate = $("#startDate").val()
|
||||
data.endDate = $("#endDate").val()
|
||||
$.ajax({
|
||||
url:"../rentPriceUpdate/reCompute",
|
||||
dataType:"json",
|
||||
type:'POST',
|
||||
data:{data:JSON.stringify(data)},
|
||||
success:function(data){
|
||||
$("#dataSheet input:checked").removeAttr("checked")
|
||||
showSuccessMsg(data.msg)
|
||||
$('#myModal').modal('hide')
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</#compress>
|
||||
@@ -0,0 +1,278 @@
|
||||
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
|
||||
<#compress>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>均价操作后台</title>
|
||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||
|
||||
<style>
|
||||
table tr td {
|
||||
vertical-align: middle !important;;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/main_simple.css?v=${version}" />
|
||||
<#include "/common_js.ftl" />
|
||||
<style>
|
||||
.right_arrow,.right_arrow:hover,.down_arrow,.down_arrow:hover {
|
||||
width:0;
|
||||
height:0;
|
||||
line-height:0;
|
||||
border-width:8px;
|
||||
border-style:solid;
|
||||
display: inline-block;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.right_arrow{
|
||||
border-color:transparent transparent transparent #999999;margin-right: 5px; margin-bottom: -2px;
|
||||
}
|
||||
|
||||
.right_arrow:hover{
|
||||
border-color:transparent transparent transparent red;
|
||||
}
|
||||
|
||||
.down_arrow{
|
||||
margin-top:8px;
|
||||
margin-right: 7px;
|
||||
border-color:#999999 transparent transparent transparent;
|
||||
}
|
||||
|
||||
.down_arrow:hover{
|
||||
margin-top:8px;
|
||||
border-color:red transparent transparent transparent;
|
||||
}
|
||||
|
||||
.right_arrow:hover,.down_arrow:hover {
|
||||
cursor:pointer;
|
||||
}
|
||||
input[type="checkbox"]{
|
||||
margin-top:-3px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<#include "/layout/header.ftl" />
|
||||
<div class="main-content">
|
||||
<#--
|
||||
<table class="table table-bordered table-striped table-condensed">
|
||||
<thead><tr><th style="width:220px;">项</th><th>值</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td> 城市</td><td><span id="cities"></span></td></tr>
|
||||
<tr><td> 区域</td><td><span id="regions"></span></td></tr>
|
||||
<tr><td> 板块</td><td><span id="blocks"></span></td></tr>
|
||||
<tr><td>起止时间</td>
|
||||
<td>
|
||||
<input id="startDate" class="form-control" style="width:100px;" name="startDate" value="${endDate!}" onfocus="WdatePicker({dateFmt:'yyyyMMdd',maxDate:'#F{$dp.$D(\'endDate\')||\'%y-%M-%d\'}',minDate:'2007-1-1'})" />
|
||||
-<input id="endDate" class="form-control" style="width:100px;" name="endDate" value="${endDate!}" onfocus="WdatePicker({dateFmt:'yyyyMMdd',maxDate:'%y-%M-%d',minDate:'#F{$dp.$D(\'startDate\')||\'2007-1-1\'}'})"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>操作</td>
|
||||
<td><button type="button" id="reComputeBtn" class="btn btn-danger">重算均价</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
-->
|
||||
<div style="">
|
||||
<#assign seqIndex = 0 />
|
||||
<table class="table table-condensed table-bordered table-hover">
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<#list ['HOT', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] as key>
|
||||
<a href="#${key}">${key}</a>
|
||||
</#list>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>序号</th><th>名称</th><th>最新均价</th><th>起始日期</th><th class="fixedtd">操作</th>
|
||||
</tr>
|
||||
<#list ['HOT', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] as key>
|
||||
<#if avgUpdateBoMap[key]?? && avgUpdateBoMap[key]?size gt 0>
|
||||
<tr>
|
||||
<td colspan="5" style="background-color:rgb(236, 231, 231)"> <b id="${key}" name="${key}" style="color:rgb(10, 0, 0)">${key}</b></td>
|
||||
</tr>
|
||||
<#list avgUpdateBoMap[key] as it>
|
||||
<tr data-ids = "${it.id!}" data-city="${it.city}" data-level="1" data-startDate="${it.startDate!}">
|
||||
<td style="width: 40px;"><#assign seqIndex = seqIndex +1 />${seqIndex}</td>
|
||||
<td style="width:400px;">
|
||||
${it.city}
|
||||
</td>
|
||||
<td>${it.avgPrice!}</td>
|
||||
<td>${it.startDate!}</td>
|
||||
<td>
|
||||
<a href="../rentPriceUpdate/detail?cityDisplay=${it.city!}">详细信息</a>
|
||||
<a href="../rentPriceUpdate/districtList?cityDisplay=${it.city!}">查看小区</a>
|
||||
<a href="../districtHouseStat/list?cityDisplay=${it.city}">样本房源</a>
|
||||
</td>
|
||||
</tr>
|
||||
</#list>
|
||||
</#if>
|
||||
</#list>
|
||||
<table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<#--
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
listeners.addCityLevelListeners();
|
||||
listeners.addItemListeners();
|
||||
$("#reComputeBtn").click(function(){
|
||||
var data ={};
|
||||
var commands = Array();
|
||||
$("input:checked").each(function(){
|
||||
var tr = $(this).parent().parent();
|
||||
var command = {};
|
||||
if(tr.attr("data-level")=="1"){
|
||||
command.city = tr.attr("data-city")
|
||||
}else if(tr.attr("data-level")=="2"){
|
||||
command.city = tr.attr("data-city")
|
||||
command.region = tr.attr("data-region")
|
||||
}else if(tr.attr("data-level")=="3"){
|
||||
command.city = tr.attr("data-city")
|
||||
command.region = tr.attr("data-region")
|
||||
command.block = tr.attr("data-block")
|
||||
}
|
||||
command.startDate = tr.attr("data-startDate")
|
||||
commands.push(command)
|
||||
|
||||
})
|
||||
if(commands.length==0){
|
||||
alert("你没有选择任何城市、区域或板块!")
|
||||
return;
|
||||
}
|
||||
if(!confirm("耗时任务,请慎重进行!!!你确定要重算吗?")){
|
||||
return;
|
||||
}
|
||||
data.commands = commands ;
|
||||
data.startDate = $("#startDate").val()
|
||||
data.endDate = $("#endDate").val()
|
||||
$.ajax({
|
||||
url:"../rentPriceUpdate/reCompute",
|
||||
dataType:"json",
|
||||
cache:false,
|
||||
type:'POST',
|
||||
data:{data:JSON.stringify(data)},
|
||||
success:function(data){
|
||||
alert(data.msg)
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
listeners ={
|
||||
addCityLevelListeners:function(){
|
||||
$("[data-level='1'] span").click(function(){
|
||||
var activeTr = $(this).parent().parent()
|
||||
var ids = $(activeTr).attr("data-ids");
|
||||
if($(this).hasClass("right_arrow")){
|
||||
$(this).removeClass("right_arrow").addClass("down_arrow")
|
||||
if($("tr[data-ids*='"+$(activeTr).attr("data-ids")+",']").length > 0){
|
||||
$("tr[data-ids*='"+$(activeTr).attr("data-ids")+",']").show();
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url:"../rentPriceUpdate/loadAvgPriceData",
|
||||
dataType:"json",
|
||||
cache:true,
|
||||
data:{cityName:$(activeTr).attr("data-city")},
|
||||
success:function(data){
|
||||
$(data).each(function(){
|
||||
$('<tr data-ids="'+ids+',' + this.id +'" data-region ="'+this.region+'" data-city="'+this.city+'" data-startDate="'+this.startDate+'" data-level="2"><td><span class="right_arrow" style="margin-left:30px;"></span><input type="checkbox"> '+this.region+'</td><td>'+this.avgPrice+'</td><td>'+this.startDate+'</td><td><a href="javascript:;" class="detailBtn">详细信息</a> <a href="javascript:;" class="districtBtn">查看小区</a></td></tr>').insertAfter(activeTr)
|
||||
});
|
||||
listeners.addRegionLevelListeners();
|
||||
listeners.addItemListeners();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$(this).removeClass("down_arrow").addClass("right_arrow")
|
||||
$("tr[data-ids*='"+$(activeTr).attr("data-ids")+",']").hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
addRegionLevelListeners:function(){
|
||||
$("[data-level='2'] span").click(function(){
|
||||
var activeTr = $(this).parent().parent()
|
||||
var ids = $(activeTr).attr("data-ids");
|
||||
if($(this).hasClass("right_arrow")){
|
||||
$(this).removeClass("right_arrow").addClass("down_arrow")
|
||||
if($("tr[data-ids*='"+$(activeTr).attr("data-ids")+",']").length > 0){
|
||||
$("tr[data-ids*='"+$(activeTr).attr("data-ids")+",']").show();
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url:"../rentPriceUpdate/loadAvgPriceData",
|
||||
dataType:"json",
|
||||
cache:true,
|
||||
data:{cityName:$(activeTr).attr("data-city"),region:$(activeTr).attr("data-region")},
|
||||
success:function(data){
|
||||
$(data).each(function(){
|
||||
$('<tr data-ids="'+ids+","+this.id+'" data-level="3" data-city="'+this.city+'" data-region="'+this.region+'" data-block = "'+this.block+'" data-startDate="'+this.startDate+'"><td><span style="margin-left:90px;"></span><input type="checkbox"> '+this.block+'</td><td>'+this.avgPrice+'</td><td>'+this.startDate+'</td><td><a href="javascript:;" class="detailBtn">详细信息</a> <a href="javascript:;" class="districtBtn">查看小区</a></td></tr>').insertAfter(activeTr)
|
||||
});
|
||||
listeners.addItemListeners();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$(this).removeClass("down_arrow").addClass("right_arrow")
|
||||
$("tr[data-ids*='"+$(activeTr).attr("data-ids")+",']").hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
addItemListeners:function(){
|
||||
$("input[type='checkbox']").unbind();
|
||||
$(".detailBtn").unbind();
|
||||
$(".districtBtn").unbind();
|
||||
$("input[type='checkbox']").click(function(){
|
||||
var activeTr = $(this).parent().parent();
|
||||
if($(this).attr("checked")){
|
||||
if($(activeTr).attr("data-level")==="1"){
|
||||
$("#cities").text($("#cities").text()+activeTr.attr("data-city")+",")
|
||||
}else if($(activeTr).attr("data-level")==="2"){
|
||||
$("#regions").text($("#regions").text()+activeTr.attr("data-region")+",")
|
||||
}else if($(activeTr).attr("data-level")==="3"){
|
||||
$("#blocks").text($("#blocks").text()+activeTr.attr("data-block")+",")
|
||||
}
|
||||
|
||||
}else{
|
||||
if($(activeTr).attr("data-level")==="1"){
|
||||
$("#cities").text($("#cities").text().replace(activeTr.attr("data-city")+",",""))
|
||||
}else if($(activeTr).attr("data-level")==="2"){
|
||||
$("#regions").text($("#regions").text().replace(activeTr.attr("data-region")+",",""))
|
||||
}else if($(activeTr).attr("data-level")==="3"){
|
||||
$("#blocks").text($("#blocks").text().replace(activeTr.attr("data-block")+",",""))
|
||||
}
|
||||
}});
|
||||
$(".detailBtn").click(function(){
|
||||
var activeTr = $(this).parent().parent();
|
||||
var url = "../rentPriceUpdate/detail?cityDisplay="+$(activeTr).attr("data-city");
|
||||
if($(activeTr).attr("data-region")!=undefined){
|
||||
url =url + "®ion=" + $(activeTr).attr("data-region")
|
||||
}
|
||||
if($(activeTr).attr("data-block")!=undefined){
|
||||
url =url + "&block=" + $(activeTr).attr("data-block")
|
||||
}
|
||||
window.open(url,'_blank');
|
||||
});
|
||||
$(".districtBtn").click(function(){
|
||||
var activeTr = $(this).parent().parent();
|
||||
var url = "../rentPriceUpdate/districtList?cityDisplay="+$(activeTr).attr("data-city");
|
||||
if($(activeTr).attr("data-region")!=undefined){
|
||||
url =url + "®ion=" + $(activeTr).attr("data-region")
|
||||
}
|
||||
if($(activeTr).attr("data-block")!=undefined){
|
||||
url =url + "&block=" + $(activeTr).attr("data-block")
|
||||
}
|
||||
window.open(url,'_blank');
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
-->
|
||||
</#compress>
|
||||
@@ -0,0 +1,192 @@
|
||||
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
|
||||
<#compress>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>指导价数据</title>
|
||||
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/main_simple.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/jnotify/jNotify.jquery.css?v=${version}" />
|
||||
<style>
|
||||
.row-fluid:before, .row-fluid:after {
|
||||
display: none;
|
||||
}
|
||||
.thdiv {
|
||||
background-image: linear-gradient(to bottom, #FFF, #CCC);
|
||||
}
|
||||
.pagination-page {
|
||||
background: #fff url(../images/skin/shadow.jpg) bottom repeat-x;
|
||||
border-bottom: 1px solid #ccc;
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
overflow: hidden;
|
||||
padding: 2px 3px;
|
||||
text-align: right;
|
||||
}
|
||||
.pagination-page .page-num,.pagination-page .previous,.pagination-page .next
|
||||
{
|
||||
background: #fff;
|
||||
border: 1px solid #ccc;
|
||||
border-color: #ccc #aaa #aaa #ccc;
|
||||
color: #666;
|
||||
margin: 0 3px;
|
||||
padding: 2px 6px;
|
||||
}
|
||||
.pagination-page .current-page {
|
||||
padding: 2px 3px;
|
||||
color: #666;
|
||||
background: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
.main-content {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
.row-fluid .span2 {
|
||||
width: 100%;
|
||||
*width: 100%;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.sort-th:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<#include "/common_js.ftl" />
|
||||
<#include "/layout/header.ftl" />
|
||||
<#setting number_format="0.####">
|
||||
<div class="main-content">
|
||||
<div class="menuButton">
|
||||
<a href="../rentPriceUpdate/guidingPrice?id=${district.id!}" class="list" target="_self">添加指导价</a>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span12" style="margin-left:0;">
|
||||
<div id="thDiv" class="thdiv">
|
||||
|
||||
<table class="table table-bordered" style="margin-bottom:0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="4%">城市</th>
|
||||
<th width="4%">区域</th>
|
||||
<th width="4%">小区名</th>
|
||||
<th width="4%">日期</th>
|
||||
<th width="4%">添加人</th>
|
||||
<th width="4%">添加价格</th>
|
||||
<th width="4%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<table class="table table-bordered table-striped table-hover" id="mainTab">
|
||||
<tbody>
|
||||
<#list guidingPrices! as guid>
|
||||
<tr>
|
||||
<td width="4%">${guid.city!''}</td>
|
||||
<td width="4%">${guid.region!}</td>
|
||||
<td width="4%">${guid.name!}</td>
|
||||
<td width="4%">${guid.guidingDate?string("yyyy-MM-dd")}</td>
|
||||
<td width="4%">${guid.guidingPerson!}</td>
|
||||
<td width="4%">${guid.guidingValue!}</td>
|
||||
<td width="4%">
|
||||
<a target="_self" href="../rentPriceUpdate/guidingPrice?gid=${guid.id}&id=${district.id}">编辑</a>
|
||||
<a href="javascript:void(null)" class="deleteData" data-id="${guid.id}">删除</a>
|
||||
<button type="button" onclick="javascript:$('#myReCompModal').modal('show')" class="btn btn-danger" >重算均价</button>
|
||||
</td>
|
||||
</tr>
|
||||
</#list>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="myReCompModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">是否确定?</h3>
|
||||
</div>
|
||||
<div class="modal-body error">
|
||||
<p>1.耗时较长,请谨慎操作!</p>
|
||||
<p>2.计算<b>${district.name!}</b>的历史价格!</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true" aria-hidden="true">关闭</button>
|
||||
<button class="btn btn-primary" name="reComputeBtn" type="all">重算历史</button>
|
||||
<button class="btn btn-primary" name="reComputeBtn" type="week">最近一期</button>
|
||||
<button class="btn btn-primary" name="reComputeBtn" type="month">最近一月</button>
|
||||
<button class="btn btn-primary" name="reComputeBtn" type="quarter">最近季度</button>
|
||||
<button class="btn btn-primary" name="reComputeBtn" type="year">最近一年</button>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="../js/jquery-1.9.1.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../js/city_select.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../js/jquery.form.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../js/jNotify.jquery.min.js?v=${version}"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
//删除操作
|
||||
$(".deleteData").click(function(){
|
||||
var obj = $(this).parent().parent();
|
||||
var gid = $(this).attr("data-id");
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '../rentPriceUpdate/deleteGuidingPriceNew',
|
||||
data: {gid:gid},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
obj.remove();
|
||||
},
|
||||
error : function() {
|
||||
alert("删除失败!");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("button[name='reComputeBtn']").click(function(){
|
||||
var type = $(this).attr('type');
|
||||
var data ={};
|
||||
var commands = Array();
|
||||
commands.push({city:'${district.city!}',region:'${district.region!}',name:'${district.name!}',estateType:'${district.estateType2!}'})
|
||||
data.commands = commands ;
|
||||
data.calcRange = type;
|
||||
$.ajax({
|
||||
url:"../rentPriceUpdate/reCompute",
|
||||
dataType:"json",
|
||||
type:'POST',
|
||||
data:{data:JSON.stringify(data)},
|
||||
success:function(data){
|
||||
showSuccessMsg(data.msg)
|
||||
$('#myReCompModal').modal('hide')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function showSuccessMsg(msg){
|
||||
jNotify(
|
||||
msg,
|
||||
{
|
||||
autoHide : true,
|
||||
clickOverlay : false,
|
||||
MinWidth : 250,
|
||||
TimeShown : 2000,
|
||||
ShowTimeEffect : 1000,
|
||||
HideTimeEffect : 1000,
|
||||
LongTrip :20,
|
||||
HorizontalPosition : 'right',
|
||||
VerticalPosition : 'top',
|
||||
ShowOverlay : true,
|
||||
ColorOverlay : '#000',
|
||||
OpacityOverlay : 0.3,
|
||||
onClosed : function(){
|
||||
|
||||
},
|
||||
onCompleted : function(){
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</#compress>
|
||||
@@ -0,0 +1,111 @@
|
||||
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
|
||||
<#compress>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>添加指导价</title>
|
||||
<link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}" />
|
||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<#include "/common_js.ftl" />
|
||||
<#include "/layout/header.ftl" />
|
||||
<div class="main-content">
|
||||
<div id = "save">
|
||||
<form id="lineForm" method = "post">
|
||||
<table class = "saveTable">
|
||||
<tr>
|
||||
<td class = "t1">
|
||||
城市
|
||||
<td>
|
||||
<input name="city" id="city" type="text" disabled="true" value="${district.city!}" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class = "t1">
|
||||
区域
|
||||
<td>
|
||||
<input name="region" id="region" type="text" disabled="true" value="${district.region!}" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class = "t1">
|
||||
小区名
|
||||
<td>
|
||||
<input name="name" id="name" type="text" disabled="true" value="${district.name!}" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class = "t1">
|
||||
日期<font color="red">*</font></td>
|
||||
<td>
|
||||
<input placeholder="指导日期" id="guidingDate" name="guidingDate" readonly="true" type="text" value="${guidingDate!}" class="input-small" onfocus="WdatePicker({dateFmt:'yyyyMMdd',maxDate:'%y-%M-{%d-7}'})">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class = "t1">
|
||||
指导价格<font color="red">*</font></td>
|
||||
<td>
|
||||
<input placeholder="指导价格" name="guidingPrice" id="guidingPrice" type="number" value="${guidingPrice!}" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class = "saveTable">
|
||||
<tr>
|
||||
<td colspan="2" >
|
||||
<input id="submitForm" type="button" value="确认添加" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../js/kindeditor-4.0/kindeditor.js"></script>
|
||||
<script type="text/javascript" src="../js/kindeditor-4.0/lang/zh_CN.js"></script>
|
||||
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=3E63A744012f88c9a73a2f051aece58b"></script>
|
||||
<script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp&key=5fc2a1dec61fbd1df575a0967b87aa20"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
dayStr=function(){ //获得本周的开端日期
|
||||
var nowDate = new Date();
|
||||
return nowDate.getDay();
|
||||
}
|
||||
|
||||
|
||||
$("#submitForm").click(function(){
|
||||
var guidingDate = $("#guidingDate").val();
|
||||
if (guidingDate == '' || guidingDate == undefined) {
|
||||
alert('时间不能为空!');
|
||||
return false;
|
||||
}
|
||||
|
||||
var guidingPrice = $("#guidingPrice").val();
|
||||
if (region == '') {
|
||||
alert('指导价格不能为空!');
|
||||
return false;
|
||||
}
|
||||
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '../rentPriceUpdate/saveGuidingPrice',
|
||||
data: {id:"${district.id}",guidingDate:guidingDate,guidingPrice:guidingPrice,gid:"${gid!}"},
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
window.location.href = "../rentPriceUpdate/guidingList?id=${district.id}";
|
||||
},
|
||||
error : function() {
|
||||
alert("操作失败!");
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</#compress>
|
||||
@@ -0,0 +1,125 @@
|
||||
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
|
||||
<#compress>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>均价系统-${cityDisplay!}价格质量跟踪</title>
|
||||
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/main_simple.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/pagination.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/jnotify/jNotify.jquery.css?v=${version}" />
|
||||
<#include "/common_js.ftl" />
|
||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||
<script type="text/javascript" src="../js/jquery-1.9.1.js"></script>
|
||||
<script type="text/javascript" src="../js/jquery.pagination.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/highcharts.js"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/exporting-3.0.7.js"></script>
|
||||
<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="../js/jNotify.jquery.min.js?v=${version}"></script>
|
||||
<style>
|
||||
.cur{
|
||||
background-color:#eee;
|
||||
}
|
||||
label{display:inline-block}
|
||||
.stab {
|
||||
border: 1px solid #e0e0e0; padding: 8px 5px; cursor:pointer;border-left:none;
|
||||
width: 130px;
|
||||
float: left;
|
||||
text-align: center;
|
||||
}
|
||||
.leg {
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.leg input{
|
||||
margin-top: -2px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<#setting number_format="0.###########"/>
|
||||
<#include "/layout/header.ftl" />
|
||||
|
||||
<div class="main-content" style="padding:10px 10px;">
|
||||
<table class="table table-bordered table-condensed">
|
||||
<tr>
|
||||
<th>查询条件</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<form action="listQR" style="padding-bottom: 10px;">
|
||||
<div style="padding-top:5px;">
|
||||
<@d_city defaultValue="${cityDisplay!}" callback="changeCity" callbackField="display" showCountry="1" name="cityDisplay"/>
|
||||
</div>
|
||||
<div style="padding-top: 1px;">
|
||||
<label for="name">时间:</label>
|
||||
<input id="startDate" class="form-control" style="width:100px;" name="sdateStart" value="${sdateStart!}" onfocus="WdatePicker({dateFmt:'yyyyMMdd',maxDate:'#F{$dp.$D(\'endDate\')||\'%y%M%d\'}',minDate:'20070101'})" />
|
||||
-
|
||||
<input id="endDate" class="form-control" style="width:100px;" name="sdateEnd" value="${sdateEnd!}" onfocus="WdatePicker({dateFmt:'yyyyMMdd',maxDate:'%y%M%d',minDate:'#F{$dp.$D(\'startDate\')||\'20070101\'}'})"/>
|
||||
<input id="queryBtn" class ="btn btn-primary" type="submit" value="查询" />
|
||||
</div>
|
||||
<input type="hidden" name="stype" value="${stype!}">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="stabs">
|
||||
<span class="stab <#if stype=="1">cur</#if>">
|
||||
<a name="tab1" href="javascript:;" ref="listQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=1" class="list">小区量</a>
|
||||
</span>
|
||||
<span class="stab <#if stype=="2">cur</#if>">
|
||||
<a name="tab2" href="javascript:;" ref="listQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=2" class="list">平均可信度</a>
|
||||
</span>
|
||||
<span class="stab <#if stype=="3">cur</#if>">
|
||||
<a name="tab3" href="javascript:;" ref="listQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=3" class="list">测试案例数量</a>
|
||||
</span>
|
||||
<span class="stab <#if stype=="4">cur</#if>">
|
||||
<a name="tab4" href="javascript:;" ref="listQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=4" class="list">案例差比<10%量</a>
|
||||
</span>
|
||||
<span class="stab <#if stype=="5">cur</#if>">
|
||||
<a name="tab5" href="javascript:;" ref="listQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=5" class="list">案例差比<20%量</a>
|
||||
</span>
|
||||
<span class="stab <#if stype=="6">cur</#if>">
|
||||
<a name="tab6" href="javascript:;" ref="listQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=6" class="list">案例差比<30%量</a>
|
||||
</span>
|
||||
<#--
|
||||
<span <#if stype=="7">class="cur"</#if> style="border: 1px solid #e0e0e0; padding: 8px 10px; margin-top: 10px;cursor:pointer;border-left:none;">
|
||||
<a name="tab7" href="listQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=7" class="list">房源样本量</a>
|
||||
</span>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<div id="fregment" style="margin-top: 10px"></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function changeCity(cityDisplay) {
|
||||
var currUrl = "listQR?cityDisplay=####&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=${stype!}&vts=${vts!}";
|
||||
location.href = currUrl.replace("####", cityDisplay);
|
||||
}
|
||||
|
||||
$("#stabs a").click(function(){
|
||||
var ref = $(this).attr('ref')
|
||||
var vts = [];
|
||||
$("#chartLegend input").each(function(){
|
||||
if ($(this).is(":checked")) {
|
||||
vts.push($(this).val());
|
||||
}
|
||||
})
|
||||
location.href = ref + "&vts=" + vts.join("-")
|
||||
})
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#fregment").load("loadQRData?cityDisplay=${cityDisplay!}&stype=${stype!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd}&vts=${vts!}");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</#compress>
|
||||
@@ -0,0 +1,110 @@
|
||||
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
|
||||
<#compress>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>均价系统-${cityDisplay!}样本质量跟踪</title>
|
||||
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/main_simple.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/pagination.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/jnotify/jNotify.jquery.css?v=${version}" />
|
||||
<#include "/common_js.ftl" />
|
||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||
<script type="text/javascript" src="../js/jquery-1.9.1.js"></script>
|
||||
<script type="text/javascript" src="../js/jquery.pagination.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/highcharts.js"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/exporting-3.0.7.js"></script>
|
||||
<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="../js/jNotify.jquery.min.js?v=${version}"></script>
|
||||
<style>
|
||||
.cur{
|
||||
background-color:#eee;
|
||||
}
|
||||
label{display:inline-block}
|
||||
.stab {
|
||||
border: 1px solid #e0e0e0; padding: 8px 5px; cursor:pointer;border-left:none;
|
||||
width: 130px;
|
||||
float: left;
|
||||
text-align: center;
|
||||
}
|
||||
.leg {
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.leg input{
|
||||
margin-top: -2px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<#setting number_format="0.###########"/>
|
||||
<#include "/layout/header.ftl" />
|
||||
|
||||
<div class="main-content" style="padding:10px 10px;">
|
||||
<table class="table table-bordered table-condensed">
|
||||
<tr>
|
||||
<th>查询条件</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<form action="listSQR" style="padding-bottom: 10px;">
|
||||
<div style="padding-top:5px;">
|
||||
<@d_city defaultValue="${cityDisplay!}" callback="changeCity" callbackField="display" showCountry="1" name="cityDisplay"/>
|
||||
</div>
|
||||
<div style="padding-top: 1px;">
|
||||
<label for="name">时间:</label>
|
||||
<input id="startDate" class="form-control" style="width:100px;" name="sdateStart" value="${sdateStart!}" onfocus="WdatePicker({dateFmt:'yyyyMMdd',maxDate:'#F{$dp.$D(\'endDate\')||\'%y%M%d\'}',minDate:'20070101'})" />
|
||||
-
|
||||
<input id="endDate" class="form-control" style="width:100px;" name="sdateEnd" value="${sdateEnd!}" onfocus="WdatePicker({dateFmt:'yyyyMMdd',maxDate:'%y%M%d',minDate:'#F{$dp.$D(\'startDate\')||\'20070101\'}'})"/>
|
||||
<input id="queryBtn" class ="btn btn-primary" type="submit" value="查询" />
|
||||
</div>
|
||||
<input type="hidden" name="stype" value="${stype!}">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div>
|
||||
<span class="stab <#if stype=="1" || stype=="2" >cur</#if>">
|
||||
一个月
|
||||
<a name="tab1" href="listSQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=1" class="list" <#if stype?? && stype=="1">style="font-weight: bold;font-size: 16px;" </#if> >数量</a>
|
||||
<a name="tab1" href="listSQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=2" class="list" <#if stype?? && stype=="2">style="font-weight: bold;font-size: 16px;"</#if>>比例</a>
|
||||
</span>
|
||||
<span class="stab <#if stype=="3" || stype=="4" >cur</#if>">
|
||||
季度
|
||||
<a name="tab1" href="listSQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=3" class="list" <#if stype?? && stype=="3">style="font-weight: bold;font-size: 16px;" </#if> >数量</a>
|
||||
<a name="tab1" href="listSQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=4" class="list" <#if stype?? && stype=="4">style="font-weight: bold;font-size: 16px;" </#if> >比例</a>
|
||||
</span>
|
||||
<span class="stab <#if stype=="5" || stype=="6" >cur</#if>">
|
||||
半年
|
||||
<a name="tab1" href="listSQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=5" class="list" <#if stype?? && stype=="5">style="font-weight: bold;font-size: 16px;" </#if> >数量</a>
|
||||
<a name="tab1" href="listSQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=6" class="list" <#if stype?? && stype=="6">style="font-weight: bold;font-size: 16px;" </#if> >比例</a>
|
||||
</span>
|
||||
<span class="stab <#if stype=="7" || stype=="8" >cur</#if>">
|
||||
一年
|
||||
<a name="tab1" href="listSQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=7" class="list" <#if stype?? && stype=="7">style="font-weight: bold;font-size: 16px;" </#if> >数量</a>
|
||||
<a name="tab1" href="listSQR?cityDisplay=${cityDisplay!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=8" class="list" <#if stype?? && stype=="8">style="font-weight: bold;font-size: 16px;" </#if> >比例</a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="fregment" style="margin-top: 10px"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function changeCity(cityDisplay) {
|
||||
var currUrl = "listSQR?cityDisplay=####&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd!}&stype=${stype!}&vts=${vts!}";
|
||||
location.href = currUrl.replace("####", cityDisplay);
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#fregment").load("loadSQRData?cityDisplay=${cityDisplay!}&stype=${stype!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd}&vts=${vts!}");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</#compress>
|
||||
@@ -0,0 +1,102 @@
|
||||
<div id="container"></div>
|
||||
<div id="chartLegend" class="leg" style="display: none;">
|
||||
<input id="vt1" name="vts" value="1" type="checkbox"/><label for="vt1" style="color:#79434D;">全部</label>
|
||||
<input id="vt4" name="vts" value="4" type="checkbox"/><label for="vt4" style="color:#3A696F;">自身样本</label>
|
||||
<input id="vt7" name="vts" value="7" type="checkbox"/><label for="vt7" style="color:#DD9F19;">周边计算</label>
|
||||
<input id="vt5" name="vts" value="5" type="checkbox"/><label for="vt5" style="color:#6BB7C5;">第三方</label>
|
||||
<input id="vt6" name="vts" value="6" type="checkbox"/><label for="vt6" style="color:#729827;">成交数据</label>
|
||||
<input id="vt3" name="vts" value="3" type="checkbox"/><label for="vt3" style="color:#C877C8;">指导价</label>
|
||||
<input id="vt2" name="vts" value="2" type="checkbox"/><label for="vt2" style="color:#BBBD81;">无法计算</label>
|
||||
<input id="vt8" name="vts" value="8" type="checkbox"/><label for="vt8" style="color:#CAB0A2;">推算</label>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
Highcharts.setOptions({
|
||||
global: {
|
||||
useUTC: false
|
||||
}
|
||||
});
|
||||
|
||||
$('#container').highcharts({
|
||||
chart: {
|
||||
type: 'line'
|
||||
},
|
||||
title: {
|
||||
text: '${cityDisplay!}<#if stype=="1">小区量<#elseif stype=="2">平均可信度<#elseif stype=="3">测试案例数量<#elseif stype=="4">案例差比<10%量<#elseif stype=="5">案例差比<20%量<#elseif stype=="6">案例差比<30%量<#elseif stype=="7">样本数量</#if>情况展示'
|
||||
},
|
||||
subtitle: {
|
||||
text: '${t_util.formatDate(t_util.parseDate(sdateStart?string, 'yyyyMMdd'), 'yyyy年MM月dd日')} - ${t_util.formatDate(t_util.parseDate(sdateEnd?string, 'yyyyMMdd'), 'yyyy年MM月dd日')}'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'datetime',
|
||||
dateTimeLabelFormats: { // don't display the dummy year
|
||||
month: '%Y-%m-%d',
|
||||
year: '%Y'
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
title: {
|
||||
text: '值'
|
||||
},
|
||||
min: 0
|
||||
},
|
||||
tooltip: {
|
||||
formatter: function() {
|
||||
return '<b>'+ this.series.name +'</b><br>'+ Highcharts.dateFormat('%Y-%m-%d', this.x) +' : '+ this.y;
|
||||
}
|
||||
},
|
||||
legend : {
|
||||
enabled : false
|
||||
},
|
||||
|
||||
plotOptions: {
|
||||
line: {
|
||||
dataLabels: {
|
||||
enabled: true,
|
||||
formatter: function() {
|
||||
return this.y;
|
||||
}
|
||||
},
|
||||
enableMouseTracking: true
|
||||
}
|
||||
},
|
||||
|
||||
series: ${series!}
|
||||
});
|
||||
|
||||
$("#chartLegend").show();
|
||||
|
||||
var vts = "${vts!}".split("-");
|
||||
$.each(vts, function(i, vt){
|
||||
$("#chartLegend input").each(function(){
|
||||
if($(this).val() == vt) {
|
||||
$(this).prop("checked", true);
|
||||
$(this).next().css("font-weight", "bold");
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$("#chartLegend input").change(function(){
|
||||
var vts = [];
|
||||
$("#chartLegend input").each(function(){
|
||||
if ($(this).is(":checked")) {
|
||||
vts.push($(this).val());
|
||||
}
|
||||
})
|
||||
|
||||
if(vts.length > 0) {
|
||||
$("#fregment").load(
|
||||
"loadQRData?cityDisplay=${cityDisplay!}&stype=${stype!}&sdateStart=${sdateStart!}&sdateEnd=${sdateEnd}&vts=" + vts.join("-"),
|
||||
function(){
|
||||
$("#chartLegend input").each(function(){
|
||||
if ($(this).is(":checked")) {
|
||||
$(this).next().css("font-weight", "bold");
|
||||
}else {
|
||||
$(this).next().css("font-weight", "");
|
||||
}
|
||||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,49 @@
|
||||
<div id="container"></div>
|
||||
<div id="chartLegend" class="leg" style="display: none;">
|
||||
<input id="vt1" name="vts" value="1" type="checkbox"/><label for="vt1">一个月</label>
|
||||
<input id="vt2" name="vts" value="2" type="checkbox"/><label for="vt2">季度</label>
|
||||
<input id="vt3" name="vts" value="3" type="checkbox"/><label for="vt3">半年</label>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
Highcharts.setOptions({
|
||||
global: {
|
||||
useUTC: false
|
||||
}
|
||||
});
|
||||
|
||||
$('#container').highcharts({
|
||||
chart: {
|
||||
type: 'spline'
|
||||
},
|
||||
title: {
|
||||
text: '${cityDisplay!}<#if stype=="1">数量(一个月)<#elseif stype=="2">比例(一个月)<#elseif stype=="3">数量(季度)<#elseif stype=="4">比例(季度)<#elseif stype=="5">数量(半年)<#elseif stype=="6">比例(半年)<#elseif stype=="7">数量(一年)<#elseif stype=="8">比例(一年)</#if>情况展示'
|
||||
},
|
||||
subtitle: {
|
||||
text: '${t_util.formatDate(t_util.parseDate(sdateStart?string, 'yyyyMMdd'), 'yyyy年MM月dd日')} - ${t_util.formatDate(t_util.parseDate(sdateEnd?string, 'yyyyMMdd'), 'yyyy年MM月dd日')}'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'datetime',
|
||||
dateTimeLabelFormats: { // don't display the dummy year
|
||||
month: '%Y-%m-%d',
|
||||
year: '%Y'
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
title: {
|
||||
text: '值'
|
||||
},
|
||||
min: 0
|
||||
},
|
||||
tooltip: {
|
||||
formatter: function() {
|
||||
return '<b>'+ this.series.name +'</b><br>'+ Highcharts.dateFormat('%Y-%m-%d', this.x) +' : '+ this.y;
|
||||
}
|
||||
},
|
||||
// legend : {
|
||||
// enabled : false
|
||||
// },
|
||||
series: ${series!}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,160 @@
|
||||
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
|
||||
<#compress>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>均价更新</title>
|
||||
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/main_simple.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/pagination.css?v=${version}" />
|
||||
<link rel="stylesheet" type="text/css" href="../style/jnotify/jNotify.jquery.css?v=${version}" />
|
||||
<#include "/common_js.ftl" />
|
||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||
<script type="text/javascript" src="../js/jquery-1.9.1.js"></script>
|
||||
<script type="text/javascript" src="../js/jquery.pagination.js?v=${version}"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/highcharts-3.0.7.js"></script>
|
||||
<script type="text/javascript" src="../js/highcharts/exporting-3.0.7.js"></script>
|
||||
<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="../js/jNotify.jquery.min.js?v=${version}"></script>
|
||||
<style>
|
||||
.con {
|
||||
border-radius:0px;
|
||||
}
|
||||
label{display:inline-block}
|
||||
.input-small{
|
||||
margin:0px;
|
||||
}
|
||||
#city-border-mid{
|
||||
margin-top:6px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<#include "/layout/header.ftl" />
|
||||
<div class="main-content" style="padding:10px 10px;">
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<th>查询条件</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<form action="taskList">
|
||||
<@d_city defaultValue="${cityDisplay!}" callbackField="display" name="cityDisplay"/>
|
||||
<label for="stype">任务类型:</label>
|
||||
<select id="stype" name="stype" class="form-control" style="width:70px;">
|
||||
<option value="" <#if (stype!'') == ''>selected="selected"</#if> >不限</option>
|
||||
<option value="city" <#if (stype!'')=='city'>selected="selected"</#if>>城市</option>
|
||||
<option value="region" <#if (stype!'')=='region'>selected="selected"</#if>>区域</option>
|
||||
<option value="block" <#if (stype!'')=='block'>selected="selected"</#if>>板块</option>
|
||||
<option value="district" <#if (stype!'')=='district'>selected="selected"</#if>>小区</option>
|
||||
</select>
|
||||
<label for="keyword">关键字:</label>
|
||||
<input id="keyword" class="form-control" name="keyword" value="${keyword!}" style="width:100px;" />
|
||||
<label for="startDate">开始时间:</label>
|
||||
<#if startDate??>
|
||||
<input id="startDate" class="form-control" style="width:100px;" name="startDate" value="${startDate!?string('yyyy-MM-dd')}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endDate\')||\'%y-%M-%d\'}',minDate:'2007-1-1'})" />
|
||||
<#else>
|
||||
<input id="startDate" class="form-control" style="width:100px;" name="startDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endDate\')||\'%y-%M-%d\'}',minDate:'2007-1-1'})" />
|
||||
</#if>
|
||||
<label for="endDate">结束日期:</label>
|
||||
<#if endDate??>
|
||||
<input id="endDate" class="form-control" style="width:100px;" name="endDate" value="${endDate?string('yyyy-MM-dd')!}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'%y-%M-%d',minDate:'#F{$dp.$D(\'startDate\')||\'2007-1-1\'}'})"/>
|
||||
<#else>
|
||||
<input id="endDate" class="form-control" style="width:100px;" name="endDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'%y-%M-%d',minDate:'#F{$dp.$D(\'startDate\')||\'2007-1-1\'}'})"/>
|
||||
</#if>
|
||||
<input id="queryBtn" class ="btn btn-primary" type="submit" value="查询" />
|
||||
<a id="queryBtn" class ="btn btn-primary" href="../rentPriceUpdate/doCreatTask" >创建任务</a>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="dataSheet" class="table table-bordered table-hover">
|
||||
<tr><th>城市</th><th>区域</th><th>板块</th><th>小区名</th><th>计算类型</th><th>计算时间</th><th>状态</th><th>优先级</th><th>物业类型</th><th>种类</th><th>创建时间</th><th>备注</th></tr>
|
||||
<#list calcCommands as it>
|
||||
<tr>
|
||||
<td>${it.city!}</td><td>${it.region!}</td><td>${it.block!}</td><td>${it.name}</td>
|
||||
<td>
|
||||
<#if it.calcType ==0>指定日期<#elseif it.calcType ==1 >全部计算</#if>
|
||||
</td>
|
||||
<td>
|
||||
<#if it.calcDate??>
|
||||
${it.calcDate?string("yyyy-MM-dd")}</td>
|
||||
</#if>
|
||||
<td>
|
||||
<#if it.status ==0>
|
||||
<span class="label">初始状态</span>
|
||||
<#elseif it.status == 1>
|
||||
<span class="label label-info">正在处理</span>
|
||||
<#elseif it.status == 2>
|
||||
<span class="label label-success">处理完成</span>
|
||||
<#elseif it.status == 3>
|
||||
<span class="label label-important">处理异常</span>
|
||||
</#if>
|
||||
</td>
|
||||
<td>
|
||||
<#if it.priority ==0>
|
||||
<span class="badge badge-success">0</span>
|
||||
<#elseif it.priority == 1>
|
||||
<span class="badge badge-warning">1</span>
|
||||
<#elseif it.priority == 2>
|
||||
<span class="badge badge-important">2</span>
|
||||
</#if>
|
||||
</td>
|
||||
<td>${it.estateType!}</td>
|
||||
<td>${it.category!}</td>
|
||||
<td>${it.creationDate?string("yyyy-MM-dd HH:mm")}</td>
|
||||
<td>${it.remark!}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
<tfoot>
|
||||
<tr><td colspan="12">
|
||||
<@d_pager action = "taskList" currentPage = pager.currentPage controller = "rentPriceUpdate" totalPages = pager.totalPages/>
|
||||
</td></tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">警告</h3>
|
||||
</div>
|
||||
<div class="modal-body error">
|
||||
<p>耗时操作,请谨慎操作!</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true" aria-hidden="true">关闭</button>
|
||||
<button class="btn btn-primary" id="reComputeBtn">计算</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<script type="text/javascript">
|
||||
function showSuccessMsg(msg){
|
||||
jNotify(
|
||||
msg,
|
||||
{
|
||||
autoHide : true,
|
||||
clickOverlay : false,
|
||||
MinWidth : 250,
|
||||
TimeShown : 2000,
|
||||
ShowTimeEffect : 1000,
|
||||
HideTimeEffect : 1000,
|
||||
LongTrip :20,
|
||||
HorizontalPosition : 'right',
|
||||
VerticalPosition : 'top',
|
||||
ShowOverlay : true,
|
||||
ColorOverlay : '#000',
|
||||
OpacityOverlay : 0.3,
|
||||
onClosed : function(){
|
||||
|
||||
},
|
||||
onCompleted : function(){
|
||||
}
|
||||
});
|
||||
}
|
||||
$(function(){
|
||||
|
||||
});
|
||||
</script>
|
||||
</#compress>
|
||||
@@ -72,7 +72,9 @@
|
||||
</select>
|
||||
<label for="districtName">名称:</label>
|
||||
<input type="text" name="districtName" id="districtName" class="input-medium" style="margin-top:9px;" value="${districtName!}" ></input>
|
||||
<label for="cat">类型:</label>
|
||||
<label for="estateType">物业类型:</label>
|
||||
<input type="text" name="estateType" id="estateType" class="input-medium" style="margin-top:9px;" value="${estateType!}" ></input>
|
||||
<label for="cat">类型:</label>
|
||||
<select id="cat" name="cat" class="form-control" style="width: 110px;">
|
||||
<option value="">不限</option>
|
||||
<option <#if cat! == 'sell'>selected</#if> value="sell">二手房</option>
|
||||
@@ -98,13 +100,29 @@
|
||||
<option <#if room?? && room==9>selected="true"</#if> value="9">9室</option>
|
||||
</select>
|
||||
</span>
|
||||
|
||||
<label for="districtName">网站:</label>
|
||||
|
||||
<label for="status">状态:</label>
|
||||
<select id="status" name="status" class="form-control" style="width: 80px;">
|
||||
<option value="">不限</option>
|
||||
<option <#if status?? && status==0>selected="true"</#if> value="0">正常</option>
|
||||
<option <#if status?? && status==1>selected="true"</#if> value="1">已删除</option>
|
||||
</select>
|
||||
|
||||
<label for="rootName">网站:</label>
|
||||
<input type="text" name="rootName" id="rootName" class="input-medium" style="margin-top:9px;" value="${rootName!}" ></input>
|
||||
<label for="startDate">时间:</label>
|
||||
<input id="startDate" placeholder="开始时间" class="form-control" style="width:70px;" name="startDate" value="${startDate!}" onfocus="WdatePicker({dateFmt:'yyyyMMdd',maxDate:'#F{$dp.$D(\'endDate\')||\'%y-%M-%d\'}',minDate:'2007-1-1'})" />-
|
||||
<input id="endDate" placeholder="结束时间" class="form-control" style="width:70px;" name="endDate" value="${endDate!}" onfocus="WdatePicker({dateFmt:'yyyyMMdd',maxDate:'%y-%M-%d',minDate:'#F{$dp.$D(\'startDate\')||\'2007-1-1\'}'})"/>
|
||||
<label for="area">面积:</label>
|
||||
<input class="form-control" style="width:50px;" name="startArea" id="startArea" value="${startArea!}"/>-
|
||||
<input class="form-control" style="width:50px;" name="endArea" id="endArea" value="${endArea!}"/>
|
||||
<label for="area">单价:</label>
|
||||
<input class="form-control" style="width:50px;" name="startPrice" id="startPrice" value="${startPrice!}"/>-
|
||||
<input class="form-control" style="width:50px;" name="endPrice" id="endPrice" value="${endPrice!}"/>
|
||||
|
||||
<input id="queryBtn" class ="btn btn-primary" type="submit" value="查询" />
|
||||
<input class ="btn btn-primary" id="batchDeleteByParam" value="条件删除" style="width: 75px;"/>
|
||||
<input class ="btn btn-primary" id="batchUpdateEstateType" value="批量修改物业类型" style="width: 120px;"/>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -131,16 +149,18 @@
|
||||
<th style="width:50px;">面积</th>
|
||||
<th style="width:50px;">单价</th>
|
||||
<th style="width:60px;">总价</th>
|
||||
<th style="width:90px;"><#if sort?? && sort == 'p_date_desc'><a href="../seawater/houseList?cityDisplay=${cityDisplay!}®ion=${region!}&districtName=${districtName!}&sort=p_date_asc&cat=${cat!}&&rootName=${rootName!}&startDate=${startDate!}&endDate=${endDate!}">发布时间</a>↓
|
||||
<#elseif sort?? && sort == 'p_date_asc'><a href="../seawater/houseList?cityDisplay=${cityDisplay!}®ion=${region!}&districtName=${districtName!}&sort=p_date_desc&cat=${cat!}&&rootName=${rootName!}&startDate=${startDate!}&endDate=${endDate!}">发布时间</a>↑
|
||||
<#else><a href="../seawater/houseList?cityDisplay=${cityDisplay!}®ion=${region!}&districtName=${districtName!}&sort=p_date_asc&cat=${cat!}&rootName=${rootName!}&startDate=${startDate!}&endDate=${endDate!}">发布时间</a>↓</#if>
|
||||
<th style="width:90px;"><#if sort?? && sort == 'p_date_desc'><a href="../seawater/houseList?cityDisplay=${cityDisplay!}®ion=${region!}&districtName=${districtName!}&sort=p_date_asc&cat=${cat!}&&rootName=${rootName!}&startDate=${startDate!}&endDate=${endDate!}&room=${room!}&status=${status!}&estateType=${estateType!}&startArea${startArea!}&endArea=${endArea!}&startPrice=${startPrice!}&endPrice=${endPrice!}">发布时间</a>↓
|
||||
<#elseif sort?? && sort == 'p_date_asc'><a href="../seawater/houseList?cityDisplay=${cityDisplay!}®ion=${region!}&districtName=${districtName!}&sort=p_date_desc&cat=${cat!}&&rootName=${rootName!}&startDate=${startDate!}&endDate=${endDate!}&room=${room!}&status=${status!}&estateType=${estateType!}&startArea${startArea!}&endArea=${endArea!}&startPrice=${startPrice!}&endPrice=${endPrice!}">发布时间</a>↑
|
||||
<#else><a href="../seawater/houseList?cityDisplay=${cityDisplay!}®ion=${region!}&districtName=${districtName!}&sort=p_date_asc&cat=${cat!}&rootName=${rootName!}&startDate=${startDate!}&endDate=${endDate!}&room=${room!}&status=${status!}&estateType=${estateType!}&startArea${startArea!}&endArea=${endArea!}&startPrice=${startPrice!}&endPrice=${endPrice!}">发布时间</a>↓</#if>
|
||||
</th>
|
||||
<th style="width:50px;">室厅卫</th>
|
||||
<th style="width:50px;">楼层</th>
|
||||
<th style="width:60px;">板块</th>
|
||||
<th style="width:80px;">装修</th>
|
||||
<th style="width:70px;">朝向</th>
|
||||
<th style="width:70px;">物业类型</th>
|
||||
<th style="width:90px;">来源</th>
|
||||
<th style="width:90px;">状态</th>
|
||||
<th style="width:80px;">操作</th>
|
||||
</tr>
|
||||
<#if seawaterList??>
|
||||
@@ -172,7 +192,7 @@
|
||||
</#if>
|
||||
</td>
|
||||
<td>${it.area!' '}</td>
|
||||
<td>${(it.totalPrice / it.area)?string('#')}</td>
|
||||
<td>${it.avgPrice!' '}</td>
|
||||
<td>${it.totalPrice!' '}</td>
|
||||
<td>${it.pDate!}</td>
|
||||
<td>${it.room!'-'}/${it.hall!'-'}/${it.toilet!'-'}</td>
|
||||
@@ -180,6 +200,7 @@
|
||||
<td>${it.block!}</td>
|
||||
<td>${it.fitment!}</td>
|
||||
<td>${it.direction!}</td>
|
||||
<td>${it.estateType!}</td>
|
||||
<td>
|
||||
<#if it.url??>
|
||||
<a href="${it.url!}" target="_blank" title="${it.url!}">${t_util.urlToSiteName(it.url!)!'未知'}</a>
|
||||
@@ -187,6 +208,13 @@
|
||||
--
|
||||
</#if>
|
||||
</td>
|
||||
<td>
|
||||
<#if it.status == 0>
|
||||
正常
|
||||
<#else>
|
||||
已删除
|
||||
</#if>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:;" class="hrefClick" <#if it.name??>detail-name="${it.name}"</#if> <#if it.address??>detail-address="${it.address!}"</#if><#if it.mobile??>detail-mobile="${it.mobile}"</#if><#if it.category??>detail-category="${it.category}"</#if>>详情</a>
|
||||
<a href="javascript:;" name="todelete" detail-id="${it.id!}">删除</a>
|
||||
@@ -217,7 +245,26 @@
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true" aria-hidden="true">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="estateTypeModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">修改物业类型</h3>
|
||||
</div>
|
||||
<form class="form-horizontal" id="editEstateTypeForm">
|
||||
<div class="control-group" style="margin-top: 20px;">
|
||||
<label class="control-label" for="cityPop">物业类型</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="editEstateType" name="editEstateType" value=""/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" id="editSubmit">修改</button>
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript" src="../js/jquery.editable.js?v=${version}"></script>
|
||||
@@ -383,6 +430,106 @@
|
||||
}
|
||||
});
|
||||
|
||||
$("#batchDeleteByParam").click(function(){
|
||||
if(confirm('确认要删除当前查询条件下的所有数据吗?')) {
|
||||
var cityDisplay = $("input[name='cityDisplay']").val()
|
||||
var region = $("select[name='region']").val()
|
||||
var districtName = $("input[name='districtName']").val()
|
||||
var estateType = $("input[name='estateType']").val()
|
||||
var cat = $("select[name='cat']").val()
|
||||
var status = $("select[name='status']").val()
|
||||
var rootName = $("input[name='rootName']").val()
|
||||
var startDate = $("input[name='startDate']").val()
|
||||
var endDate = $("input[name='endDate']").val()
|
||||
var startArea = $("input[name='startArea']").val()
|
||||
var endArea = $("input[name='endArea']").val()
|
||||
var startPrice = $("input[name='startPrice']").val()
|
||||
var endPrice = $("input[name='endPrice']").val()
|
||||
if(cityDisplay == "" || region == "" || districtName == ""){
|
||||
alert("城市、区域、小区名称必填")
|
||||
return false;
|
||||
}
|
||||
var data = {"cityDisplay": cityDisplay, "region": region, "districtName": districtName,
|
||||
"estateType": estateType, "cat": cat, "status": status,
|
||||
"rootName": rootName, "startDate": startDate, "endDate": endDate,
|
||||
"startArea": startArea, "endArea": endArea, "startPrice": startPrice,
|
||||
"endPrice": endPrice}
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '../seawater/batchDeleteByParams',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
alert("批量删除操作成功");
|
||||
location.reload();
|
||||
},
|
||||
error : function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$("#batchUpdateEstateType").click(function(){
|
||||
$('#estateTypeModal').modal('show');
|
||||
});
|
||||
|
||||
$("#editSubmit").click(function(){
|
||||
var editEstateType = $("input[name='editEstateType']").val()
|
||||
if(editEstateType == ""){
|
||||
alert("物业类型必填")
|
||||
return false;
|
||||
}
|
||||
if(confirm('确认要修改当前查询条件下的物业类型吗?')) {
|
||||
var cityDisplay = $("input[name='cityDisplay']").val()
|
||||
var region = $("select[name='region']").val()
|
||||
var districtName = $("input[name='districtName']").val()
|
||||
var estateType = $("input[name='estateType']").val()
|
||||
var cat = $("select[name='cat']").val()
|
||||
var status = $("select[name='status']").val()
|
||||
var rootName = $("input[name='rootName']").val()
|
||||
var startDate = $("input[name='startDate']").val()
|
||||
var endDate = $("input[name='endDate']").val()
|
||||
var startArea = $("input[name='startArea']").val()
|
||||
var endArea = $("input[name='endArea']").val()
|
||||
var startPrice = $("input[name='startPrice']").val()
|
||||
var endPrice = $("input[name='endPrice']").val()
|
||||
if(cityDisplay == "" || region == "" || districtName == ""){
|
||||
alert("城市、区域、小区名称必填")
|
||||
return false;
|
||||
}
|
||||
console.log(startArea)
|
||||
console.log(endArea)
|
||||
console.log(startPrice)
|
||||
console.log(endPrice)
|
||||
console.log(estateType)
|
||||
if(startArea == "" && endArea == "" && startPrice == "" && endPrice == "" && estateType == ""){
|
||||
alert("面积,价格,物业类型必须至少一项有值")
|
||||
return false;
|
||||
}
|
||||
|
||||
var data = {"cityDisplay": cityDisplay, "region": region, "districtName": districtName,
|
||||
"estateType": estateType, "cat": cat, "status": status,
|
||||
"rootName": rootName, "startDate": startDate, "endDate": endDate,
|
||||
"startArea": startArea, "endArea": endArea, "startPrice": startPrice,
|
||||
"endPrice": endPrice, "editEstateType": editEstateType}
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '../seawater/batchUpdateEstateType',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(model) {
|
||||
alert("批量修改操作成功");
|
||||
location.reload();
|
||||
},
|
||||
error : function() {
|
||||
alert("批量修改操作失败");
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
$('#estateTypeModal').modal('hide');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
</#compress>
|
||||
@@ -241,10 +241,10 @@
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class = "t1">物业地址</td>
|
||||
<td class = "t1">产证地址</td>
|
||||
<td>
|
||||
<span class="labelModel1">${(evaluation.address)!}</span>
|
||||
<span class="editModel1 hide"><input type="text" name="address" value="${(evaluation.address)!}"/></span>
|
||||
<span class="labelModel1"><#if evaluation?? && evaluation.certificateAddress??>${(evaluation.certificateAddress)!}<#else>${(evaluation.address)!}</#if></span>
|
||||
<span class="editModel1 hide"><input type="text" name="certificateAddress" value="<#if evaluation?? && evaluation.certificateAddress??>${(evaluation.certificateAddress)!}<#else>${(evaluation.address)!}</#if>"/></span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<th width="6%">城市</th>
|
||||
<th width="6%">区域</th>
|
||||
<th width="10%">楼盘名称</th>
|
||||
<th width="14%">估价地址</th>
|
||||
<th width="14%">产证地址</th>
|
||||
<th width="10%">帐号</th>
|
||||
<th width="6%">面积</th>
|
||||
<th width="10%">总价</th>
|
||||
@@ -83,7 +83,7 @@
|
||||
<td>${it.city}</td>
|
||||
<td>${it.region!}</td>
|
||||
<td><a href="../yugudan/editEval?id=${it.id}">${it.districtName!}</a></td>
|
||||
<td>${it.address!}<#if it.houseNum??>${it.houseNum!}号</#if>
|
||||
<td><#if it.certificateAddress??>${(it.certificateAddress)!}<#else>${(it.address)!}</#if><#if it.houseNum??>${it.houseNum!}号</#if>
|
||||
<#if it.unitNum?? && it.unitNum?length gt 1>${it.unitNum!}单元</#if>
|
||||
<#if it.buildType!=3 && it.buildType!=8 && it.buildType!=0>
|
||||
<#if it.floorDesc?? && it.floorDesc?length gt 1>${it.floorDesc!}层</#if>
|
||||
|
||||
@@ -1847,6 +1847,9 @@ public class DataUtil {
|
||||
//
|
||||
// System.out.println(FourUpSixInto("258.393", 2));
|
||||
|
||||
String href = encodePicUrl("62afd81d303c3f827833bb03", "o", "upload");
|
||||
String link = "http://static.fangjia.com/stc/fs/"+href;
|
||||
System.out.println(link);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
FROM 192.168.0.19:9012/tomcat6:latest
|
||||
FROM 192.168.0.19:9012/tomcat6:220713
|
||||
COPY target/*.war /home/goojia/webapps/ROOT.war
|
||||
+87
-2
@@ -6,12 +6,20 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Handler;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.fangjia.core.util.DataUtil;
|
||||
import com.fangjia.core.util.DingDingMessageUtil;
|
||||
import com.fangjia.core.util.HttpRequest;
|
||||
import com.fangjia.core.util.HttpRequestException;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.fangjia.coresite.model.JsonModel;
|
||||
@@ -27,9 +35,12 @@ import com.fangjia.service.common.CookieName;
|
||||
import com.fangjia.service.fangjia.NewsResourceService;
|
||||
import com.fangjia.service.fangjia.SaleLeadsService;
|
||||
import com.fangjia.service.mongo.fangjia.ServerAreaService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class SaleLeadsController {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(SaleLeadsController.class);
|
||||
|
||||
private SaleLeadsService saleLeadsService;
|
||||
private ServerAreaService serverAreaService;
|
||||
private NewsResourceService newsResourceService;
|
||||
@@ -41,6 +52,15 @@ public class SaleLeadsController {
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 地数公众号咨询
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
public Object didataApplyAction(SaleLeadsModel model) {
|
||||
return model;
|
||||
}
|
||||
|
||||
public Object doAddAction(SaleLeadsModel model, HttpServletRequest req,
|
||||
HttpServletResponse res) throws UnsupportedEncodingException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||||
|
||||
@@ -129,8 +149,64 @@ public class SaleLeadsController {
|
||||
}
|
||||
|
||||
saleLeads = converValue(saleLeads);
|
||||
String body =
|
||||
"业务需求:" + saleLeads.getBusiness() + " " + saleLeads.getOtherBusiness() + "\n\n"
|
||||
+ "姓名:" + saleLeads.getUname() + "\n\n"
|
||||
+ "城市:" + saleLeads.getCity() + "\n\n"
|
||||
+ "工作职能:" + saleLeads.getWork() + " " + saleLeads.getOtherWork() + "\n\n"
|
||||
+ "手机:" + saleLeads.getMobile() + "\n\n"
|
||||
+ "邮箱:" + saleLeads.getEmail() + "\n\n"
|
||||
+ "公司名称:" + saleLeads.getCompany() + "\n\n"
|
||||
+ "行业性质:" + saleLeads.getIndustryNature() + " " + saleLeads.getOtherIndustryNature() + "\n\n";
|
||||
body = body.replaceAll("null", "").replaceAll("其他,请填写", "");
|
||||
if (StringUtils.isNotBlank(refUrl) && refUrl.contains("bd_vid")) {
|
||||
body += "线索来源:百度";
|
||||
} else if (StringUtils.isNotBlank(refUrl) && refUrl.contains("didata.wechat")) {
|
||||
body += "线索来源: 地数公众号";
|
||||
} else {
|
||||
body += "线索来源:房价网";
|
||||
}
|
||||
try {
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("msgtype", "text");
|
||||
JSONObject markdown = new JSONObject();
|
||||
markdown.put("title", "销售线索");
|
||||
markdown.put("content", body);
|
||||
requestBody.put("text", markdown);
|
||||
HttpRequest request = new HttpRequest();
|
||||
final String ding_url = "https://oapi.dingtalk.com/robot/send?access_token=894650a12af9497bed599df1d5f93b21d6da5bbae45f35f18c5825580ebbdf64";
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("Content-Type", "application/json; charset=utf-8");
|
||||
request.postWithBody(ding_url, requestBody, headers, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
saleLeadsService.save(saleLeads);
|
||||
|
||||
|
||||
// 对于百度广告过来的信息,进行回传
|
||||
try {
|
||||
if (StringUtils.isNotBlank(refUrl) && refUrl.contains("bd_vid")) {
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
final String baiduUrl = "https://ocpc.baidu.com/ocpcapi/api/uploadConvertData";
|
||||
Map<String, String> bdHeaders = new HashMap<String, String>();
|
||||
bdHeaders.put("Content-Type", "application/json; charset=utf-8");
|
||||
|
||||
JSONObject requestBody = new JSONObject();
|
||||
// https://fengchao.baidu.com/fc/toolscenter/optimize/track/user/27002539
|
||||
requestBody.put("token", "EZGISwlOClRMEZErT2ThZTEjpLAzs2wE@9POwrGLqpRtQeGhvvCug1N3OK1tq3skk");
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject contentJson = new JSONObject();
|
||||
contentJson.put("logidUrl", refUrl);
|
||||
contentJson.put("newType", "3");
|
||||
jsonArray.add(contentJson);
|
||||
requestBody.put("conversionTypes", jsonArray);
|
||||
String result = httpRequest.postWithBody(baiduUrl, requestBody, bdHeaders, "UTF-8");
|
||||
LOG.info("百度回传成功:" + result);
|
||||
}
|
||||
} catch (HttpRequestException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(saleLeads.getBusiness()) && saleLeads.getBusiness().contains("_")){
|
||||
String[] businessArray = saleLeads.getBusiness().split("_");
|
||||
for(String s : businessArray){
|
||||
@@ -155,7 +231,12 @@ public class SaleLeadsController {
|
||||
|
||||
if(StringUtils.isNotBlank(refUrl) && refUrl.contains("/resource/info")){
|
||||
url = refUrl.substring(refUrl.indexOf("/resource/info"), refUrl.length());
|
||||
}else{
|
||||
} else if (StringUtils.isNotBlank(refUrl) && refUrl.contains("didata.wechat")) { // 地数公众号跳转
|
||||
url = "/enquire/didataSuccess";
|
||||
if (StringUtils.isNotBlank(refUrl)) {
|
||||
url = url + "?backUrl=" + URLEncoder.encode(refUrl);
|
||||
}
|
||||
} else{
|
||||
url = "/enquire/success";
|
||||
if (StringUtils.isNotBlank(refUrl)) {
|
||||
url = url + "?backUrl=" + URLEncoder.encode(refUrl);
|
||||
@@ -224,6 +305,10 @@ public class SaleLeadsController {
|
||||
return model;
|
||||
}
|
||||
|
||||
public Object didataResultAction(SaleLeadsModel model) {
|
||||
return model;
|
||||
}
|
||||
|
||||
public SaleLeadsService getSaleLeadsService() {
|
||||
return saleLeadsService;
|
||||
}
|
||||
|
||||
+10
-1
@@ -1,6 +1,15 @@
|
||||
package com.fangjia.coresite.controllers;
|
||||
|
||||
import com.fangjia.core.util.HttpRequest;
|
||||
import com.fangjia.core.util.HttpRequestException;
|
||||
import com.fangjia.coresite.model.FangjiaModel;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 解决方案 控制器
|
||||
@@ -14,7 +23,7 @@ public class SolutionController {
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
public Object apiAction(FangjiaModel model) {
|
||||
public Object apiAction(FangjiaModel model, HttpServletRequest request) {
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -48,6 +48,11 @@ public class AntiSpiderFilter implements Filter {
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
HttpServletResponse response = (HttpServletResponse) resp;
|
||||
// 放开首页不做爬虫验证
|
||||
if (request.getRequestURL().toString().endsWith("fangjia.com") || request.getRequestURL().toString().endsWith("fangjia.com/")) {
|
||||
chain.doFilter(req, resp);
|
||||
return;
|
||||
}
|
||||
if(request.getRequestURI().endsWith("/validate") || request.getRequestURI().contains("randomCode") || request.getRequestURI().contains("checkCode")|| request.getRequestURI().contains("yeepayCallBack")){
|
||||
chain.doFilter(req, resp);
|
||||
return;
|
||||
|
||||
@@ -309,7 +309,17 @@
|
||||
<ladder>/</ladder>
|
||||
</ladders>
|
||||
</rule>
|
||||
|
||||
|
||||
<rule controller="saleLeads" action="didataApply" channel="enquire">
|
||||
<ladders>
|
||||
<ladder>/didataApply</ladder>
|
||||
</ladders>
|
||||
</rule>
|
||||
<rule controller="saleLeads" action="didataResult" channel="enquire">
|
||||
<ladders>
|
||||
<ladder>/didataSuccess</ladder>
|
||||
</ladders>
|
||||
</rule>
|
||||
|
||||
<rule controller="saleLeads" action="result" channel="enquire">
|
||||
<ladders>
|
||||
|
||||
@@ -153,47 +153,47 @@
|
||||
</div>
|
||||
<div class="main_title" id="partner" style="padding-top:100px;">他们都在和我们合作</div>
|
||||
<div class="main_content partner mobile01">
|
||||
<a class="partner11"></a>
|
||||
<a class="partner12"></a>
|
||||
<a class="partner13"></a>
|
||||
<#-- <a class="partner14"></a>-->
|
||||
<a class="partner15"></a>
|
||||
<a class="partner16" style="margin-right:0;"></a>
|
||||
<a class="partner21"></a>
|
||||
<a class="partner22"></a>
|
||||
<a class="partner23"></a>
|
||||
<a class="partner24"></a>
|
||||
<a class="partner25"></a>
|
||||
<a class="partner26" style="margin-right:0;"></a>
|
||||
<a class="partner31"></a>
|
||||
<a class="partner32"></a>
|
||||
<a class="partner33"></a>
|
||||
<a class="partner34"></a>
|
||||
<a class="partner35"></a>
|
||||
<a class="partner36" style="margin-right:0;"></a>
|
||||
<a class="partner41"></a>
|
||||
<a class="partner42"></a>
|
||||
<a class="partner43"></a>
|
||||
<a class="partner44"></a>
|
||||
<a class="partner45"></a>
|
||||
<a class="partner46" style="margin-right:0;"></a>
|
||||
<a class="partner51"></a>
|
||||
<a class="partner52"></a>
|
||||
<a class="partner53"></a>
|
||||
<a class="partner54"></a>
|
||||
<a class="partner55"></a>
|
||||
<a class="partner56" style="margin-right:0;"></a>
|
||||
<a class="partner61"></a>
|
||||
<a class="partner62"></a>
|
||||
<a class="partner63"></a>
|
||||
<a class="partner65"></a>
|
||||
<a class="partner66"></a>
|
||||
<a class="partner71" style="margin-right:0;"></a>
|
||||
<a class="partner72"></a>
|
||||
<a class="partner73"></a>
|
||||
<img src="${staticUrl}/images/fangjia/v5/company.png" style="width: 99%;"><br>
|
||||
<#-- <a class="partner11"></a>-->
|
||||
<#-- <a class="partner12"></a>-->
|
||||
<#-- <a class="partner13"></a>-->
|
||||
<#--<#– <a class="partner14"></a>–>-->
|
||||
<#-- <a class="partner15"></a>-->
|
||||
<#-- <a class="partner16"></a>-->
|
||||
<#-- <a class="partner21"></a>-->
|
||||
<#-- <a class="partner22"></a>-->
|
||||
<#-- <a class="partner23"></a>-->
|
||||
<#-- <a class="partner24"></a>-->
|
||||
<#-- <a class="partner25"></a>-->
|
||||
<#-- <a class="partner26"></a>-->
|
||||
<#-- <a class="partner31"></a>-->
|
||||
<#-- <a class="partner32"></a>-->
|
||||
<#-- <a class="partner33"></a>-->
|
||||
<#-- <a class="partner34"></a>-->
|
||||
<#-- <a class="partner35"></a>-->
|
||||
<#-- <a class="partner36"></a>-->
|
||||
<#-- <a class="partner41"></a>-->
|
||||
<#-- <a class="partner42"></a>-->
|
||||
<#-- <a class="partner43"></a>-->
|
||||
<#-- <a class="partner44"></a>-->
|
||||
<#-- <a class="partner45"></a>-->
|
||||
<#-- <a class="partner46"></a>-->
|
||||
<#-- <a class="partner51"></a>-->
|
||||
<#-- <a class="partner52"></a>-->
|
||||
<#-- <a class="partner53"></a>-->
|
||||
<#-- <a class="partner54"></a>-->
|
||||
<#-- <a class="partner55"></a>-->
|
||||
<#-- <a class="partner56"></a>-->
|
||||
<#-- <a class="partner61"></a>-->
|
||||
<#-- <a class="partner62"></a>-->
|
||||
<#-- <a class="partner63"></a>-->
|
||||
<#-- <a class="partner65"></a>-->
|
||||
<#-- <a class="partner66"></a>-->
|
||||
<#-- <a class="partner72"></a>-->
|
||||
<#-- <a class="partner73"></a>-->
|
||||
</div>
|
||||
<div class="main_content partner mobile02">
|
||||
<img src="${staticUrl}/images/fangjia/v5/partner_m.png">
|
||||
<img src="${staticUrl}/images/fangjia/v5/partner_m1.png">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -182,10 +182,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="overview_right adBoxApp03">
|
||||
<p><label>扫码下载<em>“有房”APP</em></label><br><small>更多次的评估,更好的体验</small></p>
|
||||
<img src="${staticUrl}/images/fangjia/v5/app_wx_gujia02.png">
|
||||
</div>
|
||||
<#-- <div class="overview_right adBoxApp03">-->
|
||||
<#-- <p><label>扫码下载<em>“有房”APP</em></label><br><small>更多次的评估,更好的体验</small></p>-->
|
||||
<#-- <img src="${staticUrl}/images/fangjia/v5/app_wx_gujia02.png">-->
|
||||
<#-- </div>-->
|
||||
</div>
|
||||
|
||||
<!-- PC端 -->
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li class="<#if controllerName=='resource'>current</#if>"><a href="${wwwUrl}/resource" >最新资讯</a></li>
|
||||
<li class="<#if controllerName=='resource'>current</#if>"><a href="${wwwUrl}/resource/" >最新资讯</a></li>
|
||||
<li class="subnav03 <#if controllerName == 'industry' || (controllerName == 'solution' && actionName != 'apiDoc')>current</#if>">
|
||||
<a>解决方案</a>
|
||||
<div class="dn" style="width:340px;">
|
||||
@@ -58,7 +58,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li class="<#if controllerName=='app'>current</#if>"><a href="${wwwUrl}/app/index">APP下载</a></li>
|
||||
<#-- <li class="<#if controllerName=='app'>current</#if>"><a href="${wwwUrl}/app/index">APP下载</a></li>-->
|
||||
|
||||
</ul>
|
||||
|
||||
@@ -148,9 +148,9 @@
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="${wwwUrl}/app/index" class="<#if controllerName=='app'>current</#if>">APP下载</a>
|
||||
</li>
|
||||
<#-- <li>-->
|
||||
<#-- <a href="${wwwUrl}/app/index" class="<#if controllerName=='app'>current</#if>">APP下载</a>-->
|
||||
<#-- </li>-->
|
||||
<!--<li>
|
||||
<a href="javascript:void(0)" onclick="applyLoan()" class="<#if controllerName=='loan'>current</#if>">我要贷款</a>
|
||||
</li>-->
|
||||
|
||||
@@ -207,29 +207,29 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list">
|
||||
<div class="listTop">
|
||||
<p><img src="${imgUrl}/images/fangjia/v5/diamond.png"><label>合作伙伴</label></p>
|
||||
</div>
|
||||
<div class="contentBox">
|
||||
<a class="content" href="${basePath}/terms/ydinfo" style="border-bottom:none;">
|
||||
<img src="${imgUrl}/images/fangjia/v5/youda.jpeg">
|
||||
<div>
|
||||
<p><em>房价网合作伙伴-上海友达土地房地产评估有限公司简介</em></p>
|
||||
<p><span>上海友达土地房地产评估有限公司成立于1995年,是我国最早成立的独立从事房地产估价、土地估价、房地产咨询业务的专业机构之一。</span></p>
|
||||
<p><small>上海房产门户 </small></p>
|
||||
</div>
|
||||
</a>
|
||||
<a class="content" href="${basePath}/terms/ydintr">
|
||||
<img src="${imgUrl}/images/fangjia/v5/youda.jpeg">
|
||||
<div>
|
||||
<p><em>上海友达土地房地产评估有限公司-企业内部培训</em></p>
|
||||
<p><span>2021年8月9日,上海友达土地房地产评估有限公司就房地产征收业务中遇到的诸多问题开展了企业内部培训。本次培训的宗旨是为了进一步提高员工技术水平和工作效率,强化团队合作意识,为公司的可持续性发展奠定良好基础。</span></p>
|
||||
<p><small>上海房产门户 </small></p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<#--<div class="list">-->
|
||||
<#-- <div class="listTop">-->
|
||||
<#-- <p><img src="${imgUrl}/images/fangjia/v5/diamond.png"><label>合作伙伴</label></p>-->
|
||||
<#-- </div>-->
|
||||
<#-- <div class="contentBox">-->
|
||||
<#-- <a class="content" href="${basePath}/terms/ydinfo" style="border-bottom:none;">-->
|
||||
<#-- <img src="${imgUrl}/images/fangjia/v5/youda.jpeg">-->
|
||||
<#-- <div>-->
|
||||
<#-- <p><em>房价网合作伙伴-上海友达土地房地产评估有限公司简介</em></p>-->
|
||||
<#-- <p><span>上海友达土地房地产评估有限公司成立于1995年,是我国最早成立的独立从事房地产估价、土地估价、房地产咨询业务的专业机构之一。</span></p>-->
|
||||
<#-- <p><small>上海房产门户 </small></p>-->
|
||||
<#-- </div>-->
|
||||
<#-- </a>-->
|
||||
<#-- <a class="content" href="${basePath}/terms/ydintr">-->
|
||||
<#-- <img src="${imgUrl}/images/fangjia/v5/youda.jpeg">-->
|
||||
<#-- <div>-->
|
||||
<#-- <p><em>上海友达土地房地产评估有限公司-企业内部培训</em></p>-->
|
||||
<#-- <p><span>2021年8月9日,上海友达土地房地产评估有限公司就房地产征收业务中遇到的诸多问题开展了企业内部培训。本次培训的宗旨是为了进一步提高员工技术水平和工作效率,强化团队合作意识,为公司的可持续性发展奠定良好基础。</span></p>-->
|
||||
<#-- <p><small>上海房产门户 </small></p>-->
|
||||
<#-- </div>-->
|
||||
<#-- </a>-->
|
||||
<#-- </div>-->
|
||||
<#--</div>-->
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -555,27 +555,53 @@ $(".user_btn").click(function(){
|
||||
scrollTo(0,0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 解决信息丢失问题
|
||||
var work = $(".duty:visible").find("select").val()
|
||||
if (work) {
|
||||
work = work.replaceAll("请选择您的工作职能", "")
|
||||
work = work.replaceAll("请选择", "")
|
||||
$("#work").val(work);
|
||||
}
|
||||
|
||||
var box = $(".demand p i.checked");
|
||||
if(box.length>0) {
|
||||
$(".demand").parent().find(".error span").text("")
|
||||
$(".demand").parent().find(".error").hide();
|
||||
var selectOtherFlag = false;
|
||||
var content = []
|
||||
box.each(function () {
|
||||
var s = $(this).parent().find("span").text();
|
||||
if (s.indexOf("请填写") > 0) {
|
||||
selectOtherFlag = true;
|
||||
} else {
|
||||
content.push(s);
|
||||
}
|
||||
})
|
||||
$("#business").val(content.join("_"));
|
||||
}
|
||||
|
||||
|
||||
/*if(!checkEmail()){
|
||||
scrollBy(0,-300);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!checkNature()){
|
||||
scrollBy(0,-200);
|
||||
return false;
|
||||
}
|
||||
if(!checkWork()){
|
||||
scrollBy(0,-100);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!checkNature()){
|
||||
scrollBy(0,-200);
|
||||
return false;
|
||||
}
|
||||
if(mid=="1018"||mid=="1016"){
|
||||
if(!checkOtherInfo()){
|
||||
scrollBy(0,-100);
|
||||
return false;
|
||||
}
|
||||
} */
|
||||
}
|
||||
*/
|
||||
|
||||
var cls = $(".agreement i").attr("class");
|
||||
if(cls.indexOf("checked")>-1){
|
||||
|
||||
@@ -0,0 +1,471 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
|
||||
<title>时空价值挖掘平台 -地数 didata.ai</title>
|
||||
<meta name="keywords" content="地址数据智能处理,时空价值计算,时空数据统计分析,自动化客户分类建模">
|
||||
<meta name="description" content="提交联系信息,估家科技将为您提供详尽的产品功能及服务介绍">
|
||||
<#include "../jsconstants.ftl" />
|
||||
|
||||
<link href="${staticUrl}/style/fangjia/v5/common.css?v=${version}" rel="stylesheet">
|
||||
<link href="${staticUrl}/style/fangjia/v5/main.css?v=${version}" rel="stylesheet">
|
||||
<link href="${staticUrl}/style/fangjia/v5/city.css?v=${version}" rel="stylesheet">
|
||||
<link href="${staticUrl}/style/fangjia/v5/user.css?v=${version}" rel="stylesheet">
|
||||
<script src="${staticUrl}/js/fangjia/v5/jquery-1.7.2.min.js?v=${version}"></script>
|
||||
|
||||
<style>
|
||||
.inputInfoBox01 .inputInfo label.label01a{margin-top:10px;}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
if((navigator.userAgent.match(/(iPad|iPhone|iPod|Android|ios)/i))){
|
||||
document.write("<link href='${staticUrl}/style/fangjia/v5/sm.css?v=${version}' rel='stylesheet'>");
|
||||
document.write("<link href='${staticUrl}/style/fangjia/v5/main-m.css?v=${version}' rel='stylesheet'>");
|
||||
document.write("<link href='${staticUrl}/style/fangjia/v5/city-m.css?v=${version}' rel='stylesheet'>");
|
||||
document.write("<link href='${staticUrl}/style/fangjia/v5/theme-orange.css?v=${version}' rel='stylesheet'>");
|
||||
document.write("<link href='${staticUrl}/style/fangjia/v5/mobile.css?v=${version}' rel='stylesheet'>");
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@media(max-device-width:768px){
|
||||
.main{padding-top:0;}
|
||||
.main_left{display:none;}
|
||||
.main_right{float:none;width:100%;}
|
||||
.user{width:100%;margin-top:6rem;}
|
||||
.user02{margin-left:0;}
|
||||
.title{text-align:center;position:static;}
|
||||
.title p{margin:1rem;}
|
||||
.content{padding:0 1rem;padding-top:2rem;}
|
||||
.content03 .inputInfoBox{overflow:visible;}
|
||||
.inputInfoBox01{float:none;}
|
||||
.inputInfoBox01 .inputInfo{width:100%;height:40px;margin-bottom:20px;clear:both;}
|
||||
.inputInfoBox01 .inputInfo label{float:left;line-height:40px;}
|
||||
.inputInfoBox01 .inputInfo label.label01{float:left;line-height:20px;width:66px;}
|
||||
.inputInfoBox01 .inputInfo label.label01a{clear:both;margin-bottom:17px;margin-top:17px;}
|
||||
.inputInfoBox01 .inputInfo label i{margin-left:5px;}
|
||||
.inputInfoBox01a{margin-right:0;}
|
||||
.inpu,.sel{height:40px;line-height:40px;}
|
||||
.inpu,.sel,.demand{width:89.5%;float:right;}
|
||||
.dialogBox .inpu{float:left;}
|
||||
.inpu01{width:70%;}
|
||||
.inpu02a{margin-top:17px;}
|
||||
#selectedCity{width:auto;}
|
||||
.error01{top:-17px;left:78px;}
|
||||
.user_btn,.line{width:100%;}
|
||||
.footerM{display:none;}
|
||||
}
|
||||
@media(max-device-width:414px){
|
||||
.inpu,.sel,.demand{width:79.5%;}
|
||||
.inpu01{width:45%;}
|
||||
}
|
||||
@media(max-device-width:375px){
|
||||
.inpu,.sel,.demand{width:77%;}
|
||||
.inpu01{width:40%;}
|
||||
}
|
||||
@media(max-device-width:320px){
|
||||
.inpu,.sel,.demand{width:73%;}
|
||||
.inpu01{width:30%;}
|
||||
.demand p span{width:80%;}
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<#escape x as x?html>
|
||||
<div class="header">
|
||||
<div style="background-color: black;">
|
||||
<div class="logo" style="padding-top:2px;">
|
||||
<img class="img-box__img4" src="http://www.didata.ai/upload/20220522/3324a05faa1a88d483572ec64ac48c82.png"></img>
|
||||
<#-- <a href="http://www.didata.ai/upload/20220522/3324a05faa1a88d483572ec64ac48c82.png"></a>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main">
|
||||
<div class="main_right">
|
||||
<div class="user user02">
|
||||
<div class="title">
|
||||
<p><label>预约产品Demo申请</label></p>
|
||||
<div style="text-align:left; margin-left: 2rem; font-size: 18px">我们很乐意为您提供帮助</div>
|
||||
<div style="text-align:left; margin-left: 3rem">√ 详尽的产品功能及服务介绍</div>
|
||||
<div style="text-align:left; margin-left: 3rem">√ 针对您所处的行业与业务场景,提供专业的服务方案<br/></div>
|
||||
<div style="text-align:left; margin-left: 3rem">√ 根据您的业务规模和需求,提供优惠的价格方案<br/></div>
|
||||
<div style="text-align:left; margin-left: 3rem">紧急咨询可拨打<strong>400-188-3787</strong><br/></div>
|
||||
<div style="text-align:left; margin-left: 3rem">预约申请请留下您的联系方式,我们会尽快与您联系<br/></div>
|
||||
</div>
|
||||
<div class="content content03">
|
||||
<form action="${wwwUrl}/saleLeads/doAdd" method="POST" id="_add_form">
|
||||
<input type="hidden" name="mid" value="${mid!}"/>
|
||||
<input type="hidden" name="downUrl" value="${downUrl!}"/>
|
||||
<input type="hidden" name="backUrl" value="${backUrl!}"/>
|
||||
<input type="hidden" name="resourceId" value="${resourceId!}"/>
|
||||
<div class="inputInfoBox">
|
||||
<div class="inputInfoBox01 inputInfoBox01a">
|
||||
<div class="inputInfo">
|
||||
<label>您的姓名<i>*</i></label>
|
||||
<input class="inpu inpu02" name="saleLeads.uname" id="uname" type="text" autocomplete="off" placeholder="请输入您的姓名">
|
||||
<div class="error error01 dn"><i></i><span></span></div>
|
||||
</div>
|
||||
<div class="inputInfo">
|
||||
<label>公司名称<i>*</i></label>
|
||||
<input class="inpu inpu02" name="saleLeads.company" id="company" type="text" autocomplete="off" placeholder="请输入您的公司名称">
|
||||
<div class="error error01 dn"><i></i><span></span></div>
|
||||
</div>
|
||||
<div class="inputInfo">
|
||||
<label><a class="ls2_01">手</a><a class="ls2_02">机</a><i>*</i></label>
|
||||
<input class="inpu inpu02" type="text" name="saleLeads.mobile" id="mobile" autocomplete="off" placeholder="请输入您的手机号码">
|
||||
<div class="error error01 dn"><i></i><span></span></div>
|
||||
</div>
|
||||
<div class="inputInfo">
|
||||
<label><a class="ls2_01">留</a><a class="ls2_02">言</a><i></i></label>
|
||||
<textarea class="inpu inpu02" scoll="auto" style="height:60px;padding-top:2px;" name="saleLeads.business" id="business">
|
||||
</textarea>
|
||||
<div class="error error01 dn"><i></i><span></span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<a class="user_btn" style="background: #6db5ea">提交</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<#include "../citys.ftl"/>
|
||||
|
||||
<style>
|
||||
@media(max-device-width:768px){
|
||||
.main{padding-top:0;}
|
||||
.main_left{display:none;}
|
||||
.main_right{float:none;width:100%;}
|
||||
.user{width:100%;margin-top:6rem;}
|
||||
.user02{margin-left:0;}
|
||||
.title{text-align:center;position:static;}
|
||||
.title p{margin:1rem;}
|
||||
.content{padding:0 1rem;padding-top:2rem;}
|
||||
.content03 .inputInfoBox{overflow:visible;}
|
||||
.inputInfoBox01{float:none;}
|
||||
.inputInfoBox01 .inputInfo{width:100%;height:40px;margin-bottom:20px;clear:both;}
|
||||
.inputInfoBox01 .inputInfo label{float:left;line-height:40px;}
|
||||
.inputInfoBox01 .inputInfo label.label01{float:left;line-height:20px;width:66px;}
|
||||
.inputInfoBox01 .inputInfo label.label01a{clear:both;margin-bottom:17px;margin-top:17px;}
|
||||
.inputInfoBox01 .inputInfo label i{margin-left:5px;}
|
||||
.inputInfoBox01a{margin-right:0;}
|
||||
.inpu,.sel{height:40px;line-height:40px;}
|
||||
.inpu,.sel,.demand{width:89.5%;float:right;}
|
||||
.dialogBox .inpu{float:left;}
|
||||
.inpu01{width:70%;}
|
||||
.inpu02a{margin-top:17px;}
|
||||
#selectedCity{width:auto;}
|
||||
.error01{top:-17px;left:78px;}
|
||||
.user_btn,.line{width:100%;}
|
||||
.footerM{display:none;}
|
||||
}
|
||||
@media(max-device-width:414px){
|
||||
.inpu,.sel,.demand{width:79.5%;}
|
||||
.inpu01{width:45%;}
|
||||
}
|
||||
@media(max-device-width:375px){
|
||||
.inpu,.sel,.demand{width:77%;}
|
||||
.inpu01{width:40%;}
|
||||
}
|
||||
@media(max-device-width:320px){
|
||||
.inpu,.sel,.demand{width:73%;}
|
||||
.inpu01{width:30%;}
|
||||
.demand p span{width:80%;}
|
||||
}
|
||||
.img-box__img4 {
|
||||
background-color: black;
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
object-fit: contain;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
var retFlag = 1;
|
||||
</script>
|
||||
<script type="text/javascript" src="${staticUrl}/js/fangjiaNew.js?v=${version}"></script>
|
||||
<script src="${staticUrl}/js/fangjia/v5/main.js?v=${version}"></script>
|
||||
<script src="${staticUrl}/js/fangjia/v5/city.js?v=${version}"></script>
|
||||
|
||||
<script type="text/javascript" src="//g.alicdn.com/sj/lib/zepto/zepto.js" charset="utf-8"></script>
|
||||
|
||||
<script>
|
||||
|
||||
/* 关闭路由,以实现不同页面之间的相互跳转(仅开发环境需要) */
|
||||
Zepto = $
|
||||
$.config = {router: false}
|
||||
|
||||
</script>
|
||||
|
||||
<script src="${staticUrl}/js/fangjia/v5/light7.js?v=${version}"></script>
|
||||
<script src="${staticUrl}/js/fangjia/v5/cn.js?v=${version}"></script>
|
||||
|
||||
<script>
|
||||
var controllerName = '${controllerName}';
|
||||
var mid = '${mid!}'
|
||||
$(function(){
|
||||
if((navigator.userAgent.match(/(iPad|iPhone|iPod|Android|ios)/i))){
|
||||
$(".popup-about01 .tabs a").removeAttr("href");//去除城市页面跳转
|
||||
}
|
||||
})
|
||||
$(".user_btn").click(function(){
|
||||
if(!checkContactName()){
|
||||
scrollTo(0,0);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!checkCompany()){
|
||||
scrollTo(0,0);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!checkMobile2()){
|
||||
scrollTo(0,0);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*if(!checkEmail()){
|
||||
scrollBy(0,-300);
|
||||
return false;
|
||||
}
|
||||
if(!checkWork()){
|
||||
scrollBy(0,-100);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!checkNature()){
|
||||
scrollBy(0,-200);
|
||||
return false;
|
||||
}
|
||||
if(mid=="1018"||mid=="1016"){
|
||||
if(!checkOtherInfo()){
|
||||
scrollBy(0,-100);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// var cls = $(".agreement i").attr("class");
|
||||
// if(cls.indexOf("checked")>-1){
|
||||
// $("#emailStatus").val(true);
|
||||
// }else{
|
||||
// $("#emailStatus").val(false);
|
||||
// }
|
||||
$("#_add_form").submit();
|
||||
});
|
||||
|
||||
function checkOtherNature(){
|
||||
var otherNature = $("#otherIndustryNature").val();
|
||||
if($.trim(otherNature) == ""){
|
||||
$("#otherIndustryNature").parent().find(".error:eq(0)").show();
|
||||
$("#otherIndustryNature").parent().find(".error:eq(0) span").text("其他行业性质不能为空");
|
||||
return false;
|
||||
}else{
|
||||
|
||||
$("#otherIndustryNature").parent().find(".error:eq(0)").hide();
|
||||
if(!checkIndustryNature()){
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkIndustryNature(){
|
||||
var otherWork = $("#otherWork2").val();
|
||||
if($.trim(otherWork) == ""){
|
||||
$("#otherIndustryNature").parent().find(".error:eq(1) span").text("其他工作职能不能为空");
|
||||
$("#otherIndustryNature").parent().find(".error:eq(1)").removeClass("dn")
|
||||
return false;
|
||||
}else{
|
||||
$("#otherIndustryNature").parent().find(".error:eq(1)").hide();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkWork(){
|
||||
var val = $("#nature").val();
|
||||
if(val!=""){
|
||||
if(val.indexOf("请填写")>0){
|
||||
return checkOtherNature();
|
||||
}else{
|
||||
var work = $(".duty:visible").find("select").val()
|
||||
if($.trim(work) == "请选择您的工作职能"){
|
||||
$(".duty:visible").find(".error span").text("工作职能不能为空");
|
||||
$(".duty:visible").find(".error").show();
|
||||
return false;
|
||||
}else if(work.indexOf("请填写")>-1){
|
||||
return checkOtherWork();
|
||||
}else{
|
||||
$("#work").val(work);
|
||||
$(".duty:visible").find(".error").text("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function checkOtherWork(){
|
||||
var otherWork = $("#otherWork").val();
|
||||
if($.trim(otherWork) == ""){
|
||||
$("#otherWork").parent().find(".error span").text("其他工作职能不能为空");
|
||||
$("#otherWork").parent().find(".error").show();
|
||||
return false;
|
||||
}else{
|
||||
$("#otherWork").parent().find(".error").text("");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkNature(){
|
||||
var val = $("#nature").val();
|
||||
if ($.trim(val) == "") {
|
||||
$("#nature").parent().find(".error span").text("行业性质不能为空");
|
||||
$("#nature").parent().find(".error").show();
|
||||
return false;
|
||||
}else{
|
||||
$("#nature").parent().find(".error").text("");
|
||||
|
||||
if(val.indexOf("请填写")>-1){
|
||||
return checkOtherNature();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkMobile2(){
|
||||
var val = $("#mobile").val();
|
||||
if ($.trim(val) == "") {
|
||||
$("#mobile").parent().find(".error span").text("手机号码不能为空");
|
||||
$("#mobile").parent().find(".error").show();
|
||||
return false;
|
||||
}else if(!(/^1\d{10}$/.test(val))){
|
||||
$("#mobile").parent().find(".error span").text("手机号码格式错误");
|
||||
$("#mobile").parent().find(".error").show();
|
||||
return false;
|
||||
} else{
|
||||
$("#mobile").parent().find(".error").text("");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkContactName(){
|
||||
var val = $("#uname").val();
|
||||
if ($.trim(val) == "") {
|
||||
$("#uname").parent().find(".error span").text("您的姓名不能为空");
|
||||
$("#uname").parent().find(".error").show();
|
||||
return false;
|
||||
}else{
|
||||
$("#uname").parent().find(".error").hide();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkEmail(){
|
||||
var val = $("#email").val();
|
||||
if($.trim(val) == ""){
|
||||
$("#email").parent().find(".error span").text("电子邮箱不能为空");
|
||||
$("#email").parent().find(".error").show();
|
||||
return false;
|
||||
}else if (!/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/.test(val)) {
|
||||
$("#email").parent().find(".error span").text("电子邮箱格式错误");
|
||||
$("#email").parent().find(".error").show();
|
||||
return false;
|
||||
}else{
|
||||
$("#email").parent().find(".error").text("");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkCompany(){
|
||||
var val = $("#company").val();
|
||||
if ($.trim(val) === "") {
|
||||
$("#company").parent().find(".error span").text("公司名称不能为空");
|
||||
$("#company").parent().find(".error").show();
|
||||
return false;
|
||||
}else{
|
||||
$("#company").parent().find(".error").text("");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkOtherInfo(){
|
||||
var box = $(".demand p i.checked");
|
||||
if(box.length>0){
|
||||
$(".demand").parent().find(".error span").text("")
|
||||
$(".demand").parent().find(".error").hide();
|
||||
var selectOtherFlag = false;
|
||||
var content = []
|
||||
box.each(function(){
|
||||
var s = $(this).parent().find("span").text();
|
||||
if(s.indexOf("请填写")>0){
|
||||
selectOtherFlag = true;
|
||||
}
|
||||
content.push(s);
|
||||
})
|
||||
$("#business").val(content.join("_"));
|
||||
|
||||
if(selectOtherFlag){
|
||||
var otherBusiness = $("#otherBusiness").val();
|
||||
if ($.trim(otherBusiness) == "") {
|
||||
$("#otherBusiness").parent().find(".error span").text("其他业务需求不能为空");
|
||||
$("#otherBusiness").parent().find(".error").show();
|
||||
return false;
|
||||
}else{
|
||||
$("#otherBusiness").parent().find(".error").text("");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$(".demand").parent().find(".error span").text("请至少勾选1项业务需求")
|
||||
$(".demand").parent().find(".error").show();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/* 定位城市 */
|
||||
$("body").on("click", ".letter a", function () {
|
||||
var s = $(this).html();
|
||||
$(".content").scrollTop(0);
|
||||
$(".content").scrollTop($("#" + s + "1").offset().top - 66);
|
||||
});
|
||||
$(".content-block01").scroll(function () {
|
||||
$(".content-block01 .letter").css("position","absolute");
|
||||
$(".content-block01 .letter").css("top", 116 - $("#cityContainer").position().top);
|
||||
});
|
||||
|
||||
/* 获取城市 移动端 */
|
||||
$(".popup-about01 .cityGPS").on("click", function () {
|
||||
$("#selectedCity,#city").val($(this).find("p").text());
|
||||
//$(".adBoxApp01").show();
|
||||
});
|
||||
$("body").delegate(".popup-about01 a","click", function(){
|
||||
$("#selectedCity,#city").val($(this).text());
|
||||
//$(".adBoxApp01").show();
|
||||
});
|
||||
$(".popup-about01-mobile .cityGPS").on("click", function () {
|
||||
$("#selectedCity,#city").val($(this).find("p").text());
|
||||
//$(".adBoxApp01").show();
|
||||
});
|
||||
$("body").delegate(".popup-about01-mobile a","click", function(){
|
||||
$("#selectedCity,#city").val($(this).text());
|
||||
//$(".adBoxApp01").show();
|
||||
});
|
||||
$(".popup-about01 .icon-left").on("click", function () {
|
||||
//$(".adBoxApp01").show();
|
||||
});
|
||||
|
||||
</script>
|
||||
</#escape>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,86 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
|
||||
<title>咨询信息提交成功 - 地数 didata.ai</title>
|
||||
<meta name="keywords" content="">
|
||||
<meta name="description" content="">
|
||||
|
||||
<link href="${staticUrl}/style/fangjia/v5/common.css?v=${version}" rel="stylesheet">
|
||||
<link href="${staticUrl}/style/fangjia/v5/main.css?v=${version}" rel="stylesheet">
|
||||
<link href="${staticUrl}/style/fangjia/v5/user.css?v=${version}" rel="stylesheet">
|
||||
<script src="${staticUrl}/js/fangjia/v5/jquery-1.7.2.min.js?v=${version}"></script>
|
||||
|
||||
<script>
|
||||
if((navigator.userAgent.match(/(iPad|iPhone|iPod|Android|ios)/i))){
|
||||
document.write("<link href='${staticUrl}/style/fangjia/v5/mobile.css?v=${version}' rel='stylesheet'>");
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@media(max-device-width:768px){
|
||||
.main{padding-top:0;}
|
||||
.main_right{float:none;width:100%;}
|
||||
.user{width:90%;margin-top:15rem;}
|
||||
.footerM{display:none;}
|
||||
}
|
||||
.img-box__img4 {
|
||||
background-color: black;
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
object-fit: contain;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="header">
|
||||
<div style="background-color: black;">
|
||||
<div class="logo" style="padding-top:2px;">
|
||||
<img class="img-box__img4" src="http://www.didata.ai/upload/20220522/3324a05faa1a88d483572ec64ac48c82.png"></img>
|
||||
<#-- <a href="http://www.didata.ai/upload/20220522/3324a05faa1a88d483572ec64ac48c82.png"></a>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main">
|
||||
<div class="main_right">
|
||||
<div class="user user03">
|
||||
<div class="content">
|
||||
<p class="success"><i></i>您的信息已提交成功</p>
|
||||
<p class="link" style="color:#333;">我们的专业数据顾问将会尽快与您取得联系,感谢您的咨询!</p>
|
||||
<p class="note">若您有任何问题,欢迎拨打客服电话:<a>400-188-3787</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@media(max-device-width:768px){
|
||||
.main{padding-top:0;}
|
||||
.main_right{float:none;width:100%;}
|
||||
.user{width:90%;margin-top:15rem;}
|
||||
.footerM{display:none;}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="${staticUrl}/js/fangjia/v5/main.js?v=${version}"></script>
|
||||
|
||||
<script>
|
||||
|
||||
var url = '${backUrl!}';
|
||||
var downUrl = '${downUrl!}';
|
||||
|
||||
if(!downUrl){
|
||||
setTimeout("location.href='"+url+"'",3000);
|
||||
}else{
|
||||
setTimeout("location.href='"+url+"&downUrl="+downUrl+"'",3000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,242 @@
|
||||
package com.fangjia.dal;
|
||||
import org.sothis.core.util.Pager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SeawaterQuery {
|
||||
|
||||
private String id;
|
||||
private String cat;
|
||||
private String region;
|
||||
private String districtName;
|
||||
private String cityDisplay;
|
||||
private Integer room;
|
||||
private String direction;
|
||||
private String fitment;
|
||||
private String sort;
|
||||
private Boolean order;
|
||||
private Integer StartDate;
|
||||
private Integer endDate;
|
||||
private String estateType;
|
||||
private Double startArea;
|
||||
private Double endArea;
|
||||
private Integer startPrice;
|
||||
private Integer endPrice;
|
||||
private Integer status;
|
||||
private String rootName;
|
||||
private String sortField;
|
||||
private List<String> regionAlias;
|
||||
private List<String> districtAlias;
|
||||
private String[] keys;
|
||||
private String table;
|
||||
private Pager pager;
|
||||
private String editEstateType;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCat() {
|
||||
return cat;
|
||||
}
|
||||
|
||||
public void setCat(String cat) {
|
||||
this.cat = cat;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public String getDistrictName() {
|
||||
return districtName;
|
||||
}
|
||||
|
||||
public void setDistrictName(String districtName) {
|
||||
this.districtName = districtName;
|
||||
}
|
||||
|
||||
public Integer getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public void setRoom(Integer room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public String getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(String direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public String getFitment() {
|
||||
return fitment;
|
||||
}
|
||||
|
||||
public void setFitment(String fitment) {
|
||||
this.fitment = fitment;
|
||||
}
|
||||
|
||||
public Boolean getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(Boolean order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public Integer getStartDate() {
|
||||
return StartDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Integer startDate) {
|
||||
StartDate = startDate;
|
||||
}
|
||||
|
||||
public Integer getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Integer endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getEstateType() {
|
||||
return estateType;
|
||||
}
|
||||
|
||||
public void setEstateType(String estateType) {
|
||||
this.estateType = estateType;
|
||||
}
|
||||
|
||||
public Integer getStartPrice() {
|
||||
return startPrice;
|
||||
}
|
||||
|
||||
public void setStartPrice(Integer startPrice) {
|
||||
this.startPrice = startPrice;
|
||||
}
|
||||
|
||||
public Integer getEndPrice() {
|
||||
return endPrice;
|
||||
}
|
||||
|
||||
public void setEndPrice(Integer endPrice) {
|
||||
this.endPrice = endPrice;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getSortField() {
|
||||
return sortField;
|
||||
}
|
||||
|
||||
public void setSortField(String sortField) {
|
||||
this.sortField = sortField;
|
||||
}
|
||||
|
||||
public List<String> getRegionAlias() {
|
||||
return regionAlias;
|
||||
}
|
||||
|
||||
public void setRegionAlias(List<String> regionAlias) {
|
||||
this.regionAlias = regionAlias;
|
||||
}
|
||||
|
||||
public List<String> getDistrictAlias() {
|
||||
return districtAlias;
|
||||
}
|
||||
|
||||
public void setDistrictAlias(List<String> districtAlias) {
|
||||
this.districtAlias = districtAlias;
|
||||
}
|
||||
|
||||
public String[] getKeys() {
|
||||
return keys;
|
||||
}
|
||||
|
||||
public void setKeys(String[] keys) {
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
public String getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
public void setTable(String table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
public String getRootName() {
|
||||
return rootName;
|
||||
}
|
||||
|
||||
public void setRootName(String rootName) {
|
||||
this.rootName = rootName;
|
||||
}
|
||||
|
||||
public Double getStartArea() {
|
||||
return startArea;
|
||||
}
|
||||
|
||||
public void setStartArea(Double startArea) {
|
||||
this.startArea = startArea;
|
||||
}
|
||||
|
||||
public Double getEndArea() {
|
||||
return endArea;
|
||||
}
|
||||
|
||||
public void setEndArea(Double endArea) {
|
||||
this.endArea = endArea;
|
||||
}
|
||||
|
||||
public Pager getPager() {
|
||||
return pager;
|
||||
}
|
||||
|
||||
public void setPager(Pager pager) {
|
||||
this.pager = pager;
|
||||
}
|
||||
|
||||
public String getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(String sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public String getCityDisplay() {
|
||||
return cityDisplay;
|
||||
}
|
||||
|
||||
public void setCityDisplay(String cityDisplay) {
|
||||
this.cityDisplay = cityDisplay;
|
||||
}
|
||||
|
||||
public String getEditEstateType() {
|
||||
return editEstateType;
|
||||
}
|
||||
|
||||
public void setEditEstateType(String editEstateType) {
|
||||
this.editEstateType = editEstateType;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -22,7 +22,8 @@ public enum SalesLeadEnum {
|
||||
DOWN_APPLY("1016", "下载申请"),
|
||||
FDANG_DIAO_BAO_GAO("1017", "房产专业调查评估报告"),
|
||||
BUSINESS_ASK("1018", "业务咨询"),
|
||||
HOUSE_EVAL("1019", "·¿²úÆÀ¹À");
|
||||
HOUSE_EVAL("1019", "房产评估"),
|
||||
DIDATA("1020", "地数平台");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ public class PaiMai implements MongoEntity {
|
||||
private String houseNum;
|
||||
private String unitNum;
|
||||
private String roomNum;
|
||||
private String estateType;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@@ -492,6 +493,7 @@ public class PaiMai implements MongoEntity {
|
||||
this.matchEstateType = matchEstateType;
|
||||
}
|
||||
|
||||
@Column(name = "houseNum")
|
||||
public String getHouseNum() {
|
||||
return houseNum;
|
||||
}
|
||||
@@ -500,6 +502,7 @@ public class PaiMai implements MongoEntity {
|
||||
this.houseNum = houseNum;
|
||||
}
|
||||
|
||||
@Column(name = "unitNum")
|
||||
public String getUnitNum() {
|
||||
return unitNum;
|
||||
}
|
||||
@@ -508,6 +511,7 @@ public class PaiMai implements MongoEntity {
|
||||
this.unitNum = unitNum;
|
||||
}
|
||||
|
||||
@Column(name = "roomNum")
|
||||
public String getRoomNum() {
|
||||
return roomNum;
|
||||
}
|
||||
@@ -515,4 +519,13 @@ public class PaiMai implements MongoEntity {
|
||||
public void setRoomNum(String roomNum) {
|
||||
this.roomNum = roomNum;
|
||||
}
|
||||
|
||||
@Column(name = "estateType")
|
||||
public String getEstateType() {
|
||||
return estateType;
|
||||
}
|
||||
|
||||
public void setEstateType(String estateType) {
|
||||
this.estateType = estateType;
|
||||
}
|
||||
}
|
||||
|
||||
+107
-41
@@ -95,10 +95,10 @@ public class AverageStatistics implements MongoEntity {
|
||||
private Double tuboshiEsfDiff;
|
||||
|
||||
/**中原地产二手房均价*/
|
||||
private Integer centanetNewPrice;
|
||||
private Double centanetNewDiff;
|
||||
private Integer centanetEsfPrice;
|
||||
private Double centanetEsfDiff;
|
||||
private Integer zhongyuanNewPrice;
|
||||
private Double zhongyuanNewDiff;
|
||||
private Integer zhongyuanEsfPrice;
|
||||
private Double zhongyuanEsfDiff;
|
||||
|
||||
|
||||
|
||||
@@ -155,9 +155,18 @@ public class AverageStatistics implements MongoEntity {
|
||||
private Integer zhugezhaofangNewPrice;
|
||||
private Double zhugezhaofangNewDiff;
|
||||
|
||||
|
||||
/**¼ªÎÝ*/
|
||||
private Integer jiwuEsfPrice;
|
||||
private Double jiwuEsfDiff;
|
||||
private Integer jiwuNewPrice;
|
||||
private Double jiwuNewDiff;
|
||||
|
||||
/**365*/
|
||||
private Integer tsfhouseEsfPrice;
|
||||
private Double tsfhouseEsfDiff;
|
||||
private Integer tsfhouseNewPrice;
|
||||
private Double tsfhouseNewDiff;
|
||||
|
||||
|
||||
private String level;//价格评级
|
||||
private Integer lastAvgPrice;//最终价
|
||||
private String maxDeviate;//偏离度最大的网站,房价网-云估价-房估估
|
||||
@@ -578,22 +587,22 @@ public class AverageStatistics implements MongoEntity {
|
||||
this.fangguguNewPrice = fangguguNewPrice;
|
||||
}
|
||||
|
||||
@Column(name = "centanet_new_price")
|
||||
public Integer getCentanetNewPrice() {
|
||||
return centanetNewPrice;
|
||||
@Column(name = "zhongyuan_new_price")
|
||||
public Integer getZhongyuanNewPrice() {
|
||||
return zhongyuanNewPrice;
|
||||
}
|
||||
|
||||
public void setCentanetNewPrice(Integer centanetNewPrice) {
|
||||
this.centanetNewPrice = centanetNewPrice;
|
||||
public void setZhongyuanNewPrice(Integer zhongyuanNewPrice) {
|
||||
this.zhongyuanNewPrice = zhongyuanNewPrice;
|
||||
}
|
||||
|
||||
@Column(name = "centanet_esf_price")
|
||||
public Integer getCentanetEsfPrice() {
|
||||
return centanetEsfPrice;
|
||||
@Column(name = "zhongyuan_esf_price")
|
||||
public Integer getZhongyuanEsfPrice() {
|
||||
return zhongyuanEsfPrice;
|
||||
}
|
||||
|
||||
public void setCentanetEsfPrice(Integer centanetEsfPrice) {
|
||||
this.centanetEsfPrice = centanetEsfPrice;
|
||||
public void setZhongyuanEsfPrice(Integer zhongyuanEsfPrice) {
|
||||
this.zhongyuanEsfPrice = zhongyuanEsfPrice;
|
||||
}
|
||||
|
||||
@Column(name = "lianjia_esf_price")
|
||||
@@ -659,22 +668,22 @@ public class AverageStatistics implements MongoEntity {
|
||||
this.tuboshiEsfDiff = tuboshiEsfDiff;
|
||||
}
|
||||
|
||||
@Column(name = "centanet_new_diff")
|
||||
public Double getCentanetNewDiff() {
|
||||
return centanetNewDiff;
|
||||
@Column(name = "zhongyuan_new_diff")
|
||||
public Double getZhongyuanNewDiff() {
|
||||
return zhongyuanNewDiff;
|
||||
}
|
||||
|
||||
public void setCentanetNewDiff(Double centanetNewDiff) {
|
||||
this.centanetNewDiff = centanetNewDiff;
|
||||
public void setZhongyuanNewDiff(Double zhongyuanNewDiff) {
|
||||
this.zhongyuanNewDiff = zhongyuanNewDiff;
|
||||
}
|
||||
|
||||
@Column(name = "centanet_esf_diff")
|
||||
public Double getCentanetEsfDiff() {
|
||||
return centanetEsfDiff;
|
||||
@Column(name = "zhongyuan_esf_diff")
|
||||
public Double getZhongyuanEsfDiff() {
|
||||
return zhongyuanEsfDiff;
|
||||
}
|
||||
|
||||
public void setCentanetEsfDiff(Double centanetEsfDiff) {
|
||||
this.centanetEsfDiff = centanetEsfDiff;
|
||||
public void setZhongyuanEsfDiff(Double zhongyuanEsfDiff) {
|
||||
this.zhongyuanEsfDiff = zhongyuanEsfDiff;
|
||||
}
|
||||
|
||||
@Column(name = "master_district_name")
|
||||
@@ -1074,19 +1083,76 @@ public class AverageStatistics implements MongoEntity {
|
||||
public void setFangtanEsfDiff(Double fangtanEsfDiff) {
|
||||
this.fangtanEsfDiff = fangtanEsfDiff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Column(name = "jiwu_esf_price")
|
||||
public Integer getJiwuEsfPrice() {
|
||||
return jiwuEsfPrice;
|
||||
}
|
||||
|
||||
public void setJiwuEsfPrice(Integer jiwuEsfPrice) {
|
||||
this.jiwuEsfPrice = jiwuEsfPrice;
|
||||
}
|
||||
|
||||
@Column(name = "jiwu_esf_diff")
|
||||
public Double getJiwuEsfDiff() {
|
||||
return jiwuEsfDiff;
|
||||
}
|
||||
|
||||
public void setJiwuEsfDiff(Double jiwuEsfDiff) {
|
||||
this.jiwuEsfDiff = jiwuEsfDiff;
|
||||
}
|
||||
|
||||
@Column(name = "jiwu_new_price")
|
||||
public Integer getJiwuNewPrice() {
|
||||
return jiwuNewPrice;
|
||||
}
|
||||
|
||||
public void setJiwuNewPrice(Integer jiwuNewPrice) {
|
||||
this.jiwuNewPrice = jiwuNewPrice;
|
||||
}
|
||||
|
||||
@Column(name = "jiwu_new_diff")
|
||||
public Double getJiwuNewDiff() {
|
||||
return jiwuNewDiff;
|
||||
}
|
||||
|
||||
public void setJiwuNewDiff(Double jiwuNewDiff) {
|
||||
this.jiwuNewDiff = jiwuNewDiff;
|
||||
}
|
||||
|
||||
@Column(name = "365house_esf_price")
|
||||
public Integer getTsfhouseEsfPrice() {
|
||||
return tsfhouseEsfPrice;
|
||||
}
|
||||
|
||||
public void setTsfhouseEsfPrice(Integer tsfhouseEsfPrice) {
|
||||
this.tsfhouseEsfPrice = tsfhouseEsfPrice;
|
||||
}
|
||||
|
||||
@Column(name = "365house_esf_diff")
|
||||
public Double getTsfhouseEsfDiff() {
|
||||
return tsfhouseEsfDiff;
|
||||
}
|
||||
|
||||
public void setTsfhouseEsfDiff(Double tsfhouseEsfDiff) {
|
||||
this.tsfhouseEsfDiff = tsfhouseEsfDiff;
|
||||
}
|
||||
|
||||
@Column(name = "365house_new_price")
|
||||
public Integer getTsfhouseNewPrice() {
|
||||
return tsfhouseNewPrice;
|
||||
}
|
||||
|
||||
public void setTsfhouseNewPrice(Integer tsfhouseNewPrice) {
|
||||
this.tsfhouseNewPrice = tsfhouseNewPrice;
|
||||
}
|
||||
|
||||
@Column(name = "365house_new_diff")
|
||||
public Double getTsfhouseNewDiff() {
|
||||
return tsfhouseNewDiff;
|
||||
}
|
||||
|
||||
public void setTsfhouseNewDiff(Double tsfhouseNewDiff) {
|
||||
this.tsfhouseNewDiff = tsfhouseNewDiff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,18 +22,16 @@ public class SqmetreRent implements MongoEntity {
|
||||
private String city;
|
||||
private String region;
|
||||
private String districtName;
|
||||
private Double avgPrice;
|
||||
private int markup;
|
||||
private Integer avgPrice;
|
||||
private Integer calcAvgPrice;
|
||||
private Double markup;
|
||||
private Date weekend;
|
||||
private String cat;
|
||||
private Date creationDate;
|
||||
private Date modificationDate;
|
||||
private String sampleEnum;
|
||||
private double credit;
|
||||
private String cluster;
|
||||
|
||||
private Double oldValue;
|
||||
private String oldSampleEnum;
|
||||
private Double credit;
|
||||
private String valueType;
|
||||
private Integer priceToRent;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@@ -76,22 +74,47 @@ public class SqmetreRent implements MongoEntity {
|
||||
}
|
||||
|
||||
@Column(name = "avg_price")
|
||||
public Double getAvgPrice() {
|
||||
public Integer getAvgPrice() {
|
||||
return avgPrice;
|
||||
}
|
||||
|
||||
public void setAvgPrice(Double avgPrice) {
|
||||
public void setAvgPrice(Integer avgPrice) {
|
||||
this.avgPrice = avgPrice;
|
||||
}
|
||||
|
||||
|
||||
@Column(name = "calc_avg_price")
|
||||
public Integer getCalcAvgPrice() {
|
||||
return calcAvgPrice;
|
||||
}
|
||||
|
||||
public void setCalcAvgPrice(Integer calcAvgPrice) {
|
||||
this.calcAvgPrice = calcAvgPrice;
|
||||
}
|
||||
|
||||
@Column(name = "value_type")
|
||||
public String getValueType() {
|
||||
return valueType;
|
||||
}
|
||||
|
||||
public void setValueType(String valueType) {
|
||||
this.valueType = valueType;
|
||||
}
|
||||
|
||||
@Column(name = "price_to_rent")
|
||||
public Integer getPriceToRent() {
|
||||
return priceToRent;
|
||||
}
|
||||
|
||||
public void setPriceToRent(Integer priceToRent) {
|
||||
this.priceToRent = priceToRent;
|
||||
}
|
||||
|
||||
@Column(name = "markup")
|
||||
public int getMarkup() {
|
||||
public Double getMarkup() {
|
||||
return markup;
|
||||
}
|
||||
|
||||
public void setMarkup(int markup) {
|
||||
public void setMarkup(Double markup) {
|
||||
this.markup = markup;
|
||||
}
|
||||
|
||||
@@ -123,52 +146,15 @@ public class SqmetreRent implements MongoEntity {
|
||||
}
|
||||
|
||||
|
||||
@Column(name = "sample_enum")
|
||||
public String getSampleEnum() {
|
||||
return sampleEnum;
|
||||
}
|
||||
|
||||
public void setSampleEnum(String sampleEnum) {
|
||||
this.sampleEnum = sampleEnum;
|
||||
}
|
||||
|
||||
|
||||
@Column(name = "credit")
|
||||
public double getCredit() {
|
||||
public Double getCredit() {
|
||||
return credit;
|
||||
}
|
||||
|
||||
public void setCredit(double credit) {
|
||||
public void setCredit(Double credit) {
|
||||
this.credit = credit;
|
||||
}
|
||||
|
||||
@Column(name = "cluster")
|
||||
public String getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
public void setCluster(String cluster) {
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
@Column(name = "old_value")
|
||||
public Double getOldValue() {
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
public void setOldValue(Double oldValue) {
|
||||
this.oldValue = oldValue;
|
||||
}
|
||||
|
||||
@Column(name = "old_sample_enum")
|
||||
public String getOldSampleEnum() {
|
||||
return oldSampleEnum;
|
||||
}
|
||||
|
||||
public void setOldSampleEnum(String oldSampleEnum) {
|
||||
this.oldSampleEnum = oldSampleEnum;
|
||||
}
|
||||
|
||||
@Column(name = "cat")
|
||||
public String getCat() {
|
||||
return cat;
|
||||
|
||||
@@ -83,6 +83,8 @@ public class Loudong implements MongoEntity {
|
||||
private Date modifyDate;
|
||||
/**户数*/
|
||||
private Integer households;
|
||||
/**一梯几户的户*/
|
||||
private Integer roomCount;
|
||||
/** 总建筑面积 */
|
||||
private Double totalAreas;
|
||||
/** 开盘时间 */
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.fangjia.dal.mongo.open.dao;
|
||||
|
||||
import com.fangjia.dal.MongoDao;
|
||||
import com.fangjia.dal.mongo.open.model.EvaluateRatio;
|
||||
|
||||
/**
|
||||
* @author shenjian
|
||||
* @since 2022/7/27
|
||||
*/
|
||||
public interface EvaluateRatioDao extends MongoDao<EvaluateRatio> {
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.fangjia.dal.mongo.open.dao.impl;
|
||||
|
||||
import com.fangjia.dal.MongoDaoImpl;
|
||||
import com.fangjia.dal.mongo.open.dao.EvaluateRatioDao;
|
||||
import com.fangjia.dal.mongo.open.model.EvaluateRatio;
|
||||
|
||||
/**
|
||||
* @author shenjian
|
||||
* @since 2022/7/27
|
||||
*/
|
||||
public class EvaluateRatioDaoImpl extends MongoDaoImpl<EvaluateRatio> implements EvaluateRatioDao {
|
||||
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package com.fangjia.dal.mongo.open.model;
|
||||
|
||||
import com.fangjia.dal.MongoEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* ¹À¼ÛϵÊý
|
||||
*
|
||||
* @author shenjian
|
||||
* @since 2022/7/27
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "business.evaluate_ratio")
|
||||
public class EvaluateRatio implements MongoEntity {
|
||||
|
||||
private static final long serialVersionUID = 5299813614465690722L;
|
||||
private String id;
|
||||
private String category;
|
||||
private String city;
|
||||
private String region;
|
||||
private Double ratio;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "_id", unique = true, nullable = false)
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "category")
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@Column(name = "city")
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
@Column(name = "region")
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
@Column(name = "ratio")
|
||||
public Double getRatio() {
|
||||
return ratio;
|
||||
}
|
||||
|
||||
public void setRatio(Double ratio) {
|
||||
this.ratio = ratio;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.fangjia.dal.seawater.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.dal.SeawaterQuery;
|
||||
import com.fangjia.dal.seawater.model.Seawater;
|
||||
|
||||
/**
|
||||
@@ -18,4 +19,12 @@ public interface SeawaterDao extends com.fangjia.dal.SeawaterDao<Seawater> {
|
||||
Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit , String table);
|
||||
|
||||
List<Seawater> findHouses(String city, String region, List<String> alias, Integer minPrice, Integer maxPrice, Integer limit);
|
||||
|
||||
List<Seawater> findSeawatersByQuery(SeawaterQuery query);
|
||||
|
||||
long findSeawatersCountByQuery(SeawaterQuery query);
|
||||
|
||||
void batchDeleteByParams(SeawaterQuery query);
|
||||
|
||||
void batchUpdateEstateType(SeawaterQuery query);
|
||||
}
|
||||
|
||||
+459
-16
@@ -2,6 +2,7 @@ package com.fangjia.dal.seawater.dao;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.fangjia.dal.SeawaterQuery;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
@@ -11,6 +12,7 @@ import com.fangjia.dal.seawater.model.Seawater;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.sothis.core.util.Pager;
|
||||
|
||||
public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> implements SeawaterDao {
|
||||
|
||||
@@ -29,7 +31,14 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
||||
@Override
|
||||
public Seawater findByIdFromEs(String id,String table) {
|
||||
Seawater seawater = null;
|
||||
List<JSONObject> jsonList = queryList(id,null,null,null,null,null,null,null,null, null, null, null, null, null,null,null,false,-1,-1,table);
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
query.setId(id);
|
||||
query.setTable(table);
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(-1);
|
||||
pager.setPageSize(-1);
|
||||
query.setPager(pager);
|
||||
List<JSONObject> jsonList = queryList(query);
|
||||
if(jsonList == null){
|
||||
return null;
|
||||
}else{
|
||||
@@ -44,7 +53,28 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
||||
@Override
|
||||
public List<Seawater> findSeawatersFromEs(String category, String city, String region, String name, List<String> alias, List<String> regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit, String table) {
|
||||
List<Seawater> seawaterList= new ArrayList<Seawater>();
|
||||
List<JSONObject> jsonList = queryList(null,category,city,region,name,alias,regionAlias,startDate,endDate, startArea, endArea, startPrice, endPrice, room,root,sort,order,start,limit,table);
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
query.setCat(category);
|
||||
query.setCityDisplay(city);
|
||||
query.setRegion(region);
|
||||
query.setDistrictName(name);
|
||||
query.setDistrictAlias(alias);
|
||||
query.setRegionAlias(regionAlias);
|
||||
query.setStartDate(startDate);
|
||||
query.setEndDate(endDate);
|
||||
query.setStartArea(startArea);
|
||||
query.setEndArea(endArea);
|
||||
query.setStartPrice(startPrice);
|
||||
query.setEndPrice(endPrice);
|
||||
query.setRoom(room);
|
||||
query.setRootName(root);
|
||||
query.setOrder(order);
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(start);
|
||||
pager.setPageSize(limit);
|
||||
query.setPager(pager);
|
||||
query.setTable(table);
|
||||
List<JSONObject> jsonList = queryList(query);
|
||||
if(jsonList == null){
|
||||
return null;
|
||||
}else{
|
||||
@@ -53,6 +83,23 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
||||
return seawaterList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Seawater> findSeawatersByQuery(SeawaterQuery query){
|
||||
List<Seawater> seawaterList;
|
||||
List<JSONObject> jsonList = queryList(query);
|
||||
if(jsonList == null){
|
||||
return null;
|
||||
}else{
|
||||
seawaterList = wrapSeawater(jsonList);
|
||||
}
|
||||
return seawaterList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long findSeawatersCountByQuery(SeawaterQuery query) {
|
||||
int count = queryCount(query);
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Seawater> findHouses(String city, String region, List<String> alias, Integer minPrice, Integer maxPrice, Integer limit) {
|
||||
@@ -136,6 +183,42 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchDeleteByParams(SeawaterQuery query) {
|
||||
HttpRequest request = new HttpRequest();
|
||||
|
||||
JSONObject reqBody = wrapQueryParams(query);
|
||||
|
||||
JSONObject script = new JSONObject();
|
||||
script.put("source", "ctx._source.status=1");
|
||||
script.put("lang", "painless");
|
||||
reqBody.put("script", script);
|
||||
|
||||
try {
|
||||
request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8");
|
||||
} catch (HttpRequestException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchUpdateEstateType(SeawaterQuery query) {
|
||||
HttpRequest request = new HttpRequest();
|
||||
|
||||
JSONObject reqBody = wrapQueryParams(query);
|
||||
|
||||
JSONObject script = new JSONObject();
|
||||
script.put("source", "ctx._source.estate_type="+"'"+query.getEditEstateType()+"'");
|
||||
script.put("lang", "painless");
|
||||
reqBody.put("script", script);
|
||||
|
||||
try {
|
||||
request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8");
|
||||
} catch (HttpRequestException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject addMatch(String name, String value){
|
||||
JSONObject term = new JSONObject();
|
||||
JSONObject match = new JSONObject();
|
||||
@@ -234,6 +317,11 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
||||
}catch(Exception e){
|
||||
seawater.setHall(0);
|
||||
}
|
||||
try{
|
||||
seawater.setToilet(source.getInt("toilet"));
|
||||
}catch(Exception e){
|
||||
seawater.setToilet(0);
|
||||
}
|
||||
try{
|
||||
seawater.setpDate(source.getInt("p_date"));
|
||||
}catch(Exception e){
|
||||
@@ -256,6 +344,9 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
||||
if(source.containsKey("build_type")){
|
||||
seawater.setBuildType(source.getString("build_type"));
|
||||
}
|
||||
if(source.containsKey("status")){
|
||||
seawater.setStatus(source.getInt("status"));
|
||||
}
|
||||
seawaterList.add(seawater);
|
||||
}
|
||||
return seawaterList;
|
||||
@@ -431,29 +522,381 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<JSONObject> queryList(String id,String category, String city, String region, String name, List<String> alias,
|
||||
List<String> regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root,String sort, boolean order, int start, int limit,String table){
|
||||
JSONObject json = query(id,category,city,region,name,alias,regionAlias,startDate,endDate, startArea, endArea, startPrice, endPrice, room,root,sort,order,start,limit,table);
|
||||
|
||||
private JSONObject query(SeawaterQuery query){
|
||||
long time1 = System.currentTimeMillis();
|
||||
JSONObject reqBody = new JSONObject();
|
||||
JSONObject q = new JSONObject();
|
||||
JSONObject queryJson = new JSONObject();
|
||||
List<JSONObject> jsonList = new ArrayList<JSONObject>();
|
||||
if(StringUtils.isNotBlank(query.getId())) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("_id", query.getId());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
if(StringUtils.isNotBlank(query.getCat())) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("cat", query.getCat());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
Set<String> namesList = new LinkedHashSet<String>();
|
||||
if(StringUtils.isNotBlank(query.getDistrictName())) {
|
||||
namesList.add(query.getDistrictName());
|
||||
}
|
||||
if (query.getDistrictAlias() != null) {
|
||||
namesList.addAll(query.getDistrictAlias());
|
||||
}
|
||||
if(namesList != null && namesList.size() > 0){
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("district_name", namesList);
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("terms", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
Set<String> regionsList = new LinkedHashSet<String>();
|
||||
if(StringUtils.isNotBlank(query.getRegion())) {
|
||||
regionsList.add(query.getRegion());
|
||||
}
|
||||
if (query.getRegionAlias() != null) {
|
||||
regionsList.addAll(query.getRegionAlias());
|
||||
}
|
||||
if(regionsList != null && regionsList.size() > 0){
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("region", regionsList);
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("terms", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(query.getCityDisplay())){
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("city", query.getCityDisplay());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
if(StringUtils.isNotBlank(query.getEstateType())) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("estate_type", query.getEstateType());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
if(query.getRoom() != null) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("room", query.getRoom());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
if(StringUtils.isNotBlank(query.getRootName())) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("root", query.getRootName());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
if(query.getStartDate() != null || query.getEndDate() != null){
|
||||
JSONObject param = new JSONObject();
|
||||
JSONObject temp = new JSONObject();
|
||||
JSONObject temp2 = new JSONObject();
|
||||
if(query.getStartDate() != null){
|
||||
temp2.put("gte", query.getStartDate());
|
||||
}
|
||||
if(query.getEndDate() != null){
|
||||
temp2.put("lte", query.getEndDate());
|
||||
}
|
||||
param.put("p_date", temp2);
|
||||
temp.put("range", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
|
||||
if(query.getStartArea() != null || query.getEndArea() != null){
|
||||
JSONObject param = new JSONObject();
|
||||
JSONObject temp = new JSONObject();
|
||||
JSONObject temp2 = new JSONObject();
|
||||
if(query.getStartArea() != null){
|
||||
temp2.put("gte", query.getStartArea());
|
||||
}
|
||||
if(query.getEndArea() != null){
|
||||
temp2.put("lte", query.getEndArea());
|
||||
}
|
||||
param.put("area", temp2);
|
||||
temp.put("range", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
if(query.getStartPrice() != null || query.getEndPrice() != null){
|
||||
JSONObject param = new JSONObject();
|
||||
JSONObject temp = new JSONObject();
|
||||
JSONObject temp2 = new JSONObject();
|
||||
if(query.getStartPrice() != null){
|
||||
temp2.put("gte", query.getStartPrice());
|
||||
}
|
||||
if(query.getEndPrice() != null){
|
||||
temp2.put("lte", query.getEndPrice());
|
||||
}
|
||||
param.put("avg_price", temp2);
|
||||
temp.put("range", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(query.getSort())){
|
||||
JSONObject jsonOrder = new JSONObject();
|
||||
if(query.getOrder()){
|
||||
jsonOrder.put("order", "asc");
|
||||
}else{
|
||||
jsonOrder.put("order", "desc");
|
||||
}
|
||||
JSONObject jsonSort = new JSONObject();
|
||||
jsonSort.put(query.getSortField(), jsonOrder);
|
||||
List<JSONObject> sortJsonList = new ArrayList<JSONObject>();
|
||||
sortJsonList.add(jsonSort);
|
||||
reqBody.put("sort", sortJsonList);
|
||||
}
|
||||
|
||||
if(query.getPager().getStartRow() >= 0){
|
||||
reqBody.put("from", query.getPager().getStartRow());
|
||||
}
|
||||
if(query.getPager().getPageSize() >= 0){
|
||||
reqBody.put("size", query.getPager().getPageSize());
|
||||
}
|
||||
|
||||
if(query.getStatus() != null){
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("status", query.getStatus());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
queryJson.put("must", jsonList);
|
||||
q.put("bool", queryJson);
|
||||
reqBody.put("query", q);
|
||||
//Óû§Ãû:ÃÜÂë
|
||||
Base64 token = new Base64();
|
||||
String authenticationEncoding = token.encodeAsString(new String(""+ES_USER+":"+ES_PASSWORD+"").getBytes());
|
||||
HttpRequest request = new HttpRequest();
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("Content-Type", "application/json");
|
||||
headers.put("Authorization", "Basic "+authenticationEncoding+"");
|
||||
try {
|
||||
String response = request.postWithBody("http://es.fangjia.com:9200/"+query.getTable()+"/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8");
|
||||
JSONObject json = JSONObject.fromObject(response);
|
||||
long time2 = System.currentTimeMillis();
|
||||
System.out.println(time2-time1);
|
||||
return json;
|
||||
} catch (HttpRequestException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// private List<JSONObject> queryList(String id,String category, String city, String region, String name, List<String> alias,
|
||||
// List<String> regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root,String sort, boolean order, int start, int limit,String table){
|
||||
// JSONObject json = query(id,category,city,region,name,alias,regionAlias,startDate,endDate, startArea, endArea, startPrice, endPrice, room,root,sort,order,start,limit,table);
|
||||
// if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){
|
||||
// return null;
|
||||
// }
|
||||
// JSONArray hits = json.getJSONObject("hits").getJSONArray("hits");
|
||||
// List<JSONObject> results = new ArrayList<JSONObject>();
|
||||
// for(int i=0 ;i < hits.size(); i++){
|
||||
// JSONObject jsonObject = hits.getJSONObject(i);
|
||||
// results.add(jsonObject);
|
||||
// }
|
||||
// return results;
|
||||
// }
|
||||
|
||||
private List<JSONObject> queryList(SeawaterQuery query){
|
||||
JSONObject json = query(query);
|
||||
if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){
|
||||
return null;
|
||||
}
|
||||
JSONArray hits = json.getJSONObject("hits").getJSONArray("hits");
|
||||
List<JSONObject> results = new ArrayList<JSONObject>();
|
||||
for(int i=0 ;i < hits.size(); i++){
|
||||
JSONObject jsonObject = hits.getJSONObject(i);
|
||||
results.add(jsonObject);
|
||||
}
|
||||
return results;
|
||||
return null;
|
||||
}
|
||||
JSONArray hits = json.getJSONObject("hits").getJSONArray("hits");
|
||||
List<JSONObject> results = new ArrayList<JSONObject>();
|
||||
for(int i=0 ;i < hits.size(); i++){
|
||||
JSONObject jsonObject = hits.getJSONObject(i);
|
||||
results.add(jsonObject);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private int queryCount(String id,String category, String city, String region, String name, List<String> alias,
|
||||
List<String> regionAlias, Integer startDate, Integer endDate, Integer room, String root,String sort, boolean order, int start, int limit,String table){
|
||||
JSONObject json = query(id,category,city,region,name,alias,regionAlias,startDate,endDate,null, null, null, null, room,root,sort,order,start,limit,table);
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
query.setCat(category);
|
||||
query.setCityDisplay(city);
|
||||
query.setRegion(region);
|
||||
query.setDistrictName(name);
|
||||
query.setDistrictAlias(alias);
|
||||
query.setRegionAlias(regionAlias);
|
||||
query.setStartDate(startDate);
|
||||
query.setEndDate(endDate);
|
||||
query.setRoom(room);
|
||||
query.setRootName(root);
|
||||
query.setOrder(order);
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(start);
|
||||
pager.setPageSize(limit);
|
||||
query.setPager(pager);
|
||||
query.setTable(table);
|
||||
JSONObject json = query(query);
|
||||
if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")){
|
||||
return 0;
|
||||
}
|
||||
return json.getJSONObject("hits").getInt("total");
|
||||
}
|
||||
|
||||
private int queryCount(SeawaterQuery query){
|
||||
JSONObject json = query(query);
|
||||
if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")){
|
||||
return 0;
|
||||
}
|
||||
return json.getJSONObject("hits").getInt("total");
|
||||
}
|
||||
|
||||
private JSONObject wrapQueryParams(SeawaterQuery query){
|
||||
JSONObject reqBody = new JSONObject();
|
||||
JSONObject q = new JSONObject();
|
||||
JSONObject queryJson = new JSONObject();
|
||||
List<JSONObject> jsonList = new ArrayList<JSONObject>();
|
||||
if(StringUtils.isNotBlank(query.getId())) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("_id", query.getId());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
if(StringUtils.isNotBlank(query.getCat())) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("cat", query.getCat());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
Set<String> namesList = new LinkedHashSet<String>();
|
||||
if(StringUtils.isNotBlank(query.getDistrictName())) {
|
||||
namesList.add(query.getDistrictName());
|
||||
}
|
||||
if(namesList != null && namesList.size() > 0){
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("district_name", namesList);
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("terms", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
Set<String> regionsList = new LinkedHashSet<String>();
|
||||
if(StringUtils.isNotBlank(query.getRegion())) {
|
||||
regionsList.add(query.getRegion());
|
||||
}
|
||||
if (query.getRegionAlias() != null) {
|
||||
regionsList.addAll(query.getRegionAlias());
|
||||
}
|
||||
if(regionsList != null && regionsList.size() > 0){
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("region", regionsList);
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("terms", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(query.getCityDisplay())){
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("city", query.getCityDisplay());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
if(StringUtils.isNotBlank(query.getEstateType())) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("estate_type", query.getEstateType());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
if(query.getRoom() != null) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("room", query.getRoom());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
if(StringUtils.isNotBlank(query.getRootName())) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("root", query.getRootName());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
if(query.getStartDate() != null || query.getEndDate() != null){
|
||||
JSONObject param = new JSONObject();
|
||||
JSONObject temp = new JSONObject();
|
||||
JSONObject temp2 = new JSONObject();
|
||||
if(query.getStartDate() != null){
|
||||
temp2.put("gte", query.getStartDate());
|
||||
}
|
||||
if(query.getEndDate() != null){
|
||||
temp2.put("lte", query.getEndDate());
|
||||
}
|
||||
param.put("p_date", temp2);
|
||||
temp.put("range", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
|
||||
if(query.getStartArea() != null || query.getEndArea() != null){
|
||||
JSONObject param = new JSONObject();
|
||||
JSONObject temp = new JSONObject();
|
||||
JSONObject temp2 = new JSONObject();
|
||||
if(query.getStartArea() != null){
|
||||
temp2.put("gte", query.getStartArea());
|
||||
}
|
||||
if(query.getEndArea() != null){
|
||||
temp2.put("lte", query.getEndArea());
|
||||
}
|
||||
param.put("area", temp2);
|
||||
temp.put("range", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
if(query.getStartPrice() != null || query.getEndPrice() != null){
|
||||
JSONObject param = new JSONObject();
|
||||
JSONObject temp = new JSONObject();
|
||||
JSONObject temp2 = new JSONObject();
|
||||
if(query.getStartPrice() != null){
|
||||
temp2.put("gte", query.getStartPrice());
|
||||
}
|
||||
if(query.getEndPrice() != null){
|
||||
temp2.put("lte", query.getEndPrice());
|
||||
}
|
||||
param.put("avg_price", temp2);
|
||||
temp.put("range", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
if(query.getStatus() != null){
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("status", query.getStatus());
|
||||
JSONObject temp = new JSONObject();
|
||||
temp.put("term", param);
|
||||
jsonList.add(temp);
|
||||
}
|
||||
|
||||
queryJson.put("must", jsonList);
|
||||
q.put("bool", queryJson);
|
||||
reqBody.put("query", q);
|
||||
return reqBody;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -102,8 +102,10 @@ public class FjtEvaluation implements SqlEntity{
|
||||
|
||||
private String finishDateStr;//竣工时间
|
||||
private String useType;//房屋用途
|
||||
private String certificateAddress; //产证地址
|
||||
|
||||
private Date downPdfDate;//下载报告时间
|
||||
private Integer loan ;//是否续贷 1:是 0:否
|
||||
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Id
|
||||
@@ -753,6 +755,16 @@ public class FjtEvaluation implements SqlEntity{
|
||||
}
|
||||
|
||||
|
||||
@Column(name = "certificate_address")
|
||||
public String getCertificateAddress() {
|
||||
return certificateAddress;
|
||||
}
|
||||
|
||||
public void setCertificateAddress(String certificateAddress) {
|
||||
this.certificateAddress = certificateAddress;
|
||||
}
|
||||
|
||||
|
||||
@Column(name = "down_pdf_date")
|
||||
public Date getDownPdfDate() {
|
||||
return downPdfDate;
|
||||
@@ -762,6 +774,15 @@ public class FjtEvaluation implements SqlEntity{
|
||||
this.downPdfDate = downPdfDate;
|
||||
}
|
||||
|
||||
@Column(name = "loan")
|
||||
public Integer getLoan() {
|
||||
return loan;
|
||||
}
|
||||
|
||||
public void setLoan(Integer loan) {
|
||||
this.loan = loan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FjtEvaluation{" +
|
||||
|
||||
@@ -11,7 +11,7 @@ public class ReportFileAttach implements SqlEntity {
|
||||
private Integer userId;
|
||||
private Integer evaluationId;
|
||||
private String queryId;
|
||||
private Integer fileClass;
|
||||
private Integer fileClass;//1:询价单 2:产证 3:房屋照片 4:其它附件 5:产调报告或权籍
|
||||
private String fileName;
|
||||
private String fileId;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
<mainClass>com.fangjia.datastore.DataStoreServer</mainClass>
|
||||
</manifest>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
@@ -94,8 +94,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>2.6.5</version>
|
||||
<artifactId>mongodb-driver-legacy</artifactId>
|
||||
<version>3.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
|
||||
+18
-19
@@ -1,22 +1,21 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
public class ConfigurationException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 6570405263317311822L;
|
||||
|
||||
public ConfigurationException() {
|
||||
}
|
||||
|
||||
public ConfigurationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ConfigurationException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public ConfigurationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public class ConfigurationException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 6570405263317311822L;
|
||||
|
||||
public ConfigurationException() {
|
||||
}
|
||||
|
||||
public ConfigurationException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ConfigurationException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public ConfigurationException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,80 +1,83 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
import com.fangjia.datastore.mongo.protocol.QueryMessage;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import com.fangjia.datastore.mongo.protocol.QueryMessage;
|
||||
|
||||
public class Cursor {
|
||||
private static final AtomicLong ID_GENERATOR = new AtomicLong(1);
|
||||
private long id;
|
||||
private int limit;
|
||||
private int skip;
|
||||
private long totalCount;
|
||||
private QueryMessage queryMessage;
|
||||
|
||||
public Cursor(int skip, int limit, QueryMessage queryMessage, long totalCount) {
|
||||
id = ID_GENERATOR.getAndIncrement();
|
||||
this.skip = skip;
|
||||
this.limit = limit;
|
||||
this.totalCount = totalCount;
|
||||
this.queryMessage = queryMessage;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public int nextSkip() {
|
||||
skip += limit;
|
||||
return skip;
|
||||
}
|
||||
|
||||
public void setSkip(int skip) {
|
||||
this.skip = skip;
|
||||
}
|
||||
|
||||
public boolean hasMore() {
|
||||
return this.totalCount > this.skip;
|
||||
}
|
||||
|
||||
public long getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public void setTotalCount(long totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
public QueryMessage getQueryMessage() {
|
||||
return queryMessage;
|
||||
}
|
||||
|
||||
public void setQueryMessage(QueryMessage queryMessage) {
|
||||
this.queryMessage = queryMessage;
|
||||
}
|
||||
|
||||
public int getSkip() {
|
||||
return skip;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("id:").append(id);
|
||||
builder.append(", limit:").append(limit);
|
||||
builder.append(", skip:").append(skip);
|
||||
builder.append(", totalCount:").append(totalCount);
|
||||
builder.append(", queryMessage:").append(queryMessage);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public class Cursor
|
||||
{
|
||||
private static final AtomicLong ID_GENERATOR;
|
||||
private long id;
|
||||
private int limit;
|
||||
private int skip;
|
||||
private long totalCount;
|
||||
private QueryMessage queryMessage;
|
||||
|
||||
public Cursor(final int skip, final int limit, final QueryMessage queryMessage, final long totalCount) {
|
||||
this.id = Cursor.ID_GENERATOR.getAndIncrement();
|
||||
this.skip = skip;
|
||||
this.limit = limit;
|
||||
this.totalCount = totalCount;
|
||||
this.queryMessage = queryMessage;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return this.limit;
|
||||
}
|
||||
|
||||
public void setLimit(final int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public int nextSkip() {
|
||||
return this.skip += this.limit;
|
||||
}
|
||||
|
||||
public void setSkip(final int skip) {
|
||||
this.skip = skip;
|
||||
}
|
||||
|
||||
public boolean hasMore() {
|
||||
return this.totalCount > this.skip;
|
||||
}
|
||||
|
||||
public long getTotalCount() {
|
||||
return this.totalCount;
|
||||
}
|
||||
|
||||
public void setTotalCount(final long totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
public QueryMessage getQueryMessage() {
|
||||
return this.queryMessage;
|
||||
}
|
||||
|
||||
public void setQueryMessage(final QueryMessage queryMessage) {
|
||||
this.queryMessage = queryMessage;
|
||||
}
|
||||
|
||||
public int getSkip() {
|
||||
return this.skip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("id:").append(this.id);
|
||||
builder.append(", limit:").append(this.limit);
|
||||
builder.append(", skip:").append(this.skip);
|
||||
builder.append(", totalCount:").append(this.totalCount);
|
||||
builder.append(", queryMessage:").append(this.queryMessage);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
static {
|
||||
ID_GENERATOR = new AtomicLong(1L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,35 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.bson.BSONObject;
|
||||
|
||||
import com.fangjia.datastore.config.Reloadable;
|
||||
import com.fangjia.datastore.config.StoreConfig;
|
||||
import com.fangjia.datastore.solr.Index;
|
||||
import java.util.Collection;
|
||||
import com.fangjia.datastore.config.StoreConfig;
|
||||
import com.fangjia.datastore.config.Reloadable;
|
||||
|
||||
public interface DataStore extends Reloadable {
|
||||
|
||||
StoreConfig getStoreConfig();
|
||||
|
||||
Mongo getMongo();
|
||||
|
||||
Object getAttribute(String key);
|
||||
|
||||
Object setAttribute(String key, Object attr);
|
||||
|
||||
Collection<Index> getIndexes() throws DataStoreException;
|
||||
|
||||
/**
|
||||
* °´²éѯÌõ¼þÖØ½¨Ë÷Òý
|
||||
*
|
||||
* @param query
|
||||
* @throws DataStoreException
|
||||
*/
|
||||
BSONObject reIndex(BSONObject query) throws DataStoreException;
|
||||
|
||||
void ensureIndex(Collection<Index> indexes) throws DataStoreException;
|
||||
|
||||
QueryResponse find(BSONObject query, BSONObject fields, BSONObject sort, BSONObject facet, int skip, int limit, boolean bulk,
|
||||
boolean fromMaster) throws DataStoreException;
|
||||
|
||||
int count(BSONObject query, boolean fromMaster) throws DataStoreException;
|
||||
|
||||
void remove(BSONObject query) throws DataStoreException;
|
||||
|
||||
void update(BSONObject query, BSONObject data,String ip) throws DataStoreException;
|
||||
|
||||
void save(List<? extends BSONObject> docList) throws DataStoreException;
|
||||
public interface DataStore extends Reloadable
|
||||
{
|
||||
StoreConfig getStoreConfig();
|
||||
|
||||
Mongo getMongo();
|
||||
|
||||
Object getAttribute(final String p0);
|
||||
|
||||
Object setAttribute(final String p0, final Object p1);
|
||||
|
||||
Collection<Index> getIndexes() throws DataStoreException;
|
||||
|
||||
BSONObject reIndex(final BSONObject p0) throws DataStoreException;
|
||||
|
||||
void ensureIndex(final Collection<Index> p0) throws DataStoreException;
|
||||
|
||||
QueryResponse find(final BSONObject p0, final BSONObject p1, final BSONObject p2, final BSONObject p3, final int p4, final int p5, final boolean p6, final boolean p7) throws DataStoreException;
|
||||
|
||||
int count(final BSONObject p0, final boolean p1) throws DataStoreException;
|
||||
|
||||
void remove(final BSONObject p0) throws DataStoreException;
|
||||
|
||||
int update(final BSONObject p0, final BSONObject p1) throws DataStoreException;
|
||||
|
||||
void save(final List<? extends BSONObject> p0) throws DataStoreException;
|
||||
}
|
||||
|
||||
+11
-11
@@ -3,15 +3,15 @@ package com.fangjia.datastore;
|
||||
import com.fangjia.datastore.config.DataStoreConfig;
|
||||
import com.fangjia.datastore.config.Reloadable;
|
||||
|
||||
public interface DataStoreContext extends Reloadable {
|
||||
|
||||
DataStoreConfig getDataStoreConfig();
|
||||
|
||||
DataStore getDataStore(String storeName) throws DataStoreException;
|
||||
|
||||
Cursor getCursor(long cursorId);
|
||||
|
||||
void addCursor(Cursor cursor);
|
||||
|
||||
Cursor removeCursor(long cursorId);
|
||||
public interface DataStoreContext extends Reloadable
|
||||
{
|
||||
DataStoreConfig getDataStoreConfig();
|
||||
|
||||
DataStore getDataStore(final String p0) throws DataStoreException;
|
||||
|
||||
Cursor getCursor(final long p0);
|
||||
|
||||
void addCursor(final Cursor p0);
|
||||
|
||||
Cursor removeCursor(final long p0);
|
||||
}
|
||||
|
||||
+55
-50
@@ -1,56 +1,61 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.fangjia.datastore.config.DataStoreConfig;
|
||||
import com.fangjia.datastore.config.StoreConfig;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import java.util.Map;
|
||||
import com.fangjia.datastore.config.DataStoreConfig;
|
||||
|
||||
public class DataStoreContextImpl implements DataStoreContext {
|
||||
|
||||
private final DataStoreConfig config;
|
||||
private final Map<Long, Cursor> cursorMap;
|
||||
private final Map<String, DataStore> stores;
|
||||
|
||||
public DataStoreContextImpl(DataStoreConfig config) throws ConfigurationException {
|
||||
this.config = config;
|
||||
cursorMap = new MapMaker().concurrencyLevel(50).expiration(config.getServerConfig().getCursorExpirationMinutes(),
|
||||
TimeUnit.MINUTES).makeMap();
|
||||
Set<String> storeNames = config.getStoreNames();
|
||||
stores = new HashMap<String, DataStore>(storeNames.size());
|
||||
for (String storeName : storeNames) {
|
||||
StoreConfig storeConfig = this.config.getStoreConfig(storeName);
|
||||
stores.put(storeName, new DataStoreImpl(storeConfig, new Mongo(storeConfig.getMongoConfig())));
|
||||
}
|
||||
}
|
||||
|
||||
public DataStoreConfig getDataStoreConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public DataStore getDataStore(String storeName) throws DataStoreException {
|
||||
if (!stores.containsKey(storeName)) {
|
||||
throw new DataStoreException("unknown store name: \"" + storeName + "\"");
|
||||
}
|
||||
return stores.get(storeName);
|
||||
}
|
||||
|
||||
public void reload() throws ConfigurationException {
|
||||
config.reload();
|
||||
}
|
||||
|
||||
public Cursor getCursor(long cursorId) {
|
||||
return this.cursorMap.get(cursorId);
|
||||
}
|
||||
|
||||
public void addCursor(Cursor cursor) {
|
||||
this.cursorMap.put(cursor.getId(), cursor);
|
||||
}
|
||||
|
||||
public Cursor removeCursor(long cursorId) {
|
||||
return this.cursorMap.remove(cursorId);
|
||||
}
|
||||
public class DataStoreContextImpl implements DataStoreContext
|
||||
{
|
||||
private final DataStoreConfig config;
|
||||
private final Map<Long, Cursor> cursorMap;
|
||||
private final Map<String, DataStore> stores;
|
||||
|
||||
public DataStoreContextImpl(final DataStoreConfig config) throws ConfigurationException {
|
||||
this.config = config;
|
||||
this.cursorMap = new MapMaker().concurrencyLevel(50).expiration((long)config.getServerConfig().getCursorExpirationMinutes(), TimeUnit.MINUTES).makeMap();
|
||||
final Set<String> storeNames = config.getStoreNames();
|
||||
this.stores = new HashMap<String, DataStore>(storeNames.size());
|
||||
for (final String storeName : storeNames) {
|
||||
final StoreConfig storeConfig = this.config.getStoreConfig(storeName);
|
||||
this.stores.put(storeName, new DataStoreImpl(storeConfig, new Mongo(storeConfig.getMongoConfig())));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStoreConfig getDataStoreConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStore getDataStore(final String storeName) throws DataStoreException {
|
||||
if (!this.stores.containsKey(storeName)) {
|
||||
throw new DataStoreException("unknown store name: \"" + storeName + "\"");
|
||||
}
|
||||
return this.stores.get(storeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() throws ConfigurationException {
|
||||
this.config.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor getCursor(final long cursorId) {
|
||||
return this.cursorMap.get(cursorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCursor(final Cursor cursor) {
|
||||
this.cursorMap.put(cursor.getId(), cursor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor removeCursor(final long cursorId) {
|
||||
return this.cursorMap.remove(cursorId);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-20
@@ -1,23 +1,21 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
public class DataStoreException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -5492973985910379215L;
|
||||
|
||||
public DataStoreException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DataStoreException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DataStoreException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DataStoreException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public class DataStoreException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = -5492973985910379215L;
|
||||
|
||||
public DataStoreException() {
|
||||
}
|
||||
|
||||
public DataStoreException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DataStoreException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DataStoreException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
|
||||
+627
-692
File diff suppressed because it is too large
Load Diff
+167
-182
@@ -1,193 +1,178 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.service.IoHandlerAdapter;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.mina.core.service.IoService;
|
||||
import org.apache.mina.core.service.IoServiceListener;
|
||||
import org.apache.mina.core.service.SimpleIoProcessorPool;
|
||||
import org.apache.mina.core.session.IdleStatus;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.apache.mina.filter.codec.ProtocolCodecException;
|
||||
import org.apache.mina.filter.codec.ProtocolCodecFilter;
|
||||
import org.apache.mina.filter.logging.LogLevel;
|
||||
import org.apache.mina.filter.logging.LoggingFilter;
|
||||
import org.apache.mina.transport.socket.SocketSessionConfig;
|
||||
import org.apache.mina.transport.socket.nio.NioProcessor;
|
||||
import org.apache.mina.transport.socket.nio.NioSession;
|
||||
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
|
||||
import java.util.Arrays;
|
||||
import org.bson.BSONObject;
|
||||
import org.bson.BasicBSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fangjia.datastore.config.DataStoreConfig;
|
||||
import com.fangjia.datastore.handler.DeleteMessageHandler;
|
||||
import com.fangjia.datastore.handler.GetMoreMessageHandler;
|
||||
import com.fangjia.datastore.handler.InsertMessageHandler;
|
||||
import com.fangjia.datastore.handler.KillCursorsMessageHandler;
|
||||
import com.fangjia.datastore.handler.MessageHandler;
|
||||
import com.fangjia.datastore.handler.QueryMessageHandler;
|
||||
import com.fangjia.datastore.mongo.protocol.ReplyMessage;
|
||||
import org.apache.mina.filter.codec.ProtocolCodecException;
|
||||
import java.io.IOException;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.apache.mina.transport.socket.SocketSessionConfig;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import org.apache.mina.core.session.IdleStatus;
|
||||
import org.apache.mina.core.service.IoHandler;
|
||||
import com.fangjia.datastore.handler.UpdateMessageHandler;
|
||||
import com.fangjia.datastore.mongo.codec.BSONIoBufferAllocator;
|
||||
import com.fangjia.datastore.mongo.protocol.UpdateMessage;
|
||||
import com.fangjia.datastore.handler.DeleteMessageHandler;
|
||||
import com.fangjia.datastore.mongo.protocol.DeleteMessage;
|
||||
import com.fangjia.datastore.handler.KillCursorsMessageHandler;
|
||||
import com.fangjia.datastore.mongo.protocol.KillCursorsMessage;
|
||||
import com.fangjia.datastore.handler.GetMoreMessageHandler;
|
||||
import com.fangjia.datastore.mongo.protocol.GetMoreMessage;
|
||||
import com.fangjia.datastore.handler.QueryMessageHandler;
|
||||
import com.fangjia.datastore.mongo.protocol.QueryMessage;
|
||||
import com.fangjia.datastore.handler.InsertMessageHandler;
|
||||
import com.fangjia.datastore.mongo.protocol.InsertMessage;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import org.apache.mina.filter.logging.LogLevel;
|
||||
import org.apache.mina.filter.logging.LoggingFilter;
|
||||
import org.apache.mina.core.filterchain.IoFilter;
|
||||
import org.apache.mina.filter.codec.ProtocolDecoder;
|
||||
import org.apache.mina.filter.codec.ProtocolEncoder;
|
||||
import org.apache.mina.filter.codec.ProtocolCodecFilter;
|
||||
import com.fangjia.datastore.mongo.codec.MongoProtocolDecoder;
|
||||
import com.fangjia.datastore.mongo.codec.MongoProtocolEncoder;
|
||||
import com.fangjia.datastore.mongo.protocol.DeleteMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.GetMoreMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.InsertMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.KillCursorsMessage;
|
||||
import org.apache.mina.core.service.IoProcessor;
|
||||
import java.util.concurrent.Executor;
|
||||
import org.apache.mina.core.service.SimpleIoProcessorPool;
|
||||
import org.apache.mina.transport.socket.nio.NioProcessor;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.apache.mina.core.buffer.IoBufferAllocator;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import com.fangjia.datastore.mongo.codec.BSONIoBufferAllocator;
|
||||
import com.fangjia.datastore.config.DataStoreConfig;
|
||||
import java.util.HashMap;
|
||||
import com.fangjia.datastore.handler.MessageHandler;
|
||||
import java.util.Map;
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.QueryMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.ReplyMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.UpdateMessage;
|
||||
|
||||
public class DataStoreServer extends IoHandlerAdapter implements IoServiceListener {
|
||||
|
||||
private final NioSocketAcceptor acceptor;
|
||||
private final DataStoreContext context;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DataStoreServer.class);
|
||||
private static ThreadLocal<MongoMessage> CURRENT_MESSAGE = new ThreadLocal<MongoMessage>();
|
||||
private final Map<Class<? extends MongoMessage>, MessageHandler<? extends MongoMessage>> handlerMap = new HashMap<Class<? extends MongoMessage>, MessageHandler<? extends MongoMessage>>();
|
||||
|
||||
public DataStoreServer(String[] args) throws Exception {
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("starting datastore...");
|
||||
}
|
||||
|
||||
DataStoreConfig config = new DataStoreConfig(System.getProperty("datastore.home", "d:\\goojiaconfig\\datastore"));
|
||||
config.setReadOnly(Boolean.getBoolean("datastore.readOnly"));
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info(config.toString());
|
||||
}
|
||||
context = new DataStoreContextImpl(config);
|
||||
|
||||
IoBuffer.setAllocator(new BSONIoBufferAllocator());
|
||||
|
||||
final ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
acceptor = new NioSocketAcceptor(executorService, new SimpleIoProcessorPool<NioSession>(NioProcessor.class, config
|
||||
.getServerConfig().getMaxConnections()));
|
||||
|
||||
acceptor.getFilterChain().addLast("codec",
|
||||
new ProtocolCodecFilter(new MongoProtocolEncoder(), new MongoProtocolDecoder()));
|
||||
acceptor.getFilterChain().addLast("performance",
|
||||
new PerformanceLogFilter(config.getServerConfig().getPerformanceLogFilterMaxTime()));
|
||||
if (!config.getServerConfig().isDisableLogging()) {
|
||||
LoggingFilter loggingFilter = new LoggingFilter(DataStoreServer.class);
|
||||
loggingFilter.setExceptionCaughtLogLevel(LogLevel.NONE);
|
||||
acceptor.getFilterChain().addLast("logger", loggingFilter);
|
||||
}
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LOGGER.info("shutting down...");
|
||||
acceptor.unbind();
|
||||
executorService.shutdown();
|
||||
LOGGER.info("shut down");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// register message handlers
|
||||
register(InsertMessage.class, new InsertMessageHandler(context));
|
||||
register(QueryMessage.class, new QueryMessageHandler(context));
|
||||
register(GetMoreMessage.class, new GetMoreMessageHandler(context));
|
||||
register(KillCursorsMessage.class, new KillCursorsMessageHandler(context));
|
||||
register(DeleteMessage.class, new DeleteMessageHandler(context));
|
||||
register(UpdateMessage.class, new UpdateMessageHandler(context));
|
||||
|
||||
acceptor.setHandler(this);
|
||||
acceptor.addListener(this);
|
||||
acceptor.setReuseAddress(true);
|
||||
SocketSessionConfig sessionConfig = acceptor.getSessionConfig();
|
||||
sessionConfig.setTcpNoDelay(true);
|
||||
sessionConfig.setKeepAlive(true);
|
||||
sessionConfig.setReuseAddress(true);
|
||||
sessionConfig.setReadBufferSize(config.getServerConfig().getMinaReadBufferSize());
|
||||
sessionConfig.setIdleTime(IdleStatus.BOTH_IDLE, 300);
|
||||
acceptor.bind(new InetSocketAddress(config.getServerConfig().getPort()));
|
||||
}
|
||||
|
||||
private void register(Class<? extends MongoMessage> messageClass, MessageHandler<? extends MongoMessage> handler) {
|
||||
this.handlerMap.put(messageClass, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* @throws Exception
|
||||
* @throws
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
new DataStoreServer(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
|
||||
if (cause instanceof IOException && null != cause.getMessage() && cause.getMessage().contains("Connection reset by peer")) {
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("connection closed on session: {}", session);
|
||||
}
|
||||
} else if (cause instanceof ProtocolCodecException) {
|
||||
// ProtocolDecoderException or ProtocolEncoderException
|
||||
MongoMessage message = CURRENT_MESSAGE.get();
|
||||
if (null != message) {
|
||||
if (message instanceof QueryMessage) {
|
||||
QueryMessage queryMessage = (QueryMessage) message;
|
||||
ReplyMessage reply = new ReplyMessage();
|
||||
reply.setNumberReturned(1);
|
||||
reply.setResponseFlag(8);
|
||||
reply.getMessageHeader().setResponseTo(queryMessage.getMessageHeader().getRequestID());
|
||||
BSONObject msg = new BasicBSONObject("$err", cause.getMessage());
|
||||
reply.setDocuments(Arrays.asList(msg));
|
||||
session.write(reply);
|
||||
}
|
||||
}
|
||||
} else if (LOGGER.isErrorEnabled()) {
|
||||
LOGGER.error("exception caught on session:{" + session + "}", cause);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(IoSession session, Object message) throws Exception {
|
||||
if (message instanceof MongoMessage) {
|
||||
MongoMessage mongoMessage = (MongoMessage) message;
|
||||
CURRENT_MESSAGE.set(mongoMessage);
|
||||
MessageHandler<? extends MongoMessage> handler = this.handlerMap.get(mongoMessage.getClass());
|
||||
if (null != handler) {
|
||||
handler.messageReceived(session, mongoMessage);
|
||||
} else {
|
||||
throw new RuntimeException("unknown message received:" + message);
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("unknown message received:" + message);
|
||||
}
|
||||
}
|
||||
|
||||
public void serviceActivated(IoService service) throws Exception {
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("datastore started");
|
||||
LOGGER.info("listening at " + this.context.getDataStoreConfig().getServerConfig().getPort());
|
||||
}
|
||||
}
|
||||
|
||||
public void serviceIdle(IoService service, IdleStatus idleStatus) throws Exception {
|
||||
// empty
|
||||
}
|
||||
|
||||
public void serviceDeactivated(IoService service) throws Exception {
|
||||
// empty
|
||||
}
|
||||
|
||||
public void sessionDestroyed(IoSession session) throws Exception {
|
||||
// empty
|
||||
}
|
||||
import org.slf4j.Logger;
|
||||
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
|
||||
import org.apache.mina.core.service.IoServiceListener;
|
||||
import org.apache.mina.core.service.IoHandlerAdapter;
|
||||
|
||||
public class DataStoreServer extends IoHandlerAdapter implements IoServiceListener
|
||||
{
|
||||
private final NioSocketAcceptor acceptor;
|
||||
private final DataStoreContext context;
|
||||
private static final Logger LOGGER;
|
||||
private static ThreadLocal<MongoMessage> CURRENT_MESSAGE;
|
||||
private final Map<Class<? extends MongoMessage>, MessageHandler<? extends MongoMessage>> handlerMap;
|
||||
|
||||
public DataStoreServer(final String[] args) throws Exception {
|
||||
this.handlerMap = new HashMap<Class<? extends MongoMessage>, MessageHandler<? extends MongoMessage>>();
|
||||
if (DataStoreServer.LOGGER.isInfoEnabled()) {
|
||||
DataStoreServer.LOGGER.info("starting datastore...");
|
||||
}
|
||||
final DataStoreConfig config = new DataStoreConfig(System.getProperty("datastore.home", "D:\\goojiaconfig\\seaweedsolr6"));
|
||||
config.setReadOnly(Boolean.getBoolean("datastore.readOnly"));
|
||||
if (DataStoreServer.LOGGER.isInfoEnabled()) {
|
||||
DataStoreServer.LOGGER.info(config.toString());
|
||||
}
|
||||
this.context = new DataStoreContextImpl(config);
|
||||
IoBuffer.setAllocator(new BSONIoBufferAllocator());
|
||||
final ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
this.acceptor = new NioSocketAcceptor(executorService, new SimpleIoProcessorPool(NioProcessor.class, config.getServerConfig().getMaxConnections()));
|
||||
this.acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MongoProtocolEncoder(), new MongoProtocolDecoder()));
|
||||
this.acceptor.getFilterChain().addLast("performance", new PerformanceLogFilter(config.getServerConfig().getPerformanceLogFilterMaxTime()));
|
||||
if (!config.getServerConfig().isDisableLogging()) {
|
||||
final LoggingFilter loggingFilter = new LoggingFilter(DataStoreServer.class);
|
||||
loggingFilter.setExceptionCaughtLogLevel(LogLevel.NONE);
|
||||
this.acceptor.getFilterChain().addLast("logger", loggingFilter);
|
||||
}
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
DataStoreServer.LOGGER.info("shutting down...");
|
||||
DataStoreServer.this.acceptor.unbind();
|
||||
executorService.shutdown();
|
||||
DataStoreServer.LOGGER.info("shut down");
|
||||
}
|
||||
});
|
||||
this.register(InsertMessage.class, new InsertMessageHandler(this.context));
|
||||
this.register(QueryMessage.class, new QueryMessageHandler(this.context));
|
||||
this.register(GetMoreMessage.class, new GetMoreMessageHandler(this.context));
|
||||
this.register(KillCursorsMessage.class, new KillCursorsMessageHandler(this.context));
|
||||
this.register(DeleteMessage.class, new DeleteMessageHandler(this.context));
|
||||
this.register(UpdateMessage.class, new UpdateMessageHandler(this.context));
|
||||
this.acceptor.setHandler(this);
|
||||
this.acceptor.addListener(this);
|
||||
this.acceptor.setReuseAddress(true);
|
||||
final SocketSessionConfig sessionConfig = this.acceptor.getSessionConfig();
|
||||
sessionConfig.setTcpNoDelay(true);
|
||||
sessionConfig.setKeepAlive(true);
|
||||
sessionConfig.setReuseAddress(true);
|
||||
sessionConfig.setReadBufferSize(config.getServerConfig().getMinaReadBufferSize());
|
||||
sessionConfig.setIdleTime(IdleStatus.BOTH_IDLE, 300);
|
||||
this.acceptor.bind(new InetSocketAddress(config.getServerConfig().getPort()));
|
||||
}
|
||||
|
||||
private void register(final Class<? extends MongoMessage> messageClass, final MessageHandler<? extends MongoMessage> handler) {
|
||||
this.handlerMap.put(messageClass, handler);
|
||||
}
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
new DataStoreServer(args);
|
||||
}
|
||||
|
||||
public void exceptionCaught(final IoSession session, final Throwable cause) throws Exception {
|
||||
if (cause instanceof IOException && null != cause.getMessage() && cause.getMessage().contains("Connection reset by peer")) {
|
||||
if (DataStoreServer.LOGGER.isInfoEnabled()) {
|
||||
DataStoreServer.LOGGER.info("connection closed on session: {}", (Object)session);
|
||||
}
|
||||
}
|
||||
else if (cause instanceof ProtocolCodecException) {
|
||||
final MongoMessage message = DataStoreServer.CURRENT_MESSAGE.get();
|
||||
if (null != message && message instanceof QueryMessage) {
|
||||
final QueryMessage queryMessage = (QueryMessage)message;
|
||||
final ReplyMessage reply = new ReplyMessage();
|
||||
reply.setNumberReturned(1);
|
||||
reply.setResponseFlag(8);
|
||||
reply.getMessageHeader().setResponseTo(queryMessage.getMessageHeader().getRequestID());
|
||||
final BSONObject msg = (BSONObject)new BasicBSONObject("$err", cause.getMessage());
|
||||
reply.setDocuments(Arrays.<BSONObject>asList(msg));
|
||||
session.write((Object)reply);
|
||||
}
|
||||
}
|
||||
else if (DataStoreServer.LOGGER.isErrorEnabled()) {
|
||||
DataStoreServer.LOGGER.error("exception caught on session:{" + session + "}", cause);
|
||||
}
|
||||
}
|
||||
|
||||
public void messageReceived(final IoSession session, final Object message) throws Exception {
|
||||
if (!(message instanceof MongoMessage)) {
|
||||
throw new RuntimeException("unknown message received:" + message);
|
||||
}
|
||||
final MongoMessage mongoMessage = (MongoMessage)message;
|
||||
DataStoreServer.CURRENT_MESSAGE.set(mongoMessage);
|
||||
final MessageHandler<? extends MongoMessage> handler = this.handlerMap.get(mongoMessage.getClass());
|
||||
if (null != handler) {
|
||||
handler.messageReceived(session, mongoMessage);
|
||||
return;
|
||||
}
|
||||
throw new RuntimeException("unknown message received:" + message);
|
||||
}
|
||||
|
||||
public void serviceActivated(final IoService service) throws Exception {
|
||||
if (DataStoreServer.LOGGER.isInfoEnabled()) {
|
||||
DataStoreServer.LOGGER.info("datastore started");
|
||||
DataStoreServer.LOGGER.info("listening at " + this.context.getDataStoreConfig().getServerConfig().getPort());
|
||||
}
|
||||
}
|
||||
|
||||
public void serviceIdle(final IoService service, final IdleStatus idleStatus) throws Exception {
|
||||
}
|
||||
|
||||
public void serviceDeactivated(final IoService service) throws Exception {
|
||||
}
|
||||
|
||||
public void sessionDestroyed(final IoSession session) throws Exception {
|
||||
}
|
||||
|
||||
static {
|
||||
LOGGER = LoggerFactory.getLogger((Class)DataStoreServer.class);
|
||||
DataStoreServer.CURRENT_MESSAGE = new ThreadLocal<MongoMessage>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +1,22 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bson.BSONObject;
|
||||
import java.util.Set;
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
import com.mongodb.DBObject;
|
||||
import java.util.List;
|
||||
|
||||
public interface FileStore {
|
||||
public final static String DEFAULT_CHARSET = "UTF-8";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fileList
|
||||
* 仅包含大字段的文档列表
|
||||
* @param dbObjList
|
||||
* 已经保存到数据库的主对象列表
|
||||
* @throws IllegalArgumentException
|
||||
* 大字段数据不支持默认编码时抛出
|
||||
*/
|
||||
void save(List<DBObject> fileList, List<DBObject> dbObjList) throws DataStoreException;
|
||||
|
||||
/**
|
||||
* 删除指定的大字段内容
|
||||
*
|
||||
* @param objIdList
|
||||
* 删除的主对象的id列表
|
||||
* @param removeFields
|
||||
* 需要删除的大字段名集合
|
||||
*/
|
||||
public void remove(List<ObjectId> objIdList, Set<String> removeFields);
|
||||
|
||||
/**
|
||||
* 删除所有大字段内容
|
||||
*
|
||||
* @param objIdList
|
||||
*/
|
||||
public void remove(List<ObjectId> objIdList);
|
||||
|
||||
/**
|
||||
* @param objIdList
|
||||
* 待更新的主对象id列表
|
||||
* @param data
|
||||
* 更新文档
|
||||
* @throws UnsupportedEncodingException
|
||||
* 大字段数据不支持默认编码时抛出
|
||||
*/
|
||||
public void update(List<ObjectId> objIdList, BSONObject data) throws DataStoreException;
|
||||
|
||||
/**
|
||||
* @param docList
|
||||
* 查询的结果文档
|
||||
* @param fields
|
||||
* 查询字段对象
|
||||
* @return
|
||||
* @throws IOException
|
||||
* 读取大字段数据异常时、大字段数据不支持默认编码时抛出
|
||||
*/
|
||||
public List<DBObject> find(List<DBObject> docList, BSONObject fields) throws DataStoreException;
|
||||
public interface FileStore
|
||||
{
|
||||
public static final String DEFAULT_CHARSET = "UTF-8";
|
||||
|
||||
void save(final List<DBObject> p0, final List<DBObject> p1) throws DataStoreException;
|
||||
|
||||
void remove(final List<ObjectId> p0, final Set<String> p1);
|
||||
|
||||
void remove(final List<ObjectId> p0);
|
||||
|
||||
void update(final List<ObjectId> p0, final BSONObject p1) throws DataStoreException;
|
||||
|
||||
List<DBObject> find(final List<DBObject> p0, final BSONObject p1) throws DataStoreException;
|
||||
}
|
||||
|
||||
+219
-239
@@ -1,249 +1,229 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import com.mongodb.gridfs.GridFSDBFile;
|
||||
import java.util.HashSet;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.io.OutputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import com.mongodb.gridfs.GridFSFile;
|
||||
import java.util.Date;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import com.fangjia.datastore.config.FieldTypeEnum;
|
||||
import org.bson.BSONObject;
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
import com.fangjia.datastore.config.Field;
|
||||
import com.fangjia.datastore.config.FieldTypeEnum;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collection;
|
||||
import com.fangjia.datastore.config.Field;
|
||||
import java.util.Map;
|
||||
import com.mongodb.gridfs.GridFS;
|
||||
import com.mongodb.gridfs.GridFSDBFile;
|
||||
import com.mongodb.gridfs.GridFSFile;
|
||||
|
||||
public class FileStoreImpl implements FileStore {
|
||||
|
||||
private GridFS gridFS;
|
||||
private Map<String, Field> bigFieldSet;
|
||||
|
||||
public FileStoreImpl(GridFS gridFS, Collection<Field> fields) {
|
||||
this.gridFS = gridFS;
|
||||
|
||||
// 把大字段的字段名放入set
|
||||
bigFieldSet = new HashMap<String, Field>();
|
||||
for (Field field : fields) {
|
||||
if (field.isBigField()) {
|
||||
bigFieldSet.put(field.getName(), field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void save(List<DBObject> fileList, List<DBObject> dbObjList) {
|
||||
if (null == fileList || null == dbObjList || fileList.size() != dbObjList.size())
|
||||
throw new IllegalArgumentException("empty list or unequal length list is not allowed!");
|
||||
|
||||
Iterator<DBObject> dbObjIt = dbObjList.iterator();
|
||||
for (Iterator<DBObject> fileIt = fileList.iterator(); fileIt.hasNext();) {
|
||||
// 取得已保存主对象的id
|
||||
String id = ((ObjectId) dbObjIt.next().get("_id")).toString();
|
||||
|
||||
BSONObject file = fileIt.next();
|
||||
for (String fieldName : file.keySet()) {
|
||||
byte[] bytes = null;
|
||||
|
||||
Field field = bigFieldSet.get(fieldName);
|
||||
if (null == field) {
|
||||
continue;
|
||||
}
|
||||
FieldTypeEnum fieldType = field.getType();
|
||||
if (FieldTypeEnum.TEXT == fieldType) {
|
||||
String value = (String) file.get(fieldName);
|
||||
if (!StringUtils.isBlank(value)) {
|
||||
try {
|
||||
bytes = gzip(value);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("unsupported encoding value!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null != bytes && bytes.length > 0) {
|
||||
GridFSFile mongofile = gridFS.createFile(bytes);
|
||||
mongofile.put("uploadDate", new Date());
|
||||
mongofile.put("filename", id);
|
||||
mongofile.put("contentType", fieldName);
|
||||
mongofile.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] gzip(String string) throws IOException {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(outputStream);
|
||||
gzipOutputStream.write(string.getBytes(DEFAULT_CHARSET));
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
public void remove(List<ObjectId> objIdList) {
|
||||
remove(objIdList, null);
|
||||
}
|
||||
|
||||
public void remove(List<ObjectId> objIdList, Set<String> removeFields) {
|
||||
// 删除表的所有大字段
|
||||
if (null == removeFields)
|
||||
removeFields = bigFieldSet.keySet();
|
||||
|
||||
// 若到删除的字段中没有大字段,直接返回
|
||||
if (removeFields.size() == 0)
|
||||
return;
|
||||
|
||||
List<String> idList = new ArrayList<String>(objIdList.size());
|
||||
for (ObjectId objId : objIdList) {
|
||||
idList.add(objId.toString());
|
||||
}
|
||||
|
||||
// 删除大字段关联的GridFS
|
||||
DBObject fileSeletor = new BasicDBObject();
|
||||
fileSeletor.put("filename", new BasicDBObject("$in", idList));
|
||||
fileSeletor.put("contentType", new BasicDBObject("$in", removeFields));
|
||||
gridFS.remove(fileSeletor);
|
||||
}
|
||||
|
||||
public void update(List<ObjectId> objIdList, BSONObject data) throws DataStoreException {
|
||||
// 待删除的字段
|
||||
BSONObject unset = (BSONObject) data.get("$unset");
|
||||
if (null != unset) {
|
||||
// 待删除的大字段set
|
||||
Set<String> removeSet = new HashSet<String>();
|
||||
for (String field : unset.keySet()) {
|
||||
if (bigFieldSet.containsKey(field))
|
||||
removeSet.add(field);
|
||||
}
|
||||
|
||||
if (removeSet.size() > 0)
|
||||
remove(objIdList, removeSet);
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
BSONObject set = (BSONObject) data.get("$set");
|
||||
if (null == set)
|
||||
return;
|
||||
|
||||
Map<String, Object> fileMap = new HashMap<String, Object>();
|
||||
for (String field : set.keySet()) {
|
||||
if (bigFieldSet.containsKey(field)) {
|
||||
fileMap.put(field, set.get(field));
|
||||
}
|
||||
}
|
||||
|
||||
// 更新数据中没有大字段
|
||||
if (fileMap.size() == 0)
|
||||
return;
|
||||
|
||||
// 删除大字段关联的GridFS
|
||||
remove(objIdList, fileMap.keySet());
|
||||
|
||||
// 将新的内容存入GridFS
|
||||
for (ObjectId objId : objIdList) {
|
||||
String id = objId.toString();
|
||||
for (String fieldName : fileMap.keySet()) {
|
||||
byte[] bytes = null;
|
||||
|
||||
Field field = bigFieldSet.get(fieldName);
|
||||
if (null == field) {
|
||||
continue;
|
||||
}
|
||||
FieldTypeEnum fieldType = field.getType();
|
||||
if (FieldTypeEnum.TEXT == fieldType) {
|
||||
String value = (String) fileMap.get(fieldName);
|
||||
if (!StringUtils.isBlank(value)) {
|
||||
try {
|
||||
bytes = gzip(value);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("unsupported encoding value!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null != bytes && bytes.length > 0) {
|
||||
GridFSFile mongofile = gridFS.createFile(bytes);
|
||||
mongofile.put("uploadDate", new Date());
|
||||
mongofile.put("filename", id);
|
||||
mongofile.put("contentType", fieldName);
|
||||
mongofile.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<DBObject> find(List<DBObject> docList, BSONObject fields) throws DataStoreException {
|
||||
// 判断查询的字段中有没有大字段
|
||||
Set<String> queryBigField = new HashSet<String>();
|
||||
if (null == fields) {
|
||||
queryBigField = bigFieldSet.keySet();
|
||||
} else {
|
||||
for (String field : fields.keySet()) {
|
||||
if (bigFieldSet.containsKey(field)) {
|
||||
queryBigField.add(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 没有大字段,则返回原结果文档
|
||||
if (queryBigField.size() == 0)
|
||||
return docList;
|
||||
|
||||
Map<String, DBObject> docMap = new HashMap<String, DBObject>(docList.size());
|
||||
List<String> idList = new ArrayList<String>(docList.size());
|
||||
for (DBObject dbObj : docList) {
|
||||
ObjectId objId = (ObjectId) dbObj.get("_id");
|
||||
if (null != objId) {
|
||||
String id = objId.toString();
|
||||
idList.add(id);
|
||||
docMap.put(id, dbObj);
|
||||
}
|
||||
}
|
||||
|
||||
DBObject fileSeletor = new BasicDBObject();
|
||||
fileSeletor.put("filename", new BasicDBObject("$in", idList));
|
||||
fileSeletor.put("contentType", new BasicDBObject("$in", queryBigField));
|
||||
List<GridFSDBFile> fileList = gridFS.find(fileSeletor);
|
||||
|
||||
for (GridFSDBFile file : fileList) {
|
||||
// 对应主记录id
|
||||
String id = file.getFilename();
|
||||
// 对应主记录大字段名
|
||||
String fieldName = file.getContentType();
|
||||
|
||||
DBObject obj = docMap.get(id);
|
||||
if (obj.keySet().contains(fieldName)) {
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream data = new ByteArrayOutputStream();
|
||||
GZIPOutputStream out = new GZIPOutputStream(data);
|
||||
IOUtils.copy(file.getInputStream(), out);
|
||||
|
||||
Field field = bigFieldSet.get(fieldName);
|
||||
if (null == field) {
|
||||
continue;
|
||||
}
|
||||
FieldTypeEnum fieldType = field.getType();
|
||||
if (FieldTypeEnum.TEXT == fieldType) {
|
||||
obj.put(fieldName, new String(data.toByteArray(), DEFAULT_CHARSET));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new DataStoreException("error extract text field[" + fieldName + "]:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return docList;
|
||||
}
|
||||
public class FileStoreImpl implements FileStore
|
||||
{
|
||||
private GridFS gridFS;
|
||||
private Map<String, Field> bigFieldSet;
|
||||
|
||||
public FileStoreImpl(final GridFS gridFS, final Collection<Field> fields) {
|
||||
this.gridFS = gridFS;
|
||||
this.bigFieldSet = new HashMap<String, Field>();
|
||||
for (final Field field : fields) {
|
||||
if (field.isBigField()) {
|
||||
this.bigFieldSet.put(field.getName(), field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(final List<DBObject> fileList, final List<DBObject> dbObjList) {
|
||||
if (null == fileList || null == dbObjList || fileList.size() != dbObjList.size()) {
|
||||
throw new IllegalArgumentException("empty list or unequal length list is not allowed!");
|
||||
}
|
||||
final Iterator<DBObject> dbObjIt = dbObjList.iterator();
|
||||
final Iterator<DBObject> fileIt = fileList.iterator();
|
||||
while (fileIt.hasNext()) {
|
||||
final String id = ((ObjectId)dbObjIt.next().get("_id")).toString();
|
||||
final BSONObject file = (BSONObject)fileIt.next();
|
||||
for (final String fieldName : file.keySet()) {
|
||||
byte[] bytes = null;
|
||||
final Field field = this.bigFieldSet.get(fieldName);
|
||||
if (null == field) {
|
||||
continue;
|
||||
}
|
||||
final FieldTypeEnum fieldType = field.getType();
|
||||
if (FieldTypeEnum.TEXT == fieldType) {
|
||||
final String value = (String)file.get(fieldName);
|
||||
if (!StringUtils.isBlank(value)) {
|
||||
try {
|
||||
bytes = this.gzip(value);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalArgumentException("unsupported encoding value!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null == bytes || bytes.length <= 0) {
|
||||
continue;
|
||||
}
|
||||
final GridFSFile mongofile = (GridFSFile)this.gridFS.createFile(bytes);
|
||||
mongofile.put("uploadDate", (Object)new Date());
|
||||
mongofile.put("filename", (Object)id);
|
||||
mongofile.put("contentType", (Object)fieldName);
|
||||
mongofile.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] gzip(final String string) throws IOException {
|
||||
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
final GZIPOutputStream gzipOutputStream = new GZIPOutputStream(outputStream);
|
||||
gzipOutputStream.write(string.getBytes("UTF-8"));
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(final List<ObjectId> objIdList) {
|
||||
this.remove(objIdList, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(final List<ObjectId> objIdList, Set<String> removeFields) {
|
||||
if (null == removeFields) {
|
||||
removeFields = this.bigFieldSet.keySet();
|
||||
}
|
||||
if (removeFields.size() == 0) {
|
||||
return;
|
||||
}
|
||||
final List<String> idList = new ArrayList<String>(objIdList.size());
|
||||
for (final ObjectId objId : objIdList) {
|
||||
idList.add(objId.toString());
|
||||
}
|
||||
final DBObject fileSeletor = (DBObject)new BasicDBObject();
|
||||
fileSeletor.put("filename", (Object)new BasicDBObject("$in", (Object)idList));
|
||||
fileSeletor.put("contentType", (Object)new BasicDBObject("$in", (Object)removeFields));
|
||||
this.gridFS.remove(fileSeletor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final List<ObjectId> objIdList, final BSONObject data) throws DataStoreException {
|
||||
final BSONObject unset = (BSONObject)data.get("$unset");
|
||||
if (null != unset) {
|
||||
final Set<String> removeSet = new HashSet<String>();
|
||||
for (final String field : unset.keySet()) {
|
||||
if (this.bigFieldSet.containsKey(field)) {
|
||||
removeSet.add(field);
|
||||
}
|
||||
}
|
||||
if (removeSet.size() > 0) {
|
||||
this.remove(objIdList, removeSet);
|
||||
}
|
||||
}
|
||||
final BSONObject set = (BSONObject)data.get("$set");
|
||||
if (null == set) {
|
||||
return;
|
||||
}
|
||||
final Map<String, Object> fileMap = new HashMap<String, Object>();
|
||||
for (final String field2 : set.keySet()) {
|
||||
if (this.bigFieldSet.containsKey(field2)) {
|
||||
fileMap.put(field2, set.get(field2));
|
||||
}
|
||||
}
|
||||
if (fileMap.size() == 0) {
|
||||
return;
|
||||
}
|
||||
this.remove(objIdList, fileMap.keySet());
|
||||
for (final ObjectId objId : objIdList) {
|
||||
final String id = objId.toString();
|
||||
for (final String fieldName : fileMap.keySet()) {
|
||||
byte[] bytes = null;
|
||||
final Field field3 = this.bigFieldSet.get(fieldName);
|
||||
if (null == field3) {
|
||||
continue;
|
||||
}
|
||||
final FieldTypeEnum fieldType = field3.getType();
|
||||
if (FieldTypeEnum.TEXT == fieldType) {
|
||||
final String value = (String)fileMap.get(fieldName);
|
||||
if (!StringUtils.isBlank(value)) {
|
||||
try {
|
||||
bytes = this.gzip(value);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalArgumentException("unsupported encoding value!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null == bytes || bytes.length <= 0) {
|
||||
continue;
|
||||
}
|
||||
final GridFSFile mongofile = (GridFSFile)this.gridFS.createFile(bytes);
|
||||
mongofile.put("uploadDate", (Object)new Date());
|
||||
mongofile.put("filename", (Object)id);
|
||||
mongofile.put("contentType", (Object)fieldName);
|
||||
mongofile.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DBObject> find(final List<DBObject> docList, final BSONObject fields) throws DataStoreException {
|
||||
Set<String> queryBigField = new HashSet<String>();
|
||||
if (null == fields) {
|
||||
queryBigField = this.bigFieldSet.keySet();
|
||||
}
|
||||
else {
|
||||
for (final String field : fields.keySet()) {
|
||||
if (this.bigFieldSet.containsKey(field)) {
|
||||
queryBigField.add(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (queryBigField.size() == 0) {
|
||||
return docList;
|
||||
}
|
||||
final Map<String, DBObject> docMap = new HashMap<String, DBObject>(docList.size());
|
||||
final List<String> idList = new ArrayList<String>(docList.size());
|
||||
for (final DBObject dbObj : docList) {
|
||||
final ObjectId objId = (ObjectId)dbObj.get("_id");
|
||||
if (null != objId) {
|
||||
final String id = objId.toString();
|
||||
idList.add(id);
|
||||
docMap.put(id, dbObj);
|
||||
}
|
||||
}
|
||||
final DBObject fileSeletor = (DBObject)new BasicDBObject();
|
||||
fileSeletor.put("filename", (Object)new BasicDBObject("$in", (Object)idList));
|
||||
fileSeletor.put("contentType", (Object)new BasicDBObject("$in", (Object)queryBigField));
|
||||
final List<GridFSDBFile> fileList = (List<GridFSDBFile>)this.gridFS.find(fileSeletor);
|
||||
for (final GridFSDBFile file : fileList) {
|
||||
final String id2 = file.getFilename();
|
||||
final String fieldName = file.getContentType();
|
||||
final DBObject obj = docMap.get(id2);
|
||||
if (obj.keySet().contains(fieldName)) {
|
||||
try {
|
||||
final ByteArrayOutputStream data = new ByteArrayOutputStream();
|
||||
final GZIPOutputStream out = new GZIPOutputStream(data);
|
||||
IOUtils.copy(file.getInputStream(), (OutputStream)out);
|
||||
final Field field2 = this.bigFieldSet.get(fieldName);
|
||||
if (null == field2) {
|
||||
continue;
|
||||
}
|
||||
final FieldTypeEnum fieldType = field2.getType();
|
||||
if (FieldTypeEnum.TEXT != fieldType) {
|
||||
continue;
|
||||
}
|
||||
obj.put(fieldName, (Object)new String(data.toByteArray(), "UTF-8"));
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new DataStoreException("error extract text field[" + fieldName + "]:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return docList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.datastore.config.MongoConfig;
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.MongoException;
|
||||
import com.mongodb.WriteConcern;
|
||||
import com.mongodb.MongoException;
|
||||
import java.util.List;
|
||||
import com.mongodb.DB;
|
||||
import com.fangjia.datastore.config.MongoConfig;
|
||||
|
||||
public class Mongo {
|
||||
|
||||
private final MongoConfig mongoConfig;
|
||||
|
||||
public Mongo(MongoConfig mongoConfig) {
|
||||
this.mongoConfig = mongoConfig;
|
||||
}
|
||||
|
||||
private com.mongodb.Mongo getMongo() {
|
||||
try {
|
||||
return mongoConfig.getMongo();
|
||||
} catch (ConfigurationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public DB getDB(String dbname) {
|
||||
return getMongo().getDB(dbname);
|
||||
}
|
||||
|
||||
public List<String> getDatabaseNames() throws MongoException {
|
||||
return getMongo().getDatabaseNames();
|
||||
}
|
||||
|
||||
public void setWriteConcern(WriteConcern concern) {
|
||||
getMongo().setWriteConcern(concern);
|
||||
}
|
||||
|
||||
public WriteConcern getWriteConcern() {
|
||||
return getMongo().getWriteConcern();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getMongo().toString();
|
||||
}
|
||||
|
||||
public class Mongo
|
||||
{
|
||||
private final MongoConfig mongoConfig;
|
||||
|
||||
public Mongo(final MongoConfig mongoConfig) {
|
||||
this.mongoConfig = mongoConfig;
|
||||
}
|
||||
|
||||
private com.mongodb.Mongo getMongo() {
|
||||
try {
|
||||
return this.mongoConfig.getMongo();
|
||||
}
|
||||
catch (ConfigurationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public DB getDB(final String dbname) {
|
||||
return this.getMongo().getDB(dbname);
|
||||
}
|
||||
|
||||
public List<String> getDatabaseNames() throws MongoException {
|
||||
return (List<String>)this.getMongo().getDatabaseNames();
|
||||
}
|
||||
|
||||
public void setWriteConcern(final WriteConcern concern) {
|
||||
this.getMongo().setWriteConcern(concern);
|
||||
}
|
||||
|
||||
public WriteConcern getWriteConcern() {
|
||||
return this.getMongo().getWriteConcern();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getMongo().toString();
|
||||
}
|
||||
}
|
||||
|
||||
+114
-109
@@ -1,114 +1,119 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
import org.apache.mina.core.filterchain.IoFilterAdapter;
|
||||
import org.apache.mina.core.session.IdleStatus;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.apache.mina.core.write.WriteRequest;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import com.fangjia.datastore.utils.LoggerFactory;
|
||||
import org.apache.mina.core.session.IdleStatus;
|
||||
import org.apache.mina.core.write.WriteRequest;
|
||||
import org.apache.mina.core.filterchain.IoFilter;
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.apache.mina.core.filterchain.IoFilterAdapter;
|
||||
|
||||
public class PerformanceLogFilter extends IoFilterAdapter {
|
||||
private final long maxTime;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getPerformanceLogger(PerformanceLogFilter.class);
|
||||
|
||||
public PerformanceLogFilter(long maxTime) {
|
||||
this.maxTime = maxTime;
|
||||
}
|
||||
|
||||
private void logPerformace(long time, String methodName, IoSession session, Object message) {
|
||||
Object[] params;
|
||||
if (message instanceof MongoMessage) {
|
||||
MongoMessage mongoMessage = (MongoMessage) message;
|
||||
params = new Object[] { time, methodName, session, mongoMessage.toPrettyString() };
|
||||
} else {
|
||||
params = new Object[] { time, methodName, session, message };
|
||||
}
|
||||
if (time < maxTime * 3) {
|
||||
LOGGER.warn("time={}, methodName={}, session={}, message={}", params);
|
||||
} else {
|
||||
LOGGER.error("time={}, methodName={}, session={}, message={}", params);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.messageReceived(session, message);
|
||||
} finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= maxTime) {
|
||||
logPerformace(time, "messageReceived", session, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageSent(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.messageSent(session, writeRequest);
|
||||
} finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= maxTime) {
|
||||
logPerformace(time, "messageSent", session, writeRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sessionCreated(NextFilter nextFilter, IoSession session) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.sessionCreated(session);
|
||||
} finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= maxTime) {
|
||||
logPerformace(time, "sessionCreated", session, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.sessionOpened(session);
|
||||
} finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= maxTime) {
|
||||
logPerformace(time, "sessionOpened", session, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.sessionIdle(session, status);
|
||||
} finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= maxTime) {
|
||||
logPerformace(time, "sessionIdle", session, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.sessionClosed(session);
|
||||
} finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= maxTime) {
|
||||
logPerformace(time, "sessionClosed", session, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PerformanceLogFilter extends IoFilterAdapter
|
||||
{
|
||||
private final long maxTime;
|
||||
private static final Logger LOGGER;
|
||||
|
||||
public PerformanceLogFilter(final long maxTime) {
|
||||
this.maxTime = maxTime;
|
||||
}
|
||||
|
||||
private void logPerformace(final long time, final String methodName, final IoSession session, final Object message) {
|
||||
Object[] params;
|
||||
if (message instanceof MongoMessage) {
|
||||
final MongoMessage mongoMessage = (MongoMessage)message;
|
||||
params = new Object[] { time, methodName, session, mongoMessage.toPrettyString() };
|
||||
}
|
||||
else {
|
||||
params = new Object[] { time, methodName, session, message };
|
||||
}
|
||||
if (time < this.maxTime * 3L) {
|
||||
PerformanceLogFilter.LOGGER.warn("time={}, methodName={}, session={}, message={}", params);
|
||||
}
|
||||
else {
|
||||
PerformanceLogFilter.LOGGER.error("time={}, methodName={}, session={}, message={}", params);
|
||||
}
|
||||
}
|
||||
|
||||
public void messageReceived(final NextFilter nextFilter, final IoSession session, final Object message) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.messageReceived(session, message);
|
||||
}
|
||||
finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= this.maxTime) {
|
||||
this.logPerformace(time, "messageReceived", session, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void messageSent(final NextFilter nextFilter, final IoSession session, final WriteRequest writeRequest) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.messageSent(session, writeRequest);
|
||||
}
|
||||
finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= this.maxTime) {
|
||||
this.logPerformace(time, "messageSent", session, writeRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sessionCreated(final NextFilter nextFilter, final IoSession session) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.sessionCreated(session);
|
||||
}
|
||||
finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= this.maxTime) {
|
||||
this.logPerformace(time, "sessionCreated", session, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sessionOpened(final NextFilter nextFilter, final IoSession session) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.sessionOpened(session);
|
||||
}
|
||||
finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= this.maxTime) {
|
||||
this.logPerformace(time, "sessionOpened", session, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sessionIdle(final NextFilter nextFilter, final IoSession session, final IdleStatus status) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.sessionIdle(session, status);
|
||||
}
|
||||
finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= this.maxTime) {
|
||||
this.logPerformace(time, "sessionIdle", session, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sessionClosed(final NextFilter nextFilter, final IoSession session) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
nextFilter.sessionClosed(session);
|
||||
}
|
||||
finally {
|
||||
time = System.currentTimeMillis() - time;
|
||||
if (time >= this.maxTime) {
|
||||
this.logPerformace(time, "sessionClosed", session, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
LOGGER = LoggerFactory.getPerformanceLogger(PerformanceLogFilter.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +1,80 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
import java.util.Collections;
|
||||
import org.apache.solr.client.solrj.response.FacetField;
|
||||
import com.mongodb.DBObject;
|
||||
import org.bson.types.ObjectId;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.solr.client.solrj.response.FacetField;
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
import com.mongodb.DBObject;
|
||||
|
||||
public class QueryResponse {
|
||||
private List<ObjectId> idList = Collections.emptyList();
|
||||
private List<DBObject> docList = Collections.emptyList();
|
||||
private List<FacetField> facetFieldList = null;
|
||||
private int numFound;
|
||||
private int numReturned;
|
||||
private int numToSkip;
|
||||
public final static QueryResponse EMPTY_RESPONSE = new QueryResponse();
|
||||
|
||||
public List<ObjectId> getIdList() {
|
||||
return idList;
|
||||
}
|
||||
|
||||
public void setIdList(List<ObjectId> idList) {
|
||||
this.idList = idList;
|
||||
}
|
||||
|
||||
public boolean hasMore() {
|
||||
return this.numFound > numReturned + numToSkip;
|
||||
}
|
||||
|
||||
public int getNumFound() {
|
||||
return numFound;
|
||||
}
|
||||
|
||||
public void setNumFound(int numFound) {
|
||||
this.numFound = numFound;
|
||||
}
|
||||
|
||||
public int getNumReturned() {
|
||||
return numReturned;
|
||||
}
|
||||
|
||||
public void setNumReturned(int numReturned) {
|
||||
this.numReturned = numReturned;
|
||||
}
|
||||
|
||||
public int getNumToSkip() {
|
||||
return numToSkip;
|
||||
}
|
||||
|
||||
public void setNumToSkip(int numToSkip) {
|
||||
this.numToSkip = numToSkip;
|
||||
}
|
||||
|
||||
public List<FacetField> getFacetFieldList() {
|
||||
return facetFieldList;
|
||||
}
|
||||
|
||||
public void setFacetFieldList(List<FacetField> facetFieldList) {
|
||||
this.facetFieldList = facetFieldList;
|
||||
}
|
||||
|
||||
public List<DBObject> getDocList() {
|
||||
return docList;
|
||||
}
|
||||
|
||||
public void setDocList(List<DBObject> docList) {
|
||||
this.docList = docList;
|
||||
}
|
||||
|
||||
public class QueryResponse
|
||||
{
|
||||
private List<ObjectId> idList;
|
||||
private List<DBObject> docList;
|
||||
private List<FacetField> facetFieldList;
|
||||
private int numFound;
|
||||
private int numReturned;
|
||||
private int numToSkip;
|
||||
public static final QueryResponse EMPTY_RESPONSE;
|
||||
|
||||
public QueryResponse() {
|
||||
this.idList = Collections.<ObjectId>emptyList();
|
||||
this.docList = Collections.<DBObject>emptyList();
|
||||
this.facetFieldList = null;
|
||||
}
|
||||
|
||||
public List<ObjectId> getIdList() {
|
||||
return this.idList;
|
||||
}
|
||||
|
||||
public void setIdList(final List<ObjectId> idList) {
|
||||
this.idList = idList;
|
||||
}
|
||||
|
||||
public boolean hasMore() {
|
||||
return this.numFound > this.numReturned + this.numToSkip;
|
||||
}
|
||||
|
||||
public int getNumFound() {
|
||||
return this.numFound;
|
||||
}
|
||||
|
||||
public void setNumFound(final int numFound) {
|
||||
this.numFound = numFound;
|
||||
}
|
||||
|
||||
public int getNumReturned() {
|
||||
return this.numReturned;
|
||||
}
|
||||
|
||||
public void setNumReturned(final int numReturned) {
|
||||
this.numReturned = numReturned;
|
||||
}
|
||||
|
||||
public int getNumToSkip() {
|
||||
return this.numToSkip;
|
||||
}
|
||||
|
||||
public void setNumToSkip(final int numToSkip) {
|
||||
this.numToSkip = numToSkip;
|
||||
}
|
||||
|
||||
public List<FacetField> getFacetFieldList() {
|
||||
return this.facetFieldList;
|
||||
}
|
||||
|
||||
public void setFacetFieldList(final List<FacetField> facetFieldList) {
|
||||
this.facetFieldList = facetFieldList;
|
||||
}
|
||||
|
||||
public List<DBObject> getDocList() {
|
||||
return this.docList;
|
||||
}
|
||||
|
||||
public void setDocList(final List<DBObject> docList) {
|
||||
this.docList = docList;
|
||||
}
|
||||
|
||||
static {
|
||||
EMPTY_RESPONSE = new QueryResponse();
|
||||
}
|
||||
}
|
||||
|
||||
+18
-19
@@ -1,22 +1,21 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
public class TriggerExecuteException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -1165411196743370433L;
|
||||
|
||||
public TriggerExecuteException() {
|
||||
}
|
||||
|
||||
public TriggerExecuteException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public TriggerExecuteException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public TriggerExecuteException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public class TriggerExecuteException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = -1165411196743370433L;
|
||||
|
||||
public TriggerExecuteException() {
|
||||
}
|
||||
|
||||
public TriggerExecuteException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public TriggerExecuteException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public TriggerExecuteException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
+150
-154
@@ -1,165 +1,161 @@
|
||||
package com.fangjia.datastore;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.http.HttpRequest;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.params.AllClientPNames;
|
||||
import org.apache.http.conn.scheme.PlainSocketFactory;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import com.mongodb.DBObject;
|
||||
import org.bson.BasicBSONDecoder;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.entity.ByteArrayEntity;
|
||||
import org.sothis.core.util.GZIPUtils;
|
||||
import org.bson.BasicBSONEncoder;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import java.net.URL;
|
||||
import java.net.URISyntaxException;
|
||||
import java.io.IOException;
|
||||
import org.bson.BSONObject;
|
||||
import java.util.List;
|
||||
import com.fangjia.datastore.config.Trigger;
|
||||
import org.apache.http.params.HttpParams;
|
||||
import org.apache.http.conn.ClientConnectionManager;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
|
||||
import org.apache.http.params.BasicHttpParams;
|
||||
import org.apache.http.params.CoreProtocolPNames;
|
||||
import org.apache.http.params.HttpParams;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
import org.bson.BSONEncoder;
|
||||
import org.bson.BSONObject;
|
||||
import org.bson.BasicBSONDecoder;
|
||||
import org.apache.http.conn.scheme.SchemeSocketFactory;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.PlainSocketFactory;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.sothis.core.util.GZIPUtils;
|
||||
|
||||
import com.fangjia.datastore.config.Trigger;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
|
||||
public class TriggerExecutor {
|
||||
|
||||
private final static int MAX_TOTAL = 200;
|
||||
private final static int MAX_FOR_ROUTE = 200;
|
||||
private final static String DEFAULT_CHARSET = "UTF-8";
|
||||
private final static int DEFAULT_PORT = 80;
|
||||
private final static int MAX_RETRY_COUNT = 10;
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(TriggerExecutor.class);
|
||||
private final static TriggerExecutor TRIGGER_EXECUTOR = new TriggerExecutor();
|
||||
|
||||
private final HttpClient httpClient;
|
||||
|
||||
private TriggerExecutor() {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("init trigger executor");
|
||||
}
|
||||
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||
schemeRegistry.register(new Scheme("http", DEFAULT_PORT, new PlainSocketFactory()));
|
||||
|
||||
HttpParams httpParams = new BasicHttpParams();
|
||||
httpParams.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, DEFAULT_CHARSET);
|
||||
httpParams.setParameter(AllClientPNames.SO_TIMEOUT, 300000);
|
||||
httpParams.setParameter(AllClientPNames.CONNECTION_TIMEOUT, 60000);
|
||||
|
||||
ThreadSafeClientConnManager connManager = new ThreadSafeClientConnManager(schemeRegistry);
|
||||
connManager.setMaxTotal(MAX_TOTAL);
|
||||
connManager.setDefaultMaxPerRoute(MAX_FOR_ROUTE);
|
||||
|
||||
httpClient = new DefaultHttpClient(connManager, httpParams);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("trigger executor initialized[{}]", toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static TriggerExecutor getInstance() {
|
||||
return TRIGGER_EXECUTOR;
|
||||
}
|
||||
|
||||
public List<BSONObject> execute(Trigger trigger, List<BSONObject> docList) throws TriggerExecuteException {
|
||||
try {
|
||||
List<BSONObject> ret = doExecute(trigger, docList);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("execute trigger: " + trigger + ", doc size:" + docList.size() + ", return size:" + ret.size());
|
||||
}
|
||||
return ret;
|
||||
} catch (IOException e) {
|
||||
throw new TriggerExecuteException("error execute trigger: " + trigger, e);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new TriggerExecuteException("error execute trigger: " + trigger, e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<BSONObject> doExecute(Trigger trigger, List<BSONObject> docList) throws IOException, URISyntaxException,
|
||||
TriggerExecuteException {
|
||||
URL url = new URL(trigger.getInterface());
|
||||
HttpPost httpPost = new HttpPost(url.toURI());
|
||||
DBObject object = new BasicDBObject();
|
||||
object.put("doc_list_size", docList.size());
|
||||
object.put("doc_list", docList);
|
||||
httpPost.setEntity(new ByteArrayEntity(GZIPUtils.makeAsByteArray(new BSONEncoder().encode(object))));
|
||||
HttpHost host = new HttpHost(url.getHost(), url.getPort() == -1 ? DEFAULT_PORT : url.getPort());
|
||||
HttpResponse httpResponse = executeWithRetry(host, httpPost, null, trigger);
|
||||
InputStream inputStream = httpResponse.getEntity().getContent();
|
||||
try {
|
||||
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
|
||||
BSONObject returnObject = new BasicBSONDecoder().readObject(GZIPUtils.wrap(inputStream));
|
||||
if (null != returnObject) {
|
||||
List<BSONObject> ret = (List<BSONObject>) returnObject.get("doc_list");
|
||||
if (ret == null) {
|
||||
throw new TriggerExecuteException("trigger" + trigger + " return an null doc_list[" + ret + "]");
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
throw new TriggerExecuteException("trigger" + trigger + " returns nothing at all !");
|
||||
}
|
||||
} else {
|
||||
throw new TriggerExecuteException("error execute trigger:" + trigger + ", get http code:"
|
||||
+ httpResponse.getStatusLine().getStatusCode());
|
||||
}
|
||||
} finally {
|
||||
if (null != inputStream) {
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private HttpResponse executeWithRetry(HttpHost host, HttpPost httpPost, HttpContext httpContext, Trigger trigger)
|
||||
throws IOException, TriggerExecuteException {
|
||||
int retryCounter = 0;
|
||||
HttpResponse httpResponse = null;
|
||||
while (true) {
|
||||
try {
|
||||
httpResponse = httpClient.execute(host, httpPost, (HttpContext) null);
|
||||
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
|
||||
return httpResponse;
|
||||
} else {
|
||||
retryCounter++;
|
||||
sleepAndRetry(new IllegalStateException("invalid http status code: "
|
||||
+ httpResponse.getStatusLine().getStatusCode()), retryCounter, trigger);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
retryCounter++;
|
||||
sleepAndRetry(e, retryCounter, trigger);
|
||||
} finally {
|
||||
if (null != httpResponse && httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
|
||||
httpResponse.getEntity().getContent().close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sleepAndRetry(Exception e, int retryCounter, Trigger trigger) throws TriggerExecuteException {
|
||||
if (retryCounter > MAX_RETRY_COUNT) {
|
||||
throw new TriggerExecuteException(
|
||||
"error execute trigger[" + trigger + "] after " + MAX_RETRY_COUNT + " times retry!", e);
|
||||
}
|
||||
if (LOGGER.isErrorEnabled()) {
|
||||
LOGGER.error("error execute trigger[" + trigger + "]:(" + e.getMessage() + "), retry for the " + retryCounter
|
||||
+ "th time after " + (retryCounter * 30) + " seconds...");
|
||||
}
|
||||
try {
|
||||
Thread.sleep(retryCounter * 30000);
|
||||
} catch (InterruptedException e1) {
|
||||
if (LOGGER.isWarnEnabled()) {
|
||||
LOGGER.warn("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class TriggerExecutor
|
||||
{
|
||||
private static final int MAX_TOTAL = 200;
|
||||
private static final int MAX_FOR_ROUTE = 200;
|
||||
private static final String DEFAULT_CHARSET = "UTF-8";
|
||||
private static final int DEFAULT_PORT = 80;
|
||||
private static final int MAX_RETRY_COUNT = 10;
|
||||
private static final Logger LOGGER;
|
||||
private static final TriggerExecutor TRIGGER_EXECUTOR;
|
||||
private final HttpClient httpClient;
|
||||
|
||||
private TriggerExecutor() {
|
||||
if (TriggerExecutor.LOGGER.isDebugEnabled()) {
|
||||
TriggerExecutor.LOGGER.debug("init trigger executor");
|
||||
}
|
||||
final SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||
schemeRegistry.register(new Scheme("http", 80, (SchemeSocketFactory)new PlainSocketFactory()));
|
||||
final HttpParams httpParams = (HttpParams)new BasicHttpParams();
|
||||
httpParams.setParameter("http.protocol.content-charset", (Object)"UTF-8");
|
||||
httpParams.setParameter("http.socket.timeout", (Object)300000);
|
||||
httpParams.setParameter("http.connection.timeout", (Object)60000);
|
||||
final ThreadSafeClientConnManager connManager = new ThreadSafeClientConnManager(schemeRegistry);
|
||||
connManager.setMaxTotal(200);
|
||||
connManager.setDefaultMaxPerRoute(200);
|
||||
this.httpClient = (HttpClient)new DefaultHttpClient((ClientConnectionManager)connManager, httpParams);
|
||||
if (TriggerExecutor.LOGGER.isDebugEnabled()) {
|
||||
TriggerExecutor.LOGGER.debug("trigger executor initialized[{}]", (Object)this.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static TriggerExecutor getInstance() {
|
||||
return TriggerExecutor.TRIGGER_EXECUTOR;
|
||||
}
|
||||
|
||||
public List<BSONObject> execute(final Trigger trigger, final List<BSONObject> docList) throws TriggerExecuteException {
|
||||
try {
|
||||
final List<BSONObject> ret = this.doExecute(trigger, docList);
|
||||
if (TriggerExecutor.LOGGER.isDebugEnabled()) {
|
||||
TriggerExecutor.LOGGER.debug("execute trigger: " + trigger + ", doc size:" + docList.size() + ", return size:" + ret.size());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new TriggerExecuteException("error execute trigger: " + trigger, e);
|
||||
}
|
||||
catch (URISyntaxException e2) {
|
||||
throw new TriggerExecuteException("error execute trigger: " + trigger, e2);
|
||||
}
|
||||
}
|
||||
|
||||
private List<BSONObject> doExecute(final Trigger trigger, final List<BSONObject> docList) throws IOException, URISyntaxException, TriggerExecuteException {
|
||||
final URL url = new URL(trigger.getInterface());
|
||||
final HttpPost httpPost = new HttpPost(url.toURI());
|
||||
final DBObject object = (DBObject)new BasicDBObject();
|
||||
object.put("doc_list_size", (Object)docList.size());
|
||||
object.put("doc_list", (Object)docList);
|
||||
httpPost.setEntity((HttpEntity)new ByteArrayEntity(GZIPUtils.makeAsByteArray(new BasicBSONEncoder().encode((BSONObject)object))));
|
||||
final HttpHost host = new HttpHost(url.getHost(), (url.getPort() == -1) ? 80 : url.getPort());
|
||||
final HttpResponse httpResponse = this.executeWithRetry(host, httpPost, null, trigger);
|
||||
final InputStream inputStream = httpResponse.getEntity().getContent();
|
||||
try {
|
||||
if (httpResponse.getStatusLine().getStatusCode() != 200) {
|
||||
throw new TriggerExecuteException("error execute trigger:" + trigger + ", get http code:" + httpResponse.getStatusLine().getStatusCode());
|
||||
}
|
||||
final BSONObject returnObject = new BasicBSONDecoder().readObject(GZIPUtils.wrap(inputStream));
|
||||
if (null == returnObject) {
|
||||
throw new TriggerExecuteException("trigger" + trigger + " returns nothing at all !");
|
||||
}
|
||||
final List<BSONObject> ret = (List<BSONObject>)returnObject.get("doc_list");
|
||||
if (ret == null) {
|
||||
throw new TriggerExecuteException("trigger" + trigger + " return an null doc_list[" + ret + "]");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
finally {
|
||||
if (null != inputStream) {
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private HttpResponse executeWithRetry(final HttpHost host, final HttpPost httpPost, final HttpContext httpContext, final Trigger trigger) throws IOException, TriggerExecuteException {
|
||||
int retryCounter = 0;
|
||||
HttpResponse httpResponse = null;
|
||||
while (true) {
|
||||
try {
|
||||
httpResponse = this.httpClient.execute(host, (HttpRequest)httpPost, (HttpContext)null);
|
||||
if (httpResponse.getStatusLine().getStatusCode() == 200) {
|
||||
return httpResponse;
|
||||
}
|
||||
++retryCounter;
|
||||
this.sleepAndRetry(new IllegalStateException("invalid http status code: " + httpResponse.getStatusLine().getStatusCode()), retryCounter, trigger);
|
||||
}
|
||||
catch (Exception e) {
|
||||
++retryCounter;
|
||||
this.sleepAndRetry(e, retryCounter, trigger);
|
||||
}
|
||||
finally {
|
||||
if (null != httpResponse && httpResponse.getStatusLine().getStatusCode() != 200) {
|
||||
httpResponse.getEntity().getContent().close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sleepAndRetry(final Exception e, final int retryCounter, final Trigger trigger) throws TriggerExecuteException {
|
||||
if (retryCounter > 10) {
|
||||
throw new TriggerExecuteException("error execute trigger[" + trigger + "] after " + 10 + " times retry!", e);
|
||||
}
|
||||
if (TriggerExecutor.LOGGER.isErrorEnabled()) {
|
||||
TriggerExecutor.LOGGER.error("error execute trigger[" + trigger + "]:(" + e.getMessage() + "), retry for the " + retryCounter + "th time after " + retryCounter * 30 + " seconds...");
|
||||
}
|
||||
try {
|
||||
Thread.sleep(retryCounter * 30000);
|
||||
}
|
||||
catch (InterruptedException e2) {
|
||||
if (TriggerExecutor.LOGGER.isWarnEnabled()) {
|
||||
TriggerExecutor.LOGGER.warn("", (Throwable)e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
LOGGER = LoggerFactory.getLogger((Class)TriggerExecutor.class);
|
||||
TRIGGER_EXECUTOR = new TriggerExecutor();
|
||||
}
|
||||
}
|
||||
|
||||
+164
-162
@@ -1,170 +1,172 @@
|
||||
package com.fangjia.datastore.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
import org.dom4j.Document;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.dom4j.io.SAXReader;
|
||||
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
|
||||
public class DataStoreConfig implements Reloadable {
|
||||
private final SAXReader reader = new SAXReader();
|
||||
private final String serverConfigFile;
|
||||
private final String storeConfigFile;
|
||||
private final ServerConfig serverConfig;
|
||||
private final Map<String, StoreConfig> storeConfigs;
|
||||
private final Map<String, SolrConfig> solrConfigs;
|
||||
private final Map<String, MongoConfig> mongoConfigs;
|
||||
private boolean readOnly = false;
|
||||
|
||||
public DataStoreConfig(String datastoreHome) throws ConfigurationException {
|
||||
this.serverConfigFile = datastoreHome + "/conf/server.xml";
|
||||
this.storeConfigFile = datastoreHome + "/conf/store.xml";
|
||||
this.serverConfig = new ServerConfig();
|
||||
this.storeConfigs = new HashMap<String, StoreConfig>();
|
||||
this.solrConfigs = new HashMap<String, SolrConfig>();
|
||||
this.mongoConfigs = new HashMap<String, MongoConfig>();
|
||||
load();
|
||||
}
|
||||
|
||||
public ServerConfig getServerConfig() {
|
||||
return serverConfig;
|
||||
}
|
||||
|
||||
public SolrConfig getSolrConfigById(String id) {
|
||||
return solrConfigs.get(id);
|
||||
}
|
||||
|
||||
public MongoConfig getMongoConfigById(String id) {
|
||||
return this.mongoConfigs.get(id);
|
||||
}
|
||||
|
||||
public StoreConfig getStoreConfig(String storeName) {
|
||||
return this.storeConfigs.get(storeName);
|
||||
}
|
||||
|
||||
public Set<String> getStoreNames() {
|
||||
return Collections.unmodifiableSet(this.storeConfigs.keySet());
|
||||
}
|
||||
|
||||
public void reload() throws ConfigurationException {
|
||||
load();
|
||||
}
|
||||
|
||||
private synchronized void load() throws ConfigurationException {
|
||||
Document document = read(this.serverConfigFile);
|
||||
serverConfig.reload(document.selectSingleNode("//datastore//server"));
|
||||
initSolrConfigs(document);
|
||||
initMongoConfigs(document);
|
||||
document = read(this.storeConfigFile);
|
||||
initStoreConfigs(document, solrConfigs, mongoConfigs);
|
||||
}
|
||||
|
||||
synchronized StoreConfig getOrCreateStoreConfig(String storeName) {
|
||||
StoreConfig ret = this.storeConfigs.get(storeName);
|
||||
if (null == ret) {
|
||||
ret = new StoreConfig(this, storeName);
|
||||
storeConfigs.put(storeName, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private synchronized SolrConfig getOrCreateSolrConfig(String solrId) {
|
||||
SolrConfig ret = this.solrConfigs.get(solrId);
|
||||
if (null == ret) {
|
||||
ret = new SolrConfig(this, solrId);
|
||||
solrConfigs.put(solrId, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private synchronized MongoConfig getOrCreateMongoConfig(String mongoId) throws ConfigurationException {
|
||||
MongoConfig ret = this.mongoConfigs.get(mongoId);
|
||||
if (null == ret) {
|
||||
ret = new MongoConfig(mongoId);
|
||||
mongoConfigs.put(mongoId, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void initSolrConfigs(Document document) throws ConfigurationException {
|
||||
List<Node> solrNodes = document.selectNodes("//datastore//solr");
|
||||
if (null == solrNodes || solrNodes.isEmpty()) {
|
||||
throw new ConfigurationException("no solr is configured in " + serverConfigFile + " !");
|
||||
}
|
||||
Map<String, SolrConfig> newSolrConfigs = new HashMap<String, SolrConfig>();
|
||||
for (Node solrNode : solrNodes) {
|
||||
String id = ((Element) solrNode).attributeValue("id");
|
||||
SolrConfig config = getOrCreateSolrConfig(id);
|
||||
config.reload(solrNode);
|
||||
newSolrConfigs.put(id, config);
|
||||
}
|
||||
this.solrConfigs.clear();
|
||||
this.solrConfigs.putAll(newSolrConfigs);
|
||||
}
|
||||
|
||||
private void initMongoConfigs(Document document) throws ConfigurationException {
|
||||
List<Node> mongoNodes = document.selectNodes("//datastore//mongo");
|
||||
if (null == mongoNodes || mongoNodes.isEmpty()) {
|
||||
throw new ConfigurationException("no mongo is configured in " + serverConfigFile + " !");
|
||||
}
|
||||
Map<String, MongoConfig> newMongoConfigs = new HashMap<String, MongoConfig>();
|
||||
for (Node mongoNode : mongoNodes) {
|
||||
String id = ((Element) mongoNode).attributeValue("id");
|
||||
MongoConfig mongoConfig = getOrCreateMongoConfig(id);
|
||||
mongoConfig.reload(mongoNode);
|
||||
newMongoConfigs.put(id, mongoConfig);
|
||||
}
|
||||
this.mongoConfigs.clear();
|
||||
this.mongoConfigs.putAll(newMongoConfigs);
|
||||
}
|
||||
|
||||
private void initStoreConfigs(Document document, Map<String, SolrConfig> solrConfigMap,
|
||||
Map<String, MongoConfig> mongoConfigMap) throws ConfigurationException {
|
||||
List<Node> storeNodes = document.selectNodes("//datastore//store");
|
||||
if (null == storeNodes || storeNodes.isEmpty()) {
|
||||
throw new ConfigurationException("no store is configured in " + storeConfigFile + " !");
|
||||
}
|
||||
Map<String, StoreConfig> newStoreConfigs = new HashMap<String, StoreConfig>();
|
||||
for (Node storeNode : storeNodes) {
|
||||
String name = ((Element) storeNode).attributeValue("name");
|
||||
final StoreConfig storeConfig = getOrCreateStoreConfig(name);
|
||||
storeConfig.reload(storeNode);
|
||||
newStoreConfigs.put(name, storeConfig);
|
||||
}
|
||||
this.storeConfigs.clear();
|
||||
this.storeConfigs.putAll(newStoreConfigs);
|
||||
}
|
||||
|
||||
private Document read(String configFile) throws ConfigurationException {
|
||||
try {
|
||||
return reader.read(new File(configFile));
|
||||
} catch (DocumentException e) {
|
||||
throw new ConfigurationException("error read datastore config file: " + configFile, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.append("server config file:").append(this.serverConfigFile).append(", store config file: ").append(
|
||||
this.storeConfigFile).append(", readOnly:").append(this.readOnly);
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
this.readOnly = readOnly;
|
||||
}
|
||||
public class DataStoreConfig implements Reloadable
|
||||
{
|
||||
private final SAXReader reader;
|
||||
private final String serverConfigFile;
|
||||
private final String storeConfigFile;
|
||||
private final ServerConfig serverConfig;
|
||||
private final Map<String, StoreConfig> storeConfigs;
|
||||
private final Map<String, SolrConfig> solrConfigs;
|
||||
private final Map<String, MongoConfig> mongoConfigs;
|
||||
private boolean readOnly;
|
||||
|
||||
public DataStoreConfig(final String datastoreHome) throws ConfigurationException {
|
||||
this.reader = new SAXReader();
|
||||
this.readOnly = false;
|
||||
this.serverConfigFile = datastoreHome + "/conf/server.xml";
|
||||
this.storeConfigFile = datastoreHome + "/conf/store.xml";
|
||||
this.serverConfig = new ServerConfig();
|
||||
this.storeConfigs = new HashMap<String, StoreConfig>();
|
||||
this.solrConfigs = new HashMap<String, SolrConfig>();
|
||||
this.mongoConfigs = new HashMap<String, MongoConfig>();
|
||||
this.load();
|
||||
}
|
||||
|
||||
public ServerConfig getServerConfig() {
|
||||
return this.serverConfig;
|
||||
}
|
||||
|
||||
public SolrConfig getSolrConfigById(final String id) {
|
||||
return this.solrConfigs.get(id);
|
||||
}
|
||||
|
||||
public MongoConfig getMongoConfigById(final String id) {
|
||||
return this.mongoConfigs.get(id);
|
||||
}
|
||||
|
||||
public StoreConfig getStoreConfig(final String storeName) {
|
||||
return this.storeConfigs.get(storeName);
|
||||
}
|
||||
|
||||
public Set<String> getStoreNames() {
|
||||
return Collections.<String>unmodifiableSet((Set<? extends String>)this.storeConfigs.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() throws ConfigurationException {
|
||||
this.load();
|
||||
}
|
||||
|
||||
private synchronized void load() throws ConfigurationException {
|
||||
Document document = this.read(this.serverConfigFile);
|
||||
this.serverConfig.reload(document.selectSingleNode("//datastore//server"));
|
||||
this.initSolrConfigs(document);
|
||||
this.initMongoConfigs(document);
|
||||
document = this.read(this.storeConfigFile);
|
||||
this.initStoreConfigs(document, this.solrConfigs, this.mongoConfigs);
|
||||
}
|
||||
|
||||
synchronized StoreConfig getOrCreateStoreConfig(final String storeName) {
|
||||
StoreConfig ret = this.storeConfigs.get(storeName);
|
||||
if (null == ret) {
|
||||
ret = new StoreConfig(this, storeName);
|
||||
this.storeConfigs.put(storeName, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private synchronized SolrConfig getOrCreateSolrConfig(final String solrId) {
|
||||
SolrConfig ret = this.solrConfigs.get(solrId);
|
||||
if (null == ret) {
|
||||
ret = new SolrConfig(this, solrId);
|
||||
this.solrConfigs.put(solrId, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private synchronized MongoConfig getOrCreateMongoConfig(final String mongoId) throws ConfigurationException {
|
||||
MongoConfig ret = this.mongoConfigs.get(mongoId);
|
||||
if (null == ret) {
|
||||
ret = new MongoConfig(mongoId);
|
||||
this.mongoConfigs.put(mongoId, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void initSolrConfigs(final Document document) throws ConfigurationException {
|
||||
final List<Node> solrNodes = (List<Node>)document.selectNodes("//datastore//solr");
|
||||
if (null == solrNodes || solrNodes.isEmpty()) {
|
||||
throw new ConfigurationException("no solr is configured in " + this.serverConfigFile + " !");
|
||||
}
|
||||
final Map<String, SolrConfig> newSolrConfigs = new HashMap<String, SolrConfig>();
|
||||
for (final Node solrNode : solrNodes) {
|
||||
final String id = ((Element)solrNode).attributeValue("id");
|
||||
final SolrConfig config = this.getOrCreateSolrConfig(id);
|
||||
config.reload(solrNode);
|
||||
newSolrConfigs.put(id, config);
|
||||
}
|
||||
this.solrConfigs.clear();
|
||||
this.solrConfigs.putAll(newSolrConfigs);
|
||||
}
|
||||
|
||||
private void initMongoConfigs(final Document document) throws ConfigurationException {
|
||||
final List<Node> mongoNodes = (List<Node>)document.selectNodes("//datastore//mongo");
|
||||
if (null == mongoNodes || mongoNodes.isEmpty()) {
|
||||
throw new ConfigurationException("no mongo is configured in " + this.serverConfigFile + " !");
|
||||
}
|
||||
final Map<String, MongoConfig> newMongoConfigs = new HashMap<String, MongoConfig>();
|
||||
for (final Node mongoNode : mongoNodes) {
|
||||
final String id = ((Element)mongoNode).attributeValue("id");
|
||||
final MongoConfig mongoConfig = this.getOrCreateMongoConfig(id);
|
||||
mongoConfig.reload(mongoNode);
|
||||
newMongoConfigs.put(id, mongoConfig);
|
||||
}
|
||||
this.mongoConfigs.clear();
|
||||
this.mongoConfigs.putAll(newMongoConfigs);
|
||||
}
|
||||
|
||||
private void initStoreConfigs(final Document document, final Map<String, SolrConfig> solrConfigMap, final Map<String, MongoConfig> mongoConfigMap) throws ConfigurationException {
|
||||
final List<Node> storeNodes = (List<Node>)document.selectNodes("//datastore//store");
|
||||
if (null == storeNodes || storeNodes.isEmpty()) {
|
||||
throw new ConfigurationException("no store is configured in " + this.storeConfigFile + " !");
|
||||
}
|
||||
final Map<String, StoreConfig> newStoreConfigs = new HashMap<String, StoreConfig>();
|
||||
for (final Node storeNode : storeNodes) {
|
||||
final String name = ((Element)storeNode).attributeValue("name");
|
||||
final StoreConfig storeConfig = this.getOrCreateStoreConfig(name);
|
||||
storeConfig.reload(storeNode);
|
||||
newStoreConfigs.put(name, storeConfig);
|
||||
}
|
||||
this.storeConfigs.clear();
|
||||
this.storeConfigs.putAll(newStoreConfigs);
|
||||
}
|
||||
|
||||
private Document read(final String configFile) throws ConfigurationException {
|
||||
try {
|
||||
return this.reader.read(new File(configFile));
|
||||
}
|
||||
catch (DocumentException e) {
|
||||
throw new ConfigurationException("error read datastore config file: " + configFile, (Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder ret = new StringBuilder();
|
||||
ret.append("server config file:").append(this.serverConfigFile).append(", store config file: ").append(this.storeConfigFile).append(", readOnly:").append(this.readOnly);
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return this.readOnly;
|
||||
}
|
||||
|
||||
public void setReadOnly(final boolean readOnly) {
|
||||
this.readOnly = readOnly;
|
||||
}
|
||||
}
|
||||
|
||||
+111
-120
@@ -1,127 +1,118 @@
|
||||
package com.fangjia.datastore.config;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.bson.types.ObjectId;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
public class Field {
|
||||
private String name;
|
||||
private FieldTypeEnum type;
|
||||
private boolean required;
|
||||
|
||||
Field() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public FieldTypeEnum getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
void setName(String name) {
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
throw new IllegalArgumentException("invalid field name:" + name);
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
void setType(FieldTypeEnum type) {
|
||||
if (null == type) {
|
||||
throw new IllegalArgumentException("invalid type of field[" + name + "]:" + type);
|
||||
}
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean isRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
void setRequired(boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public boolean isBigField() {
|
||||
return this.type == FieldTypeEnum.TEXT;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证一个值是否匹配其对应的类型
|
||||
*
|
||||
* @param value
|
||||
* @return 匹配则返回true,不匹配返回false
|
||||
*/
|
||||
public boolean validate(Object value) {
|
||||
if (this.required && value == null) {
|
||||
return false;
|
||||
}
|
||||
if (value == null) {
|
||||
return true;
|
||||
}
|
||||
Class<?> valueClass = value.getClass();
|
||||
switch (this.type) {
|
||||
case BOOLEAN:
|
||||
return valueClass == boolean.class || valueClass == Boolean.class;
|
||||
case BYTE:
|
||||
return valueClass == byte.class || valueClass == Byte.class;
|
||||
case INTEGER:
|
||||
return valueClass == int.class || valueClass == Integer.class;
|
||||
case LONG:
|
||||
return valueClass == long.class || valueClass == Long.class;
|
||||
case DOUBLE:
|
||||
return valueClass == double.class || valueClass == Double.class;
|
||||
case STRING:
|
||||
case TEXT:
|
||||
return valueClass == String.class;
|
||||
case LIST:
|
||||
return value instanceof List;
|
||||
case MAP:
|
||||
return value instanceof Map;
|
||||
case DATETIME:
|
||||
return value instanceof Date;
|
||||
case BINARY:
|
||||
return valueClass == byte[].class;
|
||||
case REGEXP:
|
||||
return valueClass == Pattern.class;
|
||||
case OBJECTID:
|
||||
return valueClass == ObjectId.class;
|
||||
default:
|
||||
throw new RuntimeException("un cased type:" + this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(this.name).append(this.type).append(this.required).toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (null == obj) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof Field)) {
|
||||
return false;
|
||||
}
|
||||
Field other = (Field) obj;
|
||||
return new EqualsBuilder().append(this.name, other.name).append(this.type, other.type)
|
||||
.append(this.required, other.required).isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder().append("{field:").append(name).append(", type:").append(type).append(", required:")
|
||||
.append(required).append("}").toString();
|
||||
}
|
||||
|
||||
public class Field
|
||||
{
|
||||
private String name;
|
||||
private FieldTypeEnum type;
|
||||
private boolean required;
|
||||
|
||||
Field() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public FieldTypeEnum getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
void setName(final String name) {
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
throw new IllegalArgumentException("invalid field name:" + name);
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
void setType(final FieldTypeEnum type) {
|
||||
if (null == type) {
|
||||
throw new IllegalArgumentException("invalid type of field[" + this.name + "]:" + type);
|
||||
}
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean isRequired() {
|
||||
return this.required;
|
||||
}
|
||||
|
||||
void setRequired(final boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public boolean isBigField() {
|
||||
return this.type == FieldTypeEnum.TEXT;
|
||||
}
|
||||
|
||||
public boolean validate(final Object value) {
|
||||
if (this.required && value == null) {
|
||||
return false;
|
||||
}
|
||||
if (value == null) {
|
||||
return true;
|
||||
}
|
||||
final Class<?> valueClass = value.getClass();
|
||||
switch (this.type) {
|
||||
case BOOLEAN:
|
||||
return valueClass == Boolean.TYPE || valueClass == Boolean.class;
|
||||
case BYTE:
|
||||
return valueClass == Byte.TYPE || valueClass == Byte.class;
|
||||
case INTEGER:
|
||||
return valueClass == Integer.TYPE || valueClass == Integer.class;
|
||||
case LONG:
|
||||
return valueClass == Long.TYPE || valueClass == Long.class;
|
||||
case DOUBLE:
|
||||
return valueClass == Double.TYPE || valueClass == Double.class;
|
||||
case STRING:
|
||||
case TEXT:
|
||||
return valueClass == String.class;
|
||||
case LIST:
|
||||
return value instanceof List;
|
||||
case MAP:
|
||||
return value instanceof Map;
|
||||
case DATETIME:
|
||||
return value instanceof Date;
|
||||
case BINARY:
|
||||
return valueClass == byte[].class;
|
||||
case REGEXP:
|
||||
return valueClass == Pattern.class;
|
||||
case OBJECTID:
|
||||
return valueClass == ObjectId.class;
|
||||
default:
|
||||
throw new RuntimeException("un cased type:" + this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append((Object)this.name).append((Object)this.type).append(this.required).toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (null == obj) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof Field)) {
|
||||
return false;
|
||||
}
|
||||
final Field other = (Field)obj;
|
||||
return new EqualsBuilder().append((Object)this.name, (Object)other.name).append((Object)this.type, (Object)other.type).append(this.required, other.required).isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{field:" + this.name + ", type:" + this.type + ", required:" + this.required + "}";
|
||||
}
|
||||
}
|
||||
|
||||
+28
-19
@@ -1,22 +1,31 @@
|
||||
package com.fangjia.datastore.config;
|
||||
|
||||
public enum FieldTypeEnum {
|
||||
BOOLEAN, BYTE, INTEGER, LONG, DOUBLE, STRING, TEXT, LIST, MAP, DATETIME, BINARY, REGEXP, OBJECTID;
|
||||
|
||||
private FieldTypeEnum() {
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
public static FieldTypeEnum parse(String type) {
|
||||
for (FieldTypeEnum typeEnum : FieldTypeEnum.values()) {
|
||||
if (typeEnum.name().toLowerCase().equals(type)) {
|
||||
return typeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public enum FieldTypeEnum
|
||||
{
|
||||
BOOLEAN,
|
||||
BYTE,
|
||||
INTEGER,
|
||||
LONG,
|
||||
DOUBLE,
|
||||
STRING,
|
||||
TEXT,
|
||||
LIST,
|
||||
MAP,
|
||||
DATETIME,
|
||||
BINARY,
|
||||
REGEXP,
|
||||
OBJECTID;
|
||||
|
||||
public String getType() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
public static FieldTypeEnum parse(final String type) {
|
||||
for (final FieldTypeEnum typeEnum : values()) {
|
||||
if (typeEnum.name().toLowerCase().equals(type)) {
|
||||
return typeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+91
-80
@@ -2,87 +2,98 @@ package com.fangjia.datastore.config;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.dom4j.Node;
|
||||
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
import com.fangjia.datastore.utils.XmlUtils;
|
||||
import org.dom4j.Node;
|
||||
import com.mongodb.MongoURI;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
import com.mongodb.Mongo;
|
||||
|
||||
public final class MongoConfig {
|
||||
|
||||
private String host;
|
||||
private int port;
|
||||
private final String id;
|
||||
private Mongo mongo;
|
||||
|
||||
MongoConfig(String id) throws ConfigurationException {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
private synchronized void init() throws ConfigurationException {
|
||||
if (null == mongo) {
|
||||
try {
|
||||
mongo = new Mongo(host, port);
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException("error init mongo[" + host + ":" + port, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Mongo getMongo() throws ConfigurationException {
|
||||
if (null == mongo) {
|
||||
init();
|
||||
}
|
||||
return mongo;
|
||||
}
|
||||
|
||||
synchronized void reload(Node mongoNode) throws ConfigurationException {
|
||||
String host = XmlUtils.getNodeValue(mongoNode, "host", "datastore.mongo.db.fangjia.com");
|
||||
int port = XmlUtils.getNodeValueAsInt(mongoNode, "port", 27017);
|
||||
if (host.equals(this.host) && this.port == port) {
|
||||
return;
|
||||
}
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
if (null != mongo) {
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException("error init mongo[" + host + ":" + port, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(this.host).append(this.port).append(this.id).toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (null == obj) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof MongoConfig)) {
|
||||
return false;
|
||||
}
|
||||
MongoConfig other = (MongoConfig) obj;
|
||||
return new EqualsBuilder().append(this.id, other.id).append(this.host, other.host).append(this.port, other.port)
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.append('{');
|
||||
ret.append("id:").append(this.id);
|
||||
ret.append(", host:").append(this.host);
|
||||
ret.append(", port:").append(this.port);
|
||||
ret.append('}');
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public final class MongoConfig
|
||||
{
|
||||
private String host;
|
||||
private String uri;
|
||||
private int port;
|
||||
private final String id;
|
||||
private Mongo mongo;
|
||||
|
||||
MongoConfig(final String id) throws ConfigurationException {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
private synchronized void init() throws ConfigurationException {
|
||||
if (null == this.mongo) {
|
||||
try {
|
||||
MongoURI mongoURI;
|
||||
if (StringUtils.isNotBlank(this.uri)) {
|
||||
mongoURI = new MongoURI(this.uri);
|
||||
}
|
||||
else {
|
||||
mongoURI = new MongoURI("mongodb://" + this.host + ":" + this.port);
|
||||
}
|
||||
this.mongo = new Mongo(mongoURI);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ConfigurationException("error init mongo[" + this.host + ":" + this.port, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Mongo getMongo() throws ConfigurationException {
|
||||
if (null == this.mongo) {
|
||||
this.init();
|
||||
}
|
||||
return this.mongo;
|
||||
}
|
||||
|
||||
synchronized void reload(final Node mongoNode) throws ConfigurationException {
|
||||
final String host = XmlUtils.getNodeValue(mongoNode, "host", "datastore.mongo.db.fangjia.com");
|
||||
final int port = XmlUtils.getNodeValueAsInt(mongoNode, "port", 27017);
|
||||
final String uri = XmlUtils.getNodeValue(mongoNode, "uri", "");
|
||||
if (host.equals(this.host) && this.port == port) {
|
||||
return;
|
||||
}
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.uri = uri;
|
||||
if (null != this.mongo) {
|
||||
try {
|
||||
this.init();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ConfigurationException("error init mongo[" + host + ":" + port, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append((Object)this.host).append(this.port).append((Object)this.id).toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (null == obj) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof MongoConfig)) {
|
||||
return false;
|
||||
}
|
||||
final MongoConfig other = (MongoConfig)obj;
|
||||
return new EqualsBuilder().append((Object)this.id, (Object)other.id).append((Object)this.host, (Object)other.host).append(this.port, other.port).isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder ret = new StringBuilder();
|
||||
ret.append('{');
|
||||
ret.append("id:").append(this.id);
|
||||
ret.append(", host:").append(this.host);
|
||||
ret.append(", port:").append(this.port);
|
||||
ret.append('}');
|
||||
return ret.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ package com.fangjia.datastore.config;
|
||||
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
|
||||
public interface Reloadable {
|
||||
void reload() throws ConfigurationException;
|
||||
public interface Reloadable
|
||||
{
|
||||
void reload() throws ConfigurationException;
|
||||
}
|
||||
|
||||
+67
-69
@@ -1,74 +1,72 @@
|
||||
package com.fangjia.datastore.config;
|
||||
|
||||
import com.fangjia.datastore.utils.XmlUtils;
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
import org.dom4j.Node;
|
||||
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
import com.fangjia.datastore.utils.XmlUtils;
|
||||
|
||||
public final class ServerConfig {
|
||||
private int port;
|
||||
private boolean disableLogging;
|
||||
private long performanceLogFilterMaxTime;
|
||||
private int minaReadBufferSize;
|
||||
private int cursorExpirationMinutes;
|
||||
private int defaultCursorLimit;
|
||||
private int maxConnections;
|
||||
private int triggerBatchSize;
|
||||
private int reIndexBatchSize;
|
||||
|
||||
ServerConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
void reload(Node server) throws ConfigurationException {
|
||||
if (null == server) {
|
||||
throw new ConfigurationException("no server is configured!");
|
||||
}
|
||||
this.port = XmlUtils.getNodeValueAsInt(server, "port", 27017);
|
||||
this.disableLogging = XmlUtils.getNodeValueAsBoolean(server, "disableLogging", false);
|
||||
this.performanceLogFilterMaxTime = XmlUtils.getNodeValueAsLong(server, "performanceLogFilterMaxTime", 1000);
|
||||
this.minaReadBufferSize = XmlUtils.getNodeValueAsInt(server, "minaReadBufferSize", 20480);
|
||||
this.cursorExpirationMinutes = XmlUtils.getNodeValueAsInt(server, "cursorExpirationMinutes", 5);
|
||||
this.defaultCursorLimit = XmlUtils.getNodeValueAsInt(server, "defaultCursorLimit", 20);
|
||||
this.maxConnections = XmlUtils.getNodeValueAsInt(server, "maxConnections", 10);
|
||||
this.triggerBatchSize = XmlUtils.getNodeValueAsInt(server, "triggerBatchSize", 200);
|
||||
this.reIndexBatchSize = XmlUtils.getNodeValueAsInt(server, "reIndexBatchSize", 200);
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public boolean isDisableLogging() {
|
||||
return disableLogging;
|
||||
}
|
||||
|
||||
public long getPerformanceLogFilterMaxTime() {
|
||||
return performanceLogFilterMaxTime;
|
||||
}
|
||||
|
||||
public int getMinaReadBufferSize() {
|
||||
return minaReadBufferSize;
|
||||
}
|
||||
|
||||
public int getCursorExpirationMinutes() {
|
||||
return cursorExpirationMinutes;
|
||||
}
|
||||
|
||||
public int getDefaultCursorLimit() {
|
||||
return defaultCursorLimit;
|
||||
}
|
||||
|
||||
public int getMaxConnections() {
|
||||
return maxConnections;
|
||||
}
|
||||
|
||||
public int getTriggerBatchSize() {
|
||||
return triggerBatchSize;
|
||||
}
|
||||
|
||||
public int getReIndexBatchSize() {
|
||||
return reIndexBatchSize;
|
||||
}
|
||||
|
||||
public final class ServerConfig
|
||||
{
|
||||
private int port;
|
||||
private boolean disableLogging;
|
||||
private long performanceLogFilterMaxTime;
|
||||
private int minaReadBufferSize;
|
||||
private int cursorExpirationMinutes;
|
||||
private int defaultCursorLimit;
|
||||
private int maxConnections;
|
||||
private int triggerBatchSize;
|
||||
private int reIndexBatchSize;
|
||||
|
||||
ServerConfig() {
|
||||
}
|
||||
|
||||
void reload(final Node server) throws ConfigurationException {
|
||||
if (null == server) {
|
||||
throw new ConfigurationException("no server is configured!");
|
||||
}
|
||||
this.port = XmlUtils.getNodeValueAsInt(server, "port", 27017);
|
||||
this.disableLogging = XmlUtils.getNodeValueAsBoolean(server, "disableLogging", false);
|
||||
this.performanceLogFilterMaxTime = XmlUtils.getNodeValueAsLong(server, "performanceLogFilterMaxTime", 1000L);
|
||||
this.minaReadBufferSize = XmlUtils.getNodeValueAsInt(server, "minaReadBufferSize", 20480);
|
||||
this.cursorExpirationMinutes = XmlUtils.getNodeValueAsInt(server, "cursorExpirationMinutes", 5);
|
||||
this.defaultCursorLimit = XmlUtils.getNodeValueAsInt(server, "defaultCursorLimit", 20);
|
||||
this.maxConnections = XmlUtils.getNodeValueAsInt(server, "maxConnections", 10);
|
||||
this.triggerBatchSize = XmlUtils.getNodeValueAsInt(server, "triggerBatchSize", 200);
|
||||
this.reIndexBatchSize = XmlUtils.getNodeValueAsInt(server, "reIndexBatchSize", 200);
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
public boolean isDisableLogging() {
|
||||
return this.disableLogging;
|
||||
}
|
||||
|
||||
public long getPerformanceLogFilterMaxTime() {
|
||||
return this.performanceLogFilterMaxTime;
|
||||
}
|
||||
|
||||
public int getMinaReadBufferSize() {
|
||||
return this.minaReadBufferSize;
|
||||
}
|
||||
|
||||
public int getCursorExpirationMinutes() {
|
||||
return this.cursorExpirationMinutes;
|
||||
}
|
||||
|
||||
public int getDefaultCursorLimit() {
|
||||
return this.defaultCursorLimit;
|
||||
}
|
||||
|
||||
public int getMaxConnections() {
|
||||
return this.maxConnections;
|
||||
}
|
||||
|
||||
public int getTriggerBatchSize() {
|
||||
return this.triggerBatchSize;
|
||||
}
|
||||
|
||||
public int getReIndexBatchSize() {
|
||||
return this.reIndexBatchSize;
|
||||
}
|
||||
}
|
||||
|
||||
+126
-126
@@ -1,132 +1,132 @@
|
||||
package com.fangjia.datastore.config;
|
||||
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import com.fangjia.datastore.utils.XmlUtils;
|
||||
import org.dom4j.Node;
|
||||
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
import com.fangjia.datastore.utils.XmlUtils;
|
||||
|
||||
public class SolrConfig {
|
||||
private final String id;
|
||||
private String host;
|
||||
private String home;
|
||||
private final DataStoreConfig dataStoreConfig;
|
||||
private String shards;
|
||||
private String slaves;
|
||||
private SolrConfig[] shardConfigs;
|
||||
private SolrConfig[] slaveConfigs;
|
||||
private String filter;
|
||||
|
||||
SolrConfig(DataStoreConfig dataStoreConfig, String id) {
|
||||
this.dataStoreConfig = dataStoreConfig;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
synchronized void reload(Node solrNode) throws ConfigurationException {
|
||||
this.host = removeLastSlash(XmlUtils.getNodeValue(solrNode, "host", null));
|
||||
this.shards = XmlUtils.getNodeValue(solrNode, "shards", null);
|
||||
this.slaves = XmlUtils.getNodeValue(solrNode, "slaves", null);
|
||||
this.home = XmlUtils.getNodeValue(solrNode, "home", null);
|
||||
if (StringUtils.isNotEmpty(shards) && StringUtils.isEmpty(home)) {
|
||||
throw new ConfigurationException("[" + id + "] invalid home attribute:" + home);
|
||||
}
|
||||
if (StringUtils.isEmpty(shards) && StringUtils.isEmpty(slaves) && StringUtils.isEmpty(host)) {
|
||||
throw new ConfigurationException("[" + id + "] invalid host attribute:" + host);
|
||||
}
|
||||
this.filter = removeLastSlash(XmlUtils.getNodeValue(solrNode, "filter", null));
|
||||
}
|
||||
|
||||
private SolrConfig[] getConfigs(String ids) {
|
||||
SolrConfig[] ret;
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
ret = new SolrConfig[0];
|
||||
} else {
|
||||
String[] idSplit = ids.split(",");
|
||||
ret = new SolrConfig[idSplit.length];
|
||||
for (int i = 0; i < idSplit.length; i++) {
|
||||
ret[i] = dataStoreConfig.getSolrConfigById(idSplit[i]);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public SolrConfig[] getShardsConfigs() {
|
||||
if (null == shardConfigs) {
|
||||
shardConfigs = this.getConfigs(shards);
|
||||
}
|
||||
return shardConfigs;
|
||||
}
|
||||
|
||||
public SolrConfig[] getSlaveConfigs() {
|
||||
if (null == slaveConfigs) {
|
||||
slaveConfigs = this.getConfigs(slaves);
|
||||
}
|
||||
return slaveConfigs;
|
||||
}
|
||||
|
||||
private String removeLastSlash(String s) {
|
||||
if (StringUtils.isEmpty(s)) {
|
||||
return s;
|
||||
}
|
||||
if (s.charAt(s.length() - 1) == '/') {
|
||||
return s.substring(0, s.length() - 1);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getShardsParam(String coreName) {
|
||||
SolrConfig[] shardConfigs = getShardsConfigs();
|
||||
if (shardConfigs.length == 0) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder ret = new StringBuilder();
|
||||
for (int i = 0; i < shardConfigs.length; i++) {
|
||||
ret.append(shardConfigs[i].host).append('/').append(coreName);
|
||||
if (i < shardConfigs.length - 1) {
|
||||
ret.append(',');
|
||||
}
|
||||
}
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public DataStoreConfig getDataStoreConfig() {
|
||||
return dataStoreConfig;
|
||||
}
|
||||
|
||||
public String getShards() {
|
||||
return shards;
|
||||
}
|
||||
|
||||
public String getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public String getHome() {
|
||||
return home;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.append('{');
|
||||
ret.append("id: ").append(this.id);
|
||||
ret.append(", host: ").append(this.host);
|
||||
ret.append(", shards: ").append(this.shards);
|
||||
ret.append(", slaves: ").append(this.slaves);
|
||||
ret.append('}');
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public String getSlaves() {
|
||||
return slaves;
|
||||
}
|
||||
|
||||
public class SolrConfig
|
||||
{
|
||||
private final String id;
|
||||
private String host;
|
||||
private String home;
|
||||
private final DataStoreConfig dataStoreConfig;
|
||||
private String shards;
|
||||
private String slaves;
|
||||
private SolrConfig[] shardConfigs;
|
||||
private SolrConfig[] slaveConfigs;
|
||||
private String filter;
|
||||
|
||||
SolrConfig(final DataStoreConfig dataStoreConfig, final String id) {
|
||||
this.dataStoreConfig = dataStoreConfig;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
synchronized void reload(final Node solrNode) throws ConfigurationException {
|
||||
this.host = this.removeLastSlash(XmlUtils.getNodeValue(solrNode, "host", null));
|
||||
this.shards = XmlUtils.getNodeValue(solrNode, "shards", null);
|
||||
this.slaves = XmlUtils.getNodeValue(solrNode, "slaves", null);
|
||||
this.home = XmlUtils.getNodeValue(solrNode, "home", null);
|
||||
if (StringUtils.isNotEmpty(this.shards) && StringUtils.isEmpty(this.home)) {
|
||||
throw new ConfigurationException("[" + this.id + "] invalid home attribute:" + this.home);
|
||||
}
|
||||
if (StringUtils.isEmpty(this.shards) && StringUtils.isEmpty(this.slaves) && StringUtils.isEmpty(this.host)) {
|
||||
throw new ConfigurationException("[" + this.id + "] invalid host attribute:" + this.host);
|
||||
}
|
||||
this.filter = this.removeLastSlash(XmlUtils.getNodeValue(solrNode, "filter", null));
|
||||
}
|
||||
|
||||
private SolrConfig[] getConfigs(final String ids) {
|
||||
SolrConfig[] ret;
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
ret = new SolrConfig[0];
|
||||
}
|
||||
else {
|
||||
final String[] idSplit = ids.split(",");
|
||||
ret = new SolrConfig[idSplit.length];
|
||||
for (int i = 0; i < idSplit.length; ++i) {
|
||||
ret[i] = this.dataStoreConfig.getSolrConfigById(idSplit[i]);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public SolrConfig[] getShardsConfigs() {
|
||||
if (null == this.shardConfigs) {
|
||||
this.shardConfigs = this.getConfigs(this.shards);
|
||||
}
|
||||
return this.shardConfigs;
|
||||
}
|
||||
|
||||
public SolrConfig[] getSlaveConfigs() {
|
||||
if (null == this.slaveConfigs) {
|
||||
this.slaveConfigs = this.getConfigs(this.slaves);
|
||||
}
|
||||
return this.slaveConfigs;
|
||||
}
|
||||
|
||||
private String removeLastSlash(final String s) {
|
||||
if (StringUtils.isEmpty(s)) {
|
||||
return s;
|
||||
}
|
||||
if (s.charAt(s.length() - 1) == '/') {
|
||||
return s.substring(0, s.length() - 1);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getShardsParam(final String coreName) {
|
||||
final SolrConfig[] shardConfigs = this.getShardsConfigs();
|
||||
if (shardConfigs.length == 0) {
|
||||
return "";
|
||||
}
|
||||
final StringBuilder ret = new StringBuilder();
|
||||
for (int i = 0; i < shardConfigs.length; ++i) {
|
||||
ret.append(shardConfigs[i].host).append('/').append(coreName);
|
||||
if (i < shardConfigs.length - 1) {
|
||||
ret.append(',');
|
||||
}
|
||||
}
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
public DataStoreConfig getDataStoreConfig() {
|
||||
return this.dataStoreConfig;
|
||||
}
|
||||
|
||||
public String getShards() {
|
||||
return this.shards;
|
||||
}
|
||||
|
||||
public String getFilter() {
|
||||
return this.filter;
|
||||
}
|
||||
|
||||
public String getHome() {
|
||||
return this.home;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder ret = new StringBuilder();
|
||||
ret.append('{');
|
||||
ret.append("id: ").append(this.id);
|
||||
ret.append(", host: ").append(this.host);
|
||||
ret.append(", shards: ").append(this.shards);
|
||||
ret.append(", slaves: ").append(this.slaves);
|
||||
ret.append('}');
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public String getSlaves() {
|
||||
return this.slaves;
|
||||
}
|
||||
}
|
||||
|
||||
+200
-221
@@ -1,229 +1,208 @@
|
||||
package com.fangjia.datastore.config;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import java.util.Collection;
|
||||
import org.bson.types.ObjectId;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import com.fangjia.datastore.utils.XmlUtils;
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
import com.fangjia.datastore.utils.XmlUtils;
|
||||
|
||||
public final class StoreConfig {
|
||||
|
||||
private final String name;
|
||||
private int solrMaxTotalConnections;
|
||||
private int solrMaxConnectionsPerHost;
|
||||
private SolrConfig[] masterSolrConfigs;
|
||||
private SolrConfig masterSolrConfig;
|
||||
private SolrConfig slaveSolrConfig;
|
||||
private MongoConfig mongoConfig;
|
||||
private boolean textFieldToGridFS;
|
||||
private final Trigger trigger;
|
||||
private final Map<String, Field> fields;
|
||||
private final DataStoreConfig dataStoreConfig;
|
||||
|
||||
StoreConfig(DataStoreConfig dataStoreConfig, String name) {
|
||||
this.dataStoreConfig = dataStoreConfig;
|
||||
fields = new HashMap<String, Field>();
|
||||
trigger = new Trigger();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
synchronized void reload(Node storeNode) throws ConfigurationException {
|
||||
// init solr
|
||||
String solrMastersAttr = ((Element) storeNode).attributeValue("solrMasters");
|
||||
if (StringUtils.isEmpty(solrMastersAttr)) {
|
||||
throw new ConfigurationException("[" + name + "] invalid solrMasters attribute:" + solrMastersAttr);
|
||||
}
|
||||
String[] solrMasterIds = solrMastersAttr.split(",");
|
||||
if (solrMasterIds.length > 2) {
|
||||
throw new ConfigurationException("[" + name + "] too many solr server configured:" + solrMastersAttr);
|
||||
}
|
||||
masterSolrConfigs = new SolrConfig[solrMasterIds.length];
|
||||
for (int i = 0; i < solrMasterIds.length; i++) {
|
||||
masterSolrConfigs[i] = dataStoreConfig.getSolrConfigById(solrMasterIds[i]);
|
||||
if (null == masterSolrConfigs[i]) {
|
||||
throw new ConfigurationException("[" + name + "] unknown solr id: " + solrMasterIds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
String solrSlaveAttr = System.getProperty("datastore." + name + ".solrSlave", ((Element) storeNode)
|
||||
.attributeValue("solrSlave"));
|
||||
if (StringUtils.isEmpty(solrSlaveAttr)) {
|
||||
throw new ConfigurationException("[" + name + "] invalid solrSlave attribute:" + solrSlaveAttr);
|
||||
}
|
||||
slaveSolrConfig = dataStoreConfig.getSolrConfigById(solrSlaveAttr);
|
||||
if (null == slaveSolrConfig) {
|
||||
throw new ConfigurationException("[" + name + "] unknown solr id: " + solrSlaveAttr);
|
||||
}
|
||||
|
||||
String solrMasterAttr = System.getProperty("datastore." + name + ".solrMaster", ((Element) storeNode)
|
||||
.attributeValue("solrMaster"));
|
||||
if (StringUtils.isEmpty(solrMasterAttr)) {
|
||||
throw new ConfigurationException("[" + name + "] invalid solrMaster attribute:" + solrMasterAttr);
|
||||
}
|
||||
masterSolrConfig = dataStoreConfig.getSolrConfigById(solrMasterAttr);
|
||||
if (null == masterSolrConfig) {
|
||||
throw new ConfigurationException("[" + name + "] unknown solr id: " + solrMasterAttr);
|
||||
}
|
||||
|
||||
if (slaveSolrConfig.getShardsConfigs().length != masterSolrConfig.getShardsConfigs().length) {
|
||||
throw new ConfigurationException("[" + name + "] master and slave shard count must equals !");
|
||||
}
|
||||
|
||||
// solr connections defaults
|
||||
this.solrMaxConnectionsPerHost = XmlUtils.getNodeValueAsInt(storeNode, "solrMaxConnectionsPerHost", 300);
|
||||
if (slaveSolrConfig.getShardsConfigs().length > 0) {
|
||||
this.solrMaxTotalConnections = XmlUtils.getNodeValueAsInt(storeNode, "solrMaxTotalConnections", slaveSolrConfig
|
||||
.getShardsConfigs().length
|
||||
* solrMaxConnectionsPerHost);
|
||||
} else {
|
||||
this.solrMaxTotalConnections = XmlUtils.getNodeValueAsInt(storeNode, "solrMaxTotalConnections",
|
||||
solrMaxConnectionsPerHost);
|
||||
}
|
||||
|
||||
// init mongo
|
||||
String mongoId = ((Element) storeNode).attributeValue("mongo");
|
||||
MongoConfig mongoConfig = dataStoreConfig.getMongoConfigById(mongoId);
|
||||
if (null == mongoConfig) {
|
||||
throw new ConfigurationException("[" + name + "] unknown mongo id: " + mongoId);
|
||||
}
|
||||
this.mongoConfig = mongoConfig;
|
||||
|
||||
// init other config
|
||||
this.textFieldToGridFS = XmlUtils.getNodeValueAsBoolean(storeNode, "textFieldToGridFS", false);
|
||||
|
||||
// init fields
|
||||
Map<String, Field> newFields = new HashMap<String, Field>();
|
||||
List<Node> fieldNodes = storeNode.selectNodes("schema//field");
|
||||
for (Node fieldNode : fieldNodes) {
|
||||
Element element = (Element) fieldNode;
|
||||
String fieldName = element.attributeValue("name");
|
||||
Field field = getOrCreateField(fieldName);
|
||||
field.setName(fieldName);
|
||||
field.setRequired(Boolean.parseBoolean(element.attributeValue("required")));
|
||||
field.setType(FieldTypeEnum.parse(element.attributeValue("type")));
|
||||
newFields.put(fieldName, field);
|
||||
}
|
||||
this.fields.clear();
|
||||
this.fields.putAll(newFields);
|
||||
|
||||
// init triggers
|
||||
Element triggerNode = (Element) storeNode.selectSingleNode("trigger");
|
||||
if(triggerNode != null) {
|
||||
trigger.setInterface(triggerNode.attributeValue("interface"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Trigger getTrigger() {
|
||||
return this.trigger;
|
||||
}
|
||||
|
||||
public Field getField(String fieldName) {
|
||||
return this.fields.get(fieldName);
|
||||
}
|
||||
|
||||
public boolean containsField(String fieldName) {
|
||||
return this.fields.containsKey(fieldName);
|
||||
}
|
||||
|
||||
public boolean isFieldValueLegal(String fieldName, Object value) {
|
||||
if ("_id".equals(fieldName)) {
|
||||
return value instanceof ObjectId;
|
||||
}
|
||||
if (fields.containsKey(fieldName)) {
|
||||
Field field = fields.get(fieldName);
|
||||
return field.validate(value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isBigField(String fieldName) {
|
||||
return fields.get(fieldName).isBigField();
|
||||
}
|
||||
|
||||
public Collection<Field> getFields() {
|
||||
return Collections.unmodifiableCollection(this.fields.values());
|
||||
}
|
||||
|
||||
synchronized Field getOrCreateField(String fieldName) {
|
||||
if (StringUtils.isEmpty(fieldName)) {
|
||||
throw new IllegalArgumentException("fieldName can not be null or empty!");
|
||||
}
|
||||
Field ret = this.fields.get(fieldName);
|
||||
if (null == ret) {
|
||||
ret = new Field();
|
||||
ret.setName(fieldName);
|
||||
this.fields.put(fieldName, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public MongoConfig getMongoConfig() {
|
||||
return mongoConfig;
|
||||
}
|
||||
|
||||
public DataStoreConfig getDataStoreConfig() {
|
||||
return dataStoreConfig;
|
||||
}
|
||||
|
||||
public boolean isTextFieldToGridFS() {
|
||||
return textFieldToGridFS;
|
||||
}
|
||||
|
||||
public SolrConfig getSlaveSolrConfig() {
|
||||
return slaveSolrConfig;
|
||||
}
|
||||
|
||||
public SolrConfig[] getMasterSolrConfigs() {
|
||||
return masterSolrConfigs;
|
||||
}
|
||||
|
||||
public SolrConfig getMasterSolrConfig() {
|
||||
return masterSolrConfig;
|
||||
}
|
||||
|
||||
public int getSolrMaxTotalConnections() {
|
||||
return solrMaxTotalConnections;
|
||||
}
|
||||
|
||||
public int getSolrMaxConnectionsPerHost() {
|
||||
return solrMaxConnectionsPerHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.append("\n{");
|
||||
ret.append("\n\tname: ").append(name);
|
||||
ret.append(",\n\tmasterSolrConfig: ").append(masterSolrConfig);
|
||||
ret.append(",\n\tslaveSolrConfig: ").append(this.slaveSolrConfig);
|
||||
ret.append(",\n\tmongoConfig: ").append(mongoConfig);
|
||||
ret.append(",\n\tsolrMaxTotalConnections: ").append(solrMaxTotalConnections);
|
||||
ret.append(",\n\tsolrMaxConnectionsPerHost: ").append(this.solrMaxConnectionsPerHost);
|
||||
ret.append(",\n\ttextFieldToGridFS: ").append(this.textFieldToGridFS);
|
||||
ret.append(",\n\ttrigger: ").append(trigger);
|
||||
ret.append(",\n\tmasterSolrConfigs: [\n");
|
||||
for (int i = 0; i < this.masterSolrConfigs.length; i++) {
|
||||
ret.append('\t').append('\t').append(this.masterSolrConfigs[i]);
|
||||
if (i < this.masterSolrConfigs.length - 1) {
|
||||
ret.append(',');
|
||||
}
|
||||
ret.append('\n');
|
||||
}
|
||||
ret.append("\t]\n}");
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public final class StoreConfig
|
||||
{
|
||||
private final String name;
|
||||
private int solrMaxTotalConnections;
|
||||
private int solrMaxConnectionsPerHost;
|
||||
private SolrConfig[] masterSolrConfigs;
|
||||
private SolrConfig masterSolrConfig;
|
||||
private SolrConfig slaveSolrConfig;
|
||||
private MongoConfig mongoConfig;
|
||||
private boolean textFieldToGridFS;
|
||||
private final Trigger trigger;
|
||||
private final Map<String, Field> fields;
|
||||
private final DataStoreConfig dataStoreConfig;
|
||||
|
||||
StoreConfig(final DataStoreConfig dataStoreConfig, final String name) {
|
||||
this.dataStoreConfig = dataStoreConfig;
|
||||
this.fields = new HashMap<String, Field>();
|
||||
this.trigger = new Trigger();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
synchronized void reload(final Node storeNode) throws ConfigurationException {
|
||||
final String solrMastersAttr = ((Element)storeNode).attributeValue("solrMasters");
|
||||
if (StringUtils.isEmpty(solrMastersAttr)) {
|
||||
throw new ConfigurationException("[" + this.name + "] invalid solrMasters attribute:" + solrMastersAttr);
|
||||
}
|
||||
final String[] solrMasterIds = solrMastersAttr.split(",");
|
||||
if (solrMasterIds.length > 2) {
|
||||
throw new ConfigurationException("[" + this.name + "] too many solr server configured:" + solrMastersAttr);
|
||||
}
|
||||
this.masterSolrConfigs = new SolrConfig[solrMasterIds.length];
|
||||
for (int i = 0; i < solrMasterIds.length; ++i) {
|
||||
this.masterSolrConfigs[i] = this.dataStoreConfig.getSolrConfigById(solrMasterIds[i]);
|
||||
if (null == this.masterSolrConfigs[i]) {
|
||||
throw new ConfigurationException("[" + this.name + "] unknown solr id: " + solrMasterIds[i]);
|
||||
}
|
||||
}
|
||||
final String solrSlaveAttr = System.getProperty("datastore." + this.name + ".solrSlave", ((Element)storeNode).attributeValue("solrSlave"));
|
||||
if (StringUtils.isEmpty(solrSlaveAttr)) {
|
||||
throw new ConfigurationException("[" + this.name + "] invalid solrSlave attribute:" + solrSlaveAttr);
|
||||
}
|
||||
this.slaveSolrConfig = this.dataStoreConfig.getSolrConfigById(solrSlaveAttr);
|
||||
if (null == this.slaveSolrConfig) {
|
||||
throw new ConfigurationException("[" + this.name + "] unknown solr id: " + solrSlaveAttr);
|
||||
}
|
||||
final String solrMasterAttr = System.getProperty("datastore." + this.name + ".solrMaster", ((Element)storeNode).attributeValue("solrMaster"));
|
||||
if (StringUtils.isEmpty(solrMasterAttr)) {
|
||||
throw new ConfigurationException("[" + this.name + "] invalid solrMaster attribute:" + solrMasterAttr);
|
||||
}
|
||||
this.masterSolrConfig = this.dataStoreConfig.getSolrConfigById(solrMasterAttr);
|
||||
if (null == this.masterSolrConfig) {
|
||||
throw new ConfigurationException("[" + this.name + "] unknown solr id: " + solrMasterAttr);
|
||||
}
|
||||
if (this.slaveSolrConfig.getShardsConfigs().length != this.masterSolrConfig.getShardsConfigs().length) {
|
||||
throw new ConfigurationException("[" + this.name + "] master and slave shard count must equals !");
|
||||
}
|
||||
this.solrMaxConnectionsPerHost = XmlUtils.getNodeValueAsInt(storeNode, "solrMaxConnectionsPerHost", 300);
|
||||
if (this.slaveSolrConfig.getShardsConfigs().length > 0) {
|
||||
this.solrMaxTotalConnections = XmlUtils.getNodeValueAsInt(storeNode, "solrMaxTotalConnections", this.slaveSolrConfig.getShardsConfigs().length * this.solrMaxConnectionsPerHost);
|
||||
}
|
||||
else {
|
||||
this.solrMaxTotalConnections = XmlUtils.getNodeValueAsInt(storeNode, "solrMaxTotalConnections", this.solrMaxConnectionsPerHost);
|
||||
}
|
||||
final String mongoId = ((Element)storeNode).attributeValue("mongo");
|
||||
final MongoConfig mongoConfig = this.dataStoreConfig.getMongoConfigById(mongoId);
|
||||
if (null == mongoConfig) {
|
||||
throw new ConfigurationException("[" + this.name + "] unknown mongo id: " + mongoId);
|
||||
}
|
||||
this.mongoConfig = mongoConfig;
|
||||
this.textFieldToGridFS = XmlUtils.getNodeValueAsBoolean(storeNode, "textFieldToGridFS", false);
|
||||
final Map<String, Field> newFields = new HashMap<String, Field>();
|
||||
final List<Node> fieldNodes = (List<Node>)storeNode.selectNodes("schema//field");
|
||||
for (final Node fieldNode : fieldNodes) {
|
||||
final Element element = (Element)fieldNode;
|
||||
final String fieldName = element.attributeValue("name");
|
||||
final Field field = this.getOrCreateField(fieldName);
|
||||
field.setName(fieldName);
|
||||
field.setRequired(Boolean.parseBoolean(element.attributeValue("required")));
|
||||
field.setType(FieldTypeEnum.parse(element.attributeValue("type")));
|
||||
newFields.put(fieldName, field);
|
||||
}
|
||||
this.fields.clear();
|
||||
this.fields.putAll(newFields);
|
||||
final Element triggerNode = (Element)storeNode.selectSingleNode("trigger");
|
||||
if (triggerNode != null) {
|
||||
this.trigger.setInterface(triggerNode.attributeValue("interface"));
|
||||
}
|
||||
}
|
||||
|
||||
public Trigger getTrigger() {
|
||||
return this.trigger;
|
||||
}
|
||||
|
||||
public Field getField(final String fieldName) {
|
||||
return this.fields.get(fieldName);
|
||||
}
|
||||
|
||||
public boolean containsField(final String fieldName) {
|
||||
return this.fields.containsKey(fieldName);
|
||||
}
|
||||
|
||||
public boolean isFieldValueLegal(final String fieldName, final Object value) {
|
||||
if ("_id".equals(fieldName)) {
|
||||
return value instanceof ObjectId;
|
||||
}
|
||||
if (this.fields.containsKey(fieldName)) {
|
||||
final Field field = this.fields.get(fieldName);
|
||||
return field.validate(value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isBigField(final String fieldName) {
|
||||
return this.fields.get(fieldName).isBigField();
|
||||
}
|
||||
|
||||
public Collection<Field> getFields() {
|
||||
return Collections.<Field>unmodifiableCollection((Collection<? extends Field>)this.fields.values());
|
||||
}
|
||||
|
||||
synchronized Field getOrCreateField(final String fieldName) {
|
||||
if (StringUtils.isEmpty(fieldName)) {
|
||||
throw new IllegalArgumentException("fieldName can not be null or empty!");
|
||||
}
|
||||
Field ret = this.fields.get(fieldName);
|
||||
if (null == ret) {
|
||||
ret = new Field();
|
||||
ret.setName(fieldName);
|
||||
this.fields.put(fieldName, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public MongoConfig getMongoConfig() {
|
||||
return this.mongoConfig;
|
||||
}
|
||||
|
||||
public DataStoreConfig getDataStoreConfig() {
|
||||
return this.dataStoreConfig;
|
||||
}
|
||||
|
||||
public boolean isTextFieldToGridFS() {
|
||||
return this.textFieldToGridFS;
|
||||
}
|
||||
|
||||
public SolrConfig getSlaveSolrConfig() {
|
||||
return this.slaveSolrConfig;
|
||||
}
|
||||
|
||||
public SolrConfig[] getMasterSolrConfigs() {
|
||||
return this.masterSolrConfigs;
|
||||
}
|
||||
|
||||
public SolrConfig getMasterSolrConfig() {
|
||||
return this.masterSolrConfig;
|
||||
}
|
||||
|
||||
public int getSolrMaxTotalConnections() {
|
||||
return this.solrMaxTotalConnections;
|
||||
}
|
||||
|
||||
public int getSolrMaxConnectionsPerHost() {
|
||||
return this.solrMaxConnectionsPerHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder ret = new StringBuilder();
|
||||
ret.append("\n{");
|
||||
ret.append("\n\tname: ").append(this.name);
|
||||
ret.append(",\n\tmasterSolrConfig: ").append(this.masterSolrConfig);
|
||||
ret.append(",\n\tslaveSolrConfig: ").append(this.slaveSolrConfig);
|
||||
ret.append(",\n\tmongoConfig: ").append(this.mongoConfig);
|
||||
ret.append(",\n\tsolrMaxTotalConnections: ").append(this.solrMaxTotalConnections);
|
||||
ret.append(",\n\tsolrMaxConnectionsPerHost: ").append(this.solrMaxConnectionsPerHost);
|
||||
ret.append(",\n\ttextFieldToGridFS: ").append(this.textFieldToGridFS);
|
||||
ret.append(",\n\ttrigger: ").append(this.trigger);
|
||||
ret.append(",\n\tmasterSolrConfigs: [\n");
|
||||
for (int i = 0; i < this.masterSolrConfigs.length; ++i) {
|
||||
ret.append('\t').append('\t').append(this.masterSolrConfigs[i]);
|
||||
if (i < this.masterSolrConfigs.length - 1) {
|
||||
ret.append(',');
|
||||
}
|
||||
ret.append('\n');
|
||||
}
|
||||
ret.append("\t]\n}");
|
||||
return ret.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+43
-43
@@ -1,49 +1,49 @@
|
||||
package com.fangjia.datastore.config;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
public final class Trigger {
|
||||
private String interface_;
|
||||
|
||||
Trigger() {
|
||||
}
|
||||
|
||||
public String getInterface() {
|
||||
return interface_;
|
||||
}
|
||||
|
||||
void setInterface(String interface_) {
|
||||
if (StringUtils.isEmpty(interface_) || !interface_.startsWith("http://")) {
|
||||
throw new IllegalArgumentException("invalid trigger interface: " + interface_);
|
||||
}
|
||||
this.interface_ = interface_;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(this.interface_).toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (null == obj) {
|
||||
return false;
|
||||
}
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Trigger)) {
|
||||
return false;
|
||||
}
|
||||
Trigger other = (Trigger) obj;
|
||||
return new EqualsBuilder().append(this.interface_, other.interface_).isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder().append("{interface=").append(interface_).append("}").toString();
|
||||
}
|
||||
|
||||
public final class Trigger
|
||||
{
|
||||
private String interface_;
|
||||
|
||||
Trigger() {
|
||||
}
|
||||
|
||||
public String getInterface() {
|
||||
return this.interface_;
|
||||
}
|
||||
|
||||
void setInterface(final String interface_) {
|
||||
if (StringUtils.isEmpty(interface_) || !interface_.startsWith("http://")) {
|
||||
throw new IllegalArgumentException("invalid trigger interface: " + interface_);
|
||||
}
|
||||
this.interface_ = interface_;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append((Object)this.interface_).toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (null == obj) {
|
||||
return false;
|
||||
}
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Trigger)) {
|
||||
return false;
|
||||
}
|
||||
final Trigger other = (Trigger)obj;
|
||||
return new EqualsBuilder().append((Object)this.interface_, (Object)other.interface_).isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{interface=" + this.interface_ + "}";
|
||||
}
|
||||
}
|
||||
|
||||
+13
-12
@@ -1,19 +1,20 @@
|
||||
package com.fangjia.datastore.handler;
|
||||
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import com.fangjia.datastore.DataStore;
|
||||
import com.fangjia.datastore.DataStoreContext;
|
||||
import com.fangjia.datastore.mongo.protocol.DeleteMessage;
|
||||
|
||||
public class DeleteMessageHandler extends MessageHandler<DeleteMessage> {
|
||||
|
||||
public DeleteMessageHandler(DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
public void messageReceived(DeleteMessage message,String ip) throws Exception {
|
||||
assertNotReadOnly();
|
||||
DataStore dataStore = this.dataStoreContext.getDataStore(message.getFullCollectionName());
|
||||
dataStore.remove(message.getSelector());
|
||||
}
|
||||
|
||||
public class DeleteMessageHandler extends MessageHandler<DeleteMessage>
|
||||
{
|
||||
public DeleteMessageHandler(final DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final DeleteMessage message) throws Exception {
|
||||
this.assertNotReadOnly();
|
||||
final DataStore dataStore = this.dataStoreContext.getDataStore(message.getFullCollectionName());
|
||||
dataStore.remove(message.getSelector());
|
||||
}
|
||||
}
|
||||
|
||||
+52
-47
@@ -1,54 +1,59 @@
|
||||
package com.fangjia.datastore.handler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bson.BSONObject;
|
||||
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import com.mongodb.DBObject;
|
||||
import com.fangjia.datastore.QueryResponse;
|
||||
import com.fangjia.datastore.mongo.protocol.QueryMessage;
|
||||
import com.fangjia.datastore.Cursor;
|
||||
import com.fangjia.datastore.DataStore;
|
||||
import com.fangjia.datastore.DataStoreContext;
|
||||
import com.fangjia.datastore.QueryResponse;
|
||||
import com.fangjia.datastore.mongo.protocol.GetMoreMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.QueryMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.ReplyMessage;
|
||||
import org.bson.BSONObject;
|
||||
import java.util.List;
|
||||
import com.fangjia.datastore.DataStoreContext;
|
||||
import com.fangjia.datastore.mongo.protocol.GetMoreMessage;
|
||||
|
||||
public class GetMoreMessageHandler extends MessageHandler<GetMoreMessage> {
|
||||
|
||||
public GetMoreMessageHandler(DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
public void messageReceived(GetMoreMessage message) throws Exception {
|
||||
String fullCollectionName = message.getFullCollectionName();
|
||||
if(fullCollectionName.contains("$cmd")){
|
||||
ReplyMessage reply = prepareReplyMessage(message.getMessageHeader().getRequestID(), (List<? extends BSONObject>) null);
|
||||
reply.setStartingFrom(0);
|
||||
this.writeMessage(reply);
|
||||
this.dataStoreContext.removeCursor(message.getCursorID());
|
||||
return;
|
||||
}
|
||||
DataStore dataStore = this.dataStoreContext.getDataStore(message.getFullCollectionName());
|
||||
Cursor cursor = this.dataStoreContext.getCursor(message.getCursorID());
|
||||
if (null == cursor) {
|
||||
ReplyMessage reply = prepareReplyMessage(message.getMessageHeader().getRequestID(), (List<? extends BSONObject>) null);
|
||||
reply.setStartingFrom(0);
|
||||
this.writeMessage(reply);
|
||||
} else {
|
||||
QueryMessage queryMessage = cursor.getQueryMessage();
|
||||
QueryResponse response = dataStore.find(queryMessage.getRealQuery(), queryMessage.getReturnFieldSelector(),
|
||||
queryMessage.getOrderByQuery(), queryMessage.getFacetQuery(), cursor.nextSkip(),
|
||||
message.getNumberToReturn() - 1, queryMessage.isBulkQuery(), queryMessage.isFromMaster());
|
||||
ReplyMessage reply = prepareReplyMessage(message.getMessageHeader().getRequestID(), response.getDocList());
|
||||
reply.setStartingFrom(cursor.getSkip());
|
||||
if (response.hasMore()) {
|
||||
// cursor.setTotalCount(response.getNumFound());
|
||||
// cursor.setLimit((int) response.getNumReturned());
|
||||
// this.dataStoreContext.addCursor(cursor);
|
||||
// reply.setCursorID(cursor.getId());
|
||||
} else {
|
||||
this.dataStoreContext.removeCursor(cursor.getId());
|
||||
}
|
||||
this.writeMessage(reply);
|
||||
}
|
||||
}
|
||||
public class GetMoreMessageHandler extends MessageHandler<GetMoreMessage>
|
||||
{
|
||||
public GetMoreMessageHandler(final DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final GetMoreMessage message) throws Exception {
|
||||
final String fullCollectionName = message.getFullCollectionName();
|
||||
if (fullCollectionName.contains("$cmd")) {
|
||||
final ReplyMessage reply = this.prepareReplyMessage(message.getMessageHeader().getRequestID(), (List<? extends BSONObject>)null);
|
||||
reply.setStartingFrom(0);
|
||||
this.writeMessage(reply);
|
||||
this.dataStoreContext.removeCursor(message.getCursorID());
|
||||
return;
|
||||
}
|
||||
final DataStore dataStore = this.dataStoreContext.getDataStore(message.getFullCollectionName());
|
||||
final Cursor cursor = this.dataStoreContext.getCursor(message.getCursorID());
|
||||
if (null == cursor) {
|
||||
final ReplyMessage reply2 = this.prepareReplyMessage(message.getMessageHeader().getRequestID(), (List<? extends BSONObject>)null);
|
||||
reply2.setStartingFrom(0);
|
||||
this.writeMessage(reply2);
|
||||
}
|
||||
else {
|
||||
final QueryMessage queryMessage = cursor.getQueryMessage();
|
||||
final QueryResponse response = dataStore.find(queryMessage.getRealQuery(), queryMessage.getReturnFieldSelector(), queryMessage.getOrderByQuery(), queryMessage.getFacetQuery(), cursor.nextSkip(), this.useCursor() ? message.getNumberToReturn() : (message.getNumberToReturn() - 1), queryMessage.isBulkQuery(), queryMessage.isFromMaster());
|
||||
final List<DBObject> doc = response.getDocList();
|
||||
if (this.useCursor()) {
|
||||
doc.remove(0);
|
||||
}
|
||||
final ReplyMessage reply3 = this.prepareReplyMessage(message.getMessageHeader().getRequestID(), (List<? extends BSONObject>)doc);
|
||||
reply3.setStartingFrom(cursor.getSkip());
|
||||
if (response.hasMore() && this.useCursor()) {
|
||||
cursor.setTotalCount(response.getNumFound());
|
||||
cursor.setLimit(response.getNumReturned());
|
||||
this.dataStoreContext.addCursor(cursor);
|
||||
reply3.setCursorID(cursor.getId());
|
||||
}
|
||||
else {
|
||||
this.dataStoreContext.removeCursor(cursor.getId());
|
||||
}
|
||||
this.writeMessage(reply3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+109
-107
@@ -1,115 +1,117 @@
|
||||
package com.fangjia.datastore.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import java.util.Iterator;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bson.BSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.fangjia.datastore.solr.Index;
|
||||
import java.util.Collection;
|
||||
import com.fangjia.datastore.DataStore;
|
||||
import org.bson.BSONObject;
|
||||
import java.util.List;
|
||||
import com.fangjia.datastore.DataStoreContext;
|
||||
import com.fangjia.datastore.mongo.protocol.InsertMessage;
|
||||
import com.fangjia.datastore.solr.Index;
|
||||
import com.fangjia.datastore.solr.Index.IndexTypeEnum;
|
||||
|
||||
public class InsertMessageHandler extends MessageHandler<InsertMessage> {
|
||||
|
||||
public InsertMessageHandler(DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
public void messageReceived(InsertMessage message,String ip) throws Exception {
|
||||
if (message.getFullCollectionName().endsWith("system.indexes")) {
|
||||
ensureIndex(message);
|
||||
} else {
|
||||
insert(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* db.foo.insert()
|
||||
*
|
||||
* @param message
|
||||
* @throws Exception
|
||||
*/
|
||||
private void insert(InsertMessage message) throws Exception {
|
||||
assertNotReadOnly();
|
||||
DataStore dataStore = this.dataStoreContext.getDataStore(message.getFullCollectionName());
|
||||
dataStore.save(message.getDocuments());
|
||||
}
|
||||
|
||||
/**
|
||||
* db.foo.ensureIndex()
|
||||
*
|
||||
* @param message
|
||||
* @throws Exception
|
||||
*/
|
||||
private void ensureIndex(InsertMessage message) throws Exception {
|
||||
assertNotReadOnly();
|
||||
DataStore dataStore = this.dataStoreContext.getDataStore(String.valueOf(message.getDocuments().get(0).get("ns")));
|
||||
List<Index> indexList = addToIndexList(message.getDocuments());
|
||||
dataStore.ensureIndex(indexList);
|
||||
}
|
||||
|
||||
private List<Index> addToIndexList(List<BSONObject> docList) {
|
||||
if (null == docList || docList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
List<Index> indexList = new ArrayList<Index>();
|
||||
for (BSONObject bson : docList) {
|
||||
BSONObject keys = (BSONObject) bson.get("key");
|
||||
if (null == keys) {
|
||||
continue;
|
||||
}
|
||||
for (String key : keys.keySet()) {
|
||||
Object value = keys.get(key);
|
||||
if (value instanceof String) {
|
||||
Index index = new Index(key, IndexTypeEnum.parse((String) value));
|
||||
indexList.add(index);
|
||||
} else if (value instanceof BSONObject) {
|
||||
// TODO:
|
||||
Index index = new Index();
|
||||
index.setName(key);
|
||||
for (String k : ((BSONObject) value).keySet()) {
|
||||
Object v = ((BSONObject) value).get(k);
|
||||
if (StringUtils.equalsIgnoreCase(k, "type")) {
|
||||
if (v instanceof String) {
|
||||
index.setType(IndexTypeEnum.parse((String) v));
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(k, "stored")) {
|
||||
if (v instanceof Boolean) {
|
||||
index.setStored((Boolean) v);
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(k, "indexed")) {
|
||||
if (v instanceof Boolean) {
|
||||
index.setIndexed((Boolean) v);
|
||||
}
|
||||
|
||||
} else if (StringUtils.equalsIgnoreCase(k, "multiValued")) {
|
||||
if (v instanceof Boolean) {
|
||||
index.setMultiValued((Boolean) v);
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(k, "dynamic")) {
|
||||
if (v instanceof Boolean) {
|
||||
index.setDynamic((Boolean) v);
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(k, "comments")) {
|
||||
if (v instanceof String) {
|
||||
index.setComments((String) v);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (index.getType() == null) {
|
||||
throw new IllegalArgumentException("illegal schema field: type");
|
||||
}
|
||||
indexList.add(index);
|
||||
} else {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error("invalid key value of ensureIndex:{}", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return indexList;
|
||||
}
|
||||
public class InsertMessageHandler extends MessageHandler<InsertMessage>
|
||||
{
|
||||
public InsertMessageHandler(final DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final InsertMessage message) throws Exception {
|
||||
if (message.getFullCollectionName().endsWith("system.indexes")) {
|
||||
this.ensureIndex(message);
|
||||
}
|
||||
else {
|
||||
this.insert(message);
|
||||
}
|
||||
}
|
||||
|
||||
private void insert(final InsertMessage message) throws Exception {
|
||||
this.assertNotReadOnly();
|
||||
final DataStore dataStore = this.dataStoreContext.getDataStore(message.getFullCollectionName());
|
||||
dataStore.save(message.getDocuments());
|
||||
}
|
||||
|
||||
private void ensureIndex(final InsertMessage message) throws Exception {
|
||||
this.assertNotReadOnly();
|
||||
final DataStore dataStore = this.dataStoreContext.getDataStore(String.valueOf(message.getDocuments().get(0).get("ns")));
|
||||
final List<Index> indexList = this.addToIndexList(message.getDocuments());
|
||||
dataStore.ensureIndex(indexList);
|
||||
}
|
||||
|
||||
private List<Index> addToIndexList(final List<BSONObject> docList) {
|
||||
if (null == docList || docList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
final List<Index> indexList = new ArrayList<Index>();
|
||||
for (final BSONObject bson : docList) {
|
||||
final BSONObject keys = (BSONObject)bson.get("key");
|
||||
if (null == keys) {
|
||||
continue;
|
||||
}
|
||||
for (final String key : keys.keySet()) {
|
||||
final Object value = keys.get(key);
|
||||
if (value instanceof String) {
|
||||
final Index index = new Index(key, Index.IndexTypeEnum.parse((String)value));
|
||||
indexList.add(index);
|
||||
}
|
||||
else if (value instanceof BSONObject) {
|
||||
final Index index = new Index();
|
||||
index.setName(key);
|
||||
for (final String k : ((BSONObject)value).keySet()) {
|
||||
final Object v = ((BSONObject)value).get(k);
|
||||
if (StringUtils.equalsIgnoreCase(k, "type")) {
|
||||
if (!(v instanceof String)) {
|
||||
continue;
|
||||
}
|
||||
index.setType(Index.IndexTypeEnum.parse((String)v));
|
||||
}
|
||||
else if (StringUtils.equalsIgnoreCase(k, "stored")) {
|
||||
if (!(v instanceof Boolean)) {
|
||||
continue;
|
||||
}
|
||||
index.setStored((Boolean) v);
|
||||
}
|
||||
else if (StringUtils.equalsIgnoreCase(k, "indexed")) {
|
||||
if (!(v instanceof Boolean)) {
|
||||
continue;
|
||||
}
|
||||
index.setIndexed((Boolean)v);
|
||||
}
|
||||
else if (StringUtils.equalsIgnoreCase(k, "multiValued")) {
|
||||
if (!(v instanceof Boolean)) {
|
||||
continue;
|
||||
}
|
||||
index.setMultiValued((Boolean)v);
|
||||
}
|
||||
else if (StringUtils.equalsIgnoreCase(k, "dynamic")) {
|
||||
if (!(v instanceof Boolean)) {
|
||||
continue;
|
||||
}
|
||||
index.setDynamic((Boolean)v);
|
||||
}
|
||||
else {
|
||||
if (!StringUtils.equalsIgnoreCase(k, "comments") || !(v instanceof String)) {
|
||||
continue;
|
||||
}
|
||||
index.setComments((String)v);
|
||||
}
|
||||
}
|
||||
if (index.getType() == null) {
|
||||
throw new IllegalArgumentException("illegal schema field: type");
|
||||
}
|
||||
indexList.add(index);
|
||||
}
|
||||
else {
|
||||
if (!this.logger.isErrorEnabled()) {
|
||||
continue;
|
||||
}
|
||||
this.logger.error("invalid key value of ensureIndex:{}", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return indexList;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-16
@@ -1,23 +1,24 @@
|
||||
package com.fangjia.datastore.handler;
|
||||
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.datastore.DataStoreContext;
|
||||
import com.fangjia.datastore.mongo.protocol.KillCursorsMessage;
|
||||
|
||||
public class KillCursorsMessageHandler extends MessageHandler<KillCursorsMessage> {
|
||||
|
||||
public KillCursorsMessageHandler(DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
public void messageReceived(KillCursorsMessage message,String ip) {
|
||||
List<Long> cursorIds = message.getCursorIDs();
|
||||
if (cursorIds != null) {
|
||||
for (Long cursorId : cursorIds) {
|
||||
this.dataStoreContext.removeCursor(cursorId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class KillCursorsMessageHandler extends MessageHandler<KillCursorsMessage>
|
||||
{
|
||||
public KillCursorsMessageHandler(final DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final KillCursorsMessage message) {
|
||||
final List<Long> cursorIds = message.getCursorIDs();
|
||||
if (cursorIds != null) {
|
||||
for (final Long cursorId : cursorIds) {
|
||||
this.dataStoreContext.removeCursor(cursorId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+172
-176
@@ -1,184 +1,180 @@
|
||||
package com.fangjia.datastore.handler;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.bson.BSONObject;
|
||||
import org.bson.BasicBSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fangjia.datastore.DataStoreContext;
|
||||
import com.fangjia.datastore.DataStoreException;
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import java.util.Arrays;
|
||||
import org.bson.BasicBSONObject;
|
||||
import java.util.ArrayList;
|
||||
import org.bson.BSONObject;
|
||||
import java.util.List;
|
||||
import com.fangjia.datastore.mongo.protocol.ReplyMessage;
|
||||
import java.net.InetSocketAddress;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import com.fangjia.datastore.DataStoreContext;
|
||||
import java.util.Map;
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
|
||||
public abstract class MessageHandler<T extends MongoMessage> {
|
||||
private final static String LAST_ERROR_KEY = "com.goojia.datastore.LAST_ERROR_KEY";
|
||||
private final static String PREV_ERROR_KEY = "com.goojia.datastore.PREV_ERROR_KEY";
|
||||
|
||||
private final static String SESSION_KEY = "com.goojia.datastore.SESSION_KEY";
|
||||
private final static String ERROR_OCCURRED_KEY = "com.goojia.datastore.ERROR_OCCURRED_KEY";
|
||||
private final static ThreadLocal<Map<String, Object>> THREAD_LOCAL = new ThreadLocal<Map<String, Object>>() {
|
||||
@Override
|
||||
protected Map<String, Object> initialValue() {
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
};
|
||||
|
||||
protected final DataStoreContext dataStoreContext;
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public MessageHandler(DataStoreContext dataStoreContext) {
|
||||
this.dataStoreContext = dataStoreContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* ´¦ÀíÌØ¶¨µÄÏûÏ¢
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public abstract void messageReceived(T message,String ip) throws Exception;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void messageReceived(IoSession session, MongoMessage message) throws Exception {
|
||||
System.out.println(session.getRemoteAddress());
|
||||
try {
|
||||
setSession(session);
|
||||
messageReceived((T) message,session.getRemoteAddress().toString());
|
||||
if (!isErrorOccured()) {
|
||||
this.clearLastError();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
String hostAddress = "";
|
||||
if(session.getRemoteAddress() instanceof InetSocketAddress) {
|
||||
hostAddress = ((InetSocketAddress)session.getRemoteAddress()).getAddress().getHostAddress();
|
||||
}
|
||||
this.setLastError(buildExceptionMessage(e));
|
||||
logger.error("error processing host:" + hostAddress + ",message: " + message, e);
|
||||
} finally {
|
||||
clearErrorOccured();
|
||||
}
|
||||
}
|
||||
|
||||
private void clearErrorOccured() {
|
||||
THREAD_LOCAL.get().remove(ERROR_OCCURRED_KEY);
|
||||
}
|
||||
|
||||
private void setErrorOccured() {
|
||||
THREAD_LOCAL.get().put(ERROR_OCCURRED_KEY, true);
|
||||
}
|
||||
|
||||
private boolean isErrorOccured() {
|
||||
Boolean b = (Boolean) THREAD_LOCAL.get().get(ERROR_OCCURRED_KEY);
|
||||
return null == b ? false : b;
|
||||
}
|
||||
|
||||
protected IoSession getSession() {
|
||||
return (IoSession) THREAD_LOCAL.get().get(SESSION_KEY);
|
||||
}
|
||||
|
||||
private void setSession(IoSession session) {
|
||||
THREAD_LOCAL.get().put(SESSION_KEY, session);
|
||||
}
|
||||
|
||||
protected void setLastError(Object error) {
|
||||
if (null != error) {
|
||||
IoSession session = getSession();
|
||||
Object lastError = session.getAttribute(LAST_ERROR_KEY);
|
||||
if (null != lastError) {
|
||||
session.setAttribute(PREV_ERROR_KEY, lastError);
|
||||
}
|
||||
setErrorOccured();
|
||||
session.setAttribute(LAST_ERROR_KEY, String.valueOf(error));
|
||||
}
|
||||
}
|
||||
|
||||
private void clearLastError() {
|
||||
getSession().removeAttribute(LAST_ERROR_KEY);
|
||||
}
|
||||
|
||||
protected Object getLastError() {
|
||||
return getSession().getAttribute(LAST_ERROR_KEY);
|
||||
}
|
||||
|
||||
protected Object getPrevError() {
|
||||
return getSession().getAttribute(PREV_ERROR_KEY);
|
||||
}
|
||||
|
||||
protected void writeMessage(ReplyMessage message) {
|
||||
getSession().write(message);
|
||||
}
|
||||
|
||||
protected void writeAsReplyMessage(int responseTo, List<? extends BSONObject> docs) {
|
||||
writeMessage(prepareReplyMessage(responseTo, docs));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected ReplyMessage prepareReplyMessage(int responseTo, List<? extends BSONObject> docs) {
|
||||
ReplyMessage reply = new ReplyMessage();
|
||||
reply.setNumberReturned(null == docs ? 0 : docs.size());
|
||||
reply.setResponseFlag(8);
|
||||
reply.getMessageHeader().setResponseTo(responseTo);
|
||||
if (null != docs && docs.size() > 0) {
|
||||
reply.setDocuments((List<BSONObject>) docs);
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
protected void writeAsReplyMessage(int responseTo, BSONObject... docs) {
|
||||
writeMessage(prepareReplyMessage(responseTo, docs));
|
||||
}
|
||||
|
||||
protected ReplyMessage prepareReplyMessage(int responseTo, BSONObject... docs) {
|
||||
if (null != docs && docs.length > 0) {
|
||||
List<BSONObject> docList = new ArrayList<BSONObject>(docs.length);
|
||||
for (BSONObject doc : docs) {
|
||||
docList.add(doc);
|
||||
}
|
||||
return prepareReplyMessage(responseTo, docList);
|
||||
} else {
|
||||
return prepareReplyMessage(responseTo, (List<? extends BSONObject>) null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeAsErrorMessage(int responseTo, Object errorMessage) {
|
||||
writeMessage(prepareErrorMessage(responseTo, errorMessage));
|
||||
}
|
||||
|
||||
protected ReplyMessage prepareErrorMessage(int responseTo, Object errorMessage) {
|
||||
ReplyMessage reply = new ReplyMessage();
|
||||
reply.setNumberReturned(1);
|
||||
reply.setResponseFlag(8);
|
||||
reply.getMessageHeader().setResponseTo(responseTo);
|
||||
BSONObject msg = new BasicBSONObject("$err", errorMessage == null ? null : errorMessage.toString());
|
||||
msg.put("err", errorMessage == null ? null : errorMessage.toString());
|
||||
msg.put("errmsg", errorMessage == null ? null : errorMessage.toString());
|
||||
msg.put("ok", 0.0);
|
||||
reply.setDocuments(Arrays.asList(msg));
|
||||
return reply;
|
||||
}
|
||||
|
||||
protected String buildExceptionMessage(Throwable e) {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.append(e.getClass().getName()).append(": ").append(e.getMessage());
|
||||
Throwable cause = e;
|
||||
while ((cause = cause.getCause()) != null) {
|
||||
ret.append(", caused by ").append(cause.getClass().getName()).append(": ").append(cause.getMessage());
|
||||
}
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
protected void assertNotReadOnly() throws DataStoreException {
|
||||
if (this.dataStoreContext.getDataStoreConfig().isReadOnly()) {
|
||||
throw new DataStoreException("read only server !");
|
||||
}
|
||||
}
|
||||
public abstract class MessageHandler<T extends MongoMessage>
|
||||
{
|
||||
private static final String LAST_ERROR_KEY = "com.goojia.datastore.LAST_ERROR_KEY";
|
||||
private static final String PREV_ERROR_KEY = "com.goojia.datastore.PREV_ERROR_KEY";
|
||||
private static final String SESSION_KEY = "com.goojia.datastore.SESSION_KEY";
|
||||
private static final String ERROR_OCCURRED_KEY = "com.goojia.datastore.ERROR_OCCURRED_KEY";
|
||||
private static final ThreadLocal<Map<String, Object>> THREAD_LOCAL;
|
||||
protected final DataStoreContext dataStoreContext;
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public MessageHandler(final DataStoreContext dataStoreContext) {
|
||||
this.dataStoreContext = dataStoreContext;
|
||||
}
|
||||
|
||||
public abstract void messageReceived(T message) throws Exception;
|
||||
|
||||
public void messageReceived(final IoSession session, final MongoMessage message) throws Exception {
|
||||
try {
|
||||
this.setSession(session);
|
||||
this.messageReceived((T)message);
|
||||
if (!this.isErrorOccured()) {
|
||||
this.clearLastError();
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
String hostAddress = "";
|
||||
if (session.getRemoteAddress() instanceof InetSocketAddress) {
|
||||
hostAddress = ((InetSocketAddress)session.getRemoteAddress()).getAddress().getHostAddress();
|
||||
}
|
||||
this.setLastError(this.buildExceptionMessage(e));
|
||||
this.logger.error("error processing host:" + hostAddress + ",message: " + message, e);
|
||||
}
|
||||
finally {
|
||||
this.clearErrorOccured();
|
||||
}
|
||||
}
|
||||
|
||||
private void clearErrorOccured() {
|
||||
MessageHandler.THREAD_LOCAL.get().remove("com.goojia.datastore.ERROR_OCCURRED_KEY");
|
||||
}
|
||||
|
||||
private void setErrorOccured() {
|
||||
MessageHandler.THREAD_LOCAL.get().put("com.goojia.datastore.ERROR_OCCURRED_KEY", true);
|
||||
}
|
||||
|
||||
private boolean isErrorOccured() {
|
||||
final Boolean b = (Boolean) MessageHandler.THREAD_LOCAL.get().get("com.goojia.datastore.ERROR_OCCURRED_KEY");
|
||||
return null != b && b;
|
||||
}
|
||||
|
||||
protected IoSession getSession() {
|
||||
return (IoSession)MessageHandler.THREAD_LOCAL.get().get("com.goojia.datastore.SESSION_KEY");
|
||||
}
|
||||
|
||||
private void setSession(final IoSession session) {
|
||||
MessageHandler.THREAD_LOCAL.get().put("com.goojia.datastore.SESSION_KEY", session);
|
||||
}
|
||||
|
||||
protected void setLastError(final Object error) {
|
||||
if (null != error) {
|
||||
final IoSession session = this.getSession();
|
||||
final Object lastError = session.getAttribute((Object)"com.goojia.datastore.LAST_ERROR_KEY");
|
||||
if (null != lastError) {
|
||||
session.setAttribute((Object)"com.goojia.datastore.PREV_ERROR_KEY", lastError);
|
||||
}
|
||||
this.setErrorOccured();
|
||||
session.setAttribute((Object)"com.goojia.datastore.LAST_ERROR_KEY", (Object)String.valueOf(error));
|
||||
}
|
||||
}
|
||||
|
||||
private void clearLastError() {
|
||||
this.getSession().removeAttribute((Object)"com.goojia.datastore.LAST_ERROR_KEY");
|
||||
}
|
||||
|
||||
protected Object getLastError() {
|
||||
return this.getSession().getAttribute((Object)"com.goojia.datastore.LAST_ERROR_KEY");
|
||||
}
|
||||
|
||||
protected Object getPrevError() {
|
||||
return this.getSession().getAttribute((Object)"com.goojia.datastore.PREV_ERROR_KEY");
|
||||
}
|
||||
|
||||
protected void writeMessage(final ReplyMessage message) {
|
||||
this.getSession().write((Object)message);
|
||||
}
|
||||
|
||||
protected void writeAsReplyMessage(final int responseTo, final List<? extends BSONObject> docs) {
|
||||
this.writeMessage(this.prepareReplyMessage(responseTo, docs));
|
||||
}
|
||||
|
||||
protected ReplyMessage prepareReplyMessage(final int responseTo, final List<? extends BSONObject> docs) {
|
||||
final ReplyMessage reply = new ReplyMessage();
|
||||
reply.setNumberReturned((null == docs) ? 0 : docs.size());
|
||||
reply.setResponseFlag(8);
|
||||
reply.getMessageHeader().setResponseTo(responseTo);
|
||||
if (null != docs && docs.size() > 0) {
|
||||
reply.setDocuments((List<BSONObject>)docs);
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
protected void writeAsReplyMessage(final int responseTo, final BSONObject... docs) {
|
||||
this.writeMessage(this.prepareReplyMessage(responseTo, docs));
|
||||
}
|
||||
|
||||
protected ReplyMessage prepareReplyMessage(final int responseTo, final BSONObject... docs) {
|
||||
if (null != docs && docs.length > 0) {
|
||||
final List<BSONObject> docList = new ArrayList<BSONObject>(docs.length);
|
||||
for (final BSONObject doc : docs) {
|
||||
docList.add(doc);
|
||||
}
|
||||
return this.prepareReplyMessage(responseTo, docList);
|
||||
}
|
||||
return this.prepareReplyMessage(responseTo, (List<? extends BSONObject>)null);
|
||||
}
|
||||
|
||||
protected void writeAsErrorMessage(final int responseTo, final Object errorMessage) {
|
||||
this.writeMessage(this.prepareErrorMessage(responseTo, errorMessage));
|
||||
}
|
||||
|
||||
protected ReplyMessage prepareErrorMessage(final int responseTo, final Object errorMessage) {
|
||||
final ReplyMessage reply = new ReplyMessage();
|
||||
reply.setNumberReturned(1);
|
||||
reply.setResponseFlag(8);
|
||||
reply.getMessageHeader().setResponseTo(responseTo);
|
||||
final BSONObject msg = (BSONObject)new BasicBSONObject("$err", (Object)((errorMessage == null) ? null : errorMessage.toString()));
|
||||
msg.put("err", (Object)((errorMessage == null) ? null : errorMessage.toString()));
|
||||
msg.put("errmsg", (Object)((errorMessage == null) ? null : errorMessage.toString()));
|
||||
msg.put("ok", (Object)0.0);
|
||||
reply.setDocuments(Arrays.<BSONObject>asList(msg));
|
||||
return reply;
|
||||
}
|
||||
|
||||
protected String buildExceptionMessage(final Throwable e) {
|
||||
final StringBuilder ret = new StringBuilder();
|
||||
ret.append(e.getClass().getName()).append(": ").append(e.getMessage());
|
||||
Throwable cause = e;
|
||||
while ((cause = cause.getCause()) != null) {
|
||||
ret.append(", caused by ").append(cause.getClass().getName()).append(": ").append(cause.getMessage());
|
||||
}
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
protected void assertNotReadOnly() throws DataStoreException {
|
||||
if (this.dataStoreContext.getDataStoreConfig().isReadOnly()) {
|
||||
throw new DataStoreException("read only server !");
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean useCursor() {
|
||||
return (Boolean) this.getSession().getAttribute((Object)"useCursor", false);
|
||||
}
|
||||
|
||||
static {
|
||||
THREAD_LOCAL = new ThreadLocal<Map<String, Object>>() {
|
||||
@Override
|
||||
protected Map<String, Object> initialValue() {
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+491
-480
@@ -1,490 +1,501 @@
|
||||
package com.fangjia.datastore.handler;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mongodb.BasicDBList;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.bson.BSONObject;
|
||||
import org.bson.BasicBSONObject;
|
||||
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
import com.fangjia.datastore.DataStore;
|
||||
import com.fangjia.datastore.DataStoreContext;
|
||||
import com.fangjia.datastore.DataStoreException;
|
||||
import com.fangjia.datastore.QueryResponse;
|
||||
import com.fangjia.datastore.config.Field;
|
||||
import com.fangjia.datastore.config.StoreConfig;
|
||||
import com.fangjia.datastore.mongo.protocol.QueryMessage;
|
||||
import com.fangjia.datastore.config.Field;
|
||||
import com.fangjia.datastore.mongo.protocol.ReplyMessage;
|
||||
import com.fangjia.datastore.QueryResponse;
|
||||
import com.fangjia.datastore.Cursor;
|
||||
import java.util.Collection;
|
||||
import com.fangjia.datastore.solr.Index;
|
||||
import com.fangjia.datastore.utils.MongoUtils;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
import java.util.ArrayList;
|
||||
import com.fangjia.datastore.ConfigurationException;
|
||||
import com.mongodb.BasicDBList;
|
||||
import java.util.List;
|
||||
import com.fangjia.datastore.DataStore;
|
||||
import org.bson.types.BasicBSONList;
|
||||
import org.bson.BasicBSONObject;
|
||||
import org.bson.BSONObject;
|
||||
import com.fangjia.datastore.DataStoreException;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import java.net.InetSocketAddress;
|
||||
import com.fangjia.datastore.utils.MongoUtils;
|
||||
import com.fangjia.datastore.DataStoreContext;
|
||||
import com.fangjia.datastore.mongo.protocol.QueryMessage;
|
||||
|
||||
public class QueryMessageHandler extends MessageHandler<QueryMessage> {
|
||||
|
||||
public QueryMessageHandler(DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
public void messageReceived(QueryMessage message,String ip) throws Exception {
|
||||
Object error = null;
|
||||
try {
|
||||
String[] nameSplit = MongoUtils.parseFullCollectionName(message.getFullCollectionName());
|
||||
if (null == nameSplit) {
|
||||
error = "invalid full collection name: " + message.getFullCollectionName();
|
||||
} else {
|
||||
doMessageReceived(message, nameSplit[0], nameSplit[1]);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
IoSession session = getSession();
|
||||
String hostAddress = "";
|
||||
if(session != null && session.getRemoteAddress() instanceof InetSocketAddress) {
|
||||
hostAddress = ((InetSocketAddress)session.getRemoteAddress()).getAddress().getHostAddress();
|
||||
}
|
||||
|
||||
error = buildExceptionMessage(e);
|
||||
this.writeAsErrorMessage(message.getMessageHeader().getRequestID(), error);
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error("error process host:" + hostAddress + ",message: " + message, e);
|
||||
}
|
||||
} finally {
|
||||
this.setLastError(error);
|
||||
}
|
||||
}
|
||||
|
||||
private void doMessageReceived(QueryMessage message, String dbName, String collectionName) throws DataStoreException {
|
||||
if (collectionName.equals("$cmd")) {
|
||||
onCommand(message, dbName);
|
||||
return;
|
||||
}
|
||||
if (collectionName.equals("system.namespaces")) {
|
||||
showCollections(message, dbName, collectionName);
|
||||
} else if (collectionName.equals("system.indexes")) {
|
||||
getIndexes(message, dbName, collectionName);
|
||||
} else {
|
||||
find(message, dbName, collectionName);
|
||||
}
|
||||
}
|
||||
|
||||
private void onCommand(QueryMessage message, String dbName) throws DataStoreException {
|
||||
if (dbName.equals("admin")) {
|
||||
onAdminCommand(message);
|
||||
return;
|
||||
}
|
||||
BSONObject query = message.getQuery();
|
||||
if (query.containsField("getlasterror")) {
|
||||
getLastError(message, dbName);
|
||||
} else if (query.containsField("getpreverror")) {
|
||||
getPrevError(message, dbName);
|
||||
} else if (query.containsField("count")) {
|
||||
count(message, dbName);
|
||||
} else if (query.containsField("getSchema")) {
|
||||
getSchema(message, dbName);
|
||||
} else if (query.containsField("reIndex")) {
|
||||
reIndex(message, dbName);
|
||||
} else if (query.containsField("reload")) {
|
||||
reload(message, dbName);
|
||||
} else if(query.containsField("dbStats")){
|
||||
dbStats(message, dbName);
|
||||
} else if(query.containsField("listCollections")){
|
||||
listCollections(message, dbName);
|
||||
} else if (query.containsField("isMaster") || query.containsField("ismaster")) {
|
||||
isMaster(message);
|
||||
} else if(query.containsField("buildinfo") || query.containsField("buildInfo")){
|
||||
buildinfo(message);
|
||||
} else if(query.containsField("serverStatus")){
|
||||
serverStatus(message);
|
||||
} else if(query.containsField("connectionStatus")){
|
||||
connectionStatus(message);
|
||||
} else if (query.containsField("find")) {
|
||||
find(message, dbName, query.get("find").toString() );
|
||||
} else {
|
||||
delegateCommand(message, dbName);
|
||||
}
|
||||
}
|
||||
|
||||
private void onAdminCommand(QueryMessage message) throws DataStoreException {
|
||||
BSONObject query = message.getQuery();
|
||||
if (query.containsField("whatsmyuri")) {
|
||||
whatsMyUri(message);
|
||||
} else if (query.containsField("listDatabases")) {
|
||||
listDatabases(message);
|
||||
} else if (query.containsField("nonce")) {
|
||||
nonce(message);
|
||||
} else if (query.containsField("isMaster") || query.containsField("ismaster")) {
|
||||
isMaster(message);
|
||||
} else if(query.containsField("buildinfo") || query.containsField("buildInfo")){
|
||||
buildinfo(message);
|
||||
} else if (query.containsField("replSetGetStatus")) {
|
||||
replSetGetStatus(message);
|
||||
} else if(query.containsField("getlasterror")){
|
||||
getLastError(message, "admin");
|
||||
} else if(query.containsField("serverStatus")){
|
||||
serverStatus(message);
|
||||
} else if(query.containsField("connectionStatus")){
|
||||
connectionStatus(message);
|
||||
} else if (query.containsField("getLog")) {
|
||||
getLog(message);
|
||||
} else {
|
||||
delegateAdminCommand(message);
|
||||
}
|
||||
}
|
||||
|
||||
private void replSetGetStatus(QueryMessage message) {
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 0);
|
||||
doc.put("errmsg", "not running with --replSet");
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void delegateCommand(QueryMessage message, String dbName) throws DataStoreException {
|
||||
throw new DataStoreException("unsupported command:" + message.getQuery());
|
||||
}
|
||||
|
||||
private void getLog(QueryMessage message){
|
||||
|
||||
BasicDBList names = new BasicDBList();
|
||||
names.add("global");
|
||||
names.add("startupWarnings");
|
||||
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1);
|
||||
doc.put("names", names);
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
|
||||
}
|
||||
|
||||
private void dbStats(QueryMessage message, String dbName) throws DataStoreException {
|
||||
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("db", dbName);
|
||||
doc.put("collections", this.dataStoreContext.getDataStoreConfig().getStoreNames());
|
||||
doc.put("ok", 1.0);
|
||||
InetSocketAddress localAddress = (InetSocketAddress) this.getSession().getLocalAddress();
|
||||
doc.put("primary", localAddress.getAddress().getHostAddress());
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void delegateAdminCommand(QueryMessage message) throws DataStoreException {
|
||||
throw new DataStoreException("unsupported command:" + message.getQuery());
|
||||
}
|
||||
|
||||
private void reload(QueryMessage message, String dbName) throws DataStoreException {
|
||||
assertNotReadOnly();
|
||||
try {
|
||||
this.dataStoreContext.reload();
|
||||
this.dataStoreContext.getDataStore(dbName + "." + message.getQuery().get("reload")).reload();
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
} catch (ConfigurationException e) {
|
||||
throw new DataStoreException("error reload config: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* show collections
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
private void showCollections(QueryMessage message, String dbName, String collectionName) throws DataStoreException {
|
||||
Set<String> storeNames = this.dataStoreContext.getDataStoreConfig().getStoreNames();
|
||||
List<DBObject> docList = new ArrayList<DBObject>(storeNames.size());
|
||||
for (String sn : storeNames) {
|
||||
if (sn.startsWith(dbName + ".")) {
|
||||
docList.add(new BasicDBObject("name", sn));
|
||||
}
|
||||
}
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), docList);
|
||||
}
|
||||
|
||||
/**
|
||||
* db.foo.getIndexes()
|
||||
*
|
||||
* @param message
|
||||
* @param dbName
|
||||
* @param collectionName
|
||||
* @throwstion
|
||||
*/
|
||||
private void getIndexes(QueryMessage message, String dbName, String collectionName) throws DataStoreException {
|
||||
String ns = (String) message.getQuery().get("ns");
|
||||
Collection<Index> indexes = this.dataStoreContext.getDataStore(ns).getIndexes();
|
||||
List<BSONObject> docList = new ArrayList<BSONObject>(indexes.size());
|
||||
for (Index i : indexes) {
|
||||
docList.add(i.toBSONObject());
|
||||
}
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), docList);
|
||||
}
|
||||
|
||||
/**
|
||||
* db.foo.find()
|
||||
*
|
||||
* @param message
|
||||
* @param dbName
|
||||
* @param collectionName
|
||||
* @throws DataStoreException
|
||||
*/
|
||||
private void find(QueryMessage message, String dbName, String collectionName) throws DataStoreException {
|
||||
|
||||
String fullCollectionName;
|
||||
if(message.getFullCollectionName().contains("$cmd")){
|
||||
fullCollectionName = dbName + "." + collectionName;
|
||||
}else{
|
||||
fullCollectionName = message.getFullCollectionName();
|
||||
}
|
||||
DataStore dataStore = this.dataStoreContext.getDataStore(fullCollectionName);
|
||||
QueryResponse response = dataStore.find(message.getRealQuery(), message.getReturnFieldSelector(), message
|
||||
.getOrderByQuery(), message.getFacetQuery(), message.getNumberToSkip(), message.getNumberToReturn() - 1, message
|
||||
.isBulkQuery(), message.isFromMaster());
|
||||
ReplyMessage reply = prepareReplyMessage(message.getMessageHeader().getRequestID(), response.getDocList());
|
||||
reply.setStartingFrom(message.getNumberToSkip());
|
||||
// if (response.hasMore()) {
|
||||
// Cursor cursor = new Cursor((int) message.getNumberToSkip(), (int)
|
||||
// response.getNumReturned(), message,
|
||||
// response.getNumFound());
|
||||
// this.dataStoreContext.addCursor(cursor);
|
||||
// reply.setCursorID(cursor.getId());
|
||||
// }
|
||||
this.writeMessage(reply);
|
||||
}
|
||||
|
||||
/**
|
||||
* db.getLastError()
|
||||
*
|
||||
* @param message
|
||||
* @param dbName
|
||||
*/
|
||||
private void getLastError(QueryMessage message, String dbName) {
|
||||
Object lastError = this.getLastError();
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
doc.put("n", 1);
|
||||
doc.put("$err", lastError == null ? null : lastError.toString());
|
||||
doc.put("err", lastError == null ? null : lastError.toString());
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* db.getPrevError()
|
||||
*
|
||||
* @param message
|
||||
* @param dbName
|
||||
*/
|
||||
private void getPrevError(QueryMessage message, String dbName) {
|
||||
Object prevError = this.getPrevError();
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
doc.put("n", 0);
|
||||
doc.put("$err", prevError == null ? null : prevError.toString());
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* db.foo.count()
|
||||
*
|
||||
* @param message
|
||||
* @param dbName
|
||||
* @throws DataStoreException
|
||||
*/
|
||||
private void count(QueryMessage message, String dbName) throws DataStoreException {
|
||||
BSONObject query = message.getQuery();
|
||||
int count = this.dataStoreContext.getDataStore(dbName + "." + query.get("count")).count(message.getRealQuery(),
|
||||
message.isFromMaster());
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
doc.put("n", (double) count);
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* db.foo.rumCommnad('getSchema')
|
||||
*
|
||||
* @param message
|
||||
* @param dbName
|
||||
*/
|
||||
private void getSchema(QueryMessage message, String dbName) throws DataStoreException {
|
||||
BSONObject query = message.getQuery();
|
||||
String collectionName = (String) query.get("getSchema");
|
||||
StoreConfig storeConfig = this.dataStoreContext.getDataStore(dbName + "." + collectionName).getStoreConfig();
|
||||
Collection<Field> fields = storeConfig.getFields();
|
||||
List<DBObject> docList = new ArrayList<DBObject>(fields.size());
|
||||
for (Field field : fields) {
|
||||
BasicDBObject f = new BasicDBObject();
|
||||
f.put("name", field.getName());
|
||||
f.put("type", field.getType().getType());
|
||||
docList.add(f);
|
||||
}
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
doc.put("schema", docList);
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 不带参数重建:db.foo.reIndex() 或 db.foo.runCommand('reIndex')
|
||||
* </P>
|
||||
*
|
||||
* <p>
|
||||
* 带参数重建:db.foo.runCommand('reIndex',{query:{cat:'sell',city:'上海'}})
|
||||
* <p>
|
||||
*
|
||||
* @param message
|
||||
* @param dbName
|
||||
* @throws Exception
|
||||
*/
|
||||
private void reIndex(QueryMessage message, String dbName) throws DataStoreException {
|
||||
assertNotReadOnly();
|
||||
BSONObject query = message.getQuery();
|
||||
String collectionName = (String) query.get("reIndex");
|
||||
DataStore dataStore = this.dataStoreContext.getDataStore(dbName + "." + collectionName);
|
||||
// 新增查询条件 add by yukai 2011/07/14
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
Object realQuery = query.get("query");
|
||||
if (null == realQuery)
|
||||
doc.put("version", dataStore.reIndex(null));
|
||||
else if (realQuery instanceof BSONObject)
|
||||
dataStore.reIndex((BSONObject) realQuery);
|
||||
else
|
||||
throw new DataStoreException("invalid re-index query: " + realQuery);
|
||||
doc.put("ok", 1.0);
|
||||
doc.put("n", 0D);
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* db.runCommand('whatsmyuri')
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
private void whatsMyUri(QueryMessage message) {
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
InetSocketAddress address = (InetSocketAddress) getSession().getRemoteAddress();
|
||||
doc.put("you", address.getAddress().getHostAddress() + ":" + address.getPort());
|
||||
doc.put("ok", 1.0);
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* show dbs
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
private void listDatabases(QueryMessage message) {
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
Set<String> storeNames = this.dataStoreContext.getDataStoreConfig().getStoreNames();
|
||||
Set<String> dbNames = new HashSet<String>();
|
||||
for (String sn : storeNames) {
|
||||
int i = sn.indexOf('.');
|
||||
if (i > 0) {
|
||||
String name = sn.substring(0, i);
|
||||
dbNames.add(name);
|
||||
}
|
||||
}
|
||||
List<DBObject> docs = new ArrayList<DBObject>(dbNames.size());
|
||||
for (String dn : dbNames) {
|
||||
docs.add(new BasicDBObject("name", dn));
|
||||
}
|
||||
doc.put("databases", docs);
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* show dbs
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
private void listCollections(QueryMessage message, String dbName) {
|
||||
System.out.println(message.getMessageHeader().getRequestID());
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
BSONObject cursor = new BasicDBObject();
|
||||
doc.put("cursor", cursor);
|
||||
|
||||
cursor.put("id", (long)message.getMessageHeader().getRequestID());
|
||||
cursor.put("ns", dbName + ".$cmd.listCollections");
|
||||
BasicDBList firstBatch = new BasicDBList();
|
||||
cursor.put("firstBatch", firstBatch);
|
||||
Set<String> storeNames = this.dataStoreContext.getDataStoreConfig().getStoreNames();
|
||||
for (String sn : storeNames) {
|
||||
if (sn.startsWith(dbName + ".")) {
|
||||
BSONObject collection = new BasicDBObject();
|
||||
collection.put("name", sn.replace(dbName + ".", ""));
|
||||
collection.put("options", new BasicDBObject());
|
||||
firstBatch.add(collection);
|
||||
}
|
||||
}
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* db.runCommand('nonce')
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
private void nonce(QueryMessage message) {
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
doc.put("errmsg", "no such cmd");
|
||||
doc.put("bad cmd", new BasicBSONObject("nonce", true));
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void isMaster(QueryMessage message) {
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
doc.put("ismaster", true);
|
||||
doc.put("secondary", false);
|
||||
InetSocketAddress localAddress = (InetSocketAddress) this.getSession().getLocalAddress();
|
||||
doc.put("primary", localAddress.getAddress().getHostAddress());
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void buildinfo(QueryMessage message) {
|
||||
BasicDBList versionArray = new BasicDBList();
|
||||
versionArray.add(3);
|
||||
versionArray.add(2);
|
||||
versionArray.add(9);
|
||||
versionArray.add(0);
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
doc.put("bits", 64.0);
|
||||
doc.put("debug", false);
|
||||
doc.put("version" ,"3.2.9");
|
||||
doc.put("versionArray" ,versionArray);
|
||||
doc.put("javascriptEngine", "V8");
|
||||
InetSocketAddress localAddress = (InetSocketAddress) this.getSession().getLocalAddress();
|
||||
doc.put("primary", localAddress.getAddress().getHostAddress());
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void serverStatus(QueryMessage message){
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
InetSocketAddress localAddress = (InetSocketAddress) this.getSession().getLocalAddress();
|
||||
doc.put("primary", localAddress.getAddress().getHostAddress());
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void connectionStatus(QueryMessage message){
|
||||
BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
InetSocketAddress localAddress = (InetSocketAddress) this.getSession().getLocalAddress();
|
||||
doc.put("primary", localAddress.getAddress().getHostAddress());
|
||||
writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
|
||||
public class QueryMessageHandler extends MessageHandler<QueryMessage>
|
||||
{
|
||||
public QueryMessageHandler(final DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final QueryMessage message) throws Exception {
|
||||
Object error = null;
|
||||
try {
|
||||
final String[] nameSplit = MongoUtils.parseFullCollectionName(message.getFullCollectionName());
|
||||
if (null == nameSplit) {
|
||||
error = "invalid full collection name: " + message.getFullCollectionName();
|
||||
}
|
||||
else {
|
||||
this.doMessageReceived(message, nameSplit[0], nameSplit[1]);
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
final IoSession session = this.getSession();
|
||||
String hostAddress = "";
|
||||
if (session != null && session.getRemoteAddress() instanceof InetSocketAddress) {
|
||||
hostAddress = ((InetSocketAddress)session.getRemoteAddress()).getAddress().getHostAddress();
|
||||
}
|
||||
error = this.buildExceptionMessage(e);
|
||||
this.writeAsErrorMessage(message.getMessageHeader().getRequestID(), error);
|
||||
if (this.logger.isErrorEnabled()) {
|
||||
this.logger.error("error process host:" + hostAddress + ",message: " + message, e);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
this.setLastError(error);
|
||||
}
|
||||
}
|
||||
|
||||
private void doMessageReceived(final QueryMessage message, final String dbName, final String collectionName) throws DataStoreException {
|
||||
if (collectionName.equals("$cmd")) {
|
||||
this.onCommand(message, dbName);
|
||||
return;
|
||||
}
|
||||
if (collectionName.equals("system.namespaces")) {
|
||||
this.showCollections(message, dbName, collectionName);
|
||||
}
|
||||
else if (collectionName.equals("system.indexes")) {
|
||||
this.getIndexes(message, dbName, collectionName);
|
||||
}
|
||||
else {
|
||||
this.find(message, dbName, collectionName);
|
||||
}
|
||||
}
|
||||
|
||||
private void onCommand(final QueryMessage message, final String dbName) throws DataStoreException {
|
||||
if (dbName.equals("admin")) {
|
||||
this.onAdminCommand(message);
|
||||
return;
|
||||
}
|
||||
final BSONObject query = message.getQuery();
|
||||
if (query.containsField("getlasterror")) {
|
||||
this.getLastError(message, dbName);
|
||||
}
|
||||
else if (query.containsField("getpreverror")) {
|
||||
this.getPrevError(message, dbName);
|
||||
}
|
||||
else if (query.containsField("count")) {
|
||||
this.count(message, dbName);
|
||||
}
|
||||
else if (query.containsField("getSchema")) {
|
||||
this.getSchema(message, dbName);
|
||||
}
|
||||
else if (query.containsField("reIndex")) {
|
||||
this.reIndex(message, dbName);
|
||||
}
|
||||
else if (query.containsField("reload")) {
|
||||
this.reload(message, dbName);
|
||||
}
|
||||
else if (query.containsField("dbStats")) {
|
||||
this.dbStats(message, dbName);
|
||||
}
|
||||
else if (query.containsField("listCollections")) {
|
||||
this.listCollections(message, dbName);
|
||||
}
|
||||
else if (query.containsField("isMaster") || query.containsField("ismaster")) {
|
||||
this.isMaster(message);
|
||||
}
|
||||
else if (query.containsField("buildinfo") || query.containsField("buildInfo")) {
|
||||
this.buildinfo(message);
|
||||
}
|
||||
else if (query.containsField("serverStatus")) {
|
||||
this.serverStatus(message);
|
||||
}
|
||||
else if (query.containsField("connectionStatus")) {
|
||||
this.connectionStatus(message);
|
||||
}
|
||||
else if (query.containsField("update")) {
|
||||
this.update(message, dbName);
|
||||
}
|
||||
else if (query.containsField("insert")) {
|
||||
this.insert(message, dbName);
|
||||
}
|
||||
else if (query.containsField("ping")) {
|
||||
this.ping(message);
|
||||
}
|
||||
else if (query.containsField("find")) {
|
||||
this.find(message, dbName, query.get("find").toString());
|
||||
}
|
||||
else {
|
||||
this.delegateCommand(message, dbName);
|
||||
}
|
||||
}
|
||||
|
||||
private void onAdminCommand(final QueryMessage message) throws DataStoreException {
|
||||
final BSONObject query = message.getQuery();
|
||||
if (query.containsField("whatsmyuri")) {
|
||||
this.whatsMyUri(message);
|
||||
}
|
||||
else if (query.containsField("listDatabases")) {
|
||||
this.listDatabases(message);
|
||||
}
|
||||
else if (query.containsField("nonce")) {
|
||||
this.nonce(message);
|
||||
}
|
||||
else if (query.containsField("isMaster") || query.containsField("ismaster")) {
|
||||
this.isMaster(message);
|
||||
}
|
||||
else if (query.containsField("buildinfo") || query.containsField("buildInfo")) {
|
||||
this.buildinfo(message);
|
||||
}
|
||||
else if (query.containsField("replSetGetStatus")) {
|
||||
this.replSetGetStatus(message);
|
||||
}
|
||||
else if (query.containsField("getlasterror")) {
|
||||
this.getLastError(message, "admin");
|
||||
}
|
||||
else if (query.containsField("serverStatus")) {
|
||||
this.serverStatus(message);
|
||||
}
|
||||
else if (query.containsField("connectionStatus")) {
|
||||
this.connectionStatus(message);
|
||||
}
|
||||
else if (query.containsField("collstats")) {
|
||||
this.collstats(message);
|
||||
}
|
||||
else if (query.containsField("getLog")) {
|
||||
this.getLog(message);
|
||||
}
|
||||
else if (query.containsField("ping")) {
|
||||
this.ping(message);
|
||||
}
|
||||
else {
|
||||
this.delegateAdminCommand(message);
|
||||
}
|
||||
}
|
||||
|
||||
private void replSetGetStatus(final QueryMessage message) {
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)0);
|
||||
doc.put("errmsg", (Object)"not running with --replSet");
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void delegateCommand(final QueryMessage message, final String dbName) throws DataStoreException {
|
||||
throw new DataStoreException("unsupported command:" + message.getQuery());
|
||||
}
|
||||
|
||||
private void collstats(final QueryMessage message) {
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1);
|
||||
doc.put("ns", (Object)message.getFullCollectionName());
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void ping(final QueryMessage message) throws DataStoreException {
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1);
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void update(final QueryMessage message, final String dbName) throws DataStoreException {
|
||||
final DataStore dataStore = this.dataStoreContext.getDataStore(dbName + "." + message.getQuery().get("update"));
|
||||
final BasicBSONList updates = (BasicBSONList)message.getQuery().get("updates");
|
||||
final BSONObject selector = (BSONObject)((BasicBSONObject)updates.get(0)).get("q");
|
||||
final BSONObject update = (BSONObject)((BasicBSONObject)updates.get(0)).get("u");
|
||||
final int count = dataStore.update(selector, update);
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("nModified", (Object)count);
|
||||
doc.put("n", (Object)count);
|
||||
doc.put("ok", (Object)1);
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void insert(final QueryMessage message, final String dbName) throws DataStoreException {
|
||||
final DataStore dataStore = this.dataStoreContext.getDataStore(dbName + "." + message.getQuery().get("insert"));
|
||||
final List documents = (List)message.getQuery().get("documents");
|
||||
dataStore.save(documents);
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("n", (Object)documents.size());
|
||||
doc.put("ok", (Object)1);
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void getLog(final QueryMessage message) {
|
||||
final BasicDBList names = new BasicDBList();
|
||||
names.add((Object)"global");
|
||||
names.add((Object)"startupWarnings");
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1);
|
||||
doc.put("names", (Object)names);
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void dbStats(final QueryMessage message, final String dbName) throws DataStoreException {
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("db", (Object)dbName);
|
||||
doc.put("collections", (Object)this.dataStoreContext.getDataStoreConfig().getStoreNames());
|
||||
doc.put("ok", (Object)1.0);
|
||||
final InetSocketAddress localAddress = (InetSocketAddress)this.getSession().getLocalAddress();
|
||||
doc.put("primary", (Object)localAddress.getAddress().getHostAddress());
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void delegateAdminCommand(final QueryMessage message) throws DataStoreException {
|
||||
throw new DataStoreException("unsupported command:" + message.getQuery());
|
||||
}
|
||||
|
||||
private void reload(final QueryMessage message, final String dbName) throws DataStoreException {
|
||||
this.assertNotReadOnly();
|
||||
try {
|
||||
this.dataStoreContext.reload();
|
||||
this.dataStoreContext.getDataStore(dbName + "." + message.getQuery().get("reload")).reload();
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1.0);
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
catch (ConfigurationException e) {
|
||||
throw new DataStoreException("error reload config: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void showCollections(final QueryMessage message, final String dbName, final String collectionName) throws DataStoreException {
|
||||
final Set<String> storeNames = this.dataStoreContext.getDataStoreConfig().getStoreNames();
|
||||
final List<DBObject> docList = new ArrayList<DBObject>(storeNames.size());
|
||||
for (final String sn : storeNames) {
|
||||
if (sn.startsWith(dbName + ".")) {
|
||||
docList.add((DBObject)new BasicDBObject("name", (Object)sn));
|
||||
}
|
||||
}
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), (List<? extends BSONObject>)docList);
|
||||
}
|
||||
|
||||
private void getIndexes(final QueryMessage message, final String dbName, final String collectionName) throws DataStoreException {
|
||||
final String ns = (String)message.getQuery().get("ns");
|
||||
final Collection<Index> indexes = this.dataStoreContext.getDataStore(ns).getIndexes();
|
||||
final List<BSONObject> docList = new ArrayList<BSONObject>(indexes.size());
|
||||
for (final Index i : indexes) {
|
||||
docList.add(i.toBSONObject());
|
||||
}
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), docList);
|
||||
}
|
||||
|
||||
private void find(final QueryMessage message, final String dbName, final String collectionName) throws DataStoreException {
|
||||
String fullCollectionName;
|
||||
if (message.getFullCollectionName().contains("$cmd")) {
|
||||
fullCollectionName = dbName + "." + collectionName;
|
||||
}
|
||||
else {
|
||||
fullCollectionName = message.getFullCollectionName();
|
||||
}
|
||||
final DataStore dataStore = this.dataStoreContext.getDataStore(fullCollectionName);
|
||||
QueryResponse response;
|
||||
if (this.useCursor()) {
|
||||
response = dataStore.find(message.getRealQuery(), message.getReturnFieldSelector(), message.getOrderByQuery(), message.getFacetQuery(), message.getNumberToSkip(), message.getNumberToReturn(), message.isBulkQuery(), message.isFromMaster());
|
||||
}
|
||||
else {
|
||||
response = dataStore.find(message.getRealQuery(), message.getReturnFieldSelector(), message.getOrderByQuery(), message.getFacetQuery(), message.getNumberToSkip(), message.getNumberToReturn() - 1, message.isBulkQuery(), message.isFromMaster());
|
||||
}
|
||||
final List<DBObject> doc = response.getDocList();
|
||||
if (this.useCursor()) {
|
||||
doc.remove(0);
|
||||
}
|
||||
final ReplyMessage reply = this.prepareReplyMessage(message.getMessageHeader().getRequestID(), (List<? extends BSONObject>)doc);
|
||||
reply.setStartingFrom(message.getNumberToSkip());
|
||||
if (response.hasMore() && this.useCursor()) {
|
||||
final Cursor cursor = new Cursor(message.getNumberToSkip(), message.getNumberToReturn(), message, response.getNumFound());
|
||||
this.dataStoreContext.addCursor(cursor);
|
||||
reply.setCursorID(cursor.getId());
|
||||
}
|
||||
this.writeMessage(reply);
|
||||
}
|
||||
|
||||
private void getLastError(final QueryMessage message, final String dbName) {
|
||||
final Object lastError = this.getLastError();
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1.0);
|
||||
doc.put("n", (Object)1);
|
||||
doc.put("$err", (Object)((lastError == null) ? null : lastError.toString()));
|
||||
doc.put("err", (Object)((lastError == null) ? null : lastError.toString()));
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void getPrevError(final QueryMessage message, final String dbName) {
|
||||
final Object prevError = this.getPrevError();
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1.0);
|
||||
doc.put("n", (Object)0);
|
||||
doc.put("$err", (Object)((prevError == null) ? null : prevError.toString()));
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void count(final QueryMessage message, final String dbName) throws DataStoreException {
|
||||
final BSONObject query = message.getQuery();
|
||||
final int count = this.dataStoreContext.getDataStore(dbName + "." + query.get("count")).count(message.getRealQuery(), message.isFromMaster());
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1.0);
|
||||
doc.put("n", (Object)(double)count);
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void getSchema(final QueryMessage message, final String dbName) throws DataStoreException {
|
||||
final BSONObject query = message.getQuery();
|
||||
final String collectionName = (String)query.get("getSchema");
|
||||
final StoreConfig storeConfig = this.dataStoreContext.getDataStore(dbName + "." + collectionName).getStoreConfig();
|
||||
final Collection<Field> fields = storeConfig.getFields();
|
||||
final List<DBObject> docList = new ArrayList<DBObject>(fields.size());
|
||||
for (final Field field : fields) {
|
||||
final BasicDBObject f = new BasicDBObject();
|
||||
f.put("name", field.getName());
|
||||
f.put("type", field.getType().getType());
|
||||
docList.add(f);
|
||||
}
|
||||
final BSONObject doc = new BasicBSONObject();
|
||||
doc.put("ok", 1.0);
|
||||
doc.put("schema", docList);
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void reIndex(final QueryMessage message, final String dbName) throws DataStoreException {
|
||||
this.assertNotReadOnly();
|
||||
final BSONObject query = message.getQuery();
|
||||
final String collectionName = (String)query.get("reIndex");
|
||||
final DataStore dataStore = this.dataStoreContext.getDataStore(dbName + "." + collectionName);
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
final Object realQuery = query.get("query");
|
||||
if (null == realQuery) {
|
||||
doc.put("version", (Object)dataStore.reIndex(null));
|
||||
}
|
||||
else {
|
||||
if (!(realQuery instanceof BSONObject)) {
|
||||
throw new DataStoreException("invalid re-index query: " + realQuery);
|
||||
}
|
||||
dataStore.reIndex((BSONObject)realQuery);
|
||||
}
|
||||
doc.put("ok", (Object)1.0);
|
||||
doc.put("n", (Object)0.0);
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void whatsMyUri(final QueryMessage message) {
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
final InetSocketAddress address = (InetSocketAddress)this.getSession().getRemoteAddress();
|
||||
doc.put("you", (Object)(address.getAddress().getHostAddress() + ":" + address.getPort()));
|
||||
doc.put("ok", (Object)1.0);
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void listDatabases(final QueryMessage message) {
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1.0);
|
||||
final Set<String> storeNames = this.dataStoreContext.getDataStoreConfig().getStoreNames();
|
||||
final Set<String> dbNames = new HashSet<String>();
|
||||
for (final String sn : storeNames) {
|
||||
final int i = sn.indexOf(46);
|
||||
if (i > 0) {
|
||||
final String name = sn.substring(0, i);
|
||||
dbNames.add(name);
|
||||
}
|
||||
}
|
||||
final List<DBObject> docs = new ArrayList<DBObject>(dbNames.size());
|
||||
for (final String dn : dbNames) {
|
||||
docs.add((DBObject)new BasicDBObject("name", (Object)dn));
|
||||
}
|
||||
doc.put("databases", (Object)docs);
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void listCollections(final QueryMessage message, final String dbName) {
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1.0);
|
||||
final BSONObject cursor = (BSONObject)new BasicDBObject();
|
||||
doc.put("cursor", (Object)cursor);
|
||||
cursor.put("id", (Object)(long)message.getMessageHeader().getRequestID());
|
||||
cursor.put("ns", (Object)(dbName + ".$cmd.listCollections"));
|
||||
final BasicDBList firstBatch = new BasicDBList();
|
||||
cursor.put("firstBatch", (Object)firstBatch);
|
||||
final Set<String> storeNames = this.dataStoreContext.getDataStoreConfig().getStoreNames();
|
||||
for (final String sn : storeNames) {
|
||||
if (sn.startsWith(dbName + ".")) {
|
||||
final BSONObject collection = (BSONObject)new BasicDBObject();
|
||||
collection.put("name", (Object)sn.replace(dbName + ".", ""));
|
||||
collection.put("options", (Object)new BasicDBObject());
|
||||
firstBatch.add((Object)collection);
|
||||
}
|
||||
}
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void nonce(final QueryMessage message) {
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1.0);
|
||||
doc.put("errmsg", (Object)"no such cmd");
|
||||
doc.put("bad cmd", (Object)new BasicBSONObject("nonce", (Object)true));
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void isMaster(final QueryMessage message) {
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1.0);
|
||||
doc.put("ismaster", (Object)true);
|
||||
doc.put("secondary", (Object)false);
|
||||
final InetSocketAddress localAddress = (InetSocketAddress)this.getSession().getLocalAddress();
|
||||
doc.put("primary", (Object)localAddress.getAddress().getHostAddress());
|
||||
doc.put("maxWireVersion", (Object)2);
|
||||
doc.put("minWireVersion", (Object)0);
|
||||
final BasicBSONObject client = (BasicBSONObject)message.getQuery().get("client");
|
||||
if (client != null) {
|
||||
final String platform = client.getString("platform");
|
||||
if (platform != null && (platform.contains("python") || platform.contains("Python"))) {
|
||||
this.getSession().setAttribute((Object)"useCursor", (Object)true);
|
||||
}
|
||||
final BasicBSONObject applicationInfo = (BasicBSONObject)client.get("application");
|
||||
if (applicationInfo != null && StringUtils.isNotBlank(applicationInfo.getString("name"))) {
|
||||
this.getSession().setAttribute((Object)"useCursor", (Object)true);
|
||||
}
|
||||
}
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void buildinfo(final QueryMessage message) {
|
||||
final BasicDBList versionArray = new BasicDBList();
|
||||
versionArray.add((Object)2);
|
||||
versionArray.add((Object)6);
|
||||
versionArray.add((Object)8);
|
||||
versionArray.add((Object)0);
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1.0);
|
||||
doc.put("bits", (Object)64.0);
|
||||
doc.put("debug", (Object)false);
|
||||
doc.put("version", (Object)"2.6.8");
|
||||
doc.put("versionArray", (Object)versionArray);
|
||||
doc.put("javascriptEngine", (Object)"V8");
|
||||
final InetSocketAddress localAddress = (InetSocketAddress)this.getSession().getLocalAddress();
|
||||
doc.put("primary", (Object)localAddress.getAddress().getHostAddress());
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void serverStatus(final QueryMessage message) {
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1.0);
|
||||
final InetSocketAddress localAddress = (InetSocketAddress)this.getSession().getLocalAddress();
|
||||
doc.put("primary", (Object)localAddress.getAddress().getHostAddress());
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
|
||||
private void connectionStatus(final QueryMessage message) {
|
||||
final BSONObject doc = (BSONObject)new BasicBSONObject();
|
||||
doc.put("ok", (Object)1.0);
|
||||
final InetSocketAddress localAddress = (InetSocketAddress)this.getSession().getLocalAddress();
|
||||
doc.put("primary", (Object)localAddress.getAddress().getHostAddress());
|
||||
this.writeAsReplyMessage(message.getMessageHeader().getRequestID(), doc);
|
||||
}
|
||||
}
|
||||
|
||||
+20
-20
@@ -1,27 +1,27 @@
|
||||
package com.fangjia.datastore.handler;
|
||||
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import com.fangjia.datastore.DataStore;
|
||||
import com.fangjia.datastore.DataStoreContext;
|
||||
import com.fangjia.datastore.DataStoreException;
|
||||
import com.fangjia.datastore.DataStoreContext;
|
||||
import com.fangjia.datastore.mongo.protocol.UpdateMessage;
|
||||
|
||||
public class UpdateMessageHandler extends MessageHandler<UpdateMessage> {
|
||||
|
||||
public UpdateMessageHandler(DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
public void messageReceived(UpdateMessage message,String ip) throws Exception {
|
||||
assertNotReadOnly();
|
||||
if (message.isUpsert()) {
|
||||
throw new DataStoreException("upsert is not supported.");
|
||||
}
|
||||
if (!message.isMultiUpdate()) {
|
||||
throw new DataStoreException("only multi update is supported.");
|
||||
}
|
||||
|
||||
DataStore dataStore = this.dataStoreContext.getDataStore(message.getFullCollectionName());
|
||||
dataStore.update(message.getSelector(), message.getUpdate(),ip);
|
||||
}
|
||||
|
||||
public class UpdateMessageHandler extends MessageHandler<UpdateMessage>
|
||||
{
|
||||
public UpdateMessageHandler(final DataStoreContext dataStoreContext) {
|
||||
super(dataStoreContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final UpdateMessage message) throws Exception {
|
||||
this.assertNotReadOnly();
|
||||
if (message.isUpsert()) {
|
||||
throw new DataStoreException("upsert is not supported.");
|
||||
}
|
||||
if (!message.isMultiUpdate()) {
|
||||
throw new DataStoreException("only multi update is supported.");
|
||||
}
|
||||
final DataStore dataStore = this.dataStoreContext.getDataStore(message.getFullCollectionName());
|
||||
dataStore.update(message.getSelector(), message.getUpdate());
|
||||
}
|
||||
}
|
||||
|
||||
+69
-86
@@ -1,92 +1,75 @@
|
||||
/**
|
||||
* JMongo is a mongodb driver writtern in java.
|
||||
* Copyright (C) 2010 Xiaohu Huang
|
||||
*
|
||||
* JMongo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* JMongo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JMongo. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.fangjia.datastore.mongo.codec;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
public class BSONInputStream extends InputStream {
|
||||
private final IoBuffer buffer;
|
||||
|
||||
public BSONInputStream(IoBuffer buffer) {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return buffer.get();
|
||||
}
|
||||
|
||||
public synchronized int read(byte b[], int off, int len) {
|
||||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
} else if (off < 0 || len < 0 || len > b.length - off) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
buffer.get(b, off, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
public int readInteger() {
|
||||
return this.buffer.getInt();
|
||||
}
|
||||
|
||||
public long readLong() {
|
||||
return this.buffer.getLong();
|
||||
}
|
||||
|
||||
public double readDouble() {
|
||||
return this.buffer.getDouble();
|
||||
}
|
||||
|
||||
public String readCString() throws IOException {
|
||||
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
|
||||
int b;
|
||||
while (true) {
|
||||
b = read();
|
||||
if (b != 0) {
|
||||
byteStream.write(b);
|
||||
} else {
|
||||
return new String(byteStream.toByteArray(), "UTF-8");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String readString() throws IOException {
|
||||
int len = readInteger();
|
||||
if (len < 0) {
|
||||
throw new IOException("can not read string from the stream");
|
||||
}
|
||||
if (len == 0) {
|
||||
read();
|
||||
return "";
|
||||
}
|
||||
byte[] buf = new byte[len];
|
||||
read(buf);
|
||||
return new String(buf, 0, len - 1, "UTF-8");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return buffer.remaining();
|
||||
}
|
||||
|
||||
public class BSONInputStream extends InputStream
|
||||
{
|
||||
private final IoBuffer buffer;
|
||||
|
||||
public BSONInputStream(final IoBuffer buffer) {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return this.buffer.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int read(final byte[] b, final int off, final int len) {
|
||||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (off < 0 || len < 0 || len > b.length - off) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
this.buffer.get(b, off, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
public int readInteger() {
|
||||
return this.buffer.getInt();
|
||||
}
|
||||
|
||||
public long readLong() {
|
||||
return this.buffer.getLong();
|
||||
}
|
||||
|
||||
public double readDouble() {
|
||||
return this.buffer.getDouble();
|
||||
}
|
||||
|
||||
public String readCString() throws IOException {
|
||||
final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
|
||||
while (true) {
|
||||
final int b = this.read();
|
||||
if (b == 0) {
|
||||
break;
|
||||
}
|
||||
byteStream.write(b);
|
||||
}
|
||||
return new String(byteStream.toByteArray(), "UTF-8");
|
||||
}
|
||||
|
||||
public String readString() throws IOException {
|
||||
final int len = this.readInteger();
|
||||
if (len < 0) {
|
||||
throw new IOException("can not read string from the stream");
|
||||
}
|
||||
if (len == 0) {
|
||||
this.read();
|
||||
return "";
|
||||
}
|
||||
final byte[] buf = new byte[len];
|
||||
this.read(buf);
|
||||
return new String(buf, 0, len - 1, "UTF-8");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return this.buffer.remaining();
|
||||
}
|
||||
}
|
||||
|
||||
+76
-88
@@ -1,95 +1,83 @@
|
||||
package com.fangjia.datastore.mongo.codec;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.AbstractIoBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ByteBuffer;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.buffer.IoBufferAllocator;
|
||||
|
||||
public class BSONIoBufferAllocator implements IoBufferAllocator {
|
||||
|
||||
public IoBuffer allocate(int capacity, boolean direct) {
|
||||
return wrap(allocateNioBuffer(capacity, direct));
|
||||
}
|
||||
|
||||
public ByteBuffer allocateNioBuffer(int capacity, boolean direct) {
|
||||
ByteBuffer nioBuffer;
|
||||
if (direct) {
|
||||
nioBuffer = ByteBuffer.allocateDirect(capacity);
|
||||
} else {
|
||||
nioBuffer = ByteBuffer.allocate(capacity);
|
||||
}
|
||||
nioBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
return nioBuffer;
|
||||
}
|
||||
|
||||
public IoBuffer wrap(ByteBuffer nioBuffer) {
|
||||
return new SimpleBuffer(nioBuffer);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
private class SimpleBuffer extends AbstractIoBuffer {
|
||||
private ByteBuffer buf;
|
||||
|
||||
protected SimpleBuffer(ByteBuffer buf) {
|
||||
super(BSONIoBufferAllocator.this, buf.capacity());
|
||||
this.buf = buf;
|
||||
this.buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
protected SimpleBuffer(SimpleBuffer parent, ByteBuffer buf) {
|
||||
super(parent);
|
||||
this.buf = buf;
|
||||
this.buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer buf() {
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buf(ByteBuffer buf) {
|
||||
this.buf = buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IoBuffer duplicate0() {
|
||||
return new SimpleBuffer(this, this.buf.duplicate());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IoBuffer slice0() {
|
||||
return new SimpleBuffer(this, this.buf.slice());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IoBuffer asReadOnlyBuffer0() {
|
||||
return new SimpleBuffer(this, this.buf.asReadOnlyBuffer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] array() {
|
||||
return buf.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int arrayOffset() {
|
||||
return buf.arrayOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArray() {
|
||||
return buf.hasArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void free() {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
public class BSONIoBufferAllocator implements IoBufferAllocator
|
||||
{
|
||||
public IoBuffer allocate(final int capacity, final boolean direct) {
|
||||
return this.wrap(this.allocateNioBuffer(capacity, direct));
|
||||
}
|
||||
|
||||
public ByteBuffer allocateNioBuffer(final int capacity, final boolean direct) {
|
||||
ByteBuffer nioBuffer;
|
||||
if (direct) {
|
||||
nioBuffer = ByteBuffer.allocateDirect(capacity);
|
||||
}
|
||||
else {
|
||||
nioBuffer = ByteBuffer.allocate(capacity);
|
||||
}
|
||||
nioBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
return nioBuffer;
|
||||
}
|
||||
|
||||
public IoBuffer wrap(final ByteBuffer nioBuffer) {
|
||||
return (IoBuffer)new SimpleBuffer(nioBuffer);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
private class SimpleBuffer extends AbstractIoBuffer
|
||||
{
|
||||
private ByteBuffer buf;
|
||||
|
||||
protected SimpleBuffer(final ByteBuffer buf) {
|
||||
super((IoBufferAllocator)BSONIoBufferAllocator.this, buf.capacity());
|
||||
(this.buf = buf).order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
protected SimpleBuffer(final SimpleBuffer parent, final ByteBuffer buf) {
|
||||
super((AbstractIoBuffer)parent);
|
||||
(this.buf = buf).order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
public ByteBuffer buf() {
|
||||
return this.buf;
|
||||
}
|
||||
|
||||
protected void buf(final ByteBuffer buf) {
|
||||
this.buf = buf;
|
||||
}
|
||||
|
||||
protected IoBuffer duplicate0() {
|
||||
return (IoBuffer)new SimpleBuffer(this, this.buf.duplicate());
|
||||
}
|
||||
|
||||
protected IoBuffer slice0() {
|
||||
return (IoBuffer)new SimpleBuffer(this, this.buf.slice());
|
||||
}
|
||||
|
||||
protected IoBuffer asReadOnlyBuffer0() {
|
||||
return (IoBuffer)new SimpleBuffer(this, this.buf.asReadOnlyBuffer());
|
||||
}
|
||||
|
||||
public byte[] array() {
|
||||
return this.buf.array();
|
||||
}
|
||||
|
||||
public int arrayOffset() {
|
||||
return this.buf.arrayOffset();
|
||||
}
|
||||
|
||||
public boolean hasArray() {
|
||||
return this.buf.hasArray();
|
||||
}
|
||||
|
||||
public void free() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+79
-97
@@ -1,102 +1,84 @@
|
||||
/**
|
||||
* JMongo is a mongodb driver writtern in java.
|
||||
* Copyright (C) 2010 Xiaohu Huang
|
||||
*
|
||||
* JMongo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* JMongo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JMongo. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.fangjia.datastore.mongo.codec;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.io.IOException;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
public class BSONOutputStream extends ByteArrayOutputStream {
|
||||
|
||||
private static final String ENCDOING = "UTF-8";
|
||||
|
||||
public BSONOutputStream() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BSONOutputStream(int size) {
|
||||
super(size);
|
||||
}
|
||||
|
||||
public void writeCString(String s) throws IOException {
|
||||
write(s.getBytes(ENCDOING));
|
||||
write(0);
|
||||
}
|
||||
|
||||
public void writeInteger(int i) throws IOException {
|
||||
write(i);
|
||||
write(i >> 8);
|
||||
write(i >> 16);
|
||||
write(i >> 24);
|
||||
}
|
||||
|
||||
public void writeLong(long l) throws IOException {
|
||||
write((byte) l);
|
||||
write((byte) (l >> 8));
|
||||
write((byte) (l >> 16));
|
||||
write((byte) (l >> 24));
|
||||
write((byte) (l >> 32));
|
||||
write((byte) (l >> 40));
|
||||
write((byte) (l >> 48));
|
||||
write((byte) (l >> 56));
|
||||
}
|
||||
|
||||
public void writeString(String s) throws IOException {
|
||||
byte[] bs = s.getBytes(ENCDOING);
|
||||
writeInteger(bs.length + 1);
|
||||
write(bs);
|
||||
write(0);
|
||||
}
|
||||
|
||||
public void set(int index, int i) {
|
||||
int newcount = Math.max(count, index + 4);
|
||||
if (newcount > buf.length) {
|
||||
buf = Arrays.copyOf(buf, Math.max(buf.length << 1, newcount));
|
||||
}
|
||||
buf[index] = (byte) i;
|
||||
buf[index + 1] = (byte) (i >> 8);
|
||||
buf[index + 2] = (byte) (i >> 16);
|
||||
buf[index + 3] = (byte) (i >> 24);
|
||||
count = newcount;
|
||||
}
|
||||
|
||||
public void set(int index, byte[] b, int off, int len) {
|
||||
if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} else if (len == 0) {
|
||||
return;
|
||||
}
|
||||
int newcount = Math.max(count, index + len);
|
||||
if (newcount > buf.length) {
|
||||
buf = Arrays.copyOf(buf, Math.max(buf.length << 1, newcount));
|
||||
}
|
||||
System.arraycopy(b, off, buf, index, len);
|
||||
count = newcount;
|
||||
}
|
||||
|
||||
public void setInteger(int index, int i) {
|
||||
byte[] b = new byte[] { (byte) i, (byte) (i >> 8), (byte) (i >> 16), (byte) (i >> 24) };
|
||||
set(index, b, 0, b.length);
|
||||
}
|
||||
|
||||
public void setLong(int index, long l) {
|
||||
byte[] b = new byte[] { (byte) l, (byte) (l >> 8), (byte) (l >> 16), (byte) (l >> 24), (byte) (l >> 32),
|
||||
(byte) (l >> 40), (byte) (l >> 48), (byte) (l >> 56) };
|
||||
set(index, b, 0, b.length);
|
||||
}
|
||||
public class BSONOutputStream extends ByteArrayOutputStream
|
||||
{
|
||||
private static final String ENCDOING = "UTF-8";
|
||||
|
||||
public BSONOutputStream() {
|
||||
}
|
||||
|
||||
public BSONOutputStream(final int size) {
|
||||
super(size);
|
||||
}
|
||||
|
||||
public void writeCString(final String s) throws IOException {
|
||||
this.write(s.getBytes("UTF-8"));
|
||||
this.write(0);
|
||||
}
|
||||
|
||||
public void writeInteger(final int i) throws IOException {
|
||||
this.write(i);
|
||||
this.write(i >> 8);
|
||||
this.write(i >> 16);
|
||||
this.write(i >> 24);
|
||||
}
|
||||
|
||||
public void writeLong(final long l) throws IOException {
|
||||
this.write((byte)l);
|
||||
this.write((byte)(l >> 8));
|
||||
this.write((byte)(l >> 16));
|
||||
this.write((byte)(l >> 24));
|
||||
this.write((byte)(l >> 32));
|
||||
this.write((byte)(l >> 40));
|
||||
this.write((byte)(l >> 48));
|
||||
this.write((byte)(l >> 56));
|
||||
}
|
||||
|
||||
public void writeString(final String s) throws IOException {
|
||||
final byte[] bs = s.getBytes("UTF-8");
|
||||
this.writeInteger(bs.length + 1);
|
||||
this.write(bs);
|
||||
this.write(0);
|
||||
}
|
||||
|
||||
public void set(final int index, final int i) {
|
||||
final int newcount = Math.max(this.count, index + 4);
|
||||
if (newcount > this.buf.length) {
|
||||
this.buf = Arrays.copyOf(this.buf, Math.max(this.buf.length << 1, newcount));
|
||||
}
|
||||
this.buf[index] = (byte)i;
|
||||
this.buf[index + 1] = (byte)(i >> 8);
|
||||
this.buf[index + 2] = (byte)(i >> 16);
|
||||
this.buf[index + 3] = (byte)(i >> 24);
|
||||
this.count = newcount;
|
||||
}
|
||||
|
||||
public void set(final int index, final byte[] b, final int off, final int len) {
|
||||
if (off < 0 || off > b.length || len < 0 || off + len > b.length || off + len < 0) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
final int newcount = Math.max(this.count, index + len);
|
||||
if (newcount > this.buf.length) {
|
||||
this.buf = Arrays.copyOf(this.buf, Math.max(this.buf.length << 1, newcount));
|
||||
}
|
||||
System.arraycopy(b, off, this.buf, index, len);
|
||||
this.count = newcount;
|
||||
}
|
||||
|
||||
public void setInteger(final int index, final int i) {
|
||||
final byte[] b = { (byte)i, (byte)(i >> 8), (byte)(i >> 16), (byte)(i >> 24) };
|
||||
this.set(index, b, 0, b.length);
|
||||
}
|
||||
|
||||
public void setLong(final int index, final long l) {
|
||||
final byte[] b = { (byte)l, (byte)(l >> 8), (byte)(l >> 16), (byte)(l >> 24), (byte)(l >> 32), (byte)(l >> 40), (byte)(l >> 48), (byte)(l >> 56) };
|
||||
this.set(index, b, 0, b.length);
|
||||
}
|
||||
}
|
||||
|
||||
+100
-103
@@ -1,111 +1,108 @@
|
||||
package com.fangjia.datastore.mongo.codec;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.mina.core.buffer.BufferDataException;
|
||||
import com.fangjia.datastore.mongo.protocol.UpdateMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.ReplyMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.QueryMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.KillCursorsMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.InsertMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.GetMoreMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.DeleteMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import org.apache.mina.filter.codec.ProtocolDecoderException;
|
||||
import com.fangjia.datastore.mongo.protocol.OperationCode;
|
||||
import org.apache.mina.filter.codec.ProtocolDecoderOutput;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
|
||||
import org.apache.mina.filter.codec.ProtocolDecoderException;
|
||||
import org.apache.mina.filter.codec.ProtocolDecoderOutput;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fangjia.datastore.mongo.protocol.DeleteMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.GetMoreMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.InsertMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.KillCursorsMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.OperationCode;
|
||||
import com.fangjia.datastore.mongo.protocol.QueryMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.ReplyMessage;
|
||||
import com.fangjia.datastore.mongo.protocol.UpdateMessage;
|
||||
|
||||
public class MongoProtocolDecoder extends CumulativeProtocolDecoder {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(MongoProtocolDecoder.class);
|
||||
|
||||
@Override
|
||||
protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
|
||||
try {
|
||||
if (!prefixedDataAvailable(in, 4, true)) {
|
||||
return false;
|
||||
}
|
||||
int start = in.position();
|
||||
int limit = in.limit();
|
||||
int messageSize = in.getInt(start);
|
||||
in.limit(start + messageSize);
|
||||
try {
|
||||
final IoBuffer buf = in.slice();
|
||||
int opCodeValue = buf.getInt(buf.position() + 12);
|
||||
OperationCode opCode = OperationCode.valueOf(opCodeValue);
|
||||
MongoMessage message = newInstance(opCode);
|
||||
BSONInputStream input = new BSONInputStream(buf);
|
||||
message.read(input);
|
||||
out.write(message);
|
||||
return true;
|
||||
} finally {
|
||||
in.position(start + messageSize);
|
||||
in.limit(limit);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ProtocolDecoderException pde = new ProtocolDecoderException("error decode message:", e);
|
||||
pde.setHexdump(in.getHexDump());
|
||||
LOGGER.error("", pde);
|
||||
throw pde;
|
||||
}
|
||||
}
|
||||
|
||||
private MongoMessage newInstance(OperationCode opCode) {
|
||||
switch (opCode) {
|
||||
case OP_DELETE:
|
||||
return new DeleteMessage();
|
||||
case OP_GET_MORE:
|
||||
return new GetMoreMessage();
|
||||
case OP_INSERT:
|
||||
return new InsertMessage();
|
||||
case OP_KILL_CURSORS:
|
||||
return new KillCursorsMessage();
|
||||
case OP_QUERY:
|
||||
return new QueryMessage();
|
||||
case OP_REPLY:
|
||||
return new ReplyMessage();
|
||||
case OP_UPDATE:
|
||||
return new UpdateMessage();
|
||||
case OP_MSG:
|
||||
case RESERVED:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean prefixedDataAvailable(IoBuffer buffer, int prefixLength, boolean includePrefix) {
|
||||
if (buffer.remaining() < prefixLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int dataLength;
|
||||
switch (prefixLength) {
|
||||
case 1:
|
||||
dataLength = buffer.getUnsigned(buffer.position());
|
||||
break;
|
||||
case 2:
|
||||
dataLength = buffer.getUnsignedShort(buffer.position());
|
||||
break;
|
||||
case 4:
|
||||
dataLength = buffer.getInt(buffer.position());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("prefixLength: " + prefixLength);
|
||||
}
|
||||
|
||||
if (dataLength < 0) {
|
||||
throw new BufferDataException("dataLength: " + dataLength);
|
||||
}
|
||||
|
||||
if (includePrefix) {
|
||||
return buffer.remaining() >= dataLength;
|
||||
} else {
|
||||
return buffer.remaining() - prefixLength >= dataLength;
|
||||
}
|
||||
}
|
||||
import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
|
||||
|
||||
public class MongoProtocolDecoder extends CumulativeProtocolDecoder
|
||||
{
|
||||
private static final Logger LOGGER;
|
||||
|
||||
protected boolean doDecode(final IoSession session, final IoBuffer in, final ProtocolDecoderOutput out) throws Exception {
|
||||
try {
|
||||
if (!this.prefixedDataAvailable(in, 4, true)) {
|
||||
return false;
|
||||
}
|
||||
final int start = in.position();
|
||||
final int limit = in.limit();
|
||||
final int messageSize = in.getInt(start);
|
||||
in.limit(start + messageSize);
|
||||
try {
|
||||
final IoBuffer buf = in.slice();
|
||||
final int opCodeValue = buf.getInt(buf.position() + 12);
|
||||
final OperationCode opCode = OperationCode.valueOf(opCodeValue);
|
||||
final MongoMessage message = this.newInstance(opCode);
|
||||
final BSONInputStream input = new BSONInputStream(buf);
|
||||
message.read(input);
|
||||
out.write((Object)message);
|
||||
return true;
|
||||
}
|
||||
finally {
|
||||
in.position(start + messageSize);
|
||||
in.limit(limit);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
final ProtocolDecoderException pde = new ProtocolDecoderException("error decode message:", (Throwable)e);
|
||||
pde.setHexdump(in.getHexDump());
|
||||
MongoProtocolDecoder.LOGGER.error("", (Throwable)pde);
|
||||
throw pde;
|
||||
}
|
||||
}
|
||||
|
||||
private MongoMessage newInstance(final OperationCode opCode) {
|
||||
switch (opCode) {
|
||||
case OP_DELETE:
|
||||
return new DeleteMessage();
|
||||
case OP_GET_MORE:
|
||||
return new GetMoreMessage();
|
||||
case OP_INSERT:
|
||||
return new InsertMessage();
|
||||
case OP_KILL_CURSORS:
|
||||
return new KillCursorsMessage();
|
||||
case OP_QUERY:
|
||||
return new QueryMessage();
|
||||
case OP_REPLY:
|
||||
return new ReplyMessage();
|
||||
case OP_UPDATE:
|
||||
return new UpdateMessage();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean prefixedDataAvailable(final IoBuffer buffer, final int prefixLength, final boolean includePrefix) {
|
||||
if (buffer.remaining() < prefixLength) {
|
||||
return false;
|
||||
}
|
||||
int dataLength = 0;
|
||||
switch (prefixLength) {
|
||||
case 1:
|
||||
dataLength = buffer.getUnsigned(buffer.position());
|
||||
break;
|
||||
case 2:
|
||||
dataLength = buffer.getUnsignedShort(buffer.position());
|
||||
break;
|
||||
case 4:
|
||||
dataLength = buffer.getInt(buffer.position());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("prefixLength: " + prefixLength);
|
||||
}
|
||||
if (dataLength < 0) {
|
||||
throw new BufferDataException("dataLength: " + dataLength);
|
||||
}
|
||||
if (includePrefix) {
|
||||
return buffer.remaining() >= dataLength;
|
||||
}
|
||||
return buffer.remaining() - prefixLength >= dataLength;
|
||||
}
|
||||
|
||||
static {
|
||||
LOGGER = LoggerFactory.getLogger((Class)MongoProtocolDecoder.class);
|
||||
}
|
||||
}
|
||||
|
||||
+32
-30
@@ -1,36 +1,38 @@
|
||||
package com.fangjia.datastore.mongo.codec;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.apache.mina.filter.codec.ProtocolEncoder;
|
||||
import org.apache.mina.filter.codec.ProtocolEncoderException;
|
||||
import org.apache.mina.filter.codec.ProtocolEncoderOutput;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.mina.filter.codec.ProtocolEncoderException;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import com.fangjia.datastore.mongo.protocol.MongoMessage;
|
||||
import org.apache.mina.filter.codec.ProtocolEncoderOutput;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.apache.mina.filter.codec.ProtocolEncoder;
|
||||
|
||||
public class MongoProtocolEncoder implements ProtocolEncoder {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(MongoProtocolEncoder.class);
|
||||
|
||||
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
|
||||
try {
|
||||
if (message instanceof MongoMessage) {
|
||||
MongoMessage mongoMessage = (MongoMessage) message;
|
||||
BSONOutputStream output = new BSONOutputStream(mongoMessage.getMessageHeader().getMessageLength());
|
||||
mongoMessage.write(output);
|
||||
out.write(IoBuffer.wrap(output.toByteArray()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ProtocolEncoderException pe = new ProtocolEncoderException("error encode message: " + message, e);
|
||||
LOGGER.error("", pe);
|
||||
throw pe;
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose(IoSession session) throws Exception {
|
||||
// empty
|
||||
}
|
||||
|
||||
public class MongoProtocolEncoder implements ProtocolEncoder
|
||||
{
|
||||
private static final Logger LOGGER;
|
||||
|
||||
public void encode(final IoSession session, final Object message, final ProtocolEncoderOutput out) throws Exception {
|
||||
try {
|
||||
if (message instanceof MongoMessage) {
|
||||
final MongoMessage mongoMessage = (MongoMessage)message;
|
||||
final BSONOutputStream output = new BSONOutputStream(mongoMessage.getMessageHeader().getMessageLength());
|
||||
mongoMessage.write(output);
|
||||
out.write((Object)IoBuffer.wrap(output.toByteArray()));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
final ProtocolEncoderException pe = new ProtocolEncoderException("error encode message: " + message, (Throwable)e);
|
||||
MongoProtocolEncoder.LOGGER.error("", (Throwable)pe);
|
||||
throw pe;
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose(final IoSession session) throws Exception {
|
||||
}
|
||||
|
||||
static {
|
||||
LOGGER = LoggerFactory.getLogger((Class)MongoProtocolEncoder.class);
|
||||
}
|
||||
}
|
||||
|
||||
+93
-106
@@ -1,111 +1,98 @@
|
||||
/**
|
||||
* JMongo is a mongodb driver writtern in java.
|
||||
* Copyright (C) 2010 Xiaohu Huang
|
||||
*
|
||||
* JMongo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* JMongo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JMongo. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.fangjia.datastore.mongo.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bson.BSONDecoder;
|
||||
import org.bson.BSONEncoder;
|
||||
import org.bson.BSONObject;
|
||||
import org.bson.BasicBSONDecoder;
|
||||
import org.bson.BasicBSONObject;
|
||||
|
||||
import com.fangjia.datastore.mongo.codec.BSONInputStream;
|
||||
import com.fangjia.datastore.mongo.codec.BSONOutputStream;
|
||||
import com.fangjia.datastore.utils.BSONUtils;
|
||||
import org.bson.BSONDecoder;
|
||||
import java.io.InputStream;
|
||||
import org.bson.BasicBSONDecoder;
|
||||
import com.fangjia.datastore.mongo.codec.BSONInputStream;
|
||||
import java.io.IOException;
|
||||
import org.bson.BSONEncoder;
|
||||
import org.bson.BasicBSONEncoder;
|
||||
import com.fangjia.datastore.mongo.codec.BSONOutputStream;
|
||||
import org.bson.BasicBSONObject;
|
||||
import org.bson.BSONObject;
|
||||
|
||||
public class DeleteMessage implements MongoMessage {
|
||||
|
||||
private static final long serialVersionUID = -3350216587439425208L;
|
||||
private MessageHeader messageHeader;
|
||||
private String fullCollectionName;
|
||||
private int flags;
|
||||
private BSONObject selector;
|
||||
|
||||
public DeleteMessage() {
|
||||
messageHeader = new MessageHeader(OperationCode.OP_DELETE);
|
||||
selector = new BasicBSONObject();
|
||||
}
|
||||
|
||||
public void write(BSONOutputStream out) throws IOException {
|
||||
messageHeader.write(out);
|
||||
out.writeInteger(0);
|
||||
out.writeCString(this.fullCollectionName);
|
||||
out.writeInteger(this.flags);
|
||||
BSONEncoder encoder = new BSONEncoder();
|
||||
out.write(encoder.encode(selector));
|
||||
out.set(0, out.size());
|
||||
}
|
||||
|
||||
public void read(BSONInputStream in) throws IOException {
|
||||
messageHeader.read(in);
|
||||
in.readInteger();
|
||||
this.fullCollectionName = in.readCString();
|
||||
this.flags = in.readInteger();
|
||||
BSONDecoder decoder = new BasicBSONDecoder();
|
||||
selector = decoder.readObject(in);
|
||||
}
|
||||
|
||||
public MessageHeader getMessageHeader() {
|
||||
return messageHeader;
|
||||
}
|
||||
|
||||
public String getFullCollectionName() {
|
||||
return fullCollectionName;
|
||||
}
|
||||
|
||||
public void setFullCollectionName(String fullCollectionName) {
|
||||
this.fullCollectionName = fullCollectionName;
|
||||
}
|
||||
|
||||
public int getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void setFlags(int flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
public void setSingleRemove(boolean b) {
|
||||
this.flags = (int) BSONUtils.bitSet(this.flags, 0, b);
|
||||
}
|
||||
|
||||
public BSONObject getSelector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
public void setSelector(BSONObject selector) {
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageHeader:").append(messageHeader);
|
||||
builder.append(", fullCollectionName:").append(fullCollectionName);
|
||||
builder.append(", flags:").append(flags);
|
||||
builder.append(", selector:").append(selector);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public String toPrettyString() {
|
||||
return toString();
|
||||
}
|
||||
|
||||
public class DeleteMessage implements MongoMessage
|
||||
{
|
||||
private static final long serialVersionUID = -3350216587439425208L;
|
||||
private MessageHeader messageHeader;
|
||||
private String fullCollectionName;
|
||||
private int flags;
|
||||
private BSONObject selector;
|
||||
|
||||
public DeleteMessage() {
|
||||
this.messageHeader = new MessageHeader(OperationCode.OP_DELETE);
|
||||
this.selector = (BSONObject)new BasicBSONObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final BSONOutputStream out) throws IOException {
|
||||
this.messageHeader.write(out);
|
||||
out.writeInteger(0);
|
||||
out.writeCString(this.fullCollectionName);
|
||||
out.writeInteger(this.flags);
|
||||
final BSONEncoder encoder = (BSONEncoder)new BasicBSONEncoder();
|
||||
out.write(encoder.encode(this.selector));
|
||||
out.set(0, out.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final BSONInputStream in) throws IOException {
|
||||
this.messageHeader.read(in);
|
||||
in.readInteger();
|
||||
this.fullCollectionName = in.readCString();
|
||||
this.flags = in.readInteger();
|
||||
final BSONDecoder decoder = (BSONDecoder)new BasicBSONDecoder();
|
||||
this.selector = decoder.readObject((InputStream)in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageHeader getMessageHeader() {
|
||||
return this.messageHeader;
|
||||
}
|
||||
|
||||
public String getFullCollectionName() {
|
||||
return this.fullCollectionName;
|
||||
}
|
||||
|
||||
public void setFullCollectionName(final String fullCollectionName) {
|
||||
this.fullCollectionName = fullCollectionName;
|
||||
}
|
||||
|
||||
public int getFlags() {
|
||||
return this.flags;
|
||||
}
|
||||
|
||||
public void setFlags(final int flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
public void setSingleRemove(final boolean b) {
|
||||
this.flags = (int)BSONUtils.bitSet(this.flags, 0, b);
|
||||
}
|
||||
|
||||
public BSONObject getSelector() {
|
||||
return this.selector;
|
||||
}
|
||||
|
||||
public void setSelector(final BSONObject selector) {
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageHeader:").append(this.messageHeader);
|
||||
builder.append(", fullCollectionName:").append(this.fullCollectionName);
|
||||
builder.append(", flags:").append(this.flags);
|
||||
builder.append(", selector:").append(this.selector);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPrettyString() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+77
-91
@@ -1,97 +1,83 @@
|
||||
/**
|
||||
* JMongo is a mongodb driver writtern in java.
|
||||
* Copyright (C) 2010 Xiaohu Huang
|
||||
*
|
||||
* JMongo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* JMongo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JMongo. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.fangjia.datastore.mongo.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.fangjia.datastore.mongo.codec.BSONInputStream;
|
||||
import java.io.IOException;
|
||||
import com.fangjia.datastore.mongo.codec.BSONOutputStream;
|
||||
|
||||
public class GetMoreMessage implements MongoMessage {
|
||||
|
||||
private static final long serialVersionUID = -3350216587439425208L;
|
||||
private MessageHeader messageHeader;
|
||||
private String fullCollectionName;
|
||||
private int numberToReturn;
|
||||
private long cursorID;
|
||||
|
||||
public GetMoreMessage() {
|
||||
messageHeader = new MessageHeader(OperationCode.OP_GET_MORE);
|
||||
}
|
||||
|
||||
public void write(BSONOutputStream out) throws IOException {
|
||||
messageHeader.write(out);
|
||||
out.writeInteger(0);
|
||||
out.writeCString(this.fullCollectionName);
|
||||
out.writeInteger(this.numberToReturn);
|
||||
out.writeLong(cursorID);
|
||||
out.set(0, out.size());
|
||||
}
|
||||
|
||||
public void read(BSONInputStream in) throws IOException {
|
||||
messageHeader.read(in);
|
||||
in.readInteger();
|
||||
this.fullCollectionName = in.readCString();
|
||||
this.numberToReturn = in.readInteger();
|
||||
this.cursorID = in.readLong();
|
||||
}
|
||||
|
||||
public MessageHeader getMessageHeader() {
|
||||
return messageHeader;
|
||||
}
|
||||
|
||||
public String getFullCollectionName() {
|
||||
return fullCollectionName;
|
||||
}
|
||||
|
||||
public void setFullCollectionName(String fullCollectionName) {
|
||||
this.fullCollectionName = fullCollectionName;
|
||||
}
|
||||
|
||||
public int getNumberToReturn() {
|
||||
return numberToReturn;
|
||||
}
|
||||
|
||||
public void setNumberToReturn(int numberToReturn) {
|
||||
this.numberToReturn = numberToReturn;
|
||||
}
|
||||
|
||||
public long getCursorID() {
|
||||
return cursorID;
|
||||
}
|
||||
|
||||
public void setCursorID(long cursorID) {
|
||||
this.cursorID = cursorID;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageHeader:").append(messageHeader);
|
||||
builder.append(", fullCollectionName:").append(fullCollectionName);
|
||||
builder.append(", numberToReturn:").append(numberToReturn);
|
||||
builder.append(", cursorID:").append(cursorID);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public String toPrettyString() {
|
||||
return toString();
|
||||
}
|
||||
|
||||
public class GetMoreMessage implements MongoMessage
|
||||
{
|
||||
private static final long serialVersionUID = -3350216587439425208L;
|
||||
private MessageHeader messageHeader;
|
||||
private String fullCollectionName;
|
||||
private int numberToReturn;
|
||||
private long cursorID;
|
||||
|
||||
public GetMoreMessage() {
|
||||
this.messageHeader = new MessageHeader(OperationCode.OP_GET_MORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final BSONOutputStream out) throws IOException {
|
||||
this.messageHeader.write(out);
|
||||
out.writeInteger(0);
|
||||
out.writeCString(this.fullCollectionName);
|
||||
out.writeInteger(this.numberToReturn);
|
||||
out.writeLong(this.cursorID);
|
||||
out.set(0, out.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final BSONInputStream in) throws IOException {
|
||||
this.messageHeader.read(in);
|
||||
in.readInteger();
|
||||
this.fullCollectionName = in.readCString();
|
||||
this.numberToReturn = in.readInteger();
|
||||
this.cursorID = in.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageHeader getMessageHeader() {
|
||||
return this.messageHeader;
|
||||
}
|
||||
|
||||
public String getFullCollectionName() {
|
||||
return this.fullCollectionName;
|
||||
}
|
||||
|
||||
public void setFullCollectionName(final String fullCollectionName) {
|
||||
this.fullCollectionName = fullCollectionName;
|
||||
}
|
||||
|
||||
public int getNumberToReturn() {
|
||||
return this.numberToReturn;
|
||||
}
|
||||
|
||||
public void setNumberToReturn(final int numberToReturn) {
|
||||
this.numberToReturn = numberToReturn;
|
||||
}
|
||||
|
||||
public long getCursorID() {
|
||||
return this.cursorID;
|
||||
}
|
||||
|
||||
public void setCursorID(final long cursorID) {
|
||||
this.cursorID = cursorID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageHeader:").append(this.messageHeader);
|
||||
builder.append(", fullCollectionName:").append(this.fullCollectionName);
|
||||
builder.append(", numberToReturn:").append(this.numberToReturn);
|
||||
builder.append(", cursorID:").append(this.cursorID);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPrettyString() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+99
-110
@@ -1,116 +1,105 @@
|
||||
/**
|
||||
* JMongo is a mongodb driver writtern in java.
|
||||
* Copyright (C) 2010 Xiaohu Huang
|
||||
*
|
||||
* JMongo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* JMongo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JMongo. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.fangjia.datastore.mongo.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.bson.BSONDecoder;
|
||||
import java.io.InputStream;
|
||||
import org.bson.BasicBSONDecoder;
|
||||
import java.util.ArrayList;
|
||||
import com.fangjia.datastore.mongo.codec.BSONInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import org.bson.BSONEncoder;
|
||||
import org.bson.BasicBSONEncoder;
|
||||
import com.fangjia.datastore.mongo.codec.BSONOutputStream;
|
||||
import org.bson.BSONObject;
|
||||
import java.util.List;
|
||||
|
||||
import org.bson.BSONDecoder;
|
||||
import org.bson.BSONEncoder;
|
||||
import org.bson.BSONObject;
|
||||
import org.bson.BasicBSONDecoder;
|
||||
|
||||
import com.fangjia.datastore.mongo.codec.BSONInputStream;
|
||||
import com.fangjia.datastore.mongo.codec.BSONOutputStream;
|
||||
|
||||
public class InsertMessage implements MongoMessage {
|
||||
|
||||
private static final long serialVersionUID = -3350216587439425208L;
|
||||
private MessageHeader messageHeader;
|
||||
private String fullCollectionName;
|
||||
private List<BSONObject> documents;
|
||||
|
||||
public InsertMessage() {
|
||||
messageHeader = new MessageHeader(OperationCode.OP_INSERT);
|
||||
}
|
||||
|
||||
public void write(BSONOutputStream out) throws IOException {
|
||||
messageHeader.write(out);
|
||||
out.writeInteger(0);
|
||||
out.writeCString(this.fullCollectionName);
|
||||
if (null != documents && documents.size() > 0) {
|
||||
BSONEncoder encoder = new BSONEncoder();
|
||||
for (BSONObject doc : documents) {
|
||||
out.write(encoder.encode(doc));
|
||||
}
|
||||
}
|
||||
out.setInteger(0, out.size());
|
||||
}
|
||||
|
||||
public void read(BSONInputStream in) throws IOException {
|
||||
messageHeader.read(in);
|
||||
in.readInteger();
|
||||
this.fullCollectionName = in.readCString();
|
||||
while (in.available() > 0) {
|
||||
if (null == documents) {
|
||||
documents = new ArrayList<BSONObject>();
|
||||
}
|
||||
BSONDecoder decoder = new BasicBSONDecoder();
|
||||
documents.add(decoder.readObject(in));
|
||||
}
|
||||
}
|
||||
|
||||
public MessageHeader getMessageHeader() {
|
||||
return messageHeader;
|
||||
}
|
||||
|
||||
public String getFullCollectionName() {
|
||||
return fullCollectionName;
|
||||
}
|
||||
|
||||
public void setFullCollectionName(String fullCollectionName) {
|
||||
this.fullCollectionName = fullCollectionName;
|
||||
}
|
||||
|
||||
public List<BSONObject> getDocuments() {
|
||||
return documents;
|
||||
}
|
||||
|
||||
public void setDocuments(List<BSONObject> documents) {
|
||||
this.documents = documents;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageHeader:").append(messageHeader);
|
||||
builder.append(", fullCollectionName:").append(fullCollectionName);
|
||||
builder.append(", documents:").append(documents);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public String toPrettyString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageHeader:").append(messageHeader);
|
||||
builder.append(", fullCollectionName:").append(fullCollectionName);
|
||||
if (null != documents && documents.size() > 0) {
|
||||
builder.append(", documents:").append(documents.get(0).get("_id"));
|
||||
if (documents.size() > 1) {
|
||||
builder.append("...").append(documents.size() - 1).append(" more");
|
||||
}
|
||||
} else {
|
||||
builder.append(", documents:").append(documents);
|
||||
}
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public class InsertMessage implements MongoMessage
|
||||
{
|
||||
private static final long serialVersionUID = -3350216587439425208L;
|
||||
private MessageHeader messageHeader;
|
||||
private String fullCollectionName;
|
||||
private List<BSONObject> documents;
|
||||
|
||||
public InsertMessage() {
|
||||
this.messageHeader = new MessageHeader(OperationCode.OP_INSERT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final BSONOutputStream out) throws IOException {
|
||||
this.messageHeader.write(out);
|
||||
out.writeInteger(0);
|
||||
out.writeCString(this.fullCollectionName);
|
||||
if (null != this.documents && this.documents.size() > 0) {
|
||||
final BSONEncoder encoder = (BSONEncoder)new BasicBSONEncoder();
|
||||
for (final BSONObject doc : this.documents) {
|
||||
out.write(encoder.encode(doc));
|
||||
}
|
||||
}
|
||||
out.setInteger(0, out.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final BSONInputStream in) throws IOException {
|
||||
this.messageHeader.read(in);
|
||||
in.readInteger();
|
||||
this.fullCollectionName = in.readCString();
|
||||
while (in.available() > 0) {
|
||||
if (null == this.documents) {
|
||||
this.documents = new ArrayList<BSONObject>();
|
||||
}
|
||||
final BSONDecoder decoder = (BSONDecoder)new BasicBSONDecoder();
|
||||
this.documents.add(decoder.readObject((InputStream)in));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageHeader getMessageHeader() {
|
||||
return this.messageHeader;
|
||||
}
|
||||
|
||||
public String getFullCollectionName() {
|
||||
return this.fullCollectionName;
|
||||
}
|
||||
|
||||
public void setFullCollectionName(final String fullCollectionName) {
|
||||
this.fullCollectionName = fullCollectionName;
|
||||
}
|
||||
|
||||
public List<BSONObject> getDocuments() {
|
||||
return this.documents;
|
||||
}
|
||||
|
||||
public void setDocuments(final List<BSONObject> documents) {
|
||||
this.documents = documents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageHeader:").append(this.messageHeader);
|
||||
builder.append(", fullCollectionName:").append(this.fullCollectionName);
|
||||
builder.append(", documents:").append(this.documents);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPrettyString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageHeader:").append(this.messageHeader);
|
||||
builder.append(", fullCollectionName:").append(this.fullCollectionName);
|
||||
if (null != this.documents && this.documents.size() > 0) {
|
||||
builder.append(", documents:").append(this.documents.get(0).get("_id"));
|
||||
if (this.documents.size() > 1) {
|
||||
builder.append("...").append(this.documents.size() - 1).append(" more");
|
||||
}
|
||||
}
|
||||
else {
|
||||
builder.append(", documents:").append(this.documents);
|
||||
}
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+77
-90
@@ -1,96 +1,83 @@
|
||||
/**
|
||||
* JMongo is a mongodb driver writtern in java.
|
||||
* Copyright (C) 2010 Xiaohu Huang
|
||||
*
|
||||
* JMongo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* JMongo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JMongo. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.fangjia.datastore.mongo.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import com.fangjia.datastore.mongo.codec.BSONInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import com.fangjia.datastore.mongo.codec.BSONOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.datastore.mongo.codec.BSONInputStream;
|
||||
import com.fangjia.datastore.mongo.codec.BSONOutputStream;
|
||||
|
||||
public class KillCursorsMessage implements MongoMessage {
|
||||
|
||||
private static final long serialVersionUID = -3350216587439425208L;
|
||||
private MessageHeader messageHeader;
|
||||
private int numberOfCursorIDs;
|
||||
private List<Long> cursorIDs;
|
||||
|
||||
public KillCursorsMessage() {
|
||||
messageHeader = new MessageHeader(OperationCode.OP_KILL_CURSORS);
|
||||
}
|
||||
|
||||
public MessageHeader getMessageHeader() {
|
||||
return messageHeader;
|
||||
}
|
||||
|
||||
public void write(BSONOutputStream out) throws IOException {
|
||||
messageHeader.write(out);
|
||||
out.writeInteger(0);
|
||||
out.writeInteger(numberOfCursorIDs);
|
||||
if (null != cursorIDs) {
|
||||
for (Long id : cursorIDs) {
|
||||
out.writeLong(id);
|
||||
}
|
||||
}
|
||||
out.set(0, out.size());
|
||||
}
|
||||
|
||||
public void read(BSONInputStream in) throws IOException {
|
||||
messageHeader.read(in);
|
||||
in.readInteger();
|
||||
numberOfCursorIDs = in.readInteger();
|
||||
while (in.available() > 0) {
|
||||
if (null == cursorIDs) {
|
||||
cursorIDs = new ArrayList<Long>();
|
||||
}
|
||||
cursorIDs.add(in.readLong());
|
||||
}
|
||||
}
|
||||
|
||||
public int getNumberOfCursorIDs() {
|
||||
return numberOfCursorIDs;
|
||||
}
|
||||
|
||||
public void setNumberOfCursorIDs(int numberOfCursorIDs) {
|
||||
this.numberOfCursorIDs = numberOfCursorIDs;
|
||||
}
|
||||
|
||||
public List<Long> getCursorIDs() {
|
||||
return cursorIDs;
|
||||
}
|
||||
|
||||
public void setCursorIDs(List<Long> cursorIDs) {
|
||||
this.cursorIDs = cursorIDs;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageHeader:").append(messageHeader);
|
||||
builder.append(", numberOfCursorIDs:").append(numberOfCursorIDs);
|
||||
builder.append(", cursorIDs:").append(cursorIDs);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public String toPrettyString() {
|
||||
return toString();
|
||||
}
|
||||
|
||||
public class KillCursorsMessage implements MongoMessage
|
||||
{
|
||||
private static final long serialVersionUID = -3350216587439425208L;
|
||||
private MessageHeader messageHeader;
|
||||
private int numberOfCursorIDs;
|
||||
private List<Long> cursorIDs;
|
||||
|
||||
public KillCursorsMessage() {
|
||||
this.messageHeader = new MessageHeader(OperationCode.OP_KILL_CURSORS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageHeader getMessageHeader() {
|
||||
return this.messageHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final BSONOutputStream out) throws IOException {
|
||||
this.messageHeader.write(out);
|
||||
out.writeInteger(0);
|
||||
out.writeInteger(this.numberOfCursorIDs);
|
||||
if (null != this.cursorIDs) {
|
||||
for (final Long id : this.cursorIDs) {
|
||||
out.writeLong(id);
|
||||
}
|
||||
}
|
||||
out.set(0, out.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final BSONInputStream in) throws IOException {
|
||||
this.messageHeader.read(in);
|
||||
in.readInteger();
|
||||
this.numberOfCursorIDs = in.readInteger();
|
||||
while (in.available() > 0) {
|
||||
if (null == this.cursorIDs) {
|
||||
this.cursorIDs = new ArrayList<Long>();
|
||||
}
|
||||
this.cursorIDs.add(in.readLong());
|
||||
}
|
||||
}
|
||||
|
||||
public int getNumberOfCursorIDs() {
|
||||
return this.numberOfCursorIDs;
|
||||
}
|
||||
|
||||
public void setNumberOfCursorIDs(final int numberOfCursorIDs) {
|
||||
this.numberOfCursorIDs = numberOfCursorIDs;
|
||||
}
|
||||
|
||||
public List<Long> getCursorIDs() {
|
||||
return this.cursorIDs;
|
||||
}
|
||||
|
||||
public void setCursorIDs(final List<Long> cursorIDs) {
|
||||
this.cursorIDs = cursorIDs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageHeader:").append(this.messageHeader);
|
||||
builder.append(", numberOfCursorIDs:").append(this.numberOfCursorIDs);
|
||||
builder.append(", cursorIDs:").append(this.cursorIDs);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPrettyString() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+88
-101
@@ -1,106 +1,93 @@
|
||||
/**
|
||||
* JMongo is a mongodb driver writtern in java.
|
||||
* Copyright (C) 2010 Xiaohu Huang
|
||||
*
|
||||
* JMongo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* JMongo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JMongo. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.fangjia.datastore.mongo.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.fangjia.datastore.mongo.codec.BSONInputStream;
|
||||
import com.fangjia.datastore.mongo.codec.BSONOutputStream;
|
||||
import java.io.IOException;
|
||||
import com.fangjia.datastore.mongo.codec.BSONInputStream;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.io.Serializable;
|
||||
|
||||
public final class MessageHeader implements Writable, Readable, Serializable {
|
||||
private static final long serialVersionUID = 8505270142383450097L;
|
||||
private static final AtomicInteger ID_GENERATOR = new AtomicInteger(1);
|
||||
|
||||
private int messageLength;
|
||||
private int requestID;
|
||||
private int responseTo;
|
||||
private OperationCode opCode;
|
||||
|
||||
public MessageHeader(OperationCode opCode) {
|
||||
this.opCode = opCode;
|
||||
this.requestID = ID_GENERATOR.getAndIncrement();
|
||||
}
|
||||
|
||||
public MessageHeader() {
|
||||
}
|
||||
|
||||
public void read(BSONInputStream in) throws IOException {
|
||||
messageLength = in.readInteger();
|
||||
requestID = in.readInteger();
|
||||
responseTo = in.readInteger();
|
||||
opCode = OperationCode.valueOf(in.readInteger());
|
||||
}
|
||||
|
||||
public void write(BSONOutputStream out) throws IOException {
|
||||
out.writeInteger(messageLength);
|
||||
out.writeInteger(requestID);
|
||||
out.writeInteger(responseTo);
|
||||
out.writeInteger(opCode.getValue());
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
public int getMessageLength() {
|
||||
return messageLength;
|
||||
}
|
||||
|
||||
public void setMessageLength(int messageLength) {
|
||||
this.messageLength = messageLength;
|
||||
}
|
||||
|
||||
public int getRequestID() {
|
||||
return requestID;
|
||||
}
|
||||
|
||||
public void setRequestID(int requestID) {
|
||||
this.requestID = requestID;
|
||||
}
|
||||
|
||||
public int getResponseTo() {
|
||||
return responseTo;
|
||||
}
|
||||
|
||||
public void setResponseTo(int responseTo) {
|
||||
this.responseTo = responseTo;
|
||||
}
|
||||
|
||||
public OperationCode getOpCode() {
|
||||
return opCode;
|
||||
}
|
||||
|
||||
public void setOpCode(OperationCode opCode) {
|
||||
this.opCode = opCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageLength:").append(messageLength);
|
||||
builder.append(", requestID:").append(requestID);
|
||||
builder.append(", responseTo:").append(responseTo);
|
||||
builder.append(", opCode:").append(opCode);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public final class MessageHeader implements Writable, Readable, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 8505270142383450097L;
|
||||
private static final AtomicInteger ID_GENERATOR;
|
||||
private int messageLength;
|
||||
private int requestID;
|
||||
private int responseTo;
|
||||
private OperationCode opCode;
|
||||
|
||||
public MessageHeader(final OperationCode opCode) {
|
||||
this.opCode = opCode;
|
||||
this.requestID = MessageHeader.ID_GENERATOR.getAndIncrement();
|
||||
}
|
||||
|
||||
public MessageHeader() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final BSONInputStream in) throws IOException {
|
||||
this.messageLength = in.readInteger();
|
||||
this.requestID = in.readInteger();
|
||||
this.responseTo = in.readInteger();
|
||||
this.opCode = OperationCode.valueOf(in.readInteger());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final BSONOutputStream out) throws IOException {
|
||||
out.writeInteger(this.messageLength);
|
||||
out.writeInteger(this.requestID);
|
||||
out.writeInteger(this.responseTo);
|
||||
out.writeInteger(this.opCode.getValue());
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
public int getMessageLength() {
|
||||
return this.messageLength;
|
||||
}
|
||||
|
||||
public void setMessageLength(final int messageLength) {
|
||||
this.messageLength = messageLength;
|
||||
}
|
||||
|
||||
public int getRequestID() {
|
||||
return this.requestID;
|
||||
}
|
||||
|
||||
public void setRequestID(final int requestID) {
|
||||
this.requestID = requestID;
|
||||
}
|
||||
|
||||
public int getResponseTo() {
|
||||
return this.responseTo;
|
||||
}
|
||||
|
||||
public void setResponseTo(final int responseTo) {
|
||||
this.responseTo = responseTo;
|
||||
}
|
||||
|
||||
public OperationCode getOpCode() {
|
||||
return this.opCode;
|
||||
}
|
||||
|
||||
public void setOpCode(final OperationCode opCode) {
|
||||
this.opCode = opCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("messageLength:").append(this.messageLength);
|
||||
builder.append(", requestID:").append(this.requestID);
|
||||
builder.append(", responseTo:").append(this.responseTo);
|
||||
builder.append(", opCode:").append(this.opCode);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
static {
|
||||
ID_GENERATOR = new AtomicInteger(1);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-21
@@ -1,26 +1,10 @@
|
||||
/**
|
||||
* JMongo is a mongodb driver writtern in java.
|
||||
* Copyright (C) 2010 Xiaohu Huang
|
||||
*
|
||||
* JMongo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* JMongo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JMongo. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.fangjia.datastore.mongo.protocol;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface MongoMessage extends Readable, Writable, Serializable {
|
||||
public MessageHeader getMessageHeader();
|
||||
|
||||
public String toPrettyString();
|
||||
public interface MongoMessage extends Readable, Writable, Serializable
|
||||
{
|
||||
MessageHeader getMessageHeader();
|
||||
|
||||
String toPrettyString();
|
||||
}
|
||||
|
||||
+33
-76
@@ -1,82 +1,39 @@
|
||||
/**
|
||||
* JMongo is a mongodb driver writtern in java.
|
||||
* Copyright (C) 2010 Xiaohu Huang
|
||||
*
|
||||
* JMongo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* JMongo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JMongo. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.fangjia.datastore.mongo.protocol;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum OperationCode {
|
||||
/**
|
||||
* Reply to a client request. responseTo is set
|
||||
*/
|
||||
OP_REPLY(1),
|
||||
/**
|
||||
* generic msg command followed by a string
|
||||
*/
|
||||
OP_MSG(1000),
|
||||
/**
|
||||
* update document
|
||||
*/
|
||||
OP_UPDATE(2001),
|
||||
/**
|
||||
* insert new document
|
||||
*/
|
||||
OP_INSERT(2002),
|
||||
/**
|
||||
* formerly used for OP_GET_BY_OID
|
||||
*/
|
||||
RESERVED(2003),
|
||||
/**
|
||||
* query a collection
|
||||
*/
|
||||
OP_QUERY(2004),
|
||||
/**
|
||||
* Get more data from a query. See Cursors
|
||||
*/
|
||||
OP_GET_MORE(2005),
|
||||
/**
|
||||
* Delete documents
|
||||
*/
|
||||
OP_DELETE(2006),
|
||||
/**
|
||||
* Tell database client is done with a cursor
|
||||
*/
|
||||
OP_KILL_CURSORS(2007);
|
||||
|
||||
private final int value;
|
||||
|
||||
private final static Map<Integer, OperationCode> TYPE_MAP = new HashMap<Integer, OperationCode>();
|
||||
static {
|
||||
for (OperationCode e : OperationCode.values()) {
|
||||
TYPE_MAP.put(e.value, e);
|
||||
}
|
||||
}
|
||||
|
||||
private OperationCode(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static OperationCode valueOf(int value) {
|
||||
return TYPE_MAP.get(value);
|
||||
}
|
||||
|
||||
public enum OperationCode
|
||||
{
|
||||
OP_REPLY(1),
|
||||
OP_MSG(1000),
|
||||
OP_UPDATE(2001),
|
||||
OP_INSERT(2002),
|
||||
RESERVED(2003),
|
||||
OP_QUERY(2004),
|
||||
OP_GET_MORE(2005),
|
||||
OP_DELETE(2006),
|
||||
OP_KILL_CURSORS(2007);
|
||||
|
||||
private final int value;
|
||||
private static final Map<Integer, OperationCode> TYPE_MAP;
|
||||
|
||||
private OperationCode(final int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static OperationCode valueOf(final int value) {
|
||||
return OperationCode.TYPE_MAP.get(value);
|
||||
}
|
||||
|
||||
static {
|
||||
TYPE_MAP = new HashMap<Integer, OperationCode>();
|
||||
for (final OperationCode e : values()) {
|
||||
OperationCode.TYPE_MAP.put(e.value, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user