feat:多项功能优化
This commit is contained in:
@@ -31,8 +31,7 @@ var pathPermMap = map[string]string{
|
||||
"POST:/api/v1/process-flows/upload": "produce.processflow:upload",
|
||||
"POST:/api/v1/process-steps": "produce.processflow:edit",
|
||||
"POST:/api/v1/stations": "produce.station:edit",
|
||||
// 数量不符上报(菜单 produce.qtyreport 下新增)
|
||||
"POST:/api/v1/qty-reports": "produce.qtyreport",
|
||||
"DELETE:/api/v1/stations/*": "produce.station:delete",
|
||||
// 过程巡检汇总生成《工序间检验记录》(巡检终端操作域)
|
||||
"POST:/api/v1/inspections/generate-inter-process": "sys.inspect:process",
|
||||
// 质量检验处置(过程检/完工检不合格处置 退货/返修/退换)
|
||||
|
||||
@@ -112,6 +112,17 @@ func SaveStationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteStationHandler DELETE /stations/:id(删除工位:内置工位不允许删除)
|
||||
func DeleteStationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if err := logic.New(svcCtx).DeleteStation(r.Context(), pathId(r), operator(r, "")); err != nil {
|
||||
httpx.Fail(w, 2208, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "工位已删除", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// SetFlowStatusHandler POST /process-flows/status(工艺流程启用/停用)
|
||||
func SetFlowStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -81,16 +81,29 @@ func ListAlertRulesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// ListAlertsHandler GET /alerts?status= 预警消息收件箱
|
||||
// ListAlertsHandler GET /alerts?status=&type=&from=&to=&page=&pageSize=
|
||||
// 预警消息收件箱:支持 状态/类型/时间范围(YYYY-MM-DD) 筛选;带 page 返回分页对象,否则返回全量数组(顶部铃铛未读数复用)。
|
||||
func ListAlertsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
status := r.URL.Query().Get("status")
|
||||
data, err := logic.New(svcCtx).ListAlerts(r.Context(), status)
|
||||
q := r.URL.Query()
|
||||
query := logic.AlertQuery{
|
||||
Status: q.Get("status"),
|
||||
Type: q.Get("type"),
|
||||
From: q.Get("from"),
|
||||
To: q.Get("to"),
|
||||
Page: atoiDefault(q.Get("page"), 0),
|
||||
PageSize: atoiDefault(q.Get("pageSize"), 20),
|
||||
}
|
||||
list, total, err := logic.New(svcCtx).ListAlerts(r.Context(), query)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3305, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, data)
|
||||
if query.Page > 0 {
|
||||
httpx.Ok(w, map[string]any{"list": list, "total": total, "page": query.Page, "pageSize": query.PageSize})
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, list)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ func ExportProductTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
w.Header().Set("Content-Disposition", "attachment; filename*=UTF-8''"+url.PathEscape("产品型号.xlsx"))
|
||||
w.Header().Set("Content-Disposition", "attachment; filename*=UTF-8''"+url.PathEscape("物料档案.xlsx"))
|
||||
_, _ = w.Write(b)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodGet, Path: "/torque/groups", Handler: production.TorqueGroupsHandler(serverCtx)},
|
||||
{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/audit-log", Handler: production.TorqueAuditLogHandler(serverCtx)},
|
||||
|
||||
{Method: http.MethodPost, Path: "/scan/report", Handler: production.ScanReportHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/scan/records", Handler: production.ScanRecordsHandler(serverCtx)},
|
||||
@@ -217,6 +217,7 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodPost, Path: "/process-flows/upload", Handler: UploadPdfHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/stations", Handler: ListStationsHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/stations", Handler: SaveStationHandler(serverCtx)},
|
||||
{Method: http.MethodDelete, Path: "/stations/:id", Handler: DeleteStationHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/line/points", Handler: ListPointsHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/line/move", Handler: IssueMoveHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/line/move/ack", Handler: AckMoveHandler(serverCtx)},
|
||||
@@ -235,10 +236,6 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodGet, Path: "/quality/unqualified-report", Handler: UnqualifiedReportHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/inspections/generate-inter-process", Handler: GenerateInterProcessInspectionHandler(serverCtx)},
|
||||
|
||||
// ---------- 数量不符上报(第三批) ----------
|
||||
{Method: http.MethodPost, Path: "/qty-reports", Handler: CreateQtyReportHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/qty-reports", Handler: ListQtyReportsHandler(serverCtx)},
|
||||
|
||||
// ---------- 应急呼叫(D3,MES 前端亦可发起) ----------
|
||||
{Method: http.MethodPost, Path: "/alert/emergency", Handler: EmergencyCallHandler(serverCtx)},
|
||||
|
||||
|
||||
@@ -170,36 +170,6 @@ func EmergencyCallHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// CreateQtyReportHandler POST /api/v1/qty-reports
|
||||
func CreateQtyReportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.QtyReportReq
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
req.Operator = operator(r, req.Operator)
|
||||
if err := logic.New(svcCtx).CreateQtyReport(r.Context(), req); err != nil {
|
||||
httpx.Fail(w, 2402, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "数量不符已上报", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// ListQtyReportsHandler GET /api/v1/qty-reports?status=
|
||||
func ListQtyReportsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
data, err := logic.New(svcCtx).ListQtyReports(r.Context(),
|
||||
r.URL.Query().Get("status"), r.URL.Query().Get("orderNo"), r.URL.Query().Get("materialCode"))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 2404, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, data)
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateInterProcessInspectionHandler POST /api/v1/inspections/generate-inter-process
|
||||
// 一键生成《工序间检验记录》:汇总该工单 PROCESS 类巡检记录(按步骤维度)。
|
||||
func GenerateInterProcessInspectionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
Reference in New Issue
Block a user