修复大屏体检异常统计bug

This commit is contained in:
wanghao
2025-08-20 13:33:06 +08:00
parent a035d3f47e
commit 59ade8db2b
@@ -76,8 +76,8 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
List<LargeScreenMap> maps = new ArrayList<>();
if (StrUtil.isEmpty(type) || type.equals("1")) {
List<Resource> list = resourceService.list(new LambdaQueryWrapper<Resource>()
.eq(StrUtil.isNotEmpty(type),Resource::getType, type)
.eq(StrUtil.isEmpty(type),Resource::getType, "1"));
.eq(StrUtil.isNotEmpty(type), Resource::getType, type)
.eq(StrUtil.isEmpty(type), Resource::getType, "1"));
maps.addAll(list.stream().map(LargeScreenMap::new).collect(Collectors.toList()));
}
if (StrUtil.isEmpty(type) || type.equals("2")) {
@@ -86,18 +86,18 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
}
if (StrUtil.isEmpty(type) || type.equals("5")) {
List<Resource> list = resourceService.list(new LambdaQueryWrapper<Resource>()
.eq(StrUtil.isNotEmpty(type),Resource::getType, type)
.eq(StrUtil.isEmpty(type),Resource::getType, "5"));
.eq(StrUtil.isNotEmpty(type), Resource::getType, type)
.eq(StrUtil.isEmpty(type), Resource::getType, "5"));
maps.addAll(list.stream().map(LargeScreenMap::new).collect(Collectors.toList()));
}
return maps;
}
@Override
public List<HealthRoomBaseVO> healthRoomBase(HealthRoomBaseDTO dto){
public List<HealthRoomBaseVO> healthRoomBase(HealthRoomBaseDTO dto) {
List<HealthRoomBaseVO> list = new ArrayList<>();
List<Resource> resources = resourceService.list(new LambdaQueryWrapper<Resource>().eq(Resource::getType, 3)
.between(ObjUtil.isNotEmpty(dto.getCheckInDateBegin()),Resource::getCreateTime,dto.getCheckInDateBegin(),dto.getCheckInDateEnd()));
.between(ObjUtil.isNotEmpty(dto.getCheckInDateBegin()), Resource::getCreateTime, dto.getCheckInDateBegin(), dto.getCheckInDateEnd()));
for (Resource resource : resources) {
HealthRoomBaseVO baseVO = new HealthRoomBaseVO();
baseVO.setId(resource.getId());
@@ -112,15 +112,15 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
}
@Override
public IPage<HealthRoomVO> healthRoomDetail(HealthRoomDTO dto){
public IPage<HealthRoomVO> healthRoomDetail(HealthRoomDTO dto) {
IPage<HealthPlaceHomDetailsVO> detailsIPage;
try {
detailsIPage = anYanClient.healthPlaceHomDetailList(dto);
if (ObjUtil.isEmpty(detailsIPage.getRecords())) {
return new Page<>();
}
}catch (Exception e){
log.error("调用安眼API失败",e);
} catch (Exception e) {
log.error("调用安眼API失败", e);
throw new RuntimeException("调用安眼API失败");
}
IPage<HealthRoomVO> page = new Page<>();
@@ -131,100 +131,100 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
}
@Override
public IPage<MedicalAbnormalVO> medicalAbnormal (MedicalAbnormalDTO dto){
public IPage<MedicalAbnormalVO> medicalAbnormal(MedicalAbnormalDTO dto) {
IPage<MedicalAbnormalVO> page;
try {
page = anYanClient.medicalAbnormalList(dto);
if (ObjUtil.isEmpty(page.getRecords())) {
return new Page<>();
}
}catch (Exception e){
log.error("调用安眼API失败",e);
} catch (Exception e) {
log.error("调用安眼API失败", e);
throw new RuntimeException("调用安眼API失败");
}
return page;
}
@Override
public IPage<WeightPressureList> healthWeightLoss (HealthSignListParam dto){
public IPage<WeightPressureList> healthWeightLoss(HealthSignListParam dto) {
IPage<WeightPressureList> page;
try {
page = anYanClient.weightPressureList(dto);
if (ObjUtil.isEmpty(page.getRecords())) {
return new Page<>();
}
}catch (Exception e){
log.error("调用安眼API失败",e);
} catch (Exception e) {
log.error("调用安眼API失败", e);
throw new RuntimeException("调用安眼API失败");
}
return page;
}
@Override
public IPage<BloodSugarClockSList> healthBloodSugar (HealthSignListParam dto){
public IPage<BloodSugarClockSList> healthBloodSugar(HealthSignListParam dto) {
IPage<BloodSugarClockSList> page;
try {
page = anYanClient.bloodSugarClockSList(dto);
if (ObjUtil.isEmpty(page.getRecords())) {
return new Page<>();
}
}catch (Exception e){
log.error("调用安眼API失败",e);
} catch (Exception e) {
log.error("调用安眼API失败", e);
throw new RuntimeException("调用安眼API失败");
}
return page;
}
@Override
public IPage<BloodPressureList> healthBloodPressure (HealthSignListParam dto){
public IPage<BloodPressureList> healthBloodPressure(HealthSignListParam dto) {
IPage<BloodPressureList> page;
try {
page = anYanClient.bloodPressureList(dto);
if (ObjUtil.isEmpty(page.getRecords())) {
return new Page<>();
}
}catch (Exception e){
log.error("调用安眼API失败",e);
} catch (Exception e) {
log.error("调用安眼API失败", e);
throw new RuntimeException("调用安眼API失败");
}
return page;
}
@Override
public List<HospitalVO> hospital(){
public List<HospitalVO> hospital() {
List<HospitalVO> list = new ArrayList<>();
List<Resource> resources = resourceService.list(new LambdaQueryWrapper<Resource>().eq(Resource::getType, 1));
if(CollUtil.isEmpty(resources)) {
if (CollUtil.isEmpty(resources)) {
return list;
}
return resources.stream().map(HospitalVO::new).collect(Collectors.toList());
}
@Override
public List<MedicalPeopleNumStatisticsVO> medicalPeopleNumStatistics (MedicalPeopleNumStatisticsDTO dto){
public List<MedicalPeopleNumStatisticsVO> medicalPeopleNumStatistics(MedicalPeopleNumStatisticsDTO dto) {
List<MedicalPeopleNumStatisticsVO> list = redisClientUtil.getList(MEDICAL,
MEDICAL_PEOPLE_NUM_STATISTICS+":"+dto.getMedicalYear()+":"+dto.getCenterId(),MedicalPeopleNumStatisticsVO.class);
MEDICAL_PEOPLE_NUM_STATISTICS + ":" + dto.getMedicalYear() + ":" + dto.getCenterId(), MedicalPeopleNumStatisticsVO.class);
// 获取假数据
List<MedicalDataVO> medicalDataList = screenDataService.medicalDataDetail(dto.getCenterId());
if (CollUtil.isEmpty(list)){
if (CollUtil.isEmpty(list)) {
list = new ArrayList<>();
for (MedicalDataVO medicalData : medicalDataList) {
if ("1".equals(medicalData.getStatus())){
if ("1".equals(medicalData.getStatus())) {
MedicalPeopleNumStatisticsVO vo = new MedicalPeopleNumStatisticsVO();
vo.setHospitalName(medicalData.getName());
vo.setCheckedCount(Integer.valueOf(medicalData.getCount()));
list.add(vo);
}
}
}else {
} else {
for (MedicalPeopleNumStatisticsVO statistics : list) {
MedicalDataVO medicalData = medicalDataList.stream().filter(item -> item.getName().equals(statistics.getHospitalName())).findFirst().orElse(null);
if (null != medicalData){
if ("1".equals(medicalData.getStatus())){
if (medicalData.getCount().contains("+")){
statistics.setCheckedCount(statistics.getCheckedCount()+Integer.parseInt(medicalData.getCount().replace("+", "").trim()));
}else {
if (null != medicalData) {
if ("1".equals(medicalData.getStatus())) {
if (medicalData.getCount().contains("+")) {
statistics.setCheckedCount(statistics.getCheckedCount() + Integer.parseInt(medicalData.getCount().replace("+", "").trim()));
} else {
statistics.setCheckedCount(Integer.parseInt(medicalData.getCount().replace("+", "").trim()));
}
}
@@ -235,54 +235,57 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
}
@Override
public MedicalAbnormalStatisticsVO medicalAbnormalStatistics (MedicalAbnormalStatisticsDTO dto){
public MedicalAbnormalStatisticsVO medicalAbnormalStatistics(MedicalAbnormalStatisticsDTO dto) {
if (dto.getMedicalYear().isEmpty()) {
dto.setMedicalYear(String.valueOf(DateUtil.thisYear()));
}
MedicalAbnormalStatisticsVO statisticsVO = redisClientUtil.get(MEDICAL,
MEDICAL_ABNORMAL_STATISTICS+":"+dto.getMedicalYear()+":"+dto.getCenterId(),MedicalAbnormalStatisticsVO.class);
MEDICAL_ABNORMAL_STATISTICS + ":" + dto.getMedicalYear() + ":" + dto.getCenterId(), MedicalAbnormalStatisticsVO.class);
// 获取假数据
DataDetailVO dataDetailVO = screenDataService.dataDetail(dto.getCenterId(), "34");
if (ObjUtil.isEmpty(statisticsVO)){
if (ObjUtil.isEmpty(statisticsVO)) {
statisticsVO = new MedicalAbnormalStatisticsVO();
if (null != dataDetailVO){
if ("1".equals(dataDetailVO.getTotalCountStatus())){
if (null != dataDetailVO) {
if ("1".equals(dataDetailVO.getTotalCountStatus())) {
statisticsVO.setTotalCount(Integer.valueOf(dataDetailVO.getTotalCount().replace("+", "").trim()));
}
if ("1".equals(dataDetailVO.getCardiovaAbCountStatus())){
if ("1".equals(dataDetailVO.getCardiovaAbCountStatus())) {
statisticsVO.setCardiovaAbCount(Integer.valueOf(dataDetailVO.getCardiovaAbCount().replace("+", "").trim()));
}
if ("1".equals(dataDetailVO.getCerebrovAbCountStatus())){
if ("1".equals(dataDetailVO.getCerebrovAbCountStatus())) {
statisticsVO.setCerebrovAbCount(Integer.valueOf(dataDetailVO.getCerebrovAbCount().replace("+", "").trim()));
}
if ("1".equals(dataDetailVO.getCctaAbCountStatus())){
if ("1".equals(dataDetailVO.getCctaAbCountStatus())) {
statisticsVO.setCctaAbCount(Integer.valueOf(dataDetailVO.getCctaAbCount().replace("+", "").trim()));
}
}
}else {
if (null != dataDetailVO){
if ("1".equals(dataDetailVO.getTotalCountStatus())){
if (dataDetailVO.getTotalCount().contains("+")){
} else {
if (null != dataDetailVO) {
if ("1".equals(dataDetailVO.getTotalCountStatus())) {
if (dataDetailVO.getTotalCount().contains("+")) {
statisticsVO.setTotalCount(statisticsVO.getTotalCount() + Integer.parseInt(dataDetailVO.getTotalCount().replace("+", "").trim()));
}else {
} else {
statisticsVO.setTotalCount(Integer.valueOf(dataDetailVO.getTotalCount().replace("+", "").trim()));
}
}
if ("1".equals(dataDetailVO.getCardiovaAbCountStatus())){
if (dataDetailVO.getCardiovaAbCount().contains("+")){
if ("1".equals(dataDetailVO.getCardiovaAbCountStatus())) {
if (dataDetailVO.getCardiovaAbCount().contains("+")) {
statisticsVO.setCardiovaAbCount(statisticsVO.getCardiovaAbCount() + Integer.parseInt(dataDetailVO.getCardiovaAbCount().replace("+", "").trim()));
}else {
} else {
statisticsVO.setCardiovaAbCount(Integer.valueOf(dataDetailVO.getCardiovaAbCount().replace("+", "").trim()));
}
}
if ("1".equals(dataDetailVO.getCerebrovAbCountStatus())){
if (dataDetailVO.getCerebrovAbCount().contains("+")){
if ("1".equals(dataDetailVO.getCerebrovAbCountStatus())) {
if (dataDetailVO.getCerebrovAbCount().contains("+")) {
statisticsVO.setCerebrovAbCount(statisticsVO.getCerebrovAbCount() + Integer.parseInt(dataDetailVO.getCerebrovAbCount().replace("+", "").trim()));
}else {
} else {
statisticsVO.setCerebrovAbCount(Integer.valueOf(dataDetailVO.getCerebrovAbCount().replace("+", "").trim()));
}
}
if ("1".equals(dataDetailVO.getCctaAbCountStatus())){
if (dataDetailVO.getCctaAbCount().contains("+")){
if ("1".equals(dataDetailVO.getCctaAbCountStatus())) {
if (dataDetailVO.getCctaAbCount().contains("+")) {
statisticsVO.setCctaAbCount(statisticsVO.getCctaAbCount() + Integer.parseInt(dataDetailVO.getCctaAbCount().replace("+", "").trim()));
}else {
} else {
statisticsVO.setCctaAbCount(Integer.valueOf(dataDetailVO.getCctaAbCount().replace("+", "").trim()));
}
}
@@ -297,7 +300,7 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
public HealthSignVO healthSign(HealthSignDTO dto) {
// 健康打卡数据
HealthSignVO vo = redisClientUtil.get(MEDICAL,
HEALTH_SIGN+":"+dto.getCenterId(), HealthSignVO.class);
HEALTH_SIGN + ":" + dto.getCenterId(), HealthSignVO.class);
// 获取数据
DataDetailVO dataDetailVO = screenDataService.dataDetail(dto.getCenterId(), "33");
@@ -389,21 +392,21 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
}
@Override
public void runJob(){
public void runJob() {
// 查询默认应急中心
EmergencyCenter defaultCenter = centerService.getOne(new LambdaQueryWrapper<EmergencyCenter>().eq(EmergencyCenter::getDefaultCenter, true), false);
if (ObjUtil.isEmpty(defaultCenter)){
if (ObjUtil.isEmpty(defaultCenter)) {
return;
}
Date today = new Date();
if (anYanProperties.isEnable()){
if (anYanProperties.isEnable()) {
// 体检人数统计查询
List<MedicalPeopleNumStatisticsVO> medicalPeopleNumStatisticsVOS = anYanClient.examinationStatistics(DateUtil.thisYear());
redisClientUtil.set(MEDICAL,MEDICAL_PEOPLE_NUM_STATISTICS+":"+DateUtil.thisYear()+":"+defaultCenter.getId(),medicalPeopleNumStatisticsVOS);
redisClientUtil.set(MEDICAL, MEDICAL_PEOPLE_NUM_STATISTICS + ":" + DateUtil.thisYear() + ":" + defaultCenter.getId(), medicalPeopleNumStatisticsVOS);
// 体检异常数据查询
MedicalAbnormalStatisticsVO medicalAbnormalStatisticsVO = anYanClient.medicalAbnormalStatistics(DateUtil.thisYear());
redisClientUtil.set(MEDICAL,MEDICAL_ABNORMAL_STATISTICS+":"+DateUtil.thisYear()+":"+defaultCenter.getId(),medicalAbnormalStatisticsVO);
redisClientUtil.set(MEDICAL, MEDICAL_ABNORMAL_STATISTICS + ":" + DateUtil.thisYear() + ":" + defaultCenter.getId(), medicalAbnormalStatisticsVO);
// 健康打卡今日数据查询
HealthSignStatVO healthSignToday = anYanClient.healthCheckStatistics(DateUtil.beginOfDay(today), DateUtil.endOfDay(today));
@@ -426,13 +429,13 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
healthSign.setBloodSugarCountMonth(Integer.valueOf(healthSignMonth.getBpTotalCount()));
healthSign.setBloodSugarAbnormalCountMonth(Integer.valueOf(healthSignMonth.getBpAbCount()));
redisClientUtil.set(MEDICAL,HEALTH_SIGN+defaultCenter.getId(),healthSign);
}else {
redisClientUtil.set(MEDICAL, HEALTH_SIGN + defaultCenter.getId(), healthSign);
} else {
randomData(defaultCenter);
}
}
private void randomData(EmergencyCenter defaultCenter){
private void randomData(EmergencyCenter defaultCenter) {
List<MedicalPeopleNumStatisticsVO> medicalPeopleNumStatisticsVOS = new ArrayList<>();
Random random = new Random();
for (int i = 0; i < 10; i++) {
@@ -443,14 +446,14 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
vo.setCheckedCount(randomCount);
medicalPeopleNumStatisticsVOS.add(vo);
}
redisClientUtil.set(MEDICAL,MEDICAL_PEOPLE_NUM_STATISTICS+":"+DateUtil.thisYear()+":"+defaultCenter.getId(),medicalPeopleNumStatisticsVOS);
redisClientUtil.set(MEDICAL, MEDICAL_PEOPLE_NUM_STATISTICS + ":" + DateUtil.thisYear() + ":" + defaultCenter.getId(), medicalPeopleNumStatisticsVOS);
// 体检异常数据查询
MedicalAbnormalStatisticsVO medicalAbnormalStatisticsVO = new MedicalAbnormalStatisticsVO();
medicalAbnormalStatisticsVO.setTotalCount(100);
medicalAbnormalStatisticsVO.setCardiovaAbCount(50);
medicalAbnormalStatisticsVO.setCerebrovAbCount(50);
redisClientUtil.set(MEDICAL,MEDICAL_ABNORMAL_STATISTICS+":"+DateUtil.thisYear()+":"+defaultCenter.getId(),medicalAbnormalStatisticsVO);
redisClientUtil.set(MEDICAL, MEDICAL_ABNORMAL_STATISTICS + ":" + DateUtil.thisYear() + ":" + defaultCenter.getId(), medicalAbnormalStatisticsVO);
// 减重 血压 血糖 三种数据整合存
HealthSignVO healthSign = new HealthSignVO();
healthSign.setWeightLossCountDay(random.nextInt(100) + 1);
@@ -466,23 +469,23 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
healthSign.setBloodPressureAbnormalCountMonth(random.nextInt(100) + 1);
healthSign.setBloodSugarCountMonth(random.nextInt(100) + 1);
healthSign.setBloodSugarAbnormalCountMonth(random.nextInt(100) + 1);
redisClientUtil.set(MEDICAL,HEALTH_SIGN+defaultCenter.getId(),healthSign);
redisClientUtil.set(MEDICAL, HEALTH_SIGN + defaultCenter.getId(), healthSign);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void syncAnYanHospital() {
//PS: 重要说明, 目前该同步逻辑只会向emergency_resource表中新增数据或者编辑已经存在的数据, 不会将历史存在且本次同步不存在的数据删除,若需要删除在此处理
if(anYanProperties.isEnable()){
if (anYanProperties.isEnable()) {
//更新医院信息
List<HospitalListVO> hospitalListVOList = anYanClient.hospitalList();
if(ObjectUtil.isEmpty(hospitalListVOList)){
if (ObjectUtil.isEmpty(hospitalListVOList)) {
LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Resource::getType,"1");
wrapper.in(Resource::getId,hospitalListVOList.stream().map(HospitalListVO::getId).collect(Collectors.toList()));
wrapper.eq(Resource::getType, "1");
wrapper.in(Resource::getId, hospitalListVOList.stream().map(HospitalListVO::getId).collect(Collectors.toList()));
List<Resource> hospitalList = resourceService.list(wrapper);
List<Resource> saveOrUpdateBatchList = new ArrayList<>();
for(HospitalListVO hospital : hospitalListVOList){
for (HospitalListVO hospital : hospitalListVOList) {
Resource resource = hospitalList.stream().filter(re -> hospital.getId().equals(re.getId())).findFirst().orElse(new Resource());
resource.setAddress(hospital.getAddress());
resource.setMemo(hospital.getAlias()); //医院别名使用备注字段
@@ -498,13 +501,13 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
}
//更新健康小屋信息
List<HealthRoomBaseVO> healthRoomVOList = anYanClient.healthPlaceHomList();
if(ObjectUtil.isEmpty(healthRoomVOList)){
if (ObjectUtil.isEmpty(healthRoomVOList)) {
List<Resource> saveOrUpdateBatchList = new ArrayList<>();
LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Resource::getType,"2");
wrapper.in(Resource::getId,healthRoomVOList.stream().map(HealthRoomBaseVO::getId).collect(Collectors.toList()));
wrapper.eq(Resource::getType, "2");
wrapper.in(Resource::getId, healthRoomVOList.stream().map(HealthRoomBaseVO::getId).collect(Collectors.toList()));
List<Resource> roomList = resourceService.list(wrapper);
for(HealthRoomBaseVO room : healthRoomVOList){
for (HealthRoomBaseVO room : healthRoomVOList) {
Resource resource = roomList.stream().filter(re -> room.getId().equals(re.getId())).findFirst().orElse(new Resource());
resource.setAddress(room.getAddress());
resource.setCreateTime(DateUtil.parseDate(room.getBuildDate()));