Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
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
1
Merge Requests
1
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
poc
poc-api
Commits
4d5c2967
Commit
4d5c2967
authored
Jan 09, 2026
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style[software_copyright]: 优化代码结构
parent
3b672403
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
172 additions
and
169 deletions
+172
-169
SoftwareCopyRightService.java
...oftware_copyright/aggregate/SoftwareCopyRightService.java
+12
-7
SoftwareCopyRightServiceImpl.java
...opyright/aggregate/impl/SoftwareCopyRightServiceImpl.java
+54
-68
BizSoftwareCopyrightConvert.java
...ftware_copyright/convert/BizSoftwareCopyrightConvert.java
+18
-4
BizSoftwareCopyrightRestImpl.java
...are_copyright/rest/impl/BizSoftwareCopyrightRestImpl.java
+4
-30
SoftwareCopyRightScheduler.java
...tware_copyright/scheduler/SoftwareCopyRightScheduler.java
+33
-60
FileUtils.java
src/main/java/cn/com/poc/common/utils/FileUtils.java
+51
-0
No files found.
src/main/java/cn/com/poc/ai_software_copyright/aggregate/SoftwareCopyRightService.java
View file @
4d5c2967
...
...
@@ -8,8 +8,11 @@ import cn.com.gsst.dify_client.exception.DifyApiException;
import
cn.com.poc.ai_software_copyright.contant.AiSoftWareCopyRightEnum
;
import
cn.com.poc.ai_software_copyright.domian.BaseInfo
;
import
cn.com.poc.ai_software_copyright.domian.TechnicalContent
;
import
cn.com.poc.ai_software_copyright.dto.SoftwareCopyRightDto
;
import
cn.com.poc.ai_software_copyright.entity.BizSoftwareCopyrightDocRecordEntity
;
import
cn.com.poc.ai_software_copyright.entity.BizSoftwareCopyrightEntity
;
import
cn.com.poc.ai_software_copyright.entity.CallbackEntity
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.springframework.web.multipart.MultipartFile
;
/**
...
...
@@ -51,7 +54,7 @@ public interface SoftwareCopyRightService {
*
* @param id biz_software_copyright 主键id
*/
BizSoftwareCopyrightDocRecordEntity
listFile
(
Long
id
)
;
BizSoftwareCopyrightDocRecordEntity
listFile
(
Long
id
);
/**
* 获取下载地址
...
...
@@ -71,19 +74,21 @@ public interface SoftwareCopyRightService {
String
upload
(
MultipartFile
file
)
throws
IOException
;
/**
*
压缩文件并更新记录
*
软著查询
*
* @param recordEntity
* @return 压缩文件地址
* @param query 查询条件
* @param generatedStatus 生成状态
* @param pagingInfo 分页信息
* @return 软著列表
*/
String
zipFilesAndUpdateRecord
(
BizSoftwareCopyrightDocRecordEntity
recordEntity
);
List
<
BizSoftwareCopyrightEntity
>
querySoftwareCopyRight
(
String
query
,
String
generatedStatus
,
PagingInfo
pagingInfo
);
/**
* 回调-生成基础文档
*
* @param taskId 回调任务ID
* @param type 回调类型
* @param taskId
回调任务ID
* @param type
回调类型
* @param callbackEntity 回调结果
*/
void
callbackGeneratedBaseDoc
(
String
taskId
,
String
type
,
CallbackEntity
callbackEntity
);
...
...
src/main/java/cn/com/poc/ai_software_copyright/aggregate/impl/SoftwareCopyRightServiceImpl.java
View file @
4d5c2967
This diff is collapsed.
Click to expand it.
src/main/java/cn/com/poc/ai_software_copyright/convert/BizSoftwareCopyrightConvert.java
View file @
4d5c2967
...
...
@@ -87,10 +87,10 @@ public class BizSoftwareCopyrightConvert {
);
softwareCopyRightDto
.
setReferenceDocumentFileUrl
(
StringUtils
.
isNotBlank
(
entity
.
getReferenceDocumentFileUrl
())
?
JsonUtils
.
deSerialize
(
entity
.
getReferenceDocumentFileUrl
(),
new
TypeReference
<
List
<
String
>>()
{
}.
getType
())
:
Collections
.
emptyList
()
StringUtils
.
isNotBlank
(
entity
.
getReferenceDocumentFileUrl
())
?
JsonUtils
.
deSerialize
(
entity
.
getReferenceDocumentFileUrl
(),
new
TypeReference
<
List
<
String
>>()
{
}.
getType
())
:
Collections
.
emptyList
()
);
softwareCopyRightDto
.
setGeneratedDocType
(
...
...
@@ -138,4 +138,18 @@ public class BizSoftwareCopyrightConvert {
softwareCopyRightDto
.
setCreatedTime
(
item
.
getCreatedTime
());
return
softwareCopyRightDto
;
}
public
static
BizSoftwareCopyrightEntity
softwareCopyrightQueryItemToEntity
(
SoftwareCopyrightQueryItem
item
)
{
BizSoftwareCopyrightEntity
bizSoftwareCopyrightEntity
=
new
BizSoftwareCopyrightEntity
();
bizSoftwareCopyrightEntity
.
setId
(
item
.
getId
());
bizSoftwareCopyrightEntity
.
setBaseInfo
(
item
.
getBaseInfo
());
bizSoftwareCopyrightEntity
.
setTechnicalContent
(
item
.
getTechnicalContent
());
bizSoftwareCopyrightEntity
.
setReferenceDocumentFileUrl
(
item
.
getReferenceDocumentFileUrl
());
bizSoftwareCopyrightEntity
.
setGeneratedDocType
(
item
.
getGeneratedDocType
());
bizSoftwareCopyrightEntity
.
setGeneratedStatus
(
item
.
getGeneratedStatus
());
bizSoftwareCopyrightEntity
.
setErrorMess
(
item
.
getErrorMess
());
bizSoftwareCopyrightEntity
.
setCreatedTime
(
item
.
getCreatedTime
());
return
bizSoftwareCopyrightEntity
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/ai_software_copyright/rest/impl/BizSoftwareCopyrightRestImpl.java
View file @
4d5c2967
...
...
@@ -22,8 +22,6 @@ import cn.com.poc.ai_software_copyright.query.SoftwareCopyrightQueryCondition;
import
cn.com.poc.ai_software_copyright.query.SoftwareCopyrightQueryItem
;
import
cn.com.poc.ai_software_copyright.rest.BizSoftwareCopyrightRest
;
import
cn.com.poc.ai_software_copyright.service.BizSoftwareCopyrightService
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.StringUtils
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.springframework.stereotype.Component
;
...
...
@@ -33,14 +31,9 @@ import org.springframework.web.multipart.MultipartFile;
@Component
public
class
BizSoftwareCopyrightRestImpl
implements
BizSoftwareCopyrightRest
{
@Resource
private
RedisService
redisService
;
@Resource
private
SoftwareCopyRightService
softwareCopyRightService
;
@Resource
private
BizSoftwareCopyrightService
bizSoftwareCopyrightService
;
...
...
@@ -64,30 +57,11 @@ public class BizSoftwareCopyrightRestImpl implements BizSoftwareCopyrightRest {
@Override
public
List
<
SoftwareCopyRightDto
>
querySoftwareCopyRight
(
String
query
,
String
generatedStatus
,
PagingInfo
pagingInfo
)
{
SoftwareCopyrightQueryCondition
condition
=
new
SoftwareCopyrightQueryCondition
();
List
<
String
>
generatedStatusList
=
null
;
if
(
StringUtils
.
isNotBlank
(
generatedStatus
))
{
if
(
generatedStatus
.
equals
(
AiSoftWareCopyRightEnum
.
GENERATED_STATUS
.
Daft
.
name
())
||
generatedStatus
.
equals
(
AiSoftWareCopyRightEnum
.
GENERATED_STATUS
.
Pending
.
name
())
||
generatedStatus
.
equals
(
AiSoftWareCopyRightEnum
.
GENERATED_STATUS
.
Running
.
name
())
)
{
generatedStatusList
=
new
ArrayList
<>();
generatedStatusList
.
add
(
AiSoftWareCopyRightEnum
.
GENERATED_STATUS
.
Daft
.
name
());
generatedStatusList
.
add
(
AiSoftWareCopyRightEnum
.
GENERATED_STATUS
.
Pending
.
name
());
generatedStatusList
.
add
(
AiSoftWareCopyRightEnum
.
GENERATED_STATUS
.
Running
.
name
());
condition
.
setGeneratedStatusList
(
generatedStatusList
);
}
else
{
condition
.
setGeneratedStatus
(
generatedStatus
);
}
}
condition
.
setQuery
(
query
);
List
<
SoftwareCopyrightQueryItem
>
softwareCopyrightQueryItems
=
bizSoftwareCopyrightService
.
softwareCopyrightQuery
(
condition
,
pagingInfo
);
return
softwareCopyrightQueryItems
.
stream
().
map
(
BizSoftwareCopyrightConvert:
:
softwareCopyrightQueryItemToDto
)
.
collect
(
Collectors
.
toList
());
List
<
BizSoftwareCopyrightEntity
>
bizSoftwareCopyrightEntities
=
softwareCopyRightService
.
querySoftwareCopyRight
(
query
,
generatedStatus
,
pagingInfo
);
return
bizSoftwareCopyrightEntities
.
stream
().
map
(
BizSoftwareCopyrightConvert:
:
entityToDto
)
.
collect
(
Collectors
.
toList
());
}
@Override
...
...
src/main/java/cn/com/poc/ai_software_copyright/scheduler/SoftwareCopyRightScheduler.java
View file @
4d5c2967
...
...
@@ -55,25 +55,26 @@ public class SoftwareCopyRightScheduler {
"https://gsst-poe-sit.gz.bcebos.com/v1/software-copyright/%E6%A8%A1%E6%9D%BF.docx"
;
@Resource
private
SoftwareCopyRightProduceService
produce
Service
;
private
RedisService
redis
Service
;
@Resource
private
RedisService
redis
Service
;
private
BosConfigService
bosConfig
Service
;
@Resource
private
BizSoftwareCopyrightService
bizSoftwareCopyright
Service
;
private
LegalService
legal
Service
;
@Resource
private
SoftwareCopyRightAgent
softwareCopyRightAgent
;
@Resource
private
BizSoftwareCopyrightDocRecordService
bizSoftwareCopyrightDocRecord
Service
;
private
SoftwareCopyRightProduceService
produce
Service
;
@Resource
private
B
osConfigService
bosConfig
Service
;
private
B
izSoftwareCopyrightService
bizSoftwareCopyright
Service
;
@Resource
private
LegalService
legalService
;
private
BizSoftwareCopyrightDocRecordService
bizSoftwareCopyrightDocRecordService
;
@Scheduled
(
fixedDelay
=
1000
*
30
)
public
void
checkDeftSoftwareCopyRightTask
()
{
...
...
@@ -122,7 +123,7 @@ public class SoftwareCopyRightScheduler {
}
@Scheduled
(
fixedDelay
=
1000
*
30
)
@Scheduled
(
fixedDelay
=
1000
*
15
)
public
void
checkRunningSoftwareCopyRightTask
()
{
BizSoftwareCopyrightEntity
bizSoftwareCopyrightEntity
=
new
BizSoftwareCopyrightEntity
();
bizSoftwareCopyrightEntity
.
setGeneratedStatus
(
AiSoftWareCopyRightEnum
.
GENERATED_STATUS
.
Running
.
name
());
...
...
@@ -132,41 +133,37 @@ public class SoftwareCopyRightScheduler {
if
(
CollectionUtils
.
isNotEmpty
(
bizSoftwareCopyrightEntities
))
{
bizSoftwareCopyrightEntities
.
parallelStream
().
forEach
(
softwareCopyrightEntity
->
{
after
(
softwareCopyrightEntity
);
});
}
}
private
void
after
(
BizSoftwareCopyrightEntity
softwareCopyrightEntity
)
{
BizSoftwareCopyrightDocRecordEntity
recordEntity
=
bizSoftwareCopyrightDocRecordService
.
getByRelationId
(
softwareCopyrightEntity
.
getId
());
if
(
recordEntity
==
null
)
{
recordEntity
=
new
BizSoftwareCopyrightDocRecordEntity
();
recordEntity
.
setRelationId
(
softwareCopyrightEntity
.
getId
());
}
String
generatedDocType
=
softwareCopyrightEntity
.
getGeneratedDocType
();
if
(
StringUtils
.
isBlank
(
generatedDocType
))
{
return
;
}
List
<
String
>
docTypes
;
try
{
docTypes
=
JsonUtils
.
deSerialize
(
generatedDocType
,
new
TypeReference
<
List
<
String
>>()
{
if
(
StringUtils
.
isBlank
(
softwareCopyrightEntity
.
getGeneratedDocType
()))
{
return
;
}
docTypes
=
JsonUtils
.
deSerialize
(
softwareCopyrightEntity
.
getGeneratedDocType
(),
new
TypeReference
<
List
<
String
>>()
{
}.
getType
());
if
(
CollectionUtils
.
isEmpty
(
docTypes
))
{
return
;
}
}
catch
(
Exception
e
)
{
throw
new
IllegalArgumentException
(
"Invalid generatedDocType format"
,
e
);
}
if
(
docTypes
==
null
||
docTypes
.
isEmpty
())
{
return
;
}
String
redisKey
=
CALL_BACK
+
softwareCopyrightEntity
.
getId
();
boolean
allDone
=
true
;
boolean
isChange
=
false
;
BizSoftwareCopyrightDocRecordEntity
recordEntity
=
bizSoftwareCopyrightDocRecordService
.
getByRelationId
(
softwareCopyrightEntity
.
getId
());
if
(
recordEntity
==
null
)
{
recordEntity
=
new
BizSoftwareCopyrightDocRecordEntity
();
recordEntity
.
setRelationId
(
softwareCopyrightEntity
.
getId
());
}
for
(
String
docType
:
docTypes
)
{
AiSoftWareCopyRightEnum
.
DOC_TYPE
type
;
...
...
@@ -185,11 +182,9 @@ public class SoftwareCopyRightScheduler {
allDone
=
false
;
continue
;
}
try
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
obj
.
toString
());
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"result"
);
if
(
jsonArray
!=
null
)
{
byte
[]
documentBytes
=
createSourceCodeDocument
(
jsonArray
);
String
url
=
...
...
@@ -202,7 +197,6 @@ public class SoftwareCopyRightScheduler {
continue
;
}
}
}
else
if
(
type
.
equals
(
AiSoftWareCopyRightEnum
.
DOC_TYPE
.
pc_operating_manual
))
{
String
pcOperatingManual
=
recordEntity
.
getPcOperatingManual
();
if
(
StringUtils
.
isBlank
(
pcOperatingManual
))
{
...
...
@@ -211,11 +205,9 @@ public class SoftwareCopyRightScheduler {
allDone
=
false
;
continue
;
}
try
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
obj
.
toString
());
String
result
=
jsonObject
.
getString
(
"result"
);
if
(
result
!=
null
)
{
byte
[]
documentBytes
=
createSimpleDocument
(
result
);
String
url
=
uploadDocument
(
documentBytes
,
...
...
@@ -229,7 +221,6 @@ public class SoftwareCopyRightScheduler {
continue
;
}
}
}
else
if
(
type
.
equals
(
AiSoftWareCopyRightEnum
.
DOC_TYPE
.
ph_operating_manual
))
{
String
phOperatingManual
=
recordEntity
.
getPhOperatingManual
();
if
(
StringUtils
.
isBlank
(
phOperatingManual
))
{
// 修复:使用正确的变量名
...
...
@@ -261,7 +252,6 @@ public class SoftwareCopyRightScheduler {
BizSoftwareCopyrightConvert
.
entityToDto
(
softwareCopyrightEntity
);
BaseInfo
baseInfo
=
softwareCopyRightDto
.
getBaseInfo
();
TechnicalContent
technicalContent
=
softwareCopyRightDto
.
getTechnicalContent
();
List
<
Item
>
items
=
new
ArrayList
<>();
buildItem
(
baseInfo
,
items
,
technicalContent
);
LegalFileResponse
legalFileResponse
=
new
LegalFileResponse
();
...
...
@@ -286,39 +276,22 @@ public class SoftwareCopyRightScheduler {
}
private
void
buildItem
(
BaseInfo
baseInfo
,
List
<
Item
>
items
,
TechnicalContent
technicalContent
)
{
// 处理baseInfo的所有字段
// 处理baseInfo
,technicalContent
的所有字段
java
.
lang
.
reflect
.
Field
[]
baseInfoFields
=
baseInfo
.
getClass
().
getDeclaredFields
();
for
(
java
.
lang
.
reflect
.
Field
field
:
baseInfoFields
)
{
field
.
setAccessible
(
true
);
try
{
Object
value
=
field
.
get
(
baseInfo
);
List
<
String
>
values
=
new
ArrayList
<>();
if
(
value
==
null
)
{
values
.
add
(
" "
);
}
if
(
value
!=
null
)
{
values
.
add
(
value
.
toString
());
}
Item
item
=
new
Item
();
item
.
setKey
(
field
.
getName
());
item
.
setValue
(
values
);
item
.
setType
(
"text"
);
items
.
add
(
item
);
}
catch
(
IllegalAccessException
e
)
{
// 记录错误但继续处理其他字段
continue
;
}
}
// 处理technicalContent的所有字段
java
.
lang
.
reflect
.
Field
[]
technicalContentFields
=
technicalContent
.
getClass
().
getDeclaredFields
();
for
(
java
.
lang
.
reflect
.
Field
field
:
technicalContentFields
)
{
java
.
lang
.
reflect
.
Field
[]
fileds
=
new
java
.
lang
.
reflect
.
Field
[
baseInfoFields
.
length
+
technicalContentFields
.
length
];
System
.
arraycopy
(
baseInfoFields
,
0
,
fileds
,
0
,
baseInfoFields
.
length
);
System
.
arraycopy
(
technicalContentFields
,
0
,
fileds
,
baseInfoFields
.
length
,
technicalContentFields
.
length
);
for
(
java
.
lang
.
reflect
.
Field
field
:
fileds
)
{
field
.
setAccessible
(
true
);
try
{
Object
value
=
field
.
get
(
technicalContent
);
Object
value
=
field
.
get
(
baseInfo
);
List
<
String
>
values
=
new
ArrayList
<>();
if
(
value
==
null
)
{
values
.
add
(
" "
);
values
.
add
(
StringUtils
.
SPACE
);
}
if
(
value
!=
null
)
{
values
.
add
(
value
.
toString
());
...
...
@@ -329,7 +302,7 @@ public class SoftwareCopyRightScheduler {
item
.
setType
(
"text"
);
items
.
add
(
item
);
}
catch
(
IllegalAccessException
e
)
{
// 记录错误但继续处理其他字段
//
todo
记录错误但继续处理其他字段
continue
;
}
}
...
...
src/main/java/cn/com/poc/common/utils/FileUtils.java
View file @
4d5c2967
package
cn
.
com
.
poc
.
common
.
utils
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -7,7 +10,9 @@ import org.springframework.web.multipart.MultipartFile;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
/**
...
...
@@ -70,4 +75,50 @@ public class FileUtils {
return
null
;
}
/**
* 判断文件是否为压缩文件
*
* @param file 文件
* @return 是否为压缩文件
*/
public
static
boolean
isCompressedFile
(
File
file
)
{
String
fileName
=
file
.
getName
().
toLowerCase
();
return
fileName
.
endsWith
(
".zip"
)
||
fileName
.
endsWith
(
".tar"
)
||
fileName
.
endsWith
(
".tar.gz"
)
||
fileName
.
endsWith
(
".tgz"
)
||
fileName
.
endsWith
(
".rar"
)
||
fileName
.
endsWith
(
".7z"
);
}
/**
* 解压文件
*
* @param gzipFile
* @return
* @throws IOException
*/
public
static
List
<
File
>
unGzip
(
File
gzipFile
)
throws
IOException
{
// 目标解压目录
String
destDir
=
Files
.
createTempDirectory
(
"gzip/temp/"
).
toString
();
// 确保目标目录存在
FileUtil
.
mkdir
(
destDir
);
File
[]
extractedFiles
=
ZipUtil
.
unzip
(
gzipFile
,
new
File
(
destDir
)).
listFiles
();
return
ListUtil
.
toList
(
extractedFiles
);
}
/**
* 验证并清理文件名,防止路径遍历攻击
*/
public
static
String
sanitizeFileName
(
String
fileName
)
{
if
(
fileName
==
null
)
{
return
"unknown"
;
}
// 移除路径分隔符,防止路径遍历
fileName
=
fileName
.
replace
(
"../"
,
""
).
replace
(
"..\\"
,
""
).
replace
(
".."
,
""
);
// 只保留文件名部分
int
lastSeparatorIndex
=
Math
.
max
(
fileName
.
lastIndexOf
(
'/'
),
fileName
.
lastIndexOf
(
'\\'
));
if
(
lastSeparatorIndex
>=
0
)
{
fileName
=
fileName
.
substring
(
lastSeparatorIndex
+
1
);
}
return
fileName
.
isEmpty
()
?
"unknown"
:
fileName
;
}
}
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