Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gs1-office-web-sit
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
吴迪
gs1-office-web-sit
Commits
ccb6cf8f
Commit
ccb6cf8f
authored
Dec 06, 2021
by
吴迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【新增】GLN、GTIN接口修改
parent
1d157555
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
8 deletions
+97
-8
GLNController.java
...va/io/office/modules/manage/controller/GLNController.java
+21
-4
UeditorController.java
...va/io/office/modules/manage/entity/UeditorController.java
+2
-0
GLNSearchUtils.java
...n/java/io/office/modules/manage/utils/GLNSearchUtils.java
+44
-0
WebServiceXmlTemplate.java
...fice/modules/manage/webservice/WebServiceXmlTemplate.java
+30
-4
No files found.
src/main/java/io/office/modules/manage/controller/GLNController.java
View file @
ccb6cf8f
...
...
@@ -43,24 +43,41 @@ public class GLNController {
@Login
@PostMapping
(
"/api/gln"
)
public
R
uploadFile
(
@RequestBody
GLNRequestBo
glnRequestBo
,
HttpServletRequest
request
)
{
boolean
captcha
=
sysCaptchaService
.
validate
(
glnRequestBo
.
getUuid
(),
glnRequestBo
.
getCaptcha
());
/*
boolean captcha = sysCaptchaService.validate(glnRequestBo.getUuid(), glnRequestBo.getCaptcha());
if(!captcha){
return R.error("验证码不正确");
}
}
*/
SearchgtinlogEntity
searchgtinlogEntity
=
new
SearchgtinlogEntity
();
searchgtinlogEntity
.
setCreatedate
(
new
Date
());
searchgtinlogEntity
.
setIp
(
IPUtils
.
getIpAddr
(
request
));
if
(
glnRequestBo
.
getType
().
equals
(
"GLN"
))
{
if
(
glnRequestBo
.
getCode
().
length
()!=
13
)
{
return
R
.
error
(
"请输入13位GLN!"
);
}
// glnRequestBo.setCode("0"+glnRequestBo.getCode());
searchgtinlogEntity
.
setKeyword
(
glnRequestBo
.
getCode
());
searchgtinlogEntity
.
setClassStr
(
"GLN查询"
);
}
else
if
(
glnRequestBo
.
getType
().
equals
(
"GTIN"
)){
if
(
glnRequestBo
.
getCode
().
length
()<
12
)
{
return
R
.
error
(
"GTIN不能少于12位!"
);
}
if
(
glnRequestBo
.
getCode
().
length
()==
12
)
{
glnRequestBo
.
setCode
(
"00"
+
glnRequestBo
.
getCode
());
}
if
(
glnRequestBo
.
getCode
().
length
()==
13
)
{
glnRequestBo
.
setCode
(
"0"
+
glnRequestBo
.
getCode
());
}
searchgtinlogEntity
.
setClassStr
(
"境外条码查询:厂商信息查询"
);
}
searchgtinlogEntity
.
setKeyword
(
glnRequestBo
.
getCode
());
searchgtinlogEntity
.
setSearchsource
(
0
);
//新增查询日志
searchgtinlogService
.
save
(
searchgtinlogEntity
);
return
R
.
ok
().
put
(
"data"
,
GLNSearchUtils
.
getGLNResult
(
"9"
,
"GLN"
,
glnRequestBo
.
getCode
(),
glnRequestBo
.
getRequestedLanguage
()));
if
(
glnRequestBo
.
getType
().
equals
(
"GLN"
))
{
return
R
.
ok
().
put
(
"data"
,
GLNSearchUtils
.
getGLNResult
(
"9"
,
glnRequestBo
.
getType
(),
glnRequestBo
.
getCode
(),
glnRequestBo
.
getRequestedLanguage
()));
}
else
{
return
R
.
ok
().
put
(
"data"
,
GLNSearchUtils
.
getGTINResult
(
"9"
,
glnRequestBo
.
getType
(),
glnRequestBo
.
getCode
(),
glnRequestBo
.
getRequestedLanguage
()));
}
}
...
...
src/main/java/io/office/modules/manage/entity/UeditorController.java
View file @
ccb6cf8f
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONException;
import
io.office.modules.app.annotation.Login
;
import
io.office.modules.ueditor.com.baidu.ueditor.ActionEnter
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -25,6 +26,7 @@ public class UeditorController {
@Value
(
"${ueditorSavePath}"
)
private
String
ueditorSavePath
;
@CrossOrigin
@Login
@RequestMapping
(
"/ueditorConfig"
)
public
void
getUEditorConfig
(
HttpServletResponse
response
,
HttpServletRequest
request
){
...
...
src/main/java/io/office/modules/manage/utils/GLNSearchUtils.java
View file @
ccb6cf8f
...
...
@@ -37,7 +37,50 @@ public class GLNSearchUtils {
HttpEntity
<
String
>
entity
=
new
HttpEntity
<>(
smsTemplateXml
,
headers
);
System
.
out
.
println
(
smsTemplateXml
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
postForEntity
(
url
,
entity
,
String
.
class
);
if
(
responseEntity
.
getStatusCode
().
value
()
==
200
)
{
System
.
out
.
println
(
responseEntity
.
getBody
());
// 下面的是通过解析xml字符串的
String
returnObjs
=
responseEntity
.
getBody
().
substring
(
responseEntity
.
getBody
().
indexOf
(
"<partyDataLine>"
),
responseEntity
.
getBody
().
indexOf
(
"</gepirParty>"
)).
replaceAll
(
"<partyName />"
,
""
);
//注意 获取根节点的时候要查看返回的xml参数的形式是否为一个根节点
System
.
out
.
println
(
returnObjs
);
PartyDataLine
xmlObject
=
null
;
Reader
reader
=
null
;
//利用JAXBContext将类转为一个实例
try
{
JAXBContext
context
=
JAXBContext
.
newInstance
(
PartyDataLine
.
class
);
//XMl 转为对象的接口
Unmarshaller
unmarshaller
=
context
.
createUnmarshaller
();
reader
=
new
StringReader
(
returnObjs
);
xmlObject
=
(
PartyDataLine
)
unmarshaller
.
unmarshal
(
reader
);
if
(
reader
!=
null
)
{
reader
.
close
();
}
}
catch
(
JAXBException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
xmlObject
;
}
return
null
;
}
public
static
PartyDataLine
getGTINResult
(
String
cascade
,
String
requestedKeyCode
,
String
requestedKeyValue
,
String
requestedLanguage
)
{
String
smsTemplateXml
=
WebServiceXmlTemplate
.
SEND_MESSAGE_GTIN_TEMPLATE
.
replaceAll
(
"\\$\\{cascade\\}"
,
cascade
).
replaceAll
(
"\\$\\{requestedKeyCode\\}"
,
requestedKeyCode
)
.
replaceAll
(
"\\$\\{requestedKeyValue\\}"
,
requestedKeyValue
).
replaceAll
(
"\\$\\{requestedLanguage\\}"
,
requestedLanguage
);
String
url
=
"http://webservice.anccnet.com:8080/gepir4/gepirv4.asmx"
;
RestTemplate
restTemplate
=
new
RestTemplate
();
//创建请求头
//创建请求头
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"Content-Type"
,
"text/xml; charset=utf-8"
);
HttpEntity
<
String
>
entity
=
new
HttpEntity
<>(
smsTemplateXml
,
headers
);
System
.
out
.
println
(
smsTemplateXml
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
postForEntity
(
url
,
entity
,
String
.
class
);
if
(
responseEntity
.
getStatusCode
().
value
()
==
200
)
{
System
.
out
.
println
(
responseEntity
.
getBody
());
// 下面的是通过解析xml字符串的
String
returnObjs
=
responseEntity
.
getBody
().
substring
(
responseEntity
.
getBody
().
indexOf
(
"<partyDataLine>"
),
responseEntity
.
getBody
().
indexOf
(
"</gepirParty>"
)).
replaceAll
(
"<partyName />"
,
""
);
//注意 获取根节点的时候要查看返回的xml参数的形式是否为一个根节点
System
.
out
.
println
(
returnObjs
);
...
...
@@ -64,4 +107,5 @@ public class GLNSearchUtils {
}
}
src/main/java/io/office/modules/manage/webservice/WebServiceXmlTemplate.java
View file @
ccb6cf8f
...
...
@@ -20,15 +20,41 @@ public class WebServiceXmlTemplate {
" </requestHeader>\n"
+
" </soap:Header>\n"
+
" <soap:Body>\n"
+
" <get
Prefix
Licensee xmlns=\"http://gepir4.ws.gs1.org/\">\n"
+
" <get
Prefix
Licensee xmlns=\"\">\n"
+
" <get
Prefix
Licensee>\n"
+
" <get
Key
Licensee xmlns=\"http://gepir4.ws.gs1.org/\">\n"
+
" <get
Key
Licensee xmlns=\"\">\n"
+
" <get
Key
Licensee>\n"
+
" <requestedKeyCode>${requestedKeyCode}</requestedKeyCode>\n"
+
" <requestedKeyValue>${requestedKeyValue}</requestedKeyValue>\n"
+
" <requestedLanguage>${requestedLanguage}</requestedLanguage>\n"
+
" </getPrefixLicensee>\n"
+
" </getKeyLicensee>\n"
+
" </getKeyLicensee>\n"
+
" </getKeyLicensee>\n"
+
" </soap:Body>\n"
+
"</soap:Envelope>"
;
public
static
String
SEND_MESSAGE_GTIN_TEMPLATE
=
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
+
" <soap:Header>\n"
+
" <requestHeader xmlns=\"http://gepir4.ws.gs1.org/\">\n"
+
" <requesterGLN xmlns=\"\">6900000000007</requesterGLN>\n"
+
" <onBehalfOfGLN xmlns=\"\">6900000000007</onBehalfOfGLN>\n"
+
" <isAuthenticated xmlns=\"\">true</isAuthenticated>\n"
+
" <cascade xmlns=\"\">${cascade}</cascade>\n"
+
" </requestHeader>\n"
+
" </soap:Header>\n"
+
" <soap:Body>\n"
+
" <getPrefixLicensee xmlns=\"http://gepir4.ws.gs1.org/\">\n"
+
" <getPrefixLicensee xmlns=\"\">\n"
+
"<getPrefixLicensee> \n"
+
" <requestedKeyCode>${requestedKeyCode}</requestedKeyCode>\n"
+
" <requestedKeyValue>${requestedKeyValue}</requestedKeyValue>\n"
+
" </getPrefixLicensee>\n"
+
" </getPrefixLicensee>\n"
+
" </getPrefixLicensee>\n"
+
" </soap:Body>\n"
+
"</soap:Envelope>"
;
}
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