| | |
| | | package org.springblade.mdm.flow.service; |
| | | |
| | | import com.google.common.io.FileBackedOutputStream; |
| | | import com.itextpdf.text.Document; |
| | | import com.itextpdf.text.DocumentException; |
| | | import com.itextpdf.text.PageSize; |
| | | import com.itextpdf.text.pdf.BaseFont; |
| | | import com.itextpdf.text.pdf.PdfWriter; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.flow.vo.ApproveTableInfo; |
| | | |
| | | import java.io.FileNotFoundException; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | |
| | | public class ApproveTableServiceTest { |
| | | @Test |
| | | public void test(){ |
| | | ApproveTableService s = new ApproveTableService(null,null,null,null,null); |
| | | ApproveTableService s = new ApproveTableService(); |
| | | try { |
| | | //s.exportApproveTable("1",new FileOutputStream("d:/t.pdf")); |
| | | BaseFont bfChinese = s.getBaseFont(); |
| | | |
| | | Document document = new Document(PageSize.B5.rotate()); |
| | | |
| | | String filename = "d:/t"+System.currentTimeMillis()+".pdf"; |
| | | File pdf = new File(filename); |
| | | if(pdf.exists()){ |
| | | pdf.delete(); |
| | | } |
| | | PdfWriter.getInstance(document,new FileOutputStream(pdf)); |
| | | |
| | | document.open(); |
| | | |
| | | FlowProgramProperties props = new FlowProgramProperties(); |
| | | props.setDrawingNo("CP3-1"); |
| | | props.setProcessNo("A"); |
| | | props.setProcessEdition("93"); |
| | | props.setCraftEdition("工艺版次"); |
| | | props.setProductModel("CP3"); |
| | | //编制 |
| | | |
| | | Machine machine = new Machine(); |
| | | machine.setName("1075"); |
| | | machine.setProgSendDir("d:\\mdm\\send"); |
| | | |
| | | ApproveTableInfo appInfo = new ApproveTableInfo(); |
| | | appInfo.setTeamLeaderName("组长1"); |
| | | appInfo.setProgrammerName("编制1"); |
| | | appInfo.setCheckerName("校对1"); |
| | | appInfo.setSeniorName("审核1"); |
| | | |
| | | |
| | | Calendar startCal = Calendar.getInstance(); |
| | | startCal.add(Calendar.DAY_OF_MONTH, -5); |
| | | appInfo.setProgrammingDate(startCal.getTime()); |
| | | |
| | | startCal.add(Calendar.DAY_OF_MONTH, 2); |
| | | appInfo.setCheckDate(startCal.getTime()); |
| | | |
| | | |
| | | startCal.add(Calendar.DAY_OF_MONTH, 2); |
| | | appInfo.setApproveDate(startCal.getTime()); |
| | | s.printPage(document,bfChinese,props,machine,1,appInfo); |
| | | |
| | | document.close(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |