20260518172616

This commit is contained in:
oneao committed 2026-05-18 17:26:17 +08:00
1 parent 2e704bbbb0
commit 5cfc87eee8
8 files changed
+500 -276

No files matched your search

@@ -304,4 +304,81 @@ public class FileController {
}
}
@PostMapping("/deletes")
@Transactional(rollbackFor = Exception.class)
public Result<Void> deleteFiles(@RequestBody List<Object> subids) {
try {
if (subids == null || subids.isEmpty()) {
return Result.ok();
}
for (Object subidObj : subids) {
if (subidObj == null) {
continue;
}
Long subid = Long.valueOf(subidObj.toString());
// 1. 查询文件记录
List<Map<String, Object>> maps = dbUtils.loadData(
"SELECT * FROM bf_file WHERE subid = ?",
subid
);
if (maps.isEmpty()) {
continue;
}
Map<String, Object> objectMap = maps.get(0);
// 2. 获取文件路径
String mxMapfilename = objectMap.get("mx_mapfilename") == null
? ""
: objectMap.get("mx_mapfilename").toString();
// 3. 删除本地文件
if (StringUtils.isNotBlank(mxMapfilename)) {
String filePath = PathUtils.joinFilePath(
fileConfig.getBaseDir(),
mxMapfilename
);
boolean deleted = FileUtils.deleteFileByPath(filePath);
if (!deleted) {
System.out.println("文件删除失败或不存在: " + filePath);
}
}
// 4. 删除数据库记录
dbUtils.deleteById("bf_file", "subid", subid);
// 5. 记录日志
Map<String, Object> mapData = new HashMap<>();
ObjectMapper objectMapper = new ObjectMapper();
String dataStr = objectMapper.writeValueAsString(objectMap);
String currentDateTime = TimeUtils.getDateTime();
mapData.put("b_table", "bf_file");
mapData.put("b_option", "DELETE");
mapData.put("b_datas", dataStr);
mapData.put("b_inputdatetime", currentDateTime);
mapData.put("b_inputuser_id", UserContext.get().getUserId());
dbUtils.insert("log_datas", "b_id", mapData);
}
return Result.ok();
} catch (Exception e) {
e.printStackTrace();
return Result.fail("批量删除失败: " + e.getMessage());
}
}
}
@@ -16,7 +16,7 @@ spring:
time-zone: "Asia/Shanghai"
date-format: yyyy-MM-dd HH:mm:ss
profiles:
active: build
active: dev
file:
base-dir: D:/data/file
@@ -1,10 +1,10 @@
#url=jdbc:sqlserver://118.89.70.199:1433;databaseName=G3BoxOCR
#username=sa
#password=zhang520..
#driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
url=jdbc:sqlserver://127.0.0.1:1433;databaseName=G3ContainerOCR
url=jdbc:sqlserver://118.89.70.199:1433;databaseName=G3BoxOCR
username=sa
password=123456@aaa
password=zhang520..
driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
#url=jdbc:sqlserver://127.0.0.1:1433;databaseName=G3ContainerOCR
#username=sa
#password=123456@aaa
#driver=com.microsoft.sqlserver.jdbc.SQLServerDriver