Commit b10f663e by 刘鑫

pref: 界面改约容量查询接口变更 支持时间段, 半天容量

1 parent df98b302
...@@ -257,10 +257,13 @@ public class CapacityUtils { ...@@ -257,10 +257,13 @@ public class CapacityUtils {
long remain = collect.stream().mapToLong(CapacityEngineerSliceUsedEntity::getCapLeft).sum(); long remain = collect.stream().mapToLong(CapacityEngineerSliceUsedEntity::getCapLeft).sum();
segment.setRemain(remain); segment.setRemain(remain);
segment.setStatus(totalTakeTime <= maxDuration ? 1 : 0); segment.setStatus(totalTakeTime <= maxDuration ? 1 : 0);
long totalCapacity = collect.stream().mapToLong(CapacityEngineerSliceUsedEntity::getCapTotal).sum();
segment.setTotalCapacity(totalCapacity);
} else { } else {
segment.setMaxDuration(0); segment.setMaxDuration(0);
segment.setRemain(0); segment.setRemain(0);
segment.setStatus(0); segment.setStatus(0);
segment.setTotalCapacity(0);
} }
return segment; return segment;
} }
......
...@@ -2,16 +2,24 @@ package com.dituhui.pea.order.controller; ...@@ -2,16 +2,24 @@ package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException; import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.OrderCreateReqDTO; import com.dituhui.pea.order.dto.param.CapacityQueryDTO;
import com.dituhui.pea.order.dto.CapacityOrderQueryDTO;
import com.dituhui.pea.order.dto.param.OrderDTO; import com.dituhui.pea.order.dto.param.OrderDTO;
import com.dituhui.pea.order.service.OrderCreateService;
import com.dituhui.pea.order.service.CapacityQueryService; import com.dituhui.pea.order.service.CapacityQueryService;
import com.dituhui.pea.order.service.OrderCreateService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.time.ZoneId;
/**
* 工单接口
*/
@RestController @RestController
@RequestMapping("/pea-order") @RequestMapping("/pea-order")
public class OrderCreateController { public class OrderCreateController {
...@@ -44,14 +52,18 @@ public class OrderCreateController { ...@@ -44,14 +52,18 @@ public class OrderCreateController {
return res; return res;
} }
/**
* 改约容量查询
*
* @param reqDTO 查询参数
* @return 返回日期范围内的容量信息
*/
@PostMapping("/order/service/capacity/query") @PostMapping("/order/service/capacity/query")
public Result<?> capacityQuery(@Validated @RequestBody CapacityOrderQueryDTO.Request reqDTO) { public Result<CapacityQueryDTO.Result> capacityQuery(@Validated @RequestBody CapacityQueryDTO.Request reqDTO) {
Result<?> res = null; //查询日期起止参数限制为一月
try { LocalDate startDate = reqDTO.getBeginDate().toInstant().atZone(ZoneId.of("+8")).toLocalDate();
res = capacityQueryService.queryMatchCapacityData(reqDTO); LocalDate endDate = reqDTO.getEndDate().toInstant().atZone(ZoneId.of("+8")).toLocalDate();
} catch (BusinessException e) {
return Result.failed(e.getMessage()); return capacityQueryService.matchCapacityData(reqDTO, reqDTO.getServices(), reqDTO.getLocation(), startDate, endDate);
}
return res;
} }
} }
...@@ -165,6 +165,11 @@ public class CapacityQueryDTO { ...@@ -165,6 +165,11 @@ public class CapacityQueryDTO {
* 剩余容量 * 剩余容量
*/ */
private long remain; private long remain;
/**
* 区间总容量
*/
private long totalCapacity;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!