diff --git a/src/main/java/com/chint/application/out/FSSCController.java b/src/main/java/com/chint/application/out/FSSCController.java index 992d2ee6..bf69872e 100644 --- a/src/main/java/com/chint/application/out/FSSCController.java +++ b/src/main/java/com/chint/application/out/FSSCController.java @@ -1,7 +1,9 @@ package com.chint.application.out; import com.chint.domain.aggregates.system.FsscSystem; +import com.chint.domain.aggregates.system.SystemCode; import com.chint.domain.aggregates.user.User; +import com.chint.domain.repository.SystemCodeRepository; import com.chint.domain.service.JTCompanyDomainService; import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.Result; @@ -15,12 +17,12 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import static com.chint.infrastructure.constant.BPMConstant.*; +import static com.chint.infrastructure.constant.BPMConstant.FSSC; +import static com.chint.infrastructure.constant.BPMConstant.XN_FSSC; import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS; import static com.chint.infrastructure.constant.FSSCConstant.*; @@ -44,6 +46,12 @@ public class FSSCController { @Autowired private PostRequest postRequest; + @Autowired + private SystemCodeRepository systemCodeRepository; + + @Value("${chint.envMark}") + private String envMark; + private Map urlCache = new HashMap<>(); @PostConstruct @@ -60,27 +68,18 @@ public class FSSCController { User user = BaseContext.getCurrentUser(); String employeeNo = user.getEmployeeNo(); //这里需要根据companyCode进行匹配到正确的申请单网址 - - List systemCodes = user.getFsscSystemList() - .stream() - .map(FsscSystem::getSystemCode) - .toList(); - - List res = new ArrayList<>(); - - if (systemCodes.contains(FSSC)) { - FsscSystem fsscSystem = new FsscSystem(FSSC_NAME, FSSC, - postRequest.getReDirectUrl(FSSC_LOAD_URL + generateFsscUrlPath(employeeNo))); - res.add(fsscSystem); - } - //如果用户的公司编码属于集团 ,那么加入集团财务共享跳转地址 - if (systemCodes.contains(XN_FSSC)) { - FsscSystem fsscSystem = new FsscSystem(XN_FSSC_NAME, XN_FSSC, - postRequest.getReDirectUrl(FSSC_LOAD_URL + generateXNFsscUrlPath(employeeNo))); - res.add(fsscSystem); - } - - return Result.Success(SUCCESS, res); + List fsscSystemList = user.getFsscSystemList(); + fsscSystemList.forEach(it -> { + SystemCode sysCode = systemCodeRepository.findBySysCode(it.getSystemCode()); + String dataBaseUrl; + if (envMark.equals("prod")) { + dataBaseUrl = sysCode.getSystemCodeUrl().getRedirectUrlProd(); + } else { + dataBaseUrl = sysCode.getSystemCodeUrl().getRedirectUrlDev(); + } + it.setRedirectUrl(postRequest.getReDirectUrl(generateUrlPathFromDataBase(dataBaseUrl, employeeNo))); + }); + return Result.Success(SUCCESS, fsscSystemList); } public String generateFsscUrlPath(String employeeNo) { @@ -91,4 +90,7 @@ public class FSSCController { return XN_FSSC_REDIRECT_PATH_APPROVAL_ONE + employeeNo + FSSC_REDIRECT_PATH_APPROVAL_TWO; } + public String generateUrlPathFromDataBase(String dataBaseUrl, String employeeNo) { + return dataBaseUrl + employeeNo + FSSC_REDIRECT_PATH_APPROVAL_TWO; + } } diff --git a/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java b/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java index 85be5680..73c1527f 100644 --- a/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java +++ b/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java @@ -5,10 +5,10 @@ import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEnti import com.chint.domain.aggregates.order.Location; import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.standards.CityTag; -import com.chint.domain.service.TrainStandardsService; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.LocationException; import com.chint.domain.repository.*; +import com.chint.domain.service.TrainStandardsService; import com.chint.domain.value_object.FlightPriceData; import com.chint.domain.value_object.HotelPriceData; import com.chint.domain.value_object.PriceQueryData; @@ -150,7 +150,7 @@ public class CTripEstimatePrice implements EstimatePrice { public FlightPriceData queryFlightPrice(PriceQueryData priceQueryData) { checkPriceQueryData(priceQueryData); FlightProductInfo flightProductInfo = new FlightProductInfo(); - + FlightPriceData flightPriceData = new FlightPriceData(); String employeeNo; String standardLevel; if (priceQueryData.getRouteId() != null) { @@ -176,6 +176,13 @@ public class CTripEstimatePrice implements EstimatePrice { getCityId(originLocation); Location arriveLocation = locationRepository.findById(priceQueryData.getArriveCity()); getCityId(arriveLocation); + + //增加判断,如果查不到城市id就返回为空 + if (originLocation.getCityId() == null || arriveLocation.getCityId() == null) { + flightPriceData.setSuccess(false); + flightPriceData.setMaxPrice(NO_PRICE_ERROR); + return flightPriceData; + } routeInfo.setArriveCityID( originLocation.getCityId().toString()); routeInfo.setDepartCityID( @@ -187,7 +194,7 @@ public class CTripEstimatePrice implements EstimatePrice { BookingRelatedApiRequest bookingRelatedApiRequest = cTripEstimateRequest .generateBaseRequest(flightProductInfo, null, null, employeeNo, standardLevel); BookingRelatedApiResponse estimate = cTripEstimateRequest.estimate(bookingRelatedApiRequest); - FlightPriceData flightPriceData = new FlightPriceData(); + if (estimate.getStatus().getSuccess()) { Optional.ofNullable( @@ -334,10 +341,13 @@ public class CTripEstimatePrice implements EstimatePrice { private Location getCityId(Location location) { if (location.getCityId() == null) { if (location.getLevel().equals(LOCATION_LEVEL_COUNTY)) { - CountryLevelInfoEntity byCityName = countryLevelInfoRepository - .findByCityName(location.getLocationName()) - .get(0); - location.setCityId(byCityName.getCountyId()); + List list = countryLevelInfoRepository + .findByCityName(location.getLocationName()); + if (list != null && !list.isEmpty()) { + CountryLevelInfoEntity byCityName = list + .get(0); + location.setCityId(byCityName.getCountyId()); + } } else { List prefectureLevelCityInfoEntity = prefectureLevelRepository .findByCityName(location.getLocationName()); diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java index b5d1ed1f..88d633a6 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java @@ -1,9 +1,13 @@ package com.chint.domain.aggregates.order.order_record; import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; @Data +@Table("order_car_record") public class OrderCarRecord extends OrderBaseRecord { + @Id private Long id; private Long orderDetailId; private String trvaleSysType; // 数据来源商旅平台 XC:携程 TC:同程 diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java index ffaf0d6e..c41565e2 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java @@ -1,9 +1,13 @@ package com.chint.domain.aggregates.order.order_record; import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; @Data +@Table("order_flight_record") public class OrderFlightRecord extends OrderBaseRecord{ + @Id private Long id; private Long orderDetailId; private String trvaleSysType; // 数据来源商旅平台 XC:携程 TC:同程 diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderHotelRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderHotelRecord.java index ce21bb90..08854f0c 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderHotelRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderHotelRecord.java @@ -1,9 +1,13 @@ package com.chint.domain.aggregates.order.order_record; import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; @Data +@Table("order_hotel_record") public class OrderHotelRecord extends OrderBaseRecord{ + @Id private Long id; private Long orderDetailId; private String trvaleSysType; // 数据来源商旅平台 XC:携程 TC:同程 diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderTrainRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderTrainRecord.java index ef397bb9..de177373 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderTrainRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderTrainRecord.java @@ -1,9 +1,13 @@ package com.chint.domain.aggregates.order.order_record; import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; @Data +@Table("order_train_record") public class OrderTrainRecord extends OrderBaseRecord{ + @Id private Long id; private Long orderDetailId; private String trvaleSysType; // 数据来源商旅平台 XC:携程 TC:同程 diff --git a/src/main/java/com/chint/domain/aggregates/system/FsscSystem.java b/src/main/java/com/chint/domain/aggregates/system/FsscSystem.java index 4d575d45..816f2a8d 100644 --- a/src/main/java/com/chint/domain/aggregates/system/FsscSystem.java +++ b/src/main/java/com/chint/domain/aggregates/system/FsscSystem.java @@ -1,11 +1,25 @@ package com.chint.domain.aggregates.system; -import com.chint.interfaces.rest.base.PostRequest; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; + @Data +@NoArgsConstructor public class FsscSystem { - private final String systemName; - private final String systemCode; - private final String redirectUrl; + private String systemName; + private String systemCode; + private String redirectUrl; + + public FsscSystem(String systemName, String systemCode) { + this.systemName = systemName; + this.systemCode = systemCode; + } + + public FsscSystem(String systemName, String systemCode, String redirectUrl) { + this.systemName = systemName; + this.systemCode = systemCode; + this.redirectUrl = redirectUrl; + } } diff --git a/src/main/java/com/chint/domain/aggregates/system/JTCompany.java b/src/main/java/com/chint/domain/aggregates/system/JTCompany.java index 16d92096..4bc27666 100644 --- a/src/main/java/com/chint/domain/aggregates/system/JTCompany.java +++ b/src/main/java/com/chint/domain/aggregates/system/JTCompany.java @@ -16,4 +16,5 @@ public class JTCompany implements Serializable { private Long id; private String companyName; private String companyCode; + private Long systemCodeId; } diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java index 17e17d95..5727fab0 100644 --- a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java +++ b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java @@ -23,4 +23,6 @@ public class SystemCode implements Serializable { private Integer ifImmediateResponse; //是否立马回复审批结果,0不是,1是 @MappedCollection(idColumn = "system_id", keyColumn = "system_key") private List companyInfos; + @MappedCollection(idColumn = "system_code_id") + private SystemCodeUrl systemCodeUrl; } diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemCodeUrl.java b/src/main/java/com/chint/domain/aggregates/system/SystemCodeUrl.java new file mode 100644 index 00000000..c299500a --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/system/SystemCodeUrl.java @@ -0,0 +1,20 @@ +package com.chint.domain.aggregates.system; + +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.io.Serial; +import java.io.Serializable; + +@Data +@Table("system_code_url") +public class SystemCodeUrl implements Serializable { + @Serial + private static final long serialVersionUID = 5003392233348155635L; + @Id + private Long id; + private Long systemCodeId; + private String redirectUrlDev; + private String redirectUrlProd; +} diff --git a/src/main/java/com/chint/domain/aggregates/user/User.java b/src/main/java/com/chint/domain/aggregates/user/User.java index 8ac2aaae..edc6462d 100644 --- a/src/main/java/com/chint/domain/aggregates/user/User.java +++ b/src/main/java/com/chint/domain/aggregates/user/User.java @@ -99,6 +99,12 @@ public class User implements Serializable { this.companyCode = companyCode; } + public User addFssc(String CompanyName, String sysCode) { + FsscSystem fsscSystem = new FsscSystem(CompanyName, sysCode); + this.addFsscSystemToList(fsscSystem); + return this; + } + public User addXNFssc(String loadUrl, PostRequest postRequest) { FsscSystem fsscSystem = new FsscSystem(XN_FSSC_NAME, XN_FSSC, postRequest.getReDirectUrl(loadUrl + generateXNFsscUrlPath())); this.addFsscSystemToList(fsscSystem); @@ -110,7 +116,8 @@ public class User implements Serializable { this.addFsscSystemToList(fsscSystem); return this; } - public User addJTFssc(String companyName,String loadUrl, PostRequest postRequest) { + + public User addJTFssc(String companyName, String loadUrl, PostRequest postRequest) { FsscSystem fsscSystem = new FsscSystem(companyName, FSSC, postRequest.getReDirectUrl(loadUrl + generateFsscUrlPath())); this.addFsscSystemToList(fsscSystem); return this; diff --git a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordBasic.java b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordBasic.java new file mode 100644 index 00000000..91221ae4 --- /dev/null +++ b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordBasic.java @@ -0,0 +1,58 @@ +package com.chint.domain.factoriy.order_record; + +import cn.hutool.core.bean.BeanUtil; +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; +import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; +import lombok.Data; + +@Data +public class OrderRecordBasic { + // 数据来源商旅平台 + private String trvaleSysType; + // 对应所属系统 + private String belongSysType; + // 订单号 + private String orderNo; + // 消费明细唯一标识 + private String detailId; + // 核算企业id + private String accountCompanyId; + // 核算企业名称 + private String accountCompanyName; + // 申请单号 + private String receiptsNum; + // 行程编号 + private String scheduleNum; + // 预订人Code + private String bookingUserCode; + // 预订人姓名 + private String bookingName; + // 预订人电话 + private String bookingUserPhone; + // 资源供应商 + private String supplier; + // 超标原因 + private String overStandardReason; + // 项目订单号 + private String projectOrderNo; + // 成本中心 + private String offlineCcomyCode; + + public OrderCarRecord carRecord() { + return BeanUtil.copyProperties(this, OrderCarRecord.class); + } + + public OrderFlightRecord flightRecord() { + return BeanUtil.copyProperties(this, OrderFlightRecord.class); + } + + public OrderHotelRecord hotelRecord() { + return BeanUtil.copyProperties(this, OrderHotelRecord.class); + } + + public OrderTrainRecord trainRecord() { + return BeanUtil.copyProperties(this, OrderTrainRecord.class); + } +} 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 new file mode 100644 index 00000000..75422687 --- /dev/null +++ b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordExtensionFactory.java @@ -0,0 +1,16 @@ +package com.chint.domain.factoriy.order_record; + +import com.chint.domain.aggregates.order.*; + +public interface OrderRecordExtensionFactory { + + CarOrderDetail createCarOrderRecord(Object carOrderDetailData); + + TrainOrderDetail createTrainOrderRecord(Object trainOrderDetailData); + + FlightOrderDetail createFlightOrderRecord(Object flightOrderDetailData); + + HotelOrderDetail createHotelOrderRecord(Object hotelOrderDetailData); + + +} diff --git a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java index ddf06219..1981be66 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java @@ -1,8 +1,61 @@ package com.chint.domain.factoriy.order_record; +import com.chint.domain.aggregates.order.ApproveOrderNo; +import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.aggregates.user.User; +import com.chint.domain.repository.UserRepository; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import static com.chint.infrastructure.constant.BelongSystemConstant.*; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; + @Component public class OrderRecordFactory { + @Autowired + private UserRepository userRepository; + + public OrderRecordBasic buildWithRouteOrder(RouteOrder routeOrder) { + routeOrder.reloadStatus(); + OrderRecordBasic orderRecordBasic = new OrderRecordBasic(); + //完成身份信息 + String userId = routeOrder.getUserId(); + User user = userRepository.findByUserEmployeeNo(userId); + + orderRecordBasic.setBookingUserCode(user.getEmployeeNo()); + orderRecordBasic.setBookingName(user.getName()); + orderRecordBasic.setBookingUserPhone(user.getPhoneNumber()); + + //配置供应商信息 + String supplierName = routeOrder.getSupplierName(); + if (supplierName.equals(SUPPLIER_C_TRIP)) { + orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); + } else { + orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_LY); + } + + ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + if (approveOrderNo != null) { + orderRecordBasic.setAccountCompanyId(approveOrderNo.getAccountCompanyCode()); + orderRecordBasic.setAccountCompanyName(approveOrderNo.getAccountCompanyName()); + orderRecordBasic.setProjectOrderNo(approveOrderNo.getProjectName()); + String sysCode = routeOrder.getApproveOrderNo().getSysCode(); + if (sysCode != null) { + if (sysCode.equals(BELONG_SYS_CODE_FSSC)) { + orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_FSSC); + } + if (sysCode.equals(BELONG_SYS_CODE_H3BPM)) { + orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_H3BPM); + } + if (sysCode.equals(BELONG_SYS_CODE_XNFSSC)) { + orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_XNFSSC); + } + if (sysCode.equals(BELONG_SYS_CODE_ANFSSC)) { + orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_ANFSSC); + } + } + } + return orderRecordBasic; + } } diff --git a/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java new file mode 100644 index 00000000..62642c15 --- /dev/null +++ b/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java @@ -0,0 +1,9 @@ +package com.chint.domain.repository; + +import com.chint.domain.aggregates.order.order_record.OrderCarRecord; + +import java.util.List; + +public interface OrderCarRecordRepository { + List saveAll(List orderCarRecordList); +} diff --git a/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java new file mode 100644 index 00000000..f73dd606 --- /dev/null +++ b/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java @@ -0,0 +1,9 @@ +package com.chint.domain.repository; + +import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; + +import java.util.List; + +public interface OrderFlightRecordRepository { + List saveAll(List orderFlightRecordList); +} diff --git a/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java new file mode 100644 index 00000000..6f2d18f4 --- /dev/null +++ b/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java @@ -0,0 +1,9 @@ +package com.chint.domain.repository; + +import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; + +import java.util.List; + +public interface OrderHotelRecordRepository { + List saveAll(List orderHotelRecordList); +} diff --git a/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java new file mode 100644 index 00000000..35dfdca9 --- /dev/null +++ b/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java @@ -0,0 +1,10 @@ +package com.chint.domain.repository; + +import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; +import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; + +import java.util.List; + +public interface OrderTrainRecordRepository { + List saveAll(List orderTrainRecordList); +} diff --git a/src/main/java/com/chint/domain/service/JTCompanyDomainService.java b/src/main/java/com/chint/domain/service/JTCompanyDomainService.java index c99918c5..f0d5427d 100644 --- a/src/main/java/com/chint/domain/service/JTCompanyDomainService.java +++ b/src/main/java/com/chint/domain/service/JTCompanyDomainService.java @@ -3,6 +3,7 @@ package com.chint.domain.service; import com.chint.domain.aggregates.system.JTCompany; import com.chint.domain.repository.JTCompanyRepository; +import com.chint.domain.repository.SystemCodeRepository; import jakarta.annotation.PostConstruct; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -18,6 +19,9 @@ public class JTCompanyDomainService { @Autowired private JTCompanyRepository jtCompanyRepository; + @Autowired + private SystemCodeRepository systemCodeRepository; + private Set companyBlackList = new HashSet<>(); @@ -33,7 +37,7 @@ public class JTCompanyDomainService { if (companyName != null) { boolean contains = companyBlackList.stream().map(JTCompany::getCompanyName).toList().contains(companyName); //如果找不到的话, 再次查询数据进行一次查找 - if(!contains){ + if (!contains) { companyBlackList.addAll(jtCompanyRepository.findAll()); contains = companyBlackList.stream().map(JTCompany::getCompanyName).toList().contains(companyName); } @@ -50,4 +54,9 @@ public class JTCompanyDomainService { } return false; } + + public String findSystemCodeByCompanyCode(String companyCode) { + JTCompany byCompanyCode = jtCompanyRepository.findByCompanyCode(companyCode); + return systemCodeRepository.findById(byCompanyCode.getSystemCodeId()).getSystemCode(); + } } diff --git a/src/main/java/com/chint/domain/service/LegDomainService.java b/src/main/java/com/chint/domain/service/LegDomainService.java index 62aa92e4..3dae4d6e 100644 --- a/src/main/java/com/chint/domain/service/LegDomainService.java +++ b/src/main/java/com/chint/domain/service/LegDomainService.java @@ -53,7 +53,6 @@ public class LegDomainService { } } - if (lastOrderStatus.equals(ORDER_EVENT_CANCEL_NAME)) { LegEvent legEvent = legEventFactory.creatLegEvent(LEG_EVENT_CANCEL); leg.addEvent(legEvent); diff --git a/src/main/java/com/chint/domain/service/OrderDetailDomainService.java b/src/main/java/com/chint/domain/service/OrderDetailDomainService.java index 8a00259e..190c8df3 100644 --- a/src/main/java/com/chint/domain/service/OrderDetailDomainService.java +++ b/src/main/java/com/chint/domain/service/OrderDetailDomainService.java @@ -2,9 +2,12 @@ package com.chint.domain.service; import com.chint.domain.aggregates.order.OrderDetail; 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; +import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; import com.chint.domain.factoriy.order_detail.OrderDetailFactory; -import com.chint.domain.repository.OrderDetailRepository; -import com.chint.domain.repository.RouteRepository; +import com.chint.domain.repository.*; import com.chint.domain.service.order_search.OrderSearchSelector; import com.chint.domain.service.supplier.OrderDataAdapterSelector; import com.chint.domain.value_object.OrderLegData; @@ -36,6 +39,19 @@ public class OrderDetailDomainService { @Autowired private OrderDataAdapterSelector orderDataAdapterSelector; + @Autowired + private OrderCarRecordRepository orderCarRecordRepository; + + @Autowired + private OrderHotelRecordRepository orderHotelRecordRepository; + + @Autowired + private OrderFlightRecordRepository orderFlightRecordRepository; + + @Autowired + private OrderTrainRecordRepository orderTrainRecordRepository; + + public void syncOrderDetailStatus(List orderLegDataList) { for (OrderLegData orderLegData : orderLegDataList) { orderDetailRepository.findByOrderNo(orderLegData.getOutOrderNo()).ifPresent( @@ -67,4 +83,18 @@ public class OrderDetailDomainService { syncOrderDetailStatus(orderLegDataList); return true; } + + public List saveCarOrderRecordBatch(List orderCarRecordList) { + return orderCarRecordRepository.saveAll(orderCarRecordList); + } + public List saveFlightOrderRecordBatch(List orderFlightRecordList) { + return orderFlightRecordRepository.saveAll(orderFlightRecordList); + } + public List saveTrainOrderRecordBatch(List orderTrainRecordList) { + return orderTrainRecordRepository.saveAll(orderTrainRecordList); + } + public List saveHotelOrderRecordBatch(List orderHotelRecordList) { + return orderHotelRecordRepository.saveAll(orderHotelRecordList); + } + } diff --git a/src/main/java/com/chint/domain/service/OrderDomainService.java b/src/main/java/com/chint/domain/service/OrderDomainService.java index 89340067..07fe8b27 100644 --- a/src/main/java/com/chint/domain/service/OrderDomainService.java +++ b/src/main/java/com/chint/domain/service/OrderDomainService.java @@ -162,6 +162,8 @@ public class OrderDomainService { return list; } + + @ListenTo(command = "OrderCreateCommand", order = 0) public RouteOrder createOrder(OrderCreateCommand command) { User user = command.getUser(); @@ -628,4 +630,5 @@ public class OrderDomainService { } } } + } diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java index b6d4d259..1a5b145c 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java @@ -112,7 +112,6 @@ public class LegEventHandler implements LegEventService { //保存提交审批所提供的资料 ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); approveOrderNo.setActualOrderNo(data.getActualOrderNo()); -// approveOrderNo.setAccountCompany(data.getAccountCompany()); approveOrderNo.setInstructions(data.getInstructions()); approveOrderNo.setCreator(data.getCreator()); approveOrderNo.setAccountCompanyCode(data.getAccountCompanyCode()); diff --git a/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java new file mode 100644 index 00000000..f76fe4ad --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java @@ -0,0 +1,22 @@ +package com.chint.infrastructure.repository; + +import com.chint.domain.aggregates.order.order_record.OrderCarRecord; +import com.chint.domain.repository.OrderCarRecordRepository; +import com.chint.infrastructure.repository.jdbc.JdbcOrderCarRecordRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.ArrayList; +import java.util.List; + +@Repository +public class OrderCarRecordRepositoryImpl implements OrderCarRecordRepository { + @Autowired + private JdbcOrderCarRecordRepository orderCarRecordRepository; + @Override + public List saveAll(List orderCarRecordList) { + List res = new ArrayList<>(); + orderCarRecordRepository.saveAll(orderCarRecordList).forEach(res::add); + return res; + } +} diff --git a/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java new file mode 100644 index 00000000..a1afff6e --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java @@ -0,0 +1,24 @@ +package com.chint.infrastructure.repository; + +import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; +import com.chint.domain.repository.OrderFlightRecordRepository; +import com.chint.infrastructure.repository.jdbc.JdbcOrderFlightRecordRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.ArrayList; +import java.util.List; + +@Repository +public class OrderFlightRecordRepositoryImpl implements OrderFlightRecordRepository { + + @Autowired + private JdbcOrderFlightRecordRepository jdbcOrderFlightRecordRepository; + + @Override + public List saveAll(List orderFlightRecordList) { + List res = new ArrayList<>(); + jdbcOrderFlightRecordRepository.saveAll(orderFlightRecordList).forEach(res::add); + return res; + } +} diff --git a/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java new file mode 100644 index 00000000..e7a4cf8a --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java @@ -0,0 +1,25 @@ +package com.chint.infrastructure.repository; + +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.JdbcOrderFlightRecordRepository; +import com.chint.infrastructure.repository.jdbc.JdbcOrderHotelRecordRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.ArrayList; +import java.util.List; + +@Repository +public class OrderHotelRecordRepositoryImpl implements OrderHotelRecordRepository { + + @Autowired + private JdbcOrderHotelRecordRepository jdbcOrderHotelRecordRepository; + @Override + public List saveAll(List orderHotelRecordList) { + List res = new ArrayList<>(); + jdbcOrderHotelRecordRepository.saveAll(orderHotelRecordList).forEach(res::add); + return res; + } +} diff --git a/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java new file mode 100644 index 00000000..71aac4f9 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java @@ -0,0 +1,24 @@ +package com.chint.infrastructure.repository; + +import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; +import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; +import com.chint.domain.repository.OrderTrainRecordRepository; +import com.chint.infrastructure.repository.jdbc.JdbcOrderHotelRecordRepository; +import com.chint.infrastructure.repository.jdbc.JdbcOrderTrainRecordRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.ArrayList; +import java.util.List; + +@Repository +public class OrderTrainRecordRepositoryImpl implements OrderTrainRecordRepository { + @Autowired + private JdbcOrderTrainRecordRepository jdbcOrderTrainRecordRepository; + @Override + public List saveAll(List orderTrainRecordList) { + List res = new ArrayList<>(); + jdbcOrderTrainRecordRepository.saveAll(orderTrainRecordList).forEach(res::add); + return res; + } +} diff --git a/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java index 6c9c46e1..54543c8f 100644 --- a/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java @@ -5,13 +5,9 @@ import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.repository.SystemCodeRepository; import com.chint.infrastructure.repository.jdbc.JdbcSystemCodeRepository; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Repository; - -import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; - @Repository public class SystemCodeRepositoryImpl implements SystemCodeRepository { @@ -31,6 +27,6 @@ public class SystemCodeRepositoryImpl implements SystemCodeRepository { @Override public SystemCode findById(Long id) { - return jdbcSystemCodeRepository.findById(id).orElseThrow(() -> new NotFoundException(NOT_FOUND)); + return jdbcSystemCodeRepository.findById(id).orElseThrow(() -> new NotFoundException("该产业公司不在实施范围内")); } } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java new file mode 100644 index 00000000..43f5f58a --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java @@ -0,0 +1,9 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.order.order_record.OrderCarRecord; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface JdbcOrderCarRecordRepository extends CrudRepository { +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java new file mode 100644 index 00000000..cfc7e5f2 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java @@ -0,0 +1,9 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface JdbcOrderFlightRecordRepository extends CrudRepository { +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java new file mode 100644 index 00000000..03d806dc --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java @@ -0,0 +1,9 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface JdbcOrderHotelRecordRepository extends CrudRepository { +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java new file mode 100644 index 00000000..bc274d54 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java @@ -0,0 +1,9 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface JdbcOrderTrainRecordRepository extends CrudRepository { +} diff --git a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java index 8647350f..da97aaa0 100644 --- a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java +++ b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java @@ -3,7 +3,6 @@ package com.chint.interfaces.rest.user; import com.chint.domain.aggregates.standards.Ranks; import com.chint.domain.aggregates.standards.StaffRank; -import com.chint.domain.aggregates.system.JTCompany; import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.JTCompanyRepository; import com.chint.domain.repository.StaffRankRepository; @@ -21,11 +20,10 @@ import org.springframework.stereotype.Service; import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.function.Predicate; -import java.util.stream.Collectors; -import static com.chint.infrastructure.constant.RankConstant.*; +import static com.chint.infrastructure.constant.RankConstant.DEFAULT_RANK_NAME; +import static com.chint.infrastructure.constant.RankConstant.JT_COMPANY_CODE; @Slf4j @@ -120,13 +118,16 @@ public class UserHttpRequestImpl implements UserHttpRequest { getDataFromUserSFData(user, userData); - if (user.getCompanyCode().equals(XN_COMPANY_CODE)) { - user.addXNFssc(FSSC_LOAD_URL, postRequest); - } - //如果用户的公司编码属于集团 ,那么加入集团财务共享跳转地址 - if (jtCompanyDomainService.ifCompanyInJT(null, userData.getCompany())) { - user.addJTFssc(userData.getCompany_cn(), FSSC_LOAD_URL, postRequest); - } + String sysCode = jtCompanyDomainService.findSystemCodeByCompanyCode(user.getCompanyCode()); + + user.addFssc(userData.getCompany_cn(), sysCode); +// if (user.getCompanyCode().equals(XN_COMPANY_CODE)) { +// user.addXNFssc(FSSC_LOAD_URL, postRequest); +// } +// //如果用户的公司编码属于集团 ,那么加入集团财务共享跳转地址 +// if (jtCompanyDomainService.ifCompanyInJT(null, userData.getCompany())) { +// user.addJTFssc(userData.getCompany_cn(), FSSC_LOAD_URL, postRequest); +// } return user; } @@ -164,25 +165,31 @@ public class UserHttpRequestImpl implements UserHttpRequest { } private void processSpecialCompanies(List userDataDTOS, User user) { - Set companyCodes = userDataDTOS.stream() - .map(UserDataDTO::getCompany) - .collect(Collectors.toSet()); - - List inJtCompanyCodes = companyCodes - .stream() - .filter(code -> jtCompanyDomainService.ifCompanyInJT(null, code)) + List list = userDataDTOS.stream() + .filter(it -> jtCompanyDomainService.ifCompanyInJT(null, it.getCompany())) .toList(); - for (String inJtCompanyCode : inJtCompanyCodes) { - JTCompany byCompanyCode = jtCompanyRepository.findByCompanyCode(inJtCompanyCode); - user.addJTFssc(byCompanyCode.getCompanyName(), FSSC_LOAD_URL, postRequest); - } - - - if (companyCodes.contains(XN_COMPANY_CODE)) { - user.addXNFssc(FSSC_LOAD_URL, postRequest); - } + list.forEach(it -> user.addFssc(it.getCompany_cn(), + jtCompanyDomainService.findSystemCodeByCompanyCode(it.getCompany()))); +// Set companyCodes = userDataDTOS.stream() +// .map(UserDataDTO::getCompany) +// .collect(Collectors.toSet()); +// +// +// List inJtCompanyCodes = companyCodes +// .stream() +// .filter(code -> jtCompanyDomainService.ifCompanyInJT(null, code)) +// .toList(); +// +// for (String inJtCompanyCode : inJtCompanyCodes) { +// JTCompany byCompanyCode = jtCompanyRepository.findByCompanyCode(inJtCompanyCode); +// user.addJTFssc(byCompanyCode.getCompanyName(), FSSC_LOAD_URL, postRequest); +// } +// +// if (companyCodes.contains(XN_COMPANY_CODE)) { +// user.addXNFssc(FSSC_LOAD_URL, postRequest); +// } } private User getDataFromUserSFData(User user, UserDataDTO userData) {