Jelajahi Sumber

平台库存监控

zhengly 2 tahun lalu
induk
melakukan
32e8b9963c

+ 3 - 2
MicroServices/Business/Business.Application.Contracts/DOP/ISyncDOPAppService.cs

@@ -1,4 +1,5 @@
-using System;
+using Business.Dto;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -14,6 +15,6 @@ namespace Business.DOP
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        string SyncPlatformFinishedProductMonitoring();
+        Task<string> SyncPlatformFinishedProductMonitoring(List<PlatformInventoryDto> platformInventoryDtoList);
     }
 }

+ 35 - 0
MicroServices/Business/Business.Application.Contracts/Dto/PlatformInventoryDto.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Dto
+{
+    /// <summary>
+    /// 平台库存DTO
+    /// </summary>
+    public class PlatformInventoryDto
+    {
+        /// <summary>
+        /// 仓库
+        /// </summary>
+        public string? Location { get; set; }
+        /// <summary>
+        /// 规格
+        /// </summary>
+        public string? SpecificationModel { get; set;}
+        /// <summary>
+        /// 批号
+        /// </summary>
+        public string? BatchNumber { get; set; }
+        /// <summary>
+        /// 库存数量
+        /// </summary>
+        public decimal? InventoryQuantity { get; set; }
+        /// <summary>
+        /// 有效期
+        /// </summary>
+        public decimal? PeriodOfValidity { get; set; }
+    }
+}

+ 107 - 5
MicroServices/Business/Business.Application/DOP/SyncDOPAppService.cs

@@ -1,25 +1,127 @@
 using Abp.Application.Services;
 using Abp.Dependency;
-using Business.ResourceExamineManagement;
+using Business.Core.Utilities;
+using Business.Dto;
+using Business.Model.WMS;
+using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using System.Threading.Tasks;
+using Volo.Abp.MultiTenancy;
+using Volo.Abp.Uow;
+using IUnitOfWorkManager = Volo.Abp.Uow.IUnitOfWorkManager;
 
 namespace Business.DOP
 {
     //DOP
     public class SyncDOPAppService : ApplicationService, ISyncDOPAppService, ITransientDependency
     {
+        #region 服务
+        /// <summary>
+        /// 工单
+        /// </summary>
+        //private readonly ISqlRepository<PlatformSpecificationComparison> _PlatformSpecificationComparison;
+
+        /// <summary>
+        /// 平台规格型号对照表
+        /// </summary>
+        private readonly Volo.Abp.Domain.Repositories.IRepository<PlatformSpecificationComparison, long> _PlatformSpecificationComparison;
+        /// <summary>
+        /// 平台库存表
+        /// </summary>
+        private readonly Volo.Abp.Domain.Repositories.IRepository<PlatformInventory, long> _PlatformInventory;
+        /// <summary>
+        ///  雪花算法
+        /// </summary>
+        SnowFlake snowFlake = new SnowFlake();
+        /// <summary>
+        /// 事务
+        /// </summary>
+        private readonly IUnitOfWorkManager _unitOfWorkManager;
+        #endregion
+        #region 构造函数
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        public SyncDOPAppService(
+            Volo.Abp.Domain.Repositories.IRepository<PlatformSpecificationComparison, long> PlatformSpecificationComparison,
+            Volo.Abp.Domain.Repositories.IRepository<PlatformInventory, long> PlatformInventory,
+             IUnitOfWorkManager unitOfWorkManager,
+        ICurrentTenant currentTenant
+            )
+        {
+            _PlatformSpecificationComparison = PlatformSpecificationComparison;
+            _PlatformInventory = PlatformInventory;
+            _unitOfWorkManager = unitOfWorkManager;
+        }
+        #endregion
         /// <summary>
         /// 平台成品监控
         /// </summary>
         /// <returns></returns>
         /// <exception cref="NotImplementedException"></exception>
-        public string SyncPlatformFinishedProductMonitoring()
+        public async Task<string> SyncPlatformFinishedProductMonitoring(List<PlatformInventoryDto> platformInventoryDtoList)
         {
-            throw new NotImplementedException();
+            var ret = SavePlatformFinishedProductMonitoringAsync(platformInventoryDtoList, 1);
+            return await ret;
+        }
+        /// <summary>
+        /// 保存库存信息
+        /// </summary>
+        /// <param name="platformInventoryDtoList"></param>
+        /// <param name="type">1海王,2国科</param>
+        public async Task<string> SavePlatformFinishedProductMonitoringAsync(List<PlatformInventoryDto> platformInventoryDtoList, int type)
+        {
+            if (platformInventoryDtoList.Count == 0)
+            {
+                return JsonConvert.SerializeObject("成品库存为空!");
+            }
+            List<PlatformInventory> platformInventoryInsert = new List<PlatformInventory>();
+            List<PlatformInventory> platformInventoryDel;
+            if (type == 1)
+            {
+                platformInventoryDel = _PlatformInventory.GetListAsync(x => x.Code == "HW0001").Result;
+            }
+            else
+            {
+                platformInventoryDel = _PlatformInventory.GetListAsync(x => x.Code == "HW0002").Result;
+            }
+            foreach (var item in platformInventoryDtoList)
+            {
+                PlatformInventory platformInventory = new PlatformInventory();
+                platformInventory.GenerateNewId(snowFlake.NextId());
+                platformInventory.Location = item.Location;
+                platformInventory.SpecificationModel = item.SpecificationModel;
+                platformInventory.BatchNumber = item.BatchNumber;
+                platformInventory.InventoryQuantity = item.InventoryQuantity;
+                platformInventory.PeriodOfValidity = item.PeriodOfValidity;
+                if (type == 1)
+                {
+                    platformInventory.Code = "HW0001";
+                }
+                else
+                {
+                    platformInventory.Code = "HW0002";
+                }
+                platformInventoryInsert.Add(platformInventory);
+            }
+            using (var unitOfWork = _unitOfWorkManager.Begin(false, true))
+            {
+                try
+                {
+                    await _PlatformInventory.DeleteManyAsync(platformInventoryDel);
+                    await _PlatformInventory.InsertManyAsync(platformInventoryInsert);
+
+                    await unitOfWork.CompleteAsync();
+                }
+                catch (Exception e)
+                {
+                    new NLogHelper("SyncDOPAppService").WriteLog("PrMerge", "接口获取失败:" + e.Message);
+                    unitOfWork.Dispose();
+                    return JsonConvert.SerializeObject(e.Message);
+                }
+            }
+            return JsonConvert.SerializeObject("ok");
         }
     }
 }

+ 3 - 2
MicroServices/Business/Business.HttpApi/Controllers/DOP/DOPController.cs

@@ -1,4 +1,5 @@
 using Business.DOP;
+using Business.Dto;
 using Business.ResourceExamineManagement;
 using Microsoft.AspNetCore.Mvc;
 using System;
@@ -33,9 +34,9 @@ namespace Business.Controllers.DOP
         /// <returns></returns>
         [HttpPost]
         [Route("SyncPlatformFinishedProductMonitoring")]
-        public string SyncPlatformFinishedProductMonitoring()
+        public async Task<string> SyncPlatformFinishedProductMonitoring(List<PlatformInventoryDto> platformInventoryDtoList)
         {
-            return _DopAppService.SyncPlatformFinishedProductMonitoring();
+            return await _DopAppService.SyncPlatformFinishedProductMonitoring(platformInventoryDtoList);
         }
     }
 }

+ 49 - 0
MicroServices/Business/Bussiness.Model/WMS/PlatformInventory.cs

@@ -0,0 +1,49 @@
+using Business.Core.Attributes;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Model.WMS
+{
+    /// <summary>
+    /// 平台规格库存对照
+    /// </summary>
+    [Comment("平台规格库存对照")]
+    public class PlatformInventory : BaseEntity
+    {
+        /// <summary>
+        /// 仓库
+        /// </summary>
+        [Comment("仓库")]
+        public string? Location { get; set; }
+        /// <summary>
+        /// 规格或货品编码
+        /// </summary>
+        [Comment("规格或货品编码")]
+        public string? SpecificationModel { get; set; }
+        /// <summary>
+        /// 批号
+        /// </summary>
+        [Comment("批号")]
+        public string? BatchNumber { get; set; }
+        /// <summary>
+        /// 数量
+        /// </summary>
+        [Comment("数量")]
+        public decimal? InventoryQuantity { get; set; }
+        /// <summary>
+        /// 有效期
+        /// </summary>
+        [Comment("有效期")]
+        public decimal? PeriodOfValidity { get; set; }
+        /// <summary>
+        /// 编码
+        /// </summary>
+        [Comment("编码")]
+        public string? Code { get; set; }
+    }
+}

+ 4 - 0
MicroServices/Business/Bussiness.Model/WMS/PlatformSpecificationComparison.cs

@@ -37,5 +37,9 @@ namespace Business.Model.WMS
         /// </summary>
         [Comment("国科规格型号")]
         public string? GKSpecificationModel { get; set; }
+        /// <summary>
+        /// 库存型号
+        /// </summary>
+        public string? Type { get; set; }
     }
 }