Browse Source

1.日考勤页面中增加显示工作时长。

zhengqiang 3 năm trước cách đây
mục cha
commit
e79aac901a

+ 2 - 2
common/src/main/java/com/jpsoft/shinestar/modules/business/dto/PersonInfoDayWSADTO.java

@@ -432,6 +432,6 @@ public class PersonInfoDayWSADTO {
     @ApiModelProperty(value = "未刷次数")
     private Integer notSwipingNum;
 
-
-
+    @ApiModelProperty(value = "工作时长")
+    private String workTimes;
 }

+ 1 - 1
common/src/main/resources/mapper/business/WorkScheduleAttendance.xml

@@ -669,7 +669,7 @@
         and
         del_flag=0
         and
-        record_time>'2021-09-01'
+        record_time>'2021-10-01'
         order by record_time asc
         limit ${limit}
     </select>

+ 185 - 14
web/src/main/java/com/jpsoft/shinestar/modules/business/controller/WorkScheduleAttendanceController.java

@@ -288,12 +288,30 @@ public class WorkScheduleAttendanceController {
 //            List<String> dateLst = new ArrayList<>();
 //            dateLst.add(startMonth + "%");
 //            dateLst.add(endMonth + "%");
-
+            Map<String,CompanyInfo> companyInfoMap = new HashMap<>();
 
             for (PersonInfo pi : page.getResult()) {
                 PersonInfoMonthWSADTO wsaDTO = new PersonInfoMonthWSADTO();
                 wsaDTO.setPersonInfo(pi);
 
+                CompanyInfo ci = null;
+
+                if(!companyInfoMap.containsKey(pi.getCompanyId())){
+                    ci = companyInfoService.get(pi.getCompanyId());
+                    companyInfoMap.put(pi.getCompanyId(), ci);
+                }
+                else{
+                    ci = companyInfoMap.get(pi.getCompanyId());
+                }
+
+                if(ci!=null) {
+                    if (StringUtils.isNotEmpty(ci.getFullName())) {
+                        wsaDTO.setCompanyName(ci.getFullName());
+                    } else {
+                        wsaDTO.setCompanyName(ci.getName());
+                    }
+                }
+
                 //出差次数businessTripNum
                 //Map<String,Object> searchParams11 = new HashMap<>();
                 //searchParams11.put("workStatus","3");
@@ -382,7 +400,7 @@ public class WorkScheduleAttendanceController {
 
                 //工作时长
                 Map<String, Object> workMinuteParams = new HashMap<>();
-                searchParams3.put("classify", "2");
+                workMinuteParams.put("classify", "2");
 
                 BigDecimal workMinutes = workScheduleAttendanceService.findSumWorkMinuteByParams(pi.getId(), startDate, endDate, workMinuteParams);
 
@@ -1262,10 +1280,18 @@ public class WorkScheduleAttendanceController {
                         }
 
                         wsaDayDTO.setNotSwipingNum(notSwipingNum);
-                        String shiftNumberStrs = shiftNumbers.stream()
-                                .map((shiftNumber) -> shiftNumber)
-                                .collect(Collectors.joining(","));
+
+                        String shiftNumberStrs = shiftNumbers.stream().collect(Collectors.joining(","));
                         wsaDayDTO.setShiftNumbers(shiftNumberStrs);
+
+                        //工作时长
+                        Map<String, Object> workMinuteParams = new HashMap<>();
+                        workMinuteParams.put("classify", "2");
+
+                        BigDecimal workMinutes = workScheduleAttendanceService.findSumWorkMinuteByParams(pi.getId(), sdf.parse(queryDate), sdf.parse(queryDate), workMinuteParams);
+
+                        wsaDayDTO.setWorkTimes(formatTime(workMinutes.intValue()));
+
                         perWsaList.add(wsaDayDTO);
 
                         exist = true;
@@ -1611,9 +1637,140 @@ public class WorkScheduleAttendanceController {
         return msgResult;
     }
 
-    @ApiOperation(value = "导出考勤按月统计")
-    @PostMapping("exportMonthXls")
-    public MessageResult<String> exportMonthXls(
+    @ApiOperation(value = "导出后勤月报表")
+    @PostMapping("exportHqMonthXls")
+    public MessageResult<String> exportHqMonthXls(
+            @RequestBody JSONObject requestBody,
+            @RequestAttribute String subject) {
+        MessageResult<String> msgResult = new MessageResult<>();
+
+        try {
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            XSSFSheet sheet = workbook.createSheet();
+            //表头
+            XSSFRow rowTitle = sheet.createRow(0);
+            XSSFCell cellTitle0 = rowTitle.createCell(0);
+            cellTitle0.setCellValue("部门");
+            XSSFCell cellTitle1 = rowTitle.createCell(1);
+            cellTitle1.setCellValue("工号");
+            XSSFCell cellTitle2 = rowTitle.createCell(2);
+            cellTitle2.setCellValue("姓名");
+
+            XSSFCell cellTitle3 = rowTitle.createCell(3);
+            cellTitle3.setCellValue("应出勤天数");
+            XSSFCell cellTitle4 = rowTitle.createCell(4);
+            cellTitle4.setCellValue("实际出勤天数");
+            XSSFCell cellTitle5 = rowTitle.createCell(5);
+            cellTitle5.setCellValue("迟到分钟");
+            XSSFCell cellTitle6 = rowTitle.createCell(6);
+            cellTitle6.setCellValue("迟到次数");
+            XSSFCell cellTitle7 = rowTitle.createCell(7);
+            cellTitle7.setCellValue("早退分钟");
+            XSSFCell cellTitle8 = rowTitle.createCell(8);
+            cellTitle8.setCellValue("早退次数");
+            XSSFCell cellTitle9 = rowTitle.createCell(9);
+            cellTitle9.setCellValue("加班小时");
+            XSSFCell cellTitle10 = rowTitle.createCell(10);
+            cellTitle10.setCellValue("旷工天数");
+            XSSFCell cellTitle11 = rowTitle.createCell(11);
+            cellTitle11.setCellValue("未打卡次数");
+            XSSFCell cellTitle12 = rowTitle.createCell(12);
+            cellTitle12.setCellValue("签到次数");
+            XSSFCell cellTitle13 = rowTitle.createCell(13);
+            cellTitle13.setCellValue("出差天数");
+            XSSFCell cellTitle14 = rowTitle.createCell(14);
+            cellTitle14.setCellValue("请假天数");
+            XSSFCell cellTitle15 = rowTitle.createCell(15);
+            cellTitle15.setCellValue("备注");
+
+            JSONArray array = requestBody.getJSONArray("data");
+
+            for (int i = 0; i < array.size(); i++) {
+                Row row = sheet.createRow(i + 1);
+
+                JSONObject jsonObject = array.getJSONObject(i);
+
+                int colIndex = 0;
+
+                if (jsonObject.getJSONObject("personInfo") != null) {
+                    row.createCell(colIndex).setCellValue(jsonObject.getString("companyName"));
+                    colIndex++;
+
+                    row.createCell(colIndex).setCellValue(jsonObject.getJSONObject("personInfo").getString("jobNumber"));
+                    colIndex++;
+
+                    row.createCell(colIndex).setCellValue(jsonObject.getJSONObject("personInfo").getString("name"));
+                    colIndex++;
+                } else {
+                    colIndex += 3;
+                }
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("attendanceDays"));
+                colIndex++;
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("totalAttendanceDays"));
+                colIndex++;
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("lateMinutes"));
+                colIndex++;
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("lateNum"));
+                colIndex++;
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("leaveEarlyMinutes"));
+                colIndex++;
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("leaveEarlyNum"));
+                colIndex++;
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("overtime"));
+                colIndex++;
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("absenteeismDays"));
+                colIndex++;
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("notSwipingNum"));
+                colIndex++;
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("signNum"));
+                colIndex++;
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("businessTripNum"));
+                colIndex++;
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("leaveNum"));
+                colIndex++;
+                row.createCell(colIndex).setCellValue(jsonObject.getString("remark"));
+                colIndex++;
+
+                //todo 将wb保存到oss
+                ByteArrayOutputStream output = new ByteArrayOutputStream();
+                workbook.write(output);
+
+                byte[] buffer = output.toByteArray();
+                ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+                //格式化
+                SimpleDateFormat sim = new SimpleDateFormat("yyyyMMddHHmmss");
+                String fileName = "导出后勤考勤月统计数据" + sim.format(new Date()) + ".xlsx";
+                String downloadUrl = OSSUtil.upload(ossConfig, "import", fileName, input);
+
+                msgResult.setData(downloadUrl);
+                msgResult.setResult(true);
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "服务端导出考勤按月统计")
+    @PostMapping("exportMonthXlsByServer")
+    public MessageResult<String> exportMonthXlsByServer(
             @RequestParam(value = "companyId", defaultValue = "") String companyId,
             @RequestParam(value = "subordinate", defaultValue = "false") Boolean subordinate,
             @RequestParam(value = "name", defaultValue = "") String name,
@@ -1657,7 +1814,8 @@ public class WorkScheduleAttendanceController {
             cellTitle13.setCellValue("出差天数");
             XSSFCell cellTitle14 = rowTitle.createCell(14);
             cellTitle14.setCellValue("请假天数");
-
+            XSSFCell cellTitle15 = rowTitle.createCell(15);
+            cellTitle15.setCellValue("工作时长");
 
             Map<String, Object> searchParams = new HashMap<>();
             Map<String, Object> msgMap = new HashMap<>();
@@ -1804,6 +1962,12 @@ public class WorkScheduleAttendanceController {
                 XSSFCell cellContent14 = rowContent.createCell(14);
                 cellContent14.setCellValue(leaveNum);
 
+                Map<String, Object> workMinuteParams = new HashMap<>();
+                workMinuteParams.put("classify", "2");
+
+                BigDecimal workMinutes = workScheduleAttendanceService.findSumWorkMinuteByParams(pi.getId(), startDate, endDate, workMinuteParams);
+                XSSFCell cellContent15 = rowContent.createCell(15);
+                cellContent15.setCellValue(formatTime(workMinutes.intValue()));
 
                 //todo 将wb保存到oss
                 ByteArrayOutputStream output = new ByteArrayOutputStream();
@@ -2018,9 +2182,9 @@ public class WorkScheduleAttendanceController {
         return msgResult;
     }
 
-    @ApiOperation(value = "导出勤月报表")
-    @PostMapping("exportHqMonthXls")
-    public MessageResult<String> exportHqMonthXls(
+    @ApiOperation(value = "导出勤月报表")
+    @PostMapping("exportMonthXls")
+    public MessageResult<String> exportMonthXls(
             @RequestBody JSONObject requestBody,
             @RequestAttribute String subject) {
         MessageResult<String> msgResult = new MessageResult<>();
@@ -2062,7 +2226,9 @@ public class WorkScheduleAttendanceController {
             XSSFCell cellTitle14 = rowTitle.createCell(14);
             cellTitle14.setCellValue("请假天数");
             XSSFCell cellTitle15 = rowTitle.createCell(15);
-            cellTitle15.setCellValue("备注");
+            cellTitle15.setCellValue("工作时长");
+            XSSFCell cellTitle16 = rowTitle.createCell(16);
+            cellTitle16.setCellValue("备注");
 
             JSONArray array = requestBody.getJSONArray("data");
 
@@ -2121,6 +2287,11 @@ public class WorkScheduleAttendanceController {
 
                 row.createCell(colIndex).setCellValue(jsonObject.getString("leaveNum"));
                 colIndex++;
+
+
+                row.createCell(colIndex).setCellValue(jsonObject.getString("workTimes"));
+                colIndex++;
+
                 row.createCell(colIndex).setCellValue(jsonObject.getString("remark"));
                 colIndex++;
 
@@ -2133,7 +2304,7 @@ public class WorkScheduleAttendanceController {
 
                 //格式化
                 SimpleDateFormat sim = new SimpleDateFormat("yyyyMMddHHmmss");
-                String fileName = "导出后勤考勤月统计数据" + sim.format(new Date()) + ".xlsx";
+                String fileName = "导出考勤月统计数据" + sim.format(new Date()) + ".xlsx";
                 String downloadUrl = OSSUtil.upload(ossConfig, "import", fileName, input);
 
                 msgResult.setData(downloadUrl);