| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.enums.ApplicationTypeEnum; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.service.ICommonFileService; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import com.ruoyi.sales.vo.SalesLedgerVo; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | |
| | | @RestController |
| | | @RequestMapping("/sales/ledger") |
| | | @AllArgsConstructor |
| | | @Api(tags = "销售台账") |
| | | @Tag(name = "销售台账") |
| | | @Slf4j |
| | | public class SalesLedgerController extends BaseController { |
| | | |
| | | private ISalesLedgerService salesLedgerService; |
| | | |
| | | private ICommonFileService commonFileService; |
| | | |
| | | @Autowired |
| | | private InvoiceLedgerMapper invoiceLedgerMapper; |
| | | |
| | | @Autowired |
| | | private ReceiptPaymentMapper receiptPaymentMapper; |
| | | private final FileUtil fileUtil; |
| | | |
| | | /** |
| | | * 导入销售台账 |
| | | */ |
| | | @Log(title = "导入销售台账", businessType = BusinessType.INSERT) |
| | | @PostMapping("/import") |
| | | @ApiOperation("导入销售台账") |
| | | @Operation(summary = "导入销售台账") |
| | | public AjaxResult importData(@RequestParam("file") |
| | | @ApiParam(value = "Excel文件", required = true) |
| | | MultipartFile file) { |
| | | return salesLedgerService.importData(file); |
| | | } |
| | | |
| | | @ApiOperation("导出销售台账模板") |
| | | @Operation(summary = "导出销售台账模板") |
| | | @PostMapping("/exportTemplate") |
| | | public void exportTemplate(HttpServletResponse response) { |
| | | // 1. 模板文件在resources/static下的路径 |
| | |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, SalesLedgerDto salesLedgerDto) { |
| | | Page page = new Page(-1,-1); |
| | | IPage<SalesLedger> salesLedgerIPage = listPage(page, salesLedgerDto); |
| | | ExcelUtil<SalesLedger> util = new ExcelUtil<SalesLedger>(SalesLedger.class); |
| | | IPage<SalesLedgerVo> salesLedgerIPage = listPage(page, salesLedgerDto); |
| | | ExcelUtil<SalesLedgerVo> util = new ExcelUtil<SalesLedgerVo>(SalesLedgerVo.class); |
| | | if(salesLedgerIPage == null){ |
| | | util.exportExcel(response, new ArrayList<>(), "销售台账数据"); |
| | | return; |
| | | } |
| | | List<SalesLedger> list = salesLedgerIPage.getRecords(); |
| | | List<SalesLedgerVo> list = salesLedgerIPage.getRecords(); |
| | | util.exportExcel(response, list, "销售台账数据"); |
| | | } |
| | | |
| | |
| | | Page page = new Page(); |
| | | page.setCurrent(-1); |
| | | page.setSize(-1); |
| | | IPage<SalesLedger> salesLedgerIPage = listPage(page, salesLedgerDto); |
| | | ExcelUtil<SalesLedger> util = new ExcelUtil<SalesLedger>(SalesLedger.class); |
| | | IPage<SalesLedgerVo> salesLedgerIPage = listPage(page, salesLedgerDto); |
| | | ExcelUtil<SalesLedgerVo> util = new ExcelUtil<SalesLedgerVo>(SalesLedgerVo.class); |
| | | util.exportExcel(response, salesLedgerIPage == null ? new ArrayList<>() : salesLedgerIPage.getRecords(), "导出开票登记列表"); |
| | | } |
| | | |
| | |
| | | * 查询销售台账列表 |
| | | */ |
| | | @GetMapping("/listPage") |
| | | public IPage<SalesLedger> listPage(Page page, SalesLedgerDto salesLedgerDto) { |
| | | IPage<SalesLedger> iPage = salesLedgerService.selectSalesLedgerListPage(page, salesLedgerDto); |
| | | public IPage<SalesLedgerVo> listPage(Page page, SalesLedgerDto salesLedgerDto) { |
| | | IPage<SalesLedgerVo> iPage = salesLedgerService.selectSalesLedgerListPage(page, salesLedgerDto); |
| | | |
| | | // 查询结果为空,直接返回 |
| | | if (CollectionUtils.isEmpty(iPage.getRecords())) { |
| | |
| | | } |
| | | } |
| | | |
| | | for (SalesLedger salesLedger : iPage.getRecords()) { |
| | | Long ledgerId = salesLedger.getId(); |
| | | for (SalesLedgerVo salesLedgerVo : iPage.getRecords()) { |
| | | Long ledgerId = salesLedgerVo.getId(); |
| | | // 合同总金额 |
| | | BigDecimal contractAmount = salesLedger.getContractAmount() == null ? BigDecimal.ZERO : salesLedger.getContractAmount(); |
| | | BigDecimal contractAmount = salesLedgerVo.getContractAmount() == null ? BigDecimal.ZERO : salesLedgerVo.getContractAmount(); |
| | | // 开票总额和回款总额 |
| | | BigDecimal invoiceTotal = invoiceTotals.getOrDefault(ledgerId, BigDecimal.ZERO); |
| | | BigDecimal receiptPaymentAmountTotal = receiptTotals.getOrDefault(ledgerId, BigDecimal.ZERO); |
| | |
| | | noReceiptPaymentAmountTotal = BigDecimal.ZERO; |
| | | } |
| | | |
| | | salesLedger.setNoInvoiceAmountTotal(noInvoiceAmountTotal); |
| | | salesLedger.setInvoiceTotal(invoiceTotal); |
| | | salesLedger.setReceiptPaymentAmountTotal(receiptPaymentAmountTotal); |
| | | salesLedger.setNoReceiptAmount(noReceiptPaymentAmountTotal); |
| | | salesLedgerVo.setNoInvoiceAmountTotal(noInvoiceAmountTotal); |
| | | salesLedgerVo.setInvoiceTotal(invoiceTotal); |
| | | salesLedgerVo.setReceiptPaymentAmountTotal(receiptPaymentAmountTotal); |
| | | salesLedgerVo.setNoReceiptAmount(noReceiptPaymentAmountTotal); |
| | | |
| | | // 如果已经有过开票或回款操作,则不允许编辑 |
| | | boolean hasInvoiceOperation = invoiceTotal.compareTo(BigDecimal.ZERO) > 0; |
| | | boolean hasReceiptOperation = receiptPaymentAmountTotal.compareTo(BigDecimal.ZERO) > 0; |
| | | salesLedger.setIsEdit(!(hasInvoiceOperation || hasReceiptOperation)); |
| | | salesLedgerVo.setIsEdit(!(hasInvoiceOperation || hasReceiptOperation)); |
| | | |
| | | salesLedgerVo.setStorageBlobVOs(fileUtil.getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum.FILE, RecordTypeEnum.SALES_LEDGER, ledgerId)); |
| | | } |
| | | |
| | | if (ObjectUtils.isNotEmpty(salesLedgerDto.getStatus())) { |
| | |
| | | return iPage; |
| | | } |
| | | |
| | | @ApiOperation("查询销售台账消耗物料信息") |
| | | @Operation(summary = "查询销售台账消耗物料信息") |
| | | @GetMapping("/getSalesLedgerWithProductsLoss") |
| | | public R getSalesLedgerWithProductsLoss(Long salesLedgerId) { |
| | | return R.ok(salesLedgerService.getSalesLedgerWithProductsLoss(salesLedgerId)); |