推送配置推送历史代码提交

This commit is contained in:
lilin 2026-07-13 13:46:48 +08:00
parent 527eb5ea86
commit 8a4374ed5d
17 changed files with 1067 additions and 143 deletions

View File

@ -24,17 +24,23 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
public void insertFill(MetaObject metaObject) {
Date now = new Date();
// 自动填充创建时间
// 创建时间
this.strictInsertFill(metaObject, "createdAt", Date.class, now);
// 自动填充更新时间
// 更新时间
this.strictInsertFill(metaObject, "updatedAt", Date.class, now);
// 更新时间
this.strictInsertFill(metaObject, "modifyTime", Date.class, now);
try {
String userId = SecurityUtils.getUserId();
// 自动填充更新时间
// 创建人
this.strictInsertFill(metaObject, "createdBy", String.class, userId );
// 自动填充更新时间
//创建人
this.strictInsertFill(metaObject, "recordUser", String.class, userId );
// 更新人
this.strictInsertFill(metaObject, "modifyUser", String.class, userId);
// 更新人
this.strictInsertFill(metaObject, "updatedBy", String.class, userId);
} catch (Exception e) {
log.info("message{}",e.getMessage());
@ -47,12 +53,21 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
*/
@Override
public void updateFill(MetaObject metaObject) {
// 自动填充更新时间
this.strictUpdateFill(metaObject, "updatedAt", Date.class, new Date());
Date date = new Date();
// 更新时间
this.strictUpdateFill(metaObject, "updatedAt", Date.class, date);
// 删除时间
this.strictUpdateFill(metaObject, "deleteTime", Date.class, date);
// 跟新时间
this.strictInsertFill(metaObject, "modifyTime", Date.class, date);
try {
String userId = SecurityUtils.getUserId();
// 自动填充更新人
// 更新人
this.strictInsertFill(metaObject, "updatedBy", String.class, userId);
// 删除人
this.strictInsertFill(metaObject, "deleteUser", String.class, userId);
// 更新人
this.strictInsertFill(metaObject, "modifyUser", String.class, userId);
} catch (Exception e) {
log.info("message{}",e.getMessage());
}

View File

@ -4,23 +4,24 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yfd.platform.annotation.Log;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.config.ResponseResult;
import com.yfd.platform.system.domain.PushConfig;
import com.yfd.platform.system.domain.PushConfigTargetRequest;
import com.yfd.platform.system.domain.PushHistory;
import com.yfd.platform.system.domain.PushHistoryDetail;
import com.yfd.platform.system.service.IPushConfigService;
import com.yfd.platform.qgc_data.domain.ApprovalMain;
import com.yfd.platform.system.domain.*;
import com.yfd.platform.system.service.*;
import com.yfd.platform.utils.DataSourceRequestUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import static cn.hutool.core.date.DateUtil.parseDate;
@RestController
@RequestMapping("/system/pushConfig")
@ -30,14 +31,32 @@ public class PushConfigController {
@Resource
private IPushConfigService pushConfigService;
@Resource
private IUserService userService;
@Resource
private ISysRoleService roleService;
@Resource
private IPushHistoryService pushHistoryService;
@Resource
private IPushHistoryDetailService pushHistoryDetailService;
@Operation(summary = "查询推送配置列表")
@GetMapping("/getPushConfigList")
public ResponseResult getPushConfigList(Page<PushConfig> page,
String categoryName,
String messageType,
Integer targetType,
Integer status) {
return ResponseResult.successData(pushConfigService.getPushConfigPage(page, categoryName, messageType, targetType, status));
@PostMapping("/getPushConfigList")
public ResponseResult getPushConfigList(@RequestBody DataSourceRequest request) {
Page<PushConfig> pushConfigPage = DataSourceRequestUtil.executeQuery(request, PushConfig.class, pushConfigService);
return ResponseResult.successData(pushConfigPage);
// String categoryName = null;
// String messageType = null;
// Integer targetType = null;
// Integer status = null;
// return ResponseResult.successData(pushConfigService.getPushConfigPage(page, categoryName, messageType, targetType, status));
}
@Operation(summary = "根据ID查询推送配置")
@ -63,7 +82,7 @@ public class PushConfigController {
@Log(module = "推送配置", value = "删除推送配置")
@Operation(summary = "删除推送配置")
@PostMapping("/deletePushConfig")
public ResponseResult deletePushConfig(@RequestParam String ids) {
public ResponseResult deletePushConfig(@RequestBody List<String> ids) {
return pushConfigService.deletePushConfig(ids) ? ResponseResult.success() : ResponseResult.error("删除失败");
}
@ -102,23 +121,78 @@ public class PushConfigController {
}
@Operation(summary = "查询推送历史主表")
@GetMapping("/getPushHistoryList")
public ResponseResult getPushHistoryList(Page<PushHistory> page,
String configId,
Integer status,
String messageTypeCode,
String startTime,
String endTime) {
Date start = StrUtil.isBlank(startTime) ? null : DateUtil.parse(startTime);
Date end = StrUtil.isBlank(endTime) ? null : DateUtil.parse(endTime);
return ResponseResult.successData(pushConfigService.getPushHistoryPage(page, configId, status, messageTypeCode, start, end));
@PostMapping("/postPushHistoryList")
public ResponseResult getPushHistoryList(@RequestBody DataSourceRequest request) {
// 1. 预处理日期过滤器
List<DataSourceRequest.FilterDescriptor> filters = request.getFilter().getFilters();
for (DataSourceRequest.FilterDescriptor filter : filters) {
String field = filter.getField();
// 判断是否为日期字段根据你的实体字段名
if (isDateField(field)) {
Object value = filter.getValue();
if (value != null) {
String strValue = value.toString();
if (StrUtil.isNotBlank(strValue)) {
Date dateValue = parseDate(strValue);
// 关键将转换后的 Date 对象重新设置回 filter
filter.setValue(dateValue);
}
}
}
}
// 2. 调用通用查询
Page<PushHistory> pushHistoryPage = DataSourceRequestUtil.executeQuery(request, PushHistory.class, pushHistoryService);
return ResponseResult.successData(pushHistoryPage);
}
// 辅助方法判断字段是否为日期类型根据你的实体类字段名
private boolean isDateField(String field) {
// 这些字段在 PushHistory 中都是 Date 类型
return "planTime".equals(field)
|| "createdAt".equals(field)
|| "updatedAt".equals(field)
|| "modifyTime".equals(field)
|| "deleteTime".equals(field);
}
// 辅助方法解析日期字符串
private Date parseDate(String dateStr) {
try {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateStr);
} catch (ParseException e) {
throw new BizException("日期格式错误,请使用 yyyy-MM-dd HH:mm:ss 格式: " + dateStr);
}
}
@Operation(summary = "查询推送历史明细")
@GetMapping("/getPushHistoryDetailList")
public ResponseResult getPushHistoryDetailList(Page<PushHistoryDetail> page,
String historyId,
Integer status) {
return ResponseResult.successData(pushConfigService.getPushHistoryDetailPage(page, historyId, status));
@PostMapping("/getPushHistoryDetailList")
public ResponseResult getPushHistoryDetailList(@RequestBody DataSourceRequest request) {
Page<PushHistoryDetail> pushHistoryDetailPage = DataSourceRequestUtil.executeQuery(request, PushHistoryDetail.class, pushHistoryDetailService);
return ResponseResult.successData(pushHistoryDetailPage);
}
@GetMapping("/queryUsersList")
@Operation(summary = "查询状态正常的用户列表")
@ResponseBody
public ResponseResult queryUsersList( @RequestParam(value = "name", required = false) String name,@RequestHeader(value = "Tenant_id", required = false) String tenantId) {
List<SysUser> sysUserList = userService.queryUsersList(name,StrUtil.trimToNull(tenantId));
return ResponseResult.successData(sysUserList);
}
@Operation(summary = "根据historyId查推送历史明细详情")
@GetMapping("/getPushHistoryDetailById")
public ResponseResult getPushHistoryDetailById(@RequestParam String historyId) {
return ResponseResult.successData(pushHistoryDetailService.getPushHistoryDetailById(historyId));
}
@GetMapping("/queryRolesList")
@Operation(summary = "查询角色类型列表")
@ResponseBody
public ResponseResult queryRolesList( @RequestParam(value = "roleName", required = false) String roleName,@RequestHeader(value = "Tenant_id", required = false) String tenantId) {
List<SysRole> sysRoleList = roleService.queryRolesList(roleName,StrUtil.trimToNull(tenantId));
return ResponseResult.successData(sysRoleList);
}
}

View File

@ -1,8 +1,6 @@
package com.yfd.platform.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.io.Serializable;
@ -15,6 +13,7 @@ public class PushConfig implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_UUID)
@TableField("ID")
private String id;
private String categoryCode;
@ -41,16 +40,20 @@ public class PushConfig implements Serializable {
private Integer status;
@TableField(fill = FieldFill.INSERT)
private Date createdAt;
private Date updatedAt;
@TableField(fill = FieldFill.INSERT)
private String recordUser;
@TableField(fill = FieldFill.UPDATE)
private String modifyUser;
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date modifyTime;
/** 是否已删除0=未删除 1=已删除 */
@TableField("IS_DELETED")
private Integer isDeleted;
private String deleteUser;

View File

@ -12,10 +12,16 @@ public class PushConfigTargetRequest implements Serializable {
private String configId;
// /**
// * 0-用户1-角色
// */
// private Integer type;
/**
* 0-用户1-角色
* 1-所有人2-按人3-角色
*/
private Integer type;
private Integer targetType;
private List<String> userRoleIds;
}

View File

@ -0,0 +1,10 @@
package com.yfd.platform.system.domain;
import lombok.Data;
@Data
public class PushHistoryDetailStatistics {
private Integer pendingCount; // 待推送0
private Integer successCount; // 成功1
private Integer failCount; // 失败2
}

View File

@ -0,0 +1,15 @@
package com.yfd.platform.system.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class PushTargetVo implements Serializable {
private Integer targetType;
private List<String> userRoleIds;
private List<PushConfigTargetVo> pushConfigTargetVoList;
}

View File

@ -0,0 +1,28 @@
package com.yfd.platform.system.domain;
import lombok.Data;
import java.io.Serializable;
@Data
public class SdWtbhVo implements Serializable{
private static final long serialVersionUID = 1L;
private String stcd;
private String stnm;
private String baseId;
private String baseName;
private String sttpCode;
private String sttpName;
private String rstcd;
private String warnState;
}

View File

@ -2,6 +2,20 @@ package com.yfd.platform.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yfd.platform.system.domain.PushHistoryDetail;
import com.yfd.platform.system.domain.PushHistoryDetailStatistics;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
@Mapper
public interface PushHistoryDetailMapper extends BaseMapper<PushHistoryDetail> {
@Select("SELECT " +
"COUNT(CASE WHEN STATUS = 0 THEN 1 END) AS pendingCount, " +
"COUNT(CASE WHEN STATUS = 1 THEN 1 END) AS successCount, " +
"COUNT(CASE WHEN STATUS = 2 THEN 1 END) AS failCount " +
"FROM PUSH_HISTORY_DETAIL " +
"WHERE HISTORY_ID = #{historyId}")
PushHistoryDetailStatistics countByHistoryId(@Param("historyId") String historyId);
}

View File

@ -2,11 +2,7 @@ package com.yfd.platform.system.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yfd.platform.system.domain.PushConfig;
import com.yfd.platform.system.domain.PushConfigTargetRequest;
import com.yfd.platform.system.domain.PushConfigTargetVo;
import com.yfd.platform.system.domain.PushHistory;
import com.yfd.platform.system.domain.PushHistoryDetail;
import com.yfd.platform.system.domain.*;
import java.util.Date;
import java.util.List;
@ -23,7 +19,7 @@ public interface IPushConfigService extends IService<PushConfig> {
boolean updatePushConfig(PushConfig pushConfig);
boolean deletePushConfig(String ids);
boolean deletePushConfig(List<String> ids);
boolean setPushConfigStatus(String id, Integer status);
@ -31,7 +27,7 @@ public interface IPushConfigService extends IService<PushConfig> {
boolean savePushTargets(PushConfigTargetRequest request);
List<PushConfigTargetVo> getPushTargets(String configId);
PushTargetVo getPushTargets(String configId);
Page<PushHistory> getPushHistoryPage(Page<PushHistory> page,
String configId,

View File

@ -4,4 +4,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.yfd.platform.system.domain.PushHistoryDetail;
public interface IPushHistoryDetailService extends IService<PushHistoryDetail> {
Object getPushHistoryDetailById(String historyId);
}

View File

@ -65,4 +65,6 @@ public interface ISysRoleService extends IService<SysRole> {
boolean setMenuById(String id, String menuIds);
List<SysRole> selectRoleList(String rolename, String tenantId);
List<SysRole> queryRolesList(String roleName, String tenantId);
}

View File

@ -183,4 +183,5 @@ public interface IUserService extends IService<SysUser> {
************************************/
Page<SysUser> queryPendingAuditUsers(Page<SysUser> page, String name, String regStatus, String tenantId);
List<SysUser> queryUsersList(String name, String tenantId);
}

View File

@ -2,10 +2,23 @@ package com.yfd.platform.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.system.domain.PushHistoryDetail;
import com.yfd.platform.system.domain.PushHistoryDetailStatistics;
import com.yfd.platform.system.mapper.PushHistoryDetailMapper;
import com.yfd.platform.system.service.IPushHistoryDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class PushHistoryDetailServiceImpl extends ServiceImpl<PushHistoryDetailMapper, PushHistoryDetail> implements IPushHistoryDetailService {
@Autowired
private PushHistoryDetailMapper pushHistoryDetailMapper;
@Override
public Object getPushHistoryDetailById(String historyId) {
return pushHistoryDetailMapper.countByHistoryId(historyId);
}
}

View File

@ -1,6 +1,8 @@
package com.yfd.platform.system.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.config.ResponseResult;
@ -172,4 +174,15 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
return roleMapper.selectRoleList(rolename, tenantId);
}
@Override
public List<SysRole> queryRolesList(String roleName, String tenantId) {
LambdaQueryWrapper<SysRole> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrUtil.isNotBlank(tenantId), SysRole::getTenantId, tenantId);
queryWrapper.like(StrUtil.isNotBlank(roleName),SysRole::getRolename, roleName);
queryWrapper.ne(SysRole::getLevel, 1);
queryWrapper.orderByDesc(SysRole::getLevel);
List<SysRole> sysRoleList = this.list( queryWrapper);
return sysRoleList;
}
}

View File

@ -904,4 +904,20 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme
return true;
}
}
@Override
public List<SysUser> queryUsersList(String name, String tenantId) {
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrUtil.isNotBlank(tenantId), SysUser::getTenantId, tenantId);
queryWrapper.eq(SysUser::getStatus, 1);
queryWrapper.and(StrUtil.isNotBlank(name), wrapper ->
wrapper.like(SysUser::getNickname, name)
.or()
.like(SysUser::getRealName, name)
);
queryWrapper.orderByDesc(SysUser::getRegTime);
List<SysUser> sysUserList = this.list( queryWrapper);
return sysUserList;
}
}

View File

@ -0,0 +1,28 @@
package com.yfd.platform.utils;
import cn.hutool.cron.pattern.CronPattern;
import cn.hutool.cron.pattern.CronPatternUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.DateField;
import java.util.Date;
/**
* Cron 表达式工具类基于 Hutool 6.x
* 支持 6 位或 7 位表达式 星期 []
*/
public class CronUtil {
/**
* 校验 Cron 表达式是否合法
* @param expression Cron 表达式支持 6 7 个字段
* @return true-合法false-非法
*/
public static boolean isValid(String expression) {
try {
CronPattern.of(expression);
return true;
} catch (Exception e) {
return false;
}
}
}