feat: 大屏新增虚拟工位滚动栏与多订单轮播,附件表增加删除原因及彻底清除留痕字段
This commit is contained in:
@@ -241,19 +241,24 @@ func uploadAttachmentHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
// attachmentViewRow 附件返回视图:附带可直接预览/下载的 URL(按 id 提供,避免中文/多级路径问题)。
|
||||
type attachmentViewRow struct {
|
||||
ID int64 `json:"id"`
|
||||
BizType string `json:"bizType"`
|
||||
BizID string `json:"bizId"`
|
||||
FileType string `json:"fileType"`
|
||||
FileName string `json:"fileName"`
|
||||
FileSize int64 `json:"fileSize"`
|
||||
FileExt string `json:"fileExt"`
|
||||
MimeType string `json:"mimeType"`
|
||||
UploadedBy string `json:"uploadedBy"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
Archived bool `json:"archived"`
|
||||
Deleted bool `json:"deleted"`
|
||||
URL string `json:"url"`
|
||||
ID int64 `json:"id"`
|
||||
BizType string `json:"bizType"`
|
||||
BizID string `json:"bizId"`
|
||||
FileType string `json:"fileType"`
|
||||
FileName string `json:"fileName"`
|
||||
FileSize int64 `json:"fileSize"`
|
||||
FileExt string `json:"fileExt"`
|
||||
MimeType string `json:"mimeType"`
|
||||
UploadedBy string `json:"uploadedBy"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
Archived bool `json:"archived"`
|
||||
Deleted bool `json:"deleted"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedReason string `json:"deletedReason"`
|
||||
PurgedAt int64 `json:"purgedAt"`
|
||||
PurgedBy string `json:"purgedBy"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
func attachmentView(ctx *svc.ServiceContext, rec *ent.Attachment) *attachmentViewRow {
|
||||
@@ -261,6 +266,8 @@ func attachmentView(ctx *svc.ServiceContext, rec *ent.Attachment) *attachmentVie
|
||||
ID: int64(rec.ID), BizType: rec.BizType, BizID: rec.BizID, FileType: rec.FileType,
|
||||
FileName: rec.FileName, FileSize: rec.FileSize, FileExt: rec.FileExt, MimeType: rec.MimeType,
|
||||
UploadedBy: rec.UploadedBy, CreatedAt: rec.CreatedAt, Archived: rec.Archived, Deleted: rec.Deleted,
|
||||
DeletedAt: rec.DeletedAt, DeletedBy: rec.DeletedBy, DeletedReason: rec.DeletedReason,
|
||||
PurgedAt: rec.PurgedAt, PurgedBy: rec.PurgedBy,
|
||||
// 公开预览 URL 用磁盘 UUID 文件名(不可枚举),杜绝顺序 ID 越权遍历(安全审计 #8)
|
||||
URL: "/uploads/" + filepath.Base(rec.FilePath),
|
||||
}
|
||||
@@ -327,7 +334,8 @@ func listAllAttachmentsHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
q = q.Where(attachment.CreatedAtLTE(t.Add(24 * time.Hour).Unix()))
|
||||
}
|
||||
}
|
||||
if r.URL.Query().Get("includeDeleted") != "true" {
|
||||
includeDeleted := r.URL.Query().Get("includeDeleted") == "true"
|
||||
if !includeDeleted {
|
||||
q = q.Where(attachment.DeletedEQ(false))
|
||||
}
|
||||
total, err := q.Count(ctx0())
|
||||
@@ -335,6 +343,36 @@ func listAllAttachmentsHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
fail(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
// 视角死角提示:未勾选含已删除时,告知当前筛选下有多少已删除附件被隐藏
|
||||
hiddenDeleted := 0
|
||||
if !includeDeleted {
|
||||
hq := ctx.EntClient.Attachment.Query().Where(attachment.DeletedEQ(true))
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("fileType")); v != "" {
|
||||
hq = hq.Where(attachment.FileTypeEQ(strings.ToUpper(v)))
|
||||
}
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("bizType")); v != "" {
|
||||
hq = hq.Where(attachment.BizTypeEQ(v))
|
||||
}
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("bizId")); v != "" {
|
||||
hq = hq.Where(attachment.BizIDContainsFold(v))
|
||||
}
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("fileName")); v != "" {
|
||||
hq = hq.Where(attachment.FileNameContainsFold(v))
|
||||
}
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("startDate")); v != "" {
|
||||
if t, err := time.ParseInLocation("2006-01-02", v, time.Local); err == nil {
|
||||
hq = hq.Where(attachment.CreatedAtGTE(t.Unix()))
|
||||
}
|
||||
}
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("endDate")); v != "" {
|
||||
if t, err := time.ParseInLocation("2006-01-02", v, time.Local); err == nil {
|
||||
hq = hq.Where(attachment.CreatedAtLTE(t.Add(24 * time.Hour).Unix()))
|
||||
}
|
||||
}
|
||||
if n, e := hq.Count(ctx0()); e == nil {
|
||||
hiddenDeleted = n
|
||||
}
|
||||
}
|
||||
list, err := q.Order(ent.Desc("created_at"), ent.Desc("id")).
|
||||
Offset((page - 1) * pageSize).Limit(pageSize).All(ctx0())
|
||||
if err != nil {
|
||||
@@ -347,54 +385,7 @@ func listAllAttachmentsHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
// 磁盘状态一并返回,供页面顶部告警条展示
|
||||
ok(w, map[string]any{"total": total, "list": rows, "page": page, "pageSize": pageSize,
|
||||
"disk": diskStatus(ctx)})
|
||||
}
|
||||
}
|
||||
|
||||
// deleteAttachmentHandler 删除附件(逻辑删除:DB 标记 deleted;物理文件由「已删除附件」抽屉执行物理清理释放空间)
|
||||
// POST /api/attachments/delete body: { id }
|
||||
func deleteAttachmentHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil || req.ID <= 0 {
|
||||
fail(w, http.StatusBadRequest, "参数错误:id 必填")
|
||||
return
|
||||
}
|
||||
rec, err := ctx.EntClient.Attachment.Get(ctx0(), int(req.ID))
|
||||
if err != nil {
|
||||
fail(w, http.StatusNotFound, "附件不存在")
|
||||
return
|
||||
}
|
||||
// 删除保护(需求1):关键业务附件禁止删除,避免质量/工艺记录丢失。
|
||||
// 1) 工艺流程(PROCESS_PDF)、流程卡(PROCESS_CARD):全程禁删(工艺依据,需永久留存)。
|
||||
// 2) 检验照片/报告(INSPECTION_*):未超本地保留年数禁删(质量追溯期内不可删)。
|
||||
switch rec.FileType {
|
||||
case FileTypeProcessPDF, FileTypeProcessCard:
|
||||
fail(w, http.StatusForbidden, "工艺流程 / 流程卡为关键工艺文件,禁止删除")
|
||||
return
|
||||
case FileTypeInspectionPhoto, FileTypeInspectionPDF:
|
||||
years := ctx.Config.Attachment.LocalRetentionYears
|
||||
if years <= 0 {
|
||||
years = 1
|
||||
}
|
||||
cutYear := timeNow().Year() - years
|
||||
if time.Unix(rec.CreatedAt, 0).Year() >= cutYear {
|
||||
fail(w, http.StatusForbidden, fmt.Sprintf("检验记录在质量追溯保留期(%d 年)内,禁止删除", years))
|
||||
return
|
||||
}
|
||||
}
|
||||
if _, err := ctx.EntClient.Attachment.UpdateOneID(int(req.ID)).
|
||||
SetDeleted(true).SetDeletedAt(timeNow().Unix()).
|
||||
SetNillableDeletedBy(strPtr(r.Header.Get("X-Username"))).
|
||||
Save(ctx0()); err != nil {
|
||||
fail(w, http.StatusInternalServerError, "删除附件失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
ctx.EventLog.Write(ctx0(), "attachment.delete", r.Header.Get("X-Username"), rec.BizType, rec.BizID,
|
||||
"删除附件 "+rec.FileName, nil)
|
||||
ok(w, map[string]any{"id": req.ID})
|
||||
"hiddenDeleted": hiddenDeleted, "disk": diskStatus(ctx)})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,16 +531,25 @@ func checkDiskOnce(ctx *svc.ServiceContext) {
|
||||
}
|
||||
}
|
||||
|
||||
// purgeDeletedHandler 物理清理已逻辑删除的附件(需求2):
|
||||
// 扫描 deleted=true 的索引,物理删除对应磁盘文件释放本地空间;
|
||||
// 索引保留(deleted 标记不变)以便追溯。默认 dryRun 预检,返回将清理数量与释放字节。
|
||||
// POST /api/attachments/purge-deleted body: { dryRun }
|
||||
// purgeDeletedHandler 批量物理清理已逻辑删除的附件(数据归档页「磁盘空间回收」批量入口):
|
||||
// 扫描 deleted=true 且未清除的索引,物理删除对应磁盘文件释放本地空间;
|
||||
// 索引保留(purged_at/by 留痕)以便追溯。dryRun 预检返回将清理数量与释放字节;
|
||||
// 执行须实名留痕;保护期/禁删保护的附件跳过(计入 protected)。
|
||||
// POST /api/attachments/purge-deleted body: { dryRun, ackName, ackPhone }
|
||||
func purgeDeletedHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
DryRun bool `json:"dryRun"`
|
||||
DryRun bool `json:"dryRun"`
|
||||
AckName string `json:"ackName"`
|
||||
AckPhone string `json:"ackPhone"`
|
||||
}
|
||||
_ = parseJSON(r, &req)
|
||||
if !req.DryRun {
|
||||
if err := checkAckNamePhone(req.AckName, req.AckPhone); err != nil {
|
||||
fail(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
root := attRoot(ctx)
|
||||
recs, err := ctx.EntClient.Attachment.Query().
|
||||
Where(attachment.DeletedEQ(true)).All(ctx0())
|
||||
@@ -557,8 +557,17 @@ func purgeDeletedHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
fail(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
removed, freed, missing, failed := 0, int64(0), 0, 0
|
||||
removed, freed, missing, failed, protected := 0, int64(0), 0, 0, 0
|
||||
user := r.Header.Get("X-Username")
|
||||
for _, rec := range recs {
|
||||
if rec.PurgedAt != 0 {
|
||||
missing++ // 已清除过(文件已删),仅计数
|
||||
continue
|
||||
}
|
||||
if blocked := attachmentProtectCheck(ctx, rec.CreatedAt) + attachmentFileTypeProtect(ctx, rec); blocked != "" {
|
||||
protected++
|
||||
continue
|
||||
}
|
||||
abs, okp := safeAbsPath(root, rec.FilePath)
|
||||
if !okp {
|
||||
failed++
|
||||
@@ -567,6 +576,10 @@ func purgeDeletedHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
info, statErr := os.Stat(abs)
|
||||
if statErr != nil {
|
||||
missing++ // 文件已不存在(已清理或丢失),仅计数
|
||||
// 补标记:索引侧注明已清除,避免反复扫描
|
||||
now := timeNow().Unix()
|
||||
_, _ = ctx.EntClient.Attachment.UpdateOneID(rec.ID).
|
||||
SetNillablePurgedAt(&now).SetNillablePurgedBy(strPtr(user)).Save(ctx0())
|
||||
continue
|
||||
}
|
||||
size := info.Size()
|
||||
@@ -579,15 +592,21 @@ func purgeDeletedHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
failed++
|
||||
continue
|
||||
}
|
||||
now := timeNow().Unix()
|
||||
_, _ = ctx.EntClient.Attachment.UpdateOneID(rec.ID).
|
||||
SetNillablePurgedAt(&now).SetNillablePurgedBy(strPtr(user)).Save(ctx0())
|
||||
removed++
|
||||
freed += size
|
||||
}
|
||||
if !req.DryRun {
|
||||
ctx.EventLog.Write(ctx0(), "attachment.purge", r.Header.Get("X-Username"), "attachment", "purge",
|
||||
fmt.Sprintf("物理清理已删附件:删除%d 释放%.2fMB 缺失%d 失败%d", removed, float64(freed)/1024/1024, missing, failed),
|
||||
map[string]any{"removed": removed, "freed": freed, "missing": missing, "failed": failed})
|
||||
ctx.EventLog.Write(ctx0(), "attachment.purge", user, "attachment", "purge",
|
||||
fmt.Sprintf("批量物理清理已删附件:删除%d 释放%.2fMB 缺失%d 失败%d 保护期跳过%d(确认人:%s %s)",
|
||||
removed, float64(freed)/1024/1024, missing, failed, protected,
|
||||
strings.TrimSpace(req.AckName), strings.TrimSpace(req.AckPhone)),
|
||||
map[string]any{"removed": removed, "freed": freed, "missing": missing, "failed": failed, "protected": protected})
|
||||
}
|
||||
ok(w, map[string]any{"removed": removed, "freed": freed, "missing": missing, "failed": failed, "dryRun": req.DryRun})
|
||||
ok(w, map[string]any{"removed": removed, "freed": freed, "missing": missing, "failed": failed,
|
||||
"protected": protected, "dryRun": req.DryRun})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,507 @@
|
||||
package handler
|
||||
|
||||
// 附件生命周期(2026-10-28 重构):
|
||||
// - 附件中心转纯查阅;删除/恢复/彻底清除唯一入口 = 数据归档页「磁盘空间回收」(admin/attachment:manage)。
|
||||
// - 删除前提示清楚(本文件 deletePrecheck):保护期、禁删保护、引用校验、备份覆盖情况,全部透明列出。
|
||||
// - 两道闸:① 时间保护期(仅允许删除 N 天前数据,sys_config: archive.protect.days,默认 180);
|
||||
// ② 确认弹窗完整提示 + 实名(姓名/手机号)留痕。误删是用户行为,系统不建补救层、不承诺备份介质可读。
|
||||
// - 引用校验器:biz_type+biz_id 反查业务表;引用=0 视为孤儿(无保留价值),>0 拒删并列出引用方;
|
||||
// 未注册的业务类型按"有引用"处理(fail-safe,宁可拒删不误删)。
|
||||
// - 业务面板「移除」:上传人本人撤回误传附件(物理删除文件+记录),不受保护期约束(新传数据),
|
||||
// 但禁删保护仍然生效。
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"bj_power_wms/ent"
|
||||
"bj_power_wms/ent/attachment"
|
||||
"bj_power_wms/ent/backuprecord"
|
||||
"bj_power_wms/ent/inboundorder"
|
||||
"bj_power_wms/ent/inspectionrecord"
|
||||
"bj_power_wms/ent/material"
|
||||
"bj_power_wms/ent/outboundorder"
|
||||
"bj_power_wms/ent/semifinished"
|
||||
"bj_power_wms/internal/svc"
|
||||
)
|
||||
|
||||
// ackPhoneRe 实名留痕手机号校验。
|
||||
var ackPhoneRe = regexp.MustCompile(`^1\d{10}$`)
|
||||
|
||||
func checkAckNamePhone(name, phone string) error {
|
||||
if strings.TrimSpace(name) == "" {
|
||||
return fmt.Errorf("须填写确认人姓名(警示留痕)")
|
||||
}
|
||||
if !ackPhoneRe.MatchString(strings.TrimSpace(phone)) {
|
||||
return fmt.Errorf("须填写有效的 11 位手机号(警示留痕)")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// attachmentProtectDays 数据保护期(天)。
|
||||
func attachmentProtectDays(ctx *svc.ServiceContext) int {
|
||||
return CfgIntFromSysConfig(ctx, CfgArchiveProtectDays, 180)
|
||||
}
|
||||
|
||||
// attachmentProtectCheck 保护期校验:created_at 须早于保护期。返回非空即拦截原因。
|
||||
func attachmentProtectCheck(ctx *svc.ServiceContext, createdAt int64) string {
|
||||
days := attachmentProtectDays(ctx)
|
||||
if days <= 0 {
|
||||
return ""
|
||||
}
|
||||
cutoff := timeNow().Unix() - int64(days)*86400
|
||||
if createdAt > cutoff {
|
||||
return fmt.Sprintf("该数据在保护期内(仅允许删除 %d 天前的数据,即 %s 之前上传的)",
|
||||
days, time.Unix(cutoff, 0).Format("2006-01-02"))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// attachmentFileTypeProtect 禁删保护(关键业务附件):返回非空即拦截原因。
|
||||
func attachmentFileTypeProtect(ctx *svc.ServiceContext, rec *ent.Attachment) string {
|
||||
switch rec.FileType {
|
||||
case FileTypeProcessPDF, FileTypeProcessCard:
|
||||
return "工艺流程 / 流程卡为关键工艺文件,禁止删除"
|
||||
case FileTypeInspectionPhoto, FileTypeInspectionPDF:
|
||||
years := ctx.Config.Attachment.LocalRetentionYears
|
||||
if years <= 0 {
|
||||
years = 1
|
||||
}
|
||||
cutYear := timeNow().Year() - years
|
||||
if time.Unix(rec.CreatedAt, 0).Year() >= cutYear {
|
||||
return fmt.Sprintf("检验记录在质量追溯保留期(%d 年)内,禁止删除", years)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// attachmentRefs 引用校验器:返回(引用数, 引用方描述列表)。
|
||||
func attachmentRefs(ctx *svc.ServiceContext, bizType, bizId string) (int, []string) {
|
||||
bizId = strings.TrimSpace(bizId)
|
||||
if bizId == "" {
|
||||
return 0, nil
|
||||
}
|
||||
c := ctx.EntClient
|
||||
switch bizType {
|
||||
case "inbound":
|
||||
n, err := c.InboundOrder.Query().Where(inboundorder.InboundNoEQ(bizId)).Count(ctx0())
|
||||
return refResult(err, n, fmt.Sprintf("入库单 %s", bizId))
|
||||
case "outbound":
|
||||
n, err := c.OutboundOrder.Query().Where(outboundorder.OutboundNoEQ(bizId)).Count(ctx0())
|
||||
return refResult(err, n, fmt.Sprintf("出库单 %s", bizId))
|
||||
case "material":
|
||||
n, err := c.Material.Query().Where(material.CodeEQ(bizId)).Count(ctx0())
|
||||
return refResult(err, n, fmt.Sprintf("物料档案 %s", bizId))
|
||||
case "semi":
|
||||
n, err := c.SemiFinished.Query().Where(semifinished.SnEQ(bizId)).Count(ctx0())
|
||||
return refResult(err, n, fmt.Sprintf("半成品 %s", bizId))
|
||||
case "inspection":
|
||||
id, perr := strconv.Atoi(bizId)
|
||||
if perr != nil {
|
||||
return 1, []string{"检验记录 ID 非法,按有引用处理"}
|
||||
}
|
||||
n, err := c.InspectionRecord.Query().Where(inspectionrecord.IDEQ(id)).Count(ctx0())
|
||||
return refResult(err, n, fmt.Sprintf("检验记录 #%s", bizId))
|
||||
default:
|
||||
// fail-safe:未注册引用校验的业务类型一律视为有引用
|
||||
return 1, []string{fmt.Sprintf("业务类型 %s 未注册引用校验,按有引用处理", bizType)}
|
||||
}
|
||||
}
|
||||
|
||||
func refResult(err error, n int, label string) (int, []string) {
|
||||
if err != nil {
|
||||
return 1, []string{"引用校验查询失败:" + err.Error()}
|
||||
}
|
||||
if n > 0 {
|
||||
return n, []string{label}
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// attachmentBackupInfo 透明信息:上传时间是否落在某次成功备份的时间窗内(不承诺介质可读)。
|
||||
func attachmentBackupInfo(ctx *svc.ServiceContext, createdAt int64) string {
|
||||
recs, err := ctx.EntClient.BackupRecord.Query().
|
||||
Where(backuprecord.StatusEQ("success"),
|
||||
backuprecord.RangeStartLTE(createdAt), backuprecord.RangeEndGTE(createdAt)).
|
||||
All(ctx0())
|
||||
if err != nil {
|
||||
return "备份覆盖情况查询失败"
|
||||
}
|
||||
if len(recs) == 0 {
|
||||
return "无备份记录覆盖该文件的上传时间"
|
||||
}
|
||||
parts := make([]string, 0, len(recs))
|
||||
for _, r := range recs {
|
||||
parts = append(parts, fmt.Sprintf("#%d(%s ~ %s)", r.ID,
|
||||
time.Unix(r.RangeStart, 0).Format("2006-01-02"), time.Unix(r.RangeEnd, 0).Format("2006-01-02")))
|
||||
}
|
||||
return "该文件上传时间在备份记录覆盖范围内:" + strings.Join(parts, "、")
|
||||
}
|
||||
|
||||
// deletePrecheckVO 删除前提示清楚所需的全部信息。
|
||||
type deletePrecheckVO struct {
|
||||
ID int64 `json:"id"`
|
||||
FileName string `json:"fileName"`
|
||||
FileSize int64 `json:"fileSize"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
BizType string `json:"bizType"`
|
||||
BizID string `json:"bizId"`
|
||||
ProtectDays int `json:"protectDays"`
|
||||
ProtectBlocked string `json:"protectBlocked"` // 非空=保护期/禁删保护拦截原因
|
||||
RefCount int `json:"refCount"`
|
||||
Refs []string `json:"refs"`
|
||||
BackupInfo string `json:"backupInfo"`
|
||||
}
|
||||
|
||||
// deletePrecheckHandler POST /api/attachments/delete-precheck {id}
|
||||
func deletePrecheckHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil || req.ID <= 0 {
|
||||
fail(w, http.StatusBadRequest, "参数错误:id 必填")
|
||||
return
|
||||
}
|
||||
rec, err := ctx.EntClient.Attachment.Get(ctx0(), int(req.ID))
|
||||
if err != nil {
|
||||
fail(w, http.StatusNotFound, "附件不存在")
|
||||
return
|
||||
}
|
||||
refCount, refs := attachmentRefs(ctx, rec.BizType, rec.BizID)
|
||||
ok(w, deletePrecheckVO{
|
||||
ID: int64(rec.ID), FileName: rec.FileName, FileSize: rec.FileSize,
|
||||
CreatedAt: rec.CreatedAt, BizType: rec.BizType, BizID: rec.BizID,
|
||||
ProtectDays: attachmentProtectDays(ctx),
|
||||
ProtectBlocked: attachmentProtectCheck(ctx, rec.CreatedAt) + attachmentFileTypeProtect(ctx, rec),
|
||||
RefCount: refCount, Refs: refs,
|
||||
BackupInfo: attachmentBackupInfo(ctx, rec.CreatedAt),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// deleteAttachmentHandler 重构:逻辑删除(数据归档页入口)。
|
||||
// POST /api/attachments/delete body: { id, reason, ackName, ackPhone }
|
||||
// 校验:禁删保护 + 保护期 + 引用校验(有引用拒删)+ 实名留痕。
|
||||
func deleteAttachmentHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
ID int64 `json:"id"`
|
||||
Reason string `json:"reason"`
|
||||
AckName string `json:"ackName"`
|
||||
AckPhone string `json:"ackPhone"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil || req.ID <= 0 {
|
||||
fail(w, http.StatusBadRequest, "参数错误:id 必填")
|
||||
return
|
||||
}
|
||||
rec, err := ctx.EntClient.Attachment.Get(ctx0(), int(req.ID))
|
||||
if err != nil {
|
||||
fail(w, http.StatusNotFound, "附件不存在")
|
||||
return
|
||||
}
|
||||
if rec.Deleted {
|
||||
fail(w, http.StatusBadRequest, "该附件已是删除状态")
|
||||
return
|
||||
}
|
||||
if blocked := attachmentProtectCheck(ctx, rec.CreatedAt) + attachmentFileTypeProtect(ctx, rec); blocked != "" {
|
||||
fail(w, http.StatusForbidden, blocked)
|
||||
return
|
||||
}
|
||||
refCount, refs := attachmentRefs(ctx, rec.BizType, rec.BizID)
|
||||
if refCount > 0 {
|
||||
fail(w, http.StatusForbidden, "该附件仍被业务数据引用,禁止删除:"+strings.Join(refs, "、"))
|
||||
return
|
||||
}
|
||||
if err := checkAckNamePhone(req.AckName, req.AckPhone); err != nil {
|
||||
fail(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
if _, err := ctx.EntClient.Attachment.UpdateOneID(int(req.ID)).
|
||||
SetDeleted(true).SetDeletedAt(timeNow().Unix()).
|
||||
SetNillableDeletedBy(strPtr(r.Header.Get("X-Username"))).
|
||||
SetNillableDeletedReason(strPtr(strings.TrimSpace(req.Reason))).
|
||||
Save(ctx0()); err != nil {
|
||||
fail(w, http.StatusInternalServerError, "删除附件失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
ctx.EventLog.Write(ctx0(), "attachment.delete", r.Header.Get("X-Username"), rec.BizType, rec.BizID,
|
||||
fmt.Sprintf("删除附件 %s(%.2f MB;确认人:%s %s;说明:%s)",
|
||||
rec.FileName, float64(rec.FileSize)/1024/1024,
|
||||
strings.TrimSpace(req.AckName), strings.TrimSpace(req.AckPhone),
|
||||
ornull(req.Reason)), nil)
|
||||
ok(w, map[string]any{"id": req.ID})
|
||||
}
|
||||
}
|
||||
|
||||
// restoreAttachmentHandler 恢复逻辑删除(未彻底清除前可反悔)。
|
||||
// POST /api/attachments/restore body: { id }
|
||||
func restoreAttachmentHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil || req.ID <= 0 {
|
||||
fail(w, http.StatusBadRequest, "参数错误:id 必填")
|
||||
return
|
||||
}
|
||||
rec, err := ctx.EntClient.Attachment.Get(ctx0(), int(req.ID))
|
||||
if err != nil {
|
||||
fail(w, http.StatusNotFound, "附件不存在")
|
||||
return
|
||||
}
|
||||
if !rec.Deleted {
|
||||
fail(w, http.StatusBadRequest, "该附件不是删除状态,无需恢复")
|
||||
return
|
||||
}
|
||||
if rec.PurgedAt != 0 {
|
||||
fail(w, http.StatusBadRequest, "该附件已彻底清除(磁盘文件已删除),无法恢复;如需找回请使用对应备份包")
|
||||
return
|
||||
}
|
||||
if _, err := ctx.EntClient.Attachment.UpdateOneID(int(req.ID)).SetDeleted(false).Save(ctx0()); err != nil {
|
||||
fail(w, http.StatusInternalServerError, "恢复附件失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
ctx.EventLog.Write(ctx0(), "attachment.restore", r.Header.Get("X-Username"), rec.BizType, rec.BizID,
|
||||
"恢复附件 "+rec.FileName, nil)
|
||||
ok(w, map[string]any{"id": req.ID})
|
||||
}
|
||||
}
|
||||
|
||||
// purgeAttachmentHandler 彻底清除单个已删除附件:物理删除磁盘文件,索引保留(purged_at/by 留痕)。
|
||||
// POST /api/attachments/purge body: { id, ackName, ackPhone }
|
||||
func purgeAttachmentHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
ID int64 `json:"id"`
|
||||
AckName string `json:"ackName"`
|
||||
AckPhone string `json:"ackPhone"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil || req.ID <= 0 {
|
||||
fail(w, http.StatusBadRequest, "参数错误:id 必填")
|
||||
return
|
||||
}
|
||||
rec, err := ctx.EntClient.Attachment.Get(ctx0(), int(req.ID))
|
||||
if err != nil {
|
||||
fail(w, http.StatusNotFound, "附件不存在")
|
||||
return
|
||||
}
|
||||
if !rec.Deleted {
|
||||
fail(w, http.StatusBadRequest, "请先删除(逻辑删除)后再彻底清除")
|
||||
return
|
||||
}
|
||||
if rec.PurgedAt != 0 {
|
||||
fail(w, http.StatusBadRequest, "该附件已彻底清除")
|
||||
return
|
||||
}
|
||||
if blocked := attachmentProtectCheck(ctx, rec.CreatedAt) + attachmentFileTypeProtect(ctx, rec); blocked != "" {
|
||||
fail(w, http.StatusForbidden, blocked)
|
||||
return
|
||||
}
|
||||
if err := checkAckNamePhone(req.AckName, req.AckPhone); err != nil {
|
||||
fail(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
root := attRoot(ctx)
|
||||
removed := false
|
||||
if abs, okp := safeAbsPath(root, rec.FilePath); okp {
|
||||
if rerr := osRemoveIfExist(abs); rerr == "" {
|
||||
removed = true
|
||||
}
|
||||
}
|
||||
now := timeNow().Unix()
|
||||
if _, err := ctx.EntClient.Attachment.UpdateOneID(int(req.ID)).
|
||||
SetNillablePurgedAt(&now).
|
||||
SetNillablePurgedBy(strPtr(r.Header.Get("X-Username"))).
|
||||
Save(ctx0()); err != nil {
|
||||
fail(w, http.StatusInternalServerError, "清除标记失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
ctx.EventLog.Write(ctx0(), "attachment.purge", r.Header.Get("X-Username"), rec.BizType, rec.BizID,
|
||||
fmt.Sprintf("彻底清除附件 %s(%.2f MB,文件已删除%s;确认人:%s %s)",
|
||||
rec.FileName, float64(rec.FileSize)/1024/1024,
|
||||
map[bool]string{true: "", false: ",文件本已缺失"}[removed],
|
||||
strings.TrimSpace(req.AckName), strings.TrimSpace(req.AckPhone)), nil)
|
||||
ok(w, map[string]any{"id": req.ID, "removed": removed})
|
||||
}
|
||||
}
|
||||
|
||||
// removeAttachmentHandler 业务面板「移除」:上传人本人撤回误传附件(物理删除文件+记录)。
|
||||
// POST /api/attachments/remove body: { id, reason }
|
||||
// 仅上传人本人可操作;禁删保护生效;不受保护期约束(针对刚上传的数据)。
|
||||
func removeAttachmentHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
ID int64 `json:"id"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil || req.ID <= 0 {
|
||||
fail(w, http.StatusBadRequest, "参数错误:id 必填")
|
||||
return
|
||||
}
|
||||
rec, err := ctx.EntClient.Attachment.Get(ctx0(), int(req.ID))
|
||||
if err != nil {
|
||||
fail(w, http.StatusNotFound, "附件不存在")
|
||||
return
|
||||
}
|
||||
if rec.Deleted {
|
||||
fail(w, http.StatusBadRequest, "该附件已是删除状态")
|
||||
return
|
||||
}
|
||||
user := r.Header.Get("X-Username")
|
||||
if rec.UploadedBy != user {
|
||||
fail(w, http.StatusForbidden, "仅上传人本人可移除附件;其他情况请管理员在「数据归档」页处理")
|
||||
return
|
||||
}
|
||||
if blocked := attachmentFileTypeProtect(ctx, rec); blocked != "" {
|
||||
fail(w, http.StatusForbidden, blocked)
|
||||
return
|
||||
}
|
||||
root := attRoot(ctx)
|
||||
if abs, okp := safeAbsPath(root, rec.FilePath); okp {
|
||||
_ = osRemoveIfExist(abs)
|
||||
}
|
||||
if _, derr := ctx.EntClient.Attachment.Delete().Where(attachment.ID(rec.ID)).Exec(ctx0()); derr != nil {
|
||||
fail(w, http.StatusInternalServerError, "移除附件失败: "+derr.Error())
|
||||
return
|
||||
}
|
||||
ctx.EventLog.Write(ctx0(), "attachment.remove", user, rec.BizType, rec.BizID,
|
||||
fmt.Sprintf("移除附件 %s(上传人本人撤回,物理删除;说明:%s)", rec.FileName, ornull(req.Reason)), nil)
|
||||
ok(w, map[string]any{"id": req.ID})
|
||||
}
|
||||
}
|
||||
|
||||
// orphanScanHandler 扫描无引用附件(孤儿):附件正常状态但业务单据已不存在。
|
||||
// GET /api/attachments/orphans → { total, totalSize, list(截断500) }
|
||||
func orphanScanHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
recs, err := ctx.EntClient.Attachment.Query().
|
||||
Where(attachment.DeletedEQ(false)).Order(ent.Desc("created_at")).All(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
type orphanVO struct {
|
||||
ID int64 `json:"id"`
|
||||
FileName string `json:"fileName"`
|
||||
FileSize int64 `json:"fileSize"`
|
||||
BizType string `json:"bizType"`
|
||||
BizID string `json:"bizId"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
var total int64
|
||||
list := make([]orphanVO, 0, 16)
|
||||
const capN = 500
|
||||
for _, rec := range recs {
|
||||
// 已彻底清除的(文件没了)不再列为孤儿
|
||||
if rec.PurgedAt != 0 {
|
||||
continue
|
||||
}
|
||||
n, refs := attachmentRefs(ctx, rec.BizType, rec.BizID)
|
||||
if n > 0 {
|
||||
continue
|
||||
}
|
||||
total += rec.FileSize
|
||||
if len(list) < capN {
|
||||
reason := "业务单据不存在(可能未保存即取消,或单据已删除)"
|
||||
if len(refs) > 0 {
|
||||
reason = refs[0]
|
||||
}
|
||||
list = append(list, orphanVO{
|
||||
ID: int64(rec.ID), FileName: rec.FileName, FileSize: rec.FileSize,
|
||||
BizType: rec.BizType, BizID: rec.BizID, CreatedAt: rec.CreatedAt, Reason: reason,
|
||||
})
|
||||
}
|
||||
}
|
||||
ok(w, map[string]any{"count": len(list), "truncated": len(recs) > capN, "totalSize": total, "list": list})
|
||||
}
|
||||
}
|
||||
|
||||
// orphanPurgeHandler 批量清除孤儿附件:物理删除文件 + 删除索引记录(无引用数据无保留价值)。
|
||||
// POST /api/attachments/orphans/purge body: { ids: [], ackName, ackPhone }(ids 空=全部扫描到的)
|
||||
func orphanPurgeHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
IDs []int64 `json:"ids"`
|
||||
AckName string `json:"ackName"`
|
||||
AckPhone string `json:"ackPhone"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil {
|
||||
fail(w, http.StatusBadRequest, "请求体解析失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
if err := checkAckNamePhone(req.AckName, req.AckPhone); err != nil {
|
||||
fail(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
if len(req.IDs) == 0 {
|
||||
// 扫描全部孤儿
|
||||
recs, err := ctx.EntClient.Attachment.Query().Where(attachment.DeletedEQ(false)).All(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
for _, rec := range recs {
|
||||
if rec.PurgedAt != 0 {
|
||||
continue
|
||||
}
|
||||
if n, _ := attachmentRefs(ctx, rec.BizType, rec.BizID); n == 0 {
|
||||
req.IDs = append(req.IDs, int64(rec.ID))
|
||||
}
|
||||
}
|
||||
}
|
||||
root := attRoot(ctx)
|
||||
removed, failed, freed := 0, 0, int64(0)
|
||||
for _, id := range req.IDs {
|
||||
rec, err := ctx.EntClient.Attachment.Get(ctx0(), int(id))
|
||||
if err != nil {
|
||||
failed++
|
||||
continue
|
||||
}
|
||||
if rec.Deleted || rec.PurgedAt != 0 {
|
||||
continue
|
||||
}
|
||||
if n, _ := attachmentRefs(ctx, rec.BizType, rec.BizID); n > 0 {
|
||||
failed++ // 执行时引用出现(如单据刚保存),跳过
|
||||
continue
|
||||
}
|
||||
if abs, okp := safeAbsPath(root, rec.FilePath); okp {
|
||||
if info, serr := os.Stat(abs); serr == nil {
|
||||
freed += info.Size()
|
||||
}
|
||||
_ = osRemoveIfExist(abs)
|
||||
}
|
||||
if _, derr := ctx.EntClient.Attachment.Delete().Where(attachment.ID(rec.ID)).Exec(ctx0()); derr != nil {
|
||||
failed++
|
||||
continue
|
||||
}
|
||||
removed++
|
||||
}
|
||||
ctx.EventLog.Write(ctx0(), "attachment.orphan.purge", r.Header.Get("X-Username"), "attachment", "orphan",
|
||||
fmt.Sprintf("清除无引用附件:删除%d 释放%.2fMB 失败%d(确认人:%s %s)",
|
||||
removed, float64(freed)/1024/1024, failed,
|
||||
strings.TrimSpace(req.AckName), strings.TrimSpace(req.AckPhone)), nil)
|
||||
ok(w, map[string]any{"removed": removed, "failed": failed, "freed": freed})
|
||||
}
|
||||
}
|
||||
|
||||
// osRemoveIfExist 物理删除文件(不存在视为成功)。返回空串=成功。
|
||||
func osRemoveIfExist(abs string) string {
|
||||
if err := os.Remove(abs); err != nil && !os.IsNotExist(err) {
|
||||
return err.Error()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func ornull(s string) string {
|
||||
if strings.TrimSpace(s) == "" {
|
||||
return "无"
|
||||
}
|
||||
return strings.TrimSpace(s)
|
||||
}
|
||||
@@ -1,13 +1,28 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"bj_power_wms/internal/backup"
|
||||
"bj_power_wms/internal/svc"
|
||||
)
|
||||
|
||||
// checkCleanupProtect 数据保护期校验:仅允许清理 N 天前的数据(默认 180 天,sys_config: archive.protect.days)。
|
||||
func checkCleanupProtect(ctx *svc.ServiceContext, end int64) error {
|
||||
days := CfgIntFromSysConfig(ctx, CfgArchiveProtectDays, 180)
|
||||
if days <= 0 {
|
||||
return nil
|
||||
}
|
||||
cutoff := time.Now().Unix() - int64(days)*86400
|
||||
if end > cutoff {
|
||||
return fmt.Errorf("保护期内的数据禁止删除(保护期 %d 天):清理窗口须结束于 %s 及之前", days, time.Unix(cutoff, 0).Format("2006-01-02"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// backupItemsHandler GET /api/backup/items 可选数据项(质量 4 表不出现)
|
||||
func backupItemsHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -80,19 +95,31 @@ func cleanupCheckHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
func cleanupStartHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Start int64 `json:"start"`
|
||||
End int64 `json:"end"`
|
||||
Items []string `json:"items"`
|
||||
Start int64 `json:"start"`
|
||||
End int64 `json:"end"`
|
||||
Items []string `json:"items"`
|
||||
Mode string `json:"mode"`
|
||||
Force bool `json:"force"`
|
||||
AckName string `json:"ackName"`
|
||||
AckPhone string `json:"ackPhone"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil {
|
||||
fail(w, http.StatusBadRequest, "请求体解析失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
if err := checkCleanupProtect(ctx, req.End); err != nil {
|
||||
fail(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
jobID, err := ctx.Backup.StartCleanup(backup.CleanupRequest{
|
||||
Start: req.Start,
|
||||
End: req.End,
|
||||
Items: req.Items,
|
||||
Operator: r.Header.Get("X-Username"),
|
||||
Mode: req.Mode,
|
||||
Force: req.Force,
|
||||
AckName: req.AckName,
|
||||
AckPhone: req.AckPhone,
|
||||
})
|
||||
if err != nil {
|
||||
fail(w, http.StatusBadRequest, err.Error())
|
||||
@@ -168,6 +195,10 @@ func cleanupPreviewHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
fail(w, http.StatusBadRequest, "时间窗不合法")
|
||||
return
|
||||
}
|
||||
if err := checkCleanupProtect(ctx, req.End); err != nil {
|
||||
fail(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
if len(req.Items) == 0 {
|
||||
fail(w, http.StatusBadRequest, "请至少选择一个数据项")
|
||||
return
|
||||
|
||||
@@ -213,15 +213,25 @@ func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
|
||||
)
|
||||
|
||||
// 附件(下沉到各业务页内嵌使用:入库/物料/检验/半成品/出库)
|
||||
// 2026-10-28 生命周期重构:附件中心转纯查阅;删除/恢复/彻底清除唯一入口=数据归档页(attachment:manage);
|
||||
// 业务面板仅保留上传人本人「移除」误传附件(/remove,handler 内校验本人)。
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{Method: http.MethodPost, Path: "/api/attachments/upload", Handler: uploadAttachmentHandler(ctx)},
|
||||
{Method: http.MethodGet, Path: "/api/attachments", Handler: listAttachmentsHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/attachments/delete", Handler: deleteAttachmentHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/attachments/remove", Handler: removeAttachmentHandler(ctx)},
|
||||
// 删除前提示清楚:预检只读(保护期/引用/备份覆盖情况),登录即可查
|
||||
{Method: http.MethodPost, Path: "/api/attachments/delete-precheck", Handler: deletePrecheckHandler(ctx)},
|
||||
// 以下为数据归档页清理工作台(attachment:manage)
|
||||
{Method: http.MethodPost, Path: "/api/attachments/delete", Handler: requirePerm(ctx, "attachment:manage", deleteAttachmentHandler(ctx))},
|
||||
{Method: http.MethodPost, Path: "/api/attachments/restore", Handler: requirePerm(ctx, "attachment:manage", restoreAttachmentHandler(ctx))},
|
||||
{Method: http.MethodPost, Path: "/api/attachments/purge", Handler: requirePerm(ctx, "attachment:manage", purgeAttachmentHandler(ctx))},
|
||||
{Method: http.MethodGet, Path: "/api/attachments/orphans", Handler: requirePerm(ctx, "attachment:manage", orphanScanHandler(ctx))},
|
||||
{Method: http.MethodPost, Path: "/api/attachments/orphans/purge", Handler: requirePerm(ctx, "attachment:manage", orphanPurgeHandler(ctx))},
|
||||
// 附件中心(系统管理 → 附件中心)
|
||||
{Method: http.MethodGet, Path: "/api/attachments/all", Handler: requirePerm(ctx, "attachment:view", listAllAttachmentsHandler(ctx))},
|
||||
{Method: http.MethodGet, Path: "/api/attachments/disk-status", Handler: requirePerm(ctx, "attachment:view", diskStatusHandler(ctx))},
|
||||
// 空间清理(需求2):物理清理已删附件归 attachment:manage
|
||||
// 空间清理:批量物理清理已删附件归 attachment:manage
|
||||
{Method: http.MethodPost, Path: "/api/attachments/purge-deleted", Handler: requirePerm(ctx, "attachment:manage", purgeDeletedHandler(ctx))},
|
||||
},
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
const (
|
||||
CfgArchiveRemindDays = "archive.remind.days" // 数据归档提醒周期(天,0=关闭)
|
||||
CfgArchiveBackupPath = "archive.backup.path" // 备份默认目标路径(记住上次成功路径)
|
||||
CfgArchiveProtectDays = "archive.protect.days" // 数据保护期(天):仅允许删除该天数之前的数据,默认 180
|
||||
CfgLocationRule = "location.recommend.rule" // 库位推荐规则:last=上次位置优先 / same_shelf=同货架优先
|
||||
CfgInboundOrderPrefix = "inbound.order.prefix" // 入库单默认前缀/流水规则
|
||||
CfgAttachmentMaxSize = "attachment.max.size.hint" // 附件单文件大小上限提示(MB)
|
||||
@@ -27,6 +28,7 @@ const (
|
||||
var wmsSettingsDefaults = map[string]string{
|
||||
CfgArchiveRemindDays: "7",
|
||||
CfgArchiveBackupPath: "",
|
||||
CfgArchiveProtectDays: "180",
|
||||
CfgLocationRule: "last",
|
||||
CfgInboundOrderPrefix: "",
|
||||
CfgAttachmentMaxSize: "50",
|
||||
|
||||
Reference in New Issue
Block a user