处理文件对比缓存问题

This commit is contained in:
袁东强 2025-07-21 13:39:52 +08:00 committed by zhaolei
parent e2255fa7e1
commit 3f298c9f7c

View File

@ -1,5 +1,6 @@
package com.actionsoft.apps.coe.pal.pal.repository.upfile.dao; package com.actionsoft.apps.coe.pal.pal.repository.upfile.dao;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.cache.PALUpfileCache;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
import com.actionsoft.bpms.commons.database.RowMapper; import com.actionsoft.bpms.commons.database.RowMapper;
import com.actionsoft.bpms.util.DBSql; import com.actionsoft.bpms.util.DBSql;
@ -45,6 +46,10 @@ public class UpFileDao {
} }
String sql = DBSql.getInsertStatement(UpfileModel.DATABASE_ENTITY, paraMap); String sql = DBSql.getInsertStatement(UpfileModel.DATABASE_ENTITY, paraMap);
result = DBSql.update(sql.toString(), paraMap); result = DBSql.update(sql.toString(), paraMap);
if (result > 0) {
// 更新缓存
PALUpfileCache.putModel(model);
}
return result; return result;
} }
@ -77,7 +82,11 @@ public class UpFileDao {
sql.setCharAt(index, ' '); sql.setCharAt(index, ' ');
sql.append("where " + UpfileModel.FIELD_UUID + "=?"); sql.append("where " + UpfileModel.FIELD_UUID + "=?");
args.add(model.getUuid()); args.add(model.getUuid());
return DBSql.update(sql.toString(), args.toArray()); int result = DBSql.update(sql.toString(), args.toArray());
if (result > 0) {
PALUpfileCache.putModel(model);
}
return result;
} }
public boolean batchInsert(List<UpfileModel> list) { public boolean batchInsert(List<UpfileModel> list) {
@ -105,6 +114,8 @@ public class UpFileDao {
prest.addBatch(); prest.addBatch();
} }
prest.executeBatch(); prest.executeBatch();
//更新缓存
list.stream().forEach(PALUpfileCache::putModel);
conn.commit(); conn.commit();
return true; return true;
} catch (SQLException e) { } catch (SQLException e) {
@ -177,6 +188,10 @@ public class UpFileDao {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY).append(" where id = '" + uuid + "'"); sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY).append(" where id = '" + uuid + "'");
result = DBSql.update(sql.toString()); result = DBSql.update(sql.toString());
if (result > 0) {
// 更新缓存
PALUpfileCache.removeById(uuid);
}
return result; return result;
} }
@ -185,6 +200,10 @@ public class UpFileDao {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY).append(" where 1 = 1 ").append(sqlWhere); sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY).append(" where 1 = 1 ").append(sqlWhere);
result = DBSql.update(sql.toString()); result = DBSql.update(sql.toString());
if (result > 0) {
// 更新缓存
PALUpfileCache.getCache().reload();
}
return result; return result;
} }