快乐的昕的电脑
2025-10-18 01a24397d01fa1cf6c12876ae05609c5a198be96
Services/MesInvItemBarcodesManager.cs
@@ -290,6 +290,8 @@
        if (womdaa == null) throw new Exception("工单单号不存在");
        var okQty = query.currentCjNum - query.initCjNum - query.bf;//良品数量
        // 创建报工记录
        var mesReporting = new MesReporting
        {
@@ -301,13 +303,31 @@
            AddressCode = womdaa.AddressCode,
            MachineNo = womdaa.MachineNo,
            BfQty = query.bf,//不良数量
            OkQty = query.currentCjNum - query.initCjNum - query.bf,//良品数量
            OkQty = okQty,//良品数量
            CsQty = query.initCjNum,//初始采集数
            JtQty = query.currentCjNum,//报工时采集数
            CjQty = query.currentCjNum,//报工时采集数
            ItemNo = womdaa.Daa002,
            BillNo = womdaa.Daa001,
            BgPerson = query.staffNo // 新增:报工人编号
        };
        // 更新工单Daa011为原值加上本次良品数量
        Db.Updateable<Womdaa>()
            .SetColumns(x => x.Daa011 == (womdaa.Daa011 ?? 0) + (okQty ?? 0))
            .Where(x => x.Daa001 == womdaa.Daa001)
            .ExecuteCommand();
        // 判断是否全部完工,若是则写入实际完工日期
        var womdaaAfter = Db.Queryable<Womdaa>()
            .Where(s => s.Daa001 == query.orderNo)
            .First();
        if (womdaaAfter != null && womdaaAfter.Daa011 >= womdaaAfter.Daa008)
        {
            Db.Updateable<Womdaa>()
                .SetColumns(x => x.Daa017 == DateTime.Now)
                .Where(x => x.Daa001 == womdaaAfter.Daa001)
                .ExecuteCommand();
        }
        // 插入报工记录和条码记录
        return Db.Insertable(mesReporting)
@@ -364,12 +384,12 @@
        // 更新报工记录
        Db.Updateable<MesReporting>()
            .SetColumns(a => a.BlQty == BlQty.ToString())
            .SetColumns(a => a.BlQty == BlQty)
            .SetColumns(a => a.CsQty == (anchors.InitialValue ?? 0))
            .SetColumns(a => a.JtQty == jt)
            // .SetColumns(a => a.BfQty == bfQty)
            .SetColumns(a => a.CjQty == ljcj.ToString())
            .SetColumns(a => a.DyQty == DyQty.ToString())
            .SetColumns(a => a.CjQty == ljcj)
            .SetColumns(a => a.DyQty == DyQty)
            .Where(a => a.ItemNoCade == mesReporting.ItemNoCade)
            .ExecuteCommand();
    }