Browse Source

Merge branch 'master' of https://e.coding.net/chuanghaikeji/jinganxiangsu/Homestay_app_houtai

lijie 2 years ago
parent
commit
9f7a4eb28c

+ 6 - 10
mhotel/src/com/happy/Model/HouseNumber.java

@@ -1,9 +1,6 @@
 package com.happy.Model;
 
-import com.happy.dto.HouseNumberStatusDto;
-
 import java.util.Date;
-import java.util.List;
 
 /**
  * @Description  
@@ -20,11 +17,10 @@ public class HouseNumber {
 	private Date createDate; // 创建时间
 	private Date modifyDate; // 修改时间
 	private Integer status; // 状态(0.删除 1.正常)
-
 	/**
-	 * 房态信息态管理-房态管理
+	 * 1.净2.脏
 	 */
-	private List<HouseNumberStatusDto> houseNumberStatuses;
+	private Integer houseStatus;
 
 
 	public String getId() {
@@ -89,11 +85,11 @@ public class HouseNumber {
 		this.status = status;
 	}
 
-	public List<HouseNumberStatusDto> getHouseNumberStatuses() {
-		return houseNumberStatuses;
+	public Integer getHouseStatus() {
+		return houseStatus;
 	}
 
-	public void setHouseNumberStatuses(List<HouseNumberStatusDto> houseNumberStatuses) {
-		this.houseNumberStatuses = houseNumberStatuses;
+	public void setHouseStatus(Integer houseStatus) {
+		this.houseStatus = houseStatus;
 	}
 }

+ 40 - 0
mhotel/src/com/happy/action/HouseNumberAction.java

@@ -0,0 +1,40 @@
+package com.happy.action;
+
+import com.alibaba.fastjson.JSONObject;
+import com.happy.Until.GetHttpParam;
+import com.happy.Until.ResUtil;
+import com.happy.common.controller.BaseController;
+import com.happy.dto.HouseNumberDto;
+import com.happy.service.HouseNumberService;
+import com.opensymphony.xwork2.ModelDriven;
+import lombok.SneakyThrows;
+import org.apache.struts2.ServletActionContext;
+
+import javax.annotation.Resource;
+
+public class HouseNumberAction extends BaseController implements ModelDriven<HouseNumberDto> {
+    private final HouseNumberDto houseNumberDto = new HouseNumberDto();
+
+    @Override
+    public HouseNumberDto getModel() {
+        return houseNumberDto;
+    }
+
+    @Resource(name = "HouseNumberService")
+    private HouseNumberService houseNumberService;
+
+
+    /**
+     * 置脏/净
+     */
+    @SneakyThrows
+    public void modifyHouseStatus() {
+        String postDataStr = GetHttpParam.getRequestPostData(request);
+        HouseNumberDto postDataObj = JSONObject.parseObject(postDataStr, HouseNumberDto.class);
+        houseNumberService.modifyHouseStatus(postDataObj);
+        ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
+            put("message", "请求成功");
+            put("code", 200);
+        }}.toString());
+    }
+}

+ 2 - 2
mhotel/src/com/happy/action/HouseNumberStatusAction.java

@@ -55,7 +55,7 @@ public class HouseNumberStatusAction extends BaseController implements ModelDriv
     }
 
     /**
-     * 批量置脏/净、批量开/关房 房态管理-房态管理
+     * 批量开/关房 房态管理-房态管理
      */
     @SneakyThrows
     public void modifyStatusBatch() {
@@ -69,7 +69,7 @@ public class HouseNumberStatusAction extends BaseController implements ModelDriv
     }
 
     /**
-     * 置脏/净、开/关房 房态管理-房态管理
+     * 开/关房 房态管理-房态管理
      */
     @SneakyThrows
     public void modifyStatus() {

+ 8 - 3
mhotel/src/com/happy/dao/HouseNumberDao.java

@@ -2,8 +2,8 @@ package com.happy.dao;
 
 import com.happy.Model.Booking;
 import com.happy.Model.HouseNumber;
+import com.happy.dto.HouseNumberDto;
 
-import java.awt.print.Book;
 import java.util.List;
 
 public interface HouseNumberDao {
@@ -14,9 +14,14 @@ public interface HouseNumberDao {
     List<HouseNumber> queryHouseStatus(Booking book);
 
     /**
-     * 查询指定房型下的所有非删除状态的房间
+     * 查询指定房型下的所有非删除状态的房间(脏房/净房)
      */
-    List<HouseNumber> queryListByHouseIdList(List<String> houseIdList);
+    List<HouseNumberDto> queryListOne(HouseNumberDto houseNumberDto);
+
+    /**
+     * 房态管理-置脏/净
+     */
+    void modifyHouseStatus(HouseNumberDto houseNumberDto);
 
     List<HouseNumber> queryByHouseId(String houseId);
 }

+ 41 - 29
mhotel/src/com/happy/dao/impl/HouseNumberImplDao.java

@@ -1,10 +1,12 @@
 package com.happy.dao.impl;
 
 import com.happy.Model.Booking;
-import com.happy.Model.HotelCoupon;
 import com.happy.Model.HouseNumber;
+import com.happy.Until.BeanMapTool;
 import com.happy.Until.UUIDUtil;
 import com.happy.dao.HouseNumberDao;
+import com.happy.dto.HouseNumberDto;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@@ -13,16 +15,12 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
 import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
 import org.springframework.stereotype.Repository;
 
-import java.awt.print.Book;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import java.util.UUID;
 
 @Repository("HouseNumberDao")
-public class HouseNumberImplDao  implements HouseNumberDao {
+public class HouseNumberImplDao implements HouseNumberDao {
     @Autowired
     private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
 
@@ -42,18 +40,18 @@ public class HouseNumberImplDao  implements HouseNumberDao {
                 " VALUES " +
                 " (:id,:house_id,:number_name,:create_id,:create_date,:modify_date,:status) ";
         List<MapSqlParameterSource> houseNumberList = new ArrayList<>();
-        for (HouseNumber h1 : list){
+        for (HouseNumber h1 : list) {
             MapSqlParameterSource mapSqlParameterSource = new MapSqlParameterSource();
             mapSqlParameterSource.addValue("id", String.valueOf(UUID.randomUUID()));
-            mapSqlParameterSource.addValue("house_id",h1.getHouseId());
-            mapSqlParameterSource.addValue("number_name",h1.getNumberName());
-            mapSqlParameterSource.addValue("create_id",h1.getCreateId());
-            mapSqlParameterSource.addValue("create_date",UUIDUtil.getNewDate());
-            mapSqlParameterSource.addValue("modify_date",UUIDUtil.getNewDate());
-            mapSqlParameterSource.addValue("status",h1.getStatus());
+            mapSqlParameterSource.addValue("house_id", h1.getHouseId());
+            mapSqlParameterSource.addValue("number_name", h1.getNumberName());
+            mapSqlParameterSource.addValue("create_id", h1.getCreateId());
+            mapSqlParameterSource.addValue("create_date", UUIDUtil.getNewDate());
+            mapSqlParameterSource.addValue("modify_date", UUIDUtil.getNewDate());
+            mapSqlParameterSource.addValue("status", h1.getStatus());
             houseNumberList.add(mapSqlParameterSource);
         }
-        int[] m = namedParameterJdbcTemplate.batchUpdate(insertSql,houseNumberList.toArray(new SqlParameterSource[0]));
+        int[] m = namedParameterJdbcTemplate.batchUpdate(insertSql, houseNumberList.toArray(new SqlParameterSource[0]));
         return m.length;
     }
 
@@ -62,12 +60,12 @@ public class HouseNumberImplDao  implements HouseNumberDao {
         HouseNumber h1 = list.get(0);
         String delSql = "update `house_number` set status=0 where house_id=:houseId";
         MapSqlParameterSource sps = new MapSqlParameterSource();
-        sps.addValue("houseId",h1.getHouseId());
+        sps.addValue("houseId", h1.getHouseId());
         int num = 0;
-        try{
+        try {
             num = namedParameterJdbcTemplate.update(delSql, sps);
             this.saveBatch(list);
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
         }
         return 0;
@@ -79,25 +77,39 @@ public class HouseNumberImplDao  implements HouseNumberDao {
                 "(select * from house_number where house_id = :house_id) a\n" +
                 "left join (select number_id from house_number_status where DATE_FORMAT(set_date,'%Y-%m-%d') >= :order_start_time and DATE_FORMAT(set_date,'%Y-%m-%d') <= :order_end_time and `status` != 1 group by number_id) b on a.id = b.number_id";
         MapSqlParameterSource sps = new MapSqlParameterSource();
-        sps.addValue("house_id",book.getHouseId());
-        sps.addValue("order_start_time",book.getOrderStartTime().substring(0,10));
-        sps.addValue("order_end_time",book.getOrderEndTime().substring(0,10));
+        sps.addValue("house_id", book.getHouseId());
+        sps.addValue("order_start_time", book.getOrderStartTime().substring(0, 10));
+        sps.addValue("order_end_time", book.getOrderEndTime().substring(0, 10));
         List<HouseNumber> list = new ArrayList<>();
-        try{
-            list = namedParameterJdbcTemplate.query(sql,sps, new BeanPropertyRowMapper<>(HouseNumber.class));
-        }catch (Exception e){
+        try {
+            list = namedParameterJdbcTemplate.query(sql, sps, new BeanPropertyRowMapper<>(HouseNumber.class));
+        } catch (Exception e) {
             e.printStackTrace();
         }
-        if(list != null && list.size()>0) return list;
+        if (list != null && list.size() > 0) return list;
         return null;
     }
 
     @Override
-    public List<HouseNumber> queryListByHouseIdList(List<String> houseIdList) {
-        final String sql = "select id, house_id, number_name, create_id, create_date, modify_date, status from house_number where status in (1, 2) and house_id in (:houseIdList) order by number_name";
-        return namedParameterJdbcTemplate.query(sql, new MapSqlParameterSource() {{
-            addValue("houseIdList", houseIdList);
-        }}, new BeanPropertyRowMapper<>(HouseNumber.class));
+    public List<HouseNumberDto> queryListOne(HouseNumberDto houseNumberDto) {
+        final String SQL_HEAD = "select id, house_id, number_name, create_id, create_date, modify_date, status, house_status from house_number where status in (1, 2) and house_id in (:houseIdList)";
+        final String SQL_TAIL = " order by number_name";
+        StringBuilder sql = new StringBuilder(SQL_HEAD);
+        if (houseNumberDto.getHouseStatus() != null) sql.append(" and house_status = :houseStatus");
+        sql.append(SQL_TAIL);
+        return namedParameterJdbcTemplate.query(sql.toString(), BeanMapTool.beanToMap(houseNumberDto), new BeanPropertyRowMapper<>(HouseNumberDto.class));
+    }
+
+    @Override
+    public void modifyHouseStatus(HouseNumberDto houseNumberDto) {
+        if (StringUtils.isBlank(houseNumberDto.getId()) && (houseNumberDto.getIdList() == null || houseNumberDto.getIdList().isEmpty()))
+            return;
+        final String SQL_HEAD = "update house_number set house_status = :houseStatus, modify_date = :modifyDate";
+        StringBuilder sql = new StringBuilder(SQL_HEAD);
+        if (StringUtils.isNotBlank(houseNumberDto.getId())) sql.append(" where id = :id");
+        if (houseNumberDto.getIdList() != null && !houseNumberDto.getIdList().isEmpty())
+            sql.append(" where id in (:idList)");
+        namedParameterJdbcTemplate.update(sql.toString(), BeanMapTool.beanToMap(houseNumberDto));
     }
 
     @Override

+ 24 - 0
mhotel/src/com/happy/dto/HouseNumberDto.java

@@ -0,0 +1,24 @@
+package com.happy.dto;
+
+import com.happy.Model.HouseNumber;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class HouseNumberDto extends HouseNumber {
+    /**
+     * id集合
+     */
+    private List<String> idList;
+    /**
+     * 房型id结合
+     */
+    private List<String> houseIdList;
+    /**
+     * 房态信息 房态管理-房态管理
+     */
+    private List<HouseNumberStatusDto> houseNumberStatuses;
+}

+ 1 - 1
mhotel/src/com/happy/dto/HouseNumberStatusDto.java

@@ -19,7 +19,7 @@ public class HouseNumberStatusDto extends HouseNumberStatus {
     private List<String> houseNumberIds;
 
     /**
-     * 房间id集合
+     * 房间状态集合
      */
     private List<Integer> statuses;
     /**

+ 11 - 1
mhotel/src/com/happy/service/HouseNumberService.java

@@ -2,19 +2,22 @@ package com.happy.service;
 
 import com.happy.Model.Booking;
 import com.happy.Model.HouseNumber;
+import com.happy.dto.HouseNumberDto;
 
-import java.awt.print.Book;
 import java.util.List;
 
 public interface HouseNumberService {
     /**
      * 描述:直接新增
+     *
      * @param list 房号
      * @return 印象行数
      */
     int saveBatch(List<HouseNumber> list);
+
     /**
      * 描述:先删除后新增
+     *
      * @param list 房号
      * @return 印象行数
      */
@@ -22,6 +25,7 @@ public interface HouseNumberService {
 
     /**
      * 描述:查询可添加的房间
+     *
      * @param book 订单号
      * @return 返回房间号 Status 为 3的房间表示不可预定
      */
@@ -29,8 +33,14 @@ public interface HouseNumberService {
 
     /**
      * 描述:查询该房型下的房间号
+     *
      * @param houseId 房型id
      * @return 该房型的房间列表
      */
     List<HouseNumber> queryByHouseId(String houseId);
+
+    /**
+     * 房态管理-置脏/净
+     */
+    void modifyHouseStatus(HouseNumberDto houseNumberDto);
 }

+ 1 - 1
mhotel/src/com/happy/service/HouseNumberStatusService.java

@@ -20,7 +20,7 @@ public interface HouseNumberStatusService {
     List<?> queryListWithHouse(HouseNumberStatusDto houseNumberStatusDto);
 
     /**
-     * 批量置脏/净、批量开/关房
+     * 批量开/关房
      */
     void modifyStatusBatch(HouseNumberStatusDto houseNumberStatusDto);
 

+ 12 - 3
mhotel/src/com/happy/service/impl/HouseNumberImplService.java

@@ -2,20 +2,22 @@ package com.happy.service.impl;
 
 import com.happy.Model.Booking;
 import com.happy.Model.HouseNumber;
-import com.happy.dao.HouseDao;
+import com.happy.Until.DateUtil;
 import com.happy.dao.HouseNumberDao;
+import com.happy.dto.HouseNumberDto;
 import com.happy.service.HouseNumberService;
-import com.happy.service.HouseService;
+import lombok.SneakyThrows;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.awt.print.Book;
+import java.util.Date;
 import java.util.List;
 
 @Service("HouseNumberService")
 public class HouseNumberImplService implements HouseNumberService {
     @Resource
     public HouseNumberDao houseNumberDao;
+
     @Override
     public int saveBatch(List<HouseNumber> list) {
         return houseNumberDao.saveBatch(list);
@@ -36,4 +38,11 @@ public class HouseNumberImplService implements HouseNumberService {
         return houseNumberDao.queryByHouseId(houseId);
     }
 
+    @SneakyThrows
+    @Override
+    public void modifyHouseStatus(HouseNumberDto houseNumberDto) {
+        Date dataTime = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
+        houseNumberDto.setModifyDate(dataTime);
+        houseNumberDao.modifyHouseStatus(houseNumberDto);
+    }
 }

+ 55 - 89
mhotel/src/com/happy/service/impl/HouseNumberStatusImplService.java

@@ -9,6 +9,7 @@ import com.happy.Until.Func;
 import com.happy.dao.HouseNumberDao;
 import com.happy.dao.HouseNumberStatusDao;
 import com.happy.dao.HousePriceDao;
+import com.happy.dto.HouseNumberDto;
 import com.happy.dto.HouseNumberStatusDto;
 import com.happy.dto.HousePriceDto;
 import com.happy.service.HouseNumberStatusService;
@@ -48,9 +49,11 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
         Integer showType = houseNumberStatusDto.getShowType();
         if (StringUtils.isBlank(managerId) || showType == null) return null;
         List<House> houseList = housePriceService.queryHouseListByManagerId(houseNumberStatusDto.getManagerId());
-        if (houseList.isEmpty()) return null;
-        List<HouseNumber> houseNumberList = houseNumberDao.queryListByHouseIdList(houseList.stream().map(House::getId).collect(Collectors.toList()));
-        if (houseNumberList.isEmpty()) return null;
+        if (houseList == null || houseList.isEmpty()) return null;
+        HouseNumberDto houseNumberDto = new HouseNumberDto();
+        houseNumberDto.setHouseIdList(houseList.stream().map(House::getId).collect(Collectors.toList()));
+        List<HouseNumberDto> houseNumberList = houseNumberDao.queryListOne(houseNumberDto);
+        if (houseNumberList == null || houseNumberList.isEmpty()) return null;
 
         String setDate = houseNumberStatusDto.getSetDate();
         Date startDate = DateUtil.parseDateOnly(setDate);
@@ -58,7 +61,7 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
         String setDateWithEndDate = String.format("%s,%s", setDate, DateUtil.parseDateToStr(endDate, DateUtil.Time_Formatter_Day));
 
         //region 房间状态信息
-        houseNumberStatusDto.setStatuses(Arrays.asList(2, 3, 4, 5, 6));
+        houseNumberStatusDto.setStatuses(Arrays.asList(2, 5, 6));
         List<String> houseNumberIdList = houseNumberList.stream().map(HouseNumber::getId).collect(Collectors.toList());
         houseNumberStatusDto.setHouseNumberIds(houseNumberIdList);
         List<HouseNumberStatusDto> houseNumberStatusDtoList;
@@ -74,29 +77,22 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
         }
         //endregion
 
-        boolean existHouseNumberStatus = !houseNumberStatusDtoList.isEmpty();
-
-        //region 订单信息
-        Map<String, HouseNumberStatusDto> orderInfoMap;
-        if (existHouseNumberStatus) {
+        if (!houseNumberStatusDtoList.isEmpty()) {
+            //region 预定/入住的订单信息
+            Map<String, HouseNumberStatusDto> orderInfoMap;
             List<String> bookingId = houseNumberStatusDtoList.stream()
                     .filter(item -> item.getStatus() == 5 || item.getStatus() == 6)
                     .map(HouseNumberStatusDto::getBookingId).collect(Collectors.toList());
-
             if (bookingId.isEmpty()) {
                 orderInfoMap = Collections.emptyMap();
             } else {
                 orderInfoMap = houseNumberStatusDao.queryOrderSomeColumnListByIds(bookingId)
                         .stream().collect(Collectors.toMap(HouseNumberStatusDto::getBookingId, item -> item, (bookingIdOne, bookingIdTow) -> bookingIdOne));
             }
-        } else {
-            orderInfoMap = Collections.emptyMap();
-        }
-        //endregion
+            //endregion
 
-        if (existHouseNumberStatus) {
             houseNumberList.forEach(houseNumber -> {
-                ArrayList<HouseNumberStatusDto> houseNumberStatuses = new ArrayList<>();
+                List<HouseNumberStatusDto> houseNumberStatuses = new ArrayList<>();
                 for (HouseNumberStatusDto numberStatusDto : houseNumberStatusDtoList) {
                     // 填充预定/入住的一些订单信息
                     if (numberStatusDto.getStatus() == 5 || numberStatusDto.getStatus() == 6) {
@@ -111,7 +107,7 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
                 }
             });
         }
-
+        JSONObject result = new JSONObject();
         if (houseNumberStatusDto.getShowType() == 1) {
             List<String> dateListBetween = DateUtil.getDateStrListBetween(startDate, endDate);
 
@@ -123,22 +119,22 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
             List<HousePriceDto> housePriceDtoList = housePriceDao.queryListTwo(housePriceDto);
             //endregion
             List<JSONObject> datas = new ArrayList<>();
-            JSONObject result = new JSONObject(new LinkedHashMap<>());
             houseList.forEach(house -> houseNumberList.forEach(houseNumber -> {
                 if (houseNumber.getHouseId().equals(house.getId())) {
                     JSONObject houseJsonObject = new JSONObject(new LinkedHashMap<>());
                     houseJsonObject.put("id", house.getId());
                     houseJsonObject.put("houseName", house.gethName());
                     String numberName = houseNumber.getNumberName();
+                    houseJsonObject.put("numberName", numberName);
+                    houseJsonObject.put("numberStatus", houseNumber.getHouseStatus());
                     dateListBetween.forEach(date -> {
-                        houseJsonObject.put("numberName", numberName);
                         JSONObject dateJsonObject = new JSONObject();
                         dateJsonObject.put("numberId", houseNumber.getId());
                         dateJsonObject.put("houseName", house.gethName());
                         dateJsonObject.put("numberName", numberName);
                         dateJsonObject.put("housePrice", getPrice(DateUtil.parseDateOnly(date), house, housePriceDtoList));
                         List<HouseNumberStatusDto> houseNumberStatuses = houseNumber.getHouseNumberStatuses();
-                        if (houseNumberStatuses != null && !houseNumberStatuses.isEmpty()){
+                        if (houseNumberStatuses != null && !houseNumberStatuses.isEmpty()) {
                             houseNumberStatuses.forEach(houseNumberStatus -> {
                                 if (date.equals(houseNumberStatus.getSetDate())) {
                                     dateJsonObject.put("closeType", houseNumberStatus.getCloseType());
@@ -161,21 +157,20 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
                     datas.add(houseJsonObject);
                 }
             }));
-            ArrayList<JSONObject> dataTimes = new ArrayList();
-            dateListBetween.forEach(date->{
-                JSONObject dataTime = new JSONObject();//
-                dataTime.put("dateStr",date);
-                dataTime.put("roomSum",getSum(date,houseNumberList));
+            ArrayList<JSONObject> dataTimes = new ArrayList<>();
+            dateListBetween.forEach(date -> {
+                JSONObject dataTime = new JSONObject();
+                dataTime.put("dateStr", date);
+                dataTime.put("roomSum", getSum(date, houseNumberList));
                 dataTimes.add(dataTime);
             });
 
             result.put("dateTimes", dataTimes);
-            result.put("datas",datas);
+            result.put("datas", datas);
             return result;
         }
         if (houseNumberStatusDto.getShowType() == 2) {
-            JSONObject result = new JSONObject(new LinkedHashMap<>());
-            result.put("data",buildResultOne(houseList, houseNumberList));
+            result.put("data", buildResultOne(houseList, houseNumberList));
             return result;
         }
         return null;
@@ -186,29 +181,12 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
         String managerId = houseNumberStatusDto.getManagerId();
         if (StringUtils.isBlank(managerId)) return Collections.emptyList();
         List<House> houseList = housePriceService.queryHouseListByManagerId(houseNumberStatusDto.getManagerId());
-        if (houseList.isEmpty()) return houseList;
-        List<HouseNumber> houseNumberList = houseNumberDao.queryListByHouseIdList(houseList.stream().map(House::getId).collect(Collectors.toList()));
-        if (houseNumberList.isEmpty()) return houseList;
-
-        // 需求文档只注明:批量置净时展示的是脏房(status=3)
-        if (houseNumberStatusDto.getStatus() != null && houseNumberStatusDto.getStatus() == 3) {
-            //region 此代码块为移除不是脏房的房间
-            List<String> houseNumberIdList = houseNumberList.stream().map(HouseNumber::getId).collect(Collectors.toList());
-
-            //region 脏房房间id集合
-            HouseNumberStatusDto paramsOne = new HouseNumberStatusDto();
-            paramsOne.setHouseNumberIds(houseNumberIdList);
-            paramsOne.setStatuses(Collections.singletonList(3));
-            List<String> numberIdList = houseNumberStatusDao.queryList(paramsOne).stream()
-                    .map(HouseNumberStatusDto::getNumberId)
-                    .collect(Collectors.toList());
-            //endregion
-
-            if (numberIdList.isEmpty()) return houseList;
-            Set<String> numberIdSet = new HashSet<>(numberIdList);
-            houseNumberList = houseNumberList.stream().filter(houseNumber -> numberIdSet.contains(houseNumber.getId())).collect(Collectors.toList());
-            //endregion
-        }
+        if (houseList == null || houseList.isEmpty()) return houseList;
+        HouseNumberDto houseNumberDto = new HouseNumberDto();
+        houseNumberDto.setHouseIdList(houseList.stream().map(House::getId).collect(Collectors.toList()));
+        houseNumberDto.setHouseStatus(houseNumberStatusDto.getStatus());
+        List<HouseNumberDto> houseNumberList = houseNumberDao.queryListOne(houseNumberDto);
+        if (houseNumberList == null || houseNumberList.isEmpty()) return houseList;
         return buildResultOne(houseList, houseNumberList);
     }
 
@@ -217,44 +195,32 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
     public void modifyStatusBatch(HouseNumberStatusDto houseNumberStatusDto) {
         Integer status = houseNumberStatusDto.getStatus();
         String createId = houseNumberStatusDto.getCreateId();
-        boolean isStatusEqualsThree = status == 3;
-        boolean isStatusEqualsFour = status == 4;
-        List<String> dateStrListBetween;
-        if (isStatusEqualsFour) {
-            String[] setDateStr = houseNumberStatusDto.getSetDate().split(",");
-            dateStrListBetween = DateUtil.getDateStrListBetween(DateUtil.parseDateOnly(setDateStr[0]), DateUtil.parseDateOnly(setDateStr[1]));
-        } else {
-            dateStrListBetween = Collections.emptyList();
-        }
-        String currentDateStr = DateUtil.getFormatDate(DateUtil.Time_Formatter_Day);
         Date dataTime = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
-        List<String> houseNumberIds = houseNumberStatusDto.getHouseNumberIds();
-        List<HouseNumberStatus> houseNumberStatusList = new ArrayList<>();
-        if (isStatusEqualsThree || isStatusEqualsFour) {
+        if (status == 2) {
+            // 关房
+            String[] setDateStr = houseNumberStatusDto.getSetDate().split(",");
+            List<String> dateStrListBetween = DateUtil.getDateStrListBetween(DateUtil.parseDateOnly(setDateStr[0]), DateUtil.parseDateOnly(setDateStr[1]));
+            List<String> houseNumberIds = houseNumberStatusDto.getHouseNumberIds();
+            List<HouseNumberStatus> houseNumberStatusList = new ArrayList<>();
             houseNumberIds.forEach(houseNumberId -> {
                 HouseNumberStatus houseNumberStatus = new HouseNumberStatus();
                 houseNumberStatus.setNumberId(houseNumberId);
                 houseNumberStatus.setStatus(status);
                 houseNumberStatus.setCreateId(createId);
                 houseNumberStatus.setCreateDate(dataTime);
-                if (isStatusEqualsThree) {
-                    houseNumberStatus.setId(Func.newGuid());
-                    houseNumberStatus.setSetDate(currentDateStr);
-                    houseNumberStatusList.add(houseNumberStatus);
-                } else {
-                    dateStrListBetween.forEach(dateStr -> {
-                        HouseNumberStatus houseNumberStatusNew = new HouseNumberStatus();
-                        BeanUtils.copyProperties(houseNumberStatus, houseNumberStatusNew);
-                        houseNumberStatusNew.setId(Func.newGuid());
-                        houseNumberStatusNew.setCloseType(houseNumberStatusDto.getCloseType());
-                        houseNumberStatusNew.setSetDate(dateStr);
-                        houseNumberStatusNew.setRemark(houseNumberStatusDto.getRemark());
-                        houseNumberStatusList.add(houseNumberStatusNew);
-                    });
-                }
+                dateStrListBetween.forEach(dateStr -> {
+                    HouseNumberStatus houseNumberStatusNew = new HouseNumberStatus();
+                    BeanUtils.copyProperties(houseNumberStatus, houseNumberStatusNew);
+                    houseNumberStatusNew.setId(Func.newGuid());
+                    houseNumberStatusNew.setCloseType(houseNumberStatusDto.getCloseType());
+                    houseNumberStatusNew.setSetDate(dateStr);
+                    houseNumberStatusNew.setRemark(houseNumberStatusDto.getRemark());
+                    houseNumberStatusList.add(houseNumberStatusNew);
+                });
             });
             houseNumberStatusDao.saveBatch(houseNumberStatusList);
-        } else {
+        } else if (status == 0) {
+            // 开房
             houseNumberStatusDto.setModifyDate(dataTime);
             houseNumberStatusDao.updateStatus(houseNumberStatusDto);
         }
@@ -265,28 +231,28 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
     public void modifyStatus(HouseNumberStatusDto houseNumberStatusDto) {
         Integer status = houseNumberStatusDto.getStatus();
         String createId = houseNumberStatusDto.getCreateId();
-        boolean isStatusEqualsThree = status == 3;
-        boolean isStatusEqualsFour = status == 4;
         Date dataTime = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
-        if (isStatusEqualsThree || isStatusEqualsFour) {
+        if (status == 2) {
+            // 关房
             HouseNumberStatus houseNumberStatus = new HouseNumberStatus();
             BeanUtils.copyProperties(houseNumberStatusDto, houseNumberStatus);
             houseNumberStatus.setId(Func.newGuid());
             houseNumberStatus.setCreateDate(dataTime);
             houseNumberStatus.setCreateId(createId);
             houseNumberStatusDao.saveBatch(Collections.singletonList(houseNumberStatus));
-        } else {
+        } else if (status == 0) {
+            // 开房
             houseNumberStatusDto.setModifyDate(dataTime);
             houseNumberStatusDao.updateStatus(houseNumberStatusDto);
         }
     }
 
-    private List<JSONObject> buildResultOne(List<House> houseList, List<HouseNumber> houseNumberList) {
+    private List<JSONObject> buildResultOne(List<House> houseList, List<HouseNumberDto> houseNumberList) {
         List<JSONObject> result = new ArrayList<>();
         Map<String, List<HouseNumber>> houseNumberMap = houseNumberList.stream().collect(Collectors.groupingBy(HouseNumber::getHouseId));
         houseList.forEach(house -> {
             JSONObject houseJosoObj = (JSONObject) JSONObject.toJSON(house);
-            houseJosoObj.put("HouseNumberList", houseNumberMap.getOrDefault(house.getId(), Collections.emptyList()));
+            houseJosoObj.put("houseNumberList", houseNumberMap.getOrDefault(house.getId(), Collections.emptyList()));
             result.add(houseJosoObj);
         });
         return result;
@@ -316,7 +282,7 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
      */
     private Double getPrice(Date dateIn, House house, List<HousePriceDto> housePriceDtoList) {
         Double price = house.getPrice();
-        if (housePriceDtoList.isEmpty()) return price;
+        if (housePriceDtoList == null || housePriceDtoList.isEmpty()) return price;
         for (HousePriceDto priceDto : housePriceDtoList) {
             String[] date = priceDto.getSetDate().split(",");
             Date startDate = DateUtil.parseDateOnly(date[0]);
@@ -336,10 +302,10 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
      *
      * @return 当天剩余房间数量
      */
-    private int getSum(String dateIn, List<HouseNumber> houseNumberList) {
+    private int getSum(String dateIn, List<HouseNumberDto> houseNumberList) {
         int total = houseNumberList.size();
         int used = 0;
-        for (HouseNumber houseNumber : houseNumberList) {
+        for (HouseNumberDto houseNumber : houseNumberList) {
             List<HouseNumberStatusDto> houseNumberStatuses = houseNumber.getHouseNumberStatuses();
             if (houseNumberStatuses != null && !houseNumberStatuses.isEmpty()) {
                 boolean flag = houseNumberStatuses.stream().anyMatch(item -> dateIn.equals(item.getSetDate()));

+ 2 - 2
mhotel/src/com/happy/service/impl/HousePriceServiceImpl.java

@@ -121,7 +121,7 @@ public class HousePriceServiceImpl implements HousePriceService {
     public void exportHistory(HousePriceDto housePriceDto) {
         if (StringUtils.isBlank(housePriceDto.getManagerId())) return;
         List<HousePriceDto> list = housePriceDao.queryListThree(housePriceDto, null, null);
-        if (list.isEmpty()) return;
+        if (list == null || list.isEmpty()) return;
         // List<Vector<Object>> vectorsList = new ArrayList<>();
         List<Vector> vectorsList = new ArrayList<>();
         list.forEach(housePrice -> {
@@ -163,7 +163,7 @@ public class HousePriceServiceImpl implements HousePriceService {
      */
     private Double getPrice(Date dateIn, HousePriceDto housePriceDto, List<HousePriceDto> housePriceDtoList) {
         Double price = housePriceDto.getOriginalPrice();
-        if (housePriceDtoList.isEmpty()) return price;
+        if (housePriceDtoList == null || housePriceDtoList.isEmpty()) return price;
         for (HousePriceDto priceDto : housePriceDtoList) {
             String[] date = priceDto.getSetDate().split(",");
             Date startDate = DateUtil.parseDateOnly(date[0]);

+ 2 - 0
mhotel/src/struts.xml

@@ -43,6 +43,8 @@
 		</action>
 		<action name="house/price/*" method = "{1}" class="com.happy.action.HousePriceAction">
 		</action>
+		<action name="house/number/*" method = "{1}" class="com.happy.action.HouseNumberAction">
+		</action>
 		<action name="house/number/status/*" method = "{1}" class="com.happy.action.HouseNumberStatusAction">
 		</action>
 		<action name="book*" method = "{1}" class="com.happy.action.bookAction">