fix:结算明细修正入账公司名称

This commit is contained in:
lulz1 2024-04-18 13:23:51 +08:00
parent e3edec5888
commit ebf483e884
8 changed files with 184 additions and 4 deletions

View File

@ -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<OrderFlightRecord> handlerFlightRecordData(OrderRecordQueryDTO orderRecordQueryDTO){
PageResult<OrderFlightRecord> byRecordParam = orderFlightRecordRepository.findByRecordParam(orderRecordQueryDTO);
byRecordParam.getRecords().forEach(it-> systemDomainService
.companyNameByAccountId(it.getAccountCompanyId())
.ifPresentOrElse(it::setAccountCompanyName,()->it.setAccountCompanyName(it.getAccountCompanyName())));
return byRecordParam;
}
public PageResult<OrderHotelRecord> handlerHotelRecordData(OrderRecordQueryDTO orderRecordQueryDTO){
PageResult<OrderHotelRecord> byRecordParam = orderHotelRecordRepository.findByRecordParam(orderRecordQueryDTO);
byRecordParam.getRecords().forEach(it-> systemDomainService
.companyNameByAccountId(it.getAccountCompanyId())
.ifPresentOrElse(it::setAccountCompanyName,()->it.setAccountCompanyName(it.getAccountCompanyName())));
return byRecordParam;
}
public PageResult<OrderTrainRecord> handlerTrainRecordData(OrderRecordQueryDTO orderRecordQueryDTO){
PageResult<OrderTrainRecord> byRecordParam = orderTrainRecordRepository.findByRecordParam(orderRecordQueryDTO);
byRecordParam.getRecords().forEach(it-> systemDomainService
.companyNameByAccountId(it.getAccountCompanyId())
.ifPresentOrElse(it::setAccountCompanyName,()->it.setAccountCompanyName(it.getAccountCompanyName())));
return byRecordParam;
}
public PageResult<OrderCarRecord> handlerCarRecordData(OrderRecordQueryDTO orderRecordQueryDTO){
PageResult<OrderCarRecord> byRecordParam = orderCarRecordRepository.findByRecordParam(orderRecordQueryDTO);
byRecordParam.getRecords().forEach(it-> systemDomainService
.companyNameByAccountId(it.getAccountCompanyId())
.ifPresentOrElse(it::setAccountCompanyName,()->it.setAccountCompanyName(it.getAccountCompanyName())));
return byRecordParam;
}
public Result<PageResult<Object>> orderDetailInfoPageQuery(AuthenticationSignDto authenticationDto) {
Integer productType = authenticationDto.getProductType();

View File

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

View File

@ -0,0 +1,9 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.system.AccountCompany;
import java.util.List;
public interface AccountCompanyRepository {
List<AccountCompany> findAll();
}

View File

@ -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<String> companyNameByAccountId(String accountId) {
List<AccountCompany> all = accountCompanyRepository.findAll();
return all.stream()
.filter(it->it.getAccountId().equals(accountId))
.map(AccountCompany::getCompanyName)
.findFirst();
}
}

View File

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

View File

@ -0,0 +1,13 @@
package com.chint.infrastructure.export;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class OrderDetailExportFactory {
// public List<OrderDetailExport> createExportData(){
//
// }
}

View File

@ -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<AccountCompany> findAll() {
List<AccountCompany> res = new ArrayList<>();
jdbcAccountCompanyRepository.findAll().forEach(res::add);
return res;
}
}

View File

@ -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<AccountCompany,Long> {
}