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

fixed shareholder structure -- frank

parent cc4dccc8
......@@ -202,4 +202,10 @@ public class OrganizationHKController {
return organizationHKService.deleteDirector(id);
}
@RequestMapping(value = "getAllOrgTreeData",method = RequestMethod.GET)
public OperationResultDto<List<OrgShareholderTreeDataDto>> getAllOrgTreeData(){
logger.info("POST /api/v1/orgHK/getAllOrgTreeData");
return organizationHKService.getAllOrgTreeData();
}
}
......@@ -726,4 +726,57 @@ public class OrganizationHKServiceImpl {
resultDto.setResult(true);
return resultDto;
}
public OperationResultDto<List<OrgShareholderTreeDataDto>> getAllOrgTreeData() {
OperationResultDto<List<OrgShareholderTreeDataDto>> resultDto = new OperationResultDto<>();
List<OrgShareholderTreeDto> orgShareholderTreeDtos = organizationShareholderExtMapper.selectOrgShareholderTreeDto();
List<OrgShareholderTreeDataDto> orgShareholderTreeDataDtos = new ArrayList<>();
int id = 1;
for (OrgShareholderTreeDto orgShareholderTreeDto : orgShareholderTreeDtos) {
OrgShareholderTreeDataDto orgNode;
if (orgShareholderTreeDataDtos.stream().noneMatch(b -> b.getOrgId().equals(orgShareholderTreeDto.getOrgId()))) {
orgNode = new OrgShareholderTreeDataDto();
orgNode.setId(id++);
orgNode.setOrgId(orgShareholderTreeDto.getOrgId());
orgNode.setName(orgShareholderTreeDto.getOrgName());
orgShareholderTreeDataDtos.add(orgNode);
} else {
orgNode = orgShareholderTreeDataDtos.stream().filter(e -> e.getOrgId().equals(orgShareholderTreeDto.getOrgId())).findFirst().get();
}
OrgShareholderTreeDataDto investNode;
if (orgShareholderTreeDto.getInvestId() != null) {
if (orgShareholderTreeDataDtos.stream().noneMatch(c -> c.getOrgId().equals(orgShareholderTreeDto.getInvestId()))) {
investNode = new OrgShareholderTreeDataDto();
investNode.setId(id++);
investNode.setOrgId(orgShareholderTreeDto.getInvestId());
investNode.setName(orgShareholderTreeDto.getInvestName());
investNode.setPercent(orgShareholderTreeDto.getPercent());
orgShareholderTreeDataDtos.add(investNode);
} else {
investNode = orgShareholderTreeDataDtos.stream().filter(f -> f.getOrgId().equals(orgShareholderTreeDto.getInvestId())).findFirst().get();
investNode.setPercent(orgShareholderTreeDto.getPercent());
}
if (orgNode.getPid() == null) {
orgNode.setPid(investNode.getId());
} else {
List<Integer> spids;
if (orgNode.getSpids() == null) {
spids = new ArrayList<>();
} else {
spids = orgNode.getSpids();
}
spids.add(investNode.getId());
orgNode.setSpids(spids);
}
}
}
resultDto.setData(orgShareholderTreeDataDtos);
resultDto.setResult(true);
return resultDto;
}
}
......@@ -3,6 +3,7 @@ package pwc.taxtech.atms.organization.dao.extension;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.organization.dpo.OrgShareholderTreeDto;
import pwc.taxtech.atms.organization.dpo.ShareholderDto;
import pwc.taxtech.atms.organization.dpo.SubsidaryDto;
......@@ -16,4 +17,21 @@ public interface OrganizationShareholderExtMapper extends MyMapper {
@Select("select a.id, a.entity_id as entityId,b.name as entityName,a.voting_percentage as votingPercentage from organization_shareholder a left join organization b on a.entity_id=b.id where investment_entity_id=#{id} and a.is_delete=0")
List<SubsidaryDto> selectSubsidary(Long entityId);
@Select("select\n" +
" c.id orgId,\n" +
" c.name orgName,\n" +
" c.investId,\n" +
" d.name investName,\n" +
" c.voting_percentage percent\n" +
"from\n" +
" (select\n" +
" a.id,\n" +
" a.name,\n" +
" b.investment_entity_id investId,\n" +
" b.voting_percentage\n" +
" from organization a left join organization_shareholder b on a.id = b.entity_id\n" +
" where a.is_active = 1 and (b.is_delete = 0 or b.is_delete is null)) c left join (select *\n" +
" from organization) d on c.investId = d.id")
List<OrgShareholderTreeDto> selectOrgShareholderTreeDto();
}
......@@ -16,4 +16,5 @@ public class OrgShareholderTreeDataDto {
Integer pid;
List<Integer> spids;
Boolean isMiddleNode;
Long orgId;
}
\ No newline at end of file
package pwc.taxtech.atms.organization.dpo;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class OrgShareholderTreeDto {
Long orgId;
String orgName;
Long investId;
String investName;
String percent;
}
infrastructureModule.controller('organizationFullChartController', ['$scope','$log','$timeout', function ($scope,$log,$timeout) {
infrastructureModule.controller('organizationFullChartController', ['$scope', '$log', '$timeout', 'orgHKService', function ($scope, $log, $timeout, orgHKService) {
'use strict';
(function initialize() {
$log.debug('organizationFullChartController.ctor()...');
var initOrgTree = function (nodesCotent) {
console.log("nodesContent", 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:#ffff;stroke:#000;stroke-width:1px" />';
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="#000" 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="#000" 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 =
'<rect x="0" y="0" width="36" height="36" rx="12" ry="12" fill="#2E2E2E" stroke="#aeaeae" stroke-width="1"></rect>'
+ '<line x1="4" y1="18" x2="32" y2="18" stroke-width="1" stroke="#aeaeae"></line>'
+ '<line x1="18" y1="4" x2="18" y2="32" stroke-width= "1" stroke="#aeaeae"></line>';
OrgChart.templates.myTemplate.minus =
'<rect x="0" y="0" width="36" height="36" rx="12" ry="12" fill="#2E2E2E" stroke="#aeaeae" stroke-width="1"></rect>'
+ '<line x1="4" y1="18" x2="32" y2="18" stroke-width="1" stroke="#aeaeae"></line>';
$scope.chart = new OrgChart(document.getElementById("tree"), {
template: "ana",
template: "myTemplate",
enableSearch: false,
// nodeMenu: {
// add: {text: "Add"},
// edit: {text: "Edit"},
// remove: {text: "Remove"}
// },
// menu: {
// pdf: {text: "Export PDF"},
// png: {text: "Export PNG"},
// svg: {text: "Export SVG"},
// csv: {text: "Export CSV"}
// },
menu: {
png: {text: "Export PNG"}
},
linkBinding: {
link_field_0: "percent"
},
nodeBinding: {
field_0: "name"
// field_1: "title",
// img_0: "img"
},
nodes: [
{id: 4, name: "Amber McKenzie", title: "CEO", img: "//balkangraph.com/js/img/1.jpg", percent: "100%"},
{id: 5, name: "Amber McKenzie", title: "CEO", img: "//balkangraph.com/js/img/1.jpg", percent: "100%"},
{id: 6, name: "Amber McKenzie", title: "CEO", img: "//balkangraph.com/js/img/1.jpg", percent: "100%"},
{id: 1, pid: 4, spids: [5, 6], name: "Amber McKenzie", title: "CEO", img: "//balkangraph.com/js/img/1.jpg", percent: "100%"},
{id: 2, pid: 1, name: "Ava Field", title: "IT Manager", img: "//balkangraph.com/js/img/2.jpg", mobile: "0878108255", percent: "100%"},
{id: 3, pid: 1, name: "Peter Stevens", title: "HR Manager", img: "//balkangraph.com/js/img/3.jpg", percent: "100%"}
],
// onExportStart: exportStart
// nodes: [
// {id: 5, pid: 4, name: "Subsidary1", percent: "100%"},
// {id: 6, pid: 4, name: "Subsidary2", percent: "100%"},
// {id: 1, name: "Shareholder1", percent: "100%", spids: []},
// {id: 2, name: "Shareholder2", percent: "100%"},
// {id: 3, name: "Shareholder3", percent: "100%"},
// {id: 4, pid: 1, spids: [2, 3], name: "Comapny", percent: ""}
//
// ],
nodes: nodesCotent,
onExportStart: exportStart,
onClick: click,
onRedraw: redraw,
mouseScrool: OrgChart.action.none
});
};
var initialized = false;
var redraw = function () {
if (!initialized) {
//第一次在加载时的元素
initialized = true;
}
//处理多父级
var spidNode = _.filter(nodesCotentValue, function (item) {
return item.spids && item.spids.length > 0;
});
$scope.showIt = false;
$timeout(function () {
// $("#divA").css("display","block");
$scope.showIt = true;
$scope.showIt = true;
},10*1000);
for (var i = 0; i < spidNode.length; i++) {
var node = spidNode[i];
for (var j = 0; j < node.spids.length; j++) {
//连接线
var secondLinkSelector = "svg>g[second-link-id='[" + node.id + "][" + node.spids[j] + "]']";
var dString = $(secondLinkSelector + ">path").attr("d");
var numbers = dString.match(/\d+/g).map(Number);
numbers[0] = numbers[0] - 30;
numbers[2] = numbers[2] - 30;
numbers[4] = numbers[4] - 30;
numbers[6] = numbers[6] - 30;
numbers[7] = numbers[7] - 20;
var template = "M{0},{1} L{2},{3} L{4},{5} L{6},{7}";
var dStringR = template.formatWithArgs(numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], numbers[6], numbers[7]);
$(secondLinkSelector + ">path").attr("d", dStringR);
$(secondLinkSelector + ">path").attr("stroke", "#000");
//百分数
var percent = _.find(nodesCotentValue, function (item) {
return item.id === node.spids[j];
}).percent;
var dStr = $(secondLinkSelector + ">path").attr("d");
var numbers = dStr.match(/\d+/g).map(Number);
var x = numbers[6] - 20;
var y = numbers[7] + 30;
var g = makeSVG('g', {"transform": "matrix(1,0,0,1," + x + "," + y + ") rotate(0)"});
var rateText = makeSVG('text', {"text-anchor": "middle", "fill": "#aeaeae", "width": "290", "x": "0", "y": "0", "style": "font-size:10px"});
$(secondLinkSelector + ">path").after(g);
$(secondLinkSelector + ">g").append(rateText);
$(secondLinkSelector + ">g>text").text(percent + "%");
}
}
//处理直接父级节点
var pidNodes = _.filter(nodesCotentValue, function (item) {
return item.pid && item.pid > 0;
});
for (var i = 0; i < pidNodes.length; i++) {
var node = pidNodes[i];
var id = node.id;
var pid = node.pid;
var percent = _.find(nodesCotentValue, function (item) {
return item.id === pid;
}).percent;
var linkSelector = "svg>g[link-id='[" + pid + "][" + id + "]']";
var transformStr = $(linkSelector + ">g").attr("transform");
if (transformStr) {
console.log("transformStr", transformStr);
var numbers = transformStr.match(/\d+/g).map(Number);
console.log("numbers", numbers);
numbers[4] = numbers[4] - 20;
var template = "matrix({0},{1},{2},{3},{4},{5}) rotate({6})";
var transformStrR = template.formatWithArgs(numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], numbers[6]);
console.log("transformStrR", transformStrR);
$(linkSelector + ">g").attr("transform", transformStrR);
}
else {
var dStr = $(linkSelector + ">path").attr("d");
var numbers = dStr.match(/\d+/g).map(Number);
var x = numbers[6] - 20;
var y = numbers[7] - 15;
var g = makeSVG('g', {"transform": "matrix(1,0,0,1," + x + "," + y + ") rotate(0)"});
var rateText = makeSVG('text', {"text-anchor": "middle", "fill": "#aeaeae", "width": "290", "x": "0", "y": "0", "style": "font-size:10px"});
$(linkSelector + ">path").after(g);
$(linkSelector + ">g").append(rateText);
}
$(linkSelector + ">g>text").text(percent + "%");
}
// nodesCotentValue = [
// {id: 5, pid: 4, name: "Subsidary1", percent: "100%"},
// {id: 6, pid: 4, name: "Subsidary2", percent: "100%"},
// {id: 1, name: "Shareholder1", percent: "100%", spids: []},
// {id: 2, name: "Shareholder2", percent: "100%"},
// {id: 3, name: "Shareholder3", percent: "100%"},
// {id: 4, pid: 1, spids: [2, 3], name: "Comapny", percent: ""}
// ];
// middleNode = {id: 4, pid: 1, spids: [2, 3], name: "Comapny", percent: "100%"};
// if (middleNode && middleNode.id > 0) {
// //check if there are more than 1 sub node,need change x coordinate
// var subNodes = _.filter(nodesCotentValue, function (item) {
// return item.id > middleNode.id;
// });
//
// var beforeNodes = _.filter(nodesCotentValue, function (item) {
// return item.id < middleNode.id;
// });
// var haveMoreThanOneNode = false;
// if (subNodes.length > 1) {
// haveMoreThanOneNode = true;
// }
//
// var y = beforeNodes.length > 0 && subNodes.length > 0 ? 346 : 166;
// for (var iii = 0; iii < subNodes.length; iii++) {
// var value = 80 + 220 * iii;
// var nodeSelector = "svg>g[link-id='[" + middleNode.id + "][" + subNodes[iii].id + "]']";
// $(nodeSelector + ">g").attr("transform", "matrix(1,0,0,1," + value + "," + y + ") rotate(0)");
// $(nodeSelector + ">g>text").text(subNodes[iii].percent + "%");
// }
//
// 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 node = _.find(nodesCotentValue, function (item) {
// return item.id === 1;
// });
// var linkSelector = "svg>g[link-id='[1][" + middleNode.id + "]']";
// var linkXValue = 80;
// if (haveMoreThanOneNode) {
// linkXValue = linkXValue + 110;
// }
//
// $(linkSelector + ">g").attr("transform", "matrix(1,0,0,1," + linkXValue + ",166) rotate(0)");
// var linkSelectorG = linkSelector + ">g";
// var linkSelectorGText = linkSelectorG + ">text";
// $(linkSelectorGText).text(node.percent + "%");
// if (middleNode.id > 2) {
// var count = 0;
// for (var i = 2; i < middleNode.id; i++) {
// var subNode = _.find(nodesCotentValue, function (item) {
// return item.id === i;
// });
// var nodeSelector = "svg>g[second-link-id='[" + middleNode.id + "][" + i + "]']";
// var value = 0;
// var value2 = 0;
// if (haveMoreThanOneNode) {
// value = 320 + 110 + 220 * count;
// value2 = 100 + 110;
// } else {
// value = 320 + 220 * count;
// value2 = 100;
// }
// $(nodeSelector + ">path").attr("stroke", "#000");
// $(nodeSelector + ">path").attr("d", "M" + value2 + ",180 L" + value2 + ",160 L" + value + ",160 L" + value + ",102");
// count++;
// var val2 = value - 20;
// var rateG = makeSVG('g', {"transform": "matrix(1,0,0,1," + val2 + ",128) rotate(0)"});
// $(nodeSelector + ">path").after(rateG);
// var nodeSelectorG = nodeSelector + ">g";
// var rateText = makeSVG('text', {"text-anchor": "middle", "fill": "#aeaeae", "width": "290", "x": "0", "y": "0", "style": "font-size:10px"});
// $(nodeSelectorG).append(rateText);
// var nodeSelectorGText = nodeSelectorG + ">text";
// $(nodeSelectorGText).text(subNode.percent + "%");
// }
// }
// }
};
var makeSVG = function (tag, attrs) {
var el = document.createElementNS('http://www.w3.org/2000/svg', tag);
for (var k in attrs)
el.setAttribute(k, attrs[k]);
return el;
};
var exportStart = function (sender, options, svg) {
var svg = $('svg')[0].outerHTML;
console.log("svg", svg);
canvg(document.getElementById('canvas'), svg);
var canvas = document.getElementById("canvas");
var a = document.createElement("a");
a.download = "OrgChart.png";
a.href = canvas.toDataURL("image/png");
a.click();
return false;
};
var click = function (sender, node) {
return false;
};
var nodesCotentValue;
var initOrgChart = function () {
orgHKService.getAllOrgTreeData().success(function (res) {
if (res && res.result) {
// middleNode = _.find(res.data, function (node) {
// return node.isMiddleNode;
// });
console.log("res.data", res.data);
initOrgTree(res.data);
nodesCotentValue = res.data;
}
});
};
(function initialize() {
initOrgChart();
})();
}
......
......@@ -49,6 +49,31 @@
};
}
if (!String.prototype.formatWithArgs) {
String.prototype.formatWithArgs = function (args) {
var result = this;
if (arguments.length > 0) {
if (arguments.length === 1 && typeof (args) === "object") {
for (var key in args) {
if (args[key] !== undefined) {
var reg = new RegExp("({" + key + "})", "g");
result = result.replace(reg, args[key]);
}
}
}
else {
for (var i = 0; i < arguments.length; i++) {
if (arguments[i] !== undefined) {
var reg = new RegExp("({)" + i + "(})", "g");
result = result.replace(reg, arguments[i]);
}
}
}
}
return result;
}
}
if (!Number.prototype.formatAmount) {
Number.prototype.formatAmount = function (decPlaces, type) {
if (type) {
......@@ -214,6 +239,7 @@
function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
};
......@@ -1203,8 +1229,8 @@
}
}
};
PWC.addIndex = function(data){
for(var i = 0, j= data.length; i<j; i++){
PWC.addIndex = function (data) {
for (var i = 0, j = data.length; i < j; i++) {
data[i].xh = i + 1;
}
return data;
......
......@@ -70,6 +70,9 @@ webservices.factory('orgHKService', ['$http', 'apiConfig', function ($http, apiC
},
deleteDirector: function (id) {
return $http.delete('/orgHK/deleteDirector?id=' + id, apiConfig.create());
},
getAllOrgTreeData: function () {
return $http.get('/orgHK/getAllOrgTreeData', apiConfig.create());
}
}
}]);
\ No newline at end of file
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