Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
long-tern-care-service
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
hubin
long-tern-care-service
Commits
78717895
Commit
78717895
authored
Aug 28, 2023
by
zhangwanglin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补卡列表附件下载
parent
c5a0d709
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
175 additions
and
3 deletions
+175
-3
AuditingRoleConfig.java
...a/com/hungraim/ltc/account/config/AuditingRoleConfig.java
+16
-0
AccountController.java
...om/hungraim/ltc/account/controller/AccountController.java
+2
-0
ChSrvTaskDetailMapper.java
...a/com/hungraim/ltc/account/dao/ChSrvTaskDetailMapper.java
+4
-0
AccountServiceImpl.java
...hungraim/ltc/account/service/impl/AccountServiceImpl.java
+15
-0
ChSrvTaskDetailMapper.xml
...rvice/src/main/resources/mapper/ChSrvTaskDetailMapper.xml
+9
-1
SrvTaskReqVO.java
...n/java/com/hungraim/ltc/pojo/vo/account/SrvTaskReqVO.java
+2
-0
SrvTaskRespVO.java
.../java/com/hungraim/ltc/pojo/vo/account/SrvTaskRespVO.java
+3
-0
FileUtils.java
...n-core/src/main/java/com/hungraim/ltc/util/FileUtils.java
+98
-2
FileUploadController.java
.../hungraim/ltc/system/controller/FileUploadController.java
+16
-0
AttachService.java
...n/java/com/hungraim/ltc/system/service/AttachService.java
+2
-0
AttachServiceImpl.java
...m/hungraim/ltc/system/service/impl/AttachServiceImpl.java
+8
-0
No files found.
account/account-service/src/main/java/com/hungraim/ltc/account/config/AuditingRoleConfig.java
0 → 100644
View file @
78717895
package
com
.
hungraim
.
ltc
.
account
.
config
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Component
@Data
@ConfigurationProperties
(
prefix
=
"auditing.role"
)
public
class
AuditingRoleConfig
{
private
List
<
String
>
roleId
;
}
account/account-service/src/main/java/com/hungraim/ltc/account/controller/AccountController.java
View file @
78717895
...
...
@@ -167,6 +167,8 @@ public class AccountController {
if
(
srvOrganId
!=
0
)
{
srvTaskReqVO
.
setSrvOrganId
(
srvOrganId
);
}
Integer
userId
=
TokenParsingUtil
.
TokenParsing
(
token
,
"userId"
);
srvTaskReqVO
.
setUserId
(
userId
);
return
Result
.
success
(
accountService
.
getSrvTaskCardList
(
srvTaskReqVO
));
}
...
...
account/account-service/src/main/java/com/hungraim/ltc/account/dao/ChSrvTaskDetailMapper.java
View file @
78717895
...
...
@@ -7,6 +7,7 @@ import com.hungraim.ltc.pojo.vo.account.SrvTaskReqVO;
import
com.hungraim.ltc.pojo.vo.account.SrvTaskRespVO
;
import
com.hungraim.ltc.pojo.vo.disable.PlaceOtherVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
@@ -35,4 +36,6 @@ public interface ChSrvTaskDetailMapper extends BaseMapper<ChSrvTaskDetail> {
List
<
PlaceOtherVO
>
placeOtherTaskQuery
();
int
getRoleByUserId
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"roleIds"
)
List
<
String
>
roleIds
);
}
\ No newline at end of file
account/account-service/src/main/java/com/hungraim/ltc/account/service/impl/AccountServiceImpl.java
View file @
78717895
...
...
@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSON;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.hungraim.ltc.account.config.AuditingRoleConfig
;
import
com.hungraim.ltc.account.dao.*
;
import
com.hungraim.ltc.account.service.AccountService
;
import
com.hungraim.ltc.account.service.BaseAccountService
;
...
...
@@ -28,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -58,6 +60,8 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
private
final
ChSrvPlanMapper
chSrvPlanMapper
;
@Autowired
private
AuditingRoleConfig
auditingRoleConfig
;
private
final
ChSrvTaskDetailMapper
chSrvTaskDetailMapper
;
private
final
ChSrvTaskFinishItemMapper
chSrvTaskFinishItemMapper
;;
...
...
@@ -720,6 +724,17 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
@Override
public
Page
<
SrvTaskRespVO
>
getSrvTaskCardList
(
SrvTaskReqVO
srvTaskReqVO
){
Page
<
SrvTaskRespVO
>
srvTaskList
=
taskDetailMapper
.
getSrvTaskCardList
(
new
Page
<>(
srvTaskReqVO
.
getPageNum
(),
srvTaskReqVO
.
getPageSize
()),
srvTaskReqVO
);
List
<
String
>
roleIds
=
auditingRoleConfig
.
getRoleId
();
log
.
info
(
"==========getSrvTaskCardList====roleIds:{}"
,
roleIds
);
// 有审核的权限就配置,根据配置的审核角色查询是否满足条件,如果查到返回给前端1 可以审核,为2不展示审核按钮
int
count
=
taskDetailMapper
.
getRoleByUserId
(
srvTaskReqVO
.
getUserId
(),
roleIds
);
List
<
SrvTaskRespVO
>
records
=
srvTaskList
.
getRecords
();
for
(
SrvTaskRespVO
record
:
records
)
{
if
(
count
>
0
){
record
.
setAuditFlag
(
true
);
}
}
return
srvTaskList
;
}
...
...
account/account-service/src/main/resources/mapper/ChSrvTaskDetailMapper.xml
View file @
78717895
...
...
@@ -181,6 +181,14 @@
</update>
<select
id=
"getRoleByUserId"
resultType=
"java.lang.Integer"
>
select count(*) from LTC_USER_ROLE r where r.user_id = #{userId}
<if
test=
"roleIds != null"
>
and r.role_id in
<foreach
collection=
"roleIds"
item=
"roleIds"
open=
"("
close=
")"
separator=
","
>
#{roleIds}
</foreach>
</if>
</select>
</mapper>
common/common-core/src/main/java/com/hungraim/ltc/pojo/vo/account/SrvTaskReqVO.java
View file @
78717895
...
...
@@ -22,4 +22,6 @@ public class SrvTaskReqVO extends BaseReq {
private
String
srvOrganName
;
private
Long
srvOrganId
;
private
Integer
userId
;
}
common/common-core/src/main/java/com/hungraim/ltc/pojo/vo/account/SrvTaskRespVO.java
View file @
78717895
...
...
@@ -50,5 +50,7 @@ public class SrvTaskRespVO {
private
String
auditRemark
;
private
boolean
auditFlag
;
}
\ No newline at end of file
common/common-core/src/main/java/com/hungraim/ltc/util/FileUtils.java
View file @
78717895
...
...
@@ -2,11 +2,14 @@ package com.hungraim.ltc.util;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.util.IOUtils
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.*
;
import
java.net.URLEncoder
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
...
...
@@ -80,4 +83,97 @@ public class FileUtils {
}
}
public
static
void
downloadPathFile
(
String
path
,
String
fileName
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
//设置文件路径
File
file
=
new
File
(
path
);
//判断文件是否存在
if
(
file
.
exists
())
{
FileInputStream
fis
=
null
;
OutputStream
os
=
null
;
try
{
// 取得输出流
os
=
response
.
getOutputStream
();
// 清空输出流
response
.
reset
();
//response.setContentType("application/force-download");// 设置强制下载不打开
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setHeader
(
"content-Type"
,
"application/vnd.ms-excel"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
fis
=
new
FileInputStream
(
file
);
IOUtils
.
copy
(
fis
,
os
);
response
.
getOutputStream
().
flush
();
/* bis = new BufferedInputStream(fis);
OutputStream os = response.getOutputStream();
int i = bis.read(buffer);
while (i != -1) {
os.write(buffer, 0, i);
i = bis.read(buffer);
}*/
log
.
info
(
"=========下载成功:{}"
,
fileName
);
}
catch
(
Exception
e
)
{
log
.
error
(
"=====error1:{}"
,
e
);
}
finally
{
try
{
if
(
fis
!=
null
)
{
fis
.
close
();
}
}
catch
(
IOException
e
)
{
// logger.error(ExceptionUtils.getFullStackTrace(e));
}
try
{
if
(
os
!=
null
)
{
os
.
close
();
}
}
catch
(
IOException
e
)
{
//logger.error(ExceptionUtils.getFullStackTrace(e));
}
}
}
}
/**
* 文件下载
*
* @param fileName
* @return
* @author 小辰哥哥
*/
public
static
byte
[]
downloadFile
(
String
path
,
String
fileName
,
HttpServletResponse
response
)
{
// 关联文件
File
file
=
new
File
(
path
);
byte
[]
fileBytes
=
null
;
FileInputStream
fileInputStream
=
null
;
ByteArrayOutputStream
bos
=
null
;
//设置响应头类型,这里可以根据文件类型设置,text/plain、application/vnd.ms-excel等
response
.
setHeader
(
"content-type"
,
"text/plain;charset=UTF-8"
);
response
.
setContentType
(
"application/octet-stream;charset=UTF-8"
);
//如果不设置响应头大小,可能报错:“Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃”
response
.
addHeader
(
"Content-Length"
,
String
.
valueOf
(
file
.
length
()));
try
{
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
fileInputStream
=
new
FileInputStream
(
file
);
bos
=
new
ByteArrayOutputStream
();
byte
[]
bytes
=
new
byte
[
1024
];
int
len
;
while
((
len
=
fileInputStream
.
read
(
bytes
))
!=
-
1
)
{
bos
.
write
(
bytes
,
0
,
len
);
}
fileBytes
=
bos
.
toByteArray
();
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
fileInputStream
.
close
();
bos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
fileBytes
;
}
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/controller/FileUploadController.java
View file @
78717895
...
...
@@ -12,7 +12,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
import
java.util.Objects
;
@RestController
@RequestMapping
(
"/api.system/resource"
)
...
...
@@ -88,4 +91,17 @@ public class FileUploadController {
List
<
ChFndAttach
>
chFndAttaches
=
attachService
.
selectAttachs
(
ctrlId
,
attachType
);
return
Result
.
success
(
chFndAttaches
);
}
@GetMapping
(
"/download"
)
public
void
download
(
Long
attachId
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
ChFndAttach
chFndAttach
=
attachService
.
selectById
(
attachId
);
if
(
Objects
.
nonNull
(
chFndAttach
)){
String
filePath
=
chFndAttach
.
getFilePath
();
String
fileName
=
chFndAttach
.
getFileName
();
FileUtils
.
downloadPathFile
(
filePath
,
fileName
,
request
,
response
);
}
}
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/service/AttachService.java
View file @
78717895
...
...
@@ -35,4 +35,6 @@ public interface AttachService {
* @return 返回对应的数据列表
*/
List
<
ChFndAttach
>
selectAttachs
(
Long
ctrlId
,
Short
attachType
);
ChFndAttach
selectById
(
Long
attachId
);
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/service/impl/AttachServiceImpl.java
View file @
78717895
...
...
@@ -11,6 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
@Service
public
class
AttachServiceImpl
implements
AttachService
{
...
...
@@ -103,4 +104,11 @@ public class AttachServiceImpl implements AttachService {
public
List
<
ChFndAttach
>
selectAttachs
(
Long
ctrlId
,
Short
attachType
)
{
return
this
.
getChFndAttaches
(
ctrlId
,
attachType
);
}
@Override
public
ChFndAttach
selectById
(
Long
attachId
){
ChFndAttach
chFndAttach
=
chFndAttachMapper
.
selectById
(
attachId
);
return
chFndAttach
;
}
}
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