| | |
| | | |
| | | if (womdaa == null) throw new Exception("工单单号不存在"); |
| | | |
| | | if (womdaa.Daa018 != "开工") throw new Exception("工单未开工"); |
| | | |
| | | var okQty = query.currentCjNum - query.initCjNum - query.bf;//良品数量 |
| | | |
| | | // 创建报工记录 |
| | | var mesReporting = new MesReporting |
| | | { |
| | |
| | | // BgPerson = strings[0], |
| | | AddressCode = womdaa.AddressCode, |
| | | MachineNo = womdaa.MachineNo, |
| | | BfQty = query.bf, |
| | | // OkQty = print, |
| | | BfQty = query.bf,//不良数量 |
| | | OkQty = okQty,//良品数量 |
| | | CsQty = query.initCjNum,//初始采集数 |
| | | CjQty = query.currentCjNum,//报工时采集数 |
| | | ItemNo = womdaa.Daa002, |
| | | BillNo = womdaa.Daa001 |
| | | BillNo = womdaa.Daa001, |
| | | BgPerson = query.staffNo // 新增:报工人编号 |
| | | }; |
| | | |
| | | // 更新工单Daa011为原值加上本次良品数量,Daa012为原值加上本次不良品数量 |
| | | Db.Updateable<Womdaa>() |
| | | .SetColumns(x => x.Daa011 == (womdaa.Daa011 ?? 0) + (okQty ?? 0)) |
| | | .SetColumns(x => x.Daa012 == (womdaa.Daa012 ?? 0) + (query.bf ?? 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) |
| | | { |
| | | var finishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | Db.Updateable<Womdaa>() |
| | | .SetColumns(x => x.Daa017 == DateTime.Parse(finishTime)) |
| | | .SetColumns(x => x.Daa018 == "完工") |
| | | .Where(x => x.Daa001 == womdaaAfter.Daa001) |
| | | .ExecuteCommand(); |
| | | |
| | | // 同步更新MES_ORDER_STA的END_TIME |
| | | Db.Updateable<object>() |
| | | .AS("MES_ORDER_STA") |
| | | .SetColumns("END_TIME", finishTime) |
| | | .Where($"ORDER_NO = '{womdaaAfter.Daa001}'") |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | // 插入报工记录和条码记录 |
| | | return Db.Insertable(mesReporting) |
| | |
| | | var s1 = DateTime.Now.ToString("yyyy-MM-dd"); |
| | | |
| | | // 获取数采数据 |
| | | var CjQty = Db.Queryable<MesNumerical>() |
| | | var CjQty = Db.Queryable<MesNumericalBycl>() |
| | | .Where(s => |
| | | s.MachineNo == mesReporting.MachineNo && s.EditDate == s1) |
| | | .OrderByDescending(s => s.CjTiem) |
| | |
| | | |
| | | // 更新报工记录 |
| | | Db.Updateable<MesReporting>() |
| | | .SetColumns(a => a.BlQty == BlQty.ToString()) |
| | | .SetColumns(a => a.CsQty == anchors.InitialValue.ToString()) |
| | | .SetColumns(a => a.JtQty == jt.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(); |
| | | } |