|
@@ -13,6 +13,7 @@ import com.management.platform.service.LeaveSheetService;
|
|
|
import com.management.platform.service.UserFvTimeService;
|
|
|
import com.management.platform.util.DockWithMLD;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
+import com.management.platform.util.WorkDayCalculateUtils;
|
|
|
import org.springframework.http.*;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -29,10 +30,7 @@ import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -62,7 +60,7 @@ public class UserFvTimeController {
|
|
|
@Resource
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
- private DecimalFormat df = new DecimalFormat("#.0");
|
|
|
+ private DecimalFormat df = new DecimalFormat("#0.0");
|
|
|
|
|
|
@RequestMapping("/get")
|
|
|
public HttpRespMsg get(){
|
|
@@ -377,21 +375,41 @@ public class UserFvTimeController {
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
List<UserFvTime> timeList = userFvTimeService.list(new QueryWrapper<UserFvTime>().between("work_date", startDate, endDate).eq("company_id", user.getCompanyId()).eq("user_id", user.getId()));
|
|
|
double sum = timeList.stream().mapToDouble(UserFvTime::getWorkHours).sum();
|
|
|
- httpRespMsg.setData(df.format(sum));
|
|
|
+ int workDayCount = WorkDayCalculateUtils.getWorkDaysCountInRange(startDate, endDate, timeType.getIncludeWeekends());
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ map.put("workHours", df.format(sum));
|
|
|
+ map.put("workDayCount", workDayCount);
|
|
|
+ if (workDayCount == 0) {
|
|
|
+ map.put("avgWorkDayHours", 0);
|
|
|
+ } else {
|
|
|
+ map.put("avgWorkDayHours", df.format(sum / workDayCount));
|
|
|
+ }
|
|
|
+ httpRespMsg.setData(map);
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/getMinYiWorkHour")
|
|
|
public HttpRespMsg getMinYiWorkHour(HttpServletRequest request, String startDate,String endDate){
|
|
|
HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
- DecimalFormat df = new DecimalFormat("#.0");
|
|
|
+ DecimalFormat df = new DecimalFormat("#0.0");
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
List<UserFvTime> userFvTimeList = userFvTimeService.list(new QueryWrapper<UserFvTime>().between("work_date", startDate, endDate).eq("company_id", user.getCompanyId()).eq("user_id", user.getId()));
|
|
|
double sum=0;
|
|
|
sum = userFvTimeList.stream().mapToDouble(UserFvTime::getWorkHours).sum();
|
|
|
- httpRespMsg.setData(df.format(sum));
|
|
|
+ int workDayCount = WorkDayCalculateUtils.getWorkDaysCountInRange(startDate, endDate, timeType.getIncludeWeekends());
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ map.put("workHours", df.format(sum));
|
|
|
+ map.put("workDayCount", workDayCount);
|
|
|
+ if (workDayCount == 0) {
|
|
|
+ map.put("avgWorkDayHours", 0);
|
|
|
+ } else {
|
|
|
+ map.put("avgWorkDayHours", df.format(sum / workDayCount));
|
|
|
+ }
|
|
|
+ httpRespMsg.setData(map);
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|