|
|
@ -8,10 +8,13 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.parser.Feature;
|
|
|
|
import com.alibaba.fastjson.parser.Feature;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.weaver.common.authority.annotation.WeaPermission;
|
|
|
|
import com.weaver.common.authority.annotation.WeaPermission;
|
|
|
|
import com.weaver.common.base.entity.result.WeaResult;
|
|
|
|
import com.weaver.common.base.entity.result.WeaResult;
|
|
|
|
import com.weaver.seconddev.sxjg.config.EbDbDataSourceConfigResp;
|
|
|
|
import com.weaver.seconddev.sxjg.config.EbDbDataSourceConfigResp;
|
|
|
|
import com.weaver.seconddev.sxjg.util.NccApiUtil;
|
|
|
|
import com.weaver.seconddev.sxjg.util.NccApiUtil;
|
|
|
|
|
|
|
|
import com.weaver.seconddev.sxjg.util.ProvinceCityNode;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@ -154,32 +157,99 @@ public class PayslipPageController {
|
|
|
|
//跟据doclistpk获取基础数据集合
|
|
|
|
//跟据doclistpk获取基础数据集合
|
|
|
|
@WeaPermission(publicPermission = true)
|
|
|
|
@WeaPermission(publicPermission = true)
|
|
|
|
@GetMapping("/getDataSourceList")
|
|
|
|
@GetMapping("/getDataSourceList")
|
|
|
|
public WeaResult<JSONArray> getDataSourceList(@RequestParam("dataSourcePk")String dataSourcePk) {
|
|
|
|
public WeaResult<JSONArray> getDataSourceList(@RequestParam("dataSourcePk")String dataSourcePk,
|
|
|
|
JSONArray result = new JSONArray();
|
|
|
|
@RequestParam(value = "type",required = false,defaultValue = "0") Integer type) throws JsonProcessingException {
|
|
|
|
String sql = "select pk_defdoc,defdocname,enablestate,pid from ec_ebuilder_designer.uf_ncc_defdoc where doclistpk = '"+dataSourcePk+"'";
|
|
|
|
if(type == 10) {//籍贯省市区
|
|
|
|
List<Map<String, Object>> rs = jdbcTemplateresp.queryForList(sql);
|
|
|
|
JSONArray result = new JSONArray();
|
|
|
|
Map<String, Object> singlemap = null;
|
|
|
|
String sql = "select id,pk_defdoc,defdocname,enablestate,pid from ec_ebuilder_designer.uf_ncc_defdoc where doclistpk = '"+dataSourcePk+"'";
|
|
|
|
if(CollectionUtil.isNotEmpty(rs)) {
|
|
|
|
List<Map<String, Object>> rs = jdbcTemplateresp.queryForList(sql);
|
|
|
|
for(Map<String, Object> rsmap : rs) {
|
|
|
|
List<ProvinceCityNode> data = new ArrayList<>();
|
|
|
|
JSONObject rsobj = new JSONObject();
|
|
|
|
if(CollectionUtil.isNotEmpty(rs)) {
|
|
|
|
String pk_defdoc = String.valueOf(rsmap.get("pk_defdoc"));
|
|
|
|
for(Map<String, Object> single : rs) {
|
|
|
|
String defdocname = String.valueOf(rsmap.get("defdocname"));
|
|
|
|
String id = String.valueOf(single.get("id"));
|
|
|
|
String enablestate = String.valueOf(rsmap.get("enablestate"));
|
|
|
|
String pk_defdoc = String.valueOf(single.get("pk_defdoc"));
|
|
|
|
String parentdoc = String.valueOf(rsmap.get("pid"));
|
|
|
|
String defdocname = String.valueOf(single.get("defdocname"));
|
|
|
|
rsobj.put("pkvalue",pk_defdoc);
|
|
|
|
//String enablestate = String.valueOf(single.get("enablestate"));
|
|
|
|
rsobj.put("pkname",defdocname);
|
|
|
|
String pid = String.valueOf(single.get("pid"));
|
|
|
|
rsobj.put("enablestate",enablestate);
|
|
|
|
ProvinceCityNode provinceCityNode = new ProvinceCityNode(id,pid,pk_defdoc,defdocname);
|
|
|
|
if(!("null".equals(parentdoc))) {
|
|
|
|
data.add(provinceCityNode);
|
|
|
|
sql = "select pk_defdoc from ec_ebuilder_designer.uf_ncc_defdoc where id = '"+parentdoc+"'";
|
|
|
|
|
|
|
|
singlemap = jdbcTemplateresp.queryForMap(sql);
|
|
|
|
|
|
|
|
String singlepkdoc = String.valueOf(singlemap.get("pk_defdoc"));
|
|
|
|
|
|
|
|
rsobj.put("parentpkvlaue",singlepkdoc);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
rsobj.put("parentpkvlaue",parentdoc);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.add(rsobj);
|
|
|
|
//创建一个List集合来存放最终的树状结构数据
|
|
|
|
|
|
|
|
List<Map<String, Object>> menuList = new ArrayList<>();
|
|
|
|
|
|
|
|
// 先存入最顶级的树(0代表没有父级,即最顶级),然后通过最顶级的id递归获取子级
|
|
|
|
|
|
|
|
for (ProvinceCityNode entity : data) {
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
|
|
if (entity.parentid ==null || "null".equals(entity.parentid) || "".equals(entity.parentid) || "0".equals(entity.parentid)) {
|
|
|
|
|
|
|
|
map.put("id", entity.id);
|
|
|
|
|
|
|
|
map.put("value", entity.value);
|
|
|
|
|
|
|
|
map.put("isLeaf", entity.isLeaf);
|
|
|
|
|
|
|
|
map.put("parentid", entity.parentid);
|
|
|
|
|
|
|
|
map.put("loading", entity.loading);
|
|
|
|
|
|
|
|
map.put("label", entity.label);
|
|
|
|
|
|
|
|
map.put("disabled", entity.disabled);
|
|
|
|
|
|
|
|
map.put("children", getChildren(data, entity.id));
|
|
|
|
|
|
|
|
menuList.add(map);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
|
|
// 将 List<Map<String, Object>> 转换为 JSON
|
|
|
|
|
|
|
|
String json = objectMapper.writeValueAsString(menuList);
|
|
|
|
|
|
|
|
result = JSONArray.parseArray(json);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return WeaResult.success(result);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
JSONArray result = new JSONArray();
|
|
|
|
|
|
|
|
String sql = "select pk_defdoc,defdocname,enablestate,pid from ec_ebuilder_designer.uf_ncc_defdoc where doclistpk = '"+dataSourcePk+"'";
|
|
|
|
|
|
|
|
List<Map<String, Object>> rs = jdbcTemplateresp.queryForList(sql);
|
|
|
|
|
|
|
|
Map<String, Object> singlemap = null;
|
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(rs)) {
|
|
|
|
|
|
|
|
for(Map<String, Object> rsmap : rs) {
|
|
|
|
|
|
|
|
JSONObject rsobj = new JSONObject();
|
|
|
|
|
|
|
|
String pk_defdoc = String.valueOf(rsmap.get("pk_defdoc"));
|
|
|
|
|
|
|
|
String defdocname = String.valueOf(rsmap.get("defdocname"));
|
|
|
|
|
|
|
|
String enablestate = String.valueOf(rsmap.get("enablestate"));
|
|
|
|
|
|
|
|
String parentdoc = String.valueOf(rsmap.get("pid"));
|
|
|
|
|
|
|
|
rsobj.put("pkvalue",pk_defdoc);
|
|
|
|
|
|
|
|
rsobj.put("pkname",defdocname);
|
|
|
|
|
|
|
|
rsobj.put("enablestate",enablestate);
|
|
|
|
|
|
|
|
if(!("null".equals(parentdoc))) {
|
|
|
|
|
|
|
|
sql = "select pk_defdoc from ec_ebuilder_designer.uf_ncc_defdoc where id = '"+parentdoc+"'";
|
|
|
|
|
|
|
|
singlemap = jdbcTemplateresp.queryForMap(sql);
|
|
|
|
|
|
|
|
String singlepkdoc = String.valueOf(singlemap.get("pk_defdoc"));
|
|
|
|
|
|
|
|
rsobj.put("parentpkvlaue",singlepkdoc);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
rsobj.put("parentpkvlaue",parentdoc);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result.add(rsobj);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return WeaResult.success(result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 递归获取子级节点
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getChildren(List<ProvinceCityNode> data, String id) {
|
|
|
|
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
|
|
|
if (data == null || data.size() == 0 || id == null) {
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (ProvinceCityNode entity : data) {
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
|
|
//如果本级id与数据的父id相同,就说明是子父级关系
|
|
|
|
|
|
|
|
if (id.equals(entity.parentid)) {
|
|
|
|
|
|
|
|
map.put("id", entity.id);
|
|
|
|
|
|
|
|
map.put("value", entity.value);
|
|
|
|
|
|
|
|
map.put("isLeaf", entity.isLeaf);
|
|
|
|
|
|
|
|
map.put("parentid", entity.parentid);
|
|
|
|
|
|
|
|
map.put("loading", entity.loading);
|
|
|
|
|
|
|
|
map.put("label", entity.label);
|
|
|
|
|
|
|
|
map.put("disabled", entity.disabled);
|
|
|
|
|
|
|
|
map.put("children", getChildren(data, entity.id));
|
|
|
|
|
|
|
|
list.add(map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return WeaResult.success(result);
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|