修改预警通知接口和回访通知接口
This commit is contained in:
parent
3dd2d2b7bf
commit
5a9d927419
@ -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;
|
||||
|
||||
@ -35,6 +53,23 @@ public class AlertMessageStatisticsRespVO {
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@ -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,41 @@ 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);
|
||||
|
||||
}
|
||||
@ -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);
|
||||
|
||||
}
|
||||
@ -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,7 @@ public class AlertMessageServiceImpl implements AlertMessageService {
|
||||
// 执行查询
|
||||
return alertMessageMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAlertMessage(Integer id) {
|
||||
// 校验存在
|
||||
@ -82,36 +84,18 @@ 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);
|
||||
// 查询总体统计
|
||||
Map<String, Object> totalStats = alertMessageMapper.selectAlertMessageStatistics(
|
||||
statisticsReqVO.getOrgid(),
|
||||
statisticsReqVO.getStartTime(),
|
||||
statisticsReqVO.getEndTime()
|
||||
);
|
||||
|
||||
// 查询按日期分组的数据
|
||||
List<Map<String, Object>> dailyStatistics = alertMessageMapper.selectDailyStatistics(
|
||||
List<Map<String, Object>> dailyStatistics = alertMessageMapper.selectDailyAlertMessageStatistics(
|
||||
statisticsReqVO.getOrgid(),
|
||||
statisticsReqVO.getStartTime(),
|
||||
statisticsReqVO.getEndTime()
|
||||
@ -131,17 +115,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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -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,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