Commit 4f5cb72f authored by gaozhaochen's avatar gaozhaochen

update: 科室、医院数据更新时,先删除后更新,失败回滚

parent adad9945
...@@ -5,6 +5,7 @@ import cn.sh.stc.sict.cloud.common.log.annotation.SysLog; ...@@ -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.common.security.util.SecurityUtils;
import cn.sh.stc.sict.cloud.upms.dto.CurrentUser; import cn.sh.stc.sict.cloud.upms.dto.CurrentUser;
import cn.sh.stc.sict.theme.common.crypto.EncryptionUtil; 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.HpStatisticsService;
import cn.sh.stc.sict.theme.hphy.service.HpThirdInterfaceStatusService; import cn.sh.stc.sict.theme.hphy.service.HpThirdInterfaceStatusService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -30,6 +31,8 @@ public class HpStatisticsController { ...@@ -30,6 +31,8 @@ public class HpStatisticsController {
private final HpThirdInterfaceStatusService hpThirdInterfaceStatusService; private final HpThirdInterfaceStatusService hpThirdInterfaceStatusService;
private final RefreshJob refreshJob;
@ApiOperation("统计用户使用情况") @ApiOperation("统计用户使用情况")
@GetMapping("/usage-overview") @GetMapping("/usage-overview")
public R statisticsUsage(@RequestParam("startTime") String startTime, public R statisticsUsage(@RequestParam("startTime") String startTime,
...@@ -64,4 +67,20 @@ public class HpStatisticsController { ...@@ -64,4 +67,20 @@ public class HpStatisticsController {
return new R(); 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();
}
} }
...@@ -62,10 +62,7 @@ public class RefreshJob { ...@@ -62,10 +62,7 @@ public class RefreshJob {
MapperFactory factory = new DefaultMapperFactory.Builder().build(); MapperFactory factory = new DefaultMapperFactory.Builder().build();
List<HpHosInfo> hpHosInfos = factory.getMapperFacade().mapAsList(list, HpHosInfo.class); List<HpHosInfo> hpHosInfos = factory.getMapperFacade().mapAsList(list, HpHosInfo.class);
hpHosInfoService.saveHospital(hpHosInfos);
for (HpHosInfo hpHosInfo : hpHosInfos) {
saveOrUpdateHospital(hpHosInfo);
}
} }
/** /**
...@@ -80,11 +77,13 @@ public class RefreshJob { ...@@ -80,11 +77,13 @@ public class RefreshJob {
MapperFactory factory = new DefaultMapperFactory.Builder().build(); MapperFactory factory = new DefaultMapperFactory.Builder().build();
for (HpHosInfo hospital : hospitals) { 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 { ...@@ -158,6 +157,26 @@ public class RefreshJob {
} }
} }
private void saveOrUpdateDept(String hosOrgCode, MapperFactory factory) {
// 一级科室
List<DeptInfo> deptInfos = WanDaHttpUtil.getDeptInfoTop(new HosInfo(hosOrgCode));
if (CollectionUtil.isEmpty(deptInfos)) {
return;
}
List<HpDeptInfo> hpDeptInfos = cloneTopDept(deptInfos);
deptInfoService.saveDept(hosOrgCode, hpDeptInfos, DataConstant.TOP_DEPT);
// 二级科室
List<DeptInfo> twoDeptInfos = WanDaHttpUtil.getDeptInfoTwo(new DeptInfo(hosOrgCode));
if (CollectionUtil.isEmpty(twoDeptInfos)) {
return;
}
List<HpDeptInfo> twoDeptList = factory.getMapperFacade().mapAsList(twoDeptInfos, HpDeptInfo.class);
deptInfoService.saveDept(hosOrgCode, twoDeptList, DataConstant.TWO_DEPT);
}
private void saveOrUpdateTopDept(String hosOrgCode) { private void saveOrUpdateTopDept(String hosOrgCode) {
List<DeptInfo> deptInfos = WanDaHttpUtil.getDeptInfoTop(new HosInfo(hosOrgCode)); List<DeptInfo> deptInfos = WanDaHttpUtil.getDeptInfoTop(new HosInfo(hosOrgCode));
if (CollectionUtil.isEmpty(deptInfos)) { if (CollectionUtil.isEmpty(deptInfos)) {
......
...@@ -4,6 +4,8 @@ import cn.sh.stc.sict.theme.hphy.model.HpDeptInfo; ...@@ -4,6 +4,8 @@ import cn.sh.stc.sict.theme.hphy.model.HpDeptInfo;
import cn.sh.stc.sict.theme.hphy.vo.DeptDoctorsVO; import cn.sh.stc.sict.theme.hphy.vo.DeptDoctorsVO;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/** /**
* (HpDeptInfo)表服务接口 * (HpDeptInfo)表服务接口
* *
...@@ -22,7 +24,7 @@ public interface HpDeptInfoService extends IService<HpDeptInfo> { ...@@ -22,7 +24,7 @@ public interface HpDeptInfoService extends IService<HpDeptInfo> {
void asyncUpdate(HpDeptInfo dept); void asyncUpdate(HpDeptInfo dept);
void saveDept(String hosOrgCode, List<HpDeptInfo> deptList, Byte deptLevel);
} }
package cn.sh.stc.sict.theme.hphy.service; 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 cn.sh.stc.sict.theme.hphy.model.HpHosInfo;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/** /**
* (HpHosInfo)表服务接口 * (HpHosInfo)表服务接口
* *
...@@ -16,4 +19,6 @@ public interface HpHosInfoService extends IService<HpHosInfo> { ...@@ -16,4 +19,6 @@ public interface HpHosInfoService extends IService<HpHosInfo> {
* @return true-存在;false-不存在 * @return true-存在;false-不存在
*/ */
boolean hospitalExist(String hosOrgCode); boolean hospitalExist(String hosOrgCode);
void saveHospital(List<HpHosInfo> hosInfos);
} }
\ No newline at end of file
...@@ -23,6 +23,7 @@ import lombok.AllArgsConstructor; ...@@ -23,6 +23,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -118,7 +119,17 @@ public class HpDeptInfoServiceImpl extends ServiceImpl<HpDeptInfoMapper, HpDeptI ...@@ -118,7 +119,17 @@ public class HpDeptInfoServiceImpl extends ServiceImpl<HpDeptInfoMapper, HpDeptI
return remainDoctors; return remainDoctors;
} }
// public static void main(String[] args) { @Override
@Transactional(rollbackFor = Exception.class)
public void saveDept(String hosOrgCode, List<HpDeptInfo> deptList, Byte deptLevel) {
this.remove(new LambdaQueryWrapper<HpDeptInfo>()
.eq(HpDeptInfo::getHosOrgCode, hosOrgCode)
.eq(HpDeptInfo::getDeptLevel, deptLevel)
);
this.saveBatch(deptList);
}
// public static void main(String[] args) {
// //
// DeptInfo info = new DeptInfo(); // DeptInfo info = new DeptInfo();
// info.setHosOrgCode("Y0180100700"); // info.setHosOrgCode("Y0180100700");
......
package cn.sh.stc.sict.theme.hphy.service.impl; 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.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.model.HpHosInfo;
import cn.sh.stc.sict.theme.hphy.service.HpHosInfoService; 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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* (HpHosInfo)表服务实现类 * (HpHosInfo)表服务实现类
...@@ -19,4 +24,11 @@ public class HpHosInfoServiceImpl extends ServiceImpl<HpHosInfoMapper, HpHosInfo ...@@ -19,4 +24,11 @@ public class HpHosInfoServiceImpl extends ServiceImpl<HpHosInfoMapper, HpHosInfo
public boolean hospitalExist(String hosOrgCode) { public boolean hospitalExist(String hosOrgCode) {
return this.getById(hosOrgCode) != null; return this.getById(hosOrgCode) != null;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public void saveHospital(List<HpHosInfo> hosInfos) {
this.remove(new LambdaQueryWrapper<>());
this.saveBatch(hosInfos);
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment