Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xm-sportstest
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiamai-test
xm-sportstest
Commits
079e6625
Commit
079e6625
authored
Jul 13, 2024
by
DuJunLi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编辑训练营排课课次,删除训练营排课课次,优化代码
parent
0bf67329
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
201 additions
and
34 deletions
+201
-34
src/main/java/com/xiaomai/cases/polar/schedule/camp/CampScheduleTools.java
+4
-1
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestCreateCampRuleSchedule.java
+2
-6
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestDelCampScheduleItem.java
+123
-0
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestEditCampRuleSchedule.java
+0
-3
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestEditCampScheduleItem.java
+0
-0
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestGetCampScheduleItemDetail.java
+0
-3
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestGetCampScheduleTable.java
+1
-5
src/main/java/com/xiaomai/cases/polar/schedule/group/TestEditGroupSchedule.java
+4
-16
src/main/java/com/xiaomai/utils/CommUtil.java
+67
-0
No files found.
src/main/java/com/xiaomai/cases/polar/schedule/camp/CampScheduleTools.java
View file @
079e6625
...
@@ -275,9 +275,11 @@ public class CampScheduleTools extends XMBaseTest {
...
@@ -275,9 +275,11 @@ public class CampScheduleTools extends XMBaseTest {
}
}
return
null
;
return
null
;
}
}
}
}
\ No newline at end of file
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestCreateCampRuleSchedule.java
View file @
079e6625
...
@@ -37,7 +37,6 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
...
@@ -37,7 +37,6 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
@Test
(
description
=
"创建训练营排课日程"
)
@Test
(
description
=
"创建训练营排课日程"
)
public
void
testCreateCampRuleSchedule
()
{
public
void
testCreateCampRuleSchedule
()
{
System
.
out
.
println
(
"*********************"
+
campInfo
);
//从训练营活动中获取教练信息
//从训练营活动中获取教练信息
String
chiefCoachId
=
super
.
chiefCoachId
;
String
chiefCoachId
=
super
.
chiefCoachId
;
...
@@ -47,7 +46,7 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
...
@@ -47,7 +46,7 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
//获取存量场地
//获取存量场地
List
<
String
>
venueAreaIds
=
groupScheduleTools
.
getStockArea
(
"流星花园秘密基地"
);
List
<
String
>
venueAreaIds
=
groupScheduleTools
.
getStockArea
(
"流星花园秘密基地"
);
String
campId
=
super
.
campId
;
String
campId
=
super
.
campId
;
//创建训练营排课
//创建训练营排课
:按日期
campScheduleTools
.
createCampRuleSchedule
(
campId
,
assistCoachIds
,
chiefCoachId
,
super
.
courseId
,
campScheduleTools
.
createCampRuleSchedule
(
campId
,
assistCoachIds
,
chiefCoachId
,
super
.
courseId
,
super
.
traineeLowerLimit
,
super
.
traineeUpperLimit
,
super
.
traineeLowerLimit
,
super
.
traineeUpperLimit
,
"1020"
,
super
.
openStartDate
,
super
.
openEndDate
,
true
,
"1020"
,
super
.
openStartDate
,
super
.
openEndDate
,
true
,
...
@@ -61,10 +60,7 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
...
@@ -61,10 +60,7 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
@AfterClass
(
description
=
"删除此case创建的训练营排课日程和训练营活动"
)
@AfterClass
(
description
=
"删除此case创建的训练营排课日程和训练营活动"
)
public
void
delData
()
{
public
void
delData
()
{
if
(
null
!=
ruldId
||!
ruldId
.
isEmpty
())
{
//直接删除训练营会的,对应的排课日程会被自动删除,校验其他case中已有
campScheduleTools
.
delCampRuleSchedule
(
ruldId
);
}
if
(
null
!=
campId
||!
campId
.
isEmpty
())
{
if
(
null
!=
campId
||!
campId
.
isEmpty
())
{
this
.
getTrainingTools
().
deleteTraining
(
campId
);
this
.
getTrainingTools
().
deleteTraining
(
campId
);
}
}
...
...
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestDelCampScheduleItem.java
0 → 100644
View file @
079e6625
package
com
.
xiaomai
.
cases
.
polar
.
schedule
.
camp
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.CommUtil
;
import
com.xiaomai.utils.XMJSONPath
;
import
org.testng.Assert
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
javax.annotation.Resource
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Set
;
/**
* 删除训练营课次(单个/当前及后续)
* @author adu
* data 2024/7/12 17:05
*/
public
class
TestDelCampScheduleItem
extends
SelectTargetTrainingCampAndGetInfo
{
@Resource
(
name
=
"campScheduleTools"
)
CampScheduleTools
campScheduleTools
;
String
campId
=
""
;
String
chiefCoachId
=
""
;
String
ruldId
=
""
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Schedule
,
"API_delCampScheduleItem"
,
LoginAccount
.
ADU_PROD
,
Terminal
.
B
,
"adu"
);
super
.
beforeTest
();
// 获取选择的训练营ID
campId
=
super
.
campId
;
//1.2获取训练营活动的指定教练ID
chiefCoachId
=
super
.
chiefCoachId
;
//获取目标时间段内 最大有效课时数
String
[]
weekDaysArray
=
{
"TUESDAY"
,
"THURSDAY"
,
"SATURDAY"
,
"SUNDAY"
};
List
<
String
>
weekdaysList
=
Arrays
.
asList
(
weekDaysArray
);
int
loopNum
=
campScheduleTools
.
queryExpectedLoopNum
(
CommUtil
.
oneKeyGetAddDay
(
3
),
super
.
openEndDate
,
weekdaysList
);
//创建训练营排课:按次数 星期:2,4,6,7
campScheduleTools
.
oneKeyCreateCampRuleSchedule
(
campId
,
chiefCoachId
,
super
.
courseId
,
super
.
traineeLowerLimit
,
super
.
traineeUpperLimit
,
"1140"
,
super
.
openEndDate
,
true
,
String
.
valueOf
(
loopNum
));
//查询排课日程:根据训练营和关联课程查询
campScheduleTools
.
getCampRuleScheduleList
(
campId
,
super
.
courseId
,
""
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
size
()
==
1
,
"排课创建成功后,日程中没查询到对应数据"
);
ruldId
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
getJSONObject
(
0
).
getString
(
"ruleId"
);
}
@Test
(
description
=
"删除当前课次"
)
public
void
testDelCurrentCampScheduleItem
(){
//获取下周日课次ID
Set
<
String
>
scheduleIds7
=
campScheduleTools
.
getCampTableDate
(
13
);
if
(
scheduleIds7
.
size
()
!=
0
&&
scheduleIds7
!=
null
){
//删除下周日所有的课次
scheduleIds7
.
stream
().
forEach
(
scheduleId
->
{
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"applyRestRule"
,
false
);
body
.
put
(
"scheduleId"
,
scheduleId
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
});
//删除成功后check 下周日课表是否有数据
String
startDate
=
CommUtil
.
oneKeyGetNextWeekXDay
(
13
);
//下周日00点时间
String
endDate
=
CommUtil
.
oneKeyGetNextWeekEndXDay
(
7
);
//下周日23:59
campScheduleTools
.
getCampScheduleTable
(
startDate
,
endDate
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.totalCount"
),
"0"
);
}
}
@Test
(
description
=
"删除当前及后续课次"
,
priority
=
1
)
public
void
testDelCurrentAndSubsequentCampSchedule
()
{
//获取下周六课次ID
Set
<
String
>
scheduleIds6
=
campScheduleTools
.
getCampTableDate
(
12
);
if
(
scheduleIds6
.
size
()
!=
0
&&
scheduleIds6
!=
null
){
//删除下周日所有的课次
scheduleIds6
.
stream
().
forEach
(
scheduleId
->
{
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"applyRestRule"
,
true
);
body
.
put
(
"scheduleId"
,
scheduleId
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
});
//删除成功后check从下周六到排课结束日期课表是否有数据
String
startDate
=
CommUtil
.
oneKeyGetNextWeekXDay
(
12
);
//下周六00点时间
campScheduleTools
.
getCampScheduleTable
(
startDate
,
super
.
openEndDate
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.totalCount"
),
"0"
);
}
}
@AfterClass
(
description
=
"删除此case创建的训练营排课日程"
)
public
void
delData
()
{
//先删除规则,再操作删除对应的训练营活动,此处顺序不能换,如果先删除训练营活动,对应的排课会自动删除,所以就不用删除排课日程了,这个场景其他case中会体现
if
(
null
!=
ruldId
||!
ruldId
.
isEmpty
())
{
campScheduleTools
.
delCampRuleSchedule
(
ruldId
);
//删除日程后check 日程列表数据是否还能搜索到,期望搜索结果数据为空
campScheduleTools
.
getCampRuleScheduleList
(
campId
,
super
.
courseId
,
""
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
size
()
==
0
,
"日程被删除后,对应的排课日程列表还可以查到相关数据"
);
}
if
(
null
!=
campId
||!
campId
.
isEmpty
())
{
this
.
getTrainingTools
().
deleteTraining
(
campId
);
}
}
}
\ No newline at end of file
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestEditCampRuleSchedule.java
View file @
079e6625
...
@@ -103,9 +103,6 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo
...
@@ -103,9 +103,6 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo
@AfterClass
(
description
=
"删除此case创建的训练营排课日程"
)
@AfterClass
(
description
=
"删除此case创建的训练营排课日程"
)
public
void
delData
()
{
public
void
delData
()
{
if
(
null
!=
ruldId
||!
ruldId
.
isEmpty
())
{
campScheduleTools
.
delCampRuleSchedule
(
ruldId
);
}
if
(
null
!=
campId
||!
campId
.
isEmpty
())
{
if
(
null
!=
campId
||!
campId
.
isEmpty
())
{
this
.
getTrainingTools
().
deleteTraining
(
campId
);
this
.
getTrainingTools
().
deleteTraining
(
campId
);
}
}
...
...
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestEditCampScheduleItem.java
0 → 100644
View file @
079e6625
This diff is collapsed.
Click to expand it.
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestGetCampScheduleItemDetail.java
View file @
079e6625
...
@@ -90,9 +90,6 @@ public class TestGetCampScheduleItemDetail extends SelectTargetTrainingCampAndGe
...
@@ -90,9 +90,6 @@ public class TestGetCampScheduleItemDetail extends SelectTargetTrainingCampAndGe
@AfterClass
(
description
=
"删除此case创建的训练营排课日程"
)
@AfterClass
(
description
=
"删除此case创建的训练营排课日程"
)
public
void
delData
()
{
public
void
delData
()
{
if
(
null
!=
ruldId
||
!
ruldId
.
isEmpty
())
{
campScheduleTools
.
delCampRuleSchedule
(
ruldId
);
}
if
(
null
!=
campId
||
!
campId
.
isEmpty
())
{
if
(
null
!=
campId
||
!
campId
.
isEmpty
())
{
this
.
getTrainingTools
().
deleteTraining
(
campId
);
this
.
getTrainingTools
().
deleteTraining
(
campId
);
}
}
...
...
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestGetCampScheduleTable.java
View file @
079e6625
...
@@ -17,7 +17,6 @@ import org.testng.annotations.Test;
...
@@ -17,7 +17,6 @@ import org.testng.annotations.Test;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* 测试获取训练营排课课表
* 测试获取训练营排课课表
...
@@ -113,11 +112,8 @@ public class TestGetCampScheduleTable extends SelectTargetTrainingCampAndGetInfo
...
@@ -113,11 +112,8 @@ public class TestGetCampScheduleTable extends SelectTargetTrainingCampAndGetInfo
Assert
.
assertTrue
(
resultCount
>=
total
,
"查询到的课表数据和预期不一致"
);
Assert
.
assertTrue
(
resultCount
>=
total
,
"查询到的课表数据和预期不一致"
);
}
}
@AfterClass
(
description
=
"删除此case创建的训练营排课日程"
)
@AfterClass
(
description
=
"删除此case创建的训练营排课日程
,只操作删除对应的训练营活动即可
"
)
public
void
delData
()
{
public
void
delData
()
{
if
(
null
!=
ruldId
||!
ruldId
.
isEmpty
())
{
campScheduleTools
.
delCampRuleSchedule
(
ruldId
);
}
if
(
null
!=
campId
||!
campId
.
isEmpty
())
{
if
(
null
!=
campId
||!
campId
.
isEmpty
())
{
this
.
getTrainingTools
().
deleteTraining
(
campId
);
this
.
getTrainingTools
().
deleteTraining
(
campId
);
}
}
...
...
src/main/java/com/xiaomai/cases/polar/schedule/group/TestEditGroupSchedule.java
View file @
079e6625
...
@@ -52,7 +52,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
...
@@ -52,7 +52,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
body
.
put
(
"applyRestRule"
,
false
);
body
.
put
(
"applyRestRule"
,
false
);
body
.
put
(
"scheduleId"
,
scheduleId
);
body
.
put
(
"scheduleId"
,
scheduleId
);
//获取下周四某个时间点的开始时间戳
//获取下周四某个时间点的开始时间戳
String
startStamp
=
getWholeHourTimeStamp
(
10
,
"13:30"
);
String
startStamp
=
CommUtil
.
getWholeHourTimeStamp
(
10
,
"13:30"
);
body
.
put
(
"startTime"
,
startStamp
);
body
.
put
(
"startTime"
,
startStamp
);
body
.
put
(
"chiefCoachId"
,
chiefCoachIdS
);
body
.
put
(
"chiefCoachId"
,
chiefCoachIdS
);
...
@@ -100,7 +100,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
...
@@ -100,7 +100,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
body
.
put
(
"applyRestRule"
,
true
);
//改的时日程当前及后续
body
.
put
(
"applyRestRule"
,
true
);
//改的时日程当前及后续
body
.
put
(
"scheduleId"
,
scheduleId
);
body
.
put
(
"scheduleId"
,
scheduleId
);
//获取下周二某个时间点的开始时间戳
//获取下周二某个时间点的开始时间戳
String
startStamp1
=
getWholeHourTimeStamp
(
8
,
"13:00"
);
String
startStamp1
=
CommUtil
.
getWholeHourTimeStamp
(
8
,
"13:00"
);
body
.
put
(
"startTime"
,
startStamp1
);
body
.
put
(
"startTime"
,
startStamp1
);
body
.
put
(
"chiefCoachId"
,
chiefCoachIdS
);
body
.
put
(
"chiefCoachId"
,
chiefCoachIdS
);
...
@@ -123,7 +123,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
...
@@ -123,7 +123,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
//查看下周三课次是否同步被修改
//查看下周三课次是否同步被修改
Set
<
String
>
scheduleIdX
=
groupScheduleTools
.
getTableDate
(
9
);
Set
<
String
>
scheduleIdX
=
groupScheduleTools
.
getTableDate
(
9
);
String
startStamp2
=
getWholeHourTimeStamp
(
9
,
"13:00"
);
String
startStamp2
=
CommUtil
.
getWholeHourTimeStamp
(
9
,
"13:00"
);
if
(!
scheduleIdX
.
isEmpty
())
{
if
(!
scheduleIdX
.
isEmpty
())
{
scheduleIdX
.
stream
().
forEach
(
scheduleId1
->
{
scheduleIdX
.
stream
().
forEach
(
scheduleId1
->
{
//编辑成功后check同规则中下周三课次详情修改内容是否同步成功
//编辑成功后check同规则中下周三课次详情修改内容是否同步成功
...
@@ -136,7 +136,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
...
@@ -136,7 +136,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
}
}
//获取下周一的课次ID,查看下周一课次是否还是原来的(没被修改,还是原来的规则)
//获取下周一的课次ID,查看下周一课次是否还是原来的(没被修改,还是原来的规则)
Set
<
String
>
scheduleId1
=
groupScheduleTools
.
getTableDate
(
7
);
Set
<
String
>
scheduleId1
=
groupScheduleTools
.
getTableDate
(
7
);
String
startStamp3
=
getWholeHourTimeStamp
(
7
,
"13:00"
);
String
startStamp3
=
CommUtil
.
getWholeHourTimeStamp
(
7
,
"13:00"
);
if
(!
scheduleId1
.
isEmpty
())
{
if
(!
scheduleId1
.
isEmpty
())
{
scheduleId1
.
stream
().
forEach
(
scheduleId0
->
{
scheduleId1
.
stream
().
forEach
(
scheduleId0
->
{
//编辑成功后check同规则中下周一课次详情
//编辑成功后check同规则中下周一课次详情
...
@@ -158,19 +158,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
...
@@ -158,19 +158,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
}
}
/**
*
* @param n 整数
* @param time 整点时间 比如13:00
* @return
*/
public
String
getWholeHourTimeStamp
(
int
n
,
String
time
){
Date
getWeekStartDayData
=
CommUtil
.
getStartOfDateWeek
(
now
);
Date
getNextWeekXDayData
=
CommUtil
.
addNDays
(
getWeekStartDayData
,
n
);
String
getNextWeekXDayDataS
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
getNextWeekXDayData
.
getTime
());
return
CommUtil
.
getStringTimestampByStrTime
(
getNextWeekXDayDataS
+
" "
+
time
);
}
/**
/**
* 编辑后通过查看课次详情check数据是否同步被修改
* 编辑后通过查看课次详情check数据是否同步被修改
...
...
src/main/java/com/xiaomai/utils/CommUtil.java
View file @
079e6625
...
@@ -12,7 +12,10 @@ import java.lang.reflect.Method;
...
@@ -12,7 +12,10 @@ import java.lang.reflect.Method;
import
java.text.DateFormat
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.DayOfWeek
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.time.temporal.TemporalAdjusters
;
import
java.util.*
;
import
java.util.*
;
public
class
CommUtil
{
public
class
CommUtil
{
...
@@ -214,6 +217,22 @@ public class CommUtil {
...
@@ -214,6 +217,22 @@ public class CommUtil {
return
getStringTimestamp
(
getNextWeekStartDay
,
"yyyy-MM-dd HH:mm:ss"
);
return
getStringTimestamp
(
getNextWeekStartDay
,
"yyyy-MM-dd HH:mm:ss"
);
}
}
/**
* 获取下下周的某一天的开始时间
* @param n,7是下下周一,8是下下周2
* @return
*/
public
static
String
oneKeyGetNextNextWeekXStartDay
(
int
n
){
Date
getWeekStartDayData
=
getStartOfDateWeek
(
now
);
//获取本周的第一天
Date
getNextWeekStartDayData
=
addNDays
(
getWeekStartDayData
,
7
);
//下周第一天
Date
getNextNextWeekStartDayData
=
addNDays
(
getNextWeekStartDayData
,
n
);
String
getNextNextWeekXStartDay
=
getFormatTimeStr
(
getNextNextWeekStartDayData
,
"yyyy-MM-dd HH:mm:ss"
);
//时间格式转化为string
return
getStringTimestamp
(
getNextNextWeekXStartDay
,
"yyyy-MM-dd HH:mm:ss"
);
}
public
static
Date
getEndOfDay
(
Date
date
)
{
public
static
Date
getEndOfDay
(
Date
date
)
{
assert
date
!=
null
;
assert
date
!=
null
;
return
new
DateTime
(
date
).
withTime
(
23
,
59
,
59
,
999
).
toDate
();
return
new
DateTime
(
date
).
withTime
(
23
,
59
,
59
,
999
).
toDate
();
...
@@ -259,6 +278,20 @@ public class CommUtil {
...
@@ -259,6 +278,20 @@ public class CommUtil {
return
wholeHourTimestamp
;
return
wholeHourTimestamp
;
}
}
/**
*
* @param n 整数
* @param time 整点时间 比如13:00
* @return
*/
public
static
String
getWholeHourTimeStamp
(
int
n
,
String
time
){
Date
getWeekStartDayData
=
CommUtil
.
getStartOfDateWeek
(
now
);
Date
getNextWeekXDayData
=
CommUtil
.
addNDays
(
getWeekStartDayData
,
n
);
String
getNextWeekXDayDataS
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
getNextWeekXDayData
.
getTime
());
return
CommUtil
.
getStringTimestampByStrTime
(
getNextWeekXDayDataS
+
" "
+
time
);
}
public
static
String
getStringTimestampByStrTime
(
String
time
)
{
public
static
String
getStringTimestampByStrTime
(
String
time
)
{
...
@@ -286,6 +319,34 @@ public class CommUtil {
...
@@ -286,6 +319,34 @@ public class CommUtil {
}
}
/**
* 获取指定周的某一天的开始时间00,比如下周的第一天,下周的第二天
* @param day ,0就是周的第一天,1是周二,2是周三,3是周四,4是周五,5是周六,6是周日
* @param week 周为单位,1是当前周加1周即为下周,2就是下下周,0就是代表本周
* @return
*/
public
static
String
getXStartOfDateNextXWeek
(
int
day
,
int
week
)
{
Date
getNextXWeekStartDayData
=
new
DateTime
(
now
).
withDayOfWeek
(
1
).
plusWeeks
(
week
).
withTimeAtStartOfDay
().
toDate
();
Date
getNextXWeekStartXDayData
=
addNDays
(
getNextXWeekStartDayData
,
day
);
String
getNextXWeekStartXDayDataS
=
getFormatTimeStr
(
getNextXWeekStartXDayData
,
"yyyy-MM-dd HH:mm:ss"
);
//时间格式转化为string
return
getStringTimestamp
(
getNextXWeekStartXDayDataS
,
"yyyy-MM-dd HH:mm:ss"
);
}
/**
* 获取指定周的某一天的结束时间23:59,比如下周的最后一天天,下下周的第二天
* @param day 0表示某周的最后一天,-1表示某周的周六,-2周五,-3周四,-4周三,-5周二,-6周一
* @param week 周为单位,1是当前周加1周即为下周,2就是下下周,0就是代表本周
* @return
*/
public
static
String
getXEndOfDateNextXWeek
(
int
day
,
int
week
)
{
Date
getNextXWeekEndDayData
=
new
DateTime
(
now
).
withDayOfWeek
(
7
).
plusWeeks
(
2
).
withTime
(
23
,
59
,
59
,
0
).
toDate
();
Date
getNextXWeekEndXDayData
=
addNDays
(
getNextXWeekEndDayData
,
day
);
String
getNextXWeekEndXDayDataS
=
getFormatTimeStr
(
getNextXWeekEndXDayData
,
"yyyy-MM-dd HH:mm:ss"
);
//时间格式转化为string
return
getStringTimestamp
(
getNextXWeekEndXDayDataS
,
"yyyy-MM-dd HH:mm:ss"
);
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
getWholeHourTimestamp
();
getWholeHourTimestamp
();
Date
getWeekStartDayData
=
getStartOfDateWeek
(
now
);
//获取本周的第一天
Date
getWeekStartDayData
=
getStartOfDateWeek
(
now
);
//获取本周的第一天
...
@@ -311,6 +372,12 @@ public class CommUtil {
...
@@ -311,6 +372,12 @@ public class CommUtil {
LocalDateTime
future
=
now
.
plusSeconds
(
2
);
LocalDateTime
future
=
now
.
plusSeconds
(
2
);
System
.
out
.
println
(
"未来2秒时间: "
+
future
);
System
.
out
.
println
(
"未来2秒时间: "
+
future
);
System
.
out
.
println
(
"%%%%%"
+
getXEndOfDateNextXWeek
(-
1
,
2
));
}
}
...
...
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