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 ffc592439333e282e0435ed67cc7e2c80ddb9fbd..ac16b2b8e422f0f739a0daf80f0396cc4752c2b4 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 6bab7771f720e23f10b9ae0b4f7cbea5fbb91734..847f3d57f8890ffbe960a42f404b4a5466899a23 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 c4eb2da5e762f98ec7529a2841dedb112e78bc91..887c9435385f8d8ee79681a5e6616b27e287a0ee 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 416a1f2156c4d83b862b2e68a6f4553f2216d4ce..a9eb413bd9b02d7f166d069b785208c4b4d101aa 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 3c128065da92a37b439efaee3c4778d4fd39b9cd..7fe299f44d24ef5ff0f307413aaab85ecfd0f0c9 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 7e8973cf6b300b2b7ed422818aeb29c739c051b6..5a3f3c4b13aeeec9a6e00fd512968df8b4a3962d 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