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.

176 lines
6.2 KiB

9 months ago
package com.dsideal.base.DataEase.Controller;
9 months ago
import cn.hutool.core.codec.Base64;
9 months ago
import com.dsideal.base.Base.Model.BaseModel;
9 months ago
import com.dsideal.base.BaseApplication;
9 months ago
import com.dsideal.base.DataEase.Model.DataEaseModel;
9 months ago
import com.dsideal.base.Interceptor.EmptyInterface;
9 months ago
import com.dsideal.base.Interceptor.IsLoginInterface;
9 months ago
import com.dsideal.base.Interceptor.IsNumericInterface;
9 months ago
import com.dsideal.base.Res.Model.ResourceModel;
9 months ago
import com.dsideal.base.Util.CommonUtil;
import com.dsideal.base.Util.CookieUtil;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.plugin.activerecord.Record;
import io.github.yedaxia.apidocs.ApiDoc;
import net.sf.json.JSONArray;
9 months ago
import net.sf.json.JSONObject;
9 months ago
import java.util.List;
9 months ago
9 months ago
public class DataEaseController extends Controller {
DataEaseModel dm = new DataEaseModel();
9 months ago
ResourceModel rm = new ResourceModel();
9 months ago
BaseModel bm = new BaseModel();
9 months ago
// http://10.10.21.20:9000/dsBase/dataease/route?city_name=昆明市
// http://10.10.21.20:9000/dsBase/dataease/route?city_name=楚雄彝族自治州
// http://10.10.21.20:9000/dsBase/dataease/route?city_name=西双版纳傣族自治州
// !!!必须发布后访问才能做到进入此接口,否则浏览器就走缓存,不进来这个接口了!!!
9 months ago
9 months ago
/**
*
9 months ago
*
9 months ago
* @param city_name
*/
9 months ago
@Before({GET.class})
@EmptyInterface({"city_name"})
public void route(String city_name) {
//大屏名称
String dataVisualizationName = BaseApplication.PropKit.get("dataEase.dataVisualizationName");
//发布的地址
String publish_url = BaseApplication.PropKit.get("dataEase.publish_url");
//先更新一下数据表
dm.updateCity(dataVisualizationName, city_name);
//再拼接一下URL的最终地址
JSONObject jo = new JSONObject();
jo.put("city_name", city_name);
String base64Str = Base64.encode(jo.toString());
//跳转
redirect(publish_url + "/#/de-link/zud8IQ8J?attachParams=" + base64Str);
}
9 months ago
/**
* identity_id,
*/
@Before({GET.class})
@IsLoginInterface({})
public void getDataSet() {
// 人员身份
// identity_id=1 省
// identity_id=2 市
// identity_id=3 县
int identity_id = Integer.parseInt(CookieUtil.getValue(getRequest(), "identity_id"));
9 months ago
List<com.jfinal.plugin.activerecord.Record> list = dm.getDataSetByIdentityId(identity_id);
9 months ago
renderJson(CommonUtil.renderJsonForLayUI(list));
}
/**
*
*
* @param dataset_id id
*/
@Before(GET.class)
@IsLoginInterface({})
9 months ago
@IsNumericInterface({"dataset_id"})
9 months ago
public void getDataSetTable(int dataset_id) {
List<Record> list = dm.getDataSetTableContent(dataset_id);
renderJson(CommonUtil.renderJsonForLayUI(list));
}
/**
*
*
* @param dataset_id id
* @param data
*/
@Before(POST.class)
@IsLoginInterface({})
public void saveDataSetTable(int dataset_id, String data) {
//登录的人员
int identity_id = Integer.parseInt(CookieUtil.getValue(getRequest(), "identity_id"));
String person_id = CookieUtil.getValue(getRequest(), "person_id");
//如果是市/州,名称
//如果是县区,名称
String xmqh = bm.getPersonInfo(person_id).getStr("person_name").replace("管理员", "");
JSONArray jsonArray = JSONArray.fromObject(data);
for (Object o : jsonArray) {
net.sf.json.JSONObject jo = (net.sf.json.JSONObject) o;
9 months ago
if (identity_id > 1 && jo.containsKey("行政区划") && !jo.getString("行政区划").equals(xmqh)) {
9 months ago
renderJson(CommonUtil.returnMessageJson(false, "数据集数据与当前登录人员所属行政区划不一致,请重新选择数据集!"));
return;
}
}
if (identity_id > 1) {
for (Object o : jsonArray) {
net.sf.json.JSONObject jo = (net.sf.json.JSONObject) o;
if (!jo.containsKey("行政区划")) {
renderJson(CommonUtil.returnMessageJson(false, "数据集数据不是省级管理员操作,但却没有行政区划的字段!"));
return;
}
break;
}
}
//保存
dm.saveDataSetTable(identity_id, dataset_id, xmqh, jsonArray);
renderJson(CommonUtil.returnMessageJson(true, "保存成功"));
}
9 months ago
9 months ago
/**
* Excel
*
* @param id id
*/
@Before(GET.class)
@IsLoginInterface({})
@IsNumericInterface({"id"})
public void downloadExcel(int id) {
//根据当前登录人员的身份,获取对应的数据集名称
int identity_id = Integer.parseInt(CookieUtil.getValue(getRequest(), "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);
Record record = dm.getDataSetById(id);
String table_name = record.getStr("table_name");
String dataSetName = record.getStr("dataset_name");
switch (identity_id) {
case 1:
break;
case 2:
break;
case 3:
break;
}
}
/**
* Excel
*
* @param type_id 1:2
*/
@Before(GET.class)
@IsLoginInterface({})
public void downSampleExcel(int type_id) {
}
/**
* Excel
*/
@Before(POST.class)
@IsLoginInterface({})
public void uploadExcel() {
}
9 months ago
9 months ago
}