TestPrefixWhitelist.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import com.mes.core.ProjectConfigManager;
  2. /**
  3. * 测试前缀白名单功能
  4. */
  5. public class TestPrefixWhitelist {
  6. public static void main(String[] args) {
  7. ProjectConfigManager pm = ProjectConfigManager.getInstance();
  8. System.out.println("=== 当前产品:" + pm.getCurrentProductId() + " ===");
  9. // 测试工件码前缀
  10. System.out.println("\n【工件码前缀白名单】");
  11. String[] productPrefixes = pm.getProductPrefixes();
  12. if (productPrefixes != null) {
  13. for (String prefix : productPrefixes) {
  14. System.out.println(" - " + prefix);
  15. }
  16. System.out.println("提示文本: " + pm.getProductPrefixHint());
  17. }
  18. // 测试冷板码前缀
  19. System.out.println("\n【冷板码前缀白名单】");
  20. String[] coldPlatePrefixes = pm.getColdPlatePrefixes();
  21. if (coldPlatePrefixes != null) {
  22. for (String prefix : coldPlatePrefixes) {
  23. System.out.println(" - " + prefix);
  24. }
  25. System.out.println("提示文本: " + pm.getColdPlatePrefixHint());
  26. }
  27. // 测试底护板码前缀
  28. System.out.println("\n【底护板码前缀白名单】");
  29. String[] bottomPlatePrefixes = pm.getBottomPlatePrefixes();
  30. if (bottomPlatePrefixes != null) {
  31. for (String prefix : bottomPlatePrefixes) {
  32. System.out.println(" - " + prefix);
  33. }
  34. System.out.println("提示文本: " + pm.getBottomPlatePrefixHint());
  35. }
  36. // 测试匹配逻辑
  37. System.out.println("\n【匹配测试】");
  38. String[] testCodes = {"+KA99123", "+KC14456", "+KB98789", "+INVALID"};
  39. for (String code : testCodes) {
  40. boolean match = pm.matchProductPrefix(code);
  41. System.out.println(" " + code + " -> " + (match ? "✓ 匹配" : "✗ 不匹配"));
  42. }
  43. // 测试冷板码匹配
  44. System.out.println("\n【冷板码匹配测试】");
  45. String[] testColdPlates = {"+KB004123", "2510456", "+INVALID"};
  46. for (String code : testColdPlates) {
  47. boolean match = pm.matchColdPlatePrefix(code);
  48. System.out.println(" " + code + " -> " + (match ? "✓ 匹配" : "✗ 不匹配"));
  49. }
  50. }
  51. }