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 9413a17b
authored
Nov 23, 2023
by
huangjinxin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop' into develop
2 parents
5ed157c1
9b60af50
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
157 additions
and
36 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/service/impl/EngineerCalendarServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/feign/bean/BeanUserDetail.java
View file @
9413a17
...
...
@@ -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 @
9413a17
...
...
@@ -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
());
}
/**
* 处理全部机构
*
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerCalendarServiceImpl.java
View file @
9413a17
...
...
@@ -450,12 +450,6 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
@Override
public
EngineerCalendarResultDTO
queryEngineerCalendar
(
String
engineerCode
,
LocalDate
startDate
,
LocalDate
endDate
)
{
List
<
String
>
teamIds
=
orgTeamEngineerDao
.
getTeamIdsByEngineerCode
(
engineerCode
);
if
(
CollectionUtils
.
isEmpty
(
teamIds
))
{
//TODO 未查到小队信息如何返回
return
null
;
}
List
<
LocalDate
>
dateRange
=
Stream
.
iterate
(
startDate
,
date
->
date
.
plusDays
(
1
))
.
limit
(
ChronoUnit
.
DAYS
.
between
(
startDate
,
endDate
.
plusDays
(
1
)))
.
collect
(
Collectors
.
toList
());
...
...
@@ -468,14 +462,6 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
Map
<
String
,
List
<
CapacityEngineerCalendarEntity
>>
configs
=
calendarEntityList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
CapacityEngineerCalendarEntity:
:
getWorkday
));
//取teamID
final
String
teamId
=
teamIds
.
get
(
0
);
// 初始化一天的日历
final
OrgTeamEntity
orgTeam
=
orgTeamDao
.
getByTeamId
(
teamId
);
String
[]
workDayArray
=
orgTeam
.
getWorkdays
().
split
(
","
);
List
<
String
>
workDayList
=
new
ArrayList
<>(
Arrays
.
asList
(
workDayArray
));
List
<
EngineerCalendar
>
engineerCalendarResultList
=
dateRange
.
stream
().
map
(
date
->
{
final
String
strDate
=
LocalDateTimeUtil
.
format
(
date
,
PATTERN_DATE
);
final
Instant
instant
=
Timestamp
.
valueOf
(
date
.
atTime
(
LocalTime
.
MIDNIGHT
)).
toInstant
();
...
...
@@ -500,13 +486,12 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
calendars
.
addAll
(
engineerCalendars
);
}
else
{
EngineerCalendar
engineerCalendar
=
new
EngineerCalendar
();
int
dayOfWeek
=
date
.
getDayOfWeek
().
getValue
();
Instant
startInstant
=
LocalDateTime
.
of
(
date
,
LocalTime
.
MIN
).
atZone
(
ZoneId
.
of
(
"+8"
)).
toInstant
();
engineerCalendar
.
setBeginTime
(
Date
.
from
(
startInstant
));
Instant
endInstant
=
LocalDateTime
.
of
(
date
,
LocalTime
.
MAX
).
atZone
(
ZoneId
.
of
(
"+8"
)).
toInstant
();
engineerCalendar
.
setEndTime
(
Date
.
from
(
endInstant
));
engineerCalendar
.
setDate
(
Date
.
from
(
instant
));
if
(!
workDayList
.
contains
(
String
.
valueOf
(
dayOfWeek
)
))
{
if
(!
engineerWorkDay
(
engineerCode
,
date
))
{
engineerCalendar
.
setEventType
(
"REST"
);
engineerCalendar
.
setEvent
(
"休息"
);
engineerCalendar
.
setContent
(
"休息"
);
...
...
@@ -527,11 +512,6 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
private
List
<
EngineerCalendarDTO
.
Calendar
>
getOneEngineerCalendars
(
String
engineerCode
,
String
bdate
,
String
edate
)
{
// 返回某一个技术员,日期范围内的日历列表
List
<
EngineerCalendarDTO
.
Calendar
>
calendars
=
new
ArrayList
<>();
List
<
String
>
teamIds
=
orgTeamEngineerDao
.
getTeamIdsByEngineerCode
(
engineerCode
);
if
(
teamIds
==
null
||
teamIds
.
isEmpty
())
{
return
new
ArrayList
<>();
}
LocalDate
startDate
=
DateUtils
.
localDateFromStr
(
bdate
);
LocalDate
endDate
=
DateUtils
.
localDateFromStr
(
edate
);
List
<
LocalDate
>
datesInRange
=
Stream
.
iterate
(
startDate
,
date
->
date
.
plusDays
(
1
))
...
...
@@ -543,7 +523,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
for
(
LocalDate
date
:
datesInRange
)
{
String
sDate
=
LocalDateTimeUtil
.
format
(
date
,
PATTERN_DATE
);
EngineerCalendarDTO
.
Calendar
calander
=
null
;
calander
=
getEmptyCalendar
(
teamIds
.
get
(
0
),
sDate
);
calander
=
getEmptyCalendar
(
sDate
);
if
(
configs
.
containsKey
(
sDate
))
{
List
<
EngineerCalendarDTO
.
Content
>
contents
=
new
ArrayList
<>();
// 有配置
...
...
@@ -760,7 +740,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
return
!
CollectionUtils
.
isEmpty
(
configs
);
}
private
EngineerCalendarDTO
.
Calendar
getEmptyCalendar
(
String
teamId
,
String
date
)
{
private
EngineerCalendarDTO
.
Calendar
getEmptyCalendar
(
String
date
)
{
// 初始化一天的日历
EngineerCalendarDTO
.
Calendar
calendar
=
new
EngineerCalendarDTO
.
Calendar
();
calendar
.
setDate
(
date
);
...
...
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