Background introduction
When the customer wants to click to switch the organization on the EAS interface, the pop-up interface organization type list displays the financial organization instead of all organizations by default.
#Wed Apr 22 15:26:03 CST 2020 t6G$tdT3T$ScR11LgutFURO33n8_=1;0;true 00000000-0000-0000-0000-00000000000013B7DE7F=2;0;true 256c221a-0106-1000-e000-10d7c0a813f413B7DE7F=2;0;true
When you can find the assignment by searching this.dialog, the type of this.dialog is NewOrgF7PromptDialog
Through debugging, the final implementation type of this.dialog is SwitchOrgF7PromptDialog.
The core content is here! ! !
initPropertiesHandler () needs to modify the code, remove the null check of this.props, and force to re-read the configuration file every time, so as to take effect after the configuration file is modified.
private void initPropertiesHandler () { / * * @update 20200422 yacong_liu Customer requirements: The list of financial organizations is displayed by default when switching organizations. * Implementation plan: change the value in OrgSwitchPropertyFile.properties, you need to ensure that the program reloads the configuration file every time * / // 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 = new Properties(); this.props.load(new FileInputStream(this.orgSwitchPropertyFile)); } catch (IOException e) { logger.error(e); this.props = null; return; } } // } }
The final solution: during initialization, change the value corresponding to the logged-in user in OrgSwitchPropertyFile.properties , or change to the financial organization type if it is not the financial organization type. Change the source code SwitchOrgF7PromptDialog.initPropertiesHandler () method to force the configuration file to be read every time. Will sacrifice some performance.
New extension class: NewOrgF7UICTEx
package 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 组织切换界面 * @author yacong_liu Email:[email protected] * @date 2020-4-21 & 下午02:57:10 * @since V1.0 */ public class NewOrgF7UICTEx extends NewOrgF7UI { private static Logger logger = Logger.getLogger(NewOrgF7UICTEx.class); private File orgSwitchPropertyFile = null; private Properties props = null; public NewOrgF7UICTEx() throws Exception { super(); } /** * (Non-Javadoc) * * @Title buildQuickQueryCombox * @Description Set the default display financial organization <hook> * @see com.kingdee.eas.basedata.org.client.NewOrgF7UI # buildQuickQueryCombox () * / @Override protected void buildQuickQueryCombox () { super .buildQuickQueryCombox () ; // The class name of the method caller String className = Thread.currentThread (). GetStackTrace () [2 ] .getClassName (); // The method name of the method caller String methodName = Thread.currentThread (). GetStackTrace ( ) [2 ] .getMethodName (); if (! StringUtils.equalsIgnoreCase (className, "com.kingdee.eas.basedata.org.client.NewOrgF7UI" ) ||! StringUtils.equalsIgnoreCase (methodName, "onLoad" )) { // When opening the organization to switch the F7 interface, the default Show financial organization return ; } // Change organization switching configuration file OrgSwitchPropertyFile.properties String key = MultiOrgsClientCacheImplUtil.getPathStrFromObjID (SysContext.getSysContext () .getCurrentUserInfo (). GetId (). ToString ()); initPropertiesHandler (); if (! IsNeedUpdate (key)) { // No need to change the value logger .info ( "******* ********* NewOrgF7UICTEx_buildQuickQueryCombox OrgSwitchPropertyFile.properties value is already financial organization 2, no need to change! "); return ; } String filePath = new StringBuffer (). append (System.getProperty ("easclient.root" )). append ( File.separator) .append ( "OrgSwitchPropertyFile.properties" ) .toString (); logger.info ( new StringBuffer ("********* NewOrgF7UICTEx_buildQuickQueryCombox pre-change configuration file, file path:" ) .append ( filePath) .append ( "key:" ) .append (key) .toString ()); updateProperties (key, filePath); logger.info (/**"********** NewOrgF7UICTEx_buildQuickQueryCombox change configuration file completed" ); } * @title updateProperties * @description modify configuration file property value * @param key property key * @param filePath file path * / private void updateProperties ( String key, String filePath) { try { Properties props = new Properties (); InputStream fis = new FileInputStream (filePath); props.load (fis); fis.close (); // Be sure to close fis before modifying the value OutputStream fos = new FileOutputStream (filePath); props.setProperty (key, getNewValue (key) .toString ()); props.store (fos, "Update" + key + "value"); // Save and add comments fos .close (); } catch (IOException e) { logger.error (e); System.err.println ( "********** OrgSwitchPropertyFile.properties property update error! key" + key); } } / ** * @title * @description The new value of the configuration file key is generated. The default value is set to the financial organization 2 * @param key configuration file key * @return StringBuffer * / private StringBuffer getNewValue (String key) { StringBuffer value = new StringBuffer(); if (this.props.containsKey(key)) { String[] properties = this.props.getProperty(key).split(";"); String orgViewType = properties[0]; if (!StringUtils.equals("2", orgViewType)) { properties[0] = "2"; // 默认值设置为财务组织 for (int i = 0; i < properties.length; i++) { value.append(properties[i]); if (i < properties.length - 1) { value.append ( ";" ); } } } } return value; } / ** * * @title * @description Do you need to change the value of the configuration file * @param key * @return * / private boolean isNeedUpdate ( String key) { if ( this .props.containsKey (key)) { String [] properties = this .props.getProperty (key) .split (";" ); String orgViewType = properties [0 ]; if (! StringUtils.equals ("2" , orgViewType)) { return true ; } } return false ; } / ** * * @title * @description Load switching organization cache configuration file OrgSwitchPropertyFile. properties * $ {EAS_HOMW} \ client \ deploy \ client \ OrgSwitchPropertyFile.properties * * / private void initPropertiesHandler () { 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 = new Properties(); this.props.load(new FileInputStream(this.orgSwitchPropertyFile)); } catch (IOException e) { logger.error(e); this.props = null; return; } } } } }