发票管理-关联凭证 支持一次性关联多张

new
parent b4a4004474
commit daefbf3e43

@ -15,6 +15,7 @@ import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import liquibase.pro.packaged.A; import liquibase.pro.packaged.A;
import me.zhyd.oauth.log.Log; import me.zhyd.oauth.log.Log;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -83,6 +84,23 @@ public class InvoicesController {
return success(true); return success(true);
} }
@PutMapping("/update/array")
@Operation(summary = "更新发票")
@PreAuthorize("@ss.hasPermission('accounting:invoices:update')")
public CommonResult<Boolean> updateInvoicesArray(@Valid @RequestBody InvoicesUpdateArray updateArray) {
List<InvoicesDO> list = new LinkedList<>();
List<InvoicesDO> 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") @DeleteMapping("/delete")
@Operation(summary = "删除发票") @Operation(summary = "删除发票")
@Parameter(name = "id", description = "编号", required = true) @Parameter(name = "id", description = "编号", required = true)

@ -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;
}

@ -28,6 +28,9 @@ public interface InvoicesService {
*/ */
void updateInvoices(@Valid InvoicesUpdateReqVO updateReqVO); void updateInvoices(@Valid InvoicesUpdateReqVO updateReqVO);
void updateInvoicesArray(@Valid List<InvoicesDO> list);
/** /**
* *
* *

@ -47,6 +47,11 @@ public class InvoicesServiceImpl implements InvoicesService {
invoicesMapper.updateById(updateObj); invoicesMapper.updateById(updateObj);
} }
@Override
public void updateInvoicesArray(List<InvoicesDO> list) {
invoicesMapper.updateBatch(list,list.size());
}
@Override @Override
public void deleteInvoices(Long[] id) { public void deleteInvoices(Long[] id) {

Loading…
Cancel
Save