预警导出
This commit is contained in:
+40
@@ -4,10 +4,15 @@ package com.adc.da.slrs.sarStandWarning.controller;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.sarStandIssueControlProduct.entity.SarStandIssueControlProduct;
|
||||
import com.adc.da.slrs.sarStandIssueControlProduct.entity.StandIssueControlProductExcelVO;
|
||||
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.service.Impl.EarlyWarningEOServiceImpl;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -17,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -113,4 +120,37 @@ public class EarlyWarningEOController extends BaseController<EarlyWarningEO> {
|
||||
return Result.success("200",listMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/exprotWarning")
|
||||
@ApiOperation("导出预警")
|
||||
public void exportStandardsInfoExcel(WarningExcelVO excelVO, HttpServletResponse response) throws Exception {
|
||||
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
|
||||
try {
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
||||
if(excelVO.getExportName()==null){
|
||||
excelVO.setExportName("标准预警");
|
||||
}
|
||||
String fileName = URLEncoder.encode(excelVO.getExportName(), "UTF-8").replaceAll("\\+", "%20");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
|
||||
List<StandWarningEO> exportExcel = earlyWarningEOService.getExportExcel(excelVO);
|
||||
|
||||
|
||||
// 这里需要设置不关闭流
|
||||
EasyExcel.write(response.getOutputStream(), SarStandIssueControlProduct.class).autoCloseStream(Boolean.FALSE).sheet("sheet1")
|
||||
.doWrite(exportExcel);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
// 重置response
|
||||
response.reset();
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.getWriter().println(JSON.toJSONString(Result.error()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -7,8 +7,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EarlyWarningEODao extends BaseMapper<EarlyWarningEO> {
|
||||
|
||||
IPage<StandWarningEO> selectWarningPage(IPage<StandWarningEO> page, @Param("waringEO") StandWarningEO warningEO);
|
||||
IPage<StandWarningEO> selectWarningPage(IPage<StandWarningEO> page, @Param("waringEO") StandWarningEO warningEO,@Param("idList") List<String> ids);
|
||||
|
||||
}
|
||||
|
||||
+18
-1
@@ -1,6 +1,8 @@
|
||||
package com.adc.da.slrs.sarStandWarning.entity;
|
||||
|
||||
import com.adc.da.base.entity.BaseEntity;
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -25,64 +27,79 @@ public class EarlyWarningEO extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("id")
|
||||
@TableId("ID")
|
||||
private String id;
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("标准id")
|
||||
@TableField("STAND_ID")
|
||||
private String standId;
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("标准类别")
|
||||
@TableField(exist = false)
|
||||
private String standType;
|
||||
|
||||
@ExcelProperty("标准号")
|
||||
@ApiModelProperty("标准号")
|
||||
@TableField(exist = false)
|
||||
private String standCode;
|
||||
|
||||
@ExcelProperty("标准名称")
|
||||
@ApiModelProperty("标准名称")
|
||||
@TableField(exist = false)
|
||||
private String standName;
|
||||
|
||||
@ExcelProperty("发布日期")
|
||||
@ApiModelProperty("发布日期")
|
||||
@TableField(exist = false)
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
private Date putTime;
|
||||
|
||||
@ExcelIgnore
|
||||
@TableField(exist = false)
|
||||
private Date lastTime;
|
||||
|
||||
@ExcelProperty("适用车型")
|
||||
@ApiModelProperty("适用车型")
|
||||
@TableField(exist = false)
|
||||
private String applyType;
|
||||
|
||||
@ExcelProperty("责任工程师")
|
||||
@ApiModelProperty("责任工程师")
|
||||
@TableField(exist = false)
|
||||
private String dutyEngineer;
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("条款(分解单)id")
|
||||
@TableField(exist = false)
|
||||
private String itemsId;
|
||||
|
||||
@ExcelProperty("条款(分解单)编号")
|
||||
@ApiModelProperty("条款(分解单)编号")
|
||||
@TableField(exist = false)
|
||||
private String itemsNum;
|
||||
|
||||
@ExcelProperty("条款(分解单)名称")
|
||||
@ApiModelProperty("条款(分解单)名称")
|
||||
@TableField(exist = false)
|
||||
private String itemsName;
|
||||
|
||||
@ExcelIgnore
|
||||
@TableField("POLICY_ID")
|
||||
private String policyId;
|
||||
|
||||
@ExcelIgnore
|
||||
@TableField(exist = false)
|
||||
private String policyName;
|
||||
|
||||
|
||||
@ExcelIgnore
|
||||
@TableField("MARK")
|
||||
private String mark;
|
||||
|
||||
@ExcelIgnore
|
||||
@TableField("POWER")
|
||||
private String power;
|
||||
|
||||
|
||||
+20
-1
@@ -1,5 +1,7 @@
|
||||
package com.adc.da.slrs.sarStandWarning.entity;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -11,62 +13,79 @@ import java.util.Date;
|
||||
@Accessors(chain = true)
|
||||
public class StandWarningEO extends EarlyWarningEO {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ExcelProperty("新车型实施日期")
|
||||
@ApiModelProperty("新车型实施日期")
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private String XCXSSRQ;
|
||||
|
||||
@ExcelProperty("在产车实施日期")
|
||||
@ApiModelProperty("在产车实施日期")
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private String ZCCSSRQ;
|
||||
|
||||
@ExcelProperty("实施日期")
|
||||
@ApiModelProperty("实施日期")
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private String SSRQ;
|
||||
|
||||
|
||||
@ExcelProperty("标准编号")
|
||||
private String standNum;
|
||||
|
||||
@ExcelProperty("标准类别")
|
||||
private String standSort;
|
||||
|
||||
@ExcelProperty("标准年份")
|
||||
private String standYear;
|
||||
|
||||
@ExcelProperty("发布日期")
|
||||
private String issueTime;
|
||||
|
||||
@ExcelIgnore
|
||||
private Integer page;
|
||||
|
||||
@ExcelIgnore
|
||||
private Integer pageSize;
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("范围查询新车型实施日期开始")
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private String startXCXSSRQ;
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("范围查询新车型实施日期结束")
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private String endXCXSSRQ;
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("范围查询在产车实施日期开始")
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private String startZCCSSRQ;
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("范围查询在产车实施日期结束")
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private String endZCCSSRQ;
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("范围查询实施日期开始")
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private String startSSRQ;
|
||||
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("范围查询实施日期结束")
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private String endSSRQ;
|
||||
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("范围查询发布日期开始")
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private String startPutTime;
|
||||
|
||||
|
||||
@ExcelIgnore
|
||||
@ApiModelProperty("范围查询发布日期结束")
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private String endPutTime;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.adc.da.slrs.sarStandWarning.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class WarningExcelVO {
|
||||
@ApiModelProperty("文件名")
|
||||
String exportName;
|
||||
@ApiModelProperty("导出的ID列表")
|
||||
List<String> ids;
|
||||
}
|
||||
+3
@@ -3,6 +3,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.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -20,4 +21,6 @@ public interface EarlyWarningEOService extends IService<EarlyWarningEO> {
|
||||
|
||||
|
||||
IPage<StandWarningEO> getStandWarning(StandWarningEO queryPage);
|
||||
|
||||
List<StandWarningEO> getExportExcel(WarningExcelVO excelVO);
|
||||
}
|
||||
|
||||
+13
-1
@@ -4,6 +4,7 @@ package com.adc.da.slrs.sarStandWarning.service.Impl;
|
||||
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.service.EarlyWarningEOService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -111,9 +112,20 @@ public class EarlyWarningEOServiceImpl extends ServiceImpl<EarlyWarningEODao, Ea
|
||||
@Override
|
||||
public IPage<StandWarningEO> getStandWarning(StandWarningEO queryPage) {
|
||||
IPage<StandWarningEO> iPage = new Page<>(queryPage.getPage(),queryPage.getPageSize());
|
||||
return earlyWarningEODao.selectWarningPage(iPage,queryPage);
|
||||
return earlyWarningEODao.selectWarningPage(iPage,queryPage,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出预警
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StandWarningEO> getExportExcel(WarningExcelVO excelVO){
|
||||
IPage<StandWarningEO> standWarningEOIPage = earlyWarningEODao.selectWarningPage(null, null, excelVO.getIds());
|
||||
return standWarningEOIPage.getRecords();
|
||||
}
|
||||
|
||||
|
||||
private IPage<EarlyWarningEO> getEarlyWarningEOIPage(int current,int pageSize, QueryWrapper<EarlyWarningEO> wrapper) {
|
||||
wrapper.eq("power",1);
|
||||
Page<EarlyWarningEO> page = new Page<>(current, pageSize);
|
||||
|
||||
+44
-33
@@ -37,40 +37,51 @@
|
||||
|
||||
|
||||
<sql id="stand_where">
|
||||
<if test="waringEO.standCode != null and waringEO.standCode != ''">
|
||||
AND trim(replace(CONCAT(
|
||||
sarInfo.STAND_SORT,
|
||||
' ',
|
||||
sarInfo.STAND_NUMBER,
|
||||
'-',
|
||||
sarInfo.STAND_YEAR
|
||||
),' ','')) LIKE trim(replace(CONCAT('%',#{waringEO.standCode},'%'),' ',''))
|
||||
</if>
|
||||
<if test="waringEO.standName != null and waringEO.standName != ''">
|
||||
AND sarInfo.STAND_NAME like concat('%', #{waringEO.standName},'%')
|
||||
</if>
|
||||
<if test="waringEO.startPutTime != null and waringEO.startPutTime != '' and waringEO.endPutTime != null and waringEO.endPutTime != '' ">
|
||||
AND (
|
||||
DATE_FORMAT(sarInfo.PUT_TIME, '%Y-%m-%d') >= DATE_FORMAT(
|
||||
#{waringEO.endPutTime},
|
||||
'%Y-%m-%d'
|
||||
)
|
||||
|
||||
AND
|
||||
DATE_FORMAT( sarInfo.PUT_TIME, '%Y-%m-%d') <= DATE_FORMAT(
|
||||
#{waringEO.endPutTime},
|
||||
'%Y-%m-%d'
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="waringEO.startSSRQ != null and waringEO.startSSRQ != '' and waringEO.endSSRQ != null and waringEO.endSSRQ != ''">
|
||||
AND (
|
||||
sarInfo.ID IN (SELECT DISTINCT law_id FROM warning_date as t WHERE
|
||||
DATE_FORMAT(t.SSRQ, '%Y-%m-%d') >= DATE_FORMAT(#{waringEO.startSSRQ}, '%Y-%m-%d')
|
||||
AND
|
||||
DATE_FORMAT(t.SSRQ, '%Y-%m-%d') <= DATE_FORMAT(#{waringEO.endSSRQ}, '%Y-%m-%d') AND t.time_name = 'SSRQ' )
|
||||
)
|
||||
</if>
|
||||
<if test="idList != null and idList.size() > 0">
|
||||
|
||||
warning.ID
|
||||
IN
|
||||
<foreach collection="idList" item="id" open="and (" close=")" separator=",">
|
||||
<!-- 每个遍历需要生成的串 -->
|
||||
#{id}
|
||||
</foreach>
|
||||
|
||||
</if>
|
||||
|
||||
<if test="waringEO.standCode != null and waringEO.standCode != ''">
|
||||
AND trim(replace(CONCAT(
|
||||
sarInfo.STAND_SORT,
|
||||
' ',
|
||||
sarInfo.STAND_NUMBER,
|
||||
'-',
|
||||
sarInfo.STAND_YEAR
|
||||
),' ','')) LIKE trim(replace(CONCAT('%',#{waringEO.standCode},'%'),' ',''))
|
||||
</if>
|
||||
<if test="waringEO.standName != null and waringEO.standName != ''">
|
||||
AND sarInfo.STAND_NAME like concat('%', #{waringEO.standName},'%')
|
||||
</if>
|
||||
<if test="waringEO.startPutTime != null and waringEO.startPutTime != '' and waringEO.endPutTime != null and waringEO.endPutTime != '' ">
|
||||
AND (
|
||||
DATE_FORMAT(sarInfo.PUT_TIME, '%Y-%m-%d') >= DATE_FORMAT(
|
||||
#{waringEO.endPutTime},
|
||||
'%Y-%m-%d'
|
||||
)
|
||||
AND
|
||||
DATE_FORMAT( sarInfo.PUT_TIME, '%Y-%m-%d') <= DATE_FORMAT(
|
||||
#{waringEO.endPutTime},
|
||||
'%Y-%m-%d'
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="waringEO.startSSRQ != null and waringEO.startSSRQ != '' and waringEO.endSSRQ != null and waringEO.endSSRQ != ''">
|
||||
AND (
|
||||
sarInfo.ID IN (SELECT DISTINCT law_id FROM warning_date as t WHERE
|
||||
DATE_FORMAT(t.SSRQ, '%Y-%m-%d') >= DATE_FORMAT(#{waringEO.startSSRQ}, '%Y-%m-%d')
|
||||
AND
|
||||
DATE_FORMAT(t.SSRQ, '%Y-%m-%d') <= DATE_FORMAT(#{waringEO.endSSRQ}, '%Y-%m-%d') AND t.time_name = 'SSRQ' )
|
||||
)
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectWarningPage" resultMap="resultMap">
|
||||
|
||||
Reference in New Issue
Block a user