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
81e29bde
Commit
81e29bde
authored
Jun 27, 2022
by
huyuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
huyc 项目档案代码提交
parent
4560adb8
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
337 additions
and
141 deletions
+337
-141
EmployeeProjectExportVO.java
...oud/plus/v1/yifu/archives/vo/EmployeeProjectExportVO.java
+16
-3
FileUploadController.java
...lus/v1/yifu/archives/controller/FileUploadController.java
+6
-77
TElecEmployeeInfoController.java
...yifu/archives/controller/TElecEmployeeInfoController.java
+2
-13
TEmployeeProjectController.java
.../yifu/archives/controller/TEmployeeProjectController.java
+2
-2
FileUploadService.java
...loud/plus/v1/yifu/archives/service/FileUploadService.java
+18
-0
TElecEmployeeInfoService.java
...us/v1/yifu/archives/service/TElecEmployeeInfoService.java
+10
-0
FileUploadServiceImpl.java
.../v1/yifu/archives/service/impl/FileUploadServiceImpl.java
+105
-0
TElecEmployeeInfoServiceImpl.java
...u/archives/service/impl/TElecEmployeeInfoServiceImpl.java
+169
-41
TEmployeeProjectServiceImpl.java
...fu/archives/service/impl/TEmployeeProjectServiceImpl.java
+1
-1
TEmployeeProjectMapper.xml
...-biz/src/main/resources/mapper/TEmployeeProjectMapper.xml
+8
-4
No files found.
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/vo/EmployeeProjectExportVO.java
View file @
81e29bde
...
@@ -18,6 +18,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo;
...
@@ -18,6 +18,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.write.style.ColumnWidth
;
import
com.alibaba.excel.annotation.write.style.ColumnWidth
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.Data
;
import
javax.validation.constraints.Past
;
import
javax.validation.constraints.Past
;
...
@@ -309,10 +310,22 @@ public class EmployeeProjectExportVO{
...
@@ -309,10 +310,22 @@ public class EmployeeProjectExportVO{
private
Integer
contractStatus
;
private
Integer
contractStatus
;
/**
/**
* 业务类型
* 业务类型
一级分类
*/
*/
@ExcelProperty
(
value
=
"业务类型"
)
@ExcelProperty
(
value
=
"业务类型一级分类"
)
private
String
businessType
;
private
String
businessPrimaryType
;
/**
* 业务类型二级分类
*/
@ExcelProperty
(
value
=
"业务类型二级分类"
)
private
String
businessSecondType
;
/**
* 业务类型三级分类
*/
@ExcelProperty
(
value
=
"业务类型三级分类"
)
private
String
businessThirdType
;
/**
/**
* 商险状态(字典)
* 商险状态(字典)
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/FileUploadController.java
View file @
81e29bde
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller;
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TAttaInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TAttaInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.FileUploadService
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TAttaInfoService
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TAttaInfoService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil
;
...
@@ -17,7 +18,6 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -17,7 +18,6 @@ import org.springframework.web.multipart.MultipartFile;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -36,6 +36,9 @@ public class FileUploadController {
...
@@ -36,6 +36,9 @@ public class FileUploadController {
@Autowired
@Autowired
private
TAttaInfoService
tAttaInfoService
;
private
TAttaInfoService
tAttaInfoService
;
@Autowired
private
FileUploadService
fileUploadService
;
/**
/**
* @Author fxj
* @Author fxj
* @Description
* @Description
...
@@ -52,60 +55,12 @@ public class FileUploadController {
...
@@ -52,60 +55,12 @@ public class FileUploadController {
/*@ApiImplicitParams({
/*@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "Form文件上传", required = true, dataType = "__file", paramType = "form"),
@ApiImplicitParam(name = "file", value = "Form文件上传", required = true, dataType = "__file", paramType = "form"),
@ApiImplicitParam(name = "filePath", value = "文件上传路径", required = false, dataType = "String", paramType = "form"),
@ApiImplicitParam(name = "filePath", value = "文件上传路径", required = false, dataType = "String", paramType = "form"),
@ApiImplicitParam(name = "type", value = "关系类型(0客户附件1联系人附件2跟进记录附件3合同附件4合同归档附件5报价单6招标信息7业务评估)", required = true, dataType = "int", paramType = "form"),
@ApiImplicitParam(name = "type", value = "关系类型(0客户附件1联系人附件2跟进记录附件3合同附件4合同归档附件5报价单6招标信息7业务评估
8电子档案
)", required = true, dataType = "int", paramType = "form"),
@ApiImplicitParam(name = "domain", value = "实体id(传入就插入对应关系,用于编辑)", required = false, paramType = "form")
@ApiImplicitParam(name = "domain", value = "实体id(传入就插入对应关系,用于编辑)", required = false, paramType = "form")
})*/
})*/
@PostMapping
(
value
=
"/ossUploadFile"
)
@PostMapping
(
value
=
"/ossUploadFile"
)
public
R
<
FileVo
>
uploadImg
(
@RequestBody
MultipartFile
file
,
String
filePath
,
Integer
type
,
String
domain
)
throws
IOException
{
public
R
<
FileVo
>
uploadImg
(
@RequestBody
MultipartFile
file
,
String
filePath
,
Integer
type
,
String
domain
)
throws
IOException
{
if
(
null
==
file
)
{
return
fileUploadService
.
uploadImg
(
file
,
filePath
,
type
,
domain
);
return
R
.
failed
(
"文件删除异常,请重新上传!"
);
}
String
fileName
=
file
.
getOriginalFilename
();
if
(
Common
.
isEmpty
(
fileName
))
{
return
R
.
failed
(
"文件名不能为空!"
);
}
if
(
fileName
.
length
()
>
100
)
{
return
R
.
failed
(
"文件名不能超过100个字符!"
);
}
//filePath不传默认存储空间的根目录
//jpg,jpeg,png,bmp
String
key
=
""
;
if
(
Common
.
isNotNull
(
filePath
))
{
key
=
filePath
+
"/"
+
System
.
currentTimeMillis
()
+
fileName
;
}
else
{
key
=
System
.
currentTimeMillis
()
+
fileName
;
}
if
(!
Common
.
checkFile
(
key
))
{
return
R
.
failed
(
"非法上传类型!"
);
}
boolean
flag
=
ossUtil
.
uploadFileByStream
(
file
.
getInputStream
(),
key
,
null
);
FileVo
fileVo
;
TAttaInfo
attaInfo
;
URL
url
;
if
(
flag
)
{
log
.
info
(
"文件:"
+
fileName
+
"上传至存储空间"
+
ossUtil
.
getBucketName
()
+
"成功!"
);
attaInfo
=
initUnitAttaForInsert
(
fileName
,
key
,
file
.
getSize
());
attaInfo
.
setRelationType
(
String
.
valueOf
(
type
));
try
{
attaInfo
.
setDomainId
(
domain
);
attaInfo
=
tAttaInfoService
.
add
(
attaInfo
);
}
catch
(
Exception
e
)
{
log
.
error
(
"OSS文件上传接口异常:"
+
e
.
getMessage
());
ossUtil
.
deleteObject
(
null
,
key
);
return
R
.
failed
(
"fail:"
+
e
.
getMessage
());
}
//有实体id则插入关系,用于编辑
if
(
Common
.
isNotNull
(
domain
))
{
url
=
ossUtil
.
getObjectUrl
(
null
,
attaInfo
.
getAttaSrc
());
fileVo
=
new
FileVo
(
attaInfo
.
getId
(),
attaInfo
.
getAttaName
(),
url
.
toString
());
return
R
.
ok
(
fileVo
,
"success"
);
}
url
=
ossUtil
.
getObjectUrl
(
null
,
attaInfo
.
getAttaSrc
());
fileVo
=
new
FileVo
(
attaInfo
.
getId
(),
attaInfo
.
getAttaName
(),
url
.
toString
());
return
R
.
ok
(
fileVo
,
"success"
);
}
else
{
return
R
.
failed
(
"fail:上传失败"
);
}
}
}
...
@@ -137,32 +92,6 @@ public class FileUploadController {
...
@@ -137,32 +92,6 @@ public class FileUploadController {
return
R
.
ok
(
null
,
"删除失败!"
);
return
R
.
ok
(
null
,
"删除失败!"
);
}
}
/**
* 对象初始化
* @param fileName
* @param key
* @param fileSize
* @return
*/
private
TAttaInfo
initUnitAttaForInsert
(
String
fileName
,
String
key
,
long
fileSize
)
{
TAttaInfo
unitAtta
=
new
TAttaInfo
();
char
slash
=
'/'
;
char
point
=
'.'
;
if
(
fileName
.
lastIndexOf
(
slash
)
>=
0
)
{
unitAtta
.
setAttaName
(
fileName
.
substring
(
fileName
.
lastIndexOf
(
slash
)));
}
else
{
unitAtta
.
setAttaName
(
fileName
);
}
unitAtta
.
setAttaSize
(
fileSize
);
unitAtta
.
setAttaSrc
(
key
);
if
(
key
.
lastIndexOf
(
point
)
>=
0
)
{
unitAtta
.
setAttaType
(
key
.
substring
(
key
.
lastIndexOf
(
point
)));
}
unitAtta
.
setCreateTime
(
LocalDateTime
.
now
());
return
unitAtta
;
}
/**
/**
* 获取附件下载地址
* 获取附件下载地址
*
*
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TElecEmployeeInfoController.java
View file @
81e29bde
...
@@ -17,13 +17,9 @@
...
@@ -17,13 +17,9 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
controller
;
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
controller
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TElecEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TElecEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TElecEmployeeInfoService
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TElecEmployeeInfoService
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
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.log.annotation.SysLog
;
import
com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
...
@@ -50,8 +46,6 @@ public class TElecEmployeeInfoController {
...
@@ -50,8 +46,6 @@ public class TElecEmployeeInfoController {
private
final
TElecEmployeeInfoService
tElecEmployeeInfoService
;
private
final
TElecEmployeeInfoService
tElecEmployeeInfoService
;
private
final
TEmployeeInfoService
tEmployeeInfoService
;
/**
/**
* 分页查询
* 分页查询
* @param page 分页对象
* @param page 分页对象
...
@@ -126,12 +120,7 @@ public class TElecEmployeeInfoController {
...
@@ -126,12 +120,7 @@ public class TElecEmployeeInfoController {
@SysLog
(
"通过身份证号查询人员档案"
)
@SysLog
(
"通过身份证号查询人员档案"
)
@PostMapping
(
"/getEmpInfo"
)
@PostMapping
(
"/getEmpInfo"
)
public
R
getEmpInfoByCard
(
@RequestParam
String
idCard
)
{
public
R
getEmpInfoByCard
(
@RequestParam
String
idCard
)
{
TEmployeeInfo
tEmployeeInfo
=
tEmployeeInfoService
.
getOne
((
Wrappers
.<
TEmployeeInfo
>
query
().
lambda
()
return
R
.
ok
(
tElecEmployeeInfoService
.
getEmpInfoByCard
(
idCard
));
.
eq
(
TEmployeeInfo:
:
getEmpIdcard
,
idCard
)));
if
(
Common
.
isNotNull
(
tEmployeeInfo
))
{
return
R
.
ok
(
tEmployeeInfo
);
}
return
R
.
failed
(
"未找到身份证号对应的档案信息"
);
}
}
/**
/**
...
@@ -142,7 +131,7 @@ public class TElecEmployeeInfoController {
...
@@ -142,7 +131,7 @@ public class TElecEmployeeInfoController {
@PostMapping
(
"/importZip"
)
@PostMapping
(
"/importZip"
)
@Operation
(
summary
=
"批量导入电子档案"
,
description
=
"批量导入电子档案"
)
@Operation
(
summary
=
"批量导入电子档案"
,
description
=
"批量导入电子档案"
)
@SysLog
(
"批量导入电子档案"
)
@SysLog
(
"批量导入电子档案"
)
public
R
<
Boolean
>
importZip
(
@Request
Param
(
"file"
)
MultipartFile
file
)
{
public
R
<
Boolean
>
importZip
(
@Request
Body
MultipartFile
file
)
{
return
this
.
tElecEmployeeInfoService
.
importZip
(
file
);
return
this
.
tElecEmployeeInfoService
.
importZip
(
file
);
}
}
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmployeeProjectController.java
View file @
81e29bde
...
@@ -230,8 +230,8 @@ public class TEmployeeProjectController {
...
@@ -230,8 +230,8 @@ public class TEmployeeProjectController {
* @Date 2022-06-21
* @Date 2022-06-21
**/
**/
@PostMapping
(
"/export"
)
@PostMapping
(
"/export"
)
public
void
export
(
HttpServletResponse
response
,
EmployeeProjectExportVO
projectDTO
,
@RequestParam
(
name
=
"idstr"
,
required
=
false
)
String
idstr
,
public
void
export
(
HttpServletResponse
response
,
@RequestParam
(
name
=
"idstr"
,
required
=
false
)
String
idstr
,
@RequestBody
List
<
String
>
exportFields
)
{
@RequestBody
List
<
String
>
exportFields
,
EmployeeProjectExportVO
projectDTO
)
{
tEmployeeProjectService
.
listExportProject
(
response
,
projectDTO
,
idstr
,
exportFields
);
tEmployeeProjectService
.
listExportProject
(
response
,
projectDTO
,
idstr
,
exportFields
);
}
}
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/FileUploadService.java
0 → 100644
View file @
81e29bde
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.FileVo
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
/**
* 文件上传
*
* @author pwang
* @date 2022-07-27 16:16:07
*/
public
interface
FileUploadService
{
R
<
FileVo
>
uploadImg
(
MultipartFile
file
,
String
filePath
,
Integer
type
,
String
domain
)
throws
IOException
;
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/TElecEmployeeInfoService.java
View file @
81e29bde
...
@@ -42,4 +42,14 @@ public interface TElecEmployeeInfoService extends IService<TElecEmployeeInfo> {
...
@@ -42,4 +42,14 @@ public interface TElecEmployeeInfoService extends IService<TElecEmployeeInfo> {
* @date: 2022/6/24
* @date: 2022/6/24
*/
*/
R
<
Boolean
>
importZip
(
MultipartFile
file
);
R
<
Boolean
>
importZip
(
MultipartFile
file
);
/**
* @description: 通过身份证号查询人员档案
* @param idCard 身份证号
* @return: R
* @author: huyc
* @date: 2022/6/27
*/
R
getEmpInfoByCard
(
String
idCard
);
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/FileUploadServiceImpl.java
0 → 100644
View file @
81e29bde
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
.
impl
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TAttaInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.FileUploadService
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TAttaInfoService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.FileVo
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.time.LocalDateTime
;
@Service
@RequiredArgsConstructor
@Slf4j
public
class
FileUploadServiceImpl
implements
FileUploadService
{
private
final
OSSUtil
ossUtil
;
private
final
TAttaInfoService
tAttaInfoService
;
@Override
public
R
<
FileVo
>
uploadImg
(
MultipartFile
file
,
String
filePath
,
Integer
type
,
String
domain
)
throws
IOException
{
if
(
null
==
file
)
{
return
R
.
failed
(
"文件删除异常,请重新上传!"
);
}
String
fileName
=
file
.
getOriginalFilename
();
if
(
Common
.
isEmpty
(
fileName
))
{
return
R
.
failed
(
"文件名不能为空!"
);
}
if
(
fileName
.
length
()
>
100
)
{
return
R
.
failed
(
"文件名不能超过100个字符!"
);
}
//filePath不传默认存储空间的根目录
//jpg,jpeg,png,bmp
String
key
=
""
;
if
(
Common
.
isNotNull
(
filePath
))
{
key
=
filePath
+
"/"
+
System
.
currentTimeMillis
()
+
fileName
;
}
else
{
key
=
System
.
currentTimeMillis
()
+
fileName
;
}
if
(!
Common
.
checkFile
(
key
))
{
return
R
.
failed
(
"非法上传类型!"
);
}
boolean
flag
=
ossUtil
.
uploadFileByStream
(
file
.
getInputStream
(),
key
,
null
);
FileVo
fileVo
;
TAttaInfo
attaInfo
;
URL
url
;
if
(
flag
)
{
log
.
info
(
"文件:"
+
fileName
+
"上传至存储空间"
+
ossUtil
.
getBucketName
()
+
"成功!"
);
attaInfo
=
initUnitAttaForInsert
(
fileName
,
key
,
file
.
getSize
());
attaInfo
.
setRelationType
(
String
.
valueOf
(
type
));
try
{
attaInfo
.
setDomainId
(
domain
);
attaInfo
=
tAttaInfoService
.
add
(
attaInfo
);
}
catch
(
Exception
e
)
{
log
.
error
(
"OSS文件上传接口异常:"
+
e
.
getMessage
());
ossUtil
.
deleteObject
(
null
,
key
);
return
R
.
failed
(
"fail:"
+
e
.
getMessage
());
}
//有实体id则插入关系,用于编辑
if
(
Common
.
isNotNull
(
domain
))
{
url
=
ossUtil
.
getObjectUrl
(
null
,
attaInfo
.
getAttaSrc
());
fileVo
=
new
FileVo
(
attaInfo
.
getId
(),
attaInfo
.
getAttaName
(),
url
.
toString
());
return
R
.
ok
(
fileVo
,
"success"
);
}
url
=
ossUtil
.
getObjectUrl
(
null
,
attaInfo
.
getAttaSrc
());
fileVo
=
new
FileVo
(
attaInfo
.
getId
(),
attaInfo
.
getAttaName
(),
url
.
toString
());
return
R
.
ok
(
fileVo
,
"success"
);
}
else
{
return
R
.
failed
(
"fail:上传失败"
);
}
}
/**
* 对象初始化
* @param fileName
* @param key
* @param fileSize
* @return
*/
private
TAttaInfo
initUnitAttaForInsert
(
String
fileName
,
String
key
,
long
fileSize
)
{
TAttaInfo
unitAtta
=
new
TAttaInfo
();
char
slash
=
'/'
;
char
point
=
'.'
;
if
(
fileName
.
lastIndexOf
(
slash
)
>=
0
)
{
unitAtta
.
setAttaName
(
fileName
.
substring
(
fileName
.
lastIndexOf
(
slash
)));
}
else
{
unitAtta
.
setAttaName
(
fileName
);
}
unitAtta
.
setAttaSize
(
fileSize
);
unitAtta
.
setAttaSrc
(
key
);
if
(
key
.
lastIndexOf
(
point
)
>=
0
)
{
unitAtta
.
setAttaType
(
key
.
substring
(
key
.
lastIndexOf
(
point
)));
}
unitAtta
.
setCreateTime
(
LocalDateTime
.
now
());
return
unitAtta
;
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TElecEmployeeInfoServiceImpl.java
View file @
81e29bde
...
@@ -16,30 +16,38 @@
...
@@ -16,30 +16,38 @@
*/
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
.
impl
;
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
service
.
impl
;
import
cn.hutool.core.io.FileTypeUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.CharsetUtil
;
import
cn.hutool.core.util.CharsetUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TElecEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TElecEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.mapper.TElecEmployeeInfoMapper
;
import
com.yifu.cloud.plus.v1.yifu.archives.mapper.TElecEmployeeInfoMapper
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.FileUploadService
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TElecEmployeeInfoService
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TElecEmployeeInfoService
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
org.apache.commons.compress.archivers.zip.ZipArchiveEntry
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.FileVo
;
import
org.apache.commons.compress.archivers.zip.ZipFile
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprUpmsProperties
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil
;
import
lombok.RequiredArgsConstructor
;
import
org.apache.commons.fileupload.FileItem
;
import
org.apache.commons.fileupload.FileItemFactory
;
import
org.apache.commons.fileupload.disk.DiskFileItemFactory
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.commons.CommonsMultipartFile
;
import
java.io.*
;
import
java.util.*
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.UUID
;
/**
/**
* 电子档案信息表
* 电子档案信息表
...
@@ -48,8 +56,16 @@ import java.util.UUID;
...
@@ -48,8 +56,16 @@ import java.util.UUID;
* @date 2022-06-18 09:39:46
* @date 2022-06-18 09:39:46
*/
*/
@Service
@Service
@RequiredArgsConstructor
@EnableConfigurationProperties
(
DaprUpmsProperties
.
class
)
public
class
TElecEmployeeInfoServiceImpl
extends
ServiceImpl
<
TElecEmployeeInfoMapper
,
TElecEmployeeInfo
>
implements
TElecEmployeeInfoService
{
public
class
TElecEmployeeInfoServiceImpl
extends
ServiceImpl
<
TElecEmployeeInfoMapper
,
TElecEmployeeInfo
>
implements
TElecEmployeeInfoService
{
private
final
TEmployeeInfoService
tEmployeeInfoService
;
private
final
FileUploadService
fileUploadService
;
private
final
DaprUpmsProperties
daprUpmsProperties
;
@Override
@Override
public
boolean
save
(
TElecEmployeeInfo
entity
)
{
public
boolean
save
(
TElecEmployeeInfo
entity
)
{
return
super
.
save
(
entity
);
return
super
.
save
(
entity
);
...
@@ -62,53 +78,165 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM
...
@@ -62,53 +78,165 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM
/**
/**
* @description: 解析zip文件包中的多个附件,并生成结算记录
* @description: 解析zip文件包中的多个附件,并生成结算记录
* @param
f
ile zip文件包
* @param
zipF
ile zip文件包
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.Boolean>
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.Boolean>
* @author:
wangweiguo
* @author:
huyc
* @date: 202
1/8/19
* @date: 202
2/6/27
*/
*/
@Override
@Override
public
R
<
Boolean
>
importZip
(
MultipartFile
file
)
{
public
R
<
Boolean
>
importZip
(
MultipartFile
zipFile
)
{
//C:\Users\登录用户~1\AppData\Local\Temp\
String
pathName
=
System
.
getProperty
(
"java.io.tmpdir"
)
+
"shpFileCache/"
;
String
dec
=
System
.
getProperty
(
"java.io.tmpdir"
)
+
"shpFileCache/"
;
File
unzip
=
null
;
//获取文件名(包括后缀)
File
etractFile
=
null
;
String
pname
=
zipFile
.
getOriginalFilename
();
pathName
=
pathName
+
pname
;
try
{
try
{
String
fileType
=
FileTypeUtil
.
getType
(
file
.
getInputStream
());
File
file
=
new
File
(
pathName
);
// if (!StringUtils.equalsIgnoreCase(fileType, CommonConstants.ZIP_TYPE)) {
zipFile
.
transferTo
(
file
);
// return R.failed(ErrorCodes.IMPORT_FILE_TYPE_ERROR);
// 获取解压出来的文件名 不带后缀
// }
unZip
(
file
,
dec
);
}
catch
(
Exception
e
)
{
List
list
=
new
ArrayList
();
e
.
printStackTrace
();
}
return
R
.
ok
();
}
etractFile
=
new
File
(
UUID
.
randomUUID
().
toString
());
@Override
unzip
=
ZipUtil
.
unzip
(
file
.
getInputStream
(),
etractFile
,
CharsetUtil
.
CHARSET_GBK
);
public
R
getEmpInfoByCard
(
String
idCard
)
{
TEmployeeInfo
tEmployeeInfo
=
tEmployeeInfoService
.
getOne
((
Wrappers
.<
TEmployeeInfo
>
query
().
lambda
()
.
eq
(
TEmployeeInfo:
:
getEmpIdcard
,
idCard
)));
if
(
Common
.
isNotNull
(
tEmployeeInfo
))
{
return
R
.
ok
(
tEmployeeInfo
);
}
return
R
.
failed
(
"未找到身份证号对应的档案信息"
);
}
ZipFile
zipFile
=
new
ZipFile
(
unzip
);
/**
* zip解压
* @param srcFile zip源文件
* @throws RuntimeException 解压失败会抛出运行时异常
*/
private
R
unZip
(
File
srcFile
,
String
destDirPath
)
throws
RuntimeException
{
for
(
Enumeration
<?
extends
ZipArchiveEntry
>
e
=
zipFile
.
getEntries
();
e
.
hasMoreElements
();)
{
// 调用字典服务,渲染字典值
ZipArchiveEntry
entry
=
e
.
nextElement
();
R
<
Map
<
String
,
Map
<
String
,
String
>>>
dictR
=
HttpDaprUtil
.
invokeMethodPost
(
daprUpmsProperties
.
getAppUrl
(),
daprUpmsProperties
.
getAppId
()
,
"/dict/inner/getDictToLable"
,
null
,
Map
.
class
,
SecurityConstants
.
FROM_IN
);
Map
<
String
,
Map
<
String
,
String
>>
dictMap
;
// 电子档案类型
Map
<
String
,
String
>
elecTypeMap
;
if
(
dictR
==
null
)
{
return
R
.
failed
(
"获取字典失败!"
);
}
else
{
dictMap
=
dictR
.
getData
();
elecTypeMap
=
dictMap
.
get
(
"elec_archives_type"
);
}
//记录解压出来的所有文件名
List
<
String
>
filesName
=
new
ArrayList
<>();
// 判断源文件是否存在
if
(!
srcFile
.
exists
())
{
throw
new
RuntimeException
(
srcFile
.
getPath
()
+
"所指文件不存在"
);
}
// 开始解压
ZipFile
zipFile
=
null
;
try
{
zipFile
=
new
ZipFile
(
srcFile
,
CharsetUtil
.
CHARSET_GBK
);
Enumeration
<?>
entries
=
zipFile
.
entries
();
if
(!
entry
.
isDirectory
()){
while
(
entries
.
hasMoreElements
())
{
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
zipFile
.
getInputStream
(
entry
)));
ZipEntry
entry
=
(
ZipEntry
)
entries
.
nextElement
();
//添加进filesName
String
empInfo
=
entry
.
getName
();
// 如果是文件夹,就创建个文件夹
if
(
entry
.
isDirectory
())
{
String
dirPath
=
destDirPath
+
"/"
+
entry
.
getName
();
File
dir
=
new
File
(
dirPath
);
dir
.
mkdirs
();
}
else
{
// 如果是文件,就先创建一个文件,然后用io流把内容copy过去
File
targetFile
=
new
File
(
destDirPath
+
"/"
+
entry
.
getName
());
String
line
=
""
;
// 保证这个文件的父文件夹必须要存在
if
(!
targetFile
.
getParentFile
().
exists
())
{
targetFile
.
getParentFile
().
mkdirs
();
}
targetFile
.
createNewFile
();
// 将压缩文件内容写入到这个文件中
InputStream
is
=
zipFile
.
getInputStream
(
entry
);
FileOutputStream
fos
=
new
FileOutputStream
(
targetFile
);
int
len
;
byte
[]
buf
=
new
byte
[
1024
];
while
((
len
=
is
.
read
(
buf
))
!=
-
1
)
{
fos
.
write
(
buf
,
0
,
len
);
}
while
((
line
=
br
.
readLine
())
!=
null
){
R
<
FileVo
>
fileVo
=
fileUploadService
.
uploadImg
(
fileCovertMultipartFile
(
targetFile
),
""
,
CommonConstants
.
EIGHT_INT
,
""
);
if
(
line
.
length
()
>
0
){
list
.
add
(
line
);
if
(
empInfo
.
length
()
>
empInfo
.
lastIndexOf
(
"/"
)
+
1
)
{
String
idCard
=
empInfo
.
substring
(
0
,
empInfo
.
indexOf
(
"/"
));
String
dataType
=
empInfo
.
substring
(
empInfo
.
indexOf
(
"/"
)
+
1
,
empInfo
.
lastIndexOf
(
"/"
));
String
empName
=
""
;
TEmployeeInfo
tEmployeeInfo
=
tEmployeeInfoService
.
getOne
((
Wrappers
.<
TEmployeeInfo
>
query
().
lambda
()
.
eq
(
TEmployeeInfo:
:
getEmpIdcard
,
idCard
)));
if
(
Common
.
isNotNull
(
tEmployeeInfo
))
{
empName
=
tEmployeeInfo
.
getEmpName
();
}
String
attachInfo
=
empInfo
.
substring
(
empInfo
.
lastIndexOf
(
"/"
)+
1
,
empInfo
.
length
());
TElecEmployeeInfo
tElecEmployeeInfo
=
new
TElecEmployeeInfo
();
tElecEmployeeInfo
.
setEmpIdcard
(
idCard
);
tElecEmployeeInfo
.
setEmpName
(
empName
);
tElecEmployeeInfo
.
setAttaInfo
(
attachInfo
);
if
(
Common
.
isNotNull
(
elecTypeMap
))
{
tElecEmployeeInfo
.
setDataType
(
elecTypeMap
.
get
(
dataType
));
}
}
tElecEmployeeInfo
.
setFileId
(
fileVo
.
getData
().
getUid
());
this
.
save
(
tElecEmployeeInfo
);
}
}
br
.
close
();
// 关流顺序,先打开的后关闭
fos
.
close
();
is
.
close
();
}
}
}
}
}
catch
(
IO
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
throw
new
RuntimeException
(
"unzip error from ZipUtils"
,
e
);
}
finally
{
}
finally
{
if
(
etractFile
!=
null
)
{
if
(
zipFile
!=
null
)
{
FileUtil
.
del
(
etractFile
);
try
{
zipFile
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
return
R
.
ok
();
return
R
.
ok
();
}
}
/**
* File转MultipartFile
* @description: File转MultipartFile
* @param file 需要转换的文件
* @return: org.springframework.web.multipart.MultipartFile
* @author: huyc
* @date: 2022/6/27
*/
private
MultipartFile
fileCovertMultipartFile
(
File
file
)
{
FileItemFactory
factory
=
new
DiskFileItemFactory
(
16
,
null
);
FileItem
item
=
factory
.
createItem
(
file
.
getName
(),
"text/plain"
,
true
,
file
.
getName
());
int
bytesRead
=
0
;
byte
[]
buffer
=
new
byte
[
8192
];
try
{
FileInputStream
fis
=
new
FileInputStream
(
file
);
OutputStream
os
=
item
.
getOutputStream
();
while
((
bytesRead
=
fis
.
read
(
buffer
,
0
,
8192
))
!=
-
1
)
{
os
.
write
(
buffer
,
0
,
bytesRead
);
}
os
.
close
();
fis
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
MultipartFile
multipartFile
=
new
CommonsMultipartFile
(
item
);
return
multipartFile
;
}
}
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmployeeProjectServiceImpl.java
View file @
81e29bde
...
@@ -587,7 +587,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
...
@@ -587,7 +587,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename*=utf-8'zh_cn'"
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename*=utf-8'zh_cn'"
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
EasyExcel
.
write
(
fileName
,
EmployeeProjectExportVO
.
class
).
includeColumnFiledNames
(
includeColumnFiledNames
).
sheet
(
"项目档案"
)
EasyExcel
.
write
(
out
,
EmployeeProjectExportVO
.
class
).
includeColumnFiledNames
(
includeColumnFiledNames
).
sheet
(
"项目档案"
)
.
doWrite
(
list
);
.
doWrite
(
list
);
out
.
flush
();
out
.
flush
();
}
}
...
...
yifu-archives/yifu-archives-biz/src/main/resources/mapper/TEmployeeProjectMapper.xml
View file @
81e29bde
...
@@ -88,7 +88,9 @@
...
@@ -88,7 +88,9 @@
<result
property=
"unitNo"
column=
"UNIT_NO"
/>
<result
property=
"unitNo"
column=
"UNIT_NO"
/>
<result
property=
"deptName"
column=
"DEPT_NAME"
/>
<result
property=
"deptName"
column=
"DEPT_NAME"
/>
<result
property=
"deptNo"
column=
"DEPT_NO"
/>
<result
property=
"deptNo"
column=
"DEPT_NO"
/>
<result
property=
"businessType"
column=
"BUSINESS_TYPE"
/>
<result
property=
"businessPrimaryType"
column=
"BUSINESS_PRIMARY_TYPE"
/>
<result
property=
"businessSecondType"
column=
"BUSINESS_SECOND_TYPE"
/>
<result
property=
"businessThirdType"
column=
"BUSINESS_THIRD_TYPE"
/>
<result
property=
"contractType"
column=
"CONTRACT_TYPE"
/>
<result
property=
"contractType"
column=
"CONTRACT_TYPE"
/>
<result
property=
"workingHours"
column=
"WORKING_HOURS"
/>
<result
property=
"workingHours"
column=
"WORKING_HOURS"
/>
<result
property=
"post"
column=
"POST"
/>
<result
property=
"post"
column=
"POST"
/>
...
@@ -175,7 +177,9 @@
...
@@ -175,7 +177,9 @@
a.UNIT_NO,
a.UNIT_NO,
a.DEPT_NAME,
a.DEPT_NAME,
a.DEPT_NO,
a.DEPT_NO,
concat(a.BUSINESS_PRIMARY_TYPE,'/',BUSINESS_SECOND_TYPE,'/',a.BUSINESS_THIRD_TYPE) AS BUSINESS_TYPE,
a.BUSINESS_PRIMARY_TYPE,
a.BUSINESS_SECOND_TYPE,
a.BUSINESS_THIRD_TYPE,
a.CONTRACT_TYPE,
a.CONTRACT_TYPE,
a.WORKING_HOURS,
a.WORKING_HOURS,
a.POST,
a.POST,
...
@@ -462,9 +466,9 @@
...
@@ -462,9 +466,9 @@
<if
test=
"tEmployeeProject.fileTown != null"
>
<if
test=
"tEmployeeProject.fileTown != null"
>
AND b.FILE_TOWN = #{tEmployeeProject.fileTown}
AND b.FILE_TOWN = #{tEmployeeProject.fileTown}
</if>
</if>
<if
test=
"tEmployee
Info
.idList != null"
>
<if
test=
"tEmployee
Project
.idList != null"
>
AND a.id in
AND a.id in
<foreach
item=
"idStr"
index=
"index"
collection=
"tEmployee
Info
.idList"
open=
"("
separator=
","
close=
")"
>
<foreach
item=
"idStr"
index=
"index"
collection=
"tEmployee
Project
.idList"
open=
"("
separator=
","
close=
")"
>
#{idStr}
#{idStr}
</foreach>
</foreach>
</if>
</if>
...
...
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