|
@@ -524,14 +524,16 @@ public class WorkOverController {
|
|
|
@ApiImplicitParam(name = "jobNumber", value = "工号", dataType = "string", paramType = "query"),
|
|
|
@ApiImplicitParam(name = "startTime", value = "加班开始日期", paramType = "form"),
|
|
|
@ApiImplicitParam(name = "endTime", value = "加班结束日期", paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "exportFlag", value = "是否导出报表(默认不导出0,1导出", paramType = "form"),
|
|
|
})
|
|
|
- public MessageResult<Map> statisticsList(
|
|
|
+ public MessageResult<Object> statisticsList(
|
|
|
@RequestParam(value = "companyId", defaultValue = "") String companyId,
|
|
|
@RequestParam(value="subordinate",defaultValue="false") Boolean subordinate,
|
|
|
@RequestParam(value = "personName", defaultValue = "") String personName,
|
|
|
@RequestParam(value = "jobNumber", defaultValue = "") String jobNumber,
|
|
|
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
|
|
|
@DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime,
|
|
|
+ @RequestParam(value = "exportFlag", defaultValue = "0") String exportFlag,
|
|
|
@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
@RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
|
|
|
@RequestAttribute String subject){
|
|
@@ -539,7 +541,7 @@ public class WorkOverController {
|
|
|
//当前用户ID
|
|
|
System.out.println(subject);
|
|
|
|
|
|
- MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
+ MessageResult<Object> msgResult = new MessageResult<>();
|
|
|
|
|
|
Map<String,Object> searchParams = new HashMap<>();
|
|
|
Map<String, Object> msgMap = new HashMap<>();
|
|
@@ -620,17 +622,78 @@ public class WorkOverController {
|
|
|
wosList.add(wos);
|
|
|
}
|
|
|
|
|
|
- msgMap.put("wosList",wosList);
|
|
|
- msgMap.put("recordsTotal",page.getTotal());
|
|
|
- msgMap.put("recordsFiltered",page.getTotal());
|
|
|
- msgMap.put("totalPage",page.getPages());
|
|
|
- msgMap.put("pageNumber",page.getPageNum());
|
|
|
- msgMap.put("pageSize",page.getPageSize());
|
|
|
- msgResult.setData(msgMap);
|
|
|
+ if("0".equals(exportFlag)) {
|
|
|
+ msgMap.put("wosList",wosList);
|
|
|
+ msgMap.put("recordsTotal",page.getTotal());
|
|
|
+ msgMap.put("recordsFiltered",page.getTotal());
|
|
|
+ msgMap.put("totalPage",page.getPages());
|
|
|
+ msgMap.put("pageNumber",page.getPageNum());
|
|
|
+ msgMap.put("pageSize",page.getPageSize());
|
|
|
+ msgResult.setData(msgMap);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ String filePath = exportStatisticsList(wosList);
|
|
|
+ msgResult.setData(filePath);
|
|
|
+ }
|
|
|
msgResult.setResult(true);
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
+ private String exportStatisticsList(List<WorkOverStatistics> wosList) {
|
|
|
+ String downloadUrl = "";
|
|
|
+
|
|
|
+ Workbook workbook = new HSSFWorkbook();
|
|
|
+ Sheet sheet = workbook.createSheet();
|
|
|
+
|
|
|
+ //表头
|
|
|
+ Row rowTitle = sheet.createRow(0);
|
|
|
+
|
|
|
+ String[] titles = new String[]{"序号","编号","单位/部门","工号","姓名","加班时长","加班申请次数","审批通过次数","最后申请时间","最后审核时间"};
|
|
|
+
|
|
|
+ for (int i=0;i<titles.length;i++) {
|
|
|
+ Cell cell = rowTitle.createCell(i);
|
|
|
+ cell.setCellValue(titles[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ for (int i=0;i<wosList.size();i++){
|
|
|
+ WorkOverStatistics workOverStatistics = wosList.get(i);
|
|
|
+
|
|
|
+ Row row = sheet.createRow(i+1);
|
|
|
+
|
|
|
+ int colIndex = 0;
|
|
|
+
|
|
|
+ row.createCell(colIndex++).setCellValue(i+1);
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverStatistics.getPersonId());
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverStatistics.getCompanyName());
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverStatistics.getJobNumber());
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverStatistics.getPersonName());
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverStatistics.getDurationStr());
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverStatistics.getCount());
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverStatistics.getApprovalCount());
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverStatistics.getLastCreateTime());
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverStatistics.getLastApprovalTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+
|
|
|
+ try {
|
|
|
+ workbook.write(output);
|
|
|
+
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMDDHHmmss");
|
|
|
+
|
|
|
+ downloadUrl = OSSUtil.upload(ossConfig,"requestForLeave","加班统计" + sdf.format(new Date()) + ".xls",input);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+ }
|
|
|
+
|
|
|
+ return downloadUrl;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value="加班统计详细")
|
|
|
@RequestMapping(value = "statisticsDetail",method = RequestMethod.POST)
|
|
|
@ApiImplicitParams({
|