diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/HphyEvaController.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/HphyEvaController.java index fdd06c3e0420865f426b1fe4f4b804e6207d5fe2..fc4d36b2902bf494c728c25f069ffcaaf2904138 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/HphyEvaController.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/HphyEvaController.java @@ -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 patientList = GuideUtil.getPatientList(patient, guide); List 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); } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/WDController.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/WDController.java index b13b59d524633a37e86d34ee4b4baa91f324a648..8eb56b36de2777b0fca4c78d352abc1d6a253707 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/WDController.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/WDController.java @@ -1,6 +1,7 @@ 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 list = WanDaHttpUtil.getOrderNumInfo(numSourceInfo); + + return new R(list); } } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpDocInfoService.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpDocInfoService.java index bfff237bcac6c1257a94836381857b6fe9617e3e..a8d6becec8c7caa38807cd5cf6e72ca0c275e9d1 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpDocInfoService.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpDocInfoService.java @@ -1,8 +1,13 @@ 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 { */ boolean doctorExist(String resourceCode); + List getRecommendList(HphyGuideRecord guide, List pythonList); } \ No newline at end of file diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HphyGuideMatchService.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HphyGuideMatchService.java index 6f252473a7a410d053e5b3acc7e6eeb7fa35a069..f4dd69d4486d94a27dfa20e1e2fbec9ddc505c43 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HphyGuideMatchService.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HphyGuideMatchService.java @@ -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 { + void asyncSaveBatch(List matchList); } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpDocInfoServiceImpl.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpDocInfoServiceImpl.java index d728961f394b9c72a1a81834df194b67404b0ff4..54446f43a412b3a29607e58b047d9c89c86f9532 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpDocInfoServiceImpl.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpDocInfoServiceImpl.java @@ -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 implements HpDocInfoService { + private HphyGuideMatchService hphyGuideMatchService; + @Override public boolean doctorExist(String resourceCode) { return this.getById(resourceCode) != null; } + + @Override + public List getRecommendList(HphyGuideRecord guide, List pythonList) { + List result = new ArrayList<>(); + Map matchMap = pythonList.stream().collect(Collectors.toMap(PythonResult::getDoctorId, PythonResult::getMatchScore)); + List doctorIdList = pythonList.stream().map(PythonResult::getDoctorId).collect(Collectors.toList()); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(HpDocInfo::getPersonId, doctorIdList); + List list = this.list(wrapper); + List 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 diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HphyGuideMatchServiceImpl.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HphyGuideMatchServiceImpl.java index 656148d4eae38406cdd475aa7aaf007a9e46f614..0885bf8fd8a43b052a40036b5485d9259ab41e5b 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HphyGuideMatchServiceImpl.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HphyGuideMatchServiceImpl.java @@ -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 implements HphyGuideMatchService { private final HphyGuideMatchMapper hphyGuideMatchMapper; + + @Override + @Async + public void asyncSaveBatch(List matchList) { + this.saveBatch(matchList); + } } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HphyGuideRecordServiceImpl.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HphyGuideRecordServiceImpl.java index 6ffc85fb9b1245430b2f4928551a811102ec2984..91c4c200161b1e890633c67571470a16b905e022 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HphyGuideRecordServiceImpl.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HphyGuideRecordServiceImpl.java @@ -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 pythonList = JSON.parseArray(obj.getStr("data"), PythonResult.class); - List resultList = hphyDoctorService.getRecommendList(guide, pythonList); + // List resultList = hphyDoctorService.getRecommendList(guide, pythonList); + List resultList = hpDocInfoService.getRecommendList(guide, pythonList); result.put("doctorList", resultList); return new R(result).setBizCode(200); } else { diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/util/PythonUtil.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/util/PythonUtil.java index b9efc7e195cd5c0db39d7d2a4326715e482ed0d1..f4110ff4c6cf0da6eb596837688c5ff465078392 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/util/PythonUtil.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/util/PythonUtil.java @@ -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; } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/DoctorMatchVO.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/DoctorMatchVO.java index 32124e2fbf574f67d05e7a8b9034fec3123147b1..09f6866dc860b3dd7ba6cd4e31fdf5c241aca24b 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/DoctorMatchVO.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/DoctorMatchVO.java @@ -1,10 +1,12 @@ 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; } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/DoctorPatientMatchVO.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/DoctorPatientMatchVO.java index 7e646e465af7c772e622ffae0f7381dad35c8b86..bd8d259e8c3ef70adae1af7be6edd186867e4296 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/DoctorPatientMatchVO.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/DoctorPatientMatchVO.java @@ -1,7 +1,7 @@ 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 patientLabelList; + private List patientLabelList1; + private JSONArray patientLabelList2; // 医生信息 - private HphyDoctor doctor; + private HpDocInfo doctor; // 医生标签 private JSONArray doctorLabelList; }