package com.ample.esb.service.impl; 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.awe.util.Transaction; import com.amarsoft.dict.als.manage.CodeManager; import com.ample.esb.bean.amp.*; import com.ample.esb.bean.esb.MessageAppHead; import com.ample.esb.bean.esb.MessageBody; import com.ample.esb.bean.esb.MessageEsbHead; import com.ample.esb.common.EsbCommon; import com.ample.esb.common.ParamDataUtils; import com.ample.esb.service.AmpService; import com.ample.esb.util.DateUtils; import com.ample.esb.util.XstreamUtil; import com.tenwa.lease.flow.project.businessapply.LBBusinessPrimary; import jbo.app.tenwa.calc.*; import jbo.app.tenwa.customer.*; import jbo.com.tenwa.entity.comm.flow.CUSTOMER_HISTORY_INFO_TEMP; import jbo.com.tenwa.lease.comm.*; import jbo.oti.RC_ADDRESS_INFO; import jbo.oti.RC_SCORE_RESULT; import jbo.prd.PRD_SPECIFIC_LIBRARY; import jbo.sys.FLOW_TASK; import java.math.BigDecimal; import java.sql.SQLException; import java.util.*; public class AmpServiceImpl extends EsbCommon implements AmpService { private String flowUnid; private String operatorId; private String tranNo; public AmpServiceImpl(Map map){ setFlowUnid(map.get("flowUnid")); setOperatorId(map.get("operatorId")); setTranNo(map.get("tranNo")); } public void resetFraudTakenCode(){ BizObjectManager bom = null; BizObject boRsr = null; try { bom = JBOFactory.getBizObjectManager(RC_SCORE_RESULT.CLASS_NAME); boRsr = bom.createQuery("flow_no=:flow_no").setParameter("flow_no",flowUnid).getSingleResult(true); if(boRsr==null){ return; } boRsr.setAttributeValue("fraud_taken_code",""); boRsr.setAttributeValue("update_time", DateUtils.dateTimeNowCore()); bom.saveObject(boRsr); } catch (JBOException e) { e.printStackTrace(); } } @Override public MessageEsbHead esbHead() { MessageEsbHead head = new MessageEsbHead(); head = super.getCommonEsbHead(head); head.setTargetSystemId("AMP"); head.setServiceId("SCN0003"); head.setServiceVersion("1.0.0"); head.setScenesId("018"); head.setScenesVersion("1.0"); head.setTranCode("AMP005"); head.setCommType("10"); head.setChannelId("09"); head.setFileFlag("0"); return head; } @Override public MessageAppHead appHead() { MessageAppHead head = new MessageAppHead(); head = super.getCommonAppHead(head); head.setOperatorId(operatorId); return head; } @Override public MessageBody messgeBody() { MessageBody body = new MessageBody(); body = super.getCommonBody(body); body.setAmpRequest(getRequestBody()); return body; } public AmpRequest getRequestBody() { String requestInfo = XstreamUtil.xmlConvertNotTitle(getApplicationTitle()); requestInfo = "" + requestInfo + "]]>"; AmpRequest ampRequest = new AmpRequest(); ampRequest.setApplication(requestInfo); return ampRequest; } @Override public ApplicationTitle getApplicationTitle() { ApplicationTitle app = new ApplicationTitle(); try{ this.init(); Applicant2 app2 = new Applicant2(); app2.setDealerInfo(getDealerInfo()); app2.setLoanInfo(getLoanInfo()); app2.setVehicleInfo(getVehicleInfo()); app2.setCustomerInfo(getCustomerInfo()); app2.setCoborrowers(getCoborrowers()); app2.setGuarantorInfo(getGuarantorInfo()); app2.setContInfo(getContInfo()); app2.setApplicationInfo(getApplicationInfo()); app2.setPreviouslyVehicle(getPreviouslyVehicle()); app.setApplicant2(app2); }catch (Exception e){ e.printStackTrace(); } return app; } //公共参数 //订单临时表 private BizObject boLpit; //个人临时表 private BizObject boCpt; //测算临时表 private BizObject boLcct; //订单临时表集合 private List boLects; private List boLguts; private BizObjectManager bomLpi; private BizObject boCft; //经销商正式表 private BizObject boDi; /** * 往bean里面填值 * @throws JBOException */ public void init() throws JBOException { boLpit = JBOFactory.createBizObjectQuery(LB_PROJECT_INFO_TEMP.CLASS_NAME,"FLOWUNID=:FLOWUNID").setParameter("FLOWUNID",flowUnid).getSingleResult(false); /*if(boLpit==null||boLpit.getAttribute("ID")==null||"".equals(boLpit.getAttribute("ID").toString())){ return; }*/ boCpt = JBOFactory.createBizObjectQuery(CUSTOMER_PERSON_TEMP.CLASS_NAME,"FLOWUNID=:flowunid").setParameter("flowunid",flowUnid).getSingleResult(false); boLects = JBOFactory.createBizObjectQuery(LB_EQUIPMENT_CAR_TEMP.CLASS_NAME,"FLOWUNID=:FLOWUNID").setParameter("FLOWUNID",flowUnid).getResultList(false); boLcct = JBOFactory.createBizObjectQuery(LC_CALC_CONDITION_TEMP.CLASS_NAME,"FLOWUNID=:flowunid").setParameter("flowunid",flowUnid).getSingleResult(false); bomLpi = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME); String distributorNo = boLpit.getAttribute("distributor_id").toString(); boDi = JBOFactory.createBizObjectQuery(DISTRIBUTOR_INFO.CLASS_NAME,"DISTRIBUTOR_NO=:distributorNo").setParameter("distributorNo",distributorNo).getSingleResult(false); boCft = JBOFactory.createBizObjectQuery(CUSTOMER_FAMILY_TEMP.CLASS_NAME,"FLOWUNID=:flowunid and Partner_='Y'").setParameter("flowunid",flowUnid).getSingleResult(false); boLguts = JBOFactory.createBizObjectQuery(LB_GUARANTEE_UNIT_TEMP.CLASS_NAME,"FLOWUNID=:flowunid ").setParameter("flowunid",flowUnid).getResultList(false); } public DealerInfo getDealerInfo() throws JBOException { if(boDi==null||boDi.getAttribute("ID")==null||"".equals(boDi.getAttribute("ID").toString())){ return null; } String distributorNo = boLpit.getAttribute("distributor_id").toString(); DealerInfo di = new DealerInfo(); //经销商名称 di.setDealerName(boDi.getAttribute("DISTRIBUTOR_NAME").toString()); //经销商编号 di.setDealerId(distributorNo); di.setDealerMode(""); String addressCode = boDi.getAttribute("DISTRIBUTOR_ADDRESS").getString(); String dealerProvince = ParamDataUtils.queryMapBcProvinceCode("AreaCode",addressCode); String dealerCity = ParamDataUtils.queryMapBcCityCode("AreaCode",addressCode); di.setDealerProvince_gb(dealerProvince); di.setDealerCity_gb(dealerCity); di.setDealerDistrict_gb(""); di.setDealerStreet_gb(""); di.setSubDealerName(""); di.setDealerGuaranteeRatio(""); di.setDealerFiledVisitFlag(""); di.setSubDealerAppFlag(""); di.setDealerArea(""); di.setSubDealerCode(""); di.setDealerTotalUsedAmount(""); di.setDealerAvailableAmount(""); int monthApproveCount = bomLpi.createQuery("select 1 from o left join jbo.com.tenwa.lease.comm.LB_EQUIPMENT_CAR lec on lec.project_id=o.id where o.distributor_id=:distributor_id and o.project_status='13' and left(o.INPUTTIME,7)=:curMonth").setParameter("distributor_id",distributorNo).setParameter("curMonth", DateUtils.monthNowCore()).getTotalCount(); int monthFailCount = bomLpi.createQuery("select 1 from o left join jbo.com.tenwa.lease.comm.LB_EQUIPMENT_CAR lec on lec.project_id=o.id where o.distributor_id=:distributor_id and o.PROJECT_STATUS<>'13' and left(o.INPUTTIME,7)=:curMonth").setParameter("distributor_id",distributorNo).setParameter("curMonth",DateUtils.monthNowCore()).getTotalCount(); di.setApprovalCountThisMonth(monthApproveCount); di.setRefuseCountThisMonth(monthFailCount); BizObjectManager bomLfi = JBOFactory.getBizObjectManager(LC_FUND_INCOME.CLASS_NAME); int monthLoanCount = bomLfi.createQuery("select 1 from o left join jbo.com.tenwa.lease.comm.LB_EQUIPMENT_CAR lec on lec.project_id=o.project_id left join jbo.com.tenwa.lease.comm.LB_PROJECT_INFO lpi on lpi.id=o.project_id where o.pay_type = 'pay_type_out' and o.PAY_STATUS='have_paid' and o.FEE_TYPE='feetype10' and o.SETTLE_METHOD='settlemethod6' and left(o.fact_date,7)=:curMonth and lpi.distributor_id=:distributor_id").setParameter("distributor_id",distributorNo).setParameter("curMonth",DateUtils.monthNowCore()).getTotalCount(); di.setLoanCountThisMonth(monthLoanCount); int yearApproveCount = bomLpi.createQuery("select 1 from o left join jbo.com.tenwa.lease.comm.LB_EQUIPMENT_CAR lec on lec.project_id=o.id where o.distributor_id=:distributor_id and o.project_status='13' and left(o.INPUTTIME,4)=:curYear").setParameter("distributor_id",distributorNo).setParameter("curYear",DateUtils.yearNow()).getTotalCount(); int yearFailCount = bomLpi.createQuery("select 1 from o left join jbo.com.tenwa.lease.comm.LB_EQUIPMENT_CAR lec on lec.project_id=o.id where o.distributor_id=:distributor_id and o.PROJECT_STATUS<>'13' and left(o.INPUTTIME,4)=:curYear").setParameter("distributor_id",distributorNo).setParameter("curYear",DateUtils.yearNow()).getTotalCount(); int yearLoanCount = bomLfi.createQuery("select FACT_MONEY from o left join jbo.com.tenwa.lease.comm.LB_EQUIPMENT_CAR lec on lec.project_id=o.project_id left join jbo.com.tenwa.lease.comm.LB_PROJECT_INFO lpi on lpi.id=o.project_id where o.pay_type = 'pay_type_out' and o.PAY_STATUS='have_paid' and o.FEE_TYPE='feetype10' and o.SETTLE_METHOD='settlemethod6' and left(o.fact_date,4)=:curYear and lpi.distributor_id=:distributor_id").setParameter("distributor_id",distributorNo).setParameter("curYear",DateUtils.yearNow()).getTotalCount(); di.setApprovalCountThisYear(yearApproveCount); di.setRefuseCountThisYear(yearFailCount); di.setLoanCountThisYear(yearLoanCount); return di; } public LoanInfo getLoanInfo() throws Exception { LoanInfo li = new LoanInfo(); li.setProductId(boLpit.getAttribute("PRODUCT_ID").toString()); li.setProductName(boLpit.getAttribute("PRODUCT_NAME").toString()); String settleMethod = boLcct.getAttribute("SETTLE_METHOD").toString(); li.setProductType(ParamDataUtils.queryBcEnumType("SETTLE_METHOD",settleMethod)); li.setSubsityTypeCode(""); //年利率(产品利率) String productRate = ProductParamUtil.getProductParameterValue(boLpit.getAttribute("PRODUCT_ID").toString(),"PRD0350","product_rate","ProductRate"); if("".equals(productRate)){ BizObject boLcsit = JBOFactory.createBizObjectQuery(LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME,"FLOWUNID=:flowunid").setParameter("flowunid",flowUnid).getSingleResult(false); productRate = boLcsit.getAttribute("DISCOUNT_RATE").toString(); } BigDecimal interestRate = new BigDecimal(productRate).divide(new BigDecimal("100"),4,BigDecimal.ROUND_HALF_UP); li.setInterestRate(interestRate.toString()); //首付比例(综合) double firstRatio = boLcct.getAttribute("ALL_FIRST_PAYMENT_RATIO").getDouble()/100; li.setDownPaymentPercentage(new BigDecimal(firstRatio).setScale(4,BigDecimal.ROUND_HALF_UP).toString()); //总首付金额 li.setDownPaymentTotalAmount(boLcct.getAttribute("ALL_FIRST_PAYMENT").toString()); li.setFinanceAmountUnit(""); String finaAmountTotal = boLcct.getAttribute("CLEAN_LEASE_MONEY").toString(); li.setFinanceAmountTotal(finaAmountTotal); //期数 li.setTerms(boLcct.getAttribute("INCOME_NUMBER").toString()); List boLrps = JBOFactory.createBizObjectQuery(LC_RENT_PLAN_TEMP.CLASS_NAME,"select o.interest,o.rent from o where o.FLOWUNID=:flowunid").setParameter("flowunid",flowUnid).getResultList(false); BigDecimal interestTotal = new BigDecimal("0"); double firstRent = 0; for(int i=0;i 0) { IsSubsity="1"; } } //厂家承担利息总额,即厂家贴息金额 li.setMakerInterestTotal(makerInterestTotal); li.setMakerInterestTotalDeposit(""); li.setIsSubsity(IsSubsity); //风险张琬璐要求改为商务条件页面的总价款 li.setContractPriceTotal(boLcct.getAttribute("TOTAL_ALL").toString()); li.setMonthInterestRate(interestRate.divide(new BigDecimal("12"),4,BigDecimal.ROUND_HALF_UP).toString()); li.setPayType("银行卡直扣"); li.setPayRemark(""); li.setIsLinked(ParamDataUtils.queryBcEnumType("TrueFalse",boLpit.getAttribute("IS_NETCAR").toString())); li.setLinkedCompany(boLpit.getAttribute("AFFILIATEDNAME").toString()); li.setLinkedCompanyType(boLpit.getAttribute("LEGALPERSONID").toString()); li.setReserveString1("0"); li.setReserveString2(""); li.setReserveString3(""); li.setReserveString4(""); li.setReserveString5(""); //车辆贷款用途 乘用车或商用。 0:商用车。目前取的TCF商用车,TCC乘用车 String carType = boLpit.getAttribute("car_type").toString(); li.setAssetPurpose("乘用车".equals(carType)?"TCC":"TCF"); li.setBalloonPercentage(""); li.setBalloonAmount(""); String financedAmtPct = new BigDecimal(finaAmountTotal).divide(new BigDecimal(boLcct.getAttribute("TOTAL_ALL").toString()),4,BigDecimal.ROUND_HALF_UP).toString(); li.setFinancedAmtPct(financedAmtPct); li.setRentalCalculationMtd(""); //客户承担利率 String yearRate = boLcct.getAttribute("YEAR_RATE").toString(); li.setBaseCustomerRate(yearRate); //贴息利率 li.setSubsidyRte(interestRate.subtract(new BigDecimal(yearRate)).toString()); li.setCalcSubsidyRte(""); li.setCalcSubsidyAmt(""); //实际利率,刘英明:产品利率 li.setActualRte(interestRate.toString()); li.setPaymentScheme(ParamDataUtils.queryBcEnumType("income_number_year",boLcct.getAttribute("INCOME_NUMBER_YEAR").toString())); li.setDealerSubsidyPct("0"); li.setManufacturerSubsidyPct("0"); li.setCalcDealerSubsidyAmt(interestRate.subtract(new BigDecimal(yearRate)).doubleValue()); li.setCalcManufacturerSubsidyAmt(makerInterestTotal); li.setCarCount(boLects.size()); li.setExposuresNumber(getExposuresNumber()); li.setExposureAmount(getExposuresAmount()); li.setCarRealDownPaymentRatio(boLcct.getAttribute("FIRST_PAYMENT_RATIO").toString()); li.setCarRealDownPaymentAmt(boLcct.getAttribute("FIRST_PAYMENT").toString()); li.setFinancingRatio(1.0-boLcct.getAttribute("FIRST_PAYMENT_RATIO").getDouble()); return li; } public VehicleInfo getVehicleInfo() throws JBOException { VehicleInfo vi = new VehicleInfo(); List SingleVehicleTypes = new ArrayList<>(); for(BizObject bo : boLects){ SingleVehicleType svt = new SingleVehicleType(); //品牌制造商 svt.setMaker(ParamDataUtils.queryBcEnumType("MANUFACTURER_NAME",bo.getAttribute("MANUFACTURER_NAME").toString())); svt.setBrand(bo.getAttribute("BRAND").toString()); svt.setSeries(bo.getAttribute("car_series").toString()); //车型 svt.setModel(bo.getAttribute("MODEL").toString()); //车辆台数 svt.setQuantity("1"); //车辆交易价格 svt.setPriceUnit(bo.getAttribute("EQUIP_PRICE").toString()); svt.setPriceTotal(""); svt.setGps(""); svt.setChassisVehicleModel(""); svt.setSubsityVehicleModel(""); //车辆类型:新车;二手车 svt.setVehicleType(ParamDataUtils.queryBcEnumType("CarType",boLpit.getAttribute("CAR_TYPE").toString())); svt.setOtherFee(""); svt.setProducer(""); //新车指导价 svt.setNewPrice(bo.getAttribute("NOW_TOTAL").toString()); svt.setVinNumber(""); svt.setEngineNumber(""); //车辆用途 svt.setPurpose(ParamDataUtils.queryBcEnumType("car_use_type",bo.getAttribute("car_use_type").toString())); svt.setComments(""); svt.setTransmission(""); svt.setIsAffiliated(""); svt.setAffiliatedCompName(""); svt.setAffiliatedCompCrdcode(""); svt.setRoadOperationLicenseCode(boLpit.getAttribute("TRANSPORTCERTID").toString()); svt.setCarType(ParamDataUtils.queryBcEnumType("CarType",boLpit.getAttribute("CAR_TYPE").toString())); svt.setBuyUseType(bo.getAttribute("cartype").toString()); svt.setPurchaseTax(boLcct.getAttribute("PURCHASE_TAX").toString()); svt.setCarPrice(bo.getAttribute("EQUIP_PRICE").toString()); svt.setCarRealPrice(bo.getAttribute("EQUIP_PRICE").toString()); SingleVehicleTypes.add(svt); } vi.setSingleVehicleTypes(SingleVehicleTypes); return vi; } public CustomerInfo getCustomerInfo() throws Exception { CustomerInfo ci = null; BizObject boCit = JBOFactory.createBizObjectQuery(CUSTOMER_INFO_TEMP.CLASS_NAME,"FLOWUNID=:flowunid").setParameter("flowunid",flowUnid).getSingleResult(false); String customerType = boCit.getAttribute("customertype").toString(); if("01".equals(customerType)){ ci = getCustomerInfoOfCompany(); } if("03".equals(customerType)){ ci = getCustomerInfoOfPerson(); } return ci; } public CustomerInfo getCustomerInfoOfCompany() throws JBOException { CustomerInfo ci = new CustomerInfo(); BizObject boCct = JBOFactory.createBizObjectQuery(CUSTOMER_COMPANY_TEMP.CLASS_NAME,"FLOWUNID=:flowunid").setParameter("flowunid",flowUnid).getSingleResult(false); String chName = boCct.getAttribute("company_name").toString(); String idCardNum = boCct.getAttribute("certid").toString(); String idTypeCode = boCct.getAttribute("CERTTYPE").toString(); String annualIncome = boCct.getAttribute("business_income").toString(); String phoneHome = boCct.getAttribute("tel").toString(); String phoneOffice = boCct.getAttribute("company_tel").toString(); String businessTypeCode = boCct.getAttribute("unit_properties").toString(); ci.setChName(chName); ci.setIdCardNum(idCardNum); ci.setIdTypeCode(ParamDataUtils.queryBcEnumType("CertType",idTypeCode)); ci.setAnnualIncome(annualIncome); ci.setPhoneHome(phoneHome); ci.setPhoneOffice(phoneOffice); ci.setBusinessNatureCde(ParamDataUtils.queryBcEnumType("Unit_nature",businessTypeCode)); ci.setCustTypeId("2"); ci.setCheckedType("2"); return ci; } public CustomerInfo getCustomerInfoOfPerson() throws Exception { CustomerInfo ci = new CustomerInfo(); BizObject boCat = JBOFactory.createBizObjectQuery(CUSTOMER_ACCOUNT_TEMP.CLASS_NAME,"FLOWUNID=:flowunid").setParameter("flowunid",flowUnid).getSingleResult(false); String idTypeCode = ParamDataUtils.queryBcEnumType("CertType",boCpt.getAttribute("CERTTYPE").toString()); String chName = boCpt.getAttribute("FULLNAME").toString(); String idCardNum = boCpt.getAttribute("CERTID").toString(); String genderCode = ParamDataUtils.queryBcEnumType("sex",boCpt.getAttribute("SEX").toString()); String maritalStatusCode = ParamDataUtils.queryBcEnumType("marry",boCpt.getAttribute("MARRIAGE").toString(),boCpt.getAttribute("childrens_number").toString()); String residentialStatusCode = ParamDataUtils.queryBcEnumType("Property_type",boCpt.getAttribute("Property_type").toString()); String MonthlyIncome = boCpt.getAttribute("FAMILYMONTHINCOME").toString(); String phoneCellPhone01 = boCpt.getAttribute("mobile").toString(); String empemployerName = boCpt.getAttribute("WORKCORP").toString(); String businessTypeCode = boCpt.getAttribute("Unit_nature").toString(); String phoneHome = boCpt.getAttribute("telephone").toString(); String phoneOffice = boCpt.getAttribute("WORKTEL").toString(); String loanCardNumber = boCat.getAttribute("acc_number").toString(); String openBankMobileNo = boCat.getAttribute("MOBILE").toString(); String expense = boCpt.getAttribute("monthly_expenses").toString(); String birthday = boCpt.getAttribute("birthday").toString().replace("/","-"); String idBirthday = idCardNum.substring(6,14); String nowDay = DateUtils.dateNow(); int ageInYear = DateUtils.yearDiffByDate(idBirthday,nowDay); int ageInMonth = DateUtils.monthDiffByDate(idBirthday,nowDay); String workAddressId = boCpt.getAttribute("work_address_id").getString(); BizObject boRai = this.getAddressById(workAddressId); if(boRai==null){ } String workProvinceCode = boRai.getAttribute("province_code").toString(); String workCityCode = boRai.getAttribute("city_code").toString(); String workDistrictCode = boRai.getAttribute("district_code").toString(); String workAddressDetail = boRai.getAttribute("address_detail").toString(); String occupationCode = ParamDataUtils.queryBcEnumType("career",boCpt.getAttribute("HEADSHIP").toString()); String empBusinessTypeCode = ParamDataUtils.queryBcEnumType("workUnitIndustry",boCpt.getAttribute("UNITKIND").toString()); String empPositionCode = ParamDataUtils.queryBcEnumType("duties",boCpt.getAttribute("OCCUPATION").toString()); String highestEducation = ParamDataUtils.queryBcEnumType("Education",boCpt.getAttribute("EDUEXPERIENCE").toString()); String CardTermBeginDate = boCpt.getAttribute("start_idexpiry").toString().replace("/","-"); String CardTermEndDate = idDateConvert(boCpt.getAttribute("idexpiry").toString()); String nationId = ParamDataUtils.queryBcEnumType("nation",boCpt.getAttribute("NATIONALITY").toString()); String localResidentFlag = ParamDataUtils.queryBcEnumType("spouse_hukou",boCpt.getAttribute("shukou").toString()); ci.setChName(chName); //证件类型 ci.setIdTypeCode(idTypeCode); //证件号 ci.setIdCardNum(idCardNum); //年龄 ci.setAgeInYear(ageInYear); //性别 ci.setGenderCode(genderCode); //婚姻状况 ci.setMaritalStatusCode(maritalStatusCode); //学历 ci.setEducationCode(highestEducation); //居住状况(安鹏房产类型) ci.setResidentialStatusCode(residentialStatusCode); //月收入 ci.setMonthlyIncome(MonthlyIncome); //年收入 ci.setAnnualIncome(""); ci.setMonthlyDTI(""); ci.setNoOfDependents(""); //工作单位名称 ci.setEmpemployerName(empemployerName); //单位所属行业 ci.setEmpBusinessTypeCode(empBusinessTypeCode); //职业 ci.setEmpOccupationCode(occupationCode); //职务 ci.setEmpPositionCode(empPositionCode); ci.setEmpProfessionalRank(""); ci.setWorkSince(""); ci.setEmpTimeOfEmployee(""); ci.setPhoneCellphone01(phoneCellPhone01); ci.setPhoneCellphone02(""); ci.setPhoneHome(phoneHome); ci.setPhoneOffice(phoneOffice); ci.setBankStatementStatusCode(""); ci.setLocalResidentFlag(localResidentFlag); ci.setLocalApplicantFlag(""); ci.setVipCust(""); //重复申请客户(0:否1:是) ci.setRepeatedApplicantFlag(repeatedApplicantFlag(idCardNum)); ci.setHukouType(""); //最高学历 ci.setHighestEducation(highestEducation); ci.setHighestDegree(""); ci.setOfficePostCode(""); ci.setCurrentOfficeEntryDate(""); ci.setPhsNumber(""); ci.setEmail(""); ci.setHasDrivingLicence(""); ci.setAllowDrivingType(""); //人员类别(1.个人、2.法人) ci.setCheckedType("1"); //贷款卡号(银行卡号) ci.setLoanCardNumber(loanCardNumber); ci.setLoanCardPassword(""); ci.setArchiveUrl(""); ci.setAgeInMonth(ageInMonth); ci.setChildrenFlag(""); ci.setBlacklistInd(""); ci.setThaiTitleCde(""); //月支出 ci.setExpense(expense); //生日 ci.setBrithday(birthday); ci.setLicenseExpireDate(""); ci.setCountryCode(""); ci.setAreaCode(""); ci.setExtentionNbr(""); ci.setPhoneTypeCde(""); //职务 风险张琬璐要求用这个字段 ci.setDesignationCde(empPositionCode); ci.setCityCde(""); ci.setStateCde(""); //省市区 ci.setProvinceGB(workProvinceCode); ci.setCityGB(workCityCode); ci.setDistrictGB(workDistrictCode); ci.setStreetGB(""); //企业性质 ci.setBusinessNatureCde(ParamDataUtils.queryBcEnumType("Unit_nature",businessTypeCode)); ci.setPostCode(""); //工作地址 ci.setEmployAddress(workAddressDetail); //职业 ci.setOccupationCode(occupationCode); //企业类型 ci.setBusinessTypeCde(empBusinessTypeCode); //表示工作年限的长度(从事运输行业年限) ci.setTimeInYear2(""); ci.setRankCde(""); //职业 ci.setOccupationCde(occupationCode); //单位所属行业 ci.setIndustryTypeCde(empBusinessTypeCode); ci.setAddr(getAddr()); ci.setExposure(getExposure(idTypeCode)); //客户类型 ci.setCustTypeId("1"); ci.setIdCardTermBeginDate(CardTermBeginDate); ci.setIdCardTermEndDate(CardTermEndDate); ci.setOpenBankMobileNo(openBankMobileNo); ci.setNationId(nationId); ci.setQueryReason(CodeManager.getItemName("pboc_query_strategy","qryReason_lessee")); return ci; } public Coborrowers getCoborrowers() throws Exception { Coborrowers cos = new Coborrowers(); if(boCft==null){ return cos; } List coborrowerList = new ArrayList<>(); coborrowerList.add(getCoborrower()); cos.setCoborrower(coborrowerList); return cos; } public Coborrower getCoborrower() throws Exception { Coborrower co = new Coborrower(); String idTypeCode = ParamDataUtils.queryBcEnumType("CertType",boCft.getAttribute("CERTTYPE").toString()); String chName = boCft.getAttribute("name").toString(); String idCardNum = boCft.getAttribute("CERTID").toString(); String genderCode = ParamDataUtils.queryBcEnumType("sex",boCft.getAttribute("SEX").toString()); String maritalStatusCode = ParamDataUtils.queryBcEnumType("marry",boCft.getAttribute("marry_type").toString(),boCft.getAttribute("childrens_number").toString()); String residentialStatusCode = ParamDataUtils.queryBcEnumType("Property_type",boCft.getAttribute("residential_status").toString()); String MonthlyIncome = boCft.getAttribute("smincome").toString(); String phoneCellPhone01 = boCft.getAttribute("tel").toString(); String empemployerName = boCft.getAttribute("suname").toString(); String businessTypeCode = boCft.getAttribute("enterprise_nature").toString(); String phoneHome = boCft.getAttribute("tel").toString(); String phoneOffice = boCft.getAttribute("suphone").toString(); String expense = boCft.getAttribute("monthly_expenses").toString(); String birthday = boCft.getAttribute("birthday").toString().replace("/","-"); String idBirthday = idCardNum.substring(6,14); String nowDay = DateUtils.dateNow(); int ageInYear = DateUtils.yearDiffByDate(idBirthday,nowDay); int ageInMonth = DateUtils.monthDiffByDate(idBirthday,nowDay); String workAddressId = boCft.getAttribute("work_address_id").getString(); BizObject boRai = getAddressById(workAddressId); String workProvinceCode = boRai.getAttribute("province_code").toString(); String workCityCode = boRai.getAttribute("city_code").toString(); String workDistrictCode = boRai.getAttribute("district_code").toString(); String workAddressDetail = boRai.getAttribute("address_detail").toString(); String occupationCode = ParamDataUtils.queryBcEnumType("career",boCft.getAttribute("career_type").toString()); String empBusinessTypeCode = ParamDataUtils.queryBcEnumType("workUnitIndustry",boCft.getAttribute("industry_type").toString()); String empPositionCode = ParamDataUtils.queryBcEnumType("duties",boCft.getAttribute("sposition").toString()); String highestEducation = ParamDataUtils.queryBcEnumType("Education",boCft.getAttribute("education_level").toString()); String CardTermBeginDate = boCft.getAttribute("start_idexpiry").toString().replace("/","-"); String CardTermEndDate = idDateConvert(boCft.getAttribute("idexpiry").toString()); String nationId = ParamDataUtils.queryBcEnumType("nation",boCft.getAttribute("nation").toString()); String censusRegAddrId = boCft.getAttribute("id_address_id").toString(); BizObject boCens = this.getAddressById(censusRegAddrId); String censusRegAddr = boCens.getAttribute("full_address").toString(); String relationshipCode = ParamDataUtils.queryBcEnumType("personContact",boCft.getAttribute("ASSURE_RELATION").toString()); String localResidentFlag = ParamDataUtils.queryBcEnumType("spouse_hukou",boCpt.getAttribute("shukou").toString()); co.setChName(chName); //证件类型 co.setIdTypeCode(idTypeCode); //证件号 co.setIdCardNum(idCardNum); //年龄 co.setAgeInYear(ageInYear); //性别 co.setGenderCode(genderCode); //婚姻状况 co.setMaritalStatusCode(maritalStatusCode); //学历 co.setEducationCode(highestEducation); //居住状况(安鹏房产类型) co.setResidentialStatusCode(residentialStatusCode); //月收入 co.setMonthlyIncome(MonthlyIncome); //年收入 co.setAnnualIncome(""); co.setMonthlyDTI(""); co.setNoOfDependents(""); //工作单位名称 co.setEmpemployerName(empemployerName); //单位所属行业 co.setEmpBusinessTypeCode(empBusinessTypeCode); //职业 co.setEmpOccupationCode(occupationCode); //职务 co.setEmpPositionCode(empPositionCode); co.setEmpProfessionalRank(""); co.setWorkSince(""); co.setEmpTimeOfEmployee(""); co.setPhoneCellphone01(phoneCellPhone01); co.setPhoneCellphone02(""); co.setPhoneHome(phoneHome); co.setPhoneOffice(phoneOffice); co.setBankStatementStatusCode(""); co.setLocalResidentFlag(localResidentFlag); co.setLocalApplicantFlag(""); co.setVipCust(""); //重复申请客户(0:否1:是) co.setRepeatedApplicantFlag(repeatedApplicantFlag(idCardNum)); co.setHukouType(""); //最高学历 co.setHighestEducation(highestEducation); co.setHighestDegree(""); co.setOfficePostCode(""); co.setCurrentOfficeEntryDate(""); co.setPhsNumber(""); co.setEmail(""); co.setHasDrivingLicence(""); co.setAllowDrivingType(""); //人员类别(1.个人、2.法人) co.setCheckedType("1"); co.setLoanCardPassword(""); co.setArchiveUrl(""); co.setAgeInMonth(ageInMonth); co.setChildrenFlag(""); co.setBlacklistInd(""); co.setThaiTitleCde(""); //月支出 co.setExpense(expense); //生日 co.setBrithday(birthday); co.setLicenseExpireDate(""); co.setCountryCode(""); co.setAreaCode(""); co.setExtentionNbr(""); co.setPhoneTypeCde(""); //职务 风险张琬璐要求用这个字段 co.setDesignationCde(empPositionCode); co.setCityCde(""); co.setStateCde(""); //省市区 co.setProvinceGB(workProvinceCode); co.setCityGB(workCityCode); co.setDistrictGB(workDistrictCode); co.setStreetGB(""); //企业性质 co.setBusinessNatureCde(ParamDataUtils.queryBcEnumType("Unit_nature",businessTypeCode)); co.setPostCode(""); //工作地址 co.setEmployAddress(workAddressDetail); //职业 co.setOccupationCode(occupationCode); //企业类型 co.setBusinessTypeCde(empBusinessTypeCode); //表示工作年限的长度(从事运输行业年限) co.setTimeInYear2(""); co.setRankCde(""); //职业 co.setOccupationCde(occupationCode); //单位所属行业 co.setIndustryTypeCde(empBusinessTypeCode); co.setAddr(getAddr()); co.setExposure(getExposure(idTypeCode)); //客户类型(目前系统共借人只有一个,且为自然人,默认填入1) co.setCustTypeId("1"); co.setIdCardTermBeginDate(CardTermBeginDate); co.setIdCardTermEndDate(CardTermEndDate); //民族 co.setNationId(nationId); //户籍地址 co.setCensusRegAddr(censusRegAddr); //单位电话 co.setTelWorkNo(phoneOffice); //与主借人关系 co.setRelationshipCode(relationshipCode); //共借人编号(目前系统只有一个共借人,默认填1) co.setBorrowerId("1"); //征信查询原因 co.setQueryReason(CodeManager.getItemName("pboc_query_strategy","qryReason_jointApplicant")); return co; } public GuarantorInfo getGuarantorInfo() throws Exception { GuarantorInfo gi = new GuarantorInfo(); List gis = new ArrayList<>(); for(BizObject boLgu : boLguts){ Guar gr = getGuar(boLgu); if(gr==null){ continue; } gis.add(gr); } gi.setGuars(gis); return gi; } public Guar getGuar(BizObject boLgu) throws Exception { String certType = boLgu.getAttribute("CERTTYPE").toString(); Guar gr = null; if(certType.startsWith("Ind")){ gr = getGuarOfPerson(boLgu); } if(certType.startsWith("Ent")){ gr = getGuarOfCompany(boLgu); } return gr; } public Guar getGuarOfCompany(BizObject boLgu) throws JBOException { Guar gr = new Guar(); String chName = boLgu.getAttribute("FULLNAME").toString(); String idCardNum = boLgu.getAttribute("CERTID").toString(); String idTypeCode = boLgu.getAttribute("CERTTYPE").toString(); String relationshipCode = ParamDataUtils.queryBcEnumType("personContact",boLgu.getAttribute("ASSURE_RELATION").toString()); gr.setChName(chName); gr.setIdCardNum(idCardNum); gr.setIdTypeCode(ParamDataUtils.queryBcEnumType("CertType",idTypeCode)); gr.setRelationshipCode(relationshipCode); gr.setCustTypeId("2"); gr.setCheckedType("2"); return gr; } public Guar getGuarOfPerson(BizObject boLgu) throws Exception { Guar gr = new Guar(); String idTypeCode = ParamDataUtils.queryBcEnumType("CertType",boLgu.getAttribute("CERTTYPE").toString()); String chName = boLgu.getAttribute("FULLNAME").toString(); String idCardNum = boLgu.getAttribute("CERTID").toString(); String genderCode = ParamDataUtils.queryBcEnumType("sex",boLgu.getAttribute("SEX").toString()); String maritalStatusCode = ParamDataUtils.queryBcEnumType("marry",boLgu.getAttribute("Marital_status").toString(),boLgu.getAttribute("childrens_number").toString()); String residentialStatusCode = ParamDataUtils.queryBcEnumType("Property_type",boLgu.getAttribute("residential_status").toString()); String MonthlyIncome = boLgu.getAttribute("Major_monthly_income").toString(); String phoneCellPhone01 = boLgu.getAttribute("MOBILE").toString(); String empemployerName = boLgu.getAttribute("WORKCORP").toString(); String businessTypeCode = boLgu.getAttribute("enterprise_nature").toString(); String phoneHome = boLgu.getAttribute("MOBILE").toString(); String phoneOffice = boLgu.getAttribute("WORKTEL").toString(); String expense = boLgu.getAttribute("monthly_expenses").toString(); String birthday = boLgu.getAttribute("birthday").toString().replace("/","-"); String idBirthday = idCardNum.substring(6,14); String nowDay = DateUtils.dateNow(); int ageInYear = DateUtils.yearDiffByDate(idBirthday,nowDay); int ageInMonth = DateUtils.monthDiffByDate(idBirthday,nowDay); String workAddressId = boLgu.getAttribute("work_address_id").getString(); BizObject boRai = getAddressById(workAddressId); String workProvinceCode = boRai.getAttribute("province_code").toString(); String workCityCode = boRai.getAttribute("city_code").toString(); String workDistrictCode = boRai.getAttribute("district_code").toString(); String workAddressDetail = boRai.getAttribute("address_detail").toString(); String occupationCode = ParamDataUtils.queryBcEnumType("career",boLgu.getAttribute("career_type").toString()); String empBusinessTypeCode = ParamDataUtils.queryBcEnumType("workUnitIndustry",boLgu.getAttribute("industry_type").toString()); String empPositionCode = ParamDataUtils.queryBcEnumType("duties",boLgu.getAttribute("TITLE").toString()); String highestEducation = ParamDataUtils.queryBcEnumType("Education",boLgu.getAttribute("education_level").toString()); String CardTermBeginDate = boLgu.getAttribute("start_idexpiry").toString().replace("/","-"); String CardTermEndDate = idDateConvert(boLgu.getAttribute("idexpiry").toString()); String nationId = ParamDataUtils.queryBcEnumType("nation",boLgu.getAttribute("nation").toString()); String censusRegAddrId = boLgu.getAttribute("id_address_id").toString(); BizObject boCens = this.getAddressById(censusRegAddrId); String censusRegAddr = boCens.getAttribute("full_address").toString(); String relationshipCode = ParamDataUtils.queryBcEnumType("personContact",boLgu.getAttribute("ASSURE_RELATION").toString()); String localResidentFlag = ParamDataUtils.queryBcEnumType("spouse_hukou",boCpt.getAttribute("shukou").toString()); gr.setChName(chName); //证件类型 gr.setIdTypeCode(idTypeCode); //证件号 gr.setIdCardNum(idCardNum); //年龄 gr.setAgeInYear(ageInYear); //性别 gr.setGenderCode(genderCode); //婚姻状况 gr.setMaritalStatusCode(maritalStatusCode); //学历 gr.setEducationCode(highestEducation); //居住状况(安鹏房产类型) gr.setResidentialStatusCode(residentialStatusCode); //月收入 gr.setMonthlyIncome(MonthlyIncome); //年收入 gr.setAnnualIncome(""); gr.setMonthlyDTI(""); gr.setNoOfDependents(""); //工作单位名称 gr.setEmpemployerName(empemployerName); //单位所属行业 gr.setEmpBusinessTypeCode(empBusinessTypeCode); //职业 gr.setEmpOccupationCode(occupationCode); //职务 gr.setEmpPositionCode(empPositionCode); gr.setEmpProfessionalRank(""); gr.setWorkSince(""); gr.setEmpTimeOfEmployee(""); gr.setPhoneCellphone01(phoneCellPhone01); gr.setPhoneCellphone02(""); gr.setPhoneHome(phoneHome); gr.setPhoneOffice(phoneOffice); gr.setBankStatementStatusCode(""); gr.setLocalResidentFlag(localResidentFlag); gr.setLocalApplicantFlag(""); gr.setVipCust(""); //重复申请客户(0:否1:是) gr.setRepeatedApplicantFlag(repeatedApplicantFlag(idCardNum)); gr.setHukouType(""); //最高学历 gr.setHighestEducation(highestEducation); gr.setHighestDegree(""); gr.setOfficePostCode(""); gr.setCurrentOfficeEntryDate(""); gr.setPhsNumber(""); gr.setEmail(""); gr.setHasDrivingLicence(""); gr.setAllowDrivingType(""); //人员类别(1.个人、2.法人) gr.setCheckedType("1"); gr.setLoanCardPassword(""); gr.setArchiveUrl(""); gr.setAgeInMonth(ageInMonth); gr.setChildrenFlag(""); gr.setBlacklistInd(""); gr.setThaiTitleCde(""); //月支出 gr.setExpense(expense); //生日 gr.setBrithday(birthday); gr.setLicenseExpireDate(""); gr.setCountryCode(""); gr.setAreaCode(""); gr.setExtentionNbr(""); gr.setPhoneTypeCde(""); //职务 风险张琬璐要求用这个字段 gr.setDesignationCde(empPositionCode); gr.setCityCde(""); gr.setStateCde(""); //省市区 gr.setProvinceGB(workProvinceCode); gr.setCityGB(workCityCode); gr.setDistrictGB(workDistrictCode); gr.setStreetGB(""); //企业性质 gr.setBusinessNatureCde(ParamDataUtils.queryBcEnumType("Unit_nature",businessTypeCode)); gr.setPostCode(""); //工作地址 gr.setEmployAddress(workAddressDetail); //职业 gr.setOccupationCode(occupationCode); //企业类型 gr.setBusinessTypeCde(empBusinessTypeCode); //表示工作年限的长度(从事运输行业年限) gr.setTimeInYear2(""); gr.setRankCde(""); //职业 gr.setOccupationCde(occupationCode); //单位所属行业 gr.setIndustryTypeCde(empBusinessTypeCode); gr.setAddr(getAddr()); gr.setExposure(getExposure(idTypeCode)); gr.setCustTypeId("1"); gr.setIdCardTermBeginDate(CardTermBeginDate); gr.setIdCardTermEndDate(CardTermEndDate); //民族 gr.setNationId(nationId); //户籍地址 gr.setCensusRegAddr(censusRegAddr); //与主借人关系 gr.setRelationshipCode(relationshipCode); //征信查询原因 gr.setQueryReason(CodeManager.getItemName("pboc_query_strategy","qryReason_guarantor")); return gr; } public ContInfo getContInfo() throws JBOException { ContInfo ci = new ContInfo(); List contrs = new ArrayList<>(); Contr contr = new Contr(); contr.setContNum("1"); contr.setChName(boCpt.getAttribute("EMERGENCY_CONTACT_PERSON").toString()); String relationshipCode1 = ParamDataUtils.queryBcEnumType("personContact",boCpt.getAttribute("EMPLOYRECORD").toString()); contr.setRelationshipCode(relationshipCode1); contr.setCellPhone(boCpt.getAttribute("EMERGENCY_CONTACT_TEL").toString()); Contr contr2 = new Contr(); contr2.setContNum("2"); contr2.setChName(boCpt.getAttribute("INTRO").toString()); String relationshipCode2 = ParamDataUtils.queryBcEnumType("personContact",boCpt.getAttribute("EDUDEGREE").toString()); contr2.setRelationshipCode(relationshipCode2); contr2.setCellPhone(boCpt.getAttribute("REMARK").toString()); contrs.add(contr); contrs.add(contr2); ci.setContrs(contrs); return ci; } public int repeatedApplicantFlag(String certId) throws JBOException { int repeatedApplicantFlag = 0; //int boCountLgu = JBOFactory.createBizObjectQuery(LB_GUARANTEE_UNIT.CLASS_NAME,"CERTID=:certId").setParameter("certId",certId).getTotalCount(); //int boCountCf = JBOFactory.createBizObjectQuery(CUSTOMER_FAMILY.CLASS_NAME,"CERTID=:certId and status='valid' and Partner_='Y' ").setParameter("certId",certId).getTotalCount(); int boCountCi = JBOFactory.createBizObjectQuery(CUSTOMER_INFO.CLASS_NAME,"CERTID=:certId ").setParameter("certId",certId).getTotalCount(); if(boCountCi>0){ repeatedApplicantFlag = 1; } return repeatedApplicantFlag; } public Addr getAddr() throws JBOException { BizObject boCat = JBOFactory.createBizObjectQuery(CUSTOMER_ADDRESS_TEMP.CLASS_NAME,"FLOWUNID=:flowunid and customerid=:customerId").setParameter("flowunid",flowUnid).setParameter("customerId",boCpt.getAttribute("customerid").toString()).getSingleResult(false); String liveAddressId = boCat.getAttribute("province").getString(); String provinceCode = ParamDataUtils.queryMapBcProvinceCode("AreaCode",liveAddressId); String cityCode = ParamDataUtils.queryMapBcCityCode("AreaCode",liveAddressId); String districtCode = ParamDataUtils.queryMapBcCountyCode("AreaCode",liveAddressId); String fullAddress = boCat.getAttribute("dressdetail").getString(); String residentialStatusCode = ParamDataUtils.queryBcEnumType("Property_type",boCpt.getAttribute("Property_type").toString()); Addr addr = new Addr(); addr.setProvince(""); addr.setCity(""); addr.setDistrict(""); addr.setProvinceGB(provinceCode); addr.setCityGB(cityCode); addr.setDistrictGB(districtCode); addr.setStreetGB(""); addr.setAddress(fullAddress); addr.setPostCode(""); addr.setAddrType(""); addr.setAddrNum(""); addr.setPropertyTypeCde(residentialStatusCode); addr.setHukouAddress(""); return addr; } public Exposure getExposure(String certId) throws JBOException { //必须用身份证号,不能用customerid,因为存在一个身份证号,多个customerid的情况 List boCis = JBOFactory.createBizObjectQuery(CUSTOMER_INFO.CLASS_NAME,"CERTID=:certId").setParameter("certId",certId).getResultList(false); BigDecimal corpusRemain = new BigDecimal("0"); BigDecimal yetLoan = new BigDecimal("0"); int carCountRemain = 0; int carCountYetLoan = 0; for(BizObject boCi : boCis){ String customerId = boCi.getAttribute("CUSTOMERID").toString(); //一个customerId存在多个合同 List boLuls = JBOFactory.createBizObjectQuery(LB_UNION_LESSEE.CLASS_NAME,"CUSTOMER_ID=:CUSTOMER_ID and is_main='Y'").setParameter("CUSTOMER_ID",customerId).getResultList(false); for(BizObject boLul : boLuls){ String contractId = boLul.getAttribute("contract_id").toString(); BizObject boLci = JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO.CLASS_NAME,"ID=:ID").setParameter("ID",contractId).getSingleResult(false); String contractStatus = boLci.getAttribute("CONTRACT_STATUS").toString(); if("31".equals(contractStatus)){ BizObject boCat = JBOFactory.createBizObjectQuery(LC_CALC_CONDITION.CLASS_NAME,"CONTRACT_ID=:CONTRACT_ID").setParameter("CONTRACT_ID",contractId).getSingleResult(false); String financeAmount = boCat.getAttribute("CLEAN_LEASE_MONEY").toString(); BizObject boLri = JBOFactory.createBizObjectQuery(LC_RENT_INCOME.CLASS_NAME,"select ifnull(sum(corpus),0) as v.corpusTotal from o where CONTRACT_ID=:CONTRACT_ID and ROLL_BACK='0' ").setParameter("CONTRACT_ID",contractId).getSingleResult(false); String corpusTotal = boLri.getAttribute("corpusTotal").toString(); corpusRemain = corpusRemain.add(new BigDecimal(financeAmount).subtract(new BigDecimal(corpusTotal))); carCountRemain = JBOFactory.createBizObjectQuery(LB_EQUIPMENT_CAR.CLASS_NAME,"CONTRACT_ID=:CONTRACT_ID").setParameter("CONTRACT_ID",contractId).getTotalCount(); } if("21".equals(contractStatus)){ BizObject boLfi = JBOFactory.createBizObjectQuery(LC_FUND_INCOME.CLASS_NAME,"CONTRACT_ID=:CONTRACT_ID and pay_type='pay_type_out' and fee_type='feetype10' and SETTLE_METHOD='settlemethod6' and roll_back='0' and PAY_STATUS<>'have_paid' ").setParameter("CONTRACT_ID",contractId).getSingleResult(false); String factMoney = boLfi.getAttribute("fact_money").toString(); yetLoan = yetLoan.add(new BigDecimal(factMoney)); carCountYetLoan = JBOFactory.createBizObjectQuery(LB_EQUIPMENT_CAR.CLASS_NAME,"CONTRACT_ID=:CONTRACT_ID").setParameter("CONTRACT_ID",contractId).getTotalCount(); } } } Exposure ep = new Exposure(); ep.setOutstanding(corpusRemain.toString()); ep.setApprovalAmt(yetLoan.toString()); ep.setOsNum(carCountRemain); ep.setApprovalNum(carCountYetLoan); return ep; } public ApplicationInfo getApplicationInfo() throws Exception { ApplicationInfo app = new ApplicationInfo(); String number = boLpit.getAttribute("PROJECT_NO").toString(); BizObject boft = JBOFactory.createBizObjectQuery(FLOW_TASK.CLASS_NAME,"select min(begintime) as v.minTime,max(begintime) as v.maxTime from o where flowno='BusinessApplyFlow' and phasetype='1020' and objectno=:flowunid").setParameter("flowunid",flowUnid).getSingleResult(false); String minTime = boft.getAttribute("minTime").toString().replace("/","-").replace(" ","T"); String maxTime = boft.getAttribute("maxTime").toString().replace("/","-").replace(" ","T"); String faName = boLpit.getAttribute("inputName").toString(); String faCellphone = boLpit.getAttribute("inputTel").toString(); String carType = boLpit.getAttribute("car_type").toString(); app.setNumber(number); app.setApplicationType("APF"); app.setOriginalSystemId("APF"); app.setTranNo(tranNo); app.setFirstProposalDate(minTime); app.setLastProposalDate(maxTime); app.setFaName(faName); app.setFaid(""); app.setFaCellphone(faCellphone); app.setFvName(""); app.setFvCellphone(""); app.setFvDateoffv(""); app.setFieldVisitFlag(""); app.setBusinessStep(""); app.setGroupCustomerUpId(""); app.setGroupCustomerSpecialLimit(""); //区分贷款车辆类型(CV、PV) app.setLoanvehicleType("乘用车".equals(carType)?"PV":"CV"); app.setQueryReason(""); app.setCreditQueryType(""); app.setCreditQueryInterface(""); BizObject boPsl = JBOFactory.createBizObjectQuery(PRD_SPECIFIC_LIBRARY.CLASS_NAME,"PRODUCTID=:PRODUCTID").setParameter("PRODUCTID",boLpit.getAttribute("PRODUCT_ID").toString()).getSingleResult(false); String lendingType = boPsl.getAttribute("LENDING_TYPE").toString(); app.setIsVehicleGuaranty("AFTER".equals(lendingType)||"FIRST".equals(lendingType)?"1":"0"); app.setCvHeadVehicleCount(""); app.setSosRandomNumber(""); //申请日期 app.setApplicationDate(boLpit.getAttribute("project_date").toString().replace("/","-").replace(" ","T")); //经销商提交申请或重新提交申请时间。 app.setApplicationSubmitDate(maxTime); //申请类型 客户类型 1个人 2法人 BizObject boCit = JBOFactory.createBizObjectQuery(CUSTOMER_INFO_TEMP.CLASS_NAME,"FLOWUNID=:flowunid").setParameter("flowunid",flowUnid).getSingleResult(false); String customerType = "1"; if("01".equals(boCit.getAttribute("customertype").toString())){ customerType="2"; } app.setCustomerType(customerType); //经销商担保模式 app.setStatusCode(ParamDataUtils.queryBcEnumType("dischanneltype",boDi.getAttribute("channeltype").toString())); return app; } public PreviouslyVehicle getPreviouslyVehicle() throws JBOException { PreviouslyVehicle pv = new PreviouslyVehicle(); pv.setWorkingTime(ParamDataUtils.queryBcEnumType("employmentTime",boCpt.getAttribute("pre_operate_years").toString())); pv.setPreviouslyVehicleType(ParamDataUtils.queryBcEnumType("operatePreVehicleType",boCpt.getAttribute("pre_operate_car_type").toString())); pv.setPreviouslyVehicleLicense(boCpt.getAttribute("pre_operate_car_no").toString()); return pv; } public BizObject getAddressById(String addressId) throws JBOException { BizObject boRai = null; BizObjectManager rcAddressInfo = JBOFactory.getBizObjectManager(RC_ADDRESS_INFO.CLASS_NAME); if(addressId==null || "".equals(addressId)){ boRai = rcAddressInfo.newObject(); boRai.setAttributeValue("province_code",""); boRai.setAttributeValue("city_code",""); boRai.setAttributeValue("district_code",""); boRai.setAttributeValue("address_detail","空地址"); return boRai; } boRai = rcAddressInfo.createQuery("address_id=:id").setParameter("id", addressId).getSingleResult(false); if(boRai == null){ boRai = rcAddressInfo.newObject(); boRai.setAttributeValue("province_code",""); boRai.setAttributeValue("city_code",""); boRai.setAttributeValue("district_code",""); boRai.setAttributeValue("address_detail","根据address_id未查得地址"); } return boRai; } public int exposures() throws JBOException { Set projectSet = new HashSet<>(); BizObject boCit = JBOFactory.createBizObjectQuery(CUSTOMER_INFO_TEMP.CLASS_NAME,"FLOWUNID=:flowunid").setParameter("flowunid",flowUnid).getSingleResult(false); String applyCertId = boCpt.getAttribute("CERTID").toString(); projectSet.addAll(getExposuresNumberByCertID(applyCertId)); if(boCft!=null){ String coBorroeerId = boCft.getAttribute("CERTID").toString(); projectSet.addAll(getExposuresNumberByCertID(coBorroeerId)); } if(boLguts.size()>0){ for(BizObject boLgu : boLguts){ String lguCertId = boLgu.getAttribute("CERTID").toString(); projectSet.addAll(getExposuresNumberByCertID(lguCertId)); } } return projectSet.size(); } public String exposuresAmount() throws JBOException { Set projectSet = new HashSet<>(); BigDecimal amount = new BigDecimal("0.00"); BizObject boCit = JBOFactory.createBizObjectQuery(CUSTOMER_INFO_TEMP.CLASS_NAME,"FLOWUNID=:flowunid").setParameter("flowunid",flowUnid).getSingleResult(false); String applyCertId = boCpt.getAttribute("CERTID").toString(); projectSet.addAll(getExposuresNumberByCertID(applyCertId)); if(boCft!=null){ String coBorroeerId = boCft.getAttribute("CERTID").toString(); projectSet.addAll(getExposuresNumberByCertID(coBorroeerId)); } if(boLguts.size()>0){ for(BizObject boLgu : boLguts){ String lguCertId = boLgu.getAttribute("CERTID").toString(); projectSet.addAll(getExposuresNumberByCertID(lguCertId)); } } for(String projectId : projectSet){ BizObject boLpc = JBOFactory.createBizObjectQuery(LC_PROJ_CONDITION.CLASS_NAME,"PROJECT_ID=:PROJECT_ID").setParameter("PROJECT_ID",projectId).getSingleResult(false); String cleanLeaseMoney = boLpc.getAttribute("CLEAN_LEASE_MONEY").toString(); String cautionMoney =boLpc.getAttribute("CAUTION_MONEY").toString(); BizObject boLri = JBOFactory.createBizObjectQuery(LC_RENT_INCOME.CLASS_NAME,"select sum(rent) as v.rentIncome from O where ROLL_BACK=0 and PROJECT_ID=:PROJECT_ID").setParameter("PROJECT_ID",projectId).getSingleResult(false); String rentIncome = boLri.getAttribute("rentIncome").toString(); if("".equals(rentIncome)){ continue; } amount = new BigDecimal(cleanLeaseMoney).subtract(new BigDecimal(cautionMoney)).subtract(new BigDecimal(rentIncome)).add(amount); } return amount.toString(); } public Set getExposuresNumberByCertID(String certId) throws JBOException { /* 具体敞口逻辑为:主借人或者共借人或担保人出现在其他合同(全条线业务)中作为主借或者共借人或担保人(重复合同取一次计算) =全部合同的(已放款的贷款余额 + 待放款的贷款金额 + 已核准未放款贷款金额 - 保证金金额) + 本单申请的(贷款金额 - 保证金金额) +当前在信审节点中申请的(贷款金额 - 保证金金额) 法人客户,需考虑法人客户的自然人主体:法定代表人、实际控制人及股东关联的订单敞口。 */ //一个身份证可能存在多个customerid List boCis = JBOFactory.createBizObjectQuery(CUSTOMER_INFO.CLASS_NAME,"select CUSTOMERID from O where CERTID=:certId").setParameter("certId",certId).getResultList(false); Set projectSet = new HashSet<>(); for(BizObject boCi : boCis){ String customerId = boCi.getAttribute("CUSTOMERID").toString(); //一个customerId存在多个合同 List boLuls = JBOFactory.createBizObjectQuery(LB_UNION_LESSEE.CLASS_NAME,"select project_id from O where CUSTOMER_ID=:CUSTOMER_ID and is_main='Y'").setParameter("CUSTOMER_ID",customerId).getResultList(false); for(BizObject boLul : boLuls){ String projectId = boLul.getAttribute("project_id").toString(); projectSet.add(projectId); } } List boCfs = JBOFactory.createBizObjectQuery(CUSTOMER_FAMILY.CLASS_NAME,"select PROJECT_ID from O where CERTID=:certId and status='valid' and Partner_='Y'").setParameter("certId",certId).getResultList(false); for(BizObject boCf : boCfs){ String projectId = boCf.getAttribute("PROJECT_ID").toString(); projectSet.add(projectId); } List boLgus = JBOFactory.createBizObjectQuery(LB_GUARANTEE_UNIT.CLASS_NAME,"select PROJECT_ID from O where CERTID=:certId ").setParameter("certId",certId).getResultList(false); for(BizObject boLgu : boLgus){ String projectId = boLgu.getAttribute("PROJECT_ID").toString(); projectSet.add(projectId); } return projectSet; } public int getExposuresNumber() throws JBOException { BigDecimal count = new BigDecimal("0"); for(BizObject boChit : getExposures()){ count = count.add(new BigDecimal(boChit.getAttribute("CLIENTBUYNUMBER").toString())); } return count.intValue(); } public List getExposures() throws JBOException { List boChits = JBOFactory.createBizObjectQuery(CUSTOMER_HISTORY_INFO_TEMP.CLASS_NAME,"FLOWUNID=:flowunid ").setParameter("flowunid",flowUnid).getResultList(false); System.out.println(boChits.size()); return boChits; } public String getExposuresAmount() throws JBOException { Transaction Sqlca = null; String amount = "0.00"; try { Sqlca = Transaction.createTransaction("als"); amount = LBBusinessPrimary.obtainExposureMoney(Sqlca,flowUnid).toString(); } catch (SQLException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { if (Sqlca != null) try { Sqlca.commit(); Sqlca.disConnect(); Sqlca = null; } catch (Exception e) { e.printStackTrace(); } } return amount; } public String idDateConvert(String date){ if("2100/12/31".equals(date)){ date = "0000-00-00"; }else{ date = date.replace("/","-"); } return date; } public String getFlowUnid() { return flowUnid; } public void setFlowUnid(String flowUnid) { this.flowUnid = flowUnid; } public String getOperatorId() { return operatorId; } public void setOperatorId(String operatorId) { this.operatorId = operatorId; } public String getTranNo() { return tranNo; } public void setTranNo(String tranNo) { this.tranNo = tranNo; } }