xiachuang 1 سال پیش
والد
کامیت
b04e8b2372

+ 3 - 9
src/main/java/com/palmnest/application/dto/input/ConditionerAddTimeOrderUpdateParam.java

@@ -2,10 +2,8 @@ package com.palmnest.application.dto.input;
 
 import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
-import org.springmodules.validation.bean.conf.loader.annotation.handler.NotBlank;
-import org.springmodules.validation.bean.conf.loader.annotation.handler.NotEmpty;
-import org.springmodules.validation.bean.conf.loader.annotation.handler.NotNull;
 
+import java.io.Serializable;
 import java.util.Date;
 import java.util.List;
 
@@ -14,18 +12,14 @@ import java.util.List;
  * @since 2023/8/9 10:04
  */
 @Data
-public class ConditionerAddTimeOrderUpdateParam {
-    @NotEmpty
+public class ConditionerAddTimeOrderUpdateParam implements Serializable {
+    private static final long serialVersionUID = 1309632156649001152L;
     private List<Integer> roomIds;
-    @NotBlank
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
     private Date useStartTime;
-    @NotBlank
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
     private Date useEndTime;
-    @NotBlank
     private String orderNo;
-    @NotNull
     private Long orderId;
     private String remark;
     private Integer modificationDisabled = 0;

+ 12 - 9
src/main/java/com/palmnest/service/estateserve/airconditioner/impl/ConditionerAddTimeServiceImpl.java

@@ -232,6 +232,7 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
              * 项目的空调使用规则信息
              */
             List<AirRule> airRules = airRuleManager.getAirRule(airConditionerAddTime.getOrganizationId(), applicationType, applicationAirAddTime, dataType, "", "");
+            log.info("空调加时申请,查询到到的空调加时规则为:{}", airRules);
             AirRule airRule = null;
             if (null == airRules || airRules.isEmpty()) {
                 return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败,不能匹配到空调加时规则或该时段有免费的空调加时无需申请");
@@ -576,17 +577,11 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
             /**
              * 下单时保存可用的规则 修改订单时需要用
              */
-            Map<String, Object> param = new HashMap<>();
-            param.put("organizationId", airConditionerAddTime.getOrganizationId());
-            param.put("isEnabled", 1);
-            Page airRulePage = airRuleManager.findPageBy(param, 100, 1);
-            log.info("空调加时申请,查询所有可用规则,airConditionerAddTime={},结果:{}", JSON.toJSONString(airConditionerAddTime), JSON.toJSONString(airRulePage));
-            List items = airRulePage.getItems();
-            if (cn.superdesk.libs.common.util.CollectionUtils.isEmpty(items)) {
+            if (cn.superdesk.libs.common.util.CollectionUtils.isEmpty(airRules)) {
                 return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败,没有可用规则,请联系系统管理员");
             }
 
-            String allAirRulesStr = JSON.toJSONString(items);
+            String allAirRulesStr = JSON.toJSONString(airRules);
 
             /**
              * 下单时保存所有可用房间信息 修改订单时需要用
@@ -2411,6 +2406,7 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
             }
 
             List<AirRule> airRules = JSON.parseArray(extend.getAirRules(), AirRule.class);
+            log.info("空调加时订单计算费用,订单编号:{},订单id:{},空调加时规则:{}", order.getOrderNo(), order.getOrderId(), JSON.toJSONString(airRules));
 
             AirRule airRule = null;
             if (null == airRules || airRules.isEmpty()) {
@@ -2451,6 +2447,10 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
              *	使用面积
              */
             String applyArea;
+
+            List<Integer> roomIds = order.getRoomIds();
+
+
             BigDecimal calcapplyArea = BigDecimal.ZERO;// 按层申请的面积
             Map<Integer, BigDecimal> floorSumAreaMap = new HashMap<>();// 每层楼的合计申请面积
             Map<Integer, Boolean> mapIsHaveFloor = new HashMap<>();// 当前楼层是有-一层起订
@@ -2460,10 +2460,13 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
             for (RoomInfo roomInfo : roomInfos) {
 
                 Integer floorId = roomInfo.getFloorId().intValue();
-                String roomName = roomInfo.getName();
 
                 BigDecimal area = roomInfo.getArea();
                 Integer areaRuleType = roomInfo.getAreaRuleType();
+                // 选择的房间不包含当前房间则跳过
+                if (!roomIds.contains(roomInfo.getId())) {
+                    continue;
+                }
 
                 if (floorSumAreaMap.containsKey(floorId)) {
                     BigDecimal temp_area = floorSumAreaMap.get(floorId);

+ 4 - 5
src/main/java/com/palmnest/webapp/controller/backstage/AirConditionerAddTimeController.java

@@ -31,7 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ExtendedModelMap;
 import org.springframework.ui.Model;
-import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 
@@ -639,9 +638,9 @@ public class AirConditionerAddTimeController {
 	 * @param request
 	 * @return
 	 */
-	@RequestMapping(value = "/calcAddTimeOrderFee", method = RequestMethod.POST)
+	@RequestMapping(value = "/calcAddTimeOrderFee")
 	@ResponseBody
-	public AppResultDto calcAddTimeOrderFee(@RequestBody @Validated ConditionerAddTimeOrderUpdateParam order, HttpServletRequest request) {
+	public AppResultDto calcAddTimeOrderFee(@ModelAttribute ConditionerAddTimeOrderUpdateParam order, HttpServletRequest request) {
 		User  user  = (User) request.getSession().getAttribute("UserCache");
 		log.info("更新空调加时订单前计算费用, user: {}, order:{}", user.getFullName(), JSON.toJSONString(order));
 		ConditionerAddTimeOrderFeeVO vo = conditionerAddTimeService.calcAddTimeOrderFee(order);
@@ -654,9 +653,9 @@ public class AirConditionerAddTimeController {
 	 * @param request
 	 * @return
 	 */
-	@RequestMapping(value = "updateAddTimeOrder", method = RequestMethod.POST)
+	@RequestMapping(value = "updateAddTimeOrder")
 	@ResponseBody
-	public AppResultDto updateAddTimeOrder(@RequestBody @Validated ConditionerAddTimeOrderUpdateParam order, HttpServletRequest request) {
+	public AppResultDto updateAddTimeOrder(@ModelAttribute ConditionerAddTimeOrderUpdateParam order, HttpServletRequest request) {
 		User  user  = (User) request.getSession().getAttribute("UserCache");
 		log.info("更新空调加时订单, user: {}, order:{}", user.getFullName(), JSON.toJSONString(order));
 		conditionerAddTimeService.updateAddTimeOrder(order, user);