feat: 新增拧紧待签任务集中签字功能
新增了巡检终端的拧紧待签任务聚合查询和批量审核签字接口,支持检验员对拧紧任务进行第二签;在权限系统中新增对应按钮权限,前端页面新增指标选择下拉和绩效报表的上机记录页签,同时完善相关帮助文档和配置项。
This commit is contained in:
@@ -36,6 +36,8 @@ var pathPermMap = map[string]string{
|
||||
"PUT:/api/v1/settings": "sys.settings:edit",
|
||||
// 过程巡检汇总生成《工序间检验记录》(巡检终端操作域)
|
||||
"POST:/api/v1/inspections/generate-inter-process": "sys.inspect:process",
|
||||
// 拧紧待签任务集中签字(巡检终端操作域,检验员第二签)
|
||||
"POST:/api/v1/torque/audit-group": "sys.inspect:sign",
|
||||
// 质量检验处置(过程检/完工检不合格处置 退货/返修/退换)
|
||||
"POST:/api/v1/quality/disposal": "produce.quality:edit",
|
||||
// 附件中心(sys.attachment 菜单下):删除 / 归档清理属管理动作;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package production
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -184,3 +185,46 @@ func TorqueAuditLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Ok(w, data)
|
||||
}
|
||||
}
|
||||
|
||||
// TorquePendingHandler GET /torque/pending 拧紧待签任务:未审核记录按 工单号+SN+工位 聚合,
|
||||
// 供巡检终端检验员集中第二签(真分页 page/pageSize)
|
||||
func TorquePendingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
data, err := logic.New(svcCtx).ListTorquePendingGroups(r.Context(),
|
||||
atoiDefault(q.Get("page"), 1), atoiDefault(q.Get("pageSize"), 20))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3212, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, data)
|
||||
}
|
||||
}
|
||||
|
||||
// TorqueAuditGroupHandler POST /torque/audit-group 拧紧分组批量审核签字:
|
||||
// 把 工单号+SN+工位 一组内全部未审核记录标记审核人=当前登录账号,返回签字条数
|
||||
func TorqueAuditGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
WorkOrderNo string `json:"workOrderNo"`
|
||||
Sn string `json:"sn"`
|
||||
StationNo string `json:"stationNo"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if req.Sn == "" {
|
||||
httpx.Fail(w, 3213, "缺少 sn")
|
||||
return
|
||||
}
|
||||
n, err := logic.New(svcCtx).AuditTorqueGroup(r.Context(),
|
||||
req.WorkOrderNo, req.Sn, req.StationNo, req.Remark, operator(r, ""))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3213, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, fmt.Sprintf("已签字 %d 条", n), map[string]any{"count": n})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,6 +216,9 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodGet, Path: "/torque/stat", Handler: production.TorqueStatHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/torque/audit", Handler: production.TorqueAuditHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/torque/audit-log", Handler: production.TorqueAuditLogHandler(serverCtx)},
|
||||
// 巡检终端「待签任务」:拧紧未审核聚合 + 检验员集中第二签
|
||||
{Method: http.MethodGet, Path: "/torque/pending", Handler: production.TorquePendingHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/torque/audit-group", Handler: production.TorqueAuditGroupHandler(serverCtx)},
|
||||
|
||||
{Method: http.MethodGet, Path: "/process-steps", Handler: production.ProcessStepsHandler(serverCtx)},
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ func StationCheckinInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
|
||||
}
|
||||
}
|
||||
|
||||
// PerformanceExportHandler GET /performance/export 绩效报表导出(一个 xlsx 三个 sheet:按人/按工位/明细)
|
||||
// PerformanceExportHandler GET /performance/export 绩效报表导出(一个 xlsx 四个 sheet:按人/按工位/明细/上机记录)
|
||||
// 执行全项目统一导出时间硬规则:起止必填(默认近3个月)、间隔≤1年
|
||||
func PerformanceExportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -233,8 +233,8 @@ func PerformanceExportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
{"按工位", "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{"操作人", "工位", "日期", "工艺ID", "工艺名", "完成数", "合格", "不合格", "累计作业时长(秒)", "平均作业时长(秒)", "效率(件/小时)"}, func(r *logic.WorkloadRow) []any {
|
||||
return []any{r.Operator, r.StationNo, r.Date, r.FlowId, r.ProcessName, r.DoneCount, r.OkCount, r.NgCount, r.TotalDurationSec, r.AvgDurationSec, r.Efficiency}
|
||||
{"明细", "detail", []string{"操作人", "工单号", "工位", "日期", "工艺ID", "工艺名", "完成数", "合格", "不合格", "累计作业时长(秒)", "平均作业时长(秒)", "效率(件/小时)"}, func(r *logic.WorkloadRow) []any {
|
||||
return []any{r.Operator, r.OrderNo, r.StationNo, r.Date, r.FlowId, r.ProcessName, r.DoneCount, r.OkCount, r.NgCount, r.TotalDurationSec, r.AvgDurationSec, r.Efficiency}
|
||||
}},
|
||||
}
|
||||
for i, vw := range views {
|
||||
@@ -258,6 +258,26 @@ func PerformanceExportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 第四个 sheet:上机记录(由开工签到+报工实绩推导,不受工单号筛选影响)
|
||||
if sess, ok := data["sessions"].(map[string]any); ok {
|
||||
if sessList, ok2 := sess["list"].([]logic.StationSessionRow); ok2 {
|
||||
sheet := "上机记录"
|
||||
f.NewSheet(sheet)
|
||||
headers := []string{"操作人", "工位", "日期", "上机时间(签到)", "下机时间(最后活动)", "在机时长(秒)", "加工件数", "效率(件/小时)"}
|
||||
for c, h := range headers {
|
||||
cell, _ := excelize.CoordinatesToCellName(c+1, 1)
|
||||
_ = f.SetCellValue(sheet, cell, h)
|
||||
}
|
||||
for rIdx, it := range sessList {
|
||||
vals := []any{it.Operator, it.StationNo, it.Date, it.CheckinAt, it.LastActiveAt, it.DurationSec, it.DoneCount, it.Efficiency}
|
||||
for c := range headers {
|
||||
cell, _ := excelize.CoordinatesToCellName(c+1, rIdx+2)
|
||||
_ = f.SetCellValue(sheet, cell, vals[c])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
w.Header().Set("Content-Disposition", "attachment; filename*=UTF-8''"+url.PathEscape("绩效报表.xlsx"))
|
||||
_, _ = f.WriteTo(w)
|
||||
|
||||
Reference in New Issue
Block a user