Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lyf-beidou-cdp-api
Overview
Overview
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
zhoupeng
lyf-beidou-cdp-api
Commits
e1bb8058
Commit
e1bb8058
authored
Aug 29, 2023
by
zhoupeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交导入组织架构openapi接口
parent
c7a4184c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
3 deletions
+121
-3
SyncEmployeCdpController.java
...m/rome/order/api/controller/SyncEmployeCdpController.java
+20
-3
SyncEmployeCdpService.java
.../com/rome/order/domain/service/SyncEmployeCdpService.java
+17
-0
SyncEmployeCdpServiceImpl.java
.../order/domain/service/impl/SyncEmployeCdpServiceImpl.java
+71
-0
QiDianOpenApiRemoteConstant.java
...tructure/remote/constant/QiDianOpenApiRemoteConstant.java
+13
-0
No files found.
src/main/java/com/rome/order/api/controller/SyncEmployeCdpController.java
View file @
e1bb8058
...
...
@@ -6,9 +6,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
/**
* @Author: zhoupeng
...
...
@@ -32,4 +30,23 @@ public class SyncEmployeCdpController {
return
Response
.
builderSuccess
(
syncEmployeCdpService
.
synAllEmpCdpBase
(
pageNum
));
}
@GetMapping
(
"/synByCdpEmployee"
)
@ApiOperation
(
value
=
"新Cdp根据员工号同步员工信息"
)
public
Response
<
Boolean
>
synByCdpEmployee
(
@RequestParam
(
"employeeNumber"
)
String
employeeNumber
){
Boolean
flag
=
syncEmployeCdpService
.
synByCdpEmployee
(
employeeNumber
);
return
Response
.
builderSuccess
(
flag
);
}
@GetMapping
(
"/syncProgress"
)
@ApiOperation
(
value
=
"新Cdp根据员工号同步员工信息"
)
public
Response
<
String
>
syncProgress
(){
String
progress
=
syncEmployeCdpService
.
synProgress
();
return
Response
.
builderSuccess
(
progress
);
}
}
src/main/java/com/rome/order/domain/service/SyncEmployeCdpService.java
View file @
e1bb8058
...
...
@@ -14,4 +14,21 @@ public interface SyncEmployeCdpService {
* 同步查询员工(基础信息) -(工单系统等)
*/
Boolean
synAllEmpCdpBase
(
Integer
pageNum
);
/**
* 根据员工号同步员工信息
* @param employeeNumber
* @return
*/
Boolean
synByCdpEmployee
(
String
employeeNumber
);
/**
* 查询组织架构导入进度
* @return
*/
String
synProgress
();
}
src/main/java/com/rome/order/domain/service/impl/SyncEmployeCdpServiceImpl.java
View file @
e1bb8058
...
...
@@ -3,11 +3,13 @@ package com.rome.order.domain.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.PageInfo
;
import
com.rome.order.domain.enums.ResponseMsg
;
import
com.rome.order.domain.service.OrganizationRedisService
;
import
com.rome.order.domain.service.SyncEmployeCdpService
;
import
com.rome.order.domain.util.DateUtils
;
import
com.rome.order.domain.util.HmacSHA256Util
;
import
com.rome.order.domain.util.HttpUtil
;
import
com.rome.order.domain.util.ParameterCheckUtils
;
import
com.rome.order.infrastructure.dataobject.SyncEmployeeCdpDO
;
import
com.rome.order.infrastructure.mapper.SyncEmployeeCdpMapper
;
import
com.rome.order.infrastructure.remote.constant.QiDianOpenApiRemoteConstant
;
...
...
@@ -55,6 +57,54 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
return
this
.
synEmpCdp
(
null
,
pageNum
,
1
,
allOrg
);
}
@Override
public
Boolean
synByCdpEmployee
(
String
employeeNumber
)
{
// 参数非空校验
ParameterCheckUtils
.
noNull
(
ResponseMsg
.
PARAM_EMPLOYEENUMBER_NOT_EMPT
,
employeeNumber
);
EmpMainDataResDTO
dataResDTO
=
userEmployeeFacade
.
synByEmployee
(
employeeNumber
);
ParameterCheckUtils
.
noNull
(
ResponseMsg
.
PARAM_EMPLOYEENUMBER_EMPT
,
dataResDTO
);
Long
userId
=
dataResDTO
.
getUserId
();
String
result
=
this
.
orgSetAdminAccountId
(
userId
+
""
);
Boolean
successFlag
=
false
;
String
errMsg
=
""
;
if
(
StringUtils
.
isNotBlank
(
result
)){
Map
map
=
JSONObject
.
parseObject
(
result
,
Map
.
class
);
if
(
Objects
.
nonNull
(
map
.
get
(
"status"
)))
{
Object
statusObj
=
map
.
get
(
"status"
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
statusObj
));
String
code
=
jsonObject
.
getString
(
"code"
);
String
message
=
jsonObject
.
getString
(
"message"
);
//返回为1 表示成功
if
(
RemoteConstant
.
CODE
.
equals
(
code
)){
successFlag
=
true
;
}
else
{
//其他的表示失败
errMsg
=
message
;
}
}
}
return
successFlag
;
}
@Override
public
String
synProgress
()
{
try
{
String
timestamp
=
DateUtils
.
convert
(
new
Date
(),
DateUtils
.
YYYYMMDDHHMMSS
);
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"corporationId"
,
"0"
);
headers
.
put
(
"timestamp"
,
timestamp
);
String
sign
=
HmacSHA256Util
.
getSign
(
timestamp
);
headers
.
put
(
"sign"
,
sign
);
log
.
info
(
"------指定某员工为企业管理员查询组织架构导入进度头部信息------:{}"
,
JSON
.
toJSONString
(
headers
));
String
result
=
HttpUtil
.
httpGet
(
QiDianOpenApiRemoteConstant
.
SYNC_PROGRESS_URL
,
headers
);
log
.
info
(
"----synProgress返回信息----:{}"
,
result
);
return
result
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
e
.
getMessage
();
}
}
/**
* 同步员工数据
...
...
@@ -205,6 +255,26 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
}
}
private
String
orgSetAdminAccountId
(
String
accountId
){
try
{
log
.
info
(
"-----指定某员工为企业管理员/api/dataauth/authserver/openapi/org/set/admin入参信息----:{}"
,
accountId
);
String
timestamp
=
DateUtils
.
convert
(
new
Date
(),
DateUtils
.
YYYYMMDDHHMMSS
);
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"corporationId"
,
"0"
);
headers
.
put
(
"timestamp"
,
timestamp
);
String
sign
=
HmacSHA256Util
.
getSign
(
timestamp
);
headers
.
put
(
"sign"
,
sign
);
log
.
info
(
"------指定某员工为企业管理员/api/dataauth/authserver/openapi/org/set/admin头部信息------:{}"
,
JSON
.
toJSONString
(
headers
));
String
result
=
HttpUtil
.
httpGet
(
QiDianOpenApiRemoteConstant
.
SET_ADMIN_ACCOUNT_URL
+
accountId
,
headers
);
log
.
info
(
"----orgSetAdminAccountId返回信息----:{}"
,
result
);
return
result
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
/**
* 同步导入组织架构和人员信息到企点
* @param staffs
...
...
@@ -221,6 +291,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
headers
.
put
(
"sign"
,
sign
);
log
.
info
(
"------同步导入组织架构和人员信息到企点/api/dataauth/authserver/openapi/org/sync头部信息------:{}"
,
JSON
.
toJSONString
(
headers
));
String
result
=
HttpUtil
.
httpPost
(
QiDianOpenApiRemoteConstant
.
ORG_SYNC_URL
,
bodyStr
,
headers
);
log
.
info
(
"----syncCdpEmpOrg返回信息----:{}"
,
result
);
return
result
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
src/main/java/com/rome/order/infrastructure/remote/constant/QiDianOpenApiRemoteConstant.java
View file @
e1bb8058
...
...
@@ -14,4 +14,17 @@ public class QiDianOpenApiRemoteConstant {
* 导入组织架构openapi接口
*/
public
static
String
ORG_SYNC_URL
=
"/api/dataauth/authserver/openapi/org/sync"
;
/**
* 导入组织架构openapi接口
*/
public
static
String
SET_ADMIN_ACCOUNT_URL
=
"/api/dataauth/authserver/openapi/org/set/admin?account="
;
/**
* 查询组织架构导入进度接口
*/
public
static
String
SYNC_PROGRESS_URL
=
"/api/dataauth/authserver/openapi/org/sync/progress"
;
}
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