| | |
| | | package com.ruoyi.purchase.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | 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.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.page.TableDataInfo; |
| | | import com.ruoyi.purchase.dto.PurchaseLedgerDto; |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerTemplateMapper; |
| | |
| | | import com.ruoyi.purchase.pojo.PurchaseLedgerTemplate; |
| | | import com.ruoyi.purchase.pojo.SalesLedgerProductTemplate; |
| | | import com.ruoyi.purchase.service.IPurchaseLedgerService; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.service.ISalesLedgerProductService; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 采购台账Controller |
| | |
| | | @Log(title = "导入采购台账", businessType = BusinessType.INSERT) |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入采购台账") |
| | | public R<?> importData(@RequestParam("file") |
| | | public AjaxResult importData(@RequestParam("file") |
| | | @ApiParam(value = "Excel文件", required = true) |
| | | MultipartFile file) { |
| | | return purchaseLedgerService.importData(file); |
| | |
| | | util.exportExcel(response, list, "【请填写功能名称】数据"); |
| | | } |
| | | |
| | | /** |
| | | * 导出来票登记列表 |
| | | */ |
| | | @Log(title = "导出来票登记列表", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/exportOne") |
| | | public void exportOne(HttpServletResponse response, PurchaseLedger purchaseLedger) { |
| | | Page page = new Page(); |
| | | page.setCurrent(-1); |
| | | page.setSize(-1); |
| | | IPage<PurchaseLedgerDto> purchaseLedgerDtoIPage = purchaseLedgerService.selectPurchaseLedgerListPage(page, new PurchaseLedgerDto()); |
| | | ExcelUtil<PurchaseLedgerDto> util = new ExcelUtil<PurchaseLedgerDto>(PurchaseLedgerDto.class); |
| | | util.exportExcel(response, purchaseLedgerDtoIPage.getRecords(), "导出来票登记列表"); |
| | | } |
| | | |
| | | /** |
| | | * 新增修改采购台账 |
| | | */ |
| | | @Log(title = "采购台账", businessType = BusinessType.INSERT) |
| | | @PostMapping("/addOrEditPurchase") |
| | | public R<?> addOrEditPurchase(@RequestBody PurchaseLedgerDto purchaseLedgerDto) throws Exception { |
| | | purchaseLedgerService.addOrEditPurchase(purchaseLedgerDto); |
| | | return R.ok(); |
| | | public AjaxResult addOrEditPurchase(@RequestBody PurchaseLedgerDto purchaseLedgerDto) throws Exception { |
| | | return toAjax(purchaseLedgerService.addOrEditPurchase(purchaseLedgerDto)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Operation(summary = "/查询采购模板") |
| | | @GetMapping("/getPurchaseTemplateList") |
| | | public R<?> getPurchaseTemplateList() { |
| | | public AjaxResult getPurchaseTemplateList() { |
| | | List<PurchaseLedgerTemplate> purchaseLedgers = purchaseLedgerTemplateMapper.selectList(null); |
| | | purchaseLedgers.forEach(purchaseLedgerDto1 -> { |
| | | LambdaQueryWrapper<SalesLedgerProductTemplate> queryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | purchaseLedgerDto1.setProductList(list); |
| | | } |
| | | }); |
| | | return R.ok(purchaseLedgers); |
| | | return AjaxResult.success(purchaseLedgers); |
| | | } |
| | | /** |
| | | * 修改采购台账审批状态 |
| | | */ |
| | | @PostMapping("/updateApprovalStatus") |
| | | public R<?> addOrEditPurchase(@RequestBody PurchaseLedger purchaseLedger){ |
| | | purchaseLedgerService.updateById(purchaseLedger); |
| | | return R.ok(); |
| | | public AjaxResult addOrEditPurchase(@RequestBody PurchaseLedger purchaseLedger){ |
| | | return toAjax(purchaseLedgerService.updateById(purchaseLedger)); |
| | | } |
| | | /** |
| | | * 查询采购台账和产品父子列表 |
| | |
| | | */ |
| | | @Log(title = "采购台账", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/delPurchase") |
| | | public R<?> remove(@RequestBody Long[] ids) { |
| | | purchaseLedgerService.deletePurchaseLedgerByIds(ids); |
| | | return R.ok(); |
| | | public AjaxResult remove(@RequestBody Long[] ids) { |
| | | return toAjax(purchaseLedgerService.deletePurchaseLedgerByIds(ids)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * 根据销售合同查询产品信息 |
| | | */ |
| | | @GetMapping("/getProductBySalesNo") |
| | | public R<?> getProductBySalesNo(Long id) { |
| | | return R.ok(purchaseLedgerService.getProductBySalesNo(id)); |
| | | public AjaxResult getProductBySalesNo(Long id) { |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * 根据id查询采购合同号 |
| | | */ |
| | | @GetMapping("/getPurchaseNoById") |
| | | public R<?> getPurchaseNoById(Long id) { |
| | | return R.ok(purchaseLedgerService.getPurchaseNoById(id)); |
| | | public AjaxResult getPurchaseNoById(Long id) { |
| | | return AjaxResult.success(purchaseLedgerService.getPurchaseNoById(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * 根据采购合同号查询产品 |
| | | */ |
| | | @GetMapping("/getInfo") |
| | | public R<?> getInfo(PurchaseLedgerDto purchaseLedgerDto) { |
| | | return R.ok(purchaseLedgerService.getInfo(purchaseLedgerDto)); |
| | | public AjaxResult getInfo(PurchaseLedgerDto purchaseLedgerDto) { |
| | | return AjaxResult.success(purchaseLedgerService.getInfo(purchaseLedgerDto)); |
| | | } |
| | | |
| | | /** |
| | | * 查询采购台账列表 |
| | | */ |
| | | @GetMapping("/listPage") |
| | | public R<?> listPage(Page page, PurchaseLedgerDto purchaseLedger) { |
| | | return R.ok(purchaseLedgerService.selectPurchaseLedgerListPage(page, purchaseLedger)); |
| | | public AjaxResult listPage(Page page, PurchaseLedgerDto purchaseLedger) { |
| | | return AjaxResult.success(purchaseLedgerService.selectPurchaseLedgerListPage(page, purchaseLedger)); |
| | | } |
| | | |
| | | @Operation(summary = "生成采购序列号") |
| | | @GetMapping("/createPurchaseNo") |
| | | @Log(title = "生成采购序列号", businessType = BusinessType.OTHER) |
| | | public R<?> createPurchaseNo() { |
| | | return R.ok(purchaseLedgerService.getPurchaseNo(), "生成成功"); |
| | | public AjaxResult createPurchaseNo(@RequestParam Date entryDate) { |
| | | return AjaxResult.success("生成成功",purchaseLedgerService.getPurchaseNo(entryDate)); |
| | | } |
| | | } |