diff --git a/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/EntryCommandServiceImpl.java b/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/EntryCommandServiceImpl.java index 64a79c91a5475597269c265360e03e51f56d5a61..8b7658469129aff5978ae6291c6ded5a2ccc7e0f 100644 --- a/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/EntryCommandServiceImpl.java +++ b/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/EntryCommandServiceImpl.java @@ -40,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -123,6 +124,7 @@ public class EntryCommandServiceImpl implements EntryCommandService { //pdf List<VchDetailEntity> detailList = voucherAggregate.getVchDetailList(); detailList.forEach(t->{ + t.setCustomerSupplierName(incomeAggregate.getPaymentAccount().getAccountName()); t.setBillNo(incomeAggregate.getReceiptBillVo().getBillNo()); }); push(Arrays.asList(incomeAggregate),detailList,"鏆傚瓨鍏ヨ处",true,map); @@ -184,6 +186,7 @@ public class EntryCommandServiceImpl implements EntryCommandService { //PDF List<VchDetailEntity> detailList = voucherAggregate.getVchDetailList(); detailList.forEach(t->{ + t.setCustomerSupplierName(incomeAggregate.getPaymentAccount().getAccountName()); t.setBillNo(incomeAggregate.getReceiptBillVo().getBillNo()); }); push(Arrays.asList(incomeAggregate),detailList,"鏀跺叆鍏ヨ处",voucher,map); @@ -232,6 +235,7 @@ public class EntryCommandServiceImpl implements EntryCommandService { //PDF List<VchDetailEntity> detailList = voucherAggregate.getVchDetailList(); detailList.forEach(t->{ + t.setCustomerSupplierName(incomeAggregate.getPaymentAccount().getAccountName()); t.setBillNo(incomeAggregate.getReceiptBillVo().getBillNo()); }); push(Arrays.asList(incomeAggregate),detailList,"鏀跺叆鍏ヨ处",true,map); @@ -355,6 +359,7 @@ public class EntryCommandServiceImpl implements EntryCommandService { //PDF List<VchDetailEntity> detailList = voucherAggregate.getVchDetailList(); detailList.forEach(t->{ + t.setCustomerSupplierName(incomeAggregate.getPaymentAccount().getAccountName()); t.setBillNo(incomeAggregate.getReceiptBillVo().getBillNo()); }); push(Arrays.asList(incomeAggregate),detailList,"鏀跺叆鍏ヨ处",voucher,map); @@ -413,6 +418,7 @@ public class EntryCommandServiceImpl implements EntryCommandService { //PDF List<VchDetailEntity> detailList = voucherAggregate.getVchDetailList(); detailList.forEach(t->{ + t.setCustomerSupplierName(incomeAggregate.getPaymentAccount().getAccountName()); t.setBillNo(incomeAggregate.getReceiptBillVo().getBillNo()); }); push(Arrays.asList(incomeAggregate),detailList,"鏀跺叆鍏ヨ处",voucher,map); @@ -485,6 +491,7 @@ public class EntryCommandServiceImpl implements EntryCommandService { //PDF List<VchDetailEntity> detailList = voucherAggregate.getVchDetailList(); detailList.forEach(t->{ + t.setCustomerSupplierName(incomeAggregate.getPaymentAccount().getAccountName()); t.setBillNo(incomeAggregate.getReceiptBillVo().getBillNo()); }); push(Arrays.asList(incomeAggregate),detailList,"鏀跺叆鍏ヨ处",voucher,map); @@ -531,6 +538,7 @@ public class EntryCommandServiceImpl implements EntryCommandService { //鎺ㄩ€侀檮浠跺拰鐢宠鍗� List<VchDetailEntity> detailList = voucherAggregate.getVchDetailList(); detailList.forEach(t->{ + t.setCustomerSupplierName(incomeAggregate.getPaymentAccount().getAccountName()); t.setBillNo(incomeAggregate.getReceiptBillVo().getBillNo()); }); push(Arrays.asList(incomeAggregate),detailList,"鏀跺叆鍏ヨ处",true,map); @@ -562,6 +570,7 @@ public class EntryCommandServiceImpl implements EntryCommandService { Long voucherId = voucherRepository.save(voucherAggregate); List<VchDetailEntity> detailList = voucherAggregate.getVchDetailList(); detailList.forEach(t->{ + t.setCustomerSupplierName(incomeAggregate.getPaymentAccount().getAccountName()); t.setBillNo(incomeAggregate.getReceiptBillVo().getBillNo()); }); //3 鍏ヨ处淇濆瓨 @@ -608,21 +617,42 @@ public class EntryCommandServiceImpl implements EntryCommandService { } catch (DocumentException e) { throw new RuntimeException(e); } + BigDecimal vouTotalAmount = calculateTotalSum(detailList); if(voucher){ - map.keySet().forEach(entryBillFlowId->{ - IncomeAggregate incomeAggregate = map.get(entryBillFlowId); - VoucherTo to; - to = new VoucherTo( - entryBillFlowId+"",userName, "", + if(batch){ + VoucherTo to = new VoucherTo( + batchId+"", + userName, + "", personName, - incomeAggregate.getPaymentAccount().getAccountName(), - incomeAggregate.getReceiptBillVo().getBillNo()); + "", + "");//杩欎釜鍙傛暟鏃犵敤 + voucherUtil.createOutVoucher(to,vouTotalAmount,detailList); + }else{ + map.keySet().forEach(entryBillFlowId->{ + IncomeAggregate incomeAggregate = map.get(entryBillFlowId); + VoucherTo to = new VoucherTo( + entryBillFlowId+"",userName, "", + personName, + incomeAggregate.getPaymentAccount().getAccountName(), + incomeAggregate.getReceiptBillVo().getBillNo()); if(smallTitle.equals("鏆傚瓨鍏ヨ处")){ to.setAttrPersonNo(userInfoUtil.getLoginInfoOut().getUserName()); to.setBillNo(incomeAggregate.getReceiptBillVo().getBillNo()); } - voucherUtil.createOutVoucher(to,incomeAggregate.getIncomeAmount(),detailList); + voucherUtil.createOutVoucher(to,vouTotalAmount,detailList); }); + } } } + private BigDecimal calculateTotalSum(List<VchDetailEntity> list) { + // 璁$畻鍊熸柟鍜岃捶鏂圭殑鎬诲拰锛屽鐞� null 鍊硷紝骞舵渶缁堣繑鍥炲€熸柟鍜岃捶鏂圭殑鎬诲拰涔嬪拰 + return list.stream() + .map(entity -> { + BigDecimal deAmount = entity.getDeAmount() != null ? entity.getDeAmount() : BigDecimal.ZERO; + BigDecimal crAmount = entity.getCrAmount() != null ? entity.getCrAmount() : BigDecimal.ZERO; + return deAmount.add(crAmount); + }) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } } diff --git a/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/InvoiceCommandServieceImpl.java b/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/InvoiceCommandServieceImpl.java index 94aacf1f144aa86cb0c8838d47cc7782a0f27ba1..1133e549ca4b352708a89dbd1f9487ae0dd84ccb 100644 --- a/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/InvoiceCommandServieceImpl.java +++ b/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/InvoiceCommandServieceImpl.java @@ -508,6 +508,7 @@ public class InvoiceCommandServieceImpl extends BaseCommandAbstractService<Invoi Long voucherId = voucherRepository.save(voucherAggregate); List<VchDetailEntity> detailList = voucherAggregate.getVchDetailList(); detailList.forEach(t->{ + t.setCustomerSupplierName(incomeAggregate.getPaymentAccount().getAccountName()); t.setBillNo(incomeAggregate.getReceiptBillVo().getBillNo()); }); UserInfoOut infoOut = userInfoUtil.getLoginInfoOut(); @@ -533,7 +534,8 @@ public class InvoiceCommandServieceImpl extends BaseCommandAbstractService<Invoi person, incomeAggregate.getPaymentAccount().getAccountName(), incomeAggregate.getReceiptBillVo().getBillNo()); - voucherUtil.createOutVoucher(to,incomeAggregate.getIncomeAmount(),detailList); + BigDecimal totalSum = calculateTotalSum(detailList); + voucherUtil.createOutVoucher(to,totalSum,detailList); try { FileUtil.downloadVoucherPDF("鏀跺叆鍏ヨ处", userName, Arrays.asList(incomeAggregate),false,entryBillFlowId); } catch (IOException e) { @@ -607,13 +609,15 @@ public class InvoiceCommandServieceImpl extends BaseCommandAbstractService<Invoi String person = infoOut.getUserName()+"-"+infoOut.getPersonName(); List<VchDetailEntity> detailList = voucherAggregate.getVchDetailList(); detailList.forEach(t->{ + t.setCustomerSupplierName(incomeAggregate.getPaymentAccount().getAccountName()); t.setBillNo(incomeAggregate.getReceiptBillVo().getBillNo()); }); VoucherTo to = new VoucherTo(entryBillFlowId+"",userName, "", person, incomeAggregate.getPaymentAccount().getAccountName(), incomeAggregate.getReceiptBillVo().getBillNo()); - voucherUtil.createOutVoucher(to,incomeAggregate.getIncomeAmount(),detailList); + BigDecimal totalSum = calculateTotalSum(detailList); + voucherUtil.createOutVoucher(to,totalSum,detailList); try { FileUtil.downloadVoucherPDF("琛ュ紑绁ㄥ叆璐�", userName, Arrays.asList(incomeAggregate),false,entryBillFlowId); } catch (IOException e) { @@ -700,4 +704,14 @@ public class InvoiceCommandServieceImpl extends BaseCommandAbstractService<Invoi } return resMap; } + private BigDecimal calculateTotalSum(List<VchDetailEntity> list) { + // 璁$畻鍊熸柟鍜岃捶鏂圭殑鎬诲拰锛屽鐞� null 鍊硷紝骞舵渶缁堣繑鍥炲€熸柟鍜岃捶鏂圭殑鎬诲拰涔嬪拰 + return list.stream() + .map(entity -> { + BigDecimal deAmount = entity.getDeAmount() != null ? entity.getDeAmount() : BigDecimal.ZERO; + BigDecimal crAmount = entity.getCrAmount() != null ? entity.getCrAmount() : BigDecimal.ZERO; + return deAmount.add(crAmount); + }) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } } diff --git a/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/assembler/VchDetailAssembler.java b/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/assembler/VchDetailAssembler.java index 56fe8b717cd6811e785cdb8b6e31a424354da60b..451749b36290078aec891685fe4c0d84cd9452cf 100644 --- a/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/assembler/VchDetailAssembler.java +++ b/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/assembler/VchDetailAssembler.java @@ -31,6 +31,7 @@ public class VchDetailAssembler { object.getBigDecimal("deAmount"), object.getBigDecimal("crAmount"), object.getString("vouSummary"), + "", "" ); list.add(vchDetailEntity); diff --git a/ServiceSite/src/main/java/com/seasky/ledgerincome/domain/aggregate/voucher/VchDetailEntity.java b/ServiceSite/src/main/java/com/seasky/ledgerincome/domain/aggregate/voucher/VchDetailEntity.java index 4a4aad5420c2671fc256e275e21bab4f925431ad..5a3569e162b5099dbfc8c52c9a7810790e3c79d8 100644 --- a/ServiceSite/src/main/java/com/seasky/ledgerincome/domain/aggregate/voucher/VchDetailEntity.java +++ b/ServiceSite/src/main/java/com/seasky/ledgerincome/domain/aggregate/voucher/VchDetailEntity.java @@ -46,4 +46,6 @@ public class VchDetailEntity { //寰€鏉ュ彿 private String billNo; + + private String customerSupplierName; } diff --git a/ServiceSite/src/main/java/com/seasky/ledgerincome/utils/VoucherUtil.java b/ServiceSite/src/main/java/com/seasky/ledgerincome/utils/VoucherUtil.java index 50ecb49732d8e5285abfbfd4d4d6ea8d629a767b..b2c99416642106ace974bad38a8d7754ad4afdb9 100644 --- a/ServiceSite/src/main/java/com/seasky/ledgerincome/utils/VoucherUtil.java +++ b/ServiceSite/src/main/java/com/seasky/ledgerincome/utils/VoucherUtil.java @@ -476,6 +476,7 @@ public class VoucherUtil { JSONObject stationObj = JSONObject.parseObject(s); return stationObj; } + //vouTotalAmount 鍊熻捶鍚堣閲戦 public JSONObject createOutVoucher(VoucherTo voucherTo, BigDecimal vouTotalAmount, List<VchDetailEntity> vchDetailEntityList){ String path=propertyUtil.getInnerInterfacePath(); String secret = propertyUtil.getSecret(); @@ -517,9 +518,9 @@ public class VoucherUtil { m.put("deorcr",item.getDeorcr()); m.put("summary",item.getSummery()); m.put("remark1",voucherTo.getOutOrderNo()); - m.put("BillNo",voucherTo.getBillNo());//寰€鏉ュ彿 + m.put("BillNo",item.getBillNo());//寰€鏉ュ彿 m.put("AttrPersonNo",voucherTo.getAttrPersonNo());//缁忓姙浜哄伐鍙� - m.put("CustomerSupplierName",voucherTo.getCustomerSupplierName());//浠樻敞鍗曚綅鍚嶇О + m.put("CustomerSupplierName",item.getCustomerSupplierName());//浠樻敞鍗曚綅鍚嶇О detailInfo.add(m); } input.put("headerInfo",headerInfo);