Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
5968e325
Commit
5968e325
authored
Aug 12, 2022
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.事务回滚调整
2.调整为baseEntry为common
parent
59c1cf45
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
114 deletions
+133
-114
TzBaseEnterpriseInfo.java
...amos/boot/module/tzs/api/entity/TzBaseEnterpriseInfo.java
+9
-6
RegUnitInfoServiceImpl.java
...dule/tzs/flc/biz/service/impl/RegUnitInfoServiceImpl.java
+124
-108
No files found.
amos-boot-system-tzs/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/entity/TzBaseEnterpriseInfo.java
View file @
5968e325
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
api
.
entity
;
import
java.util.Date
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity
;
import
java.util.Date
;
/**
* 企业数据信息
...
...
@@ -13,15 +17,16 @@ import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
* @author duanwei
* @date 2022-08-10
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"TzBaseEnterpriseInfo对象"
,
description
=
"企业数据信息"
)
@ApiModel
(
value
=
"TzBaseEnterpriseInfo对象"
,
description
=
"企业数据信息"
)
public
class
TzBaseEnterpriseInfo
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"使用单位唯一标识"
)
private
String
useUnitCode
;
...
...
@@ -116,8 +121,6 @@ public class TzBaseEnterpriseInfo extends BaseEntity {
private
String
appId
;
@ApiModelProperty
(
value
=
"管辖机构"
)
private
String
governingBody
;
...
...
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/biz/service/impl/RegUnitInfoServiceImpl.java
View file @
5968e325
...
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.api.R
;
import
com.yeejoin.amos.boot.biz.common.constants.CommonConstant
;
import
com.yeejoin.amos.boot.biz.common.entity.DataDictionary
;
import
com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl
;
...
...
@@ -84,43 +85,55 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
RegUnitInfoDto
registerUnit
(
RegUnitInfoDto
model
)
{
tzsAuthServiceImpl
.
setRequestContext
();
// 1.插入注册单位基本信息表:tz_flc_reg_unit_info
RegUnitInfo
regUnitInfo
=
new
RegUnitInfo
();
// 注册用统一信用码注册,默认证件类型为营业执照,数据来源:cb_data_dictionary code = 1060
model
.
setUnitCodeType
(
"1060"
);
Bean
.
copyExistPropertis
(
model
,
regUnitInfo
);
// 2.插入单位注册许可信息表:tz_base_unit_licence
List
<
BaseUnitLicenceDto
>
unitLicenceDtos
=
model
.
getUnitLicences
();
List
<
BaseUnitLicence
>
baseUnitLicences
=
unitLicenceDtos
.
stream
().
map
(
s
->
{
s
.
setUnitCode
(
model
.
getUnitCode
());
s
.
setUnitName
(
model
.
getName
());
BaseUnitLicence
target
=
new
BaseUnitLicence
();
Bean
.
copyExistPropertis
(
s
,
target
);
return
target
;
}).
collect
(
Collectors
.
toList
());
baseUnitLicenceService
.
saveOrUpdateBatch
(
baseUnitLicences
);
// 3.插入工商单位信息表:tz_flc_reg_unit_ic
RegUnitIc
regUnitIc
=
new
RegUnitIc
();
model
.
getRegUnitIc
().
setUnitCode
(
model
.
getUnitCode
());
model
.
getRegUnitIc
().
setUnitName
(
model
.
getName
());
Bean
.
copyExistPropertis
(
model
.
getRegUnitIc
(),
regUnitIc
);
regUnitIcService
.
save
(
regUnitIc
);
// 4.调用平台进行创建单位、用户信息,同步用户信息
if
(
UnitReviewStateEnum
.
NO_NEED_REVIEW
.
getCode
().
equals
(
model
.
getState
()))
{
// 4.1 自动创建:调用平台进行创建单位、用户信息
this
.
createCompanyAndUser
(
regUnitInfo
);
// 4.2 创建企业信息
this
.
createBaseEnterpriseInfo
(
model
);
try
{
tzsAuthServiceImpl
.
setRequestContext
();
// 注册用统一信用码注册,默认证件类型为营业执照,数据来源:cb_data_dictionary code = 1060
model
.
setUnitCodeType
(
"1060"
);
Bean
.
copyExistPropertis
(
model
,
regUnitInfo
);
// 1.插入单位注册许可信息表:tz_base_unit_licence
List
<
BaseUnitLicenceDto
>
unitLicenceDtos
=
model
.
getUnitLicences
();
List
<
BaseUnitLicence
>
baseUnitLicences
=
unitLicenceDtos
.
stream
().
map
(
s
->
{
s
.
setUnitCode
(
model
.
getUnitCode
());
s
.
setUnitName
(
model
.
getName
());
BaseUnitLicence
target
=
new
BaseUnitLicence
();
Bean
.
copyExistPropertis
(
s
,
target
);
return
target
;
}).
collect
(
Collectors
.
toList
());
baseUnitLicenceService
.
saveOrUpdateBatch
(
baseUnitLicences
);
// 2.插入工商单位信息表:tz_flc_reg_unit_ic
RegUnitIc
regUnitIc
=
new
RegUnitIc
();
model
.
getRegUnitIc
().
setUnitCode
(
model
.
getUnitCode
());
model
.
getRegUnitIc
().
setUnitName
(
model
.
getName
());
Bean
.
copyExistPropertis
(
model
.
getRegUnitIc
(),
regUnitIc
);
regUnitIcService
.
save
(
regUnitIc
);
// 3.调用平台进行创建单位、用户信息,同步用户信息
if
(
UnitReviewStateEnum
.
NO_NEED_REVIEW
.
getCode
().
equals
(
model
.
getState
()))
{
// 4.1 创建企业信息
this
.
createBaseEnterpriseInfo
(
model
);
// 4.2 自动创建:调用平台进行创建单位、用户信息
this
.
createCompanyAndUser
(
regUnitInfo
);
}
// 4.插入注册单位基本信息表:tz_flc_reg_unit_info
this
.
save
(
regUnitInfo
);
// 5.组织返回数据
// 5.1企业基本信息
Bean
.
copyExistPropertis
(
regUnitInfo
,
model
);
// 5.2行政许可数据
model
.
setUnitLicences
(
Bean
.
toModels
(
baseUnitLicences
,
BaseUnitLicenceDto
.
class
));
// 5.3工商信息
model
.
setRegUnitIc
(
Bean
.
toModel
(
regUnitIc
,
new
RegUnitIcDto
()));
}
catch
(
Exception
e
)
{
// 删除已经创建的企业信息
if
(
StringUtils
.
isNotEmpty
(
regUnitInfo
.
getAmosCompanySeq
())){
Privilege
.
companyClient
.
deleteCompany
(
regUnitInfo
.
getAmosCompanySeq
());
}
// 删除已经创建的管理员账号
if
(
StringUtils
.
isNotEmpty
(
regUnitInfo
.
getAdminUserId
())){
Privilege
.
agencyUserClient
.
multDeleteUser
(
regUnitInfo
.
getAdminUserId
());
}
throw
new
RuntimeException
(
e
.
getMessage
());
}
this
.
save
(
regUnitInfo
);
// 5.组织返回数据
// 5.1企业基本信息
Bean
.
copyExistPropertis
(
regUnitInfo
,
model
);
// 5.2行政许可数据
model
.
setUnitLicences
(
Bean
.
toModels
(
baseUnitLicences
,
BaseUnitLicenceDto
.
class
));
// 5.3工商信息
model
.
setRegUnitIc
(
Bean
.
toModel
(
regUnitIc
,
new
RegUnitIcDto
()));
return
model
;
}
...
...
@@ -128,6 +141,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
TzBaseEnterpriseInfo
baseEnterpriseInfo
=
new
TzBaseEnterpriseInfo
();
baseEnterpriseInfo
.
setUnitType
(
regUnitInfo
.
getUnitType
());
baseEnterpriseInfo
.
setUseCode
(
regUnitInfo
.
getUnitCode
());
baseEnterpriseInfo
.
setUseUnit
(
regUnitInfo
.
getName
());
baseEnterpriseInfo
.
setProvince
(
regUnitInfo
.
getProvince
());
baseEnterpriseInfo
.
setCity
(
regUnitInfo
.
getCity
());
baseEnterpriseInfo
.
setDistrict
(
regUnitInfo
.
getDistrict
());
...
...
@@ -252,82 +266,85 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
}
private
void
createCompanyAndUser
(
RegUnitInfo
regUnitInfo
)
{
FeignClientResult
<
List
<
RoleModel
>>
roleListResult
=
Privilege
.
roleClient
.
queryRoleList
(
null
,
null
);
List
<
RoleModel
>
allRoleList
=
roleListResult
.
getResult
();
List
<
RoleModel
>
userRoleList
;
List
<
Long
>
roleIds
=
new
ArrayList
<>();
Set
<
String
>
roleNameSet
=
new
HashSet
<>();
// 3.1创建公司
CompanyModel
companyInfo
=
new
CompanyModel
();
companyInfo
.
setAddress
(
regUnitInfo
.
getProvince
()
+
regUnitInfo
.
getCity
()
+
regUnitInfo
.
getDistrict
()
+
regUnitInfo
.
getStree
()
+
regUnitInfo
.
getCommunity
()
+
regUnitInfo
.
getAddress
());
companyInfo
.
setAgencyCode
(
"tzs"
);
companyInfo
.
setParentId
(
Long
.
parseLong
(
regUnitInfo
.
getManagementUnitId
()));
companyInfo
.
setLevel
(
"company"
);
companyInfo
.
setCompanyName
(
regUnitInfo
.
getName
());
companyInfo
.
setCompanyCode
(
regUnitInfo
.
getUnitCode
());
companyInfo
.
setContact
(
regUnitInfo
.
getLegalPerson
());
companyInfo
.
setLandlinePhone
(
regUnitInfo
.
getLegalPersonTel
());
FeignClientResult
<
CompanyModel
>
companyResult
=
Privilege
.
companyClient
.
create
(
companyInfo
);
if
(
companyResult
==
null
||
companyResult
.
getResult
()
==
null
)
{
throw
new
BadRequest
(
"单位注册失败"
);
}
String
adminUserName
=
regUnitInfo
.
getAdminName
();
String
loginName
=
regUnitInfo
.
getAdminLoginName
();
String
pwd
=
regUnitInfo
.
getAdminLoginPwd
();
String
adminTel
=
regUnitInfo
.
getAdminTel
();
// 3.2 创建平台用户
companyInfo
=
companyResult
.
getResult
();
AgencyUserModel
agencyUserModel
=
new
AgencyUserModel
();
agencyUserModel
.
setUserName
(
loginName
);
agencyUserModel
.
setRealName
(
adminUserName
);
agencyUserModel
.
setLockStatus
(
"UNLOCK"
);
agencyUserModel
.
setPassword
(
pwd
);
agencyUserModel
.
setRePassword
(
pwd
);
agencyUserModel
.
setAgencyCode
(
"tzs"
);
agencyUserModel
.
setMobile
(
adminTel
);
String
unitTypeCode
=
regUnitInfo
.
getUnitTypeCode
();
// 根据unitTypeCode 获取应用和角色 数据字典配置
DataDictionary
unitType
=
iDataDictionaryService
.
getOne
(
new
LambdaQueryWrapper
<
DataDictionary
>().
eq
(
DataDictionary:
:
getCode
,
unitTypeCode
));
String
appCode
=
unitType
.
getTypeDesc
()
!=
null
?
unitType
.
getTypeDesc
()
:
""
;
String
[]
appCodes
=
appCode
.
split
(
","
);
Set
<
String
>
appCodesSet
=
new
HashSet
<>();
Collections
.
addAll
(
appCodesSet
,
appCodes
);
Map
<
Long
,
List
<
Long
>>
roleSeqMap
=
new
HashMap
<>();
roleNameSet
.
add
(
unitType
.
getName
());
userRoleList
=
allRoleList
.
stream
().
filter
(
r
->
r
.
getRoleName
().
equals
(
unitType
.
getName
())).
collect
(
Collectors
.
toList
());
userRoleList
.
forEach
(
r
->
{
roleIds
.
add
(
r
.
getSequenceNbr
());
});
roleSeqMap
.
put
(
companyInfo
.
getSequenceNbr
(),
roleIds
);
Map
<
Long
,
List
<
RoleModel
>>
orgRoles
=
new
HashMap
<>();
orgRoles
.
put
(
companyInfo
.
getSequenceNbr
(),
userRoleList
);
agencyUserModel
.
setAppCodes
(
new
ArrayList
<>(
appCodesSet
));
agencyUserModel
.
setOrgRoles
(
orgRoles
);
agencyUserModel
.
setOrgRoleSeqs
(
roleSeqMap
);
FeignClientResult
<
AgencyUserModel
>
userResult
;
FeignClientResult
<
AgencyUserModel
>
userResult
=
null
;
try
{
FeignClientResult
<
List
<
RoleModel
>>
roleListResult
=
Privilege
.
roleClient
.
queryRoleList
(
null
,
null
);
List
<
RoleModel
>
allRoleList
=
roleListResult
.
getResult
();
List
<
RoleModel
>
userRoleList
;
List
<
Long
>
roleIds
=
new
ArrayList
<>();
Set
<
String
>
roleNameSet
=
new
HashSet
<>();
// 3.1创建公司
companyInfo
.
setAddress
(
regUnitInfo
.
getProvince
()
+
regUnitInfo
.
getCity
()
+
regUnitInfo
.
getDistrict
()
+
regUnitInfo
.
getStree
()
+
regUnitInfo
.
getCommunity
()
+
regUnitInfo
.
getAddress
());
companyInfo
.
setAgencyCode
(
"tzs"
);
companyInfo
.
setParentId
(
Long
.
parseLong
(
regUnitInfo
.
getManagementUnitId
()));
companyInfo
.
setLevel
(
"company"
);
companyInfo
.
setCompanyName
(
regUnitInfo
.
getName
());
companyInfo
.
setCompanyCode
(
regUnitInfo
.
getUnitCode
());
companyInfo
.
setContact
(
regUnitInfo
.
getLegalPerson
());
companyInfo
.
setLandlinePhone
(
regUnitInfo
.
getLegalPersonTel
());
FeignClientResult
<
CompanyModel
>
companyResult
=
Privilege
.
companyClient
.
create
(
companyInfo
);
if
(
companyResult
==
null
||
companyResult
.
getResult
()
==
null
)
{
throw
new
BadRequest
(
"单位注册失败"
);
}
String
adminUserName
=
regUnitInfo
.
getAdminName
();
String
loginName
=
regUnitInfo
.
getAdminLoginName
();
String
pwd
=
regUnitInfo
.
getAdminLoginPwd
();
String
adminTel
=
regUnitInfo
.
getAdminTel
();
// 3.2 创建平台用户
companyInfo
=
companyResult
.
getResult
();
AgencyUserModel
agencyUserModel
=
new
AgencyUserModel
();
agencyUserModel
.
setUserName
(
loginName
);
agencyUserModel
.
setRealName
(
adminUserName
);
agencyUserModel
.
setLockStatus
(
"UNLOCK"
);
agencyUserModel
.
setPassword
(
pwd
);
agencyUserModel
.
setRePassword
(
pwd
);
agencyUserModel
.
setAgencyCode
(
"tzs"
);
agencyUserModel
.
setMobile
(
adminTel
);
String
unitTypeCode
=
regUnitInfo
.
getUnitTypeCode
();
// 根据unitTypeCode 获取应用和角色 数据字典配置
DataDictionary
unitType
=
iDataDictionaryService
.
getOne
(
new
LambdaQueryWrapper
<
DataDictionary
>().
eq
(
DataDictionary:
:
getCode
,
unitTypeCode
));
String
appCode
=
unitType
.
getTypeDesc
()
!=
null
?
unitType
.
getTypeDesc
()
:
""
;
String
[]
appCodes
=
appCode
.
split
(
","
);
Set
<
String
>
appCodesSet
=
new
HashSet
<>();
Collections
.
addAll
(
appCodesSet
,
appCodes
);
Map
<
Long
,
List
<
Long
>>
roleSeqMap
=
new
HashMap
<>();
roleNameSet
.
add
(
unitType
.
getName
());
userRoleList
=
allRoleList
.
stream
().
filter
(
r
->
r
.
getRoleName
().
equals
(
unitType
.
getName
())).
collect
(
Collectors
.
toList
());
userRoleList
.
forEach
(
r
->
roleIds
.
add
(
r
.
getSequenceNbr
()));
roleSeqMap
.
put
(
companyInfo
.
getSequenceNbr
(),
roleIds
);
Map
<
Long
,
List
<
RoleModel
>>
orgRoles
=
new
HashMap
<>();
orgRoles
.
put
(
companyInfo
.
getSequenceNbr
(),
userRoleList
);
agencyUserModel
.
setAppCodes
(
new
ArrayList
<>(
appCodesSet
));
agencyUserModel
.
setOrgRoles
(
orgRoles
);
agencyUserModel
.
setOrgRoleSeqs
(
roleSeqMap
);
userResult
=
Privilege
.
agencyUserClient
.
create
(
agencyUserModel
);
}
catch
(
InnerInvokException
e
)
{
if
(
userResult
==
null
||
userResult
.
getResult
()
==
null
)
{
throw
new
BadRequest
(
"单位注册失败"
);
}
regUnitInfo
.
setAdminUserId
(
userResult
.
getResult
().
getUserId
());
regUnitInfo
.
setAmosCompanySeq
(
companyInfo
.
getSequenceNbr
().
toString
());
// 3.3 org_user 创建组织机构
OrgUsr
org
=
new
OrgUsr
();
org
.
setBizOrgCode
(
TreeParser
.
genTreeCode
());
org
.
setBizOrgType
(
CommonConstant
.
BIZ_ORG_TYPE_COMPANY
);
org
.
setBizOrgName
(
regUnitInfo
.
getName
());
org
.
setRecDate
(
new
Date
());
org
.
setRecUserId
(
userResult
.
getResult
().
getUserId
());
org
.
setRecUserName
(
userResult
.
getResult
().
getUserName
());
org
.
setAmosOrgId
(
companyInfo
.
getSequenceNbr
()
+
""
);
org
.
setAmosOrgCode
(
companyInfo
.
getOrgCode
());
iOrgUsrService
.
save
(
org
);
}
catch
(
Exception
e
)
{
// 删除已经创建的 企业信息
Privilege
.
companyClient
.
deleteCompany
(
companyInfo
.
getSequenceNbr
()
+
""
);
throw
new
BadRequest
(
e
.
getMessage
());
}
if
(
userResult
==
null
||
userResult
.
getResult
()
==
null
)
{
throw
new
BadRequest
(
"注册失败"
);
if
(
companyInfo
!=
null
&&
companyInfo
.
getSequenceNbr
()
!=
null
){
Privilege
.
companyClient
.
deleteCompany
(
companyInfo
.
getSequenceNbr
()
+
""
);
}
if
(
userResult
!=
null
&&
userResult
.
getResult
()
!=
null
&&
StringUtils
.
isNotEmpty
(
userResult
.
getResult
().
getUserId
())){
Privilege
.
agencyUserClient
.
multDeleteUser
(
userResult
.
getResult
().
getUserId
());
}
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
RuntimeException
(
e
.
getMessage
());
}
// 3.3 org_user 创建组织机构
OrgUsr
org
=
new
OrgUsr
();
org
.
setBizOrgCode
(
TreeParser
.
genTreeCode
());
org
.
setBizOrgType
(
CommonConstant
.
BIZ_ORG_TYPE_COMPANY
);
org
.
setBizOrgName
(
regUnitInfo
.
getName
());
org
.
setRecDate
(
new
Date
());
org
.
setRecUserId
(
userResult
.
getResult
().
getUserId
());
org
.
setRecUserName
(
userResult
.
getResult
().
getUserName
());
org
.
setAmosOrgId
(
companyInfo
.
getSequenceNbr
()
+
""
);
org
.
setAmosOrgCode
(
companyInfo
.
getOrgCode
());
iOrgUsrService
.
save
(
org
);
regUnitInfo
.
setAdminUserId
(
userResult
.
getResult
().
getUserId
());
regUnitInfo
.
setAmosCompanySeq
(
companyInfo
.
getSequenceNbr
().
toString
());
}
}
\ No newline at end of file
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