diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/VoucherController.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/VoucherController.java index ebdb7bb5..eb053787 100644 --- a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/VoucherController.java +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/VoucherController.java @@ -22,7 +22,9 @@ import cn.iocoder.yudao.module.accounting.service.invoices.InvoicesService; import cn.iocoder.yudao.module.setting.service.passwords.PasswordsService; import com.alibaba.fastjson.JSONObject; import org.springframework.web.bind.annotation.*; + import javax.annotation.Resource; + import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; import io.swagger.v3.oas.annotations.tags.Tag; @@ -44,6 +46,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; + import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; import cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo.*; @@ -79,7 +82,7 @@ public class VoucherController { VoucherExportReqVO vo = new VoucherExportReqVO(); vo.setVoucherNum(createReqVO.getVoucherNum()); List voucherList = voucherService.getVoucherList(vo); - if (voucherList.size()>0){ + if (voucherList.size() > 0) { return error("凭证号重复!"); } return success(voucherService.createVoucher(createReqVO)); @@ -98,11 +101,11 @@ public class VoucherController { @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('accounting:voucher:delete')") public CommonResult deleteVoucher(@RequestParam("id") Long[] id) { - List listId = new ArrayList(Arrays.asList(id)) ; + List listId = new ArrayList(Arrays.asList(id)); List voucherList = voucherService.getVoucherList(listId); - for (VoucherDO voucher : voucherList) { - if (voucher.getFileStatus().equals(AccountingStatusEnum.LOGFILE.getValue())){ - return error("凭证号:"+voucher.getVoucherNum()+" 该凭证已归档,请勿删除!"); + for (VoucherDO voucher : voucherList) { + if (voucher.getFileStatus().equals(AccountingStatusEnum.LOGFILE.getValue())) { + return error("凭证号:" + voucher.getVoucherNum() + " 该凭证已归档,请勿删除!"); } } voucherService.deleteVoucher(id); @@ -134,7 +137,7 @@ public class VoucherController { PageResult pageResult = voucherService.getVoucherPage(pageVO); PageResult voucherRespVOPageResult = VoucherConvert.INSTANCE.convertPage(pageResult); String jsonString = JSONObject.toJSONString(voucherRespVOPageResult); - passwordsService.jsonToXmlConverter(response,pageVO.getInputPassword(),jsonString); + passwordsService.jsonToXmlConverter(response, pageVO.getInputPassword(), jsonString); } @GetMapping("/page") @@ -142,14 +145,14 @@ public class VoucherController { @PreAuthorize("@ss.hasPermission('accounting:voucher:query')") public CommonResult> getVoucherPage(@Valid VoucherPageReqVO pageVO) { PageResult pageResult = voucherService.getVoucherPage(pageVO); - int i=0; + int i = 0; - //完整性检查 + //完整性检查,并设置会计凭证的完整性 List list = pageResult.getList(); - for (VoucherDO voucherDO:list - ) { + for (VoucherDO voucherDO : list + ) { //如果未归档才检查完整性 - if(!voucherDO.getFileStatus().equals(AccountingStatusEnum.LOGFILE.getValue())) { + if (!voucherDO.getFileStatus().equals(AccountingStatusEnum.LOGFILE.getValue())) { String remark = " "; Long id = voucherDO.getId(); AttachmentExportReqVO attachmentExportReqVO = new AttachmentExportReqVO(); @@ -193,7 +196,7 @@ public class VoucherController { voucherUpdateReqVO.setCherks(voucherDO.getCherks()); voucherUpdateReqVO.setRemark(remark); voucherService.updateVoucher(voucherUpdateReqVO); - }else { + } else { VoucherUpdateReqVO voucherUpdateReqVO = new VoucherUpdateReqVO(); voucherUpdateReqVO.setId(voucherDO.getId()); voucherUpdateReqVO.setCherks(Integer.valueOf(AccountingStatusEnum.COMPLETE.getValue())); @@ -201,9 +204,10 @@ public class VoucherController { voucherService.updateVoucher(voucherUpdateReqVO); } } - - + //查询未归档的会计凭证返回前端 + pageVO.setFileStatus(String.valueOf(0)); PageResult pageResult2 = voucherService.getVoucherPage(pageVO); + return success(VoucherConvert.INSTANCE.convertPage(pageResult2)); } @@ -212,7 +216,7 @@ public class VoucherController { @PreAuthorize("@ss.hasPermission('accounting:voucher:export')") @OperateLog(type = EXPORT) public void exportVoucherExcel(@Valid VoucherExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { + HttpServletResponse response) throws IOException { List list = voucherService.getVoucherList(exportReqVO); // 导出 Excel List datas = VoucherConvert.INSTANCE.convertList02(list);