lg
2024-08-15 155e67da6f128562af9e02fb86582635a4f7f57a
Merge branch 'master' of http://43.142.96.171:8080/r/~tjx/StandardPda
已修改3个文件
265 ■■■■■ 文件已修改
MES.Service/Dto/service/MovesDto.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/service/Warehouse/MesInvItemMovesManager.cs 221 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/Controllers/Warehouse/MesInvItemMovesController.cs 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/Dto/service/MovesDto.cs
@@ -4,8 +4,12 @@
public class MovesDto
{
    //出入单
    public List<MesInvItemMoves>? FromList { get; set; }
    public List<MesInvItemOutItems>? OutItems { get; set; }
    public List<MesInvItemMovesCDetails>? BarcodeList { get; set; }
    
    //入库单
    public bool? InAudit{ get; set; }
    public MesInvItemBarcodes? BarcodesInfo{ get; set; }
}
MES.Service/service/Warehouse/MesInvItemMovesManager.cs
@@ -12,39 +12,148 @@
    //这里面写的代码不会给覆盖,如果要重新生成请删除 MesInvItemMovesManager.cs
    public int ScanInBarcode(WarehouseQuery query)
    public MovesDto ScanInBarcode(WarehouseQuery query)
    {
        if (string.IsNullOrEmpty(query.sectionCode))
        {
            throw new Exception("请扫库位条码!");
        }
        int pBillTypeId = 300;
        int pTransctionNo = 301;
        var depotQuery = Db.Queryable<MesDepotSections, MesDepots>((a, b) => new JoinQueryInfos(
                JoinType.Inner, a.Zuid.ToString() == b.Zuid))
        var depotQuery = Db.Queryable<MesDepotSections, MesDepots>((a, b) =>
                new JoinQueryInfos(
                    JoinType.Inner, a.Zuid.ToString() == b.Zuid))
            .Where((a, b) => a.DepotSectionCode == query.sectionCode)
            .Select((a, b) => new { b.DepotCode })
            .First();
        if (depotQuery == null)
        {
            throw new Exception($"002[库位编码 {query.sectionCode} 不存在,请确认!");
        }
        var cDepotCode = depotQuery.DepotCode;
        // 查询调拔入库信息
        var itemMoveQuery = Db.Queryable<MesInvItemMoves, MesInvItemMovesCDetails>((a, b) => new JoinQueryInfos(
                JoinType.Inner, a.Id == b.ItemMoveId))
            .Where((a, b) => b.ItemBarcode == query.barcode && a.BillTypeId == pBillTypeId && a.TransactionNo == pTransctionNo &&
        var itemMoveQuery = Db
            .Queryable<MesInvItemMoves, MesInvItemMovesCDetails>((a, b) =>
                new JoinQueryInfos(
                    JoinType.Inner, a.Id == b.ItemMoveId))
            .Where((a, b) => b.ItemBarcode == query.barcode &&
                             a.BillTypeId == pBillTypeId &&
                             a.TransactionNo == pTransctionNo &&
                             a.Status == 1 && SqlFunc.IsNull(b.MoveOk, 0) != 1)
            .Select((a, b) => new { a.Id, a.BillNo, a.InvDepotsCode })
            .First();
        return 0;
        if (itemMoveQuery == null)
        {
            throw new Exception("条码未做调拔出库扫码,请核对!");
        }
        var cBillNo = itemMoveQuery.BillNo;
        var iDepotCode = itemMoveQuery.InvDepotsCode;
        // 验证库区与仓库
        var depotValidationQuery = Db.Queryable<MesDepotSections, MesDepots>(
                (a, b) => new JoinQueryInfos(
                    JoinType.Inner, a.Zuid.ToString() == b.Zuid))
            .Where((a, b) => a.DepotSectionCode == query.sectionCode &&
                             b.DepotCode == iDepotCode)
            .Select((a, b) => new { b.DepotCode })
            .First();
        if (depotValidationQuery == null)
        {
            throw new Exception($"002[库位编码 {query.sectionCode} 不存在,请确认!");
        }
        if (iDepotCode != depotValidationQuery.DepotCode)
        {
            throw new Exception("实际仓库与申请调入仓库不符,请核对!");
        }
        var barcodeCount = Db.Queryable<MesInvItemMovesCDetails>()
            .Where(b =>
                b.ItemBarcode == query.barcode &&
                b.ItemMoveId == itemMoveQuery.Id && b.MoveOk == 1)
            .Count();
        if (barcodeCount > 0)
        {
            throw new Exception("条码调拔已完成,请核对!");
        }
        var barcodeInfo = Db.Queryable<MesInvItemBarcodes>()
            .Where(t => t.ItemBarcode == query.barcode)
            .First();
        if (barcodeInfo == null)
        {
            throw new Exception("条码不存在,请核对!");
        }
        var isAudit = UseTransaction(db =>
        {
            // 更新业务、库存和条码数据
            db.Updateable<MesInvBusiness2>()
                .SetColumns(b => new MesInvBusiness2
                {
                    ToInvDepotsCode = cDepotCode,
                    ToInvDepotSectionsCode = query.sectionCode
                })
                .Where(b =>
                    b.BillNo == cBillNo && b.BillTypeId == pBillTypeId &&
                    b.TransactionCode == pTransctionNo.ToString() &&
                    b.ItemBarcode == query.barcode)
                .ExecuteCommand();
            db.Updateable<MesInvItemStocks>()
                .SetColumns(b => new MesInvItemStocks
                {
                    DepotsCode = cDepotCode,
                    DepotSectionsCode = query.sectionCode
                })
                .Where(b => b.ItemBarcode == query.barcode)
                .ExecuteCommand();
            db.Updateable<MesInvItemMovesCDetails>()
                .SetColumns(b => new MesInvItemMovesCDetails
                {
                    MoveOk = 1,
                    InvDepotsCode = cDepotCode,
                    InvDepotSectionsCode = query.sectionCode
                })
                .Where(b =>
                    b.ItemBarcode == query.barcode &&
                    b.ItemMoveId == itemMoveQuery.Id)
                .ExecuteCommand();
            // 检查是否所有条码已扫码移库
            var totalQuantity = db.Queryable<MesInvItemOutItems>()
                .Where(a => a.ItemOutId == itemMoveQuery.Id)
                .Sum(a => SqlFunc.IsNull(a.Quantity, 0));
            var scannedQuantity = db.Queryable<MesInvItemMovesCDetails>()
                .Where(a => a.ItemMoveId == itemMoveQuery.Id && a.MoveOk == 1)
                .Sum(a => SqlFunc.IsNull(a.Quantity, 0));
            if (totalQuantity == scannedQuantity)
            {
                return 1;
            }
            return 0;
        });
        MovesDto dto = new MovesDto();
        dto.InAudit = isAudit == 1;
        dto.BarcodesInfo = barcodeInfo;
        return dto;
    }
    public List<MesInvItemMoves> GetBillNo(WarehouseQuery query)
    {
@@ -324,4 +433,92 @@
        return results;
    }
    public bool Audit(WarehouseQuery query)
    {
        return Db.Updateable<MesInvItemMoves>()
            .SetColumns(a => new MesInvItemMoves { Ts = 1 })
            .Where(a => a.Id == query.id)
            .ExecuteCommand() > 0;
    }
    public MessageCenter SaveMessageCenter(WarehouseQuery query)
    {
        var message = MesToErpParam(query);
        var executeReturnIdentity =
            Db.Insertable(message).ExecuteReturnIdentity();
        if (executeReturnIdentity > 0)
        {
            message.Id = executeReturnIdentity;
            message.Pid = executeReturnIdentity;
            return message;
        }
        throw new Exception("获取数据失败");
    }
    public MessageCenter MesToErpParam(WarehouseQuery query)
    {
        var erpParameters = "";
        var title = "";
        var tableName = "MES_INV_ITEM_MOVES_" + query.Type;
        if ("A".Equals(query.Type))
        {
            erpParameters = GetErpParameters(query.billNo);
            title = "调拨入库单" + query.billNo + "审核";
        }
        else if ("B".Equals(query.Type))
        {
            erpParameters = GetDeApprovePam(query.id);
            title = "调拨入库单" + query.billNo + "反审核";
        }
        var ErpUrl = AppsettingsUtility.Settings.ProductionErpUrl;
        var message = new MessageCenter
        {
            TableName = tableName,
            Url = ErpUrl,
            Status = 1,
            CreateBy = query.userName,
            Route = query.billNo,
            Title = title,
            PageName = "Allocation/Add?id=" + query.id +
                       "&billNo=" + query.billNo,
            CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
            Method = "POST",
            Seq = 1,
            Data = erpParameters,
            IsMessage = 0,
            ContentType = "application/x-www-form-urlencoded"
        };
        return message;
    }
    private string GetErpParameters(string? billNo)
    {
        // var invItemIns = Db.Queryable<MesInvItemOuts>()
        //     .Single(x => x.ItemOutNo == billNo);
        //
        // //调用function函数
        // var sql =
        //     $"SELECT F_GENERATE_DATA_INSERTED('{billNo}') FROM DUAL;";
        // var jsonString = Db.Ado.SqlQuerySingle<string>(sql);
        //
        // var encodedUrl = "taskname=CGTL&mesid=" + invItemIns.Id +
        //                  "&optype=create&datajson=" + jsonString;
        //
        // return encodedUrl;
        return null;
    }
    private string GetDeApprovePam(decimal? id)
    {
        // var sid = (int)id;
        // var encodedUrl = "taskname=CGTL&mesid=" + sid +
        //                  "&optype=delete&datajson={}";
        //
        // return encodedUrl;
        return null;
    }
}
MESApplication/Controllers/Warehouse/MesInvItemMovesController.cs
@@ -12,6 +12,46 @@
public class MesInvItemMovesController : ControllerBase
{
    private readonly MesInvItemMovesManager m = new();
    [HttpPost("Audit")]
    public ResponseResult Audit(WarehouseQuery query)
    {
        try
        {
            dynamic resultInfos = new ExpandoObject();
            resultInfos.tbBillList = m.Audit(query);
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
    [HttpPost("SaveMessageCenter")]
    public ResponseResult SaveMessageCenter(WarehouseQuery entity)
    {
        try
        {
            dynamic resultInfos = new ExpandoObject();
            resultInfos.tbBillList = m.SaveMessageCenter(entity);
            return new ResponseResult
            {
                status = 0,
                message = "OK",
                data = resultInfos
            };
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
    //GetPage
    [HttpPost("GetPage")]