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
2c0845dd
Commit
2c0845dd
authored
Jul 01, 2019
by
frank.xa.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed org -- frank
parent
995a3328
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
325 additions
and
54 deletions
+325
-54
OrganizationStructureController.java
...tech/atms/controller/OrganizationStructureController.java
+57
-0
OrganizationServiceImpl.java
...wc/taxtech/atms/service/impl/OrganizationServiceImpl.java
+54
-54
OrganizationStructureServiceImpl.java
...h/atms/service/impl/OrganizationStructureServiceImpl.java
+214
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/controller/OrganizationStructureController.java
0 → 100644
View file @
2c0845dd
package
pwc
.
taxtech
.
atms
.
controller
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
pwc.taxtech.atms.dto.ApiResultDto
;
import
pwc.taxtech.atms.dto.IdModel
;
import
pwc.taxtech.atms.dto.OrganizationStructureDto
;
import
pwc.taxtech.atms.dto.OrganizationStructureInputDto
;
import
pwc.taxtech.atms.service.impl.OrganizationStructureServiceImpl
;
import
java.util.List
;
@RestController
@RequestMapping
(
"/api/v1/organizationstructure"
)
public
class
OrganizationStructureController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
OrganizationStructureController
.
class
);
@Autowired
private
OrganizationStructureServiceImpl
organizationStructureService
;
// @ApiOperation(value = "主数据机构层级查询")
@RequestMapping
(
value
=
"/getlist"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
List
<
OrganizationStructureDto
>
getOrganizationStructures
()
{
logger
.
debug
(
"OrganizationStructureController /getlist"
);
return
organizationStructureService
.
getOrganizationStructures
();
}
// @ApiOperation(value = "主数据机构层级增加")
// @ApiImplicitParam(name = "organizationStructureDtoList", value = "organizationStructureDto List", required = true, dataType = "List<OrganizationStructureDto>")
@RequestMapping
(
value
=
"/add"
,
method
=
RequestMethod
.
POST
)
public
ApiResultDto
addOrganizationStructures
(
@RequestBody
List
<
OrganizationStructureInputDto
>
organizationStructureDtoList
)
{
logger
.
debug
(
"OrganizationStructureController /add"
);
return
organizationStructureService
.
addOrganizationStructures
(
organizationStructureDtoList
);
}
// @ApiOperation(value = "主数据机构层级删除")
// @ApiImplicitParam(name = "idModel", value = "idModel", required = true, dataType = "IdModel")
@RequestMapping
(
value
=
"/delete"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
Integer
deleteOrganizationStructure
(
@RequestBody
IdModel
idModel
)
{
logger
.
debug
(
"OrganizationStructureController /delete"
);
return
organizationStructureService
.
deleteOrganizationStructure
(
idModel
);
}
// @ApiOperation(value = "主数据机构层级修改")
// @ApiImplicitParam(name = "organizationStructureDtoList", value = "organizationStructureDto List", required = true, dataType = "List<OrganizationStructureDto>")
@RequestMapping
(
method
=
RequestMethod
.
PUT
)
public
@ResponseBody
ApiResultDto
updateOrganizationStructure
(
@RequestBody
List
<
OrganizationStructureInputDto
>
organizationStructureDtoList
)
{
logger
.
debug
(
"OrganizationStructureController update"
);
return
organizationStructureService
.
updateOrganizationStructures
(
organizationStructureDtoList
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/service/impl/OrganizationServiceImpl.java
View file @
2c0845dd
...
@@ -2021,7 +2021,7 @@ public class OrganizationServiceImpl extends BaseService{
...
@@ -2021,7 +2021,7 @@ public class OrganizationServiceImpl extends BaseService{
}
}
// 添加账套
// 添加账套
//
if(!orgDto.getOversea()){
if
(!
orgDto
.
getOversea
()){
// for (EnterpriseAccountSetOrgDto p : orgDto.getEnterpriseAccountSetOrgList()) {
// for (EnterpriseAccountSetOrgDto p : orgDto.getEnterpriseAccountSetOrgList()) {
// EnterpriseAccountSetOrg enterpriseAccountSetOrg = new EnterpriseAccountSetOrg();
// EnterpriseAccountSetOrg enterpriseAccountSetOrg = new EnterpriseAccountSetOrg();
// enterpriseAccountSetOrg.setId(CommonUtils.getUUID());
// enterpriseAccountSetOrg.setId(CommonUtils.getUUID());
...
@@ -2067,19 +2067,19 @@ public class OrganizationServiceImpl extends BaseService{
...
@@ -2067,19 +2067,19 @@ public class OrganizationServiceImpl extends BaseService{
// newRule.setUpdateTime(now);
// newRule.setUpdateTime(now);
// taxPayerReportRuleMapper.insert(newRule);
// taxPayerReportRuleMapper.insert(newRule);
// }
// }
//
for (OrganizationServiceTemplateGroupDto p : orgDto.getOrganizationServiceTemplateGroupList()) {
for
(
OrganizationServiceTemplateGroupDto
p
:
orgDto
.
getOrganizationServiceTemplateGroupList
())
{
//
OrganizationServiceTemplateGroup orgServiceTempGroup = new OrganizationServiceTemplateGroup();
OrganizationServiceTemplateGroup
orgServiceTempGroup
=
new
OrganizationServiceTemplateGroup
();
//
orgServiceTempGroup.setId(distributedIdService.nextId());
orgServiceTempGroup
.
setId
(
distributedIdService
.
nextId
());
//
orgServiceTempGroup.setOrganizationId(orgDto.getId());
orgServiceTempGroup
.
setOrganizationId
(
orgDto
.
getId
());
//
orgServiceTempGroup.setServiceTypeId(p.getServiceTypeId());
orgServiceTempGroup
.
setServiceTypeId
(
p
.
getServiceTypeId
());
//
orgServiceTempGroup.setTemplateGroupId(p.getTemplateGroupId());
orgServiceTempGroup
.
setTemplateGroupId
(
p
.
getTemplateGroupId
());
//
organizationServiceTemplateGroupMapper.insert(orgServiceTempGroup);
organizationServiceTemplateGroupMapper
.
insert
(
orgServiceTempGroup
);
//
}
}
//
//
// CopyModelTree(orgDto);//__restoreroy__
// CopyModelTree(orgDto);//__restoreroy__
//
//
addOrgSelfDimensionList(orgDto);
addOrgSelfDimensionList
(
orgDto
);
//
}
}
// C#中的内部类CommonLogParams 在JAVA中已经被合并到OperationLogDto中
// C#中的内部类CommonLogParams 在JAVA中已经被合并到OperationLogDto中
UpdateLogParams
tempCommonLogParms
=
new
UpdateLogParams
();
UpdateLogParams
tempCommonLogParms
=
new
UpdateLogParams
();
tempCommonLogParms
.
setOperationModule
(
Organization
.
value
());
tempCommonLogParms
.
setOperationModule
(
Organization
.
value
());
...
@@ -2434,13 +2434,13 @@ public class OrganizationServiceImpl extends BaseService{
...
@@ -2434,13 +2434,13 @@ public class OrganizationServiceImpl extends BaseService{
//
//
// EnterpriseAccountSetOrgExample e2 = new EnterpriseAccountSetOrgExample();
// EnterpriseAccountSetOrgExample e2 = new EnterpriseAccountSetOrgExample();
for
(
EnterpriseAccountSetOrgDto
p
:
orgDto
.
getEnterpriseAccountSetOrgList
())
{
//
for (EnterpriseAccountSetOrgDto p : orgDto.getEnterpriseAccountSetOrgList()) {
p
.
setEffectiveDate
(
Strings
.
isBlank
(
p
.
getEffectiveDateStr
())
?
p
.
getEffectiveDate
()
//
p.setEffectiveDate(Strings.isBlank(p.getEffectiveDateStr()) ? p.getEffectiveDate()
:
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd"
).
parseDateTime
(
p
.
getEffectiveDateStr
()
+
"-01"
)
//
: DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(p.getEffectiveDateStr() + "-01")
.
toDate
());
//
.toDate());
p
.
setExpiredDate
(
Strings
.
isBlank
(
p
.
getExpiredDateStr
())
?
p
.
getExpiredDate
()
//
p.setExpiredDate(Strings.isBlank(p.getExpiredDateStr()) ? p.getExpiredDate()
:
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd"
).
parseDateTime
(
p
.
getExpiredDateStr
()
+
"-01"
)
//
: DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(p.getExpiredDateStr() + "-01")
.
plusMonths
(
1
).
minusDays
(
1
).
toDate
());
//
.plusMonths(1).minusDays(1).toDate());
// if (enterpriseAccountSetOrgList != null
// if (enterpriseAccountSetOrgList != null
// && enterpriseAccountSetOrgList.stream().anyMatch(t -> Strings.equals(t.getId(), p.getId()))) {
// && enterpriseAccountSetOrgList.stream().anyMatch(t -> Strings.equals(t.getId(), p.getId()))) {
// EnterpriseAccountSetOrg tempDto = enterpriseAccountSetOrgList.stream()
// EnterpriseAccountSetOrg tempDto = enterpriseAccountSetOrgList.stream()
...
@@ -2478,18 +2478,18 @@ public class OrganizationServiceImpl extends BaseService{
...
@@ -2478,18 +2478,18 @@ public class OrganizationServiceImpl extends BaseService{
// .forEach(delSet -> enterpriseAccountSetOrgMapper.deleteByPrimaryKey(delSet.getId()));
// .forEach(delSet -> enterpriseAccountSetOrgMapper.deleteByPrimaryKey(delSet.getId()));
// }
// }
OrganizationServiceTemplateGroupExample
oSTGExample
=
new
OrganizationServiceTemplateGroupExample
();
//
OrganizationServiceTemplateGroupExample oSTGExample = new OrganizationServiceTemplateGroupExample();
pwc
.
taxtech
.
atms
.
entity
.
OrganizationServiceTemplateGroupExample
.
Criteria
oSTGCriteria
=
oSTGExample
//
pwc.taxtech.atms.entity.OrganizationServiceTemplateGroupExample.Criteria oSTGCriteria = oSTGExample
.
createCriteria
();
//
.createCriteria();
if
(
orgDto
.
getId
()
!=
null
)
{
//
if (orgDto.getId() != null) {
oSTGCriteria
.
andOrganizationIdEqualTo
(
orgDto
.
getId
());
//
oSTGCriteria.andOrganizationIdEqualTo(orgDto.getId());
}
else
{
//
} else {
oSTGCriteria
.
andOrganizationIdIsNull
();
//
oSTGCriteria.andOrganizationIdIsNull();
}
//
}
List
<
OrganizationServiceTemplateGroup
>
currentOrganizationServiceTemplateGroupList
=
organizationServiceTemplateGroupMapper
//
List<OrganizationServiceTemplateGroup> currentOrganizationServiceTemplateGroupList = organizationServiceTemplateGroupMapper
.
selectByExample
(
oSTGExample
);
//
.selectByExample(oSTGExample);
//
List
<
OrganizationServiceTemplateGroup
>
updateOrganizationServiceTemplateGroupList
=
new
ArrayList
<>();
//
List<OrganizationServiceTemplateGroup> updateOrganizationServiceTemplateGroupList = new ArrayList<>();
// TaxPayerReportRuleExample taxExample = new TaxPayerReportRuleExample();
// TaxPayerReportRuleExample taxExample = new TaxPayerReportRuleExample();
// taxExample.or().andIsDefaultEqualTo(true);
// taxExample.or().andIsDefaultEqualTo(true);
// Assert.notNull(orgDto.getId(), "orgDto id null exception on updateOrg");
// Assert.notNull(orgDto.getId(), "orgDto id null exception on updateOrg");
...
@@ -2499,16 +2499,16 @@ public class OrganizationServiceImpl extends BaseService{
...
@@ -2499,16 +2499,16 @@ public class OrganizationServiceImpl extends BaseService{
// TaxPayerReportRule activeRule = reportRules.stream()
// TaxPayerReportRule activeRule = reportRules.stream()
// .filter(t -> t.getOrganizationId() == null ? false : t.getOrganizationId().contains(orgDto.getId()))
// .filter(t -> t.getOrganizationId() == null ? false : t.getOrganizationId().contains(orgDto.getId()))
// .findFirst().orElse(null);
// .findFirst().orElse(null);
// C#中在此处定义的defaultRule在下文中未被引用,JAVA中将其删除
//
// C#中在此处定义的defaultRule在下文中未被引用,JAVA中将其删除
//
// 更新机构服务
//
// 更新机构服务
currentOrganizationServiceTemplateGroupList
.
stream
()
//
currentOrganizationServiceTemplateGroupList.stream()
.
forEach
(
tg
->
organizationServiceTemplateGroupMapper
.
deleteByPrimaryKey
(
tg
.
getId
()));
//
.forEach(tg -> organizationServiceTemplateGroupMapper.deleteByPrimaryKey(tg.getId()));
//
// For VAT, update Rule Engine tables instead of
//
// For VAT, update Rule Engine tables instead of
OrganizationServiceTemplateGroupDto
vatSetting
=
orgDto
.
getOrganizationServiceTemplateGroupList
().
stream
()
//
OrganizationServiceTemplateGroupDto vatSetting = orgDto.getOrganizationServiceTemplateGroupList().stream()
.
filter
(
t
->
Strings
.
equals
(
t
.
getServiceTypeId
(),
ServiceTypeEnum
.
VAT
.
value
().
toString
()))
//
.filter(t -> Strings.equals(t.getServiceTypeId(), ServiceTypeEnum.VAT.value().toString()))
.
findFirst
().
orElse
(
null
);
//
.findFirst().orElse(null);
// if (vatSetting != null) {
// if (vatSetting != null) {
// TemplateGroup templateGrp = vatSetting.getTemplateGroupId() != null
// TemplateGroup templateGrp = vatSetting.getTemplateGroupId() != null
// ? templateGroupMapper.selectByPrimaryKey(vatSetting.getTemplateGroupId())
// ? templateGroupMapper.selectByPrimaryKey(vatSetting.getTemplateGroupId())
...
@@ -2567,16 +2567,16 @@ public class OrganizationServiceImpl extends BaseService{
...
@@ -2567,16 +2567,16 @@ public class OrganizationServiceImpl extends BaseService{
// }
// }
// } else if (activeRule != null) { // If no setting, remove non-default rule
// } else if (activeRule != null) { // If no setting, remove non-default rule
// taxPayerReportRuleMapper.deleteByPrimaryKey(activeRule.getId());
// taxPayerReportRuleMapper.deleteByPrimaryKey(activeRule.getId());
}
// for (OrganizationServiceTemplateGroupDto p : orgDto.getOrganizationServiceTemplateGroupList()) {
// OrganizationServiceTemplateGroup temp = new OrganizationServiceTemplateGroup();
// temp.setId(distributedIdService.nextId());
// temp.setOrganizationId(orgDto.getId());
// temp.setServiceTypeId(p.getServiceTypeId());
// temp.setTemplateGroupId(p.getTemplateGroupId());
//// updateOrganizationServiceTemplateGroupList.add(temp);
// organizationServiceTemplateGroupMapper.insertSelective(temp);
// }
// }
for
(
OrganizationServiceTemplateGroupDto
p
:
orgDto
.
getOrganizationServiceTemplateGroupList
())
{
OrganizationServiceTemplateGroup
temp
=
new
OrganizationServiceTemplateGroup
();
temp
.
setId
(
distributedIdService
.
nextId
());
temp
.
setOrganizationId
(
orgDto
.
getId
());
temp
.
setServiceTypeId
(
p
.
getServiceTypeId
());
temp
.
setTemplateGroupId
(
p
.
getTemplateGroupId
());
// updateOrganizationServiceTemplateGroupList.add(temp);
organizationServiceTemplateGroupMapper
.
insertSelective
(
temp
);
}
// 更新自定义属性
// 更新自定义属性
// C#中的内部类CommonLogParams 在JAVA中替换成UpdateLogParams中
// C#中的内部类CommonLogParams 在JAVA中替换成UpdateLogParams中
...
@@ -2670,8 +2670,8 @@ public class OrganizationServiceImpl extends BaseService{
...
@@ -2670,8 +2670,8 @@ public class OrganizationServiceImpl extends BaseService{
List
<
UpdateLogParams
>
addLogList
=
new
ArrayList
<>();
List
<
UpdateLogParams
>
addLogList
=
new
ArrayList
<>();
// List<TemplateGroup> queryTemplate = templateGroupMapper.selectByExample(null);
// List<TemplateGroup> queryTemplate = templateGroupMapper.selectByExample(null);
//
List<ServiceType> queryService = serviceTypeMapper.selectByExample(null);
List
<
ServiceType
>
queryService
=
serviceTypeMapper
.
selectByExample
(
null
);
//
// for (OrganizationServiceTemplateGroup item : addList) {
// for (OrganizationServiceTemplateGroup item : addList) {
// ServiceType st1 = queryService.stream().filter(sa -> Strings.equals(sa.getId(), item.getServiceTypeId()))
// ServiceType st1 = queryService.stream().filter(sa -> Strings.equals(sa.getId(), item.getServiceTypeId()))
// .findFirst().orElse(null);
// .findFirst().orElse(null);
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/impl/OrganizationStructureServiceImpl.java
0 → 100644
View file @
2c0845dd
package
pwc
.
taxtech
.
atms
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
pwc.taxtech.atms.common.*
;
import
pwc.taxtech.atms.common.message.ErrorMessageCN
;
import
pwc.taxtech.atms.dao.OrganizationStructureMapper
;
import
pwc.taxtech.atms.dto.*
;
import
pwc.taxtech.atms.entity.OrganizationStructure
;
import
pwc.taxtech.atms.entity.OrganizationStructureExample
;
import
pwc.taxtech.atms.exception.ApplicationException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Service
public
class
OrganizationStructureServiceImpl
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
OrganizationStructureServiceImpl
.
class
);
@Autowired
private
OrganizationStructureMapper
organizationStructureMapper
;
@Autowired
private
OperationLogServiceImpl
operationLogService
;
@Autowired
private
OrganizationServiceImpl
organizationService
;
@Autowired
private
AuthUserHelper
authUserHelper
;
public
List
<
OrganizationStructureDto
>
getOrganizationStructures
()
{
logger
.
debug
(
"OrganizationStructureService getOrganizationStructures"
);
OrganizationStructureExample
organizationStructureExample
=
new
OrganizationStructureExample
();
organizationStructureExample
.
setOrderByClause
(
"name ASC"
);
List
<
OrganizationStructure
>
organizationStructureList
=
organizationStructureMapper
.
selectByExample
(
organizationStructureExample
);
return
rotateOrganizationStructureList
(
organizationStructureList
);
}
public
ApiResultDto
addOrganizationStructures
(
List
<
OrganizationStructureInputDto
>
organizationStructureDtoList
)
{
logger
.
debug
(
"OrganizationStructureService addOrganizationStructure"
);
logger
.
debug
(
"organization structure to add: {}"
,
JSON
.
toJSONString
(
organizationStructureDtoList
,
true
));
ApiResultDto
res
=
ApiResultDto
.
success
();
if
(
organizationStructureDtoList
.
isEmpty
())
{
return
ApiResultDto
.
fail
(
CommonConstants
.
JSONNULLOBJECT
);
}
for
(
OrganizationStructureInputDto
organizationStructureDto
:
organizationStructureDtoList
)
{
res
=
addOrganizationStructure
(
organizationStructureDto
);
if
(
ApiResultDto
.
FAILED
==
res
.
getCode
())
break
;
}
return
res
;
}
public
ApiResultDto
addOrganizationStructure
(
OrganizationStructureInputDto
organizationStructureDto
)
{
OrganizationStructureExample
example
=
new
OrganizationStructureExample
();
example
.
createCriteria
().
andNameEqualTo
(
organizationStructureDto
.
getName
());
if
(
organizationStructureMapper
.
countByExample
(
example
)>
0
){
return
ApiResultDto
.
fail
(
ErrorMessageCN
.
StrctureRepeat
);
}
OrganizationStructure
organizationStructure
=
rotateOrganizationStructureDto
(
organizationStructureDto
);
organizationStructure
.
setId
(
CommonUtils
.
getUUID
());
organizationStructure
.
setCreateTime
(
new
Date
());
organizationStructure
.
setUpdateTime
(
new
Date
());
organizationStructureMapper
.
insert
(
organizationStructure
);
// operation log
OperationLogDto
operationLogDto
=
new
OperationLogDto
();
makeUpOperationLogDto
(
operationLogDto
);
operationLogDto
.
setOperationObject
(
organizationStructureDto
.
getName
());
operationLogDto
.
setAction
(
OperationAction
.
New
.
value
());
operationLogService
.
addOperationLog
(
operationLogDto
);
return
ApiResultDto
.
success
();
}
private
void
makeUpOperationLogDto
(
OperationLogDto
operationLogDto
)
{
operationLogDto
.
setModule
(
OperationModule
.
BasicDataOrganizationStructure
.
value
());
operationLogDto
.
setLogType
(
OperateLogType
.
OperationLogBasicData
.
value
());
}
public
Integer
deleteOrganizationStructure
(
IdModel
idModel
)
{
logger
.
debug
(
"OrganizationStructureService deleteOrganizationStructure"
);
logger
.
debug
(
"organization structure to delete, id: {}"
,
JSON
.
toJSONString
(
idModel
,
true
));
if
(
idModel
==
null
||
idModel
.
getId
()
==
null
)
{
throw
new
ApplicationException
(
CommonConstants
.
JSONNULLOBJECT
);
}
OrganizationStructure
organizationStructure
=
organizationStructureMapper
.
selectByPrimaryKey
(
idModel
.
getId
());
if
(
organizationStructure
==
null
)
{
throw
new
ApplicationException
(
"can't find OrganizationStructure to delete, id: "
+
idModel
.
getId
());
}
int
result
=
organizationStructureMapper
.
deleteByPrimaryKey
(
idModel
.
getId
());
// operation log
OperationLogDto
operationLogDto
=
new
OperationLogDto
();
makeUpOperationLogDto
(
operationLogDto
);
operationLogDto
.
setAction
(
OperationAction
.
Delete
.
value
());
operationLogService
.
addOperationLog
(
operationLogDto
);
return
result
;
}
public
ApiResultDto
updateOrganizationStructures
(
List
<
OrganizationStructureInputDto
>
organizationStructureDtoList
)
{
logger
.
debug
(
"OrganizationStructureService updateOrganizationStructures"
);
logger
.
debug
(
"organization structure to update: {}"
,
JSON
.
toJSONString
(
organizationStructureDtoList
,
true
));
if
(
organizationStructureDtoList
.
isEmpty
())
{
return
ApiResultDto
.
fail
(
CommonConstants
.
JSONNULLOBJECT
);
}
for
(
OrganizationStructureInputDto
organizationStructureDto
:
organizationStructureDtoList
)
{
//isActive changed or not
boolean
isStatusChangeOperation
=
false
;
if
(
organizationStructureDto
==
null
||
!
StringUtils
.
hasText
(
organizationStructureDto
.
getId
()))
{
return
ApiResultDto
.
fail
(
"primary key can't be null"
);
}
// current OrganizationStructure
OrganizationStructure
organizationStructure
=
organizationStructureMapper
.
selectByPrimaryKey
(
organizationStructureDto
.
getId
());
if
(
organizationStructure
==
null
)
{
return
ApiResultDto
.
fail
(
"can't find organizationStructure, id: "
+
organizationStructureDto
.
getId
());
}
boolean
notChange
=
organizationStructureDto
.
getIsActive
().
equals
(
organizationStructure
.
getIsActive
())&&
organizationStructure
.
getName
().
equals
(
organizationStructureDto
.
getName
());
OrganizationStructureExample
example
=
new
OrganizationStructureExample
();
example
.
createCriteria
().
andIdNotEqualTo
(
organizationStructureDto
.
getId
()).
andNameEqualTo
(
organizationStructureDto
.
getName
());
boolean
nameExist
=
organizationStructureMapper
.
countByExample
(
example
)
>
0
;
if
(
notChange
)
{
return
ApiResultDto
.
fail
(
ErrorMessageCN
.
OrgStructureFailed
);
}
if
(
nameExist
)
{
return
ApiResultDto
.
fail
(
ErrorMessageCN
.
OrgStructureNameExist
);
}
//copy current OrganizationStructure as tmp
OrganizationStructure
originOrganizationStructure
=
new
OrganizationStructure
();
CommonUtils
.
copyProperties
(
organizationStructure
,
originOrganizationStructure
);
if
(!
organizationStructureDto
.
getIsActive
().
equals
(
organizationStructure
.
getIsActive
())
||
!
org
.
apache
.
commons
.
lang3
.
StringUtils
.
equals
(
organizationStructureDto
.
getName
(),
organizationStructure
.
getName
()))
{
isStatusChangeOperation
=
true
;
organizationStructure
.
setIsActive
(
organizationStructureDto
.
getIsActive
());
organizationStructure
.
setName
(
organizationStructureDto
.
getName
());
// 参照atms取消层级若有机构不能停用的限制
/*if (!organizationStructureDto.getIsActive()&&
organizationService.isOrganizationStructureExists(organizationStructureDto.getId())) {
// continue;
// return false;
throw new ApplicationException("the organization must not contain sub-organization!");
}*/
}
organizationStructure
.
setUpdateTime
(
new
Date
());
organizationStructureMapper
.
updateByPrimaryKey
(
organizationStructure
);
//add operation log
if
(
isStatusChangeOperation
)
{
UpdateLogParams
updateLogParams
=
new
UpdateLogParams
();
updateLogParams
.
setOperationObject
(
originOrganizationStructure
.
getName
());
updateLogParams
.
setOriginalState
(
originOrganizationStructure
);
updateLogParams
.
setUpdateState
(
organizationStructure
);
updateLogParams
.
setOperationUser
(
authUserHelper
.
getCurrentAuditor
().
get
());
updateLogParams
.
setOperationModule
(
OperationModule
.
BasicDataOrganizationStructure
.
value
());
updateLogParams
.
setOperationAction
(
OperationAction
.
Update
.
value
());
updateLogParams
.
setOperateLogType
(
OperateLogType
.
OperationLogBasicData
.
value
());
//check how many properties being updated and the log number should be same
operationLogService
.
updateDataAddLog
(
updateLogParams
);
}
}
return
ApiResultDto
.
success
();
}
private
OrganizationStructure
rotateOrganizationStructureDto
(
OrganizationStructureInputDto
organizationStructureDto
)
{
OrganizationStructure
organizationStructure
=
new
OrganizationStructure
();
organizationStructure
.
setId
(
organizationStructureDto
.
getId
());
organizationStructure
.
setName
(
organizationStructureDto
.
getName
());
organizationStructure
.
setIsActive
(
organizationStructureDto
.
getIsActive
());
return
organizationStructure
;
}
private
List
<
OrganizationStructureDto
>
rotateOrganizationStructureList
(
List
<
OrganizationStructure
>
organizationStructureList
)
{
List
<
OrganizationStructureDto
>
organizationStructureDtoList
=
new
ArrayList
<>();
if
(
organizationStructureList
!=
null
&&
!
organizationStructureList
.
isEmpty
())
{
for
(
OrganizationStructure
organizationStructure
:
organizationStructureList
)
{
organizationStructureDtoList
.
add
(
rotateOrganizationStructure
(
organizationStructure
));
}
}
return
organizationStructureDtoList
;
}
private
OrganizationStructureDto
rotateOrganizationStructure
(
OrganizationStructure
organizationStructure
)
{
OrganizationStructureDto
organizationStructureDto
=
new
OrganizationStructureDto
();
organizationStructureDto
.
setId
(
organizationStructure
.
getId
());
organizationStructureDto
.
setIsActive
(
organizationStructure
.
getIsActive
());
organizationStructureDto
.
setName
(
organizationStructure
.
getName
());
return
organizationStructureDto
;
}
}
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