diff --git a/src/main/java/com/chint/application/dtos/OrganizationTicketClerk.java b/src/main/java/com/chint/application/dtos/OrganizationTicketClerk.java new file mode 100644 index 00000000..3010f738 --- /dev/null +++ b/src/main/java/com/chint/application/dtos/OrganizationTicketClerk.java @@ -0,0 +1,9 @@ +package com.chint.application.dtos; + +import lombok.Data; + +@Data +public class OrganizationTicketClerk { + private String orgCode; + private String clerkName; +} diff --git a/src/main/java/com/chint/application/in/AutoWorkController.java b/src/main/java/com/chint/application/in/AutoWorkController.java index 52256ce9..c7119541 100644 --- a/src/main/java/com/chint/application/in/AutoWorkController.java +++ b/src/main/java/com/chint/application/in/AutoWorkController.java @@ -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; diff --git a/src/main/java/com/chint/application/out/LoginController.java b/src/main/java/com/chint/application/out/LoginController.java index f0734e8c..1f1e7198 100644 --- a/src/main/java/com/chint/application/out/LoginController.java +++ b/src/main/java/com/chint/application/out/LoginController.java @@ -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 diff --git a/src/main/java/com/chint/application/out/UserController.java b/src/main/java/com/chint/application/out/UserController.java index 8fbf135b..9972fe78 100644 --- a/src/main/java/com/chint/application/out/UserController.java +++ b/src/main/java/com/chint/application/out/UserController.java @@ -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.*; diff --git a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java index 4671686d..8ba68619 100644 --- a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java @@ -126,35 +126,47 @@ public class OrderDetailQuery { public List handlerFlightRecordData(List 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 handlerHotelRecordData(List 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 handlerTrainRecordData(List 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 handlerCarRecordData(List 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; } diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index 390b3c0b..c343989d 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -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; 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 73c1527f..8492a589 100644 --- a/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java +++ b/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java @@ -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; diff --git a/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java b/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java index 2b228be9..a8200cca 100644 --- a/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java @@ -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; diff --git a/src/main/java/com/chint/application/services/login/strategy/PailaMobileLoginStrategy.java b/src/main/java/com/chint/application/services/login/strategy/PailaMobileLoginStrategy.java index c375938c..cbc6b06b 100644 --- a/src/main/java/com/chint/application/services/login/strategy/PailaMobileLoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/strategy/PailaMobileLoginStrategy.java @@ -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; diff --git a/src/main/java/com/chint/application/system/SystemController.java b/src/main/java/com/chint/application/system/SystemController.java index ef64142f..be9d653c 100644 --- a/src/main/java/com/chint/application/system/SystemController.java +++ b/src/main/java/com/chint/application/system/SystemController.java @@ -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 save(@RequestBody SystemAnnouncementDTO systemAnnouncementDTO) { @@ -92,4 +102,19 @@ public class SystemController { .toList(); return Result.Success(SUCCESS, systemAnnouncements); } + + + @ApiOperation("添加票务员") + @PostMapping("/organization/add/clerk") + public Result addOrganizationClerk(@RequestBody OrganizationTicketClerk organizationTicketClerk) { + systemDomainService.addOrganizationClerk(organizationTicketClerk); + return Result.Success(SUCCESS); + } + + @ApiOperation("同步所有的组织") + @PostMapping("/organization/sync/all") + public Result organizationSyncAll() { + CompletableFuture.runAsync(() -> orgRequest.syncAllOrgAndGenerateParentId()); + return Result.Success(SUCCESS, "开始执行中"); + } } diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderBaseRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderBaseRecord.java index 65a3be19..5c71875d 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderBaseRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderBaseRecord.java @@ -8,4 +8,6 @@ import java.time.LocalDateTime; public class OrderBaseRecord { private LocalDateTime createDataTime; private LocalDateTime updateDataTime; + private String ticketClerk; // 票务员 + private String belongDepart; } 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 510cd30d..b5a7307b 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 @@ -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 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 f6e3718f..f1815918 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 @@ -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 ) { 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 fd3aa531..09e8a44e 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 @@ -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 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 83120a25..aeb509e5 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 @@ -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 diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemAnnouncementEmployee.java b/src/main/java/com/chint/domain/aggregates/system/SystemAnnouncementEmployee.java index f2ea0db1..aaa11bae 100644 --- a/src/main/java/com/chint/domain/aggregates/system/SystemAnnouncementEmployee.java +++ b/src/main/java/com/chint/domain/aggregates/system/SystemAnnouncementEmployee.java @@ -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; } diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemOrganization.java b/src/main/java/com/chint/domain/aggregates/system/SystemOrganization.java new file mode 100644 index 00000000..8092a42b --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/system/SystemOrganization.java @@ -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 systemOrganizationExtensionList; + @Transient + private List 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; + } +} diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemOrganizationExtension.java b/src/main/java/com/chint/domain/aggregates/system/SystemOrganizationExtension.java new file mode 100644 index 00000000..55da012a --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/system/SystemOrganizationExtension.java @@ -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; +} 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 3dd51a50..86b4b3cc 100644 --- a/src/main/java/com/chint/domain/aggregates/user/User.java +++ b/src/main/java/com/chint/domain/aggregates/user/User.java @@ -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; diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java index 23022499..49035882 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java @@ -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; diff --git a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java index 279ee090..1098f590 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java @@ -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; diff --git a/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java index e223d823..2aef8119 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java @@ -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; /** * 同程数据转换 diff --git a/src/main/java/com/chint/domain/repository/SystemOrganizationRepository.java b/src/main/java/com/chint/domain/repository/SystemOrganizationRepository.java new file mode 100644 index 00000000..770872ad --- /dev/null +++ b/src/main/java/com/chint/domain/repository/SystemOrganizationRepository.java @@ -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 systemOrganizationList); + + SystemOrganization save(SystemOrganization systemOrganization); + + List findAll(); + + Optional findByOrgCodeContaining(String orgCode); + + List findByOrgCodeList(List orgCode); + + List findByParentId(Long parentId); +} diff --git a/src/main/java/com/chint/domain/service/BPMOrderDomainService.java b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java index 78446b8e..7a65e9c9 100644 --- a/src/main/java/com/chint/domain/service/BPMOrderDomainService.java +++ b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java @@ -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; diff --git a/src/main/java/com/chint/domain/service/JTCompanyDomainService.java b/src/main/java/com/chint/domain/service/JTCompanyDomainService.java index 6eb60095..c7d21239 100644 --- a/src/main/java/com/chint/domain/service/JTCompanyDomainService.java +++ b/src/main/java/com/chint/domain/service/JTCompanyDomainService.java @@ -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 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(); } diff --git a/src/main/java/com/chint/domain/service/OrderDomainService.java b/src/main/java/com/chint/domain/service/OrderDomainService.java index 196aff5b..2fb7af7a 100644 --- a/src/main/java/com/chint/domain/service/OrderDomainService.java +++ b/src/main/java/com/chint/domain/service/OrderDomainService.java @@ -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; diff --git a/src/main/java/com/chint/domain/service/SystemDomainService.java b/src/main/java/com/chint/domain/service/SystemDomainService.java index 7d525c36..a1442ef3 100644 --- a/src/main/java/com/chint/domain/service/SystemDomainService.java +++ b/src/main/java/com/chint/domain/service/SystemDomainService.java @@ -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) { @@ -42,9 +52,71 @@ public class SystemDomainService { public Optional companyNameByAccountId(String accountId) { List all = accountCompanyRepository.findAll(); return all.stream() - .filter(it->it.getAccountId().equals(accountId)) + .filter(it -> it.getAccountId().equals(accountId)) .map(AccountCompany::getCompanyName) .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 childOrganizationList = systemOrganization.getChildOrganizationList(); + if (childOrganizationList != null && !childOrganizationList.isEmpty()) { + for (SystemOrganization organization : childOrganizationList) { + loadClerk(organization, clerk); + } + } + } + + public SystemOrganization queryChild(SystemOrganization systemOrganization) { + List 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 generateRecordClerk(List recordList) { + List orgCodeList = recordList.stream() + .map(OrderBaseRecord::getBelongDepart) + .distinct() + .filter(Objects::nonNull).toList(); + List 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; + } } diff --git a/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java b/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java index 2c8973cd..f5fd4e7f 100644 --- a/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java +++ b/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java @@ -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; diff --git a/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java index 7ff79b52..05f8df3e 100644 --- a/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java @@ -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; diff --git a/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java b/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java index 4d0f4494..b567da42 100644 --- a/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java +++ b/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java @@ -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,13 +122,13 @@ 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()); } } - public RouteOrder getRouteByRouteOrderNo(String routeOrderNo){ + public RouteOrder getRouteByRouteOrderNo(String routeOrderNo) { Long routeId = routeCacheManage.cacheRouteOrderNoMapRouteId(routeOrderNo, null); if (routeId == null) { routeCacheManage.invalidateRouteOrderNoMapRouteId(routeOrderNo); @@ -137,7 +136,7 @@ public class RouteCacheService { return getFromCacheOrSaveToCache(routeId); } RouteOrder routeOrder = jdbcRouteRepository.findByRouteOrderNo(routeOrderNo); - if(routeOrder != null) { + if (routeOrder != null) { routeCacheManage.cacheRouteOrderNoMapRouteId(routeOrderNo, routeOrder.reloadStatus()); } return routeOrder; diff --git a/src/main/java/com/chint/infrastructure/constant/SFConstant.java b/src/main/java/com/chint/infrastructure/constant/SFConstant.java index 092472a4..05a9930f 100644 --- a/src/main/java/com/chint/infrastructure/constant/SFConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/SFConstant.java @@ -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"; + + } diff --git a/src/main/java/com/chint/infrastructure/constant/SystemConstant.java b/src/main/java/com/chint/infrastructure/constant/SystemConstant.java new file mode 100644 index 00000000..e2fb2585 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/constant/SystemConstant.java @@ -0,0 +1,6 @@ +package com.chint.infrastructure.constant; + +public class SystemConstant { + + public static final String ORG_CLERK_FIELD_NAME = "Clerk"; +} diff --git a/src/main/java/com/chint/infrastructure/repository/StaffRankRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/StaffRankRepositoryImpl.java index ad292a31..716ba766 100644 --- a/src/main/java/com/chint/infrastructure/repository/StaffRankRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/StaffRankRepositoryImpl.java @@ -42,13 +42,13 @@ public class StaffRankRepositoryImpl implements StaffRankRepository { } @Override - public Optional> findRankNameByEmployNoAndJTCompany(String employName, String companyCode) { + public Optional> 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)); } } } diff --git a/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java new file mode 100644 index 00000000..afc1a850 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java @@ -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 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 findAll() { + List systemOrganizationList = new ArrayList<>(); + jdbcSystemOrganizationRepository.findAll() + .forEach(systemOrganizationList::add); + return systemOrganizationList; + } + + @Override + public Optional findByOrgCodeContaining(String orgCode) { + return jdbcSystemOrganizationRepository.findByOrgCodeContaining(orgCode).stream().findFirst(); + } + + @Override + public List findByOrgCodeList(List orgCode) { + return jdbcSystemOrganizationRepository.findByOrgShortCodeIn(orgCode); + } + + + + @Override + public List findByParentId(Long parentId) { + return jdbcSystemOrganizationRepository.findByParentId(parentId); + } +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcStaffRankRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcStaffRankRepository.java index a612234c..3b7dbf23 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcStaffRankRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcStaffRankRepository.java @@ -9,4 +9,5 @@ import java.util.List; @Repository public interface JdbcStaffRankRepository extends CrudRepository { List findByEmployeeNoAndTag(String employeeNo,String tag); + List findByEmployeeNo(String employeeNo); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcSystemOrganizationRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcSystemOrganizationRepository.java new file mode 100644 index 00000000..933ad7d2 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcSystemOrganizationRepository.java @@ -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 { + List findByOrgCodeContaining(String orgCode); + List findByOrgCode(String orgCode); + List findByParentId(Long parentId); + List findByOrgShortCodeIn(Collection orgCode); +} diff --git a/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java b/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java index 8074e19e..a3f8a898 100644 --- a/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java +++ b/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java @@ -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; diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java index 5fda1ec7..1bc2d84d 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java @@ -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; diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java index 5a717888..2506a4b8 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java @@ -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; diff --git a/src/main/java/com/chint/interfaces/rest/data_center/DataCenterUtil.java b/src/main/java/com/chint/interfaces/rest/data_center/DataCenterUtil.java new file mode 100644 index 00000000..32662a93 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/data_center/DataCenterUtil.java @@ -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); + } + } +} diff --git a/src/main/java/com/chint/interfaces/rest/data_center/org/OrgRequest.java b/src/main/java/com/chint/interfaces/rest/data_center/org/OrgRequest.java new file mode 100644 index 00000000..4b1584cd --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/data_center/org/OrgRequest.java @@ -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 orgDataList = new ArrayList<>(); + boolean shouldContinue = true; + while (shouldContinue) { + int start = (page - 1) * pageSize; + log.info("Pulling org data. Page={}", page); + try { + LinkedHashMap 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 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 all = systemOrganizationRepository.findAll(); + updateOrganizations(all); + systemOrganizationRepository.saveAll(all); + } + + + public DataCenterResult requestToDataCenter(LinkedHashMap 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 parseUserData(DataCenterResult result) { + Type type = new TypeToken>() { + }.getType(); + return gson.fromJson(result.getData().toString(), type); + } + + public static void updateOrganizations(List organizations) { + // Create a map from orgCode to SystemOrganization for quick lookup + Map 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 ""; // 如果没有找到数字,返回空字符串 + } + +} diff --git a/src/main/java/com/chint/interfaces/rest/data_center/org/OrgSfResponse.java b/src/main/java/com/chint/interfaces/rest/data_center/org/OrgSfResponse.java new file mode 100644 index 00000000..3a4b10ec --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/data_center/org/OrgSfResponse.java @@ -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; + } +} diff --git a/src/main/java/com/chint/interfaces/rest/user/BatchUserWorker.java b/src/main/java/com/chint/interfaces/rest/data_center/user/BatchUserWorker.java similarity index 97% rename from src/main/java/com/chint/interfaces/rest/user/BatchUserWorker.java rename to src/main/java/com/chint/interfaces/rest/data_center/user/BatchUserWorker.java index 2e65fbe0..783cd91f 100644 --- a/src/main/java/com/chint/interfaces/rest/user/BatchUserWorker.java +++ b/src/main/java/com/chint/interfaces/rest/data_center/user/BatchUserWorker.java @@ -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; diff --git a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequest.java b/src/main/java/com/chint/interfaces/rest/data_center/user/UserHttpRequest.java similarity index 85% rename from src/main/java/com/chint/interfaces/rest/user/UserHttpRequest.java rename to src/main/java/com/chint/interfaces/rest/data_center/user/UserHttpRequest.java index e5c2089f..ec832c3f 100644 --- a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequest.java +++ b/src/main/java/com/chint/interfaces/rest/data_center/user/UserHttpRequest.java @@ -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; diff --git a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java b/src/main/java/com/chint/interfaces/rest/data_center/user/UserHttpRequestImpl.java similarity index 94% rename from src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java rename to src/main/java/com/chint/interfaces/rest/data_center/user/UserHttpRequestImpl.java index 95667f48..5623e1dd 100644 --- a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java +++ b/src/main/java/com/chint/interfaces/rest/data_center/user/UserHttpRequestImpl.java @@ -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 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); } @@ -140,7 +152,7 @@ public class UserHttpRequestImpl implements UserHttpRequest { return null; } - if(!userSFDataFromOpenApi.isEmpty()){ + if (!userSFDataFromOpenApi.isEmpty()) { for (UserDataDTO userDataDTO : userSFDataFromOpenApi) { user.addDeptInfo(userDataDTO); } @@ -151,9 +163,9 @@ public class UserHttpRequestImpl implements UserHttpRequest { .filter(userDataDTO -> userDataDTO.getStatus().equals("A")) .toList(); - if(fromJson.isEmpty()){ + + if (fromJson.isEmpty()) { user.setStatus(0); - user.loadInfoFromDept(); Command.of(UserDisabledCommand.class).user(user).sendToQueue(); } else { user.setStatus(1); diff --git a/src/main/java/com/chint/interfaces/rest/user/UserSFRequest.java b/src/main/java/com/chint/interfaces/rest/data_center/user/UserSFRequest.java similarity index 72% rename from src/main/java/com/chint/interfaces/rest/user/UserSFRequest.java rename to src/main/java/com/chint/interfaces/rest/data_center/user/UserSFRequest.java index 688ff7a1..f0c42be8 100644 --- a/src/main/java/com/chint/interfaces/rest/user/UserSFRequest.java +++ b/src/main/java/com/chint/interfaces/rest/data_center/user/UserSFRequest.java @@ -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 getUserSFDataFromOpenApi(User user) { @@ -75,13 +65,8 @@ public class UserSFRequest { } - public List getUserSFDataFromOpenApiBycompanyName(String companyName) { - - return null; - } - public DataCenterResult requestToDataCenter(LinkedHashMap map) { - AccessKeyDTO akSkLoad = akSkLoad(); + AccessKeyDTO akSkLoad = dataCenterUtil.akSkLoad(); DataCenterOption option = new DataCenterOption(); option.setSk(akSkLoad.sk); option.setAk(akSkLoad.ak); diff --git a/src/main/java/com/chint/interfaces/rest/user/UserSync.java b/src/main/java/com/chint/interfaces/rest/data_center/user/UserSync.java similarity index 85% rename from src/main/java/com/chint/interfaces/rest/user/UserSync.java rename to src/main/java/com/chint/interfaces/rest/data_center/user/UserSync.java index fa78bd95..17ba37fa 100644 --- a/src/main/java/com/chint/interfaces/rest/user/UserSync.java +++ b/src/main/java/com/chint/interfaces/rest/data_center/user/UserSync.java @@ -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; diff --git a/src/main/java/com/chint/interfaces/rest/user/dto/AccessKeyDTO.java b/src/main/java/com/chint/interfaces/rest/data_center/user/dto/AccessKeyDTO.java similarity index 75% rename from src/main/java/com/chint/interfaces/rest/user/dto/AccessKeyDTO.java rename to src/main/java/com/chint/interfaces/rest/data_center/user/dto/AccessKeyDTO.java index 140b5057..6183fe21 100644 --- a/src/main/java/com/chint/interfaces/rest/user/dto/AccessKeyDTO.java +++ b/src/main/java/com/chint/interfaces/rest/data_center/user/dto/AccessKeyDTO.java @@ -1,4 +1,4 @@ -package com.chint.interfaces.rest.user.dto; +package com.chint.interfaces.rest.data_center.user.dto; import lombok.Data; diff --git a/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankDTO.java b/src/main/java/com/chint/interfaces/rest/data_center/user/dto/TravelRankDTO.java similarity index 81% rename from src/main/java/com/chint/interfaces/rest/user/dto/TravelRankDTO.java rename to src/main/java/com/chint/interfaces/rest/data_center/user/dto/TravelRankDTO.java index faa15c2f..5d9565a1 100644 --- a/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankDTO.java +++ b/src/main/java/com/chint/interfaces/rest/data_center/user/dto/TravelRankDTO.java @@ -1,4 +1,4 @@ -package com.chint.interfaces.rest.user.dto; +package com.chint.interfaces.rest.data_center.user.dto; import lombok.Data; diff --git a/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankParam.java b/src/main/java/com/chint/interfaces/rest/data_center/user/dto/TravelRankParam.java similarity index 79% rename from src/main/java/com/chint/interfaces/rest/user/dto/TravelRankParam.java rename to src/main/java/com/chint/interfaces/rest/data_center/user/dto/TravelRankParam.java index 85995093..b0958e93 100644 --- a/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankParam.java +++ b/src/main/java/com/chint/interfaces/rest/data_center/user/dto/TravelRankParam.java @@ -1,4 +1,4 @@ -package com.chint.interfaces.rest.user.dto; +package com.chint.interfaces.rest.data_center.user.dto; import lombok.Data; diff --git a/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankResponseDTO.java b/src/main/java/com/chint/interfaces/rest/data_center/user/dto/TravelRankResponseDTO.java similarity index 77% rename from src/main/java/com/chint/interfaces/rest/user/dto/TravelRankResponseDTO.java rename to src/main/java/com/chint/interfaces/rest/data_center/user/dto/TravelRankResponseDTO.java index b884e001..9d19f071 100644 --- a/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankResponseDTO.java +++ b/src/main/java/com/chint/interfaces/rest/data_center/user/dto/TravelRankResponseDTO.java @@ -1,4 +1,4 @@ -package com.chint.interfaces.rest.user.dto; +package com.chint.interfaces.rest.data_center.user.dto; import java.util.List; diff --git a/src/main/java/com/chint/interfaces/rest/user/dto/UserDataDTO.java b/src/main/java/com/chint/interfaces/rest/data_center/user/dto/UserDataDTO.java similarity index 98% rename from src/main/java/com/chint/interfaces/rest/user/dto/UserDataDTO.java rename to src/main/java/com/chint/interfaces/rest/data_center/user/dto/UserDataDTO.java index ccc5eec2..3bee7599 100644 --- a/src/main/java/com/chint/interfaces/rest/user/dto/UserDataDTO.java +++ b/src/main/java/com/chint/interfaces/rest/data_center/user/dto/UserDataDTO.java @@ -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; diff --git a/src/main/java/com/chint/interfaces/rest/ly/LYUserRequest.java b/src/main/java/com/chint/interfaces/rest/ly/LYUserRequest.java index 6707eafa..5a6b70ad 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/LYUserRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ly/LYUserRequest.java @@ -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: - return 0; + if (workStatus == null) { + return 0; } + return switch (workStatus) { + case "A" -> 1; + case "T" -> 0; + default -> 0; + }; } public boolean saveCurrentUser(User user) { @@ -92,17 +92,17 @@ public class LYUserRequest implements UserSync { private EmployeeEntity user2LYEmployee(User user) { EmployeeEntity employeeEntity = new EmployeeEntity(); employeeEntity.setOutEmployeeId(String.valueOf(user.getEmployeeNo())); - userNameRepository.findByEmployeeNo(user.getEmployeeNo()).ifPresentOrElse(it->employeeEntity.setSurName(it.getIdName()), - ()-> employeeEntity.setSurName(user.getName())); + 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); return employeeEntity; } - @ListenTo(command = "UserLoginCommand",order = 0) + @ListenTo(command = "UserLoginCommand", order = 0) @Override public User syncUserInfoToSupplier(UserLoginCommand command) { User user = command.getUser(); @@ -115,7 +115,7 @@ public class LYUserRequest implements UserSync { return user; } - @ListenTo(command = "UserDisabledCommand",order = 3) + @ListenTo(command = "UserDisabledCommand", order = 3) @Override public void disableUserToSupplier(UserDisabledCommand command) { User user = command.getUser(); diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 1bfa6574..131e8338 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -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 = "正泰集团股份有限公司";