chore: 批量完成项目多模块迭代优化
1. 废弃半成品库存表并统一库存主表 2. 修复列表排序与搜索大小写不敏感问题 3. 新增用户最近登录时间、工单BOM名称字段 4. 完善角色管理、工位选择器功能 5. 增加拧紧数据补录、成品自动回流WMS能力 6. 统一导出时间范围校验规则 7. 丰富物料/备料单筛选条件 8. 调整菜单与权限命名适配产品型号业务
This commit is contained in:
@@ -2,6 +2,7 @@ package handler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -17,6 +18,38 @@ import (
|
||||
"github.com/xuri/excelize/v2"
|
||||
)
|
||||
|
||||
// normalizeExportRange 导出时间范围硬规则(2026-09-08 全项目统一):
|
||||
// ① 起止都空 → 默认近 3 个月;② 只传一个 → 报错;③ 间隔 > 1 年 → 报错;④ 结束早于起始 → 报错。
|
||||
// 返回归一化后的 YYYY-MM-DD 字符串,调用方按原有逻辑解析过滤。
|
||||
func normalizeExportRange(startDate, endDate string) (string, string, error) {
|
||||
if startDate == "" && endDate == "" {
|
||||
now := time.Now()
|
||||
return now.AddDate(0, -3, 0).Format("2006-01-02"), now.Format("2006-01-02"), nil
|
||||
}
|
||||
if startDate == "" || endDate == "" {
|
||||
return "", "", errors.New("导出必须同时提供起始时间与结束时间")
|
||||
}
|
||||
st, err1 := time.ParseInLocation("2006-01-02", startDate, time.Local)
|
||||
et, err2 := time.ParseInLocation("2006-01-02", endDate, time.Local)
|
||||
if err1 != nil || err2 != nil {
|
||||
return "", "", errors.New("时间格式应为 YYYY-MM-DD")
|
||||
}
|
||||
if et.Before(st) {
|
||||
return "", "", errors.New("结束时间不能早于起始时间")
|
||||
}
|
||||
if et.Sub(st) > 366*24*time.Hour {
|
||||
return "", "", errors.New("导出时间间隔不能超过 1 年")
|
||||
}
|
||||
return startDate, endDate, nil
|
||||
}
|
||||
|
||||
// exportRangeUnix 把 YYYY-MM-DD 区间转为 unix 秒闭区间 [start, end+1天)
|
||||
func exportRangeUnix(startDate, endDate string) (int64, int64) {
|
||||
st, _ := time.ParseInLocation("2006-01-02", startDate, time.Local)
|
||||
et, _ := time.ParseInLocation("2006-01-02", endDate, time.Local)
|
||||
return st.Unix(), et.Add(24*time.Hour).Unix() - 1
|
||||
}
|
||||
|
||||
// xlsxColumn 导出列定义:列名 + 取值函数(返回字符串)
|
||||
type xlsxColumn struct {
|
||||
Title string
|
||||
|
||||
Reference in New Issue
Block a user