package com.yc.education.controller.admin;/**
 * huangpan
 * 2019/10/16
 * energy
 */

import com.github.pagehelper.PageInfo;
import com.yc.education.model.Coom;
import com.yc.education.model.Coomclassify;
import com.yc.education.model.Orders;
import com.yc.education.model.Personnel;
import com.yc.education.service.CoomService;
import com.yc.education.service.CoomclassifyService;
import com.yc.education.service.OrdersService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 *@ClassName RommController
 *@Description TODO
 *@Author 预约信息
 *@Date 2019/10/16 17:51
 *@Version 1.0
 */
@Controller
public class RommController {
    @Autowired
    CoomService coomService;
    @Autowired
    CoomclassifyService coomclassifyService;
    @Autowired
    OrdersService ordersService;

    /*会议室预约*/
    /*@RequestMapping("roomlist.html")
    public ModelAndView getRoom(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                @RequestParam(value = "pageSize",defaultValue = "6") Integer pageSize,HttpSession session){
        Personnel sesionPer =(Personnel) session.getAttribute("sesionPer");
        if(sesionPer==null||sesionPer.equals("")){
            return new ModelAndView("redirect:index.html");
        }else {
        ModelAndView modelAndView=new ModelAndView("xingtai/roomlist");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = df.format(new Date());
        List<Coomclassify> coomFys = coomclassifyService.getCoomFys();
        List<Orders> ordersStartEnd = ordersService.getOrdersStartEnd(format, format);
        List<Coom> coomL=coomService.getCooms();
        List<Coom> coomList=coomService.getCoomt(pageNum, pageSize);
        Set<Coom> coomSet=new HashSet<>();
        for (int i=0;i<coomList.size();i++){
            for (int j=0;j<ordersStartEnd.size();j++){
                if(coomList.get(i).getId()==ordersStartEnd.get(j).getCid()){
                    coomList.remove(i);
                    i--;
                    break;
                }
            }
        }
        List<Orders> selOrders=new ArrayList<>();
    for (Coom cf:coomList){
        List<Orders> ordersStartEndIds = ordersService.getOrdersStartEndIds(cf.getId(), format);
       for (Orders or:ordersStartEndIds){
           selOrders.add(or);
       }
    }
          modelAndView.addObject("coomList", new PageInfo<>(coomList));
          modelAndView.addObject("coomL", coomL);
          modelAndView.addObject("coomFys", coomFys);
          modelAndView.addObject("selOrders", selOrders);
          modelAndView.addObject("startTime", format);
             modelAndView.addObject("endTime", format);
          modelAndView.addObject("url", "roomlist.html");
          modelAndView.addObject("pageNums", pageNum);
        return modelAndView;}
    }*/

    /*提交预约*/
    @RequestMapping("orders-save.html")
    /*@DateTimeFormat(pattern = "yyyy-MM-dd")Date startTime, Object endTime,*/
    public ModelAndView orders_save(Orders orders, String sumTime,String cpt,HttpSession session,Integer cid){
        Personnel sesionPer =(Personnel) session.getAttribute("sesionPer");
        String[] spant=sumTime.split(" 到 ");
        String startime=spant[0];
        String endTime=spant[1];
        System.err.println(startime+"startTime");
        System.err.println(endTime+"end");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String commentdatemin = df.format(new Date());
        System.err.println(cid);
        List<Orders> ordersStartEndId = ordersService.getOrderCfpId(cid, startime, endTime);
        Coom coomsById = coomService.getCoomsById(cid);
        List<Coomclassify> coomclassifies = coomclassifyService.getcoomFyId(coomsById.getCid());
        Coomclassify coomclassify=coomclassifies.get(0);
 /*       Coomclassify coomclassify=(Coomclassify)
                coomclassifies;*/
        int numberst=0;
        if (orders.getNumbers()<=coomclassify.getMaxs()){
            numberst=coomclassify.getId();
        }

        /*Coom coomsById = coomService.getCoomsById(orders.getCid());*/
 /*       Integer cout=coomsById.getCid();
       Coomclassify coomclassify=(Coomclassify) coomclassifyService.getcoomFyId(cout);*/

        if (coomsById.getCid()==numberst) {
            if (ordersStartEndId.size() == 0) {
                orders.setStarttime(startime);
                orders.setEndtime(endTime);
                orders.setOrdertime(commentdatemin);
                orders.setPid(sesionPer.getId());
                ordersService.save(orders);
                return getOrders(session, 1, 6, "预约成功");
                /*ordersService.getOrdersPid()*/
            } else {
                return getOrders(session, 1, 6, "预约失败");
            }
        }else{
            return getOrders(session, 1, 6, "使用人数不符合");
        }
    }
    /*查询已预约信息*/
    @RequestMapping("order.html")
    public ModelAndView getOrders(HttpSession session,@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                  @RequestParam(value = "pageSize",defaultValue = "6") Integer pageSize,String returnst){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = df.format(new Date());
        Personnel sesionPer =(Personnel) session.getAttribute("sesionPer");
        if(sesionPer==null||sesionPer.equals("")){
            return new ModelAndView("redirect:index.html");
        }else {
            ModelAndView modelAndView = new ModelAndView("xingtai/order");
            List<Orders> ordersPid = ordersService.getOrdersPid(sesionPer.getId(), pageNum, pageSize);
            List<Coom> cooms = coomService.getCooms();
            modelAndView.addObject("cooms", cooms);
            modelAndView.addObject("ordersPid", new PageInfo<>(ordersPid));
            modelAndView.addObject("pageNums", pageNum);
            modelAndView.addObject("returnst", returnst);
            modelAndView.addObject("Url", "order.html");
            modelAndView.addObject("startTime", format);
            modelAndView.addObject("endTime", format);
            return modelAndView;
        }
    }
    /* 删除预约信息*/
    @RequestMapping("delOrderById.html")
    @ResponseBody
    public void delOrderById(@Param("id") Integer id){
        ordersService.delOrderById(id);
    }

/*通过人数查询*/
    @RequestMapping("coomlists.html")
    public ModelAndView comlistCfpId(Integer cfpid,@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                     @RequestParam(value = "pageSize",defaultValue = "6") Integer pageSize,HttpSession session){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = df.format(new Date());
        ModelAndView modelAndView=new ModelAndView("xingtai/roomlist");
        List<Coom> coomlist=coomService.getCoomCid(cfpid);
        List<Coomclassify> coomFys = coomclassifyService.getCoomFys();
        List<Coom> coomCid = coomService.getCoomCid(cfpid);
        List<Orders> selOrders=new ArrayList<>();
        for (Coom item:coomCid){
            List<Orders> ordersStartEndIds = ordersService.getOrdersStartEndIds(item.getId(), format);
            for (Orders o:ordersStartEndIds){
                selOrders.add(o);
            }
        }
        modelAndView.addObject("cfpid", cfpid);
        modelAndView.addObject("coomList",new PageInfo<>(coomCid));
        modelAndView.addObject("coomFys", coomFys);
        modelAndView.addObject("coomL",coomlist );
        modelAndView.addObject("selOrders", selOrders);
        modelAndView.addObject("url", "coomlists.html");
        modelAndView.addObject("pageNums", pageNum);
        modelAndView.addObject("cid", coomlist.get(0).getId());
        session.setAttribute("commcfpid", cfpid);
        return modelAndView;

    }
    /*通过会议室查询*/
    @RequestMapping("coomlistC.html")
    public ModelAndView coomlistC(Integer cid,HttpSession session){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = df.format(new Date());
        ModelAndView modelAndView=new ModelAndView("xingtai/roomlist");
        List<Coom> coomlist=coomService.getCooms();

         List <Coom>  coomCid = coomService.selCoomid(cid);
        List<Coomclassify> coomFys= coomclassifyService.getcoomFyId(coomCid.get(0).getCid());
        List<Orders> selOrders=new ArrayList<>();
            List<Orders> ordersStartEndIds = ordersService.getOrdersStartEndIds(coomCid.get(0).getId(),format);
            for (Orders o:ordersStartEndIds){
                selOrders.add(o);
        }
        modelAndView.addObject("cid", cid);
        modelAndView.addObject("coomList", new PageInfo<>(coomCid));
        modelAndView.addObject("coomFys", coomFys);
        modelAndView.addObject("coomL",coomCid );
        modelAndView.addObject("selOrders", selOrders);
        modelAndView.addObject("url", "coomlistC.html");
        modelAndView.addObject("cfpid", coomFys.get(0).getId());
        session.setAttribute("coomcid", cid);
        return modelAndView;
    }
    /*根据时间查询*/
    @RequestMapping("coomlistTime.html")
    public ModelAndView coomlistTime(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date startTime,
                                     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date endTime
    ,@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                     @RequestParam(value = "pageSize",defaultValue = "6" )Integer pageSize
    ){
        ModelAndView modelAndView=new ModelAndView("xingtai/roomlist");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = df.format(startTime);
        String format1=df.format(endTime);
        if(format==null&&format.equals(""))
            format=df.format(new Date());
        if(format1==null&&format1.equals(""))
            format1=df.format(new Date());
        List<Coomclassify> coomFys = coomclassifyService.getCoomFys();
        List<Orders> ordersStartEnd = ordersService.getOrdersStartEnd(format, format1);
        List<Coom> coomL=coomService.getCooms();
        List<Coom> coomList=coomService.getCoomt(pageNum, pageSize);
        for (int i=0;i<coomList.size();i++){
            for (int j=0;j<ordersStartEnd.size();j++){
                if(coomList.get(i).getId()==ordersStartEnd.get(j).getCid()){
                    coomList.remove(i);
                    i--;
                    break;
                }
            }
        }
        List<Orders> selOrders=new ArrayList<>();
        for (Coom cf:coomList){
            List<Orders> ordersStartEndIds = ordersService.getOrdersStartEndIds(cf.getId(), format);
            for (Orders or:ordersStartEndIds){
                selOrders.add(or);
            }
        }
        for (Orders r:selOrders){
            System.err.println(r.getStarttime()+"结束时间:"+r.getEndtime());
        }
        modelAndView.addObject("coomList", new PageInfo<>(coomList));
        modelAndView.addObject("coomL", coomL);
        /* modelAndView.addObject("commentdatemin", commentdatemin);*/
        modelAndView.addObject("coomFys", coomFys);
        modelAndView.addObject("selOrders", selOrders);
        modelAndView.addObject("startTime", format);
        modelAndView.addObject("endTime", format1);
        modelAndView.addObject("url", "coomlistTime.html");
        modelAndView.addObject("pageNums", pageNum);
        return modelAndView;

    }
    /*根据预约人，时间搜索已预约信息*/
    @RequestMapping("orderTime.html")
    public ModelAndView orderTime(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date startTime,
                                  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date endTime,HttpSession session,@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                  @RequestParam(value = "pageSize",defaultValue = "6") Integer pageSize){
        Personnel sesionPesr =(Personnel) session.getAttribute("sesionPer");
        if(sesionPesr==null||sesionPesr.equals("")){
            return new ModelAndView("redirect:index.html");
        }else {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String format = df.format(startTime);
            String format1 = df.format(endTime);
            String format3 = format;
            String format4 = format3;
            if (format == null && format.equals(""))
                format = df.format(new Date());
            if (format1 == null && format1.equals(""))
                format1 = df.format(new Date());
            Personnel sesionPer = (Personnel) session.getAttribute("sesionPer");
            ModelAndView modelAndView = new ModelAndView("xingtai/order");
            List<Orders> ordersPid = ordersService.getOrderCidTime(sesionPer.getId(), format, format1, pageNum, pageSize);
            modelAndView.addObject("ordersPid", new PageInfo<>(ordersPid));
            modelAndView.addObject("Url", "orderTime.html");
            modelAndView.addObject("pageNums", pageNum);
            List<Coom> cooms = coomService.getCooms();
            modelAndView.addObject("cooms", cooms);
            modelAndView.addObject("startTime", format);
            modelAndView.addObject("endTime", format1);

            return modelAndView;
        }
    }
    /*模拟关联查询*/
    @RequestMapping("tts.html")
    public ModelAndView tts(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date startTime,
                            @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date endTime,HttpSession session,
                            @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                            @RequestParam(value = "pageSize",defaultValue = "6" )Integer pageSize){
        Object coomcid = session.getAttribute("coomcid");
        Object commcfpid = session.getAttribute("commcfpid");
        ModelAndView modelAndView=new ModelAndView("xingtai/roomlist");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = df.format(startTime);
        String format1=df.format(endTime);
        List<Coomclassify> coomFys = coomclassifyService.getCoomFys();
        List<Orders> ordersStartEnd = ordersService.getOrdersStartEnd(format, format1);
        List<Coom> coomL=coomService.getCooms();
        List<Coom> coomList=coomService.getCoomt(pageNum, pageSize);
        for (int i=0;i<coomList.size();i++){
            for (int j=0;j<ordersStartEnd.size();j++){
                if(coomList.get(i).getId()==ordersStartEnd.get(j).getCid()){
                    coomList.remove(i);
                    i--;
                    break;
                }
            }
        }
        if (coomcid!=null&&!coomcid.equals("")){
            for (int i=0;i<coomList.size();i++){
                if (coomList.get(i).getId()!=coomcid){
                    coomList.remove(i);
                    i--;
                }
            }
        }
        if (commcfpid!=null&&!commcfpid.equals("")){
            for (int z=0;z<coomList.size();z++){
                if (coomList.get(z).getCid()!=commcfpid){
                    coomList.remove(z);
                   z--;
                }
            }
        }
        List<Orders> selOrders=new ArrayList<>();
        for (Coom cf:coomList){
            List<Orders> ordersStartEndIds = ordersService.getOrdersStartEndIds(cf.getId(), format);
            for (Orders or:ordersStartEndIds){
                selOrders.add(or);
            }
        }
        modelAndView.addObject("coomList", new PageInfo<>(coomList));
        modelAndView.addObject("coomL", coomL);
        modelAndView.addObject("coomFys", coomFys);
        modelAndView.addObject("selOrders", selOrders);
        modelAndView.addObject("startTime", format);
        modelAndView.addObject("endTime", format1);
        modelAndView.addObject("url", "coomlistTime.html");
        modelAndView.addObject("pageNums", pageNum);
        modelAndView.addObject("cfpid", (Integer)commcfpid);
        modelAndView.addObject("cid", (Integer)coomcid);
        return modelAndView;

    }

    /*根据时间查询*/
    @RequestMapping("gaoguang.html")
    public ModelAndView gaoguang(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date startTime,
                                 @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date endTime,HttpSession session,
                                 @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                 @RequestParam(value = "pageSize",defaultValue = "6" )Integer pageSize){
        Personnel sesionPer =(Personnel) session.getAttribute("sesionPer");
        if(sesionPer==null||sesionPer.equals("")){
            return new ModelAndView("redirect:index.html");
        }else {
        ModelAndView modelAndView=new ModelAndView("xingtai/roomlist");
        Integer coomcid =(Integer) session.getAttribute("coomcid");/*会议室*/
        Integer commcfpid =(Integer) session.getAttribute("commcfpid");/*人数*/
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = df.format(startTime);
        String format1=df.format(endTime);
        if(format==null&&format.equals(""))
            format=df.format(new Date());
        if(format1==null&&format1.equals(""))
            format1=df.format(new Date());
        List<Coom> idNotIn = coomService.getIdNotIn(coomcid, format, format1, pageNum, pageSize, commcfpid);
        List<Orders> selOrders=new ArrayList<>();
        for (Coom cf:idNotIn){
            List<Orders> ordersStartEndIds = ordersService.getOrdersStartEndIds(cf.getId(), format);
            for (Orders or:ordersStartEndIds){
                selOrders.add(or);
            }
        }
        List<Coomclassify> coomclassifies=new ArrayList<>();
        List<Coom> cooms=new ArrayList<>();
        Integer cid=0;
        if (commcfpid!=null&&!commcfpid.equals("")){
            coomclassifies = coomclassifyService.getcoomFyId(commcfpid);
            cooms=coomService.getCoomCid(commcfpid);
            cid=cooms.get(0).getId();
        }if (coomcid!=null&&!coomcid.equals("")){
            cooms=coomService.selCoomid(coomcid);
            cid=coomcid;
            coomclassifies=coomclassifyService.getcoomFyId(cooms.get(0).getCid());
            commcfpid=coomclassifies.get(0).getId();
        }else{

            coomclassifies=  coomclassifyService.getCoomFys();
            cooms= coomService.getCooms();
        }
        modelAndView.addObject("startTime", format);
        modelAndView.addObject("endTime", format1);
        modelAndView.addObject("selOrders", selOrders);
        modelAndView.addObject("cfpid", commcfpid);
        modelAndView.addObject("cid", cid);
        modelAndView.addObject("coomList", new PageInfo<>(idNotIn));
        modelAndView.addObject("coomL", cooms);
        modelAndView.addObject("coomFys", coomclassifies);
        modelAndView.addObject("url", "gaoguang.html");
        modelAndView.addObject("pageNums", pageNum);
        session.setAttribute("startTime", format);
        session.setAttribute("endTime", format1);
        return modelAndView;}
    }
    /*根据人数搜索信息*/
    @RequestMapping("gaoguangshike.html")
    public ModelAndView gaoguangshike( @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                       @RequestParam(value = "pageSize",defaultValue = "6" )Integer pageSize,Integer cfpid,HttpSession session){
        Personnel sesionPer =(Personnel) session.getAttribute("sesionPer");
        if(sesionPer==null||sesionPer.equals("")){
            return new ModelAndView("redirect:index.html");
        }else {
        ModelAndView modelAndView=new ModelAndView("xingtai/roomlist");
        Integer coomcid =(Integer) session.getAttribute("coomcid");/*会议室*/
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String startTime =(String) session.getAttribute("startTime");
        String endTime =(String) session.getAttribute("endTime");
        if(startTime==null||startTime.equals("")){
            startTime=df.format(new Date());}
        if(endTime==null||endTime.equals("")){
            endTime=df.format(new Date());}
        List<Coom> idNotIn = coomService.getIdNotIn(coomcid, startTime, endTime, pageNum, pageSize, cfpid);
        List<Orders> selOrders=new ArrayList<>();
        for (Coom cf:idNotIn){
            List<Orders> ordersStartEndIds = ordersService.getOrdersStartEndIds(cf.getId(), endTime);
            for (Orders or:ordersStartEndIds){
                selOrders.add(or);
            }
        }
        List<Coomclassify> coomclassifies=coomclassifyService.getcoomFyId(cfpid);
        List<Coom> coomCids = coomService.getCoomCid(cfpid);
        coomcid=coomCids.get(0).getId();
        modelAndView.addObject("selOrders", selOrders);
        modelAndView.addObject("startTime", startTime);
        modelAndView.addObject("endTime", endTime);
        modelAndView.addObject("cfpid", cfpid);
        modelAndView.addObject("cid", coomcid);
        modelAndView.addObject("coomList", new PageInfo<>(idNotIn));
        modelAndView.addObject("coomL", coomCids);
        modelAndView.addObject("coomFys", coomclassifies);
        modelAndView.addObject("url", "gaoguangshike,html");
        modelAndView.addObject("pageNums", pageNum);
        session.setAttribute("commcfpid", cfpid);
        return modelAndView;}
    }
    /*根据会议室查询信息*/
    @RequestMapping("gaoguangsk.html")
    public ModelAndView gaoguangsk(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                   @RequestParam(value = "pageSize",defaultValue = "6" )Integer pageSize,Integer cid,HttpSession session){
        Personnel sesionPer =(Personnel) session.getAttribute("sesionPer");
        if(sesionPer==null||sesionPer.equals("")){
            return new ModelAndView("redirect:index.html");
        }else {
        ModelAndView modelAndView=new ModelAndView("xingtai/roomlist");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Integer commcfpid =(Integer) session.getAttribute("commcfpid");/*人数*/
        String startTime =(String) session.getAttribute("startTime");
        String endTime =(String) session.getAttribute("endTime");
        if(startTime==null||startTime.equals("")){
            startTime=df.format(new Date());}
        if(endTime==null||endTime.equals("")){
            endTime=df.format(new Date());}
        List<Coom> idNotIn = coomService.getIdNotIn(cid, startTime, endTime, pageNum, pageSize, commcfpid);
        List<Orders> selOrders=new ArrayList<>();
        for (Coom cf:idNotIn){
            List<Orders> ordersStartEndIds = ordersService.getOrdersStartEndIds(cf.getId(), endTime);
            for (Orders or:ordersStartEndIds){
                selOrders.add(or);
            }
        }
        List<Coom> cooms = coomService.selCoomid(cid);
        List<Coomclassify> coomclassifies = coomclassifyService.getcoomFyId(cooms.get(0).getCid());
        modelAndView.addObject("startTime", startTime);
        modelAndView.addObject("endTime", endTime);
        modelAndView.addObject("cfpid", coomclassifies.get(0).getId());
        modelAndView.addObject("selOrders", selOrders);
        modelAndView.addObject("cid", cid);
        modelAndView.addObject("coomList", new PageInfo<>(idNotIn));
        modelAndView.addObject("coomL", cooms);
        modelAndView.addObject("coomFys", coomclassifies);
        modelAndView.addObject("url", "gaoguangsk,html");
        modelAndView.addObject("pageNums", pageNum);
        session.setAttribute("coomcid", cid);
        return modelAndView;}
    }
    /*查询所有*/
    @RequestMapping("roomlist.html")
    public ModelAndView roomlist(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                 @RequestParam(value = "pageSize",defaultValue = "6") Integer pageSize,HttpSession session){
        Personnel sesionPer =(Personnel) session.getAttribute("sesionPer");
        if(sesionPer==null||sesionPer.equals("")){
            return new ModelAndView("redirect:index.html");
        }else {
        ModelAndView modelAndView=new ModelAndView("xingtai/roomlist");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = df.format(new Date());
        List<Coom> idNotIn = coomService.getIdNotIn(null, format, format, pageNum, pageSize, null);
        List<Orders> selOrders=new ArrayList<>();
        for (Coom cf:idNotIn){
            List<Orders> ordersStartEndIds = ordersService.getOrdersStartEndIds(cf.getId(), format);
            for (Orders or:ordersStartEndIds){
                selOrders.add(or);
            }
        }
        List<Coom> cooms = coomService.getCooms();
        List<Coomclassify> coomclassifies = coomclassifyService.getCoomFys();
        modelAndView.addObject("startTime", format);
        modelAndView.addObject("endTime", format);
        modelAndView.addObject("coomList", new PageInfo<>(idNotIn));
        modelAndView.addObject("selOrders", selOrders);
        modelAndView.addObject("coomL", cooms);
        modelAndView.addObject("coomFys", coomclassifies);
        modelAndView.addObject("url", "roomlist.html");
        modelAndView.addObject("pageNums", pageNum);
        session.removeAttribute("coomcid");
        session.removeAttribute("commcfpid");
        session.removeAttribute("startTime");
        session.removeAttribute("endTime");
        return modelAndView;}
    }
}
