Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
李苗
/
Vion-DevOps
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b9276b67
authored
Mar 22, 2024
by
HlQ
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[chg] 移除合同同步接口
1 parent
922aa4e9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
169 deletions
src/main/java/vion/controller/FileController.java
src/main/java/vion/model/Pic.java
src/main/java/vion/controller/FileController.java
View file @
b9276b6
...
...
@@ -8,35 +8,19 @@ import org.dromara.hutool.core.collection.CollUtil;
import
org.dromara.hutool.core.date.DateUtil
;
import
org.dromara.hutool.core.io.file.FileNameUtil
;
import
org.dromara.hutool.core.io.file.FileUtil
;
import
org.dromara.hutool.core.regex.ReUtil
;
import
org.dromara.hutool.core.text.StrUtil
;
import
org.dromara.hutool.core.util.ObjUtil
;
import
org.dromara.hutool.crypto.SecureUtil
;
import
org.dromara.hutool.http.client.HttpDownloader
;
import
org.dromara.hutool.http.client.Request
;
import
org.dromara.hutool.http.meta.Method
;
import
org.dromara.hutool.json.JSONArray
;
import
org.dromara.hutool.json.JSONObject
;
import
org.dromara.hutool.json.JSONUtil
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
vion.dto.FileInfoDTO
;
import
vion.model.Contract
;
import
vion.model.FileInfo
;
import
vion.model.Pic
;
import
vion.service.IContractService
;
import
vion.service.IFileService
;
import
java.io.File
;
import
java.io.IOException
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@RestController
@RequestMapping
(
"/api"
)
...
...
@@ -45,7 +29,6 @@ import java.util.stream.Collectors;
public
class
FileController
{
private
final
IFileService
fileService
;
private
final
IContractService
contractService
;
private
final
Converter
converter
;
@Value
(
"${fileUrl:}"
)
...
...
@@ -134,147 +117,4 @@ public class FileController {
return
"文件保存成功"
;
}
@GetMapping
(
"/contractFile"
)
public
String
export
()
{
String
url
=
"jdbc:sqlserver://47.92.144.255:1433;databaseName=UFDATA_001_2020;encrypt=false"
;
String
username
=
"vion-reader"
;
String
password
=
"vion-reader"
;
List
<
Pic
>
res
=
new
ArrayList
<>();
try
(
Connection
connection
=
DriverManager
.
getConnection
(
url
,
username
,
password
))
{
String
sql
=
"""
select a.hetongluru_name as contract_no,b.hetongluru_char13 as pic_url from tcu_hetongluru a, tcu_hetongluru_attr b
where a.hetongluru_id = b.hetongluru_id and b.hetongluru_char13 != '';
"""
;
try
(
Statement
statement
=
connection
.
createStatement
())
{
ResultSet
resultSet
=
statement
.
executeQuery
(
sql
);
while
(
resultSet
.
next
())
{
Pic
pic
=
new
Pic
();
String
contractNo
=
resultSet
.
getString
(
"contract_no"
);
pic
.
setContractNo
(
contractNo
);
String
picUrl
=
resultSet
.
getString
(
"pic_url"
);
if
(
StrUtil
.
isBlank
(
picUrl
))
{
continue
;
}
// 获取字符串picUrl后三十六个字符
String
code
=
picUrl
.
substring
(
picUrl
.
length
()
-
36
);
pic
.
setCode
(
code
);
res
.
add
(
pic
);
}
}
}
catch
(
SQLException
e
)
{
}
Map
<
String
,
Contract
>
no2ConMap
=
contractService
.
list
().
stream
().
collect
(
Collectors
.
toMap
(
Contract:
:
getContractNo
,
Function
.
identity
()));
// CSRP20111098 CSRM23065215
for
(
Pic
pic
:
res
)
{
String
contractNo
=
pic
.
getContractNo
();
String
code
=
pic
.
getCode
();
if
(!
no2ConMap
.
containsKey
(
contractNo
))
{
log
.
info
(
"合同文件导入-合同不存在:{}"
,
contractNo
);
continue
;
}
Contract
contract
=
no2ConMap
.
get
(
contractNo
);
List
<
FileInfo
>
list
=
fileService
.
lambdaQuery
()
.
eq
(
FileInfo:
:
getContractId
,
contract
.
getId
())
.
eq
(
FileInfo:
:
getSourceType
,
5
)
.
eq
(
FileInfo:
:
getSourceId
,
contract
.
getId
()).
list
();
if
(
CollUtil
.
isNotEmpty
(
list
))
{
log
.
info
(
"合同文件导入-合同文件已存在:{}"
,
contractNo
);
continue
;
}
String
body
=
Request
.
of
(
"http://47.92.144.255:8072/pub/processattach.php?Action=viewfiles&PageSrc="
)
.
header
(
"Cookie"
,
"PHPSESSID=v0t8clpoqcn1686fhneul31rf4; LoginSystemCookie=1; LoginNameCookie=0191; OrgCodeCookie=%28default%29%40001; ID_LIST_OL_10_0_0_MessageItem__Subject=250; TL_EXPANDED=*REL_CRMCONTRACT4*XSFPSQD.hetonglur2017*hetongluru.XMMC4*hetongpingshen.Opportunity4"
)
.
method
(
Method
.
POST
)
.
form
(
Map
.
of
(
"cellID"
,
code
))
.
send
()
.
bodyStr
();
if
(
body
.
contains
(
"text/javascript"
))
{
log
.
info
(
"合同文件导入-调CRM接口出错:{}"
,
contractNo
);
break
;
}
if
(
StrUtil
.
isBlank
(
body
))
{
log
.
info
(
"合同文件导入-body为空:{},code:{}"
,
contractNo
,
code
);
continue
;
}
if
(!
StrUtil
.
contains
(
body
,
"href"
))
{
log
.
info
(
"合同文件导入-无文件:{},code:{}"
,
contractNo
,
code
);
continue
;
}
JSONObject
json
=
JSONUtil
.
parseObj
(
body
);
Object
o
=
json
.
get
(
"files"
);
if
(
o
instanceof
JSONObject
)
{
JSONObject
files
=
json
.
getJSONObject
(
"files"
);
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
files
)
{
if
(
ObjUtil
.
isEmpty
(
entry
.
getValue
()))
{
continue
;
}
String
href
=
entry
.
getValue
().
toString
();
String
suf
=
ReUtil
.
get
(
"href='(.*?)'"
,
href
,
1
);
String
finalUrl
=
"http://47.92.144.255:8072"
+
suf
;
String
name
=
ReUtil
.
get
(
">(.*?)<"
,
href
,
1
);
String
path
=
fileUrl
+
FileUtil
.
FILE_SEPARATOR
+
"contract"
+
FileUtil
.
FILE_SEPARATOR
+
contract
.
getId
()
+
FileUtil
.
FILE_SEPARATOR
+
name
;
log
.
info
(
"合同:{},文件存入路径:{}"
,
contractNo
,
path
);
File
file
=
HttpDownloader
.
downloadFile
(
finalUrl
,
FileUtil
.
file
(
path
));
FileInfo
fileInfo
=
new
FileInfo
();
fileInfo
.
setStoreId
(-
1L
);
fileInfo
.
setSourceId
(
contract
.
getId
());
fileInfo
.
setSourceType
(
5
);
fileInfo
.
setContractId
(
contract
.
getId
());
fileInfo
.
setName
(
name
);
fileInfo
.
setUrl
(
path
);
fileInfo
.
setType
(
FileNameUtil
.
extName
(
file
));
fileInfo
.
setSha256
(
SecureUtil
.
sha256
(
file
).
toUpperCase
());
fileInfo
.
setUploader
(
"CRM"
);
fileService
.
save
(
fileInfo
);
}
}
else
if
(
o
instanceof
JSONArray
)
{
JSONArray
files
=
json
.
getJSONArray
(
"files"
);
for
(
Object
obj
:
files
)
{
if
(
ObjUtil
.
isEmpty
(
obj
))
{
continue
;
}
String
href
=
obj
.
toString
();
String
suf
=
ReUtil
.
get
(
"href='(.*?)'"
,
href
,
1
);
String
finalUrl
=
"http://47.92.144.255:8072"
+
suf
;
String
name
=
ReUtil
.
get
(
">(.*?)<"
,
href
,
1
);
String
path
=
fileUrl
+
FileUtil
.
FILE_SEPARATOR
+
"contract"
+
FileUtil
.
FILE_SEPARATOR
+
contract
.
getId
()
+
FileUtil
.
FILE_SEPARATOR
+
name
;
log
.
info
(
"合同:{},文件存入路径:{}"
,
contractNo
,
path
);
File
file
=
HttpDownloader
.
downloadFile
(
finalUrl
,
FileUtil
.
file
(
path
));
FileInfo
fileInfo
=
new
FileInfo
();
fileInfo
.
setStoreId
(-
1L
);
fileInfo
.
setSourceId
(
contract
.
getId
());
fileInfo
.
setSourceType
(
5
);
fileInfo
.
setContractId
(
contract
.
getId
());
fileInfo
.
setName
(
name
);
fileInfo
.
setUrl
(
path
);
fileInfo
.
setType
(
FileNameUtil
.
extName
(
file
));
fileInfo
.
setSha256
(
SecureUtil
.
sha256
(
file
).
toUpperCase
());
fileInfo
.
setUploader
(
"CRM"
);
fileService
.
save
(
fileInfo
);
}
}
else
{
log
.
info
(
"合同文件导入-json转化出错:{},code:{}"
,
contractNo
,
code
);
}
}
return
"success"
;
}
@DeleteMapping
(
"/speFile"
)
public
String
delSpeFile
()
{
List
<
FileInfo
>
list
=
fileService
.
lambdaQuery
().
eq
(
FileInfo:
:
getSourceType
,
5
).
eq
(
FileInfo:
:
getUploader
,
"CRM"
).
list
();
for
(
FileInfo
file
:
list
)
{
FileUtil
.
del
(
file
.
getUrl
());
fileService
.
removeById
(
file
.
getId
());
}
return
"success"
;
}
}
\ No newline at end of file
src/main/java/vion/model/Pic.java
deleted
100644 → 0
View file @
922aa4e
package
vion
.
model
;
import
lombok.Data
;
@Data
public
class
Pic
{
private
String
contractNo
;
private
String
code
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment