预警excel导出 数据与表格对应

This commit is contained in:
zhaokaiyao@91isoft.com
2021-12-10 15:38:41 +08:00
parent 13b5444e24
commit c783f40d41
7 changed files with 80 additions and 23 deletions
@@ -9,6 +9,7 @@ import com.adc.da.slrs.sarStandIssueControlProduct.entity.StandIssueControlProdu
import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
import com.adc.da.slrs.sarStandWarning.entity.StandWarningEO;
import com.adc.da.slrs.sarStandWarning.entity.WarningExcelVO;
import com.adc.da.slrs.sarStandWarning.entity.WarningExportVO;
import com.adc.da.slrs.sarStandWarning.service.Impl.EarlyWarningEOServiceImpl;
import com.alibaba.excel.EasyExcel;
@@ -148,11 +149,11 @@ public class EarlyWarningEOController extends BaseController<EarlyWarningEO> {
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
// List<StandWarningEO> exportExcel = earlyWarningEOService.getExportExcel(excelVO);
List<StandWarningEO> exportExcel = earlyWarningEOService.getExportExcel(excelVO);
List<WarningExportVO> exportExcel = earlyWarningEOService.getExportExcel(excelVO);
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), StandWarningEO.class).autoCloseStream(Boolean.FALSE).sheet("sheet1")
EasyExcel.write(response.getOutputStream(), WarningExportVO.class).autoCloseStream(Boolean.FALSE).sheet("sheet1")
.doWrite(exportExcel);
} catch (Exception e) {
System.out.println(e);
@@ -3,6 +3,7 @@ package com.adc.da.slrs.sarStandWarning.dao;
import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
import com.adc.da.slrs.sarStandWarning.entity.StandWarningEO;
import com.adc.da.slrs.sarStandWarning.entity.WarningExportVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
@@ -14,6 +15,6 @@ public interface EarlyWarningEODao extends BaseMapper<EarlyWarningEO> {
IPage<StandWarningEO> selectWarningPage(IPage<StandWarningEO> page, @Param("waringEO") StandWarningEO warningEO);
List<StandWarningEO> exportWarning(@Param("idList") List<String> ids);
List<WarningExportVO> exportWarning(@Param("idList") List<String> ids);
}
@@ -47,17 +47,17 @@ public class EarlyWarningEO extends BaseEntity {
@TableField(exist = false)
private String standType;
@ExcelProperty("标准号")
@ExcelProperty(value = "标准号",index = 1)
@ApiModelProperty("标准号")
@TableField(exist = false)
private String standCode;
@ExcelProperty("标准名称")
@ExcelProperty(value = "标准名称",index = 2)
@ApiModelProperty("标准名称")
@TableField(exist = false)
private String standName;
@ExcelProperty("发布日期")
@ExcelProperty(value = "发布日期",index = 5)
@ApiModelProperty("发布日期")
@TableField(exist = false)
@DateTimeFormat(pattern="yyyy-MM-dd")
@@ -67,12 +67,12 @@ public class EarlyWarningEO extends BaseEntity {
@TableField(exist = false)
private Date lastTime;
@ExcelProperty("适用车型")
@ExcelIgnore
@ApiModelProperty("适用车型")
@TableField(exist = false)
private String applyType;
@ExcelProperty("责任工程师")
@ExcelIgnore
@ApiModelProperty("责任工程师")
@TableField(exist = false)
private String dutyEngineer;
@@ -82,12 +82,12 @@ public class EarlyWarningEO extends BaseEntity {
@TableField(exist = false)
private String itemsId;
@ExcelProperty("条款(分解单)编号")
@ExcelProperty(value = "条款(分解单)编号",index = 3)
@ApiModelProperty("条款(分解单)编号")
@TableField(exist = false)
private String itemsNum;
@ExcelProperty("条款(分解单)名称")
@ExcelProperty(value = "条款(分解单)名称",index = 4)
@ApiModelProperty("条款(分解单)名称")
@TableField(exist = false)
private String itemsName;
@@ -0,0 +1,35 @@
package com.adc.da.slrs.sarStandWarning.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class WarningExportVO extends EarlyWarningEO {
@ExcelProperty(value = "实施日期",index = 6)
@ApiModelProperty("标准号")
private String SSRQ;
@ExcelProperty(value = "新车型实施日期",index = 7)
@ApiModelProperty("新车型实施日期")
private String XCXSSRQ;
@ExcelProperty(value = "在产车实施日期",index = 8)
@ApiModelProperty("在产车实施日期")
private String ZCCSSRQ;
@ExcelProperty(value = "标准类别",index = 0)
@ApiModelProperty("标准类别显示")
private String standTypeShow;
@ExcelProperty(value = "适用车型",index = 9)
@ApiModelProperty("适用车型展示")
private String applyTypeShow;
}
@@ -4,6 +4,7 @@ package com.adc.da.slrs.sarStandWarning.service;
import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
import com.adc.da.slrs.sarStandWarning.entity.StandWarningEO;
import com.adc.da.slrs.sarStandWarning.entity.WarningExcelVO;
import com.adc.da.slrs.sarStandWarning.entity.WarningExportVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -22,5 +23,5 @@ public interface EarlyWarningEOService extends IService<EarlyWarningEO> {
IPage<StandWarningEO> getStandWarning(StandWarningEO queryPage);
List<StandWarningEO> getExportExcel(WarningExcelVO excelVO);
List<WarningExportVO> getExportExcel(WarningExcelVO excelVO);
}
@@ -5,6 +5,7 @@ import com.adc.da.slrs.sarStandWarning.dao.EarlyWarningEODao;
import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
import com.adc.da.slrs.sarStandWarning.entity.StandWarningEO;
import com.adc.da.slrs.sarStandWarning.entity.WarningExcelVO;
import com.adc.da.slrs.sarStandWarning.entity.WarningExportVO;
import com.adc.da.slrs.sarStandWarning.service.EarlyWarningEOService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -120,8 +121,8 @@ public class EarlyWarningEOServiceImpl extends ServiceImpl<EarlyWarningEODao, Ea
* @return
*/
@Override
public List<StandWarningEO> getExportExcel(WarningExcelVO excelVO){
List<StandWarningEO> standWarningEOList = earlyWarningEODao.exportWarning( excelVO.getIds());
public List<WarningExportVO> getExportExcel(WarningExcelVO excelVO){
List<WarningExportVO> standWarningEOList = earlyWarningEODao.exportWarning( excelVO.getIds());
// IPage<StandWarningEO> standWarningEOIPage = earlyWarningEODao.selectWarningPage(null, null, null);
return standWarningEOList;
@@ -38,8 +38,6 @@
<sql id="stand_where">
<if test="waringEO.standCode != null and waringEO.standCode != ''">
AND trim(replace(CONCAT(
sarInfo.STAND_SORT,
@@ -74,18 +72,35 @@
)
</if>
</sql>
<select id="exportWarning" resultType="com.adc.da.slrs.sarStandWarning.entity.StandWarningEO">
<sql id="export_column">
warning.id AS ID,
sarInfo.ID AS STAND_ID,
sarInfo.STAND_TYPE,
CONCAT(sarInfo.STAND_SORT,' ',sarInfo.STAND_NUMBER,'-',sarInfo.STAND_YEAR) AS STAND_CODE,
sarInfo.STAND_NAME,
sarInfo.PUT_TIME,
attr.SSRQ as SSRQ,
case stand_type
when 'INLAND' then '国内标准'
when 'FOREIGN' then '国外标准'
ELSE ''
END
as standTypeShow
</sql>
<select id="exportWarning" resultType="com.adc.da.slrs.sarStandWarning.entity.WarningExportVO">
SELECT WARNING_RESULT.* FROM
(
SELECT
<include refid="stand_column"/>
,
attr.CLLX AS
APPLY_TYPE ,
attr
.ZRGCS AS DUTY_ENGINEER ,
<include refid="export_column"/> ,
dicType.DIC_TYPE_NAME AS applyTypeShow,
attr.CLLX AS APPLY_TYPE ,
attr.ZRGCS AS DUTY_ENGINEER ,
NULL AS ITEMS_ID ,
NULL AS ITEMS_NUM , NULL AS ITEMS_NAME ,
NULL AS POLICY_ID ,
@@ -97,6 +112,7 @@
FROM sar_stand_warning AS warning
LEFT JOIN sar_standards_info AS sarInfo on sarInfo.id=warning.STAND_ID
LEFT JOIN sar_stand_attr_info AS attr on attr.STAND_ID=warning.STAND_ID
LEFT JOIN ts_dictype as dicType on dicType.DIC_TYPE_CODE =attr.CLLX
<where>
POWER = '1'
AND (MARK = 'stand')
@@ -116,7 +132,8 @@
UNION ALL
SELECT
<include refid="stand_column"/> ,
<include refid="export_column"/> ,
dicType.DIC_TYPE_NAME AS applyTypeShow,
items.APPLY_ARCTIC AS APPLY_TYPE ,
items.DUTY_ENGINEER AS DUTY_ENGINEER ,
items.ID AS ITEMS_ID ,
@@ -133,6 +150,7 @@
LEFT JOIN sar_standards_info AS sarInfo ON sarInfo.id = warning.STAND_ID
LEFT JOIN sar_stand_items AS items ON items.STAND_ID = warning.STAND_ID
LEFT JOIN sar_stand_attr_info AS attr ON attr.STAND_ID = warning.STAND_ID
LEFT JOIN ts_dictype as dicType on dicType.DIC_TYPE_CODE =items.APPLY_ARCTIC
<where>
POWER = '1'
AND (MARK = 'item')