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 { ...@@ -202,4 +202,10 @@ public class OrganizationHKController {
return organizationHKService.deleteDirector(id); 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 { ...@@ -726,4 +726,57 @@ public class OrganizationHKServiceImpl {
resultDto.setResult(true); resultDto.setResult(true);
return resultDto; 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; ...@@ -3,6 +3,7 @@ package pwc.taxtech.atms.organization.dao.extension;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import pwc.taxtech.atms.MyMapper; 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.ShareholderDto;
import pwc.taxtech.atms.organization.dpo.SubsidaryDto; import pwc.taxtech.atms.organization.dpo.SubsidaryDto;
...@@ -16,4 +17,21 @@ public interface OrganizationShareholderExtMapper extends MyMapper { ...@@ -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") @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); 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 { ...@@ -16,4 +16,5 @@ public class OrgShareholderTreeDataDto {
Integer pid; Integer pid;
List<Integer> spids; List<Integer> spids;
Boolean isMiddleNode; 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;
}
...@@ -49,6 +49,31 @@ ...@@ -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) { if (!Number.prototype.formatAmount) {
Number.prototype.formatAmount = function (decPlaces, type) { Number.prototype.formatAmount = function (decPlaces, type) {
if (type) { if (type) {
...@@ -214,6 +239,7 @@ ...@@ -214,6 +239,7 @@
function s4() { function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
} }
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}; };
...@@ -1203,8 +1229,8 @@ ...@@ -1203,8 +1229,8 @@
} }
} }
}; };
PWC.addIndex = function(data){ PWC.addIndex = function (data) {
for(var i = 0, j= data.length; i<j; i++){ for (var i = 0, j = data.length; i < j; i++) {
data[i].xh = i + 1; data[i].xh = i + 1;
} }
return data; return data;
......
...@@ -70,6 +70,9 @@ webservices.factory('orgHKService', ['$http', 'apiConfig', function ($http, apiC ...@@ -70,6 +70,9 @@ webservices.factory('orgHKService', ['$http', 'apiConfig', function ($http, apiC
}, },
deleteDirector: function (id) { deleteDirector: function (id) {
return $http.delete('/orgHK/deleteDirector?id=' + id, apiConfig.create()); 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