| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | KaoQinDao kaoQinDao; |
| | | |
| | | @Override |
| | | public PageInfo<TbKaoqing> findAll(Integer page, Integer limit) { |
| | | QueryWrapper queryWrapper = new QueryWrapper<>(); |
| | | PageHelper.startPage(page,limit); |
| | | PageHelper.startPage(page, limit); |
| | | LocalDate currentDate = LocalDate.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | String formattedDate = currentDate.format(formatter); |
| | |
| | | |
| | | @Override |
| | | public PageInfo<TbKaoqing> findSearch(Integer page, Integer limit, TbKaoqing achor) { |
| | | PageHelper.startPage(page,limit); |
| | | PageHelper.startPage(page, limit); |
| | | List<TbKaoqing> cardList = null; |
| | | String dateStr = achor.getName(); |
| | | String dateStr1 = achor.getBumen(); |
| | |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (achor.getTagid() == null || achor.getTagid().equals("")){ |
| | | //只根据时间查询 |
| | | cardList = kaoQinDao.findSearchTime(achor); |
| | | }else{ |
| | | if (achor.getName() == null || achor.getName().equals("")){ |
| | | LocalDate currentDate = LocalDate.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | String formattedDate = currentDate.format(formatter); |
| | | achor.setName(formattedDate); |
| | | cardList = kaoQinDao.findSearch(achor); |
| | | }else{ |
| | | cardList = kaoQinDao.findSearch(achor); |
| | | } |
| | | //根据时间和输入的姓名进行查询 |
| | | if (achor.getTagid() == null || achor.getTagid().equals("")) { |
| | | String s = achor.getIntime().split(" ")[0]; |
| | | String e = achor.getOuttime().split(" ")[0]; |
| | | String[] start = s.split("-"); |
| | | String[] end = e.split("-"); |
| | | String sql = new String(); |
| | | //只根据时间查询 |
| | | LocalDate startDate = LocalDate.of(Integer.parseInt(start[0]), Integer.parseInt(start[1]), Integer.parseInt(start[2])); |
| | | LocalDate endDate = LocalDate.of(Integer.parseInt(end[0]), Integer.parseInt(end[1]), Integer.parseInt(end[2])); |
| | | long numOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate); |
| | | // 计算两个日期之间的天数 |
| | | for (int i = 1; i <= numOfDaysBetween; i++) { |
| | | LocalDate date = startDate.plusDays(i); |
| | | String riqi = date.toString().split("-")[0]+date.toString().split("-")[1]+date.toString().split("-")[2]; |
| | | sql += " UNION select * from tb_kaoqing_" + riqi+" "; |
| | | achor.setBumen(sql);} |
| | | cardList = kaoQinDao.findSearchTime(achor); |
| | | } else { |
| | | if (achor.getName() == null || achor.getName().equals("")) { |
| | | LocalDate currentDate = LocalDate.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | String formattedDate = currentDate.format(formatter); |
| | | achor.setName(formattedDate); |
| | | cardList = kaoQinDao.findSearch(achor); |
| | | } else { |
| | | cardList = kaoQinDao.findSearch(achor); |
| | | } |
| | | //根据时间和输入的姓名进行查询 |
| | | |
| | | } |
| | | } |
| | | PageInfo<TbKaoqing> info = new PageInfo<>(cardList); |
| | | return info; |
| | | } |