|
@@ -701,11 +701,12 @@ public class WorkOverController {
|
|
|
@ApiImplicitParam(name = "startTime", value = "加班开始日期", paramType = "form"),
|
|
|
@ApiImplicitParam(name = "endTime", value = "加班结束日期", paramType = "form"),
|
|
|
})
|
|
|
- public MessageResult<Map> statisticsDetail(
|
|
|
+ public MessageResult<Object> statisticsDetail(
|
|
|
@RequestParam(value = "personId", defaultValue = "") String personId,
|
|
|
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
|
|
|
@DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime,
|
|
|
@RequestParam(value = "status", defaultValue = "") String status,
|
|
|
+ @RequestParam(value = "exportFlag", defaultValue = "0") String exportFlag,
|
|
|
@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
@RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
|
|
|
@RequestAttribute String subject){
|
|
@@ -713,7 +714,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<>();
|
|
@@ -743,11 +744,119 @@ public class WorkOverController {
|
|
|
wop.setPersonInfo(pi);
|
|
|
}
|
|
|
|
|
|
- msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
+ if("0".equals(exportFlag)) {
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ String filePath = exportStatisticsDetail(page.getResult());
|
|
|
+ msgResult.setData(filePath);
|
|
|
+ }
|
|
|
+
|
|
|
msgResult.setResult(true);
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
+ private String exportStatisticsDetail(List<WorkOverPerson> wopList) {
|
|
|
+ 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<wopList.size();i++){
|
|
|
+ WorkOverPerson workOverPerson = wopList.get(i);
|
|
|
+
|
|
|
+ Row row = sheet.createRow(i+1);
|
|
|
+
|
|
|
+ int colIndex = 0;
|
|
|
+
|
|
|
+ row.createCell(colIndex++).setCellValue(i+1);
|
|
|
+ if(workOverPerson.getCreateTime() != null) {
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverPerson.getCreateTime());
|
|
|
+ }else{
|
|
|
+ colIndex++;
|
|
|
+ }
|
|
|
+ if(workOverPerson.getPersonInfo().getName() != null) {
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverPerson.getPersonInfo().getName());
|
|
|
+ }else{
|
|
|
+ colIndex++;
|
|
|
+ }
|
|
|
+ if(workOverPerson.getPersonInfo().getJobNumber() != null) {
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverPerson.getPersonInfo().getJobNumber());
|
|
|
+ }else{
|
|
|
+ colIndex++;
|
|
|
+ }
|
|
|
+ if(workOverPerson.getPersonInfo().getCompanyName() != null) {
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverPerson.getPersonInfo().getCompanyName());
|
|
|
+ }else{
|
|
|
+ colIndex++;
|
|
|
+ }
|
|
|
+ if(workOverPerson.getWorkOver() != null && workOverPerson.getWorkOver().getStartTime() != null) {
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverPerson.getWorkOver().getStartTime());
|
|
|
+ }else{
|
|
|
+ colIndex++;
|
|
|
+ }
|
|
|
+ if(workOverPerson.getWorkOver() != null && workOverPerson.getWorkOver().getEndTime() != null) {
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverPerson.getWorkOver().getEndTime());
|
|
|
+ }else{
|
|
|
+ colIndex++;
|
|
|
+ }
|
|
|
+ if(workOverPerson.getFinishTime() != null) {
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverPerson.getFinishTime());
|
|
|
+ }else{
|
|
|
+ colIndex++;
|
|
|
+ }
|
|
|
+ if(workOverPerson.getDurationStr() != null) {
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverPerson.getDurationStr());
|
|
|
+ }else{
|
|
|
+ colIndex++;
|
|
|
+ }
|
|
|
+ if(workOverPerson.getWorkOver() != null && workOverPerson.getWorkOver().getReason() != null) {
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverPerson.getWorkOver().getReason());
|
|
|
+ }else{
|
|
|
+ colIndex++;
|
|
|
+ }
|
|
|
+ if(workOverPerson.getApprovalPersonName() != null) {
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverPerson.getApprovalPersonName());
|
|
|
+ }else{
|
|
|
+ colIndex++;
|
|
|
+ }
|
|
|
+ if(workOverPerson.getWorkOver() != null && workOverPerson.getWorkOver().getStatusN() != null) {
|
|
|
+ row.createCell(colIndex++).setCellValue(workOverPerson.getWorkOver().getStatusN());
|
|
|
+ }else{
|
|
|
+ colIndex++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
//分钟转小时
|
|
|
private String formatTime(int minuteStr) {
|
|
|
String resultStr = "";
|