apzl_leasing/src_tenwa/com/tenwa/flow/comm/handler/BusinessCustomerInfoHandler.java
2018-08-17 18:11:29 +08:00

67 lines
3.3 KiB
Java

package com.tenwa.flow.comm.handler;
import jbo.app.tenwa.customer.CUSTOMER_ADDRESS_TEMP;
import jbo.app.tenwa.customer.CUSTOMER_FAMILY_TEMP;
import jbo.com.tenwa.lease.comm.LB_UNION_LESSEE_TEMP;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.awe.dw.handler.impl.CommonHandler;
public class BusinessCustomerInfoHandler extends CommonHandler {
@Override
protected void beforeInsert(JBOTransaction tx, BizObject bo)
throws Exception {
BizObjectManager bomCAT = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS_TEMP.CLASS_NAME, tx);
BizObject boCAT = bomCAT.newObject();
boCAT.setAttributeValue("customerid", bo.getAttribute("customerid"));
boCAT.setAttributeValue("isadd", "yes");
boCAT.setAttributeValue("isnew", "yes");
boCAT.setAttributeValue("country", "CHN");
boCAT.setAttributeValue("addtype", "0060");
boCAT.setAttributeValue("status", "valid");
boCAT.setAttributeValue("province", bo.getAttribute("province"));
boCAT.setAttributeValue("dressdetail", bo.getAttribute("dressdetail"));
boCAT.setAttributeValue("zipcode", bo.getAttribute("zipcode"));
boCAT.setAttributeValue("fulladdress", bo.getAttribute("fulladdress"));
boCAT.setAttributeValue("flowunid", bo.getAttribute("FLOWUNID"));
bomCAT.saveObject(boCAT);
}
@Override
protected void beforeUpdate(JBOTransaction tx, BizObject bo)
throws Exception {
BizObjectManager bomCAT= JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS_TEMP.CLASS_NAME, tx);
BizObjectManager bomLULT= JBOFactory.getBizObjectManager(LB_UNION_LESSEE_TEMP.CLASS_NAME, tx);
BizObjectManager cftManage = JBOFactory.getBizObjectManager(CUSTOMER_FAMILY_TEMP.CLASS_NAME, tx);
BizObject boCAT=bomCAT.createQuery("customerid=:customerid and flowunid='"+bo.getAttribute("FLOWUNID").getString()+"'").setParameter("customerid", bo.getAttribute("customerid").getString()).getSingleResult(true);
BizObject boLULT=bomLULT.createQuery("customer_id=:customerid and flowunid='"+bo.getAttribute("FLOWUNID").getString()+"'").setParameter("customerid", bo.getAttribute("customerid").getString()).getSingleResult(true);
boLULT.setAttributeValue("customer_name", bo.getAttribute("fullname"));
bomLULT.saveObject(boLULT);
if(boCAT==null){
boCAT=bomCAT.newObject();
boCAT.setAttributeValue("customerid", bo.getAttribute("customerid"));
boCAT.setAttributeValue("flowunid", bo.getAttribute("flowunid"));
boCAT.setAttributeValue("isadd", "yes");
boCAT.setAttributeValue("isnew", "yes");
boCAT.setAttributeValue("country", "CHN");
boCAT.setAttributeValue("addtype", "0060");
}
boCAT.setAttributeValue("addtype", "0060");
boCAT.setAttributeValue("province", bo.getAttribute("province"));
boCAT.setAttributeValue("dressdetail", bo.getAttribute("dressdetail"));
boCAT.setAttributeValue("zipcode", bo.getAttribute("zipcode"));
boCAT.setAttributeValue("fulladdress", bo.getAttribute("fulladdress"));
bomCAT.saveObject(boCAT);
if(!("01".equals(bo.getAttribute("MARRIAGE").getString()))){
BizObject cft = cftManage.createQuery("flowunid=:flowunid and Spouse_='Y'").setParameter("flowunid", bo.getAttribute("flowunid").getString()).getSingleResult(true);
if(cft!=null){
cftManage.deleteObject(cft);
}
}
}
}