Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
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
fangxinjiang
yifu-mvp
Commits
12c9484a
Commit
12c9484a
authored
Apr 16, 2026
by
fangxinjiang
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/MVP1.7.22' into MVP1.7.22
parents
39b425cb
2a899af0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
176 additions
and
9 deletions
+176
-9
pom.xml
yifu-social/yifu-social-biz/pom.xml
+5
-0
TSocialFriendController.java
...us/v1/yifu/social/controller/TSocialFriendController.java
+1
-1
TSocialFriendServiceImpl.java
...v1/yifu/social/service/impl/TSocialFriendServiceImpl.java
+4
-0
ExcelToImage.java
...com/yifu/cloud/plus/v1/yifu/social/util/ExcelToImage.java
+45
-8
NewExcelToImage.java
.../yifu/cloud/plus/v1/yifu/social/util/NewExcelToImage.java
+121
-0
No files found.
yifu-social/yifu-social-biz/pom.xml
View file @
12c9484a
...
...
@@ -117,6 +117,11 @@
<artifactId>
aspose-words
</artifactId>
<version>
23.1
</version>
</dependency>
<dependency>
<groupId>
com.luhuiguo
</groupId>
<artifactId>
aspose-cells
</artifactId>
<version>
23.1
</version>
</dependency>
</dependencies>
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/controller/TSocialFriendController.java
View file @
12c9484a
...
...
@@ -92,7 +92,7 @@ public class TSocialFriendController {
@SysLog
(
"定时任务清理临时文件"
)
@Inner
public
void
doClearFriend
()
{
tSocialFriendPushService
.
doClearFriend
();
//
tSocialFriendPushService.doClearFriend();
}
@Operation
(
description
=
"2定时任务获取税友"
)
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/impl/TSocialFriendServiceImpl.java
View file @
12c9484a
...
...
@@ -358,6 +358,7 @@ public class TSocialFriendServiceImpl extends ServiceImpl<TSocialFriendMapper, T
}
}
updateSocial
.
setYgsHandleStatus
(
ygsHandleStatus
);
updateSocial
.
setYgsHandleStatusOld
(
""
);
// 拉取审核结果,加日志
if
(
Common
.
isNotNull
(
ygsHandleStatus
))
{
socialLog
=
tSocialSoldierLogService
.
getSocialFriendLog
(
socialInfo
,
"拉取"
,
"社保"
...
...
@@ -448,6 +449,7 @@ public class TSocialFriendServiceImpl extends ServiceImpl<TSocialFriendMapper, T
}
}
updateSocial
.
setYsdHandleStatus
(
ysdHandleStatus
);
updateSocial
.
setYsdHandleStatusOld
(
""
);
// 拉取审核结果,加日志
if
(
Common
.
isNotNull
(
ysdHandleStatus
))
{
...
...
@@ -639,6 +641,7 @@ public class TSocialFriendServiceImpl extends ServiceImpl<TSocialFriendMapper, T
updateSocial
=
new
TSocialInfo
();
updateSocial
.
setId
(
socialInfo
.
getId
());
updateSocial
.
setYgsHandleStatus
(
ygsHandleStatus
);
updateSocial
.
setYgsHandleStatusOld
(
""
);
// 处理社保办理成功或失败,
if
(
Common
.
isNotNull
(
updateSocial
.
getId
()))
{
tSocialInfoService
.
updateById
(
updateSocial
);
...
...
@@ -652,6 +655,7 @@ public class TSocialFriendServiceImpl extends ServiceImpl<TSocialFriendMapper, T
updateSocial
=
new
TSocialInfo
();
updateSocial
.
setId
(
socialInfo
.
getId
());
updateSocial
.
setYsdHandleStatus
(
ygsHandleStatus
);
updateSocial
.
setYsdHandleStatusOld
(
""
);
// 处理社保办理成功或失败,
if
(
Common
.
isNotNull
(
updateSocial
.
getId
()))
{
tSocialInfoService
.
updateById
(
updateSocial
);
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/util/ExcelToImage.java
View file @
12c9484a
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
social
.
util
;
import
com.aspose.cells.ImageOrPrintOptions
;
import
com.aspose.cells.ImageType
;
import
com.aspose.cells.SheetRender
;
import
com.spire.xls.Workbook
;
import
com.spire.xls.Worksheet
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
...
...
@@ -10,7 +13,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import
com.yifu.cloud.plus.v1.yifu.social.config.SocialFriendConfig
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFriendBackLog
;
import
com.yifu.cloud.plus.v1.yifu.social.service.TSocialFriendBackLogService
;
import
com.yifu.cloud.plus.v1.yifu.social.vo.SociaFriendYgsAddVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
...
...
@@ -18,7 +21,6 @@ import javax.imageio.ImageIO;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
...
...
@@ -35,6 +37,9 @@ import java.util.Base64;
@Component
public
class
ExcelToImage
{
@Autowired
private
WordToImageUtil
wordToImageUtil
;
private
final
static
String
toImag
=
"\\ToImg.png"
;
private
static
final
String
TO_IMAGE_TEMP
=
"\\ToImgTemp.png"
;
...
...
@@ -56,14 +61,15 @@ public class ExcelToImage {
File
tempFile
=
null
;
File
compressedTempFile
=
null
;
//加载Excel工作表
Workbook
wb
=
new
Workbook
();
//
Workbook wb = new Workbook();
try
{
wb
.
loadFromHtml
(
inputStream
);
/*wb.loadFromHtml(inputStream);
//获取工作表
Worksheet sheet = wb.getWorksheets().get(0);
sheet.saveToImage(toImagePath);*/
String
toImagePath
=
projectRoot
+
toImag
;
sheet
.
saveToImage
(
toImagePath
);
createWorksheetImage
(
inputStream
,
toImagePath
);
tempFile
=
new
File
(
toImagePath
);
// 上传税友文件服务器,返回文件路径
...
...
@@ -89,9 +95,9 @@ public class ExcelToImage {
e
.
printStackTrace
();
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
toImagConvertError
+
e
.
getMessage
());
}
finally
{
if
(
wb
!=
null
)
{
/*
if (wb != null) {
wb.dispose(); // 重要:释放资源并删除临时文件
}
}
*/
if
(
tempFile
!=
null
&&
tempFile
.
exists
()){
tempFile
.
delete
();
}
...
...
@@ -262,4 +268,35 @@ public class ExcelToImage {
sheet.saveToFile("ToPCL.pcl", String.valueOf(FileFormat.PCL));*/
}
/*public void excelToImageMain(String toImagePath) {
try {
createWorksheetImage(toImagePath);
} catch (Exception e) {
e.printStackTrace();
}
}*/
private
static
void
createWorksheetImage
(
InputStream
inputStream
,
String
toImagePath
)
{
com
.
aspose
.
cells
.
Workbook
workbook
=
null
;
try
{
workbook
=
new
com
.
aspose
.
cells
.
Workbook
(
inputStream
);
// 获取第一个工作表
com
.
aspose
.
cells
.
Worksheet
worksheet
=
workbook
.
getWorksheets
().
get
(
0
);
// 设置为适应内容大小
worksheet
.
getPageSetup
().
setZoom
(
100
);
// 转换为图片
ImageOrPrintOptions
options
=
new
ImageOrPrintOptions
();
options
.
setImageType
(
ImageType
.
PNG
);
options
.
setOnePagePerSheet
(
true
);
SheetRender
render
=
new
SheetRender
(
worksheet
,
options
);
render
.
toImage
(
0
,
toImagePath
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
workbook
!=
null
)
{
workbook
.
dispose
();
}
}
}
}
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/util/NewExcelToImage.java
0 → 100644
View file @
12c9484a
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
social
.
util
;
import
com.aspose.cells.*
;
import
org.apache.poi.xssf.usermodel.XSSFCell
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
java.io.*
;
import
java.nio.file.Files
;
// DEMO,实际应用见:ExcelToImage
public
class
NewExcelToImage
{
private
static
final
String
OUTPUT_DIR
=
"output"
;
private
static
final
String
IMAGE_FILE
=
OUTPUT_DIR
+
File
.
separator
+
"WorksheetToImage.png"
;
public
static
void
main
(
String
[]
args
)
{
try
{
new
File
(
OUTPUT_DIR
).
mkdirs
();
createWorksheetImage
();
System
.
out
.
println
(
"\n=== 转换完成!图片已保存到 output 目录 ==="
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
static
void
createWorksheetImage
()
{
System
.
out
.
println
(
"1.创建工作表并转换为图片..."
);
// 使用 try-with-resources 自动管理临时文件
File
tempExcelFile
=
null
;
try
(
XSSFWorkbook
workbook
=
new
XSSFWorkbook
())
{
// 1. 创建临时文件(自动删除)
tempExcelFile
=
File
.
createTempFile
(
"excel_temp_"
,
".xlsx"
);
tempExcelFile
.
deleteOnExit
();
// JVM退出时自动删除
// 2. 构建Excel内容
XSSFSheet
worksheet
=
workbook
.
createSheet
(
"sales Report"
);
// 标题行
XSSFRow
titleRow
=
worksheet
.
createRow
(
0
);
XSSFCell
titleCell
=
titleRow
.
createCell
(
0
);
titleCell
.
setCellValue
(
"sales Report"
);
// 表头行
XSSFRow
headerRow
=
worksheet
.
createRow
(
2
);
String
[]
headers
=
{
"Date"
,
"Product"
,
"Customer"
,
"Amount"
,
"show"
};
for
(
int
i
=
0
;
i
<
headers
.
length
;
i
++)
{
XSSFCell
cell
=
headerRow
.
createCell
(
i
);
cell
.
setCellValue
(
headers
[
i
]);
}
// 数据行
Object
[][]
data
=
{{
"1"
,
"2"
,
"3"
,
"4"
,
"5"
},
{
"6"
,
"7"
,
"8"
,
"9"
,
"10"
},
{
"11"
,
"12"
,
"13"
,
"14"
,
"15"
}};
for
(
int
i
=
0
;
i
<
data
.
length
;
i
++)
{
XSSFRow
row
=
worksheet
.
createRow
(
i
+
3
);
for
(
int
j
=
0
;
j
<
data
[
i
].
length
;
j
++)
{
XSSFCell
cell
=
row
.
createCell
(
j
);
cell
.
setCellValue
(
String
.
valueOf
(
data
[
i
][
j
]));
}
}
// 自动调整列宽
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
worksheet
.
autoSizeColumn
(
i
);
}
// 3. 写入临时文件(使用 try-with-resources)
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
tempExcelFile
))
{
workbook
.
write
(
fos
);
}
System
.
out
.
println
(
" √ Excel临时文件已创建:"
+
tempExcelFile
.
getAbsolutePath
());
// 4. 使用流方式读取并转换为图片(避免多次磁盘IO)
convertExcelToImage
(
tempExcelFile
,
IMAGE_FILE
);
System
.
out
.
println
(
" √ 工作表图片已保存:"
+
IMAGE_FILE
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
// 5. 清理临时文件
if
(
tempExcelFile
!=
null
&&
tempExcelFile
.
exists
())
{
boolean
deleted
=
tempExcelFile
.
delete
();
if
(
deleted
)
{
System
.
out
.
println
(
" √ 临时文件已清理:"
+
tempExcelFile
.
getName
());
}
}
}
}
/**
* 将Excel文件转换为图片(使用流方式)
*/
private
static
void
convertExcelToImage
(
File
excelFile
,
String
imagePath
)
throws
Exception
{
// 使用 try-with-resources 自动管理 Workbook 资源
try
(
FileInputStream
fis
=
new
FileInputStream
(
excelFile
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
())
{
// 从流加载Excel
Workbook
workbook
=
new
Workbook
(
fis
);
Worksheet
worksheet
=
workbook
.
getWorksheets
().
get
(
0
);
// 设置页面选项
ImageOrPrintOptions
options
=
new
ImageOrPrintOptions
();
options
.
setImageType
(
ImageType
.
PNG
);
options
.
setOnePagePerSheet
(
true
);
options
.
setHorizontalResolution
(
96
);
// 设置水平分辨率
options
.
setVerticalResolution
(
96
);
// 设置垂直分辨率
// 渲染工作表
SheetRender
render
=
new
SheetRender
(
worksheet
,
options
);
// 直接渲染到流(避免中间文件)
render
.
toImage
(
0
,
imagePath
);
}
}
}
\ No newline at end of file
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