Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
Aidea
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
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
sa_aidea
Aidea
Commits
54673991
Commit
54673991
authored
Aug 20, 2021
by
马超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(微问诊): 获取图文处方列表、详情、图片接口
parent
2535fc5a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
274 additions
and
40 deletions
+274
-40
CdfortisConstant.java
.../java/com/cftech/cdfortis/constants/CdfortisConstant.java
+3
-0
CdfortisService.java
...ain/java/com/cftech/cdfortis/service/CdfortisService.java
+27
-0
CdfortisServiceImpl.java
...com/cftech/cdfortis/service/impl/CdfortisServiceImpl.java
+134
-37
CdfortisResponseUtil.java
...n/java/com/cftech/cdfortis/util/CdfortisResponseUtil.java
+64
-0
CdfortisController.java
...main/java/com/cftech/cdfortis/web/CdfortisController.java
+43
-3
cdfortis.http
...ules/prescription-module/src/main/test/http/cdfortis.http
+3
-0
No files found.
aidea-modules/prescription-module/src/main/java/com/cftech/cdfortis/constants/CdfortisConstant.java
View file @
54673991
...
...
@@ -17,4 +17,7 @@ public class CdfortisConstant {
public
static
String
RESULT_SUCC_CODE
=
"C00010000"
;
public
static
int
HTTP_SUCC
=
200
;
}
aidea-modules/prescription-module/src/main/java/com/cftech/cdfortis/service/CdfortisService.java
View file @
54673991
...
...
@@ -29,4 +29,31 @@ public interface CdfortisService {
* @return
*/
JSONObject
uploadDrugInfo
(
List
<
PreDrugs
>
preDrugsList
);
/**
* 获取图文处方列表
*
* @param page
* @param rows
* @param startTime
* @param endTime
* @return
*/
JSONObject
getFbusiList
(
int
page
,
int
rows
,
String
startTime
,
String
endTime
);
/**
* 获取图文处方详情
*
* @param presId
* @return
*/
JSONObject
getFbusiDetail
(
String
presId
);
/**
* 获取图文处方图片
*
* @param presId
* @return
*/
JSONObject
getFbusiPicture
(
String
presId
);
}
aidea-modules/prescription-module/src/main/java/com/cftech/cdfortis/service/impl/CdfortisServiceImpl.java
View file @
54673991
...
...
@@ -7,18 +7,21 @@ import com.cftech.cdfortis.model.CdfortisDrugInfo;
import
com.cftech.cdfortis.service.CdfortisService
;
import
com.cftech.cdfortis.util.CdfortisResponseUtil
;
import
com.cftech.cdfortis.util.CdfortisTokenUtil
;
import
com.cftech.core.util.StringUtils
;
import
com.cftech.core.util.SystemConfig
;
import
com.cftech.predrugs.model.PreDrugs
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.*
;
import
org.apache.http.client.methods.RequestBuilder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
*
获取微问诊token
Service
*
微问诊
Service
*
* @author :machao
* @date :Created in 2021/08/19 9:30
...
...
@@ -30,30 +33,35 @@ public class CdfortisServiceImpl implements CdfortisService {
@Autowired
CdfortisTokenUtil
cdfortisTokenUtil
;
private
OkHttpClient
client
;
private
static
final
MediaType
MEDIA_TYPE_JSON
=
MediaType
.
parse
(
"application/json; charset=utf-8"
);
private
static
String
appid
=
SystemConfig
.
p
.
getProperty
(
"cdfortis.appid"
);
/**
* 获取token
*
* @return
*/
@Override
public
JSONObject
getTokenResult
()
{
JSONObject
rtnJson
=
new
JSONObject
();
try
{
String
token
=
cdfortisTokenUtil
.
getToken
();
rtnJson
.
put
(
"errorNo"
,
"0"
);
rtnJson
.
put
(
"
token
"
,
token
);
rtnJson
.
put
(
"
data
"
,
token
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
rtnJson
.
put
(
"errorNo"
,
"1"
);
rtnJson
.
put
(
"errorMsg"
,
e
.
getMessage
());
rtnJson
.
put
(
"errorEnMsg"
,
e
.
getMessage
());
handleException
(
rtnJson
,
e
);
}
return
rtnJson
;
}
/**
* 上传药品清单
*
* @param preDrugsList
* @return
*/
@Override
public
JSONObject
uploadDrugInfo
(
List
<
PreDrugs
>
preDrugsList
)
{
JSONObject
rtnJson
=
new
JSONObject
();
...
...
@@ -67,24 +75,13 @@ public class CdfortisServiceImpl implements CdfortisService {
// 转换药品类型为微问诊需要的结构
List
<
CdfortisDrugInfo
>
cdfortisDrugList
=
preDrugsList
.
stream
().
map
(
this
::
fromPreDrugs
).
collect
(
Collectors
.
toList
());
param
.
put
(
"drugInfo"
,
cdfortisDrugList
);
// 构建请求
OkHttpClient
client
=
getClient
();
RequestBody
body
=
RequestBody
.
create
(
MEDIA_TYPE_JSON
,
param
.
toJSONString
());
Request
request
=
new
Request
.
Builder
().
url
(
uploadUrl
).
post
(
body
).
build
();
Response
response
=
client
.
newCall
(
request
).
execute
();
// 判断http状态值
if
(
200
!=
response
.
code
())
{
rtnJson
.
put
(
"errorNo"
,
"1"
);
rtnJson
.
put
(
"errorMsg"
,
"微问诊请求失败"
);
rtnJson
.
put
(
"errorEnMsg"
,
"request failure"
);
// 获取请求结果
JSONObject
retObj
=
CdfortisResponseUtil
.
getResponseBody
(
request
,
rtnJson
);
if
(
retObj
==
null
)
{
return
rtnJson
;
}
ResponseBody
responseBody
=
response
.
body
();
String
retStr
=
responseBody
.
string
();
log
.
debug
(
"上传接口请求结果: {}"
,
retStr
);
// 解析结果
JSONObject
retObj
=
JSONObject
.
parseObject
(
retStr
);
CdfortisResponseUtil
.
checkResponse
(
retObj
);
JSONObject
data
=
retObj
.
getJSONObject
(
"data"
);
boolean
isAllSuccess
=
data
.
getBooleanValue
(
"isAllSuccess"
);
if
(!
isAllSuccess
)
{
...
...
@@ -98,17 +95,115 @@ public class CdfortisServiceImpl implements CdfortisService {
rtnJson
.
put
(
"errorNo"
,
"0"
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
rtnJson
.
put
(
"errorNo"
,
"1"
);
rtnJson
.
put
(
"errorMsg"
,
e
.
getMessage
());
rtnJson
.
put
(
"errorEnMsg"
,
e
.
getMessage
());
handleException
(
rtnJson
,
e
);
}
return
rtnJson
;
}
/**
* 获取图文处方列表
*
* @param page
* @param rows
* @param startTime
* @param endTime
* @return
*/
@Override
public
JSONObject
getFbusiList
(
int
page
,
int
rows
,
String
startTime
,
String
endTime
)
{
JSONObject
rtnJson
=
new
JSONObject
();
String
getFbusiListUrl
=
SystemConfig
.
p
.
getProperty
(
"cdfortis.get_fbusi_list_url"
);
try
{
// 构建URL参数
HttpUrl
.
Builder
urlBuild
=
HttpUrl
.
parse
(
getFbusiListUrl
).
newBuilder
();
urlBuild
.
addQueryParameter
(
"appid"
,
appid
);
urlBuild
.
addQueryParameter
(
"token"
,
cdfortisTokenUtil
.
getToken
());
urlBuild
.
addQueryParameter
(
"page"
,
page
+
""
);
urlBuild
.
addQueryParameter
(
"rows"
,
rows
+
""
);
urlBuild
.
addQueryParameter
(
"startTime"
,
startTime
);
urlBuild
.
addQueryParameter
(
"endTime"
,
endTime
);
HttpUrl
requestUrl
=
urlBuild
.
build
();
log
.
debug
(
"获取图文处方列表地址: {}"
,
requestUrl
.
toString
());
Request
request
=
new
Request
.
Builder
().
url
(
requestUrl
).
get
().
build
();
// 获取请求结果
JSONObject
retObj
=
CdfortisResponseUtil
.
getResponseBody
(
request
,
rtnJson
);
if
(
retObj
==
null
)
{
return
rtnJson
;
}
rtnJson
.
put
(
"errorNo"
,
"0"
);
rtnJson
.
put
(
"data"
,
retObj
.
getJSONObject
(
"data"
));
}
catch
(
Exception
e
)
{
handleException
(
rtnJson
,
e
);
}
return
rtnJson
;
}
/**
* 获取图文处方详情
*
* @param presId
* @return
*/
@Override
public
JSONObject
getFbusiDetail
(
String
presId
)
{
JSONObject
rtnJson
=
new
JSONObject
();
String
getFbusiInfoUrl
=
SystemConfig
.
p
.
getProperty
(
"cdfortis.get_fbusi_info_url"
);
try
{
HttpUrl
.
Builder
urlBuild
=
HttpUrl
.
parse
(
getFbusiInfoUrl
).
newBuilder
();
urlBuild
.
addQueryParameter
(
"appid"
,
appid
);
urlBuild
.
addQueryParameter
(
"token"
,
cdfortisTokenUtil
.
getToken
());
urlBuild
.
addQueryParameter
(
"presId"
,
presId
);
HttpUrl
requestUrl
=
urlBuild
.
build
();
log
.
debug
(
"获取图文处方详情地址: {}"
,
requestUrl
.
toString
());
Request
request
=
new
Request
.
Builder
().
url
(
requestUrl
).
get
().
build
();
JSONObject
retObj
=
CdfortisResponseUtil
.
getResponseBody
(
request
,
rtnJson
);
if
(
retObj
==
null
)
{
return
rtnJson
;
}
rtnJson
.
put
(
"errorNo"
,
"0"
);
rtnJson
.
put
(
"data"
,
retObj
.
getJSONObject
(
"data"
));
}
catch
(
Exception
e
)
{
handleException
(
rtnJson
,
e
);
}
return
rtnJson
;
}
/**
* 获取图文处方图片
*
* @param presId
* @return
*/
@Override
public
JSONObject
getFbusiPicture
(
String
presId
)
{
JSONObject
rtnJson
=
new
JSONObject
();
String
getFbusiPicUrl
=
SystemConfig
.
p
.
getProperty
(
"cdfortis.get_fbusi_pic_url"
);
try
{
HttpUrl
.
Builder
urlBuild
=
HttpUrl
.
parse
(
getFbusiPicUrl
).
newBuilder
();
urlBuild
.
addQueryParameter
(
"appid"
,
appid
);
urlBuild
.
addQueryParameter
(
"token"
,
cdfortisTokenUtil
.
getToken
());
urlBuild
.
addQueryParameter
(
"presId"
,
presId
);
HttpUrl
requestUrl
=
urlBuild
.
build
();
log
.
debug
(
"获取图文处方图片地址: {}"
,
requestUrl
.
toString
());
Request
request
=
new
Request
.
Builder
().
url
(
requestUrl
).
get
().
build
();
JSONObject
retObj
=
CdfortisResponseUtil
.
getResponseBody
(
request
,
rtnJson
);
if
(
retObj
==
null
)
{
return
rtnJson
;
}
rtnJson
.
put
(
"errorNo"
,
"0"
);
rtnJson
.
put
(
"data"
,
retObj
.
getJSONObject
(
"data"
));
}
catch
(
Exception
e
)
{
handleException
(
rtnJson
,
e
);
}
return
rtnJson
;
}
/**
* 转换药品信息
*
* @return
* @para preDrugs
*/
...
...
@@ -124,16 +219,18 @@ public class CdfortisServiceImpl implements CdfortisService {
}
private
OkHttpClient
getClient
()
{
if
(
client
==
null
)
{
OkHttpClient
.
Builder
builder
=
new
OkHttpClient
.
Builder
();
Dispatcher
dispatcher
=
new
Dispatcher
();
dispatcher
.
setMaxRequests
(
100
);
dispatcher
.
setMaxRequestsPerHost
(
50
);
builder
.
dispatcher
(
dispatcher
);
client
=
builder
.
build
();
}
return
client
;
/**
* 处理异常
*
* @param rtnJson
* @param e
*/
private
void
handleException
(
JSONObject
rtnJson
,
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
rtnJson
.
put
(
"errorNo"
,
"1"
);
rtnJson
.
put
(
"errorMsg"
,
e
.
getMessage
());
rtnJson
.
put
(
"errorEnMsg"
,
e
.
getMessage
());
}
}
aidea-modules/prescription-module/src/main/java/com/cftech/cdfortis/util/CdfortisResponseUtil.java
View file @
54673991
...
...
@@ -2,11 +2,75 @@ package com.cftech.cdfortis.util;
import
com.alibaba.fastjson.JSONObject
;
import
com.cftech.cdfortis.constants.CdfortisConstant
;
import
com.cftech.core.util.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.*
;
import
java.io.IOException
;
@Slf4j
public
class
CdfortisResponseUtil
{
private
static
OkHttpClient
client
;
/**
* 获取请求client
*
* @return
*/
public
static
OkHttpClient
getClient
()
{
if
(
client
==
null
)
{
OkHttpClient
.
Builder
builder
=
new
OkHttpClient
.
Builder
();
Dispatcher
dispatcher
=
new
Dispatcher
();
dispatcher
.
setMaxRequests
(
100
);
dispatcher
.
setMaxRequestsPerHost
(
50
);
builder
.
dispatcher
(
dispatcher
);
client
=
builder
.
build
();
}
return
client
;
}
/**
* 获取请求结果
*
* @param request
* @return
* @throws Exception
*/
public
static
JSONObject
getResponseBody
(
Request
request
,
JSONObject
rtnJson
)
throws
Exception
{
// 构建请求
OkHttpClient
client
=
getClient
();
try
{
Response
response
=
client
.
newCall
(
request
).
execute
();
// 判断http状态值
if
(
CdfortisConstant
.
HTTP_SUCC
!=
response
.
code
())
{
log
.
error
(
response
.
message
());
rtnJson
.
put
(
"errorNo"
,
"1"
);
rtnJson
.
put
(
"errorMsg"
,
"微问诊请求失败"
);
rtnJson
.
put
(
"errorEnMsg"
,
"request failure"
);
return
null
;
}
ResponseBody
responseBody
=
response
.
body
();
String
retStr
=
responseBody
.
string
();
log
.
debug
(
"接口请求结果: {}"
,
retStr
);
// 转换结果
JSONObject
retObj
=
JSONObject
.
parseObject
(
retStr
);
// 插件结果
checkResponse
(
retObj
);
return
retObj
;
}
catch
(
Exception
e
)
{
throw
new
Exception
(
e
.
getMessage
());
}
}
/**
* 检查结果是否失败
*
* @param retObj
* @throws Exception
*/
public
static
void
checkResponse
(
JSONObject
retObj
)
throws
Exception
{
JSONObject
returnCode
=
retObj
.
getJSONObject
(
CdfortisConstant
.
RETURN_CODE
);
if
(!
CdfortisConstant
.
RESULT_SUCC_CODE
.
equals
(
returnCode
.
getString
(
CdfortisConstant
.
RETURN_CODE_KEY
)))
{
...
...
aidea-modules/prescription-module/src/main/java/com/cftech/cdfortis/web/CdfortisController.java
View file @
54673991
...
...
@@ -22,7 +22,7 @@ import java.util.List;
public
class
CdfortisController
{
@Autowired
CdfortisService
token
Service
;
CdfortisService
cdfortis
Service
;
/**
* 获取微问诊token
...
...
@@ -31,7 +31,7 @@ public class CdfortisController {
*/
@GetMapping
(
"/get/token"
)
public
JSONObject
getToken
()
{
return
token
Service
.
getTokenResult
();
return
cdfortis
Service
.
getTokenResult
();
}
...
...
@@ -43,7 +43,47 @@ public class CdfortisController {
*/
@PostMapping
(
"/upload/druginfo"
)
public
JSONObject
uploadDrugInfo
(
@RequestBody
List
<
PreDrugs
>
preDrugsList
)
{
return
token
Service
.
uploadDrugInfo
(
preDrugsList
);
return
cdfortis
Service
.
uploadDrugInfo
(
preDrugsList
);
}
/**
* 微问诊图文处方列表
*
* @param iDisplayStart 查询的页数
* @param iDisplayLength 一次查询几条(最大50)
* @param startTime 开始时间
* @param endTime 结束时间
* @return
*/
@GetMapping
(
"/get/fbusi/list"
)
public
JSONObject
getFbusiList
(
int
iDisplayStart
,
int
iDisplayLength
,
@RequestParam
String
startTime
,
@RequestParam
String
endTime
)
{
return
cdfortisService
.
getFbusiList
(
iDisplayStart
,
iDisplayLength
,
startTime
,
endTime
);
}
/**
* 获取图文处方详情
*
* @param presId 处方编号
* @return
*/
@GetMapping
(
"/get/fbusi/detail"
)
public
JSONObject
getFbusiDetail
(
@RequestParam
String
presId
)
{
return
cdfortisService
.
getFbusiDetail
(
presId
);
}
/**
* 获取图文处方图片
*
* @param presId 处方编号
* @return
*/
@GetMapping
(
"/get/fbusi/picture"
)
public
JSONObject
getFbusiPicture
(
@RequestParam
String
presId
)
{
return
cdfortisService
.
getFbusiPicture
(
presId
);
}
}
aidea-modules/prescription-module/src/main/test/http/cdfortis.http
View file @
54673991
...
...
@@ -14,3 +14,6 @@ Content-Type: application/json
}]
###
GET http://localhost:8080/aidea/mobile/auth/cdfortis/get/fbusi/list?iDisplayStart=1&iDisplayLength=10&startTime=2020-09-07 00:00:00&endTime=2020-09-14 23:59:59
###
\ No newline at end of file
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