新增接口实现查询当前用户关注台站信息及缓存配置信息
修改新增关注台站信息接口 增加查询台站类型工具类
This commit is contained in:
parent
ed5ca585b1
commit
e9ac06c22c
|
@ -0,0 +1,17 @@
|
|||
package org.jeecg.common;
|
||||
|
||||
public class StationTypeUtil {
|
||||
|
||||
public static String getStationType(Integer stationId){
|
||||
String stationType = "";
|
||||
if (stationId<=200){
|
||||
stationType = "IMS STATION(P)";
|
||||
}else if(stationId>200 && stationId<=300){
|
||||
stationType = "IMS STATION(G)";
|
||||
}else if(stationId>300){
|
||||
stationType = "NRL";
|
||||
}
|
||||
return stationType;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import io.swagger.annotations.ApiOperation;
|
|||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.config.valid.InsertGroup;
|
||||
import org.jeecg.modules.entity.SysUserFocusStation;
|
||||
import org.jeecg.modules.entity.UserFocusStation;
|
||||
import org.jeecg.modules.service.ISysUserFocusStationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -27,10 +28,10 @@ public class SysUserFocusStationController {
|
|||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("create")
|
||||
@ApiOperation(value = "新增关注", notes = "新增关注")
|
||||
public Result create(@RequestBody @Validated(value = InsertGroup.class) SysUserFocusStation sysUserFocusStation){
|
||||
return sysUserFocusStationService.create(sysUserFocusStation);
|
||||
@PostMapping("saveUserFocusByUserId")
|
||||
@ApiOperation(value = "保存用户关注台站及缓存配置信息", notes = "保存用户关注台站及缓存配置信息")
|
||||
public Result create(@RequestBody UserFocusStation userFocusStation){
|
||||
return sysUserFocusStationService.create(userFocusStation);
|
||||
}
|
||||
|
||||
@DeleteMapping("deleteById")
|
||||
|
@ -39,4 +40,12 @@ public class SysUserFocusStationController {
|
|||
return sysUserFocusStationService.deleteById(stationId);
|
||||
}
|
||||
|
||||
@GetMapping("findUserFocusByUserId")
|
||||
@ApiOperation(value = "根据用户id查询用户的缓存配置信息及关注台站信息", notes = "根据用户id查询用户的缓存配置信息及关注台站信息")
|
||||
public Result findUserFocusByUserId(String userId){
|
||||
return sysUserFocusStationService.findUserFocusByUserId(userId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package org.jeecg.modules.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName(value = "station_receiving_config")
|
||||
public class StationReceivingConfig implements Serializable {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 缓存时间
|
||||
*/
|
||||
@TableField(value = "cache_time")
|
||||
private Double cacheTime;
|
||||
|
||||
/**
|
||||
* 间隔缩放
|
||||
*/
|
||||
@TableField(value = "scale_interval")
|
||||
private Double scaleInterval;
|
||||
|
||||
/**
|
||||
* 时间线长度
|
||||
*/
|
||||
@TableField(value = "timeline_length")
|
||||
private Double timelineLength;
|
||||
|
||||
/**
|
||||
* 更新间隔时间
|
||||
*/
|
||||
@TableField(value = "update_interval_time")
|
||||
private Double updateIntervalTime;
|
||||
|
||||
/**
|
||||
* 用户关注台站信息
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
List<SysUserFocusStation> sysUserFocusStations;
|
||||
|
||||
}
|
|
@ -41,9 +41,9 @@ public class SysUserFocusStation implements Serializable {
|
|||
/**
|
||||
* 类型
|
||||
*/
|
||||
@TableField(value = "type")
|
||||
@TableField(value = "station_type")
|
||||
@NotBlank(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
||||
private String type;
|
||||
private String stationType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
|
@ -58,15 +58,21 @@ public class SysUserFocusStation implements Serializable {
|
|||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
* 经度
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Double lon;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
* 纬度
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Double lat;
|
||||
|
||||
/**
|
||||
* 海拔
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String altitude;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package org.jeecg.modules.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UserFocusStation implements Serializable {
|
||||
|
||||
/**
|
||||
* 缓存时间
|
||||
*/
|
||||
private Double cacheTime;
|
||||
|
||||
/**
|
||||
* 间隔缩放
|
||||
*/
|
||||
private Double scaleInterval;
|
||||
|
||||
/**
|
||||
* 时间线长度
|
||||
*/
|
||||
private Double timelineLength;
|
||||
|
||||
/**
|
||||
* 更新间隔时间
|
||||
*/
|
||||
private Double updateIntervalTime;
|
||||
|
||||
/**
|
||||
* 台站id集合
|
||||
*/
|
||||
private List<Integer> stationIds;
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.entity.StationReceivingConfig;
|
||||
|
||||
public interface StationReceivingConfigMapper extends BaseMapper<StationReceivingConfig> {
|
||||
}
|
|
@ -3,6 +3,7 @@ package org.jeecg.modules.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.entity.SysUserFocusStation;
|
||||
import org.jeecg.modules.entity.UserFocusStation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -16,9 +17,9 @@ public interface ISysUserFocusStationService extends IService<SysUserFocusStatio
|
|||
|
||||
/**
|
||||
* 新增关注的台站,核设施信息
|
||||
* @param sysUserFocusStation
|
||||
* @param userFocusStation
|
||||
*/
|
||||
Result create(SysUserFocusStation sysUserFocusStation);
|
||||
Result create(UserFocusStation userFocusStation);
|
||||
|
||||
/**
|
||||
* 取消关注
|
||||
|
@ -26,4 +27,11 @@ public interface ISysUserFocusStationService extends IService<SysUserFocusStatio
|
|||
*/
|
||||
Result deleteById(String stationId);
|
||||
|
||||
/**
|
||||
* 根据用户id查询对应的缓存配置信息
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Result findUserFocusByUserId(String userId);
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.spatial4j.core.distance.DistanceUtils;
|
|||
import com.spatial4j.core.shape.Rectangle;
|
||||
import org.jeecg.common.CacheName;
|
||||
import org.jeecg.common.PointUtil;
|
||||
import org.jeecg.common.StationTypeUtil;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.modules.base.entity.GardsMetData;
|
||||
|
@ -64,13 +65,8 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
StationOperation stationOperation = new StationOperation();
|
||||
stationOperation.setStationId(gardsStation.getStationId());
|
||||
stationOperation.setStationName(gardsStation.getStationCode());
|
||||
if (gardsStation.getStationId()<=200){
|
||||
stationOperation.setStationType("IMS STATION(P)");
|
||||
}else if(gardsStation.getStationId()>200 && gardsStation.getStationId()<=300){
|
||||
stationOperation.setStationType("IMS STATION(G)");
|
||||
}else if(gardsStation.getStationId()>300){
|
||||
stationOperation.setStationType("NRL");
|
||||
}
|
||||
String stationType = StationTypeUtil.getStationType(gardsStation.getStationId());
|
||||
stationOperation.setStationType(stationType);
|
||||
stationOperation.setAltitude(Objects.isNull(gardsStation.getElevation())?"":gardsStation.getElevation()+"m");
|
||||
stationOperation.setLon(String.valueOf(gardsStation.getLon()));
|
||||
stationOperation.setLat(String.valueOf(gardsStation.getLat()));
|
||||
|
@ -103,7 +99,7 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
@Override
|
||||
public Result findInfo(String stationId, String type) {
|
||||
Result result = new Result();
|
||||
if (type.equals("IMS STATION(P)") || type.equals("IMS STATION(G)")){
|
||||
if (type.equals("IMS STATION(P)") || type.equals("IMS STATION(G)") || type.equals("NRL")){
|
||||
HashMap<String, GardsStations> stationInfoMap = (HashMap<String, GardsStations>) redisUtil.get("stationInfoMap");
|
||||
GardsStations stations = stationInfoMap.get(stationId);
|
||||
if (Objects.nonNull(stations)){
|
||||
|
@ -114,10 +110,13 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
}
|
||||
}else if(type.equals("Nuclear Facility")){
|
||||
HashMap<String, GardsNuclearfacility> nuclearFacilityMap = (HashMap<String, GardsNuclearfacility>) redisUtil.get("nuclearFacilityMap");
|
||||
//从缓存的核设施map中获取对应的核设施信息
|
||||
GardsNuclearfacility nuclearfacility = nuclearFacilityMap.get(stationId);
|
||||
if (Objects.nonNull(nuclearfacility)){
|
||||
nuclearfacility.setLongitude(PointUtil.calculate(nuclearfacility.getLatitude()));
|
||||
nuclearfacility.setLatitude(PointUtil.calculate(nuclearfacility.getLongitude()));
|
||||
String longitude = nuclearfacility.getLongitude();
|
||||
String latitude = nuclearfacility.getLatitude();
|
||||
nuclearfacility.setLongitude(PointUtil.calculate(latitude));
|
||||
nuclearfacility.setLatitude(PointUtil.calculate(longitude));
|
||||
result.setResult(nuclearfacility);
|
||||
result.setSuccess(true);
|
||||
}else {
|
||||
|
|
|
@ -3,15 +3,22 @@ package org.jeecg.modules.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.CacheName;
|
||||
import org.jeecg.common.StationTypeUtil;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.entity.StationReceivingConfig;
|
||||
import org.jeecg.modules.entity.SysUser;
|
||||
import org.jeecg.modules.entity.SysUserFocusStation;
|
||||
import org.jeecg.modules.entity.UserFocusStation;
|
||||
import org.jeecg.modules.mapper.StationReceivingConfigMapper;
|
||||
import org.jeecg.modules.mapper.SysUserFocusStationMapper;
|
||||
import org.jeecg.modules.mapper.SysUserMapper;
|
||||
import org.jeecg.modules.service.ICacheTimeService;
|
||||
import org.jeecg.modules.service.ISysUserFocusStationService;
|
||||
import org.jeecg.modules.system.entity.GardsStations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -20,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("sysUserFocusStationService")
|
||||
public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStationMapper, SysUserFocusStation> implements ISysUserFocusStationService {
|
||||
|
@ -28,6 +36,10 @@ public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStat
|
|||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
@Autowired
|
||||
private ICacheTimeService cacheTimeService;
|
||||
@Autowired
|
||||
private StationReceivingConfigMapper stationReceivingConfigMapper;
|
||||
|
||||
@Override
|
||||
public List<SysUserFocusStation> findList() {
|
||||
|
@ -39,8 +51,11 @@ public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStat
|
|||
if (CollectionUtils.isNotEmpty(stationInfoMap)){
|
||||
if (Objects.nonNull(stationInfoMap.get(item.getStationId()))){
|
||||
GardsStations stations = (GardsStations) stationInfoMap.get(item.getStationId());
|
||||
String stationType = StationTypeUtil.getStationType(stations.getStationId());
|
||||
item.setStationType(stationType);
|
||||
item.setLon(stations.getLon());
|
||||
item.setLat(stations.getLat());
|
||||
item.setAltitude(Objects.isNull(stations.getElevation())?"":stations.getElevation()+"m");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -51,7 +66,7 @@ public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStat
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result create(SysUserFocusStation sysUserFocusStation) {
|
||||
public Result create(UserFocusStation userFocusStation) {
|
||||
Result result = new Result();
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
|
@ -65,12 +80,49 @@ public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStat
|
|||
result.error500("当前用户不存在!");
|
||||
return result;
|
||||
}
|
||||
Long id = IdWorker.getId();
|
||||
sysUserFocusStation.setId(String.valueOf(id));
|
||||
sysUserFocusStation.setUserId(sysUser.getId());
|
||||
sysUserFocusStation.setCreateTime(new Date());
|
||||
sysUserFocusStation.setCreateBy(username);
|
||||
this.baseMapper.insert(sysUserFocusStation);
|
||||
//判断传递参数信息是否为空
|
||||
if (Objects.nonNull(userFocusStation)){
|
||||
//通过用户id判断是否存在用户的缓存配置信息
|
||||
LambdaQueryWrapper<StationReceivingConfig> receivingConfigQueryWrapper = new LambdaQueryWrapper<>();
|
||||
receivingConfigQueryWrapper.eq(StationReceivingConfig::getUserId, sysUser.getId());
|
||||
StationReceivingConfig receivingConfig = stationReceivingConfigMapper.selectOne(receivingConfigQueryWrapper);
|
||||
//如果没有对应的用户缓存信息 则进行新增
|
||||
if (Objects.isNull(receivingConfig)){
|
||||
receivingConfig = new StationReceivingConfig();
|
||||
Long id = IdWorker.getId();
|
||||
receivingConfig.setId(id.toString());
|
||||
receivingConfig.setUserId(sysUser.getId());
|
||||
receivingConfig.setCacheTime(userFocusStation.getCacheTime());
|
||||
receivingConfig.setScaleInterval(userFocusStation.getScaleInterval());
|
||||
receivingConfig.setTimelineLength(userFocusStation.getTimelineLength());
|
||||
receivingConfig.setUpdateIntervalTime(userFocusStation.getUpdateIntervalTime());
|
||||
stationReceivingConfigMapper.insert(receivingConfig);
|
||||
}else {
|
||||
receivingConfig.setCacheTime(userFocusStation.getCacheTime());
|
||||
receivingConfig.setScaleInterval(userFocusStation.getScaleInterval());
|
||||
receivingConfig.setTimelineLength(userFocusStation.getTimelineLength());
|
||||
receivingConfig.setUpdateIntervalTime(userFocusStation.getUpdateIntervalTime());
|
||||
stationReceivingConfigMapper.updateById(receivingConfig);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(userFocusStation.getStationIds())){
|
||||
//根据用户id查询出对应的用户关注台站信息 删除用户的所有关注台站信息并重新保存
|
||||
LambdaQueryWrapper<SysUserFocusStation> userFocusStationQueryWrapper = new LambdaQueryWrapper<>();
|
||||
userFocusStationQueryWrapper.eq(SysUserFocusStation::getUserId, sysUser.getId());
|
||||
this.baseMapper.delete(userFocusStationQueryWrapper);
|
||||
for (Integer stationId:userFocusStation.getStationIds()) {
|
||||
SysUserFocusStation sysUserFocusStation = new SysUserFocusStation();
|
||||
Long id = IdWorker.getId();
|
||||
sysUserFocusStation.setId(String.valueOf(id));
|
||||
sysUserFocusStation.setUserId(sysUser.getId());
|
||||
sysUserFocusStation.setStationId(String.valueOf(stationId));
|
||||
String stationType = StationTypeUtil.getStationType(stationId);
|
||||
sysUserFocusStation.setStationType(stationType);
|
||||
sysUserFocusStation.setCreateTime(new Date());
|
||||
sysUserFocusStation.setCreateBy(username);
|
||||
this.baseMapper.insert(sysUserFocusStation);
|
||||
}
|
||||
}
|
||||
result.success("新增成功");
|
||||
return result;
|
||||
}
|
||||
|
@ -99,4 +151,44 @@ public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStat
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findUserFocusByUserId(String userId) {
|
||||
Result result = new Result();
|
||||
//根据用户id查询存储的缓存配置信息
|
||||
LambdaQueryWrapper<StationReceivingConfig> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(StationReceivingConfig::getUserId, userId);
|
||||
StationReceivingConfig receivingConfig = stationReceivingConfigMapper.selectOne(queryWrapper);
|
||||
//如果用户对应的缓存配置信息为空时,查询字典表中的默认值
|
||||
if (Objects.isNull(receivingConfig)){
|
||||
receivingConfig = new StationReceivingConfig();
|
||||
//调用接口获取数据库中对应缓存配置信息默认值
|
||||
List<Map<String, String>> cacheList = cacheTimeService.findCacheTime();
|
||||
for (int i=0; i< cacheList.size(); i++){
|
||||
if ( StringUtils.isNotBlank(cacheList.get(i).get(CacheName.cacheTime)) ){
|
||||
String cacheTime = cacheList.get(i).get(CacheName.cacheTime);
|
||||
receivingConfig.setCacheTime(Double.valueOf(cacheTime));
|
||||
}else if ( StringUtils.isNotBlank(cacheList.get(i).get(CacheName.scaleInterval)) ){
|
||||
String scaleInterval = cacheList.get(i).get(CacheName.scaleInterval);
|
||||
receivingConfig.setScaleInterval(Double.valueOf(scaleInterval));
|
||||
}else if ( StringUtils.isNotBlank(cacheList.get(i).get(CacheName.timelineLength)) ){
|
||||
String timelineLength = cacheList.get(i).get(CacheName.timelineLength);
|
||||
receivingConfig.setTimelineLength(Double.valueOf(timelineLength));
|
||||
}else if ( StringUtils.isNotBlank(cacheList.get(i).get(CacheName.updateIntervalTime)) ){
|
||||
String updateIntervalTime = cacheList.get(i).get(CacheName.updateIntervalTime);
|
||||
receivingConfig.setUpdateIntervalTime(Double.valueOf(updateIntervalTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
//根据用户id查询出用户的关注台站信息
|
||||
LambdaQueryWrapper<SysUserFocusStation> focusStationQueryWrapper = new LambdaQueryWrapper<>();
|
||||
focusStationQueryWrapper.eq(SysUserFocusStation::getUserId, userId);
|
||||
List<SysUserFocusStation> sysUserFocusStations = this.baseMapper.selectList(focusStationQueryWrapper);
|
||||
if (Objects.nonNull(sysUserFocusStations)){
|
||||
receivingConfig.setSysUserFocusStations(sysUserFocusStations);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(receivingConfig);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user