feat:新增分账员可配置接口,结算数据按照已配置的分账员进行返回
This commit is contained in:
parent
606d9a91c5
commit
7f8e2bc283
|
@ -0,0 +1,9 @@
|
|||
package com.chint.application.dtos;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrganizationTicketClerk {
|
||||
private String orgCode;
|
||||
private String clerkName;
|
||||
}
|
|
@ -12,9 +12,8 @@ import com.chint.infrastructure.util.PageResult;
|
|||
import com.chint.infrastructure.util.Result;
|
||||
import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave;
|
||||
import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo;
|
||||
import com.chint.interfaces.rest.user.BatchUserWorker;
|
||||
import com.chint.interfaces.rest.data_center.user.BatchUserWorker;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.chint.application.out;
|
|||
|
||||
import com.chint.application.commands.OrderCreateCommand;
|
||||
import com.chint.application.commands.UserLoginCommand;
|
||||
import com.chint.application.commands.UserSFCommand;
|
||||
import com.chint.application.services.login.strategy.ANFeiShuLoginStrategy;
|
||||
import com.chint.application.services.login.strategy.FeishuLoginStrategy;
|
||||
import com.chint.application.services.login.strategy.PailaLoginStrategy;
|
||||
|
@ -24,7 +23,7 @@ import com.chint.infrastructure.util.Digest;
|
|||
import com.chint.infrastructure.util.Result;
|
||||
import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest;
|
||||
import com.chint.interfaces.rest.ly.LYUserRequest;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -32,7 +31,6 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
|
|
@ -7,8 +7,8 @@ import com.chint.domain.aggregates.user.UserDepartmentInfo;
|
|||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
import com.chint.interfaces.rest.user.BatchUserWorker;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.BatchUserWorker;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
|
@ -126,35 +126,47 @@ public class OrderDetailQuery {
|
|||
|
||||
|
||||
public List<OrderFlightRecord> handlerFlightRecordData(List<OrderFlightRecord> orderFlightRecordList) {
|
||||
orderFlightRecordList.forEach(it -> systemDomainService
|
||||
.companyNameByAccountId(it.getAccountCompanyId())
|
||||
.ifPresentOrElse(it::setAccountCompanyName, () -> it.setAccountCompanyName(it.getAccountCompanyName())));
|
||||
orderFlightRecordList.forEach(it -> it.setReceiptsNum(QueryUtil.reGetReceiptsNum(it.getReceiptsNum())));
|
||||
orderFlightRecordList.forEach(record -> {
|
||||
systemDomainService
|
||||
.companyNameByAccountId(record.getAccountCompanyId())
|
||||
.ifPresentOrElse(record::setAccountCompanyName, () -> record.setAccountCompanyName(record.getAccountCompanyName()));
|
||||
record.setReceiptsNum(QueryUtil.reGetReceiptsNum(record.getReceiptsNum()));
|
||||
});
|
||||
systemDomainService.generateRecordClerk(orderFlightRecordList);
|
||||
return orderFlightRecordList;
|
||||
}
|
||||
|
||||
|
||||
public List<OrderHotelRecord> handlerHotelRecordData(List<OrderHotelRecord> orderHotelRecordList) {
|
||||
orderHotelRecordList.forEach(it -> systemDomainService
|
||||
.companyNameByAccountId(it.getAccountCompanyId())
|
||||
.ifPresentOrElse(it::setAccountCompanyName, () -> it.setAccountCompanyName(it.getAccountCompanyName())));
|
||||
orderHotelRecordList.forEach(it -> it.setReceiptsNum(QueryUtil.reGetReceiptsNum(it.getReceiptsNum())));
|
||||
orderHotelRecordList.forEach(record -> {
|
||||
systemDomainService
|
||||
.companyNameByAccountId(record.getAccountCompanyId())
|
||||
.ifPresentOrElse(record::setAccountCompanyName, () -> record.setAccountCompanyName(record.getAccountCompanyName()));
|
||||
record.setReceiptsNum(QueryUtil.reGetReceiptsNum(record.getReceiptsNum()));
|
||||
});
|
||||
systemDomainService.generateRecordClerk(orderHotelRecordList);
|
||||
return orderHotelRecordList;
|
||||
}
|
||||
|
||||
public List<OrderTrainRecord> handlerTrainRecordData(List<OrderTrainRecord> orderTrainRecordList) {
|
||||
orderTrainRecordList.forEach(it -> systemDomainService
|
||||
.companyNameByAccountId(it.getAccountCompanyId())
|
||||
.ifPresentOrElse(it::setAccountCompanyName, () -> it.setAccountCompanyName(it.getAccountCompanyName())));
|
||||
orderTrainRecordList.forEach(it -> it.setReceiptsNum(QueryUtil.reGetReceiptsNum(it.getReceiptsNum())));
|
||||
orderTrainRecordList.forEach(record -> {
|
||||
systemDomainService
|
||||
.companyNameByAccountId(record.getAccountCompanyId())
|
||||
.ifPresentOrElse(record::setAccountCompanyName, () -> record.setAccountCompanyName(record.getAccountCompanyName()));
|
||||
record.setReceiptsNum(QueryUtil.reGetReceiptsNum(record.getReceiptsNum()));
|
||||
});
|
||||
systemDomainService.generateRecordClerk(orderTrainRecordList);
|
||||
return orderTrainRecordList;
|
||||
}
|
||||
|
||||
public List<OrderCarRecord> handlerCarRecordData(List<OrderCarRecord> orderCarRecordList) {
|
||||
orderCarRecordList.forEach(it -> systemDomainService
|
||||
.companyNameByAccountId(it.getAccountCompanyId())
|
||||
.ifPresentOrElse(it::setAccountCompanyName, () -> it.setAccountCompanyName(it.getAccountCompanyName())));
|
||||
orderCarRecordList.forEach(it -> it.setReceiptsNum(QueryUtil.reGetReceiptsNum(it.getReceiptsNum())));
|
||||
orderCarRecordList.forEach(record -> {
|
||||
systemDomainService
|
||||
.companyNameByAccountId(record.getAccountCompanyId())
|
||||
.ifPresentOrElse(record::setAccountCompanyName, () -> record.setAccountCompanyName(record.getAccountCompanyName()));
|
||||
record.setReceiptsNum(QueryUtil.reGetReceiptsNum(record.getReceiptsNum()));
|
||||
});
|
||||
systemDomainService.generateRecordClerk(orderCarRecordList);
|
||||
return orderCarRecordList;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import com.chint.infrastructure.util.BaseContext;
|
|||
import com.chint.infrastructure.util.DateTimeUtil;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import com.chint.infrastructure.util.StringCheck;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.chint.interfaces.rest.ctrip.dto.estimate.response.BookingRelatedApiRe
|
|||
import com.chint.interfaces.rest.ctrip.dto.estimate.response.CTripSeatType;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.response.HotelValuationResult;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.response.TrainValuationResult;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -3,11 +3,10 @@ package com.chint.application.services.login.strategy;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.chint.application.dtos.UserDTO;
|
||||
import com.chint.application.services.login.LoginStrategy;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.exceptions.SSOLoginException;
|
||||
import com.chint.domain.factoriy.user.UserFactory;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.chint.application.services.login.LoginStrategy;
|
|||
import com.chint.domain.exceptions.SSOLoginException;
|
||||
import com.chint.domain.factoriy.user.UserFactory;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package com.chint.application.system;
|
||||
|
||||
import com.chint.application.dtos.OrganizationTicketClerk;
|
||||
import com.chint.application.dtos.SystemAnnouncementDTO;
|
||||
import com.chint.application.dtos.SystemAnnouncementVO;
|
||||
import com.chint.domain.aggregates.system.SystemAnnouncement;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.repository.SystemAnnouncementRepository;
|
||||
import com.chint.domain.service.SystemDomainService;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
import com.chint.interfaces.rest.data_center.org.OrgRequest;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -17,6 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import java.time.LocalDateTime;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
|
||||
|
@ -29,6 +33,12 @@ public class SystemController {
|
|||
@Autowired
|
||||
private SystemAnnouncementRepository systemAnnouncementRepository;
|
||||
|
||||
@Autowired
|
||||
private SystemDomainService systemDomainService;
|
||||
|
||||
@Autowired
|
||||
private OrgRequest orgRequest;
|
||||
|
||||
@ApiOperation("新增公告")
|
||||
@PostMapping("/announcement/save")
|
||||
public Result<SystemAnnouncement> save(@RequestBody SystemAnnouncementDTO systemAnnouncementDTO) {
|
||||
|
@ -92,4 +102,19 @@ public class SystemController {
|
|||
.toList();
|
||||
return Result.Success(SUCCESS, systemAnnouncements);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("添加票务员")
|
||||
@PostMapping("/organization/add/clerk")
|
||||
public Result<String> addOrganizationClerk(@RequestBody OrganizationTicketClerk organizationTicketClerk) {
|
||||
systemDomainService.addOrganizationClerk(organizationTicketClerk);
|
||||
return Result.Success(SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation("同步所有的组织")
|
||||
@PostMapping("/organization/sync/all")
|
||||
public Result<String> organizationSyncAll() {
|
||||
CompletableFuture.runAsync(() -> orgRequest.syncAllOrgAndGenerateParentId());
|
||||
return Result.Success(SUCCESS, "开始执行中");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,4 +8,6 @@ import java.time.LocalDateTime;
|
|||
public class OrderBaseRecord {
|
||||
private LocalDateTime createDataTime;
|
||||
private LocalDateTime updateDataTime;
|
||||
private String ticketClerk; // 票务员
|
||||
private String belongDepart;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class OrderCarRecord extends OrderBaseRecord {
|
|||
private String detailId; // 结算明细唯一标识
|
||||
private String accountCompanyId; // 核算企业code
|
||||
private String accountCompanyName; // 核算企业名称
|
||||
private String ticketClerk; // 票务员
|
||||
// private String ticketClerk; // 票务员
|
||||
private String accountPeriod; // 账期号
|
||||
private String billNo; // 账单号
|
||||
private String receiptsNum; // 关联申请单号
|
||||
|
@ -65,7 +65,7 @@ public class OrderCarRecord extends OrderBaseRecord {
|
|||
private String orderSource; // 预订来源:线上/线下
|
||||
private String payAmount;//支付总金额
|
||||
private String receiptsNumOrigin;//支付总金额
|
||||
private String belongDepart; //归属部门
|
||||
// private String belongDepart; //归属部门
|
||||
private String settleOrderFlag;
|
||||
|
||||
public OrderCarRecord loadBelongDeport(String belongDeport
|
||||
|
|
|
@ -22,7 +22,7 @@ public class OrderFlightRecord extends OrderBaseRecord {
|
|||
private String detailId; // 结算明细唯一标识
|
||||
private String accountCompanyId; // 核算企业code
|
||||
private String accountCompanyName; // 核算企业名称
|
||||
private String ticketClerk; // 票务员
|
||||
// private String ticketClerk; // 票务员
|
||||
private String accountPeriod; // 账期号
|
||||
private String billNo; // 账单号(结算单号)
|
||||
private String orderNo; // 订单号
|
||||
|
@ -80,7 +80,7 @@ public class OrderFlightRecord extends OrderBaseRecord {
|
|||
private String createTime;
|
||||
private String receiptsNumOrigin;//原差旅申请单单号
|
||||
private String payAmount;
|
||||
private String belongDepart; //归属部门
|
||||
// private String belongDepart; //归属部门
|
||||
private String settleOrderFlag;
|
||||
public OrderFlightRecord loadBelongDeport(String belongDeport
|
||||
) {
|
||||
|
|
|
@ -24,7 +24,7 @@ public class OrderHotelRecord extends OrderBaseRecord {
|
|||
private String detailId; // 结算明细唯一标识
|
||||
private String accountCompanyId; // 核算企业code
|
||||
private String accountCompanyName; // 核算企业名称
|
||||
private String ticketClerk; // 票务员
|
||||
// private String ticketClerk; // 票务员
|
||||
private String accountPeriod; // 账期号
|
||||
private String billNo; // 账单号(结算单号)
|
||||
private String orderNo; // 订单号
|
||||
|
@ -79,7 +79,7 @@ public class OrderHotelRecord extends OrderBaseRecord {
|
|||
private String orderStatus;
|
||||
private String createTime;
|
||||
private String receiptsNumOrigin;//支付总金额
|
||||
private String belongDepart; //归属部门
|
||||
// private String belongDepart; //归属部门
|
||||
private String settleOrderFlag;
|
||||
|
||||
public OrderHotelRecord loadBelongDeport(String belongDeport
|
||||
|
|
|
@ -21,7 +21,7 @@ public class OrderTrainRecord extends OrderBaseRecord{
|
|||
private String detailId; // 结算明细唯一标识
|
||||
private String accountCompanyId; // 核算企业code
|
||||
private String accountCompanyName; // 核算企业名称
|
||||
private String ticketClerk; // 票务员
|
||||
// private String ticketClerk; // 票务员
|
||||
private String accountPeriod; // 账期号
|
||||
private String billNo; // 账单号
|
||||
private String orderNo; // 订单号
|
||||
|
@ -74,7 +74,7 @@ public class OrderTrainRecord extends OrderBaseRecord{
|
|||
private String yxId; // 影像比对ID
|
||||
private String orderStatus;//订单状态
|
||||
private String receiptsNumOrigin;//原差旅申请单单号
|
||||
private String belongDepart; //归属部门
|
||||
// private String belongDepart; //归属部门
|
||||
private String settleOrderFlag;
|
||||
|
||||
public OrderTrainRecord loadBelongDeport(String belongDeport
|
||||
|
|
|
@ -14,7 +14,6 @@ public class SystemAnnouncementEmployee implements Serializable {
|
|||
private static final long serialVersionUID = 1926351891678893214L;
|
||||
private Long id;
|
||||
private Long announcementId;
|
||||
private Integer announcementKey;
|
||||
private String employeeNo;
|
||||
private String extension;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package com.chint.domain.aggregates.system;
|
||||
|
||||
|
||||
import com.chint.interfaces.rest.data_center.org.OrgSfResponse;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Table("system_organization")
|
||||
public class SystemOrganization implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 2301161883096613214L;
|
||||
@Id
|
||||
private Long id;
|
||||
private String orgCode;
|
||||
private String orgShortCode;
|
||||
private String orgName;
|
||||
private String orgEnName;
|
||||
private Long parentId;
|
||||
private String parentOrgCode;
|
||||
private String parentOrgName;
|
||||
private String parentOrgEnName;
|
||||
private String ChargePersonCode;
|
||||
private String ChargePersonLongCode;
|
||||
private String ChargePersonName;
|
||||
private String status;
|
||||
private String costCenter;
|
||||
private String orgLevel;
|
||||
private String lastModifiedDateTime;
|
||||
@MappedCollection(idColumn = "system_organization_id", keyColumn = "system_organization_key")
|
||||
private List<SystemOrganizationExtension> systemOrganizationExtensionList;
|
||||
@Transient
|
||||
private List<SystemOrganization> childOrganizationList;
|
||||
|
||||
|
||||
public static SystemOrganization of(OrgSfResponse.OrgData data) {
|
||||
SystemOrganization systemOrganization = new SystemOrganization();
|
||||
systemOrganization.setOrgCode(data.getExternalCode());
|
||||
systemOrganization.setOrgName(data.getName());
|
||||
systemOrganization.setOrgEnName(data.getName_en_US());
|
||||
systemOrganization.setParentId(null);
|
||||
systemOrganization.setParentOrgCode(data.getCust_parent());
|
||||
systemOrganization.setParentOrgName(data.getCust_parent_cn());
|
||||
systemOrganization.setParentOrgEnName(null);
|
||||
systemOrganization.setChargePersonCode(data.getHeadOfUnit());
|
||||
systemOrganization.setChargePersonLongCode(data.getSFUsername());
|
||||
systemOrganization.setChargePersonName(data.getHeadOfUnitName());
|
||||
systemOrganization.setStatus(data.getStatus());
|
||||
systemOrganization.setOrgLevel(data.getLev());
|
||||
systemOrganization.setLastModifiedDateTime(data.getLastModifiedDateTime());
|
||||
systemOrganization.setCostCenter(data.getCust_costCenter());
|
||||
return systemOrganization;
|
||||
}
|
||||
|
||||
public SystemOrganization addExtensionField(String fieldName, String fieldValue, String extension) {
|
||||
if (this.systemOrganizationExtensionList == null) {
|
||||
this.systemOrganizationExtensionList = new ArrayList<>();
|
||||
}
|
||||
// Search for an existing extension with the same field name
|
||||
this.systemOrganizationExtensionList.stream()
|
||||
.filter(e -> e.getFieldName().equals(fieldName))
|
||||
.findFirst()
|
||||
.ifPresentOrElse(it -> {
|
||||
it.setFieldValue(fieldValue);
|
||||
it.setExtension(extension);
|
||||
}, () -> {
|
||||
// Otherwise, add a new extension
|
||||
SystemOrganizationExtension newExtension = new SystemOrganizationExtension();
|
||||
newExtension.setFieldName(fieldName);
|
||||
newExtension.setFieldValue(fieldValue);
|
||||
newExtension.setExtension(extension);
|
||||
this.systemOrganizationExtensionList.add(newExtension);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.chint.domain.aggregates.system;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Table("system_organization_extension")
|
||||
public class SystemOrganizationExtension implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 908735916325783214L;
|
||||
@Id
|
||||
private Long id;
|
||||
private Long systemOrganizationId;
|
||||
private Long systemOrganizationKey;
|
||||
private String fieldName;
|
||||
private String fieldValue;
|
||||
private String extension;
|
||||
}
|
|
@ -13,7 +13,7 @@ import com.chint.infrastructure.echo_framework.command.Command;
|
|||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.infrastructure.util.StringCheck;
|
||||
import com.chint.interfaces.rest.base.PostRequest;
|
||||
import com.chint.interfaces.rest.user.dto.UserDataDTO;
|
||||
import com.chint.interfaces.rest.data_center.user.dto.UserDataDTO;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderRespon
|
|||
import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse;
|
||||
import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse;
|
||||
import com.chint.interfaces.rest.ly.tools.LYOrderUtil;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import com.chint.domain.service.RouteRequestDomainService;
|
|||
import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository;
|
||||
import com.chint.infrastructure.util.DateTimeUtil;
|
||||
import com.chint.infrastructure.util.OrderNo;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@ import com.chint.domain.aggregates.user.UserDepartmentInfo;
|
|||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.*;
|
||||
import com.chint.infrastructure.util.BeanCopyUtils;
|
||||
import com.chint.interfaces.rest.bpm.dto.BPMResponse;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -29,7 +28,6 @@ import java.util.function.Consumer;
|
|||
|
||||
import static com.chint.infrastructure.constant.BelongSystemConstant.*;
|
||||
import static com.chint.infrastructure.constant.OrderRecordConstant.*;
|
||||
import static com.chint.infrastructure.constant.RankConstant.OUT_OF_STANDARD;
|
||||
|
||||
/**
|
||||
* 同程数据转换
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.chint.domain.repository;
|
||||
|
||||
|
||||
import com.chint.domain.aggregates.system.SystemOrganization;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface SystemOrganizationRepository {
|
||||
void saveAll(List<SystemOrganization> systemOrganizationList);
|
||||
|
||||
SystemOrganization save(SystemOrganization systemOrganization);
|
||||
|
||||
List<SystemOrganization> findAll();
|
||||
|
||||
Optional<SystemOrganization> findByOrgCodeContaining(String orgCode);
|
||||
|
||||
List<SystemOrganization> findByOrgCodeList(List<String> orgCode);
|
||||
|
||||
List<SystemOrganization> findByParentId(Long parentId);
|
||||
}
|
|
@ -6,9 +6,6 @@ import com.chint.domain.aggregates.order.OrderDetail;
|
|||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.domain.aggregates.system.ProcessInitiationControl;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.factoriy.leg_event.LegEventFactory;
|
||||
import com.chint.domain.factoriy.order.RouteOrderFactory;
|
||||
import com.chint.domain.factoriy.order_detail.OrderDetailFactory;
|
||||
import com.chint.domain.repository.*;
|
||||
import com.chint.infrastructure.constant.CommonMessageConstant;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcLegRepository;
|
||||
|
@ -28,7 +25,6 @@ import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightOrderInfoEntity;
|
|||
import com.chint.interfaces.rest.ly.LYSearchRequest;
|
||||
import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderResponse;
|
||||
import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -38,7 +34,6 @@ import java.math.BigDecimal;
|
|||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.chint.infrastructure.constant.BPMConstant.*;
|
||||
import static com.chint.infrastructure.constant.BPMConstant.REFUND_TYPE_FLIGHT;
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.chint.domain.service;
|
|||
|
||||
|
||||
import com.chint.domain.aggregates.system.JTCompany;
|
||||
import com.chint.domain.exceptions.AuthException;
|
||||
import com.chint.domain.repository.JTCompanyRepository;
|
||||
import com.chint.domain.repository.SystemCodeRepository;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
|
@ -47,10 +46,6 @@ public class JTCompanyDomainService {
|
|||
return false;
|
||||
}
|
||||
|
||||
// public JTCompany findByCompanyNameOrCompanyCode(String companyName, String companyCode){
|
||||
//
|
||||
// }
|
||||
|
||||
public boolean ifCompanyInJT(String companyName, String companyCode, Long systemCodeId) {
|
||||
List<JTCompany> all = jtCompanyRepository.findAll();
|
||||
if (companyName != null) {
|
||||
|
@ -70,10 +65,12 @@ public class JTCompanyDomainService {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String findSystemCodeByCompanyCode(String companyCode) {
|
||||
JTCompany byCompanyCode = jtCompanyRepository.findByCompanyCode(companyCode);
|
||||
if (byCompanyCode == null) {
|
||||
throw new AuthException("用户所在公司不在实施范围内");
|
||||
return null;
|
||||
}
|
||||
return systemCodeRepository.findById(byCompanyCode.getSystemCodeId()).getSystemCode();
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse;
|
|||
import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderResponse;
|
||||
import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse;
|
||||
import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
package com.chint.domain.service;
|
||||
|
||||
import com.chint.application.dtos.OrganizationTicketClerk;
|
||||
import com.chint.domain.aggregates.order.order_record.OrderBaseRecord;
|
||||
import com.chint.domain.aggregates.system.AccountCompany;
|
||||
import com.chint.domain.aggregates.system.SystemCode;
|
||||
import com.chint.domain.aggregates.system.SystemOrganization;
|
||||
import com.chint.domain.aggregates.system.SystemOrganizationExtension;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.repository.AccountCompanyRepository;
|
||||
import com.chint.domain.repository.SystemCodeRepository;
|
||||
import com.chint.domain.repository.SystemOrganizationRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.chint.infrastructure.constant.DataMessageConstant.SYS_CODE_ERROR;
|
||||
import static com.chint.infrastructure.constant.SystemConstant.ORG_CLERK_FIELD_NAME;
|
||||
|
||||
@Service
|
||||
public class SystemDomainService {
|
||||
|
@ -22,6 +29,9 @@ public class SystemDomainService {
|
|||
@Autowired
|
||||
private AccountCompanyRepository accountCompanyRepository;
|
||||
|
||||
@Autowired
|
||||
private SystemOrganizationRepository systemOrganizationRepository;
|
||||
|
||||
public boolean checkSystemCode(String sysCode) {
|
||||
boolean b = systemCodeRepository.findBySysCode(sysCode) != null;
|
||||
if (!b) {
|
||||
|
@ -47,4 +57,66 @@ public class SystemDomainService {
|
|||
.findFirst();
|
||||
}
|
||||
|
||||
|
||||
public void addOrganizationClerk(OrganizationTicketClerk organizationTicketClerk) {
|
||||
systemOrganizationRepository
|
||||
.findByOrgCodeContaining(organizationTicketClerk.getOrgCode())
|
||||
.ifPresent(it -> loadClerk(queryChild(it), organizationTicketClerk.getClerkName()));
|
||||
}
|
||||
|
||||
public void loadClerk(SystemOrganization systemOrganization, String clerk) {
|
||||
systemOrganization.addExtensionField(ORG_CLERK_FIELD_NAME, clerk, null);
|
||||
systemOrganizationRepository.save(systemOrganization);
|
||||
List<SystemOrganization> childOrganizationList = systemOrganization.getChildOrganizationList();
|
||||
if (childOrganizationList != null && !childOrganizationList.isEmpty()) {
|
||||
for (SystemOrganization organization : childOrganizationList) {
|
||||
loadClerk(organization, clerk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SystemOrganization queryChild(SystemOrganization systemOrganization) {
|
||||
List<SystemOrganization> byParentId = systemOrganizationRepository.findByParentId(systemOrganization.getId());
|
||||
if (byParentId.isEmpty()) {
|
||||
return systemOrganization;
|
||||
} else {
|
||||
systemOrganization.setChildOrganizationList(byParentId);
|
||||
for (SystemOrganization organization : byParentId) {
|
||||
queryChild(organization);
|
||||
}
|
||||
return systemOrganization;
|
||||
}
|
||||
}
|
||||
|
||||
public String queryClerkByOrgCodeContaining(String orgCode) {
|
||||
return systemOrganizationRepository.findByOrgCodeContaining(orgCode)
|
||||
.flatMap(it -> it.getSystemOrganizationExtensionList()
|
||||
.stream()
|
||||
.filter(field -> field.getFieldName().equals(ORG_CLERK_FIELD_NAME))
|
||||
.map(SystemOrganizationExtension::getFieldValue)
|
||||
.findFirst())
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public List<? extends OrderBaseRecord> generateRecordClerk(List<? extends OrderBaseRecord> recordList) {
|
||||
List<String> orgCodeList = recordList.stream()
|
||||
.map(OrderBaseRecord::getBelongDepart)
|
||||
.distinct()
|
||||
.filter(Objects::nonNull).toList();
|
||||
List<SystemOrganization> organizationList =
|
||||
systemOrganizationRepository.findByOrgCodeList(orgCodeList);
|
||||
recordList.forEach(record -> organizationList
|
||||
.stream()
|
||||
.filter(org -> org.getOrgShortCode().equals(record.getBelongDepart()))
|
||||
.findFirst()
|
||||
.ifPresent(org -> record.setTicketClerk(
|
||||
org.getSystemOrganizationExtensionList()
|
||||
.stream()
|
||||
.filter(field -> field.getFieldName().equals(ORG_CLERK_FIELD_NAME))
|
||||
.findFirst()
|
||||
.flatMap(field -> Optional.ofNullable(field.getFieldValue()))
|
||||
.orElse(null)
|
||||
)));
|
||||
return recordList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.chint.domain.service.auth;
|
||||
|
||||
import com.chint.application.dtos.AuthenticationDto;
|
||||
import com.chint.application.dtos.OrderSearchResult;
|
||||
import com.chint.domain.aggregates.order.Client;
|
||||
import com.chint.domain.aggregates.system.FsscSystem;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
|
@ -16,7 +15,7 @@ import com.chint.infrastructure.util.BaseContext;
|
|||
import com.chint.infrastructure.util.JWTUtil;
|
||||
import com.chint.infrastructure.util.Json;
|
||||
import com.chint.infrastructure.util.Token;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
|
@ -17,7 +17,7 @@ import com.chint.interfaces.rest.ctrip.dto.approval.hotel.HotelEndorsementDetail
|
|||
import com.chint.interfaces.rest.ctrip.dto.approval.quick.CarQuickEndorsementDetail;
|
||||
import com.chint.interfaces.rest.ctrip.dto.approval.quick.RankInfo;
|
||||
import com.chint.interfaces.rest.ctrip.dto.approval.train.TrainEndorsementDetail;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
|
@ -100,7 +100,6 @@ public class RouteCacheService {
|
|||
Long routeId = routeCacheManage.cacheFakeOrderNoAndSysCodeMapRouteId(fakeOrderNo, sysCode, null);
|
||||
if (routeId == null) {
|
||||
routeCacheManage.invalidateFakeOrderNoAndSysCodeMapRouteId(fakeOrderNo, sysCode);
|
||||
return null;
|
||||
}
|
||||
RouteOrder routeOrder = jdbcRouteRepository.findByApproveOrderNo_FakeOrderNoAndApproveOrderNo_SysCode(fakeOrderNo, sysCode);
|
||||
if (routeOrder == null) {
|
||||
|
@ -109,7 +108,7 @@ public class RouteCacheService {
|
|||
} else {
|
||||
routeOrder.reloadStatus();
|
||||
routeCacheManage.cacheFakeOrderNoAndSysCodeMapRouteId(fakeOrderNo, sysCode, routeOrder);
|
||||
return getFromCacheOrSaveToCache(routeId);
|
||||
return getFromCacheOrSaveToCache(routeOrder.getRouteId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,9 +122,9 @@ public class RouteCacheService {
|
|||
routeCacheManage.invalidateActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode);
|
||||
return null;
|
||||
} else {
|
||||
routeOrder = routeOrder.reloadStatus();
|
||||
routeOrder.reloadStatus();
|
||||
routeCacheManage.cacheActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode, routeOrder);
|
||||
return getFromCacheOrSaveToCache(routeId);
|
||||
return getFromCacheOrSaveToCache(routeOrder.getRouteId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,4 +12,7 @@ public class SFConstant {
|
|||
public static final String USER_DATA_PATH = "/open/HR/commonuserlist";
|
||||
public static final String TRAVEL_RANK_BASE_URL = "http://10.10.14.178:8080";
|
||||
public static final String TRAVEL_RANK_PATH = "/fssc/queryBill/queryTravelLevelByRank";
|
||||
public static final String ORG_SYNC_PATH = "/open/personmasterdate/orgpagelist";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package com.chint.infrastructure.constant;
|
||||
|
||||
public class SystemConstant {
|
||||
|
||||
public static final String ORG_CLERK_FIELD_NAME = "Clerk";
|
||||
}
|
|
@ -42,13 +42,13 @@ public class StaffRankRepositoryImpl implements StaffRankRepository {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<List<StaffRank>> findRankNameByEmployNoAndJTCompany(String employName, String companyCode) {
|
||||
public Optional<List<StaffRank>> findRankNameByEmployNoAndJTCompany(String employeeNo, String companyCode) {
|
||||
if (jtCompanyDomainService.ifCompanyInJT(null, companyCode, 1L)) {
|
||||
return Optional.ofNullable(jdbcStaffRankRepository.findByEmployeeNoAndTag(employName, "1"));
|
||||
} else if (jtCompanyDomainService.ifCompanyInJT(null, companyCode, 1L)) {
|
||||
return Optional.ofNullable(jdbcStaffRankRepository.findByEmployeeNoAndTag(employName, "2"));
|
||||
return Optional.ofNullable(jdbcStaffRankRepository.findByEmployeeNoAndTag(employeeNo, "1"));
|
||||
} else if (jtCompanyDomainService.ifCompanyInJT(null, companyCode, 3L)) {
|
||||
return Optional.ofNullable(jdbcStaffRankRepository.findByEmployeeNoAndTag(employeeNo, "2"));
|
||||
} else {
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(jdbcStaffRankRepository.findByEmployeeNo(employeeNo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package com.chint.infrastructure.repository;
|
||||
|
||||
import com.chint.domain.aggregates.system.SystemOrganization;
|
||||
import com.chint.domain.repository.SystemOrganizationRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcSystemOrganizationRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepository {
|
||||
|
||||
@Autowired
|
||||
private JdbcSystemOrganizationRepository jdbcSystemOrganizationRepository;
|
||||
|
||||
@Override
|
||||
public void saveAll(List<SystemOrganization> systemOrganizationList) {
|
||||
for (SystemOrganization systemOrganization : systemOrganizationList) {
|
||||
jdbcSystemOrganizationRepository
|
||||
.findByOrgCode(systemOrganization.getOrgCode())
|
||||
.stream()
|
||||
.findFirst()
|
||||
.ifPresent(it -> systemOrganization.setId(it.getId()));
|
||||
jdbcSystemOrganizationRepository.save(systemOrganization);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemOrganization save(SystemOrganization systemOrganization) {
|
||||
return jdbcSystemOrganizationRepository.save(systemOrganization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemOrganization> findAll() {
|
||||
List<SystemOrganization> systemOrganizationList = new ArrayList<>();
|
||||
jdbcSystemOrganizationRepository.findAll()
|
||||
.forEach(systemOrganizationList::add);
|
||||
return systemOrganizationList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SystemOrganization> findByOrgCodeContaining(String orgCode) {
|
||||
return jdbcSystemOrganizationRepository.findByOrgCodeContaining(orgCode).stream().findFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SystemOrganization> findByOrgCodeList(List<String> orgCode) {
|
||||
return jdbcSystemOrganizationRepository.findByOrgShortCodeIn(orgCode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<SystemOrganization> findByParentId(Long parentId) {
|
||||
return jdbcSystemOrganizationRepository.findByParentId(parentId);
|
||||
}
|
||||
}
|
|
@ -9,4 +9,5 @@ import java.util.List;
|
|||
@Repository
|
||||
public interface JdbcStaffRankRepository extends CrudRepository<StaffRank, Integer> {
|
||||
List<StaffRank> findByEmployeeNoAndTag(String employeeNo,String tag);
|
||||
List<StaffRank> findByEmployeeNo(String employeeNo);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.chint.infrastructure.repository.jdbc;
|
||||
|
||||
import com.chint.domain.aggregates.system.SystemOrganization;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface JdbcSystemOrganizationRepository extends CrudRepository<SystemOrganization, Long> {
|
||||
List<SystemOrganization> findByOrgCodeContaining(String orgCode);
|
||||
List<SystemOrganization> findByOrgCode(String orgCode);
|
||||
List<SystemOrganization> findByParentId(Long parentId);
|
||||
List<SystemOrganization> findByOrgShortCodeIn(Collection<String> orgCode);
|
||||
}
|
|
@ -7,8 +7,8 @@ import com.chint.domain.repository.UserNameRepository;
|
|||
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||
import com.chint.interfaces.rest.amap.dto.UserQueryResponse;
|
||||
import com.chint.interfaces.rest.amap.request.AmapRequest;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.user.UserSync;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserSync;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.chint.infrastructure.util.SignUtils;
|
|||
import com.chint.interfaces.rest.base.PostRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.request.*;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.response.BookingRelatedApiResponse;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
|
|
@ -12,8 +12,8 @@ import com.chint.interfaces.rest.ctrip.dto.AuthenticationResponseList;
|
|||
import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationInfo;
|
||||
import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationListRequest;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.user.UserSync;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserSync;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.chint.interfaces.rest.data_center;
|
||||
|
||||
import com.chint.interfaces.rest.data_center.user.dto.AccessKeyDTO;
|
||||
import com.google.gson.Gson;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static com.chint.infrastructure.constant.SFConstant.AK_BASE_URL;
|
||||
import static com.chint.infrastructure.constant.SFConstant.GET_AK_URL;
|
||||
|
||||
@Component
|
||||
public class DataCenterUtil {
|
||||
|
||||
@Value("${sf.systemId}")
|
||||
private String systemId;
|
||||
|
||||
public AccessKeyDTO akSkLoad() {
|
||||
String asSkUrl = AK_BASE_URL + GET_AK_URL + "?systemId=" + systemId;
|
||||
HttpClient client = HttpClients.createDefault();
|
||||
HttpGet getMethod = new HttpGet(asSkUrl);
|
||||
getMethod.setHeader("Content-Type", "application/json");
|
||||
try {
|
||||
var response = client.execute(getMethod);
|
||||
var responseBody = EntityUtils.toString(response.getEntity(), "UTF-8");
|
||||
var gson = new Gson();
|
||||
return gson.fromJson(responseBody, AccessKeyDTO.class);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
package com.chint.interfaces.rest.data_center.org;
|
||||
|
||||
import com.chint.dc.api.DataCenterResult;
|
||||
import com.chint.dc.api.dto.DataCenterOption;
|
||||
import com.chint.dc.api.service.DataCenterService;
|
||||
import com.chint.domain.aggregates.system.SystemOrganization;
|
||||
import com.chint.domain.repository.SystemOrganizationRepository;
|
||||
import com.chint.interfaces.rest.data_center.DataCenterUtil;
|
||||
import com.chint.interfaces.rest.data_center.user.dto.AccessKeyDTO;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.chint.infrastructure.constant.SFConstant.ORG_SYNC_PATH;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OrgRequest {
|
||||
|
||||
@Value("${sf.openApiBaseUrl}")
|
||||
private String OPENAI_BASE_URL;
|
||||
|
||||
@Autowired
|
||||
private DataCenterUtil dataCenterUtil;
|
||||
|
||||
@Autowired
|
||||
private SystemOrganizationRepository systemOrganizationRepository;
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
public void syncAllOrg() {
|
||||
int pageSize = 1000;
|
||||
int page = 1;
|
||||
List<OrgSfResponse.OrgData> orgDataList = new ArrayList<>();
|
||||
boolean shouldContinue = true;
|
||||
while (shouldContinue) {
|
||||
int start = (page - 1) * pageSize;
|
||||
log.info("Pulling org data. Page={}", page);
|
||||
try {
|
||||
LinkedHashMap<String, Object> parameters = new LinkedHashMap<>();
|
||||
parameters.put("start", start);
|
||||
parameters.put("status", "A");
|
||||
parameters.put("pageSize", pageSize);
|
||||
|
||||
DataCenterResult result = requestToDataCenter(parameters);
|
||||
if (!result.getSuccess()) {
|
||||
log.error("Failed to get org data. StatusCode={}", result.getCode());
|
||||
continue;
|
||||
}
|
||||
|
||||
List<OrgSfResponse.OrgData> orgDataResponse = parseUserData(result);
|
||||
if (orgDataResponse.isEmpty()) {
|
||||
shouldContinue = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (page % 10 == 0) {
|
||||
log.info("Pausing after 10 pages...");
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
||||
page++;
|
||||
orgDataList.addAll(orgDataResponse);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RuntimeException("Thread was interrupted", e);
|
||||
} catch (Exception e) {
|
||||
log.error("An error occurred: {}", e.getMessage(), e);
|
||||
shouldContinue = false;
|
||||
}
|
||||
}
|
||||
systemOrganizationRepository.saveAll(orgDataList.stream().map(SystemOrganization::of).toList());
|
||||
}
|
||||
|
||||
public void syncAllOrgAndGenerateParentId() {
|
||||
syncAllOrg();
|
||||
generateParentId();
|
||||
}
|
||||
|
||||
public void generateParentId() {
|
||||
List<SystemOrganization> all = systemOrganizationRepository.findAll();
|
||||
updateOrganizations(all);
|
||||
systemOrganizationRepository.saveAll(all);
|
||||
}
|
||||
|
||||
|
||||
public DataCenterResult requestToDataCenter(LinkedHashMap<String, Object> map) {
|
||||
AccessKeyDTO akSkLoad = dataCenterUtil.akSkLoad();
|
||||
DataCenterOption option = new DataCenterOption();
|
||||
option.setSk(akSkLoad.sk);
|
||||
option.setAk(akSkLoad.ak);
|
||||
option.setUrl(OPENAI_BASE_URL);
|
||||
DataCenterService dataCenterService = new DataCenterService(option);
|
||||
return dataCenterService.post(ORG_SYNC_PATH, map);
|
||||
}
|
||||
|
||||
private List<OrgSfResponse.OrgData> parseUserData(DataCenterResult result) {
|
||||
Type type = new TypeToken<List<OrgSfResponse.OrgData>>() {
|
||||
}.getType();
|
||||
return gson.fromJson(result.getData().toString(), type);
|
||||
}
|
||||
|
||||
public static void updateOrganizations(List<SystemOrganization> organizations) {
|
||||
// Create a map from orgCode to SystemOrganization for quick lookup
|
||||
Map<String, SystemOrganization> orgCodeToOrganization = organizations.stream()
|
||||
.collect(Collectors.toMap(SystemOrganization::getOrgCode, org -> org));
|
||||
|
||||
// Iterate over each organization and set the parent fields
|
||||
for (SystemOrganization org : organizations) {
|
||||
SystemOrganization parentOrg = orgCodeToOrganization.get(org.getParentOrgCode());
|
||||
if (parentOrg != null) {
|
||||
org.setParentId(parentOrg.getId());
|
||||
org.setParentOrgEnName(parentOrg.getOrgEnName());
|
||||
}
|
||||
org.setOrgShortCode(extractNumbers(org.getOrgCode()));
|
||||
}
|
||||
}
|
||||
|
||||
public static String extractNumbers(String input) {
|
||||
// 创建一个正则表达式,用于匹配数字
|
||||
Pattern pattern = Pattern.compile("\\d+");
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
|
||||
// 检查是否找到数字
|
||||
if (matcher.find()) {
|
||||
return matcher.group(); // 返回第一个匹配的数字串
|
||||
}
|
||||
return ""; // 如果没有找到数字,返回空字符串
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.chint.interfaces.rest.data_center.org;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrgSfResponse {
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
private String total;
|
||||
private String success;
|
||||
private OrgData data;
|
||||
|
||||
@Data
|
||||
public static class OrgData {
|
||||
private String externalCode;
|
||||
private String name;
|
||||
private String name_en_US;
|
||||
private String cust_parent;
|
||||
private String cust_parent_cn;
|
||||
private String headOfUnit;
|
||||
private String headOfUnitName;
|
||||
private String status;
|
||||
private String lev;
|
||||
private String SFUsername;
|
||||
private String cust_costCenter;
|
||||
private String lastModifiedDateTime;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.chint.interfaces.rest.user;
|
||||
package com.chint.interfaces.rest.data_center.user;
|
||||
|
||||
import com.chint.application.commands.UserDisabledCommand;
|
||||
import com.chint.dc.api.DataCenterResult;
|
||||
|
@ -11,8 +11,8 @@ import com.chint.domain.service.JTCompanyDomainService;
|
|||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest;
|
||||
import com.chint.interfaces.rest.ly.LYUserRequest;
|
||||
import com.chint.interfaces.rest.user.dto.AccessKeyDTO;
|
||||
import com.chint.interfaces.rest.user.dto.UserDataDTO;
|
||||
import com.chint.interfaces.rest.data_center.user.dto.AccessKeyDTO;
|
||||
import com.chint.interfaces.rest.data_center.user.dto.UserDataDTO;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.extern.slf4j.Slf4j;
|
|
@ -1,4 +1,4 @@
|
|||
package com.chint.interfaces.rest.user;
|
||||
package com.chint.interfaces.rest.data_center.user;
|
||||
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.aggregates.user.UserCustomCode;
|
|
@ -1,4 +1,4 @@
|
|||
package com.chint.interfaces.rest.user;
|
||||
package com.chint.interfaces.rest.data_center.user;
|
||||
|
||||
|
||||
import com.chint.application.commands.UserDisabledCommand;
|
||||
|
@ -8,6 +8,7 @@ import com.chint.domain.aggregates.standards.Ranks;
|
|||
import com.chint.domain.aggregates.standards.StaffRank;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.aggregates.user.UserDepartmentInfo;
|
||||
import com.chint.domain.exceptions.AuthException;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.repository.JTCompanyRepository;
|
||||
import com.chint.domain.repository.StaffRankRepository;
|
||||
|
@ -20,7 +21,7 @@ import com.chint.infrastructure.echo_framework.command.Command;
|
|||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.infrastructure.util.StringCheck;
|
||||
import com.chint.interfaces.rest.base.PostRequest;
|
||||
import com.chint.interfaces.rest.user.dto.UserDataDTO;
|
||||
import com.chint.interfaces.rest.data_center.user.dto.UserDataDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
@ -78,10 +79,21 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
//这个方法 逻辑进行修改 , 首先通过查询 表的方式 , 如果部分数据为空 , 那么就要查询 sf信息获取
|
||||
user.loadInfoFromDept();
|
||||
//根据员工的登录信息,来创建fssc基础跳转信息
|
||||
List<UserDepartmentInfo> userDepartmentInfoList = user
|
||||
.getUserDepartmentInfoList()
|
||||
.stream()
|
||||
.filter(it -> this.jtCompanyDomainService.ifCompanyInJT(null, it.getCompanyCode()))
|
||||
.toList();
|
||||
for (UserDepartmentInfo userDepartmentInfo : user.getUserDepartmentInfoList()) {
|
||||
String sysCode = jtCompanyDomainService.findSystemCodeByCompanyCode(userDepartmentInfo.getCompanyCode());
|
||||
if (sysCode == null) {
|
||||
continue;
|
||||
}
|
||||
user.addFssc(userDepartmentInfo.getCompanyName(), sysCode);
|
||||
}
|
||||
if (user.getFsscSystemList() == null || user.getFsscSystemList().isEmpty()) {
|
||||
throw new AuthException("用户所在公司不在实施范围内");
|
||||
}
|
||||
return loadRankCode(user);
|
||||
}
|
||||
|
||||
|
@ -151,9 +163,9 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
.filter(userDataDTO -> userDataDTO.getStatus().equals("A"))
|
||||
.toList();
|
||||
|
||||
|
||||
if (fromJson.isEmpty()) {
|
||||
user.setStatus(0);
|
||||
user.loadInfoFromDept();
|
||||
Command.of(UserDisabledCommand.class).user(user).sendToQueue();
|
||||
} else {
|
||||
user.setStatus(1);
|
|
@ -1,4 +1,4 @@
|
|||
package com.chint.interfaces.rest.user;
|
||||
package com.chint.interfaces.rest.data_center.user;
|
||||
|
||||
import com.chint.dc.api.DataCenterResult;
|
||||
import com.chint.dc.api.dto.DataCenterOption;
|
||||
|
@ -6,8 +6,9 @@ import com.chint.dc.api.service.DataCenterService;
|
|||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.service.JTCompanyDomainService;
|
||||
import com.chint.interfaces.rest.user.dto.AccessKeyDTO;
|
||||
import com.chint.interfaces.rest.user.dto.UserDataDTO;
|
||||
import com.chint.interfaces.rest.data_center.DataCenterUtil;
|
||||
import com.chint.interfaces.rest.data_center.user.dto.AccessKeyDTO;
|
||||
import com.chint.interfaces.rest.data_center.user.dto.UserDataDTO;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.apache.http.client.HttpClient;
|
||||
|
@ -35,23 +36,12 @@ public class UserSFRequest {
|
|||
@Value("${sf.openApiBaseUrl}")
|
||||
private String OPENAI_BASE_URL;
|
||||
|
||||
@Autowired
|
||||
private DataCenterUtil dataCenterUtil;
|
||||
|
||||
@Autowired
|
||||
private JTCompanyDomainService jtCompanyDomainService;
|
||||
|
||||
private AccessKeyDTO akSkLoad() {
|
||||
String asSkUrl = AK_BASE_URL + GET_AK_URL + "?systemId=" + systemId;
|
||||
HttpClient client = HttpClients.createDefault();
|
||||
HttpGet getMethod = new HttpGet(asSkUrl);
|
||||
getMethod.setHeader("Content-Type", "application/json");
|
||||
try {
|
||||
var response = client.execute(getMethod);
|
||||
var responseBody = EntityUtils.toString(response.getEntity(), "UTF-8");
|
||||
var gson = new Gson();
|
||||
return gson.fromJson(responseBody, AccessKeyDTO.class);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Cacheable(value = "UserDataFromSF", key = "#user.employeeNo")
|
||||
public List<UserDataDTO> getUserSFDataFromOpenApi(User user) {
|
||||
|
@ -75,13 +65,8 @@ public class UserSFRequest {
|
|||
}
|
||||
|
||||
|
||||
public List<UserDataDTO> getUserSFDataFromOpenApiBycompanyName(String companyName) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public DataCenterResult requestToDataCenter(LinkedHashMap<String, Object> map) {
|
||||
AccessKeyDTO akSkLoad = akSkLoad();
|
||||
AccessKeyDTO akSkLoad = dataCenterUtil.akSkLoad();
|
||||
DataCenterOption option = new DataCenterOption();
|
||||
option.setSk(akSkLoad.sk);
|
||||
option.setAk(akSkLoad.ak);
|
|
@ -1,4 +1,4 @@
|
|||
package com.chint.interfaces.rest.user;
|
||||
package com.chint.interfaces.rest.data_center.user;
|
||||
|
||||
import com.chint.application.commands.UserDisabledCommand;
|
||||
import com.chint.application.commands.UserLoginCommand;
|
|
@ -1,4 +1,4 @@
|
|||
package com.chint.interfaces.rest.user.dto;
|
||||
package com.chint.interfaces.rest.data_center.user.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.chint.interfaces.rest.user.dto;
|
||||
package com.chint.interfaces.rest.data_center.user.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.chint.interfaces.rest.user.dto;
|
||||
package com.chint.interfaces.rest.data_center.user.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package com.chint.interfaces.rest.user.dto;
|
||||
package com.chint.interfaces.rest.data_center.user.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.chint.interfaces.rest.user.dto;
|
||||
package com.chint.interfaces.rest.data_center.user.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -9,8 +9,8 @@ import com.chint.infrastructure.util.BaseContext;
|
|||
import com.chint.interfaces.rest.ly.dto.user.EmployeeEntity;
|
||||
import com.chint.interfaces.rest.ly.dto.user.EmployeeRequest;
|
||||
import com.chint.interfaces.rest.ly.dto.user.UserResponse;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.user.UserSync;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserSync;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -71,14 +71,14 @@ public class LYUserRequest implements UserSync {
|
|||
}
|
||||
|
||||
private Integer translateWorkStatus(String workStatus) {
|
||||
switch (workStatus) {
|
||||
case "A":
|
||||
return 1;
|
||||
case "T":
|
||||
return 0;
|
||||
default:
|
||||
if (workStatus == null) {
|
||||
return 0;
|
||||
}
|
||||
return switch (workStatus) {
|
||||
case "A" -> 1;
|
||||
case "T" -> 0;
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
|
||||
public boolean saveCurrentUser(User user) {
|
||||
|
@ -95,7 +95,7 @@ public class LYUserRequest implements UserSync {
|
|||
userNameRepository.findByEmployeeNo(user.getEmployeeNo()).ifPresentOrElse(it -> employeeEntity.setSurName(it.getIdName()),
|
||||
() -> employeeEntity.setSurName(user.getName()));
|
||||
employeeEntity.setGender(translateGender(user.getGender()));
|
||||
employeeEntity.setWorkingState(translateWorkStatus(user.getWorkStatus()));
|
||||
employeeEntity.setWorkingState(1);
|
||||
employeeEntity.setReservationType(0);
|
||||
String standardLevel = user.getStandardLevel();
|
||||
employeeEntity.setPositionLevelName(standardLevel);
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.chint.interfaces.rest.ctrip.CTripAirportRequest;
|
|||
import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.airport.AirportSearchResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.put.CTripStatusNotification;
|
||||
import com.chint.interfaces.rest.data_center.org.OrgRequest;
|
||||
import com.chint.interfaces.rest.ly.LYPostRequest;
|
||||
import com.chint.interfaces.rest.ly.LYSearchRequest;
|
||||
import com.chint.interfaces.rest.ly.LYUserRequest;
|
||||
|
@ -37,10 +38,10 @@ import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.OrderInfo;
|
|||
import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse;
|
||||
import com.chint.interfaces.rest.ly.dto.strokepush.StrokePushResult;
|
||||
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeRequest;
|
||||
import com.chint.interfaces.rest.user.BatchUserWorker;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequestImpl;
|
||||
import com.chint.interfaces.rest.user.UserSFRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.BatchUserWorker;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequestImpl;
|
||||
import com.chint.interfaces.rest.data_center.user.UserSFRequest;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -153,6 +154,19 @@ class RouteApplicationTests {
|
|||
@Autowired
|
||||
private SystemDomainService systemDomainService;
|
||||
|
||||
@Autowired
|
||||
private OrgRequest orgRequest;
|
||||
|
||||
|
||||
@Test
|
||||
void testSyncOrg(){
|
||||
orgRequest.syncAllOrg();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateOrg(){
|
||||
orgRequest.generateParentId();
|
||||
}
|
||||
|
||||
void test3() {
|
||||
FlyOkDTO freightDTO = new FlyOkDTO();
|
||||
|
@ -281,7 +295,7 @@ class RouteApplicationTests {
|
|||
|
||||
@Test
|
||||
void loginSignProd() {
|
||||
String sfno = "200308003";
|
||||
String sfno = "210303016";
|
||||
String syscode = "FSSC";
|
||||
String billcode = "CLSQ240225000099";
|
||||
String companycode = "正泰集团股份有限公司";
|
||||
|
|
Loading…
Reference in New Issue