feat: 完成产线与仓储系统多模块迭代升级

本次迭代覆盖MES与WMS核心业务:
1. 新增接驳台托盘传感器读取与AGV对接能力
2. 完善工单排产、备料流程与权限体系拆分
3. 优化看板接口与前端路由、样式
4. 新增操作日志、库存盘点与角色保护逻辑
5. 修复代理地址、BOM保存等已知问题
This commit is contained in:
SunYF
2026-09-04 14:18:53 +08:00
parent c1fc6d32b2
commit b6799c9de4
138 changed files with 20613 additions and 2220 deletions
+25 -1
View File
@@ -7,6 +7,8 @@ import (
"bj_power_mes/ent"
"bj_power_mes/ent/plcsendlog"
"bj_power_mes/ent/workorder"
"bj_power_mes/ent/workpiece"
)
type PlcSendReq struct {
@@ -17,11 +19,33 @@ type PlcSendReq struct {
}
// SendProcess 下发 PLC 工序码。
// 约束:上一条工序未收到完成信号,不下发下一条(模拟 S7 握手)。
// 约束:① SN 必须属于所选工单且已进线(未完工);② 上一条工序未收到完成信号,不下发下一条(模拟 S7 握手)。
func (s *Service) SendProcess(ctx context.Context, req PlcSendReq, operator string) (*ent.PlcSendLog, error) {
if req.ProcessCombination == "" {
return nil, errors.New("工位组合不能为空")
}
if req.OrderNo == "" {
return nil, errors.New("请选择工单号")
}
if req.Sn == "" {
return nil, errors.New("请填写/扫描工件 SN")
}
// 校验①:SN 归属工单且已进线
wo, err := s.ctx.EntClient.WorkOrder.Query().Where(workorder.WorkOrderNo(req.OrderNo)).First(ctx)
if err != nil {
return nil, errors.New("工单不存在:" + req.OrderNo)
}
if wo.Status == "DONE" || wo.Status == "CANCELLED" {
return nil, errors.New("该工单已完成或已取消,不能下发")
}
wp, err := s.ctx.EntClient.Workpiece.Query().
Where(workpiece.Sn(req.Sn), workpiece.OrderNo(req.OrderNo)).First(ctx)
if err != nil {
return nil, errors.New("该 SN 不属于当前工单或未进线登记(请先在工件进线中登记)")
}
if wp.Status == "DONE" {
return nil, errors.New("该工件已完工,无需再次下发")
}
// 检查是否存在未完成的同工位下发
last, err := s.ctx.EntClient.PlcSendLog.Query().
Where(plcsendlog.Status("SENT")).Order(plcsendlog.ByID()).First(ctx)