同步AED数据
This commit is contained in:
+11
-15
@@ -1,13 +1,10 @@
|
||||
package com.renkang.anyan.model.vo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@@ -62,21 +59,20 @@ public class AnYanAedInfo {
|
||||
@Schema(title = "更新时间")
|
||||
private Date updateDate;
|
||||
|
||||
public String getLon() {
|
||||
//安眼提供的经纬度过长, 在这里只保留6位小数
|
||||
if(StrUtil.isNotEmpty(lon)){
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(Double.parseDouble(lon)).setScale(6, RoundingMode.HALF_UP);
|
||||
return bigDecimal.toString();
|
||||
public String getSecondOfficeName() {
|
||||
if(null != secondOfficeName){
|
||||
// 处理返数据中的空格和换行符
|
||||
return secondOfficeName.replaceAll(" ","").replaceAll("\r\n","");
|
||||
}
|
||||
return lon;
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getLat() {
|
||||
//安眼提供的经纬度过长, 在这里只保留6位小数
|
||||
if(StrUtil.isNotEmpty(lat)){
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(Double.parseDouble(lat)).setScale(6, RoundingMode.HALF_UP);
|
||||
return bigDecimal.toString();
|
||||
public String getThirdOfficeName() {
|
||||
if(null != thirdOfficeName){
|
||||
// 处理返数据中的空格和换行符
|
||||
return thirdOfficeName.replaceAll(" ","").replaceAll("\r\n","");
|
||||
}
|
||||
return lat;
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
@@ -326,4 +326,10 @@ public class AedEquipmentMangerController extends JeecgController<AedEquipmentMa
|
||||
return Result.ok(aedEquipmentMangerService.selectAedAllBack());
|
||||
}
|
||||
|
||||
@GetMapping("/syncAnYanAedData")
|
||||
public Result<String> syncAnYanAedData() {
|
||||
aedEquipmentMangerService.syncAnYanAedData();
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -132,4 +132,9 @@ public interface IAedEquipmentMangerService extends IService<AedEquipmentManger>
|
||||
SrcInfo getSrc();
|
||||
|
||||
List<AedEquipmentManger> selectAedAllBack();
|
||||
|
||||
/**
|
||||
* 从安眼系统同步更新AED数据
|
||||
*/
|
||||
void syncAnYanAedData();
|
||||
}
|
||||
|
||||
+68
-1
@@ -10,7 +10,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.renkang.emergency.aed.entity.AedLocationEquipment;
|
||||
import com.renkang.anyan.client.AnYanClient;
|
||||
import com.renkang.anyan.model.vo.AnYanAedInfo;
|
||||
import com.renkang.emergency.aed.manage.AedCacheNewManager;
|
||||
import com.renkang.emergency.aed.manage.AedManagerNew;
|
||||
import com.renkang.emergency.aed.mapper.AedEquipmentMangerMapper;
|
||||
@@ -27,6 +28,7 @@ import com.renkang.emergency.aed.vo.res.manager.AedGeo;
|
||||
import com.renkang.emergency.bean.response.SrcInfo;
|
||||
import com.renkang.emergency.entity.AedEquipmentManger;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.jeecg.bean.response.DepartEasyVO;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.util.DictUtil;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
@@ -50,6 +52,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -93,6 +96,8 @@ public class AedEquipmentMangerServiceImpl extends ServiceImpl<AedEquipmentMange
|
||||
private DictUtil dictUtil;
|
||||
@Autowired
|
||||
private GlobalManager globalManager;
|
||||
@Autowired
|
||||
private AnYanClient anYanClient;
|
||||
|
||||
@Override
|
||||
public IPage<AEDManagerPageRes> queryManagerPageList(Integer pageNo, Integer pageSize, String name, Integer type, String orgCode, String mfrs, String model, String hostSerialNum) {
|
||||
@@ -580,4 +585,66 @@ public class AedEquipmentMangerServiceImpl extends ServiceImpl<AedEquipmentMange
|
||||
public List<AedEquipmentManger> selectAedAllBack() {
|
||||
return list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncAnYanAedData() {
|
||||
//通过安眼接口查询AED数据 ps:重要说明 ,此更新接口是完全以安眼接口返回的AED数据为基准,本系统自行维护或者修改的数据都会被覆盖掉(安眼有的数据才会被覆盖)
|
||||
List<AnYanAedInfo> anYanAedInfos = anYanClient.queryAnYanAedInfo();
|
||||
if(ObjectUtil.isNotEmpty(anYanAedInfos)){
|
||||
LambdaQueryWrapper<AedEquipmentManger> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(AedEquipmentManger::getPublishFlag, 1); //只处理已布点的数据
|
||||
List<AedEquipmentManger> equipmentMangerList = list(wrapper);
|
||||
List<AedEquipmentManger> saveOrUpdateBatchList = new ArrayList<>();
|
||||
//通过安眼平台返回的单位名称去反查本系统的orgCode
|
||||
Map<String, List<DepartEasyVO>> orgMap = sysBaseAPI.queryDeptByName( anYanAedInfos.stream().map(AnYanAedInfo::getThirdOfficeName).collect(Collectors.toSet()));
|
||||
for (AnYanAedInfo anYanAedInfo : anYanAedInfos) {
|
||||
try {
|
||||
AedEquipmentManger equipmentManger = equipmentMangerList.stream().filter(re -> anYanAedInfo.getId().equals(re.getAyId())).findFirst().orElse(new AedEquipmentManger());
|
||||
equipmentManger.setName("自动体外除颤仪");
|
||||
equipmentManger.setPublishFlag(0);
|
||||
if(StrUtil.isNotEmpty(anYanAedInfo.getLat()) && StrUtil.isNotEmpty(anYanAedInfo.getLon())){
|
||||
equipmentManger.setGeoCollectType(1);
|
||||
equipmentManger.setPublishFlag(1);
|
||||
BigDecimal lon = BigDecimal.valueOf(Double.parseDouble(anYanAedInfo.getLon())).setScale(6, RoundingMode.HALF_UP);
|
||||
BigDecimal lat = BigDecimal.valueOf(Double.parseDouble(anYanAedInfo.getLat())).setScale(6, RoundingMode.HALF_UP);
|
||||
equipmentManger.setLongitude(lon);
|
||||
equipmentManger.setLatitude(lat);
|
||||
equipmentManger.setInstallTime(anYanAedInfo.getCreateDate());
|
||||
}
|
||||
//处理所属部门
|
||||
List<DepartEasyVO> departEasyVOS = orgMap.get(anYanAedInfo.getThirdOfficeName());
|
||||
if(ObjectUtil.isNotEmpty(departEasyVOS)){
|
||||
String orgCode = departEasyVOS.stream()
|
||||
.filter(de -> anYanAedInfo.getSecondOfficeName().equals(de.getParentName()))
|
||||
.map(DepartEasyVO::getOrgCode)
|
||||
.findFirst().orElse("");
|
||||
equipmentManger.setDepartCode(orgCode);
|
||||
}
|
||||
equipmentManger.setInstallAddress(anYanAedInfo.getProvidePlace());
|
||||
equipmentManger.setManageUserMobile(anYanAedInfo.getTel());
|
||||
equipmentManger.setUpdateTime(new Date());
|
||||
saveOrUpdate(equipmentManger); //更新信息
|
||||
saveOrUpdateBatchList.add(equipmentManger);
|
||||
aedCacheNewManager.deleteCache(equipmentManger.getId()); //删除缓存
|
||||
aedUtils.removeGeo(equipmentManger.getId()); //删除位置信息
|
||||
if(equipmentManger.getPublishFlag() == 1){
|
||||
//添加位置信息
|
||||
aedUtils.addGeo(equipmentManger.getLongitude().doubleValue(), equipmentManger.getLatitude().doubleValue(), equipmentManger.getId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//处理需要删除的数据(本次接口没查到的直接删除 , 以安眼接口返回为准)
|
||||
List<String> anYanAedIds = saveOrUpdateBatchList.stream().map(AedEquipmentManger::getAyId).collect(Collectors.toList());
|
||||
List<AedEquipmentManger> deleteList = equipmentMangerList.stream().filter(hos -> !anYanAedIds.contains(hos.getAyId())).collect(Collectors.toList());
|
||||
if(ObjectUtil.isNotEmpty(deleteList)){
|
||||
for(AedEquipmentManger manger : deleteList){
|
||||
removeById(manger);
|
||||
aedCacheNewManager.deleteCache(manger.getId());
|
||||
aedUtils.removeGeo(manger.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-1
@@ -1,5 +1,6 @@
|
||||
package com.renkang.emergency.largeScreen.task;
|
||||
package com.renkang.emergency.task;
|
||||
|
||||
import com.renkang.emergency.aed.service.IAedEquipmentMangerService;
|
||||
import com.renkang.emergency.largeScreen.service.ILargeScreenService;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
@@ -12,6 +13,7 @@ import org.springframework.stereotype.Component;
|
||||
@RequiredArgsConstructor
|
||||
public class LargeScreenJob {
|
||||
private final ILargeScreenService largeScreenService;
|
||||
private final IAedEquipmentMangerService aedEquipmentMangerService;
|
||||
|
||||
/**
|
||||
* 同步安眼系统数据,缓存redis
|
||||
@@ -41,4 +43,17 @@ public class LargeScreenJob {
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步安眼系统中的油aed数据
|
||||
*/
|
||||
@XxlJob(value = "syncAnYanAedData")
|
||||
public ReturnT<String> syncAnYanAedData() {
|
||||
try {
|
||||
aedEquipmentMangerService.syncAnYanAedData();
|
||||
return ReturnT.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package org.jeecg.bean.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DepartEasyVO {
|
||||
/**
|
||||
* 单位code
|
||||
*/
|
||||
private String orgCode;
|
||||
/**
|
||||
* 机构/部门名称
|
||||
*/
|
||||
private String orgName;
|
||||
/**
|
||||
* 父级单位code
|
||||
*/
|
||||
private String parentCode;
|
||||
/**
|
||||
* 父级单位名称
|
||||
*/
|
||||
private String parentName;
|
||||
}
|
||||
+9
@@ -751,6 +751,15 @@ public interface ISysBaseAPI extends CommonAPI {
|
||||
@PostMapping("/sys/sysDepart/queryDepartNameByOrgCodes")
|
||||
Map<String,String> queryDepartNameByOrgCodes(@RequestBody Set<String> orgCodeSet);
|
||||
|
||||
|
||||
/**
|
||||
* 根据单位名称反查单位code (使用于导入通过单位名称补全单位code , 如果单位名称重复通过上级单位的code或者名称二次比对)
|
||||
* @param orgNameSet codes
|
||||
* @return <'部门名称',[匹配到的部门信息]></>
|
||||
*/
|
||||
@PostMapping("/sys/sysDepart/queryDeptByName")
|
||||
Map<String,List<DepartEasyVO>> queryDeptByName(@RequestBody Set<String> orgNameSet);
|
||||
|
||||
// /**
|
||||
// * 39根据多个部门编码(逗号分隔),查询返回多个部门信息
|
||||
// * @param ids
|
||||
|
||||
+5
@@ -422,6 +422,11 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<DepartEasyVO>> queryDeptByName(Set<String> orgNameSet) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryDepartsByIds(String ids) {
|
||||
return null;
|
||||
|
||||
+11
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.bean.response.DepartEasyVO;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
@@ -913,6 +914,16 @@ public class SysDepartController {
|
||||
return sysDepartService.queryDepartNameByOrgCodes(orgCodeSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据单位名称反查单位code (使用于导入通过单位名称补全单位code , 如果单位名称重复通过上级单位的code或者名称二次比对)
|
||||
* @param orgNameSet codes
|
||||
* @return <'部门名称',[匹配到的部门信息]></>
|
||||
*/
|
||||
@PostMapping("/queryDeptByName")
|
||||
public Map<String,List<DepartEasyVO>> queryDeptByName(@RequestBody Set<String> orgNameSet){
|
||||
return sysDepartService.queryDeptByName(orgNameSet);
|
||||
}
|
||||
|
||||
@GetMapping("/departDataInit")
|
||||
public void departDataInit(){
|
||||
sysDepartService.departDataInit();
|
||||
|
||||
+8
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.bean.response.DepartEasyVO;
|
||||
import org.jeecg.common.system.bean.response.BaseUser;
|
||||
import org.jeecg.common.system.vo.SysDepartGps;
|
||||
import org.jeecg.common.system.vo.SysDepartModel;
|
||||
@@ -266,4 +267,11 @@ public interface ISysDepartService extends IService<SysDepart> {
|
||||
Map<String, String> queryDepartNameByOrgCodes(Set<String> orgCodeSet);
|
||||
|
||||
void departDataInit();
|
||||
|
||||
/**
|
||||
* 根据单位名称反查单位code
|
||||
* @param orgNameSet
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<DepartEasyVO>> queryDeptByName(Set<String> orgNameSet);
|
||||
}
|
||||
|
||||
+37
-3
@@ -21,13 +21,13 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.bean.response.DepartEasyVO;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.FillRuleConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.exception.ExceptionAssertsUtil;
|
||||
import org.jeecg.common.system.bean.response.BaseUser;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.system.vo.SysDepartGps;
|
||||
import org.jeecg.common.system.vo.SysDepartModel;
|
||||
@@ -44,8 +44,8 @@ import org.jeecg.modules.system.manager.UserCacheManager;
|
||||
import org.jeecg.modules.system.mapper.*;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
import org.jeecg.untils.CoordinateConverter;
|
||||
import org.jeecg.modules.system.util.FindsDepartsChildrenUtil;
|
||||
import org.jeecg.untils.CoordinateConverter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -54,6 +54,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -1244,6 +1245,40 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<DepartEasyVO>> queryDeptByName(Set<String> orgNameSet) {
|
||||
Map<String, List<DepartEasyVO>> resultMap = new HashMap<>();
|
||||
if(ObjectUtil.isNotEmpty(orgNameSet)){
|
||||
orgNameSet = orgNameSet.stream().map(s -> s.replaceAll(" ","")).collect(Collectors.toSet());
|
||||
LambdaQueryWrapper<SysDepart> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.select(SysDepart::getOrgCode,SysDepart::getDepartName,SysDepart::getParentId);
|
||||
queryWrapper.in(SysDepart::getDepartName,orgNameSet);
|
||||
queryWrapper.eq(SysDepart::getDelFlag,0);
|
||||
List<SysDepart> departList = departMapper.selectList(queryWrapper);
|
||||
if(departList.size() > 0){
|
||||
Map<String,SysDepart> parentMap = departMapper.selectBatchIds(
|
||||
departList.stream().map(SysDepart::getParentId).collect(Collectors.toSet()))
|
||||
.stream().collect(Collectors.toMap(SysDepart::getId, Function.identity()));
|
||||
Map<String,List<SysDepart>> deptMap = departList.stream().collect(Collectors.groupingBy(SysDepart::getDepartName));
|
||||
deptMap.forEach((name,value) ->{
|
||||
List<DepartEasyVO> easyVOS = new ArrayList<>();
|
||||
value.forEach(dept ->{
|
||||
DepartEasyVO departEasyVO = new DepartEasyVO();
|
||||
departEasyVO.setOrgCode(dept.getOrgCode());
|
||||
departEasyVO.setOrgName(dept.getDepartName());
|
||||
SysDepart parent= parentMap.get(dept.getParentId());
|
||||
if(null != parent){
|
||||
departEasyVO.setParentCode(parent.getOrgCode());
|
||||
departEasyVO.setParentName(parent.getDepartName());
|
||||
}
|
||||
});
|
||||
resultMap.put(name,easyVOS);
|
||||
});
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelDepartManager(String orgCode, List<String> userIds) {
|
||||
List<SysUser> sysUsers = sysUserMapper.selectBatchIds(userIds);
|
||||
@@ -1695,7 +1730,6 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单元格的值
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user