Commit 07ec99a8 authored by wdy's avatar wdy

Merge branch 'dev' of http://gitlab.91isoft.com:90/wangfei/vehicle-quality-review into wangdingyi

parents 1fb3b15e 2f682d97
......@@ -160,4 +160,9 @@ public class InspectionReportPdfVO {
*/
private String sampleNumberSummary;
/**
* 品牌图片
*/
private String brandImage;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "首页数量统计")
public class QuantityStatisticsVO {
@ApiModelProperty("支持标准数量")
private Long standardQuantity;
@ApiModelProperty("测试用例数量")
private Long numberUseCases;
@ApiModelProperty("任务数量")
private Long numberTasks;
@ApiModelProperty("检验报告数量")
private Long numberReports;
@ApiModelProperty("检验员数量")
private Long numberInspectors;
@ApiModelProperty("车企数量")
private Long numberCompanies;
@ApiModelProperty("整车样品数量")
private Long numberVehicleSamples;
@ApiModelProperty("零部件样品数量")
private Long numberComponentSamples;
@ApiModelProperty("测试方法数量")
private Long numberMethods;
@ApiModelProperty("场景数量")
private Long numberScenes;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "首页标准类别统计")
public class StandardCategoryStatisticsVO {
@ApiModelProperty("类别数量")
private Long value;
@ApiModelProperty("类别名称")
private String name;
}
package com.ruoyi.mapper;
import com.ruoyi.domain.vo.QuantityStatisticsVO;
import com.ruoyi.domain.vo.StandardCategoryStatisticsVO;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface StatisticsHomeMapper {
// 数量统计
public QuantityStatisticsVO selectQuantityStatistics(QuantityStatisticsVO quantityStatisticsHome);
// 标准类别统计
public List<StandardCategoryStatisticsVO> selectStandardCategoryStatistics();
}
package com.ruoyi.service;
import com.ruoyi.domain.vo.QuantityStatisticsVO;
import com.ruoyi.domain.vo.StandardCategoryStatisticsVO;
import java.util.List;
public interface StatisticsHomeService {
// 数量统计
public QuantityStatisticsVO selectQuantityStatistics(QuantityStatisticsVO quantityStatisticsHome);
// 标准类别统计
public List<StandardCategoryStatisticsVO> selectStandardCategoryStatistics();
}
package com.ruoyi.service.impl;
import cn.hutool.core.util.StrUtil;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.*;
import com.ruoyi.common.core.domain.entity.SysDictData;
......@@ -70,26 +71,24 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
ByteArrayOutputStream bos = null;
try {
// 模板绝对路径--服务器
String fileName = "/template/receipt_template_02_27.pdf";
String fileName = "/template/receipt_template_03_27.pdf";
// 读取现有模板内容
reader = new PdfReader(fileName);
// 创建输出流
bos = new ByteArrayOutputStream();
// 实例化PdfStamper准备编辑pdf内容
ps = new PdfStamper(reader, bos);
// 获取表单所有元素
AcroFields fields = ps.getAcroFields();
// 设置具体字体格式的编码, 不设置的话中文可能不会显示
BaseFont bf = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
fields.addSubstitutionFont(bf);
// 测试数据
InspectionReportPdfVO inspectionReportPdfVO = requireData(taskId);
// 渲染数据
renderData(fields, inspectionReportPdfVO);
renderData(fields, inspectionReportPdfVO, ps);
//必须要调用这个,否则文档不会生成的
ps.setFormFlattening(true);
......@@ -106,7 +105,12 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
}
}
assert bos != null;
return uploadMinio(bos, "检验报告_" + taskId);
// 名字
return uploadMinio(bos, "整车信息安全检验报告-" + getReportName());
}
private String getReportName() {
return DateUtils.parseDateToStr("yyyyMMddHHmm", new Date());
}
/**
......@@ -172,7 +176,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
document.close();
// 上传到Minio
return uploadMinio(outputStream, "企业留档文件_" + taskId);
return uploadMinio(outputStream, "企业留档文件-" + getReportName());
}
/**
......@@ -252,8 +256,9 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
* 渲染数据
* @param fields
*/
private void renderData(AcroFields fields, InspectionReportPdfVO inspectionReportPdfVO) throws Exception {
private void renderData(AcroFields fields, InspectionReportPdfVO inspectionReportPdfVO, PdfStamper ps) throws Exception {
// 取出当前对象所有属性,并赋值到模板里
// 文本域
Class<? extends InspectionReportPdfVO> aClass = inspectionReportPdfVO.getClass();
Field[] declaredFields = aClass.getDeclaredFields();
for (Field field : declaredFields) {
......@@ -266,6 +271,15 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
fields.setField(key, value);
}
}
// 图片域
// 样品
String url = inspectionReportPdfVO.getBrandImage();
if (StrUtil.isNotBlank(url)) {
if (url.startsWith(",")) {
url = inspectionReportPdfVO.getBrandImage().substring(1);
}
addImageToPdf("brand", fields, ps, "http://49.232.167.247:22038" + url.split(",")[0]);
}
}
......@@ -314,7 +328,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
// 获取操作的页面
PdfContentByte under = stamper.getOverContent(pageNo);
// 根据域的大小缩放图片
image.scaleToFit(signRect.getWidth() * 2, signRect.getHeight());
image.scaleToFit(signRect.getWidth(), signRect.getHeight());
// 添加图片并设置位置(个人通过此设置使得图片垂直水平居中,可参考,具体情况已实际为准)
image.setAbsolutePosition(x, y);
under.addImage(image);
......
package com.ruoyi.service.impl;
import com.ruoyi.domain.vo.QuantityStatisticsVO;
import com.ruoyi.domain.vo.StandardCategoryStatisticsVO;
import com.ruoyi.mapper.StatisticsHomeMapper;
import com.ruoyi.service.StatisticsHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional
public class StatisticsHomeServiceImpl implements StatisticsHomeService {
@Autowired
private StatisticsHomeMapper statisticsHomeMapper;
@Override
public QuantityStatisticsVO selectQuantityStatistics(QuantityStatisticsVO quantityStatisticsHome){
return statisticsHomeMapper.selectQuantityStatistics(quantityStatisticsHome);
}
@Override
public List<StandardCategoryStatisticsVO> selectStandardCategoryStatistics(){
return statisticsHomeMapper.selectStandardCategoryStatistics();
}
}
package com.ruoyi.web;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.domain.vo.QuantityStatisticsVO;
import com.ruoyi.domain.vo.StandardCategoryStatisticsVO;
import com.ruoyi.service.StatisticsHomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Api(tags = {"首页统计"})
@RestController
@RequestMapping("/home/statistics")
public class StatisticsHomeController {
@Autowired
private StatisticsHomeService statisticsHomeService;
@ApiOperation("首页数量统计")
@PostMapping("/quantityStatistics")
public R<QuantityStatisticsVO> selectQuantityStatistics(@Validated @RequestBody QuantityStatisticsVO quantityStatisticsHome){
return R.ok(statisticsHomeService.selectQuantityStatistics(quantityStatisticsHome));
}
@ApiOperation("首页标准分类占比")
@PostMapping("/standardCategory")
public R<List<StandardCategoryStatisticsVO>> selectStandardCategoryStatistics(){
return R.ok(statisticsHomeService.selectStandardCategoryStatistics());
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mapper.StatisticsHomeMapper">
<select id="selectQuantityStatistics" resultType="com.ruoyi.domain.vo.QuantityStatisticsVO" parameterType="com.ruoyi.domain.vo.QuantityStatisticsVO">
SELECT
( SELECT count( id ) FROM t_standard ) AS standardQuantity,
( SELECT count( id ) FROM t_test_usecase ) AS numberUseCases,
( SELECT count( id ) FROM t_task ) AS numberTasks,
( SELECT count( id ) FROM t_automobile_enterprise WHERE deleted = 0 ) AS numberCompanies,
(
SELECT
count( su.user_id )
FROM
sys_user su
LEFT JOIN sys_user_role sur ON sur.user_id = su.user_id
WHERE
sur.role_id = 106
) AS numberInspectors,
( SELECT count( id ) FROM t_sample WHERE flag = '0' AND deleted = 0 ) AS numberVehicleSamples,
( SELECT count( id ) FROM t_sample WHERE flag = '1' AND deleted = 0 ) AS numberComponentSamples,
( SELECT count( id ) FROM t_test_scenario ) AS numberScenes,
( SELECT count( id ) FROM t_test_type ) AS numberMethods,
( SELECT count( id ) FROM t_task WHERE vehicle_information_url IS NOT NULL ) AS numberReports
</select>
<select id="selectStandardCategoryStatistics" resultType="com.ruoyi.domain.vo.StandardCategoryStatisticsVO">
SELECT
count( id ) AS value,
standard_type AS name
FROM
t_standard
GROUP BY
standard_type
</select>
</mapper>
\ No newline at end of file
......@@ -311,14 +311,15 @@
GROUP_CONCAT(distinct s.sample_sender) AS sampleSender,
GROUP_CONCAT(distinct DATE_FORMAT(s.delivery_date, '%Y-%m-%d')) AS sampleDeliveryDate,
count(s.id) AS sampleQuantity,
sum(s.number_of_samples) AS sampleSum,
CONVERT(sum(s.number_of_samples), UNSIGNED) AS sampleSum,
GROUP_CONCAT(distinct DATE_FORMAT(s.manufacture_date, '%Y-%m-%d')) AS sampleDeliveryDate,
t.product_model AS vehicleType,
t.product_model AS vehicleModel,
t.id AS taskNumber,
GROUP_CONCAT(distinct s.sample_number) AS sampleNumberSummary,
GROUP_CONCAT(distinct s.identification_code) AS vehicleIdentificationNumber,
t.task_list AS inspectionItem,
DATE_FORMAT(t.create_time, '%Y-%m-%d') AS productionDate
DATE_FORMAT(t.create_time, '%Y-%m-%d') AS productionDate,
GROUP_CONCAT(distinct s.trademark) AS brandImage
from
t_task t
left join t_task_sample_relation tsr on t.id = tsr.task_id
......
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