天气和在线离线
This commit is contained in:
parent
65df874493
commit
84d907af1d
@ -1,9 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zhgd.xmgl.modules.electrical.mapper.ElectricalDevMapper">
|
<mapper namespace="com.zhgd.xmgl.modules.electrical.mapper.ElectricalDevMapper">
|
||||||
|
|
||||||
<select id="selectElectricalDevList" resultType="com.zhgd.xmgl.modules.electrical.entity.ElectricalDev">
|
<select id="selectElectricalDevList" resultType="com.zhgd.xmgl.modules.electrical.entity.ElectricalDev">
|
||||||
select *,(case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60) <=10 then 2 else 1 end)
|
select *,(case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/86400) <=7 then 2 else 1 end)
|
||||||
is_closed
|
is_closed
|
||||||
from electrical_dev
|
from electrical_dev
|
||||||
where project_sn=#{projectSn}
|
where project_sn=#{projectSn}
|
||||||
@ -11,7 +10,8 @@
|
|||||||
<select id="selectElectricalDevCount" resultType="java.util.Map" parameterType="map">
|
<select id="selectElectricalDevCount" resultType="java.util.Map" parameterType="map">
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(1) devNum,
|
COUNT(1) devNum,
|
||||||
IFNULL(SUM((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60)<=10 then 1 else 0 end)),0) devOnline
|
IFNULL(SUM((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/86400)<=7 then 1 else 0
|
||||||
|
end)),0) devOnline
|
||||||
FROM electrical_dev de INNER JOIN project a ON de.project_sn=a.project_sn
|
FROM electrical_dev de INNER JOIN project a ON de.project_sn=a.project_sn
|
||||||
INNER JOIN company cp ON a.company_sn=cp.company_sn
|
INNER JOIN company cp ON a.company_sn=cp.company_sn
|
||||||
INNER JOIN company b ON cp.parent_id=b.company_id
|
INNER JOIN company b ON cp.parent_id=b.company_id
|
||||||
|
|||||||
@ -20,8 +20,6 @@ public interface EnvironmentDevMapper extends BaseMapper<EnvironmentDev> {
|
|||||||
|
|
||||||
List<EnvironmentDev> selectEnvironmentDevList(Map<String, Object> map);
|
List<EnvironmentDev> selectEnvironmentDevList(Map<String, Object> map);
|
||||||
|
|
||||||
List<EnvironmentDev> selectProjectEnvironmentDevList(Map<String, Object> map);
|
|
||||||
|
|
||||||
List<Map<String,Object>> selectAllDevCount();
|
List<Map<String,Object>> selectAllDevCount();
|
||||||
|
|
||||||
List<Map<String,Object>> selectCompanyDevCountStatistics(Map<String, Object> map);
|
List<Map<String,Object>> selectCompanyDevCountStatistics(Map<String, Object> map);
|
||||||
|
|||||||
@ -1,62 +1,75 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zhgd.xmgl.modules.environment.mapper.EnvironmentDevMapper">
|
<mapper namespace="com.zhgd.xmgl.modules.environment.mapper.EnvironmentDevMapper">
|
||||||
|
<sql id="getOnline">
|
||||||
|
(case
|
||||||
|
when round((UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(
|
||||||
|
${real_time}
|
||||||
|
)) / 86400) <= 7 then 1
|
||||||
|
else 0 end)
|
||||||
|
</sql>
|
||||||
<update id="updateEnvironmentDevRealTimeById">
|
<update id="updateEnvironmentDevRealTimeById">
|
||||||
UPDATE environment_dev SET real_time=now()
|
UPDATE environment_dev
|
||||||
WHERE id=#{id}
|
SET real_time=now()
|
||||||
|
WHERE id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="selectEnvironmentDevList" resultType="com.zhgd.xmgl.modules.environment.entity.EnvironmentDev">
|
<select id="selectEnvironmentDevList" resultType="com.zhgd.xmgl.modules.environment.entity.EnvironmentDev">
|
||||||
select *,(case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60) <=10 then 1 else 0 end)
|
select *,
|
||||||
|
<include refid="getOnline">
|
||||||
|
<property name="real_time" value="real_time"/>
|
||||||
|
</include>
|
||||||
dev_online
|
dev_online
|
||||||
from environment_dev
|
from environment_dev
|
||||||
where project_sn=#{projectSn}
|
where project_sn = #{projectSn}
|
||||||
</select>
|
|
||||||
<select id="selectProjectEnvironmentDevList" resultType="com.zhgd.xmgl.modules.environment.entity.EnvironmentDev">
|
|
||||||
select *,(case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60) <=10 then 1 else 0 end)
|
|
||||||
dev_online
|
|
||||||
from environment_dev
|
|
||||||
where project_sn=#{projectSn}
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectAllDevCount" resultType="java.util.Map">
|
<select id="selectAllDevCount" resultType="java.util.Map">
|
||||||
SELECT project_sn projectSn,
|
SELECT project_sn projectSn,
|
||||||
COUNT(1) devNum,
|
COUNT(1) devNum,
|
||||||
SUM((case
|
SUM(
|
||||||
when round((UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(real_time)) / 60) <= 10 then 1
|
<include refid="getOnline">
|
||||||
else 0 end)) devOnline
|
<property name="real_time" value="real_time"/>
|
||||||
|
</include>
|
||||||
|
) devOnline
|
||||||
FROM environment_dev
|
FROM environment_dev
|
||||||
GROUP BY project_sn
|
GROUP BY project_sn
|
||||||
</select>
|
</select>
|
||||||
<select id="selectCompanyDevCountStatistics" resultType="java.util.Map">
|
<select id="selectCompanyDevCountStatistics" resultType="java.util.Map">
|
||||||
SELECT
|
SELECT IFNULL(SUM(IFNULL(d.totalDev, 0)), 0) totalDev
|
||||||
IFNULL(SUM(IFNULL(d.totalDev,0)),0) totalDev,
|
, IFNULL(SUM(IFNULL(d.devOnline, 0)), 0) devOnline
|
||||||
IFNULL(SUM(IFNULL(d.devOnline,0)),0) devOnline,
|
, IFNULL(SUM(IFNULL(d.totalDev, 0)), 0) - IFNULL(SUM(IFNULL(d.devOnline, 0)), 0) devNotOnline
|
||||||
IFNULL(SUM(IFNULL(d.totalDev,0)),0)-IFNULL(SUM(IFNULL(d.devOnline,0)),0) devNotOnline
|
|
||||||
<if test="companyType == '1'.toString()">
|
<if test="companyType == '1'.toString()">
|
||||||
,a.company_name name
|
, a.company_name name
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '2'.toString()">
|
<if test="companyType == '2'.toString()">
|
||||||
,b.company_name name
|
, b.company_name name
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '3'.toString()">
|
<if test="companyType == '3'.toString()">
|
||||||
,cp.company_name name
|
, cp.company_name name
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '4'.toString()">
|
<if test="companyType == '4'.toString()">
|
||||||
,c.project_name name
|
, c.project_name name
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '5'.toString()">
|
<if test="companyType == '5'.toString()">
|
||||||
,c.project_name name
|
, c.project_name name
|
||||||
</if>
|
</if>
|
||||||
FROM company a LEFT JOIN company b ON b.parent_id=a.company_id
|
FROM company a
|
||||||
LEFT JOIN company cp ON b.company_id=cp.parent_id
|
LEFT JOIN company b ON b.parent_id = a.company_id
|
||||||
LEFT JOIN project c ON cp.company_sn=c.company_sn
|
LEFT JOIN company cp ON b.company_id = cp.parent_id
|
||||||
|
LEFT JOIN project c ON cp.company_sn = c.company_sn
|
||||||
LEFT JOIN (SELECT w1.project_sn,
|
LEFT JOIN (SELECT w1.project_sn,
|
||||||
COUNT(1) totalDev,
|
COUNT(1) totalDev,
|
||||||
IFNULL(SUM((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60)<=10 then 1 else 0 end)),0) devOnline
|
IFNULL(SUM(
|
||||||
|
<include refid="getOnline">
|
||||||
|
<property name="real_time" value="real_time"/>
|
||||||
|
</include>
|
||||||
|
), 0) devOnline
|
||||||
from environment_dev w1
|
from environment_dev w1
|
||||||
GROUP BY w1.project_sn) d ON c.project_sn=d.project_sn
|
GROUP BY w1.project_sn) d ON c.project_sn = d.project_sn
|
||||||
<if test="companyType == '1'.toString()">
|
<if test="companyType == '1'.toString()">
|
||||||
WHERE a.headquarters_sn=#{sn} AND a.company_type=2
|
WHERE a.headquarters_sn = #{sn}
|
||||||
|
AND a.company_type = 2
|
||||||
GROUP BY a.company_id
|
GROUP BY a.company_id
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '2'.toString()">
|
<if test="companyType == '2'.toString()">
|
||||||
@ -77,75 +90,86 @@
|
|||||||
order by totalDev desc
|
order by totalDev desc
|
||||||
</select>
|
</select>
|
||||||
<select id="selectEnvironmentDevCount" resultType="java.util.Map" parameterType="map">
|
<select id="selectEnvironmentDevCount" resultType="java.util.Map" parameterType="map">
|
||||||
SELECT
|
SELECT COUNT(1) devNum,
|
||||||
COUNT(1) devNum,
|
IFNULL(SUM(
|
||||||
IFNULL(SUM((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60)<=10 then 1 else 0 end)),0) devOnline
|
<include refid="getOnline">
|
||||||
FROM environment_dev de INNER JOIN project a ON de.project_sn=a.project_sn
|
<property name="real_time" value="real_time"/>
|
||||||
INNER JOIN company cp ON a.company_sn=cp.company_sn
|
</include>
|
||||||
INNER JOIN company b ON cp.parent_id=b.company_id
|
), 0) devOnline
|
||||||
Left JOIN company f ON b.parent_id=f.company_id
|
FROM environment_dev de
|
||||||
|
INNER JOIN project a ON de.project_sn = a.project_sn
|
||||||
|
INNER JOIN company cp ON a.company_sn = cp.company_sn
|
||||||
|
INNER JOIN company b ON cp.parent_id = b.company_id
|
||||||
|
Left JOIN company f ON b.parent_id = f.company_id
|
||||||
<where>
|
<where>
|
||||||
<if test="companyType == '1'.toString()">
|
<if test="companyType == '1'.toString()">
|
||||||
and f.headquarters_sn=#{sn}
|
and f.headquarters_sn = #{sn}
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '2'.toString()">
|
<if test="companyType == '2'.toString()">
|
||||||
and f.company_sn=#{sn}
|
and f.company_sn = #{sn}
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '3'.toString()">
|
<if test="companyType == '3'.toString()">
|
||||||
and b.company_sn=#{sn}
|
and b.company_sn = #{sn}
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '4'.toString()">
|
<if test="companyType == '4'.toString()">
|
||||||
and de.project_sn=#{sn}
|
and de.project_sn = #{sn}
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '5'.toString()">
|
<if test="companyType == '5'.toString()">
|
||||||
and cp.company_sn=#{sn}
|
and cp.company_sn = #{sn}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
<select id="selectProjectEnvironmentDevCount" resultType="java.util.Map" parameterType="map">
|
<select id="selectProjectEnvironmentDevCount" resultType="java.util.Map" parameterType="map">
|
||||||
select tp.*,
|
select tp.*,
|
||||||
IFNULL(tp.devNum,0)-IFNULL(tp.devOnline,0) devNotOnline
|
IFNULL(tp.devNum, 0) - IFNULL(tp.devOnline, 0) devNotOnline
|
||||||
from (SELECT
|
from (SELECT COUNT(1) devNum,
|
||||||
COUNT(1) devNum,
|
IFNULL(SUM(
|
||||||
IFNULL(SUM((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60)<=10 then 1 else 0 end)),0) devOnline
|
<include refid="getOnline">
|
||||||
|
<property name="real_time" value="real_time"/>
|
||||||
|
</include>
|
||||||
|
), 0) devOnline
|
||||||
FROM environment_dev de
|
FROM environment_dev de
|
||||||
where de.project_sn=#{projectSn}
|
where de.project_sn = #{projectSn}
|
||||||
) tp
|
) tp
|
||||||
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
<select id="selectEnvironmentDevAccessCountList" resultType="java.util.Map">
|
<select id="selectEnvironmentDevAccessCountList" resultType="java.util.Map">
|
||||||
SELECT
|
SELECT IFNULL(SUM(IFNULL(d.totalDev, 0)), 0) totalDev
|
||||||
IFNULL(SUM(IFNULL(d.totalDev,0)),0) totalDev,
|
, IFNULL(SUM(IFNULL(d.devOnline, 0)), 0) devOnline
|
||||||
IFNULL(SUM(IFNULL(d.devOnline,0)),0) devOnline,
|
, IFNULL(SUM(IFNULL(d.num, 0)), 0) devProjectNum
|
||||||
IFNULL(SUM(IFNULL(d.num,0)),0) devProjectNum,
|
, IFNULL(SUM((CASE when c.project_sn is not null then 1 else 0 end)), 0) totalProjectNum
|
||||||
IFNULL(SUM((CASE when c.project_sn is not null then 1 else 0 end )),0) totalProjectNum,
|
, IFNULL(SUM(IFNULL(d.totalDev, 0)), 0) - IFNULL(SUM(IFNULL(d.devOnline, 0)), 0) devNotOnline
|
||||||
IFNULL(SUM(IFNULL(d.totalDev,0)),0)-IFNULL(SUM(IFNULL(d.devOnline,0)),0) devNotOnline
|
|
||||||
<if test="companyType == '1'.toString()">
|
<if test="companyType == '1'.toString()">
|
||||||
,a.company_name name
|
, a.company_name name
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '2'.toString()">
|
<if test="companyType == '2'.toString()">
|
||||||
,b.company_name name
|
, b.company_name name
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '3'.toString()">
|
<if test="companyType == '3'.toString()">
|
||||||
,cp.company_name name
|
, cp.company_name name
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '4'.toString()">
|
<if test="companyType == '4'.toString()">
|
||||||
,c.project_name name
|
, c.project_name name
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '5'.toString()">
|
<if test="companyType == '5'.toString()">
|
||||||
,c.project_name name
|
, c.project_name name
|
||||||
</if>
|
</if>
|
||||||
FROM company a LEFT JOIN company b ON b.parent_id=a.company_id
|
FROM company a
|
||||||
LEFT JOIN company cp ON b.company_id=cp.parent_id
|
LEFT JOIN company b ON b.parent_id = a.company_id
|
||||||
LEFT JOIN project c ON cp.company_sn=c.company_sn
|
LEFT JOIN company cp ON b.company_id = cp.parent_id
|
||||||
LEFT JOIN (SELECT w1.project_sn,1 num,
|
LEFT JOIN project c ON cp.company_sn = c.company_sn
|
||||||
|
LEFT JOIN (SELECT w1.project_sn,
|
||||||
|
1 num,
|
||||||
COUNT(1) totalDev,
|
COUNT(1) totalDev,
|
||||||
IFNULL(SUM((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60)<=10 then 1 else 0 end)),0) devOnline
|
IFNULL(SUM(
|
||||||
|
<include refid="getOnline">
|
||||||
|
<property name="real_time" value="real_time"/>
|
||||||
|
</include>
|
||||||
|
), 0) devOnline
|
||||||
from environment_dev w1
|
from environment_dev w1
|
||||||
GROUP BY w1.project_sn) d ON c.project_sn=d.project_sn
|
GROUP BY w1.project_sn) d ON c.project_sn = d.project_sn
|
||||||
<if test="companyType == '1'.toString()">
|
<if test="companyType == '1'.toString()">
|
||||||
WHERE a.headquarters_sn=#{sn} AND a.company_type=2
|
WHERE a.headquarters_sn = #{sn}
|
||||||
|
AND a.company_type = 2
|
||||||
GROUP BY a.company_id
|
GROUP BY a.company_id
|
||||||
</if>
|
</if>
|
||||||
<if test="companyType == '2'.toString()">
|
<if test="companyType == '2'.toString()">
|
||||||
@ -165,5 +189,4 @@
|
|||||||
</if>
|
</if>
|
||||||
order by totalProjectNum desc
|
order by totalProjectNum desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@ -204,7 +204,7 @@ public class EnvironmentDevServiceImpl extends ServiceImpl<EnvironmentDevMapper,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnvironmentDevAlaramCountListVo selectEnvironmentDevAlaramCountList(Map<String, Object> map) {
|
public EnvironmentDevAlaramCountListVo selectEnvironmentDevAlaramCountList(Map<String, Object> map) {
|
||||||
List<EnvironmentDev> devList = environmentDevMapper.selectProjectEnvironmentDevList(map);
|
List<EnvironmentDev> devList = environmentDevMapper.selectEnvironmentDevList(map);
|
||||||
int totalDevOnlineNum = 0;
|
int totalDevOnlineNum = 0;
|
||||||
int totalAlarmNum = 0;
|
int totalAlarmNum = 0;
|
||||||
if (devList != null && devList.size() > 0) {
|
if (devList != null && devList.size() > 0) {
|
||||||
|
|||||||
@ -30,9 +30,7 @@
|
|||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<select id="selectPageDetail" resultType="com.zhgd.xmgl.modules.frontier.entity.FrontierProtectionDev">
|
<select id="selectPageDetail" resultType="com.zhgd.xmgl.modules.frontier.entity.FrontierProtectionDev">
|
||||||
select fpd.*,i.team_name,IFNULL(((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(fpd.upload_time))/60)<=30
|
select fpd.*,i.team_name,1 online
|
||||||
then 1 else 0 end)),0)
|
|
||||||
online
|
|
||||||
from frontier_protection_dev fpd left join team_info i on i.id=fpd.duty_team_info_id
|
from frontier_protection_dev fpd left join team_info i on i.id=fpd.duty_team_info_id
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zhgd.xmgl.modules.poisonous.mapper.PoisonousGasDevMapper">
|
<mapper namespace="com.zhgd.xmgl.modules.poisonous.mapper.PoisonousGasDevMapper">
|
||||||
<select id="queryPageList" resultType="com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDev">
|
<select id="queryPageList" resultType="com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDev">
|
||||||
select pgd.*, ti.team_name dutyTeamInfoName,IFNULL(((case when
|
select pgd.*,
|
||||||
round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(pgd.upload_date))/60)<=30 then 1 else 0 end)),0)
|
ti.team_name dutyTeamInfoName,
|
||||||
online
|
1 online
|
||||||
from poisonous_gas_dev pgd
|
from poisonous_gas_dev pgd
|
||||||
join team_info ti on ti.id = pgd.duty_team_info_id
|
join team_info ti on ti.id = pgd.duty_team_info_id
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
|
|||||||
@ -2,9 +2,7 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zhgd.xmgl.modules.smoke.mapper.SmokeDevMapper">
|
<mapper namespace="com.zhgd.xmgl.modules.smoke.mapper.SmokeDevMapper">
|
||||||
<select id="queryWrapper" resultType="com.zhgd.xmgl.modules.smoke.entity.SmokeDev">
|
<select id="queryWrapper" resultType="com.zhgd.xmgl.modules.smoke.entity.SmokeDev">
|
||||||
select sd.*,ti.team_name dutyTeamInfoName,IFNULL(((case when
|
select sd.*,ti.team_name dutyTeamInfoName,1 online
|
||||||
round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(sd.upload_date))/60)<=30 then 1 else 0 end)),0)
|
|
||||||
online
|
|
||||||
from smoke_dev sd inner join team_info
|
from smoke_dev sd inner join team_info
|
||||||
ti on ti.id=sd.duty_team_info_id
|
ti on ti.id=sd.duty_team_info_id
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.zhgd.xmgl.util;
|
package com.zhgd.xmgl.util;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpException;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@ -33,6 +34,10 @@ public class AqiUtil {
|
|||||||
private static RedisRepository redisRepository;
|
private static RedisRepository redisRepository;
|
||||||
public static String SYSTEM_CITIES_KEY = "SYSTEM_CITIES";
|
public static String SYSTEM_CITIES_KEY = "SYSTEM_CITIES";
|
||||||
public static String WEATHER_DATA = "WEATHER_DATA:";
|
public static String WEATHER_DATA = "WEATHER_DATA:";
|
||||||
|
/**
|
||||||
|
* 天气质量
|
||||||
|
*/
|
||||||
|
public static String WEATHER_QUALITY = "WEATHER_QUALITY:";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public void setSystemCitiesMapper(SystemCitiesMapper systemCitiesMapper) {
|
public void setSystemCitiesMapper(SystemCitiesMapper systemCitiesMapper) {
|
||||||
@ -162,6 +167,11 @@ public class AqiUtil {
|
|||||||
*/
|
*/
|
||||||
public static Double getWeatherInfo(String cityCode) {
|
public static Double getWeatherInfo(String cityCode) {
|
||||||
List<SystemCities> systemCities = redisRepository.getOrSet(SYSTEM_CITIES_KEY, () -> systemCitiesMapper.selectList(null), 60 * 60L);
|
List<SystemCities> systemCities = redisRepository.getOrSet(SYSTEM_CITIES_KEY, () -> systemCitiesMapper.selectList(null), 60 * 60L);
|
||||||
|
String key = WEATHER_QUALITY + cityCode;
|
||||||
|
Object ro = redisRepository.get(key);
|
||||||
|
if (ro != null) {
|
||||||
|
return (Double) ro;
|
||||||
|
}
|
||||||
Map<String, SystemCities> cityIdMap = systemCities.stream().collect(Collectors.toMap(e -> e.getCityid(), Function.identity(), (o, o2) -> o));
|
Map<String, SystemCities> cityIdMap = systemCities.stream().collect(Collectors.toMap(e -> e.getCityid(), Function.identity(), (o, o2) -> o));
|
||||||
//空气指数
|
//空气指数
|
||||||
Double air = null;
|
Double air = null;
|
||||||
@ -173,7 +183,7 @@ public class AqiUtil {
|
|||||||
if (StringUtils.isNotBlank(cityId)) {
|
if (StringUtils.isNotBlank(cityId)) {
|
||||||
param.put("cityid", cityId);
|
param.put("cityid", cityId);
|
||||||
}
|
}
|
||||||
String result = HttpUtil.get("https://v0.yiketianqi.com/free/day", param);
|
String result = HttpUtil.get("https://v0.yiketianqi.com/free/day", param, 5000);
|
||||||
if (result != null && result.length() > 0) {
|
if (result != null && result.length() > 0) {
|
||||||
JSONObject obj = JSONObject.parseObject(result);
|
JSONObject obj = JSONObject.parseObject(result);
|
||||||
if (obj != null && obj.getString("air") != null) {
|
if (obj != null && obj.getString("air") != null) {
|
||||||
@ -186,6 +196,7 @@ public class AqiUtil {
|
|||||||
if (air == null) {
|
if (air == null) {
|
||||||
air = 80d;
|
air = 80d;
|
||||||
}
|
}
|
||||||
|
redisRepository.set(key, air, 60 * 60L);
|
||||||
return air;
|
return air;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,8 +246,15 @@ public class AqiUtil {
|
|||||||
log.info(getDegree(getPollutionDegree(temp)));*/
|
log.info(getDegree(getPollutionDegree(temp)));*/
|
||||||
//log.info(getWeatherInfo("110100"));
|
//log.info(getWeatherInfo("110100"));
|
||||||
//log.info(getWeatherData("110100"));
|
//log.info(getWeatherData("110100"));
|
||||||
System.out.println(getWeatherInfo("11"));
|
//System.out.println(getWeatherInfo("11"));
|
||||||
//log.info(getDegree(getPollutionDegree(39d)));
|
//log.info(getDegree(getPollutionDegree(39d)));
|
||||||
|
try {
|
||||||
|
|
||||||
|
String result = HttpUtil.get("https://v0.yiketianqi.com/free/day", 1000);
|
||||||
|
} catch (HttpException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.out.println(123);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user