| 
						
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -1,5 +1,14 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				package com.sq.customization.util;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.io.File;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.util.HashMap;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.util.Map;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import com.alibaba.excel.EasyExcel;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import com.alibaba.excel.context.AnalysisContext;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import com.alibaba.excel.event.AnalysisEventListener;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import com.sq.customization.bean.DesignPartBean;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				public class RangeAdjuster {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public static String adjustRange(String range) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (range == null || range.trim().isEmpty()) {
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -75,12 +84,61 @@ public class RangeAdjuster {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            return range; // 不支持的格式,返回原字符串
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private static void readExcel(File excelfile,int start_rownum,int idcol2,int dongtaicol) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    	// 自定义监听器
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        AnalysisEventListener<Map<Integer, String>> listener = new AnalysisEventListener<Map<Integer, String>>() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            @Override
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            public void invoke(Map<Integer, String> rowData, AnalysisContext context) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            	String id = rowData.get(idcol2-1) != null ? rowData.get(idcol2-1) : "";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                String dongtai = rowData.get(dongtaicol-1) != null ? rowData.get(dongtaicol-1) : "";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				               String key = id;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				               System.out.println(id+dongtai);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                if (!DesignPartBeanMap.containsKey(key)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    DesignPartBean bean = new DesignPartBean();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    // 设置值,确保不会为 null
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        // 使用正则表达式分隔符 NM, N.M, N·M(不区分大小写)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    	System.out.println(dongtai);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        System.out.println(split.length);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    DesignPartBeanMap.put(key, bean);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            @Override
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            public void doAfterAllAnalysed(AnalysisContext context) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                System.out.println("读取完成,共 " + DesignPartBeanMap.size() + " 行数据");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        };
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        // 执行读取
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        EasyExcel.read(excelfile, listener)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                .sheet(0) // 指定 sheet 索引
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                .headRowNumber(start_rownum)  // 从第0行开始读取(包含标题行则设为1)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                .doRead();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private static Map<String,DesignPartBean> DesignPartBeanMap = new HashMap<>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public static void main(String[] args) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        // 测试用例
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        String[] tests = {"3±1", "1-4", "1-", "-4", ""};
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        for (String test : tests) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            System.out.println("Input: " + test + " -> Output: " + adjustRange(test));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//        String[] tests = {"3±1", "1-4", "1-", "-4", ""};
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//        for (String test : tests) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//            System.out.println("Input: " + test + " -> Output: " + adjustRange(test));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    	DesignPartBeanMap.clear();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    	File file = new File("C:\\Users\\Administrator\\Desktop\\123.xlsx");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    	readExcel(file,2,13,682);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//    	for(String id:DesignPartBeanMap.keySet()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//    		
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//    	}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        String dongtai = "123±1N.M";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            // 使用正则表达式分隔符 NM, N.M, N·M(不区分大小写)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if(split!= null && split.length == 2) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								System.out.println(split[0]);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |