Commit 535826ec by 丁伟峰

增加了日期查询

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