update:修改字段名称,增加导出

This commit is contained in:
zzy
2021-07-15 17:43:19 +08:00
parent 369e1532bc
commit 12fa95cea9
3 changed files with 34 additions and 9 deletions
@@ -9,16 +9,13 @@ import com.adc.da.http.Result;
import com.adc.da.slrs.sarLawsAttrDetailedList.dao.SarLawsAttrDetailedListDao;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.*;
import com.adc.da.slrs.sarLawsAttrDetailedList.service.ISarLawsAttrDetailedListService;
import com.adc.da.slrs.sarStandardsInfo.controller.SarStandardsInfoController;
import com.adc.da.slrs.sarStandardsInfo.dao.SarStandardsInfoDao;
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfoEOPage;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
@@ -99,7 +96,7 @@ public class SarLawsAttrDetailedListController extends BaseController<SarLawsAtt
* date 2021-06-24
**/
@ApiOperation(value = "导出标准信息")
@RequestMapping("/ExportLawsById")
@PostMapping("/ExportLawsById")
public void ExportLawsById(HttpServletResponse response, StandExcelVo standExcelVo){
try {
response.setContentType("application/vnd.ms-excel");
@@ -117,6 +114,30 @@ public class SarLawsAttrDetailedListController extends BaseController<SarLawsAtt
}else {
data=sarLawsAttrDetailedListDao.selectLawsById(standExcelVo.getIds(),null);
}
for (LawsDto lawsDto:data){
if (StringUtils.isNoneBlank(sarLawsAttrDetailedListDao.selectTypeApplicable(lawsDto.getId()).toString())){
lawsDto.setTypeApplicable(sarLawsAttrDetailedListDao.selectTypeApplicable(lawsDto.getId()).toString());
}
}
List<StandExcelDto> standExcelDtos = new ArrayList<>();
for (LawsDto lawsDto:data){
StandExcelDto standExcelDto = StandExcelDto.builder()
.standNumber(lawsDto.getStandNumber())
.standName(lawsDto.getStandName())
.standEnName(lawsDto.getStandEnName())
.typeApplicable(lawsDto.getTypeApplicable())
.NYLX(lawsDto.getNYLX())
.putTime(lawsDto.getPutTime())
.newCarTime(lawsDto.getXCXSSRQGJ())
.nowCarTime(lawsDto.getZCCSSRQGJ())
.ZRBM(lawsDto.getZRBM())
.SYCPX(lawsDto.getSYCPX())
.CYCVPPSBM(lawsDto.getCYCVPPSBM())
.CYCVPPSCN(lawsDto.getCYCVPPSCN())
.KCCVPPSBM(lawsDto.getKCCVPPSBM())
.KCCVPPSCN(lawsDto.getKCCVPPSCN())
.build();
}
EasyExcel.write(response.getOutputStream(), LawsDto.class).autoCloseStream(Boolean.FALSE).sheet("sheet1")
.doWrite(data);
} catch (Exception e) {
@@ -34,9 +34,9 @@ public class LawsDto {
@ApiModelProperty(value = "标准实施日期")
private String putTime;
@ApiModelProperty(value = "新车型实施日期")
private String newCarTime;
private String XCXSSRQGJ;
@ApiModelProperty(value = "在产车实施日期")
private String nowCarTime;
private String ZCCSSRQGJ;
@ApiModelProperty(value = "责任部门")
private String ZRBM;
@ApiModelProperty(value = "适用产品线")
@@ -2,8 +2,10 @@ package com.adc.da.slrs.sarLawsAttrDetailedList.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* //TODO 添加类、接口描述
@@ -14,6 +16,8 @@ import lombok.Data;
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class StandExcelDto {
@ApiModelProperty(value = "标准编号")
private String standNumber;
@@ -22,7 +26,7 @@ public class StandExcelDto {
@ApiModelProperty(value = "英文名称")
private String standEnName;
@ApiModelProperty(value = "适用车型")
private String[] typeApplicable;
private String typeApplicable;
@ApiModelProperty(value = "能源类型")
private String NYLX;
@ApiModelProperty(value = "标准实施日期")