fix:修复分页查询时因为用户数据重复问题

This commit is contained in:
lulz1 2024-07-10 17:13:45 +08:00
parent cd1e8fd52a
commit 0e564a5b16
6 changed files with 57 additions and 24 deletions

View File

@ -32,7 +32,7 @@ public class LegExtensionField implements Serializable {
private String originDescription; private String originDescription;
private String destinationDescription; private String destinationDescription;
private String estimatedAmount; private String estimatedAmount;
private String extension;
public LegExtensionField addLocationIdsAsString(List<Long> locationIds) { public LegExtensionField addLocationIdsAsString(List<Long> locationIds) {
this.locationIds = Arrays.toString(locationIds.toArray()); this.locationIds = Arrays.toString(locationIds.toArray());

View File

@ -7,17 +7,12 @@ import lombok.Data;
public class LegData { public class LegData {
public final String legId; public final String legId;
public final Integer legType; public final Integer legType;
@ApiModelProperty("变更理由") @ApiModelProperty("变更理由")
private final String changeReason; private final String changeReason;
public final String startTime; public final String startTime;
public String endTime; public String endTime;
public final Long originId; public final Long originId;
public final Long destinationId; public final Long destinationId;
public String currencyType; public String currencyType;

View File

@ -20,4 +20,6 @@ public class LegExtensionFieldData {
private String estimatedAmount; private String estimatedAmount;
@ApiModelProperty("地理位置id列表") @ApiModelProperty("地理位置id列表")
private List<Long> locationIds; private List<Long> locationIds;
@ApiModelProperty("扩展字段")
public String extension;
} }

View File

@ -82,7 +82,7 @@ public class RouteCacheService {
// return routeListByIds; // return routeListByIds;
} else { } else {
List<RouteOrder> routeOrders = jdbcRouteRepository.findByUserIdOrApproveOrderNo_Creator(employeeNo, employeeNo); List<RouteOrder> routeOrders = jdbcRouteRepository.findByUserIdOrApproveOrderNo_Creator(employeeNo, employeeNo);
CompletableFuture.runAsync(()->{ CompletableFuture.runAsync(() -> {
routeCacheManage.getRouteIdsByEmployeeNo(employeeNo, routeOrders, null); routeCacheManage.getRouteIdsByEmployeeNo(employeeNo, routeOrders, null);
routeOrders.forEach(this::updateRouteCache); routeOrders.forEach(this::updateRouteCache);
}); });
@ -202,7 +202,7 @@ public class RouteCacheService {
List<Long> routeIds = routeCacheManage.getRouteIdsByEmployeeNo(userId, null, null); List<Long> routeIds = routeCacheManage.getRouteIdsByEmployeeNo(userId, null, null);
if (routeIds == null || routeIds.size() <= 2) { if (routeIds == null || routeIds.size() <= 2) {
List<RouteOrder> routeOrders = preloadUserRoutes(userId); List<RouteOrder> routeOrders = preloadUserRoutes(userId);
routeIds = routeOrders.stream().map(RouteOrder::getRouteId).toList(); routeIds = routeOrders.stream().filter(Objects::nonNull).map(RouteOrder::getRouteId).toList();
} }
if (!routeIds.contains(routeId)) { if (!routeIds.contains(routeId)) {
List<Long> newRouteIds = new ArrayList<>(routeIds); List<Long> newRouteIds = new ArrayList<>(routeIds);
@ -233,9 +233,11 @@ public class RouteCacheService {
.map(RouteOrder::getRouteId).toList(); .map(RouteOrder::getRouteId).toList();
List<Long> notInCacheRouteIds = routeIds.stream().filter(it -> !inCacheRouteIds.contains(it)) List<Long> notInCacheRouteIds = routeIds.stream().filter(it -> !inCacheRouteIds.contains(it))
.toList(); .toList();
if(!notInCacheRouteIds.isEmpty()) {
List<RouteOrder> byRouteIdIn = jdbcRouteRepository.findByRouteIdIn(notInCacheRouteIds); List<RouteOrder> byRouteIdIn = jdbcRouteRepository.findByRouteIdIn(notInCacheRouteIds);
CompletableFuture.runAsync(() -> byRouteIdIn.forEach(this::updateRouteCache)); CompletableFuture.runAsync(() -> byRouteIdIn.forEach(this::updateRouteCache));
inCacheRouteOrder.addAll(byRouteIdIn); inCacheRouteOrder.addAll(byRouteIdIn);
}
return inCacheRouteOrder; return inCacheRouteOrder;
} else { } else {
return List.of(); return List.of();
@ -243,6 +245,9 @@ public class RouteCacheService {
} }
private void updateRouteCache(RouteOrder routeOrder) { private void updateRouteCache(RouteOrder routeOrder) {
if(routeOrder.getOrderStatus() == null){
routeOrder.reloadStatus();
}
routeCacheManage.invalidateRouteCache(routeOrder.getRouteId()); routeCacheManage.invalidateRouteCache(routeOrder.getRouteId());
routeCacheManage.cacheRouteOrder(routeOrder); routeCacheManage.cacheRouteOrder(routeOrder);
} }

View File

@ -86,7 +86,7 @@ public class UserRepositoryImpl extends AbstractGenericRepository<User, Long> im
public List<User> findByEmployeeNoIn(Set<String> employeeNoSet) { public List<User> findByEmployeeNoIn(Set<String> employeeNoSet) {
return this.findByFieldsIn("EmployeeNo", employeeNoSet, return this.findByFieldsIn("EmployeeNo", employeeNoSet,
User::getEmployeeNo, User::getEmployeeNo,
(set) -> jdbcUserRepository.findByEmployeeNoIn(employeeNoSet)); (set) -> jdbcUserRepository.findByEmployeeNoIn(set));
} }
@Override @Override

View File

@ -3,6 +3,7 @@ package com.chint;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.chint.application.dtos.AddLegData;
import com.chint.application.in.RankController; import com.chint.application.in.RankController;
import com.chint.application.out.LoginController; import com.chint.application.out.LoginController;
import com.chint.application.services.login.strategy.PailaLoginStrategy; import com.chint.application.services.login.strategy.PailaLoginStrategy;
@ -313,9 +314,9 @@ class RouteApplicationTests {
@Test @Test
void loginSign() { void loginSign() {
String sfno = "211213002"; String sfno = "220222190";
String syscode = "FSSC"; String syscode = "FSSC";
String billcode = "CLSQ240225000099"; String billcode = "CLSQ240225000101";
String companycode = "正泰集团股份有限公司"; String companycode = "正泰集团股份有限公司";
String timespan = "1708908662738"; String timespan = "1708908662738";
String s = Digest.md5(sfno + syscode + billcode + companycode + LOGIN_SECRET_KEY + timespan); String s = Digest.md5(sfno + syscode + billcode + companycode + LOGIN_SECRET_KEY + timespan);
@ -324,7 +325,7 @@ class RouteApplicationTests {
@Test @Test
void loginSignProd() { void loginSignProd() {
String sfno = "230615020"; String sfno = "240522018";
String syscode = "FSSC"; String syscode = "FSSC";
String billcode = "CLSQ240225000099"; String billcode = "CLSQ240225000099";
String companycode = "正泰集团股份有限公司"; String companycode = "正泰集团股份有限公司";
@ -335,20 +336,26 @@ class RouteApplicationTests {
} }
@Test
void deleteRouteOrder2() {
routeRepository.deleteById(50519L);
}
@Test @Test
void testPushBatch() throws UnsupportedEncodingException { void testPushBatch() throws UnsupportedEncodingException {
List<String> billcodeList = List.of("CLS24062500065", List<String> billcodeList = List.of("CLS24070100346",
"CLS24062400348", "CLS24070100358",
"CLS24062500073", "CLS24070100472",
"CLS24062500207"); "CLS24070100474",
"CLS24063000266");
List<String> sfnoList = List.of( List<String> sfnoList = List.of(
"220915110", "220524027",
"220719073", "220506052",
"230627119", "180605050",
"220802056" "220621032",
"220630159"
); );
System.out.println(billcodeList.size()); System.out.println(billcodeList.size());
@ -376,6 +383,30 @@ class RouteApplicationTests {
} }
} }
@Test
void addLegToTempRoute() {
String url = "https://trip.chint.com/api/order/leg/add";
List<String> billcodeList = List.of("CLS24070100346",
"CLS24070100358",
"CLS24070100472",
"CLS24070100474",
"CLS24063000266");
Gson gson = new Gson();
for (String billcode : billcodeList) {
String postStr = String.format(
"""
{"routeId":null,"sysCode":"ANFSSC","fakeOrderNo":"%s","legData":{"legType":3,"startTime":"2024-07-04 00:00:00","endTime":"2024-07-05 00:00:00","legExtensionFieldData":{"amountType":3,"estimatedAmount":"0.00","locationIds":[321,317]}},"ifApprove":0}
""", billcode);
Result post = postRequest.post("token",
"""
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJFbXBsb3llZU5vIiwiaWF0IjoxNzIwNTc3MjI5LCJleHAiOjE3MjA1ODgwMjksImVtcGxveWVlTGV2ZWwiOm51bGwsImNvbXBhbnlDb2RlIjoiQTMwMDAwMDAxIiwicmFua0NvZGUiOiJKVF9TVEFOREFSRF9MRVZFTF9GT1VSIiwiZnNzY1N5c3RlbUxpc3QiOiJbe1wic3lzdGVtTmFtZVwiOlwi5rWZ5rGf5q2j5rOw55S15Zmo6IKh5Lu95pyJ6ZmQ5YWs5Y-4XCIsXCJzeXN0ZW1Db2RlXCI6XCJGU1NDXCIsXCJjb21wYW55Q29kZVwiOlwiQTMwMDAwMDAxXCJ9XSIsInBob25lTnVtYmVyIjoiMTU4NTcxOTMzNjUiLCJuYW1lIjoi5Y2i6bqf5ZOyIiwiZW1wbG95ZWVObyI6IjIzMDYxNTAyMCIsInVzZXJJZCI6MSwidXNlckxvZ2luUGFyYW0iOiJ7XCJzZm5vXCI6XCIyMzA2MTUwMjBcIixcInN5c2NvZGVcIjpcIkZTU0NcIixcImJpbGxjb2RlXCI6XCJcIixcImNvbXBhbnlDb2RlXCI6XCJcIixcInRpbWVzcGFuXCI6XCIxNzIwNTc3MjI4NTIyXCJ9IiwiZW1haWwiOm51bGwsInN0YW5kYXJkTGV2ZWwiOiJKVF9TVEFOREFSRF9MRVZFTF9GT1VSIn0.UQMdGCBT8ZUPvbyLiyr_SvLw4x7HmHQ0RvJp8qepemA
"""
, url, gson.fromJson(postStr, AddLegData.class), Result.class);
System.out.println(post);
}
}
// @Test // @Test
void queryUserInfo() { void queryUserInfo() {
User user2 = User.withEmployeeNo("180101001"); User user2 = User.withEmployeeNo("180101001");