diff --git a/src/main/java/com/chint/application/system/UserController.java b/src/main/java/com/chint/application/system/UserController.java index f98c0775..fb87565e 100644 --- a/src/main/java/com/chint/application/system/UserController.java +++ b/src/main/java/com/chint/application/system/UserController.java @@ -125,4 +125,10 @@ public class UserController { } return Result.Success(SUCCESS, userDepartmentInfoList); } + + @ApiOperation("获取当前登录用户信息") + @PostMapping("/current") + public Result currentUser() { + return Result.Success(SUCCESS, BaseContext.getCurrentUser()); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java index 9ac69782..b8002582 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java @@ -28,4 +28,6 @@ public interface JdbcOrderDetailRepository extends CrudRepository findByCreateTimeBetweenAndProductType(LocalDateTime createTime, LocalDateTime createTime2, Integer productType); List findByCreateTimeBetweenAndProductTypeAndOrderNoContaining(LocalDateTime createTime, LocalDateTime createTime2, Integer productType, String orderNo); List findByUpdateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); + + List findAllByRouteIdIn(Collection routeIds); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java index e10381d1..a4b68834 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import java.time.LocalDateTime; @@ -52,4 +53,10 @@ select * from route_order r1 left join route_custom_extension_field r2 on r1.rou List findByField(); List findByRouteOrderNoIn(Collection routeOrderNo); + + List findAllByApproveOrderNo_ActualOrderNoContaining(String approveOrderNo_actualOrderNo); + + @Query("select od.order_no from route_order ro,order_detail od where ro.route_id=od.route_id and ro.actual_order_no like :actualOrderNo") + List findByActualOrderNo(@Param("actualOrderNo") String actualOrderNo); + } diff --git a/src/main/java/com/chint/manage/entity/dto/ItineraryPageDto.java b/src/main/java/com/chint/manage/entity/dto/ItineraryPageDto.java index 85d034ed..94ec51e1 100644 --- a/src/main/java/com/chint/manage/entity/dto/ItineraryPageDto.java +++ b/src/main/java/com/chint/manage/entity/dto/ItineraryPageDto.java @@ -14,9 +14,9 @@ public class ItineraryPageDto { private Long routeId; //差旅订单单号 private String routeOrderNo; - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private LocalDateTime startTime; - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private LocalDateTime endTime; private String userId; private String userName; @@ -25,18 +25,16 @@ public class ItineraryPageDto { //申请说明 private String instructions; private String actualOrderNo; - private List approveEvents; +// private List approveEvents; private String approvalStatus; - private List legItems; - //差旅订单总价值 private List locationResList; - public String getApprovalStatus() { - if (this.approveEvents != null && !this.approveEvents.isEmpty()) { - ApprovalEvent lastApprovalEvent = getLastApprovalEvent(); + public String getApprovalStatus(List approveEvents) { + if (approveEvents != null && !approveEvents.isEmpty()) { + ApprovalEvent lastApprovalEvent = getLastApprovalEvent(approveEvents); if (lastApprovalEvent != null) { lastApprovalEvent.reloadStatus(); this.approvalStatus = lastApprovalEvent.getEventName(); @@ -44,7 +42,7 @@ public class ItineraryPageDto { } return approvalStatus; } - private ApprovalEvent getLastApprovalEvent() { - return this.approveEvents.isEmpty() ? null : this.approveEvents.get(this.approveEvents.size() - 1); + private ApprovalEvent getLastApprovalEvent(List approveEvents) { + return approveEvents.isEmpty() ? null : approveEvents.get(approveEvents.size() - 1); } } diff --git a/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java b/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java index dfd37b77..41407ec8 100644 --- a/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java +++ b/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java @@ -14,6 +14,6 @@ public class ConsumptionDetailQuery extends BaseQuery{ * 0-火车 1飞机 2酒店 3打车 */ private Integer productType; - private String userName; - private String orderNo; + private String userName=""; + private String actualOrderNo=""; //申请单号 } diff --git a/src/main/java/com/chint/manage/entity/query/ItineraryPageQuery.java b/src/main/java/com/chint/manage/entity/query/ItineraryPageQuery.java index 62e2ebc1..4d7e7639 100644 --- a/src/main/java/com/chint/manage/entity/query/ItineraryPageQuery.java +++ b/src/main/java/com/chint/manage/entity/query/ItineraryPageQuery.java @@ -8,7 +8,7 @@ import java.util.List; @Data public class ItineraryPageQuery extends BaseQuery { - private String applicant;// 申请人 - private String actualOrderNo; //申请单号 + private String applicant="";// 申请人 + private String actualOrderNo=""; //申请单号 private List userIds=new ArrayList<>(); } diff --git a/src/main/java/com/chint/manage/entity/query/OrderPageQuery.java b/src/main/java/com/chint/manage/entity/query/OrderPageQuery.java index f3e08024..ae52fbbd 100644 --- a/src/main/java/com/chint/manage/entity/query/OrderPageQuery.java +++ b/src/main/java/com/chint/manage/entity/query/OrderPageQuery.java @@ -9,13 +9,13 @@ import java.util.List; @Data public class OrderPageQuery extends BaseQuery { //订单号 - private String oderNo; + private String oderNo=""; //申请单号 - private String actualOrderNo; + private String actualOrderNo=""; //出行人 - private String travelers; + private String travelers=""; //预订人 - private String applicant; + private String applicant=""; //开始日期 private String startTime; //结束日期 @@ -23,6 +23,6 @@ public class OrderPageQuery extends BaseQuery { //产品类型 private String productType; //部门名称 - private String deptName; + private String deptName=""; private List userIds=new ArrayList<>(); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java index e618902d..e3c7238c 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java @@ -1,13 +1,20 @@ package com.chint.manage.mapper; import com.chint.domain.aggregates.order.CarOrderDetail; +import com.chint.domain.aggregates.order.HotelOrderDetail; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface JdbcCarOrderDetailRepository extends CrudRepository { Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); + + Page findAllByUserNameContainsAndOrderNoIn(String userName, List orderNo, Pageable pageable); + + Page findAllByUserNameContains(String userName, Pageable pageable); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java index e8d30c7c..2dc921c5 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java @@ -1,13 +1,20 @@ package com.chint.manage.mapper; import com.chint.domain.aggregates.order.FlightOrderDetail; +import com.chint.domain.aggregates.order.TrainOrderDetail; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface JdbcFlightOrderDetailRepository extends CrudRepository { Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); + + Page findAllByUserNameContainsAndOrderNoIn(String userName, List orderNo, Pageable pageable); + + Page findAllByUserNameContains(String userName, Pageable pageable); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java index 4fcda59e..1d73e0c2 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java @@ -1,5 +1,6 @@ package com.chint.manage.mapper; +import com.chint.domain.aggregates.order.FlightOrderDetail; import com.chint.domain.aggregates.order.HotelOrderDetail; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; import org.springframework.data.domain.Page; @@ -7,8 +8,14 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface JdbcHotelOrderDetailRepository extends CrudRepository { Page findAllByBookingNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); + + Page findAllByBookingNameContainsAndOrderNoIn(String userName, List orderNo, Pageable pageable); + + Page findAllByBookingNameContains(String userName, Pageable pageable); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java index ca270676..24bacd8a 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java @@ -6,8 +6,14 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface JdbcTrainOrderDetailRepository extends CrudRepository { Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); + + Page findAllByUserNameContainsAndOrderNoIn(String userName, List orderNo, Pageable pageable); + + Page findAllByUserNameContains(String userName, Pageable pageable); } diff --git a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java index 29148b91..e51ba020 100644 --- a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java +++ b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java @@ -1,6 +1,8 @@ package com.chint.manage.mapper.impl; import com.chint.domain.aggregates.order.*; +import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository; +import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository; import com.chint.infrastructure.util.PageResult; import com.chint.manage.entity.dto.ItineraryPageDto; import com.chint.manage.entity.query.ConsumptionDetailQuery; @@ -41,6 +43,10 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai private JdbcHotelOrderDetailRepository jdbcHotelOrderDetailRepository; @Autowired private JdbcFlightOrderDetailRepository jdbcFlightOrderDetailRepository; + @Autowired + private JdbcRouteRepository jdbcRouteRepository; + @Autowired + private JdbcOrderDetailRepository jdbcOrderDetailRepository; @Override @@ -54,6 +60,10 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai } Map params = new HashMap<>(); + //设置null + if (dto.getActualOrderNo().isEmpty()){ + dto.setActualOrderNo(null); + } params.put("actualOrderNo", dto.getActualOrderNo()); params.put("userIds", dto.getUserIds()); PageRequest pageRequest = PageRequest @@ -71,20 +81,29 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai @Override public PageResult pageConsumptionDetail(ConsumptionDetailQuery dto) { - if (dto.getUserName()==null){ - dto.setUserName(""); - } - if (dto.getOrderNo()==null){ - dto.setOrderNo(""); - } PageRequest pageRequest = PageRequest .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending()); Page data=new PageImpl<>(Collections.emptyList()); + //申请单查询 + if (!dto.getActualOrderNo().isEmpty()){ + List orderNos=jdbcRouteRepository.findByActualOrderNo("%" + dto.getActualOrderNo() + "%"); + if (orderNos.isEmpty()){ + return new PageResult(0,new ArrayList<>()); + } + switch (dto.getProductType()) { + case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContainsAndOrderNoIn(dto.getUserName(),orderNos,pageRequest)); + case LEG_TYPE_AIRPLANE -> data=getOrderFlightRecord(jdbcFlightOrderDetailRepository.findAllByUserNameContainsAndOrderNoIn(dto.getUserName(),orderNos,pageRequest)); + case LEG_TYPE_HOTEL -> data=getOrderHotelRecord(jdbcHotelOrderDetailRepository.findAllByBookingNameContainsAndOrderNoIn(dto.getUserName(),orderNos,pageRequest)); + case LEG_TYPE_TAXI -> data=getOrderCarRecord(jdbcCarOrderDetailRepository.findAllByUserNameContainsAndOrderNoIn(dto.getUserName(),orderNos,pageRequest)); + } + return PageResult.totalPageNum(data.getTotalElements(), data.getContent()); + } + switch (dto.getProductType()) { - case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getUserName(),dto.getOrderNo(),pageRequest)); - case LEG_TYPE_AIRPLANE -> data=getOrderFlightRecord(jdbcFlightOrderDetailRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getUserName(),dto.getOrderNo(),pageRequest)); - case LEG_TYPE_HOTEL -> data=getOrderHotelRecord(jdbcHotelOrderDetailRepository.findAllByBookingNameContainsAndOrderNoContaining(dto.getUserName(),dto.getOrderNo(),pageRequest)); - case LEG_TYPE_TAXI -> data=getOrderCarRecord(jdbcCarOrderDetailRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getUserName(),dto.getOrderNo(),pageRequest)); + case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContains(dto.getUserName(),pageRequest)); + case LEG_TYPE_AIRPLANE -> data=getOrderFlightRecord(jdbcFlightOrderDetailRepository.findAllByUserNameContains(dto.getUserName(),pageRequest)); + case LEG_TYPE_HOTEL -> data=getOrderHotelRecord(jdbcHotelOrderDetailRepository.findAllByBookingNameContains(dto.getUserName(),pageRequest)); + case LEG_TYPE_TAXI -> data=getOrderCarRecord(jdbcCarOrderDetailRepository.findAllByUserNameContains(dto.getUserName(),pageRequest)); } return PageResult.totalPageNum(data.getTotalElements(), data.getContent()); } diff --git a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java index 98f1de08..062a557e 100644 --- a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java +++ b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java @@ -89,9 +89,12 @@ public class ManageServiceImpl implements ManageService { @Override public PageResult itineraryPageQuery(ItineraryPageQuery dto) { - List users=jdbcUserRepository.findAllByNameContains(dto.getApplicant()); - if (users==null||users.isEmpty()){ - return null; + List users=new ArrayList<>(); + if (!dto.getApplicant().isEmpty()){ + users=jdbcUserRepository.findAllByNameContains(dto.getApplicant()); + if (users==null||users.isEmpty()){ + return null; + } } dto.setUserIds(users.stream().map(User::getEmployeeNo).toList()); Page page= jdbcConsumptionDetailRepository.itineraryPageQueryByDto(dto); @@ -105,11 +108,10 @@ public class ManageServiceImpl implements ManageService { .stream() .map(routeOrder -> { RouteOrder order=routeOrders.stream().filter(s->s.getRouteId().equals(routeOrder.getRouteId())).toList().get(0); - routeOrder.setApproveEvents(order.getApproveEvents()); - routeOrder.setLegItems(order.getLegItems()); - legDomainService.queryLocation(routeOrder.getLegItems()); + legDomainService.queryLocation(order.getLegItems()); + routeOrder.setApprovalStatus(routeOrder.getApprovalStatus(order.getApproveEvents())); User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId()); - return getRouteOrderPageRes(routeOrder, user); + return getRouteOrderPageRes(routeOrder, user,order.getLegItems()); }) .toList(); return PageResult.totalPageNum(page.getTotalElements(), orders); @@ -145,8 +147,7 @@ public class ManageServiceImpl implements ManageService { return excelList; } - private static ItineraryPageDto getRouteOrderPageRes(ItineraryPageDto res, User user) { - List legItems=res.getLegItems(); + private static ItineraryPageDto getRouteOrderPageRes(ItineraryPageDto res, User user,List legItems) { List locationRes = legItems .stream() .flatMap(leg -> Stream.of(leg.getOriginLocation(), leg.getDestinationLocation()))