fs-danaus
2022-09-15 e95a73219e7cbce52c5333afff7bc7b237c4697c
新增删除系统日志表多余记录接口
1个文件已添加
1个文件已修改
70 ■■■■■ 已修改文件
src/com/yc/open/init/InitSystemTaks.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/init/shcedule/DeleteSystemLogSchedule.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/init/InitSystemTaks.java
@@ -192,6 +192,9 @@
                    case "OP0050"://右下角弹窗显示
                        createScheduleTask(dataSourceEntity, task, new MessagePopTipsSchedule(dataSourceEntity));
                        break;
                    case "OP0055"://删除系统日志表中的记录
                        createScheduleTask(dataSourceEntity, task, new DeleteSystemLogSchedule(dataSourceEntity));
                        break;
                    default:
                        break;
                }
src/com/yc/open/init/shcedule/DeleteSystemLogSchedule.java
New file
@@ -0,0 +1,67 @@
package com.yc.open.init.shcedule;
import com.yc.entity.DataSourceEntity;
import com.yc.factory.FactoryBean;
import com.yc.multiData.SpObserver;
import com.yc.service.BaseService;
/**
 * 删除系统日志表中的记录
 */
public class DeleteSystemLogSchedule extends BaseSchedule implements Runnable {
    public DeleteSystemLogSchedule(DataSourceEntity dataSourceEntity) {
        super(dataSourceEntity);
    }
    @Override
    public void run() {
        try {
            if (Thread.interrupted()) {
                throw new InterruptedException();
            }
            String dbid = dataSourceEntity.getDbId() + "";
            log.info(dataSourceEntity.getSystemDescribe() + "-开始执行删除系统日志表中的记录");
            SpObserver.setDBtoInstance("_" + dbid);
            BaseService baseService = (BaseService) FactoryBean.getBean("BaseService");
            String sql="--慢查询日志,保留30天\n" +
                    " delete a from _sys_InquireTableLog a where InsertDate < DATEADD(day,-30,getdate())\n" +
                    " \n" +
                    " --回收站,保留30天\n" +
                    " delete a  from _Sys_SaveRecSQLForDeleted   a \n" +
                    " where exists(select  1 from _Sys_SaveRecForDeleted as b where a.DocCode = b.DocCode and b.EnterDate < DATEADD(day,-30,getdate())) \n" +
                    " --回收站,保留30天\n" +
                    " delete a from _Sys_SaveRecItemForDeleted a\n" +
                    " where exists(select  1 from _Sys_SaveRecForDeleted as b where a.DocCode = b.DocCode and b.EnterDate < DATEADD(day,-30,getdate())) \n" +
                    " --回收站,保留30天\n" +
                    " delete a from _Sys_SaveRecForDeleted a  where a.EnterDate < DATEADD(day,-30,getdate())\n" +
                    " \n" +
                    " --库存异动日志表,保留30天\n" +
                    " delete a from t140902Log a where a.logtime < DATEADD(day,-30,getdate())\n" +
                    " \n" +
                    " --最近访问,保留30天\n" +
                    " delete a from _sys_RecentAccessFormid a where a.lasttime < DATEADD(day,-30,getdate())\n" +
                    " \n" +
                    " --打印日志,保留30天\n" +
                    " delete a  from _sysprintlog  a where a.printdate < DATEADD(day,-30,getdate())\n" +
                    " \n" +
                    " --登录日志,保留60天\n" +
                    " delete a from _sysloginlog a where a.intime < DATEADD(day,-60,getdate())\n" +
                    " \n" +
                    " --系统错误日志,保留60天\n" +
                    " delete a from _sysErrorLog a where a.recordingtime  < DATEADD(day,-60,getdate())\n" +
                    " \n" +
                    " --附件删除日志,保留60天\n" +
                    " delete a  from _sys_AttachmentLog a where a.downloadtime  < DATEADD(day,-60,getdate()) ";
            baseService.getSimpleJdbcTemplate().execute(sql);
            log.info(dataSourceEntity.getSystemDescribe() + "-完成删除系统日志表中的记录");
        } catch (InterruptedException ex) {
            log.info(dataSourceEntity.getSystemID() + "删除系统日志表中的记录被终止");
        } catch (Exception ex) {
            ex.printStackTrace();
            log.error(dataSourceEntity.getSystemDescribe() + ":" + ex.getMessage());
        } finally {
            SpObserver.setDBtoInstance();
        }
    }
}