Commit eff3e8a8 authored by eddie.woo's avatar eddie.woo

modify

parent 00ce6fbc
......@@ -44,6 +44,24 @@ public class EnterpriseAccountConstant {
public static final int MaxAcctPropValue = 6;
public static final int SpecialAcctPropValue = -1;
public static final String EnterpriceAccountRepeat = "EnterpriceAccountRepeat";
public static final String EnterpriceAccountParentDisable = "EnterpriceAccountParentDisable";
public static final String StdCodeIsNotExist = "StdCodeIsNotExist";
public static final String NoParentCode = "NoParentCode";
public static final String OrgNotExist = "OrgNotExist";
public static final String SystemError = "SystemError";
public static final String NoAccountNeedClear = "NoAccountNeedClear";
public static final String InputParamInComplete = "InputParamInComplete";
public static final String AccountSetNotExist = "AccountSetNotExist";
public static final String ExistMappedOrg = "ExistMappedOrg";
public static final String SubjectCorresponding = "SubjectCorresponding";
public static final String DirectionFormatError = "DirectionFormatError";
public static final String AcctPropFormatError = "AcctPropFormatError";
public static final String AcctPropNullError = "AcctPropNullError";
public static final List<String> IgnoreFieldList = Arrays.asList(IsLeafField, AcctLevelField, FullNameField);
public static final Map<String, String> DirectionMap = ImmutableMap.<String, String>builder()
......
......@@ -5,6 +5,19 @@ import java.util.Map;
public class StdAccountEnum {
public enum RuleType {
TWO(2);
private Integer code;
RuleType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
public enum AcctProp {
Asset("1", "资产"),
Debt("2", "负债"),
......
......@@ -34,12 +34,7 @@ import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.constant.EnterpriseAccountConstant;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.epaccount.AccountMappingDto;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountAndValidateInfo;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountDto;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountSetDto;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountSetOrgDto;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountUploadDto;
import pwc.taxtech.atms.dto.epaccount.*;
import pwc.taxtech.atms.service.EnterpriseAccountService;
import pwc.taxtech.atms.service.EnterpriseAccountSetService;
import pwc.taxtech.atms.service.impl.FileService;
......@@ -282,4 +277,28 @@ public class EnterpriseAccountManagerController {
}
return OperationResultDto.error("自动对应失败");
}
@ResponseBody
@ApiOperation(value = "手动对应")
@RequestMapping(value = "mapAccount", method = RequestMethod.POST)
public OperationResultDto mapAccount(@RequestBody AccountMapDto dto) {
try {
return enterpriseAccountService.mapAccount(dto);
} catch (Exception e) {
logger.error("mapAccount error.", e);
}
return OperationResultDto.error("自动对应失败");
}
@ResponseBody
@ApiOperation(value = "取消对应")
@RequestMapping(value = "clearMap", method = RequestMethod.POST)
public OperationResultDto clearMap(@RequestBody String[] epAccountIDs, @RequestParam String orgId) {
try {
return enterpriseAccountService.clearMap(epAccountIDs, orgId);
} catch (Exception e) {
logger.error("clearMap error.", e);
}
return OperationResultDto.error("取消对应失败");
}
}
......@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.stdaccount.StandardAccountDto;
import pwc.taxtech.atms.dto.stdaccount.StdAccountFancyTreeDto;
import pwc.taxtech.atms.service.StdAccountService;
......@@ -32,4 +33,20 @@ public class StdAccountController extends BaseController {
}
return Collections.emptyList();
}
@ResponseBody
@ApiOperation(value = "查看对应关系")
@RequestMapping(value = "getStdAccountLinkEtsAccount", method = RequestMethod.GET)
public List<StandardAccountDto> getStdAccountLinkEtsAccount(@RequestParam String orgID,
@RequestParam String accountSetID) {
if (StringUtils.isAnyBlank(orgID, accountSetID)) {
return Collections.emptyList();
}
try {
return stdAccountService.GetStdAccountLinkEtsAccount(orgID, accountSetID);
} catch (Exception e) {
logger.error("getStdAccountLinkEtsAccount error.", e);
}
return Collections.emptyList();
}
}
package pwc.taxtech.atms.dto.accountmapping;
package pwc.taxtech.atms.dao.dao;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -7,19 +7,21 @@ 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 pwc.taxtech.atms.entitiy.EnterpriseAccount;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class AccountMappingDao {
@Autowired
AccountMappingMapper mapper;
@Autowired
EnterpriseAccountDao epAccountDao;
@Autowired
AccountMappingManualDao mappingManualDao;
public void delByEpAccountCodeList(List<String> codeList) {
if (CollectionUtils.isNotEmpty(codeList)) {
......@@ -70,7 +72,6 @@ public class AccountMappingDao {
stdAccountCode = CommonConstants.NullStdCode;
//region 新逻辑
if (!bOverwrite) {
if (!isStdExists(accountSetId, accountCode, industryID, orgId)) {
updateToTable(accountCode, accountSetId, stdAccountCode, industryID, enterpriseAccountID, orgId);
......@@ -78,8 +79,65 @@ public class AccountMappingDao {
} else {
updateToTable(accountCode, accountSetId, stdAccountCode, industryID, enterpriseAccountID, orgId);
}
//endregion
}
public List<AccountMapping> getAccountMapping(String epAccountCode, String epAccountSetID, String orgID) {
AccountMappingExample example = new AccountMappingExample();
AccountMappingExample.Criteria criteria = example.createCriteria();
criteria.andEnterpriseAccountCodeEqualTo(epAccountCode);
criteria.andEnterpriseAccountSetIDEqualTo(epAccountSetID);
criteria.andOrganizationIDEqualTo(orgID);
return mapper.selectByExample(example);
}
public void delMapping(String epAccountCode, String epAccountSetID, String orgID, String industryID) {
AccountMappingExample example = new AccountMappingExample();
AccountMappingExample.Criteria criteria = example.createCriteria();
criteria.andEnterpriseAccountCodeEqualTo(epAccountCode);
criteria.andEnterpriseAccountSetIDEqualTo(epAccountSetID);
criteria.andOrganizationIDEqualTo(orgID);
criteria.andIndustryIDEqualTo(industryID);
mapper.deleteByExample(example);
}
public void delMapping(String epAccountSetID, String orgID, String industryID) {
AccountMappingExample example = new AccountMappingExample();
AccountMappingExample.Criteria criteria = example.createCriteria();
criteria.andEnterpriseAccountSetIDEqualTo(epAccountSetID);
criteria.andOrganizationIDEqualTo(orgID);
criteria.andIndustryIDEqualTo(industryID);
mapper.deleteByExample(example);
}
public void clearMapping(List<EnterpriseAccount> eaList, String industryID,
String orgID, Boolean isToClearAllMapping) {
if (CollectionUtils.isEmpty(eaList)) {
return;
}
List<String> codeList = eaList.stream().map(EnterpriseAccount::getCode).collect(Collectors.toList());
if (!isToClearAllMapping) {
for (EnterpriseAccount ea : eaList) {
delMapping(ea.getCode(), ea.getEnterpriseAccountSetID(), industryID, orgID);
//同时删除手动对应表的对应关系
mappingManualDao.delMapping(ea.getFullName(), ea.getEnterpriseAccountSetID(), industryID, orgID);
clearChildMapping(ea.getCode(), ea.getEnterpriseAccountSetID(), industryID, orgID, codeList);
}
} else {
delMapping(eaList.get(0).getEnterpriseAccountSetID(), industryID, orgID);
}
}
private void clearChildMapping(String eaCode, String setId, String industryID, String orgID, List<String> codeList) {
List<EnterpriseAccount> list = epAccountDao.getEpAccountBy(eaCode, setId);
for (EnterpriseAccount row : list) {
String code = row.getCode();
//如果在本身的id里面包含了,说明第一次遍历的时候已经更新过数据库了,不需要再一次更新
if (codeList.contains(code)) continue;
//string updatesql = "UPDATE EnterpriseAccount SET StdCode=NULL WHERE ID=@ID";
delMapping(code, setId, orgID, industryID);
clearChildMapping(row.getCode(), row.getEnterpriseAccountSetID(), industryID, orgID, codeList);
}
}
}
package pwc.taxtech.atms.dao.dao;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.AccountMappingManualMapper;
......@@ -18,4 +19,14 @@ public class AccountMappingManualDao {
AccountMappingManualExample example = new AccountMappingManualExample();
return Optional.ofNullable(mapper.selectByExample(example));
}
public void delMapping(String fullName,String epAccountSetID,String orgID,String industryID){
AccountMappingManualExample example = new AccountMappingManualExample();
AccountMappingManualExample.Criteria criteria = example.createCriteria();
criteria.andFullNameEqualTo(fullName);
criteria.andEnterpriseAccountSetIDEqualTo(epAccountSetID);
criteria.andOrganizationIDEqualTo(StringUtils.defaultString(orgID));
criteria.andIndustryIDEqualTo(StringUtils.defaultString(industryID));
mapper.deleteByExample(example);
}
}
......@@ -25,11 +25,24 @@ public class EnterpriseAccountDao {
@Autowired
private JdbcTemplate jdbcTemplate;
public Optional<List<EnterpriseAccount>> getByEpAccountSetId(String epAccountSetId) {
public List<EnterpriseAccount> getAll() {
EnterpriseAccountExample example = new EnterpriseAccountExample();
return enterpriseAccountMapper.selectByExample(example);
}
public List<EnterpriseAccount> getByEpAccountSetId(String epAccountSetId) {
EnterpriseAccountExample example = new EnterpriseAccountExample();
EnterpriseAccountExample.Criteria criteria = example.createCriteria();
criteria.andEnterpriseAccountSetIDEqualTo(epAccountSetId);
return enterpriseAccountMapper.selectByExample(example);
}
public List<EnterpriseAccount> getEpAccountBy(String parentCode, String epAccountSetId) {
EnterpriseAccountExample example = new EnterpriseAccountExample();
EnterpriseAccountExample.Criteria criteria = example.createCriteria();
criteria.andParentCodeEqualTo(parentCode);
criteria.andEnterpriseAccountSetIDEqualTo(epAccountSetId);
return Optional.ofNullable(enterpriseAccountMapper.selectByExample(example));
return enterpriseAccountMapper.selectByExample(example);
}
public Optional<EnterpriseAccount> getEpAccount(String epAccountCode, String epAccountSetId) {
......
package pwc.taxtech.atms.dao.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.entitiy.Organization;
@Service
public class OrganizationDao {
@Autowired
private OrganizationMapper organizationMapper;
}
......@@ -2,6 +2,7 @@ package pwc.taxtech.atms.dao.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.constant.enums.StdAccountEnum;
import pwc.taxtech.atms.dao.StandardAccountMapper;
import pwc.taxtech.atms.entitiy.StandardAccount;
import pwc.taxtech.atms.entitiy.StandardAccountExample;
......@@ -21,5 +22,22 @@ public class StandardAccountDao {
return Optional.ofNullable(standardAccountMapper.selectByExample(example));
}
public List<StandardAccount> getByCodeAndIndustryId(String code, String industryId) {
StandardAccountExample example = new StandardAccountExample();
StandardAccountExample.Criteria criteria = example.createCriteria();
criteria.andCodeEqualTo(code);
criteria.andIndustryIDEqualTo(industryId);
return standardAccountMapper.selectByExample(example);
}
public List<StandardAccount> getStdAccount(StdAccountEnum.RuleType ruleType, String industryId,Boolean isActive,Boolean isLeaf) {
StandardAccountExample example = new StandardAccountExample();
StandardAccountExample.Criteria criteria = example.createCriteria();
criteria.andRuleTypeEqualTo(ruleType.getCode());
criteria.andIndustryIDEqualTo(industryId);
criteria.andIsActiveEqualTo(isActive);
criteria.andIsLeafEqualTo(isLeaf);
return standardAccountMapper.selectByExample(example);
}
}
package pwc.taxtech.atms.dto.epaccount;
import com.alibaba.fastjson.annotation.JSONField;
import java.util.List;
import java.util.Map;
public class AccountMapDto {
public String orgID;
@JSONField(name = "EnterpriseAccountCodes")
public String[] enterpriseAccountCodes;
@JSONField(name = "StandardAccountCode")
public String standardAccountCode;
@JSONField(name = "ParentAccountMappingResult")
public Map<String, List<String>> parentAccountMappingResult;
@JSONField(name = "AccountSetID")
public String accountSetID;
public String getOrgID() {
return orgID;
}
public void setOrgID(String orgID) {
this.orgID = orgID;
}
public String[] getEnterpriseAccountCodes() {
return enterpriseAccountCodes;
}
public void setEnterpriseAccountCodes(String[] enterpriseAccountCodes) {
this.enterpriseAccountCodes = enterpriseAccountCodes;
}
public String getStandardAccountCode() {
return standardAccountCode;
}
public void setStandardAccountCode(String standardAccountCode) {
this.standardAccountCode = standardAccountCode;
}
public Map<String, List<String>> getParentAccountMappingResult() {
return parentAccountMappingResult;
}
public void setParentAccountMappingResult(Map<String, List<String>> parentAccountMappingResult) {
this.parentAccountMappingResult = parentAccountMappingResult;
}
public String getAccountSetID() {
return accountSetID;
}
public void setAccountSetID(String accountSetID) {
this.accountSetID = accountSetID;
}
}
......@@ -3,10 +3,7 @@ package pwc.taxtech.atms.service;
import java.util.List;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.epaccount.AccountMappingDto;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountAndValidateInfo;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountDto;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountSetDto;
import pwc.taxtech.atms.dto.epaccount.*;
import pwc.taxtech.atms.entitiy.EnterpriseAccount;
public interface EnterpriseAccountService {
......@@ -104,5 +101,9 @@ public interface EnterpriseAccountService {
OperationResultDto autoMap(String orgId, String accountSetId);
OperationResultDto mapAccount(AccountMapDto accountMapDto);
OperationResultDto clearMap(String[] epAccountIDs, String orgId);
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.common.ServiceException;
import pwc.taxtech.atms.dto.stdaccount.StandardAccountDto;
import pwc.taxtech.atms.dto.stdaccount.StdAccountFancyTreeDto;
import java.util.List;
public interface StdAccountService {
List<StdAccountFancyTreeDto> getStdAccountHierarchy(String orgId) throws ServiceException;
List<StandardAccountDto> GetStdAccountLinkEtsAccount(String orgID, String accountSetID);
}
......@@ -7,9 +7,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.ServiceException;
import pwc.taxtech.atms.constant.EnterpriseAccountConstant;
import pwc.taxtech.atms.constant.enums.StdAccountEnum;
import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.dao.StandardAccountMapper;
import pwc.taxtech.atms.dao.dao.StandardAccountDao;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.stdaccount.StandardAccountDto;
import pwc.taxtech.atms.dto.stdaccount.StdAccountFancyTreeDto;
import pwc.taxtech.atms.entitiy.Organization;
import pwc.taxtech.atms.entitiy.StandardAccount;
......@@ -30,6 +34,8 @@ public class StdAccountServiceImpl extends BaseService implements StdAccountServ
@Autowired
private OrganizationMapper organizationMapper;
@Autowired
private StandardAccountDao standardAccountDao;
@Override
public List<StdAccountFancyTreeDto> getStdAccountHierarchy(String orgId) throws ServiceException {
......@@ -73,6 +79,28 @@ public class StdAccountServiceImpl extends BaseService implements StdAccountServ
return resultList;
}
@Override
public List<StandardAccountDto> GetStdAccountLinkEtsAccount(String orgID, String accountSetID) {
if (StringUtils.isBlank(orgID)) {
return Collections.emptyList();
}
//todo
Organization organization = organizationMapper.selectByPrimaryKey(orgID);
if (organization == null) {
return Collections.emptyList();
}
String industryID = organization.getIndustryID();
List<StandardAccount> stdAccounts = standardAccountDao.getStdAccount(StdAccountEnum.RuleType.TWO, industryID, true, true);
if (CollectionUtils.isEmpty(stdAccounts)) {
stdAccounts = standardAccountDao.getStdAccount(StdAccountEnum.RuleType.TWO, "0", true, true);
}
return Collections.emptyList();
}
private void getSubStdAccount(StdAccountFancyTreeDto node, List<StandardAccount> allList) {
List<StdAccountFancyTreeDto> childList = allList.stream().filter(x -> StringUtils.equals(node.getCode(), x.getParentCode()))
.map(this::rotateToDto).collect(Collectors.toList());
......
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