Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
eff3e8a8
Commit
eff3e8a8
authored
May 21, 2018
by
eddie.woo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
00ce6fbc
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
515 additions
and
29 deletions
+515
-29
EnterpriseAccountConstant.java
.../pwc/taxtech/atms/constant/EnterpriseAccountConstant.java
+18
-0
StdAccountEnum.java
.../java/pwc/taxtech/atms/constant/enums/StdAccountEnum.java
+13
-0
EnterpriseAccountManagerController.java
...h/atms/controller/EnterpriseAccountManagerController.java
+25
-6
StdAccountController.java
...ava/pwc/taxtech/atms/controller/StdAccountController.java
+17
-0
AccountMappingDao.java
...main/java/pwc/taxtech/atms/dao/dao/AccountMappingDao.java
+63
-5
AccountMappingManualDao.java
...ava/pwc/taxtech/atms/dao/dao/AccountMappingManualDao.java
+11
-0
EnterpriseAccountDao.java
...n/java/pwc/taxtech/atms/dao/dao/EnterpriseAccountDao.java
+15
-2
OrganizationDao.java
...c/main/java/pwc/taxtech/atms/dao/dao/OrganizationDao.java
+13
-0
StandardAccountDao.java
...ain/java/pwc/taxtech/atms/dao/dao/StandardAccountDao.java
+18
-0
AccountMapDto.java
...in/java/pwc/taxtech/atms/dto/epaccount/AccountMapDto.java
+58
-0
EnterpriseAccountService.java
...va/pwc/taxtech/atms/service/EnterpriseAccountService.java
+6
-5
StdAccountService.java
...main/java/pwc/taxtech/atms/service/StdAccountService.java
+3
-0
EnterpriseAccountServiceImpl.java
...xtech/atms/service/impl/EnterpriseAccountServiceImpl.java
+227
-11
StdAccountServiceImpl.java
.../pwc/taxtech/atms/service/impl/StdAccountServiceImpl.java
+28
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/constant/EnterpriseAccountConstant.java
View file @
eff3e8a8
...
...
@@ -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
()
...
...
atms-api/src/main/java/pwc/taxtech/atms/constant/enums/StdAccountEnum.java
View file @
eff3e8a8
...
...
@@ -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"
,
"负债"
),
...
...
atms-api/src/main/java/pwc/taxtech/atms/controller/EnterpriseAccountManagerController.java
View file @
eff3e8a8
...
...
@@ -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
(
"取消对应失败"
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/controller/StdAccountController.java
View file @
eff3e8a8
...
...
@@ -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
();
}
}
atms-api/src/main/java/pwc/taxtech/atms/d
to/accountmapping
/AccountMappingDao.java
→
atms-api/src/main/java/pwc/taxtech/atms/d
ao/dao
/AccountMappingDao.java
View file @
eff3e8a8
package
pwc
.
taxtech
.
atms
.
d
to
.
accountmapping
;
package
pwc
.
taxtech
.
atms
.
d
ao
.
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
);
}
}
}
atms-api/src/main/java/pwc/taxtech/atms/dao/dao/AccountMappingManualDao.java
View file @
eff3e8a8
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
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/dao/dao/EnterpriseAccountDao.java
View file @
eff3e8a8
...
...
@@ -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
)
{
...
...
atms-api/src/main/java/pwc/taxtech/atms/dao/dao/OrganizationDao.java
0 → 100644
View file @
eff3e8a8
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
;
}
atms-api/src/main/java/pwc/taxtech/atms/dao/dao/StandardAccountDao.java
View file @
eff3e8a8
...
...
@@ -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
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/dto/epaccount/AccountMapDto.java
0 → 100644
View file @
eff3e8a8
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
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/service/EnterpriseAccountService.java
View file @
eff3e8a8
...
...
@@ -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
{
...
...
@@ -103,6 +100,10 @@ public interface EnterpriseAccountService {
List
<
EnterpriseAccountDto
>
getList
(
String
epAccountSetID
,
String
orgId
,
String
filterType
);
OperationResultDto
autoMap
(
String
orgId
,
String
accountSetId
);
OperationResultDto
mapAccount
(
AccountMapDto
accountMapDto
);
OperationResultDto
clearMap
(
String
[]
epAccountIDs
,
String
orgId
);
}
atms-api/src/main/java/pwc/taxtech/atms/service/StdAccountService.java
View file @
eff3e8a8
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
);
}
atms-api/src/main/java/pwc/taxtech/atms/service/impl/EnterpriseAccountServiceImpl.java
View file @
eff3e8a8
...
...
@@ -3,6 +3,7 @@
package
pwc
.
taxtech
.
atms
.
service
.
impl
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -17,6 +18,7 @@ import pwc.taxtech.atms.common.message.LogMessage;
import
pwc.taxtech.atms.constant.EnterpriseAccountConstant
;
import
pwc.taxtech.atms.constant.IndustryConstant
;
import
pwc.taxtech.atms.constant.enums.AccountRuleEnum
;
import
pwc.taxtech.atms.dao.AccountMappingManualMapper
;
import
pwc.taxtech.atms.dao.dao.AccountMappingManualDao
;
import
pwc.taxtech.atms.dao.dao.EnterpriseAccountDao
;
import
pwc.taxtech.atms.dao.dao.EnterpriseAccountSetOrgDao
;
...
...
@@ -25,12 +27,9 @@ import pwc.taxtech.atms.dto.OperationLogDto;
import
pwc.taxtech.atms.dto.OperationResultDto
;
import
pwc.taxtech.atms.dto.UpdateLogParams
;
import
pwc.taxtech.atms.dto.ValidateInfoDto
;
import
pwc.taxtech.atms.d
to.accountmapping
.AccountMappingDao
;
import
pwc.taxtech.atms.d
ao.dao
.AccountMappingDao
;
import
pwc.taxtech.atms.dto.accountmapping.AccountMappingManualDto
;
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.dto.stdaccount.StandardAccountDto
;
import
pwc.taxtech.atms.entitiy.*
;
import
pwc.taxtech.atms.service.AccountService
;
...
...
@@ -60,6 +59,8 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
private
EnterpriseAccountSetOrgDao
epAccountSetOrgDao
;
@Autowired
private
AccountMappingDao
accountMappingDao
;
@Autowired
private
AccountMappingManualMapper
mappingManualMapper
;
private
Map
<
String
,
List
<
String
>>
mapParentAccountResult
;
...
...
@@ -718,7 +719,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
//region 获取基础信息
//获取指定企业账套下的企业科目集合并转化为DTO
List
<
EnterpriseAccount
>
epAccountList
=
enterpriseAccountDao
.
getByEpAccountSetId
(
setOrg
.
getEnterpriseAccountSetID
())
.
get
()
;
List
<
EnterpriseAccount
>
epAccountList
=
enterpriseAccountDao
.
getByEpAccountSetId
(
setOrg
.
getEnterpriseAccountSetID
());
List
<
EnterpriseAccountDto
>
accountDtoList
=
epAccountList
.
stream
().
map
(
x
->
{
return
CommonUtils
.
copyProperties
(
x
,
new
EnterpriseAccountDto
());
}).
collect
(
Collectors
.
toList
());
...
...
@@ -894,8 +895,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
accountMappingDao
.
mapStdAccountByCode
(
setOrg
.
getEnterpriseAccountSetID
(),
mappedStdAccount
.
getParentCode
(),
accountParent
.
getCode
(),
industryId
,
orgId
,
true
,
0
);
}
else
{
//todo 全局变量
// this.MapParentAccountResult = new Dictionary<string, List<string>>();
mapParentAccountResult
=
Maps
.
newHashMap
();
List
<
String
>
codeList
=
Lists
.
newArrayList
();
if
(
CollectionUtils
.
isNotEmpty
(
accountParentChildList
))
{
//只需要把子科目加入其中一个就可以了
...
...
@@ -929,6 +929,224 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
}
}
@Transactional
@Override
public
OperationResultDto
mapAccount
(
AccountMapDto
accountMapDto
)
{
//region 获取相关的机构对象,标准科目对象, 账套对象
Organization
organization
=
organizationMapper
.
selectByPrimaryKey
(
accountMapDto
.
getOrgID
());
String
industryID
;
if
(
organization
==
null
)
{
return
OperationResultDto
.
error
(
EnterpriseAccountConstant
.
OrgNotExist
);
}
industryID
=
organization
.
getIndustryID
();
//通过该机构的行业ID和标准科目的Code获取相关的标准科目对象
List
<
StandardAccount
>
tmpList
=
standardAccountDao
.
getByCodeAndIndustryId
(
accountMapDto
.
getStandardAccountCode
(),
industryID
);
if
(
CollectionUtils
.
isEmpty
(
tmpList
))
{
return
OperationResultDto
.
error
(
EnterpriseAccountConstant
.
StdCodeIsNotExist
);
}
StandardAccount
stdAccount
=
tmpList
.
get
(
0
);
//通过机构的ID获取与之机构关联的账套对象
//以下通过机构ID获取账套是错误的,因为一个机构存在多个账套,不知道用户选择的是哪个账套
//var accountSet = this._dbContext.Set<EnterpriseAccountSetOrg>().Where(x => x.OrganizationID == organization.ID).FirstOrDefault();
String
accountSetID
=
accountMapDto
.
getAccountSetID
();
if
(
StringUtils
.
isBlank
(
accountSetID
))
{
return
OperationResultDto
.
error
(
EnterpriseAccountConstant
.
AccountSetNotExist
);
}
List
<
EnterpriseAccount
>
eaList
=
enterpriseAccountDao
.
getByEpAccountSetId
(
accountSetID
);
//获取账套信息
EnterpriseAccountSet
accountSet
=
enterpriseAccountSetMapper
.
selectByPrimaryKey
(
accountSetID
);
//endregion
//region 手动对应当前及所有子科目
for
(
String
eAccountCode
:
accountMapDto
.
getEnterpriseAccountCodes
())
{
Optional
<
EnterpriseAccount
>
opEpAccount
=
eaList
.
stream
().
filter
(
x
->
StringUtils
.
equals
(
x
.
getCode
(),
eAccountCode
)).
findFirst
();
EnterpriseAccount
eAccount
;
if
(
opEpAccount
.
isPresent
())
{
eAccount
=
opEpAccount
.
get
();
//region 获取对应前旧对应关系所所对应的标准科目,为了记录日志
List
<
AccountMapping
>
mappingList
=
accountMappingDao
.
getAccountMapping
(
eAccountCode
,
accountSetID
,
organization
.
getID
());
AccountMapping
mapping
;
String
originalCode
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
mappingList
))
{
mapping
=
mappingList
.
get
(
0
);
originalCode
=
mapping
.
getStandardAccountCode
();
}
//endregion
accountMappingDao
.
mapStdAccountByCode
(
accountSetID
,
stdAccount
.
getCode
(),
eAccount
.
getCode
(),
industryID
,
organization
.
getID
(),
true
,
0
);
//region 根据新的需求,需要将手动对应的记录记载下来,在下次自动对应的时候需要优先考虑
AccountMappingManual
manual
=
new
AccountMappingManual
();
manual
.
setID
(
CommonUtils
.
getUUID
());
manual
.
setFullName
(
eAccount
.
getFullName
());
manual
.
setStandardCode
(
stdAccount
.
getCode
());
manual
.
setOrganizationID
(
organization
.
getID
());
manual
.
setEnterpriseAccountSetID
(
accountSetID
);
manual
.
setUpdateBy
(
authUserHelper
.
getCurrentAuditor
());
manual
.
setUpdateTime
(
new
Date
());
addManualMappingRecord
(
manual
);
//endregion
//1. 如果将标准科目对应到企业科目的父级,那么该企业科目的子级都对应到该标准科目
updateManualMapChildAccount
(
eaList
,
eAccount
,
stdAccount
,
accountSetID
,
industryID
,
organization
.
getID
());
//region 添加日志
OperationLogDto
operationLogDto
=
new
OperationLogDto
();
operationLogDto
.
setOperationContent
(
eAccount
.
getCode
()
+
CommonConstants
.
DashSignSeparator
+
eAccount
.
getName
());
operationLogDto
.
setAction
(
OperationAction
.
ManualMapping
.
value
());
operationLogDto
.
setOperationObject
(
organization
.
getName
()
+
"-"
+
accountSet
.
getName
());
operationLogDto
.
setOriginalState
(
StringUtils
.
isBlank
(
originalCode
)
?
StringUtils
.
EMPTY
:
originalCode
+
CommonConstants
.
DashSignSeparator
+
stdAccount
.
getName
());
operationLogDto
.
setUpdateState
(
stdAccount
.
getCode
()
+
CommonConstants
.
DashSignSeparator
+
stdAccount
.
getName
());
operationLogDto
.
setModule
(
OperationModule
.
SubjectCorresponding
.
value
());
operationLogDto
.
setComment
(
StringUtils
.
EMPTY
);
operationLogDto
.
setLogType
(
OperateLogType
.
OperationLogSubject
.
value
());
operationLogService
.
addOperationLog
(
operationLogDto
);
//endregion
}
}
//endregion
//region 手动对应当前的所有父级科目
//清空ParentAccountMapResult
this
.
mapParentAccountResult
=
Maps
.
newHashMap
();
mapAccountUpdateParent
(
Lists
.
newArrayList
(
accountMapDto
.
getEnterpriseAccountCodes
()),
accountSetID
,
industryID
,
organization
.
getID
(),
true
);
//endregion
AccountMapDto
mapDto
=
new
AccountMapDto
();
mapDto
.
setParentAccountMappingResult
(
this
.
mapParentAccountResult
);
return
OperationResultDto
.
success
(
mapDto
);
}
@Override
public
OperationResultDto
clearMap
(
String
[]
epAccountIDs
,
String
orgId
)
{
if
(
epAccountIDs
!=
null
&&
StringUtils
.
isNotBlank
(
orgId
))
{
boolean
isToClearAllMapping
=
false
;
Organization
organization
=
organizationMapper
.
selectByPrimaryKey
(
orgId
);
if
(
organization
==
null
)
{
return
OperationResultDto
.
error
(
EnterpriseAccountConstant
.
OrgNotExist
);
}
String
industryID
=
organization
.
getIndustryID
();
List
<
EnterpriseAccount
>
eaAllList
=
enterpriseAccountDao
.
getAll
();
List
<
String
>
enterpriseAccountIDs
=
Lists
.
newArrayList
(
epAccountIDs
);
List
<
EnterpriseAccount
>
enterpriseAccountList
=
eaAllList
.
stream
().
filter
(
x
->
enterpriseAccountIDs
.
contains
(
x
.
getID
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
enterpriseAccountList
))
{
//获取该账套下有多少企业科目
String
enterprisetAccountSetId
=
enterpriseAccountList
.
get
(
0
).
getEnterpriseAccountSetID
();
long
countOfEnterpriseAccount
=
eaAllList
.
stream
().
filter
(
x
->
StringUtils
.
equals
(
x
.
getEnterpriseAccountSetID
(),
enterprisetAccountSetId
)).
count
();
if
(
countOfEnterpriseAccount
==
enterpriseAccountList
.
size
())
{
isToClearAllMapping
=
true
;
}
accountMappingDao
.
clearMapping
(
enterpriseAccountList
,
industryID
,
orgId
,
isToClearAllMapping
);
//如果该账套下的企业科目和传进来需要取消的个数一样,说明是全部取消,没有必须要再去更新父级状态
if
(!
isToClearAllMapping
)
{
//清空ParentAccountMapResult
this
.
mapParentAccountResult
=
Maps
.
newHashMap
();
clearParentMapping
(
eaAllList
,
enterpriseAccountList
,
enterprisetAccountSetId
,
industryID
,
orgId
);
}
//region 添加日志
String
enterpriseAccountID
=
enterpriseAccountIDs
.
get
(
0
);
//获取账套信息
EnterpriseAccountSet
accountSet
=
enterpriseAccountSetMapper
.
selectByPrimaryKey
(
enterprisetAccountSetId
);
//记载取消的企业科目
String
clearEACodeList
=
StringUtils
.
join
(
enterpriseAccountList
.
stream
().
map
(
x
->
x
.
getCode
())
.
collect
(
Collectors
.
toList
()),
","
);
OperationLogDto
operationLogDto
=
new
OperationLogDto
();
operationLogDto
.
setOperationContent
(
EnterpriseAccountConstant
.
SubjectCorresponding
);
operationLogDto
.
setAction
(
OperationAction
.
CancelMapping
.
value
());
operationLogDto
.
setOperationObject
(
accountSet
!=
null
?
organization
.
getName
()
+
"-"
+
accountSet
.
getName
()
:
organization
.
getName
());
operationLogDto
.
setOriginalState
(
StringUtils
.
EMPTY
);
operationLogDto
.
setUpdateState
(
StringUtils
.
EMPTY
);
operationLogDto
.
setModule
(
OperationModule
.
SubjectCorresponding
.
value
());
operationLogDto
.
setComment
(
isToClearAllMapping
?
StringUtils
.
EMPTY
:
clearEACodeList
);
operationLogDto
.
setLogType
(
OperateLogType
.
OperationLogSubject
.
value
());
operationLogService
.
addOperationLog
(
operationLogDto
);
//endregion
AccountMapDto
mapDto
=
new
AccountMapDto
();
mapDto
.
setParentAccountMappingResult
(
this
.
mapParentAccountResult
);
return
OperationResultDto
.
success
(
mapDto
);
}
}
return
OperationResultDto
.
error
(
EnterpriseAccountConstant
.
NoAccountNeedClear
);
}
private
void
clearParentMapping
(
List
<
EnterpriseAccount
>
eaAllList
,
List
<
EnterpriseAccount
>
eaClearList
,
String
enterpriseAccountSetID
,
String
industryID
,
String
orgID
)
{
for
(
EnterpriseAccount
ea
:
eaClearList
)
{
Optional
<
EnterpriseAccount
>
eaParentOp
=
eaAllList
.
stream
().
filter
(
x
->
StringUtils
.
equals
(
x
.
getCode
(),
ea
.
getParentCode
())
&&
StringUtils
.
equals
(
x
.
getEnterpriseAccountSetID
(),
enterpriseAccountSetID
)).
findFirst
();
if
(
eaParentOp
.
isPresent
())
{
EnterpriseAccount
eaParent
=
eaParentOp
.
get
();
//删除科目对应表里面的对应关系
accountMappingDao
.
delMapping
(
eaParent
.
getCode
(),
enterpriseAccountSetID
,
orgID
,
industryID
);
//添加到list中为了更新UI界面
addMapParentAccountResult
(
eaParent
.
getCode
(),
Lists
.
newArrayList
(
null
,
StringUtils
.
EMPTY
));
//删除父级以及更高层的对应关系
clearParentMappingRecursion
(
eaAllList
,
eaParent
,
enterpriseAccountSetID
,
industryID
,
orgID
);
}
}
}
private
void
clearParentMappingRecursion
(
List
<
EnterpriseAccount
>
eaAllList
,
EnterpriseAccount
eaParent
,
String
enterpriseAccountSetID
,
String
industryID
,
String
orgID
)
{
if
(
StringUtils
.
isNotBlank
(
eaParent
.
getParentCode
()))
{
Optional
<
EnterpriseAccount
>
parentAccountOp
=
eaAllList
.
stream
().
filter
(
x
->
StringUtils
.
equals
(
x
.
getCode
(),
eaParent
.
getParentCode
())
&&
StringUtils
.
equals
(
x
.
getEnterpriseAccountSetID
(),
enterpriseAccountSetID
)).
findFirst
();
if
(
parentAccountOp
.
isPresent
())
{
EnterpriseAccount
parentAccount
=
parentAccountOp
.
get
();
//删除科目对应表里面的对应关系
accountMappingDao
.
delMapping
(
parentAccount
.
getCode
(),
enterpriseAccountSetID
,
orgID
,
industryID
);
//添加到list中为了更新UI界面
addMapParentAccountResult
(
parentAccount
.
getCode
(),
Lists
.
newArrayList
(
null
,
StringUtils
.
EMPTY
));
clearParentMappingRecursion
(
eaAllList
,
parentAccount
,
enterpriseAccountSetID
,
industryID
,
orgID
);
}
}
}
private
void
updateManualMapChildAccount
(
List
<
EnterpriseAccount
>
eaList
,
EnterpriseAccount
eAccountCode
,
StandardAccount
stdAccount
,
String
accountSetID
,
String
industryID
,
String
orgID
)
{
List
<
EnterpriseAccount
>
eAccount
=
eaList
.
stream
().
filter
(
x
->
StringUtils
.
equals
(
x
.
getParentCode
(),
eAccountCode
.
getCode
()))
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
eAccount
))
{
for
(
EnterpriseAccount
ea
:
eAccount
)
{
accountMappingDao
.
mapStdAccountByCode
(
accountSetID
,
stdAccount
.
getCode
(),
ea
.
getCode
(),
industryID
,
orgID
,
true
,
0
);
//region 根据新的需求,需要将手动对应的记录记载下来,在下次自动对应的时候需要优先考虑
AccountMappingManual
manual
=
new
AccountMappingManual
();
manual
.
setID
(
CommonUtils
.
getUUID
());
manual
.
setFullName
(
ea
.
getFullName
());
manual
.
setStandardCode
(
stdAccount
.
getCode
());
manual
.
setOrganizationID
(
orgID
);
manual
.
setEnterpriseAccountSetID
(
accountSetID
);
manual
.
setIndustryID
(
industryID
);
manual
.
setUpdateBy
(
authUserHelper
.
getCurrentAuditor
());
manual
.
setUpdateTime
(
new
Date
());
addManualMappingRecord
(
manual
);
//endregion
updateManualMapChildAccount
(
eaList
,
ea
,
stdAccount
,
accountSetID
,
industryID
,
orgID
);
}
}
}
public
void
addManualMappingRecord
(
AccountMappingManual
manualMapping
)
{
mappingManualDao
.
delMapping
(
manualMapping
.
getFullName
(),
manualMapping
.
getEnterpriseAccountSetID
(),
manualMapping
.
getOrganizationID
(),
manualMapping
.
getIndustryID
());
mappingManualMapper
.
insertSelective
(
manualMapping
);
}
public
List
<
EnterpriseAccountDto
>
getAllActiveAccounts
(
String
orgID
,
String
industryId
,
String
accountSetId
,
Boolean
isActive
)
{
List
<
Map
<
String
,
Object
>>
list
=
enterpriseAccountDao
.
selectAccounts
(
industryId
,
accountSetId
,
orgID
,
EnterpriseAccountConstant
.
InvalidId
,
EnterpriseAccountConstant
.
InvalidId
,
EnterpriseAccountConstant
.
InvalidId
,
isActive
);
...
...
@@ -981,9 +1199,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
}
if
(
exceptionFlag
)
{
//todo
// this.mapParentAccountResult = new Dictionary<string, List<string>>();
this
.
mapParentAccountResult
=
Maps
.
newHashMap
();
mapAccountUpdateParent
(
enterpriseCodeList
,
accountSetId
,
industryID
,
orgID
,
false
);
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/impl/StdAccountServiceImpl.java
View file @
eff3e8a8
...
...
@@ -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
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment