|
@@ -62,38 +62,55 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
String userId = request.getHeader("Token");
|
|
|
User user = userMapper.selectById(userId);
|
|
|
List<Map<String, Object>> nameList = new ArrayList<>();
|
|
|
- if (user.getRole().equals("0")) {
|
|
|
+ if (user.getRole() == 0) {
|
|
|
//普通员工只能看自己的
|
|
|
Map map = new HashMap();
|
|
|
map.put("id", user.getId());
|
|
|
map.put("name", user.getName());
|
|
|
- nameList.add(map);
|
|
|
+ List<Map<String, Object>> list = reportMapper.getReportByDate(date, (String) map.get("id"));
|
|
|
+ if (list.size() > 0) {
|
|
|
+ nameList.add(map);
|
|
|
+ map.put("data", list);
|
|
|
+ double reportTime = 0;
|
|
|
+ for (Map<String, Object> m : list) {
|
|
|
+ double t = (double) m.get("time");
|
|
|
+ reportTime += t;
|
|
|
+ }
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
+ map.put("reportTime", df.format(reportTime));
|
|
|
+ List<TimeCalculationShow> timeList = timeCalculationShowMapper.selectList(new QueryWrapper<TimeCalculationShow>().eq("user_id", (String) map.get("id")).eq("date", date));
|
|
|
+ int calculateTime = 0;
|
|
|
+ for (TimeCalculationShow show : timeList) {
|
|
|
+ calculateTime += show.getDuration();
|
|
|
+ }
|
|
|
+ //数据库是秒,时间转换为小时;
|
|
|
+ double d = calculateTime*1.0/3600;
|
|
|
+ map.put("calculateTime", df.format(d));
|
|
|
+ }
|
|
|
} else {
|
|
|
nameList = reportMapper.getReportNameByDate(date,
|
|
|
userMapper.selectById(request.getHeader("Token")).getCompanyId());
|
|
|
- }
|
|
|
-
|
|
|
- for (Map<String, Object> map : nameList) {
|
|
|
- //再根据人分别获取当天的报告
|
|
|
- List<Map<String, Object>> list = reportMapper.getReportByDate(date, (String) map.get("id"));
|
|
|
- map.put("data", list);
|
|
|
- double reportTime = 0;
|
|
|
- for (Map<String, Object> m : list) {
|
|
|
- double t = (double) m.get("time");
|
|
|
- reportTime += t;
|
|
|
- }
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- map.put("reportTime", df.format(reportTime));
|
|
|
- List<TimeCalculationShow> timeList = timeCalculationShowMapper.selectList(new QueryWrapper<TimeCalculationShow>().eq("user_id", (String) map.get("id")).eq("date", date));
|
|
|
- int calculateTime = 0;
|
|
|
- for (TimeCalculationShow show : timeList) {
|
|
|
- calculateTime += show.getDuration();
|
|
|
+ for (Map<String, Object> map : nameList) {
|
|
|
+ //再根据人分别获取当天的报告
|
|
|
+ List<Map<String, Object>> list = reportMapper.getReportByDate(date, (String) map.get("id"));
|
|
|
+ map.put("data", list);
|
|
|
+ double reportTime = 0;
|
|
|
+ for (Map<String, Object> m : list) {
|
|
|
+ double t = (double) m.get("time");
|
|
|
+ reportTime += t;
|
|
|
+ }
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
+ map.put("reportTime", df.format(reportTime));
|
|
|
+ List<TimeCalculationShow> timeList = timeCalculationShowMapper.selectList(new QueryWrapper<TimeCalculationShow>().eq("user_id", (String) map.get("id")).eq("date", date));
|
|
|
+ int calculateTime = 0;
|
|
|
+ for (TimeCalculationShow show : timeList) {
|
|
|
+ calculateTime += show.getDuration();
|
|
|
+ }
|
|
|
+ //数据库是秒,时间转换为小时;
|
|
|
+ double d = calculateTime*1.0/3600;
|
|
|
+ map.put("calculateTime", df.format(d));
|
|
|
}
|
|
|
- //数据库是秒,时间转换为小时;
|
|
|
- double d = calculateTime*1.0/3600;
|
|
|
- map.put("calculateTime", df.format(d));
|
|
|
}
|
|
|
-
|
|
|
httpRespMsg.data = nameList;
|
|
|
} catch (NullPointerException e) {
|
|
|
e.printStackTrace();
|