package org.example.Impl;

import jakarta.annotation.PostConstruct;
import org.example.Impl.Sql.factory.AllInOneSqlFactory;
import org.example.Impl.Sql.provider.AllInOneSqlProvider;
import org.example.Utils.NativeExtensionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.sql.SQLException;

@Service
public class UpdateImpl extends OptBaseImpl {
    /*
      检查并升级升级数据库各表
     */
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Value("${custom.database.type}")
    private String databaseType;

    private AllInOneSqlProvider sqlProvider;
    @Autowired
    AllInOneSqlFactory allInOneSqlFactory; // 注入Spring管理的实例

    @PostConstruct
    public void initSqlProvider() {
        // 工厂只创建一次，结果缓存到成员变量sqlProvider中
        this.sqlProvider = allInOneSqlFactory.createProvider(this.databaseType);
    }

    @Autowired


    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    private void updateSystemOtherTab() {
//        StringBuilder sqlBuilder = new StringBuilder();
//
//        sqlBuilder.append(String.format(
//                "if col_length('%s', 'sumCond') is null exec('alter table %s add sumCond varchar(500);')",
//                "dbo.p_systemdlltabdetailgrid", "dbo.p_systemdlltabdetailgrid"
//        ));
//
//        sqlBuilder.append(String.format(
//                "if col_length('%s', 'sumCond') is null exec('alter table %s add sumCond varchar(500);')",
//                "dbo.p_systembilldetail", "dbo.p_systembilldetail"
//        ));
//
//        sqlBuilder.append(String.format(
//                "if col_length('%s', 'sumCond') is null exec('alter table %s add sumCond varchar(500);')",
//                "dbo.p_systembillauditAttachDetail", "dbo.p_systembillauditAttachDetail"
//        ));
//
//        sqlBuilder.append(String.format(
//                "if col_length('%s', 'dllcoid') is null exec('alter table %s add dllcoid varchar(100);')",
//                "dbo.P_fm_DirectoryTab", "dbo.P_fm_DirectoryTab"
//        ));
//
//        sqlBuilder.append(String.format(
//                "if col_length('%s', 'dllcoid') is null exec('alter table %s add dllcoid varchar(100);')",
//                "dbo.p_fm_filetab", "dbo.p_fm_filetab"
//        ));

        String sql = this.sqlProvider.updateSystemOtherTabSql();
        jdbcTemplate.execute(sql);
    }

    private void updateBillTab_210525() {
//        StringBuilder sqlBuilder = new StringBuilder();

        // region p_systembilldetail
//        sqlBuilder.append(String.format(
//                "if col_length('%s', 'addmoduleid') is null exec('alter table %s add addmoduleid varchar(500);')",
//                "dbo.p_systembilldetail", "dbo.p_systembilldetail"
//        ));
        // endregion
        String sql = this.sqlProvider.updateBillTab_210525Sql();

        jdbcTemplate.execute(sql);
    }

    private void updateBillTab_211022() {
//        StringBuilder sqlBuilder = new StringBuilder();

        // region p_systembilldetail
//        sqlBuilder.append(String.format(
//                "if col_length('%s', 'bandTitle') is null exec('alter table %s add bandTitle varchar(500);') " +
//                        "if col_length('%s', 'bandFields') is null exec('alter table %s add bandFields varchar(8000);')",
//                "dbo.p_systembilldetail", "dbo.p_systembilldetail",
//                "dbo.p_systembilldetail", "dbo.p_systembilldetail"
//        ));
        // endregion
        String sql = this.sqlProvider.updateBillTab_211022Sql();

        jdbcTemplate.execute(sql);
    }

    /**
     * 更新系统表
     */

    private void updateSysTab() {
//        StringBuilder sqlBuilder = new StringBuilder();

        // region p_SystemTab
        // 公司名称
//        sqlBuilder.append("if col_length('dbo.p_SystemTab', 'clientname') is null " +
//                "exec('alter table dbo.p_SystemTab add clientname varchar(100);')");
//        sqlBuilder.append("if col_length('dbo.p_SystemTab', 'clientenname') is null " +
//                "exec('alter table dbo.p_SystemTab add clientenname varchar(200);')");
//        sqlBuilder.append("if col_length('dbo.p_SystemTab', 'copyright') is null " +
//                "exec('alter table dbo.p_SystemTab add copyright varchar(100);')");
//        sqlBuilder.append("if col_length('dbo.p_SystemTab', 'clientlogname') is null " +
//                "exec('alter table dbo.p_SystemTab add clientlogname varchar(200);')");
//        sqlBuilder.append("if col_length('dbo.p_SystemTab', 'webclientname') is null " +
//                "exec('alter table dbo.p_SystemTab add webclientname varchar(100);')");
//        sqlBuilder.append("if col_length('dbo.p_SystemTab', 'webclientenname') is null " +
//                "exec('alter table dbo.p_SystemTab add webclientenname varchar(200);')");
//        sqlBuilder.append("if col_length('dbo.p_SystemTab', 'serverattachpath') is null " +
//                "exec('alter table dbo.p_SystemTab add serverattachpath varchar(2000);')");
//        sqlBuilder.append("if col_length('dbo.p_SystemTab', 'localOAUrl') is null " +
//                "exec('alter table dbo.p_SystemTab add localOAUrl varchar(2000);')");
        // endregion

        String sql = this.sqlProvider.updateSysTabSql();

        jdbcTemplate.execute(sql);
    }

    private void updateSysTab_210630() {
//        StringBuilder sqlBuilder = new StringBuilder();
//
//        // region p_SystemTab
//        // 公司名称
//        sqlBuilder.append("if col_length('dbo.p_SystemTab', 'downloadAddress') is null " +
//                "exec('alter table dbo.p_SystemTab add downloadAddress varchar(1000);')");
//        // endregion

        String sql = this.sqlProvider.updateSysTab_210630Sql();

        jdbcTemplate.execute(sql);
    }

    private void updateProductSpeciesTab() {
//        StringBuilder sqlBuilder = new StringBuilder();
//
//        // region p_SystemTab
//        // 公司名称
//        sqlBuilder.append("if col_length('dbo.bmp_ProductSpeciesTab', 'uploadOper') is null " +
//                "exec('alter table dbo.bmp_ProductSpeciesTab add uploadOper varchar(2000);')");
//        sqlBuilder.append("if col_length('dbo.bmp_ProductSpeciesTab', 'downloadOper') is null " +
//                "exec('alter table dbo.bmp_ProductSpeciesTab add downloadOper varchar(2000);')");
//        sqlBuilder.append("if col_length('dbo.bmp_ProductSpeciesTab', 'deleteOper') is null " +
//                "exec('alter table dbo.bmp_ProductSpeciesTab add deleteOper varchar(2000);')");
//        sqlBuilder.append("if col_length('dbo.bmp_ProductSpeciesTab', 'previewOper') is null " +
//                "exec('alter table dbo.bmp_ProductSpeciesTab add previewOper varchar(2000);')");
//        // endregion

        String sql = this.sqlProvider.updateProductSpeciesTabSql();

        jdbcTemplate.execute(sql);
    }

    /**
     * 更新系统菜单表
     */

    private void updateSysMenuTab() {
//        StringBuilder sqlBuilder = new StringBuilder();

        // region p_formmenuconfigtab
        // dllfilename1 web端的模块，targetmode 菜单作用位置，targetmodel 0为全部，3 为web
//        sqlBuilder.append("if col_length('dbo.p_formmenuconfigtab', 'dllfilename1') is null " +
//                "exec('alter table dbo.P_FormMenuConfigTab add DllFileName1 varchar(100);') " +
//                "if col_length('dbo.p_formmenuconfigtab', 'TargetMode') is null " +
//                "exec('alter table dbo.P_FormMenuConfigTab add TargetMode int default(0);') " +
//                "if col_length('dbo.p_formmenuconfigtab', 'GroupCaption') is null " +
//                "exec('alter table dbo.P_FormMenuConfigTab add GroupCaption varchar(50);') " +
//                "if col_length('dbo.p_formmenuconfigtab', 'SeriesId') is null " +
//                "exec('alter table dbo.P_FormMenuConfigTab add SeriesId int');");
        // 以下升级注释掉，因为cs还未做到同步
        // if col_length('p_formmenuconfigtab', 'useFlag') is null
        //     exec('alter table P_FormMenuConfigTab add useFlag int');
        // endregion

        String sql = this.sqlProvider.updateSysMenuTabSql();

        jdbcTemplate.execute(sql);
    }

    /**
     * 更新子系统表
     */

    private void updateSubSysTab() {
//        StringBuilder sqlBuilder = new StringBuilder();
//
//        // region P_SubSystemTab
//        // used 在cs上1表示可以点，0表示禁用不可点，visible控制禁用，0启用
//        sqlBuilder.append("if col_length('dbo.P_SubSystemTab', 'subsystip') is null " +
//                "exec('alter table dbo.P_SubSystemTab add subsystip varchar(500);')");
//        sqlBuilder.append("if col_length('dbo.P_SubSystemTab', 'visible') is null " +
//                "exec('alter table dbo.P_SubSystemTab add visible int default 0;')");
//        // 这个好像没用210521
//        sqlBuilder.append("if col_length('dbo.P_SubSystemTab', 'webshow') is null " +
//                "exec('alter table dbo.P_SubSystemTab add webshow bit default 1;')");
//        // endregion

        String sql = this.sqlProvider.updateSubSysTabSql();

        jdbcTemplate.execute(sql);
    }

    /**
     * 更新单据类型表
     */

    private void updateBillTypeTab() {
//        StringBuilder sqlBuilder = new StringBuilder();
//
//        // region p_systembilltype
//        sqlBuilder.append("if col_length('dbo.p_systembilltype', 'overbacksql') is null " +
//                "exec('alter table dbo.p_systembilltype add overbacksql varchar(3000),overbackkey uniqueidentifier;') " +
//                "if col_length('dbo.p_systembilltype', 'PopupUnionCode') is null " +
//                "exec('alter table dbo.p_systembilltype add PopupUnionCode [varchar](50) NULL') " +
//                "if col_length('dbo.p_systembilltype', 'defaultShowSearch') is null " +
//                "exec('alter table dbo.p_systembilltype add defaultShowSearch [int] NULL') " +
//                "if col_length('dbo.p_systembilltype', 'MuitlAuditFlag') is null " +
//                "exec('alter table dbo.p_systembilltype add MuitlAuditFlag [int] NULL') " +
//                "if col_length('dbo.p_systembilltype', 'bs_adddllname') is null " +
//                "exec('alter table dbo.p_systembilltype add bs_adddllname varchar(100) NULL') " +
//                "if col_length('dbo.p_systembilltype', 'BackSelected') is null " +
//                "exec('alter table dbo.p_systembilltype add BackSelected bit NULL');");
//        // endregion

        String sql = this.sqlProvider.updateBillTypeTabSql();

        jdbcTemplate.execute(sql);
    }

    private void updateBillTypeTab_210901() {
//        StringBuilder sqlBuilder = new StringBuilder();
//
//        // 处理p_systembilltype表
//        sqlBuilder.append("if col_length('dbo.p_systembilltype', 'countSql') is null " +
//                "exec('alter table dbo.p_systembilltype add countSql varchar(max) NULL');");

        String sql = this.sqlProvider.updateBillTypeTab_210901Sql();
        jdbcTemplate.execute(sql);
    }

    /**
     * 更新DLL表结构
     */
    private void updateDllTab() {
//        StringBuilder sqlBuilder = new StringBuilder();
//
//        // 处理p_systemdlltab表
//        // 地理位置定位的mark图标
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'LocationImg') is null " +
//                "exec('alter table dbo.p_systemdlltab add LocationImg varchar(100);')");
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'addcaption') is null " +
//                "exec('alter table dbo.p_systemdlltab add addcaption varchar(100);')");
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'modifycaption') is null " +
//                "exec('alter table dbo.p_systemdlltab add modifycaption varchar(200);')");
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'applycaption') is null " +
//                "exec('alter table dbo.p_systemdlltab add applycaption varchar(200);')");
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'addmodid') is null " +
//                "exec('alter table dbo.p_systemdlltab add addmodid varchar(200);')");
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'saveapplyenabled') is null " +
//                "exec('alter table dbo.p_systemdlltab add saveapplyenabled int;')");
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'addcopyenabled') is null " +
//                "exec('alter table dbo.p_systemdlltab add addcopyenabled int null;')");
//
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'bs_adddllname') is null " +
//                "exec('alter table dbo.p_systemdlltab add bs_adddllname varchar(50)') " +
//                "if col_length('dbo.p_systemdlltab', 'displayRows') is null " +
//                "exec('alter table dbo.p_systemdlltab add displayRows int default 50;')");
//
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'BSRowHeight') is null " +
//                "exec('alter table dbo.p_systemdlltab add BSRowHeight int;')");
//
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'popupWidth') is null " +
//                "exec('alter table dbo.p_systemdlltab add popupWidth int,popupHeight int;')");
//
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'BackSelected') is null " +
//                "exec('alter table dbo.p_systemdlltab add BackSelected bit;')");

        String sql = this.sqlProvider.updateDllTabSql();

        jdbcTemplate.execute(sql);
    }

    private void updateDllTab_210610() {
//        StringBuilder sqlBuilder = new StringBuilder();
//
//        // 处理p_systemdlltab表
//        // 地理位置定位的mark图标
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'delCaption') is null " +
//                "exec('alter table dbo.p_systemdlltab add delCaption varchar(100);')");
        String sql = this.sqlProvider.updateDllTab_210610Sql();

        jdbcTemplate.execute(sql);
    }

    private void updateDllTab_210624() {
//        StringBuilder sqlBuilder = new StringBuilder();
//
//        // 处理p_systemdlltab表
//        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'addHintMSG') is null " +
//                "exec('alter table dbo.p_systemdlltab add addHintMSG varchar(1000);')");

        String sql = this.sqlProvider.updateDllTab_210624Sql();

        jdbcTemplate.execute(sql);
    }

    /**
     * 待办事项模块各模块数据sql
     */
    private void updateDllTab_21429() {
//        StringBuilder sqlBuilder = new StringBuilder();
//
//        // 处理p_systemdlltab表
//        sqlBuilder.append(String.format("if col_length('%s', 'tasksql') is null " +
//                        "exec('alter table %s add tasksql varchar(max);')",
//                "dbo.p_systemdlltab", "dbo.p_systemdlltab"));
//
//        // 处理p_systembilltype表
//        sqlBuilder.append(String.format("if col_length('%s', 'tasksql') is null " +
//                        "exec('alter table %s add tasksql varchar(max);')",
//                "dbo.p_systembilltype", "dbo.p_systembilltype"));
//        sqlBuilder.append(String.format("if col_length('%s', 'newver') is null " +
//                        "exec('alter table %s add newver int;')",
//                "dbo.p_systembilltype", "dbo.p_systembilltype"));
//        sqlBuilder.append(String.format("if col_length('%s', 'newWFVer') is null " +
//                        "exec('alter table %s add newWFVer int;')",
//                "dbo.p_systembilltype", "dbo.p_systembilltype"));

        String sql = this.sqlProvider.updateDllTab_21429Sql();

        jdbcTemplate.execute(sql);
    }

    /**
     * 升级模块附件预览信息图表大小
     */
    private void updateDllTab_240617() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_systemdlltab表
        sqlBuilder.append(String.format("if col_length('%s', 'attatchInfoWidth') is null " +
                        "exec('alter table %s add attatchInfoWidth int;')",
                "dbo.p_systemdlltab", "dbo.p_systemdlltab"));
        // sqlBuilder.append(String.format("if col_length('%s', 'attatchInfoHeight') is null " +
        //                                "exec('alter table %s add attatchInfoHeight int;')",
        //                                "p_systemdlltab", "p_systemdlltab"));

        // 处理p_systembilltype表
        sqlBuilder.append(String.format("if col_length('%s', 'attatchInfoWidth') is null " +
                        "exec('alter table %s add attatchInfoWidth int;')",
                "dbo.p_systembilltype", "dbo.p_systembilltype"));
        // sqlBuilder.append(String.format("if col_length('%s', 'attatchInfoHeight') is null " +
        //                                "exec('alter table %s add attatchInfoHeight int;')",
        //                                "p_systembilltype", "p_systembilltype"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 升级基础模块数据源为接口时
     */
    private void updateDllTab_240619() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_systemdlltab表
        sqlBuilder.append(String.format("if col_length('%s', 'apiDataNode') is null " +
                        "exec('alter table %s add apiDataNode varchar(100);')",
                "dbo.p_systemdlltab", "dbo.p_systemdlltab"));
        sqlBuilder.append(String.format("if col_length('%s', 'apiSuccNode') is null " +
                        "exec('alter table %s add apiSuccNode varchar(100);')",
                "dbo.p_systemdlltab", "dbo.p_systemdlltab"));
        sqlBuilder.append(String.format("if col_length('%s', 'apiSuccVal') is null " +
                        "exec('alter table %s add apiSuccVal varchar(100);')",
                "dbo.p_systemdlltab", "dbo.p_systemdlltab"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 待办事项模块各模块数据sql
     */
    private void updateDllTab_231215() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_systemdlltab表
        sqlBuilder.append(String.format("if col_length('%s', 'MuitlAuditFlag') is null " +
                        "exec('alter table %s add MuitlAuditFlag int;')",
                "dbo.p_systemdlltab", "dbo.p_systemdlltab"));

        // 处理p_systembilltype表
        sqlBuilder.append(String.format("if col_length('%s', 'MuitlAuditFlag') is null " +
                        "exec('alter table %s add MuitlAuditFlag int;')",
                "dbo.p_systembilltype", "dbo.p_systembilltype"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 待办事项模块各模块数据sql
     */
    private void updateDllTab_240117() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_systemdlltab表
        sqlBuilder.append(String.format("if col_length('%s', 'disableDetail') is null " +
                        "exec('alter table %s add disableDetail int default 0;')",
                "dbo.p_systemdlltab", "dbo.p_systemdlltab"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateGroupTab_240120() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_sydbGroupTab表
        sqlBuilder.append(String.format("if col_length('%s', 'localIp') is null " +
                        "exec('alter table %s add localIp varchar(100);')",
                "dbo.p_sydbGroupTab", "dbo.p_sydbGroupTab"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 待办事项模块各模块数据sql
     */
    private void updateDllTab_210519() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_systemdlltab表
        sqlBuilder.append(String.format("if col_length('%s', 'selectLeaf') is null " +
                        "exec('alter table %s add selectLeaf int default 1;')",
                "dbo.p_systemdlltab", "dbo.p_systemdlltab"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 基础档案新增复选框选择模式
     */
    private void updateDllTab_221024() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_systemdlltab表
        sqlBuilder.append(String.format("if col_length('%s', 'multcheck') is null " +
                        "exec('alter table %s add multcheck int default 0;')",
                "dbo.p_systemdlltab", "dbo.p_systemdlltab"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateDllTab_210901() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_systemdlltab表
        // 地理位置定位的mark图标
        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'countSql') is null " +
                "exec('alter table dbo.p_systemdlltab add countSql varchar(max);')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新DLL表详情
     * <p>
     * 创建时间：2021-02-02
     * 修改人：
     * 修改时间：
     * 修改备注：
     * 版本：
     */
    private void updateDllTabDetail() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_systemDlltabDetail表
        sqlBuilder.append("if col_length('dbo.p_systemDlltabDetail', 'unionparentfield') is null " +
                "exec('alter table dbo.p_systemDlltabDetail add unionparentfield varchar(100);')");
        sqlBuilder.append("if col_length('dbo.p_systemDlltabDetail', 'operUsers') is null " +
                "exec('alter table dbo.p_systemDlltabDetail add operUsers varchar(3000);')");
        sqlBuilder.append("if col_length('dbo.p_systemDlltabDetail', 'library') is null " +
                "exec('alter table dbo.p_systemDlltabDetail add library varchar(100);')");
        sqlBuilder.append("if col_length('dbo.p_systemDlltabDetail', 'addVisible') is null " +
                "begin " +
                "exec('alter table dbo.p_systemDlltabDetail add addVisible int default 1;') " +
                "exec('update dbo.p_systemDlltabDetail set addVisible=1;') " +
                "end");

        // sumcond 20200921

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateDllTabDetail_210430() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append(String.format("if col_length('%s', 'displayMode') is null " +
                        "exec('alter table %s add displayMode int;')",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateDllTabDetail_250426() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append(String.format("if col_length('%s', 'gridDetailCheck') is null " +
                        "exec('alter table %s add gridDetailCheck int;')",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 基础档案明细添加界面显示方式
     */
    private void updateDllTabDetail_210514() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append(String.format("if col_length('%s', 'addShowMode') is null " +
                        "exec('alter table %s add addShowMode int;')",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 明细在大屏中的高和宽
     */
    private void updateDllTabDetail_220114() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append(String.format("if col_length('%s', 'bandHeight') is null " +
                        "exec('alter table %s add bandHeight varchar(10);') " +
                        "if col_length('%s', 'bandWidth') is null " +
                        "exec('alter table %s add bandWidth varchar(10);')",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 基础档案明细添加界面显示方式
     */
    private void updateDllTabDetail_210914() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append(String.format("if col_length('%s', 'visibleCond') is null " +
                        "exec('alter table %s add visibleCond varchar(200);') " +
                        "if col_length('%s', 'fieldCond') is null " +
                        "exec('alter table %s add fieldCond varchar(200);') " +
                        "if col_length('%s', 'disableField') is null " +
                        "exec('alter table %s add disableField varchar(200);') " +
                        "if col_length('%s', 'fieldCond1') is null " +
                        "exec('alter table %s add fieldCond1 varchar(200);') " +
                        "if col_length('%s', 'disableField1') is null " +
                        "exec('alter table %s add disableField1 varchar(200);') " +
                        "if col_length('%s', 'fieldCond2') is null " +
                        "exec('alter table %s add fieldCond2 varchar(200);') " +
                        "if col_length('%s', 'disableField2') is null " +
                        "exec('alter table %s add disableField2 varchar(200);') " +
                        "if col_length('%s', 'unionCond') is null " +
                        "exec('alter table %s add unionCond varchar(2000);')",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail",
                "dbo.p_systemdlltabdetail", "dbo.p_systemdlltabdetail"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新工作簿表结构
     */
    private void updateWorkBookTab() throws SQLException {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_systemwordbooktab";

        // 添加多个字段检查和添加语句
        sqlBuilder.append(String.format(
                "if col_length('%s', 'InputHintText') is null exec('alter table %s add InputHintText varchar(1000);')%n",
                tableName, tableName));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'TitleColor') is null exec('alter table %s add TitleColor varchar(100);')%n",
                tableName, tableName));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'userenname') is null exec('alter table %s add userenname varchar(100);')%n",
                tableName, tableName));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'bs_order') is null exec('alter table %s add bs_order int;')%n",
                tableName, tableName));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'bs_field') is null exec('alter table %s add bs_field varchar(1000);')%n",
                tableName, tableName));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'bs_color') is null exec('alter table %s add bs_color varchar(100);')%n",
                tableName, tableName));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'bs_fontsize') is null exec('alter table %s add bs_fontsize varchar(100);')%n",
                tableName, tableName));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'sumCond') is null exec('alter table %s add sumCond varchar(500);')%n",
                tableName, tableName));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'labelWidth') is null exec('alter table %s add labelWidth int;')%n",
                tableName, tableName));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'labelAlign') is null exec('alter table %s add labelAlign int;')%n",
                tableName, tableName));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2021-05-27更新工作簿表
     */
    private void updateWorkBookTab_210527() throws SQLException {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_systemwordbooktab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'disableCond') is null exec('alter table %s add disableCond varchar(1000);')%n",
                tableName, tableName));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2021-09-11更新工作簿表
     */
    private void updateWorkBookTab_210911() throws SQLException {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_systemwordbooktab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'disableType') is null exec('alter table %s add disableType int;')%n",
                tableName, tableName));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2022-07-04升级字段高亮配置
     */
    private void updateWorkBookTab_220704() throws SQLException {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_systemwordbooktab表
        String table1 = "dbo.p_systemwordbooktab";
        sqlBuilder.append(String.format(
                "if col_length('%s', 'highlightFColor') is null exec('alter table %s add highlightFColor varchar(50);')%n",
                table1, table1));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'highlightBColor') is null exec('alter table %s add highlightBColor varchar(50);')%n",
                table1, table1));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'highlightBold') is null exec('alter table %s add highlightBold int;')%n",
                table1, table1));

        // 处理p_systembillinfo表
        String table2 = "dbo.p_systembillinfo";
        sqlBuilder.append(String.format(
                "if col_length('%s', 'highlightFColor') is null exec('alter table %s add highlightFColor varchar(50);')%n",
                table2, table2));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'highlightBColor') is null exec('alter table %s add highlightBColor varchar(50);')%n",
                table2, table2));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'highlightBold') is null exec('alter table %s add highlightBold int;')%n",
                table2, table2));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2024-03-21更新工作簿表
     */
    private void updateWorkBookTab_240321() throws SQLException {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_systemwordbooktab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'sumCalc') is null exec('alter table %s add sumCalc varchar(8000);')%n",
                tableName, tableName));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2024-04-12更新通知表
     */
    private void updateNotification_240412() throws SQLException {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_systemNotification表
        sqlBuilder.append(String.format(
                "if col_length('%s', 'templetename') is null exec('alter table %s add templetename varchar(100);')%n",
                "dbo.p_systemNotification", "dbo.p_systemNotification"));

        // 处理p_systemMessageTab表
        sqlBuilder.append(String.format(
                "if col_length('%s', 'templetename') is null exec('alter table %s add templetename varchar(100);')%n",
                "dbo.p_systemMessageTab", "dbo.p_systemMessageTab"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新通知表结构
     */
    private void updateNotificationTab() throws SQLException {
        StringBuilder sqlBuilder = new StringBuilder();

        // 创建p_systemNotification表
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[p_systemNotification]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n");
        sqlBuilder.append("begin \n");
        sqlBuilder.append("    CREATE TABLE [dbo].[p_systemNotification](\n");
        sqlBuilder.append("        [Id] [int] IDENTITY(1,1) NOT NULL,\n");
        sqlBuilder.append("        [DLLCoid] [varchar](50) NULL,\n");
        sqlBuilder.append("        [Msg] [nvarchar](500) NULL,\n");
        sqlBuilder.append("        [Cnt] [int] NULL,\n");
        sqlBuilder.append("        [Status] [int] NULL,\n");
        sqlBuilder.append("        [Created] [datetime] NULL,\n");
        sqlBuilder.append("        [UserId] [varchar](50) NULL,\n");
        sqlBuilder.append("        [TypeId] [varchar](50) NULL,\n");
        sqlBuilder.append("        [DllFileName] [varchar](100) NULL,\n");
        sqlBuilder.append("        [ModuleName] [varchar](100) NULL,\n");
        sqlBuilder.append("        [LoginAccount] [varchar](100) NULL,\n");
        sqlBuilder.append("        [msgid] [int] NOT NULL,\n");
        sqlBuilder.append("        [cnt1] [int] NOT NULL,\n");
        sqlBuilder.append("        [msgid1] [int] NULL,\n");
        sqlBuilder.append("        [stepcode] [int] NULL,\n");
        sqlBuilder.append("        [messid] [int] NULL,\n");
        sqlBuilder.append("        [modtype] [int] NULL,\n");
        sqlBuilder.append("        [billdocument_id] [varchar](50) NULL,\n");
        sqlBuilder.append("        [menuid] [int] NULL,\n");
        sqlBuilder.append("        [confirmid] [varchar](20) NULL,\n");
        sqlBuilder.append("     CONSTRAINT [PK_p_systemNotification] PRIMARY KEY CLUSTERED \n");
        sqlBuilder.append("    (\n");
        sqlBuilder.append("        [Id] ASC\n");
        sqlBuilder.append("    ) )\n");
        sqlBuilder.append("end;\n");

        // 添加confirmid字段
        sqlBuilder.append(String.format(
                "if col_length('%s', 'confirmid') is null exec('alter table %s add confirmid varchar(20);')%n",
                "dbo.p_systemNotification", "dbo.p_systemNotification"));

        // 创建p_systemNotification_History表
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[p_systemNotification_History]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n");
        sqlBuilder.append("begin \n");
        sqlBuilder.append("    CREATE TABLE [dbo].[p_systemNotification_History](\n");
        sqlBuilder.append("        [Id] [int] IDENTITY(1,1) NOT NULL,\n");
        sqlBuilder.append("        [OperateDate] [datetime] NULL default(getdate()),\n");
        sqlBuilder.append("        [keyvalue] [varchar](50) NULL,\n");
        sqlBuilder.append("        [UserId] [varchar](50) NULL,\n");
        sqlBuilder.append("        [menuid] [int] NULL,\n");
        sqlBuilder.append("        [AuditMessages] [varchar](MAX) NULL,\n");
        sqlBuilder.append("        [messid] [int] NULL,\n");
        sqlBuilder.append("        [DLLCoid] [varchar](50) NULL,\n");
        sqlBuilder.append("        [num] [int] NOT NULL,\n");
        sqlBuilder.append("        [dllname] [varchar](100) NULL,\n");
        sqlBuilder.append("        [modulename] [varchar](200) NULL,\n");
        sqlBuilder.append("        [stepcode] [int] NULL,\n");
        sqlBuilder.append("        [menumode] [int] NULL,\n");
        sqlBuilder.append("        [hasSearch] [int] NULL,\n");
        sqlBuilder.append("        [Status] [int] NULL,\n");
        sqlBuilder.append("        [StatusMsg] [varchar](MAX) NULL,\n");
        sqlBuilder.append("     CONSTRAINT [PK_p_systemNotification_History] PRIMARY KEY CLUSTERED \n");
        sqlBuilder.append("    (\n");
        sqlBuilder.append("        [Id] ASC\n");
        sqlBuilder.append("    ) )\n");
        sqlBuilder.append("end;\n");

        // 修改字段长度
        sqlBuilder.append("alter table dbo.p_systemNotification_History alter column keyvalue varchar(MAX);\n");
        sqlBuilder.append("alter table dbo.p_systemNotification_History alter column DLLCoid varchar(500);\n");
        sqlBuilder.append("alter table dbo.p_systemNotification_History alter column dllname varchar(MAX);\n");
        sqlBuilder.append("alter table dbo.p_systemNotification_History alter column modulename varchar(MAX);\n");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 升级消息及微信表
     */
    private void updateMessge() throws SQLException {
        StringBuilder sqlBuilder = new StringBuilder();

        // 创建p_systemMessageTab表
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[p_systemMessageTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n");
        sqlBuilder.append("begin \n");
        sqlBuilder.append("    CREATE TABLE [dbo].[p_systemMessageTab](\n");
        sqlBuilder.append("        [ID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,\n");
        sqlBuilder.append("        [Title] [varchar](50) NULL,\n");
        sqlBuilder.append("        [Msg] [varchar](500) NULL,\n");
        sqlBuilder.append("        [MsgDetail] [varchar](5000) NULL,\n");
        sqlBuilder.append("        [NoticeUserID] [int] NULL,\n");
        sqlBuilder.append("        [NoticeUserName] [varchar](50) NULL,\n");
        sqlBuilder.append("        [DllCoid] [varchar](50) NULL,\n");
        sqlBuilder.append("        [DllFileName] [varchar](50) NULL,\n");
        sqlBuilder.append("        [CreateDate] [datetime] NULL,\n");
        sqlBuilder.append("        [ReadFlag] [bit] NOT NULL,\n");
        sqlBuilder.append("        [CreateUserID] [int] NULL,\n");
        sqlBuilder.append("        [CreateUserName] [varchar](50) NULL,\n");
        sqlBuilder.append("        [DeleteFlag] [int] NULL CONSTRAINT [DF__p_systemM__Delet__744B9841]  DEFAULT ((0)),\n");
        sqlBuilder.append("    CONSTRAINT [PK_p_systemMessageTab] PRIMARY KEY( [ID] ASC )\n");
        sqlBuilder.append("         )\n");
        sqlBuilder.append("end;\n");

        // 创建微信推送表P_WX_BSclientMsg
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[P_WX_BSclientMsg]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n");
        sqlBuilder.append("begin \n");
        sqlBuilder.append("    CREATE TABLE [dbo].[P_WX_BSclientMsg](\n");
        sqlBuilder.append("	[id] [bigint] IDENTITY(1,1) NOT NULL,\n");
        sqlBuilder.append("	[AuditMessages] [varchar](max) NULL,\n");
        sqlBuilder.append("	[UserId] [varchar](500) NULL,\n");
        sqlBuilder.append("	[keyvalue] [varchar](500) NULL,\n");
        sqlBuilder.append("	[stepcode] [int] NULL,\n");
        sqlBuilder.append("	[moduleid] [varchar](500) NULL,\n");
        sqlBuilder.append("	[operDate] [datetime] NULL\n");
        sqlBuilder.append(") ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]\n");
        sqlBuilder.append("ALTER TABLE [dbo].[P_WX_BSclientMsg] ADD  CONSTRAINT [DF_p_WX_BSclientMsg_operDate]  DEFAULT (getdate()) FOR [operDate]\n");
        sqlBuilder.append("end;\n");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 主页firstPage配置表
     */
    private void updateFirstPageTable() throws SQLException {
        StringBuilder sqlBuilder = new StringBuilder();

        // 1. 基本配置表P_SystemFirstPageSetTab
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[P_SystemFirstPageSetTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n");
        sqlBuilder.append("begin \n");
        sqlBuilder.append("    CREATE TABLE [dbo].[P_SystemFirstPageSetTab](\n");
        sqlBuilder.append("        [id] [int] IDENTITY(1,1) NOT NULL,\n");
        sqlBuilder.append("        [itemCode] [varchar](20) NOT NULL,\n");
        sqlBuilder.append("        [itemTitle] [varchar](50) NULL,\n");
        sqlBuilder.append("        [itemIMG] [varchar](150) NULL,\n");
        sqlBuilder.append("        [itemRowNo] [int] NULL,\n");
        sqlBuilder.append("        [itemOrder] [int] NULL default(1),\n");
        sqlBuilder.append("        [itemWidth] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemHeight] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemType] [int] NULL,\n");
        sqlBuilder.append("        [itemTypeFull] [varchar](50) NULL,\n");
        sqlBuilder.append("        [itemDataSource] [varchar](5000) NULL,\n");
        sqlBuilder.append("        [itemLinked] [int] NULL default(1),\n");
        sqlBuilder.append("        [itemPrivilege] [varchar](500) NULL,\n");
        sqlBuilder.append("        [enableFlag] [int] NULL default(0),\n");
        sqlBuilder.append("        [enableType] [int] NOT NULL default(-1),\n");
        sqlBuilder.append("        [operateDate] [datetime] NULL default(getdate()),\n");
        sqlBuilder.append("        [operatorName] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemTemplate] [varchar](100) NULL,\n");
        sqlBuilder.append("    CONSTRAINT [PK_P_SystemFirstPageSetTab] PRIMARY KEY( [itemCode] ASC )\n");
        sqlBuilder.append("         )\n");
        sqlBuilder.append("end;\n");

        // 添加enableType字段
        sqlBuilder.append("if col_length('dbo.P_SystemFirstPageSetTab', 'enableType') is null \n");
        sqlBuilder.append("  exec('alter table dbo.P_SystemFirstPageSetTab add enableType int;')\n");

        // 2. 高宽权限配置表P_SystemOperFirstPageTab
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[P_SystemOperFirstPageTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n");
        sqlBuilder.append("begin \n");
        sqlBuilder.append("    CREATE TABLE [dbo].[P_SystemOperFirstPageTab](\n");
        sqlBuilder.append("        [id] [int] IDENTITY(1,1) NOT NULL,\n");
        sqlBuilder.append("        [operatorId] [int] NOT NULL default(-1),\n");
        sqlBuilder.append("        [itemCode] [varchar](20) NOT NULL,\n");
        sqlBuilder.append("        [itemRowNo] [int] NULL,\n");
        sqlBuilder.append("        [itemOrder] [int] NULL,\n");
        sqlBuilder.append("        [itemWidth] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemHeight] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemLeft] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemTop] [varchar](20) NULL,\n");
        sqlBuilder.append("        [operateDate] [datetime] NOT NULL default(getdate()),\n");
        sqlBuilder.append("        [operatorName] [varchar](20) NULL,\n");
        sqlBuilder.append("        [enableFlag] [int] NULL default(1),\n");
        sqlBuilder.append("        [deleted] [bit] NULL,\n");
        sqlBuilder.append("    CONSTRAINT [Unique_P_SystemOperFirstPageTab] UNIQUE ( [operatorId] ASC,[itemCode] ASC )\n");
        sqlBuilder.append("    )\n");
        sqlBuilder.append("end\n");

        // 3. 按模块配置的桌面表P_SystemDllFirstPageTab
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[P_SystemDllFirstPageTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n");
        sqlBuilder.append("begin \n");
        sqlBuilder.append("    CREATE TABLE [dbo].[P_SystemDllFirstPageTab](\n");
        sqlBuilder.append("        [id] [int] IDENTITY(1,1) NOT NULL,\n");
        sqlBuilder.append("        [dllcoid] [varchar](50) NOT NULL,\n");
        sqlBuilder.append("        [itemCode] [varchar](20) NOT NULL,\n");
        sqlBuilder.append("        [itemRowNo] [int] NULL,\n");
        sqlBuilder.append("        [itemOrder] [int] NULL,\n");
        sqlBuilder.append("        [itemWidth] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemHeight] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemLeft] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemTop] [varchar](20) NULL,\n");
        sqlBuilder.append("        [operateDate] [datetime] NOT NULL default(getdate()),\n");
        sqlBuilder.append("        [operatorName] [varchar](20) NULL,\n");
        sqlBuilder.append("        [enableFlag] [int] NULL default(1),\n");
        sqlBuilder.append("        [deleted] [bit] NULL,\n");
        sqlBuilder.append("        [queryField] [varchar](50) NULL,\n");
        sqlBuilder.append("        [condition] [varchar](2000) NULL,\n");
        sqlBuilder.append("    CONSTRAINT [Unique_P_SystemDllFirstPageTab] UNIQUE ( [dllcoid] ASC,[itemCode] ASC )\n");
        sqlBuilder.append("    )\n");
        sqlBuilder.append("end\n");

        // 4. 模块个人桌面表P_SystemDllOperFirstPageTab
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[P_SystemDllOperFirstPageTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n");
        sqlBuilder.append("begin \n");
        sqlBuilder.append("    CREATE TABLE [dbo].[P_SystemDllOperFirstPageTab](\n");
        sqlBuilder.append("        [id] [int] IDENTITY(1,1) NOT NULL,\n");
        sqlBuilder.append("        [operatorId] [int] NOT NULL default(-1),\n");
        sqlBuilder.append("        [dllcoid] [varchar](50) NOT NULL,\n");
        sqlBuilder.append("        [itemCode] [varchar](20) NOT NULL,\n");
        sqlBuilder.append("        [itemRowNo] [int] NULL,\n");
        sqlBuilder.append("        [itemOrder] [int] NULL,\n");
        sqlBuilder.append("        [itemWidth] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemHeight] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemLeft] [varchar](20) NULL,\n");
        sqlBuilder.append("        [itemTop] [varchar](20) NULL,\n");
        sqlBuilder.append("        [operateDate] [datetime] NOT NULL default(getdate()),\n");
        sqlBuilder.append("        [operatorName] [varchar](20) NULL,\n");
        sqlBuilder.append("        [enableFlag] [int] NULL default(1),\n");
        sqlBuilder.append("        [deleted] [bit] NULL,\n");
        sqlBuilder.append("    CONSTRAINT [Unique_P_SystemDllOperFirstPageTab] UNIQUE ( [operatorId] ASC, [dllcoid] ASC,[itemCode] ASC )\n");
        sqlBuilder.append("    )\n");
        sqlBuilder.append("end\n");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新手机验证码表
     */
    public void updatePhoneCode() throws SQLException {
//        StringBuilder sqlBuilder = new StringBuilder();
//
//        // 关键修改1：用标准SQL判断表是否存在（Kingbase兼容版100%支持）
//        // 替代SQL Server的sysobjects/OBJECTPROPERTY，避免判断失效
//        sqlBuilder.append("IF NOT EXISTS (\n");
//        sqlBuilder.append("    SELECT 1 FROM information_schema.tables \n");
//        sqlBuilder.append("    WHERE table_schema = 'dbo'");
//        sqlBuilder.append("      AND table_name = 'P_ValidCode' ");
//        sqlBuilder.append(")\n");
//        sqlBuilder.append("BEGIN\n");
//        // 关键修改2：动态SQL中显式指定架构，且简化写法（避免sp_executesql的上下文问题）
//        sqlBuilder.append("    CREATE TABLE dbo.P_ValidCode(\n");  // 直接写dbo.P_ValidCode，不用[]（兼容版支持但更简洁）
//        sqlBuilder.append("        id INT PRIMARY KEY IDENTITY(1,1) NOT NULL,\n");
//        sqlBuilder.append("        phone VARCHAR(100) NULL,\n");
//        sqlBuilder.append("        sendtime DATETIME NULL,\n");
//        sqlBuilder.append("        validcode VARCHAR(10) NULL,\n");
//        sqlBuilder.append("        type INT NULL,\n");
//        sqlBuilder.append("        ip VARCHAR(20) NULL\n");
//        sqlBuilder.append("    );\n");
//        sqlBuilder.append("END\n");
//        String sqlBuilder = this.sqlProvider.updatePhoneCodeSql();

        String sql = this.sqlProvider.updatePhoneCodeSql();
        jdbcTemplate.execute(sql);
    }

    /**
     * 附件表加上审批加上审批步骤码
     */
    private void updatePfmFileTab() {
        StringBuilder sqlBuilder = new StringBuilder();
        // 地理位置定位的mark图标
        sqlBuilder.append("if col_length('dbo.P_fm_FileTab', 'stepcode') is null " +
                "exec('alter table dbo.P_fm_FileTab add stepcode varchar(100);')");
        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 升级公告，可选升级，现在只有宜宾使用了公告
     */
    private void updateNotic() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 公告升级
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[p_announcement]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " +
                "exec('CREATE TABLE [dbo].[p_announcement]( " +
                "[Billdocument_Id] [varchar](50) NOT NULL, " +
                "[OperatorId] [int] NULL, " +
                "[Operatorname] [varchar](50) NULL, " +
                "[OperateDate] [datetime] NULL, " +
                "[notice] [varchar](5000) NULL, " +
                "[id] [int] IDENTITY(1,1) NOT NULL, " +
                "[str] [varchar](200) NULL, " +
                "[ban] [int] NULL, " +
                "[Affirmer] [int] NULL, " +
                "[AffirmDate] [datetime] NULL, " +
                "[stepcode] [int] NULL, " +
                "[stepTime] [decimal](8, 2) NULL, " +
                "[endTime] [datetime] NULL, " +
                "[stepOver] [int] NOT NULL, " +
                "[stepOverTime] [datetime] NULL, " +
                "[stepOverId] [int] NULL, " +
                "[stepOverName] [varchar](20) NULL, " +
                "[billType] [int] NULL, " +
                "[stepDirection] [varchar](50) NULL, " +
                "[happentime] [datetime] NULL, " +
                "[pStepCode] [varchar](100) NULL, " +
                "[cancelFlag] [int] NULL, " +
                "[cancelTime] [datetime] NULL, " +
                "[cancelOper] [int] NULL, " +
                "[bz] [int] NULL, " +
                "[date] [datetime] NULL, " +
                "CONSTRAINT [PK_p_announcement] PRIMARY KEY CLUSTERED " +
                "( " +
                "[Billdocument_Id] ASC " +
                ")WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY] " +
                ") ON [PRIMARY] " +
                "SET ANSI_PADDING OFF " +
                "ALTER TABLE [dbo].[p_announcement] ADD  CONSTRAINT [DF_p_announcement_Affirmer]  DEFAULT ((0)) FOR [Affirmer] " +
                "ALTER TABLE [dbo].[p_announcement] ADD  CONSTRAINT [DF_p_announcement_stepOver]  DEFAULT ((0)) FOR [stepOver] " +
                "ALTER TABLE [dbo].[p_announcement] ADD  CONSTRAINT [DF_p_announcement_cancelFlag]  DEFAULT ((0)) FOR [cancelFlag] " +
                "ALTER TABLE [dbo].[p_announcement] ADD  CONSTRAINT [DF_p_announcement_bz]  DEFAULT ((0)) FOR [bz]');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 升级图表模板的拓展参数
     */
    private void updateChartExtends() {
        StringBuilder sqlBuilder = new StringBuilder();
        // 升级图表模板的拓展参数
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[P_SystemChartTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " +
                "exec(' CREATE TABLE [dbo].[P_SystemChartTab]( " +
                "[id] [int] primary key IDENTITY(1,1) NOT NULL, " +
                "[tabkey] uniqueidentifier not NULL, " +
                "[formkey] uniqueidentifier not null default newid(), " +
                "[dllpar1] [varchar](2000) NULL, " +
                "[dllpar2] [varchar](2000) NULL, " +
                "[dllpar3] [varchar](2000) NULL, " +
                "[dllpar4] [varchar](2000) NULL, " +
                "[dllpar5] [varchar](2000) NULL, " +
                "[dllpar6] [varchar](2000) NULL, " +
                "[dllpar7] [varchar](2000) NULL, " +
                "[dllpar8] [varchar](2000) NULL, " +
                "[dllpar9] [varchar](2000) NULL, " +
                "[dllpar10] [varchar](2000) NULL)');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 如果字段类型为地图，那么检测有没有地图相关字段，没有就添加
     *
     * @param tabname   表名
     * @param fieldname 字段名
     */
    public void updateMapField(String tabname, String fieldname) {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append(String.format("if col_length('%s', '%s_itude') is null " +
                        "exec('alter table %s add %s_itude varchar(100);')",
                tabname, fieldname, tabname, fieldname));

        sqlBuilder.append(String.format("if col_length('%s', '%s_longitude') is null " +
                        "exec('alter table %s add %s_longitude varchar(50);')",
                tabname, fieldname, tabname, fieldname));

        sqlBuilder.append(String.format("if col_length('%s', '%s_latitude') is null " +
                        "exec('alter table %s add %s_latitude varchar(50);')",
                tabname, fieldname, tabname, fieldname));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新移动卡片表结构
     */
    private void updateMobileCard() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[P_SystemCardDetailTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " +
                "exec('CREATE TABLE [dbo].[P_SystemCardDetailTab]( " +
                "[id] [int] IDENTITY(1,1) primary key NOT NULL, " +
                "[SourceKey] [varchar](40) NULL, " +
                "[rowid] [int] NULL, " +
                "[rowheight] [int] NULL, " +
                "[splitline] [int] NULL, " +
                "[orderid] [int] NULL, " +
                "[displaytext] [varchar](200) NULL, " +
                "[fontname] [varchar](30) NULL, " +
                "[fontsize] [int] NULL, " +
                "[fcolor] [varchar](20) NULL, " +
                "[bcolor] [varchar](20) NULL, " +
                "[dbcolor] [varchar](20) NULL, " +
                "[dfcolor] [varchar](20) NULL, " +
                "[fbold] [int] NULL, " +
                "[fitalic] [int] NULL, " +
                "[fstrikeline] [int] NULL, " +
                "[RightAlign] [int] NULL, " +
                "[displayType] [int] NULL, " +
                "[visible] [int] NULL " +
                ")');");

        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[p_systemCardTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " +
                "exec('CREATE TABLE [dbo].[p_systemCardTab]( " +
                "[id] [int] IDENTITY(1,1) NOT NULL, " +
                "[formKey] [varchar](40) NULL, " +
                "[SourceKey] [varchar](40) NULL, " +
                "[GroupName] [varchar](50) NULL, " +
                "[orderid] [int] NULL, " +
                "[maincard] [int] NULL, " +
                "[mxorderid] [int] NULL, " +
                "[GroupVisible] [int] NULL, " +
                "[visible] [int] NULL " +
                ") ');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateMobileCard_210707() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append("if col_length('dbo.p_systemCardDetailTab', 'condition') is null " +
                "exec('alter table dbo.p_systemCardDetailTab add condition varchar(200);')");

        sqlBuilder.append("if col_length('dbo.p_systemCardDetailTab', 'textAlign') is null " +
                "exec('alter table dbo.p_systemCardDetailTab add textAlign int;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateMobileCard_220322() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append("if col_length('dbo.p_systemCardDetailTab', 'colname') is null " +
                "exec('alter table dbo.p_systemCardDetailTab add colname varchar(100);')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 升级web的打印程序
     */
    private void updateWebPrint() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[p_systemwebPrint]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " +
                "exec(' create table dbo.p_systemwebPrint( " +
                "id int primary key identity(1,1), " +
                "printname varchar(100), " +
                "content text, " +
                "tab varchar(100) " +
                ")');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 检测是否存在流程图配置表，如果不存在就自动添加进去
     */
    private void updateFlowChartCfgTable() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[P_Systemdlltabflowtypestepcfg]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " +
                "exec(' create table dbo.P_Systemdlltabflowtypestepcfg( " +
                "id int primary key identity(1,1), " +
                "[typeCode] [varchar](10) NOT NULL, " +
                "[billType] [varchar](10) NOT NULL, " +
                "[option] varchar(4000), " +
                "[cfgName] varchar(200), " +
                ")');");

        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[p_systembillflowtypestepcfg]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " +
                "exec(' create table dbo.p_systembillflowtypestepcfg( " +
                "id int primary key identity(1,1), " +
                "[typeCode] [varchar](10) NOT NULL, " +
                "[billType] [varchar](10) NOT NULL, " +
                "[option] varchar(4000), " +
                "[cfgName] varchar(200), " +
                ")');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新字段
     */
    private void updateField() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systembillsourcecond', 'InputHintText') is null " +
                "exec('alter table dbo.p_systembillsourcecond add InputHintText varchar(1000);')");

        sqlBuilder.append("if col_length('dbo.p_systembillsourcecond', 'TitleColor') is null " +
                "exec('alter table dbo.p_systembillsourcecond add TitleColor varchar(100);')");


        sqlBuilder.append("if col_length('dbo.p_systemdlltabflow', 'islocked') is null " +
                "exec('alter table dbo.p_systemdlltabflow add islocked varchar(1000);') " +
                "if col_length('dbo.p_systemdlltabflow', 'requiredFields') is null " +
                "exec('alter table dbo.p_systemdlltabflow add requiredFields varchar(2000);') " +
                "if col_length('dbo.p_systemdlltabflow', 'requiredDetailFields') is null " +
                "exec('alter table dbo.p_systemdlltabflow add requiredDetailFields varchar(2000);')");

        sqlBuilder.append("if col_length('dbo.p_systembillflow', 'requiredFields') is null " +
                "exec('alter table dbo.p_systembillflow add requiredFields varchar(2000);') " +
                "if col_length('dbo.p_systembillflow', 'requiredDetailFields') is null " +
                "exec('alter table dbo.p_systembillflow add requiredDetailFields varchar(2000);') " +
                "if col_length('dbo.p_systembillflow', 'islocked') is null " +
                "exec('alter table dbo.p_systembillflow add islocked int;')");

        sqlBuilder.append("if col_length('dbo.P_fm_FileTab', 'webPath') is null " +
                "exec('alter table dbo.P_fm_FileTab add webPath varchar(2000);') " +
                "if col_length('dbo.P_fm_FileTab', 'stepcode') is null " +
                "exec('alter table dbo.P_fm_FileTab add stepcode varchar(200);')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateDllFlow_220823() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systemdlltabflow', 'auditContent') is null " +
                "exec('alter table dbo.p_systemdlltabflow add auditContent varchar(5000)')");

        sqlBuilder.append("if col_length('dbo.p_systembillflow', 'auditContent') is null " +
                "exec('alter table dbo.p_systembillflow add auditContent varchar(5000);')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateAuditFlowTypeStepTab() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append("if col_length('dbo.P_systembillflowtypestep', 'nextStepCode') is null " +
                "exec('alter table dbo.P_systembillflowtypestep add nextStepCode varchar(1000);')");

        sqlBuilder.append("if col_length('dbo.p_systemdlltabflowtypestep', 'nextStepCode') is null " +
                "exec('alter table dbo.p_systemdlltabflowtypestep add nextStepCode varchar(1000);')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 审核调用明细
     */
    private void updateDlltabDetailFlowTab() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[p_SystemDlltabDetailFlowTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " +
                "exec(' CREATE TABLE [dbo].[p_SystemDlltabDetailFlowTab]( " +
                "[id] [int] IDENTITY(1,1) primary key NOT NULL, " +
                "[typecode] [varchar](50) NULL, " +
                "[detailKey] [varchar](50) NULL, " +
                "[detailName] [varchar](50) NULL, " +
                "[stepcode] [int] NULL, " +
                "[modifyFields] [varchar](100) NULL, " +
                "[isvisible] [int] NULL default 0, " +
                "[displayMode] [int] NULL, " +
                "[hintMsg] [varchar](2000) NULL, " +
                "[eventType] [varchar](20) NULL, " +
                "[addShowMode] [int] NULL default 0 " +
                ")');");

        sqlBuilder.append("if col_length('dbo.p_SystemDlltabDetailFlowTab', 'isvisible') is null " +
                "exec('alter table dbo.p_SystemDlltabDetailFlowTab add isvisible bit;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateDlltabDetailFlowTab_210430() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append("if col_length('dbo.p_SystemDlltabDetailFlowTab', 'displayMode') is null " +
                "exec('alter table dbo.p_SystemDlltabDetailFlowTab add displayMode int;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateDlltabDetailFlowTab_210514() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append("if col_length('dbo.p_SystemDlltabDetailFlowTab', 'addShowMode') is null " +
                "exec('alter table dbo.p_SystemDlltabDetailFlowTab add addShowMode int;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新账单字段表结构
     */
    private void updateBillField() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systembillInfo', 'InputHintText') is null \n")
                .append("    exec('alter table dbo.p_systembillInfo add InputHintText varchar(1000);');\n")
                .append("if col_length('dbo.p_systembillInfo', 'TitleColor') is null \n")
                .append("    exec('alter table dbo.p_systembillInfo add TitleColor varchar(100);');\n")
                .append("if col_length('dbo.p_systembillInfo', 'labelWidth') is null \n")
                .append("    exec('alter table dbo.p_systembillInfo add labelWidth int;');\n")
                .append("if col_length('dbo.p_systembillInfo', 'labelAlign') is null \n")
                .append("    exec('alter table dbo.p_systembillInfo add labelAlign int;');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新模块自定义添加模块表结构
     */
    private void updateCusModuleAddTpl() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.P_pubrpsettab', 'moduleContent') is null \n")
                .append("    exec('alter table dbo.P_pubrpsettab add moduleContent text;');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新视图定义
     */
    private void updateView() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("IF NOT EXISTS(SELECT 1 FROM sys.views WHERE name='v_systemdlltab')\n")
                .append("    if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[p_systembilltype]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n")
                .append("        exec('CREATE view [dbo].[v_systemdlltab]\n")
                .append("              as\n")
                .append("              select DllCoid,ToolsName,dirid,bmpSpec,1 as modType,isReport,SQLDT1 as TableName,sql from dbo.p_systemDlltab\n")
                .append("         ')\n")
                .append("    else\n")
                .append("        exec('CREATE view [dbo].[v_systemdlltab]\n")
                .append("              as\n")
                .append("              select DllCoid,ToolsName,dirid,bmpSpec,1 as modType,isReport,SQLDT1 as TableName,sql from dbo.p_systemDlltab\n")
                .append("              union all\n")
                .append("              select typecode,typename,dirid,bmpspec,2 as modType,0 as isReport,masterTable as TableName,masterSql from dbo.p_systembilltype\n")
                .append("          ');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 创建Web附件自定义显示方式表
     */
    private void updateAttcCusSet() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[P_fm_WebCusSetTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n")
                .append("    exec('create dbo.table P_fm_WebCusSetTab(\n")
                .append("          id int identity primary key ,\n")
                .append("          dllcoid varchar(100),\n")
                .append("          operatorId varchar(100),\n")
                .append("          viewType int --附件显示模式 0：视图，1：表格\n")
                .append("      );');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 创建模板数据表
     */
    private void updateTemplateTab() {
        StringBuilder sqlBuilder = new StringBuilder();
        // 模板数据
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[T_TemplateData]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n")
                .append("    exec('create table dbo.T_TemplateData(\n")
                .append("          id int identity primary key ,\n")
                .append("          tplName varchar(100),\n")
                .append("          cmpKey varchar(100),\n")
                .append("          moduleId varchar(100),\n")
                .append("          dataProvider varchar(100),\n")
                .append("          dataSource varchar(8000)\n")
                .append("      );');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 创建BI时间变化列表
     */
    private void updateBITab() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[BI_TimeChangeList]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n")
                .append("    exec('CREATE TABLE [dbo].[BI_TimeChangeList](\n")
                .append("          [id] [int] IDENTITY(1,1) NOT NULL,\n")
                .append("          [dllcoid] [varchar](100) NULL,\n")
                .append("          [loadDll] [varchar](200) NULL,\n")
                .append("          [title] [varchar](300) NULL,\n")
                .append("          [desp] [varchar](1000) NULL,\n")
                .append("          [showTime] [int] NULL,\n")
                .append("          [showMode] [int] NULL,\n")
                .append("          [refreshTime] [int] NULL,\n")
                .append("       CONSTRAINT [PK_BI_TimeChangeList] PRIMARY KEY CLUSTERED \n")
                .append("      (\n")
                .append("          [id] ASC\n")
                .append("      ));');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新错误信息表结构
     */
    private void updateErrInfoTab() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[p_errlogtab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n")
                .append("    exec('CREATE TABLE [dbo].[P_ErrLogTab](\n")
                .append("          [id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,\n")
                .append("          [SubID] [int] NOT NULL default 0,\n")
                .append("          [ErrID] [real] NOT NULL default 0,\n")
                .append("          [Operator] [varchar](100) NOT NULL default '''',\n")
                .append("          [Operatedate] [datetime] NOT NULL default getdate(),\n")
                .append("          [Content] [varchar](500) NOT NULL default '''',\n")
                .append("          [ErrMethod] [varchar](100) NOT NULL default '''',\n")
                .append("          [ErrMsg] [varchar](8000) NOT NULL default '''',\n")
                .append("          [ErrStack] [varchar](8000) NOT NULL default '''',\n")
                .append("          [ErrCode] [varchar](100) NOT NULL default '''',\n")
                .append("          [MsgAsert] [varchar](500) NOT NULL default '''',\n")
                .append("          [MsgPic] [image] NOT NULL default '',\n")
                .append("          [Ws] [varchar](30) NOT NULL default '''',\n")
                .append("          [ErrParam] [varchar](8000) NULL\n")
                .append("          )\n")
                .append("      ');\n")
                .append("else \n")
                .append("begin\n")
                .append("    if col_length('dbo.P_ErrLogTab', 'ErrMethod') is null \n")
                .append("        exec('alter table dbo.P_ErrLogTab add ErrMethod varchar(100);');\n")
                .append("    if col_length('dbo.P_ErrLogTab', 'ErrStack') is null \n")
                .append("        exec('alter table dbo.P_ErrLogTab add ErrStack varchar(8000);');\n")
                .append("    if col_length('dbo.P_ErrLogTab', 'ErrCode') is null \n")
                .append("        exec('alter table dbo.P_ErrLogTab add ErrCode varchar(100);');\n")
                .append("end");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 创建微信用户绑定客户表
     */
    private void updateWxBindCusTab() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[p_WxUserBindCustomer]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n")
                .append("    exec('CREATE TABLE [dbo].[p_WxUserBindCustomer](\n")
                .append("          [id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,\n")
                .append("          [openId] varchar(50) NOT NULL,\n")
                .append("          [Coid] varchar(50) NOT NULL,\n")
                .append("          [CreateTime] [datetime] not null default getdate()\n")
                .append("          )\n")
                .append("      ');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新弹出菜单表结构
     */
    private void updatePopupMenu() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systempopupmenu', 'dbclickevent') is null \n")
                .append("    exec('alter table dbo.p_systempopupmenu add dbclickevent int;')\n")
                .append("if col_length('dbo.p_systempopupmenu', 'showtoolbar') is null \n")
                .append("    exec('alter table dbo.p_systempopupmenu add showtoolbar int;');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2021-05-07 更新弹出菜单表结构
     */
    private void updatePopupMenu_210507() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systempopupmenu', 'showMode') is null \n")
                .append("    exec('alter table dbo.p_systempopupmenu add showMode int;');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2022-07-20 更新弹出菜单表结构（右键合并执行）
     */
    private void updatePopupMenu_220720() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systempopupmenu', 'mergeExec') is null \n")
                .append("    exec('alter table dbo.p_systempopupmenu add mergeExec int;');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2022-08-12 更新弹出菜单表结构
     */
    private void updatePopupMenu_220812() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systempopupmenu', 'isCopy') is null \n")
                .append("    exec('alter table dbo.p_systempopupmenu add isCopy int;');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2022-09-29 更新弹出菜单表结构（升级右键功能）
     */
    private void updatePopupMenu_220929() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systempopupmenu', 'beforeTab') is null \n")
                .append("    exec('alter table dbo.p_systempopupmenu add beforeTab varchar(100);');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2022-11-23 更新弹出菜单表结构（右键是否需要行数据）
     */
    private void updatePopupMenu_221123() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systempopupmenu', 'isStartRun') is null \n")
                .append("    exec('alter table dbo.p_systempopupmenu add isStartRun int;');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 更新审核附件表结构
     */
    private void updateAuditAttach() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systembillauditAttach', 'unionModule') is null \n")
                .append("    exec('alter table dbo.p_systembillauditAttach add unionModule varchar(100);')\n")
                .append("if col_length('dbo.p_systembillauditAttach', 'unionParentField') is null \n")
                .append("    exec('alter table dbo.p_systembillauditAttach add unionParentField varchar(100);')\n")
                .append("if col_length('dbo.p_systembillauditAttach', 'unionValue') is null \n")
                .append("    exec('alter table dbo.p_systembillauditAttach add unionValue varchar(100);')\n")
                .append("if col_length('dbo.p_systembillauditAttach', 'displayMode') is null \n")
                .append("    exec('alter table dbo.p_systembillauditAttach add displayMode int;');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2021-09-18 更新审核附件表结构
     */
    private void updateAuditAttach_20210918() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systembillauditAttach', 'unionCond') is null \n")
                .append("    exec('alter table dbo.p_systembillauditAttach add unionCond varchar(2000);');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2021-09-18 更新DLL附件表结构
     */
    private void updateDlltabAttach_20210918() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systemdlltabattach', 'unionCond') is null \n")
                .append("    exec('alter table dbo.p_systemdlltabattach add unionCond varchar(2000);');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2024-11-04 更新DLL附件表结构
     */
    private void updateDlltabAttach_20241104() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systemdlltabattach', 'library') is null \n")
                .append("    exec('alter table dbo.p_systemdlltabattach add library varchar(200);')\n")
                .append("if col_length('dbo.p_systemdlltabattach', 'params') is null \n")
                .append("    exec('alter table dbo.p_systemdlltabattach add params varchar(8000);');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2021-09-27 更新图表配置表结构
     */
    private void updateSystemdlltabChart_20210927() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systemdlltabchart', 'IsAbsolutely') is null \n")
                .append("    exec('alter table dbo.p_systemdlltabchart add IsAbsolutely int;')\n")
                .append("if col_length('dbo.p_systemdlltabchart', 'YScale') is null \n")
                .append("    exec('alter table dbo.p_systemdlltabchart add YScale decimal(18, 8);');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2022-02-08 更新图表配置表结构
     */
    private void updateSystemdlltabChart_20220208() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systemdlltabchart', 'yvaluefield1') is null \n")
                .append("    exec('alter table dbo.p_systemdlltabchart add yvaluefield1 varchar(50);')\n")
                .append("if col_length('dbo.p_systemdlltabchart', 'yvaluefield2') is null \n")
                .append("    exec('alter table dbo.p_systemdlltabchart add yvaluefield2 varchar(50);');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 2024-08-20 更新图表配置表结构
     */
    private void updateSystemdlltabChart_20240820() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systemdlltabchart', 'valueVisible') is null \n")
                .append("    exec('alter table dbo.p_systemdlltabchart add valueVisible int default 0;');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateSystemdlltabChart_20241225() {
        StringBuilder sqlBuilder = new StringBuilder();
        // xlabel 旋转角度
        sqlBuilder.append(String.format("if col_length('%s', 'labelangle') is null " +
                        "exec('alter table %s add labelangle int default 0;')",
                "dbo.p_systemdlltabchart", "dbo.p_systemdlltabchart"));
        // xlabel 是否显示
        sqlBuilder.append(String.format("if col_length('%s', 'labelvisible') is null " +
                        "exec('alter table %s add labelvisible int;')",
                "dbo.p_systemdlltabchart", "dbo.p_systemdlltabchart"));
        // xlabel 字体大小
        sqlBuilder.append(String.format("if col_length('%s', 'labelsize') is null " +
                        "exec('alter table %s add labelsize int;')",
                "dbo.p_systemdlltabchart", "dbo.p_systemdlltabchart"));

        // legend显示与否
        sqlBuilder.append(String.format("if col_length('%s', 'legendvisible') is null " +
                        "exec('alter table %s add legendvisible int;')",
                "dbo.p_systemdlltabchart", "dbo.p_systemdlltabchart"));
        // x轴是否间隔显示
        sqlBuilder.append(String.format("if col_length('%s', 'labelSpaced') is null " +
                        "exec('alter table %s add labelSpaced int;')",
                "dbo.p_systemdlltabchart", "dbo.p_systemdlltabchart"));

        // 饼图锯齿
        sqlBuilder.append(String.format("if col_length('%s', 'circlejagge') is null " +
                        "exec('alter table %s add circlejagge int;')",
                "dbo.p_systemdlltabchart", "dbo.p_systemdlltabchart"));

        // 饼图空心 1-100
        sqlBuilder.append(String.format("if col_length('%s', 'circlehollow') is null " +
                        "exec('alter table %s add circlehollow int;')",
                "dbo.p_systemdlltabchart", "dbo.p_systemdlltabchart"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateSysMenuTab_250120() {
        StringBuilder sqlBuilder = new StringBuilder();

        // p_formmenuconfigtab
        sqlBuilder.append("if col_length('dbo.p_formmenuconfigtab', 'serverId') is null " +
                "exec('alter table dbo.P_FormMenuConfigTab add serverId int'); ");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateFiletab_250120() {
        // 向filetab 添加字段 tottime
        String sql = "if col_length('dbo.p_fm_filetab', 'tottime') is null " +
                "exec('alter table dbo.p_fm_filetab add tottime varchar(50);')";
        jdbcTemplate.execute(sql);
    }

    private void updateLogTab_20211027() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append("IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_P_LogTab_Content]') AND type = 'D') " +
                "BEGIN " +
                "ALTER TABLE [dbo].[P_LogTab] DROP CONSTRAINT [DF_P_LogTab_Content] " +
                "END " +
                "alter table dbo.P_LogTab alter column content varchar(max); " +
                "ALTER TABLE [dbo].[P_LogTab] ADD  CONSTRAINT [DF_P_LogTab_Content]  DEFAULT ('') FOR [Content]; " +
                "alter table dbo.P_LogTab alter column object varchar(5000);");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateEmployeetab_20210928() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append(String.format("if col_length('%s', 'p_emp_clientid') is null " +
                        "exec('alter table %s add p_emp_clientid int;') " +
                        "if col_length('%s', 'p_emp_logintype') is null " +
                        "exec('alter table %s add p_emp_logintype int;')",
                "dbo.p_employeetab", "dbo.p_employeetab",
                "dbo.p_employeetab", "dbo.p_employeetab"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateEmployeetab_20221207() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append(String.format("if col_length('%s', 'p_emp_phone') is null " +
                        "exec('alter table %s add p_emp_phone varchar(100);')",
                "dbo.p_employeetab", "dbo.p_employeetab"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateDllTab_202111122() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'newVer') is null " +
                "exec('alter table dbo.p_systemdlltab add newVer int;')");

        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'newWFVer') is null " +
                "exec('alter table dbo.p_systemdlltab add newWFVer int;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateDllTab_20211129() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'detailPageAlign') is null " +
                "exec('alter table dbo.p_systemdlltab add detailPageAlign int default 0')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 表格编辑方式，行编辑还是单元格编辑
     */
    private void updateDllTab_20220309() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'editType') is null " +
                "exec('alter table dbo.p_systemdlltab add editType int default 0')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 是否启用单元格模板
     */
    private void updateDllTab_20220414() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'cellTplflag') is null " +
                "exec('alter table dbo.p_systemdlltab add cellTplflag int default 0')");
        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateDllTab_20220524() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'attatchModifyCond') is null " +
                "exec('alter table dbo.p_systemdlltab add attatchModifyCond varchar(1000)')");
        sqlBuilder.append("if col_length('dbo.p_systembilltype', 'attatchModifyCond') is null " +
                "exec('alter table dbo.p_systembilltype add attatchModifyCond varchar(1000)')");
        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateEmployeetab_20220617() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append(String.format("if col_length('%s', 'p_emp_PwdErrNum') is null " +
                        "exec('alter table %s add p_emp_PwdErrNum int;') " +
                        "if col_length('%s', 'p_emp_PwdLocked') is null " +
                        "exec('alter table %s add p_emp_PwdLocked bit;') " +
                        "if col_length('%s', 'p_emp_PwdLockDate') is null " +
                        "exec('alter table %s add p_emp_PwdLockDate datetime;')",
                "dbo.p_employeetab", "dbo.p_employeetab",
                "dbo.p_employeetab", "dbo.p_employeetab",
                "dbo.p_employeetab", "dbo.p_employeetab"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateDllTab_20211129a() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_SystemdllTabAttach', 'attachType') is null " +
                "exec('alter table dbo.p_SystemdllTabAttach add attachType varchar(200)')");
        sqlBuilder.append("if col_length('dbo.p_SystemdllTabAttach', 'attachIMG') is null " +
                "exec('alter table dbo.p_SystemdllTabAttach add attachIMG varchar(200)')");
        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateWorkbooktab_20230206() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systemwordbooktab', 'IsAddControl') is null " +
                "exec('alter table dbo.p_systemwordbooktab add IsAddControl int')");
        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 文件上传类型控制 附件与字段 例 *.pdf,*.mp4 。。。。
     */
    private void updateBmpType_20240913() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systemwordbooktab', 'bmptype') is null " +
                "exec('alter table dbo.p_systemwordbooktab add bmptype varchar(100)')");
        sqlBuilder.append("if col_length('dbo.p_systembilltype', 'bmptype') is null " +
                "exec('alter table dbo.p_systembilltype add bmptype varchar(100)')");
        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'bmptype') is null " +
                "exec('alter table dbo.p_systemdlltab add bmptype varchar(100)')");
        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 禁用手机卡片模式
     */
    private void updateDllTab_20230209() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'DisMobileCard') is null " +
                "exec('alter table dbo.p_systemdlltab add DisMobileCard int default 0')");
        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 附件新增版本名称和版本号
     */
    private void updateFileTab20230224() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.P_fm_FileTab', 'vname') is null " +
                "exec('alter table dbo.P_fm_FileTab add vname varchar(100);');");
        // 注释掉的原代码保持不变
        // sqlBuilder.append("if col_length('P_fm_FileTab', 'vercode') is null " +
        //         "exec('alter table P_fm_FileTab add vercode varchar(100)');");
        jdbcTemplate.execute(sqlBuilder.toString());
    }

    public void updatebSysTab20230224() {
        StringBuilder sqlBuilder = new StringBuilder();
        // 1：开启设备绑定
        sqlBuilder.append(String.format("if col_length('%s', 'MobileDevOnly') is null " +
                        "exec('alter table %s add MobileDevOnly int;')",
                "dbo.p_systemtab", "dbo.p_systemtab"));
        // 1：允许多设备
        sqlBuilder.append(String.format("if col_length('%s', 'MultMobileDev') is null " +
                        "exec('alter table %s add MultMobileDev int;')",
                "dbo.p_systemtab", "dbo.p_systemtab"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 升级桌面快捷方式数据源各控件独立
     */
    private void updateMegToolLiknkTab_20220914() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.P_MessageToolLinkDllTab', 'cardId') is null " +
                "begin " +
                "exec('alter table dbo.P_MessageToolLinkDllTab add cardId int') " +
                "exec('update m set m.cardId=b.id from dbo.P_MessageToolLinkDllTab m " +
                "inner join [dbo].[P_SystemOperFirstPageTab] b on m.EmployeeID=b.operatorId " +
                "inner join [dbo].[P_SystemFirstPageSetTab] c on b.itemCode=c.itemCode and c.itemTypeFull=''0103'' " +
                "where ISNULL(m.cardid,'')='' ') " +
                "end");
        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 新版登录页配置 20211118
     */
    private void updateLoginCfg() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append(String.format("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[%s]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " +
                        "exec('CREATE TABLE [dbo].[%s]( " +
                        "[id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL, " +
                        "[SysName] varchar(50) NOT NULL, " +
                        "[Copyright] varchar(100) NOT NULL, " +
                        "[Logo] varchar(500) NOT NULL, " +
                        "[disabled] int not null default 0 " +
                        ") '); ",
                "dbo.p_systemLoginCfgTab", "dbo.p_systemLoginCfgTab"));

        sqlBuilder.append(String.format("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[%s]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " +
                        "exec('CREATE TABLE [dbo].[%s]( " +
                        "[id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL, " +
                        "[sysId] [int] not null, " +
                        "[Title] varchar(50) NOT NULL, " +
                        "[Desp] varchar(5000) NOT NULL, " +
                        "[ImgSrc] varchar(500) NOT NULL, " +
                        "[disabled] int not null default 0 " +
                        ") '); ",
                "dbo.p_systemLoginBanner", "dbo.p_systemLoginBanner"));
        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 下拉框禁用拼音查询，影响速度
     */
    private void updateFieldTab_20230314() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append(String.format("if col_length('%s', 'doNotSpelling') is null " +
                        "exec('alter table %s add doNotSpelling int default 0;')",
                "dbo.p_systemwordbooktab", "dbo.p_systemwordbooktab"));
        sqlBuilder.append(String.format("if col_length('%s', 'doNotSpelling') is null " +
                        "exec('alter table %s add doNotSpelling int default 0;')",
                "dbo.p_systembillinfo", "dbo.p_systembillinfo"));
        sqlBuilder.append(String.format("if col_length('%s', 'doNotSpelling') is null " +
                        "exec('alter table %s add doNotSpelling int default 0;')",
                "dbo.p_systembilldetail", "dbo.p_systembilldetail"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     *
     */
    private void updateFieldTab_20240904() {
        StringBuilder sqlBuilder = new StringBuilder();

        sqlBuilder.append(String.format("if col_length('%s', 'dataAlignment') is null " +
                        "exec('alter table %s add dataAlignment int default 0;')",
                "dbo.p_systembilldetail", "dbo.p_systembilldetail"));
        sqlBuilder.append(String.format("if col_length('%s', 'fontName') is null " +
                        "exec('alter table %s add fontName varchar(100);')",
                "dbo.p_systembilldetail", "dbo.p_systembilldetail"));
        sqlBuilder.append(String.format("if col_length('%s', 'labelAlign') is null " +
                        "exec('alter table %s add labelAlign int default 0;')",
                "dbo.p_systembilldetail", "dbo.p_systembilldetail"));
        // 兼容设置
        sqlBuilder.append(String.format("if col_length('%s', 'dataAlign') is null " +
                        "exec('alter table %s add dataAlign int default 0;')",
                "dbo.p_systembilldetail", "dbo.p_systembilldetail"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 新增根据用户设置访问不同的首页
     */
    private void updateEmployeeTab_20240909() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 兼容设置（注释掉的原代码保持不变）
        // sqlBuilder.append(String.format("if col_length('%s', 'WebIndex') is null " +
        //         "exec('alter table %s add WebIndex varchar(100);')",
        //         "p_employeetab", "p_employeetab"));
        sqlBuilder.append(String.format("if col_length('%s', 'AppIndex') is null " +
                        "exec('alter table %s add AppIndex varchar(100);')",
                "dbo.p_employeetab", "dbo.p_employeetab"));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 下拉框禁用拼音查询，影响速度
     */
    private void updateSysteTab_20230328() {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_systemtab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'ADLogin') is null exec('alter table %s add ADLogin int default 0;')%n",
                tableName, tableName
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'ADPath') is null exec('alter table %s add ADPath varchar(100);')%n",
                tableName, tableName
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'ADUser') is null exec('alter table %s add ADUser varchar(100);')%n",
                tableName, tableName
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'ADPwd') is null exec('alter table %s add ADPwd varchar(100);')%n",
                tableName, tableName
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 下拉框禁用拼音查询，影响速度
     */
    private void updateSysteTab_20240625() {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_systemtab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'emaurl') is null exec('alter table %s add emaurl varchar(1000);')%n",
                tableName, tableName
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 下拉框禁用拼音查询，影响速度
     */
    private void updateDllTab_20230406() {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_systemdlltab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'bmpSpecIsMJ') is null exec('alter table %s add bmpSpecIsMJ int default 0;')%n",
                tableName, tableName
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 新版web调用cs打印 打印时参数表 2022-02-21
     */
    private void updatePrintTab() {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_systemWebPrintTab";

        sqlBuilder.append(String.format(
                "if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[%s]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n" +
                        "exec('CREATE TABLE [dbo].[%s](\n" +
                        "    [id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,\n" +
                        "    [operatorId] varchar(100),\n" +
                        "    [operatorName] varchar(100),\n" +
                        "    [dllcoId] varchar(100) NULL,\n" +
                        "    [billdocumentId] varchar(100) NULL,\n" +
                        "    [contextMenuId] int NULL,\n" +
                        "    [printName] varchar(100) NULL,\n" +
                        "    [printSta] int default 0,\n" +
                        "    [sql1] varchar(8000) NULL,\n" +
                        "    [sql2] varchar(8000) NULL,\n" +
                        "    [sql3] varchar(8000) NULL,\n" +
                        "    [sql4] varchar(8000) NULL\n" +
                        ")')",
                tableName, tableName
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 新版web调用cs打印 打印次数统计 2025-05-07
     */
    private void updatePrintTab250507() {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_systemWebPrintTab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'printSta') is null exec('alter table %s add printSta int default 0;')%n",
                tableName, tableName
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'billdocumentId') is null exec('alter table %s add billdocumentId varchar(100);')%n",
                tableName, tableName
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 程序日志表
     */
    private void updateWebProLogTab() {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_sysWebProLogTab";

        sqlBuilder.append(String.format(
                "if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[%s]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n" +
                        "exec('CREATE TABLE [dbo].[%s](\n" +
                        "    [id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,\n" +
                        "    [level] varchar(10),\n" +
                        "    [className] varchar(100),\n" +
                        "    [operatorId] varchar(100),\n" +
                        "    [operatorName] varchar(100),\n" +
                        "    [dllcoId] varchar(100) NULL,\n" +
                        "    [passTime] decimal(18,2) NULL,\n" +
                        "    [method] varchar(100) NULL,\n" +
                        "    [args] text NULL,\n" +
                        "    [msg] text NULL,\n" +
                        "    [happenTime] datetime not NULL default getdate()\n" +
                        ")')",
                tableName, tableName
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateEmployeeTab_20230408() {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_employeetab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'GTClientId') is null exec('alter table %s add GTClientId varchar(100);')%n",
                tableName, tableName
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'CTClientInfo') is null exec('alter table %s add CTClientInfo varchar(8000);')%n",
                tableName, tableName
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateEmployeeTab_20230412() {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_employeetab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'AppVer') is null exec('alter table %s add AppVer varchar(100);')%n",
                tableName, tableName
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateEmployeeTab_20230413() {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_employeetab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'OsLastLoginDate') is null exec('alter table %s add OsLastLoginDate datetime;')%n",
                tableName, tableName
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'LoginOsModel') is null exec('alter table %s add LoginOsModel varchar(100);')%n",
                tableName, tableName
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private void updateEmployeeTab_20230520() {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_employeetab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'LoginOsID') is null exec('alter table %s add LoginOsID varchar(100);')%n",
                tableName, tableName
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'FieldServiceType') is null exec('alter table %s add FieldServiceType int default 1;')%n",
                tableName, tableName
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 增加表格文字停靠样式，表格线配置，表格编号配置
     */
    private void update_20230522() {
        StringBuilder sqlBuilder = new StringBuilder();

        // 处理p_systemwordbooktab表
        String table1 = "dbo.p_systemwordbooktab";
        sqlBuilder.append(String.format(
                "if col_length('%s', 'dataAlign') is null exec('alter table %s add dataAlign varchar(100);')%n",
                table1, table1
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'frozenFlag') is null exec('alter table %s add frozenFlag int;')%n",
                table1, table1
        ));

        // 处理p_systemDlltabDetailGrid表
        String table2 = "p_systemDlltabDetailGrid";
        sqlBuilder.append(String.format(
                "if col_length('%s', 'dataAlign') is null exec('alter table %s add dataAlign varchar(100);')%n",
                table2, table2
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'frozenFlag') is null exec('alter table %s add frozenFlag int;')%n",
                table2, table2
        ));

        // 处理p_systemdlltab表
        String table3 = "dbo.p_systemdlltab";
        sqlBuilder.append(String.format(
                "if col_length('%s', 'noGridLine') is null exec('alter table %s add noGridLine int default 0;')%n",
                table3, table3
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'noRownumber') is null exec('alter table %s add noRownumber int default 0;')%n",
                table3, table3
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'noColumnHeader') is null exec('alter table %s add noColumnHeader int default 0;')%n",
                table3, table3
        ));

        // 处理p_systemdlltabdetail表
        String table4 = "dbo.p_systemdlltabdetail";
        sqlBuilder.append(String.format(
                "if col_length('%s', 'noGridLine') is null exec('alter table %s add noGridLine int default 0;')%n",
                table4, table4
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'noRownumber') is null exec('alter table %s add noRownumber int default 0;')%n",
                table4, table4
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'noColumnHeader') is null exec('alter table %s add noColumnHeader int default 0;')%n",
                table4, table4
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    public void updateComment_230612() {
        StringBuilder sqlBuilder = new StringBuilder();
        String table1 = "dbo.P_SystemCheckCommentTab";

        // 创建P_SystemCheckCommentTab表
        sqlBuilder.append(String.format(
                "if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[%s]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n" +
                        "exec('CREATE TABLE [dbo].[%s](\n" +
                        "    [id] [bigint] PRIMARY KEY IDENTITY(1,1) NOT NULL,\n" +
                        "    [moduleid] varchar(100) null, --模块编号\n" +
                        "    [keyValue] varchar(500) null, --主键值\n" +
                        "    [stepCode] varchar(100) null, --步骤码\n" +
                        "    [atts] varchar(8000) null,--附件\n" +
                        "    [pdataguid] [varchar](40) NULL,--来源标识ID\n" +
                        "    [operatorid] [int] NULL,--操作人员\n" +
                        "    [operatorname] [varchar](20) NULL,--操作人员名称\n" +
                        "    [commenttype] [int] NULL, --类别，1=点赞，2=评论\n" +
                        "    [comment_text] [varchar](2000) NULL, --评论内容\n" +
                        "    [operatedate] [datetime] NULL, --发生时间\n" +
                        "    [c_address] [varchar](200) NULL, --发生定点定位\n" +
                        "    [c_address_itude] [varchar](100) NULL, --地点经纬度\n" +
                        "    [c_address_longitude] [varchar](50) NULL,--经度\n" +
                        "    [c_address_latitude] [varchar](50) NULL--纬度\n" +
                        ")')",
                table1, table1
        ));

        // 创建crm_ProjectPlanLogTab表
        String table2 = "dbo.crm_ProjectPlanLogTab";
        sqlBuilder.append("\n");
        sqlBuilder.append(String.format(
                "if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[%s]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n" +
                        "exec('CREATE TABLE [dbo].[%s](\n" +
                        "    [id] [int] IDENTITY(1,1) PRIMARY key NOT NULL,\n" +
                        "    [RunningNumber] [varchar](40) NULL,\n" +
                        "    [PRunningNumber] [varchar](40) NULL,\n" +
                        "    [planTitle] [varchar](5000) NULL,\n" +
                        "    [planTime] [decimal](18, 1) NULL,\n" +
                        "    [planOper] [varchar](50) NULL,\n" +
                        "    [PlanDate] [datetime] NULL,\n" +
                        "    [Remark] [varchar](5000) NULL,\n" +
                        "    [FinishStatus] [int] NULL default 0,\n" +
                        "    [FinishBak] [varchar](5000) NULL,\n" +
                        "    [SelfAssessment] [varchar](5000) NULL,\n" +
                        "    [ManagerAssessment] [varchar](5000) NULL,\n" +
                        "    [OperateDate] [datetime] NULL,\n" +
                        "    [OperatorName] [varchar](20) NULL,\n" +
                        "    [stepover] [int] NULL,\n" +
                        "    [stepovertime] [datetime] NULL,\n" +
                        "    [stepovername] [varchar](50) NULL,\n" +
                        "    [isSubsidies] [int] NULL default 0,\n" +
                        "    [scoreValue] [decimal](18, 2) NULL default 0,\n" +
                        "    [yearid] [int] NULL,\n" +
                        "    [monthid] [int] NULL,\n" +
                        "    [weekid] [int] NULL,\n" +
                        "    [weekname] [varchar](50) NULL,\n" +
                        "    [ProjectNo] [varchar](20) NULL,\n" +
                        "    [StageNo] [varchar](20) NULL,\n" +
                        "    [StageName] [varchar](200) NULL,\n" +
                        "    [PlanNo] [varchar](20) NULL,\n" +
                        "    [CustomId] [varchar](50) NULL,\n" +
                        "    [PlanDaymid] [int] NULL,\n" +
                        "    [TopLogID] [int] NULL,\n" +
                        "    [NextRemark] [varchar](1000) NULL,\n" +
                        "    [insert_linktab] [varchar](100) NULL,\n" +
                        "    [insert_wcsqtab] [varchar](100) NULL,\n" +
                        "    [crm_hr_str3] [varchar](1000) NULL,\n" +
                        "    [crm_hr_str3_latitude] [varchar](1000) NULL,\n" +
                        "    [crm_hr_str3_longitude] [varchar](1000) NULL,\n" +
                        "    [ZlogBillID] [varchar](1000) NULL,\n" +
                        "    [work_mode] [varchar](100) NULL,\n" +
                        "    [GroupName] [varchar](100) NULL,\n" +
                        "    [LtoNo] [varchar](100) NULL,\n" +
                        "    [crm_hr_str3_itude] [varchar](100) NULL,\n" +
                        "    [completetime] [datetime] NULL,\n" +
                        "    [entryname] [varchar](500) NULL,\n" +
                        "    [str1] [varchar](1000) NULL,\n" +
                        "    [str2] [varchar](1000) NULL,\n" +
                        "    [str3] [varchar](1000) NULL,\n" +
                        "    [str4] [varchar](1000) NULL,\n" +
                        "    [str5] [varchar](1000) NULL,\n" +
                        "    [billno] [varchar](20) NULL,\n" +
                        "    [name] [varchar](200) NULL default '''',\n" +
                        "    [sname] [varchar](500) NULL default '''',\n" +
                        "    [colorid] [int] NULL default 0,\n" +
                        "    [sign] [int] NULL default 0,\n" +
                        "    [delid] [int] NULL default 0,\n" +
                        "    [operatorid] [int] NULL default 0,\n" +
                        "    [Affirmer] [int] NULL,\n" +
                        "    [AffirmDate] [datetime] NULL,\n" +
                        "    [ban] [int] NULL,\n" +
                        "    [stepcode] [int] NULL,\n" +
                        "    [billtype] [int] NULL,\n" +
                        "    [happentime] [datetime] NULL,\n" +
                        "    [endtime] [datetime] NULL,\n" +
                        "    [stepdirection] [char](1) NULL,\n" +
                        "    [stepoverid] [int] NULL,\n" +
                        "    [Rtagid] [int] NULL,\n" +
                        "    [stepTime] [decimal](10, 2) NULL,\n" +
                        "    [cancelFlag] [int] NULL,\n" +
                        "    [pStepCode] [varchar](100) NULL,\n" +
                        "    [cancelTime] [datetime] NULL,\n" +
                        "    [cancelOper] [int] NULL,\n" +
                        "    [lskjimport_errorFlag] [varchar](20) NULL default ''0'',\n" +
                        "    [planOperId] [varchar](50) NULL,\n" +
                        "    atts varchar(8000) null,--附件\n" +
                        "    rztype int default 0, --日志类型，0=日志，1=计划，2=议题\n" +
                        "    qd_address varchar(200),--签到地址（定位）\n" +
                        "    qd_address_itude varchar(20),--签到经纬度\n" +
                        "    qd_address_longitude varchar(20),--签到经度\n" +
                        "    qd_address_latitude varchar(20),--签到纬度\n" +
                        "    qd_time datetime,--签到时间\n" +
                        "    qt_address varchar(200),--签退地址（定位）\n" +
                        "    qt_time datetime,--签退时间\n" +
                        "    qt_address_itude varchar(20),--签退经纬度\n" +
                        "    qt_address_longitude varchar(20),--签退经度\n" +
                        "    qt_address_latitude varchar(20),--签退纬度\n" +
                        "    share_users varchar(2000),--分享人员,多人逗号分割\n" +
                        "    dataguid varchar(40) default newid(),--数据识别GUID,可用于关联到考勤、附件或者点赞评论等\n" +
                        "    nextdt datetime --下次提醒时间\n" +
                        ")')",
                table2, table2
        ));

        // 执行第一条SQL
        jdbcTemplate.execute(sqlBuilder.toString());

        // 清空builder，准备第二条SQL
        sqlBuilder.setLength(0);
        sqlBuilder.append(String.format(
                "if col_length('%s', 'rztype') is null exec('\n" +
                        "    alter table %s add rztype int, --日志类型，0=日志，1=计划，2=议题\n" +
                        "    planOperId varchar(50),\n" +
                        "    atts varchar(8000) null,--附件\n" +
                        "    qd_address varchar(200),--签到地址（定位）\n" +
                        "    qd_address_itude varchar(20),--签到经纬度\n" +
                        "    qd_address_longitude varchar(20),--签到经度\n" +
                        "    qd_address_latitude varchar(20),--签到纬度\n" +
                        "    qd_time datetime,--签到时间\n" +
                        "    qt_address varchar(200),--签退地址（定位）\n" +
                        "    qt_time datetime,--签退时间\n" +
                        "    qt_address_itude varchar(20),--签退经纬度\n" +
                        "    qt_address_longitude varchar(20),--签退经度\n" +
                        "    qt_address_latitude varchar(20),--签退纬度\n" +
                        "    share_users varchar(2000),--分享人员,多人逗号分割\n" +
                        "    dataguid varchar(40) default newid()--数据识别GUID,可用于关联到考勤、附件或者点赞评论等\n" +
                        "')",
                table2, table2
        ));

        jdbcTemplate.execute(sqlBuilder.toString());

        // 清空builder，准备第三条SQL
        sqlBuilder.setLength(0);
        String table3 = "dbo.Hr_daily_recordlistTab";
        sqlBuilder.append(String.format(
                "if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[%s]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n" +
                        "exec('CREATE TABLE [dbo].[%s](\n" +
                        "    rztype int, --日志类型，0=日志，1=计划，2=议题\n" +
                        "    planOperId varchar(50),\n" +
                        "    sourceModid varchar(20),--来源模块\n" +
                        "    sourceKeyValue varchar(50),--来源主键\n" +
                        "    atts varchar(8000) null,--附件\n" +
                        "    qd_address varchar(200),--签到地址（定位）\n" +
                        "    qd_address_itude varchar(20),--签到经纬度\n" +
                        "    qd_address_longitude varchar(20),--签到经度\n" +
                        "    qd_address_latitude varchar(20),--签到纬度\n" +
                        "    qd_time datetime,--签到时间\n" +
                        "    qt_address varchar(200),--签退地址（定位）\n" +
                        "    qt_time datetime,--签退时间\n" +
                        "    qt_address_itude varchar(20),--签退经纬度\n" +
                        "    qt_address_longitude varchar(20),--签退经度\n" +
                        "    qt_address_latitude varchar(20),--签退纬度\n" +
                        "    share_users varchar(2000),--分享人员,多人逗号分割\n" +
                        "    dataguid varchar(40) default newid()--数据识别GUID,可用于关联到考勤、附件或者点赞评论等\n" +
                        ")')\n" +
                        "else if col_length('%s', 'rztype') is null exec('\n" +
                        "    alter table %s add rztype int, --日志类型，0=日志，1=计划，2=议题\n" +
                        "    planOperId varchar(50),\n" +
                        "    sourceModid varchar(20),--来源模块\n" +
                        "    sourceKeyValue varchar(50),--来源主键\n" +
                        "    atts varchar(8000) null,--附件\n" +
                        "    qd_address varchar(200),--签到地址（定位）\n" +
                        "    qd_address_itude varchar(20),--签到经纬度\n" +
                        "    qd_address_longitude varchar(20),--签到经度\n" +
                        "    qd_address_latitude varchar(20),--签到纬度\n" +
                        "    qd_time datetime,--签到时间\n" +
                        "    qt_address varchar(200),--签退地址（定位）\n" +
                        "    qt_time datetime,--签退时间\n" +
                        "    qt_address_itude varchar(20),--签退经纬度\n" +
                        "    qt_address_longitude varchar(20),--签退经度\n" +
                        "    qt_address_latitude varchar(20),--签退纬度\n" +
                        "    share_users varchar(2000),--分享人员,多人逗号分割\n" +
                        "    dataguid varchar(40) default newid()--数据识别GUID,可用于关联到考勤、附件或者点赞评论等\n" +
                        "')",
                table3, table3, table3, table3
        ));

        // 添加头像字段
        sqlBuilder.append("\n");
        String table4 = "dbo.p_employeetab";
        sqlBuilder.append(String.format(
                "if col_length('%s', 'webbmp') is null exec('alter table %s add webbmp varchar(1000)')",
                table4, table4
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 增加表格文字停靠样式，表格线配置，表格编号配置
     */
    private void update_20230704() {
        StringBuilder sqlBuilder = new StringBuilder();
        String tableName = "dbo.p_systemdlltab";

        sqlBuilder.append(String.format(
                "if col_length('%s', 'closeAfterModify') is null exec('alter table %s add closeAfterModify int;')%n",
                tableName, tableName
        ));
        sqlBuilder.append(String.format(
                "if col_length('%s', 'closeAfterAdd') is null exec('alter table %s add closeAfterAdd int;')%n",
                tableName, tableName
        ));

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 扫码相关字段更新 (202307011)
     */
    private void update_202307011() {
        StringBuilder sqlBuilder = new StringBuilder();
        // scanMode 扫码弹窗 1弹窗 barSplitChar 扫码分隔符 barSplitFields 扫码分割的字段
        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'scanMode') is null \n")
                .append("  exec('alter table dbo.p_systemdlltab add scanMode int;')\n")
                .append("if col_length('dbo.p_systemdlltab', 'verifyCancel') is null \n")
                .append("  exec('alter table dbo.p_systemdlltab add verifyCancel int;')\n")
                .append("if col_length('dbo.p_systemdlltab', 'barSplitChar') is null \n")
                .append("  exec('alter table dbo.p_systemdlltab add barSplitChar varchar(100);')\n")
                .append("if col_length('dbo.p_systemdlltab', 'barSplitFields') is null \n")
                .append("  exec('alter table dbo.p_systemdlltab add barSplitFields varchar(1000);')\n")
                .append("if col_length('dbo.p_systemdlltab', 'appAutoSave') is null \n")
                .append("  exec('alter table dbo.p_systemdlltab add appAutoSave int;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 添加分组表相关字段
     */
    private void updateAddGroupTab() {
        StringBuilder sqlBuilder = new StringBuilder();
        // 添加界面，分组框打开时，是否折叠 空或者1为展开
        sqlBuilder.append("if col_length('dbo.p_systemaddgroup', 'isexpand') is null \n")
                .append("  exec('alter table dbo.p_systemaddgroup add isexpand int;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 明细分页设置更新
     */
    private void update_p_systemdlldetailtab() {
        StringBuilder sqlBuilder = new StringBuilder();
        // 添加界面明细分页数设置  大屏相关
        sqlBuilder.append("if col_length('dbo.p_systemdlltabdetail', 'displayRows') is null \n")
                .append("  exec('alter table dbo.p_systemdlltabdetail add displayRows int default 0;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 下拉框宽度配置更新 (240420)
     */
    private void updateLookupWidth240420() {
        StringBuilder sqlBuilder = new StringBuilder();
        // 添加下拉框宽度配置
        sqlBuilder.append("if col_length('dbo.p_systemwordbooktab', 'lookupWidth') is null \n")
                .append("  exec('alter table dbo.p_systemwordbooktab add lookupWidth int default 0;')\n")
                .append("if col_length('dbo.p_systemwordbooktab', 'lookupFieldsWidth') is null \n")
                .append("  exec('alter table dbo.p_systemwordbooktab add lookupFieldsWidth varchar(50);')\n")
                .append("if col_length('dbo.p_systembillinfo', 'lookupWidth') is null \n")
                .append("  exec('alter table dbo.p_systembillinfo add lookupWidth int default 0;')\n")
                .append("if col_length('dbo.p_systembillinfo', 'lookupFieldsWidth') is null \n")
                .append("  exec('alter table dbo.p_systembillinfo add lookupFieldsWidth varchar(50);')\n")
                .append("if col_length('dbo.p_systembilldetail', 'lookupWidth') is null \n")
                .append("  exec('alter table dbo.p_systembilldetail add lookupWidth int default 0;')\n")
                .append("if col_length('dbo.p_systembilldetail', 'lookupFieldsWidth') is null \n")
                .append("  exec('alter table dbo.p_systembilldetail add lookupFieldsWidth varchar(50);')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 字体大小配置更新 (240426)
     */
    private void update_bookfontsize240426() {
        StringBuilder sqlBuilder = new StringBuilder();
        // 添加下拉框宽度配置
        sqlBuilder.append("if col_length('dbo.p_systemwordbooktab', 'fontSize') is null \n")
                .append("  exec('alter table dbo.p_systemwordbooktab add fontSize int;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 字体大小配置更新 (240815)
     */
    private void update_bookfontsize240815() {
        StringBuilder sqlBuilder = new StringBuilder();
        // 添加下拉框宽度配置
        sqlBuilder.append("if col_length('dbo.p_systembillInfo', 'fontSize') is null \n")
                .append("  exec('alter table dbo.p_systembillInfo add fontSize int;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 弹窗菜单更新 (240428)
     */
    private void update_popupmenu240428() {
        StringBuilder sqlBuilder = new StringBuilder();
        // 添加下拉框宽度配置
        sqlBuilder.append("if col_length('dbo.p_systempopupmenu', 'defailtImage') is null \n")
                .append("  exec('alter table dbo.p_systempopupmenu add defailtImage varchar(100);')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 弹窗菜单更新 (240522)
     */
    private void update_popupmenu240522() {
        StringBuilder sqlBuilder = new StringBuilder();
        // 添加下拉框宽度配置
        sqlBuilder.append("if col_length('dbo.p_systempopupmenu', 'disabletype') is null \n")
                .append("  exec('alter table dbo.p_systempopupmenu add disabletype int default 0;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 条件配置更新 (240807)
     */
    private void updateCondition240807() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systembillsourcecond', 'dataformat') is null \n")
                .append("  exec('alter table dbo.p_systembillsourcecond add dataformat varchar(100);')\n")
                // 启用条件
                .append("if col_length('dbo.p_systembillsourcecond', 'disableCond') is null \n")
                .append("  exec('alter table dbo.p_systembillsourcecond add disableCond varchar(1000);')\n")
                // 启用类型 1：显示和不显示 默认0：启用和禁用
                .append("if col_length('dbo.p_systembillsourcecond', 'disableType') is null \n")
                .append("  exec('alter table dbo.p_systembillsourcecond add disableType int;')\n")
                .append("if col_length('dbo.p_systembillsourcecond', 'fontsize') is null \n")
                .append("  exec('alter table dbo.p_systembillsourcecond add fontsize int;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 单据行高和对齐方式更新 (20240902)
     */
    private void update_20240902() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_systembilltype', 'rowHeight') is null \n")
                .append("  exec('alter table dbo.p_systembilltype add rowHeight int;')\n")
                .append("if col_length('dbo.p_systembillsourcegrid', 'dataAlignment') is null \n")
                .append("  exec('alter table dbo.p_systembillsourcegrid add dataAlignment int default 0;')\n")
                .append("if col_length('dbo.p_systembillsourcegrid', 'labelAlign') is null \n")
                .append("  exec('alter table dbo.p_systembillsourcegrid add labelAlign int default 0;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 新BI表结构创建 (240824)
     */
    private void updateNewBI_240824() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[BI_NodeTagTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n")
                .append("exec('CREATE TABLE [dbo].[BI_NodeTagTab](\n")
                .append("     [ID] [int] primary key IDENTITY(1,1) NOT NULL,\n")
                .append("     [nodeName] varchar(150) NULL,\n")
                .append("     [navigateType] [int] NULL,\n")
                .append("     [operatorid] [int] NULL,\n")
                .append("     [operatedate] [datetime] NULL,\n")
                .append("     [enableFlag] [int] NULL default 0\n")
                .append(" ); \n")
                .append(" EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''BI显示名称或标题'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_NodeTagTab'', @level2type=N''COLUMN'',@level2name=N''nodeName''; \n")
                .append(" EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''导航类别，0-菜单导航，1=树结构导航'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_NodeTagTab'', @level2type=N''COLUMN'',@level2name=N''navigateType''; \n")
                .append(" EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''启用标记1=启用'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_NodeTagTab'', @level2type=N''COLUMN'',@level2name=N''enableFlag'';')\n")
                .append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[BI_StructureTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n")
                .append("exec('CREATE TABLE [dbo].[BI_StructureTab](\n")
                .append("       [id] [int] primary key IDENTITY(1,1) NOT NULL,\n")
                .append("       [Tagid] [int] NULL,\n")
                .append("       [SpeciesNo] varchar(50) NULL,\n")
                .append("       [SpeciesName] varchar(50) NULL,\n")
                .append("       [enableFlag] [int] NULL default 0,\n")
                .append("       [Bak] varchar(150) NULL,\n")
                .append("       [Modid] varchar(50) NULL,\n")
                .append("       [mainVisible] [int] NULL default 0,\n")
                .append("       [imgUrl] varchar(200) NULL,\n")
                .append("       [visibleDetailType] [int] NULL default 0,\n")
                .append("       [mainHeight] [int] NULL,\n")
                .append("       [mainWidth] [int] NULL,\n")
                .append("       [defaultFlag] [int] NULL default 0,\n")
                .append("       [operatorid] [int] NULL,\n")
                .append("       [operatedate] [datetime] NULL,\n")
                .append("       [displayModid] varchar(50) NULL,\n")
                .append("       [dllfilename] varchar(50) NULL,\n")
                .append("       [dllparams] varchar(1000) NULL,\n")
                .append("       [Orderid] [int] NULL\n")
                .append("   ); \n")
                .append("   EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''BI标识，通过访问地址传入，名称对应BI_NodeTagTab'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_StructureTab'', @level2type=N''COLUMN'',@level2name=N''Tagid''; \n")
                .append("   EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''BI节点代码'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_StructureTab'', @level2type=N''COLUMN'',@level2name=N''SpeciesNo''; \n")
                .append("   EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''BI节点名称'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_StructureTab'', @level2type=N''COLUMN'',@level2name=N''SpeciesName''; \n")
                .append("   EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''启用标记1=启用，节点禁用后不再显示（含子节点）'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_StructureTab'', @level2type=N''COLUMN'',@level2name=N''enableFlag''; \n")
                .append("   EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''节点说明'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_StructureTab'', @level2type=N''COLUMN'',@level2name=N''Bak''; \n")
                .append("   EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''关联模块编号，配置了关联模块号'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_StructureTab'', @level2type=N''COLUMN'',@level2name=N''Modid''; \n")
                .append("   EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''显示模块标记，1代表在节点上'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_StructureTab'', @level2type=N''COLUMN'',@level2name=N''mainVisible''; \n")
                .append("   EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''首页显示模块'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_StructureTab'', @level2type=N''COLUMN'',@level2name=N''displayModid''; \n")
                .append("   EXEC sys.sp_addextendedproperty @name=N''MS_Description'', @value=N''关联模块调用模版'' , @level0type=N''SCHEMA'',@level0name=N''dbo'', @level1type=N''TABLE'',@level1name=N''BI_StructureTab'', @level2type=N''COLUMN'',@level2name=N''dllfilename'';')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 考勤打卡限制时间更新 (20240920)
     */
    private void update_20240920() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_employeetab', 'p_emp_AttendanceTime') is null \n")
                .append("  exec('alter table dbo.p_employeetab add p_emp_AttendanceTime int;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 禁用mes选账套功能更新 (20241006)
     */
    private void update_20241006() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_SystemTab', 'mes_address_change') is null \n")
                .append("  exec('alter table dbo.p_SystemTab add mes_address_change int;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 系统DLL表更新 (241025)
     */
    private void updateDllTab_241025() {
        StringBuilder sqlBuilder = new StringBuilder();
        // p_systemdlltab
        sqlBuilder.append("if col_length('dbo.p_systemdlltab', 'CsHasDefultSearch') is null \n")
                .append("  exec('alter table dbo.p_systemdlltab add CsHasDefultSearch int default 0;')\n")
                .append("if col_length('dbo.p_systemdlltab', 'gridobjcheck') is null \n")
                .append("  exec('alter table dbo.p_systemdlltab add gridobjcheck int default 0;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 字体颜色配置更新 (241101)
     */
    private void updateBookColor_241101() {
        StringBuilder sqlBuilder = new StringBuilder();
        // p_systemdlltab
        sqlBuilder.append("if col_length('dbo.p_systemwordbookcolor', 'fontsize') is null \n")
                .append("  exec('alter table dbo.p_systemwordbookcolor add fontsize int null;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 业务表更新 (241119)
     */
    private void updatebusiness_241119() {
        StringBuilder sqlBuilder = new StringBuilder();
        // p_systemdlltab
        sqlBuilder.append("if col_length('dbo.P_SystemCheckTab', 'stepover') is null \n")
                .append("  exec('alter table dbo.P_SystemCheckTab add stepover int null;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 业务表更新 (24111901)
     */
    private void updateBusiness24111901() {
        StringBuilder sqlBuilder = new StringBuilder();
        // p_systemdlltab
        sqlBuilder.append("if col_length('dbo.LBC_FileGroupTab', 'deptids') is null \n")
                .append("  exec('alter table dbo.LBC_FileGroupTab add deptids varchar(100) null;')\n")
                .append("if col_length('dbo.LBC_ExamGroupTab', 'judge') is null \n")
                .append("  exec('alter table dbo.LBC_ExamGroupTab add judge int null;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 知识库文件组排序更新 (24121001)
     */
    private void updateBusiness24121001() {
        StringBuilder sqlBuilder = new StringBuilder();
        // p_systemdlltab
        sqlBuilder.append("if col_length('dbo.LBC_FileGroupTab', 'grouporderid') is null \n")
                .append("  exec('alter table dbo.LBC_FileGroupTab add grouporderid varchar(100) null;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * 知识库附件排序更新 (24121101)
     */
    private void updatebusiness_24121101() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if col_length('dbo.p_fm_filetab', 'fileorderid') is null \n")
                .append("  exec('alter table dbo.p_fm_filetab add fileorderid varchar(100) null;')");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    /**
     * web端自动更新表创建 (20250429)
     */
    private void updateWebUpdTab() {
        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[P_SystemWebUpdateTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n")
                .append("exec('CREATE TABLE [dbo].[P_SystemWebUpdateTab](\n")
                .append("       [id] [int] IDENTITY(1,1) NOT NULL primary key,\n")
                .append("       [version] [varchar](100) not NULL,\n")
                .append("       [versioncode] [int] not NULL,\n")
                .append("       [name] [varchar](50) NULL,\n")
                .append("       [note] [varchar](500) NULL,\n")
                .append("       [download] [varchar](500) NULL,\n")
                .append("       [desc] [varchar](50) NULL,\n")
                .append("       [createDate] datetime not null default getdate(),\n")
                .append("       [force] int default 0--是否强制更新 1：必须更新\n")
                .append("   )');\n")
                .append("if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[P_SystemWebUpdateHisTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n")
                .append("exec('CREATE TABLE [dbo].[P_SystemWebUpdateHisTab](\n")
                .append("       [id] [int] IDENTITY(1,1) NOT NULL primary key,\n")
                .append("       [version] [int] NULL,\n")
                .append("       [oaurl] [varchar](100) NULL,\n")
                .append("       [webver] [varchar](100) NULL,\n")
                .append("       [sysinfo] [varchar](max) NULL,\n")
                .append("       [createDate] datetime not null default getdate()\n")
                .append("   )');");

        jdbcTemplate.execute(sqlBuilder.toString());
    }

    private String dataVersion = "";

    /**
     * 当前程序版本
     */
    private static final String VERSION = "1.0.9.4";

    /**
     * 检查更新版本
     *
     * @param ver         版本号
     * @param versionName 版本字段名，默认"WebVersion"
     * @return 如果版本不一致需要更新返回true，否则返回false
     */
    protected boolean checkUpdateVersion(String ver, String versionName) {
        if (versionName == null || versionName.isEmpty()) {
            versionName = "WebVersion";
        }

        try {
            // 检查并添加版本字段
            StringBuilder sqlBuilder = new StringBuilder();
            sqlBuilder.append(String.format("if col_length('dbo.p_SystemTab', '%s') is null " +
                            "exec('alter table dbo.p_SystemTab add %s varchar(100);')",
                    versionName, versionName));
            jdbcTemplate.execute(sqlBuilder.toString());

            // 查询当前数据版本
            String querySql = String.format("select top 1 %s from dbo.p_SystemTab", versionName);
            Object result = jdbcTemplate.queryForObject(querySql, Object.class);
            dataVersion = result != null ? result.toString() : "";

            // 版本不一致时更新
            if (!dataVersion.equals(ver)) {
                String updateSql = String.format("update dbo.p_SystemTab set %s = '%s'", versionName, ver);
                jdbcTemplate.execute(updateSql);

                // 处理初始版本为空的情况
                if (dataVersion.isEmpty()) {
                    dataVersion = "1.0.0.0";
                }
                return true;
            }
            return false;
        } catch (Exception e) {
            // 日志记录可根据实际情况添加
            log.error("Exception caught", e);
            return false;
        }
    }

    protected boolean checkUpdateVersion(String ver) {
        return checkUpdateVersion(ver, "WebVersion");
    }

    /**
     * 获取数据版本的数字表示（去除小数点）
     */
    protected int getDataVer() {
        return NativeExtensionUtils.ToInt32(dataVersion.replace(".", ""));
    }

    /**
     * 获取当前程序版本的数字表示（去除小数点）
     */
    public static int getVersion() {
        return NativeExtensionUtils.ToInt32(VERSION.replace(".", ""));
    }

    /**
     * 升级控制主方法
     */
    public boolean checkUpdate() throws SQLException {
        if (checkUpdateVersion(VERSION)) {
            int currentVersion = getDataVer();

            // 执行各版本升级操作
            if (1000 >= currentVersion) {
                updateSubSysTab();
                updateSysMenuTab();
                updateDllTab();
                updateBillTypeTab();
                updateDllTabDetail();
                updateWorkBookTab();
                updateNotificationTab();
                updateMessge();
                updateSystemOtherTab();
                updateField();
                updateBillField();
                updateView();
                updateFlowChartCfgTable();
                updateFirstPageTable();
                updateBITab();
                updateMobileCard();
                updateAttcCusSet();
                updateErrInfoTab();
                updateProductSpeciesTab(); // 20220706添加
            }
            if (1002 >= currentVersion) updateSysTab();
            if (1003 > currentVersion) updateDlltabDetailFlowTab();
            if (1004 > currentVersion) updateAuditFlowTypeStepTab();
            if (1005 > currentVersion) updateCusModuleAddTpl();
            if (1006 > currentVersion) updatePopupMenu();
            if (1007 > currentVersion) updateDllTab_21429();
            if (1008 > currentVersion) {
                updateAuditAttach();
                updateDlltabDetailFlowTab_210430();
                updateDllTabDetail_210430();
                updatePopupMenu_210507();
                updateDllTabDetail_210514();
                updateDlltabDetailFlowTab_210514();
            }
            if (1009 > currentVersion) {
                updateDllTab_210519();
                updateBillTab_210525();
            }
            if (1010 > currentVersion) updateWorkBookTab_210527();
            if (1011 > currentVersion) updateDllTab_210610();
            if (1012 > currentVersion) {
                updateDllTab_210624();
                updateSysTab_210630();
            }
            if (1013 > currentVersion) updateMobileCard_210707();
            if (1014 > currentVersion) {
                updateDllTab_210901();
                updateBillTypeTab_210901();
            }
            if (1015 > currentVersion) updateWorkBookTab_210911();
            if (1016 > currentVersion) {
                updateDllTabDetail_210914();
                updateAuditAttach_20210918();
                updateDlltabAttach_20210918();
            }
            if (1017 > currentVersion) updateSystemdlltabChart_20210927();
            if (1018 > currentVersion) updateBillTab_211022();
            if (1019 > currentVersion) updateLogTab_20211027();
            if (1020 > currentVersion) {
                updateEmployeetab_20210928();
                updateDllTab_202111122();
            }
            if (1021 > currentVersion) updateLoginCfg();
            if (1022 > currentVersion) updateDllTab_20211129();
            if (1023 > currentVersion) updateDllTab_20211129a();
            if (canUpdVer(1024)) updateDllTabDetail_220114();
            if (canUpdVer(1025)) updateSystemdlltabChart_20220208();
            if (canUpdVer(1026)) updateDllTab_20220309();
            if (canUpdVer(1027)) updateMobileCard_220322();
            if (canUpdVer(1028)) updateDllTab_20220414();
            if (canUpdVer(1029)) updateDllTab_20220524();
            if (canUpdVer(1030)) updateEmployeetab_20220617();
            if (canUpdVer(1031)) updateWorkBookTab_220704();
            if (canUpdVer(1032)) updatePopupMenu_220720();
            if (canUpdVer(1033)) updatePopupMenu_220812();
            if (canUpdVer(1034)) updateDllFlow_220823();
            if (canUpdVer(1035)) updatePrintTab(); // 该版本需新版打印程序支持
            if (canUpdVer(1036)) updateMegToolLiknkTab_20220914();
            if (canUpdVer(1037)) updatePopupMenu_220929();
            if (canUpdVer(1038)) updateDllTab_221024();
            if (canUpdVer(1039)) updatePopupMenu_221123();
            if (canUpdVer(1040)) updateEmployeetab_20221207();
            if (canUpdVer(1041)) updateWorkbooktab_20230206();
            if (canUpdVer(1042)) updateDllTab_20230209();
            if (canUpdVer(1043)) {
                updateFileTab20230224();
                updatebSysTab20230224();
            }
            if (canUpdVer(1044)) updateFieldTab_20230314();
            if (canUpdVer(1045)) updateSysteTab_20230328();
            if (canUpdVer(1046)) updateDllTab_20230406();
            if (canUpdVer(1047)) updateEmployeeTab_20230408();
            if (canUpdVer(1048)) updateEmployeeTab_20230412();
            if (canUpdVer(1049)) updateEmployeeTab_20230413();
            if (canUpdVer(1050)) updateEmployeeTab_20230520();
            if (canUpdVer(1051)) {
                update_20230522();
                updateComment_230612();
            }
            if (canUpdVer(1052)) update_20230704();
            if (canUpdVer(1055)) {
                update_202307011();
                updateAddGroupTab();
            }
            if (canUpdVer(1056)) update_p_systemdlldetailtab();
            if (canUpdVer(1057)) updateDllTab_231215();
            if (canUpdVer(1058)) updateDllTab_240117();
            if (canUpdVer(1059)) updateGroupTab_240120();
            if (canUpdVer(1060)) updateWorkBookTab_240321();
            if (canUpdVer(1061)) updateNotification_240412();
            if (canUpdVer(1062)) updateLookupWidth240420();
            if (canUpdVer(1063)) update_bookfontsize240426();
            if (canUpdVer(1064)) update_popupmenu240428();
            if (canUpdVer(1065)) update_popupmenu240522();
            if (canUpdVer(1066)) updateDllTab_240617();
            if (canUpdVer(1067)) updateDllTab_240619();
            if (canUpdVer(1068)) updateSysteTab_20240625();
            if (canUpdVer(1069)) updateCondition240807();
            if (canUpdVer(1070)) update_bookfontsize240815();
            if (canUpdVer(1071)) updateSystemdlltabChart_20240820();
            if (canUpdVer(1074)) update_20240902();
            if (canUpdVer(1075)) updateFieldTab_20240904();
            if (canUpdVer(1076)) updateEmployeeTab_20240909();
            if (canUpdVer(1077)) {
                updateBmpType_20240913();
                updateNewBI_240824();
            }
            if (canUpdVer(1078)) update_20241006();
            if (canUpdVer(1079)) update_20240920();
            if (canUpdVer(1080)) updateDllTab_241025();
            if (canUpdVer(1081)) updateBookColor_241101();
            if (canUpdVer(1082)) updateDlltabAttach_20241104();
            if (canUpdVer(1084)) updatebusiness_241119();
            if (canUpdVer(1087)) updatebusiness_24121101();
            if (canUpdVer(1088)) updateSystemdlltabChart_20241225();
            if (canUpdVer(1091)) {
                updateSysMenuTab_250120();
                updateFiletab_250120();
            }
            if (canUpdVer(1092)) updateDllTabDetail_250426();
            if (canUpdVer(1093)) updateWebUpdTab();
            if (canUpdVer(1094)) updatePrintTab250507();

            return true;
        }
        return false;
    }

    /**
     * 检查是否可以升级到指定版本
     *
     * @param updVer 目标版本
     * @return 是否可以升级
     */
    protected boolean canUpdVer(int updVer) {
        int currentVersion = getDataVer();
        return updVer > currentVersion && updVer <= getVersion();
    }
}
