2021-01-12 16:18:49 +08:00

858 lines
35 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.tenwa.apzl.invoicemanager.rentplaninvoice;
import java.io.File;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import org.beetl.ext.fn.ParseDouble;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import jbo.app.tenwa.calc.LC_RENT_PLAN;
import jbo.app.tenwa.calc.LI_INVOICE_CONFIRM;
import jbo.app.tenwa.calc.LI_INVOICE_CONFIRM_DETAIL;
import jbo.app.tenwa.calc.LI_INVOICE_RESULT;
import jbo.app.tenwa.calc.VI_INVOICE_RENT_PLAN_CONFIRM;
import jbo.app.tenwa.calc.VI_LI_INVOICE_OTHERS;
import jbo.app.tenwa.calc.VI_LI_INVOICE_RENT;
import jbo.app.tenwa.customer.CUSTOMER_COMPANY;
import jbo.app.tenwa.customer.CUSTOMER_FAMILY;
import jbo.app.tenwa.customer.CUSTOMER_PERSON;
import jbo.awe.USER_INFO;
import jbo.com.tenwa.entity.comm.invoice.LI_RENT_INVOICE_INFO;
import jbo.com.tenwa.entity.comm.own.OWN_ACCOUNT;
import jbo.com.tenwa.entity.comm.own.OWN_INFO;
import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.BizObjectQuery;
import com.amarsoft.are.jbo.JBOException;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.awe.Configure;
import com.amarsoft.awe.util.ASResultSet;
import com.amarsoft.awe.util.SqlObject;
import com.amarsoft.awe.util.Transaction;
import com.tenwa.app.invoice.action.InvoiceRequest;
import com.tenwa.app.invoice.data.ResponseEnum;
import com.tenwa.app.invoice.pojo.ResultPojo;
import com.tenwa.app.invoice.request.InvoiceRequestBase;
import com.tenwa.app.invoice.request.InvoiceRequestBody;
import com.tenwa.app.invoice.request.InvoiceRequestHead;
import com.tenwa.app.invoice.request.InvoiceRequestInput;
import com.tenwa.app.invoice.utils.DownloadPdfUtil;
import com.tenwa.app.invoice.utils.JaxbUtil;
import com.tenwa.app.invoice.utils.MathUtil;
import com.tenwa.app.invoice.utils.Num2ChineseUtil;
import com.tenwa.app.invoice.utils.PasswordGenerateUtil;
import com.tenwa.app.invoice.utils.ResultUtil;
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
import com.tenwa.flow.action.comm.BaseTable;
import com.tenwa.util.SecurityUtil;
public class rentPlanInvoiceManager extends BaseTable {
private String planIds;
private String ids;
private String moneyTypes;
private String sid;
public String getPlanIds() {
return planIds;
}
public void setPlanIds(String planIds) {
this.planIds = planIds;
}
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
public String getMoneyTypes() {
return moneyTypes;
}
public void setMoneyTypes(String moneyTypes) {
this.moneyTypes = moneyTypes;
}
public String getSid() {
return sid;
}
public void setSid(String sid) {
this.sid = sid;
}
/**<2A><><EFBFBD><EFBFBD>1
*<2A><><EFBFBD><EFBFBD>--<2D><>Ϣ<EFBFBD><CFA2> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϣ<EFBFBD><CFA2>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>뿪Ʊ<EBBFAA><C6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><><EFBFBD>ӷ<EFBFBD>Ʊ
* @param tx
* @return
* @throws Exception
*/
public String selectApplyConfirm(JBOTransaction tx) throws Exception {
BizObjectManager lriiManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME);
BizObjectManager viInvoiceRentManager = JBOFactory.getBizObjectManager(VI_LI_INVOICE_RENT.CLASS_NAME);
tx.join(lriiManager);
tx.join(viInvoiceRentManager);
String[] planIds = this.getPlanIds().split("@");
String invoice_status = "1";
String bill_type = "electronic";
String invoice_money = "";
String tax_type = "";
String plan_id = "";
String PAYMENT_NUMBER = "";
String TAX_REG_CODE = "";
String TAX_BANK = "";
String TAX_ACC = "";
String contract_id = "";
String invoice_object= "back_rent";
for (int i = 0; i < planIds.length; i++) {
String planId = planIds[i];
// BizObject viInvoiceRent =
// viInvoiceRentManager.createQuery("plan_id=:plan_id").setParameter("plan_id",
// planId).getSingleResult(false);
@SuppressWarnings("unchecked")
List<BizObject> viInvoiceRent = JBOFactory.createBizObjectQuery("jbo.app.tenwa.calc.VI_LI_INVOICE_RENT","plan_id=:plan_id").setParameter("plan_id", planId).getResultList(false);
for (BizObject bizObject : viInvoiceRent) {
String id = UUID.randomUUID().toString().replaceAll("-", "");
invoice_money = bizObject.getAttribute("plan_money").toString();
plan_id = bizObject.getAttribute("plan_id").toString();
PAYMENT_NUMBER = bizObject.getAttribute("payment_number").toString();
TAX_REG_CODE = bizObject.getAttribute("cert_id").toString();
TAX_BANK = bizObject.getAttribute("bank_name").toString();
TAX_ACC = bizObject.getAttribute("acc_number").toString();
contract_id = bizObject.getAttribute("contract_id").toString();
tax_type = bizObject.getAttribute("tax_type").toString();
if ("<EFBFBD><EFBFBD>Ϣ".equals(tax_type)) {
tax_type = "interest";
} else if ("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ".equals(tax_type)) {
tax_type = "overinterest";
}
BizObject lriiObject = lriiManager.createQuery("plan_id=:plan_id and tax_type=:tax_type")
.setParameter("plan_id", planId).setParameter("tax_type", tax_type).getSingleResult(false);
if (lriiObject != null) {
lriiManager.createQuery("update o set invoice_status='1' where plan_id=:plan_id and tax_type=:tax_type").setParameter("plan_id", planId).setParameter("tax_type", tax_type).executeUpdate();
} else {
BizObject rentInvoiceInfo = lriiManager.newObject();
rentInvoiceInfo.setAttributeValue("id", id);
rentInvoiceInfo.setAttributeValue("invoice_status",invoice_status);
rentInvoiceInfo.setAttributeValue("bill_type", bill_type);
rentInvoiceInfo.setAttributeValue("invoice_money",invoice_money);
rentInvoiceInfo.setAttributeValue("invoice_object",invoice_object);
/*
* if("<22><>Ϣ".equals(tax_type)){
* rentInvoiceInfo.setAttributeValue("tax_type",
* "interest"); }else if("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ".equals(tax_type)){
* rentInvoiceInfo.setAttributeValue("tax_type",
* "overinterest");
*
* }else{ return "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>"; }
*/
if ("".equals(tax_type) || tax_type == null) {
return "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>";
} else {
rentInvoiceInfo.setAttributeValue("tax_type", tax_type);
}
rentInvoiceInfo.setAttributeValue("TEMPORARY_NOINVOICE","0.00");
rentInvoiceInfo.setAttributeValue("NOINVOICE", "0.00");
rentInvoiceInfo.setAttributeValue("plan_id", plan_id);
rentInvoiceInfo.setAttributeValue("PAYMENT_NUMBER",PAYMENT_NUMBER);
rentInvoiceInfo.setAttributeValue("TAX_REG_CODE",TAX_REG_CODE);// <20><>˰<EFBFBD><CBB0>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD>
rentInvoiceInfo.setAttributeValue("TAX_BANK", TAX_BANK);// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
rentInvoiceInfo.setAttributeValue("TAX_ACC", TAX_ACC);// <20><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
rentInvoiceInfo.setAttributeValue("contract_id",contract_id);
rentInvoiceInfo = this.initTabeUserInfo(rentInvoiceInfo);
lriiManager.saveObject(rentInvoiceInfo);
}
}
}
return "<EFBFBD><EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>";
}
/**<2A><><EFBFBD><EFBFBD>2
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/gps/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/ΥԼ<CEA5><D4BC> <20><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>--<2D><><EFBFBD>ӷ<EFBFBD>Ʊ
* @param tx
* @return
* @throws Exception
*/
public String selectApplyOtherConfirm(JBOTransaction tx) throws Exception {
BizObjectManager lriiManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME);
BizObjectManager viInvoiceOtherManager = JBOFactory.getBizObjectManager(VI_LI_INVOICE_OTHERS.CLASS_NAME);
tx.join(lriiManager);
tx.join(viInvoiceOtherManager);
String[] moneyTypes = this.getMoneyTypes().split("@");
String invoice_status = "1";
String bill_type = "electronic";
String invoice_money = "";
String plan_id = "";
String PAYMENT_NUMBER = "";
String TAX_REG_CODE = "";
String TAX_BANK = "";
String TAX_ACC = "";
String moneytype = "";
String contract_id = "";
String invoice_object= "back_rent";
for (int i = 0; i < moneyTypes.length; i++) {
String id = UUID.randomUUID().toString().replaceAll("-", "");
String[] str = moneyTypes[i].split("#");
contract_id = str[0];
moneytype = str[1];
// Map<String,String> map = new HashMap<String, String>();
// map.put("contract_id", contract_id);
// map.put("moneytype", moneytype);
// BizObject viInvoiceOther =
// DataOperatorUtil.getJBOBySQL("SELECT invoice_price,PAYMENT_NUMBER,cert_id,bank_name,acc_number from O",
// "jbo.app.tenwa.calc.VI_LI_INVOICE_OTHERS", map, tx);
// BizObject viInvoiceOther =
// viInvoiceOtherManager.createQuery("contract_id=:contract_id AND moneytype=:moneytype").setParameter("contract_id",
// contract_id).setParameter("moneytype",
// moneytype).getSingleResult(false);
BizObject viInvoiceOther = JBOFactory.createBizObjectQuery("jbo.app.tenwa.calc.VI_LI_INVOICE_OTHERS","SELECT invoice_price,PAYMENT_NUMBER,cert_id,bank_name,acc_number from O where contract_id=:contract_id AND moneytype=:moneytype")
.setParameter("contract_id", contract_id).setParameter("moneytype", moneytype).getSingleResult(false);
invoice_money = viInvoiceOther.getAttribute("invoice_price").toString();
PAYMENT_NUMBER = viInvoiceOther.getAttribute("PAYMENT_NUMBER").toString();
TAX_REG_CODE = viInvoiceOther.getAttribute("cert_id").toString();
TAX_BANK = viInvoiceOther.getAttribute("bank_name").toString();
TAX_ACC = viInvoiceOther.getAttribute("acc_number").toString();
BizObject lriiObject = lriiManager.createQuery("contract_id=:contract_id and tax_type=:moneytype")
.setParameter("contract_id", contract_id)
.setParameter("moneytype", moneytype).getSingleResult(false);
if (lriiObject != null) {
lriiManager.createQuery("update o set invoice_status='1' where contract_id=:contract_id and tax_type=:moneytype")
.setParameter("contract_id", contract_id)
.setParameter("moneytype", moneytype).executeUpdate();
} else {
BizObject rentInvoiceInfo = lriiManager.newObject();
rentInvoiceInfo.setAttributeValue("id", id);
rentInvoiceInfo.setAttributeValue("invoice_status",invoice_status);
rentInvoiceInfo.setAttributeValue("bill_type", bill_type);
rentInvoiceInfo.setAttributeValue("invoice_money",invoice_money);
rentInvoiceInfo.setAttributeValue("invoice_object",invoice_object);
if ("gps".equals(moneytype)) {
rentInvoiceInfo.setAttributeValue("tax_type", moneytype);
} else if ("sxf".equals(moneytype)) {
rentInvoiceInfo.setAttributeValue("tax_type", moneytype);
} else if ("myhj".equals(moneytype)) {
rentInvoiceInfo.setAttributeValue("tax_type", moneytype);
} else if ("wyj".equals(moneytype)) {
rentInvoiceInfo.setAttributeValue("tax_type", moneytype);
} else {
return "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>";
}
rentInvoiceInfo.setAttributeValue("TEMPORARY_NOINVOICE", "0.00");
rentInvoiceInfo.setAttributeValue("NOINVOICE", "0.00");
rentInvoiceInfo.setAttributeValue("plan_id", plan_id);
rentInvoiceInfo.setAttributeValue("PAYMENT_NUMBER",PAYMENT_NUMBER);
rentInvoiceInfo.setAttributeValue("TAX_REG_CODE", TAX_REG_CODE);// <20><>˰<EFBFBD><CBB0>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD>
rentInvoiceInfo.setAttributeValue("TAX_BANK", TAX_BANK);// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
rentInvoiceInfo.setAttributeValue("TAX_ACC", TAX_ACC);// <20><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
rentInvoiceInfo.setAttributeValue("contract_id", contract_id);
rentInvoiceInfo = this.initTabeUserInfo(rentInvoiceInfo);
lriiManager.saveObject(rentInvoiceInfo);
}
}
return "<EFBFBD><EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>";
}
/**<2A><><EFBFBD><EFBFBD>3
* <20><>Ʊȷ<C6B1><C8B7><EFBFBD>
*
* @param tx
* @return
* @throws Exception
*/
public String invoiceConfirmSubmit(JBOTransaction tx) throws Exception {
Transaction Sqlca = null;
/* BizObjectManager ownAccountManager = JBOFactory.getBizObjectManager(OWN_ACCOUNT.CLASS_NAME);
BizObject ownAccount = ownAccountManager
.createQuery("state_=:state and acc_type=:acc_type and money_type=:money_type and account_type=:account_type")
.setParameter("state", "0010").setParameter("acc_type", "0010")
.setParameter("money_type", "01")
.setParameter("account_type", "invoice").getSingleResult(false);
if (ownAccount == null || "".equals(ownAccount)) {
return "<22><><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>";
}*/
String[] rentInvoiceids = this.getIds().split("@");
List<String> rentPlanIdList = new ArrayList<String>();
for (int i = 0; i < rentInvoiceids.length; i++) {
rentPlanIdList.add("'" + rentInvoiceids[i] + "'");
}
String customerid = "";
String customerName = "";
String rentPlanstr = StringUtils.join(rentPlanIdList.toArray(), ",");
BizObjectManager invoiceManager = JBOFactory.getBizObjectManager(VI_INVOICE_RENT_PLAN_CONFIRM.CLASS_NAME);
@SuppressWarnings("unchecked")
List<BizObject> checkInvoiceList = (List<BizObject>) invoiceManager.createQuery("SELECT O.contract_id,O.customer_name,O.CUSTOMER_ID FROM O WHERE O.id IN (" + rentPlanstr + ") GROUP BY O.contract_id").getResultList(false);
String xhdwyhzh = "";
String xhdwdzdh = "";
for (BizObject bizObject : checkInvoiceList) {
//<2F><>ȡ<EFBFBD><C8A1>ͬid
String contract_id = bizObject.getAttribute("contract_id").toString();
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺ź͵<C5BA>ַ<EFBFBD>
BizObject rent = JBOFactory.createBizObjectQuery("jbo.app.tenwa.calc.LC_RENT_INCOME", "SELECT O.own_number,oi.lease_tel FROM O LEFT JOIN jbo.com.tenwa.entity.comm.own.OWN_INFO oi ON O.own_account=oi.own_name WHERE O.contract_id =:contract_id GROUP BY O.contract_id")
.setParameter("contract_id", contract_id).getSingleResult(false);
if(rent==null){
return "<EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>";
}else{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
xhdwyhzh = rent.getAttribute("own_number")==null? "" : rent.getAttribute("own_number").toString();
//<2F><>ַ<EFBFBD>
xhdwdzdh = rent.getAttribute("lease_tel")==null? "" : rent.getAttribute("lease_tel").toString();
}
customerid = bizObject.getAttribute("CUSTOMER_ID").toString();
customerName = bizObject.getAttribute("customer_name").toString();
List<BizObject> boList = invoiceManager.createQuery("contract_id=:contract_id and id IN ("+rentPlanstr+")")
.setParameter("contract_id", contract_id).getResultList(false);
List<String> list = new ArrayList<String>();
for (BizObject bizObject2 : boList) {
String id = bizObject2.getAttribute("id").toString();
list.add(id);
}
// String[] ids = (String[]) list.toArray();
String[] ids = new String[list.size()];
list.toArray(ids);
String confirmId = UUID.randomUUID().toString().replaceAll("-", "");
Double hjje = 0.00;
Double hjse = 0.00;
Double jshj = 0.00;
List<BizObject> confirmDetailList = new ArrayList<BizObject>();
DecimalFormat df2 = new DecimalFormat(".00");
DecimalFormat df6 = new DecimalFormat(".000000");
BizObjectManager invoiceRentManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME);
//˰<><CBB0>
Double sl = 0.00;
for (int i = 0; i < ids.length; i++) {
String invoiceId = ids[i];// li_rent_invoice_info<66><6F>id
BizObjectManager confirmDetailManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM_DETAIL.CLASS_NAME);
tx.join(confirmDetailManager);
BizObject confirmDetailBizObject = confirmDetailManager.newObject();
Double invoiceMoney = 0.00;
String planid = "";
String planList = "";
String TAX_TYPE = "";
String spbm = "";
String spmc = "";
String taxType = "";
BizObject invoiceRentBizObject = invoiceRentManager.createQuery("ID=:id ").setParameter("id", invoiceId).getSingleResult(false);
invoiceMoney = new BigDecimal(invoiceRentBizObject.getAttribute("INVOICE_MONEY").getString()).setScale(2,
BigDecimal.ROUND_HALF_UP).doubleValue();
TAX_TYPE = invoiceRentBizObject.getAttribute("TAX_TYPE").getString();
planid = invoiceRentBizObject.getAttribute("plan_id").toString();
if (planid != null && !"".equals(planid)) {
BizObjectManager rentPlanManager = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME);
BizObject rentPlan = rentPlanManager.createQuery("id=:plan_id").setParameter("plan_id", planid).getSingleResult(false);
planList = rentPlan.getAttribute("plan_list").toString();
planList = Num2ChineseUtil.format(planList);
if ("overinterest".equals(TAX_TYPE)) {
planList +="<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ";
taxType = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ";
}else{
taxType = "<EFBFBD><EFBFBD>Ϣ";
}
spmc = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ";
} else {
if ("myhj".equals(TAX_TYPE)) {
spmc = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
taxType = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
} else if ("sxf".equals(TAX_TYPE)) {
spmc = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
taxType = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
} else if ("gps".equals(TAX_TYPE)) {
spmc = "GPS<EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
taxType = "GPS";
} else if ("wyj".equals(TAX_TYPE)) {
spmc = "ΥԼ<EFBFBD><EFBFBD>";
taxType = "ΥԼ<EFBFBD><EFBFBD>";
} else {
return "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>";
}
}
String sql = "SELECT getTaxs('02','"+taxType+"',O.inputtime) AS tax FROM lb_contract_info O WHERE O.id=:contract_id";
Map conditon = new HashMap<String,String>();
conditon.put("contract_id", contract_id);
List<Map<String,String>> data = DataOperatorUtil.getDataBySql(tx, sql, conditon);
sl = Double.parseDouble(data.get(0).get("tax"));
conditon.clear();
Double se = Double.valueOf(df2.format(invoiceMoney * sl));
confirmDetailBizObject.setAttributeValue("dj", "");
confirmDetailBizObject.setAttributeValue("je", invoiceMoney);
hjje = MathUtil.add(hjje, invoiceMoney);
hjse = MathUtil.add(hjse, se);
confirmDetailBizObject.setAttributeValue("invoice_type",TAX_TYPE);
confirmDetailBizObject.setAttributeValue("invoice_id",invoiceId);
confirmDetailBizObject.setAttributeValue("spsl", "");
confirmDetailBizObject.setAttributeValue("dw", "");
confirmDetailBizObject.setAttributeValue("fphxz", "0");
confirmDetailBizObject.setAttributeValue("spmc", spmc);
confirmDetailBizObject.setAttributeValue("spsm", "");
confirmDetailBizObject.setAttributeValue("ggxh", planList);
confirmDetailBizObject.setAttributeValue("invoice_confirm_id",confirmId);
confirmDetailBizObject.setAttributeValue("sl", sl);
confirmDetailBizObject.setAttributeValue("se", se);
confirmDetailBizObject.setAttributeValue("hsbz", "0");
Configure config = Configure.getInstance();
try {
spbm = config.getConfigure("INVOICE_SPBM");
} catch (Exception e) {
e.printStackTrace();
return "<EFBFBD><EFBFBD>ȡa3web<EFBFBD>Ŀ<EFBFBD>Ʊ<EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD><EFBFBD>";
}
confirmDetailBizObject.setAttributeValue("spbm", spbm);
confirmDetailBizObject.setAttributeValue("zxbm", "");
confirmDetailBizObject.setAttributeValue("yhzcbs", "0");
confirmDetailBizObject.setAttributeValue("slbs", "");
confirmDetailBizObject.setAttributeValue("zzstsgl", "");
confirmDetailBizObject = this.initTabeUserInfo(confirmDetailBizObject);
confirmDetailManager.saveObject(confirmDetailBizObject);
confirmDetailList.add(confirmDetailBizObject);
}
if (confirmDetailList.size() > 0) {
BizObjectManager confirmManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM.CLASS_NAME);
tx.join(confirmManager);
BizObject confirmBizObject = confirmManager.newObject();
/*String ownId = ownAccount.getAttribute("own_id").toString();
BizObjectManager ownInfoManager = JBOFactory.getBizObjectManager(OWN_INFO.CLASS_NAME);
BizObject ownInfo = ownInfoManager.createQuery("OWN_NUMBER=:OWN_NUMBER").setParameter("OWN_NUMBER", ownId).getSingleResult(false);
String xhdwdzdh = ownInfo.getAttribute("LEASE_TEL").toString();// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ַ<EFBFBD>
*/
BizObjectManager customerPersonManager = JBOFactory.getBizObjectManager(CUSTOMER_PERSON.CLASS_NAME);
BizObjectManager customerFamilyManager = JBOFactory.getBizObjectManager(CUSTOMER_FAMILY.CLASS_NAME);
BizObject customerPerson = customerPersonManager.createQuery("SELECT o.certid,caa.fulladdress,o.mobile,ca.acc_number,ca.bank_name from o JOIN jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca ON ca.customerid=o.customerid JOIN jbo.app.tenwa.customer.CUSTOMER_ADDRESS caa ON caa.customerid=ca.customerid where o.customerid=:customerid")
.setParameter("customerid", customerid).getSingleResult(false);
BizObject customerFamily = customerFamilyManager.createQuery("customerid=:customerid").setParameter("customerid", customerid).getSingleResult(false);
String familyTel = "";
if (customerFamily != null) {
familyTel = customerFamily.getAttribute("tel").toString();
}
String certid = "";
String fulladdress = "";
String mobile = "";
String acc_number = "";
String bank_name = "";
String acc_bank = "";
String address_tel = "";
if (customerPerson != null) {
certid = customerPerson.getAttribute("certid").toString();
fulladdress = customerPerson.getAttribute("fulladdress").toString();
mobile = customerPerson.getAttribute("mobile").toString();
acc_number = customerPerson.getAttribute("acc_number").toString();
bank_name = customerPerson.getAttribute("bank_name").toString();
acc_bank = "[" + bank_name + "][" + acc_number + "]";
address_tel = "[" + mobile + "][" + fulladdress + "]";
}
BizObjectManager contractInfoManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME);
BizObject contractInfo = contractInfoManager.createQuery("SELECT o.leas_form,lul.customer_id,ci.customertype FROM o JOIN jbo.com.tenwa.lease.comm.LB_UNION_LESSEE lul ON o.id=lul.contract_id JOIN jbo.app.tenwa.customer.CUSTOMER_INFO ci ON ci.customerid=lul.customer_id WHERE O.businesstype='1' AND lul.customer_id=:customerid")
.setParameter("customerid", customerid).getSingleResult(false);
String customertype = contractInfo.getAttribute("customertype").toString();// <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD>Ȼ<EFBFBD>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>
BizObjectManager userInfoManager = JBOFactory.getBizObjectManager(USER_INFO.CLASS_NAME);
BizObject userInfo = userInfoManager.createQuery("userid=:userid").setParameter("userid", CurUserID).getSingleResult(false);
String username = userInfo.getAttribute("username").toString();// <20><>Ʊ<EFBFBD><C6B1>
//<2F><>list<73>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
confirmBizObject.setAttributeValue("id", confirmId);
confirmBizObject.setAttributeValue("sid",PasswordGenerateUtil.getRandom(64,PasswordGenerateUtil.TYPE.LETTER_CAPITAL));
confirmBizObject.setAttributeValue("yylxdm", "1");
confirmBizObject.setAttributeValue("fplxdm", "026");
confirmBizObject.setAttributeValue("kplx", "0");
confirmBizObject.setAttributeValue("tspz", "00");
confirmBizObject.setAttributeValue("xhdwdzdh", xhdwdzdh);
confirmBizObject.setAttributeValue("xhdwyhzh", xhdwyhzh);
confirmBizObject.setAttributeValue("ghdwsbh", certid);
confirmBizObject.setAttributeValue("ghdwmc", customerName);
confirmBizObject.setAttributeValue("ghdwdzdh", address_tel);
confirmBizObject.setAttributeValue("ghdwyhzh", acc_bank);
confirmBizObject.setAttributeValue("hsslbs", "0");
confirmBizObject.setAttributeValue("zhsl", "");
confirmBizObject.setAttributeValue("hjje", hjje);
confirmBizObject.setAttributeValue("hjse", hjse);
confirmBizObject.setAttributeValue("jshj",MathUtil.add(hjje, hjse));
confirmBizObject.setAttributeValue("fhr", "");
confirmBizObject.setAttributeValue("kpr", username);
confirmBizObject.setAttributeValue("zyspmc", "");
confirmBizObject.setAttributeValue("spsm", "");
confirmBizObject.setAttributeValue("ssyf", "");
confirmBizObject.setAttributeValue("tzdbh", "");
confirmBizObject.setAttributeValue("yfpdm", "");
confirmBizObject.setAttributeValue("yfphm", "");
confirmBizObject.setAttributeValue("GMF_DZYX", "");
confirmBizObject.setAttributeValue("FIELD3", "back_rent");//<2F><><EFBFBD><EFBFBD>
if ("01".equals(customertype)) {
confirmBizObject.setAttributeValue("GMF_SJHM", familyTel);
} else {
confirmBizObject.setAttributeValue("GMF_SJHM", mobile);
}
confirmBizObject.setAttributeValue("GMF_OPENID", "");
confirmBizObject = this.initTabeUserInfo(confirmBizObject);
confirmManager.saveObject(confirmBizObject);
InvoiceRequest invoiceRequest = new InvoiceRequest();
ResultPojo result = invoiceRequest.send(confirmBizObject,confirmDetailList);
if (result.getCode() == 0) {
InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData();
String returncode = responseBase.getBody().getReturncode();
String returnmsg = responseBase.getBody().getReturnmsg();
System.out.println("[OK][returncode]=>>>" + returncode);
System.out.println("[OK][returnmsg]=>>>" + returnmsg);
if ("0".equals(returncode)) {
System.out.println("[OK][SUCCESS]");
for (BizObject confirmDetailBizObject : confirmDetailList) {
String invoiceId = confirmDetailBizObject.getAttribute("invoice_id").toString();
invoiceRentManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId)
.setParameter("invoicestatus","3").executeUpdate();
}
} else {
return returnmsg;
}
} else {
System.out.println("[FAIL]=>>>" + result.getMsg());
return result.getMsg();
}
} else {
return "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>";
}
// ===================================================
}
return "<EFBFBD><EFBFBD>Ʊ<EFBFBD>ɹ<EFBFBD>";
}
/**<2A><><EFBFBD><EFBFBD>4
* <20>˻<EFBFBD><CBBB><EFBFBD><EFBFBD>뿪Ʊ
*
* @param tx
* @return
* @throws Exception
*/
public String backInvoice(JBOTransaction tx) throws Exception {
BizObjectManager lriiManager = JBOFactory
.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME);
tx.join(lriiManager);
String[] rentPlanids = this.getIds().split("@");
for (int i = 0; i < rentPlanids.length; i++) {
lriiManager.createQuery("update o set INVOICE_STATUS='2' where ID=:id ").setParameter("id", rentPlanids[i]).executeUpdate();
}
return "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>";
}
/**
* <20><><EFBFBD><EFBFBD>5
* <20><>Ʊ<EFBFBD><C6B1><EFBFBD>߲<EFBFBD>ѯ--<2D><><EFBFBD>ɿ<EFBFBD><C9BF><EFBFBD><EFBFBD>صĵ<D8B5><C4B5><EFBFBD>PDF
* @param tx
* @return
* @throws JBOException
*/
public String selectConfirm(JBOTransaction tx) throws JBOException {
Configure config = Configure.getInstance();
String INVOICE_LOCAL_PATH = "";
String appId = "";
try {
INVOICE_LOCAL_PATH = config.getConfigure("INVOICE_LOCAL_PATH");
appId = config.getConfigure("INVOICE_APPID");
} catch (Exception e) {
e.printStackTrace();
return "a3web->[INVOICE_LOCAL_PATH]<5D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
String[] sids = this.getSid().split("@");
String sid = "";
for (int i = 0; i < sids.length; i++) {
sid = sids[i];
InvoiceRequestBase invoiceRequestBase = new InvoiceRequestBase();
InvoiceRequestHead invoiceRequestHead = new InvoiceRequestHead();
invoiceRequestHead.setAppid(appId);
invoiceRequestHead.setSid(sid);
invoiceRequestBase.setHead(invoiceRequestHead);
invoiceRequestBase.setComment("<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
invoiceRequestBase.setId("CXKPJG");
invoiceRequestBase.setVersion("1.0");
String xml = JaxbUtil.convertToXml(invoiceRequestBase);
System.out.println(xml);
ResultPojo result = doPost(xml);
// <20><><EFBFBD><EFBFBD>sid<69>õ<EFBFBD>LI_INVOICE_CONFIRM<52><4D><EFBFBD><EFBFBD>id(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>id<69>ʹ˱<CDB4>id<69><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LI_INVOICE_CONFIRM_Detail<69><6C><EFBFBD><EFBFBD>)
BizObjectManager confirmManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM.CLASS_NAME);
BizObject confirm = confirmManager.createQuery("sid=:sid").setParameter("sid", sid).getSingleResult(false);
String invoice_confirm_id = confirm.getAttribute("id").toString();
String id = UUID.randomUUID().toString().replaceAll("-", "");
if (result.getCode() == 0) {
InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData();
String returncode = responseBase.getBody().getReturncode();
String returnmsg = responseBase.getBody().getReturnmsg();
String fplxdm = responseBase.getBody().getFplxdm();
String fpdm = responseBase.getBody().getFpdm();
String fphm = responseBase.getBody().getFphm();
String kprq = responseBase.getBody().getKprq();
String hjje = responseBase.getBody().getHjje();
String skm = responseBase.getBody().getSkm();
String jym = responseBase.getBody().getJym();
String pdfurl = "";
String localFile = "";
String path = "";
String localF = "";
BizObjectManager confirmResultManager = JBOFactory.getBizObjectManager(LI_INVOICE_RESULT.CLASS_NAME);
BizObject confirmResult = confirmResultManager.createQuery("sid=:sid").setParameter("sid", sid).getSingleResult(false);
if (confirmResult != null) {
localF = confirmResult.getAttribute("localFile").toString();
}
if ("0".equals(returncode)) {
pdfurl = responseBase.getBody().getPdfurl();
if (confirmResult == null || "".equals(localF)
|| localF == null) {
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyyMMdd");
String ydm = dateFormat.format(new Date());
path = File.separator + ydm.substring(0, 4)
+ File.separator + ydm.substring(4, 6)
+ File.separator + ydm.substring(6, 8);
path = path
+ File.separator
+ PasswordGenerateUtil
.getRandom(
50,
PasswordGenerateUtil.TYPE.LETTER_CAPITAL)
+ ".pdf";
localFile = INVOICE_LOCAL_PATH + path;
try {
DownloadPdfUtil.go(pdfurl, localFile);
path = SecurityUtil.encrypt(path, "invoice");
} catch (Exception e) {
e.printStackTrace();
return "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>PDFʧ<EFBFBD><EFBFBD>";
}
}
}
if (confirmResult == null) {
BizObject confirmResultNew = confirmResultManager.newObject();
confirmResultNew.setAttributeValue("ID", id);
confirmResultNew.setAttributeValue("sid", sid);
confirmResultNew.setAttributeValue("fplxdm", fplxdm);
confirmResultNew.setAttributeValue("fpdm", fpdm);
confirmResultNew.setAttributeValue("fphm", fphm);
confirmResultNew.setAttributeValue("kprq", kprq);
confirmResultNew.setAttributeValue("hjje", hjje);
confirmResultNew.setAttributeValue("skm", skm);
confirmResultNew.setAttributeValue("jym", jym);
confirmResultNew.setAttributeValue("pdfurl", pdfurl);
confirmResultNew.setAttributeValue("localFile", path);
confirmResultNew.setAttributeValue("returncode", returncode);
confirmResultNew.setAttributeValue("returnmsg", returnmsg);
confirmResultManager.saveObject(confirmResultNew);
} else {
String slocalFile = confirmResult.getAttribute("localFile").toString();
if ("".equals(slocalFile)) {
confirmResultManager.createQuery("update o set fplxdm=:fplxdm,fpdm=:fpdm,fphm=:fphm,kprq=:kprq,hjje=:hjje,skm=:skm,jym=:jym,pdfurl=:pdfurl,localFile=:localFile,returncode=:returncode,returnmsg=:returnmsg where sid=:sid ")
.setParameter("sid", sid)
.setParameter("fplxdm", fplxdm)
.setParameter("fpdm", fpdm)
.setParameter("fphm", fphm)
.setParameter("kprq", kprq)
.setParameter("hjje", hjje)
.setParameter("skm", skm)
.setParameter("jym", jym)
.setParameter("returncode", returncode)
.setParameter("returnmsg", returnmsg)
.setParameter("pdfurl", pdfurl)
.setParameter("localFile", path)
.executeUpdate();
} else {
confirmResultManager.createQuery("update o set fplxdm=:fplxdm,fpdm=:fpdm,fphm=:fphm,kprq=:kprq,hjje=:hjje,skm=:skm,jym=:jym,returncode=:returncode,returnmsg=:returnmsg where sid=:sid ")
.setParameter("sid", sid)
.setParameter("fplxdm", fplxdm)
.setParameter("fpdm", fpdm)
.setParameter("fphm", fphm)
.setParameter("kprq", kprq)
.setParameter("hjje", hjje)
.setParameter("skm", skm)
.setParameter("jym", jym)
.setParameter("returncode", returncode)
.setParameter("returnmsg", returnmsg)
.executeUpdate();
}
}
System.out.println("[OK][returncode]=>>>" + returncode);
System.out.println("[OK][returnmsg]=>>>" + returnmsg);
if ("0".equals(returncode)) {
// <20>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>״̬
BizObjectManager confirmDetailManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM_DETAIL.CLASS_NAME);
BizObject confirmDetail = confirmDetailManager.createQuery("invoice_confirm_id=:invoice_confirm_id")
.setParameter("invoice_confirm_id",invoice_confirm_id).getSingleResult(false);
String invoiceId = confirmDetail.getAttribute("invoice_id").toString();
BizObjectManager invoiceRentManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME, tx);
invoiceRentManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ")
.setParameter("id", invoiceId)
.setParameter("invoicestatus", "5").executeUpdate();
} else {
return returnmsg;
}
} else {
System.out.println("[FAIL]=>>>" + result.getMsg());
return result.getMsg();
}
}
return "<EFBFBD><EFBFBD>ѯ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>";
/*
* if(result.getCode().toString()!="0"){ return "<22><>ѯʧ<D1AF><CAA7>"; }
*
* System.out.println("result=>>>"+JSONObject.toJSONString(result));
* showResult(result); return "<22><>ѯ<EFBFBD>ɹ<EFBFBD>";
*/
}
/**
* <20><><EFBFBD><EFBFBD>6
* <20><><EFBFBD><EFBFBD>5<EFBFBD>е<EFBFBD><D0B5>ô˷<C3B4><CBB7><EFBFBD>
* @param xml
* @return
*/
public ResultPojo doPost(String xml) {
Configure config = Configure.getInstance();
String url = "";
try {
url = config.getConfigure("INVOICE_URL");
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
HttpHeaders httpHeaders = new HttpHeaders();
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
param.add("bw", xml);
RestTemplate restTemplate = new RestTemplate();
HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<>(
param, httpHeaders);
ResponseEntity<String> response = null;
try {
response = restTemplate.exchange(url, HttpMethod.POST, entity,
String.class);
} catch (Exception e) {
return ResultUtil.error(ResponseEnum.NETWORK.getMsg());
}
System.out.println(response.getBody());
InvoiceRequestBase r = JaxbUtil.converyToJavaBean(response.getBody(),InvoiceRequestBase.class);
return ResultUtil.success(r);
}
/**
* <20><>ʾ<EFBFBD>ӿڷ<D3BF><DAB7>صĽ<D8B5><C4BD><EFBFBD>
* <20>˷<EFBFBD><CBB7><EFBFBD>δʹ<CEB4><CAB9>
* @param result
*/
private void showResult(ResultPojo result) {
if (result.getCode() == 0) {
InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData();
String returncode = responseBase.getBody().getReturncode();
String returnmsg = responseBase.getBody().getReturnmsg();
System.out.println("[OK][returncode]=>>>" + returncode);
System.out.println("[OK][returnmsg]=>>>" + returnmsg);
if ("0".equals(returncode)) {
System.out.println("[OK][SUCCESS]");
}
} else {
System.out.println("[FAIL]=>>>" + result.getMsg());
}
}
}