Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vehicle-quality-review
Project
Project
Details
Activity
Releases
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
王飞
vehicle-quality-review
Commits
287c13a9
Commit
287c13a9
authored
Jul 05, 2024
by
wdy
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'master'
dev - master 39 See merge request
!403
parents
e39158c6
e8e9a3db
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
7 deletions
+104
-7
ReviewEnterpriseArchiveMapper.java
.../java/com/ruoyi/mapper/ReviewEnterpriseArchiveMapper.java
+8
-0
ReviewEnterpriseArchiveServiceImpl.java
...uoyi/service/impl/ReviewEnterpriseArchiveServiceImpl.java
+12
-5
ReviewEnterpriseArchiveMapper.xml
...c/main/resources/mapper/ReviewEnterpriseArchiveMapper.xml
+5
-0
TestDownload.java
ruoyi-admin/src/test/java/com/ruoyi/TestDownload.java
+77
-0
TestRecordsTest.java
ruoyi-admin/src/test/java/com/ruoyi/TestRecordsTest.java
+2
-2
No files found.
quality-review/src/main/java/com/ruoyi/mapper/ReviewEnterpriseArchiveMapper.java
View file @
287c13a9
...
...
@@ -27,6 +27,14 @@ public interface ReviewEnterpriseArchiveMapper extends BaseMapper<ReviewEnterpri
Long
findFileName
(
@Param
(
"taskId"
)
Long
taskId
,
@Param
(
"fileName"
)
String
fileName
);
/**
* 根据文件名称和任务id查询
* @param taskId
* @param fileName
* @return
*/
ReviewEnterpriseArchive
findByFileNameAndId
(
@Param
(
"taskId"
)
Long
taskId
,
@Param
(
"fileName"
)
String
fileName
);
List
<
ReviewEnterpriseArchive
>
findEnterpriseArchive
(
ReviewEnterpriseArchiveFindRequest
request
);
ReviewEnterpriseArchive
findByFileName
(
@Param
(
"fileName"
)
String
fileName
);
...
...
quality-review/src/main/java/com/ruoyi/service/impl/ReviewEnterpriseArchiveServiceImpl.java
View file @
287c13a9
...
...
@@ -9,6 +9,7 @@ import com.ruoyi.common.exception.ServiceException;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.bean.BeanUtils
;
import
com.ruoyi.domain.ReviewEnterpriseArchive
;
import
com.ruoyi.domain.Task
;
import
com.ruoyi.domain.vo.*
;
...
...
@@ -253,20 +254,26 @@ public class ReviewEnterpriseArchiveServiceImpl extends ServiceImpl<ReviewEnterp
@Override
public
void
importEnterprise
(
List
<
EnterpriseImportFileVO
>
list
,
Long
taskId
,
HttpServletResponse
response
){
List
<
EnterpriseImportFileVO
>
filteredList
=
new
ArrayList
<>();
for
(
EnterpriseImportFileVO
vo:
list
){
vo
.
setCreateTime
(
getNowDate
());
vo
.
setCreateBy
(
SecurityUtils
.
getLoginUser
().
getUser
().
getNickName
());
vo
.
setTaskId
(
Long
.
valueOf
(
taskId
));
vo
.
setId
(
IdUtil
.
getSnowflake
().
nextId
());
Long
sum
=
reviewEnterpriseArchiveMapper
.
findFileName
(
Long
.
valueOf
(
taskId
),
vo
.
getFileName
());
if
(
sum
>
0
)
{
throw
new
ServiceException
(
"新增文件名称重复,请检查"
,
HttpStatus
.
ERROR
);
}
ReviewEnterpriseArchive
enterpriseArchive
=
reviewEnterpriseArchiveMapper
.
findByFileNameAndId
(
Long
.
valueOf
(
taskId
),
vo
.
getFileName
());
if
(
vo
.
getFileName
().
isEmpty
()){
throw
new
ServiceException
(
"文件名称不能为空"
,
HttpStatus
.
ERROR
);
}
if
(
enterpriseArchive
!=
null
)
{
BeanUtils
.
copyBeanProp
(
enterpriseArchive
,
vo
);
reviewEnterpriseArchiveService
.
updateById
(
enterpriseArchive
);
}
if
(
enterpriseArchive
==
null
)
{
// 只有当enterpriseArchive为空时,才将vo添加到新的列表中
filteredList
.
add
(
vo
);
}
}
reviewEnterpriseArchiveMapper
.
insertEnterprise
(
l
ist
);
reviewEnterpriseArchiveMapper
.
insertEnterprise
(
filteredL
ist
);
}
@Override
...
...
quality-review/src/main/resources/mapper/ReviewEnterpriseArchiveMapper.xml
View file @
287c13a9
...
...
@@ -82,6 +82,11 @@
</if>
</where>
</select>
<select
id=
"findByFileNameAndId"
resultType=
"com.ruoyi.domain.ReviewEnterpriseArchive"
>
SELECT id, enterprise_name, file_name, version, publish_date, status, identify_number, storage, photo, task_id, create_by, create_time
FROM t_review_enterprise_archive
where file_name = #{fileName} and task_id = #{taskId}
</select>
<insert
id=
"insertEnterprise"
parameterType=
"java.util.List"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into t_review_enterprise_archive(id,enterprise_name,file_name,version,publish_date,status,identify_number,storage,task_id,create_by,create_time)values
...
...
ruoyi-admin/src/test/java/com/ruoyi/TestDownload.java
0 → 100644
View file @
287c13a9
package
com
.
ruoyi
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
java.io.File
;
@SpringBootTest
public
class
TestDownload
{
@Test
public
void
Test
()
{
try
{
// 压缩包的名称和路径
String
zipFilePath
=
"downloaded_files.zip"
;
HttpResponse
response
=
HttpUtil
.
createPost
(
"https://10.12.48.78:8090/api/project/download/fd40de37-9c57-4597-8f74-d0754dfa17b2"
)
.
execute
();
if
(
response
.
isOk
())
{
// 从响应头中获取文件名,这里假设Content-Disposition头包含文件名
String
contentDisposition
=
response
.
header
(
"Content-Disposition"
);
String
fileName
=
extractFileNameFromContentDisposition
(
contentDisposition
);
if
(
StrUtil
.
isNotBlank
(
fileName
))
{
// 保存下载的文件到临时位置
String
tempFilePath
=
"temp_"
+
fileName
;
FileUtil
.
writeBytes
(
IoUtil
.
readBytes
(
response
.
bodyStream
()),
FileUtil
.
file
(
tempFilePath
));
System
.
out
.
println
(
"文件下载成功:"
+
fileName
);
// 将临时文件添加到压缩包中
// ZipUtil.addFile(zipFilePath, tempFilePath);
System
.
out
.
println
(
"文件已添加到压缩包:"
+
zipFilePath
);
// 删除临时文件
FileUtil
.
del
(
tempFilePath
);
}
else
{
System
.
err
.
println
(
"无法从响应头中提取文件名"
);
}
}
else
{
System
.
err
.
println
(
"下载失败,状态码:"
+
response
.
getStatus
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 从Content-Disposition头中提取文件名。
* 注意:这是一个简化的示例,真实场景可能需要更复杂的解析逻辑。
*
* @param contentDisposition Content-Disposition头的值
* @return 提取的文件名,如果未找到则返回空字符串
*/
private
static
String
extractFileNameFromContentDisposition
(
String
contentDisposition
)
{
if
(
StrUtil
.
isBlank
(
contentDisposition
))
{
return
""
;
}
String
[]
parts
=
contentDisposition
.
split
(
";"
);
for
(
String
part
:
parts
)
{
part
=
part
.
trim
();
if
(
part
.
startsWith
(
"filename="
))
{
return
part
.
substring
(
part
.
indexOf
(
'='
)
+
1
).
replace
(
"\""
,
""
);
}
}
return
""
;
}
}
ruoyi-admin/src/test/java/com/ruoyi/TestRecordsTest.java
View file @
287c13a9
...
...
@@ -28,7 +28,7 @@ public class TestRecordsTest {
public
void
test
()
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
"
project_items;27
"
);
map
.
put
(
"id"
,
"
5wU7nij8QomtoGMVhoxQjryw8hncJ
"
);
map
.
put
(
"verbose"
,
"ALL"
);
//以post形式请求接口
...
...
@@ -43,7 +43,7 @@ public class TestRecordsTest {
List
<
CaseResultVO
>
caseResultVOS
=
jsonObject
.
getList
(
"case_result_list"
,
CaseResultVO
.
class
);
// 获取本地存储的列表
List
<
TestRecords
>
recordsList
=
testRecordsService
.
findByTaskId
(
"
project_items;29
"
);
List
<
TestRecords
>
recordsList
=
testRecordsService
.
findByTaskId
(
"
5wU7nij8QomtoGMVhoxQjryw8hncJ
"
);
List
<
TestRecords
>
list
=
new
ArrayList
<>();
if
(
caseResultVOS
.
size
()
!=
0
&&
caseResultVOS
!=
null
)
{
...
...
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