啊鑫
2024-08-14 2b55ea83a98f5f5db2bb1e0576d54b583f017128
MES.Service/service/Warehouse/OpeningReceiptServer.cs
@@ -6,12 +6,15 @@
namespace MES.Service.service.Warehouse;
public class OpeningReceiptServer :RepositoryNoEntity
public class OpeningReceiptServer : RepositoryNoEntity
{
    private const string Factory = "1000";
    private const string Company = "1000";
    private const int billTypeId = 100;
    private const int transactionNo = 601;
    public MesInvItemBarcodes ScanInBarcodeQC(WarehouseQuery query)
    {
@@ -25,9 +28,6 @@
        {
            throw new Exception($"002[库位编码 {query.sectionCode} 不存在,请确认!");
        }
        int billTypeId = 100;
        int transactionNo = 601;
        var checkBarcodeAlreadyReceived =
            CheckBarcodeAlreadyReceived(query.barcode);
@@ -49,7 +49,7 @@
        }
        var inventoryItemInId = GetOrCreateInventoryItemInId(barcodeInfo,
            depotCode, query.userName, transactionNo, out string billNo);
            depotCode, query.userName, out string billNo);
        UseTransaction(db =>
        {
@@ -64,8 +64,56 @@
            return 1;
        });
        return barcodeInfo;
    }
    public PurchaseInventory GetForm(WarehouseQuery query)
    {
        var mesInvItemBarcodes = Db.Queryable<MesInvItemBarcodes>()
            .Where(s => s.ItemBarcode == query.barcode).Count();
        if (mesInvItemBarcodes <= 0)
        {
            throw new Exception("条码不存在");
        }
        var mesInvItemInCDetails = Db.Queryable<MesInvItemInCDetails>()
            .Where(s => s.ItemBarcode == query.barcode).Single();
        PurchaseInventory entity = new PurchaseInventory
        {
            ItemIns = GetMesInvItemIns(mesInvItemInCDetails.ItemInId),
            InvItemInCDetails =
                GetMesInvItemInCDetailsList(mesInvItemInCDetails.ItemInId),
            ItemStocks = Db.Queryable<MesInvItemStocks>()
                .Where(s => s.ItemBarcode == query.barcode).ToList()
        };
        return entity;
    }
    public MesInvItemIns GetMesInvItemIns(decimal id)
    {
        return Db.Queryable<MesInvItemIns>()
            .Where(s => s.Id == id).Single();
    }
    public List<MesInvItemInCDetails> GetMesInvItemInCDetailsList(decimal id)
    {
        return Db.Queryable<MesInvItemInCDetails, MesUnit>((a, b) =>
                new JoinQueryInfos(JoinType.Inner, a.Unit == b.Id.ToString()))
            .Where((a, b) => a.ItemInId == id)
            .Select((a, b) => new MesInvItemInCDetails
            {
                ItemBarcode = a.ItemBarcode,
                ItemNo = a.ItemNo,
                ItemSname = a.ItemSname,
                DepotSectionCode = a.DepotSectionCode,
                Quantity = a.Quantity,
                Unit = b.Fname,
                Remark = a.Remark
            })
            .ToList();
    }
    private void InsertInventoryDetails(decimal itemInId, string billNo,
@@ -113,7 +161,7 @@
    }
    private decimal GetOrCreateInventoryItemInId(MesInvItemBarcodes barcodeInfo,
        string depotCode, string userName, int transactionNo, out string billNo)
        string depotCode, string userName, out string billNo)
    {
        var inventory = Db.Queryable<MesInvItemIns>()
            .Where(d => d.InsDate >= DateTime.Today &&
@@ -125,7 +173,6 @@
                        d.SuppNo == barcodeInfo.SuppNo &&
                        d.DepotsCode == depotCode)
            .First();
        if (inventory != null)
        {
            billNo = inventory.BillNo;
@@ -139,7 +186,7 @@
        var executeReturnIdentity = Db.Insertable(new MesInvItemIns
        {
            BillNo = billNo,
            BillTypeId = 100,
            BillTypeId = billTypeId,
            InsDate = DateTime.Now,
            DepotsCode = depotCode,
            TransctionNo = transactionNo.ToString(),
@@ -231,7 +278,7 @@
        var executeCommand = Db.Insertable(new MesInvBusiness2
        {
            Status = 1,
            BillTypeId = 100,
            BillTypeId = billTypeId,
            TransactionCode = "601",
            BusinessType = 1,
            ItemBarcode = barcodeInfo.ItemBarcode,