Commit 083058b2 authored by 马超's avatar 马超

feat(微问诊): 上传成功后更新药品上传状态

parent 73b231dc
......@@ -129,6 +129,13 @@ public class CdfortisServiceImpl implements CdfortisService {
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");
......
......@@ -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);
......
......@@ -7,12 +7,22 @@ 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": "江苏艾迪药业股份有限公司"
}
]
......
......@@ -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
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