|
|
|
package com.dsideal.base.DataEase.Controller;
|
|
|
|
|
|
|
|
import com.dsideal.base.Base.Model.BaseModel;
|
|
|
|
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
|
|
|
import com.dsideal.base.Interceptor.EmptyInterface;
|
|
|
|
import com.dsideal.base.Interceptor.IsLoginInterface;
|
|
|
|
import com.dsideal.base.Interceptor.IsNumericInterface;
|
|
|
|
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;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@ApiDoc
|
|
|
|
public class DataEaseController extends Controller {
|
|
|
|
DataEaseModel dm = new DataEaseModel();
|
|
|
|
BaseModel bm = new BaseModel();
|
|
|
|
|
|
|
|
// http://10.10.21.20:9000/dsBase/dataease/route?city_name=昆明市&r=1234234
|
|
|
|
// http://10.10.21.20:9000/dsBase/dataease/route?city_name=楚雄彝族自治州&r=1234234
|
|
|
|
/**
|
|
|
|
* DataEase仪表板外部参数传递
|
|
|
|
* https://www.jianshu.com/p/cc9982e986f5
|
|
|
|
*
|
|
|
|
* https://base64.us/
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* {"city_name":"昆明市"}
|
|
|
|
* http://10.10.14.203:8100/#/de-link/zud8IQ8J?attachParams=eyJjaXR5X25hbWUiOiLmmIbmmI7luIIifQ==
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* {"city_name":"楚雄彝族自治州"}
|
|
|
|
* http://10.10.14.203:8100/#/de-link/zud8IQ8J?attachParams=eyJjaXR5X25hbWUiOiLmpZrpm4TlvZ3ml4/oh6rmsrvlt54ifQ==
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* 路由跳转
|
|
|
|
* @param city_name 城市名称
|
|
|
|
*/
|
|
|
|
@Before({GET.class})
|
|
|
|
@EmptyInterface({"city_name"})
|
|
|
|
public void route(String city_name) {
|
|
|
|
if(city_name.equals("昆明市")){
|
|
|
|
dm.updateCity("156530100");
|
|
|
|
redirect301("http://10.10.14.203:8100/#/de-link/zud8IQ8J?attachParams=eyJjaXR5X25hbWUiOiLmmIbmmI7luIIifQ==");
|
|
|
|
}else{
|
|
|
|
dm.updateCity("156532300");
|
|
|
|
redirect301("http://10.10.14.203:8100/#/de-link/zud8IQ8J?attachParams=eyJjaXR5X25hbWUiOiLmpZrpm4TlvZ3ml4/oh6rmsrvlt54ifQ==");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 根据当前登录人员的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"));
|
|
|
|
List<com.jfinal.plugin.activerecord.Record> list = dm.getDataSet(identity_id);
|
|
|
|
renderJson(CommonUtil.renderJsonForLayUI(list));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取数据集下的数据表
|
|
|
|
*
|
|
|
|
* @param dataset_id 数据集id
|
|
|
|
*/
|
|
|
|
@Before(GET.class)
|
|
|
|
@IsLoginInterface({})
|
|
|
|
@IsNumericInterface({"dataset_id"})
|
|
|
|
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;
|
|
|
|
if (identity_id > 1 && jo.containsKey("行政区划") && !jo.getString("行政区划").equals(xmqh)) {
|
|
|
|
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, "保存成功"));
|
|
|
|
}
|
|
|
|
}
|