feat(bms):导出应收账单
This commit is contained in:
+4
@@ -133,8 +133,12 @@ public class BillManageApplicationService {
|
||||
List<BillManagePO> billManagePOS = billManageDomainService.queryList(billManageDO);
|
||||
for (BillManagePO billManagePO : billManagePOS) {
|
||||
String billNumber = billManagePO.getBillNumber(); // 获取账单编号
|
||||
// 原有 - 前端列表用,不变
|
||||
List<BillDetail> billDetails = billDetailMapper.selectList(new LambdaQueryWrapper<BillDetail>().eq(BillDetail::getBillNumber, billNumber));
|
||||
billManagePO.setBillDetailList(billDetails);
|
||||
// 新增 - 导出用,LEFT JOIN billing_statement 拿到费用科目
|
||||
List<BillDetailPO> billDetailPOs = billDetailMapper.getDetailsByBillManageId(billManagePO.getBillManageId());
|
||||
billManagePO.setBillDetailPOList(billDetailPOs);
|
||||
}
|
||||
return billManagePOS;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import com.mhd.bms.application.server.billManage.BillManageApplicationService;
|
||||
import com.mhd.bms.domain.billManage.repository.po.BillDetailPO;
|
||||
@@ -13,7 +15,9 @@ import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementDO;
|
||||
import com.mhd.bms.domain.ncLog.entity.NcLog;
|
||||
import com.mhd.bms.infrastructure.utils.UniqueKeyUtil;
|
||||
import com.mhd.bms.interfaces.dto.billingStatement.BillingStatementDTO;
|
||||
import com.mhd.bms.interfaces.dto.billManage.BillManageExportVO;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.utils.poi.ExcelUtil;
|
||||
import com.mhd.common.log.annotation.Log;
|
||||
import com.mhd.common.log.enums.BusinessType;
|
||||
import com.mhd.common.redis.enums.RedisLockTypeEnum;
|
||||
@@ -31,6 +35,7 @@ import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
|
||||
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
|
||||
import com.mhd.bms.interfaces.assembler.billManage.BillManageAssembler;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.mhd.common.core.web.controller.BaseController;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.core.web.page.TableDataInfo;
|
||||
@@ -79,6 +84,55 @@ public class BillManageApi extends BaseController{
|
||||
return AjaxResult.success(billManageApplicationService.listCount(billManageDO));
|
||||
}
|
||||
|
||||
@ApiOperation("导出应收账单")
|
||||
@GetMapping(value = "/exportReceivableList", produces = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
public void exportReceivableList(BillManageDTO billManageDTO, HttpServletResponse response) throws IOException
|
||||
{
|
||||
//转换实体
|
||||
BillManageDO billManageDO = new BillManageDO();
|
||||
BeanUtils.copyProperties(billManageDTO,billManageDO);
|
||||
billManageDO.setBillType(1);
|
||||
//查全部(不分页)
|
||||
List<BillManagePO> list = billManageApplicationService.queryList(billManageDO);
|
||||
|
||||
//扁平化处理:一条明细生成一行
|
||||
List<BillManageExportVO> exportList = new ArrayList<>();
|
||||
for (BillManagePO bill : list) {
|
||||
List<BillDetailPO> details = bill.getBillDetailPOList();
|
||||
if (details != null && !details.isEmpty()) {
|
||||
for (BillDetailPO detail : details) {
|
||||
BillManageExportVO vo = new BillManageExportVO();
|
||||
//复制全部账单头字段
|
||||
BeanUtils.copyProperties(bill, vo);
|
||||
//覆盖明细字段
|
||||
vo.setFeeType(detail.getFeeType());
|
||||
vo.setServiceItemsCode(detail.getServiceItemsCode());
|
||||
vo.setServiceItemsName(detail.getServiceItemsName());
|
||||
vo.setFirstSubjectCode(detail.getFirstSubjectCode());
|
||||
vo.setFirstSubjectName(detail.getFirstSubjectName());
|
||||
vo.setSecondSubjectCode(detail.getSecondSubjectCode());
|
||||
vo.setSecondSubjectName(detail.getSecondSubjectName());
|
||||
vo.setBillingAmount(detail.getBillingAmount());
|
||||
exportList.add(vo);
|
||||
}
|
||||
} else {
|
||||
//没有明细也要有一行
|
||||
BillManageExportVO vo = new BillManageExportVO();
|
||||
BeanUtils.copyProperties(bill, vo);
|
||||
exportList.add(vo);
|
||||
}
|
||||
}
|
||||
|
||||
//设置下载头,防止浏览器乱码
|
||||
String fileName = URLEncoder.encode("应收账单", "UTF-8").replaceAll("\\+", "%20");
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||
|
||||
ExcelUtil<BillManageExportVO> util = new ExcelUtil<>(BillManageExportVO.class);
|
||||
util.exportExcel(response, exportList, "应收账单");
|
||||
}
|
||||
|
||||
@ApiOperation("获取nc推送日志")
|
||||
@GetMapping(value = "/getNcLog")
|
||||
public AjaxResult getNcLog(@RequestParam(name = "billManageId") Long billManageId, @RequestParam(name = "type") Long type)
|
||||
|
||||
Reference in New Issue
Block a user