|
|
|
@ -1,11 +1,5 @@
|
|
|
|
|
package com.glxp.api.service.inout.impl;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author : zhangsan
|
|
|
|
|
* @date : 2023/4/17 11:13
|
|
|
|
|
* @modyified By :
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
@ -43,6 +37,8 @@ public class ExcelServiceImpl implements ExcelService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IoStatYearService statYearService;
|
|
|
|
|
@Resource
|
|
|
|
|
private IoStatDetailService statDetailService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* excel导入-单个sheet
|
|
|
|
@ -71,9 +67,9 @@ public class ExcelServiceImpl implements ExcelService {
|
|
|
|
|
* @param response 响应体
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void excelExport(HttpServletResponse response, String billNo,String key) {
|
|
|
|
|
public void excelExport(HttpServletResponse response, String billNo, String key) {
|
|
|
|
|
try {
|
|
|
|
|
List<ExcelVO> excelVOS = structureDate(billNo,key);
|
|
|
|
|
List<ExcelVO> excelVOS = structureDate(billNo, key);
|
|
|
|
|
excelHandler.exportExcel(response, excelVOS, ExcelVO.class, "excel导出-单et", "excel导出heet");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RenException("导出失败");
|
|
|
|
@ -103,10 +99,10 @@ public class ExcelServiceImpl implements ExcelService {
|
|
|
|
|
objList.add(new ExcelVO());
|
|
|
|
|
objList.add(new ExcelVO());
|
|
|
|
|
List<List<Object>> resultList = excelHandler.importExcelsByIndex(multipartFile, objList, 6, indexList);
|
|
|
|
|
System.out.println("resultList="+resultList.size());
|
|
|
|
|
resultList.forEach(vo->{
|
|
|
|
|
System.out.println("resultList=" + resultList.size());
|
|
|
|
|
resultList.forEach(vo -> {
|
|
|
|
|
List<ExcelVO> voList = JSON.parseArray(JSON.toJSONString(vo), ExcelVO.class);
|
|
|
|
|
System.out.println("voList="+voList.size()+"条数据");
|
|
|
|
|
System.out.println("voList=" + voList.size() + "条数据");
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RenException("导入失败");
|
|
|
|
@ -187,102 +183,122 @@ public class ExcelServiceImpl implements ExcelService {
|
|
|
|
|
*
|
|
|
|
|
* @return 数据集合
|
|
|
|
|
*/
|
|
|
|
|
private List<ExcelVO> structureDate(String billNo ,String key) {
|
|
|
|
|
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.setDeptName(ioStatDayEntities.get(i).getDeptName());
|
|
|
|
|
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.setDeptName(ioStatMonthEntities.get(i).getDeptName());
|
|
|
|
|
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.setDeptName(ioStatQuarterEntities.get(i).getDeptName());
|
|
|
|
|
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.setDeptName(ioStatYearEntities.get(i).getDeptName());
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
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.setDeptName(ioStatDayEntities.get(i).getDeptName());
|
|
|
|
|
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.setDeptName(ioStatMonthEntities.get(i).getDeptName());
|
|
|
|
|
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.setDeptName(ioStatQuarterEntities.get(i).getDeptName());
|
|
|
|
|
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 if (key.equals("year")) {
|
|
|
|
|
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.setDeptName(ioStatYearEntities.get(i).getDeptName());
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (key.equals("custom")) {
|
|
|
|
|
List<IoStatDetailEntity> ioStatYearEntities = statDetailService.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.setDeptName(ioStatYearEntities.get(i).getInvName());
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|