|
|
@@ -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");
|
|
|
}
|
|
|
}
|
|
|
}
|