apzl_leasing/calc/com/tenwa/flow/CopyInfoTempToFormal.java
linxiaoping e198ace19a 更改
2018-06-23 18:03:01 +08:00

79 lines
3.4 KiB
Java

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);
Map<String,String>fromCondtion=new HashMap<String, String>();
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);
Map<String,String>toCondtion=new HashMap<String, String>();
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<String,String> 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();
}
}