|
|
@@ -2,6 +2,7 @@ package com.xjrsoft.module.dataexpert.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
@@ -9,15 +10,21 @@ import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.page.PageOutput;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.module.dataexpert.dto.AddDataExpertTemplateDto;
|
|
|
+import com.xjrsoft.module.dataexpert.dto.DataExpertDto;
|
|
|
import com.xjrsoft.module.dataexpert.dto.DataExpertTemplatePageDto;
|
|
|
import com.xjrsoft.module.dataexpert.dto.UpdateDataExpertTemplateDto;
|
|
|
+import com.xjrsoft.module.dataexpert.entity.DataExpertSource;
|
|
|
import com.xjrsoft.module.dataexpert.entity.DataExpertTemplate;
|
|
|
+import com.xjrsoft.module.dataexpert.service.IDataExpertSourceService;
|
|
|
import com.xjrsoft.module.dataexpert.service.IDataExpertTemplateService;
|
|
|
+import com.xjrsoft.module.dataexpert.vo.DataExpertTemplateFieldVo;
|
|
|
import com.xjrsoft.module.dataexpert.vo.DataExpertTemplatePageVo;
|
|
|
import com.xjrsoft.module.dataexpert.vo.DataExpertTemplateVo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang3.function.FailablePredicate;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
@@ -28,7 +35,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @title: 数据导出-数据模板
|
|
|
@@ -42,7 +51,7 @@ import java.util.List;
|
|
|
@AllArgsConstructor
|
|
|
public class DataExpertTemplateController {
|
|
|
|
|
|
-
|
|
|
+ private final IDataExpertSourceService dataExpertSourceService;
|
|
|
private final IDataExpertTemplateService dataExpertTemplateService;
|
|
|
|
|
|
@GetMapping(value = "/page")
|
|
|
@@ -100,12 +109,35 @@ public class DataExpertTemplateController {
|
|
|
@GetMapping(value = "/field-info")
|
|
|
@ApiOperation(value="根据id查询数据导出-数据模板信息")
|
|
|
@SaCheckPermission("dataexperttemplate:detail")
|
|
|
- public RT<DataExpertTemplateVo> getFieldInfo(@RequestParam Long id){
|
|
|
- DataExpertTemplate dataExpertTemplate = dataExpertTemplateService.getById(id);
|
|
|
- if (dataExpertTemplate == null) {
|
|
|
- return RT.error("找不到此数据!");
|
|
|
+ public RT<List<DataExpertTemplateFieldVo>> getFieldInfo(@RequestParam Long id){
|
|
|
+ return RT.ok(dataExpertTemplateService.getFieldList(id));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/export")
|
|
|
+ @ApiOperation(value = "导出")
|
|
|
+ public ResponseEntity<byte[]> exportData(@Valid DataExpertDto dto) {
|
|
|
+ DataExpertTemplate template = dataExpertTemplateService.getById(dto.getDataExpertTemplateId());
|
|
|
+ DataExpertSource expertSource = dataExpertSourceService.getById(template.getDataExpertSourceId());
|
|
|
+
|
|
|
+ String fields = "";
|
|
|
+ Map<Integer, String> showNameMap = new HashMap<>();
|
|
|
+
|
|
|
+ List<DataExpertTemplateFieldVo> fieldList = dto.getFieldList();
|
|
|
+ for (int i = 0; i < fieldList.size(); i ++){
|
|
|
+ DataExpertTemplateFieldVo fieldVo = fieldList.get(i);
|
|
|
+ showNameMap.put(i, fieldVo.getShowName());
|
|
|
+ if(i > 0){
|
|
|
+ fields += ",";
|
|
|
+ }
|
|
|
+ fields += fieldVo.getFieldName();
|
|
|
}
|
|
|
- return RT.ok(BeanUtil.toBean(dataExpertTemplate, DataExpertTemplateVo.class));
|
|
|
+ for (DataExpertTemplateFieldVo dataExpertTemplateFieldVo : dto.getFieldList()) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return RT.fileStream(null, "WeeklyDutySchedule" + ExcelTypeEnum.XLSX.getValue());
|
|
|
}
|
|
|
|
|
|
}
|