|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|