Merge branch 'dev' of http://47.97.21.20:3000/echo/route into dev
This commit is contained in:
commit
16935ccb5d
|
@ -30,13 +30,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.chint.infrastructure.constant.BPMConstant.AN_FSSC;
|
||||
import static com.chint.infrastructure.constant.BPMConstant.FSSC;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/public")
|
||||
|
@ -200,20 +196,7 @@ public class LoginController {
|
|||
|
||||
private void syncUserInfoToSupplier(User user) {
|
||||
// 给定的 LocalDateTime 实例,示例中为2024年3月1日15:00
|
||||
LocalDateTime lastSyncTime = user.getSyncTime();
|
||||
|
||||
if (lastSyncTime == null) {
|
||||
asyncUser(user);
|
||||
return;
|
||||
}
|
||||
// 获取当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 计算当前时间与给定时间之间的持续时间
|
||||
Duration duration = Duration.between(lastSyncTime, now);
|
||||
|
||||
// 判断是否超过一天
|
||||
if (duration.toDays() >= 1) {
|
||||
if (user.checkSyncTime()) {
|
||||
asyncUser(user);
|
||||
} else {
|
||||
log.info("未超过一天,不执行同步。");
|
||||
|
|
|
@ -78,6 +78,8 @@ public class RouteOrder implements Serializable {
|
|||
@Transient
|
||||
private String supplierCNName;
|
||||
|
||||
@MappedCollection(idColumn = "route_id")
|
||||
private RouterOrderExtensionField routerOrderExtensionField;
|
||||
|
||||
@MappedCollection(idColumn = "route_id", keyColumn = "route_order_key")
|
||||
private List<Leg> legItems;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.chint.domain.aggregates.order;
|
||||
|
||||
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("route_order_extension_field")
|
||||
public class RouterOrderExtensionField implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 2212312435311609990L;
|
||||
@Id
|
||||
private Long id;
|
||||
@Column("route_id")
|
||||
private Long routeId;
|
||||
|
||||
private String belongDeptCode;
|
||||
|
||||
|
||||
}
|
|
@ -71,8 +71,16 @@ public class OrderCarRecord extends OrderBaseRecord {
|
|||
private String orderSource; // 预订来源:线上/线下
|
||||
private String payAmount;//支付总金额
|
||||
private String receiptsNumOrigin;//支付总金额
|
||||
private String belongDeport; //归属部门
|
||||
|
||||
|
||||
public OrderCarRecord loadBelongDeport(String belongDeport
|
||||
) {
|
||||
// 行程信息
|
||||
this.setBelongDeport(belongDeport);
|
||||
return this;
|
||||
}
|
||||
|
||||
//添加行程信息
|
||||
public OrderCarRecord loadTravelInfo(String startTime,
|
||||
String arriveTime,
|
||||
|
|
|
@ -80,6 +80,14 @@ public class OrderFlightRecord extends OrderBaseRecord {
|
|||
private String createTime;
|
||||
private String receiptsNumOrigin;//原差旅申请单单号
|
||||
private String payAmount;
|
||||
private String belongDeport; //归属部门
|
||||
|
||||
public OrderFlightRecord loadBelongDeport(String belongDeport
|
||||
) {
|
||||
// 行程信息
|
||||
this.setBelongDeport(belongDeport);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 加载基础订单信息
|
||||
public OrderFlightRecord loadBasicOrderInfo(String orderNo,
|
||||
|
|
|
@ -79,6 +79,14 @@ public class OrderHotelRecord extends OrderBaseRecord {
|
|||
private String orderStatus;
|
||||
private String createTime;
|
||||
private String receiptsNumOrigin;//支付总金额
|
||||
private String belongDeport; //归属部门
|
||||
|
||||
public OrderHotelRecord loadBelongDeport(String belongDeport
|
||||
) {
|
||||
// 行程信息
|
||||
this.setBelongDeport(belongDeport);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 加载基础订单信息
|
||||
public OrderHotelRecord loadBasicOrderInfo(String orderNo,
|
||||
|
|
|
@ -73,6 +73,14 @@ public class OrderTrainRecord extends OrderBaseRecord{
|
|||
private String trainTime; // 发车时间 yyyy-MM-dd HH:mm:ss
|
||||
private String yxId; // 影像比对ID
|
||||
private String receiptsNumOrigin;//原差旅申请单单号
|
||||
private String belongDeport; //归属部门
|
||||
|
||||
public OrderTrainRecord loadBelongDeport(String belongDeport
|
||||
) {
|
||||
// 行程信息
|
||||
this.setBelongDeport(belongDeport);
|
||||
return this;
|
||||
}
|
||||
// 加载基础订单信息
|
||||
public OrderTrainRecord loadBasicOrderInfo(Long id, String orderNo, String orderStatus, String createTime) {
|
||||
this.setId(id);
|
||||
|
|
|
@ -19,10 +19,12 @@ import org.springframework.data.relational.core.mapping.Table;
|
|||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.chint.infrastructure.constant.AuthMessageConstant.USER_FSSC_SYSTEM_LIST;
|
||||
import static com.chint.infrastructure.constant.BPMConstant.*;
|
||||
|
@ -72,6 +74,66 @@ public class User implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
public UserDepartmentInfo.Builder addDeptInfo() {
|
||||
return new UserDepartmentInfo.Builder(this);
|
||||
}
|
||||
|
||||
public String lowestDeptCode() {
|
||||
Optional<UserDepartmentInfo> first = this.userDepartmentInfoList
|
||||
.stream()
|
||||
.filter(it -> it.getIfPrimary() == 1)
|
||||
.findFirst();
|
||||
return first.map(this::lowestDept).orElse(null);
|
||||
}
|
||||
|
||||
public String lowestDeptCode(String companyName) {
|
||||
Optional<UserDepartmentInfo> first = this.userDepartmentInfoList
|
||||
.stream()
|
||||
.filter(it -> it.getCompanyName().equals(companyName))
|
||||
.findFirst();
|
||||
return first.map(this::lowestDept).orElse(null);
|
||||
}
|
||||
|
||||
private String lowestDept(UserDepartmentInfo userDepartmentInfo) {
|
||||
if (userDepartmentInfo.getDepartmentCodeSeven() != null) {
|
||||
return userDepartmentInfo.getDepartmentCodeSeven();
|
||||
}
|
||||
if (userDepartmentInfo.getDepartmentCodeSix() != null) {
|
||||
return userDepartmentInfo.getDepartmentCodeSix();
|
||||
}
|
||||
if (userDepartmentInfo.getDepartmentCodeFive() != null) {
|
||||
return userDepartmentInfo.getDepartmentCodeFive();
|
||||
}
|
||||
if (userDepartmentInfo.getDepartmentCodeFour() != null) {
|
||||
return userDepartmentInfo.getDepartmentCodeFour();
|
||||
}
|
||||
if (userDepartmentInfo.getDepartmentCodeThree() != null) {
|
||||
return userDepartmentInfo.getDepartmentCodeThree();
|
||||
}
|
||||
if (userDepartmentInfo.getDepartmentCodeTwo() != null) {
|
||||
return userDepartmentInfo.getDepartmentCodeTwo();
|
||||
}
|
||||
if (userDepartmentInfo.getDepartmentCodeOne() != null) {
|
||||
return userDepartmentInfo.getDepartmentCodeOne();
|
||||
}
|
||||
if (userDepartmentInfo.getCompanyCode() != null) {
|
||||
return userDepartmentInfo.getCompanyCode();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Boolean checkSyncTime() {
|
||||
if (this.syncTime == null) {
|
||||
return true;
|
||||
}
|
||||
// 获取当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 计算当前时间与给定时间之间的持续时间
|
||||
Duration duration = Duration.between(syncTime, now);
|
||||
// 判断是否超过一天
|
||||
return duration.toDays() >= 1;
|
||||
}
|
||||
|
||||
public User addDeptInfo(UserDepartmentInfo userDepartmentInfo) {
|
||||
if (this.userDepartmentInfoList == null) {
|
||||
this.userDepartmentInfoList = new ArrayList<>();
|
||||
|
|
|
@ -63,7 +63,7 @@ public class UserDepartmentInfo implements Serializable {
|
|||
this.ifPrimary = ifPrimary;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
public static class Builder {
|
||||
private User user;
|
||||
private String companyCode;
|
||||
|
|
|
@ -7,11 +7,14 @@ import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
|
|||
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
|
||||
import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
|
||||
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.*;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.repository.LocationRepository;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.domain.service.OrderDetailDomainService;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository;
|
||||
import com.chint.infrastructure.util.DateTimeUtil;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -35,6 +38,11 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
@Autowired
|
||||
private LocationRepository locationRepository;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
@Autowired
|
||||
private UserHttpRequest userHttpRequest;
|
||||
|
||||
private OrderRecordBasic buildWithRecord(CTripCarRecord cTripCarRecord) {
|
||||
OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
|
||||
CTripCarPassengerInfo cTripCarPassengerInfo = cTripCarRecord.getCTripCarPassengerInfo();
|
||||
|
@ -66,7 +74,6 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
} else {
|
||||
orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_NOT);
|
||||
}
|
||||
|
||||
return orderRecordBasic;
|
||||
}
|
||||
|
||||
|
@ -173,6 +180,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
"",
|
||||
cTripCarRecordBase.getCreateTime()));
|
||||
|
||||
//这里添加归属部门编号 , 这里兼容测试环境 , 如果行程规划单已经有这个值 , 那么直接取, 没有的话,查找用户的部门获取
|
||||
Optional<RouterOrderExtensionField> routerOrderExtensionField = byOrderNo
|
||||
.flatMap(it -> Optional.ofNullable(it.getRouterOrderExtensionField()));
|
||||
routerOrderExtensionField.ifPresentOrElse(it -> orderCarRecord.loadBelongDeport(it.getBelongDeptCode()),
|
||||
() -> orderCarRecord.loadBelongDeport(
|
||||
belongDeport(orderCarRecord.getBookingUserCode(), orderCarRecord.getAccountCompanyName())
|
||||
));
|
||||
|
||||
return orderCarRecord;
|
||||
}
|
||||
|
||||
|
@ -367,6 +382,15 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
.loadBasicOrderInfo(String.valueOf(cTripFlightRecordBase.getOrderId()),
|
||||
"",
|
||||
cTripFlightRecordBase.getCreateTime()));
|
||||
|
||||
|
||||
//这里添加归属部门编号 , 这里兼容测试环境 , 如果行程规划单已经有这个值 , 那么直接取, 没有的话,查找用户的部门获取
|
||||
Optional<RouterOrderExtensionField> routerOrderExtensionField = byOrderNo
|
||||
.flatMap(it -> Optional.ofNullable(it.getRouterOrderExtensionField()));
|
||||
routerOrderExtensionField.ifPresentOrElse(it -> orderFlightRecord.loadBelongDeport(it.getBelongDeptCode()),
|
||||
() -> orderFlightRecord.loadBelongDeport(
|
||||
belongDeport(orderFlightRecord.getBookingUserCode(), orderFlightRecord.getAccountCompanyName())
|
||||
));
|
||||
return orderFlightRecord;
|
||||
}
|
||||
|
||||
|
@ -553,6 +577,28 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
cTripHotelOrderDetail.getDept2(),
|
||||
cTripHotelOrderDetail.getDept3());
|
||||
|
||||
|
||||
//这里添加归属部门编号 , 这里兼容测试环境 , 如果行程规划单已经有这个值 , 那么直接取, 没有的话,查找用户的部门获取
|
||||
Optional<RouterOrderExtensionField> routerOrderExtensionField = byOrderNo
|
||||
.flatMap(it -> Optional.ofNullable(it.getRouterOrderExtensionField()));
|
||||
routerOrderExtensionField.ifPresentOrElse(it -> orderHotelRecord.loadBelongDeport(it.getBelongDeptCode()),
|
||||
() -> orderHotelRecord.loadBelongDeport(
|
||||
belongDeport(orderHotelRecord.getBookingUserCode(), orderHotelRecord.getAccountCompanyName())
|
||||
));
|
||||
return orderHotelRecord;
|
||||
}
|
||||
|
||||
private String belongDeport(String accountCompanyName, String employeeNo) {
|
||||
User user = userRepository.findByUserEmployeeNo(employeeNo);
|
||||
if (user.getUserDepartmentInfoList() == null || user.getUserDepartmentInfoList().isEmpty()) {
|
||||
userHttpRequest.loadUserDeptInfo(user);
|
||||
}
|
||||
String deptCode = user.lowestDeptCode(accountCompanyName);
|
||||
if (deptCode == null) {
|
||||
//根据入账公司没有找到部门编码的话,直接获取主岗编码
|
||||
deptCode = user.lowestDeptCode();
|
||||
}
|
||||
//清除部门编码里面的字母
|
||||
return deptCode.replaceAll("\\D", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,4 +4,6 @@ import com.chint.domain.aggregates.user.User;
|
|||
|
||||
public interface UserHttpRequest {
|
||||
User loadUserInfo(User user);
|
||||
|
||||
User loadUserDeptInfo(User user);
|
||||
}
|
|
@ -4,8 +4,10 @@ package com.chint.interfaces.rest.user;
|
|||
import com.chint.domain.aggregates.standards.Ranks;
|
||||
import com.chint.domain.aggregates.standards.StaffRank;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.aggregates.user.UserDepartmentInfo;
|
||||
import com.chint.domain.repository.JTCompanyRepository;
|
||||
import com.chint.domain.repository.StaffRankRepository;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.domain.service.JTCompanyDomainService;
|
||||
import com.chint.domain.service.RankDomainService;
|
||||
import com.chint.infrastructure.constant.SFConstant;
|
||||
|
@ -57,10 +59,12 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
@Autowired
|
||||
private JTCompanyRepository jtCompanyRepository;
|
||||
|
||||
|
||||
@Value("${sf.systemId}")
|
||||
private String systemId;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Override
|
||||
public User loadUserInfo(User user) {
|
||||
loadSFInfo(user);
|
||||
|
@ -115,20 +119,13 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
}
|
||||
|
||||
private User loadSingleSF(UserDataDTO userData, User user) {
|
||||
|
||||
getDataFromUserSFData(user, userData);
|
||||
|
||||
String sysCode = jtCompanyDomainService.findSystemCodeByCompanyCode(user.getCompanyCode());
|
||||
|
||||
user.addFssc(userData.getCompany_cn(), sysCode);
|
||||
// if (user.getCompanyCode().equals(XN_COMPANY_CODE)) {
|
||||
// user.addXNFssc(FSSC_LOAD_URL, postRequest);
|
||||
// }
|
||||
// //如果用户的公司编码属于集团 ,那么加入集团财务共享跳转地址
|
||||
// if (jtCompanyDomainService.ifCompanyInJT(null, userData.getCompany())) {
|
||||
// user.addJTFssc(userData.getCompany_cn(), FSSC_LOAD_URL, postRequest);
|
||||
// }
|
||||
|
||||
//根据同步时间来决定是否要同步部门信息
|
||||
if (user.checkSyncTime()) {
|
||||
addDeptInfo(userData, user, true);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
|
@ -153,6 +150,30 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
// 检查并处理JT公司和XN公司的特殊情况
|
||||
processSpecialCompanies(userDataDTOS, user);
|
||||
|
||||
for (UserDataDTO userDataDTO : userDataDTOS) {
|
||||
if (userDataDTO.getPersonIdExternal().equals(userDataDTO.getLoginUsername())) {
|
||||
addDeptInfo(userDataDTO, user, true);
|
||||
} else {
|
||||
addDeptInfo(userDataDTO, user, false);
|
||||
}
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
private User addDeptInfo(UserDataDTO userData, User user, Boolean ifPrimary) {
|
||||
UserDepartmentInfo.Builder builder = user.addDeptInfo()
|
||||
.companyInfo(userData.getCompany(), userData.getCompany_cn())
|
||||
.deptOne(userData.getUnit1(), userData.getUnit1_cn())
|
||||
.deptTwo(userData.getUnit2(), userData.getUnit2_cn())
|
||||
.deptThree(userData.getUnit3(), userData.getUnit3_cn())
|
||||
.deptFour(userData.getUnit4(), userData.getUnit4_cn())
|
||||
.deptFive(userData.getUnit5(), userData.getUnit5_cn())
|
||||
.deptSix(null, null)
|
||||
.deptSeven(null, null);
|
||||
if (ifPrimary) {
|
||||
builder.primary();
|
||||
}
|
||||
builder.addToUser();
|
||||
return user;
|
||||
}
|
||||
|
||||
|
@ -172,24 +193,6 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
|
||||
list.forEach(it -> user.addFssc(it.getCompany_cn(),
|
||||
jtCompanyDomainService.findSystemCodeByCompanyCode(it.getCompany())));
|
||||
// Set<String> companyCodes = userDataDTOS.stream()
|
||||
// .map(UserDataDTO::getCompany)
|
||||
// .collect(Collectors.toSet());
|
||||
//
|
||||
//
|
||||
// List<String> inJtCompanyCodes = companyCodes
|
||||
// .stream()
|
||||
// .filter(code -> jtCompanyDomainService.ifCompanyInJT(null, code))
|
||||
// .toList();
|
||||
//
|
||||
// for (String inJtCompanyCode : inJtCompanyCodes) {
|
||||
// JTCompany byCompanyCode = jtCompanyRepository.findByCompanyCode(inJtCompanyCode);
|
||||
// user.addJTFssc(byCompanyCode.getCompanyName(), FSSC_LOAD_URL, postRequest);
|
||||
// }
|
||||
//
|
||||
// if (companyCodes.contains(XN_COMPANY_CODE)) {
|
||||
// user.addXNFssc(FSSC_LOAD_URL, postRequest);
|
||||
// }
|
||||
}
|
||||
|
||||
private User getDataFromUserSFData(User user, UserDataDTO userData) {
|
||||
|
@ -205,4 +208,21 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
return user;
|
||||
}
|
||||
|
||||
public User loadUserDeptInfo(User user) {
|
||||
List<UserDataDTO> userDataDTOList = userSFRequest.getUserSFDataFromOpenApi(user);
|
||||
if (userDataDTOList != null && userDataDTOList.size() == 1) {
|
||||
addDeptInfo(userDataDTOList.get(0), user, true);
|
||||
}
|
||||
|
||||
if (userDataDTOList != null && userDataDTOList.size() > 1) {
|
||||
for (UserDataDTO userDataDTO : userDataDTOList) {
|
||||
if (userDataDTO.getPersonIdExternal().equals(userDataDTO.getLoginUsername())) {
|
||||
addDeptInfo(userDataDTO, user, true);
|
||||
} else {
|
||||
addDeptInfo(userDataDTO, user, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return userRepository.save(user);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue