fix:分页排序将已结束的订单放到最后,修复未提交审批的订单查询问题
This commit is contained in:
parent
c840f523ed
commit
04ba946e9f
|
@ -35,7 +35,8 @@ import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.FSSCConstant.*;
|
import static com.chint.infrastructure.constant.FSSCConstant.*;
|
||||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL;
|
||||||
|
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER;
|
||||||
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_CITY;
|
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_CITY;
|
||||||
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_COUNTY;
|
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_COUNTY;
|
||||||
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL_NAME;
|
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL_NAME;
|
||||||
|
@ -138,11 +139,16 @@ public class OrderQuery {
|
||||||
//根据系统标识进行筛选
|
//根据系统标识进行筛选
|
||||||
routeOrders = sysCodeFilter(routeOrders, queryData.getSysCode());
|
routeOrders = sysCodeFilter(routeOrders, queryData.getSysCode());
|
||||||
|
|
||||||
|
//将已结束的行程放到最后
|
||||||
|
Comparator<RouteOrder> statusComparator = Comparator.comparing(
|
||||||
|
(RouteOrder order) -> order.getOrderStatus().equals(ORDER_STATUS_FINISH),
|
||||||
|
Comparator.reverseOrder()
|
||||||
|
);
|
||||||
|
|
||||||
int total = routeOrders.size();
|
int total = routeOrders.size();
|
||||||
List<RouteOrderPageRes> orders = routeOrders
|
List<RouteOrderPageRes> orders = routeOrders
|
||||||
.stream()
|
.stream()
|
||||||
.sorted(Comparator.comparing(RouteOrder::getUpdateTime).reversed())
|
.sorted(statusComparator.thenComparing(RouteOrder::getUpdateTime).reversed())
|
||||||
.skip((long) (pageNum - 1) * pageSize)
|
.skip((long) (pageNum - 1) * pageSize)
|
||||||
.limit(pageSize)
|
.limit(pageSize)
|
||||||
.map(routeOrder -> {
|
.map(routeOrder -> {
|
||||||
|
@ -539,18 +545,24 @@ public class OrderQuery {
|
||||||
|
|
||||||
public List<RouteOrderPageRes> queryNotSubmit(OrderQueryData queryData) {
|
public List<RouteOrderPageRes> queryNotSubmit(OrderQueryData queryData) {
|
||||||
User currentUser = BaseContext.getCurrentUser();
|
User currentUser = BaseContext.getCurrentUser();
|
||||||
List<RouteOrder> routeOrders = routeRepository.findByActualOrderNoNotNull(queryData);
|
List<RouteOrder> routeOrders = routeRepository.findAllByEmployeeNo(currentUser.getEmployeeNo());
|
||||||
routeOrders = routeOrders.stream().filter(it -> it.getUserId().equals(currentUser.getEmployeeNo())).toList();
|
routeOrders = routeOrders.stream().filter(it -> it.getUserId().equals(currentUser.getEmployeeNo())).toList();
|
||||||
routeOrders.forEach(route -> orderDomainService.queryLocation(route.getLegItems()));
|
routeOrders.forEach(route -> {
|
||||||
|
orderDomainService.queryLocation(route.getLegItems());
|
||||||
|
orderDomainService.checkRouteOrderStatus(route);
|
||||||
|
});
|
||||||
Stream<RouteOrder> stream = routeOrders.stream();
|
Stream<RouteOrder> stream = routeOrders.stream();
|
||||||
if (queryData.getSupplierName() != null) {
|
if (queryData.getSupplierName() != null) {
|
||||||
stream = stream
|
stream = stream
|
||||||
.filter(it-> it.getRouteRequestList()
|
.filter(it -> it.getRouteRequestList() == null || it.getRouteRequestList().isEmpty() ||
|
||||||
|
it.getRouteRequestList()
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(routeRequest -> !routeRequest.getSupplier().equals(queryData.getSupplierName())));
|
.anyMatch(routeRequest -> !routeRequest.getSupplier().equals(queryData.getSupplierName())));
|
||||||
}
|
}
|
||||||
return stream
|
return stream
|
||||||
.filter(order -> order.reloadStatus().getOrderStatus().equals(ORDER_STATUS_APPROVAL))
|
.filter(order -> order.getApproveOrderNo() != null && order.getApproveOrderNo().getActualOrderNo() != null)
|
||||||
|
.filter(order -> order.getOrderStatus().equals(ORDER_STATUS_APPROVAL))
|
||||||
|
.sorted(Comparator.comparing(RouteOrder::getUpdateTime).reversed())
|
||||||
.map(order -> {
|
.map(order -> {
|
||||||
User user = userRepository.findByUserEmployeeNo(order.getUserId());
|
User user = userRepository.findByUserEmployeeNo(order.getUserId());
|
||||||
return getRouteOrderPageRes(order, user);
|
return getRouteOrderPageRes(order, user);
|
||||||
|
|
|
@ -149,7 +149,6 @@ public class OrderDomainService {
|
||||||
if (leg.getDestinationId() != null) {
|
if (leg.getDestinationId() != null) {
|
||||||
leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId()));
|
leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -450,4 +449,11 @@ public class OrderDomainService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RouteOrder checkRouteOrderStatus(RouteOrder routeOrder) {
|
||||||
|
if(routeOrder.getOrderStatus() == null ) {
|
||||||
|
routeOrder.reloadStatus();
|
||||||
|
routeRepository.save(routeOrder);
|
||||||
|
}
|
||||||
|
return routeOrder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,4 +46,5 @@ public class SystemDomainService {
|
||||||
.map(AccountCompany::getCompanyName)
|
.map(AccountCompany::getCompanyName)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import com.chint.domain.aggregates.user.User;
|
||||||
import com.chint.domain.repository.*;
|
import com.chint.domain.repository.*;
|
||||||
import com.chint.domain.service.JTCompanyDomainService;
|
import com.chint.domain.service.JTCompanyDomainService;
|
||||||
import com.chint.domain.service.OrderDomainService;
|
import com.chint.domain.service.OrderDomainService;
|
||||||
|
import com.chint.domain.service.SystemDomainService;
|
||||||
import com.chint.domain.service.order_sync.LYOrderSyncAdapter;
|
import com.chint.domain.service.order_sync.LYOrderSyncAdapter;
|
||||||
import com.chint.domain.value_object.RanksData;
|
import com.chint.domain.value_object.RanksData;
|
||||||
import com.chint.infrastructure.repository.CTripOrderDetailImpl;
|
import com.chint.infrastructure.repository.CTripOrderDetailImpl;
|
||||||
|
@ -149,6 +150,10 @@ class RouteApplicationTests {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderDomainService orderDomainService;
|
private OrderDomainService orderDomainService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemDomainService systemDomainService;
|
||||||
|
|
||||||
|
|
||||||
void test3() {
|
void test3() {
|
||||||
FlyOkDTO freightDTO = new FlyOkDTO();
|
FlyOkDTO freightDTO = new FlyOkDTO();
|
||||||
ParamFly param = new ParamFly();
|
ParamFly param = new ParamFly();
|
||||||
|
@ -1271,4 +1276,9 @@ class RouteApplicationTests {
|
||||||
}
|
}
|
||||||
System.out.println(receiptsNum);
|
System.out.println(receiptsNum);
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
void testS(){
|
||||||
|
Optional<String> s = systemDomainService.companyNameByAccountId(null);
|
||||||
|
s.ifPresent(System.out::println);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue