feat: 新增工序签字功能,移除移料指令模块
新增操作工/检验员工序签字功能,支持工艺步骤配置签字要求;删除移料指令相关代码,将移料页签重命名为产线点位(上料/下料);新增成品入库功能及相关权限;优化备料单状态、质量状态逻辑,新增批次序号字段;修复AGV取消后备料单回退状态问题。
This commit is contained in:
@@ -139,7 +139,9 @@ func MarkMaterialRequestStatusInternalHandler(svcCtx *svc.ServiceContext) http.H
|
||||
httpx.BadRequest(w, "请求体缺失")
|
||||
return
|
||||
}
|
||||
if req.Status != "DELIVERING" && req.Status != "DONE" {
|
||||
// 备料单状态词表:PENDING(待备料)/LOCKED(已备料已出库)/DELIVERING(配送中)/DONE(已接料完结)
|
||||
// WMS 取消 AGV 后回退用 PENDING(待备料),与 MES 词表对齐(修复 WAIT_SEND 越界静默失败)
|
||||
if req.Status != "DELIVERING" && req.Status != "DONE" && req.Status != "PENDING" {
|
||||
httpx.Fail(w, 3106, "非法状态")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package production
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -94,39 +93,6 @@ func TorqueRecordsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// TorqueGroupsHandler GET /torque/groups 拧紧一级汇总(工单号/SN/日期/工位 四条件复合 + 应拧 vs 实拧满足判定)
|
||||
func TorqueGroupsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
from := parseTorqueTime(q.Get("from"), false)
|
||||
to := parseTorqueTime(q.Get("to"), true)
|
||||
data, err := logic.New(svcCtx).ListTorqueGroups(r.Context(), q.Get("sn"), q.Get("workOrderNo"), q.Get("stationNo"),
|
||||
from, to, atoiDefault(q.Get("page"), 1), atoiDefault(q.Get("pageSize"), 20))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3210, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, data)
|
||||
}
|
||||
}
|
||||
|
||||
// TorqueStatHandler GET /torque/stat 单工件单工位应拧 vs 实拧统计
|
||||
func TorqueStatHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
if q.Get("sn") == "" {
|
||||
httpx.Fail(w, 3211, "缺少 sn 参数")
|
||||
return
|
||||
}
|
||||
data, err := logic.New(svcCtx).TorqueScrewStat(r.Context(), q.Get("sn"), q.Get("stationNo"))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3211, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, data)
|
||||
}
|
||||
}
|
||||
|
||||
// ProcessStepsHandler 查询工位的工序步骤(参数采集模板),供巡检终端等按工位动态渲染。
|
||||
// 按 stationNo 加载该工位启用工艺流程的工序步骤。
|
||||
func ProcessStepsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
@@ -144,87 +110,3 @@ func ProcessStepsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Ok(w, data)
|
||||
}
|
||||
}
|
||||
|
||||
// TorqueAuditHandler POST /torque/audit 拧紧记录审核签字
|
||||
func TorqueAuditHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
RecordId int `json:"recordId"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if req.RecordId <= 0 {
|
||||
httpx.Fail(w, 3208, "缺少 recordId")
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).AuditTorqueRecord(r.Context(), req.RecordId, req.Remark, operator(r, "")); err != nil {
|
||||
httpx.Fail(w, 3208, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "审核成功", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// TorqueAuditLogHandler GET /torque/audit-log 查询拧紧记录修改留痕
|
||||
func TorqueAuditLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
id := atoiDefault(q.Get("recordId"), 0)
|
||||
if id <= 0 {
|
||||
httpx.Fail(w, 3209, "缺少 recordId")
|
||||
return
|
||||
}
|
||||
data, err := logic.New(svcCtx).ListTorqueAuditLog(r.Context(), id)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3209, err.Error())
|
||||
return
|
||||
}
|
||||
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})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package production
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"bj_power_mes/common/httpx"
|
||||
"bj_power_mes/internal/logic"
|
||||
"bj_power_mes/internal/svc"
|
||||
)
|
||||
|
||||
// InspectorSignHandler 检验员签字确认(需求B 第二签)。需 sys.inspect:sign 权限(perm.go 兜底)。
|
||||
func InspectorSignHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.InspectorSignReq
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).InspectorSign(r.Context(), req, operator(r, "")); err != nil {
|
||||
httpx.Fail(w, 3301, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "签字成功", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// SignPendingHandler 待检验员签字列表(需求B 巡检终端「待签任务」数据源)。
|
||||
func SignPendingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
f := logic.PendingSignFilter{
|
||||
Sn: q.Get("sn"),
|
||||
OrderNo: q.Get("orderNo"),
|
||||
StationNo: q.Get("stationNo"),
|
||||
Page: atoiDefault(q.Get("page"), 1),
|
||||
PageSize: atoiDefault(q.Get("pageSize"), 50),
|
||||
}
|
||||
data, total, err := logic.New(svcCtx).PendingSigns(r.Context(), f)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3302, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"list": data, "total": total})
|
||||
}
|
||||
}
|
||||
@@ -273,13 +273,40 @@ func SaveDailyPlanHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
func ListDailyPlansHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orderNo := r.URL.Query().Get("orderNo")
|
||||
planDate := r.URL.Query().Get("planDate")
|
||||
data, err := logic.New(svcCtx).ListDailyPlansWithCombination(r.Context(), orderNo, planDate)
|
||||
q := r.URL.Query()
|
||||
// 日期窗口:防内存炸弹。默认今天~今天+30 由前端传;显示历史时 planDateStart 为空。
|
||||
planDateStart := q.Get("planDateStart")
|
||||
planDateEnd := q.Get("planDateEnd")
|
||||
// 排序方向:asc=按排产日期升序(从前到后,默认) / desc=降序(最新在前)。
|
||||
sortDir := q.Get("sort")
|
||||
if sortDir == "" {
|
||||
sortDir = "asc"
|
||||
}
|
||||
page, _ := strconv.Atoi(q.Get("page"))
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
pageSize, _ := strconv.Atoi(q.Get("pageSize"))
|
||||
if pageSize < 1 {
|
||||
pageSize = 50
|
||||
}
|
||||
rows, total, err := logic.New(svcCtx).ListDailyPlansPaged(r.Context(), planDateStart, planDateEnd, page, pageSize, sortDir)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3009, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"list": rows, "total": total})
|
||||
}
|
||||
}
|
||||
|
||||
// ListUnplannedWorkOrdersHandler GET /daily-plans/unplanned 未排产工单列表(日排产页顶部入口用)。
|
||||
func ListUnplannedWorkOrdersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
data, err := logic.New(svcCtx).ListUnplannedWorkOrders(r.Context())
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3011, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, data)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user