|
|
@ -19,10 +19,13 @@ import com.dreamchaser.depository_manage.utils.*; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang.StringUtils; |
|
|
import org.apache.commons.lang.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.core.io.ClassPathResource; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.io.File; |
|
|
import java.io.File; |
|
|
|
|
|
import java.io.IOException; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.concurrent.Future; |
|
|
import java.util.concurrent.Future; |
|
|
@ -436,6 +439,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
public List<String> writeExcelForPrint(Integer id, Integer pageSize, UserByPort userToken) { |
|
|
public List<String> writeExcelForPrint(Integer id, Integer pageSize, UserByPort userToken) { |
|
|
// 生成的表格名称列表
|
|
|
// 生成的表格名称列表
|
|
|
List<String> fileNameList = new ArrayList<>(); |
|
|
List<String> fileNameList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
// 获取要打印的出库主单
|
|
|
// 获取要打印的出库主单
|
|
|
ApplicationOutRecord record = depositoryRecordMapper.findApplicationOutRecordPById(id); |
|
|
ApplicationOutRecord record = depositoryRecordMapper.findApplicationOutRecordPById(id); |
|
|
// 获取要打印的所有子单
|
|
|
// 获取要打印的所有子单
|
|
|
@ -446,8 +450,9 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
if (recordMinList.size() > pageSize) { |
|
|
if (recordMinList.size() > pageSize) { |
|
|
pagesum = (int) Math.ceil(recordMinList.size() / (double) pageSize); |
|
|
pagesum = (int) Math.ceil(recordMinList.size() / (double) pageSize); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 读取表格模板
|
|
|
// 读取表格模板
|
|
|
String templateFileName = "D://PrintTemplate.xlsx"; |
|
|
String templateFileName = "static/upload/PrintTemplate.xlsx"; |
|
|
|
|
|
|
|
|
// 待打印主数据列表
|
|
|
// 待打印主数据列表
|
|
|
List<ExcelInfoByWrite> data = ListUtils.newArrayList(); |
|
|
List<ExcelInfoByWrite> data = ListUtils.newArrayList(); |
|
|
@ -572,8 +577,15 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
data.add(excelInfoByWrite); |
|
|
data.add(excelInfoByWrite); |
|
|
} |
|
|
} |
|
|
// 生成的表格
|
|
|
// 生成的表格
|
|
|
String fileName = "D://PrintTemplate" + System.currentTimeMillis() + ".xlsx"; |
|
|
String fileName = System.getProperty("java.io.tmpdir") + File.separator+"PrintTemplate" + System.currentTimeMillis() + ".xlsx"; |
|
|
try (ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileName).build()) { |
|
|
ClassPathResource classPathResourceForTemplate = new ClassPathResource(templateFileName); |
|
|
|
|
|
File fileForTemplate = null; |
|
|
|
|
|
try { |
|
|
|
|
|
fileForTemplate = classPathResourceForTemplate.getFile(); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
try (ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(fileForTemplate).build()) { |
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.HORIZONTAL).build(); |
|
|
FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.HORIZONTAL).build(); |
|
|
// 如果有多个list 模板上必须有{前缀.} 这里的前缀就是 data1,然后多个list必须用 FillWrapper包裹
|
|
|
// 如果有多个list 模板上必须有{前缀.} 这里的前缀就是 data1,然后多个list必须用 FillWrapper包裹
|
|
|
|