Commit 58136755 by huluobin

导出报表加客户编号 项目

parent 49cc3c62
......@@ -42,24 +42,26 @@ public class CostExportServiceImpl implements CostExportService {
private CostDetailDao costDetailDao;
@Autowired
private CostDetailService costDetailService;
@Override
public String exportFees(List<String> exportNos) {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("费用表");
List<CostDto> exportList = getExportList(exportNos);
if (null == exportList || exportList.size() < 1){
if (null == exportList || exportList.size() < 1) {
return null;
}
// 设置表头
String[] headers = {"费用单号","费用类型","费用单大类","费用单小类","费用单状态","借支/借还","关联借支单号","借支单状态","是否抵个税","付款主体","收款单位","付款理由","付款金额","币种","创建人名称","下单时间","用途","付款时间","发票状态"};
String[] headers = {"费用单号", "费用类型", "费用单大类", "费用单小类", "费用单状态", "借支/借还", "关联借支单号", "借支单状态", "是否抵个税", "付款主体", "收款单位", "付款理由", "付款金额", "币种", "创建人名称", "下单时间", "用途", "付款时间", "发票状态"
, "项目", "客户编号"};
HSSFRow row0 = sheet.createRow(0);
for (int i = 0; i<headers.length;i++){
for (int i = 0; i < headers.length; i++) {
HSSFCell cell = row0.createCell(i);
HSSFRichTextString text = new HSSFRichTextString(headers[i]);
cell.setCellValue(text);
}
int rows = 1;
for (CostDto costDto : exportList){
for (CostDto costDto : exportList) {
HSSFRow row = sheet.createRow(rows);
row.createCell(0).setCellValue(costDto.getCostNo());
row.createCell(2).setCellValue(costDto.getTypeName());
......@@ -71,13 +73,13 @@ public class CostExportServiceImpl implements CostExportService {
row.createCell(14).setCellValue(costDto.getCreateUsername());
// 日期格式更改
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time= sdf.format(costDto.getCreateTime());
String time = sdf.format(costDto.getCreateTime());
row.createCell(15).setCellValue(time);
row.createCell(16).setCellValue(costDto.getCostReason());
if (costDto.getPayTime() != null) row.createCell(17).setCellValue(sdf.format(costDto.getPayTime()));
if (1 == costDto.getCostForm()){
if (1 == costDto.getCostForm()) {
row.createCell(1).setCellValue("付款");
if (null != costDto.getIsLend() && 2 == costDto.getIsLend()){
if (null != costDto.getIsLend() && 2 == costDto.getIsLend()) {
row.createCell(1).setCellValue("差额单");
row.createCell(6).setCellValue(costDto.getSupCostNo());
row.createCell(12).setCellValue(costDto.getPayPlanAmountDto());
......@@ -88,32 +90,34 @@ public class CostExportServiceImpl implements CostExportService {
row.createCell(8).setCellValue(costDto.getIsTaxStr());
}
}
if (2 == costDto.getCostForm()){
if (2 == costDto.getCostForm()) {
row.createCell(1).setCellValue("收款");
row.createCell(12).setCellValue(costDto.getAmountDto());
row.createCell(13).setCellValue(costDto.getDicDto());
}
if (3 == costDto.getCostForm()){
if (3 == costDto.getCostForm()) {
row.createCell(5).setCellValue(costDto.getIsLendDto());
if (1 == costDto.getIsLend()){
if (1 == costDto.getIsLend()) {
row.createCell(1).setCellValue("借支");
row.createCell(7).setCellValue(costDto.getLendStatusDto());
row.createCell(12).setCellValue(costDto.getAmountDto());
row.createCell(13).setCellValue(costDto.getDicDto());
}
if (2 == costDto.getIsLend()){
if (2 == costDto.getIsLend()) {
row.createCell(6).setCellValue(costDto.getSupCostNo());
row.createCell(1).setCellValue("借还");
row.createCell(12).setCellValue(costDto.getPayPlanAmountDto());
row.createCell(13).setCellValue(costDto.getPayDicDto());
if(costDto.getHasInvoice() == 1) {
if (costDto.getHasInvoice() == 1) {
row.createCell(18).setCellValue("已给");
}else {
} else {
row.createCell(18).setCellValue("未给");
}
}
}
rows ++;
row.createCell(19).setCellValue(costDto.getProjectType());
row.createCell(20).setCellValue(costDto.getCustomerNum());
rows++;
}
// 保存到本地,并且返回路径
String filePath = saveFile(workbook);
......@@ -121,12 +125,12 @@ public class CostExportServiceImpl implements CostExportService {
}
@Override
public CostExpDomain saveRecord(CostExportVo costExportVo,String filePath) {
public CostExpDomain saveRecord(CostExportVo costExportVo, String filePath) {
CostExpDomain costExpDomain = new CostExpDomain();
costExpDomain.setExpList(costExportVo.getParams().getExportNos().toString());
costExpDomain.setExpNo(createExpNo());
costExpDomain.setExpPath(filePath);
costExpDomain.setExpTime(new Date( ));
costExpDomain.setExpTime(new Date());
UserDomain user = userDao.selectByuserid(costExportVo.getParams().getUserid());
costExpDomain.setExpUserid(costExportVo.getParams().getUserid());
costExpDomain.setExpUsername(user.getUsername());
......@@ -139,10 +143,10 @@ public class CostExportServiceImpl implements CostExportService {
@Override
public String createExpNo() {
String expNo = "EXP"+System.currentTimeMillis();
String expNo = "EXP" + System.currentTimeMillis();
CostExpDomain exp = costExpDao.selectByExpNo(expNo);
while (null != exp){
expNo = "EXP"+System.currentTimeMillis();
while (null != exp) {
expNo = "EXP" + System.currentTimeMillis();
exp = costExpDao.selectByExpNo(expNo);
}
return expNo;
......@@ -157,12 +161,12 @@ public class CostExportServiceImpl implements CostExportService {
private String saveFile(HSSFWorkbook workbook) {
// 文件名
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String fileName = "fee"+sdf.format(new Date())+".xls";
String filePath = PathUtil.getBasePath()+PathUtil.getPath("export/cost/");
filePath = filePath+ UUID.randomUUID()+"&"+fileName;
String fileName = "fee" + sdf.format(new Date()) + ".xls";
String filePath = PathUtil.getBasePath() + PathUtil.getPath("export/cost/");
filePath = filePath + UUID.randomUUID() + "&" + fileName;
File dest = new File(filePath);
// 创建路径
if(!dest.getParentFile().exists()){
if (!dest.getParentFile().exists()) {
dest.getParentFile().mkdirs();
}
// 生成 excel 文件
......@@ -181,29 +185,29 @@ public class CostExportServiceImpl implements CostExportService {
private List<CostDto> getExportList(List<String> exportNos) {
List<CostDto> exportList;
// 获取要导出的费用列表
if (null != exportNos && exportNos.size() >= 1){
if (null != exportNos && exportNos.size() >= 1) {
exportList = new ArrayList<>();
for (String costNo: exportNos){
for (String costNo : exportNos) {
CostDto costDtoByNo = costService.getCostDtoByNo(costNo);
if ( 1 == costDtoByNo.getCostForm()){
if (1 == costDtoByNo.getCostForm()) {
// 付款单,将子项目赋值到 CostDto 逐一打印
List<CostDetailDomain> costDetailDomains = costDetailDao.selectListByCostNo(costNo);
if (null != costDetailDomains && costDetailDomains.size() >= 1){
for (CostDetailDomain detail: costDetailDomains){
if (null != costDetailDomains && costDetailDomains.size() >= 1) {
for (CostDetailDomain detail : costDetailDomains) {
CostDto cost = new CostDto();
BeanUtils.copyProperties(costDtoByNo,cost);
BeanUtils.copyProperties(detail,cost);
cost.setAmountDto(""+cost.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
if (null != costDtoByNo.getIsLend() && 2 == costDtoByNo.getIsLend()){
cost.setPayPlanAmountDto(""+cost.getPayPlanAmount().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
BeanUtils.copyProperties(costDtoByNo, cost);
BeanUtils.copyProperties(detail, cost);
cost.setAmountDto("" + cost.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
if (null != costDtoByNo.getIsLend() && 2 == costDtoByNo.getIsLend()) {
cost.setPayPlanAmountDto("" + cost.getPayPlanAmount().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
exportList.add(cost);
}
}
}else {
costDtoByNo.setAmountDto(""+costDtoByNo.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
if (3 == costDtoByNo.getCostForm() && 2 == costDtoByNo.getIsLend()){
costDtoByNo.setPayPlanAmountDto(""+costDtoByNo.getPayPlanAmount().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
} else {
costDtoByNo.setAmountDto("" + costDtoByNo.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
if (3 == costDtoByNo.getCostForm() && 2 == costDtoByNo.getIsLend()) {
costDtoByNo.setPayPlanAmountDto("" + costDtoByNo.getPayPlanAmount().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
exportList.add(costDtoByNo);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment