From 4f5cb72f95635f8fead23bca1702d1f7799179b9 Mon Sep 17 00:00:00 2001 From: gaozhaochen Date: Wed, 11 Oct 2023 17:20:00 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E7=A7=91=E5=AE=A4=E3=80=81=E5=8C=BB?= =?UTF-8?q?=E9=99=A2=E6=95=B0=E6=8D=AE=E6=9B=B4=E6=96=B0=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=85=88=E5=88=A0=E9=99=A4=E5=90=8E=E6=9B=B4=E6=96=B0=EF=BC=8C?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=9B=9E=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/HpStatisticsController.java | 19 ++++++++++++ .../sict/theme/hphy/schedule/RefreshJob.java | 31 +++++++++++++++---- .../theme/hphy/service/HpDeptInfoService.java | 4 ++- .../theme/hphy/service/HpHosInfoService.java | 5 +++ .../service/impl/HpDeptInfoServiceImpl.java | 13 +++++++- .../service/impl/HpHosInfoServiceImpl.java | 12 +++++++ 6 files changed, 76 insertions(+), 8 deletions(-) diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/web/HpStatisticsController.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/web/HpStatisticsController.java index ffc5924..ac16b2b 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/web/HpStatisticsController.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/web/HpStatisticsController.java @@ -5,6 +5,7 @@ import cn.sh.stc.sict.cloud.common.log.annotation.SysLog; 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.crypto.EncryptionUtil; +import cn.sh.stc.sict.theme.hphy.schedule.RefreshJob; import cn.sh.stc.sict.theme.hphy.service.HpStatisticsService; import cn.sh.stc.sict.theme.hphy.service.HpThirdInterfaceStatusService; import io.swagger.annotations.Api; @@ -30,6 +31,8 @@ public class HpStatisticsController { private final HpThirdInterfaceStatusService hpThirdInterfaceStatusService; + private final RefreshJob refreshJob; + @ApiOperation("统计用户使用情况") @GetMapping("/usage-overview") public R statisticsUsage(@RequestParam("startTime") String startTime, @@ -64,4 +67,20 @@ public class HpStatisticsController { return new R(); } + @ApiOperation("采集万达接口的医院、科室、患者数据") + @PutMapping("/gather-wd") + @SysLog + public R gatherHosDeptDoc(@RequestParam("tag") String tag) { + if(tag.contains("hos")){ + refreshJob.updateHosp(); + } + if(tag.contains("dept")){ + refreshJob.updateDept(); + } + if(tag.contains("doc")){ + refreshJob.updateDocInfo(); + } + return new R(); + } + } 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 6bab777..847f3d5 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 @@ -62,10 +62,7 @@ public class RefreshJob { MapperFactory factory = new DefaultMapperFactory.Builder().build(); List hpHosInfos = factory.getMapperFacade().mapAsList(list, HpHosInfo.class); - - for (HpHosInfo hpHosInfo : hpHosInfos) { - saveOrUpdateHospital(hpHosInfo); - } + hpHosInfoService.saveHospital(hpHosInfos); } /** @@ -80,11 +77,13 @@ public class RefreshJob { MapperFactory factory = new DefaultMapperFactory.Builder().build(); + for (HpHosInfo hospital : hospitals) { + saveOrUpdateDept(hospital.getHosOrgCode(), factory); // 获取一级科室 - saveOrUpdateTopDept(hospital.getHosOrgCode()); + // saveOrUpdateTopDept(hospital.getHosOrgCode()); // 获取二级科室 - saveOrUpdateTwoDept(hospital.getHosOrgCode(), factory); + // saveOrUpdateTwoDept(hospital.getHosOrgCode(), factory); } } @@ -158,6 +157,26 @@ public class RefreshJob { } } + private void saveOrUpdateDept(String hosOrgCode, MapperFactory factory) { + // 一级科室 + List deptInfos = WanDaHttpUtil.getDeptInfoTop(new HosInfo(hosOrgCode)); + if (CollectionUtil.isEmpty(deptInfos)) { + return; + } + List hpDeptInfos = cloneTopDept(deptInfos); + deptInfoService.saveDept(hosOrgCode, hpDeptInfos, DataConstant.TOP_DEPT); + + // 二级科室 + List twoDeptInfos = WanDaHttpUtil.getDeptInfoTwo(new DeptInfo(hosOrgCode)); + if (CollectionUtil.isEmpty(twoDeptInfos)) { + return; + } + + List twoDeptList = factory.getMapperFacade().mapAsList(twoDeptInfos, HpDeptInfo.class); + deptInfoService.saveDept(hosOrgCode, twoDeptList, DataConstant.TWO_DEPT); + + } + private void saveOrUpdateTopDept(String hosOrgCode) { List deptInfos = WanDaHttpUtil.getDeptInfoTop(new HosInfo(hosOrgCode)); if (CollectionUtil.isEmpty(deptInfos)) { diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpDeptInfoService.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpDeptInfoService.java index c4eb2da..887c943 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpDeptInfoService.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpDeptInfoService.java @@ -4,6 +4,8 @@ import cn.sh.stc.sict.theme.hphy.model.HpDeptInfo; import cn.sh.stc.sict.theme.hphy.vo.DeptDoctorsVO; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** * (HpDeptInfo)表服务接口 * @@ -22,7 +24,7 @@ public interface HpDeptInfoService extends IService { void asyncUpdate(HpDeptInfo dept); - + void saveDept(String hosOrgCode, List deptList, Byte deptLevel); } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpHosInfoService.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpHosInfoService.java index 416a1f2..a9eb413 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpHosInfoService.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpHosInfoService.java @@ -1,8 +1,11 @@ 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.HpHosInfo; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** * (HpHosInfo)表服务接口 * @@ -16,4 +19,6 @@ public interface HpHosInfoService extends IService { * @return true-存在;false-不存在 */ boolean hospitalExist(String hosOrgCode); + + void saveHospital(List hosInfos); } \ 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 3c12806..7fe299f 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 @@ -23,6 +23,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -118,7 +119,17 @@ public class HpDeptInfoServiceImpl extends ServiceImpl deptList, Byte deptLevel) { + this.remove(new LambdaQueryWrapper() + .eq(HpDeptInfo::getHosOrgCode, hosOrgCode) + .eq(HpDeptInfo::getDeptLevel, deptLevel) + ); + this.saveBatch(deptList); + } + + // public static void main(String[] args) { // // DeptInfo info = new DeptInfo(); // info.setHosOrgCode("Y0180100700"); diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpHosInfoServiceImpl.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpHosInfoServiceImpl.java index 7e8973c..5a3f3c4 100644 --- a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpHosInfoServiceImpl.java +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpHosInfoServiceImpl.java @@ -1,10 +1,15 @@ package cn.sh.stc.sict.theme.hphy.service.impl; import cn.sh.stc.sict.theme.hphy.dao.HpHosInfoMapper; +import cn.sh.stc.sict.theme.hphy.model.HpDocInfo; import cn.sh.stc.sict.theme.hphy.model.HpHosInfo; import cn.sh.stc.sict.theme.hphy.service.HpHosInfoService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; /** * (HpHosInfo)表服务实现类 @@ -19,4 +24,11 @@ public class HpHosInfoServiceImpl extends ServiceImpl hosInfos) { + this.remove(new LambdaQueryWrapper<>()); + this.saveBatch(hosInfos); + } } \ No newline at end of file -- 2.22.0