功能优化
This commit is contained in:
parent
b937ae32dd
commit
fdb4bc45b7
|
|
@ -1,5 +1,10 @@
|
|||
package com.sercurityControl.proteam.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sercurityControl.proteam.dutyTask.domain.BadWeatherEntity;
|
||||
import com.sercurityControl.proteam.dutyTask.domain.WeatherBean;
|
||||
import com.sercurityControl.proteam.dutyTask.mapper.BadWeatherMapper;
|
||||
import com.sercurityControl.proteam.dutyTask.service.TaskService;
|
||||
import com.sercurityControl.proteam.dutyTask.service.WorkTeamSchedule;
|
||||
import com.sercurityControl.proteam.service.DeviceMachineService;
|
||||
|
|
@ -11,6 +16,14 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
* 站班会进行管理 自动分配定时任务
|
||||
|
|
@ -20,6 +33,9 @@ import javax.annotation.Resource;
|
|||
@EnableScheduling
|
||||
public class ClassMettingScheduTask {
|
||||
|
||||
@Resource
|
||||
private BadWeatherMapper mapper;
|
||||
|
||||
@Resource
|
||||
public WorkTeamSchedule schedule;
|
||||
@Resource
|
||||
|
|
@ -78,6 +94,69 @@ public class ClassMettingScheduTask {
|
|||
logsService.LoginFileUpload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加天气数据
|
||||
*/
|
||||
@Scheduled(cron = "0 30 1 * * ?")
|
||||
public void getWeatherData() {
|
||||
//合肥
|
||||
String addressCode="101220101";
|
||||
String json=getWeather("https://devapi.qweather.com/v7/weather/15d?location="+addressCode+"&key=b18f5b7c218c413abe751d40ec906d9c");
|
||||
JSONObject jsonObject = JSON.parseObject(json);
|
||||
String code=jsonObject.getString("code");
|
||||
if("200".equals(code)){
|
||||
String daily=jsonObject.getString("daily");
|
||||
List<WeatherBean> weatherList = JSON.parseArray(String.valueOf(daily), WeatherBean.class );
|
||||
if(weatherList!=null&&weatherList.size()>0){
|
||||
//清空数据库表数据
|
||||
mapper.delBadWeatherData();
|
||||
for(WeatherBean wea:weatherList){
|
||||
BadWeatherEntity bean = new BadWeatherEntity();
|
||||
bean.setDate(wea.getFxDate());
|
||||
bean.setWeather(wea.getTextDay());
|
||||
bean.setMinTemperature(wea.getTempMin());
|
||||
bean.setMaxTemperature(wea.getTempMax());
|
||||
if ("晴".equals(wea.getTextDay())){
|
||||
bean.setWarning("优");
|
||||
} else if ("阴".equals(wea.getTextDay())){
|
||||
bean.setWarning("良");
|
||||
} else if ("多云".equals(wea.getTextDay())){
|
||||
bean.setWarning("良");
|
||||
} else if (wea.getTextDay().contains("雨")){
|
||||
bean.setWarning("差");
|
||||
} else if (wea.getTextDay().contains("雪")){
|
||||
bean.setWarning("差");
|
||||
}else {
|
||||
bean.setWarning("良");
|
||||
}
|
||||
int re = mapper.addBadWeather(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getWeather(String weather_url){
|
||||
String json="";
|
||||
StringBuffer sb = new StringBuffer();
|
||||
try {
|
||||
//101280101为广州 3d为未来3天天气 now为当前天气
|
||||
URL url = new URL(weather_url);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream is = conn.getInputStream();
|
||||
GZIPInputStream gzin = new GZIPInputStream(is);
|
||||
// 设置读取流的编码格式,自定义编码
|
||||
InputStreamReader isr = new InputStreamReader(gzin, "utf-8");
|
||||
BufferedReader reader = new BufferedReader(isr);
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sb.append(line + " ");
|
||||
}
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
json=sb.toString();
|
||||
return json;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ public class TeamManageController {
|
|||
@Resource(name = "TeamManageService")
|
||||
private TeamManageService service;
|
||||
|
||||
@ApiOperation(value = "班组管理-列表")
|
||||
@PostMapping(value = "getList")
|
||||
@SysLog(title = "班组管理", model = "班组管理->班组管理", operaType = OperaType.QUERY, details = "班组管理",logType = 1)
|
||||
public Map<String, Object> getList(ParamsDto dto) {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
package com.sercurityControl.proteam.supplement.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.securityControl.common.core.constant.HttpStatus;
|
||||
import com.sercurityControl.proteam.supplement.domain.dto.ParamsDto;
|
||||
import com.sercurityControl.proteam.supplement.domain.vo.TeamManageVo;
|
||||
import com.sercurityControl.proteam.supplement.mapper.KeyRisksMapper;
|
||||
import com.sercurityControl.proteam.supplement.mapper.TeamManageMapper;
|
||||
import com.sercurityControl.proteam.supplement.service.KeyRisksService;
|
||||
import com.sercurityControl.proteam.supplement.service.TeamManageService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
|
|||
|
|
@ -156,5 +156,6 @@
|
|||
AND jtp.delete_flag = 0
|
||||
WHERE jt.delete_flag = 0
|
||||
AND jcmi.class_id IS NULL
|
||||
limit 30
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue