Commit b3368cc1 authored by 马超's avatar 马超

Merge branch 'develop-mc' into 'master'

Develop mc

See merge request !4
parents ad3b61bc 083058b2
......@@ -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,33 @@ 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);
}
/**
* 通过订单号获取图文详情
*
* @param orderId
* @return
* @throws Exception
*/
@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 "";
}
// 检查结果
......
......@@ -8,11 +8,15 @@ import com.cftech.cdfortis.util.CdfortisTokenUtil;
import com.cftech.prescription.model.Prescription;
import com.cftech.prescription.service.PrescriptionService;
import com.cftech.product.model.Product;
import com.cftech.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 微问诊相关接口调用Controller
......@@ -35,6 +39,9 @@ public class CdfortisController {
@Autowired
PrescriptionService prescriptionService;
@Autowired
ProductService productService;
/**
* 获取微问诊token
*
......@@ -69,6 +76,17 @@ public class CdfortisController {
Object data = "";
if (!isAllSuccess) {
JSONArray failedDataArr = dataJsonObj.getJSONArray("failedData");
// List转map,key是productNumber、value是product本身
List<String> productNumberList = productList.stream()
.map(Product::getProductNumber)
.collect(Collectors.toList());
// 遍历上传失败的数据,排除掉
for (int i = 0; i < failedDataArr.size(); i++) {
String erpId = failedDataArr.getJSONObject(i).getString("erpId");
productNumberList.remove(erpId);
}
productService.updateUploadFlag(productNumberList, true);
data = failedDataArr;
}
setSuccResult(rtnJson, data);
......@@ -102,7 +120,7 @@ public class CdfortisController {
/**
* 获取图文处方详情
* 获取Prescritpion Id获取图文处方详情
*
* @param presId 处方编号
* @return
......@@ -111,7 +129,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 +138,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;
......@@ -50,7 +51,7 @@ public class PrescriptionServiceImpl extends GenericServiceImpl<Prescription> im
@Override
public List<Prescription> findPreScriptionList(int iDisplayStart, int iDisplayLength) throws Exception {
return findPreScriptionList(iDisplayStart, iDisplayLength);
return findPreScriptionList(iDisplayStart, iDisplayLength, null, null);
}
@Override
......@@ -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,26 @@ GET http://localhost:8080/aidea/mobile/auth/cdfortis/get/token
POST http://localhost:8080/aidea/mobile/auth/cdfortis/upload/druginfo
Content-Type: application/json
[{
[
{
"id": "22",
"approveNumber": "国药准字Z10910006",
"format": "10g/袋",
"price": "39.80",
"productNumber": "PD202011040006",
"productName": "番泻叶颗粒",
"manufacturer": "江苏艾迪药业股份有限公司"
}]
},
{
"id": "24",
"approveNumber": "国药准字XXXX",
"format": "75mg/片",
"price": "1.00",
"productNumber": "6901028193498",
"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 +36,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
......@@ -30,4 +30,10 @@ public interface ProductMapper extends GenericDao<Product> {
* @return
*/
List<Product> selectProduct(Map<String,Object> params);
/**
*
* @param productNumberList
*/
void updateUploadFlag(@Param("productNumberList") List<String> productNumberList,@Param("uploadFlag") int uploadFlag);
}
\ No newline at end of file
......@@ -36,6 +36,7 @@
<result column="unit" property="unit"/>
<result column="invoice_code" property="invoiceCode"/>
<result column="deviation" property="deviation"/>
<result column="upload_flag" property="uploadFlag"/>
</resultMap>
<sql id="sqlWhere">
......@@ -98,7 +99,8 @@
isreading,
unit,
invoice_code,
deviation
deviation,
upload_flag
</sql>
<sql id="productList">
......@@ -127,7 +129,8 @@
t.reading,
t.isreading,
t.invoice_code invoiceCode,
t.deviation
t.deviation,
t.upload_flag AS uploadFlag
</sql>
<insert id="save" parameterType="com.cftech.product.model.Product" useGeneratedKeys="true"
......@@ -171,6 +174,7 @@
#{unit,jdbcType=VARCHAR},
#{invoiceCode,jdbcType=VARCHAR},
#{deviation, jdbcType=BIGINT}
#{uploadFlag, jdbcType=TINYINT}
)
</insert>
......@@ -220,7 +224,8 @@
a.is_rs isRs,
a.reading reading,
a.invoice_code,
a.deviation
a.deviation,
a.upload_flag uploadFlag
FROM
t_aidea_product a
LEFT JOIN t_aidea_product_classify b ON a.classify_id = b.id
......@@ -260,7 +265,8 @@
a.product_number productNumber,
a.is_rs isRs,
a.reading reading,
a.invoice_code
a.invoice_code,
a.upload_flag uploadFlag
FROM
t_aidea_product a
LEFT JOIN t_aidea_product_classify b ON FIND_IN_SET(b.id,a.classify_id)
......@@ -376,6 +382,9 @@
<if test="deviation != null">
deviation = #{deviation, jdbcType=BIGINT}
</if>
<if test="uploadFlag != null">
upload_flag = #{uploadFlag, jdbcType=TINYINT}
</if>
</set>
where id=#{id,jdbcType=BIGINT}
</update>
......@@ -383,6 +392,14 @@
<update id="delete" parameterType="java.lang.Long">
update t_aidea_product set del_flag=1 where id=#{id,jdbcType=BIGINT}
</update>
<update id="updateUploadFlag">
update t_aidea_product set upload_flag=#{uploadFlag} where product_number IN
<foreach item="item" index="index" collection="productNumberList" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<!-- 根据ID查询商品详情!-->
<select id="product" resultType="com.cftech.product.model.ProductVO">
select
......
......@@ -164,6 +164,8 @@ public class Product implements Serializable {
private Long updateBy;
/* 偏移量 */
private Long deviation;
/* 上传标识 */
private boolean uploadFlag;
public Product() {
this.delFlag = false;
......
......@@ -43,4 +43,12 @@ public interface ProductService extends GenericService<Product> {
* @return
*/
List<Product> selectProduct(Conds conds, Sort sort,int pageSize,int pageNo,List<String> classifyId);
/**
* 更新上传标识
*
* @param productNumberList
* @param uploadFlag
*/
void updateUploadFlag(List<String> productNumberList, boolean uploadFlag);
}
......@@ -200,5 +200,10 @@ public class ProductServiceImpl extends GenericServiceImpl<Product> implements P
return productMapper.selectProduct(params);
}
@Override
public void updateUploadFlag(List<String> productNumberList, boolean uploadFlag) {
productMapper.updateUploadFlag(productNumberList, uploadFlag ? 1 : 0);
}
}
\ No newline at end of file
......@@ -162,3 +162,5 @@ cdfortis.get_fbusi_list_url=https://api.cdfortis.com/api/fbusi/getFbusiList
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
#\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
......@@ -161,3 +161,5 @@ cdfortis.get_fbusi_list_url=https://api.cdfortis.com/api/fbusi/getFbusiList
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
#\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