Commit 73b231dc authored by 马超's avatar 马超

feat(微问诊): 新增通过订单号获取处方单详情接口

parent 4874b274
......@@ -31,6 +31,7 @@ public class FbusiDetail implements Serializable {
private String presUrl;
private List<FbusiDrug> drugs;
private List<FbusiDrug> drugList;
}
......@@ -43,6 +43,16 @@ public interface CdfortisService {
*/
FbusiDetail getFbusiDetail(String presId) throws Exception;
/**
* 通过订单号图文处方详情
*
* @param orderId
* @return
* @throws Exception
*/
FbusiDetail getFbusiDetailByOrderId(String orderId) throws Exception;
/**
* 获取图文处方图片
*
......
......@@ -102,7 +102,6 @@ public class CdfortisServiceImpl implements CdfortisService {
return new ArrayList<>();
}
String datalistStr = dataObject.getString("list");
//TODO 结果映射
return JSONArray.parseArray(datalistStr, Prescription.class);
}
......@@ -124,6 +123,26 @@ public class CdfortisServiceImpl implements CdfortisService {
// 请求获取数据
String data = CdfortisResponseUtil.request(getFbusiInfoUrl, CdfortisConstant.METHOD_GET, urlParam,
null, null);
if (StringUtils.isEmpty(data)) {
return null;
}
return JSONObject.parseObject(data, FbusiDetail.class);
}
@Override
public FbusiDetail getFbusiDetailByOrderId(String orderId) throws Exception {
String getFbusiInfoByOrderIdUrl = SystemConfig.p.getProperty("cdfortis.get_fbusi_info_by_order_id_url");
// 构建URL参数
Map<String, String> urlParam = new HashMap<>(3);
urlParam.put("appid", appid);
urlParam.put("token", cdfortisTokenUtil.getToken());
urlParam.put("orderId", orderId);
// 请求获取数据
String data = CdfortisResponseUtil.request(getFbusiInfoByOrderIdUrl, CdfortisConstant.METHOD_GET, urlParam,
null, null);
if (StringUtils.isEmpty(data)) {
return null;
}
return JSONObject.parseObject(data, FbusiDetail.class);
}
......
......@@ -87,9 +87,8 @@ public class CdfortisResponseUtil {
log.debug("request result: {}", retStr);
// 转换结果
JSONObject retObj = JSONObject.parseObject(retStr);
// 列表接口没有数据的特殊处理(理论上没有数据应该是一个空数组,但是微问诊返回结果是错误)
if (SystemConfig.p.getProperty("cdfortis.get_fbusi_list_url").equals(url)
&& CdfortisConstant.RESULT_NO_DATA_CODE.equals(retObj.getJSONObject(CdfortisConstant.RETURN_CODE).getString(CdfortisConstant.RETURN_CODE_KEY))) {
// 接口没有数据的特殊处理(理论上没有数据应该是一个空数组,但是微问诊返回结果是错误)
if (CdfortisConstant.RESULT_NO_DATA_CODE.equals(retObj.getJSONObject(CdfortisConstant.RETURN_CODE).getString(CdfortisConstant.RETURN_CODE_KEY))) {
return "";
}
// 检查结果
......
......@@ -102,7 +102,7 @@ public class CdfortisController {
/**
* 获取图文处方详情
* 获取Prescritpion Id获取图文处方详情
*
* @param presId 处方编号
* @return
......@@ -111,7 +111,7 @@ public class CdfortisController {
public JSONObject getFbusiDetail(@RequestParam String presId) {
JSONObject rtnJson = new JSONObject();
try {
Prescription preScription = prescriptionService.findPreScription(presId);
Prescription preScription = prescriptionService.findPreScriptionById(presId);
setSuccResult(rtnJson, preScription);
} catch (Exception e) {
handleException(rtnJson, e);
......@@ -120,6 +120,25 @@ public class CdfortisController {
}
/**
* 通过orderId获取图文处方详情
*
* @param orderId 处方编号
* @return
*/
@GetMapping("/get/fbusi/info")
public JSONObject getFbusiDetailByOrderId(@RequestParam String orderId) {
JSONObject rtnJson = new JSONObject();
try {
Prescription prescription = prescriptionService.findPreScriptionByOrderId(orderId);
setSuccResult(rtnJson, prescription);
} catch (Exception e) {
handleException(rtnJson, e);
}
return rtnJson;
}
/**
* 获取图文处方图片
*
......
......@@ -40,7 +40,8 @@ public interface PrescriptionService extends GenericService<Prescription> {
* @param presId
* @return
*/
Prescription findPreScription(String presId) throws Exception;
Prescription findPreScriptionById(String presId) throws Exception;
Prescription findPreScriptionByOrderId(String orderId) throws Exception;
}
......@@ -14,6 +14,7 @@ import com.cftech.prescription.service.PrescriptionService;
import com.cftech.core.generic.GenericDao;
import com.cftech.core.generic.GenericServiceImpl;
import com.cftech.core.sql.Conds;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
......@@ -107,15 +108,50 @@ public class PrescriptionServiceImpl extends GenericServiceImpl<Prescription> im
return onLineList;
}
/**
* 通过Id 获取详情
*
* @param presId
* @return
* @throws Exception
*/
@Override
public Prescription findPreScription(String presId) throws Exception {
public Prescription findPreScriptionById(String presId) throws Exception {
Prescription prescription = fetchById(presId);
if (prescription != null && !StringUtils.isEmpty(prescription.getSymptom())) {
return prescription;
}
FbusiDetail fbusiDetail = cdfortisService.getFbusiDetail(presId);
prescription = handlePrescription(prescription, fbusiDetail);
return prescription;
}
/**
* 通过number/orderId获取详情
*
* @param orderId
* @return
* @throws Exception
*/
@Override
public Prescription findPreScriptionByOrderId(String orderId) throws Exception {
Conds conds = new Conds();
conds.equal("number", orderId);
Prescription prescription = fetchSearchByConds(conds);
if (prescription != null && !StringUtils.isEmpty(prescription.getSymptom())) {
return prescription;
}
FbusiDetail fbusiDetail = cdfortisService.getFbusiDetailByOrderId(orderId);
prescription = handlePrescription(prescription, fbusiDetail);
return prescription;
}
@NotNull
private Prescription handlePrescription(Prescription prescription, FbusiDetail fbusiDetail) throws Exception {
if (fbusiDetail == null) {
throw new Exception("找不到对应的处方数据");
throw new Exception("找不到对应的处方数据(暂无数据)");
}
if (prescription == null) {
// save数据
......@@ -140,6 +176,11 @@ public class PrescriptionServiceImpl extends GenericServiceImpl<Prescription> im
private void handleFrug(FbusiDetail fbusiDetail, Prescription prescription) {
List<FbusiDrug> drugs = fbusiDetail.getDrugs();
List<PreDrugs> preDrugsList = new ArrayList<>();
// 如果drugs字段为空,则获取drugList字段值
if (CollectionUtils.isEmpty(drugs)) {
drugs = fbusiDetail.getDrugList();
}
// 如果drugList也为空,则直接返回
if (CollectionUtils.isEmpty(drugs)) {
return;
}
......@@ -150,7 +191,9 @@ public class PrescriptionServiceImpl extends GenericServiceImpl<Prescription> im
Sort sort = new Sort("create_time", OrderType.DESC);
preDrugsList = preDrugsService.fetchSearchByPage(drugConds, sort, 0, count);
}
// 将集合数据转换成Map数据
Map<String, PreDrugs> preDrugMap = preDrugsList.stream().collect(Collectors.toMap(PreDrugs::getDrugId, preDrugs -> preDrugs));
// 遍历处方药品信息,做保存或更新操作
for (FbusiDrug fbusiDrug : drugs) {
PreDrugs preDrug = new PreDrugs();
if (preDrugMap.containsKey(fbusiDrug.getDrugId())) {
......
......@@ -5,14 +5,16 @@ GET http://localhost:8080/aidea/mobile/auth/cdfortis/get/token
POST http://localhost:8080/aidea/mobile/auth/cdfortis/upload/druginfo
Content-Type: application/json
[{
"approveNumber": "国药准字Z10910006",
"format": "10g/袋",
"price": "39.80",
"productNumber": "PD202011040006",
"productName": "番泻叶颗粒",
"manufacturer": "江苏艾迪药业股份有限公司"
}]
[
{
"approveNumber": "国药准字Z10910006",
"format": "10g/袋",
"price": "39.80",
"productNumber": "PD202011040006",
"productName": "番泻叶颗粒",
"manufacturer": "江苏艾迪药业股份有限公司"
}
]
### 获取图文处方列表接口
GET http://localhost:8080/aidea/mobile/auth/cdfortis/get/fbusi/list?iDisplayStart=0&iDisplayLength=10&startTime=2021-08-03 00:00:00&endTime=2021-08-03 20:59:59
......@@ -24,4 +26,7 @@ GET http://localhost:8080/aidea/mobile/auth/cdfortis/get/fbusi/picture?presId=11
### 获取单条图文处方详情
GET http://localhost:8080/aidea/mobile/auth/cdfortis/get/fbusi/detail?presId=11264635
### 通过orderId获取图文处方详情
GET http://localhost:8080/aidea/mobile/auth/cdfortis/get/fbusi/info?orderId=PRE202108250001
###
\ No newline at end of file
......@@ -161,4 +161,6 @@ cdfortis.get_fbusi_list_url=https://api.cdfortis.com/api/fbusi/getFbusiList
#\u5fae\u95ee\u8bca\u83b7\u53d6\u56fe\u6587\u5904\u65b9\u56fe\u7247\u63a5\u53e3
cdfortis.get_fbusi_pic_url=https://api.cdfortis.com/api/fbusi/getFbusiPicture
#\u5fae\u95ee\u8bca\u83b7\u53d6\u5355\u6761\u56fe\u6587\u5904\u65b9\u8be6\u60c5\u63a5\u53e3
cdfortis.get_fbusi_info_url=https://api.cdfortis.com/api/fbusi/getFbusiInfo
\ No newline at end of file
cdfortis.get_fbusi_info_url=https://api.cdfortis.com/api/fbusi/getFbusiInfo
#\u5fae\u95ee\u8bca\u901a\u8fc7\u8ba2\u5355\u53f7\u56fe\u6587\u5904\u65b9\u8be6\u60c5
cdfortis.get_fbusi_info_by_order_id_url=https://api.cdfortis.com/api/fbusi/getFbusiInfoByOrderId
\ No newline at end of file
......@@ -160,4 +160,6 @@ cdfortis.get_fbusi_list_url=https://api.cdfortis.com/api/fbusi/getFbusiList
#\u5fae\u95ee\u8bca\u83b7\u53d6\u56fe\u6587\u5904\u65b9\u56fe\u7247\u63a5\u53e3
cdfortis.get_fbusi_pic_url=https://api.cdfortis.com/api/fbusi/getFbusiPicture
#\u5fae\u95ee\u8bca\u83b7\u53d6\u5355\u6761\u56fe\u6587\u5904\u65b9\u8be6\u60c5\u63a5\u53e3
cdfortis.get_fbusi_info_url=https://api.cdfortis.com/api/fbusi/getFbusiInfo
\ No newline at end of file
cdfortis.get_fbusi_info_url=https://api.cdfortis.com/api/fbusi/getFbusiInfo
#\u5fae\u95ee\u8bca\u901a\u8fc7\u8ba2\u5355\u53f7\u56fe\u6587\u5904\u65b9\u8be6\u60c5
cdfortis.get_fbusi_info_by_order_id_url=https://api.cdfortis.com/api/fbusi/getFbusiInfoByOrderId
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment