历史客户信息查询优化

This commit is contained in:
zzk 2023-09-21 15:24:31 +08:00
parent 2be464f3b6
commit 04e7e91ef8

View File

@ -85,7 +85,7 @@ public class InsertCustomerHistoryInfo {
String czr_yqrent_over = "0";
if(!"".equals(czr_proj_id)){
//获取客户为主承租人订单总数
String gm_nu = "select count(lul.id) as num from lb_union_lessee lul where CONTRACT_ID in ("+czr_proj_id+")";
String gm_nu = "select count(lci.id) as num from lb_contract_info lci where lci.id in ("+czr_proj_id+") and lci.CONTRACT_STATUS <> '104' and lci.CONTRACT_STATUS <> '101'";
List<Map<String, String>> gm_number = con.executeQuery(gm_nu);
if(gm_number.size()>0){
gmnum = gm_number.get(0).get("num");
@ -103,13 +103,13 @@ public class InsertCustomerHistoryInfo {
jq_number = jq_num.get(0).get("num");
}
//获取客户为主承租未结清合同数
String wjq_contract_num = "select count(lci.ID) as num from lb_contract_info lci where lci.ID in ("+czr_proj_id+") and lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS <= 100";
String wjq_contract_num = "select count(lci.ID) as num from lb_contract_info lci where lci.ID in ("+czr_proj_id+") and lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS < 100";
List<Map<String, String>> wjq_num = con.executeQuery(wjq_contract_num);
if(wjq_num.size()>0){
wjq_number = wjq_num.get(0).get("num");
}
//获取客户为主承租车辆总和
String car_num = "select count(lec.ID) as num from lb_union_lessee lul left join lb_equipment_car lec on lec.CONTRACT_ID = lul.CONTRACT_ID where lul.CONTRACT_ID in ("+czr_proj_id+") and lec.car_attribute = 'head'";
String car_num = "select count(lec.ID) as num from lb_contract_info lci left join lb_equipment_car lec on lec.CONTRACT_ID = lci.id where lci.id in ("+czr_proj_id+") and lec.car_attribute = 'head'";
List<Map<String, String>> car_number = con.executeQuery(car_num);
if(car_number.size()>0){
carnumber = car_number.get(0).get("num");
@ -121,30 +121,29 @@ public class InsertCustomerHistoryInfo {
carjqnumber = car_jq_number.get(0).get("num");
}
//获取客户为主承租未结清车辆总和
String car_wjq_num = "select count(lec.ID) as num from lb_contract_info lci left join lb_equipment_car lec on lec.CONTRACT_ID = lci.ID where lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS <= 100 and lec.car_attribute = 'head' and lci.ID in ("+czr_proj_id+")";
String car_wjq_num = "select count(lec.ID) as num from lb_contract_info lci left join lb_equipment_car lec on lec.CONTRACT_ID = lci.ID where lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS < 100 and lec.car_attribute = 'head' and lci.ID in ("+czr_proj_id+")";
List<Map<String, String>> car_wjq_number = con.executeQuery(car_wjq_num);
if(car_wjq_number.size()>0){
carwjqnumber = car_wjq_number.get(0).get("num");
}
//获取客户为主承租剩余租金,逾期租金
//总实收
String ssmoney_num = "select sum(nvl(lri.corpus, 0)) as corpus from lc_rent_income lri where lri.CONTRACT_ID in ("+czr_proj_id+")";
String ssmoney_num = "select replace(format(sum(nvl(lri.corpus,0)),2),',','') as corpus from lc_rent_income lri where lri.CONTRACT_ID in ("+czr_proj_id+")";
List<Map<String, String>> ssmoney_number = con.executeQuery(ssmoney_num);
BigDecimal ssmoney = new BigDecimal(0);
if(ssmoney_number.get(0).get("corpus")==null || "".equals(ssmoney_number.get(0).get("corpus"))){
if(ssmoney_number.get(0).get("corpus")!=null || !"".equals(ssmoney_number.get(0).get("corpus"))){
ssmoney = new BigDecimal(ssmoney_number.get(0).get("corpus"));
}
//剩余本金
czr_rent_over = new BigDecimal(CLEAN_LEASE_MONEY.replace(",","")).subtract(ssmoney);
String yqmoney_num = "select sum(lrp.rent - t.RENT) as yqrent_over from \n" +
String yqmoney_num = "select format(sum(lrp.rent-nvl(t.RENT,0)),2) as yqrent_over from \n" +
"lc_rent_plan lrp\n" +
"left join (select CONTRACT_ID,lri.PLAN_LIST,sum(RENT) as RENT from lc_rent_income lri where lri.CONTRACT_ID in ("+czr_proj_id+") group by lri.CONTRACT_ID,lri.PLAN_LIST) t \n" +
" on t.CONTRACT_ID = lrp.CONTRACT_ID and t.PLAN_LIST = lrp.PLAN_LIST \n" +
"where STR_TO_DATE(lrp.plan_date,'%Y/%m/%d') < now()\n" +
"\tand lrp.contract_id in ("+czr_proj_id+")";
List<Map<String, String>> yqmoney_number = con.executeQuery(yqmoney_num);
czr_yqrent_over = "";
if(yqmoney_number.size()>0){
czr_yqrent_over = yqmoney_number.get(0).get("yqrent_over");
}else {
@ -177,7 +176,7 @@ public class InsertCustomerHistoryInfo {
String gt_yqrent_over = "0";
if(!"".equals(gt_proj_id)){
//获取客户为共同承租人订单总数
String gt_gm_nu = "select count(lci.ID) as num from lb_contract_info lci where lci.ID in ("+gt_proj_id+")";
String gt_gm_nu = "select count(lci.ID) as num from lb_contract_info lci where lci.ID in ("+gt_proj_id+") and lci.CONTRACT_STATUS <> '104' and lci.CONTRACT_STATUS <> '101'";
List<Map<String, String>> gt_gm_number = con.executeQuery(gt_gm_nu);
if(gt_gm_number.size()>0){
gtgmnumber = gt_gm_number.get(0).get("num");
@ -195,7 +194,7 @@ public class InsertCustomerHistoryInfo {
gt_jq_number = gt_jq_num.get(0).get("num");
}
//获取客户为共同承租人未结清单数
String gt_wjq_contract_num = "select count(lci.ID) as num from lb_contract_info lci where lci.ID in ("+gt_proj_id+") and lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS <= 100";
String gt_wjq_contract_num = "select count(lci.ID) as num from lb_contract_info lci where lci.ID in ("+gt_proj_id+") and lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS < 100";
List<Map<String, String>> gt_wjq_num = con.executeQuery(gt_wjq_contract_num);
if(gt_wjq_num.size()>0){
gt_wjq_number = gt_wjq_num.get(0).get("num");
@ -213,31 +212,30 @@ public class InsertCustomerHistoryInfo {
gtcarjqnumber = gt_car_jq_number.get(0).get("num");
}
//获取客户为共同承租人未结清车辆总和
String gt_car_wjq_num = "select count(lec.ID) as num from lb_contract_info lci left join lb_equipment_car lec on lec.CONTRACT_ID = lci.ID where lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS <= 100 and lec.car_attribute = 'head' and lci.ID in ("+gt_proj_id+")";
String gt_car_wjq_num = "select count(lec.ID) as num from lb_contract_info lci left join lb_equipment_car lec on lec.CONTRACT_ID = lci.ID where lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS < 100 and lec.car_attribute = 'head' and lci.ID in ("+gt_proj_id+")";
List<Map<String, String>> gt_car_wjq_number = con.executeQuery(gt_car_wjq_num);
if(gt_car_wjq_number.size()>0){
gtcarwjqnumber = gt_car_wjq_number.get(0).get("num");
}
//获取客户为共同承租人剩余租金,罚息
//总实收
String ssgt_money_num = "select sum(nvl(lri.corpus, 0)) as corpus from lc_rent_income lri where lri.CONTRACT_ID in ("+gt_proj_id+")";
String ssgt_money_num = "select replace(format(sum(nvl(lri.corpus,0)),2),',','') as corpus from lc_rent_income lri where lri.CONTRACT_ID in ("+gt_proj_id+")";
List<Map<String, String>> ssgt_money_number = con.executeQuery(ssgt_money_num);
BigDecimal ssgt_money = new BigDecimal(0);
if(ssgt_money_number.get(0).get("corpus")==null||"".equals(ssgt_money_number.get(0).get("corpus"))){
if(ssgt_money_number.get(0).get("corpus")!=null||!"".equals(ssgt_money_number.get(0).get("corpus"))){
ssgt_money = new BigDecimal(ssgt_money_number.get(0).get("corpus"));
}
//总剩余本金
gt_rent_over = new BigDecimal(GT_CLEAN_LEASE_MONEY.replace(",","")).subtract(ssgt_money);
String gt_yqmoney_num = "select sum(lrp.rent - t.RENT) as yqrent_over from \n" +
String gt_yqmoney_num = "select format(sum(lrp.rent-nvl(t.RENT,0)),2) as yqrent_over from \n" +
"lc_rent_plan lrp\n" +
"left join (select CONTRACT_ID,lri.PLAN_LIST,sum(RENT) as RENT from lc_rent_income lri where lri.CONTRACT_ID in ("+gt_proj_id+") group by lri.CONTRACT_ID,lri.PLAN_LIST) t \n" +
" on t.CONTRACT_ID = lrp.CONTRACT_ID and t.PLAN_LIST = lrp.PLAN_LIST \n" +
"where STR_TO_DATE(lrp.plan_date,'%Y/%m/%d') < now()\n" +
"\tand lrp.contract_id in ("+gt_proj_id+")";
List<Map<String, String>> gt_yqmoney_number = con.executeQuery(gt_yqmoney_num);
gt_yqrent_over = "";
if(gt_yqmoney_number.size()>0){
gt_yqrent_over = gt_yqmoney_number.get(0).get("yqrent_over");
}else {
@ -247,7 +245,6 @@ public class InsertCustomerHistoryInfo {
}
//获取担保人合同ID
String dbprojid = "select lci.id from lb_guarantee_unit lgu left join lb_contract_info lci on lci.ID = lgu.CONTRACT_ID where lgu.certid = '"+certid+"' and lci.CONTRACT_STATUS <> '101' and lci.CONTRACT_STATUS <> '104'";
List<Map<String, String>> dbproj_id = con.executeQuery(dbprojid);
@ -289,7 +286,7 @@ public class InsertCustomerHistoryInfo {
db_jq_number = db_jq_num.get(0).get("num");
}
//获取客户为担保人未结清单数
String db_wjq_contract_num = "select count(lci.ID) as num from lb_contract_info lci where lci.ID in ("+db_proj_id+") and lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS <= 100";
String db_wjq_contract_num = "select count(lci.ID) as num from lb_contract_info lci where lci.ID in ("+db_proj_id+") and lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS < 100";
List<Map<String, String>> db_wjq_num = con.executeQuery(db_wjq_contract_num);
if(db_wjq_num.size()>0){
db_wjq_number = db_wjq_num.get(0).get("num");
@ -307,30 +304,29 @@ public class InsertCustomerHistoryInfo {
dbcarjqnumber = db_car_jq_number.get(0).get("num");
}
//获取客户为担保人未结清车辆总和
String db_car_wjq_num = "select count(lec.ID) as num from lb_contract_info lci left join lb_equipment_car lec on lec.CONTRACT_ID = lci.ID where lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS <= 100 and lec.car_attribute = 'head' and lci.ID in ("+db_proj_id+")";
String db_car_wjq_num = "select count(lec.ID) as num from lb_contract_info lci left join lb_equipment_car lec on lec.CONTRACT_ID = lci.ID where lci.CONTRACT_STATUS >=31 and lci.CONTRACT_STATUS < 100 and lec.car_attribute = 'head' and lci.ID in ("+db_proj_id+")";
List<Map<String, String>> db_car_wjq_number = con.executeQuery(db_car_wjq_num);
if(db_car_wjq_number.size()>0){
dbcarwjqnumber = db_car_wjq_number.get(0).get("num");
}
//获取客户为担保人剩余租金,罚息
//总实收
String ssdb_money_num = "select sum(nvl(lri.corpus, 0)) as corpus from lc_rent_income lri where lri.CONTRACT_ID in ("+db_proj_id+")";
String ssdb_money_num = "select replace(format(sum(nvl(lri.corpus,0)),2),',','') as corpus from lc_rent_income lri where lri.CONTRACT_ID in ("+db_proj_id+")";
List<Map<String, String>> ssdb_money_number = con.executeQuery(ssdb_money_num);
BigDecimal ssdb_money = new BigDecimal(0);
if(ssdb_money_number.get(0).get("corpus") != null || "".equals(ssdb_money_number.get(0).get("corpus"))){
if(ssdb_money_number.get(0).get("corpus") != null || !"".equals(ssdb_money_number.get(0).get("corpus"))){
ssdb_money = new BigDecimal(ssdb_money_number.get(0).get("corpus"));
}
//总剩余本金
db_rent_over = new BigDecimal(DB_CLEAN_LEASE_MONEY.replace(",","")).subtract(ssdb_money);
String db_yqmoney_num = "select sum(lrp.rent - t.RENT) as yqrent_over from \n" +
String db_yqmoney_num = "select format(sum(lrp.rent-nvl(t.RENT,0)),2) as yqrent_over from \n" +
"lc_rent_plan lrp\n" +
"left join (select CONTRACT_ID,lri.PLAN_LIST,sum(RENT) as RENT from lc_rent_income lri where lri.CONTRACT_ID in ("+db_proj_id+") group by lri.CONTRACT_ID,lri.PLAN_LIST) t \n" +
" on t.CONTRACT_ID = lrp.CONTRACT_ID and t.PLAN_LIST = lrp.PLAN_LIST \n" +
"where STR_TO_DATE(lrp.plan_date,'%Y/%m/%d') < now()\n" +
"\tand lrp.contract_id in ("+db_proj_id+")";
List<Map<String, String>> db_yqmoney_number = con.executeQuery(db_yqmoney_num);
db_yqrent_over = "";
if(db_yqmoney_number.size()>0){
db_yqrent_over = db_yqmoney_number.get(0).get("yqrent_over");
}else {