From df61b9f9532e384ea26512cd8c11ff43efb260d2 Mon Sep 17 00:00:00 2001 From: fshenye <512914587@qq.com> Date: Thu, 28 Jan 2021 15:05:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AF=BC=E5=8C=BB=E5=8F=82?= =?UTF-8?q?=E6=95=B0=20=E8=B0=83=E6=95=B4=E5=AF=BC=E5=8C=BB=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hphy/controller/mp/HphyEvaController.java | 13 ++-- .../mp/HphyPatientBaseController.java | 2 +- .../sict/theme/hphy/schedule/RefreshJob.java | 40 ++++++------- .../hphy/service/HphyGuideRecordService.java | 2 +- .../impl/HphyGuideRecordServiceImpl.java | 60 +++++++++++++------ .../stc/sict/theme/hphy/util/PythonUtil.java | 4 +- .../sh/stc/sict/theme/hphy/vo/PythonDTO.java | 27 ++++++++- 7 files changed, 97 insertions(+), 51 deletions(-) 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 39c2ecf..fdd06c3 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 @@ -7,7 +7,6 @@ import cn.sh.stc.sict.cloud.common.core.constant.Constant; import cn.sh.stc.sict.cloud.common.core.util.NumberUtil; import cn.sh.stc.sict.cloud.common.core.util.R; import cn.sh.stc.sict.cloud.common.security.util.SecurityUtils; -import cn.sh.stc.sict.cloud.upms.dto.CurrentUser; 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; @@ -22,6 +21,7 @@ import cn.sh.stc.sict.theme.hphy.util.PythonUtil; import cn.sh.stc.sict.theme.hphy.vo.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.transaction.annotation.Transactional; @@ -144,11 +144,12 @@ public class HphyEvaController { @ApiOperation("调用python程序") @GetMapping("/python/result") public R getPythonResult(@RequestParam("guideId") Long guideId, - @RequestParam("")String a, - @RequestParam("")String b, - @RequestParam("")String c, - @RequestParam("")String d) throws UnsupportedEncodingException { - return hphyGuideRecordService.getPythonResult(guideId); + @ApiParam("纬度") @RequestParam(value = "addX",required = false)String addX, + @ApiParam("经度") @RequestParam(value = "addY",required = false)String addY, + @ApiParam("是否距离优先 Y-是") @RequestParam(value = "distence", defaultValue = "N", required = false)String distence, + @ApiParam("是否高龄医生优先 H-是") @RequestParam(value = "exp",defaultValue = "N", required = false)String exp, + @ApiParam("是否人气优先 Y-是") @RequestParam(value = "fre",defaultValue = "N", required = false)String fre) throws UnsupportedEncodingException { + return hphyGuideRecordService.getPythonResult(guideId, addX, addY, distence, exp, fre); } /** diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/HphyPatientBaseController.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/HphyPatientBaseController.java index 047c170..7a55785 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/HphyPatientBaseController.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/mp/HphyPatientBaseController.java @@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.*; @RequestMapping("/hphy/c/patientbase") @AllArgsConstructor @Slf4j -@Api(tags = "[D]患者基本信息") +@Api(tags = "[C]患者基本信息") public class HphyPatientBaseController { private HphyPatientBaseService hphyPatientBaseService; diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/schedule/RefreshJob.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/schedule/RefreshJob.java index a43f1b7..3c6b521 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/schedule/RefreshJob.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/schedule/RefreshJob.java @@ -17,24 +17,24 @@ import java.util.List; @Component public class RefreshJob { - @Scheduled(cron = "") - public void updateHosp(){ - HosInfo hosInfo = new HosInfo(); - List list = WanDaHttpUtil.getHospitalInfo(hosInfo); - } - - @Scheduled(cron = "") - public void updateDeptTop(){ - - } - - @Scheduled(cron = "") - public void updateDeptTwo(){ - - } - - @Scheduled(cron = "") - public void updateDocInfo(){ - - } +// @Scheduled(cron = "") +// public void updateHosp(){ +// HosInfo hosInfo = new HosInfo(); +// List list = WanDaHttpUtil.getHospitalInfo(hosInfo); +// } +// +// @Scheduled(cron = "") +// public void updateDeptTop(){ +// +// } +// +// @Scheduled(cron = "") +// public void updateDeptTwo(){ +// +// } +// +// @Scheduled(cron = "") +// public void updateDocInfo(){ +// +// } } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HphyGuideRecordService.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HphyGuideRecordService.java index 3210ee5..d065470 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HphyGuideRecordService.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HphyGuideRecordService.java @@ -26,7 +26,7 @@ public interface HphyGuideRecordService extends IService { HphyGuideRecord getByPatientId(String patientId); - R getPythonResult(Long guideId) throws UnsupportedEncodingException; + R getPythonResult(Long guideId, String addX, String addY, String distence, String exp, String fre) throws UnsupportedEncodingException; List listAnalysis(Long guideId); } 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 fabe7d1..6ffc85f 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 @@ -2,13 +2,14 @@ package cn.sh.stc.sict.theme.hphy.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdcardUtil; import cn.hutool.core.util.StrUtil; 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; import cn.sh.stc.sict.cloud.common.core.util.R; +import cn.sh.stc.sict.theme.common.model.HphyArticle; +import cn.sh.stc.sict.theme.common.service.HphyArticleService; 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; @@ -29,10 +30,7 @@ import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -44,6 +42,7 @@ public class HphyGuideRecordServiceImpl extends ServiceImpl(Arrays.asList(guide.getDisease().split(StringPool.SEMICOLON)))); - String pyResutl = PythonUtil.getDcotorMatchListForHP(JSONUtil.toJsonStr(pydto)); - update.setPyResult(pyResutl); - update.setAge(patient.getAge()); - guide.setPyResult(pyResutl); - this.updateById(update); - } +// if (StrUtil.isBlank(guide.getPyResult())) { +// } + HphyGuideRecord update = new HphyGuideRecord(); + update.setId(guideId); + HphyPatientBase patient = hphyPatientBaseService.getById(guide.getPatientId()); + PythonDTO pydto = new PythonDTO(patient, new ArrayList<>(Arrays.asList(guide.getDisease().split(StringPool.SEMICOLON)))); + pydto.setParam(addX, addY, distence, exp, fre); + String pyResutl = PythonUtil.getDcotorMatchListForHP(JSONUtil.toJsonStr(pydto)); + update.setPyResult(pyResutl); + update.setAge(patient.getAge()); + guide.setPyResult(pyResutl); + this.updateById(update); if (JSONUtil.isJson(guide.getPyResult())) { JSONObject obj = JSONUtil.parseObj(guide.getPyResult()); + List articleIdList = JSON.parseArray(obj.getStr("atricle"), Long.class); + Map result = new HashMap<>(); + if (CollUtil.isNotEmpty(articleIdList)) { + LambdaQueryWrapper articleWrapper = new LambdaQueryWrapper<>(); + articleWrapper.in(HphyArticle::getId, articleIdList) + .select(HphyArticle.class, i -> (!i.getColumn().equals("content"))) + .orderByDesc(HphyArticle::getCreateTime); + List articleList = hphyArticleService.list(articleWrapper); + result.put("articleList", articleList); + } // indicator 0-字符串 1-json if (Constant.STRING_YES.equals(obj.getStr("indicator"))) { List pythonList = JSON.parseArray(obj.getStr("data"), PythonResult.class); List resultList = hphyDoctorService.getRecommendList(guide, pythonList); - return new R(resultList).setBizCode(200); + result.put("doctorList", resultList); + return new R(result).setBizCode(200); } else { - return new R(obj.getStr("data")).setBizCode(100); + result.put("msg", obj.getStr("data")); + return new R(result).setBizCode(100); } } else { return new R(guide.getPyResult()).setBizCode(100); 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 e0771f2..b9efc7e 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 @@ -21,7 +21,7 @@ public class PythonUtil { public static String getDcotorMatchListForHP(String params) throws UnsupportedEncodingException { log.error("py->syptomoList--->{}", params); - String url = "http://localhost:9003/hello?aa=" + params; + String url = "http://173.18.1.63:9003/hello?aa=" + params; String body = HttpRequest.post(url) .setEncodeUrlParams(true) .execute() @@ -40,7 +40,7 @@ public class PythonUtil { public static JSONArray getMatchLabel(String params) { log.error("getMatchLabel->params--->{}", params); - String url = "http://localhost:9004/hello?aa=" + params; + String url = "http://173.18.1.63:9004/hello?aa=" + params; String body = HttpRequest.post(url) .setEncodeUrlParams(true) .execute() diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/PythonDTO.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/PythonDTO.java index 68c43ce..c58d0b6 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/PythonDTO.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/PythonDTO.java @@ -25,9 +25,14 @@ public class PythonDTO { private String distence = "N"; private String age = "N"; private String exp = "N"; - private List add; - private List appo; + private String fre = "N"; + /** + * [纬度,经度] + */ + private List add = new ArrayList<>(); private List disease; + private List reserve_list = new ArrayList<>(); + private List appo = new ArrayList<>(); private Object result; public PythonDTO(HphyPatientBase patient, List disease) throws UnsupportedEncodingException { @@ -67,4 +72,22 @@ public class PythonDTO { }); } } + + public void setParam(String addX, String addY, String distence, String exp, String fre) { + if (StrUtil.isNotBlank(addX) && StrUtil.isNotBlank(addY)) { + List list = new ArrayList<>(); + list.add(addX); + list.add(addY); + this.add = list; + } + if(StrUtil.isNotBlank(distence)){ + this.distence = distence; + } + if(StrUtil.isNotBlank(exp)){ + this.exp = exp; + } + if(StrUtil.isNotBlank(fre)){ + this.fre = fre; + } + } } -- 2.22.0