|
@@ -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) {
|