diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ProductLineItems/Inputs/ProductionLineItemImportInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ProductLineItems/Inputs/ProductionLineItemImportInput.cs
index 689b0a3fe..4c7cb3524 100644
--- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ProductLineItems/Inputs/ProductionLineItemImportInput.cs
+++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ProductLineItems/Inputs/ProductionLineItemImportInput.cs
@@ -49,19 +49,19 @@ public class ProductionLineItemImportInput : SfsBaseDataImportInputBase
///
/// 原料库位
///
- [Display(Name = "原料库位Json集合")]
+ [Display(Name = "[来源]成品/半成品库位")]
public string RawLocationCodeListJson { get; set; }
///
/// 成品库位
///
- [Display(Name = "完工库位Json集合")]
+ [Display(Name = "[来源]原材料库位")]
public string ProductLocationCodeListJson { get; set; }
///
/// 线边库位
///
- [Display(Name = "线边库位Json集合")]
+ [Display(Name = "[完工]线边库位")]
public string WipLocationCodeListJson { get; set; }
///
diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ProductionLineItems/ProductionLineItemAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ProductionLineItems/ProductionLineItemAppService.cs
index baf8d33f7..bbd6033ee 100644
--- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ProductionLineItems/ProductionLineItemAppService.cs
+++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ProductionLineItems/ProductionLineItemAppService.cs
@@ -3,22 +3,16 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
-using DocumentFormat.OpenXml.Office2010.ExcelAc;
-using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.Caching;
using Volo.Abp.Domain.Repositories;
-using Volo.Abp.ObjectMapping;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Basedata.Domain;
using Win_in.Sfs.Basedata.Domain.Shared;
-using Win_in.Sfs.Shared.Domain;
using Win_in.Sfs.Shared.Domain.Shared;
-using Win_in.Sfs.Shared.Domain.Shared.Enums.Store;
-using static Win_in.Sfs.Basedata.Domain.BasedataSettings;
namespace Win_in.Sfs.Basedata.Application;
@@ -28,11 +22,14 @@ public class ProductionLineItemAppService :
SfsBaseDataAppServiceBase, IProductionLineItemAppService
{
- private readonly IProductionLineAppService _productionLineAppService ;
- private readonly ILocationAppService _locationAppService ;
+ private readonly IProductionLineAppService _productionLineAppService;
+ private readonly ILocationAppService _locationAppService;
private readonly IItemBasicAppService _itemBasicAppService;
+
public ProductionLineItemAppService(
- IProductionLineItemRepository repository, IDistributedCache cache, IProductionLineAppService productionLineAppService, ILocationAppService locationAppService, IItemBasicAppService itemBasicAppService
+ IProductionLineItemRepository repository, IDistributedCache cache,
+ IProductionLineAppService productionLineAppService, ILocationAppService locationAppService,
+ IItemBasicAppService itemBasicAppService
) : base(repository, cache)
{
base.CreatePolicyName = ProductionLineItemPermissions.Create;
@@ -40,7 +37,7 @@ public class ProductionLineItemAppService :
base.DeletePolicyName = ProductionLineItemPermissions.Delete;
_productionLineAppService = productionLineAppService;
_locationAppService = locationAppService;
- _itemBasicAppService= itemBasicAppService;
+ _itemBasicAppService = itemBasicAppService;
}
[HttpPost("upsert")]
@@ -49,22 +46,25 @@ public class ProductionLineItemAppService :
var entity = ObjectMapper.Map(input);
await _repository.UpdateAsync(entity).ConfigureAwait(false);
}
+
///
- /// 用来重写 导入数据时可以加工数据
+ /// 用来重写 导入数据时可以加工数据
///
///
///
- protected override async Task> ImportProcessingEntityAsync(Dictionary dictionary)
+ protected override async Task> ImportProcessingEntityAsync(
+ Dictionary dictionary)
{
var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key);
foreach (var list in addList)
{
if (!string.IsNullOrEmpty(list.RawLocationCodeListJson))
- {
- var rawlocationcodelist = list.RawLocationCodeListJson.Split(",");
- list.RawLocationCodeListJson = JsonSerializer.Serialize(rawlocationcodelist);
+ {
+ var rawlocationcodelist = list.RawLocationCodeListJson.Split(",");
+ list.RawLocationCodeListJson = JsonSerializer.Serialize(rawlocationcodelist);
}
+
if (!string.IsNullOrEmpty(list.ProductLocationCodeListJson))
{
var productlocationcodelist = list.ProductLocationCodeListJson.Split(",");
@@ -76,42 +76,49 @@ public class ProductionLineItemAppService :
var wiplocationcodelist = list.WipLocationCodeListJson.Split(",");
list.WipLocationCodeListJson = JsonSerializer.Serialize(wiplocationcodelist);
}
- var baseItem= await _itemBasicAppService.GetByCodeAsync(list.ItemCode).ConfigureAwait(false);
+
+ var baseItem = await _itemBasicAppService.GetByCodeAsync(list.ItemCode).ConfigureAwait(false);
list.ItemName = baseItem?.Name;
list.ItemDesc1 = baseItem?.Desc1;
list.ItemDesc2 = baseItem?.Desc2;
}
+
return dictionary;
}
+
protected override async Task ValidateImportModelAsync(ProductionLineItemImportInput importInput,
List validationRresult)
{
await base.ValidateImportModelAsync(importInput, validationRresult).ConfigureAwait(false);
await CheckItemBasicItemCodeAsync(importInput.ItemCode, validationRresult).ConfigureAwait(false);
await CheckProductionLineProdLineCodeAsync(importInput.ProdLineCode, validationRresult).ConfigureAwait(false);
- await CheckSameItem(importInput.ProdLineCode, importInput.ItemCode, validationRresult).ConfigureAwait(false);
- CheckProductionLineProdLineCodeJsonAsync(importInput.RawLocationCodeListJson, validationRresult);
- CheckProductionLineProdLineCodeJsonAsync(importInput.ProductLocationCodeListJson, validationRresult);
- CheckProductionLineProdLineCodeJsonAsync(importInput.WipLocationCodeListJson, validationRresult);
-
+ await CheckSameItemAsync(importInput.ProdLineCode, importInput.ItemCode, validationRresult)
+ .ConfigureAwait(false);
+ CheckProductionLineProdLineCodeJsonAsync(importInput,validationRresult);
}
- private async Task CheckSameItem(string ProdLineCode,string ItemCode, List validationRresult)
+
+ private async Task CheckSameItemAsync(string prodLineCode, string ItemCode,
+ List validationRresult)
{
- var item =await _repository.FirstOrDefaultAsync(r=>r.ProdLineCode== ProdLineCode&&r.ItemCode==ItemCode).ConfigureAwait(false);
- if (item!=null)
- {
- validationRresult.Add(new ValidationResult($"生产线{ProdLineCode}物料号{ItemCode}已存在", new string[] { "生产线", "物料号" }));
+ var item = await _repository.FirstOrDefaultAsync(r => r.ProdLineCode == prodLineCode && r.ItemCode == ItemCode)
+ .ConfigureAwait(false);
+ if (item != null)
+ {
+ validationRresult.Add(new ValidationResult($"生产线{prodLineCode}物料号{ItemCode}已存在", new[] { "生产线", "物料号" }));
}
-
}
- private void CheckProductionLineProdLineCodeJsonAsync(string locationCodeList, List validationRresult)
+
+ private void CheckProductionLineProdLineCodeJsonAsync(ProductionLineItemImportInput input ,
+ List validationRresult)
{
- if (string.IsNullOrEmpty(locationCodeList))
+ if (string.IsNullOrEmpty(input.ProductLocationCodeListJson)&&
+ string.IsNullOrEmpty(input.RawLocationCodeListJson)&&
+ string.IsNullOrEmpty(input.WipLocationCodeListJson))
{
- validationRresult.Add(new ValidationResult($"请维护生产线和库位关系"));
+ validationRresult.Add(new ValidationResult("[来源]成品/半成品库位 或 [来源]原材料库位 或 [完工]线边库位 不能都为空"));
}
-
}
+
[HttpPost("get-by-product")]
public virtual async Task> GetByProductLineCodeAsync(string productLineCode)
{
@@ -124,30 +131,34 @@ public class ProductionLineItemAppService :
string itemCode)
{
var entity = await _repository
- .FirstOrDefaultAsync(p => p.ProdLineCode == productLineCode && p.ItemCode == itemCode).ConfigureAwait(false);
+ .FirstOrDefaultAsync(p => p.ProdLineCode == productLineCode && p.ItemCode == itemCode)
+ .ConfigureAwait(false);
return ObjectMapper.Map(entity);
}
+
[HttpPost("get-by-productlinecode-and-itemcode-and-erplocationcode-async")]
- public virtual async Task> GetByProductLineCodeAndItemCodeAndErpLocationCodeAsync(List locationType, string erpLocationCodes,string itemCode)
+ public virtual async Task> GetByProductLineCodeAndItemCodeAndErpLocationCodeAsync(
+ List locationType, string erpLocationCodes, string itemCode)
{
-
- List list = new List();
- var locations= await _locationAppService.GetListByTypesAndErpCodeAsync(locationType, erpLocationCodes).ConfigureAwait(false);
+ var list = new List();
+ var locations = await _locationAppService.GetListByTypesAndErpCodeAsync(locationType, erpLocationCodes)
+ .ConfigureAwait(false);
if (locations.Count <= 0)
{
- throw new UserFriendlyException($"未维护储位基础信息!");
+ throw new UserFriendlyException("未维护储位基础信息!");
}
- else
+
+ var pls = await _productionLineAppService.GetByLocationCodesAsync(locations.Select(r => r.Code).ToList())
+ .ConfigureAwait(false);
+ var plscode = pls.Select(r => r.Code).ToList();
+ var entitys = await _repository.GetListAsync(r => r.ItemCode == itemCode && plscode.Contains(r.ProdLineCode))
+ .ConfigureAwait(false);
+ foreach (var entity in entitys)
{
- var pls= await _productionLineAppService.GetByLocationCodesAsync(locations.Select(r=>r.Code).ToList()).ConfigureAwait(false);
- var plscode = pls.Select(r => r.Code).ToList();
- var entitys= await _repository.GetListAsync(r => r.ItemCode == itemCode && plscode.Contains(r.ProdLineCode)).ConfigureAwait(false);
- foreach (var entity in entitys)
- {
- var locationcodes= JsonSerializer.Deserialize>(entity.ProductLocationCodeListJson);
- list.AddRange(locationcodes);
- }
+ var locationcodes = JsonSerializer.Deserialize>(entity.ProductLocationCodeListJson);
+ list.AddRange(locationcodes);
}
+
return list;
}
}