bug修复

This commit is contained in:
guo 2023-12-16 11:32:44 +08:00
parent 232c6507d9
commit 67ee1959a1
22 changed files with 313 additions and 220 deletions

View File

@ -11,12 +11,14 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import com.gexin.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -37,9 +39,9 @@ public class AirQualityAnalysisController {
private IAirQualityAnalysisService airQualityAnalysisService;
/**
* 添加
*
* @param airQualityAnalysis
* @return
*/
@ -62,6 +64,7 @@ public class AirQualityAnalysisController {
/**
* 通过id查询
*
* @param
* @return
*/
@ -88,7 +91,7 @@ public class AirQualityAnalysisController {
}
@ApiOperation(value = "查询天气", notes = "查询天气" , httpMethod="POST")
@ApiOperation(value = "查询天气-周", notes = "查询天气-周", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "cityid", value = "市区编码", paramType = "query", required = false, dataType = "String"),
})
@ -97,4 +100,13 @@ public class AirQualityAnalysisController {
return Result.success(airQualityAnalysisService.getWeatherData(MapUtils.getString(map, "cityid")));
}
@ApiOperation(value = "查询天气实况", notes = "查询天气实况", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "cityid", value = "市区编码", paramType = "body", required = false, dataType = "String"),
})
@PostMapping(value = "/getWeatherLiveData")
public Result<Object> getWeatherLiveData(@RequestBody Map<String, Object> map) {
return Result.success(airQualityAnalysisService.getWeatherLiveData(MapUtils.getString(map, "cityid")));
}
}

View File

@ -3,7 +3,9 @@ package com.zhgd.xmgl.modules.environment.service;
import com.zhgd.xmgl.modules.environment.entity.AirQualityAnalysis;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.environment.entity.vo.AirQualityStatisticsVo;
import com.gexin.fastjson.JSONObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -22,4 +24,6 @@ public interface IAirQualityAnalysisService extends IService<AirQualityAnalysis>
void deleteProjectAirQualityAnalysis(String projectSn);
String getWeatherData(String cityid);
Object getWeatherLiveData(String cityid);
}

View File

@ -1,4 +1,5 @@
package com.zhgd.xmgl.modules.environment.service.impl;
import com.gexin.fastjson.JSONObject;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
@ -106,4 +107,11 @@ public class AirQualityAnalysisServiceImpl extends ServiceImpl<AirQualityAnalysi
}
return AqiUtil.getWeatherData(weathercityid);
}
@Override
public Object getWeatherLiveData(String cityid) {
QueryWrapper<SystemCities> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SystemCities::getCityid, cityid);
return AqiUtil.getLiveWeatherInfo(cityid);
}
}

View File

@ -12,10 +12,12 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
@ -42,7 +44,7 @@ public class HighSlopeEngineeringController {
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "body", required = true, dataType = "Integer"),
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "body", required = true, dataType = "Integer"),
})
@PostMapping(value = "/list")
@PostMapping(value = "/page")
public Result<IPage<HighSlopeEngineering>> queryPageList(@RequestBody Map<String, Object> map) {
return Result.success(highSlopeEngineeringService.selectHighSlopeEngineeringPage(map));
}
@ -54,7 +56,7 @@ public class HighSlopeEngineeringController {
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", required = true, dataType = "String"),
})
@PostMapping(value = "/selectHighSlopeList")
@PostMapping(value = "/list")
public Result<List<HighSlopeEngineering>> selectHighSlopeList(@RequestBody Map<String, Object> map) {
return Result.success(highSlopeEngineeringService.selectHighSlopeList(map));
}
@ -67,7 +69,7 @@ public class HighSlopeEngineeringController {
*/
@ApiOperation(value = "添加高边坡-工程信息", notes = "添加高边坡-工程信息", httpMethod = "POST")
@PostMapping(value = "/add")
public Result<HighSlopeEngineering> add(@RequestBody HighSlopeEngineering highSlopeEngineering) {
public Result<HighSlopeEngineering> add(@RequestBody @Validated HighSlopeEngineering highSlopeEngineering) {
highSlopeEngineeringService.saveHighSlopeEngineering(highSlopeEngineering);
return Result.ok();
}
@ -93,7 +95,7 @@ public class HighSlopeEngineeringController {
@ApiOperation(value = "删除高边坡-工程信息", notes = "删除高边坡-工程信息", httpMethod = "POST")
@ApiImplicitParam(name = "id", value = "高边坡-工程ID", paramType = "body", required = true, dataType = "Integer")
@PostMapping(value = "/delete")
public Result<HighSlopeEngineering> delete(@RequestBody Map<String, Object> map) {
public Result<HighSlopeEngineering> delete(@ApiIgnore @RequestBody Map<String, Object> map) {
highSlopeEngineeringService.deleteHighSlopeEngineering(MapUtils.getLong(map, "id"));
return Result.ok();
}

View File

@ -123,7 +123,7 @@ public class HighSlopeCurrentData implements Serializable {
@Excel(name = "高边坡名称", width = 15)
@ApiModelProperty(value = "高边坡名称")
@TableField(exist = false)
private String engineeringName;
private String slopeName;
/**

View File

@ -1,24 +1,23 @@
package com.zhgd.xmgl.modules.highslope.entity;
import java.io.Serializable;
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 com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description: 高边坡-工程
* 基坑<a>检测内容
* a>测点>传感器
* a>测点>传感器>实时数据
* a>实时数据
* 基坑>平面图<b>测点
* @author pds
@ -52,17 +51,17 @@ public class HighSlopeEngineering implements Serializable {
/**
* 开工日期
*/
@Excel(name = "开工日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "开工日期", width = 20, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "开工日期")
private java.util.Date startDate;
/**
* 完工日期
*/
@Excel(name = "完工日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "完工日期", width = 20, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "完工日期")
private java.util.Date endDate;
/**
@ -94,19 +93,19 @@ public class HighSlopeEngineering implements Serializable {
*/
@Excel(name = "监测方案", width = 15)
@ApiModelProperty(value = "监测方案")
private java.lang.Object surveyScheme;
private String surveyScheme;
/**
* 地勘报告
*/
@Excel(name = "地勘报告", width = 15)
@ApiModelProperty(value = "地勘报告")
private java.lang.Object prospectingReport;
private String prospectingReport;
/**
* 设计图纸
*/
@Excel(name = "设计图纸", width = 15)
@ApiModelProperty(value = "设计图纸")
private java.lang.Object deviseDrawing;
private String deviseDrawing;
/**
* 安全等级
*/
@ -136,8 +135,9 @@ public class HighSlopeEngineering implements Serializable {
@ApiModelProperty(value = "更新时间 yyyy-MM-dd HH:mm:ss")
private java.util.Date updateTime;
@ApiModelProperty(value = "默认监测内容ID")
@ApiModelProperty(value = "高边坡-监测类型表id多个,分隔)")
@TableField(exist = false)
private String monitorTypeIds;
@NotBlank
private String highSlopeMonitorTypeIds;
}

View File

@ -13,13 +13,6 @@ import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @ClassName HighSlopeMonitorType
* @author 邱平毅
* @date 2022/8/19 11:25
* @Version 1.0
*/
/**
* 高边坡-监测类型表
*/

View File

@ -144,7 +144,7 @@ public class HighSlopeSensor implements Serializable {
*/
@ApiModelProperty(value = "高边坡名称")
@TableField(exist = false)
private String engineeringName;
private String slopeName;
/**
* 测点名称
@ -175,8 +175,8 @@ public class HighSlopeSensor implements Serializable {
@TableField(exist = false)
private String unit;
@TableField(exist = false)
@ApiModelProperty(value = "传感器编码")
@TableField(exist = false)
private String sensorTypeCode;

View File

@ -3,7 +3,7 @@
<mapper namespace="com.zhgd.xmgl.modules.highslope.mapper.HighSlopeCurrentDataMapper">
<select id="selectPageByProjectSn"
resultType="com.zhgd.xmgl.modules.highslope.entity.HighSlopeCurrentData">
SELECT dee.engineering_name engineeringName,
SELECT dee.slope_name slopeName,
demp.measure_point_name measurePointName,
dest.sensor_type_name sensorTypeName,
des.sensor_sn,
@ -23,8 +23,8 @@
inner join high_slope_sensor des on decd.sensor_sn = des.sensor_sn
inner join high_slope_measure_point demp
on des.measure_point_number = demp.measure_point_number
inner join high_slope_engineering dee on demp.high_slope_id = dee.id
inner join high_slope_sensor_type dest on dest.id = des.sensor_type_id
inner join high_slope_engineering dee on demp.high_slope_engineering_id = dee.id
inner join high_slope_sensor_type dest on dest.id = des.high_slope_sensor_type_id
where dee.project_sn = #{projectSn}
<if test="sensorTypeId != null">
and dest.id = #{sensorTypeId}
@ -81,7 +81,7 @@
<select id="selectHighSlopeCurrentDataList"
resultType="com.zhgd.xmgl.modules.highslope.entity.HighSlopeCurrentData">
select dee.engineering_name engineeringName,
select dee.slope_name slopeName,
demp.measure_point_name measurePointName,
demp.measure_point_number measurePointNumber,
dest.sensor_type_name sensorTypeName,

View File

@ -6,13 +6,13 @@
SELECT *
from high_slope_engineering
WHERE project_sn=#{param.projectSn}
order by start_time
order by id desc
</select>
<select id="selectHighSlopeList"
resultType="com.zhgd.xmgl.modules.highslope.entity.HighSlopeEngineering">
SELECT *
from high_slope_engineering
WHERE project_sn=#{projectSn}
order by start_time
order by id desc
</select>
</mapper>

View File

@ -5,10 +5,10 @@
resultType="com.zhgd.xmgl.modules.highslope.entity.HighSlopeMeasurePoint">
select a.*
from high_slope_measure_point a
INNER JOIN high_slope_monitor_type_rela b ON a.rela_id = b.id
where b.high_slope_id = #{highSlopeId}
INNER JOIN high_slope_engineering_to_monitor_type b ON a.high_slope_engineering_to_monitor_type_id = b.id
where b.high_slope_engineering_id = #{highSlopeId}
<if test="relaId != null and relaId != ''">
and a.rela_id = #{relaId}
and a.high_slope_engineering_to_monitor_type_id = #{relaId}
</if>
</select>
@ -22,19 +22,19 @@
</resultMap>
<select id="getDetailsByMeasurePointNumber" resultMap="measurePointAndSensor">
select demp.id,
demp.high_slope_id,
demp.rela_id,
demp.high_slope_engineering_id,
demp.high_slope_engineering_to_monitor_type_id,
demp.measure_point_name,
demp.measure_point_number,
demp.measure_point_addr,
demp.alarm_state,
demp.alarm_type,
demp.alarm_data_id,
demp.high_slope_current_data_id,
demp.alarm_date,
des.id sId,
des.sensor_sn,
des.sensor_name,
des.sensor_type_id,
des.high_slope_sensor_type_id,
des.status,
des.early_warning_value,
des.alarm_value,

View File

@ -139,7 +139,7 @@ public class HighSlopeCurrentDataServiceImpl extends ServiceImpl<HighSlopeCurren
currentData.setAlarmStateStr(DataStatusEnum.getStatusNameById(currentData.getAlarmState()));
}
String[] heads = {"高边坡名称", "测点名称", "传感器类型", "传感器名称", "传感器编号", "初始值", "采集时间", "上次值", "本次值", "本次变化量", "累计值", "累计值预警值", "变化速率", "变化速率预警值", "报警状态"};
String[] headsStr = {"engineeringName", "measurePointName", "sensorTypeName", "sensorName", "sensorSn", "fiducialValue", "receiveTime", "lastTimeData", "data", "dataThis", "dataTotal", "alarmValue", "dataRate", "rateAlarmValue", "alarmStateStr"};
String[] headsStr = {"slopeName", "measurePointName", "sensorTypeName", "sensorName", "sensorSn", "fiducialValue", "receiveTime", "lastTimeData", "data", "dataThis", "dataTotal", "alarmValue", "dataRate", "rateAlarmValue", "alarmStateStr"};
JxlExcelUtils.excelExport("高边坡实时数据列表", heads, headsStr, list, response);
} catch (Exception e) {
log.error("导出培训记录数据异常" + e);

View File

@ -62,10 +62,10 @@ public class HighSlopeEngineeringServiceImpl extends ServiceImpl<HighSlopeEngine
public void saveHighSlopeEngineering(HighSlopeEngineering highSlopeEngineering) {
checkParams(highSlopeEngineering);
setStatus(highSlopeEngineering);
highSlopeEngineering.setId(null);
highSlopeEngineeringMapper.insert(highSlopeEngineering);
if (StringUtils.isNotEmpty(highSlopeEngineering.getMonitorTypeIds())) {
String date = DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN);
List<HighSlopeEngineeringToMonitorType> relaList = Arrays.stream(highSlopeEngineering.getMonitorTypeIds().split(","))
if (StringUtils.isNotEmpty(highSlopeEngineering.getHighSlopeMonitorTypeIds())) {
List<HighSlopeEngineeringToMonitorType> relaList = Arrays.stream(highSlopeEngineering.getHighSlopeMonitorTypeIds().split(","))
.map(item -> new HighSlopeEngineeringToMonitorType(null, highSlopeEngineering.getId(), Long.valueOf(item), null, null)).collect(Collectors.toList());
highSlopeEngineeringToMonitorTypeService.saveBatch(relaList);
}
@ -74,7 +74,7 @@ public class HighSlopeEngineeringServiceImpl extends ServiceImpl<HighSlopeEngine
@Override
public void deleteHighSlopeEngineering(Long id) {
highSlopeEngineeringToMonitorTypeService.deleteByExcavationId(id);
highSlopeEngineeringMapper.delete(Wrappers.<HighSlopeEngineering>lambdaQuery().eq(HighSlopeEngineering::getId, id));
highSlopeEngineeringMapper.deleteById(id);
}
@Override

View File

@ -28,7 +28,6 @@ public class HighSlopeEngineeringToEngineeringToMonitorTypeServiceImpl extends S
@Override
public void deleteByExcavationId(Long id) {
LambdaQueryWrapper<HighSlopeEngineeringToMonitorType> queryWrapper = Wrappers.<HighSlopeEngineeringToMonitorType>lambdaQuery().eq(HighSlopeEngineeringToMonitorType::getHighSlopeEngineeringId, id);
List<Long> relaIdList = highSlopeEngineeringToMonitorTypeMapper.selectList(queryWrapper).stream().map(HighSlopeEngineeringToMonitorType::getId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(relaIdList)) {
highSlopeMeasurePointService.deleteByRelaIdList(relaIdList);

View File

@ -51,7 +51,6 @@ public class HighSlopeMeasurePointServiceImpl extends ServiceImpl<HighSlopeMeasu
// 验证测点编号是否存在
QueryWrapper<HighSlopeMeasurePoint> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HighSlopeMeasurePoint::getMeasurePointNumber, measurePointNumber);
// queryWrapper.lambda().eq(HighSlopeMeasurePoint::getMeasurePointNumber, measurePointNumber).eq(HighSlopeMeasurePoint::getRelaId, highSlopeMeasurePoint.getRelaId());
int count = highSlopeMeasurePointMapper.selectCount(queryWrapper);
if (count > 0) {
log.warn("当前监测类型,测点编号 {} 已存在!", measurePointNumber);
@ -60,9 +59,8 @@ public class HighSlopeMeasurePointServiceImpl extends ServiceImpl<HighSlopeMeasu
// 验证是否存在
List<HighSlopeSensor> sensorList = highSlopeMeasurePoint.getSensorList();
verifySensorData(sensorList);
highSlopeMeasurePoint.setAlarmState(1);
highSlopeMeasurePoint.setId(null);
highSlopeMeasurePointMapper.insert(highSlopeMeasurePoint);
for (HighSlopeSensor highSlopeSensor : sensorList) {

View File

@ -285,6 +285,8 @@ public class Project implements Serializable {
private String extend2;
@ApiModelProperty(value = "中建四局指挥中心BIM")
private String bimCommandCenterUrl;
@ApiModelProperty(value = "天气信息")
private String weatherInfo;
/**
* runde平台token

View File

@ -132,6 +132,20 @@ public class SmartBeamFieldBeamController {
return result;
}
@ApiOperation(value = "开始生产", notes = "开始生产", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "智慧梁场-梁ID", paramType = "body", required = true, dataType = "String"),
})
@PostMapping(value = "/beginProduce")
public Result beginProduce(@ApiIgnore @RequestBody HashMap<String, Object> paramMap) {
Long id = MapUtils.getLong(paramMap, "id");
SmartBeamFieldBeam entity = new SmartBeamFieldBeam();
entity.setId(id);
entity.setBeamMakeStatus(2);
smartBeamFieldBeamService.updateById(entity);
return Result.ok();
}
@ApiOperation(value = "给梁绑定生产线", notes = "给梁绑定生产线", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "smartBeamFieldBeamId", value = "智慧梁场-梁ID", paramType = "body", required = true, dataType = "String"),

View File

@ -26,12 +26,12 @@
<select id="countSmartBeamFieldBeam"
resultType="com.zhgd.xmgl.modules.smartbeamfield.entity.vo.CountSmartBeamFieldBeamVo">
select t.*, ifnull(round(makeBeamPedestalOccupyCount / makeBeamPedestalCount, 2), 0) as
select t.*, ifnull(round(makeBeamPedestalOccupyCount / makeBeamPedestalCount*100, 2), 0) as
makeBeamPedestalOccupyRate,
makeBeamPedestalCount-makeBeamPedestalOccupyCount as makeBeamPedestalNotOccupyCount
from (
select count(*) makeBeamPedestalCount,
ifnull(if(max(sbfbtp.id) is not null, 1, 0), 0) makeBeamPedestalOccupyCount
ifnull(sum(if(sbfbtp.id is not null, 1, 0)), 0) makeBeamPedestalOccupyCount
from smart_beam_field_make_beam_pedestal sbfmbp
left join (SELECT *
FROM smart_beam_field_beam_to_process

View File

@ -20,6 +20,7 @@ import com.zhgd.xmgl.modules.smartbeamfield.service.ISmartBeamFieldProductionLin
import com.zhgd.xmgl.util.PageUtil;
import com.zhgd.xmgl.util.RefUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -81,7 +82,14 @@ public class SmartBeamFieldProductionLineServiceImpl extends ServiceImpl<SmartBe
throw new OpenAlertException("productionLineMakeBeamPedestalList[i].smartBeamFieldMakeBeamPedestalId智慧梁场-制梁台座id不能为空");
}
pedestal.setProjectSn(smartBeamFieldProductionLine.getProjectSn());
try {
smartBeamFieldProductionLineToMakeBeamPedestalMapper.insert(pedestal);
} catch (Exception e) {
e.printStackTrace();
if (e instanceof DuplicateKeyException) {
throw new OpenAlertException("制梁台座已被绑定,请刷新重试");
}
}
}
}
}

View File

@ -116,7 +116,6 @@ public class StableWaterMixStationTask {
//请求成功
//第10步处理请求结果第三方系统自行处理
String stringContent = restResponseInfo.getStringContent();
System.out.println(stringContent);
JSONObject scjo = JSON.parseObject(stringContent);
if (scjo.getBoolean("success")) {
saveData(scjo.getJSONObject("data"), project);

View File

@ -3,8 +3,8 @@ package com.zhgd.xmgl.util;
import cn.hutool.http.HttpException;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gexin.fastjson.JSON;
import com.gexin.fastjson.JSONObject;
import com.zhgd.redis.lock.RedisRepository;
import com.zhgd.xmgl.modules.basicdata.entity.SystemCities;
import com.zhgd.xmgl.modules.basicdata.mapper.SystemCitiesMapper;
@ -36,16 +36,29 @@ public class AqiUtil {
public static String SYSTEM_CITIES_KEY = "SYSTEM_CITIES";
public static String WEATHER_DATA = "WEATHER_DATA:";
private static String tianqiUrl;
private static String tianqiAppid;
private static String tianqiAppsecret;
/**
* 天气质量
*/
public static String WEATHER_QUALITY = "WEATHER_QUALITY:";
public static String WEATHER_LIVE = "WEATHER_LIVE:";
@Value("${tianqiUrl}")
public void setTianqiUrl(String tianqiUrl) {
AqiUtil.tianqiUrl = tianqiUrl;
}
@Value("${tianqiAppid}")
public void setTianqiAppid(String tianqiAppid) {
AqiUtil.tianqiAppid = tianqiAppid;
}
@Value("${tianqiAppsecret}")
public void setTianqiAppsecret(String tianqiAppsecret) {
AqiUtil.tianqiAppsecret = tianqiAppsecret;
}
@Autowired
public void setSystemCitiesMapper(SystemCitiesMapper systemCitiesMapper) {
AqiUtil.systemCitiesMapper = systemCitiesMapper;
@ -184,13 +197,16 @@ public class AqiUtil {
Double air = null;
try {
Map<String, Object> param = new HashMap<>();
param.put("appid", "41289558");
param.put("appsecret", "45CS7niV");
param.put("appid", tianqiAppid);
param.put("appsecret", tianqiAppsecret);
String cityId = Optional.ofNullable(cityIdMap.get(cityCode)).map(e -> e.getWeathercityid()).orElse(null);
if (StringUtils.isNotBlank(cityId)) {
param.put("cityid", cityId);
}
String result = HttpUtil.get("https://v0.yiketianqi.com/free/day", param, 5000);
String urlString = tianqiUrl + "/free/day";
log.info("tianqi:url:{},param:{}", urlString, JSON.toJSONString(param));
String result = HttpUtil.get(urlString, param, 5000);
log.info("tianqi:rs:{}", result);
if (result != null && result.length() > 0) {
JSONObject obj = JSONObject.parseObject(result);
if (obj != null && obj.getString("air") != null) {
@ -207,22 +223,56 @@ public class AqiUtil {
return air;
}
/**
* 实况天气
*
* @param cityCode cityid
* @return
*/
public static Object getLiveWeatherInfo(String cityCode) {
List<SystemCities> systemCities = redisRepository.getOrSet(SYSTEM_CITIES_KEY, () -> systemCitiesMapper.selectList(null), 60 * 60L);
String key = WEATHER_LIVE + cityCode;
Object ro = redisRepository.get(key);
if (ro != null) {
return (HashMap) ro;
}
Map<String, SystemCities> cityIdMap = systemCities.stream().collect(Collectors.toMap(e -> e.getCityid(), Function.identity(), (o, o2) -> o));
HashMap result = null;
try {
Map<String, Object> param = new HashMap<>();
param.put("appid", tianqiAppid);
param.put("appsecret", tianqiAppsecret);
String cityId = Optional.ofNullable(cityIdMap.get(cityCode)).map(e -> e.getWeathercityid()).orElse(null);
if (StringUtils.isNotBlank(cityId)) {
param.put("cityid", cityId);
}
String urlString = tianqiUrl + "/free/day";
log.info("tianqi:url:{},param:{}", urlString, JSON.toJSONString(param));
String rs = HttpUtil.get(urlString, param, 5000);
log.info("tianqi:rs:{}", rs);
result = JSON.parseObject(rs, HashMap.class);
} catch (Exception e) {
e.printStackTrace();
}
redisRepository.set(key, result, 60 * 60L);
return result;
}
public static String getWeatherData(String cityid) {
String result = "";
try {
result = redisRepository.getOrSet(WEATHER_DATA + cityid, () -> {
Map<String, Object> param = new HashMap<>();
param.put("unescape", "1");
//param.put("appid", "79112751");
//param.put("appsecret", "EBqjU987");
param.put("appid", "41289558");
param.put("appsecret", "45CS7niV");
param.put("appid", tianqiAppid);
param.put("appsecret", tianqiAppsecret);
if (StringUtils.isNotEmpty(cityid)) {
param.put("cityid", cityid);
}
String r = HttpUtil.get(tianqiUrl, param);
String r = HttpUtil.get(tianqiUrl + "/free/week", param);
JSONObject jsonObject = JSONObject.parseObject(r);
JSONArray sevenDataArr = jsonObject.getJSONArray("data");
com.gexin.fastjson.JSONArray sevenDataArr = jsonObject.getJSONArray("data");
for (Object o : sevenDataArr) {
JSONObject jo = (JSONObject) o;
jo.put("cityid", jsonObject.get("cityid"));

View File

@ -154,6 +154,10 @@ koyoe.nowData=${koyoe.base-url}/third-party/api/nowData?sn=%s
# 是否证书验证
is-license=false
#天气url
tianqiUrl=http://v1.yiketianqi.com/free/week
tianqiUrl=http://v1.yiketianqi.com
#天气appid
tianqiAppid=41289558
#天气appsecret
tianqiAppsecret=45CS7niV
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8