| | |
| | | package com.ruoyi.cwgl.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.cwgl.domain.ReceivableFeeDetail; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.ruoyi.common.utils.file.DownloadExportUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | |
| | | return toAjax(receivableFeeManagementService.createReceivableBill(billCreateVo)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 作废应收费用管理记录 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('cwgl:receivableFeeManagement:void')") |
| | | @Log(title = "应收费用管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/void/{id}") |
| | | public AjaxResult voidReceivableFee(@PathVariable Integer id) |
| | | { |
| | | return toAjax(receivableFeeManagementService.voidReceivableFeeManagement(id)); |
| | | } |
| | | |
| | | /** |
| | | * 导入应收费用管理数据(支持多Sheet:Sheet1主表,Sheet2明细表) |
| | | */ |
| | | @Log(title = "应收费用管理", businessType = BusinessType.IMPORT) |
| | | @PreAuthorize("@ss.hasPermi('cwgl:receivableFeeManagement:import')") |
| | | @PostMapping("/importData") |
| | | public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception |
| | | { |
| | | // 导入主表数据(Sheet1) |
| | | ExcelUtil<ReceivableFeeManagement> mainUtil = new ExcelUtil<ReceivableFeeManagement>(ReceivableFeeManagement.class); |
| | | List<ReceivableFeeManagement> receivableFeeList = mainUtil.importExcel("Sheet1", file.getInputStream(),10000); |
| | | |
| | | // 导入明细表数据(Sheet2)并关联到主表 |
| | | ExcelUtil<ReceivableFeeDetail> detailUtil = new ExcelUtil<ReceivableFeeDetail>(ReceivableFeeDetail.class); |
| | | List<ReceivableFeeDetail> detailList = detailUtil.importExcel("Sheet2", file.getInputStream(),10000); |
| | | |
| | | // 将明细数据关联到对应的主表记录 |
| | | if (detailList != null && !detailList.isEmpty()) { |
| | | for (ReceivableFeeDetail detail : detailList) { |
| | | // 根据序号字段找到对应的主表记录 |
| | | for (ReceivableFeeManagement mainRecord : receivableFeeList) { |
| | | if (mainRecord.getSerialNumber() != null && |
| | | mainRecord.getSerialNumber().equals(detail.getSerialNumber())) { |
| | | if (mainRecord.getReceivableFeeDetailList() == null) { |
| | | mainRecord.setReceivableFeeDetailList(new ArrayList<>()); |
| | | } |
| | | mainRecord.getReceivableFeeDetailList().add(detail); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | String message = receivableFeeManagementService.importReceivableFee(receivableFeeList, getUsername()); |
| | | return success(message); |
| | | } |
| | | |
| | | /** |
| | | * 下载导入模板 |
| | | */ |
| | | @GetMapping("/importTemplate") |
| | | public AjaxResult importTemplate(String exportKey) |
| | | { |
| | | receivableFeeManagementService.importTemplate(exportKey); |
| | | return AjaxResult.success("导出请求成功,请稍后点击下载...!"); |
| | | } |
| | | } |