获取有走航车数据日期,device修改,绑定国控站
5 files added
12 files modified
| | |
| | | } |
| | | |
| | | /** |
| | | * @param mac 设备mac |
| | | * @return 返回请求成功后的对象信息 |
| | | */ |
| | | @GetMapping("getDates") |
| | | @ApiOperation(value = "获取有走航数据的日期", notes = "获取有走航数据的日期") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), |
| | | @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String") |
| | | }) |
| | | public ResultMessage getDates(String mac) { |
| | | if (ObjectUtils.isEmpty(mac)) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | List<String> response = specialDeviceService.getDatesByMac(mac); |
| | | return ResultMessage.ok(response); |
| | | } |
| | | |
| | | /** |
| | | * @param request 请求信息 |
| | | * @return 返回请求成功后的对象信息 |
| | | */ |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * 走航车秒数据表 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-09-13 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class HistorySecondCruiser extends Model<HistorySecondCruiser> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 设备mac |
| | | */ |
| | | private String mac; |
| | | |
| | | /** |
| | | * 数据时间 |
| | | */ |
| | | private Date time; |
| | | |
| | | /** |
| | | * 数据 |
| | | */ |
| | | private String value; |
| | | |
| | | /** |
| | | * 此数据所属组织id |
| | | */ |
| | | private Integer organizationId; |
| | | |
| | | /** |
| | | * 数据批次 |
| | | */ |
| | | private Date batch; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return null; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.moral.api.entity.HistorySecondCruiser; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * 走航车秒数据表 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-09-13 |
| | | */ |
| | | public interface HistorySecondCruiserMapper extends BaseMapper<HistorySecondCruiser> { |
| | | |
| | | List<String> getDates(Map<String,Object> params); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import com.moral.api.entity.HistorySecondCruiser; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 走航车秒数据表 服务类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-09-13 |
| | | */ |
| | | public interface HistorySecondCruiserService extends IService<HistorySecondCruiser> { |
| | | |
| | | } |
| | |
| | | */ |
| | | SpecialDevice getSpecialDeviceByMac(String mac); |
| | | |
| | | //获取半年内有数据的走航日期 |
| | | List<String> getDatesByMac(String mac); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.moral.api.entity.HistorySecondCruiser; |
| | | import com.moral.api.mapper.HistorySecondCruiserMapper; |
| | | import com.moral.api.service.HistorySecondCruiserService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 走航车秒数据表 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-09-13 |
| | | */ |
| | | @Service |
| | | public class HistorySecondCruiserServiceImpl extends ServiceImpl<HistorySecondCruiserMapper, HistorySecondCruiser> implements HistorySecondCruiserService { |
| | | |
| | | } |
| | |
| | | |
| | | 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.mapper.HistorySecondSpecialMapper; |
| | | import com.moral.api.mapper.SpecialDeviceMapper; |
| | | import com.moral.api.service.OrganizationService; |
| | |
| | | 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; |
| | | |
| | |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | SpecialDeviceMapper specialDeviceMapper; |
| | | |
| | | @Autowired |
| | | private HistorySecondCruiserMapper historySecondCruiserMapper; |
| | | |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | |
| | |
| | | return specialDevice; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getDatesByMac(String mac) { |
| | | Map<String, Object> userInfo = (Map) TokenUtils.getUserInfo(); |
| | | Map<String, Object> orgInfo = (Map) userInfo.get("organization"); |
| | | Integer orgId = (Integer) orgInfo.get("id"); |
| | | |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("orgId", orgId); |
| | | params.put("mac", mac); |
| | | Date start = DateUtils.addMonths(new Date(), -6); |
| | | params.put("start", DateUtils.dateToDateString(start)); |
| | | return historySecondCruiserMapper.getDates(params); |
| | | } |
| | | |
| | | |
| | | //根据距离筛选数据 |
| | | private List<Map<String, Object>> filterData(List<Map<String, Object>> data) { |
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.HistorySecondCruiserMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.HistorySecondCruiser"> |
| | | <result column="mac" property="mac"/> |
| | | <result column="time" property="time"/> |
| | | <result column="value" property="value"/> |
| | | <result column="organization_id" property="organizationId"/> |
| | | <result column="batch" property="batch"/> |
| | | </resultMap> |
| | | |
| | | <select id="getDates" resultType="java.lang.String"> |
| | | SELECT DISTINCT DATE_FORMAT(`time`,'%Y-%m-%d') `time` |
| | | FROM history_second_cruiser |
| | | WHERE mac = #{mac} |
| | | AND organization_id = #{orgId} |
| | | AND `time` <![CDATA[>=]]> #{start} |
| | | ORDER BY `time` |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | |
| | | String mac = device.getMac(); |
| | | Integer monitorPointId = device.getMonitorPointId(); |
| | | Integer versionId = device.getDeviceVersionId(); |
| | | if (name == null || mac == null || monitorPointId == null || versionId == null) { |
| | | if (ObjectUtils.isEmpty(name) || ObjectUtils.isEmpty(mac) || ObjectUtils.isEmpty(monitorPointId) || ObjectUtils.isEmpty(versionId)) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.WebUtils; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | govMonitorPointService.delete(id); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取该区域下所有国控/省控/县控站点", notes = "获取该区域下所有国控/省控/县控站点") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @GetMapping("govMonitorPoints") |
| | | public ResultMessage selectGovMonitorPoints(String regionCode) { |
| | | List<Map<String, Object>> response = govMonitorPointService.selectGovMonitorPoints(regionCode); |
| | | return ResultMessage.ok(response); |
| | | } |
| | | } |
| | |
| | | private Integer organizationId; |
| | | |
| | | /** |
| | | * 国控站/省控站/县控站标示,与gov_monitor_point中guid对应 |
| | | */ |
| | | private String guid; |
| | | |
| | | /** |
| | | * 设备型号id |
| | | */ |
| | | private Integer deviceVersionId; |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | |
| | | import java.util.List; |
| | | |
| | | import com.moral.api.entity.Device; |
| | | import com.moral.api.entity.GovMonitorPoint; |
| | | import com.moral.api.entity.ManageAccount; |
| | | import com.moral.api.entity.MonitorPoint; |
| | | import com.moral.api.entity.Organization; |
| | |
| | | private MonitorPoint monitorPoint; |
| | | |
| | | /* |
| | | * 国控站点 |
| | | * */ |
| | | private GovMonitorPoint govMonitorPoint; |
| | | |
| | | /* |
| | | * 维护人 |
| | | * */ |
| | | private List<ManageAccount> operators; |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | **/ |
| | | GovMonitorPoint selectGovMonitorPointInfoById(int id); |
| | | |
| | | //获取区域下政府站点列表 |
| | | List<Map<String, Object>> selectGovMonitorPoints(String regionCode); |
| | | |
| | | } |
| | |
| | | import com.moral.api.service.DeviceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import com.moral.api.service.GovMonitorPointService; |
| | | import com.moral.api.service.SysDictDataService; |
| | | import com.moral.api.util.CacheUtils; |
| | | import com.moral.api.util.AdjustDataUtils; |
| | |
| | | mpInfo.put("provinceCode", monitorPoint.getProvinceCode()); |
| | | deviceInfo.put("monitorPoint", mpInfo); |
| | | |
| | | //国控站点 |
| | | Map<String, Object> govMpInfo = new LinkedHashMap<>(); |
| | | |
| | | govMpInfo.put("guid", null); |
| | | govMpInfo.put("name", null); |
| | | if (device.getGovMonitorPoint() != null) { |
| | | govMpInfo.put("guid", device.getGovMonitorPoint().getGuid()); |
| | | govMpInfo.put("name", device.getGovMonitorPoint().getName()); |
| | | } |
| | | deviceInfo.put("govMonitorPoint", govMpInfo); |
| | | setDeviceInfoToRedis(mac, deviceInfo); |
| | | return deviceInfo; |
| | | } |
| | |
| | | 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) deviceInfo.get("govMonitorPoint"); |
| | | if (ObjectUtils.isEmpty(govMpInfo.get("guid"))) { |
| | | return deviceData; |
| | | } |
| | | String guid = (String) govMpInfo.get("guid"); |
| | | //获取国控站aqi数据 |
| | | Map<String, Object> aqiMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, guid); |
| | | return adjustDataUtils.adjust(deviceData, adjustFormula, ObjectUtils.isEmpty(aqiMap) ? null : aqiMap); |
| | | } |
| | | deviceData.remove("DataTime"); |
| | |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.util.RegionCodeUtils; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.lang.reflect.Field; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | |
| | | GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectById(id); |
| | | return govMonitorPoint; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectGovMonitorPoints(String regionCode) { |
| | | QueryWrapper<GovMonitorPoint> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("guid", "name").eq("is_delete", Constants.NOT_DELETE); |
| | | if (!ObjectUtils.isEmpty(regionCode)) { |
| | | String regionName = RegionCodeUtils.regionCodeConvertToName(Integer.parseInt(regionCode)); |
| | | queryWrapper.eq(regionName, regionCode); |
| | | } |
| | | return govMonitorPointMapper.selectMaps(queryWrapper); |
| | | } |
| | | } |
| | |
| | | <result column="operate_ids" property="operateIds"/> |
| | | <result column="monitor_point_id" property="monitorPointId"/> |
| | | <result column="organization_id" property="organizationId"/> |
| | | <result column="guid" property="guid"/> |
| | | <result column="device_version_id" property="deviceVersionId"/> |
| | | <result column="profession" property="profession"/> |
| | | <result column="tech" property="tech"/> |
| | |
| | | <result column="mp_area_code" property="areaCode"/> |
| | | <result column="mp_city_code" property="cityCode"/> |
| | | <result column="mp_province_code" property="provinceCode"/> |
| | | </association> |
| | | |
| | | <!--国控站点--> |
| | | <association property="govMonitorPoint" javaType="com.moral.api.entity.GovMonitorPoint"> |
| | | <result column="gmp_guid" property="guid"/> |
| | | <result column="gmp_name" property="name"/> |
| | | </association> |
| | | |
| | | <!--型号--> |
| | |
| | | mp.area_code mp_area_code, |
| | | mp.city_code mp_city_code, |
| | | mp.province_code mp_province_code, |
| | | gmp.guid gmp_guid, |
| | | gmp.name gmp_name, |
| | | ma.id operate_id, |
| | | v.id version_id, |
| | | v.`name` version_name, |
| | |
| | | ON d.organization_id = o.id |
| | | LEFT JOIN `monitor_point` mp |
| | | ON mp.id = d.monitor_point_id |
| | | LEFT JOIN `gov_monitor_point` gmp |
| | | ON gmp.guid = d.guid |
| | | LEFT JOIN `manage_account` ma |
| | | ON FIND_IN_SET |
| | | ( |