通过安眼接口更新基础数据

This commit is contained in:
feng
2025-12-02 17:54:32 +08:00
parent cd6d48c22e
commit cb0d45c81b
9 changed files with 66 additions and 44 deletions
@@ -1,5 +1,8 @@
-- aed表加字段
ALTER TABLE `aed_equipment_manger` ALTER TABLE `aed_equipment_manger`
ADD COLUMN `geo_collect_type` tinyint NULL DEFAULT 0 COMMENT '位置数据维护方式(0-地图选点,1-手动维护)' AFTER `latitude`; ADD COLUMN `geo_collect_type` tinyint NULL DEFAULT 0 COMMENT '位置数据维护方式(0-地图选点,1-手动维护)' AFTER `latitude`;
ADD COLUMN `ay_id` varchar(255) NULL COMMENT '安眼平台系统id' AFTER `name`;
-- 应急资源表加字段
ALTER TABLE `emergency_resource` ALTER TABLE `emergency_resource`
ADD COLUMN `ay_id` varchar(255) NULL COMMENT '安眼平台系统id' AFTER `run_time`; ADD COLUMN `ay_id` varchar(255) NULL COMMENT '安眼平台系统id' AFTER `run_time`;
@@ -16,6 +16,11 @@ public class EmergencyContactParam {
*/ */
@Schema(title = "身份证号") @Schema(title = "身份证号")
private String idNo; private String idNo;
/**
* 工号
*/
@Schema(title = "工号")
private String employeeNum;
/** /**
* 数据级别 * 数据级别
*/ */
@@ -437,5 +437,10 @@ public class AedEquipmentManger implements Serializable {
*/ */
private String controlOrgName; private String controlOrgName;
/**
* 对应的安眼系统的业务ID
*/
@Schema(title = "安眼id")
private String ayId;
} }
@@ -67,6 +67,7 @@ public class Resource implements Serializable {
@Excel(name = "纬度", width = 15) @Excel(name = "纬度", width = 15)
@Schema(title = "纬度") @Schema(title = "纬度")
private BigDecimal latitude; private BigDecimal latitude;
/** /**
* 资源类型(1:油田医院 3:健康小屋 5:救护车) 202508xj 项目字典发生变化 , 使用字典resource_type , * 资源类型(1:油田医院 3:健康小屋 5:救护车) 202508xj 项目字典发生变化 , 使用字典resource_type ,
*/ */
@@ -184,7 +185,9 @@ public class Resource implements Serializable {
@Excel(name = "备注", width = 15) @Excel(name = "备注", width = 15)
@Schema(title = "备注") @Schema(title = "备注")
private String memo; private String memo;
/**
* 对应的安眼系统的业务ID
*/
@Schema(title = "安眼id") @Schema(title = "安眼id")
private String ayId; private String ayId;
} }
@@ -162,6 +162,12 @@ public class LargeScreenNewController {
largeScreenService.runJob(); largeScreenService.runJob();
} }
@GetMapping("syncAnYanHospital")
@Operation(summary = "测试安眼数据同步任务", description = "测试安眼数据同步任务")
public void syncAnYanHospital() {
largeScreenService.syncAnYanHospital();
}
/** /**
* 编辑或新增 * 编辑或新增
* *
@@ -42,7 +42,7 @@ public class LargeScreenMap {
this.id = resource.getId(); this.id = resource.getId();
this.name = resource.getName(); this.name = resource.getName();
this.mobile = resource.getMobile(); this.mobile = resource.getMobile();
this.orgName = resource.getAddress(); this.orgName = resource.getMemo();
this.type = resource.getType(); this.type = resource.getType();
this.latitude = String.valueOf(resource.getLatitude()); this.latitude = String.valueOf(resource.getLatitude());
this.longitude = String.valueOf(resource.getLongitude()); this.longitude = String.valueOf(resource.getLongitude());
@@ -42,10 +42,8 @@ import org.jeecg.util.TypeConversionUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.math.RoundingMode;
import java.util.Date; import java.util.*;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -483,52 +481,70 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void syncAnYanHospital() { public void syncAnYanHospital() {
//PS: 重要说明, 目前该同步逻辑只会向emergency_resource表中新增数据或者编辑已经存在的数据, 不会将历史存在且本次同步不存在的数据删除,若需要删除在此处理
if (anYanProperties.isEnable()) { if (anYanProperties.isEnable()) {
//更新医院信息 //更新医院信息 ,数据全部以安眼平台接口返回为准
List<HospitalListVO> hospitalListVOList = anYanClient.hospitalList(); List<HospitalListVO> hospitalListVOList = anYanClient.hospitalList();
if (ObjectUtil.isEmpty(hospitalListVOList)) { if (ObjectUtil.isNotEmpty(hospitalListVOList)) {
LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Resource::getType, "1"); 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> hospitalList = resourceService.list(wrapper);
List<Resource> saveOrUpdateBatchList = new ArrayList<>(); 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 resource = hospitalList.stream().filter(re -> hospital.getId().equals(re.getAyId())).findFirst().orElse(new Resource());
resource.setAddress(hospital.getAddress()); resource.setAddress(hospital.getAddress());
resource.setMemo(hospital.getAlias()); //医院别名使用备注字段 resource.setMemo(hospital.getHospitalName()); //通过观察安眼返回的hospitalName字段并不是医院名称 ,而是地址
try {
resource.setCreateTime(DateUtil.parseDate(hospital.getContractDate())); resource.setCreateTime(DateUtil.parseDate(hospital.getContractDate()));
resource.setName(hospital.getHospitalName()); } catch (Exception e) {
resource.setId(hospital.getId()); e.printStackTrace();
}
resource.setName(hospital.getAlias()); //别名是医院名称
resource.setAyId(hospital.getId());
//todo 如果经纬度需要经度的转换在此处处理
resource.setLatitude(TypeConversionUtil.toBigDecimalOfNull(hospital.getLat())); resource.setLatitude(TypeConversionUtil.toBigDecimalOfNull(hospital.getLat()));
resource.setLongitude(TypeConversionUtil.toBigDecimalOfNull(hospital.getLon())); resource.setLongitude(TypeConversionUtil.toBigDecimalOfNull(hospital.getLon()));
resource.setType("1"); resource.setType("1");
saveOrUpdateBatchList.add(resource); saveOrUpdateBatchList.add(resource);
} }
resourceService.saveOrUpdateBatch(saveOrUpdateBatchList); resourceService.saveOrUpdateBatch(saveOrUpdateBatchList);
//处理需要删除的数据(本次接口没查到的直接删除 , 以安眼接口返回为准)
List<String> anYanHospitalIds = saveOrUpdateBatchList.stream().map(Resource::getAyId).collect(Collectors.toList());
List<Resource> deleteList = hospitalList.stream().filter(hos -> !anYanHospitalIds.contains(hos.getAyId())).collect(Collectors.toList());
if(ObjectUtil.isNotEmpty(deleteList)){
resourceService.removeBatchByIds(deleteList);
} }
//更新健康小屋信息 }
//更新健康小屋信息,,数据全部以安眼平台接口返回为准
List<HealthRoomBaseVO> healthRoomVOList = anYanClient.healthPlaceHomList(); List<HealthRoomBaseVO> healthRoomVOList = anYanClient.healthPlaceHomList();
if (ObjectUtil.isEmpty(healthRoomVOList)) { if (ObjectUtil.isNotEmpty(healthRoomVOList)) {
List<Resource> saveOrUpdateBatchList = new ArrayList<>();
LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Resource::getType, "2"); wrapper.eq(Resource::getType, "3");
wrapper.in(Resource::getId, healthRoomVOList.stream().map(HealthRoomBaseVO::getId).collect(Collectors.toList()));
List<Resource> roomList = resourceService.list(wrapper); List<Resource> roomList = resourceService.list(wrapper);
List<Resource> saveOrUpdateBatchList = new ArrayList<>();
for (HealthRoomBaseVO room : healthRoomVOList) { for (HealthRoomBaseVO room : healthRoomVOList) {
Resource resource = roomList.stream().filter(re -> room.getId().equals(re.getId())).findFirst().orElse(new Resource()); Resource resource = roomList.stream().filter(re -> room.getId().equals(re.getAyId())).findFirst().orElse(new Resource());
resource.setAddress(room.getAddress()); resource.setAddress(Optional.ofNullable(room.getDepartName()).orElse("") + Optional.ofNullable(room.getAddress()).orElse(""));
resource.setCreateTime(DateUtil.parseDate(room.getBuildDate())); resource.setUpdateTime(new Date());
resource.setName(room.getDepartName()); resource.setName(room.getDepartName()); //暂时使用单位名称作为名称, 就可能会有重复
resource.setId(room.getId()); resource.setMemo(room.getDepartName());
resource.setLatitude(TypeConversionUtil.toBigDecimalOfNull(room.getLat())); resource.setAyId(room.getId());
resource.setLongitude(TypeConversionUtil.toBigDecimalOfNull(room.getLon())); //处理经纬度(安眼返回的数据精度过长)
if(StrUtil.isNotEmpty(room.getLat()) && StrUtil.isNotEmpty(room.getLon())){
resource.setLatitude(TypeConversionUtil.toBigDecimalOfNull(room.getLat()).setScale(6, RoundingMode.HALF_UP));
resource.setLongitude(TypeConversionUtil.toBigDecimalOfNull(room.getLon()).setScale(6, RoundingMode.HALF_UP));
}
resource.setJobNum(room.getJobNum()); resource.setJobNum(room.getJobNum());
resource.setRunTime(room.getRunTime()); resource.setRunTime(room.getRunTime());
resource.setType("2"); resource.setType("3");
saveOrUpdateBatchList.add(resource); saveOrUpdateBatchList.add(resource);
} }
resourceService.saveOrUpdateBatch(saveOrUpdateBatchList); resourceService.saveOrUpdateBatch(saveOrUpdateBatchList);
//处理需要删除的数据(本次接口没查到的直接删除 , 以安眼接口返回为准)
List<String> anYanRoomIds = saveOrUpdateBatchList.stream().map(Resource::getAyId).collect(Collectors.toList());
List<Resource> deleteList = roomList.stream().filter(room -> !anYanRoomIds.contains(room.getAyId())).collect(Collectors.toList());
if(ObjectUtil.isNotEmpty(deleteList)){
resourceService.removeBatchByIds(deleteList);
}
} }
} }
} }
@@ -8,9 +8,4 @@ public interface IXjAedService extends IService<XjAed> {
void aedDataInit(); void aedDataInit();
void aedDataUtil(); void aedDataUtil();
/**
* 定时任务更新aed数据 , 数据通过安眼平台接口获取
*/
void aedDataRefreshTask();
} }
@@ -150,15 +150,4 @@ public class XjAedServiceImpl extends ServiceImpl<XjAedMapper, XjAed> implements
System.out.println(gps.getLatitude()); System.out.println(gps.getLatitude());
} }
} }
@Override
@Transactional
public void aedDataRefreshTask() {
//安眼接口查询AED数据 , 主要更新位置信息 ,目前安眼平台没有设备编码来确定AED的唯一性,安放位置使用二级单位+三级单位+具体位置标注
List<AnYanAedInfo> anYanAedInfos = anYanClient.queryAnYanAedInfo();
if(ObjectUtil.isNotEmpty(anYanAedInfos)){
//todo , 本系统做了对应功能后此处的同步方法暂不使用
List<XjAed> xjAedList = baseMapper.selectList(new QueryWrapper<>());
}
}
} }