package com.tenwa.flow; import java.util.HashMap; import java.util.Map; import jbo.app.tenwa.customer.DISTRIBUTOR_INFO; import jbo.app.tenwa.customer.DISTRIBUTOR_INFO_TEMP; import com.amarsoft.app.util.ASOrgObject; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.util.StringFunction; import com.amarsoft.awe.util.Transaction; import com.amarsoft.context.ASUser; import com.tenwa.comm.util.jboutil.DataOperatorUtil; import com.tenwa.flow.baseBussion.BaseBussiness; import com.tenwa.lease.flow.project.businessapply.DistributorCompare; public class CopyInfoTempToFormal extends BaseBussiness{ @Override public Object run(Transaction Sqlca) throws Exception { this.initBussinessParam(Sqlca); String orgid=this.saveOrgInfo(Sqlca); MapfromCondtion=new HashMap(); fromCondtion.put("flowunid",this.getAttribute("FlowUnid").toString()); BizObject dst= DataOperatorUtil.getSingleJBO(DISTRIBUTOR_INFO_TEMP.CLASS_NAME, fromCondtion, Sqlca); String disStatus = dst.getAttribute("distributor_status").toString(); dst.setAttributeValue("orgid",orgid ); BizObjectManager dit = JBOFactory.getBizObjectManager(DISTRIBUTOR_INFO_TEMP.CLASS_NAME,Sqlca); if("distributor_status08".equals(disStatus)){ dst.setAttributeValue("distributor_status", "distributor_status09"); } dit.saveObject(dst); MaptoCondtion=new HashMap(); DistributorCompare dc=new DistributorCompare(); fromCondtion.clear(); fromCondtion.put("flowunid",this.getAttribute("FlowUnid").toString()); toCondtion.clear(); toCondtion.put("distributor_no", dst.getAttribute("distributor_no").getString()); DataOperatorUtil.copyJBOSet(DISTRIBUTOR_INFO_TEMP.CLASS_NAME, fromCondtion, DISTRIBUTOR_INFO.CLASS_NAME, toCondtion, null, dc, Sqlca); String sMessage="true"; return sMessage; } /** * 保存渠道信息 * @author 2018-06-10 */ private String saveOrgInfo(Transaction Sqlca) throws Exception { ASOrgObject orgObject= new ASOrgObject("8006");//默认为安鹏向下的渠道信息 Map mapOrgInfo=orgObject.nextLevalOrgNo(Sqlca); BizObjectManager manager = JBOFactory.getFactory().getManager("jbo.sys.ORG_INFO"); BizObject bo=null; BizObjectManager PM=JBOFactory.getBizObjectManager(DISTRIBUTOR_INFO_TEMP.CLASS_NAME); BizObject partnerInfo=PM.createQuery(" select * from O where O.flowUnid=:flowUnid").setParameter("flowUnid", this.getAttribute("FlowUnid").toString()).getSingleResult(true); if(!mapOrgInfo.isEmpty()){ ASUser asUser=new ASUser(this.getAttribute("CurUserID").toString()); bo=manager.newObject(); bo.setAttributeValue("ORGID", mapOrgInfo.get("orgno")); bo.setAttributeValue("SORTNO", mapOrgInfo.get("sortno")); bo.setAttributeValue("TREESORTNO", mapOrgInfo.get("sortno")); bo.setAttributeValue("ORGLEVEL", "9");//默认渠道 bo.setAttributeValue("STATUS", "1");//默认启用 if(partnerInfo!=null){ bo.setAttributeValue("RELATIVEORGID", "8006"); bo.setAttributeValue("BELONGORGID", "8006"); bo.setAttributeValue("ORGNAME", partnerInfo.getAttribute("distributor_name").toString()); bo.setAttributeValue("INPUTORG", asUser.getOrgID()); bo.setAttributeValue("InputUser", asUser.getUserID()); bo.setAttributeValue("InputTime", StringFunction.getTodayNow()); } manager.saveObject(bo); } return bo.getAttribute("ORGID").toString(); } }