Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
44686417
Commit
44686417
authored
Jul 08, 2021
by
fupeiyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
值班导入导出
parent
e8470581
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
606 additions
and
9 deletions
+606
-9
DateUtils.java
...ava/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
+14
-1
DutyCarExcelDto.java
...join/amos/boot/module/common/api/dto/DutyCarExcelDto.java
+70
-0
DutyPersonExcelDto.java
...n/amos/boot/module/common/api/dto/DutyPersonExcelDto.java
+53
-0
FireExpertsDto.java
...ejoin/amos/boot/module/common/api/dto/FireExpertsDto.java
+0
-1
FirefightersExcelDto.java
...amos/boot/module/common/api/dto/FirefightersExcelDto.java
+1
-1
TitleEnum.java
.../yeejoin/amos/boot/module/common/api/enums/TitleEnum.java
+34
-0
ExcelStyleUtil.java
...oin/amos/boot/module/common/api/excel/ExcelStyleUtil.java
+183
-0
ExcelUtil.java
.../yeejoin/amos/boot/module/common/api/excel/ExcelUtil.java
+0
-0
ExcelEnums.java
...om/yeejoin/amos/boot/module/jcs/api/enums/ExcelEnums.java
+1
-0
DateUtils.java
.../yeejoin/amos/boot/module/common/biz/utils/DateUtils.java
+82
-0
ExcelController.java
.../amos/boot/module/jcs/biz/controller/ExcelController.java
+147
-6
DataSourcesImpl.java
...mos/boot/module/jcs/biz/service/impl/DataSourcesImpl.java
+21
-0
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
View file @
44686417
...
@@ -520,6 +520,18 @@ public class DateUtils {
...
@@ -520,6 +520,18 @@ public class DateUtils {
return
dateParse
(
dateFormat
(
date
,
MONTH_PATTERN
)
+
"-"
+
value
,
null
);
return
dateParse
(
dateFormat
(
date
,
MONTH_PATTERN
)
+
"-"
+
value
,
null
);
}
}
/**
* 当前日期毫秒.xls
*
* @return
*/
public
static
String
formatName
()
{
Calendar
calen
=
Calendar
.
getInstance
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMddhhmmss"
);
String
name
=
sdf
.
format
(
calen
.
getTime
());
return
name
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
/*System.out.println(dateTimeToDate(new Date()));
/*System.out.println(dateTimeToDate(new Date()));
System.out.println(dateParse("2017-02-04 14:58:20", null));
System.out.println(dateParse("2017-02-04 14:58:20", null));
...
@@ -531,7 +543,8 @@ public class DateUtils {
...
@@ -531,7 +543,8 @@ public class DateUtils {
/*
/*
System.out.println(getDaysOfMonth(dateParse("2017-02-01", null)));
System.out.println(getDaysOfMonth(dateParse("2017-02-01", null)));
System.out.println(getDaysOfYear(dateParse("2017-01-30", null)));*/
System.out.println(getDaysOfYear(dateParse("2017-01-30", null)));*/
//System.out.println(dateFormat(dateAddMonths(dateParse("2017-02-07", StrUtils.MONTH_PATTERN), -12), StrUtils.MONTH_PATTERN));
//System.out.println(dateFormat(dateAddMonths(dateParse("2017-02-07", StrUtils.MONTH_PATTERN), -12), StrUtils
// .MONTH_PATTERN));
/*System.out.println(dateFormat(maxDateOfMonth(dateParse("2016-02", "yyyy-MM")), null));
/*System.out.println(dateFormat(maxDateOfMonth(dateParse("2016-02", "yyyy-MM")), null));
System.out.println(dateFormat(minDateOfMonth(dateParse("2016-03-31", null)), null));*/
System.out.println(dateFormat(minDateOfMonth(dateParse("2016-03-31", null)), null));*/
}
}
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/dto/DutyCarExcelDto.java
0 → 100644
View file @
44686417
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
api
.
dto
;
import
com.alibaba.excel.annotation.ExcelIgnore
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint
;
import
com.yeejoin.amos.boot.module.common.api.excel.RoleNameExplicitConstraint
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 值班班次
*
* @author system_generator
* @date 2021-07-06
*/
@Data
@ApiModel
(
value
=
"DutyCarDto"
,
description
=
"值班车辆"
)
public
class
DutyCarExcelDto
implements
Serializable
{
@ExcelIgnore
private
static
final
long
serialVersionUID
=
1L
;
@ExcelProperty
(
value
=
"序号"
,
index
=
0
)
@ApiModelProperty
(
value
=
"序号"
)
private
Integer
number
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"消防队伍id"
)
private
String
teamId
;
@ExcelProperty
(
value
=
"消防队伍"
,
index
=
1
)
@ApiModelProperty
(
value
=
"消防队伍名称"
)
private
String
teamName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"用户id"
)
private
String
userId
;
@ExcelProperty
(
value
=
"姓名"
,
index
=
2
)
@ApiModelProperty
(
value
=
"用户名称"
)
private
String
userName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"岗位id"
)
private
String
postType
;
@ExcelProperty
(
value
=
"岗位"
,
index
=
3
)
@ApiModelProperty
(
value
=
"岗位名称"
)
private
String
postTypeName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"车辆id"
)
private
String
carId
;
@ExplicitConstraint
(
indexNum
=
4
,
sourceClass
=
RoleNameExplicitConstraint
.
class
,
method
=
"getCarList"
)
//固定下拉内容
@ExcelProperty
(
value
=
"车辆名称(车牌)"
,
index
=
4
)
@ApiModelProperty
(
value
=
"车辆名称"
)
private
String
carName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"值班信息"
)
private
List
<
DutyPersonShiftDto
>
dutyShift
=
new
ArrayList
<>();
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/dto/DutyPersonExcelDto.java
0 → 100644
View file @
44686417
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
api
.
dto
;
import
com.alibaba.excel.annotation.ExcelIgnore
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 值班班次
*
* @author system_generator
* @date 2021-07-06
*/
@Data
@ApiModel
(
value
=
"DutyPersonDto"
,
description
=
"值班人"
)
public
class
DutyPersonExcelDto
implements
Serializable
{
@ExcelIgnore
private
static
final
long
serialVersionUID
=
1L
;
@ExcelProperty
(
value
=
"序号"
,
index
=
0
)
@ApiModelProperty
(
value
=
"序号"
)
private
Integer
number
;
@ExcelProperty
(
value
=
"用户id"
,
index
=
1
)
@ApiModelProperty
(
value
=
"用户id"
)
private
String
userId
;
@ExcelProperty
(
value
=
"姓名"
,
index
=
2
)
@ApiModelProperty
(
value
=
"用户名称"
)
private
String
userName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"部门id"
)
private
String
deptId
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"部门名称"
)
private
String
deptName
;
@ApiModelProperty
(
value
=
"岗位id"
)
private
String
postType
;
@ApiModelProperty
(
value
=
"岗位名称"
)
private
String
postTypeName
;
@ApiModelProperty
(
value
=
"值班信息"
)
private
List
<
DutyPersonShiftDto
>
dutyShift
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/dto/FireExpertsDto.java
View file @
44686417
...
@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.common.api.dto;
...
@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.common.api.dto;
import
com.alibaba.excel.annotation.ExcelIgnore
;
import
com.alibaba.excel.annotation.ExcelIgnore
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
com.yeejoin.amos.boot.module.common.api.enums.ExcelSelectData
;
import
com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint
;
import
com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint
;
import
com.yeejoin.amos.boot.module.common.api.excel.RoleNameExplicitConstraint
;
import
com.yeejoin.amos.boot.module.common.api.excel.RoleNameExplicitConstraint
;
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/dto/FirefightersExcelDto.java
View file @
44686417
...
@@ -68,7 +68,7 @@ public class FirefightersExcelDto extends BaseDto {
...
@@ -68,7 +68,7 @@ public class FirefightersExcelDto extends BaseDto {
private
Date
birthdayTime
;
private
Date
birthdayTime
;
@ExplicitConstraint
(
indexNum
=
7
,
source
=
{
"男"
,
"女"
})
//固定下拉内容
@ExplicitConstraint
(
indexNum
=
7
,
source
=
{
"男"
,
"女"
})
//固定下拉内容
@ExcelProperty
(
value
=
"性别"
,
index
=
5
)
@ExcelProperty
(
value
=
"性别"
,
index
=
7
)
@ApiModelProperty
(
value
=
"性别"
)
@ApiModelProperty
(
value
=
"性别"
)
private
String
gender
;
private
String
gender
;
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/enums/TitleEnum.java
0 → 100644
View file @
44686417
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
api
.
enums
;
/**
* @Author: Xing Lei
* @Description:
* @Date: 2020/4/7 13:50
*/
public
enum
TitleEnum
{
NUMBER
(
"序号"
,
"number"
),
FIRE_TEAM
(
"消防队伍"
,
"teamName"
),
USER_ID
(
"用户ID"
,
"userId"
),
USER_NAME
(
"姓名"
,
"userName"
),
POST
(
"岗位"
,
"post"
),
CAR
(
"车辆"
,
"carName"
),
ARRANGE
(
"班次"
,
"arrange"
);
TitleEnum
(
String
name
,
String
key
)
{
this
.
name
=
name
;
this
.
key
=
key
;
}
private
String
name
;
private
String
key
;
public
String
getName
()
{
return
name
;
}
public
String
getKey
()
{
return
key
;
}
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/excel/ExcelStyleUtil.java
0 → 100644
View file @
44686417
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
api
.
excel
;
import
cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity
;
import
cn.afterturn.easypoi.excel.entity.params.ExcelForEachParams
;
import
cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler
;
import
org.apache.poi.ss.usermodel.*
;
/**
* @title: ExcelStyleUtil
* @Author fpy
* @Date: 2021/7/8 15:36
* @Version 1.0
*/
public
class
ExcelStyleUtil
implements
IExcelExportStyler
{
private
static
final
short
STRING_FORMAT
=
(
short
)
BuiltinFormats
.
getBuiltinFormat
(
"TEXT"
);
private
static
final
short
FONT_SIZE_TEN
=
10
;
private
static
final
short
FONT_SIZE_ELEVEN
=
11
;
private
static
final
short
FONT_SIZE_TWELVE
=
12
;
/**
* 大标题样式
*/
private
CellStyle
headerStyle
;
/**
* 每列标题样式
*/
private
CellStyle
titleStyle
;
/**
* 数据行样式
*/
private
CellStyle
styles
;
public
ExcelStyleUtil
(
Workbook
workbook
)
{
this
.
init
(
workbook
);
}
/**
* 初始化样式
*
* @param workbook
*/
private
void
init
(
Workbook
workbook
)
{
//this.headerStyle = initHeaderStyle(workbook);
this
.
titleStyle
=
initTitleStyle
(
workbook
);
this
.
styles
=
initStyles
(
workbook
);
}
/**
* 大标题样式
*
* @param color
* @return
*/
@Override
public
CellStyle
getHeaderStyle
(
short
color
)
{
return
headerStyle
;
}
/**
* 每列标题样式
*
* @param color
* @return
*/
@Override
public
CellStyle
getTitleStyle
(
short
color
)
{
return
titleStyle
;
}
/**
* 数据行样式
*
* @param parity 可以用来表示奇偶行
* @param entity 数据内容
* @return 样式
*/
@Override
public
CellStyle
getStyles
(
boolean
parity
,
ExcelExportEntity
entity
)
{
return
styles
;
}
/**
* 获取样式方法
*
* @param dataRow 数据行
* @param obj 对象
* @param data 数据
*/
@Override
public
CellStyle
getStyles
(
Cell
cell
,
int
dataRow
,
ExcelExportEntity
entity
,
Object
obj
,
Object
data
)
{
return
getStyles
(
true
,
entity
);
}
/**
* 模板使用的样式设置
*/
@Override
public
CellStyle
getTemplateStyles
(
boolean
isSingle
,
ExcelForEachParams
excelForEachParams
)
{
return
null
;
}
/**
* 初始化--大标题样式
*
* @param workbook
* @return
*/
private
CellStyle
initHeaderStyle
(
Workbook
workbook
)
{
CellStyle
style
=
getBaseCellStyle
(
workbook
);
style
.
setFont
(
getFont
(
workbook
,
FONT_SIZE_TWELVE
,
true
));
return
style
;
}
/**
* 初始化--每列标题样式
*
* @param workbook
* @return
*/
private
CellStyle
initTitleStyle
(
Workbook
workbook
)
{
CellStyle
style
=
getBaseCellStyle
(
workbook
);
//style.setFont(getFont(workbook, FONT_SIZE_ELEVEN, false));
//背景色
style
.
setFillForegroundColor
(
IndexedColors
.
PALE_BLUE
.
getIndex
());
style
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
return
style
;
}
/**
* 初始化--数据行样式
*
* @param workbook
* @return
*/
private
CellStyle
initStyles
(
Workbook
workbook
)
{
CellStyle
style
=
getBaseCellStyle
(
workbook
);
style
.
setFont
(
getFont
(
workbook
,
FONT_SIZE_TEN
,
false
));
style
.
setDataFormat
(
STRING_FORMAT
);
return
style
;
}
/**
* 基础样式
*
* @return
*/
private
CellStyle
getBaseCellStyle
(
Workbook
workbook
)
{
CellStyle
style
=
workbook
.
createCellStyle
();
//下边框
style
.
setBorderBottom
(
BorderStyle
.
THIN
);
//左边框
style
.
setBorderLeft
(
BorderStyle
.
THIN
);
//上边框
style
.
setBorderTop
(
BorderStyle
.
THIN
);
//右边框
style
.
setBorderRight
(
BorderStyle
.
THIN
);
//水平居中
style
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
//上下居中
style
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
//设置自动换行
style
.
setWrapText
(
true
);
return
style
;
}
/**
* 字体样式
*
* @param size 字体大小
* @param isBold 是否加粗
* @return
*/
private
Font
getFont
(
Workbook
workbook
,
short
size
,
boolean
isBold
)
{
Font
font
=
workbook
.
createFont
();
//字体样式
font
.
setFontName
(
"宋体"
);
//是否加粗
font
.
setBold
(
isBold
);
//字体大小
font
.
setFontHeightInPoints
(
size
);
return
font
;
}
}
\ No newline at end of file
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/excel/ExcelUtil.java
View file @
44686417
This diff is collapsed.
Click to expand it.
amos-boot-module/amos-boot-module-api/amos-boot-module-jcs-api/src/main/java/com/yeejoin/amos/boot/module/jcs/api/enums/ExcelEnums.java
View file @
44686417
...
@@ -11,4 +11,5 @@ public class ExcelEnums {
...
@@ -11,4 +11,5 @@ public class ExcelEnums {
public
static
final
String
XFDW
=
"XFDW"
;
//("XFDW","消防队伍")
public
static
final
String
XFDW
=
"XFDW"
;
//("XFDW","消防队伍")
public
static
final
String
WXXFZ
=
"WXXFZ"
;
//("WXXFZ","微型消防站")
public
static
final
String
WXXFZ
=
"WXXFZ"
;
//("WXXFZ","微型消防站")
public
static
final
String
XFRY
=
"XFRY"
;
//("XFRY","消防人员")
public
static
final
String
XFRY
=
"XFRY"
;
//("XFRY","消防人员")
public
static
final
String
CLZQ
=
"CLZQ"
;
//("CLZQ","车辆执勤")
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/utils/DateUtils.java
0 → 100644
View file @
44686417
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
biz
.
utils
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* @title: DateUtils
* @Author fpy
* @Date: 2021/7/8 14:58
* @Version 1.0
*/
public
class
DateUtils
{
private
static
final
SimpleDateFormat
shortSdf
=
new
SimpleDateFormat
(
"yyyy/M/d"
);
private
static
final
Calendar
calendar
=
Calendar
.
getInstance
();
/**
* 获取某月的日期List
*
* @param yearParam
* @param monthParam
* @return
*/
public
static
List
<
String
>
getDayByMonth
(
int
yearParam
,
int
monthParam
)
{
List
list
=
new
ArrayList
();
Calendar
aCalendar
=
Calendar
.
getInstance
(
Locale
.
CHINA
);
aCalendar
.
set
(
yearParam
,
monthParam
-
1
,
1
);
int
year
=
aCalendar
.
get
(
Calendar
.
YEAR
);
//年份
int
month
=
aCalendar
.
get
(
Calendar
.
MONTH
)
+
1
;
//月份
int
day
=
aCalendar
.
getActualMaximum
(
Calendar
.
DATE
);
for
(
int
i
=
1
;
i
<=
day
;
i
++)
{
list
.
add
(
year
+
"/"
+
month
+
"/"
+
i
);
}
return
list
;
}
/**
* 获取某月的日期List
*
* @param dateStr
* @return
*/
public
static
List
<
Date
>
getDayByMonth
(
String
dateStr
)
{
List
list
=
new
ArrayList
();
Date
date
=
null
;
try
{
date
=
shortSdf
.
parse
(
dateStr
);
calendar
.
setTime
(
date
);
int
month
=
calendar
.
get
(
Calendar
.
MONTH
)
+
1
;
//月份
int
year
=
calendar
.
get
(
Calendar
.
YEAR
);
//年份
int
day
=
calendar
.
getActualMaximum
(
Calendar
.
DATE
);
for
(
int
i
=
1
;
i
<=
day
;
i
++)
{
list
.
add
(
year
+
"/"
+
month
+
"/"
+
i
);
}
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
list
;
}
/**
* 日期返回Date类型
*
* @param dateStr
* @return
*/
public
static
int
strToDateShort
(
String
dateStr
)
{
try
{
Date
date
=
shortSdf
.
parse
(
dateStr
);
calendar
.
setTime
(
date
);
int
month
=
calendar
.
get
(
Calendar
.
MONTH
)
+
1
;
return
month
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
0
;
}
}
\ No newline at end of file
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/controller/ExcelController.java
View file @
44686417
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jcs
.
biz
.
controller
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jcs
.
biz
.
controller
;
import
java.util.ArrayList
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
com.alibaba.excel.support.ExcelTypeEnum
;
import
com.yeejoin.amos.boot.biz.common.feign.AmosFeignService
;
import
com.yeejoin.amos.boot.biz.common.utils.MenuFrom
;
import
com.yeejoin.amos.boot.module.common.api.dto.*
;
import
com.yeejoin.amos.boot.module.common.api.dto.*
;
import
com.yeejoin.amos.boot.module.common.api.entity.*
;
import
com.yeejoin.amos.boot.module.common.api.entity.*
;
import
com.yeejoin.amos.boot.module.common.api.enums.TitleEnum
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.*
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.*
;
import
com.yeejoin.amos.boot.module.common.biz.utils.DateUtils
;
import
com.yeejoin.amos.boot.module.jcs.api.entity.Aircraft
;
import
com.yeejoin.amos.boot.module.jcs.api.entity.Aircraft
;
import
com.yeejoin.amos.boot.module.jcs.biz.service.impl.EquipmentServiceImpl
;
import
com.yeejoin.amos.boot.module.jcs.biz.service.impl.FireTeamServiceImpl
;
import
com.yeejoin.amos.boot.module.jcs.biz.service.impl.FireTeamServiceImpl
;
import
org.apache.poi.hssf.usermodel.HSSFSheet
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
...
@@ -57,6 +68,16 @@ public class ExcelController extends BaseController {
...
@@ -57,6 +68,16 @@ public class ExcelController extends BaseController {
FireStationServiceImpl
fireStationService
;
FireStationServiceImpl
fireStationService
;
@Autowired
@Autowired
FirefightersServiceImpl
firefightersService
;
FirefightersServiceImpl
firefightersService
;
@Autowired
DutyCarServiceImpl
dutyCarService
;
@Autowired
AmosFeignService
amosFeignService
;
@Autowired
EquipmentServiceImpl
equipmentService
;
@Autowired
DutyShiftServiceImpl
dutyShiftService
;
@Autowired
DutyCommonServiceImpl
dutyCommonServiceImpl
;
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
...
@@ -151,6 +172,10 @@ public class ExcelController extends BaseController {
...
@@ -151,6 +172,10 @@ public class ExcelController extends BaseController {
case
ExcelEnums
.
XFRY
:
case
ExcelEnums
.
XFRY
:
excelImportFirefighters
(
multipartFile
);
excelImportFirefighters
(
multipartFile
);
break
;
break
;
case
ExcelEnums
.
CLZQ
:
excelImportDutyCar
(
multipartFile
);
break
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -158,6 +183,82 @@ public class ExcelController extends BaseController {
...
@@ -158,6 +183,82 @@ public class ExcelController extends BaseController {
}
}
}
}
private
void
excelImportDutyCar
(
MultipartFile
multipartFile
)
throws
Exception
{
String
fileName
=
multipartFile
.
getOriginalFilename
();
if
(
fileName
==
null
)
{
throw
new
Exception
(
"文件不存在!"
);
}
if
(!
fileName
.
toLowerCase
().
endsWith
(
ExcelTypeEnum
.
XLS
.
getValue
())
&&
!
fileName
.
toLowerCase
().
endsWith
(
ExcelTypeEnum
.
XLSX
.
getValue
()))
{
throw
new
Exception
(
"文件类型异常!"
);
}
InputStream
input
=
multipartFile
.
getInputStream
();
HSSFWorkbook
xssfWorkbook
=
new
HSSFWorkbook
(
input
);
HSSFSheet
sheet
=
xssfWorkbook
.
getSheetAt
(
0
);
List
<
Map
<
String
,
Object
>>
dataList
=
new
ArrayList
<>();
if
(
sheet
!=
null
)
{
//获取表头月份
String
dateStr
=
""
;
Row
titleRow
=
sheet
.
getRow
(
0
);
Cell
monthCell
=
titleRow
.
getCell
(
5
);
dateStr
=
monthCell
==
null
?
""
:
monthCell
.
toString
();
List
<
Date
>
dayByMonth
=
DateUtils
.
getDayByMonth
(
dateStr
);
initDutyCarData
(
sheet
,
dataList
,
dayByMonth
);
}
dutyCommonServiceImpl
.
saveImportData
(
dataList
);
}
private
void
initDutyCarData
(
HSSFSheet
sheet
,
List
<
Map
<
String
,
Object
>>
dataList
,
List
<
Date
>
dayByMonth
)
{
//遍历行,i = 1,从第二行开始,第一行是表头跳过。
for
(
int
i
=
1
;
i
<
sheet
.
getPhysicalNumberOfRows
();
i
++)
{
DutyCarDto
dutyCarDto
=
new
DutyCarDto
();
//row是一行数据,row.getCell(i),代表拿到这一行,第i列数据
Row
row
=
sheet
.
getRow
(
i
);
if
(
row
==
null
)
{
continue
;
}
Cell
cell
=
null
;
cell
=
row
.
getCell
(
1
);
if
(
cell
!=
null
)
{
String
[]
split
=
cell
.
toString
().
split
(
"@"
);
dutyCarDto
.
setTeamName
(
split
[
0
]);
dutyCarDto
.
setTeamId
(
split
[
1
]);
}
cell
=
row
.
getCell
(
2
);
if
(
cell
!=
null
)
{
String
[]
split
=
cell
.
toString
().
split
(
"@"
);
dutyCarDto
.
setUserName
(
split
[
0
]);
dutyCarDto
.
setUserId
(
split
[
1
]);
}
cell
=
row
.
getCell
(
3
);
if
(
cell
!=
null
)
{
String
[]
split
=
cell
.
toString
().
split
(
"@"
);
dutyCarDto
.
setPostTypeName
(
split
[
0
]);
dutyCarDto
.
setPostType
(
split
[
1
]);
}
cell
=
row
.
getCell
(
4
);
if
(
cell
!=
null
)
{
String
[]
split
=
cell
.
toString
().
split
(
"@"
);
dutyCarDto
.
setCarName
(
split
[
0
]);
dutyCarDto
.
setCarId
(
split
[
1
]);
}
List
<
DutyPersonShiftDto
>
dutyShift
=
dutyCarDto
.
getDutyShift
();
for
(
int
j
=
0
;
j
<
dayByMonth
.
size
();
j
++)
{
cell
=
row
.
getCell
(
4
+
j
);
String
dutyType
=
cell
==
null
?
""
:
cell
.
toString
();
if
(!
StringUtils
.
isEmpty
(
dutyType
))
{
DutyPersonShiftDto
dutyPersonShiftDto
=
new
DutyPersonShiftDto
();
dutyPersonShiftDto
.
setDutyDate
(
dayByMonth
.
get
(
j
));
dutyPersonShiftDto
.
setShiftId
(
Long
.
valueOf
(
dutyType
.
split
(
"@"
)[
1
]));
dutyShift
.
add
(
dutyPersonShiftDto
);
}
}
Map
<
String
,
Object
>
dutyCarDtoMap
=
Bean
.
BeantoMap
(
dutyCarDto
);
dataList
.
add
(
dutyCarDtoMap
);
}
}
private
void
excelImportFirefighters
(
MultipartFile
multipartFile
)
throws
Exception
{
private
void
excelImportFirefighters
(
MultipartFile
multipartFile
)
throws
Exception
{
List
<
FirefightersExcelDto
>
excelDtoList
=
ExcelUtil
.
readFirstSheetExcel
(
multipartFile
,
List
<
FirefightersExcelDto
>
excelDtoList
=
ExcelUtil
.
readFirstSheetExcel
(
multipartFile
,
FirefightersExcelDto
.
class
,
1
);
FirefightersExcelDto
.
class
,
1
);
...
@@ -390,5 +491,45 @@ public class ExcelController extends BaseController {
...
@@ -390,5 +491,45 @@ public class ExcelController extends BaseController {
fireExpertsServiceImpl
.
saveBatch
(
excelEntityList
);
fireExpertsServiceImpl
.
saveBatch
(
excelEntityList
);
}
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"导出值班模板"
,
notes
=
"导出值班模板"
)
@GetMapping
(
value
=
"/duty_car_template/{year}/{month}"
)
public
void
dutyCarTemplate
(
HttpServletResponse
response
,
@PathVariable
(
"year"
)
int
year
,
@PathVariable
(
"month"
)
int
month
,
ExcelDto
excelDto
,
@RequestParam
(
value
=
"orgCode"
,
required
=
false
)
String
orgCode
)
{
try
{
List
<
Map
<
String
,
Object
>>
contentList
=
new
ArrayList
<>();
// 根据id列表获取队伍下的人
List
<
DutyCarDto
>
orgTeam
=
new
ArrayList
<>();
if
(!
orgTeam
.
isEmpty
())
{
AtomicInteger
row
=
new
AtomicInteger
(
1
);
orgTeam
.
forEach
(
o
->
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
TitleEnum
.
NUMBER
.
getKey
(),
""
+
(
row
.
getAndIncrement
()));
map
.
put
(
TitleEnum
.
FIRE_TEAM
.
getKey
(),
o
.
getTeamName
());
map
.
put
(
TitleEnum
.
USER_NAME
.
getKey
(),
o
.
getUserName
());
map
.
put
(
TitleEnum
.
POST
.
getKey
(),
o
.
getPostTypeName
());
contentList
.
add
(
map
);
});
}
// 获取日期
List
<
String
>
dayByMonth
=
DateUtils
.
getDayByMonth
(
year
,
month
);
// 获取排班类型
String
[]
dutyNameList
=
getDutyNameList
();
ExcelUtil
.
createDutyTemplate
(
response
,
excelDto
.
getFileName
(),
excelDto
.
getSheetName
(),
contentList
,
DutyCarExcelDto
.
class
,
dayByMonth
,
dutyNameList
,
dataSourcesImpl
,
true
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"系统异常!"
);
}
}
private
String
[]
getDutyNameList
()
{
List
<
String
>
dutyShiftList
=
new
ArrayList
<>();
List
<
DutyShiftDto
>
dutyShiftDtoList
=
dutyShiftService
.
queryForDutyShiftList
();
dutyShiftDtoList
.
forEach
(
item
->
dutyShiftList
.
add
(
item
.
getName
()
+
"@"
+
item
.
getSequenceNbr
()));
String
[]
dutyNameList
=
dutyShiftList
.
toArray
(
new
String
[
dutyShiftList
.
size
()]);
return
dutyNameList
;
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/service/impl/DataSourcesImpl.java
View file @
44686417
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.google.common.collect.Lists
;
import
com.yeejoin.amos.boot.biz.common.utils.MenuFrom
;
import
com.yeejoin.amos.boot.biz.common.utils.MenuFrom
;
import
com.yeejoin.amos.boot.module.common.api.dto.FireTeamCardDto
;
import
com.yeejoin.amos.boot.module.common.api.dto.FireTeamCardDto
;
import
com.yeejoin.amos.boot.module.common.api.dto.FireTeamListDto
;
import
com.yeejoin.amos.boot.module.common.api.dto.FireTeamListDto
;
...
@@ -16,16 +17,19 @@ import com.yeejoin.amos.boot.module.common.api.excel.DataSources;
...
@@ -16,16 +17,19 @@ import com.yeejoin.amos.boot.module.common.api.excel.DataSources;
import
com.yeejoin.amos.boot.module.common.api.mapper.DataDictionaryMapper
;
import
com.yeejoin.amos.boot.module.common.api.mapper.DataDictionaryMapper
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.FirefightersServiceImpl
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.FirefightersServiceImpl
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl
;
import
com.yeejoin.amos.boot.module.jcs.api.feign.EquipFeignClient
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.*
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Service
@Service
...
@@ -41,6 +45,8 @@ public class DataSourcesImpl implements DataSources {
...
@@ -41,6 +45,8 @@ public class DataSourcesImpl implements DataSources {
FirefightersServiceImpl
firefightersService
;
FirefightersServiceImpl
firefightersService
;
@Autowired
@Autowired
FireTeamServiceImpl
fireTeamService
;
FireTeamServiceImpl
fireTeamService
;
@Autowired
EquipFeignClient
equipFeignClient
;
@Autowired
@Autowired
...
@@ -94,11 +100,26 @@ public class DataSourcesImpl implements DataSources {
...
@@ -94,11 +100,26 @@ public class DataSourcesImpl implements DataSources {
break
;
break
;
case
"getMaritalStatus"
:
case
"getMaritalStatus"
:
str
=
ExcelSelectData
.
MARITAL_STATUS
;
str
=
ExcelSelectData
.
MARITAL_STATUS
;
break
;
case
"getCarList"
:
str
=
getCarList
();
break
;
}
}
}
}
return
str
;
return
str
;
}
}
private
String
[]
getCarList
()
{
ResponseModel
<
Object
>
response
=
equipFeignClient
.
getFireCarListAll
();
List
<
Map
<
String
,
Object
>>
carList
=
(
List
<
Map
<
String
,
Object
>>)
response
.
getResult
();
List
<
String
>
carNameList
=
Lists
.
newArrayList
();
carList
.
forEach
(
car
->
{
carNameList
.
add
(
car
.
get
(
"name"
)
+
"("
+
car
.
get
(
"carNum"
)
+
")"
+
"@"
+
car
.
get
(
"id"
));
});
String
[]
str
=
carNameList
.
toArray
(
new
String
[
carNameList
.
size
()]);
return
str
;
}
private
String
[]
getFireTeam
()
{
private
String
[]
getFireTeam
()
{
Page
<
FireTeamCardDto
>
pageBean
=
new
Page
<>(
1
,
Integer
.
MAX_VALUE
);
Page
<
FireTeamCardDto
>
pageBean
=
new
Page
<>(
1
,
Integer
.
MAX_VALUE
);
IPage
<
FireTeamCardDto
>
fireTeamCardDtoIPage
=
fireTeamService
.
listFireTeamByPage
(
pageBean
,
IPage
<
FireTeamCardDto
>
fireTeamCardDtoIPage
=
fireTeamService
.
listFireTeamByPage
(
pageBean
,
...
...
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