- 在 .env.production 中新增 VITE_AUTH_COOKIE_NAME 配置项用于设置认证cookie名称 - 将 AcceptanceException.vue 中的表单标签宽度从固定90px改为自动适配 - 在 ActionDialog.vue 中将多个表单项标记为必填项并调整标签宽度为自动适配 - 重构 ActionHistory.vue 中的按钮布局结构并添加表格列样式类名 - 更新 api-contract-audit.cjs 添加生产任务和BOM相关接口的契约测试 - 修改 auth.js 使用动态认证cookie键名替换硬编码的Admin-Token - 调整系统角色授权用户页面的表单布局和表格样式类名 - 优化 ReceiptDialog Batch 组件的对话框尺寸、表单验证和分页功能
22 lines
2.2 KiB
Java
22 lines
2.2 KiB
Java
package com.ruoyi.projectdev;
|
|
import java.math.BigDecimal;
|
|
import java.io.*;
|
|
import java.util.*;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.junit.jupiter.api.Test;
|
|
import com.ruoyi.web.controller.warehouse.SupplierQuoteImport;
|
|
import com.ruoyi.warehouse.domain.*;
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
class SupplierQuoteImportTest {
|
|
private PurchaseSheet sheet(){var s=new PurchaseSheet();var b=new PurchaseBatch();b.setBatchNo("CG2026100001");s.setBatch(b);var rows=new ArrayList<PurchaseRequest>();for(long i=1;i<=3;i++){var r=new PurchaseRequest();r.setId(i);r.setProductCode(i==3?"WP2":"WP1");r.setMaterialName(i==3?"物品2":"物品1");r.setQuantity(BigDecimal.ONE);r.setPurchaseStatus(0);rows.add(r);}s.setRows(rows);return s;}
|
|
private byte[] file(String[][] data)throws Exception{try(var b=new XSSFWorkbook();var out=new ByteArrayOutputStream()){var s=b.createSheet();String[] h={"采购批次","物品编码","最终单价"};var header=s.createRow(0);for(int i=0;i<h.length;i++)header.createCell(i).setCellValue(h[i]);for(int r=0;r<data.length;r++){var row=s.createRow(r+1);for(int c=0;c<3;c++)row.createCell(c).setCellValue(data[r][c]);}b.write(out);return out.toByteArray();}}
|
|
@Test void reorderingMatchesByCodeAndFillsAllProjectLines()throws Exception{
|
|
var result=SupplierQuoteImport.preview(new ByteArrayInputStream(file(new String[][]{{"CG2026100001","WP2","2.125"},{"CG2026100001","WP1","1.123456"}})),sheet());assertNull(result.get(0).get("error"));assertEquals(List.of(3L),result.get(0).get("rowIds"));assertEquals(List.of(1L,2L),result.get(1).get("rowIds"));assertEquals(new BigDecimal("1.123456"),result.get(1).get("unitPrice"));
|
|
}
|
|
@Test void mismatchesDuplicatesBadPriceAndReceivedItemsCannotSilentlyApply()throws Exception{
|
|
var s=sheet();s.getRows().get(0).setReceivedQuantity(BigDecimal.ONE);
|
|
var result=SupplierQuoteImport.preview(new ByteArrayInputStream(file(new String[][]{{"OTHER","WP2","2"},{"CG2026100001","WP1","1"},{"CG2026100001","WP2","-1"},{"CG2026100001","WP2","3"}})),s);
|
|
assertNotNull(result.get(0).get("error"));assertNull(result.get(1).get("error"));assertEquals(List.of(2L),result.get(1).get("rowIds"));assertNotNull(result.get(2).get("error"));assertNotNull(result.get(3).get("error"));
|
|
}
|
|
}
|