feat(mes): 添加定时同步可生产数量到WMS及BOM项相关标准字段

- 在main.go中添加定时任务每10分钟同步可生产数量到WMS系统
- 为BomItem实体添加relatedStandard字段及相关CRUD方法
- 为InspectionRecord实体添加reportNo、materialCode、materialName等字段
- 更新ent schema确保新字段的验证和默认值设置
- 添加必要的数据库迁移和字段映射逻辑
This commit is contained in:
SunYF
2026-09-17 12:49:07 +08:00
parent b4b274301d
commit 1cc93795ce
191 changed files with 24504 additions and 1250 deletions
+12 -13
View File
@@ -217,21 +217,20 @@ func PerformanceExportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
f := excelize.NewFile()
type view struct {
name string
key string
name string
key string
headers []string
cols func(m map[string]any) []any
cols func(r *logic.WorkloadRow) []any
}
rowOf := func(v any) map[string]any { m, _ := v.(map[string]any); return m }
views := []view{
{"按人", "byOperator", []string{"操作人", "完成数", "合格", "不合格"}, func(m map[string]any) []any {
return []any{m["operator"], m["doneCount"], m["okCount"], m["ngCount"]}
{"按人", "byOperator", []string{"操作人", "完成数", "合格", "不合格", "累计作业时长(秒)", "平均作业时长(秒)", "效率(件/小时)"}, func(r *logic.WorkloadRow) []any {
return []any{r.Operator, r.DoneCount, r.OkCount, r.NgCount, r.TotalDurationSec, r.AvgDurationSec, r.Efficiency}
}},
{"按工位", "byStation", []string{"工位", "完成数", "合格", "不合格"}, func(m map[string]any) []any {
return []any{m["stationNo"], m["doneCount"], m["okCount"], m["ngCount"]}
{"按工位", "byStation", []string{"工位", "完成数", "合格", "不合格", "累计作业时长(秒)", "平均作业时长(秒)", "效率(件/小时)"}, func(r *logic.WorkloadRow) []any {
return []any{r.StationNo, r.DoneCount, r.OkCount, r.NgCount, r.TotalDurationSec, r.AvgDurationSec, r.Efficiency}
}},
{"明细", "detail", []string{"操作人", "工位", "日期", "工序", "工序名", "完成数", "合格", "不合格"}, func(m map[string]any) []any {
return []any{m["operator"], m["stationNo"], m["date"], m["processCode"], m["processName"], m["doneCount"], m["okCount"], m["ngCount"]}
{"明细", "detail", []string{"操作人", "工位", "日期", "工序", "工序名", "完成数", "合格", "不合格", "累计作业时长(秒)", "平均作业时长(秒)", "效率(件/小时)"}, func(r *logic.WorkloadRow) []any {
return []any{r.Operator, r.StationNo, r.Date, r.ProcessCode, r.ProcessName, r.DoneCount, r.OkCount, r.NgCount, r.TotalDurationSec, r.AvgDurationSec, r.Efficiency}
}},
}
for i, vw := range views {
@@ -246,12 +245,12 @@ func PerformanceExportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
_ = f.SetCellValue(sheet, cell, h)
}
vm, _ := data[vw.key].(map[string]any)
list, _ := vm["list"].([]any)
list, _ := vm["list"].([]*logic.WorkloadRow)
for rIdx, it := range list {
m := rowOf(it)
vals := vw.cols(it)
for c := range vw.headers {
cell, _ := excelize.CoordinatesToCellName(c+1, rIdx+2)
_ = f.SetCellValue(sheet, cell, vw.cols(m)[c])
_ = f.SetCellValue(sheet, cell, vals[c])
}
}
}