Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-zx-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Jobs
Commits
Open sidebar
项目统一框架
一体化_户用光伏项目代码
amos-boot-zx-biz
Commits
3122b373
Commit
3122b373
authored
Jul 12, 2021
by
fupeiyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
值班导入导出
parent
ddfa99c0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
180 additions
and
124 deletions
+180
-124
DateUtils.java
...ava/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
+26
-0
DutyPersonExcelDto.java
...n/amos/boot/module/common/api/dto/DutyPersonExcelDto.java
+6
-4
ExcelUtil.java
.../yeejoin/amos/boot/module/common/api/excel/ExcelUtil.java
+0
-1
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
+0
-94
ExcelController.java
.../amos/boot/module/jcs/biz/controller/ExcelController.java
+147
-25
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
View file @
3122b373
...
@@ -618,4 +618,30 @@ public class DateUtils {
...
@@ -618,4 +618,30 @@ public class DateUtils {
String
name
=
sdf
.
format
(
calen
.
getTime
());
String
name
=
sdf
.
format
(
calen
.
getTime
());
return
name
;
return
name
;
}
}
/**
* 获取某月的日期List
*
* @param dateStr
* @return
*/
public
static
List
<
Date
>
getDayByMonth
(
String
dateStr
)
{
List
<
Date
>
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
++)
{
String
source
=
year
+
"-"
+
month
+
"-"
+
i
;
list
.
add
(
shortSdf
.
parse
(
source
));
}
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
list
;
}
}
}
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
View file @
3122b373
...
@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.common.api.dto;
...
@@ -2,6 +2,8 @@ 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.module.common.api.excel.ExplicitConstraint
;
import
com.yeejoin.amos.boot.module.common.api.excel.RoleNameExplicitConstraint
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -26,7 +28,7 @@ public class DutyPersonExcelDto implements Serializable {
...
@@ -26,7 +28,7 @@ public class DutyPersonExcelDto implements Serializable {
@ApiModelProperty
(
value
=
"序号"
)
@ApiModelProperty
(
value
=
"序号"
)
private
Integer
number
;
private
Integer
number
;
@ExcelProperty
(
value
=
"用户
id
"
,
index
=
1
)
@ExcelProperty
(
value
=
"用户
ID
"
,
index
=
1
)
@ApiModelProperty
(
value
=
"用户id"
)
@ApiModelProperty
(
value
=
"用户id"
)
private
String
userId
;
private
String
userId
;
...
@@ -42,12 +44,12 @@ public class DutyPersonExcelDto implements Serializable {
...
@@ -42,12 +44,12 @@ public class DutyPersonExcelDto implements Serializable {
@ApiModelProperty
(
value
=
"部门名称"
)
@ApiModelProperty
(
value
=
"部门名称"
)
private
String
deptName
;
private
String
deptName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"岗位id"
)
@ApiModelProperty
(
value
=
"岗位id"
)
private
String
postType
;
private
String
postType
;
@ExplicitConstraint
(
type
=
"DUTY_POST_TYPE"
,
indexNum
=
3
,
sourceClass
=
RoleNameExplicitConstraint
.
class
)
//动态下拉内容
@ExcelProperty
(
value
=
"岗位"
,
index
=
3
)
@ApiModelProperty
(
value
=
"岗位名称"
)
@ApiModelProperty
(
value
=
"岗位名称"
)
private
String
postTypeName
;
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/excel/ExcelUtil.java
View file @
3122b373
...
@@ -121,7 +121,6 @@ public class ExcelUtil {
...
@@ -121,7 +121,6 @@ public class ExcelUtil {
}
}
}
}
ExcelWriterSheetBuilder
excelWriterSheetBuilder
=
EasyExcel
.
write
(
getOutputStream
(
fileName
,
response
,
ExcelWriterSheetBuilder
excelWriterSheetBuilder
=
EasyExcel
.
write
(
getOutputStream
(
fileName
,
response
,
ExcelTypeEnum
.
XLSX
)).
head
(
dutyCarTitleList
).
excelType
(
ExcelTypeEnum
.
XLSX
)
ExcelTypeEnum
.
XLSX
)).
head
(
dutyCarTitleList
).
excelType
(
ExcelTypeEnum
.
XLSX
)
.
sheet
(
sheetName
).
registerWriteHandler
(
new
TemplateCellWriteHandlerDate
(
explicitListConstraintMap
))
.
sheet
(
sheetName
).
registerWriteHandler
(
new
TemplateCellWriteHandlerDate
(
explicitListConstraintMap
))
...
...
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 @
3122b373
...
@@ -12,4 +12,5 @@ public class ExcelEnums {
...
@@ -12,4 +12,5 @@ public class ExcelEnums {
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","车辆执勤")
public
static
final
String
CLZQ
=
"CLZQ"
;
//("CLZQ","车辆执勤")
public
static
final
String
RYZB
=
"RYZB"
;
//("RYZB","人员值班")
}
}
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
deleted
100644 → 0
View file @
ddfa99c0
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-MM-dd"
);
public
static
final
String
DATE_PATTERN
=
"yyyy-MM-dd"
;
private
static
final
Calendar
calendar
=
Calendar
.
getInstance
();
public
static
final
String
DATE_TIME_PATTERN
=
"yyyy-MM-dd HH:mm:ss"
;
/**
* 获取某月的日期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
;
}
public
static
Date
getDate
(
String
dateStr
)
{
try
{
Date
date
=
shortSdf
.
parse
(
dateStr
);
return
date
;
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
\ 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 @
3122b373
...
@@ -8,20 +8,18 @@ import java.util.concurrent.atomic.AtomicInteger;
...
@@ -8,20 +8,18 @@ import java.util.concurrent.atomic.AtomicInteger;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.ExcelReader
;
import
com.alibaba.excel.support.ExcelTypeEnum
;
import
com.alibaba.excel.support.ExcelTypeEnum
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.yeejoin.amos.boot.biz.common.feign.AmosFeignService
;
import
com.yeejoin.amos.boot.biz.common.feign.AmosFeignService
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
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.biz.service.IDutyPersonService
;
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.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.commons.beanutils.ConvertUtils
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
...
@@ -86,6 +84,10 @@ public class ExcelController extends BaseController {
...
@@ -86,6 +84,10 @@ public class ExcelController extends BaseController {
DutyPersonServiceImpl
dutyPersonService
;
DutyPersonServiceImpl
dutyPersonService
;
@Autowired
@Autowired
DutyPersonShiftServiceImpl
dutyPersonShiftService
;
DutyPersonShiftServiceImpl
dutyPersonShiftService
;
@Autowired
OrgUsrServiceImpl
orgUsrService
;
@Autowired
IDutyPersonService
iDutyPersonService
;
private
static
final
String
NOT_DUTY
=
"休"
;
private
static
final
String
NOT_DUTY
=
"休"
;
...
@@ -183,8 +185,10 @@ public class ExcelController extends BaseController {
...
@@ -183,8 +185,10 @@ public class ExcelController extends BaseController {
excelImportFirefighters
(
multipartFile
);
excelImportFirefighters
(
multipartFile
);
break
;
break
;
case
ExcelEnums
.
CLZQ
:
case
ExcelEnums
.
CLZQ
:
excelImportDuty
Car
(
multipartFile
);
excelImportDuty
Person
(
multipartFile
,
ExcelEnums
.
CLZQ
);
break
;
break
;
case
ExcelEnums
.
RYZB
:
excelImportDutyPerson
(
multipartFile
,
ExcelEnums
.
RYZB
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -192,7 +196,7 @@ public class ExcelController extends BaseController {
...
@@ -192,7 +196,7 @@ public class ExcelController extends BaseController {
}
}
}
}
private
void
excelImportDuty
Car
(
MultipartFile
multipartFil
e
)
throws
Exception
{
private
void
excelImportDuty
Person
(
MultipartFile
multipartFile
,
String
dutyTyp
e
)
throws
Exception
{
String
fileName
=
multipartFile
.
getOriginalFilename
();
String
fileName
=
multipartFile
.
getOriginalFilename
();
if
(
fileName
==
null
)
{
if
(
fileName
==
null
)
{
...
@@ -207,16 +211,59 @@ public class ExcelController extends BaseController {
...
@@ -207,16 +211,59 @@ public class ExcelController extends BaseController {
List
<
Map
<
String
,
Object
>>
dataList
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
dataList
=
new
ArrayList
<>();
if
(
sheet
!=
null
)
{
if
(
sheet
!=
null
)
{
//获取表头月份
//获取表头月份
String
dateStr
=
""
;
Row
titleRow
=
sheet
.
getRow
(
0
);
Row
titleRow
=
sheet
.
getRow
(
0
);
Cell
monthCell
=
titleRow
.
getCell
(
5
);
Cell
monthCell
=
titleRow
.
getCell
(
5
);
dateStr
=
monthCell
==
null
?
""
:
monthCell
.
toString
();
String
dateStr
=
monthCell
==
null
?
""
:
monthCell
.
toString
();
List
<
Date
>
dayByMonth
=
DateUtils
.
getDayByMonth
(
dateStr
);
List
<
Date
>
dayByMonth
=
DateUtils
.
getDayByMonth
(
dateStr
);
if
(
ExcelEnums
.
CLZQ
.
equals
(
dutyType
))
{
initDutyCarData
(
sheet
,
dataList
,
dayByMonth
);
dutyCarService
.
saveImportData
(
dataList
);
}
else
if
(
ExcelEnums
.
RYZB
.
equals
(
dutyType
))
{
initDutyPersonData
(
sheet
,
dataList
,
dayByMonth
);
dutyPersonService
.
saveImportData
(
dataList
);
}
}
}
initDutyCarData
(
sheet
,
dataList
,
dayByMonth
);
private
void
initDutyPersonData
(
XSSFSheet
sheet
,
List
<
Map
<
String
,
Object
>>
dataList
,
List
<
Date
>
dayByMonth
)
{
//遍历行,i = 1,从第二行开始,第一行是表头跳过。
for
(
int
i
=
1
;
i
<
sheet
.
getPhysicalNumberOfRows
();
i
++)
{
DutyPersonDto
dutyPersonDto
=
new
DutyPersonDto
();
//row是一行数据,row.getCell(i),代表拿到这一行,第i列数据
Row
row
=
sheet
.
getRow
(
i
);
if
(
row
==
null
)
{
continue
;
}
Cell
cell
=
row
.
getCell
(
1
);
if
(
cell
!=
null
)
{
dutyPersonDto
.
setUserId
(
cell
.
toString
());
}
cell
=
row
.
getCell
(
2
);
if
(
cell
!=
null
)
{
dutyPersonDto
.
setUserName
(
cell
.
toString
());
}
cell
=
row
.
getCell
(
3
);
if
(
cell
!=
null
)
{
String
[]
split
=
cell
.
toString
().
split
(
"@"
);
dutyPersonDto
.
setPostTypeName
(
split
[
0
]);
dutyPersonDto
.
setPostType
(
split
[
1
]);
}
List
<
DutyPersonShiftDto
>
dutyShift
=
new
ArrayList
<>();
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
);
}
}
dutyPersonDto
.
setDutyShift
(
dutyShift
);
Map
<
String
,
Object
>
dutyPersonDtoMap
=
Bean
.
BeantoMap
(
dutyPersonDto
);
dataList
.
add
(
dutyPersonDtoMap
);
}
}
dutyCommonServiceImpl
.
saveImportData
(
dataList
);
}
}
private
void
initDutyCarData
(
XSSFSheet
sheet
,
List
<
Map
<
String
,
Object
>>
dataList
,
List
<
Date
>
dayByMonth
)
{
private
void
initDutyCarData
(
XSSFSheet
sheet
,
List
<
Map
<
String
,
Object
>>
dataList
,
List
<
Date
>
dayByMonth
)
{
...
@@ -228,8 +275,7 @@ public class ExcelController extends BaseController {
...
@@ -228,8 +275,7 @@ public class ExcelController extends BaseController {
if
(
row
==
null
)
{
if
(
row
==
null
)
{
continue
;
continue
;
}
}
Cell
cell
=
null
;
Cell
cell
=
row
.
getCell
(
1
);
cell
=
row
.
getCell
(
1
);
if
(
cell
!=
null
)
{
if
(
cell
!=
null
)
{
String
[]
split
=
cell
.
toString
().
split
(
"@"
);
String
[]
split
=
cell
.
toString
().
split
(
"@"
);
dutyCarDto
.
setTeamName
(
split
[
0
]);
dutyCarDto
.
setTeamName
(
split
[
0
]);
...
@@ -255,11 +301,10 @@ public class ExcelController extends BaseController {
...
@@ -255,11 +301,10 @@ public class ExcelController extends BaseController {
}
}
List
<
DutyPersonShiftDto
>
dutyShift
=
dutyCarDto
.
getDutyShift
();
List
<
DutyPersonShiftDto
>
dutyShift
=
dutyCarDto
.
getDutyShift
();
for
(
int
j
=
0
;
j
<
dayByMonth
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
dayByMonth
.
size
();
j
++)
{
cell
=
row
.
getCell
(
4
+
j
);
cell
=
row
.
getCell
(
5
+
j
);
String
dutyType
=
cell
==
null
?
""
:
cell
.
toString
();
String
dutyType
=
cell
==
null
?
""
:
cell
.
toString
();
if
(!
StringUtils
.
isEmpty
(
dutyType
))
{
if
(!
StringUtils
.
isEmpty
(
dutyType
))
{
DutyPersonShiftDto
dutyPersonShiftDto
=
new
DutyPersonShiftDto
();
DutyPersonShiftDto
dutyPersonShiftDto
=
new
DutyPersonShiftDto
();
// dutyPersonShiftDto.setDutyDate(DateUtils.getDate(dayByMonth.get(j)));
dutyPersonShiftDto
.
setDutyDate
(
dayByMonth
.
get
(
j
));
dutyPersonShiftDto
.
setDutyDate
(
dayByMonth
.
get
(
j
));
dutyPersonShiftDto
.
setShiftId
(
Long
.
valueOf
(
dutyType
.
split
(
"@"
)[
1
]));
dutyPersonShiftDto
.
setShiftId
(
Long
.
valueOf
(
dutyType
.
split
(
"@"
)[
1
]));
dutyShift
.
add
(
dutyPersonShiftDto
);
dutyShift
.
add
(
dutyPersonShiftDto
);
...
@@ -504,12 +549,17 @@ public class ExcelController extends BaseController {
...
@@ -504,12 +549,17 @@ public class ExcelController extends BaseController {
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"导出值班模板"
,
notes
=
"导出值班模板"
)
@ApiOperation
(
value
=
"导出值班模板"
,
notes
=
"导出值班模板"
)
@GetMapping
(
value
=
"/duty_
car_
template"
)
@GetMapping
(
value
=
"/duty_template"
)
public
void
dutyCarTemplate
(
HttpServletResponse
response
,
@RequestParam
(
"beginDate"
)
String
beginDate
,
public
void
dutyCarTemplate
(
HttpServletResponse
response
,
@RequestParam
(
"beginDate"
)
String
beginDate
,
@RequestParam
(
"endDate"
)
String
endDate
,
ExcelDto
excelDto
,
@RequestParam
(
"endDate"
)
String
endDate
,
ExcelDto
excelDto
,
@RequestParam
(
"
teamIds"
)
String
teamI
ds
)
{
@RequestParam
(
"
ids"
)
String
i
ds
)
{
try
{
try
{
List
<
List
<
Object
>>
data
=
initDutyTemplate
(
teamIds
);
List
<
List
<
Object
>>
data
=
new
ArrayList
<>();
if
(
ExcelEnums
.
CLZQ
.
equals
(
excelDto
.
getType
()))
{
data
=
initDutyCarTemplate
(
ids
);
}
else
if
(
ExcelEnums
.
RYZB
.
equals
(
excelDto
.
getType
()))
{
data
=
initDutyPersonTemplate
(
ids
);
}
// 获取日期
// 获取日期
List
<
Map
<
String
,
Object
>>
rangeDate
=
dutyPersonShiftService
.
getBaseMapper
().
genRangeDate
(
beginDate
,
List
<
Map
<
String
,
Object
>>
rangeDate
=
dutyPersonShiftService
.
getBaseMapper
().
genRangeDate
(
beginDate
,
endDate
);
endDate
);
...
@@ -522,7 +572,40 @@ public class ExcelController extends BaseController {
...
@@ -522,7 +572,40 @@ public class ExcelController extends BaseController {
}
}
}
}
private
List
<
List
<
Object
>>
initDutyTemplate
(
String
teamIds
)
{
private
List
<
List
<
Object
>>
initDutyPersonTemplate
(
String
ids
)
{
List
<
List
<
Object
>>
data
=
new
ArrayList
<>();
// 根据id列表获取部门下的人
List
<
Long
>
idList
=
Lists
.
newArrayList
();
if
(!
ValidationUtil
.
isEmpty
(
ids
))
{
String
[]
strings
=
ids
.
split
(
","
);
Long
[]
convert
=
(
Long
[])
ConvertUtils
.
convert
(
strings
,
Long
.
class
);
idList
=
Arrays
.
asList
(
convert
);
}
try
{
List
<
CompanyPerson
>
companyPeople
=
orgUsrService
.
returnCompanyPerson
(
idList
);
if
(!
companyPeople
.
isEmpty
())
{
AtomicInteger
row
=
new
AtomicInteger
(
1
);
companyPeople
.
forEach
(
item
->
{
List
<
OrgUsrDto
>
persons
=
item
.
getPersons
();
if
(
persons
!=
null
&&
!
persons
.
isEmpty
())
{
persons
.
forEach
(
o
->
{
ArrayList
<
Object
>
list
=
new
ArrayList
<>();
list
.
add
(
row
.
getAndIncrement
());
list
.
add
(
o
.
getSequenceNbr
().
toString
());
list
.
add
(
o
.
getBizOrgName
());
data
.
add
(
list
);
});
}
});
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"系统异常!"
);
}
return
data
;
}
private
List
<
List
<
Object
>>
initDutyCarTemplate
(
String
teamIds
)
{
List
<
List
<
Object
>>
data
=
new
ArrayList
<>();
List
<
List
<
Object
>>
data
=
new
ArrayList
<>();
// 根据id列表获取队伍下的人
// 根据id列表获取队伍下的人
List
<
String
>
teamIdList
=
Lists
.
newArrayList
();
List
<
String
>
teamIdList
=
Lists
.
newArrayList
();
...
@@ -547,7 +630,7 @@ public class ExcelController extends BaseController {
...
@@ -547,7 +630,7 @@ public class ExcelController extends BaseController {
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"导出值班信息"
,
notes
=
"导出值班模板"
)
@ApiOperation
(
value
=
"导出值班信息"
,
notes
=
"导出值班模板"
)
@GetMapping
(
value
=
"/duty_
car_
info"
)
@GetMapping
(
value
=
"/duty_info"
)
public
void
dutyCarDuty
(
HttpServletResponse
response
,
@RequestParam
(
"beginDate"
)
String
beginDate
,
public
void
dutyCarDuty
(
HttpServletResponse
response
,
@RequestParam
(
"beginDate"
)
String
beginDate
,
@RequestParam
(
"endDate"
)
String
endDate
,
ExcelDto
excelDto
)
{
@RequestParam
(
"endDate"
)
String
endDate
,
ExcelDto
excelDto
)
{
try
{
try
{
...
@@ -556,7 +639,12 @@ public class ExcelController extends BaseController {
...
@@ -556,7 +639,12 @@ public class ExcelController extends BaseController {
endDate
);
endDate
);
List
<
String
>
dayByMonth
=
new
ArrayList
<>();
List
<
String
>
dayByMonth
=
new
ArrayList
<>();
rangeDate
.
forEach
(
item
->
dayByMonth
.
add
((
String
)
item
.
get
(
"date"
)));
rangeDate
.
forEach
(
item
->
dayByMonth
.
add
((
String
)
item
.
get
(
"date"
)));
List
<
List
<
Object
>>
data
=
initDutyInfo
(
beginDate
,
endDate
,
dayByMonth
);
List
<
List
<
Object
>>
data
=
new
ArrayList
<>();
if
(
ExcelEnums
.
CLZQ
.
equals
(
excelDto
.
getType
()))
{
data
=
initDutyCarInfo
(
beginDate
,
endDate
,
dayByMonth
);
}
else
if
(
ExcelEnums
.
RYZB
.
equals
(
excelDto
.
getType
()))
{
data
=
initDutyPersonInfo
(
beginDate
,
endDate
,
dayByMonth
);
}
exportDutyTemplate
(
response
,
excelDto
.
getClassUrl
(),
dayByMonth
,
excelDto
,
data
,
false
);
exportDutyTemplate
(
response
,
excelDto
.
getClassUrl
(),
dayByMonth
,
excelDto
,
data
,
false
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -565,7 +653,42 @@ public class ExcelController extends BaseController {
...
@@ -565,7 +653,42 @@ public class ExcelController extends BaseController {
}
}
}
}
private
List
<
List
<
Object
>>
initDutyInfo
(
String
beginDate
,
String
endDate
,
List
<
String
>
dayByMonth
)
throws
ParseException
{
private
List
<
List
<
Object
>>
initDutyPersonInfo
(
String
beginDate
,
String
endDate
,
List
<
String
>
dayByMonth
)
throws
ParseException
{
// 查询已值班数据
List
<
DutyPersonDto
>
contentList
=
iDutyPersonService
.
downloadList
(
beginDate
,
endDate
);
List
<
List
<
Object
>>
data
=
new
ArrayList
<>();
// 组装导出数据
if
(!
contentList
.
isEmpty
())
{
AtomicInteger
row
=
new
AtomicInteger
(
1
);
contentList
.
forEach
(
o
->
{
ArrayList
<
Object
>
list
=
new
ArrayList
<>();
list
.
add
(
row
.
getAndIncrement
());
list
.
add
(
o
.
getUserId
());
list
.
add
(
o
.
getUserName
());
list
.
add
(
o
.
getPostTypeName
());
List
<
DutyPersonShiftDto
>
dutyShift
=
o
.
getDutyShift
();
HashMap
<
String
,
String
>
dutyShiftMap
=
new
HashMap
<>();
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
dutyShift
.
forEach
(
item
->
dutyShiftMap
.
put
(
format
.
format
(
item
.
getDutyDate
()),
item
.
getShiftName
()));
if
(!
dutyShift
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
dayByMonth
.
size
();
i
++)
{
if
(
dutyShiftMap
.
containsKey
(
dayByMonth
.
get
(
i
)))
{
list
.
add
(
dutyShiftMap
.
get
(
dayByMonth
.
get
(
i
)));
}
else
{
list
.
add
(
NOT_DUTY
);
}
}
}
data
.
add
(
list
);
});
}
return
data
;
}
private
List
<
List
<
Object
>>
initDutyCarInfo
(
String
beginDate
,
String
endDate
,
List
<
String
>
dayByMonth
)
throws
ParseException
{
// 查询已值班数据
// 查询已值班数据
List
<
DutyCarDto
>
contentList
=
dutyCarService
.
downloadList
(
beginDate
,
endDate
);
List
<
DutyCarDto
>
contentList
=
dutyCarService
.
downloadList
(
beginDate
,
endDate
);
List
<
List
<
Object
>>
data
=
new
ArrayList
<>();
List
<
List
<
Object
>>
data
=
new
ArrayList
<>();
...
@@ -583,7 +706,7 @@ public class ExcelController extends BaseController {
...
@@ -583,7 +706,7 @@ public class ExcelController extends BaseController {
List
<
DutyPersonShiftDto
>
dutyShift
=
o
.
getDutyShift
();
List
<
DutyPersonShiftDto
>
dutyShift
=
o
.
getDutyShift
();
HashMap
<
String
,
String
>
dutyShiftMap
=
new
HashMap
<>();
HashMap
<
String
,
String
>
dutyShiftMap
=
new
HashMap
<>();
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"
%Y-%m-%
d"
);
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"
yyyy-MM-d
d"
);
dutyShift
.
forEach
(
item
->
dutyShiftMap
.
put
(
format
.
format
(
item
.
getDutyDate
()),
item
.
getShiftName
()));
dutyShift
.
forEach
(
item
->
dutyShiftMap
.
put
(
format
.
format
(
item
.
getDutyDate
()),
item
.
getShiftName
()));
if
(!
dutyShift
.
isEmpty
())
{
if
(!
dutyShift
.
isEmpty
())
{
...
@@ -618,7 +741,6 @@ public class ExcelController extends BaseController {
...
@@ -618,7 +741,6 @@ public class ExcelController extends BaseController {
List
<
String
>
dutyShiftList
=
new
ArrayList
<>();
List
<
String
>
dutyShiftList
=
new
ArrayList
<>();
List
<
DutyShiftDto
>
dutyShiftDtoList
=
dutyShiftService
.
queryForDutyShiftList
(
null
,
false
);
List
<
DutyShiftDto
>
dutyShiftDtoList
=
dutyShiftService
.
queryForDutyShiftList
(
null
,
false
);
dutyShiftDtoList
.
forEach
(
item
->
dutyShiftList
.
add
(
item
.
getName
()
+
"@"
+
item
.
getSequenceNbr
()));
dutyShiftDtoList
.
forEach
(
item
->
dutyShiftList
.
add
(
item
.
getName
()
+
"@"
+
item
.
getSequenceNbr
()));
String
[]
dutyNameList
=
dutyShiftList
.
toArray
(
new
String
[
dutyShiftList
.
size
()]);
return
dutyShiftList
.
toArray
(
new
String
[
dutyShiftList
.
size
()]);
return
dutyNameList
;
}
}
}
}
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