apzl_leasing/src_sys/com/tenwa/flow/action/comm/FlowBussionAction.java
zhangbb 1bcf4934f3 1.业务申请选择产品时,设置生效日期。
2.产品中增加是否有佣金,并在业务申请时增加到项目表中。
2018-10-09 09:30:44 +08:00

287 lines
9.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
private String customertype;
private String custname;
private String leasform;
private String carAttributes;
public List<BizObject> FlowMutexConfig;
public Map<String, String> FlowParam = new HashMap<String, String>();
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<String, String> scriptMap = new HashMap<String, String>();
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 executeFlowBackScript(JBOTransaction tx,
BizObject flowBussinessObject) throws Exception {
Item item = CodeManager.getItem("ApplyType", this.getApplyType());
String flowno = item.getAttribute2();
Map<String, String> scriptMap = new HashMap<String, String>();
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.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<String, String> getFlowParam() {
return FlowParam;
}
public void setFlowParam(Map<String, String> flowParam) {
FlowParam = flowParam;
}
public String getFlowNo() {
return FlowNo;
}
public void setFlowNo(String flowNo) {
FlowNo = flowNo;
}
public List<BizObject> getFlowMutexConfig() {
return FlowMutexConfig;
}
public void setFlowMutexConfig(List<BizObject> 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;
}
}