1084 lines
52 KiB
Java
1084 lines
52 KiB
Java
package com.tenwa.flow.rent.rentincome;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.sql.CallableStatement;
|
|
import java.sql.Connection;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.ResultSet;
|
|
import java.sql.Statement;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.springframework.web.context.ContextLoader;
|
|
import org.springframework.web.context.WebApplicationContext;
|
|
|
|
import jbo.app.tenwa.calc.LC_CARD_DEDUCT_DOC_TEMP;
|
|
import jbo.app.tenwa.calc.LC_EBANK_PROCESS;
|
|
import jbo.app.tenwa.calc.LC_EBANK_TEMP;
|
|
import jbo.app.tenwa.calc.LC_FUND_INCOME;
|
|
import jbo.app.tenwa.calc.LC_FUND_INCOME_TEMP;
|
|
import jbo.app.tenwa.calc.LC_FUND_PLAN;
|
|
import jbo.app.tenwa.calc.LC_RENT_INCOME;
|
|
import jbo.app.tenwa.calc.LC_RENT_INCOME_TEMP;
|
|
import jbo.app.tenwa.calc.LC_RENT_PLAN;
|
|
import jbo.app.tenwa.calc.VI_CARD_DEDUCT_DATA;
|
|
import jbo.app.tenwa.calc.VI_LC_RENT_PLAN;
|
|
import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO;
|
|
import jbo.com.tenwa.lease.comm.LC_OCCUPY_RENT_LIST;
|
|
|
|
import com.amarsoft.app.awe.config.InitDBType;
|
|
import com.amarsoft.app.util.ProductParamUtil;
|
|
import com.amarsoft.are.jbo.BizObject;
|
|
import com.amarsoft.are.jbo.BizObjectManager;
|
|
import com.amarsoft.are.jbo.JBOException;
|
|
import com.amarsoft.are.jbo.JBOFactory;
|
|
import com.amarsoft.are.jbo.JBOTransaction;
|
|
import com.amarsoft.are.util.StringFunction;
|
|
import com.amarsoft.awe.util.Transaction;
|
|
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
|
import com.tenwa.reckon.constant.Scale;
|
|
import com.tenwa.reckon.util.UUIDUtil;
|
|
|
|
public class RentIncomeMethod {
|
|
|
|
private String planIDs;
|
|
private String flowunid;
|
|
private String overCorpuss;
|
|
private String overInterests;
|
|
private String overPenaltys;
|
|
private String balance;
|
|
private String portionCollectionID;
|
|
private String portionMoney;
|
|
private String oldFactMoney;
|
|
private String newFactMoney;
|
|
private String cautionDeductionIDs;
|
|
private String ids;//实际回笼临时表标识
|
|
private String isChanged;//操作时后台数据库产生变化开关
|
|
private String sql;
|
|
private String userid;
|
|
private String orgid;
|
|
private String deductDocId;
|
|
|
|
public String getDeductDocId() {
|
|
return deductDocId;
|
|
}
|
|
|
|
public void setDeductDocId(String deductDocId) {
|
|
this.deductDocId = deductDocId;
|
|
}
|
|
|
|
public String getUserid() {
|
|
return userid;
|
|
}
|
|
|
|
public void setUserid(String userid) {
|
|
this.userid = userid;
|
|
}
|
|
|
|
public String getOrgid() {
|
|
return orgid;
|
|
}
|
|
|
|
public void setOrgid(String orgid) {
|
|
this.orgid = orgid;
|
|
}
|
|
|
|
public String getSql() {
|
|
return sql;
|
|
}
|
|
|
|
public void setSql(String sql) {
|
|
this.sql = sql;
|
|
}
|
|
|
|
public String getIsChanged() {
|
|
return isChanged;
|
|
}
|
|
|
|
public void setIsChanged(String isChanged) {
|
|
this.isChanged = isChanged;
|
|
}
|
|
|
|
public String getIds() {
|
|
return ids;
|
|
}
|
|
|
|
public void setIds(String ids) {
|
|
this.ids = ids;
|
|
}
|
|
|
|
public String getCautionDeductionIDs() {
|
|
return cautionDeductionIDs;
|
|
}
|
|
|
|
public void setCautionDeductionIDs(String cautionDeductionIDs) {
|
|
this.cautionDeductionIDs = cautionDeductionIDs;
|
|
}
|
|
|
|
public String getFlowunid() {
|
|
return flowunid;
|
|
}
|
|
|
|
public void setFlowunid(String flowunid) {
|
|
this.flowunid = flowunid;
|
|
}
|
|
|
|
public String getPlanIDs() {
|
|
return planIDs;
|
|
}
|
|
|
|
public void setPlanIDs(String planIDs) {
|
|
this.planIDs = planIDs;
|
|
}
|
|
|
|
public String getOverCorpuss() {
|
|
return overCorpuss;
|
|
}
|
|
|
|
public void setOverCorpuss(String overCorpuss) {
|
|
this.overCorpuss = overCorpuss;
|
|
}
|
|
|
|
public String getOverInterests() {
|
|
return overInterests;
|
|
}
|
|
|
|
public void setOverInterests(String overInterests) {
|
|
this.overInterests = overInterests;
|
|
}
|
|
|
|
public String getOverPenaltys() {
|
|
return overPenaltys;
|
|
}
|
|
|
|
public void setOverPenaltys(String overPenaltys) {
|
|
this.overPenaltys = overPenaltys;
|
|
}
|
|
|
|
public String getBalance() {
|
|
return balance;
|
|
}
|
|
|
|
public void setBalance(String balance) {
|
|
this.balance = balance;
|
|
}
|
|
|
|
public String getPortionCollectionID() {
|
|
return portionCollectionID;
|
|
}
|
|
|
|
public void setPortionCollectionID(String portionCollectionID) {
|
|
this.portionCollectionID = portionCollectionID;
|
|
}
|
|
|
|
public String getPortionMoney() {
|
|
return portionMoney;
|
|
}
|
|
|
|
public void setPortionMoney(String portionMoney) {
|
|
this.portionMoney = portionMoney;
|
|
}
|
|
|
|
public String getOldFactMoney() {
|
|
return oldFactMoney;
|
|
}
|
|
|
|
public void setOldFactMoney(String oldFactMoney) {
|
|
this.oldFactMoney = oldFactMoney;
|
|
}
|
|
|
|
public String getNewFactMoney() {
|
|
return newFactMoney;
|
|
}
|
|
|
|
public void setNewFactMoney(String newFactMoney) {
|
|
this.newFactMoney = newFactMoney;
|
|
}
|
|
/**
|
|
* 租金核销
|
|
*/
|
|
public String setRentDataToRentIncome(JBOTransaction tx) throws JBOException{
|
|
try{
|
|
boolean flag = false;
|
|
if("Y".equals(isChanged)){
|
|
flag = true;
|
|
}
|
|
BigDecimal bel = new BigDecimal(balance == null?"0":balance); //可核销金额
|
|
BigDecimal allFactMoney = bel;
|
|
BizObjectManager bomEb = JBOFactory.getBizObjectManager(LC_EBANK_TEMP.CLASS_NAME);
|
|
tx.join(bomEb);
|
|
BizObject boEb = bomEb.createQuery("FLOWUNID=:FLOWUNID")
|
|
.setParameter("FLOWUNID", flowunid).getSingleResult(true);
|
|
if(flag){
|
|
bel = new BigDecimal(boEb.getAttribute("MAYOPE_MONEY").getString());
|
|
allFactMoney = bel;
|
|
}
|
|
String[] ids = planIDs.split("@");
|
|
String[] corpuss = new String[ids.length];
|
|
String[] interests = new String[ids.length];
|
|
String[] Penaltys = new String[ids.length];
|
|
if(overCorpuss != null){
|
|
corpuss = overCorpuss.split("@");
|
|
interests = overInterests.split("@");
|
|
Penaltys = overPenaltys.split("@");
|
|
}
|
|
String factDate = boEb.getAttribute("FACT_DATE").getString();
|
|
Date f = new SimpleDateFormat("yyyy/MM/dd").parse(factDate);
|
|
for(int i=0;i<ids.length;i++){
|
|
BizObject boVLRP = JBOFactory.createBizObjectQuery(LC_RENT_PLAN.CLASS_NAME, "ID=:ID").setParameter("ID", ids[i])
|
|
.getSingleResult(false);
|
|
BizObject boLCI = JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO.CLASS_NAME, "ID=:ID").setParameter("ID", boVLRP.getAttribute("CONTRACT_ID").getString())
|
|
.getSingleResult(false);
|
|
Map<String,List<Map<String,String>>> paymentOrders = ProductParamUtil.getProductComponentDecisionTable(boLCI.getAttribute("PRODUCT_ID").getString(), "PRD0307", "rmoname", "rmosortno");
|
|
String penaltyRule = ProductParamUtil.getProductParameterValue(boLCI.getAttribute("PRODUCT_ID").getString(), "PRD0307","PenaltyRule", "PenaltyRule");
|
|
String[] paymentOrder = new String[3];
|
|
String planDate = boVLRP.getAttribute("PLAN_DATE").getString();
|
|
if(f.compareTo(new SimpleDateFormat("yyyy/MM/dd").parse(planDate)) > 0){
|
|
for(int j=0;j<paymentOrders.get("RMO-02").size();j++){
|
|
paymentOrder[Integer.parseInt(paymentOrders.get("RMO-02").get(j).get("rmosortno"))-1] = paymentOrders.get("RMO-02").get(j).get("rmoname");
|
|
}
|
|
}else{
|
|
for(int j=0;j<paymentOrders.get("RMO-01").size();j++){
|
|
paymentOrder[Integer.parseInt(paymentOrders.get("RMO-01").get(j).get("rmosortno"))-1] = paymentOrders.get("RMO-01").get(j).get("rmoname");
|
|
}
|
|
}
|
|
if("penalty_income".equals(penaltyRule)){
|
|
Penaltys[i] = "0.00";
|
|
}
|
|
BizObjectManager boLRI = JBOFactory.getBizObjectManager(LC_RENT_INCOME_TEMP.CLASS_NAME);
|
|
BizObjectManager bomLORL = JBOFactory.getBizObjectManager(LC_OCCUPY_RENT_LIST.CLASS_NAME,tx);
|
|
BizObject boLORL = bomLORL.newObject();
|
|
boLORL.setAttributeValue("ID", UUIDUtil.getUUID());
|
|
boLORL.setAttributeValue("PAYMENT_NUMBER", boVLRP.getAttribute("PAYMENT_NUMBER").getString());
|
|
boLORL.setAttributeValue("PLAN_LIST", boVLRP.getAttribute("PLAN_LIST").getString());
|
|
boLORL.setAttributeValue("FLOW_NAME", "网银收款");
|
|
boLORL.setAttributeValue("FLOWUNID", flowunid);
|
|
bomLORL.saveObject(boLORL);
|
|
tx.join(boLRI);
|
|
BizObject boLRIT = boLRI.newObject();
|
|
boLRIT.setAttributeValue("QUOT_ID", boVLRP.getAttribute("QUOT_ID").getString());
|
|
boLRIT.setAttributeValue("CUST_ID", boVLRP.getAttribute("CUST_ID").getString());
|
|
boLRIT.setAttributeValue("PROJECT_ID", boVLRP.getAttribute("PROJECT_ID").getString());
|
|
boLRIT.setAttributeValue("PROJECT_PLAN_NUMBER", boVLRP.getAttribute("PROJECT_PLAN_NUMBER").getString());
|
|
boLRIT.setAttributeValue("CONTRACT_ID", boVLRP.getAttribute("CONTRACT_ID").getString());
|
|
boLRIT.setAttributeValue("CONTRACT_PLAN_NUMBER", boVLRP.getAttribute("CONTRACT_PLAN_NUMBER").getString());
|
|
boLRIT.setAttributeValue("PAYMENT_NUMBER", boVLRP.getAttribute("PAYMENT_NUMBER").getString());
|
|
boLRIT.setAttributeValue("EBANK_NUMBER", boEb.getAttribute("ID").getString());
|
|
boLRIT.setAttributeValue("PLAN_ID", ids[i]);
|
|
boLRIT.setAttributeValue("PLAN_LIST", boVLRP.getAttribute("PLAN_LIST").getString());
|
|
boLRIT.setAttributeValue("INTEREST_ADJUST", 0);
|
|
boLRIT.setAttributeValue("SETTLE_METHOD", "settlemethod6");
|
|
List<BizObject> boLCRI = JBOFactory.createBizObjectQuery(LC_RENT_INCOME.CLASS_NAME, "PLAN_ID=:PLAN_ID").setParameter("PLAN_ID", ids[i])
|
|
.getResultList(false);
|
|
List<BizObject> boLCRIT = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and IS_FLOWING = 0").setParameter("PLAN_ID", ids[i])
|
|
.getResultList(false);
|
|
boLRIT.setAttributeValue("HIRE_LIST", boLCRI.size()+boLCRIT.size()+1);
|
|
boLRIT.setAttributeValue("HIRE_DATE", boEb.getAttribute("FACT_DATE").getString());
|
|
boLRIT.setAttributeValue("HIRE_OBJECT", boEb.getAttribute("CLIENT_NAME").getString());
|
|
BigDecimal money;
|
|
if(!flag){
|
|
money = new BigDecimal(corpuss[i]).add(new BigDecimal(interests[i])).add(new BigDecimal(Penaltys[i]));
|
|
if(!ids[i].equals(portionCollectionID)){
|
|
bel = bel.subtract(money);
|
|
boLRIT.setAttributeValue("RENT", new BigDecimal(corpuss[i]).add(new BigDecimal(interests[i])));
|
|
boLRIT.setAttributeValue("CORPUS", new BigDecimal(corpuss[i]));
|
|
boLRIT.setAttributeValue("INTEREST", new BigDecimal(interests[i]));
|
|
boLRIT.setAttributeValue("PENALTY", new BigDecimal(Penaltys[i]));
|
|
}else{
|
|
BigDecimal portionMoneys = new BigDecimal(portionMoney);
|
|
BigDecimal rentMoney = new BigDecimal(0);
|
|
for(int j=0;j<paymentOrder.length;j++){ //获取产品还款次序
|
|
BigDecimal subtractMoney = new BigDecimal(0);
|
|
String subtractMoneyName = "";
|
|
if("本金".equals(paymentOrder[j])){
|
|
subtractMoneyName = "CORPUS";
|
|
subtractMoney = new BigDecimal(corpuss[i]);
|
|
}else if("利息".equals(paymentOrder[j])){
|
|
subtractMoneyName = "INTEREST";
|
|
subtractMoney = new BigDecimal(interests[i]);
|
|
}else if("罚息".equals(paymentOrder[j])){
|
|
subtractMoneyName = "PENALTY";
|
|
subtractMoney = new BigDecimal(Penaltys[i]);
|
|
}
|
|
if(portionMoneys.compareTo(new BigDecimal(0)) == 0){ //如果已经为0,则为对应的回笼对象赋值0
|
|
if("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)){
|
|
rentMoney = rentMoney.add(new BigDecimal(0));
|
|
}
|
|
boLRIT.setAttributeValue(subtractMoneyName, 0);
|
|
}else{
|
|
if(portionMoneys.compareTo(subtractMoney) >= 0){ //如果能正常减去,则为对应的回笼对象赋值对应值
|
|
if("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)){
|
|
rentMoney = rentMoney.add(subtractMoney);
|
|
}
|
|
portionMoneys = portionMoneys.subtract(subtractMoney);
|
|
boLRIT.setAttributeValue(subtractMoneyName, subtractMoney);
|
|
}else{ //如果不够减,则把剩余的值赋值给对应的回笼对象
|
|
if("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)){
|
|
rentMoney = rentMoney.add(portionMoneys);
|
|
}
|
|
boLRIT.setAttributeValue(subtractMoneyName, portionMoneys);
|
|
portionMoneys = new BigDecimal(0);
|
|
}
|
|
}
|
|
}
|
|
boLRIT.setAttributeValue("RENT", rentMoney);
|
|
bel = bel.subtract(new BigDecimal(portionMoney));
|
|
}
|
|
}else{
|
|
BizObject bo = JBOFactory.getBizObjectManager(VI_LC_RENT_PLAN.CLASS_NAME).createQuery("id=:planID").setParameter("planID", ids[i]).getSingleResult(false);
|
|
String corpusOver = bo.getAttribute("corpus_over").getString();
|
|
String interestOver = bo.getAttribute("interest_over").getString();
|
|
String penaltyOver = bo.getAttribute("penalty_over").getString();
|
|
if("penalty_income".equals(penaltyRule)){
|
|
penaltyOver = "0.00";
|
|
}else{
|
|
// penaltyOver = JBOFactory.getBizObjectManager(VI_LC_RENT_PLAN.CLASS_NAME).createQuery("select v.getRentPenalty('"+boVLRP.getAttribute("PAYMENT_NUMBER").getString()+"','"+boVLRP.getAttribute("PLAN_LIST").getString()+"','"+factDate+"') v.penalty from O").getSingleResult(false).getAttribute("penalty").getString();
|
|
}
|
|
money = new BigDecimal(corpusOver).add(new BigDecimal(interestOver)).add(new BigDecimal(penaltyOver));
|
|
if(money.compareTo(bel) <= 0){
|
|
bel = bel.subtract(money);
|
|
boLRIT.setAttributeValue("RENT", new BigDecimal(corpusOver).add(new BigDecimal(interestOver)));
|
|
boLRIT.setAttributeValue("CORPUS", new BigDecimal(corpusOver));
|
|
boLRIT.setAttributeValue("INTEREST", new BigDecimal(interestOver));
|
|
boLRIT.setAttributeValue("PENALTY", new BigDecimal(penaltyOver));
|
|
}else{
|
|
BigDecimal portionMoneys = bel;
|
|
BigDecimal rentMoney = new BigDecimal(0);
|
|
for(int j=0;j<paymentOrder.length;j++){ //获取产品还款次序
|
|
BigDecimal subtractMoney = new BigDecimal(0);
|
|
String subtractMoneyName = "";
|
|
if("本金".equals(paymentOrder[j])){
|
|
subtractMoneyName = "CORPUS";
|
|
subtractMoney = new BigDecimal(corpusOver);
|
|
}else if("利息".equals(paymentOrder[j])){
|
|
subtractMoneyName = "INTEREST";
|
|
subtractMoney = new BigDecimal(interestOver);
|
|
}else if("罚息".equals(paymentOrder[j])){
|
|
subtractMoneyName = "PENALTY";
|
|
subtractMoney = new BigDecimal(penaltyOver);
|
|
}
|
|
if(portionMoneys.compareTo(new BigDecimal(0)) == 0){ //如果已经为0,则为对应的回笼对象赋值0
|
|
if("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)){
|
|
rentMoney = rentMoney.add(new BigDecimal(0));
|
|
}
|
|
boLRIT.setAttributeValue(subtractMoneyName, 0);
|
|
}else{
|
|
if(portionMoneys.compareTo(subtractMoney) >= 0){ //如果能正常减去,则为对应的回笼对象赋值对应值
|
|
if("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)){
|
|
rentMoney = rentMoney.add(subtractMoney);
|
|
}
|
|
portionMoneys = portionMoneys.subtract(subtractMoney);
|
|
boLRIT.setAttributeValue(subtractMoneyName, subtractMoney);
|
|
}else{ //如果不够减,则把剩余的值赋值给对应的回笼对象
|
|
if("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)){
|
|
rentMoney = rentMoney.add(portionMoneys);
|
|
}
|
|
boLRIT.setAttributeValue(subtractMoneyName, portionMoneys);
|
|
portionMoneys = new BigDecimal(0);
|
|
}
|
|
}
|
|
}
|
|
boLRIT.setAttributeValue("RENT", rentMoney);
|
|
bel = bel.subtract(bel);
|
|
}
|
|
}
|
|
boLRIT.setAttributeValue("CORPUS_ADJUST", 0);
|
|
boLRIT.setAttributeValue("PENALTY_ADJUST", 0);
|
|
boLRIT.setAttributeValue("OWN_BANK", boEb.getAttribute("OWN_BANK").getString());
|
|
boLRIT.setAttributeValue("OWN_ACCOUNT", boEb.getAttribute("OWN_ACCOUNT").getString());
|
|
boLRIT.setAttributeValue("OWN_NUMBER", boEb.getAttribute("OWNACC_NUMBER").getString());
|
|
boLRIT.setAttributeValue("HIRE_BANK", boEb.getAttribute("CLIENT_BANK").getString());
|
|
boLRIT.setAttributeValue("HIRE_ACCOUNT", boEb.getAttribute("CLIENT_ACCOUNT").getString());
|
|
boLRIT.setAttributeValue("HIRE_NUMBER", boEb.getAttribute("CLIENT_ACC_NUMBER").getString());
|
|
//安鹏要求改为当前日期
|
|
//boLRIT.setAttributeValue("ACCOUNTING_DATE", boEb.getAttribute("FACT_DATE").getString());
|
|
boLRIT.setAttributeValue("ACCOUNTING_DATE", StringFunction.getToday());
|
|
boLRIT.setAttributeValue("ROLL_BACK", 0);
|
|
boLRIT.setAttributeValue("COIN", boVLRP.getAttribute("COIN").getString());
|
|
boLRIT.setAttributeValue("IS_FLOWING", 0);
|
|
boLRIT.setAttributeValue("FLOWUNID", flowunid);
|
|
boLRI.saveObject(boLRIT);
|
|
}
|
|
if(bel.compareTo(new BigDecimal(0)) > 0){
|
|
allFactMoney = allFactMoney.subtract(bel);
|
|
}
|
|
BizObjectManager bomLEP = JBOFactory.getBizObjectManager(LC_EBANK_PROCESS.CLASS_NAME);
|
|
tx.join(bomLEP);
|
|
BizObject boLEP = bomLEP.createQuery("FLOWUNID=:FLOWUNID").setParameter("FLOWUNID", flowunid).getSingleResult(true);
|
|
BigDecimal processMoney = new BigDecimal(boLEP.getAttribute("PROCESS_MONEY").getDouble());
|
|
boLEP.setAttributeValue("PROCESS_MONEY", processMoney.add(allFactMoney));
|
|
bomLEP.saveObject(boLEP);
|
|
BigDecimal hadMoney = new BigDecimal(boEb.getAttribute("HAD_MONEY").getDouble()).add(allFactMoney);
|
|
BigDecimal factMoney = new BigDecimal(boEb.getAttribute("FACT_MONEY").getDouble());
|
|
boEb.setAttributeValue("HAD_MONEY", hadMoney);
|
|
boEb.setAttributeValue("MAYOPE_MONEY", factMoney.subtract(hadMoney));
|
|
bomEb.saveObject(boEb);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
return "ERROR";
|
|
}
|
|
return "SUCCESS";
|
|
}
|
|
|
|
/**
|
|
* 保证金抵扣
|
|
*/
|
|
public String setCautionDeduction(JBOTransaction tx) throws Exception{
|
|
try{
|
|
boolean flag = false;
|
|
if("Y".equals(isChanged)){
|
|
flag = true;
|
|
}
|
|
String[] ids = planIDs.split("@");//计划id
|
|
String[] corpuss = new String[ids.length];
|
|
String[] interests = new String[ids.length];
|
|
String[] Penaltys = new String[ids.length];
|
|
if(overCorpuss != null){
|
|
corpuss = overCorpuss.split("@");//本金余额
|
|
interests = overInterests.split("@");//利息余额
|
|
Penaltys = overPenaltys.split("@");//罚息余额
|
|
}
|
|
String[] datas = cautionDeductionIDs.split("@~");//保证金抵扣id+保证金余额
|
|
String[] cIDs = new String[datas.length];
|
|
BigDecimal[] overmoneys = new BigDecimal[datas.length];//保证金余额
|
|
BigDecimal zero = new BigDecimal(0);
|
|
BizObjectManager boLRI = JBOFactory.getBizObjectManager(LC_RENT_INCOME_TEMP.CLASS_NAME);
|
|
tx.join(boLRI);
|
|
BizObjectManager boLFI = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME);
|
|
tx.join(boLFI);
|
|
for(int i=0;i<datas.length;i++){
|
|
cIDs[i] = datas[i].split("@")[0];//保证金抵扣id
|
|
overmoneys[i] = new BigDecimal(datas[i].split("@")[1]);//保证金抵扣余额
|
|
}
|
|
for(int i=0;i<cIDs.length;i++){
|
|
String deductionID = UUIDUtil.getUUID();
|
|
BigDecimal deductionOverMoney = overmoneys[i];
|
|
for(int j=0;j<ids.length;j++){
|
|
List<BizObject> boLCRI = JBOFactory.createBizObjectQuery(LC_RENT_INCOME.CLASS_NAME, "PLAN_ID=:PLAN_ID and ROLL_BACK=0 ").setParameter("PLAN_ID", ids[j])
|
|
.getResultList(false);
|
|
List<BizObject> boLCRIT = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and IS_FLOWING = 0 and ROLL_BACK=0 ").setParameter("PLAN_ID", ids[j])
|
|
.getResultList(false);
|
|
int charge_list = boLCRI.size()+boLCRIT.size()+1;
|
|
BizObject boVLRP = JBOFactory.createBizObjectQuery(LC_RENT_PLAN.CLASS_NAME, "ID=:ID").setParameter("ID", ids[j])
|
|
.getSingleResult(false);
|
|
BizObject boLCI = JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO.CLASS_NAME, "ID=:ID").setParameter("ID", boVLRP.getAttribute("CONTRACT_ID").getString())
|
|
.getSingleResult(false);
|
|
Map<String,List<Map<String,String>>> paymentOrders = ProductParamUtil.getProductComponentDecisionTable(boLCI.getAttribute("PRODUCT_ID").getString(), "PRD0307", "rmoname", "rmosortno");
|
|
String penaltyRule = ProductParamUtil.getProductParameterValue(boLCI.getAttribute("PRODUCT_ID").getString(), "PRD0307","PenaltyRule", "PenaltyRule");
|
|
if("penalty_income".equals(penaltyRule)){
|
|
Penaltys[j] = "0.00";
|
|
}
|
|
BigDecimal money = new BigDecimal(corpuss[j]).add(new BigDecimal(interests[j])).add(new BigDecimal(Penaltys[j]));
|
|
String corpusOver = "";
|
|
String interestOver = "";
|
|
String penaltyOver = "";
|
|
if(flag){
|
|
BizObject bo = JBOFactory.getBizObjectManager(VI_LC_RENT_PLAN.CLASS_NAME).createQuery("id=:planID").setParameter("planID", ids[i]).getSingleResult(false);
|
|
corpusOver = bo.getAttribute("corpus_over").getString();
|
|
interestOver = bo.getAttribute("interest_over").getString();
|
|
penaltyOver = bo.getAttribute("penalty_over").getString();
|
|
if("penalty_income".equals(penaltyRule)){
|
|
penaltyOver = "0.00";
|
|
}
|
|
money = new BigDecimal(corpusOver).add(new BigDecimal(interestOver)).add(new BigDecimal(penaltyOver));
|
|
}
|
|
if(deductionOverMoney.compareTo(zero)>0 && money.compareTo(zero)>0){//保证金抵扣大于零和活动租金大于零
|
|
BizObjectManager bomLORL = JBOFactory.getBizObjectManager(LC_OCCUPY_RENT_LIST.CLASS_NAME,tx);
|
|
BizObject boLORL = bomLORL.createQuery("PAYMENT_NUMBER=:paymentnumber and PLAN_LIST=:planlist and FLOW_NAME='保证金抵扣流程' and FLOWUNID=:flowunid ").setParameter("paymentnumber", boVLRP.getAttribute("PAYMENT_NUMBER").getString())
|
|
.setParameter("planlist",boVLRP.getAttribute("PLAN_LIST").getString()).setParameter("flowunid",flowunid).getSingleResult();
|
|
if(boLORL==null){
|
|
boLORL = bomLORL.newObject();
|
|
boLORL.setAttributeValue("ID", UUIDUtil.getUUID());
|
|
boLORL.setAttributeValue("PAYMENT_NUMBER", boVLRP.getAttribute("PAYMENT_NUMBER").getString());
|
|
boLORL.setAttributeValue("PLAN_LIST", boVLRP.getAttribute("PLAN_LIST").getString());
|
|
boLORL.setAttributeValue("FLOW_NAME", "保证金抵扣流程");
|
|
boLORL.setAttributeValue("FLOWUNID", flowunid);
|
|
bomLORL.saveObject(boLORL);
|
|
}
|
|
String[] paymentOrder = new String[3];
|
|
if(new BigDecimal(Penaltys[j]).compareTo(zero)==0){//正常还款次序
|
|
for(int k=0;k<paymentOrders.get("RMO-01").size();k++){
|
|
paymentOrder[Integer.parseInt(paymentOrders.get("RMO-01").get(k).get("rmosortno"))-1] = paymentOrders.get("RMO-01").get(k).get("rmoname");
|
|
}
|
|
}else{
|
|
for(int k=0;k<paymentOrders.get("RMO-02").size();k++){//逾期还款次序
|
|
paymentOrder[Integer.parseInt(paymentOrders.get("RMO-02").get(k).get("rmosortno"))-1] = paymentOrders.get("RMO-02").get(k).get("rmoname");
|
|
}
|
|
}
|
|
BizObject boLRIT = boLRI.newObject();
|
|
boLRIT.setAttributeValue("QUOT_ID", boVLRP.getAttribute("QUOT_ID").getString());
|
|
boLRIT.setAttributeValue("CUST_ID", boVLRP.getAttribute("CUST_ID").getString());
|
|
boLRIT.setAttributeValue("PROJECT_ID", boVLRP.getAttribute("PROJECT_ID").getString());
|
|
boLRIT.setAttributeValue("PROJECT_PLAN_NUMBER", boVLRP.getAttribute("PROJECT_PLAN_NUMBER").getString());
|
|
boLRIT.setAttributeValue("CONTRACT_ID", boVLRP.getAttribute("CONTRACT_ID").getString());
|
|
boLRIT.setAttributeValue("CONTRACT_PLAN_NUMBER", boVLRP.getAttribute("CONTRACT_PLAN_NUMBER").getString());
|
|
boLRIT.setAttributeValue("PAYMENT_NUMBER", boVLRP.getAttribute("PAYMENT_NUMBER").getString());
|
|
boLRIT.setAttributeValue("PLAN_ID", ids[j]);
|
|
boLRIT.setAttributeValue("PLAN_LIST", boVLRP.getAttribute("PLAN_LIST").getString());
|
|
boLRIT.setAttributeValue("INTEREST_ADJUST", 0);
|
|
boLRIT.setAttributeValue("SETTLE_METHOD", "settlemethod7");
|
|
boLRIT.setAttributeValue("HIRE_LIST", charge_list);
|
|
boLRIT.setAttributeValue("HIRE_DATE", StringFunction.getToday());
|
|
boLRIT.setAttributeValue("ACCOUNTING_DATE", StringFunction.getToday());
|
|
if(deductionOverMoney.compareTo(money)>=0){//此笔保证金抵扣余额大于等于回笼租金加回笼罚息之和
|
|
if(flag){
|
|
boLRIT.setAttributeValue("RENT", new BigDecimal(corpusOver).add(new BigDecimal(interestOver)));
|
|
boLRIT.setAttributeValue("CORPUS", new BigDecimal(corpusOver));
|
|
boLRIT.setAttributeValue("INTEREST", new BigDecimal(interestOver));
|
|
boLRIT.setAttributeValue("PENALTY", new BigDecimal(penaltyOver));
|
|
}else{
|
|
boLRIT.setAttributeValue("RENT", new BigDecimal(corpuss[j]).add(new BigDecimal(interests[j])));
|
|
boLRIT.setAttributeValue("CORPUS", new BigDecimal(corpuss[j]));
|
|
boLRIT.setAttributeValue("INTEREST", new BigDecimal(interests[j]));
|
|
boLRIT.setAttributeValue("PENALTY", new BigDecimal(Penaltys[j]));
|
|
corpuss[j]="0.00";
|
|
interests[j]="0.00";
|
|
Penaltys[j]="0.00";
|
|
}
|
|
deductionOverMoney=deductionOverMoney.subtract(money);
|
|
}else{//此笔保证金抵扣余额小于回笼租金加回笼罚息之和
|
|
if(flag){
|
|
BigDecimal thisRent = zero;
|
|
for(int k=0;k<paymentOrder.length;k++){
|
|
if("本金".equals(paymentOrder[k])){
|
|
if(deductionOverMoney.compareTo(new BigDecimal(corpusOver))>=0){
|
|
boLRIT.setAttributeValue("CORPUS", new BigDecimal(corpusOver));
|
|
deductionOverMoney=deductionOverMoney.subtract(new BigDecimal(corpusOver));
|
|
thisRent=thisRent.add(new BigDecimal(corpusOver));
|
|
}else{
|
|
boLRIT.setAttributeValue("CORPUS", deductionOverMoney);
|
|
deductionOverMoney=zero;
|
|
thisRent=thisRent.add(deductionOverMoney);
|
|
}
|
|
}else if("利息".equals(paymentOrder[k])){
|
|
if(deductionOverMoney.compareTo(new BigDecimal(interestOver))>=0){
|
|
boLRIT.setAttributeValue("INTEREST", new BigDecimal(interestOver));
|
|
deductionOverMoney=deductionOverMoney.subtract(new BigDecimal(interestOver));
|
|
thisRent=thisRent.add(new BigDecimal(interestOver));
|
|
}else{
|
|
boLRIT.setAttributeValue("INTEREST", deductionOverMoney);
|
|
deductionOverMoney=zero;
|
|
thisRent=thisRent.add(deductionOverMoney);
|
|
}
|
|
}else if("罚息".equals(paymentOrder[k])){
|
|
if(deductionOverMoney.compareTo(new BigDecimal(penaltyOver))>=0){
|
|
boLRIT.setAttributeValue("PENALTY", new BigDecimal(penaltyOver));
|
|
deductionOverMoney=deductionOverMoney.subtract(new BigDecimal(penaltyOver));
|
|
}else{
|
|
boLRIT.setAttributeValue("PENALTY", deductionOverMoney);
|
|
deductionOverMoney=zero;
|
|
}
|
|
}
|
|
}
|
|
boLRIT.setAttributeValue("RENT", thisRent);
|
|
}else{
|
|
BigDecimal thisRent = zero;
|
|
for(int k=0;k<paymentOrder.length;k++){
|
|
if("本金".equals(paymentOrder[k])){
|
|
if(deductionOverMoney.compareTo(new BigDecimal(corpuss[j]))>=0){
|
|
boLRIT.setAttributeValue("CORPUS", new BigDecimal(corpuss[j]));
|
|
deductionOverMoney=deductionOverMoney.subtract(new BigDecimal(corpuss[j]));
|
|
thisRent=thisRent.add(new BigDecimal(corpuss[j]));
|
|
corpuss[j]="0.00";
|
|
}else{
|
|
boLRIT.setAttributeValue("CORPUS", deductionOverMoney);
|
|
thisRent=thisRent.add(deductionOverMoney);
|
|
deductionOverMoney=zero;
|
|
corpuss[j]=new BigDecimal(corpuss[j]).subtract(deductionOverMoney).setScale(Scale.CORPUS_SCALE).toString();
|
|
}
|
|
}else if("利息".equals(paymentOrder[k])){
|
|
if(deductionOverMoney.compareTo(new BigDecimal(interests[j]))>=0){
|
|
boLRIT.setAttributeValue("INTEREST", new BigDecimal(interests[j]));
|
|
deductionOverMoney=deductionOverMoney.subtract(new BigDecimal(interests[j]));
|
|
thisRent=thisRent.add(new BigDecimal(interests[j]));
|
|
interests[j]="0.00";
|
|
}else{
|
|
boLRIT.setAttributeValue("INTEREST", deductionOverMoney);
|
|
thisRent=thisRent.add(deductionOverMoney);
|
|
deductionOverMoney=zero;
|
|
interests[j]=new BigDecimal(interests[j]).subtract(deductionOverMoney).setScale(Scale.INTEREST_SCALE).toString();
|
|
}
|
|
}else if("罚息".equals(paymentOrder[k])){
|
|
if(deductionOverMoney.compareTo(new BigDecimal(Penaltys[j]))>=0){
|
|
boLRIT.setAttributeValue("PENALTY", new BigDecimal(Penaltys[j]));
|
|
deductionOverMoney=deductionOverMoney.subtract(new BigDecimal(Penaltys[j]));
|
|
Penaltys[j]="0.00";
|
|
}else{
|
|
boLRIT.setAttributeValue("PENALTY", deductionOverMoney);
|
|
deductionOverMoney=zero;
|
|
Penaltys[j]=new BigDecimal(Penaltys[j]).subtract(deductionOverMoney).setScale(Scale.RENT_SCALE).toString();
|
|
}
|
|
}
|
|
}
|
|
boLRIT.setAttributeValue("RENT", thisRent);
|
|
}
|
|
}
|
|
boLRIT.setAttributeValue("CORPUS_ADJUST", 0);
|
|
boLRIT.setAttributeValue("PENALTY_ADJUST", 0);
|
|
boLRIT.setAttributeValue("ROLL_BACK", 0);
|
|
boLRIT.setAttributeValue("DEDUCTION_ID", deductionID);
|
|
boLRIT.setAttributeValue("COIN", boVLRP.getAttribute("COIN").getString());
|
|
boLRIT.setAttributeValue("IS_FLOWING", 0);
|
|
boLRIT.setAttributeValue("FLOWUNID", flowunid);
|
|
boLRI.saveObject(boLRIT);
|
|
}
|
|
}
|
|
if(overmoneys[i].compareTo(deductionOverMoney)>0){
|
|
List<BizObject> boLCFI = JBOFactory.createBizObjectQuery(LC_FUND_INCOME.CLASS_NAME, "PLAN_ID=:PLAN_ID and ROLL_BACK=0 ").setParameter("PLAN_ID", cIDs[i])
|
|
.getResultList(false);
|
|
List<BizObject> boLCFIT = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and IS_FLOWING = 0 and ROLL_BACK=0 ").setParameter("PLAN_ID", cIDs[i])
|
|
.getResultList(false);
|
|
int charge_listFund = boLCFI.size()+boLCFIT.size()+1;
|
|
BizObject boLFP = JBOFactory.createBizObjectQuery(LC_FUND_PLAN.CLASS_NAME, "id=:id").setParameter("id", cIDs[i]).getSingleResult(false);
|
|
BizObject boLFIT = boLFI.newObject();
|
|
boLFIT.setAttributeValue("ID", deductionID);
|
|
boLFIT.setAttributeValue("QUOT_ID", boLFP.getAttribute("QUOT_ID").getString());
|
|
boLFIT.setAttributeValue("CUST_ID", boLFP.getAttribute("CUST_ID").getString());
|
|
boLFIT.setAttributeValue("PROJECT_ID", boLFP.getAttribute("PROJECT_ID").getString());
|
|
boLFIT.setAttributeValue("PROJECT_PLAN_NUMBER", boLFP.getAttribute("PROJECT_PLAN_NUMBER").getString());
|
|
boLFIT.setAttributeValue("CONTRACT_ID", boLFP.getAttribute("CONTRACT_ID").getString());
|
|
boLFIT.setAttributeValue("CONTRACT_PLAN_NUMBER", boLFP.getAttribute("CONTRACT_PLAN_NUMBER").getString());
|
|
boLFIT.setAttributeValue("PAYMENT_NUMBER", boLFP.getAttribute("PAYMENT_NUMBER").getString());
|
|
boLFIT.setAttributeValue("PLAN_ID", boLFP.getAttribute("ID").getString());
|
|
boLFIT.setAttributeValue("PLAN_LIST", boLFP.getAttribute("PLAN_LIST").getString());
|
|
boLFIT.setAttributeValue("PAY_TYPE", boLFP.getAttribute("PAY_TYPE").getString());
|
|
boLFIT.setAttributeValue("FEE_TYPE", boLFP.getAttribute("FEE_TYPE").getString());
|
|
boLFIT.setAttributeValue("SETTLE_METHOD", "settlemethod7");
|
|
boLFIT.setAttributeValue("CHARGE_LIST", charge_listFund);
|
|
boLFIT.setAttributeValue("FACT_DATE", StringFunction.getToday());
|
|
boLFIT.setAttributeValue("ACCOUNTING_DATE", StringFunction.getToday());
|
|
boLFIT.setAttributeValue("FACT_MONEY", overmoneys[i].subtract(deductionOverMoney));
|
|
boLFIT.setAttributeValue("FEE_ADJUST", 0);
|
|
boLFIT.setAttributeValue("FACT_OBJECT", boLFP.getAttribute("PAY_OBJ").getString());
|
|
boLFIT.setAttributeValue("ROLL_BACK", 0);
|
|
boLFIT.setAttributeValue("FLOWUNID", flowunid);
|
|
boLFIT.setAttributeValue("IS_FLOWING", 0);
|
|
boLFIT.setAttributeValue("COIN", boLFP.getAttribute("COIN").getString());
|
|
boLFIT.setAttributeValue("MEMO", boLFP.getAttribute("FPNOTE").getString());
|
|
boLFI.saveObject(boLFIT);
|
|
}
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
return "ERROR";
|
|
}
|
|
return "SUCCESS";
|
|
}
|
|
|
|
public String updateEbankAndEbankProcess(JBOTransaction tx){
|
|
try{
|
|
BizObjectManager bomEb = JBOFactory.getBizObjectManager(LC_EBANK_TEMP.CLASS_NAME);
|
|
tx.join(bomEb);
|
|
BizObject boEb = bomEb.createQuery("FLOWUNID=:FLOWUNID")
|
|
.setParameter("FLOWUNID", flowunid).getSingleResult(true);
|
|
BigDecimal hadMoney = new BigDecimal(boEb.getAttribute("HAD_MONEY").getDouble())
|
|
.subtract(new BigDecimal(oldFactMoney)).add(new BigDecimal(newFactMoney));
|
|
BigDecimal factMoney = new BigDecimal(boEb.getAttribute("FACT_MONEY").getDouble());
|
|
boEb.setAttributeValue("HAD_MONEY", hadMoney);
|
|
boEb.setAttributeValue("MAYOPE_MONEY", factMoney.subtract(hadMoney));
|
|
BizObjectManager bomLEP = JBOFactory.getBizObjectManager(LC_EBANK_PROCESS.CLASS_NAME);
|
|
tx.join(bomLEP);
|
|
bomLEP.createQuery("update O set process_money=:allFactMoney where flowunid=:flowUnid")
|
|
.setParameter("allFactMoney", newFactMoney).setParameter("flowUnid", flowunid).executeUpdate();
|
|
bomEb.saveObject(boEb);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
return "ERROR";
|
|
}
|
|
return "SUCCESS";
|
|
}
|
|
|
|
public String updateRelativeFundIncome(JBOTransaction tx){
|
|
try{
|
|
if(ids != null){
|
|
BizObjectManager bomLFIT = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME);
|
|
tx.join(bomLFIT);
|
|
String[] incomeIds = ids.split("@");
|
|
for(int i=0;i<incomeIds.length;i++){
|
|
BizObject boLRIT = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME, "flowunid=:flowunid and id=:id")
|
|
.setParameter("flowunid", flowunid).setParameter("id", incomeIds[i]).getSingleResult(false);
|
|
BigDecimal useMoney = new BigDecimal(boLRIT.getAttribute("RENT").getString())
|
|
.add(new BigDecimal(boLRIT.getAttribute("PENALTY").getString()));
|
|
bomLFIT.createQuery("update O set fact_money=:useMoney where id=:id").setParameter("useMoney", useMoney.toString())
|
|
.setParameter("id", boLRIT.getAttribute("DEDUCTION_ID").getString())
|
|
.executeUpdate();
|
|
}
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
return "ERROR";
|
|
}
|
|
return "SUCCESS";
|
|
}
|
|
|
|
public String deleteRelativeFundIncome(JBOTransaction tx){
|
|
try{
|
|
BizObjectManager bomLFIT = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME);
|
|
tx.join(bomLFIT);
|
|
String[] deductionIDs = ids.split("@");
|
|
for(int i=0;i<deductionIDs.length;i++){
|
|
bomLFIT.createQuery("delete from O where id=:id and flowunid=:flowunid").setParameter("id", deductionIDs[i])
|
|
.setParameter("flowunid", flowunid)
|
|
.executeUpdate();
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
return "ERROR";
|
|
}
|
|
return "SUCCESS";
|
|
}
|
|
|
|
public String deleteRelativeRentIncome(JBOTransaction tx){
|
|
try{
|
|
BizObjectManager bomLFIT = JBOFactory.getBizObjectManager(LC_RENT_INCOME_TEMP.CLASS_NAME);
|
|
tx.join(bomLFIT);
|
|
String[] deductionIDs = ids.split("@");
|
|
for(int i=0;i<deductionIDs.length;i++){
|
|
bomLFIT.createQuery("delete from O where deduction_id=:id and flowunid=:flowunid").setParameter("id", deductionIDs[i])
|
|
.setParameter("flowunid", flowunid)
|
|
.executeUpdate();
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
return "ERROR";
|
|
}
|
|
return "SUCCESS";
|
|
}
|
|
|
|
/**
|
|
* 罚息减免
|
|
*/
|
|
public String setPenaltyDataToRentIncome(JBOTransaction tx) throws JBOException{
|
|
try{
|
|
String[] Penaltys = overPenaltys.split("@");
|
|
Boolean flag = false;
|
|
if("Y".equals(isChanged)){
|
|
flag = true;
|
|
}
|
|
String[] ids = planIDs.split("@");
|
|
for(int i=0;i<ids.length;i++){
|
|
BizObject boVLR = JBOFactory.createBizObjectQuery(LC_RENT_PLAN.CLASS_NAME, "ID=:ID").setParameter("ID", ids[i])
|
|
.getSingleResult(false);
|
|
BizObject boVLRP = JBOFactory.createBizObjectQuery(VI_LC_RENT_PLAN.CLASS_NAME, "ID=:ID").setParameter("ID", ids[i])
|
|
.getSingleResult(false);
|
|
|
|
BizObjectManager boLRI = JBOFactory.getBizObjectManager(LC_RENT_INCOME_TEMP.CLASS_NAME);
|
|
BizObjectManager bomLORL = JBOFactory.getBizObjectManager(LC_OCCUPY_RENT_LIST.CLASS_NAME,tx);
|
|
BizObject boLORL = bomLORL.newObject();
|
|
boLORL.setAttributeValue("ID", UUIDUtil.getUUID());
|
|
boLORL.setAttributeValue("PAYMENT_NUMBER", boVLRP.getAttribute("PAYMENT_NUMBER").getString());
|
|
boLORL.setAttributeValue("PLAN_LIST", boVLRP.getAttribute("PLAN_LIST").getString());
|
|
boLORL.setAttributeValue("FLOW_NAME", "罚息减免流程");
|
|
boLORL.setAttributeValue("FLOWUNID", flowunid);
|
|
bomLORL.saveObject(boLORL);
|
|
tx.join(boLRI);
|
|
BizObject boLRIT = boLRI.newObject();
|
|
boLRIT.setAttributeValue("QUOT_ID", boVLR.getAttribute("QUOT_ID").getString());
|
|
boLRIT.setAttributeValue("CUST_ID", boVLR.getAttribute("CUST_ID").getString());
|
|
boLRIT.setAttributeValue("PROJECT_ID", boVLR.getAttribute("PROJECT_ID").getString());
|
|
boLRIT.setAttributeValue("PROJECT_PLAN_NUMBER", boVLR.getAttribute("PROJECT_PLAN_NUMBER").getString());
|
|
boLRIT.setAttributeValue("CONTRACT_ID", boVLR.getAttribute("CONTRACT_ID").getString());
|
|
boLRIT.setAttributeValue("CONTRACT_PLAN_NUMBER", boVLR.getAttribute("CONTRACT_PLAN_NUMBER").getString());
|
|
boLRIT.setAttributeValue("PAYMENT_NUMBER", boVLR.getAttribute("PAYMENT_NUMBER").getString());
|
|
boLRIT.setAttributeValue("EBANK_NUMBER", "");
|
|
boLRIT.setAttributeValue("PLAN_ID", ids[i]);
|
|
boLRIT.setAttributeValue("PLAN_LIST", boVLR.getAttribute("PLAN_LIST").getString());
|
|
boLRIT.setAttributeValue("INTEREST_ADJUST", 0);
|
|
boLRIT.setAttributeValue("SETTLE_METHOD", "settlemethod12");
|
|
List<BizObject> boLCRI = JBOFactory.createBizObjectQuery(LC_RENT_INCOME.CLASS_NAME, "PLAN_ID=:PLAN_ID and ROLL_BACK='0'").setParameter("PLAN_ID", ids[i])
|
|
.getResultList(false);
|
|
List<BizObject> boLCRIT = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and IS_FLOWING = 0 and ROLL_BACK='0'").setParameter("PLAN_ID", ids[i])
|
|
.getResultList(false);
|
|
boLRIT.setAttributeValue("HIRE_LIST", boLCRI.size()+boLCRIT.size()+1);
|
|
boLRIT.setAttributeValue("HIRE_DATE", StringFunction.getToday());
|
|
boLRIT.setAttributeValue("ACCOUNTING_DATE", StringFunction.getToday());
|
|
boLRIT.setAttributeValue("RENT", 0);
|
|
boLRIT.setAttributeValue("CORPUS", 0);
|
|
boLRIT.setAttributeValue("INTEREST", 0);
|
|
boLRIT.setAttributeValue("INTEREST_ADJUST", 0);
|
|
boLRIT.setAttributeValue("PENALTY", 0);
|
|
boLRIT.setAttributeValue("CORPUS_ADJUST", 0);
|
|
boLRIT.setAttributeValue("PENALTY_ADJUST", flag?boVLRP.getAttribute("PENALTY_OVER").getString():Penaltys[i]);
|
|
boLRIT.setAttributeValue("ROLL_BACK", 0);
|
|
boLRIT.setAttributeValue("COIN", boVLR.getAttribute("COIN").getString());
|
|
boLRIT.setAttributeValue("IS_FLOWING", 0);
|
|
boLRIT.setAttributeValue("FLOWUNID", flowunid);
|
|
boLRI.saveObject(boLRIT);
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
return "ERROR";
|
|
}
|
|
return "SUCCESS";
|
|
}
|
|
|
|
public String createRentIncomeWithCard(JBOTransaction tx) throws Exception{
|
|
String sReturn = "SUCCESS";
|
|
Transaction tran = Transaction.createTransaction(tx);
|
|
Connection con = null;
|
|
try{
|
|
con = tran.getConnection(tran);
|
|
/* ResultSet rs = stat.executeQuery("select count(1) cou from lc_card_deduct_data where deduct_docid='"+deductDocId+"' and income_status='0'");
|
|
if(rs.next()){
|
|
String cou = rs.getString("cou");
|
|
if("0".equals(cou)){
|
|
return "false";
|
|
}
|
|
}*/
|
|
CallableStatement call = con.prepareCall("call proc_card_income('"+deductDocId+"','"+userid+"','"+orgid+"')");
|
|
call.execute();
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
if(con !=null){
|
|
con.rollback();
|
|
con.close();
|
|
con = null;
|
|
}
|
|
return "ERROR";
|
|
}finally{
|
|
if(con !=null){
|
|
con.commit();
|
|
con.close();
|
|
con = null;
|
|
}
|
|
}
|
|
return sReturn;
|
|
}
|
|
|
|
/*public String createRentIncomeWithCard(JBOTransaction tx) throws Exception{
|
|
String sReturn = "SUCCESS";
|
|
sql = sql.replaceAll("△", ",");
|
|
sql = sql.replaceAll("&", "=");
|
|
Connection con = null;
|
|
try{
|
|
List<BizObject> boVCDD = JBOFactory.getBizObjectManager(VI_CARD_DEDUCT_DATA.CLASS_NAME).createQuery(sql).getResultList(false);
|
|
int count = 0;//循环次数
|
|
int n = 0;//匹配失败次数
|
|
long start = System.currentTimeMillis();
|
|
WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
|
|
ComboPooledDataSource datasource = wac.getBean("dataSourceJDBC",ComboPooledDataSource.class);
|
|
BigDecimal money = new BigDecimal(0);
|
|
con = datasource.getConnection();
|
|
con.setAutoCommit(false);
|
|
String executeSql = "insert into lc_rent_income_temp (id,"
|
|
+ "quot_id,"
|
|
+ "cust_id,"
|
|
+ "project_id,"
|
|
+ "project_plan_number,"
|
|
+ "contract_id,"
|
|
+ "contract_plan_number,"
|
|
+ "payment_number,"
|
|
+ "plan_id,"
|
|
+ "plan_list,"
|
|
+ "hire_list,"
|
|
+ "hire_date,"
|
|
+ "rent,"
|
|
+ "corpus,"
|
|
+ "interest,"
|
|
+ "penalty,"
|
|
+ "corpus_adjust,"
|
|
+ "interest_adjust,"
|
|
+ "penalty_adjust,"
|
|
+ "settle_method,"
|
|
+ "carddeduct_id,"
|
|
+ "carddeduct_status,"
|
|
+ "hire_object,"
|
|
+ "hire_bank,"
|
|
+ "hire_account,"
|
|
+ "hire_number,"
|
|
+ "own_bank,"
|
|
+ "own_account,"
|
|
+ "own_number,"
|
|
+ "roll_back,"
|
|
+ "flowunid,"
|
|
+ "inputuserid,"
|
|
+ "inputorgid,"
|
|
+ "inputtime,"
|
|
+ "is_flowing) "
|
|
+ "SELECT replace(uuid(),'-',''),"
|
|
+ "lrp.quot_id,"
|
|
+ "lrp.cust_id,"
|
|
+ "lrp.project_id,"
|
|
+ "lrp.project_plan_number,"
|
|
+ "lrp.contract_id,"
|
|
+ "lrp.contract_plan_number,"
|
|
+ "lrp.payment_number,"
|
|
+ "lrp.id,"
|
|
+ "lrp.plan_list,"
|
|
+ "ifnull(li.hire_list,0)+1+?,"
|
|
+ "?,"
|
|
+ "CASE WHEN '租金'=? THEN vlrp.rent_over ELSE 0 END,"
|
|
+ "CASE WHEN '租金'=? THEN vlrp.corpus_over ELSE 0 END,"
|
|
+ "CASE WHEN '租金'=? THEN vlrp.interest_over ELSE 0 END,"
|
|
+ "CASE WHEN '租金'=? THEN 0 ELSE vlrp.penalty_over END,"
|
|
+ "0,"
|
|
+ "0,"
|
|
+ "0,"
|
|
+ "'settlemethod6',"
|
|
+ "?,"
|
|
+ "'have_income',"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "'0',"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "'0' FROM lc_rent_plan AS lrp LEFT JOIN(SELECT lr.payment_number,lr.plan_list,COUNT(lr.plan_list)AS hire_list FROM (SELECT lri.payment_number,lri.plan_list,COUNT(lri.plan_list)AS hire_list FROM lc_rent_income AS lri WHERE lri.ROLL_BACK='0' and lri.payment_number=? and lri.plan_list=? GROUP BY lri.payment_number,lri.plan_list UNION SELECT lrit.payment_number,lrit.plan_list,COUNT(lrit.plan_list)AS hire_list FROM lc_rent_income_temp AS lrit WHERE lrit.roll_back='0' AND lrit.is_flowing='0' and lrit.payment_number=? and lrit.plan_list=? GROUP BY lrit.payment_number,lrit.plan_list)AS lr GROUP BY lr.payment_number,lr.plan_list) AS li ON li.payment_number=lrp.PAYMENT_NUMBER AND li.plan_list=lrp.PLAN_LIST LEFT JOIN vi_lc_rent_plan AS vlrp ON vlrp.payment_number=lrp.PAYMENT_NUMBER AND vlrp.plan_list=lrp.plan_list where lrp.plan_list=? and lrp.PAYMENT_NUMBER=?";
|
|
if("ORACLE".equals(InitDBType.DBTYPE)){
|
|
executeSql = "insert into lc_rent_income_temp (id,"
|
|
+ "quot_id,"
|
|
+ "cust_id,"
|
|
+ "project_id,"
|
|
+ "project_plan_number,"
|
|
+ "contract_id,"
|
|
+ "contract_plan_number,"
|
|
+ "payment_number,"
|
|
+ "plan_id,"
|
|
+ "plan_list,"
|
|
+ "hire_list,"
|
|
+ "hire_date,"
|
|
+ "rent,"
|
|
+ "corpus,"
|
|
+ "interest,"
|
|
+ "penalty,"
|
|
+ "corpus_adjust,"
|
|
+ "interest_adjust,"
|
|
+ "penalty_adjust,"
|
|
+ "settle_method,"
|
|
+ "carddeduct_id,"
|
|
+ "carddeduct_status,"
|
|
+ "hire_object,"
|
|
+ "hire_bank,"
|
|
+ "hire_account,"
|
|
+ "hire_number,"
|
|
+ "own_bank,"
|
|
+ "own_account,"
|
|
+ "own_number,"
|
|
+ "roll_back,"
|
|
+ "flowunid,"
|
|
+ "inputuserid,"
|
|
+ "inputorgid,"
|
|
+ "inputtime,"
|
|
+ "is_flowing) "
|
|
+ "SELECT sys_guid(),"
|
|
+ "lrp.quot_id,"
|
|
+ "lrp.cust_id,"
|
|
+ "lrp.project_id,"
|
|
+ "lrp.project_plan_number,"
|
|
+ "lrp.contract_id,"
|
|
+ "lrp.contract_plan_number,"
|
|
+ "lrp.payment_number,"
|
|
+ "lrp.id,"
|
|
+ "lrp.plan_list,"
|
|
+ "nvl(li.hire_list,0)+1+?,"
|
|
+ "?,"
|
|
+ "CASE WHEN '租金'=? THEN vlrp.rent_over ELSE 0 END,"
|
|
+ "CASE WHEN '租金'=? THEN vlrp.corpus_over ELSE 0 END,"
|
|
+ "CASE WHEN '租金'=? THEN vlrp.interest_over ELSE 0 END,"
|
|
+ "CASE WHEN '租金'=? THEN 0 ELSE vlrp.penalty_over END,"
|
|
+ "0,"
|
|
+ "0,"
|
|
+ "0,"
|
|
+ "'settlemethod6',"
|
|
+ "?,"
|
|
+ "'have_income',"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "'0',"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "?,"
|
|
+ "'0' FROM lc_rent_plan lrp LEFT JOIN(SELECT lr.payment_number,lr.plan_list,COUNT(lr.plan_list)AS hire_list FROM (SELECT lri.payment_number,lri.plan_list,COUNT(lri.plan_list)AS hire_list FROM lc_rent_income lri WHERE lri.ROLL_BACK='0' and lri.payment_number=? and lri.plan_list=? GROUP BY lri.payment_number,lri.plan_list UNION SELECT lrit.payment_number,lrit.plan_list,COUNT(lrit.plan_list)AS hire_list FROM lc_rent_income_temp lrit WHERE lrit.roll_back='0' AND lrit.is_flowing='0' and lrit.payment_number=? and lrit.plan_list=? GROUP BY lrit.payment_number,lrit.plan_list) lr GROUP BY lr.payment_number,lr.plan_list) li ON li.payment_number=lrp.PAYMENT_NUMBER AND li.plan_list=lrp.PLAN_LIST LEFT JOIN vi_lc_rent_plan vlrp ON vlrp.payment_number=lrp.PAYMENT_NUMBER AND vlrp.plan_list=lrp.plan_list where lrp.plan_list=? and lrp.PAYMENT_NUMBER=?";
|
|
}
|
|
String failedSql = "insert into lc_card_deduct_matchfail_temp(id,deduct_docid,carddeduct_id,inputuserid,inputorgid,inputtime,flowunid) values(replace(uuid(),'-',''),?,?,?,?,?,?)";
|
|
if("ORACLE".equals(InitDBType.DBTYPE)){
|
|
failedSql = "insert into lc_card_deduct_matchfail_temp(id,deduct_docid,carddeduct_id,inputuserid,inputorgid,inputtime,flowunid) values(sys_guid(),?,?,?,?,?,?)";
|
|
}
|
|
PreparedStatement executeStat = con.prepareStatement(executeSql);
|
|
PreparedStatement executeFailedStat = con.prepareStatement(failedSql);
|
|
String planList = "";
|
|
String paymentNumber = "";
|
|
for(BizObject b:boVCDD){
|
|
if(!b.getAttribute("actual_debit_amt").getString().equals(b.getAttribute("over_money").getString())){
|
|
n++;
|
|
executeFailedStat.setString(1, b.getAttribute("deduct_docid").getString());
|
|
executeFailedStat.setString(2, b.getAttribute("carddeduct_id").getString());
|
|
executeFailedStat.setString(3, userid);
|
|
executeFailedStat.setString(4, orgid);
|
|
executeFailedStat.setString(5, StringFunction.getToday());
|
|
executeFailedStat.setString(6, flowunid);
|
|
executeFailedStat.addBatch();
|
|
continue;
|
|
}
|
|
count++;
|
|
if(planList.equals(b.getAttribute("plan_list").getString()) && paymentNumber.equals(b.getAttribute("payment_number").getString())){
|
|
executeStat.setInt(1, 0);
|
|
}else{
|
|
executeStat.setInt(1, 0);
|
|
}
|
|
executeStat.setString(2, b.getAttribute("enddate").getString());
|
|
executeStat.setString(3, b.getAttribute("fee_type").getString());
|
|
executeStat.setString(4, b.getAttribute("fee_type").getString());
|
|
executeStat.setString(5, b.getAttribute("fee_type").getString());
|
|
executeStat.setString(6, b.getAttribute("fee_type").getString());
|
|
executeStat.setString(7, b.getAttribute("carddeduct_id").getString());
|
|
executeStat.setString(8, b.getAttribute("client_account").getString());
|
|
executeStat.setString(9, b.getAttribute("client_bank").getString());
|
|
executeStat.setString(10, b.getAttribute("client_account").getString());
|
|
executeStat.setString(11, b.getAttribute("client_acc_number").getString());
|
|
executeStat.setString(12, b.getAttribute("lease_acc_bank").getString());
|
|
executeStat.setString(13, b.getAttribute("own_account").getString());
|
|
executeStat.setString(14, b.getAttribute("ownacc_number").getString());
|
|
executeStat.setString(15, flowunid);
|
|
executeStat.setString(16, userid);
|
|
executeStat.setString(17, orgid);
|
|
executeStat.setString(18, StringFunction.getToday());
|
|
executeStat.setString(19, b.getAttribute("payment_number").getString());
|
|
executeStat.setString(20, b.getAttribute("plan_list").getString());
|
|
executeStat.setString(21, b.getAttribute("payment_number").getString());
|
|
executeStat.setString(22, b.getAttribute("plan_list").getString());
|
|
executeStat.setString(23, b.getAttribute("plan_list").getString());
|
|
executeStat.setString(24, b.getAttribute("payment_number").getString());
|
|
planList = b.getAttribute("plan_list").getString();
|
|
paymentNumber = b.getAttribute("payment_number").getString();
|
|
money = money.add(new BigDecimal(b.getAttribute("actual_debit_amt").getString()));
|
|
executeStat.addBatch();
|
|
if(count == 1000){
|
|
executeStat.executeBatch();
|
|
executeStat.clearBatch();
|
|
count = 0;
|
|
}
|
|
}
|
|
executeFailedStat.executeBatch();
|
|
executeStat.executeBatch();
|
|
BizObjectManager bomLCDD = JBOFactory.getBizObjectManager(LC_CARD_DEDUCT_DOC_TEMP.CLASS_NAME);
|
|
tx.join(bomLCDD);
|
|
bomLCDD.createQuery("update O set allmayope_money=allfact_money-(allhad_money+"+money+"),allhad_money=allhad_money+"+money+" where flowunid='"+flowunid+"'").executeUpdate();
|
|
con.commit();
|
|
if(n > 0){
|
|
sReturn = "PORTION@"+n;
|
|
}
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
con.rollback();
|
|
tx.rollback();
|
|
return "ERROR";
|
|
}
|
|
return sReturn;
|
|
}*/
|
|
}
|