|
@@ -428,4 +428,166 @@ public class ZymlServiceImpl implements IZymlService {
|
|
|
private boolean hasChild(List<ZymlTreeDTO> list, ZymlTreeDTO t) {
|
|
|
return getChildList(list, t).size() > 0 ? true : false;
|
|
|
}
|
|
|
+
|
|
|
+ //递归循环
|
|
|
+ public List<ZymlDTO> GetZymlSubsetList(String username, String pbsm, String name, Boolean share) {
|
|
|
+ String sharestate = null;
|
|
|
+ if (share != null && share == true) {
|
|
|
+ sharestate = "0";
|
|
|
+ }
|
|
|
+ List<ZymlDTO> ret = new ArrayList<>();
|
|
|
+ List<ZymlDTO> res = zymlMapper.GetListCondition(username, null, pbsm, name, sharestate);
|
|
|
+ for (ZymlDTO dto : res) {
|
|
|
+ List<ZymlDTO> subset = GetZymlSubsetList(username, dto.getBsm(), name, share);
|
|
|
+ ret.addAll(subset);
|
|
|
+ }
|
|
|
+ ret.addAll(res);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RequestResult GetZymlList(String bsm, String pbsm, String name, Boolean share, Boolean subset) {
|
|
|
+ try {
|
|
|
+ List<ZymlDTO> res = new ArrayList<>();
|
|
|
+ String sharestate = "1";
|
|
|
+ if (share != null && share == true) {
|
|
|
+ sharestate = "0";
|
|
|
+ }
|
|
|
+ //TODO 暂时为admin
|
|
|
+// String username = SecurityUtils.getUsername();
|
|
|
+ String username = "admin";
|
|
|
+ if (StringUtils.isNotEmpty(username)) {
|
|
|
+ //暂定管理员权限可以查询所有数据,其他只能看到自己的
|
|
|
+ if (username.equals("admin")) {
|
|
|
+ username = null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return RequestResult.error("参数缺失");
|
|
|
+ }
|
|
|
+ List<ZymlDTO> ret = zymlMapper.GetListCondition(username, bsm, pbsm, name, sharestate);
|
|
|
+ if (subset != null && subset) {
|
|
|
+ for (ZymlDTO dto : ret) {
|
|
|
+ List<ZymlDTO> subsetList = GetZymlSubsetList(username, dto.getBsm(), name, share);
|
|
|
+ res.addAll(subsetList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ res.addAll(ret);
|
|
|
+ List<ZymlTreeDataDTO> treedata = new ArrayList<>();
|
|
|
+ for (int i = 0; i < res.size(); i++) {
|
|
|
+ ZymlDTO cur = res.get(i);
|
|
|
+ ZymlTreeDataDTO c = new ZymlTreeDataDTO();
|
|
|
+// c.setDisabled((cur.getParent() == 1));
|
|
|
+ c.setId(cur.getBsm());
|
|
|
+ c.setPid(cur.getPbsm());
|
|
|
+ c.setLabel(cur.getName());
|
|
|
+ c.setTitle(cur.getName());
|
|
|
+ c.setType(cur.getType());
|
|
|
+ c.setLegend(cur.getLegend());
|
|
|
+ c.setUrl(cur.getUrl());
|
|
|
+ c.setSource(cur.getSde());
|
|
|
+ c.setFavorite(cur.getMy());
|
|
|
+ c.setMinimumlevel(cur.getMinimumlevel());
|
|
|
+ c.setMaximumlevel(cur.getMaximumlevel());
|
|
|
+ c.setFormat(cur.getFormat());
|
|
|
+ c.setLayergroup(cur.getLayergroup());
|
|
|
+ c.setQpfa(cur.getQpfa());
|
|
|
+ c.setFwys(cur.getFwys());
|
|
|
+ c.setFwgzkj(cur.getFwgzkj());
|
|
|
+ c.setFwmc(cur.getFwmc());
|
|
|
+ c.setServerType(cur.getServerType());
|
|
|
+ c.setSharestate(cur.getSharestate());
|
|
|
+ c.setYear(cur.getYear());
|
|
|
+ treedata.add(c);
|
|
|
+ }
|
|
|
+ List<ZymlTreeDataDTO> data = buildDeptTree2(treedata);
|
|
|
+ return RequestResult.success("成功", data);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return RequestResult.error("失败", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public RequestResult GetZymlShareList(String name) {
|
|
|
+ List<ZymlDTO> res = new ArrayList<>();
|
|
|
+ List<ZymlDTO> ret = zymlMapper.GetListCondition(null, null, null, null, null);
|
|
|
+ for (ZymlDTO dto : ret) {
|
|
|
+ List<ZymlDTO> subsetList = GetZymlSubsetList(null, dto.getBsm(), null, null);
|
|
|
+ res.addAll(subsetList);
|
|
|
+ }
|
|
|
+ res.addAll(ret);
|
|
|
+ List<ZymlTreeDataDTO> treedata = new ArrayList<>();
|
|
|
+ for (int i = 0; i < res.size(); i++) {
|
|
|
+ ZymlDTO cur = res.get(i);
|
|
|
+ ZymlTreeDataDTO c = new ZymlTreeDataDTO();
|
|
|
+// c.setDisabled((cur.getParent() == 1));
|
|
|
+ c.setId(cur.getBsm());
|
|
|
+ c.setPid(cur.getPbsm());
|
|
|
+ c.setLabel(cur.getName());
|
|
|
+ c.setTitle(cur.getName());
|
|
|
+ c.setType(cur.getType());
|
|
|
+ c.setLegend(cur.getLegend());
|
|
|
+ c.setUrl(cur.getUrl());
|
|
|
+ c.setSource(cur.getSde());
|
|
|
+ c.setFavorite(cur.getMy());
|
|
|
+ c.setMinimumlevel(cur.getMinimumlevel());
|
|
|
+ c.setMaximumlevel(cur.getMaximumlevel());
|
|
|
+ c.setFormat(cur.getFormat());
|
|
|
+ c.setLayergroup(cur.getLayergroup());
|
|
|
+ c.setQpfa(cur.getQpfa());
|
|
|
+ c.setFwys(cur.getFwys());
|
|
|
+ c.setFwgzkj(cur.getFwgzkj());
|
|
|
+ c.setFwmc(cur.getFwmc());
|
|
|
+ c.setServerType(cur.getServerType());
|
|
|
+ c.setSharestate(cur.getSharestate());
|
|
|
+ c.setYear(cur.getYear());
|
|
|
+ treedata.add(c);
|
|
|
+ }
|
|
|
+ //获取树
|
|
|
+ List<ZymlTreeDataDTO> newRET = new ArrayList<>();
|
|
|
+ List<ZymlTreeDataDTO> data = buildDeptTree2(treedata);
|
|
|
+ for (ZymlTreeDataDTO dto : data) {
|
|
|
+ Map<String, Object> statsMap = new HashMap<>();
|
|
|
+ statsMap.put("stats", false);
|
|
|
+ statsMap.put("id", dto.getId());
|
|
|
+ statsMap.put("data", dto);
|
|
|
+
|
|
|
+ Map<String, Object> retStatsMap = handleZymlTreeShare(statsMap);
|
|
|
+ Boolean retstats = (Boolean) retStatsMap.get("stats");
|
|
|
+ if (retstats) {
|
|
|
+ ZymlTreeDataDTO newData0 = (ZymlTreeDataDTO) retStatsMap.get("data");
|
|
|
+ newRET.add(newData0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return RequestResult.success(newRET);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private Map<String, Object> handleZymlTreeShare(Map<String, Object> data) {
|
|
|
+ ZymlTreeDataDTO dtoObj = (ZymlTreeDataDTO) data.get("data");
|
|
|
+ Boolean stats = (Boolean) data.get("stats");
|
|
|
+ //判断是否是共享类型
|
|
|
+ String sharestate = dtoObj.getSharestate();
|
|
|
+ if (StringUtils.isNotEmpty(sharestate) && sharestate.equals("0")) {
|
|
|
+ stats = true;
|
|
|
+ }
|
|
|
+ List<ZymlTreeDataDTO> child = dtoObj.getChildren();
|
|
|
+ List<ZymlTreeDataDTO> newchild = new ArrayList<>();
|
|
|
+ for (ZymlTreeDataDTO dto : child) {
|
|
|
+ Map<String, Object> statsMap = new HashMap<>();
|
|
|
+ statsMap.put("stats", false);
|
|
|
+ statsMap.put("id", dto.getId());
|
|
|
+ statsMap.put("data", dto);
|
|
|
+ Map<String, Object> retStatsMap = handleZymlTreeShare(statsMap);
|
|
|
+ Boolean retstats = (Boolean) retStatsMap.get("stats");
|
|
|
+ if (retstats) {
|
|
|
+ ZymlTreeDataDTO newData0 = (ZymlTreeDataDTO) retStatsMap.get("data");
|
|
|
+ stats = true;
|
|
|
+ newchild.add(newData0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dtoObj.setChildren(newchild);
|
|
|
+ data.put("data", dtoObj);
|
|
|
+ data.put("stats", stats);
|
|
|
+ return data;
|
|
|
+ }
|
|
|
}
|