diff --git a/src/main/java/com/chint/application/in/AutoWorkController.java b/src/main/java/com/chint/application/in/AutoWorkController.java index 4c783344..6828d763 100644 --- a/src/main/java/com/chint/application/in/AutoWorkController.java +++ b/src/main/java/com/chint/application/in/AutoWorkController.java @@ -95,18 +95,20 @@ public class AutoWorkController { return Result.Success(SUCCESS); } - @ApiOperation("拉取按月份的流水") - @PostMapping("/record/pull/month/") + @ApiOperation("拉取供应商的结算账单") + @PostMapping("/record/pull") public Result pullDataFromSupplier(@RequestBody RecordMonthSaveDTO param) { String date = param.getDate(); OrderRecordPuller orderRecordPuller = supplierAdapterSelector .of(param.getSupplierName(), OrderRecordPuller.class); //将昨天的结算数据生成为财务共享需要的数据 OrderRecordGenerateCommand command = Command.of(OrderRecordGenerateCommand.class) - .startTime(DateTimeUtil.firstDayOfMonth(date)) - .endTime(DateTimeUtil.endDayOfMonth(date)) - .date(date) .supplierName(param.getSupplierName()); + if (date != null) { + command.startTime(DateTimeUtil.firstDayOfMonth(date)) + .endTime(DateTimeUtil.endDayOfMonth(date)) + .date(date); + } if (param.getProductType().equals(LEG_TYPE_TRAIN)) { orderRecordPuller.pullTrainOrderRecord(command); } @@ -123,6 +125,15 @@ public class AutoWorkController { } +// @ApiOperation("生成结算数据根据时间参数") +// @PostMapping("/record/pull") +// public Result generateFromRecord(@RequestBody RecordMonthSaveDTO param) { +// +// return Result.Success(SUCCESS); +// +// } + + @Transactional @ApiOperation("根据月份生成结算记录") @PostMapping("/record/save/month") diff --git a/src/main/java/com/chint/application/in/RankController.java b/src/main/java/com/chint/application/in/RankController.java index f8e8ab64..cb655630 100644 --- a/src/main/java/com/chint/application/in/RankController.java +++ b/src/main/java/com/chint/application/in/RankController.java @@ -46,6 +46,12 @@ public class RankController { @Autowired private JdbcRanksStandardLevelRepository jdbcRanksStandardLevelRepository; + @Autowired + private RanksRepository ranksRepository; + + @Autowired + private RanksFactory ranksFactory; + @ApiOperation("分页查询等级") @PostMapping("/pageQuery") @@ -74,6 +80,21 @@ public class RankController { return Result.Success(CommonMessageConstant.SUCCESS, jdbcRanksRepository.save(ranks)); } + @Transactional + @ApiOperation("保存职级和差标映射") + @PostMapping("/save/add") + public Result saveRanks(@RequestBody RanksData ranksdata) { + Ranks ranks = ranksFactory.createRanks(ranksdata); + Ranks save = null; + try { + save = ranksRepository.save(ranks); + } catch (Exception e) { + throw new DuplicateException(CommonMessageConstant.DUPLICATE_ERROR); + } + return Result.Success(CommonMessageConstant.SUCCESS, save); + } + + @Transactional @ApiOperation("添加差标标准") @PostMapping("/save/standards") diff --git a/src/main/java/com/chint/domain/aggregates/order/Leg.java b/src/main/java/com/chint/domain/aggregates/order/Leg.java index 3eccf530..1dc1cd80 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Leg.java +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -92,6 +92,24 @@ public class Leg implements Serializable { return new Leg(legId); } + + public boolean legIsInternal() { + if (this.originLocation != null && !this.originLocation.isInternal()) { + return false; + } + if (this.destinationLocation != null && !this.destinationLocation.isInternal()) { + return false; + } + if (this.legExtensionField != null) { + for (Location location : this.legExtensionField.getLocationList()) { + if (!location.isInternal()) { + return false; + } + } + } + return true; + } + public Leg queryEstimateAmount(EstimateAdapter estimateAdapter, String supplierName) { if (!this.getLegType().equals(LEG_TYPE_OTHER) && !this.getLegType().equals(LEG_TYPE_TAXI)) { this.amount = estimateAdapter.of(supplierName).amountEstimate(this); diff --git a/src/main/java/com/chint/domain/aggregates/order/Location.java b/src/main/java/com/chint/domain/aggregates/order/Location.java index 430d7f2a..3083296c 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Location.java +++ b/src/main/java/com/chint/domain/aggregates/order/Location.java @@ -33,4 +33,8 @@ public class Location implements Serializable { private Long cityId; private Integer isHaveAirport; private Integer locationType; + + public boolean isInternal(){ + return isInternal == 1; + } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java index 8db59f6a..2fa3161f 100644 --- a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java +++ b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java @@ -34,10 +34,26 @@ public class SupplierProduct implements Serializable { } public boolean checkStandardLevelIfInUse(String standardLevel) { - return this.getSupplierProductStandardLevelList() + return this.supplierProductStandardLevelList .stream() .filter(SupplierProductStandardLevel::inUse) .map(SupplierProductStandardLevel::getStandardLevelName) .anyMatch(it -> it.equals(standardLevel)); } + + public boolean checkSysCodeIfNotUse(String sysCode) { + return this.supplierProductSysCodeList + .stream() + .filter(SupplierProductSysCode::notUse) + .map(SupplierProductSysCode::getSystemCode) + .anyMatch(it -> it.equals(sysCode)); + } + + public boolean checkCompanyIfNotUse(String companyCode) { + return this.supplierProductCompanyList + .stream() + .filter(SupplierProductCompany::notUse) + .map(SupplierProductCompany::getCompanyCode) + .anyMatch(it -> it.equals(companyCode)); + } } diff --git a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductCompany.java b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductCompany.java index 6bc4123a..fced4e76 100644 --- a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductCompany.java +++ b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductCompany.java @@ -22,4 +22,7 @@ public class SupplierProductCompany implements Serializable { public boolean inUse() { return status == 1; } + public boolean notUse() { + return status == 0; + } } diff --git a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductStandardLevel.java b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductStandardLevel.java index 3eb94f47..efea6536 100644 --- a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductStandardLevel.java +++ b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductStandardLevel.java @@ -23,4 +23,8 @@ public class SupplierProductStandardLevel implements Serializable { public boolean inUse() { return status == 1; } + + public boolean notUse() { + return status == 0; + } } diff --git a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductSysCode.java b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductSysCode.java index 78e1a687..362f3a81 100644 --- a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductSysCode.java +++ b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductSysCode.java @@ -19,7 +19,12 @@ public class SupplierProductSysCode implements Serializable { private String systemCode; private Integer status; private String extension; + public boolean inUse() { return status == 1; } + + public boolean notUse() { + return status == 0; + } } diff --git a/src/main/java/com/chint/domain/factoriy/ranks/RanksFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/ranks/RanksFactoryImpl.java index fae6ce67..65f8c71b 100644 --- a/src/main/java/com/chint/domain/factoriy/ranks/RanksFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/ranks/RanksFactoryImpl.java @@ -28,6 +28,7 @@ public class RanksFactoryImpl implements RanksFactory { case STANDARD_LEVEL_WL_CODE -> STANDARD_LEVEL_WL; case STANDARD_LEVEL_AN_CODE -> STANDARD_LEVEL_AN; case STANDARD_LEVEL_GY_CODE -> STANDARD_LEVEL_GY; + case STANDARD_LEVEL_QC_CODE -> STANDARD_LEVEL_QC; // case STANDARD_LEVEL_SZKJ_CODE -> STANDARD_LEVEL_SZKJ; case STANDARD_LEVEL_SDZN_CODE -> STANDARD_LEVEL_SDZN; // case STANDARD_LEVEL_DQXS_CODE -> STANDARD_LEVEL_DQXS; diff --git a/src/main/java/com/chint/domain/repository/AmapCarOrderRecordRepository.java b/src/main/java/com/chint/domain/repository/AmapCarOrderRecordRepository.java index 5a26daa1..945b2c2d 100644 --- a/src/main/java/com/chint/domain/repository/AmapCarOrderRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/AmapCarOrderRecordRepository.java @@ -8,5 +8,7 @@ public interface AmapCarOrderRecordRepository { List saveAll(List records); + List findByOrderIds(List orderIds); + List findByDs(String ds); } diff --git a/src/main/java/com/chint/domain/service/LegDomainService.java b/src/main/java/com/chint/domain/service/LegDomainService.java index 4386a644..52ff5926 100644 --- a/src/main/java/com/chint/domain/service/LegDomainService.java +++ b/src/main/java/com/chint/domain/service/LegDomainService.java @@ -2,13 +2,17 @@ package com.chint.domain.service; import com.chint.application.dtos.response.LegRes; import com.chint.domain.aggregates.order.*; +import com.chint.domain.aggregates.supplier.Supplier; +import com.chint.domain.aggregates.supplier.SupplierProduct; import com.chint.domain.exceptions.LegEventException; import com.chint.domain.factoriy.leg_event.LegEventFactory; import com.chint.domain.repository.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR; import static com.chint.infrastructure.constant.LegConstant.*; @@ -90,7 +94,7 @@ public class LegDomainService { public void deleteByLegNo(String legNo) { Leg byLegNo = legRepository.findByLegNo(legNo); - if(byLegNo == null){ + if (byLegNo == null) { return; } RouteOrder routeOrder = routeRepository.queryById(byLegNo.getRouteId()).reloadStatus(); @@ -131,7 +135,7 @@ public class LegDomainService { public List queryLocation(List list) { list.forEach(leg -> { LegExtensionField legExtensionField = leg.getLegExtensionField(); - if (legExtensionField != null && legExtensionField.getLocationIds() != null ) { + if (legExtensionField != null && legExtensionField.getLocationIds() != null) { List locationIdsAsLong; if (legExtensionField.getLocationIds().startsWith("[")) { locationIdsAsLong = legExtensionField.getLocationIdsAsLongFromArray(); @@ -168,16 +172,57 @@ public class LegDomainService { public List queryLegsCanSync(RouteOrder routeOrder, String supplierName) { List legItems = routeOrder.getLegItems(); - legItems = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList(); - - //通过查看供应商的商品类型,来进行同步 - legItems = supplierDomainService.ifCanSync(legItems, supplierName); - - legItems.forEach(Leg::reloadStatus); queryLocation(legItems); + legItems = legItems.stream() + .filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER) && it.legIsInternal()) + .toList(); + // 通过查看供应商的商品类型,来进行同步 + legItems = ifCanSync(legItems, routeOrder, supplierName); + legItems.forEach(Leg::reloadStatus); return legItems; } + private List ifCanSync(List legs, RouteOrder routeOrder, String supplierName) { + return supplierRepository.findBySupplierName(supplierName) + .map(supplier -> { + List productTypes = supplier.getSupplierProductList() + .stream() + .filter(it -> it.getIfCanOrder().equals(1)) + .map(SupplierProduct::getProductType) + .toList(); + return legs.stream() + .filter(leg -> productTypes.contains(leg.getLegType()) && checkLegCompatibility(leg, routeOrder, supplier)) + .toList(); + }) + .orElse(legs); + } + + private boolean checkLegCompatibility(Leg leg, RouteOrder routeOrder, Supplier supplier) { + return switch (leg.getLegType()) { + case LEG_TYPE_TRAIN -> supplier.trainSupplierProduct() + .map(product -> isProductCompatible(routeOrder, product)) + .orElse(false); + case LEG_TYPE_AIRPLANE -> supplier.flightSupplierProduct() + .map(product -> isProductCompatible(routeOrder, product)) + .orElse(false); + case LEG_TYPE_HOTEL -> supplier.hotelSupplierProduct() + .map(product -> isProductCompatible(routeOrder, product)) + .orElse(false); + case LEG_TYPE_TAXI -> supplier.carSupplierProduct() + .map(product -> isProductCompatible(routeOrder, product)) + .orElse(false); + default -> false; + }; + } + + private boolean isProductCompatible(RouteOrder routeOrder, + SupplierProduct supplierProduct) { + return supplierProduct.checkStandardLevelIfInUse(routeOrder.getStandardLevel()) + && !supplierProduct.checkSysCodeIfNotUse(routeOrder.getApproveOrderNo().getSysCode()) + && !supplierProduct.checkSysCodeIfNotUse(routeOrder.getApproveOrderNo().getAccountCompany()) + && !supplierProduct.checkSysCodeIfNotUse(routeOrder.getApproveOrderNo().getAccountCompanyName()); + } + public List syncLegExclusive(RouteOrder routeOrder, List legItems, String supplierName) { List alreadySyncLegs = routeOrder.getRouteRequestList() diff --git a/src/main/java/com/chint/domain/service/RouteRequestDomainService.java b/src/main/java/com/chint/domain/service/RouteRequestDomainService.java index 5f1e88fd..c571d4e9 100644 --- a/src/main/java/com/chint/domain/service/RouteRequestDomainService.java +++ b/src/main/java/com/chint/domain/service/RouteRequestDomainService.java @@ -76,11 +76,12 @@ public class RouteRequestDomainService { RouteOrder routeOrder = routeRepository.queryById(syncLegData.getRouteId()); legDomainService.checkLegIfStartApproval(routeOrder); List legIds = syncLegData.getLegIds(); - RouteRequest routeRequest = getRouteRequest(routeOrder, legIds, syncLegData.getSupplierName()); + String supplierName = syncLegData.getSupplierName(); + RouteRequest routeRequest = getRouteRequest(routeOrder, legIds, supplierName); if (routeRequest.getStatus().equals(ROUTE_REQUEST_STATUS_PREPARE)) { //如果是刚生成的订单需要加入行程规划单当中 //保存供应商信息 - routeRequest.setSupplier(syncLegData.getSupplierName()); + routeRequest.setSupplier(supplierName); routeOrder.addRouteRequest(routeRequest); } else { //如果是不是刚生成的,需要调整差旅申请单的行程 @@ -102,15 +103,26 @@ public class RouteRequestDomainService { } legs.forEach(it -> it.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_NOT_ORDERED))); - //这里执行同步 - if (supplierAdapterSelector.of(syncLegData.getSupplierName(), SupplierOrderSync.class).syncRouteRequest(routeRequest)) { - routeRequest.addEvent(RouteRequestEvent.sync(syncLegData.getSupplierName())); - //通过保存聚合根来保存差旅申请单 + + supplierRepository.findBySupplierName(supplierName) + .ifPresentOrElse( + supplier -> syncRouteRequest(routeRequest, supplier, routeOrder), + () -> { + throw new CommandException("未找到供应商,无法同步差旅申请单,联系管理员"); + } + ); + return routeRequest; + } + + // 提取同步逻辑到一个单独的方法 + private void syncRouteRequest(RouteRequest routeRequest, Supplier supplier, RouteOrder routeOrder) { + if (supplierAdapterSelector.of(supplier.getName(), SupplierOrderSync.class).syncRouteRequest(routeRequest, supplier)) { + routeRequest.addEvent(RouteRequestEvent.sync(supplier.getName())); + // 通过保存聚合根来保存差旅申请单 routeRepository.save(routeOrder); } else { throw new CommandException("同步差旅申请单失败,联系管理员"); } - return routeRequest; } @@ -118,59 +130,76 @@ public class RouteRequestDomainService { List legIds = syncLegData.getLegIds(); Long routeId = syncLegData.getRouteId(); RouteOrder routeOrder = routeRepository.queryById(routeId); - Optional optionalRouteRequest; - if (syncLegData.getRouteRequestId() != null) { - //如果指定的对应的差旅申请单 , 那么取消对应的差旅申请单 - optionalRouteRequest = routeOrder.getRouteRequestList() - .stream() - .filter(it -> it.getId().equals(syncLegData.getRouteRequestId())) - .findFirst(); - } else { - //如果指定的行程单号和供应商 , 该供应商对应的差旅申请单 - optionalRouteRequest = routeOrder.getRouteRequestList() - .stream() - .filter(it -> it.getSupplier().equals(syncLegData.getSupplierName())) - .findFirst(); - } - optionalRouteRequest.ifPresent(it -> { - //这里的逻辑为发现 差旅申请单的机票行程节点 如果已经是 下单的状态, 就不进行取消, 因此实际上按照 该差旅申请单的 同步来进行 - List legs = it.loadLegInfoSelf(routeOrder) - .getRouteRequestLegList() - .stream() - .map(RouteRequestLeg::getLeg) - .toList(); - Optional supplierOptional = supplierRepository.findBySupplierName(it.getSupplier()); - Map> collect; + Optional optionalRouteRequest = findRouteRequest(routeOrder, syncLegData); + + optionalRouteRequest.ifPresent(routeRequest -> { + List legs = getLegsFromRouteRequest(routeRequest, routeOrder); + + Optional supplierOptional = supplierRepository.findBySupplierName(routeRequest.getSupplier()); + if (supplierOptional.isPresent()) { - collect = legs - .stream() - .collect(Collectors.partitioningBy(leg -> supplierDomainService.ifCanCancel(leg, it.getSupplier()) && legIds.contains(leg.getLegId()))); - List orderedLegs = collect.get(false); - if (!orderedLegs.isEmpty()) { - it.reloadGenerateRequestLegs(orderedLegs); - supplierAdapterSelector.of(it.getSupplier(), SupplierOrderSync.class).syncRouteRequest(it); - it.addEvent(RouteRequestEvent.sync(it.getSupplier())); - List notOrderLegs = collect.get(true); - notOrderLegs.forEach(leg -> leg.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL))); - } else { - it.addEvent(RouteRequestEvent.cancel(it.getSupplier())); - getLegInfoFromRouteOrder(it, routeOrder); - supplierAdapterSelector.of(it.getSupplier(), SupplierOrderSync.class).syncRouteRequest(it); - it.getRouteRequestLegList() - .forEach(requestLeg -> requestLeg.getLeg().addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL))); - } + Map> legsPartitionedByOrderStatus = partitionLegsByOrderStatus(legs, legIds, routeRequest); + handleOrderedLegs(routeRequest, legsPartitionedByOrderStatus.get(false), routeOrder); + handleNotOrderedLegs(routeRequest, legsPartitionedByOrderStatus.get(true), routeOrder); } else { - it.addEvent(RouteRequestEvent.cancel(it.getSupplier())); - getLegInfoFromRouteOrder(it, routeOrder); - supplierAdapterSelector.of(it.getSupplier(), SupplierOrderSync.class).syncRouteRequest(it); - it.getRouteRequestLegList() - .forEach(requestLeg -> requestLeg.getLeg().addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL))); + cancelRouteRequest(routeRequest, routeOrder); } }); + routeRepository.save(routeOrder); } + private Optional findRouteRequest(RouteOrder routeOrder, SyncLegData syncLegData) { + return (syncLegData.getRouteRequestId() != null) + ? routeOrder.getRouteRequestList().stream() + .filter(it -> it.getId().equals(syncLegData.getRouteRequestId())) + .findFirst() + : routeOrder.getRouteRequestList().stream() + .filter(it -> it.getSupplier().equals(syncLegData.getSupplierName())) + .findFirst(); + } + + private List getLegsFromRouteRequest(RouteRequest routeRequest, RouteOrder routeOrder) { + return routeRequest.loadLegInfoSelf(routeOrder) + .getRouteRequestLegList() + .stream() + .map(RouteRequestLeg::getLeg) + .toList(); + } + + private Map> partitionLegsByOrderStatus(List legs, List legIds, RouteRequest routeRequest) { + return legs.stream() + .collect(Collectors.partitioningBy(leg -> supplierDomainService.ifCanCancel(leg, routeRequest.getSupplier()) && legIds.contains(leg.getLegId()))); + } + + private void handleOrderedLegs(RouteRequest routeRequest, List orderedLegs, RouteOrder routeOrder) { + if (!orderedLegs.isEmpty()) { + routeRequest.reloadGenerateRequestLegs(orderedLegs); + syncRouteRequest(routeRequest); + routeRequest.addEvent(RouteRequestEvent.sync(routeRequest.getSupplier())); + } else { + cancelRouteRequest(routeRequest, routeOrder); + } + } + + private void handleNotOrderedLegs(RouteRequest routeRequest, List notOrderedLegs, RouteOrder routeOrder) { + notOrderedLegs.forEach(leg -> leg.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL))); + syncRouteRequest(routeRequest); + } + + private void cancelRouteRequest(RouteRequest routeRequest, RouteOrder routeOrder) { + routeRequest.addEvent(RouteRequestEvent.cancel(routeRequest.getSupplier())); + getLegInfoFromRouteOrder(routeRequest, routeOrder); + syncRouteRequest(routeRequest); + routeRequest.getRouteRequestLegList() + .forEach(requestLeg -> requestLeg.getLeg().addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL))); + } + + private void syncRouteRequest(RouteRequest routeRequest) { + supplierAdapterSelector.of(routeRequest.getSupplier(), SupplierOrderSync.class).syncRouteRequest(routeRequest); + } + //获取目前已经同步到供应商的差旅申请单 private RouteRequest getRouteRequest(RouteOrder routeOrder, List legIds, String supplier) { @@ -224,7 +253,11 @@ public class RouteRequestDomainService { } RouteRequest routeRequest = routeRequestRepository.findByRouteRequestNo(journeyNo); if (routeRequest == null) { - return routeRepository.findByOrderNo(journeyNo); + RouteOrder byOrderNo = routeRepository.findByOrderNo(journeyNo); + if (byOrderNo == null) { + byOrderNo = routeRepository.findByOrderNo(journeyNo.split("#")[0]); + } + return byOrderNo; } return routeRepository.queryById(routeRequest.getRouteId()); } diff --git a/src/main/java/com/chint/domain/service/SupplierDomainService.java b/src/main/java/com/chint/domain/service/SupplierDomainService.java index 85eacccf..e7b4363f 100644 --- a/src/main/java/com/chint/domain/service/SupplierDomainService.java +++ b/src/main/java/com/chint/domain/service/SupplierDomainService.java @@ -59,6 +59,8 @@ public class SupplierDomainService { } } + + @ListenTo(command = "SupplierCallBackErrorCommand", order = 0) public void supplierCallBackError(SupplierCallBackErrorCommand command) { SupplierCallBackLog supplierCallBackLog = SupplierCallBackLog diff --git a/src/main/java/com/chint/domain/service/order_record/AmapOrderRecordPuller.java b/src/main/java/com/chint/domain/service/order_record/AmapOrderRecordPuller.java index 54d15a98..89b404f8 100644 --- a/src/main/java/com/chint/domain/service/order_record/AmapOrderRecordPuller.java +++ b/src/main/java/com/chint/domain/service/order_record/AmapOrderRecordPuller.java @@ -13,7 +13,7 @@ import java.util.List; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP; @Component -public class AmapOrderRecordPuller implements OrderRecordPuller{ +public class AmapOrderRecordPuller implements OrderRecordPuller { @Autowired private AmapSettleBillRequest amapSettleBillRequest; @@ -39,8 +39,23 @@ public class AmapOrderRecordPuller implements OrderRecordPuller{ @Override public boolean pullCarOrderRecord(OrderRecordGenerateCommand command) { try { - List listElements = amapSettleBillRequest.amapRecordByMonth(command.getDate()); - List list = listElements.stream().map(AmapCarOrderRecord::of).toList(); + List listElements; + String date = command.getDate(); + String oneDate = command.getOneDate(); + if (date != null) { + listElements = amapSettleBillRequest.amapRecordByMonth(date); + } else if (oneDate != null) { + listElements = amapSettleBillRequest.amapRecordByDay(oneDate); + } else { + listElements = amapSettleBillRequest.amapRecordByDay(); + } + List orderIdList = listElements.stream().map(FinishedOrderResponse.ListElement::getAmapOrderId).toList(); + List alreadyExist = amapCarOrderRecordRepository.findByOrderIds(orderIdList); + List list = listElements.parallelStream().map(AmapCarOrderRecord::of).peek(it -> alreadyExist.forEach(already -> { + if (already.getAmapOrderId().equals(it.getAmapOrderId())) { + it.setId(already.getId()); + } + })).toList(); amapCarOrderRecordRepository.saveAll(list); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java index 4c59ca97..a724f786 100644 --- a/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java @@ -144,6 +144,9 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync { } List areaCodes = new ArrayList<>(); for (Location location : locationList) { + if (!location.isInternal()) { + continue; + } if (location.getLocationType() != LOCATION_TYPE_CITY) { //如果类型不是地级市,那么就从地区路径获取地级市信息 String[] split = location.getLocationPathName().split("_"); @@ -173,7 +176,9 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync { }); if (routeRequestFields.getAccountCompanyName().equals("浙江正泰物联技术有限公司") || - routeRequestFields.getAccountCompanyName().equals("浙江正泰仪器仪表有限责任公司")) { + routeRequestFields.getAccountCompanyName().equals("浙江正泰仪器仪表有限责任公司") || + routeRequestFields.getAccountCompanyName().equals("浙江正泰水务科技有限公司") || + routeRequestFields.getAccountCompanyName().equals("山东鲁正电子有限公司")) { throw new AuthException("你目前的公司暂不支持使用高德打车"); } return dto; diff --git a/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java b/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java index 8449fc15..33eff32a 100644 --- a/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java +++ b/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java @@ -3,12 +3,14 @@ package com.chint.domain.service.order_sync; import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.supplier.Supplier; -import com.chint.domain.aggregates.supplier.SupplierProductStandardLevel; +import com.chint.domain.aggregates.supplier.SupplierProduct; import com.chint.domain.exceptions.AuthException; import com.chint.domain.service.supplier.SupplierAdapter; import java.util.List; +import static com.chint.infrastructure.constant.LegConstant.*; + public interface SupplierOrderSync extends SupplierAdapter { boolean syncSupplierOrder(RouteOrder order); @@ -19,43 +21,60 @@ public interface SupplierOrderSync extends SupplierAdapter { boolean cancelRouteRequest(RouteRequest routeRequest); default boolean syncRouteRequest(RouteRequest routeRequest, Supplier supplier) { + if (routeRequest == null || supplier == null) { + throw new AuthException("验证差旅申请单失败,请联系管理员"); + } RouteRequestFields routeRequestFields = routeRequest.getRouteRequestFields(); - - List legType = routeRequest.getRouteRequestLegList() + List legList = routeRequest.getRouteRequestLegList() .stream() .map(RouteRequestLeg::getLeg) - .map(Leg::getLegType) .toList(); - - supplier.carSupplierProduct() - .ifPresent(carSupplierProduct -> { - if (!carSupplierProduct.checkStandardLevelIfInUse(routeRequestFields.getStandardLevel())) { - throw new AuthException("你目前的公司暂不支持使用高德打车"); - } - }); - - - supplier.flightSupplierProduct().ifPresent(flightSupplierProduct -> { - if (flightSupplierProduct.getSupplierProductStandardLevelList() - .stream() - .filter(SupplierProductStandardLevel::inUse) - .map(SupplierProductStandardLevel::getStandardLevelName) - .noneMatch(standardLevel -> standardLevel.equals(routeRequestFields.getStandardLevel()))) { - throw new AuthException("你目前的公司暂不支持使用高德打车"); + legList.forEach(leg -> { + switch (leg.getLegType()) { + case LEG_TYPE_TRAIN -> trainProductCheck(routeRequestFields, supplier); + case LEG_TYPE_AIRPLANE -> flightProductCheck(routeRequestFields, supplier); + case LEG_TYPE_HOTEL -> hotelProductCheck(routeRequestFields, supplier); + case LEG_TYPE_TAXI -> carProductCheck(routeRequestFields, supplier); } }); - - supplier.flightSupplierProduct().ifPresent(flightSupplierProduct -> { - if (flightSupplierProduct.getSupplierProductStandardLevelList() - .stream() - .filter(SupplierProductStandardLevel::inUse) - .map(SupplierProductStandardLevel::getStandardLevelName) - .noneMatch(standardLevel -> standardLevel.equals(routeRequestFields.getStandardLevel()))) { - throw new AuthException("你目前的公司暂不支持使用高德打车"); - } - }); - return syncRouteRequest(routeRequest); } + private void carProductCheck(RouteRequestFields routeRequestFields, Supplier supplier) { + supplier.carSupplierProduct() + .ifPresent(carSupplierProduct -> productCheck(routeRequestFields, carSupplierProduct, supplier, "打车")); + } + + private void flightProductCheck(RouteRequestFields routeRequestFields, Supplier supplier) { + supplier.flightSupplierProduct() + .ifPresent(flightSupplierProduct -> productCheck(routeRequestFields, flightSupplierProduct, supplier, "机票")); + } + + private void hotelProductCheck(RouteRequestFields routeRequestFields, Supplier supplier) { + supplier.hotelSupplierProduct() + .ifPresent(hotelSupplierProduct -> productCheck(routeRequestFields, hotelSupplierProduct, supplier, "酒店")); + } + + private void trainProductCheck(RouteRequestFields routeRequestFields, Supplier supplier) { + supplier.trainSupplierProduct() + .ifPresent(trainSupplierProduct -> productCheck(routeRequestFields, trainSupplierProduct, supplier, "火车")); + } + + private void productCheck(RouteRequestFields routeRequestFields, + SupplierProduct supplierProduct, + Supplier supplier, + String legCnName) { + if (!supplierProduct.checkStandardLevelIfInUse(routeRequestFields.getStandardLevel())) { + throw new AuthException("你目前的差标暂不支持使用" + supplier.getCnName() + legCnName); + } + if (supplierProduct.checkSysCodeIfNotUse(routeRequestFields.getSysCode())) { + throw new AuthException("你目前的来源系统暂不支持使用" + supplier.getCnName() + legCnName); + } + if (supplierProduct.checkSysCodeIfNotUse(routeRequestFields.getAccountCompany())) { + throw new AuthException("你目前的公司暂不支持使用" + supplier.getCnName() + legCnName); + } + if (supplierProduct.checkSysCodeIfNotUse(routeRequestFields.getAccountCompanyName())) { + throw new AuthException("你目前的公司暂不支持使用" + supplier.getCnName() + legCnName); + } + } } diff --git a/src/main/java/com/chint/domain/service/supplier/SupplierAdapterSelector.java b/src/main/java/com/chint/domain/service/supplier/SupplierAdapterSelector.java index 34f47ba6..24778e15 100644 --- a/src/main/java/com/chint/domain/service/supplier/SupplierAdapterSelector.java +++ b/src/main/java/com/chint/domain/service/supplier/SupplierAdapterSelector.java @@ -27,7 +27,6 @@ public class SupplierAdapterSelector { Map beansOfType = applicationContext.getBeansOfType(SupplierAdapter.class); for (SupplierAdapter adapter : beansOfType.values()) { String supplierName = adapter.getSupplierName(); - log.info(supplierName); adapterMap .computeIfAbsent(supplierName, k -> new HashMap<>()) .put(adapter.getClass().getInterfaces()[0], adapter); diff --git a/src/main/java/com/chint/domain/service/supplier/SupplierConstantUtil.java b/src/main/java/com/chint/domain/service/supplier/SupplierConstantUtil.java index 4914fa8e..e0e5f37c 100644 --- a/src/main/java/com/chint/domain/service/supplier/SupplierConstantUtil.java +++ b/src/main/java/com/chint/domain/service/supplier/SupplierConstantUtil.java @@ -10,6 +10,7 @@ public class SupplierConstantUtil { return switch (supplier) { case SUPPLIER_L_Y -> SUPPLIER_L_Y_CN_NAME; case SUPPLIER_C_TRIP -> SUPPLIER_C_TRIP_CN_NAME; + case SUPPLIER_AMAP -> SUPPLIER_AMAP_CN_NAME; default -> "未知供应商"; }; } diff --git a/src/main/java/com/chint/infrastructure/constant/RankConstant.java b/src/main/java/com/chint/infrastructure/constant/RankConstant.java index 4c68f66d..8dec978a 100644 --- a/src/main/java/com/chint/infrastructure/constant/RankConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/RankConstant.java @@ -10,10 +10,12 @@ public class RankConstant { public static final String STANDARD_LEVEL_WL_CODE = "A70000059";//仪表编号 public static final String STANDARD_LEVEL_AN_CODE = "A70000021";//仪表编号 public static final String STANDARD_LEVEL_GY_CODE = "A20000001";//正泰电气股份有限公司 + public static final String STANDARD_LEVEL_QC_CODE = "A30040001";//正泰电气股份有限公司 public static final String STANDARD_LEVEL_YB = "YB_";//浙江正泰仪器仪表有限责任公司 public static final String STANDARD_LEVEL_WL = "WL_";//浙江正泰仪器仪表有限责任公司 public static final String STANDARD_LEVEL_AN = "AN_";//浙江正泰仪器仪表有限责任公司 public static final String STANDARD_LEVEL_GY = "GY_";//正泰电气股份有限公司 + public static final String STANDARD_LEVEL_QC = "QC_";//汽车科技 public static final String STANDARD_LEVEL_SZKJ_CODE = "";//数智科技编号 public static final String STANDARD_LEVEL_SZKJ = "SZKJ_";//数智科技 public static final String STANDARD_LEVEL_SDZN_CODE = "A70000067";//山东智能编号 diff --git a/src/main/java/com/chint/infrastructure/repository/AmapCarOrderRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/AmapCarOrderRecordRepositoryImpl.java index 4dac86f8..616c89f8 100644 --- a/src/main/java/com/chint/infrastructure/repository/AmapCarOrderRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/AmapCarOrderRecordRepositoryImpl.java @@ -22,6 +22,11 @@ public class AmapCarOrderRecordRepositoryImpl implements AmapCarOrderRecordRepos return res; } + @Override + public List findByOrderIds(List orderIds) { + return jdbcAmapCarOrderRecordRepository.findByAmapOrderIdIn(orderIds); + } + @Override public List findByDs(String ds) { return jdbcAmapCarOrderRecordRepository.findByDsContaining(ds); diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcAmapCarOrderRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcAmapCarOrderRecordRepository.java index 8e9bc1c9..731801a5 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcAmapCarOrderRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcAmapCarOrderRecordRepository.java @@ -4,9 +4,11 @@ import com.chint.domain.aggregates.order.order_record.amap_order_record.AmapCarO import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.util.Collection; import java.util.List; @Repository public interface JdbcAmapCarOrderRecordRepository extends CrudRepository { List findByDsContaining(String ds); + List findByAmapOrderIdIn(Collection amapOrderId); } diff --git a/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java b/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java index fee858f9..34f48d0f 100644 --- a/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java +++ b/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java @@ -21,6 +21,7 @@ public class DateTimeUtil { return formatter.format(time); } + public static String timeToStr(LocalDateTime input) { return input.format(formatterDate); } @@ -37,6 +38,10 @@ public class DateTimeUtil { return input.format(formatterDateYYYYMMDD); } + public static LocalDateTime strToTimeYYYYMMDD(String input) { + return LocalDateTime.parse(input, formatterDateYYYYMMDD); + } + public static LocalDateTime strToTime(String input) { return LocalDateTime.parse(input.substring(0, 19), formatter); } diff --git a/src/main/java/com/chint/interfaces/rest/amap/request/AmapRequest.java b/src/main/java/com/chint/interfaces/rest/amap/request/AmapRequest.java index 4aa03b52..e14e27f4 100644 --- a/src/main/java/com/chint/interfaces/rest/amap/request/AmapRequest.java +++ b/src/main/java/com/chint/interfaces/rest/amap/request/AmapRequest.java @@ -2,37 +2,14 @@ package com.chint.interfaces.rest.amap.request; import com.chint.infrastructure.util.SignUtils; import com.chint.interfaces.rest.amap.BaseRequestParam; - -import com.chint.interfaces.rest.amap.BaseResponse; import com.chint.interfaces.rest.base.PostRequest; -import com.google.common.base.Charsets; -import com.google.gson.Gson; import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpEntity; -import org.apache.http.NameValuePair; -import org.apache.http.client.HttpClient; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.message.BasicNameValuePair; -import org.apache.http.util.EntityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import java.io.IOException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; import java.util.Map; -import static com.chint.infrastructure.constant.AmapConstant.USER_CREATE_PATH; - @Slf4j @Component public class AmapRequest { @@ -68,7 +45,7 @@ public class AmapRequest { return request.getSend(url, params, responseType); } - public V post(String url,BaseRequestParam baseRequestParam, Class responseType) { + public V post(String url, BaseRequestParam baseRequestParam, Class responseType) { baseRequestParam.setAppId(appId); baseRequestParam.setEid(eid); baseRequestParam.setEnt(4); diff --git a/src/main/java/com/chint/interfaces/rest/amap/request/AmapSettleBillRequest.java b/src/main/java/com/chint/interfaces/rest/amap/request/AmapSettleBillRequest.java index 9816b212..66888928 100644 --- a/src/main/java/com/chint/interfaces/rest/amap/request/AmapSettleBillRequest.java +++ b/src/main/java/com/chint/interfaces/rest/amap/request/AmapSettleBillRequest.java @@ -7,6 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -60,4 +62,16 @@ public class AmapSettleBillRequest { String endDayOfMonth = DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.endDayOfMonth(date)); return pageFinishedOrder(firstDayOfMonth, endDayOfMonth); } + + public List amapRecordByDay() { + LocalDateTime today = LocalDateTime.now(); + LocalDateTime yesterday = today.minusDays(1).toLocalDate().atStartOfDay(); + return pageFinishedOrder(DateTimeUtil.timeToStrYYYYMMDD(yesterday), DateTimeUtil.timeToStrYYYYMMDD(today)); + } + + public List amapRecordByDay(String date) { + LocalDateTime localDateTime = DateTimeUtil.strToTimeYYYYMMDD(date); + LocalDateTime yesterday = localDateTime.minusDays(1).toLocalDate().atStartOfDay(); + return pageFinishedOrder(DateTimeUtil.timeToStrYYYYMMDD(yesterday), DateTimeUtil.timeToStrYYYYMMDD(localDateTime)); + } } diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderDetailRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderDetailRequest.java index c99d85ae..9fbb2d5d 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderDetailRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderDetailRequest.java @@ -12,7 +12,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import static com.chint.infrastructure.constant.CTripConstant.*; @@ -58,9 +57,19 @@ public class CTripOrderDetailRequest { public OrderFlightResponse getFlightOrder() { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); - LocalDateTime localDateTime = LocalDateTime.now().minusDays(1L); - return getFlightOrder(formatter.format(localDateTime), formatter.format(localDateTime)); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime localDateTime = now.minusDays(1L); + return postRequest.post(flightOrderUrl, + getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)), + OrderFlightResponse.class); + } + + public OrderFlightResponse getFlightOrder(String oneDate) { + LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate); + LocalDateTime localDateTime = oneDateL.minusDays(1L); + return postRequest.post(flightOrderUrl, + getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)), + OrderFlightResponse.class); } public OrderFlightResponse getFlightOrderByDate(String date) { @@ -70,7 +79,7 @@ public class CTripOrderDetailRequest { public OrderFlightResponse getFlightOrder(String dateFrom, String dateTo) { - return postRequest.post(flightOrderUrl, getParamByDateFromAndDateTo(dateFrom, dateTo), + return postRequest.post(flightOrderUrl, getParamByBatch(dateFrom, dateTo), OrderFlightResponse.class); } @@ -80,13 +89,23 @@ public class CTripOrderDetailRequest { } public OrderHotelResponse getHotelOrder() { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); - LocalDateTime localDateTime = LocalDateTime.now().minusDays(1L); - return getHotelOrder(formatter.format(localDateTime), formatter.format(localDateTime)); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime localDateTime = now.minusDays(1L); + return postRequest.post(hotelOrderUrl, + getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)), + OrderHotelResponse.class); + } + + public OrderHotelResponse getHotelOrder(String oneDate) { + LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate); + LocalDateTime localDateTime = oneDateL.minusDays(1L); + return postRequest.post(hotelOrderUrl, + getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)), + OrderHotelResponse.class); } public OrderHotelResponse getHotelOrder(String dateFrom, String dateTo) { - return postRequest.post(hotelOrderUrl, getParamByDateFromAndDateTo(dateFrom, dateTo), + return postRequest.post(hotelOrderUrl, getParamByBatch(dateFrom, dateTo), OrderHotelResponse.class); } @@ -97,13 +116,24 @@ public class CTripOrderDetailRequest { public OrderTrainResponse getTrainOrder() { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); - LocalDateTime localDateTime = LocalDateTime.now().minusDays(1L); - return getTrainOrder(formatter.format(localDateTime), formatter.format(localDateTime)); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime localDateTime = now.minusDays(1L); + return postRequest.post(trainOrderUrl, + getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)), + OrderTrainResponse.class); } + public OrderTrainResponse getTrainOrder(String oneDate) { + LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate); + LocalDateTime localDateTime = oneDateL.minusDays(1L); + return postRequest.post(trainOrderUrl, + getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)), + OrderTrainResponse.class); + } + + public OrderTrainResponse getTrainOrder(String dateFrom, String dateTo) { - return postRequest.post(trainOrderUrl, getParamByDateFromAndDateTo(dateFrom, dateTo), + return postRequest.post(trainOrderUrl, getParamByBatch(dateFrom, dateTo), OrderTrainResponse.class); } @@ -113,17 +143,40 @@ public class CTripOrderDetailRequest { } public OrderCarResponse getCarOrder() { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); - LocalDateTime localDateTime = LocalDateTime.now().minusDays(1L); - return getCarOrder(formatter.format(localDateTime), formatter.format(localDateTime)); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime localDateTime = now.minusDays(1L); + return postRequest.post(carOrderUrl, + getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)), + OrderCarResponse.class); + } + + public OrderCarResponse getCarOrder(String oneDate) { + LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate); + LocalDateTime localDateTime = oneDateL.minusDays(1L); + return postRequest.post(carOrderUrl, + getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)), + OrderCarResponse.class); } public OrderCarResponse getCarOrder(String dateFrom, String dateTo) { - return postRequest.post(carOrderUrl, getParamByDateFromAndDateTo(dateFrom, dateTo), + return postRequest.post(carOrderUrl, getParamByBatch(dateFrom, dateTo), OrderCarResponse.class); } private OrderRecordParam getParamByDateFromAndDateTo(String dateFrom, String dateTo) { + OrderRecordParam orderFlightParam = OrderRecordParam.of( + C_TRIP_ACCOUNT_ID, + dateFrom, + dateTo, + null + ); + orderFlightParam.auth(Authentification.midOf(C_TRIP_APP_KEY, ticketRequest.loadTicket())); + orderFlightParam.setAppKey(C_TRIP_APP_KEY); + orderFlightParam.setTicket(ticketRequest.loadTicket()); + return orderFlightParam; + } + + private OrderRecordParam getParamByBatch(String dateFrom, String dateTo) { String substring = dateFrom.substring(0, 6); String dateFromNew = substring + "01"; String batchNo = C_TRIP_CORP_ID + "_" + C_TRIP_ACCOUNT_ID + "_" + dateFromNew; diff --git a/src/test/java/com/chint/CTripTest.java b/src/test/java/com/chint/CTripTest.java index a98cbb4a..d0449b84 100644 --- a/src/test/java/com/chint/CTripTest.java +++ b/src/test/java/com/chint/CTripTest.java @@ -250,7 +250,7 @@ public class CTripTest { @Test void search() { BaseContext.setCurrentUser(user); - SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("32559146895"); + SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31592018105"); System.out.println(response); } diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index b301bed8..56eb018c 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -18,6 +18,7 @@ import com.chint.domain.service.JTCompanyDomainService; import com.chint.domain.service.OrderDomainService; import com.chint.domain.service.SystemDomainService; import com.chint.domain.service.order_sync.LYOrderSyncAdapter; +import com.chint.domain.value_object.RanksData; import com.chint.infrastructure.repository.CTripOrderDetailImpl; import com.chint.infrastructure.util.DateTimeUtil; import com.chint.infrastructure.util.Digest; @@ -304,7 +305,7 @@ class RouteApplicationTests { @Test void loginSign() { - String sfno = "230410022"; + String sfno = "190506003"; String syscode = "FSSC"; String billcode = "CLSQ240225000099"; String companycode = "正泰集团股份有限公司"; @@ -315,7 +316,7 @@ class RouteApplicationTests { @Test void loginSignProd() { - String sfno = "230214151"; + String sfno = "240611055"; String syscode = "FSSC"; String billcode = "CLSQ240225000099"; String companycode = "正泰集团股份有限公司"; @@ -1368,34 +1369,34 @@ class RouteApplicationTests { } - // @Test + @Test void addRanks() { -// RanksData ranksData = new RanksData(); -// ranksData.setIndustry("正泰电气股份有限公司"); -// ranksData.setCompanyCode("A20000001"); -// for (int i = 1; i < 13; i++) { -// if (i <= 1) { -// ranksData.setLevel(3); -// } else if (i <= 4) { -// ranksData.setLevel(3); -// } else if (i <= 8) { -// ranksData.setLevel(2); -// } else { -// ranksData.setLevel(1); -// } -// ranksData.setRankName("P" + i); -// rankController.saveRanks(ranksData); -// ranksData.setRankName("M" + i); -// rankController.saveRanks(ranksData); -// ranksData.setRankName("L" + i); -// rankController.saveRanks(ranksData); -// } -// -// for (int i = 1; i < 6; i++) { -// ranksData.setLevel(4); -// ranksData.setRankName("PR" + i); -// rankController.saveRanks(ranksData); -// } + RanksData ranksData = new RanksData(); + ranksData.setIndustry("浙江正泰汽车科技有限公司"); + ranksData.setCompanyCode("A30040001"); + for (int i = 1; i < 13; i++) { + if (i <= 1) { + ranksData.setLevel(3); + } else if (i <= 5) { + ranksData.setLevel(3); + } else if (i <= 7) { + ranksData.setLevel(2); + } else { + ranksData.setLevel(1); + } + ranksData.setRankName("P" + i); + rankController.saveRanks(ranksData); + ranksData.setRankName("M" + i); + rankController.saveRanks(ranksData); + ranksData.setRankName("L" + i); + rankController.saveRanks(ranksData); + } + + for (int i = 1; i < 6; i++) { + ranksData.setLevel(4); + ranksData.setRankName("PR" + i); + rankController.saveRanks(ranksData); + } } // @Test