Reiskuchen 5 éve
szülő
commit
2a66f97f8c

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -37,6 +37,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     public HttpRespMsg getProjectList(HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
+            //通过公司id获取该公司所有的项目列表
             Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
             httpRespMsg.data = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
         } catch (NullPointerException e) {

+ 13 - 9
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -73,6 +73,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         return httpRespMsg;
     }
 
+    //导出报告
     @Override
     public HttpRespMsg exportReport(String date, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
@@ -82,7 +83,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             HSSFSheet sheet = workbook.createSheet(date + "日报");
             //创建表头
             HSSFRow headRow = sheet.createRow(0);
-            //设置列宽 setColumnWidth的第二个参数要乘以256这个参数的单位是1/256个字符宽度
+            //设置列宽 setColumnWidth的第二个参数要乘以256 这个参数的单位是1/256个字符宽度
             sheet.setColumnWidth(0, 5 * 256);
             sheet.setColumnWidth(1, 10 * 256);
             sheet.setColumnWidth(2, 20 * 256);
@@ -94,7 +95,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             HSSFFont font = workbook.createFont();
             font.setBold(true);
             headStyle.setFont(font);
-
+            //表头
             HSSFCell headCell;
             headCell = headRow.createCell(0);
             headCell.setCellValue("序号");
@@ -114,11 +115,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             headCell = headRow.createCell(5);
             headCell.setCellValue("提交时间");
             headCell.setCellStyle(headStyle);
-
             //设置日期格式
             HSSFCellStyle style = workbook.createCellStyle();
             style.setDataFormat(HSSFDataFormat.getBuiltinFormat("yy/mm/dd hh:mm"));
-            //新增数据行,并且设置单元格数据
+            //新增数据行 并且装填数据
             int rowNum = 1;
             for (Map<String, Object> map : reportMapper.getAllReportByDate(date)) {
                 HSSFRow row = sheet.createRow(rowNum);
@@ -133,13 +133,13 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 cell.setCellStyle(style);
                 rowNum++;
             }
-
             //生成Excel文件
             String fileUrlSuffix = date + "日报" + new SimpleDateFormat("hh-mm-ss").format(new Date()) + ".xls";
             FileOutputStream fos = new FileOutputStream(path + fileUrlSuffix);
             workbook.write(fos);
             fos.flush();
             fos.close();
+            //返回生成的文件地址/upload文件夹下
             httpRespMsg.data = "/upload/" + fileUrlSuffix;
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败或缺少数据");
@@ -163,15 +163,19 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     .eq("creator_id", userId)
                     .eq("create_date", LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd")))));
             //顺便再获取一下可分配时间
-            Double totalWorkingTime = 0.0;
-            //此处认为0是工作时间
+            Integer totalWorkingTime = 0;
+            //以下区间被认为是工作时间
+            Integer[] workType = {0, 1, 2, 3, 4, 5};
+            //工作时间筛选
             for (TimeCalculation timeCalculation : timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
                     .eq("date", LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd")))
                     .eq("user_id", userId)
-                    .eq("action_type", 0))) {
+                    .in("action_type", workType))) {
                 totalWorkingTime += timeCalculation.getDuration();
             }
-            resultMap.put("time", new DecimalFormat("#.00").format(totalWorkingTime / 3600));
+            //把总秒数转为double后换算为小时并保留两位小数
+            resultMap.put("time", new DecimalFormat("#.00").format((double) totalWorkingTime / 3600));
+            //顺便返回该公司全部的计划
             resultMap.put("project", projectMapper.selectList(new QueryWrapper<Project>()
                     .eq("company_id", userMapper.selectById(userId).getCompanyId())));
             httpRespMsg.data = resultMap;

+ 5 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java

@@ -458,14 +458,14 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
             //单独记录当前的时间以便使用
             LocalTime currentTime = screenshot.getIndate().toLocalTime();
             if (latestRecord != null) {
-                //首先对比类型
+                //首先对比类型 同一种行为才有可能合并
                 if (latestRecord.getActionType().equals(screenshot.getPicType())) {
-                    //如果有记录的话 准备计算上次结束和新的开始的时间差
+                    //如果有记录的话 计算上次结束和新的开始的时间差
                     LocalTime estimatedTime = latestRecord.getEndTime();
                     Integer durationSecond = ((currentTime.getHour() - estimatedTime.getHour()) * 3600
                             + (currentTime.getMinute() - estimatedTime.getMinute()) * 60
                             + (currentTime.getSecond() - estimatedTime.getSecond()));
-                    //断层不大于600秒的话
+                    //断层不大于一定时间的话 这个定义目前为600秒
                     if (durationSecond <= DETECTION_INTERVAL) {
                         //确认连续 将状态改为连续
                         isConsecutive = true;
@@ -473,7 +473,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
                 }
             }
             if (isConsecutive) {
-                //如果是连续的话那就准备修改上一条记录的最后时间和持续时间
+                //如果是连续的话 修改上一条记录的最后时间和持续时间
                 LocalTime startTime = latestRecord.getStartTime();
                 //计算新的间隔
                 Integer duration = ((currentTime.getHour() - startTime.getHour()) * 3600
@@ -483,7 +483,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
                 latestRecord.setEndTime(currentTime).setDuration(duration);
                 timeCalculationMapper.updateById(latestRecord);
             } else {
-                //如果不是连续的话 那就准备新增一个记录
+                //如果不是连续的话 新增一个记录
                 TimeCalculation timeCalculation = new TimeCalculation();
                 timeCalculation
                         .setUserId(screenshot.getUid())