dangsn
2024-06-05 72c7bbd66b8456db7dabf0dbc15f7aa9c2af2b9d
Source/platformProject/vci-platform-web/src/main/java/com/vci/web/initTask/VciWebInitTaskComponent.java
@@ -1,19 +1,14 @@
package com.vci.web.initTask;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.vci.corba.common.VCIError;
import com.vci.frameworkcore.compatibility.ISmFunctionQueryService;
import com.vci.client.mw.ClientContextVariable;
import com.vci.client.mw.LaunchModeEnum;
import com.vci.corba.common.PLException;
import com.vci.corba.omd.data.AttributeValue;
import com.vci.frameworkcore.constant.FrameWorkBtmTypeConstant;
import com.vci.frameworkcore.properties.VciFramworkCompatibilityProperties;
import com.vci.mw.client.ClientContextVariable;
import com.vci.mw.client.InvocationUtility;
import com.vci.mw.client.LaunchModeEnum;
import com.vci.starter.corba.initializer.JacorbClientRequestInterceptor;
import com.vci.starter.corba.properties.JacorbClientMapProperties;
import com.vci.starter.web.annotation.config.VciConfigField;
import com.vci.starter.web.annotation.config.VciConfigModule;
import com.vci.starter.web.enumpck.DataSecretEnum;
import com.vci.starter.web.enumpck.SessionStorageTypeEnum;
import com.vci.starter.web.enumpck.UserSecretEnum;
import com.vci.starter.web.interceptor.VciSessionForLoginI;
@@ -24,8 +19,9 @@
import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
import com.vci.web.pageModel.OsAttributeVO;
import com.vci.web.properties.WebProperties;
import com.vci.web.service.*;
import com.vci.web.service.impl.OsAttributeServiceImpl;
import com.vci.web.service.OsAttributeServiceI;
import com.vci.web.service.VciMdServiceI;
import com.vci.web.service.WebSecretServiceI;
import com.vci.web.service.impl.UIEngineServiceImpl;
import com.vci.web.service.impl.WebContextInfoFetcher;
import com.vci.web.service.impl.WebInitServiceImpl;
@@ -41,7 +37,6 @@
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ResourceUtils;
import plm.bs.bom.common.AttributeValue;
import java.io.File;
import java.io.FileInputStream;
@@ -133,11 +128,11 @@
    @Autowired
    private WebSecretServiceI secretService;
    /**
     * corba的客户端
     */
    @Autowired(required = false)
    private JacorbClientMapProperties jacorbClientMapProperties;
//    /**
//     * corba的客户端
//     */
//    @Autowired(required = false)
//    private JacorbClientMapProperties jacorbClientMapProperties;
    /**
     * 执行初始化
@@ -258,12 +253,12 @@
                properties.load(new FileInputStream(file));
                String url = properties.getProperty("NameService");
                String name = properties.getProperty("InstanceIdentity");
                if (StringUtils.isNotBlank(url)) {
                    jacorbClientMapProperties.setUrl(url);
                }
                if (StringUtils.isNotBlank(name)) {
                    jacorbClientMapProperties.setInstanceIdentity(name);
                }
//                if (StringUtils.isNotBlank(url)) {
//                    jacorbClientMapProperties.setUrl(url);
//                }
//                if (StringUtils.isNotBlank(name)) {
//                    jacorbClientMapProperties.setInstanceIdentity(name);
//                }
            }
        }catch (IOException e) {
            logger.error("读取平台的corb配置文件出现了错误",e);
@@ -288,8 +283,8 @@
    public void initSetting() {
        System.out.println("----初始化用于查询配置的用户----");
        ClientContextVariable.setClientLanuchMode(LaunchModeEnum.WebApp);
        InvocationUtility.registerIInvocationContext(contextInfoFetcher);
        JacorbClientRequestInterceptor.sessionContext = contextInfoFetcher;
//        InvocationUtility.registerIInvocationContext(contextInfoFetcher);
//        JacorbClientRequestInterceptor.sessionContext = contextInfoFetcher;
        System.out.println("----初始化用于查询配置的用户完成----");
        System.out.println("----开始扫描有VciConfigModule注解的类----");
        String[] namesForAnnotation = ApplicationContextProvider.getApplicationContext().getBeanNamesForAnnotation(VciConfigModule.class);
@@ -311,43 +306,43 @@
                        }
                        configFieldMap.put(vciConfigField.value(),field);
                    });
//                    configFieldMap.forEach((configField,field)->{
//                        String configValue = null;
//                        try {
//                            configValue = platformClientUtil.getLogonFactoryService().getFrameworkService().getConfigValue("",configField);
//                        } catch (VCIError vciError) {
//                           if(logger.isErrorEnabled()){
//                               logger.error(vciError.error_code,vciError);
//                           }
//                        }
//                        Class<?> fieldType = field.getType();
//                        Method method = WebUtil.getSetmethod(bean.getClass(), field);
//                        Object value = null;
//                        if(fieldType.equals(Boolean.class) || fieldType.equals(boolean.class)){
//                            value = ("on".equalsIgnoreCase(configValue) || "true".equalsIgnoreCase(configValue))?true:false;
//                        }else if(fieldType.equals(Double.class) || fieldType.equals(double.class)){
//                            value = WebUtil.getDouble(configValue);
//                        }else if(fieldType.equals(Long.class) || fieldType.equals(long.class)){
//                            value = WebUtil.getLong(configValue);
//                        }else if(fieldType.equals(Float.class) || fieldType.equals(float.class)){
//                            value = WebUtil.getFloat(configValue);
//                        }else if(fieldType.equals(Integer.class) || fieldType.equals(int.class)){
//                            value = WebUtil.getInt(configValue);
//                        }else{
//                            value = configValue;
//                        }
//                        try {
//                            method.invoke(bean,value);
//                        } catch (IllegalAccessException e) {
//                            if(logger.isErrorEnabled()){
//                                logger.error(e.getMessage(),e);
//                            }
//                        } catch (InvocationTargetException e) {
//                            if(logger.isErrorEnabled()){
//                                logger.error(e.getMessage(),e);
//                            }
//                        }
//                    });
                    configFieldMap.forEach((configField,field)->{
                        String configValue = null;
                        try {
                            configValue = platformClientUtil.getFrameworkService().getConfigValue(configField);
                        } catch (PLException vciError) {
                           if(logger.isErrorEnabled()){
                               logger.error(vciError.code,vciError);
                           }
                        }
                        Class<?> fieldType = field.getType();
                        Method method = WebUtil.getSetmethod(bean.getClass(), field);
                        Object value = null;
                        if(fieldType.equals(Boolean.class) || fieldType.equals(boolean.class)){
                            value = ("on".equalsIgnoreCase(configValue) || "true".equalsIgnoreCase(configValue))?true:false;
                        }else if(fieldType.equals(Double.class) || fieldType.equals(double.class)){
                            value = WebUtil.getDouble(configValue);
                        }else if(fieldType.equals(Long.class) || fieldType.equals(long.class)){
                            value = WebUtil.getLong(configValue);
                        }else if(fieldType.equals(Float.class) || fieldType.equals(float.class)){
                            value = WebUtil.getFloat(configValue);
                        }else if(fieldType.equals(Integer.class) || fieldType.equals(int.class)){
                            value = WebUtil.getInt(configValue);
                        }else{
                            value = configValue;
                        }
                        try {
                            method.invoke(bean,value);
                        } catch (IllegalAccessException e) {
                            if(logger.isErrorEnabled()){
                                logger.error(e.getMessage(),e);
                            }
                        } catch (InvocationTargetException e) {
                            if(logger.isErrorEnabled()){
                                logger.error(e.getMessage(),e);
                            }
                        }
                    });
                }
            }
        }