|
|
|
|
@ -1,11 +1,15 @@
|
|
|
|
|
package org.dromara.out.controller;
|
|
|
|
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
|
import jakarta.validation.constraints.NotEmpty;
|
|
|
|
|
import jakarta.validation.constraints.NotNull;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
|
|
import org.dromara.common.core.validate.AddGroup;
|
|
|
|
|
import org.dromara.common.core.validate.EditGroup;
|
|
|
|
|
import org.dromara.common.excel.utils.ExcelUtil;
|
|
|
|
|
@ -15,14 +19,24 @@ import org.dromara.common.log.enums.BusinessType;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
import org.dromara.common.web.core.BaseController;
|
|
|
|
|
import org.dromara.out.domain.OutConstructionValue;
|
|
|
|
|
import org.dromara.out.domain.OutConstructionValueRange;
|
|
|
|
|
import org.dromara.out.domain.bo.OutConstructionValueRangeBo;
|
|
|
|
|
import org.dromara.out.domain.vo.OutConstructionAllValueRangeVo;
|
|
|
|
|
import org.dromara.out.domain.vo.OutConstructionValueRangeVo;
|
|
|
|
|
import org.dromara.out.domain.vo.OutConstructionValueVo;
|
|
|
|
|
import org.dromara.out.service.IOutConstructionValueRangeService;
|
|
|
|
|
import org.dromara.out.service.IOutConstructionValueService;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 施工产值范围
|
|
|
|
|
@ -30,6 +44,7 @@ import java.util.List;
|
|
|
|
|
* @author lilemy
|
|
|
|
|
* @date 2025-09-25
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Validated
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@RestController
|
|
|
|
|
@ -38,6 +53,8 @@ public class OutConstructionValueRangeController extends BaseController {
|
|
|
|
|
|
|
|
|
|
private final IOutConstructionValueRangeService outConstructionValueRangeService;
|
|
|
|
|
|
|
|
|
|
private final IOutConstructionValueService outConstructionValueService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询施工产值范围列表
|
|
|
|
|
*/
|
|
|
|
|
@ -54,8 +71,47 @@ public class OutConstructionValueRangeController extends BaseController {
|
|
|
|
|
@Log(title = "施工产值范围", businessType = BusinessType.EXPORT)
|
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
public void export(OutConstructionValueRangeBo bo, HttpServletResponse response) {
|
|
|
|
|
List<OutConstructionValueRangeVo> list = outConstructionValueRangeService.queryList(bo);
|
|
|
|
|
ExcelUtil.exportExcel(list, "施工产值范围", OutConstructionValueRangeVo.class, response);
|
|
|
|
|
LambdaQueryWrapper<OutConstructionValue> lqw = new LambdaQueryWrapper<>();
|
|
|
|
|
lqw.eq(bo.getProjectId() != null, OutConstructionValue::getProjectId, bo.getProjectId());
|
|
|
|
|
if (bo.getStartDate() != null && bo.getEndDate() != null) {
|
|
|
|
|
lqw.between(OutConstructionValue::getReportDate, bo.getStartDate(), bo.getEndDate());
|
|
|
|
|
} else if (bo.getStartDate() != null) {
|
|
|
|
|
lqw.ge(OutConstructionValue::getReportDate, bo.getStartDate());
|
|
|
|
|
} else if (bo.getEndDate() != null) {
|
|
|
|
|
lqw.le(OutConstructionValue::getReportDate, bo.getEndDate());
|
|
|
|
|
}
|
|
|
|
|
List<OutConstructionValue> list = outConstructionValueService.list(lqw);
|
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
List<OutConstructionValueVo> valueVoList = new ArrayList<>(list.stream().map(value -> {
|
|
|
|
|
OutConstructionValueVo vo = new OutConstructionValueVo();
|
|
|
|
|
BeanUtils.copyProperties(value, vo);
|
|
|
|
|
return vo;
|
|
|
|
|
}).toList());
|
|
|
|
|
outConstructionValueService.supplementaryData(valueVoList);
|
|
|
|
|
Set<Long> weekIds = valueVoList.stream().map(OutConstructionValueVo::getRangeId).collect(Collectors.toSet());
|
|
|
|
|
List<OutConstructionValueRange> ranges = outConstructionValueRangeService.listByIds(weekIds);
|
|
|
|
|
Map<Long, List<OutConstructionValueRange>> rangeMap = ranges.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(OutConstructionValueRange::getId));
|
|
|
|
|
Map<Long, List<OutConstructionValueVo>> map = valueVoList.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(OutConstructionValueVo::getRangeId));
|
|
|
|
|
List<List<OutConstructionValueVo>> valueList = new ArrayList<>();
|
|
|
|
|
List<String> nameList = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<Long, List<OutConstructionValueVo>> entry : map.entrySet()) {
|
|
|
|
|
List<OutConstructionValueVo> valueVos = entry.getValue();
|
|
|
|
|
valueList.add(valueVos);
|
|
|
|
|
if (rangeMap.containsKey(entry.getKey())) {
|
|
|
|
|
OutConstructionValueRange range = rangeMap.get(entry.getKey()).getFirst();
|
|
|
|
|
nameList.add(range.getStartDate() + " - " + range.getEndDate());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
ExcelUtil.exportMultiSheetExcelEnhanced(valueList, nameList, OutConstructionValueVo.class, null, response);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error("导出失败", e);
|
|
|
|
|
throw new ServiceException("导出失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|