备份修改的优化结算查询的代码

This commit is contained in:
lulz1 2024-05-11 10:15:04 +08:00
parent 4fbcbd779a
commit 37af34dc63
33 changed files with 269 additions and 41 deletions

View File

@ -1,6 +1,5 @@
package com.chint.application.services.login; package com.chint.application.services.login;
import com.chint.domain.aggregates.user.User;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Optional; import java.util.Optional;

View File

@ -1,8 +1,6 @@
package com.chint.application.services.login; package com.chint.application.services.login;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.AuthException;
import com.chint.domain.exceptions.SSOLoginException; import com.chint.domain.exceptions.SSOLoginException;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;

View File

@ -21,7 +21,6 @@ import java.net.URISyntaxException;
import java.util.Optional; import java.util.Optional;
import static com.chint.infrastructure.constant.AuthMessageConstant.AUTHENTICATION_FAILED; import static com.chint.infrastructure.constant.AuthMessageConstant.AUTHENTICATION_FAILED;
import static com.chint.infrastructure.constant.BPMConstant.AN_FSSC;
@Component @Component
public class ANFeiShuLoginStrategy implements LoginStrategy { public class ANFeiShuLoginStrategy implements LoginStrategy {

View File

@ -21,10 +21,9 @@ import java.net.URISyntaxException;
import java.util.Optional; import java.util.Optional;
import static com.chint.infrastructure.constant.AuthMessageConstant.AUTHENTICATION_FAILED; import static com.chint.infrastructure.constant.AuthMessageConstant.AUTHENTICATION_FAILED;
import static com.chint.infrastructure.constant.BPMConstant.AN_FSSC;
@Component @Component
public class FeishuLoginStrategy implements LoginStrategy { public class FeishuLoginStrategy extends PailaLoginStrategy implements LoginStrategy {
@Value("${feishu.base-url}") @Value("${feishu.base-url}")
private String feishuBaseUrl; private String feishuBaseUrl;

View File

@ -74,8 +74,6 @@ public class PailaMobileLoginStrategy implements LoginStrategy {
@Override @Override
public String getUserInfo(String accessToken) { public String getUserInfo(String accessToken) {
List<NameValuePair> userInfoParams = Collections.singletonList( List<NameValuePair> userInfoParams = Collections.singletonList(
new BasicNameValuePair("access_token", accessToken) new BasicNameValuePair("access_token", accessToken)
); );

View File

@ -576,5 +576,18 @@ public class RouteOrder implements Serializable {
return routeOrderDetail; return routeOrderDetail;
} }
public boolean checkIfMine(String routeRequestNo) {
if (routeRequestNo == null || routeRequestNo.isEmpty()) {
return false;
}
if (routeRequestNo.equals(this.routeOrderNo)) {
return true;
}
for (RouteRequest routeRequest : this.getRouteRequestList()) {
if (routeRequest.getRouteRequestNo().equals(routeRequestNo)) {
return true;
}
}
return false;
}
} }

View File

@ -1,5 +1,6 @@
package com.chint.domain.factoriy.order_record; package com.chint.domain.factoriy.order_record;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.order_record.OrderCarRecord; import com.chint.domain.aggregates.order.order_record.OrderCarRecord;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
@ -9,6 +10,8 @@ import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripCa
import com.chint.interfaces.rest.amap.dto.settlement.FinishedOrderResponse; import com.chint.interfaces.rest.amap.dto.settlement.FinishedOrderResponse;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
import static com.chint.infrastructure.constant.BelongSystemConstant.TRAVAL_SYS_TYPE_CTRIP; import static com.chint.infrastructure.constant.BelongSystemConstant.TRAVAL_SYS_TYPE_CTRIP;
@ -44,4 +47,25 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
public OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData) { public OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData) {
return null; return null;
} }
@Override
public OrderCarRecord createCarOrderRecord(Object orderCarRecordData, RouteOrder routeOrder) {
return null;
}
@Override
public OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData, RouteOrder routeOrder) {
return null;
}
@Override
public OrderFlightRecord createFlightOrderRecord(Object orderFlightRecordData, RouteOrder routeOrder) {
return null;
}
@Override
public OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData, RouteOrder routeOrder) {
return null;
}
} }

View File

@ -717,6 +717,25 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
return orderHotelRecord; return orderHotelRecord;
} }
@Override
public OrderCarRecord createCarOrderRecord(Object orderCarRecordData, RouteOrder routeOrder) {
return null;
}
@Override
public OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData, RouteOrder routeOrder) {
return null;
}
@Override
public OrderFlightRecord createFlightOrderRecord(Object orderFlightRecordData, RouteOrder routeOrder) {
return null;
}
@Override
public OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData, RouteOrder routeOrder) {
return null;
}
private String getCustomCode(String name) { private String getCustomCode(String name) {
UserCustomCode userCustomCode = userCustomCodeRepository. UserCustomCode userCustomCode = userCustomCodeRepository.

View File

@ -89,6 +89,27 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
return orderHotelRecord; return orderHotelRecord;
} }
@Override
public OrderCarRecord createCarOrderRecord(Object orderCarRecordData, RouteOrder routeOrder) {
return null;
}
@Override
public OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData, RouteOrder routeOrder) {
return null;
}
@Override
public OrderFlightRecord createFlightOrderRecord(Object orderFlightRecordData, RouteOrder routeOrder) {
return null;
}
@Override
public OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData, RouteOrder routeOrder) {
return null;
}
@Override @Override
public OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData) { public OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData) {
OrderTrainRecord orderTrainRecord = new OrderTrainRecord(); OrderTrainRecord orderTrainRecord = new OrderTrainRecord();

View File

@ -1,6 +1,6 @@
package com.chint.domain.factoriy.order_record; package com.chint.domain.factoriy.order_record;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.order_record.OrderCarRecord; import com.chint.domain.aggregates.order.order_record.OrderCarRecord;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
@ -8,6 +8,7 @@ import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
public interface OrderRecordExtensionFactory { public interface OrderRecordExtensionFactory {
OrderCarRecord createCarOrderRecord(Object orderCarRecordData); OrderCarRecord createCarOrderRecord(Object orderCarRecordData);
OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData); OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData);
@ -16,4 +17,11 @@ public interface OrderRecordExtensionFactory {
OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData); OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData);
OrderCarRecord createCarOrderRecord(Object orderCarRecordData, RouteOrder routeOrder);
OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData, RouteOrder routeOrder);
OrderFlightRecord createFlightOrderRecord(Object orderFlightRecordData, RouteOrder routeOrder);
OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData, RouteOrder routeOrder);
} }

View File

@ -16,6 +16,8 @@ public interface OrderCarRecordRepository {
Optional<OrderCarRecord> findByDetailId(String detailId); Optional<OrderCarRecord> findByDetailId(String detailId);
List<OrderCarRecord> findByDetailIdIn(List<String> detailIdList);
PageResult<OrderCarRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, PageResult<OrderCarRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime,
Integer pageSize, Integer pageNum ,String systemType); Integer pageSize, Integer pageNum ,String systemType);
PageResult<OrderCarRecord> findBySystemTypeAndLastMonth(Integer pageSize, PageResult<OrderCarRecord> findBySystemTypeAndLastMonth(Integer pageSize,

View File

@ -13,6 +13,7 @@ public interface OrderFlightRecordRepository {
List<OrderFlightRecord> saveAll(List<OrderFlightRecord> orderFlightRecordList); List<OrderFlightRecord> saveAll(List<OrderFlightRecord> orderFlightRecordList);
Optional<OrderFlightRecord> findByDetailId(String detailId); Optional<OrderFlightRecord> findByDetailId(String detailId);
List<OrderFlightRecord> findByDetailIdIn(List<String> detailId);
PageResult<OrderFlightRecord> findByUpdateDataTime(LocalDateTime startTime, PageResult<OrderFlightRecord> findByUpdateDataTime(LocalDateTime startTime,
LocalDateTime endTime, LocalDateTime endTime,

View File

@ -13,6 +13,7 @@ public interface OrderHotelRecordRepository {
List<OrderHotelRecord> saveAll(List<OrderHotelRecord> orderHotelRecordList); List<OrderHotelRecord> saveAll(List<OrderHotelRecord> orderHotelRecordList);
Optional<OrderHotelRecord> findByDetailId(String detailId); Optional<OrderHotelRecord> findByDetailId(String detailId);
List<OrderHotelRecord> findByDetailIdIn(List<String> detailIds);
PageResult<OrderHotelRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, PageResult<OrderHotelRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime,
Integer pageSize, Integer pageNum, String systemType); Integer pageSize, Integer pageNum, String systemType);

View File

@ -16,6 +16,8 @@ public interface OrderTrainRecordRepository {
Optional<OrderTrainRecord> findByDetailId(String detailId); Optional<OrderTrainRecord> findByDetailId(String detailId);
List<OrderTrainRecord> findByDetailIdIn(List<String> detailIds);
PageResult<OrderTrainRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, PageResult<OrderTrainRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime,
Integer pageSize, Integer pageNum ,String systemType); Integer pageSize, Integer pageNum ,String systemType);

View File

@ -11,6 +11,8 @@ import java.util.List;
public interface RouteRepository { public interface RouteRepository {
RouteOrder queryById(Long orderId); RouteOrder queryById(Long orderId);
List<RouteOrder> queryByIdIn(List<Long> routeIds);
List<RouteOrder> queryAllInOneDayAndEffective(LocalDateTime start, LocalDateTime end); List<RouteOrder> queryAllInOneDayAndEffective(LocalDateTime start, LocalDateTime end);
void deleteById(Long orderId); void deleteById(Long orderId);

View File

@ -3,6 +3,10 @@ package com.chint.domain.repository;
import com.chint.domain.aggregates.order.RouteRequest; import com.chint.domain.aggregates.order.RouteRequest;
import java.util.List;
public interface RouteRequestRepository { public interface RouteRequestRepository {
RouteRequest findByRouteRequestNo(String routeRequestNo); RouteRequest findByRouteRequestNo(String routeRequestNo);
List<RouteRequest> findByRouteRequestNoIn(List<String> routeRequestNoList);
} }

View File

@ -17,7 +17,9 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
@ -86,32 +88,77 @@ public class OrderDetailDomainService {
} }
public List<OrderCarRecord> saveCarOrderRecordBatch(List<OrderCarRecord> orderCarRecordList) { public List<OrderCarRecord> saveCarOrderRecordBatch(List<OrderCarRecord> orderCarRecordList) {
//如果发现唯一键已经存在 那么就做更新处理 List<String> detailIds = orderCarRecordList.stream().map(OrderCarRecord::getDetailId)
orderCarRecordList.forEach(needSave-> orderCarRecordRepository .toList();
.findByDetailId(needSave.getDetailId()) List<OrderCarRecord> byDetailIdIn = orderCarRecordRepository.findByDetailIdIn(detailIds);
.ifPresent(it-> // 使用Map来映射detailId与对应的OrderCarRecord
needSave.setId(it.getId()))); Map<String, OrderCarRecord> idToExistingRecord = byDetailIdIn.stream()
.collect(Collectors.toMap(OrderCarRecord::getDetailId, record -> record));
// 遍历提交的list更新或准备新创建的记录
for (OrderCarRecord submittedRecord : orderCarRecordList) {
OrderCarRecord existingRecord = idToExistingRecord.get(submittedRecord.getDetailId());
if (existingRecord != null) {
// 如果记录已存在则更新它的ID以进行更新操作
submittedRecord.setId(existingRecord.getId());
}
}
return orderCarRecordRepository.saveAll(orderCarRecordList); return orderCarRecordRepository.saveAll(orderCarRecordList);
} }
public List<OrderFlightRecord> saveFlightOrderRecordBatch(List<OrderFlightRecord> orderFlightRecordList) { public List<OrderFlightRecord> saveFlightOrderRecordBatch(List<OrderFlightRecord> orderFlightRecordList) {
orderFlightRecordList.forEach(needSave-> orderFlightRecordRepository List<String> detailIds = orderFlightRecordList.stream().map(OrderFlightRecord::getDetailId)
.findByDetailId(needSave.getDetailId()) .toList();
.ifPresent(it-> List<OrderFlightRecord> byDetailIdIn = orderFlightRecordRepository.findByDetailIdIn(detailIds);
needSave.setId(it.getId())));
// 使用Map来映射detailId与对应的OrderFlightRecord
Map<String, OrderFlightRecord> idToExistingRecord = byDetailIdIn.stream()
.collect(Collectors.toMap(OrderFlightRecord::getDetailId, record -> record));
// 遍历提交的list更新或准备新创建的记录
for (OrderFlightRecord submittedRecord : orderFlightRecordList) {
OrderFlightRecord existingRecord = idToExistingRecord.get(submittedRecord.getDetailId());
if (existingRecord != null) {
// 如果记录已存在则更新它的ID以进行更新操作
submittedRecord.setId(existingRecord.getId());
}
}
return orderFlightRecordRepository.saveAll(orderFlightRecordList); return orderFlightRecordRepository.saveAll(orderFlightRecordList);
} }
public List<OrderTrainRecord> saveTrainOrderRecordBatch(List<OrderTrainRecord> orderTrainRecordList) { public List<OrderTrainRecord> saveTrainOrderRecordBatch(List<OrderTrainRecord> orderTrainRecordList) {
orderTrainRecordList.forEach(needSave-> orderTrainRecordRepository List<String> detailIds = orderTrainRecordList.stream().map(OrderTrainRecord::getDetailId)
.findByDetailId(needSave.getDetailId()) .toList();
.ifPresent(it-> List<OrderTrainRecord> byDetailIdIn = orderTrainRecordRepository.findByDetailIdIn(detailIds);
needSave.setId(it.getId())));
// 使用Map来映射detailId与对应的OrderFlightRecord
Map<String, OrderTrainRecord> idToExistingRecord = byDetailIdIn.stream()
.collect(Collectors.toMap(OrderTrainRecord::getDetailId, record -> record));
// 遍历提交的list更新或准备新创建的记录
for (OrderTrainRecord submittedRecord : orderTrainRecordList) {
OrderTrainRecord existingRecord = idToExistingRecord.get(submittedRecord.getDetailId());
if (existingRecord != null) {
// 如果记录已存在则更新它的ID以进行更新操作
submittedRecord.setId(existingRecord.getId());
}
}
return orderTrainRecordRepository.saveAll(orderTrainRecordList); return orderTrainRecordRepository.saveAll(orderTrainRecordList);
} }
public List<OrderHotelRecord> saveHotelOrderRecordBatch(List<OrderHotelRecord> orderHotelRecordList) { public List<OrderHotelRecord> saveHotelOrderRecordBatch(List<OrderHotelRecord> orderHotelRecordList) {
orderHotelRecordList.forEach(needSave-> orderHotelRecordRepository List<String> detailIds = orderHotelRecordList.stream().map(OrderHotelRecord::getDetailId)
.findByDetailId(needSave.getDetailId()) .toList();
.ifPresent(it-> List<OrderHotelRecord> byDetailIdIn = orderHotelRecordRepository.findByDetailIdIn(detailIds);
needSave.setId(it.getId())));
// 使用Map来映射detailId与对应的OrderFlightRecord
Map<String, OrderHotelRecord> idToExistingRecord = byDetailIdIn.stream()
.collect(Collectors.toMap(OrderHotelRecord::getDetailId, record -> record));
// 遍历提交的list更新或准备新创建的记录
for (OrderHotelRecord submittedRecord : orderHotelRecordList) {
OrderHotelRecord existingRecord = idToExistingRecord.get(submittedRecord.getDetailId());
if (existingRecord != null) {
// 如果记录已存在则更新它的ID以进行更新操作
submittedRecord.setId(existingRecord.getId());
}
}
return orderHotelRecordRepository.saveAll(orderHotelRecordList); return orderHotelRecordRepository.saveAll(orderHotelRecordList);
} }

View File

@ -14,7 +14,6 @@ import com.chint.domain.value_object.SyncLegData;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@ -221,4 +220,22 @@ public class RouteRequestDomainService {
} }
return routeRepository.queryById(routeRequest.getRouteId()); return routeRepository.queryById(routeRequest.getRouteId());
} }
public List<RouteOrder> getRouteOrder(List<String> journeyNoList) {
//先通过
List<RouteRequest> byRouteRequestNoIn = routeRequestRepository.findByRouteRequestNoIn(journeyNoList);
List<String> existedRouteRequestNo = byRouteRequestNoIn.stream().map(RouteRequest::getRouteRequestNo).toList();
List<String> needQueryFromDB = journeyNoList
.stream()
.filter(journeyNo -> !existedRouteRequestNo.contains(journeyNo))
.toList();
List<Long> routIds = byRouteRequestNoIn.stream().map(RouteRequest::getRouteId).toList();
List<RouteOrder> routeOrders = routeRepository.queryByIdIn(routIds);
if (!needQueryFromDB.isEmpty()) {
List<RouteOrder> routeOrderListFromDB = needQueryFromDB.stream().map(routeRepository::findByOrderNo).toList();
routeOrders.addAll(routeOrderListFromDB);
return routeOrders;
}
return routeOrders;
}
} }

View File

@ -200,4 +200,12 @@ public class RouteCacheService {
routeCacheManage.getRouteIdsByEmployeeNo(userId, null, newRouteIds); routeCacheManage.getRouteIdsByEmployeeNo(userId, null, newRouteIds);
} }
} }
public List<RouteOrder> queryByIdIn(List<Long> routeIds) {
if (routeIds != null && !routeIds.isEmpty()) {
return routeCacheManage.getRouteListByIds(routeIds);
} else {
return List.of();
}
}
} }

View File

@ -44,6 +44,11 @@ public class OrderCarRecordRepositoryImpl implements OrderCarRecordRepository {
return orderCarRecordRepository.findByDetailId(detailId); return orderCarRecordRepository.findByDetailId(detailId);
} }
@Override
public List<OrderCarRecord> findByDetailIdIn(List<String> detailIdList) {
return orderCarRecordRepository.findByDetailIdIn(detailIdList);
}
@Override @Override
public PageResult<OrderCarRecord> findByUpdateDataTime(LocalDateTime startTime, public PageResult<OrderCarRecord> findByUpdateDataTime(LocalDateTime startTime,
LocalDateTime endTime, LocalDateTime endTime,

View File

@ -46,6 +46,11 @@ public class OrderFlightRecordRepositoryImpl implements OrderFlightRecordReposit
return jdbcOrderFlightRecordRepository.findByDetailId(detailId); return jdbcOrderFlightRecordRepository.findByDetailId(detailId);
} }
@Override
public List<OrderFlightRecord> findByDetailIdIn(List<String> detailId) {
return jdbcOrderFlightRecordRepository.findByDetailIdIn(detailId);
}
@Override @Override
public PageResult<OrderFlightRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum, String systemType) { public PageResult<OrderFlightRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum, String systemType) {
PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending());

View File

@ -2,8 +2,6 @@ package com.chint.infrastructure.repository;
import com.chint.application.dtos.OrderRecordExtensionParam; import com.chint.application.dtos.OrderRecordExtensionParam;
import com.chint.application.dtos.OrderRecordQueryDTO; import com.chint.application.dtos.OrderRecordQueryDTO;
import com.chint.application.queryies.util.QueryUtil;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import com.chint.domain.repository.OrderHotelRecordRepository; import com.chint.domain.repository.OrderHotelRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderHotelRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderHotelRecordRepository;
@ -47,6 +45,11 @@ public class OrderHotelRecordRepositoryImpl implements OrderHotelRecordRepositor
return jdbcOrderHotelRecordRepository.findByDetailId(detailId); return jdbcOrderHotelRecordRepository.findByDetailId(detailId);
} }
@Override
public List<OrderHotelRecord> findByDetailIdIn(List<String> detailIds) {
return jdbcOrderHotelRecordRepository.findByDetailIdIn(detailIds);
}
@Override @Override
public PageResult<OrderHotelRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum, String systemType) { public PageResult<OrderHotelRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum, String systemType) {
PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending());

View File

@ -44,6 +44,11 @@ public class OrderTrainRecordRepositoryImpl implements OrderTrainRecordRepositor
return jdbcOrderTrainRecordRepository.findByDetailId(detailId); return jdbcOrderTrainRecordRepository.findByDetailId(detailId);
} }
@Override
public List<OrderTrainRecord> findByDetailIdIn(List<String> detailIds) {
return jdbcOrderTrainRecordRepository.findByDetailIdIn(detailIds);
}
@Override @Override
public PageResult<OrderTrainRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum, String systemType) { public PageResult<OrderTrainRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum, String systemType) {
PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending());

View File

@ -8,7 +8,6 @@ import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.PageResult; import com.chint.infrastructure.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
@ -16,6 +15,7 @@ import org.springframework.stereotype.Repository;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Objects;
@Repository @Repository
public class RouteRepositoryImpl implements RouteRepository { public class RouteRepositoryImpl implements RouteRepository {
@ -32,6 +32,29 @@ public class RouteRepositoryImpl implements RouteRepository {
return routeCacheService.getRouteById(orderId); return routeCacheService.getRouteById(orderId);
} }
@Override
public List<RouteOrder> queryByIdIn(List<Long> routeIds) {
List<RouteOrder> routeOrders = new java.util.ArrayList<>(routeCacheService.queryByIdIn(routeIds)
.stream()
.filter(Objects::nonNull)
.toList());
List<Long> existedRouteIds = routeOrders
.stream()
.filter(Objects::nonNull)
.map(RouteOrder::getRouteId)
.toList();
List<Long> needQueryFromDB = routeIds
.stream()
.filter(id -> !existedRouteIds.contains(id))
.toList();
List<RouteOrder> byRouteIdIn = jdbcRouteRepository
.findByRouteIdIn(needQueryFromDB);
//将查询出来的行程规划单缓存到数据库
byRouteIdIn.forEach(route -> routeCacheService.cacheRouteOrder(route));
routeOrders.addAll(byRouteIdIn);
return routeOrders;
}
@Override @Override
public List<RouteOrder> queryAllInOneDayAndEffective(LocalDateTime start, LocalDateTime end) { public List<RouteOrder> queryAllInOneDayAndEffective(LocalDateTime start, LocalDateTime end) {
return jdbcRouteRepository.findByCreateTimeBetweenAndApproveOrderNo_ActualOrderNoNotNull(start, end); return jdbcRouteRepository.findByCreateTimeBetweenAndApproveOrderNo_ActualOrderNoNotNull(start, end);
@ -64,7 +87,6 @@ public class RouteRepositoryImpl implements RouteRepository {
} }
@Override @Override
public RouteOrder findByOrderNo(String orderNo) { public RouteOrder findByOrderNo(String orderNo) {
return routeCacheService.getRouteByRouteOrderNo(orderNo); return routeCacheService.getRouteByRouteOrderNo(orderNo);

View File

@ -7,6 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
@Repository @Repository
public class RouteRequestRepositoryImpl implements RouteRequestRepository { public class RouteRequestRepositoryImpl implements RouteRequestRepository {
@ -18,4 +20,8 @@ public class RouteRequestRepositoryImpl implements RouteRequestRepository {
public RouteRequest findByRouteRequestNo(String routeRequestNo) { public RouteRequest findByRouteRequestNo(String routeRequestNo) {
return jdbcRouteRequestRepository.findByRouteRequestNo(routeRequestNo); return jdbcRouteRequestRepository.findByRouteRequestNo(routeRequestNo);
} }
@Override
public List<RouteRequest> findByRouteRequestNoIn(List<String> routeRequestNoList){
return jdbcRouteRequestRepository.findByRouteRequestNoIn(routeRequestNoList);
}
} }

View File

@ -8,6 +8,7 @@ import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -27,6 +28,8 @@ public interface JdbcOrderCarRecordRepository extends CrudRepository<OrderCarRec
LocalDateTime updateDataTime4, LocalDateTime updateDataTime4,
Pageable pageable); Pageable pageable);
List<OrderCarRecord> findByDetailIdIn(Collection<String> detailId);
@Query(""" @Query("""
select r1.* from order_car_record r1 select r1.* from order_car_record r1

View File

@ -8,6 +8,7 @@ import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -26,6 +27,7 @@ public interface JdbcOrderFlightRecordRepository extends CrudRepository<OrderFli
LocalDateTime updateDataTime4, LocalDateTime updateDataTime4,
Pageable pageable); Pageable pageable);
List<OrderFlightRecord> findByDetailIdIn(Collection<String> detailId);
@Query(""" @Query("""
select r1.* from order_flight_record r1 select r1.* from order_flight_record r1

View File

@ -1,6 +1,5 @@
package com.chint.infrastructure.repository.jdbc; package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -9,6 +8,7 @@ import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -28,6 +28,8 @@ public interface JdbcOrderHotelRecordRepository extends CrudRepository<OrderHote
LocalDateTime updateDataTime4, LocalDateTime updateDataTime4,
Pageable pageable); Pageable pageable);
List<OrderHotelRecord> findByDetailIdIn(Collection<String> detailId);
@Query(""" @Query("""
select r1.* from order_hotel_record r1 select r1.* from order_hotel_record r1
left join order_detail o1 on r1.order_detail_id = o1.order_id left join order_detail o1 on r1.order_detail_id = o1.order_id

View File

@ -8,6 +8,7 @@ import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -16,6 +17,7 @@ public interface JdbcOrderTrainRecordRepository extends CrudRepository<OrderTrai
Optional<OrderTrainRecord> findByDetailId(String detailId); Optional<OrderTrainRecord> findByDetailId(String detailId);
Page<OrderTrainRecord> findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable); Page<OrderTrainRecord> findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable);
Page<OrderTrainRecord> findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(String belongSysType, String accountPeriod, String accountPeriod2, Pageable pageable); Page<OrderTrainRecord> findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(String belongSysType, String accountPeriod, String accountPeriod2, Pageable pageable);
Page<OrderTrainRecord> findByBelongSysTypeAndUpdateDataTimeBetweenOrBelongSysTypeIsNullAndUpdateDataTimeBetween(String belongSysType, Page<OrderTrainRecord> findByBelongSysTypeAndUpdateDataTimeBetweenOrBelongSysTypeIsNullAndUpdateDataTimeBetween(String belongSysType,
@ -25,6 +27,7 @@ public interface JdbcOrderTrainRecordRepository extends CrudRepository<OrderTrai
LocalDateTime updateDataTime4, LocalDateTime updateDataTime4,
Pageable pageable); Pageable pageable);
List<OrderTrainRecord> findByDetailIdIn(Collection<String> detailId);
@Query(""" @Query("""
select r1.* from order_train_record r1 select r1.* from order_train_record r1

View File

@ -43,6 +43,8 @@ public interface JdbcRouteRepository extends CrudRepository<RouteOrder, Long> {
Page<RouteOrder> findAllBy(PageRequest pageResult); Page<RouteOrder> findAllBy(PageRequest pageResult);
List<RouteOrder> findByRouteIdIn(List<Long> routeIds);
@Query(""" @Query("""
select * from route_order r1 left join route_custom_extension_field r2 on r1.route_id = r2.route_id where select * from route_order r1 left join route_custom_extension_field r2 on r1.route_id = r2.route_id where
""") """)

View File

@ -4,8 +4,11 @@ import com.chint.domain.aggregates.order.RouteRequest;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
@Repository @Repository
public interface JdbcRouteRequestRepository extends CrudRepository<RouteRequest, Long> { public interface JdbcRouteRequestRepository extends CrudRepository<RouteRequest, Long> {
RouteRequest findByRouteRequestNo(String routeRequestNo); RouteRequest findByRouteRequestNo(String routeRequestNo);
List<RouteRequest> findByRouteRequestNoIn(Collection<String> routeRequestNo);
} }

View File

@ -824,7 +824,7 @@ public class LYTest {
@Test @Test
void searchTrain() { void searchTrain() {
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24032167485837934"); TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24050872686468359");
Gson gson = new Gson(); Gson gson = new Gson();
String json = gson.toJson(trainOrderDetail); String json = gson.toJson(trainOrderDetail);
System.out.println(json); System.out.println(json);

View File

@ -10,6 +10,7 @@ import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity;
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity; import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.order.Location; import com.chint.domain.aggregates.order.Location;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord; import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.*; import com.chint.domain.repository.*;
@ -158,6 +159,12 @@ class RouteApplicationTests {
private OrgRequest orgRequest; private OrgRequest orgRequest;
@Test
void testQueryIdsFromCache(){
List<RouteOrder> routeOrders = routeRepository.queryByIdIn(List.of(11822L, 11823L, 11824L, 11825L, 11826L));
System.out.println(routeOrders);
}
@Test @Test
void testSyncOrg(){ void testSyncOrg(){
orgRequest.syncAllOrg(); orgRequest.syncAllOrg();
@ -295,7 +302,7 @@ class RouteApplicationTests {
@Test @Test
void loginSignProd() { void loginSignProd() {
String sfno = "210303016"; String sfno = "181008027";
String syscode = "FSSC"; String syscode = "FSSC";
String billcode = "CLSQ240225000099"; String billcode = "CLSQ240225000099";
String companycode = "正泰集团股份有限公司"; String companycode = "正泰集团股份有限公司";
@ -1021,9 +1028,7 @@ class RouteApplicationTests {
@Test @Test
void deleteByOrderId() { void deleteByOrderId() {
orderDetailRepository.deleteById(1440L); orderDetailRepository.deleteById(3037L);
orderDetailRepository.deleteById(1441L);
orderDetailRepository.deleteById(1448L);
} }
// @Test // @Test