Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
lulz1 2024-05-28 10:45:58 +08:00
commit 1e090f0825
13 changed files with 98 additions and 38 deletions

View File

@ -125,4 +125,10 @@ public class UserController {
}
return Result.Success(SUCCESS, userDepartmentInfoList);
}
@ApiOperation("获取当前登录用户信息")
@PostMapping("/current")
public Result<User> currentUser() {
return Result.Success(SUCCESS, BaseContext.getCurrentUser());
}
}

View File

@ -28,4 +28,6 @@ public interface JdbcOrderDetailRepository extends CrudRepository<OrderDetail, L
List<OrderDetail> findByCreateTimeBetweenAndProductType(LocalDateTime createTime, LocalDateTime createTime2, Integer productType);
List<OrderDetail> findByCreateTimeBetweenAndProductTypeAndOrderNoContaining(LocalDateTime createTime, LocalDateTime createTime2, Integer productType, String orderNo);
List<OrderDetail> findByUpdateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2);
List<OrderDetail> findAllByRouteIdIn(Collection<Long> routeIds);
}

View File

@ -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<RouteOrder> findByField();
List<RouteOrder> findByRouteOrderNoIn(Collection<String> routeOrderNo);
List<RouteOrder> 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<String> findByActualOrderNo(@Param("actualOrderNo") String actualOrderNo);
}

View File

@ -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<ApprovalEvent> approveEvents;
// private List<ApprovalEvent> approveEvents;
private String approvalStatus;
private List<Leg> legItems;
//差旅订单总价值
private List<LocationRes> locationResList;
public String getApprovalStatus() {
if (this.approveEvents != null && !this.approveEvents.isEmpty()) {
ApprovalEvent lastApprovalEvent = getLastApprovalEvent();
public String getApprovalStatus(List<ApprovalEvent> 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<ApprovalEvent> approveEvents) {
return approveEvents.isEmpty() ? null : approveEvents.get(approveEvents.size() - 1);
}
}

View File

@ -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=""; //申请单号
}

View File

@ -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<String> userIds=new ArrayList<>();
}

View File

@ -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<String> userIds=new ArrayList<>();
}

View File

@ -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<CarOrderDetail, Long> {
Page<CarOrderDetail> findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
Page<CarOrderDetail> findAllByUserNameContainsAndOrderNoIn(String userName, List<String> orderNo, Pageable pageable);
Page<CarOrderDetail> findAllByUserNameContains(String userName, Pageable pageable);
}

View File

@ -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<FlightOrderDetail, Long> {
Page<FlightOrderDetail> findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
Page<FlightOrderDetail> findAllByUserNameContainsAndOrderNoIn(String userName, List<String> orderNo, Pageable pageable);
Page<FlightOrderDetail> findAllByUserNameContains(String userName, Pageable pageable);
}

View File

@ -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<HotelOrderDetail, Long> {
Page<HotelOrderDetail> findAllByBookingNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
Page<HotelOrderDetail> findAllByBookingNameContainsAndOrderNoIn(String userName, List<String> orderNo, Pageable pageable);
Page<HotelOrderDetail> findAllByBookingNameContains(String userName, Pageable pageable);
}

View File

@ -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<TrainOrderDetail, Long> {
Page<TrainOrderDetail> findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
Page<TrainOrderDetail> findAllByUserNameContainsAndOrderNoIn(String userName, List<String> orderNo, Pageable pageable);
Page<TrainOrderDetail> findAllByUserNameContains(String userName, Pageable pageable);
}

View File

@ -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<String, Object> 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<? extends BaseExcel> 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<? extends BaseExcel> data=new PageImpl<>(Collections.emptyList());
//申请单查询
if (!dto.getActualOrderNo().isEmpty()){
List<String> orderNos=jdbcRouteRepository.findByActualOrderNo("%" + dto.getActualOrderNo() + "%");
if (orderNos.isEmpty()){
return new PageResult<BaseExcel>(0,new ArrayList<>());
}
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.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.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());
}

View File

@ -89,10 +89,13 @@ public class ManageServiceImpl implements ManageService {
@Override
public PageResult<ItineraryPageDto> itineraryPageQuery(ItineraryPageQuery dto) {
List<User> users=jdbcUserRepository.findAllByNameContains(dto.getApplicant());
List<User> 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<ItineraryPageDto> 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<Leg> legItems=res.getLegItems();
private static ItineraryPageDto getRouteOrderPageRes(ItineraryPageDto res, User user,List<Leg> legItems) {
List<LocationRes> locationRes = legItems
.stream()
.flatMap(leg -> Stream.of(leg.getOriginLocation(), leg.getDestinationLocation()))