Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
Y
yn-health-science
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐俊
yn-health-science
Commits
05f76520
Commit
05f76520
authored
Apr 01, 2025
by
徐俊
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.yiboshi.com/XuJun/yn-health-science
parents
a95a349f
456d64f9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
6 additions
and
127 deletions
+6
-127
ComProjectController.java
...ava/com/yiboshi/science/rest/v1/ComProjectController.java
+0
-20
ComProjectTaskController.java
...com/yiboshi/science/rest/v1/ComProjectTaskController.java
+2
-3
ComProjectAssignServiceImpl.java
...shi/science/service/impl/ComProjectAssignServiceImpl.java
+1
-1
ComProjectConclusionServiceImpl.java
...science/service/impl/ComProjectConclusionServiceImpl.java
+1
-2
ComProjectServiceImpl.java
...m/yiboshi/science/service/impl/ComProjectServiceImpl.java
+1
-17
PdfUtil.java
...dmin/src/main/java/com/yiboshi/science/utils/PdfUtil.java
+0
-0
TalentToPDF.java
.../src/main/java/com/yiboshi/science/utils/TalentToPDF.java
+0
-0
TaskToPDF.java
...in/src/main/java/com/yiboshi/science/utils/TaskToPDF.java
+1
-84
No files found.
science-admin/src/main/java/com/yiboshi/science/rest/v1/ComProjectController.java
View file @
05f76520
...
...
@@ -15,7 +15,6 @@ import com.yiboshi.science.service.ComFileService;
import
com.yiboshi.science.service.ComProjectService
;
import
com.yiboshi.science.service.ComProjectTaskService
;
import
com.yiboshi.science.service.SystemParameterService
;
import
com.yiboshi.science.utils.PdfUtil
;
import
com.yiboshi.science.utils.ProjectInfoToPDF
;
import
com.yiboshi.science.utils.StringUtil
;
import
io.swagger.annotations.Api
;
...
...
@@ -87,25 +86,6 @@ public class ComProjectController extends BaseController<ComProjectService, ComP
return
ResponseDataModel
.
ok
(
comProjectService
.
getCount
(
e
));
}
@ApiOperation
(
value
=
"项目信息导出"
,
httpMethod
=
"POST"
,
notes
=
"项目信息导出"
)
@RequestMapping
(
"/export1/{id}"
)
@PostMapping
public
void
export1
(
@PathVariable
String
id
)
{
comProjectService
.
export
(
id
,
request
,
response
);
}
@ApiOperation
(
value
=
"项目信息导出"
,
httpMethod
=
"POST"
,
notes
=
"项目信息导出"
)
@RequestMapping
(
"/export/{id}"
)
@PostMapping
public
ResponseDataModel
<
byte
[]>
export
(
@PathVariable
String
id
)
{
try
{
return
ResponseDataModel
.
ok
(
PdfUtil
.
createPDF
(
response
,
"tmp-report.html"
,
new
ComProject
()));
}
catch
(
Exception
e
)
{
return
new
ResponseDataModel
(
ResponseCode
.
SERVER_ERROR
,
""
);
}
}
/**
* 根据id获取项目信息
*
...
...
science-admin/src/main/java/com/yiboshi/science/rest/v1/ComProjectTaskController.java
View file @
05f76520
...
...
@@ -21,13 +21,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer
;
import
javax.servlet.ServletOutputStream
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* 功能:任务书表 接口
...
...
@@ -157,7 +155,8 @@ public class ComProjectTaskController extends BaseController<ComProjectTaskServi
// 生成PDF文件字节数组
// byte[] pdfBytes = TaskInfoToPDFUtil.createContractPdf(dto);
byte
[]
pdfBytes
=
TaskToPDF
.
createContractPdf
(
dto
);
// byte[] pdfBytes = TaskToPDF.createContractPdf(dto);
byte
[]
pdfBytes
=
TalentToPDF
.
createContractPdf
(
dto
);
// 设置响应头
response
.
setContentType
(
"application/pdf"
);
String
fileName
=
new
String
((
dto
.
getProjName
()
+
".pdf"
).
getBytes
(
"UTF-8"
),
"ISO-8859-1"
);
...
...
science-admin/src/main/java/com/yiboshi/science/service/impl/ComProjectAssignServiceImpl.java
View file @
05f76520
...
...
@@ -253,7 +253,7 @@ public class ComProjectAssignServiceImpl extends BaseServiceImpl<ComProjectAssig
economyScore
=
new
BigDecimal
(
df1
.
format
(
economyScore
));
}
totalScore
=
technologyScore
.
add
(
economyScore
);
calculateScore
=
technologyAverageScore
.
multiply
(
new
BigDecimal
(
0.8
)).
add
(
economyAverageScore
.
multiply
(
new
BigDecimal
(
0.2
)));
calculateScore
=
technologyAverageScore
.
multiply
(
new
BigDecimal
(
1
)).
add
(
economyAverageScore
.
multiply
(
new
BigDecimal
(
1
)));
calculateScore
=
new
BigDecimal
(
df1
.
format
(
calculateScore
));
if
(
list
.
size
()
>
personCount
)
completed
=
0
;
...
...
science-admin/src/main/java/com/yiboshi/science/service/impl/ComProjectConclusionServiceImpl.java
View file @
05f76520
...
...
@@ -17,7 +17,6 @@ import com.yiboshi.science.entity.ComProjectConclusion;
import
com.yiboshi.science.param.query.ComProjectConclusionQueryVO
;
import
com.yiboshi.science.service.*
;
import
com.yiboshi.science.utils.DateUtils
;
import
com.yiboshi.science.utils.PdfUtil
;
import
org.apache.velocity.VelocityContext
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -339,7 +338,7 @@ public class ComProjectConclusionServiceImpl extends BaseServiceImpl<ComProjectC
context
.
put
(
"day"
,
day
>=
10
?
day
:
"0"
+
day
);
try
(
ServletOutputStream
outputStream
=
response
.
getOutputStream
())
{
PdfUtil
.
pdfFile
(
context
,
"/template/demo.html"
,
outputStream
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
science-admin/src/main/java/com/yiboshi/science/service/impl/ComProjectServiceImpl.java
View file @
05f76520
...
...
@@ -963,23 +963,7 @@ public class ComProjectServiceImpl extends BaseServiceImpl<ComProjectDAO, ComPro
public
void
export
(
@PathVariable
String
id
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
String
filename
=
System
.
currentTimeMillis
()
+
".pdf"
;
response
.
reset
();
response
.
setContentType
(
"application/pdf"
);
response
.
addHeader
(
"Content-Disposition"
,
"inline; filename="
+
URLUtil
.
encode
(
filename
,
CharsetUtil
.
CHARSET_UTF_8
));
VelocityContext
context
=
new
VelocityContext
();
Calendar
calendar
=
Calendar
.
getInstance
();
int
month
=
calendar
.
get
(
Calendar
.
MONTH
)
+
1
;
int
day
=
calendar
.
get
(
Calendar
.
DATE
);
context
.
put
(
"reportYear"
,
2024
);
context
.
put
(
"year"
,
calendar
.
get
(
Calendar
.
YEAR
));
context
.
put
(
"month"
,
month
>=
10
?
month
:
"0"
+
month
);
context
.
put
(
"day"
,
day
>=
10
?
day
:
"0"
+
day
);
try
(
ServletOutputStream
outputStream
=
response
.
getOutputStream
())
{
PdfUtil
.
pdfFile
(
context
,
"/template/tmp-report.html"
,
outputStream
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
...
...
science-admin/src/main/java/com/yiboshi/science/utils/PdfUtil.java
View file @
05f76520
This diff is collapsed.
Click to expand it.
science-admin/src/main/java/com/yiboshi/science/utils/TalentToPDF.java
0 → 100644
View file @
05f76520
This diff is collapsed.
Click to expand it.
science-admin/src/main/java/com/yiboshi/science/utils/TaskToPDF.java
View file @
05f76520
...
...
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.Objects
;
import
static
com
.
yiboshi
.
science
.
utils
.
PdfUtil
.*;
import
static
com
.
yiboshi
.
science
.
utils
.
ProjectInfoToPDF
.
getCurrentOperatingSystem
;
public
class
TaskToPDF
{
...
...
@@ -259,88 +260,4 @@ public class TaskToPDF {
}
document
.
add
(
projTable
);
}
private
static
void
addTablePageCell
(
Table
table
,
String
label
,
String
value
,
Integer
labelColspan
,
Integer
valueColspan
,
PdfFont
font
)
{
if
(
Objects
.
isNull
(
labelColspan
))
labelColspan
=
1
;
if
(
Objects
.
isNull
(
valueColspan
))
valueColspan
=
1
;
Cell
labelCell
=
new
Cell
(
1
,
labelColspan
);
labelCell
.
setMinHeight
(
36
f
);
labelCell
.
setVerticalAlignment
(
VerticalAlignment
.
BOTTOM
);
labelCell
.
setHorizontalAlignment
(
HorizontalAlignment
.
LEFT
);
labelCell
.
setBorder
(
new
SolidBorder
(
new
DeviceRgb
(
0
,
0
,
0
),
0.1f
));
// 设置边框宽度
labelCell
.
add
(
new
Paragraph
(
label
!=
null
?
label
.
toString
()
:
""
).
setFont
(
font
).
setFontSize
(
15
));
labelCell
.
setBorder
(
Border
.
NO_BORDER
);
table
.
addCell
(
labelCell
);
Cell
valueCell
=
new
Cell
(
1
,
valueColspan
);
valueCell
.
setPadding
(
3
f
);
valueCell
.
setMinHeight
(
36
f
);
valueCell
.
setVerticalAlignment
(
VerticalAlignment
.
BOTTOM
);
valueCell
.
setHorizontalAlignment
(
HorizontalAlignment
.
LEFT
);
// 只设置下边框
valueCell
.
setBorderTop
(
Border
.
NO_BORDER
);
valueCell
.
setBorderLeft
(
Border
.
NO_BORDER
);
valueCell
.
setBorderRight
(
Border
.
NO_BORDER
);
valueCell
.
setBorderBottom
(
unitedBorder
);
valueCell
.
add
(
new
Paragraph
(
value
!=
null
?
value
.
toString
()
:
""
).
setFont
(
font
).
setFontSize
(
15
));
table
.
addCell
(
valueCell
);
}
private
static
void
addValueCell
(
Table
table
,
String
label
,
Integer
labelColspan
,
String
value
,
Integer
valueColspan
,
Float
height
,
PdfFont
font
,
Float
fontSize
,
VerticalAlignment
vertical
,
HorizontalAlignment
horizontal
)
{
addCell
(
table
,
label
,
labelColspan
,
null
,
height
,
font
,
fontSize
,
vertical
,
horizontal
);
addCell
(
table
,
value
,
valueColspan
,
null
,
height
,
font
,
fontSize
,
vertical
,
horizontal
);
}
private
static
void
addCell
(
Table
table
,
Object
value
,
Integer
colspan
,
Integer
rowspan
,
Float
height
,
PdfFont
font
,
Float
fontSize
,
VerticalAlignment
vertical
,
HorizontalAlignment
horizontal
)
{
if
(
Objects
.
isNull
(
font
))
font
=
createFont
(
"simsun.ttc"
);
if
(
Objects
.
isNull
(
fontSize
))
fontSize
=
10.5f
;
if
(
Objects
.
isNull
(
height
))
height
=
25.5f
;
if
(
Objects
.
isNull
(
colspan
))
colspan
=
1
;
if
(
Objects
.
isNull
(
rowspan
))
rowspan
=
1
;
if
(
Objects
.
isNull
(
vertical
))
vertical
=
VerticalAlignment
.
MIDDLE
;
if
(
Objects
.
isNull
(
horizontal
))
horizontal
=
HorizontalAlignment
.
CENTER
;
Cell
cell
=
new
Cell
(
rowspan
,
colspan
);
cell
.
setPadding
(
5
f
);
cell
.
setMinHeight
(
height
);
cell
.
setVerticalAlignment
(
vertical
);
cell
.
setHorizontalAlignment
(
horizontal
);
cell
.
setBorderRight
(
unitedBorder
);
cell
.
setBorderBottom
(
unitedBorder
);
// 创建段落并检查字体
cell
.
add
(
new
Paragraph
(
value
!=
null
?
value
.
toString
()
:
""
).
setFont
(
font
).
setFontSize
(
fontSize
));
table
.
addCell
(
cell
);
}
// 为了保持兼容性,添加原有方法的重载
private
static
void
setParagraph
(
Document
document
,
Object
value
,
PdfFont
font
,
float
FontSize
,
boolean
bold
)
throws
DocumentException
{
Paragraph
paragraph
=
new
Paragraph
(
value
!=
null
?
value
.
toString
()
:
""
)
.
setFont
(
font
)
.
setFontSize
(
FontSize
)
.
setTextAlignment
(
TextAlignment
.
LEFT
)
// 设置文字对齐方式
.
setMarginLeft
(
1
f
);
// 设置左缩进
if
(
bold
)
{
paragraph
.
setBold
();
}
document
.
add
(
paragraph
);
}
private
static
String
numberTo
(
int
number
)
{
char
[]
cs
=
"零一二三四五六七八九"
.
toCharArray
();
String
temp
=
""
;
while
(
number
>
0
)
{
temp
+=
cs
[
number
%
10
];
number
/=
10
;
}
return
temp
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment