|
@@ -1,6 +1,7 @@
|
|
|
package com.pj.project.tb_fee_details;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
@@ -11,8 +12,11 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.ExcelWriter;
|
|
|
+import com.alibaba.excel.util.ListUtils;
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
|
|
+import com.alibaba.excel.write.metadata.style.WriteCellStyle;
|
|
|
+import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -44,6 +48,7 @@ import com.pj.project4sp.role.SpRoleMapper;
|
|
|
import com.pj.project4sp.uploadfile.UploadUtil;
|
|
|
import com.pj.utils.so.SoMap;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.ss.usermodel.BorderStyle;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
@@ -349,7 +354,7 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public String export(SoMap so) throws Exception{
|
|
|
+ /*public String export(SoMap so) throws Exception{
|
|
|
Date now = new Date();
|
|
|
String nowStr = DateUtil.format(now, "yyyy-MM-dd HH:mm");
|
|
|
String beginTime = so.getString("beginTime");
|
|
@@ -442,6 +447,119 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
excelWriter.fill(exportList, fillConfig, writeSheet);
|
|
|
excelWriter.finish();
|
|
|
return prefix + "/feeDetails/" + today + "/收费明细表_" + time + ".xlsx";
|
|
|
+ }*/
|
|
|
+
|
|
|
+ public String export(SoMap so) {
|
|
|
+ Date now = new Date();
|
|
|
+ String nowStr = DateUtil.format(now, "yyyy-MM-dd HH:mm");
|
|
|
+ String beginTime = so.getString("beginTime");
|
|
|
+ String endTime = so.getString("endTime");
|
|
|
+ String time = beginTime + "至" + endTime;
|
|
|
+ Map<String, String> head = new HashMap<>();
|
|
|
+ head.put("time", time);
|
|
|
+ head.put("exportTime", nowStr);
|
|
|
+
|
|
|
+ BigDecimal allDayFee = new BigDecimal(0);
|
|
|
+ BigDecimal allDayTaxes = new BigDecimal(0);
|
|
|
+ BigDecimal allDayNoTaxFee = new BigDecimal(0);
|
|
|
+ List<ExportFeeDetailDTO> exportList = new ArrayList<>();
|
|
|
+ List<TbFeeDetails> list = this.getList(so);
|
|
|
+ Integer index = 1;
|
|
|
+ for (TbFeeDetails feeDetails : list) {
|
|
|
+ String feeType = TbFeeDetails.fee.getDesc(feeDetails.getFeeType());
|
|
|
+ ExportFeeDetailDTO detailDTO = new ExportFeeDetailDTO();
|
|
|
+ detailDTO.setBusinessNo(feeDetails.getBusinessNo()).setCarNo(feeDetails.getCarNo())
|
|
|
+ .setFeeType(feeType).setItemTypeName(feeDetails.getItemTypeName())
|
|
|
+ .setItemName(feeDetails.getItemName()).setItemPrice(feeDetails.getItemPrice())
|
|
|
+ .setPayType("微信支付").setIndex(index++)
|
|
|
+ .setPayMode("直接收款")
|
|
|
+ .setWeight(feeDetails.getWeight()).setNum(feeDetails.getNum()).setUnitPrice(feeDetails.getUnitPrice())
|
|
|
+ .setSettle("已结算").setTaxRate(feeDetails.getTaxRate().multiply(new BigDecimal(100)))
|
|
|
+ .setTaxPrice(feeDetails.getTaxPrice()).setNoTaxPrice(feeDetails.getNoTaxPrice()).setPayTime(feeDetails.getPayTime())
|
|
|
+ .setPickCustomerName(feeDetails.getPickCustomerName())
|
|
|
+ .setTransactionId(feeDetails.getTransactionId())
|
|
|
+ .setKaiDanPerson(feeDetails.getKaiDanPerson())
|
|
|
+ .setJiChaPerson(feeDetails.getJiChaPerson())
|
|
|
+ .setDiaoDuPerson(feeDetails.getDiaoDuPerson());
|
|
|
+ if(!StrUtil.isEmpty(feeDetails.getBusinessId())){
|
|
|
+ detailDTO.setBusinessNo(feeDetails.getBusinessNo());
|
|
|
+ }else {
|
|
|
+ detailDTO.setBusinessNo(feeDetails.getBusinessCarNo());
|
|
|
+ }
|
|
|
+ exportList.add(detailDTO);
|
|
|
+ allDayFee = allDayFee.add(feeDetails.getItemPrice());
|
|
|
+ allDayTaxes = allDayTaxes.add(feeDetails.getTaxPrice());
|
|
|
+ allDayNoTaxFee = allDayNoTaxFee.add(feeDetails.getNoTaxPrice());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String separator = File.separator;
|
|
|
+ String today = DateUtil.today();
|
|
|
+ String rootPath = UploadUtil.uploadConfig.rootFolder + separator + UploadUtil.uploadConfig.httpPrefix;
|
|
|
+ String prefix = myConfig.getDomain() + UploadUtil.uploadConfig.httpPrefix;
|
|
|
+ String extPath = "feeDetails" + separator + today + separator;
|
|
|
+ String fileName = "收费明细表_" + time + ".xlsx";
|
|
|
+ String savePath = rootPath + separator + extPath;
|
|
|
+ File saveFIle = new File(savePath);
|
|
|
+ if (!saveFIle.exists()) {
|
|
|
+ saveFIle.mkdirs();
|
|
|
+ }
|
|
|
+
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource("static/day-fee-new.xlsx");
|
|
|
+ //InputStream tempInputStream =classPathResource.getInputStream();
|
|
|
+ WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
|
|
|
+ contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
+ contentWriteCellStyle.setBorderTop(BorderStyle.THIN);
|
|
|
+ contentWriteCellStyle.setBorderRight(BorderStyle.THIN);
|
|
|
+ contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
+ HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(
|
|
|
+ contentWriteCellStyle,contentWriteCellStyle);
|
|
|
+ ExcelWriter excelWriter = null;
|
|
|
+ try {
|
|
|
+ excelWriter = EasyExcel.write(savePath + fileName, ExportFeeDetailDTO.class)
|
|
|
+ .registerWriteHandler(horizontalCellStyleStrategy)
|
|
|
+ .withTemplate(classPathResource.getInputStream()).build();
|
|
|
+ WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
|
|
+ // FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();//换行
|
|
|
+ excelWriter.fill(exportList, writeSheet);
|
|
|
+ excelWriter.fill(head, writeSheet);
|
|
|
+ List<List<String>> totalListList = ListUtils.newArrayList();//动态添加行集合
|
|
|
+ List<String> totalList2 = ListUtils.newArrayList();//倒数第2行
|
|
|
+ List<String> totalList1 = ListUtils.newArrayList();//倒数第1行
|
|
|
+ totalListList.add(totalList2);
|
|
|
+ totalListList.add(totalList1);
|
|
|
+ for (int i=0;i<22;i++){
|
|
|
+ if(i==7){
|
|
|
+ totalList2.add("合计");
|
|
|
+ }else if(i==8){
|
|
|
+ totalList2.add(allDayFee.toString());
|
|
|
+ }else if(i==11){
|
|
|
+ totalList2.add(allDayTaxes.toString());
|
|
|
+ }else if(i==12){
|
|
|
+ totalList2.add(allDayNoTaxFee.toString());
|
|
|
+ }else {
|
|
|
+ totalList2.add(null);
|
|
|
+ }
|
|
|
+ if(i==2){
|
|
|
+ totalList1.add("收费核对员:");
|
|
|
+ }else if(i==10){
|
|
|
+ totalList1.add("收费统计员:");
|
|
|
+ }else if(i==18){
|
|
|
+ totalList1.add("收费员:");
|
|
|
+ }else {
|
|
|
+ totalList1.add(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ excelWriter.write(totalListList, writeSheet);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }finally {
|
|
|
+ if(excelWriter!=null){
|
|
|
+ excelWriter.finish();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return prefix + "/feeDetails/" + today + "/收费明细表_" + time + ".xlsx";
|
|
|
}
|
|
|
|
|
|
private boolean checkTimeRange(String begin, String end, Date now) {
|