ACtion代码:
public class PedigreeAction extends BaseAction{
public PedigreeQueryBO pedigreeQueryBO;
public void setPedigreeQueryBO(PedigreeQueryBO pedigreeQueryBO) {
this.pedigreeQueryBO = pedigreeQueryBO;
}
@SuppressWarnings("unchecked")
public String getPedigreeDetail(){
String zch = request.getParameter("zch");
Map<String,List> map = new HashMap<String,List>();
//获取企业(机构)登记信息
List<FrkGsjQyjgdjxx> qydjList = this.pedigreeQueryBO.queryQyjgdjxx(zch);
if(qydjList != null)
{
map.put("qydjxx", qydjList);
request.setAttribute("qymc", qydjList.get(0).getQyjgmc());
}
//获取法人股东对外投资信息
List<GdDwtzShowBean> frGdDwtzList = new ArrayList();
if(gdList != null)
{
map.put("gdxx", gdList);
for(int i=0;i<gdList.size();i++){
//自然人
if(gdList.get(i).getTzrbz().equals("1"))
{
List<FrkGsjQyjgdjxx> zrrGdDwtz = this.pedigreeQueryBO.queryZrrGdDwtz(zch, gdList.get(i).getTzr(), gdList.get(i).getZjlx(), gdList.get(i).getZjhm());
if(zrrGdDwtz != null)
{
for(int j=0;j<zrrGdDwtz.size();j++){
GdDwtzShowBean showBean = new GdDwtzShowBean();
showBean.setQymc(zrrGdDwtz.get(j).getQyjgmc());
showBean.setTzr(gdList.get(i).getTzr());
zrrGdDwtzList.add(showBean);
}
}
}else if(gdList.get(i).getTzrbz().equals("2"))//非自然人
{
List<FrkGsjQyjgdjxx> frGdDwtz = this.pedigreeQueryBO.queryFrGdDwtz(zch, gdList.get(i).getTzr(), gdList.get(i).getZzlx(), gdList.get(i).getZzbh());
if(frGdDwtz != null)
{
for(int j=0;j<frGdDwtz.size();j++){
GdDwtzShowBean showBean = new GdDwtzShowBean();
showBean.setQymc(frGdDwtz.get(j).getQyjgmc());
showBean.setTzr(gdList.get(i).getTzr());
zrrGdDwtzList.add(showBean);
}
}
}
}
map.put("zrrGdDwtz", zrrGdDwtzList);
map.put("frGdDwtz", frGdDwtzList);
}
//节点展示Json串
List<Map<String,String>> newNodes = this.execNodes(map);
JSONArray jsonDataNodes = JSONArray.fromObject(newNodes);
request.setAttribute("jsonDataNodes", jsonDataNodes);
//关系展示Json串
List<Map<String,String>> newLink = this.execLink(map);
JSONArray jsonDataLink= JSONArray.fromObject(newLink);
request.setAttribute("jsonDataLink", jsonDataLink);
return "success";
}
/**
* <p>Method :execNodes
* <p>Description : 获取节点展示Json串
*
* @param map
* @return
*/
@SuppressWarnings("unchecked")
private List<Map<String, String>> execNodes(Map<String, List> map){
List<Map<String,String>> newTzrList = new ArrayList<Map<String,String>>();
//企业对外投资节点展示
if(map.get("zyryxx") != null)
{
List<FrkGsjQyjgdjxx> zyryList = map.get("qydwtz");
for(int i=0;i<zyryList.size();i++){
Map<String,String> mapshow = new HashMap<String, String>();
mapshow.put("category", "1");
mapshow.put("name", zyryList.get(i).getQyjgmc());
mapshow.put("value", "11");
newTzrList.add(mapshow);
}
}
//主要人员对外投资节点展示信息
if(map.get("zyryDwtz") != null)
{
List zyryDwtzList = map.get("zyryDwtz");
for(int i=0;i<zyryDwtzList.size();i++){
Map<String,String> mapshow = new HashMap<String, String>();
mapshow.put("category", "6");
mapshow.put("name", ((Zyryjzxx)zyryDwtzList.toArray()[i]).getQyjgmc());
mapshow.put("value", "11");
newTzrList.add(mapshow);
}
}
//股东节点展示信息
if(map.get("gdxx")!=null)
{
List<FrkGsjTzrczxx> gdList = map.get("gdxx");
for(int i=0;i<gdList.size();i++){
Map<String,String> mapshow = new HashMap<String, String>();
mapshow.put("category", "3");
mapshow.put("name", gdList.get(i).getTzr()+" ");
mapshow.put("value", "11");
newTzrList.add(mapshow);
}
}
//自然人股东对外投资节点展示信息
if(map.get("zrrGdDwtz")!=null)
{
List<GdDwtzShowBean> zrrGdDwtzList = map.get("zrrGdDwtz");
for(int i=0;i<zrrGdDwtzList.size();i++){
Map<String,String> mapshow = new HashMap<String, String>();
mapshow.put("category", "4");
mapshow.put("name", zrrGdDwtzList.get(i).getQymc());
mapshow.put("value", "11");
newTzrList.add(mapshow);
}
}
//法人股东对外投资节点展示信息
if(map.get("frGdDwtz")!=null)
{
List<GdDwtzShowBean> frGdDwtzList = map.get("frGdDwtz");
for(int i=0;i<frGdDwtzList.size();i++){
Map<String,String> mapshow = new HashMap<String, String>();
mapshow.put("category", "4");
mapshow.put("name", frGdDwtzList.get(i).getQymc());
mapshow.put("value", "11");
newTzrList.add(mapshow);
}
}
return newTzrList;
}
/**
* <p>Method :execLink
* <p>Description : 获取关系展示Json串
*
* @param tzrjczList
* @return
*/
@SuppressWarnings("unchecked")
private List<Map<String,String>> execLink(Map<String, List> map){
List<Map<String,String>> newTzrList = new ArrayList<Map<String,String>>();
String qymc = "";
//根节点信息获取
if(map.get("qydjxx") != null)
{
List<FrkGsjQyjgdjxx> qydjList = map.get("qydjxx");
qymc = qydjList.get(0).getQyjgmc();
}
//企业对外投资
if(map.get("qydwtz") != null)
{
List<FrkGsjQyjgdjxx> fzjgxx = map.get("qydwtz");
List<FrkGsjQyjgdjxx> qydjList = map.get("qydjxx");
qymc = qydjList.get(0).getQyjgmc();
for(int i=0;i<fzjgxx.size();i++){
Map<String,String> mapshow = new HashMap<String, String>();
mapshow.put("source",qymc);
mapshow.put("target",fzjgxx.get(i).getQyjgmc() );
mapshow.put("weight", "2 ");
mapshow.put("name", "企业对外投资");
newTzrList.add(mapshow);
}
}
//股东关系展示信息
if(map.get("gdxx")!=null)
{
List<FrkGsjTzrczxx> gdList = map.get("gdxx");
for(int i=0;i<gdList.size();i++){
Map<String,String> mapshow = new HashMap<String, String>();
mapshow.put("source", gdList.get(i).getTzr()+" ");
mapshow.put("target", qymc);
mapshow.put("weight", "1");
mapshow.put("name", "股东");
newTzrList.add(mapshow);
}
}
//自然人股东对外投资关系展示信息
if(map.get("zrrGdDwtz")!=null)
{
List<GdDwtzShowBean> zrrGdDwtzList = map.get("zrrGdDwtz");
for(int i=0;i<zrrGdDwtzList.size();i++){
Map<String,String> mapshow = new HashMap<String, String>();
mapshow.put("source", zrrGdDwtzList.get(i).getTzr());
mapshow.put("target", zrrGdDwtzList.get(i).getQymc());
mapshow.put("weight", "1");
mapshow.put("name", "股东对外投资");
newTzrList.add(mapshow);
}
}
//法人股东对外投资关系展示信息
if(map.get("frGdDwtz")!=null)
{
List<GdDwtzShowBean> frGdDwtzList = map.get("frGdDwtz");
for(int i=0;i<frGdDwtzList.size();i++){
Map<String,String> mapshow = new HashMap<String, String>();
mapshow.put("source", frGdDwtzList.get(i).getTzr());
mapshow.put("target", frGdDwtzList.get(i).getQymc());
mapshow.put("weight", "1");
mapshow.put("name", "股东对外投资");
newTzrList.add(mapshow);
}
}
return newTzrList;
}
}
前台接收:
<%
String zch = request.getParameter("zch");
%>
<%@ page language="java" import="net.sf.json.JSONArray" %>
<%
String jsonDataNodes = String.valueOf(request.getAttribute("jsonDataNodes")).replace("[","");
JSONArray jsonDataLink = (JSONArray)request.getAttribute("jsonDataLink");
%>