快乐的昕的电脑
2025-10-16 f6e4c06a6ea3b865c9e167b824ad6c00842170a9
根据工单ID获取报工信息
已修改2个文件
已添加1个文件
126 ■■■■■ 文件已修改
Controllers/WomdaaController.cs 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Services/Dto/MesReportingBgDto.cs 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Services/WomdaaManager.cs 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Controllers/WomdaaController.cs
@@ -12,7 +12,15 @@
public class WomdaaController : ControllerBase
{
    private readonly WomdaaManager m = new();
    public class BillNoBgQueryDto
    {
        public string BillNo { get; set; }
        public string MachineNo { get; set; }
        public DateTime? From { get; set; }
        public DateTime? To { get; set; }
        public int PageIndex { get; set; } = 1;
        public int PageSize { get; set; } = 500;
    }
    //GetWomdaasByMachine
    [HttpPost("GetWomdaasByMachine")]
@@ -262,4 +270,34 @@
            return ResponseResult.ResponseError(ex);
        }
    }
    [HttpPost("GetByBillNoBG")]
    public IActionResult GetByBillNoBG([FromBody] BillNoBgQueryDto dto)
    {
        if (string.IsNullOrWhiteSpace(dto.BillNo))
            return Ok(new { status = 1, message = "billNo不能为空" });
        try
        {
            var (tbBillList, totalCount) = m.GetByBillNoBG(
                dto.BillNo, dto.MachineNo, dto.From, dto.To, dto.PageIndex, dto.PageSize);
            return Ok(new
            {
                status = 0,
                message = "Ok",
                data = new
                {
                    tbBillList,
                    totalCount
}
            });
        }
        catch (Exception ex)
        {
            // è®°å½•日志 ex
            return Ok(new { status = 1, message = "服务器错误" });
        }
    }
}
Services/Dto/MesReportingBgDto.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
public class MesReportingBgDto
{
    public long Id { get; set; }
    public string BillNo { get; set; }
    public string ItemNo { get; set; }
    public string MachineNo { get; set; }
    public string StaffNo { get; set; }
    public string StaffName { get; set; }
    public DateTime? BgDate { get; set; }
    public int? KgQty { get; set; }
    public int? InitialValue { get; set; }
    public int? ProductionCount { get; set; }
    public int? SQuantity { get; set; }
    public int? OkQty { get; set; }
    public int? NgQty { get; set; }
}
Services/WomdaaManager.cs
@@ -1,6 +1,7 @@
using PadApplication.DB;
using PadApplication.Entites.DbModels;
using PadApplication.Entites.Dto;
using SqlSugar;
namespace PadApplication.Services;
@@ -183,17 +184,74 @@
    }
    /// <summary>
    ///     æ ¹æ®å·¥å•ID获取打印信息
    ///     æ ¹æ®å·¥å•ID获取报工信息
    /// </summary>
    /// <param name="query">包含工单ID的查询条件</param>
    /// <returns>工单打印信息</returns>
    /// <returns>工单报工信息</returns>
    public VPrint GetWomdaaPrintById(OrderMachineDto query)
    {
        var vPrint = Db.Queryable<VPrint>()
            .Where(s => s.Id == query.OrderId).First();
        vPrint.RmiPrQty =
            (int)Math.Ceiling(
                (double)((vPrint.Bqty - vPrint.SQuantity) / vPrint.Qqty));
            .Where(s => s.Id == query.OrderId)
            .First();
        if (vPrint == null)
            return null;
        // é˜²æ­¢é™¤é›¶å’Œç©ºå€¼å¼‚常
        var bqty = vPrint.Bqty ?? 0;
        var sQuantity = vPrint.SQuantity ?? 0;
        var qqty = vPrint.Qqty ?? 0;
        if (qqty == 0)
        {
            vPrint.RmiPrQty = 0;
        }
        else
        {
            // å‰©ä½™å¯æ‰“印张数 = (可打印总数量 - å·²æ‰“印数量) / æ ‡å‡†åŒ…装数,向上取整
            var remain = bqty - sQuantity;
            vPrint.RmiPrQty = remain > 0 ? (int)Math.Ceiling((double)remain / (double)qqty) : 0;
        }
        return vPrint;
    }
    public (List<MesReportingBgDto> tbBillList, int totalCount) GetByBillNoBG(
    string billNo, string machineNo, DateTime? from, DateTime? to, int pageIndex, int pageSize)
    {
        var query = Db.Queryable<MesReporting>()
            .Where(x => x.BillNo == billNo);
        if (!string.IsNullOrWhiteSpace(machineNo))
            query = query.Where(x => x.MachineNo == machineNo);
        if (from.HasValue)
            query = query.Where(x => x.BgDate >= from.Value);
        if (to.HasValue)
            query = query.Where(x => x.BgDate < to.Value.AddDays(1));
        var totalCount = query.Count();
        var tbBillList = query.OrderBy(x => x.BgDate, OrderByType.Desc)
            .Select(x => new MesReportingBgDto
            {
                Id = (long)x.Id,
                BillNo = x.BillNo,
                ItemNo = x.ItemNo,
                MachineNo = x.MachineNo,
                StaffNo = x.BgPerson,
                StaffName = x.BgPerson, // å¦‚有独立姓名字段可替换
                BgDate = x.BgDate,
                KgQty = SqlFunc.ToInt32(x.CjQty),
                InitialValue = SqlFunc.ToInt32(x.CsQty),
                ProductionCount = SqlFunc.ToInt32(x.CjQty),
                SQuantity = SqlFunc.ToInt32(x.OkQty),
                OkQty = SqlFunc.ToInt32(x.OkQty),
                NgQty = SqlFunc.ToInt32(x.BfQty)
            })
            .ToPageList((pageIndex < 1 ? 1 : pageIndex), (pageSize < 1 ? 200 : (pageSize > 1000 ? 1000 : pageSize)), ref totalCount);
        return (tbBillList, totalCount);
    }
}