@ -17,6 +17,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.http.HttpHeaders ;
import org.apache.http.HttpHeaders ;
import org.apache.poi.ss.usermodel.* ;
import org.apache.poi.ss.usermodel.* ;
import org.apache.poi.ss.util.CellRangeAddress ;
import org.apache.poi.xssf.usermodel.XSSFWorkbook ;
import org.apache.poi.xssf.usermodel.XSSFWorkbook ;
import org.apache.poi.xssf.usermodel.XSSFWorkbookFactory ;
import org.apache.poi.xssf.usermodel.XSSFWorkbookFactory ;
import org.apache.shiro.SecurityUtils ;
import org.apache.shiro.SecurityUtils ;
@ -199,8 +200,8 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
@RequestMapping ( value = "/exportXls2" )
@RequestMapping ( value = "/exportXls2" )
public ModelAndView exportXls3 ( HttpServletRequest request , ClockinLog clockinLog ) throws IOException {
return this . exportXls2 ( request , ClockInLogExportResp . class , "打卡" ) ;
public Object exportXls3 ( HttpServletRequest request , ClockinLog clockinLog ) throws IOException {
return this . exportXls3 ( request , ClockInLogExportResp . class , "打卡" ) ;
}
}
/ / @RequestMapping ( value = "/exportXls2" )
/ / @RequestMapping ( value = "/exportXls2" )
@ -391,15 +392,17 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
}
}
/ / 创建工作簿
/ / 创建工作簿
XSSFWorkbookFactory xssfWorkbookFactory = new XSSFWorkbookFactory ( ) ;
Workbook workbook = new XSSFWorkbook ( ) ;
Workbook workbook = new XSSFWorkbook ( ) ;
/ / 创建工作表
/ / 创建工作表
Sheet sheet = workbook . createSheet ( "考勤" ) ;
Sheet sheet = workbook . createSheet ( "考勤" ) ;
/ / 创建表头行
Row headerRow = sheet . createRow ( 0 ) ;
headerRow . createCell ( 0 ) . setCellValue ( "日期" ) ;
headerRow . createCell ( 1 ) . setCellValue ( "打卡时间" ) ;
/ / Row headerRow2 = sheet . createRow ( 2 ) ;
/ /
/ /
/ / headerRow2 . createCell ( 0 ) . setCellValue ( "日期" ) ;
/ / headerRow2 . createCell ( 1 ) . setCellValue ( "打卡时间" ) ;
List < Map < String , Object > > maps = new ArrayList < > ( ) ;
List < Map < String , Object > > maps = new ArrayList < > ( ) ;
Map < String , Object > map = new HashMap < > ( ) ;
Map < String , Object > map = new HashMap < > ( ) ;
@ -441,6 +444,14 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
List < Map < String , Object > > list = new ArrayList < > ( ) ;
List < Map < String , Object > > list = new ArrayList < > ( ) ;
List < String > strings = null ;
List < String > strings = null ;
List < ClockInLogExportResp > exportList = new ArrayList < > ( ) ;
List < ClockInLogExportResp > exportList = new ArrayList < > ( ) ;
CellStyle wrapStyle = workbook . createCellStyle ( ) ;
wrapStyle . setAlignment ( HorizontalAlignment . CENTER ) ;
wrapStyle . setBorderTop ( BorderStyle . THIN ) ; / / 顶部边框
wrapStyle . setBorderBottom ( BorderStyle . THIN ) ; / / 底部边框
wrapStyle . setBorderLeft ( BorderStyle . THIN ) ; / / 左边边框
wrapStyle . setBorderRight ( BorderStyle . THIN ) ; / / 右边边框
int headerRowNum = 0 ;
for ( ClockinTeamLog clockinTeamLog : clockinTeamLogs ) {
for ( ClockinTeamLog clockinTeamLog : clockinTeamLogs ) {
ClockInProject clockInProject = clockInProjectService . lambdaQuery ( )
ClockInProject clockInProject = clockInProjectService . lambdaQuery ( )
. eq ( ClockInProject : : getDelFlag , 0 )
. eq ( ClockInProject : : getDelFlag , 0 )
@ -461,9 +472,26 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
ClockInLogExportResp clockInLogExportResp = new ClockInLogExportResp ( ) ;
ClockInLogExportResp clockInLogExportResp = new ClockInLogExportResp ( ) ;
clockInLogExportResp . setName ( clockinAuth . getName ( ) ) ;
clockInLogExportResp . setName ( clockinAuth . getName ( ) ) ;
clockInLogExportResp . setDate ( nowYearMonth ) ;
clockInLogExportResp . setDate ( nowYearMonth ) ;
/ / 创建表头行
Row headerRow = sheet . createRow ( headerRowNum ) ;
Cell cell1 = headerRow . createCell ( 0 ) ;
cell1 . setCellStyle ( wrapStyle ) ;
cell1 . setCellValue ( "姓名:" + clockinAuth . getName ( ) + " 日期:" + nowYearMonth ) ;
sheet . addMergedRegion ( new CellRangeAddress ( headerRowNum , headerRowNum , 0 , day - 1 ) ) ;
/ / Row row1 = sheet . createRow ( 1 ) ;
/ / row1 . createCell ( 0 ) . setCellValue ( clockinAuth . getName ( ) ) ;
sheet . setColumnWidth ( 0 , 256 * 10 ) ;
sheet . setColumnWidth ( 1 , 256 * 10 ) ;
map . put ( "name" , clockinAuth . getName ( ) ) ;
map . put ( "name" , clockinAuth . getName ( ) ) ;
map . put ( "sex" , nowYearMonth ) ;
map . put ( "sex" , nowYearMonth ) ;
List < Map < String , Object > > maps1 = new ArrayList < > ( ) ;
List < Map < String , Object > > maps1 = new ArrayList < > ( ) ;
Row row = sheet . createRow ( 1 + headerRowNum ) ;
Row row2 = sheet . createRow ( 2 + headerRowNum ) ;
headerRowNum = headerRowNum + 3 ;
int num = 3 ;
for ( int n = 1 ; n < = day ; n + + ) {
for ( int n = 1 ; n < = day ; n + + ) {
ClockInLogExportResp2 clockInLogExportResp2 = new ClockInLogExportResp2 ( ) ;
ClockInLogExportResp2 clockInLogExportResp2 = new ClockInLogExportResp2 ( ) ;
@ -480,11 +508,17 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
if ( DayOfWeek . SATURDAY . equals ( localDateTime . getDayOfWeek ( ) ) | | DayOfWeek . SUNDAY . equals ( localDateTime . getDayOfWeek ( ) ) ) {
if ( DayOfWeek . SATURDAY . equals ( localDateTime . getDayOfWeek ( ) ) | | DayOfWeek . SUNDAY . equals ( localDateTime . getDayOfWeek ( ) ) ) {
type = 1 ;
type = 1 ;
}
}
Row row = sheet . createRow ( n ) ;
row . createCell ( 0 ) . setCellValue ( yearMonthDay ) ;
Cell cell2 = row . createCell ( n - 1 ) ;
cell2 . setCellValue ( n ) ;
cell2 . setCellStyle ( wrapStyle ) ;
List < ClockInLogResp > clockInLogExpeort = clockinLogMapper . getClockInLogExpeort ( yearMonthDay , clockInProject . getId ( ) , clockinTeamLog . getUserId ( ) , type ) ;
List < ClockInLogResp > clockInLogExpeort = clockinLogMapper . getClockInLogExpeort ( yearMonthDay , clockInProject . getId ( ) , clockinTeamLog . getUserId ( ) , type ) ;
String clockInTime = "" ;
String clockInTime = "" ;
for ( ClockInLogResp clockInLogResp : clockInLogExpeort ) {
for ( ClockInLogResp clockInLogResp : clockInLogExpeort ) {
if ( StringUtils . isBlank ( clockInLogResp . getTime ( ) ) & & clockInLogResp . getType ( ) = = 2 ) {
continue ;
}
if ( StringUtils . isBlank ( clockInLogResp . getTime ( ) ) ) {
if ( StringUtils . isBlank ( clockInLogResp . getTime ( ) ) ) {
clockInLogResp . setClockStartTime ( "缺卡" ) ;
clockInLogResp . setClockStartTime ( "缺卡" ) ;
@ -493,9 +527,9 @@ public class ClockinLogController extends JeecgController<ClockinLog, IClockinLo
/ / strings . add ( clockInLogResp . getClockStartTime ( ) ) ;
/ / strings . add ( clockInLogResp . getClockStartTime ( ) ) ;
}
}
/ / 创建一个单元格样式 , 用于自动换行
/ / 创建一个单元格样式 , 用于自动换行
CellStyle wrapStyle = workbook . createCellStyle ( ) ;
wrapStyle . setWrapText ( true ) ;
wrapStyle . setWrapText ( true ) ;
Cell cell = row . createCell ( 1 ) ;
Cell cell = row2 . createCell ( n - 1 ) ;
cell . setCellValue ( clockInTime ) ;
cell . setCellValue ( clockInTime ) ;
cell . setCellStyle ( wrapStyle ) ;
cell . setCellStyle ( wrapStyle ) ;
Map < String , Object > map1 = new HashMap < > ( ) ;
Map < String , Object > map1 = new HashMap < > ( ) ;