package com.ruoyi.sales; import com.ruoyi.RuoYiApplication; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIf; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.test.annotation.Rollback; import org.springframework.transaction.annotation.Transactional; import javax.sql.DataSource; import java.util.Collections; import java.util.List; /** * 数据修复:当销售订单主表发货状态为「已发货」时,将下属销售产品行的产品出库审批状态 * {@code sales_ledger_product.approve_status} 统一为已出库。 *
* 与 {@code product-inventory-management-hbtmblc.sql} 中字段注释一致: * {@code sales_ledger.delivery_status} {@code tinyint(1) NOT NULL DEFAULT '0'}: * 发货状态:1-未发货,2-审批中,3-审批不通过,4-审批通过,5-已发货。本任务仅在 {@code 5-已发货} 时同步产品行。 * {@code sales_ledger_product.approve_status}:0-未出库,1-已出库,2-待审核,3-审核完成,4-审核失败。 *
* 仅处理 {@code type = 1} 的销售产品行;仅更新当前 {@code approve_status} 不是 {@code 1}(已出库)的行,避免无意义写库。 *
* 执行前必须:{@code -Druoyi.salesProductApproveStatus.sync.commit=true} 或环境变量
* {@code RUOYI_SALES_PRODUCT_APPROVE_STATUS_SYNC_COMMIT=true}。未开启时本用例跳过。
*/
@SpringBootTest(classes = RuoYiApplication.class)
class SalesProductApproveStatusSyncTest {
private static final Logger log = LoggerFactory.getLogger(SalesProductApproveStatusSyncTest.class);
/**
* 与库注释一致:1 = 已出库
*/
private static final int APPROVE_STATUS_SHIPPED_OUT = 1;
/**
* 视为「订单已发货、需同步产品状态」的主表 {@code delivery_status};默认仅 {@code 5}(已发货)。
*/
private static final List