领域驱动设计 用DDD重构会计凭证生成(下)( 九 )

feeMap;List appendAccountDocumentDetails;for (AdAccountRuleSubjectPO ruleSubject : rule.getRuleSubjects()) {log.info("按借贷关系的科目生成分录明细:借方:{} , 贷方:{}", ruleSubject.getDebitSubjectCode(), ruleSubject.getCreditSubjectCode());entrySeq = entrySeq + detailNum;//借方科目detailNum = this.saveAccountDocumentDetail(ruleSubject.getDebitSubjectCode(), AdConstants.DC_FLAG_DEBIT, vo, amount.getAmountValue(), entrySeq, accountDocumentInfo, ruleSubject.getDebitAbstractRulePO());entrySeq = entrySeq + detailNum;//贷方科目detailNum = this.saveAccountDocumentDetail(ruleSubject.getCreditSubjectCode(), AdConstants.DC_FLAG_CREDIT, vo, amount.getAmountValue(), entrySeq, accountDocumentInfo, ruleSubject.getCreditAbstractRulePO());//发票生成的应付借方补充凭证entrySeq = entrySeq + detailNum;if (AmountTypeEnum.BILL_AMOUNT.getVoucherType().equals(accountDocumentInfo.getVoucherType())//应付&& AdConstants.SPECIAL_ACC_SUBJECT_CODE_FEES.equals(ruleSubject.getDebitSubjectCode())) { //借方log.info("发票生成的应付借方补充凭证:{}==={}", accountDocumentInfo.getVoucherType(), ruleSubject.getDebitSubjectCode());feeMap = vo.getFeeMap();appendAccountDocumentDetails = this.appendInvoiceAccountDocumentDetails(feeMap, AdConstants.DC_FLAG_DEBIT, vo, entrySeq, accountDocumentInfo, ruleSubject.getDebitAbstractRulePO());if (!CollectionUtils.isEmpty(appendAccountDocumentDetails)) {this.saveAccountDocumentDetail(vo, appendAccountDocumentDetails);entrySeq = entrySeq + appendAccountDocumentDetails.size();}}if (BillTypeKindConstants.BILL_TYPE_KIND_PURCHASE.equals(vo.getBillTypeKind()) //采购单&& "0".equals(vo.getSupplierArea())) { //供应商是境内log.info("发票生成的应收贷方补充凭证:{}==={}", vo.getBillTypeKind(), vo.getSupplierArea());entrySeq = entrySeq + detailNum;if (AmountTypeEnum.RETURN_AMOUNT.getVoucherType().equals(accountDocumentInfo.getVoucherType())//应收&& AdConstants.SPECIAL_ACC_SUBJECT_CODE_FEES.equals(ruleSubject.getCreditSubjectCode())) { //贷方feeMap = vo.getFeeMap();appendAccountDocumentDetails = this.appendInvoiceAccountDocumentDetails(feeMap, AdConstants.DC_FLAG_CREDIT, vo, entrySeq, accountDocumentInfo, ruleSubject.getCreditAbstractRulePO());if (!CollectionUtils.isEmpty(appendAccountDocumentDetails)) {this.saveAccountDocumentDetail(vo, appendAccountDocumentDetails);entrySeq = entrySeq + appendAccountDocumentDetails.size();}}}}accountDocumentInfo.setEasVoucherType(this.getEasVoucherType(accountDocumentInfo.getId(), null));adAccountDocumentInfoService.update(accountDocumentInfo);}}return generateFlag;}...}

领域驱动设计  用DDD重构会计凭证生成(下)

文章插图
public class PushVoucherLogicImpl implements PushVoucherLogic {@Overridepublic ResponseBuilder pushVoucherByBillNo(String billNo, Integer pushType, Long operatorId, String operatorName) {log.info("根据单据编号推送凭证 , 单据编号:{} , 推送分类:{}", billNo, pushType);List pushStatusList = new ArrayList<>();pushStatusList.add(PushStatusEnum.PUSH_UNSENT.getStatus());pushStatusList.add(PushStatusEnum.PUSH_FAIL.getStatus());List documentPOList = getAdAccountDocumentList(billNo);if (CollectionUtils.isEmpty(documentPOList)) {log.info("根据单据编号推送凭证 , 单据编号:{} , 推送分类:{} , 未获取到凭证信息", billNo, pushType);return ResponseBuilder.ok().setErrorMsg("根据单号:" + billNo + " , 推送分类:" + pushType + " , 未获取到凭证信息").setErrorCode("9999");}documentPOList.forEach(adAccountDocumentPO -> {AdAccountDocumentInfoQueryVO documentInfoQueryVO = new AdAccountDocumentInfoQueryVO();documentInfoQueryVO.setVoucherMainId(adAccountDocumentPO.getId());documentInfoQueryVO.setPushStatusList(pushStatusList);documentInfoQueryVO.setPushType(pushType);List documentInfoPOList = documentInfoService.query(documentInfoQueryVO);if (CollectionUtils.isEmpty(documentInfoPOList)) {return;}adQueryService.queryAdAccountDocumentDetail(documentInfoPOList);adAccountDocumentPO.setAdAccountDocumentInfoPOList(documentInfoPOList);});ResponseBuilder res = batchPushVoucher(documentPOList, operatorId, operatorName, true);return res;}private ResponseBuilder batchPushVoucher(List documentPOList, Long operatorId, String operatorName, boolean monitorFlag) {if (CollectionUtils.isEmpty(documentPOList)) {log.error("凭证批量推送时 , 入参documentPOList为空");return ResponseBuilder.FAILURE.setErrorMsg("会计凭证信息不能为空");}// EAS登录认证Result loginResult = easLoginService.login();if (!loginResult.isSuccess()) {this.batchUpdateFailWhenEasLoginFail(documentPOList, operatorId, operatorName, loginResult.getError().getErrorMessage(), monitorFlag);return ResponseBuilder.FAILURE.setErrorMsg(loginResult.getError().getErrorMessage());}List errorMessageList = new ArrayList