Просмотр исходного кода

[账单][修改][下载账单]

release_toaliyun_real
gongbiao 7 лет назад
Родитель
Сommit
ceab203d5e
2 измененных файлов: 68 добавлений и 54 удалений
  1. +67
    -53
      mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java
  2. +1
    -1
      mallinkService/src/main/resources/mapper/WxBillAllMapper.xml

+ 67
- 53
mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java Просмотреть файл

@@ -1,6 +1,5 @@
package com.iformall.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
@@ -17,7 +16,6 @@ import com.iformall.service.*;
import com.iformall.utils.Constant;
import com.iformall.utils.DateUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
@@ -31,8 +29,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
* @author gongbiao
@@ -209,8 +207,10 @@ public class WxBillAllServiceImpl implements WxBillAllService {
//设置查询参数-当前月
wxBillAll.setMonth(month);
//查询
List<Map<String, Object>> billList = wxBillAllMapper.list(wxBillAll);

//List<Map<String, Object>> billList = wxBillAllMapper.list(wxBillAll);
Map<Object, List<Map<String, Object>>> billMapList = wxBillAllMapper.list(wxBillAll).parallelStream().collect(Collectors.groupingBy(x -> {
return x.get("merchantId");
}));
XSSFWorkbook workbook;
String filepath = Constant.fileDirectory;
File savefile = new File(filepath);
@@ -223,54 +223,68 @@ public class WxBillAllServiceImpl implements WxBillAllService {
try {
File file = new File(filepath);
workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("账单");
Row row = sheet.createRow(0);
Cell shopNumberCell = row.createCell(0);
Cell merchantNameCell = row.createCell(1);
Cell billNameCell = row.createCell(2);
Cell needPayCell = row.createCell(3);
Cell receivePayCell = row.createCell(4);
Cell oweCell = row.createCell(5);
Cell receiveDateCell = row.createCell(6);
Cell expiredDayCell = row.createCell(7);
Cell statusCell = row.createCell(8);

shopNumberCell.setCellValue("商铺号");
merchantNameCell.setCellValue("商户名称");
billNameCell.setCellValue("费用类型");
needPayCell.setCellValue("实际应收金额(元)");
receivePayCell.setCellValue("实收金额(元)");
oweCell.setCellValue("欠缴金额(元)");
receiveDateCell.setCellValue("缴款截止日期");
expiredDayCell.setCellValue("过期时间");
statusCell.setCellValue("账单状态");

for (int i = 0,size=billList.size(); i < size; i++) {
row = sheet.createRow(i + 1);
shopNumberCell = row.createCell(0);
merchantNameCell = row.createCell(1);
billNameCell = row.createCell(2);
needPayCell = row.createCell(3);
receivePayCell = row.createCell(4);
oweCell = row.createCell(5);
receiveDateCell = row.createCell(6);
expiredDayCell = row.createCell(7);
statusCell = row.createCell(8);
Map<String, Object> billMap = billList.get(i);
logger.info(billMap.toString());
shopNumberCell.setCellValue(billMap.get("shopNumber").toString());
merchantNameCell.setCellValue(billMap.get("merchantName").toString());
billNameCell.setCellValue(billMap.get("name").toString());
BigDecimal needPay = new BigDecimal(billMap.get("needPay").toString()).divide(new BigDecimal(100));
needPayCell.setCellValue(needPay.toString());
BigDecimal receivePay = new BigDecimal(billMap.get("receivePay").toString()).divide(new BigDecimal(100));
receivePayCell.setCellValue(receivePay.toString());
BigDecimal owe = new BigDecimal(billMap.get("owe").toString()).divide(new BigDecimal(100));
oweCell.setCellValue(owe.toString());
String receiveDate = DateUtils.date2String((Date) billMap.get("receiveDate"), "yyyy-MM-dd");
receiveDateCell.setCellValue(receiveDate);
expiredDayCell.setCellValue(billMap.get("expiredDay").toString());
statusCell.setCellValue(EnumBillDailyStatus.getEnum((Integer) billMap.get("status")).getMessage());
int count=1;
Set<Map.Entry<Object, List<Map<String, Object>>>> entries = billMapList.entrySet();
for(Map.Entry<Object, List<Map<String, Object>>> entry:entries){
List<Map<String, Object>> billList = entry.getValue();
Map<String, Object> billInfo = billList.get(0);
String merchantName = billInfo.get("merchantName").toString();
XSSFSheet sheet = workbook.createSheet(merchantName+"-"+count++);
Row row = sheet.createRow(0);
Cell shopNumberCell = row.createCell(0);
Cell merchantNameCell = row.createCell(1);
Cell billNameCell = row.createCell(2);
Cell needPayCell = row.createCell(3);
Cell receivePayCell = row.createCell(4);
Cell oweCell = row.createCell(5);
Cell receiveDateCell = row.createCell(6);
Cell expiredDayCell = row.createCell(7);
Cell statusCell = row.createCell(8);

shopNumberCell.setCellValue("商铺号");
merchantNameCell.setCellValue("商户名称");
billNameCell.setCellValue("费用类型");
needPayCell.setCellValue("实际应收金额(元)");
receivePayCell.setCellValue("实收金额(元)");
oweCell.setCellValue("欠缴金额(元)");
receiveDateCell.setCellValue("缴款截止日期");
expiredDayCell.setCellValue("过期时间");
statusCell.setCellValue("账单状态");

for (int i = 0,size=billList.size(); i < size; i++) {
row = sheet.createRow(i + 1);
shopNumberCell = row.createCell(0);
merchantNameCell = row.createCell(1);
billNameCell = row.createCell(2);
needPayCell = row.createCell(3);
receivePayCell = row.createCell(4);
oweCell = row.createCell(5);
receiveDateCell = row.createCell(6);
expiredDayCell = row.createCell(7);
statusCell = row.createCell(8);
Map<String, Object> billMap = billList.get(i);
logger.info(billMap.toString());
shopNumberCell.setCellValue(billMap.get("shopNumber").toString());
merchantNameCell.setCellValue(billMap.get("merchantName").toString());
billNameCell.setCellValue(billMap.get("name").toString());
BigDecimal needPay = new BigDecimal(billMap.get("needPay").toString()).divide(new BigDecimal(100));
needPayCell.setCellValue(needPay.toString());
BigDecimal receivePay = new BigDecimal(billMap.get("receivePay").toString()).divide(new BigDecimal(100));
receivePayCell.setCellValue(receivePay.toString());
BigDecimal owe = new BigDecimal(billMap.get("owe").toString()).divide(new BigDecimal(100));
oweCell.setCellValue(owe.toString());
String receiveDate = DateUtils.date2String((Date) billMap.get("receiveDate"), "yyyy-MM-dd");
receiveDateCell.setCellValue(receiveDate);
expiredDayCell.setCellValue(billMap.get("expiredDay").toString());
statusCell.setCellValue(EnumBillDailyStatus.getEnum((Integer) billMap.get("status")).getMessage());
}
row = sheet.createRow(billList.size()+1);
Cell managerInfoCell = row.createCell(0);
Cell managerCell = row.createCell(1);
Cell managerPhoneCell = row.createCell(2);
managerInfoCell.setCellValue("负责人信息:");
managerCell.setCellValue(billInfo.get("manager")==null?"":billInfo.get("manager").toString());
managerPhoneCell.setCellValue(billInfo.get("managerPhone")==null?"":billInfo.get("managerPhone").toString());

}



+ 1
- 1
mallinkService/src/main/resources/mapper/WxBillAllMapper.xml Просмотреть файл

@@ -5,7 +5,7 @@
<select id="list" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
select bill.id,bill.merchant_id merchantId,bill.shop_id shopId,bill.bill_type_value billTypeValue,bill.bill_type billType,bill.need_pay needPay,
bill.receive_pay receivePay,bill.pay,bill.owe,bill.receive_date receiveDate,bill.pay_date payDate,bill.expired_day expiredDay,bill.status,
bill.tenant_id tenantId,m.name merchantName,s.shop_number shopNumber,bill.starttime,bill.endtime,bill.name from (
bill.tenant_id tenantId,m.name merchantName,s.shop_number shopNumber,bill.starttime,bill.endtime,bill.name,s.manager,s.manager_phone managerPhone from (
select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金' bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime from wx_bill_rent
union
select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金' bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime from wx_bill_rent_deposit


Загрузка…
Отмена
Сохранить