Introducción de antecedentes
Cuando el cliente desea hacer clic para cambiar la organización en la interfaz EAS, la lista de tipos de organización de la interfaz emergente muestra la organización financiera en lugar de todas las organizaciones de forma predeterminada.
# Miércoles 22 de abril 15:26:03 CST 2020 t6G $ tdT3T $ ScR11LgutFURO33n8_ = 1; 0; verdadero 00000000-0000-0000-0000-00000000000013B7DE7F = 2; 0; verdadero 256c221a -0106-1000-e000-10d7c0a813f413B7DE7F = 2; 0; cierto
Cuando puede encontrar la asignación buscando this.dialog, el tipo de this.dialog es NewOrgF7PromptDialog
A través de la depuración, el tipo de implementación final de this.dialog es SwitchOrgF7PromptDialog.
¡El contenido principal está aquí! ! !
initPropertiesHandler () necesita modificar el código, eliminar la comprobación nula de this.props y forzar a volver a leer el archivo de configuración cada vez, para que pueda tener efecto después de que se modifique el archivo de configuración.
private void initPropertiesHandler () { / * * @update 20200422 yacong_liu Requisitos del cliente: la lista de organizaciones financieras se muestra de forma predeterminada al cambiar de organización. * Plan de implementación: cambie el valor en OrgSwitchPropertyFile.properties, debe asegurarse de que el programa vuelva a cargar el archivo de configuración cada vez * / // if (this.props == null) { String easClientRoot = System.getProperty ("easclient.root" ); if (! StringUtils.isEmpty (easClientRoot)) { this .orgSwitchPropertyFile = new File ( new StringBuffer (). Append (easClientRoot) .append ( File.separator) .append ( "OrgSwitchPropertyFile.properties" ) .toString ()); try{ if (! this .orgSwitchPropertyFile.exists ()) { this .orgSwitchPropertyFile.createNewFile (); } this .props = nuevas Propiedades (); this .props.load ( nuevo FileInputStream ( this .orgSwitchPropertyFile)); } catch (IOException e) { logger.error (e); esto .props = nulo ; volver ; } } // } }
La solución final: durante la inicialización, cambie el valor correspondiente al usuario conectado en OrgSwitchPropertyFile.properties , o cambie el tipo de organización financiera si no es el tipo de organización financiera. Cambie el método del código fuente SwitchOrgF7PromptDialog.initPropertiesHandler () para forzar la lectura del archivo de configuración cada vez. Sacrificará algo de rendimiento.
Nueva clase de extensión: NewOrgF7UICTEx
paquete com.kingdee.eas.basedata.org.client; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.log4j.Logger; import com.kingdee.eas.basedata.org.MultiOrgsClientCacheImplUtil; import com.kingdee.eas.common.client.SysContext; import com.kingdee.util.StringUtils; / ** * * @copyright 天津 xx 有限公司 * @title NewOrgF7UICTEx * @description 组织 切换 界面 * @autor yacong_liu Correo electrónico: [email protected] * @date 2020-4-21 & 下午 02:57:10 * @since V1.0 * / public class NewOrgF7UICTEx extiende NewOrgF7UI { registrador estático privado = Logger.getLogger ( clase NewOrgF7UICTEx. ); Archivo privado orgSwitchPropertyFile = null ; Propiedades privadas props = nulo ; public NewOrgF7UICTEx () lanza Exception { super (); } / ** * (非 Javadoc) * * @Title buildQuickQueryCombox * @Description Establece la organización financiera de visualización predeterminada <hook> * @see com.kingdee.eas.basedata.org.client.NewOrgF7UI # buildQuickQueryCombox () * / @Override protegido vacío buildQuickQueryCombox () { super . ; // El nombre de la clase del llamante del método String className = Thread.currentThread (). GetStackTrace () [2 ] .getClassName (); // El nombre del método del llamador del método String methodName = Thread.currentThread (). GetStackTrace ( ) [2 ] .getMethodName (); if(! StringUtils.equalsIgnoreCase (className, "com.kingdee.eas.basedata.org.client.NewOrgF7UI" ) ||! StringUtils.equalsIgnoreCase (methodName, "onLoad" )) { // Al abrir la organización para cambiar la interfaz F7, el valor predeterminado mostrar los organismos financieros vuelven ; } // cambiar la organización para cambiar perfiles OrgSwitchPropertyFile.properties Key String = MultiOrgsClientCacheImplUtil.getPathStrFromObjID (SysContext.getSysContext () .getCurrentUserInfo () getId toString () () ..); initPropertiesHandler (); SI ! ( isNeedUpdate (clave)) { // No es necesario cambiar el valor logger .info ("**************** NewOrgF7UICTEx_buildQuickQueryCombox ¡El valor OrgSwitchPropertyFile.properties ya es la organización financiera 2, no es necesario cambiar!" ); Volver ; } String filePath = new StringBuffer (). Append (System.getProperty ("easclient.root" )). append ( File.separator) .append ( "OrgSwitchPropertyFile.properties" ) .toString (); logger.info ( new StringBuffer ("********* NewOrgF7UICTEx_buildQuickQueryCombox configuración previa al cambio Archivo, ruta del archivo: " ) .append ( filePath) .append ( " key: " ) .append (key) .toString ()); updateProperties (key, filePath); logger.info ("********** NewOrgF7UICTEx_buildQuickQueryCombox cambia el archivo de configuración completado" ); } / ** * @title updateProperties * @description modifica el valor de propiedad del archivo de configuración * @param key property key * @param filePath file path * / private void updateProperties (String key, String filePath) { try { Properties props = new Properties (); InputStream fis = nuevo FileInputStream (filePath); props.load (fis); fis.close (); // Asegúrese de cerrar fis OutputStream fos = new FileOutputStream (filePath) antes de modificar el valor props.setProperty (key, getNewValue (key) .toString ()); props.store (fos, "Update" + key + "value"); // Guardar y agregar comentarios fos.close (); } catch (IOException e) { logger.error (e); System.err.println ( "********** OrgSwitchPropertyFile.properties error de actualización de propiedad! clave" + clave); } } / ** * @title * @ descripción El valor predeterminado del nuevo valor de la clave del archivo de configuración generado se establece en la organización financiera 2 * @param clave del archivo de configuración clave * @return StringBuffer getNewValue (String key) {StringBuffer * / private StringBuffer value = new StringBuffer (); if ( this .props.containsKey (key)) { String [] properties = this .props.getProperty (key) .split (";" ); Cadena orgViewType = propiedades [0 ]; if (! StringUtils.equals ("2" , orgViewType)) { properties [ 0] = "2"; // 默认 值 设置 为 财务 组织 para ( int i = 0; i <properties.length; i ++ ) { value.append (properties [i]); if (i <propiedades.longitud - 1 ) { value.append ( ";" ); } } } } valor devuelto ; } / ** * * @title * @description ¿Necesita cambiar el valor del archivo de configuración * @param key * @return * / private boolean isNeedUpdate ( String key) { if ( this .props.containsKey (key)) { String [] properties = this .props.getProperty (key) .split (";" ); String orgViewType= propiedades [0 ]; if (! StringUtils.equals ("2" , orgViewType)) { return true ; } } return false ; } / ** * * @title * @description carga cambiar el archivo de configuración de caché de la organización OrgSwitchPropertyFile.properties * $ {EAS_HOMW} \ client \ deploy \ client \ OrgSwitchPropertyFile.properties * * / private void initPropertiesHandler () { if ( this .props == null ) { Cadena easClientRoot = System.getProperty ("easclient.root" ); if (! (StringUtils.isEmpty (easClientRoot))) { this .orgSwitchPropertyFile = new File ( new StringBuffer (). append (easClientRoot) .append ( File.separator) .append ( "OrgSwitchPropertyFile.properties" ) .toString ()) ; intente { if (! ( this .orgSwitchPropertyFile.exists ())) { this .orgSwitchPropertyFile.createNewFile (); } esto .props = nuevoPropiedades (); this .props.load ( nuevo FileInputStream ( this .orgSwitchPropertyFile)); } catch (IOException e) { logger.error (e); esto .props = nulo ; volver ; } } } } }