新增易方达接口以及添加claude技能

This commit is contained in:
2026-02-27 15:18:57 +08:00
parent 167aae2164
commit 5789350de2
@@ -19,36 +19,63 @@ public class YourEntity implements MongoEntity {
**重要规则**: **重要规则**:
- **点之前**(`.`前):**数据库名**(database) - **点之前**(`.`前):**数据库名**(database)
- **点之后**(`.`后):**集合名**(collection) - **点之后**(`.`后):**集合名**(collection)
- 不同的数据库对应不同的 MongoDB URI 常量
### 数据库与 URI 常量的对应关系
| 数据库名 | MongoDB URI 常量 | 服务器地址 | 用途 |
|---------|-----------------|-----------|------|
| `business` | `Constants.SEAWATER_MONGO_URI` | 192.168.0.206:27020 | 业务日志、开放平台相关 |
| `fangjia` | `Constants.FANGJIA_MONGO_URI` | mongo.db.fangjia.com:28017 | 核心业务数据 |
| `fangjia_stat` | `Constants.FANGJIA_MONGO_URI` | mongo.db.fangjia.com:28017 | 统计数据 |
| `address_analytics` | `Constants.FANGJIA_MONGO_URI` | mongo.db.fangjia.com:28017 | 地址分析数据 |
**示例**: **示例**:
```java ```java
// business.open_uri_log → business 数据库 → 使用 SEAWATER_MONGO_URI // business.open_uri_log → business 数据库,open_uri_log 集合
@Table(name = "business.open_uri_log") @Table(name = "business.open_uri_log")
// fangjia_stat.district_stat → fangjia_stat 数据库 → 使用 FANGJIA_MONGO_URI // fangjia_stat.district_stat → fangjia_stat 数据库,district_stat 集合
@Table(name = "fangjia_stat.district_stat") @Table(name = "fangjia_stat.district_stat")
// fangjia.seaweed → fangjia 数据库,seaweed 集合 → 使用 FANGJIA_MONGO_URI // fangjia.seaweed → fangjia 数据库,seaweed 集合
@Table(name = "fangjia.seaweed") @Table(name = "fangjia.seaweed")
``` ```
### 数据访问方式
#### 1. 业务项目中(fangjia-open、fangjia-coresite 等)
**推荐方式**:通过 DAL 层的 Service 和 DAO 访问数据
```java
// 使用 Service 层
@Autowired
private DistrictStatService districtStatService;
DistrictStat stat = districtStatService.findOneDistrictStatsSort(city, region, name, null);
```
**不推荐**:直接使用 MongoDB URI 连接数据库
#### 2. Script 项目中(fangjia-script)
**可以使用**:MongoDB URI 常量直接查询
| 数据库名 | MongoDB URI 常量 | 服务器地址 |
|---------|-----------------|-----------|
| `business` | `Constants.SEAWATER_MONGO_URI` | 192.168.0.206:27020 |
| `fangjia`、`fangjia_stat` 等 | `Constants.FANGJIA_MONGO_URI` | mongo.db.fangjia.com:28017 |
```groovy
// Script 项目中可以直接使用 Mongo3Utils
MongoCollection<Document> coll = Mongo3Utils.getDbCollection(
Constants.SEAWATER_MONGO_URI,
"business",
"open_uri_log"
)
```
**原因**:Script 项目主要用于数据分析、批处理、测试等场景,需要灵活直接的数据库访问
--- ---
## MongoDB数据表 ## MongoDB数据表
### 1. business.open_uri_log ### 1. business.open_uri_log
**服务器**:192.168.0.206 (通过 `Constants.SEAWATER_MONGO_URI` 连接) **数据库**:business (MongoDB 192.168.0.206:27020)
**集合名**:open_uri_log
**作用**:记录所有开放平台API的调用日志,包含请求参数、返回结果等 **作用**:记录所有开放平台API的调用日志,包含请求参数、返回结果等
@@ -61,7 +88,9 @@ public class YourEntity implements MongoEntity {
| `res_map` | Document | 返回结果(嵌套文档) | | `res_map` | Document | 返回结果(嵌套文档) |
| `c_date` | Date | 创建时间 | | `c_date` | Date | 创建时间 |
**连接方式**: **访问方式**:
**Script 项目** - 直接使用 Mongo3Utils 查询:
```groovy ```groovy
import com.fangjia.core.Constants import com.fangjia.core.Constants
import com.fangjia.core.util.Mongo3Utils import com.fangjia.core.util.Mongo3Utils
@@ -71,10 +100,7 @@ MongoCollection<Document> coll = Mongo3Utils.getDbCollection(
"business", "business",
"open_uri_log" "open_uri_log"
) )
```
**典型查询**:
```groovy
// 查询特定用户的API调用记录 // 查询特定用户的API调用记录
Document query = new Document("user_id", "1007569") Document query = new Document("user_id", "1007569")
.append("request_uri", "/address/risk") .append("request_uri", "/address/risk")
@@ -88,15 +114,15 @@ MongoCursor<Document> cursor = coll.find(query)
``` ```
**使用场景**: **使用场景**:
- 提取历史调用数据用于接口测试 - 提取历史调用数据用于接口测试(Script项目)
- 分析API调用量和参数分布 - 分析API调用量和参数分布(Script项目)
- 排查接口调用问题 - 排查接口调用问题
--- ---
### 2. fangjia_stat.district_stat ### 2. fangjia_stat.district_stat
**数据库**:fangjia_stat (通过 `Constants.FANGJIA_MONGO_URI` 连接) **数据库**:fangjia_stat (MongoDB mongo.db.fangjia.com:28017)
**集合名**:district_stat **集合名**:district_stat
**作用**:存储小区级别的价格统计数据 **作用**:存储小区级别的价格统计数据
@@ -111,22 +137,36 @@ MongoCursor<Document> cursor = coll.find(query)
| `avgPrice` | Integer | 均价(备选,元/平米) | | `avgPrice` | Integer | 均价(备选,元/平米) |
| `weekend` | Date | 数据更新时间 | | `weekend` | Date | 数据更新时间 |
**典型查询**: **访问方式**:
```groovy
// 通过DistrictStatService查询 **业务项目** - 通过 Service 层查询:
```java
@Autowired
private DistrictStatService districtStatService;
// 查询最新的小区统计数据
DistrictStat latestStat = districtStatService.findOneDistrictStatsSort( DistrictStat latestStat = districtStatService.findOneDistrictStatsSort(
city, region, name, null city, region, name, null
) );
// 优先使用avg_price_2b // 优先使用avg_price_2b
Integer avgPrice = null Integer avgPrice = null;
if (latestStat.getAvg_price_2b() != null && latestStat.getAvg_price_2b() > 0) { if (latestStat.getAvg_price_2b() != null && latestStat.getAvg_price_2b() > 0) {
avgPrice = latestStat.getAvg_price_2b() avgPrice = latestStat.getAvg_price_2b();
} else if (latestStat.getAvgPrice() > 0) { } else if (latestStat.getAvgPrice() > 0) {
avgPrice = latestStat.getAvgPrice() avgPrice = latestStat.getAvgPrice();
} }
``` ```
**Script 项目** - 可直接使用 Mongo3Utils 查询:
```groovy
MongoCollection<Document> coll = Mongo3Utils.getDbCollection(
Constants.FANGJIA_MONGO_URI,
"fangjia_stat",
"district_stat"
)
```
**使用场景**: **使用场景**:
- 查询小区参考均价 - 查询小区参考均价
- E基金地址匹配接口返回参考价格 - E基金地址匹配接口返回参考价格
@@ -136,7 +176,7 @@ if (latestStat.getAvg_price_2b() != null && latestStat.getAvg_price_2b() > 0) {
### 3. fangjia.deal_price ### 3. fangjia.deal_price
**数据库**:fangjia (通过 `Constants.FANGJIA_MONGO_URI` 连接) **数据库**:fangjia (MongoDB mongo.db.fangjia.com:28017)
**集合名**:deal_price **集合名**:deal_price
**作用**:存储房产成交记录 **作用**:存储房产成交记录
@@ -151,30 +191,44 @@ if (latestStat.getAvg_price_2b() != null && latestStat.getAvg_price_2b() > 0) {
| `totalPrice` | Integer | 成交总价(万元) | | `totalPrice` | Integer | 成交总价(万元) |
| 成交时间 | Date | 成交日期 | | 成交时间 | Date | 成交日期 |
**典型查询**: **访问方式**:
```groovy
// 通过DealPriceService查询近半年成交记录 **业务项目** - 通过 Service 层查询:
Date halfYearAgo = new Date(System.currentTimeMillis() - 180L * 24 * 60 * 60 * 1000) ```java
Date now = new Date() @Autowired
private DealPriceService dealPriceService;
// 查询近半年成交记录
Date halfYearAgo = new Date(System.currentTimeMillis() - 180L * 24 * 60 * 60 * 1000);
Date now = new Date();
List<DealPrice> dealPrices = dealPriceService.findDealPriceList( List<DealPrice> dealPrices = dealPriceService.findDealPriceList(
city, region, name, halfYearAgo, now city, region, name, halfYearAgo, now
) );
// 找到单价最接近参考均价的成交记录 // 找到单价最接近参考均价的成交记录
DealPrice closestDeal = null DealPrice closestDeal = null;
int minDiff = Integer.MAX_VALUE int minDiff = Integer.MAX_VALUE;
for (DealPrice deal : dealPrices) { for (DealPrice deal : dealPrices) {
if (deal.getAvgPrice() != null && deal.getTotalPrice() != null) { if (deal.getAvgPrice() != null && deal.getTotalPrice() != null) {
int diff = Math.abs(deal.getAvgPrice() - referencePrice) int diff = Math.abs(deal.getAvgPrice() - referencePrice);
if (diff < minDiff) { if (diff < minDiff) {
minDiff = diff minDiff = diff;
closestDeal = deal closestDeal = deal;
} }
} }
} }
``` ```
**Script 项目** - 可直接使用 Mongo3Utils 查询:
```groovy
MongoCollection<Document> coll = Mongo3Utils.getDbCollection(
Constants.FANGJIA_MONGO_URI,
"fangjia",
"deal_price"
)
```
**使用场景**: **使用场景**:
- 查询成交记录 - 查询成交记录
- 计算典型总价(最接近参考均价的成交总价) - 计算典型总价(最接近参考均价的成交总价)
@@ -184,7 +238,7 @@ for (DealPrice deal : dealPrices) {
### 4. fangjia_stat.region_sell_stat ### 4. fangjia_stat.region_sell_stat
**数据库**:fangjia_stat (通过 `Constants.FANGJIA_MONGO_URI` 连接) **数据库**:fangjia_stat (MongoDB mongo.db.fangjia.com:28017)
**集合名**:region_sell_stat **集合名**:region_sell_stat
**作用**:存储区域级别的销售价格统计 **作用**:存储区域级别的销售价格统计
@@ -198,27 +252,41 @@ for (DealPrice deal : dealPrices) {
| `date` | Integer | 数据日期(yyyyMM格式) | | `date` | Integer | 数据日期(yyyyMM格式) |
| `updateDate` | Date | 更新时间 | | `updateDate` | Date | 更新时间 |
**典型查询**: **访问方式**:
```groovy
// 需要先格式化城市和区域为简称
String formattedCity = RegionData.formatCity(city)
String formattedRegion = RegionData.formatRegion(formattedCity, district)
// 通过RegionSellStatService查询最新区域价格 **业务项目** - 通过 Service 层查询:
```java
@Autowired
private RegionSellStatService regionSellStatService;
// 需要先格式化城市和区域为简称
String formattedCity = RegionData.formatCity(city);
String formattedRegion = RegionData.formatRegion(formattedCity, district);
// 查询最新区域价格
RegionSellStat regionSellStat = regionSellStatService.findNewestRegionPrice( RegionSellStat regionSellStat = regionSellStatService.findNewestRegionPrice(
formattedCity, formattedRegion formattedCity, formattedRegion
) );
if (regionSellStat != null && regionSellStat.getAvgPrice() != null) { if (regionSellStat != null && regionSellStat.getAvgPrice() != null) {
Integer avgPrice = regionSellStat.getAvgPrice() Integer avgPrice = regionSellStat.getAvgPrice();
// 格式化日期 // 格式化日期
String updateTime = DateUtil.formatByPattern( String updateTime = DateUtil.formatByPattern(
DateUtil.parseDate(regionSellStat.getDate().toString(), "yyyyMM"), DateUtil.parseDate(regionSellStat.getDate().toString(), "yyyyMM"),
"yyyy-MM-dd" "yyyy-MM-dd"
) );
} }
``` ```
**Script 项目** - 可直接使用 Mongo3Utils 查询:
```groovy
MongoCollection<Document> coll = Mongo3Utils.getDbCollection(
Constants.FANGJIA_MONGO_URI,
"fangjia_stat",
"region_sell_stat"
)
```
**使用场景**: **使用场景**:
- 查询区域级别参考价格 - 查询区域级别参考价格
- 地址匹配失败时返回区域价格 - 地址匹配失败时返回区域价格
@@ -228,7 +296,7 @@ if (regionSellStat != null && regionSellStat.getAvgPrice() != null) {
### 5. fangjia.seaweed ### 5. fangjia.seaweed
**数据库**:fangjia (通过 `Constants.FANGJIA_MONGO_URI` 连接) **数据库**:fangjia (MongoDB mongo.db.fangjia.com:28017)
**集合名**:seaweed (实体类为 District,通过 @DatastoreCategory("district") 标识) **集合名**:seaweed (实体类为 District,通过 @DatastoreCategory("district") 标识)
**作用**:存储小区、写字楼等建筑的基础信息(权威数据源) **作用**:存储小区、写字楼等建筑的基础信息(权威数据源)
@@ -243,18 +311,32 @@ if (regionSellStat != null && regionSellStat.getAvgPrice() != null) {
| `cat` | String | 分类(district=小区, office=写字楼) | | `cat` | String | 分类(district=小区, office=写字楼) |
| `estate_type2` | String | 物业类型 | | `estate_type2` | String | 物业类型 |
**典型查询**: **访问方式**:
```groovy
// 通过DistrictService根据ID查询 **业务项目** - 通过 Service 层查询:
District district = districtService.findById(id) ```java
@Autowired
private DistrictService districtService;
// 根据ID查询小区信息
District district = districtService.findById(id);
if (district != null) { if (district != null) {
String city = district.getCity() String city = district.getCity();
String region = district.getRegion() String region = district.getRegion();
String name = district.getName() String name = district.getName();
} }
``` ```
**Script 项目** - 可直接使用 Mongo3Utils 查询:
```groovy
MongoCollection<Document> coll = Mongo3Utils.getDbCollection(
Constants.FANGJIA_MONGO_URI,
"fangjia",
"seaweed"
)
```
**使用场景**: **使用场景**:
- 根据ID查询小区权威信息 - 根据ID查询小区权威信息
- 获取小区的城市、区域、名称用于后续查询 - 获取小区的城市、区域、名称用于后续查询