Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hp-smart
Overview
Overview
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
platform
hp-smart
Commits
3660055b
Commit
3660055b
authored
Mar 27, 2024
by
liulei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
APP文件上传
parent
3236342b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
11 deletions
+77
-11
HpjxApplication.java
src/main/java/com/baosight/hpjx/HpjxApplication.java
+10
-0
FileUploadController.java
...va/com/baosight/hpjx/controller/FileUploadController.java
+64
-0
ServiceHPMT002.java
.../java/com/baosight/hpjx/hp/mt/service/ServiceHPMT002.java
+2
-10
HPMT002.xml
src/main/java/com/baosight/hpjx/hp/mt/sql/HPMT002.xml
+1
-1
No files found.
src/main/java/com/baosight/hpjx/HpjxApplication.java
View file @
3660055b
...
@@ -8,7 +8,9 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
...
@@ -8,7 +8,9 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.web.servlet.ServletComponentScan
;
import
org.springframework.boot.web.servlet.ServletComponentScan
;
import
org.springframework.boot.web.servlet.support.SpringBootServletInitializer
;
import
org.springframework.boot.web.servlet.support.SpringBootServletInitializer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ImportResource
;
import
org.springframework.context.annotation.ImportResource
;
import
org.springframework.web.multipart.commons.CommonsMultipartResolver
;
@SpringBootApplication
(
scanBasePackages
=
"com.baosight"
)
@SpringBootApplication
(
scanBasePackages
=
"com.baosight"
)
@ServletComponentScan
(
"com.baosight.iplat4j.core.web.servlet"
)
@ServletComponentScan
(
"com.baosight.iplat4j.core.web.servlet"
)
...
@@ -26,4 +28,12 @@ public class HpjxApplication extends SpringBootServletInitializer {
...
@@ -26,4 +28,12 @@ public class HpjxApplication extends SpringBootServletInitializer {
return
application
.
sources
(
HpjxApplication
.
class
);
return
application
.
sources
(
HpjxApplication
.
class
);
}
}
@Bean
(
"multipartResolver"
)
public
CommonsMultipartResolver
multipartResolver
(){
CommonsMultipartResolver
resolver
=
new
CommonsMultipartResolver
();
resolver
.
setDefaultEncoding
(
"UTF-8"
);
resolver
.
setMaxInMemorySize
(
10000
);
return
resolver
;
}
}
}
src/main/java/com/baosight/hpjx/controller/FileUploadController.java
0 → 100644
View file @
3660055b
package
com
.
baosight
.
hpjx
.
controller
;
import
com.baosight.hpjx.hp.mt.untils.Base64ToMultipartFile
;
import
com.baosight.hpjx.hp.mt.untils.UploadUtils2
;
import
com.baosight.hpjx.util.FileUtils
;
import
com.baosight.hpjx.util.LogUtils
;
import
com.baosight.hpjx.util.MapUtils
;
import
com.baosight.hpjx.util.StringUtils
;
import
com.baosight.iplat4j.core.ei.EiConstant
;
import
com.baosight.iplat4j.core.ei.EiInfo
;
import
com.baosight.iplat4j.core.exception.PlatException
;
import
com.baosight.iplat4j.core.service.soa.XServiceManager
;
import
com.baosight.iplat4j.eu.dm.document.bos.s3.api.signed.SignedBosHelp
;
import
com.baosight.iplat4j.eu.dm.document.bos.s3.param.BosParamHelp
;
import
com.google.common.base.Joiner
;
import
lombok.extern.slf4j.Slf4j
;
import
net.sf.json.JSONObject
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.commons.CommonsMultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Set
;
/**
* @author:songx
* @date:2024/3/14,14:26
*/
@CrossOrigin
@RestController
@RequestMapping
({
"/upload/file"
})
public
class
FileUploadController
{
/**
* 更具docId上传文件
*
* @param file
* @throws IOException
*/
@RequestMapping
(
value
=
"/app"
,
method
=
RequestMethod
.
POST
)
public
Map
upload
(
MultipartFile
file
)
throws
IOException
{
Map
resultMap
=
new
HashMap
();
try
{
JSONObject
upload
=
UploadUtils2
.
upload
((
CommonsMultipartFile
)
file
);
resultMap
.
put
(
"id"
,
upload
.
getString
(
"docId"
));
resultMap
.
put
(
"status"
,
EiConstant
.
STATUS_SUCCESS
);
resultMap
.
put
(
"message"
,
"SUCCESS"
);
return
resultMap
;
}
catch
(
Exception
e
)
{
resultMap
.
put
(
"status"
,
500
);
resultMap
.
put
(
"message"
,
LogUtils
.
getMsg
(
e
));
return
resultMap
;
}
}
}
src/main/java/com/baosight/hpjx/hp/mt/service/ServiceHPMT002.java
View file @
3660055b
...
@@ -211,10 +211,7 @@ public class ServiceHPMT002 extends ServiceBase {
...
@@ -211,10 +211,7 @@ public class ServiceHPMT002 extends ServiceBase {
String
docId
=
hpzl001A
.
getDocId
();
String
docId
=
hpzl001A
.
getDocId
();
dirId
.
put
(
"docId"
,
docId
);
dirId
.
put
(
"docId"
,
docId
);
List
<
Map
>
query
=
this
.
dao
.
query
(
"HPMT002.queryFile"
,
dirId
);
List
<
Map
>
query
=
this
.
dao
.
query
(
"HPMT002.queryFile"
,
dirId
);
File
file
=
new
File
(
ROOT_PATH
+
"/A/"
+
query
.
get
(
0
).
get
(
"CHG_NAME"
));
imgList
.
add
((
String
)
query
.
get
(
0
).
get
(
"URL"
));
BufferedImage
bf
=
ImageIO
.
read
(
file
);
String
imgBase64
=
UploadUtils
.
imageToBase64
(
bf
);
imgList
.
add
(
imgBase64
);
}
}
//处理的文件
//处理的文件
Map
Map2
=
new
HashMap
();
Map
Map2
=
new
HashMap
();
...
@@ -228,17 +225,12 @@ public class ServiceHPMT002 extends ServiceBase {
...
@@ -228,17 +225,12 @@ public class ServiceHPMT002 extends ServiceBase {
String
docId
=
hpzl001A
.
getDocId
();
String
docId
=
hpzl001A
.
getDocId
();
dirId
.
put
(
"docId"
,
docId
);
dirId
.
put
(
"docId"
,
docId
);
List
<
Map
>
query
=
this
.
dao
.
query
(
"HPMT002.queryFile"
,
dirId
);
List
<
Map
>
query
=
this
.
dao
.
query
(
"HPMT002.queryFile"
,
dirId
);
File
file
=
new
File
(
ROOT_PATH
+
"/A/"
+
query
.
get
(
0
).
get
(
"CHG_NAME"
));
imgList2
.
add
((
String
)
query
.
get
(
0
).
get
(
"URL"
));
BufferedImage
bf
=
ImageIO
.
read
(
file
);
String
imgBase64
=
UploadUtils
.
imageToBase64
(
bf
);
imgList2
.
add
(
imgBase64
);
}
}
Map
sqlMap
=
new
HashMap
();
Map
sqlMap
=
new
HashMap
();
sqlMap
.
put
(
"companyCode"
,
companyCode
);
sqlMap
.
put
(
"companyCode"
,
companyCode
);
sqlMap
.
put
(
"id"
,
id
);
sqlMap
.
put
(
"id"
,
id
);
List
<
Map
>
rows
=
this
.
dao
.
query
(
"HPMT002.pmQualityDetail"
,
sqlMap
);
List
<
Map
>
rows
=
this
.
dao
.
query
(
"HPMT002.pmQualityDetail"
,
sqlMap
);
EiBlock
eiBlock
=
new
EiBlock
(
EiConstant
.
resultBlock
);
eiBlock
.
setRows
(
rows
);
resultMap
.
put
(
"result"
,
rows
);
resultMap
.
put
(
"result"
,
rows
);
resultMap
.
put
(
"img"
,
imgList
);
resultMap
.
put
(
"img"
,
imgList
);
resultMap
.
put
(
"img2"
,
imgList2
);
resultMap
.
put
(
"img2"
,
imgList2
);
...
...
src/main/java/com/baosight/hpjx/hp/mt/sql/HPMT002.xml
View file @
3660055b
...
@@ -231,7 +231,7 @@
...
@@ -231,7 +231,7 @@
<select
id=
"queryFile"
resultClass=
"java.util.HashMap"
>
<select
id=
"queryFile"
resultClass=
"java.util.HashMap"
>
SELECT
CHG_NAME FROM iplat.TEUDM02 where DOC
_ID=#docId#
SELECT
URL FROM iplat.TEUDM05 where RES
_ID=#docId#
</select>
</select>
...
...
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