新增查看页面

This commit is contained in:
2026-01-24 17:56:15 +08:00
parent 2cf92c6e49
commit b7e0b87cd9
15 changed files with 346 additions and 37 deletions

View File

@@ -26,6 +26,18 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.12.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>

View File

@@ -0,0 +1,10 @@
package com.jeesite.modules.app.Api.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping(value = "/cApi/myJob")
public class cApiJob {
}

View File

@@ -5,6 +5,8 @@ import com.jeesite.modules.app.Api.model.ApiResult;
import com.jeesite.modules.app.Api.model.ResultCodeEnum; import com.jeesite.modules.app.Api.model.ResultCodeEnum;
import com.jeesite.modules.biz.entity.BizAreaSource; import com.jeesite.modules.biz.entity.BizAreaSource;
import com.jeesite.modules.biz.service.BizAreaSourceService; import com.jeesite.modules.biz.service.BizAreaSourceService;
import com.jeesite.modules.file.entity.FileUpload;
import com.jeesite.modules.file.service.FileUploadService;
import com.jeesite.modules.sys.entity.DictData; import com.jeesite.modules.sys.entity.DictData;
import com.jeesite.modules.sys.utils.DictUtils; import com.jeesite.modules.sys.utils.DictUtils;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;

View File

@@ -1,7 +1,11 @@
package com.jeesite.modules.app; package com.jeesite.modules.app;
import com.jeesite.common.config.Global;
import com.jeesite.modules.app.dao.MyWorkInfo; import com.jeesite.modules.app.dao.MyWorkInfo;
import com.jeesite.modules.app.dao.RealTimeWeather;
import com.jeesite.modules.app.utils.MyUtils;
import com.jeesite.modules.app.utils.WeatherUtils;
import com.jeesite.modules.biz.entity.BizCalendarSchedule; import com.jeesite.modules.biz.entity.BizCalendarSchedule;
import com.jeesite.modules.biz.entity.BizListItem; import com.jeesite.modules.biz.entity.BizListItem;
import com.jeesite.modules.biz.entity.BizProjectInfo; import com.jeesite.modules.biz.entity.BizProjectInfo;
@@ -36,6 +40,9 @@ public class appStart {
@Resource @Resource
private BizCalendarScheduleService bizCalendarScheduleService; private BizCalendarScheduleService bizCalendarScheduleService;
String API_KEY = "7e6a6422c4b949dd90a5ad3302137b76";
private String LOCATION = Global.getConfig("biz.weather.Loc", "101010100");
/** /**
* 首页 * 首页
@@ -44,6 +51,9 @@ public class appStart {
@ResponseBody @ResponseBody
public MyWorkInfo list() { public MyWorkInfo list() {
User user = UserUtils.getUser(); User user = UserUtils.getUser();
WeatherUtils weather = new WeatherUtils(API_KEY);
RealTimeWeather timeWeather = weather.getRealTimeWeather(LOCATION);
String weatherText = MyUtils.concatParams("今日", timeWeather.getText(), ",温度:{", timeWeather.getTemp(), "℃-", timeWeather.getHumidity(), "℃},", timeWeather.getWindDir());
// 日程 // 日程
BizCalendarSchedule schedule = new BizCalendarSchedule(); BizCalendarSchedule schedule = new BizCalendarSchedule();
schedule.setParticipantUser(user.getLoginCode()); schedule.setParticipantUser(user.getLoginCode());
@@ -69,7 +79,7 @@ public class appStart {
.map(Long::intValue) .map(Long::intValue)
.orElse(0); .orElse(0);
List<BizResumeEmployee> employees = bizResumeEmployeeService.findList(new BizResumeEmployee()); List<BizResumeEmployee> employees = bizResumeEmployeeService.findList(new BizResumeEmployee());
MyWorkInfo workInfo = new MyWorkInfo(notifyNums, listItems.size(), projectNums, projectInfos.size(), calendarNums, schedules.size(), employees.size()); MyWorkInfo workInfo = new MyWorkInfo(weatherText, notifyNums, listItems.size(), projectNums, projectInfos.size(), calendarNums, schedules.size(), employees.size());
return workInfo; return workInfo;
} }

View File

@@ -0,0 +1,43 @@
package com.jeesite.modules.app.dao;
import lombok.Data;
import java.io.Serializable;
@Data
public class DailyWeather implements Serializable {
// 预报日期yyyy-MM-dd
private String date;
// 最低温度(℃)
private String tempMin;
// 最高温度(℃)
private String tempMax;
// 白天天气状况(如:晴、多云)
private String textDay;
// 夜间天气状况(如:多云、雨)
private String textNight;
// 白天风向(如:东风、南风)
private String windDirDay;
// 白天风力等级2、3
private String windScaleDay;
/**
* 无参构造方法(框架/反射实例化必备)
*/
public DailyWeather() {
}
/**
* 全参构造方法(快速创建对象)
*/
public DailyWeather(String date, String tempMin, String tempMax, String textDay, String textNight, String windDirDay, String windScaleDay) {
this.date = date;
this.tempMin = tempMin;
this.tempMax = tempMax;
this.textDay = textDay;
this.textNight = textNight;
this.windDirDay = windDirDay;
this.windScaleDay = windScaleDay;
}
}

View File

@@ -0,0 +1,31 @@
package com.jeesite.modules.app.dao;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class DailyWeatherMap implements Serializable {
// 天气详情链接
private String location;
// 数据更新时间
private String updateTime;
// 每日预报列表
private List<DailyWeather> daily;
/**
* 无参构造方法
*/
public DailyWeatherMap() {
}
/**
* 全参构造方法
*/
public DailyWeatherMap(String location, String updateTime, List<DailyWeather> daily) {
this.location = location;
this.updateTime = updateTime;
this.daily = daily;
}
}

View File

@@ -7,6 +7,8 @@ import java.io.Serializable;
@Data @Data
public class MyWorkInfo implements Serializable { public class MyWorkInfo implements Serializable {
private String weatherText;
private Integer notifyNums; private Integer notifyNums;
private Integer notifyAllNums; private Integer notifyAllNums;
@@ -25,7 +27,8 @@ public class MyWorkInfo implements Serializable {
} }
public MyWorkInfo(Integer notifyNums, Integer notifyAllNums, Integer projectNums, Integer projectAllNums,Integer calendarNums,Integer calendarAllNums, Integer teamNums) { public MyWorkInfo(String weatherText, Integer notifyNums, Integer notifyAllNums, Integer projectNums, Integer projectAllNums, Integer calendarNums, Integer calendarAllNums, Integer teamNums) {
this.weatherText = weatherText;
this.notifyNums = notifyNums; this.notifyNums = notifyNums;
this.notifyAllNums = notifyAllNums; this.notifyAllNums = notifyAllNums;
this.projectNums = projectNums; this.projectNums = projectNums;

View File

@@ -0,0 +1,43 @@
package com.jeesite.modules.app.dao;
import lombok.Data;
import java.io.Serializable;
@Data
public class RealTimeWeather implements Serializable {
// 温度(℃)
private String temp;
// 体感温度(℃)
private String feelsLike;
// 天气状况(如:晴、多云、雨)
private String text;
// 风向(如:南风、东风)
private String windDir;
// 风力等级3、5
private String windScale;
// 相对湿度(%
private String humidity;
// 更新时间格式2026-01-24T12:00+08:00
private String updateTime;
/**
* 无参构造方法(框架/反射实例化时需要)
*/
public RealTimeWeather() {
}
/**
* 全参构造方法(快速创建对象)
*/
public RealTimeWeather(String temp, String feelsLike, String text, String windDir, String windScale, String humidity, String updateTime) {
this.temp = temp;
this.feelsLike = feelsLike;
this.text = text;
this.windDir = windDir;
this.windScale = windScale;
this.humidity = humidity;
this.updateTime = updateTime;
}
}

View File

@@ -1,22 +0,0 @@
package com.jeesite.modules.app.service;
import com.jeesite.common.config.Global;
import com.jeesite.modules.app.utils.MyUtils;
import com.jeesite.modules.biz.entity.BizCalendarSchedule;
import com.jeesite.modules.biz.entity.BizListItem;
import com.jeesite.modules.biz.service.BizListItemService;
import com.jeesite.modules.sys.entity.User;
import com.jeesite.modules.sys.utils.UserUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class MsgService {
@Resource
private BizListItemService bizListItemService;
private static final String HTTP_URL = Global.getConfig("biz.http.url", "");
}

View File

@@ -0,0 +1,186 @@
package com.jeesite.modules.app.utils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.jeesite.modules.app.dao.DailyWeather;
import com.jeesite.modules.app.dao.DailyWeatherMap;
import com.jeesite.modules.app.dao.RealTimeWeather;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* 和风天气API工具类V7版本
*/
public class WeatherUtils {
// 和风天气API基础地址
private static final String BASE_URL = "https://mt6r6ujk6c.re.qweatherapi.com/v7";
private static final OkHttpClient OK_HTTP_CLIENT = new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS) // 连接超时
.readTimeout(10, TimeUnit.SECONDS) // 读取超时
.build();
private static final Gson GSON = new Gson();
private static final Type MAP_TYPE = new TypeToken<Map<String, Object>>() {
}.getType();
// 和风天气API Key
private final String apiKey;
/**
* 初始化工具类
*
* @param apiKey 和风天气开发者平台获取的API Key
* @throws IllegalArgumentException API Key为空时抛出
*/
public WeatherUtils(String apiKey) {
if (apiKey == null || apiKey.trim().isEmpty()) {
throw new IllegalArgumentException("API Key不能为空请前往和风天气开发者平台申请");
}
this.apiKey = apiKey;
}
/**
* 发送HTTP GET请求内部通用方法
*
* @param path API接口路径如/weather/now
* @param location 位置城市ID/经纬度如101010100
* @return API原始响应的Map失败返回null
*/
private Map<String, Object> sendRequest(String path, String location) {
// 拼接请求URL带参数
String url = String.format("%s%s?location=%s&lang=zh&key=%s",
BASE_URL, path, location, apiKey);
// 构建请求
Request request = new Request.Builder()
.url(url)
.get()
.build();
try (Response response = OK_HTTP_CLIENT.newCall(request).execute()) {
// 检查HTTP响应状态
if (!response.isSuccessful()) {
System.err.println("HTTP请求失败状态码" + response.code());
return null;
}
// 读取响应体并解析为Map
String responseBody = response.body().string();
Map<String, Object> responseMap = GSON.fromJson(responseBody, MAP_TYPE);
// 校验API返回的状态码
String code = (String) responseMap.get("code");
if (!"200".equals(code)) {
String errorMsg = getErrorMsg(code);
System.err.println("API返回错误" + code + " - " + errorMsg);
return null;
}
return responseMap;
} catch (IOException e) {
System.err.println("网络请求异常:" + e.getMessage());
return null;
}
}
/**
* 解析和风天气API错误码含义
*
* @param code 错误码
* @return 错误描述
*/
private String getErrorMsg(String code) {
return switch (code) {
case "400" -> "请求参数错误";
case "401" -> "API Key错误或过期";
case "403" -> "API Key无权限访问该接口";
case "404" -> "请求的接口不存在";
case "429" -> "API调用频率超限";
case "500" -> "服务器内部错误";
default -> "未知错误";
};
}
/**
* 查询实时天气
*
* @param location 位置城市ID/经纬度如101010100=北京)
*/
public RealTimeWeather getRealTimeWeather(String location) {
if (location == null || location.trim().isEmpty()) {
System.err.println("位置参数不能为空");
return null;
}
// 调用实时天气接口
Map<String, Object> responseMap = sendRequest("/weather/now", location);
if (responseMap == null || !responseMap.containsKey("now")) {
return null;
}
// 提取实时天气核心字段
Map<String, Object> nowMap = (Map<String, Object>) responseMap.get("now");
RealTimeWeather timeWeather = new RealTimeWeather(
(String) nowMap.get("temp"), // 温度
(String) nowMap.get("feelsLike"), // 体感温度
(String) nowMap.get("text"), // 天气状况
(String) nowMap.get("windDir"), // 风向
(String) nowMap.get("windScale"), // 风力等级
(String) nowMap.get("humidity"), // 相对湿度
(String) responseMap.get("updateTime") // 更新时间
);
return timeWeather;
}
/**
* 查询未来几天的天气预报免费版默认最多3天
*
* @param location 位置城市ID/经纬度)
* @param days 查询天数1-15免费版建议≤3
* @return 封装后的预报Map失败返回null
*/
public DailyWeatherMap getDailyWeather(String location, int days) {
if (location == null || location.trim().isEmpty()) {
System.err.println("位置参数不能为空");
return null;
}
if (days < 1 || days > 15) {
System.err.println("查询天数需在1-15之间");
return null;
}
// 选择对应接口路径
String path = switch (days) {
case 1, 2, 3 -> "/weather/3d";
case 4, 5, 6, 7 -> "/weather/7d";
default -> "/weather/15d";
};
// 调用预报接口
Map<String, Object> responseMap = sendRequest(path, location);
if (responseMap == null || !responseMap.containsKey("daily")) {
return null;
}
// 提取每日预报列表并截断到指定天数
List<Map<String, Object>> originalDailyList = (List<Map<String, Object>>) responseMap.get("daily");
List<DailyWeather> dailyList = originalDailyList.stream()
.limit(days)
.map(map -> new DailyWeather(
(String) map.get("fxDate"),
(String) map.get("tempMin"),
(String) map.get("tempMax"),
(String) map.get("textDay"),
(String) map.get("textNight"),
(String) map.get("windDirDay"),
(String) map.get("windScaleDay")
))
.toList();
return new DailyWeatherMap(
(String) responseMap.get("fxLink"),
(String) responseMap.get("updateTime"),
dailyList
);
}
}

View File

@@ -61,8 +61,6 @@ public class BizMyfilesService extends CrudService<BizMyfilesDao, BizMyfiles> {
@Transactional @Transactional
public void save(BizMyfiles bizMyfiles) { public void save(BizMyfiles bizMyfiles) {
super.save(bizMyfiles); super.save(bizMyfiles);
// 保存上传附件
FileUploadUtils.saveFileUpload(bizMyfiles, bizMyfiles.getId(), "bizMyfiles_file");
} }
/** /**

View File

@@ -2,7 +2,6 @@ package com.jeesite.modules.biz.web;
import java.util.List; import java.util.List;
import com.jeesite.modules.app.service.MsgService;
import com.jeesite.modules.app.utils.vDate; import com.jeesite.modules.app.utils.vDate;
import com.jeesite.modules.biz.entity.BizCalendarFlow; import com.jeesite.modules.biz.entity.BizCalendarFlow;
import com.jeesite.modules.biz.entity.BizListItem; import com.jeesite.modules.biz.entity.BizListItem;
@@ -49,10 +48,6 @@ public class BizCalendarScheduleController extends BaseController {
@Resource @Resource
private BizCalendarFlowService flowService; private BizCalendarFlowService flowService;
@Resource
private MsgService msgService;
private final BizCalendarScheduleService bizCalendarScheduleService; private final BizCalendarScheduleService bizCalendarScheduleService;

View File

@@ -3,18 +3,16 @@ package com.jeesite.modules.biz.web;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import cn.hutool.core.net.multipart.UploadFile;
import com.jeesite.modules.app.utils.FileDownloadUtils; import com.jeesite.modules.app.utils.FileDownloadUtils;
import com.jeesite.modules.app.utils.MyFileUtils; import com.jeesite.modules.app.utils.MyFileUtils;
import com.jeesite.modules.app.utils.vId; import com.jeesite.modules.app.utils.vId;
import com.jeesite.modules.biz.entity.BizMailAttachments;
import com.jeesite.modules.file.entity.FileEntity;
import com.jeesite.modules.file.entity.FileUpload; import com.jeesite.modules.file.entity.FileUpload;
import com.jeesite.modules.file.service.FileEntityService;
import com.jeesite.modules.file.utils.FileUploadUtils; import com.jeesite.modules.file.utils.FileUploadUtils;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@@ -43,7 +41,6 @@ import com.jeesite.modules.biz.service.BizMyfilesService;
@Controller @Controller
@RequestMapping(value = "${adminPath}/biz/myfiles") @RequestMapping(value = "${adminPath}/biz/myfiles")
public class BizMyfilesController extends BaseController { public class BizMyfilesController extends BaseController {
private static final String FILE_PATH = "/ogsapp/files"; private static final String FILE_PATH = "/ogsapp/files";
private final BizMyfilesService bizMyfilesService; private final BizMyfilesService bizMyfilesService;

View File

@@ -9,6 +9,7 @@ import { BasicModel } from '@jeesite/core/api/model/baseModel';
const { adminPath } = useGlobSetting(); const { adminPath } = useGlobSetting();
export interface MyWorkInfo extends BasicModel<MyWorkInfo> { export interface MyWorkInfo extends BasicModel<MyWorkInfo> {
weatherText?: string;
notifyNums?: number; notifyNums?: number;
notifyAllNums?: number; notifyAllNums?: number;
projectNums?: number; projectNums?: number;

View File

@@ -3,7 +3,7 @@
<Avatar :src="userinfo.avatarUrl || headerImg" :size="72" class="!mx-auto !block" /> <Avatar :src="userinfo.avatarUrl || headerImg" :size="72" class="!mx-auto !block" />
<div class="mt-2 flex flex-col justify-center md:ml-6 md:mt-0"> <div class="mt-2 flex flex-col justify-center md:ml-6 md:mt-0">
<h1 class="text-md md:text-lg">您好, {{ userinfo.userName }}, 开始您一天的工作吧</h1> <h1 class="text-md md:text-lg">您好, {{ userinfo.userName }}, 开始您一天的工作吧</h1>
<span class="text-secondary"> 今日晴20 - 32 </span> <span class="text-secondary"> {{ workInfo?.weatherText }} </span>
</div> </div>
<div class="mt-4 flex flex-1 justify-end items-center md:mt-0 gap-x-8 md:gap-x-16"> <div class="mt-4 flex flex-1 justify-end items-center md:mt-0 gap-x-8 md:gap-x-16">
<div class="flex flex-col justify-center items-center"> <div class="flex flex-col justify-center items-center">