Commit c0793357 authored by 马超's avatar 马超

feat(微问诊): 修改获取列表数据接口、修改获取药品详情的接口

parent e65f1e0c
...@@ -9,7 +9,7 @@ public class FbusiDrug implements Serializable { ...@@ -9,7 +9,7 @@ public class FbusiDrug implements Serializable {
private String drugId; private String drugId;
private String drugName; private String drugName;
private String drugCompany; private String drugCompany;
private String drugNum; private Long drugNum;
private String apprNumber; private String apprNumber;
private String spec; private String spec;
private String dosage; private String dosage;
......
...@@ -111,8 +111,8 @@ public class CdfortisController { ...@@ -111,8 +111,8 @@ public class CdfortisController {
public JSONObject getFbusiDetail(@RequestParam String presId) { public JSONObject getFbusiDetail(@RequestParam String presId) {
JSONObject rtnJson = new JSONObject(); JSONObject rtnJson = new JSONObject();
try { try {
FbusiDetail fbusiDetail = cdfortisService.getFbusiDetail(presId); Prescription preScription = prescriptionService.findPreScription(presId);
setSuccResult(rtnJson, fbusiDetail); setSuccResult(rtnJson, preScription);
} catch (Exception e) { } catch (Exception e) {
handleException(rtnJson, e); handleException(rtnJson, e);
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<result column="spec" property="spec"/> <result column="spec" property="spec"/>
<result column="appr_number" property="apprNumber"/> <result column="appr_number" property="apprNumber"/>
<result column="drug_num" property="drugNum"/> <result column="drug_num" property="drugNum"/>
<result column="drug_compay" property="drugCompay"/> <result column="drug_compay" property="drugCompany"/>
<result column="name" property="name"/> <result column="name" property="name"/>
<result column="drug_id" property="drugId"/> <result column="drug_id" property="drugId"/>
<result column="parent_id" property="parentId"/> <result column="parent_id" property="parentId"/>
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
spec, spec,
appr_number, appr_number,
drug_num, drug_num,
drug_compay, drug_company,
name, name,
drug_id, drug_id,
parent_id, parent_id,
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
#{spec, jdbcType=VARCHAR}, #{spec, jdbcType=VARCHAR},
#{apprNumber, jdbcType=VARCHAR}, #{apprNumber, jdbcType=VARCHAR},
#{drugNum, jdbcType=BIGINT}, #{drugNum, jdbcType=BIGINT},
#{drugCompay, jdbcType=VARCHAR}, #{drugCompany, jdbcType=VARCHAR},
#{name, jdbcType=VARCHAR}, #{name, jdbcType=VARCHAR},
#{drugId, jdbcType=VARCHAR}, #{drugId, jdbcType=VARCHAR},
#{parentId, jdbcType=BIGINT}, #{parentId, jdbcType=BIGINT},
...@@ -159,8 +159,8 @@ ...@@ -159,8 +159,8 @@
<if test="drugNum != null"> <if test="drugNum != null">
drug_num = #{drugNum, jdbcType=BIGINT}, drug_num = #{drugNum, jdbcType=BIGINT},
</if> </if>
<if test="drugCompay != null"> <if test="drugCompany != null">
drug_compay = #{drugCompay, jdbcType=VARCHAR}, drug_company = #{drugCompany, jdbcType=VARCHAR},
</if> </if>
<if test="name != null"> <if test="name != null">
name = #{name, jdbcType=VARCHAR}, name = #{name, jdbcType=VARCHAR},
......
...@@ -43,7 +43,7 @@ public class PreDrugs implements Serializable { ...@@ -43,7 +43,7 @@ public class PreDrugs implements Serializable {
private String price; private String price;
/* 药品生产厂家 */ /* 药品生产厂家 */
@ExportConfig(value = "药品生产厂家", width = 100, showLevel = 1) @ExportConfig(value = "药品生产厂家", width = 100, showLevel = 1)
private String drugCompay; private String drugCompany;
/* 药品名称 */ /* 药品名称 */
@ExportConfig(value = "药品名称", width = 100, showLevel = 1) @ExportConfig(value = "药品名称", width = 100, showLevel = 1)
private String name; private String name;
......
...@@ -35,5 +35,12 @@ public interface PrescriptionService extends GenericService<Prescription> { ...@@ -35,5 +35,12 @@ public interface PrescriptionService extends GenericService<Prescription> {
*/ */
List<Prescription> findPreScriptionList(int iDisplayStart, int iDisplayLength, String startTime, String endTime) throws Exception; List<Prescription> findPreScriptionList(int iDisplayStart, int iDisplayLength, String startTime, String endTime) throws Exception;
/**
* 获取Prescription详情
* @param presId
* @return
*/
Prescription findPreScription(String presId) throws Exception;
} }
package com.cftech.prescription.service.impl; package com.cftech.prescription.service.impl;
import com.cftech.cdfortis.model.FbusiDetail;
import com.cftech.cdfortis.model.FbusiDrug;
import com.cftech.cdfortis.service.CdfortisService; import com.cftech.cdfortis.service.CdfortisService;
import com.cftech.core.scope.OrderType; import com.cftech.core.scope.OrderType;
import com.cftech.core.sql.Sort; import com.cftech.core.sql.Sort;
import com.cftech.core.util.DateUtils; import com.cftech.core.util.DateUtils;
import com.cftech.predrugs.model.PreDrugs;
import com.cftech.predrugs.service.PreDrugsService;
import com.cftech.prescription.model.Prescription; import com.cftech.prescription.model.Prescription;
import com.cftech.prescription.dao.PrescriptionMapper; import com.cftech.prescription.dao.PrescriptionMapper;
import com.cftech.prescription.service.PrescriptionService; import com.cftech.prescription.service.PrescriptionService;
import com.cftech.core.generic.GenericDao; import com.cftech.core.generic.GenericDao;
import com.cftech.core.generic.GenericServiceImpl; import com.cftech.core.generic.GenericServiceImpl;
import com.cftech.core.sql.Conds; import com.cftech.core.sql.Conds;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -38,6 +40,9 @@ public class PrescriptionServiceImpl extends GenericServiceImpl<Prescription> im ...@@ -38,6 +40,9 @@ public class PrescriptionServiceImpl extends GenericServiceImpl<Prescription> im
@Autowired @Autowired
CdfortisService cdfortisService; CdfortisService cdfortisService;
@Autowired
PreDrugsService preDrugsService;
@Override @Override
public GenericDao<Prescription> getGenericMapper() { public GenericDao<Prescription> getGenericMapper() {
return prescriptionMapper; return prescriptionMapper;
...@@ -64,7 +69,7 @@ public class PrescriptionServiceImpl extends GenericServiceImpl<Prescription> im ...@@ -64,7 +69,7 @@ public class PrescriptionServiceImpl extends GenericServiceImpl<Prescription> im
} }
Sort sort = new Sort("create_time", OrderType.DESC); Sort sort = new Sort("create_time", OrderType.DESC);
// 查询在时间范围内的数据 // TODO 查询在时间范围内的数据
Conds listConds = new Conds(); Conds listConds = new Conds();
// listConds.between("start_time", startTime, endTime); // listConds.between("start_time", startTime, endTime);
List<Prescription> prescriptions = fetchSearchByPage(listConds, sort, iDisplayStart, iDisplayLength); List<Prescription> prescriptions = fetchSearchByPage(listConds, sort, iDisplayStart, iDisplayLength);
...@@ -101,4 +106,65 @@ public class PrescriptionServiceImpl extends GenericServiceImpl<Prescription> im ...@@ -101,4 +106,65 @@ public class PrescriptionServiceImpl extends GenericServiceImpl<Prescription> im
} }
return onLineList; return onLineList;
} }
@Override
public Prescription findPreScription(String presId) throws Exception {
Prescription prescription = fetchById(presId);
if (prescription != null && !StringUtils.isEmpty(prescription.getSymptom())) {
return prescription;
}
FbusiDetail fbusiDetail = cdfortisService.getFbusiDetail(presId);
if (fbusiDetail == null) {
throw new Exception("找不到对应的处方数据");
}
if (prescription == null) {
// save数据
prescription = new Prescription();
BeanUtils.copyProperties(fbusiDetail, prescription);
save(prescription);
} else {
// update 数据
BeanUtils.copyProperties(fbusiDetail, prescription);
update(prescription);
}
handleFrug(fbusiDetail, prescription);
return prescription;
}
/**
* 处理处方单中的药品信息逻辑(存在则更新,不存在则新增)
*
* @param fbusiDetail
* @param prescription
*/
private void handleFrug(FbusiDetail fbusiDetail, Prescription prescription) {
List<FbusiDrug> drugs = fbusiDetail.getDrugs();
List<PreDrugs> preDrugsList = new ArrayList<>();
if (CollectionUtils.isEmpty(drugs)) {
return;
}
Conds drugConds = new Conds();
drugConds.equal("parent_id", prescription.getId());
int count = preDrugsService.count(drugConds);
if (count != 0) {
Sort sort = new Sort("create_time", OrderType.DESC);
preDrugsList = preDrugsService.fetchSearchByPage(drugConds, sort, 0, count);
}
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())) {
preDrug = preDrugMap.get(fbusiDrug.getDrugId());
BeanUtils.copyProperties(fbusiDrug, preDrug);
preDrug.setName(fbusiDrug.getDrugName());
preDrug.setParentId(prescription.getId());
preDrugsService.update(preDrug);
} else {
BeanUtils.copyProperties(fbusiDrug, preDrug);
preDrug.setName(fbusiDrug.getDrugName());
preDrug.setParentId(prescription.getId());
preDrugsService.save(preDrug);
}
}
}
} }
\ 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