Merge branch 'master' of http://114.55.171.231:3000/Euni4U/backend
This commit is contained in:
commit
f33411a3d8
@ -80,6 +80,13 @@ public class AlertMessageController {
|
||||
return success(BeanUtils.toBean(pageResult, AlertMessageRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/statistics-summary")
|
||||
@Operation(summary = "获取预警统计数据")
|
||||
public CommonResult<AlertStatisticsVO> getAlertStatistics(@RequestParam Integer orgid) {
|
||||
AlertStatisticsVO data = alertMessageService.getAlertStatistics(orgid);
|
||||
return success(data);
|
||||
}
|
||||
|
||||
@GetMapping("/statistics")
|
||||
@Operation(summary = "统计预警信息")
|
||||
public CommonResult<AlertMessageStatisticsRespVO> getAlertMessageStatistics(@Valid AlertMessageStatisticsReqVO statisticsReqVO) {
|
||||
|
||||
@ -15,13 +15,11 @@ public class AlertMessageStatisticsReqVO {
|
||||
|
||||
@Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "开始时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime startTime;
|
||||
private String startTime;
|
||||
|
||||
@Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "结束时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime endTime;
|
||||
private String endTime;
|
||||
|
||||
@Schema(description = "机构ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30089")
|
||||
@NotNull(message = "机构ID不能为空")
|
||||
|
||||
@ -18,6 +18,24 @@ public class AlertMessageStatisticsRespVO {
|
||||
@Schema(description = "未读数量", example = "20")
|
||||
private Long unreadCount;
|
||||
|
||||
@Schema(description = "SOS预警数量", example = "60")
|
||||
private Long sosCount;
|
||||
|
||||
@Schema(description = "分析预警数量", example = "40")
|
||||
private Long analysisCount;
|
||||
|
||||
@Schema(description = "SOS预警已读数量", example = "50")
|
||||
private Long sosReadCount;
|
||||
|
||||
@Schema(description = "SOS预警未读数量", example = "10")
|
||||
private Long sosUnreadCount;
|
||||
|
||||
@Schema(description = "分析预警已读数量", example = "30")
|
||||
private Long analysisReadCount;
|
||||
|
||||
@Schema(description = "分析预警未读数量", example = "10")
|
||||
private Long analysisUnreadCount;
|
||||
|
||||
@Schema(description = "按日期分组的预警信息数据")
|
||||
private List<DailyAlertData> dailyData;
|
||||
|
||||
@ -26,15 +44,32 @@ public class AlertMessageStatisticsRespVO {
|
||||
public static class DailyAlertData {
|
||||
@Schema(description = "日期", example = "2024-01-01")
|
||||
private LocalDate date;
|
||||
|
||||
|
||||
@Schema(description = "该日期的预警总数", example = "10")
|
||||
private Long totalCount;
|
||||
|
||||
|
||||
@Schema(description = "该日期的已读数量", example = "8")
|
||||
private Long readCount;
|
||||
|
||||
|
||||
@Schema(description = "该日期的未读数量", example = "2")
|
||||
private Long unreadCount;
|
||||
}
|
||||
|
||||
}
|
||||
@Schema(description = "该日期的SOS预警数量", example = "6")
|
||||
private Long sosCount;
|
||||
|
||||
@Schema(description = "该日期的分析预警数量", example = "4")
|
||||
private Long analysisCount;
|
||||
|
||||
@Schema(description = "该日期的SOS预警已读数量", example = "5")
|
||||
private Long sosReadCount;
|
||||
|
||||
@Schema(description = "该日期的SOS预警未读数量", example = "1")
|
||||
private Long sosUnreadCount;
|
||||
|
||||
@Schema(description = "该日期的分析预警已读数量", example = "3")
|
||||
private Long analysisReadCount;
|
||||
|
||||
@Schema(description = "该日期的分析预警未读数量", example = "1")
|
||||
private Long analysisUnreadCount;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.alertmessage.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AlertStatisticsVO {
|
||||
|
||||
@Schema(description = "预警总数", required = true, example = "8")
|
||||
private Integer alertTotal;
|
||||
|
||||
@Schema(description = "未处理预警数", required = true, example = "3")
|
||||
private Integer alertUnhandled;
|
||||
}
|
||||
@ -77,7 +77,12 @@ public class DeviceController {
|
||||
DeviceDO device = deviceService.getDeviceId(devicecode);
|
||||
return success(BeanUtils.toBean(device, DeviceRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/getDeviceidCount")
|
||||
@Operation(summary = "统计设备数量和在线离线 首页")
|
||||
public CommonResult<DeviceStatistics> getDeviceStatistics(@RequestParam Integer orgid) {
|
||||
DeviceStatistics statistics = deviceService.getDeviceStatistics(orgid);
|
||||
return success(statistics);
|
||||
}
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得设备分页")
|
||||
public CommonResult<PageResult<DeviceRespVO>> getDevicePage(@Valid DevicePageReqVO pageReqVO) {
|
||||
@ -114,4 +119,11 @@ public class DeviceController {
|
||||
return success(BeanUtils.toBean(pageResult, DeviceRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/map-data")
|
||||
@Operation(summary = "获取设备分布地图数据")
|
||||
public CommonResult<DeviceMapVO> getDeviceMapData(@RequestParam Integer orgid) {
|
||||
DeviceMapVO data = deviceService.getDeviceMapData(orgid);
|
||||
return success(data);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.device.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AlertStatistics {
|
||||
private Integer total;
|
||||
private Integer unhandled;
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.device.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DeviceMapVO {
|
||||
@Schema(description = "总设备数", required = true, example = "156")
|
||||
private Integer totalCount;
|
||||
|
||||
@Schema(description = "在线设备数", required = true, example = "142")
|
||||
private Integer onlineCount;
|
||||
|
||||
@Schema(description = "离线设备数", required = true, example = "14")
|
||||
private Integer offlineCount;
|
||||
|
||||
@Schema(description = "预警总数", required = true, example = "8")
|
||||
private Integer alertTotal;
|
||||
|
||||
@Schema(description = "未处理预警数", required = true, example = "3")
|
||||
private Integer alertUnhandled;
|
||||
|
||||
@Schema(description = "地图数据", required = true)
|
||||
private List<MapDataItem> mapData;
|
||||
|
||||
@Schema(description = "散点图数据", required = true)
|
||||
private List<ScatterDataItem> scatterData;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.device.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
public class DeviceStatistics {
|
||||
@Schema(description = "设备总数", required = true, example = "8")
|
||||
private Integer totalCount;
|
||||
|
||||
@Schema(description = "在线设备数", required = true, example = "5")
|
||||
private Integer onlineCount;
|
||||
|
||||
@Schema(description = "离线设备数", required = true, example = "3")
|
||||
private Integer offlineCount;
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.device.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MapDataItem {
|
||||
@Schema(description = "省份名称", required = true, example = "辽宁省")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "设备数量", required = true, example = "45")
|
||||
private Integer value;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.device.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ProvinceCoords {
|
||||
private String provinceName;
|
||||
private Double longitude;
|
||||
private Double latitude;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.device.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ProvinceDeviceCount {
|
||||
private String province;
|
||||
private Integer count;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.device.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ScatterDataItem {
|
||||
@Schema(description = "省份名称", required = true, example = "辽宁省")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "坐标和数量 [经度, 纬度, 数量]", required = true, example = "[123.4315, 41.8057, 45]")
|
||||
private double[] value;
|
||||
|
||||
@Schema(description = "设备数量", required = true, example = "45")
|
||||
private Integer count;
|
||||
}
|
||||
@ -72,12 +72,16 @@ public class PersonController {
|
||||
}
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得用户基本信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<PersonRespVO> getPerson(@RequestParam("id") Integer id) {
|
||||
PersonDO person = personService.getPerson(id);
|
||||
return success(BeanUtils.toBean(person, PersonRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/member-growth-data")
|
||||
@Operation(summary = "首页统计会员增长趋势")
|
||||
public CommonResult<List<MemberGrowthVO>> getMemberGrowthData(@RequestParam Integer orgid) {
|
||||
List<MemberGrowthVO> growthData = personService.getMemberGrowthData(orgid);
|
||||
return success(growthData);
|
||||
}
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得用户基本信息分页")
|
||||
public CommonResult<PageResult<PersonRespVO>> getPersonPage(@Valid PersonPageReqVO pageReqVO) {
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.person.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MemberGrowthVO {
|
||||
|
||||
@Schema(description = "日期")
|
||||
private String date;
|
||||
@Schema(description = "数量")
|
||||
private Integer count;
|
||||
}
|
||||
@ -66,6 +66,14 @@ public class RecordController {
|
||||
RecordDO record = recordService.getRecord(id);
|
||||
return success(BeanUtils.toBean(record, RecordRespVO.class));
|
||||
}
|
||||
@GetMapping("/getstatistics")
|
||||
@Operation(summary = "获得会员回访记录")
|
||||
public CommonResult<List<Map<String, Object>>> getVipCountByDay(@RequestParam("orgid") Integer orgid,
|
||||
@RequestParam("startDate") String startDate,
|
||||
@RequestParam("endDate") String endDate) {
|
||||
List<Map<String, Object>> result = recordService.getVipCountByDay(orgid, startDate, endDate);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得会员回访记录分页")
|
||||
|
||||
@ -55,4 +55,51 @@ public interface AlertMessageMapper extends BaseMapperX<AlertMessageDO> {
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
@Select("SELECT " +
|
||||
"COUNT(*) as totalCount, " +
|
||||
"SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as readCount, " +
|
||||
"SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END) as unreadCount, " +
|
||||
"SUM(CASE WHEN alerttype = 1 THEN 1 ELSE 0 END) as sosCount, " +
|
||||
"SUM(CASE WHEN alerttype = 2 THEN 1 ELSE 0 END) as analysisCount, " +
|
||||
"SUM(CASE WHEN alerttype = 1 AND status = 1 THEN 1 ELSE 0 END) as sosReadCount, " +
|
||||
"SUM(CASE WHEN alerttype = 1 AND status = 0 THEN 1 ELSE 0 END) as sosUnreadCount, " +
|
||||
"SUM(CASE WHEN alerttype = 2 AND status = 1 THEN 1 ELSE 0 END) as analysisReadCount, " +
|
||||
"SUM(CASE WHEN alerttype = 2 AND status = 0 THEN 1 ELSE 0 END) as analysisUnreadCount " +
|
||||
"FROM tb_alert_message " +
|
||||
"WHERE orgid = #{orgid} " +
|
||||
"AND createtime BETWEEN #{startTime} AND #{endTime}")
|
||||
Map<String, Object> selectAlertMessageStatistics(@Param("orgid") Integer orgid,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
@Select("SELECT " +
|
||||
"DATE(createtime) as date, " +
|
||||
"COUNT(*) as totalCount, " +
|
||||
"SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as readCount, " +
|
||||
"SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END) as unreadCount, " +
|
||||
"SUM(CASE WHEN alerttype = 1 THEN 1 ELSE 0 END) as sosCount, " +
|
||||
"SUM(CASE WHEN alerttype = 2 THEN 1 ELSE 0 END) as analysisCount, " +
|
||||
"SUM(CASE WHEN alerttype = 1 AND status = 1 THEN 1 ELSE 0 END) as sosReadCount, " +
|
||||
"SUM(CASE WHEN alerttype = 1 AND status = 0 THEN 1 ELSE 0 END) as sosUnreadCount, " +
|
||||
"SUM(CASE WHEN alerttype = 2 AND status = 1 THEN 1 ELSE 0 END) as analysisReadCount, " +
|
||||
"SUM(CASE WHEN alerttype = 2 AND status = 0 THEN 1 ELSE 0 END) as analysisUnreadCount " +
|
||||
"FROM tb_alert_message " +
|
||||
"WHERE orgid = #{orgid} " +
|
||||
"AND createtime BETWEEN #{startTime} AND #{endTime} " +
|
||||
"GROUP BY DATE(createtime) " +
|
||||
"ORDER BY date ASC")
|
||||
List<Map<String, Object>> selectDailyAlertMessageStatistics(@Param("orgid") Integer orgid,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 获取预警统计数据 首页
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
"COUNT(*) as alertTotal, " +
|
||||
"SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END) as alertUnhandled " +
|
||||
"FROM tb_alert_message WHERE orgid = #{orgid}")
|
||||
AlertStatisticsVO getAlertStatistics(@Param("orgid") Integer orgid);
|
||||
|
||||
}
|
||||
@ -9,6 +9,8 @@ import cn.iocoder.yudao.module.system.dal.dataobject.device.DeviceDO;
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.device.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 设备 Mapper
|
||||
@ -54,5 +56,36 @@ public interface DeviceMapper extends BaseMapperX<DeviceDO> {
|
||||
wrapper.orderByDesc(DeviceDO::getId);
|
||||
return selectPage(reqVO, wrapper);
|
||||
}
|
||||
/**
|
||||
* 获取设备基础统计
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
"COUNT(*) as totalCount, " +
|
||||
"SUM(CASE WHEN devicestatus = 1 THEN 1 ELSE 0 END) as onlineCount, " +
|
||||
"SUM(CASE WHEN devicestatus = 2 THEN 1 ELSE 0 END) as offlineCount " +
|
||||
"FROM tb_device WHERE orgid = #{orgid}")
|
||||
DeviceStatistics getDeviceStatistics(@Param("orgid") Integer orgid);
|
||||
|
||||
/**
|
||||
* 获取省份设备数量统计
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
"SUBSTRING_INDEX(location, '/', 1) as province, " +
|
||||
"COUNT(*) as count " +
|
||||
"FROM tb_device " +
|
||||
"WHERE orgid = #{orgid} " +
|
||||
"GROUP BY SUBSTRING_INDEX(location, '/', 1)")
|
||||
List<ProvinceDeviceCount> getProvinceDeviceCount(@Param("orgid") Integer orgid);
|
||||
|
||||
/**
|
||||
* 根据省份名称获取经纬度
|
||||
*/
|
||||
@Select("SELECT province_name, longitude, latitude " +
|
||||
"FROM province_coords " +
|
||||
"WHERE province_name = #{provinceName}")
|
||||
ProvinceCoords getByProvince(@Param("provinceName") String provinceName);
|
||||
/*
|
||||
* 首页查询设备数量统计
|
||||
* */
|
||||
DeviceStatistics getDevice_Statistics(@Param("orgid") Integer orgid);
|
||||
}
|
||||
@ -48,5 +48,9 @@ public interface PersonMapper extends BaseMapperX<PersonDO> {
|
||||
* 按天统计开通会员的人数
|
||||
*/
|
||||
List<Map<String, Object>> countVipByDay(@Param("startDate") String startDate, @Param("endDate") String endDate);
|
||||
/*
|
||||
* 首页统计 会员增长趋势 一周
|
||||
* */
|
||||
List<MemberGrowthVO> getMemberGrowthData(@Param("orgid") Integer orgid);
|
||||
|
||||
}
|
||||
@ -58,4 +58,11 @@ public interface RecordMapper extends BaseMapperX<RecordDO> {
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 按日期分组查询会员回访记录统计,包含结果
|
||||
*/
|
||||
List<Map<String, Object>> selectDailyStatisticsWithResult(@Param("orgid") Integer orgid,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
}
|
||||
@ -33,6 +33,10 @@ public interface AlertMessageService {
|
||||
* 根据机构ID查询所有未读预警信息
|
||||
* */
|
||||
List<AlertMessageDO> getAlertMessageList(Integer deptid);
|
||||
/*
|
||||
* 预警信息统计 首页
|
||||
* */
|
||||
AlertStatisticsVO getAlertStatistics(Integer orgid);
|
||||
|
||||
/**
|
||||
* 删除预警信息
|
||||
|
||||
@ -46,6 +46,7 @@ public class AlertMessageServiceImpl implements AlertMessageService {
|
||||
AlertMessageDO updateObj = BeanUtils.toBean(updateReqVO, AlertMessageDO.class);
|
||||
alertMessageMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AlertMessageDO> getAlertMessageList(Integer deptid) {
|
||||
// 创建 LambdaQueryWrapper 实例
|
||||
@ -58,6 +59,21 @@ public class AlertMessageServiceImpl implements AlertMessageService {
|
||||
// 执行查询
|
||||
return alertMessageMapper.selectList(queryWrapper);
|
||||
}
|
||||
@Override
|
||||
public AlertStatisticsVO getAlertStatistics(Integer orgid) {
|
||||
// 直接调用Mapper,一次查询获取所有数据
|
||||
AlertStatisticsVO result = alertMessageMapper.getAlertStatistics(orgid);
|
||||
|
||||
// 处理null值,确保返回的数据不为null
|
||||
if (result == null) {
|
||||
result = new AlertStatisticsVO();
|
||||
result.setAlertTotal(0);
|
||||
result.setAlertUnhandled(0);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAlertMessage(Integer id) {
|
||||
// 校验存在
|
||||
@ -82,41 +98,23 @@ public class AlertMessageServiceImpl implements AlertMessageService {
|
||||
return alertMessageMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
// 修改你的Service方法
|
||||
@Override
|
||||
public AlertMessageStatisticsRespVO getAlertMessageStatistics(AlertMessageStatisticsReqVO statisticsReqVO) {
|
||||
// 创建查询条件
|
||||
LambdaQueryWrapper<AlertMessageDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 添加时间范围条件
|
||||
queryWrapper.between(AlertMessageDO::getCreatetime, statisticsReqVO.getStartTime(), statisticsReqVO.getEndTime());
|
||||
|
||||
// 添加机构ID条件
|
||||
queryWrapper.eq(AlertMessageDO::getOrgid, statisticsReqVO.getOrgid());
|
||||
|
||||
// 查询总数量
|
||||
Long totalCount = alertMessageMapper.selectCount(queryWrapper);
|
||||
|
||||
// 查询已读数量
|
||||
LambdaQueryWrapper<AlertMessageDO> readQueryWrapper = new LambdaQueryWrapper<>();
|
||||
readQueryWrapper.between(AlertMessageDO::getCreatetime, statisticsReqVO.getStartTime(), statisticsReqVO.getEndTime())
|
||||
.eq(AlertMessageDO::getOrgid, statisticsReqVO.getOrgid())
|
||||
.eq(AlertMessageDO::getStatus, 1); // status = 1 表示已读
|
||||
Long readCount = alertMessageMapper.selectCount(readQueryWrapper);
|
||||
|
||||
// 查询未读数量
|
||||
LambdaQueryWrapper<AlertMessageDO> unreadQueryWrapper = new LambdaQueryWrapper<>();
|
||||
unreadQueryWrapper.between(AlertMessageDO::getCreatetime, statisticsReqVO.getStartTime(), statisticsReqVO.getEndTime())
|
||||
.eq(AlertMessageDO::getOrgid, statisticsReqVO.getOrgid())
|
||||
.eq(AlertMessageDO::getStatus, 0); // status = 0 表示未读
|
||||
Long unreadCount = alertMessageMapper.selectCount(unreadQueryWrapper);
|
||||
|
||||
// 查询按日期分组的数据
|
||||
List<Map<String, Object>> dailyStatistics = alertMessageMapper.selectDailyStatistics(
|
||||
statisticsReqVO.getOrgid(),
|
||||
statisticsReqVO.getStartTime(),
|
||||
// 查询总体统计
|
||||
Map<String, Object> totalStats = alertMessageMapper.selectAlertMessageStatistics(
|
||||
statisticsReqVO.getOrgid(),
|
||||
statisticsReqVO.getStartTime(),
|
||||
statisticsReqVO.getEndTime()
|
||||
);
|
||||
|
||||
|
||||
// 查询按日期分组的数据
|
||||
List<Map<String, Object>> dailyStatistics = alertMessageMapper.selectDailyAlertMessageStatistics(
|
||||
statisticsReqVO.getOrgid(),
|
||||
statisticsReqVO.getStartTime(),
|
||||
statisticsReqVO.getEndTime()
|
||||
);
|
||||
|
||||
// 转换按日期分组的数据
|
||||
List<AlertMessageStatisticsRespVO.DailyAlertData> dailyData = new ArrayList<>();
|
||||
for (Map<String, Object> stat : dailyStatistics) {
|
||||
@ -131,17 +129,29 @@ public class AlertMessageServiceImpl implements AlertMessageService {
|
||||
dailyAlertData.setTotalCount(((Number) stat.get("totalCount")).longValue());
|
||||
dailyAlertData.setReadCount(((Number) stat.get("readCount")).longValue());
|
||||
dailyAlertData.setUnreadCount(((Number) stat.get("unreadCount")).longValue());
|
||||
dailyAlertData.setSosCount(((Number) stat.get("sosCount")).longValue());
|
||||
dailyAlertData.setAnalysisCount(((Number) stat.get("analysisCount")).longValue());
|
||||
dailyAlertData.setSosReadCount(((Number) stat.get("sosReadCount")).longValue());
|
||||
dailyAlertData.setSosUnreadCount(((Number) stat.get("sosUnreadCount")).longValue());
|
||||
dailyAlertData.setAnalysisReadCount(((Number) stat.get("analysisReadCount")).longValue());
|
||||
dailyAlertData.setAnalysisUnreadCount(((Number) stat.get("analysisUnreadCount")).longValue());
|
||||
dailyData.add(dailyAlertData);
|
||||
}
|
||||
|
||||
|
||||
// 构建返回结果
|
||||
AlertMessageStatisticsRespVO result = new AlertMessageStatisticsRespVO();
|
||||
result.setTotalCount(totalCount);
|
||||
result.setReadCount(readCount);
|
||||
result.setUnreadCount(unreadCount);
|
||||
result.setTotalCount(((Number) totalStats.get("totalCount")).longValue());
|
||||
result.setReadCount(((Number) totalStats.get("readCount")).longValue());
|
||||
result.setUnreadCount(((Number) totalStats.get("unreadCount")).longValue());
|
||||
result.setSosCount(((Number) totalStats.get("sosCount")).longValue());
|
||||
result.setAnalysisCount(((Number) totalStats.get("analysisCount")).longValue());
|
||||
result.setSosReadCount(((Number) totalStats.get("sosReadCount")).longValue());
|
||||
result.setSosUnreadCount(((Number) totalStats.get("sosUnreadCount")).longValue());
|
||||
result.setAnalysisReadCount(((Number) totalStats.get("analysisReadCount")).longValue());
|
||||
result.setAnalysisUnreadCount(((Number) totalStats.get("analysisUnreadCount")).longValue());
|
||||
result.setDailyData(dailyData);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
@ -59,6 +59,11 @@ public interface DeviceService {
|
||||
* @return 设备分页
|
||||
*/
|
||||
PageResult<DeviceDO> getDevicePage(DevicePageReqVO pageReqVO);
|
||||
/*
|
||||
*
|
||||
* 首页 获取设备数量统计
|
||||
* */
|
||||
DeviceStatistics getDeviceStatistics(Integer orgid);
|
||||
|
||||
/**
|
||||
* 根据设备ID更新设备状态
|
||||
@ -75,5 +80,9 @@ public interface DeviceService {
|
||||
* @return 设备分页
|
||||
*/
|
||||
PageResult<DeviceDO> getDeviceNotBind(DevicePageReqVO pageReqVO);
|
||||
|
||||
/*
|
||||
*
|
||||
* 首页查询设备地图分布接口
|
||||
* */
|
||||
DeviceMapVO getDeviceMapData(Integer orgid);
|
||||
}
|
||||
@ -12,6 +12,9 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.device.DeviceMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
@ -80,7 +83,10 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
public PageResult<DeviceDO> getDevicePage(DevicePageReqVO pageReqVO) {
|
||||
return deviceMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceStatistics getDeviceStatistics(Integer orgid) {
|
||||
return deviceMapper.getDevice_Statistics(orgid);
|
||||
}
|
||||
@Override
|
||||
public void updateDeviceStatus(Integer devicecode, Integer devicestatus) {
|
||||
// 校验设备是否存在
|
||||
@ -101,5 +107,45 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
public PageResult<DeviceDO> getDeviceNotBind(DevicePageReqVO pageReqVO) {
|
||||
return deviceMapper.selectNotBindPage(pageReqVO);
|
||||
}
|
||||
@Override
|
||||
public DeviceMapVO getDeviceMapData(Integer orgid) {
|
||||
DeviceMapVO result = new DeviceMapVO();
|
||||
|
||||
// 1. 获取设备基础统计
|
||||
DeviceStatistics stats = deviceMapper.getDeviceStatistics(orgid);
|
||||
result.setTotalCount(stats.getTotalCount());
|
||||
result.setOnlineCount(stats.getOnlineCount());
|
||||
result.setOfflineCount(stats.getOfflineCount());
|
||||
|
||||
|
||||
|
||||
// 3. 获取省份分布数据
|
||||
List<ProvinceDeviceCount> provinceData = deviceMapper.getProvinceDeviceCount(orgid);
|
||||
List<MapDataItem> mapData = new ArrayList<>();
|
||||
List<ScatterDataItem> scatterData = new ArrayList<>();
|
||||
|
||||
for (ProvinceDeviceCount item : provinceData) {
|
||||
// 地图数据
|
||||
MapDataItem mapItem = new MapDataItem();
|
||||
mapItem.setName(item.getProvince());
|
||||
mapItem.setValue(item.getCount());
|
||||
mapData.add(mapItem);
|
||||
|
||||
// 散点图数据
|
||||
ProvinceCoords coords = deviceMapper.getByProvince(item.getProvince());
|
||||
if (coords != null) {
|
||||
ScatterDataItem scatterItem = new ScatterDataItem();
|
||||
scatterItem.setName(item.getProvince());
|
||||
scatterItem.setValue(new double[]{coords.getLongitude(), coords.getLatitude(), item.getCount()});
|
||||
scatterItem.setCount(item.getCount());
|
||||
scatterData.add(scatterItem);
|
||||
}
|
||||
}
|
||||
|
||||
result.setMapData(mapData);
|
||||
result.setScatterData(scatterData);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -28,6 +28,11 @@ public interface PersonService {
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updatePerson(@Valid PersonSaveReqVO updateReqVO);
|
||||
/*
|
||||
* 首页统计会员增长趋势 一周
|
||||
* */
|
||||
List<MemberGrowthVO> getMemberGrowthData(Integer orgid);
|
||||
|
||||
/*
|
||||
* 根据主键ID 更新家庭成员 信息
|
||||
* */
|
||||
|
||||
@ -48,6 +48,10 @@ public class PersonServiceImpl implements PersonService {
|
||||
personMapper.updateById(updateObj);
|
||||
}
|
||||
@Override
|
||||
public List<MemberGrowthVO> getMemberGrowthData(Integer orgid) {
|
||||
return personMapper.getMemberGrowthData(orgid);
|
||||
}
|
||||
@Override
|
||||
public Integer updatefamilyinfo(PersonUpfamilyInfoVO updateReqVO)
|
||||
{
|
||||
Integer maxfamilyid = generateNextFamilyId();
|
||||
|
||||
@ -28,6 +28,10 @@ public interface RecordService {
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateRecord(@Valid RecordSaveReqVO updateReqVO);
|
||||
/*
|
||||
* 回访记录统计信息
|
||||
* */
|
||||
List<Map<String, Object>> getVipCountByDay(Integer orgid, String startDate, String endDate);
|
||||
|
||||
/**
|
||||
* 删除会员回访记录
|
||||
|
||||
@ -1,17 +1,14 @@
|
||||
package cn.iocoder.yudao.module.system.service.record;
|
||||
|
||||
import com.alibaba.druid.wall.violation.ErrorCode;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.LocalDate;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.record.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.record.RecordDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.record.RecordMapper;
|
||||
@ -49,6 +46,10 @@ public class RecordServiceImpl implements RecordService {
|
||||
RecordDO updateObj = BeanUtils.toBean(updateReqVO, RecordDO.class);
|
||||
recordMapper.updateById(updateObj);
|
||||
}
|
||||
@Override
|
||||
public List<Map<String, Object>> getVipCountByDay(Integer orgid, String startDate, String endDate) {
|
||||
return recordMapper.selectDailyStatisticsWithResult(orgid,startDate, endDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRecord(Integer id) {
|
||||
|
||||
@ -8,5 +8,12 @@
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
<select id="getDevice_Statistics" resultType="cn.iocoder.yudao.module.system.controller.admin.device.vo.DeviceStatistics">
|
||||
SELECT
|
||||
COUNT(*) AS totalCount,
|
||||
SUM(CASE WHEN devicestatus = 1 THEN 1 ELSE 0 END) AS onlineCount,
|
||||
SUM(CASE WHEN devicestatus = 2 THEN 1 ELSE 0 END) AS offlineCount
|
||||
FROM tb_device
|
||||
WHERE orgid = #{orgid}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -20,5 +20,40 @@
|
||||
GROUP BY DATE_FORMAT(vipStartTime, '%Y-%m-%d')
|
||||
ORDER BY date
|
||||
</select>
|
||||
|
||||
<select id="getMemberGrowthData" resultType="cn.iocoder.yudao.module.system.controller.admin.person.vo.MemberGrowthVO">
|
||||
WITH date_series AS (
|
||||
SELECT CURDATE() - INTERVAL 6 DAY AS date UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 5 DAY UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 4 DAY UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 3 DAY UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 2 DAY UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 1 DAY UNION ALL
|
||||
SELECT CURDATE()
|
||||
),
|
||||
daily_stats AS (
|
||||
SELECT
|
||||
DATE(vipstarttime) AS vip_date,
|
||||
COUNT(*) AS count
|
||||
FROM tb_user
|
||||
WHERE isvip = 1
|
||||
AND orgid = #{orgid}
|
||||
AND vipstarttime >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
|
||||
AND vipstarttime < DATE_ADD(CURDATE(), INTERVAL 1 DAY)
|
||||
GROUP BY DATE(vipstarttime)
|
||||
)
|
||||
SELECT
|
||||
CASE DAYOFWEEK(ds.date)
|
||||
WHEN 1 THEN '周日'
|
||||
WHEN 2 THEN '周一'
|
||||
WHEN 3 THEN '周二'
|
||||
WHEN 4 THEN '周三'
|
||||
WHEN 5 THEN '周四'
|
||||
WHEN 6 THEN '周五'
|
||||
WHEN 7 THEN '周六'
|
||||
END AS date,
|
||||
COALESCE(stats.count, 0) AS count
|
||||
FROM date_series ds
|
||||
LEFT JOIN daily_stats stats ON ds.date = stats.vip_date
|
||||
ORDER BY ds.date
|
||||
</select>
|
||||
</mapper>
|
||||
@ -8,5 +8,19 @@
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
<select id="selectDailyStatisticsWithResult" parameterType="map" resultType="map">
|
||||
SELECT
|
||||
DATE(visittime) AS date,
|
||||
COUNT(*) AS totalCount,
|
||||
SUM(CASE WHEN visitstatus = 1 THEN 1 ELSE 0 END) AS visitedCount,
|
||||
SUM(CASE WHEN visitstatus = 0 THEN 1 ELSE 0 END) AS unvisitedCount,
|
||||
SUM(CASE WHEN visitstatus = 1 AND result = '满意' THEN 1 ELSE 0 END) AS satisfiedCount,
|
||||
SUM(CASE WHEN visitstatus = 1 AND result = '一般' THEN 1 ELSE 0 END) AS normalCount,
|
||||
SUM(CASE WHEN visitstatus = 1 AND result = '不满意' THEN 1 ELSE 0 END) AS unsatisfiedCount
|
||||
FROM visit_record
|
||||
WHERE visittime BETWEEN #{startTime} AND #{endTime}
|
||||
AND orgid = #{orgid}
|
||||
GROUP BY DATE(visittime)
|
||||
ORDER BY date
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user