apzl_leasing/src_tenwa/com/tenwa/customer/handler/person/NewCustomerPersonHandler.java
2018-06-03 22:26:41 +08:00

121 lines
7.3 KiB
Java

package com.tenwa.customer.handler.person;
import jbo.app.tenwa.customer.CUSTOMER_INFO;
import jbo.app.tenwa.customer.CUSTOMER_TYPE;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.BizObjectQuery;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.awe.dw.handler.impl.CommonHandler;
import com.tenwa.comm.util.date.DateAssistant;
public class NewCustomerPersonHandler extends CommonHandler{
@Override
protected void initDisplayForAdd(BizObject bo) throws Exception {
String customerId=this.asPage.getAttribute("customerId").toString();
BizObject cust = JBOFactory.getBizObjectManager(CUSTOMER_INFO.CLASS_NAME).createQuery("customerid=:customerid ")
.setParameter("customerid",customerId).getSingleResult(false);
BizObject custtype = JBOFactory.getBizObjectManager(CUSTOMER_TYPE.CLASS_NAME).createQuery("customerid=:customerid and custtype='cust_type.cust'")
.setParameter("customerid",customerId).getSingleResult(false);
//将客户注册信息带初始化至客户基本信息中
bo.setAttributeValue("CUSTOMERID",customerId);
bo.setAttributeValue("FULLNAME",cust.getAttribute("customername").getString());
bo.setAttributeValue("status", custtype.getAttribute("custstatus").getString());
bo.setAttributeValue("CERTTYPE",cust.getAttribute("certtype").getString());
bo.setAttributeValue("CERTID",cust.getAttribute("certid").getString());
bo.setAttributeValue("COUNTRY",cust.getAttribute("nationcode").getString());
}
@Override
protected void initDisplayForEdit(BizObject bo) throws Exception {
String customerId=this.asPage.getAttribute("customerId").toString();
BizObject cust = JBOFactory.getBizObjectManager(CUSTOMER_INFO.CLASS_NAME).createQuery("customerid=:customerid ")
.setParameter("customerid",customerId).getSingleResult(false);
BizObject custtype = JBOFactory.getBizObjectManager(CUSTOMER_TYPE.CLASS_NAME).createQuery("customerid=:customerid and custtype='cust_type.cust'")
.setParameter("customerid",customerId).getSingleResult(false);
//将客户注册信息带初始化至客户基本信息中
bo.setAttributeValue("CUSTOMERID",customerId);
bo.setAttributeValue("FULLNAME",cust.getAttribute("customername").getString());
bo.setAttributeValue("status", custtype.getAttribute("custstatus").getString());
bo.setAttributeValue("CERTTYPE",cust.getAttribute("certtype").getString());
bo.setAttributeValue("CERTID",cust.getAttribute("certid").getString());
bo.setAttributeValue("COUNTRY",cust.getAttribute("nationcode").getString());
super.initDisplayForEdit(bo);
}
@Override
protected void afterInsert(JBOTransaction tx, BizObject bo)
throws Exception {
//同步更新customer_info custkind字段和customer_type status字段
String customerId=this.asPage.getAttribute("customerId").toString();
String custkind=bo.getAttribute("custkind").toString();
BizObjectManager custManager = JBOFactory.getBizObjectManager(CUSTOMER_INFO.CLASS_NAME);
BizObject cust = custManager.createQuery("customerid=:customerid ").setParameter("customerid",customerId).getSingleResult(true);
BizObjectManager custtypeManager = JBOFactory.getBizObjectManager(CUSTOMER_TYPE.CLASS_NAME);
BizObject custtype=custtypeManager.createQuery("customerid=:customerid and custtype='cust_type.cust'")
.setParameter("customerid",customerId).getSingleResult(true);
if(!custtype.getAttribute("custstatus").getString().equals(bo.getAttribute("status").getString())){
BizObjectQuery custtypebq = custtypeManager.createQuery("update O set custstatus=:custstatus,updateuserid=:updateuserid,updatetime=:updatetime,updateorgid=:updateorgid where customerid= :customerid and custtype='cust_type.cust'");
custtypebq.setParameter("custstatus",bo.getAttribute("status").getString());
custtypebq.setParameter("customerid",customerId);
custtypebq.setParameter("updateuserid", curUser.getUserID());
custtypebq.setParameter("updatetime",DateAssistant.getTodayNow());
custtypebq.setParameter("updateorgid",curUser.getOrgID());
custtypebq.executeUpdate();
}
if(!cust.getAttribute("custkind").getString().equals(bo.getAttribute("custkind").getString())){
BizObjectQuery custbq = custManager.createQuery("update O set custkind=:custkind,updateuserid=:updateuserid,updatetime=:updatetime,updateorgid=:updateorgid where customerid= :customerid ");
custbq.setParameter("customerid",customerId);
custbq.setParameter("updateuserid", curUser.getUserID());
custbq.setParameter("updatetime",DateAssistant.getTodayNow());
custbq.setParameter("updateorgid",curUser.getOrgID());
custbq.setParameter("custkind",custkind);
custbq.executeUpdate();
}
}
@Override
protected void afterUpdate(JBOTransaction tx, BizObject bo)
throws Exception {
//同步更新customer_info custkind,customername字段和customer_type status字段
String customerId=this.asPage.getAttribute("customerId").toString();
String custkind=bo.getAttribute("custkind").toString();
String FULLNAME=bo.getAttribute("FULLNAME").toString();
BizObjectManager custManager = JBOFactory.getBizObjectManager(CUSTOMER_INFO.CLASS_NAME);
BizObject cust = custManager.createQuery("customerid=:customerid ").setParameter("customerid",customerId).getSingleResult(true);
BizObjectManager custtypeManager = JBOFactory.getBizObjectManager(CUSTOMER_TYPE.CLASS_NAME);
BizObject custtype=custtypeManager.createQuery("customerid=:customerid and custtype='cust_type.cust'")
.setParameter("customerid",customerId).getSingleResult(true);
if(!custtype.getAttribute("custstatus").getString().equals(bo.getAttribute("status").getString())){
BizObjectQuery custtypebq = custtypeManager.createQuery("update O set custstatus=:custstatus,updateuserid=:updateuserid,updatetime=:updatetime,updateorgid=:updateorgid where customerid= :customerid and custtype='cust_type.cust'");
custtypebq.setParameter("custstatus",bo.getAttribute("status").getString());
custtypebq.setParameter("customerid",customerId);
custtypebq.setParameter("updateuserid", curUser.getUserID());
custtypebq.setParameter("updatetime",DateAssistant.getTodayNow());
custtypebq.setParameter("updateorgid",curUser.getOrgID());
custtypebq.executeUpdate();
}
if(!cust.getAttribute("custkind").getString().equals(bo.getAttribute("custkind").getString())){
BizObjectQuery custbq = custManager.createQuery("update O set custkind=:custkind,updateuserid=:updateuserid,updatetime=:updatetime,updateorgid=:updateorgid where customerid= :customerid ");
custbq.setParameter("customerid",customerId);
custbq.setParameter("updateuserid", curUser.getUserID());
custbq.setParameter("updatetime",DateAssistant.getTodayNow());
custbq.setParameter("updateorgid",curUser.getOrgID());
custbq.setParameter("custkind",custkind);
custbq.executeUpdate();
}
if(!cust.getAttribute("customername").getString().equals(bo.getAttribute("FULLNAME").getString())){
BizObjectQuery custbq = custManager.createQuery("update O set customername=:customername,updateuserid=:updateuserid,updatetime=:updatetime,updateorgid=:updateorgid where customerid= :customerid ");
custbq.setParameter("customerid",customerId);
custbq.setParameter("updateuserid", curUser.getUserID());
custbq.setParameter("updatetime",DateAssistant.getTodayNow());
custbq.setParameter("updateorgid",curUser.getOrgID());
custbq.setParameter("customername",FULLNAME);
custbq.executeUpdate();
}
}
}