ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
Source/Service/BOFactory/src/com/vci/server/bof/server/ServiceFacadeUtil.java
@@ -1,25 +1,14 @@
package com.vci.server.bof.server;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.HibernateException;
import com.vci.corba.omd.btm.BtmItem;
import com.vci.corba.omd.data.AttributeValue;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.corba.omd.data.LinkObject;
import com.vci.server.base.exception.ExceptionLocalHandler;
import com.vci.server.base.persistence.dao.HibernateSessionFactory;
import com.vci.server.base.utility.ServerServiceProvider;
import com.vci.server.cache.OMCacheProvider;
import com.vci.common.exception.VciExceptionTool;
import com.vci.corba.common.VCIError;
import com.vci.corba.common.data.VCIInvocationInfo;
import com.vci.corba.common.data.UserEntityInfo;
import com.vci.corba.framework.method.FrameworkServicePrx;
import com.vci.common.log.LogType;
/**
 * 定义工具方法
@@ -46,21 +35,21 @@
    * @param oid:对象OID
    * @throws VCIError 
    */
   protected void recordLog(String user, String module, String ip, String operation, String type, String objName, String oid) throws VCIError {
      userEntity.userName = user;
      if(module.equalsIgnoreCase(type)){
         userEntity.modules = getBtmShowName(module);
      }else{
         userEntity.modules = module;
      }
      userEntity.ip = ip;
      String con = "操作的数据是->" + getBtmShowName(type) + ":" + objName;
      //记录日志
      ServerServiceProvider.getFrameService().savelogGeneralOperation("操作成功", con, userEntity, oid, type);
      //LogRecordUtil.writeLog(userEntity, operation, "操作成功", "操作的数据是->" + getBtmShowName(type) + ":" + objName, LogType.GeneralOperation, oid);
   }
//   protected void recordLog(String user, String module, String ip, String operation, String type, String objName, String oid) throws VCIError {
//      userEntity.userName = user;
//      if(module.equalsIgnoreCase(type)){
//         userEntity.modules = getBtmShowName(module);
//      }else{
//         userEntity.modules = module;
//      }
//      userEntity.ip = ip;
//
//      String con = "操作的数据是->" + getBtmShowName(type) + ":" + objName;
//      //记录日志
//
//      ServerServiceProvider.getFrameService().savelogGeneralOperation("操作成功", con, userEntity, oid, type);
//      //LogRecordUtil.writeLog(userEntity, operation, "操作成功", "操作的数据是->" + getBtmShowName(type) + ":" + objName, LogType.GeneralOperation, oid);
//   }
   
   /**
    * 批量存储log
@@ -71,57 +60,59 @@
    * @throws SQLException
    * @throws VCIError 
    */
   protected void batchRecordLog(BusinessObject[] bos, String ip, String operation) throws HibernateException, SQLException, VCIError {
      batchRecordLog(bos,ip,operation,"操作成功");
   }
//   protected void batchRecordLog(BusinessObject[] bos, String ip, String operation) throws HibernateException, SQLException, VCIError {
//      //batchRecordLog(bos,ip,operation,"操作成功");
//      LogRecordUtil.batchWriteLog(userEntity, bos, operation, "操作成功");
//   }
   
   private void batchRecordLog(BusinessObject[] bos, String ip, String operation,String result) throws HibernateException, SQLException, VCIError{
      if (bos == null || bos.length < 1) {
         return;
      }
      VCIInvocationInfo invInfo = HibernateSessionFactory.getVciSessionInfo();
      if (StringUtils.isEmpty(invInfo.userName))
         userEntity.userName = bos[0].creator;
      else
         userEntity.userName = invInfo.userName;
      userEntity.ip = ip;
      String type = bos[0].btName;
      userEntity.modules = getBtmShowName(type);
      FrameworkServicePrx fService= ServerServiceProvider.getFrameService();
//      ArrayList<String> logList = new ArrayList<String>();
      for (int i = 0; i < bos.length; i++) {
         BusinessObject bo = bos[i];
         String info = StringUtils.isNotBlank(bo.name)?bo.name:(StringUtils.isNotBlank(bo.id)?bo.id:bo.oid);
         String btmShowName = getBtmShowName(bos[i].btName);
         try {
            fService.saveLogV2(result, "操作的数据为->"+ btmShowName + ":" + info, operation, (short)LogType.GeneralOperation.getIntVal(), bos[i].oid, userEntity);
         } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }
//         logList.add(LogRecordUtil.getLogSql(userEntity, operation, result, "操作的数据为->"+ btmShowName + ":" + info, LogType.GeneralOperation, bos[i].oid, role, btmShowName));
//         if ((i + 1) % 200 == 0) {
//            LogRecordUtil.batchSaveLog(logList.toArray(new String[logList.size()]));
//            logList.clear();
//         }
      }
//      if (bos.length % 200 != 0) {
//         LogRecordUtil.batchSaveLog(logList.toArray(new String[logList.size()]));
//         logList.clear();
//   private void batchRecordLog(BusinessObject[] bos, String ip, String operation,String result) throws HibernateException, SQLException, VCIError{
//      if (bos == null || bos.length < 1) {
//         return;
//      }
   }
//
//      VCIInvocationInfo invInfo = HibernateSessionFactory.getVciSessionInfo();
//
//      if (StringUtils.isEmpty(invInfo.userName))
//         userEntity.userName = bos[0].creator;
//      else
//         userEntity.userName = invInfo.userName;
//
//      userEntity.ip = ip;
//
//      String type = bos[0].btName;
//      userEntity.modules = getBtmShowName(type);
//
//      FrameworkServicePrx fService= ServerServiceProvider.getFrameService();
//
////      ArrayList<String> logList = new ArrayList<String>();
//      for (int i = 0; i < bos.length; i++) {
//         BusinessObject bo = bos[i];
//         String info = StringUtils.isNotBlank(bo.name)?bo.name:(StringUtils.isNotBlank(bo.id)?bo.id:bo.oid);
//         String btmShowName = getBtmShowName(bos[i].btName);
//
//         try {
//            LogRecordUtil.writeLog(userEntity, result, "操作的数据为->"+ btmShowName + ":" + info, operation, (short)LogType.GeneralOperation.getIntVal(), bos[i].oid);
//            //LogRecordUtil.w (result, "操作的数据为->"+ btmShowName + ":" + info, operation, (short)LogType.GeneralOperation.getIntVal(), bos[i].oid, userEntity);
//         } catch (VCIError e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//         }
//
////         logList.add(LogRecordUtil.getLogSql(userEntity, operation, result, "操作的数据为->"+ btmShowName + ":" + info, LogType.GeneralOperation, bos[i].oid, role, btmShowName));
////         if ((i + 1) % 200 == 0) {
////            LogRecordUtil.batchSaveLog(logList.toArray(new String[logList.size()]));
////            logList.clear();
////         }
//      }
////      if (bos.length % 200 != 0) {
////         LogRecordUtil.batchSaveLog(logList.toArray(new String[logList.size()]));
////         logList.clear();
////      }
//   }
   
   protected void batchFailRecordLog(BusinessObject[] bos, String ip, String operation) throws HibernateException, SQLException, VCIError{
      batchRecordLog(bos,ip,operation,"操作失败");
   }
//   protected void batchFailRecordLog(BusinessObject[] bos, String ip, String operation) throws HibernateException, SQLException, VCIError{
//      batchRecordLog(bos,ip,operation,"操作失败");
//   }
   
   
   /**