From daefbf3e4310c12be265c136ed5241c74bef43e4 Mon Sep 17 00:00:00 2001 From: "LAPTOP-0SF788NU\\admin" <3306174053@qq.com> Date: Mon, 6 Nov 2023 16:41:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E7=A5=A8=E7=AE=A1=E7=90=86-=E5=85=B3?= =?UTF-8?q?=E8=81=94=E5=87=AD=E8=AF=81=20=20=E6=94=AF=E6=8C=81=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E6=80=A7=E5=85=B3=E8=81=94=E5=A4=9A=E5=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/invoices/InvoicesController.java | 18 ++++++++++++++++ .../invoices/vo/InvoicesUpdateArray.java | 21 +++++++++++++++++++ .../service/invoices/InvoicesService.java | 3 +++ .../service/invoices/InvoicesServiceImpl.java | 5 +++++ 4 files changed, 47 insertions(+) create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/vo/InvoicesUpdateArray.java diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java index a69be58e..751edf37 100644 --- a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java @@ -15,6 +15,7 @@ import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONObject; import liquibase.pro.packaged.A; import me.zhyd.oauth.log.Log; +import org.springframework.beans.BeanUtils; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; @@ -83,6 +84,23 @@ public class InvoicesController { return success(true); } + @PutMapping("/update/array") + @Operation(summary = "更新发票") + @PreAuthorize("@ss.hasPermission('accounting:invoices:update')") + public CommonResult updateInvoicesArray(@Valid @RequestBody InvoicesUpdateArray updateArray) { + List list = new LinkedList<>(); + List invoicesList = invoicesService.getInvoicesList(Arrays.asList(updateArray.getId())); + for (InvoicesDO in : invoicesList) { + if (in.getVoucherId() !=null){ + return error(in.getVoucherId()+":该发票已被关联"); + } + in.setVoucherId(updateArray.getVoucherId()); + list.add(in); + } + invoicesService.updateInvoicesArray(list); + return success(true); + } + @DeleteMapping("/delete") @Operation(summary = "删除发票") @Parameter(name = "id", description = "编号", required = true) diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/vo/InvoicesUpdateArray.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/vo/InvoicesUpdateArray.java new file mode 100644 index 00000000..baea44cf --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/vo/InvoicesUpdateArray.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.invoices.vo; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 发票批量绑定关联凭证vo + */ +@Data +public class InvoicesUpdateArray { + + @Schema(description = "发票id", requiredMode = Schema.RequiredMode.REQUIRED, example = "5466") + private Long[] id; + + @Schema(description = "凭证id,一个凭证对应多个电子发票", requiredMode = Schema.RequiredMode.REQUIRED, example = "25675") + private Long voucherId; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/invoices/InvoicesService.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/invoices/InvoicesService.java index d92ccf11..41ae9226 100644 --- a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/invoices/InvoicesService.java +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/invoices/InvoicesService.java @@ -28,6 +28,9 @@ public interface InvoicesService { */ void updateInvoices(@Valid InvoicesUpdateReqVO updateReqVO); + void updateInvoicesArray(@Valid List list); + + /** * 删除发票 * diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/invoices/InvoicesServiceImpl.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/invoices/InvoicesServiceImpl.java index 37f09dba..3cac699a 100644 --- a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/invoices/InvoicesServiceImpl.java +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/invoices/InvoicesServiceImpl.java @@ -47,6 +47,11 @@ public class InvoicesServiceImpl implements InvoicesService { invoicesMapper.updateById(updateObj); } + @Override + public void updateInvoicesArray(List list) { + invoicesMapper.updateBatch(list,list.size()); + } + @Override public void deleteInvoices(Long[] id) {