Commit edc1fe66 authored by fshenye's avatar fshenye

1. 提供单个科室统计号源功能

2. 号源统计时,科室内医生也统计号源
3. 号源统计时,标记数据库中医生是否有号源
4. 查询科室医生时,从库中查,综合万达接口的返回
parent e31be677
...@@ -24,7 +24,7 @@ public interface HpgpBusyIdlePredictionService extends IService<HpgpBusyIdlePred ...@@ -24,7 +24,7 @@ public interface HpgpBusyIdlePredictionService extends IService<HpgpBusyIdlePred
*/ */
List<HpgpBusyIdlePrediction> busyIdlePrediction(String deptName); List<HpgpBusyIdlePrediction> busyIdlePrediction(String deptName);
void statisticResourceInfo(HpgpDepartmentRank dept, Date startDate, Date endDate); void statisticResourceInfo(HpgpDepartmentRank dept, Date startDate, Date endDate, Byte flag);
List<HpgpBusyIdlePrediction> listByDeptRank(HpgpDepartmentRank dept, DateTime startTime, DateTime endTime); List<HpgpBusyIdlePrediction> listByDeptRank(HpgpDepartmentRank dept, DateTime startTime, DateTime endTime);
} }
...@@ -5,7 +5,9 @@ import cn.hutool.core.collection.CollectionUtil; ...@@ -5,7 +5,9 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; 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.NumberUtil;
import cn.sh.stc.sict.theme.hpgp.dao.HpgpBusyIdlePredictionMapper; import cn.sh.stc.sict.theme.hpgp.dao.HpgpBusyIdlePredictionMapper;
import cn.sh.stc.sict.theme.hpgp.dao.HpgpDepartmentRankMapper; import cn.sh.stc.sict.theme.hpgp.dao.HpgpDepartmentRankMapper;
...@@ -13,6 +15,8 @@ import cn.sh.stc.sict.theme.hpgp.model.HpgpBusyIdlePrediction; ...@@ -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.model.HpgpDepartmentRank;
import cn.sh.stc.sict.theme.hpgp.service.HpgpBusyIdlePredictionService; import cn.sh.stc.sict.theme.hpgp.service.HpgpBusyIdlePredictionService;
import cn.sh.stc.sict.theme.hpgp.vo.DeptRankVO; 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 cn.sh.stc.sict.theme.hphy.wd.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -35,6 +39,7 @@ import java.util.stream.Collectors; ...@@ -35,6 +39,7 @@ import java.util.stream.Collectors;
@Service("hpgpBusyIdlPredictionService") @Service("hpgpBusyIdlPredictionService")
public class HpgpBusyIdlePredictionServiceImpl extends ServiceImpl<HpgpBusyIdlePredictionMapper, HpgpBusyIdlePrediction> implements HpgpBusyIdlePredictionService { public class HpgpBusyIdlePredictionServiceImpl extends ServiceImpl<HpgpBusyIdlePredictionMapper, HpgpBusyIdlePrediction> implements HpgpBusyIdlePredictionService {
private final HpgpDepartmentRankMapper departmentRankMapper; private final HpgpDepartmentRankMapper departmentRankMapper;
private final HpDocInfoService hpDocInfoService;
@Override @Override
public List<HpgpBusyIdlePrediction> busyIdlePrediction(String deptName) { public List<HpgpBusyIdlePrediction> busyIdlePrediction(String deptName) {
...@@ -66,30 +71,39 @@ public class HpgpBusyIdlePredictionServiceImpl extends ServiceImpl<HpgpBusyIdleP ...@@ -66,30 +71,39 @@ public class HpgpBusyIdlePredictionServiceImpl extends ServiceImpl<HpgpBusyIdleP
return vo; return vo;
} }
@Async // @Async
@Override @Override
public void statisticResourceInfo(HpgpDepartmentRank dept, Date startDate, Date endDate) { public void statisticResourceInfo(HpgpDepartmentRank dept, Date startDate, Date endDate, Byte flag) {
DeptInfo deptInfo = new DeptInfo(); try {
deptInfo.setHosOrgCode(dept.getHospitalCode()); DeptInfo deptInfo = new DeptInfo();
deptInfo.setOneDeptCode(dept.getOneDeptCode()); deptInfo.setHosOrgCode(dept.getHospitalCode());
deptInfo.setDeptCode(dept.getDeptCode()); deptInfo.setOneDeptCode(dept.getOneDeptCode());
List<OutPatInfo> outList = WanDaHttpUtil.getResourceOutPatInfo(deptInfo); deptInfo.setDeptCode(dept.getDeptCode());
List<DoctInfo> docList = WanDaHttpUtil.getResourceDoctInfo(deptInfo); List<OutPatInfo> outList = WanDaHttpUtil.getResourceOutPatInfo(deptInfo);
if (CollUtil.isEmpty(outList) && CollUtil.isEmpty(docList)) { List<DoctInfo> docList = WanDaHttpUtil.getResourceDoctInfo(deptInfo);
return; List<HpDocInfo> hpDocList = hpDocInfoService.listByDeptInfo(deptInfo);
} if (CollUtil.isEmpty(outList) && CollUtil.isEmpty(docList) && CollUtil.isEmpty(hpDocList)) {
Map<String, HpgpBusyIdlePrediction> dateResultMap = new HashMap<>(); return;
this.getOutResourceInfo(dept, outList, dateResultMap, startDate, endDate); }
this.getDocResourceInfo(dept, docList, dateResultMap, startDate, endDate); Map<String, HpgpBusyIdlePrediction> dateResultMap = new HashMap<>();
if (CollUtil.isNotEmpty(dateResultMap)) { this.getOutResourceInfo(dept, outList, dateResultMap, startDate, endDate);
dateResultMap.forEach((k, v) -> { this.getDocResourceInfo(dept, docList, dateResultMap, startDate, endDate);
LambdaQueryWrapper<HpgpBusyIdlePrediction> wrapper = new LambdaQueryWrapper<>(); if (Constant.BYTE_YES.equals(flag)) {
wrapper.eq(HpgpBusyIdlePrediction::getHospitalCode, v.getHospitalCode()) this.getHpDocResourceInfo(dept, hpDocList, docList, dateResultMap, startDate, endDate);
.eq(HpgpBusyIdlePrediction::getOneDeptCode, v.getOneDeptCode()) }
.eq(HpgpBusyIdlePrediction::getDeptCode, v.getDeptCode()) if (CollUtil.isNotEmpty(dateResultMap)) {
.eq(HpgpBusyIdlePrediction::getPredictionDate, v.getPredictionDate()); dateResultMap.forEach((k, v) -> {
this.saveOrUpdate(v, wrapper); LambdaQueryWrapper<HpgpBusyIdlePrediction> 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<HpgpBusyIdleP ...@@ -141,6 +155,53 @@ public class HpgpBusyIdlePredictionServiceImpl extends ServiceImpl<HpgpBusyIdleP
numSourceInfo.setResourceCode(doc.getResourceCode()); numSourceInfo.setResourceCode(doc.getResourceCode());
List<NumSourceInfo> orderNumInfo = WanDaHttpUtil.getOrderNumInfo(numSourceInfo); List<NumSourceInfo> orderNumInfo = WanDaHttpUtil.getOrderNumInfo(numSourceInfo);
if (CollUtil.isNotEmpty(orderNumInfo)) { if (CollUtil.isNotEmpty(orderNumInfo)) {
hpDocInfoService.updateResource(numSourceInfo, Constant.BYTE_YES);
Map<String, List<NumSourceInfo>> 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<HpDocInfo> hpDocList, List<DoctInfo> docList,
Map<String, HpgpBusyIdlePrediction> dateResultMap,
Date startDate,
Date endDate) {
Set<String> 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<NumSourceInfo> orderNumInfo = WanDaHttpUtil.getOrderNumInfo(numSourceInfo);
if (CollUtil.isNotEmpty(orderNumInfo)) {
hpDocInfoService.updateResource(numSourceInfo, Constant.BYTE_YES);
Map<String, List<NumSourceInfo>> dateMap = orderNumInfo.stream().collect(Collectors.groupingBy(NumSourceInfo::getScheduleDate)); Map<String, List<NumSourceInfo>> dateMap = orderNumInfo.stream().collect(Collectors.groupingBy(NumSourceInfo::getScheduleDate));
dateMap.forEach((date, numList) -> { dateMap.forEach((date, numList) -> {
HpgpBusyIdlePrediction vo = dateResultMap.getOrDefault(date, new HpgpBusyIdlePrediction()); HpgpBusyIdlePrediction vo = dateResultMap.getOrDefault(date, new HpgpBusyIdlePrediction());
...@@ -157,6 +218,8 @@ public class HpgpBusyIdlePredictionServiceImpl extends ServiceImpl<HpgpBusyIdleP ...@@ -157,6 +218,8 @@ public class HpgpBusyIdlePredictionServiceImpl extends ServiceImpl<HpgpBusyIdleP
vo.setScoreByNum(); vo.setScoreByNum();
dateResultMap.put(date, vo); dateResultMap.put(date, vo);
}); });
} else {
hpDocInfoService.updateResource(numSourceInfo, Constant.BYTE_NO);
} }
}); });
} }
......
...@@ -3,12 +3,15 @@ package cn.sh.stc.sict.theme.hphy.controller.mp; ...@@ -3,12 +3,15 @@ package cn.sh.stc.sict.theme.hphy.controller.mp;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.sh.stc.sict.cloud.common.core.constant.Constant;
import cn.sh.stc.sict.cloud.common.core.util.R; import cn.sh.stc.sict.cloud.common.core.util.R;
import cn.sh.stc.sict.theme.hpgp.model.HpgpDepartmentRank; 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.HpgpBusyIdlePredictionService;
import cn.sh.stc.sict.theme.hpgp.service.HpgpDepartmentRankService; import cn.sh.stc.sict.theme.hpgp.service.HpgpDepartmentRankService;
import cn.sh.stc.sict.theme.hphy.model.HpDeptInfo; import cn.sh.stc.sict.theme.hphy.model.HpDeptInfo;
import cn.sh.stc.sict.theme.hphy.service.HpDeptInfoService; import cn.sh.stc.sict.theme.hphy.service.HpDeptInfoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.api.ApiController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -67,15 +70,22 @@ public class HpDeptInfoController extends ApiController { ...@@ -67,15 +70,22 @@ public class HpDeptInfoController extends ApiController {
@ApiOperation("定时统计排行科室的号源信息") @ApiOperation("定时统计排行科室的号源信息")
@PostMapping("/statistic/rank/wd/resource") @PostMapping("/statistic/rank/wd/resource")
public R statisticRankDeptResourceInfo() { public R statisticRankDeptResourceInfo(@RequestParam(value = "hospCode", required = false) String hospCode,
List<HpgpDepartmentRank> deptList = hpgpDepartmentRankService.list(); @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<HpgpDepartmentRank> 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<HpgpDepartmentRank> deptList = hpgpDepartmentRankService.list(wrapper);
deptList.forEach(dept -> { deptList.forEach(dept -> {
if (StrUtil.isEmpty(dept.getOneDeptCode()) || StrUtil.isEmpty(dept.getDeptCode())) { if (StrUtil.isEmpty(dept.getOneDeptCode()) || StrUtil.isEmpty(dept.getDeptCode())) {
return; return;
} }
Date startDate = DateUtil.date(); Date startDate = DateUtil.date();
Date endDate = DateUtil.offsetDay(startDate, 10); Date endDate = DateUtil.offsetDay(startDate, 10);
hpgpBusyIdlePredictionService.statisticResourceInfo(dept, startDate, endDate); hpgpBusyIdlePredictionService.statisticResourceInfo(dept, startDate, endDate, flag);
}); });
return new R(); return new R();
} }
......
...@@ -23,4 +23,5 @@ public class HpDocInfoController extends ApiController { ...@@ -23,4 +23,5 @@ public class HpDocInfoController extends ApiController {
* 服务对象 * 服务对象
*/ */
private final HpDocInfoService hpDocInfoService; private final HpDocInfoService hpDocInfoService;
} }
\ No newline at end of file
...@@ -55,6 +55,8 @@ public class HpDocInfo extends Model<HpDocInfo> { ...@@ -55,6 +55,8 @@ public class HpDocInfo extends Model<HpDocInfo> {
@ApiModelProperty(hidden = false, value = "是否有资源(0有,1无)") @ApiModelProperty(hidden = false, value = "是否有资源(0有,1无)")
private String isResource; private String isResource;
private Byte hasResource;
/** /**
* 获取主键值 * 获取主键值
......
...@@ -3,6 +3,7 @@ package cn.sh.stc.sict.theme.hphy.schedule; ...@@ -3,6 +3,7 @@ package cn.sh.stc.sict.theme.hphy.schedule;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; 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.model.HpgpDepartmentRank;
import cn.sh.stc.sict.theme.hpgp.service.HpgpBusyIdlePredictionService; import cn.sh.stc.sict.theme.hpgp.service.HpgpBusyIdlePredictionService;
import cn.sh.stc.sict.theme.hpgp.service.HpgpDepartmentRankService; import cn.sh.stc.sict.theme.hpgp.service.HpgpDepartmentRankService;
...@@ -121,7 +122,7 @@ public class RefreshJob { ...@@ -121,7 +122,7 @@ public class RefreshJob {
} }
Date startDate = DateUtil.date(); Date startDate = DateUtil.date();
Date endDate = DateUtil.offsetDay(startDate, 10); Date endDate = DateUtil.offsetDay(startDate, 10);
hpgpBusyIdlePredictionService.statisticResourceInfo(dept, startDate, endDate); hpgpBusyIdlePredictionService.statisticResourceInfo(dept, startDate, endDate, Constant.BYTE_NO);
}); });
} }
......
...@@ -4,6 +4,8 @@ import cn.sh.stc.sict.theme.hphy.model.HpDocInfo; ...@@ -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.model.HphyGuideRecord;
import cn.sh.stc.sict.theme.hphy.vo.DoctorMatchVO; 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.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 com.baomidou.mybatisplus.extension.service.IService;
import java.util.List; import java.util.List;
...@@ -26,4 +28,8 @@ public interface HpDocInfoService extends IService<HpDocInfo> { ...@@ -26,4 +28,8 @@ public interface HpDocInfoService extends IService<HpDocInfo> {
List<DoctorMatchVO> getRecommendList(HphyGuideRecord guide, List<PythonResult> pythonList); List<DoctorMatchVO> getRecommendList(HphyGuideRecord guide, List<PythonResult> pythonList);
void saveDoctor(List<HpDocInfo> docInfos, String hosOrgCode); void saveDoctor(List<HpDocInfo> docInfos, String hosOrgCode);
List<HpDocInfo> listByDeptInfo(DeptInfo deptInfo);
void updateResource(NumSourceInfo numSourceInfo, Byte hasResource);
} }
\ No newline at end of file
...@@ -2,14 +2,10 @@ package cn.sh.stc.sict.theme.hphy.service.impl; ...@@ -2,14 +2,10 @@ package cn.sh.stc.sict.theme.hphy.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; 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.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.constant.DataConstant;
import cn.sh.stc.sict.theme.hphy.dao.HpDeptInfoMapper; 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.HpDeptInfo;
import cn.sh.stc.sict.theme.hphy.model.HpDocInfo; 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;
...@@ -17,7 +13,10 @@ import cn.sh.stc.sict.theme.hphy.service.HpDeptInfoService; ...@@ -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.HpDocInfoService;
import cn.sh.stc.sict.theme.hphy.service.HpHosInfoService; 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.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.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -25,7 +24,9 @@ import lombok.extern.slf4j.Slf4j; ...@@ -25,7 +24,9 @@ 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 java.util.*; import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -60,8 +61,10 @@ public class HpDeptInfoServiceImpl extends ServiceImpl<HpDeptInfoMapper, HpDeptI ...@@ -60,8 +61,10 @@ public class HpDeptInfoServiceImpl extends ServiceImpl<HpDeptInfoMapper, HpDeptI
} }
LambdaQueryWrapper<HpDocInfo> docWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<HpDocInfo> docWrapper = new LambdaQueryWrapper<>();
docWrapper.eq(HpDocInfo::getHosOrgCode, hospitalCode); docWrapper.eq(HpDocInfo::getHosOrgCode, hospitalCode)
docWrapper.eq(HpDocInfo::getOneDeptCode, deptInfo.getOneDeptCode()); .eq(HpDocInfo::getOneDeptCode, deptInfo.getOneDeptCode())
.eq(HpDocInfo::getHasResource, Constant.BYTE_YES);
if (DataConstant.TWO_DEPT.equals(deptInfo.getDeptLevel())) { if (DataConstant.TWO_DEPT.equals(deptInfo.getDeptLevel())) {
docWrapper.eq(HpDocInfo::getDeptCode, deptInfo.getDeptCode()); docWrapper.eq(HpDocInfo::getDeptCode, deptInfo.getDeptCode());
} }
...@@ -103,10 +106,9 @@ public class HpDeptInfoServiceImpl extends ServiceImpl<HpDeptInfoMapper, HpDeptI ...@@ -103,10 +106,9 @@ public class HpDeptInfoServiceImpl extends ServiceImpl<HpDeptInfoMapper, HpDeptI
private List<HpDocInfo> getRemainDoctList(List<HpDocInfo> doctors, List<DoctInfo> resourceDoctInfo) { private List<HpDocInfo> getRemainDoctList(List<HpDocInfo> doctors, List<DoctInfo> resourceDoctInfo) {
Map<String, HpDocInfo> doctorMap = doctors.stream().collect(Collectors.groupingBy(HpDocInfo::getResourceCode, Collectors.collectingAndThen(Collectors.toList(), x -> x.get(0)))); Map<String, HpDocInfo> doctorMap = doctors.stream().collect(Collectors.groupingBy(HpDocInfo::getResourceCode, Collectors.collectingAndThen(Collectors.toList(), x -> x.get(0))));
List<HpDocInfo> remainDoctors = new ArrayList<>(); List<HpDocInfo> remainDoctors = new ArrayList<>();
remainDoctors.addAll(doctors);
resourceDoctInfo.forEach(res -> { resourceDoctInfo.forEach(res -> {
if(doctorMap.containsKey(res.getResourceCode())){ if (!doctorMap.containsKey(res.getResourceCode())) {
remainDoctors.add(doctorMap.get(res.getResourceCode()));
}else{
HpDocInfo doctor = BeanUtil.toBean(res, HpDocInfo.class); HpDocInfo doctor = BeanUtil.toBean(res, HpDocInfo.class);
hpDocInfoService.save(doctor); hpDocInfoService.save(doctor);
remainDoctors.add(doctor); remainDoctors.add(doctor);
...@@ -161,21 +163,56 @@ public class HpDeptInfoServiceImpl extends ServiceImpl<HpDeptInfoMapper, HpDeptI ...@@ -161,21 +163,56 @@ public class HpDeptInfoServiceImpl extends ServiceImpl<HpDeptInfoMapper, HpDeptI
// List<NumSourceInfo> list = WanDaHttpUtil.getOrderNumInfo(numSourceInfo); // List<NumSourceInfo> list = WanDaHttpUtil.getOrderNumInfo(numSourceInfo);
// //
// log.error("list = {}", JSONUtil.toJsonStr(list)); // 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<NumSourceInfo> 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<NumSourceInfo> result = WanDaHttpUtil.getOrderNumInfo(numSourceInfo);
// log.error("numSourceInfo = {}", JSONUtil.toJsonStr(result));
// } // }
/** /**
* 消化内科 42503527600 上海市瑞金医院卢湾分院 1013 3122 消化科 1 1013 3122 * Y0180100700 293 3 上海交通大学医学院附属第九人民医院黄浦分院 内科 消化内科 03.02 消化内科
* 消化内科 Y0180100700 上海交通大学医学院附属第九人民医院黄浦分院 293 3 消化内科 2 293 3 * Y0180100700 293 6 上海交通大学医学院附属第九人民医院黄浦分院 内科 心血管内科 03.04 心血管内科
* 消化内科 42502763900 黄浦区肿瘤防治院 10 0002 消化专科 3 10 0002
* E7880343800 50 2006
* @param args * @param args
*/ */
// public static void main(String[] args) { // public static void main(String[] args) {
// String orgCode = "E7880343800"; // String orgCode = "Y0180100700";
// String oneDeptCode = "50"; // String oneDeptCode = "293";
// String deptCode = "2006"; // 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<NumSourceInfo> result = WanDaHttpUtil.getOrderNumInfo(numSourceInfo);
// log.error("numSourceInfo = {}", JSONUtil.toJsonStr(result));
// HosInfo hosInfo = new HosInfo(); // HosInfo hosInfo = new HosInfo();
// hosInfo.setHosOrgCode(orgCode); // hosInfo.setHosOrgCode(orgCode);
// List<DeptInfo> oneDeptInfo = WanDaHttpUtil.getDeptInfoTop(hosInfo); // List<DeptInfo> oneDeptInfo = WanDaHttpUtil.getDeptInfoTop(hosInfo);
......
package cn.sh.stc.sict.theme.hphy.service.impl; package cn.sh.stc.sict.theme.hphy.service.impl;
import cn.hutool.core.collection.CollUtil; 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.dao.HpDocInfoMapper;
import cn.sh.stc.sict.theme.hphy.model.HpDocInfo; import cn.sh.stc.sict.theme.hphy.model.HpDocInfo;
import cn.sh.stc.sict.theme.hphy.model.HphyGuideMatch; import cn.sh.stc.sict.theme.hphy.model.HphyGuideMatch;
...@@ -9,7 +10,11 @@ import cn.sh.stc.sict.theme.hphy.service.HpDocInfoService; ...@@ -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.service.HphyGuideMatchService;
import cn.sh.stc.sict.theme.hphy.vo.DoctorMatchVO; 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.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.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -41,7 +46,7 @@ public class HpDocInfoServiceImpl extends ServiceImpl<HpDocInfoMapper, HpDocInfo ...@@ -41,7 +46,7 @@ public class HpDocInfoServiceImpl extends ServiceImpl<HpDocInfoMapper, HpDocInfo
@Override @Override
public List<DoctorMatchVO> getRecommendList(HphyGuideRecord guide, List<PythonResult> pythonList) { public List<DoctorMatchVO> getRecommendList(HphyGuideRecord guide, List<PythonResult> pythonList) {
List<DoctorMatchVO> result = new ArrayList<>(); List<DoctorMatchVO> result = new ArrayList<>();
if(CollUtil.isNotEmpty(pythonList)){ if (CollUtil.isNotEmpty(pythonList)) {
Map<String, Double> matchMap = pythonList.stream().collect(Collectors.toMap(PythonResult::getDoctorId, PythonResult::getMatchScore)); Map<String, Double> matchMap = pythonList.stream().collect(Collectors.toMap(PythonResult::getDoctorId, PythonResult::getMatchScore));
List<String> doctorIdList = pythonList.stream().map(PythonResult::getDoctorId).collect(Collectors.toList()); List<String> doctorIdList = pythonList.stream().map(PythonResult::getDoctorId).collect(Collectors.toList());
LambdaQueryWrapper<HpDocInfo> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<HpDocInfo> wrapper = new LambdaQueryWrapper<>();
...@@ -82,4 +87,25 @@ public class HpDocInfoServiceImpl extends ServiceImpl<HpDocInfoMapper, HpDocInfo ...@@ -82,4 +87,25 @@ public class HpDocInfoServiceImpl extends ServiceImpl<HpDocInfoMapper, HpDocInfo
this.remove(new LambdaQueryWrapper<HpDocInfo>().eq(HpDocInfo::getHosOrgCode, hosOrgCode)); this.remove(new LambdaQueryWrapper<HpDocInfo>().eq(HpDocInfo::getHosOrgCode, hosOrgCode));
this.saveBatch(docInfos); this.saveBatch(docInfos);
} }
@Override
public List<HpDocInfo> listByDeptInfo(DeptInfo deptInfo) {
LambdaQueryWrapper<HpDocInfo> 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<HpDocInfo> 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
...@@ -5,6 +5,7 @@ public class WanDaConstant { ...@@ -5,6 +5,7 @@ public class WanDaConstant {
/** /**
* 预约类型:1-医生 2-门诊 * 预约类型:1-医生 2-门诊
*/ */
public static final String ORDER_TYPE_DOCT = "1";
public static final String ORDER_TYPE_OUTP = "1"; public static final String ORDER_TYPE_OUTP = "1";
public static final String ORDER_TYPE_CLINC = "2"; public static final String ORDER_TYPE_CLINC = "2";
......
...@@ -197,28 +197,35 @@ public class WanDaHttpUtil { ...@@ -197,28 +197,35 @@ public class WanDaHttpUtil {
*/ */
public List<NumSourceInfo> getOrderNumInfo(NumSourceInfo numSourceInfo) { public List<NumSourceInfo> getOrderNumInfo(NumSourceInfo numSourceInfo) {
String xml = WanDaUtil.GetOrderNumInfoServiceXML(numSourceInfo); String xml = WanDaUtil.GetOrderNumInfoServiceXML(numSourceInfo);
String body = HttpRequest.post(URL) String body = "";
.body(xml) try {
.execute() body = HttpRequest.post(URL)
.body(); .body(xml)
.execute()
if (StrUtil.isBlank(body)) { .body();
log.error("号源查询 失败");
return null; if (StrUtil.isBlank(body)) {
} log.error("号源查询 失败");
// log.info("号源查询:body = {}", body); return null;
String returnXml = getReturn(body, "GetOrderNumInfoService"); }
if (Constant.STRING_NO.equals(getCode(returnXml))) { String returnXml = getReturn(body, "GetOrderNumInfoService");
Document document = XmlUtil.readXML(returnXml); if (Constant.STRING_NO.equals(getCode(returnXml))) {
NodeList nodeList = document.getElementsByTagName("NumSourceInfo"); Document document = XmlUtil.readXML(returnXml);
List<NumSourceInfo> list = new ArrayList<>(); NodeList nodeList = document.getElementsByTagName("NumSourceInfo");
if (null != nodeList && nodeList.getLength() > 0) { List<NumSourceInfo> list = new ArrayList<>();
for (int i = 0; i < nodeList.getLength(); i++) { if (null != nodeList && nodeList.getLength() > 0) {
list.add(XmlUtil.xmlToBean(nodeList.item(i), NumSourceInfo.class)); for (int i = 0; i < nodeList.getLength(); i++) {
list.add(XmlUtil.xmlToBean(nodeList.item(i), NumSourceInfo.class));
}
} }
return list;
} else {
return null;
} }
return list; }catch (Exception e){
} else { log.error("号源查询失败,num = {}", JSONUtil.toJsonStr(numSourceInfo));
log.error("号源查询失败,body = {}", body);
log.error(e.getMessage(), e);
return null; return null;
} }
} }
...@@ -416,7 +423,7 @@ public class WanDaHttpUtil { ...@@ -416,7 +423,7 @@ public class WanDaHttpUtil {
*/ */
public List<DoctInfo> getResourceDoctInfo(DeptInfo deptInfo) { public List<DoctInfo> getResourceDoctInfo(DeptInfo deptInfo) {
String xml = WanDaUtil.GetResourceDoctInfoServiceXML(deptInfo); String xml = WanDaUtil.GetResourceDoctInfoServiceXML(deptInfo);
//log.error("获取可预约医生信息 xml = {}", xml);
String body = HttpRequest.post(URL) String body = HttpRequest.post(URL)
.body(xml) .body(xml)
.execute() .execute()
...@@ -426,7 +433,7 @@ public class WanDaHttpUtil { ...@@ -426,7 +433,7 @@ public class WanDaHttpUtil {
log.error("获取可预约医生信息 失败"); log.error("获取可预约医生信息 失败");
return null; return null;
} }
// log.info("获取可预约医生信息:body = {}", body); //log.info("获取可预约医生信息:body = {}", body);
String returnXml = getReturn(body, "GetResourceDoctInfoService"); String returnXml = getReturn(body, "GetResourceDoctInfoService");
return serialDoctInfo(returnXml); return serialDoctInfo(returnXml);
} }
...@@ -439,7 +446,7 @@ public class WanDaHttpUtil { ...@@ -439,7 +446,7 @@ public class WanDaHttpUtil {
*/ */
public List<OutPatInfo> getResourceOutPatInfo(DeptInfo deptInfo) { public List<OutPatInfo> getResourceOutPatInfo(DeptInfo deptInfo) {
String xml = WanDaUtil.GetResourceOutPatInfoServiceXML(deptInfo); String xml = WanDaUtil.GetResourceOutPatInfoServiceXML(deptInfo);
// log.error("xml = {}", xml); //log.error("获取可预约门诊信息 xml = {}", xml);
String body = HttpRequest.post(URL) String body = HttpRequest.post(URL)
.body(xml) .body(xml)
.execute() .execute()
...@@ -449,7 +456,7 @@ public class WanDaHttpUtil { ...@@ -449,7 +456,7 @@ public class WanDaHttpUtil {
log.error("查询门诊信息失败"); log.error("查询门诊信息失败");
return null; return null;
} }
// log.info("查询门诊信息:body = {}", body); //log.info("查询门诊信息:body = {}", body);
String returnXml = getReturn(body, "GetResourceOutPatInfoService"); String returnXml = getReturn(body, "GetResourceOutPatInfoService");
return serialOutPatInfo(returnXml); return serialOutPatInfo(returnXml);
} }
......
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