Commit 50f6a44d authored by eddie.woo's avatar eddie.woo

add autoMap

parent 159d0642
...@@ -163,6 +163,10 @@ ...@@ -163,6 +163,10 @@
<property name="useActualColumnNames" value="true" /> <property name="useActualColumnNames" value="true" />
<property name="ignoreQualifiersAtRuntime" value="true"/> <property name="ignoreQualifiersAtRuntime" value="true"/>
</table> </table>
<table tableName="AccountMappingManual" domainObjectName="AccountMappingManual">
<property name="useActualColumnNames" value="true" />
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
<table tableName="EnterpriseAccountSetOrg" domainObjectName="EnterpriseAccountSetOrg"> <table tableName="EnterpriseAccountSetOrg" domainObjectName="EnterpriseAccountSetOrg">
<property name="useActualColumnNames" value="true" /> <property name="useActualColumnNames" value="true" />
<property name="ignoreQualifiersAtRuntime" value="true"/> <property name="ignoreQualifiersAtRuntime" value="true"/>
......
package pwc.taxtech.atms.common.message;
public class EnterpriseAccountSetOrgMsg {
public static final String EnterpriseAccountSetOrgExists = "EnterpriseAccountSetOrgExists";
public static final String NoOrgSetOrOrgExist = "NoOrgSetOrOrgExist";
public static final String EnterpriseAccountSetOrgDateTimeOverlap = "EnterpriseAccountSetOrgDateTimeOverlap";
public static final String RelevantOranization = "RelevantOranization";
public static final String EffectiveDateAreaProblem = "EffectiveDateAreaProblem";
public static final String EnterpriseAccountSetOrgOnlyOncePerYear = "EnterpriseAccountSetOrgOnlyOncePerYear";
}
package pwc.taxtech.atms.constant;
public class AccountMappingConstant {
public enum Status {
UNMAPPED(1, "未对应"),
MAPPED(2, "已对应"),
DIRECTION_DIFFERENT(3, "借贷方向不一致"),
ACCOUNT_TYPE_DIFFERENT(4, "科目类型不一致");
private Integer code;
private String name;
Status(Integer code, String name) {
this.code = code;
this.name = name;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
}
}
package pwc.taxtech.atms.constant.enums;
public enum AccountRuleEnum {
Rule2001("企业会计制度(2001年实施)", 1),
Rule2007("企业会计准则(2007年实施)", 2);
private String name;
private Integer value;
AccountRuleEnum(String name, Integer value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public Integer getValue() {
return value;
}
}
...@@ -270,4 +270,16 @@ public class EnterpriseAccountManagerController { ...@@ -270,4 +270,16 @@ public class EnterpriseAccountManagerController {
@RequestParam String filterType) { @RequestParam String filterType) {
return enterpriseAccountService.getList(espID, orgID, filterType); return enterpriseAccountService.getList(espID, orgID, filterType);
} }
@ResponseBody
@ApiOperation(value = "科目自动对应")
@RequestMapping(value = "autoMap", method = RequestMethod.GET)
public OperationResultDto autoMap(@RequestParam String orgID, @RequestParam String accountSetID) {
try {
return enterpriseAccountService.autoMap(orgID, accountSetID);
} catch (Exception e) {
logger.error("autoMap error.", e);
}
return OperationResultDto.error("自动对应失败");
}
} }
package pwc.taxtech.atms.dao.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.AccountMappingManualMapper;
import pwc.taxtech.atms.entitiy.AccountMappingManual;
import pwc.taxtech.atms.entitiy.AccountMappingManualExample;
import java.util.List;
import java.util.Optional;
@Service
public class AccountMappingManualDao {
@Autowired
AccountMappingManualMapper mapper;
public Optional<List<AccountMappingManual>> getAll() {
AccountMappingManualExample example = new AccountMappingManualExample();
return Optional.ofNullable(mapper.selectByExample(example));
}
}
package pwc.taxtech.atms.dao.dao;
import com.google.common.collect.Lists;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.constant.AccountMappingConstant;
import pwc.taxtech.atms.constant.EnterpriseAccountConstant;
import pwc.taxtech.atms.dao.EnterpriseAccountMapper;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountDto;
import pwc.taxtech.atms.entitiy.EnterpriseAccount;
import pwc.taxtech.atms.entitiy.EnterpriseAccountExample;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Service
public class EnterpriseAccountDao {
@Autowired
private EnterpriseAccountMapper enterpriseAccountMapper;
@Autowired
private JdbcTemplate jdbcTemplate;
public Optional<List<EnterpriseAccount>> getByEpAccountSetId(String epAccountSetId) {
EnterpriseAccountExample example = new EnterpriseAccountExample();
EnterpriseAccountExample.Criteria criteria = example.createCriteria();
criteria.andEnterpriseAccountSetIDEqualTo(epAccountSetId);
return Optional.ofNullable(enterpriseAccountMapper.selectByExample(example));
}
public Optional<EnterpriseAccount> getEpAccount(String epAccountCode, String epAccountSetId) {
EnterpriseAccountExample example = new EnterpriseAccountExample();
EnterpriseAccountExample.Criteria criteria = example.createCriteria();
criteria.andCodeEqualTo(epAccountCode);
criteria.andEnterpriseAccountSetIDEqualTo(epAccountSetId);
return enterpriseAccountMapper.selectByExample(example).stream().findFirst();
}
public String getEpAccountID(String epAccountCode, String epAccountSetId) {
Optional<EnterpriseAccount> optional = getEpAccount(epAccountCode, epAccountSetId);
return optional.isPresent() ? optional.get().getID() : StringUtils.EMPTY;
}
public List<EnterpriseAccountDto> getAccountMappingResult(String accountSetId, int ruleId, String industryId) {
//amk.IndustryId倒序排列可以保证在结果集中,同一个COA,本行业的匹配结果在通用关键字匹配结果之前出现
String sql = "SELECT a.Code, a.IsLeaf, sa.Code StdCode,a.FullName as AccountFullName, amk.FullName as MappingFullName,amk.IndustryId"
+ " FROM (select * from AccountMappingKeyword where IndustryId=?) amk "
+ " INNER JOIN (select * from StandardAccount where IndustryId=?) sa ON amk.StandardCode = sa.Code"
+ " INNER JOIN EnterpriseAccount a on a.FullName like amk.FullName"
+ " WHERE amk.RuleType = ? AND sa.IsLeaf = 1 AND a.EnterpriseAccountSetID=?"
+ " ORDER BY a.Code,amk.IndustryId DESC";
List<Map<String, Object>> queryList = jdbcTemplate.queryForList(sql, industryId, industryId, ruleId, accountSetId);
List<EnterpriseAccountDto> list = Lists.newArrayList();
for (Map<String, Object> obj : queryList) {
EnterpriseAccountDto account = new EnterpriseAccountDto();
account.setCode(MapUtils.getString(obj, "Code"));
account.setIsLeaf(StringUtils.equals(MapUtils.getString(obj, "isLeaf"), "1"));
account.setStdCode(MapUtils.getString(obj, "StdCode"));
account.setFullName(MapUtils.getString(obj, "AccountFullName"));
account.setMappingFullName(MapUtils.getString(obj, "MappingFullName"));
list.add(account);
}
return list;
}
public List<Map<String, Object>> selectAccounts(String industryId, String accountSetId, String organizationID, int iAcctProp,
int iIsMapped, int iLevel, Boolean bIsActive) {
//In admin module, enterprise account has IsInVoucher to identify vouchers
//However web admin is not requried voucher, so the field is not available in web admin,
//so set acctVoucherHasNull=true at this moment
//But in the web admin, balance is not required at this stage, so set balanceIsNull=true
//string sql = "select count(1) from EnterpriseAccount where IsInVoucher is null";
//bool balanceIsNull = true;
//bool acctVoucherHasNull = true;
List<String> whereList = Lists.newArrayList();
String sql = "SELECT * FROM ( " +
"SELECT CASE IsLeaf WHEN 0 THEN '+' ELSE '' END IsEx,Code, Name, FullName, " +
"CASE Direction WHEN 1 THEN N'借方' WHEN -1 THEN N'贷方' END Direction, " +
"CASE StdAccountCode WHEN '0000' THEN '-' ELSE StdAccountCode END StdCode," +
"CASE StdAccountCode WHEN '0000' THEN '-' ELSE StdName END StdName, " +
"CASE StdAccountCode WHEN '0000' THEN '-' ELSE StdAccountCode + '/' + StdFullName END StdCodeName, " +
"CASE StdAccountCode WHEN '0000' THEN '-' ELSE CASE StdDirection WHEN 1 THEN N'借方' WHEN -1 THEN N'贷方' END END StdDirection, " +
"CASE WHEN AcctProp<>StdAcctProp THEN 1 ELSE 0 END IsAcctPropDiff," +
"CASE WHEN StdAccountCode IS NULL THEN 0 ELSE 1 END MappingStatus, " +
"CASE WHEN StdAccountCode IS NULL THEN AcctProp ELSE StdAcctProp END AcctProp, ParentCode, AcctLevel, StdAccountCode AcctStdCode, IsLeaf " +
" FROM (SELECT ID,Code,Name,FullName,Direction,AcctProp,ParentCode,AcctLevel,IsLeaf FROM EnterpriseAccount WHERE EnterpriseAccountSetID=?) ea " +
"LEFT JOIN (SELECT EnterpriseAccountCode ,StandardAccountCode FROM AccountMapping WHERE OrganizationID=? AND IndustryID=?) am ON ea.Code=am.EnterpriseAccountCode " +
"LEFT JOIN (SELECT ID StdID, Code StdAccountCode, Name StdName, FullName StdFullName,Direction StdDirection,AcctProp StdAcctProp FROM StandardAccount WHERE IndustryID=?) sa ON am.StandardAccountCode=sa.StdAccountCode ) T";
List<Object> params = Lists.newArrayList(accountSetId, organizationID, industryId, industryId);
if (iAcctProp != EnterpriseAccountConstant.InvalidId) {
sql += "AcctProp = ?";
params.add(iAcctProp);
}
if (iIsMapped == AccountMappingConstant.Status.UNMAPPED.getCode()) {
sql += "StdCode IS NULL";
} else if (iIsMapped == AccountMappingConstant.Status.MAPPED.getCode()) {
sql += "StdCode IS NOT NULL";
} else if (iIsMapped == AccountMappingConstant.Status.DIRECTION_DIFFERENT.getCode()) {
sql += "StdCode IS NOT NULL AND Direction<>StdDirection";
} else if (iIsMapped == AccountMappingConstant.Status.ACCOUNT_TYPE_DIFFERENT.getCode()) {
sql += "StdCode IS NOT NULL AND IsAcctPropDiff=1";
}
if (iLevel != EnterpriseAccountConstant.InvalidId) {
sql += "AcctLevel = ?";
params.add(iLevel);
}
sql += " ORDER BY Code";
return jdbcTemplate.queryForList(sql, params.toArray());
}
}
package pwc.taxtech.atms.dao.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.EnterpriseAccountSetOrgMapper;
import pwc.taxtech.atms.entitiy.EnterpriseAccountSetOrg;
import pwc.taxtech.atms.entitiy.EnterpriseAccountSetOrgExample;
import java.util.List;
@Service
public class EnterpriseAccountSetOrgDao {
@Autowired
private EnterpriseAccountSetOrgMapper mapper;
public List<EnterpriseAccountSetOrg> getByOrgIdAndAccountSetId(String orgId, String accountSetId) {
EnterpriseAccountSetOrgExample example = new EnterpriseAccountSetOrgExample();
EnterpriseAccountSetOrgExample.Criteria criteria = example.createCriteria();
criteria.andOrganizationIDEqualTo(orgId);
criteria.andEnterpriseAccountSetIDEqualTo(accountSetId);
return mapper.selectByExample(example);
}
}
package pwc.taxtech.atms.dao.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.StandardAccountMapper;
import pwc.taxtech.atms.entitiy.StandardAccount;
import pwc.taxtech.atms.entitiy.StandardAccountExample;
import java.util.List;
import java.util.Optional;
@Service
public class StandardAccountDao {
@Autowired
private StandardAccountMapper standardAccountMapper;
public Optional<List<StandardAccount>> getByIndustryId(String industryId) {
StandardAccountExample example = new StandardAccountExample();
StandardAccountExample.Criteria criteria = example.createCriteria();
criteria.andIndustryIDEqualTo(industryId);
return Optional.ofNullable(standardAccountMapper.selectByExample(example));
}
}
package pwc.taxtech.atms.dto.accountmapping;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonConstants;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dao.AccountMappingMapper;
import pwc.taxtech.atms.dao.dao.EnterpriseAccountDao;
import pwc.taxtech.atms.entitiy.AccountMapping;
import pwc.taxtech.atms.entitiy.AccountMappingExample;
import java.util.List;
@Service
public class AccountMappingDao {
@Autowired
AccountMappingMapper mapper;
@Autowired
EnterpriseAccountDao epAccountDao;
public void delByEpAccountCodeList(List<String> codeList) {
if (CollectionUtils.isNotEmpty(codeList)) {
AccountMappingExample example = new AccountMappingExample();
AccountMappingExample.Criteria criteria = example.createCriteria();
criteria.andEnterpriseAccountCodeIn(codeList);
mapper.deleteByExample(example);
}
}
public boolean isStdExists(String accountSetID, String enterpirseAccountCode, String industryID, String orgID) {
AccountMappingExample example = new AccountMappingExample();
AccountMappingExample.Criteria criteria = example.createCriteria();
criteria.andEnterpriseAccountCodeEqualTo(enterpirseAccountCode);
criteria.andEnterpriseAccountSetIDEqualTo(accountSetID);
criteria.andOrganizationIDEqualTo(orgID);
criteria.andIndustryIDEqualTo(industryID);
criteria.andStandardAccountCodeNotEqualTo(CommonConstants.EmptyStdCode);
return mapper.countByExample(example) > 0;
}
private void updateToTable(String accountCode, String accountSetId, String stdAccountCode,
String industryID, String enterpriseAccountID, String orgID) {
AccountMappingExample example = new AccountMappingExample();
AccountMappingExample.Criteria criteria = example.createCriteria();
criteria.andEnterpriseAccountCodeEqualTo(accountCode);
criteria.andEnterpriseAccountSetIDEqualTo(accountSetId);
criteria.andOrganizationIDEqualTo(orgID);
criteria.andIndustryIDEqualTo(industryID);
mapper.deleteByExample(example);
AccountMapping mapping = new AccountMapping();
mapping.setID(CommonUtils.getUUID());
mapping.setEnterpriseAccountCode(accountCode);
mapping.setEnterpriseAccountSetID(accountSetId);
mapping.setOrganizationID(orgID);
mapping.setStandardAccountCode(stdAccountCode);
mapping.setIndustryID(industryID);
mapper.insertSelective(mapping);
}
public void mapStdAccountByCode(String accountSetId, String stdAccountCode, String accountCode,
String industryID, String orgId, boolean bOverwrite, int acctLevel) {
String enterpriseAccountID = epAccountDao.getEpAccountID(accountCode, accountSetId);
if (StringUtils.isBlank(stdAccountCode))
stdAccountCode = CommonConstants.NullStdCode;
//region 新逻辑
if (!bOverwrite) {
if (!isStdExists(accountSetId, accountCode, industryID, orgId)) {
updateToTable(accountCode, accountSetId, stdAccountCode, industryID, enterpriseAccountID, orgId);
}
} else {
updateToTable(accountCode, accountSetId, stdAccountCode, industryID, enterpriseAccountID, orgId);
}
//endregion
}
}
package pwc.taxtech.atms.dto.accountmapping;
import com.alibaba.fastjson.annotation.JSONField;
import java.util.Date;
public class AccountMappingManualDto {
@JSONField(name = "id")
public String ID;
public String standardCode;
public String fullName;
public String enterpriseAccountSetID;
public String organizationID;
public String industryID;
public int priority;
public Date updateTime;
public String updateBy;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getStandardCode() {
return standardCode;
}
public void setStandardCode(String standardCode) {
this.standardCode = standardCode;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getEnterpriseAccountSetID() {
return enterpriseAccountSetID;
}
public void setEnterpriseAccountSetID(String enterpriseAccountSetID) {
this.enterpriseAccountSetID = enterpriseAccountSetID;
}
public String getOrganizationID() {
return organizationID;
}
public void setOrganizationID(String organizationID) {
this.organizationID = organizationID;
}
public String getIndustryID() {
return industryID;
}
public void setIndustryID(String industryID) {
this.industryID = industryID;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
}
package pwc.taxtech.atms.dto.stdaccount;
import com.alibaba.fastjson.annotation.JSONField;
import java.util.List;
public class StandardAccountDto {
@JSONField(name = "id")
public String ID;
public String code;
public String name;
public String parentCode;
public String fullName;
public int number;
public Boolean expanded;
public Integer acctProp;
public Integer subProp;
public Integer acctLevel;
public int direction;
public Boolean isLeaf;
public int ruleType;
public Boolean isActive;
public String englishName;
public String industryID;
public String title;
public String etsName;
public String etsCode;
public List<StandardAccountDto> children;
public String treeLevel;
/// <summary>
/// 父级科目名称
/// </summary>
/// <value>
/// The name of the parent.
/// </value>
public String parentName;
/// <summary>
/// 父级科目全名
/// </summary>
/// <value>
/// The full name of the parent.
/// </value>
public String parentFullName;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public Boolean getExpanded() {
return expanded;
}
public void setExpanded(Boolean expanded) {
this.expanded = expanded;
}
public Integer getAcctProp() {
return acctProp;
}
public void setAcctProp(Integer acctProp) {
this.acctProp = acctProp;
}
public Integer getSubProp() {
return subProp;
}
public void setSubProp(Integer subProp) {
this.subProp = subProp;
}
public Integer getAcctLevel() {
return acctLevel;
}
public void setAcctLevel(Integer acctLevel) {
this.acctLevel = acctLevel;
}
public int getDirection() {
return direction;
}
public void setDirection(int direction) {
this.direction = direction;
}
public Boolean getLeaf() {
return isLeaf;
}
public void setLeaf(Boolean leaf) {
isLeaf = leaf;
}
public int getRuleType() {
return ruleType;
}
public void setRuleType(int ruleType) {
this.ruleType = ruleType;
}
public Boolean getActive() {
return isActive;
}
public void setActive(Boolean active) {
isActive = active;
}
public String getEnglishName() {
return englishName;
}
public void setEnglishName(String englishName) {
this.englishName = englishName;
}
public String getIndustryID() {
return industryID;
}
public void setIndustryID(String industryID) {
this.industryID = industryID;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getEtsName() {
return etsName;
}
public void setEtsName(String etsName) {
this.etsName = etsName;
}
public String getEtsCode() {
return etsCode;
}
public void setEtsCode(String etsCode) {
this.etsCode = etsCode;
}
public List<StandardAccountDto> getChildren() {
return children;
}
public void setChildren(List<StandardAccountDto> children) {
this.children = children;
}
public String getTreeLevel() {
return treeLevel;
}
public void setTreeLevel(String treeLevel) {
this.treeLevel = treeLevel;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public String getParentFullName() {
return parentFullName;
}
public void setParentFullName(String parentFullName) {
this.parentFullName = parentFullName;
}
}
...@@ -101,6 +101,8 @@ public interface EnterpriseAccountService { ...@@ -101,6 +101,8 @@ public interface EnterpriseAccountService {
List<EnterpriseAccountSetDto> getEnterpriseAccountSetListByOrgID(String orgId); List<EnterpriseAccountSetDto> getEnterpriseAccountSetListByOrgID(String orgId);
List<EnterpriseAccountDto> getList(String epAccountSetID, String orgId, String filterType); List<EnterpriseAccountDto> getList(String epAccountSetID, String orgId, String filterType);
OperationResultDto autoMap(String orgId, String accountSetId);
} }
...@@ -9,6 +9,7 @@ import pwc.taxtech.atms.dto.OperationResultDto; ...@@ -9,6 +9,7 @@ import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.OrganizationValidateDto; import pwc.taxtech.atms.dto.OrganizationValidateDto;
import pwc.taxtech.atms.dto.dimension.DimensionOrgDtoDashboard; import pwc.taxtech.atms.dto.dimension.DimensionOrgDtoDashboard;
import pwc.taxtech.atms.dto.dimension.OrgDashboardParams; import pwc.taxtech.atms.dto.dimension.OrgDashboardParams;
import pwc.taxtech.atms.dto.navtree.DevTreeDto;
import pwc.taxtech.atms.dto.navtree.NavTreeDto; import pwc.taxtech.atms.dto.navtree.NavTreeDto;
import pwc.taxtech.atms.dto.organization.OrgBasicDto; import pwc.taxtech.atms.dto.organization.OrgBasicDto;
import pwc.taxtech.atms.dto.organization.OrgCustomDto; import pwc.taxtech.atms.dto.organization.OrgCustomDto;
...@@ -83,4 +84,6 @@ public interface OrganizationService { ...@@ -83,4 +84,6 @@ public interface OrganizationService {
OrgGeneralInfoDto getGeneralInfo(String orgID); OrgGeneralInfoDto getGeneralInfo(String orgID);
List<DevTreeDto> getOrgIvhTreeList(Integer useType,String orgSetId);
} }
...@@ -25,6 +25,8 @@ import java.util.Objects; ...@@ -25,6 +25,8 @@ import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
...@@ -95,6 +97,8 @@ import pwc.taxtech.atms.dto.dimension.DimensionValueDisplayDto; ...@@ -95,6 +97,8 @@ import pwc.taxtech.atms.dto.dimension.DimensionValueDisplayDto;
import pwc.taxtech.atms.dto.dimension.DimensionValueJoinDimensionDto; import pwc.taxtech.atms.dto.dimension.DimensionValueJoinDimensionDto;
import pwc.taxtech.atms.dto.dimension.OrgDashboardParams; import pwc.taxtech.atms.dto.dimension.OrgDashboardParams;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountSetOrgDto; import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountSetOrgDto;
import pwc.taxtech.atms.dto.navtree.DevTreeDto;
import pwc.taxtech.atms.dto.navtree.IvhTreeDto;
import pwc.taxtech.atms.dto.navtree.NavTreeDto; import pwc.taxtech.atms.dto.navtree.NavTreeDto;
import pwc.taxtech.atms.dto.organization.OrgBasicDto; import pwc.taxtech.atms.dto.organization.OrgBasicDto;
import pwc.taxtech.atms.dto.organization.OrgCountDto; import pwc.taxtech.atms.dto.organization.OrgCountDto;
...@@ -2848,6 +2852,103 @@ public class OrganizationServiceImpl implements OrganizationService { ...@@ -2848,6 +2852,103 @@ public class OrganizationServiceImpl implements OrganizationService {
return getOrgGeneralInfo(orgID); return getOrgGeneralInfo(orgID);
} }
@Override
public List<DevTreeDto> getOrgIvhTreeList(Integer useType, String orgSetId) {
//todo
List<DevTreeDto> result = Lists.newArrayList();
List<IvhTreeDto> orgDtoList = Lists.newArrayList();
List<Organization> orgList;
OrganizationExample orgExample = new OrganizationExample();
if (useType < 2)
{
orgList = organizationMapper.selectByExample(orgExample);
}
else
{
EnterpriseAccountSetOrgExample tmpExample = new EnterpriseAccountSetOrgExample();
EnterpriseAccountSetOrgExample.Criteria criteria = tmpExample.createCriteria();
criteria.andEnterpriseAccountSetIDEqualTo(orgSetId);
List<EnterpriseAccountSetOrg> enAccountSetOrgList = enterpriseAccountSetOrgMapper.selectByExample(tmpExample);
if (CollectionUtils.isNotEmpty(enAccountSetOrgList)){
List<String> orgIdList = enAccountSetOrgList.stream().map(EnterpriseAccountSetOrg::getOrganizationID)
.collect(toList());
OrganizationExample.Criteria orgCriteria = orgExample.createCriteria();
orgCriteria.andIDIn(orgIdList);
orgList = organizationMapper.selectByExample(orgExample);
}else {
orgList = Lists.newArrayList();
}
}
if (CollectionUtils.isNotEmpty(orgList)) {
//find rootOrg
List<Organization> rootOrgList;
if (useType == 1) {
rootOrgList = orgList.stream().filter(x -> StringUtils.isBlank(x.getParentID())).collect(toList());
} else {
rootOrgList = orgList.stream().filter(x -> StringUtils.isBlank(x.getParentID()) && x.getIsActive())
.collect(toList());
}
List<ServiceType> serviceList = Lists.newArrayList();
for (Organization org: rootOrgList){
IvhTreeDto root = new IvhTreeDto();
root.setChildren(Lists.newArrayList());
root.setLabel(org.getName());
root.setValue(org);
orgDtoList.add(generateIvhTreeDto(org,orgList,serviceList,useType));
}
}
return orgDtoList.stream().map(this::devTreeDtoMapper).collect(toList());
}
private DevTreeDto devTreeDtoMapper(IvhTreeDto ivhTreeDto) {
DevTreeDto dto = new DevTreeDto();
dto.setText(ivhTreeDto.getLabel());
List<IvhTreeDto> childList = ivhTreeDto.getChildren();
if (CollectionUtils.isNotEmpty(childList)) {
dto.setItems(Lists.newArrayList());
for (IvhTreeDto ivh : childList) {
dto.getItems().add(devTreeDtoMapper(ivh));
}
}
dto.setId(ivhTreeDto.getId());
dto.setData(ivhTreeDto);
return dto;
}
private IvhTreeDto generateIvhTreeDto(Organization parentOrg, List<Organization> orgList,
List<ServiceType> serviceList, int useType) {
IvhTreeDto result = new IvhTreeDto();
OrganizationDto parentOrgDto = new OrganizationDto();
CommonUtils.copyProperties(parentOrg, parentOrgDto);
if (null != parentOrg && StringUtils.isNotBlank(parentOrg.getID())) {
parentOrgDto.setParentName(orgList.stream().filter(x -> StringUtils.equals(x.getID(), parentOrg.getParentID()))
.findFirst().map(x -> x.getName()).orElse(StringUtils.EMPTY));
}
List<Organization> subOrgList;
if (useType == 1) {
subOrgList = orgList.stream().filter(x -> StringUtils.equals(x.getParentID(), parentOrg.getID())).collect(toList());
} else {
subOrgList = orgList.stream().filter(x -> StringUtils.equals(x.getParentID(), parentOrg.getID()) && x.getIsActive())
.collect(toList());
}
parentOrgDto.setSubOrgs(Lists.newArrayList());
List<IvhTreeDto> children = Lists.newArrayList();
//create and add subtrees to the current node
for (Organization subOrg : subOrgList) {
children.add(generateIvhTreeDto(subOrg, orgList, serviceList, useType));
}
result.setLabel(parentOrgDto.getName());
result.setValue(parentOrgDto);
result.setChildren(children);
return result;
}
private OrgGeneralInfoDto getOrgGeneralInfo(String orgID) { private OrgGeneralInfoDto getOrgGeneralInfo(String orgID) {
List<OrgGeneralInfoMiddleDto> query = organizationMapper.selectJoinToOrgGeneralInfo(); List<OrgGeneralInfoMiddleDto> query = organizationMapper.selectJoinToOrgGeneralInfo();
List<OrgGeneralInfoMiddleDto> filter = query.stream().filter(x -> Strings.equals(x.getID(), orgID)) List<OrgGeneralInfoMiddleDto> filter = query.stream().filter(x -> Strings.equals(x.getID(), orgID))
......
...@@ -89,6 +89,8 @@ public class StdAccountServiceImpl extends BaseService implements StdAccountServ ...@@ -89,6 +89,8 @@ public class StdAccountServiceImpl extends BaseService implements StdAccountServ
StdAccountFancyTreeDto dto = new StdAccountFancyTreeDto(); StdAccountFancyTreeDto dto = new StdAccountFancyTreeDto();
dto.setExpanded(false); dto.setExpanded(false);
dto.setHasChildren(false); dto.setHasChildren(false);
return CommonUtils.copyProperties(account, dto); CommonUtils.copyProperties(account, dto);
dto.setTitle(dto.getCode() + "-" + (StringUtils.equals(dto.getDirection(), "1") ? "借" : "贷") + "-" + dto.getName());
return dto;
} }
} }
...@@ -758,7 +758,7 @@ public class UserServiceImpl extends AbstractService implements UserService { ...@@ -758,7 +758,7 @@ public class UserServiceImpl extends AbstractService implements UserService {
userRole.setServiceTypeID(r != null ? r.getServiceTypeID() : ""); userRole.setServiceTypeID(r != null ? r.getServiceTypeID() : "");
userRoleList.add(userRole); userRoleList.add(userRole);
logger.debug("Start to insert user role [ {} ] with roleID [ {} ]", userRole.getID(), role); logger.debug("Start to insert user role [ {} ] with roleID [ {} ]", userRole.getID(), role);
userRoleMapper.insert(userRole); userRoleMapper.insertSelective(userRole);
} }
// 添加所属机构的访问权限 // 添加所属机构的访问权限
UserOrganization userOrganization = findUserOrganizationByUserIDAndOrganizationID(user.getID(), UserOrganization userOrganization = findUserOrganizationByUserIDAndOrganizationID(user.getID(),
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd"> http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- DruidDataSource数据源配置) --> <!-- DruidDataSource数据源配置) -->
<!-- See: https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_DruidDataSource%E5%8F%82%E8%80%83%E9%85%8D%E7%BD%AE --> <!-- See: https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_DruidDataSource%E5%8F%82%E8%80%83%E9%85%8D%E7%BD%AE -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
...@@ -42,4 +44,23 @@ ...@@ -42,4 +44,23 @@
<!-- 配置监控统计拦截的filters --> <!-- 配置监控统计拦截的filters -->
<property name="filters" value="stat" /> <property name="filters" value="stat" />
</bean> </bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="druid-stat-interceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor">
</bean>
<bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut" scope="prototype">
<property name="patterns">
<list>
<value>pwc.taxtech.atms.dao.*</value>
</list>
</property>
</bean>
<aop:config>
<aop:advisor advice-ref="druid-stat-interceptor" pointcut-ref="druid-stat-pointcut"/>
</aop:config>
</beans> </beans>
\ 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