通过安眼接口更新基础数据
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
-- aed表加字段
|
||||
ALTER TABLE `aed_equipment_manger`
|
||||
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`
|
||||
ADD COLUMN `ay_id` varchar(255) NULL COMMENT '安眼平台系统id' AFTER `run_time`;
|
||||
+5
@@ -16,6 +16,11 @@ public class EmergencyContactParam {
|
||||
*/
|
||||
@Schema(title = "身份证号")
|
||||
private String idNo;
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
@Schema(title = "工号")
|
||||
private String employeeNum;
|
||||
/**
|
||||
* 数据级别
|
||||
*/
|
||||
|
||||
+5
@@ -437,5 +437,10 @@ public class AedEquipmentManger implements Serializable {
|
||||
*/
|
||||
private String controlOrgName;
|
||||
|
||||
/**
|
||||
* 对应的安眼系统的业务ID
|
||||
*/
|
||||
@Schema(title = "安眼id")
|
||||
private String ayId;
|
||||
|
||||
}
|
||||
|
||||
+4
-1
@@ -67,6 +67,7 @@ public class Resource implements Serializable {
|
||||
@Excel(name = "纬度", width = 15)
|
||||
@Schema(title = "纬度")
|
||||
private BigDecimal latitude;
|
||||
|
||||
/**
|
||||
* 资源类型(1:油田医院 3:健康小屋 5:救护车) 202508xj 项目字典发生变化 , 使用字典resource_type ,
|
||||
*/
|
||||
@@ -184,7 +185,9 @@ public class Resource implements Serializable {
|
||||
@Excel(name = "备注", width = 15)
|
||||
@Schema(title = "备注")
|
||||
private String memo;
|
||||
|
||||
/**
|
||||
* 对应的安眼系统的业务ID
|
||||
*/
|
||||
@Schema(title = "安眼id")
|
||||
private String ayId;
|
||||
}
|
||||
|
||||
+6
@@ -162,6 +162,12 @@ public class LargeScreenNewController {
|
||||
largeScreenService.runJob();
|
||||
}
|
||||
|
||||
@GetMapping("syncAnYanHospital")
|
||||
@Operation(summary = "测试安眼数据同步任务", description = "测试安眼数据同步任务")
|
||||
public void syncAnYanHospital() {
|
||||
largeScreenService.syncAnYanHospital();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑或新增
|
||||
*
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class LargeScreenMap {
|
||||
this.id = resource.getId();
|
||||
this.name = resource.getName();
|
||||
this.mobile = resource.getMobile();
|
||||
this.orgName = resource.getAddress();
|
||||
this.orgName = resource.getMemo();
|
||||
this.type = resource.getType();
|
||||
this.latitude = String.valueOf(resource.getLatitude());
|
||||
this.longitude = String.valueOf(resource.getLongitude());
|
||||
|
||||
+42
-26
@@ -42,10 +42,8 @@ import org.jeecg.util.TypeConversionUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -483,52 +481,70 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncAnYanHospital() {
|
||||
//PS: 重要说明, 目前该同步逻辑只会向emergency_resource表中新增数据或者编辑已经存在的数据, 不会将历史存在且本次同步不存在的数据删除,若需要删除在此处理
|
||||
if (anYanProperties.isEnable()) {
|
||||
//更新医院信息
|
||||
//更新医院信息 ,数据全部以安眼平台接口返回为准
|
||||
List<HospitalListVO> hospitalListVOList = anYanClient.hospitalList();
|
||||
if (ObjectUtil.isEmpty(hospitalListVOList)) {
|
||||
if (ObjectUtil.isNotEmpty(hospitalListVOList)) {
|
||||
LambdaQueryWrapper<Resource> wrapper = new LambdaQueryWrapper<>();
|
||||
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) {
|
||||
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.setMemo(hospital.getAlias()); //医院别名使用备注字段
|
||||
resource.setCreateTime(DateUtil.parseDate(hospital.getContractDate()));
|
||||
resource.setName(hospital.getHospitalName());
|
||||
resource.setId(hospital.getId());
|
||||
resource.setMemo(hospital.getHospitalName()); //通过观察安眼返回的hospitalName字段并不是医院名称 ,而是地址
|
||||
try {
|
||||
resource.setCreateTime(DateUtil.parseDate(hospital.getContractDate()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
resource.setName(hospital.getAlias()); //别名是医院名称
|
||||
resource.setAyId(hospital.getId());
|
||||
//todo 如果经纬度需要经度的转换在此处处理
|
||||
resource.setLatitude(TypeConversionUtil.toBigDecimalOfNull(hospital.getLat()));
|
||||
resource.setLongitude(TypeConversionUtil.toBigDecimalOfNull(hospital.getLon()));
|
||||
resource.setType("1");
|
||||
saveOrUpdateBatchList.add(resource);
|
||||
}
|
||||
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();
|
||||
if (ObjectUtil.isEmpty(healthRoomVOList)) {
|
||||
List<Resource> saveOrUpdateBatchList = new ArrayList<>();
|
||||
if (ObjectUtil.isNotEmpty(healthRoomVOList)) {
|
||||
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, "3");
|
||||
List<Resource> roomList = resourceService.list(wrapper);
|
||||
List<Resource> saveOrUpdateBatchList = new ArrayList<>();
|
||||
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()));
|
||||
resource.setName(room.getDepartName());
|
||||
resource.setId(room.getId());
|
||||
resource.setLatitude(TypeConversionUtil.toBigDecimalOfNull(room.getLat()));
|
||||
resource.setLongitude(TypeConversionUtil.toBigDecimalOfNull(room.getLon()));
|
||||
Resource resource = roomList.stream().filter(re -> room.getId().equals(re.getAyId())).findFirst().orElse(new Resource());
|
||||
resource.setAddress(Optional.ofNullable(room.getDepartName()).orElse("") + Optional.ofNullable(room.getAddress()).orElse(""));
|
||||
resource.setUpdateTime(new Date());
|
||||
resource.setName(room.getDepartName()); //暂时使用单位名称作为名称, 就可能会有重复
|
||||
resource.setMemo(room.getDepartName());
|
||||
resource.setAyId(room.getId());
|
||||
//处理经纬度(安眼返回的数据精度过长)
|
||||
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.setRunTime(room.getRunTime());
|
||||
resource.setType("2");
|
||||
resource.setType("3");
|
||||
saveOrUpdateBatchList.add(resource);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-5
@@ -8,9 +8,4 @@ public interface IXjAedService extends IService<XjAed> {
|
||||
void aedDataInit();
|
||||
|
||||
void aedDataUtil();
|
||||
|
||||
/**
|
||||
* 定时任务更新aed数据 , 数据通过安眼平台接口获取
|
||||
*/
|
||||
void aedDataRefreshTask();
|
||||
}
|
||||
|
||||
-11
@@ -150,15 +150,4 @@ public class XjAedServiceImpl extends ServiceImpl<XjAedMapper, XjAed> implements
|
||||
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<>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user