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
62cf9946
Commit
62cf9946
authored
May 13, 2024
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MVP1.6.4-社保士兵相关代码7_手搓识别表数据
parent
475d8107
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
192 additions
and
10 deletions
+192
-10
TSocialSoldierReturnErrorVo.java
...d/plus/v1/yifu/social/vo/TSocialSoldierReturnErrorVo.java
+1
-0
TSocialSoldierServiceImpl.java
...1/yifu/social/service/impl/TSocialSoldierServiceImpl.java
+191
-10
No files found.
yifu-social/yifu-social-api/src/main/java/com/yifu/cloud/plus/v1/yifu/social/vo/TSocialSoldierReturnErrorVo.java
View file @
62cf9946
...
@@ -30,6 +30,7 @@ import java.io.Serializable;
...
@@ -30,6 +30,7 @@ import java.io.Serializable;
*/
*/
@Data
@Data
public
class
TSocialSoldierReturnErrorVo
extends
RowIndex
implements
Serializable
{
public
class
TSocialSoldierReturnErrorVo
extends
RowIndex
implements
Serializable
{
//是否处理完成 是否成功 反馈结果 企业名称 证件类型 身份证号码 姓名 国籍 个人身份 民族 参加工作日期 工资 新增原因 文化程度 户口性质 增员年月 户口所在地 用工形式 手机号码 通讯地址 就业登记时间 单位就业起始时间 合同期限类型 合同起始时间 合同终止日期 录用工种代码 合同签订类别 工作时间制度 养老参保日期 工伤参保日期 失业参保日期 户口所在地行政区划代码 居住所在地行政区划代码 当前经办行政区划代码 补缴原因 资料文件 录屏文件路径 回传信息 回传信息1 回传信息2
@ExcelProperty
(
"错误信息"
)
@ExcelProperty
(
"错误信息"
)
private
String
errorInfo
;
private
String
errorInfo
;
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/impl/TSocialSoldierServiceImpl.java
View file @
62cf9946
...
@@ -16,7 +16,9 @@
...
@@ -16,7 +16,9 @@
*/
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
social
.
service
.
impl
;
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
social
.
service
.
impl
;
import
cn.hutool.core.util.ArrayUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
...
@@ -29,6 +31,8 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
...
@@ -29,6 +31,8 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
import
com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelColumnVo
;
import
com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelSheetVo
;
import
com.yifu.cloud.plus.v1.yifu.social.config.SocialConfig
;
import
com.yifu.cloud.plus.v1.yifu.social.config.SocialConfig
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.FailReasonConfig
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.FailReasonConfig
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.TSocialInfo
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.TSocialInfo
;
...
@@ -40,6 +44,10 @@ import com.yifu.cloud.plus.v1.yifu.social.service.TSocialSoldierService;
...
@@ -40,6 +44,10 @@ import com.yifu.cloud.plus.v1.yifu.social.service.TSocialSoldierService;
import
com.yifu.cloud.plus.v1.yifu.social.vo.TSocialSoldierReturnErrorVo
;
import
com.yifu.cloud.plus.v1.yifu.social.vo.TSocialSoldierReturnErrorVo
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
lombok.extern.log4j.Log4j2
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.apache.poi.ss.usermodel.CellType
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.authority.AuthorityUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
...
@@ -49,6 +57,7 @@ import java.io.UnsupportedEncodingException;
...
@@ -49,6 +57,7 @@ import java.io.UnsupportedEncodingException;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.text.DecimalFormat
;
import
java.util.*
;
import
java.util.*
;
/**
/**
...
@@ -131,7 +140,7 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
...
@@ -131,7 +140,7 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
conn
.
setConnectTimeout
(
30
*
1000
);
conn
.
setConnectTimeout
(
30
*
1000
);
in
=
conn
.
getInputStream
();
in
=
conn
.
getInputStream
();
// 实际读取文件内容
// 实际读取文件内容
importDiy
(
in
,
idCardMap
,
errorMap
);
this
.
readXls
(
in
,
idCardMap
,
errorMap
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -150,8 +159,177 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
...
@@ -150,8 +159,177 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
return
R
.
ok
();
return
R
.
ok
();
}
}
public
R
<
List
<
TSocialSoldierReturnErrorVo
>>
readXls
(
InputStream
inputStream
,
Map
<
String
,
TSocialInfo
>
idCardMap
,
Map
<
String
,
FailReasonConfig
>
errorMap
)
{
TSocialSoldierReturnErrorVo
vo
;
List
<
TSocialSoldierReturnErrorVo
>
voList
=
new
ArrayList
<>();
HSSFWorkbook
sheets
=
null
;
try
{
sheets
=
new
HSSFWorkbook
(
inputStream
);
// sheet
HSSFSheet
sheetAt
=
sheets
.
getSheetAt
(
0
);
HSSFRow
row
;
// 每个单元格内容
String
cellValue
;
// 内容行
int
dataRow
;
HSSFCell
cell
;
// 循环每个sheet
if
(
sheetAt
!=
null
&&
Common
.
isNotNull
(
sheetAt
.
getSheetName
()))
{
// 初始化每个sheet的数据行
dataRow
=
0
;
// 错误信息 所在列
Integer
errorInfoNum
=
null
;
// 是否处理完成 所在列
Integer
isDoCompletedNum
=
null
;
// 是否成功 所在列
Integer
isSuccessNum
=
null
;
// 反馈结果 所在列
Integer
msgNum
=
null
;
// 身份证号码 所在列
Integer
idCardNum
=
null
;
// 证件号码 所在列
Integer
empIdCardNum
=
null
;
public
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
,
Map
<
String
,
TSocialInfo
>
idCardMap
// 错误信息
String
errorInfo
=
null
;
// 是否处理完成
String
isDoCompleted
=
null
;
// 是否成功
String
isSuccess
=
null
;
// 反馈结果
String
msg
=
null
;
// 身份证号码
String
idCard
=
null
;
// 证件号码
String
empIdCard
=
null
;
for
(
int
rowNum
=
0
;
rowNum
<=
sheetAt
.
getLastRowNum
();
rowNum
++)
{
row
=
sheetAt
.
getRow
(
rowNum
);
if
(
row
!=
null
)
{
// 循环当前行的内容
if
(
rowNum
==
0
)
{
for
(
int
cellNum
=
0
;
cellNum
<
row
.
getLastCellNum
();
cellNum
++)
{
// 标题行
cell
=
row
.
getCell
(
cellNum
);
cellValue
=
""
;
try
{
if
(
cell
!=
null
)
{
if
(
CellType
.
STRING
==
cell
.
getCellType
())
{
cellValue
=
row
.
getCell
(
cellNum
).
getStringCellValue
();
}
else
if
(
CellType
.
NUMERIC
==
cell
.
getCellType
())
{
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getNumericCellValue
());
if
(
cellValue
.
contains
(
"E"
))
{
cellValue
=
String
.
valueOf
(
new
DecimalFormat
(
"#"
).
format
(
row
.
getCell
(
cellNum
).
getNumericCellValue
()));
}
}
}
}
catch
(
NumberFormatException
e
)
{
cell
.
setCellType
(
CellType
.
STRING
);
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getStringCellValue
());
}
if
(
"错误信息"
.
equals
(
cellValue
))
{
errorInfoNum
=
cellNum
;
}
else
if
(
"是否处理完成"
.
equals
(
cellValue
))
{
isDoCompletedNum
=
cellNum
;
}
else
if
(
"是否成功"
.
equals
(
cellValue
))
{
isSuccessNum
=
cellNum
;
}
else
if
(
"反馈结果"
.
equals
(
cellValue
))
{
msgNum
=
cellNum
;
}
else
if
(
"身份证号码"
.
equals
(
cellValue
))
{
idCardNum
=
cellNum
;
}
else
if
(
"证件号码"
.
equals
(
cellValue
))
{
empIdCardNum
=
cellNum
;
}
}
}
else
{
if
(
Common
.
isEmpty
(
errorInfoNum
)
&&
Common
.
isEmpty
(
isDoCompletedNum
))
{
return
R
.
failed
(
"未找到对应表头!"
);
}
else
{
if
(
Common
.
isNotNull
(
errorInfoNum
))
{
errorInfo
=
getCellValue
(
row
,
errorInfoNum
);
vo
=
new
TSocialSoldierReturnErrorVo
();
vo
.
setErrorInfo
(
errorInfo
);
voList
.
add
(
vo
);
return
R
.
failed
(
"数据错误!!"
);
}
else
{
if
(
Common
.
isNotNull
(
isDoCompletedNum
)
&&
Common
.
isNotNull
(
isSuccessNum
)
&&
Common
.
isNotNull
(
msgNum
))
{
isDoCompleted
=
getCellValue
(
row
,
isDoCompletedNum
);
isSuccess
=
getCellValue
(
row
,
isSuccessNum
);
msg
=
getCellValue
(
row
,
msgNum
);
if
(
Common
.
isNotNull
(
idCardNum
))
{
idCard
=
getCellValue
(
row
,
idCardNum
);
}
else
if
(
Common
.
isNotNull
(
empIdCardNum
))
{
empIdCard
=
getCellValue
(
row
,
empIdCardNum
);
}
vo
=
new
TSocialSoldierReturnErrorVo
();
vo
.
setIsDoCompleted
(
isDoCompleted
);
vo
.
setIsSuccess
(
isSuccess
);
vo
.
setMsg
(
msg
);
vo
.
setIdCard
(
idCard
);
vo
.
setEmpIdCard
(
empIdCard
);
voList
.
add
(
vo
);
}
}
}
}
}
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
if
(
sheets
!=
null
)
{
try
{
sheets
.
close
();
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
}
}
}
finally
{
if
(
sheets
!=
null
)
{
try
{
sheets
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
if
(!
voList
.
isEmpty
())
{
importTSocialInfo
(
voList
,
idCardMap
,
errorMap
);
}
return
R
.
ok
(
voList
);
}
/**
* @Description: 获取单元格内容
* @Author: hgw
* @Date: 2024/5/13 16:34
* @return: java.lang.String
**/
private
String
getCellValue
(
HSSFRow
row
,
int
cellNum
)
{
HSSFCell
cell
=
row
.
getCell
(
cellNum
);
String
cellValue
=
""
;
try
{
if
(
cell
!=
null
)
{
if
(
CellType
.
STRING
==
cell
.
getCellType
())
{
cellValue
=
row
.
getCell
(
cellNum
).
getStringCellValue
();
}
else
if
(
CellType
.
NUMERIC
==
cell
.
getCellType
())
{
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getNumericCellValue
());
if
(
cellValue
.
contains
(
"E"
))
{
cellValue
=
String
.
valueOf
(
new
DecimalFormat
(
"#"
).
format
(
row
.
getCell
(
cellNum
).
getNumericCellValue
()));
}
}
}
}
catch
(
NumberFormatException
e
)
{
cell
.
setCellType
(
CellType
.
STRING
);
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getStringCellValue
());
}
return
cellValue
;
}
/*public R<List<ErrorMessage>> importDiy(InputStream inputStream, Map<String, TSocialInfo> idCardMap
, Map<String, FailReasonConfig> errorMap) {
, Map<String, FailReasonConfig> errorMap) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TSocialSoldierReturnErrorVo> util1 = new ExcelUtil<>(TSocialSoldierReturnErrorVo.class);
ExcelUtil<TSocialSoldierReturnErrorVo> util1 = new ExcelUtil<>(TSocialSoldierReturnErrorVo.class);
...
@@ -160,13 +338,13 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
...
@@ -160,13 +338,13 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
try {
EasyExcel.read(inputStream, TSocialSoldierReturnErrorVo.class, new ReadListener<TSocialSoldierReturnErrorVo>() {
EasyExcel.read(inputStream, TSocialSoldierReturnErrorVo.class, new ReadListener<TSocialSoldierReturnErrorVo>() {
/**
*/
/**
* 单次缓存的数据量
* 单次缓存的数据量
*/
*/
/*
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*/
/**
*临时存储
*临时存储
*/
*/
/*
private List<TSocialSoldierReturnErrorVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
private List<TSocialSoldierReturnErrorVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
@Override
...
@@ -192,9 +370,9 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
...
@@ -192,9 +370,9 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
saveData();
saveData();
}
}
/**
*/
/**
* 加上存储数据库
* 加上存储数据库
*/
*/
/*
private void saveData() {
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTSocialInfo(cachedDataList, idCardMap, errorMap);
importTSocialInfo(cachedDataList, idCardMap, errorMap);
...
@@ -206,7 +384,7 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
...
@@ -206,7 +384,7 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
}
return R.ok(errorMessageList);
return R.ok(errorMessageList);
}
}
*/
private
void
importTSocialInfo
(
List
<
TSocialSoldierReturnErrorVo
>
excelVOList
,
Map
<
String
,
TSocialInfo
>
idCardMap
private
void
importTSocialInfo
(
List
<
TSocialSoldierReturnErrorVo
>
excelVOList
,
Map
<
String
,
TSocialInfo
>
idCardMap
,
Map
<
String
,
FailReasonConfig
>
errorMap
)
{
,
Map
<
String
,
FailReasonConfig
>
errorMap
)
{
...
@@ -337,11 +515,14 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
...
@@ -337,11 +515,14 @@ public class TSocialSoldierServiceImpl extends ServiceImpl<TSocialSoldierMapper,
String
handleRemark
=
"社保士兵自动办理成功!"
;
String
handleRemark
=
"社保士兵自动办理成功!"
;
String
remark
=
"社保士兵自动办理成功!!"
;
String
remark
=
"社保士兵自动办理成功!!"
;
String
socialType
=
"1,2,3"
;
String
socialType
=
"1,2,3"
;
Set
<
String
>
dbAuthsSet
=
new
HashSet
<>();
Collection
<?
extends
GrantedAuthority
>
authorities
=
AuthorityUtils
.
createAuthorityList
(
dbAuthsSet
.
toArray
(
new
String
[
0
]));
YifuUser
user
=
new
YifuUser
(
"1"
,
1L
,
"社保士兵部门"
,
"社保士兵"
,
YifuUser
user
=
new
YifuUser
(
"1"
,
1L
,
"社保士兵部门"
,
"社保士兵"
,
"社保士兵"
,
"0"
,
SecurityConstants
.
BCRYPT
+
"123456"
,
"社保士兵"
,
"0"
,
SecurityConstants
.
BCRYPT
+
"123456"
,
"12345678911"
,
true
,
true
,
true
,
"12345678911"
,
true
,
true
,
true
,
true
,
true
,
"1"
,
null
,
"1"
,
"1"
,
authorities
,
"1"
,
null
,
null
,
null
,
null
,
null
);
null
);
if
(!
ygsList
.
isEmpty
())
{
if
(!
ygsList
.
isEmpty
())
{
...
...
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