Browse Source

1增加统计分析报表导出

Xiaojh 4 years ago
parent
commit
52fb2db468

+ 79 - 1
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayReportController.java

@@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.time.LocalDateTime;
@@ -30,7 +32,7 @@ import java.time.format.DateTimeFormatter;
 @RequestMapping("/payreport")
 @Api(tags = "计费系统-报表")
 public class PayReportController {
-    @Autowired
+    @Resource
     PayReportService payReportService;
 
     @ApiOperation(value="收费明细报表")
@@ -119,4 +121,80 @@ public class PayReportController {
         return  new AjaxMessage<>(ResultStatus.OK,pagination);
     }
 
+
+    @ApiOperation(value = "欠费用户明细报表导出")
+    @GetMapping("/exportDebt")
+    public void exportDebt(
+            @ApiParam(value = "机构ID", required = false) @RequestParam(required = false) Integer officeId,
+            @ApiParam(value = "小区code", required = false) @RequestParam(required = false) String communityId,
+            @ApiParam(value = "用户编码(模糊查询)", required = false) @RequestParam(required = false) String accountNumber,
+            HttpServletResponse httpServletResponse
+    ){
+        PayArrearagedetailsReportDto  inParams = new PayArrearagedetailsReportDto();
+        inParams.setOfficeId(officeId);
+        inParams.setCommunity(communityId);
+        inParams.setAccountNumber(accountNumber);
+        payReportService.getDebtListExcel(inParams,httpServletResponse);
+    }
+
+    @ApiOperation(value = "收费员明细报表导出")
+    @GetMapping("/exportOperatorde")
+    public void exportOperatorde(
+            @ApiParam(value = "小区code", required = false) @RequestParam(required = false) String communityId,
+            @ApiParam(value = "收费员ID",required = false)@RequestParam(required = false) Integer operateId,
+            @ApiParam(value = "小计值(与小计状态一起使用,如查询小计值大于100的)",required = false) @RequestParam(required = false) BigDecimal subtotal,
+            @ApiParam(value = "小计状态,0等于,1小于,2大于",required = false) @RequestParam(required = false) Integer subtotalSt,
+            @ApiParam(value = "开始时间yyyyMMdd", required = false) @RequestParam(required = false) String beginTime,
+            @ApiParam(value = "结束时间yyyyMMdd", required = false) @RequestParam(required = false) String endTime,
+            HttpServletResponse httpServletResponse
+    ){
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+        PayOperatordetailsReportDto inParams = new PayOperatordetailsReportDto();
+        inParams.setCommunity(communityId);
+        if(operateId != null)
+            inParams.setCreateBy(new BigInteger(String.valueOf(operateId)));
+        if(StringUtils.isNotBlank(beginTime)){
+            beginTime = beginTime +"000000";
+            inParams.setBeginTime( LocalDateTime.parse(beginTime,df));
+        }
+        if(StringUtils.isNotBlank(endTime)){
+            endTime = endTime + "235959";
+            inParams.setEndTime(LocalDateTime.parse(endTime, df));
+        }
+        if(subtotal != null)
+            inParams.setSubtotal(subtotal);
+        if(subtotalSt != null)
+            inParams.setDataType(subtotalSt);
+        payReportService.getOperatordetListExcel(inParams,httpServletResponse);
+    }
+
+    @ApiOperation(value = "收费明细报表导出")
+    @GetMapping("/exportTran")
+    public void exportTran(
+            @ApiParam(value = "机构ID", required = false) @RequestParam(required = false) Integer officeId,
+            @ApiParam(value = "支付方式ID,字典类:type=支付方式", required = false) @RequestParam(required = false) Integer payway,
+            @ApiParam(value = "收费员ID",required = false)@RequestParam(required = false) Integer operateId,
+            @ApiParam(value = "开始时间yyyyMMdd", required = false) @RequestParam(required = false) String beginTime,
+            @ApiParam(value = "结束时间yyyyMMdd", required = false) @RequestParam(required = false) String endTime,
+            HttpServletResponse httpServletResponse
+    ){
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+        PayTransactiondetailsReportDto inParams = new PayTransactiondetailsReportDto();
+
+        inParams.setOfficeId(officeId);
+        inParams.setPayWay(payway);
+        if(operateId != null)
+            inParams.setCreateBy(new BigInteger(String.valueOf(operateId)));
+
+        if(StringUtils.isNotBlank(beginTime)){
+            beginTime = beginTime +"000000";
+            inParams.setBeginTime( LocalDateTime.parse(beginTime,df));
+        }
+        if(StringUtils.isNotBlank(endTime)){
+            endTime = endTime + "235959";
+            inParams.setEndTime(LocalDateTime.parse(endTime, df));
+        }
+        payReportService.getTranExcel(inParams,httpServletResponse);
+    }
+
 }

+ 201 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayReportServiceImpl.java

@@ -1,6 +1,8 @@
 package com.bz.smart_city.service.impl.pay;
 
+import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.commom.util.ExcelUtil;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dao.pay.PayReportMapper;
 import com.bz.smart_city.dto.LoginUser;
@@ -8,14 +10,19 @@ import com.bz.smart_city.dto.pay.*;
 import com.bz.smart_city.service.pay.PayAgenttransactionService;
 import com.bz.smart_city.service.pay.PayReportService;
 import com.github.pagehelper.PageHelper;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
 
+import static com.google.common.collect.Lists.newArrayList;
+
 /**
  * @Author: ZJY
  * @DATE: 2020-07-28 11:18
@@ -175,4 +182,198 @@ public class PayReportServiceImpl implements PayReportService {
         //return new Pagination<>(reList);
     }
 
+    /**
+     * 导出用户欠费明细表
+     * @param payArrearagedetailsReportDto
+     * @param httpServletResponse
+     */
+    public void getDebtListExcel(PayArrearagedetailsReportDto payArrearagedetailsReportDto, HttpServletResponse httpServletResponse){
+
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        BigInteger customerId = new BigInteger(String.valueOf(loginUser.getCustomerId()));
+        payArrearagedetailsReportDto.setCustomerId(customerId);
+        BigInteger siteId = new BigInteger(String.valueOf(loginUser.getSiteId()));
+        payArrearagedetailsReportDto.setSiteId(siteId);
+
+        String title = "欠费用户明细表";//表头名称
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        //列名
+        String[] rowsName = new String[]{"序号","客户编码","客户名称","地址","水量","水费","污水费","不征税自来水","违约金","超计划水费","合计金额","联系方式"};
+        List<PayArrearagedetailsReportDto> reSubList = new ArrayList<>();
+        List<PayArrearagedetailsReportDto> reList = payReportMapper.getPayArrearagedetailsReportList(payArrearagedetailsReportDto);
+        if(reList != null && reList.size() > 0){
+            PayArrearagedetailsReportDto totalDto = new PayArrearagedetailsReportDto();
+            Integer payamount = 0;
+            BigDecimal payamountFee = BigDecimal.ZERO;
+            BigDecimal polluteFee= BigDecimal.ZERO;
+            BigDecimal taxExemptFee= BigDecimal.ZERO;
+            BigDecimal penltyFee= BigDecimal.ZERO;
+            BigDecimal outLevelFee= BigDecimal.ZERO;
+            BigDecimal subtotal= BigDecimal.ZERO;
+            for(int i=0;i<reList.size();i++){
+                payamount = payamount + reList.get(i).getPayamount();//水量
+                payamountFee = payamountFee.add(reList.get(i).getPayamountFee());//水费
+                polluteFee = polluteFee.add(reList.get(i).getPolluteFee());//污水费
+                taxExemptFee = taxExemptFee.add(reList.get(i).getTaxExemptFee());//不征税
+                penltyFee = penltyFee.add(reList.get(i).getPenltyFee());//违约金
+                outLevelFee = outLevelFee.add(reList.get(i).getOutLevelFee());//超计划水费
+                subtotal = subtotal.add(reList.get(i).getSubtotal());//合计
+            }
+            totalDto.setPayamount(payamount);
+            totalDto.setPayamountFee(payamountFee);;
+            totalDto.setPolluteFee(polluteFee);
+            totalDto.setTaxExemptFee(taxExemptFee);
+            totalDto.setPenltyFee(penltyFee);
+            totalDto.setOutLevelFee(outLevelFee);
+            totalDto.setSubtotal(subtotal);
+            totalDto.setAccountNumber("合计");
+            reSubList.add(totalDto);
+            reSubList.addAll(reList);
+        }
+
+        List<Object[]> dataList = newArrayList();
+        Object[] objs = null;
+        BigDecimal db =  new BigDecimal("0.0");
+        for(int i=0; i<reSubList.size() ; i++){
+            PayArrearagedetailsReportDto dto = reSubList.get(i);
+            objs = new Object[rowsName.length];
+            objs[0] = i;
+            objs[1] = dto != null && StringUtils.isNotBlank(dto.getAccountNumber()) ? dto.getAccountNumber() : "";
+            objs[2] = dto != null && StringUtils.isNotBlank(dto.getAccountName()) ? dto.getAccountName() : "";
+            objs[3] = dto != null && StringUtils.isNotBlank(dto.getAccountAddr()) ? dto.getAccountAddr() : "" ;
+            objs[4] = dto != null && dto.getPayamount() != null ? dto.getPayamount() : db;
+            objs[5] = dto != null && dto.getPayamountFee() != null ? dto.getPayamountFee() : db;
+            objs[6] = dto != null && dto.getPolluteFee() != null ? dto.getPolluteFee() : db;
+            objs[7] = dto != null && dto.getTaxExemptFee() != null ? dto.getTaxExemptFee() : db;
+            objs[8] = dto != null && dto.getPenltyFee() != null ? dto.getPenltyFee() : db;
+            objs[9] = dto != null && dto.getOutLevelFee() != null ? dto.getOutLevelFee() : db;
+            objs[10] = dto != null && dto.getSubtotal() != null ? dto.getSubtotal() : db;
+            objs[11] = dto != null && StringUtils.isNotBlank(dto.getMobilePhone()) ? dto.getMobilePhone() : "";
+            dataList.add(objs);
+        }
+        ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+        try {
+            excelUtil.export(httpServletResponse);
+        } catch (Exception e) {
+            throw new ServiceException(-900, "导出异常");
+        }
+    }
+
+    /**
+     * 导出操作员明细表
+     * @param payOperatordetailsReportDto
+     * @param httpServletResponse
+     */
+    public void getOperatordetListExcel(PayOperatordetailsReportDto payOperatordetailsReportDto, HttpServletResponse httpServletResponse){
+
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        BigInteger customerId = new BigInteger(String.valueOf(loginUser.getCustomerId()));
+        payOperatordetailsReportDto.setCustomerId(customerId);
+        BigInteger siteId = new BigInteger(String.valueOf(loginUser.getSiteId()));
+        payOperatordetailsReportDto.setSiteId(siteId);
+
+        String title = "收费员明细表";//表头名称
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        //列名
+        String[] rowsName = new String[]{"序号","客户名称","小区","客户编码","地址","预存款","实收款","小计","收费时间","收费员"};
+        List<PayOperatordetailsReportDto> reSubList = new ArrayList<>();
+        List<PayOperatordetailsReportDto> reList = payReportMapper.getPayOperatordetailsReportList(payOperatordetailsReportDto);
+        if(reList != null && reList.size() > 0){
+            PayOperatordetailsReportDto totalDto = new PayOperatordetailsReportDto();
+            BigDecimal receivedCount = BigDecimal.ZERO;
+            BigDecimal transamount = BigDecimal.ZERO;
+            BigDecimal subtotal = BigDecimal.ZERO;
+            for(int i=0;i<reList.size();i++){
+                receivedCount = receivedCount.add(reList.get(i).getReceivedCount());
+                transamount = transamount.add(reList.get(i).getTransamount());
+                subtotal = subtotal.add(reList.get(i).getSubtotal());
+            }
+            totalDto.setSubtotal(subtotal);
+            totalDto.setTransamount(transamount);
+            totalDto.setReceivedCount(receivedCount);
+            totalDto.setAccountName("合计");
+            reSubList.add(totalDto);
+            reSubList.addAll(reList);
+        }
+
+        List<Object[]> dataList = newArrayList();
+        Object[] objs = null;
+        BigDecimal db =  new BigDecimal("0.0");
+        for(int i=0; i<reSubList.size() ; i++){
+            PayOperatordetailsReportDto dto = reSubList.get(i);
+            objs = new Object[rowsName.length];
+            objs[0] = i;
+            objs[1] = dto != null && StringUtils.isNotBlank(dto.getAccountName()) ? dto.getAccountName() : "";
+            objs[2] = dto != null && StringUtils.isNotBlank(dto.getCommunityName()) ? dto.getCommunityName() : "";
+            objs[3] = dto != null && StringUtils.isNotBlank(dto.getAccountNumber()) ? dto.getAccountNumber() : "";
+            objs[4] = dto != null && StringUtils.isNotBlank(dto.getAccountAddr()) ? dto.getAccountAddr() : "";
+            objs[5] = dto != null && dto.getTransamount() != null ? dto.getTransamount() : db;
+            objs[6] = dto != null && dto.getReceivedCount() != null ? dto.getReceivedCount() : db;
+            objs[7] = dto != null && dto.getSubtotal() != null ? dto.getSubtotal() : db;
+            objs[8] = dto != null && dto.getTransTime() != null ? dto.getTransTime() : null;
+            objs[9] = dto != null && dto.getCreateByName() != null ? dto.getCreateByName() : "";
+            dataList.add(objs);
+        }
+        ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+        try {
+            excelUtil.export(httpServletResponse);
+        } catch (Exception e) {
+            throw new ServiceException(-900, "导出异常");
+        }
+    }
+
+    /**
+     * 导出收费明细表
+     * @param payTransactiondetailsReportDto
+     * @param httpServletResponse
+     */
+    public void getTranExcel(PayTransactiondetailsReportDto payTransactiondetailsReportDto,HttpServletResponse httpServletResponse){
+
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        BigInteger customerId = new BigInteger(String.valueOf(loginUser.getCustomerId()));
+        payTransactiondetailsReportDto.setCustomerId(customerId);
+        BigInteger siteId = new BigInteger(String.valueOf(loginUser.getSiteId()));
+        payTransactiondetailsReportDto.setSiteId(siteId);
+
+        String title = "收费明细表";//表头名称
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        //列名
+        String[] rowsName = new String[]{"序号","客户编码","客户名称","地址","收费金额","支付方式","收费时间","收费员"};
+        List<PayTransactiondetailsReportDto> reSubList = new ArrayList<>();
+        List<PayTransactiondetailsReportDto> reList = payReportMapper.getPayTransactiondetailsReportList(payTransactiondetailsReportDto);
+        if(reList != null && reList.size() > 0){
+            PayTransactiondetailsReportDto totalDto = new PayTransactiondetailsReportDto();
+            BigDecimal transAmount = BigDecimal.ZERO;
+            for(int i=0;i<reList.size();i++){
+                transAmount = transAmount.add(reList.get(i).getTransAmount());
+            }
+            totalDto.setTransAmount(transAmount);
+            totalDto.setAccountNumber("合计");
+            reSubList.add(totalDto);
+            reSubList.addAll(reList);
+        }
+
+        List<Object[]> dataList = newArrayList();
+        Object[] objs = null;
+        BigDecimal db =  new BigDecimal("0.0");
+        for(int i=0; i<reSubList.size() ; i++){
+            PayTransactiondetailsReportDto dto = reSubList.get(i);
+            objs = new Object[rowsName.length];
+            objs[0] = i;
+            objs[1] = dto != null && StringUtils.isNotBlank(dto.getAccountNumber()) ? dto.getAccountNumber() : "";
+            objs[2] = dto != null && StringUtils.isNotBlank(dto.getAccountName()) ? dto.getAccountName() : "";
+            objs[3] = dto != null && StringUtils.isNotBlank(dto.getAccountAddr()) ? dto.getAccountAddr() : "";
+            objs[4] = dto != null && dto.getTransAmount() != null ? dto.getTransAmount() : db;
+            objs[5] = dto != null && StringUtils.isNotBlank(dto.getPaywayLabel()) ? dto.getPaywayLabel() : "";
+            objs[6] = dto != null && dto.getTransTime() != null ? dto.getTransTime() : null;
+            objs[7] = dto != null && dto.getCreateByName() != null ? dto.getCreateByName() : "";
+            dataList.add(objs);
+        }
+        ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+        try {
+            excelUtil.export(httpServletResponse);
+        } catch (Exception e) {
+            throw new ServiceException(-900, "导出异常");
+        }
+    }
 }

+ 8 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayReportService.java

@@ -5,6 +5,8 @@ import com.bz.smart_city.dto.pay.PayArrearagedetailsReportDto;
 import com.bz.smart_city.dto.pay.PayOperatordetailsReportDto;
 import com.bz.smart_city.dto.pay.PayTransactiondetailsReportDto;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * @Author: ZJY
  * @DATE: 2020-07-28 11:17
@@ -16,4 +18,10 @@ public interface PayReportService {
     Pagination<PayOperatordetailsReportDto> getPayOperatordetailsReport(PayOperatordetailsReportDto payOperatordetailsReportDto,int pageNum,int pageSize);
 
     Pagination<PayArrearagedetailsReportDto> getPayArrearagedetailsReport(PayArrearagedetailsReportDto payArrearagedetailsReportDto, int pageNum, int pageSize);
+
+    void getDebtListExcel(PayArrearagedetailsReportDto payArrearagedetailsReportDto, HttpServletResponse httpServletResponse);
+
+    void getOperatordetListExcel(PayOperatordetailsReportDto payOperatordetailsReportDto, HttpServletResponse httpServletResponse);
+
+    void getTranExcel(PayTransactiondetailsReportDto payTransactiondetailsReportDto,HttpServletResponse httpServletResponse);
 }