public Task creatTaskAndRunTaskqiyongde(String pinbanFangshi){
return new Task() {
@Override
protected Object call() throws Exception {
try {
System.out.println("第一次");
String parentFile = getParentFile();
//todo
updateProgress(0, 100);
String message = "";
int countS = 0;
int countE = 0;
if (isSelected()) {
for (int i = 0; i < selectedCells.size(); i++) {
TablePosition tablePosition = selectedCells.get(i);
ObservableList selectedItems = tablePosition.getTableView().getSelectionModel().getSelectedItems();
List<RowData> list = new ArrayList<>();
for (int j = 0; j < selectedItems.size(); j++) {
list.add((RowData) selectedItems.get(j));
}
for (int j = 0; j < list.size(); j++) {
try {
RowData rowData = list.get(j);
System.out.println("--------------------");
Paper paper33 = getPaperByChoiceBox((String)choiceBox.getValue());
System.out.println(rowData+"\n"+pinbanFangshi+"\n"+choiceBox.getValue()+"\n"+paper33);
if (rowData.getState().equals("待处理")) {
File file = new File(rowData.getFile());
util.Storage.pdfReaderMap = new HashMap<Integer, PdfReader>();
String name = file.getName();
name = NameUtilss.removeSuffix(name);
String yaoqiu = NameUtilss.midString(name, "[", "]");
File fileXml = new File(ChatController.class.getClassLoader().getResource("info/info.xml").getPath());
//todo
updateProgress(5, 100);
SAXReader saxReader = new SAXReader();
//读取xml文件 并且返回一个Document 对象
Document document = saxReader.read(fileXml);
//得到xml文件的根节点
Element rootElement = document.getRootElement();
util.Storage.impInfo = new ImpInfo();
//todo
updateProgress(10, 100);
/**
* 打印方式
*/
List<String> danMianPrintList = TomXmlUtil.getPrintList(TomXmlUtil.getElement(rootElement, "要求→打印方式→单面打印"));
List<String> shuangMianPrintList = TomXmlUtil.getPrintList(TomXmlUtil.getElement(rootElement, "要求→打印方式→双面打印"));
String makeUp = NameUtilss.getMakeUp(yaoqiu, danMianPrintList, shuangMianPrintList);
System.out.println("makeUp:"+makeUp);
util.Storage.impInfo.setMakeUp(makeUp);
/**
* 材料
*/
List<String> materialList = TomXmlUtil.getMaterialList(TomXmlUtil.getElement(rootElement, "要求→材料"));
String material = NameUtilss.getMaterial(yaoqiu, materialList);
util.Storage.impInfo.setMaterial(material);
//todo
updateProgress(15, 100);
/**
* 工艺
*/
List<String> technologyList = TomXmlUtil.getMaterialList(TomXmlUtil.getElement(rootElement, "要求→工艺"));
String technology = NameUtilss.getMaterial(yaoqiu, technologyList);
util.Storage.impInfo.setTechnology(technology);
/**
* 后道
*/
List<String> lastProcessList = TomXmlUtil.getMaterialList(TomXmlUtil.getElement(rootElement, "要求→后道"));
String lastProcess = NameUtilss.getMaterial(yaoqiu, lastProcessList);
util.Storage.impInfo.setLastProcess(lastProcess);
/**
* 克重
*/
int weight = NameUtilss.getWeight(yaoqiu);
util.Storage.impInfo.setWeight(weight);
/**
* 数量
*/
int number = NameUtilss.getNumber(yaoqiu);
util.Storage.impInfo.setNumber(number);
//todo
updateProgress(20, 100);
/**
* 纸张与定位与需要添加的文件
*/
entry.Paper paper = TomXmlUtil.getPaper(material, lastProcess, rootElement);
TomXmlUtil.setImpInfo(file.toString(), document);
//todo
updateProgress(25, 100);
//间距 1这个值需要后面传进来
String finalName = null;
if (paper != null) {
//获取拼版属性 ImpositionInfo(col=6, row=14, rotate=90, spellNumber=84, impSize=Size(w=314.9995, h=442.99994), singleSize=Size(w=49.99992, h=29.999996))
ImpositionInfo impositionInfo = ImpositionUtil.getImposition(paper, util.Storage.impInfo, "210509001");
//todo
updateProgress(35, 100);
finalName = parentFile + "/" + System.currentTimeMillis() + ".pdf";
ItextUtil.createPdfImposition(paper, impositionInfo, finalName);
// for(int k=1;k<12;){
// //todo
// updateProgress(35+k*5, 100);
// }
} else {
System.out.println("材料未找到");
}
if (file != null && new File(finalName).exists()) {
tableView.getItems().remove(rowData);
countS++;
rowData.setState("√-" + pinbanFangshi);
rowData.setFile(finalName);
tableView2.getItems().add(rowData);
} else {
countE++;
}
updateProgress(100, 100);
}
}catch (Exception e3){
e3.printStackTrace();
}
}
}
errorMessage(message, countS, countE);
}
} catch (Exception e) {
log.error(pinbanFangshi + "拼版报错了");
}
System.out.println("22222");
return true;
}
};
}
弃用的方法
最新推荐文章于 2023-08-30 16:49:46 发布