You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.5 KiB
62 lines
2.5 KiB
package com.dsideal.base.AI.Model;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
import java.util.List;
|
|
|
|
public class YunNanModel {
|
|
/**
|
|
* 收集指定地区的教育资源配置数据
|
|
*
|
|
* @param regions 要对比的地区数组
|
|
* @return 格式化的数据内容
|
|
*/
|
|
public String collectEducationData(String[] regions) {
|
|
// 查询教育资源配置发展预测相关表
|
|
String sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dataease' AND TABLE_NAME LIKE 'excel_报告-教育资源配置发展预测%';";
|
|
List<com.jfinal.plugin.activerecord.Record> tableList = Db.find(sql);
|
|
|
|
StringBuilder dataContent = new StringBuilder();
|
|
|
|
// 构建数据标题
|
|
dataContent.append("教育资源配置发展预测数据对比分析\n\n");
|
|
dataContent.append("对比州市:").append(String.join(" vs ", regions)).append("\n\n");
|
|
|
|
// 遍历所有相关数据表
|
|
for (com.jfinal.plugin.activerecord.Record record : tableList) {
|
|
String tableName = record.getStr("TABLE_NAME");
|
|
dataContent.append("数据表:").append(tableName).append("\n");
|
|
|
|
// 为每个地区收集数据
|
|
for (String region : regions) {
|
|
sql = "select * from `" + tableName + "` where `行政区划`=?";
|
|
List<com.jfinal.plugin.activerecord.Record> listContent = Db.use(DataEaseModel.DB_NAME).find(sql, region);
|
|
|
|
if (!listContent.isEmpty()) {
|
|
dataContent.append("\n").append(region).append("数据:\n");
|
|
for (Record dataRecord : listContent) {
|
|
dataContent.append(JSONUtil.toJsonPrettyStr(dataRecord.getColumns())).append("\n");
|
|
}
|
|
} else {
|
|
dataContent.append("\n").append(region).append(":无相关数据\n");
|
|
}
|
|
}
|
|
dataContent.append("\n----------------------------------------\n\n");
|
|
}
|
|
return dataContent.toString();
|
|
}
|
|
|
|
/**
|
|
* 获取云南省下所有城市名称
|
|
*
|
|
* @return
|
|
*/
|
|
public List<Record> getYunNanCity() {
|
|
String sql = "select id,area_code,area_name,full_name from t_dm_area where parent_id='FD61813E-70A1-42AB-9A8E-141ED4D47B98'";
|
|
return Db.find(sql);
|
|
}
|
|
}
|