| | |
| | | package com.sinata.system.service.impl; |
| | | |
| | | import cn.idev.excel.FastExcel; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.sinata.common.entity.PageDTO; |
| | | import com.sinata.common.utils.SecurityUtils; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.system.domain.MwWarningRecord; |
| | | import com.sinata.system.domain.query.MwWarningRecordQuery; |
| | | import com.sinata.system.domain.vo.MwWarningRecordVO; |
| | | import com.sinata.system.enums.WarningStatusEnum; |
| | | import com.sinata.system.mapper.MwWarningRecordMapper; |
| | | import com.sinata.system.service.MwWarningRecordService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.sinata.system.service.SysDepartmentService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2024-12-02 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class MwWarningRecordServiceImpl extends ServiceImpl<MwWarningRecordMapper, MwWarningRecord> implements MwWarningRecordService { |
| | | private final SysDepartmentService sysDepartmentService; |
| | | private final HttpServletResponse response; |
| | | |
| | | /** |
| | | * 预警信息分页列表 |
| | | * |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageDTO<MwWarningRecordVO> pageList(MwWarningRecordQuery query) { |
| | | String treeCode = sysDepartmentService.getTreeCodeByDepartmentId(query.getDepartmentId()); |
| | | Page<MwWarningRecordVO> page = baseMapper.pageList(new Page<>(query.getPageCurr(), query.getPageSize()), query, treeCode); |
| | | return PageDTO.of(page); |
| | | } |
| | | |
| | | /** |
| | | * 解除预警 |
| | | * |
| | | * @param id |
| | | */ |
| | | @Override |
| | | public void relieve(Long id) { |
| | | lambdaUpdate().set(MwWarningRecord::getStatus, WarningStatusEnum.RESOLVED.getCode()) |
| | | .set(MwWarningRecord::getUpdateTime, new Date()) |
| | | .set(MwWarningRecord::getUpdateBy, SecurityUtils.getUserId()) |
| | | .eq(MwWarningRecord::getId, id).update(); |
| | | } |
| | | |
| | | @Override |
| | | public void export(MwWarningRecordQuery query) throws IOException { |
| | | String treeCode = sysDepartmentService.getTreeCodeByDepartmentId(query.getDepartmentId()); |
| | | if (StringUtils.isBlank(treeCode)) { |
| | | return; |
| | | } |
| | | List<MwWarningRecordVO> list = baseMapper.queryList(new Page<>(query.getPageCurr(), query.getPageSize()), query, treeCode); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode("预警信息", "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | |
| | | FastExcel.write(response.getOutputStream(), MwWarningRecordVO.class) |
| | | .sheet("预警信息") |
| | | .doWrite(list); |
| | | } |
| | | } |