From ebf483e88449961d80d0347f18e387324a68da0d Mon Sep 17 00:00:00 2001 From: lulz1 Date: Thu, 18 Apr 2024 13:23:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=BB=93=E7=AE=97=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=85=A5=E8=B4=A6=E5=85=AC=E5=8F=B8=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../queryies/OrderDetailQuery.java | 47 ++++++++++++++++-- .../aggregates/system/AccountCompany.java | 17 +++++++ .../repository/AccountCompanyRepository.java | 9 ++++ .../domain/service/SystemDomainService.java | 16 ++++++ .../export/OrderDetailExport.java | 49 +++++++++++++++++++ .../export/OrderDetailExportFactory.java | 13 +++++ .../AccountCompanyRepositoryImpl.java | 26 ++++++++++ .../jdbc/JdbcAccountCompanyRepository.java | 11 +++++ 8 files changed, 184 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/chint/domain/aggregates/system/AccountCompany.java create mode 100644 src/main/java/com/chint/domain/repository/AccountCompanyRepository.java create mode 100644 src/main/java/com/chint/infrastructure/export/OrderDetailExport.java create mode 100644 src/main/java/com/chint/infrastructure/export/OrderDetailExportFactory.java create mode 100644 src/main/java/com/chint/infrastructure/repository/AccountCompanyRepositoryImpl.java create mode 100644 src/main/java/com/chint/infrastructure/repository/jdbc/JdbcAccountCompanyRepository.java diff --git a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java index d5892990..987ba2d7 100644 --- a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java @@ -7,9 +7,14 @@ import com.chint.application.dtos.OrderRecordQueryDTO; import com.chint.application.dtos.mapper.OrderDetailMapper; import com.chint.application.dtos.response.OrderDetailRes; import com.chint.domain.aggregates.order.*; +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.aggregates.user.User; import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.repository.*; +import com.chint.domain.service.SystemDomainService; import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.PageResult; import com.chint.infrastructure.util.Result; @@ -41,6 +46,9 @@ public class OrderDetailQuery { @Autowired private RouteRepository routeRepository; + @Autowired + private SystemDomainService systemDomainService; + @Autowired private OrderCarRecordRepository orderCarRecordRepository; @Autowired @@ -55,14 +63,45 @@ public class OrderDetailQuery { Integer productType = orderRecordQueryDTO.getProductType(); //只获取账期号为上个月的结算数据 return switch (productType) { - case 1 -> orderFlightRecordRepository.findByRecordParam(orderRecordQueryDTO); - case 2 -> orderHotelRecordRepository.findByRecordParam(orderRecordQueryDTO); - case 3 -> orderTrainRecordRepository.findByRecordParam(orderRecordQueryDTO); - case 4 -> orderCarRecordRepository.findByRecordParam(orderRecordQueryDTO); + case 1 -> handlerFlightRecordData(orderRecordQueryDTO); + case 2 -> handlerHotelRecordData(orderRecordQueryDTO); + case 3 -> handlerTrainRecordData(orderRecordQueryDTO); + case 4 -> handlerCarRecordData(orderRecordQueryDTO); default -> throw new NotFoundException("错误产品类型"); }; } + public PageResult handlerFlightRecordData(OrderRecordQueryDTO orderRecordQueryDTO){ + PageResult byRecordParam = orderFlightRecordRepository.findByRecordParam(orderRecordQueryDTO); + byRecordParam.getRecords().forEach(it-> systemDomainService + .companyNameByAccountId(it.getAccountCompanyId()) + .ifPresentOrElse(it::setAccountCompanyName,()->it.setAccountCompanyName(it.getAccountCompanyName()))); + return byRecordParam; + } + + public PageResult handlerHotelRecordData(OrderRecordQueryDTO orderRecordQueryDTO){ + PageResult byRecordParam = orderHotelRecordRepository.findByRecordParam(orderRecordQueryDTO); + byRecordParam.getRecords().forEach(it-> systemDomainService + .companyNameByAccountId(it.getAccountCompanyId()) + .ifPresentOrElse(it::setAccountCompanyName,()->it.setAccountCompanyName(it.getAccountCompanyName()))); + return byRecordParam; + } + + public PageResult handlerTrainRecordData(OrderRecordQueryDTO orderRecordQueryDTO){ + PageResult byRecordParam = orderTrainRecordRepository.findByRecordParam(orderRecordQueryDTO); + byRecordParam.getRecords().forEach(it-> systemDomainService + .companyNameByAccountId(it.getAccountCompanyId()) + .ifPresentOrElse(it::setAccountCompanyName,()->it.setAccountCompanyName(it.getAccountCompanyName()))); + return byRecordParam; + } + + public PageResult handlerCarRecordData(OrderRecordQueryDTO orderRecordQueryDTO){ + PageResult byRecordParam = orderCarRecordRepository.findByRecordParam(orderRecordQueryDTO); + byRecordParam.getRecords().forEach(it-> systemDomainService + .companyNameByAccountId(it.getAccountCompanyId()) + .ifPresentOrElse(it::setAccountCompanyName,()->it.setAccountCompanyName(it.getAccountCompanyName()))); + return byRecordParam; + } public Result> orderDetailInfoPageQuery(AuthenticationSignDto authenticationDto) { Integer productType = authenticationDto.getProductType(); diff --git a/src/main/java/com/chint/domain/aggregates/system/AccountCompany.java b/src/main/java/com/chint/domain/aggregates/system/AccountCompany.java new file mode 100644 index 00000000..d1a2f0cc --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/system/AccountCompany.java @@ -0,0 +1,17 @@ +package com.chint.domain.aggregates.system; + +import lombok.Data; +import org.springframework.data.relational.core.mapping.Table; + +import java.io.Serial; +import java.io.Serializable; + +@Data +@Table("system_account_company") +public class AccountCompany implements Serializable { + @Serial + private static final long serialVersionUID = 1256889067306431230L; + private Long id ; + private String accountId; + private String companyName; +} diff --git a/src/main/java/com/chint/domain/repository/AccountCompanyRepository.java b/src/main/java/com/chint/domain/repository/AccountCompanyRepository.java new file mode 100644 index 00000000..277ed10f --- /dev/null +++ b/src/main/java/com/chint/domain/repository/AccountCompanyRepository.java @@ -0,0 +1,9 @@ +package com.chint.domain.repository; + +import com.chint.domain.aggregates.system.AccountCompany; + +import java.util.List; + +public interface AccountCompanyRepository { + List findAll(); +} diff --git a/src/main/java/com/chint/domain/service/SystemDomainService.java b/src/main/java/com/chint/domain/service/SystemDomainService.java index dd355072..b4b5ef2b 100644 --- a/src/main/java/com/chint/domain/service/SystemDomainService.java +++ b/src/main/java/com/chint/domain/service/SystemDomainService.java @@ -1,11 +1,16 @@ package com.chint.domain.service; +import com.chint.domain.aggregates.system.AccountCompany; import com.chint.domain.aggregates.system.SystemCode; import com.chint.domain.exceptions.NotFoundException; +import com.chint.domain.repository.AccountCompanyRepository; import com.chint.domain.repository.SystemCodeRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Optional; + import static com.chint.infrastructure.constant.DataMessageConstant.SYS_CODE_ERROR; @Service @@ -14,6 +19,9 @@ public class SystemDomainService { @Autowired private SystemCodeRepository systemCodeRepository; + @Autowired + private AccountCompanyRepository accountCompanyRepository; + public boolean checkSystemCode(String sysCode) { boolean b = systemCodeRepository.findBySysCode(sysCode) != null; if (!b) { @@ -30,4 +38,12 @@ public class SystemDomainService { } return bySysCode.getIfImmediateResponse() == 1; } + + public Optional companyNameByAccountId(String accountId) { + List all = accountCompanyRepository.findAll(); + return all.stream() + .filter(it->it.getAccountId().equals(accountId)) + .map(AccountCompany::getCompanyName) + .findFirst(); + } } diff --git a/src/main/java/com/chint/infrastructure/export/OrderDetailExport.java b/src/main/java/com/chint/infrastructure/export/OrderDetailExport.java new file mode 100644 index 00000000..4cb611bd --- /dev/null +++ b/src/main/java/com/chint/infrastructure/export/OrderDetailExport.java @@ -0,0 +1,49 @@ +package com.chint.infrastructure.export; + + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.HeadFontStyle; +import com.alibaba.excel.annotation.write.style.HeadStyle; +import com.alibaba.excel.enums.poi.FillPatternTypeEnum; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@HeadStyle(fillPatternType = FillPatternTypeEnum.NO_FILL) // 设置表头背景为无色 +@HeadFontStyle(fontHeightInPoints = 10) +@ColumnWidth(16) +public class OrderDetailExport { + @ExcelProperty("公司ID") + private String companyId; + @ExcelProperty("公司名称") + private String companyName; + @ExcelProperty("预订人ID") + private String employeeNo; + @ExcelProperty("预订人姓名") + private String employeeName; + @ExcelProperty("预订人部门") + private String employeeDepartment; + @ExcelProperty("订单号") + private String orderNo; + @ExcelProperty("来源(携程或者同程)") + private String supplierName; + @ExcelProperty("订单状态") + private String orderStatus; + @ExcelProperty("产品类型") + private String productType; + @ExcelProperty("预订日期") + private String orderDate; + @ExcelProperty("预订时间") + private String orderTime; + @ExcelProperty("订单金额") + private String orderAmount; + @ExcelProperty("对应所属系统") + private String systemCode; + @ExcelProperty("核算企业名称") + private String accountCompanyName; + @ExcelProperty("项目订单号") + private String projectCode; +} diff --git a/src/main/java/com/chint/infrastructure/export/OrderDetailExportFactory.java b/src/main/java/com/chint/infrastructure/export/OrderDetailExportFactory.java new file mode 100644 index 00000000..5f354fab --- /dev/null +++ b/src/main/java/com/chint/infrastructure/export/OrderDetailExportFactory.java @@ -0,0 +1,13 @@ +package com.chint.infrastructure.export; + +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class OrderDetailExportFactory { + +// public List createExportData(){ +// +// } +} diff --git a/src/main/java/com/chint/infrastructure/repository/AccountCompanyRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/AccountCompanyRepositoryImpl.java new file mode 100644 index 00000000..bc2c6a54 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/AccountCompanyRepositoryImpl.java @@ -0,0 +1,26 @@ +package com.chint.infrastructure.repository; + +import com.chint.domain.aggregates.system.AccountCompany; +import com.chint.domain.repository.AccountCompanyRepository; +import com.chint.infrastructure.repository.jdbc.JdbcAccountCompanyRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Repository; + +import java.util.ArrayList; +import java.util.List; + +@Repository +public class AccountCompanyRepositoryImpl implements AccountCompanyRepository { + + @Autowired + private JdbcAccountCompanyRepository jdbcAccountCompanyRepository; + + @Cacheable(value = "AccountCompanyAll") + @Override + public List findAll() { + List res = new ArrayList<>(); + jdbcAccountCompanyRepository.findAll().forEach(res::add); + return res; + } +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcAccountCompanyRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcAccountCompanyRepository.java new file mode 100644 index 00000000..4d86f788 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcAccountCompanyRepository.java @@ -0,0 +1,11 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.location.CityEntity; +import com.chint.domain.aggregates.system.AccountCompany; +import com.chint.domain.repository.AccountCompanyRepository; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface JdbcAccountCompanyRepository extends CrudRepository { +}