@ -81,7 +81,9 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
@@ -81,7 +81,9 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
lotteryProject . setType ( LotteryProjectDto . TypeEnum . ONESELF . getCode ( ) ) ;
lotteryProject . setStatus ( LotteryProjectDto . StatusEnum . TO_BE_EXTRACTED . getCode ( ) ) ;
lotteryProject . setStatusName ( LotteryProjectDto . StatusEnum . TO_BE_EXTRACTED . getDescribe ( ) ) ;
if ( null ! = param . getBidEvaluationTime ( ) ) {
lotteryProject . setBidOpeningTime ( LocalDate . parse ( LocalDateTimeUtil . format ( param . getBidEvaluationTime ( ) , "yyyy-MM-dd" ) ) ) ;
}
UserInfo userInfo = userProvider . get ( ) ;
lotteryProject . setUserDeptId ( userInfo . getOrganizeId ( ) ) ;
//添加根子单数据
@ -102,7 +104,9 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
@@ -102,7 +104,9 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
throw new DataException ( "id不能为空" ) ;
}
LotteryProject lotteryProject = BeanUtil . copyProperties ( param , LotteryProject . class ) ;
if ( null ! = param . getBidEvaluationTime ( ) ) {
lotteryProject . setBidOpeningTime ( LocalDate . parse ( LocalDateTimeUtil . format ( param . getBidEvaluationTime ( ) , "yyyy-MM-dd" ) ) ) ;
}
UserInfo userInfo = userProvider . get ( ) ;
;
lotteryProject . setUpdateId ( userInfo . getUserId ( ) ) ;
@ -343,7 +347,7 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
@@ -343,7 +347,7 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
throw new DataException ( "暂未有确认专家,无法打印" ) ;
}
try {
MockMultipartFile mockMultipartFile = expertPrinting ( "专家抽取结果打印.docx" , extractExpertsInfo ) ;
MockMultipartFile mockMultipartFile = expertPrinting ( "专家抽取结果打印.docx" , extractExpertsInfo , lotteryProject . getProjectName ( ) ) ;
String temporaryFilePath = fileApi . getPath ( FileTypeConstant . TEMPORARY ) ;
FileInfo fileInfo = fileUploadApi . uploadFile ( mockMultipartFile , temporaryFilePath , "专家抽取结果打印.docx" ) ;
vo . setName ( fileInfo . getFilename ( ) ) ;
@ -357,13 +361,13 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
@@ -357,13 +361,13 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
if ( CollectionUtil . isEmpty ( extractExpertsInfo ) ) {
throw new DataException ( "暂未有确认公司,无法打印" ) ;
}
MockMultipartFile mockMultipartFile = companyPrinting ( "招投标公司抽取结果打印.docx" , extractExpertsInfo ) ;
MockMultipartFile mockMultipartFile = companyPrinting ( "招投标公司抽取结果打印.docx" , extractExpertsInfo , lotteryProject . getProjectName ( ) ) ;
String temporaryFilePath = fileApi . getPath ( FileTypeConstant . TEMPORARY ) ;
FileInfo fileInfo = fileUploadApi . uploadFile ( mockMultipartFile , temporaryFilePath , "招投标公司抽取结果打印.docx" ) ;
vo . setName ( fileInfo . getFilename ( ) ) ;
vo . setUrl ( UploaderUtil . uploaderFile ( fileInfo . getFilename ( ) + "#" + "Temporary" ) + "&name=" + "招投标公司抽取结果打印.docx" ) ;
} catch ( Exception e ) {
log . error ( "专家 抽取结果打印异常" , e ) ;
log . error ( "公司 抽取结果打印异常" , e ) ;
}
break ;
}
@ -372,27 +376,42 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
@@ -372,27 +376,42 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
return vo ;
}
private MockMultipartFile expertPrinting ( String fileName , List < LotteryProjectDto . ExtractExpertsInfo > data ) throws Exception {
private MockMultipartFile expertPrinting ( String fileName , List < LotteryProjectDto . ExtractExpertsInfo > data , String projectName ) throws Exception {
try ( InputStream inputStream = ResourceUtil . getStream ( "jnpf/templete/浙江出版传媒股份有限公司ERP系统建设项目.docx" ) ;
XWPFDocument doc = new XWPFDocument ( inputStream ) ) {
// 找到标记位置的段落
XWPFParagraph placeholderParagraph = null ;
XWPFParagraph textParagraph = null ;
for ( XWPFParagraph paragraph : doc . getParagraphs ( ) ) {
if ( paragraph . getText ( ) . contains ( "{{table_here}}" ) ) {
placeholderParagraph = paragraph ;
break ;
}
if ( paragraph . getText ( ) . contains ( "{{projectName}}" ) ) {
textParagraph = paragraph ;
}
}
if ( placeholderParagraph = = null ) {
throw new IllegalStateException ( "Cannot find placeholder in the document." ) ;
}
// 删除包含占位符的段落
XWPFRun run = placeholderParagraph . getRuns ( ) . get ( 0 ) ;
run . setText ( run . getText ( 0 ) . replace ( "{{table_here}}" , "" ) , 0 ) ;
//替换项目名称
if ( textParagraph ! = null ) {
String join = StrUtil . join ( "" , textParagraph . getRuns ( ) . stream ( ) . map ( te - > te . getText ( 0 ) ) . collect ( Collectors . toList ( ) ) ) ;
XWPFRun xwpfRun = textParagraph . getRuns ( ) . get ( 0 ) ;
for ( XWPFRun textParagraphRun : textParagraph . getRuns ( ) ) {
textParagraphRun . setText ( "" ) ;
}
xwpfRun . setText ( join . replace ( "{{projectName}}" , projectName ) , 0 ) ;
}
// 在占位符位置插入表格
// 插入表格到占位符位置后
@ -463,18 +482,22 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
@@ -463,18 +482,22 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
}
}
private MockMultipartFile companyPrinting ( String fileName , List < LotteryProjectDto . ExtractExpertsInfo > data ) throws Exception {
private MockMultipartFile companyPrinting ( String fileName , List < LotteryProjectDto . ExtractExpertsInfo > data , String projectName ) throws Exception {
try ( InputStream inputStream = ResourceUtil . getStream ( "jnpf/templete/招投标公司打印.docx" ) ;
XWPFDocument doc = new XWPFDocument ( inputStream ) ) {
// 找到标记位置的段落
XWPFParagraph placeholderParagraph = null ;
XWPFParagraph textParagraph = null ;
for ( XWPFParagraph paragraph : doc . getParagraphs ( ) ) {
if ( paragraph . getText ( ) . contains ( "{{table_here}}" ) ) {
placeholderParagraph = paragraph ;
break ;
}
if ( paragraph . getText ( ) . contains ( "{{projectName}}" ) ) {
textParagraph = paragraph ;
}
}
if ( placeholderParagraph = = null ) {
@ -485,6 +508,16 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
@@ -485,6 +508,16 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
XWPFRun run = placeholderParagraph . getRuns ( ) . get ( 0 ) ;
run . setText ( run . getText ( 0 ) . replace ( "{{table_here}}" , "" ) , 0 ) ;
//替换项目名称
if ( textParagraph ! = null ) {
String join = StrUtil . join ( "" , textParagraph . getRuns ( ) . stream ( ) . map ( te - > te . getText ( 0 ) ) . collect ( Collectors . toList ( ) ) ) ;
XWPFRun xwpfRun = textParagraph . getRuns ( ) . get ( 0 ) ;
for ( XWPFRun textParagraphRun : textParagraph . getRuns ( ) ) {
textParagraphRun . setText ( "" ) ;
}
xwpfRun . setText ( join . replace ( "{{projectName}}" , projectName ) , 0 ) ;
}
// 在占位符位置插入表格
// 插入表格到占位符位置后
// XWPFTable table = doc.createTable();
@ -670,16 +703,20 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
@@ -670,16 +703,20 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
"]" ;
// List<LotteryProjectDto.ExtractExpertsInfo> data = JSON.parseArray(s, LotteryProjectDto.ExtractExpertsInfo.class);
List < LotteryProjectDto . ExtractExpertsInfo > data = JSON . parseArray ( s2 , LotteryProjectDto . ExtractExpertsInfo . class ) ;
try ( InputStream inputStream = new FileInputStream ( new File ( "/Users/yangzhenli/Documents/项目/jnpf /浙江出版传媒股份有限公司ERP系统建设项目.docx" ) ) ;
try ( InputStream inputStream = new FileInputStream ( new File ( "/Users/yangzhenli/code/jnpfsoft-jnpf-jnpf-java-cloud-/jnpf-tendering/jnpf-tendering-server/src/main/resources/jnpf/templete /浙江出版传媒股份有限公司ERP系统建设项目.docx" ) ) ;
XWPFDocument doc = new XWPFDocument ( inputStream ) ) {
// 找到标记位置的段落
XWPFParagraph placeholderParagraph = null ;
XWPFParagraph textParagraph = null ;
for ( XWPFParagraph paragraph : doc . getParagraphs ( ) ) {
if ( paragraph . getText ( ) . contains ( "{{table_here}}" ) ) {
placeholderParagraph = paragraph ;
break ;
}
if ( paragraph . getText ( ) . contains ( "{{projectName}}" ) ) {
textParagraph = paragraph ;
}
}
if ( placeholderParagraph = = null ) {
@ -689,6 +726,15 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
@@ -689,6 +726,15 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
// 删除包含占位符的段落
XWPFRun run = placeholderParagraph . getRuns ( ) . get ( 0 ) ;
run . setText ( run . getText ( 0 ) . replace ( "{{table_here}}" , "" ) , 0 ) ;
//替换项目名称
if ( textParagraph ! = null ) {
String join = StrUtil . join ( "" , textParagraph . getRuns ( ) . stream ( ) . map ( te - > te . getText ( 0 ) ) . collect ( Collectors . toList ( ) ) ) ;
XWPFRun xwpfRun = textParagraph . getRuns ( ) . get ( 0 ) ;
for ( XWPFRun textParagraphRun : textParagraph . getRuns ( ) ) {
textParagraphRun . setText ( "" ) ;
}
xwpfRun . setText ( join . replace ( "{{projectName}}" , "测试2" ) , 0 ) ;
}
// 在占位符位置插入表格
// 插入表格到占位符位置后