apzl_leasing/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCache.java
2018-12-13 16:23:34 +08:00

1536 lines
68 KiB
Java
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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

package com.tenwa.collectaudit.cache;
import java.io.File;
import java.math.BigDecimal;
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 jbo.app.tenwa.calc.LC_RENT_PLAN;
import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT;
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;
//»ñÈ¡´æÅÌÎļþ
public static String getCollectIntface(String id) throws Exception{
String sql="select lr.filename from LB_INTFACE_FILE_RECORD lr "
+ "where lr.id=:id";
Map<String,String> map=new HashMap<String, String>();
map.put("id", id);
JBOTransaction tx = null;
String filename="";
tx=JBOFactory.createJBOTransaction();
List<Map<String,String>> 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);
List<BizObject> 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\\´úÊÕ¸¶ÏµÍ³½Ó¿ÚÎĵµºÍJAVA°æ²âÊÔdemo¼°²âÊÔÏà¹Ø²ÎÊý\\JAVA°æ²âÊÔDEMO¼°²âÊÔ²ÎÊý_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<BizObject> 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<BizObject> 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<BizObject> 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 ca.customerid=O.customer_id and O.contract_id=ca.contract_id and ca.acc_info = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false);
for (BizObject bo : bolist) {
List<BizObject> 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<String, String> 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<String, String> 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<String, String> 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<String, String> 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<String, String> 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<String, String> 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<String, String> 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<String, String> 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 Exception
*/
public Map<String, String> handcraftsingleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws Exception{
String cerrentDate = DateAssistant.getToday();//»ñÈ¡µ±Ç°ÈÕÆÚ,¸ñʽΪ:yyyy/MM/dd
Map<String, String> map = new HashMap<String, String>();
//¸ÄΪ´æ´¢¹ý³ÌʵÏÖ
/*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;
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);
ASResultSet rs = null;
rs = Sqlca.getASResultSet(asql);
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+"'");
}
}
BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME);
BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME);
List<BizObject> bolist = bm.createQuery("select distinct O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where ca.customerid=O.customer_id and O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false);
for (BizObject bo : bolist) {
Map<String, String> 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();
}
return "×ܹ²ÓÐ "+i+" ±Ê×â½ðÊÕ¿î³É¹¦\n"+j+" ±Ê×â½ðÊÕ¿îʧ°Ü";
}
/**
* ʵʱ´úÊÕ
* @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("<?xml version=\"1.0\" encoding=\"GBK\"?>");
strbuff.append("<GZELINK>");
strbuff.append("<INFO>");
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("</INFO>");
strbuff.append("<BODY>");
strbuff.append("<TRANS_SUM>");
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("</TRANS_SUM>");
strbuff.append("<TRANS_DETAILS><TRANS_DETAIL>");
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("<TRANS_DETAIL>"), strbuff.length());
strbuff.append("</TRANS_DETAILS>");
strbuff.append("</BODY>");
strbuff.append("</GZELINK>");
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<BizObject> 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 ca.customerid=O.customer_id and 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{
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<BizObject> 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 ca.customerid=O.customer_id and 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<BizObject> 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;//²ð·Ö×â½ð,¿Û¿î³É¹¦¼Ç¼
for (int i = 1; i <= snArray.length; i++) {
Map<String, String> 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();
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 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{
//¸üÐÂÊÕ¸¶×´Ì¬
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", "δÊÕ¿î")
.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");
}
}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();
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", "²¿·ÖÊÕ¿î")
.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", "δÊÕ¿î")
.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<String, String> 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<String, String> map = getRetAndCode(strResp);
//Éú³É´æÅÌ¡¢»ØÅÌÎļþ
savaFile(tx, strResp,batch_title,bo);
return map;
}
/**
* ÅúÁ¿²éѯ½Ó¿Ú--»ØÁý×â½ð
* @param tx
* @param bc
* @param bo
* @param rent
* @return
* @throws Exception
*/
public Map<String, String> querysingleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws Exception{
String cerrentDate = DateAssistant.getToday();
Map<String, String> map = new HashMap<String, String>();
//¸ÄΪ´æ´¢¹ý³ÌʵÏÖ
/*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;
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);
ASResultSet rs = null;
rs = Sqlca.getASResultSet(asql);
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("<?xml version=\"1.0\" encoding=\"GBK\"?>");
strbuff.append("<GZELINK>");
strbuff.append("<INFO>");
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("</INFO>");
strbuff.append("<BODY>");
strbuff.append("<QUERY_TRANS>");
strbuff.append("<QUERY_SN>");
strbuff.append(query_sn);//Òª²éѯµÄ½»Ò×Á÷Ë®
strbuff.append("</QUERY_SN>");
strbuff.append("<QUERY_REMARK/>");
strbuff.append("<RET_TYPE/>");
strbuff.append("</QUERY_TRANS>");
strbuff.append("<QUERY_DETAILS>");
strbuff.append("<QUERY_DETAIL>");
strbuff.append("<QUERY_DETAIL_SN>");
strbuff.append(sn);//½»Ò×Ã÷ϸºÅ
strbuff.append("</QUERY_DETAIL_SN>");
strbuff.append("</QUERY_DETAIL>");
strbuff.append("</QUERY_DETAILS>");
strbuff.append("</BODY>");
strbuff.append("</GZELINK>");
return strbuff;
}
/**
* ÅúÁ¿´úÊÕ-·¢ËÍÇëÇó
* @param tx
* @param bc
* @param bo
* @param rent
* @return
* @throws Exception
*/
public Map<String, String> singleBatchCollectMoeny(JBOTransaction tx,List<BizObject> 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<String, String> 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<BizObject> list) throws JBOException{
//Æ´½ÓXML±¨ÎÄ
//String req = System.currentTimeMillis()+"";
StringBuffer strbuff = new StringBuffer();
strbuff.append("<?xml version=\"1.0\" encoding=\"GBK\"?>");
strbuff.append("<GZELINK>");
strbuff.append("<INFO>");
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("</INFO>");
strbuff.append("<BODY>");
strbuff.append("<TRANS_SUM>");
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<BizObject> 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("</TRANS_SUM>");
strbuff.append("<TRANS_DETAILS><TRANS_DETAIL>");
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<BizObject> 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 >= 10) {
sn = "000"+ (++item);
}else if(item >= 100){
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 >= 10) {
sn = "000"+ (++item);
}else if(item >= 100){
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 >= 10) {
sn = "000"+ (++item);
}else if(item >= 100){
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("<TRANS_DETAIL>"), strbuff.length());
strbuff.append("</TRANS_DETAILS>");
strbuff.append("</BODY>");
strbuff.append("</GZELINK>");
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<String, String> 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<String, String> getRetAndCode(String strXML){
Map<String, String> map = new HashMap<String, String>();
Map<String, String> res = new HashMap<String, String>();
Pattern pm = Pattern.compile("(?<=<RET_CODE>)([\\S\\s]*?)(?=</RET_CODE>)");
Matcher mm = pm.matcher(strXML);
int i = 0;
while (mm.find())
{
map.put("RET_CODE"+i++, mm.group());
}
Pattern pc = Pattern.compile("(?<=<ERR_MSG>)([\\S\\s]*?)(?=</ERR_MSG>)");
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<String, String> getRetAndCodeByBatch(String strXML){
Map<String, String> map = new HashMap<String, String>();
Map<String, String> res = new HashMap<String, String>();
System.out.println(1);
int iStart = strXML.indexOf("<ERR_MSG>");
if (iStart != -1) {
int end = strXML.indexOf("</ERR_MSG>");
String errMsg = strXML.substring(iStart+9, end);
map.put("ERR_MSG", errMsg);
}
int kStart = strXML.indexOf("<REQ_SN>");
if (kStart != -1) {
int end = strXML.indexOf("</REQ_SN>");
String reqSn = strXML.substring(kStart+8, end);
map.put("REQ_SN", reqSn);
}
Pattern pm = Pattern.compile("(?<=<RET_CODE>)([\\S\\s]*?)(?=</RET_CODE>)");
Matcher mm = pm.matcher(strXML);
int i = 0;
while (mm.find())
{
map.put("RET_CODE"+i++, mm.group());
}
Pattern pc = Pattern.compile("(?<=<SN>)([\\S\\s]*?)(?=</SN>)");
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<String, String> getMsgAndCode(String strXML){
Map<String, String> map = new HashMap<String, String>();
int iStart = strXML.indexOf("<ERR_MSG>");
if (iStart != -1) {
int end = strXML.indexOf("</ERR_MSG>");
String strMsg = strXML.substring(iStart+9, end);
map.put("ERR_MSG", strMsg);
}
int jStart = strXML.indexOf("<RET_CODE>");
if (jStart != -1) {
int end = strXML.indexOf("</RET_CODE>");
String strMsg = strXML.substring(jStart+10, end);
map.put("RET_CODE", strMsg);
}
return map;
}
/**
* »ñÈ¡ÏìÓ¦Âë
* @param strXML
* @return
*/
public Map<String, String> getInfoAndStatus(String strXML){
Map<String, String> map = new HashMap<String, String>();
Map<String, String> res = new HashMap<String, String>();
int jStart = strXML.indexOf("<RET_CODE>");
if (jStart != -1) {
int end = strXML.indexOf("</RET_CODE>");
String retCode = strXML.substring(jStart+10, end);
map.put("RET_CODE", retCode);
}
int iStart = strXML.indexOf("<ERR_MSG>");
if (iStart != -1) {
int end = strXML.indexOf("</ERR_MSG>");
String errMsg = strXML.substring(iStart+9, end);
map.put("ERR_MSG", errMsg);
}
int kStart = strXML.indexOf("<TRANS_STATUS>");
if (kStart != -1) {
int end = strXML.indexOf("</TRANS_STATUS>");
String errMsg = strXML.substring(kStart+14, end);
map.put("TRANS_STATUS", errMsg);
}
int lStart = strXML.indexOf("<TRANS_INFO>");
if (lStart != -1) {
int end = strXML.indexOf("</TRANS_INFO>");
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<String, String> vitfyCollectManage(Map<String, String> 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("<?xml version=\"1.0\" encoding=\"GBK\"?>");
strbuff.append("<GZELINK>");
strbuff.append("<INFO>");
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("</INFO>");
strbuff.append("<BODY>");
strbuff.append("<TRANS_SUM>");
strbuff.append("<SUBMIT_TIME>");
strbuff.append(currenttime);//ÇëÇóʱ¼ä
strbuff.append("</SUBMIT_TIME>");
strbuff.append("<MERCHANT_ID>");
strbuff.append(InitCollectConfig.MERCHANTID);//ÉÌ»§ºÅ
/*strbuff.append("000191400207649");//ÉÌ»§ºÅ
*/ strbuff.append("</MERCHANT_ID>");
strbuff.append("<BANK_CODE/>");
strbuff.append("<ACCOUNT_NO>");
strbuff.append(map.get("ACCOUNT_NO"));//¿¨ºÅ
strbuff.append("</ACCOUNT_NO>");
strbuff.append("<ACCOUNT_NAME>");
strbuff.append(map.get("ACCOUNT_NAME"));//»§Ãû
strbuff.append("</ACCOUNT_NAME>");
//ÅжÏÊÇ·ñ´æÔÚ
if (map.containsKey("ID_TYPE")) {
strbuff.append("<ID_TYPE>");
strbuff.append(map.get("ID_TYPE"));//¿ª»§Ö¤¼þÀàÐÍ
strbuff.append("</ID_TYPE>");
}
if (map.containsKey("ID")) {
strbuff.append("<ID>");
strbuff.append(map.get("ID"));//Ö¤¼þºÅ
strbuff.append("</ID>");
}
if (map.containsKey("TEL")) {
strbuff.append("<TEL>");
strbuff.append(map.get("TEL"));//ÊÖ»úºÅ
strbuff.append("</TEL>");
}
strbuff.append("<CRE_VAL_DATE>");
strbuff.append("");//´û¼Ç¿¨ÓÐЧÆÚ
strbuff.append("</CRE_VAL_DATE>");
strbuff.append("<CRE_CVN2>");
strbuff.append("");//´û¼Ç¿¨CV2
strbuff.append("</CRE_CVN2>");
strbuff.append("</TRANS_SUM>");
strbuff.append("</BODY>");
strbuff.append("</GZELINK>");
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;
}
}