Commit 535826ec by 丁伟峰

增加了日期查询

1 parent fd6a4e09
...@@ -3,7 +3,7 @@ package com.alibaba.cloud.integration.order.controller; ...@@ -3,7 +3,7 @@ package com.alibaba.cloud.integration.order.controller;
import com.alibaba.cloud.integration.common.BusinessException; import com.alibaba.cloud.integration.common.BusinessException;
import com.alibaba.cloud.integration.common.Result; import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dto.EngineersGanttReqDTO; import com.alibaba.cloud.integration.order.dto.EngineersGanttReqDTO;
import com.alibaba.cloud.integration.order.dto.WorkbenchOrderChangeListReqDTO; import com.alibaba.cloud.integration.order.dto.OrderChangeListReqDTO;
import com.alibaba.cloud.integration.order.service.WorkbenchService; import com.alibaba.cloud.integration.order.service.WorkbenchService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -19,7 +19,7 @@ public class WorkbenchController { ...@@ -19,7 +19,7 @@ public class WorkbenchController {
WorkbenchService workbenchService; WorkbenchService workbenchService;
@GetMapping("/workbench/serviceOrder/change/list") @GetMapping("/workbench/serviceOrder/change/list")
public Result<?> orderChangeList(@Validated WorkbenchOrderChangeListReqDTO reqDTO) { public Result<?> orderChangeList(@Validated OrderChangeListReqDTO reqDTO) {
Result<?> res = null; Result<?> res = null;
try { try {
res = workbenchService.getOrderChangeList(reqDTO); res = workbenchService.getOrderChangeList(reqDTO);
......
...@@ -8,17 +8,19 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -8,17 +8,19 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Date;
@Repository @Repository
@Where(clause = "status = 1") @Where(clause = "status = 1")
public interface OrderChangeDao extends JpaRepository<OrderChangeEntity, Integer> { public interface OrderChangeDao extends JpaRepository<OrderChangeEntity, Integer> {
@Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgClusterId = :clusterId") @Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgClusterId = :clusterId and Date(a.createTime) = :date")
Page<OrderChangeEntity> findAllByClusterId(String clusterId, Pageable pageable); Page<OrderChangeEntity> findAllByClusterId(String clusterId, Date date, Pageable pageable);
@Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgBranchId = :branchId") @Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgBranchId = :branchId and Date(a.createTime) = :date")
Page<OrderChangeEntity> findAllByBranchId(String branchId, Pageable pageable); Page<OrderChangeEntity> findAllByBranchId(String branchId, Date date, Pageable pageable);
@Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgGroupId = :groupId") @Query("select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgGroupId = :groupId and Date(a.createTime) = :date")
Page<OrderChangeEntity> findAllByGroupId(String groupId, Pageable pageable); Page<OrderChangeEntity> findAllByGroupId(String groupId, Date date, Pageable pageable);
} }
package com.alibaba.cloud.integration.order.dto; package com.alibaba.cloud.integration.order.dto;
import java.util.Date;
@lombok.Data @lombok.Data
public class WorkbenchOrderChangeListReqDTO { public class OrderChangeListReqDTO {
/** /**
* 查询范围:root/cluster/branch/group * 查询范围:root/cluster/branch/group
*/ */
...@@ -12,6 +14,7 @@ public class WorkbenchOrderChangeListReqDTO { ...@@ -12,6 +14,7 @@ public class WorkbenchOrderChangeListReqDTO {
private String levelValue; private String levelValue;
private int page; private int page;
private int size; private int size;
private Date date = new Date();
/** /**
* 排序 * 排序
*/ */
......
...@@ -6,7 +6,7 @@ import java.util.List; ...@@ -6,7 +6,7 @@ import java.util.List;
@lombok.Data @lombok.Data
@Accessors(chain = true) @Accessors(chain = true)
public class WorkbenchOrderChangeListRespDTO { public class OrderChangeListRespDTO {
private List<?> content; private List<?> content;
private long pageCurrent; private long pageCurrent;
private long pages; private long pages;
......
...@@ -2,10 +2,10 @@ package com.alibaba.cloud.integration.order.service; ...@@ -2,10 +2,10 @@ package com.alibaba.cloud.integration.order.service;
import com.alibaba.cloud.integration.common.Result; import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dto.EngineersGanttReqDTO; import com.alibaba.cloud.integration.order.dto.EngineersGanttReqDTO;
import com.alibaba.cloud.integration.order.dto.WorkbenchOrderChangeListReqDTO; import com.alibaba.cloud.integration.order.dto.OrderChangeListReqDTO;
public interface WorkbenchService { public interface WorkbenchService {
Result<?> getOrderChangeList(WorkbenchOrderChangeListReqDTO orderChangeListReqDTO); Result<?> getOrderChangeList(OrderChangeListReqDTO orderChangeListReqDTO);
Result<?> getEngineersGanttList(EngineersGanttReqDTO ganttReqDTO); Result<?> getEngineersGanttList(EngineersGanttReqDTO ganttReqDTO);
} }
...@@ -39,22 +39,22 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -39,22 +39,22 @@ public class WorkbenchServiceImpl implements WorkbenchService {
private CapacityEngineerStatDao capacityEngineerStatDao; private CapacityEngineerStatDao capacityEngineerStatDao;
@Override @Override
public Result<?> getOrderChangeList(WorkbenchOrderChangeListReqDTO orderChangeListReqDTO) { public Result<?> getOrderChangeList(OrderChangeListReqDTO reqDTO) {
Pageable pageable = PageRequest.of(orderChangeListReqDTO.getPage() - 1, orderChangeListReqDTO.getSize()); Pageable pageable = PageRequest.of(reqDTO.getPage() - 1, reqDTO.getSize());
Page<?> changes; Page<?> changes;
String levelType = orderChangeListReqDTO.getLevelType(); String levelType = reqDTO.getLevelType();
String levelValue = orderChangeListReqDTO.getLevelValue(); String levelValue = reqDTO.getLevelValue();
if ("cluster".equals(levelType)) { if ("cluster".equals(levelType)) {
changes = orderChangeDao.findAllByClusterId(levelValue, pageable); changes = orderChangeDao.findAllByClusterId(levelValue, reqDTO.getDate(), pageable);
} else if ("branch".equals(levelType)) { } else if ("branch".equals(levelType)) {
changes = orderChangeDao.findAllByBranchId(levelValue, pageable); changes = orderChangeDao.findAllByBranchId(levelValue, reqDTO.getDate(), pageable);
} else { } else {
changes = orderChangeDao.findAllByGroupId(levelValue, pageable); changes = orderChangeDao.findAllByGroupId(levelValue, reqDTO.getDate(), pageable);
} }
List<WorkbenchOrderChangeListRespDTO.Content> contents = new ArrayList<>(); List<OrderChangeListRespDTO.Content> contents = new ArrayList<>();
for (Object e1 : changes.getContent()) { for (Object e1 : changes.getContent()) {
OrderChangeEntity e = (OrderChangeEntity) e1; OrderChangeEntity e = (OrderChangeEntity) e1;
WorkbenchOrderChangeListRespDTO.Content content = new WorkbenchOrderChangeListRespDTO.Content(); OrderChangeListRespDTO.Content content = new OrderChangeListRespDTO.Content();
OrderRequestEntity orderRequestEntity = orderRequestDao.getByOrderId(e.getOrderId()); OrderRequestEntity orderRequestEntity = orderRequestDao.getByOrderId(e.getOrderId());
content.setOrderId(e.getOrderId()) content.setOrderId(e.getOrderId())
.setCustomerName(orderRequestEntity.getName()) .setCustomerName(orderRequestEntity.getName())
...@@ -64,12 +64,12 @@ public class WorkbenchServiceImpl implements WorkbenchService { ...@@ -64,12 +64,12 @@ public class WorkbenchServiceImpl implements WorkbenchService {
.setUpdateTime(e.getUpdateTime().toString()); .setUpdateTime(e.getUpdateTime().toString());
contents.add(content); contents.add(content);
} }
WorkbenchOrderChangeListRespDTO resp = new WorkbenchOrderChangeListRespDTO(); OrderChangeListRespDTO respDTO = new OrderChangeListRespDTO();
resp.setTotal(changes.getTotalElements()) respDTO.setTotal(changes.getTotalElements())
.setPages(changes.getTotalPages()) .setPages(changes.getTotalPages())
.setPageSize(changes.getSize()) .setPageSize(changes.getSize())
.setContent(contents); .setContent(contents);
return Result.success(resp); return Result.success(respDTO);
} }
@Override @Override
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!