From c427840445fefb679a287dbeaba81bd417388aeb Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期五, 04 九月 2026 17:10:44 +0800
Subject: [PATCH] feat:开票和bip推送分离 新增bip报账单 新增合同标的物变更
---
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java | 694 +++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 476 insertions(+), 218 deletions(-)
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java
index 9085c51..7724343 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java
@@ -5,8 +5,9 @@
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.io.StreamProgress;
-import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.core.lang.tree.Tree;
+import cn.hutool.core.lang.tree.TreeNode;
+import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
@@ -21,10 +22,7 @@
import com.by4cloud.platformx.admin.api.feign.RemoteDeptService;
import com.by4cloud.platformx.business.api.feign.RemoteFlowProcessService;
import com.by4cloud.platformx.business.constant.FlowNameEnum;
-import com.by4cloud.platformx.business.dto.ContractInvoiceQueryDTO;
-import com.by4cloud.platformx.business.dto.ContractQueryDTO;
-import com.by4cloud.platformx.business.dto.GenInvoiceInfoDTO;
-import com.by4cloud.platformx.business.dto.InvoiceQueryDTO;
+import com.by4cloud.platformx.business.dto.*;
import com.by4cloud.platformx.business.entity.*;
import com.by4cloud.platformx.business.mapper.*;
import com.by4cloud.platformx.business.service.ContractInvoiceService;
@@ -37,6 +35,7 @@
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
@@ -69,6 +68,8 @@
private final RemoteFlowProcessService remoteFlowProcessService;
private final PaymentConfirmService paymentConfirmService;
private final StringRedisTemplate redisTemplate;
+ private final BipViewMapper bipViewMapper;
+ private final BipDictMapper bipDictMapper;
@Value("${BWInvoice.url}")
@@ -80,11 +81,26 @@
@Value("${bip.url}")
private String url;
- @Value("${bip.appKey}")
- private String appKey;
+ @Value("${dept.sgb}")
+ private String sgb;
- @Value("${bip.appSecret}")
- private String appSecret;
+ @Value("${dept.smj}")
+ private String smj;
+
+ @Value("${dept.smjzt}")
+ private String smjzt;
+
+ @Value("${dept.smjsc}")
+ private String smjsc;
+
+ @Value("${dept.tfgs}")
+ private String tfgs;
+
+ @Value("${dept.jxc}")
+ private String jxc;
+
+ @Value("${dept.ymj}")
+ private String ymj;
@Value("${file.path}")
private String localPath;
@@ -104,13 +120,16 @@
.eq(ContractSubjectMatter::getMaterialCode, contractInvoiceOutBoundVo.getSubjectMatterCode())
.eq(StrUtil.isNotBlank(contractInvoiceOutBoundVo.getLineNo()), ContractSubjectMatter::getLineNo, contractInvoiceOutBoundVo.getLineNo())
.last("limit 1"));
- if (ObjUtil.isNotNull(subjectMatter) && subjectMatter.getAdvanceNum().compareTo(new BigDecimal("0")) > 0) {
- contractInvoiceOutBoundVo.setInvoiceNum(contractInvoiceOutBoundVo.getOutBoundNum().subtract(subjectMatter.getAdvanceNum()));
+ if (ObjUtil.isNotNull(subjectMatter)) {
+ contractInvoiceOutBoundVo.setUnitPrice(subjectMatter.getUnitPrice());
+ if (subjectMatter.getAdvanceNum().compareTo(new BigDecimal("0")) > 0) {
+ contractInvoiceOutBoundVo.setInvoiceNum(contractInvoiceOutBoundVo.getOutBoundNum().subtract(subjectMatter.getAdvanceNum()));
+ }
}
contractInvoiceOutBoundVo.setToInvoiceNum(contractInvoiceOutBoundVo.getInvoiceNum());
});
}
- return R.ok(invoiceOutBoundVoList);
+ return R.ok(invoiceOutBoundVoList.stream().filter(item->item.getUnitPrice().compareTo(new BigDecimal("0"))>0).collect(Collectors.toList()));
}
@Override
@@ -122,13 +141,13 @@
.selectAs(ContractSubjectMatter::getQuantity, "outBoundNum")
.eq(ContractSubjectMatter::getContractId, contractId);
List<ContractInvoiceOutBoundVo> invoiceOutBoundVoList = contractSubjectMatterMapper.selectJoinList(ContractInvoiceOutBoundVo.class, wrapper);
- if (ArrayUtil.isNotEmpty(invoiceOutBoundVoList)) {
+ if (CollUtil.isNotEmpty(invoiceOutBoundVoList)) {
invoiceOutBoundVoList.stream().forEach(contractInvoiceOutBoundVo -> {
contractInvoiceOutBoundVo.setInvoiceNum(contractInvoiceOutBoundVo.getOutBoundNum().subtract(contractInvoiceOutBoundVo.getAdvanceNum()));
contractInvoiceOutBoundVo.setToInvoiceNum(contractInvoiceOutBoundVo.getInvoiceNum());
});
}
- return R.ok(invoiceOutBoundVoList);
+ return R.ok(invoiceOutBoundVoList.stream().filter(item->item.getUnitPrice().compareTo(new BigDecimal("0"))>0).collect(Collectors.toList()));
}
@Override
@@ -145,6 +164,11 @@
public R genInvoiceInfo(GenInvoiceInfoDTO genInvoiceInfoDTO) {
if (CollUtil.isEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList())) {
return R.failed("璇烽�夋嫨寮�绁ㄥ嚭搴撳崟鍚庡啀鎿嶄綔");
+ }
+ genInvoiceInfoDTO.setOutBoundInvoiceList(genInvoiceInfoDTO.getOutBoundInvoiceList().stream().filter(item->
+ item.getInvoiceNum().compareTo(new BigDecimal("0"))>0).collect(Collectors.toList()));
+ if (CollUtil.isEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList())) {
+ return R.failed("璇烽�夋嫨寮�绁ㄥ嚭搴撳崟鍚庢垨璋冩暣寮�绁ㄦ暟閲忓啀鎿嶄綔");
}
Long contractId = null;
//棰勬敹娆惧紑绁�
@@ -164,6 +188,10 @@
return R.failed("鑾峰彇寮�绁ㄥ崟浣嶅紓甯�");
}
SysDept b = r.getData();
+ BusinessCustomer customer = businessCustomerMapper.selectById(contract.getPartyAId());
+ if (ObjUtil.isNull(customer)){
+ return R.failed("鑾峰彇璐柟鍗曚綅寮傚父");
+ }
BigDecimal advanceAmount = new BigDecimal("0");
for (ContractOutBoundInvoiceVo contractOutBoundInvoiceVo : genInvoiceInfoDTO.getOutBoundInvoiceList()) {
ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
@@ -177,7 +205,7 @@
return R.failed("寮�绁ㄩ噾棰濊秴鍑哄悎鍚岀璁㈤樁娈靛簲鏀堕噾棰�:" + schedule.getPlannedAmount() + ",璇疯皟鏁村紑绁ㄦ暟閲�");
}
GenInvoiceInfoVo vo = genAdvanceInvoiceInfoVo(genInvoiceInfoDTO, contract, b);
-
+ vo = transBipVo(vo,b,customer);
return R.ok(vo);
}
@@ -198,6 +226,10 @@
return R.failed("鑾峰彇寮�绁ㄥ崟浣嶅紓甯�");
}
SysDept b = r.getData();
+ BusinessCustomer customer = businessCustomerMapper.selectById(contract.getPartyAId());
+ if (ObjUtil.isNull(customer)){
+ return R.failed("鑾峰彇璐柟鍗曚綅寮傚父");
+ }
//鏈哄姩杞﹀紑绁�
if (StrUtil.equals(genInvoiceInfoDTO.getInvoiceType(), "3") || StrUtil.equals(genInvoiceInfoDTO.getInvoiceType(), "4")) {
if (StrUtil.isBlank(genInvoiceInfoDTO.getVehicleNo())) {
@@ -213,19 +245,46 @@
return r1;
}
JSONObject request1 = genQueryVehDetailParam(genInvoiceInfoDTO.getVehicleNo(), b);
- R r2 = requestQueryVehicleDetail(request1);
+ R<JSONObject> r2 = requestQueryVehicleDetail(request1,genInvoiceInfoDTO);
if (!r2.isOk()) {
return r2;
}
+ r2.getData().put("contact",b.getOrgContact());
genInvoiceInfoDTO.setVehicleData(r2.getData().toString());
}
GenInvoiceInfoVo vo = genInvoiceInfoVo(genInvoiceInfoDTO, contract, b);
-
+ vo = transBipVo(vo,b,customer);
return R.ok(vo);
}
- private R requestQueryVehicleDetail(JSONObject request) {
+ private GenInvoiceInfoVo transBipVo(GenInvoiceInfoVo vo,SysDept comp,BusinessCustomer customer) {
+ ContractInvoiceBipVo bipVo = new ContractInvoiceBipVo();
+ bipVo.setDjrq(DateUtil.today());
+ bipVo.setKpzz(comp.getBipCode());
+ bipVo.setYwzz(comp.getBipCode());
+ R<SysDept> rDept = remoteDeptService.getById(SecurityUtils.getUser().getDeptId());
+ if (rDept.isOk()) {
+ bipVo.setBm(rDept.getData().getOrgCode());
+ bipVo.setHsdy(rDept.getData().getOrgCode());
+ }
+ bipVo.setYwy(SecurityUtils.getUser().getNickname());
+ bipVo.setPzzdr(SecurityUtils.getUser().getNickname());
+ bipVo.setJylx("ZBYXGLXT");
+ bipVo.setWldxlx("1");
+ bipVo.setKh(customer.getCreditCode());
+ bipVo.setBz("CNY");
+ bipVo.setFjzs("1");
+ bipVo.setSfzy("1");
+ bipVo.setSfnbwl("1");
+ bipVo.setSfjyjs("0");
+ bipVo.setDjfx("1");
+ bipVo.setItemList(vo.getInvoiceItemList());
+ vo.setBipVo(bipVo);
+ return vo;
+ }
+
+ private R requestQueryVehicleDetail(JSONObject request,GenInvoiceInfoDTO invoiceInfoDTO) {
String requestId = IdUtil.fastUUID();
log.info("鏈哄姩杞﹀悎鏍艰瘉鏌ヨ鎺ュ彛鍏ュ弬锛歿},", request.toJSONString());
@@ -240,6 +299,17 @@
JSONArray models = resultObj.getJSONArray("model");
if (CollUtil.isNotEmpty(models)) {
JSONObject model = (JSONObject) models.get(0);
+ if (StrUtil.isNotBlank(invoiceInfoDTO.getOrigin())) {
+ model.put("origin",invoiceInfoDTO.getOrigin());
+ }
+ if (StrUtil.isNotBlank(invoiceInfoDTO.getTonnage())) {
+ model.put("tonnage",invoiceInfoDTO.getTonnage());
+ }
+ if (StrUtil.isNotBlank(invoiceInfoDTO.getPassengersLimited())) {
+ model.put("passengersLimited",invoiceInfoDTO.getPassengersLimited());
+ }
+ model.put("origin",invoiceInfoDTO.getOrigin());
+ model.put("vehicleNo",invoiceInfoDTO.getVehicleNo());
return R.ok(model);
}
return R.failed("鏈哄姩杞﹀悎鏍艰瘉鏌ヨ寮傚父");
@@ -288,6 +358,7 @@
private GenInvoiceInfoVo genInvoiceInfoVo(GenInvoiceInfoDTO genInvoiceInfoDTO, Contract contract, SysDept b) {
GenInvoiceInfoVo vo = new GenInvoiceInfoVo();
BusinessCustomer a = businessCustomerMapper.selectById(contract.getPartyAId());
+ vo.setContractId(contract.getId());
vo.setPartyA(a.getCompanyName());
vo.setPartyAOrgCode(a.getCreditCode());
vo.setPartyAOpenBank(a.getBankName());
@@ -297,6 +368,8 @@
vo.setPartyBOpenBank(b.getOrgBank());
vo.setPartyBBankAccount(b.getOrgBankAccount());
vo.setInvoiceType(a.getInvoiceType());
+ vo.setRemarks(genInvoiceInfoDTO.getRemarks());
+ vo.setOutBoundInvoiceList(genInvoiceInfoDTO.getOutBoundInvoiceList());
if (StrUtil.isNotBlank(genInvoiceInfoDTO.getInvoiceType())) {
vo.setInvoiceVehicleType(genInvoiceInfoDTO.getInvoiceType());
}
@@ -318,24 +391,36 @@
if (CollUtil.isNotEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList())) {
genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> {
ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
-
- if (!CollUtil.contains(erpCode, contractOutBound.getSubjectMatterCode())) {
- erpCode.add(contractOutBound.getSubjectMatterCode());
+ ContractSubjectMatter subjectMatter = subjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery()
+ .eq(ContractSubjectMatter::getMaterialCode, contractOutBound.getSubjectMatterCode())
+ .eq(StrUtil.isNotBlank(contractOutBound.getLineNo()),ContractSubjectMatter::getLineNo,contractOutBound.getLineNo())
+ .eq(ContractSubjectMatter::getContractId, contract.getId()).last("limit 1"));
+ if (!CollUtil.contains(erpCode, contractOutBound.getSubjectMatterCode()+subjectMatter.getUnitPrice())) {
+ erpCode.add(contractOutBound.getSubjectMatterCode()+subjectMatter.getUnitPrice());
ContractOutBoundMergeVo mergeVo = new ContractOutBoundMergeVo();
- mergeVo.setMaterialCode(contractOutBound.getSubjectMatterCode());
+ mergeVo.setMaterialCode(contractOutBound.getSubjectMatterCode()+subjectMatter.getUnitPrice());
mergeVo.setMaterialInternalName(contractOutBound.getSubjectMatterName());
mergeVo.setQuantity(contractOutBoundInvoiceVo.getInvoiceNum());
- Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode())
- .eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1"));
+ Product product = new Product();
+ List<String> smjList = new ArrayList<>();
+ smjList.add(smj);
+ smjList.add(smjsc);
+ smjList.add(smjzt);
+ if ((""+SecurityUtils.getUser().getCompId()).equals(smj)||(""+SecurityUtils.getUser().getCompId()).equals(smjsc)||
+ (""+SecurityUtils.getUser().getCompId()).equals(smjzt)){
+ product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode())
+ .in(Product::getCompId, smjList).last("limit 1"));
+ }else {
+ product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode())
+ .eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1"));
+ }
+
if (ObjUtil.isNotNull(product)) {
mergeVo.setTaxClass(product.getTaxClass());
mergeVo.setSpecification(product.getProductType());
mergeVo.setTaxRate(new BigDecimal(product.getTaxRate()));
mergeVo.setTaxCode(product.getTaxCode());
}
- ContractSubjectMatter subjectMatter = subjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery()
- .eq(ContractSubjectMatter::getMaterialCode, contractOutBound.getSubjectMatterCode())
- .eq(ContractSubjectMatter::getContractId, contract.getId()).last("limit 1"));
if (ObjUtil.isNotNull(subjectMatter)) {
mergeVo.setUnitPrice(subjectMatter.getUnitPrice());
mergeVo.setUnit(subjectMatter.getUnit());
@@ -352,16 +437,17 @@
mergeOutBounds.add(mergeVo);
} else {
List<ContractOutBoundMergeVo> filteredList = mergeOutBounds.stream()
- .filter(item -> contractOutBound.getSubjectMatterCode().equals(item.getMaterialCode())) // 闃叉绌烘寚閽堬紝寤鸿甯搁噺鍦ㄥ墠
+ .filter(item -> item.getMaterialCode().equals(subjectMatter.getMaterialCode()+subjectMatter.getUnitPrice())) // 闃叉绌烘寚閽堬紝寤鸿甯搁噺鍦ㄥ墠
.collect(Collectors.toList());
- if (ArrayUtil.isNotEmpty(filteredList)) {
+ if (CollUtil.isNotEmpty(filteredList)) {
filteredList.get(0).setQuantity(filteredList.get(0).getQuantity().add(contractOutBound.getOutBoundNum()));
}
}
});
- if (ArrayUtil.isNotEmpty(mergeOutBounds)) {
+ if (CollUtil.isNotEmpty(mergeOutBounds)) {
invoiceItemVoList = BeanUtil.copyToList(mergeOutBounds, InvoiceItemVo.class);
- invoiceItemVoList.stream().forEach(invoiceItemVo -> {
+ invoiceItemVoList.stream().filter(invoiceItem->invoiceItem.getUnitPrice().compareTo(new BigDecimal("0"))>0)
+ .forEach(invoiceItemVo -> {
// for (InvoiceItemVo invoiceItemVo:invoiceItemVoList) {
BigDecimal itemPrice = invoiceItemVo.getUnitPrice().multiply(invoiceItemVo.getQuantity());
BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("100").add(invoiceItemVo.getTaxRate()), 2, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate());
@@ -376,7 +462,7 @@
}
}
} else {
- if (ArrayUtil.isNotEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList())) {
+ if (CollUtil.isNotEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList())) {
genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> {
ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
@@ -394,40 +480,38 @@
mergeVo.setSpecification(product.getProductType());
mergeVo.setTaxRate(new BigDecimal(product.getTaxRate()));
mergeVo.setTaxCode(product.getTaxCode());
- Product productClass = productMapper.selectById(product.getParentId());
- if (ObjUtil.isNotNull(product)) {
- if (StrUtil.equals(product.getErpCode(), "water_bill")) {
- mergeVo.setItemName("*" + product.getTaxClass() + "*姘磋垂");
- mergeVo.setUnit("鍚�");
- } else if (StrUtil.equals(product.getErpCode(), "electricity_bill")) {
- mergeVo.setItemName("*" + product.getTaxClass() + "*鐢佃垂");
- mergeVo.setUnit("搴�");
- } else if (StrUtil.equals(product.getErpCode(), "house_rental")) {
- mergeVo.setItemName("*" + product.getTaxClass() + "*鎴垮眿绉熻祦");
- } else {
- mergeVo.setItemName("*" + product.getTaxClass() + "*" + productClass.getProductName());
- }
-
- }
}
ContractSubjectMatter subjectMatter = subjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery()
.eq(ContractSubjectMatter::getMaterialCode, schedule.getSubjectMatterCode())
.eq(ContractSubjectMatter::getContractId, contract.getId()).last("limit 1"));
if (ObjUtil.isNotNull(subjectMatter)) {
mergeVo.setUnitPrice(subjectMatter.getUnitPrice());
+ if (StrUtil.equals(product.getErpCode(), "water_bill")) {
+ mergeVo.setItemName("*" + product.getTaxClass() + "*姘磋垂");
+ mergeVo.setUnit("鍚�");
+ } else if (StrUtil.equals(product.getErpCode(), "electricity_bill")) {
+ mergeVo.setItemName("*" + product.getTaxClass() + "*鐢佃垂");
+ mergeVo.setUnit("搴�");
+ } else if (StrUtil.equals(product.getErpCode(), "house_rental")) {
+ mergeVo.setItemName("*" + product.getTaxClass() + "*鎴垮眿绉熻祦");
+ } else {
+ mergeVo.setItemName("*" + product.getTaxClass() + "*" + subjectMatter.getMaterialName());
+ }
+
}
mergeOutBounds.add(mergeVo);
} else {
List<ContractOutBoundMergeVo> filterMergeVo = mergeOutBounds.stream().filter(item -> item.getMaterialCode()
.equals(schedule.getSubjectMatterCode())).collect(Collectors.toList());
- if (ArrayUtil.isNotEmpty(filterMergeVo)) {
+ if (CollUtil.isNotEmpty(filterMergeVo)) {
filterMergeVo.get(0).setPriceAndTax(schedule.getPlannedAmount().add(filterMergeVo.get(0).getPriceAndTax()));
}
}
});
- if (ArrayUtil.isNotEmpty(mergeOutBounds)) {
+ if (CollUtil.isNotEmpty(mergeOutBounds)) {
invoiceItemVoList = BeanUtil.copyToList(mergeOutBounds, InvoiceItemVo.class);
- invoiceItemVoList.stream().forEach(invoiceItemVo -> {
+ invoiceItemVoList.stream().filter(invoiceItem->invoiceItem.getUnitPrice().compareTo(new BigDecimal("0"))>0)
+ .forEach(invoiceItemVo -> {
// for (InvoiceItemVo invoiceItemVo:invoiceItemVoList) {
BigDecimal itemPrice = invoiceItemVo.getPriceAndTax();
BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("100").add(invoiceItemVo.getTaxRate()), 2, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate());
@@ -448,6 +532,7 @@
private GenInvoiceInfoVo genAdvanceInvoiceInfoVo(GenInvoiceInfoDTO genInvoiceInfoDTO, Contract contract, SysDept b) {
GenInvoiceInfoVo vo = new GenInvoiceInfoVo();
BusinessCustomer a = businessCustomerMapper.selectById(contract.getPartyAId());
+ vo.setContractId(contract.getId());
vo.setAdvanceInvoice("111");
vo.setPartyA(a.getCompanyName());
vo.setPartyAOrgCode(a.getCreditCode());
@@ -457,6 +542,8 @@
vo.setPartyBOrgCode(b.getOrgCode());
vo.setPartyBOpenBank(b.getOrgBank());
vo.setPartyBBankAccount(b.getOrgBankAccount());
+ vo.setRemarks(genInvoiceInfoDTO.getRemarks());
+ vo.setOutBoundInvoiceList(genInvoiceInfoDTO.getOutBoundInvoiceList());
List<InvoiceItemVo> invoiceItemVoList = new ArrayList<>();
List<String> erpCode = new ArrayList<>();
List<ContractOutBoundMergeVo> mergeOutBounds = new ArrayList<>();
@@ -465,7 +552,7 @@
genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> {
ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
if (ObjUtil.isNotNull(subjectMatter)) {
- if (!CollUtil.contains(erpCode, subjectMatter.getMaterialCode())) {
+ if (!CollUtil.contains(erpCode, subjectMatter.getMaterialCode()+subjectMatter.getUnitPrice())) {
erpCode.add(subjectMatter.getMaterialCode());
ContractOutBoundMergeVo mergeVo = new ContractOutBoundMergeVo();
mergeVo.setMaterialCode(subjectMatter.getMaterialCode());
@@ -478,21 +565,20 @@
mergeVo.setSpecification(product.getProductType());
mergeVo.setTaxRate(new BigDecimal(product.getTaxRate()));
mergeVo.setTaxCode(product.getTaxCode());
- Product productClass = productMapper.selectById(product.getParentId());
- if (ObjUtil.isNotNull(product)) {
- if (StrUtil.equals(product.getErpCode(), "water_bill")) {
- mergeVo.setItemName("*" + product.getTaxClass() + "*姘磋垂");
- mergeVo.setUnit("鍚�");
- } else if (StrUtil.equals(product.getErpCode(), "electricity_bill")) {
- mergeVo.setItemName("*" + product.getTaxClass() + "*鐢佃垂");
- mergeVo.setUnit("搴�");
- } else if (StrUtil.equals(product.getErpCode(), "house_rental")) {
- mergeVo.setItemName("*" + product.getTaxClass() + "*鎴垮眿绉熻祦");
- } else {
- mergeVo.setItemName("*" + product.getTaxClass() + "*" + productClass.getProductName());
- }
-
+ }
+ if (ObjUtil.isNotNull(product)) {
+ if (StrUtil.equals(product.getErpCode(), "water_bill")) {
+ mergeVo.setItemName("*" + product.getTaxClass() + "*姘磋垂");
+ mergeVo.setUnit("鍚�");
+ } else if (StrUtil.equals(product.getErpCode(), "electricity_bill")) {
+ mergeVo.setItemName("*" + product.getTaxClass() + "*鐢佃垂");
+ mergeVo.setUnit("搴�");
+ } else if (StrUtil.equals(product.getErpCode(), "house_rental")) {
+ mergeVo.setItemName("*" + product.getTaxClass() + "*鎴垮眿绉熻祦");
+ } else {
+ mergeVo.setItemName("*" + product.getTaxClass() + "*" + subjectMatter.getMaterialName());
}
+
}
mergeVo.setUnitPrice(subjectMatter.getUnitPrice());
mergeVo.setUnit(subjectMatter.getUnit());
@@ -501,9 +587,9 @@
}
});
- if (ArrayUtil.isNotEmpty(mergeOutBounds)) {
+ if (CollUtil.isNotEmpty(mergeOutBounds)) {
invoiceItemVoList = BeanUtil.copyToList(mergeOutBounds, InvoiceItemVo.class);
- invoiceItemVoList.stream().forEach(invoiceItemVo -> {
+ invoiceItemVoList.stream().filter(invoiceItem->invoiceItem.getUnitPrice().compareTo(new BigDecimal("0"))>0).forEach(invoiceItemVo -> {
// for (InvoiceItemVo invoiceItemVo:invoiceItemVoList) {
BigDecimal itemPrice = invoiceItemVo.getUnitPrice().multiply(invoiceItemVo.getQuantity());
BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("100").add(invoiceItemVo.getTaxRate()), 2, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate());
@@ -522,31 +608,18 @@
}
@Override
- public R toInvoice(GenInvoiceInfoDTO genInvoiceInfoDTO) {
- if (ArrayUtil.isEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList())) {
- return R.failed("璇烽�夋嫨寮�绁ㄥ嚭搴撳崟鍚庡啀鎿嶄綔");
+ public R toInvoice(ToInvoiceDTO toInvoiceDTO) {
+ Contract contract = contractMapper.selectById(toInvoiceDTO.getContractId());
+ if (ObjUtil.isNull(contract)) {
+ return R.failed("鍚堝悓淇℃伅寮傚父锛岃鑱旂郴鎶�鏈汉鍛�");
}
- if (StrUtil.equals(genInvoiceInfoDTO.getInvoiceType(), "3") || StrUtil.equals(genInvoiceInfoDTO.getInvoiceType(), "4")) {
- if (StrUtil.isBlank(genInvoiceInfoDTO.getVehicleNo())) {
- return R.failed("鏈哄姩杞﹀紑绁ㄨ杈撳叆杞︽灦鍙�");
- }
- BigDecimal invoiceNumSum = genInvoiceInfoDTO.getOutBoundInvoiceList().stream().map(item -> item.getInvoiceNum()).reduce(BigDecimal.ZERO, BigDecimal::add);
- if (invoiceNumSum.compareTo(new BigDecimal("1")) > 0) {
- return R.failed("鏈哄姩杞﹀紑绁ㄥ彧鑳�1娆″紑1杈�");
- }
- }
- Long contractId = null;
- if (StrUtil.isNotBlank(genInvoiceInfoDTO.getContractId())) {
+ if (StrUtil.isNotBlank(toInvoiceDTO.getAdvanceInvoice())) {
ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery()
- .eq(ContractPaymentSchedule::getStageName, "鍚堝悓绛捐").eq(ContractPaymentSchedule::getContractId, genInvoiceInfoDTO.getContractId())
+ .eq(ContractPaymentSchedule::getStageName, "鍚堝悓绛捐").eq(ContractPaymentSchedule::getContractId, toInvoiceDTO.getContractId())
.last("limit 1"));
if (ObjUtil.isNull(schedule)) {
return R.failed("鍚堝悓棰勬敹娆鹃樁娈靛紓甯革紝璇疯仈绯绘妧鏈汉鍛�");
- }
- Contract contract = contractMapper.selectById(genInvoiceInfoDTO.getContractId());
- if (ObjUtil.isNull(contract)) {
- return R.failed("鍚堝悓淇℃伅寮傚父锛岃鑱旂郴鎶�鏈汉鍛�");
}
ContractInvoice lastInvoice = baseMapper.selectOne(Wrappers.<ContractInvoice>lambdaQuery().eq(ContractInvoice::getContractId, contract.getId())
.orderByDesc(ContractInvoice::getCreateTime).last("limit 1"));
@@ -559,7 +632,7 @@
}
SysDept b = r.getData();
BigDecimal advanceAmount = new BigDecimal("0");
- for (ContractOutBoundInvoiceVo contractOutBoundInvoiceVo : genInvoiceInfoDTO.getOutBoundInvoiceList()) {
+ for (ContractOutBoundInvoiceVo contractOutBoundInvoiceVo : toInvoiceDTO.getOutBoundInvoiceList()) {
ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
if (ObjUtil.isNotNull(subjectMatter)) {
advanceAmount = advanceAmount.add(contractOutBoundInvoiceVo.getInvoiceNum().multiply(subjectMatter.getUnitPrice()));
@@ -569,9 +642,9 @@
if (advanceAmount.compareTo(schedule.getPlannedAmount()) > 0) {
return R.failed("寮�绁ㄩ噾棰濊秴鍑哄悎鍚岀璁㈤樁娈靛簲鏀堕噾棰�:" + schedule.getPlannedAmount() + ",璇疯皟鏁村紑绁ㄦ暟閲�");
}
- GenInvoiceInfoVo vo = genAdvanceInvoiceInfoVo(genInvoiceInfoDTO, contract, b);
+ GenInvoiceInfoVo vo = BeanUtil.copyProperties(toInvoiceDTO,GenInvoiceInfoVo.class);
//鍙戠エ淇濆瓨
- ContractInvoice invoice = saveContractInvoice(vo, contract, genInvoiceInfoDTO.getOutBoundInvoiceList(), DateUtil.current() + "", "1");
+ ContractInvoice invoice = saveContractInvoice(vo, contract, toInvoiceDTO.getOutBoundInvoiceList(), DateUtil.current() + "", "1");
//鍚姩娴佺▼
ProcessInstanceParamDto dto = new ProcessInstanceParamDto();
Map<String, Object> map = BeanUtil.beanToMap(invoice);
@@ -582,57 +655,20 @@
return R.failed("娴佺▼鍚姩澶辫触");
}
//鏇存柊鍚堝悓鍑哄簱鍗曠姸鎬�
- genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> {
+ toInvoiceDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> {
ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
subjectMatter.setAdvanceNum(subjectMatter.getAdvanceNum().add(contractOutBoundInvoiceVo.getInvoiceNum()));
contractSubjectMatterMapper.updateById(subjectMatter);
});
return R.ok();
}
- if (!StrUtil.equals(genInvoiceInfoDTO.getContractCategory(), "water_house")) {
- ContractOutBound outBound = contractOutBoundMapper.selectById(genInvoiceInfoDTO.getOutBoundInvoiceList().get(0).getContractOutBoundId());
- contractId = outBound.getContractId();
- } else {
- ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(genInvoiceInfoDTO.getOutBoundInvoiceList().get(0).getContractOutBoundId());
- contractId = schedule.getContractId();
- }
- Contract contract = contractMapper.selectById(contractId);
- if (ObjUtil.isNull(contract)) {
- return R.failed("鍚堝悓淇℃伅寮傚父锛岃鑱旂郴鎶�鏈汉鍛�");
- }
- R<SysDept> r = remoteDeptService.getById(contract.getPartyBId());
- if (!r.isOk()) {
- return R.failed("鑾峰彇寮�绁ㄥ崟浣嶅紓甯�");
- }
- SysDept b = r.getData();
- //鏈哄姩杞﹀紑绁�
- if (StrUtil.equals(genInvoiceInfoDTO.getInvoiceType(), "3") || StrUtil.equals(genInvoiceInfoDTO.getInvoiceType(), "4")) {
- if (StrUtil.isBlank(genInvoiceInfoDTO.getVehicleNo())) {
- return R.failed("鏈哄姩杞﹀紑绁ㄨ杈撳叆杞︽灦鍙�");
- }
- BigDecimal invoiceNumSum = genInvoiceInfoDTO.getOutBoundInvoiceList().stream().map(item -> item.getInvoiceNum()).reduce(BigDecimal.ZERO, BigDecimal::add);
- if (invoiceNumSum.compareTo(new BigDecimal("1")) > 0) {
- return R.failed("鏈哄姩杞﹀紑绁ㄥ彧鑳�1娆″紑1杈�");
- }
- JSONObject request = genQueryVinParam(genInvoiceInfoDTO.getVehicleNo(), b);
- R r1 = requestQueryVehicleNo(request);
- if (!r1.isOk()) {
- return r1;
- }
- JSONObject request1 = genQueryVehDetailParam(genInvoiceInfoDTO.getVehicleNo(), b);
- R r2 = requestQueryVehicleDetail(request1);
- if (!r2.isOk()) {
- return r2;
- }
- genInvoiceInfoDTO.setVehicleData(r2.getData().toString());
- }
- GenInvoiceInfoVo vo = genInvoiceInfoVo(genInvoiceInfoDTO, contract, b);
+ GenInvoiceInfoVo vo = BeanUtil.copyProperties(toInvoiceDTO,GenInvoiceInfoVo.class);
//鍙戠エ淇濆瓨
- ContractInvoice invoice = saveContractInvoice(vo, contract, genInvoiceInfoDTO.getOutBoundInvoiceList(), DateUtil.current() + "", "0");
+ ContractInvoice invoice = saveContractInvoice(vo, contract, toInvoiceDTO.getOutBoundInvoiceList(), DateUtil.current() + "", "0");
//鍚姩娴佺▼
ProcessInstanceParamDto dto = new ProcessInstanceParamDto();
Map<String, Object> map = BeanUtil.beanToMap(invoice);
- if (StrUtil.equals(genInvoiceInfoDTO.getContractCategory(), "water_house")) {
+ if (StrUtil.equals(toInvoiceDTO.getContractCategory(), "water_house")) {
map.put("contractCategory", "water_house");
}
dto.setParamMap(map);
@@ -643,17 +679,15 @@
}
if (!StrUtil.equals(contract.getContractCategory(), "water_house")) {
//鏇存柊鍚堝悓鍑哄簱鍗曠姸鎬�
- genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> {
+ toInvoiceDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> {
ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
contractOutBound.setInvoiceStatus("1");
- if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum())) <= 0) {
- contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().add(contractOutBoundInvoiceVo.getInvoiceNum()));
- }
+ contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().add(contractOutBoundInvoiceVo.getInvoiceNum()));
contractOutBoundMapper.updateById(contractOutBound);
});
} else {
//鏇存柊鍚堝悓鎴跨 姘寸數 璐瑰紑绁ㄧ姸鎬�
- genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> {
+ toInvoiceDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> {
ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
schedule.setInvoiceFlag("1");
contractPaymentScheduleMapper.updateById(schedule);
@@ -721,7 +755,7 @@
data.put("invoiceTotalPriceTax", vo.getTotalPrice());
data.put("buyerBankName", vo.getPartyAOpenBank());
data.put("buyerBankNumber", vo.getPartyABankAccount());
-
+ data.put("remarks",vo.getRemarks());
jsonObject.put("data", data);
return jsonObject;
}
@@ -762,7 +796,6 @@
@Override
public R toRedInvoice(Long invoiceId) {
-
ContractInvoice blueInvoice = baseMapper.selectById(invoiceId);
blueInvoice.setRedReversal("2");
baseMapper.updateById(blueInvoice);
@@ -776,10 +809,21 @@
invoice.setInvoiceTotalTax(blueInvoice.getInvoiceTotalTax());
invoice.setInvoiceTotalPrice(blueInvoice.getInvoiceTotalPrice());
invoice.setInvoiceTotalPriceTax(blueInvoice.getInvoiceTotalPriceTax());
- invoice.setInvoicePreview(blueInvoice.getInvoicePreview());
- invoice.setInvoiceTotalTax(blueInvoice.getInvoiceTotalTax());
- invoice.setInvoiceTotalPrice(blueInvoice.getInvoiceTotalPrice());
- invoice.setInvoiceTotalPriceTax(blueInvoice.getInvoiceTotalPriceTax());
+
+ ToInvoiceDTO toInvoiceDTO = BeanUtil.copyProperties(JSONObject.parseObject(blueInvoice.getInvoicePreview()),ToInvoiceDTO.class);
+ toInvoiceDTO.setTotalPrice(toInvoiceDTO.getTotalPrice().multiply(new BigDecimal(-1)));
+ toInvoiceDTO.setTotalTax(toInvoiceDTO.getTotalTax().multiply(new BigDecimal(-1)));
+ if (CollUtil.isNotEmpty(toInvoiceDTO.getInvoiceItemList())){
+ toInvoiceDTO.getInvoiceItemList().stream().forEach(item->{
+ item.setPriceTax(item.getPriceTax().multiply(new BigDecimal("-1")));
+ item.setPriceNoTax(item.getPriceNoTax().multiply(new BigDecimal("-1")));
+ item.setPriceAndTax(item.getPriceAndTax().multiply(new BigDecimal("-1")));
+ });
+ }
+ invoice.setInvoicePreview(JSONObject.toJSONString(toInvoiceDTO));
+ invoice.setInvoiceTotalTax(blueInvoice.getInvoiceTotalTax().multiply(new BigDecimal("-1")));
+ invoice.setInvoiceTotalPrice(blueInvoice.getInvoiceTotalPrice().multiply(new BigDecimal("-1")));
+ invoice.setInvoiceTotalPriceTax(blueInvoice.getInvoiceTotalPriceTax().multiply(new BigDecimal("-1")));
invoice.setOutBoundId(blueInvoice.getOutBoundId());
invoice.setInvoiceTime(new Date());
invoice.setInvoiceCategory("2");
@@ -808,26 +852,26 @@
return R.ok();
}
- private JSONObject genRedInvoice(Contract contract, ContractInvoice blueInvoice, String redConfirmSerialNo) {
+ private JSONObject genRedInvoice(Contract contract, ContractInvoice blueInvoice,ContractInvoice redInvoice, String redConfirmSerialNo) {
JSONObject jsonObject = new JSONObject();
- jsonObject.put("taxNo", blueInvoice.getTaxNo());
+ jsonObject.put("taxNo", redInvoice.getTaxNo());
jsonObject.put("redConfirmSerialNo", redConfirmSerialNo);
jsonObject.put("entryIdentity", "01");
- jsonObject.put("sellerTaxNo", blueInvoice.getTaxNo());
- jsonObject.put("sellerTaxName", blueInvoice.getSellerTaxName());
- jsonObject.put("buyerTaxName", blueInvoice.getBuyerTaxName());
- jsonObject.put("buyerTaxNo", blueInvoice.getBuyerTaxNo());
+ jsonObject.put("sellerTaxNo", redInvoice.getTaxNo());
+ jsonObject.put("sellerTaxName", redInvoice.getSellerTaxName());
+ jsonObject.put("buyerTaxName", redInvoice.getBuyerTaxName());
+ jsonObject.put("buyerTaxNo", redInvoice.getBuyerTaxNo());
jsonObject.put("originInvoiceDate", DateUtil.formatDateTime(blueInvoice.getInvoiceTime()));
- jsonObject.put("originInvoiceTotalPrice", blueInvoice.getInvoiceTotalPrice());
- jsonObject.put("originInvoiceTotalTax", blueInvoice.getInvoiceTotalTax());
- jsonObject.put("invoiceTotalPrice", blueInvoice.getInvoiceTotalPrice().multiply(new BigDecimal("-1")));
- jsonObject.put("invoiceTotalTax", blueInvoice.getInvoiceTotalTax().multiply(new BigDecimal("-1")));
+ jsonObject.put("originInvoiceTotalPrice", redInvoice.getInvoiceTotalPriceTax());
+ jsonObject.put("originInvoiceTotalTax", redInvoice.getInvoiceTotalTax());
+ jsonObject.put("invoiceTotalPrice", redInvoice.getInvoiceTotalPrice());
+ jsonObject.put("invoiceTotalTax", redInvoice.getInvoiceTotalTax());
jsonObject.put("originInvoiceIsPaper", "N");
jsonObject.put("originInvoiceType", "01");
jsonObject.put("redInvoiceLabel", "01");
jsonObject.put("invoiceSource", "2");
jsonObject.put("originalInvoiceNo", blueInvoice.getInvoiceNo());
- GenInvoiceInfoVo vo = BeanUtil.copyProperties(JSONObject.parseObject(blueInvoice.getInvoicePreview()), GenInvoiceInfoVo.class);
+ GenInvoiceInfoVo vo = BeanUtil.copyProperties(JSONObject.parseObject(redInvoice.getInvoicePreview()), GenInvoiceInfoVo.class);
JSONArray invoiceDetailsList = new JSONArray();
Integer lineNo = 1;
for (InvoiceItemVo invoiceItemVo : vo.getInvoiceItemList()) {
@@ -836,12 +880,15 @@
invoiceDetail.put("projectName", invoiceItemVo.getItemName());
invoiceDetail.put("goodsLineNo", lineNo);
invoiceDetail.put("goodsCode", invoiceItemVo.getTaxCode());
- invoiceDetail.put("goodsTaxRate", invoiceItemVo.getTaxRate().divide(new BigDecimal("100")));
+ invoiceDetail.put("goodsTaxRate", invoiceItemVo.getTaxRate());
invoiceDetail.put("goodsUnit", invoiceItemVo.getUnit());
invoiceDetail.put("goodsQuantity", invoiceItemVo.getQuantity());
// invoiceDetail.put("goodsPrice", invoiceItemVo.getUnitPrice());
- invoiceDetail.put("goodsTotalPrice", invoiceItemVo.getPriceNoTax().multiply(new BigDecimal("-1")));
- invoiceDetail.put("goodsTotalTax", invoiceItemVo.getPriceTax().multiply(new BigDecimal("-1")));
+ invoiceDetail.put("goodsTotalPrice", invoiceItemVo.getPriceNoTax());
+ invoiceDetail.put("goodsTotalTax", invoiceItemVo.getPriceTax());
+ if (vo.getInvoiceVehicleType().equals("3")||vo.getInvoiceVehicleType().equals("4")){
+ invoiceDetail.put("goodsSpecification", invoiceItemVo.getSpecification());
+ }
invoiceDetailsList.add(invoiceDetail);
lineNo++;
}
@@ -857,7 +904,7 @@
.eq(ContractInvoice::getApprovalStatus, "1")
.eq(ContractInvoice::getBwRequestResult, "1")
.isNull(ContractInvoice::getInvoicePath));
- if (ArrayUtil.isNotEmpty(contractInvoices)) {
+ if (CollUtil.isNotEmpty(contractInvoices)) {
contractInvoices.stream().forEach(contractInvoice -> {
JSONObject request = new JSONObject();
request.put("taxNo", contractInvoice.getTaxNo());
@@ -879,7 +926,7 @@
contractInvoice.setInvoiceStatus("2");
baseMapper.updateById(contractInvoice);
//浼犺緭闄勪欢
- pushBipInvoicePdf(contractInvoice);
+// pushBipInvoicePdf(contractInvoice);
}
});
}
@@ -887,7 +934,7 @@
return R.ok();
}
- private void pushBipInvoicePdf(ContractInvoice contractInvoice) {
+ private void pushBipInvoicePdf(ContractInvoice contractInvoice){
String accessToken = "";
if (redisTemplate.hasKey("BIP_TOKEN")) {
accessToken = (String) redisTemplate.opsForValue().get("BIP_TOKEN");
@@ -930,7 +977,7 @@
.execute();
log.info("搴旀敹鍙戠エ闄勪欢涓婁紶鍥炲弬:{}", response.body());
//淇濆瓨璇锋眰璁板綍
- paymentConfirmService.saveBipRequestRecord(request, "搴旀敹鍙戠エ闆嗘垚鎺ュ彛", response.body());
+ paymentConfirmService.saveBipRequestRecord(request, "搴旀敹鍙戠エ闄勪欢涓婁紶鎺ュ彛", response.body());
JSONObject resultJson = JSONObject.parseObject(response.body());
if (resultJson.containsKey("code") && resultJson.getString("code").equals("200")) {
JSONObject datas = resultJson.getJSONObject("data");
@@ -964,8 +1011,40 @@
// 2. 瑙g爜 Base64 涓哄瓧鑺傛暟缁�
byte[] fileBytes = Base64.getDecoder().decode(base64Str);
+ File file = new File(targetPath);
+
+ // 1. 鑾峰彇鐖剁洰褰曞璞�
+ File parentDir = file.getParentFile();
+
+ // 2. 濡傛灉鐖剁洰褰曚笉涓虹┖涓斾笉瀛樺湪锛屽垯鍒涘缓鎵�鏈夊繀闇�鐨勭埗鐩綍
+ if (parentDir != null && !parentDir.exists()) {
+ // mkdirs() 浼氶�掑綊鍒涘缓鎵�鏈変笉瀛樺湪鐨勭埗鐩綍
+ // 蹇呴』妫�鏌ヨ繑鍥炲�硷紝鍥犱负鍙兘鍥犳潈闄愪笉瓒虫垨璺緞闈炴硶鑰屽け璐�
+ if (!parentDir.mkdirs()) {
+ // 濡傛灉 mkdirs 杩斿洖 false锛屽啀娆℃鏌ユ槸鍚﹀瓨鍦紙澶勭悊骞跺彂鎯呭喌锛�
+ if (!parentDir.exists()) {
+ log.error("鏃犳硶鍒涘缓鐖剁洰褰�: " + parentDir.getAbsolutePath());
+ }
+ }
+ }
+
+ // 3. 鍒涘缓鏂囦欢鏈韩
+ // createNewFile() 浠呭湪鏂囦欢涓嶅瓨鍦ㄦ椂鍒涘缓锛屽鏋滃凡瀛樺湪鍒欒繑鍥� false 浣嗕笉鎶ラ敊
+ if (!file.exists()) {
+ boolean created = false;
+ try {
+ created = file.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ if (!created) {
+ // 澶勭悊骞跺彂鍒涘缓澶辫触鎴栧叾浠栧紓甯�
+ log.error("鏃犳硶鍒涘缓鏂囦欢: " + file.getAbsolutePath());
+ }
+ }
+
// 3. 灏嗗瓧鑺傛暟缁勫啓鍏ユ枃浠�
- try (FileOutputStream fos = new FileOutputStream(new File(targetPath))) {
+ try (FileOutputStream fos = new FileOutputStream(file)) {
fos.write(fileBytes);
fos.flush();
System.out.println("鏂囦欢淇濆瓨鎴愬姛: " + targetPath);
@@ -1077,22 +1156,76 @@
data.put("bustypeCode", "ZBYXGLXT");//浜ゆ槗绫诲瀷缂栫爜 鏆備及榛樿ZGYSFP锛岄攢鍞粯璁BYXGLXT
data.put("contractNo", contract.getContractNo());
data.put("oriCurrencyCode", "CNY");//甯佺
+
data.put("_status", "Insert");
GenInvoiceInfoVo vo = BeanUtil.copyProperties(JSONObject.parseObject(contractInvoice.getInvoicePreview()), GenInvoiceInfoVo.class);
JSONArray bodyItem = new JSONArray();
- for (InvoiceItemVo invoiceItemVo : vo.getInvoiceItemList()) {
+ for (InvoiceItemVo invoiceItemVo : vo.getBipVo().getItemList()) {
JSONObject item = new JSONObject();
+ item.put("expenseItemCode",invoiceItemVo.getJjsx());//缁忔祹浜嬮」
item.put("invoiceNo", contractInvoice.getInvoiceNo());
item.put("taxRate", invoiceItemVo.getTaxRate());
item.put("oriTaxAmount", invoiceItemVo.getPriceTax());
item.put("oriTaxIncludedAmount", invoiceItemVo.getPriceAndTax());
item.put("_status", "Insert");
-
+ JSONObject freeChId = new JSONObject();
+ freeChId.put("GX08",invoiceItemVo.getHsdy());//鏍哥畻鍗曞厓
+ freeChId.put("YSYF31",invoiceItemVo.getSfjs());//鏄惁璁$◣
+ freeChId.put("JT04",invoiceItemVo.getHsjylx());//鏍哥畻浜ゆ槗绫诲瀷 0101 闆嗗洟澶栭儴 01020301 涓夌骇鍒嗗瓙鍏徃闂� 01020302 涓夌骇鍒嗗叕鍙镐笌瀛愬瓙鍏徃涔嬮棿
+ freeChId.put("JT06",invoiceItemVo.getKxmx());//娆鹃」鏄庣粏
+ freeChId.put("JT32",invoiceItemVo.getZyys());//浣滀笟瑕佺礌
+ freeChId.put("zzbkfl",invoiceItemVo.getBkfl());//鏉垮潡鍒嗙被
+ freeChId.put("JT12",invoiceItemVo.getCpwlfl());//浜у搧鐗╂枡鍒嗙被
+ item.put("freeChId",freeChId);
bodyItem.add(item);
}
data.put("bodyItem", bodyItem);
+ JSONObject freeChId = new JSONObject();
+ freeChId.put("YSYF_SFZY",vo.getBipVo().getSfzy());//鏄惁涓昏惀
+ freeChId.put("fk_038",vo.getBipVo().getPzzdr());//鍑瘉鍒跺崟浜�
+ freeChId.put("YSYF_08",vo.getBipVo().getSfnbwl());//鏄惁鍐呴儴寰�鏉�
+ freeChId.put("YSYF24",vo.getBipVo().getSfjyjs());//鏄惁绠�鏄撹绋�
+ freeChId.put("fk_002",vo.getBipVo().getFjzs());//闄勪欢1
+ freeChId.put("GX08",vo.getBipVo().getHsdy());//鏍哥畻鍗曞厓
+ freeChId.put("TzMY042",contract.getExpirationDate());//棰勮鍥炴鏃ユ湡
+ data.put("freeChId", freeChId);
+ data.put("remarks",vo.getBipVo().getZy());//鎽樿
jsonObject.put("data", data);
return jsonObject;
+ }
+
+ private String transEconomic(String economicMatters) {
+ if (economicMatters.equals("1")){
+ return "09001006";
+ }
+ if (economicMatters.equals("2")){
+ return "09004003";
+ }
+ if (economicMatters.equals("3")){
+ return "09003005";
+ }
+ if (economicMatters.equals("4")){
+ return "09002042";
+ }
+ if (economicMatters.equals("5")){
+ return "09002002";
+ }
+ if (economicMatters.equals("6")){
+ return "09004001";
+ }
+ if (economicMatters.equals("7")){
+ return "09003002001";
+ }
+ if (economicMatters.equals("8")){
+ return "09003002002";
+ }
+ if (economicMatters.equals("9")){
+ return "09003002003";
+ }
+ if (economicMatters.equals("10")){
+ return "09003003";
+ }
+ return "";
}
@Override
@@ -1100,7 +1233,7 @@
if (bwFlag) {
List<ContractInvoice> contractInvoices = baseMapper.selectList(Wrappers.<ContractInvoice>lambdaQuery()
.eq(ContractInvoice::getInvoiceCategory, "2").eq(ContractInvoice::getInvoiceStatus, "3"));
- if (ArrayUtil.isNotEmpty(contractInvoices)) {
+ if (CollUtil.isNotEmpty(contractInvoices)) {
contractInvoices.stream().forEach(contractInvoice -> {
JSONObject request = new JSONObject();
request.put("taxNo", contractInvoice.getTaxNo());
@@ -1120,7 +1253,7 @@
return;
}
JSONArray models = resultObj.getJSONArray("model");
- if (ArrayUtil.isNotEmpty(models)) {
+ if (CollUtil.isNotEmpty(models)) {
JSONObject model = (JSONObject) models.get(0);
if (StrUtil.isEmpty(model.getString("confirmBillingMark")) || StrUtil.equals(model.getString("confirmBillingMark"), "N")) {
@@ -1131,7 +1264,7 @@
contractInvoice.setInvoiceNo(model.getString("redInvoiceNo"));
contractInvoice.setRedReversal("1");
//鎺ㄩ�丅IP
- pushBipInvoice(contractInvoice);
+// pushBipInvoice(contractInvoice);
}
}
});
@@ -1158,15 +1291,15 @@
//钃濈エ
if (invoice.getInvoiceCategory().equals("1")) {
- // TODO 寮�钃濈エ鎺ュ彛鏈哄姩杞�
- if (StrUtil.equals(vo.getInvoiceVehicleType(), "3")) {
+ // TODO 寮�钃濈エ鎺ュ彛鏈哄姩杞﹂攢鍞�
+ if (StrUtil.equals(vo.getInvoiceVehicleType(), "4")) {
JSONObject request = genBlueInvoiceVehicle(vo, invoice.getSerialNo(), dept);
String requestId = IdUtil.fastUUID();
invoice.setBwRequestId(requestId);
invoice.setBwRequestParam(request.toJSONString());
- log.info("鏈哄姩杞﹀彂绁ㄥ紑鍏疯姹傛帴鍙e叆鍙�:{}", request.toJSONString());
+ log.info("鏈哄姩杞﹂攢鍞粺涓�鍙戠エ寮�鍏疯姹傛帴鍙e叆鍙�:{}", request.toJSONString());
String result = HttpUtil.post(bwUrl + "method=baiwang.output.invoice.vehicleissue&version=1.0&requestId=" + requestId, request.toJSONString());
- log.info("鏈哄姩杞﹀彂绁ㄥ紑鍏疯姹傛帴鍙e洖鍙�:{}", result);
+ log.info("鏈哄姩杞﹂攢鍞粺涓�鍙戠エ寮�鍏疯姹傛帴鍙e洖鍙�:{}", result);
saveBwRequestRecord("baiwang.output.invoice.vehicleissue", requestId, request.toJSONString(), result);
JSONObject resultObj = JSONObject.parseObject(result);
if (resultObj.containsKey("requestId") && StrUtil.equals(resultObj.getString("requestId"), requestId) &&
@@ -1180,13 +1313,39 @@
invoice.setInvoiceTime(invoiceDate);
invoice.setInvoiceNo(modelJson.getString("invoiceNo"));
//鎺ㄩ�丅IP
- pushBipInvoice(invoice);
+// pushBipInvoice(invoice);
+ }
+ }
+
+ // TODO 寮�钃濈エ鎺ュ彛鏈哄姩杞︿笓鐢�
+ if (StrUtil.equals(vo.getInvoiceVehicleType(), "3")) {
+ JSONObject request = genBlueInvoiceVehiclePre(vo, invoice.getSerialNo(), dept);
+ String requestId = IdUtil.fastUUID();
+ invoice.setBwRequestId(requestId);
+ invoice.setBwRequestParam(request.toJSONString());
+ log.info("鏈哄姩杞︿笓鐢ㄥ彂绁ㄥ紑鍏疯姹傛帴鍙e叆鍙�:{}", request.toJSONString());
+ String result = HttpUtil.post(bwUrl + "method=baiwang.output.invoice.issue&version=1.0&requestId=" + requestId, request.toJSONString());
+ log.info("鏈哄姩杞︿笓鐢ㄥ彂绁ㄥ紑鍏疯姹傛帴鍙e洖鍙�:{}", result);
+ saveBwRequestRecord("baiwang.output.invoice.issue", requestId, request.toJSONString(), result);
+ JSONObject resultObj = JSONObject.parseObject(result);
+ if (resultObj.containsKey("requestId") && StrUtil.equals(resultObj.getString("requestId"), requestId) &&
+ resultObj.getBoolean("success")) {
+ log.info("寮�绁ㄦ垚鍔燂紒锛侊紒");
+ invoice.setBwRequestResult("1");
+ }
+ JSONObject modelJson = resultObj.getJSONObject("model");
+ if (ObjUtil.isNotNull(modelJson)) {
+ Date invoiceDate = DateUtil.parse(modelJson.getString("invoiceDate"), DatePattern.PURE_DATETIME_PATTERN);
+ invoice.setInvoiceTime(invoiceDate);
+ invoice.setInvoiceNo(modelJson.getString("invoiceNo"));
+ //鎺ㄩ�丅IP
+// pushBipInvoice(invoice);
}
}
// TODO 寮�钃濈エ鎺ュ彛 闈炴満鍔ㄨ溅
- JSONObject request = genBlueInvoice(vo, invoice.getSerialNo(), dept);
- if (bwFlag) {
+ if (!StrUtil.equals(vo.getInvoiceVehicleType(), "3")&&!StrUtil.equals(vo.getInvoiceVehicleType(), "4")) {
+ JSONObject request = genBlueInvoice(vo, invoice.getSerialNo(), dept);
String requestId = IdUtil.fastUUID();
invoice.setBwRequestId(requestId);
invoice.setBwRequestParam(request.toJSONString());
@@ -1209,7 +1368,7 @@
invoice.setInvoiceTime(invoiceDate);
invoice.setInvoiceNo(model.getString("invoiceNo"));
//鎺ㄩ�丅IP
- pushBipInvoice(invoice);
+// pushBipInvoice(invoice);
}
}
}
@@ -1220,29 +1379,30 @@
}
if (!StrUtil.equals(contract.getContractCategory(), "water_house")) {
//鍚堝悓鐘舵��
- if (StrUtil.equals(contract.getBillingStatus(), "2")) {
- contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout()));
- if (contract.getBillingAmout().compareTo(contract.getAmount()) == 0 &&
- contract.getPaidAmount().compareTo(contract.getAmount().subtract(contract.getDropAmount())) == 0) {
- contract.setBillingStatus("3");
- contract.setContractStatus(3);
- }
- if (contract.getBillingAmout().compareTo(contract.getAmount()) < 0) {
- contract.setBillingStatus("1");
- List<ContractOutBound> outBoundList = contractOutBoundMapper.selectList(Wrappers.<ContractOutBound>lambdaQuery()
- .eq(ContractOutBound::getContractId, contract.getId())
- .apply("invoice_num < out_bound_num"));
- if (CollUtil.isNotEmpty(outBoundList)) {
- contract.setBillingStatus("2");
- }
-
- }
- //闃叉閲嶅瀹″紑绁ㄥ鏍搁�氳繃鍚� 寮�绁ㄩ噾棰濊秴鍑哄悎鍚岄噾棰�
- if (contract.getBillingAmout().compareTo(contract.getAmount()) > 0) {
- contract.setBillingAmout(contract.getAmount());
- }
- contractMapper.updateById(contract);
+ contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout()));
+ if (contract.getBillingAmout().compareTo(contract.getAmount()) == 0) {
+ contract.setBillingStatus("3");
}
+ if (contract.getPaidAmount().compareTo(contract.getAmount().subtract(contract.getDropAmount())) >= 0&&
+ contract.getBillingAmout().compareTo(contract.getAmount()) == 0){
+ contract.setContractStatus(3);
+ }
+ if (contract.getBillingAmout().compareTo(contract.getAmount()) < 0) {
+ contract.setBillingStatus("1");
+ List<ContractOutBound> outBoundList = contractOutBoundMapper.selectList(Wrappers.<ContractOutBound>lambdaQuery()
+ .eq(ContractOutBound::getContractId, contract.getId())
+ .apply("invoice_num < out_bound_num"));
+ if (CollUtil.isNotEmpty(outBoundList)) {
+ contract.setBillingStatus("2");
+ }
+
+ }
+ //闃叉閲嶅瀹″紑绁ㄥ鏍搁�氳繃鍚� 寮�绁ㄩ噾棰濊秴鍑哄悎鍚岄噾棰�
+ if (contract.getBillingAmout().compareTo(contract.getAmount()) > 0) {
+ contract.setBillingAmout(contract.getAmount());
+ }
+ contractMapper.updateById(contract);
+
} else {
//鍒ゆ柇 寰幆鏄惁瀹屾垚
List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery().eq(ContractExecDate::getContractId, contract.getId())
@@ -1251,14 +1411,17 @@
//鍒ゆ柇鏄惁鏈夊彲寮�绁ㄨ褰�
List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
.eq(ContractPaymentSchedule::getContractId, contract.getId()).eq(ContractPaymentSchedule::getInvoiceFlag, "0"));
- if (ArrayUtil.isEmpty(scheduleList)) {
+ if (CollUtil.isEmpty(scheduleList)) {
contract.setBillingStatus("3");
} else {
contract.setBillingStatus("2");
}
contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout()));
+ if (contract.getBillingAmout().compareTo(contract.getAmount()) == 0) {
+ contract.setBillingStatus("3");
+ }
if (contract.getBillingAmout().compareTo(contract.getAmount()) == 0 &&
- contract.getPaidAmount().compareTo(contract.getAmount().subtract(contract.getDropAmount())) == 0) {
+ contract.getPaidAmount().compareTo(contract.getAmount().subtract(contract.getDropAmount())) >= 0) {
contract.setBillingStatus("3");
contract.setContractStatus(3);
}
@@ -1270,7 +1433,7 @@
//鍒ゆ柇鏄惁鏈夊彲寮�绁ㄨ褰�
List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
.eq(ContractPaymentSchedule::getContractId, contract.getId()));
- if (ArrayUtil.isEmpty(scheduleList)) {
+ if (CollUtil.isEmpty(scheduleList)) {
contract.setBillingStatus("1");
} else {
contract.setBillingStatus("2");
@@ -1285,7 +1448,7 @@
if (invoice.getInvoiceCategory().equals("2")) {
// TODO 寮�绾㈢エ鎺ュ彛
ContractInvoice blueInvoice = baseMapper.selectById(invoice.getBlueInvoiceId());
- JSONObject request = genRedInvoice(contract, blueInvoice, invoice.getSerialNo());
+ JSONObject request = genRedInvoice(contract,blueInvoice, invoice, invoice.getSerialNo());
String requestId = IdUtil.fastUUID();
invoice.setBwRequestId(requestId);
invoice.setBwRequestParam(request.toJSONString());
@@ -1313,12 +1476,12 @@
invoice.setInvoiceNo(model.getString("redInvoiceNo"));
invoice.setRedReversal("1");
//鎺ㄩ�丅IP
- pushBipInvoice(invoice);
+// pushBipInvoice(invoice);
}
}
}
baseMapper.updateById(invoice);
- contract.setBillingAmout(contract.getBillingAmout().subtract(invoice.getInvoiceTotalPriceTax()));
+ contract.setBillingAmout(contract.getBillingAmout().add(invoice.getInvoiceTotalPriceTax()));
//闃叉閲嶅瀹″紑绁ㄥ鏍搁�氳繃鍚� 寮�绁ㄩ噾棰濅负璐�
if (contract.getBillingAmout().compareTo(new BigDecimal("0")) < 0) {
contract.setBillingAmout(new BigDecimal("0"));
@@ -1329,7 +1492,7 @@
if (StrUtil.isNotBlank(vo.getAdvanceInvoice())) {
//杩樺師棰勫紑鏁伴噺
List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList = BeanUtil.copyToList(JSONArray.parseArray(blueInvoice.getInvoicePreviewParam()), ContractOutBoundInvoiceVo.class);
- if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList)) {
+ if (CollUtil.isNotEmpty(outBoundInvoiceVoList)) {
outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> {
ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
if (ObjUtil.isNotNull(subjectMatter)) {
@@ -1349,19 +1512,17 @@
if (!StrUtil.equals(contract.getContractCategory(), "water_house")) {
//鏇存柊鍚堝悓鍑哄簱鍗曠姸鎬�
List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList = BeanUtil.copyToList(JSONArray.parseArray(blueInvoice.getInvoicePreviewParam()), ContractOutBoundInvoiceVo.class);
- if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList)) {
+ if (CollUtil.isNotEmpty(outBoundInvoiceVoList)) {
outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> {
ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
- if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum())) <= 0) {
- contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum()));
- contractOutBoundMapper.updateById(contractOutBound);
- }
+ contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum()));
+ contractOutBoundMapper.updateById(contractOutBound);
});
}
} else {
//鏇存柊鍚堝悓鎴跨 姘寸數 璐瑰紑绁ㄧ姸鎬�
List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList = BeanUtil.copyToList(JSONArray.parseArray(blueInvoice.getInvoicePreviewParam()), ContractOutBoundInvoiceVo.class);
- if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList)) {
+ if (CollUtil.isNotEmpty(outBoundInvoiceVoList)) {
outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> {
ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
schedule.setInvoiceFlag("0");
@@ -1371,6 +1532,60 @@
}
}
+ }
+
+ private JSONObject genBlueInvoiceVehiclePre(GenInvoiceInfoVo vo, String serialNo, SysDept dept) {
+ JSONObject vechicleData = JSONObject.parseObject(vo.getVehicleData());
+ JSONObject jsonObject = new JSONObject();
+ //閿�鏂�
+ jsonObject.put("taxNo", vo.getPartyBOrgCode());//绋庡彿
+ jsonObject.put("taxUserName", SecurityUtils.getUser().getPhone());//鏁扮數璐﹀彿
+
+ jsonObject.put("formatGenerate", false);//鏄惁闇�瑕佺敓鎴愮増寮忚繑鍥炵増寮忛摼鎺�(true / false)
+ jsonObject.put("formatPushType", false);//鐗堝紡鐢熸垚鏄惁鎺ㄩ��(true / false)
+ jsonObject.put("taxUserName", dept.getInvoiceContact());
+ //data
+ JSONObject data = new JSONObject();
+ data.put("invoiceTypeCode", "01");
+ data.put("invoiceType", "0");
+ data.put("serialNo", serialNo);
+ data.put("invoiceSpecialMark","14");//鐗瑰畾涓氬姟鏍囪瘑 14-鏈哄姩杞�
+// data.put("taxationMethod","2");
+// data.put("taxationLabel","02");//鍙戠エ绫诲瀷浠g爜涓衡��01-鏁扮數鍙戠エ锛堝鍊肩◣涓撶敤鍙戠エ锛夈��02-鏁扮數鍙戠エ锛堟櫘閫氬彂绁級鈥濇椂涓斿緛绋庢柟寮忎负鈥�2-宸寰佺◣鈥濇椂蹇呭~
+ List<JSONObject> invoiceDetailsList = new ArrayList<>();
+ Integer lineNo = 1;
+ //data.invoiceDetailsList
+ for (InvoiceItemVo invoiceItemVo : vo.getInvoiceItemList()) {
+ JSONObject invoiceDetail = new JSONObject();
+
+ invoiceDetail.put("goodsLineNo", lineNo);
+ invoiceDetail.put("goodsName", invoiceItemVo.getItemName());
+ invoiceDetail.put("projectName", invoiceItemVo.getItemName());
+ invoiceDetail.put("goodsCode", invoiceItemVo.getTaxCode());
+ invoiceDetail.put("goodsTaxRate", invoiceItemVo.getTaxRate().divide(new BigDecimal("100")));
+ invoiceDetail.put("goodsUnit", "杈�");
+ invoiceDetail.put("goodsQuantity", invoiceItemVo.getQuantity());
+// invoiceDetail.put("goodsPrice", invoiceItemVo.getUnitPrice());
+ invoiceDetail.put("goodsSpecification", vo.getVehicleNo());
+ invoiceDetail.put("goodsTotalPrice", invoiceItemVo.getPriceNoTax());
+ invoiceDetail.put("goodsTotalTax", invoiceItemVo.getPriceTax());
+
+ invoiceDetailsList.add(invoiceDetail);
+ lineNo++;
+ }
+ data.put("invoiceDetailsList", invoiceDetailsList);
+ //璐柟
+ data.put("buyerTaxNo", vo.getPartyAOrgCode());
+ data.put("buyerName", vo.getPartyA());
+ data.put("sellerTaxNo", vo.getPartyBOrgCode());// TODO 绋庡姟鎬诲眬绯荤粺鐧婚檰浜烘墜鏈哄彿
+ data.put("invoiceTotalPrice", vo.getTotalPrice().subtract(vo.getTotalTax()));
+ data.put("invoiceTotalPriceTax", vo.getTotalPrice());
+ data.put("invoiceTotalTax", vo.getTotalTax());
+ data.put("buyerBankName", vo.getPartyAOpenBank());
+ data.put("buyerBankNumber", vo.getPartyABankAccount());
+
+ jsonObject.put("data", data);
+ return jsonObject;
}
private JSONObject genBlueInvoiceVehicle(GenInvoiceInfoVo vo, String serialNo, SysDept dept) {
@@ -1434,19 +1649,17 @@
if (!StrUtil.equals(contract.getContractCategory(), "water_house")) {
//鏇存柊鍚堝悓鍑哄簱鍗曠姸鎬�
List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList = BeanUtil.copyToList(JSONArray.parseArray(invoice.getInvoicePreviewParam()), ContractOutBoundInvoiceVo.class);
- if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList)) {
+ if (CollUtil.isNotEmpty(outBoundInvoiceVoList)) {
outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> {
ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
- if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum())) <= 0) {
- contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum()));
- contractOutBoundMapper.updateById(contractOutBound);
- }
+ contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum()));
+ contractOutBoundMapper.updateById(contractOutBound);
});
}
} else {
//鏇存柊鍚堝悓鎴跨 姘寸數 璐瑰紑绁ㄧ姸鎬�
List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList = BeanUtil.copyToList(JSONArray.parseArray(invoice.getInvoicePreviewParam()), ContractOutBoundInvoiceVo.class);
- if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList)) {
+ if (CollUtil.isNotEmpty(outBoundInvoiceVoList)) {
outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> {
ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
schedule.setInvoiceFlag("0");
@@ -1505,7 +1718,7 @@
invoice.setInvoiceTime(invoiceDate);
invoice.setInvoiceNo(model.getString("invoiceNo"));
//鎺ㄩ�丅IP
- pushBipInvoice(invoice);
+// pushBipInvoice(invoice);
}
}
}
@@ -1529,7 +1742,7 @@
}
invoice.setBwRequestResult("1");
JSONArray models = resultObj.getJSONArray("model");
- if (ArrayUtil.isNotEmpty(models)) {
+ if (CollUtil.isNotEmpty(models)) {
JSONObject model = (JSONObject) models.get(0);
if (StrUtil.isEmpty(model.getString("confirmBillingMark")) || StrUtil.equals(model.getString("confirmBillingMark"), "N")) {
//绛夊緟纭
@@ -1539,7 +1752,7 @@
invoice.setInvoiceNo(model.getString("redInvoiceNo"));
invoice.setRedReversal("1");
//鎺ㄩ�丅IP
- pushBipInvoice(invoice);
+// pushBipInvoice(invoice);
}
}
}
@@ -1710,6 +1923,51 @@
return R.ok();
}
+ @Override
+ public ContractInvoice getById(Long id) {
+ return baseMapper.selectById(id);
+ }
+
+ @Override
+ public R bipPushPdf(Long invoiceId) {
+ ContractInvoice invoice = baseMapper.selectById(invoiceId);
+ pushBipInvoicePdf(invoice);
+ return R.ok();
+ }
+
+ @Override
+ public R selectBipByKey(String dictKey) {
+ List<BipDict> bipDictList = bipDictMapper.selectList(Wrappers.<BipDict>lambdaQuery().eq(BipDict::getDictKey,dictKey));
+ if (CollUtil.isNotEmpty(bipDictList)){
+ // 鏉冮檺鍐呴儴闂�
+ List<TreeNode<Long>> collect = bipDictList.stream()
+ .map(dict -> {
+ TreeNode<Long> treeNode = new TreeNode<>();
+ treeNode.setId(dict.getId());
+ treeNode.setParentId(dict.getParentId());
+ treeNode.setName(dict.getDictName());
+ treeNode.setWeight(dict.getDictCode());
+ return treeNode;
+ })
+ .collect(Collectors.toList());
+
+ return R.ok(TreeUtil.build(collect,0L));
+ }
+ return R.failed("瀛楀吀鑾峰彇澶辫触");
+ }
+
+ @Override
+ public R saveAndPush(ContractInvoiceUpateDTO upateDTO) {
+ ContractInvoice invoice = baseMapper.selectById(upateDTO.getId());
+ invoice.setInvoicePreview(upateDTO.getInvoicePreview());
+ baseMapper.updateById(invoice);
+ R r = bipPush(invoice.getId());
+ if (!r.isOk()){
+ return r;
+ }
+ return bipPushPdf(invoice.getId());
+ }
+
public static void main(String[] args) {
File file = new File("d://tmp//" + IdUtil.fastUUID() + ".pdf");
HttpUtil.downloadFile("http://fp.baiwang.com/format/d?d=BB99645F8ED2AE7D2055E7D29330D366B7CAE92C278C6BB84D222610CEC2118D", file);
--
Gitblit v1.9.1