screnn_api特殊设备实体类修改,走航车实时websocket,manage设备补偿
6 files added
11 files modified
| | |
| | | @GetMapping("selectCruisers") |
| | | @ApiOperation(value = "获取当前组织下所有走航车列表", notes = "走航车轨迹") |
| | | public ResultMessage getCarsInfo() { |
| | | List<Map<String, Object>> response = specialDeviceService.getCarsInfo(); |
| | | List<Map<String, Object>> response = specialDeviceService.selectCruisers(); |
| | | return ResultMessage.ok(response); |
| | | } |
| | | |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-09-16 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class GovMonitorPoint extends Model<GovMonitorPoint> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * id |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 政府站点code |
| | | */ |
| | | private String guid; |
| | | |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 经度 |
| | | */ |
| | | private Double longitude; |
| | | |
| | | /** |
| | | * 纬度 |
| | | */ |
| | | private Double latitude; |
| | | |
| | | /** |
| | | * 省编码 |
| | | */ |
| | | private Integer provinceCode; |
| | | |
| | | /** |
| | | * 市编码 |
| | | */ |
| | | private Integer cityCode; |
| | | |
| | | /** |
| | | * 县/区编码 |
| | | */ |
| | | private Integer areaCode; |
| | | |
| | | /** |
| | | * 政府站点类型:国控、省控、县控 |
| | | */ |
| | | private String stationLevel; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 是否删除 |
| | | */ |
| | | private String isDelete; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String desc; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-08-18 |
| | | * @since 2021-08-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-08-26 |
| | | * @since 2021-08-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | |
| | | private String mac; |
| | | |
| | | /** |
| | | * 政府站点id |
| | | */ |
| | | private String guid; |
| | | |
| | | /** |
| | | * 维护人id,多个逗号隔开,来源于manage_account |
| | | */ |
| | | private String operateIds; |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import com.moral.api.entity.GovMonitorPoint; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-09-16 |
| | | */ |
| | | public interface GovMonitorPointMapper extends BaseMapper<GovMonitorPoint> { |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.pojo.redisBean; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.moral.api.entity.GovMonitorPoint; |
| | | import com.moral.api.entity.ManageAccount; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.entity.SpecialDevice; |
| | | import com.moral.api.entity.Version; |
| | | |
| | | /** |
| | | * @program: screen |
| | | * @description: 特殊设备存入redis实体类 |
| | | * @author: lizijie |
| | | * @create: 2021-09-14 16:41 |
| | | **/ |
| | | @Data |
| | | public class SpecialDeviceInfoDTO { |
| | | |
| | | /** |
| | | * 特殊设备 |
| | | */ |
| | | private SpecialDevice specialDevice; |
| | | |
| | | /** |
| | | * 政府站点 |
| | | */ |
| | | private GovMonitorPoint govMonitorPoint; |
| | | |
| | | /** |
| | | * 型号 |
| | | */ |
| | | private Version version; |
| | | |
| | | /** |
| | | * 维护人 |
| | | */ |
| | | private List<ManageAccount> operates; |
| | | |
| | | /** |
| | | * 组织 |
| | | */ |
| | | private Organization organization; |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import com.moral.api.entity.GovMonitorPoint; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-09-16 |
| | | */ |
| | | public interface GovMonitorPointService extends IService<GovMonitorPoint> { |
| | | |
| | | } |
| | |
| | | public interface SpecialDeviceService extends IService<SpecialDevice> { |
| | | |
| | | //获取该组织下所有走航车设备列表 |
| | | List<Map<String, Object>> getCarsInfo(); |
| | | List<Map<String, Object>> selectCruisers(); |
| | | |
| | | //走航车轨迹 |
| | | List<Map<String, Object>> carTrajectory(Map<String, Object> params); |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.moral.api.entity.GovMonitorPoint; |
| | | import com.moral.api.mapper.GovMonitorPointMapper; |
| | | import com.moral.api.service.GovMonitorPointService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-09-16 |
| | | */ |
| | | @Service |
| | | public class GovMonitorPointServiceImpl extends ServiceImpl<GovMonitorPointMapper, GovMonitorPoint> implements GovMonitorPointService { |
| | | |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.HistorySecondSpecial; |
| | | import com.moral.api.entity.Organization; |
| | | |
| | | import com.moral.api.entity.SpecialDevice; |
| | | import com.moral.api.entity.SpecialDeviceHistory; |
| | | import com.moral.api.mapper.HistorySecondCruiserMapper; |
| | |
| | | import com.moral.api.service.SpecialDeviceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | |
| | | import com.moral.util.DateUtils; |
| | | import com.moral.util.GeodesyUtils; |
| | | import com.moral.util.TokenUtils; |
| | |
| | | private final static Double dis = 50d; |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getCarsInfo() { |
| | | public List<Map<String, Object>> selectCruisers() { |
| | | //获取当前用户信息 |
| | | Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo(); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization"); |
| | |
| | | QueryWrapper<SpecialDeviceHistory> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("mac", "name") |
| | | .eq("organization_id", orgId) |
| | | .eq("special_type", Constants.SPECIAL_DEVICE_CAR) |
| | | .eq("special_type", Constants.SPECIAL_DEVICE_CRUISER) |
| | | .eq("is_delete", Constants.NOT_DELETE); |
| | | return specialDeviceHistoryService.listMaps(queryWrapper); |
| | | } |
| | |
| | | @Override |
| | | public SpecialDevice getSpecialDeviceMapByMac(String mac) { |
| | | QueryWrapper<SpecialDevice> queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("mac",mac); |
| | | queryWrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | queryWrapper.eq("mac", mac); |
| | | queryWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | SpecialDevice specialDevice = specialDeviceMapper.selectOne(queryWrapper); |
| | | return specialDevice; |
| | | } |
| | |
| | | |
| | | import com.moral.api.entity.SpecialDevice; |
| | | import com.moral.api.entity.UnitConversion; |
| | | import com.moral.api.pojo.redisBean.SpecialDeviceInfoDTO; |
| | | import com.moral.constant.RedisConstants; |
| | | |
| | | //走航车实时websocket |
| | |
| | | this.session = session; |
| | | this.mac = mac; |
| | | this.specialDevice = (SpecialDevice) redisTemplate.opsForHash().get(RedisConstants.SPECIAL_DEVICE_INFO, mac); |
| | | //获取设备地区对应的AQI用于补偿使用 |
| | | /*Map<String, Object> deviceInfo = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.DEVICE, mac); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) deviceInfo.get("organization"); |
| | | String areaCode = String.valueOf(orgInfo.get("areaCode")); |
| | | String cityCode = String.valueOf(orgInfo.get("cityCode")); |
| | | try { |
| | | this.regionAqi = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, areaCode); |
| | | if (ObjectUtils.isEmpty(this.regionAqi)) |
| | | this.regionAqi = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, cityCode); |
| | | //获取设备信息 |
| | | SpecialDeviceInfoDTO deviceInfo = (SpecialDeviceInfoDTO) redisTemplate.opsForHash().get(RedisConstants.SPECIAL_DEVICE, mac); |
| | | //获取与设备绑定的国控站guid, |
| | | String guid = deviceInfo.getSpecialDevice().getGuid(); |
| | | if (!ObjectUtils.isEmpty(guid)) { |
| | | //获取国控aqi数据,用于补偿 |
| | | this.regionAqi = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, guid); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | }*/ |
| | | } |
| | | sockets.add(this); |
| | | } |
| | | |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.GovMonitorPointMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.GovMonitorPoint"> |
| | | <id column="id" property="id"/> |
| | | <result column="guid" property="guid"/> |
| | | <result column="name" property="name"/> |
| | | <result column="longitude" property="longitude"/> |
| | | <result column="latitude" property="latitude"/> |
| | | <result column="province_code" property="provinceCode"/> |
| | | <result column="city_code" property="cityCode"/> |
| | | <result column="area_code" property="areaCode"/> |
| | | <result column="station_level" property="stationLevel"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="is_delete" property="isDelete"/> |
| | | <result column="desc" property="desc"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | |
| | | <id column="id" property="id"/> |
| | | <result column="name" property="name"/> |
| | | <result column="mac" property="mac"/> |
| | | <result column="guid" property="guid"/> |
| | | <result column="operate_ids" property="operateIds"/> |
| | | <result column="organization_id" property="organizationId"/> |
| | | <result column="device_version_id" property="deviceVersionId"/> |
| | |
| | | <id column="id" property="id"/> |
| | | <result column="name" property="name"/> |
| | | <result column="mac" property="mac"/> |
| | | <result column="guid" property="guid"/> |
| | | <result column="operate_ids" property="operateIds"/> |
| | | <result column="organization_id" property="organizationId"/> |
| | | <result column="device_version_id" property="deviceVersionId"/> |
| | |
| | | /* |
| | | * 字典表走航车设备类型 |
| | | * */ |
| | | public static final String SPECIAL_DEVICE_CAR = "0"; |
| | | public static final String SPECIAL_DEVICE_CRUISER = "0"; |
| | | |
| | | /* |
| | | * 字典表无人机设备类型 |
| | |
| | | Map<String, Object> adjustFormula = redisTemplate.opsForHash().entries(RedisConstants.ADJUST + "_" + mac); |
| | | if (!ObjectUtils.isEmpty(adjustFormula)) { |
| | | Map<String, Object> deviceInfo = getDeviceByMac(mac); |
| | | Map<String, Object> monitorPoint = (Map<String, Object>) deviceInfo.get("monitorPoint"); |
| | | String areaCode = monitorPoint.get("areaCode").toString(); |
| | | String cityCode = monitorPoint.get("cityCode").toString(); |
| | | |
| | | Map<String, Object> aqiMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, areaCode); |
| | | if (ObjectUtils.isEmpty(aqiMap)) { |
| | | aqiMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, cityCode); |
| | | //获取设备绑定的国控站信息 |
| | | Map<String, Object> govMpInfo = (Map<String, Object>) deviceInfo.get("govMonitorPoint"); |
| | | Map<String, Object> aqiMap = null; |
| | | if (govMpInfo.get("guid") != null) { |
| | | aqiMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, govMpInfo.get("guid").toString()); |
| | | } |
| | | return adjustDataUtils.adjust(deviceData, adjustFormula, ObjectUtils.isEmpty(aqiMap) ? null : aqiMap); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 判断组织是否含有该设备的型号,如果没有则添加到组织型号关系表中 |
| | | * @Param: [orgId, versionId] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/9/6 |
| | | */ |
| | | * @Description: 判断组织是否含有该设备的型号,如果没有则添加到组织型号关系表中 |
| | | * @Param: [orgId, versionId] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/9/6 |
| | | */ |
| | | private void insertOrganizationUnitAlarm(Integer orgId, Integer versionId) { |
| | | //查询是否含有该型号 |
| | | QueryWrapper<OrganizationUnitAlarm> queryOrganizationVersionWrapper = new QueryWrapper<>(); |
| | |
| | | String sensorCode = versionSensorUnit.getSensorCode(); |
| | | //设置默认报警值 |
| | | SysDictData alarm = sensorAlarms.get(sensorCode); |
| | | if(alarm!=null) |
| | | if (alarm != null) |
| | | organizationUnitAlarm.setAlarmLevel(alarm.getDataValue()); |
| | | organizationUnitAlarm.setOrganizationId(orgId); |
| | | organizationUnitAlarm.setVersionId(versionId); |
| | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 删除设备后,如果该组织没有这个设备型号其他的设备了,则删除组织型号关系表中该型号的信息。 |
| | | * @Param: [orgId, versionId] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/9/6 |
| | | */ |
| | | * @Description: 删除设备后,如果该组织没有这个设备型号其他的设备了,则删除组织型号关系表中该型号的信息。 |
| | | * @Param: [orgId, versionId] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/9/6 |
| | | */ |
| | | private void deleteOrganizationUnitAlarm(Integer orgId, Integer versionId) { |
| | | QueryWrapper<Device> queryOrganizationVersionWrapper = new QueryWrapper<>(); |
| | | queryOrganizationVersionWrapper.eq("organization_id", orgId); |
| | |
| | | /** |
| | | * @param deviceData 设备数据 |
| | | * @param adjustFormula 校准公式 |
| | | * @param aqiMap 设备所在地区对应的墨迹aqi数据 |
| | | * @param aqiMap 与设备绑定的国控站点aqi数据 |
| | | * @return Map<String, Object> 校准后数据 |
| | | */ |
| | | public Map<String, Object> adjust(Map<String, Object> deviceData, Map<String, Object> adjustFormula, Map<String, Object> aqiMap) { |