同步代码
This commit is contained in:
parent
6001abe2b0
commit
0c3eaadbb9
5
pom.xml
5
pom.xml
|
@ -93,6 +93,11 @@
|
||||||
<artifactId>spring-boot-starter-cache</artifactId>
|
<artifactId>spring-boot-starter-cache</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>easyexcel</artifactId>
|
<artifactId>easyexcel</artifactId>
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.chint.infrastructure.util.Result;
|
||||||
import com.chint.infrastructure.util.StringCheck;
|
import com.chint.infrastructure.util.StringCheck;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -37,6 +38,7 @@ public class LocationController {
|
||||||
return Result.Success(SUCCESS, locationRepository.pageQuery(locationParam));
|
return Result.Success(SUCCESS, locationRepository.pageQuery(locationParam));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Cacheable(value = "LocationResByFirstLetter", key = "#locationParam")
|
||||||
@ApiOperation("根据查询词查询地理信息")
|
@ApiOperation("根据查询词查询地理信息")
|
||||||
@PostMapping("/query/word")
|
@PostMapping("/query/word")
|
||||||
public Result<List<LocationRes>> queryByFirstLetter(@RequestBody LocationParam locationParam) {
|
public Result<List<LocationRes>> queryByFirstLetter(@RequestBody LocationParam locationParam) {
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class OrderApplicationService {
|
||||||
if (order.getOrderStatus() >= ORDER_STATUS_APPROVAL) {
|
if (order.getOrderStatus() >= ORDER_STATUS_APPROVAL) {
|
||||||
leg = legDomainService.addApproveEvent(leg);
|
leg = legDomainService.addApproveEvent(leg);
|
||||||
}
|
}
|
||||||
|
leg.setRouteId(routeOrder.getRouteId());
|
||||||
legRepository.save(leg);
|
legRepository.save(leg);
|
||||||
|
|
||||||
if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) {
|
if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) {
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.chint.infrastructure.config.redis;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||||
|
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnection;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
import springfox.documentation.annotations.Cacheable;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
@EnableCaching
|
||||||
|
@Configuration
|
||||||
|
@Slf4j
|
||||||
|
public class RedisConfiguration {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisConnectionFactory connectionFactory;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RedisCacheManager cacheManager() {
|
||||||
|
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
|
||||||
|
.entryTtl(Duration.ofHours(1)); // 设置缓存过期时间为1小时
|
||||||
|
return RedisCacheManager.builder(connectionFactory)
|
||||||
|
.cacheDefaults(config)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RedisTemplate redisTemplate(){
|
||||||
|
log.info("开始创建redis模板对象...");
|
||||||
|
RedisTemplate redisTemplate = new RedisTemplate();
|
||||||
|
//设置redis的连接工厂对象
|
||||||
|
RedisConnection connection = connectionFactory.getConnection();
|
||||||
|
System.out.println(connection);
|
||||||
|
redisTemplate.setConnectionFactory(connectionFactory);
|
||||||
|
//设置redis key的序列化器
|
||||||
|
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||||
|
return redisTemplate;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.chint.infrastructure.webconfig;
|
package com.chint.infrastructure.config.webconfig;
|
||||||
|
|
||||||
import com.auth0.jwt.exceptions.TokenExpiredException;
|
import com.auth0.jwt.exceptions.TokenExpiredException;
|
||||||
import com.chint.domain.aggregates.user.User;
|
import com.chint.domain.aggregates.user.User;
|
|
@ -1,6 +1,5 @@
|
||||||
package com.chint.infrastructure.webconfig;
|
package com.chint.infrastructure.config.webconfig;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
@ -12,7 +12,8 @@ import com.chint.infrastructure.constant.SFConstant;
|
||||||
import com.chint.infrastructure.util.BaseContext;
|
import com.chint.infrastructure.util.BaseContext;
|
||||||
import com.chint.infrastructure.util.StringCheck;
|
import com.chint.infrastructure.util.StringCheck;
|
||||||
import com.chint.interfaces.rest.base.PostRequest;
|
import com.chint.interfaces.rest.base.PostRequest;
|
||||||
import com.chint.interfaces.rest.user.dto.*;
|
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.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -115,71 +116,12 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
||||||
Type type = new TypeToken<List<UserDataDTO>>() {
|
Type type = new TypeToken<List<UserDataDTO>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
if (result.getData() != null) {
|
if (result.getData() != null) {
|
||||||
String companyCode = user.getCompanyCode();
|
|
||||||
if (companyCode == null) {
|
|
||||||
companyCode = BaseContext.getCurrentUser().getUserLoginParam().getCompanyCode();
|
|
||||||
}
|
|
||||||
String newCompanyCode = companyCode;
|
|
||||||
List<UserDataDTO> fromJson = gson.fromJson(result.getData().toString(), type);
|
List<UserDataDTO> fromJson = gson.fromJson(result.getData().toString(), type);
|
||||||
|
|
||||||
List<String> companyCodeList = fromJson.stream().map(UserDataDTO::getCompany).toList();
|
|
||||||
|
|
||||||
|
|
||||||
if (fromJson.size() == 1) {
|
if (fromJson.size() == 1) {
|
||||||
UserDataDTO userData = fromJson.get(0);
|
UserDataDTO userData = fromJson.get(0);
|
||||||
user.setCompanyCode(userData.getCompany());
|
loadSingleSF(userData, user);
|
||||||
user.setCompanyName(userData.getCompany_cn());
|
|
||||||
user.setWorkStatus(userData.getStatus());
|
|
||||||
user.setGender(userData.getGender());
|
|
||||||
user.setName(userData.getUname());
|
|
||||||
user.setPhoneNumber(userData.getMobilePhone());
|
|
||||||
user.setManaLevel(userData.getCust_manaLevel());
|
|
||||||
user.setProfLevel(userData.getCust_profLevel());
|
|
||||||
user.setQualityLevel(userData.getCust_qualityLevel());
|
|
||||||
if (user.getCompanyCode().equals(XN_COMPANY_CODE)) {
|
|
||||||
user.addXNFssc(FSSC_LOAD_URL, postRequest);
|
|
||||||
} else {
|
|
||||||
user.addJTFssc(FSSC_LOAD_URL, postRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user.getEmployeeNo().equals("220208013")) {
|
|
||||||
user.addXNFssc(FSSC_LOAD_URL, postRequest);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Optional<UserDataDTO> first;
|
loadBatchSF(fromJson, user);
|
||||||
//这里进行判断如果是中文字段的CompanyCode需要用中文名进行匹配
|
|
||||||
if (StringCheck.isFirstCharacterChinese(newCompanyCode)) {
|
|
||||||
first = fromJson.stream()
|
|
||||||
.filter(userData -> userData.getCompany_cn().equals(newCompanyCode))
|
|
||||||
.findFirst();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
first = fromJson.stream()
|
|
||||||
.filter(userData -> userData.getCompany().equals(newCompanyCode))
|
|
||||||
.findFirst();
|
|
||||||
}
|
|
||||||
first.ifPresent(
|
|
||||||
userData -> {
|
|
||||||
user.setCompanyCode(userData.getCompany());
|
|
||||||
user.setWorkStatus(userData.getStatus());
|
|
||||||
user.setGender(userData.getGender());
|
|
||||||
user.setName(userData.getUname());
|
|
||||||
user.setPhoneNumber(userData.getMobilePhone());
|
|
||||||
user.setCompanyName(userData.getCompany_cn());
|
|
||||||
}
|
|
||||||
);
|
|
||||||
fromJson.stream()
|
|
||||||
.filter(userData -> userData.getUserId().equals(userData.getPersonIdExternal()))
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(userData -> {
|
|
||||||
user.setManaLevel(userData.getCust_manaLevel());
|
|
||||||
user.setProfLevel(userData.getCust_profLevel());
|
|
||||||
user.setQualityLevel(userData.getCust_qualityLevel());
|
|
||||||
});
|
|
||||||
user.addJTFssc(FSSC_LOAD_URL, postRequest);
|
|
||||||
if (companyCodeList.contains(XN_COMPANY_CODE) || user.getEmployeeNo().equals("220208013")) {
|
|
||||||
user.addXNFssc(FSSC_LOAD_URL, postRequest);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
} else {
|
} else {
|
||||||
|
@ -187,10 +129,73 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private User loadSingleSF(List<UserDataDTO> userDataDTOS, User user){
|
private User loadSingleSF(UserDataDTO userData, User user) {
|
||||||
|
user.setCompanyCode(userData.getCompany());
|
||||||
|
user.setCompanyName(userData.getCompany_cn());
|
||||||
|
user.setWorkStatus(userData.getStatus());
|
||||||
|
user.setGender(userData.getGender());
|
||||||
|
user.setName(userData.getUname());
|
||||||
|
user.setPhoneNumber(userData.getMobilePhone());
|
||||||
|
user.setManaLevel(userData.getCust_manaLevel());
|
||||||
|
user.setProfLevel(userData.getCust_profLevel());
|
||||||
|
user.setQualityLevel(userData.getCust_qualityLevel());
|
||||||
|
|
||||||
|
if (user.getCompanyCode().equals(XN_COMPANY_CODE)) {
|
||||||
|
user.addXNFssc(FSSC_LOAD_URL, postRequest);
|
||||||
|
}
|
||||||
|
//如果用户的公司编码属于集团 ,那么加入集团财务共享跳转地址
|
||||||
|
if (jtCompanyDomainService.ifCompanyInJT(null, userData.getCompany())) {
|
||||||
|
user.addJTFssc(FSSC_LOAD_URL, postRequest);
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
private User loadBatchSF(List<UserDataDTO> userDataDTOS, User user) {
|
||||||
|
//从用户身上获取companyCode ,
|
||||||
|
String companyCode = user.getCompanyCode();
|
||||||
|
if (companyCode == null) {
|
||||||
|
//如果为null,说明用户是登录操作 ,那么从登录参数中获取 companyCode
|
||||||
|
companyCode = BaseContext.getCurrentUser().getUserLoginParam().getCompanyCode();
|
||||||
|
}
|
||||||
|
String newCompanyCode = companyCode;
|
||||||
|
List<String> companyCodeList = userDataDTOS.stream().map(UserDataDTO::getCompany).toList();
|
||||||
|
Optional<UserDataDTO> first;
|
||||||
|
if (StringCheck.isFirstCharacterChinese(newCompanyCode)) {
|
||||||
|
first = userDataDTOS.stream()
|
||||||
|
.filter(userData -> userData.getCompany_cn().equals(newCompanyCode))
|
||||||
|
.findFirst();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
first = userDataDTOS.stream()
|
||||||
|
.filter(userData -> userData.getCompany().equals(newCompanyCode))
|
||||||
|
.findFirst();
|
||||||
|
}
|
||||||
|
first.ifPresent(
|
||||||
|
userData -> {
|
||||||
|
user.setCompanyCode(userData.getCompany());
|
||||||
|
user.setWorkStatus(userData.getStatus());
|
||||||
|
user.setGender(userData.getGender());
|
||||||
|
user.setName(userData.getUname());
|
||||||
|
user.setPhoneNumber(userData.getMobilePhone());
|
||||||
|
user.setCompanyName(userData.getCompany_cn());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
userDataDTOS.stream()
|
||||||
|
.filter(userData -> userData.getUserId().equals(userData.getPersonIdExternal()))
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(userData -> {
|
||||||
|
user.setManaLevel(userData.getCust_manaLevel());
|
||||||
|
user.setProfLevel(userData.getCust_profLevel());
|
||||||
|
user.setQualityLevel(userData.getCust_qualityLevel());
|
||||||
|
});
|
||||||
|
|
||||||
|
//如果用户的公司编码属于集团 ,那么加入集团财务共享跳转地址
|
||||||
|
if (jtCompanyDomainService.ifCompanyInJT(null, user.getCompanyCode())) {
|
||||||
|
user.addJTFssc(FSSC_LOAD_URL, postRequest);
|
||||||
|
}
|
||||||
|
if (companyCodeList.contains(XN_COMPANY_CODE)) {
|
||||||
|
user.addXNFssc(FSSC_LOAD_URL, postRequest);
|
||||||
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,12 @@ chint:
|
||||||
username: tripbook
|
username: tripbook
|
||||||
password: W@Xgf25d&lRk*L0X#
|
password: W@Xgf25d&lRk*L0X#
|
||||||
url: https://gxdev03.chint.com/businesstravelhome/
|
url: https://gxdev03.chint.com/businesstravelhome/
|
||||||
|
redis:
|
||||||
|
host: 10.10.103.131
|
||||||
|
port: 6379
|
||||||
|
password: Worktask@Redis2023
|
||||||
|
database: 4
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
org.springframework.jdbc.core.JdbcTemplate: DEBUG
|
org.springframework.jdbc.core.JdbcTemplate: DEBUG
|
||||||
|
|
|
@ -11,7 +11,11 @@ chint:
|
||||||
username: tripbookpro
|
username: tripbookpro
|
||||||
password: W@Xbf25d&lG5k*L01X#
|
password: W@Xbf25d&lG5k*L01X#
|
||||||
url: https://trip.chint.com/
|
url: https://trip.chint.com/
|
||||||
|
redis:
|
||||||
|
host: 10.10.103.131
|
||||||
|
port: 6379
|
||||||
|
password: Worktask@Redis2023
|
||||||
|
database: 4
|
||||||
#正式
|
#正式
|
||||||
ly:
|
ly:
|
||||||
appId: zhengtai
|
appId: zhengtai
|
||||||
|
|
|
@ -23,6 +23,12 @@ chint:
|
||||||
username: tripbook
|
username: tripbook
|
||||||
password: W@Xgf25d&lRk*L0X#
|
password: W@Xgf25d&lRk*L0X#
|
||||||
url: https://gxdev03.chint.com/businesstravelhome/
|
url: https://gxdev03.chint.com/businesstravelhome/
|
||||||
|
redis:
|
||||||
|
host: 10.10.103.131
|
||||||
|
port: 6379
|
||||||
|
password: Worktask@Redis2023
|
||||||
|
database: 4
|
||||||
|
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
|
|
|
@ -6,4 +6,9 @@ spring:
|
||||||
url: jdbc:mysql://${chint.datasource.host}:${chint.datasource.port}/${chint.datasource.database}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
url: jdbc:mysql://${chint.datasource.host}:${chint.datasource.port}/${chint.datasource.database}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||||
username: ${chint.datasource.username}
|
username: ${chint.datasource.username}
|
||||||
password: ${chint.datasource.password}
|
password: ${chint.datasource.password}
|
||||||
|
data:
|
||||||
|
redis:
|
||||||
|
host: ${chint.redis.host}
|
||||||
|
port: ${chint.redis.port}
|
||||||
|
password: ${chint.redis.password}
|
||||||
|
database: ${chint.redis.database}
|
||||||
|
|
Loading…
Reference in New Issue