|
@@ -1,7 +1,6 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.mapper.*;
|
|
@@ -219,20 +218,49 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
|
|
- //获取报告列表
|
|
|
|
|
|
+ //按状态获取报告列表
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg getListByState(Integer pageIndex, Integer pageSize, Integer state, String date,
|
|
|
|
- HttpServletRequest request) {
|
|
|
|
|
|
+ public HttpRespMsg getListByState(Integer state, HttpServletRequest request) {
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
try {
|
|
try {
|
|
- if (state == -1) {
|
|
|
|
- state = null;
|
|
|
|
- }
|
|
|
|
Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("records", reportMapper.getListByState(new Page<>(pageIndex, pageSize), state, companyId, date));
|
|
|
|
- map.put("total", reportMapper.countByState(state, companyId, date));
|
|
|
|
- httpRespMsg.data = map;
|
|
|
|
|
|
+ String userId = request.getHeader("Token");
|
|
|
|
+ User user = userMapper.selectById(userId);
|
|
|
|
+ List<Map<String, Object>> nameList = reportMapper.getDetailByState(state, companyId);
|
|
|
|
+ for (Map<String, Object> map : nameList) {
|
|
|
|
+ //再根据人分别获取当天的报告
|
|
|
|
+ List<Map<String, Object>> list = reportMapper.getReportByDate(
|
|
|
|
+ map.get("date").toString(),
|
|
|
|
+ (String) map.get("id"));
|
|
|
|
+ map.put("data", list);
|
|
|
|
+ double reportTime = 0;
|
|
|
|
+ if (list.size() > 0) {
|
|
|
|
+ for (Map<String, Object> m : list) {
|
|
|
|
+ double t = (double) m.get("time");
|
|
|
|
+ reportTime += t;
|
|
|
|
+ }
|
|
|
|
+ map.put("state", list.get(0).get("state"));
|
|
|
|
+ }
|
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
|
+ map.put("reportTime", df.format(reportTime));
|
|
|
|
+ //顺便再获取一下可分配时间
|
|
|
|
+ Integer calculateTime = 0;
|
|
|
|
+ //以下区间被认为是工作时间
|
|
|
|
+ Integer[] workType = {-1, 0, 1, 2, 3, 4, 5};
|
|
|
|
+ //工作时间筛选
|
|
|
|
+ List<TimeCalculation> timeCalculations = timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
|
|
|
|
+ .eq("date", map.get("date").toString())
|
|
|
|
+ .eq("user_id", map.get("id"))
|
|
|
|
+ .in("action_type", workType));
|
|
|
|
+ if (timeCalculations != null) {
|
|
|
|
+ for (TimeCalculation timeCalculation : timeCalculations) {
|
|
|
|
+ calculateTime += timeCalculation.getDuration();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //把总秒数转为double后换算为小时并保留两位小数
|
|
|
|
+ map.put("calculateTime", df.format((double) calculateTime / 3600));
|
|
|
|
+ }
|
|
|
|
+ httpRespMsg.data = nameList;
|
|
} catch (NullPointerException e) {
|
|
} catch (NullPointerException e) {
|
|
httpRespMsg.setError("验证失败");
|
|
httpRespMsg.setError("验证失败");
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|