diff --git a/WebContent/WEB-INF/etc/jbo/jbo_customer.xml b/WebContent/WEB-INF/etc/jbo/jbo_customer.xml index 1c928cc8a..59f3ab265 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_customer.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_customer.xml @@ -3251,120 +3251,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebContent/WEB-INF/etc/jbo/jbo_lease.xml b/WebContent/WEB-INF/etc/jbo/jbo_lease.xml index 5594ab56c..a33882ce7 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_lease.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_lease.xml @@ -2406,6 +2406,7 @@ + diff --git a/src/com/amarsoft/app/awe/config/CollectProperties.java b/src/com/amarsoft/app/awe/config/CollectProperties.java index 82507b727..a934906a1 100644 --- a/src/com/amarsoft/app/awe/config/CollectProperties.java +++ b/src/com/amarsoft/app/awe/config/CollectProperties.java @@ -1,142 +1,163 @@ -package com.amarsoft.app.awe.config; - - -public class CollectProperties{ - - private String c_serverUrl; - private String b_serverUrl; - private String merchantId; - private String flag; - private String userName; - private String userPass; - private String businessCode; - private String c_dataType; - private String c_level; - private String c_trxCode; - private String c_version; - private String b_trxCode; - private String b_version; - private String b_dataType; - private String b_level; - private String publicKeyUrl; - private String privateKeyUrl; - private String clearRequestUrl; - private String batch_trxCode;//״ - - public String getBatch_trxCode() { - return batch_trxCode; - } - public void setBatch_trxCode(String batch_trxCode) { - this.batch_trxCode = batch_trxCode; - } - public String getPublicKeyUrl() { - return publicKeyUrl; - } - public void setPublicKeyUrl(String publicKeyUrl) { - this.publicKeyUrl = publicKeyUrl; - } - public String getPrivateKeyUrl() { - return privateKeyUrl; - } - public void setPrivateKeyUrl(String privateKeyUrl) { - this.privateKeyUrl = privateKeyUrl; - } - public String getClearRequestUrl() { - return clearRequestUrl; - } - public void setClearRequestUrl(String clearRequestUrl) { - this.clearRequestUrl = clearRequestUrl; - } - public String getC_serverUrl() { - return c_serverUrl; - } - public void setC_serverUrl(String c_serverUrl) { - this.c_serverUrl = c_serverUrl; - } - public String getB_serverUrl() { - return b_serverUrl; - } - public void setB_serverUrl(String b_serverUrl) { - this.b_serverUrl = b_serverUrl; - } - public String getMerchantId() { - return merchantId; - } - public void setMerchantId(String merchantId) { - this.merchantId = merchantId; - } - public String getFlag() { - return flag; - } - public void setFlag(String flag) { - this.flag = flag; - } - public String getUserName() { - return userName; - } - public void setUserName(String userName) { - this.userName = userName; - } - public String getUserPass() { - return userPass; - } - public void setUserPass(String userPass) { - this.userPass = userPass; - } - public String getBusinessCode() { - return businessCode; - } - public void setBusinessCode(String businessCode) { - this.businessCode = businessCode; - } - public String getC_dataType() { - return c_dataType; - } - public void setC_dataType(String c_dataType) { - this.c_dataType = c_dataType; - } - public String getC_level() { - return c_level; - } - public void setC_level(String c_level) { - this.c_level = c_level; - } - public String getC_trxCode() { - return c_trxCode; - } - public void setC_trxCode(String c_trxCode) { - this.c_trxCode = c_trxCode; - } - public String getC_version() { - return c_version; - } - public void setC_version(String c_version) { - this.c_version = c_version; - } - public String getB_trxCode() { - return b_trxCode; - } - public void setB_trxCode(String b_trxCode) { - this.b_trxCode = b_trxCode; - } - public String getB_version() { - return b_version; - } - public void setB_version(String b_version) { - this.b_version = b_version; - } - public String getB_dataType() { - return b_dataType; - } - public void setB_dataType(String b_dataType) { - this.b_dataType = b_dataType; - } - public String getB_level() { - return b_level; - } - public void setB_level(String b_level) { - this.b_level = b_level; - } - - -} +package com.amarsoft.app.awe.config; + + +public class CollectProperties{ + + private String c_serverUrl; + private String b_serverUrl; + private String merchantId; + private String flag; + private String userName; + private String userPass; + private String businessCode; + private String c_dataType; + private String c_level; + private String c_trxCode; + private String c_version; + private String b_trxCode; + private String b_version; + private String b_dataType; + private String b_level; + private String publicKeyUrl; + private String privateKeyUrl; + private String clearRequestUrl; + private String batch_trxCode;//״ + private String tianJinmerchantId; + private String tianJinuserName; + private String tianJinuserPass; + + public String getBatch_trxCode() { + return batch_trxCode; + } + public void setBatch_trxCode(String batch_trxCode) { + this.batch_trxCode = batch_trxCode; + } + public String getPublicKeyUrl() { + return publicKeyUrl; + } + public void setPublicKeyUrl(String publicKeyUrl) { + this.publicKeyUrl = publicKeyUrl; + } + public String getPrivateKeyUrl() { + return privateKeyUrl; + } + public void setPrivateKeyUrl(String privateKeyUrl) { + this.privateKeyUrl = privateKeyUrl; + } + public String getClearRequestUrl() { + return clearRequestUrl; + } + public void setClearRequestUrl(String clearRequestUrl) { + this.clearRequestUrl = clearRequestUrl; + } + public String getC_serverUrl() { + return c_serverUrl; + } + public void setC_serverUrl(String c_serverUrl) { + this.c_serverUrl = c_serverUrl; + } + public String getB_serverUrl() { + return b_serverUrl; + } + public void setB_serverUrl(String b_serverUrl) { + this.b_serverUrl = b_serverUrl; + } + public String getMerchantId() { + return merchantId; + } + public void setMerchantId(String merchantId) { + this.merchantId = merchantId; + } + public String getFlag() { + return flag; + } + public void setFlag(String flag) { + this.flag = flag; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public String getUserPass() { + return userPass; + } + public void setUserPass(String userPass) { + this.userPass = userPass; + } + public String getBusinessCode() { + return businessCode; + } + public void setBusinessCode(String businessCode) { + this.businessCode = businessCode; + } + public String getC_dataType() { + return c_dataType; + } + public void setC_dataType(String c_dataType) { + this.c_dataType = c_dataType; + } + public String getC_level() { + return c_level; + } + public void setC_level(String c_level) { + this.c_level = c_level; + } + public String getC_trxCode() { + return c_trxCode; + } + public void setC_trxCode(String c_trxCode) { + this.c_trxCode = c_trxCode; + } + public String getC_version() { + return c_version; + } + public void setC_version(String c_version) { + this.c_version = c_version; + } + public String getB_trxCode() { + return b_trxCode; + } + public void setB_trxCode(String b_trxCode) { + this.b_trxCode = b_trxCode; + } + public String getB_version() { + return b_version; + } + public void setB_version(String b_version) { + this.b_version = b_version; + } + public String getB_dataType() { + return b_dataType; + } + public void setB_dataType(String b_dataType) { + this.b_dataType = b_dataType; + } + public String getB_level() { + return b_level; + } + public void setB_level(String b_level) { + this.b_level = b_level; + } + public String getTianJinmerchantId() { + return tianJinmerchantId; + } + public void setTianJinmerchantId(String tianJinmerchantId) { + this.tianJinmerchantId = tianJinmerchantId; + } + public String getTianJinuserName() { + return tianJinuserName; + } + public void setTianJinuserName(String tianJinuserName) { + this.tianJinuserName = tianJinuserName; + } + public String getTianJinuserPass() { + return tianJinuserPass; + } + public void setTianJinuserPass(String tianJinuserPass) { + this.tianJinuserPass = tianJinuserPass; + } + + +} diff --git a/src/com/amarsoft/app/awe/config/InitCollectConfig.java b/src/com/amarsoft/app/awe/config/InitCollectConfig.java index 95ccc5b38..439bb6651 100644 --- a/src/com/amarsoft/app/awe/config/InitCollectConfig.java +++ b/src/com/amarsoft/app/awe/config/InitCollectConfig.java @@ -1,62 +1,76 @@ -package com.amarsoft.app.awe.config; - -import javax.servlet.http.HttpServlet; - -import org.springframework.web.context.ContextLoader; -import org.springframework.web.context.WebApplicationContext; - -import com.mchange.v2.c3p0.ComboPooledDataSource; - -/** - * ȫ ӿϢ - * @author yangdm - */ -public class InitCollectConfig extends HttpServlet{ - private static final long serialVersionUID = 1L; - public static final String C_SERVERURL; - public static final String B_SERVERURL; - public static final String MERCHANTID; - public static final String FLAG; - public static final String USERNAME; - public static final String USERPASS; - public static final String BUSSINESSCODE; - public static final String C_DATATYPE; - public static final String C_LEVEL; - public static final String C_TRXCODE; - public static final String C_VERSION; - /** - * ״룬ͬʵʱ - */ - public static final String BATCH_TRXCODE; - public static final String B_TRXCODE; - public static final String B_VERSION; - public static final String B_DATATYPE; - public static final String B_LEVEL; - public static final String PUBLICKEYURL; - public static final String PRIVATEKEYURL; - public static final String CLEARREQUESTURL; - - static{ - WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext(); - CollectProperties collectproperties = wac.getBean("collectConfig", CollectProperties.class); - C_SERVERURL = collectproperties.getC_serverUrl(); - B_SERVERURL = collectproperties.getB_serverUrl(); - MERCHANTID = collectproperties.getMerchantId(); - FLAG = collectproperties.getFlag(); - USERNAME = collectproperties.getUserName(); - USERPASS = collectproperties.getUserPass(); - BUSSINESSCODE = collectproperties.getBusinessCode(); - C_DATATYPE = collectproperties.getC_dataType(); - C_LEVEL = collectproperties.getC_level(); - C_TRXCODE = collectproperties.getC_trxCode(); - C_VERSION = collectproperties.getC_version(); - BATCH_TRXCODE = collectproperties.getBatch_trxCode(); - B_TRXCODE = collectproperties.getB_trxCode(); - B_VERSION = collectproperties.getB_version(); - B_DATATYPE = collectproperties.getB_dataType(); - B_LEVEL = collectproperties.getB_level(); - PUBLICKEYURL=collectproperties.getPublicKeyUrl(); - PRIVATEKEYURL=collectproperties.getPrivateKeyUrl(); - CLEARREQUESTURL=collectproperties.getClearRequestUrl(); - } -} +package com.amarsoft.app.awe.config; + +import javax.servlet.http.HttpServlet; + +import org.springframework.web.context.ContextLoader; +import org.springframework.web.context.WebApplicationContext; + +import com.mchange.v2.c3p0.ComboPooledDataSource; + +/** + * ȫ ӿϢ + * @author yangdm + */ +public class InitCollectConfig extends HttpServlet{ + private static final long serialVersionUID = 1L; + public static final String C_SERVERURL; + public static final String B_SERVERURL; + public static final String MERCHANTID; + public static final String FLAG; + public static final String USERNAME; + public static final String USERPASS; + public static final String BUSSINESSCODE; + public static final String C_DATATYPE; + public static final String C_LEVEL; + public static final String C_TRXCODE; + public static final String C_VERSION; + /** + * ״룬ͬʵʱ + */ + public static final String BATCH_TRXCODE; + public static final String B_TRXCODE; + public static final String B_VERSION; + public static final String B_DATATYPE; + public static final String B_LEVEL; + public static final String PUBLICKEYURL; + public static final String PRIVATEKEYURL; + public static final String CLEARREQUESTURL; + /** + * ̻ + * ̻̻ţ001053110000013 + ̻̻ƣӿڲ̻ + ̻ûoperator13 + ̻룺ora_123456 + */ + public static final String TIANJIN_MERCHANTID; + public static final String TIANJIN_USERNAME; + public static final String TIANJIN_USERPASS; + + + static{ + WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext(); + CollectProperties collectproperties = wac.getBean("collectConfig", CollectProperties.class); + C_SERVERURL = collectproperties.getC_serverUrl(); + B_SERVERURL = collectproperties.getB_serverUrl(); + MERCHANTID = collectproperties.getMerchantId(); + FLAG = collectproperties.getFlag(); + USERNAME = collectproperties.getUserName(); + USERPASS = collectproperties.getUserPass(); + BUSSINESSCODE = collectproperties.getBusinessCode(); + C_DATATYPE = collectproperties.getC_dataType(); + C_LEVEL = collectproperties.getC_level(); + C_TRXCODE = collectproperties.getC_trxCode(); + C_VERSION = collectproperties.getC_version(); + BATCH_TRXCODE = collectproperties.getBatch_trxCode(); + B_TRXCODE = collectproperties.getB_trxCode(); + B_VERSION = collectproperties.getB_version(); + B_DATATYPE = collectproperties.getB_dataType(); + B_LEVEL = collectproperties.getB_level(); + PUBLICKEYURL=collectproperties.getPublicKeyUrl(); + PRIVATEKEYURL=collectproperties.getPrivateKeyUrl(); + CLEARREQUESTURL=collectproperties.getClearRequestUrl(); + TIANJIN_MERCHANTID=collectproperties.getTianJinmerchantId(); + TIANJIN_USERNAME=collectproperties.getTianJinuserName(); + TIANJIN_USERPASS=collectproperties.getTianJinuserPass(); + } +} diff --git a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java index fa5963338..a4e40e121 100644 --- a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java +++ b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java @@ -1,1772 +1,1835 @@ -package com.tenwa.collectaudit.cache; - -import java.io.File; -import java.math.BigDecimal; -import java.sql.SQLException; -import java.text.DecimalFormat; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.springframework.jdbc.object.SqlCall; - -import jbo.app.tenwa.calc.LC_RENT_PLAN; -import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT; -import jbo.app.tenwa.customer.DISTRIBUTOR_INFO; -import jbo.com.tenwa.entity.comm.flow.D_DEPOSITCHARGE_INFO; -import jbo.com.tenwa.entity.comm.flow.D_DEPOSITRETURN_INFO; -import jbo.com.tenwa.lease.comm.LB_BUCKLE_LOG; -import jbo.com.tenwa.lease.comm.LB_CLEAR_FILE_RECORD; -import jbo.com.tenwa.lease.comm.LB_INTFACE_FILE_RECORD; -import jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN; -import jbo.sys.CODE_LIBRARY; - -import com.amarsoft.app.als.sys.tools.DateTool; -import com.amarsoft.app.awe.config.InitCollectConfig; -import com.amarsoft.app.util.StringUtil; -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.ASResultSet; -import com.amarsoft.awe.util.SqlObject; -import com.amarsoft.awe.util.Transaction; -import com.gnete.security.crypt.Crypt; -import com.gnete.security.crypt.CryptException; -import com.ibm.sslight.tools.mainExit; -import com.tenwa.comm.util.date.DateAssistant; -import com.tenwa.comm.util.jboutil.DataOperatorUtil; - -public class CollectAuditInfoCache { - - private String id; - private String fileSavePath = "d:/tmp/als/InterFace"; - private String inputuserid; - private String inputorgid; - private String clearDate; - private String distributor_id; - private String penaltys; - - /** - * ̱֤ - * ƻIDڱ֤ȡΪdepositcharge_id˻رΪRENT_PLAN_ID - * @param depositcharge_id,tx - * @return - * @throws Exception - */ - public void writeBackDistributor(String RENT_PLAN_ID,Transaction Sqlca) throws JBOException{ - BizObjectManager bmDCI = JBOFactory.getFactory().getManager(D_DEPOSITCHARGE_INFO.CLASS_NAME); - BizObjectManager bmDRI = JBOFactory.getFactory().getManager(D_DEPOSITRETURN_INFO.CLASS_NAME); - BizObjectManager bmDI = JBOFactory.getFactory().getManager(DISTRIBUTOR_INFO.CLASS_NAME); - BizObject bDRI= bmDRI.createQuery("RENT_PLAN_ID=:RENT_PLAN_ID").setParameter("RENT_PLAN_ID", RENT_PLAN_ID).getSingleResult(false); - String distributorId = bDRI.getAttribute("DISTRIBUTOR_ID").toString(); - String cautionMoney = bDRI.getAttribute("CAUTION_MONEY").toString(); - //D_DEPOSITCHARGE_INFO - BizObject bDCI_N = bmDCI.newObject(); - bDCI_N.setAttributeValue("DISTRIBUTOR_ID", distributorId); - bDCI_N.setAttributeValue("CAUTION_MONEY", cautionMoney); - bDCI_N.setAttributeValue("MONEY_TYPE","bondBack"); - bDCI_N.setAttributeValue("INPUTTIME",StringFunction.getTodayNow()); - bDCI_N.setAttributeValue("INPUTUSERID",inputuserid); - bDCI_N.setAttributeValue("INPUTORGID",inputorgid); - bDCI_N.setAttributeValue("RENT_PLAN_ID",RENT_PLAN_ID); - bmDCI.saveObject(bDCI_N); - //޸ľϢĽ - BizObject bDI = bmDI.createQuery("distributor_no=:distributor_id").setParameter("distributor_id", distributorId).getSingleResult(false); - BigDecimal sum = new BigDecimal(bDI.getAttribute("sums").getString()); - double account_balance = sum.add(new BigDecimal(cautionMoney)).doubleValue(); - bmDI.createQuery("update O set O.sums='"+account_balance+"' where O.distributor_no=:distributor_id").setParameter("distributor_id", distributorId).executeUpdate(); - System.out.println("ɹ"); - } - - //ȡļ - public static String getCollectIntface(String id) throws Exception{ - - String sql="select lr.filename from LB_INTFACE_FILE_RECORD lr " - + "where lr.id=:id"; - Map map=new HashMap(); - map.put("id", id); - JBOTransaction tx = null; - String filename=""; - tx=JBOFactory.createJBOTransaction(); - List> list=DataOperatorUtil.getDataBySql(tx, sql, map); - if(list.size()>0){ - filename=StringUtil.nullToString(list.get(0).get("FILENAME")) ; - } - tx.commit(); - return filename; - } - //УǷѾտ - public String checkRentIsIncome(JBOTransaction tx) throws JBOException{ - String[] ids = id.split("@"); - StringBuffer parms = new StringBuffer(); - for (String str : ids) { - if (parms.length()==0) { - parms.append("'"+str+"'"); - }else{ - parms.append(",'"+str+"'"); - } - } - BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME,tx); - List bolist = bm.createQuery("select v.getCustomerName(O.customer_id) as v.customer_name,O.account,O.acc_number,O.mobile,O.contract_id,O.plan_list,O.plan_date,O.COLLECT_STATUS,O.BATCH_STATUS,O.rent from O where O.id in ("+parms.toString()+")").getResultList(false); - for (BizObject bo : bolist) { - String name = bo.getAttribute("customer_name").toString().trim(); - String plan_list = bo.getAttribute("plan_list").toString(); - String plan_date = bo.getAttribute("plan_date").toString(); - String batchstatus = bo.getAttribute("BATCH_STATUS").toString(); - String rent = bo.getAttribute("rent").toString(); - if ("process".equals(batchstatus)) {//жǷ - return "error@"+name+""+plan_list+"Ϊ"+plan_date+"ڽۿ".trim(); - } - if ("".equals(rent) || "0".equals(rent) || "0.0".equals(rent)) {//жʣտ - return "error@"+name+""+plan_list+"Ϊ"+plan_date+"Ѿȫȡ,޷ٴοۿ".trim(); - } - } - return "sucess"; - } - //ϴļ - public String uploadClearFile(JBOTransaction tx) throws JBOException{ - String currentDateTime = DateAssistant.getTodayNow(); - String currenttime=currentDateTime.replaceAll("/", ""); - currenttime=currenttime.replaceAll(":", ""); - currenttime=currenttime.replaceAll(" ", ""); - //String SETT_DATE = "20170920"; - String SETT_DATE = this.getClearDate() != null ? this.getClearDate().replace("/", "") : ""; - String SETT_NO = "01"; - String SF_TYPE = InitCollectConfig.FLAG; - String USER_NAME = InitCollectConfig.USERNAME; - String MERCHANT_ID = InitCollectConfig.MERCHANTID; - String REQ_TIME = currenttime; - //String URL = "http://59.41.103.98:333/gzdsf/GetSettFile.do?"; - String URL = InitCollectConfig.CLEARREQUESTURL+"?"; - String SIGNED_MSG = ""; - try { - Crypt crypt = new Crypt("gbk"); - String pathPfx = InitCollectConfig.PRIVATEKEYURL; - //"D:\\BaiduNetdisk\\Download\\ոϵͳӿĵJAVAdemoز\\JAVADEMOԲ_20170825\\̻֤\\ORA@TEST1.p12"; - SIGNED_MSG = SETT_DATE+"|"+SETT_NO+"|"+USER_NAME+"|"+MERCHANT_ID+"|"+REQ_TIME; - SIGNED_MSG = crypt.sign(SIGNED_MSG, pathPfx, "123456"); - URL += "SETT_DATE="+SETT_DATE+"&SETT_NO="+SETT_NO+"&SF_TYPE="+SF_TYPE+"&USER_NAME="+USER_NAME+"&MERCHANT_ID="+MERCHANT_ID+"&REQ_TIME="+REQ_TIME+"&SIGNED_MSG="+SIGNED_MSG; - System.out.println(URL); - } catch (CryptException e) { - e.printStackTrace(); - } - BizObjectManager bm = JBOFactory.getFactory().getManager(LB_CLEAR_FILE_RECORD.CLASS_NAME); - bm.createQuery("update O set O.FULLPATH=:FULLPATH where O.id=:id").setParameter("FULLPATH", URL) - .setParameter("id", this.getId()).executeUpdate(); - return "sucess"; - } - // - public String fristCollectAudit(JBOTransaction tx) throws JBOException{ - String[] ids = id.split("@"); - StringBuffer buff = new StringBuffer(); - for (String str : ids) { - if (buff.length() == 0) { - buff.append("'"+str+"'"); - }else{ - buff.append(",'"+str+"'"); - } - } - String parm = buff.toString(); - BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); - BizObjectManager acc = JBOFactory.getFactory().getManager(CUSTOMER_ACCOUNT.CLASS_NAME); - List bolist = bm.createQuery("select v.getCustomerName(O.customer_id) as v.customer_name,O.account,O.acc_number,O.mobile,O.contract_id,O.plan_list,O.plan_date,O.COLLECT_STATUS,O.BATCH_STATUS,O.rent from O where O.id in ("+parm.toString()+")").getResultList(false); - for (BizObject bo : bolist) { - System.out.println("˻:"+bo.getAttribute("account")+",п:"+bo.getAttribute("acc_number") - +",ֻ:"+bo.getAttribute("mobile")+"ͬID:"+bo.getAttribute("contract_id")); - String name = bo.getAttribute("customer_name").toString().trim(); - BizObject ac = acc.createQuery("O.account=:account and O.acc_type = 'Debit' and O.sign_status ='Y' and O.acc_number=:acc_number and O.mobile=:mobile and O.contract_id=:contract_id") - .setParameter("account", bo.getAttribute("account").toString()) - .setParameter("acc_number", bo.getAttribute("acc_number").toString()) - .setParameter("mobile", bo.getAttribute("mobile").toString()) - .setParameter("contract_id", bo.getAttribute("contract_id").toString()) - .getSingleResult(false); - if (ac == null) { - return "error@ͻ"+name+"δǩԼ,ȽǩԼ".trim(); - } - } - BizObjectManager bmr = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); - //String today=DateTool.getToday(); - bmr.createQuery("update O set O.AUDIT_STATE = 'Y' where id in ("+parm+")").executeUpdate(); - //bmr.createQuery("update O set O.AUDIT_STATE = 'Y',CollectTime='"+today+"' where id in ("+parm+")").executeUpdate(); - return "success"; - } - - //˻ - public String rebackCollectAudit(JBOTransaction tx) throws JBOException{ - String[] ids = id.split("@"); - StringBuffer parms = new StringBuffer(); - for (String str : ids) { - if (parms.length() == 0) { - parms.append("'"+str+"'"); - }else{ - parms.append(",'"+str+"'"); - } - } - BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); - List bolist = bm.createQuery("select v.getCustomerName(O.customer_id) as v.customer_name,O.fact_rent,O.account,O.acc_number,O.mobile,O.contract_id,O.plan_list,O.plan_date,O.COLLECT_STATUS,O.BATCH_STATUS,O.rent from O where O.id in ("+parms.toString()+")").getResultList(false); - for (BizObject bo : bolist) { - String name = bo.getAttribute("customer_name").toString().trim(); - String plan_list = bo.getAttribute("plan_list").toString(); - String plan_date = bo.getAttribute("plan_date").toString(); - String batchstatus = bo.getAttribute("BATCH_STATUS").toString(); - String rent = bo.getAttribute("rent").toString(); - double fact_rent = bo.getAttribute("fact_rent").getDouble();//ʵ - double income_rent = bo.getAttribute("rent").getDouble();// - if ("process".equals(batchstatus)) {//жǷ - return "error@"+name+""+plan_list+"Ϊ"+plan_date+"ڽۿ,޷˻س".trim(); - } - if ("".equals(rent) || "0".equals(rent) || "0.0".equals(rent)) {//жʣտ - return "error@"+name+""+plan_list+"Ϊ"+plan_date+"Ѿȫȡ,޷˻س".trim(); - } - if (income_rent > 0 && (fact_rent > income_rent)) {//տ - return "error@"+name+""+plan_list+"Ϊ"+plan_date+"Ѿȡ,޷˻س".trim(); - } - } - BizObjectManager bmlrp = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); - bmlrp.createQuery("update O set O.AUDIT_STATE = 'N' where id in ("+parms.toString()+")").executeUpdate(); - - return "success"; - } - - /** - * ʵʱ - * @param tx - * @return - * @throws Exception - */ - public String barchCollectManage(JBOTransaction tx) throws Exception{ - int i = 0,j = 0; - String[] ids = id.split("@"); - StringBuffer parms = new StringBuffer(); - for (String str : ids) { - if (parms.length()==0) { - parms.append("'"+str+"'"); - }else{ - parms.append(",'"+str+"'"); - } - } - BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); - BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); - List bolist = bm.createQuery("select distinct O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,ca.ACCOUNT_PROVINCE,ca.BANK_DEPOSIT,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_info = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false); - for (BizObject bo : bolist) { - List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false); - for (BizObject code : codelist) { - String itemname = code.getAttribute("itemname").toString().trim(); - double itemdescribe = code.getAttribute("itemdescribe").getDouble(); - if (bo.getAttribute("BANK_NAME") != null && bo.getAttribute("bank_name").toString().indexOf(itemname) !=-1 && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) { - BigDecimal m = new BigDecimal(bo.getAttribute("rent").toString()); - int rent = m.multiply(new BigDecimal(100)).intValue(); - BigDecimal mi = new BigDecimal(itemdescribe); - long divide = mi.multiply(new BigDecimal(100)).longValue(); - int k = (int) Math.floor(rent/divide); - int l = (int) Math.ceil(rent%divide); - int im = 0; - for (int k2 = 1; k2 <= k; k2++) { - Map map = singleCollectMoeny(tx,bc,bo,itemdescribe+"",k2+""); - if ("0000".equals(map.get("RET_CODE"))) { - i++; - im++; - }else{ - j++; - } - } - if (l != 0) { - String surprent = String.valueOf(new DecimalFormat("#.00").format(bo.getAttribute("rent").getDouble() - k*itemdescribe)); - String hire_list = (k+1)+""; - Map map = singleCollectMoeny(tx,bc,bo,surprent,hire_list); - if ("0000".equals(map.get("RET_CODE"))) { - i++; - im++; - }else{ - j++; - } - } - if(im > 1 && ((l != 0 && im != (k+1))||(l == 0 && im != k))){ - //ո״̬ - bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS where O.id=:id") - .setParameter("COLLECT_STATUS", "տ") - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - } - }else { - Map map = singleCollectMoeny(tx,bc,bo,bo.getAttribute("rent").toString(),"1"); - if ("0000".equals(map.get("RET_CODE"))) { - i++; - }else{ - j++; - } - } - } - /*if (bo.getAttribute("BANK_NAME") != null && bo.getAttribute("bank_name").toString().indexOf("") !=-1 && Double.parseDouble(bo.getAttribute("rent").toString()) > 5000) { - BigDecimal m = new BigDecimal(bo.getAttribute("rent").toString()); - int rent = m.multiply(new BigDecimal(100)).intValue(); - int k = (int) Math.floor(rent/500000); - int l = (int) Math.ceil(rent%500000); - int im = 0; - for (int k2 = 1; k2 <= k; k2++) { - Map map = singleCollectMoeny(tx,bc,bo,"5000.00",k2+""); - if ("0000".equals(map.get("RET_CODE"))) { - i++; - im++; - }else{ - j++; - } - } - if (l != 0) { - String surprent = String.valueOf(new DecimalFormat("#.00").format(bo.getAttribute("rent").getDouble() - k*5000)); - String hire_list = (k+1)+""; - Map map = singleCollectMoeny(tx,bc,bo,surprent,hire_list); - if ("0000".equals(map.get("RET_CODE"))) { - i++; - im++; - }else{ - j++; - } - } - if(im > 1 && ((l != 0 && im != (k+1))||(l == 0 && im != k))){ - //ո״̬ - bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS where O.id=:id") - .setParameter("COLLECT_STATUS", "տ") - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - } - }else { - Map map = singleCollectMoeny(tx,bc,bo,bo.getAttribute("rent").toString(),"1"); - if ("0000".equals(map.get("RET_CODE"))) { - i++; - }else{ - j++; - } - }*/ - } - - return "ܹ "+i+" տɹ\n"+j+" տʧ"; - } - - /** - * ӿڴ - * @param tx - * @param bc - * @param bo - * @param rent - * @return - * @throws Exception - */ - public Map singleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws Exception{ - CollectAuditProcess cp = new CollectAuditProcess(); - //ļ - String currentDateTime = DateAssistant.getTodayNow(); - String currentYear = currentDateTime.substring(0,4); - String month = currentDateTime.substring(5,7); - String day = currentDateTime.substring(8,10); - String merchantNumber = InitCollectConfig.MERCHANTID; - String flag = InitCollectConfig.FLAG; - String version = InitCollectConfig.C_VERSION; - String date = currentYear+month+day;//ύ - String batch_title = ""; - int i = 0,j = 0; - //ļ· - String rootDir = this.fileSavePath; - File file = new File(rootDir + File.separator + currentYear - + File.separator + month + File.separator - + day); - System.out.println(file.getAbsolutePath()); - if(!file.exists()){//Ŀ¼ֱӴ - file.mkdirs(); - } - String req_sn = System.currentTimeMillis()+"";//κ - batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn; - BigDecimal m = new BigDecimal(rent); - String fact_rent = String.valueOf(m.multiply(new BigDecimal(100)).intValue()); - String acc_number = bo.getAttribute("ACC_NUMBER").toString(); - String account = bo.getAttribute("ACCOUNT").toString(); - String bank_code = bo.getAttribute("BANK_DEPOSIT").toString(); - String province = bo.getAttribute("ACCOUNT_PROVINCE").toString(); - StringBuffer strbuff = collectTimely(fact_rent, acc_number, account,bank_code,province, req_sn); - //Ӧ - String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title); - Map map = getRetAndCode(strResp); - if ("0000".equals(map.get("RET_CODE"))) { - i++; - }else{ - j++; - } - if (map.containsKey("RET_CODE") && "0000".equals(map.get("RET_CODE"))) { - Transaction Sqlca =null; - String cerrentDate = DateAssistant.getToday(); - JBOTransaction transaction = JBOFactory.createJBOTransaction(); - BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction); - BizObject boi = bmi.createQuery("select v.sys_guid() as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER," - + "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST," - + "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,'"+rent+"' as v.RENT,case when ("+rent+" - vl.interest_over) > 0 then ("+rent+" - vl.interest_over) else 0 end as v.CORPUS,case when ("+rent+" - vl.interest_over) > 0 then (vl.interest_over) else "+rent+" end as v.INTEREST,vl.penalty_over as v.PENALTY," - + "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id" - + " and vl.contract_id =:contract_id and vl.plan_date =:plan_date") - .setParameter("contract_id", bo.getAttribute("contract_id").toString()) - .setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false); - if (boi != null) { - // - String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST," - + " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)" - + "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"'," - + "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"'," - + "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"'," - + "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')"; - Sqlca = Transaction.createTransaction(transaction); - SqlObject asql = new SqlObject(sql); - Sqlca.executeSQL(asql); - } - transaction.commit(); - Sqlca.commit(); - } - BizObject bco = bc.createQuery("id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false); - String batch_number = bco.getAttribute("batch_number").toString(); - if ("0000".equals(map.get("RET_CODE"))){ - if (batch_number.length() == 0) { - batch_number += "׳ɹˮΪ:"+req_sn; - }else{ - batch_number += ";׳ɹˮΪ:"+req_sn; - } - }else{ - if (batch_number.length() == 0) { - batch_number += "ʧˮΪ:"+req_sn; - }else{ - batch_number += ";ʧˮΪ:"+req_sn; - } - } - //ո״̬ - bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_NUMBER=:BATCH_NUMBER where O.id=:id") - .setParameter("COLLECT_STATUS", "0000".equals(map.get("RET_CODE")) ? "տɹ" : "δտ") - .setParameter("COLLECT_MSG", map.get("ERR_MSG")) - .setParameter("BATCH_NUMBER", batch_number) - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - //ɴ̡ļ - savaFile(tx, strResp,batch_title,bo); - - return map; - } - - /** - * ֶ - * @param tx - * @param bc - * @param bo - * @param rent - * @return - * @throws JBOException - * @throws SQLException - * @throws Exception - */ - public Map handcraftsingleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws JBOException, SQLException { - String cerrentDate = DateAssistant.getToday();//ȡǰ,ʽΪ:yyyy/MM/dd - Map map = new HashMap(); - //Ϊ洢ʵ - /*JBOTransaction transaction = JBOFactory.createJBOTransaction(); - BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction); - BizObject boi = bmi.createQuery("select v.replace(v.uuid(),'-','') as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER," - + "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST," - + "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,vl.rent_over as v.RENT,vl.corpus_over as v.CORPUS,vl.interest_over as v.INTEREST,("+rent+"-vl.corpus_over-vl.interest_over) as v.PENALTY," - + "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id" - + " and vl.contract_id =:contract_id and vl.plan_date =:plan_date") - .setParameter("contract_id", bo.getAttribute("contract_id").toString()) - .setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false); - if (boi != null) { - // - String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST," - + " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)" - + "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"'," - + "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"'," - + "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"'," - + "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')"; - Transaction Sqlca =null; - Sqlca = Transaction.createTransaction(transaction); - SqlObject asql = new SqlObject(sql); - Sqlca.executeSQL(asql); - Sqlca.commit(); - } - transaction.commit();*/ - - Transaction Sqlca =null; - ASResultSet rs = null; - try { - - Sqlca = Transaction.createTransaction(tx); - String ln_contract_id = bo.getAttribute("contract_id").toString(); - String ln_plan_date = bo.getAttribute("plan_date").toString(); - String in_rent = rent; - String in_hire_list = hire_list; - String in_type = "1"; - String SQL="{call proc_insert_hexiao('"+ln_contract_id+"','"+ln_plan_date+"','"+in_rent+"','"+in_hire_list+"','"+in_type+"')} "; - SqlObject asql = new SqlObject(SQL); - rs = Sqlca.getASResultSet(asql); - } catch (Exception e) { - e.printStackTrace(); - }finally{ - if(rs != null) rs.close(); - if(Sqlca!=null)Sqlca.commit(); - } - - - - /*BizObject bco = bc.createQuery("id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false); - String batch_number = bco.getAttribute("BATCH_NO").toString(); - if (batch_number.length() == 0) { - batch_number += "ֹ:"+rent; - }else{ - batch_number += ";ֹ:"+rent; - }*/ - //ո״̬ - bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") - .setParameter("COLLECT_STATUS", "տɹ") - .setParameter("COLLECT_MSG", map.get("ERR_MSG")) - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - map.put("RET_CODE", "0000"); - return map; - } - /** - * ֶ - * @param tx - * @param bc - * @param bo - * @param rent - * @return - * @throws JBOException - * @throws SQLException - * @throws Exception - */ - public Map handcraftsingleCollectMoenyDistrbutor(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws JBOException, SQLException { - String cerrentDate = DateAssistant.getToday();//ȡǰ,ʽΪ:yyyy/MM/dd - Map map = new HashMap(); - //Ϊ洢ʵ - /*JBOTransaction transaction = JBOFactory.createJBOTransaction(); - BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction); - BizObject boi = bmi.createQuery("select v.replace(v.uuid(),'-','') as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER," - + "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST," - + "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,vl.rent_over as v.RENT,vl.corpus_over as v.CORPUS,vl.interest_over as v.INTEREST,("+rent+"-vl.corpus_over-vl.interest_over) as v.PENALTY," - + "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id" - + " and vl.contract_id =:contract_id and vl.plan_date =:plan_date") - .setParameter("contract_id", bo.getAttribute("contract_id").toString()) - .setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false); - if (boi != null) { - // - String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST," - + " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)" - + "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"'," - + "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"'," - + "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"'," - + "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')"; - Transaction Sqlca =null; - Sqlca = Transaction.createTransaction(transaction); - SqlObject asql = new SqlObject(sql); - Sqlca.executeSQL(asql); - Sqlca.commit(); - } - transaction.commit();*/ - - Transaction Sqlca =null; - ASResultSet rs = null; - try { - - Sqlca = Transaction.createTransaction(tx); - String ln_contract_id = bo.getAttribute("contract_id").toString(); - String ln_plan_date = bo.getAttribute("plan_date").toString(); - String in_rent = rent; - String in_hire_list = hire_list; - String in_type = "3"; - String SQL="{call proc_insert_hexiao('"+ln_contract_id+"','"+ln_plan_date+"','"+in_rent+"','"+in_hire_list+"','"+in_type+"')} "; - SqlObject asql = new SqlObject(SQL); - rs = Sqlca.getASResultSet(asql); - } catch (Exception e) { - e.printStackTrace(); - }finally{ - if(rs != null) rs.close(); - if(Sqlca!=null)Sqlca.commit(); - } - - - - /*BizObject bco = bc.createQuery("id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false); - String batch_number = bco.getAttribute("BATCH_NO").toString(); - if (batch_number.length() == 0) { - batch_number += "ֹ:"+rent; - }else{ - batch_number += ";ֹ:"+rent; - }*/ - //ո״̬ - /*bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") - .setParameter("COLLECT_STATUS", "տɹ") - .setParameter("COLLECT_MSG", map.get("ERR_MSG")) - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate();*/ - map.put("RET_CODE", "0000"); - return map; - } - /** - * ֶտ޸״̬, - * @param tx - * @return - * @throws Exception - */ - public String afterCollectManage(JBOTransaction tx) throws Exception{ - int i = 0,j = 0; - String[] ids = id.split("@"); - StringBuffer parms = new StringBuffer(); - for (String str : ids) { - if (parms.length()==0) { - parms.append("'"+str+"'"); - }else{ - parms.append(",'"+str+"'"); - } - } - Transaction Sqlca = Transaction.createTransaction(tx); - BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); - BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); - List bolist = bm.createQuery("select distinct O.contract_id,O.id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false); - for (BizObject bo : bolist) { - Map map = handcraftsingleCollectMoeny(tx,bc,bo,bo.getAttribute("rent").toString(),"1"); - i++; - //ո״̬ - bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") - .setParameter("COLLECT_STATUS", "ֹտ") - .setParameter("COLLECT_MSG", "ֹۿ") - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - BizObject boDDI=JBOFactory.createBizObjectQuery(D_DEPOSITRETURN_INFO.CLASS_NAME,"RENT_PLAN_ID=:rentPlanId").setParameter("rentPlanId", bo.getAttribute("id").toString()).getSingleResult(false); - if(boDDI!=null){ - this.writeBackDistributor(bo.getAttribute("id").toString(), Sqlca); - } - - - } - - return "ܹ "+i+" տɹ\n"+j+" տʧ"; - } - /** - * ֶտ޸״̬,,̱֤ - * @param tx - * @return - * @throws Exception - */ - public String afterCollectManageDistributor(JBOTransaction tx) throws Exception{ - int i = 0,j = 0; - String[] ids = id.split("@"); - String[] penaltyArray = penaltys.split("@"); - - BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME,tx); - BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,tx); - BizObjectManager bd = JBOFactory.getFactory().getManager(D_DEPOSITRETURN_INFO.CLASS_NAME,tx); - BizObjectManager bdi = JBOFactory.getFactory().getManager(DISTRIBUTOR_INFO.CLASS_NAME,tx); - - for(int c=0;c map = handcraftsingleCollectMoenyDistrbutor(tx,bc,bom,rent,penaltyArray[c]); - i++; - //ո״̬ - bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.PENALTY=:PENALTY where O.id=:id") - .setParameter("COLLECT_STATUS", "") - .setParameter("COLLECT_MSG", "̱֤") - .setParameter("PENALTY", penaltyArray[c]) - .setParameter("id", bom.getAttribute("id").toString()).executeUpdate(); - //뾭̱֤˻ر - BizObject bobdi = bdi.createQuery("distributor_no=:distributor_id").setParameter("distributor_id", distributor_id).getSingleResult(false); - BigDecimal sum = new BigDecimal(bobdi.getAttribute("sums").getString()); - double account_balance = sum.subtract(new BigDecimal(t_rent)).doubleValue(); - BizObject bod = bd.newObject(); - bod.setAttributeValue("DISTRIBUTOR_ID", distributor_id); - bod.setAttributeValue("CAUTION_MONEY", t_rent); - bod.setAttributeValue("ACCOUNT_BALANCE", account_balance); - bod.setAttributeValue("MONEY_TYPE","bondRepay"); - bod.setAttributeValue("INPUTTIME",StringFunction.getTodayNow()); - bod.setAttributeValue("INPUTUSERID",inputuserid); - bod.setAttributeValue("INPUTORGID",inputorgid); - bod.setAttributeValue("CONTRACT_ID",bom.getAttribute("contract_id").toString()); - bod.setAttributeValue("PLAN_LIST",bom.getAttribute("plan_list").toString()); - bod.setAttributeValue("RENT_PLAN_ID",bom.getAttribute("id").toString()); - bd.saveObject(bod); - //޸ľϢĽ - bdi.createQuery("update O set O.sums='"+account_balance+"' where O.distributor_no=:distributor_id").setParameter("distributor_id", distributor_id).executeUpdate(); - } - return "ܹ "+i+" տɹ\n"+j+" տʧ"; - } - private BigDecimal BigDecimal(String string) { - // TODO Auto-generated method stub - return null; - } - - private Double Double(String string) { - // TODO Auto-generated method stub - return null; - } - - /** - * ʵʱ - * @param rent - * @param acc_number п - * @param account - * @param bankcode д - * @param province пʡ - * @param req_sn ˮ - * @return - */ - public StringBuffer collectTimely(String rent,String acc_number,String account,String bankcode,String province,String req_sn){ - //ƴXML - String req = System.currentTimeMillis()+""; - StringBuffer strbuff = new StringBuffer(); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - Info info = new Info(); - info.setTRX_CODE(InitCollectConfig.C_TRXCODE); - info.setVERSION(InitCollectConfig.C_VERSION); - info.setDATA_TYPE(InitCollectConfig.C_DATATYPE); - info.setLEVEL(InitCollectConfig.C_LEVEL); - info.setUSER_NAME(InitCollectConfig.USERNAME); - info.setUSER_PASS(InitCollectConfig.USERPASS); - info.setREQ_SN(req_sn); - info.setSIGNED_MSG(""); - strbuff.append(EntityTransform.toXml(info)); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - Trans_Sum trans_sum = new Trans_Sum(); - trans_sum.setBUSINESS_CODE(InitCollectConfig.BUSSINESSCODE); - trans_sum.setMERCHANT_ID(InitCollectConfig.MERCHANTID); - trans_sum.setEXPECT_SEND_TIME(""); - trans_sum.setTOTAL_ITEM("1"); - trans_sum.setTOTAL_SUM(rent); - strbuff.append(EntityTransform.toXml(trans_sum)); - strbuff.append(""); - strbuff.append(""); - Trans_Detail trans_detail = new Trans_Detail(); - trans_detail.setSN("0001"); - trans_detail.setBANK_CODE(bankcode);//д - trans_detail.setACCOUNT_TYPE("00"); - trans_detail.setACCOUNT_NO(acc_number); - trans_detail.setACCOUNT_NAME(account); - trans_detail.setPROVINCE(province);//пʡ - trans_detail.setACCOUNT_PROP("0"); - trans_detail.setAMOUNT(rent); - trans_detail.setCURRENCY("CNY"); - trans_detail.setRECKON_ACCOUNT(""); - strbuff.append(EntityTransform.toXmlByLotCollect(trans_detail)); - strbuff.delete(strbuff.lastIndexOf(""), strbuff.length()); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - - return strbuff; - } - - /** - * - - * @param tx - * @return - * @throws Exception - */ - public String batchCollectManage(JBOTransaction tx) throws Exception{ - int i = 0,j = 0; - String[] ids = id.split("@"); - StringBuffer parms = new StringBuffer(); - for (String str : ids) { - if (parms.length()==0) { - parms.append("'"+str+"'"); - }else{ - parms.append(",'"+str+"'"); - } - } - BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); - BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); - List bolist = bm.createQuery("select distinct O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false); - if (bolist.size() != 0) { - singleBatchCollectMoeny(tx, bolist); - } - return "ϵͳڴУԺ"; - } - - /** - * ѯտ״̬ - * @return - * @throws Exception - */ - public String queryBatchCollectStatus(JBOTransaction tx) throws Exception{ - Transaction Sqlca = Transaction.createTransaction(tx); - BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); - BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); - String[] ids = id.split("@"); - StringBuffer parms = new StringBuffer(); - for (String str : ids) { - if (parms.length()==0) { - parms.append("'"+str+"'"); - }else{ - parms.append(",'"+str+"'"); - } - } - List bolist = bm.createQuery("select distinct O.BATCH_NO,O.BATCH_SN,O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false); - for (BizObject bo : bolist) { - String query_sn = bo.getAttribute("BATCH_NO").toString(); - String sn = bo.getAttribute("BATCH_SN").toString(); - String rent = bo.getAttribute("rent").toString(); - String bank_name = bo.getAttribute("BANK_NAME").toString(); - int m = 0; - String[] singleRent = null; - List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false); - for (BizObject code : codelist) { - String itemname = code.getAttribute("itemname").toString().trim(); - double itemdescribe = code.getAttribute("itemdescribe").getDouble(); - if (bank_name.indexOf(itemname) !=-1 && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) { - BigDecimal mi = new BigDecimal(bo.getAttribute("rent").toString()); - int singlerent = mi.multiply(new BigDecimal(100)).intValue(); - BigDecimal mj = new BigDecimal(itemdescribe); - long divide = mj.multiply(new BigDecimal(100)).longValue(); - if(divide!=0){ - int k = (int) Math.floor(singlerent/divide); - int l = (int) Math.ceil(singlerent%divide); - for (int j = 0; j < k; j++) { - m++; - } - if (l!=0) { - m++; - } - singleRent = new String[m]; - for (int i = 0; i < k; i++) { - singleRent[i] = itemdescribe+""; - } - singleRent[m-1] = String.format("%.2f",bo.getAttribute("rent").getDouble() - k*itemdescribe); - break;//ƥ䵽ѭ - } - } - } - String[] snArray = sn.split(","); - int n = 0;//,ۿɹ¼ - BizObject bolrp = bc.createQuery("O.id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false); - String collectStatus = "δտ"; - String collectStatusPart = "տ"; - //ָֹ - if(bolrp.getAttribute("COLLECT_STATUS")!=null){ - //жΪջΪnullǡΪ״̬ - if(bolrp.getAttribute("COLLECT_STATUS").toString().length()>1){ - collectStatus = bolrp.getAttribute("COLLECT_STATUS").toString(); - collectStatusPart = bolrp.getAttribute("COLLECT_STATUS").toString(); - } - } - for (int i = 1; i <= snArray.length; i++) { - Map map = querySingleBatchCollect(tx, bo, query_sn, snArray[(i-1)]); - if (snArray.length == 1) { - if (map.containsKey("RET_CODE") && "0000".equals(map.get("RET_CODE"))) { - querysingleCollectMoeny(tx, bc, bo, rent,i+""); - //ո״̬ - bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS where O.id=:id") - .setParameter("COLLECT_STATUS", "տ") - .setParameter("COLLECT_MSG", ",տɹ") - .setParameter("BATCH_STATUS", "complete")//״̬- - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - BizObject boDDI=JBOFactory.createBizObjectQuery(D_DEPOSITRETURN_INFO.CLASS_NAME,"RENT_PLAN_ID=:rentPlanId").setParameter("rentPlanId", id).getSingleResult(false); - if(boDDI!=null){ - this.writeBackDistributor(id,Sqlca); - } - bo.setAttributeValue("COLLECT_STATUS", "տ"); - bo.setAttributeValue("COLLECT_MSG", ",տɹ"); - bo.setAttributeValue("BATCH_STATUS", "complete"); - //bo.setAttributeValue("rent", bo.getAttribute("rent").toString()); - saveBuckle(bo,tx,sn,rent); - }else if (map.containsKey("RET_CODE") && ("2007".equals(map.get("RET_CODE")) || "2005".equals(map.get("RET_CODE")) || "2003".equals(map.get("RET_CODE")) || "2001".equals(map.get("RET_CODE")) || "2000".equals(map.get("RET_CODE")))){ - //еķϢ - bc.createQuery("update O set O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") - .setParameter("COLLECT_MSG", map.get("ERR_MSG")) - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); - saveBuckle(bo,tx,sn,"0.00"); - }else{ - //ո״̬ - bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO='',O.BATCH_SN='' where O.id=:id") - .setParameter("COLLECT_STATUS", collectStatus) - .setParameter("COLLECT_MSG", map.get("ERR_MSG")) - .setParameter("BATCH_STATUS", "")//״̬ - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - bo.setAttributeValue("COLLECT_STATUS", "δտ"); - bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); - bo.setAttributeValue("BATCH_STATUS", ""); - saveBuckle(bo,tx,sn,"0.00"); - } - }else if (snArray.length > 1) { - if (map.containsKey("RET_CODE") && "0000".equals(map.get("RET_CODE"))) { - querysingleCollectMoeny(tx, bc, bo, singleRent[i-1],i+""); - n++; - if (n == snArray.length) { - n = 0;//ۿɹ Ϊ 0 - //ո״̬ - bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS where O.id=:id") - .setParameter("COLLECT_STATUS", "տ") - .setParameter("COLLECT_MSG", ",տɹ") - .setParameter("BATCH_STATUS", "complete")//״̬- - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - BizObject boDDI=JBOFactory.createBizObjectQuery(D_DEPOSITRETURN_INFO.CLASS_NAME,"RENT_PLAN_ID=:rentPlanId").setParameter("rentPlanId", id).getSingleResult(false); - if(boDDI!=null){ - this.writeBackDistributor(id,Sqlca); - } - bo.setAttributeValue("COLLECT_STATUS", "տ"); - bo.setAttributeValue("COLLECT_MSG", ",տɹ"); - bo.setAttributeValue("BATCH_STATUS", "complete"); - //bo.setAttributeValue("rent", bo.getAttribute("rent").toString()); - saveBuckle(bo,tx,i+"",rent); - }else{ - //ո״̬ - bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS where O.id=:id") - .setParameter("COLLECT_STATUS", collectStatusPart) - .setParameter("COLLECT_MSG", map.get("ERR_MSG")) - .setParameter("BATCH_STATUS", "complete")//״̬- - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - bo.setAttributeValue("COLLECT_STATUS", "տ"); - bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); - bo.setAttributeValue("BATCH_STATUS", "complete"); - saveBuckle(bo,tx,i+"","0.00"); - } - }else if (map.containsKey("RET_CODE") && ("2007".equals(map.get("RET_CODE")) || "2005".equals(map.get("RET_CODE")) || "2003".equals(map.get("RET_CODE")) || "2001".equals(map.get("RET_CODE")) || "2000".equals(map.get("RET_CODE")))){ - //еķϢ - bc.createQuery("update O set O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") - .setParameter("COLLECT_MSG", map.get("ERR_MSG")) - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); - saveBuckle(bo,tx,i+"","0.00"); - }else{//ֶʿۿ,ۿɹδ 0 ,¿ۿ״̬Ϊ δۿ - if (i == snArray.length && n == 0) { - //ո״̬ - bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO='',O.BATCH_SN='' where O.id=:id") - .setParameter("COLLECT_STATUS", collectStatus) - .setParameter("COLLECT_MSG", map.get("ERR_MSG")) - .setParameter("BATCH_STATUS", "")//״̬ - .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - bo.setAttributeValue("COLLECT_STATUS", "δտ"); - bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); - bo.setAttributeValue("BATCH_STATUS", ""); - saveBuckle(bo,tx,i+"","0.00"); - } - } - } - if (i == snArray.length) {//ѭnΪ 0 - n = 0; - } - } - } - - return "success"; - - } - public void saveBuckle(BizObject bo,JBOTransaction tx,String batch_sn,String rent) throws JBOException{ - BizObjectManager blog = JBOFactory.getBizObjectManager(LB_BUCKLE_LOG.CLASS_NAME, tx); - BizObject blbo = blog.newObject(); - String collect = bo.getAttribute("COLLECT_STATUS").getString(); - if(collect!=""){ - blbo.setAttributeValue("COLLECT_STATUS", bo.getAttribute("COLLECT_STATUS").getString()); - blbo.setAttributeValue("COLLECT_MSG", bo.getAttribute("COLLECT_MSG").getString()); - blbo.setAttributeValue("BATCH_STATUS", bo.getAttribute("BATCH_STATUS").getString()); - } - blbo.setAttributeValue(LB_BUCKLE_LOG.BATCH_SN, batch_sn); - blbo.setAttributeValue(LB_BUCKLE_LOG.BATCH_NO, bo.getAttribute("BATCH_NO").getString()); - blbo.setAttributeValue(LB_BUCKLE_LOG.RENT_ID, bo.getAttribute("ID").getString()); - blbo.setAttributeValue(LB_BUCKLE_LOG.cut_money,rent); - blbo.setAttributeValue(LB_BUCKLE_LOG.inputuserid, "syetem"); - blbo.setAttributeValue(LB_BUCKLE_LOG.inputorgid, "system"); - blbo.setAttributeValue(LB_BUCKLE_LOG.inputtime, StringFunction.getTodayNow()); - blbo.setAttributeValue(LB_BUCKLE_LOG.updatetime, System.currentTimeMillis()); - blog.saveObject(blbo); - } - - /** - * ղѯӿ - * @param tx - * @param bo - * @param list - * @return - * @throws Exception - */ - public Map querySingleBatchCollect(JBOTransaction tx,BizObject bo,String query_sn,String sn) throws Exception{ - CollectAuditProcess cp = new CollectAuditProcess(); - //ļ - String currentDateTime = DateAssistant.getTodayNow(); - String currentYear = currentDateTime.substring(0,4); - String month = currentDateTime.substring(5,7); - String day = currentDateTime.substring(8,10); - String merchantNumber = InitCollectConfig.MERCHANTID; - String flag = InitCollectConfig.FLAG; - String version = InitCollectConfig.C_VERSION; - String date = currentYear+month+day;//ύ - String batch_title = ""; - int i = 0,j = 0; - //ļ· - String rootDir = this.fileSavePath; - File file = new File(rootDir + File.separator + currentYear - + File.separator + month + File.separator - + day); - System.out.println(file.getAbsolutePath()); - if(!file.exists()){//Ŀ¼ֱӴ - file.mkdirs(); - } - String req_sn = System.currentTimeMillis()+"";//κ - batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn; - StringBuffer strbuff = queryBatchXML(req_sn, query_sn, sn); - //Ӧ - String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title); - Map map = getRetAndCode(strResp); - //ɴ̡ļ - savaFile(tx, strResp,batch_title,bo); - - return map; - } - /** - * ѯӿ-- - * @param tx - * @param bc - * @param bo - * @param rent - * @return - * @throws Exception - */ - public Map querysingleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws Exception{ - String cerrentDate = DateAssistant.getToday(); - Map map = new HashMap(); - //Ϊ洢ʵ - /*JBOTransaction transaction = JBOFactory.createJBOTransaction(); - BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction); - BizObject boi = bmi.createQuery("select v.replace(v.uuid(),'-','') as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER," - + "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST," - + "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,vl.rent_over as v.RENT,vl.corpus_over as v.CORPUS,vl.interest_over as v.INTEREST,("+rent+"-vl.rent_over) as v.PENALTY," - + "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id" - + " and vl.contract_id =:contract_id and vl.plan_date =:plan_date") - .setParameter("contract_id", bo.getAttribute("contract_id").toString()) - .setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false); - if (boi != null) { - // - String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST," - + " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)" - + "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"'," - + "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"'," - + "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"'," - + "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')"; - Transaction Sqlca =null; - Sqlca = Transaction.createTransaction(transaction); - SqlObject asql = new SqlObject(sql); - Sqlca.executeSQL(asql); - } - transaction.commit();*/ - - Transaction Sqlca =null; - ASResultSet rs = null; - try { - - Sqlca = Transaction.createTransaction(tx); - String ln_contract_id = bo.getAttribute("contract_id").toString(); - String ln_plan_date = bo.getAttribute("plan_date").toString(); - String in_rent = rent; - String in_hire_list = hire_list; - String in_type = "2"; - String SQL="{call proc_insert_hexiao('"+ln_contract_id+"','"+ln_plan_date+"','"+in_rent+"','"+in_hire_list+"','"+in_type+"')} "; - SqlObject asql = new SqlObject(SQL); - rs = Sqlca.getASResultSet(asql); - } catch (Exception e) { - e.printStackTrace(); - }finally{ - if(rs != null) rs.close(); - if(Sqlca!=null)Sqlca.commit(); - } - - return map; - } - /** - * ѯӿڱ-xml - * @param req_sn ˮ - * @param query_sn ѯˮ - * @param sn ѯϸ - * @return - */ - public StringBuffer queryBatchXML(String req_sn,String query_sn,String sn){ - StringBuffer strbuff = new StringBuffer(); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - Info info = new Info(); - info.setTRX_CODE("200001"); - info.setVERSION(InitCollectConfig.C_VERSION); - info.setDATA_TYPE(InitCollectConfig.C_DATATYPE); - info.setREQ_SN(req_sn); - info.setUSER_NAME(InitCollectConfig.USERNAME); - info.setUSER_PASS(InitCollectConfig.USERPASS); - info.setSIGNED_MSG(""); - strbuff.append(EntityTransform.toXml(info)); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(query_sn);//ҪѯĽˮ - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(sn);//ϸ - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - return strbuff; - } - /** - * - - * @param tx - * @param bc - * @param bo - * @param rent - * @return - * @throws Exception - */ - public Map singleBatchCollectMoeny(JBOTransaction tx,List list) throws Exception{ - CollectAuditProcess cp = new CollectAuditProcess(); - //ļ - String currentDateTime = DateAssistant.getTodayNow(); - String currentYear = currentDateTime.substring(0,4); - String month = currentDateTime.substring(5,7); - String day = currentDateTime.substring(8,10); - String merchantNumber = InitCollectConfig.MERCHANTID; - String flag = InitCollectConfig.FLAG; - String version = InitCollectConfig.C_VERSION; - String date = currentYear+month+day;//ύ - String batch_title = ""; - int i = 0,j = 0; - //ļ· - String rootDir = this.fileSavePath; - File file = new File(rootDir + File.separator + currentYear - + File.separator + month + File.separator - + day); - System.out.println(file.getAbsolutePath()); - if(!file.exists()){//Ŀ¼ֱӴ - file.mkdirs(); - } - String req_sn = System.currentTimeMillis()+"";//κ - batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn; - StringBuffer strbuff = collectBatch(req_sn,list); - //Ӧ - String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title); - for (BizObject bo : list) { - //ɴ̡ļ - savaFile(tx, strResp,batch_title,bo); - } - Map map = getRetAndCodeByBatch(strResp); - if (map.containsKey("RET_CODE")) {//״̬ - for (BizObject biz : list) { - //״̬ - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") - .setParameter("BATCH_STATUS", "")// - .setParameter("BATCH_NO", req_sn) - .setParameter("BATCH_SN", "") - .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); - trans.commit(); - } - }else{ - int m = 0;//ͳƷ͵Ĵյ - for (int n = 1; n <= map.size(); n++) { - if (map.containsKey("SN"+n)) { - m++; - } - } - for (int k = 1; k <= m; k++) { - if (map.containsKey("REQ_SN") && map.containsKey("RET_CODE"+k) && "0000".equals(map.get("RET_CODE"+k))) { - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); - BizObject bo0 = bm.createQuery("O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%'").setParameter("BATCH_NO", map.get("REQ_SN")).getSingleResult(false); - if (bo0 != null && "process".equals(bo0.getAttribute("BATCH_STATUS"))) { - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS where O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%' ") - .setParameter("BATCH_STATUS", "process")//״̬Ϊ-- - .setParameter("BATCH_NO", map.get("REQ_SN")).executeUpdate(); - trans.commit(); - }else{ - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS where O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%' ") - .setParameter("BATCH_STATUS", "process")//״̬Ϊ-- - .setParameter("BATCH_NO", map.get("REQ_SN")).executeUpdate(); - trans.commit(); - } - }else{ - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); - BizObject bo0 = bm.createQuery("O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%'").setParameter("BATCH_NO", map.get("REQ_SN")).getSingleResult(false); - if (bo0 != null && "process".equals(bo0.getAttribute("BATCH_STATUS"))) { - //κβ - }else{ - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO='',O.BATCH_SN='' where O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%' ") - .setParameter("BATCH_STATUS", "")//״̬ - .setParameter("BATCH_NO", map.get("REQ_SN")).executeUpdate(); - trans.commit(); - } - } - } - } - return map; - } - - /** - * --ƴ - * @param rent - * @param acc_number - * @param account - * @param req_sn - * @return - * @throws JBOException - */ - public StringBuffer collectBatch(String req_sn,List list) throws JBOException{ - //ƴXML - //String req = System.currentTimeMillis()+""; - StringBuffer strbuff = new StringBuffer(); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - Info info = new Info(); - info.setTRX_CODE(InitCollectConfig.BATCH_TRXCODE); - info.setVERSION(InitCollectConfig.C_VERSION); - info.setDATA_TYPE(InitCollectConfig.C_DATATYPE); - info.setLEVEL(InitCollectConfig.C_LEVEL); - info.setUSER_NAME(InitCollectConfig.USERNAME); - info.setUSER_PASS(InitCollectConfig.USERPASS); - info.setREQ_SN(req_sn); - info.setSIGNED_MSG(""); - strbuff.append(EntityTransform.toXml(info)); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - BigDecimal mutly = new BigDecimal("0"); - int i = 0; - for (BizObject bo : list) { - String single = bo.getAttribute("rent").toString(); - BigDecimal m = new BigDecimal(single); - mutly = mutly.add(m); - String bank_name = bo.getAttribute("BANK_NAME").toString(); - List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false); - //ֵеitemdescribeֶδе - double itemdescribe = 0; - boolean flag = false; - for (BizObject code : codelist) { - String itemnameTmp = code.getAttribute("itemname").toString().trim(); - double itemdescribeTmp = code.getAttribute("itemdescribe").getDouble(); - String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString(); - if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) { - itemdescribe = new BigDecimal(itemdescribeTmp).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - flag = true; - break; - } - } - - if (flag == true && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) { - BigDecimal mi = new BigDecimal(bo.getAttribute("rent").toString()); - int singlerent = mi.multiply(new BigDecimal(100)).intValue(); - int singleitem = new BigDecimal(itemdescribe).multiply(new BigDecimal(100)).intValue(); - int k = (int) Math.floor(singlerent/singleitem); - int l = (int) Math.ceil(singlerent%singleitem); - for (int j = 0; j < k; j++) { - i++; - } - if (l!=0) { - i++; - } - }else{ - i++; - } - - } - String totalSum = String.valueOf(mutly.multiply(new BigDecimal(100)).longValue()); - String totalItem = String.valueOf(i); - Trans_Sum trans_sum = new Trans_Sum(); - trans_sum.setBUSINESS_CODE(InitCollectConfig.BUSSINESSCODE); - trans_sum.setMERCHANT_ID(InitCollectConfig.MERCHANTID); - trans_sum.setEXPECT_SEND_TIME(""); - trans_sum.setTOTAL_ITEM(totalItem); - trans_sum.setTOTAL_SUM(totalSum); - strbuff.append(EntityTransform.toXml(trans_sum)); - strbuff.append(""); - strbuff.append(""); - int item = 0; - for (BizObject biz : list) { - BigDecimal m = new BigDecimal(biz.getAttribute("rent").toString()); - String rent = String.valueOf(m.multiply(new BigDecimal(100)).longValue()); - String acc_number = biz.getAttribute("acc_number").toString(); - String account = biz.getAttribute("account").toString(); - String bank_name = biz.getAttribute("BANK_NAME").toString(); - List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false); - double itemdescribe = 0; - boolean flag = false; - for (BizObject code : codelist) { - String itemnameTmp = code.getAttribute("itemname").toString().trim(); - double itemdescribeTmp = code.getAttribute("itemdescribe").getDouble(); - String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString(); - if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) { - itemdescribe = new BigDecimal(itemdescribeTmp).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - flag = true; - break; - } - } - if (flag == true && Double.parseDouble(biz.getAttribute("rent").toString()) > itemdescribe) { - BigDecimal mi = new BigDecimal(biz.getAttribute("rent").toString()); - int singlerent = mi.multiply(new BigDecimal(100)).intValue(); - int singleitem = new BigDecimal(itemdescribe).multiply(new BigDecimal(100)).intValue(); - int k = (int) Math.floor(singlerent/singleitem); - int l = (int) Math.ceil(singlerent%singleitem); - for (int k2 = 1; k2 <= k; k2++) { - Trans_Detail trans_detail = new Trans_Detail(); - String sn = ""; - if (item >= 9&&item<99) { - sn = "000"+ (++item); - }else if(item >= 99){ - sn = "00"+ (++item); - }else{ - sn = "0000"+ (++item); - } - //׷״̬ - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); - BizObject bo = bm.createQuery("O.id=:id").setParameter("id", biz.getAttribute("id").toString()).getSingleResult(false); - String itemsn0 = ""; - if (bo !=null) { - String itemsn = bo.getAttribute("batch_sn").toString(); - if (itemsn.length() == 0) { - itemsn0 += sn; - }else{ - itemsn0 += itemsn+","+sn; - } - } - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") - .setParameter("BATCH_STATUS", "")//״̬-Ϊ - .setParameter("BATCH_NO", req_sn) - .setParameter("BATCH_SN", itemsn0) - .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); - trans.commit(); - trans_detail.setSN(sn); - trans_detail.setACCOUNT_TYPE(""); - trans_detail.setACCOUNT_NO(acc_number); - trans_detail.setACCOUNT_NAME(account); - trans_detail.setACCOUNT_PROP("0"); - trans_detail.setAMOUNT(String.valueOf(singleitem)); - trans_detail.setCURRENCY("CNY"); - trans_detail.setRECKON_ACCOUNT(""); - strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail)); - } - if (l != 0) { - String surprent = String.format("%.2f", biz.getAttribute("rent").getDouble() - k*itemdescribe); - BigDecimal mj = new BigDecimal(surprent); - String singlerent0 = String.valueOf(mj.multiply(new BigDecimal(100)).longValue()); - Trans_Detail trans_detail = new Trans_Detail(); - String sn = ""; - if (item >= 9&&item<99) { - sn = "000"+ (++item); - }else if(item >= 99){ - sn = "00"+ (++item); - }else{ - sn = "0000"+ (++item); - } - //׷״̬ - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); - BizObject bo = bm.createQuery("O.id=:id").setParameter("id", biz.getAttribute("id").toString()).getSingleResult(false); - String itemsn0 = ""; - if (bo !=null) { - String itemsn = bo.getAttribute("batch_sn").toString(); - if (itemsn.length() == 0) { - itemsn0 += sn; - }else{ - itemsn0 += itemsn+","+sn; - } - } - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") - .setParameter("BATCH_STATUS", "")//״̬-Ϊ - .setParameter("BATCH_NO", req_sn) - .setParameter("BATCH_SN", itemsn0) - .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); - trans.commit(); - trans_detail.setSN(sn); - trans_detail.setACCOUNT_TYPE(""); - trans_detail.setACCOUNT_NO(acc_number); - trans_detail.setACCOUNT_NAME(account); - trans_detail.setACCOUNT_PROP("0"); - trans_detail.setAMOUNT(singlerent0); - trans_detail.setCURRENCY("CNY"); - trans_detail.setRECKON_ACCOUNT(""); - strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail)); - } - }else{ - Trans_Detail trans_detail = new Trans_Detail(); - String sn = ""; - if (item >= 9&&item<99) { - sn = "000"+ (++item); - }else if(item >= 99){ - sn = "00"+ (++item); - }else{ - sn = "0000"+ (++item); - } - //׷״̬ - JBOTransaction trans = JBOFactory.createJBOTransaction(); - BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); - bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") - .setParameter("BATCH_STATUS", "")//״̬-Ϊ - .setParameter("BATCH_NO", req_sn) - .setParameter("BATCH_SN", sn) - .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); - trans.commit(); - trans_detail.setSN(sn); - trans_detail.setACCOUNT_TYPE(""); - trans_detail.setACCOUNT_NO(acc_number); - trans_detail.setACCOUNT_NAME(account); - trans_detail.setACCOUNT_PROP("0"); - trans_detail.setAMOUNT(rent); - trans_detail.setCURRENCY("CNY"); - trans_detail.setRECKON_ACCOUNT(""); - strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail)); - } - } - strbuff.delete(strbuff.lastIndexOf(""), strbuff.length()); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - - - return strbuff; - } - - /** - * ̡ļ - * @param tx - * @param strResp - * @param batch_title - * @throws Exception - */ - public void savaFile(JBOTransaction tx,String strResp,String batch_title,BizObject bo) throws Exception{ - //ļ - String currentDateTime = DateAssistant.getTodayNow(); - String currentYear = currentDateTime.substring(0,4); - String month = currentDateTime.substring(5,7); - String day = currentDateTime.substring(8,10); - //ļ· - String rootDir = this.fileSavePath; - File file = new File(rootDir + File.separator + currentYear - + File.separator + month + File.separator - + day); - System.out.println(file.getAbsolutePath()); - if(!file.exists()){//Ŀ¼ֱӴ - file.mkdirs(); - } - //ļ - BizObjectManager bm = JBOFactory.getFactory().getManager(LB_INTFACE_FILE_RECORD.CLASS_NAME); - BizObject send = bm.newObject(); - send.setAttributeValue("filepath", (file.getAbsoluteFile().toString().substring(rootDir.length())+"/"+batch_title+".txt").replace("\\", "/")); - send.setAttributeValue("fullpath", (file.getAbsoluteFile().toString()+"/"+batch_title+".txt").replace("\\", "/")); - send.setAttributeValue("filename", batch_title+".txt"); - send.setAttributeValue("FILE_TYPE", "S"); - send.setAttributeValue("RELA_ID", bo.getAttribute("id")); - send.setAttributeValue("inputuserid", this.inputuserid); - send.setAttributeValue("inputorgid", this.inputorgid); - send.setAttributeValue("inputtime", currentDateTime); - bm.saveObject(send); - //ɸѡӦϢ - Map map = getRetAndCode(strResp); - //getMsgAndCode(strResp); - - //ļ - BizObject reply = bm.newObject(); - reply.setAttributeValue("filepath", (file.getAbsoluteFile().toString().substring(rootDir.length())+"/"+batch_title+".rnt").replace("\\", "/")); - reply.setAttributeValue("fullpath", (file.getAbsoluteFile().toString()+"/"+batch_title+".rnt").replace("\\", "/")); - reply.setAttributeValue("filename", batch_title+".rnt"); - reply.setAttributeValue("feedback_code", map.get("RET_CODE")); - reply.setAttributeValue("feedback_message", map.get("ERR_MSG")); - reply.setAttributeValue("FILE_TYPE", "B"); - reply.setAttributeValue("RELA_ID", bo.getAttribute("id")); - reply.setAttributeValue("inputuserid", this.inputuserid); - reply.setAttributeValue("inputorgid", this.inputorgid); - reply.setAttributeValue("inputtime", currentDateTime); - bm.saveObject(reply); - } - - /** - * ʵʱգӦļ - * @param strXML - * @return - */ - public Map getRetAndCode(String strXML){ - Map map = new HashMap(); - Map res = new HashMap(); - Pattern pm = Pattern.compile("(?<=)([\\S\\s]*?)(?=)"); - Matcher mm = pm.matcher(strXML); - int i = 0; - while (mm.find()) - { - map.put("RET_CODE"+i++, mm.group()); - } - Pattern pc = Pattern.compile("(?<=)([\\S\\s]*?)(?=)"); - Matcher mc = pc.matcher(strXML); - int j = 0; - while (mc.find()) - { - map.put("ERR_MSG"+j++, mc.group()); - } - if (map.containsKey("RET_CODE0") && "0000".equals(map.get("RET_CODE0"))) { - if (map.containsKey("RET_CODE1") && "0000".equals(map.get("RET_CODE1"))) { - res.put("RET_CODE", map.get("RET_CODE1")); - res.put("ERR_MSG", map.get("ERR_MSG1")); - }else{ - res.put("RET_CODE", map.get("RET_CODE1")); - res.put("ERR_MSG", map.get("ERR_MSG1")); - } - }else{ - res.put("RET_CODE", map.get("RET_CODE0")); - res.put("ERR_MSG", map.get("ERR_MSG0")); - } - return res; - } - - /** - * -رĴ - * @param strXML - * @return - */ - public Map getRetAndCodeByBatch(String strXML){ - Map map = new HashMap(); - Map res = new HashMap(); - System.out.println(1); - int iStart = strXML.indexOf(""); - if (iStart != -1) { - int end = strXML.indexOf(""); - String errMsg = strXML.substring(iStart+9, end); - map.put("ERR_MSG", errMsg); - } - int kStart = strXML.indexOf(""); - if (kStart != -1) { - int end = strXML.indexOf(""); - String reqSn = strXML.substring(kStart+8, end); - map.put("REQ_SN", reqSn); - } - - Pattern pm = Pattern.compile("(?<=)([\\S\\s]*?)(?=)"); - Matcher mm = pm.matcher(strXML); - int i = 0; - while (mm.find()) - { - map.put("RET_CODE"+i++, mm.group()); - } - Pattern pc = Pattern.compile("(?<=)([\\S\\s]*?)(?=)"); - Matcher mc = pc.matcher(strXML); - int j = 1; - while (mc.find()) - { - map.put("SN"+j++, mc.group()); - } - if (map.containsKey("RET_CODE0") && "0000".equals(map.get("RET_CODE0"))) { - res.putAll(map); - res.remove("RET_CODE0"); - res.remove("ERR_MSG"); - }else{ - res.put("RET_CODE", map.get("RET_CODE0")); - res.put("ERR_MSG", map.get("ERR_MSG0")); - } - return res; - } - - public Map getMsgAndCode(String strXML){ - Map map = new HashMap(); - int iStart = strXML.indexOf(""); - if (iStart != -1) { - int end = strXML.indexOf(""); - String strMsg = strXML.substring(iStart+9, end); - map.put("ERR_MSG", strMsg); - } - int jStart = strXML.indexOf(""); - if (jStart != -1) { - int end = strXML.indexOf(""); - String strMsg = strXML.substring(jStart+10, end); - map.put("RET_CODE", strMsg); - } - return map; - } - - /** - * ȡӦ - * @param strXML - * @return - */ - public Map getInfoAndStatus(String strXML){ - Map map = new HashMap(); - Map res = new HashMap(); - - int jStart = strXML.indexOf(""); - if (jStart != -1) { - int end = strXML.indexOf(""); - String retCode = strXML.substring(jStart+10, end); - map.put("RET_CODE", retCode); - } - int iStart = strXML.indexOf(""); - if (iStart != -1) { - int end = strXML.indexOf(""); - String errMsg = strXML.substring(iStart+9, end); - map.put("ERR_MSG", errMsg); - } - - int kStart = strXML.indexOf(""); - if (kStart != -1) { - int end = strXML.indexOf(""); - String errMsg = strXML.substring(kStart+14, end); - map.put("TRANS_STATUS", errMsg); - } - int lStart = strXML.indexOf(""); - if (lStart != -1) { - int end = strXML.indexOf(""); - String retCode = strXML.substring(lStart+12, end); - map.put("TRANS_INFO", retCode); - } - if (map.containsKey("RET_CODE") && map.get("RET_CODE").equals("0000")) { - if (map.containsKey("TRANS_STATUS") && map.get("TRANS_STATUS").equals("0000")) { - res.put("RET_CODE", map.get("TRANS_STATUS")); - res.put("ERR_MSG", map.get("TRANS_INFO")); - }else{ - res.put("RET_CODE", map.get("TRANS_STATUS")); - res.put("ERR_MSG", map.get("TRANS_INFO")); - } - }else{ - res.put("RET_CODE", map.get("RET_CODE")); - res.put("ERR_MSG", map.get("ERR_MSG")); - } - return res; - } - //֤пҪ - public Map vitfyCollectManage(Map map) throws CryptException{ - CollectAuditProcess cp = new CollectAuditProcess(); - String currentDateTime = DateAssistant.getTodayNow(); - String currenttime=currentDateTime.replaceAll("/", ""); - currenttime=currenttime.replaceAll(":", ""); - //ʱ - currenttime=currenttime.replaceAll(" ", ""); - //֤пҪ - //ˮ - String req = System.currentTimeMillis()+""; - StringBuffer strbuff = new StringBuffer(); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - Info info = new Info(); - /*info.setTRX_CODE("100039"); - info.setVERSION("03"); - info.setDATA_TYPE("2"); - info.setLEVEL("5"); - info.setUSER_NAME("00019140020764901"); - info.setUSER_PASS("TPSHauto123.");*/ - info.setTRX_CODE(InitCollectConfig.B_TRXCODE); - info.setVERSION(InitCollectConfig.B_VERSION); - info.setDATA_TYPE(InitCollectConfig.B_DATATYPE); - info.setLEVEL(InitCollectConfig.B_LEVEL); - info.setUSER_NAME(InitCollectConfig.USERNAME); - info.setUSER_PASS(InitCollectConfig.USERPASS); - info.setREQ_SN(req); - info.setSIGNED_MSG(""); - strbuff.append(EntityTransform.toXml(info)); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(currenttime);//ʱ - strbuff.append(""); - strbuff.append(""); - strbuff.append(InitCollectConfig.MERCHANTID);//̻ - /*strbuff.append("000191400207649");//̻ -*/ strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(map.get("ACCOUNT_NO"));// - strbuff.append(""); - strbuff.append(""); - strbuff.append(map.get("ACCOUNT_NAME"));// - strbuff.append(""); - //жǷ - if (map.containsKey("ID_TYPE")) { - strbuff.append(""); - strbuff.append(map.get("ID_TYPE"));//֤ - strbuff.append(""); - } - if (map.containsKey("ID")) { - strbuff.append(""); - strbuff.append(map.get("ID"));//֤ - strbuff.append(""); - } - if (map.containsKey("TEL")) { - strbuff.append(""); - strbuff.append(map.get("TEL"));//ֻ - strbuff.append(""); - } - strbuff.append(""); - strbuff.append("");//ǿЧ - strbuff.append(""); - strbuff.append(""); - strbuff.append("");//ǿCV2 - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - strbuff.append(""); - String strResp = cp.CollectAuditVerifyReq(strbuff); - return getInfoAndStatus(strResp); - } - - - public String getInputuserid() { - return inputuserid; - } - - public void setInputuserid(String inputuserid) { - this.inputuserid = inputuserid; - } - - public String getInputorgid() { - return inputorgid; - } - - public void setInputorgid(String inputorgid) { - this.inputorgid = inputorgid; - } - - public String getFileSavePath() { - return fileSavePath; - } - - public void setFileSavePath(String fileSavePath) { - this.fileSavePath = fileSavePath; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - public String getClearDate() { - return clearDate; - } - public void setClearDate(String clearDate) { - this.clearDate = clearDate; - } - public String getDistributor_id() { - return distributor_id; - } - public void setDistributor_id(String distributor_id) { - this.distributor_id = distributor_id; - } - public String getPenaltys() { - return penaltys; - } - public void setPenaltys(String penaltys) { - this.penaltys = penaltys; - } - - -} +package com.tenwa.collectaudit.cache; + +import java.io.File; +import java.math.BigDecimal; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.springframework.jdbc.object.SqlCall; + +import jbo.app.tenwa.calc.LC_RENT_PLAN; +import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT; +import jbo.app.tenwa.customer.DISTRIBUTOR_INFO; +import jbo.com.tenwa.entity.comm.flow.D_DEPOSITCHARGE_INFO; +import jbo.com.tenwa.entity.comm.flow.D_DEPOSITRETURN_INFO; +import jbo.com.tenwa.lease.comm.LB_BUCKLE_LOG; +import jbo.com.tenwa.lease.comm.LB_CLEAR_FILE_RECORD; +import jbo.com.tenwa.lease.comm.LB_INTFACE_FILE_RECORD; +import jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN; +import jbo.sys.CODE_LIBRARY; + +import com.amarsoft.app.als.sys.tools.DateTool; +import com.amarsoft.app.awe.config.InitCollectConfig; +import com.amarsoft.app.util.StringUtil; +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.ASResultSet; +import com.amarsoft.awe.util.SqlObject; +import com.amarsoft.awe.util.Transaction; +import com.gnete.security.crypt.Crypt; +import com.gnete.security.crypt.CryptException; +import com.ibm.sslight.tools.mainExit; +import com.tenwa.comm.util.date.DateAssistant; +import com.tenwa.comm.util.jboutil.DataOperatorUtil; + +public class CollectAuditInfoCache { + + private String id; + private String fileSavePath = "d:/tmp/als/InterFace"; + private String inputuserid; + private String inputorgid; + private String clearDate; + private String distributor_id; + private String penaltys; + + /** + * ̱֤ + * ƻIDڱ֤ȡΪdepositcharge_id˻رΪRENT_PLAN_ID + * @param depositcharge_id,tx + * @return + * @throws Exception + */ + public void writeBackDistributor(String RENT_PLAN_ID,Transaction Sqlca) throws JBOException{ + BizObjectManager bmDCI = JBOFactory.getFactory().getManager(D_DEPOSITCHARGE_INFO.CLASS_NAME); + BizObjectManager bmDRI = JBOFactory.getFactory().getManager(D_DEPOSITRETURN_INFO.CLASS_NAME); + BizObjectManager bmDI = JBOFactory.getFactory().getManager(DISTRIBUTOR_INFO.CLASS_NAME); + BizObject bDRI= bmDRI.createQuery("RENT_PLAN_ID=:RENT_PLAN_ID").setParameter("RENT_PLAN_ID", RENT_PLAN_ID).getSingleResult(false); + String distributorId = bDRI.getAttribute("DISTRIBUTOR_ID").toString(); + String cautionMoney = bDRI.getAttribute("CAUTION_MONEY").toString(); + //D_DEPOSITCHARGE_INFO + BizObject bDCI_N = bmDCI.newObject(); + bDCI_N.setAttributeValue("DISTRIBUTOR_ID", distributorId); + bDCI_N.setAttributeValue("CAUTION_MONEY", cautionMoney); + bDCI_N.setAttributeValue("MONEY_TYPE","bondBack"); + bDCI_N.setAttributeValue("INPUTTIME",StringFunction.getTodayNow()); + bDCI_N.setAttributeValue("INPUTUSERID",inputuserid); + bDCI_N.setAttributeValue("INPUTORGID",inputorgid); + bDCI_N.setAttributeValue("RENT_PLAN_ID",RENT_PLAN_ID); + bmDCI.saveObject(bDCI_N); + //޸ľϢĽ + BizObject bDI = bmDI.createQuery("distributor_no=:distributor_id").setParameter("distributor_id", distributorId).getSingleResult(false); + BigDecimal sum = new BigDecimal(bDI.getAttribute("sums").getString()); + double account_balance = sum.add(new BigDecimal(cautionMoney)).doubleValue(); + bmDI.createQuery("update O set O.sums='"+account_balance+"' where O.distributor_no=:distributor_id").setParameter("distributor_id", distributorId).executeUpdate(); + System.out.println("ɹ"); + } + + //ȡļ + public static String getCollectIntface(String id) throws Exception{ + + String sql="select lr.filename from LB_INTFACE_FILE_RECORD lr " + + "where lr.id=:id"; + Map map=new HashMap(); + map.put("id", id); + JBOTransaction tx = null; + String filename=""; + tx=JBOFactory.createJBOTransaction(); + List> list=DataOperatorUtil.getDataBySql(tx, sql, map); + if(list.size()>0){ + filename=StringUtil.nullToString(list.get(0).get("FILENAME")) ; + } + tx.commit(); + return filename; + } + //УǷѾտ + public String checkRentIsIncome(JBOTransaction tx) throws JBOException{ + String[] ids = id.split("@"); + StringBuffer parms = new StringBuffer(); + for (String str : ids) { + if (parms.length()==0) { + parms.append("'"+str+"'"); + }else{ + parms.append(",'"+str+"'"); + } + } + BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME,tx); + List bolist = bm.createQuery("select v.getCustomerName(O.customer_id) as v.customer_name,O.account,O.acc_number,O.mobile,O.contract_id,O.plan_list,O.plan_date,O.COLLECT_STATUS,O.BATCH_STATUS,O.rent from O where O.id in ("+parms.toString()+")").getResultList(false); + for (BizObject bo : bolist) { + String name = bo.getAttribute("customer_name").toString().trim(); + String plan_list = bo.getAttribute("plan_list").toString(); + String plan_date = bo.getAttribute("plan_date").toString(); + String batchstatus = bo.getAttribute("BATCH_STATUS").toString(); + String rent = bo.getAttribute("rent").toString(); + if ("process".equals(batchstatus)) {//жǷ + return "error@"+name+""+plan_list+"Ϊ"+plan_date+"ڽۿ".trim(); + } + if ("".equals(rent) || "0".equals(rent) || "0.0".equals(rent)) {//жʣտ + return "error@"+name+""+plan_list+"Ϊ"+plan_date+"Ѿȫȡ,޷ٴοۿ".trim(); + } + } + return "sucess"; + } + //ϴļ + public String uploadClearFile(JBOTransaction tx) throws JBOException{ + String currentDateTime = DateAssistant.getTodayNow(); + String currenttime=currentDateTime.replaceAll("/", ""); + currenttime=currenttime.replaceAll(":", ""); + currenttime=currenttime.replaceAll(" ", ""); + //String SETT_DATE = "20170920"; + String SETT_DATE = this.getClearDate() != null ? this.getClearDate().replace("/", "") : ""; + String SETT_NO = "01"; + String SF_TYPE = InitCollectConfig.FLAG; + String USER_NAME = InitCollectConfig.USERNAME; + String MERCHANT_ID = InitCollectConfig.MERCHANTID; + String REQ_TIME = currenttime; + //String URL = "http://59.41.103.98:333/gzdsf/GetSettFile.do?"; + String URL = InitCollectConfig.CLEARREQUESTURL+"?"; + String SIGNED_MSG = ""; + try { + Crypt crypt = new Crypt("gbk"); + String pathPfx = InitCollectConfig.PRIVATEKEYURL; + //"D:\\BaiduNetdisk\\Download\\ոϵͳӿĵJAVAdemoز\\JAVADEMOԲ_20170825\\̻֤\\ORA@TEST1.p12"; + SIGNED_MSG = SETT_DATE+"|"+SETT_NO+"|"+USER_NAME+"|"+MERCHANT_ID+"|"+REQ_TIME; + SIGNED_MSG = crypt.sign(SIGNED_MSG, pathPfx, "123456"); + URL += "SETT_DATE="+SETT_DATE+"&SETT_NO="+SETT_NO+"&SF_TYPE="+SF_TYPE+"&USER_NAME="+USER_NAME+"&MERCHANT_ID="+MERCHANT_ID+"&REQ_TIME="+REQ_TIME+"&SIGNED_MSG="+SIGNED_MSG; + System.out.println(URL); + } catch (CryptException e) { + e.printStackTrace(); + } + BizObjectManager bm = JBOFactory.getFactory().getManager(LB_CLEAR_FILE_RECORD.CLASS_NAME); + bm.createQuery("update O set O.FULLPATH=:FULLPATH where O.id=:id").setParameter("FULLPATH", URL) + .setParameter("id", this.getId()).executeUpdate(); + return "sucess"; + } + // + public String fristCollectAudit(JBOTransaction tx) throws JBOException{ + String[] ids = id.split("@"); + StringBuffer buff = new StringBuffer(); + for (String str : ids) { + if (buff.length() == 0) { + buff.append("'"+str+"'"); + }else{ + buff.append(",'"+str+"'"); + } + } + String parm = buff.toString(); + BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); + BizObjectManager acc = JBOFactory.getFactory().getManager(CUSTOMER_ACCOUNT.CLASS_NAME); + List bolist = bm.createQuery("select v.getCustomerName(O.customer_id) as v.customer_name,O.account,O.acc_number,O.mobile,O.contract_id,O.plan_list,O.plan_date,O.COLLECT_STATUS,O.BATCH_STATUS,O.rent from O where O.id in ("+parm.toString()+")").getResultList(false); + for (BizObject bo : bolist) { + System.out.println("˻:"+bo.getAttribute("account")+",п:"+bo.getAttribute("acc_number") + +",ֻ:"+bo.getAttribute("mobile")+"ͬID:"+bo.getAttribute("contract_id")); + String name = bo.getAttribute("customer_name").toString().trim(); + BizObject ac = acc.createQuery("O.account=:account and O.acc_type = 'Debit' and O.sign_status ='Y' and O.acc_number=:acc_number and O.mobile=:mobile and O.contract_id=:contract_id") + .setParameter("account", bo.getAttribute("account").toString()) + .setParameter("acc_number", bo.getAttribute("acc_number").toString()) + .setParameter("mobile", bo.getAttribute("mobile").toString()) + .setParameter("contract_id", bo.getAttribute("contract_id").toString()) + .getSingleResult(false); + if (ac == null) { + return "error@ͻ"+name+"δǩԼ,ȽǩԼ".trim(); + } + } + BizObjectManager bmr = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); + //String today=DateTool.getToday(); + bmr.createQuery("update O set O.AUDIT_STATE = 'Y' where id in ("+parm+")").executeUpdate(); + //bmr.createQuery("update O set O.AUDIT_STATE = 'Y',CollectTime='"+today+"' where id in ("+parm+")").executeUpdate(); + return "success"; + } + + //˻ + public String rebackCollectAudit(JBOTransaction tx) throws JBOException{ + String[] ids = id.split("@"); + StringBuffer parms = new StringBuffer(); + for (String str : ids) { + if (parms.length() == 0) { + parms.append("'"+str+"'"); + }else{ + parms.append(",'"+str+"'"); + } + } + BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); + List bolist = bm.createQuery("select v.getCustomerName(O.customer_id) as v.customer_name,O.fact_rent,O.account,O.acc_number,O.mobile,O.contract_id,O.plan_list,O.plan_date,O.COLLECT_STATUS,O.BATCH_STATUS,O.rent from O where O.id in ("+parms.toString()+")").getResultList(false); + for (BizObject bo : bolist) { + String name = bo.getAttribute("customer_name").toString().trim(); + String plan_list = bo.getAttribute("plan_list").toString(); + String plan_date = bo.getAttribute("plan_date").toString(); + String batchstatus = bo.getAttribute("BATCH_STATUS").toString(); + String rent = bo.getAttribute("rent").toString(); + double fact_rent = bo.getAttribute("fact_rent").getDouble();//ʵ + double income_rent = bo.getAttribute("rent").getDouble();// + if ("process".equals(batchstatus)) {//жǷ + return "error@"+name+""+plan_list+"Ϊ"+plan_date+"ڽۿ,޷˻س".trim(); + } + if ("".equals(rent) || "0".equals(rent) || "0.0".equals(rent)) {//жʣտ + return "error@"+name+""+plan_list+"Ϊ"+plan_date+"Ѿȫȡ,޷˻س".trim(); + } + if (income_rent > 0 && (fact_rent > income_rent)) {//տ + return "error@"+name+""+plan_list+"Ϊ"+plan_date+"Ѿȡ,޷˻س".trim(); + } + } + BizObjectManager bmlrp = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); + bmlrp.createQuery("update O set O.AUDIT_STATE = 'N' where id in ("+parms.toString()+")").executeUpdate(); + + return "success"; + } + + /** + * ʵʱ + * @param tx + * @return + * @throws Exception + */ + public String barchCollectManage(JBOTransaction tx) throws Exception{ + int i = 0,j = 0; + String[] ids = id.split("@"); + StringBuffer parms = new StringBuffer(); + for (String str : ids) { + if (parms.length()==0) { + parms.append("'"+str+"'"); + }else{ + parms.append(",'"+str+"'"); + } + } + BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); + BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); + List bolist = bm.createQuery("select distinct O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,ca.ACCOUNT_PROVINCE,ca.BANK_DEPOSIT,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_info = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false); + for (BizObject bo : bolist) { + List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false); + for (BizObject code : codelist) { + String itemname = code.getAttribute("itemname").toString().trim(); + double itemdescribe = code.getAttribute("itemdescribe").getDouble(); + if (bo.getAttribute("BANK_NAME") != null && bo.getAttribute("bank_name").toString().indexOf(itemname) !=-1 && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) { + BigDecimal m = new BigDecimal(bo.getAttribute("rent").toString()); + int rent = m.multiply(new BigDecimal(100)).intValue(); + BigDecimal mi = new BigDecimal(itemdescribe); + long divide = mi.multiply(new BigDecimal(100)).longValue(); + int k = (int) Math.floor(rent/divide); + int l = (int) Math.ceil(rent%divide); + int im = 0; + for (int k2 = 1; k2 <= k; k2++) { + Map map = singleCollectMoeny(tx,bc,bo,itemdescribe+"",k2+""); + if ("0000".equals(map.get("RET_CODE"))) { + i++; + im++; + }else{ + j++; + } + } + if (l != 0) { + String surprent = String.valueOf(new DecimalFormat("#.00").format(bo.getAttribute("rent").getDouble() - k*itemdescribe)); + String hire_list = (k+1)+""; + Map map = singleCollectMoeny(tx,bc,bo,surprent,hire_list); + if ("0000".equals(map.get("RET_CODE"))) { + i++; + im++; + }else{ + j++; + } + } + if(im > 1 && ((l != 0 && im != (k+1))||(l == 0 && im != k))){ + //ո״̬ + bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS where O.id=:id") + .setParameter("COLLECT_STATUS", "տ") + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + } + }else { + Map map = singleCollectMoeny(tx,bc,bo,bo.getAttribute("rent").toString(),"1"); + if ("0000".equals(map.get("RET_CODE"))) { + i++; + }else{ + j++; + } + } + } + /*if (bo.getAttribute("BANK_NAME") != null && bo.getAttribute("bank_name").toString().indexOf("") !=-1 && Double.parseDouble(bo.getAttribute("rent").toString()) > 5000) { + BigDecimal m = new BigDecimal(bo.getAttribute("rent").toString()); + int rent = m.multiply(new BigDecimal(100)).intValue(); + int k = (int) Math.floor(rent/500000); + int l = (int) Math.ceil(rent%500000); + int im = 0; + for (int k2 = 1; k2 <= k; k2++) { + Map map = singleCollectMoeny(tx,bc,bo,"5000.00",k2+""); + if ("0000".equals(map.get("RET_CODE"))) { + i++; + im++; + }else{ + j++; + } + } + if (l != 0) { + String surprent = String.valueOf(new DecimalFormat("#.00").format(bo.getAttribute("rent").getDouble() - k*5000)); + String hire_list = (k+1)+""; + Map map = singleCollectMoeny(tx,bc,bo,surprent,hire_list); + if ("0000".equals(map.get("RET_CODE"))) { + i++; + im++; + }else{ + j++; + } + } + if(im > 1 && ((l != 0 && im != (k+1))||(l == 0 && im != k))){ + //ո״̬ + bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS where O.id=:id") + .setParameter("COLLECT_STATUS", "տ") + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + } + }else { + Map map = singleCollectMoeny(tx,bc,bo,bo.getAttribute("rent").toString(),"1"); + if ("0000".equals(map.get("RET_CODE"))) { + i++; + }else{ + j++; + } + }*/ + } + + return "ܹ "+i+" տɹ\n"+j+" տʧ"; + } + + /** + * ӿڴ + * @param tx + * @param bc + * @param bo + * @param rent + * @return + * @throws Exception + */ + public Map singleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws Exception{ + CollectAuditProcess cp = new CollectAuditProcess(); + //ļ + String currentDateTime = DateAssistant.getTodayNow(); + String currentYear = currentDateTime.substring(0,4); + String month = currentDateTime.substring(5,7); + String day = currentDateTime.substring(8,10); + String merchantNumber = InitCollectConfig.MERCHANTID; + String flag = InitCollectConfig.FLAG; + String version = InitCollectConfig.C_VERSION; + String date = currentYear+month+day;//ύ + String batch_title = ""; + int i = 0,j = 0; + //ļ· + String rootDir = this.fileSavePath; + File file = new File(rootDir + File.separator + currentYear + + File.separator + month + File.separator + + day); + System.out.println(file.getAbsolutePath()); + if(!file.exists()){//Ŀ¼ֱӴ + file.mkdirs(); + } + String req_sn = System.currentTimeMillis()+"";//κ + batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn; + BigDecimal m = new BigDecimal(rent); + String fact_rent = String.valueOf(m.multiply(new BigDecimal(100)).intValue()); + String acc_number = bo.getAttribute("ACC_NUMBER").toString(); + String account = bo.getAttribute("ACCOUNT").toString(); + String bank_code = bo.getAttribute("BANK_DEPOSIT").toString(); + String province = bo.getAttribute("ACCOUNT_PROVINCE").toString(); + StringBuffer strbuff = collectTimely(fact_rent, acc_number, account,bank_code,province, req_sn); + //Ӧ + String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title); + Map map = getRetAndCode(strResp); + if ("0000".equals(map.get("RET_CODE"))) { + i++; + }else{ + j++; + } + if (map.containsKey("RET_CODE") && "0000".equals(map.get("RET_CODE"))) { + Transaction Sqlca =null; + String cerrentDate = DateAssistant.getToday(); + JBOTransaction transaction = JBOFactory.createJBOTransaction(); + BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction); + BizObject boi = bmi.createQuery("select v.sys_guid() as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER," + + "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST," + + "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,'"+rent+"' as v.RENT,case when ("+rent+" - vl.interest_over) > 0 then ("+rent+" - vl.interest_over) else 0 end as v.CORPUS,case when ("+rent+" - vl.interest_over) > 0 then (vl.interest_over) else "+rent+" end as v.INTEREST,vl.penalty_over as v.PENALTY," + + "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id" + + " and vl.contract_id =:contract_id and vl.plan_date =:plan_date") + .setParameter("contract_id", bo.getAttribute("contract_id").toString()) + .setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false); + if (boi != null) { + // + String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST," + + " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)" + + "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"'," + + "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"'," + + "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"'," + + "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')"; + Sqlca = Transaction.createTransaction(transaction); + SqlObject asql = new SqlObject(sql); + Sqlca.executeSQL(asql); + } + transaction.commit(); + Sqlca.commit(); + } + BizObject bco = bc.createQuery("id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false); + String batch_number = bco.getAttribute("batch_number").toString(); + if ("0000".equals(map.get("RET_CODE"))){ + if (batch_number.length() == 0) { + batch_number += "׳ɹˮΪ:"+req_sn; + }else{ + batch_number += ";׳ɹˮΪ:"+req_sn; + } + }else{ + if (batch_number.length() == 0) { + batch_number += "ʧˮΪ:"+req_sn; + }else{ + batch_number += ";ʧˮΪ:"+req_sn; + } + } + //ո״̬ + bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_NUMBER=:BATCH_NUMBER where O.id=:id") + .setParameter("COLLECT_STATUS", "0000".equals(map.get("RET_CODE")) ? "տɹ" : "δտ") + .setParameter("COLLECT_MSG", map.get("ERR_MSG")) + .setParameter("BATCH_NUMBER", batch_number) + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + //ɴ̡ļ + savaFile(tx, strResp,batch_title,bo); + + return map; + } + + /** + * ֶ + * @param tx + * @param bc + * @param bo + * @param rent + * @return + * @throws JBOException + * @throws SQLException + * @throws Exception + */ + public Map handcraftsingleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws JBOException, SQLException { + String cerrentDate = DateAssistant.getToday();//ȡǰ,ʽΪ:yyyy/MM/dd + Map map = new HashMap(); + //Ϊ洢ʵ + /*JBOTransaction transaction = JBOFactory.createJBOTransaction(); + BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction); + BizObject boi = bmi.createQuery("select v.replace(v.uuid(),'-','') as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER," + + "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST," + + "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,vl.rent_over as v.RENT,vl.corpus_over as v.CORPUS,vl.interest_over as v.INTEREST,("+rent+"-vl.corpus_over-vl.interest_over) as v.PENALTY," + + "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id" + + " and vl.contract_id =:contract_id and vl.plan_date =:plan_date") + .setParameter("contract_id", bo.getAttribute("contract_id").toString()) + .setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false); + if (boi != null) { + // + String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST," + + " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)" + + "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"'," + + "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"'," + + "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"'," + + "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')"; + Transaction Sqlca =null; + Sqlca = Transaction.createTransaction(transaction); + SqlObject asql = new SqlObject(sql); + Sqlca.executeSQL(asql); + Sqlca.commit(); + } + transaction.commit();*/ + + Transaction Sqlca =null; + ASResultSet rs = null; + try { + + Sqlca = Transaction.createTransaction(tx); + String ln_contract_id = bo.getAttribute("contract_id").toString(); + String ln_plan_date = bo.getAttribute("plan_date").toString(); + String in_rent = rent; + String in_hire_list = hire_list; + String in_type = "1"; + String SQL="{call proc_insert_hexiao('"+ln_contract_id+"','"+ln_plan_date+"','"+in_rent+"','"+in_hire_list+"','"+in_type+"')} "; + SqlObject asql = new SqlObject(SQL); + rs = Sqlca.getASResultSet(asql); + } catch (Exception e) { + e.printStackTrace(); + }finally{ + if(rs != null) rs.close(); + if(Sqlca!=null)Sqlca.commit(); + } + + + + /*BizObject bco = bc.createQuery("id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false); + String batch_number = bco.getAttribute("BATCH_NO").toString(); + if (batch_number.length() == 0) { + batch_number += "ֹ:"+rent; + }else{ + batch_number += ";ֹ:"+rent; + }*/ + //ո״̬ + bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") + .setParameter("COLLECT_STATUS", "տɹ") + .setParameter("COLLECT_MSG", map.get("ERR_MSG")) + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + map.put("RET_CODE", "0000"); + return map; + } + /** + * ֶ + * @param tx + * @param bc + * @param bo + * @param rent + * @return + * @throws JBOException + * @throws SQLException + * @throws Exception + */ + public Map handcraftsingleCollectMoenyDistrbutor(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws JBOException, SQLException { + String cerrentDate = DateAssistant.getToday();//ȡǰ,ʽΪ:yyyy/MM/dd + Map map = new HashMap(); + //Ϊ洢ʵ + /*JBOTransaction transaction = JBOFactory.createJBOTransaction(); + BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction); + BizObject boi = bmi.createQuery("select v.replace(v.uuid(),'-','') as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER," + + "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST," + + "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,vl.rent_over as v.RENT,vl.corpus_over as v.CORPUS,vl.interest_over as v.INTEREST,("+rent+"-vl.corpus_over-vl.interest_over) as v.PENALTY," + + "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id" + + " and vl.contract_id =:contract_id and vl.plan_date =:plan_date") + .setParameter("contract_id", bo.getAttribute("contract_id").toString()) + .setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false); + if (boi != null) { + // + String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST," + + " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)" + + "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"'," + + "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"'," + + "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"'," + + "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')"; + Transaction Sqlca =null; + Sqlca = Transaction.createTransaction(transaction); + SqlObject asql = new SqlObject(sql); + Sqlca.executeSQL(asql); + Sqlca.commit(); + } + transaction.commit();*/ + + Transaction Sqlca =null; + ASResultSet rs = null; + try { + + Sqlca = Transaction.createTransaction(tx); + String ln_contract_id = bo.getAttribute("contract_id").toString(); + String ln_plan_date = bo.getAttribute("plan_date").toString(); + String in_rent = rent; + String in_hire_list = hire_list; + String in_type = "3"; + String SQL="{call proc_insert_hexiao('"+ln_contract_id+"','"+ln_plan_date+"','"+in_rent+"','"+in_hire_list+"','"+in_type+"')} "; + SqlObject asql = new SqlObject(SQL); + rs = Sqlca.getASResultSet(asql); + } catch (Exception e) { + e.printStackTrace(); + }finally{ + if(rs != null) rs.close(); + if(Sqlca!=null)Sqlca.commit(); + } + + + + /*BizObject bco = bc.createQuery("id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false); + String batch_number = bco.getAttribute("BATCH_NO").toString(); + if (batch_number.length() == 0) { + batch_number += "ֹ:"+rent; + }else{ + batch_number += ";ֹ:"+rent; + }*/ + //ո״̬ + /*bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") + .setParameter("COLLECT_STATUS", "տɹ") + .setParameter("COLLECT_MSG", map.get("ERR_MSG")) + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate();*/ + map.put("RET_CODE", "0000"); + return map; + } + /** + * ֶտ޸״̬, + * @param tx + * @return + * @throws Exception + */ + public String afterCollectManage(JBOTransaction tx) throws Exception{ + int i = 0,j = 0; + String[] ids = id.split("@"); + StringBuffer parms = new StringBuffer(); + for (String str : ids) { + if (parms.length()==0) { + parms.append("'"+str+"'"); + }else{ + parms.append(",'"+str+"'"); + } + } + Transaction Sqlca = Transaction.createTransaction(tx); + BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); + BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); + List bolist = bm.createQuery("select distinct O.contract_id,O.id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false); + for (BizObject bo : bolist) { + Map map = handcraftsingleCollectMoeny(tx,bc,bo,bo.getAttribute("rent").toString(),"1"); + i++; + //ո״̬ + bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") + .setParameter("COLLECT_STATUS", "ֹտ") + .setParameter("COLLECT_MSG", "ֹۿ") + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + BizObject boDDI=JBOFactory.createBizObjectQuery(D_DEPOSITRETURN_INFO.CLASS_NAME,"RENT_PLAN_ID=:rentPlanId").setParameter("rentPlanId", bo.getAttribute("id").toString()).getSingleResult(false); + if(boDDI!=null){ + this.writeBackDistributor(bo.getAttribute("id").toString(), Sqlca); + } + + + } + + return "ܹ "+i+" տɹ\n"+j+" տʧ"; + } + /** + * ֶտ޸״̬,,̱֤ + * @param tx + * @return + * @throws Exception + */ + public String afterCollectManageDistributor(JBOTransaction tx) throws Exception{ + int i = 0,j = 0; + String[] ids = id.split("@"); + String[] penaltyArray = penaltys.split("@"); + + BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME,tx); + BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,tx); + BizObjectManager bd = JBOFactory.getFactory().getManager(D_DEPOSITRETURN_INFO.CLASS_NAME,tx); + BizObjectManager bdi = JBOFactory.getFactory().getManager(DISTRIBUTOR_INFO.CLASS_NAME,tx); + + for(int c=0;c map = handcraftsingleCollectMoenyDistrbutor(tx,bc,bom,rent,penaltyArray[c]); + i++; + //ո״̬ + bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.PENALTY=:PENALTY where O.id=:id") + .setParameter("COLLECT_STATUS", "") + .setParameter("COLLECT_MSG", "̱֤") + .setParameter("PENALTY", penaltyArray[c]) + .setParameter("id", bom.getAttribute("id").toString()).executeUpdate(); + //뾭̱֤˻ر + BizObject bobdi = bdi.createQuery("distributor_no=:distributor_id").setParameter("distributor_id", distributor_id).getSingleResult(false); + BigDecimal sum = new BigDecimal(bobdi.getAttribute("sums").getString()); + double account_balance = sum.subtract(new BigDecimal(t_rent)).doubleValue(); + BizObject bod = bd.newObject(); + bod.setAttributeValue("DISTRIBUTOR_ID", distributor_id); + bod.setAttributeValue("CAUTION_MONEY", t_rent); + bod.setAttributeValue("ACCOUNT_BALANCE", account_balance); + bod.setAttributeValue("MONEY_TYPE","bondRepay"); + bod.setAttributeValue("INPUTTIME",StringFunction.getTodayNow()); + bod.setAttributeValue("INPUTUSERID",inputuserid); + bod.setAttributeValue("INPUTORGID",inputorgid); + bod.setAttributeValue("CONTRACT_ID",bom.getAttribute("contract_id").toString()); + bod.setAttributeValue("PLAN_LIST",bom.getAttribute("plan_list").toString()); + bod.setAttributeValue("RENT_PLAN_ID",bom.getAttribute("id").toString()); + bd.saveObject(bod); + //޸ľϢĽ + bdi.createQuery("update O set O.sums='"+account_balance+"' where O.distributor_no=:distributor_id").setParameter("distributor_id", distributor_id).executeUpdate(); + } + return "ܹ "+i+" տɹ\n"+j+" տʧ"; + } + private BigDecimal BigDecimal(String string) { + // TODO Auto-generated method stub + return null; + } + + private Double Double(String string) { + // TODO Auto-generated method stub + return null; + } + + /** + * ʵʱ + * @param rent + * @param acc_number п + * @param account + * @param bankcode д + * @param province пʡ + * @param req_sn ˮ + * @return + */ + public StringBuffer collectTimely(String rent,String acc_number,String account,String bankcode,String province,String req_sn){ + //ƴXML + String req = System.currentTimeMillis()+""; + StringBuffer strbuff = new StringBuffer(); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + Info info = new Info(); + info.setTRX_CODE(InitCollectConfig.C_TRXCODE); + info.setVERSION(InitCollectConfig.C_VERSION); + info.setDATA_TYPE(InitCollectConfig.C_DATATYPE); + info.setLEVEL(InitCollectConfig.C_LEVEL); + info.setUSER_NAME(InitCollectConfig.USERNAME); + info.setUSER_PASS(InitCollectConfig.USERPASS); + info.setREQ_SN(req_sn); + info.setSIGNED_MSG(""); + strbuff.append(EntityTransform.toXml(info)); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + Trans_Sum trans_sum = new Trans_Sum(); + trans_sum.setBUSINESS_CODE(InitCollectConfig.BUSSINESSCODE); + trans_sum.setMERCHANT_ID(InitCollectConfig.MERCHANTID); + trans_sum.setEXPECT_SEND_TIME(""); + trans_sum.setTOTAL_ITEM("1"); + trans_sum.setTOTAL_SUM(rent); + strbuff.append(EntityTransform.toXml(trans_sum)); + strbuff.append(""); + strbuff.append(""); + Trans_Detail trans_detail = new Trans_Detail(); + trans_detail.setSN("0001"); + trans_detail.setBANK_CODE(bankcode);//д + trans_detail.setACCOUNT_TYPE("00"); + trans_detail.setACCOUNT_NO(acc_number); + trans_detail.setACCOUNT_NAME(account); + trans_detail.setPROVINCE(province);//пʡ + trans_detail.setACCOUNT_PROP("0"); + trans_detail.setAMOUNT(rent); + trans_detail.setCURRENCY("CNY"); + trans_detail.setRECKON_ACCOUNT(""); + strbuff.append(EntityTransform.toXmlByLotCollect(trans_detail)); + strbuff.delete(strbuff.lastIndexOf(""), strbuff.length()); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + + return strbuff; + } + + /** + * - + * @param tx + * @return + * @throws Exception + */ + public String batchCollectManage(JBOTransaction tx) throws Exception{ + int i = 0,j = 0; + String[] ids = id.split("@"); + StringBuffer parms = new StringBuffer(); + for (String str : ids) { + if (parms.length()==0) { + parms.append("'"+str+"'"); + }else{ + parms.append(",'"+str+"'"); + } + } + BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); + BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); + //ڵݽв + List bolist = bm.createQuery("select distinct O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,O.rent,O.SUBJECTID from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in ("+parms.toString()+") and O.SUBJECTID='aa740e4111c111eaaa0000163e0e11e6'").getResultList(false); + List tianjinbolist = bm.createQuery("select distinct O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,O.rent,O.SUBJECTID from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in ("+parms.toString()+") and O.SUBJECTID='d989246c11c111eaaa0000163e0e11e6'").getResultList(false); + if (bolist.size() != 0) { + singleBatchCollectMoeny(tx, bolist); + } + if (tianjinbolist.size() != 0) { + singleBatchCollectMoeny(tx, tianjinbolist); + } + return "ϵͳڴУԺ"; + } + + /** + * ѯտ״̬ + * @return + * @throws Exception + */ + public String queryBatchCollectStatus(JBOTransaction tx) throws Exception{ + Transaction Sqlca = Transaction.createTransaction(tx); + BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME); + BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME); + String[] ids = id.split("@"); + StringBuffer parms = new StringBuffer(); + for (String str : ids) { + if (parms.length()==0) { + parms.append("'"+str+"'"); + }else{ + parms.append(",'"+str+"'"); + } + } + List bolist = bm.createQuery("select distinct O.BATCH_NO,O.BATCH_SN,O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,O.rent,O.SUBJECTID from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false); + for (BizObject bo : bolist) { + String query_sn = bo.getAttribute("BATCH_NO").toString(); + String sn = bo.getAttribute("BATCH_SN").toString(); + String rent = bo.getAttribute("rent").toString(); + String bank_name = bo.getAttribute("BANK_NAME").toString(); + int m = 0; + String[] singleRent = null; + List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false); + for (BizObject code : codelist) { + String itemname = code.getAttribute("itemname").toString().trim(); + double itemdescribe = code.getAttribute("itemdescribe").getDouble(); + if (bank_name.indexOf(itemname) !=-1 && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) { + BigDecimal mi = new BigDecimal(bo.getAttribute("rent").toString()); + int singlerent = mi.multiply(new BigDecimal(100)).intValue(); + BigDecimal mj = new BigDecimal(itemdescribe); + long divide = mj.multiply(new BigDecimal(100)).longValue(); + if(divide!=0){ + int k = (int) Math.floor(singlerent/divide); + int l = (int) Math.ceil(singlerent%divide); + for (int j = 0; j < k; j++) { + m++; + } + if (l!=0) { + m++; + } + singleRent = new String[m]; + for (int i = 0; i < k; i++) { + singleRent[i] = itemdescribe+""; + } + singleRent[m-1] = String.format("%.2f",bo.getAttribute("rent").getDouble() - k*itemdescribe); + break;//ƥ䵽ѭ + } + } + } + String[] snArray = sn.split(","); + int n = 0;//,ۿɹ¼ + BizObject bolrp = bc.createQuery("O.id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false); + String collectStatus = "δտ"; + String collectStatusPart = "տ"; + //ָֹ + if(bolrp.getAttribute("COLLECT_STATUS")!=null){ + //жΪջΪnullǡΪ״̬ + if(bolrp.getAttribute("COLLECT_STATUS").toString().length()>1){ + collectStatus = bolrp.getAttribute("COLLECT_STATUS").toString(); + collectStatusPart = bolrp.getAttribute("COLLECT_STATUS").toString(); + } + } + for (int i = 1; i <= snArray.length; i++) { + Map map = querySingleBatchCollect(tx, bo, query_sn, snArray[(i-1)]); + if (snArray.length == 1) { + if (map.containsKey("RET_CODE") && "0000".equals(map.get("RET_CODE"))) { + querysingleCollectMoeny(tx, bc, bo, rent,i+""); + //ո״̬ + bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS where O.id=:id") + .setParameter("COLLECT_STATUS", "տ") + .setParameter("COLLECT_MSG", ",տɹ") + .setParameter("BATCH_STATUS", "complete")//״̬- + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + BizObject boDDI=JBOFactory.createBizObjectQuery(D_DEPOSITRETURN_INFO.CLASS_NAME,"RENT_PLAN_ID=:rentPlanId").setParameter("rentPlanId", id).getSingleResult(false); + if(boDDI!=null){ + this.writeBackDistributor(id,Sqlca); + } + bo.setAttributeValue("COLLECT_STATUS", "տ"); + bo.setAttributeValue("COLLECT_MSG", ",տɹ"); + bo.setAttributeValue("BATCH_STATUS", "complete"); + //bo.setAttributeValue("rent", bo.getAttribute("rent").toString()); + saveBuckle(bo,tx,sn,rent); + }else if (map.containsKey("RET_CODE") && ("2007".equals(map.get("RET_CODE")) || "2005".equals(map.get("RET_CODE")) || "2003".equals(map.get("RET_CODE")) || "2001".equals(map.get("RET_CODE")) || "2000".equals(map.get("RET_CODE")))){ + //еķϢ + bc.createQuery("update O set O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") + .setParameter("COLLECT_MSG", map.get("ERR_MSG")) + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); + saveBuckle(bo,tx,sn,"0.00"); + }else{ + //ո״̬ + bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO='',O.BATCH_SN='' where O.id=:id") + .setParameter("COLLECT_STATUS", collectStatus) + .setParameter("COLLECT_MSG", map.get("ERR_MSG")) + .setParameter("BATCH_STATUS", "")//״̬ + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + bo.setAttributeValue("COLLECT_STATUS", "δտ"); + bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); + bo.setAttributeValue("BATCH_STATUS", ""); + saveBuckle(bo,tx,sn,"0.00"); + } + }else if (snArray.length > 1) { + if (map.containsKey("RET_CODE") && "0000".equals(map.get("RET_CODE"))) { + querysingleCollectMoeny(tx, bc, bo, singleRent[i-1],i+""); + n++; + if (n == snArray.length) { + n = 0;//ۿɹ Ϊ 0 + //ո״̬ + bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS where O.id=:id") + .setParameter("COLLECT_STATUS", "տ") + .setParameter("COLLECT_MSG", ",տɹ") + .setParameter("BATCH_STATUS", "complete")//״̬- + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + BizObject boDDI=JBOFactory.createBizObjectQuery(D_DEPOSITRETURN_INFO.CLASS_NAME,"RENT_PLAN_ID=:rentPlanId").setParameter("rentPlanId", id).getSingleResult(false); + if(boDDI!=null){ + this.writeBackDistributor(id,Sqlca); + } + bo.setAttributeValue("COLLECT_STATUS", "տ"); + bo.setAttributeValue("COLLECT_MSG", ",տɹ"); + bo.setAttributeValue("BATCH_STATUS", "complete"); + //bo.setAttributeValue("rent", bo.getAttribute("rent").toString()); + saveBuckle(bo,tx,i+"",rent); + }else{ + //ո״̬ + bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS where O.id=:id") + .setParameter("COLLECT_STATUS", collectStatusPart) + .setParameter("COLLECT_MSG", map.get("ERR_MSG")) + .setParameter("BATCH_STATUS", "complete")//״̬- + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + bo.setAttributeValue("COLLECT_STATUS", "տ"); + bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); + bo.setAttributeValue("BATCH_STATUS", "complete"); + saveBuckle(bo,tx,i+"","0.00"); + } + }else if (map.containsKey("RET_CODE") && ("2007".equals(map.get("RET_CODE")) || "2005".equals(map.get("RET_CODE")) || "2003".equals(map.get("RET_CODE")) || "2001".equals(map.get("RET_CODE")) || "2000".equals(map.get("RET_CODE")))){ + //еķϢ + bc.createQuery("update O set O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") + .setParameter("COLLECT_MSG", map.get("ERR_MSG")) + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); + saveBuckle(bo,tx,i+"","0.00"); + }else{//ֶʿۿ,ۿɹδ 0 ,¿ۿ״̬Ϊ δۿ + if (i == snArray.length && n == 0) { + //ո״̬ + bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO='',O.BATCH_SN='' where O.id=:id") + .setParameter("COLLECT_STATUS", collectStatus) + .setParameter("COLLECT_MSG", map.get("ERR_MSG")) + .setParameter("BATCH_STATUS", "")//״̬ + .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); + bo.setAttributeValue("COLLECT_STATUS", "δտ"); + bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); + bo.setAttributeValue("BATCH_STATUS", ""); + saveBuckle(bo,tx,i+"","0.00"); + } + } + } + if (i == snArray.length) {//ѭnΪ 0 + n = 0; + } + } + } + + return "success"; + + } + public void saveBuckle(BizObject bo,JBOTransaction tx,String batch_sn,String rent) throws JBOException{ + BizObjectManager blog = JBOFactory.getBizObjectManager(LB_BUCKLE_LOG.CLASS_NAME, tx); + BizObject blbo = blog.newObject(); + String collect = bo.getAttribute("COLLECT_STATUS").getString(); + if(collect!=""){ + blbo.setAttributeValue("COLLECT_STATUS", bo.getAttribute("COLLECT_STATUS").getString()); + blbo.setAttributeValue("COLLECT_MSG", bo.getAttribute("COLLECT_MSG").getString()); + blbo.setAttributeValue("BATCH_STATUS", bo.getAttribute("BATCH_STATUS").getString()); + } + blbo.setAttributeValue(LB_BUCKLE_LOG.BATCH_SN, batch_sn); + blbo.setAttributeValue(LB_BUCKLE_LOG.BATCH_NO, bo.getAttribute("BATCH_NO").getString()); + blbo.setAttributeValue(LB_BUCKLE_LOG.RENT_ID, bo.getAttribute("ID").getString()); + blbo.setAttributeValue(LB_BUCKLE_LOG.cut_money,rent); + blbo.setAttributeValue(LB_BUCKLE_LOG.inputuserid, "syetem"); + blbo.setAttributeValue(LB_BUCKLE_LOG.inputorgid, "system"); + blbo.setAttributeValue(LB_BUCKLE_LOG.inputtime, StringFunction.getTodayNow()); + blbo.setAttributeValue(LB_BUCKLE_LOG.updatetime, System.currentTimeMillis()); + blog.saveObject(blbo); + } + + /** + * ղѯӿ + * @param tx + * @param bo + * @param list + * @return + * @throws Exception + */ + public Map querySingleBatchCollect(JBOTransaction tx,BizObject bo,String query_sn,String sn) throws Exception{ + CollectAuditProcess cp = new CollectAuditProcess(); + //ļ + String currentDateTime = DateAssistant.getTodayNow(); + String currentYear = currentDateTime.substring(0,4); + String month = currentDateTime.substring(5,7); + String day = currentDateTime.substring(8,10); + String merchantNumber = InitCollectConfig.MERCHANTID; + if(bo!=null&&bo.getAttribute("SUBJECTID")!=null&&"".equals(bo.getAttribute("SUBJECTID").getString())){ + merchantNumber=InitCollectConfig.TIANJIN_MERCHANTID; + } + String flag = InitCollectConfig.FLAG; + String version = InitCollectConfig.C_VERSION; + String date = currentYear+month+day;//ύ + String batch_title = ""; + int i = 0,j = 0; + //ļ· + String rootDir = this.fileSavePath; + File file = new File(rootDir + File.separator + currentYear + + File.separator + month + File.separator + + day); + System.out.println(file.getAbsolutePath()); + if(!file.exists()){//Ŀ¼ֱӴ + file.mkdirs(); + } + String req_sn = System.currentTimeMillis()+"";//κ + batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn; + StringBuffer strbuff = queryBatchXML(merchantNumber,req_sn, query_sn, sn); +// queryBatchXML(req_sn, query_sn, sn); + //Ӧ + String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title); + Map map = getRetAndCode(strResp); + //ɴ̡ļ + savaFile(tx, strResp,batch_title,bo); + + return map; + } + /** + * ̻Żȡѯ + * @param merchantNumber + * @param req_sn + * @param query_sn + * @param sn + * @return + */ + private StringBuffer queryBatchXML(String merchantNumber, String req_sn, String query_sn, String sn) { + StringBuffer strbuff = new StringBuffer(); + if(InitCollectConfig.MERCHANTID.equals(merchantNumber)){ + strbuff = queryBatchXML(req_sn, query_sn, sn); + }else{ + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + Info info = new Info(); + info.setTRX_CODE("200001"); + info.setVERSION(InitCollectConfig.C_VERSION); + info.setDATA_TYPE(InitCollectConfig.C_DATATYPE); + info.setREQ_SN(req_sn); + info.setUSER_NAME(InitCollectConfig.TIANJIN_USERNAME); + info.setUSER_PASS(InitCollectConfig.TIANJIN_USERPASS); + info.setSIGNED_MSG(""); + strbuff.append(EntityTransform.toXml(info)); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(query_sn);//ҪѯĽˮ + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(sn);//ϸ + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + } + return strbuff; + } + + /** + * ѯӿ-- + * @param tx + * @param bc + * @param bo + * @param rent + * @return + * @throws Exception + */ + public Map querysingleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws Exception{ + String cerrentDate = DateAssistant.getToday(); + Map map = new HashMap(); + //Ϊ洢ʵ + /*JBOTransaction transaction = JBOFactory.createJBOTransaction(); + BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction); + BizObject boi = bmi.createQuery("select v.replace(v.uuid(),'-','') as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER," + + "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST," + + "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,vl.rent_over as v.RENT,vl.corpus_over as v.CORPUS,vl.interest_over as v.INTEREST,("+rent+"-vl.rent_over) as v.PENALTY," + + "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id" + + " and vl.contract_id =:contract_id and vl.plan_date =:plan_date") + .setParameter("contract_id", bo.getAttribute("contract_id").toString()) + .setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false); + if (boi != null) { + // + String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST," + + " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)" + + "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"'," + + "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"'," + + "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"'," + + "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')"; + Transaction Sqlca =null; + Sqlca = Transaction.createTransaction(transaction); + SqlObject asql = new SqlObject(sql); + Sqlca.executeSQL(asql); + } + transaction.commit();*/ + + Transaction Sqlca =null; + ASResultSet rs = null; + try { + + Sqlca = Transaction.createTransaction(tx); + String ln_contract_id = bo.getAttribute("contract_id").toString(); + String ln_plan_date = bo.getAttribute("plan_date").toString(); + String in_rent = rent; + String in_hire_list = hire_list; + String in_type = "2"; + String SQL="{call proc_insert_hexiao('"+ln_contract_id+"','"+ln_plan_date+"','"+in_rent+"','"+in_hire_list+"','"+in_type+"')} "; + SqlObject asql = new SqlObject(SQL); + rs = Sqlca.getASResultSet(asql); + } catch (Exception e) { + e.printStackTrace(); + }finally{ + if(rs != null) rs.close(); + if(Sqlca!=null)Sqlca.commit(); + } + + return map; + } + /** + * ѯӿڱ-xml + * @param req_sn ˮ + * @param query_sn ѯˮ + * @param sn ѯϸ + * @return + */ + public StringBuffer queryBatchXML(String req_sn,String query_sn,String sn){ + StringBuffer strbuff = new StringBuffer(); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + Info info = new Info(); + info.setTRX_CODE("200001"); + info.setVERSION(InitCollectConfig.C_VERSION); + info.setDATA_TYPE(InitCollectConfig.C_DATATYPE); + info.setREQ_SN(req_sn); + info.setUSER_NAME(InitCollectConfig.USERNAME); + info.setUSER_PASS(InitCollectConfig.USERPASS); + info.setSIGNED_MSG(""); + strbuff.append(EntityTransform.toXml(info)); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(query_sn);//ҪѯĽˮ + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(sn);//ϸ + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + return strbuff; + } + /** + * - + * @param tx + * @param bc + * @param bo + * @param rent + * @return + * @throws Exception + */ + public Map singleBatchCollectMoeny(JBOTransaction tx,List list) throws Exception{ + CollectAuditProcess cp = new CollectAuditProcess(); + //ļ + String currentDateTime = DateAssistant.getTodayNow(); + String currentYear = currentDateTime.substring(0,4); + String month = currentDateTime.substring(5,7); + String day = currentDateTime.substring(8,10); + String merchantNumber = InitCollectConfig.MERCHANTID; + if(list.get(0).getAttribute("SUBJECTID")!=null&&"d989246c11c111eaaa0000163e0e11e6".equals(list.get(0).getAttribute("SUBJECTID").getString())){ + merchantNumber = InitCollectConfig.TIANJIN_MERCHANTID; + } + String flag = InitCollectConfig.FLAG; + String version = InitCollectConfig.C_VERSION; + String date = currentYear+month+day;//ύ + String batch_title = ""; + int i = 0,j = 0; + //ļ· + String rootDir = this.fileSavePath; + File file = new File(rootDir + File.separator + currentYear + + File.separator + month + File.separator + + day); + System.out.println(file.getAbsolutePath()); + if(!file.exists()){//Ŀ¼ֱӴ + file.mkdirs(); + } + String req_sn = System.currentTimeMillis()+"";//κ + batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn; + StringBuffer strbuff = collectBatch(req_sn,list); + //Ӧ + String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title); + for (BizObject bo : list) { + //ɴ̡ļ + savaFile(tx, strResp,batch_title,bo); + } + Map map = getRetAndCodeByBatch(strResp); + if (map.containsKey("RET_CODE")) {//״̬ + for (BizObject biz : list) { + //״̬ + JBOTransaction trans = JBOFactory.createJBOTransaction(); + BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); + bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") + .setParameter("BATCH_STATUS", "")// + .setParameter("BATCH_NO", req_sn) + .setParameter("BATCH_SN", "") + .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); + trans.commit(); + } + }else{ + int m = 0;//ͳƷ͵Ĵյ + for (int n = 1; n <= map.size(); n++) { + if (map.containsKey("SN"+n)) { + m++; + } + } + for (int k = 1; k <= m; k++) { + if (map.containsKey("REQ_SN") && map.containsKey("RET_CODE"+k) && "0000".equals(map.get("RET_CODE"+k))) { + JBOTransaction trans = JBOFactory.createJBOTransaction(); + BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); + BizObject bo0 = bm.createQuery("O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%'").setParameter("BATCH_NO", map.get("REQ_SN")).getSingleResult(false); + if (bo0 != null && "process".equals(bo0.getAttribute("BATCH_STATUS"))) { + bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS where O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%' ") + .setParameter("BATCH_STATUS", "process")//״̬Ϊ-- + .setParameter("BATCH_NO", map.get("REQ_SN")).executeUpdate(); + trans.commit(); + }else{ + bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS where O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%' ") + .setParameter("BATCH_STATUS", "process")//״̬Ϊ-- + .setParameter("BATCH_NO", map.get("REQ_SN")).executeUpdate(); + trans.commit(); + } + }else{ + JBOTransaction trans = JBOFactory.createJBOTransaction(); + BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); + BizObject bo0 = bm.createQuery("O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%'").setParameter("BATCH_NO", map.get("REQ_SN")).getSingleResult(false); + if (bo0 != null && "process".equals(bo0.getAttribute("BATCH_STATUS"))) { + //κβ + }else{ + bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO='',O.BATCH_SN='' where O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%' ") + .setParameter("BATCH_STATUS", "")//״̬ + .setParameter("BATCH_NO", map.get("REQ_SN")).executeUpdate(); + trans.commit(); + } + } + } + } + return map; + } + + /** + * --ƴ + * @param rent + * @param acc_number + * @param account + * @param req_sn + * @return + * @throws JBOException + */ + public StringBuffer collectBatch(String req_sn,List list) throws JBOException{ + //ƴXML + //String req = System.currentTimeMillis()+""; + StringBuffer strbuff = new StringBuffer(); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + Info info = new Info(); + info.setTRX_CODE(InitCollectConfig.BATCH_TRXCODE); + info.setVERSION(InitCollectConfig.C_VERSION); + info.setDATA_TYPE(InitCollectConfig.C_DATATYPE); + info.setLEVEL(InitCollectConfig.C_LEVEL); + info.setUSER_NAME(InitCollectConfig.USERNAME); + info.setUSER_PASS(InitCollectConfig.USERPASS); + info.setREQ_SN(req_sn); + info.setSIGNED_MSG(""); + if(list.get(0).getAttribute("SUBJECTID")!=null&&"d989246c11c111eaaa0000163e0e11e6".equals(list.get(0).getAttribute("SUBJECTID").getString())){ + info.setUSER_NAME(InitCollectConfig.TIANJIN_USERNAME); + info.setUSER_PASS(InitCollectConfig.TIANJIN_USERPASS); + } + strbuff.append(EntityTransform.toXml(info)); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + BigDecimal mutly = new BigDecimal("0"); + int i = 0; + for (BizObject bo : list) { + String single = bo.getAttribute("rent").toString(); + BigDecimal m = new BigDecimal(single); + mutly = mutly.add(m); + String bank_name = bo.getAttribute("BANK_NAME").toString(); + List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false); + //ֵеitemdescribeֶδе + double itemdescribe = 0; + boolean flag = false; + for (BizObject code : codelist) { + String itemnameTmp = code.getAttribute("itemname").toString().trim(); + double itemdescribeTmp = code.getAttribute("itemdescribe").getDouble(); + String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString(); + if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) { + itemdescribe = new BigDecimal(itemdescribeTmp).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + flag = true; + break; + } + } + + if (flag == true && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) { + BigDecimal mi = new BigDecimal(bo.getAttribute("rent").toString()); + int singlerent = mi.multiply(new BigDecimal(100)).intValue(); + int singleitem = new BigDecimal(itemdescribe).multiply(new BigDecimal(100)).intValue(); + int k = (int) Math.floor(singlerent/singleitem); + int l = (int) Math.ceil(singlerent%singleitem); + for (int j = 0; j < k; j++) { + i++; + } + if (l!=0) { + i++; + } + }else{ + i++; + } + + } + String totalSum = String.valueOf(mutly.multiply(new BigDecimal(100)).longValue()); + String totalItem = String.valueOf(i); + Trans_Sum trans_sum = new Trans_Sum(); + trans_sum.setBUSINESS_CODE(InitCollectConfig.BUSSINESSCODE); + trans_sum.setMERCHANT_ID(InitCollectConfig.MERCHANTID); + trans_sum.setEXPECT_SEND_TIME(""); + trans_sum.setTOTAL_ITEM(totalItem); + trans_sum.setTOTAL_SUM(totalSum); + strbuff.append(EntityTransform.toXml(trans_sum)); + strbuff.append(""); + strbuff.append(""); + int item = 0; + for (BizObject biz : list) { + BigDecimal m = new BigDecimal(biz.getAttribute("rent").toString()); + String rent = String.valueOf(m.multiply(new BigDecimal(100)).longValue()); + String acc_number = biz.getAttribute("acc_number").toString(); + String account = biz.getAttribute("account").toString(); + String bank_name = biz.getAttribute("BANK_NAME").toString(); + List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false); + double itemdescribe = 0; + boolean flag = false; + for (BizObject code : codelist) { + String itemnameTmp = code.getAttribute("itemname").toString().trim(); + double itemdescribeTmp = code.getAttribute("itemdescribe").getDouble(); + String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString(); + if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) { + itemdescribe = new BigDecimal(itemdescribeTmp).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + flag = true; + break; + } + } + if (flag == true && Double.parseDouble(biz.getAttribute("rent").toString()) > itemdescribe) { + BigDecimal mi = new BigDecimal(biz.getAttribute("rent").toString()); + int singlerent = mi.multiply(new BigDecimal(100)).intValue(); + int singleitem = new BigDecimal(itemdescribe).multiply(new BigDecimal(100)).intValue(); + int k = (int) Math.floor(singlerent/singleitem); + int l = (int) Math.ceil(singlerent%singleitem); + for (int k2 = 1; k2 <= k; k2++) { + Trans_Detail trans_detail = new Trans_Detail(); + String sn = ""; + if (item >= 9&&item<99) { + sn = "000"+ (++item); + }else if(item >= 99){ + sn = "00"+ (++item); + }else{ + sn = "0000"+ (++item); + } + //׷״̬ + JBOTransaction trans = JBOFactory.createJBOTransaction(); + BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); + BizObject bo = bm.createQuery("O.id=:id").setParameter("id", biz.getAttribute("id").toString()).getSingleResult(false); + String itemsn0 = ""; + if (bo !=null) { + String itemsn = bo.getAttribute("batch_sn").toString(); + if (itemsn.length() == 0) { + itemsn0 += sn; + }else{ + itemsn0 += itemsn+","+sn; + } + } + bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") + .setParameter("BATCH_STATUS", "")//״̬-Ϊ + .setParameter("BATCH_NO", req_sn) + .setParameter("BATCH_SN", itemsn0) + .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); + trans.commit(); + trans_detail.setSN(sn); + trans_detail.setACCOUNT_TYPE(""); + trans_detail.setACCOUNT_NO(acc_number); + trans_detail.setACCOUNT_NAME(account); + trans_detail.setACCOUNT_PROP("0"); + trans_detail.setAMOUNT(String.valueOf(singleitem)); + trans_detail.setCURRENCY("CNY"); + trans_detail.setRECKON_ACCOUNT(""); + strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail)); + } + if (l != 0) { + String surprent = String.format("%.2f", biz.getAttribute("rent").getDouble() - k*itemdescribe); + BigDecimal mj = new BigDecimal(surprent); + String singlerent0 = String.valueOf(mj.multiply(new BigDecimal(100)).longValue()); + Trans_Detail trans_detail = new Trans_Detail(); + String sn = ""; + if (item >= 9&&item<99) { + sn = "000"+ (++item); + }else if(item >= 99){ + sn = "00"+ (++item); + }else{ + sn = "0000"+ (++item); + } + //׷״̬ + JBOTransaction trans = JBOFactory.createJBOTransaction(); + BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); + BizObject bo = bm.createQuery("O.id=:id").setParameter("id", biz.getAttribute("id").toString()).getSingleResult(false); + String itemsn0 = ""; + if (bo !=null) { + String itemsn = bo.getAttribute("batch_sn").toString(); + if (itemsn.length() == 0) { + itemsn0 += sn; + }else{ + itemsn0 += itemsn+","+sn; + } + } + bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") + .setParameter("BATCH_STATUS", "")//״̬-Ϊ + .setParameter("BATCH_NO", req_sn) + .setParameter("BATCH_SN", itemsn0) + .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); + trans.commit(); + trans_detail.setSN(sn); + trans_detail.setACCOUNT_TYPE(""); + trans_detail.setACCOUNT_NO(acc_number); + trans_detail.setACCOUNT_NAME(account); + trans_detail.setACCOUNT_PROP("0"); + trans_detail.setAMOUNT(singlerent0); + trans_detail.setCURRENCY("CNY"); + trans_detail.setRECKON_ACCOUNT(""); + strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail)); + } + }else{ + Trans_Detail trans_detail = new Trans_Detail(); + String sn = ""; + if (item >= 9&&item<99) { + sn = "000"+ (++item); + }else if(item >= 99){ + sn = "00"+ (++item); + }else{ + sn = "0000"+ (++item); + } + //׷״̬ + JBOTransaction trans = JBOFactory.createJBOTransaction(); + BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); + bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id") + .setParameter("BATCH_STATUS", "")//״̬-Ϊ + .setParameter("BATCH_NO", req_sn) + .setParameter("BATCH_SN", sn) + .setParameter("id", biz.getAttribute("id").toString()).executeUpdate(); + trans.commit(); + trans_detail.setSN(sn); + trans_detail.setACCOUNT_TYPE(""); + trans_detail.setACCOUNT_NO(acc_number); + trans_detail.setACCOUNT_NAME(account); + trans_detail.setACCOUNT_PROP("0"); + trans_detail.setAMOUNT(rent); + trans_detail.setCURRENCY("CNY"); + trans_detail.setRECKON_ACCOUNT(""); + strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail)); + } + } + strbuff.delete(strbuff.lastIndexOf(""), strbuff.length()); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + + + return strbuff; + } + + /** + * ̡ļ + * @param tx + * @param strResp + * @param batch_title + * @throws Exception + */ + public void savaFile(JBOTransaction tx,String strResp,String batch_title,BizObject bo) throws Exception{ + //ļ + String currentDateTime = DateAssistant.getTodayNow(); + String currentYear = currentDateTime.substring(0,4); + String month = currentDateTime.substring(5,7); + String day = currentDateTime.substring(8,10); + //ļ· + String rootDir = this.fileSavePath; + File file = new File(rootDir + File.separator + currentYear + + File.separator + month + File.separator + + day); + System.out.println(file.getAbsolutePath()); + if(!file.exists()){//Ŀ¼ֱӴ + file.mkdirs(); + } + //ļ + BizObjectManager bm = JBOFactory.getFactory().getManager(LB_INTFACE_FILE_RECORD.CLASS_NAME); + BizObject send = bm.newObject(); + send.setAttributeValue("filepath", (file.getAbsoluteFile().toString().substring(rootDir.length())+"/"+batch_title+".txt").replace("\\", "/")); + send.setAttributeValue("fullpath", (file.getAbsoluteFile().toString()+"/"+batch_title+".txt").replace("\\", "/")); + send.setAttributeValue("filename", batch_title+".txt"); + send.setAttributeValue("FILE_TYPE", "S"); + send.setAttributeValue("RELA_ID", bo.getAttribute("id")); + send.setAttributeValue("inputuserid", this.inputuserid); + send.setAttributeValue("inputorgid", this.inputorgid); + send.setAttributeValue("inputtime", currentDateTime); + bm.saveObject(send); + //ɸѡӦϢ + Map map = getRetAndCode(strResp); + //getMsgAndCode(strResp); + + //ļ + BizObject reply = bm.newObject(); + reply.setAttributeValue("filepath", (file.getAbsoluteFile().toString().substring(rootDir.length())+"/"+batch_title+".rnt").replace("\\", "/")); + reply.setAttributeValue("fullpath", (file.getAbsoluteFile().toString()+"/"+batch_title+".rnt").replace("\\", "/")); + reply.setAttributeValue("filename", batch_title+".rnt"); + reply.setAttributeValue("feedback_code", map.get("RET_CODE")); + reply.setAttributeValue("feedback_message", map.get("ERR_MSG")); + reply.setAttributeValue("FILE_TYPE", "B"); + reply.setAttributeValue("RELA_ID", bo.getAttribute("id")); + reply.setAttributeValue("inputuserid", this.inputuserid); + reply.setAttributeValue("inputorgid", this.inputorgid); + reply.setAttributeValue("inputtime", currentDateTime); + bm.saveObject(reply); + } + + /** + * ʵʱգӦļ + * @param strXML + * @return + */ + public Map getRetAndCode(String strXML){ + Map map = new HashMap(); + Map res = new HashMap(); + Pattern pm = Pattern.compile("(?<=)([\\S\\s]*?)(?=)"); + Matcher mm = pm.matcher(strXML); + int i = 0; + while (mm.find()) + { + map.put("RET_CODE"+i++, mm.group()); + } + Pattern pc = Pattern.compile("(?<=)([\\S\\s]*?)(?=)"); + Matcher mc = pc.matcher(strXML); + int j = 0; + while (mc.find()) + { + map.put("ERR_MSG"+j++, mc.group()); + } + if (map.containsKey("RET_CODE0") && "0000".equals(map.get("RET_CODE0"))) { + if (map.containsKey("RET_CODE1") && "0000".equals(map.get("RET_CODE1"))) { + res.put("RET_CODE", map.get("RET_CODE1")); + res.put("ERR_MSG", map.get("ERR_MSG1")); + }else{ + res.put("RET_CODE", map.get("RET_CODE1")); + res.put("ERR_MSG", map.get("ERR_MSG1")); + } + }else{ + res.put("RET_CODE", map.get("RET_CODE0")); + res.put("ERR_MSG", map.get("ERR_MSG0")); + } + return res; + } + + /** + * -رĴ + * @param strXML + * @return + */ + public Map getRetAndCodeByBatch(String strXML){ + Map map = new HashMap(); + Map res = new HashMap(); + System.out.println(1); + int iStart = strXML.indexOf(""); + if (iStart != -1) { + int end = strXML.indexOf(""); + String errMsg = strXML.substring(iStart+9, end); + map.put("ERR_MSG", errMsg); + } + int kStart = strXML.indexOf(""); + if (kStart != -1) { + int end = strXML.indexOf(""); + String reqSn = strXML.substring(kStart+8, end); + map.put("REQ_SN", reqSn); + } + + Pattern pm = Pattern.compile("(?<=)([\\S\\s]*?)(?=)"); + Matcher mm = pm.matcher(strXML); + int i = 0; + while (mm.find()) + { + map.put("RET_CODE"+i++, mm.group()); + } + Pattern pc = Pattern.compile("(?<=)([\\S\\s]*?)(?=)"); + Matcher mc = pc.matcher(strXML); + int j = 1; + while (mc.find()) + { + map.put("SN"+j++, mc.group()); + } + if (map.containsKey("RET_CODE0") && "0000".equals(map.get("RET_CODE0"))) { + res.putAll(map); + res.remove("RET_CODE0"); + res.remove("ERR_MSG"); + }else{ + res.put("RET_CODE", map.get("RET_CODE0")); + res.put("ERR_MSG", map.get("ERR_MSG0")); + } + return res; + } + + public Map getMsgAndCode(String strXML){ + Map map = new HashMap(); + int iStart = strXML.indexOf(""); + if (iStart != -1) { + int end = strXML.indexOf(""); + String strMsg = strXML.substring(iStart+9, end); + map.put("ERR_MSG", strMsg); + } + int jStart = strXML.indexOf(""); + if (jStart != -1) { + int end = strXML.indexOf(""); + String strMsg = strXML.substring(jStart+10, end); + map.put("RET_CODE", strMsg); + } + return map; + } + + /** + * ȡӦ + * @param strXML + * @return + */ + public Map getInfoAndStatus(String strXML){ + Map map = new HashMap(); + Map res = new HashMap(); + + int jStart = strXML.indexOf(""); + if (jStart != -1) { + int end = strXML.indexOf(""); + String retCode = strXML.substring(jStart+10, end); + map.put("RET_CODE", retCode); + } + int iStart = strXML.indexOf(""); + if (iStart != -1) { + int end = strXML.indexOf(""); + String errMsg = strXML.substring(iStart+9, end); + map.put("ERR_MSG", errMsg); + } + + int kStart = strXML.indexOf(""); + if (kStart != -1) { + int end = strXML.indexOf(""); + String errMsg = strXML.substring(kStart+14, end); + map.put("TRANS_STATUS", errMsg); + } + int lStart = strXML.indexOf(""); + if (lStart != -1) { + int end = strXML.indexOf(""); + String retCode = strXML.substring(lStart+12, end); + map.put("TRANS_INFO", retCode); + } + if (map.containsKey("RET_CODE") && map.get("RET_CODE").equals("0000")) { + if (map.containsKey("TRANS_STATUS") && map.get("TRANS_STATUS").equals("0000")) { + res.put("RET_CODE", map.get("TRANS_STATUS")); + res.put("ERR_MSG", map.get("TRANS_INFO")); + }else{ + res.put("RET_CODE", map.get("TRANS_STATUS")); + res.put("ERR_MSG", map.get("TRANS_INFO")); + } + }else{ + res.put("RET_CODE", map.get("RET_CODE")); + res.put("ERR_MSG", map.get("ERR_MSG")); + } + return res; + } + //֤пҪ + public Map vitfyCollectManage(Map map) throws CryptException{ + CollectAuditProcess cp = new CollectAuditProcess(); + String currentDateTime = DateAssistant.getTodayNow(); + String currenttime=currentDateTime.replaceAll("/", ""); + currenttime=currenttime.replaceAll(":", ""); + //ʱ + currenttime=currenttime.replaceAll(" ", ""); + //֤пҪ + //ˮ + String req = System.currentTimeMillis()+""; + StringBuffer strbuff = new StringBuffer(); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + Info info = new Info(); + /*info.setTRX_CODE("100039"); + info.setVERSION("03"); + info.setDATA_TYPE("2"); + info.setLEVEL("5"); + info.setUSER_NAME("00019140020764901"); + info.setUSER_PASS("TPSHauto123.");*/ + info.setTRX_CODE(InitCollectConfig.B_TRXCODE); + info.setVERSION(InitCollectConfig.B_VERSION); + info.setDATA_TYPE(InitCollectConfig.B_DATATYPE); + info.setLEVEL(InitCollectConfig.B_LEVEL); + info.setUSER_NAME(InitCollectConfig.USERNAME); + info.setUSER_PASS(InitCollectConfig.USERPASS); + info.setREQ_SN(req); + info.setSIGNED_MSG(""); + strbuff.append(EntityTransform.toXml(info)); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(currenttime);//ʱ + strbuff.append(""); + strbuff.append(""); + strbuff.append(InitCollectConfig.MERCHANTID);//̻ + /*strbuff.append("000191400207649");//̻ +*/ strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(map.get("ACCOUNT_NO"));// + strbuff.append(""); + strbuff.append(""); + strbuff.append(map.get("ACCOUNT_NAME"));// + strbuff.append(""); + //жǷ + if (map.containsKey("ID_TYPE")) { + strbuff.append(""); + strbuff.append(map.get("ID_TYPE"));//֤ + strbuff.append(""); + } + if (map.containsKey("ID")) { + strbuff.append(""); + strbuff.append(map.get("ID"));//֤ + strbuff.append(""); + } + if (map.containsKey("TEL")) { + strbuff.append(""); + strbuff.append(map.get("TEL"));//ֻ + strbuff.append(""); + } + strbuff.append(""); + strbuff.append("");//ǿЧ + strbuff.append(""); + strbuff.append(""); + strbuff.append("");//ǿCV2 + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + strbuff.append(""); + String strResp = cp.CollectAuditVerifyReq(strbuff); + return getInfoAndStatus(strResp); + } + + + public String getInputuserid() { + return inputuserid; + } + + public void setInputuserid(String inputuserid) { + this.inputuserid = inputuserid; + } + + public String getInputorgid() { + return inputorgid; + } + + public void setInputorgid(String inputorgid) { + this.inputorgid = inputorgid; + } + + public String getFileSavePath() { + return fileSavePath; + } + + public void setFileSavePath(String fileSavePath) { + this.fileSavePath = fileSavePath; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + public String getClearDate() { + return clearDate; + } + public void setClearDate(String clearDate) { + this.clearDate = clearDate; + } + public String getDistributor_id() { + return distributor_id; + } + public void setDistributor_id(String distributor_id) { + this.distributor_id = distributor_id; + } + public String getPenaltys() { + return penaltys; + } + public void setPenaltys(String penaltys) { + this.penaltys = penaltys; + } + + +}