Merge branch 'main' of http://10.10.14.176:3000/huanghai/YunNanDsBase
commit
c083061041
@ -1 +1 @@
|
||||
[{"baseUrl":"","className":"DataEaseController","description":"DataEaseController","docFileName":"com_dsideal_base_DataEase_Controller_DataEaseController.html","generateDocs":true,"packageName":"com.dsideal.base.DataEase.Controller","requestNodes":[{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#route","deprecated":false,"description":"省级路由","header":[],"method":["GET","POST"],"methodName":"route","paramNodes":[{"description":"城市名称","jsonBody":false,"name":"city_name","required":false,"type":"string"}],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/route"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#routePage","deprecated":false,"description":"市级路由","header":[],"method":["GET","POST"],"methodName":"routePage","paramNodes":[{"description":"哪一个仪表盘","jsonBody":false,"name":"type_id","required":false,"type":"int"}],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/routePage"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#getDataSet","deprecated":false,"description":"根据当前登录人员的identity_id,获取此人员可以维护的数据集名称","header":[],"method":["GET","POST"],"methodName":"getDataSet","paramNodes":[],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/getDataSet"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#downloadExcel","deprecated":false,"description":"下载指定数据集的Excel文件","header":[],"method":["GET","POST"],"methodName":"downloadExcel","paramNodes":[{"description":"数据集id","jsonBody":false,"name":"id","required":false,"type":"int"}],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/downloadExcel"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#downSampleExcel","deprecated":false,"description":"下载模板Excel","header":[],"method":["GET","POST"],"methodName":"downSampleExcel","paramNodes":[{"description":"数据集id","jsonBody":false,"name":"id","required":false,"type":"int"}],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/downSampleExcel"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#uploadExcel","deprecated":false,"description":"上传Excel文件","header":[],"method":["GET","POST"],"methodName":"uploadExcel","paramNodes":[],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/uploadExcel"}],"srcFileName":"D:\\dsWork\\YunNanDsBase\\src\\main\\java\\com\\dsideal\\base\\DataEase\\Controller\\DataEaseController.java"}]
|
||||
[{"baseUrl":"","className":"DataEaseController","description":"DataEaseController","docFileName":"com_dsideal_base_DataEase_Controller_DataEaseController.html","generateDocs":true,"packageName":"com.dsideal.base.DataEase.Controller","requestNodes":[{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#route","deprecated":false,"description":"省级路由","header":[],"method":["GET","POST"],"methodName":"route","paramNodes":[{"description":"城市名称","jsonBody":false,"name":"city_name","required":false,"type":"string"}],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/route"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#routePage","deprecated":false,"description":"routePage","header":[],"method":["GET","POST"],"methodName":"routePage","paramNodes":[],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/routePage"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#getDataSet","deprecated":false,"description":"根据当前登录人员的identity_id,获取此人员可以维护的数据集名称","header":[],"method":["GET","POST"],"methodName":"getDataSet","paramNodes":[],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/getDataSet"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#downloadExcel","deprecated":false,"description":"下载指定数据集的Excel文件","header":[],"method":["GET","POST"],"methodName":"downloadExcel","paramNodes":[{"description":"数据集id","jsonBody":false,"name":"id","required":false,"type":"int"}],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/downloadExcel"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#downSampleExcel","deprecated":false,"description":"下载模板Excel","header":[],"method":["GET","POST"],"methodName":"downSampleExcel","paramNodes":[{"description":"数据集id","jsonBody":false,"name":"id","required":false,"type":"int"}],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/downSampleExcel"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#uploadExcel","deprecated":false,"description":"上传Excel文件","header":[],"method":["GET","POST"],"methodName":"uploadExcel","paramNodes":[],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/uploadExcel"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#getDataSetContent","deprecated":false,"description":"获取数据集下的数据表","header":[],"method":["GET","POST"],"methodName":"getDataSetContent","paramNodes":[{"description":"数据集id","jsonBody":false,"name":"dataset_id","required":false,"type":"int"}],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/getDataSetContent"},{"changeFlag":0,"codeFileUrl":"com_dsideal_base_DataEase_Controller_DataEaseController.html#saveDataSet","deprecated":false,"description":"保存数据集下的数据表","header":[],"method":["GET","POST"],"methodName":"saveDataSet","paramNodes":[{"description":"数据集id","jsonBody":false,"name":"dataset_id","required":false,"type":"int"},{"description":"保存的数据","jsonBody":false,"name":"data","required":false,"type":"string"}],"responseNode":{"childNodes":[],"className":"","list":false,"showFieldNotNull":false},"url":"/dataease/saveDataSet"}],"srcFileName":"D:\\dsWork\\YunNanDsBase\\src\\main\\java\\com\\dsideal\\base\\DataEase\\Controller\\DataEaseController.java"}]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,115 @@
|
||||
package com.dsideal.base.Tools;
|
||||
|
||||
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
||||
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Step3_DataSetFakeData {
|
||||
public static DataEaseModel dm = new DataEaseModel();
|
||||
|
||||
/**
|
||||
* 拷贝昆明市的数据
|
||||
*
|
||||
* @param table_name
|
||||
* @param area_name
|
||||
*/
|
||||
public static void CopyData(String table_name, String source_area_name, String area_name, String parent_name) {
|
||||
String sql = "select * from `" + table_name + "` where `行政区划`='" + source_area_name + "'";
|
||||
List<Record> list = Db.use(DataEaseModel.DB_NAME).find(sql);
|
||||
for (Record r : list) {
|
||||
r.set("行政区划", area_name);
|
||||
r.set("上级行政区划", parent_name);
|
||||
r.remove("id");
|
||||
}
|
||||
System.out.println(table_name);
|
||||
Db.use(DataEaseModel.DB_NAME).batchSave(table_name, list, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除某地数据
|
||||
*
|
||||
* @param table_name
|
||||
* @param area_name
|
||||
*/
|
||||
public static void deleteData(String table_name, String area_name) {
|
||||
String sql = "delete from `" + table_name + "` where `行政区划`='" + area_name + "'";
|
||||
Db.use(DataEaseModel.DB_NAME).update(sql);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
//切换至测试数据库
|
||||
//DataEaseModel.DB_NAME = "dataease_huanghai";
|
||||
|
||||
//初始化数据库链接
|
||||
LocalMysqlConnectUtil.Init();
|
||||
|
||||
DataEaseModel dm = new DataEaseModel();
|
||||
|
||||
//这几个是要保留的地名
|
||||
List<String> keepArea = Arrays.asList("云南省", "昆明市", "楚雄州", "寻甸县");
|
||||
//所有市州
|
||||
Record rPrinvice = dm.getAreaByName("云南省");
|
||||
String province_id = rPrinvice.getStr("id");
|
||||
List<Record> listCity = dm.getAreaList(province_id);
|
||||
int identity_id = 1;
|
||||
//完善省级数据
|
||||
List<Record> list = dm.getDataSetByIdentityId(identity_id, null);
|
||||
for (Record record : list) {
|
||||
String table_name = record.getStr("table_name");
|
||||
System.out.println("正在处理数据集:" + table_name);
|
||||
String sql = "update `" + table_name + "` set `行政区划`='云南省' where `行政区划` is null";
|
||||
Db.use(DataEaseModel.DB_NAME).update(sql);
|
||||
sql = "update `" + table_name + "` set `上级行政区划`='云南省' where `上级行政区划` is null";
|
||||
Db.use(DataEaseModel.DB_NAME).update(sql);
|
||||
}
|
||||
|
||||
//拷贝城市数据
|
||||
for (Record rCity : listCity) {
|
||||
//城市名称
|
||||
String area_name = rCity.getStr("area_name");
|
||||
//如果在保留名单中,则跳过
|
||||
if (keepArea.contains(area_name)) {
|
||||
continue;
|
||||
}
|
||||
//遍历所有市州数据集
|
||||
identity_id = 2;
|
||||
list = dm.getDataSetByIdentityId(identity_id, null);
|
||||
for (Record record : list) {
|
||||
String table_name = record.getStr("table_name");
|
||||
System.out.println("正在处理数据集:" + table_name);
|
||||
//检查这个行政区划,在本数据表中是不是存在过,判断办法是 列名: `行政区划`= area_name,如果存在则不作处理,否则拷贝昆明市的数据
|
||||
deleteData(table_name, area_name);
|
||||
CopyData(table_name, "昆明市", area_name, "云南省");
|
||||
}
|
||||
}
|
||||
//获取所有县区
|
||||
List<Record> listArea = dm.getProvinceArea("云南省");
|
||||
for (Record rArea : listArea) {
|
||||
//城市名称
|
||||
String area_name = rArea.getStr("area_name");
|
||||
String parent_id = rArea.getStr("parent_id");
|
||||
//隶属哪个市州
|
||||
Record parentRecord = dm.getAreaById(parent_id);
|
||||
String parent_name = parentRecord.getStr("area_name");
|
||||
//如果在保留名单中,则跳过
|
||||
if (keepArea.contains(area_name)) {
|
||||
continue;
|
||||
}
|
||||
//遍历所有县区数据集
|
||||
identity_id = 3;
|
||||
list = dm.getDataSetByIdentityId(identity_id, null);
|
||||
for (Record record : list) {
|
||||
String table_name = record.getStr("table_name");
|
||||
System.out.println(area_name + "正在处理数据集:" + table_name);
|
||||
//检查这个行政区划,在本数据表中是不是存在过,判断办法是 列名: `行政区划`= area_name,如果存在则不作处理,否则拷贝寻甸县的数据
|
||||
deleteData(table_name, area_name);
|
||||
CopyData(table_name, "寻甸县", area_name, parent_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue