Commit fedf2d0d authored by 向怀芳's avatar 向怀芳 🎱

调整导医参数

调整导医返回结构
parent b7414e6a
......@@ -2,6 +2,7 @@ package cn.sh.stc.sict.theme.hphy.controller.mp;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.sh.stc.sict.cloud.common.core.constant.Constant;
import cn.sh.stc.sict.cloud.common.core.util.NumberUtil;
......@@ -10,10 +11,7 @@ import cn.sh.stc.sict.cloud.common.security.util.SecurityUtils;
import cn.sh.stc.sict.theme.common.dto.SocketMsg;
import cn.sh.stc.sict.theme.handler.WebSocketServer;
import cn.sh.stc.sict.theme.hphy.constant.PatientConstant;
import cn.sh.stc.sict.theme.hphy.model.HphyDoctor;
import cn.sh.stc.sict.theme.hphy.model.HphyGuideQuestion;
import cn.sh.stc.sict.theme.hphy.model.HphyGuideRecord;
import cn.sh.stc.sict.theme.hphy.model.HphyPatientBase;
import cn.sh.stc.sict.theme.hphy.model.*;
import cn.sh.stc.sict.theme.hphy.service.*;
import cn.sh.stc.sict.theme.hphy.util.GuideUtil;
import cn.sh.stc.sict.theme.hphy.util.PythonCompareParam;
......@@ -54,7 +52,8 @@ public class HphyEvaController {
private final HphyGuideRecordService hphyGuideRecordService;
private final HphyQuestionService hphyQuestionService;
private final HphyGuideQuestionService hphyGuideQuestionService;
private final HphyDoctorService hphyDoctorService;
// private final HphyDoctorService hphyDoctorService;
private final HpDocInfoService hpDocInfoService;
/**
......@@ -171,18 +170,24 @@ public class HphyEvaController {
* 年龄,地址,disease
*/
HphyPatientBase patient = hphyPatientBaseService.getById(patientId);
HphyDoctor doctor = hphyDoctorService.getById(doctorId);
// HphyDoctor doctor = hphyDoctorService.getById(doctorId);
HpDocInfo doctor = hpDocInfoService.getById(doctorId);
HphyGuideRecord guide = hphyGuideRecordService.getById(guideId);
List<LabelVO> patientList = GuideUtil.getPatientList(patient, guide);
List<String> disease = GuideUtil.getPatientDisease(guide);
PythonCompareParam param = new PythonCompareParam(patient.getCertId(), doctorId, patient.getAge(), disease);
JSONArray doctorList = PythonUtil.getMatchLabel(JSONUtil.toJsonStr(param));
PythonCompareParam param = new PythonCompareParam(patient.getCertId(), doctor.getPersonId(), patient.getAge(), disease);
JSONObject object = PythonUtil.getMatchLabel(JSONUtil.toJsonStr(param));
JSONArray doctorList = (JSONArray) object.getByPath("doctor.list");
JSONArray patientJList = (JSONArray) object.getByPath("patient.list");
DoctorPatientMatchVO vo = DoctorPatientMatchVO.builder()
.patient(patient)
.patientLabelList(patientList)
.patientLabelList1(patientList)
.patientLabelList2(patientJList)
.doctor(doctor)
.doctorLabelList(doctorList)
.build();
return new R(vo);
}
......
package cn.sh.stc.sict.theme.hphy.controller.mp;
import cn.sh.stc.sict.cloud.common.core.util.R;
import cn.sh.stc.sict.theme.hphy.wd.NumSourceInfo;
import cn.sh.stc.sict.theme.hphy.wd.WanDaHttpUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -9,6 +10,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author F_xh
*/
......@@ -28,7 +31,10 @@ public class WDController {
@ApiOperation("获取号源信息")
@GetMapping("/num/info")
public R getOrderNumberInfo() {
return new R();
public R getOrderNumberInfo(NumSourceInfo numSourceInfo) {
List<NumSourceInfo> list = WanDaHttpUtil.getOrderNumInfo(numSourceInfo);
return new R(list);
}
}
package cn.sh.stc.sict.theme.hphy.service;
import cn.sh.stc.sict.theme.hphy.model.HpDocInfo;
import cn.sh.stc.sict.theme.hphy.model.HphyGuideRecord;
import cn.sh.stc.sict.theme.hphy.vo.DoctorMatchVO;
import cn.sh.stc.sict.theme.hphy.vo.PythonResult;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* (HpDocInfo)表服务接口
*
......@@ -18,4 +23,5 @@ public interface HpDocInfoService extends IService<HpDocInfo> {
*/
boolean doctorExist(String resourceCode);
List<DoctorMatchVO> getRecommendList(HphyGuideRecord guide, List<PythonResult> pythonList);
}
\ No newline at end of file
......@@ -4,6 +4,8 @@ package cn.sh.stc.sict.theme.hphy.service;
import cn.sh.stc.sict.theme.hphy.model.HphyGuideMatch;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 导医推荐记录
*
......@@ -11,5 +13,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @date 2021-01-04 13:52:44
*/
public interface HphyGuideMatchService extends IService<HphyGuideMatch> {
void asyncSaveBatch(List<HphyGuideMatch> matchList);
}
......@@ -2,10 +2,23 @@ package cn.sh.stc.sict.theme.hphy.service.impl;
import cn.sh.stc.sict.theme.hphy.dao.HpDocInfoMapper;
import cn.sh.stc.sict.theme.hphy.model.HpDocInfo;
import cn.sh.stc.sict.theme.hphy.model.HphyGuideMatch;
import cn.sh.stc.sict.theme.hphy.model.HphyGuideRecord;
import cn.sh.stc.sict.theme.hphy.service.HpDocInfoService;
import cn.sh.stc.sict.theme.hphy.service.HphyGuideMatchService;
import cn.sh.stc.sict.theme.hphy.vo.DoctorMatchVO;
import cn.sh.stc.sict.theme.hphy.vo.PythonResult;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* (HpDocInfo)表服务实现类
*
......@@ -13,10 +26,48 @@ import org.springframework.stereotype.Service;
* @since 2021-01-28 10:35:59
*/
@Service("hpDocInfoService")
@AllArgsConstructor
public class HpDocInfoServiceImpl extends ServiceImpl<HpDocInfoMapper, HpDocInfo> implements HpDocInfoService {
private HphyGuideMatchService hphyGuideMatchService;
@Override
public boolean doctorExist(String resourceCode) {
return this.getById(resourceCode) != null;
}
@Override
public List<DoctorMatchVO> getRecommendList(HphyGuideRecord guide, List<PythonResult> pythonList) {
List<DoctorMatchVO> result = new ArrayList<>();
Map<String, Double> matchMap = pythonList.stream().collect(Collectors.toMap(PythonResult::getDoctorId, PythonResult::getMatchScore));
List<String> doctorIdList = pythonList.stream().map(PythonResult::getDoctorId).collect(Collectors.toList());
LambdaQueryWrapper<HpDocInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.in(HpDocInfo::getPersonId, doctorIdList);
List<HpDocInfo> list = this.list(wrapper);
List<HphyGuideMatch> matchList = new ArrayList<>();
list.forEach(doctor -> {
DoctorMatchVO vo = new DoctorMatchVO();
vo.setDocInfo(doctor);
vo.setMatchScore(matchMap.getOrDefault(doctor.getPersonId(), 85.0));
result.add(vo);
HphyGuideMatch match = new HphyGuideMatch();
match.setDeptId(doctor.getDeptCode());
match.setDeptName(doctor.getDeptName());
match.setDoctorId(doctor.getResourceCode());
match.setDoctorName(doctor.getResourceName());
match.setGuideId(guide.getId());
match.setHospId(doctor.getHosOrgCode());
match.setHospName(doctor.getHosName());
match.setMatchScore(vo.getMatchScore().toString());
match.setPatientId(guide.getPatientId());
match.setPatientName(guide.getPatientName());
matchList.add(match);
});
// 保存医生推荐记录
hphyGuideMatchService.asyncSaveBatch(matchList);
return result.stream()
.sorted(Comparator.comparing(DoctorMatchVO::getMatchScore).reversed())
.collect(Collectors.toList());
}
}
\ No newline at end of file
......@@ -6,11 +6,20 @@ import cn.sh.stc.sict.theme.hphy.model.HphyGuideMatch;
import cn.sh.stc.sict.theme.hphy.service.HphyGuideMatchService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("hphyGuideMatchService")
@AllArgsConstructor
public class HphyGuideMatchServiceImpl extends ServiceImpl<HphyGuideMatchMapper, HphyGuideMatch> implements HphyGuideMatchService {
private final HphyGuideMatchMapper hphyGuideMatchMapper;
@Override
@Async
public void asyncSaveBatch(List<HphyGuideMatch> matchList) {
this.saveBatch(matchList);
}
}
......@@ -14,6 +14,7 @@ import cn.sh.stc.sict.theme.hphy.constant.PatientConstant;
import cn.sh.stc.sict.theme.hphy.dao.HphyGuideRecordMapper;
import cn.sh.stc.sict.theme.hphy.model.HphyGuideRecord;
import cn.sh.stc.sict.theme.hphy.model.HphyPatientBase;
import cn.sh.stc.sict.theme.hphy.service.HpDocInfoService;
import cn.sh.stc.sict.theme.hphy.service.HphyDoctorService;
import cn.sh.stc.sict.theme.hphy.service.HphyGuideRecordService;
import cn.sh.stc.sict.theme.hphy.service.HphyPatientBaseService;
......@@ -43,6 +44,7 @@ public class HphyGuideRecordServiceImpl extends ServiceImpl<HphyGuideRecordMappe
private final HphyDoctorService hphyDoctorService;
private final HphyPatientBaseService hphyPatientBaseService;
private final HphyArticleService hphyArticleService;
private final HpDocInfoService hpDocInfoService;
/**
* 初始化导医记录
......@@ -290,7 +292,8 @@ public class HphyGuideRecordServiceImpl extends ServiceImpl<HphyGuideRecordMappe
// indicator 0-字符串 1-json
if (Constant.STRING_YES.equals(obj.getStr("indicator"))) {
List<PythonResult> pythonList = JSON.parseArray(obj.getStr("data"), PythonResult.class);
List<DoctorMatchVO> resultList = hphyDoctorService.getRecommendList(guide, pythonList);
// List<DoctorMatchVO> resultList = hphyDoctorService.getRecommendList(guide, pythonList);
List<DoctorMatchVO> resultList = hpDocInfoService.getRecommendList(guide, pythonList);
result.put("doctorList", resultList);
return new R(result).setBizCode(200);
} else {
......
......@@ -37,7 +37,7 @@ public class PythonUtil {
* @param params
* @return
*/
public static JSONArray getMatchLabel(String params) {
public static JSONObject getMatchLabel(String params) {
log.error("getMatchLabel->params--->{}", params);
String url = "http://173.18.1.63:9004/hello?aa=" + params;
......@@ -48,8 +48,7 @@ public class PythonUtil {
log.error("getMatchLabel->pyresult-------------> {}", body);
if(JSONUtil.isJsonObj(body)){
JSONObject obj = JSONUtil.parseObj(body);
JSONArray list = obj.getJSONArray("list");
return list;
return obj;
}
return null;
}
......
package cn.sh.stc.sict.theme.hphy.vo;
import cn.sh.stc.sict.theme.hphy.model.HpDocInfo;
import cn.sh.stc.sict.theme.hphy.model.HphyDoctor;
import lombok.Data;
@Data
public class DoctorMatchVO {
private HphyDoctor doctor;
private HpDocInfo docInfo;
private Double matchScore;
}
package cn.sh.stc.sict.theme.hphy.vo;
import cn.hutool.json.JSONArray;
import cn.sh.stc.sict.theme.hphy.model.HphyDoctor;
import cn.sh.stc.sict.theme.hphy.model.HpDocInfo;
import cn.sh.stc.sict.theme.hphy.model.HphyPatientBase;
import lombok.AllArgsConstructor;
import lombok.Builder;
......@@ -18,9 +18,10 @@ public class DoctorPatientMatchVO {
// 患者信息
private HphyPatientBase patient;
// 患者标签
private List<LabelVO> patientLabelList;
private List<LabelVO> patientLabelList1;
private JSONArray patientLabelList2;
// 医生信息
private HphyDoctor doctor;
private HpDocInfo doctor;
// 医生标签
private JSONArray doctorLabelList;
}
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