fix:修复通过临时规划单和系统编号查询结果一直是临时单号的问题

This commit is contained in:
lulz1 2024-07-09 16:11:38 +08:00
parent 370117b2ac
commit 8a5eb3c098
3 changed files with 35 additions and 24 deletions

View File

@ -64,8 +64,9 @@ public class OrderOutController {
String billcode = queryData.getBillcode(); String billcode = queryData.getBillcode();
String sysCode = queryData.getSysCode(); String sysCode = queryData.getSysCode();
RouteOrder routeOrder = routeRepository.findTempRouteOrderBySysCodeAndBillCode(sysCode, billcode); RouteOrder routeOrder = routeRepository.findTempRouteOrderBySysCodeAndBillCode(sysCode, billcode);
if (routeOrder == null) { RouteOrder routeOrderFromDB = orderQuery.queryByBillCodeAndSysCode(billcode, sysCode);
routeOrder = orderQuery.queryByBillCodeAndSysCode(billcode, sysCode); if (routeOrderFromDB != null) {
routeOrder = routeOrderFromDB;
} }
return Result.Success(SUCCESS, orderQuery.queryRouteRes(routeOrder.reloadStatus())); return Result.Success(SUCCESS, orderQuery.queryRouteRes(routeOrder.reloadStatus()));
} }

View File

@ -58,8 +58,7 @@ public class RouteCacheService {
} }
public RouteOrder reloadRouteOrderInCache(RouteOrder routeOrder) { public RouteOrder reloadRouteOrderInCache(RouteOrder routeOrder) {
routeCacheManage.invalidateRouteCache(routeOrder.getRouteId()); updateRouteCache(routeOrder);
routeCacheManage.cacheRouteOrder(routeOrder);
return routeOrder; return routeOrder;
} }
@ -110,37 +109,46 @@ public class RouteCacheService {
} }
public RouteOrder getRouteByFakeOrderNoAndSysCode(String fakeOrderNo, String sysCode) { public RouteOrder getRouteByFakeOrderNoAndSysCode(String fakeOrderNo, String sysCode) {
Long routeId = routeCacheManage.cacheFakeOrderNoAndSysCodeMapRouteId(fakeOrderNo, sysCode, null); return getRouteByOrderNoAndSysCode(fakeOrderNo, sysCode, true);
if (routeId == null) {
routeCacheManage.invalidateFakeOrderNoAndSysCodeMapRouteId(fakeOrderNo, sysCode);
}
RouteOrder routeOrder = jdbcRouteRepository.findByApproveOrderNo_FakeOrderNoAndApproveOrderNo_SysCode(fakeOrderNo, sysCode);
if (routeOrder == null) {
routeCacheManage.invalidateFakeOrderNoAndSysCodeMapRouteId(fakeOrderNo, sysCode);
return null;
} else {
routeOrder.reloadStatus();
routeCacheManage.cacheFakeOrderNoAndSysCodeMapRouteId(fakeOrderNo, sysCode, routeOrder);
return getFromCacheOrSaveToCache(routeOrder.getRouteId());
}
} }
public RouteOrder getRouteByActualOrderNoAndSysCode(String actualOrderNo, String sysCode) { public RouteOrder getRouteByActualOrderNoAndSysCode(String actualOrderNo, String sysCode) {
Long routeId = routeCacheManage.cacheActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode, null); return getRouteByOrderNoAndSysCode(actualOrderNo, sysCode, false);
}
private RouteOrder getRouteByOrderNoAndSysCode(String orderNo, String sysCode, boolean isFake) {
Long routeId = isFake ?
routeCacheManage.cacheFakeOrderNoAndSysCodeMapRouteId(orderNo, sysCode, null) :
routeCacheManage.cacheActualOrderNoAndSysCodeMapRouteId(orderNo, sysCode, null);
if (routeId == null) { if (routeId == null) {
routeCacheManage.invalidateActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode); if (isFake) {
routeCacheManage.invalidateFakeOrderNoAndSysCodeMapRouteId(orderNo, sysCode);
} else {
routeCacheManage.invalidateActualOrderNoAndSysCodeMapRouteId(orderNo, sysCode);
}
} }
RouteOrder routeOrder = jdbcRouteRepository.findByApproveOrderNo_ActualOrderNoAndApproveOrderNo_SysCode(actualOrderNo, sysCode); RouteOrder routeOrder = isFake ?
jdbcRouteRepository.findByApproveOrderNo_FakeOrderNoAndApproveOrderNo_SysCode(orderNo, sysCode) :
jdbcRouteRepository.findByApproveOrderNo_ActualOrderNoAndApproveOrderNo_SysCode(orderNo, sysCode);
if (routeOrder == null) { if (routeOrder == null) {
routeCacheManage.invalidateActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode); if (isFake) {
return null; routeCacheManage.invalidateFakeOrderNoAndSysCodeMapRouteId(orderNo, sysCode);
} else {
routeCacheManage.invalidateActualOrderNoAndSysCodeMapRouteId(orderNo, sysCode);
}
} else { } else {
routeOrder.reloadStatus(); routeOrder.reloadStatus();
routeCacheManage.cacheActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode, routeOrder); if (isFake) {
return getFromCacheOrSaveToCache(routeOrder.getRouteId()); routeCacheManage.cacheFakeOrderNoAndSysCodeMapRouteId(orderNo, sysCode, routeOrder);
} else {
routeCacheManage.cacheActualOrderNoAndSysCodeMapRouteId(orderNo, sysCode, routeOrder);
}
updateRouteCache(routeOrder);
} }
return routeOrder;
} }
public RouteOrder getRouteByRouteOrderNo(String routeOrderNo) { public RouteOrder getRouteByRouteOrderNo(String routeOrderNo) {
Long routeId = routeCacheManage.cacheRouteOrderNoMapRouteId(routeOrderNo, null); Long routeId = routeCacheManage.cacheRouteOrderNoMapRouteId(routeOrderNo, null);
if (routeId == null) { if (routeId == null) {

View File

@ -335,6 +335,8 @@ class RouteApplicationTests {
} }
@Test @Test
void testPushBatch() throws UnsupportedEncodingException { void testPushBatch() throws UnsupportedEncodingException {
List<String> billcodeList = List.of("CLS24062500065", List<String> billcodeList = List.of("CLS24062500065",