feat: 五项目业务实现并对接完成
- MES(B): 工单/BOM/备料/工序字典/PLC下发/拧紧/扫码报工/半成品/AGV/追溯逻辑,WMS与海康RCS客户端,看板Redis缓存API(概览/设备/进度/报警/趋势)+SSE - WMS(C): JWT滑动续签、Excel导入、盘点、内部API、种子数据、独立Postgres配置 - WMS客户端(E): Go网关8891反向代理+内嵌Vue3十页 - 工位终端(D): SQLite本地缓存+模拟拧紧源+内嵌Vue3页面 - Dashboard(A): 看板数据改接MES内部缓存API,SSE实时刷新+vite代理 - 清理各项目球形磨遗留代码,新增部署手册.md
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"bj_power_wms/ent"
|
||||
"bj_power_wms/ent/zone"
|
||||
"bj_power_wms/internal/svc"
|
||||
)
|
||||
|
||||
// createZoneHandler 创建区域
|
||||
func createZoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
ZoneCode string `json:"zoneCode"`
|
||||
ZoneName string `json:"zoneName"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil {
|
||||
fail(w, http.StatusBadRequest, "参数错误")
|
||||
return
|
||||
}
|
||||
if req.ZoneCode == "" || req.ZoneName == "" {
|
||||
fail(w, http.StatusBadRequest, "zoneCode 和 zoneName 必填")
|
||||
return
|
||||
}
|
||||
|
||||
exists, err := ctx.EntClient.Zone.Query().
|
||||
Where(zone.ZoneCodeEQ(req.ZoneCode)).
|
||||
Exist(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
if exists {
|
||||
fail(w, http.StatusConflict, "区域编码已存在")
|
||||
return
|
||||
}
|
||||
|
||||
z, err := ctx.EntClient.Zone.Create().
|
||||
SetZoneCode(req.ZoneCode).
|
||||
SetZoneName(req.ZoneName).
|
||||
SetNillableDescription(strPtr(req.Description)).
|
||||
Save(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
ok(w, z)
|
||||
}
|
||||
}
|
||||
|
||||
// listZonesHandler 区域列表
|
||||
func listZonesHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
list, err := ctx.EntClient.Zone.Query().Order(ent.Desc("id")).All(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
ok(w, list)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user