Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
Q
queueForTicket_bl
Project
Project
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
mengmeng
queueForTicket_bl
Commits
e5b86b7c
Commit
e5b86b7c
authored
Mar 24, 2021
by
mengmeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加定时任务--节假日信息更新
parent
ee346a54
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
283 additions
and
3 deletions
+283
-3
README.md
README.md
+9
-0
CalendarrDao.java
...in/java/io/hmit/modules/appointment/dao/CalendarrDao.java
+9
-0
CalendarrDTO.java
...in/java/io/hmit/modules/appointment/dto/CalendarrDTO.java
+15
-0
CalendarrEntity.java
...a/io/hmit/modules/appointment/entity/CalendarrEntity.java
+15
-0
CalendarrService.java
...io/hmit/modules/appointment/service/CalendarrService.java
+15
-0
CalendarrServiceImpl.java
...odules/appointment/service/impl/CalendarrServiceImpl.java
+39
-0
HolidayJsonDTO.java
...src/main/java/io/hmit/modules/job/dto/HolidayJsonDTO.java
+37
-0
UpdateHolidayTask.java
...main/java/io/hmit/modules/job/task/UpdateHolidayTask.java
+69
-0
CalendarrDao.xml
...in/src/main/resources/mapper/appointment/CalendarrDao.xml
+14
-0
AppointmentOrderDTO.java
.../io/hmit/modules/appointment/dto/AppointmentOrderDTO.java
+1
-1
CalendarDao.xml
...api/src/main/resources/mapper/appointment/CalendarDao.xml
+2
-2
HttpRequestUtil.java
...n/src/main/java/io/hmit/common/utils/HttpRequestUtil.java
+58
-0
No files found.
README.md
View file @
e5b86b7c
...
@@ -8,3 +8,12 @@
...
@@ -8,3 +8,12 @@
### status 3 已取号
### status 3 已取号
### status 4 消除无效号码
### status 4 消除无效号码
***
***
***
## 预约时间维护
####数据库中calendar表存放年日期,由于预约时间排除法定节假日
####因此需要按年更新表中节假日信息(定时任务UpdateHoliday 每年1月1号执行)
####只更新当前年份, 也可在定时任务执行时传入年份参数 2021
####截止2021年3月节假日接口只能提前更新一年的信息
#### 表中基本数据维护到2030年12-30日
***
\ No newline at end of file
hmit-admin/src/main/java/io/hmit/modules/appointment/dao/CalendarrDao.java
0 → 100644
View file @
e5b86b7c
package
io
.
hmit
.
modules
.
appointment
.
dao
;
import
io.hmit.common.dao.BaseDao
;
import
io.hmit.modules.appointment.entity.CalendarrEntity
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
CalendarrDao
extends
BaseDao
<
CalendarrEntity
>
{
}
hmit-admin/src/main/java/io/hmit/modules/appointment/dto/CalendarrDTO.java
0 → 100644
View file @
e5b86b7c
package
io
.
hmit
.
modules
.
appointment
.
dto
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
public
class
CalendarrDTO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
Integer
id
;
private
String
day
;
private
Integer
holiday
;
private
Integer
dow
;
}
hmit-admin/src/main/java/io/hmit/modules/appointment/entity/CalendarrEntity.java
0 → 100644
View file @
e5b86b7c
package
io
.
hmit
.
modules
.
appointment
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@NoArgsConstructor
@TableName
(
"calendar"
)
public
class
CalendarrEntity
{
private
Integer
id
;
private
String
day
;
private
Integer
holiday
;
private
Integer
dow
;
}
hmit-admin/src/main/java/io/hmit/modules/appointment/service/CalendarrService.java
0 → 100644
View file @
e5b86b7c
package
io
.
hmit
.
modules
.
appointment
.
service
;
import
io.hmit.common.service.CrudService
;
import
io.hmit.modules.appointment.dto.CalendarrDTO
;
import
io.hmit.modules.appointment.entity.CalendarrEntity
;
/**
* 新闻管理
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-01-26
*/
public
interface
CalendarrService
extends
CrudService
<
CalendarrEntity
,
CalendarrDTO
>
{
CalendarrEntity
selectByDay
(
String
day
);
}
\ No newline at end of file
hmit-admin/src/main/java/io/hmit/modules/appointment/service/impl/CalendarrServiceImpl.java
0 → 100644
View file @
e5b86b7c
package
io
.
hmit
.
modules
.
appointment
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
io.hmit.common.service.impl.CrudServiceImpl
;
import
io.hmit.modules.appointment.dao.CalendarrDao
;
import
io.hmit.modules.appointment.dto.CalendarrDTO
;
import
io.hmit.modules.appointment.entity.CalendarrEntity
;
import
io.hmit.modules.appointment.service.CalendarrService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
java.util.Map
;
/**
* 新闻管理
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-01-26
*/
@Service
public
class
CalendarrServiceImpl
extends
CrudServiceImpl
<
CalendarrDao
,
CalendarrEntity
,
CalendarrDTO
>
implements
CalendarrService
{
@Override
public
QueryWrapper
<
CalendarrEntity
>
getWrapper
(
Map
<
String
,
Object
>
params
){
String
id
=
(
String
)
params
.
get
(
"id"
);
QueryWrapper
<
CalendarrEntity
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
StringUtils
.
isNotBlank
(
id
),
"id"
,
id
);
return
wrapper
;
}
@Override
public
CalendarrEntity
selectByDay
(
String
day
)
{
CalendarrEntity
calendarr
=
baseDao
.
selectOne
(
new
QueryWrapper
<
CalendarrEntity
>().
like
(
"day"
,
day
));
return
calendarr
;
}
}
\ No newline at end of file
hmit-admin/src/main/java/io/hmit/modules/job/dto/HolidayJsonDTO.java
0 → 100644
View file @
e5b86b7c
package
io
.
hmit
.
modules
.
job
.
dto
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.hmit.common.validator.group.AddGroup
;
import
io.hmit.common.validator.group.DefaultGroup
;
import
io.hmit.common.validator.group.UpdateGroup
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.Range
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Null
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* 定时任务
*
* @author zsh 408538940@qq.com
* @since 1.0.0
*/
@Data
@ApiModel
(
value
=
"节假日信息"
)
public
class
HolidayJsonDTO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"星期--中文表示"
)
private
String
name
;
@ApiModelProperty
(
value
=
"节假日类型 0 正常工作日 1,周末 2,法定节假日 3调休"
)
private
Integer
type
;
@ApiModelProperty
(
value
=
"星期--数字表示"
)
private
Integer
week
;
}
hmit-admin/src/main/java/io/hmit/modules/job/task/UpdateHolidayTask.java
0 → 100644
View file @
e5b86b7c
package
io
.
hmit
.
modules
.
job
.
task
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
io.hmit.common.utils.ConvertUtils
;
import
io.hmit.common.utils.HttpRequestUtil
;
import
io.hmit.modules.appointment.dto.CalendarrDTO
;
import
io.hmit.modules.appointment.entity.CalendarrEntity
;
import
io.hmit.modules.appointment.service.CalendarrService
;
import
io.hmit.modules.job.dto.HolidayJsonDTO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Calendar
;
import
java.util.Map
;
/**
* 更新每年的节假日信息(后台Calendar 表中的节假日维护到2030年)
* @params
*/
@Component
(
"updateCalendar"
)
public
class
UpdateHolidayTask
implements
ITask
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Autowired
private
CalendarrService
calendarrService
;
@Override
public
void
run
(
String
params
)
{
logger
.
debug
(
"TestTask定时任务正在执行,参数为:{}"
,
params
);
String
year
=
params
;
if
(
""
.
equals
(
params
)
&&
StringUtils
.
isBlank
(
params
))
{
Calendar
calendar
=
Calendar
.
getInstance
();
year
=
String
.
valueOf
(
calendar
.
get
(
Calendar
.
YEAR
));
}
String
url
=
"http://timor.tech/api/holiday/year"
;
String
jsontest
=
HttpRequestUtil
.
sendGet
(
url
,
year
);
System
.
out
.
println
(
jsontest
);
String
holidayJson
=
""
;
Map
<
String
,
String
>
map
=
JSONArray
.
parseObject
(
jsontest
,
Map
.
class
);
for
(
Map
.
Entry
entry
:
map
.
entrySet
())
{
String
key
=
entry
.
getKey
().
toString
();
String
value
=
entry
.
getValue
().
toString
();
if
(
key
.
contains
(
"type"
))
{
System
.
out
.
println
(
key
);
System
.
out
.
println
(
value
);
holidayJson
=
value
;
}
}
Map
<
String
,
String
>
map2
=
JSONArray
.
parseObject
(
holidayJson
,
Map
.
class
);
for
(
Map
.
Entry
entry
:
map2
.
entrySet
())
{
String
day
=
entry
.
getKey
().
toString
();
String
info
=
entry
.
getValue
().
toString
();
CalendarrEntity
calendarr
=
calendarrService
.
selectByDay
(
day
);
//将获取到的节假日json 2023-11-11:{"week":6,"name":"周六","type":1} 转换成实体
HolidayJsonDTO
holidayInfo
=
JSONObject
.
parseObject
(
info
,
HolidayJsonDTO
.
class
);
calendarr
.
setDay
(
day
);
calendarr
.
setHoliday
(
holidayInfo
.
getType
());
CalendarrDTO
calendarrDTO
=
ConvertUtils
.
sourceToTarget
(
calendarr
,
CalendarrDTO
.
class
);
calendarrService
.
update
(
calendarrDTO
);
}
}
}
\ No newline at end of file
hmit-admin/src/main/resources/mapper/appointment/CalendarrDao.xml
0 → 100644
View file @
e5b86b7c
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"io.hmit.modules.appointment.dao.CalendarrDao"
>
<resultMap
type=
"io.hmit.modules.appointment.entity.CalendarrEntity"
id=
"newsMap"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"day"
column=
"day"
/>
<result
property=
"holiday"
column=
"holiday"
/>
<result
property=
"dow"
column=
"dow"
/>
</resultMap>
</mapper>
\ No newline at end of file
hmit-api/src/main/java/io/hmit/modules/appointment/dto/AppointmentOrderDTO.java
View file @
e5b86b7c
...
@@ -118,7 +118,7 @@ public class AppointmentOrderDTO implements Serializable {
...
@@ -118,7 +118,7 @@ public class AppointmentOrderDTO implements Serializable {
dto
.
setAppointmentTime
(
reservationDTO
.
getAppointmentTime
());
dto
.
setAppointmentTime
(
reservationDTO
.
getAppointmentTime
());
dto
.
setServiceWindow
(
reservationDTO
.
getServiceWindow
());
dto
.
setServiceWindow
(
reservationDTO
.
getServiceWindow
());
dto
.
setRemark
(
reservationDTO
.
getRemark
());
dto
.
setRemark
(
reservationDTO
.
getRemark
());
dto
.
setCreator
(
userEntity
.
getId
());
dto
.
setCreator
(
userEntity
.
getId
());
dto
.
setUpdater
(
userEntity
.
getId
());
dto
.
setUpdater
(
userEntity
.
getId
());
dto
.
setCreateDate
(
new
Date
());
dto
.
setCreateDate
(
new
Date
());
...
...
hmit-api/src/main/resources/mapper/appointment/CalendarDao.xml
View file @
e5b86b7c
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"io.hmit.modules.appointment.dao.CalendarDao"
>
<mapper
namespace=
"io.hmit.modules.appointment.dao.Calendar
r
Dao"
>
<resultMap
type=
"io.hmit.modules.appointment.entity.CalendarEntity"
id=
"calendarMap"
>
<resultMap
type=
"io.hmit.modules.appointment.entity.Calendar
r
Entity"
id=
"calendarMap"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"id"
column=
"id"
/>
<result
property=
"day"
column=
"day"
/>
<result
property=
"day"
column=
"day"
/>
<result
property=
"holiday"
column=
"holiday"
/>
<result
property=
"holiday"
column=
"holiday"
/>
...
...
hmit-common/src/main/java/io/hmit/common/utils/HttpRequestUtil.java
View file @
e5b86b7c
...
@@ -45,6 +45,64 @@ public class HttpRequestUtil {
...
@@ -45,6 +45,64 @@ public class HttpRequestUtil {
return
resultCode
;
return
resultCode
;
}
}
/**
* 获取每年的节假日信息
*
* @param url
* 发送请求的URL
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return URL 所代表远程资源的响应结果
*/
public
static
String
sendGet
(
String
url
,
String
param
)
{
String
result
=
""
;
BufferedReader
in
=
null
;
try
{
String
urlNameString
=
url
+
"/"
+
param
+
"?type=Y&week=Y"
;
System
.
out
.
println
(
urlNameString
);
URL
realUrl
=
new
URL
(
urlNameString
);
// 打开和URL之间的连接
URLConnection
connection
=
realUrl
.
openConnection
();
// 设置通用的请求属性
connection
.
setRequestProperty
(
"accept"
,
"*/*"
);
connection
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"user-agent"
,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"
);
// 建立实际的连接
connection
.
connect
();
// 获取所有响应头字段
Map
<
String
,
List
<
String
>>
map
=
connection
.
getHeaderFields
();
// 遍历所有的响应头字段
for
(
String
key
:
map
.
keySet
())
{
System
.
out
.
println
(
key
+
"--->"
+
map
.
get
(
key
));
}
// 定义 BufferedReader输入流来读取URL的响应
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
(),
"UTF-8"
));
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
result
+=
line
;
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"发送GET请求出现异常!"
+
e
);
e
.
printStackTrace
();
}
// 使用finally块来关闭输入流
finally
{
try
{
if
(
in
!=
null
)
{
in
.
close
();
}
}
catch
(
Exception
e2
)
{
e2
.
printStackTrace
();
}
}
return
result
;
}
/**
/**
* 向指定浙里办URL发送GET方法的请求
* 向指定浙里办URL发送GET方法的请求
*
*
...
...
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