优化
This commit is contained in:
+2
-2
@@ -16,8 +16,8 @@ public interface OverseasQuoteMapper extends BaseMapper<OverseasQuote> {
|
|||||||
@Select("""
|
@Select("""
|
||||||
SELECT COUNT(*) FROM ll_overseas_quote
|
SELECT COUNT(*) FROM ll_overseas_quote
|
||||||
WHERE warehouse_id=#{warehouseId} AND provider_name=#{providerName} AND currency=#{currency}
|
WHERE warehouse_id=#{warehouseId} AND provider_name=#{providerName} AND currency=#{currency}
|
||||||
AND status='ACTIVE' AND id<>#{excludedId}
|
AND status='ACTIVE' AND id<>#{excludedId}
|
||||||
AND effective_start<=#{effectiveEnd} AND effective_end>=#{effectiveStart}
|
AND effective_start<=#{effectiveEnd} AND effective_end>=#{effectiveStart}
|
||||||
""")
|
""")
|
||||||
int countActiveOverlap(@Param("warehouseId") long warehouseId,
|
int countActiveOverlap(@Param("warehouseId") long warehouseId,
|
||||||
@Param("providerName") String providerName,
|
@Param("providerName") String providerName,
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ class InboundPlanControllerTest {
|
|||||||
void platformPageAllowsAllCustomersWhenCustomerIdIsOmitted() {
|
void platformPageAllowsAllCustomersWhenCustomerIdIsOmitted() {
|
||||||
InboundPlanRequests.Query query = new InboundPlanRequests.Query(1, 20, null, null, null,
|
InboundPlanRequests.Query query = new InboundPlanRequests.Query(1, 20, null, null, null,
|
||||||
null, null, null, null, null, null, null, null);
|
null, null, null, null, null, null, null, null);
|
||||||
when(service.page("100", query)).thenReturn(new PageResult<>(List.of(), 1, 20, 0, 0));
|
when(service.page(null, query)).thenReturn(new PageResult<>(List.of(), 1, 20, 0, 0));
|
||||||
|
|
||||||
controller.page(platform(), null, query);
|
controller.page(platform(), null, query);
|
||||||
|
|
||||||
|
|||||||
+18
@@ -5,9 +5,13 @@ import com.baiyue.lastleg.masterdata.quote.entity.OverseasQuote;
|
|||||||
import com.baiyue.lastleg.masterdata.quote.mapper.OverseasQuoteMapper;
|
import com.baiyue.lastleg.masterdata.quote.mapper.OverseasQuoteMapper;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
import org.springframework.test.util.ReflectionTestUtils;
|
import org.springframework.test.util.ReflectionTestUtils;
|
||||||
import org.springframework.web.server.ResponseStatusException;
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -36,4 +40,18 @@ class OverseasQuoteServiceTest {
|
|||||||
.isInstanceOf(ResponseStatusException.class)
|
.isInstanceOf(ResponseStatusException.class)
|
||||||
.hasMessageContaining("409 CONFLICT");
|
.hasMessageContaining("409 CONFLICT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void overlapQueryUsesExecutableSqlOperators() throws NoSuchMethodException {
|
||||||
|
Method method = OverseasQuoteMapper.class.getDeclaredMethod("countActiveOverlap",
|
||||||
|
long.class, String.class, String.class, LocalDate.class, LocalDate.class, long.class);
|
||||||
|
String sql = String.join(" ", method.getAnnotation(Select.class).value());
|
||||||
|
|
||||||
|
org.assertj.core.api.Assertions.assertThat(sql)
|
||||||
|
.contains("id<>#{excludedId}")
|
||||||
|
.contains("effective_start<=#{effectiveEnd}")
|
||||||
|
.contains("effective_end>=#{effectiveStart}")
|
||||||
|
.doesNotContain("<")
|
||||||
|
.doesNotContain(">");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ async function safeCleanup(context, name, action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function continueLifecycle(context, name, action) {
|
||||||
|
try {
|
||||||
|
await action()
|
||||||
|
} catch (error) {
|
||||||
|
context.assert(MODULE, `${name}生命周期执行`, null, false,
|
||||||
|
error instanceof Error ? error.message : String(error), BLOCKER)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function warehousePayload(marker, edited = false) {
|
function warehousePayload(marker, edited = false) {
|
||||||
const suffix = marker.replace(/[^A-Za-z0-9]/g, '').slice(-20).toUpperCase()
|
const suffix = marker.replace(/[^A-Za-z0-9]/g, '').slice(-20).toUpperCase()
|
||||||
return {
|
return {
|
||||||
@@ -350,10 +359,12 @@ export async function run(context) {
|
|||||||
const resource = { marker: context.marker }
|
const resource = { marker: context.marker }
|
||||||
context.createdResources.phase4OverseasMasterData = resource
|
context.createdResources.phase4OverseasMasterData = resource
|
||||||
try {
|
try {
|
||||||
await createAndVerifyPartnerWarehouse(context, resource)
|
await continueLifecycle(context, '海外报价', async () => {
|
||||||
await quoteLifecycle(context, resource)
|
await createAndVerifyPartnerWarehouse(context, resource)
|
||||||
await exchangeLifecycle(context, resource)
|
await quoteLifecycle(context, resource)
|
||||||
await vehicleLifecycle(context, resource)
|
})
|
||||||
|
await continueLifecycle(context, '月度汇率', () => exchangeLifecycle(context, resource))
|
||||||
|
await continueLifecycle(context, '车辆主数据', () => vehicleLifecycle(context, resource))
|
||||||
} finally {
|
} finally {
|
||||||
await safeCleanup(context, '海外报价', async () => {
|
await safeCleanup(context, '海外报价', async () => {
|
||||||
if (!resource.quote?.id) return
|
if (!resource.quote?.id) return
|
||||||
|
|||||||
Reference in New Issue
Block a user