apzl_leasing/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCacheTj.java
2020-10-20 15:34:05 +08:00

2057 lines
92 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

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.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.quartz.JobExecutionContext;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.amarsoft.app.awe.config.InitCollectConfigTj;
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.tenwa.comm.util.date.DateAssistant;
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
import com.tenwa.lease.app.allinpay.service.impl.AllinpayPaymentDo;
import com.tenwa.quartz.DateUtil;
import jbo.app.tenwa.calc.LC_COLLECT_MANUAL_INFO;
import jbo.app.tenwa.calc.LC_RENT_INCOME;
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;
public class CollectAuditInfoCacheTj {
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;
private String collectStyle;
private String datas;
private String jobName;
public String getDatas() {
return datas;
}
public void setDatas(String datas) {
this.datas = datas;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD>̱<EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD>ID<49><44><EFBFBD>ڱ<EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ϊdepositcharge_id<69><64><EFBFBD><EFBFBD><EFBFBD>˻ر<CBBB><D8B1><EFBFBD>ΪRENT_PLAN_ID
* @param depositcharge_id,tx
* @return
* @throws Exception
*/
public void writeBackDistributor(String rentPlanId,String money,Transaction Sqlca) throws JBOException{
//<2F><>ѯ<EFBFBD>Ƿ<EFBFBD><C7B7>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>¼
BizObject boDRI=JBOFactory.createBizObjectQuery(D_DEPOSITRETURN_INFO.CLASS_NAME,"RENT_PLAN_ID=:rentPlanId").setParameter("rentPlanId", rentPlanId).getSingleResult(false);
if(boDRI!=null&&boDRI.getAttribute("CAUTION_MONEY")!=null){
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BigDecimal dci_money = new BigDecimal("0");
BizObjectManager bmDCI = JBOFactory.getFactory().getManager(D_DEPOSITCHARGE_INFO.CLASS_NAME);
List<BizObject> boDCI=bmDCI.createQuery("RENT_PLAN_ID=:rentPlanId").setParameter("rentPlanId", rentPlanId).getResultList(false);
if(boDCI.size()>0){
for(BizObject bo_dci : boDCI){
dci_money = dci_money.add(new BigDecimal(bo_dci.getAttribute("CAUTION_MONEY").toString()));
}
}
if(dci_money.compareTo(new BigDecimal(boDRI.getAttribute("CAUTION_MONEY").toString()))==-1){
BizObjectManager bmDI = JBOFactory.getFactory().getManager(DISTRIBUTOR_INFO.CLASS_NAME);
//D_DEPOSITCHARGE_INFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BizObject bDCI_N = bmDCI.newObject();
String distributorId = boDRI.getAttribute("DISTRIBUTOR_ID").toString();
bDCI_N.setAttributeValue("DISTRIBUTOR_ID", distributorId);
bDCI_N.setAttributeValue("CAUTION_MONEY", money);
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",rentPlanId);
bmDCI.saveObject(bDCI_N);
//<2F>޸ľ<DEB8><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
BizObject bDI = bmDI.createQuery("distributor_no=:distributor_id").setParameter("distributor_id", distributorId).getSingleResult(true);
String sum = new BigDecimal(bDI.getAttribute("sums").getString()).add(new BigDecimal(money)).toString();
bDI.setAttributeValue("sums", sum);
bmDI.saveObject(bDI);
System.out.println("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>");
}
}
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
/* 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;
}
//У<><D0A3><EFBFBD>Ƿ<EFBFBD><C7B7>Ѿ<EFBFBD><D1BE>տ<EFBFBD>
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<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)) {//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
return "error@"+name+"<22><>"+plan_list+"<22><><EFBFBD><EFBFBD>Ϊ"+plan_date+"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD>пۿ<DBBF><EEB4A6><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ժ<EFBFBD>".trim();
}
if ("".equals(rent) || "0".equals(rent) || "0.0".equals(rent)) {//<2F>ж<EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>
return "error@"+name+"<22><>"+plan_list+"<22><><EFBFBD><EFBFBD>Ϊ"+plan_date+"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ȡ,<2C>޷<EFBFBD><DEB7>ٴοۿ<CEBF>".trim();
}
}
return "sucess";
}
//<2F>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
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 = InitCollectConfigTj.FLAG;
String USER_NAME = InitCollectConfigTj.USERNAME;
String MERCHANT_ID = InitCollectConfigTj.MERCHANTID;
String REQ_TIME = currenttime;
//String URL = "http://59.41.103.98:333/gzdsf/GetSettFile.do?";
String URL = InitCollectConfigTj.CLEARREQUESTURL+"?";
String SIGNED_MSG = "";
try {
Crypt crypt = new Crypt("gbk");
String pathPfx = InitCollectConfigTj.PRIVATEKEYURL;
//"D:\\BaiduNetdisk\\Download\\<5C><><EFBFBD>ո<EFBFBD>ϵͳ<CFB5>ӿ<EFBFBD><D3BF>ĵ<EFBFBD><C4B5><EFBFBD>JAVA<56><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD>demo<6D><6F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>\\JAVA<56><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DEMO<4D><4F><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD>_20170825\\<5C><><EFBFBD><EFBFBD><EFBFBD>̻<EFBFBD>֤<EFBFBD><D6A4>\\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";
}
//<2F><><EFBFBD><EFBFBD>
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("<22><><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>:"+bo.getAttribute("account")+",<2C><><EFBFBD>п<EFBFBD><D0BF><EFBFBD>:"+bo.getAttribute("acc_number")
+",<2C>ֻ<EFBFBD><D6BB><EFBFBD>:"+bo.getAttribute("mobile")+"<22><>ͬ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@<40>ͻ<EFBFBD>"+name+"<22><>δǩԼ,<2C><><EFBFBD>Ƚ<EFBFBD><C8BD><EFBFBD>ǩԼ".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";
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>
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();//ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double income_rent = bo.getAttribute("rent").getDouble();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if ("process".equals(batchstatus)) {//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
return "error@"+name+"<22><>"+plan_list+"<22><><EFBFBD><EFBFBD>Ϊ"+plan_date+"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۿ<DBBF><EEB4A6><EFBFBD><EFBFBD>,<2C>޷<EFBFBD><DEB7>˻س<CBBB><D8B3><EFBFBD>".trim();
}
if ("".equals(rent) || "0".equals(rent) || "0.0".equals(rent)) {//<2F>ж<EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>
return "error@"+name+"<22><>"+plan_list+"<22><><EFBFBD><EFBFBD>Ϊ"+plan_date+"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ȡ,<2C>޷<EFBFBD><DEB7>˻س<CBBB><D8B3><EFBFBD>".trim();
}
if (income_rent > 0 && (fact_rent > income_rent)) {//<2F><><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>
return "error@"+name+"<22><>"+plan_list+"<22><><EFBFBD><EFBFBD>Ϊ"+plan_date+"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ,<2C>޷<EFBFBD><DEB7>˻س<CBBB><D8B3><EFBFBD>".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";
}*/
/**
* ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>
* @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 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 = 'TjbankType' 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))){
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS where O.id=:id")
.setParameter("COLLECT_STATUS", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>")
.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("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") !=-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))){
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS where O.id=:id")
.setParameter("COLLECT_STATUS", "<22><><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>")
.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 "<EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD> "+i+" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD><D5BF>ɹ<EFBFBD>\n"+j+" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>ʧ<EFBFBD><CAA7>";
}
/**
* <20>ӿڴ<D3BF><DAB4><EFBFBD>
* @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{
CollectAuditProcessTj cp = new CollectAuditProcessTj();
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
String currentDateTime = DateAssistant.getTodayNow();
String currentYear = currentDateTime.substring(0,4);
String month = currentDateTime.substring(5,7);
String day = currentDateTime.substring(8,10);
String merchantNumber = InitCollectConfigTj.MERCHANTID;
String flag = InitCollectConfigTj.FLAG;
String version = InitCollectConfigTj.C_VERSION;
String date = currentYear+month+day;//<2F><EFBFBD><E1BDBB><EFBFBD><EFBFBD>
String batch_title = "";
int i = 0,j = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
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()){//Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
file.mkdirs();
}
String req_sn = System.currentTimeMillis()+"";//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD>
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);
//<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
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) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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 += "<EFBFBD><EFBFBD><EFBFBD>׳ɹ<EFBFBD><EFBFBD><EFBFBD>ˮΪ:"+req_sn;
}else{
batch_number += ";<3B><><EFBFBD>׳ɹ<D7B3><C9B9><EFBFBD>ˮΪ:"+req_sn;
}
}else{
if (batch_number.length() == 0) {
batch_number += "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮΪ:"+req_sn;
}else{
batch_number += ";<3B><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD>ˮΪ:"+req_sn;
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
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")) ? "<EFBFBD>տ<EFBFBD><EFBFBD>ɹ<EFBFBD>" : "δ<EFBFBD>տ<EFBFBD>")
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
.setParameter("BATCH_NUMBER", batch_number)
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
//<2F><><EFBFBD>ɴ<EFBFBD><C9B4>̡<EFBFBD><CCA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
savaFile(tx, strResp,batch_title,bo);
return map;
}
/**
* <20>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param tx
* @param bc
* @param bo
* @param rent
* @return
* @throws JBOException
* @throws SQLException
* @throws Exception
*/
public Map<String, String> handcraftsingleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws JBOException, SQLException {
String cerrentDate = DateAssistant.getToday();//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>,<2C><>ʽΪ:yyyy/MM/dd
Map<String, String> map = new HashMap<String, String>();
//<2F><>Ϊ<EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
/*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) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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 += "<22>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"+rent;
}else{
batch_number += ";<3B>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"+rent;
}*/
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id")
.setParameter("COLLECT_STATUS", "<EFBFBD>տ<EFBFBD><EFBFBD>ɹ<EFBFBD>")
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
map.put("RET_CODE", "0000");
return map;
}
/**
* <20>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD>̴<EFBFBD><CCB4><EFBFBD>)
* @param tx
* @param bc
* @param bo
* @param rent
* @return
* @throws JBOException
* @throws SQLException
* @throws Exception
*/
public Map<String, String> handcraftsingleCollectMoenyDistrbutor(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws JBOException, SQLException {
String cerrentDate = DateAssistant.getToday();//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>,<2C><>ʽΪ:yyyy/MM/dd
Map<String, String> map = new HashMap<String, String>();
//<2F><>Ϊ<EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
/*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) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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 += "<22>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"+rent;
}else{
batch_number += ";<3B>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"+rent;
}*/
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
/*bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id")
.setParameter("COLLECT_STATUS", "<22>տ<EFBFBD><D5BF>ɹ<EFBFBD>")
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();*/
map.put("RET_CODE", "0000");
return map;
}
/**
* <20>ֶ<EFBFBD><D6B6>տ<EFBFBD><D5BF>޸<EFBFBD>״̬,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @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<BizObject> bolist = bm.createQuery("select distinct O.contract_id,O.id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,O.rent,O.PENALTY 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<String, String> map = handcraftsingleCollectMoeny(tx,bc,bo,bo.getAttribute("rent").toString(),"1");
i++;
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id")
.setParameter("COLLECT_STATUS", "<EFBFBD>ֹ<EFBFBD><EFBFBD>տ<EFBFBD>")
.setParameter("COLLECT_MSG", "<EFBFBD>ֹ<EFBFBD><EFBFBD>ۿ<EFBFBD>")
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>rent<6E><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȼ<EFBFBD>ȥ<EFBFBD><C8A5>Ϣ)
String rent = new BigDecimal(bo.getAttribute("rent").toString()).subtract( new BigDecimal(bo.getAttribute("PENALTY").toString())).toString();
this.writeBackDistributor(bo.getAttribute("id").toString(),rent, Sqlca);
}
return "<EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD> "+i+" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD><D5BF>ɹ<EFBFBD>\n"+j+" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>ʧ<EFBFBD><CAA7>";
}
/**
* <20>ֶ<EFBFBD><D6B6>տ<EFBFBD><D5BF>޸<EFBFBD>״̬,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>̱<EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @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("@");
String COMPENSATORY_CON=null;
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<ids.length;c++){
BizObject bom = bm.createQuery("select distinct O.contract_id,O.plan_list,O.plan_date,O.id,O.corpus,O.interest,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 ='"+ids[c]+"'").getSingleResult(false);
BigDecimal corpus =new BigDecimal(bom.getAttribute("corpus").getString());
BigDecimal interest =new BigDecimal(bom.getAttribute("interest").getString());
BigDecimal penalty = new BigDecimal(penaltyArray[c]);
String t_rent = corpus.add(interest).add(penalty).toString();
/**
* <20><>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB><EFBFBD>Ƿ<EFBFBD><C7B7>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>¼
*/
String contract_id = bom.getAttribute("contract_id").toString();
int plan_list=Integer.parseInt(bom.getAttribute("plan_list").toString())-1;
// <20><>ѯ<EFBFBD><D1AF>ǰҪ<C7B0><D2AA><EFBFBD><EFBFBD><EFBFBD>ڴε<DAB4><CEB5><EFBFBD>һ<EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>1<EFBFBD><31>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>Ϊ1<CEAA><31>
BizObject ddi = bd.createQuery("SELECT O.COMPENSATORY_CON FROM O WHERE O.MONEY_TYPE='bondRepay' AND O.CONTRACT_ID='"+contract_id+"' AND O.PLAN_LIST='"+plan_list+"'").getSingleResult(false);
if(ddi!=null && !"".equals(ddi)) {
COMPENSATORY_CON=String.valueOf(Integer.parseInt(ddi.getAttribute("COMPENSATORY_CON").getString())+1);
}else {
COMPENSATORY_CON="1";
}
//handcraftsingleCollectMoeny<6E><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭΪhire_list<73><74><EFBFBD>ָ<EFBFBD>Ϊ<EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǻԣ<C7BB>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ձ<EFBFBD><D5B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Map<String, String> map = handcraftsingleCollectMoenyDistrbutor(tx,bc,bom,t_rent,penaltyArray[c]);
i++;
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
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", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
.setParameter("COLLECT_MSG", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̱<EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
.setParameter("PENALTY", penaltyArray[c])
.setParameter("id", bom.getAttribute("id").toString()).executeUpdate();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBBEAD><EFBFBD>̱<EFBFBD>֤<EFBFBD><D6A4><EFBFBD>˻ر<CBBB><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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());
bod.setAttributeValue("COMPENSATORY_CON",COMPENSATORY_CON);
bd.saveObject(bod);
//<2F>޸ľ<DEB8><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
bdi.createQuery("update O set O.sums='"+account_balance+"' where O.distributor_no=:distributor_id").setParameter("distributor_id", distributor_id).executeUpdate();
}
return "<EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD> "+i+" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD><D5BF>ɹ<EFBFBD>\n"+j+" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>ʧ<EFBFBD><CAA7>";
}
private BigDecimal BigDecimal(String string) {
// TODO Auto-generated method stub
return null;
}
private Double Double(String string) {
// TODO Auto-generated method stub
return null;
}
/**
* ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>
* @param rent <09><><EFBFBD><EFBFBD>
* @param acc_number <09><><EFBFBD>п<EFBFBD><D0BF><EFBFBD>
* @param account <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param bankcode <09><><EFBFBD>д<EFBFBD><D0B4><EFBFBD>
* @param province <09><><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD>ʡ<EFBFBD><CAA1>
* @param req_sn <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>
* @return
*/
public StringBuffer collectTimely(String rent,String acc_number,String account,String bankcode,String province,String req_sn){
//ƴ<><C6B4>XML<4D><4C><EFBFBD><EFBFBD>
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(InitCollectConfigTj.C_TRXCODE);
info.setVERSION(InitCollectConfigTj.C_VERSION);
info.setDATA_TYPE(InitCollectConfigTj.C_DATATYPE);
info.setLEVEL(InitCollectConfigTj.C_LEVEL);
info.setUSER_NAME(InitCollectConfigTj.USERNAME);
info.setUSER_PASS(InitCollectConfigTj.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(InitCollectConfigTj.BUSSINESSCODE);
trans_sum.setMERCHANT_ID(InitCollectConfigTj.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);//<2F><><EFBFBD>д<EFBFBD><D0B4><EFBFBD>
trans_detail.setACCOUNT_TYPE("00");
trans_detail.setACCOUNT_NO(acc_number);
trans_detail.setACCOUNT_NAME(account);
trans_detail.setPROVINCE(province);//<2F><><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD>ʡ<EFBFBD><CAA1>
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;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @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);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>в<EFBFBD><D0B2><EFBFBD>
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 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 "ϵͳ<EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD>";
}
/**
* <20>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param tx
* @return
* @throws Exception
*/
public String batchCollectManageManual(JBOTransaction tx) throws Exception{
String[] ids = id.split("@");
String datas_json = datas.replaceAll("@", ",");
JSONObject object = JSON.parseObject(datas_json);
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> bolistTL = 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 collect_type='TLcollect' and O.id in ("+parms.toString()+")").getResultList(false);
List<BizObject> bolistYL = 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 collect_type='YLcollect' and O.id in ("+parms.toString()+")").getResultList(false);
if (bolistTL.size() != 0) {
AllinpayPaymentDo apd = new AllinpayPaymentDo();
for(BizObject bo:bolistTL){
String plan_id = bo.getAttribute("id").toString();
bo.setAttributeValue("rent", object.get(plan_id));
}
apd.BatchCollectMoeny(tx, bolistTL);
}
if (bolistYL.size() != 0) {
for(BizObject bo:bolistYL){
String plan_id = bo.getAttribute("id").toString();
bo.setAttributeValue("rent", object.get(plan_id));
}
singleBatchCollectMoeny(tx, bolistYL);
}
return "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>";
}
/**
* <20><><EFBFBD>鶨ʱ<E9B6A8><CAB1><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param jobName
* @return
*/
public String isRunning(){
try {
Scheduler defaultScheduler = StdSchedulerFactory.getDefaultScheduler();
List<JobExecutionContext> jobContexts = defaultScheduler.getCurrentlyExecutingJobs();
for (JobExecutionContext context : jobContexts) {
System.out.println(context.getTrigger().getJobKey().getName());
if (jobName.equals(context.getTrigger().getJobKey().getName())) {
return "using";
}
}
} catch (SchedulerException e) {
e.printStackTrace();
return "using";
}
System.out.println("<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
return "unUse";
}
/**
* <20><>ȡ<EFBFBD><C8A1><EFBFBD>տۿ<D5BF><DBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ񳬹<C7B7>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param jobName
* @return
*/
public String getCollectCount(){
String flag = "false";
try {
BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME);
String curDate = DateUtil.getSystemTimeByFormat("yyyy/MM/dd");
String[] ids = id.split("@");
for(int i=0;i<ids.length;i++){
int collectCount= bmlcmi.createQuery("select O.id from O where hire_date=:curDate and plan_id=:id group by O.batch_no")
.setParameter("curDate", curDate)
.setParameter("id", ids[i])
.getTotalCount();
if(collectCount>=2){
return flag;
}
}
} catch (JBOException e) {
e.printStackTrace();
return "error";
}
return "true";
}
/**
* <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>״̬
* @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);
BizObjectManager bmlri = JBOFactory.getFactory().getManager(LC_RENT_INCOME.CLASS_NAME);
BizObjectManager blcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.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,O.PENALTY 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 plan_id = bo.getAttribute("id").toString();
//<2F><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>滻Ϊ<E6BBBB>ۿ<EFBFBD><DBBF><EFBFBD><EFBFBD>query_sn<73><6E>lc_rent_plan<61><6E>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>batch_no<6E>IJ<EFBFBD>ѯΪ<D1AF><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>̵ģ<CCB5>
String collectType = "AutoBuckle";
BizObject bolcmi = blcmi.createQuery("select v.sum(money) as v.moneys from O where O.batch_no=:batch_no and O.plan_id=:plan_id group by plan_id,batch_no").setParameter("batch_no", query_sn).setParameter("plan_id", plan_id).getSingleResult(false);
if(bolcmi!=null&&bolcmi.getAttribute("moneys")!=null){
rent = bolcmi.getAttribute("moneys").toString();
bo.setAttributeValue("rent", rent);
collectType = "Manual";
}
String bank_name = bo.getAttribute("BANK_NAME").toString();
String penalty = bo.getAttribute("PENALTY").toString();
BigDecimal penalty_over = new BigDecimal(penalty);
int m = 0;
String[] singleRent = null;
List<BizObject> codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'TjbankType' 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(rent) > itemdescribe) {
BigDecimal mi = new BigDecimal(rent);
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+"";
}
if(l!=0){
singleRent[m-1] = String.format("%.2f",Double.parseDouble(rent) - k*itemdescribe);
}
break;//<2F><><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><E4B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
}
}
}
String[] snArray = sn.split(",");
int n = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>ۿ<EFBFBD><DBBF>ɹ<EFBFBD><C9B9><EFBFBD>¼
BizObject bolrp = bc.createQuery("O.id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false);
String collectStatus = "δ<EFBFBD>տ<EFBFBD>";
String collectStatusPart = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>";
//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
if(bolrp.getAttribute("COLLECT_STATUS")!=null){
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ջ<EFBFBD>Ϊnull<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǡ<EFBFBD><C7A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>
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<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"))) {
//<2F><><EFBFBD><EFBFBD>
querysingleCollectMoeny(tx, bc, bo, rent,i+"");
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>rent<6E><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȼ<EFBFBD>ȥ<EFBFBD><C8A5>Ϣ)
String redRent = new BigDecimal(rent).subtract(new BigDecimal(penalty)).toString();
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
String COLLECT_STATUS = "";
String COLLECT_MSG = "";
//<2F>Զ<EFBFBD><D4B6>ۿ<EFBFBD>
if("AutoBuckle".equals(collectType)){
COLLECT_STATUS = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>";
COLLECT_MSG = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>տ<EFBFBD><D5BF>ɹ<EFBFBD>";
//<2F>ֶ<EFBFBD><D6B6>ۿ<EFBFBD>
}else{
String rent_p = bolrp.getAttribute("rent").toString();
BizObject bolri = bmlri.createQuery("select v.sum(rent) as v.rent from O where plan_id=:plan_id group by plan_id").setParameter("plan_id", plan_id).getSingleResult(false);
String rent_i = bolri.getAttribute("rent").toString();
if(Double.parseDouble(rent_p)>Double.parseDouble(rent_i)){
COLLECT_STATUS = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>";
COLLECT_MSG = "<EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>";
BigDecimal singleRent_over = new BigDecimal(rent);
if(singleRent_over.compareTo(penalty_over)==1){
redRent = new BigDecimal(rent).subtract(penalty_over).toString();
}else{
redRent = "NoRedback";
}
}else{
COLLECT_STATUS = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>";
COLLECT_MSG = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>տ<EFBFBD><D5BF>ɹ<EFBFBD>";
}
}
if(!"NoRedback".equals(redRent)&&!redRent.isEmpty()){
this.writeBackDistributor(bo.getAttribute("id").toString(),redRent,Sqlca);
}
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", COLLECT_STATUS)
.setParameter("COLLECT_MSG", COLLECT_MSG)
.setParameter("BATCH_STATUS", "complete")//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬-<2D><><EFBFBD><EFBFBD>
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
bo.setAttributeValue("COLLECT_STATUS", COLLECT_STATUS);
bo.setAttributeValue("COLLECT_MSG", COLLECT_MSG);
bo.setAttributeValue("BATCH_STATUS", "complete");
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")))){
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еķ<D0B5><C4B7><EFBFBD><EFBFBD><EFBFBD>Ϣ
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{
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
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", "")//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
bo.setAttributeValue("COLLECT_STATUS", "δ<EFBFBD>տ<EFBFBD>");
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+"");
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>rent<6E><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȼ<EFBFBD>ȥ<EFBFBD><C8A5>Ϣ)
BigDecimal singleRent_over = new BigDecimal(singleRent[i-1]);
if(singleRent_over.compareTo(penalty_over)==1){
String redRent = new BigDecimal(singleRent[i-1]).subtract(penalty_over).toString();
penalty_over = new BigDecimal("0");
this.writeBackDistributor(bo.getAttribute("id").toString(),redRent,Sqlca);
}else{
penalty_over = penalty_over.subtract(singleRent_over);
}
n++;
if (n == snArray.length) {
n = 0;//<2F><><EFBFBD>ۿ<EFBFBD><DBBF>ɹ<EFBFBD><C9B9><EFBFBD> <20><>Ϊ 0
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
String rent_p = bolrp.getAttribute("rent").toString();
BizObject bolri = bmlri.createQuery("select v.sum(rent) as v.rent from O where plan_id=:plan_id group by plan_id").setParameter("plan_id", plan_id).getSingleResult(false);
String rent_i = bolri.getAttribute("rent").toString();
if("Manual".equals(collectType)&&Double.parseDouble(rent_p)>Double.parseDouble(rent_i)){
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", collectStatusPart)
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
.setParameter("BATCH_STATUS", "complete")//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬-<2D><><EFBFBD><EFBFBD>
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
bo.setAttributeValue("COLLECT_STATUS", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>");
bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG"));
bo.setAttributeValue("BATCH_STATUS", "complete");
saveBuckle(bo,tx,sn,singleRent[i-1]);
}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", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>")
.setParameter("COLLECT_MSG", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>տ<EFBFBD><D5BF>ɹ<EFBFBD>")
.setParameter("BATCH_STATUS", "complete")//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬-<2D><><EFBFBD><EFBFBD>
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
bo.setAttributeValue("COLLECT_STATUS", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>");
bo.setAttributeValue("COLLECT_MSG", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>տ<EFBFBD><D5BF>ɹ<EFBFBD>");
bo.setAttributeValue("BATCH_STATUS", "complete");
//bo.setAttributeValue("rent", bo.getAttribute("rent").toString());
saveBuckle(bo,tx,sn,singleRent[i-1]);
}
}else{
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
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", collectStatusPart)
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
.setParameter("BATCH_STATUS", "complete")//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬-<2D><><EFBFBD><EFBFBD>
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
bo.setAttributeValue("COLLECT_STATUS", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>");
bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG"));
bo.setAttributeValue("BATCH_STATUS", "complete");
saveBuckle(bo,tx,sn,singleRent[i-1]);
}
}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")))){
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еķ<D0B5><C4B7><EFBFBD><EFBFBD><EFBFBD>Ϣ
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{//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6>ʿۿ<CABF>,<2C><><EFBFBD><EFBFBD><EFBFBD>ۿ<EFBFBD><DBBF>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>δ 0 ,<2C><><EFBFBD><EFBFBD><EFBFBD>¿ۿ<C2BF>״̬Ϊ δ<>ۿ<EFBFBD>
if (i == snArray.length && n == 0) {
//<2F><><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>״̬
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", "")//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
bo.setAttributeValue("COLLECT_STATUS", "δ<EFBFBD>տ<EFBFBD>");
bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG"));
bo.setAttributeValue("BATCH_STATUS", "");
saveBuckle(bo,tx,sn,"0.00");
}
}
}
if (i == snArray.length) {//ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>n<EFBFBD><6E>Ϊ 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());
}
DecimalFormat format = new DecimalFormat("0.00");
rent = format.format(new BigDecimal(rent ));
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);
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ղ<EFBFBD>ѯ<EFBFBD>ӿ<EFBFBD>
* @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{
CollectAuditProcessTj cp = new CollectAuditProcessTj();
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
String currentDateTime = DateAssistant.getTodayNow();
String currentYear = currentDateTime.substring(0,4);
String month = currentDateTime.substring(5,7);
String day = currentDateTime.substring(8,10);
String merchantNumber = InitCollectConfigTj.MERCHANTID;
String flag = InitCollectConfigTj.FLAG;
String version = InitCollectConfigTj.C_VERSION;
String date = currentYear+month+day;//<2F><EFBFBD><E1BDBB><EFBFBD><EFBFBD>
String batch_title = "";
int i = 0,j = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
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()){//Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
file.mkdirs();
}
String req_sn = System.currentTimeMillis()+"";//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD>
batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn;
StringBuffer strbuff = queryBatchXML(req_sn, query_sn,sn);
// queryBatchXML(req_sn, query_sn, sn);
//<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title);
Map<String, String> map = getRetAndCode(strResp);
//<2F><><EFBFBD>ɴ<EFBFBD><C9B4>̡<EFBFBD><CCA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
savaFile(tx, strResp,batch_title,bo);
return map;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD>ӿ<EFBFBD>--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @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>();
//<2F><>Ϊ<EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
/*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) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD>ӿڱ<D3BF><DAB1><EFBFBD>-xml
* @param req_sn <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>
* @param query_sn <09><>ѯ<EFBFBD><D1AF>ˮ<EFBFBD><CBAE>
* @param sn <09><>ѯ<EFBFBD><D1AF>ϸ<EFBFBD><CFB8>
* @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(InitCollectConfigTj.C_VERSION);
info.setDATA_TYPE(InitCollectConfigTj.C_DATATYPE);
info.setREQ_SN(req_sn);
info.setUSER_NAME(InitCollectConfigTj.USERNAME);
info.setUSER_PASS(InitCollectConfigTj.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);//Ҫ<><D2AA>ѯ<EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD>ˮ
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);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8>
strbuff.append("</QUERY_DETAIL_SN>");
strbuff.append("</QUERY_DETAIL>");
strbuff.append("</QUERY_DETAILS>");
strbuff.append("</BODY>");
strbuff.append("</GZELINK>");
return strbuff;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param tx
* @param bc
* @param bo
* @param rent
* @return
* @throws Exception
*/
public Map<String, String> singleBatchCollectMoeny(JBOTransaction tx,List<BizObject> list) throws Exception{
CollectAuditProcessTj cp = new CollectAuditProcessTj();
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
String currentDateTime = DateAssistant.getTodayNow();
String currentYear = currentDateTime.substring(0,4);
String month = currentDateTime.substring(5,7);
String day = currentDateTime.substring(8,10);
String merchantNumber = InitCollectConfigTj.MERCHANTID;
String flag = InitCollectConfigTj.FLAG;
String version = InitCollectConfigTj.C_VERSION;
String date = currentYear+month+day;//<2F><EFBFBD><E1BDBB><EFBFBD><EFBFBD>
String batch_title = "";
int i = 0,j = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
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()){//Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
file.mkdirs();
}
String req_sn = System.currentTimeMillis()+"";//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD>
batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn;
StringBuffer strbuff = collectBatch(req_sn,list);
//<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title);
for (BizObject bo : list) {
//<2F><><EFBFBD>ɴ<EFBFBD><C9B4>̡<EFBFBD><CCA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
savaFile(tx, strResp,batch_title,bo);
}
Map<String, String> map = getRetAndCodeByBatch(strResp);
//<2F><><EFBFBD><EFBFBD>RET_CODE˵<45><CBB5><EFBFBD><EFBFBD>Ӧû<D3A6>гɹ<D0B3>
if (map.containsKey("RET_CODE")) {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
for (BizObject biz : list) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
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", "")//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.setParameter("BATCH_NO", req_sn)
.setParameter("BATCH_SN", "")
.setParameter("id", biz.getAttribute("id").toString()).executeUpdate();
trans.commit();
}
}else{
//<2F><>Ӧ<EFBFBD>ɹ<EFBFBD>
int m = 0;//ͳ<>Ʒ<EFBFBD><C6B7>͵Ĵ<CDB5><C4B4>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>
for (int n = 1; n <= map.size(); n++) {
if (map.containsKey("SN"+n)) {
m++;
}
}
for (int k = 1; k <= m; k++) {
//ÿ<><C3BF><EFBFBD><EFBFBD>Ӧ<EFBFBD>ɹ<EFBFBD>
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);
//<2F><>֪<EFBFBD><D6AA>Ϊɶ<CEAA><C9B6>ôд
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")//<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>Ϊ--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.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")//<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>Ϊ--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.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"))) {
//<2F><><EFBFBD><EFBFBD><EFBFBD>κβ<CEBA><CEB2><EFBFBD>
}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", "")//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
.setParameter("BATCH_NO", map.get("REQ_SN")).executeUpdate();
trans.commit();
}
}
}
}
return map;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--<2D><><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4>
* @param rent
* @param acc_number
* @param account
* @param req_sn
* @return
* @throws JBOException
*/
public StringBuffer collectBatch(String req_sn,List<BizObject> list) throws JBOException{
//ƴ<><C6B4>XML<4D><4C><EFBFBD><EFBFBD>
//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(InitCollectConfigTj.BATCH_TRXCODE);
info.setVERSION(InitCollectConfigTj.C_VERSION);
info.setDATA_TYPE(InitCollectConfigTj.C_DATATYPE);
info.setLEVEL(InitCollectConfigTj.C_LEVEL);
info.setUSER_NAME(InitCollectConfigTj.USERNAME);
info.setUSER_PASS(InitCollectConfigTj.USERPASS);
info.setREQ_SN(req_sn);
info.setSIGNED_MSG("");
strbuff.append(EntityTransform.toXml(info));
strbuff.append("</INFO>");
strbuff.append("<BODY>");
strbuff.append("<TRANS_SUM>");
//<2F>ܽ<EFBFBD><DCBD><EFBFBD>
BigDecimal mutly = new BigDecimal("0");
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int i = 0;
for (BizObject bo : list) {
String single_s = bo.getAttribute("rent").toString();
BigDecimal m_s = new BigDecimal(single_s);
mutly = mutly.add(m_s);
String bank_name = bo.getAttribute("BANK_NAME").toString();
List<BizObject> codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'TjbankType' and O.itemdescribe is not null ").getResultList(false);
//<2F><><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>е<EFBFBD>itemdescribe<62>ֶδ<D6B6><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
BigDecimal itemdescribe = new BigDecimal("0");
boolean flag = false;
for (BizObject code : codelist) {
String itemnameTmp = code.getAttribute("itemname").toString().trim();
String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString();
if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) {
itemdescribe = new BigDecimal(itemdescribeTmp1).setScale(2, BigDecimal.ROUND_HALF_UP);
flag = true;
break;
}
}
if (flag == true && m_s.compareTo(itemdescribe)==1) {
BigDecimal mi_s = m_s;
int singlerent = mi_s.multiply(new BigDecimal(100)).intValue();
int singleitem = itemdescribe.multiply(new BigDecimal(100)).intValue();
int k = singlerent/singleitem;
int l = 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(InitCollectConfigTj.BUSSINESSCODE);
trans_sum.setMERCHANT_ID(InitCollectConfigTj.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();
String planId = biz.getAttribute("id").toString();
List<BizObject> codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'TjbankType' and O.itemdescribe is not null ").getResultList(false);
BigDecimal itemdescribe = new BigDecimal("0");
boolean flag = false;
for (BizObject code : codelist) {
String itemnameTmp = code.getAttribute("itemname").toString().trim();
String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString();
if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) {
itemdescribe = new BigDecimal(itemdescribeTmp1).setScale(2, BigDecimal.ROUND_HALF_UP);
flag = true;
break;
}
}
if (flag == true && m.compareTo(itemdescribe)==1) {
BigDecimal mi = m;
int singlerent = mi.multiply(new BigDecimal(100)).intValue();
int singleitem = itemdescribe.multiply(new BigDecimal(100)).intValue();
int k = singlerent/singleitem;
int l = singlerent%singleitem;
for (int k2 = 1; k2 <= k; k2++) {
Trans_Detail trans_detail = new Trans_Detail();
String sn = "";
if(item < 9){
sn = "0000"+ (++item);
}else if (item >= 9&&item<99) {
sn = "000"+ (++item);
}else if(item >= 99&&item<999){
sn = "00"+ (++item);
}else if(item >= 999&&item<9999){
sn = "0"+ (++item);
}else{
sn = "" + (++item);
}
//׷<><D7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
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", "")//<2F><><EFBFBD><EFBFBD>״̬-Ϊ<><CEAA>
.setParameter("BATCH_NO", req_sn)
.setParameter("BATCH_SN", itemsn0)
.setParameter("id", biz.getAttribute("id").toString()).executeUpdate();
//<2F>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>ֶ<EFBFBD><D6B6><EFBFBD>
if("manual".equals(collectStyle)){
JBOTransaction transj = JBOFactory.createJBOTransaction();
BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,transj);
if(k2==1){
BizObject bolmci = bmlcmi.newObject();
bolmci.setAttributeValue("contract_id",biz.getAttribute("contract_id").toString());
bolmci.setAttributeValue("plan_id",planId);
bolmci.setAttributeValue("BATCH_NO",req_sn);
bolmci.setAttributeValue("BATCH_SN",itemsn0);
bolmci.setAttributeValue("money",biz.getAttribute("rent").toString());
bolmci.setAttributeValue("hire_date",DateUtil.getSystemTimeByFormat("yyyy/MM/dd"));
bmlcmi.saveObject(bolmci);
transj.commit();
}else{
bmlcmi.createQuery("update O set O.BATCH_SN=:BATCH_SN where O.plan_id=:id and O.BATCH_NO=:BATCH_NO")
.setParameter("BATCH_SN", itemsn0)
.setParameter("BATCH_NO", req_sn)
.setParameter("id", planId).executeUpdate();
transj.commit();
}
}
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) {
BigDecimal mj = mi.subtract(itemdescribe.multiply(new BigDecimal(k))).setScale(2, BigDecimal.ROUND_HALF_UP);
String singlerent0 = String.valueOf(mj.multiply(new BigDecimal(100)).longValue());
Trans_Detail trans_detail = new Trans_Detail();
String sn = "";
if(item < 9){
sn = "0000"+ (++item);
}else if (item >= 9&&item<99) {
sn = "000"+ (++item);
}else if(item >= 99&&item<999){
sn = "00"+ (++item);
}else if(item >= 999&&item<9999){
sn = "0"+ (++item);
}else{
sn = "" + (++item);
}
//׷<><D7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
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", "")//<2F><><EFBFBD><EFBFBD>״̬-Ϊ<><CEAA>
.setParameter("BATCH_NO", req_sn)
.setParameter("BATCH_SN", itemsn0)
.setParameter("id", biz.getAttribute("id").toString()).executeUpdate();
//<2F>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>ֶ<EFBFBD><D6B6><EFBFBD>
if("manual".equals(collectStyle)){
JBOTransaction transj = JBOFactory.createJBOTransaction();
BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,transj);
bmlcmi.createQuery("update O set O.BATCH_SN=:BATCH_SN where O.plan_id=:id and O.BATCH_NO=:BATCH_NO")
.setParameter("BATCH_SN", itemsn0)
.setParameter("BATCH_NO", req_sn)
.setParameter("id", planId).executeUpdate();
transj.commit();
}
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){
sn = "0000"+ (++item);
}else if (item >= 9&&item<99) {
sn = "000"+ (++item);
}else if(item >= 99&&item<999){
sn = "00"+ (++item);
}else if(item >= 999&&item<9999){
sn = "0"+ (++item);
}else{
sn = "" + (++item);
}
//׷<><D7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
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", "")//<2F><><EFBFBD><EFBFBD>״̬-Ϊ<><CEAA>
.setParameter("BATCH_NO", req_sn)
.setParameter("BATCH_SN", sn)
.setParameter("id", biz.getAttribute("id").toString()).executeUpdate();
//<2F>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>ֶ<EFBFBD><D6B6><EFBFBD>
if("manual".equals(collectStyle)){
BizObjectManager bmlcmi = JBOFactory.getFactory().getManager(LC_COLLECT_MANUAL_INFO.CLASS_NAME,trans);
BizObject bolmci = bmlcmi.newObject();
bolmci.setAttributeValue("contract_id",biz.getAttribute("contract_id").toString());
bolmci.setAttributeValue("plan_id",planId);
bolmci.setAttributeValue("BATCH_NO",req_sn);
bolmci.setAttributeValue("BATCH_SN",sn);
bolmci.setAttributeValue("money",biz.getAttribute("rent").toString());
bolmci.setAttributeValue("hire_date",DateUtil.getSystemTimeByFormat("yyyy/MM/dd"));
bmlcmi.saveObject(bolmci);
}
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>");
collectStyle=null;
return strbuff;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̡<EFBFBD><CCA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
* @param tx
* @param strResp
* @param batch_title
* @throws Exception
*/
public void savaFile(JBOTransaction tx,String strResp,String batch_title,BizObject bo) throws Exception{
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
String currentDateTime = DateAssistant.getTodayNow();
String currentYear = currentDateTime.substring(0,4);
String month = currentDateTime.substring(5,7);
String day = currentDateTime.substring(8,10);
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
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()){//Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
file.mkdirs();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
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);
//ɸѡ<C9B8><D1A1>Ӧ<EFBFBD><D3A6>Ϣ
Map<String, String> map = getRetAndCode(strResp);
//getMsgAndCode(strResp);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
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);
}
/**
* ʵʱ<CAB5><CAB1><EFBFBD>գ<EFBFBD><D5A3><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
* @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;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD>ر<EFBFBD><D8B1>Ĵ<EFBFBD><C4B4><EFBFBD>
* @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;
}
/**
* <20><>ȡ<EFBFBD><C8A1>Ӧ<EFBFBD><D3A6>
* @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;
}
//<2F><>֤<EFBFBD><D6A4><EFBFBD>п<EFBFBD><D0BF><EFBFBD>Ҫ<EFBFBD><D2AA>
public Map<String, String> vitfyCollectManage(Map<String, String> map) throws CryptException{
CollectAuditProcessTj cp = new CollectAuditProcessTj();
String currentDateTime = DateAssistant.getTodayNow();
String currenttime=currentDateTime.replaceAll("/", "");
currenttime=currenttime.replaceAll(":", "");
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
currenttime=currenttime.replaceAll(" ", "");
//<2F><>֤<EFBFBD><D6A4><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>
//<2F><>ˮ<EFBFBD><CBAE>
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(InitCollectConfigTj.B_TRXCODE);
info.setVERSION(InitCollectConfigTj.B_VERSION);
info.setDATA_TYPE(InitCollectConfigTj.B_DATATYPE);
info.setLEVEL(InitCollectConfigTj.B_LEVEL);
info.setUSER_NAME(InitCollectConfigTj.USERNAME);
info.setUSER_PASS(InitCollectConfigTj.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);//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
strbuff.append("</SUBMIT_TIME>");
strbuff.append("<MERCHANT_ID>");
strbuff.append(InitCollectConfigTj.MERCHANTID);//<2F>̻<EFBFBD><CCBB><EFBFBD>
/*strbuff.append("000191400207649");//<2F>̻<EFBFBD><CCBB><EFBFBD>
*/ strbuff.append("</MERCHANT_ID>");
strbuff.append("<BANK_CODE/>");
strbuff.append("<ACCOUNT_NO>");
strbuff.append(map.get("ACCOUNT_NO"));//<2F><><EFBFBD><EFBFBD>
strbuff.append("</ACCOUNT_NO>");
strbuff.append("<ACCOUNT_NAME>");
strbuff.append(map.get("ACCOUNT_NAME"));//<2F><><EFBFBD><EFBFBD>
strbuff.append("</ACCOUNT_NAME>");
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
if (map.containsKey("ID_TYPE")) {
strbuff.append("<ID_TYPE>");
strbuff.append(map.get("ID_TYPE"));//<2F><><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
strbuff.append("</ID_TYPE>");
}
if (map.containsKey("ID")) {
strbuff.append("<ID>");
strbuff.append(map.get("ID"));//֤<><D6A4><EFBFBD><EFBFBD>
strbuff.append("</ID>");
}
if (map.containsKey("TEL")) {
strbuff.append("<TEL>");
strbuff.append(map.get("TEL"));//<2F>ֻ<EFBFBD><D6BB><EFBFBD>
strbuff.append("</TEL>");
}
strbuff.append("<CRE_VAL_DATE>");
strbuff.append("");//<2F><><EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD>Ч<EFBFBD><D0A7>
strbuff.append("</CRE_VAL_DATE>");
strbuff.append("<CRE_CVN2>");
strbuff.append("");//<2F><><EFBFBD>ǿ<EFBFBD>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;
}
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;
}
public String getCollectStyle() {
return collectStyle;
}
public void setCollectStyle(String collectStyle) {
this.collectStyle = collectStyle;
}
public String getJobName() {
return jobName;
}
public void setJobName(String jobName) {
this.jobName = jobName;
}
}