Browse Source

Merge branch 'dev_DY_CC' of http://dev.ccwin-in.com:3000/BoXu.Zheng/WZC2 into dev_DY_CC

dev_DY_CC
郑勃旭 1 year ago
parent
commit
f892f000ea
  1. 6
      be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/CountAdjustNoteConverter.cs
  2. 17
      be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedIssueNoteConverter.cs
  3. 17
      be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedReceiptNoteConverter.cs
  4. 9
      be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedIssueNote/UnplannedIssueNoteExchangeDto.cs
  5. 8
      be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedReceiptNote/UnplannedReceiptNoteExchangeDto.cs
  6. 10
      be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/Win_in.Sfs.Wms.DataExchange.Application.Contracts.xml
  7. 1
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ItemStoreRelations/IItemStoreRelationAppService.cs
  8. 14
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemStoreRelations/ItemStoreRelationAppService.cs
  9. 8
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/DTOs/CountJobDependentDetailDTO.cs
  10. 54
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobImportInput.cs
  11. 199
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs
  12. 10
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAutoMapperProfile.cs
  13. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJob.cs
  14. 6
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDependentDetail.cs
  15. 134
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs
  16. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/ICountJobManager.cs
  17. 3
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs

6
be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/CountAdjustNoteConverter.cs

@ -75,7 +75,7 @@ public class CountAdjustNoteConverter : IOutgoingConverter
DestinationDataId = "",
};
outgoingToExternal.SetEffectiveDate(outgoingFromWms.EffectiveDate);
var exchangeIssue = await BuildPurchaseReceiptExchangeDtoAsync(wmsCountAdjust, detail).ConfigureAwait(false);
var exchangeIssue = BuildPurchaseReceiptExchangeDtoAsync(wmsCountAdjust, detail);
outgoingToExternal.SourceDataContent = JsonSerializer.Serialize(exchangeIssue);
var arrive = BuildWip(exchangeIssue, departmentCode);
outgoingToExternal.DestinationDataContent = JsonSerializer.Serialize(arrive);
@ -103,7 +103,7 @@ public class CountAdjustNoteConverter : IOutgoingConverter
DestinationDataId = "",
};
outgoingToExternal.SetEffectiveDate(outgoingFromWms.EffectiveDate);
var exchangeIssue = await BuildPurchaseReceiptExchangeDtoAsync(wmsCountAdjust, detail).ConfigureAwait(false);
var exchangeIssue = BuildPurchaseReceiptExchangeDtoAsync(wmsCountAdjust, detail);
outgoingToExternal.SourceDataContent = JsonSerializer.Serialize(exchangeIssue);
var arrive = BuildIssue(exchangeIssue, departmentCode);
outgoingToExternal.DestinationDataContent = JsonSerializer.Serialize(arrive);
@ -159,7 +159,7 @@ public class CountAdjustNoteConverter : IOutgoingConverter
};
return counta;
}
private async Task<CountAdjustNoteExchangeDto> BuildPurchaseReceiptExchangeDtoAsync(
private CountAdjustNoteExchangeDto BuildPurchaseReceiptExchangeDtoAsync(
CountAdjustNoteDTO wmsCountAdjust, CountAdjustNoteDetailExchangeDto wmsCountAdjustDetail)
{
var exchangeCountAdjust = _objectMapper.Map<CountAdjustNoteDTO, CountAdjustNoteExchangeDto>(wmsCountAdjust);

17
be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedIssueNoteConverter.cs

@ -22,19 +22,22 @@ public class UnplannedIssueNoteConverter : IOutgoingConverter
private readonly IDepartmentAppService _departmentAppService;
private readonly IObjectMapper _objectMapper;
private readonly ISfsUserAppService _sfsUserAppService;
private readonly IUnplannedIssueRequestAppService _unplannedIssueRequestAppService;
public UnplannedIssueNoteConverter(
IOutgoingFromWmsManager outgoingFromWmsManager
, IOutgoingToExternalManager outgoingToExternalManager
, IDepartmentAppService departmentAppService
, IObjectMapper objectMapper
, ISfsUserAppService sfsUserAppService)
, ISfsUserAppService sfsUserAppService,
IUnplannedIssueRequestAppService unplannedIssueRequestAppService)
{
_outgoingFromWmsManager = outgoingFromWmsManager;
_outgoingToExternalManager = outgoingToExternalManager;
_departmentAppService = departmentAppService;
_objectMapper = objectMapper;
_sfsUserAppService = sfsUserAppService;
_unplannedIssueRequestAppService = unplannedIssueRequestAppService;
}
/// <summary>
@ -54,6 +57,12 @@ public class UnplannedIssueNoteConverter : IOutgoingConverter
var exchangeReceipt = _objectMapper.Map<UnplannedIssueNoteDTO, UnplannedIssueNoteExchangeDto>(wmsReceipt);
var department = await _departmentAppService.GetByUsernameAsync(exchangeReceipt.Worker).ConfigureAwait(false);
var departmentCode = department == null ? "" : department.Code;
var requset = await _unplannedIssueRequestAppService.GetByNumberAsync(exchangeReceipt.UnplannedIssueRequestNumber).ConfigureAwait(false);
string worker = requset?.Worker;
if (!string.IsNullOrEmpty(worker))
{
worker = await _sfsUserAppService.GetUserNameByUserAsync(requset.Worker).ConfigureAwait(false);
}
//if (Guid.TryParse(exchangeReceipt.CreatorId.ToString(), out Guid guid))
//{
// var username = await _sfsUserAppService.GetUserNameById(guid).ConfigureAwait(false);
@ -63,7 +72,7 @@ public class UnplannedIssueNoteConverter : IOutgoingConverter
// }
//}
var purchaseOrder = BuildDataInterface(exchangeReceipt, tyrpNumber, departmentCode);
var purchaseOrder = BuildDataInterface(exchangeReceipt, tyrpNumber, departmentCode, worker);
var outgoingToExternal = new OutgoingToExternal()
{
DataType = EnumOutgoingDataType.UnplannedIssue.ToString(),
@ -123,7 +132,7 @@ public class UnplannedIssueNoteConverter : IOutgoingConverter
/// </summary>
/// <param name="exchangeOrder"></param>
/// <returns></returns>
private Wmsoutm BuildDataInterface(UnplannedIssueNoteExchangeDto exchangeOrder,string tyrpNumber,string departmentCode)
private Wmsoutm BuildDataInterface(UnplannedIssueNoteExchangeDto exchangeOrder,string tyrpNumber,string departmentCode,string worker)
{
string billtype = "4013";
if (exchangeOrder.UnplannedIssueType== EnumUnplannedIssueType.Wip)
@ -137,7 +146,7 @@ public class UnplannedIssueNoteConverter : IOutgoingConverter
wmsoutm_dt_w = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"),
wmsoutm_stat = "Y",
wmsoutm_tyrp_dt = "",
wmsoutm_user = exchangeOrder.Worker.Length >= 6 ? exchangeOrder.Worker.Substring(exchangeOrder.Worker.Length- 6) : exchangeOrder.Worker,
wmsoutm_user = worker.Length >= 6 ? worker.Substring(worker.Length- 6) : worker,
wmsoutm_dept = departmentCode,//根据Worker从UserDepartment中获取
// wmsoutm_date = exchangeOrder.ActiveDate.ToString("yyyyMMdd"),
wmsoutm_date = DateTime.Now.ToString("yyyyMMdd"),

17
be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/UnplannedReceiptNoteConverter.cs

@ -23,6 +23,7 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter
private readonly IDepartmentAppService _departmentAppService;
private readonly IObjectMapper _objectMapper;
private readonly ISfsUserAppService _sfsUserAppService;
private readonly IUnplannedReceiptRequestAppService _unplannedReceiptRequestAppService;
public UnplannedReceiptNoteConverter(
IOutgoingFromWmsManager outgoingFromWmsManager
@ -30,6 +31,9 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter
, IDepartmentAppService departmentAppService
, IObjectMapper objectMapper
, ISfsUserAppService sfsUserAppService
,
IUnplannedReceiptRequestAppService unplannedReceiptRequestAppService
)
{
_outgoingFromWmsManager = outgoingFromWmsManager;
@ -37,6 +41,7 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter
_departmentAppService = departmentAppService;
_objectMapper = objectMapper;
_sfsUserAppService = sfsUserAppService;
_unplannedReceiptRequestAppService = unplannedReceiptRequestAppService;
}
/// <summary>
@ -56,6 +61,12 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter
var exchangeReceipt = _objectMapper.Map<UnplannedReceiptNoteDTO, UnplannedReceiptNoteExchangeDto>(wmsReceipt);
var department = await _departmentAppService.GetByUsernameAsync(exchangeReceipt.Worker).ConfigureAwait(false);
var departmentCode = department == null ? "" : department.Code;
var requset = await _unplannedReceiptRequestAppService.GetByNumberAsync(exchangeReceipt.UnplannedReceiptRequestNumber).ConfigureAwait(false);
string worker = requset?.Worker;
if (!string.IsNullOrEmpty(worker))
{
worker = await _sfsUserAppService.GetUserNameByUserAsync(requset.Worker).ConfigureAwait(false);
}
//if (Guid.TryParse(exchangeReceipt.CreatorId.ToString(), out Guid guid))
//{
// var username = await _sfsUserAppService.GetUserNameById(guid).ConfigureAwait(false);
@ -64,7 +75,7 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter
// exchangeReceipt.Worker = username;
// }
//}
var purchaseOrder = BuildDataInterface(exchangeReceipt, tyrpNumber, departmentCode);
var purchaseOrder = BuildDataInterface(exchangeReceipt, tyrpNumber, departmentCode, worker);
var outgoingToExternal = new OutgoingToExternal()
{
DataType = EnumOutgoingDataType.UnplannedReceipt.ToString(),
@ -124,7 +135,7 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter
/// </summary>
/// <param name="exchangeOrder"></param>
/// <returns></returns>
private Wmsoutm BuildDataInterface(UnplannedReceiptNoteExchangeDto exchangeOrder, string tyrpNumber,string departmentCode)
private Wmsoutm BuildDataInterface(UnplannedReceiptNoteExchangeDto exchangeOrder, string tyrpNumber,string departmentCode,string worker)
{
string billtype = "4014";
if (exchangeOrder.UnplannedReceiptType == EnumUnplannedReceiptType.Wip)
@ -138,7 +149,7 @@ public class UnplannedReceiptNoteConverter : IOutgoingConverter
wmsoutm_dt_w = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"),
wmsoutm_stat = "Y",
wmsoutm_tyrp_dt = "",
wmsoutm_user = exchangeOrder.Worker.Length>=6? exchangeOrder.Worker.Substring(exchangeOrder.Worker.Length-6) : exchangeOrder.Worker,
wmsoutm_user = worker.Length>=6? worker.Substring(worker.Length-6) : worker,
wmsoutm_dept = departmentCode,//根据Worker从UserDepartment中获取
//wmsoutm_date = exchangeOrder.ActiveDate.ToString("yyyyMMdd"),
wmsoutm_date = DateTime.Now.ToString("yyyyMMdd"),

9
be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedIssueNote/UnplannedIssueNoteExchangeDto.cs

@ -1,4 +1,8 @@
using System;
using IdentityServer4.Models;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
using Win_in.Sfs.Shared.Domain;
using Win_in.Sfs.Shared.Domain.Shared.Enums.Store;
namespace Win_in.Sfs.Wms.DataExchange.WMS.UnplannedIssueNote;
@ -27,4 +31,9 @@ public class UnplannedIssueNoteExchangeDto
/// 领料类别
/// </summary>
public EnumUnplannedIssueType UnplannedIssueType { get; set; }
/// <summary>
/// 计划外出库请求单号
/// </summary>
public string UnplannedIssueRequestNumber { get; set; }
}

8
be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/UnplannedReceiptNote/UnplannedReceiptNoteExchangeDto.cs

@ -1,4 +1,8 @@
using System;
using IdentityServer4.Models;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
using Win_in.Sfs.Shared.Domain;
using Win_in.Sfs.Shared.Domain.Shared.Enums.Store;
namespace Win_in.Sfs.Wms.DataExchange.WMS.UnplannedReceiptNote;
@ -28,5 +32,9 @@ public class UnplannedReceiptNoteExchangeDto
/// 退料类别
/// </summary>
public EnumUnplannedReceiptType UnplannedReceiptType { get; set; }
/// <summary>
/// 计划外入库请求单号
/// </summary>
public string UnplannedReceiptRequestNumber { get; set; }
}

10
be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/Win_in.Sfs.Wms.DataExchange.Application.Contracts.xml

@ -1801,6 +1801,11 @@
领料类别
</summary>
</member>
<member name="P:Win_in.Sfs.Wms.DataExchange.WMS.UnplannedIssueNote.UnplannedIssueNoteExchangeDto.UnplannedIssueRequestNumber">
<summary>
计划外出库请求单号
</summary>
</member>
<member name="P:Win_in.Sfs.Wms.DataExchange.WMS.UnplannedReceiptNote.UnplannedReceiptNoteDetailExchangeDto.Number">
<summary>
单据号
@ -1861,6 +1866,11 @@
退料类别
</summary>
</member>
<member name="P:Win_in.Sfs.Wms.DataExchange.WMS.UnplannedReceiptNote.UnplannedReceiptNoteExchangeDto.UnplannedReceiptRequestNumber">
<summary>
计划外入库请求单号
</summary>
</member>
<member name="P:Win_in.Sfs.Wms.DataExchange.WMS.User.IdentityUserExchangerDto.UserName">
<summary>
用户号码

1
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ItemStoreRelations/IItemStoreRelationAppService.cs

@ -21,4 +21,5 @@ public interface IItemStoreRelationAppService : ISfsBaseDataAppServiceBase<ItemS
Task<ItemStoreRelationDTO> GetFirstAsync(ItemAndLocationRequestInput itemAndLocations);
Task<ItemStoreRelationDTO> GetFirstAsync(string itemCode, string locationCode);
Task<ItemStoreRelationDTO> GetByItemAndLocationAsync(string itemCode, string value, EnumStoreRelationType storeRelationType);
}

14
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemStoreRelations/ItemStoreRelationAppService.cs

@ -99,6 +99,20 @@ public class ItemStoreRelationAppService : SfsBaseDataAppServiceBase<ItemStoreRe
return dtos;
}
[HttpGet("by-item-location")]
public virtual async Task<ItemStoreRelationDTO> GetByItemAndLocationAsync(string itemCode,string value, EnumStoreRelationType storeRelationType)
{
var entitie= await _repository.FirstOrDefaultAsync(p => p.ItemCode == itemCode&&p.StoreValue== value && p.Enabled == true && p.StoreRelationType == storeRelationType).ConfigureAwait(false);
if (entitie != null)
{
var dtos = ObjectMapper.Map<ItemStoreRelation, ItemStoreRelationDTO>(entitie);
return dtos;
}
else
{
return null;
}
}
/// <summary>
/// 当前库位 允许的 零件关系
/// </summary>

8
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/DTOs/CountJobDependentDetailDTO.cs

@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Win_in.Sfs.Shared.Domain;
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
@ -59,4 +60,11 @@ public class CountJobDependentDetailDTO : SfsJobDetailDTOBase, IHasCountResult
/// </summary>
[Display(Name = "盘点描述")]
public string CountDescription { get; set; }
/// <summary>
/// 是否删除
/// </summary>
[Display(Name = "是否删除")]
public bool IsDelete { get; set; }
}

54
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobImportInput.cs

@ -0,0 +1,54 @@
using System.ComponentModel.DataAnnotations;
using Win_in.Sfs.Shared.Domain.Shared;
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
[Display(Name = "盘点任务")]
public class CountJobImportInput : SfsStoreImportInputBase
{
/// <summary>
/// 盘点任务单号
/// </summary>
[Display(Name = "盘点任务单号")]
[Key]
[Required]
public string CountJobNumber { get; set; }
/// <summary>
/// 物品代码
/// </summary>
[Display(Name = "物料号")]
[Required(ErrorMessage = "{0}是必填项")]
public string ItemCode { get; set; }
/// <summary>
/// 物品名称
/// </summary>
[Display(Name = "物品名称")]
public string ItemName { get; set; }
/// <summary>
/// 箱码
/// </summary>
[Display(Name = "箱码")]
public string PackingCode { get; set; } = "";
/// <summary>
/// 库存状态
/// </summary>
[Display(Name = "库存状态")]
[Required(ErrorMessage = "{0}是必填项", AllowEmptyStrings = true)]
public EnumInventoryStatus Status { get; set; }
/// <summary>
/// 批次
/// </summary>
[Display(Name = "批次")]
public string Lot { get; set; } = "";
/// <summary>
/// 盘点数量
/// </summary>
[Display(Name = "盘点数量")]
[Required(ErrorMessage = "{0}是必填项")]
public decimal CountQty { get; set; }
}

199
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs

@ -1,14 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Volo.Abp;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Validation;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Application.Contracts;
using Win_in.Sfs.Shared.Domain;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Wms.Inventory.Application.Contracts;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
using Win_in.Sfs.Wms.Store.Domain.Shared;
@ -26,17 +33,206 @@ public class CountJobAppService
ICountJobAppService
{
private readonly ICountJobManager _countJobManager;
private readonly IItemBasicAppService _itemBasicAppService;
private readonly IItemStoreRelationAppService _itemStoreRelationAppService;
private readonly IBalanceAppService _balanceAppService;
//private readonly ILocationCapacityAppService _locationCapacityAppService;
public CountJobAppService(
ICountJobRepository repository
, ICountJobManager countJobManager
, IItemBasicAppService itemBasicAppService
, IItemStoreRelationAppService itemStoreRelationAppService
, IBalanceAppService balanceAppService
) : base(repository, countJobManager)
{
_itemBasicAppService = itemBasicAppService;
_countJobManager = countJobManager;
_itemStoreRelationAppService = itemStoreRelationAppService;
_balanceAppService= balanceAppService;
}
#region 导入
/// <summary>
/// 导入数据具体实现,可重写
/// </summary>
protected override async Task<SfsImportResult> ImportInternalAsync(SfsImportRequestInput requestInput, byte[] inputFileBytes)
{
IList<CountJobImportInput> modelList = null;
var modelDict = new Dictionary<CountJobImportInput, List<ValidationResult>>();
var entityDict = new Dictionary<CountJob, EntityState>();
try
{
var hasDetails = typeof(CountJob).GetInterfaces().Any(o => o.IsGenericType && o.GetGenericTypeDefinition() == typeof(IMasterEntity<>));
modelDict = ExportImportService.ImportHaveValidationResult<CountJobImportInput>(inputFileBytes);
foreach (var modelDictItem in modelDict)
{
// DataAnnotations 静态验证
var validationRresults = modelDictItem.Value;
var model = modelDictItem.Key;
Validator.TryValidateObject(model, new ValidationContext(model, null, null), validationRresults);
}
modelList = modelDict.Keys.ToList();
List<CountJobDependentDetail> depDetails = new List<CountJobDependentDetail>();
// 如果没有验证错误或允许部分导入
var jobnumber = modelDict.First().Key.CountJobNumber;
var job = await _repository.FindAsync(r => r.Number == jobnumber).ConfigureAwait(false);
if (!modelDict.SelectMany(o => o.Value).Any() || requestInput.IsAllowPartImport)
{
foreach (var item in modelDict)
{
var model = item.Key;
var validationRresults = item.Value;
var depDetail = ObjectMapper.Map<CountJobImportInput, CountJobDependentDetail>(model);
await ValidateImportModelAsync(model, validationRresults, job, depDetail).ConfigureAwait(false);
depDetails.Add(depDetail);
}
}
if (!modelDict.SelectMany(o => o.Value).Any())
{
if (depDetails.Any())
{
await _countJobManager.ImportAsync(job,depDetails, CurrentUser).ConfigureAwait(false);
}
}
// 创建导入报告
var reportFile = ExportImportService.GetImportReport(inputFileBytes, modelDict);
// 创建返回值
return new SfsImportResult
{
TotalNum = modelList.Count,
ErrorNum = modelDict.Count(o => o.Value.Any()),
FileName = reportFile.FileDownloadName,
FileContents = reportFile.FileContents
};
}
catch (Exception ex)
{
Console.WriteLine("---------------------------------");
Console.WriteLine($"####导入验证错误:");
Console.WriteLine($"{ex.Message}");
Console.WriteLine("---------------------------------");
Logger.LogException(ex);
if (modelList != null)
{
try
{
foreach (var item in modelDict)
{
var model = item.Key;
var validationRresults = item.Value;
validationRresults.Add(new ValidationResult($"无法添加,{ex.Message}", new string[] { "异常" }));
}
// 创建导入报告
var reportFile = ExportImportService.GetImportReport(inputFileBytes, modelDict);
return new SfsImportResult
{
TotalNum = modelList.Count,
ErrorNum = modelDict.Count(o => o.Value.Any()),
FileName = reportFile.FileDownloadName,
FileContents = reportFile.FileContents
};
}
catch (Exception)
{
return new SfsImportResult()
{
ExceptionMessage = ex.Message,
FileContents = Encoding.Default.GetBytes(ex.Message)
};
}
}
else
{
return new SfsImportResult()
{
ExceptionMessage = ex.Message,
FileContents = Encoding.Default.GetBytes(ex.Message)
};
}
}
}
/// <summary>
/// 导入验证
/// </summary>
/// <param name="model"></param>
/// <param name="validationRresult"></param>
/// <param name="job"></param>
/// <param name="depDetail"></param>
/// <returns></returns>
protected async Task ValidateImportModelAsync(CountJobImportInput model,
List<ValidationResult> validationRresult, CountJob job, CountJobDependentDetail depDetail)
{
_ = new Dictionary<string, string>();
CheckJobNumberAsync(model, validationRresult, job.Number);
_ = await CheckItemBasicAsync(model, validationRresult, depDetail).ConfigureAwait(false);
_ = await CheckItemStoreRelationAsync(model, validationRresult,job.LocationCode).ConfigureAwait(false);
_ = await CheckPackingCodeAsync(model, validationRresult, job.LocationCode).ConfigureAwait(false);
}
protected async Task<ItemBasicDTO> CheckItemBasicAsync(CountJobImportInput importInput,
List<ValidationResult> validationRresult, CountJobDependentDetail depDetail)
{
var item = await _itemBasicAppService.GetByCodeAsync(importInput.ItemCode).ConfigureAwait(false);
if (item == null)
{
validationRresult.Add(new ValidationResult($"物品代码{importInput.ItemCode}不存在", new[] { "物品代码" }));
}
else if (item.StdPackQty == 0)
{
validationRresult.Add(
new ValidationResult($"物品代码{importInput.ItemCode}的物品信息中标准包装等于0或不存在", new[] { "标准包装" }));
}
else
{
depDetail.ItemName = item.Name;
depDetail.ItemDesc1 = item.Desc1;
depDetail.ItemDesc2 = item.Desc2;
depDetail.StdPackQty = item.StdPackQty;
depDetail.Uom = item.BasicUom;
}
return item;
}
protected async Task<ItemStoreRelationDTO> CheckItemStoreRelationAsync(CountJobImportInput importInput,List<ValidationResult> validationRresult,string locationCode)
{
var item = await _itemStoreRelationAppService.GetByItemAndLocationAsync(importInput.ItemCode,locationCode,EnumStoreRelationType.Location).ConfigureAwait(false);
if (item == null)
{
validationRresult.Add(new ValidationResult($"零件与库位{locationCode}对应关系不存在", new[] { "物品代码" }));
}
return item;
}
protected async Task<BalanceDTO> CheckPackingCodeAsync(CountJobImportInput importInput, List<ValidationResult> validationRresult, string locationCode)
{
if (!string.IsNullOrEmpty(importInput.PackingCode))
{
var item = await _balanceAppService.GetByPackingCodeAsync(importInput.PackingCode).ConfigureAwait(false);
if (item != null)
{
if (item.LocationCode != locationCode)
{
validationRresult.Add(new ValidationResult($"箱码已经在库位{item.LocationCode}存在不能盘点", new[] { "箱码" }));
}
if (item.Lot != importInput.Lot)
{
validationRresult.Add(new ValidationResult($"批次与库存中批次{item.Lot}不匹配不能盘点", new[] { "批次" }));
}
}
return item;
}
return null;
}
protected void CheckJobNumberAsync(CountJobImportInput importInput, List<ValidationResult> validationRresult,string jobNumber)
{
if (importInput.CountJobNumber != jobNumber)
{
validationRresult.Add(new ValidationResult($"盘点任务单号{importInput.CountJobNumber}与其它有冲突,只允许导入一个任务单号数据", new[] { "盘点任务单号" }));
}
}
#endregion
/// <summary>
/// 根据条件新增job接口
/// </summary>
@ -88,6 +284,7 @@ public class CountJobAppService
}
var entity = ObjectMapper.Map<CountJobDTO, CountJob>(dto);
entity.Number = checkEntity.Number;
await _countJobManager.CompleteAsync(entity, CurrentUser).ConfigureAwait(false);
return dto;
}

10
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAutoMapperProfile.cs

@ -1,5 +1,8 @@
using System.Collections.Generic;
using AutoMapper;
using AutoMapper.Internal.Mappers;
using Volo.Abp.AutoMapper;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
@ -88,5 +91,12 @@ public partial class StoreApplicationAutoMapperProfile : Profile
;
CreateMap<CountJobDependentDetail, CountJobDetail>()
.ReverseMap();
CreateMap< CountJobImportInput, CountJobDependentDetail>()
.IgnoreAuditedObjectProperties()
.Ignore(x => x.MasterID)
.Ignore(x => x.TenantId)
.Ignore(x => x.Number)
.Ignore(x => x.Id)
;
}
}

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJob.cs

@ -95,7 +95,7 @@ public class CountJob : SfsJobAggregateRootBase<CountJobDetail>
detail.ExpireDate = expireDate;
detail.LocationCode = locationCode;
detail.CountQty = qty;
detail.CountQty = detail.CountQty +qty;
detail.CountTime = time;
detail.CountOperator = oper;
detail.CountDescription = desc;

6
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDependentDetail.cs

@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Win_in.Sfs.Shared.Domain;
namespace Win_in.Sfs.Wms.Store.Domain;
@ -51,5 +52,10 @@ public class CountJobDependentDetail : SfsJobDetailEntityBase, IHasCountResult,
/// 盘点描述
/// </summary>
public string CountDescription { get; set; }
/// <summary>
/// 是否删除
/// </summary>
[NotMapped]
public bool IsDelete { get; set; }
}

134
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs

@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Drawing;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.ObjectMapping;
@ -132,6 +133,74 @@ public class CountJobManager : SfsJobManagerBase<CountJob, CountJobDetail>, ICou
return await _repository.UpdateAsync(entity).ConfigureAwait(false);
}
/// <summary>
/// 导入盘点任务明细是调用
/// </summary>
/// <param name="entity"></param>
/// <param name="depDetails"></param>
/// <param name="user"></param>
/// <returns></returns>
public async Task<CountJob> ImportAsync( CountJob entity, List<CountJobDependentDetail> depDetails, ICurrentUser user)
{
//修改子表数据
string locationCode = entity.Details.First().LocationCode;
string locationArea = entity.Details.First().LocationArea;
string locationGroup = entity.Details.First().LocationGroup;
string locationErpCode = entity.Details.First().LocationErpCode;
string warehouseCode = entity.Details.First().WarehouseCode;
foreach (var depDetail in depDetails)
{
decimal countCount = depDetail.CountQty;
depDetail.LocationCode = locationCode;
depDetail.LocationArea = locationArea;
depDetail.LocationGroup = locationGroup;
depDetail.LocationErpCode = locationErpCode;
depDetail.WarehouseCode = warehouseCode;
depDetail.InventoryStage = entity.InventoryStage;
if (!string.IsNullOrEmpty(depDetail.PackingCode))
{
var oldDepDetail = entity.DepDetails.FirstOrDefault(r => r.ItemCode == depDetail.ItemCode && r.PackingCode == depDetail.PackingCode && r.LocationCode == locationCode && r.InventoryStage == entity.InventoryStage && r.Lot == depDetail.Lot);
if (oldDepDetail != null)
{
countCount = depDetail.CountQty - oldDepDetail.CountQty;
entity.DepDetails.Remove(oldDepDetail);
}
}
var jobDepDetail = ObjectMapper.Map<CountJobDependentDetail, CountJobDependentDetail>(depDetail);
jobDepDetail.SetIdAndNumber(GuidGenerator, entity.Id, entity.Number);
jobDepDetail.CountLabel = GuidGenerator.Create().ToString();
entity.DepDetails.Add(jobDepDetail);
var detail = entity.Details.FirstOrDefault(r => r.ItemCode == depDetail.ItemCode && r.PackingCode == depDetail.PackingCode && r.LocationCode == locationCode && r.InventoryStage == entity.InventoryStage && r.Lot == depDetail.Lot);
if (detail == null)
{
var jobDetail = ObjectMapper.Map<CountJobDependentDetail, CountJobDetail>(depDetail);
jobDetail.ArriveDate = DateTime.Now;
jobDetail.ProduceDate = DateTime.Now;
jobDetail.ExpireDate = DateTime.Parse("9999-12-31 23:59:59.9999999");
jobDetail.InventoryQty = 0;
var detailNumber = await GetNumber().ConfigureAwait(false);
jobDetail.SetIdAndNumber(GuidGenerator, entity.Id, detailNumber);
jobDetail.CountLabel = GuidGenerator.Create().ToString();
entity.Details.Add(jobDetail);
}
else
{
jobDepDetail.ArriveDate = detail.ArriveDate;
jobDepDetail.ProduceDate = detail.ProduceDate;
jobDepDetail.ExpireDate = detail.ExpireDate;
await entity.SetDetail(detail.Id, detail.SupplierBatch, detail.ArriveDate, detail.ProduceDate, detail.ExpireDate, detail.LocationCode, countCount, detail.CountTime, detail.CountOperator, detail.CountDescription)
.ConfigureAwait(false);
}
}
//移除原有明细里没有,并且第二次扫描以处的项目
entity.Details.RemoveAll(r => r.InventoryQty == 0 && r.CountQty == 0 && r.InventoryStage == entity.InventoryStage);
entity.CompleteUserId = user.Id;
entity.CompleteUserName = user.Name;
entity.CompleteTime = Clock.Now;
await PublishCompletedAsync(entity).ConfigureAwait(false);
return await _repository.UpdateAsync(entity).ConfigureAwait(false);
}
/// <summary>
/// 根据之前定义的条件生成盘点计划
/// </summary>
@ -163,8 +232,13 @@ public class CountJobManager : SfsJobManagerBase<CountJob, CountJobDetail>, ICou
return jobList;
}
private async Task SetDetailsAsync(CountJob input, CountJob entity)
/// <summary>
/// 此方法弃用
/// </summary>
/// <param name="input"></param>
/// <param name="entity"></param>
/// <returns></returns>
private async Task SetDetailsAsync_back(CountJob input, CountJob entity)
{
//将任务里所有可盘数量置为0
input.Details.ForEach(r =>
@ -219,6 +293,62 @@ public class CountJobManager : SfsJobManagerBase<CountJob, CountJobDetail>, ICou
entity.Details.RemoveAll(r => r.InventoryQty == 0 && r.CountQty == 0&& r.InventoryStage == entity.InventoryStage);
}
private async Task SetDetailsAsync(CountJob input, CountJob entity)
{
//遍历扫描明细
foreach (var depDetail in input.DepDetails.Where(r => r.InventoryStage == entity.InventoryStage))
{
decimal countCount = depDetail.CountQty;
var detail = entity.Details.FirstOrDefault(r => r.ItemCode == depDetail.ItemCode && r.PackingCode == depDetail.PackingCode && r.LocationCode == depDetail.LocationCode && r.InventoryStage == entity.InventoryStage&&r.Lot==depDetail.Lot);
var oldDepDetail = entity.DepDetails.FirstOrDefault(r => r.ItemCode == depDetail.ItemCode && r.PackingCode == depDetail.PackingCode && r.LocationCode == depDetail.LocationCode && r.InventoryStage == entity.InventoryStage && r.Lot == depDetail.Lot);
if (depDetail.IsDelete)
{
countCount = -oldDepDetail.CountQty;
entity.DepDetails.Remove(oldDepDetail);
}
else
{
if (oldDepDetail != null && depDetail.Id == oldDepDetail.Id)
{
countCount = depDetail.CountQty - oldDepDetail.CountQty;
entity.DepDetails.Remove(oldDepDetail);
}
var jobDepDetail = ObjectMapper.Map<CountJobDependentDetail, CountJobDependentDetail>(depDetail);
var number = entity.Number;
jobDepDetail.SetIdAndNumber(GuidGenerator, entity.Id, number);
jobDepDetail.CountLabel = GuidGenerator.Create().ToString();
entity.DepDetails.Add(jobDepDetail);
if (detail != null)
{
jobDepDetail.ArriveDate = detail.ArriveDate;
jobDepDetail.ProduceDate = detail.ProduceDate;
jobDepDetail.ExpireDate = detail.ExpireDate;
}
}
if (detail == null)
{
var jobDetail = ObjectMapper.Map<CountJobDependentDetail, CountJobDetail>(depDetail);
jobDetail.ArriveDate = DateTime.Now;
jobDetail.ProduceDate = DateTime.Now;
jobDetail.ExpireDate = DateTime.Parse("9999-12-31 23:59:59.9999999");
jobDetail.InventoryQty = 0;
var detailNumber = await GetNumber().ConfigureAwait(false);
jobDetail.SetIdAndNumber(GuidGenerator, entity.Id, detailNumber);
jobDetail.CountLabel = GuidGenerator.Create().ToString();
entity.Details.Add(jobDetail);
}
else
{
await entity.SetDetail(detail.Id, detail.SupplierBatch, detail.ArriveDate, detail.ProduceDate, detail.ExpireDate, detail.LocationCode, countCount, detail.CountTime, detail.CountOperator, detail.CountDescription)
.ConfigureAwait(false);
}
}
//移除原有明细里没有,并且第二次扫描以处的项目
entity.Details.RemoveAll(r => r.InventoryQty == 0 && r.CountQty == 0 && r.InventoryStage == entity.InventoryStage);
}
public override void CheckDetails(CountJob entity, AbpValidationResult result)
{
var details = entity.Details;

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/ICountJobManager.cs

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Volo.Abp.Users;
using Win_in.Sfs.Shared.Domain.Shared;
namespace Win_in.Sfs.Wms.Store.Domain;
@ -13,4 +14,5 @@ public interface ICountJobManager : IJobManager<CountJob>
Task<List<CountJob>> CreateWithConditionAsync(CountPlan entity, List<string> partCondition, List<string> locCondition, List<EnumInventoryStatus> statusList);
Task<List<CountJob>> ResetStatusByNumberAsync(List<string> numbers);
Task<CountJob> ImportAsync(CountJob entity,List<CountJobDependentDetail> depDetails, ICurrentUser user);
}

3
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs

@ -321,7 +321,8 @@ public class CountPlanManager : SfsStoreRequestManagerBase<CountPlan, CountPlanD
foreach (var planDetail in plan.Details)
{
var entityDetail = entity.Details.FirstOrDefault(p => p.CountLabel == planDetail.CountLabel);
//var entityDetail = entity.Details.FirstOrDefault(p => p.CountLabel == planDetail.CountLabel);
var entityDetail = entity.Details.FirstOrDefault(p => p.ItemCode == planDetail.ItemCode && p.PackingCode == planDetail.PackingCode&& p.Lot == planDetail.Lot &&p.LocationCode == planDetail.LocationCode);
if (entityDetail == null)
{
entityDetail = ObjectMapper.Map<CountPlanDetail, CountPlanDetail>(planDetail);

Loading…
Cancel
Save