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
1ee21614
Commit
1ee21614
authored
Jul 11, 2023
by
xixinzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
注册相关代码
parent
187ef6d5
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
593 additions
and
16 deletions
+593
-16
UnitInfoDto.java
...om/yeejoin/amos/boot/module/hygf/api/dto/UnitInfoDto.java
+27
-0
UnitRegisterDto.java
...eejoin/amos/boot/module/hygf/api/dto/UnitRegisterDto.java
+20
-0
UnitInfo.java
...om/yeejoin/amos/boot/module/hygf/api/entity/UnitInfo.java
+55
-0
PrivilegeFeginService.java
...mos/boot/module/hygf/api/fegin/PrivilegeFeginService.java
+38
-0
IUnitInfoService.java
...n/amos/boot/module/hygf/api/service/IUnitInfoService.java
+7
-0
UnitInfoController.java
...s/boot/module/hygf/biz/controller/UnitInfoController.java
+194
-14
UnitInfoServiceImpl.java
...oot/module/hygf/biz/service/impl/UnitInfoServiceImpl.java
+240
-1
application-dev.properties
...le-hygf-biz/src/main/resources/application-dev.properties
+7
-1
application.properties
...module-hygf-biz/src/main/resources/application.properties
+5
-0
No files found.
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/dto/UnitInfoDto.java
View file @
1ee21614
...
...
@@ -48,6 +48,9 @@ public class UnitInfoDto extends BaseDto {
@ApiModelProperty
(
value
=
"管理员账户名"
)
private
String
adminLoginName
;
@ApiModelProperty
(
value
=
"管理员账户名"
)
private
String
adminUserName
;
@ApiModelProperty
(
value
=
"管理员电话"
)
private
String
adminPhone
;
...
...
@@ -66,4 +69,28 @@ public class UnitInfoDto extends BaseDto {
@ApiModelProperty
(
value
=
"角色id"
)
private
String
roleId
;
@ApiModelProperty
(
value
=
"注册地址省-市-区"
)
private
String
registerPcd
;
@ApiModelProperty
(
value
=
"工作地址省-市-区"
)
private
String
workPcd
;
@ApiModelProperty
(
value
=
"注册地址省-市-区code"
)
private
String
registerPcdCode
;
@ApiModelProperty
(
value
=
"工作地址省-市-区code"
)
private
String
workPcdCode
;
@ApiModelProperty
(
value
=
"单位类型"
)
private
String
unitType
;
@ApiModelProperty
(
value
=
"单位类型code"
)
private
String
unitTypeCode
;
@ApiModelProperty
(
value
=
"管辖机构"
)
private
String
managementUnit
;
@ApiModelProperty
(
value
=
"管辖单位id"
)
private
String
managementUnitId
;
}
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/dto/UnitRegisterDto.java
0 → 100644
View file @
1ee21614
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
api
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* @author DELL
*/
@Data
@ApiModel
(
value
=
"UnitRegisterDto"
,
description
=
"单位注册"
)
public
class
UnitRegisterDto
{
@ApiModelProperty
(
value
=
"企业名称"
)
private
UnitInfoDto
unitInfoDto
;
@ApiModelProperty
(
value
=
"企业名称"
)
private
CommerceInfoDto
commerceInfoDto
;
}
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/entity/UnitInfo.java
View file @
1ee21614
...
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.hygf.api.entity;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
...
...
@@ -112,4 +113,58 @@ public class UnitInfo extends BaseEntity {
@TableField
(
"role_id"
)
private
String
roleId
;
/**
* 管理员账户名
*/
@TableField
(
"admin_user_name"
)
private
String
adminUserName
;
/**
* 注册地址省-市-区
*/
@TableField
(
"register_pcd"
)
private
String
registerPcd
;
/**
* 工作地址省-市-区
*/
@TableField
(
"work_Pcd"
)
private
String
workPcd
;
/**
* 注册地址省-市-区code
*/
@TableField
(
"register_pcd_code"
)
private
String
registerPcdCode
;
/**
* 工作地址省-市-区code
*/
@TableField
(
"work_pcd_code"
)
private
String
workPcdCode
;
/**
* 单位类型
*/
@TableField
(
"unit_type"
)
private
String
unitType
;
/**
* 单位类型code
*/
@TableField
(
"unit_type_code"
)
private
String
unitTypeCode
;
/**
* 管辖机构
*/
@TableField
(
"management_unit"
)
private
String
managementUnit
;
/**
* 管辖单位id
*/
@TableField
(
"management_unit_id"
)
private
String
managementUnitId
;
}
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/fegin/PrivilegeFeginService.java
0 → 100644
View file @
1ee21614
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
api
.
fegin
;
import
com.yeejoin.amos.boot.biz.common.feign.FeignConfiguration
;
import
com.yeejoin.amos.component.feign.config.InnerInvokException
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.VerifyCodeAuthModel
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.*
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
@FeignClient
(
value
=
"AMOS-API-PRIVILEGE"
,
configuration
=
{
FeignConfiguration
.
class
})
public
interface
PrivilegeFeginService
{
@RequestMapping
(
value
=
"/privilege/v1/agencyuser/me"
,
method
=
RequestMethod
.
GET
)
ResponseModel
<
AgencyUserModel
>
getMe
();
//获取单位树
@RequestMapping
(
value
=
"/privilege/v1/company/tree"
,
method
=
RequestMethod
.
GET
)
FeignClientResult
tree
(
@RequestHeader
(
"token"
)
String
token
,
@RequestHeader
(
"appKey"
)
String
appKey
,
@RequestHeader
(
"product"
)
String
product
);
//获取省级行政区划
@RequestMapping
(
value
=
"systemctl/v1/region/level"
,
method
=
RequestMethod
.
GET
)
FeignClientResult
getProvince
(
@RequestParam
String
level
);
//获取行政区划树
@RequestMapping
(
value
=
"systemctl/v1/region/tree"
,
method
=
RequestMethod
.
GET
)
FeignClientResult
getTree
();
/**
* 手机号验证码登录
*/
@RequestMapping
(
value
=
"/privilege/v1/auth/mobile/verifycode"
,
method
=
RequestMethod
.
POST
)
FeignClientResult
mobileVerifyCode
(
@RequestBody
VerifyCodeAuthModel
model
)
throws
InnerInvokException
;
}
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/service/IUnitInfoService.java
View file @
1ee21614
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
api
.
service
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.UnitRegisterDto
;
import
java.util.Collection
;
/**
* 经销商人员信息接口类
*
...
...
@@ -9,4 +13,7 @@ package com.yeejoin.amos.boot.module.hygf.api.service;
*/
public
interface
IUnitInfoService
{
Collection
getManagementUnitTree
(
String
orgCode
);
UnitRegisterDto
registerUnit
(
UnitRegisterDto
model
);
}
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/controller/UnitInfoController.java
View file @
1ee21614
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
biz
.
controller
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.UnitRegisterDto
;
import
com.yeejoin.amos.boot.module.ugp.api.constants.XJConstant
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.systemctl.model.RegionModel
;
import
io.swagger.annotations.ApiParam
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.Api
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
java.util.List
;
import
java.util.*
;
import
com.yeejoin.amos.boot.module.hygf.biz.service.impl.UnitInfoServiceImpl
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -24,25 +46,28 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
* @date 2023-07-07
*/
@RestController
@Api
(
tags
=
"经销商
人员
信息Api"
)
@Api
(
tags
=
"经销商
单位
信息Api"
)
@RequestMapping
(
value
=
"/unit-info"
)
public
class
UnitInfoController
extends
BaseController
{
@Autowired
UnitInfoServiceImpl
unitInfoServiceImpl
;
/**
* 新增经销商人员信息
*
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/save"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增经销商人员信息"
,
notes
=
"新增经销商人员信息"
)
public
ResponseModel
<
UnitInfoDto
>
save
(
@RequestBody
UnitInfoDto
model
)
{
model
=
unitInfoServiceImpl
.
createWithModel
(
model
);
return
ResponseHelper
.
buildResponse
(
model
);
}
@Autowired
AmosRequestContext
requestContext
;
@Autowired
RedisUtils
redisUtil
;
@Value
(
"${hygf.sms.tempCode}"
)
private
String
smsTempCode
;
public
static
final
String
HYGF_USER_TEL
=
"hygf_tel_"
;
/**
* 验证码过期时间
*/
private
long
time
=
600
l
;
/**
* 根据sequenceNbr更新
...
...
@@ -113,4 +138,159 @@ public class UnitInfoController extends BaseController {
public
ResponseModel
<
List
<
UnitInfoDto
>>
selectForList
()
{
return
ResponseHelper
.
buildResponse
(
unitInfoServiceImpl
.
queryForUnitInfoList
());
}
/**
* 管理员身份证图片上传 无token
*
* @return
*/
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/uploadFile"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"管理员身份证图片上传 无token"
,
notes
=
"管理员身份证图片上传 无token"
)
public
ResponseModel
<
String
>
uploadFile
(
@ApiParam
(
value
=
"文件"
,
required
=
true
)
@RequestParam
MultipartFile
file
)
{
if
(
ValidationUtil
.
isEmpty
(
file
)){
throw
new
BadRequest
(
"参数校验失败."
);
}
RequestContext
.
setAppKey
(
"AMOS_STUDIO"
);
RequestContext
.
setProduct
(
"AMOS_STUDIO_WEB"
);
RequestContext
.
setToken
(
requestContext
.
getToken
());
FeignClientResult
<
Map
<
String
,
String
>>
date
=
Systemctl
.
fileStorageClient
.
updateCommonFile
(
file
);
String
urlString
=
""
;
if
(
date
!=
null
)
{
Map
<
String
,
String
>
map
=
date
.
getResult
();
Iterator
<
String
>
it
=
map
.
keySet
().
iterator
();
while
(
it
.
hasNext
())
{
urlString
=
it
.
next
();
}
}
return
ResponseHelper
.
buildResponse
(
urlString
);
}
/**
* 获取组织机构树
* @return
*/
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/region/tree"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"获取组织机构树"
,
notes
=
"获取组织机构树"
)
public
ResponseModel
<
Collection
<
RegionModel
>>
getRegionTree
()
{
RequestContext
.
setAppKey
(
"AMOS_STUDIO"
);
RequestContext
.
setProduct
(
"AMOS_STUDIO_WEB"
);
RequestContext
.
setToken
(
requestContext
.
getToken
());
return
ResponseHelper
.
buildResponse
(
Systemctl
.
regionClient
.
queryForTree
(
null
).
getResult
());
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@GetMapping
(
value
=
"/management-unit/tree"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"管辖机构树"
,
notes
=
"管辖机构树"
)
public
ResponseModel
<
Collection
>
managementUnitTree
(
@RequestParam
(
required
=
false
)
String
orgCode
)
{
RequestContext
.
setAppKey
(
"AMOS_STUDIO"
);
RequestContext
.
setProduct
(
"AMOS_STUDIO_WEB"
);
RequestContext
.
setToken
(
requestContext
.
getToken
());
Collection
result
=
unitInfoServiceImpl
.
getManagementUnitTree
(
orgCode
);
return
ResponseHelper
.
buildResponse
(
result
);
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@PostMapping
(
value
=
"/unitRegister"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"单位注册"
,
notes
=
"单位注册"
)
public
ResponseModel
<
UnitRegisterDto
>
save
(
@RequestBody
UnitRegisterDto
model
)
{
try
{
RequestContext
.
setAppKey
(
"AMOS_STUDIO"
);
RequestContext
.
setProduct
(
"AMOS_STUDIO_WEB"
);
RequestContext
.
setToken
(
requestContext
.
getToken
());
model
=
unitInfoServiceImpl
.
registerUnit
(
model
);
return
ResponseHelper
.
buildResponse
(
model
);
}
catch
(
Exception
e
)
{
ResponseModel
<
UnitRegisterDto
>
response
=
new
ResponseModel
<>();
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
response
.
setResult
(
null
);
response
.
setDevMessage
(
e
.
getMessage
());
response
.
setStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
response
.
setTraceId
(
RequestContext
.
getTraceId
());
response
.
setPath
(
request
.
getServletPath
());
return
response
;
}
}
/**
* 判断用户号码是否存在
*
* @return
*/
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/hasExistPhone/{phone}"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"判断用户号码是否存在"
,
notes
=
"判断用户号码是否存在"
)
public
ResponseModel
hasExistPhone
(
@PathVariable
(
value
=
"phone"
)
String
phone
)
{
try
{
return
CommonResponseUtil
.
success
(
Privilege
.
agencyUserClient
.
checkLoginId
(
phone
).
getResult
());
}
catch
(
Exception
e
)
{
return
CommonResponseUtil
.
failure
(
"该手机号已经注册"
);
}
}
/**
* 发送手机号验证码
*
* @return
*/
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/sendTelCode/{tel}"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"发送手机号验证码"
,
notes
=
"发送手机号验证码"
)
public
ResponseModel
<
Boolean
>
sendTelCode
(
@PathVariable
(
value
=
"tel"
)
String
tel
,
@RequestParam
(
value
=
"type"
,
required
=
false
)
String
type
)
{
if
(
ValidationUtil
.
isEmpty
(
tel
))
{
throw
new
BadRequest
(
"参数校验失败."
);
}
Boolean
flag
=
false
;
HashMap
<
String
,
String
>
params
=
new
HashMap
<>();
String
code
=
this
.
getRandomCode
();
params
.
put
(
"code"
,
code
);
params
.
put
(
"mobile"
,
tel
);
params
.
put
(
"smsCode"
,
smsTempCode
);
try
{
Systemctl
.
smsClient
.
sendCommonSms
(
params
).
getResult
();
flag
=
true
;
}
catch
(
Exception
e
)
{
throw
new
BadRequest
(
"发送短信失败:"
+
e
.
getMessage
());
}
// code 保存到缓存中
redisUtil
.
set
(
HYGF_USER_TEL
+
tel
,
code
,
time
);
return
ResponseHelper
.
buildResponse
(
flag
);
}
/**
* 验证手机号验证码是否成功
*
* @return
*/
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/verifyTelCode/{tel}/{code}"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"验证手机号验证码是否成功"
,
notes
=
"验证手机号验证码是否成功"
)
public
ResponseModel
<
Boolean
>
verifyTelCode
(
@PathVariable
(
value
=
"tel"
)
String
adminTel
,
@PathVariable
(
value
=
"code"
)
String
code
)
{
Boolean
flag
=
false
;
if
(
ValidationUtil
.
isEmpty
(
adminTel
)
||
ValidationUtil
.
isEmpty
(
code
))
{
throw
new
BadRequest
(
"参数校验失败."
);
}
if
(
redisUtil
.
hasKey
(
HYGF_USER_TEL
+
adminTel
))
{
String
redisCode
=
redisUtil
.
get
(
HYGF_USER_TEL
+
adminTel
).
toString
();
if
(
code
.
equals
(
redisCode
))
{
flag
=
true
;
}
}
return
ResponseHelper
.
buildResponse
(
flag
);
}
private
String
getRandomCode
(){
String
code
=
""
;
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
int
r
=
random
.
nextInt
(
10
);
code
=
code
+
r
;
}
return
code
;
}
}
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/service/impl/UnitInfoServiceImpl.java
View file @
1ee21614
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
biz
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
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.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.TreeParser
;
import
com.yeejoin.amos.boot.module.common.api.entity.OrgUsr
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.CommerceInfoDto
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.UnitRegisterDto
;
import
com.yeejoin.amos.boot.module.hygf.api.entity.CommerceInfo
;
import
com.yeejoin.amos.boot.module.hygf.api.entity.UnitInfo
;
import
com.yeejoin.amos.boot.module.hygf.api.fegin.PrivilegeFeginService
;
import
com.yeejoin.amos.boot.module.hygf.api.mapper.UnitInfoMapper
;
import
com.yeejoin.amos.boot.module.hygf.api.service.IUnitInfoService
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.UnitInfoDto
;
import
com.yeejoin.amos.component.feign.config.TokenOperation
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
java.util.List
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.util.*
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.FutureTask
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* 经销商人员信息服务实现类
...
...
@@ -17,6 +48,24 @@ import java.util.List;
*/
@Service
public
class
UnitInfoServiceImpl
extends
BaseService
<
UnitInfoDto
,
UnitInfo
,
UnitInfoMapper
>
implements
IUnitInfoService
{
String
COMPANY_TREE_REDIS_KEY
=
"REGULATOR_UNIT_TREE"
;
@Value
(
"${regulator.unit.code}"
)
private
String
code
;
@Value
(
"${dealer.appcode}"
)
private
String
appCodes
;
@Autowired
RedisUtils
redisUtil
;
@Autowired
PrivilegeFeginService
privilegeFeginService
;
@Autowired
CommerceInfoServiceImpl
commerceInfoService
;
/**
* 分页查询
*/
...
...
@@ -30,4 +79,193 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto,UnitInfo,UnitIn
public
List
<
UnitInfoDto
>
queryForUnitInfoList
()
{
return
this
.
queryForList
(
""
,
false
);
}
@Override
public
Collection
getManagementUnitTree
(
String
orgCode
)
{
List
<
LinkedHashMap
>
companyModels
=
(
List
<
LinkedHashMap
>)
redisUtil
.
get
(
COMPANY_TREE_REDIS_KEY
);
if
(
ValidationUtil
.
isEmpty
(
companyModels
))
{
companyModels
=
creatTree
();
}
if
(!
ValidationUtil
.
isEmpty
(
orgCode
))
{
companyModels
=
findNodesByCondition
(
companyModels
,
"orgCode"
,
orgCode
,
"children"
);
companyModels
=
(
List
<
LinkedHashMap
>)
companyModels
.
get
(
0
).
get
(
"children"
);
}
return
companyModels
;
}
@Override
public
UnitRegisterDto
registerUnit
(
UnitRegisterDto
model
)
{
UnitInfoDto
regUnitInfo
=
model
.
getUnitInfoDto
();
try
{
// 1. 调用平台进行创建单位、用户信息
this
.
createCompanyAndUser
(
regUnitInfo
);
// 2.插入单位表
regUnitInfo
=
this
.
createWithModel
(
regUnitInfo
);
CommerceInfoDto
commerceInfo
=
model
.
getCommerceInfoDto
();
commerceInfo
.
setUnitSeq
(
regUnitInfo
.
getSequenceNbr
());
commerceInfo
=
commerceInfoService
.
createWithModel
(
commerceInfo
);
model
.
setCommerceInfoDto
(
commerceInfo
);
model
.
setUnitInfoDto
(
regUnitInfo
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
// 失败后回滚:删除已经创建的企业信息
if
(!
ObjectUtils
.
isEmpty
(
regUnitInfo
.
getAmosCompanySeq
()))
{
FeignClientResult
<
CompanyModel
>
feignClientResult
=
Privilege
.
companyClient
.
seleteOne
(
regUnitInfo
.
getAmosCompanySeq
());
if
(
feignClientResult
!=
null
)
{
Privilege
.
companyClient
.
deleteCompany
(
regUnitInfo
.
getAmosCompanySeq
().
toString
());
}
}
// 失败后回滚:删除已经创建的管理员账号
if
(
StringUtils
.
isNotEmpty
(
regUnitInfo
.
getAdminUserId
()))
{
FeignClientResult
<
AgencyUserModel
>
feignClientResult
=
Privilege
.
agencyUserClient
.
queryByUserId
(
regUnitInfo
.
getAdminUserId
());
if
(
feignClientResult
!=
null
)
{
Privilege
.
agencyUserClient
.
multDeleteUser
(
regUnitInfo
.
getAdminUserId
());
}
}
throw
new
RuntimeException
(
e
.
getMessage
());
}
return
model
;
}
private
static
List
<
LinkedHashMap
>
findNodesByCondition
(
List
<
LinkedHashMap
>
nodes
,
String
conditionName
,
String
condition
,
String
childName
)
{
return
nodes
.
stream
()
.
flatMap
(
node
->
Stream
.
concat
(
node
.
get
(
conditionName
).
equals
(
condition
)
?
Stream
.
of
(
node
)
:
Stream
.
empty
(),
node
.
get
(
childName
)
!=
null
?
findNodesByCondition
((
List
<
LinkedHashMap
>)
node
.
get
(
childName
),
conditionName
,
condition
,
condition
).
stream
()
:
Stream
.
empty
()
))
.
collect
(
Collectors
.
toList
());
}
private
List
<
LinkedHashMap
>
creatTree
()
{
FeignClientResult
tree
=
privilegeFeginService
.
tree
(
RequestContext
.
getToken
(),
RequestContext
.
getAppKey
(),
RequestContext
.
getProduct
());
List
<
LinkedHashMap
>
result
=
(
List
<
LinkedHashMap
>)
tree
.
getResult
();
List
<
LinkedHashMap
>
treeData
=
deleteRegulatorTreeData
(
result
);
List
<
LinkedHashMap
>
supervisionTree
=
treeData
.
stream
().
filter
(
e
->
code
.
equals
(
e
.
get
(
"orgCode"
))).
collect
(
Collectors
.
toList
());
List
<
LinkedHashMap
>
resultTree
=
updateNullChildren
(
supervisionTree
);
redisUtil
.
set
(
COMPANY_TREE_REDIS_KEY
,
resultTree
);
return
resultTree
;
}
/**
* 将管辖机构树中children为[]的修改为null
*
* @param result
* @return
*/
private
List
<
LinkedHashMap
>
updateNullChildren
(
List
<
LinkedHashMap
>
result
)
{
Iterator
it
=
result
.
iterator
();
while
(
it
.
hasNext
())
{
LinkedHashMap
e
=
(
LinkedHashMap
)
it
.
next
();
//将管辖机构树中children为[]的修改为null
if
(
e
.
get
(
"children"
)
!=
null
)
{
if
(((
List
<
LinkedHashMap
>)
e
.
get
(
"children"
)).
size
()
==
0
)
{
e
.
put
(
"children"
,
null
);
}
}
if
(!
ObjectUtils
.
isEmpty
(
e
.
get
(
"children"
)))
{
updateNullChildren
((
List
<
LinkedHashMap
>)
e
.
get
(
"children"
));
}
}
return
result
;
}
/**
* 删除管辖机构树中level为使用单位的数据
* @param result 管辖机构树
* @return 筛选过滤后不包含使用单位的管辖机构树
*/
private
List
<
LinkedHashMap
>
deleteRegulatorTreeData
(
List
<
LinkedHashMap
>
result
)
{
Iterator
it
=
result
.
iterator
();
while
(
it
.
hasNext
())
{
LinkedHashMap
e
=
(
LinkedHashMap
)
it
.
next
();
//删除使用单位
if
(
"company"
.
equals
(
e
.
get
(
"level"
)))
{
it
.
remove
();
}
if
(
e
.
get
(
"companyName"
).
toString
().
contains
(
"行政审批局"
))
{
it
.
remove
();
}
if
(!
ObjectUtils
.
isEmpty
(
e
.
get
(
"children"
)))
{
deleteRegulatorTreeData
((
List
<
LinkedHashMap
>)
e
.
get
(
"children"
));
}
}
return
result
;
}
private
void
createCompanyAndUser
(
UnitInfoDto
regUnitInfo
)
{
CompanyModel
companyInfo
=
new
CompanyModel
();
FeignClientResult
<
AgencyUserModel
>
userResult
=
null
;
try
{
FeignClientResult
<
List
<
RoleModel
>>
roleListResult
=
Privilege
.
roleClient
.
queryRoleList
(
null
,
null
);
List
<
RoleModel
>
allRoleList
=
roleListResult
.
getResult
();
List
<
RoleModel
>
userRoleList
=
new
ArrayList
<>();
List
<
Long
>
roleIds
=
new
ArrayList
<>();
// 1创建公司
companyInfo
.
setAddress
(
regUnitInfo
.
getRegisterPcd
());
companyInfo
.
setAgencyCode
(
"JXIOP"
);
companyInfo
.
setParentId
(
Long
.
parseLong
(
regUnitInfo
.
getManagementUnitId
()));
companyInfo
.
setLevel
(
"station"
);
companyInfo
.
setCompanyName
(
regUnitInfo
.
getName
());
// companyInfo.setCompanyCode(regUnitInfo.getUnitTypeCode());
companyInfo
.
setContact
(
regUnitInfo
.
getHeadName
());
companyInfo
.
setCompanyType
(
regUnitInfo
.
getUnitType
());
companyInfo
.
setLandlinePhone
(
regUnitInfo
.
getHeadPhone
());
FeignClientResult
<
CompanyModel
>
companyResult
=
Privilege
.
companyClient
.
create
(
companyInfo
);
if
(
companyResult
==
null
||
companyResult
.
getResult
()
==
null
)
{
throw
new
BadRequest
(
"单位注册失败"
);
}
String
adminUserName
=
regUnitInfo
.
getAdminUserName
();
String
loginName
=
regUnitInfo
.
getAdminLoginName
();
String
pwd
=
regUnitInfo
.
getAdminLoginPwd
();
String
adminTel
=
regUnitInfo
.
getAdminPhone
();
// 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
(
"JXIOP"
);
agencyUserModel
.
setMobile
(
adminTel
);
List
<
String
>
split
=
Arrays
.
asList
(
StringUtils
.
split
(
appCodes
,
','
));
Map
<
Long
,
List
<
Long
>>
roleSeqMap
=
new
HashMap
<>();
Map
<
Long
,
List
<
RoleModel
>>
orgRoles
=
new
HashMap
<>();
userRoleList
=
allRoleList
.
stream
().
filter
(
r
->
r
.
getRoleName
().
equals
(
regUnitInfo
.
getUnitTypeCode
()))
.
collect
(
Collectors
.
toList
());
userRoleList
.
forEach
(
r
->
{
if
(!
roleIds
.
contains
(
r
.
getSequenceNbr
()))
{
roleIds
.
add
(
r
.
getSequenceNbr
());
}
});
roleSeqMap
.
put
(
companyInfo
.
getSequenceNbr
(),
roleIds
);
orgRoles
.
put
(
companyInfo
.
getSequenceNbr
(),
userRoleList
);
agencyUserModel
.
setAppCodes
(
split
);
agencyUserModel
.
setOrgRoles
(
orgRoles
);
agencyUserModel
.
setOrgRoleSeqs
(
roleSeqMap
);
userResult
=
Privilege
.
agencyUserClient
.
create
(
agencyUserModel
);
if
(
userResult
==
null
||
userResult
.
getResult
()
==
null
)
{
throw
new
BadRequest
(
"单位注册失败"
);
}
String
[]
userIds
=
{
userResult
.
getResult
().
getUserId
()
};
regUnitInfo
.
setAdminUserId
(
userResult
.
getResult
().
getUserId
());
regUnitInfo
.
setAmosCompanySeq
(
companyInfo
.
getSequenceNbr
());
}
catch
(
Exception
e
)
{
// 删除已经创建的 企业信息
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
());
}
}
}
\ No newline at end of file
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/resources/application-dev.properties
View file @
1ee21614
## DB properties:
spring.datasource.url
=
jdbc:mysql://172.16.10.220:3306/
production
?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.url
=
jdbc:mysql://172.16.10.220:3306/
hygf_database
?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.username
=
root
spring.datasource.password
=
Yeejoin@2020
## eureka properties:
...
...
@@ -85,3 +85,9 @@ spring.activemq.user=admin
spring.activemq.password
=
admin
spring.jms.pub-sub-domain
=
false
myqueue
=
amos.privilege.v1.JXIOP.AQSC_FDGL.userBusiness
regulator.unit.code
=
86*258
# Ӧcode
dealer.appcode
=
studio_normalapp_5133538
hygf.sms.tempCode
=
SMS_TZS_0001
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/resources/application.properties
View file @
1ee21614
...
...
@@ -60,3 +60,8 @@ spring.http.encoding.force=true
privilege.fegin.name
=
AMOS-API-PRIVILEGE
feign.client.config.default.connect-timeout
=
20000
feign.client.config.default.read-timeout
=
20000
amos.system.user.user-name
=
hygf_admin
amos.system.user.password
=
a1234567
amos.system.user.product
=
AMOS_STUDIO_WEB
amos.system.user.app-key
=
AMOS_STUDIO
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