package com.happy.action;

import com.baidubce.model.User;
import com.happy.Model.AdminManager;
import com.happy.Model.Hotel;
import com.happy.Model.House;
import com.happy.Model.weixin.Users;
import com.happy.Until.*;
import com.happy.Until.Enum.B;
import com.happy.Until.Enum.TempEnum;
import com.happy.constant.ResultStatusCode;
import com.happy.dao.UserVisitsDao;
import com.happy.dto.IPage;
import com.happy.dto.ManageHouseDto;
import com.happy.dto.OwnerHouseDto;
import com.happy.dto.townshipCountDTO;
import com.happy.service.*;
import com.happy.vo.*;
import com.opensymphony.xwork2.ActionSupport;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 首页进去Action请求交互
 */
public class AppHomePageAction extends ActionSupport implements ServletRequestAware {

    private HttpServletRequest request;
    public HttpServletResponse response;

    @Resource
    public UserVisitsDao userVisitsDao;
    @Resource
    public UserService userService;
    @Resource
    public AppHomePageService appHomePageService;
    @Resource
    public HotelService hotelService;
    @Resource
    public HouseService houseService;
    @Resource
    public FileService fileService;
    @Resource
    public AdminManagerService adminManagerService;
    @Resource(name = "housePriceService")
    private HousePriceService housePriceService;

    public int page; // 当前页
    public int rows;// 每页显示的行数rows

    public Integer id = new Integer(0);
    public String status;
    public String hotelId; //选择的当前酒店的id
    public String queryStartTime; // 查询开始时间
    public String queryEndTime; // 查询结束时间

    public String userCode; // 第一次进来获取用户的code
    public String queryValue; // 首页查寻搜索关键词
    private String hotel_township; // 所属乡镇
    public String userId; // 用户id
    public int type;

    public HttpServletRequest getRequest() {
        return request;
    }

    public void setRequest(HttpServletRequest request) {
        this.request = request;
    }

    public void setServletRequest(HttpServletRequest request) {
        this.request = request;
    }

    public HttpServletResponse getResponse() {
        return response;
    }

    public void setResponse(HttpServletResponse response) {
        this.response = response;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }


    /**
     * 进入首页,展示优选民宿数据列表
     * 优选按总评分倒序排序
     * queryValue 查询字段
     * hotel_townshipId 所属乡镇
     *
     * @return
     */
    public String preferredPage() {
        // 获取民宿列表
        IPage<Hotel> iPage = appHomePageService.getPreferredHotelList(queryValue, hotel_township, type, page, rows);
        if (iPage.getPageList() != null && iPage.getPageList().size() > 0) {
            List<Integer> managerIds = iPage.getPageList().stream().map(Hotel::getManagerId).collect(Collectors.toList());

            //2023-09-22 A-jax 获取最低价
            if (managerIds.size() > 0) {
                List<HotelPriceDataVo> prices = housePriceService.queryHotelPriceDatas(StringUtils.join(managerIds, ","), TimeExchange.getDateStr());

                List<HotelPriceOneDataVo> oneDatas = new ArrayList<>();
                //获取当天的
                for (HotelPriceDataVo hp : prices) {
                    HotelPriceOneDataVo oneData = new HotelPriceOneDataVo();
                    oneData.setSetDate(TimeExchange.getDateStr());
                    oneData.setCreateDate(hp.getCreateDate());
                    oneData.setPrice(hp.getPrice());
                    oneData.setManagerId(hp.getManagerId());
                    oneDatas.add(oneData);
                }

                /**
                 * 根据房型ID处理重复的数据
                 */
                List<HotelPriceOneDataVo> newOneDatas = new ArrayList<>();
                if (oneDatas.size() > 0) {
                    for (Integer managerId : managerIds) {
                        Optional<HotelPriceOneDataVo> one = oneDatas.stream().filter(e -> e.getManagerId().equals(managerId)).sorted(Comparator.comparing(HotelPriceOneDataVo::getCreateDate, Comparator.reverseOrder())).findFirst();
                        if (one != null && one.isPresent()) {
                            HotelPriceOneDataVo oneData = new HotelPriceOneDataVo();
                            oneData.setSetDate(one.get().getSetDate());
                            oneData.setCreateDate(one.get().getCreateDate());
                            oneData.setPrice(one.get().getPrice());
                            oneData.setManagerId(one.get().getManagerId());
                            newOneDatas.add(oneData);
                        }
                    }
                }

                /**
                 * 获取商家集合中最低房型价格
                 */
                List<PriceHotelDataVo> mins = houseService.gethotelMinPrice(StringUtils.join(managerIds, ","));
                DecimalFormat decimalFormat = new DecimalFormat("#####.##");
                for (Hotel hotel : iPage.getPageList()) {
                    //2023-11-09 A-jax 获取剩余房间数
                    List<OwnerHouseDto> result = adminManagerService.getTotalManageCount(hotel_township, type);
                    if(result != null && result.size() > 0){
                        Optional<OwnerHouseDto> mhd = result.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
                        if(mhd != null && mhd.isPresent()){
                            hotel.setRoomNumber(mhd.get().getResidueHouseNum());
                            hotel.setRoom_number_calc(mhd.get().getTotalHouseNum().toString());
                        }
                    }
                    AdminManager adminManager = adminManagerService.getById(hotel.getManagerId());
                    hotel.setType(String.valueOf(adminManager.getType()));
                    Optional<HotelPriceOneDataVo> one = null;
                    if (newOneDatas!=null){
                        one = newOneDatas.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
                    }
                    Optional<PriceHotelDataVo> min = null;
                    if (mins!=null){
                        min = mins.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
                    }
                    if (one != null && one.isPresent() && min != null && min.isPresent()) {
                        if(one.get().getPrice() > min.get().getPrice()){
                            hotel.setMin_price(decimalFormat.format(min.get().getPrice()));
                        }else {
                            hotel.setMin_price(decimalFormat.format(one.get().getPrice()));
                        }
                    } else {
                        if (min != null && min.isPresent()) {
                            hotel.setMin_price(decimalFormat.format(min.get().getPrice()));
                        }
                    }
                }

            }
        }

        // 用户访问量数据
        userVisitsDao.add(userId);
        ResponseUtil.writeJsonIPage(ServletActionContext.getResponse(), iPage);
        return null;
    }

    /**
     * 进入首页,展示精选民宿数据列表
     * 精选按总销售量倒序排序
     * queryValue 查询字段
     * hotel_townshipId 所属乡镇
     *
     * @return
     */
    public String selectedPage() {
        // 获取民宿列表
        IPage<Hotel> iPage = appHomePageService.getSelectedHotelList(queryValue, hotel_township, type, page, rows);
        if (iPage.getPageList() != null && iPage.getPageList().size() > 0) {
            List<Integer> managerIds = iPage.getPageList().stream().map(Hotel::getManagerId).collect(Collectors.toList());

            //2023-09-22 A-jax 获取最低价
            if (managerIds.size() > 0) {
                List<HotelPriceDataVo> prices = housePriceService.queryHotelPriceDatas(StringUtils.join(managerIds, ","), TimeExchange.getDateStr());

                List<HotelPriceOneDataVo> oneDatas = new ArrayList<>();
                //获取当天的
                for (HotelPriceDataVo hp : prices) {
                    HotelPriceOneDataVo oneData = new HotelPriceOneDataVo();
                    oneData.setSetDate(TimeExchange.getDateStr());
                    oneData.setCreateDate(hp.getCreateDate());
                    oneData.setPrice(hp.getPrice());
                    oneData.setManagerId(hp.getManagerId());
                    oneDatas.add(oneData);
                }

                /**
                 * 根据房型ID处理重复的数据
                 */
                List<HotelPriceOneDataVo> newOneDatas = new ArrayList<>();
                if (oneDatas.size() > 0) {
                    for (Integer managerId : managerIds) {
                        Optional<HotelPriceOneDataVo> one = oneDatas.stream().filter(e -> e.getManagerId().equals(managerId)).sorted(Comparator.comparing(HotelPriceOneDataVo::getCreateDate, Comparator.reverseOrder())).findFirst();
                        if (one != null && one.isPresent()) {
                            HotelPriceOneDataVo oneData = new HotelPriceOneDataVo();
                            oneData.setSetDate(one.get().getSetDate());
                            oneData.setCreateDate(one.get().getCreateDate());
                            oneData.setPrice(one.get().getPrice());
                            oneData.setManagerId(one.get().getManagerId());
                            newOneDatas.add(oneData);
                        }
                    }
                }

                /**
                 * 获取商家集合中最低房型价格
                 */
                List<PriceHotelDataVo> mins = houseService.gethotelMinPrice(StringUtils.join(managerIds, ","));
                DecimalFormat decimalFormat = new DecimalFormat("#####.##");
                for (Hotel hotel : iPage.getPageList()) {
                    //2023-11-09 A-jax 获取剩余房间数
                    List<OwnerHouseDto> result = adminManagerService.getTotalManageCount(hotel_township, type);
                    if(result != null && result.size() > 0){
                        Optional<OwnerHouseDto> mhd = result.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
                        if(mhd != null && mhd.isPresent()){
                            hotel.setRoomNumber(mhd.get().getResidueHouseNum());
                            hotel.setRoom_number_calc(mhd.get().getTotalHouseNum().toString());
                        }
                    }
                    AdminManager adminManager = adminManagerService.getById(hotel.getManagerId());
                    hotel.setType(String.valueOf(adminManager.getType()));
                    Optional<HotelPriceOneDataVo> one = null;
                    if (newOneDatas!=null){
                        one = newOneDatas.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
                    }
                    Optional<PriceHotelDataVo> min = null;
                    if (mins!=null){
                        min = mins.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
                    }
                    if (one != null && one.isPresent() && min != null && min.isPresent()) {
                        if(one.get().getPrice() > min.get().getPrice()){
                            hotel.setMin_price(decimalFormat.format(min.get().getPrice()));
                        }else {
                            hotel.setMin_price(decimalFormat.format(one.get().getPrice()));
                        }
                    } else {
                        if (min != null && min.isPresent()) {
                            hotel.setMin_price(decimalFormat.format(min.get().getPrice()));
                        }
                    }
                }

            }
        }

        // 用户访问量数据
        userVisitsDao.add(userId);
        ResponseUtil.writeJsonIPage(ServletActionContext.getResponse(), iPage);
        return null;
    }

    /**
     * 进入首页,展示民宿数据列表
     * queryValue 查询字段
     * hotel_townshipId 所属乡镇
     *
     * @return
     */
    public String homePage() {
        // 获取民宿列表
        IPage<Hotel> iPage = appHomePageService.getHotelList(queryValue, hotel_township, type, page, rows);
        if (iPage.getPageList() != null && iPage.getPageList().size() > 0) {
            List<Integer> managerIds = iPage.getPageList().stream().map(Hotel::getManagerId).collect(Collectors.toList());

            //2023-09-22 A-jax 获取最低价
            if (managerIds.size() > 0) {
                List<HotelPriceDataVo> prices = housePriceService.queryHotelPriceDatas(StringUtils.join(managerIds, ","), TimeExchange.getDateStr());

                List<HotelPriceOneDataVo> oneDatas = new ArrayList<>();
                //获取当天的
                for (HotelPriceDataVo hp : prices) {
                    HotelPriceOneDataVo oneData = new HotelPriceOneDataVo();
                    oneData.setSetDate(TimeExchange.getDateStr());
                    oneData.setCreateDate(hp.getCreateDate());
                    oneData.setPrice(hp.getPrice());
                    oneData.setManagerId(hp.getManagerId());
                    oneDatas.add(oneData);
                }

                /**
                 * 根据房型ID处理重复的数据
                 */
                List<HotelPriceOneDataVo> newOneDatas = new ArrayList<>();
                if (oneDatas.size() > 0) {
                    for (Integer managerId : managerIds) {
                        Optional<HotelPriceOneDataVo> one = oneDatas.stream().filter(e -> e.getManagerId().equals(managerId)).sorted(Comparator.comparing(HotelPriceOneDataVo::getCreateDate, Comparator.reverseOrder())).findFirst();
                        if (one != null && one.isPresent()) {
                            HotelPriceOneDataVo oneData = new HotelPriceOneDataVo();
                            oneData.setSetDate(one.get().getSetDate());
                            oneData.setCreateDate(one.get().getCreateDate());
                            oneData.setPrice(one.get().getPrice());
                            oneData.setManagerId(one.get().getManagerId());
                            newOneDatas.add(oneData);
                        }
                    }
                }

                /**
                 * 获取商家集合中最低房型价格
                 */
                List<PriceHotelDataVo> mins = houseService.gethotelMinPrice(StringUtils.join(managerIds, ","));
                DecimalFormat decimalFormat = new DecimalFormat("#####.##");
                for (Hotel hotel : iPage.getPageList()) {
                    //2023-11-09 A-jax 获取剩余房间数
                    List<OwnerHouseDto> result = adminManagerService.getTotalManageCount(hotel.getHotelTownship(), type);
                    if(result != null && result.size() > 0){
                        Optional<OwnerHouseDto> mhd = result.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
                        if(mhd != null && mhd.isPresent()){
                            hotel.setRoomNumber(mhd.get().getResidueHouseNum());
                            hotel.setRoom_number_calc(mhd.get().getTotalHouseNum().toString());
                        }
                    }
                    Optional<HotelPriceOneDataVo> one = null;
                    if (!newOneDatas.isEmpty()){
                        one = newOneDatas.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
                    }
                    Optional<PriceHotelDataVo> min = null;
                    if (mins!=null){
                        min = mins.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
                    }
                    if (one != null && one.isPresent() && min != null && min.isPresent()) {
                        if(one.get().getPrice() > min.get().getPrice()){
                            hotel.setMin_price(decimalFormat.format(min.get().getPrice()));
                        }else {
                            hotel.setMin_price(decimalFormat.format(one.get().getPrice()));
                        }
                    } else {
                        if (min != null && min.isPresent()) {
                            hotel.setMin_price(decimalFormat.format(min.get().getPrice()));
                        }
                    }
                }

            }
        }

        // 用户访问量数据
        userVisitsDao.add(userId);
        ResponseUtil.writeJsonIPage(ServletActionContext.getResponse(), iPage);
        return null;
    }

    /**
     * 用户点击收藏民宿
     * userId
     * hotelId
     *
     * @return
     */
    public String collectHotel() {
        if (Func.checkNull(userId) || Func.checkNull(hotelId))
            return null;

        Users users = userService.addhotelAndUsers(hotelId, userId, TempEnum.收藏);

        JSONObject jsonObject = new JSONObject();
        jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
        jsonObject.put(B.data, users);
        ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
        return null;
    }

    /**
     * 用户点击取消 收藏民宿
     * userId 用户id
     * hotelId 酒店id
     *
     * @return
     */
    public String delCollectHotel() {
        if (Func.checkNull(userId) || Func.checkNull(hotelId))
            return null;

        Users users = userService.delhotelAndUsers(hotelId, userId, TempEnum.收藏);

        JSONObject jsonObject = new JSONObject();
        jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
        jsonObject.put(B.data, users);
        ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
        return null;
    }

    /**
     * hotelId 酒店id
     * queryStartTime
     * queryEndTime
     * userId
     * 通过酒店的id获取到房间信息
     *
     * @return
     */
    public String getHouseByHotelId() throws ParseException {
        JSONObject jsonObject = new JSONObject();
        // 如果未赋值，则直接跳出
        if (Func.checkNull(hotelId) || Func.checkNull(queryStartTime) || Func.checkNull(queryEndTime)) {
            jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
            jsonObject.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
            return null;
        }

        // 使用天去查"yyyy/MM/dd"
        String startDate = DateUtil.parseDateToStr((Func.parseDate(queryStartTime)), DateUtil.Time_Formatter_Day);
        String endDate = DateUtil.parseDateToStr((Func.parseDate(queryEndTime)), DateUtil.Time_Formatter_Day);

        Hotel hotel = appHomePageService.getHotelAndHouseByHotelId(hotelId, startDate, endDate);
        hotel.setHotelFileInfoList(fileService.queryListByLinkId(hotel.getManagerId() + ""));

        AdminManager adminManager = adminManagerService.getById(hotel.getManagerId());
        hotel.setType(String.valueOf(adminManager.getType()));

        // 添加是否已收藏的酒店
        if (!Func.checkNull(userId))
            hotel = appHomePageService.assignCollect(userId, hotel);

        //region 2023-09-12 A-jax 添加房型均价：入住的每一天的价格之和 / 入住天数
        List<HousePriceDataVo> hprd = housePriceService.queryHousePriceDatas(hotel.getManagerId(), queryStartTime, TimeExchange.TimeDesD(queryEndTime, -1));
        List<HousePriceOneDataVo> oneDatas = new ArrayList<>();
        //将数据处理成单天的
        for (HousePriceDataVo hp : hprd) {
            if (hp.getStartTime().equals(hp.getEndTime())) {
                HousePriceOneDataVo oneData = new HousePriceOneDataVo();
                oneData.setSetDate(hp.getStartTime());
                oneData.setCreateDate(hp.getCreateDate());
                oneData.setPrice(hp.getPrice());
                oneData.setHouseId(hp.getHouseId());
                oneDatas.add(oneData);
            } else {
                int beDateNum = TimeExchange.daysBetween(hp.getStartTime(), hp.getEndTime());
                for (int i = 0; i <= beDateNum; i++) {
                    String date = TimeExchange.TimeDesD(hp.getStartTime(), i);
                    if (date.equals(queryEndTime)) {
                        break;
                    }
                    HousePriceOneDataVo oneData = new HousePriceOneDataVo();
                    oneData.setSetDate(TimeExchange.TimeDesD(hp.getStartTime(), i));
                    oneData.setCreateDate(hp.getCreateDate());
                    oneData.setPrice(hp.getPrice());
                    oneData.setHouseId(hp.getHouseId());
                    oneDatas.add(oneData);
                }
            }
        }

        List<String> dateStrs = new ArrayList<>();
        int dateNum = TimeExchange.daysBetween(queryStartTime, TimeExchange.TimeDesD(queryEndTime, -1));
        for (int i = 0; i <= dateNum; i++) {
            String date = TimeExchange.TimeDesD(queryStartTime, i);
            dateStrs.add(date);
        }
        List<House> houseList = hotel.getHouseList();
        if (houseList!=null && !houseList.isEmpty()) {
            for (House houseData : houseList) {
                BigDecimal todayPrice = BigDecimal.ZERO;
                for (String dateStr : dateStrs) {
                    Optional<HousePriceOneDataVo> oneData = null;
                    if (!oneDatas.isEmpty()){
                        oneData = oneDatas.stream().filter(e -> e.getHouseId().toString().equals(houseData.getId()) && e.getSetDate().equals(dateStr)).sorted(Comparator.comparing(HousePriceOneDataVo::getCreateDate, Comparator.reverseOrder())).findFirst();
                    }
                    if (oneData != null && oneData.isPresent()) {
                        todayPrice = todayPrice.add(BigDecimal.valueOf(oneData.get().getPrice()));
                    } else {
                        todayPrice = todayPrice.add(BigDecimal.valueOf(houseData.getPrice()));
                    }
                }
                houseData.setPrice(todayPrice.doubleValue());
                if (dateStrs.size() > 0) {
//                houseData.setPrice(houseData.getPrice() == 0.0 ? 0.0 : (new BigDecimal(houseData.getPrice()).divide(new BigDecimal(dateStrs.size())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
                    houseData.setPrice(houseData.getPrice() == 0.0 ? 0.0 : (new BigDecimal(houseData.getPrice()).divide(new BigDecimal(dateStrs.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue()));
                }
            }
        }

        //endregion

        // 通过时间区间查询房间信息，并带好是否有房标识给前台
        jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
        jsonObject.put(B.data, ResultUtil.ok(hotel));
        ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
        return null;
    }


    /**
     * 通过酒店的id获取到酒店详细信息
     * hotelId
     * userId
     *
     * @return
     */
    public String getHotelInfoByHotelId() {
        JSONObject jsonObject = new JSONObject();
        // 如果未赋值，则直接跳出
        if (Func.checkNull(hotelId)) {
            jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
            jsonObject.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
            return null;
        }

        Hotel hotel = hotelService.getById(Func.parseInt(hotelId));
        if (hotel == null) {
            jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
            jsonObject.put(B.message, "无法查询到当前酒店信息");
            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
            return null;
        }
        hotel.setHotelFileInfoList(fileService.queryListByLinkId(hotel.getManagerId() + ""));

        AdminManager adminManager = adminManagerService.getById(hotel.getManagerId());
        hotel.setType(String.valueOf(adminManager.getType()));

        // 添加是否已收藏的酒店
        if (!Func.checkNull(userId))
            appHomePageService.assignCollect(userId, hotel);

        jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
        jsonObject.put(B.data, hotel);
        ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
        return null;
    }


    /**
     * 描述：获取各乡俗民宿级别数量
     *
     * @return
     */
    public String getTownshipCount() {
        JSONObject resultjson = new JSONObject();
        List<townshipCountDTO> list = adminManagerService.getTownshipCount();
        if (list != null) {
            resultjson.put("message", "返回成功");
            resultjson.put("code", 200);
            resultjson.put("data", list);
            ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
            return null;
        }
        resultjson.put("message", "数据为空");
        resultjson.put("code", 205);
        ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
        return null;
    }

    /**
     * 描述：获取各乡镇剩余房数
     *
     * @return
     */
    public String getResidueCount() {
        JSONObject resultjson = new JSONObject();
        List<townshipCountDTO> list = adminManagerService.getResidueCount();

        if (list != null) {
            List<ManageHouseDto> totalCounts = adminManagerService.getTotalHouseCount();

            for (townshipCountDTO data : list) {
                Optional<ManageHouseDto> totalCount = totalCounts.stream().filter(e -> e.getName().equals(data.getName())).findFirst();
                if(totalCount != null && totalCount.isPresent()){
                    data.setSumNumber(totalCount.get().totalHouseNum);
                    data.setResidueNumber(totalCount.get().getResidueHouseNum());
                }
            }
            resultjson.put("message", "返回成功");
            resultjson.put("code", 200);
            resultjson.put("data", list);
            ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
            return null;
        }
        resultjson.put("message", "数据为空");
        resultjson.put("code", 205);
        ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
        return null;
    }


    public String getUserCode() {
        return userCode;
    }

    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }

    public String getQueryValue() {
        return queryValue;
    }

    public void setQueryValue(String queryValue) {
        this.queryValue = queryValue;
    }

    public String getHotelId() {
        return hotelId;
    }

    public void setHotelId(String hotelId) {
        this.hotelId = hotelId;
    }


    public void setHotel_township(String hotel_township) {
        this.hotel_township = hotel_township;
    }

}
