|
|
@ -33,8 +33,13 @@ import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
|
|
|
|
import com.alibaba.excel.context.AnalysisContext;
|
|
|
|
|
|
|
|
import com.alibaba.excel.event.AnalysisEventListener;
|
|
|
|
import com.sq.customization.bean.CustRuleBean;
|
|
|
|
import com.sq.customization.bean.CustRuleBean;
|
|
|
|
import com.sq.customization.bean.DesignPartBean;
|
|
|
|
import com.sq.customization.bean.DesignPartBean;
|
|
|
|
import com.sq.customization.bean.SleeveBean;
|
|
|
|
import com.sq.customization.bean.SleeveBean;
|
|
|
@ -397,11 +402,11 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
|
|
|
|
headerRow.createCell(3).setCellValue("FCC");
|
|
|
|
headerRow.createCell(3).setCellValue("FCC");
|
|
|
|
headerRow.createCell(4).setCellValue("动态扭矩");
|
|
|
|
headerRow.createCell(4).setCellValue("动态扭矩");
|
|
|
|
headerRow.createCell(5).setCellValue("KCDS");
|
|
|
|
headerRow.createCell(5).setCellValue("KCDS");
|
|
|
|
headerRow.createCell(6).setCellValue("头部形式");
|
|
|
|
// headerRow.createCell(6).setCellValue("头部形式");
|
|
|
|
headerRow.createCell(7).setCellValue("头部尺寸");
|
|
|
|
headerRow.createCell(6).setCellValue("头部尺寸");
|
|
|
|
headerRow.createCell(8).setCellValue("工具组合");
|
|
|
|
headerRow.createCell(7).setCellValue("工具组合");
|
|
|
|
headerRow.createCell(9).setCellValue("工具");
|
|
|
|
headerRow.createCell(8).setCellValue("工具");
|
|
|
|
headerRow.createCell(10).setCellValue("工具套筒");
|
|
|
|
headerRow.createCell(9).setCellValue("工具套筒");
|
|
|
|
//读取自定义的表
|
|
|
|
//读取自定义的表
|
|
|
|
readRuleExcel(excelfile);
|
|
|
|
readRuleExcel(excelfile);
|
|
|
|
readElectricfile(electricfile,1);
|
|
|
|
readElectricfile(electricfile,1);
|
|
|
@ -1309,7 +1314,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
|
|
|
|
if(workline != null) {
|
|
|
|
if(workline != null) {
|
|
|
|
Map<String,String> clause = new HashMap<>();
|
|
|
|
Map<String,String> clause = new HashMap<>();
|
|
|
|
clause.put("item_id", queryid);
|
|
|
|
clause.put("item_id", queryid);
|
|
|
|
|
|
|
|
System.out.println("获取到的工位id:"+queryid);
|
|
|
|
List<TCComponent> result2 = TCUtil.queryBOMStructObject(session,workline,"queryItem",clause);
|
|
|
|
List<TCComponent> result2 = TCUtil.queryBOMStructObject(session,workline,"queryItem",clause);
|
|
|
|
if(result2 != null) {
|
|
|
|
if(result2 != null) {
|
|
|
|
for(TCComponent stationline:result2) {
|
|
|
|
for(TCComponent stationline:result2) {
|
|
|
@ -1335,23 +1340,28 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
|
|
|
|
if(pipei_resource == null || pipei_resource.length() == 0)
|
|
|
|
if(pipei_resource == null || pipei_resource.length() == 0)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
//先判断工位下是否有此名称的资源,有的直接拿来用
|
|
|
|
//先判断工位下是否有此名称的资源,有的直接拿来用
|
|
|
|
|
|
|
|
System.out.println("先判断工位下是否有此名称的资源,有的直接拿来用");
|
|
|
|
Map<String,String> clause3 = new HashMap<>();
|
|
|
|
Map<String,String> clause3 = new HashMap<>();
|
|
|
|
clause3.put("object_name", pipei_resource);
|
|
|
|
clause3.put("object_name", pipei_resource);
|
|
|
|
List<TCComponent> Resourceresult2 = TCUtil.queryBOMStructObject2(session,stationline,"queryItem",clause3);
|
|
|
|
List<TCComponent> Resourceresult2 = TCUtil.queryBOMStructObject2(session,stationline,"queryItem",clause3);
|
|
|
|
if(Resourceresult2.size() > 0) {
|
|
|
|
if(Resourceresult2 != null && Resourceresult2.size() > 0) {
|
|
|
|
|
|
|
|
System.out.println("工位下直接拿来用"+pipei_resource);
|
|
|
|
TCUtil.connectObject(session, Resourceresult2.get(0), (TCComponent)op, "MEResource");
|
|
|
|
TCUtil.connectObject(session, Resourceresult2.get(0), (TCComponent)op, "MEResource");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
System.out.println("工位下没有资源:"+pipei_resource);
|
|
|
|
Map<String,String> clause22 = new HashMap<>();
|
|
|
|
Map<String,String> clause22 = new HashMap<>();
|
|
|
|
clause22.put("object_name", pipei_resource);
|
|
|
|
clause22.put("object_name", pipei_resource);
|
|
|
|
|
|
|
|
clause22.put("object_type", "Item");
|
|
|
|
TCComponent[] query_items = TCUtil.Generalquery2(session, "queryItem", clause22);
|
|
|
|
TCComponent[] query_items = TCUtil.Generalquery2(session, "queryItem", clause22);
|
|
|
|
if(query_items != null && query_items.length > 0) {
|
|
|
|
if(query_items != null && query_items.length > 0) {
|
|
|
|
|
|
|
|
System.out.println("工位下没有资源:"+pipei_resource);
|
|
|
|
TCComponentBOMLine newResourceline = station.add((TCComponentItem) query_items[0],null, null, false);
|
|
|
|
TCComponentBOMLine newResourceline = station.add((TCComponentItem) query_items[0],null, null, false);
|
|
|
|
TCUtil.connectObject(session, newResourceline, (TCComponent)op, "MEResource");
|
|
|
|
TCUtil.connectObject(session, newResourceline, (TCComponent)op, "MEResource");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
//创建新的item
|
|
|
|
//创建新的item
|
|
|
|
|
|
|
|
System.out.println("工位下没有资源,创建新的资源:"+pipei_resource);
|
|
|
|
TCComponentItem item = TCUtil.createItem(session, "", "A", "Item", pipei_resource);
|
|
|
|
TCComponentItem item = TCUtil.createItem(session, "", "A", "Item", pipei_resource);
|
|
|
|
TCComponentBOMLine newResourceline = station.add(item,null, null, false);
|
|
|
|
TCComponentBOMLine newResourceline = station.add(item,null, null, false);
|
|
|
|
TCUtil.connectObject(session, newResourceline, (TCComponent)op, "MEResource");
|
|
|
|
TCUtil.connectObject(session, newResourceline, (TCComponent)op, "MEResource");
|
|
|
@ -1361,7 +1371,9 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
|
|
|
|
for(String split_value:split) {
|
|
|
|
for(String split_value:split) {
|
|
|
|
clause2.clear();
|
|
|
|
clause2.clear();
|
|
|
|
clause2.put("object_name", split_value);
|
|
|
|
clause2.put("object_name", split_value);
|
|
|
|
TCComponent[] tool_resource = TCUtil.Generalquery2(session, "queryItem", clause);
|
|
|
|
clause2.put("object_type", "Design Part");
|
|
|
|
|
|
|
|
System.out.println("资源添加工具或套筒:"+split_value);
|
|
|
|
|
|
|
|
TCComponent[] tool_resource = TCUtil.Generalquery2(session, "queryItem", clause2);
|
|
|
|
if(tool_resource != null && tool_resource.length > 0) {
|
|
|
|
if(tool_resource != null && tool_resource.length > 0) {
|
|
|
|
newResourceline.add((TCComponentItem) tool_resource[0],null, null, false);
|
|
|
|
newResourceline.add((TCComponentItem) tool_resource[0],null, null, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2224,23 +2236,28 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
|
|
|
|
if(pipei_resource == null || pipei_resource.length() == 0)
|
|
|
|
if(pipei_resource == null || pipei_resource.length() == 0)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
//先判断工位下是否有此名称的资源,有的直接拿来用
|
|
|
|
//先判断工位下是否有此名称的资源,有的直接拿来用
|
|
|
|
|
|
|
|
System.out.println("先判断工位下是否有此名称的资源,有的直接拿来用");
|
|
|
|
Map<String,String> clause3 = new HashMap<>();
|
|
|
|
Map<String,String> clause3 = new HashMap<>();
|
|
|
|
clause3.put("object_name", pipei_resource);
|
|
|
|
clause3.put("object_name", pipei_resource);
|
|
|
|
List<TCComponent> Resourceresult2 = TCUtil.queryBOMStructObject2(session,stationline,"queryItem",clause3);
|
|
|
|
List<TCComponent> Resourceresult2 = TCUtil.queryBOMStructObject2(session,stationline,"queryItem",clause3);
|
|
|
|
if(Resourceresult2.size() > 0) {
|
|
|
|
if(Resourceresult2 != null && Resourceresult2.size() > 0) {
|
|
|
|
|
|
|
|
System.out.println("工位下直接拿来用"+pipei_resource);
|
|
|
|
TCUtil.connectObject(session, Resourceresult2.get(0), (TCComponent)oldop, "MEResource");
|
|
|
|
TCUtil.connectObject(session, Resourceresult2.get(0), (TCComponent)oldop, "MEResource");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
System.out.println("工位下没有资源:"+pipei_resource);
|
|
|
|
Map<String,String> clause22 = new HashMap<>();
|
|
|
|
Map<String,String> clause22 = new HashMap<>();
|
|
|
|
clause22.put("object_name", pipei_resource);
|
|
|
|
clause22.put("object_name", pipei_resource);
|
|
|
|
|
|
|
|
clause22.put("object_type", "Item");
|
|
|
|
TCComponent[] query_items = TCUtil.Generalquery2(session, "queryItem", clause22);
|
|
|
|
TCComponent[] query_items = TCUtil.Generalquery2(session, "queryItem", clause22);
|
|
|
|
if(query_items != null && query_items.length > 0) {
|
|
|
|
if(query_items != null && query_items.length > 0) {
|
|
|
|
|
|
|
|
System.out.println("工位下没有资源:"+pipei_resource);
|
|
|
|
TCComponentBOMLine newResourceline = station.add((TCComponentItem) query_items[0],null, null, false);
|
|
|
|
TCComponentBOMLine newResourceline = station.add((TCComponentItem) query_items[0],null, null, false);
|
|
|
|
TCUtil.connectObject(session, newResourceline, (TCComponent)oldop, "MEResource");
|
|
|
|
TCUtil.connectObject(session, newResourceline, (TCComponent)oldop, "MEResource");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
//创建新的item
|
|
|
|
//创建新的item
|
|
|
|
|
|
|
|
System.out.println("工位下没有资源,创建新的资源:"+pipei_resource);
|
|
|
|
TCComponentItem item = TCUtil.createItem(session, "", "A", "Item", pipei_resource);
|
|
|
|
TCComponentItem item = TCUtil.createItem(session, "", "A", "Item", pipei_resource);
|
|
|
|
TCComponentBOMLine newResourceline = station.add(item,null, null, false);
|
|
|
|
TCComponentBOMLine newResourceline = station.add(item,null, null, false);
|
|
|
|
TCUtil.connectObject(session, newResourceline, (TCComponent)oldop, "MEResource");
|
|
|
|
TCUtil.connectObject(session, newResourceline, (TCComponent)oldop, "MEResource");
|
|
|
@ -2250,7 +2267,9 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
|
|
|
|
for(String split_value:split) {
|
|
|
|
for(String split_value:split) {
|
|
|
|
clause2.clear();
|
|
|
|
clause2.clear();
|
|
|
|
clause2.put("object_name", split_value);
|
|
|
|
clause2.put("object_name", split_value);
|
|
|
|
TCComponent[] tool_resource = TCUtil.Generalquery2(session, "queryItem", clause);
|
|
|
|
clause2.put("object_type", "Design Part");
|
|
|
|
|
|
|
|
System.out.println("资源添加工具或套筒:"+split_value);
|
|
|
|
|
|
|
|
TCComponent[] tool_resource = TCUtil.Generalquery2(session, "queryItem", clause2);
|
|
|
|
if(tool_resource != null && tool_resource.length > 0) {
|
|
|
|
if(tool_resource != null && tool_resource.length > 0) {
|
|
|
|
newResourceline.add((TCComponentItem) tool_resource[0],null, null, false);
|
|
|
|
newResourceline.add((TCComponentItem) tool_resource[0],null, null, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2264,6 +2283,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2308,31 +2328,66 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//读取BOM表
|
|
|
|
//读取BOM表
|
|
|
|
|
|
|
|
// private void readExcel(File excelfile,int start_rownum,int idcol2,int svppscol2,int fcccol2
|
|
|
|
|
|
|
|
// ,int fccdescol2,int dongtaicol,int kcdscol2) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Workbook work = null;
|
|
|
|
|
|
|
|
// try(InputStream is = new FileInputStream(excelfile);){
|
|
|
|
|
|
|
|
// if (excelfile.getAbsolutePath().endsWith(".xls"))
|
|
|
|
|
|
|
|
// work = new HSSFWorkbook(is);
|
|
|
|
|
|
|
|
// else {
|
|
|
|
|
|
|
|
// work = new XSSFWorkbook(is);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Sheet sheet = work.getSheetAt(0);
|
|
|
|
|
|
|
|
// int count = sheet.getPhysicalNumberOfRows();
|
|
|
|
|
|
|
|
// for(int i = start_rownum; i < count ;i++) {
|
|
|
|
|
|
|
|
// Row row = sheet.getRow(i);
|
|
|
|
|
|
|
|
// String id = ExcelUtil.getStringCellValue(row.getCell(idcol2-1));
|
|
|
|
|
|
|
|
// if(id == null || id.length() == 0)
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// String svpps = ExcelUtil.getStringCellValue(row.getCell(svppscol2-1));
|
|
|
|
|
|
|
|
// String fcc = ExcelUtil.getStringCellValue(row.getCell(fcccol2-1));
|
|
|
|
|
|
|
|
// String fccdes = ExcelUtil.getStringCellValue(row.getCell(fccdescol2-1));
|
|
|
|
|
|
|
|
// String dongtai = ExcelUtil.getStringCellValue(row.getCell(dongtaicol-1));
|
|
|
|
|
|
|
|
// String kcds = ExcelUtil.getStringCellValue(row.getCell(kcdscol2-1));
|
|
|
|
|
|
|
|
// System.out.println("id:"+id+" svpps:"+svpps+" fcc:"+fcc+" fccdes:"+fccdes+" dongtai:"+dongtai+" kcds:"+kcds);
|
|
|
|
|
|
|
|
// String key = id;
|
|
|
|
|
|
|
|
// if(!DesignPartBeanMap.containsKey(key)) {
|
|
|
|
|
|
|
|
// DesignPartBean bean = new DesignPartBean();
|
|
|
|
|
|
|
|
// bean.setDongtai(dongtai);
|
|
|
|
|
|
|
|
// bean.setFCC(fcc);
|
|
|
|
|
|
|
|
// bean.setFCCDES(fccdes);
|
|
|
|
|
|
|
|
// bean.setKCDS(kcds);
|
|
|
|
|
|
|
|
// bean.setSVPPS(svpps);
|
|
|
|
|
|
|
|
// DesignPartBeanMap.put(key, bean);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } catch (FileNotFoundException e) {
|
|
|
|
|
|
|
|
// // TODO Auto-generated catch block
|
|
|
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
|
|
|
// // TODO Auto-generated catch block
|
|
|
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
private void readExcel(File excelfile,int start_rownum,int idcol2,int svppscol2,int fcccol2
|
|
|
|
private void readExcel(File excelfile,int start_rownum,int idcol2,int svppscol2,int fcccol2
|
|
|
|
,int fccdescol2,int dongtaicol,int kcdscol2) {
|
|
|
|
,int fccdescol2,int dongtaicol,int kcdscol2) {
|
|
|
|
Workbook work = null;
|
|
|
|
|
|
|
|
try(InputStream is = new FileInputStream(excelfile);){
|
|
|
|
// 自定义监听器
|
|
|
|
if (excelfile.getAbsolutePath().endsWith(".xls"))
|
|
|
|
AnalysisEventListener<Map<Integer, String>> listener = new AnalysisEventListener<Map<Integer, String>>() {
|
|
|
|
work = new HSSFWorkbook(is);
|
|
|
|
@Override
|
|
|
|
else {
|
|
|
|
public void invoke(Map<Integer, String> rowData, AnalysisContext context) {
|
|
|
|
work = new XSSFWorkbook(is);
|
|
|
|
String id = rowData.get(idcol2-1) != null ? rowData.get(idcol2-1) : "";
|
|
|
|
}
|
|
|
|
String dongtai = rowData.get(dongtaicol-1) != null ? rowData.get(dongtaicol-1) : "";
|
|
|
|
Sheet sheet = work.getSheetAt(0);
|
|
|
|
String fcc = rowData.get(fcccol2-1) != null ? rowData.get(fcccol2-1) : "";
|
|
|
|
int count = sheet.getPhysicalNumberOfRows();
|
|
|
|
String fccdes = rowData.get(fccdescol2-1) != null ? rowData.get(fccdescol2-1) : "";
|
|
|
|
for(int i = start_rownum; i < count ;i++) {
|
|
|
|
String kcds = rowData.get(kcdscol2-1) != null ? rowData.get(kcdscol2-1) : "";
|
|
|
|
Row row = sheet.getRow(i);
|
|
|
|
String svpps = rowData.get(svppscol2-1) != null ? rowData.get(svppscol2-1) : "";
|
|
|
|
String id = ExcelUtil.getStringCellValue(row.getCell(idcol2-1));
|
|
|
|
|
|
|
|
if(id == null || id.length() == 0)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
String svpps = ExcelUtil.getStringCellValue(row.getCell(svppscol2-1));
|
|
|
|
|
|
|
|
String fcc = ExcelUtil.getStringCellValue(row.getCell(fcccol2-1));
|
|
|
|
|
|
|
|
String fccdes = ExcelUtil.getStringCellValue(row.getCell(fccdescol2-1));
|
|
|
|
|
|
|
|
String dongtai = ExcelUtil.getStringCellValue(row.getCell(dongtaicol-1));
|
|
|
|
|
|
|
|
String kcds = ExcelUtil.getStringCellValue(row.getCell(kcdscol2-1));
|
|
|
|
|
|
|
|
System.out.println("id:"+id+" svpps:"+svpps+" fcc:"+fcc+" fccdes:"+fccdes+" dongtai:"+dongtai+" kcds:"+kcds);
|
|
|
|
|
|
|
|
String key = id;
|
|
|
|
String key = id;
|
|
|
|
if(!DesignPartBeanMap.containsKey(key)) {
|
|
|
|
if (!DesignPartBeanMap.containsKey(key)) {
|
|
|
|
DesignPartBean bean = new DesignPartBean();
|
|
|
|
DesignPartBean bean = new DesignPartBean();
|
|
|
|
|
|
|
|
// 设置值,确保不会为 null
|
|
|
|
bean.setDongtai(dongtai);
|
|
|
|
bean.setDongtai(dongtai);
|
|
|
|
bean.setFCC(fcc);
|
|
|
|
bean.setFCC(fcc);
|
|
|
|
bean.setFCCDES(fccdes);
|
|
|
|
bean.setFCCDES(fccdes);
|
|
|
@ -2341,13 +2396,18 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
|
|
|
|
DesignPartBeanMap.put(key, bean);
|
|
|
|
DesignPartBeanMap.put(key, bean);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
@Override
|
|
|
|
e.printStackTrace();
|
|
|
|
public void doAfterAllAnalysed(AnalysisContext context) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
System.out.println("读取完成,共 " + DesignPartBeanMap.size() + " 行数据");
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 执行读取
|
|
|
|
|
|
|
|
EasyExcel.read(excelfile, listener)
|
|
|
|
|
|
|
|
.sheet(0) // 指定 sheet 索引
|
|
|
|
|
|
|
|
.headRowNumber(start_rownum) // 从第0行开始读取(包含标题行则设为1)
|
|
|
|
|
|
|
|
.doRead();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//读取规则表
|
|
|
|
//读取规则表
|
|
|
|
private void readRuleExcel(File excelfile) {
|
|
|
|
private void readRuleExcel(File excelfile) {
|
|
|
@ -2719,25 +2779,29 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 读取套筒表*/
|
|
|
|
* 读取套筒表*/
|
|
|
|
private void readsleevefile(File excelfile,int start_rownum) {
|
|
|
|
private void readsleevefile(File excelfile, int start_rownum) {
|
|
|
|
Workbook work = null;
|
|
|
|
Workbook work = null;
|
|
|
|
try(InputStream is = new FileInputStream(excelfile);){
|
|
|
|
try (InputStream is = new FileInputStream(excelfile)) {
|
|
|
|
if (excelfile.getAbsolutePath().endsWith(".xls"))
|
|
|
|
if (excelfile.getAbsolutePath().endsWith(".xls")) {
|
|
|
|
work = new HSSFWorkbook(is);
|
|
|
|
work = new HSSFWorkbook(is);
|
|
|
|
else {
|
|
|
|
} else {
|
|
|
|
work = new XSSFWorkbook(is);
|
|
|
|
work = new XSSFWorkbook(is);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Sheet sheet = work.getSheetAt(0);
|
|
|
|
Sheet sheet = work.getSheetAt(0);
|
|
|
|
int count = sheet.getPhysicalNumberOfRows();
|
|
|
|
int count = sheet.getPhysicalNumberOfRows();
|
|
|
|
for(int i = start_rownum; i < count ;i++) {
|
|
|
|
|
|
|
|
|
|
|
|
// 临时存储所有 SleeveBean,按 outSize 分组
|
|
|
|
|
|
|
|
Map<String, List<SleeveBean>> tempMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = start_rownum; i < count; i++) {
|
|
|
|
Row row = sheet.getRow(i);
|
|
|
|
Row row = sheet.getRow(i);
|
|
|
|
String resourceType = ExcelUtil.getStringCellValue(row.getCell(1));
|
|
|
|
String resourceType = ExcelUtil.getStringCellValue(row.getCell(1));
|
|
|
|
String inputSize = ExcelUtil.getStringCellValue(row.getCell(6));
|
|
|
|
String inputSize = ExcelUtil.getStringCellValue(row.getCell(6));
|
|
|
|
String outSize = ExcelUtil.getStringCellValue(row.getCell(7));
|
|
|
|
String outSize = ExcelUtil.getStringCellValue(row.getCell(7));
|
|
|
|
String length = ExcelUtil.getStringCellValue(row.getCell(11));
|
|
|
|
String length = ExcelUtil.getStringCellValue(row.getCell(11));
|
|
|
|
String headform = ExcelUtil.getStringCellValue(row.getCell(16));
|
|
|
|
String headform = ExcelUtil.getStringCellValue(row.getCell(16));
|
|
|
|
if(resourceType != null && resourceType.length() > 0) {
|
|
|
|
|
|
|
|
// 使用 computeIfAbsent 简化操作
|
|
|
|
if (resourceType != null && resourceType.length() > 0) {
|
|
|
|
SleeveBean tool = new SleeveBean();
|
|
|
|
SleeveBean tool = new SleeveBean();
|
|
|
|
tool.setResourceType(resourceType);
|
|
|
|
tool.setResourceType(resourceType);
|
|
|
|
tool.setLength(length);
|
|
|
|
tool.setLength(length);
|
|
|
@ -2745,22 +2809,43 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
|
|
|
|
tool.setInputSize(inputSize);
|
|
|
|
tool.setInputSize(inputSize);
|
|
|
|
tool.setOutSize(outSize);
|
|
|
|
tool.setOutSize(outSize);
|
|
|
|
|
|
|
|
|
|
|
|
SleeveMap.computeIfAbsent(outSize, key -> new ArrayList<>()).add(tool);
|
|
|
|
// 添加到临时 Map 中
|
|
|
|
|
|
|
|
tempMap.computeIfAbsent(outSize, key -> new ArrayList<>()).add(tool);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 对每个 outSize 的 List 按 length 排序
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<SleeveBean>> entry : tempMap.entrySet()) {
|
|
|
|
|
|
|
|
List<SleeveBean> sleeveList = entry.getValue();
|
|
|
|
|
|
|
|
sleeveList.sort((bean1, bean2) -> {
|
|
|
|
|
|
|
|
// 将 length 转换为数字进行比较
|
|
|
|
|
|
|
|
double length1 = parseLength(bean1.getLength());
|
|
|
|
|
|
|
|
double length2 = parseLength(bean2.getLength());
|
|
|
|
|
|
|
|
return Double.compare(length1, length2);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// 将排序后的列表放入 SleeveMap
|
|
|
|
|
|
|
|
SleeveMap.put(entry.getKey(), sleeveList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private double parseLength(String length) {
|
|
|
|
|
|
|
|
if (length == null || length.trim().isEmpty()) {
|
|
|
|
|
|
|
|
return 0.0; // 默认值,可以根据需求调整
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return Double.parseDouble(length.trim());
|
|
|
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
|
|
|
System.err.println("无法解析 length: " + length);
|
|
|
|
|
|
|
|
return 0.0; // 解析失败时返回默认值
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
private List<TCComponent> getStation(TCComponentBOMLine child){
|
|
|
|
private List<TCComponent> getStation(TCComponentBOMLine child){
|
|
|
|
List<TCComponent> result = null;
|
|
|
|
List<TCComponent> result = null;
|
|
|
|
Map<String,String> clause = new HashMap<>();
|
|
|
|
Map<String,String> clause = new HashMap<>();
|
|
|
|