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
1e7edc13
Commit
1e7edc13
authored
Dec 12, 2024
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
excel to image -fxj
parent
34f652a7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
242 additions
and
145 deletions
+242
-145
CommonConstants.java
...ud/plus/v1/yifu/common/core/constant/CommonConstants.java
+2
-0
SocialHandleSearchVo.java
...fu/cloud/plus/v1/yifu/social/vo/SocialHandleSearchVo.java
+8
-0
pom.xml
yifu-social/yifu-social-biz/pom.xml
+1
-16
TDispatchInfoServiceImpl.java
...v1/yifu/social/service/impl/TDispatchInfoServiceImpl.java
+176
-42
ExcelMergeImage.java
.../yifu/cloud/plus/v1/yifu/social/util/ExcelMergeImage.java
+31
-80
ExcelToImage.java
...com/yifu/cloud/plus/v1/yifu/social/util/ExcelToImage.java
+13
-2
TDispatchInfoMapper.xml
...ial-biz/src/main/resources/mapper/TDispatchInfoMapper.xml
+11
-5
No files found.
yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/constant/CommonConstants.java
View file @
1e7edc13
...
...
@@ -632,4 +632,6 @@ public interface CommonConstants {
List
<
String
>
socialInfoStatus
=
Stream
.
of
(
"1"
,
"3"
,
"5"
,
"7"
).
collect
(
Collectors
.
toList
());
String
USER_DIR
=
"user.dir"
;
String
DOUBLE_LINE
=
"//"
;
}
yifu-social/yifu-social-api/src/main/java/com/yifu/cloud/plus/v1/yifu/social/vo/SocialHandleSearchVo.java
View file @
1e7edc13
...
...
@@ -153,4 +153,12 @@ public class SocialHandleSearchVo extends TDispatchInfo {
@Schema
(
description
=
"社保ID"
)
@ExcelIgnore
private
String
socialId
;
/**
* 税友自动化办理,此标识区分于页面的导出功能,值为1 时 默认取值派单审核通过 且 未办理的派单数据
*/
@ExcelAttribute
(
name
=
"税友自动化办理"
)
@ExcelIgnore
@Schema
(
description
=
"税友自动化办理"
)
private
String
syFlag
;
}
yifu-social/yifu-social-biz/pom.xml
View file @
1e7edc13
...
...
@@ -99,22 +99,7 @@
<version>
1.0.0
</version>
</dependency>
<!-- Apache POI -->
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
5.2.3
</version>
<!-- 使用最新版本 -->
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
5.2.3
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
2.12.0
</version>
</dependency>
<!-- excel to image -->
<dependency>
<groupId>
spire.xls
</groupId>
<artifactId>
spire.xls
</artifactId>
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/impl/TDispatchInfoServiceImpl.java
View file @
1e7edc13
...
...
@@ -61,7 +61,9 @@ import com.yifu.cloud.plus.v1.yifu.social.constants.DispatchConstants;
import
com.yifu.cloud.plus.v1.yifu.social.constants.PreDispatchConstants
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.*
;
import
com.yifu.cloud.plus.v1.yifu.social.mapper.*
;
import
com.yifu.cloud.plus.v1.yifu.social.service.*
;
import
com.yifu.cloud.plus.v1.yifu.social.service.TDispatchInfoService
;
import
com.yifu.cloud.plus.v1.yifu.social.service.TDispatchSocialFundInfoService
;
import
com.yifu.cloud.plus.v1.yifu.social.service.TForecastLibraryService
;
import
com.yifu.cloud.plus.v1.yifu.social.util.DoSocialTask
;
import
com.yifu.cloud.plus.v1.yifu.social.util.ExcelMergeImage
;
import
com.yifu.cloud.plus.v1.yifu.social.util.ExcelToImage
;
...
...
@@ -97,7 +99,7 @@ import java.util.stream.Collectors;
* 派单信息记录表
*
* @author fxj
* @
d
ate 2022-07-15 11:38:05
* @
D
ate 2022-07-15 11:38:05
*/
@Log4j2
@RequiredArgsConstructor
...
...
@@ -127,10 +129,6 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
private
final
TForecastLibraryService
forecastLibraryService
;
private
final
TIncomeDetailService
detailService
;
private
final
TIncomeService
incomeService
;
ExcelUtil
<
Object
>
excelUtil
=
new
ExcelUtil
<>(
Object
.
class
);
private
final
MenuUtil
menuUtil
;
...
...
@@ -149,6 +147,9 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
@Autowired
private
SysHouseHoldInfoMapper
houseHoldInfoMapper
;
@Autowired
private
TAttaInfoMapper
attaInfoMapper
;
/**
* 派单信息记录表简单分页查询
*
...
...
@@ -7521,7 +7522,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
}
/**
* @Author fxj
* @Description
* @Description
查询当月已经审核通过的未办理完成的社保或医保 增减信息
* @Date 15:58 2024/12/10
* @Param socialId:社保明细ID type: 1 社保增 2社保减 3 医保增 4 医保减
* @return
...
...
@@ -7534,7 +7535,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
}
TSocialInfo
socialInfo
=
socialMapper
.
selectById
(
socialId
);
if
(
Common
.
isEmpty
(
socialInfo
)){
return
R
.
failed
(
CommonConstants
.
PARAM_IS_NOT_ERROR
);
return
R
.
failed
(
CommonConstants
.
PARAM_IS_NOT_ERROR
+
":未获取到社保明细信息"
);
}
//查询户名称对应的户配置 以获取公章信息
SysHouseHoldInfo
holdInfo
=
houseHoldInfoMapper
.
selectOne
(
Wrappers
.<
SysHouseHoldInfo
>
query
().
lambda
()
...
...
@@ -7543,27 +7544,29 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
.
eq
(
SysHouseHoldInfo:
:
getDelFlag
,
0
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isEmpty
(
holdInfo
)){
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":获取户配置失败"
);
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":获取户配置
信息
失败"
);
}
SysBaseSetInfo
socialBaseSet
=
baseSetMapper
.
selectById
(
socialInfo
.
getSocialHousehold
(
));
if
(
Common
.
isEmpty
(
socialBaseSe
t
)){
return
R
.
failed
(
CommonConstants
.
PARAM_IS_NOT_ERROR
);
TAttaInfo
att
=
attaInfoMapper
.
selectOne
(
Wrappers
.<
TAttaInfo
>
query
().
lambda
()
.
eq
(
TAttaInfo:
:
getDomainId
,
holdInfo
.
getId
()).
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isEmpty
(
at
t
)){
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":获取电子印章信息失败"
);
}
searchVo
.
setSocialHouseholdName
(
socialInfo
.
getSocialHouseholdName
());
//searchVo.setDisMonth(DateUtil.getThisMonth());
searchVo
.
setDisMonth
(
"202410"
);
searchVo
.
setAuditStatus
(
CommonConstants
.
ZERO_STRING
);
//searchVo.setSocialHandleStatus(CommonConstants.ZERO_STRING);
searchVo
.
setUnitCreditCode
(
unitCreditCode
);
searchVo
.
setDisMonth
(
DateUtil
.
getThisMonth
());
searchVo
.
setSyFlag
(
CommonConstants
.
ONE_STRING
);
//税友特殊处理标识
searchVo
.
setSocialId
(
socialId
);
String
fileName
=
DispatchConstants
.
SOCIAL_MEDICAL_EXPORT
+
searchVo
.
getSocialHouseholdName
()
+
"_"
+
socialId
+
CommonConstants
.
XLS
;
String
projectRoot
=
System
.
getProperty
(
CommonConstants
.
USER_DIR
);
String
filePath
=
projectRoot
+
CommonConstants
.
DOUBLE_LINE
+
fileName
;
//社保增减
if
(
CommonConstants
.
ONE_STRING
.
equals
(
type
)
||
CommonConstants
.
TWO_STRING
.
equals
(
type
)){
return
doExportRosterSocial
(
searchVo
,
type
);
return
doExportRosterSocial
(
searchVo
,
type
,
fileName
,
projectRoot
,
filePath
,
att
.
getAttaSrc
()
);
}
//医保增减
if
(
CommonConstants
.
THREE_STRING
.
equals
(
type
)
||
CommonConstants
.
FOUR_STRING
.
equals
(
type
)){
return
doExportRosterMedical
(
searchVo
,
type
);
return
doExportRosterMedical
(
searchVo
,
type
,
fileName
,
projectRoot
,
filePath
,
att
.
getAttaSrc
()
);
}
return
null
;
}
...
...
@@ -7574,13 +7577,21 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
* @Param
* @return
**/
public
R
<
URL
>
doExportRosterMedical
(
SocialHandleSearchVo
searchVo
,
String
type
){
String
fileName
=
DispatchConstants
.
SOCIAL_MEDICAL_EXPORT
+
searchVo
.
getSocialHouseholdName
()
+
"_"
+
DateUtil
.
getThisMonth
()
+
CommonConstants
.
XLSX
;
public
R
<
URL
>
doExportRosterMedical
(
SocialHandleSearchVo
searchVo
,
String
type
,
String
fileName
,
String
projectRoot
,
String
filePath
,
String
src
){
//获取要导出的列表
List
<
TDispatchSocialExportVo
>
list
=
new
ArrayList
<>();
try
(
FileOutputStream
out
=
new
FileOutputStream
(
fileName
)){
File
createFile
=
null
;
ExcelWriter
excelWriter
=
null
;
try
{
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter
excelWriter
=
EasyExcel
.
write
(
out
).
build
();
createFile
=
new
File
(
filePath
);
excelWriter
=
EasyExcel
.
write
(
createFile
).
build
();
WriteSheet
writeSheet
;
WriteTable
writeTable0
;
WriteTable
writeTable1
;
...
...
@@ -7712,11 +7723,87 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
if
(
excelWriter
!=
null
)
{
excelWriter
.
finish
();
}
File
outFile
=
null
;
File
inputFile
=
null
;
File
tempFile
=
null
;
FileInputStream
inputStream
=
null
;
FileOutputStream
fileOUt
=
null
;
InputStream
inStream
=
null
;
FileInputStream
inputStreamOut
=
null
;
try
{
//读取文件 生成电子章
inputFile
=
new
File
(
filePath
);
inputStream
=
new
FileInputStream
(
inputFile
);
String
tempPath
=
projectRoot
+
"//temp_"
+
fileName
;
tempFile
=
new
File
(
tempPath
);
fileOUt
=
new
FileOutputStream
(
tempFile
);
URL
url
=
ossUtil
.
getObjectUrl
(
null
,
src
);
if
(
Common
.
isEmpty
(
url
)){
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":电子印章OSS获取URL异常"
);
}
inStream
=
url
.
openStream
();
if
(
Common
.
isEmpty
(
inStream
)){
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":电子印章OSS获取流异常"
);
}
// 添加电子章 完成后关闭所有流
excelMergeImage
.
addPictureToExcel
(
inputStream
,
inStream
,
fileOUt
,
0
,
type
);
outFile
=
new
File
(
tempPath
);
inputStreamOut
=
new
FileInputStream
(
outFile
);
// 转换成图片 完成后清理流
return
excelToImage
.
excelToImg
(
inputStreamOut
,
ossUtil
);
}
catch
(
Exception
e
){
log
.
error
(
"执行异常"
,
e
);
return
R
.
failed
(
"税友附件生成异常:"
+
e
.
getMessage
());
}
finally
{
// 清理文件
finallyClose
(
inputFile
,
tempFile
,
outFile
,
inputStream
,
fileOUt
,
inStream
,
inputStreamOut
);
}
}
catch
(
Exception
e
){
if
(
excelWriter
!=
null
)
{
excelWriter
.
finish
();
}
log
.
error
(
"税友附件生成异常"
,
e
);
return
R
.
failed
(
"税友附件生成异常:"
+
e
.
getMessage
());
}
finally
{
if
(
null
!=
createFile
&&
createFile
.
exists
()){
createFile
.
delete
();
}
if
(
null
!=
list
){
list
.
clear
();
}
}
return
null
;
}
private
void
finallyClose
(
File
inputFile
,
File
tempFile
,
File
outFile
,
FileInputStream
inputStream
,
FileOutputStream
fileOUt
,
InputStream
inStream
,
FileInputStream
inputStreamOut
)
throws
IOException
{
if
(
inputFile
.
exists
()){
inputFile
.
delete
();
}
if
(
tempFile
.
exists
()){
tempFile
.
delete
();
}
if
(
outFile
.
exists
()){
outFile
.
delete
();
}
if
(
null
!=
inputStream
){
inputStream
.
close
();
}
if
(
null
!=
fileOUt
){
fileOUt
.
close
();
}
if
(
null
!=
inStream
){
inStream
.
close
();
}
if
(
null
!=
inputStreamOut
){
inputStreamOut
.
close
();
}
}
/**
* @Author fxj
* @Description 社保增减花名册
...
...
@@ -7724,15 +7811,20 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
* @Param
* @return
**/
public
R
<
URL
>
doExportRosterSocial
(
SocialHandleSearchVo
searchVo
,
String
type
){
String
fileName
=
DispatchConstants
.
SOCIAL_MEDICAL_EXPORT
+
searchVo
.
getSocialHouseholdName
()
+
"_"
+
DateUtil
.
getThisMonth
()
+
CommonConstants
.
XLS
;
String
projectRoot
=
System
.
getProperty
(
"user.dir"
);
String
filePath
=
projectRoot
+
"//"
+
fileName
;
public
R
<
URL
>
doExportRosterSocial
(
SocialHandleSearchVo
searchVo
,
String
type
,
String
fileName
,
String
projectRoot
,
String
filePath
,
String
src
){
//获取要导出的列表
List
<
TDispatchSocialPersionExportVo
>
list
=
new
ArrayList
<>();
ExcelWriter
excelWriter
=
null
;
File
createFile
=
null
;
try
{
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter
excelWriter
=
EasyExcel
.
write
(
filePath
).
build
();
createFile
=
new
File
(
filePath
);
excelWriter
=
EasyExcel
.
write
(
createFile
).
build
();
WriteSheet
writeSheet
;
WriteTable
writeTable0
;
WriteTable
writeTable1
;
...
...
@@ -7815,7 +7907,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
excelWriter
.
write
(
new
ArrayList
<>(),
writeSheet
,
writeTable3
);
excelWriter
.
write
(
new
ArrayList
<>(),
writeSheet
,
writeTable4
);
}
}
else
if
(
CommonConstants
.
ONE
_STRING
.
equals
(
type
)){
}
else
if
(
CommonConstants
.
TWO
_STRING
.
equals
(
type
)){
//派减的数据--社保
searchVo
.
setType
(
CommonConstants
.
ONE_STRING
);
long
count1
=
getSocialPersionReduceDisCount
(
searchVo
);
...
...
@@ -7885,23 +7977,65 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
excelWriter
.
write
(
listReduce
,
writeSheet
,
writeTable2
);
excelWriter
.
write
(
new
ArrayList
<>(),
writeSheet
,
writeTable3
);
}
if
(
Common
.
isNotNull
(
listReduce
)){
listReduce
.
clear
();
}
}
if
(
excelWriter
!=
null
)
{
excelWriter
.
finish
();
}
File
inputFile
=
null
;
File
tempFile
=
null
;
File
outFile
=
null
;
FileInputStream
inputStream
=
null
;
FileOutputStream
fileOUt
=
null
;
InputStream
inStream
=
null
;
FileInputStream
inputStreamOut
=
null
;
try
{
//读取文件 生成电子章
FileInputStream
inputStream
=
new
FileInputStream
(
filePath
);
String
outPath
=
projectRoot
+
"//out_"
+
fileName
;
FileOutputStream
fileOUt
=
new
FileOutputStream
(
outPath
);
URL
url
=
ossUtil
.
getObjectUrl
(
null
,
""
);
InputStream
inStream
=
url
.
openStream
();
excelMergeImage
.
addPictureToExcel
(
inputStream
,
inStream
,
fileOUt
,
0
);
inputFile
=
new
File
(
filePath
);
inputStream
=
new
FileInputStream
(
inputFile
);
String
tempPath
=
projectRoot
+
"//temp_"
+
fileName
;
tempFile
=
new
File
(
tempPath
);
fileOUt
=
new
FileOutputStream
(
tempFile
);
URL
url
=
ossUtil
.
getObjectUrl
(
null
,
src
);
if
(
Common
.
isEmpty
(
url
)){
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":电子印章OSS获取URL异常"
);
}
inStream
=
url
.
openStream
();
if
(
Common
.
isEmpty
(
inStream
)){
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":电子印章OSS获取流异常"
);
}
// 添加电子章 完成后关闭所有流
excelMergeImage
.
addPictureToExcel
(
inputStream
,
inStream
,
fileOUt
,
0
,
type
);
outFile
=
new
File
(
tempPath
);
inputStreamOut
=
new
FileInputStream
(
outFile
);
// 转换成图片 完成后清理流
return
excelToImage
.
excelToImg
(
inputStreamOut
,
ossUtil
);
}
catch
(
Exception
e
){
log
.
error
(
"执行异常"
,
e
);
return
R
.
failed
(
"税友附件生成异常:"
+
e
.
getMessage
());
}
finally
{
// 清理文件
finallyClose
(
inputFile
,
tempFile
,
outFile
,
inputStream
,
fileOUt
,
inStream
,
inputStreamOut
);
}
}
catch
(
Exception
e
){
if
(
excelWriter
!=
null
)
{
excelWriter
.
finish
();
}
log
.
error
(
"税友附件生成异常"
,
e
);
return
R
.
failed
(
"税友附件生成异常:"
+
e
.
getMessage
());
}
finally
{
finallyClear
(
list
,
createFile
);
}
}
return
null
;
private
void
finallyClear
(
List
<
TDispatchSocialPersionExportVo
>
list
,
File
createFile
)
{
if
(
null
!=
createFile
&&
createFile
.
exists
()){
createFile
.
delete
();
}
if
(
null
!=
list
){
list
.
clear
();
}
}
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/util/ExcelMergeImage.java
View file @
1e7edc13
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
social
.
util
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
lombok.extern.log4j.Log4j2
;
import
org.apache.commons.compress.utils.IOUtils
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.stereotype.Component
;
import
javax.imageio.ImageIO
;
import
java.awt.Color
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.io.*
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
/**
* @Author fxj
...
...
@@ -18,74 +18,10 @@ import java.io.*;
* @Description
* @Version 1.0
*/
@Log4j2
@Component
public
class
ExcelMergeImage
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
String
excelFilePath
=
"E:\\test\\11\\1.xls"
;
String
imageFilePath
=
"E:\\test\\11\\1.png"
;
//convertExcelToImage(excelFilePath, imageFilePath);
//stampAdder();
}
public
static
void
convertExcelToImage
(
String
excelFilePath
,
String
imageFilePath
)
throws
IOException
{
FileInputStream
fis
=
new
FileInputStream
(
new
File
(
excelFilePath
));
Workbook
workbook
;
if
(
excelFilePath
.
endsWith
(
".xls"
))
{
workbook
=
new
HSSFWorkbook
(
fis
);
// For Excel 97-2003 (.xls) format
}
else
if
(
excelFilePath
.
endsWith
(
".xlsx"
))
{
workbook
=
new
XSSFWorkbook
(
fis
);
// For Excel 2007 and later (.xlsx) format
}
else
{
throw
new
IllegalArgumentException
(
"Unsupported file type"
);
}
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
int
rowCount
=
16
;
//sheet.getPhysicalNumberOfRows();
int
colCount
=
25
;
//sheet.getRow(0).getPhysicalNumberOfCells();
BufferedImage
image
=
new
BufferedImage
(
896
,
424
,
BufferedImage
.
TYPE_INT_RGB
);
Graphics2D
graphics
=
image
.
createGraphics
();
for
(
int
i
=
0
;
i
<
rowCount
;
i
++)
{
Row
row
=
sheet
.
getRow
(
i
);
for
(
int
j
=
0
;
j
<
colCount
;
j
++)
{
Cell
cell
=
row
.
getCell
(
j
);
if
(
cell
!=
null
)
{
graphics
.
fillRect
(
j
*
150
,
i
*
47
,
896
,
424
);
graphics
.
setColor
(
Color
.
black
);
// 设置边框颜色
graphics
.
drawRect
(
j
*
150
,
i
*
47
,
896
,
424
);
String
cellValue
=
getCellValueAsString
(
cell
);
graphics
.
drawString
(
cellValue
,
j
*
150
+
10
,
i
*
45
+
30
);
}
}
}
graphics
.
dispose
();
ImageIO
.
write
(
image
,
"png"
,
new
File
(
imageFilePath
));
workbook
.
close
();
fis
.
close
();
}
private
static
String
getCellValueAsString
(
Cell
cell
)
{
String
cellValue
=
""
;
if
(
cell
!=
null
)
{
switch
(
cell
.
getCellType
())
{
case
STRING:
cellValue
=
cell
.
getStringCellValue
();
break
;
case
NUMERIC:
cellValue
=
String
.
valueOf
(
cell
.
getNumericCellValue
());
break
;
case
BOOLEAN:
cellValue
=
String
.
valueOf
(
cell
.
getBooleanCellValue
());
break
;
case
FORMULA:
cellValue
=
cell
.
getCellFormula
();
break
;
default
:
cellValue
=
""
;
}
}
return
cellValue
;
}
/**
* @Author fxj
* @Description 03格式excel添加电子印章或图片
...
...
@@ -93,10 +29,10 @@ public class ExcelMergeImage {
* @Param
* @return
**/
public
FileOutputStream
addPictureToExcel
(
FileInputStream
fis
,
public
void
addPictureToExcel
(
FileInputStream
fis
,
InputStream
imageIs
,
FileOutputStream
fileOut
,
int
SheetNum
){
int
SheetNum
,
String
type
){
Workbook
workbook
=
null
;
try
{
workbook
=
new
HSSFWorkbook
(
fis
);
...
...
@@ -107,14 +43,24 @@ public class ExcelMergeImage {
ClientAnchor
anchor
=
helper
.
createClientAnchor
();
anchor
.
setCol1
(
2
);
anchor
.
setRow1
(
0
);
// 按花名册类型特殊处理对应印章的效果
if
(
CommonConstants
.
TWO_STRING
.
equals
(
type
)){
anchor
.
setCol2
(
5
);
anchor
.
setRow2
(
6
);
}
else
if
(
CommonConstants
.
FOUR_STRING
.
equals
(
type
)
||
CommonConstants
.
THREE_STRING
.
equals
(
type
)){
anchor
.
setCol2
(
5
);
anchor
.
setRow2
(
8
);
}
else
{
anchor
.
setCol2
(
4
);
anchor
.
setRow2
(
7
);
}
// 添加印章图片
int
pictureIdx
=
workbook
.
addPicture
(
IOUtils
.
toByteArray
(
imageIs
),
Workbook
.
PICTURE_TYPE_PNG
);
drawing
.
createPicture
(
anchor
,
pictureIdx
);
workbook
.
write
(
fileOut
);
}
catch
(
Exception
e
){
e
.
printStackTrace
(
);
log
.
error
(
"excel插入电子印章异常:{}"
,
e
.
getMessage
()
);
}
finally
{
try
{
if
(
null
!=
fis
){
...
...
@@ -123,10 +69,15 @@ public class ExcelMergeImage {
if
(
null
!=
workbook
){
workbook
.
close
();
}
if
(
null
!=
imageIs
){
imageIs
.
close
();
}
if
(
null
!=
fileOut
){
fileOut
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
fileOut
;
}
}
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/util/ExcelToImage.java
View file @
1e7edc13
...
...
@@ -6,9 +6,11 @@ import com.spire.xls.Worksheet;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
groovyjarjarpicocli.CommandLine
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
...
...
@@ -22,7 +24,10 @@ import java.net.URL;
public
class
ExcelToImage
{
public
R
<
URL
>
excelToImg
(
InputStream
inputStream
,
OSSUtil
ossUtil
){
String
projectRoot
=
System
.
getProperty
(
"user.dir"
);
if
(
null
==
inputStream
||
null
==
ossUtil
){
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":带印章excel生成图片传参异常"
);
}
String
projectRoot
=
System
.
getProperty
(
CommonConstants
.
USER_DIR
);
//加载Excel工作表
Workbook
wb
=
new
Workbook
();
wb
.
loadFromHtml
(
inputStream
);
...
...
@@ -42,12 +47,18 @@ public class ExcelToImage {
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":ExcelToImage转换异常-"
+
e
.
getMessage
());
}
finally
{
if
(
file
.
exists
()){
file
.
delete
();
}
if
(
null
!=
inputStream
){
try
{
inputStream
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
);
//调用方法,将指定Excel单元格数据范围保存为图片
...
...
yifu-social/yifu-social-biz/src/main/resources/mapper/TDispatchInfoMapper.xml
View file @
1e7edc13
...
...
@@ -2260,10 +2260,12 @@
a.DELETE_FLAG = 0
AND a.social_id is not null
<if
test=
'tDispatchInfo.socialId != null and tDispatchInfo.socialId.trim() == "0" '
>
AND a.social_id = #{tDispatchInfo.socialId}
<if
test=
"tDispatchInfo.socialId != null and tDispatchInfo.socialId.trim() != ''"
>
AND a.SOCIAL_ID = #{tDispatchInfo.socialId}
</if>
<if
test=
"tDispatchInfo.syFlag != null and tDispatchInfo.syFlag.trim() == '1'"
>
AND a.STATUS = '2'
</if>
<!-- dispatch-status 未提交1待审核2审核通过3审核不通过4办理完成5待SSC审核 -->
<if
test=
'tDispatchInfo.auditStatus != null and tDispatchInfo.auditStatus.trim() == "0" '
>
AND a.STATUS in ('2','4')
...
...
@@ -2360,9 +2362,13 @@
<sql
id=
"where_getSocialPersionDisRecord"
>
a.DELETE_FLAG = 0
AND a.social_id is not null
<if
test=
'tDispatchInfo.socialId != null and tDispatchInfo.socialId.trim() == "0" '
>
AND a.
social_id
= #{tDispatchInfo.socialId}
<if
test=
"tDispatchInfo.socialId != null and tDispatchInfo.socialId.trim() != ''"
>
AND a.
SOCIAL_ID
= #{tDispatchInfo.socialId}
</if>
<if
test=
"tDispatchInfo.syFlag != null and tDispatchInfo.syFlag.trim() == '1'"
>
AND a.STATUS = '2'
</if>
<!-- dispatch-status 未提交1待审核2审核通过3审核不通过4办理完成5待SSC审核 -->
<if
test=
'tDispatchInfo.auditStatus != null and tDispatchInfo.auditStatus.trim() == "0"'
>
AND a.STATUS in ('2','4')
...
...
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