package com.by4cloud.platformx.business.invoice.service.impl;
|
|
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONUtil;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.by4cloud.platformx.business.entity.BillingInfo;
|
import com.by4cloud.platformx.business.entity.SaleCredit;
|
import com.by4cloud.platformx.business.entity.invoice.BipInvoice;
|
import com.by4cloud.platformx.business.entity.invoice.InvoiceResult;
|
import com.by4cloud.platformx.business.entity.invoice.vo.*;
|
import com.by4cloud.platformx.business.invoice.service.BIPYsService;
|
import com.by4cloud.platformx.business.invoice.service.BipInvoiceService;
|
import com.by4cloud.platformx.business.invoice.service.FileUploadService;
|
import com.by4cloud.platformx.business.invoice.service.FpInvoiceResultService;
|
import com.by4cloud.platformx.business.invoice.utils.BipApiEnum;
|
import com.by4cloud.platformx.business.invoice.utils.BipHttpUtil;
|
import com.by4cloud.platformx.business.invoice.utils.NumUtils;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.stereotype.Component;
|
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
@Slf4j
|
@Component
|
|
public class BIPYsServiceImpl implements BIPYsService {
|
@Autowired
|
private BipHttpUtil bipHttpUtil;
|
@Autowired
|
private BipInvoiceService bipInvoiceService;
|
|
@Autowired
|
private FileUploadService fileUploadService;
|
|
|
@Autowired
|
private FpInvoiceResultService fpInvoiceResultService;
|
|
|
/*@Value("${otherPrice.dustFeePrice}")
|
private Double dustFeePrice;
|
|
@Value("${otherPrice.dustFeeRate}")
|
private Double dustFeeRate;*/
|
|
@Override
|
public BipResVo sendBIPYs(SaleCredit railwayEntrust, String id1, String id2, Boolean focus, String customerCode, String customerAddressCode, String businessType, String fromStation, Integer allId, String contractNum, String number, String jyType, String accountUnitNumber, String deptCode, String userCode, Integer isNd){//}, ZhAccountLedger accountLedger) {
|
// BipInvoice bipInvoice1 = new BipInvoice();
|
// bipInvoice1.setDay(DateUtil.date());
|
// bipInvoice1.setBipCompNumber(id2);
|
// bipInvoice1.setType(0);
|
// bipInvoice1.setInvoiceType(0);
|
// bipInvoice1.setRailwayEntrustId(railwayEntrust.getId());
|
// bipInvoice1.setAllId(allId);
|
// bipInvoice1.setCompId(railwayEntrust.getCompId());
|
// bipInvoice1.setMoney(railwayEntrust.getAllPrice());
|
// bipInvoice1.setTonnage(railwayEntrust.getTonnage());
|
// bipInvoice1.setPrice(railwayEntrust.getPrice());
|
// bipInvoice1.setResStatus("200");
|
// bipInvoice1.setDirection(1);
|
// bipInvoice1.setTrainType(railwayEntrust.getTrainType());
|
// bipInvoiceService.save(bipInvoice1);
|
// BipResVo bipResVo1 = new BipResVo<>();
|
// bipResVo1.setCode("200");
|
// if (true){
|
// return bipResVo1;
|
// }
|
|
/*Map<String, String> dictMap = RedisCacheHelper.getInstance().getDictMapByType("bip_expense_item");
|
AtomicReference<String> expenseItemCode = new AtomicReference<>("09001001,01");
|
dictMap.forEach((k, v) -> {
|
if (k.equals(railwayEntrust.getCoalId().toString())) {
|
expenseItemCode.set(v);
|
}
|
});*/
|
/*List<ContractOrder> orders = contractOrderService.list(new QueryWrapper<ContractOrder>().lambda().eq(ContractOrder::getNumber, railwayEntrust.getOrderNumber()));
|
ContractOrder order = orders.get(0);
|
Map<String,String> fromStationMap = RedisCacheHelper.getInstance().getDictMapByType("from_station");//发站
|
String fromStation2 = "";
|
if (railwayEntrust.getTrainType().equals(2) && StrUtil.isNotEmpty(order.getFromStation()) && fromStationMap!=null){
|
fromStation2 = fromStationMap.get(order.getFromStation());
|
}*/
|
//SysUser user = remoteUserService.getByName(railwayEntrust.getCreateBy());
|
//String createName = (user == null ? "" : user.getRealName());
|
//String ncCoalNumber = coal.getBipCategoryCode();//产品大类
|
//String coalBipCode = coal.getBipCode();//具体产品
|
BIPBody bipBody = new BIPBody();
|
BIPYsMxHeader mx = new BIPYsMxHeader();
|
List<BIPYsItem> bipYsItems = new ArrayList<>();
|
// mx.(railwayEntrust.getFyCompName());//发运矿
|
//mx.setMX01_code(fromStation2);//发站
|
/*if (accountLedger.getId().equals(80) || accountLedger.getId().equals(81) && !accountLedger.getId().equals(82)) {
|
contractNum = "";
|
}*/
|
if (StrUtil.isNotEmpty(contractNum)) {
|
mx.setHTBMBT(1);
|
} else {
|
mx.setHTBMBT(0);
|
}
|
mx.setContractNo(contractNum);
|
mx.setMX021_code(customerCode);//收货客户
|
mx.setMX031_code(customerCode);//结算客户
|
mx.setMX04(number);//结算单号
|
mx.setMX0401(railwayEntrust.getEntrustCode());//托收单号
|
mx.setMX051_code(businessType);//业务种类
|
//mx.setMX06(createName);//创建人
|
//mx.setMX07(railwayEntrust.getUserName());//审核人
|
|
mx.setGX08_code(accountUnitNumber);//核算单元
|
//String remark = getRemark(railwayEntrust, "销", customerCode, id2);
|
mx.setRemarks(railwayEntrust.getInvoiceRemark());
|
//String fileUrl = fileUploadService.fileUpload(6, railwayEntrust.getId());
|
mx.setFk_002(3);
|
/*if (StrUtil.isNotEmpty(fileUrl) && "01".equals(jyType)) {
|
mx.setFk_002(3 + fileUrl.split(",").length);
|
}*/
|
/*if (railwayEntrust.getFatherEntrustId() != null) {
|
fileUrl = fileUploadService.fileUpload(6, contractNum);
|
mx.setFk_002(3);
|
if (StrUtil.isNotEmpty(fileUrl) && "01".equals(jyType)) {
|
mx.setFk_002(3 + fileUrl.split(",").length);
|
}
|
}*/
|
bipBody.setBustypeCode("MXysfp");
|
bipBody.setStaffCode(userCode);
|
// bipBody.setFk_038_code(userCode);
|
bipBody.setObjectType("1");
|
bipBody.setCustomerCode(customerCode);
|
bipBody.setExtVouchCode(railwayEntrust.getEntrustCode());//煤销系统单号
|
|
bipBody.setFinanceOrgCode(id2);//开票组织ID
|
bipBody.setDirection("1");//单据方向 1蓝 -1红
|
bipBody.setBillDate(DateUtil.format(new Date(), "yyyy-MM-dd"));//开票日期
|
// bipBody.setBillDate(DateUtil.format(railwayEntrust.getBalanceDate(), "yyyy-MM-dd"));//开票日期
|
|
// if ("0101".equals(jyType)){
|
//
|
// }
|
bipBody.setContractNo(contractNum);
|
bipBody.setOrgCode(id2);//业务组织id
|
bipBody.setDeptCode(deptCode);
|
bipBody.setExchangeRateDate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
// bipBody.setExchangeRateDate(DateUtil.format(railwayEntrust.getBalanceDate(), "yyyy-MM-dd HH:mm:ss"));
|
// bipBody.setCustomer();//客户编码
|
|
//bipBody.setRemarks(remark);
|
|
//表体
|
//煤种类目
|
BIPYsItem bipYsItem = new BIPYsItem();
|
// bipYsItem.setExchangeRateDate(DateUtil.format(railwayEntrust.getBalanceDate(),"yyyy-MM-dd HH:mm:ss"));
|
|
//bipYsItem.setTaxRate(NumUtils.multiplyDouble(railwayEntrust.getTaxRate(),100d));
|
//bipYsItem.setUnitName("吨");
|
|
/*bipYsItem.setMaterialCode("7704000001");
|
bipYsItem.setQuantity(BigDecimal.valueOf(railwayEntrust.getTonnage()));
|
bipYsItem.setCustomerCode(customerCode);//客户编码
|
Double noTaxPrice = railwayEntrust.getPrice();
|
bipYsItem.setOriTaxAmount(BigDecimal.valueOf(railwayEntrust.getTaxFee()));//税额
|
String[] codes = expenseItemCode.get().split(",");
|
bipYsItem.setExpenseItemCode(codes[0]);
|
|
Double allPrice = railwayEntrust.getTotalPrice();
|
bipYsItem.setOriTaxExcludedAmount(BigDecimal.valueOf(railwayEntrust.getCoalFree()));//原币无税金额
|
bipYsItem.setOriTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getTotalPrice()));//原币含税金额
|
bipYsItem.setLocalTaxExcludedAmount(BigDecimal.valueOf(railwayEntrust.getCoalFree()));//本币无税金额
|
bipYsItem.setLocalTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getTotalPrice()));//本币含税金额
|
bipYsItem.setOriTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCoalFree(), railwayEntrust.getTonnage(), 8));//无税单价
|
bipYsItem.setLocalTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCoalFree(), railwayEntrust.getTonnage(), 8));//无税单价
|
Double realPrice = NumUtils.divideDouble(railwayEntrust.getTotalPrice(), railwayEntrust.getTonnage(), 8);
|
bipYsItem.setOriTaxIncludedPrice(realPrice);//本币含税单价
|
bipYsItem.setLocalTaxIncludedPrice(realPrice);//本币含税单价
|
//分割单金额
|
if (CompUtils.isTsCustomer(railwayEntrust.getCustomerId())) {
|
if (railwayEntrust.getFatherEntrustId() == null) {
|
|
Double noTaxMoney = railwayEntrust.getCoalMoney();
|
Double taxMoney = railwayEntrust.getCoalTaxMoney();
|
Double allMoney = NumUtils.addDouble(noTaxMoney, taxMoney, 2);
|
allPrice = allMoney;
|
bipYsItem.setOriTaxAmount(BigDecimal.valueOf(taxMoney));//税额
|
bipYsItem.setOriTaxExcludedAmount(BigDecimal.valueOf(noTaxMoney));//原币无税金额
|
bipYsItem.setOriTaxIncludedAmount(BigDecimal.valueOf(allMoney));//原币含税金额
|
bipYsItem.setLocalTaxExcludedAmount(BigDecimal.valueOf(noTaxMoney));//本币无税金额
|
bipYsItem.setLocalTaxIncludedAmount(BigDecimal.valueOf(allMoney));//本币含税金额
|
bipYsItem.setOriTaxExcludedPrice(railwayEntrust.getPrice());//无税单价
|
bipYsItem.setLocalTaxExcludedPrice(railwayEntrust.getPrice());//无税单价
|
bipYsItem.setOriTaxIncludedPrice(NumUtils.divideDouble(allMoney, railwayEntrust.getTonnage(), 8));//本币含税单价
|
bipYsItem.setLocalTaxIncludedPrice(NumUtils.divideDouble(allMoney, railwayEntrust.getTonnage(), 8));//本币含税单价
|
}
|
|
}
|
bipYsItem.setRemarks(remark);*/
|
|
//煤种表体
|
BIPYsMx bipYsMx = new BIPYsMx();
|
//bipYsMx.setJT12_code(ncCoalNumber);//物料编码
|
// bipYsMx.setJT25_code(codes[1]);
|
//bipYsMx.setGX06_code(coalBipCode);//物料名称
|
|
bipYsMx.setMX021_code(customerCode);//收货客户
|
bipYsMx.setCustomerCode(customerAddressCode);//客户编码
|
bipYsMx.setJT06_code("01001001");//款项明细
|
bipYsMx.setYSYF14_code("2");
|
if (id2!=null){
|
/*if (id2 != null && id2.equals("10439") && railwayEntrust.getCoalId() != null && railwayEntrust.getCoalId().equals(45)) {
|
bipYsMx.setJT12_code("0101020401");//物料编码
|
bipYsMx.setGX06_code("01010201043902438");//物料名称
|
}*/
|
if (id2.equals("126") || id2.equals("10439") || id2.equals("1045116") || id2.equals("104810210") || id2.equals("1027902")) {
|
bipBody.setYSYF_08("0");
|
bipYsMx.setYSYF_08("0");
|
}
|
if (id2.startsWith("104")) {
|
if (focus) {
|
bipYsMx.setYSYF52("0");
|
} else {
|
bipYsMx.setYSYF52("1");
|
}
|
|
}
|
|
}
|
bipYsMx.setGX08_code(accountUnitNumber);
|
/*bipYsMx.setMX09(railwayEntrust.getCoalName());//运销煤种
|
bipYsMx.setMX10(BigDecimal.valueOf(railwayEntrust.getRealTonnage()));//水煤量
|
bipYsMx.setMX11(railwayEntrust.getAshContentMetering());//灰分
|
bipYsMx.setMX13(railwayEntrust.getMoistureMetering());
|
bipYsMx.setMX14(railwayEntrust.getSulFurMetering());
|
bipYsMx.setMX15(railwayEntrust.getCoalName());
|
if (railwayEntrust.getInvoiceResultId() == null && !CompUtils.isKp(accountLedger.getId()) && !accountLedger.getId().equals(165)) {
|
throw new RuntimeException("结算单未开票");
|
}*/
|
InvoiceResult invoiceResult = fpInvoiceResultService.getById(railwayEntrust.getBlueInvoiceResultId());
|
if (invoiceResult != null) {
|
bipYsMx.setYSYF33(invoiceResult.getInvoiceNo());
|
bipYsItem.setInvoiceNo(invoiceResult.getInvoiceNo());
|
// bipYsMx.setInvoiceNo(invoiceResult.getInvoiceNo());
|
}
|
bipYsMx.setZzbkfl_code("01");
|
/*if (StrUtil.isNotEmpty(accountLedger.getZzbkfl())) {
|
bipYsMx.setZzbkfl_code(accountLedger.getZzbkfl());
|
}
|
String jyType1 = jyType;//特殊交易单
|
if (jyType.equals("0101") && railwayEntrust.getCustomerId() != null && railwayEntrust.getCustomerId().equals(203)) {
|
jyType1 = "01020202";
|
}
|
|
if (jyType.equals("0101") && railwayEntrust.getCustomerId() != null && (railwayEntrust.getCustomerId().equals(172) || railwayEntrust.getCustomerId().equals(200) || railwayEntrust.getCustomerId().equals(2002381))) {
|
jyType1 = "010201";
|
}*/
|
|
//bipYsMx.setJT04_code(jyType1);
|
//bipYsMx.setMX16(railwayEntrust.getTonnage());//折干量
|
bipYsItem.setFreeChId(bipYsMx);
|
// bipYsMx.setMX18(railwayEntrust.getRealTonnage());//标煤量
|
// bipYsMx.setMX18(railwayEntrust.getRealPrice());//标煤量单价
|
//收款计划
|
/*if (focus) {
|
List<BIPPayPlan> bipPayPlans = this.getBipPayPlan(railwayEntrust, allPrice);
|
bipYsItem.setGrandsonItem(bipPayPlans);
|
}*/
|
bipYsItems.add(bipYsItem);
|
String invoiceNo = invoiceResult == null ? "" : invoiceResult.getInvoiceNo();
|
|
/*if (railwayEntrust.getCustomerId() != null && (railwayEntrust.getCustomerId().equals(618) || railwayEntrust.getCustomerId().equals(608) || railwayEntrust.getCustomerId().equals(1367) || railwayEntrust.getCustomerId().equals(1002134))) {
|
this.getTsBt(railwayEntrust, customerCode, jyType1, focus, bipYsItems, isNd, accountUnitNumber, id2, fromStation, invoiceNo, contractNum);
|
} else {
|
this.getPtBt(railwayEntrust, customerCode, jyType1, focus, bipYsItems, isNd, accountUnitNumber, id2, fromStation, invoiceNo, contractNum);
|
}*/
|
|
bipBody.setBodyItem(bipYsItems);
|
|
/*if (railwayEntrust.getFatherEntrustId() == null && !railwayEntrust.getFyCompId().equals(227) && !order.getFiledId().equals(48)) {
|
List<Contract> contracts = fileUploadService.getContractsByEntrustId(railwayEntrust.getId());
|
System.out.println("重复合同:" + contracts.size() + "上级ID:" + railwayEntrust.getFatherEntrustId() + "结算单号:" + railwayEntrust.getEntrustCode());
|
if (contracts != null && contracts.size() > 0) {
|
contracts.forEach(e -> {
|
BIPYsMxHeader newMx = new BIPYsMxHeader();
|
BeanUtils.copyProperties(mx, newMx);
|
if (accountLedger.getId().equals(80) || accountLedger.getId().equals(81) || accountLedger.getId().equals(82)) {
|
newMx.setContractNo("");
|
newMx.setHTBMBT(0);
|
} else {
|
newMx.setContractNo(e.getNum());
|
newMx.setHTBMBT(1);
|
}
|
|
bipBody.setFreeChId(newMx);
|
});
|
}
|
|
} else {
|
bipBody.setFreeChId(mx);
|
}*/
|
|
|
String result = bipHttpUtil.post(BipApiEnum.应收发票保存接口, new JSONObject().set("data", bipBody));
|
BipResVo resVo = JSONUtil.toBean(result, BipResVo.class);
|
//放到单据记录表
|
BipInvoice bipInvoice = new BipInvoice();
|
bipInvoice.setDay(DateUtil.date());
|
bipInvoice.setInvoice(JSONUtil.toJsonStr(bipBody));
|
bipInvoice.setType(0);
|
bipInvoice.setInvoiceType(0);
|
bipInvoice.setContractNum(contractNum);
|
bipInvoice.setRailwayEntrustId(railwayEntrust.getId());
|
bipInvoice.setAllId(Long.parseLong(allId+""));
|
bipInvoice.setBipCompNumber(id2);
|
bipInvoice.setDirection(1);
|
bipInvoice.setCompId(railwayEntrust.getCompId());
|
bipInvoice.setResStatus(resVo.getCode());
|
// bipInvoice.setMoney(railwayEntrust.getAllPrice());
|
// bipInvoice.setTonnage(railwayEntrust.getTonnage());
|
// bipInvoice.setPrice(railwayEntrust.getPrice());
|
//bipInvoice.setTrainType(railwayEntrust.getTrainType());
|
BipResVo bipResVo = new BipResVo<>();
|
bipResVo.setCode(resVo.getCode());
|
BIPBody resBipBody = null;
|
if (resVo.getData() == null) {
|
resBipBody = new BIPBody();
|
} else {
|
resBipBody = JSONUtil.toBean(resVo.getData().toString(), BIPBody.class);
|
}
|
|
|
if (resVo.getCode().equals("200") || (StrUtil.isNotEmpty(resVo.getMessage()) && resVo.getMessage().contains("活动[财务审核]上找不到用户")) || StrUtil.isNotEmpty(resBipBody.getCode())) {
|
bipInvoice.setResInvoice(resVo.getData().toString());
|
|
bipInvoice.setBipNumber(resBipBody.getId());
|
// bipInvoice.setCode("200");
|
bipInvoice.setCode(resBipBody.getCode());
|
bipInvoice.setMessage(resVo.getMessage());
|
bipInvoiceService.save(bipInvoice);
|
bipResVo.setCode("200");
|
|
} else {
|
if (resVo.getData() != null && StrUtil.isNotEmpty(resVo.getData().toString())) {
|
bipInvoice.setBipNumber(resBipBody.getId());
|
bipInvoice.setCode(resBipBody.getCode());
|
}
|
bipInvoice.setMessage(resVo.getMessage());
|
bipResVo.setMessage(resVo.getMessage());
|
bipInvoiceService.save(bipInvoice);
|
|
}
|
if (resVo.getData() != null && StrUtil.isNotEmpty(resVo.getData().toString())) {
|
if (resBipBody.getId() != null) {
|
try {
|
/*if (railwayEntrust.getTrainType().equals(1)) {
|
if (order != null && order.getCompId() != null && order.getCompId().equals(227) && order.getFiledId() != null && order.getFiledId().equals(48)) {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(8, allId));
|
} else {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(0, allId));
|
}
|
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(3, railwayEntrust.getId(), railwayEntrust.getQualityName(), railwayEntrust.getUserCompId()));
|
} else if (railwayEntrust.getTrainType().equals(2)) {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(1, allId));
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(4, railwayEntrust.getId(), railwayEntrust.getQualityName(), railwayEntrust.getUserCompId()));
|
}
|
if (StrUtil.isNotEmpty(fileUrl)) {
|
for (String s : fileUrl.split(",")) {
|
fileUploadService.uploadUrlToBip(railwayEntrust.getId(), resBipBody.getId(), s);
|
}
|
}*/
|
//发票
|
railwayEntrust.setBipStatus(200);
|
fpInvoiceResultService.update(new UpdateWrapper<InvoiceResult>().lambda()
|
.eq(InvoiceResult::getEntrustCode, railwayEntrust.getEntrustCode())
|
.set(InvoiceResult::getPushBip, null));
|
//fpInvoiceResultService.pushBlue(railwayEntrust, 0);
|
//fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(2, allId));
|
} catch (Exception e) {
|
//railwayEntrust.setBipFileStatus(-1);
|
log.error("结算单推送附件错误---", e);
|
e.printStackTrace();
|
}
|
}
|
}
|
return bipResVo;
|
}
|
|
@Override
|
public BipResVo sendBIPYs(SaleCredit railwayEntrust) {
|
BIPBody bipBody = new BIPBody();
|
BIPYsMxHeader mx = new BIPYsMxHeader();
|
List<BIPYsItem> bipYsItems = new ArrayList<>();
|
// mx.(railwayEntrust.getFyCompName());//发运矿
|
//mx.setMX01_code(fromStation2);//发站
|
/*if (accountLedger.getId().equals(80) || accountLedger.getId().equals(81) && !accountLedger.getId().equals(82)) {
|
contractNum = "";
|
}*/
|
if (StrUtil.isNotEmpty(railwayEntrust.getContractNo())) {
|
mx.setHTBMBT(1);
|
} else {
|
mx.setHTBMBT(0);
|
}
|
mx.setContractNo(railwayEntrust.getContractNo());
|
//mx.setMX021_code(customerCode);//收货客户
|
//mx.setMX031_code(customerCode);//结算客户
|
//mx.setMX04(number);//结算单号
|
mx.setMX0401(railwayEntrust.getEntrustCode());//托收单号
|
//mx.setMX051_code(businessType);//业务种类
|
//mx.setMX06(createName);//创建人
|
//mx.setMX07(railwayEntrust.getUserName());//审核人
|
|
//mx.setGX08_code(accountUnitNumber);//核算单元
|
//String remark = getRemark(railwayEntrust, "销", customerCode, id2);
|
mx.setRemarks(railwayEntrust.getInvoiceRemark());
|
//String fileUrl = fileUploadService.fileUpload(6, railwayEntrust.getId());
|
mx.setFk_002(3);
|
/*if (StrUtil.isNotEmpty(fileUrl) && "01".equals(jyType)) {
|
mx.setFk_002(3 + fileUrl.split(",").length);
|
}*/
|
/*if (railwayEntrust.getFatherEntrustId() != null) {
|
fileUrl = fileUploadService.fileUpload(6, contractNum);
|
mx.setFk_002(3);
|
if (StrUtil.isNotEmpty(fileUrl) && "01".equals(jyType)) {
|
mx.setFk_002(3 + fileUrl.split(",").length);
|
}
|
}*/
|
bipBody.setBustypeCode("MXysfp");
|
//bipBody.setStaffCode(userCode);
|
// bipBody.setFk_038_code(userCode);
|
bipBody.setObjectType("1");
|
//bipBody.setCustomerCode(customerCode);
|
bipBody.setExtVouchCode(railwayEntrust.getEntrustCode());//煤销系统单号
|
|
//bipBody.setFinanceOrgCode(id2);//开票组织ID
|
bipBody.setDirection("1");//单据方向 1蓝 -1红
|
bipBody.setBillDate(DateUtil.format(new Date(), "yyyy-MM-dd"));//开票日期
|
// bipBody.setBillDate(DateUtil.format(railwayEntrust.getBalanceDate(), "yyyy-MM-dd"));//开票日期
|
|
// if ("0101".equals(jyType)){
|
//
|
// }
|
//bipBody.setContractNo(contractNum);
|
//bipBody.setOrgCode(id2);//业务组织id
|
//bipBody.setDeptCode(deptCode);
|
bipBody.setExchangeRateDate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
// bipBody.setExchangeRateDate(DateUtil.format(railwayEntrust.getBalanceDate(), "yyyy-MM-dd HH:mm:ss"));
|
// bipBody.setCustomer();//客户编码
|
|
//bipBody.setRemarks(remark);
|
|
//表体
|
//煤种类目
|
BIPYsItem bipYsItem = new BIPYsItem();
|
// bipYsItem.setExchangeRateDate(DateUtil.format(railwayEntrust.getBalanceDate(),"yyyy-MM-dd HH:mm:ss"));
|
|
//bipYsItem.setTaxRate(NumUtils.multiplyDouble(railwayEntrust.getTaxRate(),100d));
|
//bipYsItem.setUnitName("吨");
|
|
/*bipYsItem.setMaterialCode("7704000001");
|
bipYsItem.setQuantity(BigDecimal.valueOf(railwayEntrust.getTonnage()));
|
bipYsItem.setCustomerCode(customerCode);//客户编码
|
Double noTaxPrice = railwayEntrust.getPrice();
|
bipYsItem.setOriTaxAmount(BigDecimal.valueOf(railwayEntrust.getTaxFee()));//税额
|
String[] codes = expenseItemCode.get().split(",");
|
bipYsItem.setExpenseItemCode(codes[0]);
|
|
Double allPrice = railwayEntrust.getTotalPrice();
|
bipYsItem.setOriTaxExcludedAmount(BigDecimal.valueOf(railwayEntrust.getCoalFree()));//原币无税金额
|
bipYsItem.setOriTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getTotalPrice()));//原币含税金额
|
bipYsItem.setLocalTaxExcludedAmount(BigDecimal.valueOf(railwayEntrust.getCoalFree()));//本币无税金额
|
bipYsItem.setLocalTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getTotalPrice()));//本币含税金额
|
bipYsItem.setOriTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCoalFree(), railwayEntrust.getTonnage(), 8));//无税单价
|
bipYsItem.setLocalTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCoalFree(), railwayEntrust.getTonnage(), 8));//无税单价
|
Double realPrice = NumUtils.divideDouble(railwayEntrust.getTotalPrice(), railwayEntrust.getTonnage(), 8);
|
bipYsItem.setOriTaxIncludedPrice(realPrice);//本币含税单价
|
bipYsItem.setLocalTaxIncludedPrice(realPrice);//本币含税单价
|
//分割单金额
|
if (CompUtils.isTsCustomer(railwayEntrust.getCustomerId())) {
|
if (railwayEntrust.getFatherEntrustId() == null) {
|
|
Double noTaxMoney = railwayEntrust.getCoalMoney();
|
Double taxMoney = railwayEntrust.getCoalTaxMoney();
|
Double allMoney = NumUtils.addDouble(noTaxMoney, taxMoney, 2);
|
allPrice = allMoney;
|
bipYsItem.setOriTaxAmount(BigDecimal.valueOf(taxMoney));//税额
|
bipYsItem.setOriTaxExcludedAmount(BigDecimal.valueOf(noTaxMoney));//原币无税金额
|
bipYsItem.setOriTaxIncludedAmount(BigDecimal.valueOf(allMoney));//原币含税金额
|
bipYsItem.setLocalTaxExcludedAmount(BigDecimal.valueOf(noTaxMoney));//本币无税金额
|
bipYsItem.setLocalTaxIncludedAmount(BigDecimal.valueOf(allMoney));//本币含税金额
|
bipYsItem.setOriTaxExcludedPrice(railwayEntrust.getPrice());//无税单价
|
bipYsItem.setLocalTaxExcludedPrice(railwayEntrust.getPrice());//无税单价
|
bipYsItem.setOriTaxIncludedPrice(NumUtils.divideDouble(allMoney, railwayEntrust.getTonnage(), 8));//本币含税单价
|
bipYsItem.setLocalTaxIncludedPrice(NumUtils.divideDouble(allMoney, railwayEntrust.getTonnage(), 8));//本币含税单价
|
}
|
|
}
|
bipYsItem.setRemarks(remark);*/
|
|
//煤种表体
|
BIPYsMx bipYsMx = new BIPYsMx();
|
//bipYsMx.setJT12_code(ncCoalNumber);//物料编码
|
// bipYsMx.setJT25_code(codes[1]);
|
//bipYsMx.setGX06_code(coalBipCode);//物料名称
|
|
//bipYsMx.setMX021_code(customerCode);//收货客户
|
//bipYsMx.setCustomerCode(customerAddressCode);//客户编码
|
bipYsMx.setJT06_code("01001001");//款项明细
|
bipYsMx.setYSYF14_code("2");
|
/*if (id2!=null){
|
*//*if (id2 != null && id2.equals("10439") && railwayEntrust.getCoalId() != null && railwayEntrust.getCoalId().equals(45)) {
|
bipYsMx.setJT12_code("0101020401");//物料编码
|
bipYsMx.setGX06_code("01010201043902438");//物料名称
|
}*//*
|
if (id2.equals("126") || id2.equals("10439") || id2.equals("1045116") || id2.equals("104810210") || id2.equals("1027902")) {
|
bipBody.setYSYF_08("0");
|
bipYsMx.setYSYF_08("0");
|
}
|
if (id2.startsWith("104")) {
|
if (focus) {
|
bipYsMx.setYSYF52("0");
|
} else {
|
bipYsMx.setYSYF52("1");
|
}
|
|
}
|
|
}
|
bipYsMx.setGX08_code(accountUnitNumber);*/
|
/*bipYsMx.setMX09(railwayEntrust.getCoalName());//运销煤种
|
bipYsMx.setMX10(BigDecimal.valueOf(railwayEntrust.getRealTonnage()));//水煤量
|
bipYsMx.setMX11(railwayEntrust.getAshContentMetering());//灰分
|
bipYsMx.setMX13(railwayEntrust.getMoistureMetering());
|
bipYsMx.setMX14(railwayEntrust.getSulFurMetering());
|
bipYsMx.setMX15(railwayEntrust.getCoalName());
|
if (railwayEntrust.getInvoiceResultId() == null && !CompUtils.isKp(accountLedger.getId()) && !accountLedger.getId().equals(165)) {
|
throw new RuntimeException("结算单未开票");
|
}*/
|
InvoiceResult invoiceResult = fpInvoiceResultService.getById(railwayEntrust.getBlueInvoiceResultId());
|
if (invoiceResult != null) {
|
bipYsMx.setYSYF33(invoiceResult.getInvoiceNo());
|
bipYsItem.setInvoiceNo(invoiceResult.getInvoiceNo());
|
// bipYsMx.setInvoiceNo(invoiceResult.getInvoiceNo());
|
}
|
bipYsMx.setZzbkfl_code("01");
|
/*if (StrUtil.isNotEmpty(accountLedger.getZzbkfl())) {
|
bipYsMx.setZzbkfl_code(accountLedger.getZzbkfl());
|
}
|
String jyType1 = jyType;//特殊交易单
|
if (jyType.equals("0101") && railwayEntrust.getCustomerId() != null && railwayEntrust.getCustomerId().equals(203)) {
|
jyType1 = "01020202";
|
}
|
|
if (jyType.equals("0101") && railwayEntrust.getCustomerId() != null && (railwayEntrust.getCustomerId().equals(172) || railwayEntrust.getCustomerId().equals(200) || railwayEntrust.getCustomerId().equals(2002381))) {
|
jyType1 = "010201";
|
}*/
|
|
//bipYsMx.setJT04_code(jyType1);
|
//bipYsMx.setMX16(railwayEntrust.getTonnage());//折干量
|
bipYsItem.setFreeChId(bipYsMx);
|
// bipYsMx.setMX18(railwayEntrust.getRealTonnage());//标煤量
|
// bipYsMx.setMX18(railwayEntrust.getRealPrice());//标煤量单价
|
//收款计划
|
/*if (focus) {
|
List<BIPPayPlan> bipPayPlans = this.getBipPayPlan(railwayEntrust, allPrice);
|
bipYsItem.setGrandsonItem(bipPayPlans);
|
}*/
|
bipYsItems.add(bipYsItem);
|
String invoiceNo = invoiceResult == null ? "" : invoiceResult.getInvoiceNo();
|
|
/*if (railwayEntrust.getCustomerId() != null && (railwayEntrust.getCustomerId().equals(618) || railwayEntrust.getCustomerId().equals(608) || railwayEntrust.getCustomerId().equals(1367) || railwayEntrust.getCustomerId().equals(1002134))) {
|
this.getTsBt(railwayEntrust, customerCode, jyType1, focus, bipYsItems, isNd, accountUnitNumber, id2, fromStation, invoiceNo, contractNum);
|
} else {
|
this.getPtBt(railwayEntrust, customerCode, jyType1, focus, bipYsItems, isNd, accountUnitNumber, id2, fromStation, invoiceNo, contractNum);
|
}*/
|
|
bipBody.setBodyItem(bipYsItems);
|
|
/*if (railwayEntrust.getFatherEntrustId() == null && !railwayEntrust.getFyCompId().equals(227) && !order.getFiledId().equals(48)) {
|
List<Contract> contracts = fileUploadService.getContractsByEntrustId(railwayEntrust.getId());
|
System.out.println("重复合同:" + contracts.size() + "上级ID:" + railwayEntrust.getFatherEntrustId() + "结算单号:" + railwayEntrust.getEntrustCode());
|
if (contracts != null && contracts.size() > 0) {
|
contracts.forEach(e -> {
|
BIPYsMxHeader newMx = new BIPYsMxHeader();
|
BeanUtils.copyProperties(mx, newMx);
|
if (accountLedger.getId().equals(80) || accountLedger.getId().equals(81) || accountLedger.getId().equals(82)) {
|
newMx.setContractNo("");
|
newMx.setHTBMBT(0);
|
} else {
|
newMx.setContractNo(e.getNum());
|
newMx.setHTBMBT(1);
|
}
|
|
bipBody.setFreeChId(newMx);
|
});
|
}
|
|
} else {
|
bipBody.setFreeChId(mx);
|
}*/
|
|
|
String result = bipHttpUtil.post(BipApiEnum.应收发票保存接口, new JSONObject().set("data", bipBody));
|
BipResVo resVo = JSONUtil.toBean(result, BipResVo.class);
|
//放到单据记录表
|
BipInvoice bipInvoice = new BipInvoice();
|
bipInvoice.setDay(DateUtil.date());
|
bipInvoice.setInvoice(JSONUtil.toJsonStr(bipBody));
|
bipInvoice.setType(0);
|
bipInvoice.setInvoiceType(0);
|
bipInvoice.setContractNum(railwayEntrust.getContractNo());
|
bipInvoice.setRailwayEntrustId(railwayEntrust.getId());
|
//bipInvoice.setAllId(Long.parseLong(allId+""));
|
bipInvoice.setBipCompNumber("id2");
|
bipInvoice.setDirection(1);
|
bipInvoice.setCompId(railwayEntrust.getCompId());
|
bipInvoice.setResStatus(resVo.getCode());
|
// bipInvoice.setMoney(railwayEntrust.getAllPrice());
|
// bipInvoice.setTonnage(railwayEntrust.getTonnage());
|
// bipInvoice.setPrice(railwayEntrust.getPrice());
|
//bipInvoice.setTrainType(railwayEntrust.getTrainType());
|
BipResVo bipResVo = new BipResVo<>();
|
bipResVo.setCode(resVo.getCode());
|
BIPBody resBipBody = null;
|
if (resVo.getData() == null) {
|
resBipBody = new BIPBody();
|
} else {
|
resBipBody = JSONUtil.toBean(resVo.getData().toString(), BIPBody.class);
|
}
|
|
|
if (resVo.getCode().equals("200") || (StrUtil.isNotEmpty(resVo.getMessage()) && resVo.getMessage().contains("活动[财务审核]上找不到用户")) || StrUtil.isNotEmpty(resBipBody.getCode())) {
|
bipInvoice.setResInvoice(resVo.getData().toString());
|
|
bipInvoice.setBipNumber(resBipBody.getId());
|
// bipInvoice.setCode("200");
|
bipInvoice.setCode(resBipBody.getCode());
|
bipInvoice.setMessage(resVo.getMessage());
|
bipInvoiceService.save(bipInvoice);
|
bipResVo.setCode("200");
|
|
} else {
|
if (resVo.getData() != null && StrUtil.isNotEmpty(resVo.getData().toString())) {
|
bipInvoice.setBipNumber(resBipBody.getId());
|
bipInvoice.setCode(resBipBody.getCode());
|
}
|
bipInvoice.setMessage(resVo.getMessage());
|
bipResVo.setMessage(resVo.getMessage());
|
bipInvoiceService.save(bipInvoice);
|
|
}
|
if (resVo.getData() != null && StrUtil.isNotEmpty(resVo.getData().toString())) {
|
if (resBipBody.getId() != null) {
|
try {
|
/*if (railwayEntrust.getTrainType().equals(1)) {
|
if (order != null && order.getCompId() != null && order.getCompId().equals(227) && order.getFiledId() != null && order.getFiledId().equals(48)) {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(8, allId));
|
} else {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(0, allId));
|
}
|
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(3, railwayEntrust.getId(), railwayEntrust.getQualityName(), railwayEntrust.getUserCompId()));
|
} else if (railwayEntrust.getTrainType().equals(2)) {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(1, allId));
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(4, railwayEntrust.getId(), railwayEntrust.getQualityName(), railwayEntrust.getUserCompId()));
|
}
|
if (StrUtil.isNotEmpty(fileUrl)) {
|
for (String s : fileUrl.split(",")) {
|
fileUploadService.uploadUrlToBip(railwayEntrust.getId(), resBipBody.getId(), s);
|
}
|
}*/
|
//发票
|
railwayEntrust.setBipStatus(200);
|
fpInvoiceResultService.update(new UpdateWrapper<InvoiceResult>().lambda()
|
.eq(InvoiceResult::getEntrustCode, railwayEntrust.getEntrustCode())
|
.set(InvoiceResult::getPushBip, null));
|
//fpInvoiceResultService.pushBlue(railwayEntrust, 0);
|
//fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(2, allId));
|
} catch (Exception e) {
|
//railwayEntrust.setBipFileStatus(-1);
|
log.error("结算单推送附件错误---", e);
|
e.printStackTrace();
|
}
|
}
|
}
|
return bipResVo;
|
}
|
|
@Override
|
public BipResVo sendBIPYss(BillingInfo railwayEntrust) {
|
BIPBody bipBody = new BIPBody();
|
BIPYsMxHeader mx = new BIPYsMxHeader();
|
List<BIPYsItem> bipYsItems = new ArrayList<>();
|
// mx.(railwayEntrust.getFyCompName());//发运矿
|
//mx.setMX01_code(fromStation2);//发站
|
/*if (accountLedger.getId().equals(80) || accountLedger.getId().equals(81) && !accountLedger.getId().equals(82)) {
|
contractNum = "";
|
}*/
|
if (StrUtil.isNotEmpty(railwayEntrust.getContractNo())) {
|
mx.setHTBMBT(1);
|
} else {
|
mx.setHTBMBT(0);
|
}
|
mx.setContractNo(railwayEntrust.getContractNo());
|
//mx.setMX021_code(customerCode);//收货客户
|
//mx.setMX031_code(customerCode);//结算客户
|
//mx.setMX04(number);//结算单号
|
mx.setMX0401(railwayEntrust.getEntrustCode());//托收单号
|
//mx.setMX051_code(businessType);//业务种类
|
//mx.setMX06(createName);//创建人
|
//mx.setMX07(railwayEntrust.getUserName());//审核人
|
|
//mx.setGX08_code(accountUnitNumber);//核算单元
|
//String remark = getRemark(railwayEntrust, "销", customerCode, id2);
|
mx.setRemarks(railwayEntrust.getInvoiceRemark());
|
//String fileUrl = fileUploadService.fileUpload(6, railwayEntrust.getId());
|
mx.setFk_002(3);
|
/*if (StrUtil.isNotEmpty(fileUrl) && "01".equals(jyType)) {
|
mx.setFk_002(3 + fileUrl.split(",").length);
|
}*/
|
/*if (railwayEntrust.getFatherEntrustId() != null) {
|
fileUrl = fileUploadService.fileUpload(6, contractNum);
|
mx.setFk_002(3);
|
if (StrUtil.isNotEmpty(fileUrl) && "01".equals(jyType)) {
|
mx.setFk_002(3 + fileUrl.split(",").length);
|
}
|
}*/
|
bipBody.setBustypeCode("MXysfp");
|
//bipBody.setStaffCode(userCode);
|
// bipBody.setFk_038_code(userCode);
|
bipBody.setObjectType("1");
|
//bipBody.setCustomerCode(customerCode);
|
bipBody.setExtVouchCode(railwayEntrust.getEntrustCode());//煤销系统单号
|
|
//bipBody.setFinanceOrgCode(id2);//开票组织ID
|
bipBody.setDirection("1");//单据方向 1蓝 -1红
|
bipBody.setBillDate(DateUtil.format(new Date(), "yyyy-MM-dd"));//开票日期
|
// bipBody.setBillDate(DateUtil.format(railwayEntrust.getBalanceDate(), "yyyy-MM-dd"));//开票日期
|
|
// if ("0101".equals(jyType)){
|
//
|
// }
|
//bipBody.setContractNo(contractNum);
|
//bipBody.setOrgCode(id2);//业务组织id
|
//bipBody.setDeptCode(deptCode);
|
bipBody.setExchangeRateDate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
// bipBody.setExchangeRateDate(DateUtil.format(railwayEntrust.getBalanceDate(), "yyyy-MM-dd HH:mm:ss"));
|
// bipBody.setCustomer();//客户编码
|
|
//bipBody.setRemarks(remark);
|
|
//表体
|
//煤种类目
|
BIPYsItem bipYsItem = new BIPYsItem();
|
// bipYsItem.setExchangeRateDate(DateUtil.format(railwayEntrust.getBalanceDate(),"yyyy-MM-dd HH:mm:ss"));
|
|
//bipYsItem.setTaxRate(NumUtils.multiplyDouble(railwayEntrust.getTaxRate(),100d));
|
//bipYsItem.setUnitName("吨");
|
|
/*bipYsItem.setMaterialCode("7704000001");
|
bipYsItem.setQuantity(BigDecimal.valueOf(railwayEntrust.getTonnage()));
|
bipYsItem.setCustomerCode(customerCode);//客户编码
|
Double noTaxPrice = railwayEntrust.getPrice();
|
bipYsItem.setOriTaxAmount(BigDecimal.valueOf(railwayEntrust.getTaxFee()));//税额
|
String[] codes = expenseItemCode.get().split(",");
|
bipYsItem.setExpenseItemCode(codes[0]);
|
|
Double allPrice = railwayEntrust.getTotalPrice();
|
bipYsItem.setOriTaxExcludedAmount(BigDecimal.valueOf(railwayEntrust.getCoalFree()));//原币无税金额
|
bipYsItem.setOriTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getTotalPrice()));//原币含税金额
|
bipYsItem.setLocalTaxExcludedAmount(BigDecimal.valueOf(railwayEntrust.getCoalFree()));//本币无税金额
|
bipYsItem.setLocalTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getTotalPrice()));//本币含税金额
|
bipYsItem.setOriTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCoalFree(), railwayEntrust.getTonnage(), 8));//无税单价
|
bipYsItem.setLocalTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCoalFree(), railwayEntrust.getTonnage(), 8));//无税单价
|
Double realPrice = NumUtils.divideDouble(railwayEntrust.getTotalPrice(), railwayEntrust.getTonnage(), 8);
|
bipYsItem.setOriTaxIncludedPrice(realPrice);//本币含税单价
|
bipYsItem.setLocalTaxIncludedPrice(realPrice);//本币含税单价
|
//分割单金额
|
if (CompUtils.isTsCustomer(railwayEntrust.getCustomerId())) {
|
if (railwayEntrust.getFatherEntrustId() == null) {
|
|
Double noTaxMoney = railwayEntrust.getCoalMoney();
|
Double taxMoney = railwayEntrust.getCoalTaxMoney();
|
Double allMoney = NumUtils.addDouble(noTaxMoney, taxMoney, 2);
|
allPrice = allMoney;
|
bipYsItem.setOriTaxAmount(BigDecimal.valueOf(taxMoney));//税额
|
bipYsItem.setOriTaxExcludedAmount(BigDecimal.valueOf(noTaxMoney));//原币无税金额
|
bipYsItem.setOriTaxIncludedAmount(BigDecimal.valueOf(allMoney));//原币含税金额
|
bipYsItem.setLocalTaxExcludedAmount(BigDecimal.valueOf(noTaxMoney));//本币无税金额
|
bipYsItem.setLocalTaxIncludedAmount(BigDecimal.valueOf(allMoney));//本币含税金额
|
bipYsItem.setOriTaxExcludedPrice(railwayEntrust.getPrice());//无税单价
|
bipYsItem.setLocalTaxExcludedPrice(railwayEntrust.getPrice());//无税单价
|
bipYsItem.setOriTaxIncludedPrice(NumUtils.divideDouble(allMoney, railwayEntrust.getTonnage(), 8));//本币含税单价
|
bipYsItem.setLocalTaxIncludedPrice(NumUtils.divideDouble(allMoney, railwayEntrust.getTonnage(), 8));//本币含税单价
|
}
|
|
}
|
bipYsItem.setRemarks(remark);*/
|
|
//煤种表体
|
BIPYsMx bipYsMx = new BIPYsMx();
|
//bipYsMx.setJT12_code(ncCoalNumber);//物料编码
|
// bipYsMx.setJT25_code(codes[1]);
|
//bipYsMx.setGX06_code(coalBipCode);//物料名称
|
|
//bipYsMx.setMX021_code(customerCode);//收货客户
|
//bipYsMx.setCustomerCode(customerAddressCode);//客户编码
|
bipYsMx.setJT06_code("01001001");//款项明细
|
bipYsMx.setYSYF14_code("2");
|
/*if (id2!=null){
|
*//*if (id2 != null && id2.equals("10439") && railwayEntrust.getCoalId() != null && railwayEntrust.getCoalId().equals(45)) {
|
bipYsMx.setJT12_code("0101020401");//物料编码
|
bipYsMx.setGX06_code("01010201043902438");//物料名称
|
}*//*
|
if (id2.equals("126") || id2.equals("10439") || id2.equals("1045116") || id2.equals("104810210") || id2.equals("1027902")) {
|
bipBody.setYSYF_08("0");
|
bipYsMx.setYSYF_08("0");
|
}
|
if (id2.startsWith("104")) {
|
if (focus) {
|
bipYsMx.setYSYF52("0");
|
} else {
|
bipYsMx.setYSYF52("1");
|
}
|
|
}
|
|
}
|
bipYsMx.setGX08_code(accountUnitNumber);*/
|
/*bipYsMx.setMX09(railwayEntrust.getCoalName());//运销煤种
|
bipYsMx.setMX10(BigDecimal.valueOf(railwayEntrust.getRealTonnage()));//水煤量
|
bipYsMx.setMX11(railwayEntrust.getAshContentMetering());//灰分
|
bipYsMx.setMX13(railwayEntrust.getMoistureMetering());
|
bipYsMx.setMX14(railwayEntrust.getSulFurMetering());
|
bipYsMx.setMX15(railwayEntrust.getCoalName());
|
if (railwayEntrust.getInvoiceResultId() == null && !CompUtils.isKp(accountLedger.getId()) && !accountLedger.getId().equals(165)) {
|
throw new RuntimeException("结算单未开票");
|
}*/
|
InvoiceResult invoiceResult = fpInvoiceResultService.getById(railwayEntrust.getBlueInvoiceResultId());
|
if (invoiceResult != null) {
|
bipYsMx.setYSYF33(invoiceResult.getInvoiceNo());
|
bipYsItem.setInvoiceNo(invoiceResult.getInvoiceNo());
|
// bipYsMx.setInvoiceNo(invoiceResult.getInvoiceNo());
|
}
|
bipYsMx.setZzbkfl_code("01");
|
/*if (StrUtil.isNotEmpty(accountLedger.getZzbkfl())) {
|
bipYsMx.setZzbkfl_code(accountLedger.getZzbkfl());
|
}
|
String jyType1 = jyType;//特殊交易单
|
if (jyType.equals("0101") && railwayEntrust.getCustomerId() != null && railwayEntrust.getCustomerId().equals(203)) {
|
jyType1 = "01020202";
|
}
|
|
if (jyType.equals("0101") && railwayEntrust.getCustomerId() != null && (railwayEntrust.getCustomerId().equals(172) || railwayEntrust.getCustomerId().equals(200) || railwayEntrust.getCustomerId().equals(2002381))) {
|
jyType1 = "010201";
|
}*/
|
|
//bipYsMx.setJT04_code(jyType1);
|
//bipYsMx.setMX16(railwayEntrust.getTonnage());//折干量
|
bipYsItem.setFreeChId(bipYsMx);
|
// bipYsMx.setMX18(railwayEntrust.getRealTonnage());//标煤量
|
// bipYsMx.setMX18(railwayEntrust.getRealPrice());//标煤量单价
|
//收款计划
|
/*if (focus) {
|
List<BIPPayPlan> bipPayPlans = this.getBipPayPlan(railwayEntrust, allPrice);
|
bipYsItem.setGrandsonItem(bipPayPlans);
|
}*/
|
bipYsItems.add(bipYsItem);
|
String invoiceNo = invoiceResult == null ? "" : invoiceResult.getInvoiceNo();
|
|
/*if (railwayEntrust.getCustomerId() != null && (railwayEntrust.getCustomerId().equals(618) || railwayEntrust.getCustomerId().equals(608) || railwayEntrust.getCustomerId().equals(1367) || railwayEntrust.getCustomerId().equals(1002134))) {
|
this.getTsBt(railwayEntrust, customerCode, jyType1, focus, bipYsItems, isNd, accountUnitNumber, id2, fromStation, invoiceNo, contractNum);
|
} else {
|
this.getPtBt(railwayEntrust, customerCode, jyType1, focus, bipYsItems, isNd, accountUnitNumber, id2, fromStation, invoiceNo, contractNum);
|
}*/
|
|
bipBody.setBodyItem(bipYsItems);
|
|
/*if (railwayEntrust.getFatherEntrustId() == null && !railwayEntrust.getFyCompId().equals(227) && !order.getFiledId().equals(48)) {
|
List<Contract> contracts = fileUploadService.getContractsByEntrustId(railwayEntrust.getId());
|
System.out.println("重复合同:" + contracts.size() + "上级ID:" + railwayEntrust.getFatherEntrustId() + "结算单号:" + railwayEntrust.getEntrustCode());
|
if (contracts != null && contracts.size() > 0) {
|
contracts.forEach(e -> {
|
BIPYsMxHeader newMx = new BIPYsMxHeader();
|
BeanUtils.copyProperties(mx, newMx);
|
if (accountLedger.getId().equals(80) || accountLedger.getId().equals(81) || accountLedger.getId().equals(82)) {
|
newMx.setContractNo("");
|
newMx.setHTBMBT(0);
|
} else {
|
newMx.setContractNo(e.getNum());
|
newMx.setHTBMBT(1);
|
}
|
|
bipBody.setFreeChId(newMx);
|
});
|
}
|
|
} else {
|
bipBody.setFreeChId(mx);
|
}*/
|
|
|
String result = bipHttpUtil.post(BipApiEnum.应收发票保存接口, new JSONObject().set("data", bipBody));
|
BipResVo resVo = JSONUtil.toBean(result, BipResVo.class);
|
//放到单据记录表
|
BipInvoice bipInvoice = new BipInvoice();
|
bipInvoice.setDay(DateUtil.date());
|
bipInvoice.setInvoice(JSONUtil.toJsonStr(bipBody));
|
bipInvoice.setType(0);
|
bipInvoice.setInvoiceType(0);
|
bipInvoice.setContractNum(railwayEntrust.getContractNo());
|
bipInvoice.setRailwayEntrustId(railwayEntrust.getId());
|
//bipInvoice.setAllId(Long.parseLong(allId+""));
|
bipInvoice.setBipCompNumber("id2");
|
bipInvoice.setDirection(1);
|
bipInvoice.setCompId(railwayEntrust.getCompId());
|
bipInvoice.setResStatus(resVo.getCode());
|
// bipInvoice.setMoney(railwayEntrust.getAllPrice());
|
// bipInvoice.setTonnage(railwayEntrust.getTonnage());
|
// bipInvoice.setPrice(railwayEntrust.getPrice());
|
//bipInvoice.setTrainType(railwayEntrust.getTrainType());
|
BipResVo bipResVo = new BipResVo<>();
|
bipResVo.setCode(resVo.getCode());
|
BIPBody resBipBody = null;
|
if (resVo.getData() == null) {
|
resBipBody = new BIPBody();
|
} else {
|
resBipBody = JSONUtil.toBean(resVo.getData().toString(), BIPBody.class);
|
}
|
|
|
if (resVo.getCode().equals("200") || (StrUtil.isNotEmpty(resVo.getMessage()) && resVo.getMessage().contains("活动[财务审核]上找不到用户")) || StrUtil.isNotEmpty(resBipBody.getCode())) {
|
bipInvoice.setResInvoice(resVo.getData().toString());
|
|
bipInvoice.setBipNumber(resBipBody.getId());
|
// bipInvoice.setCode("200");
|
bipInvoice.setCode(resBipBody.getCode());
|
bipInvoice.setMessage(resVo.getMessage());
|
bipInvoiceService.save(bipInvoice);
|
bipResVo.setCode("200");
|
|
} else {
|
if (resVo.getData() != null && StrUtil.isNotEmpty(resVo.getData().toString())) {
|
bipInvoice.setBipNumber(resBipBody.getId());
|
bipInvoice.setCode(resBipBody.getCode());
|
}
|
bipInvoice.setMessage(resVo.getMessage());
|
bipResVo.setMessage(resVo.getMessage());
|
bipInvoiceService.save(bipInvoice);
|
|
}
|
if (resVo.getData() != null && StrUtil.isNotEmpty(resVo.getData().toString())) {
|
if (resBipBody.getId() != null) {
|
try {
|
/*if (railwayEntrust.getTrainType().equals(1)) {
|
if (order != null && order.getCompId() != null && order.getCompId().equals(227) && order.getFiledId() != null && order.getFiledId().equals(48)) {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(8, allId));
|
} else {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(0, allId));
|
}
|
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(3, railwayEntrust.getId(), railwayEntrust.getQualityName(), railwayEntrust.getUserCompId()));
|
} else if (railwayEntrust.getTrainType().equals(2)) {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(1, allId));
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(4, railwayEntrust.getId(), railwayEntrust.getQualityName(), railwayEntrust.getUserCompId()));
|
}
|
if (StrUtil.isNotEmpty(fileUrl)) {
|
for (String s : fileUrl.split(",")) {
|
fileUploadService.uploadUrlToBip(railwayEntrust.getId(), resBipBody.getId(), s);
|
}
|
}*/
|
//发票
|
railwayEntrust.setBipStatus(200);
|
fpInvoiceResultService.update(new UpdateWrapper<InvoiceResult>().lambda()
|
.eq(InvoiceResult::getEntrustCode, railwayEntrust.getEntrustCode())
|
.set(InvoiceResult::getPushBip, null));
|
//fpInvoiceResultService.pushBlue(railwayEntrust, 0);
|
//fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(2, allId));
|
} catch (Exception e) {
|
//railwayEntrust.setBipFileStatus(-1);
|
log.error("结算单推送附件错误---", e);
|
e.printStackTrace();
|
}
|
}
|
}
|
return bipResVo;
|
}
|
|
|
public BipResVo sendBIPYf(SaleCredit railwayEntrust,String id1,String id2,String customerCode,String businessType,String fromStation,Integer allId,String contractNum,String number,String jyType,String accountUnitNumber,String deptCode,String userCode,Integer isNd) {
|
// BipResVo bipResVo1 = new BipResVo<>();
|
// bipResVo1.setCode("200");
|
// BipInvoice bipInvoice1 = new BipInvoice();
|
// bipInvoice1.setDay(DateUtil.date());
|
// bipInvoice1.setBipCompNumber(id2);
|
// bipInvoice1.setType(0);
|
// bipInvoice1.setInvoiceType(1);
|
// bipInvoice1.setRailwayEntrustId(railwayEntrust.getId());
|
// bipInvoice1.setAllId(allId);
|
// bipInvoice1.setCompId(railwayEntrust.getCompId());
|
// bipInvoice1.setMoney(railwayEntrust.getAllPrice());
|
// bipInvoice1.setTonnage(railwayEntrust.getTonnage());
|
// bipInvoice1.setPrice(railwayEntrust.getPrice());
|
// bipInvoice1.setResStatus("200");
|
// bipInvoice1.setDirection(1);
|
// bipInvoice1.setTrainType(railwayEntrust.getTrainType());
|
// bipInvoiceService.save(bipInvoice1);
|
// if (true){
|
// return bipResVo1;
|
// }
|
/*Map<String, String> dictMap = RedisCacheHelper.getInstance().getDictMapByType("bip_expense_item");
|
AtomicReference<String> expenseItemCode = new AtomicReference<>("12008001001,01");
|
|
List<ContractOrder> orders = contractOrderService.list(new QueryWrapper<ContractOrder>().lambda().eq(ContractOrder::getNumber, railwayEntrust.getOrderNumber()));
|
ContractOrder order = orders.get(0);
|
dictMap.forEach((k, v) -> {
|
if (k.equals(railwayEntrust.getCoalId().toString())) {
|
expenseItemCode.set(v);
|
}
|
});
|
Map<String,String> fromStationMap = RedisCacheHelper.getInstance().getDictMapByType("from_station");//发站
|
String fromStation2 = "";
|
if (railwayEntrust.getTrainType().equals(2) && StrUtil.isNotEmpty(order.getFromStation()) && fromStationMap!=null){
|
fromStation2 = fromStationMap.get(order.getFromStation());
|
}
|
SysUser user = remoteUserService.getByName(railwayEntrust.getCreateBy());
|
String createName = (user==null?"":user.getRealName());*/
|
BIPBody bipBody = new BIPBody();
|
BIPYsMxHeader mx = new BIPYsMxHeader();
|
List<BIPYsItem> bipYsItems = new ArrayList<>();
|
//mx.setMX01_code(fromStation2);//发站
|
mx.setMX031_code(customerCode);//结算客户
|
// mx.setContractNo(contractNum);
|
//mx.setOrderNo(railwayEntrust.getOrderNumber());
|
//String ncCoalNumber = coal.getBipCategoryCode();
|
//String coalBipCode = coal.getBipCode();
|
|
// mx.setMX03("102");//结算客户
|
mx.setMX04(number);//结算单号
|
mx.setMX0401(railwayEntrust.getEntrustCode());//托收单号
|
mx.setMX051_code(businessType);//业务种类
|
//mx.setMX06(createName);//创建人
|
//mx.setMX07(railwayEntrust.getUserName());//审核人
|
mx.setGX08_code(accountUnitNumber);//核算单元档案
|
//String remark = getRemark(railwayEntrust, "购", id2, id1);
|
//mx.setRemarks(remark);
|
//String fileUrl = fileUploadService.fileUpload(6, contractNum);
|
mx.setFk_002(3);
|
/*if (StrUtil.isNotEmpty(fileUrl)) {
|
mx.setFk_002(3 + fileUrl.split(",").length);
|
}*/
|
|
//
|
bipBody.setBustypeCode("MXyffp");
|
bipBody.setObjectType("0");
|
bipBody.setStaffCode(userCode);
|
// bipBody.setFk_038_code(userCode);
|
/*if (accountLedger.getId().equals(80) || accountLedger.getId().equals(81) || accountLedger.getId().equals(82)) {
|
contractNum = "";
|
}*/
|
if (StrUtil.isNotEmpty(contractNum)) {
|
mx.setHTBMBT(1);
|
} else {
|
mx.setHTBMBT(0);
|
}
|
mx.setContractNo(contractNum);
|
bipBody.setContractNo(contractNum);//合同号!!
|
bipBody.setSupplierCode(id1);
|
bipBody.setCustomerCode(customerCode);
|
bipBody.setExtVouchCode(railwayEntrust.getEntrustCode());//煤销系统单号
|
bipBody.setFinanceOrgCode(id2);//收票组织ID
|
bipBody.setDirection("1");//单据方向 1蓝 -1红
|
bipBody.setBillDate(DateUtil.format(new Date(), "yyyy-MM-dd"));//开票日期
|
// bipBody.setBillDate(DateUtil.format(railwayEntrust.getBalanceDate(), "yyyy-MM-dd"));//开票日期
|
bipBody.setDeptCode(deptCode);
|
bipBody.setOrgCode(id2);//业务组织id
|
// bipBody.setExchangeRateDate(DateUtil.format(railwayEntrust.getBalanceDate(), "yyyy-MM-dd HH:mm:ss"));
|
bipBody.setExchangeRateDate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
// bipBody.setCustomer();//客户编码
|
//bipBody.setRemarks(remark);
|
//
|
//
|
BIPYsItem bipYsItem = new BIPYsItem();
|
// bipYsItem.setExchangeRateDate(DateUtil.format(railwayEntrust.getBalanceDate(),"yyyy-MM-dd HH:mm:ss"));
|
|
//bipYsItem.setTaxRate(NumUtils.multiplyDouble(railwayEntrust.getTaxRate(), 100d));
|
|
|
/*bipYsItem.setCustomerCode(id1);//客户编码
|
Double noTaxPrice = NumUtils.divideDouble(railwayEntrust.getCoalFree(), railwayEntrust.getTonnage(), 8);
|
bipYsItem.setOriTaxAmount(BigDecimal.valueOf(railwayEntrust.getTaxFee()));//税额
|
bipYsItem.setOriTaxExcludedAmount(BigDecimal.valueOf(railwayEntrust.getCoalFree()));//原币无税金额
|
bipYsItem.setOriTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getTotalPrice()));//原币含税金额
|
bipYsItem.setLocalTaxExcludedAmount(BigDecimal.valueOf(railwayEntrust.getCoalFree()));//本币无税金额
|
bipYsItem.setLocalTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getTotalPrice()));//本币含税金额
|
bipYsItem.setOriTaxExcludedPrice(noTaxPrice);//无税单价
|
bipYsItem.setLocalTaxExcludedPrice(noTaxPrice);//无税单价
|
Double realPrice = NumUtils.divideDouble(railwayEntrust.getTotalPrice(),railwayEntrust.getTonnage(),8);
|
bipYsItem.setOriTaxIncludedPrice(realPrice);//本币含税单价
|
bipYsItem.setLocalTaxIncludedPrice(realPrice);//本币含税单价
|
Double allPrice = railwayEntrust.getTotalPrice();*/
|
//分割单金额
|
/*if (railwayEntrust.getCustomerId()!=null && (railwayEntrust.getCustomerId().equals(618) || railwayEntrust.getCustomerId().equals(608) || railwayEntrust.getCustomerId().equals(1367)|| railwayEntrust.getCustomerId().equals(1002134))){
|
Double noTaxMoney = NumUtils.multiplyDouble(railwayEntrust.getPrice(),railwayEntrust.getTonnage(),2);
|
Double taxMoney = NumUtils.multiplyDouble(noTaxMoney,railwayEntrust.getTaxRate(),2);
|
Double allMoney = NumUtils.addDouble(noTaxMoney,taxMoney,2);
|
allPrice = allMoney;
|
bipYsItem.setOriTaxAmount(BigDecimal.valueOf(taxMoney));//税额
|
bipYsItem.setOriTaxExcludedAmount(BigDecimal.valueOf(noTaxMoney));//原币无税金额
|
bipYsItem.setOriTaxIncludedAmount(BigDecimal.valueOf(allMoney));//原币含税金额
|
bipYsItem.setLocalTaxExcludedAmount(BigDecimal.valueOf(noTaxMoney));//本币无税金额
|
bipYsItem.setLocalTaxIncludedAmount(BigDecimal.valueOf(allMoney));//本币含税金额
|
bipYsItem.setOriTaxExcludedPrice(railwayEntrust.getPrice());//无税单价
|
bipYsItem.setLocalTaxExcludedPrice(railwayEntrust.getPrice());//无税单价
|
bipYsItem.setOriTaxIncludedPrice(NumUtils.divideDouble(allMoney,railwayEntrust.getTonnage(),8));//本币含税单价
|
bipYsItem.setLocalTaxIncludedPrice(NumUtils.divideDouble(allMoney,railwayEntrust.getTonnage(),8));//本币含税单价
|
}
|
String[] codes = expenseItemCode.get().split(",");*/
|
/*bipYsItem.setExpenseItemCode(codes[0]);//经济事项
|
if (codes[0]!=null && codes[0].equals("09003013")){
|
bipYsItem.setExpenseItemCode("10006011");//经济事项
|
}
|
bipYsItem.setUnitName("吨");
|
bipYsItem.setUnitCode("0110");
|
bipYsItem.setMaterialCode("7704000001");
|
bipYsItem.setQuantity(BigDecimal.valueOf(railwayEntrust.getTonnage()));
|
bipYsItem.setRemarks(remark);*/
|
|
//煤种表体
|
BIPYsMx bipYsMx = new BIPYsMx();
|
// bipYsMx.setJT01("01");//物料编码
|
bipYsMx.setJT04_code(jyType);//交易类型
|
bipYsMx.setJT06_code("01001001");//款项明细
|
bipYsMx.setMX021_code(id1);//收货客户
|
bipYsMx.setCustomerCode(id1);//客户编码
|
// bipYsMx.setJT11("");
|
bipYsMx.setGX08_code(accountUnitNumber);
|
/*bipYsMx.setJT12_code(ncCoalNumber);
|
bipYsMx.setGX06_code(coalBipCode);*/
|
/*if (id2 != null && id2.equals("10439") && railwayEntrust.getCoalId() != null && railwayEntrust.getCoalId().equals(45)) {
|
bipYsMx.setJT12_code("0101020401");//物料编码
|
bipYsMx.setGX06_code("01010201043902438");//物料名称
|
}*/
|
// bipYsMx.setJT25_code(codes[1]);
|
bipYsMx.setYSYF14_code("6");
|
/*bipYsMx.setMX09(railwayEntrust.getCoalName());//运销煤种
|
bipYsMx.setMX10(BigDecimal.valueOf(railwayEntrust.getRealTonnage()));//水煤量
|
bipYsMx.setMX11(railwayEntrust.getAshContentMetering());//灰分
|
bipYsMx.setMX13(railwayEntrust.getMoistureMetering());
|
bipYsMx.setMX14(railwayEntrust.getSulFurMetering());
|
bipYsMx.setMX15(railwayEntrust.getCoalName());
|
bipYsMx.setMX16(railwayEntrust.getTonnage());
|
bipYsMx.setZzbkfl_code("01");
|
if (StrUtil.isNotEmpty(accountLedger.getZzbkfl())) {
|
bipYsMx.setZzbkfl_code(accountLedger.getZzbkfl());
|
}
|
if (id2.equals("10439")) {
|
bipYsItem.setJT09_code(null);
|
bipYsMx.setJT09_code(null);
|
}
|
|
bipYsItem.setFreeChId(bipYsMx);*/
|
// bipYsMx.setMX18(railwayEntrust.getRealTonnage());//标煤量
|
// bipYsMx.setMX18(railwayEntrust.getRealPrice());//标煤量单价
|
if (id2.startsWith("104")) {
|
bipYsMx.setYSYF52("1");
|
}
|
bipYsItems.add(bipYsItem);
|
/*if (id2.equals("1045116")) {
|
//运费
|
if (railwayEntrust.getFreight() != null && railwayEntrust.getFreight() != 0) {
|
BIPYsItem freight = new BIPYsItem();
|
freight.setExpenseItemCode("12005002007002");//经济事项
|
freight.setTaxRate(0.0);
|
freight.setOriTaxExcludedAmount(new BigDecimal(railwayEntrust.getFreight()).setScale(2,BigDecimal.ROUND_HALF_UP));//原币无税金额
|
freight.setOriTaxIncludedAmount(new BigDecimal(railwayEntrust.getFreight()).setScale(2,BigDecimal.ROUND_HALF_UP));//原币含税金额
|
freight.setOriTaxAmount(BigDecimal.valueOf(NumUtils.subtractDouble(railwayEntrust.getFreight(),railwayEntrust.getFreight(),2)));//税额
|
freight.setCustomerCode("104810210");//客户编码
|
freight.setSupplierCode("104810210");
|
freight.setLocalTaxExcludedAmount(new BigDecimal(railwayEntrust.getFreight()).setScale(2,BigDecimal.ROUND_HALF_UP));//本币无税金额
|
freight.setLocalTaxIncludedAmount(new BigDecimal(railwayEntrust.getFreight()).setScale(2,BigDecimal.ROUND_HALF_UP));//本币含税金额
|
freight.setOriTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getFreight(), railwayEntrust.getTonnage().doubleValue(),2));//无税单价
|
freight.setOriTaxIncludedPrice(NumUtils.divideDouble(railwayEntrust.getFreight(), railwayEntrust.getTonnage().doubleValue(),2));//含税单价
|
freight.setLocalTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getFreight(), railwayEntrust.getTonnage().doubleValue(),2));//本币无税单价
|
freight.setLocalTaxIncludedPrice(NumUtils.divideDouble(railwayEntrust.getFreight(), railwayEntrust.getTonnage().doubleValue(),2));//本币含税单价
|
// freight.setExpenseItemCode("1007");
|
//运费表体
|
BIPYsMx freightBipYsMx = new BIPYsMx();
|
if (id2!=null){
|
if (id2.equals("126")|| id2.equals("1045116") || id2.equals("104810210")){
|
freightBipYsMx.setJT06_code("08008");//款项明细
|
} else if (id2.equals("10439")) {
|
freightBipYsMx.setJT06_code("01001001");//款项明细
|
}
|
}
|
|
freightBipYsMx.setGX08_code(fromStation);//核算单元档案
|
// freightBipYsMx.setJT12_code("X0330101");//产品大类
|
// freightBipYsMx.setJT25_code("03");//其他业务明细
|
freightBipYsMx.setYSYF14_code("6");
|
freightBipYsMx.setJT04_code("01020202");
|
freight.setFreeChId(freightBipYsMx);
|
|
bipYsItems.add(freight);
|
}
|
}else{
|
if (railwayEntrust.getTrainType().equals(2) && isNd.equals(1)){
|
//运费
|
if (railwayEntrust.getFreight() != null && railwayEntrust.getFreight() != 0) {
|
BIPYsItem freight = new BIPYsItem();
|
freight.setExpenseItemCode("12005002007002");//经济事项
|
freight.setTaxRate(0.0);
|
freight.setOriTaxExcludedAmount(new BigDecimal(railwayEntrust.getFreight()).setScale(2,BigDecimal.ROUND_HALF_UP));//原币无税金额
|
freight.setOriTaxIncludedAmount(new BigDecimal(railwayEntrust.getFreight()).setScale(2,BigDecimal.ROUND_HALF_UP));//原币含税金额
|
freight.setOriTaxAmount(BigDecimal.valueOf(NumUtils.subtractDouble(railwayEntrust.getFreight(),railwayEntrust.getFreight(),2)));//税额
|
freight.setCustomerCode(customerCode);//客户编码
|
freight.setLocalTaxExcludedAmount(new BigDecimal(railwayEntrust.getFreight()).setScale(2,BigDecimal.ROUND_HALF_UP));//本币无税金额
|
freight.setLocalTaxIncludedAmount(new BigDecimal(railwayEntrust.getFreight()).setScale(2,BigDecimal.ROUND_HALF_UP));//本币含税金额
|
freight.setOriTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getFreight(), railwayEntrust.getTonnage().doubleValue(),2));//无税单价
|
freight.setOriTaxIncludedPrice(NumUtils.divideDouble(railwayEntrust.getFreight(), railwayEntrust.getTonnage().doubleValue(),2));//含税单价
|
freight.setLocalTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getFreight(), railwayEntrust.getTonnage().doubleValue(),2));//本币无税单价
|
freight.setLocalTaxIncludedPrice(NumUtils.divideDouble(railwayEntrust.getFreight(), railwayEntrust.getTonnage().doubleValue(),2));//本币含税单价
|
// freight.setExpenseItemCode("1007");
|
//运费表体
|
BIPYsMx freightBipYsMx = new BIPYsMx();
|
if (id2!=null){
|
if (id2.equals("126") || id2.equals("1045116") || id2.equals("104810210")){
|
freightBipYsMx.setJT06_code("08008");//款项明细
|
} else if (id2.equals("10439")) {
|
freightBipYsMx.setJT06_code("01001001");//款项明细
|
}
|
}
|
|
freightBipYsMx.setGX08_code(fromStation);//核算单元档案
|
// freightBipYsMx.setJT12_code("X0330101");//产品大类
|
// freightBipYsMx.setJT25_code("03");//其他业务明细
|
freightBipYsMx.setYSYF14_code("6");
|
freightBipYsMx.setJT04_code(jyType);
|
freight.setFreeChId(freightBipYsMx);
|
|
bipYsItems.add(freight);
|
}
|
if (railwayEntrust.getCustomerId()!=null && (railwayEntrust.getCustomerId().equals(618) || railwayEntrust.getCustomerId().equals(608) || railwayEntrust.getCustomerId().equals(1367))){
|
// bipYsItems.add(this.getYfTsBt(railwayEntrust,id1,isNd,jyType));
|
}else{
|
//取送车费
|
if (railwayEntrust.getCarFee() != null && railwayEntrust.getCarFee() != 0) {
|
BIPYsItem carFee = new BIPYsItem();
|
carFee.setTaxRate(NumUtils.multiplyDouble(railwayEntrust.getTaxRate(),100d,2));
|
carFee.setOriTaxExcludedAmount(new BigDecimal(railwayEntrust.getCarFee2()).setScale(2,BigDecimal.ROUND_HALF_UP));//原币无税金额
|
carFee.setOriTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getCarFee()).setScale(2,BigDecimal.ROUND_HALF_UP));//原币含税金额
|
carFee.setOriTaxAmount(BigDecimal.valueOf(NumUtils.subtractDouble(railwayEntrust.getCarFee(),railwayEntrust.getCarFee2(),2)));//税额
|
carFee.setCustomerCode(id1);//客户编码
|
carFee.setLocalTaxExcludedAmount(new BigDecimal(railwayEntrust.getCarFee2()).setScale(2,BigDecimal.ROUND_HALF_UP));//本币无税金额
|
carFee.setLocalTaxIncludedAmount(new BigDecimal(railwayEntrust.getCarFee()).setScale(2,BigDecimal.ROUND_HALF_UP));//本币含税金额
|
carFee.setOriTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCarFee2(), railwayEntrust.getCarNum().doubleValue(),2));//无税单价
|
carFee.setOriTaxIncludedPrice(NumUtils.divideDouble(railwayEntrust.getCarFee(), railwayEntrust.getCarNum().doubleValue(),2));//含税单价
|
carFee.setLocalTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCarFee2(), railwayEntrust.getCarNum().doubleValue(),2));//本币无税单价
|
carFee.setLocalTaxIncludedPrice(NumUtils.divideDouble(railwayEntrust.getCarFee(), railwayEntrust.getCarNum().doubleValue(),2));//本币含税单价
|
carFee.setExpenseItemCode("10006016");
|
|
//取送车费表体
|
BIPYsMx carFeeBipYsMx = new BIPYsMx();
|
carFeeBipYsMx.setJT32_code("010404");//作业要素
|
carFeeBipYsMx.setJT06_code("01001001");//款项明细
|
carFeeBipYsMx.setGX08_code(accountUnitNumber);//核算单元档案
|
// carFeeBipYsMx.setJT12_code("X0330104");//产品大类
|
carFeeBipYsMx.setYSYF14_code("6");
|
// carFeeBipYsMx.setJT25_code("12A");//其他业务明细
|
carFeeBipYsMx.setJT04_code(jyType);//交易类型(二级集团间)
|
carFee.setFreeChId(carFeeBipYsMx);
|
bipYsItems.add(carFee);
|
}
|
}
|
|
}else if(railwayEntrust.getTrainType().equals(2) && isNd.equals(3)){
|
//取送车费
|
if (railwayEntrust.getCarFee2()!=null && railwayEntrust.getCarFee2() != 0) {
|
BIPYsItem carFee = new BIPYsItem();
|
carFee.setExpenseItemCode("10006016");//经济事项
|
carFee.setTaxRate(NumUtils.multiplyDouble(railwayEntrust.getTaxRate(),100d,2));
|
Double money = NumUtils.addDouble(railwayEntrust.getCarFee2(),railwayEntrust.getCarFeeTax(),2);
|
Double noTaxMoney = railwayEntrust.getCarFee2();
|
Double taxMoney = railwayEntrust.getCarFeeTax();
|
|
|
carFee.setOriTaxExcludedAmount(new BigDecimal(noTaxMoney).setScale(2,BigDecimal.ROUND_HALF_UP));//原币无税金额
|
carFee.setOriTaxIncludedAmount(BigDecimal.valueOf(money).setScale(2,BigDecimal.ROUND_HALF_UP));//原币含税金额
|
carFee.setOriTaxAmount(BigDecimal.valueOf(taxMoney));//税额
|
carFee.setCustomerCode(customerCode);//客户编码
|
carFee.setLocalTaxExcludedAmount(new BigDecimal(noTaxMoney).setScale(2,BigDecimal.ROUND_HALF_UP));//本币无税金额
|
carFee.setLocalTaxIncludedAmount(new BigDecimal(money).setScale(2,BigDecimal.ROUND_HALF_UP));//本币含税金额
|
carFee.setOriTaxExcludedPrice(NumUtils.divideDouble(noTaxMoney, railwayEntrust.getCarNum().doubleValue(),8));//无税单价
|
carFee.setOriTaxIncludedPrice(NumUtils.divideDouble(money, railwayEntrust.getCarNum().doubleValue(),8));//含税单价
|
carFee.setLocalTaxExcludedPrice(NumUtils.divideDouble(noTaxMoney, railwayEntrust.getCarNum().doubleValue(),8));//本币无税单价
|
carFee.setLocalTaxIncludedPrice(NumUtils.divideDouble(money, railwayEntrust.getCarNum().doubleValue(),2));//本币含税单价
|
// if (focus) {
|
// List<BIPPayPlan> bipPayPlans = this.getBipPayPlan(railwayEntrust,carFee.getOriTaxIncludedAmount().doubleValue());
|
// bipYsItem.setGrandsonItem(bipPayPlans);
|
// }
|
//取送车费表体
|
BIPYsMx carFeeBipYsMx = new BIPYsMx();
|
carFeeBipYsMx.setGX08_code(accountUnitNumber);//核算单元档案
|
carFeeBipYsMx.setJT32_code("010404");//作业要素
|
carFeeBipYsMx.setJT06_code("01001001");//款项明细
|
// carFeeBipYsMx.setJT25_code("12A");
|
carFeeBipYsMx.setYSYF14_code("2");
|
// carFeeBipYsMx.setJT12_code("X0330104");//产品大类
|
carFeeBipYsMx.setJT04_code(jyType);
|
carFee.setFreeChId(carFeeBipYsMx);
|
bipYsItems.add(carFee);
|
}
|
}
|
}*/
|
/*if (railwayEntrust.getInvoiceResultId() == null && !CompUtils.isKp(accountLedger.getId()) && !accountLedger.getId().equals(165)) {
|
throw new RuntimeException("结算单未开票");
|
}*/
|
InvoiceResult invoiceResult = fpInvoiceResultService.getById(railwayEntrust.getBlueInvoiceResultId());
|
if (invoiceResult != null) {
|
bipYsMx.setYSYF33(invoiceResult.getInvoiceNo());
|
bipYsItem.setInvoiceNo(invoiceResult.getInvoiceNo());
|
}
|
bipBody.setBodyItem(bipYsItems);
|
bipBody.setFreeChId(mx);
|
String result = bipHttpUtil.post(BipApiEnum.应付发票保存接口, new JSONObject().set("data", bipBody));
|
BipResVo resVo = JSONUtil.toBean(result, BipResVo.class);
|
//放到单据记录表
|
BipInvoice bipInvoice = new BipInvoice();
|
bipInvoice.setDay(DateUtil.date());
|
bipInvoice.setInvoice(JSONUtil.toJsonStr(bipBody));
|
bipInvoice.setBipCompNumber(id2);
|
bipInvoice.setType(0);
|
bipInvoice.setInvoiceType(1);
|
bipInvoice.setContractNum(contractNum);
|
bipInvoice.setRailwayEntrustId(railwayEntrust.getId());
|
//bipInvoice.setAllId(allId);
|
bipInvoice.setCompId(railwayEntrust.getCompId());
|
/*bipInvoice.setMoney(railwayEntrust.getAllPrice());
|
bipInvoice.setTonnage(railwayEntrust.getTonnage());
|
bipInvoice.setPrice(railwayEntrust.getPrice());
|
bipInvoice.setResStatus(resVo.getCode());
|
bipInvoice.setDirection(1);
|
bipInvoice.setTrainType(railwayEntrust.getTrainType());*/
|
BipResVo bipResVo = new BipResVo<>();
|
bipResVo.setCode(resVo.getCode());
|
BIPBody resBipBody = JSONUtil.toBean(resVo.getData() == null ? new Object().toString() : resVo.getData().toString(), BIPBody.class);
|
if (resVo.getCode().equals("200") || (StrUtil.isNotEmpty(resVo.getMessage()) && resVo.getMessage().contains("活动[财务审核]上找不到用户")) || StrUtil.isNotEmpty(resBipBody.getCode())) {
|
bipInvoice.setResInvoice(resVo.getData().toString());
|
|
bipInvoice.setBipNumber(resBipBody.getId());
|
bipInvoice.setCode(resBipBody.getCode());
|
|
bipInvoice.setResInvoice(resVo.getData().toString());
|
bipInvoice.setBipNumber(resBipBody.getId());
|
// bipInvoice.setCode("200");
|
bipInvoiceService.save(bipInvoice);
|
bipResVo.setCode("200");
|
bipResVo.setMessage(resVo.getMessage());
|
|
} else {
|
if (resVo.getData() != null && StrUtil.isNotEmpty(resVo.getData().toString())) {
|
bipInvoice.setBipNumber(resBipBody.getId());
|
bipInvoice.setCode(resBipBody.getCode());
|
}
|
bipInvoice.setMessage(resVo.getMessage());
|
bipResVo.setMessage(resVo.getMessage());
|
bipInvoiceService.save(bipInvoice);
|
}
|
if (resVo.getData() != null && StrUtil.isNotEmpty(resVo.getData().toString())) {
|
if (resBipBody.getId() != null) {
|
/*try {
|
if (railwayEntrust.getTrainType().equals(1)) {
|
if (order != null && order.getCompId() != null && order.getCompId().equals(227) && order.getFiledId() != null && order.getFiledId().equals(48)) {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(8, allId));
|
} else {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(0, allId));
|
}
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(3, railwayEntrust.getId(), railwayEntrust.getQualityName(), railwayEntrust.getUserCompId()));
|
} else if (railwayEntrust.getTrainType().equals(2)) {
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(1, allId));
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(4, railwayEntrust.getId(), railwayEntrust.getQualityName(), railwayEntrust.getUserCompId()));
|
}
|
if (StrUtil.isNotEmpty(fileUrl)) {
|
for (String s : fileUrl.split(",")) {
|
fileUploadService.uploadUrlToBip(railwayEntrust.getId(), resBipBody.getId(), s);
|
}
|
}
|
//发票
|
railwayEntrust.setBipStatus("200");
|
fpInvoiceResultService.update(new UpdateWrapper<InvoiceResult>().lambda()
|
.eq(InvoiceResult::getEntrustCode, railwayEntrust.getEntrustCode())
|
.set(InvoiceResult::getPushBipyf, null));
|
fpInvoiceResultService.pushBlue(railwayEntrust, 1);
|
fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(2, allId));
|
} catch (Exception e) {
|
railwayEntrust.setBipFileStatus(-1);
|
log.error("结算单推送附件错误---", e);
|
e.printStackTrace();
|
}*/
|
}
|
}
|
return bipResVo;
|
|
}
|
|
|
|
private String getCompName(String sellCode){
|
switch (sellCode){
|
case "104810210":
|
return "邯峰运销";
|
case "126":
|
return "冀中运销";
|
case "1045116":
|
return "峰峰分";
|
case "11035":
|
return " 峰峰集团(本部运销)";
|
}
|
return "";
|
}
|
|
@Override
|
public BipResVo saveRedFlushInvoice(BipInvoice oldBipInvoice,BIPBody bipBody) {
|
String result = "";
|
if (oldBipInvoice.getInvoiceType().equals(0)){
|
result = bipHttpUtil.post(BipApiEnum.应收发票保存接口,new JSONObject().set("data",bipBody));
|
}else {
|
result = bipHttpUtil.post(BipApiEnum.应付发票保存接口,new JSONObject().set("data",bipBody));
|
}
|
Long id = oldBipInvoice.getId();
|
BipResVo resVo = JSONUtil.toBean(result,BipResVo.class);
|
//放到单据记录表
|
BipInvoice bipInvoice = new BipInvoice();
|
bipInvoice.setDay(DateUtil.date());
|
bipInvoice.setInvoice(JSONUtil.toJsonStr(bipBody));
|
bipInvoice.setType(oldBipInvoice.getType());
|
bipInvoice.setInvoiceType(oldBipInvoice.getInvoiceType());
|
bipInvoice.setRedInvoiceId(oldBipInvoice.getId());
|
bipInvoice.setDirection(-1);
|
bipInvoice.setResStatus(resVo.getCode());
|
if (resVo.getCode().equals("200")){
|
bipInvoice.setResInvoice(resVo.getData().toString());
|
BIPBody resBipBody = JSONUtil.toBean(resVo.getData() == null ? new Object().toString() : resVo.getData().toString(), BIPBody.class);
|
bipInvoice.setBipNumber(resBipBody.getId());
|
bipInvoice.setCode(resBipBody.getCode());
|
}else {
|
bipInvoice.setMessage(resVo.getMessage());
|
}
|
bipInvoiceService.save(bipInvoice);
|
bipInvoiceService.update(new UpdateWrapper<BipInvoice>().lambda().eq(BipInvoice::getId,id)
|
.set(BipInvoice::getRedInvoiceStatus,resVo.getCode()).set(BipInvoice::getRedInvoiceMessage,resVo.getMessage())
|
.set(BipInvoice::getRedInvoiceId,bipInvoice.getId()));
|
return resVo;
|
}
|
|
@Override
|
public BipResVo removeBipInvoice(String number,String code,Integer type) {
|
JSONObject jsonObject = new JSONObject();
|
JSONArray jsonArray = new JSONArray();
|
jsonArray.add(new JSONObject().set("id",number).set("code",code));
|
jsonObject.set("data",jsonArray);
|
if (type.equals(0)) {
|
String result = bipHttpUtil.post(BipApiEnum.应收发票删除接口, jsonObject);
|
BipResVo resVo = JSONUtil.toBean(result, BipResVo.class);
|
return resVo;
|
} else {
|
String result = bipHttpUtil.post(BipApiEnum.应付发票删除接口, jsonObject);
|
BipResVo resVo = JSONUtil.toBean(result, BipResVo.class);
|
return resVo;
|
}
|
}
|
|
@Override
|
public BipResVo removeBipInvoice(String number, String code, Integer type, String msg) {
|
JSONObject jsonObject = new JSONObject();
|
JSONArray jsonArray = new JSONArray();
|
jsonArray.add(new JSONObject().set("id", number).set("code", code));
|
jsonObject.set("data", jsonArray);
|
if (type.equals(0)) {
|
String result = bipHttpUtil.post(BipApiEnum.应收发票删除接口, jsonObject);
|
BipResVo resVo = JSONUtil.toBean(result, BipResVo.class);
|
if (StrUtil.isNotEmpty(msg))
|
msg += ";";
|
if (!resVo.getCode().equals("200")) {
|
resVo.setMessage(msg += "节点应收发票删除成功");
|
} else {
|
resVo.setMessage(msg += "节点应收发票删除失败");
|
}
|
return resVo;
|
} else {
|
String result = bipHttpUtil.post(BipApiEnum.应付发票删除接口, jsonObject);
|
BipResVo resVo = JSONUtil.toBean(result, BipResVo.class);
|
if (StrUtil.isNotEmpty(msg))
|
msg += ";";
|
if (!resVo.getCode().equals("200")) {
|
resVo.setMessage(msg += "节点应付发票删除成功");
|
} else {
|
resVo.setMessage(msg += "节点应收发票删除失败");
|
}
|
return resVo;
|
}
|
}
|
|
@Override
|
public BipResVo removeBipInvoices(List<BipInvoice> bipInvoiceList) {
|
JSONObject jsonObjectYs = new JSONObject();
|
JSONObject jsonObjectYf = new JSONObject();
|
JSONArray jsonArrayYs = new JSONArray();
|
JSONArray jsonArrayYf = new JSONArray();
|
if (bipInvoiceList != null && bipInvoiceList.size() > 0) {
|
bipInvoiceList.forEach(e -> {
|
if (e.getInvoiceType().equals(0)) {
|
jsonArrayYs.add(new JSONObject().set("id",e.getBipNumber()).set("code",e.getCode()));
|
}else{
|
jsonArrayYf.add(new JSONObject().set("id",e.getBipNumber()).set("code",e.getCode()));
|
}
|
});
|
}
|
if (jsonArrayYs.size()>0){
|
jsonObjectYs.set("data",jsonArrayYs);
|
String result = bipHttpUtil.post(BipApiEnum.应收发票删除接口,jsonObjectYs);
|
BipResVo resVo = JSONUtil.toBean(result, BipResVo.class);
|
return resVo;
|
}
|
if (jsonArrayYf.size()>0){
|
jsonObjectYf.set("data",jsonArrayYf);
|
String result = bipHttpUtil.post(BipApiEnum.应付发票删除接口,jsonObjectYf);
|
BipResVo resVo = JSONUtil.toBean(result, BipResVo.class);
|
return resVo;
|
}
|
return null;
|
}
|
|
@Override
|
public BIPBody getBipInvoices(String code,Integer type) {
|
JSONObject jsonObject = new JSONObject();
|
jsonObject.set("pageIndex",1);
|
jsonObject.set("pageSize",999);
|
jsonObject.set("code",code);
|
StringBuffer message = new StringBuffer();
|
String result = "";
|
if (type.equals(0)){
|
result = bipHttpUtil.post(BipApiEnum.应收发票查询接口,jsonObject);
|
}else {
|
result = bipHttpUtil.post(BipApiEnum.应付发票查询接口,jsonObject);
|
}
|
|
BipResVo resVo = JSONUtil.toBean(result,BipResVo.class);
|
if (resVo.getCode().equals("200")){
|
JSONObject object = JSONUtil.parseObj(resVo.getData());
|
if (object==null && object.get("recordList")==null)
|
return null;
|
JSONArray jsonArray = JSONUtil.parseArray(object.get("recordList"));
|
if (jsonArray==null)
|
return null;
|
List<BIPBody> resBipBody = JSONUtil.toList(jsonArray.toString(), BIPBody.class);
|
if (resBipBody==null || resBipBody.size()==0)
|
return null;
|
return resBipBody.get(0);
|
}else {
|
message.append(resVo.getMessage());
|
}
|
return null;
|
}
|
|
@Override
|
public BipResVo updBipInvoices(BipInvoice bipInvoice,String number) {
|
BIPBody bipBody = JSONUtil.toBean(bipInvoice.getResInvoice(), BIPBody.class);
|
// BIPBody selectBipBody = this.getBipInvoices(bipInvoice.getCode(),bipInvoice.getInvoiceType());
|
// bipBody.setId(selectBipBody.getId());
|
// bipBody.setCode(selectBipBody.getCode());
|
// bipBody.setBodyItem(null);
|
// bipBody.setFreeChId(null);
|
// if (bipBody!=null){
|
// bipBody.getBodyItem().forEach(e -> {
|
//
|
// });
|
// }
|
|
if (bipBody!= null){
|
List<BIPYsItem> items = bipBody.getBodyItem();
|
bipBody.set_status("Update");
|
bipBody.setOrgCurrencyCode("CNY");
|
if (items!=null){
|
Double localTaxIncludedAmount = 0d;
|
Double localTaxExcludedAmount =0d;
|
for (BIPYsItem e:items){
|
e.set_status("Update");
|
e.setOrgCurrency("1514492081064640537");
|
e.setExchangeRateTypeCode("01");
|
e.setExchangeRate(1.0);
|
e.setExchangeRateDate(bipBody.getExchangeRateDate());
|
e.setLocalTaxAmount(e.getOriTaxAmount());
|
localTaxExcludedAmount = NumUtils.addDouble(localTaxExcludedAmount,e.getLocalTaxExcludedAmount().doubleValue());
|
localTaxIncludedAmount = NumUtils.addDouble(localTaxIncludedAmount,e.getLocalTaxIncludedAmount().doubleValue());
|
if (e.getGrandsonItem()!=null){
|
e.getGrandsonItem().forEach(i -> {
|
i.set_status("Update");
|
});
|
}
|
}
|
bipBody.setLocalTaxExcludedAmount(BigDecimal.valueOf(NumUtils.accurateDouble(localTaxExcludedAmount,2)).toPlainString());
|
bipBody.setLocalTaxIncludedAmount(BigDecimal.valueOf(NumUtils.accurateDouble(localTaxIncludedAmount,2)).toPlainString());
|
bipBody.setOriTaxExcludedAmount(BigDecimal.valueOf(NumUtils.accurateDouble(localTaxExcludedAmount,2)).toPlainString());
|
bipBody.setOriTaxIncludedAmount(BigDecimal.valueOf(NumUtils.accurateDouble(localTaxIncludedAmount,2)).toPlainString());
|
}
|
|
String result = null;
|
if (bipInvoice.getInvoiceType().equals(0)){
|
result = bipHttpUtil.post(BipApiEnum.应收发票修改接口, new JSONObject().set("data", bipBody));
|
|
// result = bipHttpUtil.post(BipApiEnum.应收发票查询接口,jsonObject);
|
}else {
|
result = bipHttpUtil.post(BipApiEnum.应付发票修改接口, new JSONObject().set("data", bipBody));
|
}
|
BipResVo resVo = JSONUtil.toBean(result,BipResVo.class);
|
if (resVo.getCode().equals("200")){
|
bipInvoiceService.update(new UpdateWrapper<BipInvoice>().lambda()
|
.set(BipInvoice::getUpdInvoice,bipBody).eq(BipInvoice::getId,bipInvoice.getId()));
|
}else {
|
bipInvoiceService.update(new UpdateWrapper<BipInvoice>().lambda()
|
.set(BipInvoice::getUpdMessage,resVo.getMessage()).eq(BipInvoice::getId,bipInvoice.getId()));
|
}
|
return resVo;
|
}
|
return null;
|
}
|
|
/**
|
* 特殊户表体
|
* @param railwayEntrust
|
* @return
|
*/
|
// private List<BIPYsItem> getTsBipYsItems(RailwayEntrust railwayEntrust,String id1,String jyType){
|
// List<BIPYsItem> bipYsItems = new ArrayList<>();
|
// BIPYsItem carFee = new BIPYsItem();
|
// carFee.setTaxRate(NumUtils.multiplyDouble(railwayEntrust.getTaxRate(),100d,2));
|
// carFee.setOriTaxExcludedAmount(new BigDecimal(railwayEntrust.getCarFee2()).setScale(2,BigDecimal.ROUND_HALF_UP));//原币无税金额
|
// carFee.setOriTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getCarFee()).setScale(2,BigDecimal.ROUND_HALF_UP));//原币含税金额
|
// carFee.setOriTaxAmount(BigDecimal.valueOf(NumUtils.subtractDouble(railwayEntrust.getCarFee(),railwayEntrust.getCarFee2(),2)));//税额
|
// carFee.setCustomerCode(id1);//客户编码
|
// carFee.setLocalTaxExcludedAmount(new BigDecimal(railwayEntrust.getCarFee2()).setScale(2,BigDecimal.ROUND_HALF_UP));//本币无税金额
|
// carFee.setLocalTaxIncludedAmount(new BigDecimal(railwayEntrust.getCarFee()).setScale(2,BigDecimal.ROUND_HALF_UP));//本币含税金额
|
// carFee.setOriTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCarFee2(), railwayEntrust.getCarNum().doubleValue(),2));//无税单价
|
// carFee.setOriTaxIncludedPrice(NumUtils.divideDouble(railwayEntrust.getCarFee(), railwayEntrust.getCarNum().doubleValue(),2));//含税单价
|
// carFee.setLocalTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCarFee2(), railwayEntrust.getCarNum().doubleValue(),2));//本币无税单价
|
// carFee.setLocalTaxIncludedPrice(NumUtils.divideDouble(railwayEntrust.getCarFee(), railwayEntrust.getCarNum().doubleValue(),2));//本币含税单价
|
// carFee.setExpenseItemCode("09001001");
|
//
|
// //取送车费表体
|
// BIPYsMx carFeeBipYsMx = new BIPYsMx();
|
// carFeeBipYsMx.setJT06_code("0809");//款项明细
|
// carFeeBipYsMx.setJT12_code("X0330104");//产品大类
|
// carFeeBipYsMx.setYSYF14_code("6");
|
// carFeeBipYsMx.setJT25_code("12");//其他业务明细
|
// carFeeBipYsMx.setJT04_code(jyType);//交易类型(二级集团间)
|
// carFee.setFreeChId(carFeeBipYsMx);
|
// bipYsItems.add(carFee);
|
// }
|
/*private RailwayEntrust getDivEntrust(RailwayEntrust railwayEntrust) {
|
// railwayEntrust.setDust(railwayEntrust);
|
Double dustPrice = NumUtils.divideDouble(railwayEntrust.getDust(), 1.06d, 8);
|
|
railwayEntrust.setDustFee(NumUtils.multiplyDouble(dustPrice, railwayEntrust.getRealTonnage(), 2));//不含税金额
|
Double dustTax = NumUtils.multiplyDouble(railwayEntrust.getDustFee(), railwayEntrust.getTaxRate(), 2);//税额
|
railwayEntrust.setDustPrice(NumUtils.addDouble(railwayEntrust.getDustFee(), dustTax, 2));//合计金额
|
if (railwayEntrust.getCustomerId().equals(618) || railwayEntrust.getCustomerId().equals(1002134)) {
|
Date date = railwayEntrust.getBalanceDate();
|
// Date date1 = DateUtil.parse("2024-08-01","yyyy-MM-dd");
|
Double b = 14.8934;
|
// if (date.before(date1)){
|
// b = 13.18;
|
// }
|
railwayEntrust.setSpecialLineFee(NumUtils.multiplyDouble(railwayEntrust.getRealTonnage(), b, 4));
|
//专线费
|
railwayEntrust.setCarFee(NumUtils.addDouble(railwayEntrust.getCarFee2(), railwayEntrust.getCarFeeTax()));
|
}
|
Double taxRate = railwayEntrust.getTaxRate();
|
Double rate = NumUtils.addDouble(1d, railwayEntrust.getTaxRate());
|
railwayEntrust.setTaxFeeCount(NumUtils.subtractDouble(railwayEntrust.getAllPrice(), railwayEntrust.getFreight(), 2));
|
|
railwayEntrust.setCoalMoney(NumUtils.accurateFloat(railwayEntrust.getTaxFeeCount() - (railwayEntrust.getCarFee() == null ? 0 : railwayEntrust.getCarFee()) - (railwayEntrust.getSpecialLineFee() == null ? 0 : railwayEntrust.getSpecialLineFee()) - (railwayEntrust.getDustPrice() == null ? 0 : railwayEntrust.getDustPrice()), 2));
|
railwayEntrust.setCoalTaxMoney(NumUtils.accurateFloat(railwayEntrust.getCoalMoney() * taxRate, 2));
|
railwayEntrust.setOutNoTaxMoney(NumUtils.divideDouble(railwayEntrust.getTaxFeeCount(), rate, 2));
|
railwayEntrust.setCoalMoney(NumUtils.accurateDouble(NumUtils.accurateDouble(railwayEntrust.getOutNoTaxMoney(), 2) - NumUtils.accurateDouble((railwayEntrust.getDustFee()), 2) - railwayEntrust.getCarFee2() - NumUtils.divideDouble(railwayEntrust.getSpecialLineFee(), 1.13, 2), 2));
|
railwayEntrust.setPrice(NumUtils.divideDouble(railwayEntrust.getCoalMoney(), railwayEntrust.getTonnage(), 8));
|
if (railwayEntrust.getTrainType().equals(2)) {
|
railwayEntrust.setPrice(NumUtils.accurateDouble(railwayEntrust.getPrice(), 8));
|
}
|
railwayEntrust.setOriginalPrice(NumUtils.divideDouble(railwayEntrust.getPrice(), 1.13, 6));
|
railwayEntrust.setTaxFee(NumUtils.multiplyDouble(railwayEntrust.getCoalMoney(), railwayEntrust.getTaxRate(), 2));
|
return railwayEntrust;
|
}*/
|
|
}
|