Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-calendar
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
hqzhdj
cloud-calendar
Commits
5fe2e4a6
Commit
5fe2e4a6
authored
Feb 09, 2021
by
liangkaiping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy
parent
31ba0ad1
Hide whitespace changes
Inline
Side-by-side
Showing
48 changed files
with
3307 additions
and
2 deletions
+3307
-2
README.md
+2
-2
calendar-api/pom.xml
+66
-0
calendar-api/src/main/java/com/yizhi/calendar/application/feign/CalendarClient.java
+27
-0
calendar-api/src/main/java/com/yizhi/calendar/application/feign/CalendarRecordClient.java
+8
-0
calendar-api/src/main/java/com/yizhi/calendar/application/feign/CalendarStatisticClient.java
+48
-0
calendar-api/src/main/java/com/yizhi/calendar/application/feign/StudentCalendarClient.java
+79
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarAccountStaticticVO.java
+19
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarChartVO.java
+16
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarDetailStatisticVO.java
+40
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarParam.java
+33
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarPointSetParam.java
+22
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarPointSetVO.java
+62
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarPosterVO.java
+34
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarRecordVO.java
+58
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarRuleListVO.java
+20
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarSignViewVO.java
+41
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarStatisticVO.java
+37
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarVO.java
+56
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/HeadVO.java
+19
-0
calendar-api/src/main/java/com/yizhi/calendar/application/vo/SignNumVO.java
+11
-0
calendar/pom.xml
+64
-0
calendar/src/main/java/com/yizhi/calendar/application/CalendarApplication.java
+19
-0
calendar/src/main/java/com/yizhi/calendar/application/controller/CalendarController.java
+200
-0
calendar/src/main/java/com/yizhi/calendar/application/controller/CalendarRecordController.java
+20
-0
calendar/src/main/java/com/yizhi/calendar/application/controller/CalendarStatisticController.java
+159
-0
calendar/src/main/java/com/yizhi/calendar/application/controller/StuentCalendarController.java
+162
-0
calendar/src/main/java/com/yizhi/calendar/application/domain/Calendar.java
+81
-0
calendar/src/main/java/com/yizhi/calendar/application/domain/CalendarPointSet.java
+72
-0
calendar/src/main/java/com/yizhi/calendar/application/domain/CalendarPoster.java
+37
-0
calendar/src/main/java/com/yizhi/calendar/application/domain/CalendarRecord.java
+71
-0
calendar/src/main/java/com/yizhi/calendar/application/mapper/CalendarMapper.java
+16
-0
calendar/src/main/java/com/yizhi/calendar/application/mapper/CalendarPointSetMapper.java
+16
-0
calendar/src/main/java/com/yizhi/calendar/application/mapper/CalendarPosterMapper.java
+8
-0
calendar/src/main/java/com/yizhi/calendar/application/mapper/CalendarRecordMapper.java
+105
-0
calendar/src/main/java/com/yizhi/calendar/application/mapper/CalendarRecordMapper.xml
+220
-0
calendar/src/main/java/com/yizhi/calendar/application/service/ICalendarPointSetService.java
+16
-0
calendar/src/main/java/com/yizhi/calendar/application/service/ICalendarPosterService.java
+8
-0
calendar/src/main/java/com/yizhi/calendar/application/service/ICalendarRecordService.java
+48
-0
calendar/src/main/java/com/yizhi/calendar/application/service/ICalendarService.java
+16
-0
calendar/src/main/java/com/yizhi/calendar/application/service/impl/CalendarPointSetServiceImpl.java
+13
-0
calendar/src/main/java/com/yizhi/calendar/application/service/impl/CalendarPosterServiceImpl.java
+13
-0
calendar/src/main/java/com/yizhi/calendar/application/service/impl/CalendarRecordServiceImpl.java
+543
-0
calendar/src/main/java/com/yizhi/calendar/application/service/impl/CalendarServiceImpl.java
+20
-0
calendar/src/main/java/com/yizhi/calendar/application/task/CalendarAccountExportAsync.java
+189
-0
calendar/src/main/java/com/yizhi/calendar/application/task/CalendarDetailExportAsync.java
+226
-0
calendar/src/main/java/com/yizhi/calendar/application/task/CalendarListExportAsync.java
+218
-0
calendar/src/main/resources/bootstrap.properties
+11
-0
pom.xml
+38
-0
No files found.
README.md
View file @
5fe2e4a6
# cloud-calendar
日历 打卡
\ No newline at end of file
calendar-api/pom.xml
0 → 100644
View file @
5fe2e4a6
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
cloud-calendar
</artifactId>
<groupId>
com.yizhi
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.yizhi
</groupId>
<artifactId>
calendar-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-common-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-core
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-orm
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-util
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>
true
</skip>
</configuration>
</plugin>
<plugin>
<groupId>
org.mybatis.generator
</groupId>
<artifactId>
mybatis-generator-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
calendar-api/src/main/java/com/yizhi/calendar/application/feign/CalendarClient.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
feign
;
import
com.yizhi.calendar.application.vo.CalendarParam
;
import
com.yizhi.calendar.application.vo.CalendarVO
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
@FeignClient
(
name
=
"calendar"
,
contextId
=
"CalendarClientxz"
)
public
interface
CalendarClient
{
/**
* 日历签到打卡规则回显
* @return
*/
@GetMapping
(
"/manage/calendar/calendarPointSet/getCalendar"
)
public
CalendarVO
getCalendar
();
/**
* 日历签到打卡规则入库
* @param calendarParam
* @return
*/
@PostMapping
(
"/manage/calendar/calendarPointSet/insert"
)
public
Boolean
insertCalendarPointSet
(
@RequestBody
CalendarParam
calendarParam
);
}
calendar-api/src/main/java/com/yizhi/calendar/application/feign/CalendarRecordClient.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
feign
;
import
org.springframework.cloud.openfeign.FeignClient
;
@FeignClient
(
name
=
"calendar"
,
contextId
=
"CalendarRecordClient"
)
public
interface
CalendarRecordClient
{
}
calendar-api/src/main/java/com/yizhi/calendar/application/feign/CalendarStatisticClient.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
feign
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.yizhi.calendar.application.vo.CalendarChartVO
;
import
com.yizhi.calendar.application.vo.CalendarStatisticVO
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
import
java.util.Map
;
@FeignClient
(
name
=
"calendar"
,
contextId
=
"CalendarStatisticClient"
)
public
interface
CalendarStatisticClient
{
/**
* 打卡报表折线图
*
* @param startDate
* @param endDate
* @return
*/
@GetMapping
(
"/statistic/calendar/chart"
)
public
List
<
CalendarChartVO
>
signChart
(
@RequestParam
(
name
=
"startDate"
,
required
=
true
)
String
startDate
,
@RequestParam
(
name
=
"endDate"
,
required
=
true
)
String
endDate
);
@GetMapping
(
"/statistic/calendar/list"
)
public
Page
<
CalendarStatisticVO
>
list
(
@RequestParam
(
name
=
"startDate"
,
required
=
true
)
String
startDate
,
@RequestParam
(
name
=
"endDate"
,
required
=
true
)
String
endDate
,
@RequestParam
(
name
=
"kwd"
,
required
=
false
)
String
kwd
,
@RequestParam
(
name
=
"pageSize"
,
required
=
false
,
defaultValue
=
"10"
)
Integer
pageSize
,
@RequestParam
(
name
=
"pageNo"
,
required
=
false
,
defaultValue
=
"1"
)
Integer
pageNo
);
@GetMapping
(
"/statistic/calendar/list/export"
)
public
Map
<
String
,
Object
>
listExport
(
@RequestParam
(
name
=
"startDate"
,
required
=
true
)
String
startDate
,
@RequestParam
(
name
=
"endDate"
,
required
=
true
)
String
endDate
,
@RequestParam
(
name
=
"kwd"
,
required
=
false
)
String
kwd
);
@GetMapping
(
"/statistic/calendar/account/export"
)
public
Map
<
String
,
Object
>
accountExport
(
@RequestParam
(
name
=
"startDate"
,
required
=
true
)
String
startDate
,
@RequestParam
(
name
=
"endDate"
,
required
=
true
)
String
endDate
,
@RequestParam
(
name
=
"userId"
,
required
=
true
)
Long
userId
);
@GetMapping
(
"/statistic/calendar/detail/export"
)
public
Map
<
String
,
Object
>
detailExport
(
@RequestParam
(
name
=
"startDate"
,
required
=
true
)
String
startDate
,
@RequestParam
(
name
=
"endDate"
,
required
=
true
)
String
endDate
,
@RequestParam
(
name
=
"kwd"
,
required
=
false
)
String
kwd
);
}
calendar-api/src/main/java/com/yizhi/calendar/application/feign/StudentCalendarClient.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
feign
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.yizhi.calendar.application.vo.CalendarRecordVO
;
import
com.yizhi.calendar.application.vo.CalendarSignViewVO
;
import
com.yizhi.calendar.application.vo.HeadVO
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
import
java.util.Map
;
@FeignClient
(
name
=
"calendar"
,
contextId
=
"StudentCalendarClient"
)
public
interface
StudentCalendarClient
{
/**
* 打卡签到入口
* @param accountId
* @param siteId
* @return
*/
@GetMapping
(
"/api/calendar/sign"
)
public
Map
<
String
,
Object
>
sign
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
);
/**
* 用户每日打卡详情
* @param accountId
* @param siteId
* @return
*/
@GetMapping
(
"/api/calendar/isSign"
)
public
CalendarSignViewVO
isSign
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
);
/**
* 签到打卡头部数据
* @param accountId
* @param siteId
* @return
*/
@GetMapping
(
"/api/calendar/headData"
)
public
HeadVO
getHeadData
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
);
/**
* 签到明细
* @param accountId
* @param siteId
* @param type
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping
(
"/api/calendar/signDetail"
)
public
Page
<
CalendarRecordVO
>
getSignDetail
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
,
@RequestParam
(
"type"
)
Integer
type
,
@RequestParam
(
"pageNo"
)
Integer
pageNo
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
);
/**
* 签到日历
* @param accountId
* @param siteId
* @param month
* @return
*/
@GetMapping
(
"/api/calendar/signByMonth"
)
public
List
<
CalendarRecordVO
>
getSignByMonth
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
,
@RequestParam
(
"month"
)
String
month
);
/**
* 周期内用户打卡次数
* @param accountId
* @param siteIds
* @param startDate
* @param endDate
* @return
*/
@GetMapping
(
"/api/calendar/signNum"
)
public
Map
<
Long
,
Long
>
signNum
(
@RequestParam
(
"siteIds"
)
List
<
Long
>
siteIds
,
@RequestParam
(
"startDate"
)
String
startDate
,
@RequestParam
(
"endDate"
)
String
endDate
);
@GetMapping
(
"/api/calendar/getSignState"
)
public
Integer
getSignState
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
);
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarAccountStaticticVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@ApiModel
(
value
=
"CalendarAccountStaticticVO"
,
description
=
"用户打卡记录信息"
)
@Data
public
class
CalendarAccountStaticticVO
{
@ApiModelProperty
(
value
=
"签到日期"
)
private
String
signDate
;
@ApiModelProperty
(
value
=
"签到时间"
)
private
String
signTime
;
@ApiModelProperty
(
value
=
"积分"
)
private
Integer
point
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarChartVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@ApiModel
(
value
=
"CalendarChartVO"
,
description
=
"签到折线图"
)
@Data
public
class
CalendarChartVO
{
@ApiModelProperty
(
value
=
"折线图时间轴"
)
private
String
dateStr
;
@ApiModelProperty
(
value
=
"签到次数"
)
private
Integer
signNum
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarDetailStatisticVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@ApiModel
(
value
=
"CalendarDetailStatisticVO"
,
description
=
"签到明细信息"
)
@Data
public
class
CalendarDetailStatisticVO
{
@ApiModelProperty
(
value
=
"用户名"
)
private
String
name
;
@ApiModelProperty
(
value
=
"姓名"
)
private
String
fullName
;
@ApiModelProperty
(
value
=
"部门名称"
)
private
String
orgName
;
@ApiModelProperty
(
value
=
"所在组织架构"
)
private
String
orgNames
;
@ApiModelProperty
(
value
=
"工号"
)
private
String
workNum
;
@ApiModelProperty
(
value
=
"职位"
)
private
String
position
;
@ApiModelProperty
(
value
=
"用户id"
)
private
Long
accountId
;
@ApiModelProperty
(
value
=
"发放积分"
)
private
Integer
point
;
@ApiModelProperty
(
value
=
"签到日期"
)
private
String
signDate
;
@ApiModelProperty
(
value
=
"打卡时间"
)
private
String
signTime
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarParam.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
java.util.List
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* 日历打卡设置请求类
*
* @author hecong
* @date 2019-10-11
*/
@ApiModel
(
"日历打卡设置请求类"
)
@Data
public
class
CalendarParam
{
@ApiModelProperty
(
"首次签到积分"
)
private
Integer
firstPoint
;
@ApiModelProperty
(
"积分设置类型"
)
private
Integer
setType
;
@ApiModelProperty
(
"周期"
)
private
Long
cycle
;
@ApiModelProperty
(
"周期"
)
private
List
<
CalendarPointSetParam
>
calendarPointSets
;
@ApiModelProperty
(
"是否开启"
)
private
Integer
state
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarPointSetParam.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* 日历打卡积分规则请求类
*
* @author hecong
* @date 2019-10-11
*/
@ApiModel
(
" 日历打卡积分规则请求类"
)
@Data
public
class
CalendarPointSetParam
{
@ApiModelProperty
(
"积分对应最小连续天数"
)
private
Integer
minDate
;
@ApiModelProperty
(
"积分"
)
private
Integer
point
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarPointSetVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.baomidou.mybatisplus.enums.FieldFill
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* <p>
* 日历打卡积分发放设置表
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@Data
@ApiModel
(
value
=
"CalendarPointSet"
,
description
=
"日历打卡积分规则设置表"
)
public
class
CalendarPointSetVO
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"主键"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"日历id"
)
private
Long
calendarId
;
@ApiModelProperty
(
value
=
"积分设置类型(1连续递增,2自定义)"
)
private
Integer
setType
;
@ApiModelProperty
(
value
=
"状态 0 删除 1 有效 默认有效"
)
private
Integer
state
;
@ApiModelProperty
(
value
=
"积分对应连续最小天数"
)
private
Integer
minDate
;
@ApiModelProperty
(
value
=
"积分"
)
private
Integer
point
;
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"创建人ID"
)
private
Long
createById
;
@ApiModelProperty
(
value
=
"创建人名字"
)
private
String
createByName
;
@ApiModelProperty
(
value
=
"修改时间"
)
private
Date
updateTime
;
@ApiModelProperty
(
value
=
"修改人ID"
)
private
Long
updateById
;
@ApiModelProperty
(
value
=
"修改人名字"
)
private
String
updateByName
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarPosterVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* <p>
* 日签海报表
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@Data
@ApiModel
(
value
=
"CalendarPoster"
,
description
=
"日签海报表"
)
@TableName
(
"calendar_poster"
)
public
class
CalendarPosterVO
{
private
static
final
long
serialVersionUID
=
1L
;
private
Long
id
;
@ApiModelProperty
(
value
=
"下载地址"
)
private
String
url
;
@ApiModelProperty
(
value
=
"鸡汤文"
)
private
String
content
;
@ApiModelProperty
(
value
=
"base64编码"
)
private
String
base64Code
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarRecordVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.baomidou.mybatisplus.enums.FieldFill
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* <p>
* 日历打卡记录表
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@Data
@ApiModel
(
value
=
"CalendarRecord"
,
description
=
"日历打卡记录表"
)
public
class
CalendarRecordVO
{
private
static
final
long
serialVersionUID
=
1L
;
private
Long
id
;
@ApiModelProperty
(
value
=
"用户id"
)
private
Long
accountId
;
@ApiModelProperty
(
value
=
"首次打卡0,否1 默认首次打卡"
)
private
Integer
firstSign
;
@ApiModelProperty
(
value
=
"发放积分"
)
private
Integer
point
;
@ApiModelProperty
(
value
=
"签到日期"
)
private
String
signDate
;
@ApiModelProperty
(
value
=
"打卡时间"
)
private
String
signTime
;
@ApiModelProperty
(
value
=
"海报id"
)
private
Long
posterId
;
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"企业ID"
)
private
Long
companyId
;
@ApiModelProperty
(
value
=
"站点ID"
)
private
Long
siteId
;
@ApiModelProperty
(
value
=
"部门ID"
)
private
Long
orgId
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarRuleListVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
@ApiModel
(
value
=
"日历打卡积分规则列表类"
,
description
=
"日历打卡积分规则列表类"
)
public
class
CalendarRuleListVO
{
@ApiModelProperty
(
"连续签到最小天数"
)
private
Integer
minDate
;
@ApiModelProperty
(
"连续签到最大天数"
)
private
Integer
maxDate
;
@ApiModelProperty
(
"获取对应积分值"
)
private
Integer
point
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarSignViewVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@ApiModel
(
"日历打卡签到入口类"
)
@Data
public
class
CalendarSignViewVO
{
@ApiModelProperty
(
"是否签到"
)
private
Integer
isSign
;
@ApiModelProperty
(
"签到积分"
)
private
Integer
point
;
@ApiModelProperty
(
"已连续签到天数"
)
private
Long
day
;
@ApiModelProperty
(
"周期结束的最后一天"
)
private
Integer
isCycle
;
@ApiModelProperty
(
"背景图"
)
private
String
imgUrl
;
@ApiModelProperty
(
"已连续签到天数"
)
private
Long
sumDays
;
@ApiModelProperty
(
"鸡汤文"
)
private
String
content
;
@ApiModelProperty
(
"用户名"
)
private
String
name
;
@ApiModelProperty
(
"头像"
)
private
String
headPortrait
;
@ApiModelProperty
(
"海报id"
)
private
Long
posterId
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarStatisticVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@ApiModel
(
value
=
"CalendarStatisticVO"
,
description
=
"签到打卡统计数据"
)
@Data
public
class
CalendarStatisticVO
{
@ApiModelProperty
(
value
=
"用户id"
)
private
Long
accountId
;
@ApiModelProperty
(
value
=
"用户名"
)
private
String
name
;
@ApiModelProperty
(
value
=
"姓名"
)
private
String
fullName
;
@ApiModelProperty
(
value
=
"部门名称"
)
private
String
orgName
;
@ApiModelProperty
(
value
=
"部门所在组织架构"
)
private
String
orgNames
;
@ApiModelProperty
(
value
=
"工号"
)
private
String
workNum
;
@ApiModelProperty
(
value
=
"职位"
)
private
String
position
;
@ApiModelProperty
(
value
=
"打卡次数"
)
private
Integer
count
;
@ApiModelProperty
(
value
=
"获得积分"
)
private
Integer
point
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/CalendarVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
java.util.Date
;
import
java.util.List
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
CalendarVO
{
@ApiModelProperty
(
value
=
"主键"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"首次打卡积分"
)
private
Integer
firstPoint
;
@ApiModelProperty
(
value
=
"积分设置类型(1连续递增,2自定义)"
)
private
Integer
setType
;
@ApiModelProperty
(
value
=
"状态 0未启用 1启用 默认启用"
)
private
Integer
state
;
@ApiModelProperty
(
value
=
"周期持续天数 默认不限制"
)
private
Long
cycle
;
@ApiModelProperty
(
value
=
"企业ID"
)
private
Long
companyId
;
@ApiModelProperty
(
value
=
"站点ID"
)
private
Long
siteId
;
@ApiModelProperty
(
value
=
"部门ID"
)
private
Long
orgId
;
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"创建人ID"
)
private
Long
createById
;
@ApiModelProperty
(
value
=
"创建人名字"
)
private
String
createByName
;
@ApiModelProperty
(
value
=
"修改时间"
)
private
Date
updateTime
;
@ApiModelProperty
(
value
=
"修改人ID"
)
private
Long
updateById
;
@ApiModelProperty
(
value
=
"修改人名字"
)
private
String
updateByName
;
@ApiModelProperty
(
value
=
"积分规则"
)
private
List
<
CalendarPointSetVO
>
sets
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/HeadVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@ApiModel
(
"日历打卡学员端头部数据"
)
@Data
public
class
HeadVO
{
@ApiModelProperty
(
"连续签到天数"
)
private
Long
consecutiveDays
;
@ApiModelProperty
(
"累计签到天数"
)
private
Long
sumDays
;
@ApiModelProperty
(
"奖励积分"
)
private
Integer
point
;
}
calendar-api/src/main/java/com/yizhi/calendar/application/vo/SignNumVO.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
vo
;
import
lombok.Data
;
@Data
public
class
SignNumVO
{
private
Long
accountId
;
private
Long
signNum
;
}
calendar/pom.xml
0 → 100644
View file @
5fe2e4a6
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
cloud-calendar
</artifactId>
<groupId>
com.yizhi
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.yizhi
</groupId>
<artifactId>
calendar
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
calendar-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-system-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-util
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-core
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-orm
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-system-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- deploy 时跳过该模块 -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-deploy-plugin
</artifactId>
<configuration>
<skip>
true
</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
calendar/src/main/java/com/yizhi/calendar/application/CalendarApplication.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
@EnableTransactionManagement
@SpringBootApplication
@EnableFeignClients
(
basePackages
=
{
"com.yizhi"
})
@ComponentScan
(
basePackages
=
{
"com.yizhi"
})
public
class
CalendarApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
CalendarApplication
.
class
,
args
);
}
}
calendar/src/main/java/com/yizhi/calendar/application/controller/CalendarController.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
controller
;
import
com.yizhi.application.orm.id.IdGenerator
;
import
com.yizhi.calendar.application.vo.CalendarPointSetVO
;
import
com.yizhi.calendar.application.domain.Calendar
;
import
com.yizhi.calendar.application.domain.CalendarPointSet
;
import
com.yizhi.core.application.context.ContextHolder
;
import
com.yizhi.core.application.context.RequestContext
;
import
org.springframework.beans.BeanUtils
;
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.RestController
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.yizhi.calendar.application.service.ICalendarPointSetService
;
import
com.yizhi.calendar.application.service.ICalendarService
;
import
com.yizhi.calendar.application.vo.CalendarParam
;
import
com.yizhi.calendar.application.vo.CalendarPointSetParam
;
import
com.yizhi.calendar.application.vo.CalendarVO
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
* <p>
* 日历打卡积分发放设置表 前端控制器
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@RestController
@RequestMapping
(
"/manage/calendar"
)
public
class
CalendarController
{
@Autowired
private
ICalendarService
calendarService
;
@Autowired
private
ICalendarPointSetService
calendarPointSetService
;
@Autowired
private
IdGenerator
idGenerator
;
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
CalendarController
.
class
);
/**
* 日历签到打卡规则回显
* @return
*/
@GetMapping
(
"/calendarPointSet/getCalendar"
)
public
CalendarVO
getCalendar
()
{
CalendarVO
vo
=
new
CalendarVO
();
RequestContext
res
=
ContextHolder
.
get
();
Long
siteId
=
res
.
getSiteId
();
Calendar
set
=
new
Calendar
();
set
.
setSiteId
(
siteId
);
EntityWrapper
<
Calendar
>
wrapper
=
new
EntityWrapper
<
Calendar
>(
set
);
Calendar
calendar
=
calendarService
.
selectOne
(
wrapper
);
if
(
null
!=
calendar
)
{
CalendarPointSet
pointSet
=
new
CalendarPointSet
();
pointSet
.
setCalendarId
(
calendar
.
getId
());
pointSet
.
setSetType
(
calendar
.
getSetType
());
pointSet
.
setState
(
1
);
EntityWrapper
<
CalendarPointSet
>
entityWrapper
=
new
EntityWrapper
(
pointSet
);
entityWrapper
.
orderBy
(
"minDate"
,
true
);
List
<
CalendarPointSet
>
list
=
calendarPointSetService
.
selectList
(
entityWrapper
);
List
<
CalendarPointSetVO
>
calendarPointSetVOS
=
new
ArrayList
<
CalendarPointSetVO
>();
for
(
CalendarPointSet
calendarPointSet
:
list
)
{
CalendarPointSetVO
calendarPointSetVO
=
new
CalendarPointSetVO
();
BeanUtils
.
copyProperties
(
calendarPointSet
,
calendarPointSetVO
);
calendarPointSetVOS
.
add
(
calendarPointSetVO
);
}
vo
.
setSets
(
calendarPointSetVOS
);
vo
.
setId
(
calendar
.
getId
());
vo
.
setFirstPoint
(
calendar
.
getFirstPoint
());
vo
.
setSetType
(
calendar
.
getSetType
());
vo
.
setCycle
(
calendar
.
getCycle
());
vo
.
setState
(
calendar
.
getState
());
}
else
{
CalendarPointSet
pointSet
=
new
CalendarPointSet
();
pointSet
.
setSetType
(
1
);
pointSet
.
setPoint
(
1
);
List
<
CalendarPointSetVO
>
list
=
new
ArrayList
<
CalendarPointSetVO
>();
CalendarPointSetVO
pointSetVO
=
new
CalendarPointSetVO
();
BeanUtils
.
copyProperties
(
pointSet
,
pointSetVO
);
list
.
add
(
pointSetVO
);
vo
.
setFirstPoint
(
1
);
vo
.
setSetType
(
1
);
vo
.
setCycle
(
7
l
);
vo
.
setSets
(
list
);
vo
.
setState
(
0
);
}
return
vo
;
}
@PostMapping
(
value
=
"/calendarPointSet/insert"
)
public
Boolean
insertCalendarPointSet
(
@RequestBody
CalendarParam
calendarParam
){
LOG
.
info
(
"入参:"
+
calendarParam
.
toString
());
String
result
=
""
;
RequestContext
res
=
ContextHolder
.
get
();
Long
siteId
=
res
.
getSiteId
();
Long
accountId
=
res
.
getAccountId
();
String
accountName
=
res
.
getAccountName
();
Long
companyId
=
res
.
getCompanyId
();
Long
orgId
=
res
.
getOrgId
();
Calendar
set
=
new
Calendar
();
set
.
setSiteId
(
siteId
);
EntityWrapper
<
Calendar
>
wrapper
=
new
EntityWrapper
<
Calendar
>(
set
);
Calendar
calendar
=
calendarService
.
selectOne
(
wrapper
);
//第一次设置日历打卡规则
if
(
null
==
calendar
)
{
calendar
=
new
Calendar
();
Long
id
=
idGenerator
.
generate
();
calendar
.
setId
(
id
);
calendar
.
setSetType
(
calendarParam
.
getSetType
());
calendar
.
setFirstPoint
(
calendarParam
.
getFirstPoint
());
calendar
.
setCycle
(
calendarParam
.
getCycle
());
calendar
.
setState
(
calendarParam
.
getState
());
calendar
.
setCompanyId
(
companyId
);
calendar
.
setSiteId
(
siteId
);
calendar
.
setOrgId
(
orgId
);
calendar
.
setCreateById
(
accountId
);
calendar
.
setCreateByName
(
accountName
);
calendar
.
setCreateTime
(
new
Date
());
calendarService
.
insert
(
calendar
);
for
(
CalendarPointSetParam
pointSet:
calendarParam
.
getCalendarPointSets
())
{
CalendarPointSet
calendarPointSet
=
new
CalendarPointSet
();
calendarPointSet
.
setId
(
idGenerator
.
generate
());
calendarPointSet
.
setCalendarId
(
id
);
calendarPointSet
.
setSetType
(
calendarParam
.
getSetType
());
if
(
calendarParam
.
getSetType
()==
1
)
{
calendarPointSet
.
setPoint
(
pointSet
.
getPoint
());
}
else
{
if
(
pointSet
.
getMinDate
()>
calendarParam
.
getCycle
())
{
return
false
;
}
else
{
calendarPointSet
.
setMinDate
(
pointSet
.
getMinDate
());
calendarPointSet
.
setPoint
(
pointSet
.
getPoint
());
}
}
calendarPointSet
.
setCreateById
(
accountId
);
calendarPointSet
.
setCreateByName
(
accountName
);
calendarPointSet
.
setCreateTime
(
new
Date
());
boolean
b
=
calendarPointSetService
.
insert
(
calendarPointSet
);
}
return
true
;
}
else
{
//修改日历打卡规则
calendar
.
setSetType
(
calendarParam
.
getSetType
());
calendar
.
setFirstPoint
(
calendarParam
.
getFirstPoint
());
calendar
.
setCycle
(
calendarParam
.
getCycle
());
calendar
.
setState
(
calendarParam
.
getState
());
calendar
.
setUpdateById
(
accountId
);
calendar
.
setUpdateByName
(
accountName
);
calendar
.
setUpdateTime
(
new
Date
());
List
<
CalendarPointSet
>
list
=
new
ArrayList
<
CalendarPointSet
>();
for
(
CalendarPointSetParam
pointSet:
calendarParam
.
getCalendarPointSets
())
{
CalendarPointSet
calendarPointSet
=
new
CalendarPointSet
();
calendarPointSet
.
setCalendarId
(
calendar
.
getId
());
calendarPointSet
.
setId
(
idGenerator
.
generate
());
calendarPointSet
.
setSetType
(
calendarParam
.
getSetType
());
if
(
calendarParam
.
getSetType
()==
1
)
{
calendarPointSet
.
setPoint
(
pointSet
.
getPoint
());
}
else
{
if
(
calendarParam
.
getCycle
()<=
pointSet
.
getMinDate
())
{
return
false
;
}
else
{
calendarPointSet
.
setMinDate
(
pointSet
.
getMinDate
());
calendarPointSet
.
setPoint
(
pointSet
.
getPoint
());
}
}
calendarPointSet
.
setCreateById
(
accountId
);
calendarPointSet
.
setCreateByName
(
accountName
);
calendarPointSet
.
setCreateTime
(
new
Date
());
list
.
add
(
calendarPointSet
);
}
CalendarPointSet
calendarPointSet
=
new
CalendarPointSet
();
calendarPointSet
.
setCalendarId
(
calendar
.
getId
());
EntityWrapper
<
CalendarPointSet
>
entityWrapper
=
new
EntityWrapper
<
CalendarPointSet
>(
calendarPointSet
);
//删除之前的积分规则
calendarPointSetService
.
delete
(
entityWrapper
);
//新的积分规则入库
calendarService
.
updateById
(
calendar
);
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
boolean
b
=
calendarPointSetService
.
insertBatch
(
list
);
}
return
true
;
}
}
}
calendar/src/main/java/com/yizhi/calendar/application/controller/CalendarRecordController.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* <p>
* 日历打卡记录表 前端控制器
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@RestController
@RequestMapping
(
"/calendarRecord"
)
public
class
CalendarRecordController
{
}
calendar/src/main/java/com/yizhi/calendar/application/controller/CalendarStatisticController.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
controller
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.yizhi.calendar.application.task.CalendarAccountExportAsync
;
import
com.yizhi.calendar.application.task.CalendarDetailExportAsync
;
import
com.yizhi.calendar.application.task.CalendarListExportAsync
;
import
com.yizhi.core.application.context.ContextHolder
;
import
com.yizhi.core.application.context.RequestContext
;
import
com.yizhi.system.application.system.remote.AccountClient
;
import
com.yizhi.system.application.vo.AccountVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.plugins.pagination.PageHelper
;
import
com.yizhi.calendar.application.service.ICalendarRecordService
;
import
com.yizhi.calendar.application.vo.CalendarChartVO
;
import
com.yizhi.calendar.application.vo.CalendarStatisticVO
;
@RestController
@RequestMapping
(
"/statistic/calendar"
)
public
class
CalendarStatisticController
{
@Autowired
private
ICalendarRecordService
calendarRecordService
;
@Autowired
private
CalendarListExportAsync
calendarListExportAsync
;
@Autowired
private
CalendarAccountExportAsync
calendarAccountExportAsync
;
@Autowired
private
CalendarDetailExportAsync
calendarDetailExportAsync
;
@Autowired
private
AccountClient
accountClient
;
@GetMapping
(
"/chart"
)
public
List
<
CalendarChartVO
>
signChart
(
@RequestParam
(
name
=
"startDate"
,
required
=
true
)
String
startDate
,
@RequestParam
(
name
=
"endDate"
,
required
=
true
)
String
endDate
)
{
RequestContext
res
=
ContextHolder
.
get
();
Long
companyId
=
res
.
getCompanyId
();
Long
siteId
=
res
.
getSiteId
();
List
<
CalendarChartVO
>
list
=
calendarRecordService
.
signChart
(
startDate
,
endDate
,
companyId
,
siteId
);
return
list
;
}
@GetMapping
(
"/list"
)
public
Page
<
CalendarStatisticVO
>
list
(
@RequestParam
(
name
=
"startDate"
,
required
=
true
)
String
startDate
,
@RequestParam
(
name
=
"endDate"
,
required
=
true
)
String
endDate
,
@RequestParam
(
name
=
"kwd"
,
required
=
false
)
String
kwd
,
@RequestParam
(
name
=
"pageSize"
,
required
=
false
,
defaultValue
=
"10"
)
Integer
pageSize
,
@RequestParam
(
name
=
"pageNo"
,
required
=
false
,
defaultValue
=
"1"
)
Integer
pageNo
)
{
RequestContext
res
=
ContextHolder
.
get
();
Page
<
CalendarStatisticVO
>
page
=
new
Page
<
CalendarStatisticVO
>();
Long
companyId
=
res
.
getCompanyId
();
Long
siteId
=
res
.
getSiteId
();
if
(
pageSize
!=
null
&&
pageNo
!=
null
){
PageHelper
.
startPage
(
pageNo
,
pageSize
);
}
List
<
CalendarStatisticVO
>
list
=
calendarRecordService
.
list
(
startDate
,
endDate
,
kwd
,
companyId
,
siteId
);
if
(
pageSize
!=
null
&&
pageNo
!=
null
){
page
.
setTotal
(
PageHelper
.
getTotal
());
page
.
setSize
(
pageSize
);
page
.
setCurrent
(
pageNo
);
PageHelper
.
remove
();
}
page
.
setRecords
(
list
);
return
page
;
}
@GetMapping
(
"/list/export"
)
public
Map
<
String
,
Object
>
listExport
(
@RequestParam
(
name
=
"startDate"
,
required
=
true
)
String
startDate
,
@RequestParam
(
name
=
"endDate"
,
required
=
true
)
String
endDate
,
@RequestParam
(
name
=
"kwd"
,
required
=
false
)
String
kwd
){
RequestContext
requestContext
=
ContextHolder
.
get
();
Date
submitTime
=
new
Date
();
Long
taskId
=
submitTime
.
getTime
();
String
serialNo
=
"USER-EXPORT-"
+
taskId
;
String
taskName
=
"打卡统计-"
+
taskId
;
String
result
=
"任务编号:"
+
serialNo
+
"。任务名称:"
+
taskName
;
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"accountId"
,
requestContext
.
getAccountId
());
map
.
put
(
"siteId"
,
requestContext
.
getSiteId
());
map
.
put
(
"companyId"
,
requestContext
.
getCompanyId
());
map
.
put
(
"serialNo"
,
serialNo
);
map
.
put
(
"taskId"
,
taskId
);
map
.
put
(
"submitTime"
,
submitTime
);
map
.
put
(
"taskName"
,
taskName
);
map
.
put
(
"kwd"
,
kwd
);
map
.
put
(
"startDate"
,
startDate
);
map
.
put
(
"endDate"
,
endDate
);
map
.
put
(
"result"
,
result
);
calendarListExportAsync
.
execute
(
map
,
true
);
return
map
;
}
@GetMapping
(
"/account/export"
)
public
Map
<
String
,
Object
>
accountExport
(
@RequestParam
(
name
=
"startDate"
,
required
=
true
)
String
startDate
,
@RequestParam
(
name
=
"endDate"
,
required
=
true
)
String
endDate
,
@RequestParam
(
name
=
"userId"
,
required
=
true
)
Long
userId
){
RequestContext
requestContext
=
ContextHolder
.
get
();
Date
submitTime
=
new
Date
();
Long
taskId
=
submitTime
.
getTime
();
AccountVO
accountVO
=
accountClient
.
findById
(
userId
);
String
serialNo
=
"USER-EXPORT-"
+
taskId
;
String
taskName
=
accountVO
.
getName
()+
"打卡记录-"
+
taskId
;
String
result
=
"任务编号:"
+
serialNo
+
"。任务名称:"
+
taskName
;
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"accountId"
,
requestContext
.
getAccountId
());
map
.
put
(
"siteId"
,
requestContext
.
getSiteId
());
map
.
put
(
"companyId"
,
requestContext
.
getCompanyId
());
map
.
put
(
"serialNo"
,
serialNo
);
map
.
put
(
"taskId"
,
taskId
);
map
.
put
(
"submitTime"
,
submitTime
);
map
.
put
(
"taskName"
,
taskName
);
map
.
put
(
"startDate"
,
startDate
);
map
.
put
(
"endDate"
,
endDate
);
map
.
put
(
"userId"
,
userId
);
map
.
put
(
"accountName"
,
accountVO
.
getName
());
map
.
put
(
"result"
,
result
);
calendarAccountExportAsync
.
execute
(
map
,
true
);
return
map
;
}
@GetMapping
(
"/detail/export"
)
public
Map
<
String
,
Object
>
detailExport
(
@RequestParam
(
name
=
"startDate"
,
required
=
true
)
String
startDate
,
@RequestParam
(
name
=
"endDate"
,
required
=
true
)
String
endDate
,
@RequestParam
(
name
=
"kwd"
,
required
=
false
)
String
kwd
){
RequestContext
requestContext
=
ContextHolder
.
get
();
Date
submitTime
=
new
Date
();
Long
taskId
=
submitTime
.
getTime
();
String
serialNo
=
"USER-EXPORT-"
+
taskId
;
String
taskName
=
"打卡记录-"
+
taskId
;
String
result
=
"任务编号:"
+
serialNo
+
"。任务名称:"
+
taskName
;
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"accountId"
,
requestContext
.
getAccountId
());
map
.
put
(
"siteId"
,
requestContext
.
getSiteId
());
map
.
put
(
"companyId"
,
requestContext
.
getCompanyId
());
map
.
put
(
"serialNo"
,
serialNo
);
map
.
put
(
"taskId"
,
taskId
);
map
.
put
(
"submitTime"
,
submitTime
);
map
.
put
(
"taskName"
,
taskName
);
map
.
put
(
"kwd"
,
kwd
);
map
.
put
(
"startDate"
,
startDate
);
map
.
put
(
"endDate"
,
endDate
);
map
.
put
(
"result"
,
result
);
calendarDetailExportAsync
.
execute
(
map
,
true
);
return
map
;
}
}
calendar/src/main/java/com/yizhi/calendar/application/controller/StuentCalendarController.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
controller
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.yizhi.calendar.application.domain.Calendar
;
import
com.yizhi.calendar.application.domain.CalendarPointSet
;
import
com.yizhi.calendar.application.domain.CalendarRecord
;
import
com.yizhi.calendar.application.service.ICalendarPointSetService
;
import
com.yizhi.calendar.application.service.ICalendarService
;
import
com.yizhi.system.application.system.remote.ReportClient
;
import
com.yizhi.util.application.date.DateUtil
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.yizhi.calendar.application.service.ICalendarRecordService
;
import
com.yizhi.calendar.application.vo.CalendarSignViewVO
;
import
com.yizhi.calendar.application.vo.HeadVO
;
/**
* <p>
* 学员日历打卡
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@RestController
@RequestMapping
(
"/api/calendar"
)
public
class
StuentCalendarController
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
StuentCalendarController
.
class
);
@Autowired
private
ICalendarService
calendarService
;
@Autowired
private
ICalendarPointSetService
calendarPointSetService
;
@Autowired
private
ICalendarRecordService
calendarRecordService
;
@Autowired
private
ReportClient
reportClient
;
/**
* 打卡签到入口
* @param accountId
* @param siteId
* @return
*/
@GetMapping
(
"/sign"
)
public
Map
<
String
,
Object
>
sign
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<
String
,
Object
>();
Calendar
set
=
new
Calendar
();
set
.
setSiteId
(
siteId
);
EntityWrapper
<
Calendar
>
wrapper
=
new
EntityWrapper
<
Calendar
>(
set
);
Calendar
calendar
=
calendarService
.
selectOne
(
wrapper
);
if
(
null
!=
calendar
)
{
CalendarPointSet
pointSet
=
new
CalendarPointSet
();
pointSet
.
setCalendarId
(
calendar
.
getId
());
pointSet
.
setSetType
(
calendar
.
getSetType
());
EntityWrapper
<
CalendarPointSet
>
entityWrapper
=
new
EntityWrapper
<
CalendarPointSet
>(
pointSet
);
List
<
CalendarPointSet
>
list
=
calendarPointSetService
.
selectList
(
entityWrapper
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
Map
<
String
,
Object
>
map
=
calendarRecordService
.
sign
(
accountId
,
siteId
,
calendar
,
list
);
LOG
.
info
(
map
.
get
(
"result"
).
toString
());
return
map
;
}
else
{
resultMap
.
put
(
"result"
,
"签到失败"
);
LOG
.
info
(
siteId
+
"---该站点暂未开启日历打卡签到功能"
);
return
resultMap
;
}
}
else
{
resultMap
.
put
(
"result"
,
"签到失败"
);
LOG
.
info
(
siteId
+
"---该站点暂未设置打卡积分发放规则"
);
return
resultMap
;
}
}
/**
* 用户每日打卡详情
* @param accountId
* @param siteId
* @return
*/
@GetMapping
(
"/isSign"
)
public
CalendarSignViewVO
isSign
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
)
{
CalendarSignViewVO
vo
=
new
CalendarSignViewVO
();
Calendar
set
=
new
Calendar
();
set
.
setSiteId
(
siteId
);
EntityWrapper
<
Calendar
>
wrapper
=
new
EntityWrapper
<
Calendar
>(
set
);
Calendar
calendar
=
calendarService
.
selectOne
(
wrapper
);
if
(
null
!=
calendar
)
{
CalendarPointSet
pointSet
=
new
CalendarPointSet
();
pointSet
.
setCalendarId
(
calendar
.
getId
());
pointSet
.
setSetType
(
calendar
.
getSetType
());
EntityWrapper
<
CalendarPointSet
>
entityWrapper
=
new
EntityWrapper
<
CalendarPointSet
>(
pointSet
);
List
<
CalendarPointSet
>
list
=
calendarPointSetService
.
selectList
(
entityWrapper
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
vo
=
calendarRecordService
.
isSign
(
accountId
,
siteId
,
calendar
,
list
);
LOG
.
info
(
"用户:"
+
accountId
+
"每日签到详情:"
+
vo
);
return
vo
;
}
else
{
LOG
.
info
(
siteId
+
"---该站点暂未设置打卡积分发放规则"
);
return
vo
;
}
}
else
{
LOG
.
info
(
siteId
+
"---该站点暂未开启日历打卡签到功能"
);
return
vo
;
}
}
@GetMapping
(
"/headData"
)
public
HeadVO
getHeadData
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
)
{
return
calendarRecordService
.
getHeadData
(
accountId
,
siteId
);
}
@GetMapping
(
"/signDetail"
)
public
Page
<
CalendarRecord
>
getSignDetail
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
,
@RequestParam
(
"type"
)
Integer
type
,
@RequestParam
(
"pageNo"
)
Integer
pageNo
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
){
Page
<
CalendarRecord
>
page
=
calendarRecordService
.
getSignDetailByAccountId
(
accountId
,
siteId
,
type
,
pageNo
,
pageSize
);
return
page
;
}
@GetMapping
(
"/signByMonth"
)
public
List
<
CalendarRecord
>
getSignByMonth
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
,
@RequestParam
(
"month"
)
String
month
){
List
<
CalendarRecord
>
list
=
calendarRecordService
.
getSignByMonth
(
month
,
accountId
,
siteId
);
return
list
;
}
@GetMapping
(
"/signNum"
)
public
Map
<
Long
,
Long
>
signNum
(
@RequestParam
(
"siteIds"
)
List
<
Long
>
siteIds
,
@RequestParam
(
"startDate"
)
String
startDate
,
@RequestParam
(
"endDate"
)
String
endDate
){
return
calendarRecordService
.
signNum
(
siteIds
,
startDate
,
endDate
);
}
@GetMapping
(
"/getSignState"
)
public
Integer
getSignState
(
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"siteId"
)
Long
siteId
)
{
Date
date
=
new
Date
();
String
dayString
=
DateUtil
.
toDay
(
date
);
CalendarRecord
record
=
new
CalendarRecord
();
record
.
setSignDate
(
dayString
);
record
.
setAccountId
(
accountId
);
record
.
setSiteId
(
siteId
);
EntityWrapper
<
CalendarRecord
>
wrapper
=
new
EntityWrapper
<
CalendarRecord
>(
record
);
CalendarRecord
one
=
calendarRecordService
.
selectOne
(
wrapper
);
if
(
one
!=
null
)
{
return
1
;
}
else
{
return
0
;
}
}
}
calendar/src/main/java/com/yizhi/calendar/application/domain/Calendar.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
domain
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.baomidou.mybatisplus.enums.FieldFill
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* <p>
* 日历打卡积分发放设置表
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@Data
@ApiModel
(
value
=
"Calendar"
,
description
=
"日历打卡积分设置表"
)
@TableName
(
"calendar"
)
public
class
Calendar
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"主键"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"首次打卡积分"
)
@TableField
(
"first_point"
)
private
Integer
firstPoint
;
@ApiModelProperty
(
value
=
"积分设置类型(1连续递增,2自定义)"
)
@TableField
(
"set_type"
)
private
Integer
setType
;
@ApiModelProperty
(
value
=
"状态 0 删除 1 有效 默认有效"
)
private
Integer
state
;
@ApiModelProperty
(
value
=
"周期持续天数 默认不限制"
)
private
Long
cycle
;
@ApiModelProperty
(
value
=
"企业ID"
)
@TableField
(
"company_id"
)
private
Long
companyId
;
@ApiModelProperty
(
value
=
"站点ID"
)
@TableField
(
"site_id"
)
private
Long
siteId
;
@ApiModelProperty
(
value
=
"部门ID"
)
@TableField
(
"org_id"
)
private
Long
orgId
;
@ApiModelProperty
(
value
=
"创建时间"
)
@TableField
(
value
=
"create_time"
,
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"创建人ID"
)
@TableField
(
value
=
"create_by_id"
,
fill
=
FieldFill
.
INSERT
)
private
Long
createById
;
@ApiModelProperty
(
value
=
"创建人名字"
)
@TableField
(
value
=
"create_by_name"
,
fill
=
FieldFill
.
INSERT
)
private
String
createByName
;
@ApiModelProperty
(
value
=
"修改时间"
)
@TableField
(
value
=
"update_time"
,
fill
=
FieldFill
.
INSERT
)
private
Date
updateTime
;
@ApiModelProperty
(
value
=
"修改人ID"
)
@TableField
(
value
=
"update_by_id"
,
fill
=
FieldFill
.
INSERT
)
private
Long
updateById
;
@ApiModelProperty
(
value
=
"修改人名字"
)
@TableField
(
value
=
"update_by_name"
,
fill
=
FieldFill
.
INSERT
)
private
String
updateByName
;
}
calendar/src/main/java/com/yizhi/calendar/application/domain/CalendarPointSet.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
domain
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.baomidou.mybatisplus.enums.FieldFill
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* <p>
* 日历打卡积分发放设置表
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@Data
@ApiModel
(
value
=
"CalendarPointSet"
,
description
=
"日历打卡积分规则设置表"
)
@TableName
(
"calendar_point_set"
)
public
class
CalendarPointSet
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"主键"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"日历id"
)
@TableField
(
"calendar_id"
)
private
Long
calendarId
;
@ApiModelProperty
(
value
=
"积分设置类型(1连续递增,2自定义)"
)
@TableField
(
"set_type"
)
private
Integer
setType
;
@ApiModelProperty
(
value
=
"状态 0 删除 1 有效 默认有效"
)
private
Integer
state
;
@ApiModelProperty
(
value
=
"积分对应连续最小天数"
)
@TableField
(
"min_date"
)
private
Integer
minDate
;
@ApiModelProperty
(
value
=
"积分"
)
private
Integer
point
;
@ApiModelProperty
(
value
=
"创建时间"
)
@TableField
(
value
=
"create_time"
,
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"创建人ID"
)
@TableField
(
value
=
"create_by_id"
,
fill
=
FieldFill
.
INSERT
)
private
Long
createById
;
@ApiModelProperty
(
value
=
"创建人名字"
)
@TableField
(
value
=
"create_by_name"
,
fill
=
FieldFill
.
INSERT
)
private
String
createByName
;
@ApiModelProperty
(
value
=
"修改时间"
)
@TableField
(
value
=
"update_time"
,
fill
=
FieldFill
.
INSERT
)
private
Date
updateTime
;
@ApiModelProperty
(
value
=
"修改人ID"
)
@TableField
(
value
=
"update_by_id"
,
fill
=
FieldFill
.
INSERT
)
private
Long
updateById
;
@ApiModelProperty
(
value
=
"修改人名字"
)
@TableField
(
value
=
"update_by_name"
,
fill
=
FieldFill
.
INSERT
)
private
String
updateByName
;
}
calendar/src/main/java/com/yizhi/calendar/application/domain/CalendarPoster.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
domain
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* <p>
* 日签海报表
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@Data
@ApiModel
(
value
=
"CalendarPoster"
,
description
=
"日签海报表"
)
@TableName
(
"calendar_poster"
)
public
class
CalendarPoster
{
private
static
final
long
serialVersionUID
=
1L
;
private
Long
id
;
@ApiModelProperty
(
value
=
"下载地址"
)
@TableField
(
"url"
)
private
String
url
;
@ApiModelProperty
(
value
=
"鸡汤文"
)
@TableField
(
"content"
)
private
String
content
;
@ApiModelProperty
(
value
=
"base64编码"
)
@TableField
(
"base64_code"
)
private
String
base64Code
;
}
calendar/src/main/java/com/yizhi/calendar/application/domain/CalendarRecord.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
domain
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.baomidou.mybatisplus.enums.FieldFill
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* <p>
* 日历打卡记录表
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@Data
@ApiModel
(
value
=
"CalendarRecord"
,
description
=
"日历打卡记录表"
)
@TableName
(
"calendar_record"
)
public
class
CalendarRecord
{
private
static
final
long
serialVersionUID
=
1L
;
private
Long
id
;
@ApiModelProperty
(
value
=
"用户id"
)
@TableField
(
"account_id"
)
private
Long
accountId
;
@ApiModelProperty
(
value
=
"首次打卡0,否1 默认首次打卡"
)
@TableField
(
"first_sign"
)
private
Integer
firstSign
;
@ApiModelProperty
(
value
=
"发放积分"
)
private
Integer
point
;
@ApiModelProperty
(
value
=
"签到日期"
)
@TableField
(
"sign_date"
)
private
String
signDate
;
@ApiModelProperty
(
value
=
"打卡时间"
)
@TableField
(
"sign_time"
)
private
String
signTime
;
@ApiModelProperty
(
value
=
"海报id"
)
@TableField
(
"poster_id"
)
private
Long
posterId
;
@ApiModelProperty
(
value
=
"创建时间"
)
@TableField
(
value
=
"create_time"
,
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"企业ID"
)
@TableField
(
"company_id"
)
private
Long
companyId
;
@ApiModelProperty
(
value
=
"站点ID"
)
@TableField
(
"site_id"
)
private
Long
siteId
;
@ApiModelProperty
(
value
=
"部门ID"
)
@TableField
(
"org_id"
)
private
Long
orgId
;
}
calendar/src/main/java/com/yizhi/calendar/application/mapper/CalendarMapper.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
mapper
;
import
com.yizhi.calendar.application.domain.Calendar
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
/**
* <p>
* 日历打卡积分发放设置表 Mapper 接口
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
public
interface
CalendarMapper
extends
BaseMapper
<
Calendar
>
{
}
calendar/src/main/java/com/yizhi/calendar/application/mapper/CalendarPointSetMapper.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
mapper
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.yizhi.calendar.application.domain.CalendarPointSet
;
/**
* <p>
* 日历打卡积分规则设置表 Mapper 接口
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
public
interface
CalendarPointSetMapper
extends
BaseMapper
<
CalendarPointSet
>{
}
calendar/src/main/java/com/yizhi/calendar/application/mapper/CalendarPosterMapper.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
mapper
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.yizhi.calendar.application.domain.CalendarPoster
;
public
interface
CalendarPosterMapper
extends
BaseMapper
<
CalendarPoster
>
{
}
calendar/src/main/java/com/yizhi/calendar/application/mapper/CalendarRecordMapper.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
mapper
;
import
com.yizhi.calendar.application.domain.CalendarRecord
;
import
com.yizhi.calendar.application.vo.CalendarChartVO
;
import
com.yizhi.calendar.application.vo.CalendarDetailStatisticVO
;
import
com.yizhi.calendar.application.vo.CalendarStatisticVO
;
import
com.yizhi.calendar.application.vo.HeadVO
;
import
com.yizhi.calendar.application.vo.SignNumVO
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Param
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
/**
* <p>
* 日历打卡记录表 Mapper 接口
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
public
interface
CalendarRecordMapper
extends
BaseMapper
<
CalendarRecord
>
{
/**
* 获取用户最近一次签到记录
*
* @param accountId
* @return
*/
List
<
CalendarRecord
>
getLastSignByaccountId
(
@Param
(
"accountId"
)
Long
accountId
,
@Param
(
"siteId"
)
Long
siteId
);
/**
* 获取用户最后一次首次签到记录
*
* @param accountId
* @return
*/
List
<
CalendarRecord
>
getLastFirstSignByaccountId
(
@Param
(
"accountId"
)
Long
accountId
,
@Param
(
"siteId"
)
Long
siteId
);
/**
* 获取最大连续签到天数
*
* @param calendarId
* @param minDate
* @return
*/
Integer
getMaxDate
(
@Param
(
"calendarId"
)
Long
calendarId
,
@Param
(
"minDate"
)
Integer
minDate
);
/**
* 获取累计天数和总积分
*
* @param accountId
* @param siteId
* @return
*/
HeadVO
getSumDayAndPoint
(
@Param
(
"accountId"
)
Long
accountId
,
@Param
(
"siteId"
)
Long
siteId
);
/**
* 学员端签到明细
*
* @param accountId
* @param siteId
* @param type
* @return
*/
List
<
CalendarRecord
>
getSignDetailByAccountId
(
@Param
(
"accountId"
)
Long
accountId
,
@Param
(
"siteId"
)
Long
siteId
,
@Param
(
"type"
)
Integer
type
);
/**
* 日历详情
*
* @param date
* @return
*/
List
<
CalendarRecord
>
getSignByMonth
(
@Param
(
"month"
)
String
month
,
@Param
(
"accountId"
)
Long
accountId
,
@Param
(
"siteId"
)
Long
siteId
);
/**
* 折线图
*
* @param startDate
* @param endDate
* @param companyId
* @param siteId
* @return
*/
List
<
CalendarChartVO
>
signChart
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
,
@Param
(
"companyId"
)
Long
companyId
,
@Param
(
"siteId"
)
Long
siteId
);
List
<
CalendarStatisticVO
>
list
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
,
@Param
(
"companyId"
)
Long
companyId
,
@Param
(
"siteId"
)
Long
siteId
,
@Param
(
"accountIds"
)
List
<
Long
>
accountIds
);
List
<
CalendarRecord
>
accountList
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
,
@Param
(
"companyId"
)
Long
companyId
,
@Param
(
"siteId"
)
Long
siteId
,
@Param
(
"accountId"
)
Long
accountId
);
List
<
CalendarDetailStatisticVO
>
detailList
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
,
@Param
(
"companyId"
)
Long
companyId
,
@Param
(
"siteId"
)
Long
siteId
,
@Param
(
"accountIds"
)
List
<
Long
>
accountIds
);
List
<
SignNumVO
>
signNum
(
@Param
(
"siteIds"
)
List
<
Long
>
siteIds
,
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
}
calendar/src/main/java/com/yizhi/calendar/application/mapper/CalendarRecordMapper.xml
0 → 100644
View file @
5fe2e4a6
<?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=
"com.yizhi.calendar.application.mapper.CalendarRecordMapper"
>
<select
id=
"getLastSignByaccountId"
resultType=
"com.yizhi.calendar.application.domain.CalendarRecord"
>
SELECT
*
FROM
calendar_record cr
WHERE
cr.account_id =#{accountId}
and cr.site_id=#{siteId} ORDER BY create_time desc LIMIT 1
</select>
<select
id=
"getLastFirstSignByaccountId"
resultType=
"com.yizhi.calendar.application.domain.CalendarRecord"
>
SELECT
*
FROM
calendar_record cr
WHERE
cr.account_id =#{accountId}
and cr.site_id=#{siteId} and cr.first_sign=1 ORDER BY create_time desc LIMIT 1
</select>
<select
id=
"getMaxDate"
resultType=
"java.lang.Integer"
>
SELECT MIN(a.min_date)
FROM
calendar_point_set a
where a.calendar_id = #{calendarId}
and a.min_Date
> #{minDate}
</select>
<select
id=
"getSumDayAndPoint"
resultType=
"com.yizhi.calendar.application.vo.HeadVO"
>
SELECT
IFNULL(SUM( c.point ),0) point,
COUNT( c.account_id )
sumDays
FROM
calendar_record c
WHERE
c.account_id = #{accountId}
AND
c.site_id =
#{siteId}
</select>
<select
id=
"getSignDetailByAccountId"
resultType=
"com.yizhi.calendar.application.domain.CalendarRecord"
>
SELECT
*
FROM
calendar_record c
WHERE
c.account_id = #{accountId}
and
c.site_id = #{siteId}
<if
test=
'type != 5'
>
<choose>
<when
test=
"type == 1"
>
and YEARWEEK( DATE_FORMAT( create_time, '%Y-%m-%d'
), 1 )= YEARWEEK(
now(), 1 )
</when>
<when
test=
"type == 2"
>
and YEARWEEK( DATE_FORMAT( create_time, '%Y-%m-%d'
), 1 )= YEARWEEK(
now(), 1 )-1
</when>
<when
test=
"type == 3"
>
and
date_format(create_time,'%Y-%m')=date_format(now(),'%Y-%m')
</when>
<otherwise>
and DATE_FORMAT(create_time,'%Y-%m') =
DATE_FORMAT(DATE_SUB(curdate(),
INTERVAL 1 MONTH),'%Y-%m')
</otherwise>
</choose>
</if>
ORDER BY c.create_time DESC
</select>
<select
id=
"getSignByMonth"
resultType=
"com.yizhi.calendar.application.domain.CalendarRecord"
>
SELECT
*
FROM
calendar_record c
WHERE
c.account_id =
#{accountId}
and c.site_id = #{siteId}
and
date_format(create_time,'%Y-%m')=#{month}
</select>
<select
id=
"signChart"
resultType=
"com.yizhi.calendar.application.vo.CalendarChartVO"
>
SELECT
DATE_FORMAT(c.sign_date,'%Y%m%d') dateStr,
COUNT( id )
signNum
FROM
calendar_record c
WHERE
create_time BETWEEN str_to_date(
#{startDate},
'%Y-%m-%d %H' )
AND str_to_date(#{endDate}, '%Y-%m-%d
%H:%i:%s')
AND
company_id =
#{companyId}
AND site_id = #{siteId}
GROUP BY
dateStr
</select>
<select
id=
"list"
resultType=
"com.yizhi.calendar.application.vo.CalendarStatisticVO"
>
SELECT
c.account_id accountId,
COUNT( id ) count,
SUM( c.point ) point
FROM
calendar_record c
WHERE
create_time BETWEEN str_to_date(
#{startDate},
'%Y-%m-%d %H' )
AND str_to_date(#{endDate}, '%Y-%m-%d
%H:%i:%s')
AND c.site_id = #{siteId}
AND c.company_id = #{companyId}
AND
c.account_id IN
(
<foreach
collection=
"accountIds"
separator=
","
item=
"item"
>
#{item}
</foreach>
)
GROUP BY
c.account_id
ORDER BY
count DESC
</select>
<select
id=
"accountList"
resultType=
"com.yizhi.calendar.application.domain.CalendarRecord"
>
SELECT
c.sign_date signDate,
c.sign_time signTime,
c.point
point
FROM
calendar_record c
WHERE
create_time BETWEEN str_to_date(
#{startDate},
'%Y-%m-%d %H' )
AND str_to_date(#{endDate}, '%Y-%m-%d
%H:%i:%s')
AND c.site_id = #{siteId}
AND c.company_id = #{companyId}
AND
c.account_id = #{accountId}
ORDER BY signDate DESC
</select>
<select
id=
"detailList"
resultType=
"com.yizhi.calendar.application.vo.CalendarDetailStatisticVO"
>
SELECT
c.account_id accountId,
c.sign_date signDate,
c.sign_time
signTime,
c.point point,
c.create_time createTime
FROM
calendar_record c
WHERE
create_time BETWEEN str_to_date(
#{startDate},
'%Y-%m-%d %H' )
AND
str_to_date(#{endDate}, '%Y-%m-%d
%H:%i:%s')
AND c.site_id = #{siteId}
AND c.company_id = #{companyId}
AND
c.account_id IN
(
<foreach
collection=
"accountIds"
separator=
","
item=
"item"
>
#{item}
</foreach>
)
ORDER BY createTime DESC
</select>
<resultMap
type=
"com.yizhi.calendar.application.vo.SignNumVO"
id=
"signMap"
>
<result
property=
"accountId"
column=
"accountId"
/>
<result
property=
"signNum"
column=
"signNum"
/>
</resultMap>
<select
id=
"signNum"
resultType=
"com.yizhi.calendar.application.vo.SignNumVO"
>
SELECT
count(id) signNum,account_id accountId
FROM
calendar_record c
WHERE
c.site_id IN (
<foreach
collection=
"siteIds"
separator=
","
item=
"item"
>
#{item}
</foreach>
)
AND create_time BETWEEN #{startDate}
AND #{endDate}
group by accountId
</select>
</mapper>
calendar/src/main/java/com/yizhi/calendar/application/service/ICalendarPointSetService.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
service
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.yizhi.calendar.application.domain.CalendarPointSet
;
/**
* <p>
* 日历打卡积分规则设置表 服务类
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
public
interface
ICalendarPointSetService
extends
IService
<
CalendarPointSet
>{
}
calendar/src/main/java/com/yizhi/calendar/application/service/ICalendarPosterService.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
service
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.yizhi.calendar.application.domain.CalendarPoster
;
public
interface
ICalendarPosterService
extends
IService
<
CalendarPoster
>
{
}
calendar/src/main/java/com/yizhi/calendar/application/service/ICalendarRecordService.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
service
;
import
com.yizhi.calendar.application.domain.Calendar
;
import
com.yizhi.calendar.application.domain.CalendarPointSet
;
import
com.yizhi.calendar.application.domain.CalendarRecord
;
import
com.yizhi.calendar.application.vo.CalendarChartVO
;
import
com.yizhi.calendar.application.vo.CalendarDetailStatisticVO
;
import
com.yizhi.calendar.application.vo.CalendarSignViewVO
;
import
com.yizhi.calendar.application.vo.CalendarStatisticVO
;
import
com.yizhi.calendar.application.vo.HeadVO
;
import
java.util.List
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.service.IService
;
/**
* <p>
* 日历打卡记录表 服务类
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
public
interface
ICalendarRecordService
extends
IService
<
CalendarRecord
>
{
public
Map
<
String
,
Object
>
sign
(
Long
accountId
,
Long
siteId
,
Calendar
calendar
,
List
<
CalendarPointSet
>
list
);
public
CalendarSignViewVO
isSign
(
Long
accountId
,
Long
siteId
,
Calendar
calendar
,
List
<
CalendarPointSet
>
list
);
public
HeadVO
getHeadData
(
Long
accountId
,
Long
siteId
);
public
Page
<
CalendarRecord
>
getSignDetailByAccountId
(
Long
accountId
,
Long
siteId
,
Integer
type
,
Integer
pageNo
,
Integer
pageSize
);
public
List
<
CalendarRecord
>
getSignByMonth
(
String
month
,
Long
accountId
,
Long
siteId
);
public
List
<
CalendarChartVO
>
signChart
(
String
startDate
,
String
endDate
,
Long
companyId
,
Long
siteId
);
public
List
<
CalendarStatisticVO
>
list
(
String
startDate
,
String
endDate
,
String
kwd
,
Long
companyId
,
Long
siteId
);
public
List
<
CalendarRecord
>
accountList
(
String
startDate
,
String
endDate
,
Long
accountId
,
Long
companyId
,
Long
siteId
);
public
List
<
CalendarDetailStatisticVO
>
detailList
(
String
startDate
,
String
endDate
,
Long
companyId
,
Long
siteId
,
String
kwd
);
public
Map
<
Long
,
Long
>
signNum
(
List
<
Long
>
siteIds
,
String
startDate
,
String
endDate
);
}
calendar/src/main/java/com/yizhi/calendar/application/service/ICalendarService.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
service
;
import
com.yizhi.calendar.application.domain.Calendar
;
import
com.baomidou.mybatisplus.service.IService
;
/**
* <p>
* 日历打卡积分设置表 服务类
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
public
interface
ICalendarService
extends
IService
<
Calendar
>
{
}
calendar/src/main/java/com/yizhi/calendar/application/service/impl/CalendarPointSetServiceImpl.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
service
.
impl
;
import
com.yizhi.calendar.application.domain.CalendarPointSet
;
import
com.yizhi.calendar.application.service.ICalendarPointSetService
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.yizhi.calendar.application.mapper.CalendarPointSetMapper
;
@Service
public
class
CalendarPointSetServiceImpl
extends
ServiceImpl
<
CalendarPointSetMapper
,
CalendarPointSet
>
implements
ICalendarPointSetService
{
}
calendar/src/main/java/com/yizhi/calendar/application/service/impl/CalendarPosterServiceImpl.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
service
.
impl
;
import
com.yizhi.calendar.application.domain.CalendarPoster
;
import
com.yizhi.calendar.application.service.ICalendarPosterService
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.yizhi.calendar.application.mapper.CalendarPosterMapper
;
@Service
public
class
CalendarPosterServiceImpl
extends
ServiceImpl
<
CalendarPosterMapper
,
CalendarPoster
>
implements
ICalendarPosterService
{
}
calendar/src/main/java/com/yizhi/calendar/application/service/impl/CalendarRecordServiceImpl.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
service
.
impl
;
import
cn.hutool.core.codec.Base64Encoder
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.plugins.pagination.PageHelper
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.yizhi.application.orm.id.IdGenerator
;
import
com.yizhi.calendar.application.domain.CalendarPointSet
;
import
com.yizhi.calendar.application.domain.CalendarPoster
;
import
com.yizhi.calendar.application.domain.CalendarRecord
;
import
com.yizhi.calendar.application.mapper.CalendarPosterMapper
;
import
com.yizhi.calendar.application.mapper.CalendarRecordMapper
;
import
com.yizhi.calendar.application.service.ICalendarRecordService
;
import
com.yizhi.calendar.application.vo.*
;
import
com.yizhi.core.application.context.ContextHolder
;
import
com.yizhi.core.application.context.RequestContext
;
import
com.yizhi.system.application.system.remote.AccountClient
;
import
com.yizhi.system.application.system.remote.OrganizationClient
;
import
com.yizhi.system.application.system.remote.ReportClient
;
import
com.yizhi.system.application.vo.AccountVO
;
import
com.yizhi.system.application.vo.ReportAccountRespVO
;
import
com.yizhi.system.application.vo.ReportRangeAccountReqVO
;
import
com.yizhi.util.application.date.DateUtil
;
import
org.apache.commons.collections.CollectionUtils
;
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.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* <p>
* 日历打卡记录表 服务实现类
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@Service
public
class
CalendarRecordServiceImpl
extends
ServiceImpl
<
CalendarRecordMapper
,
CalendarRecord
>
implements
ICalendarRecordService
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
CalendarRecordServiceImpl
.
class
);
@Autowired
private
CalendarRecordMapper
calendarRecordMapper
;
@Autowired
private
IdGenerator
idGenerator
;
@Autowired
private
AccountClient
accountClient
;
@Autowired
private
ReportClient
reportClient
;
@Autowired
private
OrganizationClient
organizationClient
;
@Autowired
private
CalendarPosterMapper
calendarPosterMapper
;
@Override
public
Map
<
String
,
Object
>
sign
(
Long
accountId
,
Long
siteId
,
com
.
yizhi
.
calendar
.
application
.
domain
.
Calendar
calendar
,
List
<
CalendarPointSet
>
list
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<
String
,
Object
>();
RequestContext
res
=
ContextHolder
.
get
();
Date
date
=
new
Date
();
String
dayString
=
DateUtil
.
toDay
(
date
);
String
timeString
=
DateUtil
.
toShortSeconds
(
date
);
CalendarSignViewVO
signViewVO
=
this
.
isSign
(
accountId
,
siteId
,
calendar
,
list
);
if
(
null
!=
signViewVO
)
{
Integer
isSign
=
signViewVO
.
getIsSign
();
Long
day
=
signViewVO
.
getDay
();
Integer
point
=
signViewVO
.
getPoint
();
if
(
1
==
isSign
)
{
resultMap
.
put
(
"result"
,
"签到失败"
);
LOG
.
error
(
"用户:"
+
accountId
+
"今日已签到,不能重复签到"
);
}
else
{
CalendarRecord
record
=
new
CalendarRecord
();
record
.
setId
(
idGenerator
.
generate
());
record
.
setAccountId
(
accountId
);
record
.
setCompanyId
(
res
.
getCompanyId
());
record
.
setSiteId
(
siteId
);
record
.
setOrgId
(
res
.
getOrgId
());
record
.
setCreateTime
(
date
);
record
.
setOrgId
(
res
.
getOrgId
());
record
.
setSignDate
(
dayString
);
record
.
setSignTime
(
timeString
);
record
.
setPoint
(
point
);
record
.
setPosterId
(
signViewVO
.
getPosterId
());
if
(
day
>
0
)
{
record
.
setFirstSign
(
0
);
}
else
{
record
.
setFirstSign
(
1
);
}
boolean
b
=
this
.
insert
(
record
);
if
(
b
)
{
HeadVO
sumDayAndPoint
=
calendarRecordMapper
.
getSumDayAndPoint
(
accountId
,
siteId
);
resultMap
.
put
(
"result"
,
"签到成功"
);
resultMap
.
put
(
"consecutiveDays"
,
signViewVO
.
getDay
()+
1
);
resultMap
.
put
(
"sumDays"
,
sumDayAndPoint
.
getSumDays
());
resultMap
.
put
(
"point"
,
point
);
resultMap
.
put
(
"signId"
,
record
.
getId
());
LOG
.
info
(
"用户:"
+
accountId
+
"签到成功! 奖励积分:"
+
point
);
}
else
{
resultMap
.
put
(
"result"
,
"签到失败"
);
LOG
.
error
(
"用户:"
+
accountId
+
"签到入库失败"
);
}
}
}
else
{
resultMap
.
put
(
"result"
,
"签到失败"
);
}
return
resultMap
;
}
@Override
public
CalendarSignViewVO
isSign
(
Long
accountId
,
Long
siteId
,
com
.
yizhi
.
calendar
.
application
.
domain
.
Calendar
calendar
,
List
<
CalendarPointSet
>
list
)
{
CalendarSignViewVO
vo
=
new
CalendarSignViewVO
();
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyymmddHHmmss"
);
int
i
=
java
.
util
.
Calendar
.
getInstance
().
get
(
java
.
util
.
Calendar
.
DAY_OF_MONTH
);
Date
date
=
new
Date
();
String
dayString
=
DateUtil
.
toDay
(
date
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-mm-dd"
);
AccountVO
accountVO
=
accountClient
.
findById
(
accountId
);
HeadVO
headData
=
calendarRecordMapper
.
getSumDayAndPoint
(
accountId
,
siteId
);
List
<
CalendarRecord
>
lastFirstSigns
=
calendarRecordMapper
.
getLastFirstSignByaccountId
(
accountId
,
siteId
);
CalendarRecord
record
=
new
CalendarRecord
();
record
.
setSignDate
(
dayString
);
record
.
setAccountId
(
accountId
);
record
.
setSiteId
(
siteId
);
EntityWrapper
<
CalendarRecord
>
wrapper
=
new
EntityWrapper
<
CalendarRecord
>(
record
);
CalendarRecord
one
=
this
.
selectOne
(
wrapper
);
try
{
Date
day
=
sdf
.
parse
(
dayString
);
if
(
CollectionUtils
.
isNotEmpty
(
lastFirstSigns
))
{
CalendarRecord
lastFirstSign
=
lastFirstSigns
.
get
(
0
);
Date
lastFirstSignDay
=
sdf
.
parse
(
lastFirstSign
.
getSignDate
());
long
firstDayBetween
=
(
day
.
getTime
()
-
lastFirstSignDay
.
getTime
())
/
(
60
*
60
*
24
*
1000
);
LOG
.
info
(
"距离第一次签到"
+
firstDayBetween
+
"天"
);
// 已签到
if
(!
ObjectUtils
.
isEmpty
(
one
))
{
vo
.
setName
(
null
==
accountVO
.
getFullName
()
||
""
==
accountVO
.
getFullName
()
?
accountVO
.
getName
()
:
accountVO
.
getFullName
());
vo
.
setHeadPortrait
(!
StringUtils
.
isEmpty
(
accountVO
.
getHeadPortrait
())?
imageToBase64
(
accountVO
.
getHeadPortrait
()):
""
);
vo
.
setDay
(
firstDayBetween
+
1
);
vo
.
setIsSign
(
1
);
vo
.
setPoint
(
one
.
getPoint
());
vo
.
setIsCycle
(
0
!=
(
vo
.
getDay
()
%
calendar
.
getCycle
())
?
0
:
1
);
vo
.
setSumDays
(
headData
.
getSumDays
());
CalendarPoster
poster
=
calendarPosterMapper
.
selectById
(
one
.
getPosterId
());
if
(
null
!=
poster
)
{
vo
.
setPosterId
(
poster
.
getId
());
vo
.
setImgUrl
(
poster
.
getBase64Code
());
vo
.
setContent
(
poster
.
getContent
());
}
// 未签到
}
else
{
List
<
CalendarRecord
>
lastSigns
=
calendarRecordMapper
.
getLastSignByaccountId
(
accountId
,
siteId
);
CalendarRecord
lastSign
=
lastSigns
.
get
(
0
);
Date
lastSignDay
=
sdf
.
parse
(
lastSign
.
getSignDate
());
if
(
lastSign
.
getPosterId
()==
null
)
{
lastSign
.
setPosterId
((
long
)
(
new
Random
().
nextInt
(
21
)+
1
));
}
long
dayBetween
=
(
day
.
getTime
()
-
lastSignDay
.
getTime
())
/
(
60
*
60
*
24
*
1000
);
if
(
calendar
.
getUpdateTime
().
after
(
lastSign
.
getCreateTime
()))
{
vo
.
setName
(
null
==
accountVO
.
getFullName
()
||
""
==
accountVO
.
getFullName
()
?
accountVO
.
getName
()
:
accountVO
.
getFullName
());
vo
.
setHeadPortrait
(!
StringUtils
.
isEmpty
(
accountVO
.
getHeadPortrait
())?
imageToBase64
(
accountVO
.
getHeadPortrait
()):
""
);
vo
.
setDay
(
0
l
);
vo
.
setIsSign
(
0
);
vo
.
setIsCycle
(
0
!=
((
vo
.
getDay
()
+
1
)
%
calendar
.
getCycle
())
?
0
:
1
);
vo
.
setPoint
(
calendar
.
getFirstPoint
());
vo
.
setSumDays
(
headData
.
getSumDays
());
CalendarPoster
poster
=
calendarPosterMapper
.
selectById
(
vo
.
getIsCycle
().
equals
(
0
)?((
long
)
new
Random
().
nextInt
(
21
)+
1
):((
long
)
new
Random
().
nextInt
(
10
)+
22
));
if
(
null
!=
poster
)
{
vo
.
setPosterId
(
poster
.
getId
());
vo
.
setImgUrl
(
poster
.
getBase64Code
());
vo
.
setContent
(
poster
.
getContent
());
}
}
else
{
// 连续签到
if
(
1
==
dayBetween
)
{
// 周期内任意一天
if
(
0
!=
(
firstDayBetween
%
calendar
.
getCycle
()))
{
// 连续递增
Integer
point
=
0
;
if
(
calendar
.
getSetType
()
==
1
)
{
point
=
lastSign
.
getPoint
()
+
list
.
get
(
0
).
getPoint
();
// 自定义
}
else
{
List
<
CalendarRuleListVO
>
ruleList
=
new
ArrayList
<
CalendarRuleListVO
>();
// 组装自定义范围及积分
for
(
CalendarPointSet
pointSet
:
list
)
{
Integer
maxDate
=
calendarRecordMapper
.
getMaxDate
(
pointSet
.
getCalendarId
(),
pointSet
.
getMinDate
());
CalendarRuleListVO
ruleListVO
=
new
CalendarRuleListVO
();
ruleListVO
.
setMaxDate
(
maxDate
);
ruleListVO
.
setMinDate
(
pointSet
.
getMinDate
());
ruleListVO
.
setPoint
(
pointSet
.
getPoint
());
ruleList
.
add
(
ruleListVO
);
}
if
(
CollectionUtils
.
isNotEmpty
(
ruleList
))
{
for
(
CalendarRuleListVO
calendarRuleListVO
:
ruleList
)
{
if
(
firstDayBetween
>=
calendarRuleListVO
.
getMinDate
()
&&
null
!=
calendarRuleListVO
.
getMaxDate
()
&&
firstDayBetween
<
calendarRuleListVO
.
getMaxDate
())
{
point
=
calendarRuleListVO
.
getPoint
();
break
;
}
else
if
(
firstDayBetween
>=
calendarRuleListVO
.
getMinDate
()
&&
null
!=
calendarRuleListVO
.
getMaxDate
()
&&
firstDayBetween
>
calendarRuleListVO
.
getMaxDate
())
{
continue
;
}
else
if
(
firstDayBetween
>=
calendarRuleListVO
.
getMinDate
()
&&
null
==
calendarRuleListVO
.
getMaxDate
())
{
point
=
calendarRuleListVO
.
getPoint
();
break
;
}
else
if
(
firstDayBetween
<
calendarRuleListVO
.
getMinDate
())
{
point
=
0
;
break
;
}
}
}
}
vo
.
setName
(
null
==
accountVO
.
getFullName
()
||
""
==
accountVO
.
getFullName
()
?
accountVO
.
getName
()
:
accountVO
.
getFullName
());
vo
.
setHeadPortrait
(!
StringUtils
.
isEmpty
(
accountVO
.
getHeadPortrait
())?
imageToBase64
(
accountVO
.
getHeadPortrait
()):
""
);
vo
.
setDay
(
firstDayBetween
);
vo
.
setIsCycle
(
0
!=
((
vo
.
getDay
()
+
1
)
%
calendar
.
getCycle
())
?
0
:
1
);
vo
.
setIsSign
(
0
);
vo
.
setPoint
(
point
);
vo
.
setSumDays
(
headData
.
getSumDays
());
Long
lastPoster
=
lastSign
.
getPosterId
();
Long
posterId
=
1
l
;
if
(
lastPoster
!=
21
)
{
posterId
=
lastPoster
+
1
;
}
CalendarPoster
poster
=
calendarPosterMapper
.
selectById
(
vo
.
getIsCycle
().
equals
(
0
)?
posterId:
((
long
)
new
Random
().
nextInt
(
10
)+
22
));
if
(
null
!=
poster
)
{
vo
.
setPosterId
(
poster
.
getId
());
vo
.
setImgUrl
(
poster
.
getBase64Code
());
vo
.
setContent
(
poster
.
getContent
());
}
// 周期第一天
}
else
{
vo
.
setName
(
null
==
accountVO
.
getFullName
()
||
""
==
accountVO
.
getFullName
()
?
accountVO
.
getName
()
:
accountVO
.
getFullName
());
vo
.
setHeadPortrait
(!
StringUtils
.
isEmpty
(
accountVO
.
getHeadPortrait
())?
imageToBase64
(
accountVO
.
getHeadPortrait
()):
""
);
vo
.
setDay
(
0
l
);
vo
.
setIsSign
(
0
);
vo
.
setIsCycle
(
0
!=
((
vo
.
getDay
()
+
1
)
%
calendar
.
getCycle
())
?
0
:
1
);
vo
.
setPoint
(
calendar
.
getFirstPoint
());
vo
.
setSumDays
(
headData
.
getSumDays
());
CalendarPoster
poster
=
calendarPosterMapper
.
selectById
(
vo
.
getIsCycle
().
equals
(
0
)?((
long
)
new
Random
().
nextInt
(
21
)+
1
):((
long
)
new
Random
().
nextInt
(
10
)+
22
));
if
(
null
!=
poster
)
{
vo
.
setPosterId
(
poster
.
getId
());
vo
.
setImgUrl
(
poster
.
getBase64Code
());
vo
.
setContent
(
poster
.
getContent
());
}
}
// 首次签到
}
else
{
vo
.
setName
(
null
==
accountVO
.
getFullName
()
||
""
==
accountVO
.
getFullName
()
?
accountVO
.
getName
()
:
accountVO
.
getFullName
());
vo
.
setHeadPortrait
(!
StringUtils
.
isEmpty
(
accountVO
.
getHeadPortrait
())?
imageToBase64
(
accountVO
.
getHeadPortrait
()):
""
);
vo
.
setIsSign
(
0
);
vo
.
setPoint
(
calendar
.
getFirstPoint
());
vo
.
setDay
(
0
l
);
vo
.
setIsCycle
(
0
!=
((
vo
.
getDay
()
+
1
)
%
calendar
.
getCycle
())
?
0
:
1
);
vo
.
setSumDays
(
headData
.
getSumDays
());
CalendarPoster
poster
=
calendarPosterMapper
.
selectById
(
vo
.
getIsCycle
().
equals
(
0
)?((
long
)
new
Random
().
nextInt
(
21
)+
1
):((
long
)
new
Random
().
nextInt
(
10
)+
22
));
if
(
null
!=
poster
)
{
vo
.
setPosterId
(
poster
.
getId
());
vo
.
setImgUrl
(
poster
.
getBase64Code
());
vo
.
setContent
(
poster
.
getContent
());
}
}
}
}
// 用户第一次签到
}
else
{
vo
.
setName
(
null
==
accountVO
.
getFullName
()
||
""
==
accountVO
.
getFullName
()
?
accountVO
.
getName
()
:
accountVO
.
getFullName
());
vo
.
setHeadPortrait
(!
StringUtils
.
isEmpty
(
accountVO
.
getHeadPortrait
())?
imageToBase64
(
accountVO
.
getHeadPortrait
()):
""
);
vo
.
setDay
(
0
l
);
vo
.
setIsCycle
(
0
!=
((
vo
.
getDay
()
+
1
)
%
calendar
.
getCycle
())
?
0
:
1
);
vo
.
setIsSign
(
0
);
vo
.
setPoint
(
calendar
.
getFirstPoint
());
vo
.
setSumDays
(
0
l
);
CalendarPoster
poster
=
calendarPosterMapper
.
selectById
(
vo
.
getIsCycle
().
equals
(
0
)?((
long
)
new
Random
().
nextInt
(
21
)+
1
):((
long
)
new
Random
().
nextInt
(
10
)+
22
));
if
(
null
!=
poster
)
{
vo
.
setPosterId
(
poster
.
getId
());
vo
.
setImgUrl
(
poster
.
getBase64Code
());
vo
.
setContent
(
poster
.
getContent
());
}
}
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
LOG
.
error
(
"签到详情异常!!!"
+
e
);
}
return
vo
;
}
@Override
public
HeadVO
getHeadData
(
Long
accountId
,
Long
siteId
)
{
HeadVO
vo
=
new
HeadVO
();
List
<
CalendarRecord
>
lastFirstSigns
=
calendarRecordMapper
.
getLastFirstSignByaccountId
(
accountId
,
siteId
);
List
<
CalendarRecord
>
lastSigns
=
calendarRecordMapper
.
getLastSignByaccountId
(
accountId
,
siteId
);
if
(
CollectionUtils
.
isNotEmpty
(
lastSigns
)&&
CollectionUtils
.
isNotEmpty
(
lastFirstSigns
))
{
try
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-mm-dd"
);
CalendarRecord
lastSign
=
lastSigns
.
get
(
0
);
CalendarRecord
lastFirstSign
=
lastFirstSigns
.
get
(
0
);
long
consecutiveDays
=
(
format
.
parse
(
lastSign
.
getSignDate
()).
getTime
()
-
format
.
parse
(
lastFirstSign
.
getSignDate
()).
getTime
())
/
(
60
*
60
*
24
*
1000
);
vo
=
calendarRecordMapper
.
getSumDayAndPoint
(
accountId
,
siteId
);
vo
.
setConsecutiveDays
(
consecutiveDays
+
1
);
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
else
{
vo
.
setConsecutiveDays
(
0
l
);
vo
.
setSumDays
(
0
l
);
vo
.
setPoint
(
0
);
}
return
vo
;
}
@Override
public
Page
<
CalendarRecord
>
getSignDetailByAccountId
(
Long
accountId
,
Long
siteId
,
Integer
type
,
Integer
pageNo
,
Integer
pageSize
)
{
Page
<
CalendarRecord
>
page
=
new
Page
<
CalendarRecord
>();
LOG
.
info
(
"分页信息pageSize={},pageNo={}"
,
pageSize
,
pageNo
);
if
(
pageSize
!=
null
&&
pageNo
!=
null
)
{
PageHelper
.
startPage
(
pageNo
,
pageSize
);
}
List
<
CalendarRecord
>
list
=
this
.
baseMapper
.
getSignDetailByAccountId
(
accountId
,
siteId
,
type
);
if
(
pageSize
!=
null
&&
pageNo
!=
null
)
{
page
.
setTotal
(
PageHelper
.
getTotal
());
page
.
setSize
(
pageSize
);
page
.
setCurrent
(
pageNo
);
PageHelper
.
remove
();
}
page
.
setRecords
(
list
);
LOG
.
info
(
"签到打卡明细:"
+
page
.
getRecords
());
return
page
;
}
@Override
public
List
<
CalendarRecord
>
getSignByMonth
(
String
month
,
Long
accountId
,
Long
siteId
)
{
return
this
.
baseMapper
.
getSignByMonth
(
month
,
accountId
,
siteId
);
}
@Override
public
List
<
CalendarChartVO
>
signChart
(
String
startDate
,
String
endDate
,
Long
companyId
,
Long
siteId
)
{
// 开始时间
LocalDate
startLocalDate
=
LocalDate
.
parse
(
startDate
,
DateTimeFormatter
.
ISO_DATE
);
// 结束时间
LocalDate
endLocalDate
=
LocalDate
.
parse
(
endDate
,
DateTimeFormatter
.
ISO_DATE
);
long
endNum
=
endLocalDate
.
toEpochDay
()
-
startLocalDate
.
toEpochDay
();
endNum
=
endNum
<=
0
?
1
:
endNum
+
1
;
List
<
String
>
retDataKey
=
Stream
.
iterate
(
startLocalDate
,
nextDate
->
nextDate
.
plusDays
(
1
)).
limit
(
endNum
)
.
map
(
item
->
item
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyyMMdd"
))).
collect
(
Collectors
.
toList
());
LOG
.
info
(
"****************统计图表出来的时间信息={}"
,
JSON
.
toJSONString
(
retDataKey
));
endDate
=
endDate
+
" 23:59:59"
;
List
<
CalendarChartVO
>
list
=
this
.
baseMapper
.
signChart
(
startDate
,
endDate
,
companyId
,
siteId
);
Map
<
String
,
CalendarChartVO
>
signData
=
null
;
List
<
CalendarChartVO
>
listData
=
new
ArrayList
<
CalendarChartVO
>();
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
// 获取签到次数
signData
=
list
.
stream
().
parallel
().
collect
(
Collectors
.
toMap
(
key
->
key
.
getDateStr
(),
val
->
val
));
LOG
.
info
(
"****************统计图表出来的数据={}"
,
signData
.
toString
());
for
(
String
key
:
retDataKey
)
{
CalendarChartVO
obj
=
signData
.
get
(
key
);
if
(
obj
==
null
)
{
obj
=
new
CalendarChartVO
();
obj
.
setDateStr
(
key
);
obj
.
setSignNum
(
0
);
}
else
{
obj
.
setDateStr
(
key
);
}
listData
.
add
(
obj
);
}
}
return
listData
;
}
@Override
public
List
<
CalendarStatisticVO
>
list
(
String
startDate
,
String
endDate
,
String
kwd
,
Long
companyId
,
Long
siteId
)
{
endDate
=
endDate
+
" 23:59:59"
;
if
(
StringUtils
.
isNotBlank
(
kwd
))
{
kwd
=
"%"
+
kwd
+
"%"
;
}
else
{
kwd
=
null
;
}
ReportRangeAccountReqVO
vo
=
new
ReportRangeAccountReqVO
();
vo
.
setSiteId
(
siteId
);
vo
.
setAccountName
(
kwd
);
List
<
ReportAccountRespVO
>
accounts
=
reportClient
.
getRangeAccounts
(
vo
);
List
<
Long
>
accountIds
=
new
ArrayList
<
Long
>();
Map
<
Long
,
ReportAccountRespVO
>
map
=
new
HashMap
<
Long
,
ReportAccountRespVO
>();
List
<
CalendarStatisticVO
>
list
=
new
ArrayList
<
CalendarStatisticVO
>();
for
(
ReportAccountRespVO
user
:
accounts
)
{
map
.
put
(
user
.
getUserId
(),
user
);
accountIds
.
add
(
user
.
getUserId
());
}
if
(!
CollectionUtils
.
isEmpty
(
accountIds
))
{
list
=
this
.
baseMapper
.
list
(
startDate
,
endDate
,
companyId
,
siteId
,
accountIds
);
for
(
CalendarStatisticVO
cVo
:
list
)
{
ReportAccountRespVO
account
=
map
.
get
(
cVo
.
getAccountId
());
cVo
.
setName
(
account
.
getUserName
());
cVo
.
setFullName
(
account
.
getUserFullName
());
cVo
.
setWorkNum
(
account
.
getWorkNum
());
cVo
.
setPosition
(
account
.
getPosition
());
cVo
.
setOrgName
(
account
.
getOrgName
());
List
<
String
>
orgNames
=
organizationClient
.
getChiefOrgNames
(
account
.
getOrgId
(),
companyId
);
String
resultString
=
""
;
for
(
int
i
=
0
;
i
<
orgNames
.
size
();
i
++)
{
String
s
=
orgNames
.
get
(
i
);
if
(
i
==
0
)
{
resultString
+=
s
;
}
else
{
resultString
+=
"/"
+
s
;
}
}
cVo
.
setOrgNames
(
resultString
);
}
}
return
list
;
}
@Override
public
List
<
CalendarRecord
>
accountList
(
String
startDate
,
String
endDate
,
Long
accountId
,
Long
companyId
,
Long
siteId
)
{
endDate
=
endDate
+
" 23:59:59"
;
return
this
.
baseMapper
.
accountList
(
startDate
,
endDate
,
companyId
,
siteId
,
accountId
);
}
@Override
public
List
<
CalendarDetailStatisticVO
>
detailList
(
String
startDate
,
String
endDate
,
Long
companyId
,
Long
siteId
,
String
kwd
)
{
endDate
=
endDate
+
" 23:59:59"
;
if
(
StringUtils
.
isNotBlank
(
kwd
))
{
kwd
=
"%"
+
kwd
+
"%"
;
}
else
{
kwd
=
null
;
}
ReportRangeAccountReqVO
vo
=
new
ReportRangeAccountReqVO
();
vo
.
setSiteId
(
siteId
);
vo
.
setAccountName
(
kwd
);
List
<
ReportAccountRespVO
>
accounts
=
reportClient
.
getRangeAccounts
(
vo
);
List
<
Long
>
accountIds
=
new
ArrayList
<
Long
>();
Map
<
Long
,
ReportAccountRespVO
>
map
=
new
HashMap
<
Long
,
ReportAccountRespVO
>();
for
(
ReportAccountRespVO
user
:
accounts
)
{
map
.
put
(
user
.
getUserId
(),
user
);
accountIds
.
add
(
user
.
getUserId
());
}
List
<
CalendarDetailStatisticVO
>
list
=
this
.
baseMapper
.
detailList
(
startDate
,
endDate
,
companyId
,
siteId
,
accountIds
);
for
(
CalendarDetailStatisticVO
record
:
list
)
{
ReportAccountRespVO
account
=
map
.
get
(
record
.
getAccountId
());
record
.
setName
(
account
.
getUserName
());
record
.
setFullName
(
account
.
getUserFullName
());
record
.
setWorkNum
(
account
.
getWorkNum
());
record
.
setPosition
(
account
.
getPosition
());
record
.
setOrgName
(
account
.
getOrgName
());
List
<
String
>
orgNames
=
organizationClient
.
getChiefOrgNames
(
account
.
getOrgId
(),
companyId
);
String
resultString
=
""
;
for
(
int
i
=
0
;
i
<
orgNames
.
size
();
i
++)
{
String
s
=
orgNames
.
get
(
i
);
if
(
i
==
0
)
{
resultString
+=
s
;
}
else
{
resultString
+=
"/"
+
s
;
}
}
record
.
setOrgNames
(
resultString
);
}
return
list
;
}
public
static
String
imageToBase64
(
String
imagePath
)
{
Long
t1
=
System
.
currentTimeMillis
();
ByteArrayOutputStream
data
=
new
ByteArrayOutputStream
();
try
{
// 创建URL
URL
url
=
new
URL
(
imagePath
);
byte
[]
by
=
new
byte
[
1024
];
// 创建链接
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setRequestMethod
(
"GET"
);
conn
.
setConnectTimeout
(
5000
);
InputStream
is
=
conn
.
getInputStream
();
// 将内容读取内存中
int
len
=
-
1
;
while
((
len
=
is
.
read
(
by
))
!=
-
1
)
{
data
.
write
(
by
,
0
,
len
);
}
// 关闭流
is
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
// 对字节数组Base64编码
Base64Encoder
encoder
=
new
Base64Encoder
();
String
encode
=
encoder
.
encode
(
data
.
toByteArray
());
Long
t2
=
System
.
currentTimeMillis
();
LOG
.
info
(
"图片转base64处理时间ms:"
+(
t2
-
t1
));
return
"data:image/png;base64,"
+
encode
;
}
@Override
public
Map
<
Long
,
Long
>
signNum
(
List
<
Long
>
siteIds
,
String
startDate
,
String
endDate
)
{
Map
<
Long
,
Long
>
map
=
new
HashMap
<
Long
,
Long
>();
List
<
SignNumVO
>
signNum
=
this
.
baseMapper
.
signNum
(
siteIds
,
startDate
,
endDate
);
for
(
SignNumVO
vo:
signNum
)
{
map
.
put
(
vo
.
getAccountId
(),
vo
.
getSignNum
());
}
return
map
;
}
}
calendar/src/main/java/com/yizhi/calendar/application/service/impl/CalendarServiceImpl.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
service
.
impl
;
import
com.yizhi.calendar.application.domain.Calendar
;
import
com.yizhi.calendar.application.mapper.CalendarMapper
;
import
com.yizhi.calendar.application.service.ICalendarService
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
org.springframework.stereotype.Service
;
/**
* <p>
* 日历打卡积分发放设置表 服务实现类
* </p>
*
* @author fulan123
* @since 2019-10-10
*/
@Service
public
class
CalendarServiceImpl
extends
ServiceImpl
<
CalendarMapper
,
Calendar
>
implements
ICalendarService
{
}
calendar/src/main/java/com/yizhi/calendar/application/task/CalendarAccountExportAsync.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
task
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
com.yizhi.core.application.context.TaskContext
;
import
com.yizhi.core.application.file.constant.FileConstant
;
import
com.yizhi.core.application.file.task.AbstractDefaultTask
;
import
com.yizhi.core.application.file.util.OssUpload
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.usermodel.XSSFCell
;
import
org.apache.poi.xssf.usermodel.XSSFCellStyle
;
import
org.apache.poi.xssf.usermodel.XSSFFont
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
com.yizhi.calendar.application.domain.CalendarRecord
;
import
com.yizhi.calendar.application.service.ICalendarRecordService
;
@Component
public
class
CalendarAccountExportAsync
extends
AbstractDefaultTask
<
String
,
Map
<
String
,
Object
>>
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CalendarAccountExportAsync
.
class
);
@Autowired
private
ICalendarRecordService
calendarRecordService
;
@Override
protected
String
execute
(
Map
<
String
,
Object
>
arg0
)
{
Long
accountId
=(
Long
)
arg0
.
get
(
"accountId"
);
Long
siteId
=(
Long
)
arg0
.
get
(
"siteId"
);
Long
companyId
=(
Long
)
arg0
.
get
(
"companyId"
);
Long
taskId
=(
Long
)
arg0
.
get
(
"taskId"
);
Date
submitTime
=(
Date
)
arg0
.
get
(
"submitTime"
);
String
serialNo
=(
String
)
arg0
.
get
(
"serialNo"
);
String
taskName
=(
String
)
arg0
.
get
(
"taskName"
);
String
startDate
=
(
String
)
arg0
.
get
(
"startDate"
);
String
endDate
=
(
String
)
arg0
.
get
(
"endDate"
);
Long
userId
=
(
Long
)
arg0
.
get
(
"userId"
);
String
accountName
=
(
String
)
arg0
.
get
(
"accountName"
);
/**
* 走异步任务
*/
TaskContext
taskContext
=
new
TaskContext
(
taskId
,
serialNo
,
taskName
,
accountId
,
submitTime
,
siteId
,
companyId
);
working
(
taskContext
);
String
upLoadUrl
=
null
;
String
requestPath
=
FileConstant
.
SAVE_PATH
;
File
fileDir
=
new
File
(
requestPath
);
if
(!
fileDir
.
exists
())
{
fileDir
.
mkdir
();
}
List
<
CalendarRecord
>
list
=
calendarRecordService
.
accountList
(
startDate
,
endDate
,
userId
,
companyId
,
siteId
);
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
ff
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
try
{
//excel生成过程: excel-->sheet-->row-->cell
// 第一步,创建一个Excel文件
XSSFWorkbook
wb
=
new
XSSFWorkbook
();
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
XSSFSheet
sheet
=
wb
.
createSheet
(
"打卡记录"
);
sheet
.
setDefaultColumnWidth
(
26
);
XSSFFont
font
=
wb
.
createFont
();
font
.
setFontName
(
"新宋体"
);
font
.
setFontHeightInPoints
((
short
)
16
);
font
.
setBold
(
true
);
XSSFCellStyle
style
=
wb
.
createCellStyle
();
style
.
setFont
(
font
);
style
.
setAlignment
(
HorizontalAlignment
.
LEFT
);
// 创建一个居中格式
style
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
XSSFRow
row
=
sheet
.
createRow
((
int
)
0
);
row
.
setHeightInPoints
((
float
)
20.25
);
// 合并单元格
CellRangeAddress
cra
=
new
CellRangeAddress
(
0
,
0
,
0
,
2
);
// 起始行, 终止行, 起始列, 终止列
sheet
.
addMergedRegion
(
cra
);
XSSFCell
cell
=
row
.
createCell
((
short
)
0
);
cell
.
setCellValue
(
accountName
+
"打卡记录表 统计日期:"
+
startDate
+
" 至 "
+
endDate
);
cell
.
setCellStyle
(
style
);
XSSFRow
row1
=
sheet
.
createRow
((
int
)
1
);
row1
.
setHeightInPoints
((
float
)
18.75
);
// 合并单元格
CellRangeAddress
cra1
=
new
CellRangeAddress
(
1
,
1
,
0
,
2
);
// 起始行, 终止行, 起始列, 终止列
sheet
.
addMergedRegion
(
cra1
);
XSSFCell
cell1
=
row1
.
createCell
((
short
)
0
);
cell1
.
setCellValue
(
"报表生成时间:"
+
ff
.
format
(
submitTime
));
XSSFFont
font1
=
wb
.
createFont
();
font1
.
setFontName
(
"新宋体"
);
font1
.
setFontHeightInPoints
((
short
)
14
);
font1
.
setBold
(
false
);
XSSFCellStyle
style1
=
wb
.
createCellStyle
();
style1
.
setFont
(
font1
);
style1
.
setAlignment
(
HorizontalAlignment
.
LEFT
);
// 创建一个居中格式
style1
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
cell1
.
setCellStyle
(
style1
);
XSSFRow
row2
=
sheet
.
createRow
((
int
)
2
);
XSSFFont
font2
=
wb
.
createFont
();
XSSFCellStyle
style2
=
wb
.
createCellStyle
();
font2
.
setFontName
(
"新宋体"
);
font2
.
setFontHeightInPoints
((
short
)
12
);
font2
.
setBold
(
true
);
style2
.
setFont
(
font2
);
style2
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
// 创建一个居中格式
style2
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
row2
.
setRowStyle
(
style2
);
row2
.
setHeightInPoints
((
float
)
14.25
);
row2
.
createCell
((
short
)
0
).
setCellValue
(
"打卡日期"
);
row2
.
getCell
(
0
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
1
).
setCellValue
(
"打卡时间"
);
row2
.
getCell
(
1
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
2
).
setCellValue
(
"获得积分"
);
row2
.
getCell
(
2
).
setCellStyle
(
style2
);
CalendarRecord
vo
=
new
CalendarRecord
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
XSSFFont
font3
=
wb
.
createFont
();
XSSFCellStyle
style3
=
wb
.
createCellStyle
();
font3
.
setBold
(
false
);
font3
.
setFontName
(
"宋体"
);
font3
.
setFontHeightInPoints
((
short
)
11
);
style3
.
setFont
(
font3
);
style3
.
setAlignment
(
HorizontalAlignment
.
LEFT
);
// 创建一个居中格式
style3
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
row
=
sheet
.
createRow
(
i
+
3
);
row
.
setRowStyle
(
style3
);
row
.
setHeightInPoints
((
float
)
13.5
);
// 第四步,创建单元格,并设置值
vo
=
list
.
get
(
i
);
if
(
vo
!=
null
&&
vo
.
getSignDate
()!=
null
)
{
row
.
createCell
((
short
)
0
).
setCellValue
(
vo
.
getSignDate
());
row
.
getCell
(
0
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getSignTime
()!=
null
)
{
row
.
createCell
((
short
)
1
).
setCellValue
(
vo
.
getSignTime
());
row
.
getCell
(
1
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getPoint
()!=
null
)
{
row
.
createCell
((
short
)
2
).
setCellValue
(
vo
.
getPoint
());
row
.
getCell
(
2
).
setCellStyle
(
style3
);
}
}
// 第五步,写入实体数据 实际应用中这些数据从数据库得到,
StringBuffer
fileNameSb
=
new
StringBuffer
().
append
(
accountName
+
"打卡记录表"
).
append
(
sf
.
format
(
submitTime
)).
append
(
".xlsx"
);
String
fileName
=
fileNameSb
.
toString
();
String
path
=
new
StringBuffer
().
append
(
requestPath
).
append
(
fileNameSb
).
toString
();
FileOutputStream
os
=
null
;
File
file
=
null
;
try
{
os
=
new
FileOutputStream
(
path
);
wb
.
write
(
os
);
//阿里云返回url
upLoadUrl
=
OssUpload
.
upload
(
path
,
fileName
);
file
=
new
File
(
path
);
success
(
taskContext
,
"成功"
,
upLoadUrl
);
}
catch
(
Exception
e1
)
{
logger
.
error
(
"写入数据到Excel的过程中或者上传到阿里云中发生错误"
,
e1
);
fail
(
taskContext
,
"写入数据到Excel的过程中或者上传到阿里云中发生错误"
+
e1
.
getMessage
());
}
finally
{
if
(
os
!=
null
)
{
os
.
close
();
}
if
(
wb
!=
null
)
{
wb
.
close
();
}
if
(
file
!=
null
)
{
file
.
delete
();
}
}
}
catch
(
Exception
e
)
{
logger
.
error
(
accountName
+
"打卡记录导出过程中发生错误,请查看日志"
,
e
);
fail
(
taskContext
,
accountName
+
"打卡记录导出过程中发生错误,请查看日志"
+
e
.
getMessage
());
}
return
upLoadUrl
;
}
}
calendar/src/main/java/com/yizhi/calendar/application/task/CalendarDetailExportAsync.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
task
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
com.yizhi.core.application.context.TaskContext
;
import
com.yizhi.core.application.file.constant.FileConstant
;
import
com.yizhi.core.application.file.task.AbstractDefaultTask
;
import
com.yizhi.core.application.file.util.OssUpload
;
import
com.yizhi.system.application.system.remote.AccountClient
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.usermodel.XSSFCell
;
import
org.apache.poi.xssf.usermodel.XSSFCellStyle
;
import
org.apache.poi.xssf.usermodel.XSSFFont
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
com.yizhi.calendar.application.service.ICalendarRecordService
;
import
com.yizhi.calendar.application.vo.CalendarDetailStatisticVO
;
@Component
public
class
CalendarDetailExportAsync
extends
AbstractDefaultTask
<
String
,
Map
<
String
,
Object
>>
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CalendarDetailExportAsync
.
class
);
@Autowired
private
ICalendarRecordService
calendarRecordService
;
@Autowired
private
AccountClient
accountClient
;
@Override
protected
String
execute
(
Map
<
String
,
Object
>
arg0
)
{
Long
accountId
=
(
Long
)
arg0
.
get
(
"accountId"
);
Long
siteId
=
(
Long
)
arg0
.
get
(
"siteId"
);
Long
companyId
=
(
Long
)
arg0
.
get
(
"companyId"
);
Long
taskId
=
(
Long
)
arg0
.
get
(
"taskId"
);
Date
submitTime
=
(
Date
)
arg0
.
get
(
"submitTime"
);
String
serialNo
=
(
String
)
arg0
.
get
(
"serialNo"
);
String
taskName
=
(
String
)
arg0
.
get
(
"taskName"
);
String
startDate
=
(
String
)
arg0
.
get
(
"startDate"
);
String
endDate
=
(
String
)
arg0
.
get
(
"endDate"
);
String
kwd
=
(
String
)
arg0
.
get
(
"kwd"
);
/**
* 走异步任务
*/
TaskContext
taskContext
=
new
TaskContext
(
taskId
,
serialNo
,
taskName
,
accountId
,
submitTime
,
siteId
,
companyId
);
working
(
taskContext
);
String
upLoadUrl
=
null
;
String
requestPath
=
FileConstant
.
SAVE_PATH
;
// String requestPath = "/Users/dingxiaowei/aaa";
File
fileDir
=
new
File
(
requestPath
);
if
(!
fileDir
.
exists
())
{
fileDir
.
mkdir
();
}
List
<
CalendarDetailStatisticVO
>
list
=
calendarRecordService
.
detailList
(
startDate
,
endDate
,
companyId
,
siteId
,
kwd
);
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
ff
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
try
{
//excel生成过程: excel-->sheet-->row-->cell
// 第一步,创建一个Excel文件
XSSFWorkbook
wb
=
new
XSSFWorkbook
();
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
XSSFSheet
sheet
=
wb
.
createSheet
(
"打卡记录"
);
sheet
.
setDefaultColumnWidth
(
14
);
XSSFFont
font
=
wb
.
createFont
();
font
.
setFontName
(
"新宋体"
);
font
.
setFontHeightInPoints
((
short
)
16
);
font
.
setBold
(
true
);
XSSFCellStyle
style
=
wb
.
createCellStyle
();
style
.
setFont
(
font
);
style
.
setAlignment
(
HorizontalAlignment
.
LEFT
);
style
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
XSSFRow
row
=
sheet
.
createRow
((
int
)
0
);
row
.
setHeightInPoints
((
float
)
20.25
);
// 合并单元格
CellRangeAddress
cra
=
new
CellRangeAddress
(
0
,
0
,
0
,
8
);
// 起始行, 终止行, 起始列, 终止列
sheet
.
addMergedRegion
(
cra
);
XSSFCell
cell
=
row
.
createCell
((
short
)
0
);
cell
.
setCellValue
(
"打卡记录表 统计日期:"
+
startDate
+
" 至 "
+
endDate
);
cell
.
setCellStyle
(
style
);
XSSFFont
font1
=
wb
.
createFont
();
font1
.
setFontName
(
"新宋体"
);
font1
.
setFontHeightInPoints
((
short
)
14
);
font1
.
setBold
(
false
);
XSSFCellStyle
style1
=
wb
.
createCellStyle
();
XSSFRow
row1
=
sheet
.
createRow
((
int
)
1
);
row1
.
setHeightInPoints
((
float
)
18.75
);
// 合并单元格
CellRangeAddress
cra1
=
new
CellRangeAddress
(
1
,
1
,
0
,
8
);
// 起始行, 终止行, 起始列, 终止列
sheet
.
addMergedRegion
(
cra1
);
XSSFCell
cell1
=
row1
.
createCell
((
short
)
0
);
cell1
.
setCellValue
(
"报表生成时间:"
+
ff
.
format
(
submitTime
));
style1
.
setAlignment
(
HorizontalAlignment
.
LEFT
);
style1
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
style1
.
setFont
(
font1
);
cell1
.
setCellStyle
(
style1
);
XSSFRow
row2
=
sheet
.
createRow
((
int
)
2
);
XSSFFont
font2
=
wb
.
createFont
();
font2
.
setFontName
(
"新宋体"
);
font2
.
setFontHeightInPoints
((
short
)
12
);
font2
.
setBold
(
true
);
XSSFCellStyle
style2
=
wb
.
createCellStyle
();
style2
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
style2
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
style2
.
setFont
(
font2
);
row2
.
setHeightInPoints
((
float
)
14.25
);
row2
.
createCell
((
short
)
0
).
setCellValue
(
"用户名"
);
row2
.
getCell
(
0
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
1
).
setCellValue
(
"姓名"
);
row2
.
getCell
(
1
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
2
).
setCellValue
(
"所在部门"
);
row2
.
getCell
(
2
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
3
).
setCellValue
(
"工号"
);
row2
.
getCell
(
3
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
4
).
setCellValue
(
"职位"
);
row2
.
getCell
(
4
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
5
).
setCellValue
(
"打卡日期"
);
row2
.
getCell
(
5
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
6
).
setCellValue
(
"打卡时间"
);
row2
.
getCell
(
6
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
7
).
setCellValue
(
"获得积分"
);
row2
.
getCell
(
7
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
8
).
setCellValue
(
"所在组织架构"
);
row2
.
getCell
(
8
).
setCellStyle
(
style2
);
CalendarDetailStatisticVO
vo
=
new
CalendarDetailStatisticVO
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
XSSFFont
font3
=
wb
.
createFont
();
font3
.
setBold
(
false
);
font3
.
setFontName
(
"宋体"
);
font3
.
setFontHeightInPoints
((
short
)
11
);
XSSFCellStyle
style3
=
wb
.
createCellStyle
();
style3
.
setFont
(
font3
);
style3
.
setAlignment
(
HorizontalAlignment
.
LEFT
);
// 创建一个居中格式
style3
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
row
=
sheet
.
createRow
(
i
+
3
);
row
.
setHeightInPoints
((
float
)
13.5
);
// 第四步,创建单元格,并设置值
vo
=
list
.
get
(
i
);
if
(
vo
!=
null
&&
vo
.
getName
()
!=
null
)
{
row
.
createCell
((
short
)
0
).
setCellValue
(
vo
.
getName
());
row
.
getCell
(
0
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getFullName
()
!=
null
)
{
row
.
createCell
((
short
)
1
).
setCellValue
(
vo
.
getFullName
());
row
.
getCell
(
1
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getOrgName
()
!=
null
)
{
row
.
createCell
((
short
)
2
).
setCellValue
(
vo
.
getOrgName
());
row
.
getCell
(
2
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getWorkNum
()
!=
null
)
{
row
.
createCell
((
short
)
3
).
setCellValue
(
vo
.
getWorkNum
());
row
.
getCell
(
3
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getPosition
()
!=
null
)
{
row
.
createCell
((
short
)
4
).
setCellValue
(
vo
.
getPosition
());
row
.
getCell
(
4
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getSignDate
()
!=
null
)
{
row
.
createCell
((
short
)
5
).
setCellValue
(
vo
.
getSignDate
());
row
.
getCell
(
5
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getSignTime
()
!=
null
)
{
row
.
createCell
((
short
)
6
).
setCellValue
(
vo
.
getSignTime
());
row
.
getCell
(
6
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getPoint
()
!=
null
)
{
row
.
createCell
((
short
)
7
).
setCellValue
(
vo
.
getPoint
());
row
.
getCell
(
7
).
setCellStyle
(
style3
);
}
if
(
StringUtils
.
isNotBlank
(
vo
.
getOrgNames
()))
{
row
.
createCell
((
short
)
8
).
setCellValue
(
vo
.
getOrgNames
());
}
else
{
row
.
createCell
((
short
)
8
).
setCellValue
(
"--"
);
}
}
// 第五步,写入实体数据 实际应用中这些数据从数据库得到,
StringBuffer
fileNameSb
=
new
StringBuffer
().
append
(
"打卡记录表"
).
append
(
sf
.
format
(
submitTime
)).
append
(
".xlsx"
);
String
fileName
=
fileNameSb
.
toString
();
String
path
=
new
StringBuffer
().
append
(
requestPath
).
append
(
fileNameSb
).
toString
();
FileOutputStream
os
=
null
;
File
file
=
null
;
try
{
os
=
new
FileOutputStream
(
path
);
wb
.
write
(
os
);
//阿里云返回url
upLoadUrl
=
OssUpload
.
upload
(
path
,
fileName
);
file
=
new
File
(
path
);
success
(
taskContext
,
"成功"
,
upLoadUrl
);
}
catch
(
Exception
e1
)
{
logger
.
error
(
"写入数据到Excel的过程中或者上传到阿里云中发生错误"
,
e1
);
fail
(
taskContext
,
"写入数据到Excel的过程中或者上传到阿里云中发生错误"
+
e1
.
getMessage
());
}
finally
{
if
(
os
!=
null
)
{
os
.
close
();
}
if
(
wb
!=
null
)
{
wb
.
close
();
}
if
(
file
!=
null
)
{
file
.
delete
();
}
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"打卡记录导出过程中发生错误,请查看日志"
,
e
);
fail
(
taskContext
,
"打卡记录导出过程中发生错误,请查看日志"
+
e
.
getMessage
());
}
return
upLoadUrl
;
}
}
calendar/src/main/java/com/yizhi/calendar/application/task/CalendarListExportAsync.java
0 → 100644
View file @
5fe2e4a6
package
com
.
yizhi
.
calendar
.
application
.
task
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
com.yizhi.core.application.context.TaskContext
;
import
com.yizhi.core.application.file.constant.FileConstant
;
import
com.yizhi.core.application.file.task.AbstractDefaultTask
;
import
com.yizhi.core.application.file.util.OssUpload
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.usermodel.XSSFCell
;
import
org.apache.poi.xssf.usermodel.XSSFCellStyle
;
import
org.apache.poi.xssf.usermodel.XSSFFont
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
com.yizhi.calendar.application.service.ICalendarRecordService
;
import
com.yizhi.calendar.application.vo.CalendarStatisticVO
;
@Component
public
class
CalendarListExportAsync
extends
AbstractDefaultTask
<
String
,
Map
<
String
,
Object
>>
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CalendarListExportAsync
.
class
);
@Autowired
private
ICalendarRecordService
calendarRecordService
;
@Override
protected
String
execute
(
Map
<
String
,
Object
>
arg0
)
{
Long
accountId
=(
Long
)
arg0
.
get
(
"accountId"
);
Long
siteId
=(
Long
)
arg0
.
get
(
"siteId"
);
Long
companyId
=(
Long
)
arg0
.
get
(
"companyId"
);
Long
taskId
=(
Long
)
arg0
.
get
(
"taskId"
);
Date
submitTime
=(
Date
)
arg0
.
get
(
"submitTime"
);
String
serialNo
=(
String
)
arg0
.
get
(
"serialNo"
);
String
taskName
=(
String
)
arg0
.
get
(
"taskName"
);
String
kwd
=
(
String
)
arg0
.
get
(
"kwd"
);
String
startDate
=
(
String
)
arg0
.
get
(
"startDate"
);
String
endDate
=
(
String
)
arg0
.
get
(
"endDate"
);
/**
* 走异步任务
*/
TaskContext
taskContext
=
new
TaskContext
(
taskId
,
serialNo
,
taskName
,
accountId
,
submitTime
,
siteId
,
companyId
);
working
(
taskContext
);
String
upLoadUrl
=
null
;
String
requestPath
=
FileConstant
.
SAVE_PATH
;
// String requestPath = "/Users/dingxiaowei/aaa";
File
fileDir
=
new
File
(
requestPath
);
if
(!
fileDir
.
exists
())
{
fileDir
.
mkdir
();
}
List
<
CalendarStatisticVO
>
list
=
calendarRecordService
.
list
(
startDate
,
endDate
,
kwd
,
companyId
,
siteId
);
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
ff
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
try
{
//excel生成过程: excel-->sheet-->row-->cell
// 第一步,创建一个Excel文件
XSSFWorkbook
wb
=
new
XSSFWorkbook
();
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
XSSFSheet
sheet
=
wb
.
createSheet
(
"打卡统计"
);
sheet
.
setDefaultColumnWidth
(
12
);
XSSFFont
font
=
wb
.
createFont
();
font
.
setFontName
(
"新宋体"
);
font
.
setFontHeightInPoints
((
short
)
16
);
font
.
setBold
(
true
);
XSSFCellStyle
style
=
wb
.
createCellStyle
();
style
.
setFont
(
font
);
style
.
setAlignment
(
HorizontalAlignment
.
LEFT
);
// 创建一个左对齐格式
style
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
XSSFRow
row
=
sheet
.
createRow
((
int
)
0
);
row
.
setHeightInPoints
((
float
)
20.25
);
// 合并单元格
CellRangeAddress
cra
=
new
CellRangeAddress
(
0
,
0
,
0
,
6
);
// 起始行, 终止行, 起始列, 终止列
sheet
.
addMergedRegion
(
cra
);
XSSFCell
cell
=
row
.
createCell
((
short
)
0
);
cell
.
setCellValue
(
"打卡统计表 统计日期:"
+
startDate
+
" 至 "
+
endDate
);
cell
.
setCellStyle
(
style
);
XSSFRow
row1
=
sheet
.
createRow
((
int
)
1
);
row1
.
setHeightInPoints
((
float
)
18.75
);
// 合并单元格
CellRangeAddress
cra1
=
new
CellRangeAddress
(
1
,
1
,
0
,
7
);
// 起始行, 终止行, 起始列, 终止列
sheet
.
addMergedRegion
(
cra1
);
XSSFCell
cell1
=
row1
.
createCell
((
short
)
0
);
cell1
.
setCellValue
(
"报表生成时间:"
+
ff
.
format
(
submitTime
));
XSSFCellStyle
style1
=
wb
.
createCellStyle
();
XSSFFont
font1
=
wb
.
createFont
();
font1
.
setFontName
(
"新宋体"
);
font1
.
setFontHeightInPoints
((
short
)
14
);
font1
.
setBold
(
false
);
style1
.
setFont
(
font1
);
style1
.
setAlignment
(
HorizontalAlignment
.
LEFT
);
style1
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
cell1
.
setCellStyle
(
style1
);
XSSFRow
row2
=
sheet
.
createRow
((
int
)
2
);
XSSFCellStyle
style2
=
wb
.
createCellStyle
();
XSSFFont
font2
=
wb
.
createFont
();
font2
.
setFontName
(
"新宋体"
);
font2
.
setFontHeightInPoints
((
short
)
12
);
font2
.
setBold
(
true
);
style2
.
setFont
(
font2
);
style2
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
style2
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
row2
.
setHeightInPoints
((
float
)
14.25
);
row2
.
createCell
((
short
)
0
).
setCellValue
(
"用户名"
);
row2
.
getCell
(
0
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
1
).
setCellValue
(
"姓名"
);
row2
.
getCell
(
1
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
2
).
setCellValue
(
"所在部门"
);
row2
.
getCell
(
2
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
3
).
setCellValue
(
"工号"
);
row2
.
getCell
(
3
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
4
).
setCellValue
(
"职位"
);
row2
.
getCell
(
4
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
5
).
setCellValue
(
"打卡次数"
);
row2
.
getCell
(
5
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
6
).
setCellValue
(
"获得积分"
);
row2
.
getCell
(
6
).
setCellStyle
(
style2
);
row2
.
createCell
((
short
)
7
).
setCellValue
(
"所在组织架构"
);
row2
.
getCell
(
7
).
setCellStyle
(
style2
);
CalendarStatisticVO
vo
=
new
CalendarStatisticVO
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
XSSFCellStyle
style3
=
wb
.
createCellStyle
();
XSSFFont
font3
=
wb
.
createFont
();
font3
.
setBold
(
false
);
font3
.
setFontName
(
"宋体"
);
font3
.
setFontHeightInPoints
((
short
)
11
);
style3
.
setFont
(
font3
);
style3
.
setAlignment
(
HorizontalAlignment
.
LEFT
);
// 创建一个居中格式
style3
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
row
=
sheet
.
createRow
(
i
+
3
);
row
.
setHeightInPoints
((
float
)
13.5
);
// 第四步,创建单元格,并设置值
vo
=
list
.
get
(
i
);
if
(
vo
!=
null
&&
vo
.
getName
()!=
null
)
{
row
.
createCell
((
short
)
0
).
setCellValue
(
vo
.
getName
());
row
.
getCell
(
0
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getFullName
()!=
null
)
{
row
.
createCell
((
short
)
1
).
setCellValue
(
vo
.
getFullName
());
row
.
getCell
(
1
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getOrgName
()!=
null
)
{
row
.
createCell
((
short
)
2
).
setCellValue
(
vo
.
getOrgName
());
row
.
getCell
(
2
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getWorkNum
()!=
null
)
{
row
.
createCell
((
short
)
3
).
setCellValue
(
vo
.
getWorkNum
());
row
.
getCell
(
3
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getPosition
()!=
null
)
{
row
.
createCell
((
short
)
4
).
setCellValue
(
vo
.
getPosition
());
row
.
getCell
(
4
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getCount
()!=
null
)
{
row
.
createCell
((
short
)
5
).
setCellValue
(
vo
.
getCount
());
row
.
getCell
(
5
).
setCellStyle
(
style3
);
}
if
(
vo
!=
null
&&
vo
.
getPoint
()!=
null
)
{
row
.
createCell
((
short
)
6
).
setCellValue
(
vo
.
getPoint
());
row
.
getCell
(
6
).
setCellStyle
(
style3
);
}
if
(
StringUtils
.
isNotBlank
(
vo
.
getOrgNames
()))
{
row
.
createCell
((
short
)
7
).
setCellValue
(
vo
.
getOrgNames
());
}
else
{
row
.
createCell
((
short
)
7
).
setCellValue
(
"--"
);
}
}
// 第五步,写入实体数据 实际应用中这些数据从数据库得到,
StringBuffer
fileNameSb
=
new
StringBuffer
().
append
(
"打卡统计表"
).
append
(
sf
.
format
(
submitTime
)).
append
(
".xlsx"
);
String
fileName
=
fileNameSb
.
toString
();
String
path
=
new
StringBuffer
().
append
(
requestPath
).
append
(
fileNameSb
).
toString
();
FileOutputStream
os
=
null
;
File
file
=
null
;
try
{
os
=
new
FileOutputStream
(
path
);
wb
.
write
(
os
);
//阿里云返回url
upLoadUrl
=
OssUpload
.
upload
(
path
,
fileName
);
file
=
new
File
(
path
);
success
(
taskContext
,
"成功"
,
upLoadUrl
);
}
catch
(
Exception
e1
)
{
logger
.
error
(
"写入数据到Excel的过程中或者上传到阿里云中发生错误"
,
e1
);
fail
(
taskContext
,
"写入数据到Excel的过程中或者上传到阿里云中发生错误"
+
e1
.
getMessage
());
}
finally
{
if
(
os
!=
null
)
{
os
.
close
();
}
if
(
wb
!=
null
)
{
wb
.
close
();
}
if
(
file
!=
null
)
{
file
.
delete
();
}
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"打卡统计导出过程中发生错误,请查看日志"
,
e
);
fail
(
taskContext
,
"打卡统计导出过程中发生错误,请查看日志"
+
e
.
getMessage
());
}
return
upLoadUrl
;
}
}
calendar/src/main/resources/bootstrap.properties
0 → 100644
View file @
5fe2e4a6
server.port
=
39001
spring.application.name
=
calendar
ACTIVE
=
${spring.profiles.active}
spring.profiles.active
=
dev
# nacos
spring.cloud.nacos.config.shared-dataids
=
common-${spring.profiles.active}.properties
spring.cloud.nacos.config.namespace
=
${spring.profiles.active}
spring.cloud.nacos.config.prefix
=
${spring.application.name}
spring.cloud.nacos.config.file-extension
=
properties
#spring.cloud.nacos.config.server-addr=192.168.0.203:8848
spring.cloud.nacos.config.server-addr
=
192.168.1.22:3333,192.168.1.22:4444,192.168.1.22:5555
pom.xml
0 → 100644
View file @
5fe2e4a6
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.yizhi
</groupId>
<artifactId>
wmy-parent
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<relativePath/>
</parent>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-calendar
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<modules>
<module>
calendar-api
</module>
<module>
calendar
</module>
</modules>
<name>
cloud-calendar
</name>
<description>
日历
</description>
<packaging>
pom
</packaging>
<repositories>
<repository>
<id>
wmy4.0
</id>
<url>
http://mvn.km365.pw/nexus/content/groups/wmy4.0-group/
</url>
<releases>
<enabled>
true
</enabled>
</releases>
<snapshots>
<enabled>
true
</enabled>
<updatePolicy>
always
</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
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