Explorar o código

Merge branch 'dev' of http://123.60.180.165:4647/ZZYDOP/DOPCore into dev

tangdi %!s(int64=2) %!d(string=hai) anos
pai
achega
fa90ffb0be

+ 26 - 0
MicroServices/Business/Business.Application.Contracts/DOP/ISyncDOPAppService.cs

@@ -0,0 +1,26 @@
+using Business.Dto;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Services;
+
+namespace Business.DOP
+{
+    public interface ISyncDOPAppService : IApplicationService
+    {
+        /// <summary>
+        /// 海王成品库存监控
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        Task<string> SyncPlatformFinishedProductMonitoringHW(List<PlatformInventoryDto> platformInventoryDtoList);
+        /// <summary>
+        /// 海王成品库存监控
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        Task<string> SyncPlatformFinishedProductMonitoringGK(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; }
+    }
+}

+ 133 - 0
MicroServices/Business/Business.Application/DOP/SyncDOPAppService.cs

@@ -0,0 +1,133 @@
+using Abp.Application.Services;
+using Abp.Dependency;
+using Business.Core.Utilities;
+using Business.Dto;
+using Business.Model.WMS;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+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 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 async Task<string> SyncPlatformFinishedProductMonitoringHW(List<PlatformInventoryDto> platformInventoryDtoList)
+        {
+            var ret = SavePlatformFinishedProductMonitoringAsync(platformInventoryDtoList, 1);
+            return await ret;
+        }
+        /// <summary>
+        /// 国科平台成品监控
+        /// </summary>
+        /// <returns></returns>
+        /// <exception cref="NotImplementedException"></exception>
+        public async Task<string> SyncPlatformFinishedProductMonitoringGK(List<PlatformInventoryDto> platformInventoryDtoList)
+        {
+            var ret = SavePlatformFinishedProductMonitoringAsync(platformInventoryDtoList, 2);
+            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("PlatformFinishedProductMonitoringAsyncMerge", "接口异常:" + e.Message);
+                    unitOfWork.Dispose();
+                    return JsonConvert.SerializeObject(e.Message);
+                }
+            }
+            return JsonConvert.SerializeObject("ok");
+        }
+    }
+}

+ 53 - 0
MicroServices/Business/Business.HttpApi/Controllers/DOP/DOPController.cs

@@ -0,0 +1,53 @@
+using Business.DOP;
+using Business.Dto;
+using Business.ResourceExamineManagement;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp;
+using Volo.Abp.AspNetCore.Mvc;
+
+namespace Business.Controllers.DOP
+{
+
+    /// <summary>
+    /// DOP同步接口
+    /// </summary>
+    [RemoteService]
+    [Area("Business")]
+    [Route("api/business/DOP")]
+    public class DOPController : AbpController
+    {
+        private readonly ISyncDOPAppService _DopAppService;
+
+        public DOPController(ISyncDOPAppService DopAppService)
+        {
+            _DopAppService = DopAppService;
+        }
+        /// <summary>
+        /// 平台成品库存监控
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("SyncPlatformFinishedProductMonitoringHW")]
+        public async Task<string> SyncPlatformFinishedProductMonitoringHW(List<PlatformInventoryDto> platformInventoryDtoList)
+        {
+            return await _DopAppService.SyncPlatformFinishedProductMonitoringHW(platformInventoryDtoList);
+        }
+        /// <summary>
+        /// 平台成品库存监控
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("SyncPlatformFinishedProductMonitoringGK")]
+        public async Task<string> SyncPlatformFinishedProductMonitoringGK(List<PlatformInventoryDto> platformInventoryDtoList)
+        {
+            return await _DopAppService.SyncPlatformFinishedProductMonitoringGK(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; }
+    }
+}

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

@@ -0,0 +1,45 @@
+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 PlatformSpecificationComparison : BaseEntity
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        /// <param name="Id"></param>
+        public PlatformSpecificationComparison(long Id) : base(Id)
+        {
+        }
+        /// <summary>
+        /// 标准规格型号
+        /// </summary>
+        [Comment("标准规格型号")]
+        public string? StandardSpecifications { get; set; }
+        /// <summary>
+        /// 海王规格型号
+        /// </summary>
+        [Comment("海王规格型号")]
+        public string? HWSpecificationModel { get; set; }
+        /// <summary>
+        /// 国科规格型号
+        /// </summary>
+        [Comment("国科规格型号")]
+        public string? GKSpecificationModel { get; set; }
+        /// <summary>
+        /// 库存型号
+        /// </summary>
+        public string? Type { get; set; }
+    }
+}