Commit fd725ced authored by wujipeng's avatar wujipeng
Browse files

模板生成报表第一版

parent e7660251
...@@ -34,4 +34,10 @@ public class ReportController { ...@@ -34,4 +34,10 @@ public class ReportController {
public Result<Boolean> deleteReport(@PathVariable String id) { public Result<Boolean> deleteReport(@PathVariable String id) {
return Result.success(reportService.deleteReport(id)); return Result.success(reportService.deleteReport(id));
} }
@ApiOperation("生成报表")
@PostMapping("/generate")
public Result<Boolean> generateReport(@RequestBody ReportDTO reportDTO) {
return Result.success(reportService.generateReport(reportDTO));
}
} }
...@@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.annotation.TableId; ...@@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author : wujipeng * @author : wujipeng
...@@ -17,6 +20,9 @@ import lombok.Data; ...@@ -17,6 +20,9 @@ import lombok.Data;
@Data @Data
@TableName("report_config") @TableName("report_config")
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ReportConfigEntity { public class ReportConfigEntity {
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
......
...@@ -5,7 +5,10 @@ import com.baomidou.mybatisplus.annotation.TableField; ...@@ -5,7 +5,10 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -18,6 +21,9 @@ import java.util.Map; ...@@ -18,6 +21,9 @@ import java.util.Map;
*/ */
@Data @Data
@TableName("report") @TableName("report")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ReportEntity { public class ReportEntity {
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
......
...@@ -17,4 +17,6 @@ public interface ReportService extends IService<ReportEntity> { ...@@ -17,4 +17,6 @@ public interface ReportService extends IService<ReportEntity> {
Boolean deleteReport(String id); Boolean deleteReport(String id);
Boolean generateReport(ReportDTO reportDTO);
} }
...@@ -6,20 +6,15 @@ import com.github.pagehelper.Page; ...@@ -6,20 +6,15 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.ruzhoukj.integration.mapper.ReportMapper; import com.ruzhoukj.integration.mapper.ReportMapper;
import com.ruzhoukj.integration.pojo.dto.ReportDTO; import com.ruzhoukj.integration.pojo.dto.ReportDTO;
import com.ruzhoukj.integration.pojo.entity.ReportConfigEntity; import com.ruzhoukj.integration.pojo.entity.*;
import com.ruzhoukj.integration.pojo.entity.ReportDetailBasicEntity;
import com.ruzhoukj.integration.pojo.entity.ReportDetailMergeEntity;
import com.ruzhoukj.integration.pojo.entity.ReportEntity;
import com.ruzhoukj.integration.pojo.vo.ReportVO; import com.ruzhoukj.integration.pojo.vo.ReportVO;
import com.ruzhoukj.integration.result.PageResult; import com.ruzhoukj.integration.result.PageResult;
import com.ruzhoukj.integration.service.ReportConfigService; import com.ruzhoukj.integration.service.*;
import com.ruzhoukj.integration.service.ReportDetailBasicService;
import com.ruzhoukj.integration.service.ReportDetailMergeService;
import com.ruzhoukj.integration.service.ReportService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -37,6 +32,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, ReportEntity> i ...@@ -37,6 +32,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, ReportEntity> i
private ReportDetailMergeService reportDetailMergeService; private ReportDetailMergeService reportDetailMergeService;
@Resource @Resource
private ReportConfigService reportConfigService; private ReportConfigService reportConfigService;
@Resource
private TemplateConfigService templateConfigService;
@Resource
private TemplateDetailMergeService templateDetailMergeService;
@Resource
private TemplateDetailBasicService templateDetailBasicService;
@Resource
private TemplateService templateService;
@Override @Override
public PageResult<ReportVO> getPageData(ReportDTO reportDTO) { public PageResult<ReportVO> getPageData(ReportDTO reportDTO) {
...@@ -60,4 +63,47 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, ReportEntity> i ...@@ -60,4 +63,47 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, ReportEntity> i
reportConfigService.remove(new LambdaQueryWrapper<ReportConfigEntity>().eq(ReportConfigEntity::getReportId, id)); reportConfigService.remove(new LambdaQueryWrapper<ReportConfigEntity>().eq(ReportConfigEntity::getReportId, id));
return removeById(id); return removeById(id);
} }
@Override
@Transactional
public Boolean generateReport(ReportDTO reportDTO) {
//处理报表
TemplateEntity template = templateService.getById(reportDTO.getTemplateId());
ReportEntity report = ReportEntity.builder()
.templateId(template.getId())
.name(template.getName())
.lineNumber(template.getLineNumber())
.columnNumber(template.getColumnNumber())
.version(template.getVersion())
.year(reportDTO.getYear())
.month(reportDTO.getMonth())
.day(reportDTO.getDay())
.build();
this.save(report);
//处理报表详情-基础
List<ReportDetailBasicEntity> reportDetailBasicList = new ArrayList<>();
List<TemplateDetailBasicEntity> templateDetailBasicList = templateDetailBasicService.list(new LambdaQueryWrapper<TemplateDetailBasicEntity>()
.eq(TemplateDetailBasicEntity::getTemplateId, template.getId()));
//处理报表详情-复合
List<ReportDetailMergeEntity> reportDetailMergeList = new ArrayList<>();
List<TemplateDetailMergeEntity> templateDetailMergeList = templateDetailMergeService.list(new LambdaQueryWrapper<TemplateDetailMergeEntity>()
.eq(TemplateDetailMergeEntity::getTemplateId, template.getId()));
//处理报表配置
List<ReportConfigEntity> reportConfigList = new ArrayList<>();
List<TemplateConfigEntity> templateConfigList = templateConfigService.list(new LambdaQueryWrapper<TemplateConfigEntity>()
.eq(TemplateConfigEntity::getTemplateId, template.getId()));
for (TemplateConfigEntity templateConfigEntity : templateConfigList) {
reportConfigList.add(ReportConfigEntity.builder()
.templateId(template.getId())
.reportId(report.getId())
.num(templateConfigEntity.getNum())
.type(templateConfigEntity.getType())
.height(templateConfigEntity.getHeight())
.width(templateConfigEntity.getWidth())
.hidden(templateConfigEntity.getHidden())
.build());
}
reportConfigService.saveBatch(reportConfigList);
return Boolean.TRUE;
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment