diff --git a/src/main/java/com/chint/application/services/login/LocalLoginStrategy.java b/src/main/java/com/chint/application/services/login/LocalLoginStrategy.java index 2ec2ea02..6869a1bd 100644 --- a/src/main/java/com/chint/application/services/login/LocalLoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/LocalLoginStrategy.java @@ -1,6 +1,5 @@ package com.chint.application.services.login; -import com.chint.domain.aggregates.user.User; import org.springframework.stereotype.Component; import java.util.Optional; diff --git a/src/main/java/com/chint/application/services/login/LoginStrategy.java b/src/main/java/com/chint/application/services/login/LoginStrategy.java index d68afca6..d08fdd86 100644 --- a/src/main/java/com/chint/application/services/login/LoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/LoginStrategy.java @@ -1,8 +1,6 @@ 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 org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; diff --git a/src/main/java/com/chint/application/services/login/strategy/ANFeiShuLoginStrategy.java b/src/main/java/com/chint/application/services/login/strategy/ANFeiShuLoginStrategy.java index 1bdf8776..d63d316b 100644 --- a/src/main/java/com/chint/application/services/login/strategy/ANFeiShuLoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/strategy/ANFeiShuLoginStrategy.java @@ -21,7 +21,6 @@ import java.net.URISyntaxException; import java.util.Optional; import static com.chint.infrastructure.constant.AuthMessageConstant.AUTHENTICATION_FAILED; -import static com.chint.infrastructure.constant.BPMConstant.AN_FSSC; @Component public class ANFeiShuLoginStrategy implements LoginStrategy { diff --git a/src/main/java/com/chint/application/services/login/strategy/FeishuLoginStrategy.java b/src/main/java/com/chint/application/services/login/strategy/FeishuLoginStrategy.java index ede75dec..923f360e 100644 --- a/src/main/java/com/chint/application/services/login/strategy/FeishuLoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/strategy/FeishuLoginStrategy.java @@ -21,10 +21,9 @@ import java.net.URISyntaxException; import java.util.Optional; import static com.chint.infrastructure.constant.AuthMessageConstant.AUTHENTICATION_FAILED; -import static com.chint.infrastructure.constant.BPMConstant.AN_FSSC; @Component -public class FeishuLoginStrategy implements LoginStrategy { +public class FeishuLoginStrategy extends PailaLoginStrategy implements LoginStrategy { @Value("${feishu.base-url}") private String feishuBaseUrl; diff --git a/src/main/java/com/chint/application/services/login/strategy/PailaMobileLoginStrategy.java b/src/main/java/com/chint/application/services/login/strategy/PailaMobileLoginStrategy.java index cbc6b06b..97c2af06 100644 --- a/src/main/java/com/chint/application/services/login/strategy/PailaMobileLoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/strategy/PailaMobileLoginStrategy.java @@ -74,8 +74,6 @@ public class PailaMobileLoginStrategy implements LoginStrategy { @Override public String getUserInfo(String accessToken) { - - List userInfoParams = Collections.singletonList( new BasicNameValuePair("access_token", accessToken) ); diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java index 87e0fedc..6632e35b 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -576,5 +576,18 @@ public class RouteOrder implements Serializable { 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; + } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java index 00f12102..57a46f14 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java @@ -1,5 +1,6 @@ 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.OrderFlightRecord; 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 org.springframework.stereotype.Component; +import java.util.List; + 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) { 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; + } + } diff --git a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java index 1098f590..1199eca2 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java @@ -717,6 +717,25 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac 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) { UserCustomCode userCustomCode = userCustomCodeRepository. diff --git a/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java index 7d1dd900..b44db6e6 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java @@ -89,6 +89,27 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor 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 public OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData) { OrderTrainRecord orderTrainRecord = new OrderTrainRecord(); diff --git a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordExtensionFactory.java index dfb99170..6bd0104d 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordExtensionFactory.java @@ -1,6 +1,6 @@ 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.OrderFlightRecord; 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 { + OrderCarRecord createCarOrderRecord(Object orderCarRecordData); OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData); @@ -16,4 +17,11 @@ public interface OrderRecordExtensionFactory { 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); } diff --git a/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java index 7de508c2..3a1cea4f 100644 --- a/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java @@ -16,6 +16,8 @@ public interface OrderCarRecordRepository { Optional findByDetailId(String detailId); + List findByDetailIdIn(List detailIdList); + PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType); PageResult findBySystemTypeAndLastMonth(Integer pageSize, diff --git a/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java index b898c799..ef357a27 100644 --- a/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java @@ -13,6 +13,7 @@ public interface OrderFlightRecordRepository { List saveAll(List orderFlightRecordList); Optional findByDetailId(String detailId); + List findByDetailIdIn(List detailId); PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, diff --git a/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java index bb3646c6..8167206d 100644 --- a/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java @@ -13,6 +13,7 @@ public interface OrderHotelRecordRepository { List saveAll(List orderHotelRecordList); Optional findByDetailId(String detailId); + List findByDetailIdIn(List detailIds); PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum, String systemType); diff --git a/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java index 425f53cb..4a19a963 100644 --- a/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java @@ -16,6 +16,8 @@ public interface OrderTrainRecordRepository { Optional findByDetailId(String detailId); + List findByDetailIdIn(List detailIds); + PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType); diff --git a/src/main/java/com/chint/domain/repository/RouteRepository.java b/src/main/java/com/chint/domain/repository/RouteRepository.java index 1e8a2651..c2434380 100644 --- a/src/main/java/com/chint/domain/repository/RouteRepository.java +++ b/src/main/java/com/chint/domain/repository/RouteRepository.java @@ -11,6 +11,8 @@ import java.util.List; public interface RouteRepository { RouteOrder queryById(Long orderId); + List queryByIdIn(List routeIds); + List queryAllInOneDayAndEffective(LocalDateTime start, LocalDateTime end); void deleteById(Long orderId); diff --git a/src/main/java/com/chint/domain/repository/RouteRequestRepository.java b/src/main/java/com/chint/domain/repository/RouteRequestRepository.java index 71472b82..d19d61a1 100644 --- a/src/main/java/com/chint/domain/repository/RouteRequestRepository.java +++ b/src/main/java/com/chint/domain/repository/RouteRequestRepository.java @@ -3,6 +3,10 @@ package com.chint.domain.repository; import com.chint.domain.aggregates.order.RouteRequest; +import java.util.List; + public interface RouteRequestRepository { RouteRequest findByRouteRequestNo(String routeRequestNo); + + List findByRouteRequestNoIn(List routeRequestNoList); } diff --git a/src/main/java/com/chint/domain/service/OrderDetailDomainService.java b/src/main/java/com/chint/domain/service/OrderDetailDomainService.java index 64050c49..8f367f03 100644 --- a/src/main/java/com/chint/domain/service/OrderDetailDomainService.java +++ b/src/main/java/com/chint/domain/service/OrderDetailDomainService.java @@ -17,7 +17,9 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.Map; 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.SupplierNameConstant.SUPPLIER_C_TRIP; @@ -86,32 +88,77 @@ public class OrderDetailDomainService { } public List saveCarOrderRecordBatch(List orderCarRecordList) { - //如果发现唯一键已经存在, 那么就做更新处理 - orderCarRecordList.forEach(needSave-> orderCarRecordRepository - .findByDetailId(needSave.getDetailId()) - .ifPresent(it-> - needSave.setId(it.getId()))); + List detailIds = orderCarRecordList.stream().map(OrderCarRecord::getDetailId) + .toList(); + List byDetailIdIn = orderCarRecordRepository.findByDetailIdIn(detailIds); + // 使用Map来映射detailId与对应的OrderCarRecord + Map 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); } public List saveFlightOrderRecordBatch(List orderFlightRecordList) { - orderFlightRecordList.forEach(needSave-> orderFlightRecordRepository - .findByDetailId(needSave.getDetailId()) - .ifPresent(it-> - needSave.setId(it.getId()))); + List detailIds = orderFlightRecordList.stream().map(OrderFlightRecord::getDetailId) + .toList(); + List byDetailIdIn = orderFlightRecordRepository.findByDetailIdIn(detailIds); + + // 使用Map来映射detailId与对应的OrderFlightRecord + Map 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); } public List saveTrainOrderRecordBatch(List orderTrainRecordList) { - orderTrainRecordList.forEach(needSave-> orderTrainRecordRepository - .findByDetailId(needSave.getDetailId()) - .ifPresent(it-> - needSave.setId(it.getId()))); + List detailIds = orderTrainRecordList.stream().map(OrderTrainRecord::getDetailId) + .toList(); + List byDetailIdIn = orderTrainRecordRepository.findByDetailIdIn(detailIds); + + // 使用Map来映射detailId与对应的OrderFlightRecord + Map 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); } public List saveHotelOrderRecordBatch(List orderHotelRecordList) { - orderHotelRecordList.forEach(needSave-> orderHotelRecordRepository - .findByDetailId(needSave.getDetailId()) - .ifPresent(it-> - needSave.setId(it.getId()))); + List detailIds = orderHotelRecordList.stream().map(OrderHotelRecord::getDetailId) + .toList(); + List byDetailIdIn = orderHotelRecordRepository.findByDetailIdIn(detailIds); + + // 使用Map来映射detailId与对应的OrderFlightRecord + Map 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); } diff --git a/src/main/java/com/chint/domain/service/RouteRequestDomainService.java b/src/main/java/com/chint/domain/service/RouteRequestDomainService.java index ed2980eb..be165994 100644 --- a/src/main/java/com/chint/domain/service/RouteRequestDomainService.java +++ b/src/main/java/com/chint/domain/service/RouteRequestDomainService.java @@ -14,7 +14,6 @@ import com.chint.domain.value_object.SyncLegData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -221,4 +220,22 @@ public class RouteRequestDomainService { } return routeRepository.queryById(routeRequest.getRouteId()); } + + public List getRouteOrder(List journeyNoList) { + //先通过 + List byRouteRequestNoIn = routeRequestRepository.findByRouteRequestNoIn(journeyNoList); + List existedRouteRequestNo = byRouteRequestNoIn.stream().map(RouteRequest::getRouteRequestNo).toList(); + List needQueryFromDB = journeyNoList + .stream() + .filter(journeyNo -> !existedRouteRequestNo.contains(journeyNo)) + .toList(); + List routIds = byRouteRequestNoIn.stream().map(RouteRequest::getRouteId).toList(); + List routeOrders = routeRepository.queryByIdIn(routIds); + if (!needQueryFromDB.isEmpty()) { + List routeOrderListFromDB = needQueryFromDB.stream().map(routeRepository::findByOrderNo).toList(); + routeOrders.addAll(routeOrderListFromDB); + return routeOrders; + } + return routeOrders; + } } diff --git a/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java b/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java index b567da42..ef6fdaaf 100644 --- a/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java +++ b/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java @@ -200,4 +200,12 @@ public class RouteCacheService { routeCacheManage.getRouteIdsByEmployeeNo(userId, null, newRouteIds); } } + + public List queryByIdIn(List routeIds) { + if (routeIds != null && !routeIds.isEmpty()) { + return routeCacheManage.getRouteListByIds(routeIds); + } else { + return List.of(); + } + } } diff --git a/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java index 4a07bfe1..12ed86dc 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java @@ -44,6 +44,11 @@ public class OrderCarRecordRepositoryImpl implements OrderCarRecordRepository { return orderCarRecordRepository.findByDetailId(detailId); } + @Override + public List findByDetailIdIn(List detailIdList) { + return orderCarRecordRepository.findByDetailIdIn(detailIdList); + } + @Override public PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, diff --git a/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java index 410b11aa..47476863 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java @@ -46,6 +46,11 @@ public class OrderFlightRecordRepositoryImpl implements OrderFlightRecordReposit return jdbcOrderFlightRecordRepository.findByDetailId(detailId); } + @Override + public List findByDetailIdIn(List detailId) { + return jdbcOrderFlightRecordRepository.findByDetailIdIn(detailId); + } + @Override public PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum, String systemType) { PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); diff --git a/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java index eb218e13..6d4faede 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java @@ -2,8 +2,6 @@ package com.chint.infrastructure.repository; import com.chint.application.dtos.OrderRecordExtensionParam; 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.repository.OrderHotelRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderHotelRecordRepository; @@ -47,6 +45,11 @@ public class OrderHotelRecordRepositoryImpl implements OrderHotelRecordRepositor return jdbcOrderHotelRecordRepository.findByDetailId(detailId); } + @Override + public List findByDetailIdIn(List detailIds) { + return jdbcOrderHotelRecordRepository.findByDetailIdIn(detailIds); + } + @Override public PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum, String systemType) { PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); @@ -76,7 +79,7 @@ public class OrderHotelRecordRepositoryImpl implements OrderHotelRecordRepositor public PageResult findByRecordParam(OrderRecordQueryDTO queryDTO) { StringJoiner whereClause = new StringJoiner(" AND ", " WHERE ", ""); MapSqlParameterSource parameters = new MapSqlParameterSource(); - loadQuerySql(whereClause,parameters,queryDTO); + loadQuerySql(whereClause, parameters, queryDTO); // 计算OFFSET(跳过的行数) int offset = (queryDTO.getPageNum() - 1) * queryDTO.getPageSize(); String sql = "SELECT * FROM order_hotel_record" + whereClause + " ORDER BY detail_id ASC LIMIT :limit OFFSET :offset"; @@ -169,6 +172,6 @@ public class OrderHotelRecordRepositoryImpl implements OrderHotelRecordRepositor Integer num = jdbcOrderHotelRecordRepository.countRecordByCustomFiled(param.getFieldName(), param.getFieldValue(), param.getAccountPeriod()); - return PageResult.totalPageNum(num == null ? 0 : num, orderHotelRecords); + return PageResult.totalPageNum(num == null ? 0 : num, orderHotelRecords); } } diff --git a/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java index 121f95ff..30ba4ef6 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java @@ -44,6 +44,11 @@ public class OrderTrainRecordRepositoryImpl implements OrderTrainRecordRepositor return jdbcOrderTrainRecordRepository.findByDetailId(detailId); } + @Override + public List findByDetailIdIn(List detailIds) { + return jdbcOrderTrainRecordRepository.findByDetailIdIn(detailIds); + } + @Override public PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum, String systemType) { PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); diff --git a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java index 24472b95..a1d56947 100644 --- a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java @@ -8,7 +8,6 @@ import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository; import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.Cacheable; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; @@ -16,6 +15,7 @@ import org.springframework.stereotype.Repository; import java.time.LocalDateTime; import java.util.List; +import java.util.Objects; @Repository public class RouteRepositoryImpl implements RouteRepository { @@ -32,6 +32,29 @@ public class RouteRepositoryImpl implements RouteRepository { return routeCacheService.getRouteById(orderId); } + @Override + public List queryByIdIn(List routeIds) { + List routeOrders = new java.util.ArrayList<>(routeCacheService.queryByIdIn(routeIds) + .stream() + .filter(Objects::nonNull) + .toList()); + List existedRouteIds = routeOrders + .stream() + .filter(Objects::nonNull) + .map(RouteOrder::getRouteId) + .toList(); + List needQueryFromDB = routeIds + .stream() + .filter(id -> !existedRouteIds.contains(id)) + .toList(); + List byRouteIdIn = jdbcRouteRepository + .findByRouteIdIn(needQueryFromDB); + //将查询出来的行程规划单缓存到数据库 + byRouteIdIn.forEach(route -> routeCacheService.cacheRouteOrder(route)); + routeOrders.addAll(byRouteIdIn); + return routeOrders; + } + @Override public List queryAllInOneDayAndEffective(LocalDateTime start, LocalDateTime end) { return jdbcRouteRepository.findByCreateTimeBetweenAndApproveOrderNo_ActualOrderNoNotNull(start, end); @@ -64,7 +87,6 @@ public class RouteRepositoryImpl implements RouteRepository { } - @Override public RouteOrder findByOrderNo(String orderNo) { return routeCacheService.getRouteByRouteOrderNo(orderNo); diff --git a/src/main/java/com/chint/infrastructure/repository/RouteRequestRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RouteRequestRepositoryImpl.java index 407fd734..4ab8ca61 100644 --- a/src/main/java/com/chint/infrastructure/repository/RouteRequestRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RouteRequestRepositoryImpl.java @@ -7,6 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public class RouteRequestRepositoryImpl implements RouteRequestRepository { @@ -18,4 +20,8 @@ public class RouteRequestRepositoryImpl implements RouteRequestRepository { public RouteRequest findByRouteRequestNo(String routeRequestNo) { return jdbcRouteRequestRepository.findByRouteRequestNo(routeRequestNo); } + @Override + public List findByRouteRequestNoIn(List routeRequestNoList){ + return jdbcRouteRequestRepository.findByRouteRequestNoIn(routeRequestNoList); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java index d5fde564..5655e9c5 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java @@ -8,6 +8,7 @@ import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import java.time.LocalDateTime; +import java.util.Collection; import java.util.List; import java.util.Optional; @@ -27,6 +28,8 @@ public interface JdbcOrderCarRecordRepository extends CrudRepository findByDetailIdIn(Collection detailId); + @Query(""" select r1.* from order_car_record r1 diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java index 4ef8daf5..730d06ea 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java @@ -8,6 +8,7 @@ import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import java.time.LocalDateTime; +import java.util.Collection; import java.util.List; import java.util.Optional; @@ -26,6 +27,7 @@ public interface JdbcOrderFlightRecordRepository extends CrudRepository findByDetailIdIn(Collection detailId); @Query(""" select r1.* from order_flight_record r1 diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java index d1ed6c2c..d20770a2 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java @@ -1,6 +1,5 @@ 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 org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -9,6 +8,7 @@ import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import java.time.LocalDateTime; +import java.util.Collection; import java.util.List; import java.util.Optional; @@ -28,6 +28,8 @@ public interface JdbcOrderHotelRecordRepository extends CrudRepository findByDetailIdIn(Collection detailId); + @Query(""" select r1.* from order_hotel_record r1 left join order_detail o1 on r1.order_detail_id = o1.order_id diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java index e9a52072..a58df647 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java @@ -8,6 +8,7 @@ import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import java.time.LocalDateTime; +import java.util.Collection; import java.util.List; import java.util.Optional; @@ -16,6 +17,7 @@ public interface JdbcOrderTrainRecordRepository extends CrudRepository findByDetailId(String detailId); Page findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable); + Page findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(String belongSysType, String accountPeriod, String accountPeriod2, Pageable pageable); Page findByBelongSysTypeAndUpdateDataTimeBetweenOrBelongSysTypeIsNullAndUpdateDataTimeBetween(String belongSysType, @@ -25,6 +27,7 @@ public interface JdbcOrderTrainRecordRepository extends CrudRepository findByDetailIdIn(Collection detailId); @Query(""" select r1.* from order_train_record r1 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 79d12289..e029673f 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java @@ -43,6 +43,8 @@ public interface JdbcRouteRepository extends CrudRepository { Page findAllBy(PageRequest pageResult); + List findByRouteIdIn(List routeIds); + @Query(""" select * from route_order r1 left join route_custom_extension_field r2 on r1.route_id = r2.route_id where """) diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRequestRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRequestRepository.java index 189961dd..41ad9bf0 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRequestRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRequestRepository.java @@ -4,8 +4,11 @@ import com.chint.domain.aggregates.order.RouteRequest; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.util.Collection; +import java.util.List; + @Repository public interface JdbcRouteRequestRepository extends CrudRepository { RouteRequest findByRouteRequestNo(String routeRequestNo); - + List findByRouteRequestNoIn(Collection routeRequestNo); } diff --git a/src/test/java/com/chint/LYTest.java b/src/test/java/com/chint/LYTest.java index 21d2c416..fc4b446d 100644 --- a/src/test/java/com/chint/LYTest.java +++ b/src/test/java/com/chint/LYTest.java @@ -824,7 +824,7 @@ public class LYTest { @Test void searchTrain() { - TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24032167485837934"); + TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24050872686468359"); Gson gson = new Gson(); String json = gson.toJson(trainOrderDetail); System.out.println(json); diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 131e8338..15f9da3e 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -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.order.Leg; 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.user.User; import com.chint.domain.repository.*; @@ -158,6 +159,12 @@ class RouteApplicationTests { private OrgRequest orgRequest; + @Test + void testQueryIdsFromCache(){ + List routeOrders = routeRepository.queryByIdIn(List.of(11822L, 11823L, 11824L, 11825L, 11826L)); + System.out.println(routeOrders); + } + @Test void testSyncOrg(){ orgRequest.syncAllOrg(); @@ -295,7 +302,7 @@ class RouteApplicationTests { @Test void loginSignProd() { - String sfno = "210303016"; + String sfno = "181008027"; String syscode = "FSSC"; String billcode = "CLSQ240225000099"; String companycode = "正泰集团股份有限公司"; @@ -1021,9 +1028,7 @@ class RouteApplicationTests { @Test void deleteByOrderId() { - orderDetailRepository.deleteById(1440L); - orderDetailRepository.deleteById(1441L); - orderDetailRepository.deleteById(1448L); + orderDetailRepository.deleteById(3037L); } // @Test