refactor: 重构工艺工序相关命名与数据模型
1. 全局替换"工序"为"工艺"统一术语,包括页面文案、枚举、注释
2. 重构工单与工件工艺数据模型:
- 新增工艺组合表flow_material作为备料/齐套唯一源头
- 新增工位状态表station_state支持自主停单/恢复接单
- 移除station_process派工表,改用工单工艺组合作为路线唯一源头
- 替换processCode为flowId作为工艺关联标识
- 重构工件当前进度字段为currentStationNo
3. 删除冗余的静态备份资源文件
4. 调整物料选择组件默认启用仅显示激活物料
5. 优化工单创建/编辑逻辑,新增工艺组合校验与保存
This commit is contained in:
@@ -80,19 +80,19 @@ type cardTorque struct {
|
||||
}
|
||||
|
||||
type cardTmpl struct {
|
||||
Sn string
|
||||
OrderNo string
|
||||
Product string
|
||||
Quantity int
|
||||
CreatedAt string
|
||||
Processes []cardProcess
|
||||
Materials []string
|
||||
Operator string
|
||||
Inspector string
|
||||
DoneTime string
|
||||
Result string
|
||||
NeedTorque bool
|
||||
TorqueRows []cardTorque
|
||||
Sn string
|
||||
OrderNo string
|
||||
Product string
|
||||
Quantity int
|
||||
CreatedAt string
|
||||
Processes []cardProcess
|
||||
Materials []string
|
||||
Operator string
|
||||
Inspector string
|
||||
DoneTime string
|
||||
Result string
|
||||
NeedTorque bool
|
||||
TorqueRows []cardTorque
|
||||
}
|
||||
|
||||
// buildCard 汇总流程卡所需全部数据(ent 实体直查),并计算缺失项。
|
||||
@@ -132,23 +132,27 @@ func buildCard(ctx context.Context, svcCtx *svc.ServiceContext, sn string) (*car
|
||||
missing = append(missing, "产品数量")
|
||||
}
|
||||
|
||||
// 工序时间线(操作人 + 完成时间)
|
||||
// 工艺时间线(操作人 + 完成时间)
|
||||
procs, _ := client.WorkpieceProcess.Query().
|
||||
Where(workpieceprocess.Sn(sn)).Order(workpieceprocess.ByProcessCode()).All(ctx)
|
||||
Where(workpieceprocess.Sn(sn)).Order(ent.Asc(workpieceprocess.FieldFlowId), ent.Asc(workpieceprocess.FieldID)).All(ctx)
|
||||
for _, p := range procs {
|
||||
doneAt := ""
|
||||
if p.EndedAt != nil {
|
||||
doneAt = p.EndedAt.Format("2006-01-02 15:04")
|
||||
}
|
||||
flowLabel := p.ProcessName
|
||||
if flowLabel == "" {
|
||||
flowLabel = "工艺" + itoaCard(p.FlowId)
|
||||
}
|
||||
if p.Operator == "" {
|
||||
missing = append(missing, fmt.Sprintf("工序%s报工记录(缺操作人)", itoaCard(p.ProcessCode)))
|
||||
missing = append(missing, fmt.Sprintf("工艺「%s」报工记录(缺操作人)", flowLabel))
|
||||
}
|
||||
if p.EndedAt == nil {
|
||||
missing = append(missing, fmt.Sprintf("工序%s报工记录(缺完成时间)", itoaCard(p.ProcessCode)))
|
||||
missing = append(missing, fmt.Sprintf("工艺「%s」报工记录(缺完成时间)", flowLabel))
|
||||
}
|
||||
cp := cardProcess{
|
||||
ID: p.ID,
|
||||
Code: fmt.Sprintf("%d", p.ProcessCode),
|
||||
Code: p.StationNo,
|
||||
Name: p.ProcessName,
|
||||
Station: p.StationNo,
|
||||
Operator: p.Operator,
|
||||
@@ -162,7 +166,7 @@ func buildCard(ctx context.Context, svcCtx *svc.ServiceContext, sn string) (*car
|
||||
t.Processes = append(t.Processes, cp)
|
||||
}
|
||||
if len(procs) == 0 {
|
||||
missing = append(missing, "工序报工记录")
|
||||
missing = append(missing, "报工记录")
|
||||
}
|
||||
|
||||
// 步骤考核数据按工序实绩 ID 归组,回填到对应工序行的"采集参数"
|
||||
@@ -206,15 +210,22 @@ func buildCard(ctx context.Context, svcCtx *svc.ServiceContext, sn string) (*car
|
||||
return t, missing, nil
|
||||
}
|
||||
|
||||
// hasTorqueStep 判断该工件加工路径上是否存在"拧紧采集"步骤(经 工位→流程→步骤 链)
|
||||
// 路径由今日工位派工(station_process)派生
|
||||
// hasTorqueStep 判断该工件加工路径上是否存在"拧紧采集"步骤(经 工单工艺组合→工位→流程→步骤 链)
|
||||
// 路线 = 工单工艺组合(唯一路线源头)
|
||||
func hasTorqueStep(ctx context.Context, client *ent.Client, sn string, wp *ent.Workpiece) bool {
|
||||
route, err := logic.RouteStations(ctx, client, logic.TodayStr(), "")
|
||||
if err != nil || len(route) == 0 {
|
||||
if wp.WorkOrderId <= 0 {
|
||||
return false
|
||||
}
|
||||
wo, err := client.WorkOrder.Get(ctx, wp.WorkOrderId)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
items, _ := logic.RouteStationsFromWO(ctx, client, wo)
|
||||
if len(items) == 0 {
|
||||
return false
|
||||
}
|
||||
stations, err := client.Station.Query().
|
||||
Where(station.StationNoIn(route...), station.FlowIdGT(0)).All(ctx)
|
||||
Where(station.StationNoIn(logic.RouteStationsOfWO(items)...), station.FlowIdGT(0)).All(ctx)
|
||||
if err != nil || len(stations) == 0 {
|
||||
return false
|
||||
}
|
||||
@@ -269,13 +280,13 @@ func renderProcessCard(t *cardTmpl) (string, error) {
|
||||
<span>判定:<b>{{if eq .Result "NG"}}<span class="ng">NG</span>{{else}}{{.Result}}{{end}}</b></span>
|
||||
</div>
|
||||
{{if .Processes}}
|
||||
<h2>工序流转记录</h2>
|
||||
<h2>工艺流转记录</h2>
|
||||
<table>
|
||||
<thead><tr><th>工序</th><th>工序名称</th><th>工位</th><th>操作人</th><th>完成时间</th><th>采集参数</th><th>结果</th></tr></thead>
|
||||
<thead><tr><th>工位号</th><th>工艺名称</th><th>工位</th><th>操作人</th><th>完成时间</th><th>采集参数</th><th>结果</th></tr></thead>
|
||||
<tbody>
|
||||
{{range .Processes}}
|
||||
<tr>
|
||||
<td>工序{{.Code}}</td><td>{{.Name}}</td><td>{{.Station}}</td><td>{{.Operator}}</td><td>{{.DoneTime}}</td>
|
||||
<td>{{.Code}}</td><td>{{.Name}}</td><td>{{.Station}}</td><td>{{.Operator}}</td><td>{{.DoneTime}}</td>
|
||||
<td>{{if .Steps}}{{range .Steps}}{{.Name}}={{.Value}}({{if .OK}}<span class="ok">OK</span>{{else}}<span class="ng">NG</span>{{end}}) {{end}}{{else}}-{{end}}</td>
|
||||
<td>{{if eq .Result "NG"}}<span class="ng">NG</span>{{else}}OK{{end}}</td>
|
||||
</tr>
|
||||
@@ -283,7 +294,7 @@ func renderProcessCard(t *cardTmpl) (string, error) {
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<p style="color:#b45309;">暂无工序报工记录。</p>
|
||||
<p style="color:#b45309;">暂无报工记录。</p>
|
||||
{{end}}
|
||||
{{if .NeedTorque}}
|
||||
<h2>拧紧数据{{if not .TorqueRows}}(无数据){{end}}</h2>
|
||||
|
||||
Reference in New Issue
Block a user