From 8f9bc441edc06d6e5aeab90267e38d61bdb74d5c Mon Sep 17 00:00:00 2001 From: lulz1 Date: Tue, 7 May 2024 10:42:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=96=B0=E8=83=BD=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E5=B7=AE=E6=97=85=E7=94=B3=E8=AF=B7=E5=8D=95?= =?UTF-8?q?=EF=BC=8C=E6=90=BA=E7=A8=8B=E5=BC=80=E5=8D=A1=E7=9A=84bug?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E7=99=BB=E5=BD=95bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chint/domain/aggregates/user/User.java | 7 +++- .../repository/JTCompanyRepository.java | 2 ++ .../service/JTCompanyDomainService.java | 34 +++++++++++++++++-- .../repository/JTCompanyRepositoryImpl.java | 9 +++-- .../repository/StaffRankRepositoryImpl.java | 5 ++- .../jdbc/JdbcJTCompanyRepositoryImpl.java | 4 +++ .../rest/ctrip/CTripUserSaveRequest.java | 2 +- .../rest/user/UserHttpRequestImpl.java | 18 +++++----- .../java/com/chint/RouteApplicationTests.java | 8 ++--- 9 files changed, 64 insertions(+), 25 deletions(-) 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 00b5dd75..3dd51a50 100644 --- a/src/main/java/com/chint/domain/aggregates/user/User.java +++ b/src/main/java/com/chint/domain/aggregates/user/User.java @@ -84,11 +84,16 @@ public class User implements Serializable { //如果发现 用户的 部门信息为空, 那么直接调用 sf查询 Command.of(UserSFCommand.class).user(this).sendToQueue(); } else { + boolean res = false; for (UserDepartmentInfo userDepartmentInfo : userDepartmentInfoList) { if (userDepartmentInfo.getUname() == null) { - Command.of(UserSFCommand.class).user(this).sendToQueue(); + res = true; + break; } } + if (res) { + Command.of(UserSFCommand.class).user(this).sendToQueue(); + } } if (userDepartmentInfoList == null) { throw new NotFoundException(SF_DATA_NOT_EXIST); diff --git a/src/main/java/com/chint/domain/repository/JTCompanyRepository.java b/src/main/java/com/chint/domain/repository/JTCompanyRepository.java index a9b12214..c6e2c7d1 100644 --- a/src/main/java/com/chint/domain/repository/JTCompanyRepository.java +++ b/src/main/java/com/chint/domain/repository/JTCompanyRepository.java @@ -7,5 +7,7 @@ import java.util.List; public interface JTCompanyRepository { List findAll(); + List findByCompanyNameOrCompanyCode(String companyName, String companyCode); + JTCompany findByCompanyCode(String companyCode); } diff --git a/src/main/java/com/chint/domain/service/JTCompanyDomainService.java b/src/main/java/com/chint/domain/service/JTCompanyDomainService.java index 8930dcc3..6eb60095 100644 --- a/src/main/java/com/chint/domain/service/JTCompanyDomainService.java +++ b/src/main/java/com/chint/domain/service/JTCompanyDomainService.java @@ -30,14 +30,42 @@ public class JTCompanyDomainService { jtCompanyRepository.findAll(); } - public boolean ifCompanyInJT(String companyName, String companyCode) { List all = jtCompanyRepository.findAll(); if (companyName != null) { - return all.stream().map(JTCompany::getCompanyName).toList().contains(companyName); + return all.stream() + .map(JTCompany::getCompanyName) + .toList() + .contains(companyName); } if (companyCode != null) { - return all.stream().map(JTCompany::getCompanyCode).toList().contains(companyCode); + return all.stream() + .map(JTCompany::getCompanyCode) + .toList() + .contains(companyCode); + } + 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) { + return all.stream() + .filter(it -> it.getSystemCodeId().equals(systemCodeId)) + .map(JTCompany::getCompanyName) + .toList() + .contains(companyName); + } + if (companyCode != null) { + return all.stream() + .filter(it -> it.getSystemCodeId().equals(systemCodeId)) + .map(JTCompany::getCompanyCode) + .toList() + .contains(companyCode); } return false; } diff --git a/src/main/java/com/chint/infrastructure/repository/JTCompanyRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/JTCompanyRepositoryImpl.java index 90bdda2f..b9cdd09a 100644 --- a/src/main/java/com/chint/infrastructure/repository/JTCompanyRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/JTCompanyRepositoryImpl.java @@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Repository; -import java.util.ArrayList; import java.util.List; @Repository @@ -21,7 +20,13 @@ public class JTCompanyRepositoryImpl implements JTCompanyRepository { return jdbcJTCompanyRepository.findBySystemCodeId(1L); } - @Cacheable(value = "JTCompanyByCompanyCode" , key = "#companyCode") + @Cacheable(value = "JTCompany", key = "#companyName + '-' + companyCode") + @Override + public List findByCompanyNameOrCompanyCode(String companyName, String companyCode) { + return jdbcJTCompanyRepository.findByCompanyNameOrCompanyCode(companyName, companyCode); + } + + @Cacheable(value = "JTCompanyByCompanyCode", key = "#companyCode") @Override public JTCompany findByCompanyCode(String companyCode) { return jdbcJTCompanyRepository.findByCompanyCode(companyCode); diff --git a/src/main/java/com/chint/infrastructure/repository/StaffRankRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/StaffRankRepositoryImpl.java index 2a06f747..ad292a31 100644 --- a/src/main/java/com/chint/infrastructure/repository/StaffRankRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/StaffRankRepositoryImpl.java @@ -43,10 +43,9 @@ public class StaffRankRepositoryImpl implements StaffRankRepository { @Override public Optional> findRankNameByEmployNoAndJTCompany(String employName, String companyCode) { - String tag; - if (jtCompanyDomainService.ifCompanyInJT(null, companyCode)) { + if (jtCompanyDomainService.ifCompanyInJT(null, companyCode, 1L)) { return Optional.ofNullable(jdbcStaffRankRepository.findByEmployeeNoAndTag(employName, "1")); - } else if (companyCode.equals(XN_COMPANY_CODE)) { + } else if (jtCompanyDomainService.ifCompanyInJT(null, companyCode, 1L)) { return Optional.ofNullable(jdbcStaffRankRepository.findByEmployeeNoAndTag(employName, "2")); } else { return Optional.empty(); diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcJTCompanyRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcJTCompanyRepositoryImpl.java index 47f0ca96..aa258198 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcJTCompanyRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcJTCompanyRepositoryImpl.java @@ -11,6 +11,10 @@ public interface JdbcJTCompanyRepositoryImpl extends CrudRepository findByCompanyNameOrCompanyCode(String companyName, String companyCode); + List findBySystemCodeId(Long systemCodeId); + + } 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 4731c704..5a717888 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java @@ -111,7 +111,7 @@ public class CTripUserSaveRequest implements UserSync { userNameRepository.findByEmployeeNo(user.getEmployeeNo()).ifPresentOrElse(it -> authenticationEntity.setName(it.getIdName()), () -> authenticationEntity.setName(user.getName())); authenticationEntity.setEmployeeID(user.getEmployeeNo()); - authenticationEntity.setValid(user.getWorkStatus() == null ? 'A' : 'I'); + authenticationEntity.setValid('A'); authenticationEntity.setSubAccountName(subAccountName); return authenticationEntity; } diff --git a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java index 1a99c06a..95667f48 100644 --- a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java +++ b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java @@ -78,11 +78,7 @@ public class UserHttpRequestImpl implements UserHttpRequest { //这个方法 逻辑进行修改 , 首先通过查询 表的方式 , 如果部分数据为空 , 那么就要查询 sf信息获取 user.loadInfoFromDept(); //根据员工的登录信息,来创建fssc基础跳转信息 - List userDepartmentInfoList = user.getUserDepartmentInfoList() - .stream() - .filter(it -> jtCompanyDomainService.ifCompanyInJT(null, it.getCompanyCode())) - .toList(); - for (UserDepartmentInfo userDepartmentInfo : userDepartmentInfoList) { + for (UserDepartmentInfo userDepartmentInfo : user.getUserDepartmentInfoList()) { String sysCode = jtCompanyDomainService.findSystemCodeByCompanyCode(userDepartmentInfo.getCompanyCode()); user.addFssc(userDepartmentInfo.getCompanyName(), sysCode); } @@ -139,18 +135,22 @@ public class UserHttpRequestImpl implements UserHttpRequest { } List userSFDataFromOpenApi = userSFRequest .getUserSFDataFromOpenApi(user); + if (userSFDataFromOpenApi == null) { return null; } + + if(!userSFDataFromOpenApi.isEmpty()){ + for (UserDataDTO userDataDTO : userSFDataFromOpenApi) { + user.addDeptInfo(userDataDTO); + } + } + List fromJson = userSFDataFromOpenApi .stream() .filter(userDataDTO -> userDataDTO.getStatus().equals("A")) .toList(); - for (UserDataDTO userDataDTO : fromJson) { - user.addDeptInfo(userDataDTO); - } - if(fromJson.isEmpty()){ user.setStatus(0); user.loadInfoFromDept(); diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index ca48058a..1bfa6574 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -270,22 +270,18 @@ class RouteApplicationTests { @Test void loginSign() { - String sfno = "240402087"; + String sfno = "191202027"; String syscode = "FSSC"; String billcode = "CLSQ240225000099"; String companycode = "正泰集团股份有限公司"; String timespan = "1708908662738"; String s = Digest.md5(sfno + syscode + billcode + companycode + LOGIN_SECRET_KEY + timespan); System.out.println(s); -// log.info("info"); -// log.trace("trace"); -// log.trace("trace"); -// log.trace("trace"); } @Test void loginSignProd() { - String sfno = "240402087"; + String sfno = "200308003"; String syscode = "FSSC"; String billcode = "CLSQ240225000099"; String companycode = "正泰集团股份有限公司";