|
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.PageQuery; |
|
|
import com.ruoyi.common.core.domain.PageQuery; |
|
|
import com.ruoyi.common.core.page.TableDataInfo; |
|
|
import com.ruoyi.common.core.page.TableDataInfo; |
|
|
import com.ruoyi.zhushi.entity.*; |
|
|
import com.ruoyi.zhushi.entity.*; |
|
|
import com.ruoyi.zhushi.mapper.DkConfigMapper; |
|
|
|
|
|
import com.ruoyi.zhushi.mapper.DkRecordMapper; |
|
|
import com.ruoyi.zhushi.mapper.DkRecordMapper; |
|
|
import com.ruoyi.zhushi.service.DkRecordService; |
|
|
import com.ruoyi.zhushi.service.DkRecordService; |
|
|
import com.ruoyi.zhushi.util.Constans; |
|
|
import com.ruoyi.zhushi.util.Constans; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.io.FileInputStream; |
|
|
import java.io.FileInputStream; |
|
|
import java.io.FileOutputStream; |
|
|
|
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private DkRecordMapper dkMapper; |
|
|
private DkRecordMapper dkMapper; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private DkConfigMapper configMapper; |
|
|
|
|
|
|
|
|
|
|
|
public String getTime() { |
|
|
public String getTime() { |
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
Date currentDate = new Date(); |
|
|
Date currentDate = new Date(); |
|
|
|
|
|
|
|
|
LambdaQueryWrapper<DkCheckInRecord> queryWrapper = buildQueryWrapper(dkCheckInRecordDTO, "export"); |
|
|
LambdaQueryWrapper<DkCheckInRecord> queryWrapper = buildQueryWrapper(dkCheckInRecordDTO, "export"); |
|
|
List<DkCheckInRecordDTO> dkCheckInRecordDTOS = dkMapper.selectVoList(queryWrapper); |
|
|
List<DkCheckInRecordDTO> dkCheckInRecordDTOS = dkMapper.selectVoList(queryWrapper); |
|
|
try { |
|
|
try { |
|
|
FileInputStream templateFile = null; |
|
|
|
|
|
Workbook workbook = null; |
|
|
|
|
|
|
|
|
FileInputStream templateFile; |
|
|
|
|
|
Workbook workbook; |
|
|
// 加载模板文件 |
|
|
// 加载模板文件 |
|
|
templateFile = new FileInputStream("template.xlsx"); |
|
|
templateFile = new FileInputStream("template.xlsx"); |
|
|
workbook = WorkbookFactory.create(templateFile); |
|
|
workbook = WorkbookFactory.create(templateFile); |
|
|
|
|
|
|
|
|
// workbook.write(outputFile); |
|
|
// workbook.write(outputFile); |
|
|
// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
// response.setHeader("Content-disposition", "attachment;filename=用户数据_模板.xlsx"); |
|
|
// response.setHeader("Content-disposition", "attachment;filename=用户数据_模板.xlsx"); |
|
|
// 删除原始模板Sheet(如果不需要) |
|
|
|
|
|
// workbook.removeSheetAt(0); |
|
|
|
|
|
|
|
|
// 删除原始模板Sheet(如果不需要) |
|
|
|
|
|
workbook.removeSheetAt(0); |
|
|
workbook.write(response.getOutputStream()); |
|
|
workbook.write(response.getOutputStream()); |
|
|
// 关闭资源 |
|
|
// 关闭资源 |
|
|
// outputFile.close(); |
|
|
// outputFile.close(); |
|
|
|
|
|
|
|
|
// 执行除法,指定精度和舍入模式 |
|
|
// 执行除法,指定精度和舍入模式 |
|
|
BigDecimal result = a.divide(b, 1, BigDecimal.ROUND_HALF_UP); |
|
|
BigDecimal result = a.divide(b, 1, BigDecimal.ROUND_HALF_UP); |
|
|
dayRecord.setGongzuori("*"); |
|
|
dayRecord.setGongzuori("*"); |
|
|
dayRecord.setRemark("加班1次:" + (double)hours1/60 + "小时"); |
|
|
|
|
|
|
|
|
dayRecord.setRemark("加班1次:" + result + "小时"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void fillTemplate(Sheet sheet, EmployeeAttendance data) { |
|
|
private void fillTemplate(Sheet sheet, EmployeeAttendance data) { |
|
|
// 填充标题区域 |
|
|
// 填充标题区域 |
|
|
setCellValue(sheet, 6, 10, data.getEmployeeName()); |
|
|
setCellValue(sheet, 6, 10, data.getEmployeeName()); |
|
|
setCellValue(sheet, 3, 3, data.getDateTime()); |
|
|
|
|
|
|
|
|
setCellValue(sheet, 3, 1, data.getDateTime()); |
|
|
// setCellValue(sheet, 2, 0, data.getYear() + "年" + data.getMonth() + "月考勤记录"); |
|
|
// setCellValue(sheet, 2, 0, data.getYear() + "年" + data.getMonth() + "月考勤记录"); |
|
|
|
|
|
|
|
|
// 填充数据表格 |
|
|
// 填充数据表格 |
|
|
|
|
|
|
|
|
for (DayRecord record : data.getDayRecords()) { |
|
|
for (DayRecord record : data.getDayRecords()) { |
|
|
// setCellValue(sheet, rowIndex, 1, record.getDay()); |
|
|
// setCellValue(sheet, rowIndex, 1, record.getDay()); |
|
|
// setCellValue(sheet, rowIndex, 2, record.getWeekday()); |
|
|
// setCellValue(sheet, rowIndex, 2, record.getWeekday()); |
|
|
setCellValue(sheet, rowIndex, 3, record.getStartTime()); |
|
|
|
|
|
|
|
|
// setCellValue(sheet, rowIndex, 3, data.getDateTime()); |
|
|
setCellValue(sheet, rowIndex, 4, record.getEndTime()); |
|
|
setCellValue(sheet, rowIndex, 4, record.getEndTime()); |
|
|
setCellValue(sheet, rowIndex, 5, record.getChidao()); |
|
|
setCellValue(sheet, rowIndex, 5, record.getChidao()); |
|
|
// setCellValue(sheet, rowIndex, 6, record.getEndTime()); |
|
|
// setCellValue(sheet, rowIndex, 6, record.getEndTime()); |