|
@@ -4,12 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.github.pagehelper.PageHelper;
|
|
|
import com.sckj.common.core.AjaxResult;
|
|
|
import com.sckj.common.core.PageResult;
|
|
|
-import com.sckj.common.entity.setting.DictData;
|
|
|
import com.sckj.common.exception.OperateException;
|
|
|
-import com.sckj.common.mapper.setting.DictDataMapper;
|
|
|
import com.sckj.common.util.ExcelUtils;
|
|
|
import com.sckj.common.util.StringUtils;
|
|
|
import com.sckj.common.validate.commons.PageValidate;
|
|
@@ -44,10 +41,10 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 异常情况记录实现类
|
|
|
+ *
|
|
|
* @author zhanghao
|
|
|
*/
|
|
|
@Service
|
|
@@ -56,28 +53,25 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
@Resource
|
|
|
TExceptionLogMapper tExceptionLogMapper;
|
|
|
|
|
|
- @Resource
|
|
|
- DictDataMapper dictDataMapper;
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 异常情况记录列表
|
|
|
*
|
|
|
- * @author zhanghao
|
|
|
- * @param pageValidate 分页参数
|
|
|
+ * @param pageValidate 分页参数
|
|
|
* @param searchValidate 搜索参数
|
|
|
* @return PageResult<TExceptionLogListedVo>
|
|
|
+ * @author zhanghao
|
|
|
*/
|
|
|
-
|
|
|
+
|
|
|
public PageResult<TExceptionLogListedVo> list(PageValidate pageValidate, TExceptionLogSearchValidate searchValidate) {
|
|
|
- Integer page = pageValidate.getPageNo();
|
|
|
+ Integer page = pageValidate.getPageNo();
|
|
|
Integer limit = pageValidate.getPageSize();
|
|
|
|
|
|
QueryWrapper<TExceptionLog> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("del_flag", "1");
|
|
|
queryWrapper.orderByDesc("id");
|
|
|
|
|
|
- if(ObjectUtils.isNotEmpty(searchValidate.getCreateTimeStart()) && ObjectUtils.isNotEmpty(searchValidate.getCreateTimeEnd())){
|
|
|
+ if (ObjectUtils.isNotEmpty(searchValidate.getCreateTimeStart()) && ObjectUtils.isNotEmpty(searchValidate.getCreateTimeEnd())) {
|
|
|
queryWrapper.between("create_time", searchValidate.getCreateTimeStart(), searchValidate.getCreateTimeEnd());
|
|
|
}
|
|
|
|
|
@@ -92,15 +86,15 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
"datetime:updateTimeStart-updateTimeEnd@update_time:str",*/
|
|
|
|
|
|
tExceptionLogMapper.setSearch(queryWrapper, searchValidate, new String[]{
|
|
|
- "=:exceptionType@exception_type:int",
|
|
|
- "=:exceptionArea@exception_area:str",
|
|
|
- "=:exceptionLevel@exception_level:str",
|
|
|
+ "=:exceptionType@exception_type:int",
|
|
|
+ "=:exceptionArea@exception_area:str",
|
|
|
+ "=:exceptionLevel@exception_level:str",
|
|
|
});
|
|
|
|
|
|
IPage<TExceptionLog> iPage = tExceptionLogMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
|
|
|
|
|
List<TExceptionLogListedVo> list = new LinkedList<>();
|
|
|
- for(TExceptionLog item : iPage.getRecords()) {
|
|
|
+ for (TExceptionLog item : iPage.getRecords()) {
|
|
|
TExceptionLogListedVo vo = new TExceptionLogListedVo();
|
|
|
BeanUtils.copyProperties(item, vo);
|
|
|
vo.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(item.getCreateTime())); //由于QueryWrapper或IPage的原因导致JsonFormat注解未生效,此处手动转换格式
|
|
@@ -113,16 +107,16 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
/**
|
|
|
* 异常情况记录详情
|
|
|
*
|
|
|
- * @author zhanghao
|
|
|
* @param id 主键参数
|
|
|
* @return TExceptionLog
|
|
|
+ * @author zhanghao
|
|
|
*/
|
|
|
-
|
|
|
+
|
|
|
public TExceptionLogDetailVo detail(Integer id) {
|
|
|
TExceptionLog model = tExceptionLogMapper.selectOne(
|
|
|
new QueryWrapper<TExceptionLog>()
|
|
|
- .eq("id", id).eq("del_flag", "1")
|
|
|
- .last("limit 1"));
|
|
|
+ .eq("id", id).eq("del_flag", "1")
|
|
|
+ .last("limit 1"));
|
|
|
|
|
|
Assert.notNull(model, "数据不存在");
|
|
|
|
|
@@ -134,10 +128,10 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
/**
|
|
|
* 异常情况记录新增
|
|
|
*
|
|
|
- * @author zhanghao
|
|
|
* @param createValidate 参数
|
|
|
+ * @author zhanghao
|
|
|
*/
|
|
|
-
|
|
|
+
|
|
|
public void add(TExceptionLogCreateValidate createValidate) {
|
|
|
TExceptionLog model = new TExceptionLog();
|
|
|
model.setExceptionType(createValidate.getExceptionType());
|
|
@@ -153,15 +147,15 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
/**
|
|
|
* 异常情况记录编辑
|
|
|
*
|
|
|
- * @author zhanghao
|
|
|
* @param updateValidate 参数
|
|
|
+ * @author zhanghao
|
|
|
*/
|
|
|
-
|
|
|
+
|
|
|
public void edit(TExceptionLogUpdateValidate updateValidate) {
|
|
|
TExceptionLog model = tExceptionLogMapper.selectOne(
|
|
|
new QueryWrapper<TExceptionLog>()
|
|
|
- .eq("id", updateValidate.getId())
|
|
|
- .last("limit 1"));
|
|
|
+ .eq("id", updateValidate.getId())
|
|
|
+ .last("limit 1"));
|
|
|
|
|
|
Assert.notNull(model, "数据不存在!");
|
|
|
|
|
@@ -171,10 +165,10 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
/**
|
|
|
* 异常情况记录删除
|
|
|
*
|
|
|
- * @author zhanghao
|
|
|
* @param id 主键ID
|
|
|
+ * @author zhanghao
|
|
|
*/
|
|
|
-
|
|
|
+
|
|
|
public void del(Integer id) {
|
|
|
TExceptionLog model = tExceptionLogMapper.selectOne(
|
|
|
new QueryWrapper<TExceptionLog>()
|
|
@@ -188,13 +182,13 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
tExceptionLogMapper.updateById(model);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
public AjaxResult<Object> del_ex(List<Long> ids) {
|
|
|
List<TExceptionLog> models = tExceptionLogMapper.selectList(
|
|
|
new QueryWrapper<TExceptionLog>()
|
|
|
.in("id", ids));
|
|
|
|
|
|
- if (CollectionUtils.isEmpty(models)){
|
|
|
+ if (CollectionUtils.isEmpty(models)) {
|
|
|
return AjaxResult.failed("数据不存在");
|
|
|
}
|
|
|
TExceptionLog model = new TExceptionLog();
|
|
@@ -206,8 +200,8 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
/**
|
|
|
* 异常情况记录导出
|
|
|
*
|
|
|
- * @author zhanghao
|
|
|
* @param searchValidate 搜索参数·
|
|
|
+ * @author zhanghao
|
|
|
*/
|
|
|
public ByteArrayOutputStream exportTExceptionLog(TExceptionLogSearchValidate searchValidate) {
|
|
|
Workbook workbook = new XSSFWorkbook();
|
|
@@ -256,16 +250,17 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
* 查询预警统计
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<WarnDTO> selectWarnStats(){
|
|
|
+ public List<WarnDTO> selectWarnStats() {
|
|
|
return tExceptionLogMapper.selectWarnStats();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 异常统计
|
|
|
+ *
|
|
|
* @param searchValidate
|
|
|
* @param response
|
|
|
*/
|
|
|
- public void exportExceptionLogList(TExceptionLogSearchValidate searchValidate, HttpServletResponse response){
|
|
|
+ public void exportExceptionLogList(TExceptionLogSearchValidate searchValidate, HttpServletResponse response) {
|
|
|
List<TExceptionLogExportVo> tExceptionLogExportVos = tExceptionLogMapper.exportExceptionLogList();
|
|
|
try {
|
|
|
ExcelUtils.exportExcel(tExceptionLogExportVos, TExceptionLogExportVo.class, "异常统计", "异常统计", response);
|
|
@@ -279,7 +274,7 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
* @return
|
|
|
*/
|
|
|
public TExceptionLog getLatest() {
|
|
|
- return this.lambdaQuery().orderByDesc(TExceptionLog::getCreateTime).list().stream().findFirst().orElseThrow(()->new OperateException("未查询到数据"));
|
|
|
+ return this.lambdaQuery().orderByDesc(TExceptionLog::getCreateTime).list().stream().findFirst().orElseThrow(() -> new OperateException("未查询到数据"));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -297,7 +292,7 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
* 查询出铁数据
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<TExceptionLogDTO> queryIronExceptionData(TIronExceptionSearchScreenValidate tl2Data) {
|
|
|
+ public List<TExceptionLogDTO> queryIronExceptionData(TIronExceptionSearchScreenValidate tl2Data, Map<String, String> map) {
|
|
|
QueryWrapper<TExceptionLog> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.lambda()
|
|
|
.like(ObjectUtils.isNotEmpty(tl2Data.getExceptionDesc()), TExceptionLog::getExceptionDesc, tl2Data.getExceptionDesc())
|
|
@@ -308,13 +303,7 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
if (StringUtils.isNotBlank(tl2Data.getCreateTimeStart()) && StringUtils.isNotBlank(tl2Data.getCreateTimeEnd())) {
|
|
|
queryWrapper.lambda().between(TExceptionLog::getCreateTime, tl2Data.getCreateTimeStart(), tl2Data.getCreateTimeEnd());
|
|
|
}
|
|
|
- List<DictData> dictDataList = dictDataMapper.selectList((new QueryWrapper<DictData>().lambda().eq(DictData::getTypeId, 12).eq(DictData::getIsDelete, 0)));
|
|
|
- Map<String,String> map = dictDataList.stream().collect((Collectors.toMap(
|
|
|
- DictData::getValue, // 键映射函数
|
|
|
- DictData::getName, // 键映射函数
|
|
|
- (existingValue, newValue) -> existingValue // 合并策略:保留第一个值
|
|
|
- )));
|
|
|
- PageHelper.startPage(tl2Data.getPageNo(), tl2Data.getPageSize());
|
|
|
+
|
|
|
// 使用Java 8 lambda表达式进行数据转换
|
|
|
return list(queryWrapper)
|
|
|
.stream()
|
|
@@ -333,14 +322,14 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
|
|
|
* @param response
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public void exportIronExceptionData(TIronExceptionSearchScreenValidate tl2Data, HttpServletResponse response) throws IOException {
|
|
|
+ public void exportIronExceptionData(TIronExceptionSearchScreenValidate tl2Data, Map<String, String> map, HttpServletResponse response) throws IOException {
|
|
|
if (ObjectUtils.isEmpty(tl2Data.getCreateTimeStart()) || ObjectUtils.isEmpty(tl2Data.getCreateTimeEnd())) {
|
|
|
throw new OperateException("导出请选择开始时间和结束时间!");
|
|
|
}
|
|
|
- List<TExceptionLogDTO> tl2DataList = queryIronExceptionData(tl2Data);
|
|
|
+
|
|
|
+ List<TExceptionLogDTO> tl2DataList = queryIronExceptionData(tl2Data, map);
|
|
|
ExcelUtils.exportExcel(tl2DataList, TExceptionLogDTO.class, "告警列表数据", "告警列表数据", response);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|