Sfoglia il codice sorgente

获取本人当天日报

Reiskuchen 5 anni fa
parent
commit
075aeb3e86

+ 10 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -37,6 +37,16 @@ public class ReportController {
         return reportService.getReportList(date, request);
     }
 
+    /**
+     * 根据时间 获取本人报告信息 以及工时
+     * date 日期 格式yyyy-mm-dd
+     */
+    @RequestMapping("/getReport")
+    public HttpRespMsg getReport(@RequestParam String date) {
+        return reportService.getReport(date, request);
+    }
+
+
     /**
      * 新增或编辑报告
      * id 报告id 编辑时传

+ 14 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TimeCalculationController.java

@@ -51,9 +51,23 @@ public class TimeCalculationController {
         return timeCalculationService.getDevianceList(pageIndex, pageSize, userId, actionCode, date, request);
     }
 
+    /**
+     * 获取相同公司内所有人某天的时间统计
+     * date 日期
+     */
     @RequestMapping("/getTimeStatistics")
     public HttpRespMsg getTimeStatistics(@RequestParam String date) {
         return timeCalculationService.getTimeStatistics(date, request);
     }
+
+    /**
+     * 获取一段时间内某人的工作
+     * startDate 开始日期 格式yyyy-mm-dd
+     * endDate 结束日期 格式yyyy-mm-dd
+     */
+    @RequestMapping("/getDuration")
+    public HttpRespMsg getDuration(@RequestParam String startDate, @RequestParam String endDate) {
+        return timeCalculationService.getDuration(startDate, endDate, request);
+    }
 }
 

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java

@@ -17,6 +17,8 @@ import javax.servlet.http.HttpServletRequest;
 public interface ReportService extends IService<Report> {
     HttpRespMsg getReportList(String date, HttpServletRequest request);
 
+    HttpRespMsg getReport(String date, HttpServletRequest request);
+
     HttpRespMsg editReport(Report report);
 
     HttpRespMsg deleteReport(Integer reportId);

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/TimeCalculationService.java

@@ -21,4 +21,6 @@ public interface TimeCalculationService extends IService<TimeCalculation> {
                                 String userId, Integer actionCode, String date, HttpServletRequest request);
 
     HttpRespMsg getTimeStatistics(String date, HttpServletRequest request);
+
+    HttpRespMsg getDuration(String startDate, String endDate, HttpServletRequest request);
 }

+ 32 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -3,13 +3,16 @@ package com.management.platform.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.management.platform.entity.Report;
+import com.management.platform.entity.TimeCalculation;
 import com.management.platform.mapper.ReportMapper;
+import com.management.platform.mapper.TimeCalculationMapper;
 import com.management.platform.mapper.UserMapper;
 import com.management.platform.service.ReportService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.util.HttpRespMsg;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
@@ -36,6 +39,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     private ReportMapper reportMapper;
     @Resource
     private UserMapper userMapper;
+    @Resource
+    private TimeCalculationMapper timeCalculationMapper;
 
     //获取报告列表
     @Override
@@ -56,6 +61,33 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         return httpRespMsg;
     }
 
+    //获取本人某天工作时间和已提交的报告
+    @Override
+    public HttpRespMsg getReport(String date, HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        try {
+            String userId = userMapper.selectById(request.getHeader("Token")).getId();
+            Map<String, Object> resultMap = new HashMap<>();
+            //获取某日本人的所有日志
+            resultMap.put("report", reportMapper.selectList(new QueryWrapper<Report>()
+                    .eq("user_id", userId)));
+            //顺便再获取一下可分配时间
+            Double totalWorkingTime = 0.0;
+            //此处认为0是工作时间
+            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))) {
+                totalWorkingTime += timeCalculation.getDuration();
+            }
+            resultMap.put("time", totalWorkingTime);
+            httpRespMsg.data = resultMap;
+        } catch (NullPointerException e) {
+            httpRespMsg.setError("验证失败");
+        }
+        return httpRespMsg;
+    }
+
     //新增或编辑报告
     @Override
     public HttpRespMsg editReport(Report report) {

+ 6 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TimeCalculationServiceImpl.java

@@ -110,4 +110,10 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
         }
         return httpRespMsg;
     }
+
+    @Override
+    public HttpRespMsg getDuration(String startDate, String endDate, HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        return httpRespMsg;
+    }
 }