Browse Source

关系网

wangchuanjin 9 years ago
parent
commit
ccc751acd3

+ 28 - 23
core/src/qfw/yellowpage/yellowpagemanager.go

@@ -233,9 +233,9 @@ func (yp *Yellowpage) EnterpriseInfo(id string) error {
 			yp.T["res"] = info
 			regNo, _ := info["RegNo"].(string)
 			entName, _ := info["EntName"].(string)
-			relation, ok := getRelation(regNo, entName).(map[string]interface{})
+			relation, relflag := getRelation(regNo, entName)
 			var nodes *[]map[string]interface{}
-			if ok {
+			if relflag {
 				if d, err := json.Marshal(relation["nodes"]); err == nil && json.Unmarshal(d, &nodes) == nil && len(*nodes) > 0 {
 					//相关企业
 					var regNos []string
@@ -283,7 +283,7 @@ func (yp *Yellowpage) EnterpriseInfo(id string) error {
 			//服务列表第一页数据
 			yp.T["service"] = findServiceByEntId(id, 1, yp.Session())
 			//关系网数据
-			yp.T["relation"] = relation
+			yp.T["relflag"] = relflag
 			//著作权
 			yp.T["copyright"] = FindOne("enterprise_copyright", `{"EntId":"`+id+`"}`)
 
@@ -303,7 +303,7 @@ func (yp *Yellowpage) EnterpriseInfo(id string) error {
 				}
 			}
 			//过滤企业名
-			if ok && nodes != nil && len(*nodes) > 0 {
+			if relflag && nodes != nil && len(*nodes) > 0 {
 				go func() {
 					util.Try(func() {
 						if filterEntName(nodes) > 0 {
@@ -439,36 +439,41 @@ func isContainInQueryCache(querykey string, cache *list.List) bool {
 }
 
 func (yp *Yellowpage) GetRelation() error {
-	if util.IntAll(yp.GetSession("identWay")) == 1 {
+	var relation map[string]interface{}
+	var flag bool
+	//判断登录状态
+	if yp.GetSession("userType") != nil && util.IntAll(yp.GetSession("userType")) > 0 && util.IntAll(yp.GetSession("identWay")) == 1 {
 		regNo := yp.GetString("regNo")
 		entName := yp.GetString("entName")
-		if regNo == "" || entName == "" {
-			return nil
-		}
-		relation := getRelation(regNo, entName)
-		yp.ServeJson(M{"flag": true, "relation": relation})
-		r := relation.(map[string]interface{})
-		var links *[]map[string]interface{}
-		if d, err := json.Marshal(r["links"]); err == nil && json.Unmarshal(d, &links) == nil && len(*links) > 0 {
-			if !credit.AIsHasDo(credit.A_CKGXW, util.IntAll(yp.GetSession("credit_a"))) {
+		if regNo != "" && entName != "" {
+			relation, flag = getRelation(regNo, entName)
+			if flag && !credit.AIsHasDo(credit.A_CKGXW, util.IntAll(yp.GetSession("credit_a"))) {
 				credit.UpuserCreditSession(yp.GetSession("userId").(string), credit.A_CKGXW, "A", nil, yp.Action)
 			}
 		}
-	} else {
-		yp.ServeJson(M{"flag": false})
 	}
+	yp.ServeJson(M{"flag": flag, "relation": relation})
 	return nil
 }
-func getRelation(regNo, entName string) interface{} {
+func getRelation(regNo, entName string) (r map[string]interface{}, ok bool) {
 	if regNo == "" || entName == "" {
-		return nil
+		return
 	}
-	relation := redis.Get("enterprise", "relation-"+regNo)
-	if relation == nil {
-		relation = makeRelation(regNo, entName)
-		redis.Put("enterprise", "relation-"+regNo, relation, 7*ONEDAY)
+	rel := redis.Get("enterprise", "relation-"+regNo)
+	if rel == nil {
+		rel = makeRelation(regNo, entName)
+		redis.Put("enterprise", "relation-"+regNo, rel, 7*ONEDAY)
+	}
+	var flag bool
+	if r, flag = rel.(map[string]interface{}); flag {
+		var links *[]map[string]interface{}
+		if d, err := json.Marshal(r["links"]); err == nil && json.Unmarshal(d, &links) == nil && len(*links) > 0 {
+			ok = true
+		}
+	} else {
+		ok = false
 	}
-	return relation
+	return
 }
 
 //生成图用的结果

+ 5 - 3
core/src/web/staticres/css/entcommunity.css

@@ -656,7 +656,6 @@ a:focus, a:hover{
 	position: absolute;
 	z-index: 2;
 	right: 0px;
-	width: 91px;
 }
 .entrelation .entrelation-controlls-fullscreen{
 	top: 15px;
@@ -665,7 +664,6 @@ a:focus, a:hover{
 .entrelation .entrelation-controlls>div{
 	margin-bottom: 10px;
 	margin-left: 10px;
-	display: inline-block;
 	width: 35px;
 	height: 35px;
 	box-shadow: 0px 0px 5px #DADADA;
@@ -680,10 +678,11 @@ a:focus, a:hover{
 	cursor: pointer;
 	vertical-align: top;
 	border-radius: 3px;
+	color: #16a086;
 	
 }
 .entrelation .entrelation-controlls .entrelation-box.checked{
-	color: #16a086;
+	display: none;
 }
 :-moz-full-screen .entrelation,:-webkit-full-screen .entrelation,:-o-full-screen .entrelation,
 :-ms-full-screen .entrelation,:fullscreen .entrelation,:-ms-fullscreen .entrelation,:full-screen .entrelation{
@@ -1005,4 +1004,7 @@ a:focus, a:hover{
 	background-color: #16a086;
 	margin-left: 5px;
 	color: #ffffff;
+}
+.entinfo-page .badge.disabled{
+	background-color: #a0a0a0;
 }

+ 37 - 45
core/src/web/staticres/js/entportrait.js

@@ -5,8 +5,8 @@ var servicePaging = null;//服务列表
 var staffinfoEntity = null;//主要人员
 var dishonestyPaging = null;//失信
 var hasLoadPagingJs = false;//是否已经加载过js
-var relationFlag = false;//关系网标识
 var identWayFlag = false;//认证状态
+var relationFlag = false;
 var staffinfoFlag = false;
 /**************著作权**************/
 var copyrightFlag = false;
@@ -50,12 +50,20 @@ $(function(){
 			copyrightCount += patent.length;
 		}
 		$("#ent-tab-copyright").text(copyrightCount);
+	}else{
+		$("#ent-tab-copyright").addClass("disabled");
 	}
 	//显示失信数量
-	$("#ent-tab-dishonesty").text(dishonesty.count);
-	//显示失信数量
+	if(dishonesty.count > 0){
+		$("#ent-tab-dishonesty").text(dishonesty.count);
+	}else{
+		$("#ent-tab-dishonesty").addClass("disabled");
+	}
+	//显示变更数量
 	if(staffinfoFlag){
 		$("#ent-tab-staffinfo").text(staffinfo.length);
+	}else{
+		$("#ent-tab-staffinfo").addClass("disabled");
 	}
 	//联系地址
 	if($address){
@@ -104,7 +112,7 @@ $(function(){
 			}
 		}
 		if(index == 1){
-			b_afterLogin();
+			b_afterLogin(isLogined);
 		}else if($(this).index() == 2 && staffinfoEntity == null){
 			//加载服务列表
 			staffinfoEntity = new StaffinfoEntity();
@@ -148,8 +156,8 @@ function b_afterLogin(flag,result){
 	if(typeof(result) != "undefined"){
 		identWayFlag = result.identWay == 1;
 	}
-	identWayFlag = true;//暂时把认证权限放开
-	relationFlag = flag && identWayFlag && (relation == null || typeof(relation) == "undefined" || typeof(relation.links) == "undefined" || relation.links == null || relation.links.length == 0 || typeof(relation.nodes) == "undefined" || relation.nodes == null || relation.nodes.length <= 1);
+	//identWayFlag = true;//暂时把认证权限放开
+	relationFlag = flag && identWayFlag && !relFlag;
 	if(!$(".ent-tab>li:eq(1)").hasClass("ent-active") && relationFlag){
 		$(".ent-tab>li:eq(1)").addClass("disabled");
 	}
@@ -174,16 +182,30 @@ function initRelation(){
 				relationNoData();
 			}else{
 				$("#entrelation-limit,#entrelation-nologin").addClass("hide");
-				$(".entrelation").height($(".ent-tab-content").height());
-				loadJS(cdn+"/js/d3.v3.min.js",function(){
-					loadJS(cdn+"/js/geometry.js",function(){
-						loadJS(cdn+"/js/provinceData.min.js",function(){
-							loadJS(cdn+"/js/relation.js",function(){
-								relationEntity = new Relation(legcerNo,regNo,regCapCurName,relation);
-								relationEntity.init();
+				$.ajax({
+					url: "/member/getRelation",
+					method: "post",
+					data: {regNo:regNo,entName:entName},
+					success: function(r){
+						if(!r || !r.flag || !r.relation || !r.relation.links || r.relation.links.length == 0 || !r.relation.nodes || r.relation.nodes.length <= 1){
+							relationNoData();
+						}else{
+							$(".entrelation").height($(".ent-tab-content").height());
+							loadJS(cdn+"/js/d3.v3.min.js",function(){
+								loadJS(cdn+"/js/geometry.js",function(){
+									loadJS(cdn+"/js/provinceData.min.js",function(){
+										loadJS(cdn+"/js/relation.js",function(){
+											relationEntity = new Relation(legcerNo,regNo,regCapCurName,r.relation);
+											relationEntity.init();
+										});
+									});
+								});
 							});
-						});
-					});
+						}
+					},
+					error: function(){
+						relationNoData();
+					}
 				});
 			}
 		}else{
@@ -191,36 +213,6 @@ function initRelation(){
 			$("#entrelation-limit,#entrelation-noauthe").removeClass("hide");
 			$("#entrelation-infovis").hide();
 		}
-		/*$.ajax({
-			url: "/member/getRelation",
-			method: "post",
-			data: {regNo:regNo,entName:entName},
-			success: function(r){
-				if(r.flag == false){
-					$("#entrelation-nologin").addClass("hide");
-					$("#entrelation-limit,#entrelation-noauthe").removeClass("hide");
-					$("#entrelation-infovis").hide();
-				}else if(r.flag == true && (r == null || typeof(r) == "undefined" || typeof(r.relation.links) == "undefined" || r.relation.links.length == 0 || typeof(r.relation.nodes) == "undefined" || r.relation.nodes.length <= 1)){
-					relationNoData();
-				}else if(r.flag == true){
-					$("#entrelation-limit,#entrelation-nologin").addClass("hide");
-					$(".entrelation").height(500);
-					loadJS("/js/d3.v3.min.js",function(){
-						loadJS("/js/geometry.js",function(){
-							loadJS("/js/relation.js",function(){
-								relationEntity = new Relation(legcerNo,regNo,regCapCurName,r.relation);
-								relationEntity.init();
-							});
-						});
-					});
-				}else{
-					relationNoData();
-				}
-			},
-			error: function(){
-				relationNoData();
-			}
-		});*/
 	}else{
 		$("#entrelation-limit,#entrelation-nologin").removeClass("hide");
 	}

+ 37 - 36
core/src/web/staticres/js/relation.js

@@ -4,6 +4,7 @@ function Relation(legcerNo,regNo,regCapCurName,data){
 	this.regCapCurName = regCapCurName;
 	this.data = data;
 	this.modleFlag = data.nodes.length>15;
+	this.ispattern = this.modleFlag;
 	this.zoomlevel = 1;
 	this.w = 0;
 	this.h = 0;
@@ -25,8 +26,10 @@ Relation.prototype.init = function(){
 	var thisClass = this;
 	thisClass.w = $("#entrelation").width();
 	thisClass.h = $("#entrelation").height();
+	thisClass.centerNodeX = thisClass.w / 2;
+	thisClass.centerNodeY = thisClass.h / 2 + 5;
 	$("#entrelation-infovis").width(thisClass.w).append(
-		'<div class="entrelation-controlls hidden-sm">'
+		'<div class="entrelation-controlls">'
 		+'<div id="entrelation-pattern" class="entrelation-box'+(thisClass.modleFlag?' checked':'')+'" title="一般模式"><span class="glyphicon yibanmoshi"></span></div>'
 		+'<div id="entrelation-verbosemode" class="entrelation-box'+(thisClass.modleFlag?'':' checked')+'" title="详细模式"><span class="glyphicon xiangximoshi"></span></div>'
 		+'<div id="entrelation-restore" class="entrelation-box checked" title="退出"><span class="glyphicon suofang"></span></div>'
@@ -35,20 +38,14 @@ Relation.prototype.init = function(){
 	);
 	//一般模式
 	$("#entrelation-pattern").click(function(){
-		if($(this).hasClass("checked")){
-			return;
-		}
-		$("#entrelation-verbosemode").removeClass("checked");
-		$(this).addClass("checked");
+		$(this).hide();
+		$("#entrelation-verbosemode").show();
 		thisClass.pattern();
 	});
 	//详细模式
 	$("#entrelation-verbosemode").click(function(){
-		if($(this).hasClass("checked")){
-			return;
-		}
-		$("#entrelation-pattern").removeClass("checked");
-		$(this).addClass("checked");
+		$(this).hide();
+		$("#entrelation-pattern").show();
 		thisClass.verbosemode();
 	});
 	//全屏
@@ -83,13 +80,13 @@ Relation.prototype.init = function(){
 			thisClass.cancelFullScreen();
 		}
     };
-	$(window).resize(function(){
+	/*$(window).resize(function(){
 		if(!thisClass.redrawflag){
 		    //1秒后重绘
 			thisClass.redrawflag=true;
 			setTimeout(thisClass.redraw,1000);
 		}
-	});
+	});*/
 	if(document.getElementById("entrelation-infovis")){
 		document.getElementById("entrelation-infovis").oncontextmenu=function(){return false;};
 	}
@@ -141,8 +138,14 @@ Relation.prototype.verbosemode = function(){
 	this.modleFlag = false;
 	this.makeTextBg();
 	this.makeTitle();
-	this.tick();
-	this.force.tick();
+	if(this.ispattern){
+		this.tickFlag = true;
+		this.force.linkDistance(Math.floor(Math.random()*60)+150).start();
+	}else{
+		this.tick();
+		this.force.tick();
+	}
+	this.ispattern = false;
 }
 Relation.prototype.dataProcess = function(){
 	var reg = new RegExp(/(有限公司|有限责任公司|股份有限公司|总公司|分公司|公司|事务所|合伙企业)$|\(.*\)|\(.*\)/g);
@@ -408,13 +411,14 @@ Relation.prototype.launchFullScreen = function(element) {
   	}
 }
 Relation.prototype.cancelFullScreen = function(){
-	this.h = $("#entrelation-infovis").height();  
-	//$("#entrelation-fullscreen").text("全屏").attr("title","进入全屏视图"+((!!window.ActiveXObject || "ActiveXObject" in window)?"":" (F11)"));	
-	//force.linkDistance(120).charge(-200).size([w,h]).resume();
+	this.centerNodeX = this.w / 2;
+	this.centerNodeY = this.h / 2 + 5;
 	$("#entrelation-infovis").css({width:this.w,height:this.h});
 	//设置svg标签的宽度与高度
 	d3.select("svg").attr("width", this.w).attr("height", this.h);
 	$(".entrelation-controlls").removeClass("entrelation-controlls-fullscreen");
+	this.tickFlag = true;
+	this.force.resume();
     if(document.exitFullscreen) {
       document.exitFullscreen();
     } else if (document.msExitFullscreen) {
@@ -445,15 +449,14 @@ Relation.prototype.initFullScreen = function(){
 				//重绘
 				var w=document.body.clientWidth;
 				var h=document.body.clientHeight;
-				//if(w>1200){
-					//w= 1200
-				//}
+				thisClass.centerNodeX = w / 2;
+				thisClass.centerNodeY = h / 2 + 5;
 				$("#entrelation-infovis").css({width:w,height:h});
 				d3.select("svg").attr("width", w).attr("height", h);
 				$(".entrelation-controlls").addClass("entrelation-controlls-fullscreen");
-				thisClass.force.linkDistance(h).charge(-700).size([w,h]).resume();
+				thisClass.tickFlag = true;
+				thisClass.force.start();
 			}
-			
 		},timeout);
 	}else{
 		this.cancelFullScreen();
@@ -611,8 +614,12 @@ Relation.prototype.makeRelation = function(){
 	    .nodes(this.data.nodes)
 	    .links(this.data.links)
 	    .size([this.w, this.h])
-	    .linkDistance(function(p){
-			return Math.floor(Math.random()*60)+90;
+	    .linkDistance(function(){
+			var distance = Math.floor(Math.random()*60)+100;
+			if(!this.ispattern){
+				distance += 50;
+			}
+			return distance;
 		})
 		.chargeDistance(600)
 	    .charge(this.chargeVal)
@@ -676,6 +683,7 @@ Relation.prototype.makeRelation = function(){
 		.attr("y", "0")
 		.append("textPath")
 		.attr("class", "textpath")
+		.attr("text-anchor", "middle")
 		.attr("id", function(d) { 
 			return 'text'+d.nodeId;
 		})
@@ -683,19 +691,16 @@ Relation.prototype.makeRelation = function(){
 			return '#'+d.nodeId;
 		})
 		.text(function(d) { 
-			var invacconam = new Number(d.invacconam);
+			var invacconam = parseInt(d.invacconam);
 			if(invacconam > 0){
-				var lenInvacconam = (invacconam + "").length;
-				if(lenInvacconam > 4 && (invacconam + "").indexOf(".") > -1 && (lenInvacconam - (invacconam + "").indexOf(".")) > 4){
-					invacconam = (new Number(invacconam)).toFixed(4);
-				}
-				return invacconam+"万元";
+				return invacconam;
 			}else{
 				return "";
 			}
 		})
+		.style("font-size", "12px")
 		.style("fill", "#4e5051")
-		.attr("startOffset", "20%")
+		.attr("startOffset", "24%")
 		.style("display", this.modleFlag?"none":"block");
 	
 	this.lines.each(function (d,i){
@@ -859,10 +864,6 @@ Relation.prototype.makeTextBg = function(){
         bounds.y2 += padding.top  + padding.bottom;
 		
 		var width = bounds.x2 - bounds.x1;
-		if(d.type == "ce"){
-			thisClass.centerNodeX = thisClass.w / 2;
-			thisClass.centerNodeY = thisClass.h / 2 + 5;
-		}
 		var height = bounds.y2 - bounds.y1;
         node.select('rect')
             .attr('x', bounds.x1)

+ 4 - 4
core/src/web/templates/yellowpage/enterpriseinfo.html

@@ -122,7 +122,7 @@
 		<li><div class="b-com-border-top"></div>关系网</li>
 		<li{{if not .T.res.staffinfo}} class="disabled"{{end}}><div class="b-com-border-top"></div>主要人员<front class="badge" id="ent-tab-staffinfo">0</front></li>
 		<li{{if and (not .T.copyright.WorkCopyRight) (not .T.copyright.ComputerSoftCopyRight) (not .T.copyright.Patent)}} class="disabled"{{end}}><div class="b-com-border-top"></div>著作权<front class="badge" id="ent-tab-copyright">0</front></li>
-		<li{{if not .T.res.alterInfo}} class="disabled"{{end}}><div class="b-com-border-top"></div>变更信息<front class="badge">{{if .T.res.alterInfo}}{{len .T.res.alterInfo}}{{else}}0{{end}}</front></li>
+		<li{{if not .T.res.alterInfo}} class="disabled"{{end}}><div class="b-com-border-top"></div>变更信息<front class="badge{{if .T.res.alterInfo}}{{if eq (len .T.res.alterInfo) 0}} disabled{{end}}{{else}} disabled{{end}}">{{if .T.res.alterInfo}}{{len .T.res.alterInfo}}{{else}}0{{end}}</front></li>
 		<li{{if not .T.dishonesty.count}} class="disabled"{{end}}><div class="b-com-border-top"></div>失信信息<front class="badge" id="ent-tab-dishonesty">0</front></li>
 		<li class="{{if and (not .T.service.count) (not .T.res.s_synopsis)}}disabled {{end}}border-r-0"><div class="b-com-border-top"></div>{{if eq .T.res.s_action "01"}}企业{{else if eq .T.res.s_action "02"}}商家{{else if eq .T.res.s_action "03"}}机构{{else}}企业{{end}}黄页</li>
 	</ul>
@@ -304,7 +304,7 @@
 			<div id="entrelation-limit" class="hide entrelation-limit">
 				<div id="entrelation-nologin" class="hide text-center">
 					<img src="{{Msg "seo" "cdn"}}/images/findnull.png" class="b-findnull">
-					<h5>扫码登录认证后,即可查看企业股东信息,投资关系,公司关系脉络图等内容</h5>
+					<h5>扫码登录后,即可查看企业股东信息,投资关系,公司关系脉络图等内容</h5>
 					<button class="btn btn-primary" onclick="loginModalShow();">扫码登录</button>
 				</div>
 				<div id="entrelation-noauthe" class="hide text-center">
@@ -334,7 +334,7 @@
 				<div class="b-com-title">
 					<span><span class="bootstrap-glyphicon glyphicon-menu-right"></span></span>计算机软件著作权信息<front class="badge">0</front>
 				</div>
-				<table class="tabl<!--著作权-->e ent-table">
+				<table class="table ent-table">
 					<tr>
 						<td class="text-center" id="computerSoftCopyRightListPaging"></td>
 					</tr>
@@ -535,7 +535,7 @@ var gs = {{.T.res.gs}};
 var investor = {{.T.res.investor}};
 var OpScope = {{.T.res.OpScope}};
 var service = {{.T.service}};
-var relation = {{.T.relation}};
+var relFlag = {{.T.relflag}};
 var copyright = {{.T.copyright}};
 //联系地址
 //定义默认的郑州经纬度