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
c2edff36
Commit
c2edff36
authored
Dec 13, 2024
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
电子印章代码附件上传到税友-fxj
parent
2078c786
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
127 additions
and
11 deletions
+127
-11
SocialFriendConfig.java
.../cloud/plus/v1/yifu/social/config/SocialFriendConfig.java
+64
-0
TSocialFriendPushService.java
...plus/v1/yifu/social/service/TSocialFriendPushService.java
+1
-1
TSocialFriendPushServiceImpl.java
...ifu/social/service/impl/TSocialFriendPushServiceImpl.java
+15
-9
ExcelToImage.java
...com/yifu/cloud/plus/v1/yifu/social/util/ExcelToImage.java
+44
-1
application-dev.yml
...al/yifu-social-biz/src/main/resources/application-dev.yml
+1
-0
application-prd.yml
...al/yifu-social-biz/src/main/resources/application-prd.yml
+1
-0
application-test.yml
...l/yifu-social-biz/src/main/resources/application-test.yml
+1
-0
No files found.
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/config/SocialFriendConfig.java
View file @
c2edff36
...
...
@@ -49,6 +49,10 @@ public class SocialFriendConfig {
// url拉结果数据
@Value
(
"${socialFriend.urlGetInfo}"
)
private
String
urlGetInfo
;
// url拉结果数据
@Value
(
"${socialFriend.urlUpload}"
)
private
String
urlUpload
;
private
static
final
String
APP_KEY
=
"appKey"
;
private
static
final
String
TIMESTAMP
=
"timestamp"
;
...
...
@@ -144,6 +148,66 @@ public class SocialFriendConfig {
return
addId
;
}
/**
* @param : type 1社保增 2社保减 3医保增 4医保减
* @Description: 推送任务接口
* @Author: hgw
* @Date: 2024-12-9 16:54:31
* @return: java.lang.String
**/
public
String
uploadPng
(
RestTemplate
restTemplate
,
String
fileName
,
String
file
,
TSocialFriendBackLog
backLog
)
{
String
urlStr
=
""
;
String
appAddUrl
=
urlPre
+
urlUpload
;
String
version
=
"1.0.0"
;
String
timestamp
=
String
.
valueOf
(
new
Date
().
getTime
());
String
xReqNonce
=
"1"
;
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
// */*
headers
.
add
(
"accept"
,
MediaType
.
ALL_VALUE
);
headers
.
add
(
APP_KEY
,
appKey
);
headers
.
add
(
TIMESTAMP
,
timestamp
);
try
{
String
signature
=
SocialFriendSign
.
qianMing
(
getMapParam
(
appKey
,
appSecret
,
xReqNonce
,
version
,
timestamp
,
null
));
headers
.
add
(
"signature"
,
signature
);
}
catch
(
SignatureException
e
)
{
log
.
error
(
"税友签名失败"
,
e
);
return
urlStr
;
}
headers
.
add
(
X_REQ_NONCE
,
xReqNonce
);
headers
.
add
(
VERSION
,
version
);
JSONObject
json
=
new
JSONObject
();
// 文件名称
json
.
put
(
"wjmc"
,
fileName
);
// 文件内容
json
.
put
(
"wjnr"
,
file
);
// 业务类型 参保、停保、参保业务签名、停保业务签名、人员补缴、缴费工资变更、缴费工资业务签名
// json.put("ywlx", vo.getUnitCreditCode())
// 行政区划代码 户里的缴纳地,精确到市 "340100"
HttpEntity
<
String
>
formEntity
=
new
HttpEntity
<>(
json
.
toString
(),
headers
);
String
dataResultList
=
restTemplate
.
postForObject
(
appAddUrl
,
formEntity
,
String
.
class
);
// {"head":{"code":"00000000","description":"成功","msg":"成功","time":"2024-12-06 17:10:26","status":"Y"
// ,"body":{"requestId":"85440b327d71466abcd9c5c81d5bb172"
if
(
Common
.
isNotNull
(
dataResultList
))
{
backLog
.
setLogInfo
(
dataResultList
);
backLog
.
setCreateTime
(
LocalDateTime
.
now
());
JSONObject
dataObject
=
JSON
.
parseObject
(
dataResultList
);
String
head
=
dataObject
.
getString
(
"head"
);
if
(
Common
.
isNotNull
(
head
))
{
JSONObject
headObject
=
JSON
.
parseObject
(
head
);
String
status
=
headObject
.
getString
(
"status"
);
if
(
"Y"
.
equals
(
status
))
{
String
body
=
dataObject
.
getString
(
"body"
);
JSONObject
bodyObject
=
JSON
.
parseObject
(
body
);
urlStr
=
bodyObject
.
getString
(
"wjlj"
);
}
}
}
return
urlStr
;
}
/**
* @param json 总传参json
* @param type 1社保增 2社保减 3医保增 4医保减
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/TSocialFriendPushService.java
View file @
c2edff36
...
...
@@ -41,5 +41,5 @@ public interface TSocialFriendPushService extends IService<TSocialInfo> {
**/
R
<
String
>
pushFriend
(
List
<
String
>
dispatchIdList
);
R
<
URL
>
doExportRoster
(
String
socialId
,
String
type
,
String
unitCreditCode
);
R
<
String
>
doExportRoster
(
String
socialId
,
String
type
,
String
unitCreditCode
);
}
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/impl/TSocialFriendPushServiceImpl.java
View file @
c2edff36
...
...
@@ -143,7 +143,7 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
String
thisTime
=
DateUtil
.
getThisTime
();
List
<
TSocialFriendBackLog
>
backLogList
=
new
ArrayList
<>();
TSocialFriendBackLog
backLog
;
R
<
URL
>
urlR
;
R
<
String
>
urlR
;
for
(
SociaFriendYgsAddVo
vo
:
ygsAddlist
)
{
// 0:未到时间不动; 1:推送; 2:转人工
canPushType
=
this
.
getCanPushType
(
socialSetMap
,
vo
);
...
...
@@ -156,7 +156,7 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
// 房工接口,获取 企业职工社会保险增员花名册 url
urlR
=
doExportRoster
(
vo
.
getSocialId
(),
String
.
valueOf
(
type
),
vo
.
getUnitCreditCode
());
if
(
urlR
!=
null
&&
urlR
.
getCode
()==
200
&&
Common
.
isNotNull
(
urlR
.
getData
()))
{
vo
.
setQyzgshbxzyhmc
(
urlR
.
getData
()
.
toString
()
);
vo
.
setQyzgshbxzyhmc
(
urlR
.
getData
());
}
requestId
=
socialFriendConfig
.
pushFriendByInfo
(
restTemplate
,
vo
,
type
,
thisTime
,
backLog
);
if
(
Common
.
isEmpty
(
requestId
))
{
...
...
@@ -221,7 +221,7 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
String
thisTime
=
DateUtil
.
getThisTime
();
List
<
TSocialFriendBackLog
>
backLogList
=
new
ArrayList
<>();
TSocialFriendBackLog
backLog
;
R
<
URL
>
urlR
;
R
<
String
>
urlR
;
for
(
SociaFriendYgsAddVo
vo
:
ysdAddlist
)
{
// 0:未到时间不动; 1:推送; 2:转人工
canPushType
=
this
.
getCanPushTypeYsd
(
socialSetMap
,
vo
);
...
...
@@ -234,7 +234,7 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
// 房工接口,获取 企业职工基本医疗保险参保登记表 url
urlR
=
doExportRoster
(
vo
.
getSocialId
(),
String
.
valueOf
(
type
),
vo
.
getUnitCreditCode
());
if
(
urlR
!=
null
&&
urlR
.
getCode
()==
200
&&
Common
.
isNotNull
(
urlR
.
getData
()))
{
vo
.
setQyzgjbylbxcbdjb
(
urlR
.
getData
()
.
toString
()
);
vo
.
setQyzgjbylbxcbdjb
(
urlR
.
getData
());
}
requestId
=
socialFriendConfig
.
pushFriendByInfo
(
restTemplate
,
vo
,
type
,
thisTime
,
backLog
);
if
(
Common
.
isEmpty
(
requestId
))
{
...
...
@@ -401,7 +401,7 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
* @return
**/
@Override
public
R
<
URL
>
doExportRoster
(
String
socialId
,
String
type
,
String
unitCreditCode
)
{
public
R
<
String
>
doExportRoster
(
String
socialId
,
String
type
,
String
unitCreditCode
)
{
SocialHandleSearchVo
searchVo
=
new
SocialHandleSearchVo
();
if
(
Common
.
isEmpty
(
socialId
)
||
Common
.
isEmpty
(
type
)
||
Common
.
isEmpty
(
unitCreditCode
)){
return
R
.
failed
(
CommonConstants
.
PARAM_IS_NOT_ERROR
);
...
...
@@ -450,7 +450,7 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
* @Param
* @return
**/
public
R
<
URL
>
doExportRosterMedical
(
SocialHandleSearchVo
searchVo
,
public
R
<
String
>
doExportRosterMedical
(
SocialHandleSearchVo
searchVo
,
String
type
,
String
fileName
,
String
projectRoot
,
...
...
@@ -624,7 +624,10 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
outFile
=
new
File
(
tempPath
);
inputStreamOut
=
new
FileInputStream
(
outFile
);
// 转换成图片 完成后清理流
return
excelToImage
.
excelToImg
(
inputStreamOut
,
ossUtil
);
TSocialFriendBackLog
backLog
=
new
TSocialFriendBackLog
();
R
<
String
>
ulrR
=
excelToImage
.
excelToImg
(
inputStreamOut
,
socialFriendConfig
,
restTemplate
,
backLog
);
tSocialFriendBackLogService
.
save
(
backLog
);
return
ulrR
;
}
catch
(
Exception
e
){
return
R
.
failed
(
"税友附件生成异常:"
+
e
.
getMessage
());
}
finally
{
...
...
@@ -684,7 +687,7 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
* @Param
* @return
**/
public
R
<
URL
>
doExportRosterSocial
(
SocialHandleSearchVo
searchVo
,
public
R
<
String
>
doExportRosterSocial
(
SocialHandleSearchVo
searchVo
,
String
type
,
String
fileName
,
String
projectRoot
,
...
...
@@ -884,7 +887,10 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
outFile
=
new
File
(
tempPath
);
inputStreamOut
=
new
FileInputStream
(
outFile
);
// 转换成图片 完成后清理流
return
excelToImage
.
excelToImg
(
inputStreamOut
,
ossUtil
);
TSocialFriendBackLog
backLog
=
new
TSocialFriendBackLog
();
R
<
String
>
ulrR
=
excelToImage
.
excelToImg
(
inputStreamOut
,
socialFriendConfig
,
restTemplate
,
backLog
);
tSocialFriendBackLogService
.
save
(
backLog
);
return
ulrR
;
}
catch
(
Exception
e
){
return
R
.
failed
(
"税友附件生成异常:"
+
e
.
getMessage
());
}
finally
{
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/util/ExcelToImage.java
View file @
c2edff36
...
...
@@ -6,8 +6,10 @@ 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
com.yifu.cloud.plus.v1.yifu.social.config.SocialFriendConfig
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFriendBackLog
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
java.io.File
;
import
java.io.IOException
;
...
...
@@ -23,6 +25,46 @@ import java.net.URL;
@Component
public
class
ExcelToImage
{
public
R
<
String
>
excelToImg
(
InputStream
inputStream
,
SocialFriendConfig
socialFriendConfig
,
RestTemplate
restTemplate
,
TSocialFriendBackLog
backLog
){
if
(
null
==
inputStream
||
null
==
socialFriendConfig
){
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":带印章excel生成图片传参异常"
);
}
String
projectRoot
=
System
.
getProperty
(
CommonConstants
.
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
();
// TODO - shuiyou
String
url
=
socialFriendConfig
.
uploadPng
(
restTemplate
,
key
,
file
.
toString
(),
backLog
);
return
R
.
ok
(
url
);
}
}
catch
(
Exception
e
)
{
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
);
}
public
R
<
URL
>
excelToImg
(
InputStream
inputStream
,
OSSUtil
ossUtil
){
if
(
null
==
inputStream
||
null
==
ossUtil
){
return
R
.
failed
(
CommonConstants
.
RESULT_DATA_FAIL
+
":带印章excel生成图片传参异常"
);
...
...
@@ -82,4 +124,5 @@ public class ExcelToImage {
//调用方法将Excel保存为PCL
sheet.saveToFile("ToPCL.pcl", String.valueOf(FileFormat.PCL));*/
}
}
yifu-social/yifu-social-biz/src/main/resources/application-dev.yml
View file @
c2edff36
...
...
@@ -65,5 +65,6 @@ socialFriend:
urlPre
:
https://test-openapi.17win.com
urlPush
:
/gateway/socins/hrss/employee/v2/register
urlGetInfo
:
/gateway/socins/hrss/employee/v2/getRegisterFeedback
urlUpload
:
/gateway/file/upload
appKey
:
89357285571962202409230949030
appSecret
:
V52dkvxtFUgIvzlfNE9G8g==
\ No newline at end of file
yifu-social/yifu-social-biz/src/main/resources/application-prd.yml
View file @
c2edff36
...
...
@@ -61,5 +61,6 @@ socialFriend:
urlPre
:
https://test-openapi.17win.com
urlPush
:
/gateway/socins/hrss/employee/v2/register
urlGetInfo
:
/gateway/socins/hrss/employee/v2/getRegisterFeedback
urlUpload
:
/gateway/file/upload
appKey
:
89357285571962202409230949030
appSecret
:
V52dkvxtFUgIvzlfNE9G8g==
\ No newline at end of file
yifu-social/yifu-social-biz/src/main/resources/application-test.yml
View file @
c2edff36
...
...
@@ -60,5 +60,6 @@ socialFriend:
urlPre
:
https://test-openapi.17win.com
urlPush
:
/gateway/socins/hrss/employee/v2/register
urlGetInfo
:
/gateway/socins/hrss/employee/v2/getRegisterFeedback
urlUpload
:
/gateway/file/upload
appKey
:
89357285571962202409230949030
appSecret
:
V52dkvxtFUgIvzlfNE9G8g==
\ 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