From edc1fe66bcd6d72b607d1deb98c8ba5787ed964a Mon Sep 17 00:00:00 2001 From: fshenye <12345678> Date: Fri, 19 Aug 2022 17:38:08 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=8F=90=E4=BE=9B=E5=8D=95=E4=B8=AA?= =?UTF-8?q?=E7=A7=91=E5=AE=A4=E7=BB=9F=E8=AE=A1=E5=8F=B7=E6=BA=90=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=202.=20=E5=8F=B7=E6=BA=90=E7=BB=9F=E8=AE=A1=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E7=A7=91=E5=AE=A4=E5=86=85=E5=8C=BB=E7=94=9F=E4=B9=9F?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=8F=B7=E6=BA=90=203.=20=E5=8F=B7=E6=BA=90?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=97=B6=EF=BC=8C=E6=A0=87=E8=AE=B0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E4=B8=AD=E5=8C=BB=E7=94=9F=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=9C=89=E5=8F=B7=E6=BA=90=204.=20=E6=9F=A5=E8=AF=A2=E7=A7=91?= =?UTF-8?q?=E5=AE=A4=E5=8C=BB=E7=94=9F=E6=97=B6=EF=BC=8C=E4=BB=8E=E5=BA=93?= =?UTF-8?q?=E4=B8=AD=E6=9F=A5=EF=BC=8C=E7=BB=BC=E5=90=88=E4=B8=87=E8=BE=BE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=9A=84=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HpgpBusyIdlePredictionService.java | 2 +- .../HpgpBusyIdlePredictionServiceImpl.java | 109 ++++++++++++++---- .../controller/mp/HpDeptInfoController.java | 16 ++- .../controller/web/HpDocInfoController.java | 1 + .../stc/sict/theme/hphy/model/HpDocInfo.java | 2 + .../sict/theme/hphy/schedule/RefreshJob.java | 3 +- .../theme/hphy/service/HpDocInfoService.java | 6 + .../service/impl/HpDeptInfoServiceImpl.java | 75 +++++++++--- .../service/impl/HpDocInfoServiceImpl.java | 28 ++++- .../stc/sict/theme/hphy/wd/WanDaConstant.java | 1 + .../stc/sict/theme/hphy/wd/WanDaHttpUtil.java | 55 +++++---- 11 files changed, 226 insertions(+), 72 deletions(-) diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hpgp/service/HpgpBusyIdlePredictionService.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hpgp/service/HpgpBusyIdlePredictionService.java index 151586f..99176c3 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hpgp/service/HpgpBusyIdlePredictionService.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hpgp/service/HpgpBusyIdlePredictionService.java @@ -24,7 +24,7 @@ public interface HpgpBusyIdlePredictionService extends IService busyIdlePrediction(String deptName); - void statisticResourceInfo(HpgpDepartmentRank dept, Date startDate, Date endDate); + void statisticResourceInfo(HpgpDepartmentRank dept, Date startDate, Date endDate, Byte flag); List listByDeptRank(HpgpDepartmentRank dept, DateTime startTime, DateTime endTime); } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hpgp/service/impl/HpgpBusyIdlePredictionServiceImpl.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hpgp/service/impl/HpgpBusyIdlePredictionServiceImpl.java index 489df2d..9afa8b3 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hpgp/service/impl/HpgpBusyIdlePredictionServiceImpl.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hpgp/service/impl/HpgpBusyIdlePredictionServiceImpl.java @@ -5,7 +5,9 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; 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.theme.hpgp.dao.HpgpBusyIdlePredictionMapper; import cn.sh.stc.sict.theme.hpgp.dao.HpgpDepartmentRankMapper; @@ -13,6 +15,8 @@ import cn.sh.stc.sict.theme.hpgp.model.HpgpBusyIdlePrediction; import cn.sh.stc.sict.theme.hpgp.model.HpgpDepartmentRank; import cn.sh.stc.sict.theme.hpgp.service.HpgpBusyIdlePredictionService; import cn.sh.stc.sict.theme.hpgp.vo.DeptRankVO; +import cn.sh.stc.sict.theme.hphy.model.HpDocInfo; +import cn.sh.stc.sict.theme.hphy.service.HpDocInfoService; import cn.sh.stc.sict.theme.hphy.wd.*; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -35,6 +39,7 @@ import java.util.stream.Collectors; @Service("hpgpBusyIdlPredictionService") public class HpgpBusyIdlePredictionServiceImpl extends ServiceImpl implements HpgpBusyIdlePredictionService { private final HpgpDepartmentRankMapper departmentRankMapper; + private final HpDocInfoService hpDocInfoService; @Override public List busyIdlePrediction(String deptName) { @@ -66,30 +71,39 @@ public class HpgpBusyIdlePredictionServiceImpl extends ServiceImpl outList = WanDaHttpUtil.getResourceOutPatInfo(deptInfo); - List docList = WanDaHttpUtil.getResourceDoctInfo(deptInfo); - if (CollUtil.isEmpty(outList) && CollUtil.isEmpty(docList)) { - return; - } - Map dateResultMap = new HashMap<>(); - this.getOutResourceInfo(dept, outList, dateResultMap, startDate, endDate); - this.getDocResourceInfo(dept, docList, dateResultMap, startDate, endDate); - if (CollUtil.isNotEmpty(dateResultMap)) { - dateResultMap.forEach((k, v) -> { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(HpgpBusyIdlePrediction::getHospitalCode, v.getHospitalCode()) - .eq(HpgpBusyIdlePrediction::getOneDeptCode, v.getOneDeptCode()) - .eq(HpgpBusyIdlePrediction::getDeptCode, v.getDeptCode()) - .eq(HpgpBusyIdlePrediction::getPredictionDate, v.getPredictionDate()); - this.saveOrUpdate(v, wrapper); - }); + public void statisticResourceInfo(HpgpDepartmentRank dept, Date startDate, Date endDate, Byte flag) { + try { + DeptInfo deptInfo = new DeptInfo(); + deptInfo.setHosOrgCode(dept.getHospitalCode()); + deptInfo.setOneDeptCode(dept.getOneDeptCode()); + deptInfo.setDeptCode(dept.getDeptCode()); + List outList = WanDaHttpUtil.getResourceOutPatInfo(deptInfo); + List docList = WanDaHttpUtil.getResourceDoctInfo(deptInfo); + List hpDocList = hpDocInfoService.listByDeptInfo(deptInfo); + if (CollUtil.isEmpty(outList) && CollUtil.isEmpty(docList) && CollUtil.isEmpty(hpDocList)) { + return; + } + Map dateResultMap = new HashMap<>(); + this.getOutResourceInfo(dept, outList, dateResultMap, startDate, endDate); + this.getDocResourceInfo(dept, docList, dateResultMap, startDate, endDate); + if (Constant.BYTE_YES.equals(flag)) { + this.getHpDocResourceInfo(dept, hpDocList, docList, dateResultMap, startDate, endDate); + } + if (CollUtil.isNotEmpty(dateResultMap)) { + dateResultMap.forEach((k, v) -> { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(HpgpBusyIdlePrediction::getHospitalCode, v.getHospitalCode()) + .eq(HpgpBusyIdlePrediction::getOneDeptCode, v.getOneDeptCode()) + .eq(HpgpBusyIdlePrediction::getDeptCode, v.getDeptCode()) + .eq(HpgpBusyIdlePrediction::getPredictionDate, v.getPredictionDate()); + this.saveOrUpdate(v, wrapper); + }); + } + } catch (Exception e) { + log.error("统计号源异常, dept = {}", JSONUtil.toJsonStr(dept)); + log.error(e.getMessage(), e); } } @@ -141,6 +155,53 @@ public class HpgpBusyIdlePredictionServiceImpl extends ServiceImpl orderNumInfo = WanDaHttpUtil.getOrderNumInfo(numSourceInfo); if (CollUtil.isNotEmpty(orderNumInfo)) { + hpDocInfoService.updateResource(numSourceInfo, Constant.BYTE_YES); + Map> dateMap = orderNumInfo.stream().collect(Collectors.groupingBy(NumSourceInfo::getScheduleDate)); + dateMap.forEach((date, numList) -> { + HpgpBusyIdlePrediction vo = dateResultMap.getOrDefault(date, new HpgpBusyIdlePrediction()); + vo.setDeptCode(dept.getDeptCode()); + vo.setDeptName(dept.getDeptName()); + vo.setHospitalName(dept.getHospitalName()); + vo.setHospitalCode(dept.getHospitalCode()); + vo.setPredictionDate(DateUtil.parseDate(date)); + vo.setOneDeptCode(dept.getOneDeptCode()); + int reserveOrderNum = numList.stream().mapToInt(NumSourceInfo::getReserveOrderNum).sum(); + vo.setReserveOrderNum(NumberUtil.isNullOrZero(vo.getReserveOrderNum()) ? reserveOrderNum : vo.getReserveOrderNum() + reserveOrderNum); + int remain = numList.stream().mapToInt(NumSourceInfo::getRemainNum).sum(); + vo.setRemainNum(NumberUtil.isNullOrZero(vo.getRemainNum()) ? remain : vo.getRemainNum() + remain); + vo.setScoreByNum(); + dateResultMap.put(date, vo); + }); + } else { + hpDocInfoService.updateResource(numSourceInfo, Constant.BYTE_NO); + } + }); + } + } + + private void getHpDocResourceInfo(HpgpDepartmentRank dept, + List hpDocList, List docList, + Map dateResultMap, + Date startDate, + Date endDate) { + Set resourceCodeSet = CollUtil.isEmpty(docList) ? new HashSet<>() : docList.stream().map(DoctInfo::getResourceCode).collect(Collectors.toSet()); + if (CollUtil.isNotEmpty(hpDocList)) { + hpDocList.forEach(doc -> { + if (StrUtil.isEmpty(doc.getResourceCode()) || resourceCodeSet.contains(doc.getResourceCode())) { + return; + } + NumSourceInfo numSourceInfo = new NumSourceInfo(); + numSourceInfo.setHosOrgCode(dept.getHospitalCode()); + numSourceInfo.setOneDeptCode(dept.getOneDeptCode()); + numSourceInfo.setDeptCode(dept.getDeptCode()); + numSourceInfo.setStartTime(DateUtil.format(startDate, DatePattern.NORM_DATE_FORMAT)); + numSourceInfo.setEndTime(DateUtil.format(endDate, DatePattern.NORM_DATE_FORMAT)); + numSourceInfo.setOrderType(WanDaConstant.ORDER_TYPE_OUTP); + numSourceInfo.setPatient_type(WanDaConstant.PATIENT_TYPE_NORMAL); + numSourceInfo.setResourceCode(doc.getResourceCode()); + List orderNumInfo = WanDaHttpUtil.getOrderNumInfo(numSourceInfo); + if (CollUtil.isNotEmpty(orderNumInfo)) { + hpDocInfoService.updateResource(numSourceInfo, Constant.BYTE_YES); Map> dateMap = orderNumInfo.stream().collect(Collectors.groupingBy(NumSourceInfo::getScheduleDate)); dateMap.forEach((date, numList) -> { HpgpBusyIdlePrediction vo = dateResultMap.getOrDefault(date, new HpgpBusyIdlePrediction()); @@ -157,6 +218,8 @@ public class HpgpBusyIdlePredictionServiceImpl extends ServiceImpl deptList = hpgpDepartmentRankService.list(); + public R statisticRankDeptResourceInfo(@RequestParam(value = "hospCode", required = false) String hospCode, + @RequestParam(value = "oneDeptCode", required = false) String oneDeptCode, + @RequestParam(value = "dept", required = false) String deptCode, + @RequestParam(value = "flag", required = false, defaultValue = Constant.STRING_NO) Byte flag) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(StrUtil.isNotEmpty(hospCode), HpgpDepartmentRank::getHospitalCode, hospCode) + .eq(StrUtil.isNotEmpty(oneDeptCode), HpgpDepartmentRank::getOneDeptCode, oneDeptCode) + .eq(StrUtil.isNotEmpty(deptCode), HpgpDepartmentRank::getDeptCode, deptCode); + List deptList = hpgpDepartmentRankService.list(wrapper); deptList.forEach(dept -> { if (StrUtil.isEmpty(dept.getOneDeptCode()) || StrUtil.isEmpty(dept.getDeptCode())) { return; } Date startDate = DateUtil.date(); Date endDate = DateUtil.offsetDay(startDate, 10); - hpgpBusyIdlePredictionService.statisticResourceInfo(dept, startDate, endDate); + hpgpBusyIdlePredictionService.statisticResourceInfo(dept, startDate, endDate, flag); }); return new R(); } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/web/HpDocInfoController.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/web/HpDocInfoController.java index 81d35b8..f1d75a5 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/web/HpDocInfoController.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/web/HpDocInfoController.java @@ -23,4 +23,5 @@ public class HpDocInfoController extends ApiController { * 服务对象 */ private final HpDocInfoService hpDocInfoService; + } \ No newline at end of file diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HpDocInfo.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HpDocInfo.java index e02c07d..dc4ec93 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HpDocInfo.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/model/HpDocInfo.java @@ -55,6 +55,8 @@ public class HpDocInfo extends Model { @ApiModelProperty(hidden = false, value = "是否有资源(0有,1无)") private String isResource; + private Byte hasResource; + /** * 获取主键值 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 b83d0bb..7ca4c31 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 @@ -3,6 +3,7 @@ package cn.sh.stc.sict.theme.hphy.schedule; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; +import cn.sh.stc.sict.cloud.common.core.constant.Constant; import cn.sh.stc.sict.theme.hpgp.model.HpgpDepartmentRank; import cn.sh.stc.sict.theme.hpgp.service.HpgpBusyIdlePredictionService; import cn.sh.stc.sict.theme.hpgp.service.HpgpDepartmentRankService; @@ -121,7 +122,7 @@ public class RefreshJob { } Date startDate = DateUtil.date(); Date endDate = DateUtil.offsetDay(startDate, 10); - hpgpBusyIdlePredictionService.statisticResourceInfo(dept, startDate, endDate); + hpgpBusyIdlePredictionService.statisticResourceInfo(dept, startDate, endDate, Constant.BYTE_NO); }); } 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 5575289..ea649d1 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 @@ -4,6 +4,8 @@ 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 cn.sh.stc.sict.theme.hphy.wd.DeptInfo; +import cn.sh.stc.sict.theme.hphy.wd.NumSourceInfo; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; @@ -26,4 +28,8 @@ public interface HpDocInfoService extends IService { List getRecommendList(HphyGuideRecord guide, List pythonList); void saveDoctor(List docInfos, String hosOrgCode); + + List listByDeptInfo(DeptInfo deptInfo); + + void updateResource(NumSourceInfo numSourceInfo, Byte hasResource); } \ 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/HpDeptInfoServiceImpl.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpDeptInfoServiceImpl.java index 1814726..0bfc12f 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpDeptInfoServiceImpl.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpDeptInfoServiceImpl.java @@ -2,14 +2,10 @@ package cn.sh.stc.sict.theme.hphy.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; import cn.hutool.json.JSONUtil; -import cn.sh.stc.sict.theme.hpgp.model.HpgpDepartmentRank; +import cn.sh.stc.sict.cloud.common.core.constant.Constant; import cn.sh.stc.sict.theme.hphy.constant.DataConstant; import cn.sh.stc.sict.theme.hphy.dao.HpDeptInfoMapper; -import cn.sh.stc.sict.theme.hphy.dao.HpDocInfoMapper; -import cn.sh.stc.sict.theme.hphy.dao.HpHosInfoMapper; import cn.sh.stc.sict.theme.hphy.model.HpDeptInfo; import cn.sh.stc.sict.theme.hphy.model.HpDocInfo; import cn.sh.stc.sict.theme.hphy.model.HpHosInfo; @@ -17,7 +13,10 @@ import cn.sh.stc.sict.theme.hphy.service.HpDeptInfoService; import cn.sh.stc.sict.theme.hphy.service.HpDocInfoService; import cn.sh.stc.sict.theme.hphy.service.HpHosInfoService; import cn.sh.stc.sict.theme.hphy.vo.DeptDoctorsVO; -import cn.sh.stc.sict.theme.hphy.wd.*; +import cn.sh.stc.sict.theme.hphy.wd.DeptInfo; +import cn.sh.stc.sict.theme.hphy.wd.DoctInfo; +import cn.sh.stc.sict.theme.hphy.wd.OutPatInfo; +import cn.sh.stc.sict.theme.hphy.wd.WanDaHttpUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; @@ -25,7 +24,9 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -60,8 +61,10 @@ public class HpDeptInfoServiceImpl extends ServiceImpl docWrapper = new LambdaQueryWrapper<>(); - docWrapper.eq(HpDocInfo::getHosOrgCode, hospitalCode); - docWrapper.eq(HpDocInfo::getOneDeptCode, deptInfo.getOneDeptCode()); + docWrapper.eq(HpDocInfo::getHosOrgCode, hospitalCode) + .eq(HpDocInfo::getOneDeptCode, deptInfo.getOneDeptCode()) + .eq(HpDocInfo::getHasResource, Constant.BYTE_YES); + if (DataConstant.TWO_DEPT.equals(deptInfo.getDeptLevel())) { docWrapper.eq(HpDocInfo::getDeptCode, deptInfo.getDeptCode()); } @@ -103,10 +106,9 @@ public class HpDeptInfoServiceImpl extends ServiceImpl getRemainDoctList(List doctors, List resourceDoctInfo) { Map doctorMap = doctors.stream().collect(Collectors.groupingBy(HpDocInfo::getResourceCode, Collectors.collectingAndThen(Collectors.toList(), x -> x.get(0)))); List remainDoctors = new ArrayList<>(); + remainDoctors.addAll(doctors); resourceDoctInfo.forEach(res -> { - if(doctorMap.containsKey(res.getResourceCode())){ - remainDoctors.add(doctorMap.get(res.getResourceCode())); - }else{ + if (!doctorMap.containsKey(res.getResourceCode())) { HpDocInfo doctor = BeanUtil.toBean(res, HpDocInfo.class); hpDocInfoService.save(doctor); remainDoctors.add(doctor); @@ -161,21 +163,56 @@ public class HpDeptInfoServiceImpl extends ServiceImpl list = WanDaHttpUtil.getOrderNumInfo(numSourceInfo); // // log.error("list = {}", JSONUtil.toJsonStr(list)); + +// NumSourceInfo numSourceInfo = new NumSourceInfo(); +// numSourceInfo.setHosOrgCode(orgCode); +// numSourceInfo.setOneDeptCode(oneDeptCode); +// numSourceInfo.setDeptCode(deptCode); +// numSourceInfo.setOrderType(WanDaConstant.ORDER_TYPE_DOCT); +// numSourceInfo.setResourceCode(docResourceCode); +// numSourceInfo.setPatient_type(WanDaConstant.PATIENT_TYPE_NORMAL); +// numSourceInfo.setStartTime("2022-08-20"); +// numSourceInfo.setEndTime("2022-09-03"); +// List result = WanDaHttpUtil.getOrderNumInfo(numSourceInfo); +// log.error("numSourceInfo = {}", JSONUtil.toJsonStr(result)); + +// NumSourceInfo numSourceInfo = new NumSourceInfo(); +// numSourceInfo.setHosOrgCode(orgCode); +// numSourceInfo.setOneDeptCode(oneDeptCode); +// numSourceInfo.setDeptCode(deptCode); +// numSourceInfo.setOrderType(WanDaConstant.ORDER_TYPE_CLINC); +// numSourceInfo.setResourceCode(deptCode); +// numSourceInfo.setPatient_type(WanDaConstant.PATIENT_TYPE_NORMAL); +// numSourceInfo.setStartTime("2022-08-20"); +// numSourceInfo.setEndTime("2022-09-03"); +// List result = WanDaHttpUtil.getOrderNumInfo(numSourceInfo); +// log.error("numSourceInfo = {}", JSONUtil.toJsonStr(result)); // } /** - * 消化内科 42503527600 上海市瑞金医院卢湾分院 1013 3122 消化科 1 1013 3122 - * 消化内科 Y0180100700 上海交通大学医学院附属第九人民医院黄浦分院 293 3 消化内科 2 293 3 - * 消化内科 42502763900 黄浦区肿瘤防治院 10 0002 消化专科 3 10 0002 - * E7880343800 50 2006 + * Y0180100700 293 3 上海交通大学医学院附属第九人民医院黄浦分院 内科 消化内科 03.02 消化内科 + * Y0180100700 293 6 上海交通大学医学院附属第九人民医院黄浦分院 内科 心血管内科 03.04 心血管内科 * @param args */ // public static void main(String[] args) { -// String orgCode = "E7880343800"; -// String oneDeptCode = "50"; -// String deptCode = "2006"; +// String orgCode = "Y0180100700"; +// String oneDeptCode = "293"; +// String deptCode = "2"; +// String docResourceCode = "175"; // 陈芳 // +// NumSourceInfo numSourceInfo = new NumSourceInfo(); +// numSourceInfo.setHosOrgCode(orgCode); +// numSourceInfo.setOneDeptCode(oneDeptCode); +// numSourceInfo.setDeptCode(deptCode); +// numSourceInfo.setOrderType(WanDaConstant.ORDER_TYPE_DOCT); +// numSourceInfo.setResourceCode(docResourceCode); +// numSourceInfo.setPatient_type(WanDaConstant.PATIENT_TYPE_NORMAL); +// numSourceInfo.setStartTime("2022-08-20"); +// numSourceInfo.setEndTime("2022-09-03"); +// List result = WanDaHttpUtil.getOrderNumInfo(numSourceInfo); +// log.error("numSourceInfo = {}", JSONUtil.toJsonStr(result)); + // HosInfo hosInfo = new HosInfo(); // hosInfo.setHosOrgCode(orgCode); // List oneDeptInfo = WanDaHttpUtil.getDeptInfoTop(hosInfo); 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 475f988..70c3e6a 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 @@ -1,6 +1,7 @@ package cn.sh.stc.sict.theme.hphy.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; 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; @@ -9,7 +10,11 @@ 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 cn.sh.stc.sict.theme.hphy.wd.DeptInfo; +import cn.sh.stc.sict.theme.hphy.wd.HosInfo; +import cn.sh.stc.sict.theme.hphy.wd.NumSourceInfo; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; @@ -41,7 +46,7 @@ public class HpDocInfoServiceImpl extends ServiceImpl getRecommendList(HphyGuideRecord guide, List pythonList) { List result = new ArrayList<>(); - if(CollUtil.isNotEmpty(pythonList)){ + if (CollUtil.isNotEmpty(pythonList)) { 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<>(); @@ -82,4 +87,25 @@ public class HpDocInfoServiceImpl extends ServiceImpl().eq(HpDocInfo::getHosOrgCode, hosOrgCode)); this.saveBatch(docInfos); } + + @Override + public List listByDeptInfo(DeptInfo deptInfo) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(HpDocInfo::getHosOrgCode, deptInfo.getHosOrgCode()) + .eq(HpDocInfo::getOneDeptCode, deptInfo.getOneDeptCode()) + .eq(StrUtil.isNotEmpty(deptInfo.getDeptCode()), HpDocInfo::getDeptCode, deptInfo.getDeptCode()); + return this.list(wrapper); + } + + @Override + public void updateResource(NumSourceInfo num, Byte hasResource) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(HpDocInfo::getHosOrgCode, num.getHosOrgCode()) + .eq(HpDocInfo::getOneDeptCode, num.getOneDeptCode()) + .eq(StrUtil.isNotEmpty(num.getDeptCode()), HpDocInfo::getDeptCode, num.getDeptCode()) + .eq(HpDocInfo::getResourceCode, num.getResourceCode()); + HpDocInfo update = new HpDocInfo(); + update.setHasResource(hasResource); + this.update(update, wrapper); + } } \ No newline at end of file diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/WanDaConstant.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/WanDaConstant.java index bb12b1e..fd91c32 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/WanDaConstant.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/WanDaConstant.java @@ -5,6 +5,7 @@ public class WanDaConstant { /** * 预约类型:1-医生 2-门诊 */ + public static final String ORDER_TYPE_DOCT = "1"; public static final String ORDER_TYPE_OUTP = "1"; public static final String ORDER_TYPE_CLINC = "2"; diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/WanDaHttpUtil.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/WanDaHttpUtil.java index d48911d..821e4a5 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/WanDaHttpUtil.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/wd/WanDaHttpUtil.java @@ -197,28 +197,35 @@ public class WanDaHttpUtil { */ public List getOrderNumInfo(NumSourceInfo numSourceInfo) { String xml = WanDaUtil.GetOrderNumInfoServiceXML(numSourceInfo); - String body = HttpRequest.post(URL) - .body(xml) - .execute() - .body(); - - if (StrUtil.isBlank(body)) { - log.error("号源查询 失败"); - return null; - } - // log.info("号源查询:body = {}", body); - String returnXml = getReturn(body, "GetOrderNumInfoService"); - if (Constant.STRING_NO.equals(getCode(returnXml))) { - Document document = XmlUtil.readXML(returnXml); - NodeList nodeList = document.getElementsByTagName("NumSourceInfo"); - List list = new ArrayList<>(); - if (null != nodeList && nodeList.getLength() > 0) { - for (int i = 0; i < nodeList.getLength(); i++) { - list.add(XmlUtil.xmlToBean(nodeList.item(i), NumSourceInfo.class)); + String body = ""; + try { + body = HttpRequest.post(URL) + .body(xml) + .execute() + .body(); + + if (StrUtil.isBlank(body)) { + log.error("号源查询 失败"); + return null; + } + String returnXml = getReturn(body, "GetOrderNumInfoService"); + if (Constant.STRING_NO.equals(getCode(returnXml))) { + Document document = XmlUtil.readXML(returnXml); + NodeList nodeList = document.getElementsByTagName("NumSourceInfo"); + List list = new ArrayList<>(); + if (null != nodeList && nodeList.getLength() > 0) { + for (int i = 0; i < nodeList.getLength(); i++) { + list.add(XmlUtil.xmlToBean(nodeList.item(i), NumSourceInfo.class)); + } } + return list; + } else { + return null; } - return list; - } else { + }catch (Exception e){ + log.error("号源查询失败,num = {}", JSONUtil.toJsonStr(numSourceInfo)); + log.error("号源查询失败,body = {}", body); + log.error(e.getMessage(), e); return null; } } @@ -416,7 +423,7 @@ public class WanDaHttpUtil { */ public List getResourceDoctInfo(DeptInfo deptInfo) { String xml = WanDaUtil.GetResourceDoctInfoServiceXML(deptInfo); - + //log.error("获取可预约医生信息 xml = {}", xml); String body = HttpRequest.post(URL) .body(xml) .execute() @@ -426,7 +433,7 @@ public class WanDaHttpUtil { log.error("获取可预约医生信息 失败"); return null; } - // log.info("获取可预约医生信息:body = {}", body); + //log.info("获取可预约医生信息:body = {}", body); String returnXml = getReturn(body, "GetResourceDoctInfoService"); return serialDoctInfo(returnXml); } @@ -439,7 +446,7 @@ public class WanDaHttpUtil { */ public List getResourceOutPatInfo(DeptInfo deptInfo) { String xml = WanDaUtil.GetResourceOutPatInfoServiceXML(deptInfo); - // log.error("xml = {}", xml); + //log.error("获取可预约门诊信息 xml = {}", xml); String body = HttpRequest.post(URL) .body(xml) .execute() @@ -449,7 +456,7 @@ public class WanDaHttpUtil { log.error("查询门诊信息失败"); return null; } - // log.info("查询门诊信息:body = {}", body); + //log.info("查询门诊信息:body = {}", body); String returnXml = getReturn(body, "GetResourceOutPatInfoService"); return serialOutPatInfo(returnXml); } -- 2.22.0