提交 df7be165 authored 作者: yangqi's avatar yangqi

1

上级 5ecb3257
...@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
...@@ -83,15 +84,8 @@ public class LisaController { ...@@ -83,15 +84,8 @@ public class LisaController {
@NoAuth @NoAuth
@GetMapping("/test") @GetMapping("/test")
public ApiResponse<Object> test(String date) throws Exception { public ApiResponse<Object> test(String start, String end) throws Exception {
Date d = new Date(); equipmentService.getLogList(start, end);
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
System.out.println("日期" + f.format(d.getTime()));
Calendar calendar = Calendar.getInstance();
Date d1 = new SimpleDateFormat("yyyy-MM-dd").parse("2022-12-12");
calendar.setTime(d1);
calendar.add(Calendar.DATE,-1);
System.out.println("日期" + f.format(d1.getTime()));
return new ApiResponse<>(); return new ApiResponse<>();
} }
} }
package cn.lefull.common.utils;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
/**
* @author 杨奇
*/
public class ArrayUtils {
/**
* 根据开始时间和结束时间获取所有时间的list
* @param startDate
* @param endDate
* @return
*/
public static List<LocalDate> getTimeList(LocalDate startDate, LocalDate endDate) {
List<LocalDate> dateList = new ArrayList<>();
LocalDate tempData = startDate;
while (true) {
dateList.add(tempData);
if (tempData.compareTo(endDate) == 0) {
return dateList;
}
tempData = tempData.plusDays(1);
}
}
}
...@@ -5,6 +5,8 @@ import cn.lefull.interaction.vo.face.EntityListVO; ...@@ -5,6 +5,8 @@ import cn.lefull.interaction.vo.face.EntityListVO;
import cn.lefull.interaction.vo.face.EquipmentListVO; import cn.lefull.interaction.vo.face.EquipmentListVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
/** /**
* @author 杨奇 * @author 杨奇
*/ */
...@@ -29,4 +31,6 @@ public interface EquipmentService { ...@@ -29,4 +31,6 @@ public interface EquipmentService {
boolean searchFace(int apartmentId, String url) throws Exception; boolean searchFace(int apartmentId, String url) throws Exception;
void addDateLog(String date) throws Exception; void addDateLog(String date) throws Exception;
void getLogList(String start, String end) throws Exception;
} }
package cn.lefull.service.lisa; package cn.lefull.service.lisa;
import cn.lefull.common.utils.ArrayUtils;
import cn.lefull.common.utils.PageBuilder; import cn.lefull.common.utils.PageBuilder;
import cn.lefull.common.utils.Utils; import cn.lefull.common.utils.Utils;
import cn.lefull.interaction.pageresp.Pagination; import cn.lefull.interaction.pageresp.Pagination;
...@@ -19,6 +20,8 @@ import org.springframework.util.CollectionUtils; ...@@ -19,6 +20,8 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
/** /**
...@@ -382,4 +385,12 @@ public class EquipmentServiceImpl implements EquipmentService { ...@@ -382,4 +385,12 @@ public class EquipmentServiceImpl implements EquipmentService {
} }
} }
} }
@Override
public void getLogList(String start, String end) throws Exception {
LocalDate startDate = LocalDate.parse(start, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate endDate = LocalDate.parse(end, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<LocalDate> dateList = ArrayUtils.getTimeList(startDate, endDate);
System.out.println(dateList);
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论