fix:修复高压结算查询数据不完全的问题

This commit is contained in:
lulz1 2024-07-16 15:36:59 +08:00
parent 4f64d16ca4
commit ab7e5162c2
12 changed files with 227 additions and 25 deletions

View File

@ -0,0 +1,20 @@
package com.chint.domain.aggregates.standards;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
import java.io.Serial;
import java.io.Serializable;
@Data
@Table("rank_order")
public class RanksOrder implements Serializable {
@Serial
private static final long serialVersionUID = 978169273211358470L;
@Id
private Long id;
private String rankName;
private Integer rankOrderValue;
private String extension;
}

View File

@ -0,0 +1,20 @@
package com.chint.domain.aggregates.standards;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
import java.io.Serial;
import java.io.Serializable;
@Data
@Table("rank_org_code")
public class RanksOrgCode implements Serializable {
@Serial
private static final long serialVersionUID = 1231251689922134470L;
@Id
private Long id;
private String parentOrgCode;
private String orgCode;
private String extension;
}

View File

@ -0,0 +1,10 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.standards.RanksOrder;
import java.util.List;
import java.util.Set;
public interface RanksOrderRepository {
List<RanksOrder> findByRankNameIn(Set<String> rankNames);
}

View File

@ -0,0 +1,9 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.standards.RanksOrgCode;
import java.util.Optional;
public interface RanksOrgCodeRepository {
Optional<RanksOrgCode> findByOrgCode(String orgCode);
}

View File

@ -0,0 +1,69 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.standards.RanksOrder;
import com.chint.domain.repository.RanksOrderRepository;
import com.chint.infrastructure.echo_framework.repository.AbstractGenericRepository;
import com.chint.infrastructure.echo_framework.repository.GenericCacheRepository;
import com.chint.infrastructure.repository.jdbc.JdbcRanksOrderRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@Repository
public class RanksOrderRepositoryImpl extends AbstractGenericRepository<RanksOrder, Long> implements RanksOrderRepository {
@Autowired
private JdbcRanksOrderRepository jdbcRanksOrderRepository;
@Autowired
private RedisTemplate<String, RanksOrder> redisTemplate;
@Autowired
private RedisTemplate<String, Long> redisTemplateId;
@Autowired
public RanksOrderRepositoryImpl(RedisTemplate<String, RanksOrder> redisTemplate,
RedisTemplate<String, Long> redisTemplateId) {
super(new GenericCacheRepository<>(redisTemplate, redisTemplateId, RanksOrder.class, Long.class));
}
@Override
public List<RanksOrder> findByRankNameIn(Set<String> rankNames) {
return findByFieldsIn("RankName",
rankNames,
RanksOrder::getRankName,
(set) -> jdbcRanksOrderRepository.findByRankNameIn(set.stream().toList()));
}
@Override
public RanksOrder save(RanksOrder entity) {
return jdbcRanksOrderRepository.save(entity);
}
@Override
protected Optional<RanksOrder> findByIdFromDB(Long aLong) {
return jdbcRanksOrderRepository.findById(aLong);
}
@Override
protected List<RanksOrder> findByIdsInFromDB(Set<Long> longs) {
return jdbcRanksOrderRepository.findByIdIn(longs.stream().toList());
}
@Override
protected Long getPrimaryKeys(RanksOrder entity) {
return entity.getId();
}
@Override
protected String getPrefix() {
return "RanksOrder";
}
@Override
protected String beforeUpdateCache() {
return "";
}
}

View File

@ -0,0 +1,28 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.standards.RanksOrgCode;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.RanksOrgCodeRepository;
import com.chint.infrastructure.repository.jdbc.JdbcRanksOrgCodeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public class RanksOrgCodeRepositoryImpl implements RanksOrgCodeRepository {
@Autowired
private JdbcRanksOrgCodeRepository jdbcRanksOrgCodeRepository;
@Cacheable(value = "Ranks::OrgCode", key = "#orgCode")
@Override
public Optional<RanksOrgCode> findByOrgCode(String orgCode) {
return jdbcRanksOrgCodeRepository.findByOrgCode(orgCode).stream().findFirst();
}
}

View File

@ -0,0 +1,15 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.standards.RanksOrder;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface JdbcRanksOrderRepository extends CrudRepository<RanksOrder, Long> {
List<RanksOrder> findByRankNameIn(List<String> rankNames);
List<RanksOrder> findByIdIn(List<Long> rankIds);
}

View File

@ -0,0 +1,13 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.standards.RanksOrgCode;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface JdbcRanksOrgCodeRepository extends CrudRepository<RanksOrgCode, Long> {
List<RanksOrgCode> findByOrgCode(String orgCode);
}

View File

@ -1,7 +1,6 @@
package com.chint.interfaces.rest.data_center.user; package com.chint.interfaces.rest.data_center.user;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.aggregates.user.UserCustomCode;
public interface UserHttpRequest { public interface UserHttpRequest {
User loadUserInfo(User user); User loadUserInfo(User user);
@ -10,5 +9,7 @@ public interface UserHttpRequest {
User loadUserDeptInfo(User user); User loadUserDeptInfo(User user);
User loadRankCode(User user);
String belongDeport(String employeeNo, String accountCompanyName); String belongDeport(String employeeNo, String accountCompanyName);
} }

View File

@ -5,14 +5,14 @@ import com.chint.application.commands.UserDisabledCommand;
import com.chint.application.commands.UserLoginCommand; import com.chint.application.commands.UserLoginCommand;
import com.chint.application.commands.UserSFCommand; import com.chint.application.commands.UserSFCommand;
import com.chint.domain.aggregates.standards.Ranks; import com.chint.domain.aggregates.standards.Ranks;
import com.chint.domain.aggregates.standards.RanksOrder;
import com.chint.domain.aggregates.standards.RanksOrgCode;
import com.chint.domain.aggregates.standards.StaffRank; import com.chint.domain.aggregates.standards.StaffRank;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.aggregates.user.UserDepartmentInfo; import com.chint.domain.aggregates.user.UserDepartmentInfo;
import com.chint.domain.exceptions.AuthException; import com.chint.domain.exceptions.AuthException;
import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.JTCompanyRepository; import com.chint.domain.repository.*;
import com.chint.domain.repository.StaffRankRepository;
import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.JTCompanyDomainService; import com.chint.domain.service.JTCompanyDomainService;
import com.chint.domain.service.RankDomainService; import com.chint.domain.service.RankDomainService;
import com.chint.infrastructure.constant.SFConstant; import com.chint.infrastructure.constant.SFConstant;
@ -25,8 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.*;
import java.util.Optional;
import static com.chint.infrastructure.constant.CommonMessageConstant.EMPLOYEE_NO_NOT_EXIST; import static com.chint.infrastructure.constant.CommonMessageConstant.EMPLOYEE_NO_NOT_EXIST;
import static com.chint.infrastructure.constant.RankConstant.DEFAULT_RANK_NAME; import static com.chint.infrastructure.constant.RankConstant.DEFAULT_RANK_NAME;
@ -64,6 +63,12 @@ public class UserHttpRequestImpl implements UserHttpRequest {
@Autowired @Autowired
private JTCompanyRepository jtCompanyRepository; private JTCompanyRepository jtCompanyRepository;
@Autowired
private RanksOrderRepository ranksOrderRepository;
@Autowired
private RanksOrgCodeRepository ranksOrgCodeRepository;
@Value("${sf.systemId}") @Value("${sf.systemId}")
private String systemId; private String systemId;
@ -96,13 +101,7 @@ public class UserHttpRequestImpl implements UserHttpRequest {
} }
public User loadRankCode(User user) { public User loadRankCode(User user) {
String rankName = null; String rankName;
//默认先查找职级表里的内容
Optional<List<StaffRank>> staffRank = staffRankRepository
.findRankNameByEmployNoAndJTCompany(user.getEmployeeNo(), user.getCompanyCode());
if (staffRank.isPresent() && !staffRank.get().isEmpty()) {
rankName = staffRank.get().get(0).getEmployeeLevel();
} else {
//如果表里没有维护他的职级 那么取是sf号的职级 //如果表里没有维护他的职级 那么取是sf号的职级
if (user.getManaLevel() != null) { if (user.getManaLevel() != null) {
rankName = user.getManaLevel(); rankName = user.getManaLevel();
@ -113,8 +112,26 @@ public class UserHttpRequestImpl implements UserHttpRequest {
} else { } else {
rankName = DEFAULT_RANK_NAME; rankName = DEFAULT_RANK_NAME;
} }
//默认先查找职级表里的内容
Optional<StaffRank> staffRank = staffRankRepository
.findRankNameByEmployNoAndJTCompany(user.getEmployeeNo(), user.getCompanyCode())
.flatMap(it -> it.stream().findFirst());
if (staffRank.isPresent()) {
rankName = staffRank.get().getEmployeeLevel();
//如果存在自定义职级那么就开始比较职级大小
//这里执行rank排序规则
Optional<RanksOrder> max = ranksOrderRepository
.findByRankNameIn(Set.of(rankName, staffRank.get().getEmployeeLevel()))
.stream()
.filter(Objects::nonNull)
.max(Comparator.comparing(RanksOrder::getRankOrderValue));
if (max.isPresent()) {
rankName = max.get().getRankName();
} }
Ranks ranks = rankDomainService.queryRanks(rankName, user.getCompanyCode()); }
Optional<RanksOrgCode> orgCode = ranksOrgCodeRepository.findByOrgCode(user.getCompanyCode());
Ranks ranks = rankDomainService.queryRanks(rankName, orgCode.isPresent() ? orgCode.get().getParentOrgCode() : user.getCompanyCode());
if (ranks == null) { if (ranks == null) {
if (rankName.contains("L")) { if (rankName.contains("L")) {
rankName = rankName.replace("L", "P"); rankName = rankName.replace("L", "P");

View File

@ -821,7 +821,7 @@ public class LYTest {
@Test @Test
void searchTrain() { void searchTrain() {
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24062077869838419"); TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24061677314144436");
Gson gson = new Gson(); Gson gson = new Gson();
String json = gson.toJson(trainOrderDetail); String json = gson.toJson(trainOrderDetail);
System.out.println(json); System.out.println(json);

View File

@ -346,10 +346,10 @@ class RouteApplicationTests {
@Test @Test
void testPushBatch() throws UnsupportedEncodingException { void testPushBatch() throws UnsupportedEncodingException {
List<String> billcodeList = List.of("CLS24070300047"); List<String> billcodeList = List.of("CLS24070800088");
List<String> sfnoList = List.of( List<String> sfnoList = List.of(
"220208019" "221213065"
); );
System.out.println(billcodeList.size()); System.out.println(billcodeList.size());