package com.tenwa.lease.app.projecttransfer; import java.util.List; import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO_TEMP; import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO; import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO_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; import com.tenwa.comm.util.date.DateAssistant; public class ProjectTransferInpfoHandler extends CommonHandler { @Override protected void initDisplayForAdd(BizObject bo) throws Exception { String projectId = this.asPage.getParameter("projectId"); String projectManage = this.asPage.getParameter("projectManage"); bo.setAttributeValue("PROJECT_ID", projectId); bo.setAttributeValue("OLD_MANAGER", projectManage); bo.setAttributeValue("INPUTUSERID", this.curUser.getUserID()); bo.setAttributeValue("INPUTORGID", this.curUser.getOrgID()); bo.setAttributeValue("INPUTTIME", DateAssistant.getTodayNow()); super.initDisplayForAdd(bo); } @Override protected void afterInsert(JBOTransaction tx, BizObject bo) throws Exception { String projectId = bo.getAttribute("PROJECT_ID").getString(); String newProjectManage = bo.getAttribute("NEW_MANAGER").getString(); String newProjectDept = bo.getAttribute("NEW_ORGID").getString(); String newOrgLevelName = bo.getAttribute("NEW_ORGLEVEL").getString(); BizObjectManager lpiManager = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx); BizObjectManager lpitManager = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME, tx); BizObjectManager lciManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME, tx); BizObjectManager lcitManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO_TEMP.CLASS_NAME, tx); BizObject lpi = lpiManager.createQuery("ID=:id").setParameter("id",bo.getAttribute("PROJECT_ID").getString()).getSingleResult(false); //更新项目正式表 lpiManager.createQuery("UPDATE O SET PROJECT_DEPT=:projectdept,PROJECT_MANAGE=:projectmanage,PROJECT_DEPT_DETAIL=:projectdeptdetail,ISTRANSFER='Y',UPDATEUSERID=:updateuserid,UPDATEORGID=:updateorgid,UPDATETIME=:updatetime where ID=:id") .setParameter("projectdept",newProjectDept).setParameter("projectmanage",newProjectManage).setParameter("projectdeptdetail",newOrgLevelName).setParameter("updateuserid",this.curUser.getUserID()) .setParameter("updateorgid",this.curUser.getOrgID()).setParameter("updatetime",DateAssistant.getTodayNow()).setParameter("id",projectId).executeUpdate(); //更新项目临时表 List lpits = lpitManager.createQuery("PROJECT_NO=:projectno").setParameter("projectno",lpi.getAttribute("PROJECT_NO").getString()).getResultList(false); if(lpits.size()>0){ lpitManager.createQuery("UPDATE O SET PROJECT_DEPT=:projectdept,PROJECT_MANAGE=:projectmanage,PROJECT_DEPT_DETAIL=:projectdeptdetail,UPDATEUSERID=:updateuserid,UPDATEORGID=:updateorgid,UPDATETIME=:updatetime where PROJECT_NO=:projectno") .setParameter("projectdept",newProjectDept).setParameter("projectmanage",newProjectManage).setParameter("projectdeptdetail",newOrgLevelName).setParameter("updateuserid",this.curUser.getUserID()) .setParameter("updateorgid",this.curUser.getOrgID()).setParameter("updatetime",DateAssistant.getTodayNow()).setParameter("projectno",lpi.getAttribute("PROJECT_NO").getString()).executeUpdate(); } //更新合同正式表 List lcis = lciManager.createQuery("PROJECT_ID=:projectid ").setParameter("projectid",projectId).getResultList(false); if(lcis.size()>0){ lciManager.createQuery("UPDATE O SET PROJECT_DEPT=:projectdept,PROJECT_MANAGE=:projectmanage,UPDATEUSERID=:updateuserid,UPDATEORGID=:updateorgid,UPDATETIME=:updatetime where PROJECT_ID=:projectid ") .setParameter("projectdept",newProjectDept).setParameter("projectmanage",newProjectManage).setParameter("updateuserid",this.curUser.getUserID()) .setParameter("updateorgid",this.curUser.getOrgID()).setParameter("updatetime",DateAssistant.getTodayNow()).setParameter("projectid",projectId).executeUpdate(); } //更新合同临时表 List lcits = lcitManager.createQuery("PROJECT_ID=:projectid ").setParameter("projectid",projectId).getResultList(false); if(lcits.size()>0){ lcitManager.createQuery("UPDATE O SET PROJECT_DEPT=:projectdept,PROJECT_MANAGE=:projectmanage,UPDATEUSERID=:updateuserid,UPDATEORGID=:updateorgid,UPDATETIME=:updatetime where PROJECT_ID=:projectid ") .setParameter("projectdept",newProjectDept).setParameter("projectmanage",newProjectManage).setParameter("updateuserid",this.curUser.getUserID()) .setParameter("updateorgid",this.curUser.getOrgID()).setParameter("updatetime",DateAssistant.getTodayNow()).setParameter("projectid",projectId).executeUpdate(); } super.afterInsert(tx, bo); } }