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
c98e4f23
Commit
c98e4f23
authored
Dec 10, 2024
by
huyuchen
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/MVP1.7.3' into MVP1.7.3
parents
ecf1d1f9
9ee5cdfb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
237 additions
and
8 deletions
+237
-8
TCustomerInfo.java
...ifu/cloud/plus/v1/yifu/archives/entity/TCustomerInfo.java
+3
-0
TEmployeeContractInfoServiceImpl.java
...chives/service/impl/TEmployeeContractInfoServiceImpl.java
+2
-8
pom.xml
yifu-social/yifu-social-biz/pom.xml
+23
-0
ExcelMergeImage.java
.../yifu/cloud/plus/v1/yifu/social/util/ExcelMergeImage.java
+130
-0
ExcelToImage.java
...com/yifu/cloud/plus/v1/yifu/social/util/ExcelToImage.java
+79
-0
No files found.
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/entity/TCustomerInfo.java
View file @
c98e4f23
...
...
@@ -17,10 +17,12 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jdk.nashorn.internal.ir.annotations.Ignore
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
...
...
@@ -251,6 +253,7 @@ public class TCustomerInfo extends BaseEntity {
@Schema
(
description
=
"账户余额"
)
private
BigDecimal
balance
;
@TableField
(
exist
=
false
)
private
List
<
String
>
customerIds
;
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmployeeContractInfoServiceImpl.java
View file @
c98e4f23
...
...
@@ -91,7 +91,6 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
private
final
TEmployeeInfoMapper
tEmployeeInfoMapper
;
private
final
TEmployeeProjectService
tEmployeeProjectService
;
private
final
TSettleDomainService
tSettleDomainService
;
private
final
TCustomerInfoService
tCustomerInfoService
;
private
final
TAttaInfoService
tAttaInfoService
;
private
final
TEmployeeContractAuditService
tEmployeeContractAuditService
;
private
final
TEmployeeLogService
tEmployeeLogService
;
...
...
@@ -467,13 +466,8 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
if
(
Common
.
isEmpty
(
tEmployeeContractInfo
.
getSubjectDepart
()))
{
tEmployeeContractInfo
.
setSubjectDepart
(
settleDomain
.
getDepartName
());
tEmployeeContractInfo
.
setDeptNo
(
settleDomain
.
getDepartNo
());
}
if
(
null
!=
settleDomain
.
getCustomerId
()
&&
Common
.
isEmpty
(
tEmployeeContractInfo
.
getSubjectUnit
()))
{
TCustomerInfo
customerInfo
=
tCustomerInfoService
.
getById
(
settleDomain
.
getCustomerId
());
if
(
null
!=
customerInfo
)
{
tEmployeeContractInfo
.
setSubjectUnit
(
customerInfo
.
getCustomerName
());
tEmployeeContractInfo
.
setUnitNo
(
customerInfo
.
getCustomerCode
());
}
tEmployeeContractInfo
.
setSubjectUnit
(
settleDomain
.
getCustomerName
());
tEmployeeContractInfo
.
setUnitNo
(
settleDomain
.
getCustomerNo
());
}
}
}
...
...
yifu-social/yifu-social-biz/pom.xml
View file @
c98e4f23
...
...
@@ -98,6 +98,29 @@
<artifactId>
yifu-common-ekp
</artifactId>
<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>
<dependency>
<groupId>
spire.xls
</groupId>
<artifactId>
spire.xls
</artifactId>
<version>
5.3.0
</version>
<type>
jar
</type>
</dependency>
</dependencies>
<build>
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/util/ExcelMergeImage.java
0 → 100644
View file @
c98e4f23
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
social
.
util
;
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
javax.imageio.ImageIO
;
import
java.awt.Color
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.io.*
;
/**
* @Author fxj
* @Date 2024/12/9
* @Description
* @Version 1.0
*/
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添加电子印章或图片
* @Date 15:32 2024/12/9
* @Param
* @return
**/
public
static
FileOutputStream
addPictureToExcel
(
FileInputStream
fis
,
InputStream
imageIs
,
FileOutputStream
fileOut
,
int
SheetNum
){
Workbook
workbook
=
null
;
try
{
workbook
=
new
HSSFWorkbook
(
fis
);
Sheet
sheet
=
workbook
.
getSheetAt
(
SheetNum
);
// 在合适的位置添加印章
Drawing
<?>
drawing
=
sheet
.
createDrawingPatriarch
();
CreationHelper
helper
=
workbook
.
getCreationHelper
();
ClientAnchor
anchor
=
helper
.
createClientAnchor
();
anchor
.
setCol1
(
2
);
anchor
.
setRow1
(
0
);
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
();
}
finally
{
try
{
if
(
null
!=
fis
){
fis
.
close
();
}
if
(
null
!=
workbook
){
workbook
.
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
0 → 100644
View file @
c98e4f23
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
social
.
util
;
import
com.spire.xls.Workbook
;
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
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.net.URL
;
/**
* @Author fxj
* @Date 2024/12/9
* @Description excel 转换为 图片 并上传阿里云 (上传后自动删除生成的图片文件)
* @Version 1.0
*/
@RequiredArgsConstructor
@Component
public
class
ExcelToImage
{
@Autowired
private
static
OSSUtil
ossUtil
;
public
R
<
URL
>
excelToImg
(
InputStream
inputStream
){
String
projectRoot
=
System
.
getProperty
(
"user.dir"
);
//加载Excel工作表
Workbook
wb
=
new
Workbook
();
wb
.
loadFromHtml
(
inputStream
);
//获取工作表
Worksheet
sheet
=
wb
.
getWorksheets
().
get
(
0
);
//调用方法将Excel工作表保存为图片
sheet
.
saveToImage
(
projectRoot
+
"\\ToImg.png"
);
File
file
=
null
;
try
{
file
=
new
File
(
projectRoot
+
"\\ToImg.png"
);
if
(
file
.
exists
()){
String
key
=
System
.
currentTimeMillis
()
+
file
.
getName
();
if
(
ossUtil
.
uploadFileByFile
(
file
,
key
,
null
)){
return
R
.
ok
(
ossUtil
.
getObjectUrl
(
null
,
key
));
}
else
{
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":ExcelToImage上传OSS异常"
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":ExcelToImage转换异常-"
+
e
.
getMessage
());
}
finally
{
if
(
file
.
exists
()){
file
.
delete
();
}
}
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
);
//调用方法,将指定Excel单元格数据范围保存为图片
//sheet.saveToImage("ToImg2.png",8,1,30,7);
/*//调用方法将Excel保存为HTML
sheet.saveToHtml("ToHtml.html");
//调用方法将Excel保存为XPS
sheet.saveToFile("ToXPS.xps", String.valueOf(FileFormat.XPS));
//调用方法将Excel保存为CSV
sheet.saveToFile("ToCSV.csv", String.valueOf(FileFormat.CSV));
//调用方法将Excel保存为XML
sheet.saveToFile("ToXML.xml", String.valueOf(FileFormat.XML));
//调用方法将Excel保存为PostScript
sheet.saveToFile("ToPostScript.postscript", String.valueOf(FileFormat.PostScript));
//调用方法将Excel保存为PCL
sheet.saveToFile("ToPCL.pcl", String.valueOf(FileFormat.PCL));*/
}
}
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