新增获取时间轴列表
This commit is contained in:
parent
110d28c64f
commit
bd40ac6351
|
@ -13,6 +13,7 @@ import org.dromara.common.log.enums.BusinessType;
|
|||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.scale.domain.bo.SysInterveneRecordBo;
|
||||
import org.dromara.scale.domain.vo.SysInterveneRecordVo;
|
||||
import org.dromara.scale.domain.vo.TimeAxisVo;
|
||||
import org.dromara.scale.service.ISysInterveneRecordService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -33,15 +34,6 @@ public class SysInterveneRecordController extends BaseController {
|
|||
|
||||
private final ISysInterveneRecordService sysInterveneRecordService;
|
||||
|
||||
/**
|
||||
* 查询干预记录列表
|
||||
*/
|
||||
// @SaCheckPermission("scale:intervene:pageList")
|
||||
// @GetMapping("/pageList")
|
||||
// public TableDataInfo<SysInterveneRecordVo> list(SysInterveneRecordBo bo, PageQuery pageQuery) {
|
||||
// return sysInterveneRecordService.queryPageList(bo, pageQuery);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 导出干预记录列表
|
||||
*/
|
||||
|
@ -75,18 +67,15 @@ public class SysInterveneRecordController extends BaseController {
|
|||
return toAjax(sysInterveneRecordService.insertByBo(bo));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改干预记录
|
||||
* 获取干预时间轴信息
|
||||
*
|
||||
* @param userId 主键
|
||||
*/
|
||||
// @SaCheckPermission("scale:intervene:edit")
|
||||
// @Log(title = "干预记录", businessType = BusinessType.UPDATE)
|
||||
// @RepeatSubmit()
|
||||
// @PutMapping()
|
||||
// public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysInterveneRecordBo bo) {
|
||||
// return toAjax(sysInterveneRecordService.updateByBo(bo));
|
||||
// }
|
||||
|
||||
@SaCheckPermission("intervene:record:query")
|
||||
@GetMapping("/times")
|
||||
public R<List<TimeAxisVo>> getTimes(@NotNull(message = "用户id不能为空") Long userId) {
|
||||
return R.ok(sysInterveneRecordService.queryInterveneTimeList(userId));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package org.dromara.scale.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>时间轴<p>
|
||||
*
|
||||
* @author cjw
|
||||
* @version V1.0.0
|
||||
* @date 2024/4/24 9:34
|
||||
*/
|
||||
@Data
|
||||
public class TimeAxisVo {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String time;
|
||||
|
||||
private String type;
|
||||
}
|
|
@ -4,6 +4,9 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
import org.dromara.scale.domain.SysInterveneRecord;
|
||||
import org.dromara.scale.domain.vo.SysInterveneRecordVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.scale.domain.vo.TimeAxisVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 干预记录Mapper接口
|
||||
|
@ -13,5 +16,5 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
|||
*/
|
||||
@Mapper
|
||||
public interface SysInterveneRecordMapper extends BaseMapperPlus<SysInterveneRecord, SysInterveneRecordVo> {
|
||||
|
||||
List<TimeAxisVo> selectTimeList(Long userId);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.scale.domain.SysWarnRecord;
|
||||
import org.dromara.scale.domain.vo.TimeAxisVo;
|
||||
import org.dromara.scale.domain.vo.SysEvaluationRecordVo;
|
||||
import org.dromara.scale.domain.vo.SysWarnRecordVo;
|
||||
|
||||
|
@ -30,5 +31,7 @@ public interface SysWarnRecordMapper extends BaseMapperPlus<SysWarnRecord, SysWa
|
|||
|
||||
List<Integer> selectUseConfig();
|
||||
|
||||
List<TimeAxisVo> selectTimeList(Long userId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.dromara.scale.service;
|
|||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.scale.domain.bo.SysInterveneRecordBo;
|
||||
import org.dromara.scale.domain.vo.TimeAxisVo;
|
||||
import org.dromara.scale.domain.vo.SysInterveneRecordVo;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -40,4 +41,6 @@ public interface ISysInterveneRecordService {
|
|||
*/
|
||||
Boolean updateByBo(SysInterveneRecordBo bo);
|
||||
|
||||
List<TimeAxisVo> queryInterveneTimeList(Long userId);
|
||||
|
||||
}
|
||||
|
|
|
@ -13,14 +13,18 @@ import org.dromara.scale.constant.StatusEnum;
|
|||
import org.dromara.scale.domain.SysInterveneRecord;
|
||||
import org.dromara.scale.domain.bo.SysInterveneRecordBo;
|
||||
import org.dromara.scale.domain.vo.SysInterveneRecordVo;
|
||||
import org.dromara.scale.domain.vo.TimeAxisVo;
|
||||
import org.dromara.scale.mapper.SysInterveneRecordMapper;
|
||||
import org.dromara.scale.mapper.SysWarnRecordMapper;
|
||||
import org.dromara.scale.service.ISysInterveneRecordService;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.mapper.SysUserMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.dromara.common.satoken.utils.LoginHelper.getLoginUser;
|
||||
|
||||
|
@ -38,6 +42,8 @@ public class SysInterveneRecordServiceImpl implements ISysInterveneRecordService
|
|||
|
||||
private final SysUserMapper userMapper;
|
||||
|
||||
private final SysWarnRecordMapper warnMapper;
|
||||
|
||||
/**
|
||||
* 查询干预记录
|
||||
*/
|
||||
|
@ -116,4 +122,11 @@ public class SysInterveneRecordServiceImpl implements ISysInterveneRecordService
|
|||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeAxisVo> queryInterveneTimeList(Long userId) {
|
||||
List<TimeAxisVo> warn = warnMapper.selectTimeList(userId);
|
||||
List<TimeAxisVo> intervene = baseMapper.selectTimeList(userId);
|
||||
warn.addAll(intervene);
|
||||
return warn.stream().sorted(Comparator.comparing(TimeAxisVo::getTime).reversed()).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,15 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.scale.constant.StatusEnum;
|
||||
import org.dromara.scale.domain.SysWarnRecord;
|
||||
import org.dromara.scale.domain.bo.SysWarnRecordBo;
|
||||
import org.dromara.scale.domain.vo.SysEvaluationRecordVo;
|
||||
import org.dromara.scale.domain.vo.SysWarnRecordVo;
|
||||
import org.dromara.scale.mapper.SysWarnRecordMapper;
|
||||
import org.dromara.scale.service.ISysWarnRecordService;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.mapper.SysUserMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -30,6 +33,8 @@ public class SysWarnRecordServiceImpl implements ISysWarnRecordService {
|
|||
|
||||
private final SysWarnRecordMapper baseMapper;
|
||||
|
||||
private final SysUserMapper userMapper;
|
||||
|
||||
/**
|
||||
* 查询预警记录
|
||||
*/
|
||||
|
@ -75,6 +80,10 @@ public class SysWarnRecordServiceImpl implements ISysWarnRecordService {
|
|||
.eq(SysWarnRecord::getUserId, add.getUserId()));
|
||||
//保证同一个batch只有一条数据;
|
||||
if (warnRecord == null) {
|
||||
SysUser record = new SysUser();
|
||||
record.setUserId(add.getUserId());
|
||||
record.setInterveneStatus(StatusEnum.IN_USE.getValue());
|
||||
userMapper.updateById(record);
|
||||
return baseMapper.insert(add) > 0;
|
||||
} else {
|
||||
//取最高严重等级
|
||||
|
@ -112,7 +121,6 @@ public class SysWarnRecordServiceImpl implements ISysWarnRecordService {
|
|||
|
||||
@Override
|
||||
public Boolean updateWarnConfig(Integer[] ids) {
|
||||
|
||||
return baseMapper.updateConfigByIds(StrUtil.join(StrUtil.COMMA, ids)) > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.scale.mapper.SysInterveneRecordMapper">
|
||||
|
||||
<select id="selectTimeList" resultType="org.dromara.scale.domain.vo.TimeAxisVo">
|
||||
select intervene_id as `id`,
|
||||
CONCAT(DATE_FORMAT(create_time, '%Y-%m-%d'), ' 的预警') as `name`,
|
||||
create_time as `time`,
|
||||
'intervene' as `type`
|
||||
from sys_intervene_record
|
||||
where user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -33,4 +33,14 @@
|
|||
from sys_warn_config
|
||||
where status = 1
|
||||
</select>
|
||||
|
||||
<select id="selectTimeList" resultType="org.dromara.scale.domain.vo.TimeAxisVo">
|
||||
select wr.warn_id as `id`,
|
||||
CONCAT(DATE_FORMAT(wr.warn_time, '%Y-%m-%d'), ' ', sp.session_name, '的预警') as `name`,
|
||||
wr.warn_time as `time`,
|
||||
'warn' as `type`
|
||||
from sys_warn_record wr
|
||||
left join sys_scale_publish sp on sp.batch_no = wr.batch_no
|
||||
where wr.user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue