Commit e2499407 authored by frank.xa.zhang's avatar frank.xa.zhang

add org chart demo -- frank

parent acf2892e
......@@ -40,10 +40,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import static pwc.taxtech.atms.common.CommonConstants.SystemError;
......@@ -649,20 +646,50 @@ public class OrganizationHKServiceImpl {
public OperationResultDto<List<OrgShareholderTreeDataDto>> getOrgTreeData(Long orgId) {
OperationResultDto<List<OrgShareholderTreeDataDto>> resultDto = new OperationResultDto<>();
List<OrgShareholderTreeDataDto> orgShareholderTreeDataDtos = new ArrayList<>();
List<ShareholderDto> shareholderDtos = organizationShareholderExtMapper.selectShareholder(orgId);
List<SubsidaryDto> subsidaryDtos = organizationShareholderExtMapper.selectSubsidary(orgId);
OrganizationHK organizationHK = organizationHKMapper.selectByPrimaryKey(orgId);
int i = 1;
List<Integer> parentIds = new ArrayList<>();
//todo: add shareholder nodes
for (ShareholderDto shareholderDto : shareholderDtos) {
OrgShareholderTreeDataDto orgShareholderTreeDataDto = new OrgShareholderTreeDataDto();
orgShareholderTreeDataDto.setId(i);
orgShareholderTreeDataDto.setName(shareholderDto.getEntityName());
orgShareholderTreeDataDto.setPercent(shareholderDto.getVotingPercentage());
orgShareholderTreeDataDto.setPid(shareholderDtos.size() + 1);
orgShareholderTreeDataDto.setSpids(Collections.emptyList());
orgShareholderTreeDataDtos.add(orgShareholderTreeDataDto);
if (i > 1) {
parentIds.add(i);
}
i++;
}
//todo: add organization node
OrgShareholderTreeDataDto treeDataDto = new OrgShareholderTreeDataDto();
treeDataDto.setId(i);
treeDataDto.setName(organizationHK.getName());
treeDataDto.setPercent("");
if(i>1) {
treeDataDto.setPid(1);
treeDataDto.setSpids(parentIds);
}
i++;
orgShareholderTreeDataDtos.add(treeDataDto);
//todo: add subsidary nodes
for (SubsidaryDto subsidaryDto : subsidaryDtos) {
OrgShareholderTreeDataDto orgShareholderTreeDataDto = new OrgShareholderTreeDataDto();
orgShareholderTreeDataDto.setId(i);
orgShareholderTreeDataDto.setName(subsidaryDto.getEntityName());
orgShareholderTreeDataDto.setPercent(subsidaryDto.getVotingPercentage());
orgShareholderTreeDataDto.setPid(0);
orgShareholderTreeDataDto.setSpids(Collections.emptyList());
orgShareholderTreeDataDtos.add(orgShareholderTreeDataDto);
i++;
}
resultDto.setResult(true);
resultDto.setData(orgShareholderTreeDataDtos);
return resultDto;
}
private OrgShareholderTreeDataDto buildShareTreeNode(ShareholderDto shareholderDto){
OrgShareholderTreeDataDto orgShareholderTreeDataDto = new OrgShareholderTreeDataDto();
orgShareholderTreeDataDto.setName(shareholderDto.getEntityName());
orgShareholderTreeDataDto.setPercent(shareholderDto.getVotingPercentage());
orgShareholderTreeDataDto.setLevel(1);
return orgShareholderTreeDataDto;
}
}
......@@ -10,8 +10,9 @@ import java.util.List;
@Setter
@ToString
public class OrgShareholderTreeDataDto {
Integer id;
String name;
Integer level;
String percent;
List<OrgShareholderTreeDataDto> children;
}
Integer pid;
List<Integer> spids;
}
\ No newline at end of file
......@@ -1370,12 +1370,12 @@
};
};
var initOrgTree = function () {
var initOrgTree = function (nodesCotent) {
OrgChart.templates.myTemplate = Object.assign({}, OrgChart.templates.ana);
OrgChart.templates.myTemplate.size = [200, 120];
OrgChart.templates.myTemplate.node = '<rect width="200" height="100" style="fill:rgb(35,143,159);stroke-width:3px;stroke:rgba(153,10,10,0.01)" />';
OrgChart.templates.myTemplate.field_0 = '<text style="font-size: 10px;" fill="#ffffff" x="100" y="90" text-anchor="middle">{val}</text>';
OrgChart.templates.myTemplate.field_0 = '<text style="font-size: 20px;" fill="#000" x="100" y="90" text-anchor="middle">{val}</text>';
OrgChart.templates.myTemplate.link = '<path stroke="#686868" stroke-width="1px" fill="none" link-id="[{id}][{child-id}]" d="M{xa},{ya} L{xb},{yb} {xc},{yc} {xd},{yd}" />';
// OrgChart.templates.myTemplate.secondlink = '<path stroke="#686868" stroke-width="1px" fill="none" link-id="[{id}][{child-id}]" d="M{xa},{ya} L{xb},{yb} {xc},{yc} {xd},{yd}" />';
OrgChart.templates.myTemplate.plus =
......@@ -1409,14 +1409,15 @@
// field_1: "title",
// img_0: "img"
},
nodes: [
{id: 4, name: "Amber McKenzie", percent: "100%"},
{id: 5, name: "Amber McKenzie", percent: "100%"},
{id: 6, name: "Amber McKenzie", percent: "100%"},
{id: 1, pid: 4, spids: [5, 6], name: "Amber McKenzie", percent: "100%"},
{id: 2, pid: 1, name: "Ava Field", percent: "100%"},
{id: 3, pid: 1, name: "Peter Stevens", percent: "100%"}
],
// nodes: [
// {id: 1, name: "Amber McKenzie", percent: "",spids:[]},
// {id: 2, name: "Amber McKenzie", percent: "100%"},
// {id: 3, name: "Amber McKenzie", percent: "100%"},
// {id: 4, pid: 1, spids: [2, 3], name: "Amber McKenzie", percent: "100%"},
// {id: 5, pid: 4, name: "Ava Field", percent: "100%"},
// {id: 6, pid: 5, name: "Peter Stevens", percent: "100%"}
// ],
nodes: nodesCotent,
onExportStart: exportStart,
onClick: click,
onRedraw: redraw,
......@@ -1431,20 +1432,34 @@
//第一次在加载时的元素
initialized = true;
}
var polygon = makeSVG('polygon', {"points": '100,0 0,100 200,100', style: "fill:lime;stroke:purple;stroke-width:1", height: 115, width: 250});
var ellipse = makeSVG('ellipse', {"cx": '100', "cy": "50", "rx": "100", "ry": "50", style: "fill:blue;stroke:purple;stroke-width:2", height: 115, width: 250});
if (middleNode.id > 0) {
var middleNodeSelector = "svg>g[node-id=" + middleNode.id + "]>rect";
var polygon = makeSVG('polygon', {"points": '100,0 0,100 200,100', style: "fill:#ffff;stroke:#000;stroke-width:1", height: 115, width: 250});
$(middleNodeSelector).css("fill", "transparent").css("stroke-width", 0).after(polygon);
}
// var ellipse = makeSVG('ellipse', {"cx": '100', "cy": "50", "rx": "100", "ry": "50", style: "fill:blue;stroke:purple;stroke-width:2", height: 115, width: 250});
// var ellipse1 = makeSVG('ellipse', {"cx": '100', "cy": "50", "rx": "100", "ry": "50", style: "fill:blue;stroke:purple;stroke-width:2", height: 115, width: 250});
// var ellipse2 = makeSVG('ellipse', {"cx": '100', "cy": "50", "rx": "100", "ry": "50", style: "fill:blue;stroke:purple;stroke-width:2", height: 115, width: 250});
$("svg>g[node-id=1]>rect").css("fill", "transparent").css("stroke-width", 0).after(polygon);
// $("svg>g[node-id=1]>rect").after(polygon);
$("svg>g[node-id=4]>rect").after(ellipse);
// $("svg>g[node-id=4]>rect").after(polygon);
// $("svg>g[node-id=4]>rect").after(ellipse);
// $("svg>g[node-id=5]>rect").after(ellipse1);
// $("svg>g[node-id=6]>rect").after(ellipse2);
// $("svg>g[node-id=5]").attr("transform","matrix(1, 0, 0, 1, 360, 0)");
// $("svg>g[node-id=6]").attr("transform","matrix(1, 0, 0, 1, 590, 0)");
$("svg>g[second-link-id='[1][5]']>path").attr("d", "M210,180 L210,160 L440,160 L440,102");
$("svg>g[second-link-id='[1][6]']>path").attr("d", "M210,180 L210,160 L660,160 L660,102");
if (middleNode.id > 2) {
var count = 0;
for (var i = middleNode.id; i > 1; i--) {
var nodeSelector = "svg>g[second-link-id=[" + middleNode.id + "][" + i + "]";
var value = 440 + 220 * count;
$(nodeSelector).attr("d", "M210,180 L210,160 L" + value + ",160 L" + value + ",102");
count++;
}
}
// $("svg>g[second-link-id='[4][2]']>path").attr("d", "M210,180 L210,160 L440,160 L440,102");
// $("svg>g[second-link-id='[4][3]']>path").attr("d", "M210,180 L210,160 L660,160 L660,102");
// d: path(" M240 180 L240 160 L680 160 L680 120");
};
......@@ -1471,8 +1486,26 @@
return false;
};
var middleNode;
$scope.showPage4 = function () {
initOrgTree();
//todo:get node content @ here
orgHKService.getOrgTreeData($scope.selectCompany.id).success(function (res) {
if (res && res.result) {
if (res.data.length < 3) {
if (res.data.length === 1) {
middleNode = res.data[0];
} else {
middleNode = res.data[1];
}
} else {
middleNode = _.find(res.data, function (node) {
return node.spids.length > 0;
});
}
initOrgTree(res.data);
}
});
};
(function initialize() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment