126 lines
4.5 KiB
Java
126 lines
4.5 KiB
Java
package com.tenwa.orginfo;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import jbo.awe.ORG_INFO;
|
|
import jbo.sys.LB_ORGUSER_LOG;
|
|
|
|
import com.amarsoft.app.lc.util.DateAssistant;
|
|
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.jbo.JBOTransaction;
|
|
import com.amarsoft.context.ASUser;
|
|
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
|
|
import com.tenwa.officetempalte.util.FileOperatorUtil;
|
|
/**
|
|
* »ú¹¹¹ÜÀíÈÕÖ¾±í
|
|
* @author xu
|
|
*
|
|
*/
|
|
public class OrgInfoLogService {
|
|
public ASUser curUser;
|
|
public JBOTransaction tx;
|
|
public BizObject org;
|
|
public OrgInfoLogService( ASUser curUser,JBOTransaction tx,BizObject org) {
|
|
this.curUser=curUser;
|
|
this.tx=tx;
|
|
this.org=org;
|
|
}
|
|
public void logOrg(String Otype)throws Exception{
|
|
String comment="";
|
|
if(Otype.equals("Insert")){
|
|
comment=logOrgInsert();
|
|
}else if(Otype.equals("Update")){
|
|
comment=logOrgUpdate();
|
|
}else if(Otype.equals("Delete")){
|
|
comment=logOrgDelete();
|
|
}
|
|
if(comment.length()>0){
|
|
BizObjectManager orgLogTable = JBOFactory.getBizObjectManager(LB_ORGUSER_LOG.CLASS_NAME);
|
|
this.tx.join(orgLogTable);
|
|
BizObject orgLog=orgLogTable.newObject();
|
|
orgLog.setAttributeValue("OCOMMENT",comment);
|
|
orgLog.setAttributeValue("LOGTIME", DateAssistant.getTodayNow());
|
|
orgLog.setAttributeValue("OTYPE",Otype);
|
|
orgLog.setAttributeValue("INPUTUSER",curUser.getUserID());
|
|
orgLog.setAttributeValue("INPUTORG", curUser.getOrgID());
|
|
orgLog.setAttributeValue("INPUTTIME", org.getAttribute("INPUTTIME").getString());
|
|
orgLogTable.saveObject(orgLog);
|
|
}
|
|
}
|
|
public String logOrgDelete()throws Exception{
|
|
Map<String,String>searchCondtion=new HashMap<String,String>();
|
|
searchCondtion.put("ORGID", this.org.getAttribute("ORGID").getString());
|
|
this.org=DataOperatorUtil.getSingleJBO(ORG_INFO.CLASS_NAME, searchCondtion, this.tx);
|
|
String sComment=this.curUser.getUserName()+"ɾ³ý"+this.getParentOrgName()+"ÏÂÃæµÄ"+this.getLevel(this.org)+"["+this.org.getAttribute("ORGNAME").getString()+"]("+DateAssistant.getTodayNow()+")";
|
|
return sComment;
|
|
}
|
|
public String logOrgUpdate()throws Exception{
|
|
ASOrgObject orgObject= new ASOrgObject(this.org.getAttribute("ORGID").getString());
|
|
String sourceName=orgObject.getOrgName();
|
|
String newName=this.org.getAttribute("ORGNAME").getString();
|
|
String sComment="";
|
|
if(!sourceName.equals(newName)){
|
|
sComment=this.curUser.getUserName()+"¸üÐÂ"+this.getParentOrgName()+"ÏÂÃæµÄ"+getLevel(org)+"["+sourceName+"]ÐÞ¸ÄΪ["+newName+"]("+DateAssistant.getTodayNow()+")";
|
|
}
|
|
return sComment;
|
|
}
|
|
public String logOrgInsert()throws Exception{
|
|
|
|
String sComment=this.curUser.getUserName()+"ÔÚ"+this.getParentOrgName()+"ÐÂÔö"+this.getLevel(this.org)+"["+this.org.getAttribute("ORGNAME").getString()+"]("+DateAssistant.getTodayNow()+")";
|
|
return sComment;
|
|
}
|
|
|
|
public String getLevel(BizObject org)throws Exception{
|
|
String sLevel="";
|
|
sLevel=org.getAttribute("ORGLEVEL").getString();
|
|
String slevelName="";
|
|
if(sLevel.equals("0")){
|
|
slevelName="ƽ̨";
|
|
}else if(sLevel.equals("3")){
|
|
slevelName="¹«Ë¾";
|
|
}else if(sLevel.equals("6")){
|
|
slevelName="²¿ÃÅ";
|
|
}else if(sLevel.equals("9")){
|
|
slevelName="ÇþµÀ";
|
|
}else if(sLevel.equals("12")){
|
|
slevelName="»ú¹¹";
|
|
}
|
|
return slevelName;
|
|
}
|
|
public String getParentOrgName()throws Exception{
|
|
String orgId=org.getAttribute("orgid").getString();
|
|
orgId=orgId.substring(0, orgId.length()-3);
|
|
String parentList="";
|
|
if(orgId.length()<2){
|
|
parentList=orgId;
|
|
}else{
|
|
orgId=orgId.substring(0, orgId.length()-3);
|
|
if(orgId.length()>1){
|
|
while(orgId.length()>1){
|
|
if(parentList.length()>0){parentList=parentList+",";}
|
|
parentList=parentList+orgId;
|
|
orgId=orgId.substring(0, orgId.length()-3);
|
|
}
|
|
}else{
|
|
parentList=orgId;
|
|
}
|
|
}
|
|
String parentOrgName="";
|
|
String sql="select orgname from o where o.orgid in("+FileOperatorUtil.getStrArray(parentList, ",")+") order by sortno";
|
|
List<BizObject>orgs=JBOFactory.createBizObjectQuery(ORG_INFO.CLASS_NAME, sql).getResultList(false);
|
|
for(BizObject bo:orgs){
|
|
if(parentOrgName.length()>0){
|
|
parentOrgName=parentOrgName+"-->";
|
|
}
|
|
parentOrgName=parentOrgName+bo.getAttribute("orgname").getString();
|
|
}
|
|
return parentOrgName;
|
|
}
|
|
}
|
|
|