|
@@ -4,18 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
-import com.sckw.core.exception.BusinessException;
|
|
|
|
|
-import com.sckw.core.model.constant.NumberConstant;
|
|
|
|
|
-import com.sckw.core.model.enums.MessageLogEnum;
|
|
|
|
|
-import com.sckw.core.model.enums.ReportEnum;
|
|
|
|
|
import com.sckw.core.model.enums.ReportTypeEnum;
|
|
import com.sckw.core.model.enums.ReportTypeEnum;
|
|
|
import com.sckw.core.model.page.PageRes;
|
|
import com.sckw.core.model.page.PageRes;
|
|
|
|
|
+import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.slope.detection.dao.mysql.KwsProjectMapper;
|
|
import com.sckw.slope.detection.dao.mysql.KwsProjectMapper;
|
|
|
import com.sckw.slope.detection.dao.mysql.KwsReportDataMapper;
|
|
import com.sckw.slope.detection.dao.mysql.KwsReportDataMapper;
|
|
|
import com.sckw.slope.detection.dao.mysql.KwsReportTemplateMapper;
|
|
import com.sckw.slope.detection.dao.mysql.KwsReportTemplateMapper;
|
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsProject;
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsProject;
|
|
|
-import com.sckw.slope.detection.model.dos.mysql.KwsReportTemplate;
|
|
|
|
|
|
|
+import com.sckw.slope.detection.model.dos.mysql.KwsReportData;
|
|
|
import com.sckw.slope.detection.model.dto.HeaderData;
|
|
import com.sckw.slope.detection.model.dto.HeaderData;
|
|
|
import com.sckw.slope.detection.model.param.StatementQuery;
|
|
import com.sckw.slope.detection.model.param.StatementQuery;
|
|
|
import com.sckw.slope.detection.model.vo.ReportDetailVO;
|
|
import com.sckw.slope.detection.model.vo.ReportDetailVO;
|
|
@@ -26,10 +23,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author lfdc
|
|
* @author lfdc
|
|
@@ -54,13 +52,20 @@ public class ReportService {
|
|
|
public PageRes select(StatementQuery query, HttpServletRequest request) {
|
|
public PageRes select(StatementQuery query, HttpServletRequest request) {
|
|
|
PageHelper.startPage(query.getPage(), query.getPageSize());
|
|
PageHelper.startPage(query.getPage(), query.getPageSize());
|
|
|
String mountainId = commonService.getHeaderData(request).getMountainId();
|
|
String mountainId = commonService.getHeaderData(request).getMountainId();
|
|
|
- List<ReportStatementVO> list = reportTemplateMapper.selectListByReportNameAndProjectIdAndCompany(query, mountainId);
|
|
|
|
|
|
|
+ List<ReportStatementVO> list = reportDataMapper.selectListByReportNameAndProjectId(query, mountainId);
|
|
|
PageInfo<ReportStatementVO> info = new PageInfo<>(list);
|
|
PageInfo<ReportStatementVO> info = new PageInfo<>(list);
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
return PageRes.build(info, list);
|
|
return PageRes.build(info, list);
|
|
|
}
|
|
}
|
|
|
|
|
+ List<String> collect = list.stream().map(ReportStatementVO::getProjectId).collect(Collectors.toList());
|
|
|
|
|
+ List<KwsProject> kwsProjects = projectMapper.selectList(new LambdaQueryWrapper<KwsProject>()
|
|
|
|
|
+ .in(KwsProject::getId, collect)
|
|
|
|
|
+ .eq(KwsProject::getDelFlag, 0));
|
|
|
|
|
+ Map<Long, String> map = new HashMap<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(kwsProjects)) {
|
|
|
|
|
+ map = kwsProjects.stream().collect(Collectors.toMap(KwsProject::getId, KwsProject::getName));
|
|
|
|
|
+ }
|
|
|
for (ReportStatementVO reportStatementVO : list) {
|
|
for (ReportStatementVO reportStatementVO : list) {
|
|
|
- reportStatementVO.setStatus(ReportEnum.getDescription(reportStatementVO.getStatus()));
|
|
|
|
|
reportStatementVO.setReportType(ReportTypeEnum.getDescription(reportStatementVO.getReportType()));
|
|
reportStatementVO.setReportType(ReportTypeEnum.getDescription(reportStatementVO.getReportType()));
|
|
|
}
|
|
}
|
|
|
return PageRes.build(info, list);
|
|
return PageRes.build(info, list);
|
|
@@ -74,27 +79,34 @@ public class ReportService {
|
|
|
return HttpResult.ok(vo);
|
|
return HttpResult.ok(vo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public HttpResult dels(String id, HttpServletRequest request) {
|
|
|
|
|
|
|
+ public HttpResult dels(String ids, HttpServletRequest request) {
|
|
|
|
|
+ List<Long> list = StringUtils.splitStrToList(ids, Long.class);
|
|
|
HeaderData headerData = commonService.getHeaderData(request);
|
|
HeaderData headerData = commonService.getHeaderData(request);
|
|
|
- KwsReportTemplate template = reportTemplateMapper.selectOne(new LambdaQueryWrapper<KwsReportTemplate>().eq(KwsReportTemplate::getDelFlag, 0)
|
|
|
|
|
- .eq(KwsReportTemplate::getId, Long.parseLong(id)));
|
|
|
|
|
- if (template == null) {
|
|
|
|
|
- throw new BusinessException("模板删除失败,参数错误");
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
+ list.forEach(id -> {
|
|
|
|
|
+ reportDataMapper.update(null, new LambdaUpdateWrapper<KwsReportData>()
|
|
|
|
|
+ .eq(KwsReportData::getId, id)
|
|
|
|
|
+ .eq(KwsReportData::getDelFlag, 0)
|
|
|
|
|
+ .set(KwsReportData::getDelFlag, 1));
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
- reportTemplateMapper.update(null, new LambdaUpdateWrapper<KwsReportTemplate>()
|
|
|
|
|
- .eq(KwsReportTemplate::getId, Long.parseLong(id))
|
|
|
|
|
- .set(KwsReportTemplate::getUpdateTime, LocalDateTime.now())
|
|
|
|
|
- .set(KwsReportTemplate::getUpdateBy, (headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy())))
|
|
|
|
|
- .set(KwsReportTemplate::getStatus, NumberConstant.ONE)
|
|
|
|
|
- );
|
|
|
|
|
- KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>()
|
|
|
|
|
- .eq(KwsProject::getId, Long.parseLong(template.getProjectId())));
|
|
|
|
|
- Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
|
|
- logMap.put("projectName", project.getName());
|
|
|
|
|
- logMap.put("templateName", template.getName());
|
|
|
|
|
- commonService.insertLog(MessageLogEnum.DELETE_REPORT_TEMPLATE, headerData, logMap, headerData.getUpdateBy() == null ?
|
|
|
|
|
- null : Long.parseLong(headerData.getUpdateBy()));
|
|
|
|
|
|
|
+ return HttpResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return HttpResult.ok("删除成功");
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param ids
|
|
|
|
|
+ * @param request
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public HttpResult export(String ids, HttpServletRequest request) {
|
|
|
|
|
+ List<Long> list = StringUtils.splitStrToList(ids, Long.class);
|
|
|
|
|
+ List<KwsReportData> kwsReportData = reportDataMapper.selectList(new LambdaQueryWrapper<KwsReportData>()
|
|
|
|
|
+ .eq(KwsReportData::getDelFlag, 0)
|
|
|
|
|
+ .in(KwsReportData::getId, list));
|
|
|
|
|
+ List<String> fileUrls = new ArrayList<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(kwsReportData)) {
|
|
|
|
|
+ fileUrls = kwsReportData.stream().map(KwsReportData::getFileUrl).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok(fileUrls);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|