|
@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.time.ZoneOffset;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.DateTimeParseException;
|
|
@@ -117,11 +118,22 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
|
|
|
public HttpRespMsg getDuration(String startDate, String endDate, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
- httpRespMsg.data = timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
|
|
|
+ List<TimeCalculation> dataList = timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
|
|
|
.eq("user_id", request.getHeader("Token"))
|
|
|
+ .eq("action_type", 0)
|
|
|
.between("date",
|
|
|
LocalDate.parse(startDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")),
|
|
|
- LocalDate.parse(endDate, DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
|
|
+ LocalDate.parse(endDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")))
|
|
|
+ .orderByAsc("start_time"));
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
+ for (TimeCalculation timeCalculation : dataList) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("startTime", LocalDateTime.of(timeCalculation.getDate(), timeCalculation.getStartTime()));
|
|
|
+ map.put("endTime", LocalDateTime.of(timeCalculation.getDate(), timeCalculation.getEndTime()));
|
|
|
+ map.put("duration", timeCalculation.getDuration());
|
|
|
+ resultList.add(map);
|
|
|
+ }
|
|
|
+ httpRespMsg.data = resultList;
|
|
|
} catch (NullPointerException e) {
|
|
|
httpRespMsg.setError("验证失败");
|
|
|
} catch (DateTimeParseException e) {
|