汇总记录,导出excel

master
wangwei 2 years ago
parent c68cb845a0
commit 1e57b7ca4f

@ -46,8 +46,9 @@ public class ApiExcelController {
* @param response
*/
@GetMapping("/udiwms/inv/excelExportOut")
public void export(HttpServletResponse response,String billNo) {
excelService.excelExport(response,billNo);
public void export(HttpServletResponse response,String billNo,String key) {
excelService.excelExport(response,billNo,key);
}
/**

@ -18,4 +18,6 @@ public interface IoStatMonthDao extends BaseMapper<IoStatMonthEntity> {
* @return
*/
List<IoStatMonthEntity> filterList(FilterStatDataDetailRequest statDataDetailRequest);
}
List<IoStatMonthEntity> filterListByRecordKey(String recordKey);
}

@ -18,4 +18,6 @@ public interface IoStatQuarterDao extends BaseMapper<IoStatQuarterEntity> {
* @return
*/
List<IoStatQuarterEntity> filterList(FilterStatDataDetailRequest statDataDetailRequest);
}
List<IoStatQuarterEntity> filterListByRecordKey(String recordKey);
}

@ -18,4 +18,6 @@ public interface IoStatYearDao extends BaseMapper<IoStatYearEntity> {
* @return
*/
List<IoStatYearEntity> filterList(FilterStatDataDetailRequest statDataDetailRequest);
}
List<IoStatYearEntity> filterListByRecordKey(String recordKey);
}

@ -18,83 +18,68 @@ import java.math.BigDecimal;
@ApiModel(value = "导出实体")
public class ExcelVO {
@ColumnWidth(80)
@ExcelProperty("序号")
@ApiModelProperty(value = "序号")
private Integer id;
@ColumnWidth(80)
@ExcelProperty("产品通用名")
@ApiModelProperty(value = "产品通用名")
private String productName;
@ColumnWidth(80)
@ExcelProperty("规格型号")
@ApiModelProperty(value = "规格型号")
private String ggxh;
@ColumnWidth(80)
@ExcelProperty("批次号")
@ApiModelProperty(value = "批次号")
private String batchNo;
@ColumnWidth(80)
@ExcelProperty("数量")
@ExcelProperty({"期初","数量"})
@ApiModelProperty(value = "数量")
private Integer beginCount;
@ColumnWidth(80)
@ExcelProperty("价格")
@ExcelProperty({"期初","价格"})
@ApiModelProperty(value = "价格")
private BigDecimal beginPrice;
@ColumnWidth(80)
@ExcelProperty("金额")
@ExcelProperty({"期初","金额"})
@ApiModelProperty(value = "金额")
private BigDecimal beginAmount;
@ColumnWidth(80)
@ExcelProperty("数量")
@ExcelProperty({"入库","数量"})
@ApiModelProperty(value = "数量")
private Integer inCount;
@ColumnWidth(80)
@ExcelProperty("价格")
@ExcelProperty({"入库","价格"})
@ApiModelProperty(value = "价格")
private BigDecimal inPrice;
@ColumnWidth(80)
@ExcelProperty("金额")
@ExcelProperty({"入库","金额"})
@ApiModelProperty(value = "金额")
private BigDecimal inAmount;
@ColumnWidth(80)
@ExcelProperty("数量")
@ExcelProperty({"出库","数量"})
@ApiModelProperty(value = "数量")
private Integer outCount;
@ColumnWidth(80)
@ExcelProperty("价格")
@ExcelProperty({"出库","价格"})
@ApiModelProperty(value = "价格")
private BigDecimal outPrice;
@ColumnWidth(80)
@ExcelProperty("金额")
@ExcelProperty({"出库","金额"})
@ApiModelProperty(value = "金额")
private BigDecimal outAmount;
@ColumnWidth(80)
@ExcelProperty("数量")
@ExcelProperty({"结余","数量"})
@ApiModelProperty(value = "数量")
private Integer balanceCount;
@ColumnWidth(80)
@ExcelProperty("价格")
@ExcelProperty({"结余","价格"})
@ApiModelProperty(value = "价格")
private BigDecimal balancePrice;
@ColumnWidth(80)
@ExcelProperty("金额")
@ExcelProperty({"结余","金额"})
@ApiModelProperty(value = "金额")
private BigDecimal balanceAmount;

@ -65,4 +65,4 @@ public class SysPdfTemplateRelevanceCodeEntity {
@TableField(value = "updateTime")
private Date updateTime;
}
}

@ -30,7 +30,7 @@ public interface ExcelService {
*
* @param response
*/
void excelExport(HttpServletResponse response,String billNo);
void excelExport(HttpServletResponse response,String billNo,String key);
/**
* excel-sheet

@ -25,4 +25,6 @@ public interface IoStatMonthService {
* @return
*/
List<IoStatMonthEntity> filterList(FilterStatDataDetailRequest statDataDetailRequest);
List<IoStatMonthEntity> filterListByRecordKey(String recordKey);
}

@ -26,4 +26,6 @@ public interface IoStatQuarterService {
*/
List<IoStatQuarterEntity> filterList(FilterStatDataDetailRequest statDataDetailRequest);
List<IoStatQuarterEntity> filterListByRecordKey(String recordKey);
}

@ -25,4 +25,7 @@ public interface IoStatYearService {
* @return
*/
List<IoStatYearEntity> filterList(FilterStatDataDetailRequest statDataDetailRequest);
List<IoStatYearEntity> filterListByRecordKey(String recordKey);
}

@ -9,11 +9,9 @@ package com.glxp.api.service.inout.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.glxp.api.entity.inout.ExcelVO;
import com.glxp.api.entity.inout.IoStatDayEntity;
import com.glxp.api.entity.inout.*;
import com.glxp.api.req.inout.FilterStatDataDetailRequest;
import com.glxp.api.service.inout.ExcelService;
import com.glxp.api.service.inout.IoStatDayService;
import com.glxp.api.service.inout.*;
import com.glxp.api.util.Excel.ExcelHandler;
import com.glxp.api.util.Excel.ExcelTemplateEnum;
import com.glxp.api.util.Excel.Exception.RenException;
@ -37,6 +35,14 @@ public class ExcelServiceImpl implements ExcelService {
@Resource
private IoStatDayService statDayService;
@Resource
private IoStatMonthService statMonthService;
@Resource
private IoStatQuarterService statQuarterService;
@Resource
private IoStatYearService statYearService;
/**
* excel-sheet
@ -65,9 +71,9 @@ public class ExcelServiceImpl implements ExcelService {
* @param response
*/
@Override
public void excelExport(HttpServletResponse response, String billNo) {
public void excelExport(HttpServletResponse response, String billNo,String key) {
try {
List<ExcelVO> excelVOS = structureDate(billNo);
List<ExcelVO> excelVOS = structureDate(billNo,key);
excelHandler.exportExcel(response, excelVOS, ExcelVO.class, "excel导出-单et", "excel导出heet");
} catch (Exception e) {
throw new RenException("导出失败");
@ -181,43 +187,98 @@ public class ExcelServiceImpl implements ExcelService {
*
* @return
*/
private List<ExcelVO> structureDate(String billNo) {
private List<ExcelVO> structureDate(String billNo ,String key) {
List<ExcelVO> list = new ArrayList<>();
if("day".equals(key)){
List<IoStatDayEntity> ioStatDayEntities = statDayService.filterListByRecordKey(billNo);
for (int i=0; i < ioStatDayEntities.size(); i++) {
ExcelVO vo = new ExcelVO();
vo.setId(i+1);
vo.setProductName(ioStatDayEntities.get(i).getProductName());
vo.setGgxh(ioStatDayEntities.get(i).getGgxh());
vo.setBatchNo(ioStatDayEntities.get(i).getBatchNo());
vo.setBeginCount(ioStatDayEntities.get(i).getBeginCount());
vo.setBeginPrice(ioStatDayEntities.get(i).getBeginPrice());
vo.setBeginAmount(ioStatDayEntities.get(i).getBeginAmount());
vo.setInCount(ioStatDayEntities.get(i).getInCount());
vo.setInPrice(ioStatDayEntities.get(i).getInPrice());
vo.setInAmount(ioStatDayEntities.get(i).getInAmount());
vo.setOutCount(ioStatDayEntities.get(i).getOutCount());
vo.setOutPrice(ioStatDayEntities.get(i).getOutPrice());
vo.setOutAmount(ioStatDayEntities.get(i).getOutAmount());
vo.setBalanceCount(ioStatDayEntities.get(i).getBalanceCount());
vo.setBalancePrice(ioStatDayEntities.get(i).getBalancePrice());
vo.setBalanceAmount(ioStatDayEntities.get(i).getBalanceAmount());
list.add(vo);
}
}else if("month".equals(key)){
List<IoStatMonthEntity> ioStatMonthEntities = statMonthService.filterListByRecordKey(billNo);
for (int i=0; i < ioStatMonthEntities.size(); i++) {
ExcelVO vo = new ExcelVO();
vo.setId(i+1);
vo.setProductName(ioStatMonthEntities.get(i).getProductName());
vo.setGgxh(ioStatMonthEntities.get(i).getGgxh());
vo.setBatchNo(ioStatMonthEntities.get(i).getBatchNo());
vo.setBeginCount(ioStatMonthEntities.get(i).getBeginCount());
vo.setBeginPrice(ioStatMonthEntities.get(i).getBeginPrice());
vo.setBeginAmount(ioStatMonthEntities.get(i).getBeginAmount());
vo.setInCount(ioStatMonthEntities.get(i).getInCount());
vo.setInPrice(ioStatMonthEntities.get(i).getInPrice());
vo.setInAmount(ioStatMonthEntities.get(i).getInAmount());
vo.setOutCount(ioStatMonthEntities.get(i).getOutCount());
vo.setOutPrice(ioStatMonthEntities.get(i).getOutPrice());
vo.setOutAmount(ioStatMonthEntities.get(i).getOutAmount());
vo.setBalanceCount(ioStatMonthEntities.get(i).getBalanceCount());
vo.setBalancePrice(ioStatMonthEntities.get(i).getBalancePrice());
vo.setBalanceAmount(ioStatMonthEntities.get(i).getBalanceAmount());
list.add(vo);
}
}else if("quarter".equals(key)){
List<IoStatQuarterEntity> ioStatQuarterEntities = statQuarterService.filterListByRecordKey(billNo);
for (int i=0; i < ioStatQuarterEntities.size(); i++) {
ExcelVO vo = new ExcelVO();
vo.setId(i+1);
vo.setProductName(ioStatQuarterEntities.get(i).getProductName());
vo.setGgxh(ioStatQuarterEntities.get(i).getGgxh());
vo.setBatchNo(ioStatQuarterEntities.get(i).getBatchNo());
vo.setBeginCount(ioStatQuarterEntities.get(i).getBeginCount());
vo.setBeginPrice(ioStatQuarterEntities.get(i).getBeginPrice());
vo.setBeginAmount(ioStatQuarterEntities.get(i).getBeginAmount());
vo.setInCount(ioStatQuarterEntities.get(i).getInCount());
vo.setInPrice(ioStatQuarterEntities.get(i).getInPrice());
vo.setInAmount(ioStatQuarterEntities.get(i).getInAmount());
vo.setOutCount(ioStatQuarterEntities.get(i).getOutCount());
vo.setOutPrice(ioStatQuarterEntities.get(i).getOutPrice());
vo.setOutAmount(ioStatQuarterEntities.get(i).getOutAmount());
vo.setBalanceCount(ioStatQuarterEntities.get(i).getBalanceCount());
vo.setBalancePrice(ioStatQuarterEntities.get(i).getBalancePrice());
vo.setBalanceAmount(ioStatQuarterEntities.get(i).getBalanceAmount());
list.add(vo);
}
}else{
List<IoStatYearEntity> ioStatYearEntities = statYearService.filterListByRecordKey(billNo);
for (int i=0; i < ioStatYearEntities.size(); i++) {
ExcelVO vo = new ExcelVO();
vo.setId(i+1);
vo.setProductName(ioStatYearEntities.get(i).getProductName());
vo.setGgxh(ioStatYearEntities.get(i).getGgxh());
vo.setBatchNo(ioStatYearEntities.get(i).getBatchNo());
vo.setBeginCount(ioStatYearEntities.get(i).getBeginCount());
vo.setBeginPrice(ioStatYearEntities.get(i).getBeginPrice());
vo.setBeginAmount(ioStatYearEntities.get(i).getBeginAmount());
vo.setInCount(ioStatYearEntities.get(i).getInCount());
vo.setInPrice(ioStatYearEntities.get(i).getInPrice());
vo.setInAmount(ioStatYearEntities.get(i).getInAmount());
vo.setOutCount(ioStatYearEntities.get(i).getOutCount());
vo.setOutPrice(ioStatYearEntities.get(i).getOutPrice());
vo.setOutAmount(ioStatYearEntities.get(i).getOutAmount());
vo.setBalanceCount(ioStatYearEntities.get(i).getBalanceCount());
vo.setBalancePrice(ioStatYearEntities.get(i).getBalancePrice());
vo.setBalanceAmount(ioStatYearEntities.get(i).getBalanceAmount());
list.add(vo);
}
List<IoStatDayEntity> ioStatDayEntities = statDayService.filterListByRecordKey(billNo);
ExcelVO vo = new ExcelVO();
for (int i=0; i < ioStatDayEntities.size(); i++) {
vo.setId(i+1);
vo.setProductName(ioStatDayEntities.get(i).getProductName());
vo.setGgxh(ioStatDayEntities.get(i).getGgxh());
vo.setBatchNo(ioStatDayEntities.get(i).getBatchNo());
vo.setBeginCount(ioStatDayEntities.get(i).getBeginCount());
vo.setBeginPrice(ioStatDayEntities.get(i).getBeginPrice());
vo.setBeginAmount(ioStatDayEntities.get(i).getBeginAmount());
vo.setInCount(ioStatDayEntities.get(i).getInCount());
vo.setInPrice(ioStatDayEntities.get(i).getInPrice());
vo.setInAmount(ioStatDayEntities.get(i).getInAmount());
vo.setOutCount(ioStatDayEntities.get(i).getOutCount());
vo.setOutPrice(ioStatDayEntities.get(i).getOutPrice());
vo.setOutAmount(ioStatDayEntities.get(i).getOutAmount());
vo.setBalanceCount(ioStatDayEntities.get(i).getBalanceCount());
vo.setBalancePrice(ioStatDayEntities.get(i).getBalancePrice());
vo.setBalanceAmount(ioStatDayEntities.get(i).getBalanceAmount());
list.add(vo);
}
// for (int i = 0; i < size; i++) {
// ExcelVO vo = new ExcelVO();
// vo.setId(i);
//// vo.setAge(i);
//// vo.setName("张三" + i);
//// vo.setWen(new Random().nextInt(99));
//// vo.setRichard(new Random().nextInt(99));
//// vo.setSum(vo.getWen() + vo.getRichard());
// list.add(vo);
// }
}
return list;
}
}

@ -90,6 +90,11 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
return statMonthDao.filterList(statDataDetailRequest);
}
@Override
public List<IoStatMonthEntity> filterListByRecordKey(String recordKey) {
return statMonthDao.filterListByRecordKey(recordKey);
}
/**
*
*

@ -85,6 +85,11 @@ public class IoStatQuarterServiceImpl implements IoStatQuarterService {
return statQuarterDao.filterList(statDataDetailRequest);
}
@Override
public List<IoStatQuarterEntity> filterListByRecordKey(String recordKey) {
return statQuarterDao.filterListByRecordKey(recordKey);
}
/**
*
*

@ -87,6 +87,11 @@ public class IoStatYearServiceImpl implements IoStatYearService {
return statYearDao.filterList(statDataDetailRequest);
}
@Override
public List<IoStatYearEntity> filterListByRecordKey(String recordKey) {
return statYearDao.filterListByRecordKey(recordKey);
}
/**
*
*

@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.InputStream;
@ -112,7 +113,10 @@ public class ExcelHandler {
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
fileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.name());
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ExcelTemplateEnum.TEMPLATE_SUFFIX.getDesc());
EasyExcelFactory.write(response.getOutputStream(), clazz).sheet(sheetName).doWrite(dataList);
ServletOutputStream outputStream = response.getOutputStream();
EasyExcelFactory.write(outputStream, clazz).sheet(sheetName).doWrite(dataList);
outputStream.flush();
outputStream.close();
}
/**

@ -19,4 +19,9 @@
</if>
</where>
</select>
</mapper>
<select id="filterListByRecordKey" resultType="com.glxp.api.entity.inout.IoStatMonthEntity">
select *
from io_stat_month
where recordKeyFk = #{recordKey}
</select>
</mapper>

@ -19,4 +19,10 @@
</if>
</where>
</select>
</mapper>
<select id="filterListByRecordKey" resultType="com.glxp.api.entity.inout.IoStatQuarterEntity">
select *
from io_stat_quarter
where recordKeyFk = #{recordKey}
</select>
</mapper>

@ -19,4 +19,10 @@
</if>
</where>
</select>
</mapper>
<select id="filterListByRecordKey" resultType="com.glxp.api.entity.inout.IoStatYearEntity">
select *
from io_stat_year
where recordKeyFk = #{recordKey}
</select>
</mapper>

Loading…
Cancel
Save