修复职级的查询逻辑

This commit is contained in:
lulz1 2024-03-15 12:41:39 +08:00
parent 9d6519a783
commit 26460d8568
3 changed files with 38 additions and 34 deletions

View File

@ -1,5 +1,14 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.standards.StaffRank;
import java.util.List;
import java.util.Optional;
public interface StaffRankRepository {
String findRankNameByEmployNoAndCompanyCode(String employName, String companyCode);
Optional<List<StaffRank>> findRankNameByEmployNoAndJTCompany(String employName, String companyCode);
}

View File

@ -9,6 +9,7 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.RankConstant.DEFAULT_RANK_NAME;
import static com.chint.infrastructure.constant.RankConstant.XN_COMPANY_CODE;
@ -39,4 +40,16 @@ public class StaffRankRepositoryImpl implements StaffRankRepository {
}
return byEmployeeNoAndTag.get(0).getEmployeeLevel();
}
@Override
public Optional<List<StaffRank>> findRankNameByEmployNoAndJTCompany(String employName, String companyCode) {
String tag;
if (jtCompanyDomainService.ifCompanyInJT(null, companyCode)) {
return Optional.ofNullable(jdbcStaffRankRepository.findByEmployeeNoAndTag(employName, "1"));
} else if (companyCode.equals(XN_COMPANY_CODE)) {
return Optional.ofNullable(jdbcStaffRankRepository.findByEmployeeNoAndTag(employName, "2"));
} else {
return Optional.empty();
}
}
}

View File

@ -1,46 +1,26 @@
package com.chint.interfaces.rest.user;
import com.chint.application.out.LoginController;
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.standards.Ranks;
import com.chint.domain.aggregates.standards.StaffRank;
import com.chint.domain.aggregates.user.User;
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;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.StringCheck;
import com.chint.interfaces.rest.base.PostRequest;
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.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
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.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import static com.chint.infrastructure.constant.RankConstant.*;
import static com.chint.infrastructure.constant.SFConstant.GET_AK_URL;
import static com.chint.infrastructure.constant.SFConstant.USER_DATA_PATH;
@Slf4j
@ -72,8 +52,6 @@ public class UserHttpRequestImpl implements UserHttpRequest {
private UserSFRequest userSFRequest;
@Value("${sf.systemId}")
private String systemId;
@ -84,17 +62,21 @@ public class UserHttpRequestImpl implements UserHttpRequest {
}
public User loadRankCode(User user) {
String rankName;
if (user.getManaLevel() != null) {
rankName = user.getManaLevel();
} else if (user.getProfLevel() != null) {
rankName = user.getProfLevel();
} else if (user.getQualityLevel() != null) {
rankName = user.getQualityLevel();
} else {
//部分人员不存在职级需要调用自己维护的表格查询出职级 如果还是不存在就默认为P1
rankName = staffRankRepository.findRankNameByEmployNoAndCompanyCode(user.getEmployeeNo(), user.getCompanyCode());
if (rankName == null) {
String rankName = null;
//默认先查找职级表里的内容
Optional<List<StaffRank>> staffRank = staffRankRepository
.findRankNameByEmployNoAndJTCompany(user.getEmployeeNo(),user.getCompanyCode());
if (staffRank.isPresent() && !staffRank.get().isEmpty()) {
rankName = staffRank.get().get(0).getEmployeeLevel();
} else {
//如果表里没有维护他的职级 那么取是sf号的职级
if (user.getManaLevel() != null) {
rankName = user.getManaLevel();
} else if (user.getProfLevel() != null) {
rankName = user.getProfLevel();
} else if (user.getQualityLevel() != null) {
rankName = user.getQualityLevel();
} else {
rankName = DEFAULT_RANK_NAME;
}
}