This commit is contained in:
2024-09-03 09:55:17 +08:00
45 changed files with 1838 additions and 289 deletions
@@ -0,0 +1,84 @@
package com.fangjia.bkoff.controllers;
import com.alibaba.excel.util.DateUtils;
import com.fangjia.bkoff.model.ApiCountLogModel;
import com.fangjia.bkoff.model.ApiUserModel;
import com.fangjia.bkoff.model.JsonModel;
import com.fangjia.core.util.*;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
import com.fangjia.dal.mongo.model.ApiCountLog;
import com.fangjia.dal.mongo.model.ApiInvokeStatistical;
import com.fangjia.dal.mongo.model.ApiUserCfg;
import com.fangjia.dal.mongo.model.bkoff.BkoffUsers;
import com.fangjia.dal.mongo.open.model.ApiJsonViewConfig;
import com.fangjia.dal.mongo.open.model.ApiUserAuthority;
import com.fangjia.dal.mongo.open.model.OpenResource;
import com.fangjia.dal.mongo.tool.model.ApiCountCity;
import com.fangjia.dal.mongo.tool.model.ApiVisitCount;
import com.fangjia.dal.mongo.tool.model.OpenResourceCount;
import com.fangjia.dal.mongo.tool.model.OpenUriAnaly;
import com.fangjia.dal.sql.model.ApiUser;
import com.fangjia.dal.sql.model.User;
import com.fangjia.service.api.ApiUserCfgService;
import com.fangjia.service.mongo.bkoff.ApiInvokeStatisticalService;
import com.fangjia.service.mongo.bkoff.BkoffUsersService;
import com.fangjia.service.mongo.fangjia.ApiCountLogService;
import com.fangjia.service.mongo.fangjia.ServerAreaService;
import com.fangjia.service.open.*;
import com.fangjia.service.sql.ApiUserService;
import com.fangjia.service.sql.UserService;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.json.JSONArray;
import org.sothis.core.util.CollectionUtils;
import org.sothis.core.util.Pager;
import org.sothis.web.mvc.ActionContext;
import org.sothis.web.mvc.annotation.Param;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* apiÓû§¿ªÍ¨µÈ¹ÜÀícontroller
*
* @author
*/
public class ApiCountLogController {
private BkoffUsersService bkoffUsersService;
private ApiCountLogService apiCountLogService;
public Object listAction(ApiCountLogModel model) {
Pager pager = model.getPager(30);
if (pager.getCurrentPage() > 100) {
pager.setCurrentPage(1);
}
List<ApiCountLog> apiCountLogList = apiCountLogService.findApiCountLog(model.getUserId(), model.getUri(),pager);
model.setApiCountLogList(apiCountLogList);
pager.setTotalRows(apiCountLogList.size());
model.setPager(pager);
return model;
}
public void setBkoffUsersService(BkoffUsersService bkoffUsersService) {
this.bkoffUsersService = bkoffUsersService;
}
public void setApiCountLogService(ApiCountLogService apiCountLogService) {
this.apiCountLogService = apiCountLogService;
}
}
@@ -9,8 +9,10 @@ import com.fangjia.bkoff.model.JsonModel;
import com.fangjia.core.util.*;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
import com.fangjia.dal.mongo.model.ApiCountLog;
import com.fangjia.dal.mongo.model.ApiInvokeStatistical;
import com.fangjia.dal.mongo.model.ApiUserCfg;
import com.fangjia.dal.mongo.model.bkoff.BkoffUsers;
import com.fangjia.dal.mongo.open.model.ApiJsonViewConfig;
import com.fangjia.dal.mongo.open.model.ApiUserAuthority;
import com.fangjia.dal.mongo.open.model.OpenResource;
@@ -22,6 +24,8 @@ import com.fangjia.dal.sql.model.ApiUser;
import com.fangjia.dal.sql.model.User;
import com.fangjia.service.api.ApiUserCfgService;
import com.fangjia.service.mongo.bkoff.ApiInvokeStatisticalService;
import com.fangjia.service.mongo.bkoff.BkoffUsersService;
import com.fangjia.service.mongo.fangjia.ApiCountLogService;
import com.fangjia.service.mongo.fangjia.ServerAreaService;
import com.fangjia.service.open.*;
import com.fangjia.service.sql.ApiUserService;
@@ -73,6 +77,9 @@ public class ApiUserController {
private ApiInvokeStatisticalService apiInvokeStatisticalService;
private ApiVisitCountService apiVisitCountService;
private ApiCountCityService apiCountCityService;
private BkoffUsersService bkoffUsersService;
private ApiCountLogService apiCountLogService;
/**
* 所有api用户的信息展示
*
@@ -88,7 +95,21 @@ public class ApiUserController {
* @param ApiUser
* :用户的appKey username、等资料
*/
List<ApiUser> apiUsers = this.apiUserService.findApiUsersByParamsSortDate(null);
ArrayList<QueryParam> queryParams = new ArrayList<QueryParam>();
if (model.getStatus() != null) {
queryParams.add(new QueryParam("status", model.getStatus()));
} else {
queryParams.add(new QueryParam("status", 0));
}
if (model.getIsTest() != null) {
queryParams.add(new QueryParam("isTest", model.getIsTest()));
} else {
queryParams.add(new QueryParam("isTest", 0));
}
if (model.getPurpose() != null) {
queryParams.add(new QueryParam("purpose", model.getPurpose()));
}
List<ApiUser> apiUsers = this.apiUserService.findApiUsersByParamsSortDate(queryParams);
List<ApiUserBo> apiUserBoList = new ArrayList<ApiUserBo>();
for (ApiUser apiUser : apiUsers) {
User user = this.userService.findById(apiUser.getId());
@@ -194,6 +215,8 @@ public class ApiUserController {
apiUser.setDeadTime(model.getDeadTime());
apiUser.setManager(model.getManager());
apiUser.setIsMonitor(model.getIsMonitor());
apiUser.setContact(model.getContact());
apiUser.setPhone(model.getPhone());
this.apiUserService.save(apiUser);
// 新增用户,默认挂牌价改为默认评估价
model.setPriceType("evaluate");
@@ -237,6 +260,8 @@ public class ApiUserController {
bo.setDeadTime(apiUser.getDeadTime());
bo.setManager(apiUser.getManager());
bo.setIsMonitor(apiUser.getIsMonitor());
bo.setContact(apiUser.getContact());
bo.setPhone(apiUser.getPhone());
ApiUserCfg apiUserCfg_rate = apiUserCfgService.findByUserId(apiUser.getId(), ApiUserCfg.ApiUserCfgKey.EVALUATE_RATE);
if (apiUserCfg_rate != null) {
bo.setEvaluateRate((Double) apiUserCfg_rate.getCfgValue());
@@ -290,6 +315,8 @@ public class ApiUserController {
dataApiUser.put("deadTime", model.getDeadTime());
dataApiUser.put("manager", model.getManager());
dataApiUser.put("isMonitor", model.getIsMonitor());
dataApiUser.put("contact", model.getContact());
dataApiUser.put("phone", model.getPhone());
this.apiUserService.update(dataApiUser, userId);
// 更改用户密码
// this.userService.updateById(user,userId);
@@ -676,6 +703,9 @@ public class ApiUserController {
public Object saveAuthAction(ApiUserModel model, HttpServletRequest request) throws IllegalAccessException {
List<OpenResource> openResourceList = openResourceService.findAll();
Map<String, String> apiMap = converMapData(openResourceList);
model.setViewType("json");
model.setViewParam("config", null);
Long userId = model.getUserId();
@@ -689,6 +719,7 @@ public class ApiUserController {
authority.setSupportLatLng(model.isSupportLatLng());
apiUserAuthorityService.save(authority);
} else {
Map<String, Integer> countMap = authority.getTotalCountMap();
if (model.getLimit() != null) {
Map<String, Integer> limitCountMap = authority.getLimitCountMap();
if (limitCountMap == null) {
@@ -702,7 +733,34 @@ public class ApiUserController {
if (totalCountMap == null) {
totalCountMap = new HashMap<String, Integer>();
}
totalCountMap.put(model.getUri(), model.getSum());
Integer count = model.getSum();
//增加次数修改日志
ApiCountLog apiCountLog = new ApiCountLog();
if (countMap != null && countMap.containsKey(model.getUri())) {
String bkoffUserId = (String) ThreadLocalData.getInstance().get(ThreadLocalKey.UserId);
User user = userService.findById(userId);
BkoffUsers bkoffUser = bkoffUsersService.findBkoffUsersById(bkoffUserId);
apiCountLog.setUserId(userId);
apiCountLog.setUserName(user.getDisplayName());
apiCountLog.setUri(model.getUri());
apiCountLog.setUriName(apiMap.get(model.getUri()));
apiCountLog.setOperator(bkoffUser.getRealName());
Integer oldCount = countMap.get(model.getUri());
apiCountLog.setOldCount(oldCount);
apiCountLog.setNewCount(count);
if (count > oldCount) {
apiCountLog.setOperate("增加" + (count - oldCount) + "次");
} else if (oldCount > count) {
apiCountLog.setOperate("减少" + (oldCount - count) + "次");
}
apiCountLog.setOperateTime(new Date());
// 次数改变了再记录
if (!count.equals(oldCount)) {
apiCountLogService.save(apiCountLog);
}
}
totalCountMap.put(model.getUri(), count);
authority.setTotalCountMap(totalCountMap);
}
if (model.getIsCheckCount() != null) {
@@ -1095,91 +1153,110 @@ public class ApiUserController {
if (endDate != null) {
model.setEndDate(DateUtil.formatToYYYYMMDD(endDate));
}
Date nowDate = DateUtil.parseStringToDate(DateUtil.formatToYYYYMMDD(new Date()));
Date lastWeek = DateUtil.add(DateUtil.formatToYYYYMMDD(new Date()), -7);
Date lastMonth = DateUtil.add(DateUtil.formatToYYYYMMDD(new Date()), -30);
long diffInMillies = Math.abs(endDate.getTime() - startDate.getTime());
// 将毫秒转换为天数
long days = diffInMillies / (1000 * 60 * 60 * 24); // 使用long来计算天数
// 只查询正式账号
List<QueryParam> queryParams = Arrays.asList(new QueryParam("isTest", 0));
// 只查询正式账号、未过期、未禁用
List<QueryParam> queryParams = Arrays.asList(new QueryParam("isTest", 0),
new QueryParam("status", 0),
new QueryParam("deadTime", QueryParam.GREATER_THAN_EQUAL_OPERATOR, new Date()));
List<ApiUser> apiUsers = this.apiUserService.findApiUsersByParamsSortDate(queryParams);
// 获取正式账号的ids
List<Integer> ids = new ArrayList<Integer>();
for (ApiUser apiUser : apiUsers) {
ids.add((int) apiUser.getId());
}
// 只获取正式用户的
List<OpenUriAnaly> analyAll = openUriAnalyService.findOpenUriAnalyLogs(model.getUserId(), null, startDate, endDate);
List<OpenUriAnaly> analys = new ArrayList<OpenUriAnaly>();
for (OpenUriAnaly analy : analyAll) {
if (ids.contains(analy.getApiUserId())) {
analys.add(analy);
}
}
List<Integer> userIds = new ArrayList<Integer>();
// 获取有访问记录的用户ID
for (OpenUriAnaly analy : analys) {
if (!userIds.contains(analy.getApiUserId())) {
userIds.add(analy.getApiUserId());
}
}
//所有API
List<OpenResource> allApi = openResourceService.findAll();
// 所有API的URI与name对应Map
Map<String, String> apiMap = converMapData(allApi);
List<StatAnalyBo> bosAll = new ArrayList<StatAnalyBo>();
if (CollectionUtils.isNotEmpty(userIds)) {
if (CollectionUtils.isNotEmpty(apiUsers)) {
// 根据访问遍历用户
for (Integer userId : userIds) {
long id = (long) userId;
for (ApiUser apiUser : apiUsers) {
long id = apiUser.getId();
// 获取每个用户的访问
List<OpenUriAnaly> analyUser = openUriAnalyService.findOpenUriAnalyLogs(id, null, startDate, endDate);
ApiUserAuthority authority = apiUserAuthorityService.findByUserId(id);
// 用户有的api
List<String> userApi = authority.getOpenResourseUris();
Map<String, Integer> countMap = authority.getTotalCountMap();
// 获取 deadline
ApiUser apiUser = apiUserService.findApiUserById(id);
// 获取用户名
User user = userService.findById(id);
List<StatAnalyBo> bos = null;
bos = createAnalyBosByLink(analyUser);
long date = DateUtil.parseStringToDate("2016-11-23").getTime();
if (startDate.getTime() >= date && endDate.getTime() > date) {
List<ApiInvokeStatistical> apiInvokeStatisticalList = apiInvokeStatisticalService.findApiInvokeStatisticalList(id, startDate, endDate);
if (bos != null && apiInvokeStatisticalList.size() > 0) {
Map<String, Map<String, Integer>> resultMap = getCountByUri(apiInvokeStatisticalList);
for (StatAnalyBo boTemp : bos) {
boTemp.setPurpose(apiUser.getPurpose());
String url = boTemp.getKey();
boTemp.setSuccessEffectiveTime(resultMap.get(url).get("successEffectiveCount"));
boTemp.setSuccessInvalidTime(resultMap.get(url).get("successInvalidCount"));
boTemp.setDefeatTime(resultMap.get(url).get("defeatCount"));
if (apiUser != null) {
boTemp.setDeadline(apiUser.getDeadTime());
}
long curVistedCount = apiVisitCountService.findApiVisitCountByDay(id, url, DateUtil.truncateDay(new Date()));
long historyCount = apiVisitCountService.findApiVisitAllCount(id, url, DateUtil.truncateDay(new Date()));
if (countMap != null && countMap.containsKey(url)) {
Integer totalCount = countMap.get(url);
long usedCount = curVistedCount + historyCount;
boTemp.setSurplusCallCount(Integer.valueOf((int) (totalCount - usedCount)));
}
if (user != null) {
boTemp.setName(user.getDisplayName());
boTemp.setUserId((int) user.getId());
}
List<ApiInvokeStatistical> weekApiInvokeStatisticalList;
if (lastWeek == startDate && nowDate == endDate) {
weekApiInvokeStatisticalList = apiInvokeStatisticalList;
} else {
weekApiInvokeStatisticalList = apiInvokeStatisticalService.findApiInvokeStatisticalList(id, lastWeek, nowDate);
}
List<ApiInvokeStatistical> monthApiInvokeStatisticalList;
if (lastMonth == startDate && nowDate == endDate) {
monthApiInvokeStatisticalList = apiInvokeStatisticalList;
} else {
monthApiInvokeStatisticalList = apiInvokeStatisticalService.findApiInvokeStatisticalList(id, lastMonth, nowDate);
}
Map<String, Map<String, Integer>> resultMap = getCountByUri(apiInvokeStatisticalList);
Map<String, Map<String, Integer>> weekResultMap = getCountByUri(weekApiInvokeStatisticalList);
Map<String, Map<String, Integer>> monthResultMap = getCountByUri(monthApiInvokeStatisticalList);
List<ApiVisitCount> apiVisitCounts = apiVisitCountService.findAllApiVisitCount(id, boTemp.getKey(), startDate, endDate);
int total = 0;
for (ApiVisitCount apiVisitCount : apiVisitCounts) {
total += apiVisitCount.getVisitCount();
}
boTemp.setBillingCount(total);
double dailyUse = boTemp.getCount() * 1.0 / days;
boTemp.setDailyUse(dailyUse);
// 遍历用户所有的api
for (String url : userApi) {
// 统计用过的api
String urlName = apiMap.get(url);
StatAnalyBo bo = new StatAnalyBo();
if (resultMap.containsKey(url)) {
// 自定义时间的数据
bo.setSuccessEffectiveTime(resultMap.get(url).get("successEffectiveCount"));
bo.setSuccessInvalidTime(resultMap.get(url).get("successInvalidCount"));
bo.setDefeatTime(resultMap.get(url).get("defeatCount"));
bo.setCount(resultMap.get(url).get("totalCount"));
double dailyUse = bo.getCount() * 1.0 / days;
bo.setDailyUse(dailyUse);
}
if (weekResultMap.containsKey(url)) {
// 近一周数据
bo.setWeekSuccessEffectiveTime(weekResultMap.get(url).get("successEffectiveCount"));
bo.setWeekSuccessInvalidTime(weekResultMap.get(url).get("successInvalidCount"));
bo.setWeekDefeatTime(weekResultMap.get(url).get("defeatCount"));
bo.setWeekCount(weekResultMap.get(url).get("totalCount"));
double dailyUse = bo.getWeekCount() * 1.0 / 7;
bo.setWeekDailyUse(dailyUse);
}
if (monthResultMap.containsKey(url)) {
// 成功有效次数
bo.setMonthSuccessEffectiveTime(monthResultMap.get(url).get("successEffectiveCount"));
// 成功无效次数
bo.setMonthSuccessInvalidTime(monthResultMap.get(url).get("successInvalidCount"));
// 失败次数
bo.setMonthDefeatTime(monthResultMap.get(url).get("defeatCount"));
bo.setMonthCount(monthResultMap.get(url).get("totalCount"));
double dailyUse = bo.getMonthCount() * 1.0 / 30;
bo.setMonthDailyUse(dailyUse);
}
bo.setUrl(url);
bo.setUrlName(urlName);
bo.setDeadline(apiUser.getDeadTime());
bo.setUserId((int) id);
bo.setUserName(user.getDisplayName());
//剩余调用量
long curVistedCount = apiVisitCountService.findApiVisitCountByDay(id, url, DateUtil.truncateDay(new Date()));
long historyCount = apiVisitCountService.findApiVisitAllCount(id, url, DateUtil.truncateDay(new Date()));
if (countMap != null && countMap.containsKey(url)) {
Integer totalCount = countMap.get(url);
long usedCount = curVistedCount + historyCount;
bo.setSurplusCallCount(Integer.valueOf((int) (totalCount - usedCount)));
}
bosAll.add(bo);
}
}
bosAll.addAll(bos);
}
this.buildReport(bosAll, response, startDate, endDate);
}
this.buildReport(bosAll, response, startDate, endDate);
model.setViewType("stream");
return model;
}
@@ -1191,39 +1268,52 @@ public class ApiUserController {
for (StatAnalyBo bo : bos) {
List<String> row = new ArrayList<String>();
row.add(bo.getUserId() != null ? bo.getUserId().toString() : "");
row.add(bo.getName() != null ? bo.getName().toString() : "");
if (bo.getPurpose() != null) {
Integer purpose = bo.getPurpose();
if (purpose == 1) {
row.add("API");
} else if (purpose == 2) {
row.add("PDS");
} else if (purpose == 4) {
row.add("房生活");
}
}else {
row.add(bo.getUserName() != null ? bo.getUserName().toString() : "");
row.add(bo.getDeadline() != null ? DateUtils.format(bo.getDeadline(), "yyyy/MM/dd") : "");
row.add(bo.getUrl() != null ? bo.getUrl().toString() : "");
row.add(bo.getUrlName() != null ? bo.getUrlName().toString() : "");
row.add(bo.getSurplusCallCount() != null ? bo.getSurplusCallCount().toString() : "");
// 上周
row.add(bo.getWeekCount() != null ? bo.getWeekCount().toString() : "");
if (bo.getWeekDailyUse() != null) {
// 格式化为保留一位小数的字符串
String formattedDailyUse = String.format("%.1f", bo.getWeekDailyUse());
row.add(formattedDailyUse);
} else {
row.add("");
}
row.add(bo.getKey() != null ? bo.getKey().toString() : "");
row.add(bo.getSurplusCallCount() != null ? bo.getSurplusCallCount().toString() : "");
row.add(bo.getDeadline() != null ? DateUtils.format(bo.getDeadline(), "yyyy/MM/dd") : "");
row.add(bo.getWeekSuccessEffectiveTime() != null ? bo.getWeekSuccessEffectiveTime().toString() : "");
row.add(bo.getWeekSuccessInvalidTime() != null ? bo.getWeekSuccessInvalidTime().toString() : "");
row.add(bo.getWeekDefeatTime() != null ? bo.getWeekDefeatTime().toString() : "");
// 上个月
row.add(bo.getMonthCount() != null ? bo.getMonthCount().toString() : "");
if (bo.getMonthDailyUse() != null) {
// 格式化为保留一位小数的字符串
String formattedDailyUse = String.format("%.1f", bo.getMonthDailyUse());
row.add(formattedDailyUse);
} else {
row.add("");
}
row.add(bo.getMonthSuccessEffectiveTime() != null ? bo.getMonthSuccessEffectiveTime().toString() : "");
row.add(bo.getMonthSuccessInvalidTime() != null ? bo.getMonthSuccessInvalidTime().toString() : "");
row.add(bo.getMonthDefeatTime() != null ? bo.getMonthDefeatTime().toString() : "");
// 自定义时间
row.add(bo.getCount() != null ? bo.getCount().toString() : "");
if (bo.getDailyUse() !=null){
if (bo.getDailyUse() != null) {
// 格式化为保留一位小数的字符串
String formattedDailyUse = String.format("%.1f", bo.getDailyUse());
row.add(formattedDailyUse);
}else {
} else {
row.add("");
}
row.add(bo.getPercent() != null ? bo.getPercent().toString() : "");
row.add(bo.getSuccessEffectiveTime() != null ? bo.getSuccessEffectiveTime().toString() : "");
row.add(bo.getSuccessInvalidTime() != null ? bo.getSuccessInvalidTime().toString() : "");
row.add(bo.getDefeatTime() != null ? bo.getDefeatTime().toString() : "");
row.add(bo.getBillingCount() != null ? bo.getBillingCount().toString() : "");
dataList.add(row);
}
String fileName = "用户账号使用统计(" + DateUtils.format(startDate, "yyyy/MM/dd") + "—" + DateUtils.format(endDate, "yyyy/MM/dd") + ").xlsx";
String dateStr = "(" + DateUtils.format(startDate, "yyyy/MM/dd") + "—" + DateUtils.format(endDate, "yyyy/MM/dd") + ")";
String fileName = "用户账号使用统计" + dateStr + ".xlsx";
// ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build();
String displayName = URLEncoder.encode(fileName, "UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=\"" + displayName + "\"");
@@ -1231,8 +1321,11 @@ public class ApiUserController {
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("用户账号使用统计");
List<String> head = Arrays.asList(
"用户ID", "账号", "账号用途", "接口", "剩余使用次数", "合同到期时间", "访问次数", "日均访问量",
"占比(%)", "成功并有效", "成功并无效", "失败次数", "计费次数");
"用户ID", "账号", "合同到期时间", "接口", "接口名称", "剩余使用次数",
"访问次数(近一周)", "日均访问量(近一周)", "成功并有效(近一周)", "成功并无效(近一周)", "失败次数(近一周)",
"访问次数(近一月)", "日均访问量(近一月)", "成功并有效(近一月)", "成功并无效(近一月)", "失败次数(近一月)",
"访问次数" + dateStr, "日均访问量" + dateStr, "成功并有效" + dateStr, "成功并无效" + dateStr, "失败次数" + dateStr
);
// 创建表头
Row headRow = sheet.createRow(0);
for (int i = 0; i < head.size(); i++) {
@@ -1852,6 +1945,7 @@ public class ApiUserController {
Integer successEffectiveCount = detailMap.get("successEffectiveCount");
Integer successInvalidCount = detailMap.get("successInvalidCount");
Integer defeatCount = detailMap.get("defeatCount");
Integer totalCount = detailMap.get("totalCount");
if (successEffectiveCount != null) {
successEffectiveCount = successEffectiveCount + apiInvokeStatistical.getSuccessEffectiveTime();
} else {
@@ -1868,10 +1962,16 @@ public class ApiUserController {
} else {
defeatCount = apiInvokeStatistical.getDefeatTime();
}
if (totalCount != null) {
totalCount = totalCount + apiInvokeStatistical.getTotalTime();
} else {
totalCount = apiInvokeStatistical.getTotalTime();
}
detailMap.put("successEffectiveCount", successEffectiveCount);
detailMap.put("successInvalidCount", successInvalidCount);
detailMap.put("defeatCount", defeatCount);
detailMap.put("totalCount", totalCount);
}
return resultMap;
@@ -1989,4 +2089,12 @@ public class ApiUserController {
model.setViewParam("location", "/apiUser/list");
return model;
}
public void setBkoffUsersService(BkoffUsersService bkoffUsersService) {
this.bkoffUsersService = bkoffUsersService;
}
public void setApiCountLogService(ApiCountLogService apiCountLogService) {
this.apiCountLogService = apiCountLogService;
}
}
@@ -33,9 +33,9 @@ public class DevelopmentZoneController {
if (pager.getCurrentPage() > 100) {
pager.setCurrentPage(1);
}
long countDev = developmentZoneService.countDev(model.getProvince(), model.getName(), model.getLevel());
long countDev = developmentZoneService.countDev(model.getProvince(),model.getCityName1(), model.getName(), model.getLevel());
pager.setTotalRows((int) countDev);
List<DevelopmentZone> developmentZones = developmentZoneService.findDevelopmentZone(model.getProvince(), model.getName(), model.getLevel(), pager);
List<DevelopmentZone> developmentZones = developmentZoneService.findDevelopmentZone(model.getProvince(),model.getCityName1(), model.getName(), model.getLevel(), pager);
model.setDevelopmentZoneList(developmentZones);
model.setPager(pager);
return model;
@@ -422,9 +422,11 @@ public class fjtEvaluationController {
row.createCell(6).setCellValue(bo.getCardId());
row.createCell(7).setCellValue(bo.getEmail());
row.createCell(8).setCellValue(allRoles.get(String.valueOf(bo.getRole())));
row.createCell(9).setCellValue(bo.getCharge() + "房豆");
row.createCell(9).setCellValue("");
row.createCell(10).setCellValue(DateUtil.formatByPattern(bo.getDateCreated(),"yyyy年MM月dd日"));
row.createCell(13).setCellValue(bo.getAccountChecker());
row.createCell(14).setCellValue(DateUtil.formatByPattern(bo.getEvaluationDate(), "yyyy年MM月dd日"));
row.createCell(14).setCellValue("");
row.createCell(17).setCellValue(DateUtil.formatByPattern(bo.getEvaluationDate(), "yyyy年MM月dd日"));
}
}
@@ -0,0 +1,116 @@
package com.fangjia.bkoff.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.fangjia.dal.mongo.model.ApiCountLog;
import com.fangjia.dal.mongo.model.Township;
import java.util.Date;
import java.util.List;
public class ApiCountLogModel extends BaseModel {
@JSONField(name = "id")
private String id;
@JSONField(name = "user_id")
private Long userId;
@JSONField(name = "uri")
private String uri;
@JSONField(name = "user_name")
private String uriName;
@JSONField(name = "operate")
private String operate;
@JSONField(name = "operator")
private String operator;
@JSONField(name = "operate_time")
private Date operateTime;
// 修改次数前总次数
@JSONField(name = "old_count")
private Integer oldCount;
// 修改次数后的次数
@JSONField(name = "new_count")
private Integer newCount;
private List<ApiCountLog> apiCountLogList;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getUriName() {
return uriName;
}
public void setUriName(String uriName) {
this.uriName = uriName;
}
public String getOperate() {
return operate;
}
public void setOperate(String operate) {
this.operate = operate;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public Date getOperateTime() {
return operateTime;
}
public void setOperateTime(Date operateTime) {
this.operateTime = operateTime;
}
public Integer getOldCount() {
return oldCount;
}
public void setOldCount(Integer oldCount) {
this.oldCount = oldCount;
}
public Integer getNewCount() {
return newCount;
}
public void setNewCount(Integer newCount) {
this.newCount = newCount;
}
public List<ApiCountLog> getApiCountLogList() {
return apiCountLogList;
}
public void setApiCountLogList(List<ApiCountLog> apiCountLogList) {
this.apiCountLogList = apiCountLogList;
}
}
@@ -40,6 +40,10 @@ public class ApiUserModel extends BaseModel {
private Map<String,Double> priceRatingMap;
private Integer isMonitor;
private String contact;
private String phone;
public String getPriceType() {
return priceType;
}
@@ -70,7 +74,7 @@ public class ApiUserModel extends BaseModel {
private String type;
private String citys;// spell
private String unCheckCitys;// 页面反选的city
private int status;
private Integer status;
private String uri;
private boolean hasAuth;
private boolean supportLatLng;
@@ -378,15 +382,15 @@ public class ApiUserModel extends BaseModel {
this.limit = limit;
}
public int getStatus() {
public Integer getStatus() {
return status;
}
public void setStatus(int status) {
public void setStatus(Integer status) {
this.status = status;
}
public String getCompany() {
public String getCompany() {
return company;
}
@@ -615,4 +619,20 @@ public class ApiUserModel extends BaseModel {
public void setIsMonitor(Integer isMonitor) {
this.isMonitor = isMonitor;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
@@ -0,0 +1,63 @@
<#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>客户API次数操作日志</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">
<form action="../apiCountLog/list" id="_search_log_form">
<div>
<label for="userId">用户ID:</label>
<input type="text" name="userId" id="userId" class="input-medium" style="margin-top:9px;"
value="${userId!}"></input>
<label for="uri">uri:</label>
<input type="text" name="uri" id="uri" class="input-medium" style="margin-top:9px;"
value="${uri!}"></input>
<input id="queryBtn" class="btn btn-primary" type="submit" value="查询"/>
</div>
</form>
<div class="list" style="margin-top:5px;">
<span style="font-size:12px;">查询到<b style="color:red;">${pager.totalRows!}</b>条记录</span>
<table style="float:left;" name="reginTable" class="regionTab">
<tr>
<th>用户ID</th>
<th>用户昵称</th>
<th>uri</th>
<th>API名称</th>
<th>操作</th>
<th>原次数</th>
<th>现次数</th>
<th>操作人员</th>
<th>修改日期</th>
</tr>
<#list apiCountLogList as it>
<tr>
<td>${it.userId!}</td>
<td>${it.userName!}</td>
<td>${it.uri!}</td>
<td>${it.uriName!}</td>
<td>${it.operate!}</td>
<td>${it.oldCount!}</td>
<td>${it.newCount!}</td>
<td>${it.operator!}</td>
<td>${it.operateTime!?string("yyyy-MM-dd HH:mm:ss")}</td>
</tr>
</#list>
</table>
<#if pager??>
<@d_pager controller="apiCountLog" action="list" currentPage=pager.currentPage totalPages=pager.totalPages theme="full"/>
</#if>
</div>
</div>
</body>
</html>
</#compress>
@@ -34,12 +34,12 @@
<form id="addForm" action="doAdd" method="post">
<tr>
<td><b>昵称</b></td>
<td><input name="displayName" value="${displayName!}"/></td>
<td><input id="displayName" name="displayName" placeholder="必填项" value="${displayName!}"/></td>
</tr>
<tr>
<td><b>用户名</b></td>
<input name="userId" value="${userId!}" type="hidden"/>
<td><input id="userName" name="userName" value="${userName!}"/></td>
<td><input id="userName" name="userName" placeholder="必填项" value="${userName!}"/></td>
</tr>
<tr>
<td><b>密码</b></td>
@@ -59,7 +59,7 @@
<td>账户用途</td>
<td>
<select name="purpose">
<option value="">请选择</option>
<#-- <option value="">请选择</option>-->
<option value="1">API</option>
<option value="2">PDS</option>
<option value="4">房生活</option>
@@ -75,15 +75,27 @@
</tr>
<tr>
<td>Email</td>
<td><input name="email" value="${email!}"/></td>
<td>
<div style="display: inline-block;">
<textarea id="email" name="email" rows="5" cols="12"
style="height: 100px;width: 250px;float: left">${email!}</textarea>
</div>
<div style="display: inline-block;">
(每行一个,第一个为发送,其余抄送)<br/>
例子:<br/>
123456@qq.com<br/>
88888@163.com<br/>
987654@gmail.com
</div>
</td>
</tr>
<tr>
<td>销售负责人</td>
<td><input name="manager" value="${manager!}"/></td>
<td><input id="manager" name="manager" placeholder="必填项" value="${manager!}"/></td>
</tr>
<tr>
<td>公司</td>
<td><input name="company" value="${company!}"/></td>
<td><input id="company" name="company" placeholder="必填项" value="${company!}"/></td>
</tr>
<tr>
<td>估价调整比率</td>
@@ -92,13 +104,21 @@
</tr>
<tr>
<td>siteName</td>
<td><input name="siteName" value="${siteName!}"/></td>
<td><input name="siteName" value="${siteName!}"/></td>
</tr>
<tr>
<td>到期时间</td>
<td><input name="deadTime"
<td><input name="deadTime" id="deadTime" placeholder="必填项"
onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'%y-%M-{%d+7}'})"/></td>
</tr>
<tr>
<td>客户联系人</td>
<td><input id="contact" name="contact" placeholder="必填项" value="${contact!}"/></td>
</tr>
<tr>
<td>客户联系人电话</td>
<td><input id="phone" name="phone" placeholder="必填项" value="${phone!}"/></td>
</tr>
<tr>
<td>ip地址</td>
<td><textarea id="ip" name="ip" rows="5" cols="12"
@@ -125,6 +145,57 @@
return false
}
}
// 检查其他字段是否为空
var displayName = $.trim($("#displayName").val());
var userName = $.trim($("#userName").val());
var password = $.trim($("#password").val());
var email = $.trim($("#email").val());
var manager = $.trim($("#manager").val());
var company = $.trim($("#company").val());
var deadTime = $.trim($("#deadTime").val());
var contact = $.trim($("#contact").val());
var phone = $.trim($("#phone").val());
if (displayName === '') {
alert("昵称不能为空!");
return false;
}
if (userName === '') {
alert("用户名不能为空!");
return false;
}
if (password === '') {
alert("密码不能为空!");
return false;
}
if (email === '') {
alert("邮箱不能为空!");
return false;
}
if (manager === '') {
alert("销售负责人不能为空!");
return false;
}
if (company === '') {
alert("公司不能为空!");
return false;
}
if (deadTime === '') {
alert("到期时间不能为空!");
return false;
}
if (contact === '') {
alert("客户联系人不能为空!");
return false;
}
if (phone === '') {
alert("客户联系人电话不能为空!");
return false;
}
if (email === '') {
alert("邮箱不能为空!");
return false;
}
if (_userNameCheck) {
$("#addForm").submit();
}
@@ -7,6 +7,11 @@
<title>api用户权限控制</title>
<link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}" />
<link rel="stylesheet" type="text/css" href="../style/theme.css?v=${version}" />
<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}" />
<script type="text/javascript" src="../js/jquery-1.9.1.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>
<#include "/common_js.ftl" />
<script type="text/javascript">
</script>
@@ -65,6 +70,9 @@
<th align="center" width="30%">
访问最大次数(每天)/(总数)
</th>
<th align="center" width="15%">
访问次数修改
</th>
<th align="center" width="10%">
是否按查得计费<input type="checkbox" id="isCheckCount" >全选</input>
</th>
@@ -98,12 +106,20 @@
&nbsp;&nbsp;/
<#if bo.totalCountMap?? && bo.totalCountMap[bo.uri!]??>
<input type="text" value="${bo.totalCountMap[bo.uri!]}" name="sum" id="sum_${bo_index + 1}" style="width:80px;" ></input>
<input type="text" value="${bo.totalCountMap[bo.uri!]}" name="sum" id="sum_${bo_index + 1}" style="width:80px;" readonly ></input>
<#else>
<input type="text" value="" name="sum" id="sum_${bo_index + 1}" style="width:80px;" ></input>
<input type="text" value="" name="sum" id="sum_${bo_index + 1}" style="width:80px;" readonly></input>
</#if>
</td>
<td>
<button type="button" data-toggle="modal" data-target="#myModal" id="add_${bo_index + 1}">
增加
</button>
<button type="button" data-toggle="modal" data-target="#myModal" id="reduce_${bo_index + 1}">
减少
</button>
</td>
<td align="center">
<input type="checkbox" <#if bo.isCheckCount==1>checked </#if> id="isCheckCount_${bo_index + 1}" ></input>
</td>
@@ -111,6 +127,9 @@
<td align="center">
<input type="button" id="save_${bo_index + 1}" value="保存">
<input type="button" data-uri="${bo.uri!}" data-userid = "${authority.userId!}" value="编辑字段"/>
<a href="../apiCountLog/list?userId=${userId!}&uri=${bo.uri!}">
<button>日志查看</button>
</a>
</td>
</tr>
</#list>
@@ -130,6 +149,26 @@
</table>
</div>
</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">
<form class="form-horizontal" id="editForm">
<div class="control-group">
<label class="control-label" for="countInput">次数</label>
<div class="controls">
<input type="text" id="countInput" name="countInput" value="" /> 次
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" id="submitCount" data-dismiss="modal" aria-hidden="true">保存</button>
<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
</div>
</div>
<div class="theme-popover" id = "dialog" style="width:450px;">
<div class="theme-poptit">
<a href="javascript:;" title="关闭" class="close">×</a>
@@ -97,15 +97,27 @@
</tr>
<tr>
<td>Email</td>
<td><input name="email" value="${apiUserBo.email!}"/></td>
<td>
<div style="display: inline-block;">
<textarea id="email" name="email" rows="5" cols="12"
style="height: 100px;width: 250px;float: left">${apiUserBo.email!}</textarea>
</div>
<div style="display: inline-block;">
(每行一个,第一个为发送,其余抄送)<br/>
例子:<br/>
123456@qq.com<br/>
88888@163.com<br/>
987654@gmail.com
</div>
</td>
</tr>
<tr>
<td>销售负责人</td>
<td><input name="manager" value="${apiUserBo.manager!}" /></td>
<td><input id="manager" name="manager" placeholder="必填项" value="${apiUserBo.manager!}" /></td>
</tr>
<tr>
<td>公司</td>
<td><input name="company" value="${apiUserBo.company!}"/></td>
<td><input id="company" name="company" placeholder="必填项" value="${apiUserBo.company!}"/></td>
</tr>
<tr>
<td>估价调整比率</td>
@@ -128,7 +140,15 @@
</tr>
<tr>
<td>到期时间</td>
<td><input name="deadTime" value="<#if apiUserBo.deadTime??>${apiUserBo.deadTime?string("yyyy-MM-dd")}</#if>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></td>
<td><input id="deadTime" name="deadTime" placeholder="必填项" value="<#if apiUserBo.deadTime??>${apiUserBo.deadTime?string("yyyy-MM-dd")}</#if>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></td>
</tr>
<tr>
<td>客户联系人</td>
<td><input id="contact" name="contact" placeholder="必填项" value="${apiUserBo.contact!}"/></td>
</tr>
<tr>
<td>客户联系人电话</td>
<td><input id="phone" name="phone" placeholder="必填项" value="${apiUserBo.phone!}"/></td>
</tr>
<tr>
<td>ip地址</td>
@@ -156,6 +176,42 @@
return false
}
}
// 检查其他字段是否为空
var email = $.trim($("#email").val());
var manager = $.trim($("#manager").val());
var company = $.trim($("#company").val());
var deadTime = $.trim($("#deadTime").val());
var contact = $.trim($("#contact").val());
var phone = $.trim($("#phone").val());
if (email === '') {
alert("邮箱不能为空!");
return false;
}
if (manager === '') {
alert("销售负责人不能为空!");
return false;
}
if (company === '') {
alert("公司不能为空!");
return false;
}
if (deadTime === '') {
alert("到期时间不能为空!");
return false;
}
if (contact === '') {
alert("客户联系人不能为空!");
return false;
}
if (phone === '') {
alert("客户联系人电话不能为空!");
return false;
}
if (email === '') {
alert("邮箱不能为空!");
return false;
}
$("#submitForm").attr("action", "update");
$("#submitForm").submit();
}
@@ -47,6 +47,35 @@
<div style="padding-left:5px;">
共有用户<b>${apiUserBoList?size}</b>个
</div>
<form action="../apiUser/list" id="_search_log_form">
<div>
<div class="form-group">
<label for="purpose" class="form-label">账号用途:</label>
<select name="purpose" class="form-select">
<option value="1">API</option>
<option value="2">PDS</option>
<option value="4">房生活</option>
<option >请选择</option>
</select>
</div>
<div class="form-group">
<label for="isTest" class="form-label">账号类型:</label>
<select name="isTest" class="form-select">
<option value="0">正式账号</option>
<option value="1">测试账号</option>
<option value="2">内部账号</option>
</select>
</div>
<div class="form-group">
<label for="status" class="form-label">账号状态:</label>
<select name="status" class="form-select">
<option value="0">正常</option>
<option value="1">禁用</option>
</select>
</div>
<input id="queryBtn" class="btn btn-primary form-button" type="submit" value="查询"/>
</div>
</form>
<table width="100%">
<thead>
<tr>
@@ -56,9 +85,9 @@
<th align="center" width="100px">
昵称
</th>
<th align="center" width="60px">
账户用途
</th>
<#-- <th align="center" width="60px">-->
<#-- 账户用途-->
<#-- </th>-->
<th align="center" width="100px">
username
</th>
@@ -100,15 +129,15 @@
<td align="center">
<a href="../apiUser/edit?userId=${bo.userId!}">${bo.displayName!}</a>
</td>
<td>
<#if bo.purpose?? && bo.purpose == 1>
API
<#elseif bo.purpose?? && bo.purpose == 2>
PDS
<#elseif bo.purpose?? && bo.purpose == 4>
房生活
</#if>
</td>
<#-- <td>-->
<#-- <#if bo.purpose?? && bo.purpose == 1>-->
<#-- API-->
<#-- <#elseif bo.purpose?? && bo.purpose == 2>-->
<#-- PDS-->
<#-- <#elseif bo.purpose?? && bo.purpose == 4>-->
<#-- 房生活-->
<#-- </#if>-->
<#-- </td>-->
<td align="center">
${bo.userName!}
</td>
@@ -177,5 +206,23 @@
</div>
</div>
</body>
<style>
.form-label {
font-size: 15px; /* 增加标签的字体大小 */
}
.form-select {
font-size: 15px; /* 增加选择框的字体大小 */
margin-right: 10px; /* 调整选择框之间的间距 */
}
.form-button {
font-size: 15px; /* 增加按钮的字体大小 */
}
.form-group {
display: inline-block; /* 使每个表单组不换行 */
}
</style>
</html>
</#compress>
@@ -21,6 +21,9 @@
<label for="province">省份:</label>
<input type="text" name="province" id="province" class="input-medium" style="margin-top:9px;"
value="${province!}"></input>
<label for="cityName1">城市:</label>
<input type="text" name="cityName1" id="cityName1" class="input-medium" style="margin-top:9px;"
value="${cityName1!}"></input>
<label for="name">名称:</label>
<input type="text" name="name" id="name" class="input-medium" style="margin-top:9px;"
value="${name!}"></input>
@@ -71,7 +74,14 @@
</#if>
</td>
<td>${it.operator!}</td>
<td>${it.createTime!?string("yyyy-MM-dd HH:mm:ss")}</td>
<td>
<#if it.createTime??>
${it.createTime!?string("yyyy-MM-dd HH:mm:ss")}
<#else>
</#if>
</td>
<td>
<a href="show?id=${it.id!}" target="_blank">查看</a>
<a href="../developmentZone/edit?id=${it.id!}" target="_blank">新建围栏</a>
@@ -112,4 +112,60 @@ $(document).ready(function() {
});
});
});
// 当点击"增加"按钮时
$('button[data-target="#myModal"]').click(
function () {
var idNum = $(this).closest('tr').index() + 1; // 获取按钮所在行的索引
var isAdd = $(this).attr('id').startsWith('add'); // 判断是增加还是减少
// 动态设置模态框标题
if (isAdd) {
$('#myModalLabel').text('增加次数');
} else {
$('#myModalLabel').text('减少次数');
}
// 绑定修改次数的功能
$('#submitCount').unbind('click').click(function() {
modifyCount(isAdd, idNum);
});
// var id_num = $(this).closest('tr').index();
// var totalInputId = '#sum_' + (id_num + 1);
// var totalValue = parseInt($(totalInputId).val()) || 0; // 获取当前总次数的值
//
// // 解除之前的绑定事件
// $('#editSubmit').unbind('click').click(function () {
// var addedCount = parseInt($('#cityPop').val()) || 0; // 获取用户输入的次数
//
// var newTotal = totalValue + addedCount; // 将输入的次数加到当前总次数上
//
// $(totalInputId).val(newTotal); // 更新总次数输入框的值
//
// $("input[id='save_"+(id_num+1)+"']").trigger('click');
// });
});
function modifyCount(isAdd, idNum) {
var totalInputId = '#sum_' + idNum;
var totalValue = parseInt($(totalInputId).val()) || 0; // 获取当前总次数的值
var count = parseInt($('#countInput').val()) || 0; // 获取用户输入的次数
var newTotal = isAdd ? totalValue + count : totalValue - count; // 根据增加或减少计算新的总次数
if (newTotal < 0) {
newTotal = 0; // 确保总次数不为负数
}
$(totalInputId).val(newTotal); // 更新总次数输入框的值
$('#countInput').val(''); // 清空输入框的值
// 调用 #auth 的点击事件(根据需求)
$("input[id='save_"+(idNum)+"']").trigger('click');
}
});
@@ -295,6 +295,7 @@
<@menuitem uri='/creditRate/list' text="价格可信度与匹配率关系" />
<@menuitem uri='/czBank/sampleLogs' text="浙商银行" />
<@menuitem uri='/villageIdentify/importResult' text="涉农结果导入" />
<@menuitem uri='/apiCountLog/list' text="API次数日志" />
</ul>
</li>
@@ -196,7 +196,7 @@ public class HouseReportController {
model.setEvaluation(evaluation);
SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(evaluation.getCity(), evaluation.getRegion(), evaluation.getDistrictName(), "district");
if(null != sqmetreRent){
int rentPrice = (int) (sqmetreRent.getAvgPrice() * evaluation.getArea());
int rentPrice = (int) (sqmetreRent.getAvgPrice().intValue() * evaluation.getArea());
model.setRentPrice(rentPrice);
}
}else{
@@ -61,7 +61,7 @@ public class RentHouseReportController {
model.setEvaluation(evaluation);
SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(evaluation.getCity(), evaluation.getRegion(), evaluation.getDistrictName(), "district");
if(null != sqmetreRent){
int rentPrice = (int) (sqmetreRent.getAvgPrice() * evaluation.getArea());
int rentPrice = (int) (sqmetreRent.getAvgPrice().intValue() * evaluation.getArea());
model.setRentPrice(rentPrice);
}
@@ -107,13 +107,13 @@ public class RentHouseReportController {
double lastMonthPrice = 0;
if(null != sqmetreRent1){
lastMonthPrice = sqmetreRent1.getAvgPrice();
lastMonthPrice = sqmetreRent1.getAvgPrice().intValue();
retMap.put("lastMonthPrice", sqmetreRent1.getAvgPrice());
}
if(null != sqmetreRent2){
retMap.put("lastYearMonthPrice", sqmetreRent2.getAvgPrice());
double markup = (lastMonthPrice-sqmetreRent2.getAvgPrice())*100.0/sqmetreRent2.getAvgPrice();
double markup = (lastMonthPrice-sqmetreRent2.getAvgPrice().intValue())*100.0/sqmetreRent2.getAvgPrice().intValue();
retMap.put("markup", DataUtil.getDoubleRound(2,markup));
}
jsonRet.setJsonModel(retMap);
@@ -105,7 +105,7 @@ public class SellHouseReportController {
model.setEvaluation(eval);
SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(eval.getCity(), eval.getRegion(), eval.getDistrictName(), "district");
if(null != sqmetreRent){
int rentPrice = (int) (sqmetreRent.getAvgPrice() * eval.getArea());
int rentPrice = (int) (sqmetreRent.getAvgPrice().intValue() * eval.getArea());
model.setRentPrice(rentPrice);
}
List<LoanProduct> creditProductList = loanProductService.findProductByType("信用贷",LoanProductPositionEnum.SIMPLE_REPORT.getId());
@@ -72,7 +72,7 @@
<div class="p1_icon_base p1_01">
<div class="p1_div_v1"><span class="p1_txt">结合业务定制</span>
<span class="p2_txt">解决方案</span></div>
<div class="p2_div_v1">赋能不通场景与业务,个性化定制行业解决方案,为企业地址应用场景助力</div>
<div class="p2_div_v1">赋能不同场景与业务,个性化定制行业解决方案,为企业地址应用场景助力</div>
</div>
</div>
</div>
@@ -0,0 +1,9 @@
package com.fangjia.dal.mongo.dao;
import com.fangjia.dal.MongoDao;
import com.fangjia.dal.mongo.model.ApiCountLog;
import com.fangjia.dal.mongo.model.DevelopmentZone;
public interface ApiCountLogDao extends MongoDao<ApiCountLog> {
}
@@ -0,0 +1,9 @@
package com.fangjia.dal.mongo.dao;
import com.fangjia.dal.MongoDaoImpl;
import com.fangjia.dal.mongo.model.ApiCountLog;
import com.fangjia.dal.mongo.model.DevelopmentZone;
public class ApiCountLogDaoImpl extends MongoDaoImpl<ApiCountLog> implements ApiCountLogDao {
}
@@ -0,0 +1,127 @@
package com.fangjia.dal.mongo.model;
import com.fangjia.dal.MongoEntity;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Entity
@Table(name = "business.api_count_log")
public class ApiCountLog implements MongoEntity {
private String id;
private Long userId;
private String userName;
private String uri;
private String uriName;
private String operate;
private String operator;
private Date operateTime;
// 修改次数前总次数
private Integer oldCount;
// 修改次数后的次数
private Integer newCount;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "_id")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Column(name = "user_id")
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
@Column(name = "uri")
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
@Column(name = "uri_name")
public String getUriName() {
return uriName;
}
public void setUriName(String uriName) {
this.uriName = uriName;
}
@Column(name = "operate")
public String getOperate() {
return operate;
}
public void setOperate(String operate) {
this.operate = operate;
}
@Column(name = "operator")
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
@Column(name = "operate_time")
public Date getOperateTime() {
return operateTime;
}
public void setOperateTime(Date operateTime) {
this.operateTime = operateTime;
}
@Column(name = "old_count")
public Integer getOldCount() {
return oldCount;
}
public void setOldCount(Integer oldCount) {
this.oldCount = oldCount;
}
@Column(name = "new_count")
public Integer getNewCount() {
return newCount;
}
public void setNewCount(Integer newCount) {
this.newCount = newCount;
}
@Column(name = "user_name")
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
@@ -28,6 +28,10 @@ public class ApiUser implements SqlEntity {
private String company;
private int isTest; //0-正式客戶 1-测试用户 2-内部测试用户
private Date deadTime;
private String contact; //联系人
private String phone; //联系人手机号
/**
* 账户用途
* 1:Open APi
@@ -185,4 +189,22 @@ public class ApiUser implements SqlEntity {
public void setIsMonitor(Integer isMonitor) {
this.isMonitor = isMonitor;
}
@Column(name = "CUSTOMER_CONTACT")
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
@Column(name = "CUSTOMER_CONTACT_MOBILE")
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
@@ -20,6 +20,7 @@ import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpEntity;
@@ -42,6 +43,7 @@ import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -78,14 +80,17 @@ public class AddrSvcController {
Map<String, String> params = new HashMap<String, String>();
params.put("city", model.getCity());
params.put("address", model.getAddress());
params.put("addressAssessment", "true");
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structure/v2", params, "UTF-8");
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/formatNinelevel", params, "UTF-8");
if (json != null) {
int code = json.getInt("status");
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg);
BasicModel basicModel = new BasicModel(code == 0 ? 200 : 0, msg);
if (json.containsKey("result")) {
basicModel.setResult(CommonDtoUtils.transformV(StructureDto.class, json.get("result")));
JSONObject result = json.getJSONObject("result");
result.remove("formatAddress");
basicModel.setResult(result);
}
mav.setModel(basicModel);
} else {
@@ -118,13 +123,27 @@ public class AddrSvcController {
params.put("city", model.getCity());
params.put("address", model.getAddress());
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure/v2", params, "UTF-8");
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8");
if (json != null) {
int code = json.getInt("status");
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg);
BasicModel basicModel = new BasicModel(code == 0 ? 200 : 0, msg);
if (json.containsKey("result")) {
basicModel.setResult(CommonDtoUtils.transformV(DistrictIdentifyDto.class, json.get("result")));
DistrictIdentifyDto districtIdentifyDto = CommonDtoUtils.transformV(DistrictIdentifyDto.class, json.get("result"));
JSONObject result = json.getJSONObject("result");
if (result.containsKey("town")) {
districtIdentifyDto.setTownship(result.getString("town"));
}
if (result.containsKey("townCode")) {
districtIdentifyDto.setTownshipCode(result.getString("townCode"));
}
if (result.containsKey("committee")) {
districtIdentifyDto.setCommunity(result.getString("committee"));
}
if (result.containsKey("committeeCode")) {
districtIdentifyDto.setCommunityCode(result.getString("committeeCode"));
}
basicModel.setResult(districtIdentifyDto);
}
mav.setModel(basicModel);
} else {
@@ -265,20 +284,20 @@ public class AddrSvcController {
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
params.put("city", model.getCity());
params.put("region", model.getRegion());
params.put("district", model.getDistrict());
params.put("keywords", model.getKeywords());
params.put("page", "0");
params.put("size", String.valueOf(model.getMax() == 0 ? 20 : (model.getMax() > 100 ? 100 : model.getMax())));
params.put("offset", String.valueOf(model.getMax() == 0 ? 10 : (model.getMax() > 100 ? 100 : model.getMax())));
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addressAssociation2", params, "UTF-8");
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8");
if (json != null) {
int code = json.getInt("status");
int code = json.getInt("msgCode");
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg);
if (json.containsKey("result")) {
JSONObject result = (JSONObject.fromObject(json.get("result")));
if (result.getInt("totalElements") > 0) {
basicModel.setResult(CommonDtoUtils.transformListV(DistrictDto.class, result.getJSONArray("content")));
JSONArray jsonArray = json.getJSONArray("result");
if (jsonArray.size() > 0) {
basicModel.setResult(CommonDtoUtils.transformListV(DistrictDto.class, jsonArray));
}
}
mav.setModel(basicModel);
@@ -513,7 +532,7 @@ public class AddrSvcController {
if (map.get("city").endsWith("区")) {
return "否";
}
if (map.get("city").equals("东莞市") || map.get("city").equals("嘉峪关市") || map.get("city").equals("中山市") || map.get("city").equals("儋州市") ) {
if (map.get("city").equals("东莞市") || map.get("city").equals("嘉峪关市") || map.get("city").equals("中山市") || map.get("city").equals("儋州市")) {
return "否";
}
return "是";
@@ -526,7 +545,7 @@ public class AddrSvcController {
* @return
*/
public String addrArea(Map<String, String> map, String type) {
if (map.get("verifyFlag") == null ) {
if (map.get("verifyFlag") == null) {
return "";
}
if (map.get("verifyFlag").equals("非农")) {
@@ -675,27 +694,27 @@ public class AddrSvcController {
VillageIdentify villageResult = CollectionUtils.isNotEmpty(villageIdentifyList) ? villageIdentifyList.get(0) : null;
if (villageResult != null && StringUtils.isNotBlank(villageResult.getVerifyFlag())) {
Map<String, String> resultMap = new HashMap<String, String>();
resultMap.put("province",villageResult.getProvince());
resultMap.put("city",villageResult.getCity1());
resultMap.put("district",villageResult.getDistrict());
resultMap.put("town",villageResult.getTown());
resultMap.put("committee",villageResult.getCommittee());
resultMap.put("provinceCode",villageResult.getCityCode());
resultMap.put("cityCode",villageResult.getCityCode());
resultMap.put("districtCode",villageResult.getDistrictCode());
resultMap.put("townCode",villageResult.getTownCode());
resultMap.put("committeeCode",villageResult.getCommitteeCode());
resultMap.put("typeCode",villageResult.getTypeCode());
resultMap.put("typeName",villageResult.getTypeName());
resultMap.put("verifyFlag",villageResult.getVerifyFlag());
resultMap.put("province", villageResult.getProvince());
resultMap.put("city", villageResult.getCity1());
resultMap.put("district", villageResult.getDistrict());
resultMap.put("town", villageResult.getTown());
resultMap.put("committee", villageResult.getCommittee());
resultMap.put("provinceCode", villageResult.getCityCode());
resultMap.put("cityCode", villageResult.getCityCode());
resultMap.put("districtCode", villageResult.getDistrictCode());
resultMap.put("townCode", villageResult.getTownCode());
resultMap.put("committeeCode", villageResult.getCommitteeCode());
resultMap.put("typeCode", villageResult.getTypeCode());
resultMap.put("typeName", villageResult.getTypeName());
resultMap.put("verifyFlag", villageResult.getVerifyFlag());
resultMap.put("addrVerify", villageResult.getAddrVerify());
resultMap.put("countyLevelCity",villageResult.getCountyLevelCity());
resultMap.put("administrativeTowns",villageResult.getAdministrativeTowns());
resultMap.put("countyGov",villageResult.getCountyGov());
resultMap.put("devDistrict",villageResult.getDevDistrict());
resultMap.put("devDistrictName",villageResult.getDevDistrictName());
resultMap.put("devLevel",villageResult.getDevLevel());
resultMap.put("addrArea",villageResult.getAddrArea());
resultMap.put("countyLevelCity", villageResult.getCountyLevelCity());
resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns());
resultMap.put("countyGov", villageResult.getCountyGov());
resultMap.put("devDistrict", villageResult.getDevDistrict());
resultMap.put("devDistrictName", villageResult.getDevDistrictName());
resultMap.put("devLevel", villageResult.getDevLevel());
resultMap.put("addrArea", villageResult.getAddrArea());
BasicModel basicModel = new BasicModel(200, "OK");
basicModel.setResult(resultMap);
mav.setModel(basicModel);
@@ -950,6 +969,7 @@ public class AddrSvcController {
* @param model
* @return
*/
@Deprecated
public Object addressAssociationAction(AddressModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
@@ -994,6 +1014,238 @@ public class AddrSvcController {
return mav;
}
/**
* 市级行政区划查询接口
*
* @param model
* @return
*/
public Object listCityAction(AddressModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
HttpRequest request = new HttpRequest();
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null);
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8");
} catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (json != null) {
int code = json.getInt("msgCode");
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg);
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
if (json.containsKey("result")) {
JSONArray jsonArray = json.getJSONArray("result");
if (jsonArray != null) {
for (Object o : jsonArray) {
JSONObject result = (JSONObject) o;
HashMap<String, String> map = new HashMap<String, String>();
map.put("id", result.getString("id"));
map.put("province", result.getString("province"));
map.put("provinceCode", result.getString("tjjProvinceCode"));
map.put("city", result.getString("city"));
map.put("cityCode", result.getString("tjjCityCode"));
list.add(map);
}
}
}
basicModel.setResult(list);
mav.setModel(basicModel);
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
}
return mav;
}
/**
* 省级行政区划查询接口
*
* @param model
* @return
*/
public Object listProvinceAction(AddressModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
HttpRequest request = new HttpRequest();
JSONObject json = null;
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8");
} catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (json != null) {
int code = json.getInt("msgCode");
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg);
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
if (json.containsKey("result")) {
JSONArray jsonArray = json.getJSONArray("result");
if (jsonArray != null) {
for (Object o : jsonArray) {
JSONObject result = (JSONObject) o;
HashMap<String, String> map = new HashMap<String, String>();
map.put("id", result.getString("id"));
map.put("province", result.getString("province"));
map.put("provinceCode", result.getString("mzbProvinceCode"));
list.add(map);
}
}
}
basicModel.setResult(list);
mav.setModel(basicModel);
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
}
return mav;
}
/**
* 区域级行政区划查询接口
*
* @param model
* @return
*/
public Object listDistrictAction(AddressModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
HttpRequest request = new HttpRequest();
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null);
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null);
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8");
} catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (json != null) {
int code = json.getInt("msgCode");
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg);
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
if (json.containsKey("result")) {
JSONArray jsonArray = json.getJSONArray("result");
if (jsonArray != null) {
for (Object o : jsonArray) {
JSONObject result = (JSONObject) o;
HashMap<String, String> map = new HashMap<String, String>();
map.put("id", result.getString("id"));
map.put("province", result.getString("province"));
map.put("provinceCode", result.getString("tjjProvinceCode"));
map.put("city", result.getString("city"));
map.put("cityCode", result.getString("tjjCityCode"));
map.put("district", result.getString("district"));
map.put("districtCode", result.getString("tjjDistrictCode"));
list.add(map);
}
}
}
basicModel.setResult(list);
mav.setModel(basicModel);
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
}
return mav;
}
public Object listTownshipAction(AddressModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
HttpRequest request = new HttpRequest();
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null);
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null);
params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null);
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8");
} catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (json != null) {
int code = json.getInt("msgCode");
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg);
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
if (json.containsKey("result")) {
JSONArray jsonArray = json.getJSONArray("result");
if (jsonArray != null) {
for (Object o : jsonArray) {
JSONObject result = (JSONObject) o;
HashMap<String, String> map = new HashMap<String, String>();
map.put("id", result.getString("id"));
map.put("province", result.getString("province"));
map.put("provinceCode", result.getString("tjjProvinceCode"));
map.put("city", result.getString("city"));
map.put("cityCode", result.getString("tjjCityCode"));
map.put("district", result.getString("district"));
map.put("districtCode", result.getString("tjjDistrictCode"));
map.put("street", result.getString("street"));
map.put("streetCode", result.getString("tjjStreetCode"));
list.add(map);
}
}
}
basicModel.setResult(list);
mav.setModel(basicModel);
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
}
return mav;
}
public Object levelAction(AddressModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
HttpRequest request = new HttpRequest();
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null);
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null);
params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null);
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8");
} catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (json != null) {
int code = json.getInt("msgCode");
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg);
if (json.containsKey("result")) {
JSONObject result = json.getJSONObject("result");
basicModel.setResult(result);
}
mav.setModel(basicModel);
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
}
return mav;
}
public void setDistrictStatService(DistrictStatService districtStatService) {
this.districtStatService = districtStatService;
}
@@ -2134,6 +2134,56 @@ public class AddressController {
return mav;
}
/**
* 楼盘评级
*
* @param model
* @return
*/
public Object propertyRatingAction(CommunitySummaryRequestDto model) {
RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getAddress()) && StringUtils.isBlank(model.getId())) {
mav.setModel(BasicModel.buildBadRequestModel("小区ID或地址不能为空"));
return mav;
}
HttpRequest request = new HttpRequest();
JSONObject json = null;
try {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json");
JSONObject reqBody = new JSONObject();
reqBody.put("city", model.getCity());
reqBody.put("address", model.getAddress());
reqBody.put("id", model.getId());
String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/propertyRating", reqBody, headers, "UTF-8");
if (result != null) {
try {
json = JSONObject.fromObject(result);
} catch (Exception e) {
json = null;
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (json != null) {
int code = json.getInt("status");
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg);
if (json.containsKey("result")) {
basicModel.setResult(json.get("result"));
}
mav.setModel(basicModel);
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
}
return mav;
}
/**
* 楼盘评级
*
@@ -7,6 +7,7 @@ public class DistrictDto {
private String region;
private String name;
private String address;
private String district;
public String getProvince() {
return province;
@@ -47,4 +48,12 @@ public class DistrictDto {
public void setAddress(String address) {
this.address = address;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
}
@@ -9,6 +9,11 @@ package com.fangjia.open.model;
*/
public class CommunitySummaryRequestDto extends FangjiaApiModel {
/**
* Ð¡ÇøID
*/
private String id;
/**
* ³ÇÊÐ
*/
@@ -86,4 +91,12 @@ public class CommunitySummaryRequestDto extends FangjiaApiModel {
public void setMemo(String memo) {
this.memo = memo;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
@@ -24,7 +24,7 @@ class AddThirdPriceSample {
def dist = CommonDatautils.findDistrictById(d['A'].toString().trim())
if(dist){
def q = new BasicDBObject("city", dist.city).append("region", dist.region).append("name", dist.name).append("s_date", 202407)
def udata = new BasicDBObject("zhongyuan_esf_price", d['C'].toString().toDouble().toInteger())
def udata = new BasicDBObject("csjj_esf_price", d['C'].toString().toDouble().toInteger())
AVERAGE_STATISTICS.update(q,new BasicDBObject('$set', udata),false, false)
}else{
@@ -68,10 +68,10 @@ class BigdataDealBatch extends BaseBatch{
//664a22000000000000000000 5-20
//664b73800000000000000000 5-21
def citys = CcbCommonUtils.getRunningCitys(args)
def citys =CcbCommonUtils.getRunningCitys(args)
println "curDate:"+curDate
def allCitys = CommonDatautils.findAllCity()
def allCitys = CommonDatautils.findAllCity()
for(def city : allCitys){
addDealPriceMatch(city);
}
@@ -720,7 +720,7 @@ class BigdataDealBatch extends BaseBatch{
if(!t.match_id){
def region = RegionData.formatRegion(t.city, t.region)
def rMap = null
if(region) {
if(region || (!region && ["³ÎÂõ"].contains(t.city))) {
if(t.house_use && t.house_use.contains("商住")){
if(!t.name.contains("商住")){
t.name = t.name +"商住楼"
@@ -744,7 +744,9 @@ class BigdataDealBatch extends BaseBatch{
CcbCommonUtils.updateDealPrice(t._id, rMap.city, rMap.region, rMap.name, rMap.id)
}else if(rMap && rMap.address && address && rMap.region!=region && address.contains(rMap.address)){
CcbCommonUtils.updateDealPrice(t._id, rMap.city, rMap.region, rMap.name, rMap.id)
}else {
}else if (rMap && ["³ÎÂõ"].contains(rMap.city)){
CcbCommonUtils.updateDealPrice(t._id, rMap.city, rMap.region, rMap.name, rMap.id)
}else{
if (rMap) {
println "区域不同"
}
@@ -260,6 +260,9 @@ class ThirdPartyPriceBatch extends BaseBatch {
if(third.get("fccs_esf_price")){
price_map.fccs_avg_price = third.get("fccs_esf_price")
}
if(third.get("csjj_esf_price")){
price_map.csjj_avg_price = third.get("csjj_esf_price")
}
dataMap.updatetime = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss")
allRows << dataMap
}
@@ -308,6 +311,8 @@ class ThirdPartyPriceBatch extends BaseBatch {
web = "ÎÒ°®ÎÒ¼Ò"
}else if(k=="fccs_avg_price"){
web = "·¿²ú³¬ÊÐ"
}else if(k=="csjj_avg_price"){
web = "³ÇÊоӼÒ"
}
ret << sourceMap.get(web)
@@ -525,6 +530,7 @@ class ThirdPartyPriceBatch extends BaseBatch {
q.put("city", city)
q.put("s_date", new BasicDBObject('$gte', startDate).append('$lte',endDate))
def dbcursor = AVERAGE_STATISTICS.find(q).sort(new BasicDBObject("s_date", -1))
def map = [:]
for(def db : dbcursor){
@@ -593,6 +599,10 @@ class ThirdPartyPriceBatch extends BaseBatch {
if(!dataMap.get("fccs_esf_price") && db.get("fccs_esf_price") && db.get("fccs_esf_price")>3000){
dataMap.put("fccs_esf_price", db.get("fccs_esf_price"))
}
if(!dataMap.get("csjj_esf_price") && db.get("csjj_esf_price") && db.get("csjj_esf_price")>3000){
dataMap.put("csjj_esf_price", db.get("csjj_esf_price"))
}
// if(db.zhugezhaofang_esf_price || db.anjuke_esf_price ||db.soufang_esf_price || db.lianjia_esf_price || db.cityhouse_esf_price || db.maitian_esf_price || db.beike_esf_price || db.get("365house_esf_price") || db.zhongyuan_esf_price || db.tuboshi_esf_price || db.qfang_esf_price || db.fangtan_esf_price || db.fangduoduo_esf_price || db.get("5i5j_esf_price")){
// map.put(key, db)
// }
@@ -600,8 +610,8 @@ class ThirdPartyPriceBatch extends BaseBatch {
def resultMap = [:]
map.each {key, value->
if(value && value.size()>1){
if(value.size()==2 && !value.lianjia_esf_price && !value.beike_esf_price){
if(value && value.size()>1){ //csjj_esf_price ¹úÐÅ´ï³É½»
if(value.size()==2 && !value.lianjia_esf_price && !value.beike_esf_price && !value.csjj_esf_price){
def price = statMap.get(key)
if(price){
def priceMap = [:]
@@ -4746,7 +4746,7 @@ class CommonDatautils {
townMap.put(key, list)
}
println "乡镇街道 加载完成"
println "[${city}] 乡镇街道 加载完成 "+new Date().format("yyyy-MM-dd HH:mm:ss")
return townMap
}
@@ -15,13 +15,16 @@ import org.apache.commons.lang.StringUtils
class OpenApiUtils {
static def matchDistrict(def city, def address, def suggestDistrict, def preciseLevelflag, def suggestName){
address = address.replace("£¨","(").replace("£©",")").replace(" ","").replace("#","").replace("<","").replace(">","").replace("%","").replace("\"","")
def url = "http://open.fangjia.com/address/matchV2?city="+city+"&address="+address+"&suggestDistrict="+suggestDistrict+"&token=F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB&category=district&__refresh_cache=1"
def url = "http://open.fangjia.com/address/matchV2?city="+city+"&address="+address+"&token=F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB&category=district&__refresh_cache=1"
if(preciseLevelflag){
url = url +"&preciseLevel=strict"
}
if(suggestName){
url = url +"&suggestName="+suggestName
}
if(suggestDistrict){
url = url +"&suggestDistrict="+suggestDistrict
}
String content = new HttpRequest().get(url, "utf-8");
def rMap = [:]
if(content){
@@ -192,42 +192,112 @@ class DevProcess {
}
}
def findDev(city, name){
def q = new BasicDBObject()
q.put("name", name)
q.put("city", city)
def obj = development_zone_CONN.findOne(q)
def findDev( name){
def obj = findDevByName(name)
if(!obj){
obj = findDevByAlias(name)
if(obj){
obj.match_way = "别名"
}
}else{
obj.match_way = "相同"
}
return obj
}
def findDebBySimlar(def devs, def name, def city){
name = name.replace("经济开发区", "经济技术开发区").replace("工业园区", "工业园")
def last = null
for(def d : devs){
def alias1 = null
if(!d.alias){
alias1 = []
}else{
alias1 = d.alias
}
if(!alias1.contains(d.name)){
alias1 << d.name
}
if(alias1){
try {
for(def n : alias1){
n = n.replace("经济开发区", "经济技术开发区").replace("工业园区", "工业园")
if(d.city && d.city.contains(city) && (n.contains(name) || name.contains(n))){
last = d
break
}
}
}catch(exception){
println alias1
}
}
if(last){
break
}
}
return last
}
def findDevByName(name){
def q = new BasicDBObject()
q.put("name", name)
return development_zone_CONN.findOne(q)
}
def findDevByAlias(name){
def q = new BasicDBObject()
q.put('alias', new BasicDBObject('$in',[name]))
return development_zone_CONN.findOne(q)
}
def findDevBySimlar(name){
def q = new BasicDBObject()
q.put('name',new BasicDBObject('$regex', Pattern.compile('^.*'+name+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询
return development_zone_CONN.findOne(q)
}
def findDevByPark(prov, city, name){
def q = new BasicDBObject()
q.put('province',new BasicDBObject('$regex', Pattern.compile('^.*'+prov+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询
q.put('city',new BasicDBObject('$regex', Pattern.compile('^.*'+city+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询
q.put('park',new BasicDBObject('$regex', Pattern.compile('^.*'+name+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询
q.put("type", "园区")
return dev_mapping_CONN.findOne(q)
}
def devSplitRoad(){
def i = 0;
def i = 1;
while(i<20){
def fileName = "/home/goojia/gj/qzd-${i}.xlsx"
if(CommonDatautils.isWindow()){
fileName = "D:\\数据\\数据建设\\开发区\\福建省.xlsx"
fileName = "D:\\数据\\数据建设\\开发区\\新跑省份\\河北省\\test-${i}.xlsx"
}
File file=new File(fileName);
if(file.exists()){
ExcelUtils.multiThreadingModify(fileName,{d->
if(d['E'] && !d['G']){
def jsonObject1 = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(d['B'], d['E'])
if(d['C'] && !d['F']){
def jsonObject1 = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(d['B'], d['C'])
if(jsonObject1) {
if (jsonObject1.get("dev") && jsonObject1.get("dev") != "null") {
def devName = jsonObject1.get("dev")
def obj = findDev(d['B'], devName)
def obj = findDev(devName)
d['F'] = devName
if(jsonObject1.containsKey("detail") && jsonObject1.detail.dev_confi!='null'){
d['S'] = jsonObject1.detail.dev_confi
}
if (obj) {
d['Q'] = obj._id.toString()
d['R'] = obj.name
d['O'] = obj._id.toString()
d['P'] = obj.name
d['U'] = obj.match_way
}
}
}
}
if(d['C'] && !d['S']) {
def jsonObject = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(d['B'], d['C'])
if(d['E'] && !d['M']) {
def jsonObject = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(d['B'], d['E'])
def street = jsonObject.get("street")
def streetNumber = jsonObject.get("streetNumber")
if (jsonObject.get("province") && jsonObject.get("province") != "null") {
@@ -256,7 +326,7 @@ class DevProcess {
d['N'] = "信息不完整"
}
if (!d['N'] && !d['C'].contains(road)) {
if (!d['N'] && d['C'] && !d['C'].contains(road)) {
d['N'] = "原地址不含路"
}
@@ -276,17 +346,23 @@ class DevProcess {
if (jsonObject.get("dev") && jsonObject.get("dev") != "null") {
def devName = jsonObject.get("dev")
def obj = findDev(d['B'], devName)
def obj = findDev(devName)
d['M'] = devName
if (obj) {
d['S'] = obj._id.toString()
d['T'] = obj.name
d['Q'] = obj._id.toString()
d['R'] = obj.name
d['V'] = obj.match_way
}
if(jsonObject.containsKey("detail") && jsonObject.detail.dev_confi!='null'){
d['T'] = jsonObject.detail.dev_confi
}
}
}
},0)
i++
}
i++
println fileName+" 完成"
}
}
@@ -33,13 +33,13 @@ class MinglujiData {
def prov = "Õã½­Ê¡"
def city = "¼ÎÐË"
// exportDatas(city)
// matchDev(prov, city)
matchDev(prov, city)
matchCommunity(city)
// tempMatchDev(prov)
// saveMljData()
fiveLevelSplit(city)
}
def exportDatas(city){
def datas = findMinglujiDatas(city)
@@ -113,7 +113,7 @@ class MinglujiData {
})
}
i++
println fileName +" 完成"
println fileName +" 完成(匹配开发区不使用接口)"
}
}
@@ -196,15 +196,40 @@ class MinglujiData {
}
}
}, 0)
println fileName +" 远行完成"
println fileName +" 运行完成"
}
i++
}
}
def fiveLevelSplit(city){
def i = 1;
while(i<20) {
def fileName = "/home/goojia/gj/mlj_${i}.xlsx"
if (CommonDatautils.isWindow()) {
fileName = "D:\\数据\\数据建设\\名录集\\mlj_${i}.xlsx"
}
File file = new File(fileName);
if (file.exists()) {
ExcelUtils.multiThreadingModify(fileName, { d ->
if(d['J'] && !d['X']){
def jsonObject = com.fangjia.script.gj.district.FangjiaClientUtils.formatFivelevel(d['B'], d['J'])
if(jsonObject) {
if (jsonObject.get("address") && jsonObject.get("address") != "null") {
d['X'] = jsonObject.get("address")
}
}
}
})
}
i++
}
}
def saveMljData(){
ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\名录集\\湖州入库数据.xlsx",{d->
ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\名录集\\湖州入库2.xlsx",{d->
def obj = new BasicDBObject()
obj.put("province", d['A'])
obj.put("city", d['B'])
@@ -213,7 +238,7 @@ class MinglujiData {
obj.put("address", d['E'])
obj.put("dev_name", d['F'])
obj.put("committee", d['G'])
obj.put("street", d['H'])
obj.put("township", d['H'])
company_100_CONN.save(obj)
})
}
@@ -1,6 +1,7 @@
package com.fangjia.script.gj.district
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.addrepo.InvokeHttpRequest
import com.fangjia.script.statistics.poi.AmapPoi
import com.fangjia.script.temp.shenjian.util.GaoDeUtils
import com.fangjia.script.temp.shenjian.util.HttpUtils
@@ -335,7 +336,7 @@ class FangjiaClientUtils {
try {
address = address.replace("{","")
// def url = "http://192.168.0.19:31080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8")
def url = "http://192.168.0.100:32080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8")
def url = "http://192.168.0.93:8080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8")
if(city){
url = url +"&city="+URLEncoder.encode(city,"UTF-8")
}
@@ -352,18 +353,27 @@ class FangjiaClientUtils {
public static def formatNinelevel(city, address){
def jsonObj = null
def content = null
try {
address = address.replace("{","")
def url = "http://192.168.0.93:8080/FangJiaNlpService/formatNinelevel?address="+URLEncoder.encode(address,"UTF-8")+"&complete=false&useMap=false&addressAssessment=true"
def url = null
address = address.replace("{","")
int retryCount = 0
while (retryCount < 3) {
url = "http://192.168.0.93:8080/FangJiaNlpService/formatNinelevel?address="+URLEncoder.encode(address,"UTF-8")+"&complete=false&useMap=false&addressAssessment=true&fields=dev_confi"
if(city){
url = url +"&city="+URLEncoder.encode(city,"UTF-8")
}
content = new HttpRequest().newGet(url, null, "utf-8")
if (content) {
break
}
retryCount++
}
if (!content) {
return null
}
try {
jsonObj = JSONObject.fromObject(content)
// println jsonObj
} catch (Exception e) {
println address +" "+content
e.printStackTrace();
println address +" "+content+" "+e.getMessage()
}
return jsonObj;
}
@@ -90,6 +90,7 @@ class FjwBigdataDealBatch extends BaseBatch{
}
println "txt Éú³É " + rows.size()
saveToPgSql(rows)
// def datas = readTxt("D:\\数据\\建行\\建行成交\\MODEL_000000_000000_BIGDATA_DEAL_GJ_ADD_20230928_0001.dat")
@@ -356,7 +357,7 @@ class FjwBigdataDealBatch extends BaseBatch{
def converData(def trade, def cityCodeDatas, def distCodeMap){
def ret = []
def data = distCodeMap.get(trade.region)
def data = distCodeMap.get(trade.match_region)
if(!data){
println trade.city +" "+trade.region+" 没有找到对应的区域"
return ret
@@ -580,8 +581,8 @@ class FjwBigdataDealBatch extends BaseBatch{
}
def getYouDaData(statMap){
// def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd"))
def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20200101", "yyyyMMdd"))
def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd"))
// def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20200101", "yyyyMMdd"))
def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd"))
def q = new BasicDBObject()
q.put("contractTime", new BasicDBObject('$gte', startDate).append('$lte', endDate));
@@ -27,7 +27,7 @@ class QiliangTest {
// task.run()
def data = [
'address': '湖州市南太湖高新技术产业园区大港村陈家斗80号',
'address': '浙江省湖州市长兴县煤山镇工业园区山鹰大道7号',
'type': '1' //1:对公 0:对私
]
def s = task.getProxyResult(data);
@@ -10,6 +10,7 @@ import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.common.DataHandleUtils
import com.fangjia.script.gj.ccb.FileUtils
import com.fangjia.script.looplineinfo.InsidePolygon
import com.fangjia.script.util.CosineSimilarAlgorithm
import com.fangjia.script.util.ElasticUtils
import com.fangjia.script.util.ExcelUtils
import com.fangjia.script.util.MongoUtils
@@ -32,6 +33,7 @@ import org.elasticsearch.index.query.QueryBuilder
import org.elasticsearch.index.query.QueryBuilders
import java.nio.charset.StandardCharsets
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.CountDownLatch
import java.util.concurrent.ExecutorService
@@ -126,7 +128,11 @@ class GaoDePoiDataProcess extends BaseBatch{
}
def sysnchVillage(){
def buducitys = [ '临汾市', '临沂市', '临沧市', '临高县', '丹东市',
def buducitys = [ "宁波市","丽水市","杭州市","温州市","嘉兴市","台州市","绍兴市","金华市","衢州市",'茂名市',
'荆州市', '荆门市', '莆田市','苏州市','菏泽市', '萍乡市', '营口市', '葫芦岛市', '蚌埠市', '衡水市', '衡阳市',
'衢州市', '襄阳市', '西宁市', '西安市', '许昌市', '贵港市', '贵阳市', '贺州市', '资阳市', '赣州市', '赤峰市',
'辽源市', '辽阳市', '达州市', '运城市', '连云港市', '通化市', '通辽市', '遂宁市', '遵义市', '中山市', '临夏回族自治州',
'临汾市', '临沂市', '临沧市', '临高县', '丹东市','邵阳市', '郑州市', '郴州市', '鄂尔多斯市', '鄂州市', '酒泉市',
'丽水市', '丽江市', '乌兰察布市', '乌海市', '乌鲁木齐市', '乐东黎族自治县', '乐山市', '九江市',
'云浮市', '五家渠市', '五指山市', '亳州市', '仙桃市', '伊春市', '伊犁哈萨克自治州', '佛山市',
'佳木斯市', '保亭黎族苗族自治县', '保定市', '保山市', '信阳市', '儋州市', '克孜勒苏柯尔克孜自治州',
@@ -136,7 +142,7 @@ class GaoDePoiDataProcess extends BaseBatch{
'吕梁市', '吴忠市', '周口市', '呼伦贝尔市', '呼和浩特市', '和田地区', '咸宁市', '咸阳市',
'哈密地区', '哈尔滨市', '唐山市', '商丘市', '商洛市', '喀什地区', '嘉兴市', '嘉峪关市', '四平市',
'固原市', '图木舒克市', '塔城地区', '大兴安岭地区', '大同市', '大庆市', '大理白族自治州', '大连市',
'天水市', '天津市', '天门市', '太原市', '威海市', '娄底市', '孝感市', '宁德市', '宁波市',
'天水市', '天津市', '天门市', '太原市', '威海市', '娄底市', '孝感市', '宁德市',
'安庆市', '安康市', '安阳市', '安顺市', '定安县', '定西市', '宜宾市', '宜昌市', '宜春市',
'宝鸡市', '宣城市', '宿州市', '宿迁市', '屯昌县', '山南地区', '岳阳市', '崇左市', '巴中市',
'巴彦淖尔市', '巴音郭楞蒙古自治州', '常州市', '常德市', '平凉市', '平顶山市', '广元市', '广安市',
@@ -149,17 +155,12 @@ class GaoDePoiDataProcess extends BaseBatch{
'梅州市', '梧州市', '楚雄彝族自治州', '榆林市', '武威市', '武汉市', '毕节地区', '永州市', '汉中市',
'汕头市', '汕尾市', '江门市', '池州市', '沈阳市', '沧州市', '河池市', '河源市', '泉州市',
'泰安市', '泰州市', '泸州市', '洛阳市', '济南市', '济宁市', '济源市', '海东地区', '海口市',
'淄博市', '淮北市', '淮南市', '淮安市', '深圳市', '清远市', '温州市', '渭南市', '湖州市',
'淄博市', '淮北市', '淮南市', '淮安市', '深圳市', '清远市', '温州市', '渭南市',
'湘潭市', '湘西土家族苗族自治州', '湛江市', '滁州市', '滨州市', '漯河市', '漳州市', '潍坊市',
'潜江市', '潮州市', '澄迈县', '濮阳市', '烟台市', '焦作市', '牡丹江市', '玉林市', '玉溪市',
'珠海市', '琼中黎族苗族自治县', '琼海市', '甘南藏族自治州', '白城市', '白山市', '白沙黎族自治县',
'白银市', '百色市', '益阳市', '盐城市', '盘锦市', '眉山市', '石嘴山市', '石家庄市', '石河子市',
'神农架林区', '福州市', '秦皇岛市', '红河哈尼族彝族自治州', '绍兴市', '绥化市', '绵阳市', '聊城市',
'肇庆市', '自贡市', '舟山市', '芜湖市', '苏州市', '茂名市', '荆州市', '荆门市', '莆田市',
'菏泽市', '萍乡市', '营口市', '葫芦岛市', '蚌埠市', '衡水市', '衡阳市', '衢州市', '襄阳市',
'西宁市', '西安市', '许昌市', '贵港市', '贵阳市', '贺州市', '资阳市', '赣州市', '赤峰市',
'辽源市', '辽阳市', '达州市', '运城市', '连云港市', '通化市', '通辽市', '遂宁市', '遵义市',
'邢台市', '那曲地区', '邯郸市', '邵阳市', '郑州市', '郴州市', '鄂尔多斯市', '鄂州市', '酒泉市',
'神农架林区', '福州市', '秦皇岛市', '红河哈尼族彝族自治州', '绥化市', '邢台市', '那曲地区', '邯郸市',
'重庆市', '金华市', '金昌市', '钦州市', '铁岭市', '铜仁地区', '铜川市', '铜陵市', '银川市',
'锡林郭勒盟', '锦州市', '镇江市', '长春市', '长沙市', '长治市', '阜新市', '阜阳市', '防城港市',
'阳江市', '阳泉市', '阿克苏地区', '阿勒泰地区', '阿拉善盟', '阿拉尔市', '阿里地区', '陇南市',
@@ -167,50 +168,55 @@ class GaoDePoiDataProcess extends BaseBatch{
'鸡西市', '鹤壁市', '鹤岗市', '鹰潭市', '黄冈市', '黄山市', '黄石市', '黑河市',
'黔东南苗族侗族自治州', '黔南布依族苗族自治州', '黔西南布依族苗族自治州', '齐齐哈尔市', '龙岩市']
//"丽水市","杭州市",
def runbuducitys = ["湖州市","宁波市","温州市","嘉兴市","台州市","绍兴市","金华市","舟山市","衢州市",'七台河市', '上海市','万宁市', '三亚市', '三明市', '三门峡市', '上饶市', '东方市', '东莞市',
'东营市', '中卫市', '中山市', '临夏回族自治州']
def runbuducitys = ["舟山市","湖州市"]
for(def city : buducitys){
if(runbuducitys.contains(city)){
continue
}
def pois = findAllVillagePoiMap(city)
println "百度loading finish: "+pois.size()+" "+new Date().format("yyyy-MM-dd HH:mm:ss")
def rows = createVillageData(city, pois)
save(city, rows)
// saveToMG(city, rows)
println city +" "+pois.size()+" add:"+rows.size()
println city +" "+pois.size()+" add:"+rows.size()+" "+new Date().format("yyyy-MM-dd HH:mm:ss")
}
}
def createVillageData(city, pois){
def rets = new CopyOnWriteArrayList()
def keyRets = new CopyOnWriteArrayList()
def rets = new ConcurrentHashMap()
//def keyRets = new CopyOnWriteArrayList()
def totalCount = new AtomicLong()
final CountDownLatch latch = new CountDownLatch(pois.size())
// def townMap = findTownRange(city)
def townMap = CommonDatautils.queryTownByCity(city)
def poiKeysFilter = findEsPoiByCity(city)
def esMap = findEsPoiByCity(city)
def nameKeys = esMap.keySet()
println "Es 加载完成:"+new Date().format("yyyy-MM-dd HH:mm:ss")
for(def i=0;i<pois.size();i++){
def p = pois[i]
final def p = pois[i]
fixedThreadPool.execute(new Runnable() {
void run() {
try{
totalCount.addAndGet(1)
// def obj = MAPPOI_CONN.findOne(new BasicDBObject("name", p.name).append("district", p.district).append("city", p.city))
def key = p.city+"##"+p.district+"##"+p.name
if(!poiKeysFilter.mightContain(key)){
def key = p.city+"##"+p.district+"##"+p.name.replace("-","").replace("·","")
if(!nameKeys.contains(key)){
def prov = ProvinceData.getProvince(p.city.replace("市",""))
def ret = createVillageData(prov, p, townMap)
if(!keyRets.contains(ret.city+"##"+ret.district+"##"+ret.name)){
keyRets.addAll(ret)
rets << ret
if(ret){
def simlarObj = null
if(esMap){
simlarObj = findSimlarPoi(ret, esMap)
}
if(!simlarObj){
def newKey = ret.city+"##"+ret.district+"##"+ret.name.replace("-","").replace("·","")
if(!rets.containsKey(newKey)){
rets.put(newKey, ret)
}
}
}
}
} catch (Exception e) {
e.printStackTrace()
} finally {
@@ -223,21 +229,73 @@ class GaoDePoiDataProcess extends BaseBatch{
return rets
}
def findSimlarPoi(ret, esMap){
def simlarObj = null
def region = ""
if(ret.district){
region = ret.district
}
def regionMap = esMap.get(region)
if(regionMap){
def keys = regionMap.keySet()
for(def key : keys){
def esValue = regionMap.get(key)
if(esValue.township && ret.township){
if(esValue.name.contains(ret.name) || ret.name.contains(esValue.name)){//||
def distance = GeoUtils.calculateDistance(ret.location.lon, ret.location.lat, esValue.location.lon, esValue.location.lat);
if(distance <100){
simlarObj = esValue
println esValue.name +" "+ret.name+" "+distance
break;
}
}
// else{
// def esKey = esValue.name.replace("-","").replace("·","").replace("(", "").replace(")", "")
// def bdKey = ret.name.replace("-","").replace("·","").replace("(", "").replace(")", "")
// double score = CosineSimilarAlgorithm.getSimilarity(esKey,bdKey);
// if(score && score>=0.95) {
// def distance = GeoUtils.calculateDistance(ret.location.lon, ret.location.lat, esValue.location.lon, esValue.location.lat);
// if(distance <100){
// simlarObj = esValue
// println esValue.name +" "+ret.name+" "+distance +" "+score
// break;
// }
// }
// }
}
}
}else{
println "无数据"
}
return simlarObj
}
def findEsPoiByCity(city){
// def sql = "select city,district,name,location from didata_map_poi_single where city='${city}' "
// def rets = new HashSet()
// ElasticUtils89.executeSqlQuery(sql, { d->
//
// })
QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city))
// def rets = new HashSet()
BloomFilter<CharSequence> filter = BloomFilter.create(Funnels.stringFunnel(StandardCharsets.UTF_8), 200000000, 0.000001);
// BloomFilter<CharSequence> filter = BloomFilter.create(Funnels.stringFunnel(StandardCharsets.UTF_8), 200000000, 0.000001);
def map = new HashMap()
ElasticUtils89.executeQuery("192.168.0.89", "didata_map_poi_single", queryBuilder, { String id, Map d->
// rets << d.city +"##"+d.district+"##"+d.name
filter.put(d.city +"##"+d.district+"##"+d.name)
def district = ""
if(d.district){
district = d.district
}
def regionMap = map.get(district)
if(!regionMap){
regionMap = new HashMap()
}
def o = new BasicDBObject()
o.put("city", d.city)
o.put("district", d.district)
o.put("name", d.name)
o.put("township", d.township)
o.put("location", d.location)
regionMap.put(d.name.replace("-","").replace("·",""), o)
map.put(district, regionMap)
})
return filter
return map
}
def queryMapPoi(city){
@@ -325,6 +383,11 @@ class GaoDePoiDataProcess extends BaseBatch{
// retMap.small_type = "村庄级地名"
retMap.cat = map.std_tag
if(!map.std_tag){
// println map.name +" std_tag: "+ map.std_tag +" 为空过滤"
return null
}
def nameArr = map.std_tag.split(";|:")
if(nameArr.size()>=1){
retMap.type = nameArr[0]
@@ -429,7 +492,7 @@ class GaoDePoiDataProcess extends BaseBatch{
keys.put("gcj02_x", 1)
keys.put("gcj02_y", 1)
keys.put("std_tag", 1)
def list = BAIDU_POI_COLL.find(q, keys).toList()
def list = BAIDU_POI_COLL.find(q, keys).batchSize(2000).toList()
return list;
}
@@ -701,12 +764,11 @@ class GaoDePoiDataProcess extends BaseBatch{
int batchSize = 1000;
int processedCount = 0;
def client = ElasticUtils89.getClient("192.168.0.89")
for (int i = 0; i < rows.size(); i++) {
def map = rows[i]
rows.each{key,map->
// def map = rows.get(key)
request.add(new IndexRequest("didata_map_poi_single", "_doc", map.id).source(map, XContentType.JSON));
if(i%1000==0){
print "."
}
// 批量提交数据
if (request.numberOfActions() >= batchSize) {
@@ -717,7 +779,7 @@ class GaoDePoiDataProcess extends BaseBatch{
print "Bulk request has failures: " + bulkResponse.buildFailureMessage()
} else {
processedCount += request.numberOfActions();
println "Processed " + processedCount + " documents"
println "Processed " + processedCount + " documents "+new Date().format("yyyy-MM-dd HH:mm:ss")
}
request = new BulkRequest();
@@ -736,7 +798,6 @@ class GaoDePoiDataProcess extends BaseBatch{
}
}
println "[${city}] 结束时间 "+new Date()
}
@@ -1,28 +1,16 @@
package com.fangjia.script.trade
import java.util.regex.Matcher
package com.fangjia.script.sync
import com.fangjia.core.Constants
import com.fangjia.script.BaseBatch;
import com.fangjia.script.BatchOwner
import com.fangjia.script.util.DateUtils;
import java.util.regex.Pattern
import org.apache.commons.lang.StringUtils;
import com.fangjia.core.util.StringUtil;
import com.fangjia.datastore.driver.DSCollection;
import com.fangjia.datastore.driver.DSCursor
import com.fangjia.datastore.driver.DataStore
import com.fangjia.script.util.DateUtils
import com.mongodb.BasicDBObject
import com.mongodb.DBCollection;
import com.mongodb.DBObject
import com.fangjia.script.util.MongoUtils;
import com.fangjia.core.util.MongoUtils;
import com.fangjia.script.Watcher;
import com.mongodb.Bytes
import org.apache.commons.io.FileUtils
/**
* ½«ÏßÉÏopen uriÊý¾Ýͬ²½µ½192.168.0.60ÉÏ
* @author gaojuan
@@ -31,7 +19,7 @@ import org.apache.commons.io.FileUtils
class CopyOpenUriLog extends BaseBatch{
static DBCollection DESC_OPEN = MongoUtils.getCollectionByName("business", "open_uri_log", "seawater.mongo.db.fangjia.com", 27020)
static DBCollection DESC_OPEN = MongoUtils.getDbCollection(Constants.SEAWATER_MONGO_URI, "business", "open_uri_log")
public static final DBCollection SOURCE_OPEN = MongoUtils.getCollectionByName("business", "open_uri_log", "log.mongo.db.fangjia.com", 52002)
static main(String[] args){
runBatch(new CopyOpenUriLog(), args)
@@ -0,0 +1,17 @@
package com.fangjia.service.mongo.fangjia;
import com.fangjia.dal.mongo.model.ApiCountLog;
import com.fangjia.dal.mongo.model.DevelopmentZone;
import org.sothis.core.util.Pager;
import java.util.List;
import java.util.Map;
/**
* Created by dxy on 2015/6/8.
*/
public interface ApiCountLogService {
void save(ApiCountLog apiCountLog);
List<ApiCountLog> findApiCountLog(Long userId,String uri,Pager pager);
}
@@ -0,0 +1,45 @@
package com.fangjia.service.mongo.fangjia;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.SortParam;
import com.fangjia.dal.mongo.dao.AdministrativeMappingDao;
import com.fangjia.dal.mongo.dao.ApiCountLogDao;
import com.fangjia.dal.mongo.dao.DevelopmentZoneDao;
import com.fangjia.dal.mongo.model.AdministrativeMapping;
import com.fangjia.dal.mongo.model.ApiCountLog;
import com.fangjia.dal.mongo.model.DevelopmentZone;
import org.apache.commons.lang.StringUtils;
import org.sothis.core.util.Pager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
public class ApiCountLogServiceImpl implements ApiCountLogService {
private ApiCountLogDao apiCountLogDao;
@Override
public void save(ApiCountLog apiCountLog) {
apiCountLogDao.save(apiCountLog);
}
@Override
public List<ApiCountLog> findApiCountLog(Long userId, String uri,Pager pager) {
List<QueryParam> params = new ArrayList<QueryParam>();
if (userId!= null) {
params.add(new QueryParam("userId", userId));
}
if (StringUtils.isNotBlank(uri)) {
Pattern pattern = Pattern.compile(".*" + uri + ".*");
params.add(new QueryParam("uri", pattern));
}
List<SortParam> sortParam = Arrays.asList(new SortParam("operateTime", false));
return apiCountLogDao.findAllByParams(params,sortParam, pager.getStartRow(), pager.getPageSize());
}
public void setApiCountLogDao(ApiCountLogDao apiCountLogDao) {
this.apiCountLogDao = apiCountLogDao;
}
}
@@ -51,9 +51,9 @@ public interface DevelopmentZoneService {
* @param pager
* @return
*/
public List<DevelopmentZone> findDevelopmentZone(String province,String name,String level, Pager pager);
public List<DevelopmentZone> findDevelopmentZone(String province,String city,String name,String level, Pager pager);
public long countDev(String province,String name,String level);
public long countDev(String province,String city ,String name,String level);
public List<String> findProvinces();
public List<String> findCities(String province);
@@ -41,12 +41,16 @@ public class DevelopmentZoneServiceImpl implements DevelopmentZoneService {
@Override
public List<DevelopmentZone> findDevelopmentZone(String province,String name,String level, Pager pager) {
public List<DevelopmentZone> findDevelopmentZone(String province,String city ,String name,String level, Pager pager) {
List<QueryParam> params = new ArrayList<QueryParam>();
if (StringUtils.isNotBlank(province)) {
Pattern pattern = Pattern.compile(".*" + province + ".*");
params.add(new QueryParam("province", pattern));
}
if (StringUtils.isNotBlank(city)) {
Pattern pattern = Pattern.compile(".*" + city + ".*");
params.add(new QueryParam("cityName1", pattern));
}
if (StringUtils.isNotBlank(name)) {
Pattern pattern = Pattern.compile(".*" + name + ".*");
@@ -61,12 +65,16 @@ public class DevelopmentZoneServiceImpl implements DevelopmentZoneService {
}
@Override
public long countDev(String province, String name,String level) {
public long countDev(String province,String city, String name,String level) {
List<QueryParam> params = new ArrayList<QueryParam>();
if (StringUtils.isNotBlank(province)) {
Pattern pattern = Pattern.compile(".*" + province + ".*");
params.add(new QueryParam("province", pattern));
}
if (StringUtils.isNotBlank(city)) {
Pattern pattern = Pattern.compile(".*" + city + ".*");
params.add(new QueryParam("cityName1", pattern));
}
if (StringUtils.isNotBlank(name)) {
Pattern pattern = Pattern.compile(".*" + name + ".*");
@@ -28,6 +28,10 @@ public class ApiUserBo implements Serializable {
private String priceType;
private Integer isMonitor;
private String contact; //联系人
private String phone; //联系人手机号
public String getPriceType() {
return priceType;
}
@@ -171,4 +175,20 @@ public class ApiUserBo implements Serializable {
public void setIsMonitor(Integer isMonitor) {
this.isMonitor = isMonitor;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
@@ -6,11 +6,19 @@ public class StatAnalyBo {
private String key;
private Integer count;
private Integer weekCount;
private Integer monthCount;
private Double percent;
private Integer userId;
private Integer successEffectiveTime;
private Integer weekSuccessEffectiveTime;
private Integer monthSuccessEffectiveTime;
private Integer successInvalidTime;
private Integer weekSuccessInvalidTime;
private Integer monthSuccessInvalidTime;
private Integer defeatTime;
private Integer weekDefeatTime;
private Integer monthDefeatTime;
private Integer successTime;
private Integer billingCount;
private Integer purpose;
@@ -21,58 +29,133 @@ public class StatAnalyBo {
// ÐÂÔöurlºÍname
private String url;
private String urlName;
private String name;
private String userName;
// Ìí¼ÓÈÕ¾ùʹÓÃÁ¿
private Double dailyUse;
private Double weekDailyUse;
private Double monthDailyUse;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Integer getWeekCount() {
return weekCount;
}
public void setWeekCount(Integer weekCount) {
this.weekCount = weekCount;
}
public Integer getMonthCount() {
return monthCount;
}
public void setMonthCount(Integer monthCount) {
this.monthCount = monthCount;
}
public Double getPercent() {
return percent;
}
public void setPercent(Double percent) {
this.percent = percent;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getSuccessEffectiveTime() {
return successEffectiveTime;
}
public void setSuccessEffectiveTime(Integer successEffectiveTime) {
this.successEffectiveTime = successEffectiveTime;
}
public Integer getWeekSuccessEffectiveTime() {
return weekSuccessEffectiveTime;
}
public void setWeekSuccessEffectiveTime(Integer weekSuccessEffectiveTime) {
this.weekSuccessEffectiveTime = weekSuccessEffectiveTime;
}
public Integer getMonthSuccessEffectiveTime() {
return monthSuccessEffectiveTime;
}
public void setMonthSuccessEffectiveTime(Integer monthSuccessEffectiveTime) {
this.monthSuccessEffectiveTime = monthSuccessEffectiveTime;
}
public Integer getSuccessInvalidTime() {
return successInvalidTime;
}
public void setSuccessInvalidTime(Integer successInvalidTime) {
this.successInvalidTime = successInvalidTime;
}
public Integer getWeekSuccessInvalidTime() {
return weekSuccessInvalidTime;
}
public void setWeekSuccessInvalidTime(Integer weekSuccessInvalidTime) {
this.weekSuccessInvalidTime = weekSuccessInvalidTime;
}
public Integer getMonthSuccessInvalidTime() {
return monthSuccessInvalidTime;
}
public void setMonthSuccessInvalidTime(Integer monthSuccessInvalidTime) {
this.monthSuccessInvalidTime = monthSuccessInvalidTime;
}
public Integer getDefeatTime() {
return defeatTime;
}
public void setDefeatTime(Integer defeatTime) {
this.defeatTime = defeatTime;
}
public Integer getBillingCount() {
return billingCount;
public Integer getWeekDefeatTime() {
return weekDefeatTime;
}
public void setBillingCount(Integer billingCount) {
this.billingCount = billingCount;
public void setWeekDefeatTime(Integer weekDefeatTime) {
this.weekDefeatTime = weekDefeatTime;
}
public Integer getMonthDefeatTime() {
return monthDefeatTime;
}
public void setMonthDefeatTime(Integer monthDefeatTime) {
this.monthDefeatTime = monthDefeatTime;
}
public Integer getSuccessTime() {
@@ -83,12 +166,12 @@ public class StatAnalyBo {
this.successTime = successTime;
}
public Double getSuccessRate() {
return successRate;
public Integer getBillingCount() {
return billingCount;
}
public void setSuccessRate(Double successRate) {
this.successRate = successRate;
public void setBillingCount(Integer billingCount) {
this.billingCount = billingCount;
}
public Integer getPurpose() {
@@ -99,6 +182,14 @@ public class StatAnalyBo {
this.purpose = purpose;
}
public Double getSuccessRate() {
return successRate;
}
public void setSuccessRate(Double successRate) {
this.successRate = successRate;
}
public Integer getSurplusCallCount() {
return surplusCallCount;
}
@@ -123,12 +214,20 @@ public class StatAnalyBo {
this.url = url;
}
public String getName() {
return name;
public String getUrlName() {
return urlName;
}
public void setName(String name) {
this.name = name;
public void setUrlName(String urlName) {
this.urlName = urlName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Double getDailyUse() {
@@ -138,4 +237,20 @@ public class StatAnalyBo {
public void setDailyUse(Double dailyUse) {
this.dailyUse = dailyUse;
}
public Double getWeekDailyUse() {
return weekDailyUse;
}
public void setWeekDailyUse(Double weekDailyUse) {
this.weekDailyUse = weekDailyUse;
}
public Double getMonthDailyUse() {
return monthDailyUse;
}
public void setMonthDailyUse(Double monthDailyUse) {
this.monthDailyUse = monthDailyUse;
}
}
@@ -19,9 +19,13 @@ public class KafkaProducerUtils implements DisposableBean {
public KafkaProducerUtils() {
Properties properties = new Properties();
properties.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.0.100:30092");
properties.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.0.89:19092,192.168.0.90:19092,192.168.0.91:19092");
properties.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
properties.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
properties.setProperty("session.timeout.ms", "15000");
properties.setProperty("sasl.mechanism", "PLAIN");
properties.setProperty("security.protocol", "SASL_PLAINTEXT");
properties.setProperty("sasl.jaas.config", "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"admin\" password=\"Goojia123456\";");
this.producer = new KafkaProducer<String, String>(properties);
}