main
黄海 9 months ago
parent f4c669fb09
commit 024c182f56

@ -108,16 +108,23 @@ public class DataEaseController extends Controller {
@Before({GET.class})
@IsLoginInterface({})
public void getDataSet() {
// 人员身份
// identity_id=1 省
// identity_id=2 市
// identity_id=3 县
String identity_idStr = CookieUtil.getValue(getRequest(), "identity_id");
int identity_id = 1;
if (!StrKit.isBlank(identity_idStr)) {
identity_id = Integer.parseInt(identity_idStr);
}
List<com.jfinal.plugin.activerecord.Record> list = dm.getDataSetByIdentityId(identity_id);
//根据当前登录人员的身份,获取对应的数据集名称
String person_id = CookieUtil.getValue(getRequest(), "person_id");
//获取他是哪个城市或者县区的管理员
//行政区划码
String area_code = rm.getAreaCode(identity_id, person_id);
//根据区域码,获取区域名称
String area_name = rm.getAreaName(area_code);
// 人员身份
// identity_id=1 省
// identity_id=2 市
// identity_id=3 县
List<Record> list = dm.getDataSetByIdentityId(identity_id,area_name);
renderJson(CommonUtil.renderJsonForLayUI(list));
}
@ -147,7 +154,7 @@ public class DataEaseController extends Controller {
String dataSetName = record.getStr("dataset_name");
//导出excel
String upPath = BaseApplication.PropKit.get("upload.path") + "/";
String excelFileName = dm.exportExcel(identity_id, tableName, upPath, area_name);
String excelFileName = dm.exportExcel(identity_id, tableName, upPath, area_name);
//renderFile
renderFile(new File(excelFileName), "【" + area_name + "】" + dataSetName + "." + "xlsx");
}
@ -179,7 +186,7 @@ public class DataEaseController extends Controller {
String tableName = record.getStr("table_name");
String dataSetName = record.getStr("dataset_name");
//导出excel
String excelFileName = dm.exportExcel(identity_id, tableName, tempDir, area_name);
String excelFileName = dm.exportExcel(identity_id, tableName, tempDir, area_name);
//renderFile
renderFile(new File(excelFileName), "【样例:" + area_name + "】" + dataSetName + "." + "xlsx");
}
@ -203,7 +210,7 @@ public class DataEaseController extends Controller {
//根据区域码,获取区域名称
String area_name = rm.getAreaName(area_code);
//父亲的区域名称
String parent_area_name=rm.getParentAreaName(area_name);
String parent_area_name = rm.getParentAreaName(area_name);
//上传的文件
UploadFile uploadFile = getFile("file");
//数据集id
@ -238,7 +245,7 @@ public class DataEaseController extends Controller {
ExcelReader excelReader = new ExcelReader();
List<ExcelRow> rows = excelReader.readXlsxFile(excelPath, excelCols);
dm.saveDataSetTable(identity_id, id,parent_area_name, area_name, rows);
dm.saveDataSetTable(identity_id, id, parent_area_name, area_name, rows);
//返回结果
Kv kv = Kv.create();

@ -30,9 +30,19 @@ public class DataEaseModel {
* @param identity_id id
* @return
*/
public List<Record> getDataSetByIdentityId(int identity_id) {
String sql = "select * from t_dp_dataset where owner_id=? order by dataease_id";
return Db.find(sql, identity_id);
public List<Record> getDataSetByIdentityId(int identity_id, String area_name) {
String sql = "select t1.* from t_dp_dataset as t1 where t1.owner_id=? order by t1.dataease_id";
List<Record> list = Db.find(sql, identity_id);
if (!StrKit.isBlank(area_name)) {
for (Record record : list) {
//这个数据集,当前的区域,已经填写了多少条数据
String table_name = record.getStr("table_name");
sql = "select count(1) as c from `" + table_name + "` where `行政区划`='" + area_name + "'";
int cnt = Db.use(DB_NAME).queryInt(sql);
record.set("fill_count", cnt);
}
}
return list;
}

@ -1,6 +1,7 @@
package com.dsideal.base.Tools;
import com.dsideal.base.DataEase.Model.DataEaseModel;
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
import com.dsideal.base.Tools.Util.SshMysqlConnectUtil;
import com.jcraft.jsch.JSchException;
import com.jfinal.plugin.activerecord.Record;
@ -15,10 +16,11 @@ public class DataSetAddXzqh {
public static DataEaseModel dm = new DataEaseModel();
public static void main(String[] args) throws IOException, JSchException {
Session session = SshMysqlConnectUtil.Init();
LocalMysqlConnectUtil.Init();
//遍历所有以excel_开头的表找出这些表中是不是存在行政区划,上级行政区划的列名
for (int identity_id : new int[]{1, 2, 3}) {
List<Record> list = dm.getDataSetByIdentityId(identity_id);
List<Record> list = dm.getDataSetByIdentityId(identity_id,null);
//开始检查
for (Record record : list) {
String tableName = record.getStr("table_name");
@ -37,6 +39,5 @@ public class DataSetAddXzqh {
}
}
System.out.println("恭喜,所有数据处理完毕。");
session.disconnect();
}
}

@ -26,7 +26,7 @@ public class ExportExcel {
String privinceName = "云南省";
//一、导出省的数据集
System.out.println("正在处理省数据集...");
List<Record> list = dm.getDataSetByIdentityId(1);
List<Record> list = dm.getDataSetByIdentityId(1,null);
System.out.println("数据集个数=" + list.size());
for (Record record : list) {
String tableName = record.getStr("table_name");
@ -37,7 +37,7 @@ public class ExportExcel {
//二、导出市的数据集
System.out.println("正在处理市数据集...");
String city_name = "昆明市";
list = dm.getDataSetByIdentityId(2);
list = dm.getDataSetByIdentityId(2,null);
System.out.println("数据集个数=" + list.size());
for (Record record : list) {
String tableName = record.getStr("table_name");
@ -51,7 +51,7 @@ public class ExportExcel {
//三、导出县区的数据集
System.out.println("正在处理县区数据集...");
String area_name = "寻甸县";
list = dm.getDataSetByIdentityId(3);
list = dm.getDataSetByIdentityId(3,null);
System.out.println("数据集个数=" + list.size());
for (Record record : list) {
String tableName = record.getStr("table_name");

Loading…
Cancel
Save