feat: 同步的行程节点查看和同步时加入供应商规则(系统标识,公司名,差标管控)

This commit is contained in:
lulz1 2024-06-12 12:54:49 +08:00
parent 4d77602010
commit 79e03e9ca5
27 changed files with 438 additions and 175 deletions

View File

@ -95,18 +95,20 @@ public class AutoWorkController {
return Result.Success(SUCCESS);
}
@ApiOperation("拉取按月份的流水")
@PostMapping("/record/pull/month/")
@ApiOperation("拉取供应商的结算账单")
@PostMapping("/record/pull")
public Result<String> 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<String> generateFromRecord(@RequestBody RecordMonthSaveDTO param) {
//
// return Result.Success(SUCCESS);
//
// }
@Transactional
@ApiOperation("根据月份生成结算记录")
@PostMapping("/record/save/month")

View File

@ -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<Ranks> 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")

View File

@ -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);

View File

@ -33,4 +33,8 @@ public class Location implements Serializable {
private Long cityId;
private Integer isHaveAirport;
private Integer locationType;
public boolean isInternal(){
return isInternal == 1;
}
}

View File

@ -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));
}
}

View File

@ -22,4 +22,7 @@ public class SupplierProductCompany implements Serializable {
public boolean inUse() {
return status == 1;
}
public boolean notUse() {
return status == 0;
}
}

View File

@ -23,4 +23,8 @@ public class SupplierProductStandardLevel implements Serializable {
public boolean inUse() {
return status == 1;
}
public boolean notUse() {
return status == 0;
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -8,5 +8,7 @@ public interface AmapCarOrderRecordRepository {
List<AmapCarOrderRecord> saveAll(List<AmapCarOrderRecord> records);
List<AmapCarOrderRecord> findByOrderIds(List<String> orderIds);
List<AmapCarOrderRecord> findByDs(String ds);
}

View File

@ -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<Leg> queryLocation(List<Leg> list) {
list.forEach(leg -> {
LegExtensionField legExtensionField = leg.getLegExtensionField();
if (legExtensionField != null && legExtensionField.getLocationIds() != null ) {
if (legExtensionField != null && legExtensionField.getLocationIds() != null) {
List<Long> locationIdsAsLong;
if (legExtensionField.getLocationIds().startsWith("[")) {
locationIdsAsLong = legExtensionField.getLocationIdsAsLongFromArray();
@ -168,16 +172,57 @@ public class LegDomainService {
public List<Leg> queryLegsCanSync(RouteOrder routeOrder, String supplierName) {
List<Leg> 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<Leg> ifCanSync(List<Leg> legs, RouteOrder routeOrder, String supplierName) {
return supplierRepository.findBySupplierName(supplierName)
.map(supplier -> {
List<Integer> 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<Leg> syncLegExclusive(RouteOrder routeOrder, List<Leg> legItems, String supplierName) {
List<Long> alreadySyncLegs = routeOrder.getRouteRequestList()

View File

@ -76,11 +76,12 @@ public class RouteRequestDomainService {
RouteOrder routeOrder = routeRepository.queryById(syncLegData.getRouteId());
legDomainService.checkLegIfStartApproval(routeOrder);
List<Long> 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<Long> legIds = syncLegData.getLegIds();
Long routeId = syncLegData.getRouteId();
RouteOrder routeOrder = routeRepository.queryById(routeId);
Optional<RouteRequest> 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<Leg> legs = it.loadLegInfoSelf(routeOrder)
.getRouteRequestLegList()
.stream()
.map(RouteRequestLeg::getLeg)
.toList();
Optional<Supplier> supplierOptional = supplierRepository.findBySupplierName(it.getSupplier());
Map<Boolean, List<Leg>> collect;
Optional<RouteRequest> optionalRouteRequest = findRouteRequest(routeOrder, syncLegData);
optionalRouteRequest.ifPresent(routeRequest -> {
List<Leg> legs = getLegsFromRouteRequest(routeRequest, routeOrder);
Optional<Supplier> 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<Leg> 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<Leg> 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<Boolean, List<Leg>> 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<RouteRequest> 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<Leg> getLegsFromRouteRequest(RouteRequest routeRequest, RouteOrder routeOrder) {
return routeRequest.loadLegInfoSelf(routeOrder)
.getRouteRequestLegList()
.stream()
.map(RouteRequestLeg::getLeg)
.toList();
}
private Map<Boolean, List<Leg>> partitionLegsByOrderStatus(List<Leg> legs, List<Long> 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<Leg> 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<Leg> 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<Long> 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());
}

View File

@ -59,6 +59,8 @@ public class SupplierDomainService {
}
}
@ListenTo(command = "SupplierCallBackErrorCommand", order = 0)
public void supplierCallBackError(SupplierCallBackErrorCommand command) {
SupplierCallBackLog supplierCallBackLog = SupplierCallBackLog

View File

@ -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<FinishedOrderResponse.ListElement> listElements = amapSettleBillRequest.amapRecordByMonth(command.getDate());
List<AmapCarOrderRecord> list = listElements.stream().map(AmapCarOrderRecord::of).toList();
List<FinishedOrderResponse.ListElement> 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<String> orderIdList = listElements.stream().map(FinishedOrderResponse.ListElement::getAmapOrderId).toList();
List<AmapCarOrderRecord> alreadyExist = amapCarOrderRecordRepository.findByOrderIds(orderIdList);
List<AmapCarOrderRecord> 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();

View File

@ -144,6 +144,9 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync {
}
List<String> 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;

View File

@ -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<Integer> legType = routeRequest.getRouteRequestLegList()
List<Leg> 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);
}
}
}

View File

@ -27,7 +27,6 @@ public class SupplierAdapterSelector {
Map<String, SupplierAdapter> 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);

View File

@ -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 -> "未知供应商";
};
}

View File

@ -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";//山东智能编号

View File

@ -22,6 +22,11 @@ public class AmapCarOrderRecordRepositoryImpl implements AmapCarOrderRecordRepos
return res;
}
@Override
public List<AmapCarOrderRecord> findByOrderIds(List<String> orderIds) {
return jdbcAmapCarOrderRecordRepository.findByAmapOrderIdIn(orderIds);
}
@Override
public List<AmapCarOrderRecord> findByDs(String ds) {
return jdbcAmapCarOrderRecordRepository.findByDsContaining(ds);

View File

@ -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<AmapCarOrderRecord, Long> {
List<AmapCarOrderRecord> findByDsContaining(String ds);
List<AmapCarOrderRecord> findByAmapOrderIdIn(Collection<String> amapOrderId);
}

View File

@ -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);
}

View File

@ -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> V post(String url,BaseRequestParam baseRequestParam, Class<V> responseType) {
public <V> V post(String url, BaseRequestParam baseRequestParam, Class<V> responseType) {
baseRequestParam.setAppId(appId);
baseRequestParam.setEid(eid);
baseRequestParam.setEnt(4);

View File

@ -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<FinishedOrderResponse.ListElement> amapRecordByDay() {
LocalDateTime today = LocalDateTime.now();
LocalDateTime yesterday = today.minusDays(1).toLocalDate().atStartOfDay();
return pageFinishedOrder(DateTimeUtil.timeToStrYYYYMMDD(yesterday), DateTimeUtil.timeToStrYYYYMMDD(today));
}
public List<FinishedOrderResponse.ListElement> amapRecordByDay(String date) {
LocalDateTime localDateTime = DateTimeUtil.strToTimeYYYYMMDD(date);
LocalDateTime yesterday = localDateTime.minusDays(1).toLocalDate().atStartOfDay();
return pageFinishedOrder(DateTimeUtil.timeToStrYYYYMMDD(yesterday), DateTimeUtil.timeToStrYYYYMMDD(localDateTime));
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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