| | |
| | | |
| | | import com.itextpdf.text.Document; |
| | | import com.itextpdf.text.PageSize; |
| | | import com.itextpdf.text.pdf.BaseFont; |
| | | import com.itextpdf.text.pdf.PdfWriter; |
| | | import com.itextpdf.text.pdf.*; |
| | | import org.junit.jupiter.api.Assertions; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.flow.vo.ApproveTableInfo; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.*; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public class ProgramConfirmTableServiceTest { |
| | | @Test |
| | | public void testExportConfirmTable(){ |
| | | //@Test |
| | | public void test(){ |
| | | ProgramConfirmTableService s = new ProgramConfirmTableService(); |
| | | try { |
| | | BaseFont bfChinese = s.getBaseFont(); |
| | | String fileName = "d:/confirtabletpl.pdf";//模板绝对路径 |
| | | String outfile = "D:/q"+System.currentTimeMillis()+".pdf"; |
| | | try(InputStream ins = Files.newInputStream(Paths.get(fileName));OutputStream fos = Files.newOutputStream(Paths.get(outfile));) { |
| | | //ByteArrayInputStream bais; |
| | | |
| | | Document document = new Document(PageSize.B5.rotate()); |
| | | |
| | | String filename = "c"+System.currentTimeMillis()+".pdf"; |
| | | File pdf = new File(filename); |
| | | if(pdf.exists()){ |
| | | pdf.delete(); |
| | | //s.generateTempPDF(ins.readAllBytes(),fos); |
| | | } |
| | | 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); |
| | | |
| | | document.close(); |
| | | Assertions.assertTrue(true); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |