| | |
| | | |
| | | 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.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.mapper.SalesLedgerProductTemplateMapper; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | 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 javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @RestController |
| | | @RequestMapping("/purchase/ledger") |
| | | @AllArgsConstructor |
| | | @Api(tags = "111") |
| | | @Api(tags = "采购台账") |
| | | public class PurchaseLedgerController extends BaseController { |
| | | private IPurchaseLedgerService purchaseLedgerService; |
| | | |
| | | private ISalesLedgerService salesLedgerService; |
| | | private ISalesLedgerProductService salesLedgerProductService; |
| | | |
| | | private PurchaseLedgerTemplateMapper purchaseLedgerTemplateMapper; |
| | | |
| | | private SalesLedgerProductTemplateMapper salesLedgerProductTemplateMapper; |
| | | |
| | | /** |
| | | * 查询采购台账列表 |
| | |
| | | */ |
| | | @Log(title = "采购台账", businessType = BusinessType.INSERT) |
| | | @PostMapping("/addOrEditPurchase") |
| | | public AjaxResult addOrEditPurchase(@RequestBody PurchaseLedgerDto purchaseLedgerDto) throws IOException { |
| | | public AjaxResult addOrEditPurchase(@RequestBody PurchaseLedgerDto purchaseLedgerDto) throws Exception { |
| | | return toAjax(purchaseLedgerService.addOrEditPurchase(purchaseLedgerDto)); |
| | | } |
| | | /** |
| | | * 新增采购模板 |
| | | */ |
| | | @PostMapping("/addPurchaseTemplate") |
| | | public AjaxResult addPurchaseTemplate(@RequestBody PurchaseLedgerDto purchaseLedgerDto) throws IOException { |
| | | return toAjax(purchaseLedgerService.addPurchaseTemplate(purchaseLedgerDto)); |
| | | } |
| | | |
| | | /** |
| | | * 查询采购模板 |
| | | */ |
| | | @ApiOperation("/2222") |
| | | @ApiOperation("/查询采购模板") |
| | | @GetMapping("/getPurchaseTemplateList") |
| | | public AjaxResult getPurchaseTemplateList() { |
| | | PurchaseLedgerDto purchaseLedgerDto = new PurchaseLedgerDto(); |
| | | purchaseLedgerDto.setApprovalStatus(3); |
| | | IPage<PurchaseLedgerDto> purchaseLedgerDtoIPage = purchaseLedgerService.selectPurchaseLedgerListPage(new Page(1, -1), purchaseLedgerDto); |
| | | List<PurchaseLedgerDto> purchaseLedgers = purchaseLedgerDtoIPage.getRecords(); |
| | | |
| | | List<PurchaseLedgerTemplate> purchaseLedgers = purchaseLedgerTemplateMapper.selectList(null); |
| | | purchaseLedgers.forEach(purchaseLedgerDto1 -> { |
| | | LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(SalesLedgerProduct::getSalesLedgerId, purchaseLedgerDto1.getId()) |
| | | .eq(SalesLedgerProduct::getType, 2); |
| | | List<SalesLedgerProduct> list = salesLedgerProductService.list(queryWrapper); |
| | | LambdaQueryWrapper<SalesLedgerProductTemplate> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(SalesLedgerProductTemplate::getSalesLedgerId, purchaseLedgerDto1.getId()) |
| | | .eq(SalesLedgerProductTemplate::getType, 2); |
| | | List<SalesLedgerProductTemplate> list = salesLedgerProductTemplateMapper.selectList(queryWrapper); |
| | | if (!list.isEmpty()) { |
| | | purchaseLedgerDto1.setProductData(list); |
| | | purchaseLedgerDto1.setProductList(list); |
| | | } |
| | | }); |
| | | return AjaxResult.success(purchaseLedgers); |
| | |
| | | */ |
| | | @GetMapping("/listPage") |
| | | public AjaxResult listPage(Page page, PurchaseLedgerDto purchaseLedger) { |
| | | IPage<PurchaseLedgerDto> purchaseLedgerDtoIPage = purchaseLedgerService.selectPurchaseLedgerListPage(page ,purchaseLedger); |
| | | //过滤掉approvalStatus=3的记录 |
| | | purchaseLedgerDtoIPage.getRecords().removeIf(purchaseLedgerDto -> purchaseLedgerDto.getApprovalStatus() == 3); |
| | | return AjaxResult.success(purchaseLedgerDtoIPage); |
| | | return AjaxResult.success(purchaseLedgerService.selectPurchaseLedgerListPage(page, purchaseLedger)); |
| | | } |
| | | |
| | | @ApiOperation("生成采购序列号") |