Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 06e41c0d
authored
Nov 23, 2023
by
刘鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(bean 自有工程师): 同步指定分站下工程师数据除工作地址、工号处理外逻辑
1 parent
e89c42fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
154 additions
and
13 deletions
project-order/src/main/java/com/dituhui/pea/order/feign/bean/BeanUserDetail.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/BeanRemoteServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/feign/bean/BeanUserDetail.java
View file @
06e41c0
...
...
@@ -94,7 +94,7 @@ public class BeanUserDetail {
/**
* 工作城市
*/
private
String
workCity
;
private
Address
workCity
;
/**
* 常用出发地址,常驻的工作地址
*/
...
...
@@ -122,7 +122,7 @@ public class BeanUserDetail {
/**
* 是否兼职拉修,0:否,1:是
*/
private
String
partTimeRepair
;
private
Integer
partTimeRepair
;
/**
* 所属拉修车间
*/
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/BeanRemoteServiceImpl.java
View file @
06e41c0
...
...
@@ -8,14 +8,31 @@ import com.dituhui.pea.common.Result;
import
com.dituhui.pea.enums.StatusCodeEnum
;
import
com.dituhui.pea.order.common.RedisService
;
import
com.dituhui.pea.order.common.jackson.JsonUtil
;
import
com.dituhui.pea.order.dao.EngineerBusinessDao
;
import
com.dituhui.pea.order.dao.EngineerInfoDao
;
import
com.dituhui.pea.order.dao.OrgBranchDao
;
import
com.dituhui.pea.order.dao.OrgClusterDao
;
import
com.dituhui.pea.order.dao.OrgGroupDao
;
import
com.dituhui.pea.order.entity.EngineerBusinessEntity
;
import
com.dituhui.pea.order.entity.EngineerInfoEntity
;
import
com.dituhui.pea.order.entity.OrgBranchEntity
;
import
com.dituhui.pea.order.entity.OrgClusterEntity
;
import
com.dituhui.pea.order.entity.OrgGroupEntity
;
import
com.dituhui.pea.order.feign.IBeanRemoteService
;
import
com.dituhui.pea.order.feign.bean.*
;
import
com.dituhui.pea.order.feign.bean.AccessToken
;
import
com.dituhui.pea.order.feign.bean.Address
;
import
com.dituhui.pea.order.feign.bean.AllotResultParam
;
import
com.dituhui.pea.order.feign.bean.BeanAccountInfo
;
import
com.dituhui.pea.order.feign.bean.BeanR
;
import
com.dituhui.pea.order.feign.bean.BeanUserDetail
;
import
com.dituhui.pea.order.feign.bean.BranchDetail
;
import
com.dituhui.pea.order.feign.bean.BranchRes
;
import
com.dituhui.pea.order.feign.bean.Department
;
import
com.dituhui.pea.order.feign.bean.OrderCancel
;
import
com.dituhui.pea.order.feign.bean.Reason
;
import
com.dituhui.pea.order.feign.bean.Rescheduled
;
import
com.dituhui.pea.order.feign.bean.ServiceOrg
;
import
com.dituhui.pea.order.feign.bean.ServiceOrgDetail
;
import
com.dituhui.pea.order.feign.bean.enums.BeanOrgLevelEnum
;
import
com.dituhui.pea.order.feign.bean.enums.BeanPointTypeEnum
;
import
com.dituhui.pea.order.feign.bean.enums.BeanRegionIdEnum
;
...
...
@@ -23,11 +40,18 @@ import lombok.RequiredArgsConstructor;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
javax.transaction.Transactional
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* 调用BEAN远程接口实现
...
...
@@ -40,6 +64,11 @@ public class BeanRemoteServiceImpl {
private
final
IBeanRemoteService
beanRemoteService
;
private
final
RedisService
redisService
;
private
final
OrgClusterDao
orgClusterDao
;
private
final
OrgBranchDao
orgBranchDao
;
private
final
OrgGroupDao
orgGroupDao
;
private
final
EngineerInfoDao
engineerInfoDao
;
private
final
EngineerBusinessDao
engineerBusinessDao
;
//组织机构map,防止重复查询数据库
private
static
Map
<
String
,
OrgBranchEntity
>
branchMap
=
new
HashMap
<>();
// 上海大区,部门ID:1575934909016727553,华东大区:1575934912659275778
...
...
@@ -56,14 +85,6 @@ public class BeanRemoteServiceImpl {
@Value
(
"${bean.secret-key}"
)
private
String
secretKey
;
@Autowired
private
OrgClusterDao
orgClusterDao
;
@Autowired
private
OrgBranchDao
orgBranchDao
;
@Autowired
private
OrgGroupDao
orgGroupDao
;
//TODO 仅用于联通测试
public
void
testAllDepartment
()
{
...
...
@@ -148,6 +169,126 @@ public class BeanRemoteServiceImpl {
}
/**
* 获取指定机构(BEAN)下的工程师信息(详细), 并存储, 不包含子部门
*
* @param departId BEAN提供的部门ID--这里由于数据入库原因 查询时应只提供group级别数据
*/
@Transactional
public
void
listDepartUserAndSaveUserDetailInfo
(
String
departId
)
{
BeanR
<
List
<
BeanAccountInfo
>>
userListR
=
beanRemoteService
.
queryUserList
(
getAccessToken
(),
departId
);
log
.
info
(
"[listDepartUserAndSaveUserDetailInfo]【/api/openapi/user/queryList】参数:{},返回值-------------------->{}"
,
departId
,
JsonUtil
.
toJson
(
userListR
));
List
<
BeanAccountInfo
>
userlist
=
userListR
.
getData
();
if
(!
userListR
.
getSuccess
()
||
Objects
.
isNull
(
userlist
))
{
log
.
error
(
"[listDepartUserAndSaveUserDetailInfo]【/api/openapi/user/queryList】,没有返回正确的用户列表数据, 请求参数: {}, 错误信息:{}"
,
departId
,
userListR
.
getMessage
());
throw
new
com
.
dituhui
.
pea
.
exception
.
BusinessException
(
StatusCodeEnum
.
NO_DATA
);
}
final
int
userCount
=
userlist
.
size
();
log
.
info
(
"[listDepartUserAndSaveUserDetailInfo] 部门ID为:{}的部门下共{}个工程师信息"
,
departId
,
userCount
);
for
(
BeanAccountInfo
account
:
userlist
)
{
log
.
info
(
"开始同步人员信息{}"
,
JsonUtil
.
toJson
(
account
));
BeanR
<
BeanUserDetail
>
beanUserDetailBeanR
=
beanRemoteService
.
userDetail
(
getAccessToken
(),
account
.
getHrId
());
log
.
info
(
"[查询BEAN用户详情]【/api/openapi/user/queryDetail】返回值-------------------->{}"
,
JsonUtil
.
toJson
(
beanUserDetailBeanR
));
BeanUserDetail
userDetailInfo
=
beanUserDetailBeanR
.
getData
();
if
(!
beanUserDetailBeanR
.
getSuccess
()
||
Objects
.
isNull
(
userDetailInfo
))
{
log
.
error
(
"用户详情列表未获取到用户:{}-{}的详细信息 , 错误信息:{}"
,
account
.
getUserName
(),
account
.
getCenterId
(),
beanUserDetailBeanR
.
getMessage
());
continue
;
}
String
engineerCode
=
userDetailInfo
.
getWorkNo
();
if
(
StringUtils
.
isBlank
(
engineerCode
))
{
log
.
warn
(
"分站:{}工程师{}没有工号"
,
departId
,
userDetailInfo
.
getUsername
());
continue
;
}
engineerCode
=
"BEAN"
+
engineerCode
;
//查询是否有当前工程师工号
EngineerInfoEntity
engineerInfo
=
engineerInfoDao
.
getByEngineerCode
(
engineerCode
);
//获取有用信息保存工程师信息
if
(
Objects
.
isNull
(
engineerInfo
))
{
engineerInfo
=
new
EngineerInfoEntity
();
}
engineerInfo
.
setEngineerCode
(
engineerCode
);
engineerInfo
.
setName
(
userDetailInfo
.
getUsername
());
engineerInfo
.
setGroupId
(
departId
);
engineerInfo
.
setCosmosId
(
userDetailInfo
.
getHrId
());
engineerInfo
.
setGender
(
userDetailInfo
.
getGender
());
engineerInfo
.
setBirth
(
StringUtils
.
isBlank
(
userDetailInfo
.
getBirthday
())
?
""
:
getYear
(
userDetailInfo
.
getBirthday
()));
engineerInfo
.
setAddress
(
""
);
engineerInfo
.
setPhone
(
userDetailInfo
.
getCellPhone
());
engineerInfo
.
setKind
(
1
==
userDetailInfo
.
getPartTimeRepair
()
?
2
:
1
);
engineerInfo
.
setGrade
(
Objects
.
isNull
(
userDetailInfo
.
getGrade
())
?
""
:
userDetailInfo
.
getGrade
());
// engineerInfo.setCredentials();
//默认汽车
engineerInfo
.
setVehicle
(
1
);
engineerInfo
.
setBeanStatus
(
0
==
userDetailInfo
.
getIsDelete
()
?
1
:
0
);
//fixme 工作地址存贮
Address
address
=
userDetailInfo
.
getAddress
();
if
(
Objects
.
nonNull
(
address
))
{
engineerInfo
.
setWorkAddress
(
address
.
getAddress
());
}
else
{
engineerInfo
.
setWorkAddress
(
""
);
}
engineerInfo
.
setCreateTime
(
LocalDateTime
.
now
());
engineerInfo
.
setUpdateTime
(
LocalDateTime
.
now
());
engineerInfoDao
.
save
(
engineerInfo
);
engineerInfoDao
.
flush
();
//保存业务属性信息--常用出发地信息
EngineerBusinessEntity
engineerBusiness
=
engineerBusinessDao
.
getByEngineerCode
(
engineerCode
);
if
(
Objects
.
nonNull
(
engineerBusiness
))
{
continue
;
}
engineerBusiness
=
new
EngineerBusinessEntity
();
engineerBusiness
.
setEngineerCode
(
engineerCode
);
//以下为数据库默认值
engineerBusiness
.
setWorkOn
(
"08:00"
);
engineerBusiness
.
setWorkOff
(
"18:00"
);
engineerBusiness
.
setMaxMinute
(
600
);
engineerBusiness
.
setMaxNum
(
0
);
engineerBusiness
.
setMaxDistance
(
0
);
//fixme 工作地址存贮
if
(
Objects
.
nonNull
(
address
))
{
engineerBusiness
.
setAddress
(
Objects
.
isNull
(
address
.
getAddress
())
?
""
:
address
.
getAddress
());
engineerBusiness
.
setX
(
Objects
.
isNull
(
address
.
getLongitude
())
?
""
:
address
.
getLongitude
());
engineerBusiness
.
setY
(
Objects
.
isNull
(
address
.
getLatitude
())
?
""
:
address
.
getLatitude
());
}
else
{
engineerBusiness
.
setAddress
(
""
);
engineerBusiness
.
setX
(
""
);
engineerBusiness
.
setY
(
""
);
}
engineerBusiness
.
setVehicle
(
"1"
);
engineerBusiness
.
setVehicleNo
(
""
);
engineerBusiness
.
setPriority
(
1
);
engineerBusiness
.
setDeparture
(
3
);
engineerBusiness
.
setDispatchStrategy
(
"CENTER"
);
engineerBusiness
.
setCreateTime
(
LocalDateTime
.
now
());
engineerBusiness
.
setUpdateTime
(
LocalDateTime
.
now
());
engineerBusinessDao
.
save
(
engineerBusiness
);
}
}
private
Date
converter
(
String
timestamp
)
{
return
new
Date
(
Long
.
parseLong
(
timestamp
));
}
private
String
getYear
(
String
timestamp
)
{
return
String
.
valueOf
(
converter
(
timestamp
).
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
getYear
());
}
/**
* 处理全部机构
*
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment