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 b856e715
authored
Oct 16, 2023
by
刘鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CI: 查询技术员日历对外接口逻辑
1 parent
c047e1a7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
19 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/PeaApiController.java
project-order/src/main/java/com/dituhui/pea/order/dto/param/EngineerCalendar.java
project-order/src/main/java/com/dituhui/pea/order/service/EngineerCalendarService.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerCalendarServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/controller/PeaApiController.java
View file @
b856e71
...
...
@@ -3,32 +3,20 @@ package com.dituhui.pea.order.controller;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.OrganizationTreeDTO
;
import
com.dituhui.pea.order.dto.param.BaseDistance
;
import
com.dituhui.pea.order.dto.param.CapacityQueryDTO
;
import
com.dituhui.pea.order.dto.param.EngineerCalendarResultDTO
;
import
com.dituhui.pea.order.dto.param.EngineerOrderParam
;
import
com.dituhui.pea.order.dto.param.EngineerParamDTO
;
import
com.dituhui.pea.order.dto.param.EstimateDTO
;
import
com.dituhui.pea.order.dto.param.Order
;
import
com.dituhui.pea.order.dto.param.OrderConfirmParam
;
import
com.dituhui.pea.order.dto.param.OrderConfirmResult
;
import
com.dituhui.pea.order.dto.param.OrderDTO
;
import
com.dituhui.pea.order.dto.param.ValidGroup
;
import
com.dituhui.pea.order.dto.param.*
;
import
com.dituhui.pea.order.service.EngineerCalendarService
;
import
com.dituhui.pea.util.DateUtil
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDate
;
import
java.time.Period
;
import
java.time.ZoneId
;
import
java.util.Date
;
/**
...
...
@@ -40,6 +28,8 @@ import java.util.Date;
@Validated
public
class
PeaApiController
{
private
final
EngineerCalendarService
engineerCalendarService
;
/**
* 2.1MQ 组织架构同步事件通知
...
...
@@ -95,8 +85,11 @@ public class PeaApiController {
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
@RequestParam
(
value
=
"endDate"
)
Date
endDate
)
{
final
ZoneId
zoneId
=
ZoneId
.
of
(
"+8"
);
LocalDate
beginLocalDate
=
beginDate
.
toInstant
().
atZone
(
zoneId
).
toLocalDate
();
LocalDate
endLocalDate
=
endDate
.
toInstant
().
atZone
(
zoneId
).
toLocalDate
();
return
Result
.
success
(
new
EngineerCalendarResultDTO
(
));
return
Result
.
success
(
engineerCalendarService
.
queryEngineerCalendar
(
engineerCode
,
beginLocalDate
,
endLocalDate
));
}
...
...
project-order/src/main/java/com/dituhui/pea/order/dto/param/EngineerCalendar.java
View file @
b856e71
...
...
@@ -34,6 +34,8 @@ public class EngineerCalendar {
/**
* 结束时间
*/
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
endTime
;
/**
* 备注
...
...
project-order/src/main/java/com/dituhui/pea/order/service/EngineerCalendarService.java
View file @
b856e71
...
...
@@ -2,6 +2,9 @@ package com.dituhui.pea.order.service;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.dto.param.EngineerCalendarResultDTO
;
import
java.time.LocalDate
;
public
interface
EngineerCalendarService
{
...
...
@@ -20,4 +23,13 @@ public interface EngineerCalendarService {
Result
<?>
queryEngineerPlanNum
(
CalendarQueryNumDTO
.
Request
reqDTO
);
Result
<?>
batchDeletePlan
(
String
userId
,
CalendarBatDelDTO
.
Request
reqDTO
);
/**
* 查询工程师日期范围内的日历事件安排, 返回的内容包括:(多条)开始时间,结束时间,事件代码,事件名称,事件说明
* @param engineerCode 工程师编码
* @param startDate 开始日期
* @param endDate 结束日期
* @return 日期范围内的日历, 包含开始时间,结束时间,事件代码,事件名称,事件说明
*/
EngineerCalendarResultDTO
queryEngineerCalendar
(
String
engineerCode
,
LocalDate
startDate
,
LocalDate
endDate
);
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerCalendarServiceImpl.java
View file @
b856e71
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
cn.hutool.core.util.IdUtil
;
import
com.dituhui.pea.common.Result
;
...
...
@@ -7,6 +8,8 @@ import com.dituhui.pea.order.common.DateUtils;
import
com.dituhui.pea.order.common.EngineerUtils
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.dto.param.EngineerCalendar
;
import
com.dituhui.pea.order.dto.param.EngineerCalendarResultDTO
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.service.EngineerCalendarService
;
import
com.dituhui.pea.user.IUser
;
...
...
@@ -14,11 +17,12 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Page
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.sql.Timestamp
;
import
java.time.*
;
import
java.time.format.DateTimeFormatter
;
import
java.time.temporal.ChronoUnit
;
...
...
@@ -319,6 +323,78 @@ 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
());
List
<
CapacityEngineerCalendarEntity
>
calendarEntityList
=
capacityEngineerCalendarDao
.
findCalendarByEngineerCodeAndDateBetween
(
engineerCode
,
LocalDateTimeUtil
.
format
(
startDate
,
DatePattern
.
NORM_DATE_FORMATTER
),
LocalDateTimeUtil
.
format
(
endDate
,
DatePattern
.
NORM_DATE_FORMATTER
));
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
();
List
<
EngineerCalendar
>
calendars
=
new
ArrayList
<>();
if
(
configs
.
containsKey
(
strDate
))
{
List
<
CapacityEngineerCalendarEntity
>
capacityEngineerCalendars
=
configs
.
get
(
strDate
);
List
<
EngineerCalendar
>
engineerCalendars
=
capacityEngineerCalendars
.
stream
().
map
(
entity
->
{
EngineerCalendar
engineerCalendar
=
new
EngineerCalendar
();
engineerCalendar
.
setDate
(
Date
.
from
(
instant
));
engineerCalendar
.
setType
(
entity
.
getType
());
Instant
startInstant
=
entity
.
getStartTime
().
atZone
(
ZoneId
.
of
(
"+8"
)).
toInstant
();
engineerCalendar
.
setBeginTime
(
Date
.
from
(
startInstant
));
Instant
endInstant
=
entity
.
getEndTime
().
atZone
(
ZoneId
.
of
(
"+8"
)).
toInstant
();
engineerCalendar
.
setEndTime
(
Date
.
from
(
endInstant
));
engineerCalendar
.
setMemo
(
entity
.
getMemo
());
return
engineerCalendar
;
}).
collect
(
Collectors
.
toList
());
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
)))
{
engineerCalendar
.
setType
(
"REST"
);
}
calendars
.
add
(
engineerCalendar
);
}
return
calendars
;
}).
flatMap
(
List:
:
stream
).
collect
(
Collectors
.
toList
());
EngineerInfoEntity
engineerInfoEntity
=
engineerInfoDao
.
getByEngineerCode
(
engineerCode
);
EngineerCalendarResultDTO
result
=
new
EngineerCalendarResultDTO
();
result
.
setEngineerName
(
engineerInfoEntity
.
getName
());
result
.
setEngineerCode
(
engineerInfoEntity
.
getEngineerCode
());
result
.
setCalendar
(
engineerCalendarResultList
);
return
result
;
}
private
List
<
EngineerCalendarDTO
.
Calendar
>
getOneEngineerCalendars
(
String
engineerCode
,
String
bdate
,
String
edate
)
{
// 返回某一个技术员,日期范围内的日历列表
List
<
EngineerCalendarDTO
.
Calendar
>
calendars
=
new
ArrayList
<>();
...
...
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