Commit 2541060b authored by frank.xa.zhang's avatar frank.xa.zhang

add demo for orgChart -- frank

parent 7ad4a9a6
......@@ -173,4 +173,10 @@ public class OrganizationHKController {
return organizationHKService.deleteAttachment(attachmentId);
}
// @RequestMapping(value = "getShareholders",method = RequestMethod.GET)
// public @ResponseBody OperationResultDto<OrgShareholdersDto> getShareholders(@RequestParam Long orgId){
// logger.info("GET /api/v1/orgHK/getShareholders");
// return organizationHKService.getShareholders(orgId);
// }
}
......@@ -27,10 +27,8 @@ import pwc.taxtech.atms.organization.dao.OrganizationAttachmentMapper;
import pwc.taxtech.atms.organization.dao.OrganizationDirectorMapper;
import pwc.taxtech.atms.organization.dao.OrganizationHKMapper;
import pwc.taxtech.atms.organization.dao.OrganizationShareholderMapper;
import pwc.taxtech.atms.organization.dpo.OrganizationAttachmentDto;
import pwc.taxtech.atms.organization.dpo.OrganizationDirectorDto;
import pwc.taxtech.atms.organization.dpo.OrganizationHKDto;
import pwc.taxtech.atms.organization.dpo.OrganizationShareholderDto;
import pwc.taxtech.atms.organization.dao.extension.OrganizationShareholderExtMapper;
import pwc.taxtech.atms.organization.dpo.*;
import pwc.taxtech.atms.organization.entity.*;
import pwc.taxtech.atms.organization.mapper.OrganizationAttachmentTMapper;
import pwc.taxtech.atms.organization.mapper.OrganizationDirectorTMapper;
......@@ -94,6 +92,9 @@ public class OrganizationHKServiceImpl {
@Autowired
private OrganizationHKTMapper organizationHKTMapper;
@Resource
private OrganizationShareholderExtMapper organizationShareholderExtMapper;
@Value("${orgaization.file.location}")
private String fileDirectory;
......@@ -105,12 +106,26 @@ public class OrganizationHKServiceImpl {
List<OrganizationAttachment> organizationAttachments = organizationAttachmentMapper.selectByExample(null);
organizationHKS.forEach(a -> {
OrganizationHKDto organizationHKDto = organizationHKTMapper.toOrganizationHKDto(a);
List<OrganizationShareholderDto> tempShareholders = organizationShareholders.stream().filter(b -> b.getEntityId().equals(a.getId())).map(organizationShareholderTMapper::toOrgShareholder).collect(Collectors.toList());
List<OrganizationDirectorDto> tempDirectors = organizationDirectors.stream().filter(c -> c.getEntityId().equals(a.getId())).map(organizationDirectorTMapper::toOrganizationDirectorDto).collect(Collectors.toList());
List<OrganizationAttachmentDto> tempAttachments = organizationAttachments.stream().filter(d -> d.getEntityId().equals(a.getId())).map(organizationAttachmentTMapper::toOrganizationAttachmentDto).collect(Collectors.toList());
List<OrganizationShareholderDto> tempShareholders = organizationShareholders.stream().filter(b -> b.getEntityId().equals(a.getId()))
.map(organizationShareholderTMapper::toOrgShareholder).collect(Collectors.toList());
List<OrganizationDirectorDto> tempDirectors = organizationDirectors.stream().filter(c -> c.getEntityId().equals(a.getId()))
.map(organizationDirectorTMapper::toOrganizationDirectorDto).collect(Collectors.toList());
List<OrganizationAttachmentDto> tempAttachments = organizationAttachments.stream().filter(d -> d.getEntityId().equals(a.getId()))
.map(organizationAttachmentTMapper::toOrganizationAttachmentDto).collect(Collectors.toList());
organizationHKDto.setShareholders(tempShareholders);
organizationHKDto.setDirectors(tempDirectors);
organizationHKDto.setAttachments(tempAttachments);
List<ShareholderDto> shareholderDtos = organizationShareholderExtMapper.selectShareholder(a.getId());
List<SubsidaryDto> subsidaryDtos = organizationShareholderExtMapper.selectSubsidary(a.getId());
List<OrgShareholderDto> orgShareholderDtos = shareholderDtos.stream()
.map(organizationShareholderTMapper::toOrgShareholderDto).collect(Collectors.toList());
List<OrgSubsidaryDto> orgSubsidaryDtos = subsidaryDtos.stream()
.map(organizationShareholderTMapper::toOrgSubsidaryDto).collect(Collectors.toList());
List<OrgDirectorDto> orgDirectorDtos = organizationDirectors.stream()
.map(organizationDirectorTMapper::toOrgDirectorDto).collect(Collectors.toList());
organizationHKDto.setOrgShareholderDtos(orgShareholderDtos);
organizationHKDto.setOrgSubsidaryDtos(orgSubsidaryDtos);
organizationHKDto.setOrgDirectorDtos(orgDirectorDtos);
organizationHKDtos.add(organizationHKDto);
});
return organizationHKDtos;
......@@ -288,25 +303,33 @@ public class OrganizationHKServiceImpl {
OrganizationHK organizationHK = organizationHKMapper.selectByPrimaryKey(orgId);
OrganizationHKDto result = new OrganizationHKDto();
CommonUtils.copyProperties(organizationHK, result);
Assert.notNull(result,
"result is null");
Assert.notNull(result, "result is null");
result.setLevel(result.getLevel() == null ? 0 : result.getLevel());
// if (result.getParentId() == 0) {
result.setParentName("");
// } else {
// OrganizationHK tParent = organizationHKMapper.selectByExample(null).stream()
// .filter(sa -> Objects.equals(sa.getId(), result.getParentId())).findFirst().orElse(null);
// Assert.notNull(tParent, "tParent is null");
// result.setParentName(tParent.getName());
// }
OrganizationShareholderExample shareholderExample = new OrganizationShareholderExample();
shareholderExample.createCriteria().andEntityIdEqualTo(orgId);
List<OrganizationShareholderDto> organizationShareholderDtos = organizationShareholderMapper.selectByExample(shareholderExample).stream().map(a -> CommonUtils.copyProperties(a, new OrganizationShareholderDto())).collect(Collectors.toList());
List<OrganizationShareholderDto> organizationShareholderDtos = organizationShareholderMapper.selectByExample(shareholderExample).stream()
.map(a -> organizationShareholderTMapper.toOrgShareholder(a)).collect(Collectors.toList());
OrganizationDirectorExample directorExample = new OrganizationDirectorExample();
directorExample.createCriteria().andEntityIdEqualTo(orgId);
List<OrganizationDirectorDto> organizationDirectorDtos = organizationDirectorMapper.selectByExample(directorExample).stream().map(a -> CommonUtils.copyProperties(a, new OrganizationDirectorDto())).collect(Collectors.toList());
List<OrganizationDirectorDto> organizationDirectorDtos = organizationDirectorMapper.selectByExample(directorExample).stream()
.map(a -> organizationDirectorTMapper.toOrganizationDirectorDto(a)).collect(Collectors.toList());
result.setDirectors(organizationDirectorDtos);
result.setShareholders(organizationShareholderDtos);
OrganizationAttachmentExample organizationAttachmentExample = new OrganizationAttachmentExample();
organizationAttachmentExample.createCriteria().andEntityIdEqualTo(orgId);
List<OrganizationAttachmentDto> organizationAttachmentDtos = organizationAttachmentMapper.selectByExample(organizationAttachmentExample).stream()
.map(organizationAttachmentTMapper::toOrganizationAttachmentDto).collect(Collectors.toList());
result.setAttachments(organizationAttachmentDtos);
List<OrgShareholderDto> orgShareholderDtos = organizationShareholderExtMapper.selectShareholder(orgId).stream()
.map(organizationShareholderTMapper::toOrgShareholderDto).collect(Collectors.toList());
List<OrgSubsidaryDto> orgSubsidaryDtos = organizationShareholderExtMapper.selectSubsidary(orgId).stream()
.map(organizationShareholderTMapper::toOrgSubsidaryDto).collect(Collectors.toList());
List<OrgDirectorDto> orgDirectorDtos = organizationDirectorMapper.selectByExample(directorExample).stream()
.map(organizationDirectorTMapper::toOrgDirectorDto).collect(Collectors.toList());
result.setOrgShareholderDtos(orgShareholderDtos);
result.setOrgSubsidaryDtos(orgSubsidaryDtos);
result.setOrgDirectorDtos(orgDirectorDtos);
return result;
}
......@@ -610,7 +633,7 @@ public class OrganizationHKServiceImpl {
OrganizationAttachment attachment = organizationAttachmentMapper.selectByPrimaryKey(attachmentId);
Assert.notNull(attachment, "attachment is null");
String fileName = attachment.getDocumentName();
String filePath = fileDirectory +"/"+ attachment.getDocumentPath();
String filePath = fileDirectory + "/" + attachment.getDocumentPath();
FileExcelUtil.downloadFile(request, response, fileName, filePath);
}
......
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.ShareholderDto;
import pwc.taxtech.atms.organization.dpo.SubsidaryDto;
import java.util.List;
@Mapper
public interface OrganizationShareholderExtMapper extends MyMapper {
@Select("select a.id, a.investment_entity_id as entityId,b.name,a.voting_percentage as votingPercentage from organization_shareholder a left join organization b on a.investment_entity_id=b.id where entity_id=#{id}")
List<ShareholderDto> selectShareholder(Long entityId);
@Select("select a.id, a.entity_id as entityId,b.name,a.voting_percentage as votingPercentage from organization_shareholder a left join organization b on a.entity_id=b.id where investment_entity_id=#{id}")
List<SubsidaryDto> selectSubsidary(Long entityId);
}
package pwc.taxtech.atms.organization.dpo;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class OrgDirectorDto {
String directorName;
String residency;
}
package pwc.taxtech.atms.organization.dpo;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class OrgShareholderDto {
String entityName;
String percentage;
}
package pwc.taxtech.atms.organization.dpo;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class OrgSubsidaryDto {
String entityName;
String percentage;
}
......@@ -55,4 +55,7 @@ public class OrganizationHKDto {
private List<OrganizationShareholderDto> shareholders;
@JsonProperty("attachments")
private List<OrganizationAttachmentDto> attachments;
private List<OrgShareholderDto> orgShareholderDtos;
private List<OrgSubsidaryDto> orgSubsidaryDtos;
private List<OrgDirectorDto> orgDirectorDtos;
}
package pwc.taxtech.atms.organization.dpo;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ShareholderDto {
Long id;
Long entityId;
String entityName;
String votingPercentage;
}
package pwc.taxtech.atms.organization.dpo;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SubsidaryDto {
Long id;
Long entityId;
String entityName;
String votingPercentage;
}
package pwc.taxtech.atms.organization.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import pwc.taxtech.atms.organization.dpo.OrgDirectorDto;
import pwc.taxtech.atms.organization.dpo.OrganizationDirectorDto;
import pwc.taxtech.atms.organization.entity.OrganizationDirector;
......@@ -10,6 +10,7 @@ import pwc.taxtech.atms.organization.entity.OrganizationDirector;
public interface OrganizationDirectorTMapper {
OrganizationDirectorTMapper ORGANIZATION_DIRECTOR_T_MAPPER = Mappers.getMapper(OrganizationDirectorTMapper.class);
@Mapping(source = "id", target = "id")
OrganizationDirectorDto toOrganizationDirectorDto(OrganizationDirector organizationDirector);
OrgDirectorDto toOrgDirectorDto(OrganizationDirector organizationDirector);
}
......@@ -3,13 +3,19 @@ package pwc.taxtech.atms.organization.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import pwc.taxtech.atms.organization.dpo.OrganizationShareholderDto;
import pwc.taxtech.atms.organization.dpo.*;
import pwc.taxtech.atms.organization.entity.OrganizationShareholder;
@Mapper(componentModel = "spring")
public interface OrganizationShareholderTMapper {
OrganizationShareholderTMapper ORGANIZATION_SHAREHOLDER_T_MAPPER = Mappers.getMapper(OrganizationShareholderTMapper.class);
@Mapping(source = "id",target = "id")
@Mapping(source = "id", target = "id")
OrganizationShareholderDto toOrgShareholder(OrganizationShareholder organizationShareholder);
@Mapping(source = "votingPercentage", target = "percentage")
OrgShareholderDto toOrgShareholderDto(ShareholderDto shareholderDto);
@Mapping(source = "votingPercentage", target = "percentage")
OrgSubsidaryDto toOrgSubsidaryDto(SubsidaryDto subsidaryDto);
}
......@@ -83,10 +83,10 @@
{{selectCompany.name | limitString:50}}</p>
</div>
<div class="right-option">
<button type="button" id="organizationIsActiveBtn" class="btn" ng-class="{true:'btn-secondary', false:'btn-in-grid'}[!selectCompany.isActive]"
ng-click="updateIsActive()" ng-disabled="!isCanOrganizationIsActiveBtn"><i ng-show="selectCompany.isActive" class="material-icons stop">block</i>{{selectCompany.isActiveStr}}
</button>
<span class="right-operate"></span>
<!--<button type="button" id="organizationIsActiveBtn" class="btn" ng-class="{true:'btn-secondary', false:'btn-in-grid'}[!selectCompany.isActive]"-->
<!--ng-click="updateIsActive()" ng-disabled="!isCanOrganizationIsActiveBtn"><i ng-show="selectCompany.isActive" class="material-icons stop">block</i>{{selectCompany.isActiveStr}}-->
<!--</button>-->
<!--<span class="right-operate"></span>-->
</div>
</div>
</div>
......@@ -106,7 +106,7 @@
{{'ChartInfo' | translate}}
</md-nav-item>
</md-nav-bar>
<div class="ext-content" style="height:535px;margin-top: 10px">
<div class="ext-content" style="height:740px;margin-top: 10px">
<div ng-show="currentNavItem==='page1'" class="org-basic-data-table">
<div class="basic-org-info-wrapper">
<div class="right-option">
......@@ -288,10 +288,8 @@
<hr style="margin-top: 0px;"/>
<!--attachment-->
<div class="attachment-container">
<div class="attachment-header">
<div class="attachment-header" style="margin-bottom: 10px">
<span style="font-size: large;font-weight: bold">Attachment</span>
</div>
<div class="attachment-option">
<button id="uploadAttachBtn" class="btn" style="float:right;background: transparent;" type="file"
multiple="" ngf-select="uploadFiles($files, $invalidFiles)" accept="*" ngf-max-height="1000" ngf-max-size="20MB">
<i class="fa fa-upload" aria-hidden="true" style="font-size: large"></i>{{'upload'|translate}}
......@@ -363,15 +361,15 @@
<div class="org-chart-container"></div>
</div>
<div class="org-chart-info-bottom col-sm-12">
<div class="org-chart-info-shareholders col-sm-3 data-grid-border">
<div class="org-chart-info-shareholders col-sm-3 data-grid-border" style="height:255px">
<div class="org-chart-info-shareholders-header"><span class="lable-text">{{'Shareholders'|translate}}</span></div>
<div id="orgShareholdersGridContainer" dx-data-grid="orgShareholdersGridOptions" style="margin-top: 10px;"></div>
</div>
<div class="org-chart-info-subsidaries col-sm-3 data-grid-border" style="margin-left: 25px">
<div class="org-chart-info-subsidaries col-sm-3 data-grid-border" style="margin-left: 25px;height:255px">
<div class="org-chart-info-shareholders-header"><span class="lable-text">{{'Subsidaries'|translate}}</span></div>
<div id="orgSubsidariesGridContainer" dx-data-grid="orgSubsidariesGridOptions" style="margin-top: 10px;"></div>
</div>
<div class="org-chart-info-directors col-sm-3 data-grid-border" style="margin-left: 25px">
<div class="org-chart-info-directors col-sm-3 data-grid-border" style="margin-left: 25px;height:255px">
<div class="org-chart-info-shareholders-header"><span class="lable-text">{{'Directors'|translate}}</span></div>
<div id="orgDirectorsGridContainer" dx-data-grid="orgDirectorsGridOptions" style="margin-top: 10px;"></div>
</div>
......
......@@ -46,6 +46,15 @@ webservices.factory('orgHKService', ['$http', 'apiConfig', function ($http, apiC
},
attachmentDelete: function (attachmentId) {
return $http.delete('/orgHK/downloadAttachment?attachmentId=' + attachmentId, apiConfig.create());
},
getShareholders: function (orgId) {
return $http.get('/orgHk/getShareholders?orgId=' + orgId, apiConfig.create());
},
getSubsidaries: function (orgId) {
return $http.get('/orgHK/getSubsidaries?orgId=' + orgId, apiConfig.create());
},
getDirectors: function (orgId) {
return $http.get('/orgHK/getDirectors?orgId=' + orgId, apiConfig.create());
}
}
}]);
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://fonts.googleapis.com/css?family=Gochi+Hand" rel="stylesheet">
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div id="tree"></div>
<script src="https://balkangraph.com/js/latest/OrgChart.js"></script>
<script src="./script.js"></script>
</body>
</html>
\ No newline at end of file
window.onload = function () {
var chart = new OrgChart(document.getElementById("tree"), {
template: "olivia",
enableDragDrop: true,
nodeMouseClick: OrgChart.action.edit,
nodeMenu: {
details: { text: "Details" },
edit: { text: "Edit" },
add: { text: "Add" },
remove: { text: "Remove" }
},
dragDropMenu: {
addInGroup: { text: "Add in group" },
addAsChild: { text: "Add as child" }
},
nodeBinding: {
field_0: "name",
field_1: "title",
img_0: "img"
},
tags: {
Directors: {
group: true,
groupName: "Directors",
groupState: OrgChart.EXPAND,
template: "group_grey"
},
HRs: {
group: true,
groupName: "HR Team",
groupState: OrgChart.COLLAPSE,
template: "group_grey"
},
Sales: {
group: true,
groupName: "Sales Team",
groupState: OrgChart.EXPAND,
template: "group_grey"
},
Devs: {
group: true,
groupName: "Dev Team",
groupState: OrgChart.EXPAND,
template: "group_grey"
}
},
nodes: [
{ id: 1, tags: ["Directors"], name: "Billy Moore", title: "CEO", img: "https://balkangraph.com/js/img/2.jpg" },
{ id: 2, tags: ["Directors"], name: "Marley Wilson", title: "Director", img: "https://balkangraph.com/js/img/3.jpg" },
{ id: 3, tags: ["Directors"], name: "Bennie Shelton", title: "Shareholder", img: "https://balkangraph.com/js/img/4.jpg" },
{ id: 4, pid: 1, name: "Billie Rose", title: "Dev Team Lead", img: "https://balkangraph.com/js/img/5.jpg" },
{ id: 5, pid: 1, tags: ["HRs"], name: "Glenn Bell", title: "HR", img: "https://balkangraph.com/js/img/10.jpg" },
{ id: 6, pid: 1, tags: ["HRs"], name: "Blair Francis", title: "HR", img: "https://balkangraph.com/js/img/11.jpg" },
{ id: 7, pid: 1, name: "Skye Terrell", title: "Manager", img: "https://balkangraph.com/js/img/12.jpg" },
{ id: 8, pid: 4, tags: ["Devs"], name: "Jordan Harris", title: "JS Developer", img: "https://balkangraph.com/js/img/6.jpg" },
{ id: 9, pid: 4, tags: ["Devs"], name: "Will Woods", title: "JS Developer", img: "https://balkangraph.com/js/img/7.jpg" },
{ id: 10, pid: 4, tags: ["Devs"], name: "Skylar Parrish", title: "node.js Developer", img: "https://balkangraph.com/js/img/8.jpg" },
{ id: 11, pid: 4, tags: ["Devs"], name: "Ashton Koch", title: "C# Developer", img: "https://balkangraph.com/js/img/9.jpg" },
{ id: 12, pid: 7, tags: ["Sales"], name: "Bret Fraser", title: "Sales", img: "https://balkangraph.com/js/img/13.jpg" },
{ id: 13, pid: 7, tags: ["Sales"], name: "Steff Haley", title: "Sales", img: "https://balkangraph.com/js/img/14.jpg" }
]
});
};
html, body {
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
overflow: hidden;
font-family: Helvetica;
}
#tree {
width: 100%;
height: 100%;
}
\ 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