|
|
|
|
@ -1,12 +1,17 @@
|
|
|
|
|
package com.biutag.supervision.service.Warning.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.biutag.supervision.common.UserContextHolder; |
|
|
|
|
import com.biutag.supervision.constants.AppConstants; |
|
|
|
|
import com.biutag.supervision.constants.enums.*; |
|
|
|
|
import com.biutag.supervision.mapper.InformMessageMapper; |
|
|
|
|
import com.biutag.supervision.mapper.Negative.NegativeMapper; |
|
|
|
|
@ -27,21 +32,28 @@ import com.biutag.supervision.pojo.model.UserAuth;
|
|
|
|
|
import com.biutag.supervision.pojo.model.negative.NegativeDto; |
|
|
|
|
import com.biutag.supervision.pojo.param.Report.FlowQueryParam; |
|
|
|
|
import com.biutag.supervision.pojo.param.Warning.CompileQueryParam; |
|
|
|
|
import com.biutag.supervision.pojo.param.Warning.WarningQueryParam; |
|
|
|
|
import com.biutag.supervision.pojo.request.warning.*; |
|
|
|
|
import com.biutag.supervision.pojo.vo.entryWindow.EntryWindowVo; |
|
|
|
|
import com.biutag.supervision.pojo.vo.warning.WarningBusinessVo; |
|
|
|
|
import com.biutag.supervision.pojo.vo.warning.WarningExcelVo; |
|
|
|
|
import com.biutag.supervision.pojo.vo.warning.WarningProblemExcelVo; |
|
|
|
|
import com.biutag.supervision.service.Negative.NegativeService; |
|
|
|
|
import com.biutag.supervision.service.Negative.NegativeThingFileService; |
|
|
|
|
import com.biutag.supervision.service.Negative.NegativeWorkService; |
|
|
|
|
import com.biutag.supervision.service.Report.ReportProjectService; |
|
|
|
|
import com.biutag.supervision.service.SupDepartService; |
|
|
|
|
import com.biutag.supervision.service.SupDictDataTwoService; |
|
|
|
|
import com.biutag.supervision.service.Warning.WarningBusinessService; |
|
|
|
|
import com.biutag.supervision.service.Warning.WarningRecordService; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
@ -50,6 +62,8 @@ import java.util.List;
|
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
import static com.biutag.supervision.constants.AppConstants.CWLN; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 预警业务服务实现 |
|
|
|
|
*/ |
|
|
|
|
@ -68,6 +82,7 @@ public class WarningBusinessServiceImpl implements WarningBusinessService {
|
|
|
|
|
private final WarningContentMapper warningContentMapper; |
|
|
|
|
private final NegativeService negativeService; |
|
|
|
|
private final NegativeMapper negativeMapper; |
|
|
|
|
private final ReportProjectService reportProjectService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public WarningBusinessVo getDetail(String reportId) { |
|
|
|
|
@ -392,6 +407,178 @@ public class WarningBusinessServiceImpl implements WarningBusinessService {
|
|
|
|
|
return page; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<EntryWindowVo> getWarningPage(WarningQueryParam queryParam) { |
|
|
|
|
UserAuth user = UserContextHolder.getCurrentUser(); |
|
|
|
|
QueryWrapper<ReportProject> wrapper = buildWarningWrapper(queryParam, user); |
|
|
|
|
Page<EntryWindowVo> page = reportProjectService.getPageWarning( |
|
|
|
|
new Page<>(queryParam.getCurrent(), queryParam.getSize()), wrapper, queryParam.getWarningState()); |
|
|
|
|
|
|
|
|
|
page.getRecords().forEach(this::fillProjectData); |
|
|
|
|
return page; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void excelWarningList(WarningQueryParam param, HttpServletResponse response) { |
|
|
|
|
// 1. 调用 getWarningPage 查询全部数据(不分页,size=Integer.MAX_VALUE)
|
|
|
|
|
param.setCurrent(1); |
|
|
|
|
param.setSize(Integer.MAX_VALUE); |
|
|
|
|
IPage<EntryWindowVo> page = getWarningPage(param); |
|
|
|
|
|
|
|
|
|
// 2. Sheet1 数据转换(项目列表)
|
|
|
|
|
List<WarningExcelVo> projectList = page.getRecords().stream().map(record -> { |
|
|
|
|
WarningExcelVo vo = new WarningExcelVo(); |
|
|
|
|
vo.setReportId(record.getId()); |
|
|
|
|
vo.setReportName(record.getReportName()); |
|
|
|
|
vo.setReportType(record.getReportType()); |
|
|
|
|
vo.setProjectType(record.getProjectType()); |
|
|
|
|
vo.setWarningState("1".equals(record.getWarningState()) ? "已预警" |
|
|
|
|
: "2".equals(record.getWarningState()) ? "预警中" : "待预警"); |
|
|
|
|
vo.setSupervisionTime(record.getSupervisionTime()); |
|
|
|
|
vo.setAuditUnitStr(record.getAuditUnitStr()); |
|
|
|
|
vo.setWarningContent(record.getWarningContent()); |
|
|
|
|
vo.setProjectUnitStr(record.getProjectUnitStr()); |
|
|
|
|
vo.setProjectPrincipal(record.getProjectPrincipal()); |
|
|
|
|
vo.setProjectPhone(record.getProjectPhone()); |
|
|
|
|
vo.setPurchaseMethod(record.getPurchaseMethod()); |
|
|
|
|
vo.setReportMoney(record.getReportMoney()); |
|
|
|
|
vo.setApplicantTime(record.getApplicantTime()); |
|
|
|
|
vo.setProjectApprovalMoney(record.getProjectApprovalMoney()); |
|
|
|
|
vo.setProjectApprovalTime(record.getProjectApprovalTime()); |
|
|
|
|
vo.setArchiving(record.getArchiving()); |
|
|
|
|
return vo; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
// 3. Sheet2 数据转换(预警问题列表)
|
|
|
|
|
List<WarningProblemExcelVo> problemList = new ArrayList<>(); |
|
|
|
|
for (EntryWindowVo record : page.getRecords()) { |
|
|
|
|
List<WarningContent> contents = warningContentMapper.selectList( |
|
|
|
|
new LambdaQueryWrapper<WarningContent>() |
|
|
|
|
.eq(WarningContent::getReportId, record.getId()) |
|
|
|
|
.isNotNull(WarningContent::getRemark) |
|
|
|
|
.ne(WarningContent::getRemark, "") |
|
|
|
|
); |
|
|
|
|
for (WarningContent content : contents) { |
|
|
|
|
WarningProblemExcelVo vo = new WarningProblemExcelVo(); |
|
|
|
|
vo.setReportId(record.getId()); |
|
|
|
|
vo.setReportName(record.getReportName()); |
|
|
|
|
vo.setType(content.getType()); |
|
|
|
|
vo.setTitle(content.getTitle()); |
|
|
|
|
vo.setContent(content.getContent()); |
|
|
|
|
vo.setRemark(content.getRemark()); |
|
|
|
|
problemList.add(vo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 4. 导出多 Sheet Excel
|
|
|
|
|
try { |
|
|
|
|
String fileName = URLEncoder.encode("预警监督项目列表", "UTF-8"); |
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + ".xlsx\""); |
|
|
|
|
response.setContentType("application/octet-stream"); |
|
|
|
|
|
|
|
|
|
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()) |
|
|
|
|
.inMemory(Boolean.TRUE) |
|
|
|
|
.build(); |
|
|
|
|
|
|
|
|
|
// Sheet1
|
|
|
|
|
WriteSheet sheet1 = EasyExcel.writerSheet(0, "预警监督项目列表") |
|
|
|
|
.head(WarningExcelVo.class) |
|
|
|
|
.build(); |
|
|
|
|
excelWriter.write(projectList, sheet1); |
|
|
|
|
|
|
|
|
|
// Sheet2
|
|
|
|
|
WriteSheet sheet2 = EasyExcel.writerSheet(1, "预警问题详情") |
|
|
|
|
.head(WarningProblemExcelVo.class) |
|
|
|
|
.build(); |
|
|
|
|
excelWriter.write(problemList, sheet2); |
|
|
|
|
|
|
|
|
|
excelWriter.finish(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("导出预警列表失败", e); |
|
|
|
|
throw new RuntimeException("导出失败", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 构建预警列表查询条件 |
|
|
|
|
*/ |
|
|
|
|
private QueryWrapper<ReportProject> buildWarningWrapper(WarningQueryParam queryParam, UserAuth user) { |
|
|
|
|
QueryWrapper<ReportProject> wrapper = new QueryWrapper<ReportProject>() |
|
|
|
|
.like(StrUtil.isNotBlank(queryParam.getReportName()), "p.report_name", queryParam.getReportName()) |
|
|
|
|
.eq(StrUtil.isNotBlank(queryParam.getWarningState()), "p.warning_state", queryParam.getWarningState()) |
|
|
|
|
.eq("p.node", FlowStateEnum.End.getLabel()) |
|
|
|
|
.eq("p.delete_flag", DeleteStatusEnum.NO.getCode()); |
|
|
|
|
|
|
|
|
|
// 长望浏宁Tab
|
|
|
|
|
if ("cwlnt".equals(queryParam.getSpecialArea())) { |
|
|
|
|
wrapper.in("p.audit_unit_id", departService.getAllNodeIds(CWLN)); |
|
|
|
|
} else { |
|
|
|
|
List<String> excludeOrgIds = new ArrayList<>(departService.getAllNodeIds(AppConstants.DSZD)); |
|
|
|
|
excludeOrgIds.addAll(departService.getAllNodeIds(AppConstants.CWLN)); |
|
|
|
|
wrapper.notIn("p.audit_unit_id", excludeOrgIds); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 审计单位
|
|
|
|
|
if (StrUtil.isNotBlank(queryParam.getAuditUnitId())) { |
|
|
|
|
wrapper.in("p.audit_unit_id", departService.getAllNodeIds(queryParam.getAuditUnitId())); |
|
|
|
|
} |
|
|
|
|
// 项目单位
|
|
|
|
|
if (StrUtil.isNotBlank(queryParam.getProjectUnitId())) { |
|
|
|
|
wrapper.in("p.project_unit_id", departService.getAllNodeIds(queryParam.getProjectUnitId())); |
|
|
|
|
} |
|
|
|
|
// 权限控制
|
|
|
|
|
if (!AppConstants.USER_TYPE_SUPER.equals(user.getUserType()) |
|
|
|
|
&& !user.getRoleCodes().contains(RoleCodeEnum.FIRST_ADMIN.getCode())) { |
|
|
|
|
List<String> orgIds = user.getAuthDepartIds().isEmpty() |
|
|
|
|
? departService.getAllNodeIds(user.getDepartId()) |
|
|
|
|
: departService.getAllNodeIds(user.getAuthDepartIds()); |
|
|
|
|
wrapper.in("p.project_unit_id", orgIds); |
|
|
|
|
} |
|
|
|
|
// 日期范围
|
|
|
|
|
if (CollectionUtil.isNotEmpty(queryParam.getPublicationDate())) { |
|
|
|
|
wrapper.between(true, "p.publication_date", queryParam.getPublicationDate().get(0), queryParam.getPublicationDate().get(1)); |
|
|
|
|
} |
|
|
|
|
if (CollectionUtil.isNotEmpty(queryParam.getEndDate())) { |
|
|
|
|
wrapper.between(true, "p.archiving", queryParam.getEndDate().get(0), queryParam.getEndDate().get(1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return wrapper; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 填充项目数据 |
|
|
|
|
*/ |
|
|
|
|
private void fillProjectData(EntryWindowVo vo) { |
|
|
|
|
// 是否已下发问题:根据 negativeId 判断
|
|
|
|
|
vo.setStateData(StrUtil.isNotBlank(vo.getNegativeId()) ? "1" : "0"); |
|
|
|
|
|
|
|
|
|
// 预警问题数:有 remark 且 remark 不为空的内容条目数
|
|
|
|
|
long contentCount = contentMapper.selectCount( |
|
|
|
|
new LambdaQueryWrapper<WarningContent>() |
|
|
|
|
.eq(WarningContent::getReportId, vo.getId()) |
|
|
|
|
.isNotNull(WarningContent::getRemark) |
|
|
|
|
.ne(WarningContent::getRemark, "")); |
|
|
|
|
vo.setWarningContent(contentCount); |
|
|
|
|
|
|
|
|
|
// 格式化单位字符串
|
|
|
|
|
vo.setAuditUnitStr(formatDepartStr(vo.getAuditUnitId())); |
|
|
|
|
vo.setProjectUnitStr(formatDepartStr(vo.getProjectUnitId())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 格式化部门字符串 |
|
|
|
|
*/ |
|
|
|
|
private String formatDepartStr(String departId) { |
|
|
|
|
if (StrUtil.isBlank(departId)) return "/"; |
|
|
|
|
SupDepart depart = departService.getById(departId); |
|
|
|
|
if (depart == null) return "/"; |
|
|
|
|
if (depart.getLevel() == 3) { |
|
|
|
|
SupDepart parent = departService.getById(depart.getPid()); |
|
|
|
|
return parent.getShortName() + "/" + depart.getShortName(); |
|
|
|
|
} |
|
|
|
|
return depart.getShortName() + "/"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查找当前用户待处理的预警流程ID |
|
|
|
|
*/ |
|
|
|
|
|