package com.tenwa.flow.fund.copyebank; import java.util.ArrayList; import java.util.List; import java.util.Map; import jbo.app.tenwa.calc.LC_FUND_INCOME_TEMP; import jbo.app.tenwa.calc.LC_RENT_INCOME_TEMP; import jbo.com.tenwa.entity.comm.flow.FLOW_WORK_FLAG; import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.awe.util.Transaction; import com.tenwa.flow.action.comm.BaseFlowStartAction; import com.tenwa.flow.baseBussion.BaseBussiness; import com.tenwa.template.check.DefaultBussinessCheck; public class FlowCheck extends DefaultBussinessCheck { @Override public Object run(Transaction Sqlca) throws Exception { JBOTransaction tx = JBOFactory.createJBOTransaction(); try{ String flowunid = this.getAttribute("ObjectNo").toString(); JBOFactory.getBizObjectManager(FLOW_WORK_FLAG.CLASS_NAME,tx).createQuery("delete from O where flow_unid=:flowunid").setParameter("flowunid", flowunid).executeUpdate(); BaseFlowStartAction bfsa = new BaseFlowStartAction(); BaseBussiness bb = new BaseBussiness(); bb.setAttribute("ObjectNo", flowunid); bb.initBussinessParam(tx); bfsa.setApplyType(bb.getAttribute("applyType").toString()); bfsa.initFlowInfo(); Map params = bfsa.getFlowParam(); params.put("FlowUnid", flowunid); bfsa.setFlowParam(params); boolean flag = true; String message = ","; List contractIDs = new ArrayList(); List bosLFIT = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME).createQuery("flowunid=:flowunid").setParameter("flowunid", flowunid).getResultList(false); if(bosLFIT.size() > 0){ for(BizObject bo:bosLFIT){ String contractID = bo.getAttribute("contract_id").getString(); if(!contractIDs.contains(contractID)){ contractIDs.add(contractID); } } } List bosLRIT = JBOFactory.getBizObjectManager(LC_RENT_INCOME_TEMP.CLASS_NAME).createQuery("flowunid=:flowunid").setParameter("flowunid", flowunid).getResultList(false); if(bosLRIT.size() > 0){ for(BizObject bo:bosLRIT){ String contractID = bo.getAttribute("contract_id").getString(); if(!contractIDs.contains(contractID)){ contractIDs.add(contractID); } } } for(String con:contractIDs){ bfsa.FlowParam.put("ContractId", con); String checkResult = bfsa.flowMutexCheck(tx); if(checkResult.length() > 0){ BizObject boC = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME).createQuery("id=:contractID").setParameter("contractID", con).getSingleResult(false); message += "业务合同号【" + boC.getAttribute("contract_number").getString() + "】正在走" + checkResult.substring(checkResult.indexOf("【")+1, checkResult.indexOf("[")) + "!"; flag = false; }else{ bfsa.flowMutexInfoInit(tx); } } if(!flag){ message = message.substring(1); putMsg(message); tx.commit(); this.setPass(false); }else{ tx.commit(); putMsg("验证通过!"); this.setPass(true); } }catch(Exception e){ e.printStackTrace(); tx.rollback(); } return null; } }