From 0e4aa8d08a3bf8e8683d05081baefdbf96ce080f Mon Sep 17 00:00:00 2001
From: cjl <276999030@qq.com>
Date: Wed, 08 Nov 2023 11:45:08 +0800
Subject: [PATCH] fix:小程序添加流程状态变更

---
 screen-api/src/main/java/com/moral/api/service/impl/CityWeatherServiceImpl.java |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/screen-api/src/main/java/com/moral/api/service/impl/CityWeatherServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/CityWeatherServiceImpl.java
index 2ecef67..9bb3726 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/CityWeatherServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/CityWeatherServiceImpl.java
@@ -1,16 +1,22 @@
 package com.moral.api.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.moral.api.entity.CityWeather;
 import com.moral.api.mapper.CityWeatherMapper;
 import com.moral.api.service.CityWeatherService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.moral.constant.RedisConstants;
+import com.moral.util.WeatherUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -36,6 +42,31 @@
         return value;
     }
 
+    @Override
+    public Map<String, Object> dressingIndex(Map map) {
+        Map<String,Object> resultMap = new HashMap<>();
+        int city_code = Integer.parseInt(map.get("regionCode").toString());
+        String time = "";
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 2);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
+        time = sdf.format(calendar.getTime())+":00:00";
+        QueryWrapper<CityWeather> cityWeatherQueryWrapper = new QueryWrapper<>();
+        cityWeatherQueryWrapper.eq("city_code",city_code);
+        cityWeatherQueryWrapper.eq("time",time);
+        CityWeather cityWeather = cityWeatherMapper.selectOne(cityWeatherQueryWrapper);
+        if (ObjectUtils.isEmpty(cityWeather)){
+            return resultMap;
+        }
+        JSONObject jsonObject = JSONObject.parseObject(cityWeather.getValue());
+        Map<String,Object> weatherMap = new HashMap<>();
+        weatherMap.put("temp",jsonObject.get("temp"));
+        weatherMap.put("humidity",jsonObject.get("humidity"));
+        weatherMap.put("windScale",jsonObject.get("windScale"));
+        resultMap = WeatherUtils.dressingIndex(weatherMap);
+        return resultMap;
+    }
+
     /**
     * @Description: ������������������������������
             * @Param: [regionCode]

--
Gitblit v1.8.0