package com.tenwa.flow.action.comm; import java.util.HashMap; import java.util.List; import java.util.Map; import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT; import jbo.com.tenwa.entity.comm.flow.FLOW_MUTEX_CONFIG; import jbo.sys.FLOW_CATALOG; import jbo.sys.FLOW_MODEL; import jbo.ui.system.CODE_LIBRARY; import com.amarsoft.amarscript.Any; import com.amarsoft.amarscript.ELContext; import com.amarsoft.amarscript.Expression; 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.are.util.json.JSONDecoder; import com.amarsoft.are.util.json.JSONObject; import com.amarsoft.awe.util.Transaction; import com.amarsoft.dict.als.manage.CodeManager; import com.amarsoft.dict.als.object.Item; import com.tenwa.officetempalte.util.FileOperatorUtil; public class FlowBussionAction extends CommonAction { private String FlowUnid; private String ProjectId; private String ContractId; private String ProjectName; private String FlowName; private String FlowNo; private String FlowKey; private String ProductId; private String FixedFlowParam; public String customertype; public String custname; public String leasform; public String carAttributes; public List FlowMutexConfig; public Map FlowParam = new HashMap(); public BizObject initFLowBusinonObject(JBOTransaction tx) throws Exception { JSONObject jsonFixedFlowParam = JSONDecoder.decode(this.getFixedFlowParam().replaceAll("@", ",")); this.FlowParam= FileOperatorUtil.getJsonObjectToMap(jsonFixedFlowParam); this.initFlowInfo(); // 初始化当前用户信息 BizObjectManager bm = JBOFactory.getBizObjectManager(FLOW_BUSSINESS_OBJECT.CLASS_NAME); tx.join(bm); BizObject bo = bm.newObject(); this.FlowParam.put("FlowName",this.getFlowName()); this.initFLowBussionObjectByParam(bo); bo = this.initTabeUserInfo(bo); bm.saveObject(bo); this.FlowParam.put("FlowUnid", bo.getAttribute("flow_unid").getString()); this.updateFLowBusinonObject(tx); return bo; } public void initFLowBussionObjectByParam(BizObject bo)throws Exception { if(this.FlowParam.containsKey("ProjectId")){bo.setAttributeValue("proj_id",this.FlowParam.get("ProjectId"));} if(this.FlowParam.containsKey("ContractId")){bo.setAttributeValue("contract_id",this.FlowParam.get("ContractId"));} if(this.FlowParam.containsKey("ProjectName")){bo.setAttributeValue("proj_name",this.FlowParam.get("ProjectName"));} if(this.FlowParam.containsKey("FlowName")){bo.setAttributeValue("flow_Name",this.FlowParam.get("FlowName"));} if(this.FlowParam.containsKey("FlowKey")){bo.setAttributeValue("Flow_key",this.FlowParam.get("FlowKey"));} if(this.FlowParam.containsKey("ProductId")){bo.setAttributeValue("productId",this.FlowParam.get("ProductId"));} bo.setAttributeValue("FixedFlowParam",FileOperatorUtil.getMapToJsonStr(this.FlowParam)); } public String updateFLowBusinonObject(JBOTransaction tx) throws Exception { // 初始化当前用户信息 BizObjectManager bm = JBOFactory.getBizObjectManager(FLOW_BUSSINESS_OBJECT.CLASS_NAME); tx.join(bm); BizObjectQuery bqDest = bm.createQuery("flow_unid=:flowunid"); bqDest.setParameter("flowunid", this.FlowParam.get("FlowUnid")); BizObject bo = bqDest.getSingleResult(true);// 目标JBO,需要做更新操作 this.initFLowBussionObjectByParam(bo); bo = this.initTabeUserInfo(bo); bm.saveObject(bo); return bo.getAttribute("flow_unid").toString(); } /** * 执行行前沿检查 * * @param tx * @param sObjectNo * @throws Exception */ public void executeFlowStartScript(JBOTransaction tx, BizObject flowBussinessObject) throws Exception { Item item = CodeManager.getItem("ApplyType", this.getApplyType()); String flowno = item.getAttribute2(); Map scriptMap = new HashMap(); scriptMap.put("ObjectNo", flowBussinessObject.getAttribute("flow_unid") .getString()); scriptMap.put("UserID", this.getAsUser().getUserID()); scriptMap.put("UserName", this.getAsUser().getUserName()); scriptMap.put("OrgID", this.getAsUser().getOrgID()); scriptMap.put("OrgName", this.getAsUser().getOrgName()); scriptMap.put("FlowUnid", flowBussinessObject.getAttribute("flow_unid").getString()); scriptMap.put("FlowNo", flowno); scriptMap.put("FlowName", this.getFlowName()); scriptMap.put("FlowKey", this.getFlowKey()); scriptMap.put("custname",this.getCustname()); Transaction Sqlca = null; BizObjectManager bm1 = null; BizObjectQuery bq1 = null; bm1 = JBOFactory.getFactory().getManager(FLOW_MODEL.CLASS_NAME); bq1 = bm1 .createQuery( "SELECT o.PRESCRIPT FROM O where O.phaseno='0010' and O.flowno=:flowno") .setParameter("flowno", flowno); BizObject stepConfig = bq1.getSingleResult(true); String strScript = stepConfig.getAttribute("PRESCRIPT").getString(); if (null != strScript && strScript.length() > 5) { ELContext context = new ELContext(); context.setJBOTransaction(tx); for (String key : scriptMap.keySet()) { context.defineVarible("#" + key, scriptMap.get(key)); } context.defineBean("flowBussinessObject", flowBussinessObject); Any returnData = Expression.getExpressionValue(strScript, context); } } public void initFlowInfo() throws Exception{ BizObjectManager code = JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME); BizObjectManager cataLog = JBOFactory.getBizObjectManager(FLOW_CATALOG.CLASS_NAME); BizObjectQuery bqCode = code.createQuery("itemno='"+ this.getApplyType() + "'"); BizObject objCode = bqCode.getSingleResult(true); BizObjectQuery bqCata = cataLog.createQuery("flowno='"+ objCode.getAttribute("attribute2").toString() + "'"); BizObject objCata = bqCata.getSingleResult(true); this.FlowName = objCata.getAttribute("flowname").toString(); this.FlowNo= objCode.getAttribute("attribute2").toString(); BizObjectManager mutexManager = JBOFactory.getBizObjectManager(FLOW_MUTEX_CONFIG.CLASS_NAME); this.FlowMutexConfig=mutexManager.createQuery("flow_namea=:flowname").setParameter("flowname",this.getFlowNo()).getResultList(false); } public String getFlowName() throws Exception { return this.FlowName; } public String getFlowUnid() { return FlowUnid; } public void setFlowUnid(String flowUnid) { FlowUnid = flowUnid; } public String getProjectId() { return ProjectId; } public void setProjectId(String projectId) { ProjectId = projectId; } public String getContractId() { return ContractId; } public void setContractId(String contractId) { ContractId = contractId; } public String getProjectName() { return ProjectName; } public void setProjectName(String projectName) { ProjectName = projectName; } public void setFlowName(String flowName) { FlowName = flowName; } public String getFlowKey() { return FlowKey; } public void setFlowKey(String flowKey) { FlowKey = flowKey; } public String getProductId() { return ProductId; } public void setProductId(String productId) { ProductId = productId; } public String getFixedFlowParam() { return FixedFlowParam; } public void setFixedFlowParam(String fixedFlowParam) { FixedFlowParam = fixedFlowParam; } public Map getFlowParam() { return FlowParam; } public void setFlowParam(Map flowParam) { FlowParam = flowParam; } public String getFlowNo() { return FlowNo; } public void setFlowNo(String flowNo) { FlowNo = flowNo; } public List getFlowMutexConfig() { return FlowMutexConfig; } public void setFlowMutexConfig(List flowMutexConfig) { FlowMutexConfig = flowMutexConfig; } public String getCustomertype() { return customertype; } public void setCustomertype(String customertype) { this.customertype = customertype; } public String getCustname() { return custname; } public void setCustname(String custname) { this.custname = custname; } public String getLeasform() { return leasform; } public void setLeasform(String leasform) { this.leasform = leasform; } public String getCarAttributes() { return carAttributes; } public void setCarAttributes(String carAttributes) { this.carAttributes = carAttributes; } }