|
|
|
@ -7,6 +7,7 @@ import com.jfinal.kit.StrKit;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.plugin.activerecord.SqlPara;
|
|
|
|
|
import net.sf.json.JSONArray;
|
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
@ -39,7 +40,7 @@ public class DataEaseModel {
|
|
|
|
|
String table_name = record.getStr("table_name");
|
|
|
|
|
sql = "select count(1) as c from `" + table_name + "`";
|
|
|
|
|
if (identity_id > 1) {
|
|
|
|
|
sql += " where `行政区划`='" + area_name + "'";
|
|
|
|
|
sql += " where `行政区划`='" + area_name + "'";
|
|
|
|
|
}
|
|
|
|
|
int cnt = Db.use(DB_NAME).queryInt(sql);
|
|
|
|
|
record.set("fill_count", cnt);
|
|
|
|
@ -560,4 +561,43 @@ public class DataEaseModel {
|
|
|
|
|
String sql = "select * from ds_db.t_dm_area where province_id=? and level_id=5";
|
|
|
|
|
return Db.find(sql, provinceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取数据集对应的表
|
|
|
|
|
*
|
|
|
|
|
* @param dataset_id 数据集id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<Record> getDataSet(int dataset_id) {
|
|
|
|
|
String tableName = getTableName(dataset_id);
|
|
|
|
|
String sql = "select * from `" + tableName + "`";
|
|
|
|
|
return Db.use(DB_NAME).find(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存数据集对应的表
|
|
|
|
|
*
|
|
|
|
|
* @param dataset_id 数据集id
|
|
|
|
|
* @param ja json数组
|
|
|
|
|
*/
|
|
|
|
|
public void saveDataSet(int identity_id, int dataset_id, String area_name, JSONArray ja) {
|
|
|
|
|
String tableName = getTableName(dataset_id);
|
|
|
|
|
String sql = "delete from `" + tableName + "` where `行政区划`=?";
|
|
|
|
|
Db.use(DB_NAME).update(sql);
|
|
|
|
|
|
|
|
|
|
List<Record> list = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < ja.size(); i++) {
|
|
|
|
|
JSONObject jsonObject = ja.getJSONObject(i);
|
|
|
|
|
//遍历jo的每一个属性
|
|
|
|
|
// 或者使用keySet和for-each循环遍历
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
for (Object key : jsonObject.keySet()) {
|
|
|
|
|
Object value = jsonObject.get(key);
|
|
|
|
|
if (value.equals("null")) value = null;
|
|
|
|
|
record.set(key.toString(), value);
|
|
|
|
|
}
|
|
|
|
|
list.add(record);
|
|
|
|
|
}
|
|
|
|
|
Db.use(DB_NAME).batchSave(tableName, list, 100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|